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