TO TRANSFORM origb4/src/news/rnews.c INTO au117b4/src/news/rnews.c ... *** APPEND AFTER 90 IN origb4/src/news/rnews.c *** >#define IGREG (15+31L*(10+12L*1582)) >#define LOCK "T:HISTORY.LCK" > >struct _history { > long stamp; > char msgid[80]; >} *old_hist, *new_hist; >long histcnt = 0, oldcnt = 0; >long histsiz = 0; >int loaded; >long jul; >FILE *msgf; > *** APPEND AFTER 99 IN origb4/src/news/rnews.c *** >int SaveMessageID(const char *id); >void SaveHistory(void); >void FreeLock(const char *name); >int SetLock(const char *name); *** APPEND AFTER 155 IN origb4/src/news/rnews.c *** > long tv; > struct tm *tp; > int m, d, y; > int ja, jy, jm; > *** APPEND AFTER 157 IN origb4/src/news/rnews.c *** > loaded = 0; > *** APPEND AFTER 162 IN origb4/src/news/rnews.c *** > tv = time(NULL); > tp = localtime(&tv); > m = tp->tm_mon+1; > d = tp->tm_mday; > y = tp->tm_year + 1900L; > > if (m > 2) > { > jy = y; > jm = m+1; > } > else > { > jy = y-1; > jm = m+13; > } > jul = (long)((long)(365.25*(float)jy)+(long)(30.6001*(float)jm)+d+1720995L); > if (d+31L*(m+12L*y) >= IGREG) > { > ja = 0.01*jy; > jul += 2-ja+(int)(0.025*ja); > } > > SetLock(LOCK); > *** CHANGE 740 IN origb4/src/news/rnews.c TO 789 IN au117b4/src/news/rnews.c *** < *grp; --------------- > *grp, *msgid; *** APPEND AFTER 743 IN origb4/src/news/rnews.c *** > if (ScanHeader(base, "Message-ID:")) > ScanHeader(base, "Message-Id:"); > > msgid = ScanNext(); > > if (SaveMessageID(msgid)) > { > ulog(-1, "Duplicate ID Found: %s", msgid); > return; > } > *** CHANGE 1116 IN origb4/src/news/rnews.c TO [1176,1180] IN au117b4/src/news/rnews.c *** < --------------- > > SaveHistory(); > > FreeLock(LOCK); > *** APPEND AFTER 1162 IN origb4/src/news/rnews.c *** >#if 0 *** APPEND AFTER 1163 IN origb4/src/news/rnews.c *** >#else > memset (gp, 0, sizeof(group)); >#endif *** APPEND AFTER 1203 IN origb4/src/news/rnews.c *** > >int SetLock(const char *name) >{ > FILE *lck; > > while (lck = fopen(name,"r")) > { > fclose(lck); > Delay(5000); > } > lck = fopen(name,"w"); > fputs("LOCK",lck); > fclose(lck); > return 0; >} > >void FreeLock(const char *name) >{ > remove(name); >} > >void SaveHistory(void) >{ > long histtotal; > > if (loaded && (histcnt > 0)) > { > histtotal = histcnt + oldcnt; > > msgf = fopen("UULIB:HISTORY.FIL","r+"); > if (msgf == NULL) > msgf = fopen("UULIB:HISTORY.FIL","w"); > fwrite(&histtotal,sizeof(long),1,msgf); > if (oldcnt) > fseek(msgf,0,SEEK_END); > fwrite(new_hist,sizeof(struct _history),histcnt,msgf); > fclose(msgf); > } >} > >int SaveMessageID(const char *id) >{ > long i; > > if (PostNews) > { > msgf = fopen("UULIB:HISTORY.FIL","r"); > if (msgf == NULL) > oldcnt = 0; > else > { > fread(&oldcnt,sizeof(long),1,msgf); > fclose(msgf); > } > loaded = 1; > } > else if (!loaded) > { > msgf = fopen("UULIB:HISTORY.FIL","r"); > if (msgf == NULL) > oldcnt = 0; > else > { > fread(&oldcnt,sizeof(long),1,msgf); > i = 0; > while ((old_hist == NULL) && (i < 10)) > { > old_hist = calloc(oldcnt,sizeof(struct _history)); > if ((old_hist == NULL) && (i >= 10)) > { > ulog (-1, "malloc() : out of memory"); > exit(30); > } > i++; > if (old_hist == NULL) > Delay(100000L); > } > if (oldcnt) > fread(old_hist,sizeof(struct _history),oldcnt,msgf); > fclose(msgf); > } > loaded = 1; > } > if (PostNews == 0) > for (i = 0; i < oldcnt; i++) > if (strcmp(id,old_hist[i].msgid) == 0) > return (1); > for (i = 0; i < histcnt; i++) > if (strcmp(id,new_hist[i].msgid) == 0) > return (1); > if (histcnt+1 > histsiz) > { > histsiz += 1024; > if (new_hist) > new_hist = realloc(new_hist,histsiz*sizeof(struct _history)); > else > new_hist = calloc(histsiz,sizeof(struct _history)); > if (new_hist == NULL) > { > ulog(-1, "realloc() : out of memory"); > exit(30); > } > } > memset(&new_hist[histcnt],0,sizeof(struct _history)); > new_hist[histcnt].stamp = jul; > strncpy(new_hist[histcnt].msgid,id,79); > histcnt++; > return(0); >} >