summaryrefslogtreecommitdiffstats
path: root/nanohttp
diff options
context:
space:
mode:
authorGravatar m0gg2006-11-28 23:45:57 +0000
committerGravatar m0gg2006-11-28 23:45:57 +0000
commit9a0670ad01e00ab01cfb4f308f1b124941968fa2 (patch)
tree616729b1bcd2c837eee563e904faac091f5cb813 /nanohttp
parent17d9b98c8525c74cd83a421f151062825fe66890 (diff)
downloadcsoap-9a0670ad01e00ab01cfb4f308f1b124941968fa2.tar.gz
csoap-9a0670ad01e00ab01cfb4f308f1b124941968fa2.tar.bz2
XML signature improvements
Diffstat (limited to 'nanohttp')
-rw-r--r--nanohttp/nanohttp-base64.c25
-rw-r--r--nanohttp/nanohttp-base64.h35
-rw-r--r--nanohttp/nanohttp-client.c4
-rwxr-xr-xnanohttp/nanohttp-mime.h14
-rw-r--r--nanohttp/nanohttp-server.c4
-rw-r--r--nanohttp/nanohttp-server.h4
6 files changed, 63 insertions, 23 deletions
diff --git a/nanohttp/nanohttp-base64.c b/nanohttp/nanohttp-base64.c
index 8abee35..0e887d6 100644
--- a/nanohttp/nanohttp-base64.c
+++ b/nanohttp/nanohttp-base64.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-base64.c,v 1.2 2006/02/25 10:09:29 snowdrop Exp $
+* $Id: nanohttp-base64.c,v 1.3 2006/11/28 23:45:57 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -32,9 +32,11 @@ static const char cb64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
static const char cd64[] = "|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
/**
+ *
* encode 3 8-bit binary bytes as 4 '6-bit' characters
+ *
*/
-static void encodeblock(unsigned char in[3], unsigned char out[4], int len)
+static void _encodeblock(unsigned char in[3], unsigned char out[4], int len)
{
out[0] = cb64[in[0] >> 2];
@@ -45,10 +47,7 @@ static void encodeblock(unsigned char in[3], unsigned char out[4], int len)
return;
}
-/**
- * base64 encode a string.
- */
-void base64_encode(const unsigned char *instr, unsigned char *outstr)
+void base64_encode_string(const unsigned char *instr, unsigned char *outstr)
{
unsigned char in[3], out[4];
int i, len;
@@ -66,7 +65,7 @@ void base64_encode(const unsigned char *instr, unsigned char *outstr)
}
if (len)
{
- encodeblock(in, out, len);
+ _encodeblock(in, out, len);
for (i = 0; i < 4; i++)
*outstr++ = out[i];
}
@@ -74,9 +73,11 @@ void base64_encode(const unsigned char *instr, unsigned char *outstr)
}
/**
+ *
* decode 4 '6-bit' characters into 3 8-bit binary bytes
+ *
*/
-static void decodeblock(unsigned char in[4], unsigned char out[3])
+static void _decodeblock(unsigned char in[4], unsigned char out[3])
{
out[0] = (unsigned char)(in[0] << 2 | in[1] >> 4);
out[1] = (unsigned char)(in[1] << 4 | in[2] >> 2);
@@ -88,7 +89,7 @@ static void decodeblock(unsigned char in[4], unsigned char out[3])
/**
* decode a base64 encoded string (maybe broken...)
*/
-void base64_decode(const unsigned char *instr, unsigned char *outstr)
+void base64_decode_string(const unsigned char *instr, unsigned char *outstr)
{
unsigned char in[4], out[3], v;
int i, len;
@@ -118,7 +119,7 @@ void base64_decode(const unsigned char *instr, unsigned char *outstr)
}
if (len)
{
- decodeblock(in, out);
+ _decodeblock(in, out);
for (i = 0; i < len - 1; i++)
*outstr++ = out[i];
}
@@ -135,7 +136,7 @@ int main(int argc, char **argv) {
unsigned char outstr[80];
bzero(outstr, 80);
- base64_decode(instr, outstr);
+ base64_decode_string(instr, outstr);
printf("\"%s\" => \"%s\"\n", instr, outstr);
if (strcmp(outstr, result))
@@ -144,7 +145,7 @@ int main(int argc, char **argv) {
strcpy(instr2, outstr);
bzero(outstr, 80);
- base64_encode(instr2, outstr);
+ base64_encode_string(instr2, outstr);
printf("\"%s\" => \"%s\"\n", instr2, outstr);
if (strcmp(outstr, instr))
diff --git a/nanohttp/nanohttp-base64.h b/nanohttp/nanohttp-base64.h
index 69f5dfa..6556acf 100644
--- a/nanohttp/nanohttp-base64.h
+++ b/nanohttp/nanohttp-base64.h
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-base64.h,v 1.2 2006/05/02 09:12:50 m0gg Exp $
+* $Id: nanohttp-base64.h,v 1.3 2006/11/28 23:45:57 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -24,6 +24,31 @@
#ifndef __nanohttp_base64_h
#define __nanohttp_base64_h
+/** @file
+ *
+ * Base64 data encoding
+ *
+ * Base encoding of data is used in many situations to store or transfer data in
+ * environments that, perhaps for legacy reasons, are restricted to US-ASCII
+ * data. Base64 encoding can also be used in new applications that do not have
+ * legacy restrictions, simply because it makes it possible to manipulate objects
+ * with text editors.
+ *
+ * In the past, different applications have had different requirements and thus
+ * sometimes implemented base encodings in slightly different ways. Today,
+ * protocol specifications sometimes use base encodings in general, and "base64"
+ * in particular, without a precise description or reference. Multipurpose
+ * Internet Mail Extensions (MIME) is often used as a reference for base64
+ * without considering the consequences for line-wrapping or non-alphabet
+ * characters.
+ *
+ * @author H. Ronsdorf
+ * @version $Revision: 1.3 $
+ *
+ * @see http://www.ietf.org/rfc/rfc4648.txt
+ *
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -35,10 +60,10 @@ extern "C" {
* @param instr Pointer to the input string.
* @param outstr Pointer to the output destination.
*
- * @see base64_decode
+ * @see base64_decode_string
*
*/
-extern void base64_encode(const unsigned char *instr, unsigned char *outstr);
+extern void base64_encode_string(const unsigned char *instr, unsigned char *outstr);
/**
*
@@ -47,10 +72,10 @@ extern void base64_encode(const unsigned char *instr, unsigned char *outstr);
* @param instr Pointer to the input string.
* @param outstr Pointer to the output destination.
*
- * @see base64_encode
+ * @see base64_encode_string
*
*/
-extern void base64_decode(const unsigned char *instr, unsigned char *outstr);
+extern void base64_decode_string(const unsigned char *instr, unsigned char *outstr);
#ifdef __cplusplus
}
diff --git a/nanohttp/nanohttp-client.c b/nanohttp/nanohttp-client.c
index d9bf113..2392d81 100644
--- a/nanohttp/nanohttp-client.c
+++ b/nanohttp/nanohttp-client.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-client.c,v 1.46 2006/11/25 15:06:58 m0gg Exp $
+* $Id: nanohttp-client.c,v 1.47 2006/11/28 23:45:57 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -261,7 +261,7 @@ _httpc_set_basic_authorization_header(httpc_conn_t *conn, const char *key, const
sprintf(in, "%s:%s", user, password);
- base64_encode(in, out);
+ base64_encode_string(in, out);
sprintf(in, "Basic %s", out);
diff --git a/nanohttp/nanohttp-mime.h b/nanohttp/nanohttp-mime.h
index d6ce17d..894f6ce 100755
--- a/nanohttp/nanohttp-mime.h
+++ b/nanohttp/nanohttp-mime.h
@@ -3,7 +3,7 @@
* | \/ | | | | \/ | | _/
* |_''_| |_| |_''_| |_'/ PARSER
*
-* $Id: nanohttp-mime.h,v 1.11 2006/11/25 15:06:58 m0gg Exp $
+* $Id: nanohttp-mime.h,v 1.12 2006/11/28 23:45:57 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -29,6 +29,18 @@
#ifndef __nanohttp_mime_h
#define __nanohttp_mime_h
+/** @file
+ *
+ * @author Ferhat Ayaz
+ * @version $Revision: 1.12 $
+ *
+ * @see http://www.ietf.org/rfc/rfc2045.txt,
+ * http://www.ietf.org/rfc/rfc2046.txt,
+ * http://www.ietf.org/rfc/rfc4288.txt,
+ * http://www.ietf.org/rfc/rfc4289.txt,
+ *
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c
index 8c16e5f..4c31421 100644
--- a/nanohttp/nanohttp-server.c
+++ b/nanohttp/nanohttp-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-server.c,v 1.70 2006/11/27 12:47:27 m0gg Exp $
+* $Id: nanohttp-server.c,v 1.71 2006/11/28 23:45:57 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -558,7 +558,7 @@ _httpd_decode_authorization(const char *value, char **user, char **pass)
log_verbose2("Authorization (base64) = \"%s\"", value);
- base64_decode(value, tmp);
+ base64_decode_string(value, tmp);
log_verbose2("Authorization (ascii) = \"%s\"", tmp);
diff --git a/nanohttp/nanohttp-server.h b/nanohttp/nanohttp-server.h
index be48005..e85c64a 100644
--- a/nanohttp/nanohttp-server.h
+++ b/nanohttp/nanohttp-server.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-server.h,v 1.24 2006/11/23 15:27:33 m0gg Exp $
+ * $Id: nanohttp-server.h,v 1.25 2006/11/28 23:45:57 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -118,6 +118,8 @@ extern "C"
extern hservice_t *httpd_get_services(void);
extern hservice_t *httpd_find_service(const char *name);
+ extern void httpd_response_set_content_type(httpd_conn_t * res, const char *content_type);
+
extern herror_t httpd_send_header(httpd_conn_t * res, int code, const char *text);
extern int httpd_set_header(httpd_conn_t * conn, const char *key, const char *value);