
Dicop::Base - basics for a Dicop HTTP server/client

use Dicop::Base;

perl5.008, Exporter

Exports nothing on default.

This is a base package that contains everything neccessary to have an HTTP server bind to a port, running under a specific user/group and answering Dicop::Requests.
Also contains an assortment of often used or handy support routines used by the server/proxy and the client.

Dicop::Base::cfg_default ( $self, $hash );
Given a set of keys and their values (a list or hash reference), sets these values as default in the internal cfg object (stored in config), unless the key is already defined there.
Dicop::Base::cfg_level ( $cfg, qw/log_level debug_level .../ );
Given a cfg hash and a set of keys, will convert the keys from a format like 1+2+32 to the sum of the elements. Works good for bitfields given as a sum of 2 ** X numbers.
Encode a string that contains characters other than A-Z,a-z,0-9 etc with %XX formats (or '+' instead of spaces).
my $decoded = decode($encoded);
Decode a string containing + (space) and %XX (hex) as produced by encode().
Use time() to get the current time and cache this value.
my $time = Dicop::time();
Return the time cached by cache_time(). Subsequent calls to time will result in the same time, unless you call Dicop::cache_time() again.
Convert "ab" to "6566".
Convert "656667" to "abc".
This parses the formular data the browser/client/user send us (either by using GET, POST, or an supplied string) and breaks it into parameters. Returns a hash which keys are the parameters, and the values the corrosponding data.
Read a text file (given as complete path/name) and return a reference to the data read.
write_file( $path_to_file, \$contents);
Given a filename (with path), and a reference to a scalar, write $contents to $path_to_file. If the directories do not exist, the routine attempts to create them before writing the file.
Read a text file with lists (given as complete path/name) and return areference to the data read.
my @files = Dicop::Base::read_dir($directory);
Return a list of all files and directories in the given directory.
Reads a file containing a table template, which contains a table and one row of the table between <T> and </TR>. Returns reference to empty table with ##table## at the place of the template, and the template for one row.
The following template:
<TABLE>
<TR>
<TD>##field##<TD>##description##
</TR>
</TABLE>
would result in the template-text of:
<TABLE>
##table##
</TABLE>
and the template for one row:
<TR>
<TD>##field##<TD>##description##
</TR>
From this you can then create tables with more than one row.
Take a ref to a text template and a hash containing keys, and replace occurances of ##key## in the text with the value.
From a given amount of time in seconds, creates a string reporting it in seconds/mins/hours/days as appropriate.
From a given time difference, create a string reporting it in seconds/mins/hours/days as appropriate. Unlike ago(), it only reports one piece of time like "1 day", or "3 hours".
$random_bytes = Dicop::random(128); # get 128 random bytes
Returns X pseudo-random bytes. These are taken either from /dev/urandom or from chained calles to rand() if /dev/urandom is not available or could not be used.
$cpuinfo = Dicop::Base::cpuinfo($self, $no_warn);
Gather cpu info like model, speed etc and return as string suitable for sending to server.

None known yet.

(c) Bundesamt fuer Sicherheit in der Informationstechnik 1998-2008
DiCoP is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
See the file LICENSE or http://www.bsi.de/ for more information.