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