0.6.1 bump
[libisds.git] / test / simline / server.h
blob0d65d578dc9a9f5cc92203aa269a916d6f95da66
1 #ifndef __ISDS_SERVER_H
2 #define __ISDS_SERVER_H
4 #include <sys/types.h> /* For pid_t */
5 #include "server_types.h"
6 #include "services.h"
8 extern const char *server_error;
10 /* Save pointer to static error message if not yet set */
11 void set_server_error(const char *message);
14 /* Creates listening TCP socket on localhost.
15 * Returns the socket descriptor or -1. */
16 int listen_on_socket(void);
19 /* Format socket address as printable string.
20 * @return allocated string or NULL in case of error. */
21 char *socket2address(int socket);
24 struct arguments_basic_authentication {
25 const char *username; /* Sets required user name server has to require.
26 Set NULL to disable HTTP authentication. */
27 const char *password; /* sets required password server has to require */
28 _Bool isds_deviations; /* is flag to set conformance level. If false,
29 server is compliant to standards (HTTP, SOAP)
30 if not conflicts with ISDS specification.
31 Otherwise server mimics real ISDS implementation
32 as much as possible. */
33 const struct service_configuration *services; /* Array of enabled
34 services. Last name must
35 be SERVICE_END. */
38 /* Do the server protocol.
39 * @server_socket is listening TCP socket of the server
40 * @server_arguments is pointer to structure:
41 * Never returns. Terminates by exit(). */
42 void server_basic_authentication(int server_socket,
43 const void *server_arguments);
46 struct arguments_otp_authentication {
47 enum auth_otp_method method; /* Selects OTP method to enable */
48 const char *username; /* Sets required user name server has to require.
49 Set NULL to disable HTTP authentication. */
50 const char *password; /* Sets password server has to require */
51 const char *otp; /* Sets OTP code server has to requiere */
52 _Bool isds_deviations; /* Is flag to set conformance level. If false,
53 server is compliant to standards (HTTP, SOAP)
54 if not conflicts with ISDS specification.
55 Otherwise server mimics real ISDS implementation
56 as much as possible. */
57 const struct service_configuration *services; /* Array of enabled
58 services. Last name must
59 be SERVICE_END. */
62 /* Do the server protocol with OTP authentication.
63 * @server_socket is listening TCP socket of the server
64 * @server_arguments is pointer to structure arguments_otp_authentication. It
65 * selects OTP method to enable.
66 * Never returns. Terminates by exit(). */
67 void server_otp_authentication(int server_socket,
68 const void *server_arguments);
70 /* Implementation of server that is out of order.
71 * It always sends back SOAP Fault with HTTP error 503.
72 * @server_socket is listening TCP socket of the server
73 * @server_arguments is ununsed pointer
74 * Never returns. Terminates by exit(). */
75 void server_out_of_order(int server_socket,
76 const void *server_arguments);
79 /* Start sever in separate process.
80 * @server_process is PID of forked server
81 * @server_address is automatically allocated TCP address of listening server
82 * @username sets required user name server has to require. Set NULL to
83 * disable HTTP authentication.
84 * @password sets required password server has to require
85 * socket.
86 * @isds_deviations is flag to set conformance level. If false, server is
87 * compliant to standards (HTTP, SOAP) if not conflicts with ISDS
88 * specification. Otherwise server mimics real ISDS implementation as much
89 * as possible.
90 * @return -1 in case of error. */
91 int start_server(pid_t *server_process, char **server_address,
92 void (*server_implementation)(int, const void *),
93 const void *server_arguments);
96 /* Kill the server process.
97 * Return -1 in case of error. */
98 int stop_server(pid_t server_process);
100 #endif