r23711: Refactor the actual creation of object into its own small function.
authorMichael Adam <obnox@samba.org>
Wed, 4 Jul 2007 23:21:51 +0000 (23:21 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:23:47 +0000 (12:23 -0500)
Michael
(This used to be commit 26349c0b173e8baf6fa43deb39cb2bfdb31bf18e)

examples/scripts/users_and_groups/createdomobj.pl

index 4bcfb8edf3e29ba3bc70d56ed45c08f06adea7fd..6568b216642f304f0b179f40f304f1075eeae62d 100755 (executable)
@@ -116,7 +116,7 @@ if (@ARGV) {
        exit 1;
 }
 
        exit 1;
 }
 
-# rpc open/close functions:
+# utility functions:
 
 sub open_rpc_pipe {
        print "opening rpc pipe\n";
 
 sub open_rpc_pipe {
        print "opening rpc pipe\n";
@@ -129,20 +129,22 @@ sub close_rpc_pipe {
        close(IPC);
 }
 
        close(IPC);
 }
 
+sub do_create {
+       my $target_name = shift;
+       print "creating $target_type $target_name\n";
+       print IPC "$rpc_cmd $target_name\n";
+}
+
 # main:
 
 open_rpc_pipe();
 
 if ("x$startnum" eq "x") {
 # main:
 
 open_rpc_pipe();
 
 if ("x$startnum" eq "x") {
-       my $target_name = $prefix;
-       print "creating $target_type $target_name\n";
-       print IPC "$rpc_cmd $target_name\n";
+       do_create($prefix);
 }
 else {
        for (my $num = 1; $num <= $num_targets; ++$num) {
 }
 else {
        for (my $num = 1; $num <= $num_targets; ++$num) {
-               my $target_name = sprintf "%s%.05d", $prefix, $startnum + $num - 1;
-               print "creating $target_type $target_name\n";
-               print IPC "$rpc_cmd $target_name\n";
+               do_create(sprintf "%s%.05d", $prefix, $startnum + $num - 1);
                if (($num) % 500 == 0) {
                        printf("500 ".$target_type."s created\n");
                        close_rpc_pipe();
                if (($num) % 500 == 0) {
                        printf("500 ".$target_type."s created\n");
                        close_rpc_pipe();
@@ -151,5 +153,6 @@ else {
                }
        }
 }
                }
        }
 }
+
 close_rpc_pipe();
 
 close_rpc_pipe();