83862ef462a969c69259d6255e6806094c65f1cc
[tclink.git] / tclink.h
1 /* tclink.h - Header file for TCLink library.
2 *
3 * TCLink Copyright (c) 2013 TrustCommerce.
4 * http://www.trustcommerce.com
5 * techsupport@trustcommerce.com
6 * (949) 387-3747
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #ifndef _TCLINK_H
24 #define _TCLINK_H
25
26 #include "config.h"
27
28 /* Handle passed to all TCLink functions. A unique handle must be created
29 * for each concurrent thread, but the same handle can be shared by transactions
30 * occurring one after another (such as a for loop).
31 */
32 #define TCLinkHandle void *
33
34 /* Parameter names and values cannot exceed this size.
35 */
36 #define PARAM_MAX_LEN 256
37
38 /* Create a new TCLinkHandle.
39 */
40 TCLinkHandle TCLinkCreate();
41
42 /* Add a parameter to be sent to the server.
43 */
44 void TCLinkPushParam(TCLinkHandle handle, const char *name, const char *value);
45
46 /* Flush the parameters to the server.
47 */
48 void TCLinkSend(TCLinkHandle handle);
49
50 /* Look up a response value from the server.
51 * Returns NULL if no such parameter, or stores the value in 'value' and
52 * returns a pointer to value. value should be at least PARAM_MAX_LEN in size.
53 */
54 char *TCLinkGetResponse(TCLinkHandle handle, const char *name, char *value);
55
56 /* Get all response values from the server in one giant string.
57 * Stores the string into buf and returns a pointer to it. Size should be
58 * sizeof(buf), which will limit the string so that no buffer overruns occur.
59 */
60 char *TCLinkGetEntireResponse(TCLinkHandle handle, char *buf, int size);
61
62 /* Destory a handle, ending that transaction and freeing the memory associated with it. */
63 void TCLinkDestroy(TCLinkHandle handle);
64
65 /* Store version string into buf. Returns a pointer to buf. */
66 char *TCLinkGetVersion(char *buf);
67
68
69 /* The API methods below are subject to change. */
70
71 /* Enables (1) or Disables (0) the full SSL close_notify sequence. By default, this is set to 1.*/
72 int TCLinkSetFullClose(TCLinkHandle handle, int full_ssl_close);
73
74 /* Provides a method, before the first send call is initiated, of loading a set of trusted CA certificates (PEM format). */
75 void TCLinkSetTrustedCABundle(TCLinkHandle handle, const char *str, int len);
76
77 /* Provides a method, once the handshake is completed, a means to verify the contents of that certificate independently.
78 * Note that the certificate may not be set depending on the negotation type (in which case the pointer would be NULL)
79 */
80 void TCLinkSetValidateCallback(TCLinkHandle handle, int (*validate_cert)(int, void *));
81
82 #endif
83