added -g for compilation
changed CPPFLAGS to CFLAGS (we are not using c++) more work on expunge
Showing
11 changed files
with
59 additions
and
10 deletions
1 | 1999-11-06 Sean 'Shaleh' Perry <shaleh@debian.org> | 1 | 1999-11-06 Sean 'Shaleh' Perry <shaleh@debian.org> |
2 | 2 | ||
3 | * libmailbox/*: more work on expunge | ||
4 | * libmailbox/*: added a tester routine | ||
5 | * *: added -g to Makefile.am | ||
6 | |||
7 | 1999-11-06 Sean 'Shaleh' Perry <shaleh@debian.org> | ||
8 | |||
3 | * libmailbox/unixmbox.*: work on expunge | 9 | * libmailbox/unixmbox.*: work on expunge |
4 | use read/write along with lseek | 10 | use read/write along with lseek |
5 | still blows up -- getting there | 11 | still blows up -- getting there | ... | ... |
... | @@ -11,6 +11,9 @@ | ... | @@ -11,6 +11,9 @@ |
11 | 11 | ||
12 | - libmailbox needs an interface to set and create values in the header | 12 | - libmailbox needs an interface to set and create values in the header |
13 | 13 | ||
14 | - libmailbox/unixmbox the open function needs to be split into an open and a | ||
15 | parse function | ||
16 | |||
14 | - clean up 'mail''s compilation | 17 | - clean up 'mail''s compilation |
15 | 18 | ||
16 | - find out why the pop3 server quits on a signal when the 'quit' command is | 19 | - find out why the pop3 server quits on a signal when the 'quit' command is | ... | ... |
... | @@ -4,3 +4,4 @@ libmailutils_a_SOURCES = getopt.c getopt1.c md5.c getline.c | ... | @@ -4,3 +4,4 @@ libmailutils_a_SOURCES = getopt.c getopt1.c md5.c getline.c |
4 | 4 | ||
5 | noinst_HEADERS = getopt.h md5.h getline.h | 5 | noinst_HEADERS = getopt.h md5.h getline.h |
6 | 6 | ||
7 | CFLAGS = -Wall -pedantic -g -DTESTING | ... | ... |
1 | # Use automake to process this file -*-Makefile-*- | 1 | # Use automake to process this file -*-Makefile-*- |
2 | 2 | ||
3 | CPPFLAGS = -Wall -pedantic | 3 | CFLAGS = -Wall -pedantic -g -DTESTING |
4 | 4 | ||
5 | include_HEADERS = mailbox.h | 5 | include_HEADERS = mailbox.h |
6 | lib_LTLIBRARIES = libmailbox.la | 6 | lib_LTLIBRARIES = libmailbox.la | ... | ... |
... | @@ -83,6 +83,9 @@ mbox_open (const char *name) | ... | @@ -83,6 +83,9 @@ mbox_open (const char *name) |
83 | mbox->_lock = _mbox_dummy2; | 83 | mbox->_lock = _mbox_dummy2; |
84 | mbox->_get_body = _mbox_dummy4; | 84 | mbox->_get_body = _mbox_dummy4; |
85 | mbox->_get_header = _mbox_dummy4; | 85 | mbox->_get_header = _mbox_dummy4; |
86 | #ifdef TESTING | ||
87 | mbox->_tester = _mbox_dummy2; | ||
88 | #endif | ||
86 | 89 | ||
87 | if (S_ISREG (st.st_mode)) | 90 | if (S_ISREG (st.st_mode)) |
88 | { | 91 | { | ... | ... |
... | @@ -36,6 +36,11 @@ | ... | @@ -36,6 +36,11 @@ |
36 | #define mbox_get_body(m,n) m->_get_body(m,n) | 36 | #define mbox_get_body(m,n) m->_get_body(m,n) |
37 | #define mbox_get_header(m,n) m->_get_header(m,n) | 37 | #define mbox_get_header(m,n) m->_get_header(m,n) |
38 | #define mbox_lock(m,n) m->_lock(m,n) | 38 | #define mbox_lock(m,n) m->_lock(m,n) |
39 | #ifdef TESTING | ||
40 | #define mbox_tester(m,n) m->_tester(m,n) | ||
41 | #endif | ||
42 | |||
43 | #include <stdlib.h> | ||
39 | 44 | ||
40 | /* Lock settings */ | 45 | /* Lock settings */ |
41 | /* define this way so that it is opaque and can later become a struct w/o | 46 | /* define this way so that it is opaque and can later become a struct w/o |
... | @@ -50,7 +55,7 @@ typedef struct _mailbox | ... | @@ -50,7 +55,7 @@ typedef struct _mailbox |
50 | char *name; | 55 | char *name; |
51 | unsigned int messages; | 56 | unsigned int messages; |
52 | unsigned int num_deleted; | 57 | unsigned int num_deleted; |
53 | unsigned int *sizes; | 58 | size_t *sizes; |
54 | void *_data; | 59 | void *_data; |
55 | 60 | ||
56 | /* Functions */ | 61 | /* Functions */ |
... | @@ -63,6 +68,9 @@ typedef struct _mailbox | ... | @@ -63,6 +68,9 @@ typedef struct _mailbox |
63 | int (*_lock) __P((struct _mailbox *, mailbox_lock_t)); | 68 | int (*_lock) __P((struct _mailbox *, mailbox_lock_t)); |
64 | char *(*_get_body) __P ((struct _mailbox *, unsigned int)); | 69 | char *(*_get_body) __P ((struct _mailbox *, unsigned int)); |
65 | char *(*_get_header) __P ((struct _mailbox *, unsigned int)); | 70 | char *(*_get_header) __P ((struct _mailbox *, unsigned int)); |
71 | #ifdef TESTING | ||
72 | void (*_tester) __P ((struct _mailbox *, unsigned int)); | ||
73 | #endif | ||
66 | } | 74 | } |
67 | mailbox; | 75 | mailbox; |
68 | 76 | ... | ... |
... | @@ -145,6 +145,9 @@ END: | ... | @@ -145,6 +145,9 @@ END: |
145 | mbox->_lock = unixmbox_lock; | 145 | mbox->_lock = unixmbox_lock; |
146 | mbox->_get_body = unixmbox_get_body; | 146 | mbox->_get_body = unixmbox_get_body; |
147 | mbox->_get_header = unixmbox_get_header; | 147 | mbox->_get_header = unixmbox_get_header; |
148 | #ifdef TESTING | ||
149 | mbox->_tester = unixmbox_tester; | ||
150 | #endif | ||
148 | 151 | ||
149 | return 0; | 152 | return 0; |
150 | } | 153 | } |
... | @@ -164,6 +167,7 @@ unixmbox_close (mailbox * mbox) | ... | @@ -164,6 +167,7 @@ unixmbox_close (mailbox * mbox) |
164 | } | 167 | } |
165 | data = mbox->_data; | 168 | data = mbox->_data; |
166 | unixmbox_lock (mbox, MO_ULOCK); | 169 | unixmbox_lock (mbox, MO_ULOCK); |
170 | if (data->file) | ||
167 | fclose (data->file); | 171 | fclose (data->file); |
168 | free (data->messages); | 172 | free (data->messages); |
169 | free (mbox->sizes); | 173 | free (mbox->sizes); |
... | @@ -234,7 +238,7 @@ unixmbox_expunge (mailbox * mbox) | ... | @@ -234,7 +238,7 @@ unixmbox_expunge (mailbox * mbox) |
234 | { | 238 | { |
235 | unixmbox_data *data; | 239 | unixmbox_data *data; |
236 | int i = 0; | 240 | int i = 0; |
237 | ssize_t size = 0, size_read = 0; | 241 | size_t size = 0, size_read = 0; |
238 | char *buf = NULL; | 242 | char *buf = NULL; |
239 | int file; | 243 | int file; |
240 | int deletion_needed = 0; /* true when a deleted message has been found */ | 244 | int deletion_needed = 0; /* true when a deleted message has been found */ |
... | @@ -261,7 +265,7 @@ unixmbox_expunge (mailbox * mbox) | ... | @@ -261,7 +265,7 @@ unixmbox_expunge (mailbox * mbox) |
261 | { | 265 | { |
262 | if (deletion_needed) | 266 | if (deletion_needed) |
263 | { | 267 | { |
264 | tmp = data->messages[i + 1].header - data->messages[i].header; | 268 | tmp = mbox->sizes[i]; |
265 | if (tmp > buff_size) | 269 | if (tmp > buff_size) |
266 | { | 270 | { |
267 | buff_size = tmp; | 271 | buff_size = tmp; |
... | @@ -276,6 +280,10 @@ unixmbox_expunge (mailbox * mbox) | ... | @@ -276,6 +280,10 @@ unixmbox_expunge (mailbox * mbox) |
276 | /* error checking */ | 280 | /* error checking */ |
277 | size += size_read; | 281 | size += size_read; |
278 | } | 282 | } |
283 | else | ||
284 | { | ||
285 | size += mbox->sizes[i]; | ||
286 | } | ||
279 | } | 287 | } |
280 | else | 288 | else |
281 | { | 289 | { |
... | @@ -330,7 +338,7 @@ char * | ... | @@ -330,7 +338,7 @@ char * |
330 | unixmbox_get_body (mailbox * mbox, unsigned int num) | 338 | unixmbox_get_body (mailbox * mbox, unsigned int num) |
331 | { | 339 | { |
332 | unixmbox_data *data; | 340 | unixmbox_data *data; |
333 | unsigned int size; | 341 | size_t size; |
334 | char *buf; | 342 | char *buf; |
335 | 343 | ||
336 | if (mbox == NULL) | 344 | if (mbox == NULL) |
... | @@ -374,7 +382,7 @@ char * | ... | @@ -374,7 +382,7 @@ char * |
374 | unixmbox_get_header (mailbox * mbox, unsigned int num) | 382 | unixmbox_get_header (mailbox * mbox, unsigned int num) |
375 | { | 383 | { |
376 | unixmbox_data *data; | 384 | unixmbox_data *data; |
377 | unsigned int size; | 385 | size_t size; |
378 | char *buf; | 386 | char *buf; |
379 | 387 | ||
380 | if ( mbox == NULL ) | 388 | if ( mbox == NULL ) |
... | @@ -426,3 +434,14 @@ unixmbox_lock (mailbox *mbox, mailbox_lock_t mode) | ... | @@ -426,3 +434,14 @@ unixmbox_lock (mailbox *mbox, mailbox_lock_t mode) |
426 | return 0; | 434 | return 0; |
427 | } | 435 | } |
428 | 436 | ||
437 | #ifdef TESTING | ||
438 | void unixmbox_tester (mailbox *mbox, unsigned int num) | ||
439 | { | ||
440 | unixmbox_data *data = mbox->_data; | ||
441 | if (!data || num > mbox->messages || num < 0) | ||
442 | return; | ||
443 | printf ("Message size: %u\n", mbox->sizes[num]); | ||
444 | printf ("Message length: %lu\n", | ||
445 | data->messages[num].end - data->messages[num].header); | ||
446 | } | ||
447 | #endif | ... | ... |
... | @@ -51,7 +51,7 @@ typedef struct _unixmbox_message | ... | @@ -51,7 +51,7 @@ typedef struct _unixmbox_message |
51 | off_t header; | 51 | off_t header; |
52 | off_t body; | 52 | off_t body; |
53 | off_t end; | 53 | off_t end; |
54 | short deleted; | 54 | char deleted; |
55 | } | 55 | } |
56 | unixmbox_message; | 56 | unixmbox_message; |
57 | 57 | ||
... | @@ -74,4 +74,8 @@ int unixmbox_add_message (mailbox *mbox, char *message); | ... | @@ -74,4 +74,8 @@ int unixmbox_add_message (mailbox *mbox, char *message); |
74 | char *unixmbox_get_body (mailbox *mbox, unsigned int num); | 74 | char *unixmbox_get_body (mailbox *mbox, unsigned int num); |
75 | char *unixmbox_get_header (mailbox *mbox, unsigned int num); | 75 | char *unixmbox_get_header (mailbox *mbox, unsigned int num); |
76 | 76 | ||
77 | #ifdef TESTING | ||
78 | void unixmbox_tester (mailbox *mbox, unsigned int num); | ||
79 | #endif | ||
80 | |||
77 | #endif | 81 | #endif | ... | ... |
... | @@ -100,7 +100,8 @@ Report bugs to <bug-mailutils@gnu.org>.\n"); | ... | @@ -100,7 +100,8 @@ Report bugs to <bug-mailutils@gnu.org>.\n"); |
100 | fgets (bar, 80, stdin); | 100 | fgets (bar, 80, stdin); |
101 | c = bar[0]; | 101 | c = bar[0]; |
102 | if (c == 'd' || c == 'D' || c == 'b' || c == 'B' || c == 'h' || | 102 | if (c == 'd' || c == 'D' || c == 'b' || c == 'B' || c == 'h' || |
103 | c == 'H' || c == 'r' || c == 'R' || c == 'f' || c == 'F') | 103 | c == 'H' || c == 'r' || c == 'R' || c == 'f' || c == 'F' || |
104 | c == 'T' || c == 't' ) | ||
104 | { | 105 | { |
105 | printf ("# "); | 106 | printf ("# "); |
106 | fgets (bar, 80, stdin); | 107 | fgets (bar, 80, stdin); |
... | @@ -147,6 +148,10 @@ Report bugs to <bug-mailutils@gnu.org>.\n"); | ... | @@ -147,6 +148,10 @@ Report bugs to <bug-mailutils@gnu.org>.\n"); |
147 | case 'X': | 148 | case 'X': |
148 | mbox_expunge (mbox); | 149 | mbox_expunge (mbox); |
149 | break; | 150 | break; |
151 | case 't': | ||
152 | case 'T': | ||
153 | mbox_tester (mbox, atoi (bar) - 1); | ||
154 | break; | ||
150 | default: | 155 | default: |
151 | break; | 156 | break; |
152 | } | 157 | } | ... | ... |
-
Please register or sign in to post a comment