1998-06-17 22:31:36 +08:00
|
|
|
/*
|
|
|
|
* BIRD Library -- String Functions
|
|
|
|
*
|
|
|
|
* (c) 1998 Martin Mares <mj@ucw.cz>
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BIRD_STRING_H_
|
|
|
|
#define _BIRD_STRING_H_
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2000-04-01 07:30:21 +08:00
|
|
|
#include <string.h>
|
2012-08-14 22:25:22 +08:00
|
|
|
#include <strings.h>
|
1998-06-17 22:31:36 +08:00
|
|
|
|
|
|
|
int bsprintf(char *str, const char *fmt, ...);
|
|
|
|
int bvsprintf(char *str, const char *fmt, va_list args);
|
1998-11-17 05:40:35 +08:00
|
|
|
int bsnprintf(char *str, int size, const char *fmt, ...);
|
|
|
|
int bvsnprintf(char *str, int size, const char *fmt, va_list args);
|
1998-06-17 22:31:36 +08:00
|
|
|
|
2013-10-06 02:12:28 +08:00
|
|
|
int buffer_vprint(buffer *buf, const char *fmt, va_list args);
|
|
|
|
int buffer_print(buffer *buf, const char *fmt, ...);
|
|
|
|
void buffer_puts(buffer *buf, const char *str);
|
|
|
|
|
2015-11-24 20:52:26 +08:00
|
|
|
int patmatch(const byte *pat, const byte *str);
|
1998-11-29 22:47:24 +08:00
|
|
|
|
2016-04-07 18:20:45 +08:00
|
|
|
static inline char *xbasename(const char *str)
|
|
|
|
{
|
|
|
|
char *s = strrchr(str, '/');
|
|
|
|
return s ? s+1 : (char *) str;
|
|
|
|
}
|
|
|
|
|
2016-11-01 18:37:49 +08:00
|
|
|
static inline char *
|
|
|
|
xstrdup(const char *c)
|
|
|
|
{
|
|
|
|
size_t l = strlen(c) + 1;
|
|
|
|
char *z = xmalloc(l);
|
|
|
|
memcpy(z, c, l);
|
|
|
|
return z;
|
|
|
|
}
|
|
|
|
|
2016-10-26 22:07:45 +08:00
|
|
|
static inline void
|
|
|
|
memset32(void *D, u32 val, uint n)
|
|
|
|
{
|
|
|
|
u32 *dst = D;
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
dst[i] = val;
|
|
|
|
}
|
|
|
|
|
2016-04-29 00:01:40 +08:00
|
|
|
#define ROUTER_ID_64_LENGTH 23
|
|
|
|
|
1998-06-17 22:31:36 +08:00
|
|
|
#endif
|