From e4885444576a27c5678c57f3c917849117900738 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Tue, 22 Oct 2002 15:31:47 +0000 Subject: [PATCH] Version 0.3.0 from FTP git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@539 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- chanvars.c | 88 +++++++++++++++++++++++-------- configs/modem.conf.sample | 23 ++++++++ contrib/init.d/rc.redhat.asterisk | 8 ++- include/asterisk/chanvars.h | 13 +++++ init.asterisk | 8 ++- 5 files changed, 107 insertions(+), 33 deletions(-) diff --git a/chanvars.c b/chanvars.c index 70324b161b..6f8e8475ee 100755 --- a/chanvars.c +++ b/chanvars.c @@ -1,39 +1,81 @@ -#include +/* + * Asterisk -- A telephony toolkit for Linux. + * + * Channel Variables + * + * Copyright (C) 2002, Mark Spencer + * + * Mark Spencer + * + * This program is free software, distributed under the terms of + * the GNU General Public License + */ + #include #include -struct ast_var_t *ast_var_assign(char *name,char *value) { +#include +#include + +struct ast_var_t *ast_var_assign(char *name, char *value) +{ int i; struct ast_var_t *var; - var=malloc(sizeof(struct ast_var_t)); + var = malloc(sizeof(struct ast_var_t)); + + if (var == NULL) + { + ast_log(LOG_WARNING, "Out of memory\n"); + return NULL; + } - i=strlen(value); - var->value=malloc(i+1); - strncpy(var->value,value,i); - var->value[i]='\0'; + i = strlen(value); + var->value = malloc(i + 1); + if (var->value == NULL) + { + ast_log(LOG_WARNING, "Out of memory\n"); + free(var); + return NULL; + } + + strncpy(var->value, value, i); + var->value[i] = '\0'; - i=strlen(name); - var->name=malloc(i+1); - strncpy(var->name,name,i); - var->name[i]='\0'; - return(var); + i = strlen(name); + var->name = malloc(i + 1); + if (var->name == NULL) + { + ast_log(LOG_WARNING, "Out of memory\n"); + free(var->value); + free(var); + return NULL; + } + + strncpy(var->name, name, i); + var->name[i] = '\0'; + + return var; } -void ast_var_delete(struct ast_var_t *var) { - if (var!=NULL) { - if (var->name!=NULL) free(var->name); - if (var->value!=NULL) free(var->value); - free(var); - } +void ast_var_delete(struct ast_var_t *var) +{ + if (var == NULL) return; + + if (var->name != NULL) free(var->name); + if (var->value != NULL) free(var->value); + + free(var); } -char *ast_var_name(struct ast_var_t *var) { - return(var->name); +char *ast_var_name(struct ast_var_t *var) +{ + return (var != NULL ? var->name : NULL); } -char *ast_var_value(struct ast_var_t *var) { - return(var->value); +char *ast_var_value(struct ast_var_t *var) +{ + return (var != NULL ? var->value : NULL); } - \ No newline at end of file + diff --git a/configs/modem.conf.sample b/configs/modem.conf.sample index 1a75b7fbb1..d177502dfd 100755 --- a/configs/modem.conf.sample +++ b/configs/modem.conf.sample @@ -49,3 +49,26 @@ mode=immediate ; ;msn=39907835 ;device => /dev/ttyI0 + +;=============== +; More complex ISDN example +; +; A single device which listens to 3 MSNs +; the wildcard '*' can be used when all MSN's should be accepted. +; (The incoming number can be used to go directly into the extension +; with the matching number. I.e. if MSN 33 is called, (context,33) +; will tried first, than (context,s) and finally (default,s). +; +;msn=50780020 +;incomingmsn=50780020,50780021,50780022 +;device => /dev/ttyI2 +; +; two other devices, which are in group '1' and are used when an +; outgoing dial used: exten => s,1,Dial,Modem/g1:1234|60|r +; (we do not need more outgoing devices, since ISDN2 has only 2 channels.) +; Lines can be in more than one group (1-31); comma seperated list. +; +group=1 ; group=1,2,3,9-12 +;msn=50780023 +;device => /dev/ttyI3 +;device => /dev/ttyI4 diff --git a/contrib/init.d/rc.redhat.asterisk b/contrib/init.d/rc.redhat.asterisk index 09d5e269a2..bc421beb36 100755 --- a/contrib/init.d/rc.redhat.asterisk +++ b/contrib/init.d/rc.redhat.asterisk @@ -1,13 +1,11 @@ #!/bin/sh # -# asterisk This shell script takes care of starting and stopping -# asterisk (printer daemon). +# asterisk This shell script takes care of starting and stopping Asterisk. +# # # chkconfig: 2345 60 60 -# description: asterisk is the print daemon required for lpr to work properly. \ -# It is basically a server that arbitrates print jobs to printer(s). +# description: Asterisk is the Linux based PBX # processname: asterisk -# config: /etc/printcap # Source function library. . /etc/rc.d/init.d/functions diff --git a/include/asterisk/chanvars.h b/include/asterisk/chanvars.h index 0e20c536e5..d37c159ee4 100755 --- a/include/asterisk/chanvars.h +++ b/include/asterisk/chanvars.h @@ -1,3 +1,16 @@ +/* + * Asterisk -- A telephony toolkit for Linux. + * + * Channel Variables + * + * Copyright (C) 2002, Mark Spencer + * + * Mark Spencer + * + * This program is free software, distributed under the terms of + * the GNU General Public License + */ + #ifndef _ASTERISK_CHANVARS_INCLUDE #define _ASTERISK_CHANVARS_INCLUDE diff --git a/init.asterisk b/init.asterisk index 09d5e269a2..bc421beb36 100755 --- a/init.asterisk +++ b/init.asterisk @@ -1,13 +1,11 @@ #!/bin/sh # -# asterisk This shell script takes care of starting and stopping -# asterisk (printer daemon). +# asterisk This shell script takes care of starting and stopping Asterisk. +# # # chkconfig: 2345 60 60 -# description: asterisk is the print daemon required for lpr to work properly. \ -# It is basically a server that arbitrates print jobs to printer(s). +# description: Asterisk is the Linux based PBX # processname: asterisk -# config: /etc/printcap # Source function library. . /etc/rc.d/init.d/functions