home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1209 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  3.6 KB

  1. From: floyd@starsend.UUCP (Floyd Miller)
  2. Newsgroups: alt.sources
  3. Subject: Small Patch for UUPC/UUIO Program
  4. Message-ID: <963@ixos.UUCP>
  5. Date: 19 Apr 90 11:49:29 GMT
  6.  
  7. The following is a small source-level patch for UUPC's UUIO program.
  8. This is my version of the importpath() function from local/host.c.
  9. I've compiled it with the rest of version 1.06 of UUPC.  I believe
  10. v1.07 still uses this same piece of code in the same way.  The comments,
  11. here, should be self-explanatory.  However, I've posted a description
  12. of what I've done (and why) to alt.sources.d and comp.binaries.ibm.pc.d.
  13.  
  14. P.S.  This seemed small enough not to hassle with building a sharchive.
  15.       Please accept my appologies ig you disagree.
  16.  
  17. /*** Replace function importpath in local/host.c with the following ***/
  18. /*
  19.    importpath - convert a canonical name to a format the host can handle
  20.  
  21.    This routine converts a file name between canonical form, which is
  22.    defined as a 'unix' style pathname, and the MS-DOS all uppercase
  23.    "xxxxxxxx.xxx" format.
  24.  
  25.    Modify the canonical file name as follows:
  26.    1 - skip any path from the canonical name
  27.    2 - if the name fits DOS convention copy it as is
  28.    3 - copy up to 8 character from the canonical name converting . to _
  29.        and uppercase to lowercase.
  30.    4 - if the name was longer than 8 character copy a . to the host name
  31.        and then copy the up to three characters from the tail of the
  32.        canonical name to the host name.
  33.    5 - To avoid overwriting UUCP control and data files (due to DOS being
  34.        case insensitive) imported names beginning with "d_", "c_", or "x_" 
  35.        and having extensions, .XYN (where N is a numeral), are modified in
  36.        the following way:
  37.  
  38.           if X is lower case replace N with N+16
  39.           if Y is lower case replace N with N+26
  40.           if both X & Y are lower case then
  41.              if N is less than 7 replace N with N+36
  42.              otherwise replace N with N-20 (yielding '#', '$' or '%').
  43. */
  44.  
  45. #define min(x,y) (((x) < (y)) ? (x) : (y))
  46.  
  47. void
  48. importpath(host, canon)
  49. char *host, *canon;
  50. {
  51.     char *s, *s2, *out, c;
  52.     int i, j, len;
  53.  
  54.     out = host;
  55.  
  56.     /* get a pointer to the last component of the path */
  57.     if ((s = strrchr(canon, '/')) == (char *)NULL)
  58.     s = canon;
  59.     else
  60.     ++s;
  61.  
  62.     /* Check if name already meets DOS convention */
  63.     for (s2 = s; *s2 != '.' && *s2 != '\0'; ++s2) ;  /* find dot or end */
  64.     if (s2 - s < 9 &&          /* up to 8 chars before end or dot and ... */
  65.        (*s2 == '\0' ||           /* no more chars or ... */
  66.          (strlen(s2+1) <= 3 &&      /* up to 3 chars after the dot and ... */
  67.           strrchr(s2, '.') == s2))) /* there isn't another dot */
  68.     {
  69.     strcpy(host, s);
  70.     return;
  71.     }
  72.  
  73.     j = min(len = strlen(s), 8);
  74.  
  75.     for (i = 0; i < j; ++i)
  76.     {
  77.     c = *s++;
  78.     *out++ = (c == '.') ? '_' : tolower(c);
  79.     }
  80.     *out = '\0';
  81.  
  82.     for (s2 = s; *s2 != '\0'; ++s2) ;
  83.  
  84.     if (len > 8)
  85.     for (i = 0; i < 3 && s2 > s; ++i)
  86.         if (*--s2 == '.')
  87.         {
  88.         ++s2;
  89.         break;
  90.         }
  91.     if (*s2 != '\0')
  92.     {
  93.     (void)strcpy(out, ".");
  94.     (void)strcpy(++out, s2);
  95.     /* Fix up uucp control or data seqenced file names */
  96.     if (*(host + 1) == '_' &&
  97.         (*host == 'x' || *host == 'd' || *host == 'c') &&
  98.         strlen(out) == 3 && isdigit(out[2]))
  99.     {
  100.         i = 0;
  101.         if (islower(*out)) i = 16;
  102.         if (islower(*(out + 1))) i = i == 0 ? 26 : 36;
  103.         if (i > 0)
  104.         {
  105.         *(out + 2) += i;
  106.         if (*(out + 2) > 'Z') *(out + 2) -= 56; 
  107.         }
  108.     }
  109.     }
  110. } /*importpath*/
  111.  
  112. *******   *****************************************
  113. *****  ************************* Floyd Miller
  114. ***  *************** floyd@starsend.UUCP
  115. *  ********* floyd%starsend@PRC.Unisys.com
  116.   *** starsend!floyd@burdvax.PRC.Unisys.com
  117. *
  118.