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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
#ifndef __NM_LINUX_A_H__
#define __NM_LINUX_A_H__
/*
Copyright (C) 1998, 1999, 2000 Wabasoft
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.
*/
/*
Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/
More help for porting is include in the file nmport_a.c. Please read it before
porting or modify this port.
Linux port.
===========
*/
/* all the needed include */
#include <stdlib.h>
#include <string.h>
#ifndef LINUX
# error You must define the LINUX symbol as gcc parameter (-DLINUX=1)
#endif
#define FREE_ON_EXIT 1
#undef SECURE_CLASS_HEAP //#define SECURE_CLASS_HEAP 1
#ifdef SECURE_CLASS_HEAP
# define LOCK_CLASS_HEAP MemSemaphoreReserve(1);
# define UNLOCK_CLASS_HEAP MemSemaphoreRelease(1);
#else
# define LOCK_CLASS_HEAP ;
# define UNLOCK_CLASS_HEAP ;
#endif
/********************************************************************************
TYPE DEFINITIONS
********************************************************************************/
/* for the types, we use the GLib library of the GTK project.
See http://www.gtk.org for more informations */
#ifdef USE_GLIB
/* use glib for types */
#include <glib.h>
#else
/* we don't use glib, so we need to define g... types */
#define guchar unsigned char
#define gint32 int
#define guint32 unsigned int
#define gfloat float
#define gint16 short
#define guint16 unsigned short
#define gint int
#define guint unsigned int
#define gchar char
#define TRUE 1
#define FALSE 0
#endif
// - uchar is an 8 bit unsigned value
#define uchar guchar
// - int32 is a signed 32 bit value
#define int32 gint32
// - uint32 is an unsigned 32 bit value
#define uint32 guint32
// - float32 is a signed 32 bit floating point value
#define float32 gfloat
// - int16 is a signed 16 bit value
#define int16 gint16
// - uint16 is an unsigned 16 bit value
#define uint16 guint16
/********************************************************************************
TYPE CONVERTERS
********************************************************************************/
#ifdef FASTANDBIG
# define getUInt32(b) (uint32)( (uint32)((b)[0])<<24 | \
(uint32)((b)[1])<<16 | \
(uint32)((b)[2])<<8 |
(uint32)((b)[3]) )
# define getUInt16(b) (uint16)( ((b)[0]<<8)|(b)[1] )
# define getInt32(b) (int32) ( (uint32)((b)[0])<<24 | \
(uint32)((b)[1])<<16 | \
(uint32)((b)[2])<<8 |
(uint32)((b)[3]) )
# define getInt16(b) (int16) ( ((b)[0]<<8)|(b)[1] )
#else
uint32 getUInt32(uchar *b);
uint16 getUInt16(uchar *b);
int32 getInt32(uchar *b);
int16 getInt16(uchar *b);
#endif /* ifdef FASTANDBIG */
float32 getFloat32(uchar *buf);
/********************************************************************************
"STRING" FUNCTIONS
********************************************************************************/
#define xstrncmp(s1, s2, n) strncmp(s1, s2, n)
#define xstrncpy(dst, src, n) strncpy(dst, src, (ULong)n)
#define xstrlen(s) strlen(s)
#define xstrcat(dst, src) strcat(dst, src)
#define xmemmove(dst, src, size) memmove(dst, src, size)
#define xmemzero(mem, len) memset(mem, len, (Byte)0)
/********************************************************************************
DYNAMIC ALLOCATION FUNCTIONS
********************************************************************************/
#define xmalloc(size) malloc(size)
#define xfree(p) free(p)
/******************** TO REMOVE *********************/
#include <stdio.h>
/********************************************************************
* Elementary data types
********************************************************************/
// Fixed size data types
typedef char SByte; // 8 bits
#ifndef __TYPES__ // (Already defined in CW11)
typedef unsigned char Byte;
#endif
typedef short SWord; // 16 bits
typedef unsigned short Word;
typedef long SDWord; // 32 bits
typedef unsigned long DWord;
// Logical data types
#ifndef __TYPES__ // (Already defined in CW11)
typedef unsigned char Boolean;
#endif
typedef char Char; // Used for character strings
typedef unsigned char UChar;
typedef short Short; // >= Byte
typedef unsigned short UShort;
typedef short Int; // >= Word (use short so MPW and CW agree)
typedef unsigned short UInt;
typedef long Long; // >= DWord
typedef unsigned long ULong;
typedef short Err;
typedef DWord LocalID; // local (card relative) chunk ID
/************************************************************
* Pointer Types
*************************************************************/
typedef void* VoidPtr;
typedef VoidPtr* VoidHand;
// Fixed size data types
typedef SByte* SBytePtr;
#ifndef __TYPES__ // (Already defined in CW11)
typedef Byte* BytePtr;
#endif
typedef SWord* SWordPtr;
typedef Word* WordPtr;
typedef SDWord* SDWordPtr;
typedef DWord* DWordPtr;
// Logical data types
typedef Boolean* BooleanPtr;
typedef Char* CharPtr;
typedef UChar* UCharPtr;
typedef Short* ShortPtr;
typedef UShort* UShortPtr;
typedef Int* IntPtr;
typedef UInt* UIntPtr;
typedef Long* LongPtr;
typedef ULong* ULongPtr;
// Include the following typedefs if types.h wasn't read.
#ifndef __TYPES__
// Generic Pointer types used by Memory Manager
// We have to define Ptr as char* because that's what the Mac includes do.
typedef char* Ptr; // global pointer
typedef Ptr* Handle; // global handle
// Function types
typedef Long (*ProcPtr)();
#endif /* __TYPES__ */
/************************************************************
* Common constants
*************************************************************/
#ifndef NULL
# define NULL 0
#endif // NULL
// Include the following typedefs if types.h wasn't read.
#ifndef __TYPES__
#ifdef __MWERKS__
#if !__option(bool)
#ifndef true
#define true 1
#endif
#ifndef false
#define false 0
#endif
#endif
#else
enum {false, true};
#endif
#endif /* __TYPES__ */
#endif /* __NM_LINUX_A_H__ */
/*
Local Variables:
c-file-style: "smartdata"
End:
*/
|