tests: Fix headers inclusion
[libisds.git] / src / isds_priv.h
blob29821cc70716536266be861a4e814c29a3f9497a
1 #ifndef __ISDS_ISDS_PRIV_H__
2 #define __ISDS_ISDS_PRIV_H__
4 /* Feature macros to enable some declarations. This is kept here to align all
5 * header files to one shape. */
6 #ifndef _XOPEN_SOURCE
7 /* >= 500: strdup(3) from string.h, strptime(3) from time.h */
8 /* >= 600: setenv(3) */
9 /* >= 700: strndup(3) from string.h */
10 #define _XOPEN_SOURCE 700
11 #endif
13 #ifndef _POSIX_SOURCE
14 /* defined: strtok_r */
15 #define _POSIX_SOURCE
16 #endif
18 /* Structures not to export outside library */
19 #include "../config.h"
20 #include "isds.h"
21 #if HAVE_LIBCURL
22 #include <curl/curl.h>
23 #endif
24 #include <libxml/parser.h>
25 #include <libxml/xpath.h>
26 #include <libxml/xpathInternals.h>
27 #include <libxml/xmlsave.h>
28 #include "gettext.h"
30 #define _(x) ((const char *) dgettext(PACKAGE, (x)))
31 #define N_(x) (x)
33 #define SOAP_NS "http://schemas.xmlsoap.org/soap/envelope/"
34 #define SOAP2_NS "http://www.w3.org/2003/05/soap-envelope"
35 #define ISDS1_NS "http://isds.czechpoint.cz"
36 #define ISDS_NS "http://isds.czechpoint.cz/v20"
37 #define OISDS_NS "http://isds.czechpoint.cz/v20/asws"
38 #define SISDS_INCOMING_NS "http://isds.czechpoint.cz/v20/message"
39 #define SISDS_OUTGOING_NS "http://isds.czechpoint.cz/v20/SentMessage"
40 #define SISDS_DELIVERY_NS "http://isds.czechpoint.cz/v20/delivery"
41 #define SCHEMA_NS "http://www.w3.org/2001/XMLSchema"
42 #define DEPOSIT_NS "urn:uschovnaWSDL"
45 /* Used to choose proper name space for message elements.
46 * See _isds_register_namespaces(). */
47 typedef enum {
48 MESSAGE_NS_1,
49 MESSAGE_NS_UNSIGNED,
50 MESSAGE_NS_SIGNED_INCOMING,
51 MESSAGE_NS_SIGNED_OUTGOING,
52 MESSAGE_NS_SIGNED_DELIVERY
53 } message_ns_type;
55 /* Type of a context */
56 typedef enum {
57 CTX_TYPE_NONE = 0, /* Not configured for any connection yet */
58 CTX_TYPE_ISDS, /* Connection to ISDS */
59 CTX_TYPE_CZP, /* Connection to Czech POINT document deposit */
60 CTX_TYPE_TESTING_REQUEST_COLLECTOR /* Connection to server collectiong
61 new testing box requests */
62 } context_type;
64 /* Global variables.
65 * Allocated in isds_init() and deallocated in isds_cleanup(). */
66 extern unsigned int log_facilities;
67 extern isds_log_level log_level;
68 extern isds_log_callback log_callback; /* Pass global log message to
69 application. NULL to log to stderr
70 itself */
71 extern void *log_callback_data; /* Application specific data to pass to
72 registered log_callback function */
73 extern const char *version_gpgme; /* Static string with GPGME version */
74 extern const char *version_gcrypt; /* Static string with gcrypt version */
75 extern const char *version_openssl; /* Static string with OpenSSL version */
76 extern const char *version_expat; /* Static string with expat version */
77 /* End of global variables */
79 /* Context */
80 struct isds_ctx {
81 context_type type; /* Context type */
82 #if HAVE_LIBCURL
83 unsigned int timeout; /* milliseconds */
84 char *url; /* URL of the ISDS web service */
85 char *username;
86 char *password;
87 struct isds_pki_credentials *pki_credentials;
88 _Bool otp; /* This is OTP-authenticated context */
89 struct isds_otp *otp_credentials; /* Weak pointer to OTP credentials */
90 _Bool mep; /* This is mobile-key-authenticated context. */
91 struct isds_mep *mep_credentials; /* Weak pointer to mobile key credentials. */
92 char *saved_username; /* User name preserved after OTP log-in for OTP
93 password change */
94 CURL *curl; /* CURL session handle */
95 _Bool *tls_verify_server; /* Verify the server? */
96 isds_progress_callback progress_callback; /* Call it during
97 communication with server.
98 NULL for nothing */
99 void *progress_callback_data; /* Application provided argument
100 for progress_callback */
101 char *tls_ca_file; /* File name with CA certificates */
102 char *tls_ca_dir; /* Directory name with CA certificates */
103 char *tls_crl_file; /* File name with CRL in PEM format */
104 #endif /* HAVE_LIBCURL */
105 _Bool normalize_mime_type; /* Normalize document MIME types? */
106 char *long_message; /* message buffer */
109 /* Stores message into context' long_message buffer.
110 * Application can pick the message up using isds_long_message().
111 * NULL @message truncates the buffer but does not deallocate it.
112 * @message is coded in locale encoding */
113 isds_error isds_log_message(struct isds_ctx *context, const char *message);
115 /* Appends message into context' long_message buffer.
116 * Application can pick the message up using isds_long_message().
117 * NULL message has void effect. */
118 isds_error isds_append_message(struct isds_ctx *context, const char *message);
120 /* Stores formated message into context' long_message buffer.
121 * Application can pick the message up using isds_long_message(). */
122 isds_error isds_printf_message(struct isds_ctx *context,
123 const char *format, ...);
125 /* Log @message in class @facility with log @level into global log. @message
126 * is printf(3) formating string, variadic arguments may be neccessary.
127 * For debugging purposes. */
128 isds_error isds_log(const isds_log_facility facility,
129 const isds_log_level level, const char *message, ...);
131 /* Makes known all relevant namespaces to given XPath context
132 * @xpath_ctx is XPath context
133 * @message_ns selects propper message name space. Unsisnged and signed
134 * messages and delivery infos differ in prefix and URI. */
135 isds_error _isds_register_namespaces(xmlXPathContextPtr xpath_ctx,
136 const message_ns_type message_ns);
138 #if HAVE_LIBCURL
139 /* Discard credentials.
140 * @context is ISDS context
141 * @discard_saved_username is true for removing saved username, false for
142 * keeping it.
143 * Only that. It does not cause log out, connection close or similar. */
144 isds_error _isds_discard_credentials(struct isds_ctx *context,
145 _Bool discard_saved_username);
146 #endif /* HAVE_LIBCURL */
148 #endif