smtp-client
SMTP Client C Library
|
Test the smtp-client library. More...
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
#include "../src/smtp.h"
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
Go to the source code of this file.
Functions | |
int | smtp_si_add_size_t (const size_t a, const size_t b, size_t *const result) |
int | smtp_si_sub_size_t (const size_t a, const size_t b, size_t *const result) |
int | smtp_si_mul_size_t (const size_t a, const size_t b, size_t *const result) |
size_t | smtp_base64_decode (const char *const buf, unsigned char **decode) |
char * | smtp_base64_encode (const char *const buf, size_t buflen) |
char * | smtp_bin2hex (const unsigned char *const s, size_t slen) |
enum smtp_status_code | smtp_write (struct smtp *const smtp, const char *const buf, size_t len) |
int | smtp_str_getdelimfd (struct str_getdelimfd *const gdfd) |
int | smtp_str_getdelimfd_set_line_and_buf (struct str_getdelimfd *const gdfd, size_t copy_len) |
void | smtp_str_getdelimfd_free (struct str_getdelimfd *const gdfd) |
char * | smtp_stpcpy (char *s1, const char *s2) |
void * | smtp_reallocarray (void *ptr, size_t nmemb, size_t size) |
char * | smtp_strdup (const char *s) |
char * | smtp_str_replace (const char *const search, const char *const replace, const char *const s) |
size_t | smtp_utf8_charlen (char c) |
int | smtp_str_has_nonascii_utf8 (const char *const s) |
size_t | smtp_strnlen_utf8 (const char *s, size_t maxlen) |
size_t | smtp_fold_whitespace_get_offset (const char *const s, unsigned int maxlen) |
char * | smtp_fold_whitespace (const char *const s, unsigned int maxlen) |
char * | smtp_chunk_split (const char *const s, size_t chunklen, const char *const end) |
char * | smtp_ffile_get_contents (FILE *stream, size_t *bytes_read) |
char * | smtp_file_get_contents (const char *const filename, size_t *bytes_read) |
int | smtp_parse_cmd_line (char *const line, struct smtp_command *const cmd) |
int | smtp_date_rfc_2822 (char *const date) |
int | smtp_address_validate_email (const char *const email) |
int | smtp_address_validate_name (const char *const name) |
int | smtp_attachment_validate_name (const char *const name) |
int | smtp_header_key_validate (const char *const key) |
int | smtp_header_value_validate (const char *const value) |
int | smtp_test_seam_dec_err_ctr (int *const test_err_ctr) |
BIO * | smtp_test_seam_bio_new_socket (int sock, int close_flag) |
int | smtp_test_seam_bio_should_retry (BIO *bio) |
void * | smtp_test_seam_calloc (size_t nelem, size_t elsize) |
int | smtp_test_seam_close (int fildes) |
int | smtp_test_seam_connect (int socket, const struct sockaddr *address, socklen_t address_len) |
unsigned long | smtp_test_seam_err_peek_error (void) |
int | smtp_test_seam_fclose (FILE *stream) |
int | smtp_test_seam_ferror (FILE *stream) |
struct tm * | smtp_test_seam_gmtime_r (const time_t *timep, struct tm *result) |
unsigned char * | smtp_test_seam_hmac (const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *d, size_t n, unsigned char *md, unsigned int *md_len) |
struct tm * | smtp_test_seam_localtime_r (const time_t *timep, struct tm *result) |
void * | smtp_test_seam_malloc (size_t size) |
time_t | smtp_test_seam_mktime (struct tm *timeptr) |
void * | smtp_test_seam_realloc (void *ptr, size_t size) |
long | smtp_test_seam_recv (int socket, void *buffer, size_t length, int flags) |
int | smtp_test_seam_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout) |
ssize_t | smtp_test_seam_send (int socket, const void *buffer, size_t length, int flags) |
int | smtp_test_seam_socket (int domain, int type, int protocol) |
int | smtp_test_seam_ssl_connect (SSL *ssl) |
SSL_CTX * | smtp_test_seam_ssl_ctx_new (const SSL_METHOD *method) |
int | smtp_test_seam_ssl_do_handshake (SSL *ssl) |
X509 * | smtp_test_seam_ssl_get_peer_certificate (const SSL *ssl) |
int | smtp_test_seam_x509_check_host (X509 *cert, const char *name, size_t namelen, unsigned int flags, char **peername) |
SSL * | smtp_test_seam_ssl_new (SSL_CTX *ctx) |
int | smtp_test_seam_ssl_read (SSL *ssl, void *buf, int num) |
int | smtp_test_seam_ssl_write (SSL *ssl, const void *buf, int num) |
int | smtp_test_seam_sprintf (char *s, const char *format,...) |
size_t | smtp_test_seam_strlen (const char *s) |
time_t | smtp_test_seam_time (time_t *tloc) |
Test the smtp-client library.
This smtp-client testing framework has 100% branch coverage on POSIX systems. It requires a Postfix SMTP server that supports all of the connection security and authentication methods. These functional tests also require the user to manually check and ensure that the destination addresses received all of the test emails.
This software has been placed into the public domain using CC0.
The test harnesses control most of the test seams through the use of global counter values.
Setting a global counter to -1 will make the test seam function operate as it normally would. If set to a positive value, the value will continue to decrement every time the function gets called. When the counter reaches 0, the test seam will force the function to return an error value.
For example, initially setting the counter to 0 will force the test seam to return an error condition the first time it gets called. Setting the value to 1 initially will force the test seam to return an error condition on the second time it gets called.
Definition in file test.h.
int smtp_address_validate_email | ( | const char *const | ) |
Validate characters in the email address.
The email address must consist only of printable characters excluding the angle brackets (<) and (>).
[in] | The email address of the party. |
0 | Successful validation. |
-1 | Failed to validate. |
Definition at line 2878 of file smtp.c.
References SMTP_LINKAGE.
Referenced by smtp_address_add(), and smtp_unit_test_all_smtp_address_validate_email().
int smtp_address_validate_name | ( | const char *const | name | ) |
Validate characters in the email name.
Email user name must consist only of printable characters, excluding the double quote character.
[in] | name | Email name to validate. |
0 | Successful validation. |
-1 | Failed to validate. |
Definition at line 2903 of file smtp.c.
References SMTP_LINKAGE.
Referenced by smtp_address_add(), and smtp_unit_test_all_smtp_address_validate_name().
int smtp_attachment_validate_name | ( | const char *const | name | ) |
Validate characters in the attachment file name.
Must consist only of printable characters or the space character ( ), and excluding the quote characters (') and (").
[in] | name | Filename of the attachment shown to recipients. |
0 | Successful validation. |
-1 | Failed to validate. |
Definition at line 2927 of file smtp.c.
Referenced by smtp_attachment_add_mem(), and smtp_unit_test_all_smtp_attachment_validate_name().
size_t smtp_base64_decode | ( | const char *const | buf, |
unsigned char ** | decode | ||
) |
Decode a base64 string.
The decode parameter will get dynamically allocated by this function if it successfully completes. Therefore, the caller must free the decode parameter after use.
[in] | buf | Null-terminated base64 string. |
[out] | decode | Pointer to buffer which will get dynamically allocated and will contain the decoded binary data. This parameter will get set to NULL if the memory allocation fails. |
>=0 | Length of the data stored in the decode parameter. |
-1 | Memory allocation failure or invalid base64 byte sequences. |
Definition at line 984 of file smtp.c.
References calloc, SIZE_MAX, smtp_base64_decode_block(), SMTP_LINKAGE, smtp_si_add_size_t(), and strlen.
Referenced by smtp_auth_cram_md5(), and smtp_unit_test_base64_decode().
char* smtp_base64_encode | ( | const char *const | buf, |
size_t | buflen | ||
) |
Encode binary data into a base64 string.
[in] | buf | Binary data to encode in base64. |
[in] | buflen | Number of bytes in the buf parameter, or -1 if null-terminated. |
char* | Dynamically allocated base64 encoded string. The caller must free this string when finished. |
NULL | Memory allocation failure. |
Definition at line 825 of file smtp.c.
References calloc, SIZE_MAX, smtp_base64_encode_block(), smtp_si_mul_size_t(), and strlen.
Referenced by smtp_attachment_add_mem(), smtp_auth_cram_md5(), smtp_auth_login(), smtp_auth_plain(), and smtp_unit_test_base64_encode().
char* smtp_bin2hex | ( | const unsigned char *const | s, |
size_t | slen | ||
) |
Convert binary data to lowercase hexadecimal representation.
[in] | s | Buffer containing binary data to convert. |
[in] | slen | Number of bytes in s . |
char* | Dynamically allocated string consisting of a hexadecimal representation of binary data in s . The caller must free this memory when finished. |
NULL | Memory allocation or encoding error. |
Definition at line 1031 of file smtp.c.
References malloc, SMTP_LINKAGE, smtp_si_add_size_t(), smtp_si_mul_size_t(), and sprintf.
Referenced by smtp_auth_cram_md5(), and smtp_unit_test_bin2hex().
char* smtp_chunk_split | ( | const char *const | s, |
size_t | chunklen, | ||
const char *const | end | ||
) |
Splits a string into smaller chunks separated by a terminating string.
[in] | s | The string to chunk. |
[in] | chunklen | Number of bytes for each chunk in the string. |
[in] | end | Terminating string placed at the end of each chunk. |
char* | Pointer to an allocated string with the contents split into separate chunks. The caller must free this memory when done. |
NULL | Memory allocation failure. |
Definition at line 1312 of file smtp.c.
References calloc, SIZE_MAX, SMTP_LINKAGE, smtp_si_add_size_t(), smtp_si_mul_size_t(), smtp_strdup(), smtp_strnlen_utf8(), and strlen.
Referenced by smtp_attachment_add_mem(), and smtp_unit_test_chunk_split().
int smtp_date_rfc_2822 | ( | char *const | date | ) |
Convert the time into an RFC 2822 formatted string.
Example date format: Thu, 21 May 1998 05:33:29 -0700
[out] | date | Buffer that has at least SMTP_DATE_MAX_SZ bytes. |
0 | Successfully copied the current date to the buffer. |
-1 | Failed to establish the current date or an output format error occurred. |
Definition at line 2236 of file smtp.c.
References gmtime_r, localtime_r, mktime, SMTP_DATE_MAX_SZ, sprintf, and time.
Referenced by smtp_mail(), and smtp_unit_test_date_rfc_2822().
char* smtp_ffile_get_contents | ( | FILE * | stream, |
size_t * | bytes_read | ||
) |
Read the entire contents of a file stream and store the data into a dynamically allocated buffer.
[in] | stream | File stream already opened by the caller. |
[out] | bytes_read | Number of bytes stored in the return buffer. |
char* | A dynamically allocated buffer which contains the entire contents of stream . The caller must free this memory when done. |
NULL | Memory allocation or file read error. |
Definition at line 1386 of file smtp.c.
References ferror, realloc, SMTP_LINKAGE, and smtp_si_add_size_t().
Referenced by smtp_attachment_add_fp(), and smtp_file_get_contents().
char* smtp_file_get_contents | ( | const char *const | filename, |
size_t * | bytes_read | ||
) |
Read the entire contents of a file from a given path, and store the data into a dynamically allocated buffer.
[in] | filename | Path of file to open and read from. |
[out] | bytes_read | Number of bytes stored in the return buffer. |
char* | A dynamically allocated buffer which has the contents of the file at filename . The caller must free this memory when done. |
NULL | Memory allocation or file read error. |
Definition at line 1439 of file smtp.c.
References fclose, smtp_ffile_get_contents(), and SMTP_LINKAGE.
Referenced by smtp_attachment_add_path(), smtp_test_config_load_from_file(), smtp_unit_test_all_file_get_contents(), and smtp_unit_test_file_get_contents().
char* smtp_fold_whitespace | ( | const char *const | s, |
unsigned int | maxlen | ||
) |
Fold a line at whitespace characters.
This function tries to keep the total number of characters per line under maxlen
, but does not guarantee this. For really long text with no whitespace, the line will still extend beyond maxlen
and possibly beyond the RFC limit as defined in SMTP_LINE_MAX. This is by design and intended to keep the algorithm simpler to implement. Users sending long headers with no space characters should not assume that will work, but modern email systems may correctly process those headers anyways.
Lines get folded by adding a [CR][LF] and then two space characters on the beginning of the next line. For example, this Subject line:
Subject: Email[WS][WS]Header
Would get folded like this (assuming a small maxlen
):
Subject: Email[WS][CR][LF] [WS][WS]Header
[in] | s | String to fold. |
[in] | maxlen | Number of bytes for each line in the string (soft limit). The minimum value of this parameter is 3 and it will get forced to 3 if the provided value is less. |
char* | Pointer to an allocated string with the contents split into separate lines. The caller must free this memory when done. |
NULL | Memory allocation failed. |
Definition at line 1250 of file smtp.c.
References realloc, smtp_fold_whitespace_get_offset(), SMTP_LINKAGE, smtp_si_add_size_t(), and strlen.
Referenced by smtp_print_header(), and smtp_unit_test_fold_whitespace().
size_t smtp_fold_whitespace_get_offset | ( | const char *const | s, |
unsigned int | maxlen | ||
) |
Get the offset of the next whitespace block to process folding.
If a string does not have whitespace before maxlen
, then the index will get returned past maxlen
. Also returns the index of NULL character if that fits within the next block. The caller must check for the NULL index to indicate the last block. It will skip past any leading whitespace even if that means going over maxlen.
Examples: smtp_fold_whitespace_get_offset ("Subject: Test WS", 1/2/8/9/10/13) -> 8 smtp_fold_whitespace_get_offset ("Subject: Test WS", 14/15) -> 13 smtp_fold_whitespace_get_offset ("Subject: Test WS", 17/18) -> 16
[in] | s | String to get offset from. |
[in] | maxlen | Number of bytes for each line in the string (soft limit). |
s
. Definition at line 1179 of file smtp.c.
Referenced by smtp_fold_whitespace(), and smtp_unit_test_fold_whitespace_get_offset().
int smtp_header_key_validate | ( | const char *const | key | ) |
Validate characters in the email header key.
Must consist only of printable US-ASCII characters except colon.
[in] | key | Header key to validate. |
0 | Successful validation. |
-1 | Failed to validate. |
Definition at line 2822 of file smtp.c.
References SMTP_LINKAGE, and strlen.
Referenced by smtp_header_add(), and smtp_unit_test_all_smtp_header_key_validate().
int smtp_header_value_validate | ( | const char *const | value | ) |
Validate characters in the email header contents.
Must consist only of printable character, space, or horizontal tab.
[in] | value | Header value to validate. |
0 | Successful validation. |
-1 | Failed to validate. |
Definition at line 2852 of file smtp.c.
References SMTP_LINKAGE.
Referenced by smtp_header_add(), and smtp_unit_test_all_smtp_header_value_validate().
int smtp_parse_cmd_line | ( | char *const | line, |
struct smtp_command *const | cmd | ||
) |
Parse a server response line into the smtp_command data structure.
[in] | line | Server response string. |
[out] | cmd | Structure containing the server response data broken up into its separate components. |
Definition at line 1467 of file smtp.c.
References smtp_command::code, smtp_command::more, SMTP_BEGIN_MAIL, SMTP_INTERNAL_ERROR, strlen, and smtp_command::text.
Referenced by smtp_auth_cram_md5(), smtp_read_and_parse_code(), and smtp_unit_test_parse_cmd_line().
void* smtp_reallocarray | ( | void * | ptr, |
size_t | nmemb, | ||
size_t | size | ||
) |
Reallocate memory with unsigned wrapping checks.
[in] | ptr | Existing allocation buffer, or NULL when allocating a new buffer. |
[in] | nmemb | Number of elements to allocate. |
[in] | size | Size of each element in nmemb . |
void* | Pointer to a reallocated buffer containing nmemb * size bytes. |
NULL | Failed to reallocate memory. |
Definition at line 622 of file smtp.c.
References realloc, SMTP_LINKAGE, and smtp_si_mul_size_t().
Referenced by smtp_address_add(), smtp_attachment_add_mem(), smtp_header_add(), and smtp_unit_test_reallocarray().
int smtp_si_add_size_t | ( | const size_t | a, |
const size_t | b, | ||
size_t *const | result | ||
) |
Check if adding a size_t value will cause a wrap.
[in] | a | Add this value with b . |
[in] | b | Add this value with a . |
[out] | result | Save the addition to this buffer. Does not perform the addition if set to NULL. |
1 | Value wrapped. |
0 | Value did not wrap. |
Definition at line 252 of file smtp.c.
References g_smtp_test_err_si_add_size_t_ctr, SIZE_MAX, SMTP_LINKAGE, and smtp_test_seam_dec_err_ctr().
Referenced by smtp_address_add(), smtp_append_address_to_header(), smtp_attachment_add_mem(), smtp_auth_cram_md5(), smtp_auth_login(), smtp_auth_plain(), smtp_base64_decode(), smtp_bin2hex(), smtp_chunk_split(), smtp_ffile_get_contents(), smtp_fold_whitespace(), smtp_header_add(), smtp_mail_envelope_header(), smtp_print_header(), smtp_print_mime_attachment(), smtp_print_mime_header_and_body(), smtp_puts_terminate(), smtp_str_getdelimfd(), smtp_str_getdelimfd_set_line_and_buf(), smtp_str_replace(), smtp_strdup(), and smtp_unit_test_all_si().
int smtp_si_mul_size_t | ( | const size_t | a, |
const size_t | b, | ||
size_t *const | result | ||
) |
Check if multiplying a size_t value will cause a wrap.
[in] | a | Multiply this value with b . |
[in] | b | Multiply this value with a . |
[out] | result | Save the multiplication to this buffer. Does not perform the multiplication if set to NULL. |
1 | Value wrapped. |
0 | Value did not wrap. |
Definition at line 320 of file smtp.c.
References g_smtp_test_err_si_mul_size_t_ctr, SIZE_MAX, and smtp_test_seam_dec_err_ctr().
Referenced by smtp_base64_encode(), smtp_bin2hex(), smtp_chunk_split(), smtp_reallocarray(), and smtp_unit_test_all_si().
int smtp_si_sub_size_t | ( | const size_t | a, |
const size_t | b, | ||
size_t *const | result | ||
) |
Check if subtracting a size_t value will cause wrap.
[in] | a | Subtract this value by b . |
[in] | b | Subtract this value from a . |
[out] | result | Save the subtraction to this buffer. Does not perform the subtraction if set to NULL. |
1 | Value wrapped. |
0 | Value did not wrap. |
Definition at line 286 of file smtp.c.
References g_smtp_test_err_si_sub_size_t_ctr, SMTP_LINKAGE, and smtp_test_seam_dec_err_ctr().
Referenced by smtp_str_getdelimfd(), smtp_str_getdelimfd_set_line_and_buf(), and smtp_unit_test_all_si().
char* smtp_stpcpy | ( | char * | s1, |
const char * | s2 | ||
) |
Copy a string and get the pointer to the end of the copied buffer.
This function behaves similar to POSIX stpcpy(), useful for concatenating multiple strings onto a buffer. It always adds a null-terminated byte at the end of the string.
[in] | s1 | Destination buffer. |
[in] | s2 | Null-terminated source string to copy to s1 . |
s1
after the last copied byte. Definition at line 599 of file smtp.c.
References SMTP_LINKAGE.
Referenced by smtp_append_address_to_header(), smtp_auth_cram_md5(), smtp_auth_login(), smtp_auth_plain(), smtp_mail_envelope_header(), smtp_print_header(), smtp_print_mime_attachment(), smtp_print_mime_end(), smtp_print_mime_header_and_body(), smtp_puts_terminate(), and smtp_unit_test_stpcpy().
int smtp_str_getdelimfd | ( | struct str_getdelimfd *const | gdfd | ) |
Read and parse a delimited string using a custom socket read function.
This interface handles all of the logic for expanding the buffer, parsing the delimiter in the buffer, and returning each "line" to the caller for handling.
[in] | gdfd | See str_getdelimfd. |
Definition at line 523 of file smtp.c.
References str_getdelimfd::_buf, str_getdelimfd::_buf_len, str_getdelimfd::_bufsz, str_getdelimfd::delim, str_getdelimfd::getdelimfd_read, realloc, SMTP_GETDELIM_READ_SZ, SMTP_LINKAGE, smtp_si_add_size_t(), smtp_si_sub_size_t(), smtp_str_getdelimfd_search_delim(), smtp_str_getdelimfd_set_line_and_buf(), smtp_str_getdelimfd_throw_error(), STRING_GETDELIMFD_DONE, STRING_GETDELIMFD_ERROR, and STRING_GETDELIMFD_NEXT.
Referenced by smtp_getline(), and smtp_unit_test_str_getdelimfd().
void smtp_str_getdelimfd_free | ( | struct str_getdelimfd *const | gdfd | ) |
Free memory in the str_getdelimfd data structure.
[in] | gdfd | Frees memory stored in this socket parsing structure. |
Definition at line 489 of file smtp.c.
References str_getdelimfd::_buf, str_getdelimfd::_buf_len, str_getdelimfd::_bufsz, str_getdelimfd::line, and str_getdelimfd::line_len.
Referenced by smtp_close(), smtp_str_getdelimfd_throw_error(), and smtp_unit_test_str_getdelimfd().
int smtp_str_getdelimfd_set_line_and_buf | ( | struct str_getdelimfd *const | gdfd, |
size_t | copy_len | ||
) |
Set the internal line buffer to the number of bytes specified.
[in] | gdfd | See str_getdelimfd. |
[in] | copy_len | Number of bytes to copy to the internal line buffer. |
0 | Successfully allocated and copied data over to the new line buffer. |
-1 | Failed to allocate memory for the new line buffer. |
Definition at line 457 of file smtp.c.
References str_getdelimfd::_buf, str_getdelimfd::_buf_len, calloc, str_getdelimfd::line, str_getdelimfd::line_len, SMTP_LINKAGE, smtp_si_add_size_t(), and smtp_si_sub_size_t().
Referenced by smtp_str_getdelimfd(), and smtp_unit_test_getdelimfd_set_line_and_buf().
int smtp_str_has_nonascii_utf8 | ( | const char *const | s | ) |
Check if a string contains non-ASCII UTF-8 characters.
Uses the simple algorithm from smtp_utf8_charlen to check for non-ASCII UTF-8 characters.
[in] | s | UTF-8 string. |
1 | String contains non-ASCII UTF-8 characters. |
0 | String contains only ASCII characters. |
Definition at line 1110 of file smtp.c.
References SMTP_LINKAGE, and smtp_utf8_charlen().
Referenced by smtp_mail_envelope_header(), and smtp_unit_test_all_smtp_str_has_nonascii_utf8().
char* smtp_str_replace | ( | const char *const | search, |
const char *const | replace, | ||
const char *const | s | ||
) |
Search for all substrings in a string and replace each instance with a replacement string.
[in] | search | Substring to search for in s . |
[in] | replace | Replace each instance of the search string with this. |
[in] | s | Null-terminated string to search and replace. |
char* | A dynamically allocated string with the replaced instances as described above. The caller must free the allocated memory when finished. |
NULL | Memory allocation failure. |
Definition at line 679 of file smtp.c.
References realloc, smtp_si_add_size_t(), smtp_strdup(), and strlen.
Referenced by smtp_print_email(), and smtp_unit_test_str_replace().
char* smtp_strdup | ( | const char * | s | ) |
Copy a string into a new dynamically allocated buffer.
Returns a dynamically allocated string, with the same contents as the input string. The caller must free the returned string when finished.
[in] | s | String to duplicate. |
char* | Pointer to a new dynamically allocated string duplicated from s . |
NULL | Failed to allocate memory for the new duplicate string. |
Definition at line 650 of file smtp.c.
References malloc, SMTP_LINKAGE, smtp_si_add_size_t(), and strlen.
Referenced by smtp_address_add(), smtp_attachment_add_mem(), smtp_chunk_split(), smtp_header_add(), smtp_puts_dbg(), smtp_str_repeat(), smtp_str_replace(), smtp_unit_test_parse_cmd_line(), and smtp_unit_test_strdup().
size_t smtp_strnlen_utf8 | ( | const char * | s, |
size_t | maxlen | ||
) |
Get the number of bytes in a UTF-8 string, or a shorter count if the string exceeds a maximum specified length.
See maxlen
for more information on multi-byte parsing.
[in] | s | Null-terminated UTF-8 string. |
[in] | maxlen | Do not check more than maxlen bytes of string s except if in the middle of a multi-byte character. |
strlen(s) | If length of s has less bytes than maxlen or the same number of bytes as maxlen. See maxlen for more details. |
maxlen | If length of s has more bytes than maxlen. |
-1 | If s contains an invalid UTF-8 byte sequence. |
Definition at line 1138 of file smtp.c.
References SIZE_MAX, SMTP_LINKAGE, and smtp_utf8_charlen().
Referenced by smtp_chunk_split(), and smtp_unit_test_strnlen_utf8().
BIO* smtp_test_seam_bio_new_socket | ( | int | sock, |
int | close_flag | ||
) |
Allows the test harness to control when BIO_new_socket() fails.
[in] | sock | Existing socket to attach the BIO to. |
[in] | close_flag | Close flag for new BIO. |
BIO* | New BIO created on existing socket. |
NULL | Failed to create the new BIO. |
Definition at line 263 of file seams.c.
References BIO_new_socket, g_smtp_test_err_bio_new_socket_ctr, and smtp_test_seam_dec_err_ctr().
int smtp_test_seam_bio_should_retry | ( | BIO * | bio | ) |
Allows the test harness to control when BIO_should_retry() fails.
[in] | bio | Existing BIO connection. |
0 | The error condition does not allow a retry. |
1 | The error condition allows a retry. |
Definition at line 279 of file seams.c.
References BIO_should_retry, g_smtp_test_err_bio_should_retry_ctr, g_smtp_test_err_bio_should_retry_rc, and smtp_test_seam_dec_err_ctr().
void* smtp_test_seam_calloc | ( | size_t | nelem, |
size_t | elsize | ||
) |
Allows the test harness to control when calloc() fails.
[in] | nelem | Number of elements to allocate. |
[in] | elsize | Size of each element to allocate. |
void* | Pointer to new allocated memory. |
NULL | Memory allocation failed. |
Definition at line 298 of file seams.c.
References calloc, g_smtp_test_err_calloc_ctr, and smtp_test_seam_dec_err_ctr().
int smtp_test_seam_close | ( | int | fildes | ) |
Allows the test harness to control when close() fails.
[in] | fildes | Socket file descriptor to close. |
0 | Successfully closed file descriptor. |
-1 | Failed to close file descriptor. |
Definition at line 315 of file seams.c.
References close, g_smtp_test_err_close_ctr, and smtp_test_seam_dec_err_ctr().
int smtp_test_seam_connect | ( | int | socket, |
const struct sockaddr * | address, | ||
socklen_t | address_len | ||
) |
Allows the test harness to control when connect() fails.
[in] | socket | Socket connection. |
[in] | address | Network address of peer. |
[in] | address_len | Number of bytes in address . |
0 | Successfully connected to the peer. |
-1 | Failed to connect to the peer. |
Definition at line 333 of file seams.c.
References connect, g_smtp_test_err_connect_ctr, and smtp_test_seam_dec_err_ctr().
int smtp_test_seam_dec_err_ctr | ( | int *const | test_err_ctr | ) |
Decrement an error counter until it reaches -1.
Once a counter reaches -1, it will return a successful response (1). This typically gets used to denote when to cause a function to fail. For example, the unit test or functional test might need to cause the realloc() function to fail after calling it the third time.
[in,out] | test_err_ctr | Integer counter to decrement. |
0 | The counter has been decremented, but did not reach -1 yet. |
1 | The counter has reached -1. |
Definition at line 244 of file seams.c.
Referenced by smtp_si_add_size_t(), smtp_si_mul_size_t(), smtp_si_sub_size_t(), smtp_test_seam_bio_new_socket(), smtp_test_seam_bio_should_retry(), smtp_test_seam_calloc(), smtp_test_seam_close(), smtp_test_seam_connect(), smtp_test_seam_err_peek_error(), smtp_test_seam_fclose(), smtp_test_seam_ferror(), smtp_test_seam_gmtime_r(), smtp_test_seam_hmac(), smtp_test_seam_localtime_r(), smtp_test_seam_malloc(), smtp_test_seam_mktime(), smtp_test_seam_realloc(), smtp_test_seam_recv(), smtp_test_seam_select(), smtp_test_seam_send(), smtp_test_seam_socket(), smtp_test_seam_sprintf(), smtp_test_seam_ssl_connect(), smtp_test_seam_ssl_ctx_new(), smtp_test_seam_ssl_do_handshake(), smtp_test_seam_ssl_get_peer_certificate(), smtp_test_seam_ssl_new(), smtp_test_seam_ssl_read(), smtp_test_seam_ssl_write(), and smtp_test_seam_x509_check_host().
unsigned long smtp_test_seam_err_peek_error | ( | void | ) |
Allows the test harness to control when ERR_peek_error() returns a failure code.
0 | No error code on the error queue. |
!0 | An error code exists on the error queue. |
Definition at line 351 of file seams.c.
References ERR_peek_error, g_smtp_test_err_err_peek_error_ctr, and smtp_test_seam_dec_err_ctr().
int smtp_test_seam_fclose | ( | FILE * | stream | ) |
Allows the test harness to control when fclose() fails.
[in] | stream | File stream to close. |
0 | Successfully closed the file stream. |
EOF | An error occurred while closing the file stream. |
Definition at line 365 of file seams.c.
References fclose, g_smtp_test_err_fclose_ctr, and smtp_test_seam_dec_err_ctr().
int smtp_test_seam_ferror | ( | FILE * | stream | ) |
Allows the test harness to control the file stream error indicator return value in ferror().
[in] | stream | Check for errors on this file stream. |
0 | No errors detected on the file stream. |
1 | An error occurred during a file stream operation. |
Definition at line 382 of file seams.c.
References ferror, g_smtp_test_err_ferror_ctr, and smtp_test_seam_dec_err_ctr().
struct tm* smtp_test_seam_gmtime_r | ( | const time_t * | timep, |
struct tm * | result | ||
) |
Allows the test harness to control when gmtime_r() fails.
[in] | timep | Time value to convert to a struct tm. |
[out] | result | Converts the timep value into a UTC tm structure value and stores the results in this pointer. |
tm* | time_t value converted to a tm structure value. |
NULL | An error occurred while converting the time. |
Definition at line 399 of file seams.c.
References g_smtp_test_err_gmtime_r_ctr, gmtime_r, and smtp_test_seam_dec_err_ctr().
unsigned char* smtp_test_seam_hmac | ( | const EVP_MD * | evp_md, |
const void * | key, | ||
int | key_len, | ||
const unsigned char * | d, | ||
size_t | n, | ||
unsigned char * | md, | ||
unsigned int * | md_len | ||
) |
Allows the test harness to control when HMAC() fails.
[in] | evp_md | Hash function. |
[in] | key | Hash key. |
[in] | key_len | Number of bytes in key . |
[in] | d | Message data. |
[in] | n | Number of bytes in d . |
[out] | md | The computed message authentication code. |
[in] | md_len | Number of bytes in md . |
uchar* | Pointer to md . |
NULL | An error occurred. |
Definition at line 421 of file seams.c.
References g_smtp_test_err_hmac_ctr, HMAC, and smtp_test_seam_dec_err_ctr().
struct tm* smtp_test_seam_localtime_r | ( | const time_t * | timep, |
struct tm * | result | ||
) |
Allows the test harness to control when localtime_r() fails.
[in] | timep | Time value to convert to a struct tm. |
[out] | result | Converts the timep value into a local time tm structure value and stores the results in this pointer. |
tm* | time_t value converted to a tm structure value. |
NULL | An error occurred while converting the time. |
Definition at line 444 of file seams.c.
References g_smtp_test_err_localtime_r_ctr, localtime_r, and smtp_test_seam_dec_err_ctr().
void* smtp_test_seam_malloc | ( | size_t | size | ) |
Allows the test harness to control when malloc() fails.
[in] | size | Number of bytes to allocate. |
void* | Pointer to new allocated memory. |
NULL | Memory allocation failed. |
Definition at line 460 of file seams.c.
References g_smtp_test_err_malloc_ctr, malloc, and smtp_test_seam_dec_err_ctr().
time_t smtp_test_seam_mktime | ( | struct tm * | timeptr | ) |
Allows the test harness to control when mktime() fails.
[in] | timeptr | tm data structure to convert to time_t. |
>=0 | Time since the epoch. |
-1 | Failed to convert the time. |
Definition at line 476 of file seams.c.
References g_smtp_test_err_mktime_ctr, mktime, and smtp_test_seam_dec_err_ctr().
void* smtp_test_seam_realloc | ( | void * | ptr, |
size_t | size | ||
) |
Allows the test harness to control when realloc() fails.
[in] | ptr | Previously allocated memory or NULL memory has not been allocated yet. |
[in] | size | Number of bytes to reallocate. |
void* | Pointer to new allocated memory. |
NULL | Memory allocation failed. |
Definition at line 493 of file seams.c.
References g_smtp_test_err_realloc_ctr, realloc, and smtp_test_seam_dec_err_ctr().
long smtp_test_seam_recv | ( | int | socket, |
void * | buffer, | ||
size_t | length, | ||
int | flags | ||
) |
Allows the test harness to control when recv() fails.
[in] | socket | TCP network socket. |
[in] | buffer | Store received data in this buffer. |
[in] | length | Number of bytes in buffer . |
[in] | flags | Set this to 0. |
>=0 | Number of bytes received. |
-1 | Failed to receive bytes over the network. |
Definition at line 513 of file seams.c.
References g_smtp_test_err_recv_bytes, g_smtp_test_err_recv_ctr, g_smtp_test_err_recv_rc, recv, smtp_test_seam_dec_err_ctr(), and strlen.
int smtp_test_seam_select | ( | int | nfds, |
fd_set * | readfds, | ||
fd_set * | writefds, | ||
fd_set * | errorfds, | ||
struct timeval * | timeout | ||
) |
Allows the test harness to control when select() fails.
[in] | nfds | Check for file descriptors in range 0 to (nfds - 1) which have any of the read/write/error conditions. |
[in] | readfds | Checks for file descriptors in fd_set that have bytes ready for reading. |
[in] | writefds | Checks for file descriptors in fd_set that have bytes ready for writing. |
[in] | errorfds | Checks for file descriptors in fd_set that have errors pending. |
[in] | timeout | Wait for the read/write/error conditions in blocking mode until this timeout or an interrupt occurs. |
>=0 | Number of bits set in the bitmask. |
-1 | An error occurred. |
Definition at line 552 of file seams.c.
References g_smtp_test_err_select_ctr, select, and smtp_test_seam_dec_err_ctr().
ssize_t smtp_test_seam_send | ( | int | socket, |
const void * | buffer, | ||
size_t | length, | ||
int | flags | ||
) |
Allows the test harness to control when send() fails.
[in] | socket | TCP network socket. |
[in] | buffer | Data to send over the network. |
[in] | length | Number of bytes in buffer . |
[in] | flags | Set this to 0. |
>=0 | Number of bytes sent. |
-1 | Failed to send bytes over the network. |
Definition at line 575 of file seams.c.
References g_smtp_test_err_send_ctr, g_smtp_test_send_one_byte, send, and smtp_test_seam_dec_err_ctr().
int smtp_test_seam_socket | ( | int | domain, |
int | type, | ||
int | protocol | ||
) |
Allows the test harness to control when socket() fails.
[in] | domain | Socket domain. |
[in] | type | Socket type. |
[in] | protocol | Socket protocol. |
!(-1) | The file descriptor for the new socket. |
-1 | Failed to create the socket. |
Definition at line 606 of file seams.c.
References g_smtp_test_err_socket_ctr, smtp_test_seam_dec_err_ctr(), and socket.
int smtp_test_seam_sprintf | ( | char * | s, |
const char * | format, | ||
... | |||
) |
Allows the test harness to control when sprintf() fails.
[in] | s | Buffer to store the output contents to. |
[in] | format | Format string defined in sprintf(). |
>=0 | Number of bytes copied to s , excluding the null-terminator. |
<0 | Output or formatting error. |
Definition at line 771 of file seams.c.
References g_smtp_test_err_sprintf_ctr, g_smtp_test_err_sprintf_rc, and smtp_test_seam_dec_err_ctr().
int smtp_test_seam_ssl_connect | ( | SSL * | ssl | ) |
Allows the test harness to control when SSL_connect() fails.
[in] | ssl | OpenSSL handle. |
1 | TLS connection handshake successful. |
<1 | TLS connection handshake failed. |
Definition at line 624 of file seams.c.
References g_smtp_test_err_ssl_connect_ctr, smtp_test_seam_dec_err_ctr(), and SSL_connect.
SSL_CTX* smtp_test_seam_ssl_ctx_new | ( | const SSL_METHOD * | method | ) |
Allows the test harness to control when SSL_CTX_new() fails.
[in] | method | TLS connection method. |
SSL_CTX* | Pointer to new TLS context. |
NULL | Failed to create new TLS context. |
Definition at line 639 of file seams.c.
References g_smtp_test_err_ssl_ctx_new_ctr, smtp_test_seam_dec_err_ctr(), and SSL_CTX_new.
int smtp_test_seam_ssl_do_handshake | ( | SSL * | ssl | ) |
Allows the test harness to control when SSL_do_handshake() fails.
[in] | ssl | OpenSSL handle. |
1 | TLS handshake successful. |
<1 | TLS handshake failed. |
Definition at line 654 of file seams.c.
References g_smtp_test_err_ssl_do_handshake_ctr, smtp_test_seam_dec_err_ctr(), and SSL_do_handshake.
X509* smtp_test_seam_ssl_get_peer_certificate | ( | const SSL * | ssl | ) |
Allows the test harness to control when SSL_get_peer_certificate() fails.
[in] | ssl | OpenSSL handle. |
X509* | Peer certficate which must get freed by using X509_free(). |
NULL | Failed to get the peer certificate. |
Definition at line 669 of file seams.c.
References g_smtp_test_err_ssl_get_peer_certificate_ctr, smtp_test_seam_dec_err_ctr(), and SSL_get_peer_certificate.
SSL* smtp_test_seam_ssl_new | ( | SSL_CTX * | ctx | ) |
Allows the test harness to control when SSL_new() fails.
[in] | ctx | OpenSSL TLS context. |
SSL* | Pointer to a new TLS context. |
NULL | Failed to create new TLS context. |
Definition at line 709 of file seams.c.
References g_smtp_test_err_ssl_new_ctr, smtp_test_seam_dec_err_ctr(), and SSL_new.
int smtp_test_seam_ssl_read | ( | SSL * | ssl, |
void * | buf, | ||
int | num | ||
) |
Allows the test harness to control when SSL_read() fails.
[in] | ssl | OpenSSL TLS object. |
[in] | buf | Store received data in this buffer. |
[in] | num | Number of bytes in buf . |
>0 | Number of bytes successfully read from the TLS connection. |
<=0 | Failed to read bytes on the TLS connection. |
Definition at line 726 of file seams.c.
References g_smtp_test_err_recv_bytes, g_smtp_test_err_ssl_read_ctr, smtp_test_seam_dec_err_ctr(), SSL_read, and strlen.
int smtp_test_seam_ssl_write | ( | SSL * | ssl, |
const void * | buf, | ||
int | num | ||
) |
Allows the test harness to control when SSL_write() fails.
[in] | ssl | OpenSSL TLS object. |
[in] | buf | Data to write to the TLS connection. |
[in] | num | Number of bytes in buf . |
>0 | Number of bytes successfully written to the TLS connection. |
<=0 | Failed to write bytes to the TLS connection. |
Definition at line 753 of file seams.c.
References g_smtp_test_err_ssl_write_ctr, smtp_test_seam_dec_err_ctr(), and SSL_write.
size_t smtp_test_seam_strlen | ( | const char * | s | ) |
Allows the test harness to control the return value of strlen().
[in] | s | Null-terminated string. |
s
. Definition at line 793 of file seams.c.
References g_smtp_test_strlen_custom_ret, g_smtp_test_strlen_ret_value, and strlen.
time_t smtp_test_seam_time | ( | time_t * | tloc | ) |
Allows the test harness to control when time() fails.
[out] | tloc | Buffer to hold the time_t results. |
>=0 | Time in seconds since the Epoch. |
-1 | Failed to store the time in tloc . |
Definition at line 813 of file seams.c.
References g_smtp_test_time_custom_ret, g_smtp_test_time_ret_value, and time.
int smtp_test_seam_x509_check_host | ( | X509 * | cert, |
const char * | name, | ||
size_t | namelen, | ||
unsigned int | flags, | ||
char ** | peername | ||
) |
Allows the test harness to control when X509_check_host() fails.
[in] | cert | X509 certificate handle. |
[in] | name | Server name. |
[in] | namelen | Number of characters in name or 0 if null-terminated. |
[in] | flags | Usually set to 0. |
[in] | peername | Pointer to CN from certificate stored in this buffer if not NULL. |
1 | Successful host check. |
0 | Failed host check. |
-1 | Internal error. |
Definition at line 690 of file seams.c.
References g_smtp_test_err_x509_check_host_ctr, smtp_test_seam_dec_err_ctr(), and X509_check_host.
size_t smtp_utf8_charlen | ( | char | c | ) |
Get the length in bytes of a UTF-8 character.
This consists of a very simple check and assumes the user provides a valid UTF-8 byte sequence. It gets the length from the first byte in the sequence and does not validate any other bytes in the character sequence or any other bits in the first byte of the character sequence.
[in] | c | The first byte in a valid UTF-8 character sequence. |
>0 | Number of bytes for the current UTF-8 character sequence. |
-1 | Invalid byte sequence. |
Definition at line 1078 of file smtp.c.
References SMTP_LINKAGE.
Referenced by smtp_str_has_nonascii_utf8(), smtp_strnlen_utf8(), and smtp_unit_test_all_smtp_utf8_charlen().
enum smtp_status_code smtp_write | ( | struct smtp *const | smtp, |
const char *const | buf, | ||
size_t | len | ||
) |
Send data to the SMTP server.
Writes a buffer of length len into either the unencrypted TCP socket or the TLS encrypted socket, depending on the current underlying mode of the socket.
[in] | smtp | SMTP client context. |
[in] | buf | Data to send to the SMTP server. |
[in] | len | Number of bytes in buf. |
Definition at line 1603 of file smtp.c.
References send, smtp_puts_dbg(), smtp_status_code_set(), SMTP_STATUS_SEND, smtp::sock, SSL_write, smtp::status_code, smtp::tls, and smtp::tls_on.
Referenced by smtp_puts(), and test_failure_misc().
int g_smtp_test_err_bio_new_socket_ctr |
Counter for smtp_test_seam_bio_new_socket.
See test_seams_countdown_global for more details.
See g_smtp_test_err_bio_new_socket_ctr and test_seams_countdown_global.
Definition at line 28 of file seams.c.
Referenced by smtp_test_seam_bio_new_socket(), and test_failure_open().
int g_smtp_test_err_bio_should_retry_ctr |
Counter for smtp_test_seam_bio_should_retry.
See test_seams_countdown_global for more details.
See g_smtp_test_err_bio_should_retry_ctr and test_seams_countdown_global.
Definition at line 34 of file seams.c.
Referenced by smtp_test_seam_bio_should_retry(), and test_failure_open().
int g_smtp_test_err_bio_should_retry_rc |
Value to force the BIO_should_retry() function to return.
This value will only get returned if g_smtp_test_err_bio_should_retry_ctr has a value of 0 and this does not have a value of -1.
See g_smtp_test_err_bio_should_retry_rc.
Definition at line 39 of file seams.c.
Referenced by smtp_test_seam_bio_should_retry(), and test_failure_open().
int g_smtp_test_err_calloc_ctr |
Counter for smtp_test_seam_calloc.
See test_seams_countdown_global for more details.
See g_smtp_test_err_calloc_ctr and test_seams_countdown_global.
Definition at line 44 of file seams.c.
Referenced by smtp_test_seam_calloc(), smtp_unit_test_all_base64_decode(), smtp_unit_test_all_base64_encode(), smtp_unit_test_all_chunk_split(), smtp_unit_test_all_str_getdelimfd(), test_failure_attachment_add(), test_failure_auth(), and test_failure_open().
int g_smtp_test_err_close_ctr |
Counter for smtp_test_seam_close.
See test_seams_countdown_global for more details.
See g_smtp_test_err_close_ctr and test_seams_countdown_global.
Definition at line 49 of file seams.c.
Referenced by smtp_test_seam_close(), and test_failure_close().
int g_smtp_test_err_connect_ctr |
Counter for smtp_test_seam_connect.
See test_seams_countdown_global for more details.
See g_smtp_test_err_connect_ctr and test_seams_countdown_global.
Definition at line 54 of file seams.c.
Referenced by smtp_test_seam_connect(), and test_failure_open().
int g_smtp_test_err_err_peek_error_ctr |
Counter for smtp_test_seam_err_peek_error.
See test_seams_countdown_global for more details.
See g_smtp_test_err_err_peek_error_ctr and test_seams_countdown_global.
Definition at line 60 of file seams.c.
Referenced by smtp_test_seam_err_peek_error(), and test_failure_open().
int g_smtp_test_err_fclose_ctr |
Counter for smtp_test_seam_fclose.
See test_seams_countdown_global for more details.
See g_smtp_test_err_fclose_ctr and test_seams_countdown_global.
Definition at line 65 of file seams.c.
Referenced by smtp_test_seam_fclose(), and smtp_unit_test_all_file_get_contents().
int g_smtp_test_err_ferror_ctr |
Counter for smtp_test_seam_ferror.
See test_seams_countdown_global for more details.
See g_smtp_test_err_ferror_ctr and test_seams_countdown_global.
Definition at line 70 of file seams.c.
Referenced by smtp_test_seam_ferror(), smtp_unit_test_all_file_get_contents(), and test_failure_attachment_add().
int g_smtp_test_err_gmtime_r_ctr |
Counter for smtp_test_seam_gmtime_r.
See test_seams_countdown_global for more details.
See g_smtp_test_err_gmtime_r_ctr test_seams_countdown_global.
Definition at line 75 of file seams.c.
Referenced by smtp_test_seam_gmtime_r(), and smtp_unit_test_all_date_rfc_2822().
int g_smtp_test_err_hmac_ctr |
Counter for smtp_test_seam_hmac.
See test_seams_countdown_global for more details.
See g_smtp_test_err_hmac_ctr test_seams_countdown_global.
Definition at line 80 of file seams.c.
Referenced by smtp_test_seam_hmac(), and test_failure_auth().
int g_smtp_test_err_localtime_r_ctr |
Counter for smtp_test_seam_localtime_r.
See test_seams_countdown_global for more details.
See g_smtp_test_err_localtime_r_ctr and test_seams_countdown_global.
Definition at line 86 of file seams.c.
Referenced by smtp_test_seam_localtime_r(), smtp_unit_test_all_date_rfc_2822(), and test_failure_mail().
int g_smtp_test_err_malloc_ctr |
Counter for smtp_test_seam_malloc.
See test_seams_countdown_global for more details.
See g_smtp_test_err_malloc_ctr and test_seams_countdown_global.
Definition at line 91 of file seams.c.
Referenced by smtp_test_seam_malloc(), smtp_unit_test_all_bin2hex(), smtp_unit_test_all_strdup(), test_failure_address_add(), test_failure_attachment_add(), test_failure_auth(), test_failure_header_add(), test_failure_mail(), and test_failure_misc().
int g_smtp_test_err_mktime_ctr |
Counter for smtp_test_seam_mktime.
See test_seams_countdown_global for more details.
See g_smtp_test_err_mktime_ctr and test_seams_countdown_global.
Definition at line 96 of file seams.c.
Referenced by smtp_test_seam_mktime(), and smtp_unit_test_all_date_rfc_2822().
int g_smtp_test_err_realloc_ctr |
Counter for smtp_test_seam_realloc.
See test_seams_countdown_global for more details.
See g_smtp_test_err_realloc_ctr and test_seams_countdown_global.
Definition at line 101 of file seams.c.
Referenced by smtp_test_seam_realloc(), smtp_unit_test_all_file_get_contents(), smtp_unit_test_all_fold_whitespace(), smtp_unit_test_all_reallocarray(), smtp_unit_test_all_str_getdelimfd(), smtp_unit_test_all_str_replace(), test_failure_address_add(), test_failure_attachment_add(), test_failure_header_add(), and test_failure_mail().
char g_smtp_test_err_recv_bytes[90] |
Set the received bytes in recv() and SSL_read() to this value if it contains a null-terminated string at least one bytes long.
This makes it easier to inject a bad server response for testing the smtp-client handling of those bad responses.
See test_seams_countdown_global for more details.
See g_smtp_test_err_recv_bytes and test_seams_countdown_global.
Definition at line 116 of file seams.c.
Referenced by smtp_test_seam_recv(), smtp_test_seam_ssl_read(), and test_failure_auth().
int g_smtp_test_err_recv_ctr |
Counter for smtp_test_seam_recv.
See test_seams_countdown_global for more details.
See g_smtp_test_err_recv_ctr and test_seams_countdown_global.
Definition at line 106 of file seams.c.
Referenced by smtp_test_seam_recv(), test_failure_auth(), test_failure_mail(), and test_failure_open().
int g_smtp_test_err_recv_rc |
Value to force the recv() function to return.
This value will only get returned if g_smtp_test_err_recv_ctr has a value of 0 and this does not have a value of -1.
Definition at line 111 of file seams.c.
Referenced by smtp_test_seam_recv(), and test_failure_open().
int g_smtp_test_err_select_ctr |
Counter for smtp_test_seam_select.
See test_seams_countdown_global for more details.
See g_smtp_test_err_select_ctr and test_seams_countdown_global.
Definition at line 121 of file seams.c.
Referenced by smtp_test_seam_select(), and test_failure_timeout().
int g_smtp_test_err_send_ctr |
Counter for smtp_test_seam_send.
See test_seams_countdown_global for more details.
See g_smtp_test_err_send_ctr and test_seams_countdown_global.
Definition at line 126 of file seams.c.
Referenced by smtp_test_seam_send(), test_failure_auth(), test_failure_close(), test_failure_mail(), and test_failure_open().
int g_smtp_test_err_si_add_size_t_ctr |
Counter for smtp_si_add_size_t.
See test_seams_countdown_global for more details.
See g_smtp_test_err_si_add_size_t_ctr and test_seams_countdown_global.
Definition at line 137 of file seams.c.
Referenced by smtp_si_add_size_t(), smtp_unit_test_all_base64_decode(), smtp_unit_test_all_bin2hex(), smtp_unit_test_all_chunk_split(), smtp_unit_test_all_file_get_contents(), smtp_unit_test_all_fold_whitespace(), smtp_unit_test_all_str_getdelimfd(), smtp_unit_test_all_str_replace(), test_failure_address_add(), test_failure_attachment_add(), test_failure_auth(), test_failure_header_add(), and test_failure_mail().
int g_smtp_test_err_si_mul_size_t_ctr |
Counter for smtp_si_mul_size_t.
See test_seams_countdown_global for more details.
See g_smtp_test_err_si_mul_size_t_ctr and test_seams_countdown_global.
Definition at line 149 of file seams.c.
Referenced by smtp_si_mul_size_t(), and smtp_unit_test_all_chunk_split().
int g_smtp_test_err_si_sub_size_t_ctr |
Counter for smtp_si_sub_size_t.
See test_seams_countdown_global for more details.
See g_smtp_test_err_si_sub_size_t_ctr and test_seams_countdown_global.
Definition at line 143 of file seams.c.
Referenced by smtp_si_sub_size_t(), and smtp_unit_test_all_str_getdelimfd().
int g_smtp_test_err_socket_ctr |
Counter for smtp_test_seam_socket.
See test_seams_countdown_global for more details.
See g_smtp_test_err_socket_ctr and test_seams_countdown_global.
Definition at line 154 of file seams.c.
Referenced by smtp_test_seam_socket(), and test_failure_open().
int g_smtp_test_err_sprintf_ctr |
Counter for smtp_test_seam_sprintf.
See test_seams_countdown_global for more details.
See g_smtp_test_err_sprintf_ctr and test_seams_countdown_global.
Definition at line 204 of file seams.c.
Referenced by smtp_test_seam_sprintf(), smtp_unit_test_all_bin2hex(), and smtp_unit_test_all_date_rfc_2822().
int g_smtp_test_err_sprintf_rc |
Value to force the sprintf() function to return.
This value will only get returned if g_smtp_test_err_sprintf_ctr has a value of 0.
See g_smtp_test_err_sprintf_rc.
Definition at line 209 of file seams.c.
Referenced by smtp_test_seam_sprintf(), smtp_unit_test_all_bin2hex(), and smtp_unit_test_all_date_rfc_2822().
int g_smtp_test_err_ssl_connect_ctr |
Counter for smtp_test_seam_ssl_connect.
See test_seams_countdown_global for more details.
See g_smtp_test_err_ssl_connect_ctr and test_seams_countdown_global.
Definition at line 160 of file seams.c.
Referenced by smtp_test_seam_ssl_connect(), and test_failure_open().
int g_smtp_test_err_ssl_ctx_new_ctr |
Counter for smtp_test_seam_ssl_ctx_new.
See test_seams_countdown_global for more details.
See g_smtp_test_err_ssl_ctx_new_ctr and test_seams_countdown_global.
Definition at line 166 of file seams.c.
Referenced by smtp_test_seam_ssl_ctx_new(), and test_failure_open().
int g_smtp_test_err_ssl_do_handshake_ctr |
Counter for smtp_test_seam_ssl_do_handshake.
See test_seams_countdown_global for more details.
See g_smtp_test_err_ssl_do_handshake_ctr and test_seams_countdown_global.
Definition at line 172 of file seams.c.
Referenced by smtp_test_seam_ssl_do_handshake(), and test_failure_open().
int g_smtp_test_err_ssl_get_peer_certificate_ctr |
Counter for smtp_test_seam_ssl_get_peer_certificate.
See test_seams_countdown_global for more details.
See g_smtp_test_err_ssl_get_peer_certificate_ctr and test_seams_countdown_global.
Definition at line 178 of file seams.c.
Referenced by smtp_test_seam_ssl_get_peer_certificate(), and test_failure_open().
int g_smtp_test_err_ssl_new_ctr |
Counter for smtp_test_seam_ssl_new.
See test_seams_countdown_global for more details.
See g_smtp_test_err_ssl_new_ctr and test_seams_countdown_global.
Definition at line 189 of file seams.c.
Referenced by smtp_test_seam_ssl_new(), and test_failure_open().
int g_smtp_test_err_ssl_read_ctr |
Counter for smtp_test_seam_ssl_read.
See test_seams_countdown_global for more details.
See g_smtp_test_err_ssl_read_ctr and test_seams_countdown_global.
Definition at line 194 of file seams.c.
Referenced by smtp_test_seam_ssl_read(), test_failure_auth(), test_failure_mail(), and test_failure_open().
int g_smtp_test_err_ssl_write_ctr |
Counter for smtp_test_seam_ssl_write.
See test_seams_countdown_global for more details.
See g_smtp_test_err_ssl_write_ctr and test_seams_countdown_global.
Definition at line 199 of file seams.c.
Referenced by smtp_test_seam_ssl_write(), test_failure_auth(), test_failure_close(), test_failure_mail(), and test_failure_open().
int g_smtp_test_err_x509_check_host_ctr |
Counter for smtp_test_seam_x509_check_host.
See test_seams_countdown_global for more details.
See g_smtp_test_err_x509_check_host_ctr and test_seams_countdown_global.
Definition at line 184 of file seams.c.
Referenced by smtp_test_seam_x509_check_host(), and test_failure_open().
int g_smtp_test_send_one_byte |
Indicate if we should only send one byte at a time.
See g_smtp_test_send_one_byte.
Definition at line 131 of file seams.c.
Referenced by smtp_func_test_all_write(), and smtp_test_seam_send().
int g_smtp_test_strlen_custom_ret |
Indicates if the strlen() function should return a test value.
This can get set to one of two values:
See g_smtp_test_strlen_custom_ret.
Definition at line 214 of file seams.c.
Referenced by smtp_test_seam_strlen(), smtp_unit_test_all_base64_encode(), smtp_unit_test_all_str_replace(), smtp_unit_test_all_strdup(), and test_failure_mail().
size_t g_smtp_test_strlen_ret_value |
Value to force the strlen() function to return.
This value will only get returned if g_smtp_test_strlen_custom_ret has been set.
See g_smtp_test_strlen_ret_value.
Definition at line 219 of file seams.c.
Referenced by smtp_test_seam_strlen(), smtp_unit_test_all_base64_encode(), smtp_unit_test_all_str_replace(), smtp_unit_test_all_strdup(), and test_failure_mail().
int g_smtp_test_time_custom_ret |
Indicates if the time() function should return a custom value.
This can get set to one of two values:
See g_smtp_test_time_custom_ret.
Definition at line 224 of file seams.c.
Referenced by smtp_test_seam_time(), and smtp_unit_test_date_rfc_2822().
time_t g_smtp_test_time_ret_value |
Value to force the time() function to return.
This value will only get returned if g_smtp_test_time_custom_ret has a positive value.
See g_smtp_test_time_ret_value.
Definition at line 229 of file seams.c.
Referenced by smtp_test_seam_time(), and smtp_unit_test_date_rfc_2822().