Pgreet::DaemonUtils - Penguin Greetings shared routines related to daemon
# Constructor: $Pg_daemon = new Pgreet::DaemonUtils($Pg_default_config, $Pg_error);
# Compute number of days since 1997 to "age" ecards $DateCode = $Pg_daemon->GetDateCode();
# Back up any number of database files $Pg_daemon->backup_db_files($db_file-1, $db_file-2, $db_file-3, $db_file-4 ... );
# Copy any number of database files from one location to another $Pg_daemon->copy_db_files($src_path, $dst_path, $db_file-1, $db_file-2, $db_file-3, $db_file-4 ... );
# Copy the database records (using Berkeley DB) from one path to another $Pg_daemon->copy_db_records($db_file, $src_path, $dst_path);
# Purge database of ecard records older than $DateLimit $Pg_daemon->purge_old_cards($path, $DateLimit, $card_name_file, $name_passwd_file, $card_data_file );
# Backup and purge old records in one step. $Pg_daemon->backup_db_purge_old($path, $DateLimit, $card_name_file, $name_passwd_file, $card_data_file );
The module Pgreet::DaemonUtils
is the Penguin
Greetings module for any routines that must be shared between
the application daemon and command line utilities. This avoids
unnecessary code duplication. All of these routines involve
database manipulation at this time.
The Pgreet::DaemonUtils
constructor should be
called after a Penguin Greeting configuration object
Pgreet::Config
and error object
Pgreet::Error
has been made. Since
Pgreet::DaemonUtils
does not use the configuration
configuration information for some of it's routines, It is
possible to pass it an undef
in a command line
utility that is its ``configuration-free'' routines. An example
constructor call is below:
# Constructor: $Pg_daemon = new Pgreet::DaemonUtils($Pg_default_config, $Pg_error);
The object methods for manipulating Berkeley DB databases
and related activities included in
Pgreet::DaemonUtils
are described below:
GetDateCode()
DateCode
is included in the information when a
card is created. So subtracting the cards DateCode from
today's DateCode provides the number of days the card has
been in the database. This method is a simple function and
returns the DateCode. A simple call is below:# Compute number of days since 1997 to "age" ecards $DateCode = $Pg_daemon->GetDateCode();
backup_db_files()
.bak
. It is used to create backup files of the
database files before manipulating them. It takes any number
of file arguments as seen in the sample call below:# Back up any number of database files $Pg_daemon->backup_db_files($db_file-1, $db_file-2, $db_file-3, $db_file-4 ... );
copy_db_files()
# Copy any number of database files from one location to another $Pg_daemon->copy_db_files($src_path, $dst_path, $db_file-1, $db_file-2, $db_file-3, $db_file-4 ... );
copy_db_records()
# Copy the database records (using Berkeley DB) from one path to another $Pg_daemon->copy_db_records($db_file, $src_path, $dst_path);
purge_old_cards()
# Purge database of ecard records older than $DateLimit $Pg_daemon->purge_old_cards($path, $DateLimit, $card_name_file, $name_passwd_file, $card_data_file );
backup_db_purge_old()
backup_db_files
and
purge_old_cards
. It
first makes a backup copy of every database file with backup_db_files
and then it performs the purging of old ecards with purge_old_cards
. The
arguments are identical with purge_old_cards
as
can be seen in the sample call below.# Backup and purge old records in one step. $Pg_daemon->backup_db_purge_old($path, $DateLimit, $card_name_file, $name_passwd_file, $card_data_file );
This method exists mainly to standardize calling schemes between the application daemon and command line utilties.
Copyright (c) 2004-2005 Edouard Lagache
This software is released under the GNU General Public License, Version 2. For more information, see the COPYING file included with this software or visit: http://www.gnu.org/copyleft/gpl.html
No known bugs at this time.
Edouard Lagache <pgreetdev@canebas.org>
1.0.0
syslog, Pgreet, the Pgreet::Config manpage, the Pgreet::Error manpage, the Log::Dispatch manpage, the Log::Dispatch::File manpage, the Log::Dispatch::Syslog manpage, the CGI::Carp manpage