0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* Switches
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
#ifndef __STANDARD_UNIX_H__
|
|
23 |
#define __STANDARD_UNIX_H__
|
|
24 |
|
|
25 |
// COMPILE ONLY - these defs get things to compile - not work!!!
|
|
26 |
#ifdef WIN32
|
|
27 |
#define mktime(x) ((time_t)0)
|
|
28 |
#define strptime(a,b,c)
|
|
29 |
#define ioctl(a,b,c) (0)
|
|
30 |
#endif
|
|
31 |
|
|
32 |
// COMPILE ONLY - Windows doesn't define SIGKILL
|
|
33 |
#ifdef WIN32
|
|
34 |
#define SIGKILL 0
|
|
35 |
#endif
|
|
36 |
|
|
37 |
// COMPILE ONLY - Ioctl constants
|
|
38 |
#ifdef WIN32
|
|
39 |
#define SIOCGIFDSTADDR 0
|
|
40 |
#define SIOCSIFADDR 0
|
|
41 |
#define SIOCSIFDSTADDR 0
|
|
42 |
struct ifreq {
|
|
43 |
char *ifr_name;
|
|
44 |
struct sockaddr ifr_addr;
|
|
45 |
struct sockaddr ifr_dstaddr;
|
|
46 |
};
|
|
47 |
#endif
|
|
48 |
|
|
49 |
// Windows doesn't have getppid()
|
|
50 |
#ifdef WIN32
|
|
51 |
#define getppid() (-1)
|
|
52 |
#endif
|
|
53 |
|
|
54 |
// Windows has inet_addr instead of inet_aton
|
|
55 |
#ifdef WIN32
|
|
56 |
#define inet_aton(str,pstruct) (((pstruct)->ADDRESS_INTEGER = inet_addr(str)), 1)
|
|
57 |
#endif
|
|
58 |
|
|
59 |
// Windows has different naming conventions for some string methods.
|
|
60 |
#ifdef WIN32
|
|
61 |
#define snprintf _snprintf
|
|
62 |
#define strncasecmp _strnicmp
|
|
63 |
#endif
|
|
64 |
|
|
65 |
// Windows and Linux have different Sleep function - Windows has milliseconds while Linux
|
|
66 |
// just has seconds. This is dangerous - so I replace with a standard millisecond version
|
|
67 |
#ifndef WIN32
|
|
68 |
#define SleepForMilliseconds(x) sleep(((x)/1000))
|
|
69 |
#else
|
|
70 |
#define SleepForMilliseconds(x) Sleep((x))
|
|
71 |
#endif
|
|
72 |
|
|
73 |
// Windows doesn't like these includes - but almost all use them - so include them here to collect hash-if-defs
|
|
74 |
#ifndef WIN32
|
|
75 |
#include <unistd.h>
|
|
76 |
#include <errno.h>
|
|
77 |
#endif
|
|
78 |
|
|
79 |
// Windows doesn't define snprintf
|
|
80 |
#ifdef WIN32
|
|
81 |
#define snprintf _snprintf
|
|
82 |
#endif
|
|
83 |
|
|
84 |
// Windows doesn't follow berkely in_addr perfectly
|
|
85 |
#ifdef WIN32
|
|
86 |
#define ADDRESS_INTEGER S_un.S_addr
|
|
87 |
#else
|
|
88 |
#define ADDRESS_INTEGER s_addr
|
|
89 |
#endif
|
|
90 |
|
|
91 |
// Windows doesn't define IFNAMSIZ
|
|
92 |
#ifdef WIN32
|
|
93 |
#define IFNAMSIZ 100
|
|
94 |
#endif
|
|
95 |
|
|
96 |
// Windows doesn't have pid_t
|
|
97 |
#ifdef WIN32
|
|
98 |
#define pid_t int
|
|
99 |
#endif
|
|
100 |
|
|
101 |
// Windows doesn't have sighandler_t
|
|
102 |
#ifdef WIN32
|
|
103 |
typedef void (*sighandler_t)(int);
|
|
104 |
#endif
|
|
105 |
|
|
106 |
#endif
|