int ns__opbx_cli_command(struct soap *soap, char *command, char **results) { char *cmds[5]; cmds[0] = command; struct opbx_cli_entry *e = NULL; e = find_cli(command, 0); if ( e != NULL ) { opbx_mutex_lock(&clilock); e->inuse++; opbxx_mutex_unlock(&clilock); } else { printf("Error\n"); return SOAP_OK; } return SOAP_OK; } Was this function: int opbx_cli_command(int fd, char *s) { char *argv[OPBX_MAX_ARGS]; struct opbx_cli_entry *e; int x; char *dup; int tws; if ((dup = parse_args(s, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws))) { /* We need at least one entry, or ignore */ if (x > 0) { opbx_mutex_lock(&clilock); e = find_cli(argv, 0); if (e) e->inuse++; opbx_mutex_unlock(&clilock); if (e) { switch(e->handler(fd, x, argv)) { case RESULT_SHOWUSAGE: opbx_cli(fd, "%s", e->usage); break; } } else opbx_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv)); if (e) { opbx_mutex_lock(&clilock); e->inuse--; opbx_mutex_unlock(&clilock); } } free(dup); } else { opbx_log(LOG_WARNING, "Out of memory\n"); return -1; } return 0; }