aboutsummaryrefslogtreecommitdiff
path: root/gacopyz/gacopyz_priv.h
blob: 76be1611c2a05233d3ef261413f53584b954724d (plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* This file is part of gacopyz.
   Copyright (C) 2005, 2006, 2007, 2008, 2009 Sergey Poznyakoff

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <gacopyz.h>

typedef struct macro_assoc {
	char **argv;
	char *buffer;
} macro_assoc_t;

struct smfi_str {
	struct smfiDesc *desc; /* parent description */
	int sd;                /* socket descriptor */
        int state;             /* state; FIXME: should be enum state */
	unsigned long version; /* negotiated protocol version */
        unsigned long pflags;  /* protocol flags */
	unsigned long mta_pflags; /* pflags supported by MTA */
	unsigned long aflags;  /* milter action flags (from xxfi_flags) */
        int nmacros;           /* Number of entries in macros */
        macro_assoc_t macros[maci_max]; /* Macro tables */
	char *req_macros[maci_max]; /* Required macros */
        char *reply;           /* reply code */
        void *privdata;        /* private data */
};

struct gacopyz_conn {
	int sd;
	int foreground;        /* operate in foreground mode */
 	int stop;              /* */
	struct timeval master_timeout;
	struct smfiDesc desc;
	pid_t *pidtab;
	size_t pidcount;
	void (*cleanup) (gacopyz_conn_t, void*);
	void *cleanup_data;
};

#define GACOPYZ_TIMEOUT  7210	

#ifdef GACOPYZ_UINT32_T
typedef GACOPYZ_UINT32_T gacopyz_uint32_t; 
#else
# warning "assuming 32-bit unsigned long"
typedef unsigned long gacopyz_uint32_t;
#endif

#define GACOPYZ_OPTLEN  (sizeof(gacopyz_uint32_t) * 3) /* length of options */

void (*__gacopyz_log_printer)(int, char *, va_list);

#define GACOPYZ_DESC_LOG_MATCH(dsc, level) \
  ((dsc)->logmask & SMI_LOG_MASK(level))
#define GACOPYZ_CTX_LOG_MATCH(ctx, level) \
  GACOPYZ_DESC_LOG_MATCH((ctx)->desc, level)
#define GACOPYZ_CONN_LOG_MATCH(conn, level) \
  GACOPYZ_DESC_LOG_MATCH(&(conn)->desc, level)




struct gacopyz_iod {
	int sd;
	struct timeval timeout[GACOPYZ_TO_COUNT];
	int logmask;
};

int _gacopyz_read (gacopyz_iod_t iod, char *buf, size_t size);
int _gacopyz_write(gacopyz_iod_t iod, const char *buf, size_t size);
int gacopyz_send_command(gacopyz_iod_t iod,
			 int cmd, const void *data, size_t size);
int gacopyz_read_command(gacopyz_iod_t iod, unsigned char *cmd,
			 size_t *pcount, char **pbuf, size_t *psize);
int gacopyz_register_child(gacopyz_conn_t conn, pid_t pid);
void gacopyz_unregister_child(gacopyz_conn_t conn, pid_t pid);


/* NLS */
#undef _
#undef N_
#undef gettext
#undef dgettext
#undef ngettext
#undef textdomain
#undef bindtextdomain

#ifdef ENABLE_NLS
# include <gettext.h>
# define _(String) gettext(String)
# define N_(String) String
#else
# define _(String) (String)
# define N_(String) String
# define gettext(msgid) (msgid)
# define dgettext(domain, msgid) (msgid)
# define ngettext(sg,pl,cnt) (cnt == 1) ? (sg) : (pl)
# define textdomain(Domain)
# define bindtextdomain(Package, Directory)
#endif /* ENABLE_NLS */

Return to:

Send suggestions and report system problems to the System administrator.