Commit 599736a3 599736a3f49a0b36b50059f426e8e41e63bcc888 by Alain Magloire

attribute.c mbx_unix.c message.c

do not use an owner to set the attributes.
 	mime.c include/private/cpystr.h include/private/io0.h
 	include/private/mailbox0.h include/private/mbx_imap.h
 	include/private/mbx_mbox.h include/private/mbx_mdir.h
 	include/private/mbx_mmdf.h include/private/mbx_pop.h
 	include/private/mbx_unix.h include/private/message0.h
 	include/private/mime0.h include/private/registrar0.h
 	include/private/url0.h include/public/attribute.h
 	include/public/auth.h include/public/event.h
 	include/public/header.h include/public/io.h
 	include/public/locker.h include/public/mailbox.h
 	include/public/message.h include/public/mime.h
 	include/public/registrar.h include/public/transcode.h
 	include/public/url.h

put the headers in a separate file space.
1 parent 651775c9
......@@ -56,7 +56,6 @@ attribute_destroy (attribute_t *pattr, void *owner)
if (pattr && *pattr)
{
attribute_t attr = *pattr;
if (attr->owner == owner)
free (attr);
/* loose the link */
......@@ -66,85 +65,61 @@ attribute_destroy (attribute_t *pattr, void *owner)
}
int
attribute_set_seen (attribute_t attr, void *owner)
attribute_set_seen (attribute_t attr)
{
if (attr == NULL)
return EINVAL;
if (owner == attr->owner)
{
attr->flag |= MU_ATTRIBUTE_SEEN;
return 0;
}
return EACCES;
attr->flag |= MU_ATTRIBUTE_SEEN;
return 0;
}
int
attribute_set_answered (attribute_t attr, void *owner)
attribute_set_answered (attribute_t attr)
{
if (attr == NULL)
return EINVAL;
if (owner == attr->owner)
{
attr->flag |= MU_ATTRIBUTE_ANSWERED;
return 0;
}
return EACCES;
attr->flag |= MU_ATTRIBUTE_ANSWERED;
return 0;
}
int
attribute_set_flagged (attribute_t attr, void *owner)
attribute_set_flagged (attribute_t attr)
{
if (attr == NULL)
return EINVAL;
if (owner == attr->owner)
{
attr->flag |= MU_ATTRIBUTE_FLAGGED;
return 0;
}
return EACCES;
attr->flag |= MU_ATTRIBUTE_FLAGGED;
return 0;
}
int
attribute_set_read (attribute_t attr, void *owner)
attribute_set_read (attribute_t attr)
{
if (attr == NULL)
return EINVAL;
if (owner == attr->owner)
{
attr->flag |= MU_ATTRIBUTE_READ;
return 0;
}
return EACCES;
attr->flag |= MU_ATTRIBUTE_READ;
return 0;
}
int
attribute_set_deleted (attribute_t attr, void *owner)
attribute_set_deleted (attribute_t attr)
{
if (attr == NULL)
return EINVAL;
if (owner == attr->owner)
{
attr->flag |= MU_ATTRIBUTE_DELETED;
return 0;
}
return EACCES;
attr->flag |= MU_ATTRIBUTE_DELETED;
return 0;
}
int
attribute_set_draft (attribute_t attr, void *owner)
attribute_set_draft (attribute_t attr)
{
if (attr == NULL)
return EINVAL;
if (owner == attr->owner)
{
attr->flag |= MU_ATTRIBUTE_DRAFT;
return 0;
}
return EACCES;
attr->flag |= MU_ATTRIBUTE_DRAFT;
return 0;
}
int
attribute_set_recent (attribute_t attr, void *owner)
attribute_set_recent (attribute_t attr)
{
if (attr == NULL)
return EINVAL;
......@@ -213,94 +188,66 @@ attribute_is_recent (attribute_t attr)
}
int
attribute_unset_seen (attribute_t attr, void *owner)
attribute_unset_seen (attribute_t attr)
{
if (attr == NULL)
return 0;
if (owner == attr->owner)
{
attr->flag &= ~MU_ATTRIBUTE_SEEN;
return 0;
}
return EACCES;
attr->flag &= ~MU_ATTRIBUTE_SEEN;
return 0;
}
int
attribute_unset_answered (attribute_t attr, void *owner)
attribute_unset_answered (attribute_t attr)
{
if (attr == NULL)
return 0;
if (owner == attr->owner)
{
attr->flag &= ~MU_ATTRIBUTE_ANSWERED;
return 0;
}
return EACCES;
attr->flag &= ~MU_ATTRIBUTE_ANSWERED;
return 0;
}
int
attribute_unset_flagged (attribute_t attr, void *owner)
attribute_unset_flagged (attribute_t attr)
{
if (attr == NULL)
return 0;
if (owner == attr->owner)
{
attr->flag &= ~MU_ATTRIBUTE_FLAGGED;
return 0;
}
return EACCES;
attr->flag &= ~MU_ATTRIBUTE_FLAGGED;
return 0;
}
int
attribute_unset_read (attribute_t attr, void *owner)
attribute_unset_read (attribute_t attr)
{
if (attr == NULL)
return 0;
if (owner == attr->owner)
{
attr->flag &= ~MU_ATTRIBUTE_READ;
return 0;
}
return EACCES;
attr->flag &= ~MU_ATTRIBUTE_READ;
return 0;
}
int
attribute_unset_deleted (attribute_t attr, void *owner)
attribute_unset_deleted (attribute_t attr)
{
if (attr == NULL)
return 0;
if (owner == attr->owner)
{
attr->flag &= ~MU_ATTRIBUTE_DELETED;
return 0;
}
return EACCES;
attr->flag &= ~MU_ATTRIBUTE_DELETED;
return 0;
}
int
attribute_unset_draft (attribute_t attr, void *owner)
attribute_unset_draft (attribute_t attr)
{
if (attr == NULL)
return 0;
if (owner == attr->owner)
{
attr->flag &= ~MU_ATTRIBUTE_DRAFT;
return 0;
}
return EACCES;
attr->flag &= ~MU_ATTRIBUTE_DRAFT;
return 0;
}
int
attribute_unset_recent (attribute_t attr, void *owner)
attribute_unset_recent (attribute_t attr)
{
if (attr == NULL)
return 0;
if (owner == attr->owner)
{
attr->flag &= ~MU_ATTRIBUTE_RECENT;
return 0;
}
return EACCES;
attr->flag &= ~MU_ATTRIBUTE_RECENT;
return 0;
}
int
......@@ -312,16 +259,12 @@ attribute_is_equal (attribute_t attr, attribute_t attr2)
}
int
attribute_copy (attribute_t dest, attribute_t src, void *dest_owner)
attribute_copy (attribute_t dest, attribute_t src)
{
if (dest == NULL || src == NULL)
return EINVAL;
if (dest->owner == dest_owner)
{
memcpy (dest, src, sizeof (*dest));
return 0;
}
return EACCES;
memcpy (dest, src, sizeof (*dest));
return 0;
}
int
......@@ -340,13 +283,13 @@ string_to_attribute (const char *buffer, size_t len,
{
sep = strchr(buffer, ':'); /* pass the ':' */
if (strchr (sep, 'R') != NULL || strchr (sep, 'r') != NULL)
attribute_set_read (*pattr, owner);
attribute_set_read (*pattr);
if (strchr (sep, 'O') != NULL || strchr (sep, 'o') != NULL)
attribute_set_seen (*pattr, owner);
attribute_set_seen (*pattr);
if (strchr (sep, 'A') != NULL || strchr (sep, 'a') != NULL)
attribute_set_answered (*pattr, owner);
attribute_set_answered (*pattr);
if (strchr (sep, 'F') != NULL || strchr (sep, 'f') != NULL)
attribute_set_flagged (*pattr, owner);
attribute_set_flagged (*pattr);
}
return 0;
}
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _MIME0_H
#define _MIME0_H
#include <sys/types.h>
#include <mime.h>
#ifndef __P
#ifdef __STDC__
#define __P(args) args
#else
#define __P(args) ()
#endif
#endif /*__P */
#ifdef _cplusplus
extern "C" {
#endif
#define MIME_MAX_HDR_LEN 256
#define MIME_DFLT_BUF_SIZE 2048
/* Parser states */
#define MIME_STATE_BEGIN_LINE 1
#define MIME_STATE_SCAN_BOUNDARY 2
#define MIME_STATE_HEADERS 3
#define MIME_FLAG_MASK 0x0000ffff
/* private */
#define MIME_PARSER_ACTIVE 0x80000000
#define MIME_PARSER_HAVE_CR 0x40000000
#define MIME_NEW_MESSAGE 0x20000000
struct _mime
{
message_t msg;
header_t hdrs;
stream_t stream;
int flags;
char *content_type;
int tparts;
int nmtp_parts;
struct _mime_part **mtp_parts; /* list of parts in the msg */
int tmsgs;
int ncap_msgs;
struct _mime_part **cap_msgs; /* list of encapsulated msgs */
/* parser state */
char *boundary;
char *cur_line;
int line_ndx;
int cur_offset;
char *cur_buf;
int buf_size;
char *header_buf;
int header_buf_size;
int header_length;
int body_offset;
int body_length;
int parser_state;
};
struct _mime_part
{
mime_t mime;
header_t hdr;
message_t msg;
int body_offset;
int body_len;
};
#ifdef _cplusplus
}
#endif
#endif /* MIME0_H */
......@@ -46,26 +46,26 @@ extern int attribute_is_draft __P ((attribute_t));
extern int attribute_is_recent __P ((attribute_t));
extern int attribute_is_read __P ((attribute_t));
extern int attribute_set_seen __P ((attribute_t, void *owner));
extern int attribute_set_answered __P ((attribute_t, void *owner));
extern int attribute_set_flagged __P ((attribute_t, void *owner));
extern int attribute_set_deleted __P ((attribute_t, void *owner));
extern int attribute_set_draft __P ((attribute_t, void *owner));
extern int attribute_set_recent __P ((attribute_t, void *owner));
extern int attribute_set_read __P ((attribute_t, void *owner));
extern int attribute_unset_seen __P ((attribute_t, void *owner));
extern int attribute_unset_answered __P ((attribute_t, void *owner));
extern int attribute_unset_flagged __P ((attribute_t, void *owner));
extern int attribute_unset_deleted __P ((attribute_t, void *owner));
extern int attribute_unset_draft __P ((attribute_t, void *owner));
extern int attribute_unset_recent __P ((attribute_t, void *owner));
extern int attribute_unset_read __P ((attribute_t, void *owner));
extern int attribute_set_seen __P ((attribute_t));
extern int attribute_set_answered __P ((attribute_t));
extern int attribute_set_flagged __P ((attribute_t));
extern int attribute_set_deleted __P ((attribute_t));
extern int attribute_set_draft __P ((attribute_t));
extern int attribute_set_recent __P ((attribute_t));
extern int attribute_set_read __P ((attribute_t));
extern int attribute_unset_seen __P ((attribute_t));
extern int attribute_unset_answered __P ((attribute_t));
extern int attribute_unset_flagged __P ((attribute_t));
extern int attribute_unset_deleted __P ((attribute_t));
extern int attribute_unset_draft __P ((attribute_t));
extern int attribute_unset_recent __P ((attribute_t));
extern int attribute_unset_read __P ((attribute_t));
extern int attribute_is_equal __P ((attribute_t att1, attribute_t att2));
extern int attribute_copy __P ((attribute_t dst,
attribute_t src, void *dest_owner));
attribute_t src));
extern int string_to_attribute __P ((const char *buf, size_t len,
attribute_t *pattr, void *owner));
......
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Library Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _MIME_H
#define _MIME_H
#include <header.h>
#include <io.h>
#include <sys/types.h>
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /* __P */
/* mime flags */
#define MIME_INCREAMENTAL_PARSER 0x00000001
#ifdef _cplusplus
extern "C" {
#endif
/* forward declaration */
struct _mime;
typedef struct _mime *mime_t;
int mime_init __P ((mime_t *pmime, message_t msg, int flags));
void mime_destroy __P ((mime_t *pmime));
int mime_is_multi_part __P ((mime_t mime));
int mime_get_part __P ((mime_t mime, int part, message_t *msg));
int mime_add_part __P ((mime_t mime, message_t msg));
int mime_get_num_parts __P ((mime_t mime, int *nparts));
int mime_get_message __P ((mime_t mime, message_t *msg));
int mime_unencapsulate __P ((mime_t mime, message_t msg, message_t *newmsg));
#ifdef _cplusplus
}
#endif
#endif /* _MIME_H */
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Library Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _TRANSCODE_H
#define _TRANSCODE_H
#include <sys/types.h>
#ifndef __P
# ifdef __STDC__
# define __P(args) args
# else
# define __P(args) ()
# endif
#endif /* __P */
#ifdef _cplusplus
extern "C" {
#endif
/* forward declaration */
struct _transcoder;
typedef struct _transcoder *transcoder_t;
struct _transcoder
{
stream_t ustream; /* user reads/writes decoded/encoded data from here */
stream_t stream; /* encoder/decoder read/writes data to here */
void (*destroy)(transcoder_t tc);
void *tcdata;
};
extern int transcode_init __P ((transcoder_t *, char *encoding));
extern void transcode_destroy __P ((transcoder_t *));
extern int transcode_get_stream __P ((transcoder_t tc, stream_t *pis));
extern int transcode_set_stream __P ((transcoder_t tc, stream_t is));
#ifdef _cplusplus
}
#endif
#endif /* _TRANSCODE_H */
......@@ -608,14 +608,14 @@ mailbox_unix_readhdr (mailbox_t mbox, char *buf, size_t len,
mum->hdr_status = mum->hdr_status_end - strlen (buf);
sep = strchr(buf, ':'); /* pass the ':' */
if (strchr (sep, 'R') != NULL || strchr (sep, 'r') != NULL)
attribute_set_read (mum->old_attr, mbox);
attribute_set_read (mum->old_attr);
if (strchr (sep, 'O') != NULL || strchr (sep, 'o') != NULL)
attribute_set_seen (mum->old_attr, mbox);
attribute_set_seen (mum->old_attr);
if (strchr (sep, 'A') != NULL || strchr (sep, 'a') != NULL)
attribute_set_answered (mum->old_attr, mbox);
attribute_set_answered (mum->old_attr);
if (strchr (sep, 'F') != NULL || strchr (sep, 'f') != NULL)
attribute_set_flagged (mum->old_attr, mbox);
attribute_copy (mum->new_attr, mum->old_attr, mbox);
attribute_set_flagged (mum->old_attr);
attribute_copy (mum->new_attr, mum->old_attr);
}
}
/* check for any dubious conditions */
......@@ -774,7 +774,7 @@ mailbox_unix_scan (mailbox_t mbox, size_t msgno, size_t *pcount)
status = attribute_init (&(mum->new_attr), mbox);
if (status != 0)
{
attribute_init (&(mum->old_attr), mbox);
attribute_destroy (&(mum->old_attr), mbox);
funlockfile (mud->file);
mailbox_unix_iunlock (mbox);
mailbox_unix_unlock (mbox);
......@@ -1443,8 +1443,7 @@ mailbox_unix_get_message (mailbox_t mbox, size_t msgno, message_t *pmsg)
header_t header = NULL;
if (mbox == NULL || pmsg == NULL ||
(mud = (mailbox_unix_data_t)mbox->data) == NULL ||
mailbox_unix_is_deleted (mbox, msgno))
(mud = (mailbox_unix_data_t)mbox->data) == NULL)
return EINVAL;
mum = mud->umessages[msgno - 1];
......
......@@ -150,7 +150,7 @@ message_clone (message_t msg)
body_destroy (&body, msg);
stream_destroy (&stream, msg);
}
attribute_copy (attribute, msg->attribute, msg);
attribute_copy (attribute, msg->attribute);
/* every thing went ok */
msg->header = header;
......