ze-filter  (ze-filter-0.8.0-develop-180218)
ze-short-messages.c
Go to the documentation of this file.
1 
2 /*
3  *
4  * ze-filter - Mail Server Filter for sendmail
5  *
6  * Copyright (c) 2001-2018 - Jose-Marcio Martins da Cruz
7  *
8  * Auteur : Jose Marcio Martins da Cruz
9  * jose.marcio.mc@gmail.org
10  *
11  * Historique :
12  * Creation : Sun Sep 21 18:52:30 CEST 2008
13  *
14  * This program is free software, but with restricted license :
15  *
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * More details about ze-filter license can be found at ze-filter
22  * web site : http://foss.jose-marcio.org
23  */
24 
25 
26 #include <ze-sys.h>
27 #include <ze-filter.h>
28 #include <ze-short-messages.h>
29 
30 /* ****************************************************************************
31  * *
32  * *
33  ******************************************************************************/
34 
35 #if 0
36 HELp
37  INFO < liste >
38  LISts
39  REView < liste >
40  WHICH
41  SUBscribe < liste > <nom >
42  UNSubscribe < liste > <email >
43  UNSubscribe * <EMAIL >
44  SET < liste > |*NOMAIL
45  SET < list > |*DIGEST
46  SET < liste | *>DIGESTPLAIN
47  SET < liste > |*SUMMARY
48  SET < liste > |*NOTICE
49  SET < liste > |*MAIL
50  SET < liste > |*CONCEAL
51  SET < liste > |*NOCONCEAL
52  INDex
53  GET < liste > <fichier >
54  LAST < liste >
55  INVITE < liste > <email >
56  CONFIRM < cl é >ADD < liste > jean @ serveur nom complet
57  DEL < liste > jean @ serveur
58  STATS < liste >
59  REMIND < liste >
60  DISTribute < liste > <cl é>REJect < liste > <cl é >MODINDEX < liste > QUIT #endif static char *sympa_cmds[] = { "^hel(p)?", "^info .+", "^lis(ts)?", "^rev(iew) .+", "^which", "^sub(scribe)? .+", "^uns(ubscribe)? .+", "^set .+", "^ind(ex)?", "^get .+ .+", "^last .+", "^invite .+ .+", "^confirm .+", "^quit", "^add .+", "^del .+", "^stats .+", "^remind .+", "^dist(ribute) .+", "^rej(ect) .+", "^modindex .+", NULL }; #if 0 if (priv->body_nb == 0 && IS_UNKNOWN(priv->ip_class)) { char buf[1024]; header_T *h = priv->headers; int i; bool doit = FALSE; if (bodylen > 1023) goto ok; if (cf_get_int(CF_REJECT_SHORT_BODIES) != OPT_YES) goto ok; i = 0; while (i < bodylen && isspace(bodyp[i])) i++; memcpy(buf, bodyp + i, bodylen - i); buf[bodylen - i] = '\0'; while ((i = strlen(buf)) > 0) { if (!isspace(buf[i - 1])) break; buf[i - 1] = '\0'; } if (strlen(buf) >= cf_get_int(CF_MIN_BODY_LENGTH)) goto ok; /* * is this a subscription message ? */ if (zeStrRegex(buf, "subscribe", NULL, NULL, TRUE)) goto ok; while ((h = get_msgheader_next(h, "Subject")) != NULL) { if (h->value != NULL && zeStrRegex(h->value, "subscribe", NULL, NULL, TRUE)) goto ok; } /* * autres ??? */ #if 0 if (0) { char *p, *q; int i; while (p != NULL && *p != '\0') { if ((p = strpbrk(p, " \t\n")) != NULL) { i++; p++; continue; } } for (p = buf, i = 0;} #endif ZE_MessageInfo(10, "%s : This is a short message...", CONNID_STR(priv->id), strlen(buf)); priv->msg_short = TRUE;} ok: #endif >REJect < liste > <cl é>MODINDEX < liste > QUIT #endif static char *sympa_cmds[] = { "^hel(p)?", "^info .+", "^lis(ts)?", "^rev(iew) .+", "^which", "^sub(scribe)? .+", "^uns(ubscribe)? .+", "^set .+", "^ind(ex)?", "^get .+ .+", "^last .+", "^invite .+ .+", "^confirm .+", "^quit", "^add .+", "^del .+", "^stats .+", "^remind .+", "^dist(ribute) .+", "^rej(ect) .+", "^modindex .+", NULL }; #if 0 if (priv->body_nb == 0 && IS_UNKNOWN(priv->ip_class)) { char buf[1024]; header_T *h = priv->headers; int i; bool doit = FALSE; if (bodylen > 1023) goto ok; if (cf_get_int(CF_REJECT_SHORT_BODIES) != OPT_YES) goto ok; i = 0; while (i < bodylen && isspace(bodyp[i])) i++; memcpy(buf, bodyp + i, bodylen - i); buf[bodylen - i] = '\0'; while ((i = strlen(buf)) > 0) { if (!isspace(buf[i - 1])) break; buf[i - 1] = '\0'; } if (strlen(buf) >= cf_get_int(CF_MIN_BODY_LENGTH)) goto ok; /* * is this a subscription message ? */ if (zeStrRegex(buf, "subscribe", NULL, NULL, TRUE)) goto ok; while ((h = get_msgheader_next(h, "Subject")) != NULL) { if (h->value != NULL && zeStrRegex(h->value, "subscribe", NULL, NULL, TRUE)) goto ok; } /* * autres ??? */ #if 0 if (0) { char *p, *q; int i; while (p != NULL && *p != '\0') { if ((p = strpbrk(p, " \t\n")) != NULL) { i++; p++; continue; } } for (p = buf, i = 0;} #endif ZE_MessageInfo(10, "%s : This is a short message...", CONNID_STR(priv->id), strlen(buf)); priv->msg_short = TRUE;} ok: #endif >MODINDEX < liste > QUIT
61 #endif
62 static char *sympa_cmds[] = {
63  "^hel(p)?",
64  "^info .+",
65  "^lis(ts)?",
66  "^rev(iew) .+",
67  "^which",
68  "^sub(scribe)? .+",
69  "^uns(ubscribe)? .+",
70  "^set .+",
71  "^ind(ex)?",
72  "^get .+ .+",
73  "^last .+",
74  "^invite .+ .+",
75  "^confirm .+",
76  "^quit",
77  "^add .+",
78  "^del .+",
79  "^stats .+",
80  "^remind .+",
81  "^dist(ribute) .+",
82  "^rej(ect) .+",
83  "^modindex .+",
84  NULL
85 };
86 
87 #if 0
88 if (priv->body_nb == 0 && IS_UNKNOWN(priv->ip_class)) {
89  char buf[1024];
90  header_T *h = priv->headers;
91  int i;
92  bool doit = FALSE;
93 
94  if (bodylen > 1023)
95  goto ok;
96 
98  goto ok;
99 
100  i = 0;
101  while (i < bodylen && isspace(bodyp[i]))
102  i++;
103 
104  memcpy(buf, bodyp + i, bodylen - i);
105  buf[bodylen - i] = '\0';
106 
107  while ((i = strlen(buf)) > 0) {
108  if (!isspace(buf[i - 1]))
109  break;
110  buf[i - 1] = '\0';
111  }
112 
113  if (strlen(buf) >= cf_get_int(CF_MIN_BODY_LENGTH))
114  goto ok;
115 
116  /*
117  * is this a subscription message ?
118  */
119  if (zeStrRegex(buf, "subscribe", NULL, NULL, TRUE))
120  goto ok;
121 
122  while ((h = get_msgheader_next(h, "Subject")) != NULL) {
123  if (h->value != NULL && zeStrRegex(h->value, "subscribe", NULL, NULL, TRUE))
124  goto ok;
125  }
126 
127  /*
128  * autres ???
129  */
130 #if 0
131  if (0) {
132  char *p, *q;
133  int i;
134 
135  while (p != NULL && *p != '\0') {
136  if ((p = strpbrk(p, " \t\n")) != NULL) {
137  i++;
138  p++;
139  continue;
140  }
141  }
142  for (p = buf, i = 0;}
143 #endif
144 
145  ZE_MessageInfo(10, "%s : This is a short message...",
146  CONNID_STR(priv->id), strlen(buf));
147  priv->msg_short = TRUE;}
148 
149 ok:
150 #endif
#define CF_REJECT_SHORT_BODIES
Definition: cfh-defs.h:178
bool ok
Definition: ze-connopen.c:59
#define FALSE
Definition: macros.h:160
bool zeStrRegex(char *, char *, long *, long *, bool)
Definition: zeStrings.c:544
#define OPT_YES
Definition: ze-cf.h:45
int cf_get_int(int id)
Definition: ze-cf.c:803
char * value
Definition: ze-headers.h:36
#define IS_UNKNOWN(class)
Definition: ze-netclass.h:51
#define ZE_MessageInfo(level,...)
Definition: zeSyslog.h:90
#define TRUE
Definition: macros.h:157
#define memcpy(d, s, n)
Definition: ze-sys.h:224
#define CF_MIN_BODY_LENGTH
Definition: cfh-defs.h:179
#define CONNID_STR(connid)
Definition: ze-filter.h:113
header_T * get_msgheader_next(header_T *, char *)
Definition: ze-headers.c:175