NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_sysdeps.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef BE_WINDOWSFIXUP_H_
12#define BE_WINDOWSFIXUP_H_
13
14#ifdef _WIN32
15
16#include <windows.h>
17
18using mode_t = unsigned int;
19
20/* 1: arpa/inet.h equivalent for htons, etc. */
21#include <winsock.h>
22
23/* 2: use windows basename(3)/dirname(3) */
24char* basename(const char*);
25char* dirname(const char*);
26
27/* 3: unistd.h */
28#include <io.h>
29
30/* Windows only implements localtime and localtime_s, but _s is better */
31struct tm*
32localtime_r(
33 const time_t* clock,
34 struct tm* result);
35
36/* 4: Mainly in windows.h */
37
38/*
39 * 5: No dirent on Windows. Use open-source version compiled in NBIS.
40 * Also contains some #defines usually found in sys/stat.h.
41 */
42#include <be_dirent_windows.h>
43#ifndef S_IRWXU
44#define S_IRWXU S_IRUSR | S_IWUSR | S_IXUSR
45#endif
46#ifndef S_IRWXG
47#define S_IRWXG S_IRGRP | S_IWGRP | S_IXGRP
48#endif
49#ifndef S_IRWXO
50#define S_IRWXO S_IROTH | S_IWOTH | S_IXOTH
51#endif
52
53#ifndef F_OK
54#define F_OK 00
55#endif
56
57#ifndef R_OK
58#define R_OK 04
59#endif
60
61#ifndef W_OK
62#define W_OK 02
63#endif
64
65/* 6: mkdir() */
66#include <direct.h>
67/* ...except Windows mkdir doesn't take a mode_t */
68int mkdir(const char*, mode_t);
69int mkstemp(char*);
70
71/* 7: Symlinks aren't quite the same on Windows */
72int lstat(const char*, struct stat*);
73
74/* 8: Missing or alternate names with required C linkage for NBIS */
75
76#ifdef __cplusplus
77extern "C" {
78#endif
79
80int strncasecmp(const char* s1, const char* s2, size_t n);
81char* index(const char* s, int c);
82
83/* 9: No gettimeofday */
84int gettimeofday(struct timeval*, struct timezone*);
85
86/* 10: Skipping for now (sys/wait.h) */
87
88#ifdef __cplusplus
89}
90#endif
91
92#else
93
94/* 1 */
95#include <arpa/inet.h>
96
97/* 2 */
98
99#include <libgen.h> /* for basename(3) and dirname(3) */
100#ifdef basename /* GNU has this macro irresponsibly defined */
101#undef basename
102#endif
103
104/* 3 */
105#include <unistd.h>
106
107/* 4 */
108#include <sys/param.h>
109
110/* 5 */
111#include <dirent.h>
112
113/* 9 */
114#include <sys/time.h>
115
116/* 10 */
117#include <sys/wait.h>
118
119#endif /* _WIN32 */
120
121#endif /* BE_WINDOWSFIXUP_H_ */
std::string basename(const std::string &path)
Extract the filename component of a pathname.
std::string dirname(const std::string &path)
Extract the directory component of a pathname.