home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * UUX.C
- *
- * $Header: Beta:src/uucp/src/uucico/RCS/uux.c,v 1.1 90/02/02 11:56:20 dillon Exp Locker: dillon $
- *
- * Copyright 1988 by William Loftus. All rights reserved.
- *
- * Example: 1> uux mail-message "burdvax!rmail wpl"
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "version.h"
-
- #define VERDATE " 1.06 (18 Sep 90) "
-
- static char *version20 = "$VER: uux" VERDATE "\n\r";
-
- char user[128];
- char file_name[128];
- char command[128];
-
- char exec_file[128];
- char x_exec_file[128];
- char command_file[128];
- char data_file[128];
- int seq;
-
- char path[128];
-
- void GetTo();
- void GetSubject();
-
- #define TRUE 1
- #define FALSE 0
-
- int
- brk()
- {
- return(0);
- }
-
- void
- main(argc, argv)
- int argc;
- char **argv;
- {
- int error;
- char *up = FindConfig(USERNAME);
-
- onbreak(brk);
- if (up == NULL) {
- printf("couldn't find config entry for %s\n", USERNAME);
- exit(1);
- }
- strcpy(user, up);
-
- getcwd(path,128);
- chdir(GetConfigDir(UUSPOOL));
- if (argc == 3) {
- strcpy(file_name, argv[1]);
- strcpy(command, argv[2]);
- }
- else
- {
- printf("AmigaUUCP Plus: uux" VERDATE "\n");
- printf("Written by Ingo Feulner\n\n");
- printf("Usage: uux file-name command\n");
- printf("Example: 1> uux mail-message \"burdvax!rmail wpl\"\n");
- chdir(path);
- exit(1);
- }
- seq = GetSequence(1);
- if (seq >= 0)
- error = Queue();
- UnLockFile(exec_file);
- UnLockFile(x_exec_file);
- UnLockFile(command_file);
- UnLockFile(data_file);
- chdir(path);
- if (seq < 0 || error < 0)
- exit(1);
- }
-
- Queue()
- {
- FILE *fp;
- char system_name[32];
- int bang;
- int error;
- int rnews = 0; /* -IF- */
-
- bang = (int)strchr(command,'!');
- bang = bang - (int)command;
-
- strncpy(system_name,command,bang);
-
- system_name[bang] = '\0';
-
- if (!is_in_L_sys_file(system_name)) {
- printf ("System \"%s\" not in L.sys file.\n", system_name);
- return(-1);
- }
-
- system_name[7] = '\0';
-
- /* Will we build a rnews command? -IF- */
- if((strcmp(((char *)command + bang + 1), "rnews")) == 0)
- rnews = 1; /* Yes! */
-
- sprintf(exec_file, "D.%.6sX%04lx", system_name, seq);
- sprintf(x_exec_file, "X.%.6sX%04lx", system_name, seq);
- sprintf(command_file,"C.%.6sA%04lx", system_name, seq);
- sprintf(data_file, "D.%.6sB%04lx", system_name, seq);
-
- LockFile(exec_file);
- LockFile(x_exec_file);
- LockFile(command_file);
- LockFile(data_file);
-
- fp = fopen(exec_file,"w");
- if(fp)
- {
- fprintf(fp,"U %s %s\n", (rnews == 0) ? user : "news",
- FindConfig(NODENAME));
- fprintf(fp,"F %s\n", data_file);
- fprintf(fp,"I %s\n", data_file);
- fprintf(fp,"C %s\n", (char *)command + bang + 1);
- fclose(fp);
- }
- else
- {
- perror(exec_file);
- return(-1);
- }
-
- fp = fopen(command_file,"w");
- if (fp) {
- fprintf(fp,"S %s %s %s - %s 0666\n",
- data_file,
- data_file,
- (rnews == 0) ? user : "news", /* -IF- */
- data_file
- );
- fprintf(fp,"S %s %s %s - %s 0666\n",
- exec_file,
- x_exec_file,
- (rnews == 0) ? user : "news", /* -IF- */
- exec_file
- );
- fclose(fp);
- } else {
- perror(command_file);
- return(-1);
- }
- chdir(path);
- error = Copy(file_name, data_file);
- chdir(GetConfigDir(UUSPOOL));
- return(error);
- }
-
- /*
- * Read the control file and grab a few parameters.
- */
-
- Copy(from, to)
- char *from;
- char *to;
- {
- FILE *fd;
- FILE *td;
- int c;
- static char to_buf[128];
-
- fd = fopen(from, "r");
- if (!fd) {
- printf("Could not open %s.\n", from);
- perror(from);
- return(-1);
- }
-
- strcpy(to_buf, MakeConfigPath(UUSPOOL, to));
-
- td = fopen(to_buf, "w");
- if (!td) {
- printf("Could not open %s.\n", to_buf);
- perror(to);
- return(-1);
- }
- while ((c = fgetc(fd)) != EOF) {
- fputc((char)c, td);
- }
- fclose(fd);
- fclose(td);
- return(1);
- }
-