File: shmain.c

package info (click to toggle)
pact 980714-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 13,096 kB
  • ctags: 26,034
  • sloc: ansic: 109,076; lisp: 9,645; csh: 7,147; fortran: 1,050; makefile: 136; lex: 95; sh: 32
file content (93 lines) | stat: -rw-r--r-- 2,362 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * SHMAIN.C - the function main which when loaded with the SCHEME library
 *          - package gives a working Scheme
 *
 * Source Version: 4.0
 * Software Release #92-0043
 *
 */

#include "cpyright.h"

#include "scheme.h"

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* MAIN - a fairly vanilla place to start up a Scheme */

int main(argc, argv)
   int argc;
   char **argv;
   {char command[MAXLINE];
    int i, load_sch = 0;
    int runt_flag = TRUE;
    int command_flag = FALSE;

    SC_init("ABORT: Gross Initialization Error", (PFByte) SS_end_scheme,
            TRUE, SS_interrupt_handler,
            TRUE, NULL, 0);

#ifdef MAC
    runt_flag = FALSE;

/* connect the I/O functions */
    PG_open_console("PACT Scheme", "MONOCHROME", 1, 0.1, 0.1, 0.8, 0.8);

#endif

/* process the command line arguments */
    for (i = 1; i < argc; i++)
        if (argv[i][0] == '-')
           {switch (argv[i][1])
               {case 'l' : load_sch = ++i;              /* load Scheme file */
                           break;
                case 'r' : runt_flag = FALSE;     /* don't load full Scheme */
                           break;};}
        else
           {command_flag = TRUE;
            strcpy(command, " ");
            for ( ; i < argc; i++)
                {strcat(command, argv[i]);
                 strcat(command, " ");};};

/* Initialize the Scheme system */
    SS_init_scheme(CODE, VERSION);

/* load the full Scheme */
    if (runt_flag)
       SS_load_scm("runt.scm");

/* read the optionally specified load file */ 
    if (load_sch != 0)
       SS_load_scm(argv[load_sch]);

    SS_nsave    = 0;
    SS_nrestore = 0;
    SS_nsetc    = 0;
    SS_ngoc     = 0;

    SC_mem_stats_set(0L, 0L);

/* this is where interface special variables are initialized */
/*
    SS_pr_ch_in  = SS_get_ch;
    SS_pr_ch_un  = SS_unget_ch;
    SS_pr_ch_out = SS_put_ch;
*/

    if (command_flag)
       {int ret;

        PRINT(STDOUT, "\n\n");
	ret = SS_run(command);
	PRINT(STDOUT, "\n\n");
	return(!ret);}
    else
       {SC_banner("");
        SS_repl();};

    return(0);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/