s3-net: add command registry convert
authorGregor Beck <gbeck@sernet.de>
Mon, 20 Sep 2010 13:01:40 +0000 (15:01 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 22 Sep 2010 04:30:00 +0000 (06:30 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
docs-xml/manpages-3/net.8.xml
source3/utils/net_registry.c

index 529a7f70193fb9415a80212139a4955a2e951e9d..d648d5caaa0b9d81a8e4b5da1e86a0cb09c18911 100644 (file)
@@ -1642,6 +1642,8 @@ string.</member>
 </member>
 <member>net registry export      - Export a registration entries (.reg) file.
 </member>
+<member>net registry convert     - Convert a registration entries (.reg) file.
+</member>
 </simplelist>
 </para>
 
@@ -1760,6 +1762,16 @@ string.</member>
   </para>
 </refsect3>
 
+<refsect3>
+  <title>REGISTRY CONVERT <replaceable>in</replaceable> <!--
+  --><replaceable>out</replaceable> <!--
+  --><replaceable>[[inopt] outopt]</replaceable></title>
+
+  <para>Convert a registration entries (.reg) file <emphasis>in</emphasis>.
+  </para>
+</refsect3>
+
+
 </refsect2>
 
 <refsect2>
index 3c2e20e6ba60ec635ed9a6ec47e67512ccdf21d3..1139e45bef463aa543670010f797750af8f7a9ee 100644 (file)
@@ -1039,8 +1039,61 @@ done:
 }
 /**@}*/
 
+/******************************************************************************/
+/**
+ * @defgroup net_registry_convert Convert
+ * @ingroup net_registry
+ * @{
+ */
+
+static int net_registry_convert(struct net_context *c, int argc,
+                              const char **argv)
+{
+       int ret;
+       void* mem_ctx;
+       const char* in_opt  = NULL;
+       const char* out_opt = NULL;
+
+       if (argc < 2 || argc > 4|| c->display_usage) {
+               d_printf("%s\n%s",
+                        _("Usage:"),
+                        _("net registry convert <in> <out> [in_opt] [out_opt]\n"
+                          "net registry convert <in> <out> [out_opt]\n"));
+               d_printf("%s\n%s",
+                        _("Example:"),
+                        _("net registry convert in.reg out.reg regedit4,enc=CP1252\n"));
+               return -1;
+       }
+
+       mem_ctx = talloc_stackframe();
+
+       switch (argc ) {
+       case 2:
+               break;
+       case 3:
+               out_opt = argv[2];
+               break;
+       case 4:
+               out_opt = argv[3];
+               in_opt  = argv[2];
+               break;
+       default:
+               assert(false);
+       }
+
+
+       ret = reg_parse_file(argv[0], (struct reg_parse_callback*)
+                            reg_format_file(mem_ctx, argv[1], out_opt),
+                            in_opt);
+
+       talloc_free(mem_ctx);
+
+       return ret;
+}
+/**@}*/
 
 /******************************************************************************/
+
 int net_registry(struct net_context *c, int argc, const char **argv)
 {
        int ret = -1;
@@ -1150,6 +1203,14 @@ int net_registry(struct net_context *c, int argc, const char **argv)
                        N_("net registry export\n"
                           "    Export .reg file")
                },
+               {
+                       "convert",
+                       net_registry_convert,
+                       NET_TRANSPORT_LOCAL,
+                       N_("Convert .reg file"),
+                       N_("net registry convert\n"
+                          "    Convert .reg file")
+               },
        { NULL, NULL, 0, NULL, NULL }
        };