/*1* Copyright 2008-2012 Freescale Semiconductor Inc.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions are met:5* * Redistributions of source code must retain the above copyright6* notice, this list of conditions and the following disclaimer.7* * Redistributions in binary form must reproduce the above copyright8* notice, this list of conditions and the following disclaimer in the9* documentation and/or other materials provided with the distribution.10* * Neither the name of Freescale Semiconductor nor the11* names of its contributors may be used to endorse or promote products12* derived from this software without specific prior written permission.13*14*15* ALTERNATIVELY, this software may be distributed under the terms of the16* GNU General Public License ("GPL") as published by the Free Software17* Foundation, either version 2 of that License or (at your option) any18* later version.19*20* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY21* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED22* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE23* DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY24* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES25* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;26* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND27* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT28* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS29* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.30*/313233#ifndef __STDLIB_EXT_H34#define __STDLIB_EXT_H353637#if (defined(NCSW_LINUX)) && defined(__KERNEL__)38#include "stdarg_ext.h"39#include "std_ext.h"404142/**43* strtoul - convert a string to an uint32_t44* @cp: The start of the string45* @endp: A pointer to the end of the parsed string will be placed here46* @base: The number base to use47*/48uint32_t strtoul(const char *cp,char **endp,uint32_t base);4950/**51* strtol - convert a string to a int32_t52* @cp: The start of the string53* @endp: A pointer to the end of the parsed string will be placed here54* @base: The number base to use55*/56long strtol(const char *cp,char **endp,uint32_t base);5758/**59* strtoull - convert a string to an uint64_t60* @cp: The start of the string61* @endp: A pointer to the end of the parsed string will be placed here62* @base: The number base to use63*/64uint64_t strtoull(const char *cp,char **endp,uint32_t base);6566/**67* strtoll - convert a string to a int64 long68* @cp: The start of the string69* @endp: A pointer to the end of the parsed string will be placed here70* @base: The number base to use71*/72long long strtoll(const char *cp,char **endp,uint32_t base);7374/**75* atoi - convert a character to a int76* @s: The start of the string77*/78int atoi(const char *s);7980/**81* strnlen - Find the length of a length-limited string82* @s: The string to be sized83* @count: The maximum number of bytes to search84*/85size_t strnlen(const char * s, size_t count);8687/**88* strlen - Find the length of a string89* @s: The string to be sized90*/91size_t strlen(const char * s);9293/**94* strtok - Split a string into tokens95* @s: The string to be searched96* @ct: The characters to search for97*98* WARNING: strtok is deprecated, use strsep instead.99*/100char * strtok(char * s,const char * ct);101102/**103* strncpy - Copy a length-limited, %NUL-terminated string104* @dest: Where to copy the string to105* @src: Where to copy the string from106* @count: The maximum number of bytes to copy107*108* Note that unlike userspace strncpy, this does not %NUL-pad the buffer.109* However, the result is not %NUL-terminated if the source exceeds110* @count bytes.111*/112char * strncpy(char * dest,const char *src,size_t count);113114/**115* strcpy - Copy a %NUL terminated string116* @dest: Where to copy the string to117* @src: Where to copy the string from118*/119char * strcpy(char * dest,const char *src);120121/**122* vsscanf - Unformat a buffer into a list of arguments123* @buf: input buffer124* @fmt: format of buffer125* @args: arguments126*/127int vsscanf(const char * buf, const char * fmt, va_list args);128129/**130* vsnprintf - Format a string and place it in a buffer131* @buf: The buffer to place the result into132* @size: The size of the buffer, including the trailing null space133* @fmt: The format string to use134* @args: Arguments for the format string135*136* Call this function if you are already dealing with a va_list.137* You probably want snprintf instead.138*/139int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);140141/**142* vsprintf - Format a string and place it in a buffer143* @buf: The buffer to place the result into144* @fmt: The format string to use145* @args: Arguments for the format string146*147* Call this function if you are already dealing with a va_list.148* You probably want sprintf instead.149*/150int vsprintf(char *buf, const char *fmt, va_list args);151152#elif defined(NCSW_FREEBSD)153#include <sys/param.h>154#include <sys/kernel.h>155#include <sys/libkern.h>156157#else158#include <stdlib.h>159#include <stdio.h>160#endif /* defined(NCSW_LINUX) && defined(__KERNEL__) */161162#include "std_ext.h"163164165#endif /* __STDLIB_EXT_H */166167168