/**
* camel_mbox_parse_file: read an mbox file and parse it.
* @fd: file descriptor opened on the mbox file.
- * @message_delimiter: character string delimiting the beginig of a new message
- * @start_position: poition in the file where to start the parsing.
- * @get_message_summary: should the parser retrieve the begining of the messages
- * @status_callback: function to call peridically to indicate the progress of the parser
- * @status_interval: floating value between 0 and 1 indicate how often to call @status_callback.
+ * @message_delimiter: character string delimiting the beginig of a
+ * new message
+ * @start_position: position in the file where to start the parsing.
+ * @file_size: on output, the size in bytes of the file
+ * @next_uid: on output, the next uid available for use
+ * @get_message_summary: should the parser retrieve the begining of
+ * the messages
+ * @status_callback: function to call peridically to indicate the
+ * progress of the parser
+ * @status_interval: floating value between 0 and 1 indicate how often
+ * to call @status_callback.
* @user_data: user data that will be passed to the callback function
*
- * This routine parses an mbox file and retreives both the message starting positions and
- * some of the informations contained in the message. Those informations are mainly
- * some RFC822 headers values but also (optionally) the first characters of the mail
- * body. The @get_message_summary parameter allows to enable or disable this option.
+ * This routine parses an mbox file and retreives both the message
+ * starting positions and some of the informations contained in the
+ * message. Those informations are mainly some RFC822 headers values
+ * but also (optionally) the first characters of the mail body. The
+ * @get_message_summary parameter allows to enable or disable this
+ * option.
*
*
- * Return value: An array of CamelMboxParserMessageInfo containing the informations on each message parsed in the file
+ * Return value: An array of CamelMboxParserMessageInfo containing the
+ * informations on each message parsed in the file
**/
GArray *
camel_mbox_parse_file (int fd,
G_STRUCT_OFFSET (CamelMboxPreParser, current_message_info) +
G_STRUCT_OFFSET (CamelMboxParserMessageInfo, status)));
g_free (x_ev_header_content);
- next_available_uid = MAX (next_available_uid, parser->current_message_info.uid);
+ next_available_uid = MAX (next_available_uid, parser->current_message_info.uid + 1);
newline = TRUE;
continue;
gint fd;
gint write_result; /* XXX use this */
guint32 data;
+ struct stat st;
CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::save_summary entering \n");
* that makes sense, but because it's easy.
*/
- data = htons (CAMEL_MBOX_SUMMARY_VERSION);
+ data = htonl (CAMEL_MBOX_SUMMARY_VERSION);
write (fd, &data, sizeof (data));
- data = htons (summary->nb_message);
+ data = htonl (summary->nb_message);
write (fd, &data, sizeof (data));
- data = htons (summary->next_uid);
+ data = htonl (summary->next_uid);
write (fd, &data, sizeof (data));
- data = htons (summary->mbox_file_size);
+ data = htonl (summary->mbox_file_size);
write (fd, &data, sizeof (data));
- data = htons (summary->mbox_modtime);
+ data = htonl (summary->mbox_modtime);
write (fd, &data, sizeof (data));
for (cur_msg = 0; cur_msg < summary->nb_message; cur_msg++) {
(summary->message_info->data) + cur_msg;
/* Write meta-info. */
- data = htons (msg_info->position);
+ data = htonl (msg_info->position);
write (fd, &data, sizeof (data));
- data = htons (msg_info->size);
+ data = htonl (msg_info->size);
write (fd, &data, sizeof (data));
- data = htons (msg_info->x_evolution_offset);
+ data = htonl (msg_info->x_evolution_offset);
write (fd, &data, sizeof (data));
- data = htons (msg_info->uid);
+ data = htonl (msg_info->uid);
write (fd, &data, sizeof (data));
write (fd, &msg_info->status, 1);
/* Write subject. */
if (msg_info->headers.subject)
- field_length = htons (strlen (msg_info->headers.subject));
+ field_length = strlen (msg_info->headers.subject);
else
field_length = 0;
- write (fd, &field_length, sizeof (field_length));
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
if (msg_info->headers.subject)
write (fd, msg_info->headers.subject, field_length);
/* Write sender. */
if (msg_info->headers.sender)
- field_length = htons (strlen (msg_info->headers.sender));
+ field_length = strlen (msg_info->headers.sender);
else
field_length = 0;
- write (fd, &field_length, sizeof (field_length));
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
if (msg_info->headers.sender)
write (fd, msg_info->headers.sender, field_length);
/* Write to. */
if (msg_info->headers.to)
- field_length = htons (strlen (msg_info->headers.to));
+ field_length = strlen (msg_info->headers.to);
else
field_length = 0;
- write (fd, &field_length, sizeof (field_length));
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
if (msg_info->headers.to)
write (fd, msg_info->headers.to, field_length);
/* Write sent date. */
if (msg_info->headers.sent_date)
- field_length = htons (strlen (msg_info->headers.sent_date));
+ field_length = strlen (msg_info->headers.sent_date);
else
field_length = 0;
- write (fd, &field_length, sizeof (field_length));
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
if (msg_info->headers.sent_date)
write (fd, msg_info->headers.sent_date, field_length);
/* Write received date. */
if (msg_info->headers.received_date)
- field_length = htons (strlen (msg_info->headers.received_date));
+ field_length = strlen (msg_info->headers.received_date);
else
field_length = 0;
- write (fd, &field_length, sizeof (field_length));
+ data = htonl (field_length);
+ write (fd, &data, sizeof (data));
if (msg_info->headers.received_date)
write (fd, msg_info->headers.received_date, field_length);
}
-
+
close (fd);
CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::save_summary leaving \n");
/* Verify version number. */
read (fd, &data, sizeof(data));
- data = ntohs (data);
+ data = ntohl (data);
if (data != CAMEL_MBOX_SUMMARY_VERSION) {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_SUMMARY_INVALID,
summary = CAMEL_MBOX_SUMMARY (gtk_object_new (camel_mbox_summary_get_type (), NULL));
read (fd, &data, sizeof(data));
- summary->nb_message = ntohs (data);
+ summary->nb_message = ntohl (data);
read (fd, &data, sizeof(data));
- summary->next_uid = ntohs (data);
+ summary->next_uid = ntohl (data);
read (fd, &data, sizeof(data));
- summary->mbox_file_size = ntohs (data);
+ summary->mbox_file_size = ntohl (data);
read (fd, &data, sizeof(data));
- summary->mbox_modtime = ntohs (data);
+ summary->mbox_modtime = ntohl (data);
summary->message_info =
g_array_new (FALSE, FALSE,
/* Read the meta-info. */
read (fd, &data, sizeof(data));
- msg_info->position = ntohs (data);
+ msg_info->position = ntohl (data);
read (fd, &data, sizeof(data));
- msg_info->size = ntohs (data);
+ msg_info->size = ntohl (data);
read (fd, &data, sizeof(data));
- msg_info->x_evolution_offset = ntohs (data);
- read (fd, &(msg_info->status), 1);
+ msg_info->x_evolution_offset = ntohl (data);
read (fd, &data, sizeof(data));
- msg_info->uid = ntohs (data);
+ msg_info->uid = ntohl (data);
msg_info->headers.uid = g_strdup_printf ("%d", msg_info->uid);
read (fd, &msg_info->status, 1);
/* Read the subject. */
read (fd, &field_length, sizeof (field_length));
- field_length = ntohs (field_length);
+ field_length = ntohl (field_length);
if (field_length > 0) {
msg_info->headers.subject =
g_new0 (gchar, field_length + 1);
/* Read the sender. */
read (fd, &field_length, sizeof (field_length));
- field_length = ntohs (field_length);
+ field_length = ntohl (field_length);
if (field_length > 0) {
msg_info->headers.sender =
g_new0 (gchar, field_length + 1);
/* Read the "to" field. */
read (fd, &field_length, sizeof (field_length));
- field_length = ntohs (field_length);
+ field_length = ntohl (field_length);
if (field_length > 0) {
msg_info->headers.to =
g_new0 (gchar, field_length + 1);
/* Read the sent date field. */
read (fd, &field_length, sizeof (field_length));
- field_length = ntohs (field_length);
+ field_length = ntohl (field_length);
if (field_length > 0) {
msg_info->headers.sent_date =
g_new0 (gchar, field_length + 1);
/* Read the received date field. */
read (fd, &field_length, sizeof (field_length));
- field_length = ntohs (field_length);
+ field_length = ntohl (field_length);
if (field_length > 0) {
msg_info->headers.received_date =
g_new0 (gchar, field_length + 1);