forked from L1L1/cardpeek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.h
114 lines (88 loc) · 2.65 KB
/
misc.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**********************************************************************
*
* This file is part of Cardpeek, the smart card reader utility.
*
* Copyright 2009-2014 by Alain Pannetrat <L1L1@gmx.com>
*
* Cardpeek 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 3 of the License, or
* (at your option) any later version.
*
* Cardpeek 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 Cardpeek. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MISC_H
#define MISC_H
#include <glib.h>
#ifdef _WIN32
#include "win32/config.h"
#else
#include "config.h"
#endif
#ifndef HAVE_GSTATBUF
#include <unistd.h>
typedef struct stat GStatBuf;
#endif
/* Not needed for maverick anymore *
#ifdef __APPLE__
#define DIRENT_T struct dirent
#else*/
#define DIRENT_T const struct dirent
/* #endif
*/
#define is_hex(a) ((a>='0' && a<='9') || \
(a>='A' && a<='F') || \
(a>='a' && a<='f'))
#define is_blank(a) (a==' ' || a=='\t' || a=='\r' || a=='\n')
/*****************************************************
*
* filename parsing
*/
const char *filename_extension(const char *fname);
const char *filename_base(const char *fname);
/*****************************************************
*
* log functions
*/
typedef void (*logfunc_t)(int,const char*);
int log_printf(int level, const char *format, ...);
void log_set_function(logfunc_t logfunc);
void log_open_file(void);
void log_close_file(void);
enum {
LOG_DEBUG,
LOG_INFO,
LOG_WARNING,
LOG_ERROR
};
/*****************************************************
*
* String functions for hash maps
*/
guint cstring_hash(gconstpointer data);
gint cstring_equal(gconstpointer a, gconstpointer b);
/******************************************************
*
* version_to_bcd convert string version to BCD as
* MM.mm.rrrr
* | | |
* | | +- revision (0000-9999)
* | +------ minor (00-99)
* +--------- major (00-99)
*/
unsigned version_to_bcd(const char *version);
/******************************************************
*
* debug function
*/
#include <stdio.h>
#define HERE() { fprintf(stderr,"%s[%i]\n",__FILE__,__LINE__); fflush(stderr); }
#define UNUSED(x) (void)x
#endif /* _MISC_H_ */