Allfiles and newfiles list extended with UTF-8 encoded files

This commit is contained in:
Michiel Broek 2007-03-02 21:28:28 +00:00
parent b5dc098caf
commit 32d1ab2ba4
3 changed files with 107 additions and 59 deletions

View File

@ -50,6 +50,11 @@ v0.91.5 18-Feb-2007
Reports will be converted to the selected charset. Origin Reports will be converted to the selected charset. Origin
characterset is CP437 for now. characterset is CP437 for now.
mball:
Now also creates allfiles.utf and newfiles.utf with UTF-8
encoded text. Noth new files will also be added to the zip
archives.
mbnntp: mbnntp:
Reading news outputs UTF-8 coded articles. Reading news outputs UTF-8 coded articles.
TODO: test posting and fix if needed. TODO: test posting and fix if needed.

View File

@ -4,7 +4,7 @@
* Purpose ...............: Creates allfiles listings * Purpose ...............: Creates allfiles listings
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2005 * Copyright (C) 1997-2007
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -208,9 +208,9 @@ int main(int argc, char **argv)
void MidLine(char *txt, FILE *fp, int doit) void MidLine(char *txt, FILE *fp, FILE *up, int doit)
{ {
char temp[81]; char temp[256];
int x, y, z; int x, y, z;
if (!doit) if (!doit)
@ -219,58 +219,62 @@ void MidLine(char *txt, FILE *fp, int doit)
z = strlen(txt); z = strlen(txt);
x = 77 - z; x = 77 - z;
x /= 2; x /= 2;
strcpy(temp, ""); strcpy(temp, "\xB3");
for (y = 0; y < x; y++) for (y = 0; y < x; y++)
strcat(temp, " "); strcat(temp, " ");
strcat(temp, txt); strncat(temp, txt, 255);
z = strlen(temp);
x = 77 - z;
for (y = 0; y < x; y++) for (y = strlen(temp); y < 78; y++)
strcat(temp, " "); strncat(temp, " ", 255);
fprintf(fp, "%c", 179); strncat(temp, "\xB3\r\n", 255);
fprintf(fp, "%s", temp); fprintf(fp, temp);
fprintf(fp, "%c\r\n", 179); fprintf(up, chartran(temp));
} }
void TopBox(FILE *fp, int doit) void TopBox(FILE *fp, FILE *up, int doit)
{ {
int y; int y;
char temp[256];
if (!doit) if (!doit)
return; return;
fprintf(fp, "\r\n%c", 213); strcpy(temp, "\r\n\xDA");
for(y = 0; y < 77; y++) for(y = 0; y < 77; y++)
fprintf(fp, "%c", 205); strncat(temp, "\xC4", 255);
fprintf(fp, "%c\r\n", 184); strncat(temp, "\xBF\r\n", 255);
fprintf(fp, temp);
fprintf(up, chartran(temp));
} }
void BotBox(FILE *fp, int doit) void BotBox(FILE *fp, FILE *up, int doit)
{ {
int y; int y;
char temp[256];
if (!doit) if (!doit)
return; return;
fprintf(fp, "%c", 212); strcpy(temp, "\xC0");
for (y = 0; y < 77; y++) for (y = 0; y < 77; y++)
fprintf(fp, "%c", 205); strncat(temp, "\xC4", 255);
fprintf(fp, "%c\r\n\r\n", 190); strncat(temp, "\xD9\r\n\r\n", 255);
fprintf(fp, temp);
fprintf(up, chartran(temp));
} }
void Masterlist() void Masterlist()
{ {
FILE *fp, *np, *pAreas, *pHeader; FILE *fp, *np, *fu, *nu, *pAreas, *pHeader;
int AreaNr = 0, z, x = 0, New; int AreaNr = 0, z, x = 0, New;
unsigned int AllFiles = 0, AllKBytes = 0, NewFiles = 0, NewKBytes = 0; unsigned int AllFiles = 0, AllKBytes = 0, NewFiles = 0, NewKBytes = 0;
unsigned int AllAreaFiles, AllAreaBytes, popdown, down, NewAreaFiles, NewAreaBytes; unsigned int AllAreaFiles, AllAreaBytes, popdown, down, NewAreaFiles, NewAreaBytes;
@ -302,15 +306,30 @@ void Masterlist()
fclose(fp); fclose(fp);
die(MBERR_GENERAL); die(MBERR_GENERAL);
} }
if ((fu = fopen("allfiles.ump", "a+")) == NULL) {
WriteError("$Can't open allfiles.ump");
fclose(fp);
fclose(np);
die(MBERR_GENERAL);
}
if ((nu = fopen("newfiles.ump", "a+")) == NULL) {
WriteError("$Can't open newfiles.ump");
fclose(fp);
fclose(np);
fclose(fu);
die(MBERR_GENERAL);
}
TopBox(fp, TRUE); chartran_init((char *)"CP437", (char *)"UTF-8", 'B');
TopBox(np, TRUE);
TopBox(fp, fu, TRUE);
TopBox(np, nu, TRUE);
snprintf(temp, 81, "All available files at %s", CFG.bbs_name); snprintf(temp, 81, "All available files at %s", CFG.bbs_name);
MidLine(temp, fp, TRUE); MidLine(temp, fp, fu, TRUE);
snprintf(temp, 81, "New available files since %d days at %s", CFG.newdays, CFG.bbs_name); snprintf(temp, 81, "New available files since %d days at %s", CFG.newdays, CFG.bbs_name);
MidLine(temp, np, TRUE); MidLine(temp, np, nu, TRUE);
BotBox(fp, TRUE); BotBox(fp, fu, TRUE);
BotBox(np, TRUE); BotBox(np, nu, TRUE);
snprintf(temp, PATH_MAX, "%s/etc/header.txt", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/etc/header.txt", getenv("MBSE_ROOT"));
if (( pHeader = fopen(temp, "r")) != NULL) { if (( pHeader = fopen(temp, "r")) != NULL) {
@ -320,6 +339,8 @@ void Masterlist()
Striplf(temp); Striplf(temp);
fprintf(fp, "%s\r\n", temp); fprintf(fp, "%s\r\n", temp);
fprintf(np, "%s\r\n", temp); fprintf(np, "%s\r\n", temp);
fprintf(fu, "%s\r\n", chartran(temp));
fprintf(nu, "%s\r\n", chartran(temp));
} }
fclose(pHeader); fclose(pHeader);
} }
@ -370,28 +391,28 @@ void Masterlist()
* If there are files to report do it. * If there are files to report do it.
*/ */
if (AllAreaFiles) { if (AllAreaFiles) {
TopBox(fp, TRUE); TopBox(fp, fu, TRUE);
TopBox(np, NewAreaFiles); TopBox(np, nu, NewAreaFiles);
snprintf(temp, 81, "Area %d - %s", AreaNr, area.Name); snprintf(temp, 81, "Area %d - %s", AreaNr, area.Name);
MidLine(temp, fp, TRUE); MidLine(temp, fp, fu, TRUE);
MidLine(temp, np, NewAreaFiles); MidLine(temp, np, nu, NewAreaFiles);
snprintf(temp, 81, "File Requests allowed"); snprintf(temp, 81, "File Requests allowed");
MidLine(temp, fp, area.FileReq); MidLine(temp, fp, fu, area.FileReq);
MidLine(temp, np, area.FileReq && NewAreaFiles); MidLine(temp, np, nu, area.FileReq && NewAreaFiles);
snprintf(temp, 81, "%d KBytes in %d files", AllAreaBytes / 1024, AllAreaFiles); snprintf(temp, 81, "%d KBytes in %d files", AllAreaBytes / 1024, AllAreaFiles);
MidLine(temp, fp, TRUE); MidLine(temp, fp, fu, TRUE);
snprintf(temp, 81, "%d KBytes in %d files", NewAreaBytes / 1024, NewAreaFiles); snprintf(temp, 81, "%d KBytes in %d files", NewAreaBytes / 1024, NewAreaFiles);
MidLine(temp, np, NewAreaFiles); MidLine(temp, np, nu, NewAreaFiles);
if (popdown) { if (popdown) {
snprintf(temp, 81, "Most popular file is %s", pop); snprintf(temp, 81, "Most popular file is %s", pop);
MidLine(temp, fp, TRUE); MidLine(temp, fp, fu, TRUE);
} }
BotBox(fp, TRUE); BotBox(fp, fu, TRUE);
BotBox(np, NewAreaFiles); BotBox(np, nu, NewAreaFiles);
fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET); fseek(fdb_area->fp, fdbhdr.hdrsize, SEEK_SET);
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
@ -401,26 +422,39 @@ void Masterlist()
fdb.Name, (int)(fdb.Size / 1024), StrDateDMY(fdb.UploadDate), fdb.TimesDL, fdb.Name, (int)(fdb.Size / 1024), StrDateDMY(fdb.UploadDate), fdb.TimesDL,
strlen(fdb.Uploader)?fdb.Uploader:""); strlen(fdb.Uploader)?fdb.Uploader:"");
fprintf(fp, "%s\r\n", temp); fprintf(fp, "%s\r\n", temp);
if (New) fprintf(fu, "%s\r\n", chartran(temp));
if (New) {
fprintf(np, "%s\r\n", temp); fprintf(np, "%s\r\n", temp);
fprintf(nu, "%s\r\n", chartran(temp));
}
for (z = 0; z < 25; z++) { for (z = 0; z < 25; z++) {
if (strlen(fdb.Desc[z])) { if (strlen(fdb.Desc[z])) {
if ((fdb.Desc[z][0] == '@') && (fdb.Desc[z][1] == 'X')) { if ((fdb.Desc[z][0] == '@') && (fdb.Desc[z][1] == 'X')) {
fprintf(fp, " %s\r\n",fdb.Desc[z]+4); fprintf(fp, " %s\r\n",fdb.Desc[z]+4);
if (New) fprintf(fu, " %s\r\n",chartran(fdb.Desc[z]+4));
if (New) {
fprintf(np, " %s\r\n",fdb.Desc[z]+4); fprintf(np, " %s\r\n",fdb.Desc[z]+4);
fprintf(nu, " %s\r\n",chartran(fdb.Desc[z]+4));
}
} else { } else {
fprintf(fp, " %s\r\n",fdb.Desc[z]); fprintf(fp, " %s\r\n",fdb.Desc[z]);
if (New) fprintf(fu, " %s\r\n",chartran(fdb.Desc[z]));
if (New) {
fprintf(np, " %s\r\n",fdb.Desc[z]); fprintf(np, " %s\r\n",fdb.Desc[z]);
fprintf(nu, " %s\r\n",chartran(fdb.Desc[z]));
}
} }
} }
} }
if (strlen(fdb.Magic)) { if (strlen(fdb.Magic)) {
fprintf(fp, " Magic filerequest: %s\r\n", fdb.Magic); fprintf(fp, " Magic filerequest: %s\r\n", fdb.Magic);
if (New) fprintf(fu, " Magic filerequest: %s\r\n", fdb.Magic);
if (New) {
fprintf(np, " Magic filerequest: %s\r\n", fdb.Magic); fprintf(np, " Magic filerequest: %s\r\n", fdb.Magic);
fprintf(nu, " Magic filerequest: %s\r\n", fdb.Magic);
}
} }
} }
} }
@ -432,22 +466,22 @@ void Masterlist()
fclose(pAreas); fclose(pAreas);
TopBox(fp, TRUE); TopBox(fp, fu, TRUE);
TopBox(np, TRUE); TopBox(np, nu, TRUE);
snprintf(temp, 81, "Total %d files, %d KBytes", AllFiles, AllKBytes); snprintf(temp, 81, "Total %d files, %d KBytes", AllFiles, AllKBytes);
MidLine(temp, fp, TRUE); MidLine(temp, fp, fu, TRUE);
snprintf(temp, 81, "Total %d files, %d KBytes", NewFiles, NewKBytes); snprintf(temp, 81, "Total %d files, %d KBytes", NewFiles, NewKBytes);
MidLine(temp, np, TRUE); MidLine(temp, np, nu, TRUE);
MidLine((char *)"", fp, TRUE); MidLine((char *)"", fp, fu, TRUE);
MidLine((char *)"", np, TRUE); MidLine((char *)"", np, nu, TRUE);
snprintf(temp, 81, "Created by MBSE BBS v%s (%s-%s) at %s", VERSION, OsName(), OsCPU(), StrDateDMY(t_start)); snprintf(temp, 81, "Created by MBSE BBS v%s (%s-%s) at %s", VERSION, OsName(), OsCPU(), StrDateDMY(t_start));
MidLine(temp, fp, TRUE); MidLine(temp, fp, fu, TRUE);
MidLine(temp, np, TRUE); MidLine(temp, np, nu, TRUE);
BotBox(fp, TRUE); BotBox(fp, fu, TRUE);
BotBox(np, TRUE); BotBox(np, nu, TRUE);
snprintf(temp, PATH_MAX, "%s/etc/footer.txt", getenv("MBSE_ROOT")); snprintf(temp, PATH_MAX, "%s/etc/footer.txt", getenv("MBSE_ROOT"));
if(( pHeader = fopen(temp, "r")) != NULL) { if(( pHeader = fopen(temp, "r")) != NULL) {
@ -457,17 +491,26 @@ void Masterlist()
Striplf(temp); Striplf(temp);
fprintf(fp, "%s\r\n", temp); fprintf(fp, "%s\r\n", temp);
fprintf(np, "%s\r\n", temp); fprintf(np, "%s\r\n", temp);
fprintf(fu, "%s\r\n", chartran(temp));
fprintf(nu, "%s\r\n", chartran(temp));
} }
fclose(pHeader); fclose(pHeader);
} }
fclose(fp); fclose(fp);
fclose(np); fclose(np);
fclose(fu);
fclose(nu);
chartran_close();
if ((rename("allfiles.tmp", "allfiles.txt")) == 0) if ((rename("allfiles.tmp", "allfiles.txt")) == 0)
unlink("allfiles.tmp"); unlink("allfiles.tmp");
if ((rename("newfiles.tmp", "newfiles.txt")) == 0) if ((rename("newfiles.tmp", "newfiles.txt")) == 0)
unlink("newfiles.tmp"); unlink("newfiles.tmp");
if ((rename("allfiles.ump", "allfiles.utf")) == 0)
unlink("allfiles.ump");
if ((rename("newfiles.ump", "newfiles.utf")) == 0)
unlink("newfiles.ump");
Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024); Syslog('+', "Allfiles: %ld, %ld MBytes", AllFiles, AllKBytes / 1024);
Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024); Syslog('+', "Newfiles: %ld, %ld MBytes", NewFiles, NewKBytes / 1024);
@ -495,14 +538,14 @@ void MakeArc()
Nopper(); Nopper();
if (!do_quiet) if (!do_quiet)
printf("Creating allfiles.zip\n"); printf("Creating allfiles.zip\n");
if (!execute_str(cmd, (char *)"allfiles.zip allfiles.txt", (char *)NULL, (char *)"/dev/null", if (!execute_str(cmd, (char *)"allfiles.zip allfiles.txt allfiles.utf", (char *)NULL, (char *)"/dev/null",
(char *)"/dev/null", (char *)"/dev/null") == 0) (char *)"/dev/null", (char *)"/dev/null") == 0)
WriteError("Create allfiles.zip failed"); WriteError("Create allfiles.zip failed");
Nopper(); Nopper();
if (!do_quiet) if (!do_quiet)
printf("Creating newfiles.zip\n"); printf("Creating newfiles.zip\n");
if (!execute_str(cmd, (char *)"newfiles.zip newfiles.txt", (char *)NULL, (char *)"/dev/null", if (!execute_str(cmd, (char *)"newfiles.zip newfiles.txt newfiles.utf", (char *)NULL, (char *)"/dev/null",
(char *)"/dev/null", (char *)"/dev/null") == 0) (char *)"/dev/null", (char *)"/dev/null") == 0)
WriteError("Create newfiles.zip failed"); WriteError("Create newfiles.zip failed");

View File

@ -6,9 +6,9 @@ void ProgName(void);
void die(int); void die(int);
void Help(void); void Help(void);
void MakeIndex(void); void MakeIndex(void);
void MidLine(char *, FILE *, int); void MidLine(char *, FILE *, FILE *, int);
void TopBox(FILE *, int); void TopBox(FILE *, FILE *, int);
void BotBox(FILE *, int); void BotBox(FILE *, FILE *, int);
void Masterlist(void); void Masterlist(void);
void MakeArc(void); void MakeArc(void);