version 1.3, 2001/11/19 19:02:14 |
version 1.4, 2003/03/13 09:09:32 |
|
|
char *filename; |
char *filename; |
{ |
{ |
char *pathname; |
char *pathname; |
int f; |
int f, len; |
|
|
if (dirname == NULL || *dirname == '\0') |
if (dirname == NULL || *dirname == '\0') |
return (NULL); |
return (NULL); |
/* |
/* |
* Construct the full pathname. |
* Construct the full pathname. |
*/ |
*/ |
pathname = (char *) calloc(strlen(dirname) + strlen(filename) + 2, |
len = strlen(dirname) + strlen(filename) + 2; |
sizeof(char)); |
pathname = (char *) calloc(len, sizeof(char)); |
if (pathname == NULL) |
if (pathname == NULL) |
return (NULL); |
return (NULL); |
#if MSOFTC || OS2 |
#if MSOFTC || OS2 |
sprintf(pathname, "%s\\%s", dirname, filename); |
sprintf(pathname, "%s\\%s", dirname, filename); |
#else |
#else |
sprintf(pathname, "%s/%s", dirname, filename); |
snprintf(pathname, len, "%s/%s", dirname, filename); |
#endif |
#endif |
/* |
/* |
* Make sure the file exists. |
* Make sure the file exists. |
|
|
sprintf(fpat, "%s*", s); |
sprintf(fpat, "%s*", s); |
#else |
#else |
fpat = (char *) ecalloc(strlen(s)+2, sizeof(char)); |
fpat = (char *) ecalloc(strlen(s)+2, sizeof(char)); |
sprintf(fpat, "%s*", s); |
snprintf(fpat, strlen(s)+2, "%s*", s); |
#endif |
#endif |
s = glob(fpat); |
s = glob(fpat); |
if (strcmp(s,fpat) == 0) |
if (strcmp(s,fpat) == 0) |
|
|
(s1 == NULL ? 0 : strlen(s1)) + |
(s1 == NULL ? 0 : strlen(s1)) + |
(s2 == NULL ? 0 : strlen(s2)) + 1; |
(s2 == NULL ? 0 : strlen(s2)) + 1; |
scmd = (char *) ecalloc(len, sizeof(char)); |
scmd = (char *) ecalloc(len, sizeof(char)); |
sprintf(scmd, cmd, s1, s2); |
snprintf(scmd, len, cmd, s1, s2); |
#if HAVE_SHELL |
#if HAVE_SHELL |
shell = getenv("SHELL"); |
shell = getenv("SHELL"); |
if (shell != NULL && *shell != '\0') |
if (shell != NULL && *shell != '\0') |
|
|
/* |
/* |
* Read the output of <$SHELL -c "cmd">. |
* Read the output of <$SHELL -c "cmd">. |
*/ |
*/ |
scmd2 = (char *) ecalloc(strlen(shell) + strlen(scmd) + 7, |
len = strlen(shell) + strlen(scmd) + 7; |
sizeof(char)); |
scmd2 = (char *) ecalloc(len, sizeof(char)); |
sprintf(scmd2, "%s -c \"%s\"", shell, scmd); |
snprintf(scmd2, len, "%s -c \"%s\"", shell, scmd); |
free(scmd); |
free(scmd); |
scmd = scmd2; |
scmd = scmd2; |
} |
} |