Back to index

glibc  2.9
tsp_common.c
Go to the documentation of this file.
00001 /*
00002  *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
00003  *  Main driver
00004  */
00005 
00006 
00007 #define TST_FUNCTION_CALL(func) _TST_FUNCTION_CALL(func)
00008 #define _TST_FUNCTION_CALL(func) tst ##_## func
00009 
00010 #include <stdio.h>
00011 #include <stdlib.h>
00012 #include <string.h>
00013 #include <locale.h>
00014 #include <errno.h>
00015 #include <signal.h>
00016 
00017 #include "tst_types.h"
00018 #include "tgn_locdef.h"
00019 
00020 
00021 int
00022 main (int argc, char *argv[])
00023 {
00024   int ret;
00025   int debug;
00026 
00027   debug = argc > 1 ? atoi (argv[1]) : 0;
00028 
00029   if (debug)
00030     {
00031       fprintf (stdout, "\nTST_MBWC ===> %s ...\n", argv[0]);
00032     }
00033   ret = TST_FUNCTION_CALL (TST_FUNCTION) (stdout, debug);
00034 
00035   return (ret != 0);
00036 }
00037 
00038 #define        MAX_RESULT_REC       132
00039 char result_rec[MAX_RESULT_REC];
00040 
00041 
00042 int
00043 result (FILE * fp, char res, const char *func, const char *loc, int rec_no,
00044        int seq_no, int case_no, const char *msg)
00045 {
00046   if (fp == NULL
00047       || strlen (func) + strlen (loc) + strlen (msg) + 32 > MAX_RESULT_REC)
00048     {
00049       fprintf (stderr,
00050               "Warning: result(): can't write the result: %s:%s:%d:%d:%s\n",
00051               func, loc, rec_no, case_no, msg);
00052       return 0;
00053     }
00054 
00055   sprintf (result_rec, "%s:%s:%d:%d:%d:%c:%s\n", func, loc, rec_no, seq_no,
00056           case_no, res, msg);
00057 
00058   if (fputs (result_rec, fp) == EOF)
00059     {
00060       return 0;
00061     }
00062 
00063   return 1;
00064 }