[dovecot-cvs] dovecot/src/lib-index/mbox mbox-rewrite.c,1.44,1.45

cras at procontrol.fi cras at procontrol.fi
Thu Dec 19 03:02:37 EET 2002


Update of /home/cvs/dovecot/src/lib-index/mbox
In directory danu:/tmp/cvs-serv11467/lib-index/mbox

Modified Files:
	mbox-rewrite.c 
Log Message:
Buffer related cleanups. Use PATH_MAX instead of hardcoded 1024 for paths.
Added str_path() and str_ppath() functions. i_snprintf() now returns only -1
or 0 depending on if buffer got full. dec2str() returns the string allocated
from data stack. Instead of just casting to (long) or (int), we now use
dec2str() with printf-like functions. Added o_stream_send_str(). Added
strocpy() and replaced all strcpy()s and strncpy()s with it.

Pretty much untested, hope it doesn't break too badly :)



Index: mbox-rewrite.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mbox/mbox-rewrite.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- mbox-rewrite.c	18 Dec 2002 15:15:41 -0000	1.44
+++ mbox-rewrite.c	19 Dec 2002 01:02:35 -0000	1.45
@@ -84,7 +84,7 @@
 
 	str = t_strdup_printf("X-IMAPbase: %u %u",
 			      ctx->uid_validity, ctx->uid_last);
-	if (o_stream_send(ctx->output, str, strlen(str)) < 0)
+	if (o_stream_send_str(ctx->output, str) < 0)
 		return FALSE;
 
 	for (i = 0; i < MAIL_CUSTOM_FLAGS_COUNT; i++) {
@@ -92,8 +92,8 @@
 			if (o_stream_send(ctx->output, " ", 1) < 0)
 				return FALSE;
 
-			if (o_stream_send(ctx->output, ctx->custom_flags[i],
-					  strlen(ctx->custom_flags[i])) < 0)
+			if (o_stream_send_str(ctx->output,
+					      ctx->custom_flags[i]) < 0)
 				return FALSE;
 		}
 	}
@@ -113,7 +113,7 @@
 	    x_keywords == NULL)
 		return TRUE;
 
-	if (o_stream_send(ctx->output, "X-Keywords:", 11) < 0)
+	if (o_stream_send_str(ctx->output, "X-Keywords:") < 0)
 		return FALSE;
 
 	field = 1 << MAIL_CUSTOM_FLAG_1_BIT;
@@ -122,8 +122,8 @@
 			if (o_stream_send(ctx->output, " ", 1) < 0)
 				return FALSE;
 
-			if (o_stream_send(ctx->output, ctx->custom_flags[i],
-					  strlen(ctx->custom_flags[i])) < 0)
+			if (o_stream_send_str(ctx->output,
+					      ctx->custom_flags[i]) < 0)
 				return FALSE;
 		}
 	}
@@ -133,8 +133,7 @@
 		if (o_stream_send(ctx->output, " ", 1) < 0)
 			return FALSE;
 
-		if (o_stream_send(ctx->output, x_keywords,
-				  strlen(x_keywords)) < 0)
+		if (o_stream_send_str(ctx->output, x_keywords) < 0)
 			return FALSE;
 	}
 
@@ -152,7 +151,7 @@
 	if (status != NULL)
 		str = t_strconcat(str, status, NULL);
 
-	if (o_stream_send(ctx->output, str, strlen(str)) < 0)
+	if (o_stream_send_str(ctx->output, str) < 0)
 		return FALSE;
 	if (o_stream_send(ctx->output, "\n", 1) < 0)
 		return FALSE;
@@ -176,7 +175,7 @@
 			  (ctx->msg_flags & MAIL_DELETED) ? "T" : "",
 			  x_status, NULL);
 
-	if (o_stream_send(ctx->output, str, strlen(str)) < 0)
+	if (o_stream_send_str(ctx->output, str) < 0)
 		return FALSE;
 	if (o_stream_send(ctx->output, "\n", 1) < 0)
 		return FALSE;
@@ -191,7 +190,7 @@
 	i_snprintf(str, sizeof(str), "Content-Length: %"PRIuUOFF_T"\n",
 		   ctx->content_length);
 
-	if (o_stream_send(ctx->output, str, strlen(str)) < 0)
+	if (o_stream_send_str(ctx->output, str) < 0)
 		return FALSE;
 	return TRUE;
 }




More information about the dovecot-cvs mailing list