Early-posting a new idea for the summary format



I'm early-posting a new idea for the summary format of one
CamelMessageInfo item with an embedded CamelMessageContentInfo.

Basic question and reason for posting this: what do you guys think of
it?


"W" means "word length". On a 32 bit computer this is 4 bytes, on a 64
bit computer this is 8 bytes.

"stra" means a string that can be available at an alias too. If the
first character of the string is a non-printable character, starting
from the second byte a W bytes integer will contain the offset to the
alias. Else starting from the first character until the \0 will be the
string. Whenever it says [stra|string\0] it can therefore also mean
[stra|-> 0 + (offset + o) of the alias].

"eint" means an encoded integer.

"intW" means an integer that is "word length" in size

"-> L" means "a pointer to L". Which means that the content of the intW
is the address to (L + o).

"chrN" means "N characters" or in other words "N bytes" (the \0 is
included)

o [intW|-> x]
  [str |alias string\0]
  [str |alias string\0]
  [str |alias string\0]
x [intW|-> a]
  [str |uid-a\0]
  [intW|-> a]
  [str |uid-b\0]
  [intW|-> b]
  ...
a [intW|-> b]
  [chr9|message_id\0]
  [str |uid-a\0]
  [stra|subject\0]
  [stra|from\0]
  [stra|to\0]
  [stra|cc\0]
  [eint|size]
  [eint|sent]
  [eint|received]
  [stra|type\0]
  [stra|subtype\0]
  [eint|count]
    [stra|name\0]
    [stra|value\0]
    ...
  [stra|ci_id\0]
  [stra|ci_desc\0]
  [stra|ci_enc\0]

b [intW|-> c]
  [chr9|message_id\0]
  [str |uid-a\0]
  [stra|subject\0]
  [stra|from\0]
  [stra|to\0]
  [stra|cc\0]
  [eint|size]
  [eint|sent]
  [eint|received]
  [stra|type\0]
  [stra|subtype\0]
  [eint|count]
    [stra|name\0]
    [stra|value\0]
    ...
  [stra|ci_id\0]
  [stra|ci_desc\0]
  [stra|ci_enc\0]

c ... 



static void 
un_alias (char *start, char *content)
{
	if (content[0] == 0x01)
		return (char *) (start + ((int) content[1]));

	return content;
}

static uint32
get_flags (CamelSummaryInfo *s, int segment, int n)
{
	int offset = n * sizeof (int);
	return (uint32) s->flags_mmaps [segment] [offset];
}

void load_it (CamelFolderSummary *s)
{
	int segment;

	for (segment = 0; segment < s->segment_cnt; segment++)
	{
		while (next != end_of(s->summary_mmaps[segment]))
		{
			CameMessageInfo *info = new..();

			offset = next;

			load_msg_info (s, segment, info, i, offset,
				 &next);

			camel_folder_summary_add (s, info);
			i++;
		}
	}
}

static void
load_msg_info (CamelSummaryInfo *s, int segment, CamelMessageInfo *info,
int n, int offset, int *next)
{
	char *start = s->summary_mmaps[segment];
	CamelMessageInfoBase *bi = (CamelMessageInfoBase *) info;
	CamelMessageContentInfo *ci;

	int cnt, i;
	char *type, *subtype;
	char *ptr = start + offset;	

	bi->flags = get_flags (s, segment, n);

	bi->message_id = ptr;
	ptr += 8;
	bi->uid = ptr;
	ptr += strlen (bi->uid);
	bi->subject = un_alias (start, ptr);
	ptr += strlen (bi->subject);
	bi->from = un_alias (start, ptr);
	ptr += strlen (bi->from);
	bi->to = un_alias (start, ptr);
	ptr += strlen (bi->to);
	bi->cc = un_alias (start, ptr);
	ptr += strlen (bi->cc);

	bi->size = (int) ptr;
	ptr += sizeof (int);
	bi->sent = (int) ptr;
	ptr += sizeof (int);
	bi->received = (int) ptr;
	ptr += sizeof (int);

	type = un_alias (start, ptr);
	ptr += strlen (type);
	subtype = un_alias (start, ptr);
	ptr += strlen (subtype);

	bi->content = camel_folder_summary_content_info_new (s);

	cnt = decode_uint32 (ptr, &ptr);

	for (i=0; i< cnt; i++)
	{
		char *name, *value;

		name = un_alias (start, ptr);
		ptr += strlen (name);
		value = un_alias (start, ptr);
		ptr += strlen (value);

		camel_content_type_set_param (bi->content, name, value);
	}

	bi->content->id = un_alias (start, ptr);
	ptr += strlen (bi->content->id);
	bi->content->description = un_alias (start, ptr);
	ptr += strlen (bi->content->description);
	bi->content->encoding = un_alias (start, ptr);
	ptr += strlen (bi->uid);

	*next = (int) ptr;
}


-- 
Philip Van Hoof, software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://www.pvanhoof.be/blog







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]