Annotation of 43BSD/contrib/notes/src/limindx.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: limindx.c,v 1.7.0.2 85/09/09 18:32:46 notes Rel $";
                      6: #endif RCSIDENT
                      7: 
                      8: /*
                      9:  *     limindx(io) struct io_f *io;
                     10:  *     runs a limited form of the index and prntind functions.
                     11:  *     its purpose is to come up with a note number for forwarding
                     12:  *     notes as responses.
                     13:  *
                     14:  *     Returns the note number picked. 
                     15:  *             0 means no note.
                     16:  *
                     17:  *     Original coding:        Ray Essick      January 1982
                     18:  *
                     19:  */
                     20: 
                     21: limindx (io)
                     22: struct io_f *io;
                     23: {
                     24:     int     firstdis,
                     25:             lastdis;
                     26:     char    c;
                     27:     int     i,
                     28:             znote,
                     29:             zresp;
                     30:     struct note_f   note;
                     31:     char    buf[NAMESZ + SYSSZ + 2];                   /* for display */
                     32: 
                     33:     firstdis = io -> descr.d_nnote - Nindex + 1;       /* start at the end of the file */
                     34:     while (1)
                     35:     {
                     36:        prntind (io, &firstdis, &lastdis);              /* show the page */
                     37:        at (2, 28);
                     38:        printf ("---- Limited Index ----");
                     39:        at (0, 1);
                     40:        c = gchar ();
                     41:        printf ("\b \b");
                     42:        switch (c)
                     43:        {
                     44:            case '?': 
                     45:            case 'h': 
                     46:                help (LIMHLP);
                     47:                break;
                     48: 
                     49:            case '\r': 
                     50:            case '\n': 
                     51:            case ' ': 
                     52:            case '+':                                   /* advance 1 page */
                     53:                firstdis = lastdis;
                     54:                break;
                     55: 
                     56:            case '-':                                   /* backwards 1 page */
                     57:            case '\b': 
                     58:                firstdis -= Nindex;
                     59:                break;
                     60: 
                     61:            case '=':                                   /* back to the start */
                     62:                firstdis = 1;
                     63:                break;
                     64: 
                     65:            case '*':                                   /* last page of index */
                     66:                firstdis = io -> descr.d_nnote - Nindex + 1;
                     67:                break;
                     68: 
                     69:            case '!':                                   /* give him a shell */
                     70:                gshell ();
                     71:                break;
                     72: 
                     73:            case 'q':                                   /* leave, giving up */
                     74:            case 'Q':                                   /* and others .. */
                     75: #ifdef K_KEY
                     76:            case 'k': 
                     77:            case 'K': 
                     78: #endif K_KEY
                     79:                return 0;
                     80: 
                     81:            case 'x':                                   /* search for title */
                     82:            case 'X': 
                     83:                i = tsearch (io, lastdis, c == 'x');    /* assume lies before here */
                     84:                if (i > 0)
                     85:                    firstdis = i;                       /* set him on that page */
                     86:                continue;                               /* otherwise get another key */
                     87: 
                     88:            case 'a': 
                     89:            case 'A':                                   /* author search from current spot */
                     90:                znote = lastdis;
                     91:                zresp = 0;                              /* start at the correct place */
                     92:                do
                     93:                {
                     94:                    i = asearch (io, &znote, &zresp, (c == 'a'));
                     95:                                                        /* look */
                     96:                    if (i > 0)
                     97:                    {
                     98:                        if (zresp != 0)
                     99:                            continue;                   /* not a 'note' */
                    100:                        firstdis = znote;               /* go there */
                    101:                        break;                          /* out of this loop */
                    102:                    }
                    103:                }
                    104:                while (i > 0);                          /* until not found */
                    105:                continue;                               /* get another command */
                    106: 
                    107:            case '0':                                   /* pick a note */
                    108:            case '1': 
                    109:            case '2': 
                    110:            case '3': 
                    111:            case '4': 
                    112:            case '5': 
                    113:            case '6': 
                    114:            case '7': 
                    115:            case '8': 
                    116:            case '9': 
                    117:                printf ("  Note number > ");
                    118:                znote = getnum (c);
                    119:                if (znote <= io -> descr.d_nnote)       /* if range ok */
                    120:                {
                    121:                    /* 
                    122:                     * print the index line for this note...
                    123:                     */
                    124:                    getnrec (io, znote, &note);         /* get descriptor */
                    125: #define        INDEXROW        -2
                    126:                    at (INDEXROW, 1);
                    127:                    printf ("%d/%d/%02d", note.n_rcvd.w_month,
                    128:                            note.n_rcvd.w_day, note.n_rcvd.w_year % 100);
                    129:                    at (INDEXROW, 10);
                    130:                    printf ("%3d", znote);
                    131:                    if (note.n_stat & DIRMES)
                    132:                        printf ("*");
                    133:                    else
                    134:                        printf (" ");
                    135:                    clearerr (stdout);
                    136:                    fwrite (note.ntitle, 1, strlen (note.ntitle), stdout);
                    137:                    if (note.n_nresp != 0)
                    138:                    {
                    139:                        at (INDEXROW, 10 + 4 + TITLEN + 1);
                    140:                        printf ("%3d", note.n_nresp);
                    141:                    }
                    142:                    at (INDEXROW, 10 + 4 + TITLEN + 1 + 3 + 1);
                    143:                    if (strcmp (Authsystem, note.n_auth.asystem) != 0 &&
                    144:                            strcmp ("Anonymous", note.n_auth.aname) != 0)
                    145:                    {
                    146: #ifdef USERHOST
                    147:                        sprintf (buf, "%s@%s", note.n_auth.aname, note.n_auth.asystem);
                    148: #else
                    149:                        sprintf (buf, "%s!%s", note.n_auth.asystem, note.n_auth.aname);
                    150: #endif USERHOST
                    151:                    }
                    152:                    else
                    153:                        sprintf (buf, "%s", note.n_auth.aname);
                    154: 
                    155:                    buf[26] = '\0';                     /* don't overflow line */
                    156:                    printf ("%s", buf);
                    157:                    at (-1, 1);                         /* now ask him */
                    158:                    printf ("Do you really want note %d? ", znote);
                    159:                    if (askyn (" (y/n) ") == 'y')       /* he wants it */
                    160:                        return znote;
                    161:                }
                    162:                else
                    163:                {
                    164:                    at (0, PROMPTMSGX);
                    165:                    printf ("Note %d doesn't exist");
                    166:                    continue;
                    167:                }
                    168:        }
                    169:     }
                    170: }

unix.superglobalmegacorp.com

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