spf_response.h

Go to the documentation of this file.
00001 /* 
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of either:
00004  * 
00005  *   a) The GNU Lesser General Public License as published by the Free
00006  *      Software Foundation; either version 2.1, or (at your option) any
00007  *      later version,
00008  * 
00009  *   OR
00010  * 
00011  *   b) The two-clause BSD license.
00012  *
00013  * These licenses can be found with the distribution in the file LICENSES
00014  */
00015 
00016 #ifndef INC_SPF_RESPONSE
00017 #define INC_SPF_RESPONSE
00018 
00078 typedef
00079 enum SPF_result_enum {
00080         SPF_RESULT_INVALID = 0,         
00081         SPF_RESULT_NEUTRAL,
00082         SPF_RESULT_PASS,
00083         SPF_RESULT_FAIL,
00084         SPF_RESULT_SOFTFAIL,
00085 
00086         SPF_RESULT_NONE,
00087         SPF_RESULT_TEMPERROR,
00088         SPF_RESULT_PERMERROR
00089 } SPF_result_t;
00090 
00099 typedef
00100 enum SPF_reason_enum {
00101         SPF_REASON_NONE                 = 0
00102 ,       SPF_REASON_FAILURE
00103 ,       SPF_REASON_LOCALHOST    
00104 ,       SPF_REASON_LOCAL_POLICY 
00105 ,       SPF_REASON_MECH                 
00106 ,       SPF_REASON_DEFAULT              
00107 ,       SPF_REASON_2MX                  
00108 } SPF_reason_t;
00109 
00118 typedef
00119 enum SPF_errcode_t {
00120         SPF_E_SUCCESS    = 0    
00121 ,       SPF_E_NO_MEMORY                 
00122 ,       SPF_E_NOT_SPF                   
00123 ,       SPF_E_SYNTAX                    
00124 ,       SPF_E_MOD_W_PREF                
00125 ,       SPF_E_INVALID_CHAR              
00126 ,       SPF_E_UNKNOWN_MECH              
00127 ,       SPF_E_INVALID_OPT               
00128 ,       SPF_E_INVALID_CIDR              
00129 ,       SPF_E_MISSING_OPT               
00130 ,       SPF_E_INTERNAL_ERROR    
00131 ,       SPF_E_INVALID_ESC               
00132 ,       SPF_E_INVALID_VAR               
00133 ,       SPF_E_BIG_SUBDOM                
00134 ,       SPF_E_INVALID_DELIM             
00135 ,       SPF_E_BIG_STRING                
00136 ,       SPF_E_BIG_MECH                  
00137 ,       SPF_E_BIG_MOD                   
00138 ,       SPF_E_BIG_DNS                   
00139 ,       SPF_E_INVALID_IP4               
00140 ,       SPF_E_INVALID_IP6               
00141 ,       SPF_E_INVALID_PREFIX    
00142 ,       SPF_E_RESULT_UNKNOWN    
00143 ,       SPF_E_UNINIT_VAR                
00144 ,       SPF_E_MOD_NOT_FOUND             
00145 ,       SPF_E_NOT_CONFIG                
00146 ,       SPF_E_DNS_ERROR                 
00147 ,       SPF_E_BAD_HOST_IP               
00148 ,       SPF_E_BAD_HOST_TLD              
00149 ,       SPF_E_MECH_AFTER_ALL    
00151 ,       SPF_E_INCLUDE_RETURNED_NONE     
00152 ,       SPF_E_RECURSIVE                 
00153 ,       SPF_E_MULTIPLE_RECORDS  
00154 } SPF_errcode_t;
00155 
00156 typedef
00157 struct SPF_error_struct
00158 {
00159         SPF_errcode_t    code;
00160         char                    *message;
00161         char                     is_error;
00162 } SPF_error_t;
00163 
00164 typedef struct SPF_response_struct SPF_response_t;
00165 
00166 #include "spf.h"
00167 #include "spf_request.h"
00168 
00169 struct SPF_response_struct {
00170         /* Structure variables */
00171         SPF_request_t   *spf_request;
00172         SPF_record_t    *spf_record_exp;
00173 
00174         /* The answer itself. */
00175         SPF_result_t     result;
00176         SPF_reason_t     reason;
00177         SPF_errcode_t    err;
00178 
00179         char                    *received_spf;
00180         char                    *received_spf_value;
00181         char                    *header_comment;
00182         char                    *smtp_comment;
00183         char                    *explanation;
00184 
00185         /* The errors */
00186         SPF_error_t             *errors;
00187         unsigned short   errors_size;           
00188         unsigned short   errors_length;         
00189         unsigned short   num_errors;            
00191         /* Stuff which lets us get there. */
00192         int                              num_dns_mech;
00193 };
00194 
00195 
00196 SPF_response_t  *SPF_response_new(SPF_request_t *spf_request);
00197 void                     SPF_response_free(SPF_response_t *rp);
00198 SPF_response_t  *SPF_response_combine(SPF_response_t *main,
00199                                         SPF_response_t *r2mx);
00200 
00201         /* Query functions for elements of the result */
00202 SPF_result_t     SPF_response_result(SPF_response_t *rp);
00203 SPF_reason_t     SPF_response_reason(SPF_response_t *rp);
00204 SPF_errcode_t    SPF_response_errcode(SPF_response_t *rp);
00205 const char              *SPF_response_get_received_spf(SPF_response_t *rp);
00206 const char              *SPF_response_get_received_spf_value(SPF_response_t*rp);
00207 const char              *SPF_response_get_header_comment(SPF_response_t *rp);
00208 const char              *SPF_response_get_smtp_comment(SPF_response_t *rp);
00209 const char              *SPF_response_get_explanation(SPF_response_t *rp);
00210 
00212 int                              SPF_response_messages(SPF_response_t *rp);
00214 int                              SPF_response_errors(SPF_response_t *rp);
00216 int                              SPF_response_warnings(SPF_response_t *rp);
00218 SPF_error_t             *SPF_response_message(SPF_response_t *rp, int idx);
00219 
00220 SPF_errcode_t    SPF_error_code(SPF_error_t *err);
00221 const char *     SPF_error_message(SPF_error_t *err);
00222 char                     SPF_error_errorp(SPF_error_t *err);
00223 
00226 SPF_errcode_t    SPF_response_add_error_ptr(SPF_response_t *rp,
00227                                         SPF_errcode_t code,
00228                                         const char *text, const char *tptr,
00229                                         const char *format, ...);
00230 SPF_errcode_t    SPF_response_add_error_idx(SPF_response_t *rp,
00231                                         SPF_errcode_t code,
00232                                         const char *text, int idx,
00233                                         const char *format, ...);
00234 SPF_errcode_t    SPF_response_add_error(SPF_response_t *rp,
00235                                         SPF_errcode_t code,
00236                                         const char *format, ...);
00237 SPF_errcode_t    SPF_response_add_warn_ptr(SPF_response_t *rp,
00238                                         SPF_errcode_t code,
00239                                         const char *text, const char *tptr,
00240                                         const char *format, ...);
00241 SPF_errcode_t    SPF_response_add_warn_idx(SPF_response_t *rp,
00242                                         SPF_errcode_t code,
00243                                         const char *text, int idx,
00244                                         const char *format, ...);
00245 SPF_errcode_t    SPF_response_add_warn(SPF_response_t *rp,
00246                                         SPF_errcode_t code,
00247                                         const char *format, ...);
00248 
00249 #endif

Generated on Tue Nov 4 13:27:38 2008 for libspf2 by  doxygen 1.5.4