X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=include%2Fircd_string.h;h=df774c5e52b52f6a47b03c4af17c8896a2b61c27;hb=refs%2Fheads%2Fupstream;hp=778a0287b96766fc881618acd6f25dec80cce117;hpb=8927a39c968bc739ebb61ff972a7fe0c375930a1;p=ircu2.10.12-pk.git diff --git a/include/ircd_string.h b/include/ircd_string.h index 778a028..df774c5 100644 --- a/include/ircd_string.h +++ b/include/ircd_string.h @@ -1,63 +1,73 @@ -/* - * 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 -#ifndef INCLUDED_config_h -#include "config.h" -#endif + +#include /* for DupString()'s strcpy, strlen */ + #ifndef INCLUDED_ircd_chattr_h #include "ircd_chattr.h" #endif +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); 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 int unique_name_vector(char* names, char token, char** vector, int size); -extern int token_vector(char* names, char token, char** vector, int size); -extern const char* ircd_ntoa(const char* addr); -extern const char* ircd_ntoa_r(char* buf, const char* addr); +extern int unique_name_vector(char* names, char token, + char** vector, int size); +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); +#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* sprintf_irc(char* str, const char* format, ...); - 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) /* @@ -66,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) \ @@ -77,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++)) \ @@ -100,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 */