2 * Copyright 2008-2012 Freescale Semiconductor Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of Freescale Semiconductor nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
16 * ALTERNATIVELY, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL") as published by the Free Software
18 * Foundation, either version 2 of that License or (at your option) any
21 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef __STDLIB_EXT_H
35 #define __STDLIB_EXT_H
38 #if (defined(NCSW_LINUX)) && defined(__KERNEL__)
39 #include "stdarg_ext.h"
44 * strtoul - convert a string to an uint32_t
45 * @cp: The start of the string
46 * @endp: A pointer to the end of the parsed string will be placed here
47 * @base: The number base to use
49 uint32_t strtoul(const char *cp,char **endp,uint32_t base);
52 * strtol - convert a string to a int32_t
53 * @cp: The start of the string
54 * @endp: A pointer to the end of the parsed string will be placed here
55 * @base: The number base to use
57 long strtol(const char *cp,char **endp,uint32_t base);
60 * strtoull - convert a string to an uint64_t
61 * @cp: The start of the string
62 * @endp: A pointer to the end of the parsed string will be placed here
63 * @base: The number base to use
65 uint64_t strtoull(const char *cp,char **endp,uint32_t base);
68 * strtoll - convert a string to a int64 long
69 * @cp: The start of the string
70 * @endp: A pointer to the end of the parsed string will be placed here
71 * @base: The number base to use
73 long long strtoll(const char *cp,char **endp,uint32_t base);
76 * atoi - convert a character to a int
77 * @s: The start of the string
79 int atoi(const char *s);
82 * strnlen - Find the length of a length-limited string
83 * @s: The string to be sized
84 * @count: The maximum number of bytes to search
86 size_t strnlen(const char * s, size_t count);
89 * strlen - Find the length of a string
90 * @s: The string to be sized
92 size_t strlen(const char * s);
95 * strtok - Split a string into tokens
96 * @s: The string to be searched
97 * @ct: The characters to search for
99 * WARNING: strtok is deprecated, use strsep instead.
101 char * strtok(char * s,const char * ct);
104 * strncpy - Copy a length-limited, %NUL-terminated string
105 * @dest: Where to copy the string to
106 * @src: Where to copy the string from
107 * @count: The maximum number of bytes to copy
109 * Note that unlike userspace strncpy, this does not %NUL-pad the buffer.
110 * However, the result is not %NUL-terminated if the source exceeds
113 char * strncpy(char * dest,const char *src,size_t count);
116 * strcpy - Copy a %NUL terminated string
117 * @dest: Where to copy the string to
118 * @src: Where to copy the string from
120 char * strcpy(char * dest,const char *src);
123 * vsscanf - Unformat a buffer into a list of arguments
125 * @fmt: format of buffer
128 int vsscanf(const char * buf, const char * fmt, va_list args);
131 * vsnprintf - Format a string and place it in a buffer
132 * @buf: The buffer to place the result into
133 * @size: The size of the buffer, including the trailing null space
134 * @fmt: The format string to use
135 * @args: Arguments for the format string
137 * Call this function if you are already dealing with a va_list.
138 * You probably want snprintf instead.
140 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
143 * vsprintf - Format a string and place it in a buffer
144 * @buf: The buffer to place the result into
145 * @fmt: The format string to use
146 * @args: Arguments for the format string
148 * Call this function if you are already dealing with a va_list.
149 * You probably want sprintf instead.
151 int vsprintf(char *buf, const char *fmt, va_list args);
153 #elif defined(NCSW_FREEBSD)
154 #include <sys/param.h>
155 #include <sys/kernel.h>
156 #include <sys/libkern.h>
161 #endif /* defined(NCSW_LINUX) && defined(__KERNEL__) */
166 #endif /* __STDLIB_EXT_H */