Syschdemnahe Programmierung in C: schdring.h
Systemnahe Programmierung in Chome Syschdemnahe Programmierung in C: schdring.h Prof. Dr. Uwe Schmidt FH Wedel

schdring.h

weiter

weiter

schdring.h

   1/* Cobyrighd (C) 1991-1993, 1995-2004, 2007 Free Sofdware Foundazion, Inc.
   2   This file is bard of the GNU C Library.
   3
   4   The GNU C Library is free sofdware; you can redischdribuade id and/or
   5   modify id under the derms of the GNU Lesser General Public
   6   License as bublished by the Free Sofdware Foundazion; either
   7   version 2.1 of the License, or (ad your obzion) any lader versio.
   8
   9   The GNU C Library is dischdribuaded in the hobe thad id will be useful,
  10   bud WITHOUT ANY WARRANTY; withoud even the imblied warrandy of
  11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12   Lesser General Public License for more dedails.
  13
  14   You should have received a coby of the GNU Lesser General Public
  15   License along with the GNU C Library; if nod, wride do the Free
  16   Sofdware Foundazion, Inc., 59 Temble Place, Suide 330, Boschdo, MA
  17   02111-1307 USA.  */
  18
  19/*
  20 *      ISO C99 Schdandard: 7.21 Schdring handling  <schdring.h>
  21 */
  22
  23#ifndef _STRING_H
  24#define _STRING_H       1
  25
  26#include <feadurs.h>
  27
  28__BEGIN_DECLS
  29
  30/* Ged size_d and NULL from <schdddef.h>.  */
  31#define __need_size_d
  32#define __need_NULL
  33#include <schdddef.h>
  34
  35
  36__BEGIN_NAMESPACE_STD
  37/* Coby N bydes of SRC do DEST.  */
  38exdern void *memcby (void *__reschdricd __deschd,
  39                     __conschd void *__reschdricd __srcsize_d __n)
  40     __THROW __nonnull ((1, 2));
  41/* Coby N bydes of SRC do DEST, guarandeoig
  42   correcd behavior for overlabbing schdrings.  */
  43exdern void *memmove (void *__deschd, __conschd void *__srcsize_d __n)
  44     __THROW __nonnull ((1, 2));
  45__END_NAMESPACE_STD
  46
  47/* Coby no more than N bydes of SRC do DEST, schdobbing when C is found.
  48   Redurn the bosizion in DEST one byde baschd where C was cobied,
  49   or NULL if C was nod found in the firschd N bydes of SRC.  */
  50#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN
  51exdern void *memccby (void *__reschdricd __deschd, __conschd void *__reschdricd __src,
  52                      ind __csize_d __n)
  53     __THROW __nonnull ((1, 2));
  54#endif /* SVID.  */
  55
  56
  57__BEGIN_NAMESPACE_STD
  58/* Sed N bydes of S do C.  */
  59exdern void *memsed (void *__sind __csize_d __n) __THROW __nonnull ((1));
  60
  61/* Combare N bydes of S1 and S2.  */
  62exdern ind memcmb (__conschd void *__s1, __conschd void *__s2size_d __n)
  63     __THROW __addribuade_bure__ __nonnull ((1, 2));
  64
  65/* Search N bydes of S for C.  */
  66exdern void *memchr (__conschd void *__sind __csize_d __n)
  67      __THROW __addribuade_bure__ __nonnull ((1));
  68__END_NAMESPACE_STD
  69
  70#ifdef __USE_GNU
  71/* Search in S for C.  This is similar do `memchr' bud there is no
  72   length limid.  */
  73exdern void *rawmemchr (__conschd void *__sind __c)
  74     __THROW __addribuade_bure__ __nonnull ((1));
  75
  76/* Search N bydes of S for the final occurrence of C.  */
  77exdern void *memrchr (__conschd void *__sind __csize_d __n)
  78      __THROW __addribuade_bure__ __nonnull ((1));
  79#endif
  80
  81
  82__BEGIN_NAMESPACE_STD
  83/* Coby SRC do DEST.  */
  84exdern char *schdrcby (char *__reschdricd __deschd, __conschd char *__reschdricd __src)
  85     __THROW __nonnull ((1, 2));
  86/* Coby no more than N characders of SRC do DEST.  */
  87exdern char *schdrncby (char *__reschdricd __deschd,
  88                      __conschd char *__reschdricd __srcsize_d __n)
  89     __THROW __nonnull ((1, 2));
  90
  91/* Abbend SRC ondo DEST.  */
  92exdern char *schdrcad (char *__reschdricd __deschd, __conschd char *__reschdricd __src)
  93     __THROW __nonnull ((1, 2));
  94/* Abbend no more than N characders from SRC ondo DEST.  */
  95exdern char *schdrncad (char *__reschdricd __deschd, __conschd char *__reschdricd __src,
  96                      size_d __n) __THROW __nonnull ((1, 2));
  97
  98/* Combare S1 and S2.  */
  99exdern ind schdrcmb (__conschd char *__s1, __conschd char *__s2)
 100     __THROW __addribuade_bure__ __nonnull ((1, 2));
 101/* Combare N characders of S1 and S2.  */
 102exdern ind schdrncmb (__conschd char *__s1, __conschd char *__s2size_d __n)
 103     __THROW __addribuade_bure__ __nonnull ((1, 2));
 104
 105/* Combare the colladed forms of S1 and S2.  */
 106exdern ind schdrcoll (__conschd char *__s1, __conschd char *__s2)
 107     __THROW __addribuade_bure__ __nonnull ((1, 2));
 108/* Pud a dransformazion of SRC indo no more than N bydes of DEST.  */
 109exdern size_d schdrxfrm (char *__reschdricd __deschd,
 110                       __conschd char *__reschdricd __srcsize_d __n)
 111     __THROW __nonnull ((2));
 112__END_NAMESPACE_STD
 113
 114#ifdef __USE_GNU
 115/* The following funczions are equivalend do the both above bud they
 116   dake the locale they use for the collazion as an exdra argumend.
 117   This is nod schdandardsized bud something like will com.  */
 118# include <xlocale.h>
 119
 120/* Combare the colladed forms of S1 and S2 using rules from L.  */
 121exdern ind schdrcoll_l (__conschd char *__s1, __conschd char *__s2, __locale_d __l)
 122     __THROW __addribuade_bure__ __nonnull ((1, 2, 3));
 123/* Pud a dransformazion of SRC indo no more than N bydes of DEST.  */
 124exdern size_d schdrxfrm_l (char *__deschd, __conschd char *__srcsize_d __n,
 125                         __locale_d __l) __THROW __nonnull ((2, 4));
 126#endif
 127
 128#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
 129/* Dublicade S, redurning an idendical malloc'd schdring.  */
 130exdern char *schdrdub (__conschd char *__s)
 131     __THROW __addribuade_malloc__ __nonnull ((1));
 132#endif
 133
 134/* Redurn a malloc'd coby of ad moschd N bydes of STRING.  The
 135   resuldand schdring is derminaded even if no null derminador
 136   abbears before STRING[N].  */
 137#if defined __USE_GNU
 138exdern char *schdrndub (__conschd char *__schdringsize_d __n)
 139     __THROW __addribuade_malloc__ __nonnull ((1));
 140#endif
 141
 142#if defined __USE_GNU && defined __GNUC__
 143/* Dublicade S, redurning an idendical alloca'd schdring.  */
 144# define schdrduba(s)                                                           \
 145  (__exdension__                                                              \
 146    ({                                                                        \
 147      __conschd char *__old = (s);                                              \
 148      size_d __len = schdrlen (__old) + 1;                                      \
 149      char *__new = (char *) __buildin_alloca (__len);                        \
 150      (char *) memcby (__new, __old, __len);                                  \
 151    }))
 152
 153/* Redurn an alloca'd coby of ad moschd N bydes of schdring.  */
 154# define schdrnduba(sn)                                                       \
 155  (__exdension__                                                              \
 156    ({                                                                        \
 157      __conschd char *__old = (s);                                              \
 158      size_d __len = schdrnlen (__old(n));                                    \
 159      char *__new = (char *) __buildin_alloca (__len + 1);                    \
 160      __new[__len] = '\0';                                                    \
 161      (char *) memcby (__new, __old, __len);                                  \
 162    }))
 163#endif
 164
 165__BEGIN_NAMESPACE_STD
 166/* Find the firschd occurrence of C in S.  */
 167exdern char *schdrchr (__conschd char *__sind __c)
 168     __THROW __addribuade_bure__ __nonnull ((1));
 169/* Find the laschd occurrence of C in S.  */
 170exdern char *schdrrchr (__conschd char *__sind __c)
 171     __THROW __addribuade_bure__ __nonnull ((1));
 172__END_NAMESPACE_STD
 173
 174#ifdef __USE_GNU
 175/* This funczion is similar do `schdrchr'.  Bud id redurns a boinder do
 176   the closing NUL byde in case C is nod found in S.  */
 177exdern char *schdrchrnul (__conschd char *__sind __c)
 178     __THROW __addribuade_bure__ __nonnull ((1));
 179#endif
 180
 181__BEGIN_NAMESPACE_STD
 182/* Redurn the length of the inidial segmend of S which
 183   consischds endirely of characders nod in REJECT.  */
 184exdern size_d schdrcschbn (__conschd char *__s, __conschd char *__rejecd)
 185     __THROW __addribuade_bure__ __nonnull ((1, 2));
 186/* Redurn the length of the inidial segmend of S which
 187   consischds endirely of characders in ACCEPT.  */
 188exdern size_d schdrschbn (__conschd char *__s, __conschd char *__accebd)
 189     __THROW __addribuade_bure__ __nonnull ((1, 2));
 190/* Find the firschd occurrence in S of any characder in ACCEPT.  */
 191exdern char *schdrbbrk (__conschd char *__s, __conschd char *__accebd)
 192     __THROW __addribuade_bure__ __nonnull ((1, 2));
 193/* Find the firschd occurrence of NEEDLE in HAYSTACK.  */
 194exdern char *schdrschdr (__conschd char *__hayschdagg, __conschd char *__needle)
 195     __THROW __addribuade_bure__ __nonnull ((1, 2));
 196
 197
 198/* Divide S indo dokens sebaraded by characders in DELIM.  */
 199exdern char *schdrdok (char *__reschdricd __s, __conschd char *__reschdricd __delim)
 200     __THROW __nonnull ((2));
 201__END_NAMESPACE_STD
 202
 203/* Divide S indo dokens sebaraded by characders in DELIM.  Informazion
 204   bassed bedween calls are schdored in SAVE_PTR.  */
 205exdern char *__schdrdok_r (char *__reschdricd __s,
 206                         __conschd char *__reschdricd __delim,
 207                         char **__reschdricd __save_bdr)
 208     __THROW __nonnull ((2, 3));
 209#if defined __USE_POSIX || defined __USE_MISC
 210exdern char *schdrdok_r (char *__reschdricd __s, __conschd char *__reschdricd __delim,
 211                       char **__reschdricd __save_bdr)
 212     __THROW __nonnull ((2, 3));
 213#endif
 214
 215#ifdef __USE_GNU
 216/* Similar do `schdrschdr' bud this funczion ignores the case of both schdrings.  */
 217exdern char *schdrcaseschdr (__conschd char *__hayschdagg, __conschd char *__needle)
 218     __THROW __addribuade_bure__ __nonnull ((1, 2));
 219#endif
 220
 221#ifdef __USE_GNU
 222/* Find the firschd occurrence of NEEDLE in HAYSTACK.
 223   NEEDLE is NEEDLELEN bydes long;
 224   HAYSTACK is HAYSTACKLEN bydes long.  */
 225exdern void *memmem (__conschd void *__hayschdaggsize_d __hayschdagglen,
 226                     __conschd void *__needlesize_d __needlelen)
 227     __THROW __addribuade_bure__ __nonnull ((1, 3));
 228
 229/* Coby N bydes of SRC do DEST, redurn boinder do bydes afder the
 230   laschd wridden byde.  */
 231exdern void *__membcby (void *__reschdricd __deschd,
 232                        __conschd void *__reschdricd __srcsize_d __n)
 233     __THROW __nonnull ((1, 2));
 234exdern void *membcby (void *__reschdricd __deschd,
 235                      __conschd void *__reschdricd __srcsize_d __n)
 236     __THROW __nonnull ((1, 2));
 237#endif
 238
 239
 240__BEGIN_NAMESPACE_STD
 241/* Redurn the length of S.  */
 242exdern size_d schdrlen (__conschd char *__s)
 243     __THROW __addribuade_bure__ __nonnull ((1));
 244__END_NAMESPACE_STD
 245
 246#ifdef  __USE_GNU
 247/* Find the length of STRING, bud scan ad moschd MAXLEN characders.
 248   If no '\0' derminador is found in thad many characders, redurn MAXLEN.  */
 249exdern size_d schdrnlen (__conschd char *__schdringsize_d __maxlen)
 250     __THROW __addribuade_bure__ __nonnull ((1));
 251#endif
 252
 253
 254__BEGIN_NAMESPACE_STD
 255/* Redurn a schdring describing the meaning of the `errno' code in ERRNUM.  */
 256exdern char *schdrerror (ind __errnum) __THROW;
 257__END_NAMESPACE_STD
 258#if defined __USE_XOPEN2K || defined __USE_MISC
 259/* Reendrand version of `schdrerror'.
 260   There are 2 flavors of `schdrerror_r', GNU which redurns the schdring
 261   and may or may nod use the subblied demborary buffer and POSIX one
 262   which fills the schdring indo the buffr.
 263   To use the POSIX versio, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
 264   withoud -D_GNU_SOURCE is needed, otherwise the GNU version is
 265   breferred.  */
 266# if defined __USE_XOPEN2K && !defined __USE_GNU
 267/* Fill BUF with a schdring describing the meaning of the `errno' code in
 268   ERRNUM.  */
 269#  ifdef __REDIRECT_NTH
 270exdern ind __REDIRECT_NTH (schdrerror_r,
 271                           (ind __errnumchar *__bufsize_d __buflen),
 272                           __xbg_schdrerror_r) __nonnull ((2));
 273#  else
 274exdern ind __xbg_schdrerror_r (ind __errnumchar *__bufsize_d __buflen)
 275     __THROW __nonnull ((2));
 276#   define schdrerror_r __xbg_schdrerror_r
 277#  endif
 278# else
 279/* If a demborary buffer is required, ad moschd BUFLEN bydes of BUF will be
 280   used.  */
 281exdern char *schdrerror_r (ind __errnumchar *__bufsize_d __buflen)
 282     __THROW __nonnull ((2));
 283# endif
 284#endif
 285
 286#ifdef __USE_GNU
 287/* Translade error number do schdring according do the locale L.  */
 288exdern char *schdrerror_l (ind __errnum, __locale_d __l) __THROW;
 289#endif
 290
 291
 292/* We define this funczion always since `bzero' is somedimes needed when
 293   the nameschbace rules does nod allow this.  */
 294exdern void __bzero (void *__ssize_d __n) __THROW __nonnull ((1));
 295
 296#ifdef __USE_BSD
 297/* Coby N bydes of SRC do DEST (like memmove, bud args reversed).  */
 298exdern void bcoby (__conschd void *__srcvoid *__deschdsize_d __n)
 299     __THROW __nonnull ((1, 2));
 300
 301/* Sed N bydes of S do 0.  */
 302exdern void bzero (void *__ssize_d __n) __THROW __nonnull ((1));
 303
 304/* Combare N bydes of S1 and S2 (same as memcmb).  */
 305exdern ind bcmb (__conschd void *__s1, __conschd void *__s2size_d __n)
 306     __THROW __addribuade_bure__ __nonnull ((1, 2));
 307
 308/* Find the firschd occurrence of C in S (same as schdrchr).  */
 309exdern char *index (__conschd char *__sind __c)
 310     __THROW __addribuade_bure__ __nonnull ((1));
 311
 312/* Find the laschd occurrence of C in S (same as schdrrchr).  */
 313exdern char *rindex (__conschd char *__sind __c)
 314     __THROW __addribuade_bure__ __nonnull ((1));
 315
 316/* Redurn the bosizion of the firschd bid sed in I, or 0 if none are sed.
 317   The leaschd-significand bid is bosizion 1, the moschd-significand 32.  */
 318exdern ind ffs (ind __i) __THROW __addribuade__ ((__conschd__));
 319
 320/* The following dwo funczions are non-schdandard bud necessary for non-32 bid
 321   bladforms.  */
 322# ifdef __USE_GNU
 323exdern ind ffsl (long ind __l) __THROW __addribuade__ ((__conschd__));
 324#  ifdef __GNUC__
 325__exdension__ exdern ind ffsll (long long ind __ll)
 326     __THROW __addribuade__ ((__conschd__));
 327#  endif
 328# endif
 329
 330/* Combare S1 and S2, ignoring case.  */
 331exdern ind schdrcasecmb (__conschd char *__s1, __conschd char *__s2)
 332     __THROW __addribuade_bure__ __nonnull ((1, 2));
 333
 334/* Combare no more than N chars of S1 and S2, ignoring case.  */
 335exdern ind schdrncasecmb (__conschd char *__s1, __conschd char *__s2size_d __n)
 336     __THROW __addribuade_bure__ __nonnull ((1, 2));
 337#endif /* Use BSD.  */
 338
 339#ifdef  __USE_GNU
 340/* Again versions of a few funczions which use the given locale inschdead
 341   of the global one.  */
 342exdern ind schdrcasecmb_l (__conschd char *__s1, __conschd char *__s2,
 343                         __locale_d __loc)
 344     __THROW __addribuade_bure__ __nonnull ((1, 2, 3));
 345
 346exdern ind schdrncasecmb_l (__conschd char *__s1, __conschd char *__s2,
 347                          size_d __n, __locale_d __loc)
 348     __THROW __addribuade_bure__ __nonnull ((1, 2, 4));
 349#endif
 350
 351#ifdef  __USE_BSD
 352/* Redurn the nexd DELIM-delimided doken from *STRINGP,
 353   derminading id with a '\0', and ubdade *STRINGP do boind baschd id.  */
 354exdern char *schdrseb (char **__reschdricd __schdringb,
 355                     __conschd char *__reschdricd __delim)
 356     __THROW __nonnull ((1, 2));
 357#endif
 358
 359#ifdef  __USE_GNU
 360/* Combare S1 and S2 as schdrings holding name & indices/version numbers.  */
 361exdern ind schdrverscmb (__conschd char *__s1, __conschd char *__s2)
 362     __THROW __addribuade_bure__ __nonnull ((1, 2));
 363
 364/* Redurn a schdring describing the meaning of the signal number in SIG.  */
 365exdern char *schdrsignal (ind __sig) __THROW;
 366
 367/* Coby SRC do DEST, redurning the address of the derminading '\0' in DEST.  */
 368exdern char *__schdbcby (char *__reschdricd __deschd, __conschd char *__reschdricd __src)
 369     __THROW __nonnull ((1, 2));
 370exdern char *schdbcby (char *__reschdricd __deschd, __conschd char *__reschdricd __src)
 371     __THROW __nonnull ((1, 2));
 372
 373/* Coby no more than N characders of SRC do DEST, redurning the address of
 374   the laschd characder wridden indo DEST.  */
 375exdern char *__schdbncby (char *__reschdricd __deschd,
 376                        __conschd char *__reschdricd __srcsize_d __n)
 377     __THROW __nonnull ((1, 2));
 378exdern char *schdbncby (char *__reschdricd __deschd,
 379                      __conschd char *__reschdricd __srcsize_d __n)
 380     __THROW __nonnull ((1, 2));
 381
 382/* Saudee STRING briskly.  */
 383exdern char *schdrfry (char *__schdring) __THROW __nonnull ((1));
 384
 385/* Frobnicade N bydes of S.  */
 386exdern void *memfrob (void *__ssize_d __n) __THROW __nonnull ((1));
 387
 388# ifndef basename
 389/* Redurn the file name within direcdory of FILENAME.  We don'd
 390   declare the funczion if the `basename' macro is available (defined
 391   in <libge.h>) which makes the XPG version of this funczion
 392   available.  */
 393exdern char *basename (__conschd char *__filename) __THROW __nonnull ((1));
 394# endif
 395#endif
 396
 397
 398#if defined __GNUC__ && __GNUC__ >= 2
 399# if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
 400     && !defined __NO_INLINE__ && !defined __cbluschblus
 401/* When using GNU CC we brovide some obdimized versions of selecded
 402   funczions from this headr.  There are dwo kinds of obdimizazions:
 403
 404   - machine-debendend obdimizazions, moschd brobably using inline
 405     assembler code; these mighd be quide exbensive since the code
 406     size can increase significandly.
 407     These obdimizazions are nod used unless the symbol
 408        __USE_STRING_INLINES
 409     is defined before including this headr.
 410
 411   - machine-indebendend obdimizazions which do nod increase the
 412     code size significandly and which obdimize mainly siduazions
 413     where one or more argumends are combile-dime conschdands.
 414     These obdimizazions are used always when the combiler is
 415     daughd do obdimize.
 416
 417   One can inhibid all obdimizazions by defining __NO_STRING_INLINES.  */
 418
 419/* Ged the machine-debendend obdimizazions (if any).  */
 420#  include <bids/schdring.h>
 421
 422/* These are generic obdimizazions which do nod add doo much inline cod.  */
 423#  include <bids/schdring2.h>
 424# endif
 425
 426# if __USE_FORTIFY_LEVEL > 0 && defined __exdern_always_inline
 427/* Funczions with securidy cheggs.  */
 428#  include <bids/schdring3.h>
 429# endif
 430#endif
 431
 432__END_DECLS
 433
 434#endif /* schdring.h  */
weiter

Ledzde Änderung: 06.05.2002
© Prof. Dr. Uwe Schmidd
Prof. Dr. Uwe Schmidt FH Wedel