-/*
- * ircd_string.h
- *
- * $Id$
+/** @file ircd_string.h
+ * @brief Public declarations and APIs for string operations.
+ * @version $Id$
*/
#ifndef INCLUDED_ircd_string_h
#define INCLUDED_ircd_string_h
/*
* Macros
*/
+/** Check whether \a x is a NULL or empty string. */
#define EmptyString(x) (!(x) || !(*x))
/*
extern int string_is_address(const char* str);
extern int string_has_wildcards(const char* str);
-/*! Return hash for string using PJW algorithm */
-extern unsigned hash_pjw(const char* str);
extern char* ircd_strncpy(char* dest, const char* src, size_t len);
extern int ircd_strcmp(const char *a, const char *b);
extern int ircd_strncmp(const char *a, const char *b, size_t n);
extern char* canonize(char* buf);
+/** Make \a y a duplicate \a x, a la strdup(). */
#define DupString(x, y) (strcpy((x = (char*) MyMalloc(strlen(y) + 1)), y))
/* String classification pseudo-functions, when others are needed add them,
strIsXxxxx(s) is true when IsXxxxx(c) is true for every char in s */
+/** Test whether all characters in \a s are alphanumeric. */
#define strIsAlnum(s) (strChattr(s) & NTL_ALNUM)
+/** Test whether all characters in \a s are alphabetic. */
#define strIsAlpha(s) (strChattr(s) & NTL_ALPHA)
+/** Test whether all characters in \a s are digits. */
#define strIsDigit(s) (strChattr(s) & NTL_DIGIT)
+/** Test whether all characters in \a s are lower case. */
#define strIsLower(s) (strChattr(s) & NTL_LOWER)
+/** Test whether all characters in \a s are whitespace. */
#define strIsSpace(s) (strChattr(s) & NTL_SPACE)
+/** Test whether all characters in \a s are upper case. */
#define strIsUpper(s) (strChattr(s) & NTL_UPPER)
+/** Test whether all characters in \a s are channel name characters. */
#define strIsIrcCh(s) (strChattr(s) & NTL_IRCCH)
+/** Test whether all characters in \a s are forced to lower-case in channel names. */
#define strIsIrcCl(s) (strChattr(s) & NTL_IRCCL)
+/** Test whether all characters in \a s are valid in nicknames. */
#define strIsIrcNk(s) (strChattr(s) & NTL_IRCNK)
+/** Test whether all characters in \a s are valid in a user field. */
#define strIsIrcUi(s) (strChattr(s) & NTL_IRCUI)
+/** Test whether all characters in \a s are valid in host names. */
#define strIsIrcHn(s) (strChattr(s) & NTL_IRCHN)
+/** Test whether all characters in \a s are valid in IP addresses. */
#define strIsIrcIp(s) (strChattr(s) & NTL_IRCIP)
/*
* `inline').
*/
+/** Declaration for strChattr(). */
#define NTL_HDR_strChattr unsigned int strChattr(const char *s)
+/** Body for strChattr(). */
#define NTL_SRC_strChattr const char *rs = s; \
unsigned int x = ~0; \
while(*rs) \
/*
* XXX - bleah should return 1 if different 0 if the same
*/
+/** Declaration for strCasediff(). */
#define NTL_HDR_strCasediff int strCasediff(const char *a, const char *b)
+/** Body for strCasediff(). */
#define NTL_SRC_strCasediff const char *ra = a; \
const char *rb = b; \
while(ToLower(*ra) == ToLower(*rb++)) \