[Setup-tool-hackers] internetsharing-conf and other stuff.




This e-mail is to report that the internetsharing backend is ready (tested
on Mandrake-7.2, and should work on RedHat >= 6.2). I need people to give
it a try. 

I'll post a schema file on backend/doc/xsd/internetsharing.xsd shortly to
tell you how to set the XML for the --set operation. internet-share.xsd
will be deleted.

Also, I want to tell you about the new xst_file functions I've created
that will make our life a little bit easier:

XML PRINTING

* xst_xml_print_array (array, tag) will print you a <tag>element</tag>
  line for every element in the array.

* xst_xml_print_hash (hash, tag) now calls print_array if any of the hash
  elements is a ref to array.

I'll code a recursive xst_xml_print_structure (scalar, tag) that will
print xml of any kind of perl structure you may pass to it:

$a = { "hello" => ["hola", "ciao"], 
       "bye" => {"english" => "goodbye",
                 "spanish" => "adios"},
       "mytag" => 0
}

xst_xml_print_structure ($a, "mystuff") will print:

<mystuff>
 <hello>hola</hello>
 <hello>ciao</hello>
 <bye>
  <english>goodbye</english>
  <spanish>adios</spanish>
 </bye>
 <mytag>0</mytag>
</mystuff>

It's quite simple, and could make xml printing of the backends that use
the parse/replace tables quite trivial: you would just have to call this
function with the hash that the conf_get function returns.

PIPING

I've created three convenience functions that avoid having to use local
*FD and takes advantage of locate_tool all in one:

xst_file_run_pipe_read, xst_file_run_pipe_write and xst_file_run_backtick.

The run_pipe functions make this code:

{
  local *BLAH;
  my $tool;

  $tool = &xst_file_locate_tool ("ls");
  open BLAH, "$tool 2>/dev/null |";

  etc, etc
}

into

{
  my $fd;

  $fd = &xst_file_run_pipe_read ("ls");
  
  etc, etc.
}

This makes the actual run of the program being logged and converts the
"ls" command into "PATH=$PATH:/sbin:/usr/sbin /bin/ls 2>/dev/null", which
is less prone to fail and takes that burden from you.

Almost all the code in the current backends has been changed to use this.

xst_file_run_backtick replaces doing $a = `ls` for $a =
&xst_file_run_backtick ("ls"). The "ls" command will suffer the same
changes I wrote above.

Sorry for the lack of object-orientedness.

Greetings,
Arturo


_______________________________________________
setup-tool-hackers maillist  -  setup-tool-hackers@ximian.com
http://lists.ximian.com/mailman/listinfo/setup-tool-hackers



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]