Commit 1ada3043 1ada30438d3b1f6055b2257c7962355e2ba905e0 by Sean 'Shaleh' Perry

added -g for compilation

changed CPPFLAGS to CFLAGS (we are not using c++)
more work on expunge
1 parent 1a3b2274
1999-11-06 Sean 'Shaleh' Perry <shaleh@debian.org>
* libmailbox/*: more work on expunge
* libmailbox/*: added a tester routine
* *: added -g to Makefile.am
1999-11-06 Sean 'Shaleh' Perry <shaleh@debian.org>
* libmailbox/unixmbox.*: work on expunge
use read/write along with lseek
still blows up -- getting there
......
......@@ -11,6 +11,9 @@
- libmailbox needs an interface to set and create values in the header
- libmailbox/unixmbox the open function needs to be split into an open and a
parse function
- clean up 'mail''s compilation
- 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
noinst_HEADERS = getopt.h md5.h getline.h
CFLAGS = -Wall -pedantic -g -DTESTING
......
# Use automake to process this file -*-Makefile-*-
CPPFLAGS = -Wall -pedantic
CFLAGS = -Wall -pedantic -g -DTESTING
include_HEADERS = mailbox.h
lib_LTLIBRARIES = libmailbox.la
......
......@@ -83,6 +83,9 @@ mbox_open (const char *name)
mbox->_lock = _mbox_dummy2;
mbox->_get_body = _mbox_dummy4;
mbox->_get_header = _mbox_dummy4;
#ifdef TESTING
mbox->_tester = _mbox_dummy2;
#endif
if (S_ISREG (st.st_mode))
{
......
......@@ -36,6 +36,11 @@
#define mbox_get_body(m,n) m->_get_body(m,n)
#define mbox_get_header(m,n) m->_get_header(m,n)
#define mbox_lock(m,n) m->_lock(m,n)
#ifdef TESTING
#define mbox_tester(m,n) m->_tester(m,n)
#endif
#include <stdlib.h>
/* Lock settings */
/* define this way so that it is opaque and can later become a struct w/o
......@@ -50,7 +55,7 @@ typedef struct _mailbox
char *name;
unsigned int messages;
unsigned int num_deleted;
unsigned int *sizes;
size_t *sizes;
void *_data;
/* Functions */
......@@ -63,6 +68,9 @@ typedef struct _mailbox
int (*_lock) __P((struct _mailbox *, mailbox_lock_t));
char *(*_get_body) __P ((struct _mailbox *, unsigned int));
char *(*_get_header) __P ((struct _mailbox *, unsigned int));
#ifdef TESTING
void (*_tester) __P ((struct _mailbox *, unsigned int));
#endif
}
mailbox;
......
......@@ -145,6 +145,9 @@ END:
mbox->_lock = unixmbox_lock;
mbox->_get_body = unixmbox_get_body;
mbox->_get_header = unixmbox_get_header;
#ifdef TESTING
mbox->_tester = unixmbox_tester;
#endif
return 0;
}
......@@ -164,6 +167,7 @@ unixmbox_close (mailbox * mbox)
}
data = mbox->_data;
unixmbox_lock (mbox, MO_ULOCK);
if (data->file)
fclose (data->file);
free (data->messages);
free (mbox->sizes);
......@@ -234,7 +238,7 @@ unixmbox_expunge (mailbox * mbox)
{
unixmbox_data *data;
int i = 0;
ssize_t size = 0, size_read = 0;
size_t size = 0, size_read = 0;
char *buf = NULL;
int file;
int deletion_needed = 0; /* true when a deleted message has been found */
......@@ -261,7 +265,7 @@ unixmbox_expunge (mailbox * mbox)
{
if (deletion_needed)
{
tmp = data->messages[i + 1].header - data->messages[i].header;
tmp = mbox->sizes[i];
if (tmp > buff_size)
{
buff_size = tmp;
......@@ -276,6 +280,10 @@ unixmbox_expunge (mailbox * mbox)
/* error checking */
size += size_read;
}
else
{
size += mbox->sizes[i];
}
}
else
{
......@@ -330,7 +338,7 @@ char *
unixmbox_get_body (mailbox * mbox, unsigned int num)
{
unixmbox_data *data;
unsigned int size;
size_t size;
char *buf;
if (mbox == NULL)
......@@ -374,7 +382,7 @@ char *
unixmbox_get_header (mailbox * mbox, unsigned int num)
{
unixmbox_data *data;
unsigned int size;
size_t size;
char *buf;
if ( mbox == NULL )
......@@ -426,3 +434,14 @@ unixmbox_lock (mailbox *mbox, mailbox_lock_t mode)
return 0;
}
#ifdef TESTING
void unixmbox_tester (mailbox *mbox, unsigned int num)
{
unixmbox_data *data = mbox->_data;
if (!data || num > mbox->messages || num < 0)
return;
printf ("Message size: %u\n", mbox->sizes[num]);
printf ("Message length: %lu\n",
data->messages[num].end - data->messages[num].header);
}
#endif
......
......@@ -51,7 +51,7 @@ typedef struct _unixmbox_message
off_t header;
off_t body;
off_t end;
short deleted;
char deleted;
}
unixmbox_message;
......@@ -74,4 +74,8 @@ int unixmbox_add_message (mailbox *mbox, char *message);
char *unixmbox_get_body (mailbox *mbox, unsigned int num);
char *unixmbox_get_header (mailbox *mbox, unsigned int num);
#ifdef TESTING
void unixmbox_tester (mailbox *mbox, unsigned int num);
#endif
#endif
......
CPPFLAGS = -I$(top_srcdir)/libmailbox -Wall -pedantic
CPPFLAGS = -I$(top_srcdir)/libmailbox -Wall -pedantic -g -DTESTING
bin_PROGRAMS = mail
......
......@@ -100,7 +100,8 @@ Report bugs to <bug-mailutils@gnu.org>.\n");
fgets (bar, 80, stdin);
c = bar[0];
if (c == 'd' || c == 'D' || c == 'b' || c == 'B' || c == 'h' ||
c == 'H' || c == 'r' || c == 'R' || c == 'f' || c == 'F')
c == 'H' || c == 'r' || c == 'R' || c == 'f' || c == 'F' ||
c == 'T' || c == 't' )
{
printf ("# ");
fgets (bar, 80, stdin);
......@@ -147,6 +148,10 @@ Report bugs to <bug-mailutils@gnu.org>.\n");
case 'X':
mbox_expunge (mbox);
break;
case 't':
case 'T':
mbox_tester (mbox, atoi (bar) - 1);
break;
default:
break;
}
......
INCLUDES =-I$(srcdir) -I$(top_srcdir)/lib -I$(top_srcdir)/libmailbox
CPPFLAGS = -Wall -pedantic
CFLAGS = -Wall -pedantic -g
sbin_PROGRAMS = pop3d
......