Optional MIME type normalization while message loading
[libisds.git] / src / isds_priv.h
blobe75bca89964e129aa83e9c4a93fcdd84f0bb7778
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 ISDS1_NS "http://isds.czechpoint.cz"
20 #define ISDS_NS "http://isds.czechpoint.cz/v20"
21 #define SISDS_INCOMING_NS "http://isds.czechpoint.cz/v20/message"
22 #define SISDS_OUTGOING_NS "http://isds.czechpoint.cz/v20/SentMessage"
23 #define SISDS_DELIVERY_NS "http://isds.czechpoint.cz/v20/delivery"
24 #define SCHEMA_NS "http://www.w3.org/2001/XMLSchema"
25 #define DEPOSIT_NS "urn:uschovnaWSDL"
28 /* Used to choose proper name space for message elements.
29 * See register_namespaces(). */
30 typedef enum {
31 MESSAGE_NS_1,
32 MESSAGE_NS_UNSIGNED,
33 MESSAGE_NS_SIGNED_INCOMING,
34 MESSAGE_NS_SIGNED_OUTGOING,
35 MESSAGE_NS_SIGNED_DELIVERY
36 } message_ns_type;
38 /* Type of a context */
39 typedef enum {
40 CTX_TYPE_NONE = 0, /* Not configured for any connection yet */
41 CTX_TYPE_ISDS, /* Connection to ISDS */
42 CTX_TYPE_CZP, /* Connection to Czech POINT document deposit */
43 CTX_TYPE_TESTING_REQUEST_COLLECTOR /* Connection to server collectiong
44 new testing box requests */
45 } context_type;
47 /* Global variables.
48 * Allocated in isds_init() and deallocated in isds_cleanup(). */
49 unsigned int log_facilities;
50 isds_log_level log_level;
51 isds_log_callback log_callback; /* Pass global log message to application.
52 NULL to log to stderr itself */
53 void *log_callback_data; /* Application specific data to pass to
54 registered log_callback function */
55 const char *version_gpgme; /* Static string with GPGME version */
56 const char *version_gcrypt; /* Static string with gcrypt version */
57 const char *version_expat; /* Static string with expat version */
59 /* End of global variables */
61 /* Context */
62 struct isds_ctx {
63 context_type type; /* Context type */
64 unsigned int timeout; /* milliseconds */
65 char *url; /* URL of the ISDS web service */
66 char *username;
67 char *password;
68 struct isds_pki_credentials *pki_credentials;
69 CURL *curl; /* CURL session handle */
70 _Bool *tls_verify_server; /* Verify the server? */
71 isds_progress_callback progress_callback; /* Call it during
72 communication with server.
73 NULL for nothing */
74 void *progress_callback_data; /* Application provided argument
75 for progress_callback */
76 char *tls_ca_file; /* File name with CA certificates */
77 char *tls_ca_dir; /* Directory name with CA certificates */
78 char *tls_crl_file; /* File name with CRL in PEM format */
79 _Bool normalize_mime_type; /* Normalize document MIME types? */
80 char *long_message; /* message buffer */
83 /* Stores message into context' long_message buffer.
84 * Application can pick the message up using isds_long_message().
85 * NULL @message truncates the buffer but does not deallocate it.
86 * @message is coded in locale encoding */
87 isds_error isds_log_message(struct isds_ctx *context, const char *message);
89 /* Appends message into context' long_message buffer.
90 * Application can pick the message up using isds_long_message().
91 * NULL message has void effect. */
92 isds_error isds_append_message(struct isds_ctx *context, const char *message);
94 /* Stores formated message into context' long_message buffer.
95 * Application can pick the message up using isds_long_message(). */
96 isds_error isds_printf_message(struct isds_ctx *context,
97 const char *format, ...);
99 /* Log @message in class @facility with log @level into global log. @message
100 * is printf(3) formating string, variadic arguments may be neccessary.
101 * For debugging purposes. */
102 isds_error isds_log(const isds_log_facility facility,
103 const isds_log_level level, const char *message, ...);
105 /* Makes known all relevant namespaces to given XPath context
106 * @xpat_ctx is XPath context
107 * @message_ns selects propper message name space. Unsisnged and signed
108 * messages differs.
109 * prefix and to URI ISDS_NS */
110 isds_error register_namespaces(xmlXPathContextPtr xpath_ctx,
111 const message_ns_type message_ns);
113 #endif