From 0cecdf5879e4fbb17ae2a7113bf1f9a63c606891 Mon Sep 17 00:00:00 2001 From: dcp1990 Date: Mon, 13 Jun 2005 21:04:13 +0000 Subject: [PATCH] Use the new parsing stuff in remote.c --- include/phoned.h | 15 ++++++++++++++- phoned/remote.c | 14 ++------------ phoned/socket.c | 10 +++++----- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/include/phoned.h b/include/phoned.h index ab2feb0..4ae2c68 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.10 2005/06/13 03:40:27 dcp1990 Exp $ */ +/* $Amigan: phoned/include/phoned.h,v 1.11 2005/06/13 21:04:13 dcp1990 Exp $ */ #include /* fugly, I know... */ #define VERSION "0.1" #define LOGFILE "/var/log/phoned.log" @@ -97,6 +97,17 @@ typedef struct cnd_t { struct cnd_t* last; struct cnd_t* next; } cond_t; +typedef enum stat { + init = 0, + loginstage, + pass +} states_t; +typedef struct si_t { + states_t st; + short freeit; + FILE* fpo; +} state_info_t; + #ifdef HAVE_INET_INCS typedef struct adll_t { in_addr_t addr; @@ -132,3 +143,5 @@ cond_t* copy_condition(cond_t* con); void check_condition(cid_t* cid); void *modem_io(void *k); void give_me_modem(char* str); +char *parse_command(const char *cmd, short *cont, state_info_t *s); +void begin_dialogue(FILE* fp); diff --git a/phoned/remote.c b/phoned/remote.c index c5cc677..4731ff5 100644 --- a/phoned/remote.c +++ b/phoned/remote.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -/* $Amigan: phoned/phoned/remote.c,v 1.1 2005/06/13 21:00:07 dcp1990 Exp $ */ +/* $Amigan: phoned/phoned/remote.c,v 1.2 2005/06/13 21:04:14 dcp1990 Exp $ */ /* system includes */ #include #include @@ -39,16 +39,6 @@ #define MAXARGS 15 #define CHK(m) strcasecmp(m, argvect[cpos]) == 0 #define RNF(m) s->freeit = 0; free(is); return(m) -typedef enum stat { - init = 0, - login, - pass -} states_t; -typedef struct si_t { - states_t st; - short freeit; - FILE* fpo; -} state_info_t; char *parse_command(cmd, cont, s) const char *cmd; @@ -98,7 +88,7 @@ char *parse_command(cmd, cont, s) RNF("500 OK: Give Me Modem tested.\n"); } break; - case login: + case loginstage: break; case pass: break; diff --git a/phoned/socket.c b/phoned/socket.c index 0678292..02f8ab9 100644 --- a/phoned/socket.c +++ b/phoned/socket.c @@ -54,11 +54,11 @@ void *handclient(k) void* k; { int sk = (int)k; - char buffer[1024]; - int rlen; - rlen = recv(sk, buffer, sizeof(buffer), 0); - lprintf(debug, "Client said %s.", buffer); - close(sk); + FILE* tf; + lprintf(info, "Incoming client."); + tf = fdopen(sk, "r+"); + begin_dialogue(tf); + fclose(tf); pthread_exit(NULL); return 0; }