From bfbcefd076c4ffa706893083897e43097062701f Mon Sep 17 00:00:00 2001 From: Michael Hampton Date: Sun, 15 Dec 2002 10:53:51 +0000 Subject: [PATCH] * Final touches on the new message formatter. --- citadel/ChangeLog | 4 +++- citadel/citadel.c | 4 ++-- citadel/commands.c | 20 ++++++++++++++------ citadel/messages.c | 6 +++--- citadel/routines.c | 11 ----------- citadel/techdoc/developers.txt | 4 ++-- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 328100303..aa7c63ec4 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ + Revision 601.90 2002/12/15 10:53:51 error + * Final touches on the new message formatter. + Revision 601.89 2002/12/15 09:42:37 error * Converted more routines to new IPC code. @@ -4306,4 +4309,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citadel.c b/citadel/citadel.c index 62a79774b..be0a3740b 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -190,7 +190,7 @@ void formout(CtdlIPC *ipc, char *name) return; } if (text) { - fmout2(screenwidth, NULL, text, NULL, + fmout(screenwidth, NULL, text, NULL, ((userflags & US_PAGINATOR) ? 1 : 0), screenheight, 1, 1); free(text); @@ -1164,7 +1164,7 @@ int main(int argc, char **argv) } scr_printf("<< wrong password >>\n"); if (strlen(rc_password) > 0) - logoff(ipc, 0); + logoff(ipc, 2); goto GSTA; NEWUSR: if (strlen(rc_password) == 0) { diff --git a/citadel/commands.c b/citadel/commands.c index 5ef5445ec..25849b12b 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -314,7 +314,7 @@ void print_express(void) scr_printf(":\n"); lines_printed++; - fmout2(screenwidth, NULL, listing, NULL, 1, screenheight, -1, 0); + fmout(screenwidth, NULL, listing, NULL, 1, screenheight, -1, 0); free(listing); /* when running in curses mode, the scroll bar in most @@ -1267,6 +1267,7 @@ void display_help(CtdlIPC *ipc, char *name) } +#if 0 /* * fmout() - Citadel text formatter and paginator */ @@ -1429,12 +1430,13 @@ FMTEND: } return (sigcaught); } +#endif /* * fmout() - Citadel text formatter and paginator */ -int fmout2( +int fmout( int width, /* screen width to use */ FILE *fpin, /* file to read from, or NULL to format given text */ char *text, /* text to be formatted (when fpin is NULL */ @@ -1453,6 +1455,7 @@ int fmout2( num_urls = 0; /* Start with a clean slate of embedded URL's */ + /* Space for a single word, which can be at most screenwidth */ word = (char *)calloc(1, width); if (!word) { err_printf("Can't alloc memory to print message: %s!\n", @@ -1460,6 +1463,7 @@ int fmout2( logoff(NULL, 3); } + /* Read the entire message body into memory */ if (fpin) { size_t got = 0; @@ -1491,11 +1495,12 @@ int fmout2( if (starting_lp >= 0) lines_printed = starting_lp; + /* Run the message body */ while (*e) { /* First, are we looking at a newline? */ if (*e == '\n') { e++; - if (*e == ' ') { + if (*e == ' ') { /* Paragraph */ if (fpout) { fprintf(fpout, "\n"); } else { @@ -1504,7 +1509,7 @@ int fmout2( lines_printed = checkpagin(lines_printed, pagin, height); } column = 0; - } else if (old != ' ') { + } else if (old != ' ') {/* Don't print two spaces */ if (fpout) { fprintf(fpout, " "); } else { @@ -1512,6 +1517,7 @@ int fmout2( } column++; } + old = '\n'; continue; } /* Or are we looking at a space? */ @@ -1528,7 +1534,7 @@ int fmout2( } column = 0; } else if (!(column == 0 && old == ' ')) { - /* Eat the first space on a line */ + /* Eat only the first space on a line */ if (fpout) { fprintf(fpout, " "); } else { @@ -1589,6 +1595,7 @@ int fmout2( /* Decide where to print the word */ if (column + i >= width) { + /* Wrap to the next line */ if (fpout) { fprintf(fpout, "\n"); } else { @@ -1606,13 +1613,14 @@ int fmout2( scr_printf("%s", word); } column += i; - e += i; /* Start with the whitepsace! */ + e += i; /* Start over with the whitepsace! */ } free(word); if (fpin) /* We allocated this, remember? */ free(buffer); + /* Is this necessary? It makes the output kind of spacey. */ if (fpout) { fprintf(fpout, "\n"); } else { diff --git a/citadel/messages.c b/citadel/messages.c index ed330dc99..b733f5feb 100644 --- a/citadel/messages.c +++ b/citadel/messages.c @@ -586,7 +586,7 @@ int read_message(CtdlIPC *ipc, * Here we go */ if (format_type == 0) { - fr = fmout2(screenwidth, NULL, message->text, dest, + fr = fmout(screenwidth, NULL, message->text, dest, ((pagin == 1) ? 1 : 0), screenheight, (-1), 1); } else { /* FIXME: renderer for text/plain */ @@ -766,7 +766,7 @@ int client_make_message(CtdlIPC *ipc, if (mode == 0) { fp = fopen(filename, "r"); if (fp != NULL) { - fmout2(screenwidth, fp, NULL, NULL, 0, screenheight, 0, 0); + fmout(screenwidth, fp, NULL, NULL, 0, screenheight, 0, 0); beg = ftell(fp); fclose(fp); } else { @@ -876,7 +876,7 @@ MECR: if (mode == 2) { } fp = fopen(filename, "r"); if (fp != NULL) { - fmout2(screenwidth, fp, NULL, NULL, + fmout(screenwidth, fp, NULL, NULL, ((userflags & US_PAGINATOR) ? 1 : 0), screenheight, 0, 0); beg = ftell(fp); diff --git a/citadel/routines.c b/citadel/routines.c index 1c6e07e6a..d0538c240 100644 --- a/citadel/routines.c +++ b/citadel/routines.c @@ -331,17 +331,6 @@ int pattern(char *search, char *patn) { } -/* display internal error as defined in errmsgs */ -/* -void interr(int errnum) { - scr_printf("*** INTERNAL ERROR %d\n" - "(Press any key to continue)\n", errnum); - inkey(); - logoff(errnum); -} -*/ - - void strproc(char *string) { int a; diff --git a/citadel/techdoc/developers.txt b/citadel/techdoc/developers.txt index 3c5d681ac..a2ae30e7e 100644 --- a/citadel/techdoc/developers.txt +++ b/citadel/techdoc/developers.txt @@ -40,10 +40,10 @@ Developer codes (and where known, client codes) 7 Walden Leverich - 8 Michael Hampton + 8 Michael Hampton Client Name Status Description - 0 (unnamed) in design Client-side API library + 0 libcitadel in development Client-side API library 1 D.O.C. in development Dave's Own Citadel look-alike 69 Anticlimactic Teleservices -- 2.39.2