python-module/cpplmodule.cc
/**
 * Get compressed cppl policy from memory.
 */
Get compressed cppl policy from memory.
Get compressed cppl policy from memory .
static PyObject *cpplmodule_read_compressed_cppl(PyObject *self, PyObject *args)
{
  PyObject *retval;
  char *ccpplDataBuf;
  int ccpplDataBuf_len;
  long long pd_key;
  PolicyDefinition *pd;
  PolicyStack *compressed_policy;
  Binary ccpplData;
  if (!PyArg_ParseTuple(args, "s#L", &ccpplDataBuf, &ccpplDataBuf_len, &pd_key)) {
    return NULL;
  }
  ccpplData.read_from_mem(ccpplDataBuf, ccpplDataBuf_len * 8);
  pd = pd_list.at(pd_key);
  try {
    compressed_policy = cppl_read_compressed_cppl(ccpplData, pd);
  }
  catch (std::runtime_error e) {
    return PyErr_Format(CpplError, "%s", e.what());
  }
  catch (std::string s) {
    return PyErr_Format(CpplError, "%s", s.c_str());
  }
  long long ps_key = (long long)compressed_policy;
  ps_list[ps_key] = compressed_policy;
  retval = Py_BuildValue("L", ps_key);
  return retval;
}
static PyObject * cpplmodule_read_compressed_cppl ( PyObject * self , PyObject * args ) { PyObject * retval ; char * ccpplDataBuf ; int ccpplDataBuf_len ; long long pd_key ; PolicyDefinition * pd ; PolicyStack * compressed_policy ; Binary ccpplData ; if ( ! PyArg_ParseTuple ( args , " " , & ccpplDataBuf , & ccpplDataBuf_len , & pd_key ) ) { return NULL ; } ccpplData . read_from_mem ( ccpplDataBuf , ccpplDataBuf_len * 8 ) ; pd = pd_list . at ( pd_key ) ; try { compressed_policy = cppl_read_compressed_cppl ( ccpplData , pd ) ; } catch ( std :: runtime_error e ) { return PyErr_Format ( CpplError , " " , e . what ( ) ) ; } catch ( std :: string s ) { return PyErr_Format ( CpplError , " " , s . c_str ( ) ) ; } long long ps_key = ( long long ) compressed_policy ; ps_list [ ps_key ] = compressed_policy ; retval = Py_BuildValue ( " " , ps_key ) ; return retval ; }
Get compressed cppl policy from memory.
Get compressed cppl policy from memory .