tsp_common.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
  3. * Main driver
  4. */
  5. #define TST_FUNCTION_CALL(func) _TST_FUNCTION_CALL(func)
  6. #define _TST_FUNCTION_CALL(func) tst ##_## func
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <locale.h>
  11. #include <errno.h>
  12. #include <signal.h>
  13. #include "tst_types.h"
  14. #include "tgn_locdef.h"
  15. int
  16. main (int argc, char *argv[])
  17. {
  18. int ret;
  19. int debug;
  20. debug = argc > 1 ? atoi (argv[1]) : 0;
  21. if (debug)
  22. {
  23. fprintf (stdout, "\nTST_MBWC ===> %s ...\n", argv[0]);
  24. }
  25. ret = TST_FUNCTION_CALL (TST_FUNCTION) (stdout, debug);
  26. return (ret != 0);
  27. }
  28. #define MAX_RESULT_REC 132
  29. char result_rec[MAX_RESULT_REC];
  30. int
  31. result (FILE * fp, char res, const char *func, const char *loc, int rec_no,
  32. int seq_no, int case_no, const char *msg)
  33. {
  34. if (fp == NULL
  35. || strlen (func) + strlen (loc) + strlen (msg) + 32 > MAX_RESULT_REC)
  36. {
  37. fprintf (stderr,
  38. "Warning: result(): can't write the result: %s:%s:%d:%d:%s\n",
  39. func, loc, rec_no, case_no, msg);
  40. return 0;
  41. }
  42. sprintf (result_rec, "%s:%s:%d:%d:%d:%c:%s\n", func, loc, rec_no, seq_no,
  43. case_no, res, msg);
  44. if (fputs (result_rec, fp) == EOF)
  45. {
  46. return 0;
  47. }
  48. return 1;
  49. }