Annotation of OpenXM/src/kxx/ox100start.c, Revision 1.1
1.1 ! takayama 1: /* $OpenXM$ */
! 2: /* Moved from misc-2003/07/cygwin/test.c */
! 3: #include <stdio.h>
! 4: #include <sys/types.h>
! 5: #include <sys/stat.h>
! 6: #include <fcntl.h>
! 7: #include <stdlib.h>
! 8: #include <unistd.h>
! 9: #include <sys/wait.h>
! 10: #include <signal.h>
! 11: #include <ctype.h>
! 12:
! 13: extern char **environ;
! 14:
! 15: static int getOStypei();
! 16: static char *addSlash();
! 17: static char *get_sm1_lib_path();
! 18: static char *get_k0_lib_path();
! 19: static char *get_ox_asir_path();
! 20: static char *get_ox_sm1_path();
! 21: static char *get_ox_path();
! 22: static char *get_oxc_path();
! 23: static char *get_oxlog_path();
! 24: static char **setOXenv();
! 25: static int forkExec(char **argv);
! 26: static void usage();
! 27:
! 28: char **catArgv(char **argv1,char **argv2);
! 29:
! 30: char *getOStypes();
! 31: char *getOpenXM_HOME();
! 32: char *getLOAD_SM1_PATH2();
! 33: char **getServerEnv(char *oxServer);
! 34: char **debugServerEnv(char *oxServer);
! 35: char *cygwinPathToWinPath(char *s);
! 36:
! 37: static int Verbose_get_home = 1;
! 38: static int NoX = 0;
! 39:
! 40: #define MYFORKCP_SIZE 100
! 41: static int Myforkchildren[MYFORKCP_SIZE];
! 42: static int Myforkcp=0;
! 43: static void myforkwait() {
! 44: int status;
! 45: int pid;
! 46: int i,j;
! 47: signal(SIGCHLD,SIG_IGN);
! 48: pid = wait(&status);
! 49: fprintf(stderr,"Child process %d is exiting.\n",pid);
! 50: for (i=0; i<Myforkcp; i++) {
! 51: if (Myforkchildren[i] == pid) {
! 52: for (j=i; j<Myforkcp-1; j++) {
! 53: Myforkchildren[j] = Myforkchildren[j+1];
! 54: }
! 55: if (Myforkcp > 0) Myforkcp--;
! 56: }
! 57: }
! 58: signal(SIGCHLD,myforkwait);
! 59: }
! 60:
! 61: #define nomemory(a) {fprintf(stderr,"(%d) no more memory.\n",a);exit(10);}
! 62: #define mymalloc(a) malloc(a)
! 63:
! 64: #ifndef NOT_STANDALONE
! 65: main(int argc,char *argv[]) {
! 66: char *s;
! 67: char s2[1024];
! 68: char buf[1024];
! 69: FILE *fp;
! 70: char **aaa;
! 71: char **eee;
! 72: int i;
! 73: char *serverName;
! 74:
! 75: if (Verbose_get_home) {
! 76: printf("ostype=%s\n",getOStypes());
! 77: printf("OpenXM_HOME=%s\n",getOpenXM_HOME());
! 78: printf("sm lib =%s\n",get_sm1_lib_path());
! 79: printf("k0 lib =%s\n",get_k0_lib_path());
! 80: printf("ox_asir =%s\n",get_ox_asir_path());
! 81: }
! 82:
! 83: /* Initialize parameters */
! 84: serverName = NULL;
! 85: aaa = NULL;
! 86:
! 87: for (i=1 ; i<argc; i++) {
! 88: if (strcmp(argv[i],"-e")==0) {
! 89: if (aaa == NULL) {
! 90: fprintf(stderr,"Server is not found or not specified by -oxserver options.\n");
! 91: exit(1);
! 92: }
! 93: aaa = catArgv(aaa,&(argv[i+1]));
! 94: break;
! 95: }else if (strcmp(argv[i],"-oxserver")==0) {
! 96: i++;
! 97: serverName = argv[i];
! 98: aaa = getServerEnv(serverName);
! 99: }else if (strcmp(argv[i],"-nox")==0) {
! 100: NoX = 1;
! 101: }else{
! 102: fprintf(stderr,"Unknown option.\n");
! 103: usage();
! 104: exit(10);
! 105: }
! 106: }
! 107:
! 108: forkExec(aaa);
! 109:
! 110: }
! 111: #endif
! 112:
! 113: static void usage() {
! 114: fprintf(stderr,"oxstart100 -oxserver xxx [-e args]\n");
! 115: fprintf(stderr,"Examples: \n");
! 116: fprintf(stderr," oxstart100 -oxserver bin/ox_sm1 -e -reverse -data 3010 --control 3012 -pass 1121343432434 \n");
! 117: }
! 118:
! 119: static int forkExec(char **argv) {
! 120: int pid;
! 121: char **eee;
! 122: int m;
! 123: m = 0;
! 124: if (argv == NULL) {
! 125: fprintf(stderr,"Cannot fork and exec.\n"); return -1;
! 126: }
! 127: if ((pid = fork()) > 0) {
! 128: if (m&2) {
! 129: /* Do not call singal to turn around a trouble on cygwin. BUG. */
! 130: }else{
! 131: signal(SIGCHLD,myforkwait); /* to kill Zombie */
! 132: }
! 133: Myforkchildren[Myforkcp++] = pid;
! 134: if (Myforkcp >= MYFORKCP_SIZE-1) {
! 135: fprintf(stderr,"Child process table is full.\n");
! 136: Myforkcp = 0;
! 137: }
! 138: }else{
! 139: /* close the specified files */
! 140: if (m&1) {
! 141: sigset_t sss;
! 142: sigemptyset(&sss);
! 143: sigaddset(&sss,SIGINT);
! 144: sigprocmask(SIG_BLOCK,&sss,NULL);
! 145: }
! 146: eee = setOXenv();
! 147: if (NoX) {
! 148: FILE *null;
! 149: null = fopen("/dev/null","wb");
! 150: dup2(fileno(null),1);
! 151: dup2(fileno(null),2);
! 152: }
! 153: execve(argv[0],argv,environ);
! 154: /* This place will never be reached unless execv fails. */
! 155: fprintf(stderr,"forkExec fails: ");
! 156: }
! 157: }
! 158:
! 159: static int getOStypei() {
! 160: /*
! 161: 0 unix
! 162: 1 windows-cygwin
! 163: 2 windows-cygwin-on-X
! 164: 3 windows-native
! 165: */
! 166: int ostype;
! 167: char *s,*s2,*s3;
! 168: #if defined(__CYGWIN__)
! 169: ostype = 1;
! 170: #else
! 171: ostype = 0;
! 172: #endif
! 173: if (ostype == 0) return ostype;
! 174: /* Heuristic method */
! 175: s = (char *)getenv("WINDOWID");
! 176: if (s != NULL) {
! 177: return 2;
! 178: }
! 179: s = (char *)getenv("OSTYPE");
! 180: s2 = (char *)getenv("MACHTYPE");
! 181: s3 = (char *)getenv("PWD");
! 182: if ((s != NULL) || (s2 != NULL) || (s3 != NULL)) {
! 183: return 1;
! 184: }
! 185: return 3;
! 186: }
! 187:
! 188: char *getOStypes() {
! 189: int ostype;
! 190: ostype = getOStypei();
! 191:
! 192: if (ostype == 1) {
! 193: return("Windows-cygwin");
! 194: }else if (ostype == 2) {
! 195: return("Windows-cygwin-on-X");
! 196: }else if (ostype == 3) {
! 197: return("Windows-native");
! 198: }else{
! 199: return("unix");
! 200: }
! 201: }
! 202:
! 203: /*
! 204: kan96xx/Kan/ext.c
! 205: */
! 206: /*
! 207: -1 : no file
! 208: non-negative: there is a regular file or a directory
! 209: */
! 210: static int getFileSize(char *s) {
! 211: struct stat buf;
! 212: int m;
! 213: if (s == NULL) return -1;
! 214: m = stat(s,&buf);
! 215: if (m == -1) {
! 216: return -1;
! 217: /* fail */
! 218: }else{
! 219: /* success */
! 220: return (int) buf.st_size;
! 221: }
! 222: }
! 223:
! 224: static char *addSlash(char *p) {
! 225: char *p2;
! 226: if ((strlen(p) == 0) || (p == NULL)) return(p);
! 227: if (p[strlen(p)-1] == '/') return(p);
! 228: /* Add / */
! 229: p2 = (char *) mymalloc(sizeof(char)*(strlen(p)+3));
! 230: if (p2 == NULL) { fprintf(stderr,"No more memory.\n"); exit(10); }
! 231: strcpy(p2,p); strcat(p2,"/");
! 232: return(p2);
! 233:
! 234: }
! 235:
! 236: static void msg_get_home(int t,char *s) {
! 237: extern int Verbose_get_home;
! 238: if (!Verbose_get_home) return;
! 239: if (t == 1) {
! 240: fprintf(stderr,"getOpenXM_HOME(): ");
! 241: }else if (t == 2) {
! 242: fprintf(stderr,"getServerEnv(): ");
! 243: }else if (t == 3) {
! 244: fprintf(stderr,"setOXenv(): ");
! 245: }else if (t == 4) {
! 246: fprintf(stderr,"cygwinPathToWinPath(): ");
! 247: }else if (t == 5) {
! 248: fprintf(stderr,"catArgv(): ");
! 249: }else{
! 250: fprintf(stderr,"getting path...: ");
! 251: }
! 252: if (s != NULL) {
! 253: fprintf(stderr,"%s\n",s);
! 254: }else{
! 255: fprintf(stderr," --NULL-- \n");
! 256: }
! 257: }
! 258: /* cf. k097/d.c getLOAD_K_PATH();
! 259: kan96xx/Kan/scanner.c getLOAD_SM1_PATH();
! 260: */
! 261: char *getOpenXM_HOME() {
! 262: char *p;
! 263: char *h;
! 264: p = getOStypes();
! 265: msg_get_home(1,p);
! 266:
! 267: p = (char *) getenv("OpenXM_HOME");
! 268: if (getFileSize(p) != -1) return addSlash(p);
! 269: msg_get_home(1,"OpenXM_HOME is not found.");
! 270:
! 271: p = (char *) getenv("OPENXM_HOME");
! 272: if (getFileSize(p) != -1) return addSlash(p);
! 273: msg_get_home(1,"OPENXM_HOME is not found.");
! 274:
! 275: if (getOStypei() == 3) { /* cygwin-native */
! 276: p = (char *) getenv("OpenXM_HOME_WIN");
! 277: if (getFileSize(p) != -1) return addSlash(p);
! 278: msg_get_home(1,"OpenXM_HOME_WIN is not found.");
! 279:
! 280: p = (char *) getenv("OPENXMHOMEWIN");
! 281: if (getFileSize(p) != -1) return addSlash(p);
! 282: msg_get_home(1,"OPENXMHOMEWIN is not found.");
! 283: }
! 284:
! 285: /* Try to find default directories */
! 286: h = (char *)getenv("HOME");
! 287: if (h != NULL) {
! 288: p = (char *)mymalloc(strlen(h)+100);
! 289: if (p == NULL) {
! 290: fprintf(stderr,"No more memory.\n"); exit(100);
! 291: }
! 292: strcat(h,"/OpenXM");
! 293: p = h;
! 294: if (getFileSize(p) != -1) return addSlash(p);
! 295: msg_get_home(1,"OpenXM is not found under the home directory.");
! 296: }
! 297:
! 298: if (getOStypei() != 3) {
! 299: p = "/usr/local/OpenXM";
! 300: }else{
! 301: p = "/cygdrive/c/usr/local/OpenXM";
! 302: }
! 303: if (getFileSize(p) != -1) return addSlash(p);
! 304: msg_get_home(1,"OpenXM is not found under /usr/local");
! 305:
! 306: if (getOStypei() != 0) {
! 307: p = "/cygdrive/c/OpenXM";
! 308: if (getFileSize(p) != -1) return addSlash(p);
! 309: msg_get_home(1,"OpenXM is not found under c:\\");
! 310:
! 311: p = "/cygdrive/c/OpenXM-win";
! 312: if (getFileSize(p) != -1) return addSlash(p);
! 313: msg_get_home(1,"OpenXM-win is not found under c:\\");
! 314:
! 315: p = "/cygdrive/c/Program Files/OpenXM";
! 316: if (getFileSize(p) != -1) return addSlash(p);
! 317: msg_get_home(1,"OpenXM is not found under c:\\Program Files");
! 318:
! 319: p = "/cygdrive/c/Program Files/OpenXM-win";
! 320: if (getFileSize(p) != -1) return addSlash(p);
! 321: msg_get_home(1,"OpenXM-win is not found under c:\\Program Files");
! 322:
! 323: }
! 324:
! 325: msg_get_home(1,"Giving up!");
! 326: return NULL;
! 327:
! 328: }
! 329:
! 330: static char *get_k0_lib_path() {
! 331: char *oxhome;
! 332: char *p;
! 333:
! 334:
! 335: p = (char *)getenv("LOAD_K_PATH");
! 336: if (p != NULL) {
! 337: if (getFileSize(p) != -1) return addSlash(p);
! 338: msg_get_home(1,"LOAD_K0_PATH is not found.");
! 339: }
! 340:
! 341: oxhome = getOpenXM_HOME();
! 342: if (oxhome == NULL) return (char *)NULL;
! 343: p = (char *) mymalloc(strlen(oxhome)+100);
! 344: if (p == NULL) {fprintf(stderr,"No more memory.\n"); exit(100);}
! 345:
! 346: strcpy(p,oxhome);
! 347: strcat(p,"lib/k097");
! 348: if (getFileSize(p) != -1) return addSlash(p);
! 349: msg_get_home(1,oxhome);
! 350: msg_get_home(1," is found, but ");
! 351: msg_get_home(1,p);
! 352: msg_get_home(1," is not found.");
! 353:
! 354: msg_get_home(1,"Giving up!");
! 355: return NULL;
! 356: }
! 357:
! 358: static char *get_sm1_lib_path() {
! 359: char *oxhome;
! 360: char *p;
! 361:
! 362: p = (char *)getenv("LOAD_SM1_PATH");
! 363: if (p != NULL) {
! 364: if (getFileSize(p) != -1) return addSlash(p);
! 365: msg_get_home(1,"LOAD_SM1_PATH is not found.");
! 366: }
! 367:
! 368: oxhome = getOpenXM_HOME();
! 369: if (oxhome == NULL) return NULL;
! 370: p = (char *) mymalloc(strlen(oxhome)+100);
! 371: if (p == NULL) {fprintf(stderr,"No more memory.\n"); exit(100);}
! 372:
! 373: strcpy(p,oxhome);
! 374: strcat(p,"lib/sm1");
! 375: if (getFileSize(p) != -1) return addSlash(p);
! 376: msg_get_home(1,oxhome);
! 377: msg_get_home(1," is found, but ");
! 378: msg_get_home(1,p);
! 379: msg_get_home(1," is not found.");
! 380:
! 381: msg_get_home(1,"Giving up!");
! 382: return NULL;
! 383: }
! 384:
! 385: static char *get_ox_asir_path() {
! 386: char *oxhome;
! 387: char *p;
! 388:
! 389: oxhome = getOpenXM_HOME();
! 390: if (oxhome == NULL) return NULL;
! 391: p = (char *) mymalloc(strlen(oxhome)+100);
! 392: if (p == NULL) {fprintf(stderr,"No more memory.\n"); exit(100);}
! 393:
! 394: strcpy(p,oxhome);
! 395: strcat(p,"bin/ox_asir");
! 396: if (getFileSize(p) != -1) return p;
! 397: msg_get_home(1,oxhome);
! 398: msg_get_home(1," is found, but ");
! 399: msg_get_home(1,p);
! 400: msg_get_home(1," is not found.");
! 401:
! 402: strcpy(p,oxhome);
! 403: strcat(p,"lib/asir/ox_asir");
! 404: if (getFileSize(p) != -1) return p;
! 405: msg_get_home(1,oxhome);
! 406: msg_get_home(1," is found, but ");
! 407: msg_get_home(1,p);
! 408: msg_get_home(1," is not found.");
! 409:
! 410: msg_get_home(1,"Giving up!");
! 411: return NULL;
! 412: }
! 413:
! 414: static char *get_ox_path() {
! 415: char *oxhome;
! 416: char *p;
! 417:
! 418: oxhome = getOpenXM_HOME();
! 419: if (oxhome == NULL) return NULL;
! 420: p = (char *) mymalloc(strlen(oxhome)+100);
! 421: if (p == NULL) {fprintf(stderr,"No more memory.\n"); exit(100);}
! 422:
! 423: strcpy(p,oxhome);
! 424: strcat(p,"bin/ox");
! 425: if (getFileSize(p) != -1) return p;
! 426: msg_get_home(1,oxhome);
! 427: msg_get_home(1," is found, but ");
! 428: msg_get_home(1,p);
! 429: msg_get_home(1," is not found.");
! 430:
! 431: msg_get_home(1,"Giving up!");
! 432: return NULL;
! 433: }
! 434:
! 435:
! 436: static char *get_oxc_path() {
! 437: char *oxhome;
! 438: char *p;
! 439:
! 440: oxhome = getOpenXM_HOME();
! 441: if (oxhome == NULL) return NULL;
! 442: p = (char *) mymalloc(strlen(oxhome)+100);
! 443: if (p == NULL) {fprintf(stderr,"No more memory.\n"); exit(100);}
! 444:
! 445: strcpy(p,oxhome);
! 446: strcat(p,"bin/oxc");
! 447: if (getFileSize(p) != -1) return p;
! 448: msg_get_home(1,oxhome);
! 449: msg_get_home(1," is found, but ");
! 450: msg_get_home(1,p);
! 451: msg_get_home(1," is not found.");
! 452:
! 453: msg_get_home(1,"Giving up!");
! 454: return NULL;
! 455: }
! 456:
! 457: static char *get_oxlog_path() {
! 458: char *oxhome;
! 459: char *p;
! 460:
! 461: oxhome = getOpenXM_HOME();
! 462: if (oxhome == NULL) return NULL;
! 463: p = (char *) mymalloc(strlen(oxhome)+100);
! 464: if (p == NULL) {fprintf(stderr,"No more memory.\n"); exit(100);}
! 465:
! 466: strcpy(p,oxhome);
! 467: strcat(p,"bin/oxlog");
! 468: if (getFileSize(p) != -1) return p;
! 469: msg_get_home(1,oxhome);
! 470: msg_get_home(1," is found, but ");
! 471: msg_get_home(1,p);
! 472: msg_get_home(1," is not found.");
! 473:
! 474: msg_get_home(1,"Giving up!");
! 475: return NULL;
! 476: }
! 477:
! 478: char *cygwinPathToWinPath(char *s) {
! 479: char *pos;
! 480: char *ans;
! 481: int i;
! 482: msg_get_home(4,s);
! 483: if (s == NULL) return NULL;
! 484: if (strlen(s) == 0) return s;
! 485:
! 486: ans = (char *) mymalloc(strlen(s) + 32);
! 487: if (ans == NULL) nomemory(0);
! 488:
! 489: pos = (char *)strstr(s,"/cygdrive/");
! 490: if (pos == s) {
! 491: strcpy(ans,&(s[9]));
! 492: ans[0] = s[10]; ans[1] = ':'; ans[2] = '\\';
! 493: }else{
! 494: strcpy(ans,s);
! 495: }
! 496:
! 497: if (ans[0] == '/') {
! 498: strcpy(ans,"C:\\cygwin");
! 499: strcat(ans,s);
! 500: }
! 501:
! 502:
! 503: for (i=0; i <strlen(ans); i++) {
! 504: if (ans[i] == '/') ans[i] = '\\';
! 505: }
! 506: return ans;
! 507: }
! 508:
! 509: char **getServerEnv(char *oxServer) {
! 510: int ostype;
! 511: char *p;
! 512: char *oxhome;
! 513: char *xterm;
! 514: char *oxlog;
! 515: char *load_sm1_path;
! 516: char *load_k0_path;
! 517: char *openXM_HOME;
! 518: #define ARGV_SIZE 100
! 519: char *argv[ARGV_SIZE];
! 520: int i,k;
! 521: char **aaa;
! 522:
! 523: if (Verbose_get_home) {
! 524: if (oxServer == NULL) {
! 525: fprintf(stderr,"Server name is NULL.\n");
! 526: }else{
! 527: fprintf(stderr,"Server name is %s\n",oxServer);
! 528: }
! 529: }
! 530:
! 531: if (oxServer == NULL) return NULL;
! 532: i = 0;
! 533: argv[i] = NULL;
! 534:
! 535: ostype = getOStypei();
! 536:
! 537: oxhome = getOpenXM_HOME();
! 538: if (oxhome == NULL) return NULL;
! 539: p = (char *) mymalloc(strlen(oxhome)+strlen(oxServer)+100);
! 540: if (p == NULL) {fprintf(stderr,"No more memory.\n"); exit(100);}
! 541:
! 542: strcpy(p,oxhome);
! 543: strcat(p,oxServer);
! 544: if (getFileSize(p) == -1) {
! 545: msg_get_home(2,oxhome);
! 546: msg_get_home(2," is found, but ");
! 547: msg_get_home(2,p);
! 548: msg_get_home(2," is not found.");
! 549: return (NULL);
! 550: }
! 551: oxServer = (char *) mymalloc(strlen(oxhome)+strlen(oxServer)+100);
! 552: if (oxServer == NULL) {fprintf(stderr,"No more memory.\n"); exit(100);}
! 553: strcpy(oxServer,p);
! 554:
! 555: if ((ostype == 0) || (ostype == 2)) {
! 556: if (!NoX) {
! 557: xterm = "/usr/X11R6/bin/xterm";
! 558: if (getFileSize(xterm) == -1) {
! 559: msg_get_home(2,"xterm is not found. NoX is automatically set.");
! 560: NoX = 1;
! 561: }
! 562: }
! 563: oxlog = get_oxlog_path();
! 564: xterm = "/usr/X11R6/bin/xterm -icon -e ";
! 565: argv[i] = oxlog; i++; argv[i] = NULL;
! 566: if (!NoX) {
! 567: argv[i] = "/usr/X11R6/bin/xterm"; i++; argv[i] = NULL;
! 568: argv[i] = "-icon"; i++; argv[i] = NULL;
! 569: argv[i] = "-e"; i++; argv[i] = NULL;
! 570: }
! 571: argv[i] = get_ox_path(); i++; argv[i] = NULL;
! 572: argv[i] = "-ox"; i++; argv[i] = NULL;
! 573: argv[i] = oxServer; i++; argv[i] = NULL;
! 574: }else{
! 575: if (!NoX) {
! 576: if (getFileSize("/cygdrive/c/winnt/system32/cmd.exe") >= 0) {
! 577: xterm = "/cygdrive/c/winnt/system32/cmd.exe /c start /min ";
! 578: argv[i] = "/cygdrive/c/winnt/system32/cmd.exe"; i++; argv[i] = NULL;
! 579: }else if (getFileSize("/cygdrive/c/windows/system32/cmd.exe") >= 0) {
! 580: xterm = "/cygdrive/c/windows/system32/cmd.exe /c start /min ";
! 581: argv[i] = "/cygdrive/c/windows/system32/cmd.exe"; i++; argv[i] = NULL;
! 582: }else{
! 583: msg_get_home(2,"cmd.exe is not found. NoX is automatically set.");
! 584: NoX = 1;
! 585: }
! 586: }
! 587: oxlog = " ";
! 588: if (!NoX) {
! 589: argv[i] = "/c"; i++; argv[i] = NULL;
! 590: argv[i] = "start"; i++; argv[i] = NULL;
! 591: argv[i] = "/min"; i++; argv[i] = NULL;
! 592: }
! 593: argv[i] = cygwinPathToWinPath(get_ox_path()); i++; argv[i] = NULL;
! 594: argv[i] = "-ox"; i++; argv[i] = NULL;
! 595: argv[i] = oxServer; i++; argv[i] = NULL;
! 596: }
! 597:
! 598: aaa = (char **) mymalloc(sizeof(char*)*(i+1));
! 599: if (aaa == NULL) nomemory(0);
! 600: msg_get_home(2,"--------- Result --------------");
! 601: for (k=0; k<i; k++) {
! 602: aaa[k] = argv[k];
! 603: msg_get_home(2,aaa[k]);
! 604: aaa[k+1] = NULL;
! 605: }
! 606: return aaa;
! 607: }
! 608:
! 609: char **setOXenv() {
! 610: /* Do nothing. */
! 611: return NULL;
! 612: }
! 613: char **setOXenv_old() {
! 614: char *openXM_HOME;
! 615: char *load_sm1_path;
! 616: char *load_k0_path;
! 617: char *asir_config;
! 618: char *asir_libdir;
! 619: char *asirloadpath;
! 620: char *asir_rsh;
! 621: char *ld_library_path;
! 622: char **aaa;
! 623: int n,i,k;
! 624:
! 625: /* set environmental variables */
! 626: n = 20; /* n must be larger than the number of env vars */
! 627: n++;
! 628: load_sm1_path = (char *) getenv("LOAD_SM1_PATH");
! 629: load_k0_path = (char *) getenv("LOAD_SM1_PATH");
! 630: asir_config = (char *) getenv("ASIR_CONFIG");
! 631: asir_libdir = (char *) getenv("ASIR_LIBDIR");
! 632: asirloadpath = (char *) getenv("ASIRLOADPATH");
! 633: asir_rsh = (char *) getenv("ASIR_RSH");
! 634: ld_library_path = (char *) getenv("LD_LIBRARY_PATH");
! 635:
! 636: openXM_HOME = getOpenXM_HOME();
! 637: if (openXM_HOME != NULL)
! 638: openXM_HOME[strlen(openXM_HOME)-1] = '\0';
! 639: /* How about ASIR... ? */
! 640:
! 641: msg_get_home(3,"OpenXM_HOME is"); msg_get_home(2,openXM_HOME);
! 642: msg_get_home(3,"LOAD_SM1_PATH is"); msg_get_home(2,load_sm1_path);
! 643: msg_get_home(3,"LOAD_K0_PATH is"); msg_get_home(2,load_k0_path);
! 644:
! 645: aaa = (char **) mymalloc(sizeof(char*)*n);
! 646: if (aaa == NULL) nomemory(0);
! 647:
! 648: i = 0;
! 649: if (openXM_HOME != NULL) {
! 650: aaa[i] = openXM_HOME; i++; aaa[i] = NULL; if (i > n-2) return aaa;
! 651: }
! 652: if (load_sm1_path != NULL) {
! 653: aaa[i] = load_sm1_path; i++; aaa[i] = NULL; if (i > n-2) return aaa;
! 654: }
! 655: if (load_k0_path != NULL) {
! 656: aaa[i] = load_k0_path; i++; aaa[i] = NULL; if (i > n-2) return aaa;
! 657: }
! 658: if (asir_config != NULL) {
! 659: aaa[i] = asir_config; i++; aaa[i] = NULL; if (i > n-2) return aaa;
! 660: }
! 661: if (asir_libdir != NULL) {
! 662: aaa[i] = asir_libdir; i++; aaa[i] = NULL; if (i > n-2) return aaa;
! 663: }
! 664: if (asirloadpath != NULL) {
! 665: aaa[i] = asirloadpath; i++; aaa[i] = NULL; if (i > n-2) return aaa;
! 666: }
! 667: if (asir_rsh != NULL) {
! 668: aaa[i] = asir_rsh; i++; aaa[i] = NULL; if (i > n-2) return aaa;
! 669: }
! 670:
! 671: msg_get_home(3,"--------- Result --------------");
! 672: for (k=0; k<n; k++) {
! 673: if (aaa[k] == NULL) break;
! 674: msg_get_home(3,aaa[k]);
! 675: }
! 676:
! 677: return aaa;
! 678: }
! 679:
! 680: char **debugServerEnv(char *oxServer)
! 681: {
! 682: int t;
! 683: char **aaa;
! 684: t = Verbose_get_home;
! 685: Verbose_get_home = 1;
! 686: aaa = getServerEnv(oxServer);
! 687: Verbose_get_home = t;
! 688: return ( aaa );
! 689: }
! 690:
! 691: char **catArgv(char **argv1,char **argv2)
! 692: {
! 693: int i,n1,n2;
! 694: char **argv;
! 695: n1=0;
! 696: while (argv1[n1] != NULL) n1++;
! 697: n2=0;
! 698: while (argv2[n2] != NULL) n2++;
! 699: argv = (char **) mymalloc(sizeof(char *)*(n1+n2+1));
! 700: if (argv == NULL) nomemory(0);
! 701: for (i=0; i<n1; i++) argv[i] = argv1[i];
! 702: for (i=0; i<n2; i++) argv[n1+i] = argv2[i];
! 703: argv[n1+n2]=NULL;
! 704: for (i=0; i<n1+n2; i++) {
! 705: msg_get_home(5,argv[i]);
! 706: }
! 707: return argv;
! 708: }
! 709:
! 710: char *getLOAD_SM1_PATH2() {
! 711: char *p;
! 712: p = get_sm1_lib_path();
! 713: if (p == NULL) {
! 714: return("/usr/local/lib/sm1/");
! 715: }else{
! 716: return p;
! 717: }
! 718: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>