Module Hivex
In: ext/hivex/_hivex.c

Initialize the module.

Methods

open  

Classes and Modules

Class Hivex::Error
Class Hivex::Hivex

Public Class methods

open a hive file

Opens the hive named "filename" for reading.

Flags is an ORed list of the open flags (or 0 if you don‘t want to pass any flags). These flags are defined:

HIVEX_OPEN_VERBOSE Verbose messages.

HIVEX_OPEN_DEBUG Very verbose messages, suitable for debugging problems in the library itself.

This is also selected if the "HIVEX_DEBUG" environment variable is set to 1.

HIVEX_OPEN_WRITE Open the hive for writing. If omitted, the hive is read-only.

See "WRITING TO HIVE FILES" in hivex(3).

(For the C API documentation for this function, see hivex_open).

[Source]

/*
 * call-seq:
 *   Hivex::open(filename, flags) -> Hivex::Hivex
 *
 * open a hive file
 *
 * Opens the hive named "filename" for reading.
 * 
 * Flags is an ORed list of the open flags (or 0 if you
 * don't want to pass any flags). These flags are defined:
 * 
 * HIVEX_OPEN_VERBOSE
 * Verbose messages.
 * 
 * HIVEX_OPEN_DEBUG
 * Very verbose messages, suitable for debugging
 * problems in the library itself.
 * 
 * This is also selected if the "HIVEX_DEBUG"
 * environment variable is set to 1.
 * 
 * HIVEX_OPEN_WRITE
 * Open the hive for writing. If omitted, the hive is
 * read-only.
 * 
 * See "WRITING TO HIVE FILES" in hivex(3).
 *
 *
 * (For the C API documentation for this function, see
 * +hivex_open+[http://libguestfs.org/hivex.3.html#hivex_open]).
 */
static VALUE
ruby_hivex_open (VALUE modulev, VALUE filenamev, VALUE flagsv)
{
  const char *filename = StringValueCStr (filenamev);
  int flags = 0;
  if (RTEST (rb_hash_lookup (flagsv, ID2SYM (rb_intern ("verbose")))))
    flags += 1;
  if (RTEST (rb_hash_lookup (flagsv, ID2SYM (rb_intern ("debug")))))
    flags += 2;
  if (RTEST (rb_hash_lookup (flagsv, ID2SYM (rb_intern ("write")))))
    flags += 4;

  hive_h *r;

  r = hivex_open (filename, flags);

  if (r == NULL)
    rb_raise (e_Error, "%s", strerror (errno));

  return Data_Wrap_Struct (c_hivex, NULL, ruby_hivex_free, r);
}

[Validate]