Пример #1
0
guestfs_int_hivex_node_list *
do_hivex_node_children (int64_t nodeh)
{
  guestfs_int_hivex_node_list *ret;
  CLEANUP_FREE hive_node_h *r = NULL;
  size_t i, len;

  NEED_HANDLE (NULL);

  r = hivex_node_children (h, nodeh);
  if (r == NULL) {
    reply_with_perror ("failed");
    return NULL;
  }

  len = 0;
  for (i = 0; r[i] != 0; ++i)
    len++;

  ret = malloc (sizeof *ret);
  if (!ret) {
    reply_with_perror ("malloc");
    return NULL;
  }

  ret->guestfs_int_hivex_node_list_len = len;
  ret->guestfs_int_hivex_node_list_val =
    malloc (len * sizeof (guestfs_int_hivex_node));
  if (ret->guestfs_int_hivex_node_list_val == NULL) {
    reply_with_perror ("malloc");
    free (ret);
    return NULL;
  }

  for (i = 0; i < len; ++i)
    ret->guestfs_int_hivex_node_list_val[i].hivex_node_h = r[i];

  return ret;
}
Пример #2
0
static PyObject *
py_hivex_node_children (PyObject *self, PyObject *args)
{
  PyObject *py_r;
  hive_node_h *r;
  hive_h *h;
  PyObject *py_h;
  long node;

  if (!PyArg_ParseTuple (args, (char *) "Ol:hivex_node_children", &py_h, &node))
    return NULL;
  h = get_handle (py_h);
  r = hivex_node_children (h, node);
  if (r == NULL) {
    PyErr_SetString (PyExc_RuntimeError,
                     strerror (errno));
    return NULL;
  }

  py_r = put_node_list (r);
  free (r);
  return py_r;
}