📄 name.h
字号:
* * Notes: *\li If 'omit_final_dot' is true, then the final '.' in absolute * names other than the root name will be omitted. * *\li The name is not NUL terminated. * * Requires: * *\li 'name' is a valid absolute name * *\li 'target' is a valid buffer. * * Ensures: * *\li If the result is success: * the used space in target is updated. * * Returns: *\li #ISC_R_SUCCESS *\li #ISC_R_NOSPACE */isc_result_tdns_name_downcase(dns_name_t *source, dns_name_t *name, isc_buffer_t *target);/*%< * Downcase 'source'. * * Requires: * *\li 'source' and 'name' are valid names. * *\li If source == name, then * 'source' must not be read-only * *\li Otherwise, * 'target' is a valid buffer or 'target' is NULL and * 'name' has a dedicated buffer. * * Returns: *\li #ISC_R_SUCCESS *\li #ISC_R_NOSPACE * * Note: if source == name, then the result will always be ISC_R_SUCCESS. */isc_result_tdns_name_concatenate(dns_name_t *prefix, dns_name_t *suffix, dns_name_t *name, isc_buffer_t *target);/*%< * Concatenate 'prefix' and 'suffix'. * * Requires: * *\li 'prefix' is a valid name or NULL. * *\li 'suffix' is a valid name or NULL. * *\li 'name' is a valid name or NULL. * *\li 'target' is a valid buffer or 'target' is NULL and 'name' has * a dedicated buffer. * *\li If 'prefix' is absolute, 'suffix' must be NULL or the empty name. * * Ensures: * *\li On success, * If 'target' is not NULL and 'name' is not NULL, then 'name' * is attached to it. * The used space in target is updated. * * Returns: *\li #ISC_R_SUCCESS *\li #ISC_R_NOSPACE *\li #DNS_R_NAMETOOLONG */voiddns_name_split(dns_name_t *name, unsigned int suffixlabels, dns_name_t *prefix, dns_name_t *suffix);/*%< * * Split 'name' into two pieces on a label boundary. * * Notes: * \li 'name' is split such that 'suffix' holds the most significant * 'suffixlabels' labels. All other labels are stored in 'prefix'. * *\li Copying name data is avoided as much as possible, so 'prefix' * and 'suffix' will end up pointing at the data for 'name'. * *\li It is legitimate to pass a 'prefix' or 'suffix' that has * its name data stored someplace other than the dedicated buffer. * This is useful to avoid name copying in the calling function. * *\li It is also legitimate to pass a 'prefix' or 'suffix' that is * the same dns_name_t as 'name'. * * Requires: *\li 'name' is a valid name. * *\li 'suffixlabels' cannot exceed the number of labels in 'name'. * * \li 'prefix' is a valid name or NULL, and cannot be read-only. * *\li 'suffix' is a valid name or NULL, and cannot be read-only. * *\li If non-NULL, 'prefix' and 'suffix' must have dedicated buffers. * *\li 'prefix' and 'suffix' cannot point to the same buffer. * * Ensures: * *\li On success: * If 'prefix' is not NULL it will contain the least significant * labels. * If 'suffix' is not NULL it will contain the most significant * labels. dns_name_countlabels(suffix) will be equal to * suffixlabels. * *\li On failure: * Either 'prefix' or 'suffix' is invalidated (depending * on which one the problem was encountered with). * * Returns: *\li #ISC_R_SUCCESS No worries. (This function should always success). */isc_result_tdns_name_dup(const dns_name_t *source, isc_mem_t *mctx, dns_name_t *target);/*%< * Make 'target' a dynamically allocated copy of 'source'. * * Requires: * *\li 'source' is a valid non-empty name. * *\li 'target' is a valid name that is not read-only. * *\li 'mctx' is a valid memory context. */isc_result_tdns_name_dupwithoffsets(dns_name_t *source, isc_mem_t *mctx, dns_name_t *target);/*%< * Make 'target' a read-only dynamically allocated copy of 'source'. * 'target' will also have a dynamically allocated offsets table. * * Requires: * *\li 'source' is a valid non-empty name. * *\li 'target' is a valid name that is not read-only. * *\li 'target' has no offsets table. * *\li 'mctx' is a valid memory context. */voiddns_name_free(dns_name_t *name, isc_mem_t *mctx);/*%< * Free 'name'. * * Requires: * *\li 'name' is a valid name created previously in 'mctx' by dns_name_dup(). * *\li 'mctx' is a valid memory context. * * Ensures: * *\li All dynamic resources used by 'name' are freed and the name is * invalidated. */isc_result_tdns_name_digest(dns_name_t *name, dns_digestfunc_t digest, void *arg);/*%< * Send 'name' in DNSSEC canonical form to 'digest'. * * Requires: * *\li 'name' is a valid name. * *\li 'digest' is a valid dns_digestfunc_t. * * Ensures: * *\li If successful, the DNSSEC canonical form of 'name' will have been * sent to 'digest'. * *\li If digest() returns something other than ISC_R_SUCCESS, that result * will be returned as the result of dns_name_digest(). * * Returns: * *\li #ISC_R_SUCCESS * *\li Many other results are possible if not successful. * */isc_boolean_tdns_name_dynamic(dns_name_t *name);/*%< * Returns whether there is dynamic memory associated with this name. * * Requires: * *\li 'name' is a valid name. * * Returns: * *\li 'ISC_TRUE' if the name is dynamic othewise 'ISC_FALSE'. */isc_result_tdns_name_print(dns_name_t *name, FILE *stream);/*%< * Print 'name' on 'stream'. * * Requires: * *\li 'name' is a valid name. * *\li 'stream' is a valid stream. * * Returns: * *\li #ISC_R_SUCCESS * *\li Any error that dns_name_totext() can return. */voiddns_name_format(dns_name_t *name, char *cp, unsigned int size);/*%< * Format 'name' as text appropriate for use in log messages. * * Store the formatted name at 'cp', writing no more than * 'size' bytes. The resulting string is guaranteed to be * null terminated. * * The formatted name will have a terminating dot only if it is * the root. * * This function cannot fail, instead any errors are indicated * in the returned text. * * Requires: * *\li 'name' is a valid name. * *\li 'cp' points a valid character array of size 'size'. * *\li 'size' > 0. * */isc_result_tdns_name_settotextfilter(dns_name_totextfilter_t proc);/*%< * Set / clear a thread specific function 'proc' to be called at the * end of dns_name_totext(). * * Note: Under Windows you need to call "dns_name_settotextfilter(NULL);" * prior to exiting the thread otherwise memory will be leaked. * For other platforms, which are pthreads based, this is still a good * idea but not required. * * Returns *\li #ISC_R_SUCCESS *\li #ISC_R_UNEXPECTED */#define DNS_NAME_FORMATSIZE (DNS_NAME_MAXTEXT + 1)/*%< * Suggested size of buffer passed to dns_name_format(). * Includes space for the terminating NULL. */isc_result_tdns_name_copy(dns_name_t *source, dns_name_t *dest, isc_buffer_t *target);/*%< * Makes 'dest' refer to a copy of the name in 'source'. The data are * either copied to 'target' or the dedicated buffer in 'dest'. * * Requires: * \li 'source' is a valid name. * * \li 'dest' is an initialized name with a dedicated buffer. * * \li 'target' is NULL or an initialized buffer. * * \li Either dest has a dedicated buffer or target != NULL. * * Ensures: * *\li On success, the used space in target is updated. * * Returns: *\li #ISC_R_SUCCESS *\li #ISC_R_NOSPACE */isc_boolean_tdns_name_ishostname(const dns_name_t *name, isc_boolean_t wildcard);/*%< * Return if 'name' is a valid hostname. RFC 952 / RFC 1123. * If 'wildcard' is ISC_TRUE then allow the first label of name to * be a wildcard. * The root is also accepted. * * Requires: * 'name' to be valid. */ isc_boolean_tdns_name_ismailbox(const dns_name_t *name);/*%< * Return if 'name' is a valid mailbox. RFC 821. * * Requires: * \li 'name' to be valid. */isc_boolean_tdns_name_internalwildcard(const dns_name_t *name);/*%< * Return if 'name' contains a internal wildcard name. * * Requires: * \li 'name' to be valid. */voiddns_name_destroy(void);/*%< * Cleanup dns_name_settotextfilter() / dns_name_totext() state. * * This should be called as part of the final cleanup process. * * Note: dns_name_settotextfilter(NULL); should be called for all * threads which have called dns_name_settotextfilter() with a * non-NULL argument prior to calling dns_name_destroy(); */ISC_LANG_ENDDECLS/* *** High Peformance Macros ***//* * WARNING: Use of these macros by applications may require recompilation * of the application in some situations where calling the function * would not. * * WARNING: No assertion checking is done for these macros. */#define DNS_NAME_INIT(n, o) \do { \ (n)->magic = DNS_NAME_MAGIC; \ (n)->ndata = NULL; \ (n)->length = 0; \ (n)->labels = 0; \ (n)->attributes = 0; \ (n)->offsets = (o); \ (n)->buffer = NULL; \ ISC_LINK_INIT((n), link); \ ISC_LIST_INIT((n)->list); \} while (0)#define DNS_NAME_RESET(n) \do { \ (n)->ndata = NULL; \ (n)->length = 0; \ (n)->labels = 0; \ (n)->attributes &= ~DNS_NAMEATTR_ABSOLUTE; \ if ((n)->buffer != NULL) \ isc_buffer_clear((n)->buffer); \} while (0)#define DNS_NAME_SETBUFFER(n, b) \ (n)->buffer = (b)#define DNS_NAME_ISABSOLUTE(n) \ (((n)->attributes & DNS_NAMEATTR_ABSOLUTE) != 0 ? ISC_TRUE : ISC_FALSE)#define DNS_NAME_COUNTLABELS(n) \ ((n)->labels)#define DNS_NAME_TOREGION(n, r) \do { \ (r)->base = (n)->ndata; \ (r)->length = (n)->length; \} while (0)#define DNS_NAME_SPLIT(n, l, p, s) \do { \ dns_name_t *_n = (n); \ dns_name_t *_p = (p); \ dns_name_t *_s = (s); \ unsigned int _l = (l); \ if (_p != NULL) \ dns_name_getlabelsequence(_n, 0, _n->labels - _l, _p); \ if (_s != NULL) \ dns_name_getlabelsequence(_n, _n->labels - _l, _l, _s); \} while (0)#ifdef DNS_NAME_USEINLINE#define dns_name_init(n, o) DNS_NAME_INIT(n, o)#define dns_name_reset(n) DNS_NAME_RESET(n)#define dns_name_setbuffer(n, b) DNS_NAME_SETBUFFER(n, b)#define dns_name_countlabels(n) DNS_NAME_COUNTLABELS(n)#define dns_name_isabsolute(n) DNS_NAME_ISABSOLUTE(n)#define dns_name_toregion(n, r) DNS_NAME_TOREGION(n, r)#define dns_name_split(n, l, p, s) DNS_NAME_SPLIT(n, l, p, s)#endif /* DNS_NAME_USEINLINE */#endif /* DNS_NAME_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -