You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2013/01/11 11:43:25 UTC
[2/6] THRIFT-1826 update c_glib source header paths Patch: Simon South
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_buffered_transport.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_buffered_transport.c b/lib/c_glib/src/thrift/transport/thrift_buffered_transport.c
deleted file mode 100644
index 1193b13..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_buffered_transport.c
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <assert.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <thrift/thrift.h>
-#include <thrift/transport/thrift_transport.h>
-#include <thrift/transport/thrift_buffered_transport.h>
-
-/* object properties */
-enum _ThriftBufferedTransportProperties
-{
- PROP_0,
- PROP_THRIFT_BUFFERED_TRANSPORT_TRANSPORT,
- PROP_THRIFT_BUFFERED_TRANSPORT_READ_BUFFER_SIZE,
- PROP_THRIFT_BUFFERED_TRANSPORT_WRITE_BUFFER_SIZE
-};
-
-G_DEFINE_TYPE(ThriftBufferedTransport, thrift_buffered_transport, THRIFT_TYPE_TRANSPORT)
-
-/* implements thrift_transport_is_open */
-gboolean
-thrift_buffered_transport_is_open (ThriftTransport *transport)
-{
- ThriftBufferedTransport *t = THRIFT_BUFFERED_TRANSPORT (transport);
- return THRIFT_TRANSPORT_GET_CLASS (t->transport)->is_open (t->transport);
-}
-
-/* implements thrift_transport_open */
-gboolean
-thrift_buffered_transport_open (ThriftTransport *transport, GError **error)
-{
- ThriftBufferedTransport *t = THRIFT_BUFFERED_TRANSPORT (transport);
- return THRIFT_TRANSPORT_GET_CLASS (t->transport)->open (t->transport, error);
-}
-
-/* implements thrift_transport_close */
-gboolean
-thrift_buffered_transport_close (ThriftTransport *transport, GError **error)
-{
- ThriftBufferedTransport *t = THRIFT_BUFFERED_TRANSPORT (transport);
- return THRIFT_TRANSPORT_GET_CLASS (t->transport)->close (t->transport, error);
-}
-
-/* the actual read is "slow" because it calls the underlying transport */
-gint32
-thrift_buffered_transport_read_slow (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error)
-{
- ThriftBufferedTransport *t = THRIFT_BUFFERED_TRANSPORT (transport);
- guint32 want = len;
- guint32 got = 0;
- guchar tmpdata[len];
- guint32 have = t->r_buf->len;
-
- // we shouldn't hit this unless the buffer doesn't have enough to read
- assert (t->r_buf->len < want);
-
- // first copy what we have in our buffer.
- if (have > 0)
- {
- memcpy (buf, t->r_buf, t->r_buf->len);
- want -= t->r_buf->len;
- t->r_buf = g_byte_array_remove_range (t->r_buf, 0, t->r_buf->len);
- }
-
- // if the buffer is still smaller than what we want to read, then just
- // read it directly. otherwise, fill the buffer and then give out
- // enough to satisfy the read.
- if (t->r_buf_size < want)
- {
- got += THRIFT_TRANSPORT_GET_CLASS (t->transport)->read (t->transport,
- tmpdata,
- want,
- error);
-
- // copy the data starting from where we left off
- memcpy (buf + have, tmpdata, got);
- return got + have;
- } else {
- got += THRIFT_TRANSPORT_GET_CLASS (t->transport)->read (t->transport,
- tmpdata,
- want,
- error);
- t->r_buf = g_byte_array_append (t->r_buf, tmpdata, got);
-
- // hand over what we have up to what the caller wants
- guint32 give = want < t->r_buf->len ? want : t->r_buf->len;
-
-
- memcpy (buf + len - want, t->r_buf->data, give);
- t->r_buf = g_byte_array_remove_range (t->r_buf, 0, give);
- want -= give;
-
- return (len - want);
- }
-}
-
-/* implements thrift_transport_read */
-gint32
-thrift_buffered_transport_read (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error)
-{
- ThriftBufferedTransport *t = THRIFT_BUFFERED_TRANSPORT (transport);
-
- /* if we have enough buffer data to fulfill the read, just use
- * a memcpy */
- if (len <= t->r_buf->len)
- {
- memcpy (buf, t->r_buf->data, len);
- g_byte_array_remove_range (t->r_buf, 0, len);
- return len;
- }
-
- return thrift_buffered_transport_read_slow (transport, buf, len, error);
-}
-
-/* implements thrift_transport_read_end
- * called when write is complete. nothing to do on our end. */
-gboolean
-thrift_buffered_transport_read_end (ThriftTransport *transport, GError **error)
-{
- /* satisfy -Wall */
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-gboolean
-thrift_buffered_transport_write_slow (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error)
-{
- ThriftBufferedTransport *t = THRIFT_BUFFERED_TRANSPORT (transport);
- guint32 have_bytes = t->w_buf->len;
- guint32 space = t->w_buf_size - t->w_buf->len;
-
- // we need two syscalls because the buffered data plus the buffer itself
- // is too big.
- if ((have_bytes + len >= 2*t->w_buf->len) || (have_bytes == 0))
- {
- if (have_bytes > 0)
- {
- THRIFT_TRANSPORT_GET_CLASS (t->transport)->write (t->transport,
- t->w_buf->data,
- have_bytes,
- error);
- }
- THRIFT_TRANSPORT_GET_CLASS (t->transport)->write (t->transport,
- buf, len, error);
- if (t->w_buf->len > 0)
- {
- t->w_buf = g_byte_array_remove_range (t->w_buf, 0, t->w_buf->len);
- }
-
- return TRUE;
- }
-
- t->w_buf = g_byte_array_append (t->w_buf, buf, space);
- THRIFT_TRANSPORT_GET_CLASS (t->transport)->write (t->transport,
- t->w_buf->data,
- t->w_buf->len,
- error);
-
- t->w_buf = g_byte_array_remove_range (t->w_buf, 0, t->w_buf->len);
- t->w_buf = g_byte_array_append (t->w_buf, buf+space, len-space);
-
- return TRUE;
-}
-
-/* implements thrift_transport_write */
-gboolean
-thrift_buffered_transport_write (ThriftTransport *transport,
- const gpointer buf,
- const guint32 len, GError **error)
-{
- ThriftBufferedTransport *t = THRIFT_BUFFERED_TRANSPORT (transport);
-
- /* the length of the current buffer plus the length of the data being read */
- if (t->w_buf->len + len <= t->w_buf_size)
- {
- t->w_buf = g_byte_array_append (t->w_buf, buf, len);
- return len;
- }
-
- return thrift_buffered_transport_write_slow (transport, buf, len, error);
-}
-
-/* implements thrift_transport_write_end
- * called when write is complete. nothing to do on our end. */
-gboolean
-thrift_buffered_transport_write_end (ThriftTransport *transport, GError **error)
-{
- /* satisfy -Wall */
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-/* implements thrift_transport_flush */
-gboolean
-thrift_buffered_transport_flush (ThriftTransport *transport, GError **error)
-{
- ThriftBufferedTransport *t = THRIFT_BUFFERED_TRANSPORT (transport);
-
- if (t->w_buf != NULL && t->w_buf->len > 0)
- {
- // write the buffer and then empty it
- THRIFT_TRANSPORT_GET_CLASS (t->transport)->write (t->transport,
- t->w_buf->data,
- t->w_buf->len,
- error);
- t->w_buf = g_byte_array_remove_range (t->w_buf, 0, t->w_buf->len);
- }
- THRIFT_TRANSPORT_GET_CLASS (t->transport)->flush (t->transport,
- error);
-
- return TRUE;
-}
-
-/* initializes the instance */
-static void
-thrift_buffered_transport_init (ThriftBufferedTransport *transport)
-{
- transport->transport = NULL;
- transport->r_buf = g_byte_array_new ();
- transport->w_buf = g_byte_array_new ();
-}
-
-/* destructor */
-static void
-thrift_buffered_transport_finalize (GObject *object)
-{
- ThriftBufferedTransport *transport = THRIFT_BUFFERED_TRANSPORT (object);
-
- if (transport->r_buf != NULL)
- {
- g_byte_array_free (transport->r_buf, TRUE);
- }
- transport->r_buf = NULL;
-
- if (transport->w_buf != NULL)
- {
- g_byte_array_free (transport->w_buf, TRUE);
- }
- transport->w_buf = NULL;
-}
-
-/* property accessor */
-void
-thrift_buffered_transport_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
-{
- THRIFT_UNUSED_VAR (pspec);
- ThriftBufferedTransport *transport = THRIFT_BUFFERED_TRANSPORT (object);
-
- switch (property_id)
- {
- case PROP_THRIFT_BUFFERED_TRANSPORT_TRANSPORT:
- g_value_set_object (value, transport->transport);
- break;
- case PROP_THRIFT_BUFFERED_TRANSPORT_READ_BUFFER_SIZE:
- g_value_set_uint (value, transport->r_buf_size);
- break;
- case PROP_THRIFT_BUFFERED_TRANSPORT_WRITE_BUFFER_SIZE:
- g_value_set_uint (value, transport->w_buf_size);
- break;
- }
-}
-
-/* property mutator */
-void
-thrift_buffered_transport_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
-{
- THRIFT_UNUSED_VAR (pspec);
- ThriftBufferedTransport *transport = THRIFT_BUFFERED_TRANSPORT (object);
-
- switch (property_id)
- {
- case PROP_THRIFT_BUFFERED_TRANSPORT_TRANSPORT:
- transport->transport = g_value_get_object (value);
- break;
- case PROP_THRIFT_BUFFERED_TRANSPORT_READ_BUFFER_SIZE:
- transport->r_buf_size = g_value_get_uint (value);
- break;
- case PROP_THRIFT_BUFFERED_TRANSPORT_WRITE_BUFFER_SIZE:
- transport->w_buf_size = g_value_get_uint (value);
- break;
- }
-}
-
-/* initializes the class */
-static void
-thrift_buffered_transport_class_init (ThriftBufferedTransportClass *cls)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
- GParamSpec *param_spec = NULL;
-
- /* setup accessors and mutators */
- gobject_class->get_property = thrift_buffered_transport_get_property;
- gobject_class->set_property = thrift_buffered_transport_set_property;
-
- param_spec = g_param_spec_object ("transport", "transport (construct)",
- "Thrift transport",
- THRIFT_TYPE_TRANSPORT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (gobject_class,
- PROP_THRIFT_BUFFERED_TRANSPORT_TRANSPORT,
- param_spec);
-
- param_spec = g_param_spec_uint ("r_buf_size",
- "read buffer size (construct)",
- "Set the read buffer size",
- 0, /* min */
- 1048576, /* max, 1024*1024 */
- 512, /* default value */
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class,
- PROP_THRIFT_BUFFERED_TRANSPORT_READ_BUFFER_SIZE,
- param_spec);
-
- param_spec = g_param_spec_uint ("w_buf_size",
- "write buffer size (construct)",
- "Set the write buffer size",
- 0, /* min */
- 1048576, /* max, 1024*1024 */
- 512, /* default value */
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class,
- PROP_THRIFT_BUFFERED_TRANSPORT_WRITE_BUFFER_SIZE,
- param_spec);
-
-
- ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
-
- gobject_class->finalize = thrift_buffered_transport_finalize;
- ttc->is_open = thrift_buffered_transport_is_open;
- ttc->open = thrift_buffered_transport_open;
- ttc->close = thrift_buffered_transport_close;
- ttc->read = thrift_buffered_transport_read;
- ttc->read_end = thrift_buffered_transport_read_end;
- ttc->write = thrift_buffered_transport_write;
- ttc->write_end = thrift_buffered_transport_write_end;
- ttc->flush = thrift_buffered_transport_flush;
-}
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_buffered_transport.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_buffered_transport.h b/lib/c_glib/src/thrift/transport/thrift_buffered_transport.h
deleted file mode 100644
index 5082cea..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_buffered_transport.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef _THRIFT_BUFFERED_TRANSPORT_H
-#define _THRIFT_BUFFERED_TRANSPORT_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <thrift/transport/thrift_transport.h>
-
-G_BEGIN_DECLS
-
-/*! \file thrift_buffered_transport.h
- * \brief Implementation of a Thrift buffered transport. Subclasses
- * the ThriftTransport class.
- */
-
-/* type macros */
-#define THRIFT_TYPE_BUFFERED_TRANSPORT (thrift_buffered_transport_get_type ())
-#define THRIFT_BUFFERED_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_BUFFERED_TRANSPORT, ThriftBufferedTransport))
-#define THRIFT_IS_BUFFERED_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_BUFFERED_TRANSPORT))
-#define THRIFT_BUFFERED_TRANSPORT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_BUFFERED_TRANSPORT, ThriftBufferedTransportClass))
-#define THRIFT_IS_BUFFERED_TRANSPORT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_BUFFERED_TRANSPORT)
-#define THRIFT_BUFFERED_TRANSPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_BUFFERED_TRANSPORT, ThriftBufferedTransportClass))
-
-/*!
- * ThriftBufferedTransport instance.
- */
-struct _ThriftBufferedTransport
-{
- ThriftTransport parent;
-
- /* protected */
- ThriftTransport *transport;
-
- /* private */
- GByteArray *r_buf;
- GByteArray *w_buf;
- guint32 r_buf_size;
- guint32 w_buf_size;
-};
-typedef struct _ThriftBufferedTransport ThriftBufferedTransport;
-
-/*!
- * ThriftBufferedTransport class.
- */
-struct _ThriftBufferedTransportClass
-{
- ThriftTransportClass parent;
-};
-typedef struct _ThriftBufferedTransportClass ThriftBufferedTransportClass;
-
-/* used by THRIFT_TYPE_BUFFERED_TRANSPORT */
-GType thrift_buffered_transport_get_type (void);
-
-G_END_DECLS
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_framed_transport.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_framed_transport.c b/lib/c_glib/src/thrift/transport/thrift_framed_transport.c
deleted file mode 100644
index ad4c2eb..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_framed_transport.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <assert.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <thrift/thrift.h>
-#include <thrift/transport/thrift_transport.h>
-#include <thrift/transport/thrift_framed_transport.h>
-
-/* object properties */
-enum _ThriftFramedTransportProperties
-{
- PROP_0,
- PROP_THRIFT_FRAMED_TRANSPORT_TRANSPORT,
- PROP_THRIFT_FRAMED_TRANSPORT_READ_BUFFER_SIZE,
- PROP_THRIFT_FRAMED_TRANSPORT_WRITE_BUFFER_SIZE
-};
-
-G_DEFINE_TYPE(ThriftFramedTransport, thrift_framed_transport, THRIFT_TYPE_TRANSPORT)
-
-/* implements thrift_transport_is_open */
-gboolean
-thrift_framed_transport_is_open (ThriftTransport *transport)
-{
- ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
- return THRIFT_TRANSPORT_GET_CLASS (t->transport)->is_open (t->transport);
-}
-
-/* implements thrift_transport_open */
-gboolean
-thrift_framed_transport_open (ThriftTransport *transport, GError **error)
-{
- ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
- return THRIFT_TRANSPORT_GET_CLASS (t->transport)->open (t->transport, error);
-}
-
-/* implements thrift_transport_close */
-gboolean
-thrift_framed_transport_close (ThriftTransport *transport, GError **error)
-{
- ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
- return THRIFT_TRANSPORT_GET_CLASS (t->transport)->close (t->transport, error);
-}
-
-/* reads a frame and puts it into the buffer */
-gboolean
-thrift_framed_transport_read_frame (ThriftTransport *transport,
- GError **error)
-{
- ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
- gint32 sz, bytes;
-
- /* read the size */
- THRIFT_TRANSPORT_GET_CLASS (t->transport)->read (t->transport,
- (guint32 *) &sz,
- sizeof (sz), error);
- sz = ntohl (sz);
-
- /* create a buffer to hold the data and read that much data */
- guchar tmpdata[sz];
- bytes = THRIFT_TRANSPORT_GET_CLASS (t->transport)->read (t->transport,
- tmpdata,
- sz,
- error);
-
- /* add the data to the buffer */
- g_byte_array_append (t->r_buf, tmpdata, bytes);
-
- return TRUE;
-}
-
-/* the actual read is "slow" because it calls the underlying transport */
-gint32
-thrift_framed_transport_read_slow (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error)
-{
- ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
- guint32 want = len;
- guint32 have = t->r_buf->len;
-
- // we shouldn't hit this unless the buffer doesn't have enough to read
- assert (t->r_buf->len < want);
-
- // first copy what we have in our buffer, if there is anything left
- if (have > 0)
- {
- memcpy (buf, t->r_buf, t->r_buf->len);
- want -= t->r_buf->len;
- t->r_buf = g_byte_array_remove_range (t->r_buf, 0, t->r_buf->len);
- }
-
- // read a frame of input and buffer it
- thrift_framed_transport_read_frame (transport, error);
-
- // hand over what we have up to what the caller wants
- guint32 give = want < t->r_buf->len ? want : t->r_buf->len;
-
- // copy the data into the buffer
- memcpy (buf + len - want, t->r_buf->data, give);
- t->r_buf = g_byte_array_remove_range (t->r_buf, 0, give);
- want -= give;
-
- return (len - want);
-}
-
-/* implements thrift_transport_read */
-gint32
-thrift_framed_transport_read (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error)
-{
- ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
-
- /* if we have enough buffer data to fulfill the read, just use
- * a memcpy from the buffer */
- if (len <= t->r_buf->len)
- {
- memcpy (buf, t->r_buf->data, len);
- g_byte_array_remove_range (t->r_buf, 0, len);
- return len;
- }
-
- return thrift_framed_transport_read_slow (transport, buf, len, error);
-}
-
-/* implements thrift_transport_read_end
- * called when read is complete. nothing to do on our end. */
-gboolean
-thrift_framed_transport_read_end (ThriftTransport *transport, GError **error)
-{
- /* satisfy -Wall */
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-gboolean
-thrift_framed_transport_write_slow (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error)
-{
- THRIFT_UNUSED_VAR (error);
- ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
-
- // append the data to the buffer and we're done
- g_byte_array_append (t->w_buf, buf, len);
-
- return TRUE;
-}
-
-/* implements thrift_transport_write */
-gboolean
-thrift_framed_transport_write (ThriftTransport *transport,
- const gpointer buf,
- const guint32 len, GError **error)
-{
- ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
-
- /* the length of the current buffer plus the length of the data being read */
- if (t->w_buf->len + len <= t->w_buf_size)
- {
- t->w_buf = g_byte_array_append (t->w_buf, buf, len);
- return TRUE;
- }
-
- return thrift_framed_transport_write_slow (transport, buf, len, error);
-}
-
-/* implements thrift_transport_write_end
- * called when write is complete. nothing to do on our end. */
-gboolean
-thrift_framed_transport_write_end (ThriftTransport *transport, GError **error)
-{
- /* satisfy -Wall */
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-/* implements thrift_transport_flush */
-gboolean
-thrift_framed_transport_flush (ThriftTransport *transport, GError **error)
-{
- ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
- gint32 sz_hbo, sz_nbo;
-
- // get the size of the frame in host and network byte order
- sz_hbo = t->w_buf->len + sizeof(sz_nbo);
- sz_nbo = (gint32) htonl ((guint32) t->w_buf->len);
-
- // copy the size of the frame and then the frame itself
- guchar tmpdata[sz_hbo];
- memcpy (tmpdata, (guint8 *) &sz_nbo, sizeof (sz_nbo));
-
- if (t->w_buf->len > 0)
- {
- memcpy (tmpdata + sizeof (sz_nbo), t->w_buf->data, t->w_buf->len);
- t->w_buf = g_byte_array_remove_range (t->w_buf, 0, t->w_buf->len);
- }
-
- // write the buffer and then empty it
- THRIFT_TRANSPORT_GET_CLASS (t->transport)->write (t->transport,
- tmpdata, sz_hbo,
- error);
-
- THRIFT_TRANSPORT_GET_CLASS (t->transport)->flush (t->transport,
- error);
-
- return TRUE;
-}
-
-/* initializes the instance */
-static void
-thrift_framed_transport_init (ThriftFramedTransport *transport)
-{
- transport->transport = NULL;
- transport->r_buf = g_byte_array_new ();
- transport->w_buf = g_byte_array_new ();
-}
-
-/* destructor */
-static void
-thrift_framed_transport_finalize (GObject *object)
-{
- ThriftFramedTransport *transport = THRIFT_FRAMED_TRANSPORT (object);
-
- if (transport->r_buf != NULL)
- {
- g_byte_array_free (transport->r_buf, TRUE);
- }
- transport->r_buf = NULL;
-
- if (transport->w_buf != NULL)
- {
- g_byte_array_free (transport->w_buf, TRUE);
- }
- transport->w_buf = NULL;
-}
-
-/* property accessor */
-void
-thrift_framed_transport_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
-{
- THRIFT_UNUSED_VAR (pspec);
- ThriftFramedTransport *transport = THRIFT_FRAMED_TRANSPORT (object);
-
- switch (property_id)
- {
- case PROP_THRIFT_FRAMED_TRANSPORT_TRANSPORT:
- g_value_set_object (value, transport->transport);
- break;
- case PROP_THRIFT_FRAMED_TRANSPORT_READ_BUFFER_SIZE:
- g_value_set_uint (value, transport->r_buf_size);
- break;
- case PROP_THRIFT_FRAMED_TRANSPORT_WRITE_BUFFER_SIZE:
- g_value_set_uint (value, transport->w_buf_size);
- break;
- }
-}
-
-/* property mutator */
-void
-thrift_framed_transport_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
-{
- THRIFT_UNUSED_VAR (pspec);
- ThriftFramedTransport *transport = THRIFT_FRAMED_TRANSPORT (object);
-
- switch (property_id)
- {
- case PROP_THRIFT_FRAMED_TRANSPORT_TRANSPORT:
- transport->transport = g_value_get_object (value);
- break;
- case PROP_THRIFT_FRAMED_TRANSPORT_READ_BUFFER_SIZE:
- transport->r_buf_size = g_value_get_uint (value);
- break;
- case PROP_THRIFT_FRAMED_TRANSPORT_WRITE_BUFFER_SIZE:
- transport->w_buf_size = g_value_get_uint (value);
- break;
- }
-}
-
-/* initializes the class */
-static void
-thrift_framed_transport_class_init (ThriftFramedTransportClass *cls)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
- GParamSpec *param_spec = NULL;
-
- /* setup accessors and mutators */
- gobject_class->get_property = thrift_framed_transport_get_property;
- gobject_class->set_property = thrift_framed_transport_set_property;
-
- param_spec = g_param_spec_object ("transport", "transport (construct)",
- "Thrift transport",
- THRIFT_TYPE_TRANSPORT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
- g_object_class_install_property (gobject_class,
- PROP_THRIFT_FRAMED_TRANSPORT_TRANSPORT,
- param_spec);
-
- param_spec = g_param_spec_uint ("r_buf_size",
- "read buffer size (construct)",
- "Set the read buffer size",
- 0, /* min */
- 1048576, /* max, 1024*1024 */
- 512, /* default value */
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class,
- PROP_THRIFT_FRAMED_TRANSPORT_READ_BUFFER_SIZE,
- param_spec);
-
- param_spec = g_param_spec_uint ("w_buf_size",
- "write buffer size (construct)",
- "Set the write buffer size",
- 0, /* min */
- 1048576, /* max, 1024*1024 */
- 512, /* default value */
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class,
- PROP_THRIFT_FRAMED_TRANSPORT_WRITE_BUFFER_SIZE,
- param_spec);
-
-
- ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
-
- gobject_class->finalize = thrift_framed_transport_finalize;
- ttc->is_open = thrift_framed_transport_is_open;
- ttc->open = thrift_framed_transport_open;
- ttc->close = thrift_framed_transport_close;
- ttc->read = thrift_framed_transport_read;
- ttc->read_end = thrift_framed_transport_read_end;
- ttc->write = thrift_framed_transport_write;
- ttc->write_end = thrift_framed_transport_write_end;
- ttc->flush = thrift_framed_transport_flush;
-}
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_framed_transport.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_framed_transport.h b/lib/c_glib/src/thrift/transport/thrift_framed_transport.h
deleted file mode 100644
index da2e42e..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_framed_transport.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef _THRIFT_FRAMED_TRANSPORT_H
-#define _THRIFT_FRAMED_TRANSPORT_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <thrift/transport/thrift_transport.h>
-
-G_BEGIN_DECLS
-
-/*! \file thrift_framed_transport.h
- * \brief Implementation of a Thrift framed transport. Subclasses
- * the ThriftTransport class.
- */
-
-/* type macros */
-#define THRIFT_TYPE_FRAMED_TRANSPORT (thrift_framed_transport_get_type ())
-#define THRIFT_FRAMED_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_FRAMED_TRANSPORT, ThriftFramedTransport))
-#define THRIFT_IS_FRAMED_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_FRAMED_TRANSPORT))
-#define THRIFT_FRAMED_TRANSPORT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_FRAMED_TRANSPORT, ThriftFramedTransportClass))
-#define THRIFT_IS_FRAMED_TRANSPORT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_FRAMED_TRANSPORT)
-#define THRIFT_FRAMED_TRANSPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_FRAMED_TRANSPORT, ThriftFramedTransportClass))
-
-/*!
- * ThriftFramedTransport instance.
- */
-struct _ThriftFramedTransport
-{
- ThriftTransport parent;
-
- /* protected */
- ThriftTransport *transport;
-
- /* private */
- GByteArray *r_buf;
- GByteArray *w_buf;
- guint32 r_buf_size;
- guint32 w_buf_size;
-};
-typedef struct _ThriftFramedTransport ThriftFramedTransport;
-
-/*!
- * ThriftFramedTransport class.
- */
-struct _ThriftFramedTransportClass
-{
- ThriftTransportClass parent;
-};
-typedef struct _ThriftFramedTransportClass ThriftFramedTransportClass;
-
-/* used by THRIFT_TYPE_FRAMED_TRANSPORT */
-GType thrift_framed_transport_get_type (void);
-
-G_END_DECLS
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_memory_buffer.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_memory_buffer.c b/lib/c_glib/src/thrift/transport/thrift_memory_buffer.c
deleted file mode 100644
index b32d4a5..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_memory_buffer.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <assert.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <thrift/thrift.h>
-#include <thrift/transport/thrift_transport.h>
-#include <thrift/transport/thrift_memory_buffer.h>
-
-/* object properties */
-enum _ThriftMemoryBufferProperties
-{
- PROP_0,
- PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE,
-};
-
-G_DEFINE_TYPE(ThriftMemoryBuffer, thrift_memory_buffer, THRIFT_TYPE_TRANSPORT)
-
-/* implements thrift_transport_is_open */
-gboolean
-thrift_memory_buffer_is_open (ThriftTransport *transport)
-{
- THRIFT_UNUSED_VAR (transport);
- return TRUE;
-}
-
-/* implements thrift_transport_open */
-gboolean
-thrift_memory_buffer_open (ThriftTransport *transport, GError **error)
-{
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-/* implements thrift_transport_close */
-gboolean
-thrift_memory_buffer_close (ThriftTransport *transport, GError **error)
-{
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-/* implements thrift_transport_read */
-gint32
-thrift_memory_buffer_read (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error)
-{
- THRIFT_UNUSED_VAR (error);
- ThriftMemoryBuffer *t = THRIFT_MEMORY_BUFFER (transport);
- guint32 give = len;
-
- /* if the requested bytes are more than what we have available,
- * just give all that we have the buffer */
- if (t->buf->len < len)
- {
- give = t->buf->len;
- }
-
- memcpy (buf, t->buf->data, give);
- g_byte_array_remove_range (t->buf, 0, give);
-
- return give;
-}
-
-/* implements thrift_transport_read_end
- * called when read is complete. nothing to do on our end. */
-gboolean
-thrift_memory_buffer_read_end (ThriftTransport *transport, GError **error)
-{
- /* satisfy -Wall */
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-/* implements thrift_transport_write */
-gboolean
-thrift_memory_buffer_write (ThriftTransport *transport,
- const gpointer buf,
- const guint32 len, GError **error)
-{
- THRIFT_UNUSED_VAR (error);
-
- ThriftMemoryBuffer *t = THRIFT_MEMORY_BUFFER (transport);
-
- /* return an exception if the buffer doesn't have enough space. */
- if (len > t->buf_size - t->buf->len)
- {
- g_set_error (error, THRIFT_TRANSPORT_ERROR, THRIFT_TRANSPORT_ERROR_SEND,
- "unable to write %d bytes to buffer of length %d",
- len, t->buf_size);
- return FALSE;
- } else {
- t->buf = g_byte_array_append (t->buf, buf, len);
- return TRUE;
- }
-}
-
-/* implements thrift_transport_write_end
- * called when write is complete. nothing to do on our end. */
-gboolean
-thrift_memory_buffer_write_end (ThriftTransport *transport, GError **error)
-{
- /* satisfy -Wall */
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-/* implements thrift_transport_flush */
-gboolean
-thrift_memory_buffer_flush (ThriftTransport *transport, GError **error)
-{
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
-
- return TRUE;
-}
-
-/* initializes the instance */
-static void
-thrift_memory_buffer_init (ThriftMemoryBuffer *transport)
-{
- transport->buf = g_byte_array_new ();
-}
-
-/* destructor */
-static void
-thrift_memory_buffer_finalize (GObject *object)
-{
- ThriftMemoryBuffer *transport = THRIFT_MEMORY_BUFFER (object);
-
- if (transport->buf != NULL)
- {
- g_byte_array_free (transport->buf, TRUE);
- }
- transport->buf = NULL;
-}
-
-/* property accessor */
-void
-thrift_memory_buffer_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
-{
- THRIFT_UNUSED_VAR (pspec);
- ThriftMemoryBuffer *transport = THRIFT_MEMORY_BUFFER (object);
-
- switch (property_id)
- {
- case PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE:
- g_value_set_uint (value, transport->buf_size);
- break;
- }
-}
-
-/* property mutator */
-void
-thrift_memory_buffer_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
-{
- THRIFT_UNUSED_VAR (pspec);
- ThriftMemoryBuffer *transport = THRIFT_MEMORY_BUFFER (object);
-
- switch (property_id)
- {
- case PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE:
- transport->buf_size = g_value_get_uint (value);
- break;
- }
-}
-
-/* initializes the class */
-static void
-thrift_memory_buffer_class_init (ThriftMemoryBufferClass *cls)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
- GParamSpec *param_spec = NULL;
-
- /* setup accessors and mutators */
- gobject_class->get_property = thrift_memory_buffer_get_property;
- gobject_class->set_property = thrift_memory_buffer_set_property;
-
- param_spec = g_param_spec_uint ("buf_size",
- "buffer size (construct)",
- "Set the read buffer size",
- 0, /* min */
- 1048576, /* max, 1024*1024 */
- 512, /* default value */
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class,
- PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE,
- param_spec);
-
- ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
-
- gobject_class->finalize = thrift_memory_buffer_finalize;
- ttc->is_open = thrift_memory_buffer_is_open;
- ttc->open = thrift_memory_buffer_open;
- ttc->close = thrift_memory_buffer_close;
- ttc->read = thrift_memory_buffer_read;
- ttc->read_end = thrift_memory_buffer_read_end;
- ttc->write = thrift_memory_buffer_write;
- ttc->write_end = thrift_memory_buffer_write_end;
- ttc->flush = thrift_memory_buffer_flush;
-}
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_memory_buffer.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_memory_buffer.h b/lib/c_glib/src/thrift/transport/thrift_memory_buffer.h
deleted file mode 100644
index 8ee697e..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_memory_buffer.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef _THRIFT_MEMORY_BUFFER_H
-#define _THRIFT_MEMORY_BUFFER_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <thrift/transport/thrift_transport.h>
-
-G_BEGIN_DECLS
-
-/*! \file thrift_memory_buffer.h
- * \brief Implementation of a Thrift memory buffer transport.
- */
-
-/* type macros */
-#define THRIFT_TYPE_MEMORY_BUFFER (thrift_memory_buffer_get_type ())
-#define THRIFT_MEMORY_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_MEMORY_BUFFER, ThriftMemoryBuffer))
-#define THRIFT_IS_MEMORY_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_MEMORY_BUFFER))
-#define THRIFT_MEMORY_BUFFER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_MEMORY_BUFFER, ThriftMemoryBufferClass))
-#define THRIFT_IS_MEMORY_BUFFER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_MEMORY_BUFFER)
-#define THRIFT_MEMORY_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_MEMORY_BUFFER, ThriftMemoryBufferClass))
-
-/*!
- * ThriftMemoryBuffer instance.
- */
-struct _ThriftMemoryBuffer
-{
- ThriftTransport parent;
-
- /* private */
- GByteArray *buf;
- guint32 buf_size;
-};
-typedef struct _ThriftMemoryBuffer ThriftMemoryBuffer;
-
-/*!
- * ThriftMemoryBuffer class.
- */
-struct _ThriftMemoryBufferClass
-{
- ThriftTransportClass parent;
-};
-typedef struct _ThriftMemoryBufferClass ThriftMemoryBufferClass;
-
-/* used by THRIFT_TYPE_MEMORY_BUFFER */
-GType thrift_memory_buffer_get_type (void);
-
-G_END_DECLS
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_server_socket.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_server_socket.c b/lib/c_glib/src/thrift/transport/thrift_server_socket.c
deleted file mode 100644
index c7c6664..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_server_socket.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <errno.h>
-#include <netdb.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <thrift/thrift.h>
-#include <thrift/transport/thrift_socket.h>
-#include <thrift/transport/thrift_transport.h>
-#include <thrift/transport/thrift_server_transport.h>
-#include <thrift/transport/thrift_server_socket.h>
-
-/* object properties */
-enum _ThriftServerSocketProperties
-{
- PROP_0,
- PROP_THRIFT_SERVER_SOCKET_PORT,
- PROP_THRIFT_SERVER_SOCKET_BACKLOG
-};
-
-/* define the GError domain string */
-#define THRIFT_SERVER_SOCKET_ERROR_DOMAIN "thrift-server-socket-error-quark"
-
-/* for errors coming from socket() and connect() */
-extern int errno;
-
-G_DEFINE_TYPE(ThriftServerSocket, thrift_server_socket, THRIFT_TYPE_SERVER_TRANSPORT)
-
-gboolean
-thrift_server_socket_listen (ThriftServerTransport *transport, GError **error)
-{
- int enabled = 1; /* for setsockopt() */
- struct sockaddr_in pin;
- ThriftServerSocket *tsocket = THRIFT_SERVER_SOCKET (transport);
-
- /* create a address structure */
- memset (&pin, 0, sizeof(pin));
- pin.sin_family = AF_INET;
- pin.sin_addr.s_addr = INADDR_ANY;
- pin.sin_port = htons(tsocket->port);
-
- /* create a socket */
- if ((tsocket->sd = socket (AF_INET, SOCK_STREAM, 0)) == -1)
- {
- g_set_error (error, THRIFT_SERVER_SOCKET_ERROR,
- THRIFT_SERVER_SOCKET_ERROR_SOCKET,
- "failed to create socket - %s", strerror (errno));
- return FALSE;
- }
-
- if (setsockopt(tsocket->sd, SOL_SOCKET, SO_REUSEADDR, &enabled,
- sizeof(enabled)) == -1)
- {
- g_set_error (error, THRIFT_SERVER_SOCKET_ERROR,
- THRIFT_SERVER_SOCKET_ERROR_SETSOCKOPT,
- "unable to set SO_REUSEADDR - %s", strerror(errno));
- return FALSE;
- }
-
- /* bind to the socket */
- if (bind(tsocket->sd, (struct sockaddr *) &pin, sizeof(pin)) == -1)
- {
- g_set_error (error, THRIFT_SERVER_SOCKET_ERROR,
- THRIFT_SERVER_SOCKET_ERROR_BIND,
- "failed to bind to port %d - %s",
- tsocket->port, strerror(errno));
- return FALSE;
- }
-
- if (listen(tsocket->sd, tsocket->backlog) == -1)
- {
- g_set_error (error, THRIFT_SERVER_SOCKET_ERROR,
- THRIFT_SERVER_SOCKET_ERROR_LISTEN,
- "failed to listen to port %d - %s",
- tsocket->port, strerror(errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-ThriftTransport *
-thrift_server_socket_accept (ThriftServerTransport *transport, GError **error)
-{
- int sd = 0;
- guint addrlen = 0;
- struct sockaddr_in address;
- ThriftSocket *socket = NULL;
-
- ThriftServerSocket *tsocket = THRIFT_SERVER_SOCKET (transport);
-
- if ((sd = accept(tsocket->sd, (struct sockaddr *) &address, &addrlen)) == -1)
- {
- g_set_error (error, THRIFT_SERVER_SOCKET_ERROR,
- THRIFT_SERVER_SOCKET_ERROR_ACCEPT,
- "failed to accept connection - %s",
- strerror(errno));
- return FALSE;
- }
-
- socket = g_object_new (THRIFT_TYPE_SOCKET, NULL);
- socket->sd = sd;
-
- return THRIFT_TRANSPORT(socket);
-}
-
-gboolean
-thrift_server_socket_close (ThriftServerTransport *transport, GError **error)
-{
- ThriftServerSocket *tsocket = THRIFT_SERVER_SOCKET (transport);
-
- if (close (tsocket->sd) == -1)
- {
- g_set_error (error, THRIFT_SERVER_SOCKET_ERROR,
- THRIFT_SERVER_SOCKET_ERROR_CLOSE,
- "unable to close socket - %s", strerror(errno));
- return FALSE;
- }
- tsocket->sd = 0;
-
- return TRUE;
-}
-
-/* define the GError domain for this implementation */
-GQuark
-thrift_server_socket_error_quark (void)
-{
- return g_quark_from_static_string(THRIFT_SERVER_SOCKET_ERROR_DOMAIN);
-}
-
-/* initializes the instance */
-static void
-thrift_server_socket_init (ThriftServerSocket *socket)
-{
- socket->sd = 0;
-}
-
-/* destructor */
-static void
-thrift_server_socket_finalize (GObject *object)
-{
- ThriftServerSocket *socket = THRIFT_SERVER_SOCKET (object);
-
- if (socket->sd != 0)
- {
- close (socket->sd);
- }
- socket->sd = 0;
-}
-
-/* property accessor */
-void
-thrift_server_socket_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
-{
- ThriftServerSocket *socket = THRIFT_SERVER_SOCKET (object);
-
- switch (property_id)
- {
- case PROP_THRIFT_SERVER_SOCKET_PORT:
- g_value_set_uint (value, socket->port);
- break;
- case PROP_THRIFT_SERVER_SOCKET_BACKLOG:
- g_value_set_uint (value, socket->backlog);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-/* property mutator */
-void
-thrift_server_socket_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
-{
- ThriftServerSocket *socket = THRIFT_SERVER_SOCKET (object);
-
- switch (property_id)
- {
- case PROP_THRIFT_SERVER_SOCKET_PORT:
- socket->port = g_value_get_uint (value);
- break;
- case PROP_THRIFT_SERVER_SOCKET_BACKLOG:
- socket->backlog = g_value_get_uint (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-/* initializes the class */
-static void
-thrift_server_socket_class_init (ThriftServerSocketClass *cls)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
- GParamSpec *param_spec = NULL;
-
- /* setup accessors and mutators */
- gobject_class->get_property = thrift_server_socket_get_property;
- gobject_class->set_property = thrift_server_socket_set_property;
-
- param_spec = g_param_spec_uint ("port",
- "port (construct)",
- "Set the port to listen to",
- 0, /* min */
- 65534, /* max */
- 9090, /* default by convention */
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class,
- PROP_THRIFT_SERVER_SOCKET_PORT,
- param_spec);
-
- param_spec = g_param_spec_uint ("backlog",
- "backlog (construct)",
- "Set the accept backlog",
- 0, /* max */
- 65534, /* max */
- 1024, /* default */
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class,
- PROP_THRIFT_SERVER_SOCKET_BACKLOG,
- param_spec);
-
- gobject_class->finalize = thrift_server_socket_finalize;
-
- ThriftServerTransportClass *tstc = THRIFT_SERVER_TRANSPORT_CLASS (cls);
- tstc->listen = thrift_server_socket_listen;
- tstc->accept = thrift_server_socket_accept;
- tstc->close = thrift_server_socket_close;
-}
-
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_server_socket.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_server_socket.h b/lib/c_glib/src/thrift/transport/thrift_server_socket.h
deleted file mode 100644
index 54a6017..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_server_socket.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef _THRIFT_SERVER_SOCKET_H
-#define _THRIFT_SERVER_SOCKET_H
-
-#include <glib-object.h>
-
-#include "thrift_server_transport.h"
-
-G_BEGIN_DECLS
-
-/*! \file thrift_server_socket.h
- * \brief Socket implementation of a Thrift server transport. Implements the
- * ThriftServerTransport class.
- */
-
-/* type macros */
-#define THRIFT_TYPE_SERVER_SOCKET (thrift_server_socket_get_type ())
-#define THRIFT_SERVER_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_SERVER_SOCKET, ThriftServerSocket))
-#define THRIFT_IS_SERVER_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_SERVER_SOCKET))
-#define THRIFT_SERVER_SOCKET_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_SERVER_SOCKET, ThriftServerSocketClass))
-#define THRIFT_IS_SERVER_SOCKET_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_SERVER_SOCKET))
-#define THRIFT_SERVER_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_SERVER_SOCKET, ThriftServerSocketClass))
-
-/*!
- * Thrift ServerSocket instance.
- */
-struct _ThriftServerSocket
-{
- ThriftServerTransport parent;
-
- /* private */
- gshort port;
- gshort backlog;
- int sd;
- guint8 *buf;
- guint32 buf_size;
- guint32 buf_len;
-};
-typedef struct _ThriftServerSocket ThriftServerSocket;
-
-/*!
- * Thrift ServerSocket class.
- */
-struct _ThriftServerSocketClass
-{
- ThriftServerTransportClass parent;
-};
-typedef struct _ThriftServerSocketClass ThriftServerSocketClass;
-
-/* used by THRIFT_TYPE_SERVER_SOCKET */
-GType thrift_server_socket_get_type (void);
-
-/* define error/exception types */
-typedef enum
-{
- THRIFT_SERVER_SOCKET_ERROR_SOCKET,
- THRIFT_SERVER_SOCKET_ERROR_SETSOCKOPT,
- THRIFT_SERVER_SOCKET_ERROR_BIND,
- THRIFT_SERVER_SOCKET_ERROR_LISTEN,
- THRIFT_SERVER_SOCKET_ERROR_ACCEPT,
- THRIFT_SERVER_SOCKET_ERROR_CLOSE
-} ThriftServerSocketError;
-
-/* define a error domain for GError to use */
-GQuark thrift_server_socket_error_quark (void);
-#define THRIFT_SERVER_SOCKET_ERROR (thrift_server_socket_error_quark ())
-
-G_END_DECLS
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_server_transport.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_server_transport.c b/lib/c_glib/src/thrift/transport/thrift_server_transport.c
deleted file mode 100644
index d0a46c3..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_server_transport.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <thrift/thrift.h>
-#include <thrift/transport/thrift_transport.h>
-#include <thrift/transport/thrift_server_transport.h>
-
-G_DEFINE_ABSTRACT_TYPE(ThriftServerTransport, thrift_server_transport, G_TYPE_OBJECT)
-
-/* base initializer for the server transport interface */
-static void
-thrift_server_transport_class_init (ThriftServerTransportClass *c)
-{
- c->listen = thrift_server_transport_listen;
- c->accept = thrift_server_transport_accept;
- c->close = thrift_server_transport_close;
-}
-
-static void
-thrift_server_transport_init (ThriftServerTransport *transport)
-{
- THRIFT_UNUSED_VAR (transport);
-}
-
-gboolean
-thrift_server_transport_listen (ThriftServerTransport *transport,
- GError **error)
-{
- return THRIFT_SERVER_TRANSPORT_GET_CLASS (transport)->listen (transport,
- error);
-}
-
-ThriftTransport *
-thrift_server_transport_accept (ThriftServerTransport *transport,
- GError **error)
-{
- return THRIFT_SERVER_TRANSPORT_GET_CLASS (transport)->accept (transport,
- error);
-}
-
-gboolean
-thrift_server_transport_close (ThriftServerTransport *transport, GError **error)
-{
- return THRIFT_SERVER_TRANSPORT_GET_CLASS (transport)->close (transport,
- error);
-}
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_server_transport.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_server_transport.h b/lib/c_glib/src/thrift/transport/thrift_server_transport.h
deleted file mode 100644
index dd94325..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_server_transport.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef _THRIFT_SERVER_TRANSPORT_H
-#define _THRIFT_SERVER_TRANSPORT_H
-
-#include <glib-object.h>
-
-#include "thrift_transport.h"
-
-G_BEGIN_DECLS
-
-/*! \file thrift_server_transport.h
- * \brief Abstract class for Thrift server transports.
- */
-
-/* type macros */
-#define THRIFT_TYPE_SERVER_TRANSPORT (thrift_server_transport_get_type ())
-#define THRIFT_SERVER_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_SERVER_TRANSPORT, ThriftServerTransport))
-#define THRIFT_IS_SERVER_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_SERVER_TRANSPORT))
-#define THRIFT_SERVER_TRANSPORT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_SERVER_TRANSPORT, ThriftServerTransportClass))
-#define THRIFT_IS_SERVER_TRANSPORT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_SERVER_TRANSPORT))
-#define THRIFT_SERVER_TRANSPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_SERVER_TRANSPORT, ThriftServerTransportClass))
-
-struct _ThriftServerTransport
-{
- GObject parent;
-};
-typedef struct _ThriftServerTransport ThriftServerTransport;
-
-/*!
- * Thrift Transport class
- */
-struct _ThriftServerTransportClass
-{
- GObjectClass parent;
-
- /* vtable */
- gboolean (*listen) (ThriftServerTransport *transport, GError **error);
- ThriftTransport *(*accept) (ThriftServerTransport *transport, GError **error);
- gboolean (*close) (ThriftServerTransport *transport, GError **error);
-};
-typedef struct _ThriftServerTransportClass ThriftServerTransportClass;
-
-/* used by THRIFT_TYPE_SERVER_TRANSPORT */
-GType thrift_server_transport_get_type (void);
-
-/*!
- * Listen for new connections.
- * \public \memberof ThriftServerTransportClass
- */
-gboolean thrift_server_transport_listen (ThriftServerTransport *transport,
- GError **error);
-
-/*!
- * Accept a connection.
- * \public \memberof ThriftServerTransportClass
- */
-ThriftTransport *thrift_server_transport_accept
- (ThriftServerTransport *transport, GError **error);
-
-/*!
- * Close the transport.
- * \public \memberof ThriftServerTransportClass
- */
-gboolean thrift_server_transport_close (ThriftServerTransport *transport,
- GError **error);
-
-G_END_DECLS
-
-#endif /* _THRIFT_SERVER_TRANSPORT_H */
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_socket.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_socket.c b/lib/c_glib/src/thrift/transport/thrift_socket.c
deleted file mode 100644
index 6584a93..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_socket.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <errno.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <thrift/thrift.h>
-#include <thrift/transport/thrift_transport.h>
-#include <thrift/transport/thrift_socket.h>
-
-/* object properties */
-enum _ThriftSocketProperties
-{
- PROP_0,
- PROP_THRIFT_SOCKET_HOSTNAME,
- PROP_THRIFT_SOCKET_PORT
-};
-
-/* for errors coming from socket() and connect() */
-extern int errno;
-
-G_DEFINE_TYPE(ThriftSocket, thrift_socket, THRIFT_TYPE_TRANSPORT)
-
-/* implements thrift_transport_is_open */
-gboolean
-thrift_socket_is_open (ThriftTransport *transport)
-{
- ThriftSocket *socket = THRIFT_SOCKET (transport);
- return socket->sd != 0;
-}
-
-/* implements thrift_transport_open */
-gboolean
-thrift_socket_open (ThriftTransport *transport, GError **error)
-{
- struct hostent *hp = NULL;
- struct sockaddr_in pin;
-
- ThriftSocket *tsocket = THRIFT_SOCKET (transport);
- g_return_val_if_fail (tsocket->sd == 0, FALSE);
-
- /* lookup the destination host */
- if ((hp = gethostbyname (tsocket->hostname)) == NULL)
- {
- /* host lookup failed, bail out with an error */
- g_set_error (error, THRIFT_TRANSPORT_ERROR, THRIFT_TRANSPORT_ERROR_HOST,
- "host lookup failed for %s:%d - %s",
- tsocket->hostname, tsocket->port,
- hstrerror (h_errno));
- return FALSE;
- }
-
- /* create a socket structure */
- memset (&pin, 0, sizeof(pin));
- pin.sin_family = AF_INET;
- pin.sin_addr.s_addr = ((struct in_addr *) (hp->h_addr))->s_addr;
- pin.sin_port = htons (tsocket->port);
-
- /* create the socket */
- if ((tsocket->sd = socket (AF_INET, SOCK_STREAM, 0)) == -1)
- {
- g_set_error (error, THRIFT_TRANSPORT_ERROR, THRIFT_TRANSPORT_ERROR_SOCKET,
- "failed to create socket for host %s:%d - %s",
- tsocket->hostname, tsocket->port,
- strerror(errno));
- return FALSE;
- }
-
- /* open a connection */
- if (connect (tsocket->sd, (struct sockaddr *) &pin, sizeof(pin)) == -1)
- {
- g_set_error (error, THRIFT_TRANSPORT_ERROR, THRIFT_TRANSPORT_ERROR_CONNECT,
- "failed to connect to host %s:%d - %s",
- tsocket->hostname, tsocket->port, strerror(errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* implements thrift_transport_close */
-gboolean
-thrift_socket_close (ThriftTransport *transport, GError **error)
-{
- ThriftSocket *socket = THRIFT_SOCKET (transport);
-
- if (close (socket->sd) == -1)
- {
- g_set_error (error, THRIFT_TRANSPORT_ERROR, THRIFT_TRANSPORT_ERROR_CLOSE,
- "unable to close socket - %s",
- strerror(errno));
- return FALSE;
- }
-
- socket->sd = 0;
- return TRUE;
-}
-
-/* implements thrift_transport_read */
-gint32
-thrift_socket_read (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error)
-{
- gint ret = 0;
- guint got = 0;
-
- ThriftSocket *socket = THRIFT_SOCKET (transport);
-
- while (got < len)
- {
- ret = recv (socket->sd, buf+got, len-got, 0);
- if (ret < 0)
- {
- g_set_error (error, THRIFT_TRANSPORT_ERROR,
- THRIFT_TRANSPORT_ERROR_RECEIVE,
- "failed to read %d bytes - %s", len, strerror(errno));
- return -1;
- }
- got += ret;
- }
-
- return got;
-}
-
-/* implements thrift_transport_read_end
- * called when write is complete. nothing to do on our end. */
-gboolean
-thrift_socket_read_end (ThriftTransport *transport, GError **error)
-{
- /* satisfy -Wall */
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-/* implements thrift_transport_write */
-gboolean
-thrift_socket_write (ThriftTransport *transport, const gpointer buf,
- const guint32 len, GError **error)
-{
- gint ret = 0;
- guint sent = 0;
-
- ThriftSocket *socket = THRIFT_SOCKET (transport);
- g_return_val_if_fail (socket->sd != 0, FALSE);
-
- while (sent < len)
- {
- ret = send (socket->sd, buf + sent, len - sent, 0);
- if (ret < 0)
- {
- g_set_error (error, THRIFT_TRANSPORT_ERROR,
- THRIFT_TRANSPORT_ERROR_SEND,
- "failed to send %d bytes - %s", len, strerror(errno));
- return FALSE;
- }
- sent += ret;
- }
-
- return TRUE;
-}
-
-/* implements thrift_transport_write_end
- * called when write is complete. nothing to do on our end. */
-gboolean
-thrift_socket_write_end (ThriftTransport *transport, GError **error)
-{
- /* satisfy -Wall */
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-/* implements thrift_transport_flush
- * flush pending data. since we are not buffered, this is a no-op */
-gboolean
-thrift_socket_flush (ThriftTransport *transport, GError **error)
-{
- /* satisfy -Wall */
- THRIFT_UNUSED_VAR (transport);
- THRIFT_UNUSED_VAR (error);
- return TRUE;
-}
-
-/* initializes the instance */
-static void
-thrift_socket_init (ThriftSocket *socket)
-{
- socket->sd = 0;
-}
-
-/* destructor */
-static void
-thrift_socket_finalize (GObject *object)
-{
- ThriftSocket *socket = THRIFT_SOCKET (object);
-
- if (socket->hostname != NULL)
- {
- g_free (socket->hostname);
- }
- socket->hostname = NULL;
-
- if (socket->sd != 0)
- {
- close (socket->sd);
- }
- socket->sd = 0;
-}
-
-/* property accessor */
-void
-thrift_socket_get_property (GObject *object, guint property_id,
- GValue *value, GParamSpec *pspec)
-{
- THRIFT_UNUSED_VAR (pspec);
- ThriftSocket *socket = THRIFT_SOCKET (object);
-
- switch (property_id)
- {
- case PROP_THRIFT_SOCKET_HOSTNAME:
- g_value_set_string (value, socket->hostname);
- break;
- case PROP_THRIFT_SOCKET_PORT:
- g_value_set_uint (value, socket->port);
- break;
- }
-}
-
-/* property mutator */
-void
-thrift_socket_set_property (GObject *object, guint property_id,
- const GValue *value, GParamSpec *pspec)
-{
- THRIFT_UNUSED_VAR (pspec);
- ThriftSocket *socket = THRIFT_SOCKET (object);
-
- switch (property_id)
- {
- case PROP_THRIFT_SOCKET_HOSTNAME:
- socket->hostname = g_strdup (g_value_get_string (value));
- break;
- case PROP_THRIFT_SOCKET_PORT:
- socket->port = g_value_get_uint (value);
- break;
- }
-}
-
-/* initializes the class */
-static void
-thrift_socket_class_init (ThriftSocketClass *cls)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
- GParamSpec *param_spec = NULL;
-
- /* setup accessors and mutators */
- gobject_class->get_property = thrift_socket_get_property;
- gobject_class->set_property = thrift_socket_set_property;
-
- param_spec = g_param_spec_string ("hostname",
- "hostname (construct)",
- "Set the hostname of the remote host",
- "localhost", /* default value */
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class, PROP_THRIFT_SOCKET_HOSTNAME,
- param_spec);
-
- param_spec = g_param_spec_uint ("port",
- "port (construct)",
- "Set the port of the remote host",
- 0, /* min */
- 65534, /* max */
- 9090, /* default by convention */
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class, PROP_THRIFT_SOCKET_PORT,
- param_spec);
-
- ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
-
- gobject_class->finalize = thrift_socket_finalize;
- ttc->is_open = thrift_socket_is_open;
- ttc->open = thrift_socket_open;
- ttc->close = thrift_socket_close;
- ttc->read = thrift_socket_read;
- ttc->read_end = thrift_socket_read_end;
- ttc->write = thrift_socket_write;
- ttc->write_end = thrift_socket_write_end;
- ttc->flush = thrift_socket_flush;
-}
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_socket.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_socket.h b/lib/c_glib/src/thrift/transport/thrift_socket.h
deleted file mode 100644
index dde269c..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_socket.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef _THRIFT_SOCKET_H
-#define _THRIFT_SOCKET_H
-
-#include <glib-object.h>
-
-#include <thrift/transport/thrift_transport.h>
-
-G_BEGIN_DECLS
-
-/*! \file thrift_socket.h
- * \brief Socket implementation of a Thrift transport. Subclasses the
- * ThriftTransport class.
- */
-
-/* type macros */
-#define THRIFT_TYPE_SOCKET (thrift_socket_get_type ())
-#define THRIFT_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_SOCKET, ThriftSocket))
-#define THRIFT_IS_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_SOCKET))
-#define THRIFT_SOCKET_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_SOCKET, ThriftSocketClass))
-#define THRIFT_IS_SOCKET_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_SOCKET))
-#define THRIFT_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_SOCKET, ThriftSocketClass))
-
-/*!
- * Thrift Socket instance.
- */
-struct _ThriftSocket
-{
- ThriftTransport parent;
-
- /* private */
- gchar *hostname;
- gshort port;
- int sd;
- guint8 *buf;
- guint32 buf_size;
- guint32 buf_len;
-};
-typedef struct _ThriftSocket ThriftSocket;
-
-/*!
- * Thrift Socket class.
- */
-struct _ThriftSocketClass
-{
- ThriftTransportClass parent;
-};
-typedef struct _ThriftSocketClass ThriftSocketClass;
-
-/* used by THRIFT_TYPE_SOCKET */
-GType thrift_socket_get_type (void);
-
-G_END_DECLS
-
-#endif
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_transport.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_transport.c b/lib/c_glib/src/thrift/transport/thrift_transport.c
deleted file mode 100644
index 890bcad..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_transport.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <thrift/thrift.h>
-#include <thrift/transport/thrift_transport.h>
-
-/* define the GError domain string */
-#define THRIFT_TRANSPORT_ERROR_DOMAIN "thrift-transport-error-quark"
-
-G_DEFINE_ABSTRACT_TYPE(ThriftTransport, thrift_transport, G_TYPE_OBJECT)
-
-gboolean
-thrift_transport_is_open (ThriftTransport *transport)
-{
- return THRIFT_TRANSPORT_GET_CLASS (transport)->is_open (transport);
-}
-
-gboolean
-thrift_transport_open (ThriftTransport *transport, GError **error)
-{
- return THRIFT_TRANSPORT_GET_CLASS (transport)->open (transport, error);
-}
-
-gboolean
-thrift_transport_close (ThriftTransport *transport, GError **error)
-{
- return THRIFT_TRANSPORT_GET_CLASS (transport)->close (transport, error);
-}
-
-gint32
-thrift_transport_read (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error)
-{
- return THRIFT_TRANSPORT_GET_CLASS (transport)->read (transport, buf,
- len, error);
-}
-
-gboolean
-thrift_transport_read_end (ThriftTransport *transport, GError **error)
-{
- return THRIFT_TRANSPORT_GET_CLASS (transport)->read_end (transport,
- error);
-}
-
-gboolean
-thrift_transport_write (ThriftTransport *transport, const gpointer buf,
- const guint32 len, GError **error)
-{
- return THRIFT_TRANSPORT_GET_CLASS (transport)->write (transport, buf,
- len, error);
-}
-
-gboolean
-thrift_transport_write_end (ThriftTransport *transport, GError **error)
-{
- return THRIFT_TRANSPORT_GET_CLASS (transport)->write_end (transport,
- error);
-}
-
-gboolean
-thrift_transport_flush (ThriftTransport *transport, GError **error)
-{
- return THRIFT_TRANSPORT_GET_CLASS (transport)->flush (transport, error);
-}
-
-/* define the GError domain for Thrift transports */
-GQuark
-thrift_transport_error_quark (void)
-{
- return g_quark_from_static_string (THRIFT_TRANSPORT_ERROR_DOMAIN);
-}
-
-/* class initializer for ThriftTransport */
-static void
-thrift_transport_class_init (ThriftTransportClass *cls)
-{
- /* set these as virtual methods to be implemented by a subclass */
- cls->is_open = thrift_transport_is_open;
- cls->open = thrift_transport_open;
- cls->close = thrift_transport_close;
- cls->read = thrift_transport_read;
- cls->read_end = thrift_transport_read_end;
- cls->write = thrift_transport_write;
- cls->write_end = thrift_transport_write_end;
- cls->flush = thrift_transport_flush;
-}
-
-static void
-thrift_transport_init (ThriftTransport *transport)
-{
- THRIFT_UNUSED_VAR (transport);
-}
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_transport.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_transport.h b/lib/c_glib/src/thrift/transport/thrift_transport.h
deleted file mode 100644
index 9797473..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_transport.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef _THRIFT_TRANSPORT_H
-#define _THRIFT_TRANSPORT_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/*! \file thrift_transport.h
- * \brief Abstract class for Thrift transports.
- *
- * An abstract class is used instead of an interface because:
- * - interfaces can't seem to be used as properties. ThriftProtocol has
- * a ThriftTransport as an object property.
- * - if a method needs to be added that all subclasses can use, a class
- * is necessary.
- */
-
-/* type macros */
-#define THRIFT_TYPE_TRANSPORT (thrift_transport_get_type ())
-#define THRIFT_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_TRANSPORT, ThriftTransport))
-#define THRIFT_IS_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_TRANSPORT))
-#define THRIFT_TRANSPORT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_TRANSPORT, ThriftTransportClass))
-#define THRIFT_IS_TRANSPORT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_TRANSPORT))
-#define THRIFT_TRANSPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_TRANSPORT, ThriftTransportClass))
-
-/*!
- * Thrift Protocol object
- */
-struct _ThriftTransport
-{
- GObject parent;
-};
-typedef struct _ThriftTransport ThriftTransport;
-
-/*!
- * Thrift Transport class
- */
-struct _ThriftTransportClass
-{
- GObjectClass parent;
-
- /* vtable */
- gboolean (*is_open) (ThriftTransport *transport);
- gboolean (*open) (ThriftTransport *transport, GError **error);
- gboolean (*close) (ThriftTransport *transport, GError **error);
- gint32 (*read) (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error);
- gboolean (*read_end) (ThriftTransport *transport, GError **error);
- gboolean (*write) (ThriftTransport *transport, const gpointer buf,
- const guint32 len, GError **error);
- gboolean (*write_end) (ThriftTransport *transport, GError **error);
- gboolean (*flush) (ThriftTransport *transport, GError **error);
-};
-typedef struct _ThriftTransportClass ThriftTransportClass;
-
-/* used by THRIFT_TYPE_TRANSPORT */
-GType thrift_transport_get_type (void);
-
-/* virtual public methods */
-
-/*!
- * Checks if this transport is opened.
- * \public \memberof ThriftTransportInterface
- */
-gboolean thrift_transport_is_open (ThriftTransport *transport);
-
-/*!
- * Open the transport for reading and writing.
- * \public \memberof ThriftTransportInterface
- */
-gboolean thrift_transport_open (ThriftTransport *transport, GError **error);
-
-/*!
- * Close the transport.
- * \public \memberof ThriftTransportInterface
- */
-gboolean thrift_transport_close (ThriftTransport *transport, GError **error);
-
-/*!
- * Read some data into the buffer buf.
- * \public \memberof ThriftTransportInterface
- */
-gint32 thrift_transport_read (ThriftTransport *transport, gpointer buf,
- guint32 len, GError **error);
-
-/*!
- * Called when read is completed.
- * \public \memberof ThriftTransportInterface
- */
-gboolean thrift_transport_read_end (ThriftTransport *transport, GError **error);
-
-/*!
- * Writes data from a buffer to the transport.
- * \public \memberof ThriftTransportInterface
- */
-gboolean thrift_transport_write (ThriftTransport *transport, const gpointer buf,
- const guint32 len, GError **error);
-
-/*!
- * Called when write is completed.
- * \public \memberof ThriftTransportInterface
- */
-gboolean thrift_transport_write_end (ThriftTransport *transport,
- GError **error);
-
-/*!
- * Flushes any pending data to be written. Typically used with buffered
- * transport mechanisms.
- * \public \memberof ThriftTransportInterface
- */
-gboolean thrift_transport_flush (ThriftTransport *transport, GError **error);
-
-/* define error/exception types */
-typedef enum
-{
- THRIFT_TRANSPORT_ERROR_UNKNOWN,
- THRIFT_TRANSPORT_ERROR_HOST,
- THRIFT_TRANSPORT_ERROR_SOCKET,
- THRIFT_TRANSPORT_ERROR_CONNECT,
- THRIFT_TRANSPORT_ERROR_SEND,
- THRIFT_TRANSPORT_ERROR_RECEIVE,
- THRIFT_TRANSPORT_ERROR_CLOSE
-} ThriftTransportError;
-
-/* define an error domain for GError to use */
-GQuark thrift_transport_error_quark (void);
-#define THRIFT_TRANSPORT_ERROR (thrift_transport_error_quark ())
-
-G_END_DECLS
-
-#endif /* _THRIFT_TRANSPORT_H */
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_transport_factory.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_transport_factory.c b/lib/c_glib/src/thrift/transport/thrift_transport_factory.c
deleted file mode 100644
index e1125a3..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_transport_factory.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <thrift/thrift.h>
-#include <thrift/transport/thrift_transport_factory.h>
-
-G_DEFINE_TYPE(ThriftTransportFactory, thrift_transport_factory, G_TYPE_OBJECT)
-
-/* builds a transport from the base transport. */
-ThriftTransport *
-thrift_transport_factory_get_transport (ThriftTransportFactory *factory,
- ThriftTransport *transport)
-{
- THRIFT_UNUSED_VAR (factory);
- return transport;
-}
-
-static void
-thrift_transport_factory_class_init (ThriftTransportFactoryClass *cls)
-{
- cls->get_transport = thrift_transport_factory_get_transport;
-}
-
-static void
-thrift_transport_factory_init (ThriftTransportFactory *factory)
-{
- THRIFT_UNUSED_VAR (factory);
-}
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/src/thrift/transport/thrift_transport_factory.h
----------------------------------------------------------------------
diff --git a/lib/c_glib/src/thrift/transport/thrift_transport_factory.h b/lib/c_glib/src/thrift/transport/thrift_transport_factory.h
deleted file mode 100644
index e44198b..0000000
--- a/lib/c_glib/src/thrift/transport/thrift_transport_factory.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef _THRIFT_TRANSPORT_FACTORY_H
-#define _THRIFT_TRANSPORT_FACTORY_H
-
-#include <glib-object.h>
-
-#include "thrift_transport.h"
-
-G_BEGIN_DECLS
-
-/*! \file thrift_transport_factory.h
- * \brief Base class for Thrift Transport Factories. Used by Thrift Servers
- * to obtain a client transport from an existing transport. The default
- * implementation simply clones the provided transport.
- */
-
-/* type macros */
-#define THRIFT_TYPE_TRANSPORT_FACTORY (thrift_transport_factory_get_type ())
-#define THRIFT_TRANSPORT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_TRANSPORT_FACTORY, ThriftTransportFactory))
-#define THRIFT_IS_TRANSPORT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_TRANSPORT_FACTORY))
-#define THRIFT_TRANSPORT_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_TRANSPORT_FACTORY, ThriftTransportFactoryClass))
-#define THRIFT_IS_TRANSPORT_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_TRANSPORT_FACTORY))
-#define THRIFT_TRANSPORT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_TRANSPORT_FACTORY, ThriftTransportFactoryClass))
-
-/* Thrift Transport Factory instance */
-struct _ThriftTransportFactory
-{
- GObject parent;
-};
-typedef struct _ThriftTransportFactory ThriftTransportFactory;
-
-/* Thrift Transport Factory class */
-struct _ThriftTransportFactoryClass
-{
- GObjectClass parent;
-
- /* vtable */
- ThriftTransport *(*get_transport) (ThriftTransportFactory *factory,
- ThriftTransport *transport);
-};
-typedef struct _ThriftTransportFactoryClass ThriftTransportFactoryClass;
-
-/* used by THRIFT_TYPE_TRANSPORT_FACTORY */
-GType thrift_transport_factory_get_type (void);
-
-/* virtual public methods */
-ThriftTransport *thrift_transport_factory_get_transport (ThriftTransportFactory *factory, ThriftTransport *transport);
-
-G_END_DECLS
-
-#endif /* _THRIFT_TRANSPORT_FACTORY_H */
http://git-wip-us.apache.org/repos/asf/thrift/blob/e3da7683/lib/c_glib/test/testbinaryprotocol.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/test/testbinaryprotocol.c b/lib/c_glib/test/testbinaryprotocol.c
old mode 100644
new mode 100755
index a07118f..f75c796
--- a/lib/c_glib/test/testbinaryprotocol.c
+++ b/lib/c_glib/test/testbinaryprotocol.c
@@ -24,9 +24,9 @@
#include <netdb.h>
#include <string.h>
-#include <thrift/protocol/thrift_protocol.h>
-#include <thrift/transport/thrift_socket.h>
-#include <thrift/transport/thrift_server_socket.h>
+#include <thrift/c_glib/protocol/thrift_protocol.h>
+#include <thrift/c_glib/transport/thrift_socket.h>
+#include <thrift/c_glib/transport/thrift_server_socket.h>
#define TEST_BOOL TRUE
#define TEST_BYTE 123
@@ -71,7 +71,7 @@ my_thrift_transport_write (ThriftTransport *transport, const gpointer buf,
#define thrift_transport_read my_thrift_transport_read
#define thrift_transport_write my_thrift_transport_write
-#include "../src/thrift/protocol/thrift_binary_protocol.c"
+#include "../src/thrift/c_glib/protocol/thrift_binary_protocol.c"
#undef thrift_transport_read
#undef thrift_transport_write