1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 #ifndef _THRIFT_SERVER_SOCKET_H 21 #define _THRIFT_SERVER_SOCKET_H 22 23 #include <glib-object.h> 24 25 #include "thrift_server_transport.h" 26 27 G_BEGIN_DECLS 28 29 /*! \file thrift_server_socket.h 30 * \brief Socket implementation of a Thrift server transport. Implements the 31 * ThriftServerTransport class. 32 */ 33 34 /* type macros */ 35 #define THRIFT_TYPE_SERVER_SOCKET (thrift_server_socket_get_type ()) 36 #define THRIFT_SERVER_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_SERVER_SOCKET, ThriftServerSocket)) 37 #define THRIFT_IS_SERVER_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_SERVER_SOCKET)) 38 #define THRIFT_SERVER_SOCKET_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_SERVER_SOCKET, ThriftServerSocketClass)) 39 #define THRIFT_IS_SERVER_SOCKET_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_SERVER_SOCKET)) 40 #define THRIFT_SERVER_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_SERVER_SOCKET, ThriftServerSocketClass)) 41 42 typedef struct _ThriftServerSocket ThriftServerSocket; 43 44 /*! 45 * Thrift ServerSocket instance. 46 */ 47 struct _ThriftServerSocket 48 { 49 ThriftServerTransport parent; 50 51 /* private */ 52 guint port; 53 gchar *path; 54 gshort backlog; 55 int sd; 56 guint8 *buf; 57 guint32 buf_size; 58 guint32 buf_len; 59 }; 60 61 typedef struct _ThriftServerSocketClass ThriftServerSocketClass; 62 63 /*! 64 * Thrift ServerSocket class. 65 */ 66 struct _ThriftServerSocketClass 67 { 68 ThriftServerTransportClass parent; 69 }; 70 71 /* used by THRIFT_TYPE_SERVER_SOCKET */ 72 GType thrift_server_socket_get_type (void); 73 74 /* define error/exception types */ 75 typedef enum 76 { 77 THRIFT_SERVER_SOCKET_ERROR_SOCKET, 78 THRIFT_SERVER_SOCKET_ERROR_SETSOCKOPT, 79 THRIFT_SERVER_SOCKET_ERROR_BIND, 80 THRIFT_SERVER_SOCKET_ERROR_LISTEN, 81 THRIFT_SERVER_SOCKET_ERROR_ACCEPT, 82 THRIFT_SERVER_SOCKET_ERROR_CLOSE 83 } ThriftServerSocketError; 84 85 /* define a error domain for GError to use */ 86 GQuark thrift_server_socket_error_quark (void); 87 #define THRIFT_SERVER_SOCKET_ERROR (thrift_server_socket_error_quark ()) 88 89 G_END_DECLS 90 91 #endif 92