⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memincs.h

📁 语法分析器 完成从c/c++向C++转变
💻 H
字号:
#if defined (MEMINCS_Sym)                    /* Allow compiler one copy */
#else
#define MEMINCS_Sym

/***********************************************************************
**+
**  Module Name:  memincs.h
**
**  Description:  MEM specific defines
**
**  Include Modules Referenced:  None.
**
**  Written by:  John Tal
**
**
**  Modification history:
**
**  Date         Engineer     Mod #          Modification Description
**
**  23-May-1991  Tal          v 1.0-001      Initial conversion to C++
**
***********************************************************************/


/*
**   APIENTRY is used by Microsoft Windows and OS/2
**   just make null if not already defined
*/

#ifndef APIENTRY
#define APIENTRY
#endif


/*
**  Take care of our friend NULL
*/


#ifndef NULL
#define NULL  0
#endif


/*  
**   Implementation independent types
**   From OS/2, Windows, use SHORT in code instead of short
*/

#ifndef SHORT
typedef  short    SHORT;
typedef  SHORT *  PSHORT;
typedef  long     LONG;
typedef  LONG  *  PLONG;
typedef  int      INT;
typedef  INT   *  PINT;
typedef  unsigned short  USHORT;
typedef  USHORT * PUSHORT;
typedef  unsigned long   ULONG;
typedef  ULONG *  PULONG;
typedef  char     CHAR;
typedef  char *   PCHAR;
typedef  unsigned char  UCHAR;
typedef  unsigned char * PUCHAR;
typedef  float    FLOAT;
typedef  double   DOUBLE;
typedef  unsigned char  BYTE;
typedef  unsigned char * PBYTE;
typedef  void     VOID;
typedef  void *   PVOID;
typedef  void **  PPVOID;
typedef  unsigned char  BOOL;
typedef  unsigned char * PBOOL;
#endif



/*
**  EVERYTHING below this point should start with C_
**
**     OR IT DOES NOT BELONG IN THE MEM LEVEL FILES!
*/

/*
**  Standard function return codes
*/


#define C_OK              0               /* Good condition code */
#define C_NOTOK           -1              /* Bad condition code  */
#define C_PARTIAL_RESP    1               /* Partial Response    */
#define C_UNAVAIL         -1

/*
**  Logical types
*/

#define  C_NOTHING (0)          /*  Initialization value */
#define  C_TRUE (1)             /*  Boolean TRUE */
#define  C_FALSE (0)            /*  Boolean FALSE */

#define  C_ZERO (0)     

#define  C_HIGHER (1)           /*  memcmp, strcmp results */
#define  C_EQUAL  (0)           /*   "   */
#define  C_LOWER  (-1)          /*   "   */


/*
**  Generic object or action codes 
*/

#define  C_PARENT   1
#define  C_CHILD    2
#define  C_CLONE    3

/*
**  Procedural commands, state change requests
*/

#define  C_START    4
#define  C_STOP     5
#define  C_CREATE   7
#define  C_DESTROY  8
#define  C_INIT     9
#define  C_SHUTDOWN  (4321)

/*
**  States   (of processes, communication lines, sessions, data, etc.)
*/


#define  C_UNKNOWN  12
#define  C_ERROR    13
#define  C_LOST     14
#define  C_MIA      15   /* missing */
#define  C_RETRY    16
#define  C_LIVE     17
#define  C_DEAD     18

#define  C_COMPLETE    19
#define  C_INCOMPLETE  20


#define  C_NAME_STR    "MEM"


#define  C_NULL_CHAR  '\0'     /*  NULL character */

/*
**   Heap 
*/

#define C_HEAP_EMPTY  -1
#define C_HEAP_TOP    0


#define C_FREE(ptr) \
{ \
if((ptr) != NULL) \
{ \
   free(ptr); \
   (ptr) = NULL; \
} \
}


#define C_CNVT_NULLS_TO_SPCS(pointer, bufsize) \
{ \
PCHAR pcharIndex; \
USHORT ushortCount; \
for (pcharIndex = (PCHAR)pointer,  \
     ushortCount = 0;              \
     ushortCount < bufsize;        \
     ushortCount++,                \
     pcharIndex++                  \
    )                              \
  if (*pcharIndex == '\0')    \
    *pcharIndex = ' ';     \
}


/*
** Macro to trim out all leading and trailing blanks in a string.
** Usage C_TRIM_SPCS(pointer)
** Where pointer = buffer to be trimmed
**
**  Note that the string is shortened by the number of blanks removed
*/

#define C_TRIM_SPCS(pointer) \
{ \
SHORT shortStrlen; \
while (pointer[0] == ' ') \
{ \
  shortStrlen = strlen(pointer); \
  memmove (&pointer[0], &pointer[1], shortStrlen-1); \
  pointer[shortStrlen-1] = ' '; \
}  \
shortStrlen = strlen(pointer); \
while (pointer[shortStrlen-1] == ' ') \
{ \
  pointer[shortStrlen-1] = '\0'; \
  shortStrlen--; \
} \
}




/*
**   The following macro, C_LEAVE is used when you want to leave the
**   current module.   It does a goto to the label in your module
**   C_MODULE_EXIT.
**
**   Yes, gotos have been abused but to say you aren't going to use
**   a single one is foolish.   With no goto, you end up with code with
**   high cyclomatic complexitity (cf. McCabe and Software Metrics) and
**   which is difficult to maintain.  (Not to mention having to document
**   and try and match all those close } brackets which appear together
**                                   }
**                                 }
**                              }
**                           }
**
**   What you want to do is try an operation, if it fails and you have
**   no reason to continue processing in that module, GET OUT!
**   
**   The goto is masked in the C_LEAVE macro so you can still have a
**   coding standard that says "do not use 'goto'".   Having a goto
**   is much easier than trying and operation and nesting to another
**   level of if()  ad infinitum.
**
**
*/

#define  C_LEAVE(stat)  {sCStatus = stat; goto C_MODULE_EXIT;}

#define  C_CHECK_STATUS(stat) {if(stat) goto C_MODULE_EXIT;}
#define  C_IF_STATUS {if(sCStatus) goto C_MODULE_EXIT;}

/*
**   Return function from module
*/

#define   C_RETURN  return(sCStatus);

#define   C_SET_STATUS(stat) sCStatus = stat;

#define   C_STATUS sCStatus

/*
**   C_DEF_MODULE = Module Initialization, sets name of current module
**
**   Provided for debugging and logging
**  
**
**   usage
**
**   SHORT APIENTRY
**   SomeModule(APP_WORK_AREA_P  pstWorkArea, other parms)
**   {
**       C_DEF_MODULE("SomeModule  SM.C")
**
**       variable definitions
**
**       module code
**
**       if(error)
**         C_LEAVE(errorcode)
**
**       more module code
**
**    C_MODULE_EXIT:   (* <-  label you provide *)
**
**       C_RETURN
**   }
*/

#define   C_DEF_MODULE(modn)  static CHAR szCmoduleName[] = modn; SHORT sCStatus = C_OK;
#define   C_DEF_VMODULE(modn)  static CHAR szCmoduleName[] = modn; 

#define   C_MODULE_NAME  szCmoduleName

#endif /* MEMINCS_Sym */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -