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