void lrc_configure(void) { char *inbuf, *s, *e; inbuf = lrc_getenv(LRC_CONFIG_ENV); if (!inbuf || !inbuf[0]) { log_print(LL_OINFO, "no config options supplied\n"); return; } debug("config string: %s\n", inbuf); s = inbuf; do { int i; e = lrc_strchrnul(s, delim); for (i = 0; i < arrsz(opts); i++) if (!lrc_strncmp(opts[i].name, s, lrc_strlen(opts[i].name)) && (*e == delim || !*e)) { opts[i].parse(&opts[i], s, e - s); break; } if (i == arrsz(opts) && e != s) log_print(LL_OWARN, "unknown option: %.*s\n", e - s, s); s = e + 1; } while (*e); }
int cmd_do(const unsigned char* cmd, const unsigned char* data, unsigned int sz) { int i; for (i=0; i < arrsz(_cmdtbl); i++) if (0 == strcmp(_cmdtbl[i].cmd, (char*)cmd)) return (*_cmdtbl[i].func)(data, sz); printf("Invalid command : %s\n", cmd); return -1; }