MCPcopy Create free account
hub / github.com/decaf-project/DECAF / tsk_printf_conv

Function tsk_printf_conv

decaf/shared/sleuthkit/tsk/base/tsk_printf.c:33–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 */
32#ifdef TSK_WIN32
33static int
34tsk_printf_conv(WCHAR * wbuf, int wlen, const char *msg, va_list * args)
35{
36 char *cbuf;
37 UTF8 *ptr8;
38 UTF16 *ptr16;
39 int retVal;
40 size_t len, clen;
41
42 wbuf[0] = '\0';
43
44 /* Allocate a UTF-8 buffer and process the printf args */
45 clen = wlen * 3;
46 if (NULL == (cbuf = (char *) tsk_malloc(clen))) {
47 return 1;
48 }
49
50#ifdef _MSC_VER
51 vsnprintf_s(cbuf, clen - 1, _TRUNCATE, msg, *args);
52#else
53 vsnprintf(cbuf, clen - 1, msg, *args);
54#endif
55 len = strlen(cbuf);
56
57 //Convert to UTF-16
58 ptr8 = (UTF8 *) cbuf;
59 ptr16 = (UTF16 *) wbuf;
60 retVal =
61 tsk_UTF8toUTF16((const UTF8 **) &ptr8, &ptr8[len + 1], &ptr16,
62 &ptr16[wlen], TSKlenientConversion);
63 if (retVal != TSKconversionOK) {
64 *ptr16 = '\0';
65 if (tsk_verbose)
66 tsk_fprintf(stderr,
67 "tsk_printf_conv: error converting string to UTF-16\n");
68 }
69
70 free(cbuf);
71 return 0;
72}
73#endif
74
75/**

Callers 2

tsk_fprintfFunction · 0.85
tsk_printfFunction · 0.85

Calls 6

tsk_mallocFunction · 0.85
tsk_UTF8toUTF16Function · 0.85
tsk_fprintfFunction · 0.85
vsnprintfFunction · 0.50
strlenFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected