2
* Copyright (C) 2001 - 2004 Mike Wray <mike.wray@hp.com>
4
* This library is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; either version 2.1 of the License, or
7
* (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public License
15
* along with this library; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#ifndef _XUTIL_SYS_STRING_H_
20
#define _XUTIL_SYS_STRING_H_
22
* Replacement for standard string includes.
23
* Works in user or kernel code.
25
/*============================================================================*/
28
#include <linux/config.h>
29
#include <linux/kernel.h>
30
#include <linux/string.h>
31
#include <linux/types.h>
35
extern char *strerror(int err);
38
static inline int tolower(int c){
39
return (c>='A' && c<='Z' ? (c-'A')+'a' : c);
43
static inline int isalpha(int c){
44
return (c>='A' && c<='Z') || (c>='a' && c<='z');
47
static inline int isdigit(int c){
48
return (c>='0' && c<='9');
52
static inline int strcasecmp(const char *s1, const char *s2){
58
} while (c1 && c1 == c2);
63
static inline char * strdup(const char *s){
64
int n = (s ? 1+strlen(s) : 0);
65
char *copy = (n ? allocate(n) : NULL);
72
/*============================================================================*/
78
static inline size_t strnlen(const char *s, size_t n){
81
for(k=0; *s && k<n; s++, k++){}
88
/*============================================================================*/
90
extern int convert_atoul(const char *s, unsigned long *v);
91
extern int convert_atol(const char *s, long *v);
92
extern int path_concat(char *s, char *t, char **val);
94
#endif /* !_XUTIL_SYS_STRING_H_ */