chiark / gitweb /
better unknown-command handling
authorian <ian>
Fri, 23 May 2008 21:50:31 +0000 (21:50 +0000)
committerian <ian>
Fri, 23 May 2008 21:50:31 +0000 (21:50 +0000)
hostside/README.commands
hostside/commands.c
hostside/common.h
hostside/realtime.c

index 8dd2be7e3771e284d10bb8e2fa5c4e3d0f0f4c58..4ca65b7a184e04a94545161cee007bf634f4ceb0 100644 (file)
@@ -81,6 +81,7 @@ COMMANDS AND RESPONSES
 
  P> <command> [<arguments>...]
   results in:
+ R< ?nak unknown-command|permission-denied|invalid-syntax [: <message...>]
  R< ?executing <command> [<arguments>...]
   consequential messages including picio, signalling problems etc.
   then one of these
@@ -110,7 +111,7 @@ MULTIPLEXER FACILITIES
   or
  M< =denied
   and later perhaps
- M< =failing : <message>
+ M< =failed : <message>
   otherwise there is no need to quit - just send eof
 
  M< select [~]<glob-pattern>...
@@ -129,8 +130,7 @@ MULTIPLEXER FACILITIES
 MULTIPLEXER-IMPLEMENTED FUNCTIONALITY AFFECTING WHOLE SYSTEM
 
  P> [!]<command> <args>...
- R< ?executing [!]<command>
- R< ?ack [!]<command> ok
+ R< ?nak|executing...ack...  as above
 
  C> !realtime kill|finish|start|start-manual
  C> !save
index b3b8bb2be796d33890ec136ff7db2e9759c48ce7..f590ce43fc6d55c022c93f378348c70a2eba3bd8 100644 (file)
@@ -307,8 +307,14 @@ void command_doline(ParseState *ps, CommandInput *cmdi_arg) {
   simlog("command-in %s\n",ps->remain);
   simlog_flush();
   current_cmd= 0;
-  current_cmd= some_needword_lookup(ps, toplevel_cmds, "command");
-  if (!current_cmd) return;
+
+  if (!ps->remain[0]) return;
+  r= ps_word(ps);  assert(!r);
+  current_cmd= some_lookup(ps,toplevel_cmds);
+  if (!current_cmd) {
+    oprintf(UPO,"nack unknown-command\n");
+    return;
+  }
   oprintf(UPO, "executing %s\n",current_cmd->name);
   if (sta_state < Sta_Run && !(current_cmd->xarg & CIXF_ANYSTA)) {
     oprintf(UPO,"ack %s InvalidState : layout not ready\n",current_cmd->name);
index 6983e1f512a63935b56dcc3a7b8472586e3cdb14..e0cccd946781a3ad7e6ba592f585c3de144f363c 100644 (file)
@@ -71,7 +71,7 @@ int ps_neednoargs(ParseState *ps);
 
 #define some_lookup(ps, infos)                 \
   ((const typeof(infos[0])*)                   \
-   any_lookup((ps),(infos),sizeof((infos)[0])))
+   any_lookup((ps),(infos),INT_MAX,sizeof((infos)[0])))
 
 #define some_needword_lookup_counted(ps, infos, ninfos, what)  \
   ((const typeof(infos[0])*)                                   \
index 1dd2f418172ba15eb34533cd25ecf398e70d7253..f001b1d5ad183f761e89a1baaf3186835e2ed93f 100644 (file)
@@ -334,6 +334,7 @@ int main(int argc, const char **argv) {
          default: badusage("unknown -R suboption");
          }
        }
+       arg= 0;
        break;
       default: badusage("unknown option");
       }