home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / UUPC11XT.ZIP / RN / NEWSETUP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-21  |  1.7 KB  |  84 lines

  1. /************************************************************************
  2.  *
  3.  *  This program will set up %./NEWSRC to be subscribed to ALL of
  4.  *  the newsgroups mentioned in the active file and to have read
  5.  *  all the articles that have expired.
  6.  *
  7.  *  %.      is the directory containing all of the "dot" files
  8.  *                      it defaults to the HOME directory unless DOTDIR is
  9.  *                      defined
  10.  *
  11.  *  NEWSRC  defaults to "newsrc" unless NEWSRC is defined
  12.  *
  13.  ************************************************************************/
  14.  
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18.  
  19. #ifdef __TURBOC__
  20. #include <dir.h>
  21. #else
  22. #define MAXDIR FILENAME_MAX
  23. #endif
  24.  
  25. #include "lib.h"
  26.  
  27. #include "active.h"
  28. #include "config.h"
  29. #include "timestmp.h"
  30.  
  31. char *getval(char *nam, char *def);
  32.  
  33. char newsrc_name[MAXDIR];
  34.  
  35. main(argc, argv)
  36.    int argc;
  37.    char **argv;
  38. {
  39.    struct grp *cur_grp;
  40.    FILE *f;
  41.  
  42.    hostinit(FALSE);
  43.  
  44.    strcpy(newsrc_name, getval("DOTDIR", E_homedir));
  45.    strcat(newsrc_name, "/");
  46.    strcat(newsrc_name, getval("NEWSRC", "newsrc"));
  47.    f = fopen(newsrc_name, "w");
  48.    if (f == NULL)
  49.    {
  50.       printf("Unable to create %s\n", newsrc_name);
  51.       exit(1);
  52.    }
  53.    get_active();
  54.  
  55.    cur_grp = group_list;
  56.    while (cur_grp != NULL)
  57.    {
  58.       fprintf(f, "%s:", cur_grp->grp_name);
  59.       if (cur_grp->grp_low > 2)
  60.       {
  61.          fprintf(f, "1-%d", cur_grp->grp_low - 1);
  62.       }
  63.       fprintf(f, "\n");
  64.       cur_grp = cur_grp->grp_next;
  65.    }
  66.    fclose(f);
  67.    return (0);
  68.  
  69. }
  70.  
  71.  
  72.  
  73.  
  74. char *
  75.   getval(nam, def)
  76.    char *nam, *def;
  77. {
  78.    char *val;
  79.  
  80.    if ((val = getenv(nam)) == NULL || !*val)
  81.       val = def;
  82.    return val;
  83. }
  84.