SYS/SYS_String.h File Reference

#include "SYS_API.h"
#include <ctype.h>
#include <string.h>

Go to the source code of this file.

Functions

char * SYSstrtok (char *string, const char *delimit, char **context)
size_t SYSstrlcpy (char *dest, const char *src, size_t size)
size_t SYSstrlcat (char *dest, const char *src, size_t size)
bool SYSisspace (char c)
bool SYSisspace (unsigned char c)
bool SYSisspace (int c)


Function Documentation

bool SYSisspace ( int  c  )  [inline]

Definition at line 193 of file SYS_String.h.

bool SYSisspace ( unsigned char  c  )  [inline]

Definition at line 187 of file SYS_String.h.

bool SYSisspace ( char  c  )  [inline]

Definition at line 179 of file SYS_String.h.

size_t SYSstrlcat ( char *  dest,
const char *  src,
size_t  size 
) [inline]

The following implements the strlcpy() function from OpenBSD. The differences between strlcpy() and strncpy() are:

  • The buffer will not be filled with null
  • The size passed in is the full length of the buffer (not remaining length)
  • The dest will always be null terminated (unless it is already larger than the size passed in) The function returns strln(src) + SYSmin(size, strlen(dest)) If rcode >= size, truncation occurred

Definition at line 154 of file SYS_String.h.

size_t SYSstrlcpy ( char *  dest,
const char *  src,
size_t  size 
) [inline]

The semantics for strncpy() leave a little to be desired

  • If the buffer limit is hit, the string isn't guaranteed to be null terminated.
  • If the buffer limit isn't hit, the entire remainder of the string is filled with nulls (which can be costly with large buffers). The following implements the strlcpy() function from OpenBSD. The function is very similar to strncpy() but The return code is the length of the src string The resulting string is always null terminated (unless size == 0) The remaining buffer is not touched It's possible to check for errors by testing rcode >= size.

Definition at line 128 of file SYS_String.h.

char* SYSstrtok ( char *  string,
const char *  delimit,
char **  context 
) [inline]

A standard name for a strtok that doesn't maintain state between calls. This version is thus both reentrant and threadsafe. SYSstrtok parses a string into a sequence of tokens. On the first call to SYSstrtok, the string to be parsed must be specified as the parameter 'string'. This parameter *will be modified* (destroying your copy). 'delimit' specifies an array of single characters that will be used as delimiters. 'context' is a char * variable used internally by SYSstrtok to maintain context between calls. Subsequent calls must specify the same unchanged context variable as the first call. To use SYSstrtok, on the first call first pass in your string as the parameter 'string'; on subsequent calls, pass it in as NULL. SYSstrtok returns non-empty strings pointing to the first non-delimiter character of each token, or NULL if no further tokens are available. Example:

 char *string = strdup(getString());
 char *strptr = string;
 char *context;
 char *token = SYSstrtok(string, MY_DELIMITERS, &context);
 while (token)
 {
     do_some_stuff();
     SYSstrtok(NULL, MY_DELIMITERS, &context);
 }
 free(strptr);

Definition at line 70 of file SYS_String.h.


Generated on Thu May 24 00:09:05 2012 for HDK by  doxygen 1.5.9