Debian Codegraph @

gobi-api/Gobi_2012-06-18-1054/Core/StdAfx.h

raw
1 /*===========================================================================
2 FILE:
3 StdAfx.h
4
5 DESCRIPTION:
6 Application Framework eXtenstions for Linux
7
8 PUBLIC CLASSES AND FUNCTIONS:
9
10 Copyright (c) 2012, Code Aurora Forum. All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright
15 notice, this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright
17 notice, this list of conditions and the following disclaimer in the
18 documentation and/or other materials provided with the distribution.
19 * Neither the name of Code Aurora Forum nor
20 the names of its contributors may be used to endorse or promote
21 products derived from this software without specific prior written
22 permission.
23
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 POSSIBILITY OF SUCH DAMAGE.
36 ===========================================================================*/
37
38 //---------------------------------------------------------------------------
39 // Pragmas
40 //---------------------------------------------------------------------------
41 #pragma once
42 //---------------------------------------------------------------------------
43 // Includes
44 //---------------------------------------------------------------------------
45 #include <fstream>
46 #include <assert.h>
47 #include <termios.h>
48 #include <string.h>
49 #include <errno.h>
50 #include <algorithm>
51 #include <limits.h>
52 #include <dirent.h>
53 #include <sstream>
54 #include <stdarg.h>
55 #include <time.h>
56 #include <sys/time.h>
57 #include <sys/ioctl.h>
58 #include <sys/stat.h>
59 #include <fcntl.h>
60
61 //---------------------------------------------------------------------------
62 // Macro defination
63 //---------------------------------------------------------------------------
64
65 #define ASSERT( x ) assert( x )
66
67 #ifdef DEBUG
68
69 #ifdef ANDROID
70
71 #include <android/log.h>
72
73 // TRACE macro
74 #define TRACE( format, arg... ) \
75 if (true) \
76 { \
77 __android_log_print( ANDROID_LOG_INFO, \
78 "Gobi", "%s:%d: " format, \
79 __FILE__, \
80 __LINE__, \
81 ##arg ); \
82 }
83
84 #else
85
86 #define TRACE( format, arg... ) \
87 printf( "%s:%d: " format, \
88 __FILE__, \
89 __LINE__, \
90 ##arg )
91 #endif
92
93 #else
94 #define TRACE(...)
95 #endif
96
97 //---------------------------------------------------------------------------
98 // data type defination
99 //---------------------------------------------------------------------------
100 #ifndef FALSE
101 #define FALSE 0
102 #endif
103
104 #ifndef TRUE
105 #define TRUE 1
106 #endif
107
108 #ifndef CONST
109 #define CONST const
110 #endif
111
112 typedef void VOID;
113 typedef unsigned long DWORD;
114 typedef int BOOL;
115 typedef unsigned char BYTE;
116 typedef unsigned short WORD;
117 typedef float FLOAT;
118 typedef long long LONGLONG;
119 typedef unsigned long long ULONGLONG;
120 typedef signed char INT8;
121 typedef double DOUBLE;
122
123 typedef int INT;
124 typedef unsigned int UINT;
125 typedef unsigned int * PUINT;
126 typedef INT HANDLE;
127 typedef HANDLE HMODULE;
128
129 typedef char CHAR;
130 typedef short SHORT;
131 typedef long LONG;
132
133 typedef unsigned long ULONG;
134 typedef ULONG * PULONG;
135 typedef ULONG * ULONG_PTR;
136 typedef unsigned short USHORT;
137 typedef USHORT * PUSHORT;
138 typedef unsigned char UCHAR;
139 typedef UCHAR * PUCHAR;
140 typedef char * PSZ;
141
142
143 typedef CONST CHAR * LPCSTR;
144 typedef CHAR * LPSTR;
145
146 typedef BYTE * PBYTE;
147 typedef BOOL * PBOOL;
148 typedef INT * PINT;
149 typedef UINT * LPINT;
150 typedef WORD * PWORD;
151 typedef PWORD LPWORD;
152 typedef LONG * LPLONG;
153 typedef DWORD * PDWORD;
154 typedef VOID * PVOID;
155 typedef PVOID LPVOID;
156 typedef const void * LPCVOID;
157
158 typedef size_t SIZE_T;
159 typedef double DATE;
160
161 // Error code
162 #define NO_ERROR 0L
163 #define ERROR_SUCCESS 0L
164 #define ERROR_NO_MORE_ITEMS 259L
165 #define ERROR_CRC 23L
166 #define ERROR_OUTOFMEMORY 14L
167 #define ERROR_CAN_NOT_COMPLETE 1003L
168 #define ERROR_REVISION_MISMATCH 1306L
169 #define ERROR_BAD_ARGUMENTS 160L
170 #define INVALID_SET_FILE_POINTER -1
171 #define VALID_HANDLE_VALUE 0
172 #define INVALID_HANDLE_VALUE -1
173 #define INVALID_FILE_SZ -1
174
175 #define ERROR_GEN_FAILURE 31L
176 #define ERROR_FILE_NOT_FOUND 2L
177 #define ERROR_NOT_ENOUGH_MEMORY 8L
178 #define ERROR_INVALID_PARAMETER 87L
179 #define ERROR_BAD_FORMAT 11L
180
181
182 // Other Constant definitions
183 #define MAX_PATH 512
184 #define INFINITE 0xffffffff
185
186
187 // SIOCIWFIRSTPRIV = 0x8BE0
188
189 // Device I/O control code for setting QMI service
190 #define QMI_GET_SERVICE_FILE_IOCTL 0x8BE0 + 1
191
192 // Device I/O control code for obtaining device VIDPID
193 #define QMI_GET_VIDPID_IOCTL 0x8BE0 + 2
194
195 // Device I/O control code for obtaining device MEID
196 #define QMI_GET_MEID_IOCTL 0x8BE0 + 3
197
198 // Define the directions for pipes
199 #define READING 0
200 #define WRITING 1