Anope IRC Services  Version 2.0
Data Structures | Macros | Typedefs | Functions | Variables
anopesmtp.cpp File Reference
#include "sysconf.h"
#include <string>
#include <vector>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cerrno>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/types.h>
Include dependency graph for anopesmtp.cpp:

Go to the source code of this file.

Data Structures

struct  smtp_message
 

Macros

#define _GNU_SOURCE
 
#define ano_sockclose(fd)   close(fd)
 
#define ano_sockread(fd, buf, len)   read(fd, buf, len)
 
#define ano_sockwrite(fd, buf, len)   write(fd, buf, len)
 
#define SOCKET_ERROR   -1
 

Typedefs

typedef int ano_socket_t
 

Functions

static std::string get_logname (struct tm *tm=NULL)
 
void alog (const char *fmt,...)
 
std::string strip (const std::string &buf)
 
bool smtp_is_header (const std::string &buf)
 
void smtp_parse_header (const std::string &buf, std::string &header, std::string &value)
 
bool smtp_is_end (const std::string &buf)
 
void smtp_set_to (const std::string &to)
 
int smtp_connect (const char *host, unsigned short port)
 
int smtp_send (const char *text)
 
int smtp_read (char *buf, int len)
 
int smtp_get_code (const std::string &text)
 
int smtp_send_email ()
 
void smtp_disconnect ()
 
int main (int argc, char *argv[])
 

Variables

int smtp_debug = 0
 
struct smtp_message smail
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 20 of file anopesmtp.cpp.

#define ano_sockclose (   fd)    close(fd)

Definition at line 75 of file anopesmtp.cpp.

Referenced by smtp_connect(), smtp_disconnect(), smtp_read(), and smtp_send().

#define ano_sockread (   fd,
  buf,
  len 
)    read(fd, buf, len)

Definition at line 76 of file anopesmtp.cpp.

Referenced by smtp_read().

#define ano_sockwrite (   fd,
  buf,
  len 
)    write(fd, buf, len)

Definition at line 77 of file anopesmtp.cpp.

Referenced by smtp_send().

#define SOCKET_ERROR   -1

Definition at line 78 of file anopesmtp.cpp.

Referenced by smtp_connect(), smtp_read(), and smtp_send().

Typedef Documentation

typedef int ano_socket_t

Definition at line 74 of file anopesmtp.cpp.

Function Documentation

void alog ( const char *  fmt,
  ... 
)

Definition at line 114 of file anopesmtp.cpp.

References get_logname(), smtp_debug, and Anope::strftime().

Referenced by main(), smtp_send(), and smtp_send_email().

static std::string get_logname ( struct tm *  tm = NULL)
static

Definition at line 95 of file anopesmtp.cpp.

References name, and Anope::strftime().

Referenced by alog().

int main ( int  argc,
char *  argv[] 
)
int smtp_connect ( const char *  host,
unsigned short  port 
)

Definition at line 209 of file anopesmtp.cpp.

References ano_sockclose, smail, smtp_message::sock, and SOCKET_ERROR.

Referenced by main().

void smtp_disconnect ( )

Definition at line 405 of file anopesmtp.cpp.

References ano_sockclose, smail, smtp_send(), and smtp_message::sock.

Referenced by main().

int smtp_get_code ( const std::string &  text)

Definition at line 262 of file anopesmtp.cpp.

Referenced by smtp_send_email().

bool smtp_is_end ( const std::string &  buf)

Definition at line 187 of file anopesmtp.cpp.

Referenced by main().

bool smtp_is_header ( const std::string &  buf)

Definition at line 156 of file anopesmtp.cpp.

Referenced by main().

void smtp_parse_header ( const std::string &  buf,
std::string &  header,
std::string &  value 
)

Definition at line 169 of file anopesmtp.cpp.

References strip().

Referenced by main().

int smtp_read ( char *  buf,
int  len 
)

Definition at line 248 of file anopesmtp.cpp.

References ano_sockclose, ano_sockread, smail, smtp_message::sock, and SOCKET_ERROR.

Referenced by smtp_send_email().

int smtp_send ( const char *  text)

Definition at line 235 of file anopesmtp.cpp.

References alog(), ano_sockclose, ano_sockwrite, smail, smtp_message::sock, and SOCKET_ERROR.

Referenced by smtp_disconnect(), and smtp_send_email().

int smtp_send_email ( )
void smtp_set_to ( const std::string &  to)

Definition at line 197 of file anopesmtp.cpp.

References smail, and smtp_message::to.

Referenced by main().

std::string strip ( const std::string &  buf)

Definition at line 143 of file anopesmtp.cpp.

Referenced by main(), and smtp_parse_header().

Variable Documentation

struct smtp_message smail
int smtp_debug = 0

Definition at line 91 of file anopesmtp.cpp.

Referenced by alog(), and main().