9#include "singular_resourcesconfig.h"
12#if defined(HAVE_UNISTD_H) && defined(STDC_HEADERS)
24#define MAXPATHLEN 1024
28#define ABSOLUTE_FILENAME_P(fname) (fname[0] == '/')
36static char * omFindExec_link (
const char *
name,
char* executable)
43 if (ABSOLUTE_FILENAME_P(
name))
46 if (! access (
name, F_OK))
49 strcpy(executable,
name);
55 if (((
name[0] ==
'.') && (
name[1] ==
'/')) ||
56 ((
name[0] ==
'.') && (
name[1] ==
'.') && (
name[2] ==
'/')) ||
65 if (getwd (tbuf)==
NULL) ok=0;
70 if (ok && ! access(tbuf, F_OK))
72 strcpy(executable, tbuf);
92 while (*
p && *
p !=
':')
96 if ((tbuf[0] ==
'.' && tbuf[1] ==
'\0') || tbuf[0] ==
'\0') {
106 if (tbuf[strlen(tbuf)-1] !=
'/') strcat(tbuf,
"/");
110 if (! access (tbuf, F_OK))
112 strcpy(executable, tbuf);
130 if ((
p !=
NULL)&&(strlen(
p)>1))
140 while (*
p && *
p !=
':')
144 if (tbuf[strlen(tbuf)-1] !=
'/') strcat(tbuf,
"/");
148 if (! access (tbuf, F_OK))
150 strcpy(executable, tbuf);
166 strcpy(tbuf,BIN_DIR);
170 if (! access (tbuf, F_OK))
172 strcpy(executable, tbuf);
175 strcpy(tbuf,LIB_DIR);
179 if (! access (tbuf, F_OK))
181 strcpy(executable, tbuf);
184 strcpy(tbuf,LIB_DIR);
185 strcat(tbuf,
"/../share/singular/LIB/standard.lib");
186 if (! access (tbuf, R_OK))
194static int my_readlink(
const char*
name,
char*
buf,
size_t bufsize)
199 if ((ret = readlink(
name,
buf2, bufsize)) > 0)
224#define MAX_LINK_LEVEL 10
228static int full_readlink(
const char*
name,
char*
buf,
size_t bufsize)
232 if ((ret=my_readlink(
name,
buf, bufsize)) > 0)
252 while (
i<MAX_LINK_LEVEL);
259char * _omFindExec (
const char *
name,
char* exec);
269 ret = _omFindExec(
buf, exec);
270 if (ret !=
NULL)
return ret;
272 return _omFindExec(
name, exec);
275#define _omFindExec omFindExec
278char * _omFindExec (
const char *
name,
char* exec)
280 char * link = omFindExec_link(
name, exec);
287 link = omFindExec_link(
buf, exec);
291 char *
p = strrchr(link,
'/');
int search(const CFArray &A, const CanonicalForm &F, int i, int j)
search for F in A between index i and j
char * omFindExec(const char *name, char *exec)
int status int void * buf
int name
New type name for int.