include/libtu/misc.h

Mon, 17 Nov 2003 14:28:28 +0100

author
tuomov
date
Mon, 17 Nov 2003 14:28:28 +0100
changeset 55
d32ef6ce17a4
parent 53
f8f9366b359c
permissions
-rw-r--r--

trunk: changeset 59
Set _GNU_SOURCE when compiling with system asprintf. Default to system
asprintf.

5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
1 /*
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
2 * libtu/misc.h
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
3 *
36
63cd573ffbcf trunk: changeset 39
tuomov
parents: 32
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2002.
53
f8f9366b359c trunk: changeset 57
tuomov
parents: 36
diff changeset
5 *
f8f9366b359c trunk: changeset 57
tuomov
parents: 36
diff changeset
6 * You may distribute and modify this library under the terms of either
f8f9366b359c trunk: changeset 57
tuomov
parents: 36
diff changeset
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
8 */
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
9
8
c1994196683f trunk: changeset 11
tuomov
parents: 5
diff changeset
10 #ifndef LIBTU_MISC_H
c1994196683f trunk: changeset 11
tuomov
parents: 5
diff changeset
11 #define LIBTU_MISC_H
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
12
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
13 #include <stdlib.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
14 #include <stdio.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
15 #include <assert.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
16 #include "types.h"
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
17
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
18 #define TR(X) X
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
19 #define DUMMY_TR(X) X
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
20
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
21 #define ALLOC(X) (X*)malloczero(sizeof(X))
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
22 #define ALLOC_N(X, N) (X*)malloczero(sizeof(X)*(N))
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
23 #define REALLOC_N(PTR, X, S, N) (X*)remalloczero(PTR, sizeof(X)*(S), sizeof(X)*(N))
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
24
20
3f11f764772a trunk: changeset 23
tuomov
parents: 9
diff changeset
25 #define FREE(X) do{if(X!=NULL)free(X);}while(0)
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
26
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
27 extern void* malloczero(size_t size);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
28 extern void* remalloczero(void *ptr, size_t oldsize, size_t newsize);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
29
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
30 extern char* scopy(const char *p);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
31 extern char* scat(const char *p1, const char *p2);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
32 extern char* scatn(const char *p1, ssize_t n1, const char *p2, ssize_t n2);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
33 extern char* scat3(const char *p1, const char *p2, const char *p3);
32
7e74a8d61b76 trunk: changeset 35
tuomov
parents: 20
diff changeset
34 extern void stripws(char *p);
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
35
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
36 extern const char* simple_basename(const char *name);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
37
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
38 /* I dislike fread and fwrite... */
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
39 extern bool readf(FILE *fd, void *buf, size_t n);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
40 extern bool writef(FILE *fd, const void *buf, size_t n);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
41
8
c1994196683f trunk: changeset 11
tuomov
parents: 5
diff changeset
42 #endif /* LIBTU_MISC_H */

mercurial