home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / gnus-xover-1.2 / nntpd-patch < prev    next >
Encoding:
Text File  |  1993-04-16  |  7.1 KB  |  267 lines

  1. Xref: psuvax1 news.software.nntp:3239
  2. Path: psuvax1!uwm.edu!spool.mu.edu!olivea!decwrl!borland.com!davison
  3. From: davison@borland.com (Wayne Davison)
  4. Newsgroups: news.software.nntp
  5. Subject: Re: XOVER support in nntp...
  6. Message-ID: <C1v3y3.6E8@borland.com>
  7. Date: 3 Feb 93 07:39:39 GMT
  8. References: <MIKE.93Feb2215943@apex.yorku.ca>
  9. Organization: Borland International
  10. Lines: 255
  11.  
  12. Mike Marques (mike@ccs.yorku.ca) wrote:
  13. > Are there patches to add the XOVER command to the latest version of
  14. > nntp or is it only available under the nnrp daemon from INN?
  15.  
  16. Yes, there is such a patch for the reference NNTP implementation.  Iain
  17. Lea (tin) and I (trn) are planning to release a single enhanced version
  18. of NNTP that will have all the latest extensions needed for making a
  19. modern newsreader's life easier.  In the meantime, here's my version of
  20. XOVER support, which is a slightly optimized and bug-fixed version of the
  21. patch Rich Salz posted in late December.  Trn 3.0 (in testing) has been
  22. using this code for a few weeks now, so it appears to be in good shape.
  23. -- 
  24. Wayne Davison
  25. davison@borland.com
  26. ---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
  27. Index:common/version.c
  28. @@ -2,4 +2,4 @@
  29.   * Provide the version number of this release.
  30.   */
  31.  
  32. -char    nntp_version[] = "1.5.11 (10 February 1991)";
  33. +char    nntp_version[] = "1.5.11ov (18 January 1993)";
  34. Index:CHANGES
  35. @@ -2,6 +2,21 @@
  36.  since the initial release.  Individuals who either reported the bug or
  37.  inspired the bug fix are in square brackets.
  38.  
  39. +1.5.11+XOVER1   (Wayne Davison <davison@borland.com> 18 Jan 93)
  40. +    Fixes and minor optimizations for the XOVER command.
  41. +
  42. +1.5.11+XOVER0    (Rich $alz <rsalz@uunet.uu.net> 23 dec 92)
  43. +    This adds the XOVER command to the server.  The XOVER command
  44. +    is used to retrieve data from the .overview file that is part
  45. +    of Geoff Collyer's "nov" package (that package is not provided
  46. +    here; the official archive for it is
  47. +    world.std.com:pub/src/news/nov.dist.tar.Z).  This command
  48. +    has the following syntax:
  49. +        XOVER [first[-last]]
  50. +    Where first and last are article numbers; the default is to return
  51. +    data for all articles.  This command is only valid after a GROUP
  52. +    command.  It returns a 224 code followed by a multi-line response.
  53. +
  54.  1.5.11
  55.      Fixes to spawn.c and batch.c for those system that need
  56.      execle() to specifically call /bin/sh to exectute a sh script.
  57. Index:common/README
  58. @@ -340,6 +340,10 @@
  59.  Authorization process. Read the file AUTHORIZATION in the root directory of
  60.  the NNTP distribution for more information.
  61.  
  62. +XOVER        (defined)
  63. +     Defines whether we want to include the XOVER command, described
  64. +in the top-level README file of this distribution.
  65. +
  66.  SERVER_FILE    ("/usr/local/lib/rn/server")
  67.  
  68.       This file contains the name of the machine which runs the
  69. Index:common/conf.h.dist
  70. @@ -201,6 +201,10 @@
  71.  /* Things that relate to authentication and access */
  72.  /* Define AUTH to use the proposed NNTP Version 2 authentication protocol. */
  73.  #define    AUTH    
  74. +
  75. +/* Various protocol extensions */
  76. +#define XOVER        /* xover -- Return .overview data */
  77. +
  78.  /*
  79.   * A file containing the name of the host which is running
  80.   * the news server.  This will have to match what rrn thinks,
  81. Index:common/nntp.h
  82. @@ -20,6 +20,7 @@
  83.   *    x2x    Article selection
  84.   *    x3x    Distribution
  85.   *    x4x    Posting
  86. + *    x8x    Authorization
  87.   */
  88.  
  89.  #define    CHAR_INF    '1'
  90. @@ -42,6 +43,7 @@
  91.  #define    OK_HEAD        221    /* Head follows */
  92.  #define    OK_BODY        222    /* Body follows */
  93.  #define    OK_NOTEXT    223    /* No text sent -- stat, next, last */
  94. +#define    OK_OVER        224    /* Overview data follows */
  95.  #define    OK_NEWNEWS    230    /* New articles by message-id follow */
  96.  #define    OK_NEWGROUPS    231    /* New newsgroups follow */
  97.  #define    OK_XFERED    235    /* Article transferred successfully */
  98. Index:server/group.c
  99. @@ -67,6 +67,9 @@
  100.          return;
  101.      }
  102.  
  103. +#ifdef XOVER
  104. +    close_xover();
  105. +#endif
  106.      close_crnt();
  107.      (void) chdir(spooldir);
  108.  
  109. @@ -108,3 +111,116 @@
  110.          argv[1]);
  111.      (void) fflush(stdout);
  112.  }
  113. +
  114. +
  115. +#ifdef XOVER
  116. +static FILE *xover_fp;
  117. +static int xover_num;
  118. +
  119. +doxover(argc, argv)
  120. +    int        argc;
  121. +    char        *argv[];
  122. +{
  123. +    register FILE    *fp;
  124. +    register int    c, first, last;
  125. +    int        artnum;
  126. +    char        *p;
  127. +
  128. +    if (!canread) {
  129. +        printf("%d You only have permission to transfer, sorry.\r\n",
  130. +            ERR_ACCESS);
  131. +        (void) fflush(stdout);
  132. +        return;
  133. +    }
  134. +
  135. +    if (!ingroup) {
  136. +        printf("%d You are not currently in a newsgroup.\r\n",
  137. +            ERR_NCING);
  138. +        (void) fflush(stdout);
  139. +        return;
  140. +    }
  141. +    if (argc != 1 && argc != 2) {
  142. +        printf("%d Usage: XOVER [first[-last]].\r\n", ERR_CMDSYN);
  143. +        (void) fflush(stdout);
  144. +        return;
  145. +    }
  146. +
  147. +    if (xover_fp)
  148. +        fp = xover_fp;
  149. +    else {
  150. +        fp = xover_fp = fopen(".overview", "r");
  151. +        if (fp == NULL) {
  152. +            printf("%d No overview available.\r\n", ERR_FAULT);
  153. +            (void) fflush(stdout);
  154. +#ifdef SYSLOG
  155. +            syslog(LOG_ERR, "xover: fopen %s: %m", ".overview");
  156. +#endif
  157. +            return;
  158. +        }
  159. +        xover_num = 0;
  160. +    }
  161. +
  162. +    /* Return the desired data.  This is written carefully to avoid
  163. +     * over-long lines. */
  164. +    printf("%d overview data follows\r\n", OK_OVER);
  165. +    if (argc == 1) {
  166. +        if (xover_num) {
  167. +            fseek(fp, 0L, 0);
  168. +            xover_num = 0;
  169. +        }
  170. +        while ((c = getc(fp)) != EOF) {
  171. +            if (c == '\n')
  172. +                (void) putchar('\r');
  173. +            putchar(c);
  174. +        }
  175. +        fseek(fp, 0L, 0);
  176. +    } else {
  177. +        p = index(argv[1], '-');
  178. +        if (p == NULL)
  179. +            first = last = atoi(argv[1]);
  180. +        else {
  181. +            *p++ = '\0';
  182. +            first = atoi(argv[1]);
  183. +            last = atoi(p);
  184. +        }
  185. +        if (first < 1)
  186. +            first = 1;
  187. +        if (first < xover_num) {
  188. +            fseek(fp, 0L, 0);
  189. +            xover_num = 0;
  190. +        }
  191. +        if (xover_num) {
  192. +            artnum = xover_num;
  193. +            xover_num = 0;
  194. +        } else
  195. +            fscanf(fp, "%d", &artnum);
  196. +        while (!feof(fp)) {
  197. +            if (artnum > last) {
  198. +                xover_num = artnum;
  199. +                break;
  200. +            }
  201. +            if (artnum >= first) {
  202. +                printf("%d", artnum);
  203. +                while ((c = getc(fp)) != EOF && c != '\n')
  204. +                    putchar(c);
  205. +                printf("\r\n");
  206. +            } else
  207. +                while ((c = getc(fp)) != EOF && c != '\n')
  208. +                    continue;
  209. +            fscanf(fp, "%d", &artnum);
  210. +        }
  211. +        if (!xover_num)
  212. +            fseek(fp, 0L, 0);
  213. +    }
  214. +    printf(".\r\n");
  215. +    (void) fflush(stdout);
  216. +}
  217. +
  218. +close_xover()
  219. +{
  220. +    if (xover_fp) {
  221. +        fclose(xover_fp);
  222. +        xover_fp = NULL;
  223. +    }
  224. +}
  225. +#endif
  226. Index:server/help.c
  227. @@ -21,8 +21,15 @@
  228.      printf("NEXT        POST         QUIT\r\n");
  229.      printf("STAT        NEWGROUPS    HELP\r\n");
  230.      printf("IHAVE       NEWNEWS      SLAVE\r\n");
  231. -    printf("\r\nAdditionally, the following extention is supported:\r\n\r\n");
  232. +#if defined(XHDR) || defined(XOVER)
  233. +    printf("\r\nAdditionally, the following extension(s) are supported:\r\n\r\n");
  234. +# ifdef    XHDR
  235.      printf("XHDR        Retrieve a single header line from a range of articles.\r\n");
  236. +# endif
  237. +# ifdef    XOVER
  238. +    printf("XOVER       Return news overview data\r\n");
  239. +# endif
  240. +#endif
  241.      printf("\r\n");
  242.      printf("Bugs to Stan Barber (Internet: nntp@tmc.edu; UUCP: ...!bcm!nntp)\r\n");
  243.      printf(".\r\n");
  244. Index:server/serve.c
  245. @@ -33,6 +33,10 @@
  246.  #ifdef AUTH
  247.  extern    int    doauth();
  248.  #endif AUTH
  249. +#ifdef XOVER
  250. +extern    int    doxover();
  251. +extern    int    close_xover();
  252. +#endif
  253.  
  254.  static struct cmdent {
  255.      char    *cmd_name;
  256. @@ -61,6 +65,9 @@
  257.  #ifdef XHDR
  258.      "xhdr",        0,    xhdr,
  259.  #endif XHDR
  260. +#ifdef XOVER
  261. +    "xover",    0,    doxover,
  262. +#endif
  263.  };
  264.  #define NUMCMDS (sizeof(cmdtbl) / sizeof(struct cmdent))
  265.  
  266. ---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
  267.