/* $Header: /CVSROOT/debris/driscmds.h,v 1.2 2005/07/25 03:14:07 tino Exp $ * * DebRIS: DEBian Remote Install Scripter * Builtin commands * * $Log: driscmds.h,v $ * Revision 1.2 2005/07/25 03:14:07 tino * cmds/ directory added * * Revision 1.1 2005/06/01 02:12:34 tino * first version. As SirbeD is missing, this just does nothing yet. */ #include #include "cmds/gen-inc.h" static struct { char *cmd; int (*fn)(char *args); } dris_commands[] = { #include "cmds/gen-fn.h" { NULL } }; /* Execute a command */ static int dris_cmd(void) { int i; char *cmd; dris_buf_reset(config.out); for (i=0; config.in->buf[i]; i++) if (config.in->buf[i]=='\r' && config.in->buf[i+1]=='\n') { config.in->buf[i] = 0; i += 2; break; } config.data = i; cmd = config.in->buf; for (i=0; dris_commands[i].cmd; i++) { size_t n; n = strlen(dris_commands[i].cmd); if (!strncmp(cmd, dris_commands[i].cmd, n) && (cmd[n] || isspace(cmd[n]))) { cmd += n; while (*cmd && isspace(*cmd)) cmd++; DP(("command %s, additional data %d: %s", dris_commands[i].cmd, config.in->len-config.data, cmd)); return dris_commands[i].fn(cmd); } } return waitfor(forkcmd()); }