home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 1 / GoldFishApril1994_CD2.img / d4xx / d473 / cnewssrc / cnews_src.lzh / misc / newshist.c < prev    next >
C/C++ Source or Header  |  1990-05-28  |  2KB  |  91 lines

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