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

📄 caix.c

📁 brew代码里面的一个文件
💻 C
📖 第 1 页 / 共 5 页
字号:
 ((caii_ext_disp_type *) msg_ptr)->num_disp_recs = 0;
#endif

 /* ------------------------------------------------------
 ** Here comes the hard part. The variable part of
 ** this record can contain variable length sub-records.
 ** To avoid excessive RAM requirement, the internal
 ** format is tightly packed. Be very careful when
 ** unpack the internal format !!!
 ** ------------------------------------------------------ */
 rec_ptr = &(((caii_ext_disp_type *)msg_ptr)->var[0]);

 while ( (end_pos - msg_pos) >= sizeof(cai_ext_disp_var1_type)) /*lint !e574*/
 {

#ifdef FEATURE_MSG_PACK_UNIT_TEST
   ((caii_ext_disp_type *) msg_ptr)->num_disp_recs += 1;
#endif

   ((caii_ext_disp_var_type *) rec_ptr)->display_tag =
        b_unpackb( buf_ptr, msg_pos,
                 FSIZ( cai_ext_disp_var1_type, display_tag ));
   msg_pos += FSIZ( cai_ext_disp_var1_type, display_tag );

   ((caii_ext_disp_var_type *) rec_ptr)->display_len = len = b_unpackb( buf_ptr, msg_pos,
                 FSIZ( cai_ext_disp_var1_type, display_len ));
   msg_pos += FSIZ( cai_ext_disp_var1_type, display_len );

   if ((((caii_ext_disp_var_type *) rec_ptr)->display_tag != CAI_EXT_DISP_BLANK)  &&
       (((caii_ext_disp_var_type *) rec_ptr)->display_tag != CAI_EXT_DISP_SKIP)
      )
   {
      for(i=0; (i<len) && (msg_pos<end_pos); i++ )
      {
         ((caii_ext_disp_var_type *) rec_ptr)->chari[i] =
            b_unpackb( buf_ptr, msg_pos,
                      FSIZ( cai_ext_disp_var2_type, chari ));
         msg_pos += FSIZ( cai_ext_disp_var2_type, chari );
      }
      /* update length (use i incase loop ended because we hit the msg end) */
      ((caii_ext_disp_var_type *) rec_ptr)->display_len = (byte)i;

      if (i != len)
      { /* we hit the message end before the subrecord length */
        /* something is wrong */
        status = CAIX_INV_LEN_S;
        /* fix up the message pointer */
        rec_ptr = *message_ptr + (rec_len / 8);
        break; /* stop processing this record */
      }
      /* ----------------------------------------------
       ** One more record - calculate addition length
       ** ---------------------------------------------- */
      ((caii_ext_disp_type *) msg_ptr)->fix.rec_len+=
         (byte)FPOS(caii_ext_disp_var_type,chari) +
         ((caii_ext_disp_var_type *)rec_ptr)->display_len;

       /* --------------------------------------------------
      ** Update sub-record pointer in the internal format
      ** -------------------------------------------------- */
      rec_ptr += FENDPOS( caii_ext_disp_var_type,
         chari[((caii_ext_disp_var_type *)rec_ptr)->display_len - 1] );

   }
   else
   {
      // we are here because the display_tag was CAI_EXT_DISP_BLANK or CAI_EXT_DISP_SKIP

      // Normally, in this case, the BS will set display_len to 0, but in case it does
      // not, the following line forces it to be.
      // we make the display_len = 0 here so we don't have to perform the BLANK or SKIP
      // check any further up the chain at CM.
#ifndef FEATURE_MSG_PACK_UNIT_TEST
      ((caii_ext_disp_var_type *) rec_ptr)->display_len = 0;
#endif
      rec_ptr += FENDPOS( caii_ext_disp_var_type, display_len);
   }

 } // while()

 /* Update the pointer position inside the message which is
    being parsed */
 msg_pos = end_pos;
 *msg_pos_ptr = msg_pos;

 /* now update the pointer to the output message */
 *message_ptr = rec_ptr;

 return ( status );
}  /* xlate_ext_ext_disp_rec */


#ifdef FEATURE_IS2000_REL_A
#error code not present
#endif /* FEATURE_IS2000_REL_A */

/* <EJECT> */
/*===========================================================================

FUNCTION XLATE_EXT_INFO

DESCRIPTION
  This function translates a Traffic Channel Alert With Information
  or Flash With Information Message from external to internal format.

DEPENDENCIES
  Assumes that the internal message type received as an input to the
  procedure already includes the Alert With Information or Flash With
  Information message type.

RETURN VALUE
  Errors that were encountered while translating the message.

SIDE EFFECTS
  None

===========================================================================*/

word xlate_ext_info
(
  word len,
    /* Length of message in bits */
  byte *buf_ptr,
    /* Pointer to received message to be translated */
  caii_rx_msg_type *int_ptr
    /* Pointer to place where translated message should be placed */
)
{
  word status;
    /* Status returned to calling procedure */
  byte i;
    /* Index */
  word msg_pos;
    /* Position of record in message */
  byte *msg_ptr;
    /* Pointer to position inside internal message type */
  byte rec_type;
    /* Temporary storage for record type */
  word rec_len;
    /* Temporary storage for record length */

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* --------------------------------------------
  ** Determine if message is of sufficient length
  ** -------------------------------------------- */
  if (len < sizeof( cai_alert_fix_type )
#ifdef FEATURE_IS2000_REL_A
#error code not present
#endif
     )
  {
    status = CAIX_INV_LEN_S;
  }

  else {
    /* default status at this point is OK, unless overridden during
       message processing */
    status = CAIX_DONE_S;

    /* -----------------------------------------------------------------
    ** Length is OK --> Convert message from external to internal format
    ** starting with the first field after message_type
    ** ----------------------------------------------------------------- */
    xlate_ext_tc_hdr( buf_ptr, &int_ptr->alert.hdr );

#ifdef FEATURE_IS2000_REL_A
#error code not present
#else
     /* Mark end of fixed part of message */
     msg_pos = FENDPOS( cai_alert_fix_type, hdr.encryption );

#endif /* FEATURE_IS2000_REL_A */
     /* now msg_pos points to the start of msg */
     /* Initialize number of records to 0 */
     int_ptr->alert.num_recs = 0;
     msg_ptr = (byte*)(&int_ptr->alert.recs[0]);

     while (((len - msg_pos) > sizeof( cai_rec_hdr_type )) && /*lint !e574*/
           (status == CAIX_DONE_S))
     {
      /* ------------------------------
      ** Unpack message type and length
      ** ------------------------------ */
      ((caii_rec_hdr_type *) msg_ptr)->record_type = rec_type =
          b_unpackb( buf_ptr, msg_pos, FSIZ( cai_rec_hdr_type, record_type ));
      msg_pos += FSIZ( cai_rec_hdr_type, record_type );

      /* -------------------------
      ** Get record length in bits
      ** ------------------------- */
      rec_len = b_unpackb( buf_ptr, msg_pos,
                           FSIZ( cai_rec_hdr_type, record_len )) * 8;
      msg_pos += FSIZ( cai_rec_hdr_type, record_len );

      if ((rec_len + msg_pos) > len) {
        /* ---------------------
        ** Record length invalid
        ** --------------------- */
        status = CAIX_INV_LEN_S;
        break;
      }

      else {
        /* --------------------------------------
        ** Attempt to parse information record(s)
        ** -------------------------------------- */
        switch (rec_type) {
          case CAI_DISPLAY_REC:
            /* --------------------------
            ** Display Information Record
            ** -------------------------- */
            ((caii_display_rec_type *) msg_ptr)->fix.num_char =
               (byte) (rec_len / sizeof( cai_display_rec_var_type ));

            for (i=0;
                 i < ((caii_display_rec_type *) msg_ptr)->fix.num_char; i++)
            {
              ((caii_display_rec_type *) msg_ptr)->var[i] =
                 b_unpackb( buf_ptr, msg_pos,
                            FSIZ( cai_display_rec_var_type, chari ));
              msg_pos += FSIZ( cai_display_rec_var_type, chari );
            }

            /* -------------------------------------------------
            ** Increment internal message pointer to next record
            ** ------------------------------------------------- */
            msg_ptr += FENDPOS( caii_display_rec_type,
              var[((caii_display_rec_type *) msg_ptr)->fix.num_char - 1] );

            int_ptr->alert.num_recs++;
            break;

          case CAI_CALLED_REC:
            /* --------------------------------------
            ** Called Party Number Information Record
            ** -------------------------------------- */
            ((caii_called_rec_type *) msg_ptr)->fix.number_type =
               b_unpackb( buf_ptr, msg_pos,
                          FSIZ( cai_called_fix_type, number_type ));
            msg_pos += FSIZ( cai_called_fix_type, number_type);

            ((caii_called_rec_type *) msg_ptr)->fix.number_plan =
              b_unpackb( buf_ptr, msg_pos,
                         FSIZ( cai_called_fix_type, number_plan ));
            msg_pos += FSIZ( cai_called_fix_type, number_plan);

            ((caii_called_rec_type *) msg_ptr)->fix.num_char =
               (byte) ((rec_len - sizeof( cai_called_fix_type )) /
                          sizeof( cai_called_var_type ));

            for (i=0;
                 i < ((caii_called_rec_type *) msg_ptr)->fix.num_char; i++)
            {
              ((caii_called_rec_type *) msg_ptr)->var[i] =
                b_unpackb( buf_ptr, msg_pos,
                           FSIZ( cai_called_var_type, chari ));
               msg_pos += FSIZ( cai_called_var_type, chari );
            }

            /* ----------------------------------------------------------
            ** Increment internal message pointer to point to next record
            ** ---------------------------------------------------------- */
            msg_ptr += FENDPOS( caii_called_rec_type,
              var[((caii_called_rec_type *) msg_ptr)->fix.num_char - 1] );

            msg_pos += 1;  /* Increment past reserved bit at end */

            int_ptr->alert.num_recs++;
            break;

          case CAI_CALLING_REC:
          case CAI_CONNECT_REC:
            /* -----------------------------------------------------------
            ** Calling Party Number or Connected Number Information Record
            ** ----------------------------------------------------------- */
            ((caii_calling_rec_type *) msg_ptr)->fix.number_type =
               b_unpackb( buf_ptr, msg_pos,
                          FSIZ( cai_calling_fix_type, number_type ));
            msg_pos += FSIZ( cai_calling_fix_type, number_type);

            ((caii_calling_rec_type *) msg_ptr)->fix.number_plan =
               b_unpackb( buf_ptr, msg_pos,
                          FSIZ( cai_calling_fix_type, number_plan ));
            msg_pos += FSIZ( cai_calling_fix_type, number_plan );

            ((caii_calling_rec_type *) msg_ptr)->fix.pi =
               b_unpackb( buf_ptr, msg_pos,
                          FSIZ( cai_calling_fix_type, pi ));
            msg_pos += FSIZ( cai_calling_fix_type, pi );

            ((caii_calling_rec_type *) msg_ptr)->fix.si =
               b_unpackb( buf_ptr, msg_pos,
                          FSIZ( cai_calling_fix_type, si ));
            msg_pos += FSIZ( cai_calling_fix_type, si );

            ((caii_calling_rec_type *) msg_ptr)->fix.num_char =
               (byte) ((rec_len - sizeof( cai_calling_fix_type )) /
                          sizeof( cai_calling_var_type ));

            for (i=0;
                 i < ((caii_calling_rec_type *) msg_ptr)->fix.num_char; i++)
            {
              ((caii_calling_rec_type *) msg_ptr)->var[i] =
                 b_unpackb( buf_ptr, msg_pos,
                            FSIZ( cai_calling_var_type, chari ));
              msg_pos += FSIZ( cai_calling_var_type, chari );
            }

            /* -------------------------------
            ** Update internal message pointer
            ** ------------------------------- */
            msg_ptr += FENDPOS( caii_calling_rec_type,
              var[((caii_calling_rec_type *) msg_ptr)->fix.num_char - 1] );

            msg_pos += 5;  /* Increment past reserved bits at end */

            int_ptr->alert.num_recs++;
            break;

          case CAI_SIGNAL_REC:
            /* -------------------------
            ** Signal Information Record
            ** ------------------------- */
            ((caii_signal_rec_type *) msg_ptr)->signal_type =
               b_unpackb( buf_ptr, msg_pos,
                          FSIZ( cai_signal_rec_type, signal_type ));
            msg_pos += FSIZ( cai_signal_rec_type, signal_type );

            ((caii_signal_rec_type *) msg_ptr)->alert_pitch

⌨️ 快捷键说明

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