+/* Convert a --command into the equivalent ICL command and call
+ execute_icl_command(). The dashes have already been stripped.
+
+ The second argument is the following command-line argument
+ (or NULL if there was none). This may or may not be consumed.
+ Returns TRUE if it was.
+*/
+static int execute_dashdash_command(char *p, char *p2)
+{
+ char cli_buff[CMD_BUF_SIZE];
+ int consumed2 = FALSE;
+
+ if (!strcmp(p, "help")) {
+ strcpy(cli_buff, "-h");
+ }
+ else if (!strcmp(p, "list")) {
+ strcpy(cli_buff, "$LIST");
+ }
+ else if (!strcmp(p, "size")) {
+ consumed2 = TRUE;
+ /* We accept these arguments even though they've been withdrawn. */
+ if (!(p2 && (!strcmpcis(p2, "HUGE") || !strcmpcis(p2, "LARGE") || !strcmpcis(p2, "SMALL")))) {
+ printf("--size must be followed by \"huge\", \"large\", or \"small\"\n");
+ return consumed2;
+ }
+ strcpy(cli_buff, "$");
+ strcpyupper(cli_buff+1, p2, CMD_BUF_SIZE-1);
+ }
+ else if (!strcmp(p, "opt")) {
+ consumed2 = TRUE;
+ if (!p2 || !strchr(p2, '=')) {
+ printf("--opt must be followed by \"setting=number\"\n");
+ return consumed2;
+ }
+ strcpy(cli_buff, "$");
+ strcpyupper(cli_buff+1, p2, CMD_BUF_SIZE-1);
+ }
+ else if (!strcmp(p, "helpopt")) {
+ consumed2 = TRUE;
+ if (!p2) {
+ printf("--helpopt must be followed by \"setting\"\n");
+ return consumed2;
+ }
+ strcpy(cli_buff, "$?");
+ strcpyupper(cli_buff+2, p2, CMD_BUF_SIZE-2);
+ }
+ else if (!strcmp(p, "define")) {
+ consumed2 = TRUE;
+ if (!p2) {
+ printf("--define must be followed by \"symbol=number\"\n");
+ return consumed2;
+ }
+ strcpy(cli_buff, "$#");
+ strcpyupper(cli_buff+2, p2, CMD_BUF_SIZE-2);
+ }
+ else if (!strcmp(p, "path")) {
+ consumed2 = TRUE;
+ if (!p2 || !strchr(p2, '=')) {
+ printf("--path must be followed by \"name=path\"\n");
+ return consumed2;
+ }
+ snprintf(cli_buff, CMD_BUF_SIZE, "+%s", p2);
+ }
+ else if (!strcmp(p, "addpath")) {
+ consumed2 = TRUE;
+ if (!p2 || !strchr(p2, '=')) {
+ printf("--addpath must be followed by \"name=path\"\n");
+ return consumed2;
+ }
+ snprintf(cli_buff, CMD_BUF_SIZE, "++%s", p2);
+ }
+ else if (!strcmp(p, "config")) {
+ consumed2 = TRUE;
+ if (!p2) {
+ printf("--config must be followed by \"file.icl\"\n");
+ return consumed2;
+ }
+ snprintf(cli_buff, CMD_BUF_SIZE, "(%s)", p2);
+ }
+ else if (!strcmp(p, "trace")) {
+ consumed2 = TRUE;
+ if (!p2) {
+ printf("--trace must be followed by \"traceopt\" or \"traceopt=N\"\n");
+ return consumed2;
+ }
+ snprintf(cli_buff, CMD_BUF_SIZE, "$!%s", p2);
+ }
+ else if (!strcmp(p, "helptrace")) {
+ strcpy(cli_buff, "$!");
+ }
+ else {
+ printf("Option \"--%s\" unknown (try \"inform -h\")\n", p);
+ return FALSE;
+ }
+
+ execute_icl_command(cli_buff);
+ return consumed2;
+}
+