Begin transition to interface with vgetty

This commit is contained in:
dcp1990 2010-02-13 19:02:57 +00:00
parent e5f79de09a
commit 4acfc6f0b2
9 changed files with 41 additions and 17 deletions

View File

@ -3,7 +3,7 @@
* (C)2005, Dan Ponte * (C)2005, Dan Ponte
* BSDL w/ advert. * 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 <pcre.h> /* fugly, I know... */ #include <pcre.h> /* fugly, I know... */
#define VERSION "0.1" #define VERSION "0.1"
#define LOGFILE "-" #define LOGFILE "-"
@ -18,6 +18,7 @@ struct conf {
int loglevels; int loglevels;
short modem_tm; short modem_tm;
char* modemdev; char* modemdev;
int modemhand;
char *dbfile; char *dbfile;
}; };
#define LL_DEBUG 0x1 #define LL_DEBUG 0x1

View File

@ -1,9 +1,9 @@
# cnd Makefile # cnd Makefile
# (C)2005, Dan Ponte # (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 include ../global.mk
# basic stuff. we append for a reason. # 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 CFLAGS+=-g -Wall -W -ansi ${CPPFLAGS} -pthread
LDFLAGS+=-lutil -lpcre -lsqlite3 LDFLAGS+=-lutil -lpcre -lsqlite3
# keep these up to date. # keep these up to date.

View File

@ -39,6 +39,9 @@ hangup yylval.number = CTACT_HUP; return ACTN;
ignore yylval.number = CTACT_IGN; return ACTN; ignore yylval.number = CTACT_IGN; return ACTN;
play yylval.number = CTACT_PLAY; return ACTN; play yylval.number = CTACT_PLAY; return ACTN;
record yylval.number = CTACT_REC; 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; modemdev return MODDEV;
\| return OR; \| return OR;
\" return QUOTE; \" return QUOTE;

View File

@ -33,10 +33,10 @@ int yywrap(void)
return 1; 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 %token FILTERS ACTION NAME PHNUM FILTER FLAGS DB SOCK
/* HANGUP IGNOREIT PLAY RECORD */ /* HANGUP IGNOREIT PLAY RECORD */
%token <number> LNUML ACTN FLAG %token <number> LNUML ACTN FLAG ENA_DIS_STATE
%token <string> IPADDR PATH REGEX FNAME %token <string> IPADDR PATH REGEX FNAME
%% %%
commands: commands:
@ -68,6 +68,8 @@ directive:
database database
| |
socket socket
|
modhand
; ;
notify: notify:
NOTIFY iplist NOTIFY iplist
@ -113,6 +115,15 @@ dbpath:
modemdev: modemdev:
MODDEV devpath 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: devpath:
QUOTE PATH QUOTE QUOTE PATH QUOTE
{ {

View File

@ -76,11 +76,13 @@ void initialize(void)
exit(-1); exit(-1);
} else whatdone |= WD_CONFIG; /* XXX: if you put anything before this, edit config.y's bitmask on shutd() */ } else whatdone |= WD_CONFIG; /* XXX: if you put anything before this, edit config.y's bitmask on shutd() */
pthread_mutex_lock(&cfmx); pthread_mutex_lock(&cfmx);
if(cf.modemhand) {
if(init_modem(cf.modemdev) != 1) { if(init_modem(cf.modemdev) != 1) {
lprintf(fatal, "fatal error: modem didn't initialise properly; see previous messages\n"); lprintf(fatal, "fatal error: modem didn't initialise properly; see previous messages\n");
shutd(whatdone); shutd(whatdone);
exit(-1); exit(-1);
} else whatdone |= WD_MODEM; } else whatdone |= WD_MODEM;
}
if(!db_init(cf.dbfile)) { if(!db_init(cf.dbfile)) {
lprintf(fatal, "fatal error: database did not open, see previous messages\n"); lprintf(fatal, "fatal error: database did not open, see previous messages\n");
shutd(whatdone); shutd(whatdone);

View File

@ -65,13 +65,18 @@ int main(argc, argv)
} }
cf.modem_tm = 0; cf.modem_tm = 0;
cf.loglevels = LL_ALL; cf.loglevels = LL_ALL;
cf.modemhand = 1;
pthread_mutex_unlock(&cfmx); pthread_mutex_unlock(&cfmx);
initialize(); initialize();
lprintf(debug, "INIT IS 0x%x", PTHREAD_MUTEX_INITIALIZER); lprintf(debug, "INIT IS 0x%x", PTHREAD_MUTEX_INITIALIZER);
pthread_create(&networkth, NULL, network, NULL); pthread_create(&networkth, NULL, network, NULL);
lprintf(debug, "Started network with 0x%x.", networkth); lprintf(debug, "Started network with 0x%x.", networkth);
pthread_mutex_lock(&cfmx);
if(cf.modemhand) {
pthread_create(&modemth, NULL, modem_io, NULL); pthread_create(&modemth, NULL, modem_io, NULL);
lprintf(debug, "Started modemth with 0x%x.", modemth); lprintf(debug, "Started modemth with 0x%x.", modemth);
}
pthread_mutex_unlock(&cfmx);
pthread_create(&mainth, NULL, mainthf, NULL); pthread_create(&mainth, NULL, mainthf, NULL);
pthread_exit(NULL); pthread_exit(NULL);
return 0; return 0;

View File

@ -69,6 +69,7 @@ int modempipes[2];
extern pthread_mutex_t cfmx; extern pthread_mutex_t cfmx;
modem_t* mo; modem_t* mo;
extern modem_t rockwell; extern modem_t rockwell;
extern modem_t agere;
void stmod(str) void stmod(str)
const char* str; const char* str;
{ {
@ -237,7 +238,7 @@ int init_modem(char* dev)
return -3; return -3;
} }
fcntl(modemfd, F_SETFL, O_NONBLOCK); fcntl(modemfd, F_SETFL, O_NONBLOCK);
mo = &rockwell; mo = &agere;
mo->init(); mo->init();
/* voice_init(); */ /* voice_init(); */
pthread_mutex_unlock(&modemmx); pthread_mutex_unlock(&modemmx);

View File

@ -1,6 +1,6 @@
# cnd Makefile # cnd Makefile
# (C)2005, Dan Ponte # (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 include ../../global.mk
# basic stuff. we append for a reason. # basic stuff. we append for a reason.
CPPFLAGS+=-I../../include CPPFLAGS+=-I../../include
@ -8,8 +8,8 @@ CFLAGS+=-g -Wall -W -ansi ${CPPFLAGS}
LDFLAGS= LDFLAGS=
# keep these up to date. # keep these up to date.
MAINBIN=libmodems.a MAINBIN=libmodems.a
SRCS=rockwell.c SRCS=rockwell.c agere.c
OBJS=rockwell.o OBJS=rockwell.o agere.o
all: .depend ${MAINBIN} all: .depend ${MAINBIN}
# I know, I know, but it's good. # I know, I know, but it's good.
.depend: ${SRCS} ${OHDRS} .depend: ${SRCS} ${OHDRS}

View File

@ -1,8 +1,9 @@
main { main {
modemdev "/dev/cuad0"; modemdev "/dev/cuau1";
loglevel all; loglevel all;
database "./phoned.db"; database "./phoned.db";
socket "/tmp/phoned.sock"; socket "/tmp/phoned.sock";
modemhandler disabled;
}; };
filters { filters {
filter test1 { filter test1 {