add CS_ERR_OPTION type. cs_option() returns this error code on invalid option

This commit is contained in:
Nguyen Anh Quynh 2013-12-06 00:37:32 +08:00
parent f9e3216568
commit 041e25dd66
2 changed files with 14 additions and 8 deletions

10
cs.c
View File

@ -209,20 +209,24 @@ cs_err cs_option(csh ud, cs_opt_type type, size_t value)
switch (handle->arch) {
default:
break;
return CS_ERR_OPTION;
case CS_ARCH_X86:
if (type & CS_OPT_SYNTAX) {
switch(value) {
default:
break;
return CS_ERR_OPTION;
case CS_OPT_SYNTAX_INTEL:
handle->printer = X86_Intel_printInst;
break;
case CS_OPT_SYNTAX_ATT:
handle->printer = X86_ATT_printInst;
break;
}
}
} else
return CS_ERR_OPTION;
break;
}

View File

@ -104,14 +104,16 @@ typedef struct cs_insn {
// These are values returned by cs_errno()
typedef enum cs_err {
CS_ERR_OK = 0, // No error: everything was fine
CS_ERR_MEM, // Out-Of-Memory error
CS_ERR_ARCH, // Unsupported architecture
CS_ERR_HANDLE, // Invalid handle
CS_ERR_CSH, // Invalid csh argument
CS_ERR_MODE, // Invalid/unsupported mode
CS_ERR_MEM, // Out-Of-Memory error: cs_open(), cs_disasm_dyn()
CS_ERR_ARCH, // Unsupported architecture: cs_open()
CS_ERR_HANDLE, // Invalid handle: cs_op_count(), cs_op_index()
CS_ERR_CSH, // Invalid csh argument: cs_close(), cs_errno(), cs_option()
CS_ERR_MODE, // Invalid/unsupported mode: cs_open()
CS_ERR_OPTION, // Invalid/unsupported option: cs_option()
} cs_err;
/*
Return API version in major and minor numbers.