-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrest_send_mail.cpp
More file actions
81 lines (61 loc) · 2 KB
/
rest_send_mail.cpp
File metadata and controls
81 lines (61 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <signal.h>
#include <pthread.h>
#include <iostream>
#include <iomanip>
#include <curl/curl.h>
#include "email_util.h"
#include "rest_SM_tests.h"
void *receiving(void*);
void* sending(void*);
int main()
{
vmime::platform::setHandler<vmime::platforms::posix::posixHandler>();
curl_global_init(CURL_GLOBAL_ALL);
int ret;
pthread_t inputing;
pthread_t send;
pthread_t receive;
pthread_mutex_init(&outbound_message_queue_mutex, 0);
ret = pthread_create(&send, NULL, sending, NULL);
if(ret != 0)
std::cerr << "Error creating receiving thread" << std::endl;
//==================TEST==========================
#include "test_control.inc"
#ifdef REST_SEND_MAIL_INTERACTIVE_DEBUG
std::cerr << "***NOW STARTING INTERACTIVE DEBUGGER!\n" <<
"For every email you want to simulate sending,\n"<<
"first enter the email address on one line,\n"<<
"and then the message body on the next." << std::endl;
interactiveTest();
#endif //#ifdef REST_SEND_MAIL_INTERACTIVE_DEBUG
#ifdef REST_SEND_MAIL_LONGREQUESTS_TEST
std::cerr << "Long concurrent requests test..." << std::endl;
testLongRequests();
#endif //#ifdef REST_SEND_MAIL_LONGREQUESTS_TEST
#ifdef REST_SEND_MAIL_UNICODE_TEST
std::cerr << "Unicode test..." << std::endl;
testUnicode();
#endif //#ifdef REST_SEND_MAIL_UNICODE_TEST
//==================TEST==========================
ret = pthread_create(&receive, NULL, receiving, NULL);
if(ret != 0)
std::cerr << "Error creating receiving thread" << std::endl;
std::cerr << "All send_mail (NON-TEST) threads now started." << std::endl;
ret = pthread_join(receive, NULL);
std::cerr << "Error! Receiving thread ended..." << std::endl;
ret = pthread_join(send, NULL);
std::cerr << "Error! Sending thread ended..." << std::endl;
curl_global_cleanup();
return 0;
}