# 2.11BSD#431 - /usr/src/new/rn/getactive.c

##### Functions

    main              X

       1: #include <stdio.h>
       2: #include "config.h"
       3: #include "EXTERN.h"
       4: #include "server.h"
       5:
       6: main(argc, argv)
       7:     int     argc;
       8:     char        *argv[];
       9: {
      10:     char        ser_line[256];
      11:     int     response;
      12:     register char   *server;
      13:     register FILE   *actfp;
      14:
      15:     if (argc != 2) {
      16:         fprintf(stderr, "Usage: getactive filename\n");
      17:         exit(1);
      18:     }
      19:
      20:     server = getserverbyfile(SERVER_FILE);
      21:     if (server == NULL) {
      22:         fprintf(stderr, "Couldn't get name of news server from %s\n",
      23:             SERVER_FILE);
      24:         fprintf(stderr,
      25:       "Either fix this file, or put NNTPSERVER in your environment.\n");
      26:         exit(1);
      27:     }
      28:
      29:     response = server_init(server);
      30:     if (response < 0) {
      31:         fprintf(stderr,
      32:             "getactive: Can't get active file from server %s.\n",
      33:                 server);
      34:         exit(1);
      35:     }
      36:
      37:     if (handle_server_response(response, server) < 0)
      38:         exit(1);
      39:
      40:     put_server("LIST"); /* tell server we want the active file */
      41:     (void) get_server(ser_line, sizeof(ser_line));
      42:     if (*ser_line != CHAR_OK) {     /* and then see if that's ok */
      43:         fprintf(stderr,
      44:             "getactive: Can't get active file from server.\n");
      45:         fprintf(stderr, "Server said: %s\n", ser_line);
      46:         exit(1);
      47:     }
      48:
      49:     actfp = fopen(argv[1], "w");        /* and get ready */
      50:     if (actfp == NULL) {
      51:         close_server();
      52:         perror(argv[1]);
      53:         exit(1);
      54:     }
      55:
      56:     while (get_server(ser_line, sizeof(ser_line)) >= 0) {  /* while */
      57:         if (ser_line[0] == '.')     /* there's another line */
      58:             break;          /* get it and write it to */
      59:         if (actfp != NULL) {        /* the temporary active file */
      60:             fputs(ser_line, actfp);
      61:             putc('\n', actfp);
      62:         }
      63:     }
      64:
      65:     (void) fclose(actfp);
      66:     close_server();
      67: }

#### Defined functions

main defined in line 6; used 1 times

- in /usr/src/new/rn/rn.h line 20

Last modified: 1987-05-26 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 559 |