diff options
author | rodri <rgl@antares-labs.eu> | 2023-09-21 16:49:11 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-09-21 16:49:11 +0000 |
commit | 497acdd8860d629ba24ed9976fd47eeb743b74ab (patch) | |
tree | 7e8db0be276527ccc0b3d173290655653c8cdd64 /dat.h | |
parent | 33de2d046acfc7ee42fb71b1804b091f671b098a (diff) | |
download | battleship-497acdd8860d629ba24ed9976fd47eeb743b74ab.tar.gz battleship-497acdd8860d629ba24ed9976fd47eeb743b74ab.tar.bz2 battleship-497acdd8860d629ba24ed9976fd47eeb743b74ab.zip |
add parsecmd to the server.
modified it to allow for commands with the same name but different nargs.
now each match list entry is preceded by an 'm', to simplify its processing.
note that this breaks the client. the next commit will fix that.
Diffstat (limited to 'dat.h')
-rw-r--r-- | dat.h | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -129,9 +129,30 @@ struct Menulist char *title; Rectangle r, sr; /* content and scroll rects */ int high; /* [-1,nitems) where -1 is none */ + int off; /* entry offset ∈ [0, nitems-Maxvisitems] */ void (*add)(Menulist*, int, char*); void (*clear)(Menulist*); - void (*update)(Menulist*, Mousectl*); + int (*update)(Menulist*, Mousectl*, Channel*); void (*draw)(Menulist*, Image*); }; + +/* + * Kernel-style command parser + */ +typedef struct Cmdbuf Cmdbuf; +typedef struct Cmdtab Cmdtab; + +struct Cmdbuf +{ + char *buf; + char **f; + int nf; +}; + +struct Cmdtab +{ + int index; /* used by client to switch on result */ + char *cmd; /* command name */ + int narg; /* expected #args; 0 ==> variadic */ +}; |