[134] | 1 | #include <stdio.h>
|
---|
| 2 | #include <stdarg.h>
|
---|
| 3 | #include <string.h>
|
---|
| 4 |
|
---|
[463] | 5 | extern int _Optlink asmsprintf(char *, const char*,...);
|
---|
| 6 |
|
---|
[134] | 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, "OptSimple: bad arg1 (%#x)\n", arg1);
|
---|
| 13 | return -1;
|
---|
| 14 | }
|
---|
| 15 | if (arg2 != 0x22000022)
|
---|
| 16 | {
|
---|
| 17 | fprintf(stderr, "OptSimple: bad arg2 (%#x)\n", arg2);
|
---|
| 18 | return -2;
|
---|
| 19 | }
|
---|
| 20 | if (arg3 != 0x33000033)
|
---|
| 21 | {
|
---|
| 22 | fprintf(stderr, "OptSimple: bad arg2 (%#x)\n", arg3);
|
---|
| 23 | return -3;
|
---|
| 24 | }
|
---|
| 25 | if (arg4 != 0x44000044)
|
---|
| 26 | {
|
---|
| 27 | fprintf(stderr, "OptSimple: bad arg2 (%#x)\n", arg4);
|
---|
| 28 | return -4;
|
---|
| 29 | }
|
---|
| 30 | if (arg5 != 0x55000055)
|
---|
| 31 | {
|
---|
| 32 | fprintf(stderr, "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, "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 | {
|
---|
[463] | 58 | int rc = 0;
|
---|
| 59 | char szBuffer[128];
|
---|
[134] | 60 |
|
---|
| 61 | if (OptSimple(0x11000011, 0x22000022, 0x33000033, 0x44000044, 0x55000055))
|
---|
| 62 | {
|
---|
| 63 | printf("error: OptSimple failed\n");
|
---|
| 64 | rc++;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | if (OptPrintf("%s%c%s%s", "hello", ' ', "world", "\n"))
|
---|
| 68 | {
|
---|
| 69 | printf("error: OptPrintf failed\n");
|
---|
| 70 | rc++;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[463] | 73 | asmsprintf(szBuffer, "%s%c%s%s", "hello", ' ', "world", "\n");
|
---|
| 74 | if (strcmp(szBuffer, "hello world\n"))
|
---|
| 75 | {
|
---|
| 76 | printf("error: OptPrintf failed\n");
|
---|
| 77 | rc++;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 |
|
---|
[134] | 81 | if (!rc)
|
---|
| 82 | printf("All Testcases Successfully Executed\n");
|
---|
| 83 | else
|
---|
| 84 | printf("%d testcases failed\n");
|
---|
| 85 |
|
---|
| 86 | return rc;
|
---|
| 87 | }
|
---|