version 1.22, 2012/12/17 07:20:45 |
version 1.30, 2016/03/31 07:33:32 |
|
|
* 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.21 2006/09/13 02:26:13 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/parse/load.c,v 1.29 2015/08/14 13:51:56 fujimoto Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) |
#include <string.h> |
#include <string.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
|
|
#include <unistd.h> |
#include <unistd.h> |
#endif |
#endif |
|
|
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) |
#include <io.h> |
#include <io.h> |
#endif |
#endif |
|
|
|
|
#endif |
#endif |
|
|
char **ASIRLOADPATH; |
char **ASIRLOADPATH; |
|
int ASIRLOADPATH_LEN; |
|
|
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) |
#define ENVDELIM ';' |
#define ENVDELIM ';' |
#define MORE "more < " |
#define MORE "more < " |
#else |
#else |
Line 102 char *search_executable(char *name); |
|
Line 103 char *search_executable(char *name); |
|
|
|
extern char *asir_libdir; |
extern char *asir_libdir; |
extern char *asir_contrib_dir; |
extern char *asir_contrib_dir; |
|
extern char *asir_private_dir; |
extern char *asir_pager; |
extern char *asir_pager; |
extern int main_parser; |
extern int main_parser; |
extern JMP_BUF exec_env; |
extern JMP_BUF exec_env; |
Line 124 char *search_executable(char *name) |
|
Line 126 char *search_executable(char *name) |
|
if ( len+nlen+1 >= BUFSIZ ) continue; |
if ( len+nlen+1 >= BUFSIZ ) continue; |
sprintf(path,"%s/%s",dir,name); |
sprintf(path,"%s/%s",dir,name); |
if ( !stat(path,&buf) && !(buf.st_mode & S_IFDIR) |
if ( !stat(path,&buf) && !(buf.st_mode & S_IFDIR) |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
&& !access(path,X_OK) |
&& !access(path,X_OK) |
#endif |
#endif |
) { |
) { |
Line 143 void env_init() { |
|
Line 145 void env_init() { |
|
char *getenv(); |
char *getenv(); |
char *oxhome; |
char *oxhome; |
char rootname[BUFSIZ]; |
char rootname[BUFSIZ]; |
|
size_t len; |
|
|
|
if ( oxhome = getenv("OpenXM_HOME") ) { |
|
len = strlen(oxhome); |
|
}else { |
|
#if defined(VISUAL) || defined(__MINGW32__) |
|
get_rootdir(rootname,sizeof(rootname)); |
|
len = strlen(rootname); |
|
oxhome = rootname; |
|
#endif |
|
} |
|
|
if ( !(asir_libdir = getenv("ASIR_LIBDIR")) ) { |
if ( !(asir_libdir = getenv("ASIR_LIBDIR")) ) { |
if ( oxhome = getenv("OpenXM_HOME") ) { |
if ( oxhome ) { |
asir_libdir = (char *)malloc(strlen(oxhome)+strlen("/lib/asir")+1); |
asir_libdir = (char *)malloc(len+strlen("/lib/asir")+1); |
sprintf(asir_libdir,"%s/lib/asir",oxhome); |
sprintf(asir_libdir,"%s/lib/asir",oxhome); |
} else { |
} else { |
#if defined(VISUAL) |
|
get_rootdir(rootname,sizeof(rootname)); |
|
asir_libdir = (char *)malloc(strlen(rootname)+strlen("/lib")+1); |
|
sprintf(asir_libdir,"%s/lib",rootname); |
|
#else |
|
asir_libdir = (char *)malloc(strlen(ASIR_LIBDIR)+1); |
asir_libdir = (char *)malloc(strlen(ASIR_LIBDIR)+1); |
strcpy(asir_libdir,ASIR_LIBDIR); |
strcpy(asir_libdir,ASIR_LIBDIR); |
#endif |
|
} |
} |
} |
} |
|
|
if ( !(asir_contrib_dir = getenv("ASIR_CONTRIB_DIR")) ) { |
if ( !(asir_contrib_dir = getenv("ASIR_CONTRIB_DIR")) ) { |
if ( oxhome = getenv("OpenXM_HOME") ) { |
if ( oxhome ) { |
asir_contrib_dir = (char *)malloc(strlen(oxhome)+strlen("/lib/asir-contrib")+1); |
asir_contrib_dir = (char *)malloc(len+strlen("/lib/asir-contrib")+1); |
sprintf(asir_contrib_dir,"%s/lib/asir-contrib",oxhome); |
sprintf(asir_contrib_dir,"%s/lib/asir-contrib",oxhome); |
} else { |
} 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); |
asir_contrib_dir = (char *)malloc(strlen(ASIR_CONTRIB_DIR)+1); |
strcpy(asir_contrib_dir,ASIR_CONTRIB_DIR); |
strcpy(asir_contrib_dir,ASIR_CONTRIB_DIR); |
#endif |
|
} |
} |
} |
} |
|
|
|
asir_private_dir = NULL; |
|
#if defined(VISUAL) || defined(__MINGW32__) |
|
if ( e = getenv("APPDATA") ) { |
|
asir_private_dir = (char *)malloc(strlen(e)+strlen("/OpenXM/lib/asir-contrib")+1); |
|
sprintf(asir_private_dir,"%s/OpenXM/lib/asir-contrib",e); |
|
} |
|
#endif |
|
|
if ( !(asir_pager = getenv("PAGER")) ) { |
if ( !(asir_pager = getenv("PAGER")) ) { |
japanese = 0; |
japanese = 0; |
if ( (e = getenv("LANGUAGE")) && |
if ( (e = getenv("LANGUAGE")) && |
Line 200 void env_init() { |
|
Line 209 void env_init() { |
|
if ( !p ) |
if ( !p ) |
break; |
break; |
} |
} |
i += 4; |
i += 5; |
|
ASIRLOADPATH_LEN=i; |
ASIRLOADPATH=(char **)MALLOC(sizeof(char *)*i); |
ASIRLOADPATH=(char **)MALLOC(sizeof(char *)*i); |
for ( l = 0; l<i; l++) ASIRLOADPATH[l] = NULL; |
for ( l = 0; l<i; l++) ASIRLOADPATH[l] = NULL; |
e = getenv("ASIRLOADPATH"); |
e = getenv("ASIRLOADPATH"); |
Line 219 void env_init() { |
|
Line 229 void env_init() { |
|
} |
} |
|
|
for ( i = 0; ASIRLOADPATH[i]; i++ ); |
for ( i = 0; ASIRLOADPATH[i]; i++ ); |
|
if (asir_private_dir) ASIRLOADPATH[i++] = asir_private_dir; |
if (asir_contrib_dir) ASIRLOADPATH[i++] = asir_contrib_dir; |
if (asir_contrib_dir) ASIRLOADPATH[i++] = asir_contrib_dir; |
if (asir_libdir) ASIRLOADPATH[i++] = asir_libdir; |
if (asir_libdir) ASIRLOADPATH[i++] = asir_libdir; |
|
ASIRLOADPATH[i++] = "."; |
ASIRLOADPATH[i] = NULL; |
ASIRLOADPATH[i] = NULL; |
} |
} |
|
|
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) |
#define R_OK 4 |
#define R_OK 4 |
#endif |
#endif |
|
|
Line 232 void searchasirpath(char *name,char **pathp) |
|
Line 244 void searchasirpath(char *name,char **pathp) |
|
{ |
{ |
char **p; |
char **p; |
char *q; |
char *q; |
int l,ret; |
size_t l; |
|
int ret; |
struct stat sbuf; |
struct stat sbuf; |
|
|
if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':') |
if ( (name[0] == '/') || ( name[0] == '.') || strchr(name,':') |
Line 268 void loadasirfile(char *name0) |
|
Line 281 void loadasirfile(char *name0) |
|
FILE *in; |
FILE *in; |
INFILE t; |
INFILE t; |
extern char cppname[]; |
extern char cppname[]; |
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) |
char ibuf1[BUFSIZ],ibuf2[BUFSIZ]; |
char ibuf1[BUFSIZ],ibuf2[BUFSIZ]; |
int ac; |
int ac; |
char *av[BUFSIZ]; |
char *av[BUFSIZ]; |
Line 353 void loadasirfile(char *name0) |
|
Line 366 void loadasirfile(char *name0) |
|
#else |
#else |
char com[BUFSIZ]; |
char com[BUFSIZ]; |
|
|
sprintf(com,"%s -I%s %s",cppname,asir_libdir,name0); in = popen(com,"r"); |
sprintf(com,"%s -I%s -D__FILE__=%s %s",cppname,asir_libdir,name0,name0); in = popen(com,"r"); |
if ( !in ) { |
if ( !in ) { |
perror("popen"); |
perror("popen"); |
error("load : failed"); |
error("load : failed"); |