home *** CD-ROM | disk | FTP | other *** search
- From: floyd@starsend.UUCP (Floyd Miller)
- Newsgroups: alt.sources
- Subject: Small Patch for UUPC/UUIO Program
- Message-ID: <963@ixos.UUCP>
- Date: 19 Apr 90 11:49:29 GMT
-
- The following is a small source-level patch for UUPC's UUIO program.
- This is my version of the importpath() function from local/host.c.
- I've compiled it with the rest of version 1.06 of UUPC. I believe
- v1.07 still uses this same piece of code in the same way. The comments,
- here, should be self-explanatory. However, I've posted a description
- of what I've done (and why) to alt.sources.d and comp.binaries.ibm.pc.d.
-
- P.S. This seemed small enough not to hassle with building a sharchive.
- Please accept my appologies ig you disagree.
-
- /*** Replace function importpath in local/host.c with the following ***/
- /*
- importpath - convert a canonical name to a format the host can handle
-
- This routine converts a file name between canonical form, which is
- defined as a 'unix' style pathname, and the MS-DOS all uppercase
- "xxxxxxxx.xxx" format.
-
- Modify the canonical file name as follows:
- 1 - skip any path from the canonical name
- 2 - if the name fits DOS convention copy it as is
- 3 - copy up to 8 character from the canonical name converting . to _
- and uppercase to lowercase.
- 4 - if the name was longer than 8 character copy a . to the host name
- and then copy the up to three characters from the tail of the
- canonical name to the host name.
- 5 - To avoid overwriting UUCP control and data files (due to DOS being
- case insensitive) imported names beginning with "d_", "c_", or "x_"
- and having extensions, .XYN (where N is a numeral), are modified in
- the following way:
-
- if X is lower case replace N with N+16
- if Y is lower case replace N with N+26
- if both X & Y are lower case then
- if N is less than 7 replace N with N+36
- otherwise replace N with N-20 (yielding '#', '$' or '%').
- */
-
- #define min(x,y) (((x) < (y)) ? (x) : (y))
-
- void
- importpath(host, canon)
- char *host, *canon;
- {
- char *s, *s2, *out, c;
- int i, j, len;
-
- out = host;
-
- /* get a pointer to the last component of the path */
- if ((s = strrchr(canon, '/')) == (char *)NULL)
- s = canon;
- else
- ++s;
-
- /* Check if name already meets DOS convention */
- for (s2 = s; *s2 != '.' && *s2 != '\0'; ++s2) ; /* find dot or end */
- if (s2 - s < 9 && /* up to 8 chars before end or dot and ... */
- (*s2 == '\0' || /* no more chars or ... */
- (strlen(s2+1) <= 3 && /* up to 3 chars after the dot and ... */
- strrchr(s2, '.') == s2))) /* there isn't another dot */
- {
- strcpy(host, s);
- return;
- }
-
- j = min(len = strlen(s), 8);
-
- for (i = 0; i < j; ++i)
- {
- c = *s++;
- *out++ = (c == '.') ? '_' : tolower(c);
- }
- *out = '\0';
-
- for (s2 = s; *s2 != '\0'; ++s2) ;
-
- if (len > 8)
- for (i = 0; i < 3 && s2 > s; ++i)
- if (*--s2 == '.')
- {
- ++s2;
- break;
- }
- if (*s2 != '\0')
- {
- (void)strcpy(out, ".");
- (void)strcpy(++out, s2);
- /* Fix up uucp control or data seqenced file names */
- if (*(host + 1) == '_' &&
- (*host == 'x' || *host == 'd' || *host == 'c') &&
- strlen(out) == 3 && isdigit(out[2]))
- {
- i = 0;
- if (islower(*out)) i = 16;
- if (islower(*(out + 1))) i = i == 0 ? 26 : 36;
- if (i > 0)
- {
- *(out + 2) += i;
- if (*(out + 2) > 'Z') *(out + 2) -= 56;
- }
- }
- }
- } /*importpath*/
-
- ******* *****************************************
- ***** ************************* Floyd Miller
- *** *************** floyd@starsend.UUCP
- * ********* floyd%starsend@PRC.Unisys.com
- *** starsend!floyd@burdvax.PRC.Unisys.com
- *
-