2 ** Copyright (C) 2006-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2 of the License, or
7 ** (at your option) any later version.
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU General Public License for more details.
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #if (HAVE_DECL_S_IRGRP == 0)
30 #include <sf_unistd.h>
35 #include <sys/types.h>
39 #if (defined (WIN32) || defined (_WIN32) || defined (__CYGWIN__))
49 static const char * locations [] =
50 { ".", "../src/", "src/", "../src/.libs/", "src/.libs/",
55 test_ordinal (HMODULE hmod, const char * func_name, int ordinal)
59 print_test_name ("win32_ordinal_test", func_name) ;
62 #define LPCSTR_OF_ORDINAL(x) ((LPCSTR) ((int64_t) (x)))
64 #define LPCSTR_OF_ORDINAL(x) ((LPCSTR) (x))
67 ord = GetProcAddress (hmod, LPCSTR_OF_ORDINAL (ordinal)) ;
68 if ((name = GetProcAddress (hmod, func_name)) == NULL)
69 { FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
70 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpmsg, 0, NULL) ;
74 if (name != NULL && ord != NULL && name == ord)
84 win32_ordinal_test (void)
85 { static char buffer [1024] ;
86 static char func_name [1024] ;
89 int k, ordinal, errors = 0 ;
91 for (k = 0 ; locations [k] != NULL ; k++)
92 { snprintf (buffer, sizeof (buffer), "%s/libsndfile-1.def", locations [k]) ;
93 if ((file = fopen (buffer, "r")) != NULL)
98 { puts ("\n\nError : cannot open DEF file.\n") ;
102 for (k = 0 ; locations [k] != NULL ; k++)
103 { snprintf (buffer, sizeof (buffer), "%s/libsndfile-1.dll", locations [k]) ;
104 if ((hmod = (HMODULE) LoadLibrary (buffer)) != NULL)
109 { puts ("\n\nError : cannot load DLL.\n") ;
113 while (fgets (buffer, sizeof (buffer), file) != NULL)
114 { func_name [0] = 0 ;
117 if (sscanf (buffer, "%s @%d", func_name, &ordinal) != 2)
120 errors += test_ordinal (hmod, func_name, ordinal) ;
128 { printf ("\n\nErrors : %d\n\n", errors) ;
133 } /* win32_ordinal_test */
140 #if (TEST_WIN32 && WIN32_TARGET_DLL)
141 win32_ordinal_test () ;