Bugfix: isdnlog is running again ;-)
isdnlog creates now a file like /var/lock/LCK..isdnctrl0 README completed Added some values (countrycode, areacode, lock dir and lock file) to the global menu
This commit is contained in:
parent
e27f329e0d
commit
d5215e576a
|
@ -1,4 +1,4 @@
|
|||
## $Id: Makefile.in,v 1.8 1997/04/06 21:07:25 luethje Exp $
|
||||
## $Id: Makefile.in,v 1.9 1997/04/08 00:02:05 luethje Exp $
|
||||
##
|
||||
## ISDN accounting for isdn4linux.
|
||||
##
|
||||
|
@ -19,6 +19,13 @@
|
|||
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
##
|
||||
## $Log: Makefile.in,v $
|
||||
## Revision 1.9 1997/04/08 00:02:05 luethje
|
||||
## Bugfix: isdnlog is running again ;-)
|
||||
## isdnlog creates now a file like /var/lock/LCK..isdnctrl0
|
||||
## README completed
|
||||
## Added some values (countrycode, areacode, lock dir and lock file) to
|
||||
## the global menu
|
||||
##
|
||||
## Revision 1.8 1997/04/06 21:07:25 luethje
|
||||
## renamed file isdnrep.c to rep_main.c and function.c to isdnrep.c
|
||||
##
|
||||
|
@ -135,7 +142,7 @@ SERVICEFILE = /etc/services
|
|||
# DON'T EDIT BELOW THIS LINE
|
||||
######################################################################
|
||||
|
||||
VERSION = 2.99.4
|
||||
VERSION = 2.99.5
|
||||
|
||||
ifeq ($(POSTGRES),1)
|
||||
DEFS += -DPOSTGRES
|
||||
|
|
|
@ -196,7 +196,9 @@ Ein Bitte noch:
|
|||
|
||||
Alle Anfragen zum isdnlog nicht an meine Email-Adresse senden, sondern an
|
||||
|
||||
isdnlog@Kool.f.EUnet.de
|
||||
i4l-isdnlog@franken.de
|
||||
|
||||
Bitte auch nicht mehr die alte Adresse isdnlog@Kool.f.EUnet.de verwenden.
|
||||
|
||||
So bekommen alle Entwickler die Anfragen direkt mit, und muessen nicht
|
||||
von mir extra weitergeleitet werden. Dadurch wird die Anfrage mit
|
||||
|
@ -216,7 +218,6 @@ subscribe "emailadresse"
|
|||
stehen.
|
||||
|
||||
|
||||
|
||||
1. Was kann/ist/macht isdnlog?
|
||||
------------------------------
|
||||
|
||||
|
@ -474,7 +475,9 @@ relevanten Steuerungsparameter.
|
|||
|
||||
Diese Datei muss dem User root gehoeren (auch die Gruppe). Auch nur dieser
|
||||
darf Schreibrechte an dieser Datei haben. Diese Datei wird auch vom isdnlog
|
||||
gelesen.
|
||||
gelesen. Andernfalls beendet sich der isdnlog sofort wieder. Dieses ist ein
|
||||
Schutz, um Trojanische Pferde zu verhindern und kann auch nicht ausgeschaltet
|
||||
werden.
|
||||
|
||||
Wenn man dem compilierten den Pfad aendern will, muss man die
|
||||
Umgebungsvariable "ISDN_CONF_PATH" setzen.
|
||||
|
@ -550,6 +553,20 @@ Beispiel:
|
|||
[VARIABLES]
|
||||
MYPATH = /home/fred
|
||||
|
||||
Es duerfen als Variablennamen nur noch gross geschriebene Woerter verwendet
|
||||
werden. Ein Eintrag der Form
|
||||
|
||||
myPath = /home/fred
|
||||
|
||||
oder
|
||||
|
||||
mypath = /home/fred
|
||||
|
||||
werden z.B. unter der /bin/sh mit "MYPATH=/home/fred" gesetzt.
|
||||
Hier gibt auch keine andere Möglichkeit das zu aendern. Wenn Kleinbuschstaben
|
||||
verwendet werden sollen, muessen diese vor dem Start von isdnlog mit
|
||||
export (sh, bash) oder setenv (csh) unter der Shell gesetzt werden.
|
||||
|
||||
ACHTUNG: "MYPATH = /home/fred" wird als Variable zu "MYPATH=/home/fred".
|
||||
Es fallen also alle Blanks und Tabulatoren vor und nach dem "="
|
||||
heraus.
|
||||
|
@ -571,7 +588,7 @@ Diese Datei wird seit der Version 3.0 vom isdnlog nicht mehr staendig offen
|
|||
gehalten, sondern nur noch nach Beendigung eines Gespraeches wird die Datei
|
||||
geoeffnet, der Eintrag ergaenzt und anschliessend wieder geschlossen.
|
||||
Dadurch ist es jetzt moeglich diese Datei zu verschieben, wenn der isdnlog
|
||||
laeuft.
|
||||
laeuft und gerade kein Gespraech beendet wird.
|
||||
|
||||
RELOADCMD = reload
|
||||
|
||||
|
@ -730,7 +747,9 @@ Partner-Telefonnummern koennen eingeben werden.
|
|||
|
||||
Die Datei "callerid.conf" liegt im Verzeichnis /etc/isdn und muss dem User
|
||||
root gehoeren (auch die Gruppe). Auch nur dieser darf Schreibrechte an dieser
|
||||
Datei haben. Diese Datei wird auch vom isdnlog gelesen.
|
||||
Datei haben. Diese Datei wird auch vom isdnlog gelesen. Es ist die globale
|
||||
Datei fuer die Telefonnummern. Hier muessen auch die [MSN]-Eintraege
|
||||
untergebracht werden.
|
||||
|
||||
Die Datei "~/.isdn" kann jeder Benutzer haben, der den isdnrep und den isdnconf
|
||||
verwendet. Hier sind die Rechte der Datei voellig egal. Diese Datei ist
|
||||
|
@ -1366,6 +1385,36 @@ kommt. So wie "/usr/bin/auplay" beendet ist, wird es wieder neu gestartet.
|
|||
Die Flags "OR" haben allerdings keine Bedeutung fuer andere Geraete am S0-Bus,
|
||||
da die ISDN-Karte die Ring-Phase von anderen Geraeten am Bus nicht mitbekommt.
|
||||
|
||||
Kommentare in der in der Telefonnummerndateien:
|
||||
|
||||
Es koennen koennen Kommentare an beliebiger Stelle beginnend mit de Zeichen
|
||||
'#' eingefuegt werden (siehe lib/README.Syntax.conffile).
|
||||
Diese Kommentare haben den Nachteil, dass sie verschwinden, wenn die Datei
|
||||
z.B. vom isdnconf (oder auch vom isdnlog selber) neu geschrieben werden.
|
||||
Als Alternative gibt es dort die Moeglichkeit in den Sektionen einfach
|
||||
Dummy-Eintraege zu setzen. Diese sind Eintraege, die von isdnlog nicht
|
||||
ausgewertet werden, aber trotzdem eingelesen werden und auch wieder geschrieben
|
||||
werden.
|
||||
|
||||
Beispiel
|
||||
|
||||
[isdnlog]
|
||||
comment1 = Pro Tag duerfen max. 100 DM fuer Datenverbindungen ausgegeben \
|
||||
werden.
|
||||
CHARGEMAX = 100.00
|
||||
comment2 = Das Logfile liegt unter /var/log/isdn.log
|
||||
logfile = /var/log/isdn.log
|
||||
|
||||
|
||||
Die beiden Eintraege "comment1" und "comment2" bleiben erhalten. auch die
|
||||
Reihenfolge bleibt bestehen. Es ist nur darauf zu achten, dass kein
|
||||
Eintrag den selben Namen hat. Also zweimal die Zeile "comment" geht nicht.
|
||||
Dann wird die erste Zeile durch die zweite ersetzt. Es ist auch darauf zu
|
||||
achten, dass der Name des Eintrages nicht schon von isdnlog verwendet wird.
|
||||
Also ein Kommentar mit "SI" zu benennen schlaegt fehlt, da dieser Name
|
||||
schon reserviert ist.
|
||||
|
||||
|
||||
|
||||
5. Die Konfigurationsdatei "isdnlog.users"
|
||||
------------------------------------------
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: functions.c,v 1.5 1997/04/06 22:04:20 luethje Exp $
|
||||
/* $Id: functions.c,v 1.6 1997/04/08 00:02:12 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (log-module)
|
||||
*
|
||||
|
@ -17,6 +17,15 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
*
|
||||
* $Log: functions.c,v $
|
||||
* Revision 1.6 1997/04/08 00:02:12 luethje
|
||||
* Bugfix: isdnlog is running again ;-)
|
||||
* isdnlog creates now a file like /var/lock/LCK..isdnctrl0
|
||||
* README completed
|
||||
* Added some values (countrycode, areacode, lock dir and lock file) to
|
||||
* the global menu
|
||||
*
|
||||
*/
|
||||
|
||||
#define _FUNCTIONS_C_
|
||||
|
@ -82,7 +91,7 @@ void _Exit(char *File, int Line, int RetCode) /* WARNING: RetCode==-9 does _not_
|
|||
|
||||
if (!replay) {
|
||||
saveCharge();
|
||||
delete_runfile(pidfile);
|
||||
handle_runfiles(NULL,NULL,STOP_PROG);
|
||||
} /* if */
|
||||
|
||||
if (RetCode != -9)
|
||||
|
@ -162,34 +171,38 @@ void logger(int chan)
|
|||
call[chan].pay = 0.0;
|
||||
} /* if */
|
||||
|
||||
tries = 0;
|
||||
|
||||
if (access(logfile,W_OK) && errno == ENOENT)
|
||||
{
|
||||
if ((flog = fopen(logfile, "w")) == NULL)
|
||||
{
|
||||
tries = -1;
|
||||
print_msg(PRT_ERR,"Can not write file `%s' (%s)!\n", logfile, strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(flog);
|
||||
tries = 0;
|
||||
}
|
||||
|
||||
while (((fd = open(logfile, O_WRONLY | O_APPEND | O_EXCL)) == -1) && (tries < 1000))
|
||||
tries++;
|
||||
if (tries != -1)
|
||||
{
|
||||
while (((fd = open(logfile, O_WRONLY | O_APPEND | O_EXCL)) == -1) && (tries < 1000))
|
||||
tries++;
|
||||
|
||||
if ((tries < 1000) && ((flog = fdopen(fd, "a")) == (FILE *)NULL))
|
||||
print_msg(PRT_ERR, "Can not open file `%s': %s!\n", logfile, strerror(errno));
|
||||
else {
|
||||
fprintf(flog, "%s|%-16s|%-16s|%5d|%10d|%10d|%5d|%c|%3d|%10ld|%10ld|%s|%d|%d|%g|%s|%8.2f|\n",
|
||||
s + 4, call[chan].num[CALLING], call[chan].num[CALLED],
|
||||
(int)(call[chan].disconnect - call[chan].connect),
|
||||
(int)call[chan].duration, (int)call[chan].connect,
|
||||
call[chan].aoce, call[chan].dialin ? 'I' : 'O',
|
||||
call[chan].cause, call[chan].ibytes, call[chan].obytes,
|
||||
LOG_VERSION, call[chan].si1, call[chan].si11,
|
||||
currency_factor, currency, call[chan].pay);
|
||||
if ((tries >= 1000) || ((flog = fdopen(fd, "a")) == (FILE *)NULL))
|
||||
print_msg(PRT_ERR, "Can not open file `%s': %s!\n", logfile, strerror(errno));
|
||||
else
|
||||
{
|
||||
fprintf(flog, "%s|%-16s|%-16s|%5d|%10d|%10d|%5d|%c|%3d|%10ld|%10ld|%s|%d|%d|%g|%s|%8.2f|\n",
|
||||
s + 4, call[chan].num[CALLING], call[chan].num[CALLED],
|
||||
(int)(call[chan].disconnect - call[chan].connect),
|
||||
(int)call[chan].duration, (int)call[chan].connect,
|
||||
call[chan].aoce, call[chan].dialin ? 'I' : 'O',
|
||||
call[chan].cause, call[chan].ibytes, call[chan].obytes,
|
||||
LOG_VERSION, call[chan].si1, call[chan].si11,
|
||||
currency_factor, currency, call[chan].pay);
|
||||
|
||||
fclose(flog);
|
||||
} /* else */
|
||||
fclose(flog);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdnlog.c,v 1.5 1997/04/06 22:04:22 luethje Exp $
|
||||
/* $Id: isdnlog.c,v 1.6 1997/04/08 00:02:14 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (log-module)
|
||||
*
|
||||
|
@ -17,10 +17,21 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
*
|
||||
* $Log: isdnlog.c,v $
|
||||
* Revision 1.6 1997/04/08 00:02:14 luethje
|
||||
* Bugfix: isdnlog is running again ;-)
|
||||
* isdnlog creates now a file like /var/lock/LCK..isdnctrl0
|
||||
* README completed
|
||||
* Added some values (countrycode, areacode, lock dir and lock file) to
|
||||
* the global menu
|
||||
*
|
||||
*/
|
||||
|
||||
#define _ISDNLOG_C_
|
||||
|
||||
#include <linux/limits.h>
|
||||
|
||||
#include "isdnlog.h"
|
||||
#ifdef POSTGRES
|
||||
#include "postgres.h"
|
||||
|
@ -296,6 +307,7 @@ static void traceoptions()
|
|||
} /* traceoptions */
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int set_options(int argc, char* argv[])
|
||||
{
|
||||
|
@ -678,12 +690,14 @@ static void restoreCharge()
|
|||
|
||||
int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
register char *p;
|
||||
register int i, res = 0;
|
||||
auto int lastarg;
|
||||
auto char fn[BUFSIZ];
|
||||
register char *p;
|
||||
register int i, res = 0;
|
||||
auto int lastarg;
|
||||
auto char fn[BUFSIZ];
|
||||
auto char rlogfile[PATH_MAX];
|
||||
auto char **devices = NULL;
|
||||
#ifdef TESTCENTER
|
||||
extern void test_center(void);
|
||||
extern void test_center(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -706,7 +720,6 @@ int main(int argc, char *argv[], char *envp[])
|
|||
}
|
||||
else {
|
||||
p = strrchr(isdnctrl, C_SLASH);
|
||||
sprintf(pidfile, "%s.%s", myshortname, p ? p + 1 : isdnctrl);
|
||||
|
||||
if (add_socket(&sockets, -1) || /* reserviert fuer isdnctrl */
|
||||
add_socket(&sockets, -1) || /* reserviert fuer isdnctrl2 */
|
||||
|
@ -740,8 +753,6 @@ int main(int argc, char *argv[], char *envp[])
|
|||
|
||||
} /* else */
|
||||
|
||||
if (replay)
|
||||
strcat((char *)logfile, ".rep");
|
||||
|
||||
openlog(myshortname, LOG_NDELAY, LOG_DAEMON);
|
||||
|
||||
|
@ -791,9 +802,9 @@ int main(int argc, char *argv[], char *envp[])
|
|||
if (q931dmp) {
|
||||
mymsns = 3;
|
||||
mycountry = "+49";
|
||||
myarea = "6408";
|
||||
currency = NULL;
|
||||
dual = 1;
|
||||
myarea = "6408";
|
||||
currency = NULL;
|
||||
dual = 1;
|
||||
chargemax = 0.0;
|
||||
connectmax = 0.0;
|
||||
bytemax = 0.0;
|
||||
|
@ -815,15 +826,22 @@ int main(int argc, char *argv[], char *envp[])
|
|||
restoreCharge();
|
||||
} /* if */
|
||||
|
||||
if (!replay) {
|
||||
switch (i = create_runfile(pidfile)) {
|
||||
if (replay)
|
||||
{
|
||||
sprintf(rlogfile, "%s.rep", logfile);
|
||||
logfile = rlogfile;
|
||||
}
|
||||
else
|
||||
{
|
||||
append_element(&devices,isdnctrl);
|
||||
|
||||
switch (i = handle_runfiles(myshortname,devices,START_PROG)) {
|
||||
case 0 : break;
|
||||
|
||||
case -1 : print_msg(PRT_ERR,"Can not open pid file: %s!\n", strerror(errno));
|
||||
Exit(36);
|
||||
case -1 : print_msg(PRT_ERR,"Can not open pid/lock file: %s!\n", strerror(errno));
|
||||
Exit(36);
|
||||
|
||||
default : print_msg(PRT_ERR,"Another %s is running with pid %d!\n", myshortname, i);
|
||||
Exit(37);
|
||||
default : Exit(37);
|
||||
} /* switch */
|
||||
} /* if */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdnlog.h,v 1.4 1997/04/03 22:34:50 luethje Exp $
|
||||
/* $Id: isdnlog.h,v 1.5 1997/04/08 00:02:17 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
|
@ -20,6 +20,13 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: isdnlog.h,v $
|
||||
* Revision 1.5 1997/04/08 00:02:17 luethje
|
||||
* Bugfix: isdnlog is running again ;-)
|
||||
* isdnlog creates now a file like /var/lock/LCK..isdnctrl0
|
||||
* README completed
|
||||
* Added some values (countrycode, areacode, lock dir and lock file) to
|
||||
* the global menu
|
||||
*
|
||||
* Revision 1.4 1997/04/03 22:34:50 luethje
|
||||
* splitt the files callerid.conf and ~/.isdn.
|
||||
*
|
||||
|
@ -223,7 +230,6 @@ _EXTERN int width;
|
|||
_EXTERN int watchdog;
|
||||
_EXTERN char *isdnctrl;
|
||||
_EXTERN char isdnctrl2[FNSIZE];
|
||||
_EXTERN char pidfile[SHORT_STRING_SIZE];
|
||||
|
||||
_EXTERN IFO ifo[ISDN_MAX_CHANNELS];
|
||||
_EXTERN IO io[ISDN_MAX_CHANNELS];
|
||||
|
|
|
@ -37,6 +37,8 @@ config:
|
|||
@echo '#define CALLERIDFILE CONFIG_CALLERIDFILE' >> policy.h
|
||||
@echo '#define USERCONFFILE CONFIG_USERCONFFILE' >> policy.h
|
||||
@echo '#define RUNDIR CONFIG_RUNDIR' >> policy.h
|
||||
@echo '#define LOCKDIR CONFIG_LOCKDIR' >> policy.h
|
||||
@echo '#define LOCKFILE CONFIG_LOCKFILE' >> policy.h
|
||||
@echo '#define S_COUNTRY_PREFIX CONFIG_COUNTRY_PREFIX' >> policy.h
|
||||
@echo '#define S_AREA_PREFIX CONFIG_AREA_PREFIX' >> policy.h
|
||||
@echo '#endif' >> policy.h
|
||||
|
|
|
@ -69,9 +69,11 @@ ENTRY1=blabla1
|
|||
entry2 = blabla2
|
||||
# ^^^-------- Es duerfen vor und nach dem Gleichheitszeichen beliebig
|
||||
# Spaces und Tabulatoren verwendet werden.
|
||||
# Das erste erkannte Zeichen nach dem
|
||||
# Gleichheitszeichen darf weder ein space noch ein Tabublator
|
||||
# sein.
|
||||
# Diese werden vom Interpreter ignoriert.
|
||||
# Das erste Zeichen des Wertes der Variablen
|
||||
# (nach Gleichheitszeichen) darf weder ein Leerzeichen noch ein
|
||||
# Tabublator sein.
|
||||
# Auch ein quoten mit '\' ist nicht moeglich.
|
||||
Entry3 = {
|
||||
# ^----- Dieses Zeichen besagt, das dieser Eintrag ein oder mehrere
|
||||
# Untersektionen beinhaltet. Es MUSS in der gleichen Zeile
|
||||
|
|
117
lib/isdntools.c
117
lib/isdntools.c
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdntools.c,v 1.8 1997/04/03 22:39:13 luethje Exp $
|
||||
/* $Id: isdntools.c,v 1.9 1997/04/08 00:02:24 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (Utilities)
|
||||
*
|
||||
|
@ -19,6 +19,13 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: isdntools.c,v $
|
||||
* Revision 1.9 1997/04/08 00:02:24 luethje
|
||||
* Bugfix: isdnlog is running again ;-)
|
||||
* isdnlog creates now a file like /var/lock/LCK..isdnctrl0
|
||||
* README completed
|
||||
* Added some values (countrycode, areacode, lock dir and lock file) to
|
||||
* the global menu
|
||||
*
|
||||
* Revision 1.8 1997/04/03 22:39:13 luethje
|
||||
* bug fixes: environ variables are working again, no seg. 11 :-)
|
||||
* improved performance for reading the config files.
|
||||
|
@ -112,6 +119,7 @@
|
|||
|
||||
static int (*print_msg)(const char *, ...) = printf;
|
||||
static char *_get_areacode(char *code, int *Len, int flag);
|
||||
static int create_runfile(const char *file, const char *format);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
@ -327,44 +335,99 @@ char *confdir(void)
|
|||
|
||||
/****************************************************************************/
|
||||
|
||||
int delete_runfile(const char *progname)
|
||||
int handle_runfiles(const char *_progname, char **_devices, int flag)
|
||||
{
|
||||
char *Ptr = NULL;
|
||||
char runfile[PATH_MAX];
|
||||
static char progname[SHORT_STRING_SIZE] = "";
|
||||
static char **devices = NULL;
|
||||
auto char string[PATH_MAX];
|
||||
auto char *Ptr = NULL;
|
||||
auto int RetCode = -1;
|
||||
|
||||
if (progname != NULL)
|
||||
return -1;
|
||||
|
||||
Ptr = strrchr(progname,C_SLASH);
|
||||
sprintf(runfile,"%s%c%s.pid",RUNDIR,C_SLASH,Ptr?Ptr+1:progname);
|
||||
if (progname[0] == '\0' || devices == NULL)
|
||||
{
|
||||
if (_progname == NULL || _devices == NULL)
|
||||
return -1;
|
||||
|
||||
return unlink(runfile);
|
||||
} /* delete_runfile */
|
||||
Ptr = strrchr(progname,C_SLASH);
|
||||
strcpy(progname,Ptr?Ptr+1:_progname);
|
||||
|
||||
while (*_devices != NULL)
|
||||
{
|
||||
append_element(&devices,*_devices);
|
||||
_devices++;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag == START_PROG)
|
||||
{
|
||||
sprintf(string,"%s%c%s.pid",RUNDIR,C_SLASH,progname);
|
||||
|
||||
if ((RetCode = create_runfile(string,"%d\n")) != 0)
|
||||
{
|
||||
if (RetCode > 0)
|
||||
print_msg("Another %s is running with pid %d!\n", progname, RetCode);
|
||||
|
||||
return RetCode;
|
||||
}
|
||||
|
||||
while (*devices != NULL)
|
||||
{
|
||||
sprintf(string,"%s%c%s%s",LOCKDIR,C_SLASH,LOCKFILE,*devices);
|
||||
|
||||
if ((RetCode = create_runfile(string,"%10d\n")) != 0)
|
||||
{
|
||||
if (RetCode > 0)
|
||||
print_msg("Another process (pid=%d) is running on device %s!\n", RetCode, *devices);
|
||||
|
||||
return RetCode;
|
||||
}
|
||||
|
||||
devices++;
|
||||
}
|
||||
|
||||
RetCode = 0;
|
||||
}
|
||||
|
||||
if (flag == STOP_PROG)
|
||||
{
|
||||
sprintf(string,"%s%c%s.pid",RUNDIR,C_SLASH,progname);
|
||||
unlink(string);
|
||||
|
||||
while (*devices != NULL)
|
||||
{
|
||||
sprintf(string,"%s%c%s%s",LOCKDIR,C_SLASH,LOCKFILE,*devices);
|
||||
if (unlink(string))
|
||||
print_msg("Can not remove file %s (%s)!\n", *devices, strerror(errno));
|
||||
|
||||
devices++;
|
||||
}
|
||||
|
||||
RetCode = 0;
|
||||
}
|
||||
|
||||
return RetCode;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int create_runfile(const char *progname)
|
||||
static int create_runfile(const char *file, const char *format)
|
||||
{
|
||||
char *Ptr = NULL;
|
||||
char runfile[PATH_MAX];
|
||||
char string[SHORT_STRING_SIZE];
|
||||
int RetCode = -1;
|
||||
int fd = -1;
|
||||
FILE *fp;
|
||||
auto char string[SHORT_STRING_SIZE];
|
||||
auto int RetCode = -1;
|
||||
auto int fd = -1;
|
||||
auto FILE *fp;
|
||||
|
||||
if (progname == NULL)
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
|
||||
Ptr = strrchr(progname,C_SLASH);
|
||||
sprintf(runfile,"%s%c%s.pid",RUNDIR,C_SLASH,Ptr?Ptr+1:progname);
|
||||
|
||||
if ((fd = open(runfile, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0644)) >= 0)
|
||||
if ((fd = open(file, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0644)) >= 0)
|
||||
{
|
||||
sprintf(string, "%10d\n", (int)getpid());
|
||||
sprintf(string, format, (int)getpid());
|
||||
|
||||
if (write(fd, string, strlen(string)) != strlen(string) )
|
||||
{
|
||||
print_msg("Can not write to PID file `%s'!\n", runfile);
|
||||
print_msg("Can not write to PID file `%s'!\n", file);
|
||||
RetCode = -1;
|
||||
}
|
||||
else
|
||||
|
@ -374,7 +437,7 @@ int create_runfile(const char *progname)
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((fp = fopen(runfile, "r")) == NULL)
|
||||
if ((fp = fopen(file, "r")) == NULL)
|
||||
return -1;
|
||||
|
||||
if (fgets(string,SHORT_STRING_SIZE,fp) != NULL)
|
||||
|
@ -389,10 +452,10 @@ int create_runfile(const char *progname)
|
|||
{
|
||||
|
||||
fclose(fp);
|
||||
if (unlink(runfile))
|
||||
if (unlink(file))
|
||||
return -1;
|
||||
|
||||
return create_runfile(progname);
|
||||
return create_runfile(file,format);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
/* $Id: libisdn.h,v 1.4 1997/03/20 00:28:02 luethje Exp $
|
||||
/* $Id: libisdn.h,v 1.5 1997/04/08 00:02:25 luethje Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
|
@ -20,6 +20,13 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: libisdn.h,v $
|
||||
* Revision 1.5 1997/04/08 00:02:25 luethje
|
||||
* Bugfix: isdnlog is running again ;-)
|
||||
* isdnlog creates now a file like /var/lock/LCK..isdnctrl0
|
||||
* README completed
|
||||
* Added some values (countrycode, areacode, lock dir and lock file) to
|
||||
* the global menu
|
||||
*
|
||||
* Revision 1.4 1997/03/20 00:28:02 luethje
|
||||
* Inserted lines into the files for the revision tool.
|
||||
*
|
||||
|
@ -62,6 +69,14 @@ extern char *basename __P((__const char *__name));
|
|||
# define RUNDIR "/var/run"
|
||||
#endif
|
||||
|
||||
#ifndef LOCKDIR
|
||||
# define LOCKDIR "/var/lock"
|
||||
#endif
|
||||
|
||||
#ifndef LOCKFILE
|
||||
# define LOCKFILE "LCK.."
|
||||
#endif
|
||||
|
||||
#ifndef CONFFILE
|
||||
# define CONFFILE "isdn.conf"
|
||||
#endif
|
||||
|
@ -117,6 +132,11 @@ extern char *basename __P((__const char *__name));
|
|||
|
||||
/****************************************************************************/
|
||||
|
||||
#define START_PROG 1
|
||||
#define STOP_PROG 2
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#ifdef _ISDNTOOLS_C_
|
||||
#define _EXTERN
|
||||
#define SET_NULL = ""
|
||||
|
@ -133,8 +153,7 @@ _EXTERN int num_match(char *Pattern, char *number);
|
|||
_EXTERN char *expand_number(char *s);
|
||||
_EXTERN char *expand_file(char *s);
|
||||
_EXTERN char *confdir(void);
|
||||
_EXTERN int create_runfile(const char* progname);
|
||||
_EXTERN int delete_runfile(const char* progname);
|
||||
_EXTERN int handle_runfiles(const char *_progname, char **_devices, int flag);
|
||||
_EXTERN int Set_Codes(section* Section);
|
||||
_EXTERN char *get_areacode(char *code, int *Len, int flag);
|
||||
_EXTERN int read_conffiles(section **Section, char *groupfile);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# $Id: config.in,v 1.16 1997/04/03 08:57:07 fritz Exp $
|
||||
# $Id: config.in,v 1.17 1997/04/08 00:02:28 luethje Exp $
|
||||
#
|
||||
# The whole configuration stuff is borrowed from the kernel
|
||||
# configuration.
|
||||
|
@ -28,11 +28,15 @@ string 'Directory to install admin binaries' CONFIG_SBINDIR
|
|||
string 'Directory to install man pages' CONFIG_MANDIR
|
||||
comment 'Runtime defaults'
|
||||
string 'Write .pid files here' CONFIG_RUNDIR
|
||||
string 'Write lock files here' CONFIG_LOCKDIR
|
||||
string 'Prefix for the lock file' CONFIG_LOCKFILE
|
||||
string 'General configuration directory' CONFIG_I4LCONFDIR
|
||||
string 'Global configuration file' CONFIG_CONFFILE
|
||||
string 'Global phone number file file' CONFIG_CALLERIDFILE
|
||||
string 'User configuration file' CONFIG_USERCONFFILE
|
||||
comment 'Configuration library options'
|
||||
string 'Your country code' CONFIG_COUNTRYCODE
|
||||
string 'Your area code' CONFIG_AREACODE
|
||||
string 'Default country prefix' CONFIG_COUNTRY_PREFIX
|
||||
string 'Default area prefix' CONFIG_AREA_PREFIX
|
||||
choice 'Database for area codes' \
|
||||
|
|
|
@ -16,12 +16,16 @@ CONFIG_BINDIR='/usr/bin'
|
|||
CONFIG_SBINDIR='/sbin'
|
||||
CONFIG_MANDIR='/usr/man'
|
||||
CONFIG_RUNDIR='/var/run'
|
||||
CONFIG_LOCKDIR='/var/lock'
|
||||
CONFIG_LOCKFILE='LCK..'
|
||||
CONFIG_I4LCONFDIR='/etc/isdn'
|
||||
CONFIG_CONFFILE='isdn.conf'
|
||||
CONFIG_CALLERIDFILE='callerid.conf'
|
||||
CONFIG_USERCONFFILE='~/.isdn'
|
||||
CONFIG_COUNTRY_PREFIX='+'
|
||||
CONFIG_AREA_PREFIX='0'
|
||||
CONFIG_COUNTRYCODE='49'
|
||||
CONFIG_AREACODE='040'
|
||||
CONFIG_LIB_AREACODE=y
|
||||
CONFIG_AREACODE_DATA='/usr/lib/isdn'
|
||||
|
||||
|
|
Loading…
Reference in New Issue