This repository has been archived by the owner on Dec 4, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathSCardLog.h
77 lines (72 loc) · 2.1 KB
/
SCardLog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* SMARTCARDPP
*
* This software is released under either the GNU Library General Public
* License (see LICENSE.LGPL) or the BSD License (see LICENSE.BSD).
*
* Note that the only valid version of the LGPL license as far as this
* project is concerned is the original GNU Library General Public License
* Version 2.1, February 1999
*
*/
#ifndef SCARDLOG_H
#define SCARDLOG_H
#ifndef WIN32
#include <stdio.h>
#include <cstdlib>
#include <stdarg.h>
#include <unistd.h>
#include <PCSC/wintypes.h>
#include <PCSC/pcsclite.h>
#include <PCSC/winscard.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <cstring>
#include <sys/time.h>
#include <sys/sysctl.h>
#ifndef __APPLE__
#include <reader.h>
#endif
#define __FUNC__ __PRETTY_FUNCTION__
#else
#pragma warning(push)
#pragma warning(disable:4201)
#undef UNICODE
#include <winscard.h>
#pragma warning(pop)
#include <time.h>
#define __FUNC__ __FUNCTION__
#endif
#include <cstdio>
#include <sys/stat.h>
#include "common.h"
class SCardLog
{
private:
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
//char *procName;
static std::string getParentProcName();
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
static FILE *openLog();
public:
SCardLog();
~SCardLog();
#ifdef WIN32
static int gettimeofday(struct timeval *tv, struct timezone *tz);
#endif
static void writeByteBufferLog(const char *func, int line, unsigned int connectionID, unsigned int transactionID, unsigned char *buff, int buffLength, const char *msg);
static void writeLog(const char *fmt,...);
static void writeAPDULog(const char *func, int line, ByteVec apdu, DWORD protocol, bool isCmd, unsigned int connectionID, unsigned int transactionID);
static void writeMessage(const char *fmt,...);
static void writeByteVecLog(ByteVec buff, const char *msg);
static std::string getParentProcFullName();
};
#endif