Skip to content

Commit

Permalink
Fix indentation problem
Browse files Browse the repository at this point in the history
  • Loading branch information
danghvu committed Dec 20, 2013
1 parent 34d49d9 commit 2b19296
Showing 1 changed file with 79 additions and 79 deletions.
158 changes: 79 additions & 79 deletions cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ cs_err cs_errno(csh handle)

cs_err cs_open(cs_arch arch, cs_mode mode, csh *handle)
{
cs_struct *ud;
cs_struct *ud;

ud = calloc(1, sizeof(*ud));
if (!ud) {
// memory insufficient
return CS_ERR_MEM;
}
ud = calloc(1, sizeof(*ud));
if (!ud) {
// memory insufficient
return CS_ERR_MEM;
}

ud->errnum = CS_ERR_OK;
ud->arch = arch;
ud->mode = mode;
ud->big_endian = mode & CS_MODE_BIG_ENDIAN;
ud->reg_name = NULL;
ud->detail = CS_OPT_ON; // by default break instruction into details
ud->errnum = CS_ERR_OK;
ud->arch = arch;
ud->mode = mode;
ud->big_endian = mode & CS_MODE_BIG_ENDIAN;
ud->reg_name = NULL;
ud->detail = CS_OPT_ON; // by default break instruction into details

init_arch[ud->arch](ud);
init_arch[ud->arch](ud);

*handle = (uintptr_t)ud;
*handle = (uintptr_t)ud;

return CS_ERR_OK;
return CS_ERR_OK;
}

cs_err cs_close(csh handle)
Expand Down Expand Up @@ -129,75 +129,75 @@ static void fill_insn(cs_struct *handle, cs_insn *insn, char *buffer, MCInst *mc

cs_err cs_option(csh ud, cs_opt_type type, size_t value)
{
cs_struct *handle = (cs_struct *)(uintptr_t)ud;
if (!handle)
return CS_ERR_CSH;

switch(type) {
default:
break;
case CS_OPT_DETAIL:
handle->detail = value;
return CS_ERR_OK;
case CS_OPT_SYNTAX:
switch (handle->arch) {
default:
// only selected archs care about CS_OPT_SYNTAX
handle->errnum = CS_ERR_OPTION;
return CS_ERR_OPTION;
cs_struct *handle = (cs_struct *)(uintptr_t)ud;
if (!handle)
return CS_ERR_CSH;

switch(type) {
default:
break;
case CS_OPT_DETAIL:
handle->detail = value;
return CS_ERR_OK;
case CS_OPT_SYNTAX:
switch (handle->arch) {
default:
// only selected archs care about CS_OPT_SYNTAX
handle->errnum = CS_ERR_OPTION;
return CS_ERR_OPTION;

#ifdef CS_SUPPORT_X86
case CS_ARCH_X86:
switch(value) {
default:
// wrong syntax value
handle->errnum = CS_ERR_OPTION;
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;
}
break;
case CS_ARCH_X86:
switch(value) {
default:
// wrong syntax value
handle->errnum = CS_ERR_OPTION;
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;
}
break;
#endif
}
break;

case CS_OPT_MODE: // change engine's mode at run-time
handle->mode = value;
switch (handle->arch) {
default:
// only selected archs care about CS_OPT_SYNTAX
break;
}
break;

case CS_OPT_MODE: // change engine's mode at run-time
handle->mode = value;
switch (handle->arch) {
default:
// only selected archs care about CS_OPT_SYNTAX
break;
#ifdef CS_SUPPORT_ARM
case CS_ARCH_ARM:
if (value & CS_MODE_THUMB)
handle->disasm = Thumb_getInstruction;
else
handle->disasm = ARM_getInstruction;

handle->mode = value;
break;
case CS_ARCH_ARM:
if (value & CS_MODE_THUMB)
handle->disasm = Thumb_getInstruction;
else
handle->disasm = ARM_getInstruction;

handle->mode = value;
break;
#endif
#ifdef CS_SUPPORT_AARCH64
case CS_ARCH_MIPS:
if (value & CS_MODE_32)
handle->disasm = Mips_getInstruction;
else
handle->disasm = Mips64_getInstruction;

handle->mode = value;
break;
#ifdef CS_SUPPORT_AARCH64t
case CS_ARCH_MIPS:
if (value & CS_MODE_32)
handle->disasm = Mips_getInstruction;
else
handle->disasm = Mips64_getInstruction;

handle->mode = value;
break;
#endif
}
break;
}
}
break;
}

return CS_ERR_OK;
return CS_ERR_OK;
}

size_t cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, size_t count, cs_insn *insn)
Expand All @@ -217,7 +217,7 @@ size_t cs_disasm(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, si
memset(insn, 0, count * sizeof(*insn));

while (size > 0) {
MCInst_Init(&mci);
MCInst_Init(&mci);
mci.detail = handle->detail;
mci.mode = handle->mode;

Expand Down Expand Up @@ -279,7 +279,7 @@ size_t cs_disasm_dyn(csh ud, const uint8_t *buffer, size_t size, uint64_t offset
memset(insn_cache, 0, sizeof(insn_cache));

while (size > 0) {
MCInst_Init(&mci);
MCInst_Init(&mci);
mci.detail = handle->detail;
mci.mode = handle->mode;

Expand Down

0 comments on commit 2b19296

Please sign in to comment.