r10614: 2005-07-05 Kevin Rosenberg (kevin@rosenberg.net)
[uffi.git] / examples / c-test-fns.c
index 3ff1fde6d8ba938b6b2083cf0b6fb9a4c8970cc8..1f60e7757420c509ae140e1faea4be4b5b80ce55 100644 (file)
@@ -6,47 +6,70 @@
  *  Programer:    Kevin M. Rosenberg
  *  Date Started: Mar 2002
  *
- *  CVS Id:   $Id: c-test-fns.c,v 1.1 2002/03/21 02:41:30 kevin Exp $
+ *  CVS Id:   $Id$
  *
- * This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
+ * This file, part of UFFI, is Copyright (c) 2002-2005 by Kevin M. Rosenberg
  *
- * UFFI users are granted the rights to distribute and use this software
- * as governed by the terms of the Lisp Lesser GNU Public License
- * (http://opensource.franz.com/preamble.html), also known as the LLGPL.
-
  * These variables are correct for GCC
  * you'll need to modify these for other compilers
  ***************************************************************************/
 
+#ifdef WIN32
+#include <windows.h>
+
+BOOL WINAPI DllEntryPoint(HINSTANCE hinstdll,
+                          DWORD fdwReason,
+                          LPVOID lpvReserved)
+{
+        return 1;
+}
+       
+#define DLLEXPORT __declspec(dllexport)
+
+#else
+#define DLLEXPORT 
+#endif
+
 #include <ctype.h>
 #include <stdlib.h>
+#include <math.h>
 
 
 /* Test of constant input string */
+DLLEXPORT
 int
-cstring_count_upper (char* psz)
+cs_count_upper (char* psz)
 {
   int count = 0;
-  while (*psz) {
-    if (isupper (*psz))
-      ++count;
-    ++psz;
-  }
+
+  if (psz) {
+    while (*psz) {
+      if (isupper (*psz))
+       ++count;
+      ++psz;
+    }
+    return count;
+  } else 
+    return -1;
 }
 
 /* Test of input and output of a string */
+DLLEXPORT
 void
-cstring_to_upper (char* psz)
+cs_to_upper (char* psz)
 {
-  while (*psz) {
-    *psz = toupper (*psz);
-    ++psz;
+  if (psz) {
+    while (*psz) {
+      *psz = toupper (*psz);
+      ++psz;
+    }
   }
 }
 
 /* Test of an output only string */
+DLLEXPORT
 void
-cstring_make_random (int size, char* buffer)
+cs_make_random (int size, char* buffer)
 {
   int i;
   for (i = 0; i < size; i++)
@@ -54,5 +77,15 @@ cstring_make_random (int size, char* buffer)
 }
 
     
+/* Test of input/output vector */
+DLLEXPORT
+void
+half_double_vector (int size, double* vec)
+{
+  int i;
+  for (i = 0; i < size; i++)
+    vec[i] /= 2.;
+}
 
     
+