4 * @brief Generic types.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 #include <sys/types.h>
31 #include <definitions.h>
34 * General purpose boolean type.
41 * error message, or NULL for success
43 typedef const char *err_t
;
45 typedef enum status_t status_t
;
48 * Return values of function calls.
77 * One of the arguments is invalid.
82 * Something could not be found.
87 * Error while parsing.
92 * Error while verifying.
97 * Object in invalid state.
102 * Delete object which function belongs to.
107 * An object got created.
114 * String mappings for type status_t.
116 extern mapping_t status_m
[];
119 * Handle struct timeval like an own type.
121 typedef struct timeval timeval_t
;
124 * Handle struct timespec like an own type.
126 typedef struct timespec timespec_t
;
129 * Handle struct chunk_t like an own type.
131 typedef struct sockaddr sockaddr_t
;
134 * Use struct chunk_t as chunk_t.
136 typedef struct chunk_t chunk_t
;
139 * General purpose pointer/length abstraction.
143 * Pointer to start of data
148 * Length of data in bytes
154 * {NULL, 0}-chunk, handy for initialization
157 extern chunk_t CHUNK_INITIALIZER
;
160 * Initialize a chunk to a static buffer
162 #define chunk_from_buf(str) { str, sizeof(str) }
165 * Clone chunk contents in a newly allocated chunk
167 chunk_t
chunk_clone(chunk_t chunk
);
170 * Free contents of a chunk
172 void chunk_free(chunk_t
*chunk
);
177 chunk_t
chunk_alloc(size_t bytes
);
180 * Compare two chunks for equality,
181 * NULL chunks are never equal.
183 bool chunk_equals(chunk_t a
, chunk_t b
);
186 * Clone a data to a newly allocated buffer
188 void *clalloc(void *pointer
, size_t size
);