[BACK]Return to main.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / parse

Annotation of OpenXM_contrib2/asir2000/parse/main.c, Revision 1.3

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>