| 1 |
/* |
| 2 |
* Ikarus Scheme -- A compiler for R6RS Scheme. |
| 3 |
* Copyright (C) 2006,2007,2008 Abdulaziz Ghuloum |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License version 3 as |
| 7 |
* published by the Free Software Foundation. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, but |
| 10 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
* General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include "ikarus-main.h" |
| 21 |
#include "bootfileloc.h" |
| 22 |
#include <stdio.h> |
| 23 |
#include <string.h> |
| 24 |
#include <stdio.h> |
| 25 |
#include <stdlib.h> |
| 26 |
|
| 27 |
void ikarus_usage_short(){ |
| 28 |
fprintf(stderr, "ikarus -h for more help\n"); |
| 29 |
} |
| 30 |
|
| 31 |
void ikarus_usage(){ |
| 32 |
static char* helpstring = |
| 33 |
"\n\ |
| 34 |
Options for running ikarus scheme:\n\ |
| 35 |
\n ikarus -h\n\ |
| 36 |
Prints this help message then exits.\n\ |
| 37 |
\n ikarus [-b <bootfile>] --r6rs-script <scriptfile> opts ...\n\ |
| 38 |
Starts ikarus in r6rs-script mode. The script file is treated\n\ |
| 39 |
as an R6RS-script. The options opts ... can be obtained using\n\ |
| 40 |
the \"command-line\" procedure in the (rnrs programs) library.\n\ |
| 41 |
\n ikarus [-b <bootfile>] <file> ... [-- opts ...]\n\ |
| 42 |
Starts ikarus in interactive mode. Each of the files is first\n\ |
| 43 |
loaded into the interaction environment before the interactive\n\ |
| 44 |
repl is started. The options opts can be obtained using the\n\ |
| 45 |
\"command-line\" procedure.\n\ |
| 46 |
\n\ |
| 47 |
If the option [-b <bootfile>] is provided, the bootfile is used\n\ |
| 48 |
as the system's initial boot file from which the environment is\n\ |
| 49 |
initialized. If the -b option is not supplied, the default boot\n\ |
| 50 |
file is used. The current default boot file location is\n\ |
| 51 |
\"%s\".\n\ |
| 52 |
Consult the Ikarus Scheme User's Guide for more details.\n\n"; |
| 53 |
fprintf(stderr, helpstring, BOOTFILE); |
| 54 |
} |
| 55 |
|
| 56 |
int main(int argc, char** argv){ |
| 57 |
char* boot_file = BOOTFILE; |
| 58 |
if (((argc >= 2) && (strcmp(argv[1], "-h") == 0)) || |
| 59 |
((argc == 2) && (strcmp(argv[1], "-b") == 0))) { |
| 60 |
ikarus_usage(); |
| 61 |
exit(0); |
| 62 |
} |
| 63 |
|
| 64 |
if ((argc >= 3) && (strcmp(argv[1], "-b") == 0)){ |
| 65 |
boot_file = argv[2]; |
| 66 |
int i; |
| 67 |
for(i=3; i<=argc; i++){ |
| 68 |
argv[i-2] = argv[i]; |
| 69 |
} |
| 70 |
argc -= 2; |
| 71 |
} |
| 72 |
return ikarus_main(argc, argv, boot_file); |
| 73 |
} |
| 74 |
|
| 75 |
|