test: Deallocate all memory in isds_DbUserInfo_duplicate tests
[libisds.git] / src / isds_priv.h
blob97ade761f39f9a2693f476be1290a13bf364b2fd
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 unsigned int log_facilities;
67 isds_log_level log_level;
68 isds_log_callback log_callback; /* Pass global log message to application.
69 NULL to log to stderr itself */
70 void *log_callback_data; /* Application specific data to pass to
71 registered log_callback function */
72 const char *version_gpgme; /* Static string with GPGME version */
73 const char *version_gcrypt; /* Static string with gcrypt version */
74 const char *version_expat; /* Static string with expat version */
76 /* End of global variables */
78 /* Context */
79 struct isds_ctx {
80 context_type type; /* Context type */
81 #if HAVE_LIBCURL
82 unsigned int timeout; /* milliseconds */
83 char *url; /* URL of the ISDS web service */
84 char *username;
85 char *password;
86 struct isds_pki_credentials *pki_credentials;
87 _Bool otp; /* This is OTP-authenticated context */
88 struct isds_otp *otp_credentials; /* Weak pointer to OTP credentials */
89 char *saved_username; /* User name preserved after OTP log-in for OTP
90 password change */
91 CURL *curl; /* CURL session handle */
92 _Bool *tls_verify_server; /* Verify the server? */
93 isds_progress_callback progress_callback; /* Call it during
94 communication with server.
95 NULL for nothing */
96 void *progress_callback_data; /* Application provided argument
97 for progress_callback */
98 char *tls_ca_file; /* File name with CA certificates */
99 char *tls_ca_dir; /* Directory name with CA certificates */
100 char *tls_crl_file; /* File name with CRL in PEM format */
101 #endif /* HAVE_LIBCURL */
102 _Bool normalize_mime_type; /* Normalize document MIME types? */
103 char *long_message; /* message buffer */
106 /* Stores message into context' long_message buffer.
107 * Application can pick the message up using isds_long_message().
108 * NULL @message truncates the buffer but does not deallocate it.
109 * @message is coded in locale encoding */
110 isds_error isds_log_message(struct isds_ctx *context, const char *message);
112 /* Appends message into context' long_message buffer.
113 * Application can pick the message up using isds_long_message().
114 * NULL message has void effect. */
115 isds_error isds_append_message(struct isds_ctx *context, const char *message);
117 /* Stores formated message into context' long_message buffer.
118 * Application can pick the message up using isds_long_message(). */
119 isds_error isds_printf_message(struct isds_ctx *context,
120 const char *format, ...);
122 /* Log @message in class @facility with log @level into global log. @message
123 * is printf(3) formating string, variadic arguments may be neccessary.
124 * For debugging purposes. */
125 isds_error isds_log(const isds_log_facility facility,
126 const isds_log_level level, const char *message, ...);
128 /* Makes known all relevant namespaces to given XPath context
129 * @xpath_ctx is XPath context
130 * @message_ns selects propper message name space. Unsisnged and signed
131 * messages and delivery infos differ in prefix and URI. */
132 isds_error _isds_register_namespaces(xmlXPathContextPtr xpath_ctx,
133 const message_ns_type message_ns);
135 #if HAVE_LIBCURL
136 /* Discard credentials.
137 * @context is ISDS context
138 * @discard_saved_username is true for removing saved username, false for
139 * keeping it.
140 * Only that. It does not cause log out, connection close or similar. */
141 isds_error _isds_discard_credentials(struct isds_ctx *context,
142 _Bool discard_saved_username);
143 #endif /* HAVE_LIBCURL */
145 #endif