[dovecot-cvs] dovecot/src/lib-storage/index index-fetch-section.c,1.22,1.23 index-fetch.c,1.36,1.37 index-fetch.h,1.12,1.13

cras at procontrol.fi cras at procontrol.fi
Sun Dec 22 00:03:00 EET 2002


Update of /home/cvs/dovecot/src/lib-storage/index
In directory danu:/tmp/cvs-serv15300/lib-storage/index

Modified Files:
	index-fetch-section.c index-fetch.c index-fetch.h 
Log Message:
Replaced TempString with a String which can use any memory pool and uses
Buffer internally.



Index: index-fetch-section.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-fetch-section.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- index-fetch-section.c	19 Dec 2002 01:02:35 -0000	1.22
+++ index-fetch-section.c	21 Dec 2002 22:02:58 -0000	1.23
@@ -1,7 +1,7 @@
 /* Copyright (C) 2002 Timo Sirainen */
 
 #include "lib.h"
-#include "temp-string.h"
+#include "str.h"
 #include "istream.h"
 #include "ostream.h"
 #include "rfc822-tokenize.h"
@@ -138,7 +138,7 @@
 }
 
 typedef struct {
-	TempString *dest;
+	String *dest;
 	OStream *output;
 	uoff_t dest_size;
 
@@ -167,7 +167,7 @@
 	}
 
 	if (ctx->dest != NULL)
-		t_string_append_n(ctx->dest, str, size);
+		str_append_n(ctx->dest, str, size);
 	ctx->dest_size += size;
 
 	if (ctx->output != NULL) {
@@ -241,7 +241,7 @@
 	message_parse_header(NULL, input, NULL, fetch_header_field, ctx);
 
 	i_assert(ctx->dest_size <= ctx->max_size);
-	i_assert(ctx->dest == NULL || ctx->dest->len == ctx->dest_size);
+	i_assert(ctx->dest == NULL || str_len(ctx->dest) == ctx->dest_size);
 	return TRUE;
 }
 
@@ -288,8 +288,8 @@
 
 		i_assert(ctx.dest_size <= size->virtual_size);
 	} else {
-		ctx.dest = t_string_new(size->virtual_size < 4096 ?
-					size->virtual_size : 4096);
+		ctx.dest = t_str_new(size->virtual_size < 4096 ?
+				     size->virtual_size : 4096);
 		if (!fetch_header_fields(input, section, &ctx))
 			failed = TRUE;
 	}
@@ -315,8 +315,8 @@
 
 			i_assert(first_size == ctx.dest_size);
 		} else {
-			if (o_stream_send(output, ctx.dest->str,
-					  ctx.dest->len) < 0)
+			if (o_stream_send(output, str_c(ctx.dest),
+					  str_len(ctx.dest)) < 0)
 				failed = TRUE;
 		}
 	}

Index: index-fetch.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-fetch.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- index-fetch.c	19 Dec 2002 01:02:35 -0000	1.36
+++ index-fetch.c	21 Dec 2002 22:02:58 -0000	1.37
@@ -2,7 +2,7 @@
 
 #include "lib.h"
 #include "ostream.h"
-#include "temp-string.h"
+#include "str.h"
 #include "mail-custom-flags.h"
 #include "index-storage.h"
 #include "index-fetch.h"
@@ -20,8 +20,8 @@
 
 	date = imap_msgcache_get_internal_date(ctx->cache);
 	if (date != (time_t)-1) {
-		t_string_printfa(ctx->str, "INTERNALDATE \"%s\" ",
-				 imap_to_datetime(date));
+		str_printfa(ctx->str, "INTERNALDATE \"%s\" ",
+			    imap_to_datetime(date));
 		return TRUE;
 	} else {
 		mail_storage_set_critical(ctx->storage,
@@ -37,7 +37,7 @@
 
 	body = imap_msgcache_get(ctx->cache, IMAP_CACHE_BODY);
 	if (body != NULL) {
-		t_string_printfa(ctx->str, "BODY (%s) ", body);
+		str_printfa(ctx->str, "BODY (%s) ", body);
 		return TRUE;
 	} else {
 		mail_storage_set_critical(ctx->storage,
@@ -53,8 +53,7 @@
 
 	bodystructure = imap_msgcache_get(ctx->cache, IMAP_CACHE_BODYSTRUCTURE);
 	if (bodystructure != NULL) {
-		t_string_printfa(ctx->str, "BODYSTRUCTURE (%s) ",
-				 bodystructure);
+		str_printfa(ctx->str, "BODYSTRUCTURE (%s) ", bodystructure);
 		return TRUE;
 	} else {
 		mail_storage_set_critical(ctx->storage,
@@ -70,7 +69,7 @@
 
 	envelope = imap_msgcache_get(ctx->cache, IMAP_CACHE_ENVELOPE);
 	if (envelope != NULL) {
-		t_string_printfa(ctx->str, "ENVELOPE (%s) ", envelope);
+		str_printfa(ctx->str, "ENVELOPE (%s) ", envelope);
 		return TRUE;
 	} else {
 		mail_storage_set_critical(ctx->storage,
@@ -92,7 +91,7 @@
 		return FALSE;
 	}
 
-	t_string_printfa(ctx->str, "RFC822.SIZE %"PRIuUOFF_T" ", size);
+	str_printfa(ctx->str, "RFC822.SIZE %"PRIuUOFF_T" ", size);
 	return TRUE;
 }
 
@@ -106,14 +105,14 @@
 	if (ctx->update_seen)
 		flags |= MAIL_SEEN;
 
-	t_string_printfa(ctx->str, "FLAGS (%s) ",
-			 imap_write_flags(flags, ctx->custom_flags,
-					  ctx->custom_flags_count));
+	str_printfa(ctx->str, "FLAGS (%s) ",
+		    imap_write_flags(flags, ctx->custom_flags,
+				     ctx->custom_flags_count));
 }
 
 static void index_fetch_uid(MailIndexRecord *rec, FetchContext *ctx)
 {
-	t_string_printfa(ctx->str, "UID %u ", rec->uid);
+	str_printfa(ctx->str, "UID %u ", rec->uid);
 }
 
 static int index_fetch_send_rfc822(MailIndexRecord *rec, FetchContext *ctx)
@@ -244,7 +243,7 @@
 {
 	FetchContext *ctx = context;
 	MailFetchBodyData *sect;
-	unsigned int orig_len;
+	size_t len, orig_len;
 	int failed, data_written, fetch_flags;
 
 	/* first see what we need to do. this way we don't first do some
@@ -265,10 +264,10 @@
 		fetch_flags = FALSE;
 	}
 
-	ctx->str = t_string_new(2048);
+	ctx->str = t_str_new(2048);
 
-	t_string_printfa(ctx->str, "* %u FETCH (", client_seq);
-	orig_len = ctx->str->len;
+	str_printfa(ctx->str, "* %u FETCH (", client_seq);
+	orig_len = str_len(ctx->str);
 
 	failed = TRUE;
 	data_written = FALSE;
@@ -298,13 +297,14 @@
 
 		/* send the data written into temp string,
 		   not including the trailing zero */
-		ctx->first = ctx->str->len == orig_len;
-		if (ctx->str->len > 0) {
+		ctx->first = str_len(ctx->str) == orig_len;
+		len = str_len(ctx->str);
+		if (len > 0) {
 			if (!ctx->first)
-				ctx->str->len--;
+				str_truncate(ctx->str, len-1);
 
-			if (o_stream_send(ctx->output, ctx->str->str,
-					  ctx->str->len) < 0)
+			if (o_stream_send(ctx->output,
+					  str_c(ctx->str), len) < 0)
 				break;
 		}
 

Index: index-fetch.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-fetch.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- index-fetch.h	6 Dec 2002 01:09:23 -0000	1.12
+++ index-fetch.h	21 Dec 2002 22:02:58 -0000	1.13
@@ -12,7 +12,7 @@
 
 	MailFetchData *fetch_data;
 	OStream *output;
-	TempString *str;
+	String *str;
 	int update_seen, failed;
 	int first;
 } FetchContext;




More information about the dovecot-cvs mailing list