Annotation of 43BSDTahoe/new/nntp/server/nextlast.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char    *sccsid = "@(#)nextlast.c       1.3     (Berkeley) 6/26/87";
                      3: #endif
                      4: 
                      5: #include "common.h"
                      6: 
                      7: /*
                      8:  * NEXT
                      9:  * LAST
                     10:  *
                     11:  * Retrieve the message-id of the next or last article in the
                     12:  * newsgroup.  Position the current article pointer to this
                     13:  * article.
                     14:  */
                     15: 
                     16: nextlast(argc, argv)
                     17:        int     argc;
                     18:        char    *argv[];
                     19: {
                     20:        char    artbuf[MAX_STRLEN], art_id[MAX_STRLEN];
                     21:        int     oldptr;
                     22:        int     next;
                     23: 
                     24:        if (!canread) {
                     25:                printf("%d You only have permission to transfer, sorry.\r\n",
                     26:                        ERR_ACCESS);
                     27:                (void) fflush(stdout);
                     28:                return;
                     29:        }
                     30: 
                     31:        if (!ingroup) {
                     32:                printf("%d You are not currently in a newsgroup.\r\n",
                     33:                        ERR_NCING);
                     34:                (void) fflush(stdout);
                     35:                return;
                     36:        }
                     37: 
                     38:        if (argc != 1) {
                     39:                printf("%d NEXT/LAST need no arguments.\r\n", ERR_CMDSYN);
                     40:                (void) fflush(stdout);
                     41:                return;
                     42:        }
                     43: 
                     44:        next = (argv[0][0] == 'n' || argv[0][0] == 'N');
                     45: 
                     46:        if (art_ptr < 0 || art_ptr >= num_arts) {
                     47:                printf("%d No current article selected.\r\n",
                     48:                        ERR_NOCRNT);
                     49:                (void) fflush(stdout);
                     50:                return;
                     51:        }
                     52: 
                     53:        if (next ? (art_ptr + 1 >= num_arts) : (art_ptr - 1 < 0)) {
                     54:                printf("%d No %s article to retrieve.\r\n",
                     55:                        ERR_NONEXT,  next ? "next" : "previous");
                     56:                (void) fflush(stdout);
                     57:                return;
                     58:        }
                     59: 
                     60:        oldptr = art_ptr;
                     61:        (void) sprintf(artbuf, "%d", art_array[next ? ++art_ptr : --art_ptr]);
                     62: 
                     63:        if (!valid_art(artbuf)) {
                     64:                printf("%d Invalid article number: %s.\r\n", ERR_NOARTIG,
                     65:                        artbuf);
                     66:                (void) fflush(stdout);
                     67:                return;
                     68:        }
                     69: 
                     70:        while (open_valid_art(artbuf, art_id) == NULL) {
                     71:                if (((next) ? (++art_ptr >= num_arts) : (--art_ptr < 0))) {
                     72:                        printf("%d No %s article to retrieve.\r\n",
                     73:                                ERR_NONEXT, next ? "next" : "previous");
                     74:                        art_ptr = oldptr;
                     75:                        (void) fflush(stdout);
                     76:                        return;
                     77:                }
                     78:                (void) sprintf(artbuf, "%d", art_array[art_ptr]);
                     79:        }
                     80: 
                     81:        printf("%d %s %s Article retrieved; request text separately.\r\n",
                     82:                OK_NOTEXT, artbuf, art_id);
                     83: 
                     84:        if (argc > 1)
                     85:                art_ptr = findart(artbuf);
                     86:        (void) fflush(stdout);
                     87: }

unix.superglobalmegacorp.com

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