Annotation of OpenXM_contrib2/asir2000/io/ox_asir.c, Revision 1.14
1.14 ! noro 1: /* $OpenXM: OpenXM_contrib2/asir2000/io/ox_asir.c,v 1.13 2000/03/19 12:35:20 noro Exp $ */
1.1 noro 2: #include "ca.h"
3: #include "parse.h"
1.6 noro 4: #include "signal.h"
1.1 noro 5: #include "ox.h"
6: #include "version.h"
1.6 noro 7: #if PARI
8: #include "genpari.h"
9: #endif
1.1 noro 10:
11: void ox_usr1_handler();
1.13 noro 12: int asir_ox_init();
1.1 noro 13:
14: extern jmp_buf environnement;
15:
16: extern int do_message;
17: extern int ox_flushing;
18: extern jmp_buf ox_env;
19: extern MATHCAP my_mathcap;
20:
1.11 noro 21: extern int little_endian,ox_sock_id;
22:
1.1 noro 23: int ox_sock_id;
1.11 noro 24: int lib_ox_need_conv;
1.1 noro 25:
26: static int asir_OperandStackSize;
27: static Obj *asir_OperandStack;
28: static int asir_OperandStackPtr = -1;
29:
30: static void create_error(ERR *,unsigned int ,char *);
31: static void ox_io_init();
32: static void ox_asir_init(int,char **);
33: static Obj asir_pop_one();
34: static void asir_push_one(Obj);
35: static void asir_end_flush();
36: static void asir_executeFunction(int);
37: static int asir_executeString();
38: static void asir_evalName(unsigned int);
39: static void asir_setName(unsigned int);
40: static void asir_pops();
41: static void asir_popString();
42: static void asir_popCMO(unsigned int);
43: static void asir_popSerializedLocalObject();
44: static LIST asir_GetErrorList();
1.13 noro 45: static char *name_of_cmd(int);
1.1 noro 46: static char *name_of_id(int);
1.13 noro 47: static void asir_do_cmd(int,unsigned int);
1.1 noro 48:
49: #if MPI
1.14 ! noro 50: /* XXX : currently MPI version supports only a homogeneous cluster. */
! 51:
1.1 noro 52: extern int mpi_nprocs,mpi_myid;
53:
54: void ox_mpi_master_init() {
1.14 ! noro 55: int i,idx;
1.1 noro 56:
1.14 ! noro 57: for ( i = 0; i < mpi_nprocs; i++ ) {
! 58: /* ordering information is not exchanged */
! 59: /* idx should be equal to i */
1.1 noro 60: idx = get_iofp(i,0,0);
1.14 ! noro 61: register_server(0,idx,idx);
1.1 noro 62: }
63: }
64:
65: void ox_mpi_slave_init() {
1.14 ! noro 66: int i,idx;
! 67:
1.1 noro 68: endian_init();
69: fclose(stdin);
1.14 ! noro 70: for ( i = 0; i < mpi_nprocs; i++ ) {
! 71: /* ordering information is not exchanged */
! 72: /* idx should be equal to i */
! 73: idx = get_iofp(i,0,0);
! 74: register_server(0,idx,idx);
! 75: }
1.1 noro 76: asir_OperandStackSize = BUFSIZ;
77: asir_OperandStack = (Obj *)CALLOC(asir_OperandStackSize,sizeof(Obj));
78: asir_OperandStackPtr = -1;
79: }
80: #endif
81:
82: static void create_error(ERR *err,unsigned int serial,char *msg)
83: {
84: int len;
85: USINT ui;
86: NODE n,n1;
87: LIST list;
88: char *msg1;
89: STRING errmsg;
90:
91: MKUSINT(ui,serial);
92: len = strlen(msg);
93: msg1 = (char *)MALLOC(len+1);
94: strcpy(msg1,msg);
95: MKSTR(errmsg,msg1);
96: MKNODE(n1,errmsg,0); MKNODE(n,ui,n1); MKLIST(list,n);
97: MKERR(*err,list);
98: }
99:
100: void ox_main(int argc,char **argv) {
101: int id;
1.13 noro 102: int cmd;
1.1 noro 103: Obj obj;
104: USINT ui;
105: ERR err;
106: LIST list;
107: NODE n,n1;
108: unsigned int serial;
109: int ret;
110: extern char LastError[];
111:
112: ox_asir_init(argc,argv);
113: if ( do_message )
114: fprintf(stderr,"I'm an ox_asir, Version %d.\n",ASIR_VERSION);
115: if ( setjmp(ox_env) ) {
116: while ( NEXT(asir_infile) )
117: closecurrentinput();
118: ox_send_sync(0);
119: }
120: while ( 1 ) {
121: extern int recv_intr;
122:
123: serial = ox_recv(0,&id,&obj);
124: #if defined(VISUAL)
125: if ( recv_intr ) {
126: if ( recv_intr == 1 ) {
127: recv_intr = 0;
128: int_handler(SIGINT);
129: } else {
130: recv_intr = 0;
131: ox_usr1_handler(0);
132: }
133: }
134: #endif
135: if ( do_message )
136: fprintf(stderr,"#%d Got %s",serial,name_of_id(id));
137: switch ( id ) {
138: case OX_COMMAND:
139: cmd = ((USINT)obj)->body;
140: if ( ox_flushing )
141: break;
142: if ( do_message )
143: fprintf(stderr," %s\n",name_of_cmd(cmd));
144: if ( ret = setjmp(env) ) {
145: if ( ret == 1 ) {
146: create_error(&err,serial,LastError);
147: asir_push_one((Obj)err);
148: }
149: break;
150: }
151: asir_do_cmd(cmd,serial);
152: break;
153: case OX_DATA:
154: case OX_LOCAL_OBJECT_ASIR:
155: if ( ox_flushing )
156: break;
157: if ( do_message )
158: fprintf(stderr," -> data pushed");
159: asir_push_one(obj);
160: break;
161: case OX_SYNC_BALL:
162: asir_end_flush();
163: break;
164: default:
165: break;
166: }
167: if ( do_message )
168: fprintf(stderr,"\n");
169: }
170: }
171:
1.13 noro 172: static void asir_do_cmd(int cmd,unsigned int serial)
1.1 noro 173: {
174: MATHCAP client_mathcap;
175: Q q;
176: int i;
177: LIST list;
178:
179: switch ( cmd ) {
180: case SM_dupErrors:
181: list = asir_GetErrorList();
182: asir_push_one((Obj)list);
183: break;
184: case SM_getsp:
185: i = asir_OperandStackPtr+1;
186: STOQ(i,q);
187: asir_push_one((Obj)q);
188: break;
189: case SM_popSerializedLocalObject:
190: asir_popSerializedLocalObject();
191: break;
192: case SM_popCMO:
193: asir_popCMO(serial);
194: break;
195: case SM_popString:
196: asir_popString();
197: break;
198: case SM_setName:
199: asir_setName(serial);
200: break;
201: case SM_evalName:
202: asir_evalName(serial);
203: break;
204: case SM_executeStringByLocalParser:
205: asir_executeString();
206: break;
207: case SM_executeStringByLocalParserInBatchMode:
208: asir_executeString();
209: asir_pop_one();
210: break;
211: case SM_executeFunction:
212: asir_executeFunction(serial);
213: break;
214: case SM_shutdown:
215: asir_terminate(2);
216: break;
217: case SM_pops:
218: asir_pops();
219: break;
220: case SM_mathcap:
221: asir_push_one((Obj)my_mathcap);
222: break;
223: case SM_setMathcap:
224: client_mathcap = (MATHCAP)asir_pop_one();
225: store_remote_mathcap(0,client_mathcap);
226: break;
227: case SM_nop:
228: default:
229: break;
230: }
231: }
232:
233: static char *name_of_id(int id)
234: {
235: switch ( id ) {
236: case OX_COMMAND:
237: return "OX_COMMAND";
238: break;
239: case OX_DATA:
240: return "OX_DATA";
241: break;
242: case OX_LOCAL_OBJECT_ASIR:
243: return "OX_LOCAL_OBJECT_ASIR";
244: break;
245: case OX_SYNC_BALL:
246: return "OX_SYNC_BALL";
247: break;
248: default:
249: return "Unknown id";
250: break;
251: }
252: }
253:
1.13 noro 254: static char *name_of_cmd(int cmd)
1.1 noro 255: {
256: switch ( cmd ) {
257: case SM_popSerializedLocalObject:
258: return "SM_popSerializedLocalObject";
259: break;
260: case SM_popCMO:
261: return "SM_popCMO";
262: break;
263: case SM_popString:
264: return "SM_popString";
265: break;
266: case SM_pops:
267: return "SM_pops";
268: break;
269: case SM_setName:
270: return "SM_setName";
271: break;
272: case SM_evalName:
273: return "SM_evalName";
274: break;
275: case SM_executeStringByLocalParser:
276: return "SM_executeString";
277: break;
278: case SM_executeFunction:
279: return "SM_executeFunction";
280: break;
281: case SM_shutdown:
282: return "SM_shutdown";
283: break;
284: case SM_beginBlock:
285: return "SM_beginBlock";
286: break;
287: case SM_endBlock:
288: return "SM_endBlock";
289: break;
290: case SM_mathcap:
291: return "SM_mathcap";
292: break;
293: case SM_setMathcap:
294: return "SM_setMathcap";
295: break;
296: case SM_getsp:
297: return "SM_setMathcap";
298: break;
299: case SM_dupErrors:
300: return "SM_dupErrors";
301: break;
302: case SM_nop:
303: return "SM_nop";
304: default:
305: return "Unknown cmd";
306: break;
307: }
308: }
309:
310: static LIST asir_GetErrorList()
311: {
312: int i;
313: NODE n,n0;
314: LIST err;
315: Obj obj;
316:
317: for ( i = 0, n0 = 0; i <= asir_OperandStackPtr; i++ )
318: if ( (obj = asir_OperandStack[i]) && (OID(obj) == O_ERR) ) {
319: NEXTNODE(n0,n); BDY(n) = (pointer)obj;
320: }
321: if ( n0 )
322: NEXT(n) = 0;
323: MKLIST(err,n0);
324: return err;
325: }
326:
327: static void asir_popSerializedLocalObject()
328: {
329: Obj obj;
330: VL t,vl;
331:
332: obj = asir_pop_one();
333: get_vars_recursive(obj,&vl);
334: for ( t = vl; t; t = NEXT(t) )
335: if ( t->v->attr == (pointer)V_UC )
336: error("bsave : not implemented");
337: ox_send_cmd(0,SM_beginBlock);
338: ox_send_local_ring(0,vl);
339: ox_send_local_data(0,obj);
340: ox_send_cmd(0,SM_endBlock);
341: }
342:
343: static void asir_popCMO(unsigned int serial)
344: {
345: Obj obj;
346: ERR err;
347:
348: obj = asir_pop_one();
349: if ( valid_as_cmo(obj) )
350: ox_send_data(0,obj);
351: else {
352: create_error(&err,serial,"cannot convert to CMO object");
353: ox_send_data(0,err);
354: asir_push_one(obj);
355: }
356: }
357:
358: static void asir_popString()
359: {
360: Obj val;
361: char *buf,*obuf;
362: int l;
363: STRING str;
364:
365: val = asir_pop_one();
366: if ( !val )
367: obuf = 0;
368: else {
369: l = estimate_length(CO,val);
370: buf = (char *)ALLOCA(l+1);
371: soutput_init(buf);
372: sprintexpr(CO,val);
373: l = strlen(buf);
374: obuf = (char *)MALLOC(l+1);
375: strcpy(obuf,buf);
376: }
377: MKSTR(str,obuf);
378: ox_send_data(0,str);
379: }
380:
381: static void asir_pops()
382: {
383: int n;
384:
385: n = (int)(((USINT)asir_pop_one())->body);
386: asir_OperandStackPtr = MAX(asir_OperandStackPtr-n,-1);
387: }
388:
389: static void asir_setName(unsigned int serial)
390: {
391: char *name;
392: int l,n;
393: char *dummy = "=0;";
394: SNODE snode;
395: ERR err;
396:
397: name = ((STRING)asir_pop_one())->body;
398: l = strlen(name);
399: n = l+strlen(dummy)+1;
400: parse_strp = (char *)ALLOCA(n);
401: sprintf(parse_strp,"%s%s",name,dummy);
402: if ( mainparse(&snode) ) {
403: create_error(&err,serial,"cannot set to variable");
404: asir_push_one((Obj)err);
405: } else {
406: FA1((FNODE)FA0(snode)) = (pointer)mkfnode(1,I_FORMULA,asir_pop_one());
407: evalstat(snode);
408: }
409: }
410:
411: static void asir_evalName(unsigned int serial)
412: {
413: char *name;
414: int l,n;
415: SNODE snode;
416: ERR err;
417: pointer val;
418:
419: name = ((STRING)asir_pop_one())->body;
420: l = strlen(name);
421: n = l+2;
422: parse_strp = (char *)ALLOCA(n);
423: sprintf(parse_strp,"%s;",name);
424: if ( mainparse(&snode) ) {
425: create_error(&err,serial,"no such variable");
426: val = (pointer)err;
427: } else
428: val = evalstat(snode);
429: asir_push_one(val);
430: }
431:
432: static int asir_executeString()
433: {
434: SNODE snode;
435: pointer val;
436: char *cmd;
437: #if PARI
438: recover(0);
439: if ( setjmp(environnement) ) {
440: avma = top; recover(1);
441: resetenv("");
442: }
443: #endif
444: cmd = ((STRING)asir_pop_one())->body;
445: parse_strp = cmd;
446: if ( mainparse(&snode) ) {
447: return -1;
448: }
449: val = evalstat(snode);
450: if ( NEXT(asir_infile) ) {
451: while ( NEXT(asir_infile) ) {
452: if ( mainparse(&snode) ) {
453: asir_push_one(val);
454: return -1;
455: }
456: nextbp = 0;
457: val = evalstat(snode);
458: }
459: }
460: asir_push_one(val);
461: return 0;
462: }
463:
464: static void asir_executeFunction(int serial)
465: {
466: char *func;
467: int argc;
468: FUNC f;
469: Obj result;
470: VL vl;
471: NODE n,n1;
472: STRING fname;
473: char *path;
474: USINT ui;
475: ERR err;
1.5 noro 476: Obj arg;
1.1 noro 477: static char buf[BUFSIZ];
478:
1.5 noro 479: arg = asir_pop_one();
480: if ( !arg || OID(arg) != O_STR ) {
481: sprintf(buf,"executeFunction : invalid function name");
482: goto error;
483: } else
484: func = ((STRING)arg)->body;
485:
486: arg = asir_pop_one();
487: if ( !arg || OID(arg) != O_USINT ) {
488: sprintf(buf,"executeFunction : invalid argc");
489: goto error;
490: } else
491: argc = (int)(((USINT)arg)->body);
1.1 noro 492:
493: for ( n = 0; argc; argc-- ) {
494: NEXTNODE(n,n1);
495: BDY(n1) = (pointer)asir_pop_one();
496: }
497: if ( n )
498: NEXT(n1) = 0;
499:
500: if ( !strcmp(func,"load") ) {
501: fname = (STRING)BDY(n);
502: if ( OID(fname) == O_STR ) {
503: searchasirpath(BDY(fname),&path);
504: if ( path ) {
505: if ( do_message )
506: fprintf(stderr,"loading %s\n",path);
507: execasirfile(path);
508: } else
509: if ( do_message )
510: fprintf(stderr,"load : %s not found in the search path\n",BDY(fname));
511: }
512: result = 0;
513: } else {
514: searchf(noargsysf,func,&f);
515: if ( !f )
516: searchf(sysf,func,&f);
517: if ( !f )
518: searchf(ubinf,func,&f);
519: if ( !f )
520: searchf(usrf,func,&f);
521: if ( !f ) {
522: sprintf(buf,"executeFunction : the function %s not found",func);
1.5 noro 523: goto error;
1.1 noro 524: } else {
525: result = (Obj)bevalf(f,n);
526: }
527: }
1.5 noro 528: asir_push_one(result);
529: return;
530:
531: error:
532: create_error(&err,serial,buf);
533: result = (Obj)err;
1.1 noro 534: asir_push_one(result);
535: }
536:
537: static void asir_end_flush()
538: {
539: ox_flushing = 0;
540: }
541:
542: /*
543: asir_OperandStackPtr points to the surface of the stack.
544: That is, the data at the stack top is
545: asir_OperandStack[asir_OperandStackPtr].
546: */
547:
548:
549: static void asir_push_one(Obj obj)
550: {
551: if ( !obj || OID(obj) != O_VOID ) {
552: asir_OperandStackPtr++;
553: if ( asir_OperandStackPtr >= asir_OperandStackSize ) {
554: asir_OperandStackSize += BUFSIZ;
555: asir_OperandStack
556: = (Obj *)REALLOC(asir_OperandStack,
557: asir_OperandStackSize*sizeof(Obj));
558: }
559: asir_OperandStack[asir_OperandStackPtr] = obj;
560: }
561: }
562:
563: static Obj asir_pop_one() {
564: if ( asir_OperandStackPtr < 0 ) {
565: if ( do_message )
566: fprintf(stderr,"OperandStack underflow");
567: return 0;
568: } else {
569: if ( do_message )
570: fprintf(stderr,"pop at %d\n",asir_OperandStackPtr);
571: return asir_OperandStack[asir_OperandStackPtr--];
572: }
573: }
574:
575: static void ox_asir_init(int argc,char **argv)
576: {
577: int tmp;
578: char ifname[BUFSIZ];
579: extern int GC_dont_gc;
580: extern int read_exec_file;
581: extern int do_asirrc;
582: extern int do_server_in_X11;
583: char *getenv();
584: static ox_asir_initialized = 0;
585: FILE *ifp;
1.4 noro 586: char *homedir;
587: char *ptr;
1.1 noro 588:
589: #if !defined(VISUAL) && !MPI
590: do_server_in_X11 = 1; /* XXX */
591: #endif
592: asir_save_handler();
593: #if PARI
594: risa_pari_init();
595: #endif
596: srandom((int)get_current_time());
597:
598: #if defined(THINK_C)
599: param_init();
600: #endif
601: StackBottom = &tmp + 1; /* XXX */
602: rtime_init();
603: env_init();
604: endian_init();
605: #if !defined(VISUAL) && !defined(THINK_C)
606: /* check_key(); */
607: #endif
608: GC_init();
609: process_args(--argc,++argv);
610: output_init();
611: arf_init();
612: nglob_init();
613: glob_init();
614: sig_init();
615: tty_init();
616: debug_init();
617: pf_init();
618: sysf_init();
619: parif_init();
620: #if defined(VISUAL)
621: init_socket();
622: #endif
623: #if defined(UINIT)
624: reg_sysf();
625: #endif
1.4 noro 626: /* if ASIR_CONFIG is set, execute it; else execute .asirrc */
627: if ( ptr = getenv("ASIR_CONFIG") )
628: strcpy(ifname,ptr);
629: else {
1.1 noro 630: #if defined(THINK_C)
1.4 noro 631: sprintf(ifname,"asirrc");
1.1 noro 632: #else
1.4 noro 633: homedir = getenv("HOME");
634: if ( !homedir ) {
635: char rootname[BUFSIZ];
636:
637: get_rootdir(rootname,sizeof(rootname));
638: homedir = rootname;
639: }
640: sprintf(ifname,"%s/.asirrc",homedir);
1.1 noro 641: #endif
1.4 noro 642: }
1.1 noro 643: if ( do_asirrc && (ifp = fopen(ifname,"r")) ) {
644: input_init(ifp,ifname);
645: if ( !setjmp(env) ) {
646: read_exec_file = 1;
647: read_eval_loop();
648: read_exec_file = 0;
649: }
650: fclose(ifp);
651: }
652: input_init(0,"string");
653: #if !MPI
654: ox_io_init();
655: #endif
656: create_my_mathcap("ox_asir");
657: }
658:
659: static void ox_io_init() {
660: unsigned char c,rc;
661:
662: endian_init();
663: #if defined(VISUAL)
664: if ( !ox_sock_id )
665: exit(0);
666: iofp[0].in = WSIO_open(ox_sock_id,"r");
667: iofp[0].out = WSIO_open(ox_sock_id,"w");
668: #else
669: iofp[0].in = fdopen(3,"r");
670: iofp[0].out = fdopen(4,"w");
671:
672: setbuffer(iofp[0].in,(char *)malloc(LBUFSIZ),LBUFSIZ);
673: setbuffer(iofp[0].out,(char *)malloc(LBUFSIZ),LBUFSIZ);
674: signal(SIGUSR1,ox_usr1_handler);
675: #endif
676: asir_OperandStackSize = BUFSIZ;
677: asir_OperandStack = (Obj *)CALLOC(asir_OperandStackSize,sizeof(Obj));
678: asir_OperandStackPtr = -1;
679: if ( little_endian )
680: c = 1;
681: else
682: c = 0xff;
683: /* server : write -> read */
684: write_char(iofp[0].out,&c); ox_flush_stream_force(0);
685: read_char(iofp[0].in,&rc);
686: iofp[0].conv = c == rc ? 0 : 1;
1.14 ! noro 687: /* XXX; for raw I/O */
! 688: register_server(0,0,0);
1.3 noro 689: }
690:
691: /*
692: * Library mode functions
693: */
694:
695: /*
696: * Converts a binary encoded CMO into a risa object
697: * and pushes it onto the stack.
698: */
699:
700: void asir_ox_push_cmo(void *cmo)
701: {
702: Obj obj;
703:
704: ox_copy_init(cmo);
705: ox_buf_to_obj_as_cmo(&obj);
706: asir_push_one(obj);
707: }
708:
709: /*
710: * Pop an object from the stack and converts it
711: * int a binary encoded CMO.
712: */
713:
714: int asir_ox_pop_cmo(void *cmo, int limit)
715: {
716: Obj obj;
717: int len;
1.11 noro 718: ERR err;
1.3 noro 719:
720: obj = asir_pop_one();
1.10 noro 721: if ( !valid_as_cmo(obj) ) {
1.11 noro 722: asir_push_one(obj);
723: create_error(&err,0,"The object at the stack top is invalid as a CMO.");
724: obj = (Obj)err;
1.10 noro 725: }
1.3 noro 726: len = count_as_cmo(obj);
727: if ( len <= limit ) {
728: ox_copy_init(cmo);
729: ox_obj_to_buf_as_cmo(obj);
730: return len;
731: } else
732: return -1;
733: }
734:
735: /*
736: * Executes an SM command.
737: */
738:
1.13 noro 739: void asir_ox_push_cmd(int cmd)
1.3 noro 740: {
1.7 noro 741: int ret;
742: ERR err;
743: extern char LastError[];
744:
745: if ( ret = setjmp(env) ) {
1.12 noro 746: asir_reset_handler();
1.7 noro 747: if ( ret == 1 ) {
748: create_error(&err,0,LastError); /* XXX */
749: asir_push_one((Obj)err);
750: }
1.12 noro 751: } else {
752: asir_save_handler();
753: asir_set_handler();
1.7 noro 754: asir_do_cmd(cmd,0);
1.12 noro 755: asir_reset_handler();
756: }
1.3 noro 757: }
758:
759: /*
760: * Executes a string written in Asir.
761: */
762:
763: void asir_ox_execute_string(char *s)
764: {
765: STRING str;
1.8 noro 766: int ret;
767: ERR err;
768: extern char LastError[];
1.3 noro 769:
770: MKSTR(str,s);
771: asir_push_one((Obj)str);
1.8 noro 772: if ( ret = setjmp(env) ) {
1.12 noro 773: asir_reset_handler();
1.8 noro 774: if ( ret == 1 ) {
775: create_error(&err,0,LastError); /* XXX */
776: asir_push_one((Obj)err);
777: }
1.12 noro 778: } else {
779: asir_save_handler();
780: asir_set_handler();
1.8 noro 781: asir_executeString();
1.12 noro 782: asir_reset_handler();
783: }
1.3 noro 784: }
785:
786: /*
787: * Returns the size as a CMO of the object
788: * at the top of the stack.
789: */
790:
791: int asir_ox_peek_cmo_size()
792: {
793: Obj obj;
794: int len;
795:
796: obj = asir_pop_one();
1.11 noro 797: asir_push_one(obj);
1.10 noro 798: if ( !valid_as_cmo(obj) ) {
799: fprintf(stderr,"The object at the stack top is invalid as a CMO.\n");
800: return 0;
801: }
1.3 noro 802: len = count_as_cmo(obj);
803: return len;
804: }
805:
806: /*
807: * Initialization.
1.11 noro 808: * byteorder=0 => native
809: * =1 => network byte order
1.3 noro 810: */
811:
1.13 noro 812: int asir_ox_init(int byteorder)
1.3 noro 813: {
814: int tmp;
815: char ifname[BUFSIZ];
816: extern int GC_dont_gc;
817: extern int read_exec_file;
818: extern int do_asirrc;
819: extern int do_server_in_X11;
820: char *getenv();
821: static ox_asir_initialized = 0;
822: FILE *ifp;
823:
824: #if !defined(VISUAL) && !MPI
1.9 noro 825: do_server_in_X11 = 0; /* XXX */
1.3 noro 826: #endif
827: asir_save_handler();
828: #if PARI
829: risa_pari_init();
830: #endif
831: srandom((int)get_current_time());
832:
833: #if defined(THINK_C)
834: param_init();
835: #endif
836: StackBottom = &tmp + 1; /* XXX */
837: rtime_init();
838: env_init();
839: endian_init();
840: #if !defined(VISUAL) && !defined(THINK_C)
841: /* check_key(); */
842: #endif
843: GC_init();
844: /* process_args(argc,argv); */
845: output_init();
846: arf_init();
847: nglob_init();
848: glob_init();
849: sig_init();
850: tty_init();
851: debug_init();
852: pf_init();
853: sysf_init();
854: parif_init();
855: #if defined(VISUAL)
856: init_socket();
857: #endif
858: #if defined(UINIT)
859: reg_sysf();
860: #endif
861: #if defined(THINK_C)
862: sprintf(ifname,"asirrc");
863: #else
864: sprintf(ifname,"%s/.asirrc",getenv("HOME"));
865: #endif
866: if ( do_asirrc && (ifp = fopen(ifname,"r")) ) {
867: input_init(ifp,ifname);
868: if ( !setjmp(env) ) {
869: read_exec_file = 1;
870: read_eval_loop();
871: read_exec_file = 0;
872: }
873: fclose(ifp);
874: }
875: input_init(0,"string");
876:
877: asir_OperandStackSize = BUFSIZ;
878: asir_OperandStack = (Obj *)CALLOC(asir_OperandStackSize,sizeof(Obj));
879: asir_OperandStackPtr = -1;
1.11 noro 880: if ( little_endian && byteorder )
881: lib_ox_need_conv = 1;
1.3 noro 882: else
1.11 noro 883: lib_ox_need_conv = 0;
1.3 noro 884: do_message = 0;
1.11 noro 885: create_my_mathcap("ox_asir");
1.12 noro 886: asir_reset_handler();
1.13 noro 887: return 0;
1.1 noro 888: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>