]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/test/locale-mbwc/tst_types.h
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / test / locale-mbwc / tst_types.h
1 /*
2  *  TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY
3  *
4  *       FILE:  tst_types.h
5  *
6  *       Definitions of data types for each test function
7  */
8
9
10 #ifndef TST_TYPES_H
11 #define TST_TYPES_H
12
13 #include <stdio.h>
14 #include <wchar.h>
15 #include <wctype.h>
16 #include "tst_funcs.h"
17 #include "tgn_funcdef.h"
18
19 #define MBSSIZE            24
20 #define WCSSIZE            12
21 #define MONFMTSIZE         16
22 #define MONSIZE            64
23 #define USE_MBCURMAX       99   /* well, but ... */
24 #define TST_DBL_EPS        2.22153e-16
25 #define WCSTOK_SEQNUM      3
26 #define MBLEN_SEQNUM       3
27 #define MBTOWC_SEQNUM      3
28 #define MBSTOWCS_SEQNUM    3
29 #define WCTOMB_SEQNUM      3
30 #define WCSTOMBS_SEQNUM    3
31 #define MBRLEN_SEQNUM      3
32 #define MBRTOWC_SEQNUM     3
33 #define MBSRTOWCS_SEQNUM   3
34 #define WCRTOMB_SEQNUM     3
35 #define WCSRTOMBS_SEQNUM   3
36
37 /* Maximum numbers of test in one of the _loc arrays.  */
38 #define MAX_LOC_TEST            300
39
40
41 /*----------------------------------------------------------------------*/
42 /*  FUNCTION                                                            */
43 /*----------------------------------------------------------------------*/
44
45 typedef struct
46 {
47   char *func_str;
48   int func_id;
49 }
50 TST_FID;
51
52 typedef struct
53 {
54   int func_id;
55   const char *locale;
56 }
57 TST_HEAD;
58
59 typedef struct
60 {
61   TST_HEAD *head;
62 }
63 TST_FUNCS;
64
65
66 /*----------------------------------------------------------------------*/
67 /*  ISW*: int isw* (wchar_t wc)                                         */
68 /*----------------------------------------------------------------------*/
69
70 TST_ISW_STRUCT (ALNUM, alnum);
71 TST_ISW_STRUCT (ALPHA, alpha);
72 TST_ISW_STRUCT (CNTRL, cntrl);
73 TST_ISW_STRUCT (DIGIT, digit);
74 TST_ISW_STRUCT (GRAPH, graph);
75 TST_ISW_STRUCT (LOWER, lower);
76 TST_ISW_STRUCT (PRINT, print);
77 TST_ISW_STRUCT (PUNCT, punct);
78 TST_ISW_STRUCT (SPACE, space);
79 TST_ISW_STRUCT (UPPER, upper);
80 TST_ISW_STRUCT (XDIGIT, xdigit);
81
82 typedef struct
83 {
84   wint_t wc;
85   const char *ts;
86 }
87 TIN_ISWCTYPE_REC;
88
89 typedef
90 TEX_ERRET_REC (int)
91   TEX_ISWCTYPE_REC;
92 TMD_RECHEAD (ISWCTYPE);
93
94
95 /*----------------------------------------------------------------------*/
96 /*  MBLEN: int mblen (const char *s, size_t n)                          */
97 /*----------------------------------------------------------------------*/
98
99 typedef struct
100 {
101   char s_flg;
102   char s[MBSSIZE];
103   size_t n;
104 }
105 TIN_MBLEN_REC;
106
107 typedef TEX_ERRET_REC (int) TEX_MBLEN_REC;
108 TMD_RECHEAD (MBLEN);
109
110
111 /*----------------------------------------------------------------------*/
112 /*  MBRLEN: size_t mbrlen (const char *s, size_t n, mbstate_t *ps)      */
113 /*----------------------------------------------------------------------*/
114
115 typedef struct
116 {
117   struct
118   {
119     int s_flg;
120     char s[MBSSIZE];
121     size_t n;
122     int t_flg;
123     int t_init;
124   }
125   seq[WCSTOK_SEQNUM];
126 }
127 TIN_MBRLEN_REC;
128
129 typedef TEX_ERRET_REC_SEQ (size_t, MBRLEN_SEQNUM) TEX_MBRLEN_REC;
130 TMD_RECHEAD (MBRLEN);
131
132
133 /*----------------------------------------------------------------------*/
134 /*  MBRTOWC: size_t mbrtowc (wchar_t *pwc, const char *s, size_t n,     */
135 /*                           mbstate_t *ps)                             */
136 /*----------------------------------------------------------------------*/
137
138 typedef struct
139 {
140   struct
141   {
142     int w_flg;
143     int s_flg;
144     char s[MBSSIZE];
145     size_t n;
146     int t_flg;
147     int t_init;
148   }
149   seq[MBRTOWC_SEQNUM];
150 }
151 TIN_MBRTOWC_REC;
152
153 typedef struct
154 {
155   struct
156   {
157     TMD_ERRET (size_t);
158     wchar_t wc;
159   }
160   seq[MBRTOWC_SEQNUM];
161 }
162 TEX_MBRTOWC_REC;
163
164 TMD_RECHEAD (MBRTOWC);
165
166
167 /*----------------------------------------------------------------------*/
168 /*  MBSRTOWCS: size_t mbsrtowcs (wchar_t *ws, const char **s, size_t n, */
169 /*                               mbstate_t *ps )                        */
170 /*----------------------------------------------------------------------*/
171
172 typedef struct
173 {
174   struct
175   {
176     int w_flg;
177     char s[MBSSIZE];
178     size_t n;
179     int t_flg;
180     int t_init;
181   }
182   seq[MBSRTOWCS_SEQNUM];
183 }
184 TIN_MBSRTOWCS_REC;
185
186 typedef struct
187 {
188   struct
189   {
190     TMD_ERRET (size_t);
191     wchar_t ws[WCSSIZE];
192   }
193   seq[MBSRTOWCS_SEQNUM];
194 }
195 TEX_MBSRTOWCS_REC;
196
197 TMD_RECHEAD (MBSRTOWCS);
198
199
200 /*----------------------------------------------------------------------*/
201 /*  MBSTOWCS: size_t mbstowcs (wchar_t *ws, const char *s, size_t n)    */
202 /*----------------------------------------------------------------------*/
203
204 typedef struct
205 {
206   struct
207   {
208     int w_flg;
209     int s_flg;
210     const char *s;
211     size_t n;
212   }
213   seq[MBSTOWCS_SEQNUM];
214 }
215 TIN_MBSTOWCS_REC;
216
217 typedef TEX_MBSRTOWCS_REC TEX_MBSTOWCS_REC;
218 /* MBSRTOWCS_SEQNUM == MBSTOWCS_SEQNUM */
219 TMD_RECHEAD (MBSTOWCS);
220
221
222 /*----------------------------------------------------------------------*/
223 /*  MBTOWC: int mbtowc (wchar_t *wc, const char *s, size_t n)           */
224 /*----------------------------------------------------------------------*/
225
226 typedef TIN_MBSTOWCS_REC TIN_MBTOWC_REC;
227 /* MBTOWC_SEQNUM == MBSTOWCS_SEQNUM */
228
229 typedef struct
230 {
231   struct
232   {
233     TMD_ERRET (int);
234     wchar_t wc;
235   }
236   seq[MBTOWC_SEQNUM];
237 }
238 TEX_MBTOWC_REC;
239
240 TMD_RECHEAD (MBTOWC);
241
242
243 /*----------------------------------------------------------------------*/
244 /*  STRCOLL: int strcoll (const char *s1, const char *s2)               */
245 /*----------------------------------------------------------------------*/
246
247 typedef struct
248 {
249   char s1[MBSSIZE];
250   char s2[MBSSIZE];
251 }
252 TIN_STRCOLL_REC;
253
254 typedef TEX_ERRET_REC (int) TEX_STRCOLL_REC;
255 TMD_RECHEAD (STRCOLL);
256
257
258 /*----------------------------------------------------------------------*/
259 /*  STRFMON: size_t strfmon (char *buf, size_t nbytes,                  */
260 /*                           const char *fmt, ... )                     */
261 /*----------------------------------------------------------------------*/
262
263 typedef struct
264 {
265   int nbytes;
266   char fmt[MONFMTSIZE];
267   double val;
268 }
269 TIN_STRFMON_REC;
270
271 typedef struct
272 {
273   TMD_ERRET (size_t);
274   char mon[MONSIZE];
275 }
276 TEX_STRFMON_REC;
277
278 TMD_RECHEAD (STRFMON);
279
280
281 /*----------------------------------------------------------------------*/
282 /*  STRXFRM: size_t strxfrm (char *s1, const char *s2, size_t n)        */
283 /*----------------------------------------------------------------------*/
284
285 typedef struct
286 {
287   char org1[MBSSIZE];
288   char org2[MBSSIZE];
289   size_t n1, n2;
290 }
291 TIN_STRXFRM_REC;
292
293 typedef TEX_ERRET_REC (size_t) TEX_STRXFRM_REC; /* only for org2[] */
294 TMD_RECHEAD (STRXFRM);
295
296
297 /*----------------------------------------------------------------------*/
298 /*  SWSCANF: int swscanf (const wchar_t *ws, const wchar_t *fmt, ...)   */
299 /*----------------------------------------------------------------------*/
300
301 typedef struct
302 {
303   wchar_t ws[WCSSIZE * 3];
304   wchar_t fmt[WCSSIZE * 3];
305   int wch;
306 }
307 TIN_SWSCANF_REC;
308
309 typedef struct
310 {
311   TMD_ERRET (int);
312   int val_int;          /* %d */
313   unsigned val_uns;     /* %u */
314   float val_flt;                /* %f */
315   int val_c;            /* %c */
316   char val_s[MBSSIZE * 2];      /* %s */
317   wchar_t val_S[WCSSIZE * 2];   /* %lc, %ls, %C, %S */
318 }
319 TEX_SWSCANF_REC;
320
321 TMD_RECHEAD (SWSCANF);
322
323
324 /*----------------------------------------------------------------------*/
325 /*  TOWCTRANS: wint_t towctrans (wint_t wc, wctrans_t desc)             */
326 /*----------------------------------------------------------------------*/
327
328 typedef TIN_ISWCTYPE_REC TIN_TOWCTRANS_REC;
329 typedef TEX_ERRET_REC (wint_t) TEX_TOWCTRANS_REC;
330 TMD_RECHEAD (TOWCTRANS);
331
332
333 /*----------------------------------------------------------------------*/
334 /*  TOW*ER: wint_t tow*er (wint_t wc)                                   */
335 /*----------------------------------------------------------------------*/
336
337 TST_TOW_STRUCT (LOWER, lower);
338 TST_TOW_STRUCT (UPPER, upper);
339
340
341 /*----------------------------------------------------------------------*/
342 /*  WCRTOMB: wchar_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps)       */
343 /*----------------------------------------------------------------------*/
344
345 typedef struct
346 {
347   int s_flg;
348   wchar_t wc;
349   int t_flg;
350   int t_init;
351 }
352 TIN_WCRTOMB_REC;
353
354 typedef struct
355 {
356   TMD_ERRET (wchar_t);
357   char s[MBSSIZE];
358 }
359 TEX_WCRTOMB_REC;
360
361 TMD_RECHEAD (WCRTOMB);
362
363
364 /*----------------------------------------------------------------------*/
365 /*  WCSCAT: wchar_t *wcscat (wchar_t *ws1, wchar_t *ws2)                */
366 /*----------------------------------------------------------------------*/
367
368 typedef struct
369 {
370   wchar_t ws1[WCSSIZE];
371   wchar_t ws2[WCSSIZE];
372 }
373 TIN_WCSCAT_REC;
374
375 typedef struct
376 {
377   TMD_ERRET (wchar_t *);
378   wchar_t ws[WCSSIZE];
379 }
380 TEX_WCSCAT_REC;
381
382 TMD_RECHEAD (WCSCAT);
383
384
385 /*----------------------------------------------------------------------*/
386 /*  WCSCHR: wchar_t *wcschr (wchar_t *ws, wchar_t wc);                  */
387 /*----------------------------------------------------------------------*/
388
389 typedef struct
390 {
391   wchar_t ws[WCSSIZE];
392   wchar_t wc;
393 }
394 TIN_WCSCHR_REC;
395
396 typedef TEX_ERRET_REC (wchar_t *) TEX_WCSCHR_REC;
397 TMD_RECHEAD (WCSCHR);
398
399
400 /*----------------------------------------------------------------------*/
401 /*  WCSCMP: int wcscmp (const wchar_t *ws1, const wchar_t *ws2)         */
402 /*----------------------------------------------------------------------*/
403
404 typedef TIN_WCSCAT_REC TIN_WCSCMP_REC;
405 typedef TEX_ERRET_REC (int) TEX_WCSCMP_REC;
406 TMD_RECHEAD (WCSCMP);
407
408
409 /*----------------------------------------------------------------------*/
410 /*  WCSCOLL: int wcscoll (const wchar_t *ws1, const wchar_t *ws2)       */
411 /*----------------------------------------------------------------------*/
412
413 typedef TIN_WCSCMP_REC TIN_WCSCOLL_REC;
414 typedef struct
415 {
416   TMD_ERRET (int);
417   int cmp_flg;
418 }
419 TEX_WCSCOLL_REC;
420 TMD_RECHEAD (WCSCOLL);
421
422
423 /*----------------------------------------------------------------------*/
424 /*  WCSCPY: wchar_t *wcscpy (wchar_t *ws1, const wchar_t *ws2)          */
425 /*----------------------------------------------------------------------*/
426
427 typedef struct
428 {
429   wchar_t ws[WCSSIZE];  /* ws2: original string */
430 }
431 TIN_WCSCPY_REC;
432
433 typedef TEX_WCSCAT_REC TEX_WCSCPY_REC;
434 TMD_RECHEAD (WCSCPY);
435
436
437 /*----------------------------------------------------------------------*/
438 /*  WCSCSPN: size_t wcscspn (const wchar_t *ws1, const wchar_t *ws2)    */
439 /*----------------------------------------------------------------------*/
440
441 typedef TIN_WCSCAT_REC TIN_WCSCSPN_REC;
442 typedef TEX_ERRET_REC (size_t) TEX_WCSCSPN_REC;
443 TMD_RECHEAD (WCSCSPN);
444
445
446 /*----------------------------------------------------------------------*/
447 /*  WCSLEN: size_t wcslen (const wchar_t *ws)                           */
448 /*----------------------------------------------------------------------*/
449
450 typedef TIN_WCSCPY_REC TIN_WCSLEN_REC;
451 typedef TEX_ERRET_REC (size_t) TEX_WCSLEN_REC;
452 TMD_RECHEAD (WCSLEN);
453
454
455 /*----------------------------------------------------------------------*/
456 /*  WCSNCAT: wchar_t *wcsncat (wchar_t *ws1, const wchar_t *ws2,        */
457 /*                             size_t n)                                */
458 /*----------------------------------------------------------------------*/
459
460 typedef struct
461 {
462   wchar_t ws1[WCSSIZE];
463   wchar_t ws2[WCSSIZE];
464   size_t n;
465 }
466 TIN_WCSNCAT_REC;
467
468 typedef TEX_WCSCAT_REC TEX_WCSNCAT_REC;
469 TMD_RECHEAD (WCSNCAT);
470
471
472 /*----------------------------------------------------------------------*/
473 /*  WCSNCMP: int *wcsncmp (const wchar_t *ws1, const wchar_t *ws2,      */
474 /*                         size_t n)                                    */
475 /*----------------------------------------------------------------------*/
476
477 typedef TIN_WCSNCAT_REC TIN_WCSNCMP_REC;
478 typedef TEX_ERRET_REC (int) TEX_WCSNCMP_REC;
479 TMD_RECHEAD (WCSNCMP);
480
481
482 /*----------------------------------------------------------------------*/
483 /*  WCSNCPY: wchar_t *wcsncpy (wchar_t *ws1, const wchar_t *ws2,        */
484 /*                             size_t n)                                */
485 /*----------------------------------------------------------------------*/
486
487 typedef struct
488 {
489   wchar_t ws[WCSSIZE];  /* ws2: original string */
490   size_t n;
491 }
492 TIN_WCSNCPY_REC;
493
494 typedef TEX_WCSCPY_REC TEX_WCSNCPY_REC;
495 TMD_RECHEAD (WCSNCPY);
496
497
498 /*----------------------------------------------------------------------*/
499 /*  WCSPBRK: wchar_t *wcspbrk (const wchar_t *ws1, const wchar_t *ws2)  */
500 /*----------------------------------------------------------------------*/
501
502 typedef TIN_WCSCSPN_REC TIN_WCSPBRK_REC;
503
504 typedef struct
505 {
506   TMD_ERRET (wchar_t *);
507   wchar_t wc;
508 }
509 TEX_WCSPBRK_REC;
510
511 TMD_RECHEAD (WCSPBRK);
512
513
514 /*----------------------------------------------------------------------*/
515 /*  WCSRTOMBS: size_t wcsrtombs (char *s, const wchar_t **ws, size_t n, */
516 /*                               mbstate_t *ps)                         */
517 /*----------------------------------------------------------------------*/
518
519 typedef struct
520 {
521   int s_flg;
522   int w_flg;            /* don't need this */
523   wchar_t ws[WCSSIZE];
524   size_t n;
525   int t_flg;
526   int t_init;
527 }
528 TIN_WCSRTOMBS_REC;
529
530 typedef struct
531 {
532   TMD_ERRET (size_t);
533   char s[MBSSIZE];
534 }
535 TEX_WCSRTOMBS_REC;
536
537 TMD_RECHEAD (WCSRTOMBS);
538
539
540 /*----------------------------------------------------------------------*/
541 /*  WCSSPN: size_t wcsspn (const wchar_t *ws1, const wchar_t *ws2)      */
542 /*----------------------------------------------------------------------*/
543
544 typedef TIN_WCSCSPN_REC TIN_WCSSPN_REC;
545 typedef TEX_WCSCSPN_REC TEX_WCSSPN_REC;
546 TMD_RECHEAD (WCSSPN);
547
548
549 /*----------------------------------------------------------------------*/
550 /*  WCSSTR: wchar_t *wcsstr (const wchar_t *ws1, const wchar_t *ws2)    */
551 /*----------------------------------------------------------------------*/
552
553 typedef TIN_WCSCSPN_REC TIN_WCSSTR_REC;
554 typedef TEX_ERRET_REC (wchar_t *) TEX_WCSSTR_REC;
555 TMD_RECHEAD (WCSSTR);
556
557
558 /*----------------------------------------------------------------------*/
559 /*  WCSTOD: double wcstod (const wchar_t *np, wchar_t **endp)           */
560 /*----------------------------------------------------------------------*/
561
562 typedef struct
563 {
564   wchar_t np[WCSSIZE];
565 }
566 TIN_WCSTOD_REC;
567
568 typedef struct
569 {
570   TMD_ERRET (double);
571   double val;
572   wchar_t fwc;
573 }
574 TEX_WCSTOD_REC;
575
576 TMD_RECHEAD (WCSTOD);
577
578
579 /*----------------------------------------------------------------------*/
580 /*  WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm,           */
581 /*                           wchar_t **pt)                              */
582 /*----------------------------------------------------------------------*/
583
584 typedef struct
585 {
586   struct
587   {
588     int w_flg;
589     wchar_t ws[WCSSIZE];
590     wchar_t dt[WCSSIZE];        /* delimiter */
591   }
592   seq[WCSTOK_SEQNUM];
593 }
594 TIN_WCSTOK_REC;
595
596 typedef struct
597 {
598   struct
599   {
600     TMD_ERRET (wchar_t *);
601     wchar_t ws[WCSSIZE];
602   }
603   seq[WCSTOK_SEQNUM];
604 }
605 TEX_WCSTOK_REC;
606
607 TMD_RECHEAD (WCSTOK);
608
609
610 /*----------------------------------------------------------------------*/
611 /*  WCSTOMBS: size_t wcstombs (char s, const wchar_t *ws, size_t n)     */
612 /*----------------------------------------------------------------------*/
613
614 typedef struct
615 {
616   int s_flg;
617   int w_flg;            /* currently we don't need it. */
618   wchar_t ws[WCSSIZE];
619   size_t n;
620 }
621 TIN_WCSTOMBS_REC;
622
623 typedef struct
624 {
625   TMD_ERRET (size_t);
626   char s[MBSSIZE];
627 }
628 TEX_WCSTOMBS_REC;
629
630 TMD_RECHEAD (WCSTOMBS);
631
632
633 /*----------------------------------------------------------------------*/
634 /*  WCSWIDTH: int wcswidth (const wchar_t *ws, size_t n)                */
635 /*----------------------------------------------------------------------*/
636
637 typedef TIN_WCSNCPY_REC TIN_WCSWIDTH_REC;
638 typedef TEX_ERRET_REC (int) TEX_WCSWIDTH_REC;
639 TMD_RECHEAD (WCSWIDTH);
640
641
642 /*----------------------------------------------------------------------*/
643 /*  WCSXFRM: size_t wcsxfrm (wchar_t *ws1, const wchar_t *ws2, size_t n)*/
644 /*----------------------------------------------------------------------*/
645
646 typedef struct
647 {
648   wchar_t org1[WCSSIZE];
649   wchar_t org2[WCSSIZE];
650   int n1, n2;
651 }
652 TIN_WCSXFRM_REC;
653
654 typedef TEX_ERRET_REC (size_t) TEX_WCSXFRM_REC; /* only for org2[] */
655 TMD_RECHEAD (WCSXFRM);
656
657
658 /*----------------------------------------------------------------------*/
659 /*  WCTOB: int wctob (wint_t wc)                                        */
660 /*----------------------------------------------------------------------*/
661
662 typedef struct
663 {
664   wint_t wc;
665 }
666 TIN_WCTOB_REC;
667
668 typedef TEX_ERRET_REC (int) TEX_WCTOB_REC;
669 TMD_RECHEAD (WCTOB);
670
671
672 /*----------------------------------------------------------------------*/
673 /*  WCTOMB: int wctomb (char *s, wchar_t wc)                            */
674 /*----------------------------------------------------------------------*/
675
676 typedef struct
677 {
678   int s_flg;
679   wchar_t wc;
680 }
681 TIN_WCTOMB_REC;
682
683 typedef struct
684 {
685   TMD_ERRET (int);
686   char s[MBSSIZE];
687 }
688 TEX_WCTOMB_REC;
689
690 TMD_RECHEAD (WCTOMB);
691
692
693 /*----------------------------------------------------------------------*/
694 /*  WCTRANS: wctrans_t wctrans (const char *charclass)                  */
695 /*----------------------------------------------------------------------*/
696
697 typedef struct
698 {
699   char class[MBSSIZE];
700 }
701 TIN_WCTRANS_REC;
702
703 typedef TEX_ERRET_REC (wctrans_t) TEX_WCTRANS_REC;
704 TMD_RECHEAD (WCTRANS);
705
706
707 /*----------------------------------------------------------------------*/
708 /*  WCTYPE: wctype_t wctype (const char *class)                         */
709 /*----------------------------------------------------------------------*/
710
711 typedef TIN_WCTRANS_REC TIN_WCTYPE_REC;
712 typedef TEX_ERRET_REC (wctype_t) TEX_WCTYPE_REC;
713 TMD_RECHEAD (WCTYPE);
714
715
716 /*----------------------------------------------------------------------*/
717 /*  WCWIDTH: int wcwidth (wchar_t wc)                                   */
718 /*----------------------------------------------------------------------*/
719
720 typedef struct
721 {
722   wchar_t wc;
723 }
724 TIN_WCWIDTH_REC;
725
726 typedef TEX_ERRET_REC (int) TEX_WCWIDTH_REC;
727 TMD_RECHEAD (WCWIDTH);
728
729 #endif /* TST_TYPES_H */