5.0 from trustcommerce
[tclink.git] / tclink.h
1 /* tclink.h - Header file for TCLink library. */
2
3 #ifndef _TCLINK_H
4 #define _TCLINK_H
5
6 #include "config.h"
7
8 /* Handle passed to all TCLink functions. A unique handle must be created
9 * for each concurrent thread, but the same handle can be shared by transactions
10 * occurring one after another (such as a for loop).
11 */
12 #define TCLinkHandle void*
13
14 /* Parameter names and values cannot exceed this size.
15 */
16 #define PARAM_MAX_LEN 768
17
18 /* Create a new TCLinkHandle.
19 */
20 TCLinkHandle
21 TCLinkCreate();
22
23 /* Add a parameter to be sent to the server.
24 */
25 void
26 TCLinkPushParam(TCLinkHandle handle, const char* name, const char* value);
27
28 /* Flush the parameters to the server.
29 */
30 void
31 TCLinkSend(TCLinkHandle handle);
32
33 /* Look up a response value from the server.
34 * Returns NULL if no such parameter, or stores the value in 'value' and
35 * returns a pointer to value. value should be at least PARAM_MAX_LEN in size.
36 */
37 char*
38 TCLinkGetResponse(TCLinkHandle handle, const char* name, char* value);
39
40 /* Get all response values from the server in one giant string.
41 * Stores the string into buf and returns a pointer to it. Size should be
42 * sizeof(buf), which will limit the string so that no buffer overruns occur.
43 */
44 char*
45 TCLinkGetEntireResponse(TCLinkHandle handle, char* buf, int size);
46
47 /* Destory a handle, ending that transaction and freeing the memory associated
48 * with it. */
49 void
50 TCLinkDestroy(TCLinkHandle handle);
51
52 /* Store version string into buf. Returns a pointer to buf. */
53 char*
54 TCLinkGetVersion(char* buf);
55
56 /* The API methods below are subject to change. */
57
58 /* Enables (1) or Disables (0) the full SSL close_notify sequence. By default,
59 * this is set to 1.*/
60 int
61 TCLinkSetFullClose(TCLinkHandle handle, int full_ssl_close);
62
63 /* Provides a method, once the handshake is completed, a means to verify the
64 * contents of that certificate independently. Note that the certificate may not
65 * be set depending on the negotation type (in which case the pointer would be
66 * NULL)
67 */
68 void
69 TCLinkSetValidateCallback(TCLinkHandle handle,
70 int (*validate_cert)(int, void*));
71
72 #endif