/*
* Copyright 1987, 1988, 1989 by Massachusetts Institute of Technology
*
- * For copyright info, see copyright.h.
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose is hereby granted, provided that
+ * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. M.I.T. and the
+ * M.I.T. S.I.P.B. make no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without
+ * express or implied warranty.
*/
+#include "config.h"
#ifdef HAS_STDLIB_H
#include <stdlib.h>
#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#else
+extern int errno;
+#endif
#include "ss_internal.h"
-#include "copyright.h"
#include <stdio.h>
+static int check_request_table PROTOTYPE((ss_request_table *rqtbl, int argc,
+ char *argv[], int sci_idx));
+static int really_execute_command PROTOTYPE((int sci_idx, int argc,
+ char **argv[]));
+
/*
* get_request(tbl, idx)
*
char *line_ptr;
{
char **argv;
- int argc;
+ int argc, ret;
/* flush leading whitespace */
while (line_ptr[0] == ' ' || line_ptr[0] == '\t')
return SS_ET_ESCAPE_DISABLED;
else {
line_ptr++;
- system(line_ptr);
- return 0;
+ return (system(line_ptr) < 0) ? errno : 0;
}
}
/* parse it */
argv = ss_parse(sci_idx, line_ptr, &argc);
- if (argc == 0)
+ if (argc == 0) {
+ free(argv);
return 0;
+ }
/* look it up in the request tables, execute if found */
- return really_execute_command (sci_idx, argc, &argv);
+ ret = really_execute_command (sci_idx, argc, &argv);
+
+ free(argv);
+
+ return(ret);
}