Export ISDS server locators
[libisds.git] / src / isds_priv.h
blob298880083923c6fe66361ddd668193f9b560cdeb
1 #ifndef __ISDS_ISDS_PRIV_H__
2 #define __ISDS_ISDS_PRIV_H__
4 /* Structures not to export outside library */
5 #include "../config.h"
6 #include "isds.h"
7 #include <curl/curl.h>
8 #include <libxml/parser.h>
9 #include <libxml/tree.h>
10 #include <libxml/xpath.h>
11 #include <libxml/xpathInternals.h>
12 #include <libxml/xmlsave.h>
13 #include "gettext.h"
15 #define _(x) ((const char *) dgettext(PACKAGE, (x)))
17 #define SOAP_NS "http://schemas.xmlsoap.org/soap/envelope/"
18 #define SOAP2_NS "http://www.w3.org/2003/05/soap-envelope"
19 #define ISDS_NS "http://isds.czechpoint.cz/v20"
20 #define SISDS_INCOMING_NS "http://isds.czechpoint.cz/v20/message"
21 #define SISDS_OUTGOING_NS "http://isds.czechpoint.cz/v20/SentMessage"
22 #define SISDS_DELIVERY_NS "http://isds.czechpoint.cz/v20/delivery"
23 #define SCHEMA_NS "http://www.w3.org/2001/XMLSchema"
24 #define DEPOSIT_NS "urn:uschovnaWSDL"
27 /* Used to choose proper name space for message elements.
28 * See register_namespaces(). */
29 typedef enum {
30 MESSAGE_NS_UNSIGNED,
31 MESSAGE_NS_SIGNED_INCOMING,
32 MESSAGE_NS_SIGNED_OUTGOING,
33 MESSAGE_NS_SIGNED_DELIVERY
34 } message_ns_type;
36 /* Type of a context */
37 typedef enum {
38 CTX_TYPE_ISDS, /* Connection to ISDS */
39 CTX_TYPE_CZP /* Connection to Czech POINT document deposit */
40 } context_type;
42 /* Global variables.
43 * Allocated in isds_init() and deallocated in isds_cleanup(). */
44 unsigned int log_facilities;
45 isds_log_level log_level;
46 isds_log_callback log_callback; /* Pass global log message to application.
47 NULL to log to stderr itself */
48 void *log_callback_data; /* Application specific data to pass to
49 registered log_callback function */
51 /* End of global variables */
53 /* Context */
54 struct isds_ctx {
55 context_type type; /* Context type */
56 unsigned int timeout; /* milliseconds */
57 char *url; /* URL of the ISDS web service */
58 char *username;
59 char *password;
60 char *client_certificate;
61 char *private_key;
62 CURL *curl; /* CURL session handle */
63 _Bool *tls_verify_server; /* Verify the server? */
64 isds_progress_callback progress_callback; /* Call it during
65 communication with server.
66 NULL for nothing */
67 void *progress_callback_data; /* Application provided argument
68 for progress_callback */
69 char *tls_ca_file; /* File name with CA certificates */
70 char *tls_ca_dir; /* Directory name with CA certificates */
71 char *long_message; /* message buffer */
74 /* Stores message into context' long_message buffer.
75 * Application can pick the message up using isds_long_message().
76 * NULL @message truncates the buffer but does not deallocate it.
77 * @message is coded in locale encoding */
78 isds_error isds_log_message(struct isds_ctx *context, const char *message);
80 /* Appends message into context' long_message buffer.
81 * Application can pick the message up using isds_long_message().
82 * NULL message has void effect. */
83 isds_error isds_append_message(struct isds_ctx *context, const char *message);
85 /* Stores formated message into context' long_message buffer.
86 * Application can pick the message up using isds_long_message(). */
87 isds_error isds_printf_message(struct isds_ctx *context,
88 const char *format, ...);
90 /* Log @message in class @facility with log @level into global log. @message
91 * is printf(3) formating string, variadic arguments may be neccessary.
92 * For debugging purposes. */
93 isds_error isds_log(const isds_log_facility facility,
94 const isds_log_level level, const char *message, ...);
96 /* Makes known all relevant namespaces to given XPath context
97 * @xpat_ctx is XPath context
98 * @message_ns selects propper message name space. Unsisnged and signed
99 * messages differs.
100 * prefix and to URI ISDS_NS */
101 isds_error register_namespaces(xmlXPathContextPtr xpath_ctx,
102 const message_ns_type message_ns);
104 #endif