libxr — developer's documentation

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

xr-server.h
Go to the documentation of this file.
1 /*
2 * Copyright 2006-2008 Ondrej Jirman <ondrej.jirman@zonio.net>
3 *
4 * This file is part of libxr.
5 *
6 * Libxr is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License as published by the Free
8 * Software Foundation, either version 2 of the License, or (at your option) any
9 * later version.
10 *
11 * Libxr is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with libxr. If not, see <http://www.gnu.org/licenses/>.
18 */
19
27 #ifndef __XR_SERVER_H__
28 #define __XR_SERVER_H__
29
30 #include <openssl/ssl.h>
31 #include "xr-call.h"
32 #include "xr-http.h"
33 #include "xr-value-utils.h"
34
37 typedef struct _xr_server xr_server;
38
42 typedef struct _xr_servlet xr_servlet;
43
46 typedef gboolean (*servlet_method_t)(xr_servlet* servlet, xr_call* call);
47
50 typedef gboolean (*servlet_init_t)(xr_servlet* servlet);
51
54 typedef void (*servlet_fini_t)(xr_servlet* servlet);
55
58 typedef gboolean (*servlet_download_t)(xr_servlet* servlet);
59
62 typedef gboolean (*servlet_upload_t)(xr_servlet* servlet);
63
66 typedef struct _xr_servlet_method_def xr_servlet_method_def;
67
70 typedef struct _xr_servlet_def xr_servlet_def;
71
74 struct _xr_servlet_method_def
75 {
76 char* name;
77 servlet_method_t cb;
78 void* padding1[4];
79 };
80
83 struct _xr_servlet_def
84 {
85 char* name;
86 int size;
87 servlet_init_t init;
88 servlet_fini_t fini;
89 servlet_method_t pre_call;
90 servlet_method_t post_call;
91 servlet_download_t download;
92 servlet_upload_t upload;
93 int methods_count;
94 xr_servlet_method_def* methods;
95 servlet_method_t fallback;
96 void* padding1[10];
97 };
98
99 #define XR_SERVER_ERROR xr_server_error_quark()
100
101 typedef enum
102 {
103 XR_SERVER_ERROR_FAILED
104 } XRServerError;
105
106 G_BEGIN_DECLS
107
117 xr_server* xr_server_new(const char* cert, int threads, GError** err);
118
127 SSL_CTX* xr_server_get_ssl_context(xr_server* server);
128
137 gboolean xr_server_bind(xr_server* server, const char* port, GError** err);
138
150 gboolean xr_server_run(xr_server* server, GError** err);
151
156 void xr_server_stop(xr_server* server);
157
162 void xr_server_free(xr_server* server);
163
171 gboolean xr_server_register_servlet(xr_server* server, xr_servlet_def* servlet);
172
179 void* xr_servlet_get_priv(xr_servlet* servlet);
180
187 xr_http* xr_servlet_get_http(xr_servlet* servlet);
188
195 char* xr_servlet_get_client_ip(xr_servlet* servlet);
196
207 gboolean xr_server_simple(const char* cert, int threads, const char* bind,
208 xr_servlet_def** servlets, GError** err);
209
210 GQuark xr_server_error_quark();
211
212 G_END_DECLS
213
214 #endif
_xr_servlet_def::pre_call
servlet_method_t pre_call
Pre-call hook.
Definition: xr-server.h:89
_xr_servlet_def::size
int size
Size of the private object.
Definition: xr-server.h:86
xr_server_get_ssl_context
SSL_CTX * xr_server_get_ssl_context(xr_server *server)
Get SSL context used by the server.
xr_server_run
gboolean xr_server_run(xr_server *server, GError **err)
Run server.
xr-call.h
XML-RPC Call Handling API.
xr_servlet_get_http
xr_http * xr_servlet_get_http(xr_servlet *servlet)
Get http object for the servlet.
xr_server_stop
void xr_server_stop(xr_server *server)
Stop server.
_xr_servlet_def::post_call
servlet_method_t post_call
Post-call hook.
Definition: xr-server.h:90
_xr_servlet_def::init
servlet_init_t init
Servlet constructor.
Definition: xr-server.h:87
xr_servlet_get_client_ip
char * xr_servlet_get_client_ip(xr_servlet *servlet)
Get client IP address.
xr_server_free
void xr_server_free(xr_server *server)
Free server object.
servlet_fini_t
void(* servlet_fini_t)(xr_servlet *servlet)
Servlet fini callback type.
Definition: xr-server.h:54
xr_servlet_get_priv
void * xr_servlet_get_priv(xr_servlet *servlet)
Get private data for the servlet.
xr_http
struct _xr_http xr_http
Opaque HTTP object.
Definition: xr-http.h:46
servlet_download_t
gboolean(* servlet_download_t)(xr_servlet *servlet)
Servlet download callback type.
Definition: xr-server.h:58
xr-http.h
HTTP Transport.
xr_server_bind
gboolean xr_server_bind(xr_server *server, const char *port, GError **err)
Bind to the specified host/port.
xr_server_register_servlet
gboolean xr_server_register_servlet(xr_server *server, xr_servlet_def *servlet)
Register servlet type with the server.
_xr_servlet_def::upload
servlet_upload_t upload
Upload hook.
Definition: xr-server.h:92
_xr_servlet_method_def::name
char * name
Method name.
Definition: xr-server.h:76
_xr_servlet_def::name
char * name
Servlet name (/Name resource for client).
Definition: xr-server.h:85
_xr_servlet_def::download
servlet_download_t download
Download hook.
Definition: xr-server.h:91
xr-value-utils.h
xr_value parser/builder.
_xr_servlet_method_def
Servlet method description structure.
Definition: xr-server.h:74
xr_server_new
G_BEGIN_DECLS xr_server * xr_server_new(const char *cert, int threads, GError **err)
Create new server object.
_xr_servlet_method_def::cb
servlet_method_t cb
Method callback.
Definition: xr-server.h:77
_xr_servlet_def::fini
servlet_fini_t fini
Servlet destructor.
Definition: xr-server.h:88
xr_call
struct _xr_call xr_call
Opaque data structrure for storing intermediate representation of XML-RPC call.
Definition: xr-call.h:49
servlet_upload_t
gboolean(* servlet_upload_t)(xr_servlet *servlet)
Servlet upload callback type.
Definition: xr-server.h:62
servlet_method_t
gboolean(* servlet_method_t)(xr_servlet *servlet, xr_call *call)
Servlet method callback type.
Definition: xr-server.h:46
_xr_servlet_def
Servlet description structure.
Definition: xr-server.h:83
xr_server
struct _xr_server xr_server
Opaque data structrure that represents XML-RPC server.
Definition: xr-server.h:37
_xr_servlet_def::fallback
servlet_method_t fallback
Fallback (undefined method) hook.
Definition: xr-server.h:95
xr_server_simple
gboolean xr_server_simple(const char *cert, int threads, const char *bind, xr_servlet_def **servlets, GError **err)
Use this function as a simple way to quickly start a server.
xr_servlet
struct _xr_servlet xr_servlet
Opaque data structrure that represents single instance of servlet object.
Definition: xr-server.h:42
servlet_init_t
gboolean(* servlet_init_t)(xr_servlet *servlet)
Servlet init callback type.
Definition: xr-server.h:50
_xr_servlet_def::methods_count
int methods_count
Count of the methods implemented by the server.
Definition: xr-server.h:93
_xr_servlet_def::methods
xr_servlet_method_def * methods
Methods descriptions.
Definition: xr-server.h:94
Documentation for libxr, Fri Apr 15 2016 08:12:18.