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

📄 vspolicy.c

📁 IBE是一种非对称密码技术
💻 C
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
 */

#include "vibe.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "vspolicy.h"

#include <stdio.h>
#include <stdlib.h>

static char *m_vs_copy_buf (VoltLibCtx *libCtx, char *temp);

mVsClientPolicyT *m_vs_cp_new (
   VtLibCtx libraryCtx,
   char *xml
   )
{
  VoltLibCtx *libCtx = (VoltLibCtx *)libraryCtx;
  mVsClientPolicyT *newCp = (mVsClientPolicyT *)0;

  /* Allocate space for the mVsClientPolicyT.
   */
  newCp = (mVsClientPolicyT *)Z3Malloc (sizeof (mVsClientPolicyT));
  if (newCp == (mVsClientPolicyT *)0)
    return ((mVsClientPolicyT *)0);
  Z2Memset (newCp, 0, sizeof (mVsClientPolicyT));
  newCp->libCtx = libCtx;

  /* Call the VSClient version.
   */
  newCp->cp = vs_cp_new (xml, libCtx);

  /* If success, return what we created.
   */
  if (newCp->cp != (vsClientPolicyT *)0)
    return (newCp);

  /* If not successful, free up what we allocated.
   */
  Z2Free (newCp);
  return ((mVsClientPolicyT *)0);
}

void m_vs_cp_free (
   mVsClientPolicyT *cp
   )
{
  VoltLibCtx *libCtx;

  /* Anything to free.
   */
  if (cp == (mVsClientPolicyT *)0)
    return;

  libCtx = cp->libCtx;
  vs_cp_free (cp->cp, libCtx);
  Z2Free (cp);
}

/* Functions that return char * actually return pointers to allocated
 * space. Free that memory by calling m_vs_free_memory.
 */

int m_vs_cp_get_version (mVsClientPolicyT *cp)
{
  return (vs_cp_get_version (cp->cp, cp->libCtx));
}

int m_vs_cp_is_local_policy_locked (mVsClientPolicyT *cp)
{
  return (vs_cp_is_local_policy_locked (cp->cp, cp->libCtx));
}

char *m_vs_cp_get_primary_domain (mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_primary_domain (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

int m_vs_cp_is_local_domain (mVsClientPolicyT *cp, char *domain)
{
  return (vs_cp_is_local_domain (cp->cp, domain, cp->libCtx));
}

int m_vs_cp_get_default_district (mVsClientPolicyT *cp)
{
  return (vs_cp_get_default_district (cp->cp, cp->libCtx));
}

int m_vs_cp_is_user_on_whitelist (mVsClientPolicyT *cp, char *user)
{
  return (vs_cp_is_user_on_whitelist (cp->cp, user, cp->libCtx));
}

int m_vs_cp_is_user_provisioned(mVsClientPolicyT *cp, char *user)
{
  return (vs_cp_is_user_provisioned(cp->cp, user, cp->libCtx));
}

char *m_vs_cp_get_provisioned_district(mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_provisioned_district (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

char *m_vs_cp_get_fallthrough_district (mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_fallthrough_district (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

char *m_vs_cp_get_message_header_internal (mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_message_header_internal (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

char *m_vs_cp_get_message_header_external (mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_message_header_external (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

char *m_vs_cp_get_message_footer (mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_message_footer (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

int m_vs_cp_get_parameter_refresh_rate_negative (mVsClientPolicyT *cp)
{
  return (vs_cp_get_parameter_refresh_rate_negative (cp->cp, cp->libCtx));
}

int m_vs_cp_get_parameter_refresh_rate_positive (mVsClientPolicyT *cp)
{
  return (vs_cp_get_parameter_refresh_rate_positive (cp->cp, cp->libCtx));
}

int m_vs_cp_is_parameter_retrieval_aggressive
   (mVsClientPolicyT *cp, char *domain)
{
  return (vs_cp_is_parameter_retrieval_aggressive (cp->cp, domain, cp->libCtx));
}

int m_vs_cp_is_parameter_checking_strict (mVsClientPolicyT *cp)
{
  return (vs_cp_is_parameter_checking_strict(cp->cp, cp->libCtx));
}

int m_vs_cp_is_trusted_district (mVsClientPolicyT *cp, char *district)
{
  return (vs_cp_is_trusted_district (cp->cp, district, cp->libCtx));
}

int m_vs_cp_get_password_caching_mode (mVsClientPolicyT *cp)
{
  return (vs_cp_get_password_caching_mode (cp->cp, cp->libCtx));
}

int m_vs_cp_get_decryption_mode (mVsClientPolicyT *cp)
{
  return (vs_cp_get_decryption_mode (cp->cp, cp->libCtx));
}

int m_vs_cp_get_universal_reader_mode (mVsClientPolicyT *cp)
{
  return (vs_cp_get_universal_reader_mode (cp->cp, cp->libCtx));
}

char *m_vs_cp_get_client_setting
   (mVsClientPolicyT *cp, char *client, char *key)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_client_setting (cp->cp, client, key, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

char *m_vs_cp_get_zfr_template (mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_zfr_template (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

char *m_vs_cp_get_zdm2_template (mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_zdm2_template (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

char *m_vs_cp_get_html_message_body_template (mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_html_message_body_template (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

char *m_vs_cp_get_encrypt_rules (mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_encrypt_rules (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
   */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);
}

int m_vs_cp_get_key_purge_time (mVsClientPolicyT *cp)
{
  return (vs_cp_get_key_purge_time (cp->cp, cp->libCtx));
}

char *m_vs_cp_get_defaultZDM (mVsClientPolicyT *cp)
{
  char *temp = (char *)0;
  char *retVal = (char *)0;
  VoltLibCtx *libCtx = cp->libCtx;

  /* Get the new buffer from the VSClient.
   */
  temp = vs_cp_get_defaultZDM (cp->cp, cp->libCtx);
  if (temp == (char *)0)
    return ((char *)0);

  /* Copy it into a buffer that uses the libCtx.
  */
  retVal = m_vs_copy_buf (cp->libCtx, temp);

  Z2Free (temp);

  return (retVal);

}

char *m_vs_copy_buf (VoltLibCtx *libCtx, char *temp)
{
  unsigned int tempLen;
  char *retVal = (char *)0;

  /* Copy the input using the libCtx. It needs a NULL-terminating
   * character.
   */
  tempLen = Z2Strlen (temp);
  retVal = (char *)Z2Malloc (tempLen + 1, 0);
  if (retVal == (char *)0)
    return ((char *)0);
  Z2Memcpy (retVal, temp, tempLen);
  retVal[tempLen] = 0;

  return (retVal);
}

/* Call this function to free any memory allocated by any of the m_vs
 * routines.
 */
void m_vs_free_memory (mVsClientPolicyT *cp, char *buf)
{
  VoltLibCtx *libCtx = cp->libCtx;

  Z2Free (buf);
}

⌨️ 快捷键说明

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