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') {
102 if (getwd (tbuf) ==
NULL)
103 goto next_path_entry;
108 if (tbuf[strlen(tbuf)-1] !=
'/') strcat(tbuf,
"/");
112 if (! access (tbuf, F_OK))
114 strcpy(executable, tbuf);
133 if ((
p !=
NULL)&&(strlen(
p)>1))
143 while (*
p && *
p !=
':')
147 if (tbuf[strlen(tbuf)-1] !=
'/') strcat(tbuf,
"/");
151 if (! access (tbuf, F_OK))
153 strcpy(executable, tbuf);
169 strcpy(tbuf,BIN_DIR);
173 if (! access (tbuf, F_OK))
175 strcpy(executable, tbuf);
178 strcpy(tbuf,LIB_DIR);
182 if (! access (tbuf, F_OK))
184 strcpy(executable, tbuf);
187 strcpy(tbuf,LIB_DIR);
188 strcat(tbuf,
"/../share/singular/LIB/standard.lib");
189 if (! access (tbuf, R_OK))
197static int my_readlink(
const char*
name,
char*
buf,
size_t bufsize)
202 if ((ret = readlink(
name,
buf2, bufsize)) > 0)
227#define MAX_LINK_LEVEL 10
231static int full_readlink(
const char*
name,
char*
buf,
size_t bufsize)
235 if ((ret=my_readlink(
name,
buf, bufsize)) > 0)
255 while (
i<MAX_LINK_LEVEL);
262char * _omFindExec (
const char *
name,
char* exec);
272 ret = _omFindExec(
buf, exec);
273 if (ret !=
NULL)
return ret;
275 return _omFindExec(
name, exec);
278#define _omFindExec omFindExec
281char * _omFindExec (
const char *
name,
char* exec)
283 char * link = omFindExec_link(
name, exec);
290 link = omFindExec_link(
buf, exec);
294 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.