Annotation of OpenXM_contrib2/asir2000/parse/main.c, Revision 1.1.1.1
1.1 noro 1: /* $OpenXM: OpenXM/src/asir99/parse/main.c,v 1.2 1999/11/18 05:42:03 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:
17: double get_current_time();
18: extern int mpi_nprocs,mpi_myid;
19:
20: #if defined(VISUAL_LIB)
21: void Main(argc,argv)
22: #else
23: void ExitAsir() {
24: exit(0);
25: }
26:
27: #if defined(VISUAL)
28: void
29: #endif
30: main(argc,argv)
31: #endif
32: int argc;
33: char *argv[];
34: {
35: int tmp;
36: FILE *ifp;
37: char ifname[BUFSIZ];
38: extern int GC_dont_gc;
39: extern int read_exec_file;
40: extern int do_asirrc;
41: extern int do_file;
42: extern FILE *in_fp;
43: char *getenv();
44: char *homedir;
45: char *slash,*binname;
46:
47: StackBottom = &tmp + 1; /* XXX */
48: #if MPI
49: mpi_init();
50: if ( mpi_myid ) {
51: int slave_argc;
52: char *slave_argv[2];
53:
54: ox_mpi_slave_init();
55: slave_argc = 1;
56: slave_argv[0] = "ox_asir"; slave_argv[1]=0;
57: ox_main(argc,argv);
58: exit(0);
59: } else
60: ox_mpi_master_init();
61: #elif !defined(VISUAL)
62: slash = (char *)rindex(argv[0],'/');
63: if ( slash )
64: binname = slash+1;
65: else
66: binname = argv[0];
67: if ( !strcmp(binname,"ox_asir") ) {
68: /* never return */
69: ox_main(argc,argv);
70: exit(0);
71: } else if ( !strcmp(binname,"ox_plot") ) {
72: /* never return */
73: ox_plot_main(argc,argv);
74: exit(0);
75: } else if ( !strcmp(binname,"ox_launch") ) {
76: /* never return */
77: launch_main(argc,argv);
78: exit(0);
79: }
80: #endif
81:
82: srandom((int)get_current_time());
83: /* mt_sgenrand((unsigned long)get_current_time()); */
84:
85: #if defined(THINK_C)
86: param_init();
87: #endif
88: rtime_init();
89: env_init();
90: endian_init();
91: #if !defined(VISUAL) && !defined(THINK_C)
92: check_key();
93: #endif
94: GC_init();
95: process_args(--argc,++argv);
96: #if PARI
97: risa_pari_init();
98: #endif
99: copyright();
100: output_init();
101: arf_init();
102: nglob_init();
103: glob_init();
104: sig_init();
105: tty_init();
106: debug_init();
107: pf_init();
108: sysf_init();
109: parif_init();
110: #if defined(VISUAL)
111: init_socket();
112: #endif
113: #if defined(UINIT)
114: reg_sysf();
115: #endif
116: #if defined(THINK_C)
117: sprintf(ifname,"asirrc");
118: #else
119: homedir = getenv("HOME");
120: if ( !homedir ) {
121: char rootname[BUFSIZ];
122:
123: get_rootdir(rootname,sizeof(rootname));
124: homedir = rootname;
125: }
126: sprintf(ifname,"%s/.asirrc",homedir);
127: #endif
128: if ( do_asirrc && (ifp = fopen(ifname,"r")) ) {
129: input_init(ifp,ifname);
130: if ( !setjmp(env) ) {
131: read_exec_file = 1;
132: read_eval_loop();
133: read_exec_file = 0;
134: }
135: fclose(ifp);
136: }
137: if ( do_file )
138: input_init(in_fp,"stdin");
139: else
140: input_init(stdin,"stdin");
141: prompt();
142: while ( 1 ) {
143: #if PARI
144: recover(0);
145: if ( setjmp(environnement) ) {
146: avma = top; recover(1);
147: resetenv("");
148: }
149: #endif
150: if ( setjmp(env) )
151: prompt();
152: read_eval_loop();
153: }
154: }
155:
156: #if !defined(VISUAL_LIB)
157: /* a dummy function */
158:
159: void set_error(code,reasion,action)
160: int code;
161: char *reasion,*action;
162: {}
163: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>