summaryrefslogtreecommitdiffstats
path: root/nanohttp/nanohttp-url.h
diff options
context:
space:
mode:
authorGravatar m0gg2006-12-08 21:21:41 +0000
committerGravatar m0gg2006-12-08 21:21:41 +0000
commit46ec9aea1caadcec41ff5637c0bb2b906a2a2041 (patch)
treecd8b09aa8de70dd1b57d3df935e31540bba1b88d /nanohttp/nanohttp-url.h
parent327f375e02d4282f973d0fb96e82b99858b32719 (diff)
downloadcsoap-46ec9aea1caadcec41ff5637c0bb2b906a2a2041.tar.gz
csoap-46ec9aea1caadcec41ff5637c0bb2b906a2a2041.tar.bz2
hurl_t moved to nanohttp-url.[ch]
Diffstat (limited to 'nanohttp/nanohttp-url.h')
-rw-r--r--nanohttp/nanohttp-url.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/nanohttp/nanohttp-url.h b/nanohttp/nanohttp-url.h
new file mode 100644
index 0000000..ad35c90
--- /dev/null
+++ b/nanohttp/nanohttp-url.h
@@ -0,0 +1,120 @@
+/******************************************************************
+ * $Id: nanohttp-url.h,v 1.1 2006/12/08 21:21:41 m0gg Exp $
+ *
+ * CSOAP Project: A http client/server library in C
+ * Copyright (C) 2003-2004 Ferhat Ayaz
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Email: ferhatayaz@yahoo.com
+ ******************************************************************/
+#ifndef __nanohttp_url_h
+#define __nanohttp_url_h
+
+/**
+ *
+ * The protocol types in enumeration format. Used in some other nanohttp objects
+ * like hurl_t.
+ *
+ * @see hurl_t
+ *
+ */
+typedef enum _hprotocol
+{
+ PROTOCOL_HTTP,
+ PROTOCOL_HTTPS,
+ PROTOCOL_FTP
+} hprotocol_t;
+
+#define URL_MAX_HOST_SIZE 120
+#define URL_MAX_CONTEXT_SIZE 1024
+
+/**
+ *
+ * The URL object. A representation of an URL like:
+ *
+ * [protocol]://[host]:[port]/[context]
+ *
+ * @see http://www.ietf.org/rfc/rfc2396.txt
+ *
+ */
+struct hurl_t
+{
+ /**
+ *
+ * The transfer protocol. Note that only PROTOCOL_HTTP and PROTOCOL_HTTPS are
+ * supported by nanohttp.
+ *
+ */
+ hprotocol_t protocol;
+
+ /**
+ *
+ * The port number. If no port number was given in the URL, one of the default
+ * port numbers will be selected.
+ * - URL_HTTP_DEFAULT_PORT
+ * - URL_HTTPS_DEFAULT_PORT
+ * - URL_FTP_DEFAULT_PORT
+ *
+ */
+ short port;
+
+ /**
+ *
+ * The hostname
+ *
+ */
+ char host[URL_MAX_HOST_SIZE];
+
+ /**
+ *
+ * The string after the hostname.
+ *
+ */
+ char context[URL_MAX_CONTEXT_SIZE];
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ *
+ * Parses the given 'urlstr' and fills the given hurl_t object.
+ *
+ * @param obj the destination URL object to fill
+ * @param url the URL in string format
+ *
+ * @returns H_OK on success or one of the following otherwise
+ * - URL_ERROR_UNKNOWN_PROTOCOL
+ * - URL_ERROR_NO_PROTOCOL
+ * - URL_ERROR_NO_HOST
+ *
+ */
+extern herror_t hurl_parse(struct hurl_t * obj, const char *url);
+
+/**
+ *
+ * Frees the resources within a url and the url itself.
+ *
+ */
+extern void hurl_free(struct hurl_t *url);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif