added basic ssl support to ircu
[ircu2.10.12-pk.git] / include / ircd_string.h
index b98c7e50473c38a009e762bf95eabab74c76c77e..df774c5e52b52f6a47b03c4af17c8896a2b61c27 100644 (file)
@@ -1,10 +1,12 @@
-/*
- * 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
+
+#include <string.h> /* for DupString()'s strcpy, strlen */
+
 #ifndef INCLUDED_ircd_chattr_h
 #include "ircd_chattr.h"
 #endif
@@ -14,19 +16,11 @@ struct irc_in_addr;
 /*
  * Macros
  */
+/** Check whether \a x is a NULL or empty string. */
 #define EmptyString(x) (!(x) || !(*x))
 
-/*
- * initialize recognizers
- */
-extern int init_string(void);
-
-extern int string_is_hostname(const char* str);
-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);
@@ -36,30 +30,44 @@ extern int         token_vector(char* names, char token,
                                 char** vector, int size);
 extern const char* ircd_ntoa(const struct irc_in_addr* addr);
 extern const char* ircd_ntoa_r(char* buf, const struct irc_in_addr* addr);
-extern int         ircd_aton(struct irc_in_addr *addr, const char *str);
+#define ircd_aton(ADDR, STR) ipmask_parse((STR), (ADDR), NULL)
+extern int ipmask_parse(const char *in, struct irc_in_addr *mask, unsigned char *bits_ptr);
 extern char*       host_from_uh(char* buf, const char* userhost, size_t len);
 extern char*       ircd_strtok(char** save, char* str, char* fs);
 
 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)
 
 /*
@@ -68,8 +76,10 @@ extern char*       canonize(char* buf);
  * `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) \
@@ -79,8 +89,10 @@ extern char*       canonize(char* buf);
 /*
  * 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++)) \
@@ -102,10 +114,5 @@ static __inline__ NTL_HDR_strCasediff { NTL_SRC_strCasediff }
 #endif
 #endif /* FORCEINLINE */
 
-/*
- * Proto types of other externally visible functions
- */
-extern int strnChattr(const char *s, const size_t n);
-
 #endif /* INCLUDED_ircd_string_h */