]> git.ipfire.org Git - thirdparty/bird.git/blame - lib/string.h
RPKI: Fix reconfiguration when ssh parameters are undefined
[thirdparty/bird.git] / lib / string.h
CommitLineData
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
18int bsprintf(char *str, const char *fmt, ...);
19int bvsprintf(char *str, const char *fmt, va_list args);
53a416d3
MM
20int bsnprintf(char *str, int size, const char *fmt, ...);
21int bvsnprintf(char *str, int size, const char *fmt, va_list args);
ecacdfa4 22
0e175f9f
OZ
23int buffer_vprint(buffer *buf, const char *fmt, va_list args);
24int buffer_print(buffer *buf, const char *fmt, ...);
25void buffer_puts(buffer *buf, const char *str);
26
e422ca0f 27int patmatch(const byte *pat, const byte *str);
dee929d8 28
f2ae2bad
OZ
29static inline char *xbasename(const char *str)
30{
31 char *s = strrchr(str, '/');
32 return s ? s+1 : (char *) str;
33}
34
17fe57d8
OZ
35static inline char *
36xstrdup(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
44static inline char *
45lp_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
53static inline void
54memset32(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
15b0a922
OZ
63static inline int
64bstrcmp(const char *s1, const char *s2)
65{
66 if (s1 && s2)
67 return strcmp(s1, s2);
68 else
69 return !s2 - !s1;
70}
71
937e75d8
OZ
72#define ROUTER_ID_64_LENGTH 23
73
ecacdfa4 74#endif