ucx/ucx.h

Wed, 07 Aug 2013 09:40:46 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 07 Aug 2013 09:40:46 +0200
changeset 132
c7d7e4eeb76b
parent 131
fc3af16818a3
child 151
fc8d05972af7
permissions
-rw-r--r--

fixed ssize_t fix for MinGW

103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
1 /*
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
3 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
4 * Copyright 2013 Olaf Wintermann. All rights reserved.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
5 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
6 * Redistribution and use in source and binary forms, with or without
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
7 * modification, are permitted provided that the following conditions are met:
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
8 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
10 * notice, this list of conditions and the following disclaimer.
5
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
14 * documentation and/or other materials provided with the distribution.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
15 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 93
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
5
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
114
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
28 /**
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
29 * Main UCX Header providing most common definitions.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
30 *
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
31 * @file ucx.h
115
965fd17ed9cf added man page output
Mike Becker <universe@uap-core.de>
parents: 114
diff changeset
32 * @author Mike Becker
114
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
33 * @author Olaf Wintermann
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
34 */
5
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #ifndef UCX_H
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #define UCX_H
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include <stdlib.h>
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40
127
5418bda21896 added ssize_t typedef for windows
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
41 #ifdef _WIN32
132
c7d7e4eeb76b fixed ssize_t fix for MinGW
Mike Becker <universe@uap-core.de>
parents: 131
diff changeset
42 #if !(defined __ssize_t_defined || defined _SSIZE_T_)
127
5418bda21896 added ssize_t typedef for windows
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
43 #include <BaseTsd.h>
5418bda21896 added ssize_t typedef for windows
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
44 typedef SSIZE_T ssize_t;
5418bda21896 added ssize_t typedef for windows
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
45 #define __ssize_t_defined
132
c7d7e4eeb76b fixed ssize_t fix for MinGW
Mike Becker <universe@uap-core.de>
parents: 131
diff changeset
46 #define _SSIZE_T_
c7d7e4eeb76b fixed ssize_t fix for MinGW
Mike Becker <universe@uap-core.de>
parents: 131
diff changeset
47 #endif /* __ssize_t_defined and _SSIZE_T */
127
5418bda21896 added ssize_t typedef for windows
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
48 #else /* !_WIN32 */
5418bda21896 added ssize_t typedef for windows
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
49 #include <sys/types.h>
5418bda21896 added ssize_t typedef for windows
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
50 #endif /* _WIN32 */
5418bda21896 added ssize_t typedef for windows
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
51
5
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 #ifdef __cplusplus
65
7b2f2cab6348 added _Bool macro for cplusplus
Mike Becker <universe@uap-core.de>
parents: 42
diff changeset
53 #ifndef _Bool
7b2f2cab6348 added _Bool macro for cplusplus
Mike Becker <universe@uap-core.de>
parents: 42
diff changeset
54 #define _Bool bool
69
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 65
diff changeset
55 #define restrict
65
7b2f2cab6348 added _Bool macro for cplusplus
Mike Becker <universe@uap-core.de>
parents: 42
diff changeset
56 #endif
131
fc3af16818a3 fixed some warnings when compiling with the sun C++ Compiler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
57 #define UCX_EXTERN extern "C"
5
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 extern "C" {
131
fc3af16818a3 fixed some warnings when compiling with the sun C++ Compiler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
59 #else
fc3af16818a3 fixed some warnings when compiling with the sun C++ Compiler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 127
diff changeset
60 #define UCX_EXTERN
5
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 #endif
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62
114
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
63 /**
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
64 * Function pointer to a compare function.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
65 *
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
66 * The compare function shall take three arguments: the two values that shall be
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
67 * compared and optional additional data.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
68 * The function shall then return -1 if the first argument is less than the
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
69 * second argument, 1 if the first argument is greater than the second argument
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
70 * and 0 if both arguments are equal. If the third argument is
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
71 * <code>NULL</code>, it shall be ignored.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
72 */
18
69636f81db31 added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents: 5
diff changeset
73 typedef int(*cmp_func)(void*,void*,void*);
69636f81db31 added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents: 5
diff changeset
74
114
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
75 /**
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
76 * Function pointer to a copy function.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
77 *
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
78 * The copy function shall create a copy of the first argument and may use
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
79 * additional data provided by the second argument. If the second argument is
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
80 * <code>NULL</code>, it shall be ignored.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
81
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
82 * <b>Attention:</b> if pointers returned by functions of this type may be
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
83 * passed to <code>free()</code> depends on the implementation of the
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
84 * respective <code>copy_func</code>.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
85 */
18
69636f81db31 added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents: 5
diff changeset
86 typedef void*(*copy_func)(void*,void*);
69636f81db31 added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents: 5
diff changeset
87
114
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
88 /**
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
89 * Function pointer to a write function.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
90 *
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
91 * The signature of the write function shall be compatible to the signature
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
92 * of standard <code>fwrite</code>, though it may use arbitrary data types for
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
93 * source and destination.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
94 *
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
95 * The arguments shall contain (in ascending order): a pointer to the source,
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 115
diff changeset
96 * the length of one element, the element count and a pointer to the
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 115
diff changeset
97 * destination.
114
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
98 */
76
655020a30e77 fixed buffer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
99 typedef size_t(*write_func)(const void*, size_t, size_t, void*);
655020a30e77 fixed buffer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
100
114
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
101 /**
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
102 * Function pointer to a read function.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
103 *
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
104 * The signature of the read function shall be compatible to the signature
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
105 * of standard <code>fread</code>, though it may use arbitrary data types for
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
106 * source and destination.
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
107 *
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
108 * The arguments shall contain (in ascending order): a pointer to the
116
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 115
diff changeset
109 * destination, the length of one element, the element count and a pointer to
234920008754 some fixes and some documentation
Mike Becker <universe@uap-core.de>
parents: 115
diff changeset
110 * the source.
114
5a0859739b76 added doxyfile and documentation for ucx.h
Mike Becker <universe@uap-core.de>
parents: 103
diff changeset
111 */
76
655020a30e77 fixed buffer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
112 typedef size_t(*read_func)(void*, size_t, size_t, void*);
655020a30e77 fixed buffer
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 69
diff changeset
113
5
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 #ifdef __cplusplus
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 }
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 #endif
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 #endif /* UCX_H */
a1740117e2b7 added list specification
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119

mercurial