05244b80601358519d072453e65da11a8763d399
[uffi.git] / examples / c-test-fns.c
1 /***************************************************************************
2  * FILE IDENTIFICATION
3  *  
4  *  Name:         c-test-fns.c
5  *  Purpose:      Test functions in C for UFFI library
6  *  Programer:    Kevin M. Rosenberg
7  *  Date Started: Mar 2002
8  *
9  *  CVS Id:   $Id: c-test-fns.c,v 1.2 2002/03/21 04:04:45 kevin Exp $
10  *
11  * This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
12  *
13  * UFFI users are granted the rights to distribute and use this software
14  * as governed by the terms of the Lisp Lesser GNU Public License
15  * (http://opensource.franz.com/preamble.html), also known as the LLGPL.
16
17  * These variables are correct for GCC
18  * you'll need to modify these for other compilers
19  ***************************************************************************/
20
21 #ifdef WIN32
22 #include <windows.h>
23 #endif
24
25 #include <ctype.h>
26 #include <stdlib.h>
27
28
29 /* Test of constant input string */
30 int
31 #ifdef WIN32
32 WINAPI
33 #endif
34 cs_count_upper (char* psz)
35 {
36   int count = 0;
37
38   if (psz) {
39     while (*psz) {
40       if (isupper (*psz))
41         ++count;
42       ++psz;
43     }
44     return count;
45   } else 
46     return -1;
47 }
48
49 /* Test of input and output of a string */
50 void
51 #ifdef WIN32
52 WINAPI
53 #endif
54 cs_to_upper (char* psz)
55 {
56   if (psz) {
57     while (*psz) {
58       *psz = toupper (*psz);
59       ++psz;
60     }
61   }
62 }
63
64 /* Test of an output only string */
65 void
66 #ifdef WIN32
67 WINAPI
68 #endif
69 cs_make_random (int size, char* buffer)
70 {
71   int i;
72   for (i = 0; i < size; i++)
73     buffer[i] = 'A' + (rand() % 26);
74 }
75
76     
77
78