replace variables: some bugfixes, README comleted
This commit is contained in:
parent
0a5670cf83
commit
548dd7c055
|
@ -1,4 +1,4 @@
|
|||
## $Id: Makefile.in,v 1.11 1997/04/10 23:32:04 luethje Exp $
|
||||
## $Id: Makefile.in,v 1.12 1997/04/15 00:19:53 luethje Exp $
|
||||
##
|
||||
## ISDN accounting for isdn4linux.
|
||||
##
|
||||
|
@ -19,6 +19,9 @@
|
|||
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
##
|
||||
## $Log: Makefile.in,v $
|
||||
## Revision 1.12 1997/04/15 00:19:53 luethje
|
||||
## replace variables: some bugfixes, README comleted
|
||||
##
|
||||
## Revision 1.11 1997/04/10 23:32:04 luethje
|
||||
## Added the feature, that environment variables are allowed in the config files.
|
||||
##
|
||||
|
@ -166,7 +169,7 @@ SERVICEFILE = /etc/services
|
|||
# DON'T EDIT BELOW THIS LINE
|
||||
######################################################################
|
||||
|
||||
VERSION = 2.99.7
|
||||
VERSION = 2.99.8
|
||||
|
||||
ifeq ($(POSTGRES),1)
|
||||
DEFS += -DPOSTGRES
|
||||
|
|
126
isdnlog/README
126
isdnlog/README
|
@ -18,7 +18,8 @@ Quick-Installation-Guide
|
|||
|
||||
1. Linux-2.0.29 + isdn4kernel-2.0.29.5 verwenden:
|
||||
CONFIG_ISDN=m
|
||||
CONFIG_ISDN_DRV_TELES=m
|
||||
******* Andreas, die folgende Zeile ist wohl ueberholt!!!
|
||||
CONFIG_ISDN_DRV_TELES=m ????????????????????????????????????
|
||||
|
||||
2. isdn4k-utils.2.1.tar.gz auspacken, erstellen und installieren:
|
||||
cd /usr/src
|
||||
|
@ -28,7 +29,7 @@ Quick-Installation-Guide
|
|||
|
||||
3. Konfigurationsdatei fuer isdnlog fuellen:
|
||||
|
||||
vi | emacs | vim | e | nedit | ... | /etc/isdn/isdn.conf
|
||||
vi | emacs | vim | e | nedit | ... | /etc/isdn/callerid.conf
|
||||
|
||||
-----------------------------------------------------
|
||||
[MSN]
|
||||
|
@ -759,9 +760,14 @@ beiden Programme isdnconf und isdnrep.
|
|||
|
||||
Es koennen hier Variablen verwendet werden, die entweder in der isdn.conf
|
||||
gesetzt wurden oder vorher (z.b. auf Shellebene).
|
||||
In den Dateien "callerid.conf" und "~/.isdn" koennen keine Variablen mehr
|
||||
gesetzt werden. Das bedeutet also, dass es dort keine Sektion [VARIABLES]
|
||||
gibt.
|
||||
In den Dateien "callerid.conf" und "~/.isdn" koennen ebenfalls Variablen
|
||||
gesetzt werden. Das bedeutet also, dass es dort auch eine Sektion [VARIABLES]
|
||||
geben, wie in der "isdn.conf". Aber Achtung!! Hier koennen nur gross
|
||||
geschriebene Variablennamen verwendet werden:
|
||||
|
||||
[VARIABLES]
|
||||
fred=fred1234 # -> "FRED=fred1234" !!!!
|
||||
FRED=fred1234 # -> "FRED=fred1234"
|
||||
|
||||
Eine Variable wird allerdings nur ab dem Gleichheitszeichen ersetzt.
|
||||
|
||||
|
@ -786,6 +792,21 @@ ALIAS=${PHONE}1 # PHONE=Telefon -> "Telefon1"
|
|||
# SOUND_PATH=/home/sound RING_FILE=ring.au -> "/home/sound/ring.au"
|
||||
...
|
||||
|
||||
Wenn eine Variable nicht ersetzt werden konnte, so wird dieses angemahnt,
|
||||
und die Variable bleibt so bestehen, im Gegensatz zur bash-Shell, wo
|
||||
dann ein Leerstring ausgegeben wird:
|
||||
|
||||
...
|
||||
ALIAS = $FRED Feuerstein # -> "$FRED Feuerstein", wenn $FRED ungueltig ist.
|
||||
...
|
||||
|
||||
Wenn das "$" nicht als Zeichen fuer
|
||||
eine Variable verwendet werden soll, so muss diese mit "\$" geqoutet werden:
|
||||
|
||||
...
|
||||
ALIAS = \$PATH # -> "$PATH"
|
||||
...
|
||||
|
||||
Es gibt bestimmte Regeln, nachdem Eintraege aus der Datei "~/.isdn" die
|
||||
Eintraege der "callerid.conf" ueberschreiben:
|
||||
|
||||
|
@ -1254,7 +1275,6 @@ GROUP=201
|
|||
|
||||
Es kann also entweder der Gruppenname oder die Gruppen-ID verwendet werden.
|
||||
|
||||
*************** Bis hier ist sl gekommen, die Doku zu ueberarbeiten ***********
|
||||
Time
|
||||
----
|
||||
|
||||
|
@ -1279,10 +1299,17 @@ Wenn Time ueberhaupt nicht angegeben wird, dann bedeutet dieses "immer".
|
|||
|
||||
Beispiele:
|
||||
|
||||
IOR=/usr/bin/auplay ring.au;
|
||||
IORK=/usr/bin/auplay ring.au,5;
|
||||
IORK=/usr/bin/auplay ring.au,5,;
|
||||
...
|
||||
START={
|
||||
[FLAG]
|
||||
FLAGS = IOR
|
||||
PROGRAM = /usr/bin/auplay ring.au
|
||||
|
||||
FLAGS = IORK
|
||||
PROGRAM = /usr/bin/auplay ring.au
|
||||
INTERVAL= 5
|
||||
}
|
||||
...
|
||||
|
||||
Intervall
|
||||
---------
|
||||
|
@ -1304,32 +1331,61 @@ werden.
|
|||
Groessere Intervalle stellen kein Problem dar.
|
||||
|
||||
|
||||
Info-Arg
|
||||
--------
|
||||
Das zu startende Programm
|
||||
-------------------------
|
||||
|
||||
Hier wird das Info-Argument angegeben. Es steht dort der gesamte zu
|
||||
startende Befehl
|
||||
|
||||
Es gibt aber drei zusaetzliche Variablen, die verwendet werden duerfen:
|
||||
|
||||
$1 : Sind die Flags, die den Programmstart ausgeloest haben.
|
||||
z.B. "IR", "OC", "IH"
|
||||
Zuerst kommt die Gespraechs-Direktive und dann der Zustand
|
||||
der Verbindung. Es kommen immer _genau_ zwei Zeichen.
|
||||
$2 : Gibt als String die Telefonnummer (mit Vorwahl) des Anrufenden an.
|
||||
$3 : Gibt als String die Telefonnummer (mit Vorwahl) des Angerufenden an.
|
||||
\$1 : Sind die Flags, die den Programmstart ausgeloest haben.
|
||||
z.B. "IR", "OC", "IH"
|
||||
Zuerst kommt die Gespraechs-Direktive und dann der Zustand
|
||||
der Verbindung. Es kommen immer _genau_ zwei Zeichen.
|
||||
\$2 : Gibt als String die Telefonnummer (mit Vorwahl) des Anrufenden an.
|
||||
\$3 : Gibt als String die Telefonnummer (mit Vorwahl) des Angerufenden an.
|
||||
|
||||
Wenn bei $2 und $3 die Telefonnummer nicht bekannt ist, dann wird dort
|
||||
|
||||
Es ist zu beachten, dass hier das Zeichen "$" gequotet werden muss,
|
||||
da dieses sonst zu einem Warning fuehrt!
|
||||
|
||||
Wenn bei "\$2" und "\$3" die Telefonnummer nicht bekannt ist, dann wird dort
|
||||
ein "?" eingesetzt.
|
||||
|
||||
Es fallen also alle Blanks und Tabulatoren vor und nach dem "=" heraus.
|
||||
"IORK = /bin/auplay..." wird also zu "IORK=/bin/auplay...".
|
||||
|
||||
Eine (zwei) Zeile in der Spalte Info-Agrs kann also wie folgt aussehen:
|
||||
Eine (zwei) Section [NUMBER] (oder [MSN]) kann also wie folgt aussehen:
|
||||
|
||||
4711 Phone 1 IORK= /bin/auplay /sounds/ring.au,1,8-14,16-22;\
|
||||
OA = /bin/auplay /sounds/money.au,,8-14,16-22;
|
||||
0815 Provider 2 IOCK= /bin/popclient_script $3,300;
|
||||
[MSN]
|
||||
NUMBER = 4711
|
||||
ALIAS = Phone
|
||||
ZONE = 1
|
||||
START={
|
||||
[FLAG]
|
||||
FLAGS = IORK
|
||||
PROGRAM = /bin/auplay /sounds/ring.au
|
||||
INTERVAL= 1
|
||||
TIME = 8-14,16-22
|
||||
|
||||
[FLAG]
|
||||
FLAGS = OA
|
||||
PROGRAM = /bin/auplay /sounds/money.au
|
||||
TIME = 8-14,16-22
|
||||
}
|
||||
|
||||
[NUMBER]
|
||||
NUMBER = 0815/1234
|
||||
ALIAS = Provider
|
||||
ZONE = 2
|
||||
START={
|
||||
|
||||
[FLAG]
|
||||
FLAGS = IOCK
|
||||
PROGRAM = /bin/popclient_script \$3
|
||||
INTERVAL= 300
|
||||
}
|
||||
|
||||
Angenommen 4711 ist die MSN meines Telefons, dann wird beim Rauswaehlen
|
||||
erst immer "/bin/auplay /sounds/ring.au" abgespielt. Auch wenn das Telefon
|
||||
|
@ -1341,20 +1397,38 @@ Diese Sounds werden nur von 8Uhr bis 14Uhr und 16Uhr bis 22Uhr gespielt.
|
|||
|
||||
Wenn man zum "Provider" verbunden ist, dann werden alle 5 Minuten Mails
|
||||
geholt. Da hier keine Zeitangabe gemacht wurde, wird das Script zu
|
||||
jeder Zeit ausgefuehrt. Das Script bekommt als Parameter "0815", wenn
|
||||
jeder Zeit ausgefuehrt. Das Script bekommt als Parameter "0815/1234", wenn
|
||||
man "Provider" angerufen hat, und wenn "Provider" einen anruft, seine
|
||||
eigene MSN.
|
||||
|
||||
Wie unter "START=" beschrieben wurde, ist hier noch mal ein Beispiel
|
||||
zu finden:
|
||||
|
||||
...
|
||||
[VARIABLES]
|
||||
CMD1=/bin/auplay
|
||||
CMD2=/bin/my_prog
|
||||
DIR = /sounds/
|
||||
START=IORK=$CMD1 ${DIR}ring.au,1,8-14,16-22;\
|
||||
OA =$CMD1 ${DIR}money.au,,8-14,16-22;\
|
||||
IOC =$CMD2 $1 $2 $3,,8-14,16-22;
|
||||
|
||||
START={
|
||||
[FLAG]
|
||||
FLAGS = I|O|R|K
|
||||
PROGRAM = $CMD1 ${DIR}ring.au
|
||||
INTERVAL= 1
|
||||
TIME = 8-14,16-22
|
||||
|
||||
[FLAG]
|
||||
FLAGS = O|A
|
||||
PROGRAM = $CMD1 ${DIR}money.au
|
||||
TIME = 8-14,16-22
|
||||
|
||||
[FLAG]
|
||||
FLAGS = I|O|C
|
||||
PROGRAM = $CMD2 \$1 \$2 \$3
|
||||
TIME = 8-14,16-22
|
||||
}
|
||||
|
||||
*************** Bis hier ist sl gekommen, die Doku zu ueberarbeiten ***********
|
||||
Die letzte Zeile wird also wie folgt expandiert als Kommando, wenn ich
|
||||
jemanden anrufe mit der Nummer 0815 (Meine MSN 040/1234):
|
||||
"/bin/auplay OC 0401234 0815"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdnconf.c,v 1.5 1997/04/10 23:32:15 luethje Exp $
|
||||
/* $Id: isdnconf.c,v 1.6 1997/04/15 00:20:01 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (Report-module)
|
||||
*
|
||||
|
@ -19,6 +19,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: isdnconf.c,v $
|
||||
* Revision 1.6 1997/04/15 00:20:01 luethje
|
||||
* replace variables: some bugfixes, README comleted
|
||||
*
|
||||
* Revision 1.5 1997/04/10 23:32:15 luethje
|
||||
* Added the feature, that environment variables are allowed in the config files.
|
||||
*
|
||||
|
@ -306,14 +309,23 @@ int look_data(section **conf_dat)
|
|||
_si[0] = '\0';
|
||||
|
||||
if ((CEPtr = Get_Entry((*conf_dat)->entries,CONF_ENT_NUM)) != NULL)
|
||||
_number = strdup(Replace_Variable(CEPtr->value));
|
||||
if (del)
|
||||
_number = strdup(Replace_Variable(CEPtr->value));
|
||||
else
|
||||
_number = strdup(CEPtr->value);
|
||||
|
||||
if ((CEPtr = Get_Entry((*conf_dat)->entries,CONF_ENT_ALIAS)) != NULL)
|
||||
_alias = strdup(Replace_Variable(CEPtr->value));
|
||||
if (del)
|
||||
_alias = strdup(Replace_Variable(CEPtr->value));
|
||||
else
|
||||
_alias = strdup(CEPtr->value);
|
||||
|
||||
if ((CEPtr = Get_Entry((*conf_dat)->entries,CONF_ENT_SI)) != NULL &&
|
||||
CEPtr->value != NULL)
|
||||
sprintf(_si,"%ld",strtol(Replace_Variable(CEPtr->value), NIL, 0));
|
||||
if (del)
|
||||
sprintf(_si,"%ld",strtol(Replace_Variable(CEPtr->value), NIL, 0));
|
||||
else
|
||||
sprintf(_si,"%ld",strtol(CEPtr->value, NIL, 0));
|
||||
|
||||
if (and)
|
||||
Ret = 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdnconf.c,v 1.4 1997/04/10 23:32:24 luethje Exp $
|
||||
/* $Id: isdnconf.c,v 1.5 1997/04/15 00:20:07 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (Utilities)
|
||||
*
|
||||
|
@ -913,7 +913,7 @@ static int _readconfig(char *_myname)
|
|||
if ((SPtr = read_isdnconf(&conf_dat)) == NULL)
|
||||
return -1;
|
||||
|
||||
if (Replace_Variables(conf_dat))
|
||||
if (Replace_Variables(conf_dat) != 0)
|
||||
return -1;
|
||||
|
||||
Set_Globals(conf_dat);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: conffile.c,v 1.13 1997/04/10 23:41:26 luethje Exp $
|
||||
/* $Id: conffile.c,v 1.14 1997/04/15 00:20:13 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
|
@ -19,6 +19,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: conffile.c,v $
|
||||
* Revision 1.14 1997/04/15 00:20:13 luethje
|
||||
* replace variables: some bugfixes, README comleted
|
||||
*
|
||||
* Revision 1.13 1997/04/10 23:41:26 luethje
|
||||
* some bug fixes
|
||||
*
|
||||
|
@ -580,7 +583,7 @@ static entry* Append_Entry(entry** Entry, char *Variable, char* Value, section *
|
|||
|
||||
if (Value != NULL)
|
||||
{
|
||||
if (((*Entry)->value = strdup(Value)) == NULL)
|
||||
if (((*Entry)->value = strdup(Value)) == NULL)
|
||||
{
|
||||
free_entry(*Entry);
|
||||
*Entry = NULL;
|
||||
|
@ -1546,13 +1549,14 @@ int Replace_Variables(section *Section)
|
|||
{
|
||||
if (Entry->value != NULL && (Ptr = Replace_Variable(Entry->value)) != NULL)
|
||||
{
|
||||
free(Entry->value);
|
||||
|
||||
if ((Entry->value = strdup(Ptr)) == NULL)
|
||||
if ((Ptr = strdup(Ptr)) == NULL)
|
||||
{
|
||||
print_msg("%s","Can not allocate memory!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(Entry->value);
|
||||
Entry->value = Ptr;
|
||||
}
|
||||
|
||||
Entry = Entry->next;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
/* $Id: conffile.h,v 1.6 1997/04/10 23:32:34 luethje Exp $
|
||||
/* $Id: conffile.h,v 1.7 1997/04/15 00:20:16 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
|
@ -20,6 +20,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: conffile.h,v $
|
||||
* Revision 1.7 1997/04/15 00:20:16 luethje
|
||||
* replace variables: some bugfixes, README comleted
|
||||
*
|
||||
* Revision 1.6 1997/04/10 23:32:34 luethje
|
||||
* Added the feature, that environment variables are allowed in the config files.
|
||||
*
|
||||
|
@ -41,11 +44,11 @@
|
|||
|
||||
/****************************************************************************/
|
||||
|
||||
#define C_OVERWRITE 1
|
||||
#define C_WARN 2
|
||||
#define C_NOT_UNIQUE 4
|
||||
#define C_APPEND 8
|
||||
#define C_NO_WARN_FILE 16
|
||||
#define C_OVERWRITE 1
|
||||
#define C_WARN 2
|
||||
#define C_NOT_UNIQUE 4
|
||||
#define C_APPEND 8
|
||||
#define C_NO_WARN_FILE 16
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdntools.c,v 1.10 1997/04/08 21:57:04 luethje Exp $
|
||||
/* $Id: isdntools.c,v 1.11 1997/04/15 00:20:17 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (Utilities)
|
||||
*
|
||||
|
@ -19,6 +19,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: isdntools.c,v $
|
||||
* Revision 1.11 1997/04/15 00:20:17 luethje
|
||||
* replace variables: some bugfixes, README comleted
|
||||
*
|
||||
* Revision 1.10 1997/04/08 21:57:04 luethje
|
||||
* Create the file isdn.conf
|
||||
* some bug fixes for pid and lock file
|
||||
|
@ -555,7 +558,9 @@ int Set_Codes(section* Section)
|
|||
print_msg("Error: Variable `%s' are not set!\n",CONF_ENT_COUNTRY);
|
||||
}
|
||||
|
||||
if ((SPtr = Get_Section(Section,CONF_SEC_VAR)) != NULL)
|
||||
SPtr = Section;
|
||||
|
||||
while ((SPtr = Get_Section(SPtr,CONF_SEC_VAR)) != NULL)
|
||||
{
|
||||
Entry = SPtr->entries;
|
||||
|
||||
|
@ -566,6 +571,8 @@ int Set_Codes(section* Section)
|
|||
|
||||
Entry = Entry->next;
|
||||
}
|
||||
|
||||
SPtr = SPtr->next;
|
||||
}
|
||||
|
||||
return (RetCode==2?0:-1);
|
||||
|
|
136
lib/libtools.c
136
lib/libtools.c
|
@ -1,4 +1,4 @@
|
|||
/* $Id: libtools.c,v 1.4 1997/04/10 23:32:35 luethje Exp $
|
||||
/* $Id: libtools.c,v 1.5 1997/04/15 00:20:18 luethje Exp $
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
* Copyright 1996 by Stefan Luethje (luethje@sl-gw.lake.de)
|
||||
|
@ -18,6 +18,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: libtools.c,v $
|
||||
* Revision 1.5 1997/04/15 00:20:18 luethje
|
||||
* replace variables: some bugfixes, README comleted
|
||||
*
|
||||
* Revision 1.4 1997/04/10 23:32:35 luethje
|
||||
* Added the feature, that environment variables are allowed in the config files.
|
||||
*
|
||||
|
@ -41,6 +44,10 @@
|
|||
|
||||
/****************************************************************************/
|
||||
|
||||
#define SET_BEGIN_VAR 1
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
static int (*print_msg)(const char *, ...) = printf;
|
||||
|
||||
/****************************************************************************/
|
||||
|
@ -480,7 +487,7 @@ int is_double (char *string, double *value)
|
|||
dummy = (char*) alloca((strlen(string)+1)*sizeof(char));
|
||||
|
||||
if (value == NULL)
|
||||
*value = dummy2;
|
||||
value = &dummy2;
|
||||
|
||||
return (sscanf(string,"%lf%s",value,dummy) == 1);
|
||||
}
|
||||
|
@ -498,7 +505,7 @@ int is_integer (char *string, long int *value)
|
|||
dummy = (char*) alloca((strlen(string)+1)*sizeof(char));
|
||||
|
||||
if (value == NULL)
|
||||
*value = dummy2;
|
||||
value = &dummy2;
|
||||
|
||||
return (sscanf(string,"%ld%s",value,dummy) == 1);
|
||||
}
|
||||
|
@ -512,92 +519,105 @@ char *Replace_Variable(char *String)
|
|||
char *Var = NULL;
|
||||
char *End = NULL;
|
||||
char *Value = NULL;
|
||||
int num;
|
||||
char *Ptr = String;
|
||||
int cnt = 0;
|
||||
int num = 0;
|
||||
|
||||
|
||||
while ((Ptr = strchr(Ptr,C_BEGIN_VAR)) != NULL)
|
||||
{
|
||||
cnt++;
|
||||
Ptr++;
|
||||
}
|
||||
|
||||
if (!cnt)
|
||||
return String;
|
||||
|
||||
if (RetCode != NULL)
|
||||
free(RetCode);
|
||||
|
||||
if ((RetCode = strdup(String)) == NULL ||
|
||||
(Var = strdup(RetCode)) == NULL ||
|
||||
(End = strdup(RetCode)) == NULL ||
|
||||
(Begin = strdup(RetCode)) == NULL )
|
||||
(End = strdup(RetCode)) == NULL )
|
||||
{
|
||||
print_msg("%s!\n","Can not alllocate memory!\n");
|
||||
print_msg("%s!\n","Error: Can not allocate memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Begin[0] ='\0';
|
||||
|
||||
while ((num = sscanf(RetCode,"%[^$]$%[0-9a-zA-Z]%[^\n]",Begin,Var,End)+1) > 2 ||
|
||||
(num = sscanf(RetCode,"%[^$]${%[0-9a-zA-Z]}%[^\n]",Begin,Var,End)+1) > 2 ||
|
||||
(num = sscanf(RetCode,"$%[0-9a-zA-Z]%[^\n]",Var,End)) > 0 ||
|
||||
(num = sscanf(RetCode,"${%[0-9a-zA-Z]}%[^\n]",Var,End)) > 0 )
|
||||
while ((Ptr = strchr(RetCode,C_BEGIN_VAR)) != NULL)
|
||||
{
|
||||
if ((num > 2 && Begin[strlen(Begin)-1] == C_QUOTE_CHAR) || (Value = getenv(Var)) == NULL)
|
||||
if (Ptr != RetCode && Ptr[-1] == C_QUOTE_CHAR)
|
||||
{
|
||||
RetCode[strlen(Begin)] = 1;
|
||||
|
||||
if (strlen(Begin) > 0)
|
||||
memmove(RetCode+strlen(Begin)-1,RetCode+strlen(Begin),strlen(RetCode)-strlen(Begin)+1);
|
||||
*Ptr = SET_BEGIN_VAR;
|
||||
memmove(Ptr-1,Ptr,strlen(RetCode)-(Ptr-RetCode-1));
|
||||
cnt--;
|
||||
}
|
||||
else
|
||||
if (Value != NULL)
|
||||
if ((num = sscanf(Ptr+1,"%[0-9a-zA-Z]%[^\n]",Var,End)) >= 1 ||
|
||||
(num = sscanf(Ptr+1,"{%[0-9a-zA-Z]}%[^\n]",Var,End)) >= 1 )
|
||||
{
|
||||
if ((RetCode = (char*) realloc(RetCode,sizeof(char)*(strlen(RetCode)+strlen(Value)-strlen(Var)))) == NULL)
|
||||
if ((Value = getenv(Var)) != NULL)
|
||||
{
|
||||
print_msg("%s!\n","Can not alllocate memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
free(Begin);
|
||||
|
||||
switch(num)
|
||||
if ((Begin = strdup(RetCode)) == NULL)
|
||||
{
|
||||
print_msg("%s!\n","Error: Can not allocate memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Begin[Ptr-RetCode] = '\0';
|
||||
|
||||
if ((RetCode = (char*) realloc(RetCode,sizeof(char)*strlen(RetCode)+strlen(Value)-strlen(Var))) == NULL)
|
||||
{
|
||||
print_msg("%s!\n","Error: Can not allocate memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (num == 1)
|
||||
*End = '\0';
|
||||
|
||||
sprintf(RetCode,"%s%s%s",Begin,Value,End);
|
||||
|
||||
free(Var);
|
||||
free(End);
|
||||
|
||||
if ((Var = strdup(RetCode)) == NULL ||
|
||||
(End = strdup(RetCode)) == NULL )
|
||||
{
|
||||
print_msg("%s!\n","Error: Can not allocate memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cnt--;
|
||||
}
|
||||
else
|
||||
{
|
||||
case 1: sprintf(RetCode,"%s",Value);
|
||||
break;
|
||||
case 2: sprintf(RetCode,"%s%s",Value,End);
|
||||
break;
|
||||
case 3: sprintf(RetCode,"%s%s",Begin,Value);
|
||||
break;
|
||||
case 4: sprintf(RetCode,"%s%s%s",Begin,Value,End);
|
||||
break;
|
||||
default: break;
|
||||
*Ptr = SET_BEGIN_VAR;
|
||||
cnt--;
|
||||
|
||||
print_msg("Warning: Unknown variable `%s'!\n",Var);
|
||||
}
|
||||
|
||||
free(Begin);
|
||||
free(Var);
|
||||
free(End);
|
||||
|
||||
if ((Var = strdup(RetCode)) == NULL ||
|
||||
(End = strdup(RetCode)) == NULL ||
|
||||
(Begin = strdup(RetCode)) == NULL )
|
||||
{
|
||||
print_msg("%s!\n","Can not alllocate memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Begin[0] ='\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
print_msg("Invalid variable `%s'!\n",Var);
|
||||
free(RetCode);
|
||||
RetCode = NULL;
|
||||
break;
|
||||
}
|
||||
*Ptr = SET_BEGIN_VAR;
|
||||
}
|
||||
|
||||
if (cnt)
|
||||
print_msg("Warning: Invalid token in string `%s'!\n",String);
|
||||
|
||||
free(Begin);
|
||||
free(Var);
|
||||
free(End);
|
||||
|
||||
if ((Begin = RetCode) != NULL)
|
||||
if ((Ptr = RetCode) != NULL)
|
||||
{
|
||||
while (*Begin != '\0')
|
||||
while (*Ptr != '\0')
|
||||
{
|
||||
if (*Begin == 1)
|
||||
*Begin = '$';
|
||||
if (*Ptr == SET_BEGIN_VAR)
|
||||
*Ptr = C_BEGIN_VAR;
|
||||
|
||||
Begin++;
|
||||
Ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: libtools.h,v 1.4 1997/04/10 23:32:35 luethje Exp $
|
||||
/* $Id: libtools.h,v 1.5 1997/04/15 00:20:19 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
|
@ -19,6 +19,9 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: libtools.h,v $
|
||||
* Revision 1.5 1997/04/15 00:20:19 luethje
|
||||
* replace variables: some bugfixes, README comleted
|
||||
*
|
||||
* Revision 1.4 1997/04/10 23:32:35 luethje
|
||||
* Added the feature, that environment variables are allowed in the config files.
|
||||
*
|
||||
|
@ -60,6 +63,7 @@ extern char *basename __P((__const char *__name));
|
|||
#define QUOTE_DELETE 1
|
||||
|
||||
#define C_QUOTE_CHAR '\\'
|
||||
#define C_BEGIN_VAR '$'
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
|
Loading…
Reference in New Issue