Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / include / libc / string.h
1 /*
2  *   Creation Date: <2002/10/12 20:41:57 samuel>
3  *   Time-stamp: <2003/10/25 12:51:22 samuel>
4  *
5  *      <string.h>
6  *
7  *      string library functions
8  *
9  *   Copyright (C) 2002, 2003 Samuel Rydh (samuel@ibrium.se)
10  *
11  *   This program is free software; you can redistribute it and/or
12  *   modify it under the terms of the GNU General Public License
13  *   as published by the Free Software Foundation
14  *
15  */
16
17 #ifndef _H_STRING
18 #define _H_STRING
19
20 #include "config.h"
21
22 #define bzero(s,n)      memset( s, 0, n )
23 #define atol(nptr)      strtol(nptr, NULL, 10 )
24
25 extern long     strtol( const char *nptr, char **endptr, int base );
26 extern long long int strtoll( const char *nptr, char **endptr, int base );
27
28
29 extern int      strnicmp(const char *s1, const char *s2, size_t len);
30 extern char     *strcpy(char * dest,const char *src);
31 extern char     *strncpy(char * dest,const char *src,size_t count);
32 extern char     *strcat(char * dest, const char * src);
33 extern char     *strncat(char *dest, const char *src, size_t count);
34 extern int      strcmp(const char * cs,const char * ct);
35 extern int      strncmp(const char * cs,const char * ct,size_t count);
36 extern char     *strchr(const char * s, int c);
37 extern char     *strrchr(const char * s, int c);
38 extern size_t   strlen(const char * s);
39 extern size_t   strnlen(const char * s, size_t count);
40 extern char     *strpbrk(const char * cs,const char * ct);
41 extern char     *strsep(char **s, const char *ct);
42 extern void     *memset(void * s,int c,size_t count);
43 extern void     *memcpy(void * dest,const void *src,size_t count);
44 extern void     *memmove(void * dest,const void *src,size_t count);
45 extern int      memcmp(const void * cs,const void * ct,size_t count);
46
47 extern char     *strdup( const char *str );
48 extern int      strcasecmp( const char *cs, const char *ct );
49 extern int      strncasecmp( const char *cs, const char *ct, size_t count );
50
51 extern  char    *strncpy_nopad( char *dest, const char *src, size_t n );
52
53 #define _U      0x01    /* upper */
54 #define _L      0x02    /* lower */
55 #define _D      0x04    /* digit */
56 #define _C      0x08    /* cntrl */
57 #define _P      0x10    /* punct */
58 #define _S      0x20    /* white space (space/lf/tab) */
59 #define _X      0x40    /* hex digit */
60 #define _SP     0x80    /* hard space (0x20) */
61
62 extern const unsigned char _ctype[];
63
64 #define __ismask(x) (_ctype[(int)(unsigned char)(x)])
65
66 #define isalnum(c)      ((__ismask(c)&(_U|_L|_D)) != 0)
67 #define isalpha(c)      ((__ismask(c)&(_U|_L)) != 0)
68 #define iscntrl(c)      ((__ismask(c)&(_C)) != 0)
69 #define isdigit(c)      ((__ismask(c)&(_D)) != 0)
70 #define isgraph(c)      ((__ismask(c)&(_P|_U|_L|_D)) != 0)
71 #define islower(c)      ((__ismask(c)&(_L)) != 0)
72 #define isprint(c)      ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
73 #define ispunct(c)      ((__ismask(c)&(_P)) != 0)
74 #define isspace(c)      ((__ismask(c)&(_S)) != 0)
75 #define isupper(c)      ((__ismask(c)&(_U)) != 0)
76 #define isxdigit(c)     ((__ismask(c)&(_D|_X)) != 0)
77
78 #define isascii(c) (((unsigned char)(c))<=0x7f)
79 #define toascii(c) (((unsigned char)(c))&0x7f)
80
81
82 static inline unsigned char __tolower(unsigned char c) {
83         if (isupper(c))
84                 c -= 'A'-'a';
85         return c;
86 }
87
88 static inline unsigned char __toupper(unsigned char c) {
89         if (islower(c))
90                 c -= 'a'-'A';
91         return c;
92 }
93
94 #define tolower(c) __tolower(c)
95 #define toupper(c) __toupper(c)
96
97 extern int errno_int;
98
99 // Propolice support
100 extern long __guard[8];
101
102 void __stack_smash_handler(const char *func, int damaged);
103 void __stack_chk_fail(void);
104
105 #endif   /* _H_STRING */