int main(int argc, char* argv[]) { void* callbacks[] = {Joutput,0,Jinput,0,(void*)SMCON}; int type; jepath(argv[0]); // get path to JFE folder jt=jeload(callbacks); if(!jt){char m[1000]; jefail(m), fputs(m,stdout); exit(1);} adadbreak=(char**)jt; // first address in jt is address of breakdata signal(SIGINT,sigint); #ifdef READLINE char* rl_readline_name="jconsole"; /* argv[0] varies too much*/ #endif if(argc==2&&!strcmp(argv[1],"-jprofile")) type=3; else if(argc>2&&!strcmp(argv[1],"-jprofile")) type=1; else type=0; addargv(argc,argv,input+strlen(input)); jefirst(type,input); while(1){jedo(Jinput(jt," "));} jefree(); return 0; }
int main(int argc, char* argv[]) { void* callbacks[] = {Joutput,0,Jinput,0,(void*)SMCON}; int type; #if !defined(WIN32) && !(defined(__arm__)||defined(__mips__)) // set stack size to get limit error instead of crash struct rlimit lim; getrlimit(RLIMIT_STACK,&lim); lim.rlim_cur=0x1000000; // 0xc000000 12mb works, but let's be safe with 16mb setrlimit(RLIMIT_STACK,&lim); #endif jepath(argv[0]); // get path to JFE folder jt=jeload(callbacks); if(!jt){char m[1000]; jefail(m), fputs(m,stdout); exit(1);} adadbreak=(char**)jt; // first address in jt is address of breakdata signal(SIGINT,sigint); #ifdef READLINE char* rl_readline_name="jconsole"; /* argv[0] varies too much*/ #endif if(argc==2&&!strcmp(argv[1],"-jprofile")) type=3; else if(argc>2&&!strcmp(argv[1],"-jprofile")) type=1; else type=0; addargv(argc,argv,input+strlen(input)); #ifndef READLINE #ifndef ANDROID // _O_TEXT may not be defined on non-VC++ systems #ifdef _O_TEXT _setmode( _fileno( stdin ), _O_TEXT ); //readline filters '\r' (so does this) #endif #endif #endif jefirst(type,input); while(1){jedo(Jinput(jt," "));} jefree(); return 0; }
// build and run first sentence to set BINPATH, ARGV, and run profile // arg is command line ready to set in ARGV_z_ // type is 0 normal, 1 -jprofile xxx, 2 ijx basic, 3 nothing // profile[ARGV_z_=:...[BINPATH=:.... // profile is from BINPATH, ARGV, ijx basic, or nothing int jefirst(int type,char* arg) { int r; char* p,*q; char* input=malloc(2000+strlen(arg)); *input=0; if(0==type) { #ifdef PROFILE_PATH strcat(input,"(3 : '0!:0 y')<'"); strcat(input,PROFILE_PATH); strcat(input,"'"); #else strcat(input,"(3 : '0!:0 y')<BINPATH,'"); strcat(input,filesepx); strcat(input,"profile.ijs'"); #endif } else if(1==type) strcat(input,"(3 : '0!:0 y')2{ARGV"); else if(2==type) strcat(input,ijx); else strcat(input,"i.0 0"); strcat(input,"[ARGV_z_=:"); strcat(input,arg); strcat(input,"[BINPATH_z_=:'"); p=path; q=input+strlen(input); while(*p) { if(*p=='\'') *q++='\''; // 's doubled *q++=*p++; } *q=0; strcat(input,"'"); r=jedo(input); free(input); return r; }