aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test/os_SUITE_data/my_echo.c
blob: 712c828bb54437717787ff2b9e3d9a918dc34694 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifdef __WIN32__
#include <windows.h>

int wmain(int argc, wchar_t **argv)
{
    char* sep = "";
    int len;

    /*
     * Echo all arguments separated with '::', so that we can check that
     * quotes are interpreted correctly.
     */

    while (argc-- > 1) {
	char *utf8;
	len = WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, NULL, 0, NULL, NULL);
	utf8 = malloc(len*sizeof(char));
	WideCharToMultiByte(CP_UTF8, 0, argv++[1], -1, utf8, len, NULL, NULL);
	printf("%s%s", sep, utf8);
	free(utf8);
	sep = "::";
    }
    putchar('\n');
    return 0;
}
#else

#include <stdio.h>

int
main(int argc, char** argv)
{
    char* sep = "";

    /*
     * Echo all arguments separated with '::', so that we can check that
     * quotes are interpreted correctly.
     */

    while (argc-- > 1) {
	printf("%s%s", sep, argv++[1]);
	sep = "::";
    }
    putchar('\n');
    return 0;
}
#endif