home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * UUXQT.C by William Loftus
- * Copyright 1988 by William Loftus. All rights reserved.
- * Changes Copyright 1990 by Matthew Dillon, All Rights Reserved
- *
- * $Header: Beta:src/uucp/src/uucico/RCS/uuxqt.c,v 1.1 90/02/02 11:55:58 dillon Exp Locker: dillon $
- *
- * 3.7.90 Ingo Feulner: Added sorting.
- * 23.8.90 Ingo Feulner: Changed command systax for sendmail.
- */
-
- #include <stdio.h>
- #include <string.h>
- #include "version.h"
- #include "log.h"
-
- static char *version20 = "$VER: uuxqt 1.06 (23 Aug 90)\n\r";
-
- static char names[MAXFILES*16];
- static char *pointers[MAXFILES];
- static int file_pointer;
- static int error;
- static char *xfile;
- static char dfile[128];
- static char cmd[1024];
- static char ccmd[128];
- static char ccmd_args[128];
- static char buf[128];
- static char path[256];
-
- #define DELIM " \t\n\r"
-
- int
- brk()
- {
- return(0);
- }
-
- char *
- work_scan()
- {
- static char name[128];
- int count;
-
- file_pointer = 0;
-
- strcpy(name, MakeConfigPath(UUSPOOL, "X.#?"));
-
- count = getfnl(name, names, sizeof(names), 0);
-
- if (count > 0)
- {
- ulog(-1, "New files have arrived.");
-
- if (strbpl(pointers,MAXFILES,names) != count)
- {
- ulog(-1, "Too many execute files\n");
- return (char *)NULL;
- }
- else
- {
- tqsort(pointers, count);
- }
- }
- else
- {
- return (char *)NULL;
- }
- return (char *)1;
- }
-
- char *
- work_next()
- {
- return pointers[file_pointer++];
- }
-
- parse(x)
- char *x;
- {
- FILE *fp;
- char *tmp;
-
- fp = fopen(x, "r");
- if (fp == (char *)NULL)
- {
- ulog(-1, "Can't open file %s\n",x);
- chdir(path);
- return(0);
- }
- while (fgets(buf, sizeof buf, fp))
- {
- if (strncmp(buf, "F", 1) == 0)
- strcpy(dfile, strtok(&buf[1],DELIM));
- else if (strncmp(buf, "C", 1) == 0)
- strcpy(ccmd, strtok(&buf[1],DELIM));
- strcpy(ccmd_args, strtok(NULL, DELIM));
- while ((tmp = (char *)strtok(NULL, DELIM)) != NULL)
- {
- strcat(ccmd_args, " ");
- strcat(ccmd_args, tmp);
- }
- }
-
- if (strncmp(ccmd, "rmail", 5) == 0)
- {
- sprintf(cmd,"sendmail <%s -r %s", dfile, ccmd_args);
- ulog(-1, "Executing rmail");
- }
- else if (strncmp(ccmd, "rnews", 5) == 0)
- {
- sprintf(cmd,"rnews <%s", dfile);
- ulog(-1, "Executing rnews");
- }
- else
- {
- ulog(-1, "Unknown command request %s - Operation Aborted -\n", ccmd);
- error = 1;
- }
- fclose(fp);
- return(1);
- }
-
-
- void main()
- {
- LogProgram = "uuxqt";
- onbreak(brk);
-
- getcwd(path, sizeof(path));
- chdir(GetConfigDir(UUSPOOL));
- LockFile("UUXQT");
-
- if (work_scan() != (char *)NULL)
- {
- while ((xfile = work_next()) != (char *)NULL)
- {
- LockFile(xfile);
- if (parse(xfile))
- {
- int syserr;
-
- syserr = system(cmd);
- if (syserr == 0 && error != 1)
- {
- remove(xfile);
- remove(dfile);
- }
- }
- UnLockFile(xfile);
- }
- }
- UnLockFile("UUXQT");
- chdir(path);
- }
-