2 * Creation Date: <2002/10/12 20:41:57 samuel>
3 * Time-stamp: <2003/10/25 12:51:22 samuel>
7 * string library functions
9 * Copyright (C) 2002, 2003 Samuel Rydh (samuel@ibrium.se)
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
22 #define bzero(s,n) memset( s, 0, n )
23 #define atol(nptr) strtol(nptr, NULL, 10 )
25 extern long strtol( const char *nptr, char **endptr, int base );
26 extern long long int strtoll( const char *nptr, char **endptr, int base );
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);
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 );
51 extern char *strncpy_nopad( char *dest, const char *src, size_t n );
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) */
62 extern const unsigned char _ctype[];
64 #define __ismask(x) (_ctype[(int)(unsigned char)(x)])
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)
78 #define isascii(c) (((unsigned char)(c))<=0x7f)
79 #define toascii(c) (((unsigned char)(c))&0x7f)
82 static inline unsigned char __tolower(unsigned char c) {
88 static inline unsigned char __toupper(unsigned char c) {
94 #define tolower(c) __tolower(c)
95 #define toupper(c) __toupper(c)
100 extern long __guard[8];
102 void __stack_smash_handler(const char *func, int damaged);
103 void __stack_chk_fail(void);
105 #endif /* _H_STRING */