/************************************************************************ * PSYC Manager Daemon, src/parse.cc * Copyright (C) 2001/02 Mark Ralf Thomson * Programmer: Mark Ralf Thomson * Conceptor : Carlo von Loesch */ #include "psycm.h" #include "net.h" #include "classes.h" #include "parse.h" #include "int_functions.h" #include "extern.h" #include "msg.h" #include "user.h" void parse_data(char *,person*); char* delchr_if(char *in,char rm_c,char if_c) { int i=0,i2=0; while(in[i] != '\0') { if (in[i+1] != rm_c && in[i] != if_c) in[i2++] = in[i]; else { in[i2++] = if_c; i++; } i++; } return in; } int parse_psyc(char *,person*, bool) { return 0; } int parse_psyc_line(person *p,char *line) { int i=0; static char key[120]; static char value[2048]; params **paraobj=NULL; char *key2; #define SCANLINE sscanf(line+1, "%120s\t%2048s", key, value) || sscanf(line+1, "%120s %2024s", key, value) #define KEYLINE sscanf(line,"%120[^\r\n\f\t ]",key) switch(line[0]) { case '=' : if(SCANLINE) { if((paraobj = pa.find(key))) { if ((*paraobj)->sub) (*paraobj)->exec(p,key,value); else p->v->add(key,value); } else p->send ( SRC_ROOT, "_error_unknown_variable", R_UNKWN_VAR, ":_method",key ); } else if(!KEYLINE) key2 = line; else key2 = key; p->send ( SRC_ROOT, "_error_unknown_variable", R_UNKWN_VAR, ":_method",key ); break; case ':': break; case '+': if(!KEYLINE) key2 = line; else key2 = key; p->send ( SRC_ROOT, "_failure_unimplemented_method", R_IMPL_METH, ":_method",key2 ); break; case '-': if(!KEYLINE) key2 = line; else key2 = key; p->send ( SRC_ROOT, "_failure_unimplemented_method", R_IMPL_METH, ":_method",key2 ); break; case '?': if(!KEYLINE) key2 = line; else key2 = key; p->send ( SRC_ROOT, "_failure_unimplemented_method_typ", R_IMPL_METH, ":_method_typ",key ); break; case '_': for (i=strlen(key)-1; i>=0; i--) { if (!(key[i] == '_' || (key[i] >= 'a' && key[i] <= 'z') || (key[i] >= 'A' && key[i] <= 'Z'))) { p->send ( SRC_ROOT, "_error_illegal_method", "R_ILL_METH" ":_method",key ); } } break; } if(SCANLINE) ; return 0; } /* translate TELNET Input to a PSYC Message, using p for further informationen */ int parse_telnet(char *n,person*p,bool way) { return 0; } char * get_entry (char *in, bool *multi) { char *t=NULL; static char out[4000]; int i=0; multi = false; if(*in == '\0') return NULL; while(++i != 30) { t = strchr(in,'\n'); if(t == NULL) { strncpy(out,t,4000); *in = '\0'; return (char *)&out; } if (*t+1 != '\t') break; else *multi = true; } if(t-in >= 4000) { strncpy(out,in,4000); *in = '\0'; return (char *)&out; } memmove(in,t+1,(size_t)(in-(t+1))); return (char *)&out; } void parse_data(char *buffer,person *p) { int z; char *line; char sessid[20]; bool multi; if(p->client_proto != PT_PSYC) if((z = p->pt_trans(buffer,p,TO_PSYC)) < 0) /* translate that message to a PSYC-Message */ { cout<<"Error pt_trans:"<conn.type == P_UDP_C && strcmp(p->sessid,sessid) != 0 ) return; // cmdobj->func (p,varmap); }