header: Fix including just <hivex.h>.
[hivex.git] / generator / generator.ml
index 8f1f935..d8efc04 100755 (executable)
 
 (* This script generates language bindings and some documentation for
  * hivex.
- * 
+ *
  * After editing this file, run it (./generator/generator.ml) to
  * regenerate all the output files.  'make' will rerun this
  * automatically when necessary.  Note that if you are using a separate
  * build directory you must run generator.ml from the _source_
  * directory.
- * 
+ *
  * IMPORTANT: This script should NOT print any warnings.  If it prints
  * warnings, you should treat them as errors.
- * 
+ *
  * OCaml tips: (1) In emacs, install tuareg-mode to display and format
  * OCaml code correctly.  'vim' comes with a good OCaml editing mode by
  * default.  (2) Read the resources at http://ocaml-tutorial.org/
@@ -73,7 +73,7 @@ and argt =                              (* Note, cannot be NULL/0 unless it
 
 (* Hive types, from:
  * https://secure.wikimedia.org/wikipedia/en/wiki/Windows_Registry#Keys_and_values
- * 
+ *
  * It's unfortunate that in our original C binding we strayed away from
  * the names that Windows uses (eg. REG_SZ for strings).  We include
  * both our names and the Windows names.
@@ -158,6 +158,15 @@ but instead are lost.  See L<hivex(3)/WRITING TO HIVE FILES>.";
     "\
 Return root node of the hive.  All valid hives must contain a root node.";
 
+  "last_modified", (RInt64, [AHive]),
+    "return the modification time from the header of the hive",
+    "\
+Return the modification time from the header of the hive.
+
+The returned value is a Windows filetime.
+To convert this to a Unix C<time_t> see:
+L<http://stackoverflow.com/questions/6161776/convert-windows-filetime-to-second-in-unix-linux/6161842#6161842>";
+
   "node_name", (RString, [AHive; ANode "node"]),
     "return the name of the node",
     "\
@@ -170,6 +179,15 @@ only know the \"real\" name of the root node by knowing which registry
 file this hive originally comes from, which is knowledge that is
 outside the scope of this library.";
 
+  "node_timestamp", (RInt64, [AHive; ANode "node"]),
+    "return the modification time of the node",
+    "\
+Return the modification time of the node.
+
+The returned value is a Windows filetime.
+To convert this to a Unix C<time_t> see:
+L<http://stackoverflow.com/questions/6161776/convert-windows-filetime-to-second-in-unix-linux/6161842#6161842>";
+
   "node_children", (RNodeList, [AHive; ANode "node"]),
     "return children of node",
     "\
@@ -686,6 +704,7 @@ let rec generate_c_header () =
 #ifndef HIVEX_H_
 #define HIVEX_H_
 
+#include <stdlib.h>
 #include <stdint.h>
 
 #ifdef __cplusplus
@@ -841,7 +860,7 @@ hivex - Windows Registry \"hive\" extraction library
 =head1 SYNOPSIS
 
  #include <hivex.h>
+
 ";
   List.iter (
     fun (shortname, style, _, _) ->
@@ -1771,7 +1790,7 @@ static void raise_closed (const char *) Noreturn;
            pr "  rv = copy_type_value (r, len, t);\n";
            pr "  free (r);\n"
        | RInt32 -> pr "  rv = caml_copy_int32 (r);\n"
-       | RInt64 -> pr "  rv = caml_copy_int32 (r);\n"
+       | RInt64 -> pr "  rv = caml_copy_int64 (r);\n"
       );
 
       pr "  CAMLreturn (rv);\n";
@@ -3020,7 +3039,7 @@ initlibhivexmod (void)
   initialized = 1;
 }
 "
-  
+
 and generate_python_py () =
   generate_header HashStyle LGPLv2plus;