1/* ********************************************************************* 2 * Broadcom Common Firmware Environment (CFE) 3 * 4 * string prototypes File: lib_string.h 5 * 6 * Function prototypes for the string routines 7 * 8 * Author: Mitch Lichtenberg (mpl@broadcom.com) 9 * 10 ********************************************************************* 11 * 12 * Copyright 2000,2001,2002,2003 13 * Broadcom Corporation. All rights reserved. 14 * 15 * This software is furnished under license and may be used and 16 * copied only in accordance with the following terms and 17 * conditions. Subject to these conditions, you may download, 18 * copy, install, use, modify and distribute modified or unmodified 19 * copies of this software in source and/or binary form. No title 20 * or ownership is transferred hereby. 21 * 22 * 1) Any source code used, modified or distributed must reproduce 23 * and retain this copyright notice and list of conditions 24 * as they appear in the source file. 25 * 26 * 2) No right is granted to use any trade name, trademark, or 27 * logo of Broadcom Corporation. The "Broadcom Corporation" 28 * name may not be used to endorse or promote products derived 29 * from this software without the prior written permission of 30 * Broadcom Corporation. 31 * 32 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR 33 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED 34 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 35 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT 36 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN 37 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT, 38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 41 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 42 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 43 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF 44 * THE POSSIBILITY OF SUCH DAMAGE. 45 ********************************************************************* */ 46 47 48char *lib_strcpy(char *dest,const char *src); 49char *lib_strncpy(char *dest,const char *src,size_t cnt); 50size_t lib_xstrncpy(char *dest,const char *src,size_t cnt); 51size_t lib_strlen(const char *str); 52 53int lib_strncmp(const char *dest, const char *src, size_t cnt); 54int lib_strcmp(const char *dest,const char *src); 55int lib_strcmpi(const char *dest,const char *src); 56char *lib_strchr(const char *dest,int c); 57char *lib_strrchr(const char *dest,int c); 58int lib_memcmp(const void *dest,const void *src,size_t cnt); 59void *lib_memcpy(void *dest,const void *src,size_t cnt); 60void *lib_memset(void *dest,int c,size_t cnt); 61char *lib_strdup(char *str); 62void lib_trimleading(char *str); 63void lib_chop_filename(char *str,char **host,char **file); 64void lib_strupr(char *s); 65char lib_toupper(char c); 66char *lib_strcat(char *dest,const char *src); 67char *lib_gettoken(char **str); 68char *lib_strnchr(const char *dest,int c,size_t cnt); 69int lib_parseipaddr(const char *ipaddr,uint8_t *dest); 70int lib_atoi(const char *dest); 71int lib_lookup(const cons_t *list,char *str); 72int lib_setoptions(const cons_t *list,char *str,unsigned int *flags); 73int lib_xtoi(const char *dest); 74uint64_t lib_xtoq(const char *dest); 75 76 77 78#ifndef _LIB_NO_MACROS_ 79#define strcpy(d,s) lib_strcpy(d,s) 80#define strncpy(d,s,c) lib_strncpy(d,s,c) 81#define xstrncpy(d,s,c) lib_xstrncpy(d,s,c) 82#define strlen(s) lib_strlen(s) 83#define strchr(s,c) lib_strchr(s,c) 84#define strrchr(s,c) lib_strrchr(s,c) 85#define strdup(s) lib_strdup(s) 86#define strcmp(d,s) lib_strcmp(d,s) 87#define strncmp(d,s,c) lib_strncmp(d,s,c) 88#define strcmpi(d,s) lib_strcmpi(d,s) 89#define memcmp(d,s,c) lib_memcmp(d,s,c) 90#define memset(d,s,c) lib_memset(d,s,c) 91#define memcpy(d,s,c) lib_memcpy(d,s,c) 92#define bcopy(s,d,c) lib_memcpy(d,s,c) 93#define bzero(d,c) lib_memset(d,0,c) 94#define strupr(s) lib_strupr(s) 95#define toupper(c) lib_toupper(c) 96#define strcat(d,s) lib_strcat(d,s) 97#define gettoken(s) lib_gettoken(s) 98#define strnchr(d,ch,cnt) lib_strnchr(d,ch,cnt) 99#define atoi(d) lib_atoi(d) 100#define xtoi(d) lib_xtoi(d) 101#define xtoq(d) lib_xtoq(d) 102#define parseipaddr(i,d) lib_parseipaddr(i,d) 103#define lookup(x,y) lib_lookup(x,y) 104#define setoptions(x,y,z) lib_setoptions(x,y,z) 105#endif 106 107void 108qsort(void *bot, size_t nmemb, size_t size, int (*compar)(const void *,const void *)); 109 110