summaryrefslogtreecommitdiff
path: root/common/smtppass.h
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-08-27 23:08:18 +0000
committerStef Walter <stef@memberwebs.com>2004-08-27 23:08:18 +0000
commitdd53442133709293c04621af9af0f6d9e9aab003 (patch)
treecd1455be75dacbdc19334daf28cbbb5625a10b75 /common/smtppass.h
parent3d9db3a155a3a0812a6252f37e04b22f89b68ae5 (diff)
- Changed to buffered IO
Diffstat (limited to 'common/smtppass.h')
-rw-r--r--common/smtppass.h37
1 files changed, 34 insertions, 3 deletions
diff --git a/common/smtppass.h b/common/smtppass.h
index 4c581d2..ca3df37 100644
--- a/common/smtppass.h
+++ b/common/smtppass.h
@@ -39,6 +39,17 @@
#ifndef __CLAMSMTPD_H__
#define __CLAMSMTPD_H__
+#define BUF_LEN 256
+
+typedef struct clio
+{
+ int fd;
+ const char* name;
+ unsigned char buf[BUF_LEN];
+ size_t buflen;
+}
+clio_t;
+
/*
* A generous maximum line length. It needs to be longer than
* a full path on this system can be, because we pass the file
@@ -55,9 +66,9 @@ typedef struct clamsmtp_context
{
unsigned int id; /* Identifier for the connection */
- int client; /* Connection to client */
- int server; /* Connection to server */
- int clam; /* Connection to clamd */
+ clio_t client; /* Connection to client */
+ clio_t server; /* Connection to server */
+ clio_t clam; /* Connection to clamd */
char line[LINE_LENGTH]; /* Working buffer */
int linelen; /* Length of valid data in above */
@@ -67,5 +78,25 @@ clamsmtp_context_t;
extern int g_daemonized; /* Currently running as a daemon */
extern int g_debuglevel; /* what gets logged to console */
extern pthread_mutex_t g_mutex; /* The main mutex */
+extern struct timeval g_timeout;
+extern int g_quit;
+
+struct sockaddr_any;
+#define LINE_TOO_LONG(ctx) ((ctx)->linelen >= (LINE_LENGTH - 2))
+#define RETURN(x) { ret = x; goto cleanup; }
+
+
+#define CLIO_TRIM 0x00000001
+#define CLIO_DISCARD 0x00000002
+#define CLIO_QUIET 0x00000004
+#define clio_valid(io) ((io)->fd != -1)
+
+void clio_init(clio_t* io, const char* name);
+int clio_connect(clamsmtp_context_t* ctx, clio_t* io, struct sockaddr_any* sany, const char* addrname);
+void clio_disconnect(clamsmtp_context_t* ctx, clio_t* io);
+int clio_select(clamsmtp_context_t* ctx, clio_t** io);
+int clio_read_line(clamsmtp_context_t* ctx, clio_t* io, int trim);
+int clio_write_data(clamsmtp_context_t* ctx, clio_t* io, const char* data);
+int clio_write_data_raw(clamsmtp_context_t* ctx, clio_t* io, unsigned char* buf, int len);
#endif /* __CLAMSMTPD_H__ */