diff options
Diffstat (limited to 'v4.0/src/CMD/FC/UPDATE.C')
| -rw-r--r-- | v4.0/src/CMD/FC/UPDATE.C | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/v4.0/src/CMD/FC/UPDATE.C b/v4.0/src/CMD/FC/UPDATE.C new file mode 100644 index 0000000..8263db1 --- /dev/null +++ b/v4.0/src/CMD/FC/UPDATE.C | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | /* | ||
| 2 | * update takes a def string and update and fills the | ||
| 3 | * update with missing defs the update allowing | ||
| 4 | * specification of missing parameters. | ||
| 5 | * the parts are: ^{[~:]#:}{%#</|\>}{[~.]#}{.[~./\:]}$ | ||
| 6 | * maximum size of MAXPATHLEN (80) bytes | ||
| 7 | * | ||
| 8 | * 4/14/86 dl use U_ flags | ||
| 9 | * | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include "tools.h" | ||
| 13 | |||
| 14 | int upd (def, update, dst) | ||
| 15 | char *def, *update, *dst; | ||
| 16 | { | ||
| 17 | char *p, buf[MAXPATHLEN]; | ||
| 18 | int f; | ||
| 19 | |||
| 20 | f = 0; | ||
| 21 | p = buf; | ||
| 22 | #if MSDOS | ||
| 23 | if (drive(update, p) || drive (def, p)) | ||
| 24 | SETFLAG(f, U_DRIVE); | ||
| 25 | p += strlen (p); | ||
| 26 | #endif | ||
| 27 | |||
| 28 | if (path(update, p) || path (def, p)) | ||
| 29 | SETFLAG(f, U_PATH); | ||
| 30 | p += strlen (p); | ||
| 31 | |||
| 32 | if (filename(update, p) || filename (def, p)) | ||
| 33 | SETFLAG(f, U_NAME); | ||
| 34 | p += strlen (p); | ||
| 35 | |||
| 36 | if (extention(update, p) || extention (def, p)) | ||
| 37 | SETFLAG(f, U_EXT); | ||
| 38 | |||
| 39 | strcpy (dst, buf); | ||
| 40 | |||
| 41 | return f; | ||
| 42 | } | ||
| 43 | |||
| 44 | #if MSDOS | ||
| 45 | /* copy a drive from source to dest if present, return TRUE if we found one */ | ||
| 46 | drive (src, dst) | ||
| 47 | char *src, *dst; | ||
| 48 | { | ||
| 49 | register char *p; | ||
| 50 | |||
| 51 | p = strbscan (src, ":"); | ||
| 52 | if (*p++ == NULL) | ||
| 53 | p = src; | ||
| 54 | strcpy (dst, src); | ||
| 55 | dst[p-src] = 0; | ||
| 56 | return strlen (dst) != 0; | ||
| 57 | } | ||
| 58 | #endif | ||
| 59 | |||
| 60 | /* copy an extention from source to dest if present. include the period. | ||
| 61 | Return TRUE if one found. | ||
| 62 | */ | ||
| 63 | extention (src, dst) | ||
| 64 | char *src, *dst; | ||
| 65 | { | ||
| 66 | register char *p, *p1; | ||
| 67 | |||
| 68 | p = src - 1; | ||
| 69 | while (*(p=strbscan(1+(p1=p), ".")) != NULL) | ||
| 70 | ; | ||
| 71 | /* p1 points to last . or begin of string p points to eos */ | ||
| 72 | if (*strbscan (p1, "\\/:") != NULL || *p1 != '.') | ||
| 73 | p1 = p; | ||
| 74 | strcpy (dst, p1); | ||
| 75 | return strlen (dst) != 0; | ||
| 76 | } | ||
| 77 | |||
| 78 | /* copy a filename part from source to dest if present. return true if one | ||
| 79 | is found | ||
| 80 | */ | ||
| 81 | filename (src, dst) | ||
| 82 | char *src, *dst; | ||
| 83 | { | ||
| 84 | register char *p, *p1; | ||
| 85 | |||
| 86 | p = src-1; | ||
| 87 | while (*(p=strbscan (p1=p+1, "\\/:")) != NULL) | ||
| 88 | ; | ||
| 89 | /* p1 points after last / or at bos */ | ||
| 90 | p = strbscan (p1, "."); | ||
| 91 | strcpy (dst, p1); | ||
| 92 | dst[p-p1] = 0; | ||
| 93 | return strlen (dst) != 0; | ||
| 94 | } | ||
| 95 | |||
| 96 | /* copy a filename.ext part from source to dest if present. return true if one | ||
| 97 | is found | ||
| 98 | */ | ||
| 99 | fileext (src, dst) | ||
| 100 | char *src, *dst; | ||
| 101 | { | ||
| 102 | *dst = '\0'; | ||
| 103 | if ( filename (src, dst) ) { | ||
| 104 | dst += strlen (dst); | ||
| 105 | extention (src, dst); | ||
| 106 | return TRUE; | ||
| 107 | } | ||
| 108 | return FALSE; | ||
| 109 | } | ||
| 110 | |||
| 111 | /* copy the paths part of the file description. return true if found | ||
| 112 | */ | ||
| 113 | path (src, dst) | ||
| 114 | char *src, *dst; | ||
| 115 | { | ||
| 116 | register char *p, *p1; | ||
| 117 | |||
| 118 | if (*(p=strbscan (src, ":")) != NULL) | ||
| 119 | src = p+1; | ||
| 120 | p = src-1; | ||
| 121 | /* p points to beginning of possible path (after potential drive spec) */ | ||
| 122 | while (*(p=strbscan (p1=p+1, "\\/:")) != NULL) | ||
| 123 | ; | ||
| 124 | /* p1 points after final / or bos */; | ||
| 125 | strcpy (dst, src); | ||
| 126 | dst[p1-src] = 0; | ||
| 127 | return strlen (dst) != 0; | ||
| 128 | } | ||