1 | #include <stdio.h>
|
---|
2 | #include <stdarg.h>
|
---|
3 | #include <string.h>
|
---|
4 |
|
---|
5 | long _Optlink OptSimple(int arg1, int arg2, int arg3, int arg4, int arg5)
|
---|
6 | {
|
---|
7 | long ret;
|
---|
8 | if (arg1 != 0x11000011)
|
---|
9 | {
|
---|
10 | fprintf(stderr, "OptSimple: bad arg1 (%#x)\n", arg1);
|
---|
11 | return -1;
|
---|
12 | }
|
---|
13 | if (arg2 != 0x22000022)
|
---|
14 | {
|
---|
15 | fprintf(stderr, "OptSimple: bad arg2 (%#x)\n", arg2);
|
---|
16 | return -2;
|
---|
17 | }
|
---|
18 | if (arg3 != 0x33000033)
|
---|
19 | {
|
---|
20 | fprintf(stderr, "OptSimple: bad arg2 (%#x)\n", arg3);
|
---|
21 | return -3;
|
---|
22 | }
|
---|
23 | if (arg4 != 0x44000044)
|
---|
24 | {
|
---|
25 | fprintf(stderr, "OptSimple: bad arg2 (%#x)\n", arg4);
|
---|
26 | return -4;
|
---|
27 | }
|
---|
28 | if (arg5 != 0x55000055)
|
---|
29 | {
|
---|
30 | fprintf(stderr, "OptSimple: bad arg2 (%#x)\n", arg5);
|
---|
31 | return -5;
|
---|
32 | }
|
---|
33 |
|
---|
34 | return 0;
|
---|
35 | }
|
---|
36 |
|
---|
37 | int _Optlink OptPrintf(const char *pszFormat, ...)
|
---|
38 | {
|
---|
39 | va_list arg;
|
---|
40 | char szMsg[128];
|
---|
41 |
|
---|
42 | va_start(arg, pszFormat);
|
---|
43 | vsprintf(szMsg, pszFormat, arg);
|
---|
44 | va_end(arg);
|
---|
45 | if (strcmp(szMsg, "hello world\n"))
|
---|
46 | {
|
---|
47 | fprintf(stderr, "OptPrintf: bad result string '%s'", szMsg);
|
---|
48 | return -1;
|
---|
49 | }
|
---|
50 | return 0;
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | int main(int argc, const char * const *argv)
|
---|
55 | {
|
---|
56 | int rc = 0;
|
---|
57 |
|
---|
58 | if (OptSimple(0x11000011, 0x22000022, 0x33000033, 0x44000044, 0x55000055))
|
---|
59 | {
|
---|
60 | printf("error: OptSimple failed\n");
|
---|
61 | rc++;
|
---|
62 | }
|
---|
63 |
|
---|
64 | if (OptPrintf("%s%c%s%s", "hello", ' ', "world", "\n"))
|
---|
65 | {
|
---|
66 | printf("error: OptPrintf failed\n");
|
---|
67 | rc++;
|
---|
68 | }
|
---|
69 |
|
---|
70 | if (!rc)
|
---|
71 | printf("All Testcases Successfully Executed\n");
|
---|
72 | else
|
---|
73 | printf("%d testcases failed\n");
|
---|
74 |
|
---|
75 | return rc;
|
---|
76 | }
|
---|