1 /*
2  * $Id: wce_stdlib.h,v 1.2 2006/04/09 16:48:18 mloskot Exp $
3  *
4  * stdlib.h - standard library definitions
5  *
6  * Created by Mateusz Loskot (mateusz@loskot.net)
7  *
8  * Copyright (c) 2006 Taxus SI Ltd.
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom
15  * the Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
26  * THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27  *
28  * MIT License:
29  * http://opensource.org/licenses/mit-license.php
30  *
31  * Contact:
32  * Taxus SI Ltd.
33  * http://www.taxussi.com.pl
34  *
35  */
36 #ifndef WCEEX_STDLIB_H
37 #define WCEEX_STDLIB_H 1
38 
39 #if !defined(_WIN32_WCE)
40 # error "Only Windows CE target is supported!"
41 #endif
42 
43 /*
44  * Minimal set of required declarations to avoid inclusion of <windows.h>,
45  * because it defines 'LP' type and other which conflict with some libraries,
46  * like PROJ.4.
47  */
48 typedef unsigned long DWORD;
49 typedef wchar_t *LPWSTR, *PWSTR;
50 typedef const wchar_t *LPCWSTR, *PCWSTR;
51 
52 #define _MAX_DIR   256
53 #define _MAX_FNAME 256
54 #define _MAX_EXT   256
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif  /* __cplusplus */
59 
60 
61 /* Generate an abnormal process abort. */
62 
63 void wceex_abort(void);
64 
65 /* Searching and sorting utilities. */
66 
67 void* wceex_bsearch(const void *key, const void *base, size_t nmemb, size_t size,
68                     int (*compar)(const void *, const void *));
69 
70 void* wceex_lfind(const void *key, const void *base, size_t *nmemb, size_t size,
71                  int(*compar)(const void *, const void *));
72 
73 /* File Management Functions */
74 
75 void wceex_splitpath( const char *path,
76                       char *drive, char *dir, char *name, char *ext );
77 void wceex_wsplitpath( const wchar_t *path,
78                        wchar_t *drive, wchar_t *dir, wchar_t *name, wchar_t *ext );
79 
80 void wceex_makepath( char *path,
81                      const char *drive, const char *dir,
82                      const char *name, const char *ext );
83 void wceex_wmakepath( wchar_t *path,
84                       const wchar_t *drive, const wchar_t *dir,
85                       const wchar_t *name, const wchar_t *ext );
86 
87 char*    wceex_fullpath( char *absPath, const char *relPath, size_t maxLength );
88 wchar_t* wceex_wfullpath( wchar_t *absPath, const wchar_t *relPath, size_t maxLength );
89 
90 DWORD wceex_GetFullPathNameW( LPCWSTR lpFileName, DWORD nBufferLength,
91                               LPWSTR lpBuffer, LPWSTR *lpFilePart );
92 
93 /* Dummy compilation enablers - functions that do not provide any implementation. */
94 
95 char* wceex_getenv(const char* varname);
96 
97 #ifdef __cplusplus
98 }
99 #endif  /* __cplusplus */
100 
101 
102 #endif /* #ifndef WCEEX_STDLIB_H */
103