Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

defs.h

Go to the documentation of this file.
00001 /********************************************************************
00002         Copyright (c) 2001, Lee Patterson & Ant Works Software
00003         http://ssobjects.sourceforge.net
00004 
00005         created  :  00/00/2000 00:00am
00006         filename :  defs.h
00007         author   :  Lee Patterson (lee@antws.com)
00008         
00009         purpose  :  common defines 
00010 *********************************************************************/
00011 
00012 #ifndef CCDEFS_H
00013 #define CCDEFS_H
00014 
00015 #include <sys/types.h>
00016 #include "msdefs.h"
00017 
00018 //types to keep things simple
00019 
00020 //  short sNumber
00021 //  ushort uNumber
00022 //  int iNumber;
00023 //  uint nNumber
00024 //  byte byNumber
00025 //  bool bNumber;
00026 
00027 #ifndef _WIN32
00028 #    ifndef min
00029 # define min(x,y) (((x)<(y))?(x):(y))
00030 #    endif
00031 
00032 #    ifndef max
00033 # define max(x,y) (((x)>(y))?(x):(y))
00034 #    endif
00035 #endif
00036 
00037 typedef unsigned char byte;     //8 bits
00038 typedef unsigned short word;    //16 bits
00039 typedef short sword;            //16 bits
00040 typedef long dsword;            //32 bits
00041 typedef unsigned long dword;    //32 bites
00042 #ifndef __USE_MISC
00043 typedef unsigned long ulong;
00044 typedef unsigned int uint;
00045 #endif
00046 
00047 typedef const           char    CONSTCHAR;              //sz (makes it easier to sort functions headers by fields if const char is one word
00048 typedef const           char*   PCONSTCHAR;             //psz (LPCSTR)
00049 typedef unsigned  char  unsigned8;    //by
00050 typedef signed    char  signed8;      //sb
00051 typedef unsigned  short unsigned16;   //wNumber
00052 typedef signed    short signed16;     //swNumber
00053 typedef unsigned  long  unsigned32;   //nNumber
00054 typedef signed    long  signed32;     //iNumber
00055 
00056 //needs string.h
00057 #define ZEROMEMORY(address, numBytes)   memset((void*)(address), (int)0, (size_t)(numBytes))
00058 #define FREE_NULL(ptr)                  {free(ptr);ptr=NULL;}
00059 #ifdef __cplusplus
00060 #define DELETE_NULL(ptr)    { delete ptr; ptr = NULL; }
00061 #endif
00062 
00063 //other handy defines
00064 #define IS_EVEN(n) ((int)((n)/2)*2 == (n))
00065 #define IS_ODD(n) (!((int)((n)/2)*2 == (n)))
00066 #define NULL_TERMINATE(s,n) ((s[(n)-1] = '\0'))         //make the last character of a char array a null character
00067 
00068 //Will select number from and including min, upto and including max.
00069 //TODO: should I add some brackets around max and min like NULL_TERMINATE to make it a safer macro?
00070 #define RND(min,max) (rand()%(max+1-min)+min)
00071 
00072 // 
00073 // BREAK is like a breakpoint in a program and will stop the debugger on the
00074 // line following the BREAK call. In debug mode, it has no effect. 
00075 // BREAK_ALWAYS will break in DEBUG and RELEASE mode.
00076 //
00077 // NOTE: If not run in a debugger, it will cause the program to raise a signal
00078 //  and generate a core file. You can then use: "gdb binary core"
00079 //
00080 #ifndef DEBUG
00081 #   define BREAK
00082 #else
00083 #   define BREAK asm("int $3")
00084 #endif
00085 
00086 #define BREAK_ALWAYS asm("int $3")
00087 
00088 
00089 #ifndef UNUSED
00090 #   ifdef DEBUG
00091 #       define UNUSED(x) ((void)x)           //kills warning when a parameter isn't used
00092 #   else
00093 #       define UNUSED(x)
00094 #   endif
00095 #endif
00096 
00097 #ifndef UNUSED_ALWAYS
00098 #   define UNUSED_ALWAYS(x) ((void)x)
00099 #endif
00100 
00101 
00102 //#ifndef OS_LINUX
00103 //defines needed for FreeBSD
00104 //typedef unsigned long uint32_t;
00105 //typedef int socklen_t;
00106 //#endif
00107 
00108 
00109 #endif //CCDEFS_H

Generated on Thu Nov 8 12:39:25 2001 for SimpleServerObjects by doxygen1.2.11 written by Dimitri van Heesch, © 1997-2001