1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | /* |
---|
3 | * Copyright (C) 2000-2003, Ximian, Inc. |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef SOUP_SERVER_H |
---|
7 | #define SOUP_SERVER_H 1 |
---|
8 | |
---|
9 | #include <libsoup/soup-types.h> |
---|
10 | #include <libsoup/soup-method.h> |
---|
11 | #include <libsoup/soup-uri.h> |
---|
12 | |
---|
13 | #define SOUP_TYPE_SERVER (soup_server_get_type ()) |
---|
14 | #define SOUP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_SERVER, SoupServer)) |
---|
15 | #define SOUP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_SERVER, SoupServerClass)) |
---|
16 | #define SOUP_IS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_SERVER)) |
---|
17 | #define SOUP_IS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_SERVER)) |
---|
18 | #define SOUP_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_SERVER, SoupServerClass)) |
---|
19 | |
---|
20 | typedef struct SoupServerPrivate SoupServerPrivate; |
---|
21 | |
---|
22 | struct SoupServer { |
---|
23 | GObject parent; |
---|
24 | |
---|
25 | SoupServerPrivate *priv; |
---|
26 | }; |
---|
27 | |
---|
28 | typedef struct { |
---|
29 | GObjectClass parent_class; |
---|
30 | |
---|
31 | } SoupServerClass; |
---|
32 | |
---|
33 | GType soup_server_get_type (void); |
---|
34 | |
---|
35 | |
---|
36 | typedef struct SoupServerHandler SoupServerHandler; |
---|
37 | |
---|
38 | typedef struct { |
---|
39 | SoupMessage *msg; |
---|
40 | char *path; |
---|
41 | SoupMethodId method_id; |
---|
42 | SoupServerAuth *auth; |
---|
43 | SoupServer *server; |
---|
44 | SoupServerHandler *handler; |
---|
45 | SoupSocket *sock; |
---|
46 | } SoupServerContext; |
---|
47 | |
---|
48 | typedef void (*SoupServerCallbackFn) (SoupServerContext *context, |
---|
49 | SoupMessage *msg, |
---|
50 | gpointer user_data); |
---|
51 | |
---|
52 | typedef void (*SoupServerUnregisterFn) (SoupServer *server, |
---|
53 | SoupServerHandler *handler, |
---|
54 | gpointer user_data); |
---|
55 | |
---|
56 | struct SoupServerHandler { |
---|
57 | char *path; |
---|
58 | |
---|
59 | SoupServerAuthContext *auth_ctx; |
---|
60 | |
---|
61 | SoupServerCallbackFn callback; |
---|
62 | SoupServerUnregisterFn unregister; |
---|
63 | gpointer user_data; |
---|
64 | }; |
---|
65 | |
---|
66 | #define SOUP_SERVER_PORT "port" |
---|
67 | #define SOUP_SERVER_INTERFACE "interface" |
---|
68 | #define SOUP_SERVER_SSL_CERT_FILE "ssl-cert-file" |
---|
69 | #define SOUP_SERVER_SSL_KEY_FILE "ssl-key-file" |
---|
70 | |
---|
71 | SoupServer *soup_server_new (const char *optname1, |
---|
72 | ...); |
---|
73 | |
---|
74 | SoupProtocol soup_server_get_protocol (SoupServer *serv); |
---|
75 | guint soup_server_get_port (SoupServer *serv); |
---|
76 | |
---|
77 | void soup_server_run (SoupServer *serv); |
---|
78 | void soup_server_run_async (SoupServer *serv); |
---|
79 | void soup_server_quit (SoupServer *serv); |
---|
80 | |
---|
81 | |
---|
82 | /* Handlers */ |
---|
83 | |
---|
84 | void soup_server_add_handler (SoupServer *serv, |
---|
85 | const char *path, |
---|
86 | SoupServerAuthContext *auth_ctx, |
---|
87 | SoupServerCallbackFn callback, |
---|
88 | SoupServerUnregisterFn unreg, |
---|
89 | gpointer data); |
---|
90 | void soup_server_remove_handler (SoupServer *serv, |
---|
91 | const char *path); |
---|
92 | SoupServerHandler *soup_server_get_handler (SoupServer *serv, |
---|
93 | const char *path); |
---|
94 | GSList *soup_server_list_handlers (SoupServer *serv); |
---|
95 | |
---|
96 | |
---|
97 | /* Functions for accessing information about the specific connection */ |
---|
98 | |
---|
99 | SoupAddress *soup_server_context_get_client_address (SoupServerContext *ctx); |
---|
100 | const char *soup_server_context_get_client_host (SoupServerContext *ctx); |
---|
101 | |
---|
102 | |
---|
103 | #endif /* SOUP_SERVER_H */ |
---|