7da660408bb484d96d33ef69a63ec7c1adceedae
[citadel.git] / citadel / rcit.c
1 #define UNCOMPRESS "/usr/bin/gunzip"
2
3 /* Citadel/UX rcit $Id$
4  *
5  * This program simply feeds its standard input to the networker.  It is
6  * used primarily to hook up to UUCP feeds of Citadel data.
7  *
8  * 
9  * usage:
10  *      rcit [-z] [-s]
11  * flags:
12  *      -z      Input is compressed, run uncompress on it before processing
13  *      -s      Don't run netproc now, just accept the input into spoolin
14  */
15
16 #include <stdlib.h>
17 #include <unistd.h>
18 #include <fcntl.h>
19 #include <stdio.h>
20 #include <ctype.h>
21 #include <string.h>
22 #include <time.h>
23 #include "citadel.h"
24
25 void get_config(void);
26 struct config config;
27
28 int main(int argc, char **argv)
29 {
30         int a;
31         char flnm[128],tname[128];
32         FILE *minput, *mout;
33         char compressed_input = 0;
34         char spool_only = 0;
35
36         get_config();
37         sprintf(flnm,"./network/spoolin/rcit.%d", getpid());
38         sprintf(tname, tmpnam(NULL));
39
40         for (a=1; a<argc; ++a) {
41                 if (!strcmp(argv[a],"-z")) compressed_input = 1;
42                 if (!strcmp(argv[a],"-s")) spool_only = 1;
43         }
44
45         minput=stdin;
46         if (compressed_input) minput=popen(UNCOMPRESS,"r");
47         if (minput==NULL) fprintf(stderr,"rnews: can't open input!!!!\n");
48
49         mout=fopen(flnm,"w");
50         while ((a=getc(minput))>=0) putc(a,mout);
51         putc(0,mout);
52         fclose(mout);
53
54         unlink(tname);
55         if (compressed_input) pclose(minput);
56         if (!spool_only) execlp("./netproc", "netproc", "-i", NULL);
57         exit(0);
58 }
59
60