Qsmtp  0.30dev
Functions
addrsyntax.c File Reference

check syntax of email addresses and SMTP helos More...

#include <qsmtpd/addrparse.h>
#include <qdns.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>

Functions

static int parselocalpart (const char *const addr)
 
static int parseaddr (const char *addr)
 
int checkaddr (const char *const addr)
 
int addrspec_valid (const char *const addr)
 
int addrsyntax (char *in, const int flags, string *addr, char **more)
 check an email address for syntax errors More...
 

Detailed Description

check syntax of email addresses and SMTP helos

Function Documentation

int addrspec_valid ( const char *const  addr)

check if the given string is a valid addr-spec

Parameters
addrstring to check
Returns
if string is valid addrspec
Return values
0string is invalid
1string is valid
int addrsyntax ( char *  in,
const int  flags,
string addr,
char **  more 
)

check an email address for syntax errors

Parameters
inaddress to parse
flags
  • 0: mail from checks,
  • 1: rcpt to checks (e.g. source route is allowed),
  • 2: checks for badmailfrom/goodmailfrom lists
addrstruct string to contain the address (memory will be malloced)
morehere starts the data behind the first '>' behind the first '<' (or NULL if none)
Returns
>0 on success
Return values
1address is empty (only possible if flags is 0)
3address is a full email address
4address is a full email address with IPv4 or IPv6 address literal
0in is invalid
-1an error occured (e.g. ENOMEM)
int checkaddr ( const char *const  addr)

check an email address for validity, use as loadlistfd callback

Parameters
addrthe address to check
Returns
if address valid
Return values
0address is valid
1address is invalid

This is just !parseaddr(addr). This allows this to be used as callback.

static int parseaddr ( const char *  addr)
static

check type and correctness of mail address

Parameters
addraddress to check
Returns
status code indicating what type of address was found
Return values
0address invalid
1address only contains a domain name
2address contains @domain
3address is a full email address
4address is a full email address with IPv4 or IPv6 address literal
static int parselocalpart ( const char *const  addr)
static

check syntax correctness of local part

Parameters
addraddress to check
Returns
-1 on syntax error, length of localpart otherwise. If no '@' in addr, length of addr
Return values
-1syntax error in localpart