Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/wip/mboxfs/fs.h

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


enum {
	Ebase64,
	Equoted,
};

enum {
	FlagJunk,
	FlagNonJunk,
	FlagReplied,
	FlagFlagged,
	FlagDeleted,
	FlagDraft,
	FlagSeen,
};

static struct {
	int flag;
	char *name;
} flagtab[] = {
	FlagJunk,			"junk",
	FlagNonJunk,		"notjunk",
	FlagReplied,		"replied",
	FlagFlagged,		"flagged",
	FlagDeleted,		"deleted", 
	FlagDraft,			"draft",
	FlagSeen,			"seen"
};

#define	MAX_LINE	1000	// RFC says lines could be MAX 998+CR+LF

#define CACHELEN	1024*10	// 10k bytes default cache per message

typedef struct Message Message;
typedef struct Mailbox Mailbox;
typedef struct Mime Mime;
typedef struct Cache Cache;

struct Mime
{
	// mime info
	char *boundary;
	char *endboundary;
	char *type;
	char *charset;
	char *disposition;
	char *filename;
	char *encoding;
};

struct Cache
{
	int l;
	uchar b[CACHELEN];
};

struct Message
{
	int id;
	int status;
	int flags;

	// pointers to mbox file
	vlong start;	// start of message
	vlong end;		// end of message
	vlong hstart;		// start of header
	vlong hend;		// end of header
	vlong bstart;		// start of body
	vlong bend;		// end of body

	Mime mime;
	Cache *cache;

	int linecount;

	/* message ops */

	/* single read calls */
	vlong (*bcc)(Message*,char**);
	vlong (*cc)(Message*,char**);
	vlong (*date)(Message*,char**);
	vlong (*digest)(Message*,char**);
	vlong (*disposition)(Message*,char**);
	vlong (*filename)(Message*,char**);
	vlong (*from)(Message*,char**);
	vlong (*header)(Message*,char**);
	vlong (*info)(Message*,char**);
	vlong (*inreplyto)(Message*,char**);
	vlong (*lines)(Message*,char**);
	vlong (*messageid)(Message*,char**);
	vlong (*mimeheader)(Message*,char**);
	vlong (*replyto)(Message*,char**);
	vlong (*sender)(Message*,char**);
	vlong (*subject)(Message*,char**);
	vlong (*to)(Message*,char**);
	vlong (*type)(Message*,char**);
	vlong (*unixdate)(Message*,char**);
	vlong (*unixheader)(Message*,char**);
	

	/* multiple reads calls*/
	vlong (*body)(Message*,char**, vlong , vlong);
	vlong (*raw)(Message*,char**, vlong , vlong);
	vlong (*rawbody)(Message*,char**, vlong , vlong);
	vlong (*rawheader)(Message*,char**, vlong , vlong);
	vlong (*rawunix)(Message*,char**, vlong , vlong);
	

	Message *part;	
	Message *next;
	Message *root;

	Mailbox *b;

};

typedef struct Mailbox Mailbox;
struct Mailbox
{
	int	idc;		/* message id counter */
	char *name;
	char *file;

	int r,w;
	Biobuf br,bw;

	Message	*msgs;
	Mailbox	*next;
	
	/* mailbox ops */
	int	(*sync)(Mailbox*);
	int	(*open)(Mailbox*);
	int	(*close)(Mailbox*);
	int	(*fetch)(Mailbox*);
	int	(*purge)(Mailbox*);
};

typedef struct Fileinfo Fileinfo;
struct Fileinfo{
	Message *m;
	int Q;
};


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.