Annotation of OpenXM_contrib2/asir2000/parse/main.c, Revision 1.7
1.4 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.5 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.4 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
47: *
1.7 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/parse/main.c,v 1.6 2000/11/14 08:38:40 noro Exp $
1.4 noro 49: */
1.1 noro 50: #include "ca.h"
51: #include "parse.h"
52: #if defined(THINK_C)
53: #include <console.h>
54: #endif
55:
56: #if PARI
57: #include "genpari.h"
58:
59: extern jmp_buf environnement;
60: #endif
61:
62: extern jmp_buf env;
63:
64: double get_current_time();
65: extern int mpi_nprocs,mpi_myid;
66:
1.7 ! noro 67: #if MPI
! 68: int *StackBottom;
! 69: #endif
! 70:
1.1 noro 71: #if defined(VISUAL_LIB)
72: void Main(argc,argv)
73: #else
74: #if defined(VISUAL)
75: void
76: #endif
77: main(argc,argv)
78: #endif
79: int argc;
80: char *argv[];
81: {
82: int tmp;
83: FILE *ifp;
84: char ifname[BUFSIZ];
85: extern int GC_dont_gc;
86: extern int read_exec_file;
87: extern int do_asirrc;
88: extern int do_file;
89: extern FILE *in_fp;
90: char *getenv();
91: char *homedir;
92: char *slash,*binname;
1.2 noro 93: char *ptr;
1.1 noro 94:
95: #if MPI
1.7 ! noro 96: StackBottom = &tmp;
1.1 noro 97: mpi_init();
98: if ( mpi_myid ) {
99: int slave_argc;
100: char *slave_argv[2];
101:
102: ox_mpi_slave_init();
103: slave_argc = 1;
104: slave_argv[0] = "ox_asir"; slave_argv[1]=0;
105: ox_main(argc,argv);
106: exit(0);
107: } else
108: ox_mpi_master_init();
109: #elif !defined(VISUAL)
110: slash = (char *)rindex(argv[0],'/');
111: if ( slash )
112: binname = slash+1;
113: else
114: binname = argv[0];
115: if ( !strcmp(binname,"ox_asir") ) {
116: /* never return */
117: ox_main(argc,argv);
118: exit(0);
1.3 noro 119: #if DO_PLOT
1.1 noro 120: } else if ( !strcmp(binname,"ox_plot") ) {
121: /* never return */
122: ox_plot_main(argc,argv);
123: exit(0);
1.3 noro 124: #endif
1.1 noro 125: } else if ( !strcmp(binname,"ox_launch") ) {
126: /* never return */
127: launch_main(argc,argv);
128: exit(0);
129: }
130: #endif
131:
132: srandom((int)get_current_time());
133: /* mt_sgenrand((unsigned long)get_current_time()); */
134:
135: #if defined(THINK_C)
136: param_init();
137: #endif
138: rtime_init();
139: env_init();
140: endian_init();
1.4 noro 141: #if 0 && !defined(VISUAL) && !defined(THINK_C)
1.1 noro 142: check_key();
143: #endif
144: GC_init();
145: process_args(--argc,++argv);
146: #if PARI
147: risa_pari_init();
148: #endif
149: copyright();
150: output_init();
151: arf_init();
152: nglob_init();
153: glob_init();
154: sig_init();
155: tty_init();
156: debug_init();
157: pf_init();
158: sysf_init();
159: parif_init();
160: #if defined(VISUAL)
161: init_socket();
162: #endif
163: #if defined(UINIT)
164: reg_sysf();
165: #endif
1.2 noro 166:
167: /* if ASIR_CONFIG is set, execute it; else execute .asirrc */
168: if ( ptr = getenv("ASIR_CONFIG") )
169: strcpy(ifname,ptr);
170: else {
1.1 noro 171: #if defined(THINK_C)
1.2 noro 172: sprintf(ifname,"asirrc");
1.1 noro 173: #else
1.2 noro 174: homedir = getenv("HOME");
175: if ( !homedir ) {
176: char rootname[BUFSIZ];
1.1 noro 177:
1.2 noro 178: get_rootdir(rootname,sizeof(rootname));
179: homedir = rootname;
180: }
181: sprintf(ifname,"%s/.asirrc",homedir);
182: #endif
1.1 noro 183: }
1.2 noro 184:
1.1 noro 185: if ( do_asirrc && (ifp = fopen(ifname,"r")) ) {
186: input_init(ifp,ifname);
187: if ( !setjmp(env) ) {
188: read_exec_file = 1;
189: read_eval_loop();
190: read_exec_file = 0;
191: }
192: fclose(ifp);
193: }
1.2 noro 194:
1.1 noro 195: if ( do_file )
196: input_init(in_fp,"stdin");
197: else
198: input_init(stdin,"stdin");
199: prompt();
200: while ( 1 ) {
201: #if PARI
202: recover(0);
203: if ( setjmp(environnement) ) {
204: avma = top; recover(1);
205: resetenv("");
206: }
207: #endif
208: if ( setjmp(env) )
209: prompt();
210: read_eval_loop();
211: }
212: }
213:
214: #if !defined(VISUAL_LIB)
215: /* a dummy function */
216:
217: void set_error(code,reasion,action)
218: int code;
219: char *reasion,*action;
220: {}
221: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>