Bundesamt für Sicherheit in der Informationstechnik > Dicop-Base-3.05 > Dicop::Base

Download:
dicop/Dicop-Base-3.05.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 3.05   Source  

NAME ^

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

SYNOPSIS ^

        use Dicop::Base;

REQUIRES ^

perl5.008, Exporter

EXPORTS ^

Exports nothing on default.

DESCRIPTION ^

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.

METHODS ^

cfg_default

        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.

cfg_level

        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

Encode a string that contains characters other than A-Z,a-z,0-9 etc with %XX formats (or '+' instead of spaces).

decode

        my $decoded = decode($encoded);

Decode a string containing + (space) and %XX (hex) as produced by encode().

cache_time

Use time() to get the current time and cache this value.

time

        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.

a2h

Convert "ab" to "6566".

h2a

Convert "656667" to "abc".

parseFormArgs

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_file

Read a text file (given as complete path/name) and return a reference to the data read.

write_file

        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_list

Read a text file with lists (given as complete path/name) and return areference to the data read.

read_dir()

        my @files = Dicop::Base::read_dir($directory);

Return a list of all files and directories in the given directory.

read_table_template

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.

replace_templates

Take a ref to a text template and a hash containing keys, and replace occurances of ##key## in the text with the value.

ago

From a given amount of time in seconds, creates a string reporting it in seconds/mins/hours/days as appropriate.

simple_ago

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

        $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

        $cpuinfo = Dicop::Base::cpuinfo($self, $no_warn);

Gather cpu info like model, speed etc and return as string suitable for sending to server.

BUGS ^

None known yet.

AUTHOR ^

(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.