libspf2  1.2.10
Data Structures | Macros | Enumerations | Functions
spf_compile.c File Reference
#include "spf_sys_config.h"
#include "spf_internal.h"
#include "spf.h"
#include "spf_response.h"
#include "spf_record.h"
Include dependency graph for spf_compile.c:

Go to the source code of this file.

Data Structures

struct  SPF_mechtype_struct
 

Macros

#define SPF_RECORD_BUFSIZ   4096
 
#define ALIGN_DECL(decl)   union { double d; long l; decl } __attribute__((aligned(_ALIGN_SZ))) u
 
#define ALIGNED_DECL(var)   u.var
 
#define spf_num_mechanisms   sizeof(spf_mechtypes) / sizeof(spf_mechtypes[0])
 
#define SPF_CHECK_IN_MODIFIER()
 
#define SPF_ADD_LEN_TO(_val, _len, _max)
 
#define SPF_INIT_STRING_LITERAL(_avail)
 
#define SPF_ENSURE_STRING_AVAIL(_len)
 
#define SPF_FINI_STRING_LITERAL()
 
#define STREQ_SIZEOF(a, b)   (strncasecmp((a), (b), sizeof( (b) ) - 1) == 0)
 
#define STREQ_SIZEOF_N(a, b, n)   (((n) == sizeof(b) - 1) && (strncasecmp((a),(b),(n)) == 0))
 

Enumerations

enum  SPF_cidr_enum { CIDR_NONE, CIDR_OPTIONAL, CIDR_ONLY }
 
enum  SPF_domspec_enum { DOMSPEC_NONE, DOMSPEC_OPTIONAL, DOMSPEC_REQUIRED }
 

Functions

 __attribute__ ((warn_unused_result))
 
SPF_errcode_t SPF_record_compile (SPF_server_t *spf_server, SPF_response_t *spf_response, SPF_record_t **spf_recordp, const char *record)
 
SPF_errcode_t SPF_record_compile_macro (SPF_server_t *spf_server, SPF_response_t *spf_response, SPF_macro_t **spf_macrop, const char *record)
 

Macro Definition Documentation

◆ ALIGN_DECL

#define ALIGN_DECL (   decl)    union { double d; long l; decl } __attribute__((aligned(_ALIGN_SZ))) u

Definition at line 64 of file spf_compile.c.

◆ ALIGNED_DECL

#define ALIGNED_DECL (   var)    u.var

Definition at line 65 of file spf_compile.c.

◆ SPF_ADD_LEN_TO

#define SPF_ADD_LEN_TO (   _val,
  _len,
  _max 
)
Value:
do { \
if ( (_val) + _align_sz(_len) > (_max) ) { \
return SPF_response_add_error_ptr(spf_response, \
big_err, NULL, src, \
"SPF domainspec too long " \
"(%d chars, %d max)", \
(_val) + (_len), _max); \
} \
(_val) += _align_sz(_len); \
} while(0)

Definition at line 441 of file spf_compile.c.

◆ SPF_CHECK_IN_MODIFIER

#define SPF_CHECK_IN_MODIFIER ( )
Value:
if ( !is_mod ) \
return SPF_response_add_error_ptr(spf_response, \
"'%c' macro is only valid in modifiers", c);

◆ SPF_ENSURE_STRING_AVAIL

#define SPF_ENSURE_STRING_AVAIL (   _len)
Value:
do { \
if (ds_len + _len > ds_avail) \
return SPF_response_add_error_ptr(spf_response, \
"String literal fragment too long " \
"(%d chars, %d max)", \
ds_len, ds_avail); \
} while(0)

Definition at line 462 of file spf_compile.c.

◆ SPF_FINI_STRING_LITERAL

#define SPF_FINI_STRING_LITERAL ( )
Value:
do { \
if ( ds_len > 0 ) { \
if ( ds_len > SPF_MAX_STR_LEN ) { \
return SPF_response_add_error_ptr(spf_response, \
"String literal too long " \
"(%d chars, %d max)", \
ds_len, SPF_MAX_STR_LEN); \
} \
data->ds.len = ds_len; \
len = sizeof( *data ) + ds_len; \
SPF_ADD_LEN_TO(*data_used, len, data_avail); \
data = SPF_data_next( data ); \
ds_len = 0; \
} \
} while(0)

Definition at line 471 of file spf_compile.c.

◆ SPF_INIT_STRING_LITERAL

#define SPF_INIT_STRING_LITERAL (   _avail)
Value:
do { \
data->ds.parm_type = PARM_STRING; \
data->ds.len = 0; \
/* Magic numbers for x/Nc in gdb. */ \
data->ds.__unused0 = 0xba; data->ds.__unused1 = 0xbe; \
dst = SPF_data_str( data ); \
ds_avail = _avail; \
ds_len = 0; \
} while(0)

Definition at line 452 of file spf_compile.c.

◆ spf_num_mechanisms

#define spf_num_mechanisms   sizeof(spf_mechtypes) / sizeof(spf_mechtypes[0])

Definition at line 91 of file spf_compile.c.

◆ SPF_RECORD_BUFSIZ

#define SPF_RECORD_BUFSIZ   4096

This is greater than any possible total mechanism or modifier. SPF_MAX_MOD_LEN + SPF_MAX_STR_LEN SPF_MAX_MECH_LEN + SPF_MAX_STR_LEN

Definition at line 62 of file spf_compile.c.

◆ STREQ_SIZEOF

#define STREQ_SIZEOF (   a,
 
)    (strncasecmp((a), (b), sizeof( (b) ) - 1) == 0)

◆ STREQ_SIZEOF_N

#define STREQ_SIZEOF_N (   a,
  b,
 
)    (((n) == sizeof(b) - 1) && (strncasecmp((a),(b),(n)) == 0))

Enumeration Type Documentation

◆ SPF_cidr_enum

Enumerator
CIDR_NONE 
CIDR_OPTIONAL 
CIDR_ONLY 

Definition at line 47 of file spf_compile.c.

◆ SPF_domspec_enum

Enumerator
DOMSPEC_NONE 
DOMSPEC_OPTIONAL 
DOMSPEC_REQUIRED 

Definition at line 52 of file spf_compile.c.

Function Documentation

◆ __attribute__()

__attribute__ ( (warn_unused_result)  )

Definition at line 105 of file spf_compile.c.

◆ SPF_record_compile()

SPF_errcode_t SPF_record_compile ( SPF_server_t *  spf_server,
SPF_response_t *  spf_response,
SPF_record_t **  spf_recordp,
const char *  record 
)

The SPF compiler.

It converts the SPF record in string format that is easy for people to deal with into a compact binary format that is easy for computers to deal with.

Definition at line 1180 of file spf_compile.c.

Referenced by SPF_server_set_localpolicy().

◆ SPF_record_compile_macro()

SPF_errcode_t SPF_record_compile_macro ( SPF_server_t *  spf_server,
SPF_response_t *  spf_response,
SPF_macro_t **  spf_macrop,
const char *  record 
)

Definition at line 1499 of file spf_compile.c.

Referenced by SPF_server_set_explanation().

SPF_E_INVALID_VAR
@ SPF_E_INVALID_VAR
Definition: spf_response.h:132
SPF_MAX_STR_LEN
#define SPF_MAX_STR_LEN
Definition: spf_record.h:73
PARM_STRING
#define PARM_STRING
Definition: spf_record.h:100
NULL
#define NULL
Definition: spf_internal.h:28
SPF_response_add_error_ptr
SPF_errcode_t SPF_response_add_error_ptr(SPF_response_t *rp, SPF_errcode_t code, const char *text, const char *tptr, const char *format,...)
Definition: spf_response.c:238
SPF_E_BIG_STRING
@ SPF_E_BIG_STRING
Definition: spf_response.h:135