Annotation of embedaddon/bird2/lib/string.h, revision 1.1.1.1

1.1       misho       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: u64 bstrtoul10(const char *str, char **end);
                     28: u64 bstrtoul16(const char *str, char **end);
                     29: 
                     30: int patmatch(const byte *pat, const byte *str);
                     31: 
                     32: static inline char *xbasename(const char *str)
                     33: {
                     34:   char *s = strrchr(str, '/');
                     35:   return s ? s+1 : (char *) str;
                     36: }
                     37: 
                     38: static inline char *
                     39: xstrdup(const char *c)
                     40: {
                     41:   size_t l = strlen(c) + 1;
                     42:   char *z = xmalloc(l);
                     43:   memcpy(z, c, l);
                     44:   return z;
                     45: }
                     46: 
                     47: static inline char *
                     48: lp_strdup(linpool *lp, const char *c)
                     49: {
                     50:   size_t l = strlen(c) + 1;
                     51:   char *z = lp_allocu(lp, l);
                     52:   memcpy(z, c, l);
                     53:   return z;
                     54: }
                     55: 
                     56: static inline void
                     57: memset32(void *D, u32 val, uint n)
                     58: {
                     59:   u32 *dst = D;
                     60:   uint i;
                     61: 
                     62:   for (i = 0; i < n; i++)
                     63:     dst[i] = val;
                     64: }
                     65: 
                     66: static inline int
                     67: bstrcmp(const char *s1, const char *s2)
                     68: {
                     69:   if (s1 && s2)
                     70:     return strcmp(s1, s2);
                     71:   else
                     72:     return !s2 - !s1;
                     73: }
                     74: 
                     75: #define ROUTER_ID_64_LENGTH 23
                     76: 
                     77: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>