-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathtypes.h
72 lines (57 loc) · 1.58 KB
/
types.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
/* types.h
* By Ron Bowes
* Created September 1, 2008
*
* (See LICENSE.txt)
*
* Defines (or includes libraries that define) various required datatypes.
*
* Additionally, this module implements several miscellanious functions in a
* platform-independent way.
*/
#ifndef __TYPES_H__
#define __TYPES_H__
#ifdef WIN32
#include "pstdint.h"
#else
#include <stdint.h>
#endif
#define NBTOOL_NAME "nbtool"
#define NBTOOL_VERSION "0.05alpha2"
#define NBTOOL_NAME_VERSION NBTOOL_NAME" v"NBTOOL_VERSION
#ifndef TRUE
typedef enum
{
FALSE,
TRUE
} NBBOOL;
#else
typedef int NBBOOL;
#endif
#ifdef WIN32
typedef int socklen_t;
#define strcasecmp _strcmpi
#define strcasestr nbstrcasestr
#define fileno _fileno
#define write _write
#endif
#ifndef MIN
#define MIN(a,b) (a < b ? a : b)
#endif
#ifndef MAX
#define MAX(a,b) (a > b ? a : b)
#endif
#define DIE(a) {fprintf(stderr, "Unrecoverable error in %s(%d): %s\n\n", __FILE__, __LINE__, a); abort();}
#define DIE_MEM() {DIE("Out of memory.");}
/* Drop privileges to the chosen user, then verify that root can't be re-enabled. */
void drop_privileges(char *username);
/* Get the last error, independent of platform. */
int getlasterror();
/* Displays an error and doesn't die. The getlasterror() function is used as well as the appropriate
* error-message-display function for the platform. If str is non-NULL, it's also displayed. */
void nberror(char *str);
/* Displays an error using nberror(), then dies. */
void nbdie(char *str);
/* Implementation of strcasestr() for Windows. */
char *nbstrcasestr(char *haystack, char *needle);
#endif