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

📄 sctpredg.h

📁 是一个手机功能的模拟程序
💻 H
📖 第 1 页 / 共 5 页
字号:
/*
# clearcase: CmicroPatchRel2.3.3
*/

/*
+------------------------------------------------------------------------------+
|                                                                              |
|  Copyright by Telelogic AB 1993 - 1998                                       | 
|  Copyright by S&P Media GmbH Germany 1993 - 1998                             | 
|                                                                              |
|  This Program is owned by Telelogic and is protected by national             | 
|  copyright laws and international copyright treaties. Telelogic              | 
|  grants you the right to use this Program on one computer or in              | 
|  one local computer network at any one time.                                 | 
|  Under this License you may only modify the source code for the purpose      | 
|  of adapting it to your environment. You must reproduce and include          | 
|  any copyright and trademark notices on all copies of the source code.       | 
|  You may not use, copy, merge, modify or transfer the Program except as      | 
|  provided in this License.                                                   |
|  Telelogic does not warrant that the Program will meet your                  | 
|  requirements or that the operation of the Program will be                   | 
|  uninterrupted and error free. You are solely responsible that the           | 
|  selection of the Program and the modification of the source code            | 
|  will achieve your intended results and that the results are actually        | 
|  obtained.                                                                   |
|                                                                              |
+------------------------------------------------------------------------------+
*/

/*
# clearcase: CmicroPatchRel2.3.3
*/

#ifndef X_SCTPREDG_H
#define X_SCTPREDG_H

/* This file contains implementation of the predefined data types
   except PId. The functions defined here can be found in the file
   sctpred.c.
*/
/*
FILE INDEX
04   Generator String
05   Generator Array  (array that cannot become array in C)
06   Generator Powerset  (limited and discrete component type)
07   Generator Powerset  (general component type)
08   Generator Bag
*/

#ifndef XNO_LONG_MACROS

/****+***************************************************************
04   Generator String
********************************************************************/

/* typedef for String type ----------------------------------------*/

#define String_Type(SORT, COMPONENTSORT) \
   typedef struct XCAT(SORT,_ystruct)  * XCAT(SORT,_yptr); \
   typedef struct XCAT(SORT,_ystruct) { \
     XCAT(SORT,_yptr)   Suc; \
     COMPONENTSORT      Data; \
   } XCAT(SORT,_yrec); \
   typedef struct { \
     XCAT(SORT,_yptr) First; \
     XCAT(SORT,_yptr) Last; \
     int              Length; \
     xbool            IsAssigned; \
   } SORT;


/* String operator prototypes -------------------------------------*/

#define String_prototypes(SORT, COMPONENTSORT) \
  extern SORT XCAT(yEmptystring_,SORT) XPP((void)); \
  extern SORT XCAT(yMkString_,SORT) XPP((COMPONENTSORT)); \
  extern SDL_Integer XCAT(yLength_,SORT) XPP((SORT)); \
  extern COMPONENTSORT XCAT(yFirst_,SORT) XPP((SORT)); \
  extern COMPONENTSORT XCAT(yLast_,SORT) XPP((SORT)); \
  extern SORT XCAT(yConcat_,SORT) XPP((SORT, SORT)); \
  extern SORT XCAT(ySubString_,SORT) \
     XPP((SORT, SDL_Integer, SDL_Integer)); \
  extern COMPONENTSORT XCAT(yExtr_,SORT) XPP((SORT, SDL_Integer)); \
  extern COMPONENTSORT *XCAT(yAddr_,SORT) XPP((SORT *, SDL_Integer)); \
  \
  extern XCAT(SORT,_yptr)  XCAT(yGetAvail_,SORT) XPP((void)); \
  extern void XCAT(yAppend_,SORT) XPP((SORT *result, SORT S)); \
  \
  extern char * XCAT(yWri_,SORT) XPP((void * S)); \
  extern int XCAT(yRead_,SORT) XPP((void * Result));



/* String operator implementations --------------------------------*/

/*-- yEmptystring_SORT (String)------------------------------------*/
#define String_Emptystring(SORT, COMPONENTSORT) \
  SORT XCAT(yEmptystring_,SORT) XPP((void)) \
  { \
    SORT Result; \
    Result.First = (XCAT(SORT,_yptr))0; \
    Result.Last = (XCAT(SORT,_yptr))0; \
    Result.Length = 0; \
    Result.IsAssigned = (xbool)0; \
    return Result; \
  }


/*-- yMkString_SORT (String)---------------------------------------*/
#define String_MkString(SORT, COMPONENTSORT) \
  XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)) \
  { \
    XCAT(SORT,_yptr) Item; \
    if (XCAT(yAvail_,SORT) != (XCAT(SORT,_yptr))0) { \
      Item = XCAT(yAvail_,SORT); \
      XCAT(yAvail_,SORT) = XCAT(yAvail_,SORT)->Suc; \
      Item->Suc = (XCAT(SORT,_yptr))0; \
    } else { \
      Item = (XCAT(SORT,_yptr))xAlloc((unsigned)sizeof(XCAT(SORT,_yrec))); \
    } \
    XCAT(yDef_,COMPONENTSORT)(&Item->Data); \
    return Item; \
  } \
  \
  SORT XCAT(yMkString_,SORT) \
    XPP_PROTO( (COMPONENTSORT Component) ) \
    XPP_NOPROTO( (Component) COMPONENTSORT Component; ) \
  { \
    SORT Result; \
    Result.First = XCAT(yGetAvail_,SORT)(); \
    Result.Last = Result.First; \
    Result.Length = 1; \
    Result.IsAssigned = (xbool)0; \
    XCAT(yAssF_,COMPONENTSORT)(Result.First->Data, Component, XASS); \
    return Result; \
  }


/*-- yLength_SORT (String)-----------------------------------------*/
#define String_Length(SORT, COMPONENTSORT) \
  SDL_Integer XCAT(yLength_,SORT) \
    XPP_PROTO( (SORT SIn) ) \
    XPP_NOPROTO( (SIn) SORT SIn; ) \
  { \
    if (! SIn.IsAssigned && SIn.First != (XCAT(SORT,_yptr))0) { \
      XCAT(yFree_,SORT)((void **)&SIn); \
    } \
    return SIn.Length; \
  }

/*-- yFirst_SORT (String)------------------------------------------*/
#define String_First(SORT, COMPONENTSORT) \
  COMPONENTSORT XCAT(yFirst_,SORT) \
    XPP_PROTO( (SORT SIn) ) \
    XPP_NOPROTO( (SIn) SORT SIn; ) \
  { \
    COMPONENTSORT Result; \
    if (SIn.Length > 0) { \
      Result = SIn.First->Data; \
      if (! SIn.IsAssigned) { \
        XCAT(yFree_,SORT)((void **)&SIn); \
      } \
    } else { \
      xReportStringError("First in String sort", "Length is zero") \
      (void)memset((void *)(&Result), 0, sizeof(COMPONENTSORT)); \
      XCAT(yDef_,COMPONENTSORT)(&Result); \
    } \
    return Result; \
  }


/*-- yLast_SORT (String)-------------------------------------------*/
#define String_Last(SORT, COMPONENTSORT) \
  COMPONENTSORT XCAT(yLast_,SORT) \
    XPP_PROTO( (SORT SIn) ) \
    XPP_NOPROTO( (SIn) SORT SIn; ) \
  { \
    COMPONENTSORT Result; \
    if (SIn.Length > 0) { \
      Result = SIn.Last->Data; \
      if (! SIn.IsAssigned) { \
        XCAT(yFree_,SORT)((void **)&SIn); \
      } \
    } else { \
      xReportStringError("Last in String sort", "Length is zero") \
      (void)memset((void *)(&Result), 0, sizeof(COMPONENTSORT)); \
      XCAT(yDef_,COMPONENTSORT)(&Result); \
    } \
    return Result; \
  }


/*-- yConcat_SORT (String)-----------------------------------------*/
#define String_Concat(SORT, COMPONENTSORT) \
  void XCAT(yAppend_,SORT) \
    XPP_PROTO( (SORT *result, SORT SIn) ) \
    XPP_NOPROTO( (result, SIn) SORT *result; SORT SIn; ) \
  { \
    XCAT(SORT,_yptr)  TempSVar, TempExpr; \
    \
    (*result).Length = (*result).Length + SIn.Length; \
    if (SIn.IsAssigned) { \
      TempExpr = SIn.First; \
      TempSVar = XCAT(yGetAvail_,SORT)(); \
      if ((*result).First == (XCAT(SORT,_yptr))0) \
        (*result).First = TempSVar; \
      else \
        (*result).Last->Suc = TempSVar; \
      XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
      \
      while (TempExpr->Suc != (XCAT(SORT,_yptr))0) { \
        TempExpr = TempExpr->Suc; \
        TempSVar->Suc = XCAT(yGetAvail_,SORT)(); \
        TempSVar = TempSVar->Suc; \
        XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
      } \
      (*result).Last = TempSVar; \
    } else { \
      if ((*result).First == (XCAT(SORT,_yptr))0) \
        (*result).First = SIn.First; \
      else \
        (*result).Last->Suc = SIn.First; \
      (*result).Last = SIn.Last; \
    } \
  } \
  \
  \
  SORT XCAT(yConcat_,SORT) \
    XPP_PROTO( (SORT S1, SORT S2) ) \
    XPP_NOPROTO( (S1, S2) SORT S1; SORT S2; ) \
  { \
    SORT result; \
    \
    result.First = (XCAT(SORT,_yptr))0; \
    result.Last = (XCAT(SORT,_yptr))0; \
    result.Length = 0; \
    result.IsAssigned = (xbool)0; \
    if (S1.Length == 0) { \
      if (S2.Length == 0) \
        return result; \
      else if (! S2.IsAssigned) \
        return S2; \
      else { \
        XCAT(yAppend_,SORT)(&result, S2); \
      } \
    } else if (S2.Length == 0) { \
      if (! S1.IsAssigned) \
        return S1; \
      else { \
        XCAT(yAppend_,SORT)(&result, S1);  \
      } \
    } else { \
      XCAT(yAppend_,SORT)(&result, S1); \
      XCAT(yAppend_,SORT)(&result, S2); \
    } \
    \
    return result; \
  }


/*-- ySubstring_SORT (String)--------------------------------------*/
#define String_Substring(SORT, COMPONENTSORT) \
  SORT XCAT(ySubString_,SORT) \
    XPP_PROTO( (SORT SIn, SDL_Integer Start, SDL_Integer SubLength) ) \
    XPP_NOPROTO( (SIn, Start, SubLength) SORT SIn; SDL_Integer Start; SDL_Integer SubLength; ) \
  { \
    SORT result; \
    XCAT(SORT,_yptr)  TempSVar, TempExpr; \
    int I; \
    \
    result.First = (XCAT(SORT,_yptr))0; \
    result.Last = (XCAT(SORT,_yptr))0; \
    result.Length = 0; \
    result.IsAssigned = (xbool)0; \
    if ( SIn.Length <= 0 ) { \
      xReportStringError("SubString in string sort", "Length is zero" ) \
    } else if ( Start <= 0 ) { \
      xReportStringError("SubString in string sort", \
                         "Start is less than or equal to zero" ) \
    } else if ( SubLength < 0 ) { \
      xReportStringError("SubString in string sort", \
                         "SubLength is less than zero" ) \
    } else if ( SubLength == 0 ) { \
      /* No error if length is 0 */ \
    } else if ( Start+SubLength-1 > SIn.Length ) { \
      xReportStringError("SubString in string sort", \
        "Start+Substring-1 length is greater than string length" ) \
    } else { \
      TempExpr = SIn.First; \
      for (I=1; I<Start; I++) TempExpr = TempExpr->Suc; \
      TempSVar = XCAT(yGetAvail_,SORT)(); \
      result.First = TempSVar; \
      XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
      \
      for (I=2; I<=SubLength; I++) { \
        TempExpr = TempExpr->Suc; \
        TempSVar->Suc = XCAT(yGetAvail_,SORT)(); \
        TempSVar = TempSVar->Suc; \
        XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
      } \
      result.Last = TempSVar; \
      result.Length = SubLength; \
    } \
    if (! SIn.IsAssigned && SIn.First != (XCAT(SORT,_yptr))0) { \
      XCAT(yFree_,SORT)((void **)&SIn); \
    } \
    return result; \
  }



/*-- yModify_SORT (String)-----------------------------------------*/
#define String_Modify(SORT, COMPONENTSORT) \
  COMPONENTSORT *XCAT(yAddr_,SORT) \
    XPP_PROTO( (SORT *SIn, SDL_Integer Index) ) \
    XPP_NOPROTO( (SIn, Index) SORT *SIn; SDL_Integer Index; ) \
  { \
    COMPONENTSORT *result; \
    XCAT(SORT,_yptr) Temp; \
    if ((*SIn).Length == 0) { \
      xReportStringError("Modify of component of string sort", \
                         "String is empty. Returns default value" ) \
      result = (COMPONENTSORT *)xAlloc((xptrint)sizeof(COMPONENTSORT)); \
      XCAT(yDef_,COMPONENTSORT)(result); \
      return result; \
    } else { \
      if (Index > (*SIn).Length) { \
        xReportStringError("Modify of component of string sort", \
                           "Index > string length. Index set to 1" ) \
        Index = 1; \
      } \
      if (Index <= (SDL_Integer)0) { \
        xReportStringError("Modify of component of string sort", \
                           "Index <= 0. Index set to 1" ) \
        Index = 1; \
      } \
      Temp = (*SIn).First; \
      for (; Index>1; Index--) Temp = Temp->Suc; \
      if (! (*SIn).IsAssigned && (*SIn).First != (XCAT(SORT,_yptr))0) { \
        XCAT(yFree_,SORT)((void **)SIn); \
      } \
      return &Temp->Data; \
    } \
  }


/*-- yExtr_SORT (String)--------------------------------------------*/
#define String_Extract(SORT, COMPONENTSORT) \
  COMPONENTSORT XCAT(yExtr_,SORT) \
    XPP_PROTO( (SORT SIn, SDL_Integer Index) ) \
    XPP_NOPROTO( (SIn, Index) SORT SIn; SDL_Integer Index; ) \
  { \
    COMPONENTSORT result; \
    XCAT(SORT,_yptr) Temp; \
    if (SIn.Length == 0) { \
      xReportStringError("Extract in string sort", \
                         "String is empty. Returns default value" ) \
      (void)memset((void *)(&result), 0, sizeof(COMPONENTSORT)); \
      XCAT(yDef_,COMPONENTSORT)(&result); \
      return result; \
    } else { \
      if (Index > SIn.Length) { \
        xReportStringError("Extract in string sort", \
                           "Index > string length. Index set to 1" ) \
        Index = 1; \
      } \
      if (Index <= (SDL_Integer)0) { \
        xReportStringError("Extract in string sort", \
                           "Index <= 0. Index set to 1" ) \
        Index = 1; \
      } \
      Temp = SIn.First; \
      for (; Index>1; Index--) Temp = Temp->Suc; \
      if (! SIn.IsAssigned && SIn.First != (XCAT(SORT,_yptr))0) { \
        XCAT(yFree_,SORT)((void **)&SIn); \

⌨️ 快捷键说明

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