home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * UUCP.c written by William Loftus
- * Copyright 1988 by William Loftus. All rights reserved.
- *
- * $Header: Beta:src/uucp/src/uucico/RCS/uucp.c,v 1.1 90/02/02 11:56:13 dillon Exp Locker: dillon $
- *
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "version.h"
- #include "config.h"
-
- #define VERDATE " 1.02 (26 Sep 90) "
-
- static char *version20 = "$VER: uucp" VERDATE "\n\r";
- char to_buf[128];
- char from_buf[128];
- char path[128];
- char *user;
-
- char command_file[128];
- int seq;
-
- void BuildReceiveFile();
- void BuildSendFile();
- void read_ctl();
- char *expand_file();
- char *strchr();
- char *getcwd();
-
- #define TRUE 1
- #define FALSE 0
-
- CXBRK()
- {
- return(0);
- }
-
- void
- main(argc,argv)
- int argc;
- char **argv;
- {
- int to_bang, from_bang;
-
- if (argc != 3)
- {
- printf("AmigaUUCP Plus: uucp" VERDATE "\n");
- printf("Written by Ingo Feulner\n\n");
- printf("Usage: UUCP from_file to_file\n");
- exit(1);
- } else {
- strcat(from_buf, argv[1]);
- strcat(to_buf, argv[2]);
- }
-
- getcwd(path,128);
-
- if (chdir(GetConfigDir(UUSPOOL))) {
- printf("Couldn't change current working directory to %s\n", GetConfigDir(UUSPOOL));
- exit(1);
- }
-
- read_ctl();
-
- seq = GetSequence(1);
- if (seq < 0) {
- chdir(path);
- exit(1);
- }
-
- from_bang = (int)strchr(from_buf,'!');
- to_bang = (int)strchr(to_buf,'!');
-
- if (from_bang && to_bang) {
- printf("Can not specify a remote system in both arguments.\n");
- chdir(path);
- exit(1);
- }
-
- if (from_bang) {
- BuildReceiveFile();
- }
-
- if (to_bang) {
- BuildSendFile();
- }
-
- chdir(path);
- exit(0);
- }
-
- void
- BuildSendFile()
- {
- FILE *fp;
- char system_name[32];
- int bang;
-
- strcpy(from_buf,expand_file(from_buf));
-
- bang = (int)strchr(to_buf,'!');
- bang = bang - (int)to_buf;
-
- strncpy(system_name,to_buf,bang);
-
- system_name[bang] = '\0';
-
- if (!is_in_L_sys_file(system_name)) {
- printf("System \"%s\" not in L.sys file.\n", system_name);
- chdir(path);
- exit(1);
- }
-
- system_name[7] = '\0';
-
- sprintf(command_file,"C.%.6sA%04lx", system_name, seq);
-
- LockFile(command_file);
-
- fp = fopen(command_file,"w");
-
- if (fp) {
- /* srcnam desnam who flags temp mode who */
- fprintf(fp,"S %s %s %s %s %s %s %s\n",
- from_buf,
- to_buf + bang + 1,
- user,
- "-c",
- from_buf,
- "0666",
- user
- );
- fclose(fp);
- } else {
- UnLockFile(command_file);
- perror(command_file);
- chdir(path);
- exit(1);
- }
- UnLockFile(command_file);
- printf("Command queue for transfer to %s.\n", system_name);
- }
-
- void
- BuildReceiveFile()
- {
- FILE *fp;
- char system_name[32];
- int bang;
-
- strcpy(to_buf,expand_file(to_buf));
-
- bang = (int)strchr(from_buf,'!');
- bang = bang - (int)from_buf;
-
- strncpy(system_name,from_buf,bang);
-
- system_name[bang] = '\0';
-
- if (!is_in_L_sys_file(system_name)) {
- printf("System \"%s\" not in L.sys file.\n", system_name);
- chdir(path);
- exit(1);
- }
-
- system_name[7] = '\0';
-
- sprintf(command_file,"C.%.6sA%04lx", system_name, seq);
-
- LockFile(command_file);
-
- fp = fopen(command_file,"w");
- if (fp) {
- /* srcnam desnam who flags */
- fprintf(fp,"R %s %s %s %s\n",
- from_buf + bang + 1,
- to_buf,
- user,
- "-c"
- );
- fclose(fp);
- } else {
- UnLockFile(command_file);
- perror(command_file);
- chdir(path);
- exit(1);
- }
- UnLockFile(command_file);
- printf("Command queue for transfer from %s.\n", system_name);
- }
-
- static char name[128];
-
- char *
- expand_file(file_name)
- char *file_name;
- {
- char *colon;
-
- colon = strchr(file_name,':');
- if ((colon != (char*)NULL) && (colon != file_name)) {
- return(file_name);
- } else {
- if (path[strlen(path)-1] != ':') {
- sprintf(name,"%s/%s",path,file_name);
- return name;
- } else {
- sprintf(name,"%s%s",path,file_name);
- return name;
- }
- }
- }
-
- #define CTL_DELIM " \t\r\n"
-
- /*
- * Read the control file and grab a few parameters.
- */
-
- void
- read_ctl()
- {
- user = FindConfig(USERNAME);
- }
-