smtp.h

Go to the documentation of this file.
00001 /*
00002  *
00003  * (C) 2003-2013 Anope Team
00004  * Contact us at team@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  *
00012  */
00013 
00014 #ifndef SMTP_H
00015 #define SMTP_H
00016 
00017 /*************************************************************************/
00018 
00019 /* Some Linux boxes (or maybe glibc includes) require this for the
00020  * prototype of strsignal(). */
00021 #define _GNU_SOURCE
00022 
00023 #include <stdarg.h>
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <string.h>
00027 
00028 /* Windows does not have:
00029  * unistd.h, grp.h,
00030  * netdb.h, netinet/in.h,
00031  * sys/socket.h, sys/time.h
00032  * Windows requires:
00033  * winsock.h
00034  * -- codemastr
00035  */
00036 
00037 #ifndef _WIN32
00038 #include <unistd.h>
00039 #endif
00040 
00041 #include <signal.h>
00042 #include <time.h>
00043 #include <errno.h>
00044 #include <limits.h>
00045 
00046 #ifndef _WIN32
00047 #include <netdb.h>
00048 #include <netinet/in.h>
00049 #include <sys/socket.h>
00050 #include <arpa/inet.h>
00051 #else
00052 #include <winsock.h>
00053 #include <windows.h>
00054 #endif
00055 
00056 #include <sys/types.h>
00057 
00058 #ifndef _WIN32
00059 #include <sys/time.h>
00060 #endif
00061 
00062 #ifdef _AIX
00063 extern int strcasecmp(const char *, const char *);
00064 extern int strncasecmp(const char *, const char *, size_t);
00065 # if 0  /* These break on some AIX boxes (4.3.1 reported). */
00066 extern int socket(int, int, int);
00067 extern int connect(int, struct sockaddr *, int);
00068 # endif
00069 #endif /* _AIX */
00070 
00071 /* Some SUN fixs */
00072 #ifdef __sun
00073 /* Solaris specific code, types that do not exist in Solaris'
00074  *  * sys/types.h
00075  *   **/
00076 #ifndef INADDR_NONE
00077 #define INADDR_NONE (-1)
00078 #endif
00079 
00080 #endif
00081 
00082 
00083 #ifdef _WIN32
00084 #define PATH_MAX                MAX_PATH
00085 #define snprintf _snprintf
00086 #endif
00087 
00088 
00089 /*************************************************************************/
00090 
00091 #ifdef _WIN32
00092 #include <winsock.h>
00093 typedef SOCKET                          ano_socket_t;
00094 #define ano_sockclose(fd)               closesocket(fd)
00095 #define ano_sockread(fd, buf, len)      recv(fd, buf, len, 0)
00096 #define ano_sockwrite(fd, buf, len)      send(fd, buf, len, 0)
00097 #else
00098 typedef int                             ano_socket_t;
00099 #define ano_sockclose(fd)               close(fd)
00100 #define ano_sockread(fd, buf, len)      read(fd, buf, len)
00101 #define ano_sockwrite(fd, buf, len)     write(fd, buf, len)
00102 #define SOCKET_ERROR -1
00103 #endif
00104 
00105 
00106 /* Data structures */
00107 struct smtp_header {
00108     char *header;
00109     struct smtp_header *next;
00110 };
00111 
00112 struct smtp_body_line {
00113     char *line;
00114     struct smtp_body_line *next;
00115 };
00116 
00117 struct smtp_message {
00118     struct smtp_header *smtp_headers, *smtp_headers_tail;
00119     struct smtp_body_line *smtp_body, *smtp_body_tail;
00120     char *from;
00121     char *to;
00122     ano_socket_t sock;
00123 };
00124 
00125 struct smtp_message mail;
00126 
00127 /* set this to 1 if you want to get a log otherwise it runs silent */
00128 int smtp_debug = 0;
00129 
00130 #endif  /* SMTP_H */