util.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
#ifndef _UTIL_H
00046 #define _UTIL_H 1
00047
00048
#include <stdio.h>
00049
#include <stdlib.h>
00050
#include <stdarg.h>
00051
#include <string.h>
00052
#include <strings.h>
00053
#include <unistd.h>
00054
#include <sys/socket.h>
00055
#include <netinet/in.h>
00056
#include <time.h>
00057
#include <ctype.h>
00058
#include "main.h"
00059
00060 __BEGIN_DECLS
00061
00062
00063
00064
00065
00066
00067
00068
00069 #define SIZEOF(object) ((size_t) sizeof(object))
00070
00071
00072 #define xmalloc(n) UTIL_malloc(n, __FILE__, __LINE__, __FUNCTION__)
00073 #define xrealloc(m, n) UTIL_realloc(m, n, __FILE__, __LINE__, __FUNCTION__)
00074 #define xfree(m) UTIL_free(m, __FILE__, __LINE__, __FUNCTION__)
00075 #define xstrdup(m) UTIL_strdup(m)
00076 #define xstrndup(m, n) UTIL_strndup(m, n)
00077
00078
00079 #define xprintf(format,...) dbg_printf(FL_A, __FUNCTION__, format, __VA_ARGS__)
00080 #define xvprintf(format,...) dbg_printf(FL_B, __FUNCTION__, format, __VA_ARGS__)
00081 #define xpprintf(format,...) dbg_printf(FL_D, __FUNCTION__, format, __VA_ARGS__)
00082 #define xeprintf(s) (fprintf(stderr, s))
00083
00084
00085 #define f_bit_set(fl_bit_vector, bit) ((int)((fl_bit_vector)&(bit)))
00086
00087
00088 #define urlchr_test(c) (urlchr_table[(unsigned char)(c)] & 1)
00089 const static u_char
urlchr_table[256] =
00090 {
00091 1, 1, 1, 1, 1, 1, 1, 1,
00092 1, 1, 1, 1, 1, 1, 1, 1,
00093 1, 1, 1, 1, 1, 1, 1, 1,
00094 1, 1, 1, 1, 1, 1, 1, 1,
00095 1, 0, 1, 1, 0, 1, 1, 0,
00096 0, 0, 0, 1, 0, 0, 0, 1,
00097 0, 0, 0, 0, 0, 0, 0, 0,
00098 0, 0, 1, 1, 1, 1, 1, 1,
00099 1, 0, 0, 0, 0, 0, 0, 0,
00100 0, 0, 0, 0, 0, 0, 0, 0,
00101 0, 0, 0, 0, 0, 0, 0, 0,
00102 0, 0, 0, 1, 1, 1, 1, 0,
00103 1, 0, 0, 0, 0, 0, 0, 0,
00104 0, 0, 0, 0, 0, 0, 0, 0,
00105 0, 0, 0, 0, 0, 0, 0, 0,
00106 0, 0, 0, 1, 1, 1, 1, 1,
00107
00108 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00109 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00110 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00111 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00112
00113 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00114 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00115 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00116 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00117 };
00118
00119
00120 #define DEBUG_LOG_FILE "/var/log/spf.log"
00121
00122
00123 #define OUTPUT_LOG_FILE "/var/log/spflog.txt"
00124
00125
#if defined _SPF_DEBUG
00126
#define dbg_printf _printf_dbg
00127
#endif
00128
00129
#ifndef _SPF_DEBUG
00130 #define dbg_printf dummy_debug
00131
#endif
00132
00133
void _printf_dbg(
const u_int8_t level,
const char *function,
00134
const char *format,...);
00135
void dummy_debug(
const u_int8_t level,
const char *function,
00136
const char *format,...);
00137
void *
UTIL_malloc(
const int32_t,
const char *,
const int32_t,
00138
const char *);
00139
void *
UTIL_realloc(
void *,
const int32_t,
const char *,
const int32_t,
00140
const char *);
00141
void UTIL_free(
void *,
const char *,
const int32_t,
const char *);
00142
00143
00144
char *
UTIL_printf(
char *format, ...);
00145
void UTIL_log_result(
peer_info_t *peer_info);
00146
char *
UTIL_get_date(
void);
00147
char *
UTIL_strndup(
const char *s,
const size_t n);
00148
char *
UTIL_strdup(
const char *s);
00149 int16_t
UTIL_index(
const char *s,
const char c);
00150
char *
UTIL_split_str(
const char *s,
const char c,
const u_int8_t num);
00151
char *
UTIL_split_strr(
const char *s,
const char c,
const u_int8_t num);
00152 u_int8_t
UTIL_count_delim(
const char *s,
const char c);
00153 size_t
UTIL_guess_whats_in_the_box(
char *s,
const char c,
const u_int16_t num);
00154
SPF_BOOL UTIL_is_spf_delim(
const char c);
00155
SPF_BOOL UTIL_is_spf_result(
const char c);
00156
SPF_BOOL UTIL_is_macro(
const char *s);
00157
00158
00159
SPF_BOOL UTIL_mx_cmp(
peer_info_t *peer_info,
const char *s,
const int8_t cidr);
00160
SPF_BOOL UTIL_a_cmp(
peer_info_t *peer_info,
const char *s,
const int8_t cidr);
00161
SPF_BOOL UTIL_ptr_cmp(
peer_info_t *peer_info,
const char *s);
00162
00163
00164
SPF_MECHANISM UTIL_get_policy_mech(
const char *s);
00165
SPF_RESULT UTIL_get_mech_prefix(
peer_info_t *peer_info,
const char *s);
00166
SPF_BOOL UTIL_assoc_prefix(
peer_info_t *peer_info, SPF_RESULT p,
const char *s);
00167
policy_addr_t *
UTIL_expand_ip(
const char *s);
00168
SPF_BOOL UTIL_is_spf_delim(
const char c);
00169
char *
UTIL_rev_addr(
const char *s);
00170
char *
UTIL_get_dname(
const char *s);
00171
SPF_BOOL UTIL_cidr_cmp(
peer_info_t *peer_info,
const policy_addr_t *policy_addr,
00172
const struct in_addr *peer_addr);
00173
SPF_BOOL UTIL_validate_ptr(
peer_info_t *peer_info);
00174
SPF_BOOL UTIL_validate_hostname(
peer_info_t *peer_info,
const char *s,
00175
const int8_t cidr);
00176
char *
UTIL_url_encode(
const char *s);
00177
char *
UTIL_reverse(
const char *s,
const char delim);
00178
SPF_BOOL UTIL_addnode(
split_str_t *master,
const char *s, SPF_BOOL last);
00179
00180 __END_DECLS
00181
00182
#endif
00183
00184
Generated on Thu Jul 1 14:05:44 2004 for libspf v1.0 by
1.3.7