diff -urN uupc-extended-1.13k-original\UUCICO\dcp.c uupc-extended-1.13k-patched\UUCICO\dcp.c --- uupc-extended-1.13k-original\UUCICO\dcp.c Mon Jan 07 21:18:40 2002 +++ uupc-extended-1.13k-patched\UUCICO\dcp.c Sat Mar 27 10:41:22 2004 @@ -226,6 +226,7 @@ /* [-x debug] */ /* [-x debuglevel] */ /* [-z bps] */ +/* [-R count] */ /* */ /* e.g. */ /* */ @@ -310,6 +311,7 @@ struct HostStats remote_stats; /* host status, as defined by hostatus */ static KWBoolean dialed = KWFalse;/* True = We attempted a phone call */ +static int failedAttempts = 0; /* by default don't redial */ RCSID("$Id: dcp.c 1.59 2002/01/08 02:18:40 ahd Exp $"); @@ -359,7 +361,7 @@ /* Process our options */ /*--------------------------------------------------------------------*/ - while ((option = getopt(argc, argv, "d:g:h:m:l:r:s:tUw:x:z:n?")) != EOF) + while ((option = getopt(argc, argv, "d:g:h:m:l:r:s:tUw:x:z:n?R:")) != EOF) switch (option) { @@ -428,12 +430,18 @@ pollMode = POLL_PASSIVE; /* Implies passive polling */ hotUser = optarg; break; + + case 'R': + failedAttempts = atoi(optarg); + if (failedAttempts < 0) + failedAttempts = 0; + break; case '?': puts("\nUsage:\tuucico\t" "[-s [all | any | sys]] [-r 1|0] [-d hhmm]\n" "\t\t[-l logfile] [-n] [-t] [-U] [-x debug]\n" - "\t\t[-h handle] [-m modem] [-z bps]"); + "\t\t[-h handle] [-m modem] [-z bps] [-R count]"); return 4; } @@ -547,6 +555,7 @@ KWBoolean contacted = KWFalse; KWBoolean needUUXQT = KWFalse; + int systemFailedAttempts = failedAttempts; /*--------------------------------------------------------------------*/ /* Validate the system to call */ @@ -588,6 +597,7 @@ case CONN_INITIALIZE: setTitle("Determining system to call"); hostp = NULL; + systemFailedAttempts = failedAttempts; if ( locked ) UnlockSystem(); @@ -684,10 +694,24 @@ case CONN_DROPLINE: setTitle("Closing port %s", M_device); shutDown(); - UnlockSystem(); setTitle("Not connected"); - - m_state = CONN_CLEANUP; + if (hostp->status.hstatus == HS_CALL_FAILED + || hostp->status.hstatus == HS_STARTUP_FAILED + || hostp->status.hstatus == HS_SCRIPT_FAILED + || hostp->status.hstatus == HS_DIAL_FAILED + || hostp->status.hstatus == HS_DIAL_SCRIPT_FAILED) { + contacted = KWFalse; + if (systemFailedAttempts) { + m_state = CONN_MODEM; + systemFailedAttempts--; + } else { + UnlockSystem(); + m_state = CONN_CLEANUP; + } + } else { + UnlockSystem(); + m_state = CONN_CLEANUP; + } break; case CONN_CLEANUP: diff -urN uupc-extended-1.13k-original\UUCICO\dcpsys.c uupc-extended-1.13k-patched\UUCICO\dcpsys.c --- uupc-extended-1.13k-original\UUCICO\dcpsys.c Mon Jan 07 21:18:40 2002 +++ uupc-extended-1.13k-patched\UUCICO\dcpsys.c Sat Mar 27 10:41:22 2004 @@ -336,6 +336,8 @@ static char HostGrade( const char *fname, const char *remote ); +KWBoolean resend; + /* ************************************** */ /* Sub Systems */ /* ************************************** */ @@ -724,7 +726,7 @@ /* and call grade levels. */ /*--------------------------------------------------------------------*/ - sprintf(msg, "S%s", securep->myname ); + sprintf(msg, "S%s -R", securep->myname ); if ( bflag[F_SENDDEBUG] ) sprintf( msg + strlen(msg), " -x%d", debuglevel ); @@ -751,6 +753,14 @@ return CONN_TERMINATE; } + if (strstr(msg, "-R") != NULL) { + resend = KWTrue; + printmsg(4, "startup_server: remote can restart failed file transmissions"); + } else { + resend = KWFalse; + printmsg(4, "startup_server: remote CAN'T restart failed file transmissions"); + } + /*--------------------------------------------------------------------*/ /* Third message is protocol exchange */ /*--------------------------------------------------------------------*/ @@ -855,6 +865,8 @@ kflds = getargs(msg,flds); strcpy(sysname,&flds[0][1]); + resend = KWFalse; + for (i=1; i < kflds; i++) { if (flds[i][0] != '-') @@ -867,6 +879,10 @@ case 'Q' : /* Ignore the remote sequence number */ break; + case 'R' : + resend = KWTrue; + break; + case 'x' : if ( bflag[ F_HONORDEBUG ] ) sscanf(flds[i], "-x%d", &xdebug); @@ -989,7 +1005,7 @@ /* The host name is good; get the protocol */ /*--------------------------------------------------------------------*/ - wmsg("ROK", KWTrue); + wmsg(resend ? "ROK -R" : "ROK", KWTrue); sprintf(msg, "P%s", plist); wmsg(msg, KWTrue); diff -urN uupc-extended-1.13k-original\UUCICO\dcpxfer.c uupc-extended-1.13k-patched\UUCICO\dcpxfer.c --- uupc-extended-1.13k-original\UUCICO\dcpxfer.c Mon Jan 07 21:18:40 2002 +++ uupc-extended-1.13k-patched\UUCICO\dcpxfer.c Sat Mar 27 15:13:16 2004 @@ -158,6 +158,8 @@ static int pid; static size_t vbufsize; /* Amount to buffer in std library */ +extern KWBoolean resend; /* resend variable from dcpsys.c */ + RCSID("$Id: dcpxfer.c 1.64 2002/01/08 02:18:40 ahd Exp $"); /*--------------------------------------------------------------------*/ @@ -619,8 +621,24 @@ return XFER_ABORT; } - if (databuf[1] != 'Y') /* Otherwise reject file transfer? */ - { /* Yes --> Look for next file */ + if (databuf[1] == 'Y') { + long offset = 0, size; + + if (resend && databuf[2] && sscanf(&databuf[2], "%li", &offset) == 1 && offset > 0) { + if ( \ + fseek(xfer_stream, 0L, SEEK_END) == 0 && \ + (size = ftell(xfer_stream)) != -1L && \ + offset <= size && \ + fseek(xfer_stream, offset, SEEK_SET) == 0 \ + ) { + printmsg(4, "ssfile: remote already have this file, restarting at %ld", offset); + } else { + printmsg(0, "ssfile: wrong restart position requested: %ld, transfer aborted", offset); + return XFER_ABORT; + } + } + } else { /* Otherwise reject file transfer? */ + /* Yes --> Look for next file */ printmsg(0, "ssfile: Remote host rejected file %s, reason %s", tName, databuf[2] ? (char *) &databuf[2] : "unknown" ); @@ -948,6 +966,8 @@ char fileName[FILENAME_MAX]; size_t subscript; struct stat statbuf; + char comm[32]; + long offset = 0; /*--------------------------------------------------------------------*/ /* Determine if the file can go into the spool directory */ @@ -1022,44 +1042,40 @@ return XFER_FILEDONE; /* Look for next file from master */ } /* if */ + if (xfer_stream != NULL) (void) fclose(xfer_stream); /* Safety */ + /*--------------------------------------------------------------------*/ /* The filename is transformed, try to open it */ /*--------------------------------------------------------------------*/ + strcpy(tempName, E_tempdir); + if (tempName[strlen(tempName)-1] != '/') + strcat(tempName, "/"); + if (spool) -#ifdef __TURBOC__ - { - char *p = tmpnam( tempName ); - denormalize( p ); - xfer_stream = fopen( p, "wb"); + strcat(tempName, spolName); + else { + strncat(tempName, rmtname, 8); + strcat(tempName,"/"); + if (spolName[1] == ':') + { + char * tmp; + if (tmp = strrchr(&spolName[2], '/')) + tmp++; + else + tmp = &spolName[2]; + strcat(tempName, tmp); + } + else + strcat(tempName, spolName); } -#else -/*--------------------------------------------------------------------*/ -/* MS C 6.0 doesn't generate the name for the current directory, */ -/* so we cheat and use our own temporary file name generation */ -/* routine. */ -/*--------------------------------------------------------------------*/ - - { - char *savetemp = E_tempdir; /* Save the real temp directory */ - - E_tempdir = E_spooldir; /* Generate this file in spool */ - mktempname(tempName, "tmp"); /* Get the file name */ - E_tempdir = savetemp; /* Restore true directory name */ - - denormalize( tempName ); - xfer_stream = fopen( tempName , "wb"); - - } -#endif + spool = KWTrue; /* receive into temporary "spool" anyway */ - else if (strchr( cmdopts,'d')) - xfer_stream = FOPEN( spolName, "w", IMAGE_MODE); - else { - denormalize( spolName ); - xfer_stream = fopen( spolName, "wb"); - } + if (resend) + xfer_stream = FOPEN( tempName, "a", IMAGE_MODE ); + else + xfer_stream = FOPEN( tempName, "w", IMAGE_MODE ); if (xfer_stream == NULL) { @@ -1100,7 +1116,18 @@ if (spool) printmsg(2,"Using temp name %s",tempName); - if (!pktsendstr("SY")) + if (spool && resend) + { + fseek(xfer_stream, 0L, SEEK_END); + offset = ftell(xfer_stream); + sprintf(comm, "SY 0x%lx", offset); + if (offset > 0) + printmsg(4, "rrfile: restart %s at %ld", tempName, offset); + } else { + sprintf(comm, "SY"); + } + + if (!pktsendstr(comm)) { fclose(xfer_stream); xfer_stream = NULL;