misc.h

Thu, 03 Aug 2006 23:09:14 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Thu, 03 Aug 2006 23:09:14 +0200
changeset 102
c00694dbcde8
parent 97
daf2b3d79cb8
permissions
-rw-r--r--

Updated locations of *.mk.

58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
1 /*
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
2 * libtu/misc.h
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
3 *
97
daf2b3d79cb8 Added setparam.c.
Tuomo Valkonen <tuomov@iki.fi>
parents: 96
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2005.
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
5 *
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
6 * You may distribute and modify this library under the terms of either
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
8 */
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
9
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
10 #ifndef LIBTU_MISC_H
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
11 #define LIBTU_MISC_H
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
12
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
13 #include <stdlib.h>
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
14 #include <stdio.h>
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
15 #include <assert.h>
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
16 #include "types.h"
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
17
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
18 #define ALLOC(X) (X*)malloczero(sizeof(X))
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
19 #define ALLOC_N(X, N) (X*)malloczero(sizeof(X)*(N))
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
20 #define REALLOC_N(PTR, X, S, N) (X*)remalloczero(PTR, sizeof(X)*(S), sizeof(X)*(N))
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
21
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
22 #define FREE(X) do{if(X!=NULL)free(X);}while(0)
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
23
96
80b5394ff100 Added XOR macro.
Tuomo Valkonen <tuomov@iki.fi>
parents: 79
diff changeset
24 #define XOR(X, Y) (((X)==0) != ((Y)==0))
80b5394ff100 Added XOR macro.
Tuomo Valkonen <tuomov@iki.fi>
parents: 79
diff changeset
25
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
26 extern void* malloczero(size_t size);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
27 extern void* remalloczero(void *ptr, size_t oldsize, size_t newsize);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
28
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
29 extern char* scopy(const char *p);
63
5b732dd506d3 trunk: changeset 1360
tuomov
parents: 58
diff changeset
30 extern char* scopyn(const char *p, size_t n);
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
31 extern char* scat(const char *p1, const char *p2);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
32 extern char* scatn(const char *p1, ssize_t n1, const char *p2, ssize_t n2);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
33 extern char* scat3(const char *p1, const char *p2, const char *p3);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
34 extern void stripws(char *p);
64
f20d97d852ce trunk: changeset 1362
tuomov
parents: 63
diff changeset
35 extern const char *libtu_strcasestr(const char *str, const char *ptn);
58
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
36
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
37 extern const char* simple_basename(const char *name);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
38
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
39 /* I dislike fread and fwrite... */
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
40 extern bool readf(FILE *fd, void *buf, size_t n);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
41 extern bool writef(FILE *fd, const void *buf, size_t n);
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
42
789df543d0c3 trunk: changeset 1303
tuomov
parents:
diff changeset
43 #endif /* LIBTU_MISC_H */

mercurial