THRIFT-1003 Polishing c_glib code

Patch: Anatol Pomozov


git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1039299 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/c_glib/src/processor/thrift_processor.c b/lib/c_glib/src/processor/thrift_processor.c
index c5d4034..6e9f454 100644
--- a/lib/c_glib/src/processor/thrift_processor.c
+++ b/lib/c_glib/src/processor/thrift_processor.c
@@ -1,36 +1,32 @@
+/*
+ * 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.h"
 #include "processor/thrift_processor.h"
 
-/* forward declarations */
-static void thrift_processor_class_init (ThriftProcessorClass *cls);
+G_DEFINE_ABSTRACT_TYPE(ThriftProcessor, thrift_processor, G_TYPE_OBJECT)
 
-/* define ThriftProcessorClass's type */
-GType
-thrift_processor_get_type (void)
+gboolean
+thrift_processor_process (ThriftProcessor *processor, ThriftProtocol *in,
+                          ThriftProtocol *out)
 {
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftProcessorClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_processor_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftProcessor),
-      0, /* n_preallocs */
-      NULL, /* instance_init */
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (G_TYPE_OBJECT, "ThriftProcessor",
-                                   &info, G_TYPE_FLAG_ABSTRACT);
-  }
-
-  return type;
+  return THRIFT_PROCESSOR_GET_CLASS (processor)->process (processor, in, out);
 }
 
 /* class initializer for ThriftProcessor */
@@ -41,10 +37,8 @@
   cls->process = thrift_processor_process;
 }
 
-gboolean 
-thrift_processor_process (ThriftProcessor *processor, ThriftProtocol *in,
-                          ThriftProtocol *out)
+static void
+thrift_processor_init (ThriftProcessor *processor)
 {
-  return THRIFT_PROCESSOR_GET_CLASS (processor)->process (processor, in, out);
+  THRIFT_UNUSED_VAR (processor);
 }
-
diff --git a/lib/c_glib/src/processor/thrift_processor.h b/lib/c_glib/src/processor/thrift_processor.h
index cc0b006..390e31b 100644
--- a/lib/c_glib/src/processor/thrift_processor.h
+++ b/lib/c_glib/src/processor/thrift_processor.h
@@ -1,3 +1,22 @@
+/*
+ * 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_PROCESSOR_H
 #define _THRIFT_PROCESSOR_H
 
@@ -5,24 +24,19 @@
 
 #include "protocol/thrift_protocol.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_processor.h
  *  \brief Abstract class for Thrift processors.
  */
 
-/* type macros */	
+/* type macros */
 #define THRIFT_TYPE_PROCESSOR (thrift_processor_get_type ())
-#define THRIFT_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                   THRIFT_TYPE_PROCESSOR, ThriftProcessor))
-#define THRIFT_IS_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                      THRIFT_TYPE_PROCESSOR))
-#define THRIFT_PROCESSOR_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), \
-                                       THRIFT_TYPE_PROCESSOR, \
-                                       ThriftProcessorClass))
-#define THRIFT_IS_PROCESSOR_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), \
-                                          THRIFT_TYPE_PROCESSOR))
-#define THRIFT_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-                                             THRIFT_TYPE_PROCESSOR, \
-                                             ThriftProcessorClass))
+#define THRIFT_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_PROCESSOR, ThriftProcessor))
+#define THRIFT_IS_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_PROCESSOR))
+#define THRIFT_PROCESSOR_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_PROCESSOR, ThriftProcessorClass))
+#define THRIFT_IS_PROCESSOR_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_PROCESSOR))
+#define THRIFT_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_PROCESSOR, ThriftProcessorClass))
 
 /*!
  * Thrift Processorobject
@@ -47,7 +61,7 @@
 typedef struct _ThriftProcessorClass ThriftProcessorClass;
 
 /* used by THRIFT_TYPE_PROCESSOR */
-GType thrift_processor_get_type (void); 
+GType thrift_processor_get_type (void);
 
 /*!
  * Processes the request.
@@ -56,4 +70,6 @@
 gboolean thrift_processor_process (ThriftProcessor *processor,
                                    ThriftProtocol *in, ThriftProtocol *out);
 
+G_END_DECLS
+
 #endif /* _THRIFT_PROCESSOR_H */
diff --git a/lib/c_glib/src/protocol/thrift_binary_protocol.c b/lib/c_glib/src/protocol/thrift_binary_protocol.c
index afedc9e..7ee28e8 100644
--- a/lib/c_glib/src/protocol/thrift_binary_protocol.c
+++ b/lib/c_glib/src/protocol/thrift_binary_protocol.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <string.h>
 #include <stdio.h>
 
@@ -5,118 +24,7 @@
 #include "protocol/thrift_protocol.h"
 #include "protocol/thrift_binary_protocol.h"
 
-/* forward declarations */
-static guint64 thrift_bitwise_cast_guint64 (gdouble v);
-static gdouble thrift_bitwise_cast_gdouble (guint64 v);
-static void thrift_binary_protocol_class_init (ThriftProtocolClass *cls);
-
-gint32 thrift_binary_protocol_write_message_begin (ThriftProtocol *protocol, 
-           const gchar *name, const ThriftMessageType message_type,
-           const gint32 seqid, GError **error);
-gint32 thrift_binary_protocol_write_message_end (ThriftProtocol *protocol,
-                                                 GError **error);
-gint32 thrift_binary_protocol_write_struct_begin (ThriftProtocol *protocol,
-                                                  const gchar *name,
-                                                  GError **error);
-gint32 thrift_binary_protocol_write_struct_end (ThriftProtocol *protocol,
-                                                GError **error);
-gint32 thrift_binary_protocol_write_field_begin (ThriftProtocol *protocol,
-                                                 const gchar *name,
-                                                 const ThriftType field_type,
-                                                 const gint16 field_id,
-                                                 GError **error);
-gint32 thrift_binary_protocol_write_field_end (ThriftProtocol *protocol,
-                                               GError **error);
-gint32 thrift_binary_protocol_write_field_stop (ThriftProtocol *protocol,
-                                                GError **error);
-gint32 thrift_binary_protocol_write_map_begin (ThriftProtocol *protocol,
-                                               const ThriftType key_type,
-                                               const ThriftType value_type,
-                                               const guint32 size,
-                                               GError **error);
-gint32 thrift_binary_protocol_write_map_end (ThriftProtocol *protocol,
-                                             GError **error);
-gint32 thrift_binary_protocol_write_list_begin (ThriftProtocol *protocol,
-                                                const ThriftType element_type,
-                                                const guint32 size, 
-                                                GError **error);
-gint32 thrift_binary_protocol_write_list_end (ThriftProtocol *protocol,
-                                              GError **error);
-gint32 thrift_binary_protocol_write_set_begin (ThriftProtocol *protocol,
-                                               const ThriftType element_type,
-                                               const guint32 size, 
-                                               GError **error);
-gint32 thrift_binary_protocol_write_set_end (ThriftProtocol *protocol,
-                                             GError **error);
-gint32 thrift_binary_protocol_write_bool (ThriftProtocol *protocol,
-                                          const gboolean value, GError **error);
-gint32 thrift_binary_protocol_write_byte (ThriftProtocol *protocol,
-                                          const gint8 value, GError **error);
-gint32 thrift_binary_protocol_write_i16 (ThriftProtocol *protocol,
-                                         const gint16 value, GError **error);
-gint32 thrift_binary_protocol_write_i32 (ThriftProtocol *protocol,
-                                         const gint32 value, GError **error);
-gint32 thrift_binary_protocol_write_i64 (ThriftProtocol *protocol,
-                                         const gint64 value, GError **error);
-gint32 thrift_binary_protocol_write_double (ThriftProtocol *protocol,
-                                            const gdouble value,
-                                            GError **error);
-gint32 thrift_binary_protocol_write_string (ThriftProtocol *protocol,
-                                            const gchar *str, GError **error);
-gint32 thrift_binary_protocol_write_binary (ThriftProtocol *protocol,
-                                            const gpointer buf,
-                                            const guint32 len, GError **error);
-gint32 thrift_binary_protocol_read_message_begin (
-           ThriftProtocol *protocol, gchar **name,
-           ThriftMessageType *message_type, gint32 *seqid, GError **error);
-gint32 thrift_binary_protocol_read_message_end (ThriftProtocol *protocol,
-                                                GError **error);
-gint32 thrift_binary_protocol_read_struct_begin (ThriftProtocol *protocol,
-                                                 gchar **name,
-                                                 GError **error);
-gint32 thrift_binary_protocol_read_struct_end (ThriftProtocol *protocol,
-                                               GError **error);
-gint32 thrift_binary_protocol_read_field_begin (ThriftProtocol *protocol,
-                                                gchar **name,
-                                                ThriftType *field_type,
-                                                gint16 *field_id,
-                                                GError **error);
-gint32 thrift_binary_protocol_read_field_end (ThriftProtocol *protocol,
-                                              GError **error);
-gint32 thrift_binary_protocol_read_map_begin (ThriftProtocol *protocol,
-                                              ThriftType *key_type,
-                                              ThriftType *value_type,
-                                              guint32 *size,
-                                              GError **error);
-gint32 thrift_binary_protocol_read_map_end (ThriftProtocol *protocol,
-                                            GError **error);
-gint32 thrift_binary_protocol_read_list_begin (ThriftProtocol *protocol,
-                                               ThriftType *element_type,
-                                               guint32 *size, GError **error);
-gint32 thrift_binary_protocol_read_list_end (ThriftProtocol *protocol,
-                                             GError **error);
-gint32 thrift_binary_protocol_read_set_begin (ThriftProtocol *protocol,
-                                              ThriftType *element_type,
-                                              guint32 *size, GError **error);
-gint32 thrift_binary_protocol_read_set_end (ThriftProtocol *protocol,
-                                            GError **error);
-gint32 thrift_binary_protocol_read_bool (ThriftProtocol *protocol,
-                                         gboolean *value, GError **error);
-gint32 thrift_binary_protocol_read_byte (ThriftProtocol *protocol, gint8 *value,
-                                         GError **error);
-gint32 thrift_binary_protocol_read_i16 (ThriftProtocol *protocol, gint16 *value,
-                                        GError **error);
-gint32 thrift_binary_protocol_read_i32 (ThriftProtocol *protocol, gint32 *value,
-                                        GError **error);
-gint32 thrift_binary_protocol_read_i64 (ThriftProtocol *protocol, gint64 *value,
-                                        GError **error);
-gint32 thrift_binary_protocol_read_double (ThriftProtocol *protocol,
-                                           gdouble *value, GError **error);
-gint32 thrift_binary_protocol_read_string (ThriftProtocol *protocol,
-                                           gchar **str, GError **error);
-gint32 thrift_binary_protocol_read_binary (ThriftProtocol *protocol,
-                                           gpointer *buf, guint32 *len,
-                                           GError **error);
+G_DEFINE_TYPE(ThriftBinaryProtocol, thrift_binary_protocol, THRIFT_TYPE_PROTOCOL)
 
 static guint64
 thrift_bitwise_cast_guint64 (gdouble v)
@@ -140,82 +48,6 @@
   return u.to;
 }
 
-GType
-thrift_binary_protocol_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftBinaryProtocolClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_binary_protocol_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftBinaryProtocol),
-      0, /* n_preallocs */
-      NULL, /* instance_init */
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_PROTOCOL,
-                                   "ThriftBinaryProtocolType",
-                                   &info, 0);
-  }
-
-  return type;
-}
-
-/* initialize the class */
-static void
-thrift_binary_protocol_class_init (ThriftProtocolClass *cls)
-{
-  cls->write_message_begin = thrift_binary_protocol_write_message_begin;
-  cls->write_message_end = thrift_binary_protocol_write_message_end;
-  cls->write_struct_begin = thrift_binary_protocol_write_struct_begin;
-  cls->write_struct_end = thrift_binary_protocol_write_struct_end;
-  cls->write_field_begin = thrift_binary_protocol_write_field_begin;
-  cls->write_field_end = thrift_binary_protocol_write_field_end;
-  cls->write_field_stop = thrift_binary_protocol_write_field_stop;
-  cls->write_map_begin = thrift_binary_protocol_write_map_begin;
-  cls->write_map_end = thrift_binary_protocol_write_map_end;
-  cls->write_list_begin = thrift_binary_protocol_write_list_begin;
-  cls->write_list_end = thrift_binary_protocol_write_list_end;
-  cls->write_set_begin = thrift_binary_protocol_write_set_begin;
-  cls->write_set_end = thrift_binary_protocol_write_set_end;
-  cls->write_bool = thrift_binary_protocol_write_bool;
-  cls->write_byte = thrift_binary_protocol_write_byte;
-  cls->write_i16 = thrift_binary_protocol_write_i16;
-  cls->write_i32 = thrift_binary_protocol_write_i32;
-  cls->write_i64 = thrift_binary_protocol_write_i64;
-  cls->write_double = thrift_binary_protocol_write_double;
-  cls->write_string = thrift_binary_protocol_write_string;
-  cls->write_binary = thrift_binary_protocol_write_binary;
-  cls->read_message_begin = thrift_binary_protocol_read_message_begin;
-  cls->read_message_end = thrift_binary_protocol_read_message_end;
-  cls->read_struct_begin = thrift_binary_protocol_read_struct_begin;
-  cls->read_struct_end = thrift_binary_protocol_read_struct_end;
-  cls->read_field_begin = thrift_binary_protocol_read_field_begin;
-  cls->read_field_end = thrift_binary_protocol_read_field_end;
-  cls->read_map_begin = thrift_binary_protocol_read_map_begin;
-  cls->read_map_end = thrift_binary_protocol_read_map_end;
-  cls->read_list_begin = thrift_binary_protocol_read_list_begin;
-  cls->read_list_end = thrift_binary_protocol_read_list_end;
-  cls->read_set_begin = thrift_binary_protocol_read_set_begin;
-  cls->read_set_end = thrift_binary_protocol_read_set_end;
-  cls->read_bool = thrift_binary_protocol_read_bool;
-  cls->read_byte = thrift_binary_protocol_read_byte;
-  cls->read_i16 = thrift_binary_protocol_read_i16;
-  cls->read_i32 = thrift_binary_protocol_read_i32;
-  cls->read_i64 = thrift_binary_protocol_read_i64;
-  cls->read_double = thrift_binary_protocol_read_double;
-  cls->read_string = thrift_binary_protocol_read_string;
-  cls->read_binary = thrift_binary_protocol_read_binary;
-}
-
 gint32
 thrift_binary_protocol_write_message_begin (ThriftProtocol *protocol,
     const gchar *name, const ThriftMessageType message_type,
@@ -980,4 +812,57 @@
   return xfer;
 }
 
+static void
+thrift_binary_protocol_init (ThriftBinaryProtocol *protocol)
+{
+  THRIFT_UNUSED_VAR (protocol);
+}
 
+/* initialize the class */
+static void
+thrift_binary_protocol_class_init (ThriftBinaryProtocolClass *klass)
+{
+  ThriftProtocolClass *cls = THRIFT_PROTOCOL_CLASS (klass);
+
+  cls->write_message_begin = thrift_binary_protocol_write_message_begin;
+  cls->write_message_end = thrift_binary_protocol_write_message_end;
+  cls->write_struct_begin = thrift_binary_protocol_write_struct_begin;
+  cls->write_struct_end = thrift_binary_protocol_write_struct_end;
+  cls->write_field_begin = thrift_binary_protocol_write_field_begin;
+  cls->write_field_end = thrift_binary_protocol_write_field_end;
+  cls->write_field_stop = thrift_binary_protocol_write_field_stop;
+  cls->write_map_begin = thrift_binary_protocol_write_map_begin;
+  cls->write_map_end = thrift_binary_protocol_write_map_end;
+  cls->write_list_begin = thrift_binary_protocol_write_list_begin;
+  cls->write_list_end = thrift_binary_protocol_write_list_end;
+  cls->write_set_begin = thrift_binary_protocol_write_set_begin;
+  cls->write_set_end = thrift_binary_protocol_write_set_end;
+  cls->write_bool = thrift_binary_protocol_write_bool;
+  cls->write_byte = thrift_binary_protocol_write_byte;
+  cls->write_i16 = thrift_binary_protocol_write_i16;
+  cls->write_i32 = thrift_binary_protocol_write_i32;
+  cls->write_i64 = thrift_binary_protocol_write_i64;
+  cls->write_double = thrift_binary_protocol_write_double;
+  cls->write_string = thrift_binary_protocol_write_string;
+  cls->write_binary = thrift_binary_protocol_write_binary;
+  cls->read_message_begin = thrift_binary_protocol_read_message_begin;
+  cls->read_message_end = thrift_binary_protocol_read_message_end;
+  cls->read_struct_begin = thrift_binary_protocol_read_struct_begin;
+  cls->read_struct_end = thrift_binary_protocol_read_struct_end;
+  cls->read_field_begin = thrift_binary_protocol_read_field_begin;
+  cls->read_field_end = thrift_binary_protocol_read_field_end;
+  cls->read_map_begin = thrift_binary_protocol_read_map_begin;
+  cls->read_map_end = thrift_binary_protocol_read_map_end;
+  cls->read_list_begin = thrift_binary_protocol_read_list_begin;
+  cls->read_list_end = thrift_binary_protocol_read_list_end;
+  cls->read_set_begin = thrift_binary_protocol_read_set_begin;
+  cls->read_set_end = thrift_binary_protocol_read_set_end;
+  cls->read_bool = thrift_binary_protocol_read_bool;
+  cls->read_byte = thrift_binary_protocol_read_byte;
+  cls->read_i16 = thrift_binary_protocol_read_i16;
+  cls->read_i32 = thrift_binary_protocol_read_i32;
+  cls->read_i64 = thrift_binary_protocol_read_i64;
+  cls->read_double = thrift_binary_protocol_read_double;
+  cls->read_string = thrift_binary_protocol_read_string;
+  cls->read_binary = thrift_binary_protocol_read_binary;
+}
diff --git a/lib/c_glib/src/protocol/thrift_binary_protocol.h b/lib/c_glib/src/protocol/thrift_binary_protocol.h
index 461c524..95dced9 100644
--- a/lib/c_glib/src/protocol/thrift_binary_protocol.h
+++ b/lib/c_glib/src/protocol/thrift_binary_protocol.h
@@ -1,3 +1,22 @@
+/*
+ * 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_BINARY_PROTOCOL_H
 #define _THRIFT_BINARY_PROTOCOL_H
 
@@ -6,6 +25,8 @@
 #include "protocol/thrift_protocol.h"
 #include "transport/thrift_transport.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_binary_protocol.h
  *  \brief Binary protocol implementation of a Thrift protocol.  Implements the
  *         ThriftProtocol interface.
@@ -13,19 +34,11 @@
 
 /* type macros */
 #define THRIFT_TYPE_BINARY_PROTOCOL (thrift_binary_protocol_get_type ())
-#define THRIFT_BINARY_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                         THRIFT_TYPE_BINARY_PROTOCOL, \
-                                         ThriftBinaryProtocol))
-#define THRIFT_IS_BINARY_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                            THRIFT_TYPE_BINARY_PROTOCOL))
-#define THRIFT_BINARY_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), \
-                                             THRIFT_TYPE_BINARY_PROTOCOL, \
-                                             ThriftBinaryProtocolClass))
-#define THRIFT_IS_BINARY_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), \
-                                                THRIFT_TYPE_BINARY_PROTOCOL))
-#define THRIFT_BINARY_PROTOCOL_GET_CLASS(obj) \
-            (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_BINARY_PROTOCOL, \
-                                        ThriftBinaryProtocolClass))
+#define THRIFT_BINARY_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_BINARY_PROTOCOL, ThriftBinaryProtocol))
+#define THRIFT_IS_BINARY_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_BINARY_PROTOCOL))
+#define THRIFT_BINARY_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_BINARY_PROTOCOL, ThriftBinaryProtocolClass))
+#define THRIFT_IS_BINARY_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_BINARY_PROTOCOL))
+#define THRIFT_BINARY_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_BINARY_PROTOCOL, ThriftBinaryProtocolClass))
 
 /* version numbers */
 #define THRIFT_BINARY_PROTOCOL_VERSION_1 0x80010000
@@ -52,4 +65,6 @@
 /* used by THRIFT_TYPE_BINARY_PROTOCOL */
 GType thrift_binary_protocol_get_type (void);
 
+G_END_DECLS
+
 #endif /* _THRIFT_BINARY_PROTOCOL_H */
diff --git a/lib/c_glib/src/protocol/thrift_binary_protocol_factory.c b/lib/c_glib/src/protocol/thrift_binary_protocol_factory.c
index a3b4373..3c9f522 100644
--- a/lib/c_glib/src/protocol/thrift_binary_protocol_factory.c
+++ b/lib/c_glib/src/protocol/thrift_binary_protocol_factory.c
@@ -1,47 +1,27 @@
+/*
+ * 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.h"
 #include "protocol/thrift_binary_protocol.h"
 #include "protocol/thrift_binary_protocol_factory.h"
 
-/* forward declarations */
-static void thrift_binary_protocol_factory_class_init (ThriftProtocolFactoryClass *cls);
-
-ThriftProtocol *thrift_binary_protocol_factory_get_protocol (ThriftProtocolFactory *factory, ThriftTransport *transport);
-
-GType
-thrift_binary_protocol_factory_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftBinaryProtocolFactoryClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_binary_protocol_factory_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftBinaryProtocolFactory),
-      0, /* n_preallocs */
-      NULL, /* instance_init */
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_PROTOCOL_FACTORY,
-                                   "ThriftBinaryProtocolFactoryType",
-                                   &info, 0);
-  }
-
-  return type;
-}
-
-static void
-thrift_binary_protocol_factory_class_init (ThriftProtocolFactoryClass *cls)
-{
-  cls->get_protocol = thrift_binary_protocol_factory_get_protocol;
-}
+G_DEFINE_TYPE(ThriftBinaryProtocolFactory, thrift_binary_protocol_factory, THRIFT_TYPE_PROTOCOL_FACTORY)
 
 ThriftProtocol *
 thrift_binary_protocol_factory_get_protocol (ThriftProtocolFactory *factory,
@@ -55,4 +35,16 @@
   return THRIFT_PROTOCOL (tb);
 }
 
+static void
+thrift_binary_protocol_factory_class_init (ThriftBinaryProtocolFactoryClass *cls)
+{
+  ThriftProtocolFactoryClass *protocol_factory_class = THRIFT_PROTOCOL_FACTORY_CLASS (cls);
 
+  protocol_factory_class->get_protocol = thrift_binary_protocol_factory_get_protocol;
+}
+
+static void
+thrift_binary_protocol_factory_init (ThriftBinaryProtocolFactory *factory)
+{
+  THRIFT_UNUSED_VAR (factory);
+}
diff --git a/lib/c_glib/src/protocol/thrift_binary_protocol_factory.h b/lib/c_glib/src/protocol/thrift_binary_protocol_factory.h
index ae4ae40..3b7fcc2 100644
--- a/lib/c_glib/src/protocol/thrift_binary_protocol_factory.h
+++ b/lib/c_glib/src/protocol/thrift_binary_protocol_factory.h
@@ -1,3 +1,22 @@
+/*
+ * 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_BINARY_PROTOCOL_FACTORY_H
 #define _THRIFT_BINARY_PROTOCOL_FACTORY_H
 
@@ -5,27 +24,15 @@
 
 #include "protocol/thrift_protocol_factory.h"
 
+G_BEGIN_DECLS
+
 /* type macros */
-#define THRIFT_TYPE_BINARY_PROTOCOL_FACTORY \
-            (thrift_binary_protocol_factory_get_type ())
-#define THRIFT_BINARY_PROTOCOL_FACTORY(obj) \
-            (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                         THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, \
-                                         ThriftBinaryProtocolFactory))
-#define THRIFT_IS_BINARY_PROTOCOL_FACTORY(obj) \
-            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                         THRIFT_TYPE_BINARY_PROTOCOL_FACTORY))
-#define THRIFT_BINARY_PROTOCOL_FACTORY_CLASS(c) \
-            (G_TYPE_CHECK_CLASS_CAST ((c), \
-                                      THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, \
-                                      ThriftBinaryProtocolFactoryClass))
-#define THRIFT_IS_BINARY_PROTOCOL_FACTORY_CLASS(c) \
-            (G_TYPE_CHECK_CLASS_TYPE ((c), \
-                                      THRIFT_TYPE_BINARY_PROTOCOL_FACTORY))
-#define THRIFT_BINARY_PROTOCOL_FACTORY_GET_CLASS(obj) \
-            (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-                                        THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, \
-                                        ThriftBinaryProtocolFactoryClass))
+#define THRIFT_TYPE_BINARY_PROTOCOL_FACTORY (thrift_binary_protocol_factory_get_type ())
+#define THRIFT_BINARY_PROTOCOL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, ThriftBinaryProtocolFactory))
+#define THRIFT_IS_BINARY_PROTOCOL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_BINARY_PROTOCOL_FACTORY))
+#define THRIFT_BINARY_PROTOCOL_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, ThriftBinaryProtocolFactoryClass))
+#define THRIFT_IS_BINARY_PROTOCOL_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_BINARY_PROTOCOL_FACTORY))
+#define THRIFT_BINARY_PROTOCOL_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, ThriftBinaryProtocolFactoryClass))
 
 struct _ThriftBinaryProtocolFactory
 {
@@ -37,10 +44,11 @@
 {
   ThriftProtocolFactoryClass parent;
 };
-typedef struct _ThriftBinaryProtocolFactoryClass 
-               ThriftBinaryProtocolFactoryClass;
+typedef struct _ThriftBinaryProtocolFactoryClass ThriftBinaryProtocolFactoryClass;
 
 /* used by THRIFT_TYPE_BINARY_PROTOCOL_FACTORY */
 GType thrift_binary_protocol_factory_get_type (void);
 
+G_END_DECLS
+
 #endif /* _THRIFT_BINARY_PROTOCOL_FACTORY_H */
diff --git a/lib/c_glib/src/protocol/thrift_protocol.c b/lib/c_glib/src/protocol/thrift_protocol.c
index 8ea54b6..d951031 100644
--- a/lib/c_glib/src/protocol/thrift_protocol.c
+++ b/lib/c_glib/src/protocol/thrift_protocol.c
@@ -1,3 +1,22 @@
+/*
+ * 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.h"
 #include "protocol/thrift_protocol.h"
 #include "transport/thrift_transport.h"
@@ -12,103 +31,7 @@
   PROP_THRIFT_PROTOCOL_TRANSPORT
 };
 
-/* forward declarations */
-static void thrift_protocol_instance_init (ThriftProtocol *protocol);
-static void thrift_protocol_class_init (ThriftProtocolClass *cls);
-void thrift_protocol_get_property (GObject *object, guint property_id,
-                                   GValue *value, GParamSpec *pspec);
-void thrift_protocol_set_property (GObject *object, guint property_id,
-                                   const GValue *value, GParamSpec *pspec);
-
-/* define ThriftProtocolInterface's type */
-GType
-thrift_protocol_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info = {
-      sizeof (ThriftProtocolClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_protocol_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftProtocol),
-      0, /* n_preallocs */
-      (GInstanceInitFunc) thrift_protocol_instance_init,
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (G_TYPE_OBJECT, "ThriftProtocol",
-                                   &info, G_TYPE_FLAG_ABSTRACT);
-  }
-
-  return type;
-}
-
-static void
-thrift_protocol_instance_init (ThriftProtocol *protocol)
-{
-  protocol->transport = NULL;
-}
-
-static void
-thrift_protocol_class_init (ThriftProtocolClass *cls)
-{
-  GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
-
-  gobject_class->get_property = thrift_protocol_get_property;
-  gobject_class->set_property = thrift_protocol_set_property;
-
-  g_object_class_install_property (gobject_class,
-      PROP_THRIFT_PROTOCOL_TRANSPORT,
-      g_param_spec_object ("transport", "Transport", "Thrift Transport",
-                           THRIFT_TYPE_TRANSPORT,
-                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
-  cls->write_message_begin = thrift_protocol_write_message_begin;
-  cls->write_message_end = thrift_protocol_write_message_end;
-  cls->write_struct_begin = thrift_protocol_write_struct_begin;
-  cls->write_struct_end = thrift_protocol_write_struct_end;
-  cls->write_field_begin = thrift_protocol_write_field_begin;
-  cls->write_field_end = thrift_protocol_write_field_end;
-  cls->write_field_stop = thrift_protocol_write_field_stop;
-  cls->write_map_begin = thrift_protocol_write_map_begin;
-  cls->write_map_end = thrift_protocol_write_map_end;
-  cls->write_list_begin = thrift_protocol_write_list_begin;
-  cls->write_list_end = thrift_protocol_write_list_end;
-  cls->write_set_begin = thrift_protocol_write_set_begin;
-  cls->write_set_end = thrift_protocol_write_set_end;
-  cls->write_bool = thrift_protocol_write_bool;
-  cls->write_byte = thrift_protocol_write_byte;
-  cls->write_i16 = thrift_protocol_write_i16;
-  cls->write_i32 = thrift_protocol_write_i32;
-  cls->write_i64 = thrift_protocol_write_i64;
-  cls->write_double = thrift_protocol_write_double;
-  cls->write_string = thrift_protocol_write_string;
-  cls->write_binary = thrift_protocol_write_binary;
-  cls->read_message_begin = thrift_protocol_read_message_begin;
-  cls->read_message_end = thrift_protocol_read_message_end;
-  cls->read_struct_begin = thrift_protocol_read_struct_begin;
-  cls->read_struct_end = thrift_protocol_read_struct_end;
-  cls->read_field_begin = thrift_protocol_read_field_begin;
-  cls->read_field_end = thrift_protocol_read_field_end;
-  cls->read_map_begin = thrift_protocol_read_map_begin;
-  cls->read_map_end = thrift_protocol_read_map_end;
-  cls->read_list_begin = thrift_protocol_read_list_begin;
-  cls->read_set_begin = thrift_protocol_read_set_begin;
-  cls->read_set_end = thrift_protocol_read_set_end;
-  cls->read_bool = thrift_protocol_read_bool;
-  cls->read_byte = thrift_protocol_read_byte;
-  cls->read_i16 = thrift_protocol_read_i16;
-  cls->read_i32 = thrift_protocol_read_i32;
-  cls->read_i64 = thrift_protocol_read_i64;
-  cls->read_double = thrift_protocol_read_double;
-  cls->read_string = thrift_protocol_read_string;
-  cls->read_binary = thrift_protocol_read_binary;
-}
+G_DEFINE_ABSTRACT_TYPE(ThriftProtocol, thrift_protocol, G_TYPE_OBJECT)
 
 void
 thrift_protocol_get_property (GObject *object, guint property_id,
@@ -602,3 +525,65 @@
   return g_quark_from_static_string (THRIFT_PROTOCOL_ERROR_DOMAIN);
 }
 
+
+static void
+thrift_protocol_init (ThriftProtocol *protocol)
+{
+  protocol->transport = NULL;
+}
+
+static void
+thrift_protocol_class_init (ThriftProtocolClass *cls)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
+
+  gobject_class->get_property = thrift_protocol_get_property;
+  gobject_class->set_property = thrift_protocol_set_property;
+
+  g_object_class_install_property (gobject_class,
+      PROP_THRIFT_PROTOCOL_TRANSPORT,
+      g_param_spec_object ("transport", "Transport", "Thrift Transport",
+                           THRIFT_TYPE_TRANSPORT,
+                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+  cls->write_message_begin = thrift_protocol_write_message_begin;
+  cls->write_message_end = thrift_protocol_write_message_end;
+  cls->write_struct_begin = thrift_protocol_write_struct_begin;
+  cls->write_struct_end = thrift_protocol_write_struct_end;
+  cls->write_field_begin = thrift_protocol_write_field_begin;
+  cls->write_field_end = thrift_protocol_write_field_end;
+  cls->write_field_stop = thrift_protocol_write_field_stop;
+  cls->write_map_begin = thrift_protocol_write_map_begin;
+  cls->write_map_end = thrift_protocol_write_map_end;
+  cls->write_list_begin = thrift_protocol_write_list_begin;
+  cls->write_list_end = thrift_protocol_write_list_end;
+  cls->write_set_begin = thrift_protocol_write_set_begin;
+  cls->write_set_end = thrift_protocol_write_set_end;
+  cls->write_bool = thrift_protocol_write_bool;
+  cls->write_byte = thrift_protocol_write_byte;
+  cls->write_i16 = thrift_protocol_write_i16;
+  cls->write_i32 = thrift_protocol_write_i32;
+  cls->write_i64 = thrift_protocol_write_i64;
+  cls->write_double = thrift_protocol_write_double;
+  cls->write_string = thrift_protocol_write_string;
+  cls->write_binary = thrift_protocol_write_binary;
+  cls->read_message_begin = thrift_protocol_read_message_begin;
+  cls->read_message_end = thrift_protocol_read_message_end;
+  cls->read_struct_begin = thrift_protocol_read_struct_begin;
+  cls->read_struct_end = thrift_protocol_read_struct_end;
+  cls->read_field_begin = thrift_protocol_read_field_begin;
+  cls->read_field_end = thrift_protocol_read_field_end;
+  cls->read_map_begin = thrift_protocol_read_map_begin;
+  cls->read_map_end = thrift_protocol_read_map_end;
+  cls->read_list_begin = thrift_protocol_read_list_begin;
+  cls->read_set_begin = thrift_protocol_read_set_begin;
+  cls->read_set_end = thrift_protocol_read_set_end;
+  cls->read_bool = thrift_protocol_read_bool;
+  cls->read_byte = thrift_protocol_read_byte;
+  cls->read_i16 = thrift_protocol_read_i16;
+  cls->read_i32 = thrift_protocol_read_i32;
+  cls->read_i64 = thrift_protocol_read_i64;
+  cls->read_double = thrift_protocol_read_double;
+  cls->read_string = thrift_protocol_read_string;
+  cls->read_binary = thrift_protocol_read_binary;
+}
diff --git a/lib/c_glib/src/protocol/thrift_protocol.h b/lib/c_glib/src/protocol/thrift_protocol.h
index 0340a60..1aeaed9 100644
--- a/lib/c_glib/src/protocol/thrift_protocol.h
+++ b/lib/c_glib/src/protocol/thrift_protocol.h
@@ -1,3 +1,22 @@
+/*
+ * 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_PROTOCOL_H
 #define _THRIFT_PROTOCOL_H
 
@@ -5,12 +24,18 @@
 
 #include "transport/thrift_transport.h"
 
+G_BEGIN_DECLS
+
+/*! \file thrift_protocol.h
+ *  \brief Abstract class for Thrift protocol implementations.
+ */
+
 /**
  * Enumerated definition of the types that the Thrift protocol supports.
  * Take special note of the T_END type which is used specifically to mark
  * the end of a sequence of fields.
  */
-enum _ThriftType {
+typedef enum {
   T_STOP   = 0,
   T_VOID   = 1,
   T_BOOL   = 2,
@@ -29,39 +54,26 @@
   T_LIST   = 15,
   T_UTF8   = 16,
   T_UTF16  = 17
-};
-typedef enum _ThriftType ThriftType;
+} ThriftType;
 
 /**
  * Enumerated definition of the message types that the Thrift protocol
  * supports.
  */
-enum _ThriftMessageType {
+typedef enum {
   T_CALL      = 1,
   T_REPLY     = 2,
   T_EXCEPTION = 3,
   T_ONEWAY    = 4
-};
-typedef enum _ThriftMessageType ThriftMessageType;
-
-/*! \file thrift_protocol.h
- *  \brief Abstract class for Thrift protocol implementations.
- */
+} ThriftMessageType;
 
 /* type macros */
 #define THRIFT_TYPE_PROTOCOL (thrift_protocol_get_type ())
-#define THRIFT_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                  THRIFT_TYPE_PROTOCOL, ThriftProtocol))
-#define THRIFT_IS_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                     THRIFT_TYPE_PROTOCOL))
-#define THRIFT_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), \
-                                      THRIFT_TYPE_PROTOCOL, \
-                                      ThriftProtocolClass))
-#define THRIFT_IS_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), \
-                                         THRIFT_TYPE_PROTOCOL))
-#define THRIFT_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-                                            THRIFT_TYPE_PROTOCOL, \
-                                            ThriftProtocolClass))
+#define THRIFT_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_PROTOCOL, ThriftProtocol))
+#define THRIFT_IS_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_PROTOCOL))
+#define THRIFT_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_PROTOCOL, ThriftProtocolClass))
+#define THRIFT_IS_PROTOCOL_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_PROTOCOL))
+#define THRIFT_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_PROTOCOL, ThriftProtocolClass))
 
 /*!
  * Thrift Protocol object
@@ -141,11 +153,11 @@
   gint32 (*read_map_end) (ThriftProtocol *protocol, GError **error);
   gint32 (*read_list_begin) (ThriftProtocol *protocol, ThriftType *element_type,
                              guint32 *size, GError **error);
-  gint32 (*read_list_end) (ThriftProtocol *protocol, GError **error); 
+  gint32 (*read_list_end) (ThriftProtocol *protocol, GError **error);
   gint32 (*read_set_begin) (ThriftProtocol *protocol, ThriftType *element_type,
-                            guint32 *size, GError **error); 
+                            guint32 *size, GError **error);
   gint32 (*read_set_end) (ThriftProtocol *protocol, GError **error);
-  gint32 (*read_bool) (ThriftProtocol *protocol, gboolean *value, 
+  gint32 (*read_bool) (ThriftProtocol *protocol, gboolean *value,
                        GError **error);
   gint32 (*read_byte) (ThriftProtocol *protocol, gint8 *value, GError **error);
   gint32 (*read_i16) (ThriftProtocol *protocol, gint16 *value, GError **error);
@@ -163,7 +175,7 @@
 GType thrift_protocol_get_type (void);
 
 /* virtual public methods */
-gint32 thrift_protocol_write_message_begin (ThriftProtocol *protocol, 
+gint32 thrift_protocol_write_message_begin (ThriftProtocol *protocol,
            const gchar *name, const ThriftMessageType message_type,
            const gint32 seqid, GError **error);
 
@@ -231,11 +243,11 @@
 gint32 thrift_protocol_write_string (ThriftProtocol *protocol,
                                      const gchar *str, GError **error);
 
-gint32 thrift_protocol_write_binary (ThriftProtocol *protocol, 
+gint32 thrift_protocol_write_binary (ThriftProtocol *protocol,
                                      const gpointer buf,
                                      const guint32 len, GError **error);
 
-gint32 thrift_protocol_read_message_begin (ThriftProtocol *thrift_protocol, 
+gint32 thrift_protocol_read_message_begin (ThriftProtocol *thrift_protocol,
                                            gchar **name,
                                            ThriftMessageType *message_type,
                                            gint32 *seqid, GError **error);
@@ -321,4 +333,6 @@
 GQuark thrift_protocol_error_quark (void);
 #define THRIFT_PROTOCOL_ERROR (thrift_protocol_error_quark ())
 
+G_END_DECLS
+
 #endif /* _THRIFT_PROTOCOL_H */
diff --git a/lib/c_glib/src/protocol/thrift_protocol_factory.c b/lib/c_glib/src/protocol/thrift_protocol_factory.c
index 53b468d..073b33c 100644
--- a/lib/c_glib/src/protocol/thrift_protocol_factory.c
+++ b/lib/c_glib/src/protocol/thrift_protocol_factory.c
@@ -1,44 +1,26 @@
+/*
+ * 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.h"
 #include "protocol/thrift_protocol_factory.h"
 
-/* forward declarations */
-static void thrift_protocol_factory_class_init (ThriftProtocolFactoryClass *cls);
-ThriftProtocol *thrift_protocol_factory_get_protocol(ThriftProtocolFactory *factory, ThriftTransport *transport);
-
-
-/* define ThriftProtocolFactoryInterface's type */
-GType
-thrift_protocol_factory_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info = {
-      sizeof (ThriftProtocolFactoryClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_protocol_factory_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftProtocolFactory),
-      0, /* n_preallocs */
-      NULL, /* instance_init */
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (G_TYPE_OBJECT, "ThriftProtocolFactory",
-                                   &info, G_TYPE_FLAG_ABSTRACT);
-  }
-
-  return type;
-}
-
-static void
-thrift_protocol_factory_class_init (ThriftProtocolFactoryClass *cls)
-{
-  cls->get_protocol = thrift_protocol_factory_get_protocol;
-}
+G_DEFINE_ABSTRACT_TYPE(ThriftProtocolFactory, thrift_protocol_factory, G_TYPE_OBJECT)
 
 ThriftProtocol *
 thrift_protocol_factory_get_protocol(ThriftProtocolFactory *factory,
@@ -48,3 +30,14 @@
                                                                     transport);
 }
 
+static void
+thrift_protocol_factory_init (ThriftProtocolFactory *factory)
+{
+  THRIFT_UNUSED_VAR (factory);
+}
+
+static void
+thrift_protocol_factory_class_init (ThriftProtocolFactoryClass *cls)
+{
+  cls->get_protocol = thrift_protocol_factory_get_protocol;
+}
diff --git a/lib/c_glib/src/protocol/thrift_protocol_factory.h b/lib/c_glib/src/protocol/thrift_protocol_factory.h
index d153255..b9aeb1b 100644
--- a/lib/c_glib/src/protocol/thrift_protocol_factory.h
+++ b/lib/c_glib/src/protocol/thrift_protocol_factory.h
@@ -1,3 +1,22 @@
+/*
+ * 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_PROTOCOL_FACTORY_H
 #define _THRIFT_PROTOCOL_FACTORY_H
 
@@ -6,26 +25,19 @@
 #include "transport/thrift_transport.h"
 #include "protocol/thrift_protocol.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_protocol_factory.h
  *  \brief Abstract class for Thrift protocol factory implementations.
  */
 
 /* type macros */
 #define THRIFT_TYPE_PROTOCOL_FACTORY (thrift_protocol_factory_get_type ())
-#define THRIFT_PROTOCOL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                          THRIFT_TYPE_PROTOCOL_FACTORY, \
-                                          ThriftProtocolFactory))
-#define THRIFT_IS_PROTOCOL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                             THRIFT_TYPE_PROTOCOL_FACTORY))
-#define THRIFT_PROTOCOL_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), \
-                                              THRIFT_TYPE_PROTOCOL_FACTORY, \
-                                              ThriftProtocolFactoryClass))
-#define THRIFT_IS_PROTOCOL_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), \
-                                                 THRIFT_TYPE_PROTOCOL_FACTORY))
-#define THRIFT_PROTOCOL_FACTORY_GET_CLASS(obj) \
-            (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-                                        THRIFT_TYPE_PROTOCOL_FACTORY, \
-                                        ThriftProtocolFactoryClass))
+#define THRIFT_PROTOCOL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_PROTOCOL_FACTORY, ThriftProtocolFactory))
+#define THRIFT_IS_PROTOCOL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_PROTOCOL_FACTORY))
+#define THRIFT_PROTOCOL_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_PROTOCOL_FACTORY, ThriftProtocolFactoryClass))
+#define THRIFT_IS_PROTOCOL_FACTORY_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_PROTOCOL_FACTORY))
+#define THRIFT_PROTOCOL_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_PROTOCOL_FACTORY, ThriftProtocolFactoryClass))
 
 /*!
  * Thrift Protocol Factory object
@@ -54,4 +66,6 @@
 /* virtual public methods */
 ThriftProtocol *thrift_protocol_factory_get_protocol(ThriftProtocolFactory *factory, ThriftTransport *transport);
 
+G_END_DECLS
+
 #endif /* _THRIFT_PROTOCOL_FACTORY_H */
diff --git a/lib/c_glib/src/server/thrift_server.c b/lib/c_glib/src/server/thrift_server.c
index c7e6c1f..6199576 100644
--- a/lib/c_glib/src/server/thrift_server.c
+++ b/lib/c_glib/src/server/thrift_server.c
@@ -1,3 +1,22 @@
+/*
+ * 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.h"
 #include "thrift_server.h"
 
@@ -13,108 +32,7 @@
   PROP_THRIFT_SERVER_OUTPUT_PROTOCOL_FACTORY
 };
 
-/* forward declarations */
-static void thrift_server_instance_init (ThriftServer *server);
-static void thrift_server_class_init (ThriftServerClass *cls);
-void thrift_server_get_property (GObject *object, guint property_id,
-                                 GValue *value, GParamSpec *pspec);
-void thrift_server_set_property (GObject *object, guint property_id,
-                                 const GValue *value, GParamSpec *pspec);
-
-
-/* define ThriftServerClass's type */
-GType
-thrift_server_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftServerClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_server_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftServer),
-      0, /* n_preallocs */
-      (GInstanceInitFunc) thrift_server_instance_init,
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (G_TYPE_OBJECT, "ThriftServer",
-                                   &info, G_TYPE_FLAG_ABSTRACT);
-  }
-
-  return type;
-}
-
-/* instance initializer for Thrift Server */
-static void
-thrift_server_instance_init (ThriftServer *server)
-{
-  server->processor = NULL;
-  server->server_transport = NULL;
-  server->input_transport_factory = NULL;
-  server->output_transport_factory = NULL;
-  server->input_protocol_factory = NULL;
-  server->output_protocol_factory = NULL;
-}
-
-/* class initializer for ThriftServer
- * TODO: implement ServerEventHandler as a GClosure
- */
-static void
-thrift_server_class_init (ThriftServerClass *cls)
-{
-  GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
-
-  gobject_class->get_property = thrift_server_get_property;
-  gobject_class->set_property = thrift_server_set_property;
-
-  g_object_class_install_property (gobject_class,
-      PROP_THRIFT_SERVER_PROCESSOR,
-      g_param_spec_object ("processor", "Processor", "Thrift Processor",
-                           THRIFT_TYPE_PROCESSOR,
-                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-  g_object_class_install_property (gobject_class,
-      PROP_THRIFT_SERVER_SERVER_TRANSPORT,
-      g_param_spec_object ("server_transport", "Server Transport",
-                           "Thrift Server Transport",
-                           THRIFT_TYPE_SERVER_TRANSPORT,
-                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-  g_object_class_install_property (gobject_class,
-      PROP_THRIFT_SERVER_INPUT_TRANSPORT_FACTORY,
-      g_param_spec_object ("input_transport_factory", "Input Transport Factory",
-                           "Thrift Server Input Transport Factory",
-                           THRIFT_TYPE_TRANSPORT_FACTORY,
-                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-  g_object_class_install_property (gobject_class,
-      PROP_THRIFT_SERVER_OUTPUT_TRANSPORT_FACTORY,
-      g_param_spec_object ("output_transport_factory",
-                           "Output Transport Factory",
-                           "Thrift Server Output Transport Factory",
-                           THRIFT_TYPE_TRANSPORT_FACTORY,
-                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-  g_object_class_install_property (gobject_class,
-      PROP_THRIFT_SERVER_INPUT_PROTOCOL_FACTORY,
-      g_param_spec_object ("input_protocol_factory", "Input Protocol Factory",
-                           "Thrift Server Input Protocol Factory",
-                           THRIFT_TYPE_PROTOCOL_FACTORY,
-                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-  g_object_class_install_property (gobject_class,
-      PROP_THRIFT_SERVER_OUTPUT_PROTOCOL_FACTORY,
-      g_param_spec_object ("output_protocol_factory", "Output Protocol Factory",
-                           "Thrift Server Output Protocol Factory",
-                           THRIFT_TYPE_PROTOCOL_FACTORY,
-                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
-  /* set these as virtual methods to be implemented by a subclass */
-  cls->serve = thrift_server_serve;
-  cls->stop = thrift_server_stop;
-}
+G_DEFINE_ABSTRACT_TYPE(ThriftServer, thrift_server, G_TYPE_OBJECT)
 
 void
 thrift_server_get_property (GObject *object, guint property_id,
@@ -190,3 +108,67 @@
   THRIFT_SERVER_GET_CLASS (server)->stop (server);
 }
 
+/* instance initializer for Thrift Server */
+static void
+thrift_server_init (ThriftServer *server)
+{
+  server->processor = NULL;
+  server->server_transport = NULL;
+  server->input_transport_factory = NULL;
+  server->output_transport_factory = NULL;
+  server->input_protocol_factory = NULL;
+  server->output_protocol_factory = NULL;
+}
+
+/* class initializer for ThriftServer
+ * TODO: implement ServerEventHandler as a GClosure
+ */
+static void
+thrift_server_class_init (ThriftServerClass *cls)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
+
+  gobject_class->get_property = thrift_server_get_property;
+  gobject_class->set_property = thrift_server_set_property;
+
+  g_object_class_install_property (gobject_class,
+      PROP_THRIFT_SERVER_PROCESSOR,
+      g_param_spec_object ("processor", "Processor", "Thrift Processor",
+                           THRIFT_TYPE_PROCESSOR,
+                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (gobject_class,
+      PROP_THRIFT_SERVER_SERVER_TRANSPORT,
+      g_param_spec_object ("server_transport", "Server Transport",
+                           "Thrift Server Transport",
+                           THRIFT_TYPE_SERVER_TRANSPORT,
+                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (gobject_class,
+      PROP_THRIFT_SERVER_INPUT_TRANSPORT_FACTORY,
+      g_param_spec_object ("input_transport_factory", "Input Transport Factory",
+                           "Thrift Server Input Transport Factory",
+                           THRIFT_TYPE_TRANSPORT_FACTORY,
+                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (gobject_class,
+      PROP_THRIFT_SERVER_OUTPUT_TRANSPORT_FACTORY,
+      g_param_spec_object ("output_transport_factory",
+                           "Output Transport Factory",
+                           "Thrift Server Output Transport Factory",
+                           THRIFT_TYPE_TRANSPORT_FACTORY,
+                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (gobject_class,
+      PROP_THRIFT_SERVER_INPUT_PROTOCOL_FACTORY,
+      g_param_spec_object ("input_protocol_factory", "Input Protocol Factory",
+                           "Thrift Server Input Protocol Factory",
+                           THRIFT_TYPE_PROTOCOL_FACTORY,
+                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (gobject_class,
+      PROP_THRIFT_SERVER_OUTPUT_PROTOCOL_FACTORY,
+      g_param_spec_object ("output_protocol_factory", "Output Protocol Factory",
+                           "Thrift Server Output Protocol Factory",
+                           THRIFT_TYPE_PROTOCOL_FACTORY,
+                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+  /* set these as virtual methods to be implemented by a subclass */
+  cls->serve = thrift_server_serve;
+  cls->stop = thrift_server_stop;
+}
diff --git a/lib/c_glib/src/server/thrift_server.h b/lib/c_glib/src/server/thrift_server.h
index 2bbe95b..b1113f8 100644
--- a/lib/c_glib/src/server/thrift_server.h
+++ b/lib/c_glib/src/server/thrift_server.h
@@ -1,3 +1,22 @@
+/*
+ * 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_H
 #define _THRIFT_SERVER_H
 
@@ -8,24 +27,19 @@
 #include "transport/thrift_transport_factory.h"
 #include "protocol/thrift_protocol_factory.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_server.h
  *  \brief Abstract class for Thrift servers.
  */
 
-/* type macros */	
+/* type macros */
 #define THRIFT_TYPE_SERVER (thrift_server_get_type ())
-#define THRIFT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                THRIFT_TYPE_SERVER, ThriftServer))
-#define THRIFT_IS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                   THRIFT_TYPE_SERVER))
-#define THRIFT_SERVER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), \
-                                    THRIFT_TYPE_SERVER, \
-                                    ThriftServerClass))
-#define THRIFT_IS_SERVER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), \
-                                       THRIFT_TYPE_SERVER))
-#define THRIFT_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-                                          THRIFT_TYPE_SERVER, \
-                                          ThriftServerClass))
+#define THRIFT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_SERVER, ThriftServer))
+#define THRIFT_IS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_SERVER))
+#define THRIFT_SERVER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_SERVER, ThriftServerClass))
+#define THRIFT_IS_SERVER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_SERVER))
+#define THRIFT_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_SERVER, ThriftServerClass))
 
 /*!
  * Thrift Server object
@@ -58,7 +72,7 @@
 typedef struct _ThriftServerClass ThriftServerClass;
 
 /* used by THRIFT_TYPE_SERVER */
-GType thrift_server_get_type (void); 
+GType thrift_server_get_type (void);
 
 /*!
  * Processes the request.
@@ -71,5 +85,7 @@
  */
 void thrift_server_stop (ThriftServer *server);
 
+G_END_DECLS
+
 #endif /* _THRIFT_SERVER_H */
 
diff --git a/lib/c_glib/src/server/thrift_simple_server.c b/lib/c_glib/src/server/thrift_simple_server.c
index 1957928..fe3067a 100644
--- a/lib/c_glib/src/server/thrift_simple_server.c
+++ b/lib/c_glib/src/server/thrift_simple_server.c
@@ -1,80 +1,28 @@
+/*
+ * 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 "server/thrift_simple_server.h"
 #include "transport/thrift_transport_factory.h"
 #include "protocol/thrift_protocol_factory.h"
 #include "protocol/thrift_binary_protocol_factory.h"
 
-static void thrift_simple_server_instance_init (ThriftServer *server);
-static void thrift_simple_server_class_init (ThriftServerClass *cls);
-
-/* forward declarations */
-void thrift_simple_server_serve (ThriftServer *server);
-void thrift_simple_server_stop (ThriftServer *server);
-
-GType
-thrift_simple_server_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftSimpleServerClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_simple_server_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftSimpleServer),
-      0, /* n_preallocs */
-      (GInstanceInitFunc) thrift_simple_server_instance_init,
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_SERVER,
-                                   "ThriftSimpleServerType",
-                                   &info, 0);
-  }
-
-  return type;
-}
-
-static void
-thrift_simple_server_instance_init (ThriftServer *server)
-{
-  (THRIFT_SIMPLE_SERVER (server))->running = FALSE;
-
-  if (server->input_transport_factory == NULL)
-  {
-    server->input_transport_factory = 
-        g_object_new (THRIFT_TYPE_TRANSPORT_FACTORY, NULL);
-  }
-  if (server->output_transport_factory == NULL)
-  {
-    server->output_transport_factory =
-        g_object_new (THRIFT_TYPE_TRANSPORT_FACTORY, NULL);
-  }
-  if (server->input_protocol_factory == NULL)
-  {
-    server->input_protocol_factory =
-        g_object_new (THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, NULL);
-  }
-  if (server->output_protocol_factory == NULL)
-  {
-    server->output_protocol_factory =
-        g_object_new (THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, NULL);
-  }
-}
-
-
-/* initialize the class */
-static void
-thrift_simple_server_class_init (ThriftServerClass *cls)
-{
-  cls->serve = thrift_simple_server_serve;
-  cls->stop = thrift_simple_server_stop;
-}
+G_DEFINE_TYPE(ThriftSimpleServer, thrift_simple_server, THRIFT_TYPE_SERVER)
 
 void
 thrift_simple_server_serve (ThriftServer *server)
@@ -84,7 +32,7 @@
   ThriftTransport *t = NULL;
   ThriftTransport *input_transport = NULL, *output_transport = NULL;
   ThriftProtocol *input_protocol = NULL, *output_protocol = NULL;
-  ThriftSimpleServer *tss = THRIFT_SIMPLE_SERVER (server);
+  ThriftSimpleServer *tss = THRIFT_SIMPLE_SERVER(server);
 
   THRIFT_SERVER_TRANSPORT_GET_CLASS (server->server_transport)
       ->listen (server->server_transport, NULL);
@@ -130,4 +78,41 @@
   (THRIFT_SIMPLE_SERVER (server))->running = FALSE;
 }
 
+static void
+thrift_simple_server_init (ThriftSimpleServer *tss)
+{
+  tss->running = FALSE;
 
+  ThriftServer *server = THRIFT_SERVER(tss);
+
+  if (server->input_transport_factory == NULL)
+  {
+    server->input_transport_factory =
+        g_object_new (THRIFT_TYPE_TRANSPORT_FACTORY, NULL);
+  }
+  if (server->output_transport_factory == NULL)
+  {
+    server->output_transport_factory =
+        g_object_new (THRIFT_TYPE_TRANSPORT_FACTORY, NULL);
+  }
+  if (server->input_protocol_factory == NULL)
+  {
+    server->input_protocol_factory =
+        g_object_new (THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, NULL);
+  }
+  if (server->output_protocol_factory == NULL)
+  {
+    server->output_protocol_factory =
+        g_object_new (THRIFT_TYPE_BINARY_PROTOCOL_FACTORY, NULL);
+  }
+}
+
+/* initialize the class */
+static void
+thrift_simple_server_class_init (ThriftSimpleServerClass *class)
+{
+  ThriftServerClass *cls = THRIFT_SERVER_CLASS(class);
+
+  cls->serve = thrift_simple_server_serve;
+  cls->stop = thrift_simple_server_stop;
+}
diff --git a/lib/c_glib/src/server/thrift_simple_server.h b/lib/c_glib/src/server/thrift_simple_server.h
index 137f623..235500c 100644
--- a/lib/c_glib/src/server/thrift_simple_server.h
+++ b/lib/c_glib/src/server/thrift_simple_server.h
@@ -1,3 +1,22 @@
+/*
+ * 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_SIMPLE_SERVER_H
 #define _THRIFT_SIMPLE_SERVER_H
 
@@ -5,25 +24,19 @@
 
 #include "server/thrift_server.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_simple_server.h
  *  \brief A simple Thrift server, single-threaded.
  */
 
 /* type macros */
 #define THRIFT_TYPE_SIMPLE_SERVER (thrift_simple_server_get_type ())
-#define THRIFT_SIMPLE_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                       THRIFT_TYPE_SIMPLE_SERVER, \
-                                       ThriftSimpleServer))
-#define THRIFT_IS_SIMPLE_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                          THRIFT_TYPE_SIMPLE_SERVER))
-#define THRIFT_SIMPLE_SERVER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c) \
-                                           THRIFT_TYPE_SIMPLE_SERVER, \
-                                           ThriftSimpleServerClass))
-#define THRIFT_IS_SIMPLE_SERVER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), \
-                                              THRIFT_TYPE_SIMPLE_SERVER))
-#define THRIFT_SIMPLE_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-                                                 THRIFT_TYPE_SIMPLE_SERVER, \
-                                                 ThriftSimpleServerClass))
+#define THRIFT_SIMPLE_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_SIMPLE_SERVER, ThriftSimpleServer))
+#define THRIFT_IS_SIMPLE_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_SIMPLE_SERVER))
+#define THRIFT_SIMPLE_SERVER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c) THRIFT_TYPE_SIMPLE_SERVER, ThriftSimpleServerClass))
+#define THRIFT_IS_SIMPLE_SERVER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_SIMPLE_SERVER))
+#define THRIFT_SIMPLE_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_SIMPLE_SERVER, ThriftSimpleServerClass))
 
 /**
  * Thrift Simple Server instance.
@@ -49,5 +62,7 @@
 /* used by THRIFT_TYPE_SIMPLE_SERVER */
 GType thrift_simple_server_get_type (void);
 
+G_END_DECLS
+
 #endif /* _THRIFT_SIMPLE_SERVER_H */
 
diff --git a/lib/c_glib/src/thrift.c b/lib/c_glib/src/thrift.c
index 18a36aa..886e5c3 100644
--- a/lib/c_glib/src/thrift.c
+++ b/lib/c_glib/src/thrift.c
@@ -1,3 +1,22 @@
+/*
+ * 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.h"
 
 /**
diff --git a/lib/c_glib/src/thrift.h b/lib/c_glib/src/thrift.h
index 59db6fd..0636a2f 100644
--- a/lib/c_glib/src/thrift.h
+++ b/lib/c_glib/src/thrift.h
@@ -1,3 +1,22 @@
+/*
+ * 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_H
 #define _THRIFT_H
 
diff --git a/lib/c_glib/src/thrift_application_exception.c b/lib/c_glib/src/thrift_application_exception.c
index fa57a81..f1bee3c 100644
--- a/lib/c_glib/src/thrift_application_exception.c
+++ b/lib/c_glib/src/thrift_application_exception.c
@@ -1,55 +1,26 @@
+/*
+ * 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_application_exception.h"
 #include "protocol/thrift_protocol.h"
 
-/* forward declarations */
-void thrift_application_exception_instance_init (ThriftApplicationException *object);
-void thrift_application_exception_class_init (ThriftStructClass *cls);
-gint32 thrift_application_exception_read (ThriftStruct *object, ThriftProtocol *protocol, GError **error);
-gint32 thrift_application_exception_write (ThriftStruct *object, ThriftProtocol *protocol, GError **error);
-
-GType
-thrift_application_exception_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo type_info =
-    {
-      sizeof (ThriftApplicationExceptionClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_application_exception_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftApplicationException),
-      0, /* n_preallocs */
-      (GInstanceInitFunc) thrift_application_exception_instance_init,
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_STRUCT,
-                                   "ThriftApplicationExceptionType",
-                                   &type_info, 0);
-  }
-  return type;
-}
-
-void
-thrift_application_exception_instance_init (ThriftApplicationException *object)
-{
-  object->type = 0;
-  object->__isset_type = FALSE;
-  object->message = NULL;
-  object->__isset_message = FALSE;
-}
-
-void
-thrift_application_exception_class_init (ThriftStructClass *cls)
-{
-  cls->read = thrift_application_exception_read;
-  cls->write = thrift_application_exception_write;
-}
+G_DEFINE_TYPE(ThriftApplicationException, thrift_application_exception, THRIFT_TYPE_STRUCT)
 
 gint32
 thrift_application_exception_read (ThriftStruct *object,
@@ -190,3 +161,19 @@
   return g_quark_from_static_string (THRIFT_APPLICATION_EXCEPTION_ERROR_DOMAIN);
 }
 
+void
+thrift_application_exception_init (ThriftApplicationException *object)
+{
+  object->type = 0;
+  object->__isset_type = FALSE;
+  object->message = NULL;
+  object->__isset_message = FALSE;
+}
+
+void
+thrift_application_exception_class_init (ThriftApplicationExceptionClass *class)
+{
+  ThriftStructClass *cls = THRIFT_STRUCT_CLASS(class);
+  cls->read = thrift_application_exception_read;
+  cls->write = thrift_application_exception_write;
+}
diff --git a/lib/c_glib/src/thrift_application_exception.h b/lib/c_glib/src/thrift_application_exception.h
index 8639df2..369c29b 100644
--- a/lib/c_glib/src/thrift_application_exception.h
+++ b/lib/c_glib/src/thrift_application_exception.h
@@ -1,33 +1,41 @@
+/*
+ * 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_APPLICATION_EXCEPTION_H
 #define _THRIFT_APPLICATION_EXCEPTION_H
 
 #include <glib-object.h>
 #include "thrift_struct.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_application_exception.h
  *  \brief C Implementation of a TApplicationException.
  */
 
 /* type macros */
-#define THRIFT_TYPE_APPLICATION_EXCEPTION \
-            (thrift_application_exception_get_type ())
-#define THRIFT_APPLICATION_EXCEPTION(obj) \
-            (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                         THRIFT_TYPE_APPLICATION_EXCEPTION, \
-                                         ThriftApplicationException))
-#define THRIFT_IS_APPLICATION_EXCEPTION(obj) \
-            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                         THRIFT_TYPE_APPLICATION_EXCEPTION))
-#define THRIFT_APPLICATION_EXCEPTION_CLASS(c) \
-            (G_TYPE_CHECK_CLASS_CAST ((c), \
-                                      THRIFT_TYPE_APPLICATION_EXCEPTION, \
-                                      ThriftApplicationExceptionClass))
-#define THRIFT_IS_APPLICATION_EXCEPTION_CLASS(c) \
-            (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_APPLICATION_EXCEPTION))
-#define THRIFT_APPLICATION_EXCEPTION_GET_CLASS(obj) \
-            (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-                                        THRIFT_TYPE_APPLICATION_EXCEPTION, \
-                                        ThriftApplicationExceptionClass))
+#define THRIFT_TYPE_APPLICATION_EXCEPTION (thrift_application_exception_get_type ())
+#define THRIFT_APPLICATION_EXCEPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_APPLICATION_EXCEPTION, ThriftApplicationException))
+#define THRIFT_IS_APPLICATION_EXCEPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_APPLICATION_EXCEPTION))
+#define THRIFT_APPLICATION_EXCEPTION_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_APPLICATION_EXCEPTION, ThriftApplicationExceptionClass))
+#define THRIFT_IS_APPLICATION_EXCEPTION_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_APPLICATION_EXCEPTION))
+#define THRIFT_APPLICATION_EXCEPTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_APPLICATION_EXCEPTION, ThriftApplicationExceptionClass))
 
 struct _ThriftApplicationException
 {
@@ -64,4 +72,6 @@
 GQuark thrift_application_exception_error_quark (void);
 #define THRIFT_APPLICATION_EXCEPTION_ERROR (thrift_application_exception_error_quark ())
 
+G_END_DECLS
+
 #endif /* _THRIFT_APPLICATION_EXCEPTION_H */
diff --git a/lib/c_glib/src/thrift_struct.c b/lib/c_glib/src/thrift_struct.c
index 3f73c38..8a0928a 100644
--- a/lib/c_glib/src/thrift_struct.c
+++ b/lib/c_glib/src/thrift_struct.c
@@ -1,41 +1,26 @@
+/*
+ * 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.h"
 #include "thrift_struct.h"
 
-static void
-thrift_struct_class_init (ThriftStructClass *cls)
-{
-  ThriftStructClass *c = THRIFT_STRUCT_CLASS (cls);
-  c->read = thrift_struct_read;
-  c->write = thrift_struct_write;
-}
-
-GType
-thrift_struct_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo type_info =
-      {
-        sizeof (ThriftStructClass),
-        NULL, /* base_init */
-        NULL, /* base finalize */
-        (GClassInitFunc) thrift_struct_class_init,
-        NULL, /* class finalize */
-        NULL, /* class data */
-        sizeof (ThriftStruct),
-        0, /* n_preallocs */
-        NULL, /* instance_init */
-        NULL, /* value_table */
-      };
-
-    type = g_type_register_static (G_TYPE_OBJECT,
-                                   "ThriftStructType",
-                                   &type_info, G_TYPE_FLAG_ABSTRACT);
-  }
-
-  return type;
-}
+G_DEFINE_ABSTRACT_TYPE(ThriftStruct, thrift_struct, G_TYPE_OBJECT)
 
 gint32
 thrift_struct_read (ThriftStruct *object, ThriftProtocol *protocol,
@@ -53,3 +38,15 @@
   return THRIFT_STRUCT_GET_CLASS (object)->write (object, protocol, error);
 }
 
+static void
+thrift_struct_class_init (ThriftStructClass *cls)
+{
+  cls->read = thrift_struct_read;
+  cls->write = thrift_struct_write;
+}
+
+static void
+thrift_struct_init (ThriftStruct *structure)
+{
+  THRIFT_UNUSED_VAR (structure);
+}
diff --git a/lib/c_glib/src/thrift_struct.h b/lib/c_glib/src/thrift_struct.h
index f3e6060..edf9984 100644
--- a/lib/c_glib/src/thrift_struct.h
+++ b/lib/c_glib/src/thrift_struct.h
@@ -1,3 +1,22 @@
+/*
+ * 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_STRUCT_H
 #define THRIFT_STRUCT_H
 
@@ -5,18 +24,14 @@
 
 #include "protocol/thrift_protocol.h"
 
+G_BEGIN_DECLS
+
 #define THRIFT_TYPE_STRUCT (thrift_struct_get_type ())
-#define THRIFT_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                THRIFT_TYPE_STRUCT, ThriftStruct))
-#define THRIFT_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), \
-                                    THRIFT_TYPE_STRUCT, ThriftStructClass))
-#define THRIFT_IS_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                    THRIFT_TYPE_STRUCT))
-#define THRIFT_IS_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), \
-                                       THRIFT_TYPE_STRUCT))
-#define THRIFT_STRUCT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-                                          THRIFT_TYPE_STRUCT, \
-                                          ThriftStructClass))
+#define THRIFT_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_STRUCT, ThriftStruct))
+#define THRIFT_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_STRUCT, ThriftStructClass))
+#define THRIFT_IS_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_STRUCT))
+#define THRIFT_IS_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_STRUCT))
+#define THRIFT_STRUCT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_STRUCT, ThriftStructClass))
 
 /* struct */
 struct _ThriftStruct
@@ -46,5 +61,6 @@
 
 gint32 thrift_struct_write (ThriftStruct *object, ThriftProtocol *protocol,
                             GError **error);
+G_END_DECLS
 
 #endif
diff --git a/lib/c_glib/src/transport/thrift_buffered_transport.c b/lib/c_glib/src/transport/thrift_buffered_transport.c
index 45ea31c..53c14b1 100644
--- a/lib/c_glib/src/transport/thrift_buffered_transport.c
+++ b/lib/c_glib/src/transport/thrift_buffered_transport.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
@@ -18,65 +37,210 @@
   PROP_THRIFT_BUFFERED_TRANSPORT_WRITE_BUFFER_SIZE
 };
 
-/* forward declarations */
-static void thrift_buffered_transport_instance_init (ThriftBufferedTransport *self);
-static void thrift_buffered_transport_class_init (ThriftBufferedTransportClass *cls);
+G_DEFINE_TYPE(ThriftBufferedTransport, thrift_buffered_transport, THRIFT_TYPE_TRANSPORT)
 
-
-gboolean thrift_buffered_transport_is_open (ThriftTransport *transport);
-gboolean thrift_buffered_transport_open (ThriftTransport *transport,
-                                         GError **error);
-gboolean thrift_buffered_transport_close (ThriftTransport *transport,
-                                          GError **error);
-gint32 thrift_buffered_transport_read (ThriftTransport *transport, gpointer buf,
-                                       guint32 len, GError **error);
-gboolean thrift_buffered_transport_read_end (ThriftTransport *transport,
-                                             GError **error);
-gint32 thrift_buffered_transport_read_slow (ThriftTransport *transport,
-                                            gpointer buf, guint32 len,
-                                            GError **error);
-gboolean thrift_buffered_transport_write (ThriftTransport *transport,
-                                          const gpointer buf,
-                                          const guint32 len, GError **error);
-gboolean thrift_buffered_transport_write_end (ThriftTransport *transport,
-                                              GError **error);
-gint32 thrift_buffered_transport_write_slow (ThriftTransport *transport, 
-                                             gpointer buf, guint32 len, 
-                                             GError **error);
-gboolean thrift_buffered_transport_flush (ThriftTransport *transport,
-                                          GError **error);
-
-GType
-thrift_buffered_transport_get_type (void)
+/* implements thrift_transport_is_open */
+gboolean
+thrift_buffered_transport_is_open (ThriftTransport *transport)
 {
-  static GType type = 0;
+  ThriftBufferedTransport *t = THRIFT_BUFFERED_TRANSPORT (transport);
+  return THRIFT_TRANSPORT_GET_CLASS (t->transport)->is_open (t->transport);
+}
 
-  if (type == 0)
+/* 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[t->r_buf_size];
+  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)
   {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftBufferedTransportClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_buffered_transport_class_init,
-      NULL, /* class finalize */
-      NULL, /* class data */
-      sizeof (ThriftBufferedTransport),
-      0, /* n_preallocs */
-      (GInstanceInitFunc) thrift_buffered_transport_instance_init,
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_TRANSPORT,
-                                   "ThriftBufferedTransport", &info, 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);
   }
 
-  return type;
+  // 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,
+                                                            t->r_buf_size,
+                                                            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_instance_init (ThriftBufferedTransport *transport)
+thrift_buffered_transport_init (ThriftBufferedTransport *transport)
 {
   transport->transport = NULL;
   transport->r_buf = g_byte_array_new ();
@@ -202,205 +366,3 @@
   ttc->write_end = thrift_buffered_transport_write_end;
   ttc->flush = thrift_buffered_transport_flush;
 }
-
-/* 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);
-}
-
-/* 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;
-}
-
-/* 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[t->r_buf_size];
-  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,
-                                                            t->r_buf_size,
-                                                            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_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;
-}
-
-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_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;
-}
-
-
diff --git a/lib/c_glib/src/transport/thrift_buffered_transport.h b/lib/c_glib/src/transport/thrift_buffered_transport.h
index 6b0b17e..aaa5183 100644
--- a/lib/c_glib/src/transport/thrift_buffered_transport.h
+++ b/lib/c_glib/src/transport/thrift_buffered_transport.h
@@ -1,3 +1,22 @@
+/*
+ * 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
 
@@ -6,27 +25,20 @@
 
 #include "transport/thrift_transport.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_buffered_transport.h
- *  \brief Implementation of a Thrift buffered transport.  Subclasses 
+ *  \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))
+#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.
@@ -58,4 +70,6 @@
 /* used by THRIFT_TYPE_BUFFERED_TRANSPORT */
 GType thrift_buffered_transport_get_type (void);
 
+G_END_DECLS
+
 #endif
diff --git a/lib/c_glib/src/transport/thrift_framed_transport.c b/lib/c_glib/src/transport/thrift_framed_transport.c
index de9cb00..c8dd446 100644
--- a/lib/c_glib/src/transport/thrift_framed_transport.c
+++ b/lib/c_glib/src/transport/thrift_framed_transport.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
@@ -18,67 +37,200 @@
   PROP_THRIFT_FRAMED_TRANSPORT_WRITE_BUFFER_SIZE
 };
 
-/* forward declarations */
-static void thrift_framed_transport_instance_init (ThriftFramedTransport *self);
-static void thrift_framed_transport_class_init (ThriftFramedTransportClass *cls);
+G_DEFINE_TYPE(ThriftFramedTransport, thrift_framed_transport, THRIFT_TYPE_TRANSPORT)
 
-
-gboolean thrift_framed_transport_is_open (ThriftTransport *transport);
-gboolean thrift_framed_transport_open (ThriftTransport *transport,
-                                       GError **error);
-gboolean thrift_framed_transport_close (ThriftTransport *transport,
-                                        GError **error);
-gint32 thrift_framed_transport_read (ThriftTransport *transport, gpointer buf,
-                                     guint32 len, GError **error);
-gboolean thrift_framed_transport_read_end (ThriftTransport *transport,
-                                           GError **error);
-gint32 thrift_framed_transport_read_slow (ThriftTransport *transport,
-                                          gpointer buf, guint32 len,
-                                          GError **error);
-gboolean thrift_framed_transport_read_frame (ThriftTransport *transport,
-                                             GError **error);
-gboolean thrift_framed_transport_write (ThriftTransport *transport,
-                                        const gpointer buf,
-                                        const guint32 len, GError **error);
-gboolean thrift_framed_transport_write_end (ThriftTransport *transport,
-                                            GError **error);
-gint32 thrift_framed_transport_write_slow (ThriftTransport *transport, 
-                                           gpointer buf, guint32 len, 
-                                           GError **error);
-gboolean thrift_framed_transport_flush (ThriftTransport *transport,
-                                        GError **error);
-
-GType
-thrift_framed_transport_get_type (void)
+/* implements thrift_transport_is_open */
+gboolean
+thrift_framed_transport_is_open (ThriftTransport *transport)
 {
-  static GType type = 0;
+  ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
+  return THRIFT_TRANSPORT_GET_CLASS (t->transport)->is_open (t->transport);
+}
 
-  if (type == 0)
+/* 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 - sizeof (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)
   {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftFramedTransportClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_framed_transport_class_init,
-      NULL, /* class finalize */
-      NULL, /* class data */
-      sizeof (ThriftFramedTransport),
-      0, /* n_preallocs */
-      (GInstanceInitFunc) thrift_framed_transport_instance_init,
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_TRANSPORT,
-                                   "ThriftFramedTransport", &info, 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);
   }
 
-  return type;
+  // 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) sz_hbo);
+
+  // 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_instance_init (ThriftFramedTransport *transport)
+thrift_framed_transport_init (ThriftFramedTransport *transport)
 {
   transport->transport = NULL;
   transport->r_buf = g_byte_array_new ();
@@ -204,194 +356,3 @@
   ttc->write_end = thrift_framed_transport_write_end;
   ttc->flush = thrift_framed_transport_flush;
 }
-
-/* 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);
-}
-
-/* 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;
-}
-
-/* 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);
-}
-
-/* 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 - sizeof (sz),
-                                                           error);
-
-  /* add the data to the buffer */
-  g_byte_array_append (t->r_buf, tmpdata, bytes);
-
-  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;
-}
-
-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_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) sz_hbo);
-
-  // 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;
-}
-
-
diff --git a/lib/c_glib/src/transport/thrift_framed_transport.h b/lib/c_glib/src/transport/thrift_framed_transport.h
index d859b97..5e14e35 100644
--- a/lib/c_glib/src/transport/thrift_framed_transport.h
+++ b/lib/c_glib/src/transport/thrift_framed_transport.h
@@ -1,3 +1,22 @@
+/*
+ * 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
 
@@ -6,27 +25,20 @@
 
 #include "transport/thrift_transport.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_framed_transport.h
- *  \brief Implementation of a Thrift framed transport.  Subclasses 
+ *  \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))
+#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.
@@ -58,4 +70,6 @@
 /* used by THRIFT_TYPE_FRAMED_TRANSPORT */
 GType thrift_framed_transport_get_type (void);
 
+G_END_DECLS
+
 #endif
diff --git a/lib/c_glib/src/transport/thrift_memory_buffer.c b/lib/c_glib/src/transport/thrift_memory_buffer.c
index 34a4dfa..cc6717d 100644
--- a/lib/c_glib/src/transport/thrift_memory_buffer.c
+++ b/lib/c_glib/src/transport/thrift_memory_buffer.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
@@ -16,143 +35,7 @@
   PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE,
 };
 
-/* forward declarations */
-static void thrift_memory_buffer_instance_init (ThriftMemoryBuffer *self);
-static void thrift_memory_buffer_class_init (ThriftMemoryBufferClass *cls);
-
-
-gboolean thrift_memory_buffer_is_open (ThriftTransport *transport);
-gboolean thrift_memory_buffer_open (ThriftTransport *transport,
-                                    GError **error);
-gboolean thrift_memory_buffer_close (ThriftTransport *transport,
-                                     GError **error);
-gint32 thrift_memory_buffer_read (ThriftTransport *transport, gpointer buf,
-                                  guint32 len, GError **error);
-gboolean thrift_memory_buffer_read_end (ThriftTransport *transport,
-                                        GError **error);
-gboolean thrift_memory_buffer_write (ThriftTransport *transport,
-                                     const gpointer buf,
-                                     const guint32 len, GError **error);
-gboolean thrift_memory_buffer_write_end (ThriftTransport *transport,
-                                         GError **error);
-gboolean thrift_memory_buffer_flush (ThriftTransport *transport,
-                                     GError **error);
-
-GType
-thrift_memory_buffer_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftMemoryBufferClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_memory_buffer_class_init,
-      NULL, /* class finalize */
-      NULL, /* class data */
-      sizeof (ThriftMemoryBuffer),
-      0, /* n_preallocs */
-      (GInstanceInitFunc) thrift_memory_buffer_instance_init,
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_TRANSPORT,
-                                   "ThriftMemoryBuffer", &info, 0);
-  }
-
-  return type;
-}
-
-/* initializes the instance */
-static void
-thrift_memory_buffer_instance_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;
-}
+G_DEFINE_TYPE(ThriftMemoryBuffer, thrift_memory_buffer, THRIFT_TYPE_TRANSPORT)
 
 /* implements thrift_transport_is_open */
 gboolean
@@ -257,4 +140,90 @@
   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;
+}
diff --git a/lib/c_glib/src/transport/thrift_memory_buffer.h b/lib/c_glib/src/transport/thrift_memory_buffer.h
index 7529d1f..a207929 100644
--- a/lib/c_glib/src/transport/thrift_memory_buffer.h
+++ b/lib/c_glib/src/transport/thrift_memory_buffer.h
@@ -1,3 +1,22 @@
+/*
+ * 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
 
@@ -6,26 +25,19 @@
 
 #include "transport/thrift_transport.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_memory_buffer.h
- *  \brief Implementation of a Thrift memory buffer transport. 
+ *  \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))
+#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.
@@ -52,4 +64,6 @@
 /* used by THRIFT_TYPE_MEMORY_BUFFER */
 GType thrift_memory_buffer_get_type (void);
 
+G_END_DECLS
+
 #endif
diff --git a/lib/c_glib/src/transport/thrift_server_socket.c b/lib/c_glib/src/transport/thrift_server_socket.c
index fe11648..2ebc01c 100644
--- a/lib/c_glib/src/transport/thrift_server_socket.c
+++ b/lib/c_glib/src/transport/thrift_server_socket.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
@@ -24,43 +43,101 @@
 /* for errors coming from socket() and connect() */
 extern int errno;
 
-/* forward declarations */
-static void thrift_server_socket_instance_init (ThriftServerSocket *self);
-static void thrift_server_socket_class_init (ThriftServerSocketClass *cls);
+G_DEFINE_TYPE(ThriftServerSocket, thrift_server_socket, THRIFT_TYPE_SERVER_TRANSPORT)
 
-gboolean thrift_server_socket_listen (ThriftServerTransport *transport,
-                                      GError **error);
-ThriftTransport *thrift_server_socket_accept (ThriftServerTransport *transport,
-                                              GError **error);
-gboolean thrift_server_socket_close (ThriftServerTransport *transport,
-                                     GError **error);
-
-GType
-thrift_server_socket_get_type (void)
+gboolean
+thrift_server_socket_listen (ThriftServerTransport *transport, GError **error)
 {
-  static GType type = 0;
+  int enabled = 1; /* for setsockopt() */
+  struct sockaddr_in pin;
+  ThriftServerSocket *tsocket = THRIFT_SERVER_SOCKET (transport);
 
-  if (type == 0)
+  /* 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)
   {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftServerSocketClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_server_socket_class_init,
-      NULL, /* class finalize */
-      NULL, /* class data */
-      sizeof (ThriftServerSocket),
-      0, /* n_preallocs */
-      (GInstanceInitFunc) thrift_server_socket_instance_init,
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_SERVER_TRANSPORT,
-                                   "ThriftServerSocket", &info, 0);
+    g_set_error (error, THRIFT_SERVER_SOCKET_ERROR,
+                 THRIFT_SERVER_SOCKET_ERROR_SOCKET,
+                 "failed to create socket - %s", strerror (errno));
+    return FALSE;
   }
 
-  return type;
+  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 */
@@ -72,7 +149,7 @@
 
 /* initializes the instance */
 static void
-thrift_server_socket_instance_init (ThriftServerSocket *socket)
+thrift_server_socket_init (ThriftServerSocket *socket)
 {
   socket->sd = 0;
 }
@@ -175,98 +252,3 @@
   tstc->close = thrift_server_socket_close;
 }
 
-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;
-}
-
diff --git a/lib/c_glib/src/transport/thrift_server_socket.h b/lib/c_glib/src/transport/thrift_server_socket.h
index c56bd84..54a6017 100644
--- a/lib/c_glib/src/transport/thrift_server_socket.h
+++ b/lib/c_glib/src/transport/thrift_server_socket.h
@@ -1,3 +1,22 @@
+/*
+ * 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
 
@@ -5,6 +24,8 @@
 
 #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.
@@ -12,19 +33,11 @@
 
 /* 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))
+#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.
@@ -70,4 +83,6 @@
 GQuark thrift_server_socket_error_quark (void);
 #define THRIFT_SERVER_SOCKET_ERROR (thrift_server_socket_error_quark ())
 
+G_END_DECLS
+
 #endif
diff --git a/lib/c_glib/src/transport/thrift_server_transport.c b/lib/c_glib/src/transport/thrift_server_transport.c
index 89cbaf3..87ce8e0 100644
--- a/lib/c_glib/src/transport/thrift_server_transport.c
+++ b/lib/c_glib/src/transport/thrift_server_transport.c
@@ -1,39 +1,27 @@
+/*
+ * 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.h"
 #include "transport/thrift_transport.h"
 #include "transport/thrift_server_transport.h"
 
-/* forward declarations */
-static void thrift_server_transport_class_init (ThriftServerTransportClass *c);
-
-/* define ThriftTransportClass type */
-GType
-thrift_server_transport_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftServerTransportClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_server_transport_class_init, 
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftServerTransport),
-      0, /* n_preallocs */
-      NULL, /* instance_init */
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (G_TYPE_OBJECT,
-                                   "ThriftServerTransport",
-                                   &info, G_TYPE_FLAG_ABSTRACT);
-  }
-
-  return type;
-}
+G_DEFINE_ABSTRACT_TYPE(ThriftServerTransport, thrift_server_transport, G_TYPE_OBJECT)
 
 /* base initializer for the server transport interface */
 static void
@@ -44,6 +32,12 @@
   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)
@@ -66,5 +60,3 @@
   return THRIFT_SERVER_TRANSPORT_GET_CLASS (transport)->close (transport,
                                                                error);
 }
-
-
diff --git a/lib/c_glib/src/transport/thrift_server_transport.h b/lib/c_glib/src/transport/thrift_server_transport.h
index a74fca0..dd94325 100644
--- a/lib/c_glib/src/transport/thrift_server_transport.h
+++ b/lib/c_glib/src/transport/thrift_server_transport.h
@@ -1,3 +1,22 @@
+/*
+ * 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
 
@@ -5,25 +24,19 @@
 
 #include "thrift_transport.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_server_transport.h
  *  \brief Abstract class for Thrift server transports.
  */
 
-/* type macros */	
+/* 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))
+#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
 {
@@ -46,7 +59,7 @@
 typedef struct _ThriftServerTransportClass ThriftServerTransportClass;
 
 /* used by THRIFT_TYPE_SERVER_TRANSPORT */
-GType thrift_server_transport_get_type (void); 
+GType thrift_server_transport_get_type (void);
 
 /*!
  * Listen for new connections.
@@ -59,7 +72,7 @@
  * Accept a connection.
  * \public \memberof ThriftServerTransportClass
  */
-ThriftTransport *thrift_server_transport_accept 
+ThriftTransport *thrift_server_transport_accept
     (ThriftServerTransport *transport, GError **error);
 
 /*!
@@ -69,4 +82,6 @@
 gboolean thrift_server_transport_close (ThriftServerTransport *transport,
                                         GError **error);
 
+G_END_DECLS
+
 #endif /* _THRIFT_SERVER_TRANSPORT_H */
diff --git a/lib/c_glib/src/transport/thrift_socket.c b/lib/c_glib/src/transport/thrift_socket.c
index 951ae90..d231bc6 100644
--- a/lib/c_glib/src/transport/thrift_socket.c
+++ b/lib/c_glib/src/transport/thrift_socket.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
@@ -19,156 +38,7 @@
 /* for errors coming from socket() and connect() */
 extern int errno;
 
-/* forward declarations */
-static void thrift_socket_instance_init (ThriftSocket *self);
-static void thrift_socket_class_init (ThriftSocketClass *cls);
-
-gboolean thrift_socket_is_open (ThriftTransport *transport);
-gboolean thrift_socket_open (ThriftTransport *transport, GError **error);
-gboolean thrift_socket_close (ThriftTransport *transport, GError **error);
-gint32 thrift_socket_read (ThriftTransport *transport, gpointer buf,
-                           guint32 len, GError **error);
-gboolean thrift_socket_read_end (ThriftTransport *transport, GError **error);
-gboolean thrift_socket_write (ThriftTransport *transport, const gpointer buf,
-                              const guint32 len, GError **error);
-gboolean thrift_socket_write_end (ThriftTransport *transport, GError **error);
-gboolean thrift_socket_flush (ThriftTransport *transport, GError **error);
-
-GType
-thrift_socket_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftSocketClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_socket_class_init,
-      NULL, /* class finalize */
-      NULL, /* class data */
-      sizeof (ThriftSocket),
-      0, /* n_preallocs */
-      (GInstanceInitFunc) thrift_socket_instance_init,
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_TRANSPORT,
-                                   "ThriftSocket", &info, 0);
-  }
-
-  return type;
-}
-
-/* initializes the instance */
-static void
-thrift_socket_instance_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;
-}
+G_DEFINE_TYPE(ThriftSocket, thrift_socket, THRIFT_TYPE_TRANSPORT)
 
 /* implements thrift_transport_is_open */
 gboolean
@@ -331,4 +201,110 @@
   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;
+}
diff --git a/lib/c_glib/src/transport/thrift_socket.h b/lib/c_glib/src/transport/thrift_socket.h
index 5fc2402..b3dd357 100644
--- a/lib/c_glib/src/transport/thrift_socket.h
+++ b/lib/c_glib/src/transport/thrift_socket.h
@@ -1,3 +1,22 @@
+/*
+ * 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
 
@@ -5,6 +24,8 @@
 
 #include "transport/thrift_transport.h"
 
+G_BEGIN_DECLS
+
 /*! \file thrift_socket.h
  *  \brief Socket implementation of a Thrift transport.  Subclasses the
  *         ThriftTransport class.
@@ -12,17 +33,11 @@
 
 /* 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))
+#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.
@@ -53,4 +68,6 @@
 /* used by THRIFT_TYPE_SOCKET */
 GType thrift_socket_get_type (void);
 
+G_END_DECLS
+
 #endif
diff --git a/lib/c_glib/src/transport/thrift_transport.c b/lib/c_glib/src/transport/thrift_transport.c
index 9c57a75..a37787d 100644
--- a/lib/c_glib/src/transport/thrift_transport.c
+++ b/lib/c_glib/src/transport/thrift_transport.c
@@ -1,55 +1,29 @@
+/*
+ * 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.h"
 #include "transport/thrift_transport.h"
 
 /* define the GError domain string */
 #define THRIFT_TRANSPORT_ERROR_DOMAIN "thrift-transport-error-quark"
 
-/* forward declarations */
-static void thrift_transport_class_init (ThriftTransportClass *cls);
-
-/* define ThriftTransportInterface's type */
-GType
-thrift_transport_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (ThriftTransportClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_transport_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftTransport),
-      0, /* n_preallocs */
-      NULL, /* instance_init */
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (G_TYPE_OBJECT, "ThriftTransport",
-                                   &info, G_TYPE_FLAG_ABSTRACT);
-  }
-
-  return type;
-}
-
-/* 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;
-}
+G_DEFINE_ABSTRACT_TYPE(ThriftTransport, thrift_transport, G_TYPE_OBJECT)
 
 gboolean 
 thrift_transport_is_open (ThriftTransport *transport)
@@ -112,3 +86,23 @@
   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);
+}
diff --git a/lib/c_glib/src/transport/thrift_transport.h b/lib/c_glib/src/transport/thrift_transport.h
index 18edc4d..9797473 100644
--- a/lib/c_glib/src/transport/thrift_transport.h
+++ b/lib/c_glib/src/transport/thrift_transport.h
@@ -1,8 +1,29 @@
+/*
+ * 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.
  *
@@ -13,20 +34,13 @@
  *    is necessary.
  */
 
-/* type macros */	
+/* 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))
+#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
@@ -45,7 +59,7 @@
   GObjectClass parent;
 
   /* vtable */
-  gboolean (*is_open) (ThriftTransport *transport); 
+  gboolean (*is_open) (ThriftTransport *transport);
   gboolean (*open) (ThriftTransport *transport, GError **error);
   gboolean (*close) (ThriftTransport *transport, GError **error);
   gint32 (*read) (ThriftTransport *transport, gpointer buf,
@@ -59,7 +73,7 @@
 typedef struct _ThriftTransportClass ThriftTransportClass;
 
 /* used by THRIFT_TYPE_TRANSPORT */
-GType thrift_transport_get_type (void); 
+GType thrift_transport_get_type (void);
 
 /* virtual public methods */
 
@@ -67,7 +81,7 @@
  * Checks if this transport is opened.
  * \public \memberof ThriftTransportInterface
  */
-gboolean thrift_transport_is_open (ThriftTransport *transport); 
+gboolean thrift_transport_is_open (ThriftTransport *transport);
 
 /*!
  * Open the transport for reading and writing.
@@ -105,7 +119,7 @@
  * Called when write is completed.
  * \public \memberof ThriftTransportInterface
  */
-gboolean thrift_transport_write_end (ThriftTransport *transport, 
+gboolean thrift_transport_write_end (ThriftTransport *transport,
                                      GError **error);
 
 /*!
@@ -131,5 +145,6 @@
 GQuark thrift_transport_error_quark (void);
 #define THRIFT_TRANSPORT_ERROR (thrift_transport_error_quark ())
 
+G_END_DECLS
 
 #endif /* _THRIFT_TRANSPORT_H */
diff --git a/lib/c_glib/src/transport/thrift_transport_factory.c b/lib/c_glib/src/transport/thrift_transport_factory.c
index 6f0199f..8f9a1f2 100644
--- a/lib/c_glib/src/transport/thrift_transport_factory.c
+++ b/lib/c_glib/src/transport/thrift_transport_factory.c
@@ -1,42 +1,26 @@
+/*
+ * 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.h"
 #include "transport/thrift_transport_factory.h"
 
-/* forward declaration s*/
-static void thrift_transport_factory_class_init (ThriftTransportFactoryClass *cls);
-ThriftTransport *thrift_transport_factory_get_transport (ThriftTransportFactory *factory, ThriftTransport *transport);
-
-GType
-thrift_transport_factory_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info = {
-      sizeof (ThriftTransportFactoryClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) thrift_transport_factory_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (ThriftTransportFactory),
-      0, /* n_preallocs */
-      NULL, /* instance_init */
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (G_TYPE_OBJECT, "ThriftTransportFactory",
-                                   &info, 0);
-  }
-
-  return type;
-}
-
-static void
-thrift_transport_factory_class_init (ThriftTransportFactoryClass *cls)
-{
-  cls->get_transport = thrift_transport_factory_get_transport;
-}
+G_DEFINE_TYPE(ThriftTransportFactory, thrift_transport_factory, G_TYPE_OBJECT)
 
 /* builds a transport from the base transport. */
 ThriftTransport *
@@ -47,5 +31,14 @@
   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);
+}
diff --git a/lib/c_glib/src/transport/thrift_transport_factory.h b/lib/c_glib/src/transport/thrift_transport_factory.h
index d987a80..e44198b 100644
--- a/lib/c_glib/src/transport/thrift_transport_factory.h
+++ b/lib/c_glib/src/transport/thrift_transport_factory.h
@@ -1,3 +1,22 @@
+/*
+ * 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
 
@@ -5,6 +24,8 @@
 
 #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
@@ -13,19 +34,11 @@
 
 /* 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))
+#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
@@ -51,5 +64,6 @@
 /* virtual public methods */
 ThriftTransport *thrift_transport_factory_get_transport (ThriftTransportFactory *factory, ThriftTransport *transport);
 
+G_END_DECLS
 
 #endif /* _THRIFT_TRANSPORT_FACTORY_H */
diff --git a/lib/c_glib/test/Makefile.am b/lib/c_glib/test/Makefile.am
index a8889be..e9f070e 100644
--- a/lib/c_glib/test/Makefile.am
+++ b/lib/c_glib/test/Makefile.am
@@ -6,25 +6,9 @@
 CFLAGS = @GCOV_CFLAGS@
 CXXFLAGS = -g
 
-check_SCRIPTS = \
-  testwrapper-testtransportsocket \
-  testwrapper-testprotocolbinary \
-  testwrapper-testbufferedtransport \
-  testwrapper-testframedtransport \
-  testwrapper-testmemorybuffer \
-  testwrapper-teststruct \
-  testwrapper-testsimpleserver \
-  testwrapper-testdebugproto \
-  testwrapper-testoptionalrequired \
-  testwrapper-testthrifttest
-
-if WITH_CPP
-  check_SCRIPTS += testwrapper-testthrifttestclient
-endif
-
 check_PROGRAMS = \
   testtransportsocket \
-  testprotocolbinary \
+  testbinaryprotocol \
   testbufferedtransport \
   testframedtransport \
   testmemorybuffer \
@@ -44,8 +28,8 @@
     ../libthrift_c_glib_la-thrift_server_transport.o \
     ../libthrift_c_glib_la-thrift_server_socket.o
 
-testprotocolbinary_SOURCES = testprotocolbinary.c
-testprotocolbinary_LDADD = \
+testbinaryprotocol_SOURCES = testbinaryprotocol.c
+testbinaryprotocol_LDADD = \
     ../libthrift_c_glib_la-thrift_protocol.o \
     ../libthrift_c_glib_la-thrift_transport.o \
     ../libthrift_c_glib_la-thrift_socket.o \
@@ -158,9 +142,7 @@
 gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest.h: ../../../test/ThriftTest.thrift
 	$(THRIFT) --gen cpp $<
 
-
 TESTS = \
-  $(testwrapper-%) \
   $(check_PROGRAMS) \
   $(check_SCRIPTS)
 
@@ -212,18 +194,13 @@
 	    ${VALGRIND_LEAK_OPTS}                                       \
 	    ${$<_VALGRIND_LEAK_OPTS}  ./$<
 
-testwrapper-%: % test-wrapper.sh
-	@ln -sf test-wrapper.sh $@
-
 clean-local:
 	$(RM) -r gen-c_glib gen-cpp
 
 CLEANFILES =                            \
-    testwrapper-*                       \
     *.bb                                \
     *.bbg                               \
     *.da                                \
     *.gcno                              \
     *.gcda                              \
-    *.gcov                              \
-    test-wrapper.sh
+    *.gcov
diff --git a/lib/c_glib/test/test-wrapper.sh.in b/lib/c_glib/test/test-wrapper.sh.in
deleted file mode 100644
index 956b2d1..0000000
--- a/lib/c_glib/test/test-wrapper.sh.in
+++ /dev/null
@@ -1,58 +0,0 @@
-# /bin/sh
-
-command="$0"
-
-stripcommand=`echo "$command" | sed 's/testwrapper-//'`
-
-"$stripcommand" "$@" || exit $?
-
-if test "x@ENABLE_COVERAGE@" = "x1"; then
-  # linux: 97.67% of 86 lines executed in file ../src/test123.h
-  # bsd: 100.00% of 196 source lines executed in file testbimap.c
-
-  extrastripcommand=`echo "$stripcommand" | sed 's/\.\///'`
-    ${GCOV:-gcov} "$extrastripcommand" 2>&1                        \
-  | perl -ne 'BEGIN { $file = undef; }
-      next if m!^Creating!;
-      next if m!creating!;
-      next if m!^$!;
-      next if m!not exhausted!;
-      next if m!^Unexpected EOF!;
-      if (m!([\d\.]+)\% of \d+( source)? lines executed in file (.+)!)
-        {
-          do
-            {
-              if ( $3 !~ m#^/# )
-                {
-                  $a = $3 =~ m%([\-\w\.]+)$%;
-                  print STDERR $_;
-                  print "$1.gcov\n";
-                }
-            } if $1 < 110.0;
-        }
-      elsif (m#^File .(.*?).$#)
-        {
-          $file = $1;
-        }
-      elsif (m#Lines executed:([\d\.]+)\% of (\d+)#)
-        {
-          $percent = $1;
-          $lines = $2;
-          do
-            {
-              if ( $file !~ m#^/# )
-                {
-                  $a = $file =~ m%([\-\w\.]+)$%;
-                  print STDERR "$percent% of $lines executed in file $file\n";
-                  print "$1.gcov\n";
-                }
-            } if $percent < 110.0;
-        }
-      else
-        {
-          print
-        }'                 \
-  | xargs grep -n -A2 -B2 '#####.*\w'
-  exit 0
-fi
-
diff --git a/lib/c_glib/test/testprotocolbinary.c b/lib/c_glib/test/testbinaryprotocol.c
similarity index 94%
rename from lib/c_glib/test/testprotocolbinary.c
rename to lib/c_glib/test/testbinaryprotocol.c
index c8a54b9..94813e2 100644
--- a/lib/c_glib/test/testprotocolbinary.c
+++ b/lib/c_glib/test/testbinaryprotocol.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -639,14 +658,15 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
-  g_type_init ();
-  test_create_and_destroy ();
-  test_initialize ();
-  test_read_and_write_primitives ();
-  test_read_and_write_complex_types ();
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testmemorybuffer/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testmemorybuffer/Initialize", test_initialize);
+  g_test_add_func ("/testmemorybuffer/ReadAndWritePrimitives", test_read_and_write_primitives);
+  g_test_add_func ("/testmemorybuffer/ReadAndWriteComplexTypes", test_read_and_write_complex_types);
+
+  return g_test_run ();
 }
-
diff --git a/lib/c_glib/test/testbufferedtransport.c b/lib/c_glib/test/testbufferedtransport.c
index 6759509..fb49c8f 100644
--- a/lib/c_glib/test/testbufferedtransport.c
+++ b/lib/c_glib/test/testbufferedtransport.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
 
@@ -176,13 +195,15 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
   g_type_init();
-  test_create_and_destroy();
-  test_open_and_close();
-  test_read_and_write();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testbufferedtransport/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testbufferedtransport/OpenAndClose", test_open_and_close);
+  g_test_add_func ("/testbufferedtransport/ReadAndWrite", test_read_and_write);
+
+  return g_test_run ();
 }
 
diff --git a/lib/c_glib/test/testdebugproto.c b/lib/c_glib/test/testdebugproto.c
index b111e12..f0654f1 100644
--- a/lib/c_glib/test/testdebugproto.c
+++ b/lib/c_glib/test/testdebugproto.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <math.h>
 #include <glib-object.h>
 
@@ -7,12 +26,9 @@
 
 #include "gen-c_glib/t_test_debug_proto_test_types.h"
 
-
-int
-main(void)
+static void
+test_debug_proto(void)
 {
-  g_type_init ();
-
   TTestOneOfEach *ooe = NULL;
   TTestNesting *n = NULL;
   TTestHolyMoley *hm = NULL;
@@ -62,3 +78,15 @@
   return 0;
 }
 
+int
+main(int argc, char *argv[])
+{
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/testdebugproto/DebugProto", test_debug_proto);
+
+  return g_test_run ();
+}
+
+
diff --git a/lib/c_glib/test/testframedtransport.c b/lib/c_glib/test/testframedtransport.c
index 23951f7..3269bf5 100644
--- a/lib/c_glib/test/testframedtransport.c
+++ b/lib/c_glib/test/testframedtransport.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
 
@@ -164,13 +183,14 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
   g_type_init();
-  test_create_and_destroy();
-  test_open_and_close();
-  test_read_and_write();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testframedtransport/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testframedtransport/OpenAndClose", test_open_and_close);
+  g_test_add_func ("/testframedtransport/ReadAndWrite", test_read_and_write);
+
+  return g_test_run ();
 }
-
diff --git a/lib/c_glib/test/testmemorybuffer.c b/lib/c_glib/test/testmemorybuffer.c
index 52b18bf..65901bf 100644
--- a/lib/c_glib/test/testmemorybuffer.c
+++ b/lib/c_glib/test/testmemorybuffer.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
 
@@ -63,13 +82,14 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
   g_type_init();
-  test_create_and_destroy();
-  test_open_and_close();
-  test_read_and_write();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testmemorybuffer/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testmemorybuffer/OpenAndClose", test_open_and_close);
+  g_test_add_func ("/testmemorybuffer/ReadAndWrite", test_read_and_write);
+
+  return g_test_run ();
 }
-
diff --git a/lib/c_glib/test/testoptionalrequired.c b/lib/c_glib/test/testoptionalrequired.c
index cf44413..7165d93 100644
--- a/lib/c_glib/test/testoptionalrequired.c
+++ b/lib/c_glib/test/testoptionalrequired.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <glib.h>
 
@@ -167,16 +186,17 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
-  g_type_init ();
-  test_old_school1 ();
-  test_simple ();
-  test_tricky1 ();
-  test_tricky2 ();
-  test_tricky3 ();
-  test_tricky4 ();
-  return 0;
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/testoptionalrequired/OldSchool", test_old_school1);
+  g_test_add_func ("/testoptionalrequired/Simple", test_simple);
+  g_test_add_func ("/testoptionalrequired/Tricky1", test_tricky1);
+  g_test_add_func ("/testoptionalrequired/Tricky2", test_tricky2);
+  g_test_add_func ("/testoptionalrequired/Tricky3", test_tricky3);
+  g_test_add_func ("/testoptionalrequired/Tricky4", test_tricky4);
+
+  return g_test_run ();
 }
-
-
diff --git a/lib/c_glib/test/testsimpleserver.c b/lib/c_glib/test/testsimpleserver.c
index 182e9ef..282a6e8 100644
--- a/lib/c_glib/test/testsimpleserver.c
+++ b/lib/c_glib/test/testsimpleserver.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <glib.h>
 #include <stdlib.h>
@@ -5,6 +24,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#include "thrift.h"
 #include "processor/thrift_processor.h"
 #include "transport/thrift_server_socket.h"
 
@@ -27,6 +47,8 @@
 };
 typedef struct _TestProcessorClass TestProcessorClass;
 
+G_DEFINE_TYPE(TestProcessor, test_processor, THRIFT_TYPE_PROCESSOR)
+
 gboolean
 test_processor_process (ThriftProcessor *processor, ThriftProtocol *in,
                         ThriftProtocol *out)
@@ -35,38 +57,15 @@
 }
 
 static void
-test_processor_class_init (ThriftProcessorClass *proc)
+test_processor_init (TestProcessor *p)
 {
-  proc->process = test_processor_process;
+  THRIFT_UNUSED_VAR (p);
 }
 
-GType
-test_processor_get_type (void)
+static void
+test_processor_class_init (TestProcessorClass *proc)
 {
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo info =
-    {
-      sizeof (TestProcessorClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc) test_processor_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof (TestProcessor),
-      0, /* n_preallocs */
-      NULL, /* instance_init */
-      NULL, /* value_table */
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_PROCESSOR,
-                                   "TestProcessorType",
-                                   &info, 0);
-  }
-
-  return type;
+  (THRIFT_PROCESSOR_CLASS(proc))->process = test_processor_process;
 }
 
 static void
@@ -104,10 +103,12 @@
 }
 
 int
-main (void)
+main(int argc, char *argv[])
 {
-  g_type_init ();
-  test_server ();
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testsimpleserver/SimpleServer", test_server);
+
+  return g_test_run ();
 }
diff --git a/lib/c_glib/test/teststruct.c b/lib/c_glib/test/teststruct.c
index cb401e2..ec543be 100644
--- a/lib/c_glib/test/teststruct.c
+++ b/lib/c_glib/test/teststruct.c
@@ -1,3 +1,22 @@
+/*
+ * 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 <glib-object.h>
 
@@ -20,67 +39,13 @@
 GType thrift_test_struct_get_type (void);
 
 #define THRIFT_TYPE_TEST_STRUCT (thrift_test_struct_get_type ())
-#define THRIFT_TEST_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-                                     THRIFT_TYPE_TEST_STRUCT, \
-                                     ThriftTestStruct))
-#define THRIFT_TEST_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), \
-                                         THRIFT_TYPE_TEST_STRUCT, \
-                                         ThriftTestStructClass))
-#define THRIFT_IS_TEST_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-                                        THRIFT_TYPE_TEST_STRUCT))
-#define THRIFT_IS_TEST_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), \
-                                            THRIFT_TYPE_TEST_STRUCT))
-#define THRIFT_TEST_STRUCT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-                                               THRIFT_TYPE_TEST_STRUCT, \
-                                               ThriftTestStructClass))
+#define THRIFT_TEST_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_TEST_STRUCT, ThriftTestStruct))
+#define THRIFT_TEST_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_TEST_STRUCT, ThriftTestStructClass))
+#define THRIFT_IS_TEST_STRUCT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_TEST_STRUCT))
+#define THRIFT_IS_TEST_STRUCT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_TEST_STRUCT))
+#define THRIFT_TEST_STRUCT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_TEST_STRUCT, ThriftTestStructClass))
 
-/* test declarations */
-gint32 thrift_test_struct_read (ThriftStruct *object, ThriftProtocol *protocol,
-                                GError **error);
-gint32 thrift_test_struct_write (ThriftStruct *object, ThriftProtocol *protocol,
-                                 GError **error);
-
-static void
-thrift_test_struct_class_init (ThriftTestStructClass *cls)
-{
-  ThriftStructClass *ts_cls = THRIFT_STRUCT_CLASS (cls);
-  ts_cls->read = thrift_test_struct_read;
-  ts_cls->write = thrift_test_struct_write;
-}
-
-static void
-thrift_test_struct_instance_init (ThriftTestStruct *s)
-{
-  (void) s;
-}
-
-GType
-thrift_test_struct_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-  {
-    static const GTypeInfo type_info =
-    {
-      sizeof (ThriftTestStructClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) thrift_test_struct_class_init,
-      NULL,
-      NULL,
-      sizeof (ThriftTestStruct),
-      0,
-      (GInstanceInitFunc) thrift_test_struct_instance_init,
-      NULL, 
-    };
-
-    type = g_type_register_static (THRIFT_TYPE_STRUCT,
-                                   "ThriftTestStructType", &type_info, 0);
-  }
-
-  return type;
-}
+G_DEFINE_TYPE(ThriftTestStruct, thrift_test_struct, THRIFT_TYPE_STRUCT)
 
 gint32
 thrift_test_struct_read (ThriftStruct *object, ThriftProtocol *protocol,
@@ -96,6 +61,19 @@
   return 0;
 }
 
+static void
+thrift_test_struct_class_init (ThriftTestStructClass *cls)
+{
+  ThriftStructClass *ts_cls = THRIFT_STRUCT_CLASS (cls);
+  ts_cls->read = thrift_test_struct_read;
+  ts_cls->write = thrift_test_struct_write;
+}
+
+static void
+thrift_test_struct_init (ThriftTestStruct *s)
+{
+  THRIFT_UNUSED_VAR (s);
+}
 
 static void
 test_initialize_object (void)
@@ -112,10 +90,12 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
-  g_type_init ();
-  test_initialize_object ();
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/teststruct/InitializeObject", test_initialize_object);
+
+  return g_test_run ();
 }
diff --git a/lib/c_glib/test/testthrifttest.c b/lib/c_glib/test/testthrifttest.c
index 6020f9c..b14b606 100644
--- a/lib/c_glib/test/testthrifttest.c
+++ b/lib/c_glib/test/testthrifttest.c
@@ -7,22 +7,22 @@
 static const char TEST_ADDRESS[] = "localhost";
 static const int TEST_PORT = 64444;
 
-static void thrift_server (const int port);
-
 static void
-thrift_server (const int port)
+test_thrift_server (const int port)
 {
   ThriftServerSocket *tsocket = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
-                                              "port", port, NULL);
+                                              "port", TEST_PORT, NULL);
 
   g_object_unref (tsocket);
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
-  g_type_init ();
-  thrift_server (TEST_PORT);
-  return 0;
-}
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
 
+  g_test_add_func ("/testthrift/Server", test_thrift_server);
+
+  return g_test_run ();
+}
diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp
index 4b5b841..15389a5 100644
--- a/lib/c_glib/test/testthrifttestclient.cpp
+++ b/lib/c_glib/test/testthrifttestclient.cpp
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
 
 /* test a C client with a C++ server */
 
diff --git a/lib/c_glib/test/testtransportsocket.c b/lib/c_glib/test/testtransportsocket.c
index 14579c8..279da86 100644
--- a/lib/c_glib/test/testtransportsocket.c
+++ b/lib/c_glib/test/testtransportsocket.c
@@ -1,3 +1,22 @@
+/*
+ * 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>
 
@@ -188,13 +207,15 @@
 }
 
 int
-main(void)
+main(int argc, char *argv[])
 {
   g_type_init();
-  test_create_and_destroy();
-  test_open_and_close();
-  test_read_and_write();
+  g_test_init (&argc, &argv, NULL);
 
-  return 0;
+  g_test_add_func ("/testtransportsocket/CreateAndDestroy", test_create_and_destroy);
+  g_test_add_func ("/testtransportsocket/OpenAndClose", test_open_and_close);
+  g_test_add_func ("/testtransportsocket/ReadAndWrite", test_read_and_write);
+
+  return g_test_run ();
 }
 
diff --git a/lib/c_glib/thrift_c_glib.pc.in b/lib/c_glib/thrift_c_glib.pc.in
index 44675df..3a4137d 100644
--- a/lib/c_glib/thrift_c_glib.pc.in
+++ b/lib/c_glib/thrift_c_glib.pc.in
@@ -25,5 +25,6 @@
 Name: Thrift
 Description: Thrift C API
 Version: @VERSION@
+Requires: glib-2.0 gobject-2.0
 Libs: -L${libdir} -lthriftc
 Cflags: -I${includedir}/thrift