summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8508799)
Implemented function cs_create_host parses a YAZ host component. This
is to be used for HTTP Connect tunneling (bug #1752).
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $Id: comstack.h,v 1.27 2007-04-12 13:52:57 adam Exp $ */
+/* $Id: comstack.h,v 1.28 2007-10-05 16:46:55 adam Exp $ */
YAZ_EXPORT int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len);
YAZ_EXPORT void cs_set_max_recv_bytes(COMSTACK cs, int max_recv_bytes);
YAZ_EXPORT int cs_complete_http(const char *buf, int len);
YAZ_EXPORT int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len);
YAZ_EXPORT void cs_set_max_recv_bytes(COMSTACK cs, int max_recv_bytes);
YAZ_EXPORT int cs_complete_http(const char *buf, int len);
+YAZ_EXPORT int cs_parse_host(const char *uri, const char **host,
+ CS_TYPE *t, enum oid_proto *proto);
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: comstack.c,v 1.18 2007-01-11 10:30:41 adam Exp $
+ * $Id: comstack.c,v 1.19 2007-10-05 16:46:55 adam Exp $
-COMSTACK cs_create_host(const char *type_and_host, int blocking, void **vp)
+int cs_parse_host(const char *uri, const char **host,
+ CS_TYPE *t, enum oid_proto *proto)
- enum oid_proto proto = PROTO_Z3950;
- const char *host = 0;
- COMSTACK cs;
- CS_TYPE t;
-
- if (strncmp (type_and_host, "tcp:", 4) == 0)
+ if (strncmp (uri, "tcp:", 4) == 0)
- t = tcpip_type;
- host = type_and_host + 4;
+ *t = tcpip_type;
+ *host = uri + 4;
+ *proto = PROTO_Z3950;
- else if (strncmp (type_and_host, "ssl:", 4) == 0)
+ else if (strncmp (uri, "ssl:", 4) == 0)
- t = ssl_type;
- host = type_and_host + 4;
+ *t = ssl_type;
+ *host = uri + 4;
+ *proto = PROTO_Z3950;
- else if (strncmp (type_and_host, "unix:", 5) == 0)
+ else if (strncmp (uri, "unix:", 5) == 0)
- t = unix_type;
- host = type_and_host + 5;
+ *t = unix_type;
+ *host = uri + 5;
+ *proto = PROTO_Z3950;
- else if (strncmp(type_and_host, "http:", 5) == 0)
+ else if (strncmp(uri, "http:", 5) == 0)
- t = tcpip_type;
- host = type_and_host + 5;
- while (host[0] == '/')
- host++;
- proto = PROTO_HTTP;
+ *t = tcpip_type;
+ *host = uri + 5;
+ while (**host == '/')
+ (*host)++;
+ *proto = PROTO_HTTP;
- else if (strncmp(type_and_host, "https:", 6) == 0)
+ else if (strncmp(uri, "https:", 6) == 0)
- t = ssl_type;
- host = type_and_host + 6;
- while (host[0] == '/')
- host++;
- proto = PROTO_HTTP;
+ *t = ssl_type;
+ *host = uri + 6;
+ while (**host == '/')
+ (*host)++;
+ *proto = PROTO_HTTP;
#else
return 0;
#endif
}
else
{
#else
return 0;
#endif
}
else
{
- t = tcpip_type;
- host = type_and_host;
+ *proto = PROTO_Z3950;
+ *t = tcpip_type;
+ *host = uri;
- cs = cs_create (t, blocking, proto);
+ return 1;
+}
+
+COMSTACK cs_create_host(const char *vhost, int blocking, void **vp)
+{
+ enum oid_proto proto = PROTO_Z3950;
+ const char *host = 0;
+ COMSTACK cs;
+ CS_TYPE t;
+
+ cs_parse_host(vhost, &host, &t, &proto);
+
+ cs = cs_create(t, blocking, proto);