home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / INTERNET / UPC2S1.ZIP / UUCP.C < prev    next >
C/C++ Source or Header  |  1993-10-03  |  27KB  |  672 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    u u c p . c                                                     */
  3. /*                                                                    */
  4. /*    UUCP lookalike for IBM PC.                                      */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*    Changes Copyright (c) 1989-1993 by Kendra Electronic            */
  9. /*    Wonderworks.                                                    */
  10. /*                                                                    */
  11. /*    All rights reserved except those explicitly granted by the      */
  12. /*    UUPC/extended license agreement.                                */
  13. /*--------------------------------------------------------------------*/
  14.  
  15. /*--------------------------------------------------------------------*/
  16. /*                          RCS Information                           */
  17. /*--------------------------------------------------------------------*/
  18.  
  19. /*
  20.  *    $Id: uucp.c 1.9 1993/10/03 20:43:08 ahd Exp $
  21.  *
  22.  *    Revision history:
  23.  *    $Log: uucp.c $
  24.  * Revision 1.9  1993/10/03  20:43:08  ahd
  25.  * Normalize comments to C++ double slash
  26.  *
  27.  * Revision 1.8  1993/10/02  19:07:49  ahd
  28.  * Use 0644 permissions on files
  29.  *
  30.  * Revision 1.7  1993/09/20  04:48:25  ahd
  31.  * TCP/IP support from Dave Watt
  32.  * 't' protocol support
  33.  * OS/2 2.x support (BC++ 1.0 for OS/2)
  34.  *
  35.  * Revision 1.6  1993/08/02  03:24:59  ahd
  36.  * Further changes in support of Robert Denny's Windows 3.x support
  37.  *
  38.  * Revision 1.5  1993/07/31  16:27:49  ahd
  39.  * Changes in support of Robert Denny's Windows support
  40.  *
  41.  * Revision 1.4  1993/04/11  00:35:46  ahd
  42.  * Global edits for year, TEXT, etc.
  43.  *
  44.  * Revision 1.3  1993/04/05  04:35:40  ahd
  45.  * Use timestamp/file size information returned by directory search
  46.  *
  47.  * Revision 1.2  1992/12/11  12:45:11  ahd
  48.  * Normalize paths for files read
  49.  *
  50.  */
  51.  
  52. /*--------------------------------------------------------------------*/
  53. /*                                                                    */
  54. /*    Change history:                                                 */
  55. /*                                                                    */
  56. /*       02/08/81 H.A.E.Broomhall                                     */
  57. /*                Hacked for UUPC/extended 1.09c                      */
  58. /*       04/27/91 Drew Derbyshire                                     */
  59. /*                Modified for UUPC/extended 1.10a                    */
  60. /*       09/26/91 Mitch Mitchell                                      */
  61. /*                Support for UUX                                     */
  62. /*       01/26/92 Drew Derbyshire                                     */
  63. /*                Various comment and error message clean up          */
  64. /*--------------------------------------------------------------------*/
  65.  
  66. /*--------------------------------------------------------------------*/
  67. /*                        system include files                        */
  68. /*--------------------------------------------------------------------*/
  69.  
  70. #include  <ctype.h>
  71. #include  <direct.h>
  72. #include  <fcntl.h>
  73. #include  <io.h>
  74. #include  <stdio.h>
  75. #include  <stdlib.h>
  76. #include  <string.h>
  77. #include  <sys/types.h>
  78. #include  <sys/stat.h>
  79.  
  80. #ifdef _Windows
  81. #include <windows.h>
  82. #endif
  83.  
  84. /*--------------------------------------------------------------------*/
  85. /*                    UUPC/extended include files                     */
  86. /*--------------------------------------------------------------------*/
  87.  
  88. #include  "lib.h"
  89. #include  "expath.h"
  90. #include  "getopt.h"
  91. #include  "getseq.h"
  92. #include  "hlib.h"
  93. #include  "hostable.h"
  94. #include  "import.h"
  95. #include  "uundir.h"
  96. #include  "security.h"
  97. #include  "timestmp.h"
  98. #include  "execute.h"
  99.  
  100. #ifdef _Windows
  101. #include "winutil.h"
  102. #include "logger.h"
  103. #endif
  104.  
  105. /*--------------------------------------------------------------------*/
  106. /*                          Global variables                          */
  107. /*--------------------------------------------------------------------*/
  108.  
  109. static boolean       spool_flag = FALSE;
  110. static char          spool_file[FILENAME_MAX]; // alt spool file name
  111. static boolean       dir_flag = TRUE;
  112. static boolean       xeqt_flag = TRUE;    // Triggered by -r option
  113. static char          grade = 'n';         // Default grade of service
  114. static boolean       mail_me = FALSE;     // changes with -m
  115. static boolean       mail_them = FALSE;   // changes with -n
  116. static char  remote_user[10];             // user to mail with -n
  117. static char  *destn_file;
  118. static char  flags[16];
  119.  
  120. currentfile();
  121.  
  122. /*--------------------------------------------------------------------*/
  123. /*    u s a g e                                                       */
  124. /*                                                                    */
  125. /*    Report flags used by program                                    */
  126. /*--------------------------------------------------------------------*/
  127.  
  128. static         void    usage(void)
  129. {
  130.       fprintf(stderr, "Usage: uucp\t[-c|-C] [-d|-f] [-gGRADE] [-j] [-m] [-nUSER] [-r] [-sFILE]\\\n\
  131. \t\t[-xDEBUG_LEVEL] source-files destination-file\n");
  132. }
  133.  
  134. /*--------------------------------------------------------------------*/
  135. /*    c p                                                             */
  136. /*                                                                    */
  137. /*    Copy a file                                                     */
  138. /*--------------------------------------------------------------------*/
  139.  
  140. static int cp(char *from, char *to)
  141. {
  142.       int         fd_from, fd_to;
  143.       int         nr, nw = -1;
  144.       char        buf[BUFSIZ*4]; // faster if we alloc a big buffer
  145.  
  146.       if ((fd_from = open(from, O_RDONLY | O_BINARY)) == -1)
  147.          return(1);        // failed
  148.       /* what if the to is a directory? */
  149.       /* possible with local source & dest uucp */
  150.       if ((fd_to = open(to, O_CREAT | O_BINARY | O_WRONLY, S_IWRITE | S_IREAD)) == -1) {
  151.          close(fd_from);
  152.          return(1);        // failed
  153.          /* NOTE - this assumes all the required directories exist!  */
  154.       }
  155.       while  ((nr = read(fd_from, buf, sizeof buf)) > 0 &&
  156.          (nw = write(fd_to, buf, nr)) == nr)
  157.          ;
  158.       close(fd_to);
  159.       close(fd_from);
  160.       if (nr != 0 || nw == -1)
  161.          return(1);        // failed in copy
  162.       return(0);
  163. } /* cp */
  164.  
  165. /*--------------------------------------------------------------------*/
  166. /*    s p l i t _ p a t h                                             */
  167. /*                                                                    */
  168. /*    split_path splits a path into 3 components.                     */
  169. /*    1)  The system next in line                                     */
  170. /*    2)  Any intermediate systems as a bang path                     */
  171. /*    3)  The actual file name/path                                   */
  172. /*                                                                    */
  173. /*    It tries to be a little clever with idiots, in recognizing      */
  174. /*    system=this machine                                             */
  175. /*--------------------------------------------------------------------*/
  176.  
  177. static         void    split_path(char *path,
  178.                                   char *system,
  179.                                   char *inter,
  180.                                   char *file)
  181. {
  182.       char    *p_left, *p_right, *p;
  183.  
  184.       *system = *inter = *file = '\0';    // init to nothing
  185.       for (p = path;; p = p_left + 1)  {
  186.          p_left = strchr(p, '!');         // look for the first bang
  187.          if (p_left == NULL)  {           // not a remote path
  188.             strcpy(file, p);              // so just return filename
  189.             return;
  190.          }
  191.          /* now check if the system was in fact us.
  192.        If so strip it and restart */
  193.          if (equaln(E_nodename, p, p_left - p) &&
  194.             (E_nodename[p_left - p] == '\0'))
  195.             continue;
  196.  
  197.          p_right = strrchr(p, '!');      // look for the last bang
  198.          strcpy(file, p_right + 1);      // and thats our filename
  199.          strncpy(system, p, p_left - p); // and we have a system thats not us
  200.          system[p_left - p] = '\0';
  201.          /* now see if there is an intermediate path */
  202.          if (p_left != p_right)  {        // yup - there is
  203.             strncpy(inter, p_left + 1, p_right - p_left - 1);
  204.             inter[p_right - p_left - 1] = '\0';
  205.          }
  206.          return;                 // and we're done
  207.       }        /* never get here :-)  */
  208. }
  209.  
  210. /*--------------------------------------------------------------------*/
  211. /*    d o _ u u x                                                     */
  212. /*                                                                    */
  213. /*    Generate & execute UUX command                                  */
  214. /*--------------------------------------------------------------------*/
  215.  
  216. int   do_uux(char *remote,
  217.              char *src_syst,
  218.              char *src_file,
  219.              char *dest_syst,
  220.              char *dest_inter,
  221.              char *dest_file)
  222. {
  223.       char        xcmd[BUFSIZ];        // buffer for assembling the UUX command
  224.       char        *ex_flg;
  225.  
  226. /*--------------------------------------------------------------------*/
  227. /*                 First - lets get the basic command                 */
  228. /*--------------------------------------------------------------------*/
  229.  
  230.       ex_flg = xeqt_flag ? "" : "-r";
  231.       sprintf(xcmd, "-C %s %s!uucp -C ", ex_flg, remote);
  232.                               // but what about mailing the guy?
  233.  
  234. /*--------------------------------------------------------------------*/
  235. /*                  Now we sort out the source name                   */
  236. /*--------------------------------------------------------------------*/
  237.  
  238.       if ((*src_syst == '\0') || equal(src_syst, E_nodename))
  239.          sprintf(xcmd + strlen(xcmd), " !%s ", src_file);
  240.       else  {
  241.          if (!equal(remote, src_syst))
  242.             sprintf(xcmd + strlen(xcmd), " (%s!%s) ", src_syst, src_file);
  243.          else
  244.             sprintf(xcmd + strlen(xcmd), " (%s) ", src_file);
  245.       } /* else */
  246.  
  247. /*--------------------------------------------------------------------*/
  248. /*                   Now to do the destination name                   */
  249. /*--------------------------------------------------------------------*/
  250.  
  251.       if (*dest_inter != '\0')  {
  252.          if (*dest_syst != '\0')
  253.             sprintf(xcmd + strlen(xcmd), " (%s!%s!%s) ", dest_syst, dest_inter, dest_file);
  254.          else
  255.             sprintf(xcmd + strlen(xcmd), " (%s!%s) ", dest_inter, dest_file);
  256.       }
  257.       else  {
  258.          if ((*dest_syst == '\0') || equal(dest_syst, E_nodename))
  259.             sprintf(xcmd + strlen(xcmd), " (%s!%s) ", E_nodename, dest_file);
  260.       }
  261.       printmsg(2, "xcmd: %s", xcmd);
  262.  
  263. /*--------------------------------------------------------------------*/
  264. /*                              OK - GO!                              */
  265. /*--------------------------------------------------------------------*/
  266.  
  267.    execute("uux", xcmd, NULL, NULL, FALSE, TRUE);
  268.  
  269.    return(1);
  270.  
  271. } /* do_uux */
  272.  
  273. /*--------------------------------------------------------------------*/
  274. /*    d o _ c o p y                                                   */
  275. /*                                                                    */
  276. /*    At this point only one of the systems can be remote and only    */
  277. /*    1 hop away.  All the rest have been filtered out                */
  278. /*--------------------------------------------------------------------*/
  279.  
  280. int   do_copy(char *src_syst,
  281.               char *src_file,
  282.               char *dest_syst,
  283.               char *dest_file)
  284. {
  285.       char        *p;
  286.       boolean wild_flag = FALSE;
  287.       boolean write_flag;
  288.       char        tmfile[15];       // Unix style name for c file
  289.       char        idfile[15];       // Unix style name for data file copy
  290.       char        work[FILENAME_MAX];   // temp area for filename hacking
  291.       char        search_file[FILENAME_MAX];
  292.       char        source_path[FILENAME_MAX];
  293.       char        icfilename[FILENAME_MAX]; // our hacked c file path
  294.       char        idfilename[FILENAME_MAX]; // our hacked d file path
  295.  
  296.       struct  stat    statbuf;
  297.       DIR *dirp = NULL;
  298.       struct direct *dp = NULL;
  299.       char subseq = 'A';
  300.  
  301.       long    int     sequence;
  302.       char    *remote_syst;   // Non-local system in copy
  303.       char    *sequence_s;
  304.       FILE        *cfile;
  305.       static  char    *spool_fmt = SPOOLFMT;
  306.  
  307.       sequence = getseq();
  308.       sequence_s = JobNumber( sequence );
  309.       remote_syst =  equal(src_syst, E_nodename) ? dest_syst : src_syst;
  310.       sprintf(tmfile, spool_fmt, 'C', remote_syst, grade, sequence_s);
  311.       importpath(work, tmfile, remote_syst);
  312.       mkfilename(icfilename, E_spooldir, work);
  313.  
  314.       if (!equal(src_syst, E_nodename))
  315.       {
  316.          if (expand_path(dest_file, NULL, E_homedir, NULL) == NULL)
  317.             exit(1);
  318.          strcpy( dest_file, normalize( dest_file ));
  319.          p  = src_file;
  320.          while (*p)
  321.          {
  322.             if (*p ==  '\\')
  323.                *p = '/';
  324.             p++;
  325.          }
  326.          printmsg(1, "uucp - from \"%s\" - control = %s", src_syst,
  327.                   tmfile);
  328.          if ((cfile = FOPEN(icfilename, "a",TEXT_MODE )) == NULL)  {
  329.             printerr( icfilename );
  330.             fprintf(stderr, "uucp: cannot append to %s\n", icfilename);
  331.             panic();
  332.          }
  333.          fprintf(cfile, "R %s %s %s -%s %s 0777 %s\n", src_file, dest_file,
  334.                E_mailbox, flags, *spool_file ? spool_file : "dummy", remote_user);
  335.          fclose(cfile);
  336.          return(1);
  337.       }
  338.       else if (!equal(dest_syst, E_nodename))  {
  339.          printmsg(1,"uucp - spool %s - mkdir %s - execute %s",
  340.                 spool_flag ? "on" : "off",
  341.                   dir_flag ? "on" : "off", xeqt_flag ? "do" : "don't");
  342.  
  343.          printmsg(1,"     - dest m/c = %s  sequence = %ld  control = %s",
  344.                   dest_syst, sequence, tmfile);
  345.  
  346.          if (expand_path(src_file, NULL, E_homedir, NULL) == NULL)
  347.             exit(1);
  348.          normalize( src_file );
  349.  
  350.          p  = dest_file;
  351.  
  352.          while (*p)
  353.          {
  354.             if (*p ==  '\\')
  355.                *p = '/';
  356.             p++;
  357.          }
  358.  
  359.          if (strcspn(src_file, "*?") == strlen(src_file))
  360.          {
  361.             wild_flag = FALSE;
  362.  
  363.             if (stat(src_file, &statbuf) != 0)
  364.             {
  365.                printerr( src_file );
  366.                exit(1);
  367.             }
  368.  
  369.             if (statbuf.st_mode & S_IFDIR)
  370.             {
  371.                printf("uucp - directory name \"%s\" illegal\n",
  372.                        src_file );
  373.                exit(1);
  374.             }
  375.          } /* if (strcspn(src_file, "*?") == strlen(src_file))  */
  376.          else  {
  377.             wild_flag = TRUE;
  378.             strcpy(source_path, src_file);
  379.             p = strrchr(source_path, '/');
  380.             strcpy(search_file, p+1);
  381.             *++p = '\0';
  382.  
  383.             dirp = opendirx(source_path,search_file);
  384.             if (dirp == NULL)
  385.             {
  386.                printf("uucp - unable to open directory %s\n",source_path);
  387.                exit(1);
  388.             } /* if */
  389.  
  390.             if ((dp = readdir(dirp)) == nil(struct direct))
  391.             {
  392.                printf("uucp - can't find any file %s\n", search_file);
  393.                exit(1);
  394.             }
  395.          } /* else */
  396.  
  397.          write_flag = TRUE;
  398.  
  399.          while (write_flag)
  400.          {
  401.             if (wild_flag)
  402.             {
  403.                strcpy(src_file, source_path);
  404.                strlwr( dp->d_name );
  405.                strcat( strcpy(src_file, source_path), dp->d_name );
  406.                strcpy( src_file, normalize( src_file ));
  407.                printf("Queueing file %s for %s!%s\n", src_file, dest_syst,
  408.                         dest_file);
  409.             }
  410.             if (spool_flag)  {
  411.                sprintf(idfile , spool_fmt, 'D', E_nodename, (char) subseq++,
  412.                            sequence_s);
  413.                importpath(work, idfile, remote_syst);
  414.                mkfilename(idfilename, E_spooldir, work);
  415.                /* Do we need a MKDIR here for the system? */
  416.                if (cp(src_file, idfilename) != 0)  {
  417.                   printmsg(0, "copy \"%s\" to \"%s\" failed",
  418.                      src_file, idfilename);           // copy data
  419.                   closedir( dirp );
  420.                   exit(1);
  421.                }
  422.             }
  423.             else
  424.                strcpy(idfile, "D.0");
  425.             if ((cfile = FOPEN(icfilename, "a",TEXT_MODE)) == NULL)  {
  426.                printerr( icfilename );
  427.                printf("uucp: cannot append to %s\n", icfilename);
  428.                if (dirp != NULL )
  429.                   closedir( dirp );
  430.                exit(1);
  431.             }
  432.             fprintf(cfile, "S %s %s %s -%s %s 0644 %s\n", src_file, dest_file,
  433.                      E_mailbox, flags, idfile, remote_user);
  434.             fclose(cfile);
  435.             if (wild_flag)  {
  436.                dp = readdir(dirp);
  437.                if ( dp == NULL )
  438.                   write_flag = FALSE;
  439.             }
  440.             else
  441.                write_flag = FALSE;
  442.          }
  443.          if (dirp != NULL )
  444.             closedir( dirp );
  445.          return(1);
  446.       }
  447.       else  {
  448.          if (expand_path(src_file, NULL, E_homedir, NULL) == NULL)
  449.             exit(1);
  450.          if (expand_path(dest_file, NULL, E_homedir, NULL) == NULL)
  451.             exit(1);
  452.          if (strcmp(src_file, dest_file) == 0)
  453.          {
  454.             fprintf(stderr, "%s %s - same file; can't copy\n",
  455.                   src_file, dest_file);
  456.             exit(1);
  457.          }
  458.          cp(src_file, dest_file);
  459.          return(1);
  460.       }
  461. }
  462.  
  463. /*--------------------------------------------------------------------*/
  464. /*    m a i n                                                         */
  465. /*                                                                    */
  466. /*    main program, of course                                         */
  467. /*--------------------------------------------------------------------*/
  468.  
  469. void  main(int argc, char *argv[])
  470. {
  471.       int         i;
  472.       int         option;
  473.       boolean j_flag = FALSE;
  474.       char        src_system[100], dest_system[100];
  475.       char        src_inter[100],  dest_inter[100];
  476.       char        src_file[FILENAME_MAX],   dest_file[FILENAME_MAX];
  477.  
  478. /*--------------------------------------------------------------------*/
  479. /*                             Initialize                             */
  480. /*--------------------------------------------------------------------*/
  481.  
  482.       debuglevel = 0;
  483.  
  484.       banner( argv );
  485.       if (!configure(B_UUCP))
  486.          exit(1);
  487.  
  488. /*--------------------------------------------------------------------*/
  489. /*                        Process option flags                        */
  490. /*--------------------------------------------------------------------*/
  491.  
  492.       while ((option = getopt(argc, argv, "Ccdfg:jmn:rs:x:")) != EOF)  {
  493.          switch(option)  {
  494.             case 'c':               // don't spool
  495.                spool_flag = FALSE;
  496.                break;
  497.             case 'C':               // force spool
  498.                spool_flag = TRUE;
  499.                break;
  500.             case 'd':               // make directories
  501.                dir_flag = TRUE;
  502.                break;
  503.             case 'e':               // send uucp command to sys
  504.                /* This one is in Sams but nowhere else - I'm ignoring it */
  505.                break;
  506.             case 'f':               // don't make directories
  507.                dir_flag = FALSE;
  508.                break;
  509.             case 'g':               // set grade of transfer
  510.                grade = *optarg;
  511.                break;
  512.             case 'j':               // output job id to stdout
  513.                j_flag = TRUE;
  514.                break;
  515.             case 'm':               // send mail when copy completed
  516.                mail_me = TRUE;
  517.                break;
  518.             case 'n':               // notify remote user file was sent
  519.                mail_them = TRUE;
  520.                sprintf(remote_user, "%.8s", optarg);
  521.                break;
  522.             case 'r':               // queue job only
  523.                xeqt_flag = FALSE;
  524.                break;
  525.             case 's':               // report status of transfer to file
  526.                strcpy( spool_file, optarg);
  527.                expand_path( spool_file, NULL, E_pubdir , NULL);
  528.                break;
  529.             case 'x':               // set debug level
  530.                debuglevel = atoi(optarg);
  531.                break;
  532.             default:
  533.                usage();
  534.                exit(1);
  535.                break;
  536.          }
  537.       }
  538.       flags[0] = (char)(dir_flag ? 'd' : 'f');
  539.       flags[1] = (char)(spool_flag ? 'C' : 'c');
  540.       i = 2;
  541.       if (mail_them)
  542.          flags[i++] = 'n';
  543.       flags[i] = '\0';
  544.  
  545.       if (remote_user[0] == '\0')
  546.       {
  547.          /* copy the string taking care not to overrun the buffer */
  548.          strncpy(remote_user, E_mailbox, sizeof(remote_user) - 1 );
  549.          remote_user[sizeof(remote_user) - 1] = '\0';
  550.       }
  551.  
  552.       if (argc - optind < 2)
  553.       {
  554.          usage();
  555.          exit(1);
  556.       }
  557.  
  558. #if defined(_Windows)
  559.    openlog( NULL );
  560.    atexit( CloseEasyWin );               // Auto-close EasyWin on exit
  561. #endif
  562.  
  563. /*--------------------------------------------------------------------*/
  564. /*       Now - posibilities:                                          */
  565. /*       Sources - 1 or more, local or 1 hop away (NOT > 1 hop!)      */
  566. /*       Dest    - normal cp rules, single only, local, 1 hop or >1   */
  567. /*                 hop                                                */
  568. /*       Wildcards possible on sources.                               */
  569. /*                                                                    */
  570. /*    Actions depend on these - so we need to split the pathnames     */
  571. /*    for more info.                                                  */
  572. /*--------------------------------------------------------------------*/
  573.  
  574.       split_path(argv[argc - 1], dest_system, dest_inter, dest_file);
  575.  
  576. /*--------------------------------------------------------------------*/
  577. /*        OK - we have a destination system - do we know him?         */
  578. /*--------------------------------------------------------------------*/
  579.  
  580.       if (*dest_system != '\0')  {
  581.          if (checkreal(dest_system) == BADHOST)  {
  582.             fprintf(stderr, "uucp - bad system: %s\n", dest_system);
  583.             exit(1);
  584.          }
  585.       }
  586.       else        /* make sure we have a system name for destination */
  587.          strcpy(dest_system, E_nodename);
  588.       printmsg(9, "destination: system \"%s\", inter \"%s\", file \"%s\"",
  589.             dest_system, dest_inter, dest_file);
  590.  
  591. /*--------------------------------------------------------------------*/
  592. /*    Now - if there is more than 1 source then normal cp rules,      */
  593. /*          i.e. dest must be a directory                             */
  594. /*--------------------------------------------------------------------*/
  595.  
  596.       if (argc - optind > 2)
  597.          strcat(dest_file, "/");
  598.       destn_file = argv[argc - 1];
  599.       for (i = optind; i < (argc - 1); i++)  {
  600.          split_path(argv[i], src_system, src_inter, src_file);
  601.  
  602. /*--------------------------------------------------------------------*/
  603. /*            We need to winnow out various combinations -            */
  604. /*                        so lets get at them                         */
  605. /*                                                                    */
  606. /*                   Do we know the source system?                    */
  607. /*--------------------------------------------------------------------*/
  608.  
  609.          if (*src_system != '\0')  {
  610.             if (checkreal(src_system) == BADHOST)  {
  611.                fprintf(stderr, "uucp - bad system %s\n", src_system);
  612.                exit(1);
  613.             }
  614.          }
  615.  
  616. /*--------------------------------------------------------------------*/
  617. /*                    Source can't be >1 hop away                     */
  618. /*--------------------------------------------------------------------*/
  619.  
  620.          if (*src_inter != '\0')  {
  621.             fprintf(stderr, "uucp - illegal syntax %s\n", argv[i]);
  622.             exit(1);
  623.          }
  624.  
  625. /*--------------------------------------------------------------------*/
  626. /*        if source is remote AND wildcarded then we need uux         */
  627. /*--------------------------------------------------------------------*/
  628.  
  629.          if ((*src_system != '\0') && (strcspn(src_file, "*?[") < strlen(src_file)))  {
  630.             do_uux(src_system, src_system, src_file, dest_system, dest_inter, dest_file);
  631.             continue;
  632.          }
  633.  
  634. /*--------------------------------------------------------------------*/
  635. /*            if dest requires forwarding then we need uux            */
  636. /*--------------------------------------------------------------------*/
  637.  
  638.          if (*dest_inter != '\0')  {
  639.             do_uux(dest_system, src_system, src_file, "", dest_inter, dest_file);
  640.             continue;
  641.          }
  642.  
  643. /*--------------------------------------------------------------------*/
  644. /*         if both source & dest are remote then we need uux          */
  645. /*--------------------------------------------------------------------*/
  646.  
  647.          if ((*src_system != '\0') && (!equal(src_system, E_nodename)) &&
  648.                (*dest_system != '\0') && (!equal(dest_system, E_nodename)))  {
  649.             do_uux(dest_system, src_system, src_file, "", dest_inter, dest_file);
  650.             continue;
  651.          }
  652. /*--------------------------------------------------------------------*/
  653. /*          We have left 3 options:                                   */
  654. /*          1) src remote (non-wild) & dest local                     */
  655. /*          2) src local & dest remote 1 hop                          */
  656. /*          3) src & dest both local                                  */
  657. /*                                                                    */
  658. /*               fill up the src system if not already                */
  659. /*--------------------------------------------------------------------*/
  660.          if (*src_system == '\0')
  661.             strcpy(src_system, E_nodename);
  662.          printmsg(4, "source: system \"%s\", file \"%s\"", src_system,
  663.                      src_file);
  664.          do_copy(src_system, src_file, dest_system, dest_file);
  665.       }
  666.       if (xeqt_flag)
  667.          printmsg(1, "Call uucico");
  668.       if (j_flag)
  669.          printmsg(1,"j_flag");
  670.       exit(0);
  671. }
  672.