[dovecot-cvs] dovecot/src/imap client.c,1.13,1.14 client.h,1.4,1.5 cmd-append.c,1.14,1.15 cmd-fetch.c,1.8,1.9 cmd-search.c,1.6,1.7 cmd-sort.c,1.1,1.2 mail-storage-callbacks.c,1.2,1.3

cras at procontrol.fi cras at procontrol.fi
Fri Dec 6 03:09:24 EET 2002


Update of /home/cvs/dovecot/src/imap
In directory danu:/tmp/cvs-serv6082/imap

Modified Files:
	client.c client.h cmd-append.c cmd-fetch.c cmd-search.c 
	cmd-sort.c mail-storage-callbacks.c 
Log Message:
Renamed IBuffer and OBuffer to IStream and OStream which describes their
functionality better. I tried to keep the variable names and comments also
sensible.



Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- client.c	30 Nov 2002 16:32:20 -0000	1.13
+++ client.c	6 Dec 2002 01:09:22 -0000	1.14
@@ -3,8 +3,8 @@
 #include "common.h"
 #include "ioloop.h"
 #include "network.h"
-#include "ibuffer.h"
-#include "obuffer.h"
+#include "istream.h"
+#include "ostream.h"
 #include "commands.h"
 
 #include <stdlib.h>
@@ -36,8 +36,8 @@
 {
 	Client *client = context;
 
-	i_buffer_close(client->inbuf);
-	o_buffer_close(client->outbuf);
+	i_stream_close(client->input);
+	o_stream_close(client->output);
 }
 
 static void client_input_timeout(void *context)
@@ -46,7 +46,7 @@
 
 	client_send_line(my_client, "* BYE Disconnected for inactivity "
 			 "while waiting for command data.");
-	o_buffer_close(client->outbuf);
+	o_stream_close(client->output);
 }
 
 Client *client_create(int hin, int hout, MailStorage *storage)
@@ -54,9 +54,9 @@
 	Client *client;
 
 	client = i_new(Client, 1);
-	client->inbuf = i_buffer_create_file(hin, default_pool,
+	client->input = i_stream_create_file(hin, default_pool,
 					     MAX_INBUF_SIZE, FALSE);
-	client->outbuf = o_buffer_create_file(hout, default_pool, 4096,
+	client->output = o_stream_create_file(hout, default_pool, 4096,
 					      IO_PRIORITY_DEFAULT, FALSE);
 
 	/* always use nonblocking I/O */
@@ -65,15 +65,15 @@
 
 	/* set timeout for reading expected data (eg. APPEND). This is
 	   different from the actual idle time. */
-	i_buffer_set_blocking(client->inbuf, CLIENT_CMDINPUT_TIMEOUT,
+	i_stream_set_blocking(client->input, CLIENT_CMDINPUT_TIMEOUT,
 			      client_input_timeout, client);
 
 	/* set timeout for sending data */
-	o_buffer_set_blocking(client->outbuf, CLIENT_OUTPUT_TIMEOUT,
+	o_stream_set_blocking(client->output, CLIENT_OUTPUT_TIMEOUT,
 			      client_output_timeout, client);
 
 	client->io = io_add(hin, IO_READ, (IOFunc) client_input, client);
-	client->parser = imap_parser_create(client->inbuf, client->outbuf,
+	client->parser = imap_parser_create(client->input, client->output,
 					    MAX_INBUF_SIZE);
         client->last_input = ioloop_time;
 
@@ -87,7 +87,7 @@
 
 void client_destroy(Client *client)
 {
-	o_buffer_flush(client->outbuf);
+	o_stream_flush(client->output);
 
 	if (client->mailbox != NULL)
 		client->mailbox->close(client->mailbox);
@@ -96,8 +96,8 @@
 	imap_parser_destroy(client->parser);
 	io_remove(client->io);
 
-	i_buffer_unref(client->inbuf);
-	o_buffer_unref(client->outbuf);
+	i_stream_unref(client->input);
+	o_stream_unref(client->output);
 
 	i_free(client);
 
@@ -108,35 +108,35 @@
 
 void client_disconnect(Client *client)
 {
-	o_buffer_flush(client->outbuf);
+	o_stream_flush(client->output);
 
-	i_buffer_close(client->inbuf);
-	o_buffer_close(client->outbuf);
+	i_stream_close(client->input);
+	o_stream_close(client->output);
 }
 
 void client_send_line(Client *client, const char *data)
 {
-	if (client->outbuf->closed)
+	if (client->output->closed)
 		return;
 
-	(void)o_buffer_send(client->outbuf, data, strlen(data));
-	(void)o_buffer_send(client->outbuf, "\r\n", 2);
+	(void)o_stream_send(client->output, data, strlen(data));
+	(void)o_stream_send(client->output, "\r\n", 2);
 }
 
 void client_send_tagline(Client *client, const char *data)
 {
 	const char *tag = client->cmd_tag;
 
-	if (client->outbuf->closed)
+	if (client->output->closed)
 		return;
 
 	if (tag == NULL || *tag == '\0')
 		tag = "*";
 
-	(void)o_buffer_send(client->outbuf, tag, strlen(tag));
-	(void)o_buffer_send(client->outbuf, " ", 1);
-	(void)o_buffer_send(client->outbuf, data, strlen(data));
-	(void)o_buffer_send(client->outbuf, "\r\n", 2);
+	(void)o_stream_send(client->output, tag, strlen(tag));
+	(void)o_stream_send(client->output, " ", 1);
+	(void)o_stream_send(client->output, data, strlen(data));
+	(void)o_stream_send(client->output, "\r\n", 2);
 }
 
 void client_send_command_error(Client *client, const char *msg)
@@ -220,7 +220,7 @@
 
 static void client_command_finished(Client *client)
 {
-	client->inbuf_skip_line = TRUE;
+	client->input_skip_line = TRUE;
         client_reset_command(client);
 }
 
@@ -231,18 +231,17 @@
 	const unsigned char *data;
 	size_t i, data_size;
 
-	/* get the beginning of data in input buffer */
-	data = i_buffer_get_data(client->inbuf, &data_size);
+	data = i_stream_get_data(client->input, &data_size);
 
 	for (i = 0; i < data_size; i++) {
 		if (data[i] == '\n') {
-			client->inbuf_skip_line = FALSE;
-			i_buffer_skip(client->inbuf, i+1);
+			client->input_skip_line = FALSE;
+			i_stream_skip(client->input, i+1);
 			break;
 		}
 	}
 
-	return !client->inbuf_skip_line;
+	return !client->input_skip_line;
 }
 
 static int client_handle_input(Client *client)
@@ -257,7 +256,7 @@
 		return FALSE;
 	}
 
-	if (client->inbuf_skip_line) {
+	if (client->input_skip_line) {
 		/* we're just waiting for new line.. */
 		if (!client_skip_line(client))
 			return FALSE;
@@ -306,7 +305,7 @@
 {
 	client->last_input = ioloop_time;
 
-	switch (i_buffer_read(client->inbuf)) {
+	switch (i_stream_read(client->input)) {
 	case -1:
 		/* disconnected */
 		client_destroy(client);
@@ -315,19 +314,19 @@
 		/* parameter word is longer than max. input buffer size.
 		   this is most likely an error, so skip the new data
 		   until newline is found. */
-		client->inbuf_skip_line = TRUE;
+		client->input_skip_line = TRUE;
 
 		client_send_command_error(client, "Too long argument.");
 		client_command_finished(client);
 		break;
 	}
 
-	o_buffer_cork(client->outbuf);
+	o_stream_cork(client->output);
 	while (client_handle_input(client))
 		;
-	o_buffer_flush(client->outbuf);
+	o_stream_flush(client->output);
 
-	if (client->outbuf->closed)
+	if (client->output->closed)
 		client_destroy(client);
 }
 

Index: client.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- client.h	29 Oct 2002 06:29:17 -0000	1.4
+++ client.h	6 Dec 2002 01:09:22 -0000	1.5
@@ -11,8 +11,8 @@
 struct _Client {
 	int socket;
 	IO io;
-	IBuffer *inbuf;
-	OBuffer *outbuf;
+	IStream *input;
+	OStream *output;
 
 	MailStorage *storage;
 	Mailbox *mailbox;
@@ -29,7 +29,7 @@
 	unsigned int cmd_uid:1; /* used UID command */
 	unsigned int sync_flags_send_uid:1;
 	unsigned int rawlog:1;
-	unsigned int inbuf_skip_line:1; /* skip all the data until we've
+	unsigned int input_skip_line:1; /* skip all the data until we've
 					   found a new line */
 };
 

Index: cmd-append.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-append.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cmd-append.c	28 Oct 2002 09:46:02 -0000	1.14
+++ cmd-append.c	6 Dec 2002 01:09:22 -0000	1.15
@@ -2,7 +2,7 @@
 
 #include "common.h"
 #include "ioloop.h"
-#include "obuffer.h"
+#include "ostream.h"
 #include "commands.h"
 #include "imap-parser.h"
 #include "imap-date.h"
@@ -126,13 +126,13 @@
 		return TRUE;
 	}
 
-	o_buffer_send(client->outbuf, "+ OK\r\n", 6);
-	o_buffer_flush(client->outbuf);
+	o_stream_send(client->output, "+ OK\r\n", 6);
+	o_stream_flush(client->output);
 
 	/* save the mail */
 	failed = !box->save(box, flags, custom_flags,
 			    internal_date, timezone_offset,
-			    client->inbuf, msg_size);
+			    client->input, msg_size);
 	box->close(box);
 
 	if (failed) {

Index: cmd-fetch.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-fetch.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cmd-fetch.c	19 Oct 2002 14:51:59 -0000	1.8
+++ cmd-fetch.c	6 Dec 2002 01:09:22 -0000	1.9
@@ -264,7 +264,7 @@
 
 	/* fetch it */
 	if (client->mailbox->fetch(client->mailbox, &data,
-				   client->outbuf, &all_found)) {
+				   client->output, &all_found)) {
 		/* NOTE: syncing isn't allowed here */
                 client_sync_without_expunges(client);
 		client_send_tagline(client, all_found ? "OK Fetch completed." :

Index: cmd-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-search.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cmd-search.c	4 Dec 2002 18:28:37 -0000	1.6
+++ cmd-search.c	6 Dec 2002 01:09:22 -0000	1.7
@@ -51,7 +51,7 @@
 	} else {
 		if (client->mailbox->search(client->mailbox, charset,
 					    sargs, NULL,
-					    client->outbuf, client->cmd_uid)) {
+					    client->output, client->cmd_uid)) {
 			/* NOTE: syncing isn't allowed here */
 			client_sync_without_expunges(client);
 			client_send_tagline(client, "OK Search completed.");

Index: cmd-sort.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-sort.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmd-sort.c	4 Dec 2002 18:28:37 -0000	1.1
+++ cmd-sort.c	6 Dec 2002 01:09:22 -0000	1.2
@@ -120,7 +120,7 @@
 	} else {
 		if (client->mailbox->search(client->mailbox, charset,
 					    sargs, sorting,
-					    client->outbuf, client->cmd_uid)) {
+					    client->output, client->cmd_uid)) {
 			/* NOTE: syncing is allowed when returning UIDs */
 			if (client->cmd_uid)
 				client_sync_full(client);

Index: mail-storage-callbacks.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/mail-storage-callbacks.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mail-storage-callbacks.c	26 Nov 2002 13:07:53 -0000	1.2
+++ mail-storage-callbacks.c	6 Dec 2002 01:09:22 -0000	1.3
@@ -1,7 +1,7 @@
 /* Copyright (C) 2002 Timo Sirainen */
 
 #include "common.h"
-#include "obuffer.h"
+#include "ostream.h"
 #include "imap-util.h"
 #include "commands-util.h"
 
@@ -19,7 +19,7 @@
 	Client *client = context;
 
 	client_send_line(client, t_strconcat("* OK ", text, NULL));
-	o_buffer_flush(client->outbuf);
+	o_stream_flush(client->output);
 }
 
 static void notify_no(Mailbox *mailbox __attr_unused__,
@@ -28,7 +28,7 @@
 	Client *client = context;
 
 	client_send_line(client, t_strconcat("* NO ", text, NULL));
-	o_buffer_flush(client->outbuf);
+	o_stream_flush(client->output);
 }
 
 static void expunge(Mailbox *mailbox, unsigned int seq, void *context)




More information about the dovecot-cvs mailing list