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

📄 sctpred.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:

  C_length = xLength_SDL_Charstring(C);
  Result.Length = C_length/2 + (C_length%2 == 1 ? 1 : 0);
  Result.IsAssigned = (xbool)0;
  Result.IsUsedInSignal = (xbool)0; /* FBI July-1998 */
  Result.Bits = xAlloc_SDL_Bit_String((xptrint)Result.Length);
  for (C_index=1; C_index<=C_length; C_index=C_index+2) {
    if ( '0' <= C[C_index] && C[C_index] <= '9') {
      res = 16 * ((int)(C[C_index]) - '0');
    } else if ( 'A' <= C[C_index] && C[C_index] <= 'F') {
      res = 16 * ((int)(C[C_index]) - 'A' + 10);
    } else if ( 'a' <= C[C_index] && C[C_index] <= 'f') {
      res = 16 * ((int)(C[C_index]) - 'a' + 10);
    } else {
#ifdef XECSOP
      xSDLOpError("HexStr in sort Octet_String",
                  "Illegal character in Charstring (not digit or a-f)." );
#endif
      res = 0;
    }

    if (C_index<C_length) {
      if ( '0' <= C[C_index+1] && C[C_index+1] <= '9') {
        res = res + ((int)(C[C_index+1]) - '0');
      } else if ( 'A' <= C[C_index+1] && C[C_index+1] <= 'F') {
        res = res + ((int)(C[C_index+1]) - 'A' + 10);
      } else if ( 'a' <= C[C_index+1] && C[C_index+1] <= 'f') {
        res = res + ((int)(C[C_index+1]) - 'a' + 10);
      } else {
#ifdef XECSOP
        xSDLOpError("HexStr in sort Octet_String",
                    "Illegal character in Charstring (not digit or a-f)." );
#endif
      }
    }
    Result.Bits[(C_index-1)/2] = (unsigned char)res;
  }
  return Result;
}


/*---+---------------------------------------------------------------
     xBit_String_SDL_Octet_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Bit_String xBit_String_SDL_Octet_String (
  SDL_Octet_String S )
#else
SDL_Bit_String xBit_String_SDL_Octet_String ( S )
  SDL_Octet_String S;
#endif
{
  SDL_Bit_String Result;
  int i;

  Result.Length = S.Length*8;
  Result.IsAssigned = (xbool)0;
  Result.IsUsedInSignal = (xbool)0; 
  if (Result.Length == 0) {
    Result.Bits = 0;
    return Result;
  }
  Result.Bits = xAlloc_SDL_Bit_String((xptrint)Result.Length);

  for (i=0; i<Result.Length; i=i+8) {
    Result.Bits[i]   = (unsigned char)( S.Bits[i/8]/128);
    Result.Bits[i+1] = (unsigned char)((S.Bits[i/8]/64)%2);
    Result.Bits[i+2] = (unsigned char)((S.Bits[i/8]/32)%2);
    Result.Bits[i+3] = (unsigned char)((S.Bits[i/8]/16)%2);
    Result.Bits[i+4] = (unsigned char)((S.Bits[i/8]/8)%2);
    Result.Bits[i+5] = (unsigned char)((S.Bits[i/8]/4)%2);
    Result.Bits[i+6] = (unsigned char)((S.Bits[i/8]/2)%2);
    Result.Bits[i+7] = (unsigned char)( S.Bits[i/8]%2);
  }
  return Result;
}

/*---+---------------------------------------------------------------
     xOctet_String_SDL_Octet_String
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Octet_String xOctet_String_SDL_Octet_String (
  SDL_Bit_String S )
#else
SDL_Octet_String xOctet_String_SDL_Octet_String ( S )
  SDL_Bit_String S;
#endif
{
  SDL_Octet_String Result;
  int i;

  Result.Length = S.Length/8 + (S.Length%8>0 ? 1 : 0);
  Result.IsAssigned = (xbool)0;
  Result.IsUsedInSignal = (xbool)0; 
  if (Result.Length == 0) {
    Result.Bits = 0;
    return Result;
  }
  Result.Bits = xAlloc_SDL_Bit_String((xptrint)Result.Length);

  for (i=0; i<S.Length; i++) {
    Result.Bits[i/8] <<= 1;
    Result.Bits[i/8] += S.Bits[i];
  }
  for ( ; i%8 != 0; i++) {
    Result.Bits[i/8] <<= 1;    /* Extending with 0, not 1 as Z105 */
  }
  return Result;
}

#endif
       /* XNOUSEOFOCTETBITSTRING */


/*** Charstring ****************************************************/

#ifndef XNOUSEOFCHARSTRING

#if defined(XSCT_CADVANCED) || defined(XSCT_CBASIC)

/*---+---------------------------------------------------------------
     xAss_SDL_Charstring
-------------------------------------------------------------------*/
#ifndef XNOPROTO
void xAss_SDL_Charstring(
  SDL_Charstring *CVar,
  SDL_Charstring  CExpr,
  int             AssType )
#else
void xAss_SDL_Charstring( CVar, CExpr, AssType )
  SDL_Charstring *CVar;
  SDL_Charstring  CExpr;
  int             AssType;
#endif
{
  if (AssType == XASS) {
    if (*CVar != CExpr) {
      if (*CVar != (SDL_Charstring)0)
        xFree_SDL_Charstring((void **)CVar);
      if (CExpr == (SDL_Charstring)0)
        *CVar = (SDL_Charstring)0;
      else if (CExpr[0] == 'T') {
        CExpr[0] = 'V';
        *CVar = CExpr;
      } else {
       *CVar = xAlloc_SDL_Charstring((xptrint)(strlen(CExpr)+1));
        (void)strcpy(*CVar, CExpr);
        (*CVar)[0] = 'V';
      }
    }
  } else {
    if (CExpr == (SDL_Charstring)0)
      *CVar = (SDL_Charstring)0;
    else if (CExpr[0] == 'T' && AssType == XASSMAKE)
      *CVar = CExpr;
    else {
     *CVar = xAlloc_SDL_Charstring((xptrint)(strlen(CExpr)+1));
      (void)strcpy(*CVar, CExpr);
      (*CVar)[0] = 'T';
    }
  }
}

#else /* then XSCT_CMICRO */

#ifndef XRESTUSEOFCHARSTRING

#ifndef XNOPROTO
extern void xAss_SDL_Charstring(
  SDL_Charstring *CVar,
  SDL_Charstring  CExpr,
  int             AssType )
#else
extern void xAss_SDL_Charstring( CVar, CExpr, AssType )
  SDL_Charstring *CVar;
  SDL_Charstring  CExpr;
  int             AssType;
#endif
{
  SDL_Boolean Is_XASSPARA = SDL_False;

  if (AssType == XASSPARA)
  {
    /*
    ** Default setting of charstring variable - used in the
    ** case of output only (corrected by fbi at april-1997)
    */
    *CVar = (SDL_Charstring)0; /* set default for this variable */
                               /* needed for Cadvanced in tight */
                               /* integration and Cmicro in     */
                               /* general                       */
    Is_XASSPARA = SDL_True; /* to remember on that later */
    AssType = XASS ;
  }
 
  if (AssType == XASS) {
    if (*CVar != CExpr) {
      if (*CVar != (SDL_Charstring)0)
        xFree_SDL_Charstring((void **)CVar);
      if (CExpr == (SDL_Charstring)0)
        *CVar = (SDL_Charstring)0;
      else
        if ((CExpr[0] == 'T') || (CExpr[0] == 'P')) {
        /* assign the source pointer to dest.variable */
        /* and mark charstring variable with "V"      */ 
        CExpr[0] = 'V';
        *CVar = CExpr;
      } else {
       *CVar = xAlloc_SDL_Charstring((xptrint)(strlen(CExpr)+1));
        (void)strcpy(*CVar, CExpr);
        (*CVar)[0] = 'V';
        if (Is_XASSPARA)
          (*CVar)[0] = 'P'; /* if charstring as signalparameter in output, free this after reception */ 
      }
    }
  } else {
    if (AssType == XASSCOPY)
    {   
      /*
      ** Used for FPAR IN in a PRD when a local copy of IN par has to be created
      */
      if (CExpr == (SDL_Charstring)0)
      {
        /* if a null pointer value is sent down to procedure */
        *CVar = xAlloc_SDL_Charstring((xptrint)(2));
      }
      else
      {
        *CVar = xAlloc_SDL_Charstring((xptrint)(strlen(CExpr)+1));
        (void)strcpy(*CVar, CExpr);
      }
      (*CVar)[0] = 'V';
    }
    else
    {
      if (CExpr == (SDL_Charstring)0)
        *CVar = (SDL_Charstring)0;
      else if (CExpr[0] == 'T' && AssType == XASSMAKE)
      *CVar = CExpr;
      else {
       *CVar = xAlloc_SDL_Charstring((xptrint)(strlen(CExpr)+1));
        (void)strcpy(*CVar, CExpr);
        (*CVar)[0] = 'T';
        if (Is_XASSPARA)
          (*CVar)[0] = 'P'; /* if charstring as signalparameter in output, free this after reception */
      }
    }
  }
}

#endif /* ... XRESTUSEOFCHARSTRING */
 
#endif /* ... defined(XSCT_CADVANCED) || defined(XSCT_CBASIC) */

#if defined(XSCT_CADVANCED) || defined(XSCT_CBASIC) || (defined(XSCT_CMICRO) && ! defined(XRESTUSEOFCHARSTRING))

/*---+---------------------------------------------------------------
     xEq_SDL_Charstring
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Boolean xEq_SDL_Charstring(
  SDL_Charstring C1,
  SDL_Charstring C2 )
#else
SDL_Boolean xEq_SDL_Charstring( C1, C2 )
  SDL_Charstring C1;
  SDL_Charstring C2;
#endif
{
  SDL_Boolean Result;

  if ( ((C1 == (SDL_Charstring)0) || (strlen(C1) <= (unsigned)1)) &&
       ((C2 == (SDL_Charstring)0) || (strlen(C2) <= (unsigned)1)) )
    Result = SDL_true;
  else if ( (C1 == (SDL_Charstring)0) || (C2 == (SDL_Charstring)0) )
    Result = SDL_false;
  else if (strcmp(C1+1, C2+1) == 0)
    Result = SDL_true;
  else
    Result = SDL_false;

  if (C1 != (SDL_Charstring)0 && C1[0] == 'T')
    xFree_SDL_Charstring((void **)&C1);
  if (C2 != (SDL_Charstring)0 && C2[0] == 'T')
    xFree_SDL_Charstring((void **)&C2);
  return Result;
}


/*---+---------------------------------------------------------------
     xMkString_SDL_Charstring
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Charstring xMkString_SDL_Charstring(
  SDL_Character C )
#else
SDL_Charstring xMkString_SDL_Charstring( C )
  SDL_Character C;
#endif
{
  SDL_Charstring Result;

  if ( C == SDL_NUL ) {
#ifdef XECSOP
    xSDLOpError( "MkString in sort Charstring",
                 "Character NUL not allowed." );
#endif
    return (SDL_Charstring)0;
  }
  Result = xAlloc_SDL_Charstring((xptrint)(sizeof(C)+2));
  Result[0] = 'T';
  Result[1] = C;
  return Result;
}


/*---+---------------------------------------------------------------
     xMod_SDL_Charstring
-------------------------------------------------------------------*/

/* No longer used by generated code */

#ifndef XNOPROTO
SDL_Charstring xMod_SDL_Charstring(
  SDL_Charstring  C,
  SDL_Integer     Index,
  SDL_Character   Value )
#else
SDL_Charstring xMod_SDL_Charstring( C, Index, Value )
  SDL_Charstring  C;
  SDL_Integer     Index;
  SDL_Character   Value;
#endif
{
  if ( (C == (SDL_Charstring)0) || (Index<=0) || ((unsigned)Index>=strlen(C)) ) {
#ifdef XECSOP
    xSDLOpError("Modify! in sort Charstring", "Index out of bounds." );
#endif
    return C;
  }
  if ( Value == SDL_NUL ) {
#ifdef XECSOP
    xSDLOpError("Modify! in sort Charstring",
                "Character NUL not allowed." );
#endif
    return C;
  }
  C[Index] = Value;
  return C;
}


/*---+---------------------------------------------------------------
     yAddr_SDL_Charstring
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Character * yAddr_SDL_Charstring(
  SDL_Charstring *C,
  SDL_Integer     Index)
#else
SDL_Character * yAddr_SDL_Charstring( C, Index )
  SDL_Charstring *C;
  SDL_Integer     Index;
#endif
{
  if ( (*C == (SDL_Charstring)0) || (Index<=0) ||
       ((unsigned)Index>=strlen(*C)) ) {
#ifdef XECSOP
    xSDLOpError("Modify! in sort Charstring",
                "Index out of bounds." );
#endif
    if (*C != (SDL_Charstring)0)
      return &((*C)[1]);
    else
      return (SDL_Character *)xAlloc((xptrint)2);  /* ??? */
  } else
    return &((*C)[Index]);
}


/*---+---------------------------------------------------------------
     xExtr_SDL_Charstring
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Character xExtr_SDL_Charstring(
  SDL_Charstring  C,
  SDL_Integer     Index )
#else
SDL_Character xExtr_SDL_Charstring( C, Index )
  SDL_Charstring  C;
  SDL_Integer     Index;
#endif
{
  char Result;
  if ( (C == (SDL_Charstring)0) || (Index<=0) || ((unsigned)Index>=strlen(C)) ) {
#ifdef XECSOP
    xSDLOpError("Extract! in sort Charstring",
                "Index out of bounds." );
#endif
    Result = SDL_NUL;
  } else
    Result = C[Index];
  if (C != (SDL_Charstring)0 && C[0] == 'T')
    xFree_SDL_Charstring((void **)&C);
  return Result;
}


/*---+---------------------------------------------------------------
     xConcat_SDL_Charstring
-------------------------------------------------------------------*/
#ifndef XNOPROTO
SDL_Charstring xConcat_SDL_Charstring(
  SDL_Charstring  C1,
  SDL_Charstring  C2 )
#else
SDL_Charstring xConcat_SDL_Charstring( C1, C2 )
  SDL_Charstring  C1;
  SDL_Charstring  C2;
#endif
{
  SDL_Charstring Result;

  if (C1 == (SDL_Charstring)0) {
    if (C2 == (SDL_Charstring)0)
      return (SDL_Charstring)0;
    else if (C2[0] == 'T')
      return C2;
    else {
      Result = xAlloc_SDL_Charstring((xptrint)(strlen(C2)+1));
      (void)strcpy(Result, C2);

⌨️ 快捷键说明

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