home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 1 / GoldFishApril1994_CD2.img / d4xx / d473 / cnewssrc / cnews_src.lzh / misc / loghist.c < prev    next >
C/C++ Source or Header  |  1989-10-22  |  1KB  |  82 lines

  1. /*
  2.  * loghist - print history lines corresponding to msgids from stdin
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include "news.h"
  7. #include "history.h"
  8.  
  9. char *progname;
  10. int debug;
  11. static char *histfile;        /* unused */
  12. int remote;            /* to satisfy rnews code */
  13. int headdebug = 0;        /* no debugging */
  14.  
  15. /*
  16.  * main - parse arguments and handle options
  17.  */
  18. main(argc, argv)
  19. int argc;
  20. char *argv[];
  21. {
  22.     int c;
  23.     int errflg = 0;
  24.     extern int optind;
  25.     extern char *optarg;
  26.     char log_entry[256];
  27.  
  28.     progname = argv[0];
  29.     while ((c = getopt(argc, argv, "df:")) != EOF)
  30.         switch (c) {
  31.         case 'd':
  32.             ++debug;
  33.             break;
  34.         case 'f':
  35.             histfile = optarg;
  36.             break;
  37.         default:
  38.             errflg++;
  39.             break;
  40.         }
  41.  
  42.     while ( fgets( log_entry, 256, stdin ) != NULL )
  43.         {
  44.         log_entry[strlen(log_entry)-1] = 0;
  45.         process( log_entry );
  46.         }
  47.  
  48.     exit(0);
  49. }
  50.  
  51. /*
  52.  * process - message-id argument
  53.  */
  54. process(msgid)
  55. char *msgid;
  56. {
  57.     char *histent;
  58.  
  59.     if (msgid == NULL)
  60.         return;        
  61.     histent = gethistory(msgid);
  62.     if (histent == NULL) {
  63.         char newmsgid[1000];
  64.         extern char *strcpy(), *strcat();
  65.  
  66.         (void) strcpy(newmsgid, "<");
  67.         (void) strcat(newmsgid, msgid);
  68.         (void) strcat(newmsgid, ">");
  69.         histent = gethistory(newmsgid);
  70.     }
  71.     if (histent == NULL)
  72.         fprintf(stderr, "%s: no history entry for %s nor <%s>\n",
  73.             progname, msgid, msgid);
  74.     else
  75.         fputs(histent, stdout);
  76.     (void) fflush(stdout);
  77. }
  78.  
  79. unprivileged()
  80. {
  81. }
  82.