2012-05-25 01:05:12 +04:00
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* Print Utils
|
|
|
|
*
|
|
|
|
* Copyright 2012 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.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:20:53 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2013-03-01 00:43:57 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2012-05-25 01:05:12 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/print.h>
|
|
|
|
|
2013-03-22 05:30:31 +04:00
|
|
|
#include "trio.h"
|
|
|
|
|
2012-05-25 01:05:12 +04:00
|
|
|
void winpr_HexDump(BYTE* data, int length)
|
|
|
|
{
|
|
|
|
BYTE* p = data;
|
|
|
|
int i, line, offset = 0;
|
|
|
|
|
|
|
|
while (offset < length)
|
|
|
|
{
|
2013-03-29 02:06:34 +04:00
|
|
|
fprintf(stderr, "%04x ", offset);
|
2012-05-25 01:05:12 +04:00
|
|
|
|
|
|
|
line = length - offset;
|
|
|
|
|
|
|
|
if (line > WINPR_HEXDUMP_LINE_LENGTH)
|
|
|
|
line = WINPR_HEXDUMP_LINE_LENGTH;
|
|
|
|
|
|
|
|
for (i = 0; i < line; i++)
|
2013-03-29 02:06:34 +04:00
|
|
|
fprintf(stderr, "%02x ", p[i]);
|
2012-05-25 01:05:12 +04:00
|
|
|
|
|
|
|
for (; i < WINPR_HEXDUMP_LINE_LENGTH; i++)
|
2013-03-29 02:06:34 +04:00
|
|
|
fprintf(stderr, " ");
|
2012-05-25 01:05:12 +04:00
|
|
|
|
|
|
|
for (i = 0; i < line; i++)
|
2013-03-29 02:06:34 +04:00
|
|
|
fprintf(stderr, "%c", (p[i] >= 0x20 && p[i] < 0x7F) ? p[i] : '.');
|
2012-05-25 01:05:12 +04:00
|
|
|
|
2013-03-29 02:06:34 +04:00
|
|
|
fprintf(stderr, "\n");
|
2012-05-25 01:05:12 +04:00
|
|
|
|
|
|
|
offset += line;
|
|
|
|
p += line;
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 00:43:57 +04:00
|
|
|
|
2013-03-13 18:08:45 +04:00
|
|
|
int wvprintfx(const char *fmt, va_list args)
|
2013-03-01 00:43:57 +04:00
|
|
|
{
|
2013-03-22 05:30:31 +04:00
|
|
|
return trio_vprintf(fmt, args);
|
2013-03-01 00:43:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int wprintfx(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
2013-03-22 05:30:31 +04:00
|
|
|
status = trio_vprintf(fmt, args);
|
2013-03-01 00:43:57 +04:00
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|