blob: 5d9dda1582beb7950b3fcdef31fb944261427462 [file] [log] [blame]
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08001/* Capstone Disassembler Engine */
2/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
3
4#include <stdint.h>
5#include <stdarg.h>
6#include <stdio.h>
7
8#include "SStream.h"
Nguyen Anh Quynhedeeb042014-01-15 20:44:03 +08009#include "cs_priv.h"
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080010
11void SStream_Init(SStream *ss)
12{
13 ss->index = 0;
14 ss->buffer[0] = '\0';
15}
16
17void SStream_concat(SStream *ss, const char *fmt, ...)
18{
19 va_list ap;
20
21 va_start(ap, fmt);
Nguyen Anh Quynhedeeb042014-01-15 20:44:03 +080022 int ret = cs_vsnprintf(ss->buffer + ss->index, sizeof(ss->buffer) - (ss->index + 1), fmt, ap);
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080023 va_end(ap);
24 ss->index += ret;
25}
26
27/*
28 int main()
29 {
30 SStream ss;
31 int64_t i;
32
33 SStream_Init(&ss);
34
35 SStream_concat(&ss, "hello ");
36 SStream_concat(&ss, "%d - 0x%x", 200, 16);
37
38 i = 123;
39 SStream_concat(&ss, " + %ld", i);
40 SStream_concat(&ss, "%s", "haaaaa");
41
42 printf("%s\n", ss.buffer);
43
44 return 0;
45 }
46 */