void read_pargh() { int s,i; long *d; char c; if (odstavce!=NULL) free(odstavce); odstavce=NULL; s=(pocet=i=count_pargh())*sizeof(long)*2; if (s==0) return; odstavce=getmem(s); d=odstavce; fseek(dlg,0,SEEK_SET); c=get_article(); while (c!=0xff && i) { if (c==':') { fscanf(dlg,"%d",&s); *d++=s; *d++=ftell(dlg); i--; } if (c!='\n') new_line(); c=get_article(); } }
int count_pargh() { char c; int i=0; fseek(dlg,0,SEEK_SET); c=get_article(); while (c!=0xff) { if (c==':') i++; if (c!='\n') new_line(); c=get_article(); } return i; }
void proved_d(char *code,char *text) { static int mode=0; static char *save_text; do { if (mode==0) { *code=get_article(); switch (*code) { case ';': case ':':*code=0xff;new_line();break; case '.':*code=1;break; case '_':*code=2;break; case '"':*code=3;break; case '?':*code=4;selptr++;break; case '*':*code=0;break; default :*code=0xff;break; } if (*code!=0xff)fscanf(dlg,"%[^\n]",text); if (*code==0) { strupr(text); if (!strncmp(text,"GOTO",4)) { int n; sscanf(text+4,"%d",&n); proved_goto(n); } if (!strncmp(text,"JUMP",4)) { int n; sscanf(text+4,"%d",&n); jdi_na_odstavec(n); } else if (!strncmp(text,"DISABLE",7)) set_flags(param(text+7),0xff,1); else if (!strncmp(text,"ENABLE",6)) set_flags(param(text+7),0xfe,0); else if (!strncmp(text,"CHOICE",6)) { *text=selptr; selptr=0; *code=5; mode=1; save_text=getmem(strlen(text)-6+1); strcpy(save_text,text+6); } else if (!strncmp(text,"STOP",4)) *code=7; else if (!strncmp(text,"MENU",4)) selptr=param(text+4); } else if (*code==4) { long *l=najdi_odstavec(param(text)); char c,*d; c=l[1]>>24; if (c & 1) *code=6; d=text;while (*d>='0' && *d<='9') d++; strcpy(text,d); } }
/* * Scan for new news available at the nntp server. */ void ScanNews(void) { List *art = NULL; POverview tmp, old; FILE *pAreas; char *sAreas; struct msgareashdr Msgshdr; struct msgareas Msgs; IsDoing((char *)"Scan News"); if (nntp_connect() == -1) { WriteError("Can't connect to newsserver"); return; } if (get_xoverview()) { return; } if (!do_quiet) { mbse_colour(LIGHTGREEN, BLACK); printf("Scan for new news articles\n"); } sAreas = calloc(PATH_MAX, sizeof(char)); snprintf(sAreas, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if(( pAreas = fopen (sAreas, "r")) == NULL) { WriteError("$Can't open Messages Areas File."); return; } fread(&Msgshdr, sizeof(Msgshdr), 1, pAreas); while (fread(&Msgs, Msgshdr.recsize, 1, pAreas) == 1) { fseek(pAreas, Msgshdr.syssize, SEEK_CUR); #ifdef USE_NEWSGATE if ((Msgs.Active) && strlen(Msgs.Newsgroup)) { #else if ((Msgs.Active) && strlen(Msgs.Newsgroup) && (Msgs.Type == NEWS)) { #endif if (IsSema((char *)"upsalarm")) { Syslog('+', "Detected upsalarm semafore, aborting newsscan"); break; } Syslog('m', "Scan newsgroup: %s", Msgs.Newsgroup); if (!do_quiet) { mbse_colour(CYAN, BLACK); printf("\r%-40s", Msgs.Newsgroup); fflush(stdout); } Nopper(); if (do_one_group(&art, Msgs.Newsgroup, Msgs.Tag, Msgs.MaxArticles) == RETVAL_ERROR) break; /* * To be safe, update the dupes database after each area. */ CloseDupes(); } } fclose(pAreas); free(sAreas); for (tmp = xoverview; tmp; tmp = old) { old = tmp->next; if (tmp->header) free(tmp->header); if (tmp->field) free(tmp->field); free(tmp); } nntp_close(); do_flush = TRUE; if (!do_quiet) printf("\r \r"); } int do_one_group(List **art, char *grpname, char *ftntag, int maxarticles) { List *tmp; char temp[128], *resp; int retval, fetched = 0; int total, start, end; Syslog('m', "do_one_group(%s, %s)", grpname, ftntag); IsDoing((char *)"Scan %s", grpname); snprintf(temp, 128, "GROUP %s\r\n", grpname); nntp_send(temp); resp = nntp_receive(); retval = atoi(strtok(resp, " ")); if (retval == 480) { /* * We must login */ if (nntp_auth() == FALSE) { WriteError("Authorisation failure"); nntp_close(); return RETVAL_NOAUTH; } nntp_send(temp); resp = nntp_receive(); retval = atoi(strtok(resp, " ")); } if (retval != 211) { if (retval == 411) { WriteError("No such newsgroup: %s", grpname); return RETVAL_UNEXPECTEDANS; } WriteError("Unknown response %d to GROUP command", retval); return RETVAL_ERROR; } total = atol(strtok(NULL, " ")); start = atol(strtok(NULL, " ")); end = atol(strtok(NULL, " '\0'")); Syslog('m', "GROUP total %d, start %d, end %d, max %d", total, start, end, maxarticles); if ((maxarticles) && (total > maxarticles)) { start = end - maxarticles; total = maxarticles; Syslog('m', "NEW: total %d, start %d, end %d", total, start, end); } if (!total) { Syslog('+', "Fetched 0 articles from %s", grpname); return RETVAL_NOARTICLES; } retval = get_xover(grpname, start, end, art); if (retval != RETVAL_OK) { tidy_artlist(art); return retval; } if (!do_learn) { for (tmp = *art; tmp; tmp = tmp->next) { if (!tmp->isdupe) { /* * If the message isn't a dupe, it must be new for us. */ get_article(tmp->msgid, ftntag); fetched++; } } } tidy_artlist(art); if ((maxarticles) && (fetched == maxarticles)) Syslog('!', "Warning: the max. articles value in newsgroup %s might be to low", grpname); Syslog('+', "Fetched %d article%s from %s", fetched, (fetched == 1) ? "":"s", grpname); return RETVAL_OK; }