Annotation of OpenXM_contrib2/asir2000/parse/asir_lib.c, Revision 1.1.1.1
1.1 noro 1: /* $OpenXM: OpenXM/src/asir99/parse/asir_lib.c,v 1.1.1.1 1999/11/10 08:12:34 noro Exp $ */
2: #include "ca.h"
3: #include "parse.h"
4: #if defined(THINK_C)
5: #include <console.h>
6: #endif
7:
8: #if PARI
9: #include "genpari.h"
10:
11: extern jmp_buf environnement;
12: #endif
13:
14: extern jmp_buf env;
15: extern int *StackBottom;
16: extern char *parse_strp;
17: extern int do_file;
18:
19: void Init_Asir(int,char **);
20: int Call_Asir(char *,pointer *);
21:
22: void Init_Asir(int argc,char **argv)
23: {
24: int tmp;
25: FILE *ifp;
26: char ifname[BUFSIZ];
27: extern int GC_dont_gc;
28: extern int read_exec_file;
29: extern int do_asirrc;
30: char *getenv();
31: static asirlib_initialized=0;
32:
33: if ( asirlib_initialized )
34: return;
35: asirlib_initialized = 1;
36: do_file = 1;
37: #if PARI
38: risa_pari_init();
39: #endif
40: srandom((int)get_current_time());
41: /* mt_sgenrand((unsigned long)get_current_time()); */
42:
43: #if defined(THINK_C)
44: param_init();
45: #endif
46: StackBottom = &tmp + 1; /* XXX */
47: rtime_init();
48: env_init();
49: endian_init();
50: #if !defined(VISUAL) && !defined(THINK_C)
51: /* check_key(); */
52: #endif
53: GC_init();
54: process_args(--argc,++argv);
55: copyright();
56: output_init();
57: arf_init();
58: nglob_init();
59: glob_init();
60: sig_init();
61: tty_init();
62: debug_init();
63: pf_init();
64: sysf_init();
65: parif_init();
66: #if defined(UINIT)
67: reg_sysf();
68: #endif
69: #if defined(THINK_C)
70: sprintf(ifname,"asirrc");
71: #else
72: sprintf(ifname,"%s/.asirrc",getenv("HOME"));
73: #endif
74: if ( do_asirrc && (ifp = fopen(ifname,"r")) ) {
75: input_init(ifp,ifname);
76: if ( !setjmp(env) ) {
77: read_exec_file = 1;
78: read_eval_loop();
79: read_exec_file = 0;
80: }
81: fclose(ifp);
82: } else
83: error(".asirrc not found");
84: input_init(0,"string");
85: }
86:
87: int Call_Asir(char *cmd,pointer *result)
88: {
89: SNODE snode;
90: pointer val;
91: #if PARI
92: recover(0);
93: if ( setjmp(environnement) ) {
94: avma = top; recover(1);
95: error("PARI error");
96: }
97: #endif
98: if ( setjmp(env) ) {
99: *result = 0;
100: return -1;
101: }
102: parse_strp = cmd;
103: if ( mainparse(&snode) ) {
104: *result = 0;
105: return -1;
106: }
107: val = evalstat(snode);
108: if ( NEXT(asir_infile) ) {
109: while ( NEXT(asir_infile) ) {
110: if ( mainparse(&snode) ) {
111: *result = val;
112: return -1;
113: }
114: nextbp = 0;
115: val = evalstat(snode);
116: }
117: }
118: *result = val;
119: return 0;
120: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>