Recognize ChangeISDSPassword errors defined on 2011-10-16
[libisds.git] / src / isds_priv.h
blobe7f1c8a928411d15304de9e7cf6c2dca538814b6
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 SISDS_INCOMING_NS "http://isds.czechpoint.cz/v20/message"
38 #define SISDS_OUTGOING_NS "http://isds.czechpoint.cz/v20/SentMessage"
39 #define SISDS_DELIVERY_NS "http://isds.czechpoint.cz/v20/delivery"
40 #define SCHEMA_NS "http://www.w3.org/2001/XMLSchema"
41 #define DEPOSIT_NS "urn:uschovnaWSDL"
44 /* Used to choose proper name space for message elements.
45 * See _isds_register_namespaces(). */
46 typedef enum {
47 MESSAGE_NS_1,
48 MESSAGE_NS_UNSIGNED,
49 MESSAGE_NS_SIGNED_INCOMING,
50 MESSAGE_NS_SIGNED_OUTGOING,
51 MESSAGE_NS_SIGNED_DELIVERY
52 } message_ns_type;
54 /* Type of a context */
55 typedef enum {
56 CTX_TYPE_NONE = 0, /* Not configured for any connection yet */
57 CTX_TYPE_ISDS, /* Connection to ISDS */
58 CTX_TYPE_CZP, /* Connection to Czech POINT document deposit */
59 CTX_TYPE_TESTING_REQUEST_COLLECTOR /* Connection to server collectiong
60 new testing box requests */
61 } context_type;
63 /* Global variables.
64 * Allocated in isds_init() and deallocated in isds_cleanup(). */
65 unsigned int log_facilities;
66 isds_log_level log_level;
67 isds_log_callback log_callback; /* Pass global log message to application.
68 NULL to log to stderr itself */
69 void *log_callback_data; /* Application specific data to pass to
70 registered log_callback function */
71 const char *version_gpgme; /* Static string with GPGME version */
72 const char *version_gcrypt; /* Static string with gcrypt version */
73 const char *version_expat; /* Static string with expat version */
75 /* End of global variables */
77 /* Context */
78 struct isds_ctx {
79 context_type type; /* Context type */
80 #if HAVE_LIBCURL
81 unsigned int timeout; /* milliseconds */
82 char *url; /* URL of the ISDS web service */
83 char *username;
84 char *password;
85 struct isds_pki_credentials *pki_credentials;
86 struct isds_otp *otp; /* Pointer (no copy) to OTP credentials */
87 CURL *curl; /* CURL session handle */
88 _Bool *tls_verify_server; /* Verify the server? */
89 isds_progress_callback progress_callback; /* Call it during
90 communication with server.
91 NULL for nothing */
92 void *progress_callback_data; /* Application provided argument
93 for progress_callback */
94 char *tls_ca_file; /* File name with CA certificates */
95 char *tls_ca_dir; /* Directory name with CA certificates */
96 char *tls_crl_file; /* File name with CRL in PEM format */
97 #endif /* HAVE_LIBCURL */
98 _Bool normalize_mime_type; /* Normalize document MIME types? */
99 char *long_message; /* message buffer */
102 /* Stores message into context' long_message buffer.
103 * Application can pick the message up using isds_long_message().
104 * NULL @message truncates the buffer but does not deallocate it.
105 * @message is coded in locale encoding */
106 isds_error isds_log_message(struct isds_ctx *context, const char *message);
108 /* Appends message into context' long_message buffer.
109 * Application can pick the message up using isds_long_message().
110 * NULL message has void effect. */
111 isds_error isds_append_message(struct isds_ctx *context, const char *message);
113 /* Stores formated message into context' long_message buffer.
114 * Application can pick the message up using isds_long_message(). */
115 isds_error isds_printf_message(struct isds_ctx *context,
116 const char *format, ...);
118 /* Log @message in class @facility with log @level into global log. @message
119 * is printf(3) formating string, variadic arguments may be neccessary.
120 * For debugging purposes. */
121 isds_error isds_log(const isds_log_facility facility,
122 const isds_log_level level, const char *message, ...);
124 /* Makes known all relevant namespaces to given XPath context
125 * @xpath_ctx is XPath context
126 * @message_ns selects propper message name space. Unsisnged and signed
127 * messages and delivery infos differ in prefix and URI. */
128 isds_error _isds_register_namespaces(xmlXPathContextPtr xpath_ctx,
129 const message_ns_type message_ns);
131 #if HAVE_LIBCURL
132 /* Discard credentials.
133 * Only that. It does not cause log out, connection close or similar. */
134 isds_error _isds_discard_credentials(struct isds_ctx *context);
135 #endif /* HAVE_LIBCURL */
137 #endif