]>
Commit | Line | Data |
---|---|---|
ecacdfa4 MM |
1 | /* |
2 | * BIRD Library -- String Functions | |
3 | * | |
4 | * (c) 1998 Martin Mares <mj@ucw.cz> | |
5 | * | |
6 | * Can be freely distributed and used under the terms of the GNU GPL. | |
7 | */ | |
8 | ||
9 | #ifndef _BIRD_STRING_H_ | |
10 | #define _BIRD_STRING_H_ | |
11 | ||
12 | #include <stdarg.h> | |
221135d6 | 13 | #include <string.h> |
094d2bdb | 14 | #include <strings.h> |
ecacdfa4 | 15 | |
bb721f0d PT |
16 | #include "lib/resource.h" |
17 | ||
ecacdfa4 MM |
18 | int bsprintf(char *str, const char *fmt, ...); |
19 | int bvsprintf(char *str, const char *fmt, va_list args); | |
53a416d3 MM |
20 | int bsnprintf(char *str, int size, const char *fmt, ...); |
21 | int bvsnprintf(char *str, int size, const char *fmt, va_list args); | |
ecacdfa4 | 22 | |
0e175f9f OZ |
23 | int buffer_vprint(buffer *buf, const char *fmt, va_list args); |
24 | int buffer_print(buffer *buf, const char *fmt, ...); | |
25 | void buffer_puts(buffer *buf, const char *str); | |
26 | ||
e422ca0f | 27 | int patmatch(const byte *pat, const byte *str); |
dee929d8 | 28 | |
f2ae2bad OZ |
29 | static inline char *xbasename(const char *str) |
30 | { | |
31 | char *s = strrchr(str, '/'); | |
32 | return s ? s+1 : (char *) str; | |
33 | } | |
34 | ||
17fe57d8 OZ |
35 | static inline char * |
36 | xstrdup(const char *c) | |
37 | { | |
38 | size_t l = strlen(c) + 1; | |
39 | char *z = xmalloc(l); | |
40 | memcpy(z, c, l); | |
41 | return z; | |
42 | } | |
43 | ||
bb721f0d PT |
44 | static inline char * |
45 | lp_strdup(linpool *lp, const char *c) | |
46 | { | |
47 | size_t l = strlen(c) + 1; | |
48 | char *z = lp_allocu(lp, l); | |
49 | memcpy(z, c, l); | |
50 | return z; | |
51 | } | |
52 | ||
390601f0 OZ |
53 | static inline void |
54 | memset32(void *D, u32 val, uint n) | |
55 | { | |
56 | u32 *dst = D; | |
57 | uint i; | |
58 | ||
59 | for (i = 0; i < n; i++) | |
60 | dst[i] = val; | |
61 | } | |
62 | ||
937e75d8 OZ |
63 | #define ROUTER_ID_64_LENGTH 23 |
64 | ||
ecacdfa4 | 65 | #endif |