diff --git a/include/phoned.h b/include/phoned.h index 9513ac6..0bd3baa 100644 --- a/include/phoned.h +++ b/include/phoned.h @@ -3,7 +3,7 @@ * (C)2005, Dan Ponte * BSDL w/ advert. */ -/* $Amigan: phoned/include/phoned.h,v 1.29 2005/06/28 02:32:52 dcp1990 Exp $ */ +/* $Amigan: phoned/include/phoned.h,v 1.30 2010/02/13 19:02:57 dcp1990 Exp $ */ #include /* fugly, I know... */ #define VERSION "0.1" #define LOGFILE "-" @@ -18,6 +18,7 @@ struct conf { int loglevels; short modem_tm; char* modemdev; + int modemhand; char *dbfile; }; #define LL_DEBUG 0x1 diff --git a/phoned/Makefile b/phoned/Makefile index 26d3fef..048a1f7 100644 --- a/phoned/Makefile +++ b/phoned/Makefile @@ -1,9 +1,9 @@ # cnd Makefile # (C)2005, Dan Ponte -# $Amigan: phoned/phoned/Makefile,v 1.15 2008/08/07 19:17:23 dcp1990 Exp $ +# $Amigan: phoned/phoned/Makefile,v 1.16 2010/02/13 19:03:04 dcp1990 Exp $ include ../global.mk # basic stuff. we append for a reason. -CPPFLAGS+=-I../include -DDEBUG -DYY_NO_UNPUT -DMODDEBUG +CPPFLAGS+=-I../include -DDEBUG -DYY_NO_UNPUT -DMODDEBUG -DMODEMSAID CFLAGS+=-g -Wall -W -ansi ${CPPFLAGS} -pthread LDFLAGS+=-lutil -lpcre -lsqlite3 # keep these up to date. diff --git a/phoned/config.l b/phoned/config.l index 8a6e0fe..ce3d507 100644 --- a/phoned/config.l +++ b/phoned/config.l @@ -39,6 +39,9 @@ hangup yylval.number = CTACT_HUP; return ACTN; ignore yylval.number = CTACT_IGN; return ACTN; play yylval.number = CTACT_PLAY; return ACTN; record yylval.number = CTACT_REC; return ACTN; +enabled yylval.number = 1; return ENA_DIS_STATE; +disabled yylval.number = 0; return ENA_DIS_STATE; +modemhandler return MODHAND; modemdev return MODDEV; \| return OR; \" return QUOTE; diff --git a/phoned/config.y b/phoned/config.y index 77a4d99..856c0f1 100644 --- a/phoned/config.y +++ b/phoned/config.y @@ -33,10 +33,10 @@ int yywrap(void) return 1; } %} -%token NOTIFY OBRACE CBRACE SCOLON QUOTE MODDEV MAIN LLEVEL OR +%token NOTIFY OBRACE CBRACE SCOLON QUOTE MODDEV MAIN LLEVEL OR MODHAND %token FILTERS ACTION NAME PHNUM FILTER FLAGS DB SOCK /* HANGUP IGNOREIT PLAY RECORD */ -%token LNUML ACTN FLAG +%token LNUML ACTN FLAG ENA_DIS_STATE %token IPADDR PATH REGEX FNAME %% commands: @@ -68,6 +68,8 @@ directive: database | socket + | + modhand ; notify: NOTIFY iplist @@ -113,6 +115,15 @@ dbpath: modemdev: MODDEV devpath ; +modhand: + MODHAND ENA_DIS_STATE + { + pthread_mutex_lock(&cfmx); + cf.modemhand = $2; + pthread_mutex_unlock(&cfmx); + lprintf(debug, "Modem handler %s\n", yylval.number ? "enabled" : "disabled"); + } + ; devpath: QUOTE PATH QUOTE { diff --git a/phoned/init.c b/phoned/init.c index a2c2a65..14dc548 100644 --- a/phoned/init.c +++ b/phoned/init.c @@ -76,11 +76,13 @@ void initialize(void) exit(-1); } else whatdone |= WD_CONFIG; /* XXX: if you put anything before this, edit config.y's bitmask on shutd() */ pthread_mutex_lock(&cfmx); - if(init_modem(cf.modemdev) != 1) { - lprintf(fatal, "fatal error: modem didn't initialise properly; see previous messages\n"); - shutd(whatdone); - exit(-1); - } else whatdone |= WD_MODEM; + if(cf.modemhand) { + if(init_modem(cf.modemdev) != 1) { + lprintf(fatal, "fatal error: modem didn't initialise properly; see previous messages\n"); + shutd(whatdone); + exit(-1); + } else whatdone |= WD_MODEM; + } if(!db_init(cf.dbfile)) { lprintf(fatal, "fatal error: database did not open, see previous messages\n"); shutd(whatdone); diff --git a/phoned/main.c b/phoned/main.c index e409c67..851baa2 100644 --- a/phoned/main.c +++ b/phoned/main.c @@ -65,13 +65,18 @@ int main(argc, argv) } cf.modem_tm = 0; cf.loglevels = LL_ALL; + cf.modemhand = 1; pthread_mutex_unlock(&cfmx); initialize(); lprintf(debug, "INIT IS 0x%x", PTHREAD_MUTEX_INITIALIZER); pthread_create(&networkth, NULL, network, NULL); lprintf(debug, "Started network with 0x%x.", networkth); - pthread_create(&modemth, NULL, modem_io, NULL); - lprintf(debug, "Started modemth with 0x%x.", modemth); + pthread_mutex_lock(&cfmx); + if(cf.modemhand) { + pthread_create(&modemth, NULL, modem_io, NULL); + lprintf(debug, "Started modemth with 0x%x.", modemth); + } + pthread_mutex_unlock(&cfmx); pthread_create(&mainth, NULL, mainthf, NULL); pthread_exit(NULL); return 0; diff --git a/phoned/modem.c b/phoned/modem.c index 2ed50a7..9b682e8 100644 --- a/phoned/modem.c +++ b/phoned/modem.c @@ -69,6 +69,7 @@ int modempipes[2]; extern pthread_mutex_t cfmx; modem_t* mo; extern modem_t rockwell; +extern modem_t agere; void stmod(str) const char* str; { @@ -237,7 +238,7 @@ int init_modem(char* dev) return -3; } fcntl(modemfd, F_SETFL, O_NONBLOCK); - mo = &rockwell; + mo = &agere; mo->init(); /* voice_init(); */ pthread_mutex_unlock(&modemmx); diff --git a/phoned/modems/Makefile b/phoned/modems/Makefile index 693d8e7..fa6bb8a 100644 --- a/phoned/modems/Makefile +++ b/phoned/modems/Makefile @@ -1,6 +1,6 @@ # cnd Makefile # (C)2005, Dan Ponte -# $Amigan: phoned/phoned/modems/Makefile,v 1.2 2005/06/18 20:26:14 dcp1990 Exp $ +# $Amigan: phoned/phoned/modems/Makefile,v 1.3 2010/02/13 19:03:10 dcp1990 Exp $ include ../../global.mk # basic stuff. we append for a reason. CPPFLAGS+=-I../../include @@ -8,8 +8,8 @@ CFLAGS+=-g -Wall -W -ansi ${CPPFLAGS} LDFLAGS= # keep these up to date. MAINBIN=libmodems.a -SRCS=rockwell.c -OBJS=rockwell.o +SRCS=rockwell.c agere.c +OBJS=rockwell.o agere.o all: .depend ${MAINBIN} # I know, I know, but it's good. .depend: ${SRCS} ${OHDRS} diff --git a/phoned/phoned.conf b/phoned/phoned.conf index f473914..a23f250 100644 --- a/phoned/phoned.conf +++ b/phoned/phoned.conf @@ -1,8 +1,9 @@ main { - modemdev "/dev/cuad0"; + modemdev "/dev/cuau1"; loglevel all; database "./phoned.db"; socket "/tmp/phoned.sock"; + modemhandler disabled; }; filters { filter test1 {