No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-mail-stripsig-filter.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-mail-stripsig-filter.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 *
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with the program; if not, see <http://www.gnu.org/licenses/>
15 *
16 *
17 * Authors:
18 * Jeffrey Stedfast <fejj@ximian.com>
19 *
20 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
21 *
22 */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include <stdio.h>
29 #include <string.h>
30
31 #include "e-mail-stripsig-filter.h"
32
33 G_DEFINE_TYPE (EMailStripSigFilter, e_mail_stripsig_filter, CAMEL_TYPE_MIME_FILTER)
34
35 static void
36 strip_signature (CamelMimeFilter *filter,
37 const gchar *in,
38 gsize len,
39 gsize prespace,
40 gchar **out,
41 gsize *outlen,
42 gsize *outprespace,
43 gint flush)
44 {
45 EMailStripSigFilter *stripsig = (EMailStripSigFilter *) filter;
46 register const gchar *inptr = in;
47 const gchar *inend = in + len;
48 const gchar *start = NULL;
49
50 if (stripsig->midline) {
51 while (inptr < inend && *inptr != '\n')
52 inptr++;
53
54 if (inptr < inend) {
55 stripsig->midline = FALSE;
56 inptr++;
57 }
58 }
59
60 while (inptr < inend) {
61 if ((inend - inptr) >= 4 && !strncmp (inptr, "-- \n", 4)) {
62 start = inptr;
63 inptr += 4;
64 } else if (!stripsig->text_plain_only &&
65 (inend - inptr) >= 7 &&
66 !g_ascii_strncasecmp (inptr, "-- <BR>", 7)) {
67 start = inptr;
68 inptr += 7;
69 } else {
70 while (inptr < inend && *inptr != '\n')
71 inptr++;
72
73 if (inptr == inend) {
74 stripsig->midline = TRUE;
75 break;
76 }
77
78 inptr++;
79 }
80 }
81
82 if (start != NULL) {
83 inptr = start;
84 stripsig->midline = FALSE;
85 }
86
87 if (!flush && inend > inptr)
88 camel_mime_filter_backup (filter, inptr, inend - inptr);
89 else if (!start)
90 inptr = inend;
91
92 *out = (gchar *)in;
93 *outlen = inptr - in;
94 *outprespace = prespace;
95 }
96
97 static void
98 filter_filter (CamelMimeFilter *filter,
99 const gchar *in,
100 gsize len,
101 gsize prespace,
102 gchar **out,
103 gsize *outlen,
104 gsize *outprespace)
105 {
106 strip_signature (
107 filter, in, len, prespace, out, outlen, outprespace, FALSE);
108 }
109
110 static void
111 filter_complete (CamelMimeFilter *filter,
112 const gchar *in,
113 gsize len,
114 gsize prespace,
115 gchar **out,
116 gsize *outlen,
117 gsize *outprespace)
118 {
119 strip_signature (
120 filter, in, len, prespace, out, outlen, outprespace, TRUE);
121 }
122
123 /* should this 'flush' outstanding state/data bytes? */
124 static void
125 filter_reset (CamelMimeFilter *filter)
126 {
127 EMailStripSigFilter *stripsig = (EMailStripSigFilter *) filter;
128
129 stripsig->midline = FALSE;
130 }
131
132 static void
133 e_mail_stripsig_filter_class_init (EMailStripSigFilterClass *class)
134 {
135 CamelMimeFilterClass *mime_filter_class;
136
137 mime_filter_class = CAMEL_MIME_FILTER_CLASS (class);
138 mime_filter_class->filter = filter_filter;
139 mime_filter_class->complete = filter_complete;
140 mime_filter_class->reset = filter_reset;
141 }
142
143 static void
144 e_mail_stripsig_filter_init (EMailStripSigFilter *filter)
145 {
146 }
147
148 /**
149 * e_mail_stripsig_filter_new:
150 * @text_plain_only: Whether should look for a text/plain signature
151 * delimiter "-- \n" only or also an HTML signature delimiter "-- <BR>".
152 *
153 * Creates a new stripsig filter.
154 *
155 * Returns a new stripsig filter.
156 **/
157 CamelMimeFilter *
158 e_mail_stripsig_filter_new (gboolean text_plain_only)
159 {
160 EMailStripSigFilter *filter = g_object_new (E_TYPE_MAIL_STRIPSIG_FILTER, NULL);
161
162 filter->text_plain_only = text_plain_only;
163
164 return CAMEL_MIME_FILTER (filter);
165 }