Universal cid handler

This commit is contained in:
dcp1990 2005-06-19 01:24:15 +00:00
parent bedea8c6fb
commit ef3c0a66b8
4 changed files with 19 additions and 10 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.17 2005/06/19 00:10:56 dcp1990 Exp $ */ /* $Amigan: phoned/include/phoned.h,v 1.18 2005/06/19 01:24:15 dcp1990 Exp $ */
#include <pcre.h> /* fugly, I know... */ #include <pcre.h> /* fugly, I know... */
#define VERSION "0.1" #define VERSION "0.1"
#define LOGFILE "/var/log/phoned.log" #define LOGFILE "/var/log/phoned.log"
@ -166,6 +166,8 @@ char *parse_command(const char *cmd, short *cont, state_info_t *s);
void begin_dialogue(FILE* fp, int fd); void begin_dialogue(FILE* fp, int fd);
short db_init(char* dbfilename); short db_init(char* dbfilename);
short db_destroy(void); short db_destroy(void);
short db_add_call(cid_t* c, time_t t);
void cid_handle(cid_t *c);
/* old stuff... /* old stuff...
void modem_pickup(void); void modem_pickup(void);
void modem_hangup(void); void modem_hangup(void);

View File

@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
/* $Amigan: phoned/phoned/cid.c,v 1.5 2005/06/18 20:51:29 dcp1990 Exp $ */ /* $Amigan: phoned/phoned/cid.c,v 1.6 2005/06/19 01:24:16 dcp1990 Exp $ */
/* system includes */ /* system includes */
#include <stdlib.h> #include <stdlib.h>
#include <limits.h> #include <limits.h>
@ -167,3 +167,13 @@ cid_t* parse_cid(char* cidstring)
date[2] = '/'; date[2] = '/';
return c; return c;
} }
void cid_handle(c)
cid_t *c;
{
time_t ti;
ti = time(NULL);
cid_log(c);
cid_notify(c);
check_condition(c);
db_add_call(c, ti);
}

View File

@ -157,9 +157,7 @@ void modem_hread(char* cbuf)
if(doing_cid) { if(doing_cid) {
cid_t *rc; cid_t *rc;
rc = parse_cid(buffer); rc = parse_cid(buffer);
cid_log(rc); cid_handle(rc);
cid_notify(rc);
check_condition(rc);
free_cid(rc); free_cid(rc);
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
doing_cid = 0; doing_cid = 0;

View File

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
/* $Amigan: phoned/phoned/remote.c,v 1.5 2005/06/16 20:57:10 dcp1990 Exp $ */ /* $Amigan: phoned/phoned/remote.c,v 1.6 2005/06/19 01:24:16 dcp1990 Exp $ */
/* system includes */ /* system includes */
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -68,7 +68,7 @@ char *parse_command(cmd, cont, s)
} else { } else {
RNF("513 ERROR: Syntax error: Needs usernamd as argument.\n"); RNF("513 ERROR: Syntax error: Needs usernamd as argument.\n");
} }
} else if(CHK("tnotify")) { } else if(CHK("thandler")) {
cid_t c; cid_t c;
c.number = "7823020300"; c.number = "7823020300";
c.name = "BUSH,GEORGE W."; c.name = "BUSH,GEORGE W.";
@ -76,10 +76,9 @@ char *parse_command(cmd, cont, s)
c.hour = 3; c.hour = 3;
c.month = 4; c.month = 4;
c.minute = 20; c.minute = 20;
cid_notify(&c); cid_handle(&c);
cid_log(&c);
*cont = 0; *cont = 0;
RNF("500 OK: Notify tested.\n"); RNF("500 OK: Handler tested.\n");
} else if(CHK("tparse")) { } else if(CHK("tparse")) {
cid_t* rc; cid_t* rc;
rc = parse_cid("802701083132323130383234070F5354414E444953482048454154494E020A343031333937333337325C\n"); rc = parse_cid("802701083132323130383234070F5354414E444953482048454154494E020A343031333937333337325C\n");