| 1 | /* Capstone Disassembly Engine */ |
| 2 | /* By Nguyen Anh Quynh <[email protected]>, 2013-2019 */ |
| 3 | |
| 4 | #ifndef CS_SSTREAM_H_ |
| 5 | #define CS_SSTREAM_H_ |
| 6 | |
| 7 | #include "include/capstone/platform.h" |
| 8 | |
| 9 | #define SSTREAM_BUF_LEN 512 |
| 10 | |
| 11 | #define SSTREAM_OVERFLOW_CHECK(OS, len) \ |
| 12 | do { \ |
| 13 | if (OS->index + len + 1 > SSTREAM_BUF_LEN) { \ |
| 14 | fprintf(stderr, "Buffer overflow caught!\n"); \ |
| 15 | return; \ |
| 16 | } \ |
| 17 | } while (0) |
| 18 | |
| 19 | typedef struct SStream { |
| 20 | char buffer[SSTREAM_BUF_LEN]; |
| 21 | int index; |
| 22 | } SStream; |
| 23 | |
| 24 | void SStream_Init(SStream *ss); |
| 25 | |
| 26 | void SStream_concat(SStream *ss, const char *fmt, ...); |
| 27 | |
| 28 | void SStream_concat0(SStream *ss, const char *s); |
| 29 | |
| 30 | void SStream_concat1(SStream *ss, const char c); |
| 31 | |
| 32 | void printInt64Bang(SStream *O, int64_t val); |
| 33 | |
| 34 | void printUInt64Bang(SStream *O, uint64_t val); |
| 35 | |
| 36 | void printInt64(SStream *O, int64_t val); |
| 37 | void printUInt64(SStream *O, uint64_t val); |
| 38 | |
| 39 | void printInt32Bang(SStream *O, int32_t val); |
| 40 | |
| 41 | void printInt32(SStream *O, int32_t val); |
| 42 | |
| 43 | void printUInt32Bang(SStream *O, uint32_t val); |
| 44 | |
| 45 | void printUInt32(SStream *O, uint32_t val); |
| 46 | |
| 47 | // print number in decimal mode |
| 48 | void printInt32BangDec(SStream *O, int32_t val); |
| 49 | |
| 50 | #endif |