util.c File Reference

#include "util.h"
#include "dns.h"

Include dependency graph for util.c:

Include dependency graph

Go to the source code of this file.

Functions

void _pprintf_dbg (u_int8_t level, const char *func, const char *file, const size_t line, const char *s)
void _printf_dbg (u_int8_t level, const char *func, const char *file, const size_t line, const char *format,...)
void _dummy_debug (const u_int8_t level, const char *func, const char *file, const size_t line, const char *format,...)
void _dummy_pdebug (const u_int8_t level, const char *func, const char *file, const size_t line, const char *s)
char * UTIL_get_date (void)
void UTIL_log_result (peer_info_t *p)
char * UTIL_strndup (const char *s, const size_t n)
char * UTIL_strdup (const char *s)
void * UTIL_malloc (const int32_t n, const char *file, int32_t line, const char *func)
void * UTIL_realloc (void *p, const int32_t n, const char *file, const int32_t line, const char *func)
void UTIL_free (void *p, const char *file, const int32_t line, const char *func)
int16_t UTIL_index (const char *s, const char c)
char * UTIL_split_str (const char *s, const char c, const u_int8_t num)
char * UTIL_split_strr (const char *s, const char c, const u_int8_t num)
u_int8_t UTIL_count_delim (const char *s, const char c)
SPF_BOOL UTIL_is_spf_delim (const char c)
SPF_BOOL UTIL_is_spf_result (const char c)
SPF_BOOL UTIL_is_macro (const char *s)
SPF_BOOL UTIL_mx_cmp (peer_info_t *p, const char *s, const int8_t cidr)
SPF_BOOL UTIL_a_cmp (peer_info_t *p, const char *s, const int8_t cidr)
SPF_BOOL UTIL_ptr_cmp (peer_info_t *p, const char *s)
SPF_MECHANISM UTIL_get_policy_mech (const char *s)
SPF_BOOL UTIL_assoc_prefix (peer_info_t *p, SPF_RESULT res, const char *s)
SPF_RESULT UTIL_get_mech_prefix (peer_info_t *p, const char *s)
policy_addr_tUTIL_expand_ip (const char *s)
SPF_BOOL UTIL_is_ip (const char *id)
char * UTIL_rev_addr (const char *s)
char * UTIL_get_dname (const char *s)
SPF_BOOL UTIL_cidr_cmp (const policy_addr_t *policy_addr, const struct in_addr *peer_addr)
SPF_BOOL UTIL_validate_ptr (peer_info_t *p)
SPF_BOOL UTIL_validate_hostname (peer_info_t *p, const char *s, const int8_t cidr)
char * UTIL_url_encode (const char *s)
char * UTIL_reverse (const char *s, const char delim)
SPF_BOOL UTIL_addnode (split_str_t *master, const char *s, SPF_BOOL last)
void _UTIL_pthread_mutex (void *mutex, SPF_BOOL action)

Variables

void * util_mutex
int errno


Function Documentation

void _dummy_debug const u_int8_t  level,
const char *  func,
const char *  file,
const size_t  line,
const char *  format,
  ...
 

Definition at line 237 of file util.c.

void _dummy_pdebug const u_int8_t  level,
const char *  func,
const char *  file,
const size_t  line,
const char *  s
 

Definition at line 255 of file util.c.

void _pprintf_dbg u_int8_t  level,
const char *  func,
const char *  file,
const size_t  line,
const char *  s
 

Definition at line 97 of file util.c.

References confg, f_bit_set, FL_D, FL_F, spf_config_s::level, SPF_MAX_DEBUG, xfree, and xmalloc.

void _printf_dbg u_int8_t  level,
const char *  func,
const char *  file,
const size_t  line,
const char *  format,
  ...
 

Definition at line 154 of file util.c.

References confg, DEBUG_LOG_FILE, f_bit_set, FL_E, spf_config_s::level, SPF_MAX_DEBUG, util_mutex, xmalloc, xpthread_mutex_lock, and xpthread_mutex_unlock.

void _UTIL_pthread_mutex void *  mutex,
SPF_BOOL  action
 

Definition at line 2512 of file util.c.

References SPF_BOOL, SPF_FALSE, and SPF_TRUE.

SPF_BOOL UTIL_a_cmp peer_info_t p,
const char *  s,
const int8_t  cidr
 

Definition at line 980 of file util.c.

References peer_info_s::addr, peer_info_s::current_domain, peer_info_t, policy_addr_t, SIZEOF, SPF_BOOL, SPF_FALSE, SPF_MAX_GHBNR_DBUF, SPF_MAX_HNAME, SPF_PASS, SPF_TRUE, UTIL_assoc_prefix(), UTIL_cidr_cmp(), UTIL_index(), xepprintf, xeprintf, xfree, xgethostbyname, xgethostbyname_free, xmalloc, xstrndup, and xvprintf.

Referenced by SPF_parse_policy().

Here is the call graph for this function:

SPF_BOOL UTIL_addnode split_str_t master,
const char *  s,
SPF_BOOL  last
 

Definition at line 2421 of file util.c.

References split_str_s::elements, split_str_s::head, split_str_node_s::len, split_str_node_s::next, split_str_node_s::s, SIZEOF, SPF_BOOL, SPF_FALSE, SPF_TRUE, split_str_node_t, split_str_t, split_str_s::tail, xepprintf, xmalloc, xpprintf, and xvprintf.

Referenced by UTIL_reverse().

SPF_BOOL UTIL_assoc_prefix peer_info_t p,
SPF_RESULT  res,
const char *  s
 

Definition at line 1309 of file util.c.

References peer_info_s::error, peer_info_s::last_m, peer_info_t, peer_info_s::RES, peer_info_s::rs, spf_result_t::s, SPF_BOOL, SPF_ERROR, SPF_FALSE, SPF_H_FAIL, SPF_MAX_ERROR, SPF_NEUTRAL, SPF_NONE, SPF_PASS, SPF_RESULT, peer_info_s::spf_result, SPF_S_FAIL, SPF_TRUE, SPF_UNKNOWN, SPF_UNMECH, UTIL_index(), xepprintf, and xvprintf.

Referenced by DNS_query(), SPF_init(), SPF_parse_policy(), SPF_policy_main(), SPF_policy_main_rec(), UTIL_a_cmp(), UTIL_mx_cmp(), and UTIL_validate_hostname().

Here is the call graph for this function:

SPF_BOOL UTIL_cidr_cmp const policy_addr_t policy_addr,
const struct in_addr *  peer_addr
 

Definition at line 1961 of file util.c.

References policy_addr_s::addr, policy_addr_s::cidr, policy_addr_t, SPF_BOOL, SPF_FALSE, SPF_MAX_IP_ADDR, SPF_TRUE, xepprintf, xfree, xstrndup, and xvprintf.

Referenced by SPF_parse_policy(), UTIL_a_cmp(), and UTIL_validate_hostname().

u_int8_t UTIL_count_delim const char *  s,
const char  c
 

Definition at line 751 of file util.c.

References SPF_MAX_DELIM, xepprintf, and xvprintf.

Referenced by MACRO_eatmore(), and UTIL_get_dname().

policy_addr_t* UTIL_expand_ip const char *  s  ) 
 

Definition at line 1694 of file util.c.

References policy_addr_s::addr, policy_addr_s::cidr, policy_addr_t, SIZEOF, UTIL_index(), xepprintf, xfree, xmalloc, xstrndup, and xvprintf.

Referenced by SPF_parse_policy().

Here is the call graph for this function:

void UTIL_free void *  p,
const char *  file,
const int32_t  line,
const char *  func
 

Definition at line 522 of file util.c.

References xvprintf.

char* UTIL_get_date void   ) 
 

Definition at line 282 of file util.c.

References SPF_MAX_DATETIME, util_mutex, xmalloc, xpthread_mutex_lock, and xpthread_mutex_unlock.

Referenced by UTIL_log_result().

char* UTIL_get_dname const char *  s  ) 
 

Definition at line 1906 of file util.c.

References UTIL_count_delim(), UTIL_split_str(), xepprintf, xprintf, xstrndup, and xvprintf.

Here is the call graph for this function:

SPF_RESULT UTIL_get_mech_prefix peer_info_t p,
const char *  s
 

Definition at line 1555 of file util.c.

References peer_info_s::ALL, peer_info_s::last_m, peer_info_t, peer_info_s::RES_P, SPF_ERROR, SPF_H_FAIL, SPF_MAX_HNAME, SPF_NEUTRAL, SPF_PASS, SPF_RESULT, SPF_S_FAIL, SPF_TRUE, UTIL_index(), xepprintf, xprintf, and xvprintf.

Referenced by SPF_parse_policy().

Here is the call graph for this function:

SPF_MECHANISM UTIL_get_policy_mech const char *  s  ) 
 

Definition at line 1198 of file util.c.

References A, ALL, DEFAULT, EXISTS, EXPLAIN, INCLUDE, IP4, IP6, MX, NO_POLICY, PTR, REDIRECT, SPF_MECHANISM, UNMECH, VERSION, xepprintf, xpprintf, and xvprintf.

Referenced by SPF_parse_policy().

int16_t UTIL_index const char *  s,
const char  c
 

Definition at line 564 of file util.c.

References xepprintf, xpprintf, and xvprintf.

Referenced by MACRO_expand(), SPF_parse_policy(), UTIL_a_cmp(), UTIL_assoc_prefix(), UTIL_expand_ip(), and UTIL_get_mech_prefix().

SPF_BOOL UTIL_is_ip const char *  id  ) 
 

Definition at line 1793 of file util.c.

References SPF_BOOL, SPF_FALSE, SPF_TRUE, xepprintf, xpprintf, and xvprintf.

SPF_BOOL UTIL_is_macro const char *  s  ) 
 

Definition at line 869 of file util.c.

References SPF_BOOL, SPF_FALSE, SPF_TRUE, xepprintf, xpprintf, and xvprintf.

Referenced by SPF_parse_policy().

SPF_BOOL UTIL_is_spf_delim const char  c  ) 
 

Definition at line 790 of file util.c.

References SPF_BOOL, SPF_FALSE, SPF_TRUE, xepprintf, xpprintf, and xvprintf.

Referenced by MACRO_eatmore().

SPF_BOOL UTIL_is_spf_result const char  c  ) 
 

Definition at line 832 of file util.c.

References SPF_BOOL, SPF_FALSE, SPF_TRUE, xpprintf, and xvprintf.

Referenced by SPF_parse_policy().

void UTIL_log_result peer_info_t p  ) 
 

Definition at line 326 of file util.c.

References peer_info_s::error, peer_info_s::from, OUTPUT_LOG_FILE, peer_info_t, peer_info_s::r_ip, peer_info_s::RES, SPF_MAX_DEBUG, peer_info_s::spf_result, peer_info_s::spf_rlevel, peer_info_s::spf_ver, SPF_VERSION, UTIL_get_date(), util_mutex, xfree, xmalloc, xpthread_mutex_lock, and xpthread_mutex_unlock.

Referenced by SPF_policy_main_rec().

Here is the call graph for this function:

void* UTIL_malloc const int32_t  n,
const char *  file,
int32_t  line,
const char *  func
 

Definition at line 447 of file util.c.

References xvprintf.

Referenced by UTIL_realloc().

SPF_BOOL UTIL_mx_cmp peer_info_t p,
const char *  s,
const int8_t  cidr
 

Definition at line 914 of file util.c.

References peer_info_s::addr, DNS_query(), peer_info_s::from, peer_info_t, SPF_BOOL, SPF_FALSE, SPF_PASS, SPF_TRUE, UTIL_assoc_prefix(), UTIL_validate_hostname(), xfree, xpprintf, xstrndup, and xvprintf.

Referenced by SPF_parse_policy().

Here is the call graph for this function:

SPF_BOOL UTIL_ptr_cmp peer_info_t p,
const char *  s
 

Definition at line 1135 of file util.c.

References peer_info_s::current_domain, DNS_query(), peer_info_s::error, peer_info_t, peer_info_s::r_ip, peer_info_s::rs, SPF_BOOL, SPF_FALSE, SPF_MAX_HNAME, SPF_TRUE, UTIL_rev_addr(), xepprintf, xfree, xstrndup, and xvprintf.

Referenced by SPF_parse_policy().

Here is the call graph for this function:

void* UTIL_realloc void *  p,
const int32_t  n,
const char *  file,
const int32_t  line,
const char *  func
 

Definition at line 486 of file util.c.

References UTIL_malloc(), and xvprintf.

Here is the call graph for this function:

char* UTIL_rev_addr const char *  s  ) 
 

Definition at line 1843 of file util.c.

References xepprintf, xfree, xmalloc, xprintf, xstrndup, and xvprintf.

Referenced by DNS_check_client_reverse(), UTIL_ptr_cmp(), and UTIL_validate_ptr().

char* UTIL_reverse const char *  s,
const char  delim
 

Definition at line 2331 of file util.c.

References split_str_s::elements, split_str_s::head, split_str_node_s::len, split_str_node_s::next, split_str_node_s::s, SIZEOF, SPF_FALSE, SPF_TRUE, split_str_node_t, split_str_t, split_str_s::tail, UTIL_addnode(), xepprintf, xfree, xmalloc, xstrndup, and xvprintf.

Referenced by MACRO_eatmore().

Here is the call graph for this function:

char* UTIL_split_str const char *  s,
const char  c,
const u_int8_t  num
 

Definition at line 615 of file util.c.

References SPF_MAX_STR, xepprintf, xfree, xstrndup, and xvprintf.

Referenced by UTIL_get_dname().

char* UTIL_split_strr const char *  s,
const char  c,
const u_int8_t  num
 

Definition at line 684 of file util.c.

References xepprintf, xstrdup, and xvprintf.

Referenced by MACRO_eatmore().

char* UTIL_strdup const char *  s  ) 
 

Definition at line 412 of file util.c.

References SPF_FALSE, xepprintf, and xvprintf.

char* UTIL_strndup const char *  s,
const size_t  n
 

Definition at line 378 of file util.c.

References SPF_FALSE, xepprintf, xmalloc, and xvprintf.

char* UTIL_url_encode const char *  s  ) 
 

Definition at line 2272 of file util.c.

References urlchr_test, xepprintf, xmalloc, and xvprintf.

SPF_BOOL UTIL_validate_hostname peer_info_t p,
const char *  s,
const int8_t  cidr
 

Definition at line 2100 of file util.c.

References peer_info_s::addr, peer_info_t, policy_addr_t, peer_info_s::r_ip, SIZEOF, SPF_BOOL, SPF_FALSE, SPF_MAX_GHBNR_DBUF, SPF_MAX_IP_ADDR, SPF_PASS, SPF_TRUE, UTIL_assoc_prefix(), UTIL_cidr_cmp(), xepprintf, xfree, xgethostbyname, xgethostbyname_free, xmalloc, xpprintf, xstrndup, and xvprintf.

Referenced by DNS_check_client_reverse(), DNS_ptr_answer(), and UTIL_mx_cmp().

Here is the call graph for this function:

SPF_BOOL UTIL_validate_ptr peer_info_t p  ) 
 

Definition at line 2038 of file util.c.

References peer_info_s::current_domain, DNS_query(), peer_info_s::error, peer_info_t, peer_info_s::r_ip, peer_info_s::r_vhname, peer_info_s::rs, SPF_BOOL, SPF_FALSE, SPF_MAX_HNAME, SPF_TRUE, UTIL_rev_addr(), xepprintf, xfree, xstrndup, and xvprintf.

Here is the call graph for this function:


Variable Documentation

int errno
 

void* util_mutex
 

Definition at line 66 of file util.c.

Referenced by _printf_dbg(), UTIL_get_date(), and UTIL_log_result().


Generated on Thu Sep 16 18:10:51 2004 for libSPF v1.0 by doxygen 1.3.8