Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-gnome
Path: blob/main/mail/balsa/files/patch-libbalsa_mailbox_mh.c
16149 views
1
--- libbalsa/mailbox_mh.c.orig 2013-03-04 19:36:37.000000000 +0000
2
+++ libbalsa/mailbox_mh.c 2014-04-30 13:49:32.084143219 +0000
3
@@ -27,6 +27,8 @@
4
/* to compile this on BSD/Darwin */
5
#undef _POSIX_SOURCE
6
7
+#include <sys/types.h>
8
+#include <sys/stat.h>
9
#include <unistd.h>
10
#include <fcntl.h>
11
#include <errno.h>
12
@@ -45,7 +47,7 @@
13
struct message_info {
14
LibBalsaMailboxLocalMessageInfo local_info;
15
LibBalsaMessageFlag orig_flags; /* Has only real flags */
16
- gint fileno;
17
+ gint mi_fileno;
18
};
19
20
#define REAL_FLAGS(flags) (flags & LIBBALSA_MESSAGE_FLAGS_REAL)
21
@@ -261,7 +263,7 @@
22
23
#define MH_BASENAME(msg_info) \
24
g_strdup_printf((msg_info->orig_flags & LIBBALSA_MESSAGE_FLAG_DELETED) ? \
25
- ",%d" : "%d", msg_info->fileno)
26
+ ",%d" : "%d", msg_info->mi_fileno)
27
28
static GMimeStream *
29
libbalsa_mailbox_mh_get_message_stream(LibBalsaMailbox * mailbox,
30
@@ -336,7 +338,7 @@
31
lbm_mh_compare_fileno(const struct message_info ** a,
32
const struct message_info ** b)
33
{
34
- return (*a)->fileno - (*b)->fileno;
35
+ return (*a)->mi_fileno - (*b)->mi_fileno;
36
}
37
38
static void
39
@@ -353,7 +355,7 @@
40
41
while ((filename = g_dir_read_name(dir)) != NULL) {
42
LibBalsaMessageFlag delete_flag = 0;
43
- guint fileno;
44
+ guint mh_fileno;
45
46
if (filename[0] == ',') {
47
filename++;
48
@@ -362,22 +364,22 @@
49
if (lbm_mh_check_filename(filename) == FALSE)
50
continue;
51
52
- if (sscanf(filename, "%10d", &fileno) != 1)
53
+ if (sscanf(filename, "%10d", &mh_fileno) != 1)
54
break; /* FIXME report error? */
55
- if (fileno > mh->last_fileno)
56
- mh->last_fileno = fileno;
57
+ if (mh_fileno > mh->last_fileno)
58
+ mh->last_fileno = mh_fileno;
59
60
if (add_msg_info && mh->messages_info) {
61
struct message_info *msg_info =
62
g_hash_table_lookup(mh->messages_info,
63
- GINT_TO_POINTER(fileno));
64
+ GINT_TO_POINTER(mh_fileno));
65
if (!msg_info) {
66
msg_info = g_new0(struct message_info, 1);
67
msg_info->local_info.flags = INVALID_FLAG;
68
g_hash_table_insert(mh->messages_info,
69
- GINT_TO_POINTER(fileno), msg_info);
70
+ GINT_TO_POINTER(mh_fileno), msg_info);
71
g_ptr_array_add(mh->msgno_2_msg_info, msg_info);
72
- msg_info->fileno = fileno;
73
+ msg_info->mi_fileno = mh_fileno;
74
}
75
msg_info->orig_flags = delete_flag;
76
}
77
@@ -395,17 +397,17 @@
78
static const gchar *LibBalsaMailboxMhRecent = "recent:";
79
80
static void
81
-lbm_mh_set_flag(LibBalsaMailboxMh * mh, guint fileno, LibBalsaMessageFlag flag)
82
+lbm_mh_set_flag(LibBalsaMailboxMh * mh, guint mh_fileno, LibBalsaMessageFlag flag)
83
{
84
struct message_info *msg_info;
85
86
- if (!fileno)
87
+ if (!mh_fileno)
88
return;
89
90
- msg_info = g_hash_table_lookup(mh->messages_info, GINT_TO_POINTER(fileno));
91
+ msg_info = g_hash_table_lookup(mh->messages_info, GINT_TO_POINTER(mh_fileno));
92
93
if (!msg_info) {
94
- g_print("MH sequence info for nonexistent message %d\n", fileno);
95
+ g_print("MH sequence info for nonexistent message %d\n", mh_fileno);
96
return;
97
}
98
99
@@ -434,7 +436,7 @@
100
101
for (seq = sequences; *seq; seq++) {
102
guint end = 0;
103
- guint fileno;
104
+ guint mh_fileno;
105
106
if (!**seq)
107
continue;
108
@@ -445,11 +447,11 @@
109
if (sscanf(line, "%10d", &end) != 1)
110
break; /* FIXME report error? */
111
}
112
- if (sscanf(*seq, "%10d", &fileno) != 1)
113
+ if (sscanf(*seq, "%10d", &mh_fileno) != 1)
114
break; /* FIXME report error? */
115
do
116
- lbm_mh_set_flag(mh, fileno, flag);
117
- while (++fileno <= end);
118
+ lbm_mh_set_flag(mh, mh_fileno, flag);
119
+ while (++mh_fileno <= end);
120
}
121
122
g_strfreev(sequences);
123
@@ -581,7 +583,7 @@
124
sequences = g_strsplit(p, " ", 0);
125
for (seq = sequences; *seq; seq++) {
126
guint end = 0;
127
- guint fileno;
128
+ guint mh_fileno;
129
130
if (!**seq)
131
continue;
132
@@ -592,15 +594,15 @@
133
if (sscanf(p, "%10d", &end) != 1)
134
break; /* FIXME report error? */
135
}
136
- if (sscanf(*seq, "%10d", &fileno) != 1)
137
+ if (sscanf(*seq, "%10d", &mh_fileno) != 1)
138
break; /* FIXME report error? */
139
do {
140
- p = g_strdup_printf("%s/%d", path, fileno);
141
+ p = g_strdup_printf("%s/%d", path, mh_fileno);
142
if (access(p, F_OK) == 0)
143
retval = TRUE;
144
g_free(p);
145
/* One undeleted unread message is enough. */
146
- } while (!retval && ++fileno <= end);
147
+ } while (!retval && ++mh_fileno <= end);
148
}
149
g_strfreev(sequences);
150
break;
151
@@ -687,7 +689,7 @@
152
else {
153
g_ptr_array_remove(mh->msgno_2_msg_info, msg_info);
154
g_hash_table_remove(mh->messages_info,
155
- GINT_TO_POINTER(msg_info->fileno));
156
+ GINT_TO_POINTER(msg_info->mi_fileno));
157
libbalsa_mailbox_local_msgno_removed(mailbox, msgno);
158
if (renumber > msgno)
159
/* First message that needs renumbering. */
160
@@ -764,11 +766,11 @@
161
if (!(msg_info->local_info.flags & flag))
162
return;
163
164
- if (li->last < msg_info->fileno - 1) {
165
+ if (li->last < msg_info->mi_fileno - 1) {
166
lbm_mh_print_line(li);
167
- li->first = msg_info->fileno;
168
+ li->first = msg_info->mi_fileno;
169
}
170
- li->last = msg_info->fileno;
171
+ li->last = msg_info->mi_fileno;
172
}
173
174
static gboolean
175
@@ -850,7 +852,7 @@
176
/* free old information */
177
g_ptr_array_remove(mh->msgno_2_msg_info, msg_info);
178
g_hash_table_remove(mh->messages_info,
179
- GINT_TO_POINTER(msg_info->fileno));
180
+ GINT_TO_POINTER(msg_info->mi_fileno));
181
libbalsa_mailbox_local_msgno_removed(mailbox, msgno);
182
} else {
183
lbm_mh_flag_line(msg_info, LIBBALSA_MESSAGE_FLAG_NEW, &unseen);
184
@@ -1039,7 +1041,7 @@
185
* we'll just add new lines and let the next sync merge them with any
186
* existing lines. */
187
static void
188
-lbm_mh_update_sequences(LibBalsaMailboxMh * mh, gint fileno,
189
+lbm_mh_update_sequences(LibBalsaMailboxMh * mh, gint mh_fileno,
190
LibBalsaMessageFlag flags)
191
{
192
FILE *fp;
193
@@ -1050,13 +1052,13 @@
194
return;
195
196
if (flags & LIBBALSA_MESSAGE_FLAG_NEW)
197
- fprintf(fp, "unseen: %d\n", fileno);
198
+ fprintf(fp, "unseen: %d\n", mh_fileno);
199
if (flags & LIBBALSA_MESSAGE_FLAG_FLAGGED)
200
- fprintf(fp, "flagged: %d\n", fileno);
201
+ fprintf(fp, "flagged: %d\n", mh_fileno);
202
if (flags & LIBBALSA_MESSAGE_FLAG_REPLIED)
203
- fprintf(fp, "replied: %d\n", fileno);
204
+ fprintf(fp, "replied: %d\n", mh_fileno);
205
if (flags & LIBBALSA_MESSAGE_FLAG_RECENT)
206
- fprintf(fp, "recent: %d\n", fileno);
207
+ fprintf(fp, "recent: %d\n", mh_fileno);
208
fclose(fp);
209
}
210
211
@@ -1073,7 +1075,7 @@
212
int fd;
213
GMimeStream *out_stream;
214
GMimeFilter *crlffilter;
215
- int fileno;
216
+ int mh_fileno;
217
int retries;
218
GMimeStream *in_stream;
219
220
@@ -1116,14 +1118,14 @@
221
libbalsa_mime_stream_shared_unlock(stream);
222
g_object_unref(in_stream);
223
224
- fileno = mh->last_fileno;
225
+ mh_fileno = mh->last_fileno;
226
retries = 10;
227
do {
228
/* rename tempfile to message-number-name */
229
char *new_filename;
230
gint rename_status;
231
232
- new_filename = g_strdup_printf("%s/%d", path, ++fileno);
233
+ new_filename = g_strdup_printf("%s/%d", path, ++mh_fileno);
234
rename_status = libbalsa_safe_rename(tmp, new_filename);
235
g_free(new_filename);
236
if (rename_status != -1)
237
@@ -1146,9 +1148,9 @@
238
"Too high activity?");
239
return FALSE;
240
}
241
- mh->last_fileno = fileno;
242
+ mh->last_fileno = mh_fileno;
243
244
- lbm_mh_update_sequences(mh, fileno,
245
+ lbm_mh_update_sequences(mh, mh_fileno,
246
flags | LIBBALSA_MESSAGE_FLAG_RECENT);
247
248
return TRUE;
249
250