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

📄 policyinfo.c

📁 voltage 公司提供的一个开发Ibe的工具包
💻 C
📖 第 1 页 / 共 3 页
字号:
    }
    else
    {
      value = m_vs_cp_get_message_footer (
        localPolicyCtx->vsPolicyObj);
    }

    if (value == (char *)0)
      break;

    /* There is a value. Allocate space for a VtItem and a copy of the
     * value and return it.
     */
    status = VT_ERROR_MEMORY;
    valueLen = Z2Strlen (value);
    bufferSize = sizeof (VtItem) + valueLen;
    buffer = Z2Malloc (bufferSize, 0);
    if (buffer == (unsigned char *)0)
      break;
    Z2Memset (buffer, 0, bufferSize);
    retVal = (VtItem *)buffer;

    /* Point the data to the space after the VtItem, it's a byte
     * array, no need to worry about alignment.
     */
    retVal->data = buffer + sizeof (VtItem);

    Z2Memcpy (retVal->data, value, valueLen);
    retVal->len = valueLen;
 
    *result = retVal;

    status = 0;

  } while (0);

  if (value != (char *)0)
    m_vs_free_memory (localPolicyCtx->vsPolicyObj, value);

  return (status);
}

static int MessageHeaderInternalAlloc (
   VoltPolicyCtx *ctx,
   VoltLibCtx *libCtx,
   VtItem **result
   )
{
  int status;
  unsigned int bufferSize, valueLen;
  VoltDefaultPolicyCtx *localPolicyCtx =
    (VoltDefaultPolicyCtx *)(ctx->localCtx);
  char *value = (char *)0;
  unsigned char *buffer = (unsigned char *)0;
  VtItem *retVal;

  do
  {
    /* This checks the XML data. If the return is null, there is no
     * ZDR template.
     */
    status = 0;
    value = m_vs_cp_get_message_header_internal (localPolicyCtx->vsPolicyObj);

    if (value == (char *)0)
      break;

    /* There is a value. Allocate space for a VtItem and a copy of the
     * value and return it.
     */
    status = VT_ERROR_MEMORY;
    valueLen = Z2Strlen (value);
    bufferSize = sizeof (VtItem) + valueLen;
    buffer = Z2Malloc (bufferSize, 0);
    if (buffer == (unsigned char *)0)
      break;
    Z2Memset (buffer, 0, bufferSize);
    retVal = (VtItem *)buffer;

    /* Point the data to the space after the VtItem, it's a byte
     * array, no need to worry about alignment.
     */
    retVal->data = buffer + sizeof (VtItem);

    Z2Memcpy (retVal->data, value, valueLen);
    retVal->len = valueLen;

    *result = retVal;

    status = 0;

  } while (0);

  if (value != (char *)0)
    m_vs_free_memory (localPolicyCtx->vsPolicyObj, value);

  return (status);
}

static int MessageHeaderExternalAlloc (
   VoltPolicyCtx *ctx,
   VoltLibCtx *libCtx,
   VtItem **result
   )
{
  int status;
  unsigned int bufferSize, valueLen;
  VoltDefaultPolicyCtx *localPolicyCtx =
    (VoltDefaultPolicyCtx *)(ctx->localCtx);
  char *value = (char *)0;
  unsigned char *buffer = (unsigned char *)0;
  VtItem *retVal;

  do
  {
    /* This checks the XML data. If the return is null, there is no
     * ZDR template.
     */
    status = 0;
    value = m_vs_cp_get_message_header_external (localPolicyCtx->vsPolicyObj);

    if (value == (char *)0)
      break;

    /* There is a value. Allocate space for a VtItem and a copy of the
     * value and return it.
     */
    status = VT_ERROR_MEMORY;
    valueLen = Z2Strlen (value);
    bufferSize = sizeof (VtItem) + valueLen;
    buffer = Z2Malloc (bufferSize, 0);
    if (buffer == (unsigned char *)0)
      break;
    Z2Memset (buffer, 0, bufferSize);
    retVal = (VtItem *)buffer;

    /* Point the data to the space after the VtItem, it's a byte
     * array, no need to worry about alignment.
     */
    retVal->data = buffer + sizeof (VtItem);

    Z2Memcpy (retVal->data, value, valueLen);
    retVal->len = valueLen;

    *result = retVal;

    status = 0;

  } while (0);

  if (value != (char *)0)
    m_vs_free_memory (localPolicyCtx->vsPolicyObj, value);

  return (status);
}

static int ZdrTemplateAlloc (
   VoltPolicyCtx *ctx,
   VoltLibCtx *libCtx,
   VtItem **result
   )
{
  int status;
  unsigned int bufferSize, valueLen;
  VoltDefaultPolicyCtx *localPolicyCtx =
    (VoltDefaultPolicyCtx *)(ctx->localCtx);
  char *value = (char *)0;
  unsigned char *buffer = (unsigned char *)0;
  VtItem *retVal;

  do
  {
    /* This checks the XML data. If the return is null, there is no
     * ZDR template.
     */
    status = 0;
    value = m_vs_cp_get_zfr_template (localPolicyCtx->vsPolicyObj);

    if (value == (char *)0)
      break;

    /* There is a value. Allocate space for a VtItem and a copy of the
     * value and return it.
     */
    status = VT_ERROR_MEMORY;
    valueLen = Z2Strlen (value);
    bufferSize = sizeof (VtItem) + valueLen;
    buffer = Z2Malloc (bufferSize, 0);
    if (buffer == (unsigned char *)0)
      break;
    Z2Memset (buffer, 0, bufferSize);
    retVal = (VtItem *)buffer;

    /* Point the data to the space after the VtItem, it's a byte
     * array, no need to worry about alignment.
     */
    retVal->data = buffer + sizeof (VtItem);

    Z2Memcpy (retVal->data, value, valueLen);
    retVal->len = valueLen;

    *result = retVal;

    status = 0;

  } while (0);

  if (value != (char *)0)
    m_vs_free_memory (localPolicyCtx->vsPolicyObj, value);

  return (status);
}

static int Zdm2TemplateAlloc (
   VoltPolicyCtx *ctx,
   VoltLibCtx *libCtx,
   VtItem **result
   )
{
  int status;
  unsigned int bufferSize, valueLen;
  VoltDefaultPolicyCtx *localPolicyCtx =
    (VoltDefaultPolicyCtx *)(ctx->localCtx);
  char *value = (char *)0;
  unsigned char *buffer = (unsigned char *)0;
  VtItem *retVal;

  do
  {
    /* This checks the XML data. If the return is null, there is no
     * ZDR template.
     */
    status = 0;
    value = m_vs_cp_get_zdm2_template (localPolicyCtx->vsPolicyObj);

    if (value == (char *)0)
      break;

    /* There is a value. Allocate space for a VtItem and a copy of the
     * value and return it.
     */
    status = VT_ERROR_MEMORY;
    valueLen = Z2Strlen (value);
    bufferSize = sizeof (VtItem) + valueLen;
    buffer = Z2Malloc (bufferSize, 0);
    if (buffer == (unsigned char *)0)
      break;
    Z2Memset (buffer, 0, bufferSize);
    retVal = (VtItem *)buffer;

    /* Point the data to the space after the VtItem, it's a byte
     * array, no need to worry about alignment.
     */
    retVal->data = buffer + sizeof (VtItem);

    Z2Memcpy (retVal->data, value, valueLen);
    retVal->len = valueLen;

    *result = retVal;

    status = 0;

  } while (0);

  if (value != (char *)0)
    m_vs_free_memory (localPolicyCtx->vsPolicyObj, value);

  return (status);
}

static int HTMLMessageBodyTemplateAlloc (
   VoltPolicyCtx *ctx,
   VoltLibCtx *libCtx,
   VtItem **result
   )
{
  int status;
  unsigned int bufferSize, valueLen;
  VoltDefaultPolicyCtx *localPolicyCtx =
    (VoltDefaultPolicyCtx *)(ctx->localCtx);
  char *value = (char *)0;
  unsigned char *buffer = (unsigned char *)0;
  VtItem *retVal;

  do
  {
    /* This checks the XML data. If the return is null, there is no
     * ZDR template.
     */
    status = 0;
    value = m_vs_cp_get_html_message_body_template (localPolicyCtx->vsPolicyObj);

    if (value == (char *)0)
      break;

    /* There is a value. Allocate space for a VtItem and a copy of the
     * value and return it.
     */
    status = VT_ERROR_MEMORY;
    valueLen = Z2Strlen (value);
    bufferSize = sizeof (VtItem) + valueLen;
    buffer = Z2Malloc (bufferSize, 0);
    if (buffer == (unsigned char *)0)
      break;
    Z2Memset (buffer, 0, bufferSize);
    retVal = (VtItem *)buffer;

    /* Point the data to the space after the VtItem, it's a byte
     * array, no need to worry about alignment.
     */
    retVal->data = buffer + sizeof (VtItem);

    Z2Memcpy (retVal->data, value, valueLen);
    retVal->len = valueLen;

    *result = retVal;

    status = 0;

  } while (0);

  if (value != (char *)0)
    m_vs_free_memory (localPolicyCtx->vsPolicyObj, value);

  return (status);
}

static int EncryptRulesAlloc (
   VoltPolicyCtx *ctx,
   VoltLibCtx *libCtx,
   VtItem **result
   )
{
  int status;
  unsigned int bufferSize, valueLen;
  VoltDefaultPolicyCtx *localPolicyCtx =
    (VoltDefaultPolicyCtx *)(ctx->localCtx);
  char *value = (char *)0;
  unsigned char *buffer = (unsigned char *)0;
  VtItem *retVal;

  do
  {
    /* This checks the XML data. If the return is null, there is no
     * ZDR template.
     */
    status = 0;
    value = m_vs_cp_get_encrypt_rules (localPolicyCtx->vsPolicyObj);

    if (value == (char *)0)
      break;

    /* There is a value. Allocate space for a VtItem and a copy of the
     * value and return it.
     */
    status = VT_ERROR_MEMORY;
    valueLen = Z2Strlen (value);
    bufferSize = sizeof (VtItem) + valueLen;
    buffer = Z2Malloc (bufferSize, 0);
    if (buffer == (unsigned char *)0)
      break;
    Z2Memset (buffer, 0, bufferSize);
    retVal = (VtItem *)buffer;

    /* Point the data to the space after the VtItem, it's a byte
     * array, no need to worry about alignment.
     */
    retVal->data = buffer + sizeof (VtItem);

    Z2Memcpy (retVal->data, value, valueLen);
    retVal->len = valueLen;

    *result = retVal;

    status = 0;

  } while (0);

  if (value != (char *)0)
    m_vs_free_memory (localPolicyCtx->vsPolicyObj, value);

  return (status);
}

static int DefaultZdrLocationAlloc (
   VoltPolicyCtx *ctx,
   VoltLibCtx *libCtx,
   VtItem **result
   )
{
  int status;
  unsigned int bufferSize, valueLen;
  VoltDefaultPolicyCtx *localPolicyCtx =
    (VoltDefaultPolicyCtx *)(ctx->localCtx);
  char *value = (char *)0;
  unsigned char *buffer = (unsigned char *)0;
  VtItem *retVal;

  do
  {
    /* This checks the XML data. If the return is null, there is no
     * default ZDR location.
     */
    status = 0;
    value = m_vs_cp_get_defaultZDM (localPolicyCtx->vsPolicyObj);

    if (value == (char *)0)
      break;

    /* There is a value. Allocate space for a VtItem and a copy of the
     * value and return it.
     */
    status = VT_ERROR_MEMORY;
    valueLen = Z2Strlen (value);
    bufferSize = sizeof (VtItem) + valueLen;
    buffer = Z2Malloc (bufferSize, 0);
    if (buffer == (unsigned char *)0)
      break;
    Z2Memset (buffer, 0, bufferSize);
    retVal = (VtItem *)buffer;

    /* Point the data to the space after the VtItem, it's a byte
     * array, no need to worry about alignment.
     */
    retVal->data = buffer + sizeof (VtItem);

    Z2Memcpy (retVal->data, value, valueLen);
    retVal->len = valueLen;

    *result = retVal;

    status = 0;

  } while (0);

  if (value != (char *)0)
    m_vs_free_memory (localPolicyCtx->vsPolicyObj, value);

  return (status);
}

static int DecryptPolicyAlloc (
   VoltPolicyCtx *ctx,
   VoltLibCtx *libCtx,
   int **result
   )
{
  int mode;
  int *theValue = (int *)0;
  VoltDefaultPolicyCtx *localPolicyCtx =
    (VoltDefaultPolicyCtx *)(ctx->localCtx);

  /* Allocate the space for an int, initialize to VOLT_AUTO_DECRYPT.
   */
  theValue = (int *)Z2Malloc (sizeof (int), 0);
  if (theValue == (int *)0)
    return (VT_ERROR_MEMORY);
  *theValue = VOLT_AUTO_DECRYPT;
  *result = theValue;

  /* This checks the XML data.
   * It returns a 0 for AUTO_DECRYPT. Any other return value will be
   * DECRYPT_ON_VIEW.
   */
  mode = m_vs_cp_get_decryption_mode (localPolicyCtx->vsPolicyObj);

  /* If mode is 0, we have theValue set properly, just return.
   */
  if (mode == 0)
    return (0);

  /* The mode is not AUTO, set it to ON_VIEW.
   */
  *theValue = VOLT_DECRYPT_ON_VIEW;

  return (0);
}

⌨️ 快捷键说明

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