common/string.h (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
/*! \file
* Defines several functions to manipulate C strings and arrays.
*/
#ifndef STRING_H
#define STRING_H
#include <stdint.h>
#include <stddef.h>
#define WHITESPACE(c) ((c) == ' ' || (c) == '\t')
#define IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
#define IS_LOWER(c) ((c) >= 'a' && (c) <= 'z')
#define TO_UPPER(c) (IS_LOWER(c) ? (c) - 'a' + 'A' : c)
#define TO_LOWER(c) (IS_UPPER(c) ? (c) - 'A' + 'a' : c)
/*!
* Unsigned integral type.
*/
typedef uint32_t size_t;
typedef int64_t ssize_t;
/*!
* Copies a block of memory.
* \param destination Pointer to the destination array where the content is to be copied.
* \param source Pointer to the source of the data to be copied.
* \param num Number of bytes to be copied.
* \return \p destination is returned.
*/
void *memcpy (void *destination, const void *source, size_t num);
/*!
* Sets the \p num first bytes of the block of memory pointed to by \p ptr
* to the specified \p value
* \param ptr Pointer to the block of memory to be filled.
* \param value Value to be set (Passed as int, but converted to unsigned char)
* \param num Number of bytes to set to \p value.
* \return \p ptr is returned.
*/
void *memset (void *ptr, int value, size_t num);
unsigned int strlen(const char *);
char *strcpy(char *, const char *);
int strcmp(const char *, const char *);
int sstrcmp(const char *, const char *);
const char *strchr (const char *, int);
size_t strlstrip(char *, const char *, size_t);
size_t strrstrip(char *, const char *, size_t);
#endif