25 #define SMTP_INTERNAL_DEFINE 33 #define TMP_FILE_PATH "/tmp/test_smtp_file_get_contents.txt" 38 #define SMTP_TEST_SUBJECT_LEN 100 43 #define SMTP_TEST_BODY_LEN 1000 48 #define SMTP_MAX_SERVER_LEN 255 53 #define SMTP_MAX_CAFILE_PATH 255 58 #define SMTP_MAX_PORT_LEN 10 63 #define SMTP_MAX_EMAIL_LEN 255 68 #define SMTP_MAX_PASS_LEN 255 73 #define SMTP_MAX_ATTACHMENT_NAME_LEN 100 79 #define SMTP_TEST_DEFAULT_CONNECTION_SECURITY SMTP_SECURITY_NONE 85 #define SMTP_TEST_DEFAULT_AUTH_METHOD SMTP_AUTH_PLAIN 91 #define SMTP_TEST_DEFAULT_FLAGS (enum smtp_flag)( \ 98 #define SMTP_TEST_DEFAULT_CAFILE NULL 103 #define SMTP_TEST_DEFAULT_FROM_NAME "From Name" 108 #define SMTP_TEST_DEFAULT_TO_NAME "To Name" 113 #define SMTP_TEST_DEFAULT_CC_NAME "Cc Name" 118 #define SMTP_TEST_DEFAULT_BCC_NAME "Bcc Name" 123 #define STR_ALPHABET_LOWERCASE "abcdefghijklmnopqrstuvwxyz" 242 if(src_idx >= destsz - 1 || destsz == 0){
243 dest[src_idx] =
'\0';
247 dest[src_idx] = *src;
254 dest[src_idx] =
'\0';
274 newsz =
sizeof(*ns) * (n + 1);
303 if(n < 1 || slen < 1){
307 snewlen = slen * n + 1;
308 if((snew =
malloc(snewlen)) == NULL){
312 for(i = 0; i < n; i++){
313 memcpy(&snew[slen * i], s, slen);
315 snew[snewlen - 1] =
'\0';
355 sizeof(*slist->
slist) * (slist->
n + 1))) == NULL){
358 slist->
slist = slist_alloc;
363 slist->
slist[slist->
n] = snew;
377 for(i = 0; i < list->
n; i++){
378 free(list->
slist[i]);
405 const char *
const delimiter,
411 size_t delimiter_len;
414 memset(slist, 0,
sizeof(*slist));
415 delimiter_len =
strlen(delimiter);
424 for(i2 = 0; i2 < slen; i2++){
425 if(limit > 0 && limit - 1 <= split_idx){
432 else if(strncmp(&s[i2], delimiter, delimiter_len) == 0){
433 if(i2 - i1 == 0 && s[i2] ==
'\0'){
440 i1 = i2 + delimiter_len;
442 if(strncmp(&s[i2], delimiter, delimiter_len) == 0){
455 for(i = 0; i < (size_t)abs(limit); i++){
456 free(slist->
slist[slist->
n - i - 1]);
475 const void *
const data,
477 size_t bytes_written;
482 bytes_written =
strlen(data);
483 if(fputs(data, stream) == EOF){
488 bytes_written = fwrite(data, 1, datasz, stream);
491 return bytes_written;
513 const void *
const data,
517 size_t bytes_written;
523 else if(flags == O_APPEND){
531 if((fp = fopen(filename, mode)) == NULL){
541 return bytes_written;
554 fprintf(stderr,
"TEST FRAMEWORK: sleeping for %u seconds\n", seconds);
555 assert(sleep(seconds) == 0);
572 size_t *
const result),
576 size_t expect_result,
580 wraps = si_fp(a, b, result);
581 assert(wraps == expect_wrap);
583 assert(*result == expect_result);
647 const char *
const expect_str,
648 size_t expect_str_len){
649 unsigned char *decode;
654 assert(memcmp(decode, expect_str, str_len) == 0);
658 assert(decode == NULL);
660 assert(str_len == expect_str_len);
705 const char *
const expect){
710 assert(strcmp(result, expect) == 0);
714 assert(result == expect);
732 "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=");
761 const char *
const expect){
764 result =
smtp_bin2hex((
const unsigned char *
const)s, slen);
766 assert(strcmp(result, expect) == 0);
769 assert(result == expect);
789 "6162636465666768696a6b6c6d6e6f707172737475767778797a");
825 const char *
const s2,
826 const char *
const expect){
837 endptr = buf +
strlen(init);
840 expect_ptr = buf + bufsz - 1;
841 assert(endptr == expect_ptr);
842 assert(*endptr ==
'\0');
843 assert(strcmp(buf, expect) == 0);
887 assert(result == NULL);
917 const char *
const expect){
922 assert(strcmp(result, expect) == 0);
926 assert(result == expect);
962 const char *
const replace,
964 const char *
const expect){
969 assert(strcmp(result, expect) == 0);
973 assert(result == expect);
1005 for(i = 0; i < 10; i++){
1029 const char *utf8_str;
1069 assert(slen == expect);
1125 unsigned int maxlen,
1130 assert(result == expect);
1254 unsigned int maxlen,
1255 const char *
const expect){
1260 assert(result == expect);
1263 assert(strcmp(result, expect) == 0);
1294 "Subject: Email\r\n" 1298 "Subject: Email\r\n" 1302 "Subject: Email\r\n" 1306 "Subject: Email Test");
1313 " Email Subject\r\n" 1320 for(i = 0; i < 3; i++){
1348 const char *
const end,
1349 const char *
const expect){
1354 assert(result == expect);
1357 assert(strcmp(result, expect) == 0);
1381 "abc-def-ghi-jkl-mno-p-");
1386 "abc-!def-!ghi-!jkl-!mno-!p-!");
1391 "abcdefghij\r\nklmnopqrst\r\nuvwxyz\r\n");
1413 for(i = 0; i < 3; i++){
1439 const char *
const expect){
1444 assert(nbytes_rw ==
strlen(expect));
1449 assert(memcmp(expect, read_buf,
strlen(expect)) == 0);
1458 const char *test_str;
1466 test_str =
"test\nnewline";
1512 const char *
const expect_text){
1521 assert(rc == expect_code);
1522 assert(cmd.
code == expect_code);
1523 assert(cmd.
more == expect_more);
1524 assert(strcmp(cmd.
text, expect_text) == 0);
1573 const char *
const expect,
1581 setenv(
"TZ",
"UTC", 1);
1583 assert(rc == expect_rc);
1585 assert(strcmp(result, expect) == 0);
1599 "Sat, 03 Jan 1970 00:00:05 +0000",
1703 const char *
const expect){
1707 assert(strcmp(result, expect) == 0);
1718 "Memory allocation failed");
1759 bytes_read = fread(buf,
sizeof(
char), count, getdelimfd_fp->
fp);
1760 if(g_smtp_test_getdelimfd_fp_fail){
1763 return (
long)bytes_read;
1783 const char *expect_pieces, ...){
1786 size_t bytes_written;
1794 memset(&slist, 0,
sizeof(slist));
1800 assert(bytes_written == nbytes);
1802 memset(&getdelimfd_fp, 0,
sizeof(getdelimfd_fp));
1805 getdelimfd_fp.
fp = fp;
1807 memset(&gdfd, 0,
sizeof(gdfd));
1817 assert(rc == expect_rc);
1828 piece = expect_pieces;
1829 va_start(ap, expect_pieces);
1831 assert(strcmp(piece, slist.
slist[piece_idx]) == 0);
1833 piece = va_arg(ap,
const char *);
1836 assert(piece_idx == slist.
n);
1856 assert(result == expect_result);
1866 char test_str[] =
"test";
1926 s =
"test line 1\n";
1936 s =
"test line 1\ntest line 2";
1946 s =
"test line 1\ntest line 2\ntest line 3";
1991 g_smtp_test_getdelimfd_fp_fail = 1;
1999 g_smtp_test_getdelimfd_fp_fail = 0;
2015 for(i = 0; i < 5; i++){
2027 memset(&gdfd, 0,
sizeof(gdfd));
2028 gdfd.
_buf = test_str;
2084 char *config_data_new;
2085 size_t config_data_len;
2096 &config_data_len)) == NULL){
2101 if((config_data_new =
realloc(config_data, config_data_len + 1)) == NULL){
2105 config_data = config_data_new;
2106 config_data[config_data_len] =
'\0';
2108 rc =
smtp_str_split(config_data, config_data_len,
"\n", 0, &line_list);
2112 for(i = 0; i < line_list.
n; i++){
2113 line = line_list.
slist[i];
2117 key = strtok(line,
"=");
2122 value = strtok(NULL,
"=");
2127 if(strcmp(key,
"server") == 0){
2130 else if(strcmp(key,
"cafile") == 0){
2133 else if(strcmp(key,
"port") == 0){
2136 else if(strcmp(key,
"port_tls") == 0){
2139 else if(strcmp(key,
"user") == 0){
2142 else if(strcmp(key,
"pass") == 0){
2145 else if(strcmp(key,
"email_from") == 0){
2148 else if(strcmp(key,
"email_to") == 0){
2151 else if(strcmp(key,
"email_to_2") == 0){
2154 else if(strcmp(key,
"email_to_3") == 0){
2173 const char *
const user,
2174 const char *
const pass,
2177 assert(
g_rc == expect_status);
2190 const char *
const email,
2191 const char *
const name,
2194 assert(
g_rc == expect_status);
2206 const char *
const value,
2209 assert(
g_rc == expect_status);
2222 assert(
g_rc == expect_status);
2233 assert(
g_rc == expect_status);
2318 const char *
const cafile,
2320 const char *
const body){
2323 connection_security,
2358 const char *
const security_description){
2360 "SMTP Test: Connection Security %s",
2361 security_description);
2363 "Email sent with connection security: %s",
2364 security_description);
2403 "SMTP Test: cafile",
2415 const char *
const auth_description){
2417 "SMTP Test: AUTH %s",
2420 "Email authenticated using %s",
2454 const char *
const path,
2457 strcpy(
g_config.
body,
"This email should contain a pdf attachment");
2483 assert(
g_rc == expect_rc);
2502 const char *
const path,
2508 strcpy(
g_config.
body,
"This email should contain a pdf attachment");
2510 fp = fopen(path,
"r");
2532 assert(
g_rc == expect_rc);
2553 char attachment_data[100];
2556 "SMTP Test: Attachments (%u)",
2557 (
unsigned)num_attachment);
2559 "You should have %u attachments in this email. " 2560 "Each attachment should contain the text " 2561 "\"Attachment# <number>\"",
2562 (
unsigned)num_attachment);
2587 for(i = 0; i < num_attachment; i++){
2588 sprintf(attachment_name,
"%u.txt", (
unsigned)(i + 1));
2589 sprintf(attachment_data,
"Attachment# %u", (
unsigned)(i + 1));
2615 "SMTP Test: PDF Attachments (%u)",
2616 (
unsigned)num_attachments);
2618 "You should have %u PDF attachments in this email. " 2619 "Each attachment should contain the text " 2620 "\"SMTP TEST PDF ATTACHMENT\"",
2621 (
unsigned)num_attachments);
2641 for(i = 0; i < num_attachments; i++){
2642 sprintf(attachment_name,
"test-%u.pdf", (
unsigned)(i + 1));
2687 "alphabet-repeat.txt",
2694 "SMTP Test: Long Text Attachment",
2773 "SMTP Test: Multiple TO Addresses",
2794 "SMTP Test: BCC Address",
2811 "SMTP Test: TO and BCC Addresses",
2825 smtp_mail_check(
"This email should contain one TO and one BCC recipient.",
2832 "SMTP Test: TO, CC, and BCC Addresses",
2850 smtp_mail_check(
"This email should contain one TO, CC, and BCC recipient.",
2857 "SMTP Test: No FROM address",
2863 smtp_mail_check(
"This email should not have a FROM address in the header.",
2871 "SMTP Test: From contains UTF-8 characters",
2874 "smtp-cli€nt-t€st@somnisoft.com",
2884 smtp_mail_check(
"This email should contain a FROM address with UTF-8.",
2910 "SMTP Test: Null From Name and Blank To Name",
2927 "SMTP Test: Two To Names",
2941 smtp_mail_check(
"This email should have two addresses with different names.",
2948 "SMTP Test: Three To Names",
2966 smtp_mail_check(
"This email should have three addresses with different names.",
2975 "SMTP Test: Long Email Names",
2995 "SMTP Test: Very Long Email Names",
3006 "repeated 100 times.",
3032 "SMTP Test: Custom Date",
3036 "Thu, 21 May 1998 05:33:29 -0700",
3073 "SMTP Test: Null Header (No Date)",
3130 " Subject and Custom headers.",
3162 "SMTP Test: Very Long Email Body",
3218 "SMTP Test: No Debug Mode",
3242 const char *
const html_body =
3244 " <head><title>HTML Email Example</title></head>\n" 3246 " <table style='border: 1px solid black; background-color: #a0a0a0'>\n" 3247 " <caption>smtp_connection_security</caption>\n" 3250 " <th>Description</th>\n" 3253 " <td>SMTP_SECURITY_STARTTLS</td>\n" 3254 " <td>Use STARTTLS</td>\n" 3257 " <td>SMTP_SECURITY_TLS</td>\n" 3258 " <td>Direct TLS connection</td>\n" 3261 " <td>SMTP_SECURITY_NONE</td>\n" 3262 " <td>No encryption</td>\n" 3279 "SMTP Test: HTML Email (Content-Type: text/html)",
3304 const char *
const html_body =
3305 "This is a multi-part message in MIME format.\r\n" 3313 "This is a multi-part message in MIME format.\r\n" 3315 "Content-Type: text/plain; charset=\"utf-8\"\r\n" 3316 "Content-Transfer-Encoding: 8bit\r\n" 3318 "Plaintext section.\r\n" 3321 "Content-Type: text/html; charset=\"utf-8\"\r\n" 3322 "Content-Transfer-Encoding: 8bit\r\n" 3325 " <head><title>HTML/Plaintext Email</title></head>\n" 3327 " <h1>HTML section</h1>\n" 3328 " <h2>Heading 2</h2>\n" 3347 "SMTP Test: HTML Email (with plaintext)",
3351 "multipart/alternative; boundary=\"ABCDEF\"",
3550 "test/config/file_does_not_exist",
3875 fp = fopen(
"COPYING",
"r");
4797 const char *
const server =
"smtpout.secureserver.net";
4801 unsigned int connection_i;
4804 for(connection_i = 0; connection_i < 2; connection_i++){
4805 if(connection_i == 0){
4813 for(i = 0; i < 4; i++){
4814 fprintf(stderr,
"%s: %s: %u\n", server, port, i + 1);
4836 const char *
const name =
"test.pdf";
4837 const char *
const path =
"test/test.pdf";
4840 strcpy(
g_config.
body,
"This email should contain a pdf attachment");
4888 fprintf(stderr,
"SMTP TEST: sending test email using gmail account");
4895 "test email sent through gmail server");
4946 memset(&smtp_test, 0,
sizeof(smtp_test));
4948 while((c = getopt(argc, argv,
"u")) != -1){
SMTP_LINKAGE size_t smtp_strnlen_utf8(const char *s, size_t maxlen)
static void smtp_func_test_all_cafile(void)
int g_smtp_test_err_fclose_ctr
enum smtp_status_code smtp_close(struct smtp *smtp)
static void smtp_unit_test_all_str_getdelimfd(void)
const char * smtp_status_code_errstr(enum smtp_status_code status_code)
int g_smtp_test_err_ssl_read_ctr
enum smtp_status_code smtp_status_code_set(struct smtp *const smtp, enum smtp_status_code new_status_code)
static void smtp_unit_test_base64_encode(const char *const buf, size_t buflen, const char *const expect)
static char * smtp_str_repeat(const char *const s, size_t n)
enum smtp_status_code smtp_attachment_add_mem(struct smtp *const smtp, const char *const name, const void *const data, size_t datasz)
static void smtp_func_test_auth(enum smtp_authentication_method auth_method, const char *const auth_description)
static void smtp_unit_test_all_date_rfc_2822(void)
int g_smtp_test_err_err_peek_error_ctr
static int smtp_str_split(const char *const s, size_t slen, const char *const delimiter, int limit, struct smtp_str_list *slist)
int g_smtp_test_err_recv_rc
static void smtp_func_test_all_address(void)
static void smtp_func_test_all_attachments_path(void)
static long smtp_unit_test_getdelimfd_fp(struct str_getdelimfd *const gdfd, void *buf, size_t count)
static void test_failure_attachment_add(void)
enum smtp_result_code code
char cafile[SMTP_MAX_CAFILE_PATH]
static void smtp_func_test_attachment_mem(size_t num_attachment)
SMTP_LINKAGE int smtp_parse_cmd_line(char *const line, struct smtp_command *const cmd)
static void smtp_unit_test_all_chunk_split(void)
SMTP_LINKAGE char * smtp_bin2hex(const unsigned char *const s, size_t slen)
static void test_failure_header_add(void)
static void test_failure_auth(void)
static void smtp_func_test_connection_security(const char *const server_port, enum smtp_connection_security con_security, const char *const security_description)
#define SMTP_MAX_SERVER_LEN
static void smtp_func_test_all_html(void)
enum smtp_status_code smtp_header_add(struct smtp *const smtp, const char *const key, const char *const value)
static void smtp_unit_test_all_smtp_address_validate_name(void)
static void smtp_unit_test_all(void)
SMTP_LINKAGE void * smtp_reallocarray(void *ptr, size_t nmemb, size_t size)
char server[SMTP_MAX_SERVER_LEN]
static enum smtp_status_code g_rc
static void smtp_unit_test_stpcpy(const char *const init, const char *const s2, const char *const expect)
static void smtp_unit_test_all_smtp_header_key_validate(void)
Test the smtp-client library.
char port_tls[SMTP_MAX_PORT_LEN]
enum smtp_status_code smtp_mail(struct smtp *const smtp, const char *const body)
#define SMTP_TEST_DEFAULT_CONNECTION_SECURITY
SMTP_LINKAGE enum smtp_status_code smtp_write(struct smtp *const smtp, const char *const buf, size_t len)
SMTP_LINKAGE char * smtp_file_get_contents(const char *const filename, size_t *bytes_read)
static void smtp_unit_test_fold_whitespace(const char *const s, unsigned int maxlen, const char *const expect)
static void smtp_func_test_all_body(void)
SMTP_LINKAGE int smtp_header_key_validate(const char *const key)
static void smtp_unit_test_date_rfc_2822(time_t t, const char *const expect, int expect_rc)
static void smtp_unit_test_all_file_get_contents(void)
int g_smtp_test_err_close_ctr
enum smtp_status_code smtp_attachment_add_path(struct smtp *const smtp, const char *const name, const char *const path)
int g_smtp_test_err_ssl_ctx_new_ctr
static void smtp_func_test_all_auth_methods(void)
char port[SMTP_MAX_PORT_LEN]
static void test_failure_mail(void)
static void smtp_mail_check(const char *const body, const enum smtp_status_code expect_status)
static void smtp_unit_test_chunk_split(const char *const s, size_t chunklen, const char *const end, const char *const expect)
static char * smtp_strndup(const char *s, size_t n)
char email_to_3[SMTP_MAX_EMAIL_LEN]
int g_smtp_test_err_hmac_ctr
SMTP_LINKAGE void smtp_str_getdelimfd_free(struct str_getdelimfd *const gdfd)
int g_smtp_test_err_ssl_new_ctr
static void smtp_unit_test_smtp_status_code_errstr(enum smtp_status_code status_code, const char *const expect)
static void smtp_close_check(const enum smtp_status_code expect_status)
int g_smtp_test_err_mktime_ctr
static size_t smtp_strlcpy(char *dest, const char *src, size_t destsz)
char user[SMTP_MAX_EMAIL_LEN]
#define SMTP_TEST_DEFAULT_TO_NAME
#define SMTP_MAX_CAFILE_PATH
#define SMTP_MAX_ATTACHMENT_NAME_LEN
int g_smtp_test_err_localtime_r_ctr
int g_smtp_test_err_ssl_connect_ctr
static void smtp_func_test_header_custom_date(void)
static void smtp_unit_test_all_smtp_status_code_errstr(void)
static void smtp_auth_check(const enum smtp_authentication_method auth_method, const char *const user, const char *const pass, const enum smtp_status_code expect_status)
static struct smtp_test_config g_config
static void smtp_test_sleep(unsigned int seconds)
int g_smtp_test_strlen_custom_ret
char pass[SMTP_MAX_PASS_LEN]
static void smtp_unit_test_strnlen_utf8(const char *s, size_t maxlen, size_t expect)
char email_from[SMTP_MAX_EMAIL_LEN]
int g_smtp_test_err_ssl_get_peer_certificate_ctr
static void smtp_unit_test_all_reallocarray(void)
int g_smtp_test_err_recv_ctr
static void smtp_unit_test_all_strdup(void)
static void test_failure_timeout(void)
static void smtp_unit_test_file_get_contents(const char *const s, size_t nbytes, const char *const expect)
static void smtp_unit_test_all_base64_encode(void)
void smtp_header_clear_all(struct smtp *const smtp)
SMTP_LINKAGE int smtp_address_validate_name(const char *const name)
static void smtp_unit_test_all_base64_decode(void)
static void smtp_unit_test_all_stpcpy(void)
SMTP_LINKAGE int smtp_address_validate_email(const char *const email)
static void smtp_func_test_server_gmail(void)
static void smtp_unit_test_all_smtp_attachment_validate_name(void)
int g_smtp_test_err_realloc_ctr
int g_smtp_test_err_x509_check_host_ctr
static size_t smtp_file_put_contents(const char *const filename, const void *const data, size_t datasz, int flags)
int g_smtp_test_err_ssl_write_ctr
SMTP_LINKAGE char * smtp_base64_encode(const char *const buf, size_t buflen)
static void test_failure_close(void)
int g_smtp_test_err_sprintf_ctr
static void smtp_unit_test_reallocarray(void *ptr, size_t nmemb, size_t size, int expect_alloc)
int g_smtp_test_err_si_sub_size_t_ctr
static void smtp_func_test_server_postfix(void)
enum smtp_status_code smtp_status_code_clear(struct smtp *const smtp)
static void smtp_str_list_free(struct smtp_str_list *const list)
void smtp_address_clear_all(struct smtp *const smtp)
#define SMTP_TEST_DEFAULT_FLAGS
static void smtp_func_test_header_null_no_date(void)
static void test_smtp_open_default(void)
#define SMTP_TEST_DEFAULT_CAFILE
#define SMTP_TEST_SUBJECT_LEN
#define SMTP_MAX_PASS_LEN
#define SMTP_TEST_BODY_LEN
static int g_smtp_test_getdelimfd_fp_fail
static void smtp_unit_test_all_fold_whitespace(void)
static void smtp_unit_test_all_smtp_address_validate_email(void)
int g_smtp_test_err_bio_should_retry_rc
static void test_failure_open(void)
int g_smtp_test_err_ferror_ctr
static void smtp_unit_test_all_strnlen_utf8(void)
smtp_authentication_method
SMTP_LINKAGE int smtp_date_rfc_2822(char *const date)
SMTP_LINKAGE int smtp_str_has_nonascii_utf8(const char *const s)
static void smtp_unit_test_si_size_t(int(*si_fp)(const size_t a, const size_t b, size_t *const result), size_t a, size_t b, size_t *result, size_t expect_result, int expect_wrap)
static void smtp_unit_test_strdup(const char *const s, const char *const expect)
static void smtp_unit_test_base64_decode(const char *const buf, const char *const expect_str, size_t expect_str_len)
#define SMTP_TEST_DEFAULT_CC_NAME
int g_smtp_test_err_gmtime_r_ctr
char email_to[SMTP_MAX_EMAIL_LEN]
SMTP_LINKAGE size_t smtp_fold_whitespace_get_offset(const char *const s, unsigned int maxlen)
size_t g_smtp_test_strlen_ret_value
static void smtp_func_test_all_attachments(void)
#define SMTP_MAX_PORT_LEN
int g_smtp_test_err_bio_new_socket_ctr
static void smtp_func_test_all_headers(void)
enum smtp_status_code smtp_address_add(struct smtp *const smtp, enum smtp_address_type type, const char *const email, const char *const name)
#define STR_ALPHABET_LOWERCASE
static void smtp_func_test_server_secureserver(void)
static void smtp_func_test_send_email(const char *const port, enum smtp_connection_security connection_security, enum smtp_flag flags, enum smtp_authentication_method auth_method, const char *const cafile, const char *const subject, const char *const body)
SMTP_LINKAGE size_t smtp_base64_decode(const char *const buf, unsigned char **decode)
#define SMTP_TEST_DEFAULT_AUTH_METHOD
static void smtp_func_test_all(void)
SMTP_LINKAGE int smtp_si_sub_size_t(const size_t a, const size_t b, size_t *const result)
SMTP_LINKAGE size_t smtp_utf8_charlen(char c)
static void smtp_unit_test_all_fold_whitespace_get_offset(void)
static void smtp_func_test_all_status_code_get(void)
static size_t smtp_ffile_put_contents(FILE *stream, const void *const data, size_t datasz)
static void smtp_unit_test_all_si(void)
int g_smtp_test_send_one_byte
char g_smtp_test_err_recv_bytes[90]
static void smtp_func_test_all_write(void)
static void test_failure_misc(void)
#define SMTP_MAX_EMAIL_LEN
int g_smtp_test_err_si_add_size_t_ctr
int g_smtp_test_err_malloc_ctr
SMTP_LINKAGE int smtp_header_value_validate(const char *const value)
static void smtp_func_test_gmail_attachment(void)
static void smtp_func_test_all_attachments_mem(void)
SMTP_LINKAGE int smtp_si_mul_size_t(const size_t a, const size_t b, size_t *const result)
int g_smtp_test_time_custom_ret
char subject[SMTP_TEST_SUBJECT_LEN]
static void smtp_func_test_all_attachments_fp(void)
static void smtp_unit_test_all_smtp_str_has_nonascii_utf8(void)
static int smtp_str_list_append(struct smtp_str_list *const slist, const char *const s, size_t n)
enum smtp_status_code smtp_auth(struct smtp *const smtp, enum smtp_authentication_method auth_method, const char *const user, const char *const pass)
static void smtp_func_test_html(void)
SMTP_LINKAGE char * smtp_str_replace(const char *const search, const char *const replace, const char *const s)
int g_smtp_test_err_select_ctr
#define SMTP_TEST_DEFAULT_BCC_NAME
SMTP_LINKAGE int smtp_attachment_validate_name(const char *const name)
static void smtp_unit_test_all_bin2hex(void)
static void smtp_func_test_all_nodebug(void)
static void smtp_address_add_check(const enum smtp_address_type type, const char *const email, const char *const name, const enum smtp_status_code expect_status)
int g_smtp_test_err_connect_ctr
static void smtp_unit_test_str_replace(const char *const search, const char *const replace, const char *const s, const char *const expect)
static void smtp_func_test_html_with_plaintext(void)
int g_smtp_test_err_si_mul_size_t_ctr
static void smtp_unit_test_all_smtp_utf8_charlen(void)
SMTP_LINKAGE char * smtp_stpcpy(char *s1, const char *s2)
SMTP_LINKAGE int smtp_si_add_size_t(const size_t a, const size_t b, size_t *const result)
static void smtp_func_test_attachment_pdf(const size_t num_attachments)
static int smtp_test_config_load_from_file(const char *const config_path)
static void smtp_unit_test_fold_whitespace_get_offset(const char *const s, unsigned int maxlen, size_t expect)
int g_smtp_test_err_sprintf_rc
static void smtp_unit_test_getdelimfd_set_line_and_buf(struct str_getdelimfd *const gdfd, size_t copy_len, int expect_result)
static void smtp_unit_test_bin2hex(const char *const s, size_t slen, const char *const expect)
SMTP_LINKAGE char * smtp_fold_whitespace(const char *const s, unsigned int maxlen)
static void test_failure_status_code_set(void)
SMTP_LINKAGE enum str_getdelim_retcode smtp_str_getdelimfd(struct str_getdelimfd *const gdfd)
static void smtp_func_test_header_long(void)
enum smtp_status_code smtp_attachment_add_fp(struct smtp *const smtp, const char *const name, FILE *fp)
enum smtp_status_code smtp_status_code_get(const struct smtp *const smtp)
static void smtp_unit_test_parse_cmd_line(const char *const line, enum smtp_result_code expect_code, int expect_more, const char *const expect_text)
static void smtp_func_test_attachment_path(const char *const name, const char *const path, enum smtp_status_code expect_rc)
SMTP_LINKAGE int smtp_str_getdelimfd_set_line_and_buf(struct str_getdelimfd *const gdfd, size_t copy_len)
SMTP_LINKAGE char * smtp_chunk_split(const char *const s, size_t chunklen, const char *const end)
static void smtp_func_test_all_names(void)
SMTP_LINKAGE char * smtp_strdup(const char *s)
char email_to_2[SMTP_MAX_EMAIL_LEN]
static void smtp_func_test_attachment_long_text(void)
int g_smtp_test_err_send_ctr
int g_smtp_test_err_bio_should_retry_ctr
static void smtp_unit_test_all_str_replace(void)
int g_smtp_test_err_ssl_do_handshake_ctr
static void test_all_failure_modes(void)
static void smtp_header_add_check(const char *const key, const char *const value, const enum smtp_status_code expect_status)
int g_smtp_test_err_socket_ctr
int main(int argc, char *argv[])
#define SMTP_TEST_DEFAULT_FROM_NAME
enum smtp_status_code smtp_open(const char *const server, const char *const port, enum smtp_connection_security connection_security, enum smtp_flag flags, const char *const cafile, struct smtp **smtp)
static void smtp_func_test_attachment_fp(const char *const name, const char *const path, enum smtp_status_code expect_rc)
static void test_failure_address_add(void)
static void smtp_func_test_all_connection_security(void)
static void smtp_unit_test_all_parse_cmd_line(void)
time_t g_smtp_test_time_ret_value
static void smtp_unit_test_str_getdelimfd(const char *const input_string, size_t nbytes, int delim, enum str_getdelim_retcode expect_rc, int null_fp, const char *expect_pieces,...)
long(* getdelimfd_read)(struct str_getdelimfd *const gdfd, void *buf, size_t count)
char body[SMTP_TEST_BODY_LEN]
enum smtp_test_flags flags
static void smtp_unit_test_all_smtp_header_value_validate(void)
int g_smtp_test_err_calloc_ctr