diff --git a/ChangeLog b/ChangeLog index e81b731c..2ee8fbdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4702,7 +4702,8 @@ v0.33.20 10-Feb-2002 mbaff: The High-ascii table to translate to lowercase has now the right values to translate the ansi graphics. - Now uses the template newfiles to create the reports. + Now uses the template newfiles and filefind to create the + reports. mbtask: Removed some debug logging. diff --git a/examples/templates.tar b/examples/templates.tar index 401da616..e9b756c7 100644 Binary files a/examples/templates.tar and b/examples/templates.tar differ diff --git a/mbfido/announce.c b/mbfido/announce.c index d11abbc6..a857f4aa 100644 --- a/mbfido/announce.c +++ b/mbfido/announce.c @@ -242,21 +242,15 @@ void FinishMsg(int Final, long filepos) temp = calloc(PATH_MAX, sizeof(char)); - if (Final) { - if ((fi = OpenMacro(newfiles.Template, newfiles.Language)) != NULL) { - MacroVars("CD", "dd", TotalFiles, TotalSize); - fseek(fi, filepos, SEEK_SET); - Msg_Macro(fi); - fclose(fi); - MacroClear(); - } else { - MsgText_Add2((char *)""); - sprintf(temp, "This is a total of %d files, %lu Kbytes", TotalFiles, TotalSize); - MsgText_Add2(temp); - MsgText_Add2((char *)""); - sprintf(temp, "With regards, %s", CFG.sysop_name); - MsgText_Add2(temp); - } + if (Final && ((fi = OpenMacro(newfiles.Template, newfiles.Language)) != NULL)) { + /* + * Message footer + */ + MacroVars("CD", "dd", TotalFiles, TotalSize); + fseek(fi, filepos, SEEK_SET); + Msg_Macro(fi); + fclose(fi); + MacroClear(); } if (strlen(newfiles.Origin)) @@ -280,6 +274,9 @@ void FinishMsg(int Final, long filepos) +/* + * Report one group block of new files. + */ long Report(gr_list *, long); long Report(gr_list *ta, long filepos) { @@ -302,14 +299,16 @@ long Report(gr_list *ta, long filepos) } if ((fi = OpenMacro(newfiles.Template, newfiles.Language)) != NULL) { + /* + * Area block header + */ MacroVars("GJZ", "ssd", T_File.Echo, T_File.Comment, 0); fseek(fi, filepos, SEEK_SET); Msg_Macro(fi); filepos1 = ftell(fi); } else { - sprintf(temp, "Area %s - %s", T_File.Echo, T_File.Comment); - MsgText_Add2(temp); - MsgText_Add2((char *)"------------------------------------------------------------------------"); + free(temp); + return 0; } fseek(fp, 0, SEEK_SET); @@ -319,74 +318,51 @@ long Report(gr_list *ta, long filepos) if (CFG.slow_util && do_quiet) usleep(1); - if (fi != NULL) { - fseek(fi, filepos1, SEEK_SET); - MacroVars("slbkdt", "ssddss", T_File.Name, T_File.LName, T_File.Size, T_File.SizeKb, " ", + /* + * Report one newfile, first line. + */ + fseek(fi, filepos1, SEEK_SET); + MacroVars("slbkdt", "ssddss", T_File.Name, T_File.LName, T_File.Size, T_File.SizeKb, " ", To_Low(T_File.LDesc[0],newfiles.HiAscii)); - Msg_Macro(fi); - filepos2 = ftell(fi); - for (i = 1; i < 24; i++) { - MacroVars("t", "s", To_Low(T_File.LDesc[i],newfiles.HiAscii)); - fseek(fi, filepos2, SEEK_SET); - if (strlen(T_File.LDesc[i])) { - Msg_Macro(fi); - } else { - line = calloc(255, sizeof(char)); - while ((fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {} - free(line); - } - filepos3 = ftell(fi); + Msg_Macro(fi); + filepos2 = ftell(fi); + /* + * Extra description lines follow + */ + for (i = 1; i < 24; i++) { + MacroVars("t", "s", To_Low(T_File.LDesc[i],newfiles.HiAscii)); + fseek(fi, filepos2, SEEK_SET); + if (strlen(T_File.LDesc[i])) { + Msg_Macro(fi); + } else { + line = calloc(255, sizeof(char)); + while ((fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {} + free(line); } - } else { - sprintf(temp, "%-12s %5lu Kb. %s", T_File.Name, T_File.SizeKb, To_Low(T_File.LDesc[0],newfiles.HiAscii)); - MsgText_Add2(temp); - if (T_File.TotLdesc > 0) - for (i = 1; i < T_File.TotLdesc; i++) { - sprintf(temp, " %s", To_Low(T_File.LDesc[i],newfiles.HiAscii)); - MsgText_Add2(temp); - } + filepos3 = ftell(fi); } Total++; Size += T_File.SizeKb; - - /* - * Split message the hard way. - */ - if (Msg.Size > (CFG.new_force * 1024)) { - MacroVars("Z", "d", 1); - MsgText_Add2((char *)""); - MsgText_Add2((char *)"to be continued..."); - MsgCount++; - FinishMsg(FALSE, finalpos); - StartMsg(); - } - if ((Msg.Size > (CFG.new_split * 1024)) && (fi != NULL)) { - MacroVars("Z", "d", 1); - } } } - if (fi != NULL) { - MacroVars("AB", "dd", Total, Size); - fseek(fi, filepos3, SEEK_SET); - Msg_Macro(fi); - finalpos = ftell(fi); - } else { - MsgText_Add2((char *)"------------------------------------------------------------------------"); - sprintf(temp, "%d files, %lu Kb", Total, Size); - MsgText_Add2(temp); - MsgText_Add2((char *)""); - MsgText_Add2((char *)""); - } + /* + * Area block footer + */ + if (Msg.Size > (CFG.new_split * 1024)) + MacroVars("ABZ", "ddd", Total, Size, 1); + else + MacroVars("ABZ", "ddd", Total, Size, 0); + fseek(fi, filepos3, SEEK_SET); + Msg_Macro(fi); + finalpos = ftell(fi); fclose(fp); free(temp); /* - * Split messages the gently way. + * Split messages if too big. */ if (Msg.Size > (CFG.new_split * 1024)) { - MsgText_Add2((char *)""); - MsgText_Add2((char *)"to be continued..."); MsgCount++; FinishMsg(FALSE, finalpos); StartMsg(); diff --git a/mbfido/filefind.c b/mbfido/filefind.c index 922e5986..3dd1d81f 100644 --- a/mbfido/filefind.c +++ b/mbfido/filefind.c @@ -38,6 +38,7 @@ #include "../lib/dbcfg.h" #include "../lib/msg.h" #include "../lib/msgtext.h" +#include "../lib/diesel.h" #include "fflist.h" #include "filefind.h" #include "msgutil.h" @@ -50,7 +51,7 @@ * For netmail replies there is a different limit. */ #define MAX_DESC_LINES 5 -#define MAX_FILES_SAMEBOARD 15 +#define MAX_FILES_SAMEBOARD 25 #define MAX_FILES_OTHERBOARD 50 #define MAX_FILES_NETMAIL 100 @@ -64,14 +65,14 @@ int Replies = 0; /* Total generated replies */ void Back(int); void Back(int count) { - int i; + int i; - if (do_quiet) - return; + if (do_quiet) + return; - for (i = 0; i < count; i++) - printf("\b"); - fflush(stdout); + for (i = 0; i < count; i++) + printf("\b"); + fflush(stdout); } @@ -79,14 +80,14 @@ void Back(int count) void Clean(int); void Clean(int count) { - int i; + int i; - if (do_quiet) - return; + if (do_quiet) + return; - for (i = 0; i < count; i++) - printf(" "); - Back(count); + for (i = 0; i < count; i++) + printf(" "); + Back(count); } @@ -94,154 +95,148 @@ void Clean(int count) void ScanArea(ff_list **); void ScanArea(ff_list **ffl) { - unsigned long Number, Highest; + unsigned long Number, Highest; - if (!do_quiet) { - colour(3, 0); - printf("\r %-40s", scanmgr.Comment); - colour(12, 0); - printf(" (Scanning) "); - colour(13, 0); - fflush(stdout); - } - Syslog('+', "Scanning %s", scanmgr.Comment); - if (Msg_Open(scanmgr.ScanBoard)) { - Number = Msg_Lowest(); - Highest = Msg_Highest(); + if (!do_quiet) { + colour(3, 0); + printf("\r %-40s", scanmgr.Comment); + colour(12, 0); + printf(" (Scanning) "); + colour(13, 0); + fflush(stdout); + } + Syslog('+', "Scanning %s", scanmgr.Comment); + if (Msg_Open(scanmgr.ScanBoard)) { + Number = Msg_Lowest(); + Highest = Msg_Highest(); - do { - if (!do_quiet) { - printf("%6lu / %6lu", Number, Highest); - Back(15); - } + do { + if (!do_quiet) { + printf("%6lu / %6lu", Number, Highest); + Back(15); + } - if (CFG.slow_util && do_quiet) - usleep(1); + if (CFG.slow_util && do_quiet) + usleep(1); - if (Msg_ReadHeader(Number) == TRUE) { - if (((!strcasecmp(Msg.To, "allfix")) || - (!strcasecmp(Msg.To, "filefind"))) && - (!Msg.Received)) { - Syslog('m', "Msg: %s (%lu) [%s]", Msg.From, Number, Msg.Subject); - Msg.Received = TRUE; - Msg.Read = time(NULL); - if (Msg_Lock(30L)) { - Msg_WriteHeader(Number); - Msg_UnLock(); - Syslog('m', "Marked message received"); - } - if (strlen(Msg.Subject) && strlen(Msg.FromAddress)) { - fill_fflist(ffl); - Requests++; - } - } - } + if (Msg_ReadHeader(Number) == TRUE) { + if (((!strcasecmp(Msg.To, "allfix")) || (!strcasecmp(Msg.To, "filefind"))) && (!Msg.Received)) { + Syslog('m', "Msg: %s (%lu) [%s]", Msg.From, Number, Msg.Subject); + Msg.Received = TRUE; + Msg.Read = time(NULL); + if (Msg_Lock(30L)) { + Msg_WriteHeader(Number); + Msg_UnLock(); + Syslog('m', "Marked message received"); + } + if (strlen(Msg.Subject) && strlen(Msg.FromAddress)) { + fill_fflist(ffl); + Requests++; + } + } + } - } while (Msg_Next(&Number) == TRUE); - - Msg_Close(); - Clean(15); - } else - WriteError("$Can't open %s", scanmgr.ScanBoard); - - Back(54); - Clean(54); -} - - - -int StartReply(ff_list *); -int StartReply(ff_list *ffl) -{ - char *temp; - unsigned long crc = -1; - - if (strlen(scanmgr.ReplBoard)) { - if (!Msg_Open(scanmgr.ReplBoard)) - return FALSE; - else - CountPosted(scanmgr.ReplBoard); - } else { - if (!Msg_Open(scanmgr.ScanBoard)) - return FALSE; - else - CountPosted(scanmgr.ScanBoard); - } - - if (!Msg_Lock(30L)) { - Msg_Close(); - return FALSE; - } - Msg_New(); - - temp = calloc(PATH_MAX, sizeof(char)); - - sprintf(Msg.From, "%s", CFG.sysop_name); - sprintf(Msg.To, "%s", ffl->from); - sprintf(Msg.Subject, "Re: %s", ffl->subject); - sprintf(Msg.FromAddress, "%s", aka2str(scanmgr.Aka)); - Msg.Written = time(NULL); - Msg.Arrived = time(NULL); - Msg.Local = TRUE; - if (scanmgr.NetReply){ - Msg.Netmail = TRUE; - sprintf(Msg.ToAddress, "%d:%d/%d.%d", ffl->zone, ffl->net, ffl->node, ffl->point); - } - else - Msg.Echomail = TRUE; - - /* - * Start message text including kludges - */ - Msg_Id(scanmgr.Aka); - sprintf(temp, "\001REPLY: %s", ffl->msgid); - MsgText_Add2(temp); - Msg.ReplyCRC = upd_crc32(temp, crc, strlen(temp)); - Msg_Pid(); - Msg_Top(scanmgr.template, scanmgr.Language, scanmgr.Aka); - - return TRUE; -} - - - -void FinishReply(int, int); -void FinishReply(int Reported, int Total) -{ - char *temp; - FILE *fp; - - temp = calloc(PATH_MAX, sizeof(char)); - - MsgText_Add2((char *)""); - if (Reported < Total) { - sprintf(temp, "Listed %d out of %d files matching your search request", Reported, Total); - MsgText_Add2(temp); - MsgText_Add2((char *)"For more information, visit our BBS"); - } else { - sprintf(temp, "Found %d files matching your search request", Reported); - MsgText_Add2(temp); - } - - if (strlen(scanmgr.Origin)) - Msg_Bot(scanmgr.Aka, scanmgr.Origin, scanmgr.template); - else - Msg_Bot(scanmgr.Aka, CFG.origin, scanmgr.template); - Msg_AddMsg(); - Msg_UnLock(); - Syslog('+', "Posted message %ld", Msg.Id); - - sprintf(temp, "%s/tmp/echomail.jam", getenv("MBSE_ROOT")); - if ((fp = fopen(temp, "a")) != NULL) { - if (strlen(scanmgr.ReplBoard)) - fprintf(fp, "%s %lu\n", scanmgr.ReplBoard, Msg.Id); - else - fprintf(fp, "%s %lu\n", scanmgr.ScanBoard, Msg.Id); - fclose(fp); - } + } while (Msg_Next(&Number) == TRUE); Msg_Close(); - free(temp); + Clean(15); + } else + WriteError("$Can't open %s", scanmgr.ScanBoard); + + Back(54); + Clean(54); +} + + + +long StartReply(ff_list *); +long StartReply(ff_list *ffl) +{ + char *temp; + unsigned long crc = -1; + + if (strlen(scanmgr.ReplBoard)) { + if (!Msg_Open(scanmgr.ReplBoard)) + return -1; + else + CountPosted(scanmgr.ReplBoard); + } else { + if (!Msg_Open(scanmgr.ScanBoard)) + return -1; + else + CountPosted(scanmgr.ScanBoard); + } + + if (!Msg_Lock(30L)) { + Msg_Close(); + return -1; + } + Msg_New(); + + temp = calloc(PATH_MAX, sizeof(char)); + + sprintf(Msg.From, "%s", CFG.sysop_name); + sprintf(Msg.To, "%s", ffl->from); + sprintf(Msg.Subject, "Re: %s", ffl->subject); + sprintf(Msg.FromAddress, "%s", aka2str(scanmgr.Aka)); + Msg.Written = time(NULL); + Msg.Arrived = time(NULL); + Msg.Local = TRUE; + if (scanmgr.NetReply){ + Msg.Netmail = TRUE; + sprintf(Msg.ToAddress, "%d:%d/%d.%d", ffl->zone, ffl->net, ffl->node, ffl->point); + } else + Msg.Echomail = TRUE; + + /* + * Start message text including kludges + */ + Msg_Id(scanmgr.Aka); + sprintf(temp, "\001REPLY: %s", ffl->msgid); + MsgText_Add2(temp); + Msg.ReplyCRC = upd_crc32(temp, crc, strlen(temp)); + free(temp); + Msg_Pid(); + return Msg_Top(scanmgr.template, scanmgr.Language, scanmgr.Aka); +} + + + +void FinishReply(int, int, long); +void FinishReply(int Reported, int Total, long filepos) +{ + char *temp; + FILE *fp, *fi; + + temp = calloc(PATH_MAX, sizeof(char)); + + if ((fi = OpenMacro(scanmgr.template, scanmgr.Language)) != NULL) { + MacroVars("CD", "dd", Reported, Total); + fseek(fi, filepos, SEEK_SET); + Msg_Macro(fi); + fclose(fi); + MacroClear(); + } + + if (strlen(scanmgr.Origin)) + Msg_Bot(scanmgr.Aka, scanmgr.Origin, scanmgr.template); + else + Msg_Bot(scanmgr.Aka, CFG.origin, scanmgr.template); + Msg_AddMsg(); + Msg_UnLock(); + Syslog('+', "Posted message %ld", Msg.Id); + + sprintf(temp, "%s/tmp/%smail.jam", getenv("MBSE_ROOT"), scanmgr.NetReply?"net":"echo"); + if ((fp = fopen(temp, "a")) != NULL) { + if (strlen(scanmgr.ReplBoard)) + fprintf(fp, "%s %lu\n", scanmgr.ReplBoard, Msg.Id); + else + fprintf(fp, "%s %lu\n", scanmgr.ScanBoard, Msg.Id); + fclose(fp); + } + + Msg_Close(); + free(temp); } @@ -252,275 +247,291 @@ void FinishReply(int Reported, int Total) void ScanFiles(ff_list *); void ScanFiles(ff_list *tmp) { - char *temp, *kwd, *BigDesc; - FILE *pAreas, *pFile; - unsigned long areanr = 0, found = 0; - int i, j, k, keywrd, Found; - rf_list *rfl = NULL, *rft; - int Rep = 0, Sub = 0, Stop = FALSE; + char *temp, *kwd, *BigDesc, *line; + FILE *pAreas, *pFile, *fi; + unsigned long areanr = 0, found = 0, SubSize = 0; + int i, j, k, keywrd, Found; + rf_list *rfl = NULL, *rft; + int Rep = 0, Sub = 0, Stop = FALSE; + long filepos, filepos1 = 0, filepos2 = 0, filepos3 = 0, filepos4 = 0; - /* - * Check for local generated requests. - */ - if (!CFG.ct_LocalRep) { + /* + * Check for local generated requests. + */ + if (!CFG.ct_LocalRep) { + } + + kwd = calloc(81, sizeof(char)); + temp = calloc(1024, sizeof(char)); + BigDesc = calloc(1230, sizeof(char)); + + sprintf(temp, "%s (%d:%d/%d.%d)", tmp->from, tmp->zone, tmp->net, tmp->node, tmp->point); + Syslog('+', "ff: %s [%s]", temp, tmp->subject); + + if (!do_quiet) { + colour(3, 0); + temp[40] = '\0'; + printf("\r %-40s", temp); + colour(12, 0); + printf(" (Searching)"); + colour(13, 0); + fflush(stdout); + } + + sprintf(temp, "%s/etc/fareas.data", getenv("MBSE_ROOT")); + if ((pAreas = fopen(temp, "r")) != NULL) { + fread(&areahdr, sizeof(areahdr), 1, pAreas); + + while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { + areanr++; + Nopper(); + + if (CFG.slow_util && do_quiet) + usleep(1); + + if (!do_quiet) { + printf("%6lu / %6lu", areanr, found); + Back(15); + } + if (area.Available && area.FileFind) { + sprintf(temp, "%s/fdb/fdb%lu.data", getenv("MBSE_ROOT"), areanr); + if ((pFile = fopen(temp, "r")) != NULL) { + + while (fread(&file, sizeof(file), 1, pFile) == 1) { + for (i = 0; i < 25; i++) + sprintf(BigDesc, "%s%s", BigDesc, *(file.Desc + i)); + sprintf(temp, "%s", tmp->subject); + + Found = FALSE; + while (strlen(temp) && (!Found)) { + /* + * Split the search request in separate words. + */ + k = strlen(temp); + for (i = 0; i < k; i++) + if (temp[i] == ' ') + break; + if (i < k) { + strncpy(kwd, temp, i); + kwd[i] = '\0'; + for (j = 0; j < (k - i -1); j++) + temp[j] = temp[j+i+1]; + temp[j] = '\0'; + } else { + sprintf(kwd, "%s", temp); + temp[0] = '\0'; + } + + /* + * Check if it's a filename search or a keyword search. + */ + keywrd = FALSE; + if ((kwd[0] == '/') || (kwd[0] == '\\')) { + keywrd = TRUE; + for (i = 1; i < strlen(kwd); i++) + kwd[i-1] = kwd[i]; + kwd[i-1] = '\0'; + } + tl(kwd); + + if (strlen(kwd) > 3) { + if (strstr(file.Name, kwd) != NULL) { + Found = TRUE; + Syslog('m', "Found %s in %s in filename", kwd, file.Name); + } + if (keywrd && (strstr(tl(BigDesc), kwd) != NULL)) { + Found = TRUE; + Syslog('m', "Found %s in %s in description", kwd, file.Name); + } + } + } /* while (strlen(temp) && (!Found)) */ + if (Found) { + found++; + Syslog('m', "Found %s area %d", file.Name, areanr); + fill_rflist(&rfl, file.Name, areanr); + } + strcpy(BigDesc, ""); + } + + fclose(pFile); + } else + WriteError("$Can't open %s", temp); + } } + fclose(pAreas); + Clean(15); + } else + WriteError("$Can't open %s", temp); - kwd = calloc(81, sizeof(char)); - temp = calloc(1024, sizeof(char)); - BigDesc = calloc(1230, sizeof(char)); - - sprintf(temp, "%s (%d:%d/%d.%d)", tmp->from, tmp->zone, tmp->net, tmp->node, tmp->point); - Syslog('+', "ff: %s [%s]", temp, tmp->subject); + Back(12); + Clean(12); + if (found) { if (!do_quiet) { - colour(3, 0); - temp[40] = '\0'; - printf("\r %-40s", temp); - colour(12, 0); - printf(" (Searching)"); - colour(13, 0); - fflush(stdout); + colour(14, 0); + printf(" (Replying)"); + fflush(stdout); } - sprintf(temp, "%s/etc/fareas.data", getenv("MBSE_ROOT")); - if ((pAreas = fopen(temp, "r")) != NULL) { + if (((filepos = StartReply(tmp)) != -1) && ((fi = OpenMacro(scanmgr.template, scanmgr.Language)) != NULL)) { + areanr = 0; + + sprintf(temp, "%s/etc/fareas.data", getenv("MBSE_ROOT")); + if ((pAreas = fopen(temp, "r")) != NULL) { fread(&areahdr, sizeof(areahdr), 1, pAreas); - while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { - areanr++; + for (rft = rfl; rft; rft = rft->next) { - if (CFG.slow_util && do_quiet) - usleep(1); + /* + * Area footer + */ + if ((areanr != rft->area) && (Sub)) { + fseek(fi, filepos3, SEEK_SET); + MacroVars("AB", "dd", Sub, SubSize / 1024); + Msg_Macro(fi); + filepos4 = ftell(fi); + Sub = 0; + SubSize = 0; + } - if (!do_quiet) { - printf("%6lu / %6lu", areanr, found); - Back(15); + /* + * New area header + */ + if (areanr != rft->area) { + fseek(pAreas, ((rft->area - 1) * areahdr.recsize) + areahdr.hdrsize, SEEK_SET); + fread(&area, areahdr.recsize, 1, pAreas); + MacroVars("GJ", "ds", rft->area, area.Name); + fseek(fi, filepos, SEEK_SET); + Msg_Macro(fi); + filepos1 = ftell(fi); + areanr = rft->area; + } + + sprintf(temp, "%s/fdb/fdb%lu.data", getenv("MBSE_ROOT"), rft->area); + if ((pFile = fopen(temp, "r")) != NULL) { + while (fread(&file, sizeof(file), 1, pFile) == 1) + if (!strcmp(rft->filename, file.Name)) + break; + fclose(pFile); + MacroVars("slbkdt", "ssddss", file.Name, file.LName, file.Size, file.Size / 1024, " ", + To_Low(file.Desc[0],scanmgr.HiAscii)); + fseek(fi, filepos1, SEEK_SET); + Msg_Macro(fi); + filepos2 = ftell(fi); + SubSize += file.Size; + + /* + * We add no more then 5 description lines + * to prevent unnecesary long messages. + */ + for (i = 1; i < MAX_DESC_LINES; i++) { + MacroVars("t", "s", To_Low(file.Desc[i],scanmgr.HiAscii)); + fseek(fi, filepos2, SEEK_SET); + if (strlen(file.Desc[i])) { + Msg_Macro(fi); + } else { + line = calloc(255, sizeof(char)); + while ((fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {} + free(line); + } + filepos3 = ftell(fi); } - if (area.Available && area.FileFind) { - sprintf(temp, "%s/fdb/fdb%lu.data", getenv("MBSE_ROOT"), areanr); - if ((pFile = fopen(temp, "r")) != NULL) { + } + Rep++; + Sub++; - while (fread(&file, sizeof(file), 1, pFile) == 1) { - for (i = 0; i < 25; i++) - sprintf(BigDesc, "%s%s", BigDesc, *(file.Desc + i)); - sprintf(temp, "%s", tmp->subject); - - Found = FALSE; - while (strlen(temp) && (!Found)) { - /* - * Split the search request in - * separate words. - */ - k = strlen(temp); - for (i = 0; i < k; i++) - if (temp[i] == ' ') - break; - if (i < k) { - strncpy(kwd, temp, i); - kwd[i] = '\0'; - for (j = 0; j < (k - i -1); j++) - temp[j] = temp[j+i+1]; - temp[j] = '\0'; - } else { - sprintf(kwd, "%s", temp); - temp[0] = '\0'; - } - - /* - * Check if it's a filename search - * or a keyword search. - */ - keywrd = FALSE; - if ((kwd[0] == '/') || (kwd[0] == '\\')) { - keywrd = TRUE; - for (i = 1; i < strlen(kwd); i++) - kwd[i-1] = kwd[i]; - kwd[i-1] = '\0'; - } - tl(kwd); - - if (strlen(kwd) > 3) { - if (strstr(file.Name, kwd) != NULL) { - Found = TRUE; - Syslog('m', "Found %s in %s in filename", kwd, file.Name); - } - if (keywrd && (strstr(tl(BigDesc), kwd) != NULL)) { - Found = TRUE; - Syslog('m', "Found %s in %s in description", kwd, file.Name); - } - } - } - if (Found) { - found++; - Syslog('m', "Found %s area %d", file.Name, areanr); - fill_rflist(&rfl, file.Name, areanr); - } - strcpy(BigDesc, ""); - } - - fclose(pFile); - } else - WriteError("$Can't open %s", temp); + if (!scanmgr.NetReply) { + if (strlen(scanmgr.ReplBoard)) { + if (Rep >= MAX_FILES_OTHERBOARD) + Stop = TRUE; + } else { + if (Rep >= MAX_FILES_SAMEBOARD) + Stop = TRUE; } + } else { + if (Rep >= MAX_FILES_NETMAIL) + Stop = TRUE; + } + if (Stop) + break; } + + if (Sub) { + fseek(fi, filepos3, SEEK_SET); + MacroVars("AB", "dd", Sub, SubSize / 1024); + Msg_Macro(fi); + filepos4 = ftell(fi); + } + fclose(pAreas); - Clean(15); - } else - WriteError("$Can't open %s", temp); - - Back(12); - Clean(12); - - if (found) { - if (!do_quiet) { - colour(14, 0); - printf(" (Replying)"); - fflush(stdout); - } - - if (StartReply(tmp)) { - areanr = 0; - sprintf(temp, "%s/etc/fareas.data", getenv("MBSE_ROOT")); - if ((pAreas = fopen(temp, "r")) != NULL) { - fread(&areahdr, sizeof(areahdr), 1, pAreas); - - for (rft = rfl; rft; rft = rft->next) { - - if ((areanr != rft->area) && (Sub)) { - MsgText_Add2((char *)"------------------------------------------------------------------------"); - sprintf(temp, "Found %d file(s)", Sub); - MsgText_Add2(temp); - MsgText_Add2((char *)""); - MsgText_Add2((char *)""); - Sub = 0; - } - - if (areanr != rft->area) { - fseek(pAreas, ((rft->area - 1) * areahdr.recsize) + areahdr.hdrsize, SEEK_SET); - fread(&area, areahdr.recsize, 1, pAreas); - sprintf(temp, "Area %lu - %s", rft->area, area.Name); - MsgText_Add2(temp); - MsgText_Add2((char *)"------------------------------------------------------------------------"); - areanr = rft->area; - } - - sprintf(temp, "%s/fdb/fdb%lu.data", getenv("MBSE_ROOT"), rft->area); - if ((pFile = fopen(temp, "r")) != NULL) { - while (fread(&file, sizeof(file), 1, pFile) == 1) - if (!strcmp(rft->filename, file.Name)) - break; - fclose(pFile); - sprintf(temp, "%-12s %5lu Kb. %s", tu(file.Name), (long)(file.Size / 1024), - To_Low(file.Desc[0],scanmgr.HiAscii)); - MsgText_Add2(temp); - - /* - * We add no more then 5 description lines - * to prevent unnecesary long messages. - */ - for (i = 1; i < MAX_DESC_LINES; i++) - if (strlen(file.Desc[i])) { - sprintf(temp, " %s", To_Low(file.Desc[i],scanmgr.HiAscii)); - MsgText_Add2(temp); - } - } - Rep++; - Sub++; - - if (!scanmgr.NetReply) { - if (strlen(scanmgr.ReplBoard)) { - if (Rep >= MAX_FILES_OTHERBOARD) - Stop = TRUE; - } else { - if (Rep >= MAX_FILES_SAMEBOARD) - Stop = TRUE; - } - } else { - if (Rep >= MAX_FILES_NETMAIL) - Stop = TRUE; - } - if (Stop) - break; - } - - if (Sub) { - MsgText_Add2((char *)"------------------------------------------------------------------------"); - sprintf(temp, "Found %d file(s)", Sub); - MsgText_Add2(temp); - MsgText_Add2((char *)""); - MsgText_Add2((char *)""); - } - - fclose(pAreas); - } - FinishReply(Rep, found); - Replies++; - } - - Back(11); - Clean(11); + } + FinishReply(Rep, found, filepos4); + Replies++; } - Back(42); - Clean(42); + Back(11); + Clean(11); + } - tidy_rflist(&rfl); - free(BigDesc); - free(temp); - free(kwd); + Back(42); + Clean(42); + + tidy_rflist(&rfl); + free(BigDesc); + free(temp); + free(kwd); } int Filefind() { - char *temp; - int rc = FALSE; - FILE *fp; - ff_list *ffl = NULL, *tmp; + char *temp; + int rc = FALSE; + FILE *fp; + ff_list *ffl = NULL, *tmp; - IsDoing("FileFind"); + IsDoing("FileFind"); - if (!do_quiet) { - colour(3, 0); - printf("Processing FileFind requests\n"); - } - Syslog('+', "Processing FileFind requests"); - temp = calloc(PATH_MAX, sizeof(char)); - - sprintf(temp, "%s/etc/scanmgr.data", getenv("MBSE_ROOT")); - if ((fp = fopen(temp, "r")) == NULL) { - WriteError("$Can't open %s", temp); - free(temp); - return FALSE; - } - fread(&scanmgrhdr, sizeof(scanmgrhdr), 1, fp); - - while (fread(&scanmgr, scanmgrhdr.recsize, 1, fp) == 1) { - if (scanmgr.Active) { - ScanArea(&ffl); - - for (tmp = ffl; tmp; tmp = tmp->next) { - ScanFiles(tmp); - } - tidy_fflist(&ffl); - } - } - fclose(fp); + if (!do_quiet) { + colour(3, 0); + printf("Processing FileFind requests\n"); + } + Syslog('+', "Processing FileFind requests"); + temp = calloc(PATH_MAX, sizeof(char)); + sprintf(temp, "%s/etc/scanmgr.data", getenv("MBSE_ROOT")); + if ((fp = fopen(temp, "r")) == NULL) { + WriteError("$Can't open %s", temp); free(temp); + return FALSE; + } + fread(&scanmgrhdr, sizeof(scanmgrhdr), 1, fp); - if (Requests) { - Syslog('+', "Processed %d requests, created %d replies", Requests, Replies); - if (Replies) - rc = TRUE; - if (!do_quiet) { - colour(3, 0); - printf("Processed %d requests, created %d replies\n", Requests, Replies); - } + while (fread(&scanmgr, scanmgrhdr.recsize, 1, fp) == 1) { + if (scanmgr.Active) { + ScanArea(&ffl); + Nopper(); + for (tmp = ffl; tmp; tmp = tmp->next) { + ScanFiles(tmp); + } + tidy_fflist(&ffl); } + } + fclose(fp); + free(temp); - return rc; + if (Requests) { + Syslog('+', "Processed %d requests, created %d replies", Requests, Replies); + if (Replies) + rc = TRUE; + if (!do_quiet) { + colour(3, 0); + printf("Processed %d requests, created %d replies\n", Requests, Replies); + } + } + + return rc; } diff --git a/mbfido/msgutil.c b/mbfido/msgutil.c index bf6700d6..73415927 100644 --- a/mbfido/msgutil.c +++ b/mbfido/msgutil.c @@ -148,11 +148,13 @@ long Msg_Top(char *template, int language, fidoaddr aka) FILE *fp, *fi; long fileptr, fileptr1 = 0L; - MacroVars("YSNLTUMH", "ssssssss", aka2str(aka), CFG.sysop_name, CFG.bbs_name, CFG.location, - CFG.comment, CFG.sysop, CFG.sysdomain, CFG.www_url); temp = calloc(PATH_MAX, sizeof(char)); if ((fi = OpenMacro(template, language))) { + /* + * First override default aka with current aka, then display header. + */ + MacroVars("Y", "s", aka2str(aka)); Msg_Macro(fi); fileptr = ftell(fi); @@ -165,47 +167,17 @@ long Msg_Top(char *template, int language, fidoaddr aka) MacroVars("pqrf", "dsss", ttyinfo.type, ttyinfo.phone, ttyinfo.speed, ttyinfo.flags); fseek(fi, fileptr, SEEK_SET); Msg_Macro(fi); - fileptr1 = ftell(fi); } } fclose(fp); } + + /* + * TTY info footer + */ + Msg_Macro(fi); + fileptr1 = ftell(fi); fclose(fi); - } else { - sprintf(temp, "System name %s", CFG.bbs_name); - MsgText_Add2(temp); - sprintf(temp, "Sysop %s", CFG.sysop_name); - MsgText_Add2(temp); - sprintf(temp, "Location %s", CFG.location); - MsgText_Add2(temp); - sprintf(temp, "Remark %s", CFG.comment); - MsgText_Add2(temp); - MsgText_Add2((char *)""); - - sprintf(temp, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT")); - if ((fp = fopen(temp, "r")) != NULL) { - - MsgText_Add2((char *)"Line Phone number Maximum speed Fidonet Flags"); - MsgText_Add2((char *)"---- -------------------- -------------------- -------------------------"); - fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, fp); - - while (fread(&ttyinfo, ttyinfohdr.recsize, 1, fp) == 1) { - if (((ttyinfo.type == POTS) || (ttyinfo.type == ISDN)) && - ttyinfo.available && strlen(ttyinfo.phone)) { - switch (ttyinfo.type) { - case POTS: sprintf(temp, "POTS %-20s %-20s %s", ttyinfo.phone, ttyinfo.speed, ttyinfo.flags); - break; - case ISDN: sprintf(temp, "ISDN %-20s %-20s %s", ttyinfo.phone, ttyinfo.speed, ttyinfo.flags); - break; - } - MsgText_Add2(temp); - } - } - fclose(fp); - } - - MsgText_Add2((char *)""); - MsgText_Add2((char *)""); } free(temp); @@ -221,6 +193,9 @@ void Msg_Bot(fidoaddr UseAka, char *Org, char *template) temp = calloc(81, sizeof(char)); aka = calloc(40, sizeof(char)); + /* + * Add tearline, this is hardcoded. + */ MsgText_Add2((char *)""); MsgText_Add2(TearLine());