1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#ifndef X_GENERAL_WRAPPER
#define X_GENERAL_WRAPPER
#include <stdbool.h>
#include <stdlib.h>
#define STATIC_STRLEN(x) (sizeof(x)/sizeof(char) - 1)
#define ARRAY_LEN(x,t) (sizeof(x)/sizeof(t))
int xatol (const char* str, long* result);
void* xmalloc (size_t size);
void* xrealloc (void* ptr, size_t size);
bool xstrend (const char* str, const char* suffix);
char* xstrcat (const char* str, ...);
char* xstrdup (const char* str);
char* xsprintf (const char* format, ...);
int xfaddfd (int fd, int fdflags);
int xfdelfd (int fd, int fdflags);
int xfaddfl (int fd, int flflags);
int xfdelfl (int fd, int flflags);
char* xreadlink (const char* filename);
char* xgetcwd (void);
char* xgetexe (void);
char* xgetres (const char* filename);
size_t xwrite (int fd, const char* str, size_t size);
static inline int xmax (int a, int b) {
return a > b ? a : b;
}
static inline int xmin (int a, int b) {
return a < b ? a : b;
}
#endif /* X_GENERAL_WRAPPER */
|