2 * Copyright (c) 2001,2004 David H. Hovemeyer <daveho@cs.umd.edu>
3 * Copyright (c) 2003, Jeffrey K. Hollingsworth <hollings@cs.umd.edu>
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
17 * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
18 * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
20 * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21 * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * 2008, Jack Lange <jarusl@cs.northwestern.edu>
29 * 2008, Lei Xia <xiaxlei@gmail.com>
32 #ifndef __VMM_STRING_H__
33 #define __VMM_STRING_H__
37 #include <palacios/vmm_types.h>
40 void * memset(void* s, int c, size_t n);
41 void * memcpy(void *dst, const void* src, size_t n);
42 void * memmove(void *dst, const void *src, size_t n);
43 int memcmp(const void *s1, const void *s2, size_t n);
44 size_t strlen(const char* s);
45 size_t strnlen(const char *s, size_t maxlen);
46 int strcmp(const char* s1, const char* s2);
47 int strcasecmp(const char* s1, const char* s2);
48 int strncmp(const char* s1, const char* s2, size_t limit);
49 int strncasecmp(const char* s1, const char* s2, size_t limit);
50 char *strcat(char *s1, const char *s2);
51 char *strncat(char *s1, const char *s2, size_t limit);
52 char *strcpy(char *dest, const char *src);
53 char *strncpy(char *dest, const char *src, size_t limit);
54 char *strdup(const char *s1);
55 int atoi(const char * buf);
56 uint64_t atox(const char * buf);
57 int strtoi(const char * nptr, char ** endptr);
58 uint64_t strtox(const char * nptr, char ** endptr);
59 char *strchr(const char *s, int c);
60 char *strrchr(const char *s, int c);
61 char *strpbrk(const char *s, const char *accept);
63 size_t strspn(const char * s, const char * accept);
64 size_t strcspn(const char * s, const char * reject);
65 char * strstr(const char * haystack, const char * needle);
67 void str_tolower(char * s);
68 void str_toupper(char * s);
72 #define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
73 #define isascii(c) (((c) & ~0x7f) == 0)
74 #define isupper(c) ((c) >= 'A' && (c) <= 'Z')
75 #define islower(c) ((c) >= 'a' && (c) <= 'z')
76 #define isalpha(c) (isupper(c) || islower(c))
77 #define isdigit(c) ((c) >= '0' && (c) <= '9')
78 #define isxdigit(c) (isdigit(c) \
79 || ((c) >= 'A' && (c) <= 'F') \
80 || ((c) >= 'a' && (c) <= 'f'))
81 #define isprint(c) ((c) >= ' ' && (c) <= '~')
83 #define toupper(c) ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z')))
84 #define tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z')))