home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 1
/
GoldFishApril1994_CD2.img
/
d4xx
/
d473
/
cnewssrc
/
cnews_src.lzh
/
misc
/
loghist.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-10-22
|
1KB
|
82 lines
/*
* loghist - print history lines corresponding to msgids from stdin
*/
#include <stdio.h>
#include "news.h"
#include "history.h"
char *progname;
int debug;
static char *histfile; /* unused */
int remote; /* to satisfy rnews code */
int headdebug = 0; /* no debugging */
/*
* main - parse arguments and handle options
*/
main(argc, argv)
int argc;
char *argv[];
{
int c;
int errflg = 0;
extern int optind;
extern char *optarg;
char log_entry[256];
progname = argv[0];
while ((c = getopt(argc, argv, "df:")) != EOF)
switch (c) {
case 'd':
++debug;
break;
case 'f':
histfile = optarg;
break;
default:
errflg++;
break;
}
while ( fgets( log_entry, 256, stdin ) != NULL )
{
log_entry[strlen(log_entry)-1] = 0;
process( log_entry );
}
exit(0);
}
/*
* process - message-id argument
*/
process(msgid)
char *msgid;
{
char *histent;
if (msgid == NULL)
return;
histent = gethistory(msgid);
if (histent == NULL) {
char newmsgid[1000];
extern char *strcpy(), *strcat();
(void) strcpy(newmsgid, "<");
(void) strcat(newmsgid, msgid);
(void) strcat(newmsgid, ">");
histent = gethistory(newmsgid);
}
if (histent == NULL)
fprintf(stderr, "%s: no history entry for %s nor <%s>\n",
progname, msgid, msgid);
else
fputs(histent, stdout);
(void) fflush(stdout);
}
unprivileged()
{
}