/* * Generate a header for the replies containing the name of the author * from the original message. * * By Kalle Soiha, 1997 * More Ultimate Patches (tm) by B, 1997 * Modified for 3.42 * Even More Ultimate Patches And Fixes (tm) for 3.42 beta by B, 1998 * * Beerware - drink beer while you use it. -- Soiha * Vodkaware - drink vodka while you use it. -- B */ #include "obsolete.bzh" #include "stdlib.bzh" #define size_of_headerblock 268 char t_monthname(int m) { char months={ "January","February","March","April","May","June","July", "August","September","October","November","December" }; return(months[m-1]); } char t_numberpostfix(int n) { if (n>=11 && n<=13) return("th"); if ((n % 10)==1) return("st"); if ((n % 10)==2) return("nd"); if ((n % 10)==3) return("rd"); return("th"); } int fgetword(FILE f) { return(fgetc(f)+(fgetc(f)<<8)); } int fgetlong(FILE f) { return(fgetword(f)+(fgetword(f)<<16)); } int bun_year(int l) { return(((l>>25) & 127)+1980); } int bun_month(int l) { return((l>>21) & 15); } int bun_day(int l) { return((l>>16) & 31); } int main(char file, int confnrosave, int confnroread, int replyto) { FILE f; char from, txt; int dated, i, i1, firstmsg; if (replyto && !regexp("BBBS",stupcase(bc_confname[confnroread]))) { if ((f=fopen(sprintf("%s/%08x.dat",bg_maindir,confnroread),"rb"))==-1) return(1); firstmsg=fgetlong(f); fseek(f,(replyto-firstmsg)*size_of_headerblock+4,SEEK_SET); from=fgets(f); fseek(f,(replyto-firstmsg)*size_of_headerblock+236,SEEK_SET); dated=fgetlong(f); fclose(f); if ((f=fopen(file,"rt"))==-1) return(1); for (i=0;; ++i) { txt[i]=fgets(f); if (feof(f)) break; } fclose(f); if ((f=fopen(file,"wt"))==-1) return(1); fprintf(f,"%s said on %s at %u%s of %s %u:\n\n", from, bc_confname[confnroread], bun_day(dated), t_numberpostfix(bun_day(dated)), t_monthname(bun_month(dated)), bun_year(dated)); for (i1=0; i1