Esempio n. 1
0
static PyObject *
py_hivex_open (PyObject *self, PyObject *args)
{
  PyObject *py_r;
  hive_h *r;
  char *filename;
  int flags;

  if (!PyArg_ParseTuple (args, (char *) "si:hivex_open", &filename, &flags))
    return NULL;
  r = hivex_open (filename, flags);
  if (r == NULL) {
    PyErr_SetString (PyExc_RuntimeError,
                     strerror (errno));
    return NULL;
  }

  py_r = put_handle (r);
  return py_r;
}
Esempio n. 2
0
/* Takes optional arguments, consult optargs_bitmask. */
int
do_hivex_open (const char *filename, int verbose, int debug, int write)
{
  CLEANUP_FREE char *buf = NULL;
  int flags = 0;

  if (h) {
    hivex_close (h);
    h = NULL;
  }

  buf = sysroot_path (filename);
  if (!buf) {
    reply_with_perror ("malloc");
    return -1;
  }

  if (optargs_bitmask & GUESTFS_HIVEX_OPEN_VERBOSE_BITMASK) {
    if (verbose)
      flags |= HIVEX_OPEN_VERBOSE;
  }
  if (optargs_bitmask & GUESTFS_HIVEX_OPEN_DEBUG_BITMASK) {
    if (debug)
      flags |= HIVEX_OPEN_DEBUG;
  }
  if (optargs_bitmask & GUESTFS_HIVEX_OPEN_WRITE_BITMASK) {
    if (write)
      flags |= HIVEX_OPEN_WRITE;
  }

  h = hivex_open (buf, flags);
  if (!h) {
    reply_with_perror ("hivex failed to open %s", filename);
    return -1;
  }

  return 0;
}
Esempio n. 3
0
int
main (int argc, char *argv[])
{
  hive_h *h = hivex_open ("../images/minimal", 0);
  return h == h ? 0 : 1;
}