python-module/cpplmodule.cc
/**
 * Compress an uncompressed cppl policy.
 */
Compress an uncompressed cppl policy.
Compress an uncompressed cppl policy .
static PyObject *cpplmodule_compress_policy(PyObject *self, PyObject *args)
{
  PyObject *retval;
  long long pd_key;
  char *policy, *compressed_policy_mem;
  int compressed_policy_mem_len;
  PolicyDefinition *pd;
  Binary *compressed_policy;
  if (!PyArg_ParseTuple(args, "sL", &policy, &pd_key)) {
    return NULL;
  }
  bool traceParsingEnabled = false;
  bool traceScanningEnabled = false;
  pd = pd_list.at(pd_key);
  try {
    compressed_policy = cppl_compress_policy(policy, *pd, traceParsingEnabled, traceScanningEnabled);
  }
  catch (std::runtime_error e) {
    return PyErr_Format(CpplError, "%s", e.what());
  }
  if(!compressed_policy) {
    return PyErr_Format(CpplError, "Compression failed");
  }
  compressed_policy_mem = (char *)compressed_policy->getPointer();
  compressed_policy_mem_len = ceil((double)compressed_policy->size() / 8);
  retval = Py_BuildValue("s#", compressed_policy_mem, compressed_policy_mem_len);
  delete compressed_policy;
  return retval;
}
static PyObject * cpplmodule_compress_policy ( PyObject * self , PyObject * args ) { PyObject * retval ; long long pd_key ; char * policy , * compressed_policy_mem ; int compressed_policy_mem_len ; PolicyDefinition * pd ; Binary * compressed_policy ; if ( ! PyArg_ParseTuple ( args , " " , & policy , & pd_key ) ) { return NULL ; } bool traceParsingEnabled = false ; bool traceScanningEnabled = false ; pd = pd_list . at ( pd_key ) ; try { compressed_policy = cppl_compress_policy ( policy , * pd , traceParsingEnabled , traceScanningEnabled ) ; } catch ( std :: runtime_error e ) { return PyErr_Format ( CpplError , " " , e . what ( ) ) ; } if ( ! compressed_policy ) { return PyErr_Format ( CpplError , " " ) ; } compressed_policy_mem = ( char * ) compressed_policy -> getPointer ( ) ; compressed_policy_mem_len = ceil ( ( double ) compressed_policy -> size ( ) / 8 ) ; retval = Py_BuildValue ( " " , compressed_policy_mem , compressed_policy_mem_len ) ; delete compressed_policy ; return retval ; }
Compress an uncompressed cppl policy.
Compress an uncompressed cppl policy .