string.h

来自「参照MINIX3写的操作系统 用GCC+NASM+BOCHS开发」· C头文件 代码 · 共 435 行 · 第 1/2 页

H
435
字号
/* Copyright (C) 1991-1993, 1995-2004, 2007 Free Software Foundation, Inc.   This file is part of the GNU C Library.   The GNU C Library is free software; you can redistribute it and/or   modify it under the terms of the GNU Lesser General Public   License as published by the Free Software Foundation; either   version 2.1 of the License, or (at your option) any later version.   The GNU C Library is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   Lesser General Public License for more details.   You should have received a copy of the GNU Lesser General Public   License along with the GNU C Library; if not, write to the Free   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   02111-1307 USA.  *//* *	ISO C99 Standard: 7.21 String handling	<string.h> */#ifndef	_STRING_H#define	_STRING_H	1#include <features.h>__BEGIN_DECLS/* Get size_t and NULL from <stddef.h>.  */#define	__need_size_t#include <stddef.h>__BEGIN_NAMESPACE_STD/* Copy N bytes of SRC to DEST.  */extern void *memcpy (void *__restrict __dest,		     __const void *__restrict __src, size_t __n)     __THROW __nonnull ((1, 2));/* Copy N bytes of SRC to DEST, guaranteeing   correct behavior for overlapping strings.  */extern void *memmove (void *__dest, __const void *__src, size_t __n)     __THROW __nonnull ((1, 2));__END_NAMESPACE_STD/* Copy no more than N bytes of SRC to DEST, stopping when C is found.   Return the position in DEST one byte past where C was copied,   or NULL if C was not found in the first N bytes of SRC.  */#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPENextern void *memccpy (void *__restrict __dest, __const void *__restrict __src,		      int __c, size_t __n)     __THROW __nonnull ((1, 2));#endif /* SVID.  */__BEGIN_NAMESPACE_STD/* Set N bytes of S to C.  */extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));/* Compare N bytes of S1 and S2.  */extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)     __THROW __attribute_pure__ __nonnull ((1, 2));/* Search N bytes of S for C.  */extern void *memchr (__const void *__s, int __c, size_t __n)      __THROW __attribute_pure__ __nonnull ((1));__END_NAMESPACE_STD#ifdef __USE_GNU/* Search in S for C.  This is similar to `memchr' but there is no   length limit.  */extern void *rawmemchr (__const void *__s, int __c)     __THROW __attribute_pure__ __nonnull ((1));/* Search N bytes of S for the final occurrence of C.  */extern void *memrchr (__const void *__s, int __c, size_t __n)      __THROW __attribute_pure__ __nonnull ((1));#endif__BEGIN_NAMESPACE_STD/* Copy SRC to DEST.  */extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)     __THROW __nonnull ((1, 2));/* Copy no more than N characters of SRC to DEST.  */extern char *strncpy (char *__restrict __dest,		      __const char *__restrict __src, size_t __n)     __THROW __nonnull ((1, 2));/* Append SRC onto DEST.  */extern char *strcat (char *__restrict __dest, __const char *__restrict __src)     __THROW __nonnull ((1, 2));/* Append no more than N characters from SRC onto DEST.  */extern char *strncat (char *__restrict __dest, __const char *__restrict __src,		      size_t __n) __THROW __nonnull ((1, 2));/* Compare S1 and S2.  */extern int strcmp (__const char *__s1, __const char *__s2)     __THROW __attribute_pure__ __nonnull ((1, 2));/* Compare N characters of S1 and S2.  */extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)     __THROW __attribute_pure__ __nonnull ((1, 2));/* Compare the collated forms of S1 and S2.  */extern int strcoll (__const char *__s1, __const char *__s2)     __THROW __attribute_pure__ __nonnull ((1, 2));/* Put a transformation of SRC into no more than N bytes of DEST.  */extern size_t strxfrm (char *__restrict __dest,		       __const char *__restrict __src, size_t __n)     __THROW __nonnull ((2));__END_NAMESPACE_STD#ifdef __USE_GNU/* The following functions are equivalent to the both above but they   take the locale they use for the collation as an extra argument.   This is not standardsized but something like will come.  */# include <xlocale.h>/* Compare the collated forms of S1 and S2 using rules from L.  */extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)     __THROW __attribute_pure__ __nonnull ((1, 2, 3));/* Put a transformation of SRC into no more than N bytes of DEST.  */extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n,			 __locale_t __l) __THROW __nonnull ((2, 4));#endif#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED/* Duplicate S, returning an identical malloc'd string.  */extern char *strdup (__const char *__s)     __THROW __attribute_malloc__ __nonnull ((1));#endif/* Return a malloc'd copy of at most N bytes of STRING.  The   resultant string is terminated even if no null terminator   appears before STRING[N].  */#if defined __USE_GNUextern char *strndup (__const char *__string, size_t __n)     __THROW __attribute_malloc__ __nonnull ((1));#endif#if defined __USE_GNU && defined __GNUC__/* Duplicate S, returning an identical alloca'd string.  */# define strdupa(s)							      \  (__extension__							      \    ({									      \      __const char *__old = (s);					      \      size_t __len = strlen (__old) + 1;				      \      char *__new = (char *) __builtin_alloca (__len);			      \      (char *) memcpy (__new, __old, __len);				      \    }))/* Return an alloca'd copy of at most N bytes of string.  */# define strndupa(s, n)							      \  (__extension__							      \    ({									      \      __const char *__old = (s);					      \      size_t __len = strnlen (__old, (n));				      \      char *__new = (char *) __builtin_alloca (__len + 1);		      \      __new[__len] = '\0';						      \      (char *) memcpy (__new, __old, __len);				      \    }))#endif__BEGIN_NAMESPACE_STD/* Find the first occurrence of C in S.  */extern char *strchr (__const char *__s, int __c)     __THROW __attribute_pure__ __nonnull ((1));/* Find the last occurrence of C in S.  */extern char *strrchr (__const char *__s, int __c)     __THROW __attribute_pure__ __nonnull ((1));__END_NAMESPACE_STD#ifdef __USE_GNU/* This function is similar to `strchr'.  But it returns a pointer to   the closing NUL byte in case C is not found in S.  */extern char *strchrnul (__const char *__s, int __c)     __THROW __attribute_pure__ __nonnull ((1));#endif__BEGIN_NAMESPACE_STD/* Return the length of the initial segment of S which   consists entirely of characters not in REJECT.  */extern size_t strcspn (__const char *__s, __const char *__reject)     __THROW __attribute_pure__ __nonnull ((1, 2));/* Return the length of the initial segment of S which   consists entirely of characters in ACCEPT.  */extern size_t strspn (__const char *__s, __const char *__accept)     __THROW __attribute_pure__ __nonnull ((1, 2));/* Find the first occurrence in S of any character in ACCEPT.  */extern char *strpbrk (__const char *__s, __const char *__accept)     __THROW __attribute_pure__ __nonnull ((1, 2));/* Find the first occurrence of NEEDLE in HAYSTACK.  */extern char *strstr (__const char *__haystack, __const char *__needle)     __THROW __attribute_pure__ __nonnull ((1, 2));/* Divide S into tokens separated by characters in DELIM.  */extern char *strtok (char *__restrict __s, __const char *__restrict __delim)     __THROW __nonnull ((2));__END_NAMESPACE_STD/* Divide S into tokens separated by characters in DELIM.  Information   passed between calls are stored in SAVE_PTR.  */extern char *__strtok_r (char *__restrict __s,			 __const char *__restrict __delim,			 char **__restrict __save_ptr)     __THROW __nonnull ((2, 3));#if defined __USE_POSIX || defined __USE_MISCextern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,		       char **__restrict __save_ptr)     __THROW __nonnull ((2, 3));#endif#ifdef __USE_GNU/* Similar to `strstr' but this function ignores the case of both strings.  */extern char *strcasestr (__const char *__haystack, __const char *__needle)     __THROW __attribute_pure__ __nonnull ((1, 2));

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?