Statistics
| Branch: | Revision:

iof-bird / bird-2.0.1 / lib / string.h @ 6b3f1a54

History | View | Annotate | Download (1.28 KB)

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>
13
#include <string.h>
14
#include <strings.h>
15

    
16
#include "lib/resource.h"
17

    
18
int bsprintf(char *str, const char *fmt, ...);
19
int bvsprintf(char *str, const char *fmt, va_list args);
20
int bsnprintf(char *str, int size, const char *fmt, ...);
21
int bvsnprintf(char *str, int size, const char *fmt, va_list args);
22

    
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

    
27
int patmatch(const byte *pat, const byte *str);
28

    
29
static inline char *xbasename(const char *str)
30
{
31
  char *s = strrchr(str, '/');
32
  return s ? s+1 : (char *) str;
33
}
34

    
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

    
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

    
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

    
63
#define ROUTER_ID_64_LENGTH 23
64

    
65
#endif