[evolution-patches] soup-transfer type patch
- From: Dan Winship <danw ximian com>
- To: evolution-patches ximian com, Joe Shaw <joe ximian com>
- Subject: [evolution-patches] soup-transfer type patch
- Date: 11 Jun 2003 13:47:34 -0400
This gets rid of the pointer/int casting in SoupTransfer. This is just a
prologue to a real patch, wherein I try to finally fix the refcounting
situation...
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libsoup/ChangeLog,v
retrieving revision 1.311
diff -u -r1.311 ChangeLog
--- ChangeLog 2 Jun 2003 20:47:17 -0000 1.311
+++ ChangeLog 11 Jun 2003 17:36:48 -0000
@@ -1,3 +1,11 @@
+2003-06-11 Dan Winship <danw ximian com>
+
+ * libsoup/soup-transfer.c: Change all functions to take a
+ SoupReader * or SoupWriter * instead of a guint.
+
+ * libsoup/soup-private.h (SoupMessagePrivate): make read_tag and
+ write_tag pointers instead of guints.
+
2003-06-02 Chris Toshok <toshok ximian com>
* libsoup/soup-ssl.c: remove #include for soup-nss.h
Index: libsoup/soup-private.h
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-private.h,v
retrieving revision 1.54
diff -u -r1.54 soup-private.h
--- libsoup/soup-private.h 9 May 2003 15:25:31 -0000 1.54
+++ libsoup/soup-private.h 11 Jun 2003 17:36:48 -0000
@@ -104,8 +104,8 @@
struct _SoupMessagePrivate {
SoupConnectId connect_tag;
- guint read_tag;
- guint write_tag;
+ gpointer read_tag;
+ gpointer write_tag;
guint timeout_tag;
guint retries;
Index: libsoup/soup-transfer.c
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-transfer.c,v
retrieving revision 1.30
diff -u -r1.30 soup-transfer.c
--- libsoup/soup-transfer.c 9 May 2003 15:25:33 -0000 1.30
+++ libsoup/soup-transfer.c 11 Jun 2003 17:36:48 -0000
@@ -61,7 +61,7 @@
guint idx;
} SoupTransferChunkState;
-typedef struct {
+struct _SoupReader {
GIOChannel *channel;
guint read_tag;
guint err_tag;
@@ -89,9 +89,9 @@
SoupReadDoneFn read_done_cb;
SoupReadErrorFn error_cb;
gpointer user_data;
-} SoupReader;
+};
-typedef struct {
+struct _SoupWriter {
GIOChannel *channel;
guint write_tag;
guint err_tag;
@@ -109,16 +109,14 @@
SoupWriteDoneFn write_done_cb;
SoupWriteErrorFn error_cb;
gpointer user_data;
-} SoupWriter;
+};
#define IGNORE_CANCEL(t, cancel_p) (t)->cancelled = cancel_p;
#define UNIGNORE_CANCEL(t) (t)->cancelled = NULL;
void
-soup_transfer_read_cancel (guint tag)
+soup_transfer_read_cancel (SoupReader *r)
{
- SoupReader *r = GINT_TO_POINTER (tag);
-
if (r->cancelled) {
*(r->cancelled) = TRUE;
return;
@@ -135,15 +133,13 @@
}
void
-soup_transfer_read_set_callbacks (guint tag,
+soup_transfer_read_set_callbacks (SoupReader *r,
SoupReadHeadersDoneFn headers_done_cb,
SoupReadChunkFn read_chunk_cb,
SoupReadDoneFn read_done_cb,
SoupReadErrorFn error_cb,
gpointer user_data)
{
- SoupReader *r = GINT_TO_POINTER (tag);
-
r->headers_done_cb = headers_done_cb;
r->read_chunk_cb = read_chunk_cb;
r->read_done_cb = read_done_cb;
@@ -199,7 +195,7 @@
CANCELLED:
UNIGNORE_CANCEL (r);
- soup_transfer_read_cancel (GPOINTER_TO_INT (r));
+ soup_transfer_read_cancel (r);
return FALSE;
}
@@ -517,12 +513,12 @@
UNIGNORE_CANCEL (r);
FINISH_READ:
- soup_transfer_read_cancel (GPOINTER_TO_INT (r));
+ soup_transfer_read_cancel (r);
return FALSE;
}
-guint
+SoupReader *
soup_transfer_read (GIOChannel *chan,
gboolean overwrite_chunks,
SoupReadHeadersDoneFn headers_done_cb,
@@ -556,14 +552,12 @@
(GIOFunc) soup_transfer_read_error_cb,
reader);
- return GPOINTER_TO_INT (reader);
+ return reader;
}
void
-soup_transfer_write_cancel (guint tag)
+soup_transfer_write_cancel (SoupWriter *w)
{
- SoupWriter *w = GINT_TO_POINTER (tag);
-
if (w->cancelled) {
*(w->cancelled) = TRUE;
return;
@@ -591,7 +585,7 @@
UNIGNORE_CANCEL (w);
}
- soup_transfer_write_cancel (GPOINTER_TO_INT (w));
+ soup_transfer_write_cancel (w);
return FALSE;
}
@@ -755,7 +749,7 @@
}
CANCEL:
- soup_transfer_write_cancel (GPOINTER_TO_INT (w));
+ soup_transfer_write_cancel (w);
DONE_WRITING:
RESTORE_PIPE (pipe_handler);
@@ -799,7 +793,7 @@
return writer;
}
-guint
+SoupWriter *
soup_transfer_write_simple (GIOChannel *chan,
GString *header,
const SoupDataBuffer *src,
@@ -827,10 +821,10 @@
src->body,
src->length);
- return GPOINTER_TO_INT (writer);
+ return writer;
}
-guint
+SoupWriter *
soup_transfer_write (GIOChannel *chan,
SoupTransferEncoding encoding,
SoupWriteGetHeaderFn get_header_cb,
@@ -850,15 +844,13 @@
writer->get_header_cb = get_header_cb;
writer->get_chunk_cb = get_chunk_cb;
- return GPOINTER_TO_INT (writer);
+ return writer;
}
void
-soup_transfer_write_pause (guint tag)
+soup_transfer_write_pause (SoupWriter *w)
{
- SoupWriter *w = GINT_TO_POINTER (tag);
-
- g_return_if_fail (tag != 0);
+ g_return_if_fail (w != NULL);
if (w->write_tag) {
g_source_remove (w->write_tag);
@@ -867,11 +859,9 @@
}
void
-soup_transfer_write_unpause (guint tag)
+soup_transfer_write_unpause (SoupWriter *w)
{
- SoupWriter *w = GINT_TO_POINTER (tag);
-
- g_return_if_fail (tag != 0);
+ g_return_if_fail (w != NULL);
if (!w->write_tag) {
w->write_tag =
Index: libsoup/soup-transfer.h
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-transfer.h,v
retrieving revision 1.6
diff -u -r1.6 soup-transfer.h
--- libsoup/soup-transfer.h 15 Nov 2002 16:26:43 -0000 1.6
+++ libsoup/soup-transfer.h 11 Jun 2003 17:36:48 -0000
@@ -26,6 +26,9 @@
SOUP_TRANSFER_CONTENT_LENGTH,
} SoupTransferEncoding;
+typedef struct _SoupReader SoupReader;
+typedef struct _SoupWriter SoupWriter;
+
typedef SoupTransferDone (*SoupReadHeadersDoneFn) (
const GString *headers,
SoupTransferEncoding *encoding,
@@ -40,17 +43,17 @@
typedef void (*SoupReadErrorFn) (gboolean headers_done, gpointer user_data);
-guint soup_transfer_read (GIOChannel *chan,
- gboolean overwrite_chunks,
- SoupReadHeadersDoneFn headers_done_cb,
- SoupReadChunkFn read_chunk_cb,
- SoupReadDoneFn read_done_cb,
- SoupReadErrorFn error_cb,
- gpointer user_data);
+SoupReader *soup_transfer_read (GIOChannel *chan,
+ gboolean overwrite_chunks,
+ SoupReadHeadersDoneFn headers_done_cb,
+ SoupReadChunkFn read_chunk_cb,
+ SoupReadDoneFn read_done_cb,
+ SoupReadErrorFn error_cb,
+ gpointer user_data);
-void soup_transfer_read_cancel (guint tag);
+void soup_transfer_read_cancel (SoupReader *r);
-void soup_transfer_read_set_callbacks (guint tag,
+void soup_transfer_read_set_callbacks (SoupReader *r,
SoupReadHeadersDoneFn headers_done_cb,
SoupReadChunkFn read_chunk_cb,
SoupReadDoneFn read_done_cb,
@@ -62,12 +65,12 @@
typedef void (*SoupWriteErrorFn) (gboolean headers_done, gpointer user_data);
-guint soup_transfer_write_simple (GIOChannel *chan,
- GString *header,
- const SoupDataBuffer *src,
- SoupWriteDoneFn write_done_cb,
- SoupWriteErrorFn error_cb,
- gpointer user_data);
+SoupWriter *soup_transfer_write_simple (GIOChannel *chan,
+ GString *header,
+ const SoupDataBuffer *src,
+ SoupWriteDoneFn write_done_cb,
+ SoupWriteErrorFn error_cb,
+ gpointer user_data);
typedef void (*SoupWriteGetHeaderFn) (GString **out_hdr,
gpointer user_data);
@@ -75,18 +78,18 @@
typedef SoupTransferDone (*SoupWriteGetChunkFn) (SoupDataBuffer *out_next,
gpointer user_data);
-guint soup_transfer_write (GIOChannel *chan,
- SoupTransferEncoding encoding,
- SoupWriteGetHeaderFn get_header_cb,
- SoupWriteGetChunkFn get_chunk_cb,
- SoupWriteDoneFn write_done_cb,
- SoupWriteErrorFn error_cb,
- gpointer user_data);
+SoupWriter *soup_transfer_write (GIOChannel *chan,
+ SoupTransferEncoding encoding,
+ SoupWriteGetHeaderFn get_header_cb,
+ SoupWriteGetChunkFn get_chunk_cb,
+ SoupWriteDoneFn write_done_cb,
+ SoupWriteErrorFn error_cb,
+ gpointer user_data);
-void soup_transfer_write_pause (guint tag);
+void soup_transfer_write_pause (SoupWriter *w);
-void soup_transfer_write_unpause (guint tag);
+void soup_transfer_write_unpause (SoupWriter *w);
-void soup_transfer_write_cancel (guint tag);
+void soup_transfer_write_cancel (SoupWriter *w);
#endif /*SOUP_TRANSFER_H*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]