version 1.4, 1996/08/11 00:17:31 |
version 1.5, 1997/07/08 18:32:27 |
|
|
if (env) { |
if (env) { |
direc = strtok(env, separator); |
direc = strtok(env, separator); |
while (direc) { |
while (direc) { |
strcpy(filename, ""); |
snprintf(filename, sizeof(filename), |
strncat(filename, direc, 999); |
"%s/%s", direc, UNITSFILE); |
strncat(filename, "/", |
|
999 - strlen(filename)); |
|
strncat(filename, UNITSFILE, |
|
999 - strlen(filename)); |
|
unitfile = fopen(filename, "rt"); |
unitfile = fopen(filename, "rt"); |
if (unitfile) |
if (unitfile) |
break; |
break; |
|
|
|
|
if (unit[strlen(unit) - 1] == '^') { |
if (unit[strlen(unit) - 1] == '^') { |
copy = dupstr(unit); |
copy = dupstr(unit); |
copy[strlen(copy) - 1] = 0; |
copy[strlen(copy) - 1] = '\0'; |
for (i = 0; i < unitcount; i++) { |
for (i = 0; i < unitcount; i++) { |
if (!strcmp(unittable[i].uname, copy)) { |
if (!strcmp(unittable[i].uname, copy)) { |
strcpy(buffer, copy); |
strncpy(buffer, copy, sizeof(buffer) - 1); |
|
buffer[sizeof(buffer) - 1] = '\0'; |
free(copy); |
free(copy); |
return buffer; |
return buffer; |
} |
} |
|
|
copy[strlen(copy) - 1] = 0; |
copy[strlen(copy) - 1] = 0; |
for (i = 0; i < unitcount; i++) { |
for (i = 0; i < unitcount; i++) { |
if (!strcmp(unittable[i].uname, copy)) { |
if (!strcmp(unittable[i].uname, copy)) { |
strcpy(buffer, copy); |
strncpy(buffer, copy, sizeof(buffer) - 1); |
|
buffer[sizeof(buffer) - 1] = '\0'; |
free(copy); |
free(copy); |
return buffer; |
return buffer; |
} |
} |
|
|
copy[strlen(copy) - 1] = 0; |
copy[strlen(copy) - 1] = 0; |
for (i = 0; i < unitcount; i++) { |
for (i = 0; i < unitcount; i++) { |
if (!strcmp(unittable[i].uname, copy)) { |
if (!strcmp(unittable[i].uname, copy)) { |
strcpy(buffer, copy); |
strncpy(buffer, copy, sizeof(buffer) - 1); |
|
buffer[sizeof(buffer) - 1] = '\0'; |
free(copy); |
free(copy); |
return buffer; |
return buffer; |
} |
} |
|
|
strlen(prefixtable[i].prefixname))) { |
strlen(prefixtable[i].prefixname))) { |
unit += strlen(prefixtable[i].prefixname); |
unit += strlen(prefixtable[i].prefixname); |
if (!strlen(unit) || lookupunit(unit)) { |
if (!strlen(unit) || lookupunit(unit)) { |
strcpy(buffer, prefixtable[i].prefixval); |
snprintf(buffer, sizeof(buffer), |
strcat(buffer, " "); |
"%s %s", prefixtable[i].prefixval, unit); |
strcat(buffer, unit); |
|
return buffer; |
return buffer; |
} |
} |
} |
} |
|
|
readunits(userfile); |
readunits(userfile); |
|
|
if (optind == argc - 2) { |
if (optind == argc - 2) { |
strcpy(havestr, argv[optind]); |
strncpy(havestr, argv[optind], sizeof(havestr) - 1); |
strcpy(wantstr, argv[optind + 1]); |
havestr[sizeof(havestr) - 1] = '\0'; |
|
strncpy(wantstr, argv[optind + 1], sizeof(wantstr) - 1); |
|
wantstr[sizeof(wantstr) - 1] = '\0'; |
initializeunit(&have); |
initializeunit(&have); |
addunit(&have, havestr, 0); |
addunit(&have, havestr, 0); |
completereduce(&have); |
completereduce(&have); |