summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-09-10 23:16:00 +0000
committerGuy Harris <guy@alum.mit.edu>2004-09-10 23:16:00 +0000
commitfe3b7d73edd4e41389f9b3ff3cd9d07892ae3e56 (patch)
treed5da1055f781a8a7c6c54eaaeb30a476867caa4a
parentd121dc07f1601c58994bdd4acd6ee33ef845e0e8 (diff)
downloadwireshark-fe3b7d73edd4e41389f9b3ff3cd9d07892ae3e56.tar.gz
Move the base-64 routines to "epan/base64.c".
svn path=/trunk/; revision=11960
-rw-r--r--epan/Makefile.common2
-rw-r--r--epan/base64.c62
-rw-r--r--epan/base64.h38
-rw-r--r--epan/dissectors/packet-http.c2
-rw-r--r--util.c33
-rw-r--r--util.h2
6 files changed, 103 insertions, 36 deletions
diff --git a/epan/Makefile.common b/epan/Makefile.common
index dc4a4d0fb5..e25f5ac79c 100644
--- a/epan/Makefile.common
+++ b/epan/Makefile.common
@@ -27,6 +27,7 @@ LIBETHEREAL_SRC = \
addr_and_mask.c \
addr_resolv.c \
atalk-utils.c \
+ base64.c \
bitswap.c \
charsets.c \
circuit.c \
@@ -54,6 +55,7 @@ LIBETHEREAL_INCLUDES = \
addr_resolv.h \
address.h \
atalk-utils.h \
+ base64.h \
bitswap.h \
charsets.h \
circuit.h \
diff --git a/epan/base64.c b/epan/base64.c
new file mode 100644
index 0000000000..48456e3728
--- /dev/null
+++ b/epan/base64.c
@@ -0,0 +1,62 @@
+/* base64.c
+ * Base-64 conversion
+ *
+ * $Id$
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <string.h>
+
+/* Decode a base64 string in-place - simple and slow algorithm.
+ Return length of result. Taken from rproxy/librsync/base64.c by
+ Andrew Tridgell. */
+
+size_t epan_base64_decode(char *s)
+{
+ static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ int bit_offset, byte_offset, idx, i, n;
+ unsigned char *d = (unsigned char *)s;
+ char *p;
+
+ n=i=0;
+
+ while (*s && (p=strchr(b64, *s))) {
+ idx = (int)(p - b64);
+ byte_offset = (i*6)/8;
+ bit_offset = (i*6)%8;
+ d[byte_offset] &= ~((1<<(8-bit_offset))-1);
+ if (bit_offset < 3) {
+ d[byte_offset] |= (idx << (2-bit_offset));
+ n = byte_offset+1;
+ } else {
+ d[byte_offset] |= (idx >> (bit_offset-2));
+ d[byte_offset+1] = 0;
+ d[byte_offset+1] |= (idx << (8-(bit_offset-2))) & 0xFF;
+ n = byte_offset+2;
+ }
+ s++; i++;
+ }
+
+ return n;
+}
diff --git a/epan/base64.h b/epan/base64.h
new file mode 100644
index 0000000000..7ce9b6f8fb
--- /dev/null
+++ b/epan/base64.h
@@ -0,0 +1,38 @@
+/* base64.h
+ * Base-64 conversion
+ *
+ * $Id$
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#ifndef __BASE64_H__
+#define __BASE64_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* In-place decoding of a base64 string. */
+size_t epan_base64_decode(char *s);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __BASE64_H__ */
diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c
index 3da262534f..996edf0476 100644
--- a/epan/dissectors/packet-http.c
+++ b/epan/dissectors/packet-http.c
@@ -40,8 +40,8 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/strutil.h>
+#include <epan/base64.h>
-#include "util.h"
#include "req_resp_hdrs.h"
#include "packet-http.h"
#include "prefs.h"
diff --git a/util.c b/util.c
index 25766b2ae0..79dcf81e80 100644
--- a/util.c
+++ b/util.c
@@ -254,39 +254,6 @@ compute_timestamp_diff(gint *diffsec, gint *diffusec,
}
}
-/* Decode a base64 string in-place - simple and slow algorithm.
- Return length of result. Taken from rproxy/librsync/base64.c by
- Andrew Tridgell. */
-
-size_t epan_base64_decode(char *s)
-{
- static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- int bit_offset, byte_offset, idx, i, n;
- unsigned char *d = (unsigned char *)s;
- char *p;
-
- n=i=0;
-
- while (*s && (p=strchr(b64, *s))) {
- idx = (int)(p - b64);
- byte_offset = (i*6)/8;
- bit_offset = (i*6)%8;
- d[byte_offset] &= ~((1<<(8-bit_offset))-1);
- if (bit_offset < 3) {
- d[byte_offset] |= (idx << (2-bit_offset));
- n = byte_offset+1;
- } else {
- d[byte_offset] |= (idx >> (bit_offset-2));
- d[byte_offset+1] = 0;
- d[byte_offset+1] |= (idx << (8-(bit_offset-2))) & 0xFF;
- n = byte_offset+2;
- }
- s++; i++;
- }
-
- return n;
-}
-
/* Try to figure out if we're remotely connected, e.g. via ssh or
Terminal Server, and create a capture filter that matches aspects of the
connection. We match the following environment variables:
diff --git a/util.h b/util.h
index f4ed9dc2cb..1863474b87 100644
--- a/util.h
+++ b/util.h
@@ -39,8 +39,6 @@ char *get_args_as_string(int argc, char **argv, int optind);
/* Compute the difference between two seconds/microseconds time stamps. */
void compute_timestamp_diff(gint *, gint *, guint32, guint32, guint32, guint32);
-/* In-place decoding of a base64 string. */
-size_t epan_base64_decode(char *s);
/* Create a capture filter for the connection */
char *get_conn_cfilter(void);