[MKHIVE] Minor improvements.
[reactos.git] / sdk / tools / isohybrid / reactos_support_code.h
1 #ifndef _REACTOS_SUPPORT_CODE_H
2 #define _REACTOS_SUPPORT_CODE_H
3
4 #include <stdarg.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8
9 #ifdef _WIN32
10 #include <malloc.h>
11 #include <windows.h>
12 #else
13 #include <alloca.h>
14 #include <unistd.h>
15 #endif
16
17 // isotypes.h would provide these, but it's not available on MSVC < 2013.
18 typedef unsigned char uint8_t;
19 typedef unsigned short uint16_t;
20 typedef unsigned int uint32_t;
21 typedef unsigned long long uint64_t;
22
23 void isohybrid_error(int eval, const char* fmt, ...);
24 void isohybrid_warning(const char* fmt, ...);
25
26 #define err(...) isohybrid_error(__VA_ARGS__)
27 #define errx(...) isohybrid_error(__VA_ARGS__)
28 #define warn(...) isohybrid_warning(__VA_ARGS__)
29 #define warnx(...) isohybrid_warning(__VA_ARGS__)
30
31
32 /////////////////////////////////////////////////////////////////////////////
33 // getopt code from mingw-w64
34 /////////////////////////////////////////////////////////////////////////////
35 extern int optopt; /* single option character, as parsed */
36 extern char *optarg; /* pointer to argument of current option */
37
38 struct option /* specification for a long form option... */
39 {
40 const char *name; /* option name, without leading hyphens */
41 int has_arg; /* does it take an argument? */
42 int *flag; /* where to save its status, or NULL */
43 int val; /* its associated status value */
44 };
45
46 enum /* permitted values for its `has_arg' field... */
47 {
48 no_argument = 0, /* option never takes an argument */
49 required_argument, /* option always requires an argument */
50 optional_argument /* option may take an argument */
51 };
52
53 int getopt_long_only(int nargc, char * const *nargv, const char *options, const struct option *long_options, int *idx);
54 /////////////////////////////////////////////////////////////////////////////
55
56 #ifdef _WIN32
57 int fsync(int fd);
58 int getppid(void);
59 #endif
60
61 #ifdef _MSC_VER
62 #define fseeko _fseeki64
63 #define ftruncate _chsize
64 #endif
65
66 #endif