Annotation of 43BSD/contrib/notes/src/lprnote.c, revision 1.1.1.1

1.1       root        1: #include "parms.h"
                      2: #include "structs.h"
                      3: 
                      4: #ifdef RCSIDENT
                      5: static char rcsid[] = "$Header: lprnote.c,v 1.7.0.3 85/03/19 19:39:05 notes Rel $";
                      6: #endif RCSIDENT
                      7: 
                      8: /*
                      9:  *     lprnote(io, lprfile, toc, notenum, note, justtitle)
                     10:  *
                     11:  *     prints the specified note to lprfile, and makes an entry in
                     12:  *     toc file. Paging is taken care of and the page/line stuff is
                     13:  *     correctly set at the conclusion.
                     14:  *
                     15:  *     lprresp(io, lprfile, toc, respnum, rsprec, roffset)
                     16:  *
                     17:  *     Same as the lprnote routine. Works for responses though.
                     18:  *
                     19:  *     pagebreak(lprfile)
                     20:  *
                     21:  *     forces a page break.
                     22:  *
                     23:  *     Ray Essick      May 13, 1982
                     24:  */
                     25: 
                     26: #define        NOTENEED        7
                     27: #define        RESPNEED        7
                     28: 
                     29: extern int  length,                                    /* length of page */
                     30:             left,                                      /* left on the page */
                     31:             page;                                      /* the pae we are on */
                     32: 
                     33: lprnote (io, lprfile, toc, notenum, note, justtitle)
                     34: struct io_f *io;
                     35: FILE * lprfile, *toc;
                     36: struct note_f  *note;
                     37: {
                     38:     struct resp_f   rsprec;
                     39:     int     roffset,
                     40:             rblock;
                     41:     char    line[CMDLEN];
                     42:     int     i;
                     43:     char    ztime[DATELEN];
                     44: 
                     45:     if (left < NOTENEED)                               /* room for header and some text? */
                     46:        pagebreak (lprfile);                            /* make it that way */
                     47: 
                     48:     if (strcmp (note -> n_auth.asystem, Authsystem) &&
                     49:            strcmp ("Anonymous", note -> n_auth.aname))
                     50:     {
                     51: #ifdef USERHOST
                     52:        sprintf (line, "%s@%s", note -> n_auth.aname, note -> n_auth.asystem);
                     53: #else
                     54:        sprintf (line, "%s!%s", note -> n_auth.asystem, note -> n_auth.aname);
                     55: #endif USERHOST
                     56:     }
                     57:     else
                     58:        sprintf (line, "%s", note -> n_auth.aname);
                     59:     sprdate (&note -> n_date, ztime);                  /* format date */
                     60: 
                     61:     fprintf (toc, "%3d%s ", notenum, note -> n_stat & DIRMES ? "(*)" : "   ");
                     62:     fprintf (toc, "%-*s", TITLEN, note -> ntitle);
                     63:     fprintf (toc, "%-*s  %-*s", SYSSZ + NAMESZ + 2, line, DATELEN, ztime);
                     64:     if (!justtitle)                                    /* no page for titles only */
                     65:        fprintf (toc, "    %d", page);
                     66:     putc ('\n', toc);                                  /* end the line */
                     67: 
                     68: /*
                     69:  *     only proceed if we are dumping text. Otherwise we stop with
                     70:  *     just the table of contents entry
                     71:  */
                     72: 
                     73:     if (justtitle)                                     /* no text output */
                     74:        return;
                     75: 
                     76:     fprintf (lprfile, "\n====    ====    ====    ====    ====    ====    ====\n");
                     77:     fprintf (lprfile, "Note %-3d %s  ", notenum,
                     78:            note -> n_stat & DIRMES ? "(*)" : "   ");
                     79:     fprintf (lprfile, "%-*s", TITLEN, note -> ntitle); /* title */
                     80: 
                     81:     if (note -> n_nresp)
                     82:        fprintf (lprfile, "   %d response%c", note -> n_nresp,
                     83:                note -> n_nresp > 1 ? 's' : ' ');
                     84:     putc ('\n', lprfile);
                     85: 
                     86:     fprintf (lprfile, "%-*s", SYSSZ + NAMESZ + 1, line);
                     87: 
                     88:     fprintf (lprfile, "        %s\n\n", ztime);
                     89: 
                     90:     left -= 5;                                         /* count off the header lines */
                     91: 
                     92:     left -= pageout (io, &note -> n_addr, lprfile);    /* dump text */
                     93: 
                     94:     while (left < 0)
                     95:     {
                     96:        page++;
                     97:        left += length;
                     98:     }
                     99: 
                    100: 
                    101:     for (i = 1; i <= note -> n_nresp; i++)             /* dump responses */
                    102:     {
                    103:        if (lrsp (io, notenum, i, &rsprec, &roffset, &rblock) == -1)
                    104:            break;                                      /* bad chain */
                    105:        lprresp (io, lprfile, toc, notenum, i, &rsprec, roffset);
                    106:     }
                    107: }
                    108: 
                    109: /*
                    110:  *
                    111:  *     dump a response to a "pr" stream.
                    112:  */
                    113: 
                    114: lprresp (io, lprfile, toc, notenum, respnum, rsprec, phys)
                    115: struct io_f *io;
                    116: FILE * lprfile,
                    117: *toc;
                    118: struct resp_f  *rsprec;
                    119: {
                    120:     char    ztime[DATELEN];
                    121:     char    line[CMDLEN];
                    122: 
                    123:     if (left < RESPNEED)                               /* room on page? */
                    124:        pagebreak (lprfile);
                    125: 
                    126:     if (strcmp (rsprec -> r_auth[phys].asystem, Authsystem) &&
                    127:            strcmp ("Anonymous", rsprec -> r_auth[phys].aname))
                    128:     {
                    129: #ifdef USERHOST
                    130:        sprintf (line, "%s@%s", rsprec -> r_auth[phys].aname,
                    131:                rsprec -> r_auth[phys].asystem);
                    132: #else
                    133:        sprintf (line, "%s!%s", rsprec -> r_auth[phys].asystem,
                    134:                rsprec -> r_auth[phys].aname);
                    135: #endif USERHOST
                    136:     }
                    137:     else
                    138:        sprintf (line, "%s", rsprec -> r_auth[phys].aname);
                    139:     sprdate (&rsprec -> r_when[phys], ztime);
                    140:     fprintf (lprfile, "\n==== ==== ====\n");
                    141:     fprintf (lprfile, "Response %-4d to Note %-4d\n\t%-*s  %-*s\n\n",
                    142:            respnum, notenum, SYSSZ + NAMESZ + 2, line, DATELEN, ztime);
                    143: 
                    144:     left -= 5;                                         /* count the header */
                    145: 
                    146:     left -= pageout (io, &rsprec -> r_addr[phys], lprfile);
                    147: 
                    148:     while (left < 0)
                    149:     {
                    150:        page++;
                    151:        left += length;
                    152:     }
                    153: }
                    154: 
                    155: /*
                    156:  *     force a page break
                    157:  */
                    158: 
                    159: pagebreak (zfile)
                    160: FILE * zfile;
                    161: {
                    162:     putc ('\f', zfile);                                        /* form feed */
                    163:     page++;
                    164:     left = length;
                    165: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.