version 1.9, 2001/12/25 02:39:06 |
version 1.18, 2005/03/28 09:20:38 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.8 2001/10/09 01:36:24 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.17 2005/03/24 23:40:50 takayama Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
#define MALLOC(x) GC_malloc((x)+4) |
#define MALLOC(x) GC_malloc((x)+4) |
#endif |
#endif |
|
|
char *ASIRLOADPATH[32]; |
char **ASIRLOADPATH; |
|
|
#if defined(VISUAL) |
#if defined(VISUAL) |
#define ENVDELIM ';' |
#define ENVDELIM ';' |
Line 90 char *ASIRLOADPATH[32]; |
|
Line 90 char *ASIRLOADPATH[32]; |
|
#endif |
#endif |
|
|
#ifndef ASIR_LIBDIR |
#ifndef ASIR_LIBDIR |
#define ASIR_LIBDIR "." |
#define ASIR_LIBDIR "/usr/local/lib/asir" |
#endif |
#endif |
|
#ifndef ASIR_CONTRIB_DIR |
|
#define ASIR_CONTRIB_DIR "/usr/local/lib/asir-contrib" |
|
#endif |
|
|
char *getenv(); |
char *getenv(); |
void Pget_rootdir(); |
void Pget_rootdir(); |
|
char *search_executable(char *name); |
|
|
extern char *asir_libdir; |
extern char *asir_libdir; |
|
extern char *asir_contrib_dir; |
extern char *asir_pager; |
extern char *asir_pager; |
extern int read_exec_file; |
extern int read_exec_file; |
extern int main_parser; |
extern int main_parser; |
extern JMP_BUF exec_env; |
extern JMP_BUF exec_env; |
|
|
|
char *search_executable(char *name) |
|
{ |
|
char *c,*s,*ret; |
|
int len,nlen; |
|
char dir[BUFSIZ],path[BUFSIZ]; |
|
struct stat buf; |
|
|
|
nlen = strlen(name); |
|
for ( s = (char *)getenv("PATH"); s; ) { |
|
c = (char *)index(s,':'); |
|
len = c ? c-s : strlen(s); |
|
if ( len >= BUFSIZ ) continue; |
|
strncpy(dir,s,len); dir[len] = 0; |
|
if ( c ) s = c+1; |
|
else s = 0; |
|
if ( len+nlen+1 >= BUFSIZ ) continue; |
|
sprintf(path,"%s/%s",dir,name); |
|
if ( !stat(path,&buf) && !(buf.st_mode & S_IFDIR) |
|
#if !defined(VISUAL) |
|
&& !access(path,X_OK) |
|
#endif |
|
) { |
|
len = strlen(path)+1; |
|
ret = (char *)MALLOC(len); |
|
strcpy(ret,path); |
|
return ret; |
|
} |
|
} |
|
return 0; |
|
} |
|
|
void env_init() { |
void env_init() { |
char *e,*p,*q; |
char *e,*p,*q; |
int i,l; |
int i,l,japanese; |
char *getenv(); |
char *getenv(); |
char *oxhome; |
char *oxhome; |
char rootname[BUFSIZ]; |
char rootname[BUFSIZ]; |
Line 124 void env_init() { |
|
Line 160 void env_init() { |
|
#endif |
#endif |
} |
} |
} |
} |
|
|
|
if ( !(asir_contrib_dir = getenv("ASIR_CONTRIB_DIR")) ) { |
|
if ( oxhome = getenv("OpenXM_HOME") ) { |
|
asir_contrib_dir = (char *)malloc(strlen(oxhome)+strlen("/lib/asir-contrib")+1); |
|
sprintf(asir_contrib_dir,"%s/lib/asir-contrib",oxhome); |
|
} else { |
|
#if defined(VISUAL) |
|
get_rootdir(rootname,sizeof(rootname)); |
|
asir_contrib_dir = (char *)malloc(strlen(rootname)+strlen("/lib-asir-contrib")+1); |
|
sprintf(asir_contrib_dir,"%s/lib-asir-contrib",rootname); |
|
#else |
|
asir_contrib_dir = (char *)malloc(strlen(ASIR_CONTRIB_DIR)+1); |
|
strcpy(asir_contrib_dir,ASIR_CONTRIB_DIR); |
|
#endif |
|
} |
|
} |
|
|
if ( !(asir_pager = getenv("PAGER")) ) { |
if ( !(asir_pager = getenv("PAGER")) ) { |
asir_pager = (char *)malloc(strlen(MORE)+1); |
japanese = 0; |
strcpy(asir_pager,MORE); |
if ( (e = getenv("LANGUAGE")) && |
|
(!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1; |
|
else if ( (e = getenv("LC_ALL")) && |
|
(!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1; |
|
else if ( (e = getenv("LC_CTYPE")) && |
|
(!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1; |
|
else if ( (e = getenv("LANG")) && |
|
(!strncmp(e,"japan",5) || !strncmp(e,"ja_JP",5)) ) japanese = 1; |
|
if ( japanese ) |
|
asir_pager = search_executable("jless"); |
|
if ( !asir_pager ) { |
|
/* default: more */ |
|
asir_pager = (char *)malloc(strlen(MORE)+1); |
|
strcpy(asir_pager,MORE); |
|
} |
} |
} |
if ( e = getenv("ASIRLOADPATH" ) ) |
if ( e = getenv("ASIRLOADPATH" ) ) { |
for ( i = 0; ; i++, e = p+1 ) { |
for ( i = 0; ; i++, e = p+1 ) { |
p = (char *)index(e,ENVDELIM); |
p = (char *)index(e,ENVDELIM); |
|
if ( !p ) |
|
break; |
|
} |
|
i += 4; |
|
ASIRLOADPATH=(char **)MALLOC(sizeof(char *)*i); |
|
for ( l = 0; l<i; l++) ASIRLOADPATH[l] = NULL; |
|
e = getenv("ASIRLOADPATH"); |
|
for ( i = 0; ; i++, e = p+1 ) { |
|
p = (char *)index(e,ENVDELIM); |
l = p ? p-e : strlen(e); q = (char *)MALLOC(l+1); |
l = p ? p-e : strlen(e); q = (char *)MALLOC(l+1); |
if ( l ) { |
if ( l ) { |
strncpy(q,e,l); q[l] = 0; ASIRLOADPATH[i] = q; |
strncpy(q,e,l); q[l] = 0; ASIRLOADPATH[i] = q; |
Line 138 void env_init() { |
|
Line 214 void env_init() { |
|
if ( !p ) |
if ( !p ) |
break; |
break; |
} |
} |
|
}else{ |
|
ASIRLOADPATH=(char **)MALLOC(sizeof(char *)*3); |
|
ASIRLOADPATH[0] = NULL; |
|
} |
|
|
for ( i = 0; ASIRLOADPATH[i]; i++ ); |
for ( i = 0; ASIRLOADPATH[i]; i++ ); |
ASIRLOADPATH[i] = asir_libdir; |
if (asir_contrib_dir) ASIRLOADPATH[i++] = asir_contrib_dir; |
|
if (asir_libdir) ASIRLOADPATH[i++] = asir_libdir; |
|
ASIRLOADPATH[i] = NULL; |
} |
} |
|
|
void searchasirpath(char *name,char **pathp) |
void searchasirpath(char *name,char **pathp) |