83862ef462a969c69259d6255e6806094c65f1cc
1 /* tclink.h - Header file for TCLink library.
3 * TCLink Copyright (c) 2013 TrustCommerce.
4 * http://www.trustcommerce.com
5 * techsupport@trustcommerce.com
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.
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.
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
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).
32 #define TCLinkHandle void *
34 /* Parameter names and values cannot exceed this size.
36 #define PARAM_MAX_LEN 256
38 /* Create a new TCLinkHandle.
40 TCLinkHandle
TCLinkCreate();
42 /* Add a parameter to be sent to the server.
44 void TCLinkPushParam(TCLinkHandle handle
, const char *name
, const char *value
);
46 /* Flush the parameters to the server.
48 void TCLinkSend(TCLinkHandle handle
);
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.
54 char *TCLinkGetResponse(TCLinkHandle handle
, const char *name
, char *value
);
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.
60 char *TCLinkGetEntireResponse(TCLinkHandle handle
, char *buf
, int size
);
62 /* Destory a handle, ending that transaction and freeing the memory associated with it. */
63 void TCLinkDestroy(TCLinkHandle handle
);
65 /* Store version string into buf. Returns a pointer to buf. */
66 char *TCLinkGetVersion(char *buf
);
69 /* The API methods below are subject to change. */
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
);
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
);
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)
80 void TCLinkSetValidateCallback(TCLinkHandle handle
, int (*validate_cert
)(int, void *));