From a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Wed, 3 Jul 2024 15:52:39 +0200 Subject: format files --- src/include/base64.h | 4 +- src/include/commands.h | 2 +- src/include/constmap.h | 6 +- src/include/control.h | 8 +-- src/include/date822fmt.h | 2 +- src/include/datetime.h | 2 +- src/include/dkim.h | 172 +++++++++++++++++++++++------------------------ src/include/dkimbase.h | 64 +++++++++--------- src/include/dkimsign.h | 54 ++++++++------- src/include/dkimverify.h | 169 +++++++++++++++++++++++----------------------- src/include/dns.h | 21 +++--- src/include/dnsgettxt.h | 4 +- src/include/extra.h | 2 +- src/include/fifo.h | 2 +- src/include/fmtqfn.h | 2 +- src/include/gfrom.h | 2 +- src/include/global.h | 45 +++++++------ src/include/hfield.h | 56 +++++++-------- src/include/hier.h | 10 +-- src/include/hmac_md5.h | 3 +- src/include/ipalloc.h | 7 +- src/include/ipme.h | 1 + src/include/maildir.h | 5 +- src/include/md5.h | 13 ++-- src/include/mfrules.h | 2 +- src/include/prioq.h | 12 ++-- src/include/qlx.h | 18 ++--- src/include/qmail.h | 10 +-- src/include/qsutil.h | 8 +-- src/include/quote.h | 4 +- src/include/readsubdir.h | 6 +- src/include/received.h | 4 +- src/include/recipients.h | 2 +- src/include/sendtodo.h | 6 +- src/include/sha1.h | 3 +- src/include/sha256.h | 5 +- src/include/smtpdlog.h | 54 +++++++-------- src/include/spf.h | 115 +++++++++++++++---------------- src/include/srs2.h | 88 ++++++++++++------------ src/include/strset.h | 26 +++---- src/include/tls_remote.h | 18 ++--- src/include/token822.h | 22 +++--- src/include/ucspitls.h | 49 +++++++------- src/include/wildmat.h | 2 +- 44 files changed, 553 insertions(+), 557 deletions(-) (limited to 'src/include') diff --git a/src/include/base64.h b/src/include/base64.h index 9384411..88c8543 100644 --- a/src/include/base64.h +++ b/src/include/base64.h @@ -3,7 +3,7 @@ #include "stralloc.h" -extern int b64decode(const unsigned char *,int,stralloc *); -extern int b64encode(stralloc *,stralloc *); +extern int b64decode(const unsigned char *, int, stralloc *); +extern int b64encode(stralloc *, stralloc *); #endif diff --git a/src/include/commands.h b/src/include/commands.h index 3fd2cb8..fed35e7 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -5,7 +5,7 @@ struct commands { char *text; void (*fun)(); void (*flush)(); -} ; +}; int commands(); diff --git a/src/include/constmap.h b/src/include/constmap.h index 750702e..0a43e98 100644 --- a/src/include/constmap.h +++ b/src/include/constmap.h @@ -11,10 +11,10 @@ struct constmap { int *next; char **input; int *inputlen; -} ; +}; -int constmap_init(struct constmap *,char *,int,int); -int constmap_init_char(struct constmap *,char *,int,int,char); +int constmap_init(struct constmap *, char *, int, int); +int constmap_init_char(struct constmap *, char *, int, int, char); void constmap_free(); char *constmap(); diff --git a/src/include/control.h b/src/include/control.h index 732042c..fdd72b3 100644 --- a/src/include/control.h +++ b/src/include/control.h @@ -4,9 +4,9 @@ #include "stralloc.h" int control_init(void); -int control_readline(stralloc *,char *); -int control_rldef(stralloc *,char *,int,char *); -int control_readint(int *,char *); -int control_readfile(stralloc *,char *,int); +int control_readline(stralloc *, char *); +int control_rldef(stralloc *, char *, int, char *); +int control_readint(int *, char *); +int control_readfile(stralloc *, char *, int); #endif diff --git a/src/include/date822fmt.h b/src/include/date822fmt.h index a2f1432..fc721a0 100644 --- a/src/include/date822fmt.h +++ b/src/include/date822fmt.h @@ -1,7 +1,7 @@ #ifndef DATE822FMT_H #define DATE822FMT_H -unsigned int date822fmt(char *,struct datetime *); +unsigned int date822fmt(char *, struct datetime *); #define DATE822FMT 60 #endif diff --git a/src/include/datetime.h b/src/include/datetime.h index 68d1618..eb8abc6 100644 --- a/src/include/datetime.h +++ b/src/include/datetime.h @@ -10,7 +10,7 @@ struct datetime { int yday; int mon; int year; -} ; +}; typedef long datetime_sec; diff --git a/src/include/dkim.h b/src/include/dkim.h index 508b2df..dd2a70d 100644 --- a/src/include/dkim.h +++ b/src/include/dkim.h @@ -20,110 +20,108 @@ * *****************************************************************************/ #define DKIM_CALL -#define MAKELONG(a,b) ((long)(((unsigned)(a) & 0xffff) | (((unsigned)(b) & 0xffff) << 16))) +#define MAKELONG(a, b) ((long)(((unsigned)(a) & 0xffff) | (((unsigned)(b) & 0xffff) << 16))) #ifdef __cplusplus extern "C" { #endif // DKIM hash algorithms -#define DKIM_HASH_SHA1 1 -#define DKIM_HASH_SHA256 2 -#define DKIM_HASH_SHA1_AND_SHA256 3 -#define DKIM_HASH_ED25519 4 -#define DKIM_HASH_RSA256_AND_ED25519 5 +#define DKIM_HASH_SHA1 1 +#define DKIM_HASH_SHA256 2 +#define DKIM_HASH_SHA1_AND_SHA256 3 +#define DKIM_HASH_ED25519 4 +#define DKIM_HASH_RSA256_AND_ED25519 5 // DKIM canonicalization methods -#define DKIM_CANON_SIMPLE 1 -#define DKIM_CANON_NOWSP 2 -#define DKIM_CANON_RELAXED 3 +#define DKIM_CANON_SIMPLE 1 +#define DKIM_CANON_NOWSP 2 +#define DKIM_CANON_RELAXED 3 -#define DKIM_SIGN_SIMPLE MAKELONG(DKIM_CANON_SIMPLE,DKIM_CANON_SIMPLE) -#define DKIM_SIGN_SIMPLE_RELAXED MAKELONG(DKIM_CANON_RELAXED,DKIM_CANON_SIMPLE) -#define DKIM_SIGN_RELAXED MAKELONG(DKIM_CANON_RELAXED,DKIM_CANON_RELAXED) -#define DKIM_SIGN_RELAXED_SIMPLE MAKELONG(DKIM_CANON_SIMPLE,DKIM_CANON_RELAXED) +#define DKIM_SIGN_SIMPLE MAKELONG(DKIM_CANON_SIMPLE, DKIM_CANON_SIMPLE) +#define DKIM_SIGN_SIMPLE_RELAXED MAKELONG(DKIM_CANON_RELAXED, DKIM_CANON_SIMPLE) +#define DKIM_SIGN_RELAXED MAKELONG(DKIM_CANON_RELAXED, DKIM_CANON_RELAXED) +#define DKIM_SIGN_RELAXED_SIMPLE MAKELONG(DKIM_CANON_SIMPLE, DKIM_CANON_RELAXED) // DKIM Error codes -#define DKIM_SUCCESS 0 // operation successful -#define DKIM_FAIL -1 // verify error: message is suspicious -#define DKIM_BAD_SYNTAX -2 // signature error: DKIM-Signature could not parse or has bad tags/values -#define DKIM_SIGNATURE_BAD -3 // signature error: RSA/ED25519 verify failed -#define DKIM_SIGNATURE_BAD_BUT_TESTING -4 // signature error: RSA/ED25519 verify failed but testing -#define DKIM_SIGNATURE_EXPIRED -5 // signature error: x= is old -#define DKIM_SELECTOR_INVALID -6 // signature error: selector doesn't parse or contains invalid values -#define DKIM_SELECTOR_GRANULARITY_MISMATCH -7 // signature error: selector g= doesn't match i= -#define DKIM_SELECTOR_KEY_REVOKED -8 // signature error: selector p= empty -#define DKIM_SELECTOR_DOMAIN_NAME_TOO_LONG -9 // signature error: selector domain name too long to request -#define DKIM_SELECTOR_DNS_TEMP_FAILURE -10 // signature error: temporary dns failure requesting selector -#define DKIM_SELECTOR_DNS_PERM_FAILURE -11 // signature error: permanent dns failure requesting selector -#define DKIM_SELECTOR_PUBLIC_KEY_INVALID -12 // signature error: selector p= value invalid or wrong format -#define DKIM_NO_SIGNATURES -13 // process error, no sigs -#define DKIM_NO_VALID_SIGNATURES -14 // process error, no valid sigs -#define DKIM_BODY_HASH_MISMATCH -15 // sigature verify error: message body does not hash to bh value -#define DKIM_SELECTOR_ALGORITHM_MISMATCH -16 // signature error: selector h= doesn't match signature a= -#define DKIM_STAT_INCOMPAT -17 // signature error: incompatible v= -#define DKIM_UNSIGNED_FROM -18 // signature error: not all message's From headers in signature -#define DKIM_OUT_OF_MEMORY -20 // memory allocation failed -#define DKIM_INVALID_CONTEXT -21 // DKIMContext structure invalid for this operation -#define DKIM_NO_SENDER -22 // signing error: Could not find From: or Sender: header in message -#define DKIM_BAD_PRIVATE_KEY -23 // signing error: Could not parse private key -#define DKIM_BUFFER_TOO_SMALL -24 // signing error: Buffer passed in is not large enough -#define DKIM_MAX_ERROR -25 // set this to 1 greater than the highest error code (but negative) +#define DKIM_SUCCESS 0 // operation successful +#define DKIM_FAIL -1 // verify error: message is suspicious +#define DKIM_BAD_SYNTAX -2 // signature error: DKIM-Signature could not parse or has bad tags/values +#define DKIM_SIGNATURE_BAD -3 // signature error: RSA/ED25519 verify failed +#define DKIM_SIGNATURE_BAD_BUT_TESTING -4 // signature error: RSA/ED25519 verify failed but testing +#define DKIM_SIGNATURE_EXPIRED -5 // signature error: x= is old +#define DKIM_SELECTOR_INVALID -6 // signature error: selector doesn't parse or contains invalid values +#define DKIM_SELECTOR_GRANULARITY_MISMATCH -7 // signature error: selector g= doesn't match i= +#define DKIM_SELECTOR_KEY_REVOKED -8 // signature error: selector p= empty +#define DKIM_SELECTOR_DOMAIN_NAME_TOO_LONG \ + -9 // signature error: selector domain name too long to request +#define DKIM_SELECTOR_DNS_TEMP_FAILURE -10 // signature error: temporary dns failure requesting selector +#define DKIM_SELECTOR_DNS_PERM_FAILURE -11 // signature error: permanent dns failure requesting selector +#define DKIM_SELECTOR_PUBLIC_KEY_INVALID \ + -12 // signature error: selector p= value invalid or wrong format +#define DKIM_NO_SIGNATURES -13 // process error, no sigs +#define DKIM_NO_VALID_SIGNATURES -14 // process error, no valid sigs +#define DKIM_BODY_HASH_MISMATCH -15 // sigature verify error: message body does not hash to bh value +#define DKIM_SELECTOR_ALGORITHM_MISMATCH -16 // signature error: selector h= doesn't match signature a= +#define DKIM_STAT_INCOMPAT -17 // signature error: incompatible v= +#define DKIM_UNSIGNED_FROM -18 // signature error: not all message's From headers in signature +#define DKIM_OUT_OF_MEMORY -20 // memory allocation failed +#define DKIM_INVALID_CONTEXT -21 // DKIMContext structure invalid for this operation +#define DKIM_NO_SENDER -22 // signing error: Could not find From: or Sender: header in message +#define DKIM_BAD_PRIVATE_KEY -23 // signing error: Could not parse private key +#define DKIM_BUFFER_TOO_SMALL -24 // signing error: Buffer passed in is not large enough +#define DKIM_MAX_ERROR -25 // set this to 1 greater than the highest error code (but negative) // DKIM_SUCCESS // verify result: all signatures verified - // signature result: signature verified -#define DKIM_FINISHED_BODY 1 // process result: no more message body is needed -#define DKIM_PARTIAL_SUCCESS 2 // verify result: at least one but not all signatures verified -#define DKIM_NEUTRAL 3 // verify result: no signatures verified but message is not suspicous -#define DKIM_SUCCESS_BUT_EXTRA 4 // signature result: signature verified but it did not include all of the body - +// signature result: signature verified +#define DKIM_FINISHED_BODY 1 // process result: no more message body is needed +#define DKIM_PARTIAL_SUCCESS 2 // verify result: at least one but not all signatures verified +#define DKIM_NEUTRAL 3 // verify result: no signatures verified but message is not suspicous +#define DKIM_SUCCESS_BUT_EXTRA \ + 4 // signature result: signature verified but it did not include all of the body // This function is called once for each header in the message // return 1 to include this header in the signature and 0 to exclude. -typedef int (DKIM_CALL *DKIMHEADERCALLBACK)(const char* szHeader); +typedef int(DKIM_CALL *DKIMHEADERCALLBACK)(const char *szHeader); // This function is called to retrieve a TXT record from DNS -typedef int (DKIM_CALL *DKIMDNSCALLBACK)(const char* szFQDN,char* szBuffer,int nBufLen); +typedef int(DKIM_CALL *DKIMDNSCALLBACK)(const char *szFQDN, char *szBuffer, int nBufLen); -typedef struct DKIMContext_t -{ +typedef struct DKIMContext_t { unsigned int reserved1; unsigned int reserved2; - void* reserved3; + void *reserved3; } DKIMContext; -typedef struct DKIMSignOptions_t -{ - int nCanon; // canonization - int nIncludeBodyLengthTag; // 0 = don't include l= tag, 1 = include l= tag - int nIncludeTimeStamp; // 0 = don't include t= tag, 1 = include t= tag - int nIncludeQueryMethod; // 0 = don't include q= tag, 1 = include q= tag - char szSelector[64]; // selector - required - char szSelectorE[64]; // 2nd selector - optional - char szDomain[256]; // domain - optional - if empty, domain is computed from sender - char szIdentity[256]; // for i= tag, if empty tag will not be included in sig - unsigned long expireTime; // for x= tag, if 0 tag will not be included in sig - DKIMHEADERCALLBACK pfnHeaderCallback; // header callback - char szRequiredHeaders[256]; // colon-separated list of headers that must be signed - int nHash; // use one of the DKIM_HASH_xx constants here - // even if not present in the message - int nIncludeCopiedHeaders; // 0 = don't include z= tag, 1 = include z= tag +typedef struct DKIMSignOptions_t { + int nCanon; // canonization + int nIncludeBodyLengthTag; // 0 = don't include l= tag, 1 = include l= tag + int nIncludeTimeStamp; // 0 = don't include t= tag, 1 = include t= tag + int nIncludeQueryMethod; // 0 = don't include q= tag, 1 = include q= tag + char szSelector[64]; // selector - required + char szSelectorE[64]; // 2nd selector - optional + char szDomain[256]; // domain - optional - if empty, domain is computed from sender + char szIdentity[256]; // for i= tag, if empty tag will not be included in sig + unsigned long expireTime; // for x= tag, if 0 tag will not be included in sig + DKIMHEADERCALLBACK pfnHeaderCallback; // header callback + char szRequiredHeaders[256]; // colon-separated list of headers that must be signed + int nHash; // use one of the DKIM_HASH_xx constants here + // even if not present in the message + int nIncludeCopiedHeaders; // 0 = don't include z= tag, 1 = include z= tag } DKIMSignOptions; -typedef struct DKIMVerifyOptions_t -{ - DKIMDNSCALLBACK pfnSelectorCallback; // selector record callback - DKIMDNSCALLBACK pfnPracticesCallback; // ADSP record callback - int nHonorBodyLengthTag; // 0 = ignore l= tag, 1 = use l= tag to limit the amount of body verified - int nCheckPractices; // 0 = use default (unknown) practices, 1 = request and use author domain signing practices - int nSubjectRequired; // 0 = subject is required to be signed, 1 = not required - int nSaveCanonicalizedData; // 0 = canonicalized data is not saved, 1 = canonicalized data is saved - int nAllowUnsignedFromHeaders; // 0 = From headers not included in the signature are not allowed, 1 = allowed +typedef struct DKIMVerifyOptions_t { + DKIMDNSCALLBACK pfnSelectorCallback; // selector record callback + DKIMDNSCALLBACK pfnPracticesCallback; // ADSP record callback + int nHonorBodyLengthTag; // 0 = ignore l= tag, 1 = use l= tag to limit the amount of body verified + int nCheckPractices; // 0 = use default (unknown) practices, 1 = request and use author domain signing practices + int nSubjectRequired; // 0 = subject is required to be signed, 1 = not required + int nSaveCanonicalizedData; // 0 = canonicalized data is not saved, 1 = canonicalized data is saved + int nAllowUnsignedFromHeaders; // 0 = From headers not included in the signature are not allowed, 1 = allowed } DKIMVerifyOptions; -typedef struct DKIMVerifyDetails_t -{ +typedef struct DKIMVerifyDetails_t { char *szSignature; char *szSignatureDomain; char *szIdentityDomain; @@ -131,22 +129,24 @@ typedef struct DKIMVerifyDetails_t int nResult; } DKIMVerifyDetails; -int DKIM_CALL DKIMSignInit(DKIMContext* pSignContext,DKIMSignOptions* pOptions); -int DKIM_CALL DKIMSignProcess(DKIMContext* pSignContext,char* szBuffer,int nBufLength); -int DKIM_CALL DKIMSignGetSig2(DKIMContext* pSignContext,char* szRSAPrivKey,char *szECCPrivKey,char** pszSignature); -void DKIM_CALL DKIMSignFree(DKIMContext* pSignContext); +int DKIM_CALL DKIMSignInit(DKIMContext *pSignContext, DKIMSignOptions *pOptions); +int DKIM_CALL DKIMSignProcess(DKIMContext *pSignContext, char *szBuffer, int nBufLength); +int DKIM_CALL DKIMSignGetSig2( + DKIMContext *pSignContext, char *szRSAPrivKey, char *szECCPrivKey, char **pszSignature); +void DKIM_CALL DKIMSignFree(DKIMContext *pSignContext); -int DKIM_CALL DKIMVerifyInit(DKIMContext* pVerifyContext,DKIMVerifyOptions* pOptions); -int DKIM_CALL DKIMVerifyProcess(DKIMContext* pVerifyContext,const char* szBuffer,int nBufLength); -int DKIM_CALL DKIMVerifyResults(DKIMContext* pVerifyContext); -int DKIM_CALL DKIMVerifyGetDetails(DKIMContext* pVerifyContext,int* nSigCount,DKIMVerifyDetails** pDetails,char* szPractices); -void DKIM_CALL DKIMVerifyFree(DKIMContext* pVerifyContext); +int DKIM_CALL DKIMVerifyInit(DKIMContext *pVerifyContext, DKIMVerifyOptions *pOptions); +int DKIM_CALL DKIMVerifyProcess(DKIMContext *pVerifyContext, const char *szBuffer, int nBufLength); +int DKIM_CALL DKIMVerifyResults(DKIMContext *pVerifyContext); +int DKIM_CALL DKIMVerifyGetDetails( + DKIMContext *pVerifyContext, int *nSigCount, DKIMVerifyDetails **pDetails, char *szPractices); +void DKIM_CALL DKIMVerifyFree(DKIMContext *pVerifyContext); // const char *DKIM_CALL DKIMVersion(); const char *DKIM_CALL DKIMGetErrorString(int ErrorCode); -int _DKIM_ReportResult(char const *,char const *,char const *); +int _DKIM_ReportResult(const char *, const char *, const char *); const char *DKIM_ErrorResult(const int); #ifdef __cplusplus diff --git a/src/include/dkimbase.h b/src/include/dkimbase.h index 25aac02..bfecb5d 100644 --- a/src/include/dkimbase.h +++ b/src/include/dkimbase.h @@ -22,58 +22,56 @@ #ifndef DKIMBASE_H #define DKIMBASE_H +#include #include #include -#include #define BUFFER_ALLOC_INCREMENT 256 -#include #include +#include using namespace std; -class CDKIMBase -{ +class CDKIMBase { public: + CDKIMBase(); + ~CDKIMBase(); - CDKIMBase(); - ~CDKIMBase(); - - int Init(void); + int Init(void); - int Process(const char* szBuffer,int nBufLength,bool bEOF); - int ProcessFinal(void); + int Process(const char *szBuffer, int nBufLength, bool bEOF); + int ProcessFinal(void); - int Alloc(char*& szBuffer,int nRequiredSize); - int ReAlloc(char*& szBuffer,int& nBufferLength,int nRequiredSize); - void Free(char* szBuffer); + int Alloc(char *& szBuffer, int nRequiredSize); + int ReAlloc(char *& szBuffer, int& nBufferLength, int nRequiredSize); + void Free(char *szBuffer); - static void RemoveSWSP(char* szBuffer); - static void RemoveSWSP(char* pBuffer,int& nBufLength); - static void RemoveSWSP(string& sBuffer); + static void RemoveSWSP(char *szBuffer); + static void RemoveSWSP(char *pBuffer, int& nBufLength); + static void RemoveSWSP(string& sBuffer); - static void CompressSWSP(char* pBuffer,int& nBufLength); - static void CompressSWSP(string& sBuffer); + static void CompressSWSP(char *pBuffer, int& nBufLength); + static void CompressSWSP(string& sBuffer); - static string RelaxHeader(const string& sHeader); + static string RelaxHeader(const string& sHeader); - virtual int ProcessHeaders(void); - virtual int ProcessBody(char* szBuffer,int nBufLength,bool bEOF); + virtual int ProcessHeaders(void); + virtual int ProcessBody(char *szBuffer, int nBufLength, bool bEOF); protected: - char* m_From; - char* m_Sender; - char* m_hTag; - int m_hTagSize; - int m_hTagPos; - char* m_Line; - int m_LineSize; - int m_LinePos; - bool m_InHeaders; - - list HeaderList; + char *m_From; + char *m_Sender; + char *m_hTag; + int m_hTagSize; + int m_hTagPos; + char *m_Line; + int m_LineSize; + int m_LinePos; + bool m_InHeaders; + + list HeaderList; }; -#endif // DKIMBASE_H +#endif // DKIMBASE_H diff --git a/src/include/dkimsign.h b/src/include/dkimsign.h index 150a0b8..af1dd70 100644 --- a/src/include/dkimsign.h +++ b/src/include/dkimsign.h @@ -24,58 +24,60 @@ #include "dkimbase.h" -class CDKIMSign : public CDKIMBase -{ +class CDKIMSign : public CDKIMBase { public: CDKIMSign(); ~CDKIMSign(); //int Init() = delete; - int Init(DKIMSignOptions* pOptions); - int GetSig2(char* szRSAPrivKey,char* szECCPrivKey,char** pszSignature); + int Init(DKIMSignOptions *pOptions); + int GetSig2(char *szRSAPrivKey, char *szECCPrivKey, char **pszSignature); virtual int ProcessHeaders(void) override; - virtual int ProcessBody(char* szBuffer,int nBufLength,bool bEOF) override; + virtual int ProcessBody(char *szBuffer, int nBufLength, bool bEOF) override; - enum CKDKIMConstants { OptimalHeaderLineLength = 65 }; + enum CKDKIMConstants { + OptimalHeaderLineLength = 65 + }; - void Hash(const char* szBuffer,int nBufLength,bool bHdr); + void Hash(const char *szBuffer, int nBufLength, bool bHdr); protected: - bool SignThisTag(const string& sTag); void GetHeaderParams(const string& sHdr); void ProcessHeader(const string& sHdr); bool ParseFromAddress(void); void InitSig(void); - void AddTagToSig(const char* const Tag,const string &sValue,char cbrk,bool bFold); - void AddTagToSig(const char* const Tag,unsigned long nValue); + void AddTagToSig(const char *const Tag, const string& sValue, char cbrk, bool bFold); + void AddTagToSig(const char *const Tag, unsigned long nValue); void AddInterTagSpace(int nSizeOfNextTag); - void AddFoldedValueToSig(const string &sValue,char cbrk); + void AddFoldedValueToSig(const string& sValue, char cbrk); bool IsRequiredHeader(const string& sTag); - int ConstructSignature(char* szSignKey,int nSigAlg); + int ConstructSignature(char *szSignKey, int nSigAlg); - int AssembleReturnedSig(char* szRSAPrivKey,char* szECCPrivKey); + int AssembleReturnedSig(char *szRSAPrivKey, char *szECCPrivKey); -#if ((OPENSSL_VERSION_NUMBER < 0x10100000L) || (LIBRESSL_VERSION_NUMBER > 0 && LIBRESSL_VERSION_NUMBER < 0x20700000L)) - EVP_MD_CTX m_Hdr_sha1ctx; /* the RSA SHA1 signature */ - EVP_MD_CTX m_Hdr_sha256ctx; /* the RSA SHA256 signature */ +#if ( \ + (OPENSSL_VERSION_NUMBER < 0x10100000L) \ + || (LIBRESSL_VERSION_NUMBER > 0 && LIBRESSL_VERSION_NUMBER < 0x20700000L)) + EVP_MD_CTX m_Hdr_sha1ctx; /* the RSA SHA1 signature */ + EVP_MD_CTX m_Hdr_sha256ctx; /* the RSA SHA256 signature */ - EVP_MD_CTX m_Bdy_sha1ctx; /* the SHA1 digest */ - EVP_MD_CTX m_Bdy_sha256ctx; /* the SHA256 digest */ + EVP_MD_CTX m_Bdy_sha1ctx; /* the SHA1 digest */ + EVP_MD_CTX m_Bdy_sha256ctx; /* the SHA256 digest */ #else EVP_MD_CTX *m_Hdr_sha1ctx; /* the RSA SHA1 signature */ EVP_MD_CTX *m_Hdr_sha256ctx; /* the RSA SHA256 signature */ EVP_MD_CTX *m_Hdr_ed25519ctx; /* the PureEd25519 signature */ - EVP_MD_CTX *m_Bdy_sha1ctx; /* the SHA1 digest */ - EVP_MD_CTX *m_Bdy_sha256ctx; /* the SHA256 digest for RSA */ - EVP_MD_CTX *m_Edy_sha256ctx; /* the SHA256 digest for Ed25519 */ + EVP_MD_CTX *m_Bdy_sha1ctx; /* the SHA1 digest */ + EVP_MD_CTX *m_Bdy_sha256ctx; /* the SHA256 digest for RSA */ + EVP_MD_CTX *m_Edy_sha256ctx; /* the SHA256 digest for Ed25519 */ #endif - int m_Canon; /* canonization method */ + int m_Canon; /* canonization method */ int m_EmptyLineCount; @@ -83,9 +85,9 @@ protected: string sFrom; string sSender; string sSelector; - string eSelector; /* Used for Ed25519 signatures */ + string eSelector; /* Used for Ed25519 signatures */ string sDomain; - string sIdentity; /* for i= tag, if empty tag will not be included in sig */ + string sIdentity; /* for i= tag, if empty tag will not be included in sig */ string sRequiredHeaders; bool m_IncludeBodyLengthTag; @@ -98,7 +100,7 @@ protected: DKIMHEADERCALLBACK m_pfnHdrCallback; - string m_sSig; // DKIM-Signature .... + string m_sSig; // DKIM-Signature .... int m_nSigPos; string m_sReturnedSig; @@ -110,4 +112,4 @@ protected: int m_SigHdrs; }; -#endif // DKIMSIGN_H +#endif // DKIMSIGN_H diff --git a/src/include/dkimverify.h b/src/include/dkimverify.h index 64de2a1..685426b 100644 --- a/src/include/dkimverify.h +++ b/src/include/dkimverify.h @@ -22,131 +22,132 @@ #ifndef DKIMVERIFY_H #define DKIMVERIFY_H -#include "dkimbase.h" #include +#include "dkimbase.h" + /* not used anymore #define DKIM_ADSP_UNKNOWN 1 #define DKIM_ADSP_ALL 2 #define DKIM_ADSP_DISCARDABLE 3 */ -#define DKIM_POLICY_DOMAIN_NAME_TOO_LONG -50 // internal error -#define DKIM_POLICY_DNS_TEMP_FAILURE -51 // internal error -#define DKIM_POLICY_DNS_PERM_FAILURE -52 // internal error -#define DKIM_POLICY_INVALID -53 // internal error +#define DKIM_POLICY_DOMAIN_NAME_TOO_LONG -50 // internal error +#define DKIM_POLICY_DNS_TEMP_FAILURE -51 // internal error +#define DKIM_POLICY_DNS_PERM_FAILURE -52 // internal error +#define DKIM_POLICY_INVALID -53 // internal error /* dito #define DKIM_SIG_VERSION_PRE_02 0 #define DKIM_SIG_VERSION_02_PLUS 1 */ -class SelectorInfo -{ +class SelectorInfo { public: - SelectorInfo(const string &sSelector,const string &sDomain); - ~SelectorInfo(); + SelectorInfo(const string& sSelector, const string& sDomain); + ~SelectorInfo(); - string Domain; - string Selector; - string Granularity; - bool AllowSHA1; - bool AllowSHA256; - EVP_PKEY *PublicKey; /* the public key */ - bool Testing; - bool SameDomain; + string Domain; + string Selector; + string Granularity; + bool AllowSHA1; + bool AllowSHA256; + EVP_PKEY *PublicKey; /* the public key */ + bool Testing; + bool SameDomain; - int Status; + int Status; - int Parse(char* Buffer); + int Parse(char *Buffer); }; -class SignatureInfo -{ +class SignatureInfo { public: - SignatureInfo(bool SaveCanonicalizedData); - ~SignatureInfo(); - - void Hash(const char* szBuffer,unsigned nBufLength,bool IsBody=false); - - string Header; - unsigned Version; - string Domain; - string Selector; - string SignatureData; - string BodyHashData; - string IdentityLocalPart; - string IdentityDomain; - string CanonicalizedData; - vector SignedHeaders; - unsigned BodyLength; - unsigned HeaderCanonicalization; - unsigned BodyCanonicalization; - unsigned ExpireTime; - - unsigned VerifiedBodyCount; - unsigned UnverifiedBodyCount; - -#if ((OPENSSL_VERSION_NUMBER < 0x10100000L) || (LIBRESSL_VERSION_NUMBER > 0 && LIBRESSL_VERSION_NUMBER < 0x20700000L)) - EVP_MD_CTX m_Hdr_ctx; - EVP_MD_CTX m_Bdy_ctx; + SignatureInfo(bool SaveCanonicalizedData); + ~SignatureInfo(); + + void Hash(const char *szBuffer, unsigned nBufLength, bool IsBody = false); + + string Header; + unsigned Version; + string Domain; + string Selector; + string SignatureData; + string BodyHashData; + string IdentityLocalPart; + string IdentityDomain; + string CanonicalizedData; + vector SignedHeaders; + unsigned BodyLength; + unsigned HeaderCanonicalization; + unsigned BodyCanonicalization; + unsigned ExpireTime; + + unsigned VerifiedBodyCount; + unsigned UnverifiedBodyCount; + +#if ( \ + (OPENSSL_VERSION_NUMBER < 0x10100000L) \ + || (LIBRESSL_VERSION_NUMBER > 0 && LIBRESSL_VERSION_NUMBER < 0x20700000L)) + EVP_MD_CTX m_Hdr_ctx; + EVP_MD_CTX m_Bdy_ctx; #else - EVP_MD_CTX *m_Hdr_ctx; - EVP_MD_CTX *m_Bdy_ctx; + EVP_MD_CTX *m_Hdr_ctx; + EVP_MD_CTX *m_Bdy_ctx; #endif #if (OPENSSL_VERSION_NUMBER > 0x10101000L) - EVP_MD_CTX *m_Msg_ctx; + EVP_MD_CTX *m_Msg_ctx; #endif - SelectorInfo *m_pSelector; + SelectorInfo *m_pSelector; - int Status; - int m_nHash; // use one of the DKIM_HASH_xxx constants here - unsigned EmptyLineCount; - bool m_SaveCanonicalizedData; + int Status; + int m_nHash; // use one of the DKIM_HASH_xxx constants here + unsigned EmptyLineCount; + bool m_SaveCanonicalizedData; }; -class CDKIMVerify : public CDKIMBase -{ +class CDKIMVerify : public CDKIMBase { public: + CDKIMVerify(); + ~CDKIMVerify(); + // virtual ~CDKIMVerify() = 0; - CDKIMVerify(); - ~CDKIMVerify(); -// virtual ~CDKIMVerify() = 0; + int Init(DKIMVerifyOptions *pOptions); - int Init(DKIMVerifyOptions* pOptions); + int GetResults(void); + int GetDetails(int *nSigCount, DKIMVerifyDetails **pDetails); + // int _DNSGetTXT(const char* szFQDN,char* Buffer,int nBufLen); - int GetResults(void); - int GetDetails(int* nSigCount,DKIMVerifyDetails** pDetails); -// int _DNSGetTXT(const char* szFQDN,char* Buffer,int nBufLen); + virtual int ProcessHeaders(void); + virtual int ProcessBody(char *szBuffer, int nBufLength, bool bEOF); - virtual int ProcessHeaders(void); - virtual int ProcessBody(char* szBuffer,int nBufLength,bool bEOF); - - const char* GetPractices() { return Practices.c_str(); } + const char *GetPractices() + { + return Practices.c_str(); + } protected: + int ParseDKIMSignature(const string& sHeader, SignatureInfo& sig); - int ParseDKIMSignature(const string& sHeader,SignatureInfo &sig); - - SelectorInfo& GetSelector(const string &sSelector,const string &sDomain); + SelectorInfo& GetSelector(const string& sSelector, const string& sDomain); -// int GetADSP(const string &sDomain,int &iADSP); + // int GetADSP(const string &sDomain,int &iADSP); - list Signatures; - list Selectors; + list Signatures; + list Selectors; - DKIMDNSCALLBACK m_pfnSelectorCallback; // selector record callback -// DKIMDNSCALLBACK m_pfnPracticesCallback; // ADSP record callback + DKIMDNSCALLBACK m_pfnSelectorCallback; // selector record callback + // DKIMDNSCALLBACK m_pfnPracticesCallback; // ADSP record callback - bool m_HonorBodyLengthTag; - bool m_CheckPractices; - bool m_SubjectIsRequired; - bool m_SaveCanonicalizedData; - bool m_AllowUnsignedFromHeaders; + bool m_HonorBodyLengthTag; + bool m_CheckPractices; + bool m_SubjectIsRequired; + bool m_SaveCanonicalizedData; + bool m_AllowUnsignedFromHeaders; - vector Details; - string Practices; + vector Details; + string Practices; }; -#endif //DKIMVERIFY_H +#endif //DKIMVERIFY_H diff --git a/src/include/dns.h b/src/include/dns.h index 6293478..e914cda 100644 --- a/src/include/dns.h +++ b/src/include/dns.h @@ -6,19 +6,22 @@ extern "C" { #endif #include "dnsresolv.h" -#include "ipalloc.h" #include "stralloc.h" -#define DNS_INIT static char seed[128]; dns_random_init(seed); -#define DNS_NXD 0 -#define DNS_SOFT -5 -#define DNS_HARD -6 +#include "ipalloc.h" + +#define DNS_INIT \ + static char seed[128]; \ + dns_random_init(seed); +#define DNS_NXD 0 +#define DNS_SOFT -5 +#define DNS_HARD -6 void dns_init(int); -int dns_ip(ipalloc *,stralloc *); -int dns_mxip(ipalloc *,stralloc *,unsigned long); -int dns_tlsa(stralloc *,const stralloc *); -int dns_mxhost(stralloc *,const stralloc *); +int dns_ip(ipalloc *, stralloc *); +int dns_mxip(ipalloc *, stralloc *, unsigned long); +int dns_tlsa(stralloc *, const stralloc *); +int dns_mxhost(stralloc *, const stralloc *); #ifdef __cplusplus } diff --git a/src/include/dnsgettxt.h b/src/include/dnsgettxt.h index 6d6b8ea..3158fe0 100644 --- a/src/include/dnsgettxt.h +++ b/src/include/dnsgettxt.h @@ -1,7 +1,7 @@ #ifdef cplusplus extern "C" { -int DNSGetTXT(const char* szFQDN,char* Buffer,int nBufLen); -extern void dns_random_init(const char [12]); +int DNSGetTXT(const char *szFQDN, char *Buffer, int nBufLen); +extern void dns_random_init(const char[12]); #endif diff --git a/src/include/extra.h b/src/include/extra.h index c598175..df43a26 100644 --- a/src/include/extra.h +++ b/src/include/extra.h @@ -1,7 +1,7 @@ #ifndef EXTRA_H #define EXTRA_H -#define QUEUE_EXTRA "" +#define QUEUE_EXTRA "" #define QUEUE_EXTRALEN 0 #endif diff --git a/src/include/fifo.h b/src/include/fifo.h index f48c863..cfaa801 100644 --- a/src/include/fifo.h +++ b/src/include/fifo.h @@ -1,6 +1,6 @@ #ifndef FIFO_H #define FIFO_H -int fifo_make(char *,int); +int fifo_make(char *, int); #endif diff --git a/src/include/fmtqfn.h b/src/include/fmtqfn.h index e11e51e..11f48d3 100644 --- a/src/include/fmtqfn.h +++ b/src/include/fmtqfn.h @@ -1,7 +1,7 @@ #ifndef FMTQFN_H #define FMTQFN_H -unsigned int fmtqfn(char *,char *,unsigned long,int); +unsigned int fmtqfn(char *, char *, unsigned long, int); #define FMTQFN 40 /* maximum space needed, if len(dirslash) <= 10 */ diff --git a/src/include/gfrom.h b/src/include/gfrom.h index 121ff6d..40fb769 100644 --- a/src/include/gfrom.h +++ b/src/include/gfrom.h @@ -1,6 +1,6 @@ #ifndef GFROM_H #define GFROM_H -int gfrom(char *,int); +int gfrom(char *, int); #endif diff --git a/src/include/global.h b/src/include/global.h index 2d8ccf4..7e9b673 100644 --- a/src/include/global.h +++ b/src/include/global.h @@ -1,6 +1,7 @@ /* GLOBAL.H - RSAREF types and constants */ #include + #include "uint_t.h" /* Copyright (C) RSA Laboratories, a division of RSA Data Security, @@ -8,16 +9,16 @@ */ #ifndef _GLOBAL_H_ -#define _GLOBAL_H_ 1 + #define _GLOBAL_H_ 1 -/* PROTOTYPES should be set to one if and only if the compiler supports + /* PROTOTYPES should be set to one if and only if the compiler supports function argument prototyping. The following makes PROTOTYPES default to 1 if it has not already been defined as 0 with C compiler flags. */ -#ifndef PROTOTYPES -#define PROTOTYPES 1 -#endif + #ifndef PROTOTYPES + #define PROTOTYPES 1 + #endif /* POINTER defines a generic pointer type */ typedef unsigned char *POINTER; @@ -25,29 +26,29 @@ typedef unsigned char *POINTER; /* UINT2 defines a two byte word */ typedef unsigned short int UINT2; -/* UINT4 defines a four byte word */ -#ifdef UINT32_H -#define UINT4 uint32 -#else + /* UINT4 defines a four byte word */ + #ifdef UINT32_H + #define UINT4 uint32 + #else typedef unsigned long int UINT4; -#endif + #endif -#ifndef NULL_PTR -#define NULL_PTR ((POINTER)0) -#endif + #ifndef NULL_PTR + #define NULL_PTR ((POINTER)0) + #endif -#ifndef UNUSED_ARG -#define UNUSED_ARG(x) x = *(&x); -#endif + #ifndef UNUSED_ARG + #define UNUSED_ARG(x) x = *(&x); + #endif -/* PROTO_LIST is defined depending on how PROTOTYPES is defined above. + /* PROTO_LIST is defined depending on how PROTOTYPES is defined above. If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it returns an empty list. */ -#if PROTOTYPES -#define PROTO_LIST(list) list -#else -#define PROTO_LIST(list) () -#endif + #if PROTOTYPES + #define PROTO_LIST(list) list + #else + #define PROTO_LIST(list) () + #endif #endif /* end _GLOBAL_H_ */ diff --git a/src/include/hfield.h b/src/include/hfield.h index ab367f4..f2110b5 100644 --- a/src/include/hfield.h +++ b/src/include/hfield.h @@ -5,34 +5,34 @@ unsigned int hfield_skipname(); int hfield_known(); int hfield_valid(); -#define H_SENDER 1 -#define H_FROM 2 -#define H_REPLYTO 3 -#define H_TO 4 -#define H_CC 5 -#define H_BCC 6 -#define H_DATE 7 -#define H_MESSAGEID 8 -#define H_SUBJECT 9 -#define H_R_SENDER 10 -#define H_R_FROM 11 -#define H_R_REPLYTO 12 -#define H_R_TO 13 -#define H_R_CC 14 -#define H_R_BCC 15 -#define H_R_DATE 16 -#define H_R_MESSAGEID 17 -#define H_RETURNRECEIPTTO 18 -#define H_ERRORSTO 19 -#define H_APPARENTLYTO 20 -#define H_RECEIVED 21 -#define H_RETURNPATH 22 -#define H_DELIVEREDTO 23 -#define H_CONTENTLENGTH 24 -#define H_CONTENTTYPE 25 -#define H_CONTENTTRANSFERENCODING 26 +#define H_SENDER 1 +#define H_FROM 2 +#define H_REPLYTO 3 +#define H_TO 4 +#define H_CC 5 +#define H_BCC 6 +#define H_DATE 7 +#define H_MESSAGEID 8 +#define H_SUBJECT 9 +#define H_R_SENDER 10 +#define H_R_FROM 11 +#define H_R_REPLYTO 12 +#define H_R_TO 13 +#define H_R_CC 14 +#define H_R_BCC 15 +#define H_R_DATE 16 +#define H_R_MESSAGEID 17 +#define H_RETURNRECEIPTTO 18 +#define H_ERRORSTO 19 +#define H_APPARENTLYTO 20 +#define H_RECEIVED 21 +#define H_RETURNPATH 22 +#define H_DELIVEREDTO 23 +#define H_CONTENTLENGTH 24 +#define H_CONTENTTYPE 25 +#define H_CONTENTTRANSFERENCODING 26 #define H_NOTICEREQUESTEDUPONDELIVERYTO 27 -#define H_MAILFOLLOWUPTO 28 -#define H_NUM 29 +#define H_MAILFOLLOWUPTO 28 +#define H_NUM 29 #endif diff --git a/src/include/hier.h b/src/include/hier.h index f040e79..21413cc 100644 --- a/src/include/hier.h +++ b/src/include/hier.h @@ -1,10 +1,10 @@ #ifndef HIER_H #define HIER_H -void c(char *,char *,char *,int,int,int); -void h(char *,int,int,int); -void d(char *,char *,int,int,int); -void p(char *,char *,int,int,int); -void z(char *,char *,int,int,int,int); +void c(char *, char *, char *, int, int, int); +void h(char *, int, int, int); +void d(char *, char *, int, int, int); +void p(char *, char *, int, int, int); +void z(char *, char *, int, int, int, int); #endif diff --git a/src/include/hmac_md5.h b/src/include/hmac_md5.h index 87a2c37..aa8c00d 100644 --- a/src/include/hmac_md5.h +++ b/src/include/hmac_md5.h @@ -1,7 +1,6 @@ #ifndef HMAC_MD5_H #define HMAC_MD5_H -void hmac_md5(unsigned char *,int,unsigned char *,int,unsigned char *); +void hmac_md5(unsigned char *, int, unsigned char *, int, unsigned char *); #endif - diff --git a/src/include/ipalloc.h b/src/include/ipalloc.h index 0f58e92..6626ecc 100644 --- a/src/include/ipalloc.h +++ b/src/include/ipalloc.h @@ -1,8 +1,8 @@ #ifndef IPALLOC_H #define IPALLOC_H -#include "ip.h" #include "genalloc.h" +#include "ip.h" #define NAME_LEN 256 struct ip_mx { @@ -10,13 +10,12 @@ struct ip_mx { union { struct ip4_address ip4; struct ip6_address ip6; - } addr; + } addr; int pref; char mxh[NAME_LEN]; }; -GEN_ALLOC_typedef(ipalloc,struct ip_mx,ix,len,a) -int ipalloc_readyplus(); +GEN_ALLOC_typedef(ipalloc, struct ip_mx, ix, len, a) int ipalloc_readyplus(); int ipalloc_append(); #endif diff --git a/src/include/ipme.h b/src/include/ipme.h index 9705f45..f9dff4e 100644 --- a/src/include/ipme.h +++ b/src/include/ipme.h @@ -2,6 +2,7 @@ #define IPME_H #include "ip.h" + #include "ipalloc.h" extern ipalloc ipme; diff --git a/src/include/maildir.h b/src/include/maildir.h index 5e48822..69e679b 100644 --- a/src/include/maildir.h +++ b/src/include/maildir.h @@ -2,12 +2,13 @@ #define MAILDIR_H #include "logmsg.h" -#include "prioq.h" + +#include "prioq.h" extern struct strerr maildir_chdir_err; extern struct strerr maildir_scan_err; int maildir_chdir(void); void maildir_clean(stralloc *); -int maildir_scan(prioq *,stralloc *,int,int); +int maildir_scan(prioq *, stralloc *, int, int); #endif diff --git a/src/include/md5.h b/src/include/md5.h index 94774ba..bb12b74 100644 --- a/src/include/md5.h +++ b/src/include/md5.h @@ -32,15 +32,14 @@ extern "C" { /* MD5 context. */ typedef struct { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ + UINT4 state[4]; /* state (ABCD) */ + UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ } MD5_CTX; -void MD5Init PROTO_LIST ((MD5_CTX *)); -void MD5Update PROTO_LIST - ((MD5_CTX *, unsigned char *, unsigned int)); -void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *)); +void MD5Init PROTO_LIST((MD5_CTX *)); +void MD5Update PROTO_LIST((MD5_CTX *, unsigned char *, unsigned int)); +void MD5Final PROTO_LIST((unsigned char[16], MD5_CTX *)); #ifdef __cplusplus } diff --git a/src/include/mfrules.h b/src/include/mfrules.h index b79f338..68e678b 100644 --- a/src/include/mfrules.h +++ b/src/include/mfrules.h @@ -4,6 +4,6 @@ #include "stralloc.h" extern stralloc key; -int mfrules(int,char *,char *,char *,char *); +int mfrules(int, char *, char *, char *, char *); #endif diff --git a/src/include/prioq.h b/src/include/prioq.h index 3547b1c..cbddd9b 100644 --- a/src/include/prioq.h +++ b/src/include/prioq.h @@ -1,14 +1,18 @@ #ifndef PRIOQ_H #define PRIOQ_H -#include "datetime.h" #include "genalloc.h" -struct prioq_elt { datetime_sec dt; unsigned long id; } ; +#include "datetime.h" + +struct prioq_elt { + datetime_sec dt; + unsigned long id; +}; -GEN_ALLOC_typedef(prioq,struct prioq_elt,p,len,a) +GEN_ALLOC_typedef(prioq, struct prioq_elt, p, len, a) -int prioq_insert(); + int prioq_insert(); int prioq_min(); void prioq_delmin(); diff --git a/src/include/qlx.h b/src/include/qlx.h index 713946d..9008b31 100644 --- a/src/include/qlx.h +++ b/src/include/qlx.h @@ -3,16 +3,16 @@ /* 0, 111, 100 are qmail-local success, soft, hard */ -#define QLX_USAGE 112 -#define QLX_BUG 101 -#define QLX_ROOT 113 -#define QLX_NFS 115 -#define QLX_NOALIAS 116 -#define QLX_CDB 117 -#define QLX_SYS 118 -#define QLX_NOMEM 119 +#define QLX_USAGE 112 +#define QLX_BUG 101 +#define QLX_ROOT 113 +#define QLX_NFS 115 +#define QLX_NOALIAS 116 +#define QLX_CDB 117 +#define QLX_SYS 118 +#define QLX_NOMEM 119 #define QLX_EXECSOFT 120 -#define QLX_EXECPW 121 +#define QLX_EXECPW 121 #define QLX_EXECHARD 126 #endif diff --git a/src/include/qmail.h b/src/include/qmail.h index 7db214d..8e0ad3d 100644 --- a/src/include/qmail.h +++ b/src/include/qmail.h @@ -10,13 +10,13 @@ struct qmail { int fde; buffer ss; char buf[1024]; -} ; +}; extern int qmail_open(struct qmail *); -extern void qmail_put(struct qmail *,char *, int); -extern void qmail_puts(struct qmail *,char *); -extern void qmail_from(struct qmail *,char *); -extern void qmail_to(struct qmail *,char *); +extern void qmail_put(struct qmail *, char *, int); +extern void qmail_puts(struct qmail *, char *); +extern void qmail_from(struct qmail *, char *); +extern void qmail_to(struct qmail *, char *); extern void qmail_fail(struct qmail *); extern char *qmail_close(struct qmail *); extern unsigned long qmail_qp(struct qmail *); diff --git a/src/include/qsutil.h b/src/include/qsutil.h index a77a3f8..7ef8ec1 100644 --- a/src/include/qsutil.h +++ b/src/include/qsutil.h @@ -4,10 +4,10 @@ #include "stralloc.h" void log1s(char *); -void log2s(char *,char *); -void log3s(char *,char *,char *); -void log4s(char *,char *,char *,char *); -void log5s(char *,char *,char *,char *,char *); +void log2s(char *, char *); +void log3s(char *, char *, char *); +void log4s(char *, char *, char *, char *); +void log5s(char *, char *, char *, char *, char *); void logsa(stralloc *); void nomem(); void pausedir(char *); diff --git a/src/include/quote.h b/src/include/quote.h index 4afbc94..4f1c467 100644 --- a/src/include/quote.h +++ b/src/include/quote.h @@ -3,8 +3,8 @@ #include "stralloc.h" -int quote_need(char *,unsigned int); +int quote_need(char *, unsigned int); int quote(stralloc *, stralloc *); -int quote2(stralloc *,char *); +int quote2(stralloc *, char *); #endif diff --git a/src/include/readsubdir.h b/src/include/readsubdir.h index e612fac..3910693 100644 --- a/src/include/readsubdir.h +++ b/src/include/readsubdir.h @@ -3,14 +3,12 @@ #include "direntry.h" -typedef struct readsubdir -{ +typedef struct readsubdir { DIR *dir; int pos; char *name; void (*pause)(); -} -readsubdir; +} readsubdir; void readsubdir_init(); int readsubdir_next(); diff --git a/src/include/received.h b/src/include/received.h index 2b2ce75..eac017f 100644 --- a/src/include/received.h +++ b/src/include/received.h @@ -3,7 +3,7 @@ #include "qmail.h" -void received(struct qmail *,char *,char *,char *,char *,char *,char *,char *,char *); -void spfheader(struct qmail *,char *,char *,char *,char *,char *); +void received(struct qmail *, char *, char *, char *, char *, char *, char *, char *, char *); +void spfheader(struct qmail *, char *, char *, char *, char *, char *); #endif diff --git a/src/include/recipients.h b/src/include/recipients.h index b73f37e..e666bd1 100644 --- a/src/include/recipients.h +++ b/src/include/recipients.h @@ -2,7 +2,7 @@ #define RECIPIENTS_H int recipients_init(void); -int recipients(char *,int); +int recipients(char *, int); ssize_t safewrite(); #endif diff --git a/src/include/sendtodo.h b/src/include/sendtodo.h index 86b4434..c2c6819 100644 --- a/src/include/sendtodo.h +++ b/src/include/sendtodo.h @@ -4,11 +4,11 @@ /* critical timing feature #1: if not triggered, do not busy-loop */ /* critical timing feature #2: if triggered, respond within fixed time */ /* important timing feature: when triggered, respond instantly */ -#define SLEEP_TODO 1500 /* check todo/ every 25 minutes in any case */ -#define SLEEP_FUZZ 1 /* slop a bit on sleeps to avoid zeno effect */ +#define SLEEP_TODO 1500 /* check todo/ every 25 minutes in any case */ +#define SLEEP_FUZZ 1 /* slop a bit on sleeps to avoid zeno effect */ #define SLEEP_FOREVER 86400 /* absolute maximum time spent in select() */ #define SLEEP_CLEANUP 76431 /* time between cleanups */ #define SLEEP_SYSFAIL 123 -#define OSSIFIED 129600 /* 36 hours; _must_ exceed q-q's DEATH (24 hours) */ +#define OSSIFIED 129600 /* 36 hours; _must_ exceed q-q's DEATH (24 hours) */ #endif diff --git a/src/include/sha1.h b/src/include/sha1.h index 43d141d..3d35750 100644 --- a/src/include/sha1.h +++ b/src/include/sha1.h @@ -15,8 +15,7 @@ #define SHA1_BLOCKSIZE 64 #define SHA1_DIGESTSIZE 20 -typedef struct -{ +typedef struct { uint32_t state[5]; uint32_t count[2]; uint8_t buffer[SHA1_BLOCKSIZE]; diff --git a/src/include/sha256.h b/src/include/sha256.h index e8979c5..8c920b1 100644 --- a/src/include/sha256.h +++ b/src/include/sha256.h @@ -1,8 +1,7 @@ #ifndef SHA256_H #define SHA256_H -typedef struct -{ +typedef struct { uint8_t data[64]; uint32_t datalen; uint32_t bitlen[2]; @@ -13,6 +12,6 @@ static void sha256_init(sha256_ctx *ctx); static void sha256_transform(sha256_ctx *ctx, uint8_t *data); static void sha256_update(sha256_ctx *ctx, uint8_t *data, uint32_t len); static void sha256_final(uint8_t *hash, sha256_ctx *ctx); -extern void sha256_hash(char *hash,const char *data, size_t len); +extern void sha256_hash(char *hash, const char *data, size_t len); #endif diff --git a/src/include/smtpdlog.h b/src/include/smtpdlog.h index 0feb126..9b305c5 100644 --- a/src/include/smtpdlog.h +++ b/src/include/smtpdlog.h @@ -6,12 +6,12 @@ void flush(); void out(); void smtpdlog_init(void); -void smtp_loga(char *,char *,char *,char *,char *,char *,char *,char *,char *); -void smtp_logb(char *,char *,char *,char *,char *,char *,char *); -void smtp_logg(char *,char *,char *,char *,char *,char *,char *); -void smtp_logh(char *,char *,char *,char *,char *); -void smtp_logi(char *,char *,char *,char *,char *,char *,char *,char *); -void smtp_logr(char *,char *,char *,char *,char *,char *,char *,char *); +void smtp_loga(char *, char *, char *, char *, char *, char *, char *, char *, char *); +void smtp_logb(char *, char *, char *, char *, char *, char *, char *); +void smtp_logg(char *, char *, char *, char *, char *, char *, char *); +void smtp_logh(char *, char *, char *, char *, char *); +void smtp_logi(char *, char *, char *, char *, char *, char *, char *, char *); +void smtp_logr(char *, char *, char *, char *, char *, char *, char *, char *); void die_read(void); void die_alarm(void); @@ -34,40 +34,40 @@ int err_fork(void); int err_pipe(void); int err_write(void); int err_starttls(void); -void err_tlsreq(char *,char *,char *,char *,char *); +void err_tlsreq(char *, char *, char *, char *, char *); -void err_helo(char *,char *,char *,char *,char *,char *,char *,char *); -void err_spf(char *,char *,char *,char *,char *,char *,char *,char *); +void err_helo(char *, char *, char *, char *, char *, char *, char *, char *); +void err_spf(char *, char *, char *, char *, char *, char *, char *, char *); -void err_authsetup(char *,char *,char *,char *,char *); +void err_authsetup(char *, char *, char *, char *, char *); void err_authd(void); -void err_authmail(void); -void err_authfail(char *,char *,char *,char *,char *,char *,char *); -void err_authinvalid(char *,char *,char *,char *,char *); +void err_authmail(void); +void err_authfail(char *, char *, char *, char *, char *, char *, char *); +void err_authinvalid(char *, char *, char *, char *, char *); void err_authabrt(void); -void err_authreq(char *,char *,char *,char *,char *); -void err_submission(char *,char *,char *,char *,char *); +void err_authreq(char *, char *, char *, char *, char *); +void err_submission(char *, char *, char *, char *, char *); int err_authabort(void); -int err_authinput(void); +int err_authinput(void); int err_noauth(void); void err_wantmail(void); -void err_mav(char *,char *,char *,char *,char *,char *,char *); -void err_bmf(char *,char *,char *,char *,char *,char *,char *,char *); -void err_mfdns(char *,char *,char *,char *,char *,char *,char *); +void err_mav(char *, char *, char *, char *, char *, char *, char *); +void err_bmf(char *, char *, char *, char *, char *, char *, char *, char *); +void err_mfdns(char *, char *, char *, char *, char *, char *, char *); -void err_nogateway(char *,char *,char *,char *,char *,char *,char *); -void err_brt(char *,char *,char *,char *,char *,char *,char *); -void err_rcpts(char *,char *,char *,char *,char *,char *,char *); -void err_recipient(char *,char *,char *,char *,char *,char *,char *); +void err_nogateway(char *, char *, char *, char *, char *, char *, char *); +void err_brt(char *, char *, char *, char *, char *, char *, char *); +void err_rcpts(char *, char *, char *, char *, char *, char *, char *); +void err_recipient(char *, char *, char *, char *, char *, char *, char *); -void straynewline(void); +void straynewline(void); void err_notorious(void); -void err_size(char *,char *,char *,char *,char *,char *,char *); -void err_data(char *,char *,char *,char *,char *,char *,char *,char *); +void err_size(char *, char *, char *, char *, char *, char *, char *); +void err_data(char *, char *, char *, char *, char *, char *, char *, char *); int err_postgl(void); int err_forkgl(void); -void postgrey(char *,char *,char *,char *,char *,char *,char *); +void postgrey(char *, char *, char *, char *, char *, char *, char *); #endif diff --git a/src/include/spf.h b/src/include/spf.h index ca20418..0b8b0fc 100644 --- a/src/include/spf.h +++ b/src/include/spf.h @@ -2,12 +2,13 @@ #define SPF_H #include "stralloc.h" + #include "ipalloc.h" /* (Internal) Processing codes */ #define SPF_INIT -1 -#define SPF_EXT -2 /* x */ +#define SPF_EXT -2 /* x */ #define SPF_ME -3 #define SPF_EXHAUST -4 #define SPF_LOOP -5 @@ -15,23 +16,23 @@ #define SPF_LOCAL -7 #define SPF_ERROR -8 #define SPF_NOMEM -9 -#define SPF_SYNTAX -10 /* Setup problem */ +#define SPF_SYNTAX -10 /* Setup problem */ /* (External) Resulting codes */ -#define SPF_OK 0 /* + Pass */ -#define SPF_NONE 1 /* o None */ -#define SPF_UNKNOWN 2 /* u Unknown method */ -#define SPF_NEUTRAL 3 /* ? Neutral */ -#define SPF_SOFTFAIL 4 /* ~ Softfail */ -#define SPF_FAIL 5 /* - Not Permitted */ -#define SPF_DNSSOFT 6 /* d From DNS; not used */ +#define SPF_OK 0 /* + Pass */ +#define SPF_NONE 1 /* o None */ +#define SPF_UNKNOWN 2 /* u Unknown method */ +#define SPF_NEUTRAL 3 /* ? Neutral */ +#define SPF_SOFTFAIL 4 /* ~ Softfail */ +#define SPF_FAIL 5 /* - Not Permitted */ +#define SPF_DNSSOFT 6 /* d From DNS; not used */ #define LOOKUP_LIMIT 10 /* spfinfo: S=remoteip|O=mailfrom|C=identity/domain|H=helo|M(echanism)=query|D=redirect|I=domain|P=problem|R:result */ -#define SPF_DEFEXP "See http://%{d}/why.html?sender=%{s}&ip=%{i}&receiver=%{r}" +#define SPF_DEFEXP "See http://%{d}/why.html?sender=%{s}&ip=%{i}&receiver=%{r}" extern int flagip6; extern stralloc spfmf; @@ -48,64 +49,60 @@ extern stralloc spfexpmsg; /* this table and macro came from wget more or less */ /* and was in turn stolen by me++ from libspf as is :) */ -const static unsigned char urlchr_table[256] = -{ - 1, 1, 1, 1, 1, 1, 1, 1, /* NUL SOH STX ETX EOT ENQ ACK BEL */ - 1, 1, 1, 1, 1, 1, 1, 1, /* BS HT LF VT FF CR SO SI */ - 1, 1, 1, 1, 1, 1, 1, 1, /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */ - 1, 1, 1, 1, 1, 1, 1, 1, /* CAN EM SUB ESC FS GS RS US */ - 1, 0, 1, 1, 0, 1, 1, 0, /* SP ! " # $ % & ' */ - 0, 0, 0, 1, 0, 0, 0, 1, /* ( ) * + , - . / */ - 0, 0, 0, 0, 0, 0, 0, 0, /* 0 1 2 3 4 5 6 7 */ - 0, 0, 1, 1, 1, 1, 1, 1, /* 8 9 : ; < = > ? */ - 1, 0, 0, 0, 0, 0, 0, 0, /* @ A B C D E F G */ - 0, 0, 0, 0, 0, 0, 0, 0, /* H I J K L M N O */ - 0, 0, 0, 0, 0, 0, 0, 0, /* P Q R S T U V W */ - 0, 0, 0, 1, 1, 1, 1, 0, /* X Y Z [ \ ] ^ _ */ - 1, 0, 0, 0, 0, 0, 0, 0, /* ` a b c d e f g */ - 0, 0, 0, 0, 0, 0, 0, 0, /* h i j k l m n o */ - 0, 0, 0, 0, 0, 0, 0, 0, /* p q r s t u v w */ - 0, 0, 0, 1, 1, 1, 1, 1, /* x y z { | } ~ DEL */ - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +const static unsigned char urlchr_table[256] = { + 1, 1, 1, 1, 1, 1, 1, 1, /* NUL SOH STX ETX EOT ENQ ACK BEL */ + 1, 1, 1, 1, 1, 1, 1, 1, /* BS HT LF VT FF CR SO SI */ + 1, 1, 1, 1, 1, 1, 1, 1, /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */ + 1, 1, 1, 1, 1, 1, 1, 1, /* CAN EM SUB ESC FS GS RS US */ + 1, 0, 1, 1, 0, 1, 1, 0, /* SP ! " # $ % & ' */ + 0, 0, 0, 1, 0, 0, 0, 1, /* ( ) * + , - . / */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0 1 2 3 4 5 6 7 */ + 0, 0, 1, 1, 1, 1, 1, 1, /* 8 9 : ; < = > ? */ + 1, 0, 0, 0, 0, 0, 0, 0, /* @ A B C D E F G */ + 0, 0, 0, 0, 0, 0, 0, 0, /* H I J K L M N O */ + 0, 0, 0, 0, 0, 0, 0, 0, /* P Q R S T U V W */ + 0, 0, 0, 1, 1, 1, 1, 0, /* X Y Z [ \ ] ^ _ */ + 1, 0, 0, 0, 0, 0, 0, 0, /* ` a b c d e f g */ + 0, 0, 0, 0, 0, 0, 0, 0, /* h i j k l m n o */ + 0, 0, 0, 0, 0, 0, 0, 0, /* p q r s t u v w */ + 0, 0, 0, 1, 1, 1, 1, 1, /* x y z { | } ~ DEL */ + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; -#define WSPACE(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n') -#define NXTOK(b, p, a) do { (b) = (p); \ - while((p) < (a)->len && !WSPACE((a)->s[(p)])) ++(p); \ - while((p) < (a)->len && WSPACE((a)->s[(p)])) (a)->s[(p)++] = 0; \ - } while(0) +#define WSPACE(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n') +#define NXTOK(b, p, a) \ + do { \ + (b) = (p); \ + while ((p) < (a)->len && !WSPACE((a)->s[(p)])) ++(p); \ + while ((p) < (a)->len && WSPACE((a)->s[(p)])) (a)->s[(p)++] = 0; \ + } while (0) /* spfdnsip.c */ -int match_ip4(unsigned char [4],int,char [4]); -int match_ip6(unsigned char [16],int,char [16]); +int match_ip4(unsigned char[4], int, char[4]); +int match_ip6(unsigned char[16], int, char[16]); int get_prefix(char *); -int spf_records(stralloc *,stralloc *); -int spf_include(char *,char *); -int spf_a(char *,char *); -int spf_mx(char *,char *); -int spf_ptr(char *,char *); -int spf_ip4(char *,char *); -int spf_ip6(char *,char *); -int spf_exists(char *,char *); +int spf_records(stralloc *, stralloc *); +int spf_include(char *, char *); +int spf_a(char *, char *); +int spf_mx(char *, char *); +int spf_ptr(char *, char *); +int spf_ip4(char *, char *); +int spf_ip6(char *, char *); +int spf_exists(char *, char *); /* spf.c */ -int spf_query(const char *,const char *,const char *,const char *,const int); +int spf_query(const char *, const char *, const char *, const char *, const int); int spf_lookup(stralloc *); -int spf_mechanism(char *,char *,char *,char *); -int spf_parse(stralloc *,char *,char *); -int spf_macros(stralloc *,char *,char *); -int spf_info(char *,const char *); +int spf_mechanism(char *, char *, char *, char *); +int spf_parse(stralloc *, char *, char *); +int spf_macros(stralloc *, char *, char *); +int spf_info(char *, const char *); #endif - diff --git a/src/include/srs2.h b/src/include/srs2.h index e993928..9856636 100644 --- a/src/include/srs2.h +++ b/src/include/srs2.h @@ -19,12 +19,12 @@ */ /* This is ugly, but reasonably safe. */ -#undef TRUE +#undef TRUE #define TRUE 1 -#undef FALSE +#undef FALSE #define FALSE 0 -#define SRSSEP '=' +#define SRSSEP '=' #define SRS0TAG "SRS0" #define SRS1TAG "SRS1" @@ -37,15 +37,15 @@ #define SRS_ERRTYPE_SYNTAX 0x4000 #define SRS_ERRTYPE_SRS 0x8000 -#define SRS_SUCCESS (0) -#define SRS_ENOTSRSADDRESS (1) -#define SRS_ENOTREWRITTEN (2) +#define SRS_SUCCESS (0) +#define SRS_ENOTSRSADDRESS (1) +#define SRS_ENOTREWRITTEN (2) #define SRS_ENOSECRETS (SRS_ERRTYPE_CONFIG | 1) #define SRS_ESEPARATORINVALID (SRS_ERRTYPE_CONFIG | 2) -#define SRS_ENOSENDERATSIGN (SRS_ERRTYPE_INPUT | 1) -#define SRS_EBUFTOOSMALL (SRS_ERRTYPE_INPUT | 2) +#define SRS_ENOSENDERATSIGN (SRS_ERRTYPE_INPUT | 1) +#define SRS_EBUFTOOSMALL (SRS_ERRTYPE_INPUT | 2) #define SRS_ENOSRS0HOST (SRS_ERRTYPE_SYNTAX | 1) #define SRS_ENOSRS0USER (SRS_ERRTYPE_SYNTAX | 2) @@ -58,69 +58,67 @@ #define SRS_EHASHTOOSHORT (SRS_ERRTYPE_SYNTAX | 9) #define SRS_ETIMESTAMPOUTOFDATE (SRS_ERRTYPE_SRS | 1) -#define SRS_EHASHINVALID (SRS_ERRTYPE_SRS | 2) +#define SRS_EHASHINVALID (SRS_ERRTYPE_SRS | 2) #define SRS_ERROR_TYPE(x) ((x) & SRS_ERRTYPE_MASK) /* SRS implementation */ -#define SRS_IS_SRS_ADDRESS(x) ( \ - (strncasecmp((x),"SRS",3) == 0) && \ - (strchr("01", (x)[3]) != NULL) && \ - (strchr("-+=", (x)[4]) != NULL) \ -) +#define SRS_IS_SRS_ADDRESS(x) \ + ((strncasecmp((x), "SRS", 3) == 0) && (strchr("01", (x)[3]) != NULL) \ + && (strchr("-+=", (x)[4]) != NULL)) typedef void *(*srs_malloc_t)(size_t); -typedef void *(*srs_realloc_t)(void *,size_t); +typedef void *(*srs_realloc_t)(void *, size_t); typedef void (*srs_free_t)(void *); typedef int srs_bool; typedef struct _srs_t { /* Rewriting parameters */ -// stralloc cookies; + // stralloc cookies; char **secrets; int numsecrets; char separator; /* Security parameters */ - int maxage; /* Maximum allowed age in seconds */ + int maxage; /* Maximum allowed age in seconds */ int hashlen; int hashmin; /* Behaviour parameters */ - srs_bool alwaysrewrite; /* Rewrite even into same domain? */ - srs_bool noforward; /* Never perform forwards rewriting */ - srs_bool noreverse; /* Never perform reverse rewriting */ - char **neverrewrite; /* A list of non-rewritten domains */ + srs_bool alwaysrewrite; /* Rewrite even into same domain? */ + srs_bool noforward; /* Never perform forwards rewriting */ + srs_bool noreverse; /* Never perform reverse rewriting */ + char **neverrewrite; /* A list of non-rewritten domains */ } srs_t; /* Interface */ -int srs_set_malloc(srs_malloc_t m,srs_realloc_t r,srs_free_t f); +int srs_set_malloc(srs_malloc_t m, srs_realloc_t r, srs_free_t f); srs_t *srs_new(); void srs_init(srs_t *); void srs_free(srs_t *); -int srs_forward(srs_t *,char *,int,const char *,const char *); -int srs_forward_alloc(srs_t *,char **,const char *,const char *); -int srs_reverse(srs_t *,char *,int, const char *); -int srs_reverse_alloc(srs_t *,char **,const char *); +int srs_forward(srs_t *, char *, int, const char *, const char *); +int srs_forward_alloc(srs_t *, char **, const char *, const char *); +int srs_reverse(srs_t *, char *, int, const char *); +int srs_reverse_alloc(srs_t *, char **, const char *); const char *srs_strerror(int); -int srs_add_secret(srs_t *,const char *); -const char * srs_get_secret(srs_t *,int); - /* You probably shouldn't call these. */ -int srs_timestamp_create(srs_t *,char *,time_t); -int srs_timestamp_check(srs_t *,const char *); - -#define SRS_PARAM_DECLARE(n, t) \ - int srs_set_ ## n (srs_t *srs, t value); \ - t srs_get_ ## n (srs_t *srs); - -SRS_PARAM_DECLARE(alwaysrewrite,srs_bool) -SRS_PARAM_DECLARE(separator,char) -SRS_PARAM_DECLARE(maxage,int) -SRS_PARAM_DECLARE(hashlen,int) -SRS_PARAM_DECLARE(hashmin,int) -SRS_PARAM_DECLARE(noforward,srs_bool) -SRS_PARAM_DECLARE(noreverse,srs_bool) - -#endif /* SRS2_H */ +int srs_add_secret(srs_t *, const char *); +const char *srs_get_secret(srs_t *, int); +/* You probably shouldn't call these. */ +int srs_timestamp_create(srs_t *, char *, time_t); +int srs_timestamp_check(srs_t *, const char *); + +#define SRS_PARAM_DECLARE(n, t) \ + int srs_set_##n(srs_t *srs, t value); \ + t srs_get_##n(srs_t *srs); + +SRS_PARAM_DECLARE(alwaysrewrite, srs_bool) +SRS_PARAM_DECLARE(separator, char) +SRS_PARAM_DECLARE(maxage, int) +SRS_PARAM_DECLARE(hashlen, int) +SRS_PARAM_DECLARE(hashmin, int) +SRS_PARAM_DECLARE(noforward, srs_bool) +SRS_PARAM_DECLARE(noreverse, srs_bool) + +#endif /* SRS2_H */ diff --git a/src/include/strset.h b/src/include/strset.h index 4a5703e..e3a2e88 100644 --- a/src/include/strset.h +++ b/src/include/strset.h @@ -3,27 +3,23 @@ #include "uint_t.h" -typedef struct strset_list -{ +typedef struct strset_list { uint32 h; int next; -} -strset_list; +} strset_list; -typedef struct -{ - int mask; /* mask + 1 is power of 2, size of hash table */ - int n; /* number of entries used in list and x */ - int a; /* number of entries allocated in list and x */ - int *first; /* first[h] is front of hash list h */ +typedef struct { + int mask; /* mask + 1 is power of 2, size of hash table */ + int n; /* number of entries used in list and x */ + int a; /* number of entries allocated in list and x */ + int *first; /* first[h] is front of hash list h */ strset_list *p; /* p[i].next is next; p[i].h is hash of x[i] */ - char **x; /* x[i] is entry i */ -} -strset; + char **x; /* x[i] is entry i */ +} strset; extern uint32 strset_hash(char *); extern int strset_init(strset *); -extern char *strset_in(strset *,char *); -extern int strset_add(strset *,char *); +extern char *strset_in(strset *, char *); +extern int strset_add(strset *, char *); #endif diff --git a/src/include/tls_remote.h b/src/include/tls_remote.h index c3c7933..7df0776 100644 --- a/src/include/tls_remote.h +++ b/src/include/tls_remote.h @@ -5,7 +5,7 @@ /* the version is like this: 0xMNNFFPPS: major minor fix patch status */ #if OPENSSL_VERSION_NUMBER < 0x00908000L -# error "Need OpenSSL version at least 0.9.8" + #error "Need OpenSSL version at least 0.9.8" #endif extern char *tlsdestinfo; @@ -16,17 +16,17 @@ extern stralloc ciphers; int tls_domaincerts(const stralloc); int tls_destination(const stralloc); -int tlsa_check(const STACK_OF(X509) *,const stralloc,const unsigned long); -int tls_fingerprint(X509 *,const char *,const int); -int tls_chainfile(SSL_CTX *,const char *); -int tls_certkey(SSL_CTX *,const char *,const char *,char *); -int tls_conn(SSL *,int); -int tls_setup(int,char *,char *); -int tls_checkpeer(SSL *,X509 *,const stralloc,const int,const int); +int tlsa_check(const STACK_OF(X509) *, const stralloc, const unsigned long); +int tls_fingerprint(X509 *, const char *, const int); +int tls_chainfile(SSL_CTX *, const char *); +int tls_certkey(SSL_CTX *, const char *, const char *, char *); +int tls_conn(SSL *, int); +int tls_setup(int, char *, char *); +int tls_checkpeer(SSL *, X509 *, const stralloc, const int, const int); int tls_checkcrl(SSL *); int tls_error(void); int tls_exit(SSL *); -int utf8string(unsigned char *,int); +int utf8string(unsigned char *, int); #endif diff --git a/src/include/token822.h b/src/include/token822.h index 42c909f..e1cef4a 100644 --- a/src/include/token822.h +++ b/src/include/token822.h @@ -9,9 +9,9 @@ struct token822 { int slen; }; -GEN_ALLOC_typedef(token822_alloc,struct token822,t,len,a) +GEN_ALLOC_typedef(token822_alloc, struct token822, t, len, a) -int token822_parse(); + int token822_parse(); int token822_addrlist(); int token822_unquote(); int token822_unparse(); @@ -21,16 +21,16 @@ int token822_ready(); int token822_readyplus(); int token822_append(); -#define TOKEN822_ATOM 1 -#define TOKEN822_QUOTE 2 +#define TOKEN822_ATOM 1 +#define TOKEN822_QUOTE 2 #define TOKEN822_LITERAL 3 #define TOKEN822_COMMENT 4 -#define TOKEN822_LEFT 5 -#define TOKEN822_RIGHT 6 -#define TOKEN822_AT 7 -#define TOKEN822_COMMA 8 -#define TOKEN822_SEMI 9 -#define TOKEN822_COLON 10 -#define TOKEN822_DOT 11 +#define TOKEN822_LEFT 5 +#define TOKEN822_RIGHT 6 +#define TOKEN822_AT 7 +#define TOKEN822_COMMA 8 +#define TOKEN822_SEMI 9 +#define TOKEN822_COLON 10 +#define TOKEN822_DOT 11 #endif diff --git a/src/include/ucspitls.h b/src/include/ucspitls.h index 40f8a81..f0505c7 100644 --- a/src/include/ucspitls.h +++ b/src/include/ucspitls.h @@ -1,45 +1,46 @@ #ifndef UCSPITLS_H #define UCSPITLS_H -#include -#include #include +#include +#include + #include "stralloc.h" -#define SSL_NAME_LEN 256 +#define SSL_NAME_LEN 256 #define OPENSSL_VERSION_NUMBER 0x101010100L #if (OPENSSL_VERSION_NUMBER < 0x10100000L) -#define ssl_client() (ssl_context(SSLv23_client_method())) -#define ssl_server() (ssl_context(SSLv23_server_method())) + #define ssl_client() (ssl_context(SSLv23_client_method())) + #define ssl_server() (ssl_context(SSLv23_server_method())) #else -#define ssl_client() (ssl_context(TLS_client_method())) -#define ssl_server() (ssl_context(TLS_server_method())) + #define ssl_client() (ssl_context(TLS_client_method())) + #define ssl_server() (ssl_context(TLS_server_method())) #endif extern int ssl_errno; -int ssl_io(SSL *,int,int,unsigned int); +int ssl_io(SSL *, int, int, unsigned int); SSL_CTX *ssl_context(SSL_METHOD *); -int ssl_timeoutconn(SSL *,unsigned int); -int ssl_timeoutaccept(SSL *,unsigned int); -SSL *ssl_new(SSL_CTX *,int); -int ssl_certkey(SSL_CTX *,const char *,const char *,pem_password_cb *); -int ssl_ca(SSL_CTX *,const char *,const char *,int); -int ssl_cca(SSL_CTX *,const char *); -int ssl_ciphers(SSL_CTX *,const char *); -int ssl_verify(SSL *,const char *); -int ssl_params(SSL_CTX *,const char *,int); -int ssl_server_env(SSL *,stralloc *); -int ssl_client_env(SSL *,stralloc *); +int ssl_timeoutconn(SSL *, unsigned int); +int ssl_timeoutaccept(SSL *, unsigned int); +SSL *ssl_new(SSL_CTX *, int); +int ssl_certkey(SSL_CTX *, const char *, const char *, pem_password_cb *); +int ssl_ca(SSL_CTX *, const char *, const char *, int); +int ssl_cca(SSL_CTX *, const char *); +int ssl_ciphers(SSL_CTX *, const char *); +int ssl_verify(SSL *, const char *); +int ssl_params(SSL_CTX *, const char *, int); +int ssl_server_env(SSL *, stralloc *); +int ssl_client_env(SSL *, stralloc *); char *ssl_error_str(int); -#define ssl_errstr() (SSL_load_error_strings()) -#define ssl_free(ssl) (SSL_free((ssl))) +#define ssl_errstr() (SSL_load_error_strings()) +#define ssl_free(ssl) (SSL_free((ssl))) #define ssl_close(ssl) (close(SSL_get_fd((ssl)))) -#define ssl_pending(ssl) (SSL_pending((ssl))) -#define ssl_shutdown(ssl) (SSL_shutdown((ssl))) +#define ssl_pending(ssl) (SSL_pending((ssl))) +#define ssl_shutdown(ssl) (SSL_shutdown((ssl))) #define ssl_shutdown_pending(ssl) (SSL_get_shutdown((ssl)) & SSL_RECEIVED_SHUTDOWN) -#define ssl_shutdown_sent(ssl) (SSL_get_shutdown((ssl)) & SSL_SENT_SHUTDOWN) +#define ssl_shutdown_sent(ssl) (SSL_get_shutdown((ssl)) & SSL_SENT_SHUTDOWN) #endif diff --git a/src/include/wildmat.h b/src/include/wildmat.h index 501b7e4..99b275b 100644 --- a/src/include/wildmat.h +++ b/src/include/wildmat.h @@ -1,6 +1,6 @@ #ifndef WILDMAT_H #define WILDMAT_H -extern int wildmat(char *,char *); +extern int wildmat(char *, char *); #endif -- cgit v1.2.3