Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FreeRDP/FreeRDP-old.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Moreau <marcandre.moreau@gmail.com>2011-06-29 01:20:14 +0400
committerMarc-André Moreau <marcandre.moreau@gmail.com>2011-06-29 01:20:14 +0400
commit7c3facc4d18745350b7151e2402c92131b802cd4 (patch)
tree4410913b6a39e380cc8ca6e163b46b7a5d8e1fb4
parent46c1d75a72521b548e8f0f677b86f3aab01027e8 (diff)
libfreerdp-utils: added hexdump utils
-rw-r--r--channels/drdynvc/drdynvc_main.c39
-rw-r--r--include/freerdp/utils/Makefile.am3
-rw-r--r--include/freerdp/utils/hexdump.h27
-rw-r--r--libfreerdp-core/frdp.h2
-rw-r--r--libfreerdp-core/freerdp.c29
-rw-r--r--libfreerdp-core/rdp.c5
-rw-r--r--libfreerdp-core/surface.c3
-rw-r--r--libfreerdp-utils/Makefile.am3
-rw-r--r--libfreerdp-utils/hexdump.c56
9 files changed, 96 insertions, 71 deletions
diff --git a/channels/drdynvc/drdynvc_main.c b/channels/drdynvc/drdynvc_main.c
index 90ac6ac..1283b7d 100644
--- a/channels/drdynvc/drdynvc_main.c
+++ b/channels/drdynvc/drdynvc_main.c
@@ -28,6 +28,7 @@
#include <freerdp/utils/stream.h>
#include <freerdp/utils/chan_plugin.h>
#include <freerdp/utils/wait_obj.h>
+#include <freerdp/utils/hexdump.h>
#include "drdynvc_main.h"
@@ -72,43 +73,9 @@ struct drdynvc_plugin
};
#if LOG_LEVEL > 10
-void
-hexdump(char* p, int len)
-{
- unsigned char* line;
- int i;
- int thisline;
- int offset;
-
- line = (unsigned char*)p;
- offset = 0;
- while (offset < len)
- {
- printf("%04x ", offset);
- thisline = len - offset;
- if (thisline > 16)
- {
- thisline = 16;
- }
- for (i = 0; i < thisline; i++)
- {
- printf("%02x ", line[i]);
- }
- for (; i < 16; i++)
- {
- printf(" ");
- }
- for (i = 0; i < thisline; i++)
- {
- printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
- }
- printf("\n");
- offset += thisline;
- line += thisline;
- }
-}
+#define hexdump(data,length) freerdp_hexdump(data,length)
#else
-#define hexdump(p,len)
+#define hexdump(data,length) do { } while (0)
#endif
static int
diff --git a/include/freerdp/utils/Makefile.am b/include/freerdp/utils/Makefile.am
index 410babf..4788c93 100644
--- a/include/freerdp/utils/Makefile.am
+++ b/include/freerdp/utils/Makefile.am
@@ -11,4 +11,5 @@ include_HEADERS = \
stopwatch.h \
stream.h \
unicode.h \
- wait_obj.h
+ wait_obj.h \
+ hexdump.h
diff --git a/include/freerdp/utils/hexdump.h b/include/freerdp/utils/hexdump.h
new file mode 100644
index 0000000..d57ba8d
--- /dev/null
+++ b/include/freerdp/utils/hexdump.h
@@ -0,0 +1,27 @@
+/*
+ FreeRDP: A Remote Desktop Protocol client.
+ Hex Dump Utils
+
+ Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#ifndef __UTILS_HEXDUMP_H
+#define __UTILS_HEXDUMP_H
+
+#define FREERDP_HEXDUMP_LINE_LENGTH 16
+
+void freerdp_hexdump(uint8* data, int length);
+
+#endif /* __UTILS_HEXDUMP_H */
diff --git a/libfreerdp-core/frdp.h b/libfreerdp-core/frdp.h
index 68614b8..19f79f1 100644
--- a/libfreerdp-core/frdp.h
+++ b/libfreerdp-core/frdp.h
@@ -53,8 +53,6 @@ void
ui_warning(rdpInst * inst, char * format, ...);
void
ui_unimpl(rdpInst * inst, char * format, ...);
-void
-hexdump(unsigned char * p, int len);
int
load_license(unsigned char ** data);
RD_BOOL
diff --git a/libfreerdp-core/freerdp.c b/libfreerdp-core/freerdp.c
index 503203a..8f4ef3d 100644
--- a/libfreerdp-core/freerdp.c
+++ b/libfreerdp-core/freerdp.c
@@ -27,6 +27,7 @@
#include "ext.h"
#include <freerdp/freerdp.h>
#include <freerdp/utils/memory.h>
+#include <freerdp/utils/hexdump.h>
#define RDP_FROM_INST(_inst) ((rdpRdp *) (_inst->rdp))
@@ -90,34 +91,6 @@ ui_unimpl(rdpInst * inst, char * format, ...)
xfree(text2);
}
-void
-hexdump(unsigned char * p, int len)
-{
- unsigned char *line = p;
- int i, thisline, offset = 0;
-
- while (offset < len)
- {
- printf("%04x ", offset);
- thisline = len - offset;
- if (thisline > 16)
- thisline = 16;
-
- for (i = 0; i < thisline; i++)
- printf("%02x ", line[i]);
-
- for (; i < 16; i++)
- printf(" ");
-
- for (i = 0; i < thisline; i++)
- printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
-
- printf("\n");
- offset += thisline;
- line += thisline;
- }
-}
-
int
load_license(unsigned char ** data)
{
diff --git a/libfreerdp-core/rdp.c b/libfreerdp-core/rdp.c
index 701fddf..47b9738 100644
--- a/libfreerdp-core/rdp.c
+++ b/libfreerdp-core/rdp.c
@@ -36,6 +36,7 @@
#include "ext.h"
#include "surface.h"
#include <freerdp/freerdp.h>
+#include <freerdp/utils/hexdump.h>
#include "rdp.h"
@@ -1410,7 +1411,7 @@ process_redirect_pdu(rdpRdp * rdp, STREAM s)
rdp->redirect_routingtoken = xmalloc_in_len32_data(rdp, s,
&rdp->redirect_routingtoken_len);
printf("redirect_cookie_len: %d\n", rdp->redirect_routingtoken_len);
- hexdump((void*)rdp->redirect_routingtoken, rdp->redirect_routingtoken_len);
+ freerdp_hexdump((uint8*)rdp->redirect_routingtoken, rdp->redirect_routingtoken_len);
}
if (redirFlags & LB_USERNAME)
{
@@ -1444,7 +1445,7 @@ process_redirect_pdu(rdpRdp * rdp, STREAM s)
rdp->redirect_target_net_addresses = xmalloc_in_len32_data(rdp, s,
&rdp->redirect_target_net_addresses_len);
printf("redirect_target_net_addresses_len: %d\n", rdp->redirect_target_net_addresses_len);
- hexdump((void*)rdp->redirect_target_net_addresses, rdp->redirect_target_net_addresses_len);
+ freerdp_hexdump((uint8*)rdp->redirect_target_net_addresses, rdp->redirect_target_net_addresses_len);
}
if (redirFlags & LB_NOREDIRECT)
{
diff --git a/libfreerdp-core/surface.c b/libfreerdp-core/surface.c
index c5c4b4c..df69f47 100644
--- a/libfreerdp-core/surface.c
+++ b/libfreerdp-core/surface.c
@@ -21,6 +21,7 @@
#include "rdp.h"
#include "stream.h"
#include <freerdp/freerdp.h>
+#include <freerdp/utils/hexdump.h>
#include "surface.h"
@@ -83,7 +84,7 @@ surface_codec_cap(rdpRdp * rdp, uint8 * codec_guid, int codec_id,
else
{
//printf("unknown guid\n");
- hexdump(codec_guid, 16);
+ freerdp_hexdump(codec_guid, 16);
}
return s;
}
diff --git a/libfreerdp-utils/Makefile.am b/libfreerdp-utils/Makefile.am
index d6912fd..eda8d01 100644
--- a/libfreerdp-utils/Makefile.am
+++ b/libfreerdp-utils/Makefile.am
@@ -13,7 +13,8 @@ libfreerdp_utils_la_SOURCES = \
wait_obj.c \
chan_plugin.c \
stopwatch.c \
- profiler.c
+ profiler.c \
+ hexdump.c
libfreerdp_utils_la_CFLAGS = \
-I$(top_srcdir) \
diff --git a/libfreerdp-utils/hexdump.c b/libfreerdp-utils/hexdump.c
new file mode 100644
index 0000000..ce02eed
--- /dev/null
+++ b/libfreerdp-utils/hexdump.c
@@ -0,0 +1,56 @@
+/*
+ FreeRDP: A Remote Desktop Protocol client.
+ Hex Dump Utils
+
+ Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include <freerdp/types/base.h>
+
+#include <freerdp/utils/hexdump.h>
+
+void freerdp_hexdump(uint8* data, int length)
+{
+ uint8* p = data;
+ int i, line, offset = 0;
+
+ while (offset < length)
+ {
+ printf("%04x ", offset);
+
+ line = length - offset;
+
+ if (line > FREERDP_HEXDUMP_LINE_LENGTH)
+ line = FREERDP_HEXDUMP_LINE_LENGTH;
+
+ for (i = 0; i < line; i++)
+ printf("%02x ", p[i]);
+
+ for (; i < FREERDP_HEXDUMP_LINE_LENGTH; i++)
+ printf(" ");
+
+ for (i = 0; i < line; i++)
+ printf("%c", (p[i] >= 0x20 && p[i] < 0x7F) ? p[i] : '.');
+
+ printf("\n");
+
+ offset += line;
+ p += line;
+ }
+}
+