int main(){ char input[100], c; int i, j, k; struct command_t cmd[100]; for(i = 0, k = 1; i < 101; i++){ scanf("%[^\n]%c", input, &c); cmd[i].code = exec_cmd(cmd, input, i); if(cmd[i].code == 0){ find_result(cmd, i); k++; } if(input[i] == '\n' && c == '\n'){ break; } } for(j = 0; j < k; j++){ if(cmd[j].code == 0 && cmd[j].result != 42) printf("%d", cmd[j].result); else if(cmd[j].code == 0 && cmd[j].result == 42) printf("the answer to life, the universe and everything else"); else if(cmd[j].code == -1) printf("operation not supported"); else if(cmd[j].code == -2) printf("invalid command argument count"); else if(cmd[j].code == -3) printf("invalid command arguments"); else if(cmd[j].code == -4) printf("invalid input"); else if(cmd[j].code == -5) printf("invalid arithmetic operation"); if(j != k-1) printf("\n"); } return 0; }
intptr_t stubbed_result(const char *function) { RecordedResult *result = find_result(function); if (result == NULL) { return 0; } intptr_t value = result->result; if (! result->should_keep) { free(result); } return value; }
/*! \brief SPEECH_SCORE() Dialplan Function */ static int speech_score(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { struct ast_speech_result *result = NULL; struct ast_speech *speech = find_speech(chan); char tmp[128] = ""; if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) return -1; snprintf(tmp, sizeof(tmp), "%d", result->score); ast_copy_string(buf, tmp, len); return 0; }
/*! \brief SPEECH_GRAMMAR() Dialplan Function */ static int speech_grammar(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { struct ast_speech_result *result = NULL; struct ast_speech *speech = find_speech(chan); if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) return -1; if (result->grammar != NULL) { ast_copy_string(buf, result->grammar, len); } else { buf[0] = '\0'; } return 0; }