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] ==
'/')) ||
69 if (! access(tbuf, F_OK))
71 strcpy(executable, tbuf);
91 while (*
p && *
p !=
':')
95 if ((tbuf[0] ==
'.' && tbuf[1] ==
'\0') || tbuf[0] ==
'\0') {
105 if (tbuf[strlen(tbuf)-1] !=
'/') strcat(tbuf,
"/");
109 if (! access (tbuf, F_OK))
111 strcpy(executable, tbuf);
129 if ((
p !=
NULL)&&(strlen(
p)>1))
139 while (*
p && *
p !=
':')
143 if (tbuf[strlen(tbuf)-1] !=
'/') strcat(tbuf,
"/");
147 if (! access (tbuf, F_OK))
149 strcpy(executable, tbuf);
165 strcpy(tbuf,BIN_DIR);
169 if (! access (tbuf, F_OK))
171 strcpy(executable, tbuf);
174 strcpy(tbuf,LIB_DIR);
178 if (! access (tbuf, F_OK))
180 strcpy(executable, tbuf);
183 strcpy(tbuf,LIB_DIR);
184 strcat(tbuf,
"/../share/singular/LIB/standard.lib");
185 if (! access (tbuf, R_OK))
193static int my_readlink(
const char*
name,
char*
buf,
size_t bufsize)
198 if ((ret = readlink(
name,
buf2, bufsize)) > 0)
223#define MAX_LINK_LEVEL 10
227static int full_readlink(
const char*
name,
char*
buf,
size_t bufsize)
231 if ((ret=my_readlink(
name,
buf, bufsize)) > 0)
251 while (
i<MAX_LINK_LEVEL);
258char * _omFindExec (
const char *
name,
char* exec);
268 ret = _omFindExec(
buf, exec);
269 if (ret !=
NULL)
return ret;
271 return _omFindExec(
name, exec);
274#define _omFindExec omFindExec
277char * _omFindExec (
const char *
name,
char* exec)
279 char * link = omFindExec_link(
name, exec);
286 link = omFindExec_link(
buf, exec);
290 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
char name(const Variable &v)