home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume19 / rkive / part02 / ckconfig.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-29  |  4.8 KB  |  146 lines

  1. /*
  2. **                                                                
  3. **  Subsystem:   USENET Sources Archiver             
  4. **  File Name:   ckconfig.c               
  5. **                                                        
  6. **  usage: config [ -gV ] [ -f config_file ]
  7. **
  8. **
  9. ** This software is Copyright (c) 1989 by Kent Landfield.
  10. **
  11. ** Permission is hereby granted to copy, distribute or otherwise 
  12. ** use any part of this package as long as you do not try to make 
  13. ** money from it or pretend that you wrote it.  This copyright 
  14. ** notice must be maintained in any copy made.
  15. **
  16. ** Use of this software constitutes acceptance for use in an AS IS 
  17. ** condition. There are NO warranties with regard to this software.  
  18. ** In no event shall the author be liable for any damages whatsoever 
  19. ** arising out of or in connection with the use or performance of this 
  20. ** software.  Any use of this software is at the user's own risk.
  21. **
  22. **  If you make modifications to this software that you feel 
  23. **  increases it usefulness for the rest of the community, please 
  24. **  email the changes, enhancements, bug fixes as well as any and 
  25. **  all ideas to me. This software is going to be maintained and 
  26. **  enhanced as deemed necessary by the community.
  27. **        
  28. **        Kent Landfield
  29. **        uunet!ssbell!kent
  30. **
  31. **  History:
  32. **    Creation: Tue Feb 21 08:52:35 CST 1989 due to necessity.
  33. **                                                               
  34. */
  35. char sccsid[] = "@(#)ckconfig.c    1.1 6/1/89";
  36.  
  37. #include <sys/types.h>
  38. #include <dirent.h>
  39. #include <stdio.h>
  40. #include <pwd.h>
  41. #include <grp.h>
  42. #include "cfg.h"
  43.  
  44. #define M1 "The following values are used if the administrator has"
  45. #define M2 "not set a value for a necessary configuration item(s)."
  46. #define USAGE  "usage: %s [ -gV ] [ -f config_file ]\n"
  47.  
  48. extern struct passwd *pw;
  49. extern struct group *gr;
  50.  
  51. struct passwd *getpwuid();
  52. struct group *getgrgid();
  53.  
  54. main(argc,argv)
  55. int argc;
  56. char **argv;
  57. {
  58.    int c;
  59.    extern char *optarg;
  60.    extern int optind;
  61.  
  62.    logfp = stdout;
  63.    errfp = stderr;
  64.    progname = argv[0];
  65.    fill_in_defaults = 0;
  66.    config_file = LOCATION;
  67.  
  68.    if (argc > 1) {
  69.       while ((c = getopt(argc, argv, "gVf:")) != EOF) {
  70.          switch (c) {
  71.              case 'f':
  72.                  config_file = optarg;
  73.                  break;
  74.              case 'g':
  75.                  fill_in_defaults++;
  76.                  break;
  77.              case 'V':
  78.                  version();
  79.              default:
  80.                  (void) fprintf(errfp,USAGE, progname);
  81.                  return(1);
  82.          }
  83.       }
  84.    }
  85.    setup_defaults();
  86.  
  87.    display_config();
  88.    return(0);
  89. }
  90.  
  91.  
  92. display_config()
  93. {
  94.     register int i;
  95.  
  96.     (void) fprintf(logfp,"\n\t\tConfiguration Check for %s\n", 
  97.                          config_file);
  98.  
  99.     (void) fprintf(logfp,"\n\t\t\tGlobal Defines\n\n");
  100.  
  101.     (void) fprintf(logfp,"News Directory:      %s\n",spooldir);
  102.     (void) fprintf(logfp,"Problems Directory:  %s\n",problems_dir);
  103.     (void) fprintf(logfp,"Global Logfile:      %s\n",
  104.                          *log ? log : "NO LOGGING");
  105.     (void) fprintf(logfp,"Global Index:        %s\n", 
  106.                          *index ? index:"NO INDEXING");
  107.     (void) fprintf(logfp,"Logfile Format:      %s\n",
  108.                          *log_format ? log_format : "NOT SPECIFIED");
  109.     (void) fprintf(logfp,"Index Format:        %s\n",
  110.                          *index_format ? index_format : "NOT SPECIFIED");
  111.     (void) fprintf(logfp,"Mail Results To:     %s\n\n", 
  112.                          *mail ? mail : "NO ONE");
  113.     (void) fprintf(logfp,"%s\n%s\n\n",  M1, M2);
  114.     (void) fprintf(logfp,"Archive Type:    %s\n",
  115.                          default_type == ARCHIVE_NAME ? "Archive-Name": 
  116.                          default_type == VOLUME_ISSUE ? "Volume-Issue":
  117.                                                         "Article-Number"); 
  118.     (void) fprintf(logfp,"Patches Type:    %s\n",
  119.                          default_patch_type == PACKAGE ? "Package" :
  120.                                                          "Historical");
  121.  
  122.  
  123.     pw = getpwuid(default_owner);
  124.     (void) fprintf(logfp,"Default Owner:   %d <%s>\n", 
  125.                          default_owner,pw->pw_name);
  126.  
  127.     gr = getgrgid(default_group);
  128.     (void) fprintf(logfp,"Default Group:   %d <%s>\n", 
  129.                          default_group, gr->gr_name);
  130.     (void) fprintf(logfp,"Default Modes:   %o\n", default_modes);
  131.     (void) fprintf(logfp,"Compression:     %s\n\n",
  132.                           *compress ? compress : "NO COMPRESSION");
  133.  
  134.     if (default_patch_type == PACKAGE && default_type != ARCHIVE_NAME) {
  135.         (void) fprintf(logfp,"WARNING: Package Patches archiving is only\n");
  136.         (void) fprintf(logfp,"         used with Archive-Name archiving.\n\n");
  137.     }
  138.  
  139.     (void) fprintf(logfp,"\t\tNewsgroup Archive Configuration\n\n\n");
  140.     for (i = 0; i <= num; i++)  {
  141.          display_group_info(&group[i]);
  142.          (void) fprintf(logfp,"\n\n");
  143.     }
  144.     return;
  145. }
  146.