home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume19 / rkive / part01 / disp_grp.c < prev    next >
C/C++ Source or Header  |  1989-06-29  |  4KB  |  120 lines

  1. /*
  2. **
  3. ** This software is Copyright (c) 1989 by Kent Landfield.
  4. **
  5. ** Permission is hereby granted to copy, distribute or otherwise 
  6. ** use any part of this package as long as you do not try to make 
  7. ** money from it or pretend that you wrote it.  This copyright 
  8. ** notice must be maintained in any copy made.
  9. **
  10. **
  11. **  History:
  12. **    Creation: Tue Feb 21 08:52:35 CST 1989 due to necessity.
  13. **                                                               
  14. */
  15. #ifndef lint
  16. static char SID[] = "@(#)disp_grp.c    1.1 6/1/89";
  17. #endif
  18.  
  19. #include <sys/types.h>
  20. #include <dirent.h>
  21. #include <stdio.h>
  22. #include <pwd.h>
  23. #include <grp.h>
  24. #include "cfg.h"
  25.  
  26. extern fill_in_defaults;
  27. extern FILE *logfp;
  28.  
  29. struct passwd *pw;
  30. struct passwd *getpwuid();
  31. struct group *gr;
  32. struct group *getgrgid();
  33.  
  34. char *what_to_print(ng_val, gbl_val, str)
  35. char *ng_val, *gbl_val, *str;
  36. {
  37.     static char rtbuf[50];
  38.  
  39.     /*
  40.     ** If the newsgroup variable has been 
  41.     ** specified, return that value.
  42.     */
  43.     if (*(ng_val)) 
  44.         return (ng_val);
  45.  
  46.     /*
  47.     ** If no global value has been specified
  48.     ** so that there is no default, build the
  49.     ** display string and return.
  50.     */
  51.     if (!*gbl_val) {
  52.         (void) sprintf(rtbuf,"%-15s (*NO* DEFAULT)", str);
  53.         return (rtbuf);
  54.     }
  55.  
  56.     /*
  57.     ** Ok, here we have a global value.
  58.     ** Check if the user has requested to display global default
  59.     ** values in variables that are not specifically assigned 
  60.     ** for the newsgroup...
  61.     */
  62.     if (fill_in_defaults)
  63.         return (gbl_val);
  64.  
  65.     (void) sprintf(rtbuf,"%-15s (DEFAULT)", str);
  66.     return (rtbuf);
  67. }
  68.  
  69.  
  70. display_group_info(ng)
  71. struct group_archive *ng;
  72. {
  73.     if (!*ng->location)
  74.        (void) fprintf(logfp,"\007\007%s does not have an archived location\n",
  75.                   ng->ng_name);
  76.     else
  77.        (void) fprintf(logfp,"%s newsgroup archived to %s\n", 
  78.                   ng->ng_name, ng->location);
  79.  
  80.     (void) fprintf(logfp,"\tArchive Type:   %s\n",
  81.                   ng->type == ARCHIVE_NAME ? "Archive-Name" : 
  82.                   ng->type == VOLUME_ISSUE ? "Volume-Issue" :
  83.                                              "Article-Number"); 
  84.     (void) fprintf(logfp,"\tPatches Type:   %s\n", 
  85.                   ng->patch_type == PACKAGE ? "Package" : "Historical");
  86.  
  87.     /* 
  88.     ** The getpwuid() and getgrgid() calls have been previously made
  89.     ** thus verifying the entries exist. No real reason to check if
  90.     ** calls fail. If they do, something a lot bigger than this program
  91.     ** is hosed...
  92.     */
  93.     pw = getpwuid(ng->owner);
  94.     (void) fprintf(logfp,"\tOwner:          %d <%s>\n", 
  95.                   ng->owner, pw->pw_name);
  96.     gr = getgrgid(ng->group);
  97.     (void) fprintf(logfp,"\tGroup:          %d <%s>\n", 
  98.                   ng->group, gr->gr_name);
  99.  
  100.     (void) fprintf(logfp,"\tFile Modes:     %o\n", ng->modes);
  101.     (void) fprintf(logfp,"\tLogfile:        %s\n", 
  102.                what_to_print(ng->logfile, log, "NO LOGGING"));
  103.     (void) fprintf(logfp,"\tIndex File:     %s\n", 
  104.                what_to_print(ng->index, index, "NO INDEXING"));
  105.     (void) fprintf(logfp,"\tLogfile Format: %s\n", 
  106.                what_to_print(ng->logformat, log_format, "NOT SPECIFIED"));
  107.     (void) fprintf(logfp,"\tIndex Format:   %s\n", 
  108.                what_to_print(ng->indformat, index_format, "NOT SPECIFIED"));
  109.     (void) fprintf(logfp,"\tMail Results:   %s\n", 
  110.                what_to_print(ng->mail_list, mail, "NO ONE"));
  111.     (void) fprintf(logfp,"\tCompression:    %s\n", 
  112.                what_to_print(ng->compress, compress, "NO COMPRESSION"));
  113.  
  114.     if ((ng->patch_type == PACKAGE) && (ng->type != ARCHIVE_NAME)) {
  115.         (void) fprintf(logfp,"\nWARNING: Package Patches archiving is only\n");
  116.         (void) fprintf(logfp,"         used with Archive-Name archiving.\n");
  117.     }
  118. }
  119.  
  120.