libopensc for win32: get working logging when compiled with Visual Studio

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4242 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
viktor.tarasov 2010-04-14 11:52:27 +00:00
parent 9396297f21
commit ad0207852e
3 changed files with 27 additions and 10 deletions

View File

@ -79,6 +79,7 @@ sc_der_copy
sc_detect_card_presence
sc_disconnect_card
sc_do_log
_sc_debug
sc_enum_apps
sc_establish_context
sc_file_add_acl_entry

View File

@ -46,6 +46,13 @@ void sc_do_log(sc_context_t *ctx, int level, const char *file, int line, const c
{
va_list ap;
va_start(ap, format);
sc_do_log_va(ctx, level, file, line, func, format, ap);
va_end(ap);
}
void sc_do_log_va(sc_context_t *ctx, int level, const char *file, int line, const char *func, const char *format, va_list args)
{
char buf[1836], *p;
int r;
size_t left;
@ -64,8 +71,6 @@ void sc_do_log(sc_context_t *ctx, int level, const char *file, int line, const c
if (ctx->debug < level)
return;
va_start(ap, format);
p = buf;
left = sizeof(buf);
@ -95,7 +100,7 @@ void sc_do_log(sc_context_t *ctx, int level, const char *file, int line, const c
p += r;
left -= r;
r = vsnprintf(p, left, format, ap);
r = vsnprintf(p, left, format, args);
if (r < 0)
return;
p += r;
@ -111,12 +116,21 @@ void sc_do_log(sc_context_t *ctx, int level, const char *file, int line, const c
fprintf(outf, "\n");
fflush(outf);
va_end(ap);
return;
}
void sc_hex_dump(sc_context_t *ctx, int level, const u8 * in, size_t count, char *buf, size_t len)
void _sc_debug(struct sc_context *ctx, int level, const char *format, ...)
{
va_list ap;
va_start(ap, format);
sc_do_log_va(ctx, level, NULL, 0, NULL, format, ap);
va_end(ap);
}
/* Although not used, we need this for consistent exports */
void sc_hex_dump(struct sc_context *ctx, int level, const u8 * in, size_t count, char *buf, size_t len)
{
char *p = buf;
int lines = 0;

View File

@ -45,14 +45,16 @@ enum {
#endif
#if defined(__GNUC__)
#define sc_debug(ctx, level, format, args...) sc_do_log(ctx, level, __FILE__, __LINE__, __FUNCTION__, format , ## args)
#else
#define sc_debug(ctx, SC_LOG_DEBUG_NORMAL, level, format, args...) sc_do_log(ctx, level, NULL, 0, NULL, format , ## args)
#define sc_debug _sc_debug
#endif
void sc_do_log(struct sc_context *ctx, int level, const char *file, int line, const char *func, const char *format, ...);
void sc_do_log(struct sc_context *ctx, int level, const char *file, int line, const char *func,
const char *format, ...);
void sc_do_log_va(struct sc_context *ctx, int level, const char *file, int line, const char *func,
const char *format, va_list args);
void _sc_debug(struct sc_context *ctx, int level, const char *format, ...);
void sc_hex_dump(struct sc_context *ctx, int level, const u8 * buf, size_t len, char *out, size_t outlen);
char * sc_dump_hex(const u8 * in, size_t count);