#include #include #include #include #include #include #include #ifdef __cplusplus atlStartup::atlStartup(void){ status=0; ll_day=ll_month=ll_year=0; strcpy(nick,"nick_nDef"); strcpy(level,"level_nDef"); strcpy(room,"room_nDef"); strcpy(lastlink,"lastlink_nDef"); } atlStartup::~atlStartup(void){ } inline void atlStartup::reset(void){ atlStartup(); } inline int atlStartup::isDefined(void){ return(status==4?1:0); } int atlStartup::writeToStream(FILE*f){ return(fprintf(f,"%s %s %s %s %d.%d.%d ",level,nick,room,lastlink,ll_day,ll_month,ll_year)); } int atlStartup::analyze(const char*orig_buf){ char*buf; buf=discolorcopy(orig_buf); if(buf==NULL){ #if DEBUG fprintf(stderr,"atlStartup::analyze() ERROR: discolorcopy() returns NULL.\n"); #endif return(-1); } switch(status){ case 0:{ if(strstr(buf,ATL_ALREADYLOGGED_STR)!=NULL){ status+=4; strcpy(nick,"nick_N/A"); strcpy(room,"room_N/A"); strcpy(level,"level_N/A"); strcpy(lastlink,"lastlink_N/A"); } else{ if((strstr(buf,ATL_STARTUP1_STR)!=NULL)&&(strstr(buf,ATL_STARTUP2_STR)!=NULL)){ sscanf(strendstr(buf,ATL_STARTUP1_STR),"%s",nick); if(strchr(buf,'!')!=NULL)*strchr(buf,'!')='\0'; } } }break; case 1: if(strstr(buf,ATL_STARTUP3_STR)!=NULL){ sscanf(strendstr(buf,ATL_STARTUP3_STR),"%s",level); status++; } break; case 2: if((strrchr(buf,'|')!=NULL)&&(strrchr(strrchr(buf,'|')-1,'|')!=NULL)){ sscanf(strrchr(strrchr(buf,'|')-1,'|')+1,"%d.%d.%d,",&ll_day,&ll_month,&ll_year); status++; } break; case 3: if(strstr(buf,ATL_STARTUP4_STR)!=NULL){ sscanf(strendstr(buf,ATL_STARTUP4_STR),"%s",room); if((strrchr(buf,'|')!=NULL)&&(strrchr(strrchr(buf,'|')-1,'|')!=NULL)){ sscanf(strrchr(strrchr(buf,'|')-1,'|')+1,"%s",lastlink); } status++; } break; case 4://defined break; default: #if DEBUG fprintf(stderr,"atlStartup::analyze() WARNING: Bad status value (%d) changed to initial.\n",status); #endif status=0; break; } if(buf!=NULL)free(buf); return(isDefined()); } #endif /* #ifdef __cplusplus */