static void near FiltOrigin(void *v, char *words[], char *line) { char *txt=fchar(line, ctl_delim, 3); if (*words[1] != '.') { if (! isdigit(*words[1])) { printf("\a\nWarning! First word after 'Origin' on line %d must be a network address.\n", linenum); Compiling(-1, NULL, NULL); } ParseNNN(words[1], &PMI(v)->ma.primary, FALSE); } if (*words[2] != '.') { if (! isdigit(*words[2])) { printf("\a\nWarning! Second word after 'Origin' on line %d must be a network address.\n", linenum); Compiling(-1, NULL, NULL); } ParseNNN(words[2], &PMI(v)->ma.seenby, FALSE); } strocpy(line, txt); }
QString StreamMail::HeaderMail() { QByteArray out; //// ////onlyMETAHEADER = QByteArray(); int cursor = 0; start(); while (d->canReadLine()) { QByteArray chunk = d->readLine(); ///// const QString t_line = QString(chunk.constData()); //// decodeWordSequence(chunk); const QByteArray cline = chunk.simplified(); cursor++; if (!cline.isEmpty()) { out.append(cline); out.append("\n\r"); continue; } if (cline.isEmpty()) { start(); break; } } start(); QString useline; bool readc = false; QString clean_header = decodeWordSequence(out); //// utf subject clean //// here handle Subject on 2 or more line!!! QStringList h_lines = clean_header.split(QRegExp("(\\r\\n)|(\\n\\r)|\\r|\\n"), QString::SkipEmptyParts); for (int i = 0; i < h_lines.size(); ++i) { const QString line = QString(h_lines.at(i).simplified()); if (!line.isEmpty()) { QChar fchar(line.at(0)); int ucharkc = fchar.unicode(); if ( line.indexOf(QChar(':'), 0) !=-1 ) { readc = false; } if (Filter::headerfilter(line) && !readc) { readc = true; useline.append("\n"); } if (readc) { useline.append(line); useline.append(" "); continue; } } } return useline; }
int Parse_Matrix(FILE *ctlfile) { int x,y; char temp[MAX_LINE], /* Contains entire line */ temp2[MAX_LINE], /* Temporary holding tank */ p[MAX_LINE], /* First word on line */ *s2; linenum++; while (fgets(line,MAX_LINE,ctlfile)) { Strip_Comment(line); if (*line) { strcpy(temp,line); getword(line,p,ctl_delim,1); if (! *p) ; else if (eqstri(p,"end")) break; else if (eqstri(p,"address")) { if (alias_count==ALIAS_CNT) { printf("\n\aToo many network addresses on line %d of CTL file!\n", linenum); Compiling(-1,NULL,NULL); } else { getword(line,p,ctl_delim,2); prm.address[alias_count].zone=1; prm.address[alias_count].net=-1; prm.address[alias_count].node=-1; prm.address[alias_count].point=0; Parse_NetNode(p,&prm.address[alias_count].zone, &prm.address[alias_count].net, &prm.address[alias_count].node, &prm.address[alias_count].point); alias_count++; } } else if (eqstri(p,"gate")) prm.flags2 |= FLAG2_gate; else if (eqstri(p,"path")) { getword(line,p,ctl_delim,2); if (eqstri(p,"netinfo")) { s2=fchar(line,ctl_delim,3); Make_Path(prm.net_info,s2); if (! direxist(strings+prm.net_info)) makedir(strings+prm.net_info); } else Unknown_Ctl(linenum,p); } else if (eqstri(p,"fidouser")) { Make_Filename(prm.fidouser,fchar(line,ctl_delim,2)); } else if (eqstri(p,"nodelist")) { getword(line,p,ctl_delim,2); if (eqstri(p,"version")) { getword(line,p,ctl_delim,3); if (eqstri(p, "5")) prm.nlver=NLVER_5; else if (eqstri(p, "6")) prm.nlver=NLVER_6; else if (eqstri(p, "7")) prm.nlver=NLVER_7; else if (eqstri(p, "fd")) prm.nlver=NLVER_FD; else Unknown_Ctl(linenum,p); } else Unknown_Ctl(linenum,p); } else if (eqstri(p,"log")) { getword(line,p,ctl_delim,2); if (eqstri(p,"echomail")) { prm.flags |= FLAG_log_echo; getword(line,p,ctl_delim,3); if (! *p) { printf("\n\aError! No EchoToss filename specified on line %d of control file!\n",linenum); exit(1); } Make_Filename(prm.echotoss_name,p); } else Unknown_Ctl(linenum,p); } else if (eqstri(p,"after")) { getword(line,p,ctl_delim,2); if (eqstri(p,"edit")) { getword(line,p,ctl_delim,4); prm.edit_exit=(char)atoi(p); } else if (eqstri(p,"echomail")) { getword(line,p,ctl_delim,4); prm.echo_exit=(char)atoi(p); } else if (eqstri(p,"local")) { getword(line,p,ctl_delim,4); prm.local_exit=(char)atoi(p); } else Unknown_Ctl(linenum,p); } else if (eqstri(p,"message")) { getword(line,p,ctl_delim,2); if (eqstri(p,"show")) { getword(line,p,ctl_delim,3); getword(line,temp2,ctl_delim,5); if (eqstri(p,"ctl_a")) prm.ctla_priv=Deduce_Priv(temp2); else if (eqstri(p,"seenby")) prm.seenby_priv=Deduce_Priv(temp2); else if (eqstri(p,"private")) prm.pvt_priv=Deduce_Priv(temp2); else Unknown_Ctl(linenum,p); } else if (eqstri(p,"send")) { getword(line,p,ctl_delim,3); if (eqstri(p,"unlisted")) { getword(line,p,ctl_delim,4); prm.unlisted_priv=Deduce_Priv(p); getword(line,p,ctl_delim,5); prm.unlisted_cost=atoi(p); } else Unknown_Ctl(linenum,p); } else if (eqstri(p,"edit")) { getword(line,p,ctl_delim,3); if ((x=1,eqstri(p,"ask")) || (x=2,eqstri(p,"assume"))) { getword(line,p,ctl_delim,4); if (x==1) /* ASK */ { x=Deduce_Attribute(p); getword(line,p,ctl_delim,5); if (x==-20 && (!p || !*p)) prm.msg_localattach=0; else { y=Deduce_Priv(p); if (x==-22) /* fromfile */ prm.msg_fromfile=y; else if (x==-20) prm.msg_localattach=y; else prm.msg_ask[x]=y; } } else /* ASSUME */ { x=Deduce_Attribute(p); getword(line,p,ctl_delim,5); if (x==-20 && (!p || !*p)) prm.msg_localattach=0; else { y=Deduce_Priv(p); if (x==-22) /* fromfile */ prm.msg_fromfile=y; else if (x==-20) prm.msg_localattach=y; else prm.msg_assume[x]=y; } } } else Unknown_Ctl(linenum,p); } else Unknown_Ctl(linenum,p); } else if (eqstri(p,"app") || eqstri(p,"application")) ; else Unknown_Ctl(linenum,p); } linenum++; } linenum++; return 0; }
int Parse_Ctlfile(char *ctlname) { FILE *ctlfile; char p[MAX_LINE]; /* First word on line */ char temp[MAX_LINE]; char *bufr; int x; linenum=1; strcpy(ctl_name, fancy_fn(ctlname)); fixPathMove(ctl_name); printf("\nParsing `%s':",ctl_name); if ((ctlfile=fopen(ctlname,"r"))==NULL) { printf(" \aFatal error opening `%s' for read!\n",ctlname); exit(1); } if ((bufr=malloc(MAX_BUFR)) != NULL) setvbuf(ctlfile, bufr, _IOFBF, MAX_BUFR); while (fgets(line, MAX_LINE, ctlfile)) { Strip_Comment(line); if (*line) { getword(line, p, ctl_delim, 1); if (! *p) linenum++; else if (eqstri(p,"system")) { Compiling(LAST_SECTION,cc_section,"System"); Parse_System(ctlfile); done_sys=TRUE; } else if (eqstri(p,"access")) { strcpy(p,fchar(line,ctl_delim,2)); Compiling(LAST_ACCESS,cc_accs,p); ParseAccess(ctlfile,p); done_access=TRUE; } else if (eqstri(p,"equipment")) { Compiling(LAST_SECTION,cc_section,"Equipment"); Parse_Equipment(ctlfile); done_equip=TRUE; } else if (eqstri(p,"matrix")) { Compiling(LAST_SECTION,cc_section,"Matrix"); Parse_Matrix(ctlfile); done_matrix=TRUE; } else if (eqstri(p,"colour") || eqstri(p,"color") || eqstri(p,"colours") || eqstri(p,"colors")) { Compiling(LAST_SECTION,cc_section,"Colors"); Parse_Colours(ctlfile); done_colours=TRUE; } else if (eqstri(p,"session")) { Compiling(LAST_SECTION,cc_section,"Session"); Parse_Session(ctlfile); done_session=TRUE; } else if (eqstri(p,"language")) { Compiling(LAST_SECTION,cc_section,"Language"); Parse_Language(ctlfile); done_language=TRUE; } else if (eqstri(p,"reader")) { Compiling(LAST_SECTION,cc_section,"Reader"); Parse_Reader(ctlfile); } else if (eqstri(p, "msgdivisionbegin")) { char acs[PATHLEN]; char displayfile[PATHLEN]; linenum++; /* MsgDivisionBegin comp sysop/1234 misc\msgname The InterNet comp.* hierarchy */ getword(line, p, ctl_delim, 2); getword(line, acs, ctl_delim, 3); getword(line, displayfile, ctl_delim, 4); ParseMsgDivisionBegin(p, acs, displayfile, fchar(line, ctl_delim, 5)); } else if (eqstri(p, "filedivisionbegin")) { char acs[PATHLEN]; char displayfile[PATHLEN]; linenum++; /* FileDivisionBegin comp sysop/1234 misc\filename The InterNet comp.* hierarchy */ getword(line, p, ctl_delim, 2); getword(line, acs, ctl_delim, 3); getword(line, displayfile, ctl_delim, 4); ParseFileDivisionBegin(p, acs, displayfile, fchar(line, ctl_delim, 5)); } else if (eqstri(p, "msgdivisionend")) { linenum++; ParseMsgDivisionEnd(); } else if (eqstri(p, "filedivisionend")) { linenum++; ParseFileDivisionEnd(); } else if (eqstri(p,"msgarea")) { linenum++; getword(line,p,ctl_delim,2); Compiling(LAST_AREA,cc_area,p); ParseMsgArea(ctlfile, p); } else if (eqstri(p,"filearea")) { linenum++; getword(line,p,ctl_delim,2); Compiling(LAST_AREA,cc_area,p); ParseFileArea(ctlfile, p); } else if (eqstri(p,"protocol")) { strcpy(p, fchar(line, ctl_delim, 2)); Compiling(LAST_SECTION, cc_section, p); Parse_Protocol(ctlfile, p); } else if (eqstri(p,"menu")) { strcpy(p,fchar(line,ctl_delim,2)); Compiling(LAST_MENU,cc_menu,p); Parse_Menu(ctlfile,p); } else if (eqstri(p,"section")) { linenum++; while (fgets(line,MAX_LINE,ctlfile) != NULL) { linenum++; getword(line,p," \t\n",1); if (eqstri(p,"end")) break; } } else if (eqstri(p,"include")) { getword(line,p,ctl_delim,2); linenum++; x=linenum; last=LAST_NONE; Parse_Ctlfile(p); strcpy(ctl_name,ctlname); linenum=x; } else if (eqstri(p, "max20area")) { getword(line, p, ctl_delim, 2); if (p[1] != ':' && p[0] != '\\' && p[0] != '/') { strcpy(temp, strings + prm.sys_path); strcat(temp, p); strcpy(p, temp); } strcpy(max20area, p); strcpy(temp, p); strcat(temp, ".dat"); Make_String(prm.adat_name, temp); strcpy(temp, p); strcat(temp, ".idx"); Make_String(prm.aidx_name, temp); } else if (eqstri(p,"version14")) ; else if (eqstri(p,"version17")) ; else if (eqstri(p, "app") || eqstri(p, "application")) ; else Unknown_Ctl(linenum++,p); } else linenum++; } fclose(ctlfile); if (bufr) free(bufr); return 0; }
int VerbParse(void *pfi, struct _vbtab *verbs, char *line) { char *words[MAX_PARSE_WORDS], *p; char szFirstWord[PATHLEN]; struct _vbtab *pvt; int w, rc; rc=FALSE; Strip_Trailing(line, '\n'); if ((p=strchr(line, '%')) != NULL) *p='\0'; if ((p=strchr(line, ';')) != NULL) *p='\0'; /* Speed up parsing if we're only looking for the first word */ if (!verbs) { words[0]=szFirstWord; getword(line, words[0], ctl_delim, 1); } else { for (w=0; w < MAX_PARSE_WORDS; w++) { if ((words[w]=malloc(PATHLEN))==NULL) NoMem(); if (w==0 || *words[w-1]) getword(line, words[w], ctl_delim, w+1); else *words[w]=0; } } /* Find this in verb table */ if (verbs) for (pvt=verbs; pvt->verb && !eqstri(words[0], pvt->verb); pvt++) ; /* If we didn't get a match */ if (!verbs || !pvt->verb) { if (eqstri(words[0], "end")) rc=TRUE; else if (*words[0] && verbs) Unknown_Ctl(linenum, words[0]); } else { /* If we have a filter function, call it with a ptr to the second word */ if (pvt->f) (*pvt->f)(pfi, words, fchar(line, ctl_delim, 2)); /* Add this to a zstr heap, if necessary */ if (pvt->pzstr) HeapAdd(&PFI(pfi)->h, pvt->pzstr, fchar(line, ctl_delim, 2)); } /* Deallocate the space used for these words */ if (verbs) for (w=0; w < MAX_PARSE_WORDS; w++) free(words[w]); linenum++; return rc; }
int Parse_Reader(FILE *ctlfile) { char temp[MAX_LINE], /* Contains entire line */ p[MAX_LINE]; /* First word on line */ linenum++; while (fgets(line,MAX_LINE,ctlfile)) { Strip_Comment(line); if (*line) { strcpy(temp,line); getword(line,p,ctl_delim,1); if (! *p) ; else if (eqstri(p,"end")) break; else if (eqstri(p,"archivers")) { getword(line,p,ctl_delim,2); Make_Filename(prm.arc_ctl,p); } else if (eqstri(p,"packet")) { getword(line,p,ctl_delim,3); p[8]='\0'; Make_String(prm.olr_name,p); } else if (eqstri(p,"work")) { getword(line,p,ctl_delim,3); Make_Path(prm.olr_dir,p); if (! direxist(p)) makedir(p); } else if (eqstri(p,"phone")) { Make_String(prm.phone_num, fchar(line, ctl_delim, 3)); } else if (eqstri(p, "max")) { getword(line, p, ctl_delim, 3); prm.max_pack=(word)atoi(p); } else if (eqstri(p,"app") || eqstri(p,"application")) ; else Unknown_Ctl(linenum,p); } linenum++; } linenum++; return 0; }