ADDED: new configfile parameter PrintLines (default: YES), which

controls wether listings are separated by horizontal lines.
This commit is contained in:
TLINDEN
2012-02-10 20:32:00 +01:00
parent 8779f24249
commit 7b47e6bb10
29 changed files with 7513 additions and 14 deletions

View File

0
blib/lib/.exists Normal file
View File

305
blib/lib/NOTEDB.pm Normal file
View File

@@ -0,0 +1,305 @@
#
# this is a generic module, used by note database
# backend modules.
#
# Copyright (c) 2000-2004 Thomas Linden <tom@daemon.de>
package NOTEDB;
use Exporter ();
use vars qw(@ISA @EXPORT $crypt_supported);
$NOTEDB::VERSION = "1.31";
BEGIN {
# make sure, it works, otherwise encryption
# is not supported on this system!
eval { require Crypt::CBC; };
if($@) {
$NOTEDB::crypt_supported = 0;
}
else {
$NOTEDB::crypt_supported = 1;
}
}
sub no_crypt {
$NOTEDB::crypt_supported = 0;
}
sub use_crypt {
my($this,$key,$method) = @_;
my($cipher);
if($NOTEDB::crypt_supported == 1) {
eval {
$cipher = new Crypt::CBC($key, $method);
};
if($@) {
print "warning: Crypt::$method not supported by system!\n";
$NOTEDB::crypt_supported = 0;
}
else {
$this->{cipher} = $cipher;
}
}
else{
print "warning: Crypt::CBC not supported by system!\n";
}
}
sub use_cache {
#
# this sub turns on cache support
#
my $this = shift;
$this->{use_cache} = 1;
$this->{changed} = 1;
}
sub cache {
#
# store the whole db as hash
# if use_cache is turned on
#
my $this = shift;
if ($this->{use_cache}) {
my %res = @_;
%{$this->{cache}} = %res;
}
}
sub unchanged {
#
# return true if $this->{changed} is true, this will
# be set to true by writing subs using $this->changed().
#
my $this = shift;
return 0 if(!$this->{use_cache});
if ($this->{changed}) {
$this->{changed} = 0;
return 0;
}
else {
print "%\n";
return 1;
}
}
sub changed {
#
# turn on $this->{changed}
# this will be used by update or create subs.
#
my $this = shift;
$this->{changed} = 1;
}
sub generate_search {
#
# get user input and create perlcode ready for eval
# sample input:
# "ann.a OR eg???on AND u*do$"
# resulting output:
# "$match = 1 if(/ann\.a/i or /eg...on/i and /u.*do\$/i );
#
my($this, $string) = @_;
my $case = "i";
if ($string =~ /^\/.+?\/$/) {
return $string;
}
elsif (!$string) {
return "/^/";
}
# we will get a / in front of the first word too!
$string = " " . $string . " ";
# check for apostrophs
$string =~ s/(?<=\s)(\(??)("[^"]+"|\S+)(\)??)(?=\s)/$1 . $this->check_exact($2) . $3/ge;
# remove odd spaces infront of and after <20>and<6E> and <20>or<6F>
$string =~ s/\s\s*(AND|OR)\s\s*/ $1 /g;
# remove odd spaces infront of <20>(<28> and after <20>)<29>
$string =~ s/(\s*\()/\(/g;
$string =~ s/(\)\s*)/\)/g;
# remove first and last space so it will not masked!
$string =~ s/^\s//;
$string =~ s/\s$//;
# mask spaces if not infront of or after <20>and<6E> and <20>or<6F>
$string =~ s/(?<!AND)(?<!OR)(\s+?)(?!AND|OR)/'\s' x length($1)/ge;
# add first space again
$string = " " . $string;
# lowercase AND and OR
$string =~ s/(\s??OR\s??|\s??AND\s??)/\L$1\E/g;
# surround brackets with at least one space
$string =~ s/(?<!\\)(\)|\()/ $1 /g;
# surround strings with slashes
$string =~ s/(?<=\s)(\S+)/ $this->check_or($1, $case) /ge;
# remove slashes on <20>and<6E> and <20>or<6F>
$string =~ s/\/(and|or)\/$case/$1/g;
# remove spaces inside /string/ constructs
$string =~ s/(?<!and)(?<!or)\s*\//\//g;
$string =~ s/\/\s*(?!and|or)/\//g;
#my $res = qq(\$match = 1 if($string););
return qq(\$match = 1 if($string););
#print $res . "\n";
#return $res;
}
sub check_or {
#
# surrounds string with slashes if it is not
# <20>and<6E> or <20>or<6F>
#
my($this, $str, $case) = @_;
if ($str =~ /^\s*(or|and)\s*$/) {
return " $str ";
}
elsif ($str =~ /(?<!\\)[)(]/) {
return $str;
}
else {
return " \/$str\/$case ";
}
}
sub check_exact {
#
# helper for generate_search()
# masks special chars if string
# not inside ""
#
my($this, $str) = @_;
my %wildcards = (
'*' => '.*',
'?' => '.',
'[' => '[',
']' => ']',
'+' => '\+',
'.' => '\.',
'$' => '\$',
'@' => '\@',
'/' => '\/',
'|' => '\|',
'}' => '\}',
'{' => '\{',
);
my %escapes = (
'*' => '\*',
'?' => '\?',
'[' => '[',
']' => ']',
'+' => '\+',
'.' => '\.',
'$' => '\$',
'@' => '\@',
'(' => '\(',
')' => '\)',
'/' => '\/',
'|' => '\|',
'}' => '\}',
'{' => '\{',
);
# mask backslash
$str =~ s/\\/\\\\/g;
if ($str =~ /^"/ && $str =~ /"$/) {
# mask bracket-constructs
$str =~ s/(.)/$escapes{$1} || "$1"/ge;
}
else {
$str =~ s/(.)/$wildcards{$1} || "$1"/ge;
}
$str =~ s/^"//;
$str =~ s/"$//;
# mask spaces
$str =~ s/\s/\\s/g;
return $str;
}
sub lock {
my ($this) = @_;
if (-e $this->{LOCKFILE}) {
open LOCK, "<$this->{LOCKFILE}" or die "could not open $this->{LOCKFILE}: $!\n";
my $data = <LOCK>;
close LOCK;
chomp $data;
print "-- waiting for lock by $data --\n";
print "-- remove the lockfile if you are sure: \"$this->{LOCKFILE}\" --\n";
}
my $timeout = 60;
eval {
local $SIG{ALRM} = sub { die "timeout" };
local $SIG{INT} = sub { die "interrupted" };
alarm $timeout - 2;
while (1) {
if (! -e $this->{LOCKFILE}) {
umask 022;
open LOCK, ">$this->{LOCKFILE}" or die "could not open $this->{LOCKFILE}: $!\n";
flock LOCK, LOCK_EX;
my $now = scalar localtime();
print LOCK "$ENV{USER} since $now (PID: $$)\n";
flock LOCK, LOCK_UN;
close LOCK;
alarm 0;
return 0;
}
printf " %0d\r", $timeout;
$timeout--;
sleep 1;
}
};
if($@) {
if ($@ =~ /^inter/) {
print " interrupted\n";
}
else {
print $@;
print " timeout\n";
}
return 1;
}
return 0;
}
sub unlock {
my ($this) = @_;
unlink $this->{LOCKFILE};
}
1;

7
blib/lib/NOTEDB/README Normal file
View File

@@ -0,0 +1,7 @@
perl modules for note used as database backends.
the install.sh script will install both of them,
although you may only need one backend. Perhaps
other users on your system have oter ideas in mind...
Therefore, please ignore these file. There is nothing
to edit or to do. Simply leave this directory :-)

487
blib/lib/NOTEDB/binary.pm Normal file
View File

@@ -0,0 +1,487 @@
#!/usr/bin/perl
# $Id: binary.pm,v 1.3 2000/08/11 00:05:58 zarahg Exp $
# Perl module for note
# binary database backend. see docu: perldoc NOTEDB::binary
#
package NOTEDB::binary;
$NOTEDB::binary::VERSION = "1.10";
use strict;
#use Data::Dumper;
use IO::Seekable;
use File::Spec;
use Fcntl qw(LOCK_EX LOCK_UN);
use NOTEDB;
use Exporter ();
use vars qw(@ISA @EXPORT);
@ISA = qw(NOTEDB Exporter);
sub new {
my($this, %param) = @_;
my $class = ref($this) || $this;
my $self = {};
bless($self,$class);
$self->{NOTEDB} = $param{dbname} || File::Spec->catfile($ENV{HOME}, ".notedb");
my $MAX_NOTE = $param{max_note} || 4096;
my $MAX_TIME = $param{max_time} || 64;
if(! -e $self->{NOTEDB}) {
open(TT,">$self->{NOTEDB}") or die "Could not create $self->{NOTEDB}: $!\n";
close (TT);
}
elsif(! -w $self->{NOTEDB}) {
print "$self->{NOTEDB} is not writable!\n";
exit(1);
}
my $TYPEDEF = "i a$MAX_NOTE a$MAX_TIME";
my $SIZEOF = length pack($TYPEDEF, () );
$self->{sizeof} = $SIZEOF;
$self->{typedef} = $TYPEDEF;
$self->{maxnote} = $MAX_NOTE;
$self->{LOCKFILE} = $self->{NOTEDB} . "~LOCK";
return $self;
}
sub DESTROY
{
# clean the desk!
}
sub version {
my $this = shift;
return $NOTEDB::binary::VERSION;
}
sub set_del_all
{
my $this = shift;
unlink $this->{NOTEDB};
open(TT,">$this->{NOTEDB}") or die "Could not create $this->{NOTEDB}: $!\n";
close (TT);
}
sub get_single {
my($this, $num) = @_;
my($address, $note, $date, $buffer, $n, $t, $buffer, );
open NOTE, "+<$this->{NOTEDB}" or die "could not open $this->{NOTEDB}\n";
flock NOTE, LOCK_EX;
$address = ($num-1) * $this->{sizeof};
seek(NOTE, $address, IO::Seekable::SEEK_SET);
read(NOTE, $buffer, $this->{sizeof});
($num, $n, $t) = unpack($this->{typedef}, $buffer);
$note = $this->ude($n);
$date = $this->ude($t);
flock NOTE, LOCK_UN;
close NOTE;
return $note, $date;
}
sub get_all
{
my $this = shift;
my($num, $note, $date, %res);
if ($this->unchanged) {
return %{$this->{cache}};
}
open NOTE, "+<$this->{NOTEDB}" or die "could not open $this->{NOTEDB}\n";
flock NOTE, LOCK_EX;
my($buffer, $t, $n);
seek(NOTE, 0, 0); # START FROM BEGINNING
while(read(NOTE, $buffer, $this->{sizeof})) {
($num, $note, $date) = unpack($this->{typedef}, $buffer);
$t = $this->ude($date);
$n = $this->ude($note);
$res{$num}->{'note'} = $n;
$res{$num}->{'date'} = $t;
}
flock NOTE, LOCK_UN;
close NOTE;
$this->cache(%res);
return %res;
}
sub import_data {
my ($this, $data) = @_;
foreach my $num (keys %{$data}) {
my $pos = $this->get_nextnum();
$this->set_edit($pos, $data->{$num}->{note}, $data->{$num}->{date});
}
}
sub get_nextnum
{
my $this = shift;
my($num, $te, $me, $buffer);
if ($this->unchanged) {
$num = 1;
foreach (keys %{$this->{cache}}) {
$num++;
}
return $num;
}
open NOTE, "+<$this->{NOTEDB}" or die "could not open $this->{NOTEDB}\n";
flock NOTE, LOCK_EX;
seek(NOTE, 0, 0); # START FROM BEGINNING
while(read(NOTE, $buffer, $this->{sizeof})) {
($num, $te, $me) = unpack($this->{typedef}, $buffer);
}
$num += 1;
flock NOTE, LOCK_UN;
close NOTE;
return $num;
}
sub get_search
{
my($this, $searchstring) = @_;
my($buffer, $num, $note, $date, %res, $t, $n, $match);
my $regex = $this->generate_search($searchstring);
eval $regex;
if ($@) {
print "invalid expression: \"$searchstring\"!\n";
return;
}
$match = 0;
if ($this->unchanged) {
foreach my $num (keys %{$this->{cache}}) {
$_ = $this->{cache}{$num}->{note};
eval $regex;
if ($match) {
$res{$num}->{note} = $this->{cache}{$num}->{note};
$res{$num}->{date} = $this->{cache}{$num}->{date}
}
$match = 0;
}
return %res;
}
open NOTE, "+<$this->{NOTEDB}" or die "could not open $this->{NOTEDB}\n";
flock NOTE, LOCK_EX;
seek(NOTE, 0, 0); # START FROM BEGINNING
while(read(NOTE, $buffer, $this->{sizeof})) {
($num, $note, $date) = unpack($this->{typedef}, $buffer);
$n = $this->ude($note);
$t = $this->ude($date);
$_ = $n;
eval $regex;
if($match)
{
$res{$num}->{'note'} = $n;
$res{$num}->{'date'} = $t;
}
$match = 0;
}
flock NOTE, LOCK_UN;
close NOTE;
return %res;
}
sub set_edit {
my($this, $num, $note, $date) = @_;
$this->warn_if_too_big($note, $num);
my $address = ($num -1 ) * $this->{sizeof};
open NOTE, "+<$this->{NOTEDB}" or die "could not open $this->{NOTEDB}\n";
flock NOTE, LOCK_EX;
seek(NOTE, $address, IO::Seekable::SEEK_SET);
my $n = $this->uen($note);
my $t = $this->uen($date);
my $buffer = pack($this->{typedef}, $num, $n, $t);
print NOTE $buffer;
flock NOTE, LOCK_UN;
close NOTE;
$this->changed;
}
sub set_new {
my($this, $num, $note, $date) = @_;
$this->warn_if_too_big($note, $num);
open NOTE, "+<$this->{NOTEDB}" or die "could not open $this->{NOTEDB}\n";
flock NOTE, LOCK_EX;
seek(NOTE, 0, IO::Seekable::SEEK_END); # APPEND
my $n = $this->uen($note);
my $t = $this->uen($date);
my $buffer = pack($this->{typedef}, $num, $n, $t);
print NOTE $buffer;
flock NOTE, LOCK_UN;
close NOTE;
$this->changed;
}
sub set_del
{
my($this, $num) = @_;
my(%orig, $note, $date, $T, $setnum, $buffer, $n, $N, $t);
$setnum = 1;
%orig = $this->get_all();
return "ERROR" if (! exists $orig{$num});
delete $orig{$num};
# overwrite, but keep number!
open NOTE, ">$this->{NOTEDB}" or die "could not open $this->{NOTEDB}\n";
flock NOTE, LOCK_EX;
seek(NOTE, 0, 0); # START FROM BEGINNING
foreach $N (keys %orig) {
$n = $this->uen($orig{$N}->{'note'});
$t = $this->uen($orig{$N}->{'date'});
$buffer = pack( $this->{typedef}, $N, $n, $t);
# keep orig number, note have to call recount!
print NOTE $buffer;
seek(NOTE, 0, IO::Seekable::SEEK_END);
$setnum++;
}
flock NOTE, LOCK_UN;
close NOTE;
$this->changed;
return;
}
sub set_recountnums
{
my($this) = @_;
my(%orig, $note, $date, $T, $setnum, $buffer, $n, $N, $t);
$setnum = 1;
%orig = $this->get_all();
open NOTE, ">$this->{NOTEDB}" or die "could not open $this->{NOTEDB}\n";
flock NOTE, LOCK_EX;
seek(NOTE, 0, 0); # START FROM BEGINNING
foreach $N (sort {$a <=> $b} keys %orig) {
$n = $this->uen($orig{$N}->{'note'});
$t = $this->uen($orig{$N}->{'date'});
$buffer = pack( $this->{typedef}, $setnum, $n, $t);
print NOTE $buffer;
seek(NOTE, 0, IO::Seekable::SEEK_END);
$setnum++;
}
flock NOTE, LOCK_UN;
close NOTE;
$this->changed;
return;
}
sub uen
{
my $this = shift;
my($T);
if($NOTEDB::crypt_supported == 1) {
eval {
$T = pack("u", $this->{cipher}->encrypt($_[0]));
};
}
else {
$T = pack("u", $_[0]);
}
chomp $T;
return $T;
}
sub ude
{
my $this = shift;
my($T);
if($NOTEDB::crypt_supported == 1) {
eval {
$T = $this->{cipher}->decrypt(unpack("u",$_[0]));
};
}
else {
$T = unpack("u", $_[0]);
}
return $T;
}
sub warn_if_too_big {
my ($this, $note, $num) = @_;
my $len = length($this->uen($note));
if ($len > $this->{maxnote}) {
# calculate the 30% uuencoding overhead
my $overhead = int(($this->{maxnote} / 100) * 28);
# fetch what's left by driver
my $left = substr $note, $this->{maxnote} - $overhead;
$left = "\n$left\n";
$left =~ s/\n/\n> /gs;
print STDERR "*** WARNING $this->{version} WARNING ***\n"
."The driver encountered a string length problem with your\n"
."note entry number $num. The entry is too long. Either shorten\n"
."the entry or resize the database field for entries.\n\n"
."The following data has been cut off the entry:\n"
."\n$left\n\n";
my $copy = File::Spec->catfile($ENV{'HOME'}, "entry-$num.txt");
open N, ">$copy" or die "Could not open $copy: $!\n";
print N $note;
close N;
print "*** Wrote the complete note entry number $num to file: $copy ***\n";
}
}
sub _retrieve {
my ($this) = @_;
my $file = $this->{dbname};
if (-s $file) {
if ($this->changed() || $this->{unread}) {
my $fh = new FileHandle "<$this->{dbname}" or die "could not open $this->{dbname}\n";
flock $fh, LOCK_EX;
my %data = ParseConfig(-ConfigFile => $fh) or die "could not read to database: $!\n";
flock $fh, LOCK_UN;
$fh->close();
$this->{unread} = 0;
$this->{data} = \%data;
return %data;
}
else {
return %{$this->{data}};
}
}
else {
return ();
}
}
1; # keep this!
__END__
=head1 NAME
NOTEDB::binary - module lib for accessing a notedb from perl
=head1 SYNOPSIS
# include the module
use NOTEDB;
# create a new NOTEDB object
$db = new NOTEDB("binary", "/home/tom/.notedb", 4096, 24);
# decide to use encryption
# $key is the cipher to use for encryption
# $method must be either Crypt::IDEA or Crypt::DES
# you need Crypt::CBC, Crypt::IDEA and Crypt::DES to have installed.
$db->use_crypt($key,$method);
# do not use encryption
# this is the default
$db->no_crypt;
# get a single note
($note, $date) = $db->get_single(1);
# search for a certain note
%matching_notes = $db->get_search("somewhat");
# format of returned hash:
#$matching_notes{$numberofnote}->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
# get all existing notes
%all_notes = $db->get_all();
# format of returnes hash like the one from get_search above
# get the next noteid available
$next_num = $db->get_nextnum();
# modify a certain note
$db->set_edit(1, "any text", "23.12.2000 10:33:02");
# create a new note
$db->set_new(5, "any new text", "23.12.2000 10:33:02");
# delete a certain note
$db->set_del(5);
# turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
$db->use_crypt("passphrase", "CryptMethod");
# turn off encryption. This is the default.
$db->no_crypt();
=head1 DESCRIPTION
You can use this module for accessing a note database. There are currently
two versions of this module, one version for a SQL database and one for a
binary file (note's own database-format).
However, both versions provides identical interfaces, which means, you do
not need to change your code, if you want to switch to another database format.
Currently, NOTEDB module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
=head1 USAGE
please see the section SYNOPSIS, it says it all.
=head1 AUTHOR
Thomas Linden <tom@daemon.de>.
=cut

269
blib/lib/NOTEDB/dbm.pm Normal file
View File

@@ -0,0 +1,269 @@
#!/usr/bin/perl
# $Id: dbm.pm,v 1.3 2000/08/11 00:05:58 zarahg Exp $
# Perl module for note
# DBM database backend. see docu: perldoc NOTEDB::dbm
#
package NOTEDB::dbm;
$NOTEDB::dbm::VERSION = "1.40";
use DB_File;
use NOTEDB;
use strict;
use Exporter ();
use vars qw(@ISA @EXPORT %note %date);
@ISA = qw(NOTEDB Exporter);
sub new
{
my($this, %param) = @_;
my $class = ref($this) || $this;
my $self = {};
bless($self,$class);
my $notefile = "note.dbm";
my $timefile = "date.dbm";
my $dbm_dir = $param{directory} || File::Spec->catfile($ENV{HOME}, ".note_dbm");
if (! -d $dbm_dir) {
# try to make it
mkdir $dbm_dir || die "Could not create $dbm_dir: $!\n";
}
tie %note, "DB_File", "$dbm_dir/$notefile" || die "Could not tie $dbm_dir/$notefile: $!\n";
tie %date, "DB_File", "$dbm_dir/$timefile" || die "Could not tie $dbm_dir/$timefile: $!\n";
$self->{LOCKFILE} = $param{dbname} . "~LOCK";
return $self;
}
sub DESTROY
{
# clean the desk!
untie %note, %date;
}
sub version {
my $this = shift;
return $this->{version};
}
sub get_single
{
my($this, $num) = @_;
my($note, $date);
return $this->ude ($note{$num}), $this->ude($date{$num});
}
sub get_all
{
my $this = shift;
my($num, $note, $date, %res, $real);
foreach $num (sort {$a <=> $b} keys %date) {
$res{$num}->{'note'} = $this->ude($note{$num});
$res{$num}->{'date'} = $this->ude($date{$num});
}
return %res;
}
sub import_data {
my ($this, $data) = @_;
foreach my $num (keys %{$data}) {
my $pos = $this->get_nextnum();
$note{$pos} = $this->ude($note{$num}->{note});
$date{$pos} = $this->ude($date{$num}->{date});
}
}
sub get_nextnum
{
my($this, $num);
foreach (sort {$a <=> $b} keys %date) {
$num = $_;
}
$num++;
return $num;
}
sub get_search
{
my($this, $searchstring) = @_;
my($num, $note, $date, %res, $match);
my $regex = $this->generate_search($searchstring);
eval $regex;
if ($@) {
print "invalid expression: \"$searchstring\"!\n";
return;
}
$match = 0;
foreach $num (sort {$a <=> $b} keys %date) {
$_ = $this->ude($note{$num});
eval $regex;
if ($match) {
$res{$num}->{'note'} = $this->ude($note{$num});
$res{$num}->{'date'} = $this->ude($date{$num});
}
$match = 0;
}
return %res;
}
sub set_recountnums
{
my $this = shift;
my(%Note, %Date, $num, $setnum);
$setnum = 1;
foreach $num (sort {$a <=> $b} keys %note) {
$Note{$setnum} = $note{$num};
$Date{$setnum} = $date{$num};
$setnum++;
}
%note = %Note;
%date = %Date;
}
sub set_edit
{
my($this, $num, $note, $date) = @_;
$note{$num} = $this->uen($note);
$date{$num} = $this->uen($date);
}
sub set_new
{
my($this, $num, $note, $date) = @_;
$this->set_edit($num, $note, $date); # just the same thing
}
sub set_del
{
my($this, $num) = @_;
my($note, $date, $T);
($note, $date) = $this->get_single($num);
return "ERROR" if ($date !~ /^\d/);
delete $note{$num};
delete $date{$num};
}
sub set_del_all
{
my($this) = @_;
%note = ();
%date = ();
return;
}
sub uen
{
my $this = shift;
my($T);
if($NOTEDB::crypt_supported == 1) {
eval {
$T = pack("u", $this->{cipher}->encrypt($_[0]));
};
}
else {
$T = $_[0];
}
chomp $T;
return $T;
}
sub ude
{
my $this = shift;
my($T);
if($NOTEDB::crypt_supported == 1) {
eval {
$T = $this->{cipher}->decrypt(unpack("u",$_[0]))
};
return $T;
}
else {
return $_[0];
}
}
1; # keep this!
__END__
=head1 NAME
NOTEDB::dbm - module lib for accessing a notedb from perl
=head1 SYNOPSIS
# include the module
use NOTEDB;
# create a new NOTEDB object (the last 4 params are db table/field names)
$db = new NOTEDB("mysql","note","/home/user/.notedb/");
# get a single note
($note, $date) = $db->get_single(1);
# search for a certain note
%matching_notes = $db->get_search("somewhat");
# format of returned hash:
#$matching_notes{$numberofnote}->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
# get all existing notes
%all_notes = $db->get_all();
# format of returnes hash like the one from get_search above
# get the next noteid available
$next_num = $db->get_nextnum();
# recount all noteids starting by 1 (usefull after deleting one!)
$db->set_recountnums();
# modify a certain note
$db->set_edit(1, "any text", "23.12.2000 10:33:02");
# create a new note
$db->set_new(5, "any new text", "23.12.2000 10:33:02");
# delete a certain note
$db->set_del(5);
=head1 DESCRIPTION
You can use this module for accessing a note database. This is the dbm module.
It uses the DB_FILE module to store it's data and it uses DBM files for tis purpose.
Currently, NOTEDB module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
=head1 USAGE
please see the section SYNOPSIS, it says it all.
=head1 AUTHOR
Thomas Linden <tom@daemon.de>.
=cut

371
blib/lib/NOTEDB/dumper.pm Normal file
View File

@@ -0,0 +1,371 @@
# Perl module for note
# text database backend. see docu: perldoc NOTEDB::text
# using Storable as backend.
package NOTEDB::dumper;
$NOTEDB::text::VERSION = "1.00";
use strict;
use Data::Dumper;
use File::Spec;
use MIME::Base64;
use NOTEDB;
use Fcntl qw(LOCK_EX LOCK_UN);
use Exporter ();
use vars qw(@ISA @EXPORT);
@ISA = qw(NOTEDB Exporter);
sub new {
my($this, %param) = @_;
my $class = ref($this) || $this;
my $self = {};
bless($self,$class);
$self->{NOTEDB} = $param{dbname} || File::Spec->catfile($ENV{HOME}, ".notedb");
if(! -e $param{dbname}) {
open(TT,">$param{dbname}") or die "Could not create $param{dbname}: $!\n";
close (TT);
}
elsif(! -w $param{dbname}) {
print "$param{dbname} is not writable!\n";
exit(1);
}
$self->{LOCKFILE} = $param{dbname} . "~LOCK";
$self->{mtime} = $self->get_stat();
$self->{unread} = 1;
$self->{data} = {};
return $self;
}
sub DESTROY
{
# clean the desk!
}
sub version {
my $this = shift;
return $NOTEDB::text::VERSION;
}
sub get_stat {
my ($this) = @_;
my $mtime = (stat($this->{dbname}))[9];
return $mtime;
}
sub set_del_all {
my $this = shift;
unlink $this->{NOTEDB};
open(TT,">$this->{NOTEDB}") or die "Could not create $this->{NOTEDB}: $!\n";
close (TT);
}
sub get_single {
my($this, $num) = @_;
my($address, $note, $date, $buffer, $n, $t, $buffer, );
my %data = $this->get_all();
return ($data{$num}->{note}, $data{$num}->{date});
}
sub get_all {
my $this = shift;
my($num, $note, $date, %res);
if ($this->unchanged) {
return %{$this->{cache}};
}
my %data = $this->_retrieve();
foreach my $num (keys %data) {
$res{$num}->{note} = $this->ude($data{$num}->{note});
$res{$num}->{date} = $this->ude($data{$num}->{date});
}
$this->cache(%res);
return %res;
}
sub import_data {
my ($this, $data) = @_;
my %res = $this->_retrieve();
my $pos = (scalar keys %res) + 1;
foreach my $num (keys %{$data}) {
$res{$pos}->{note} = $this->uen($data->{$num}->{note});
$res{$pos}->{date} = $this->uen($data->{$num}->{date});
$pos++;
}
$this->_store(\%res);
}
sub get_nextnum {
my $this = shift;
my($num, $te, $me, $buffer);
if ($this->unchanged) {
$num = 1;
foreach (keys %{$this->{cache}}) {
$num++;
}
return $num;
}
my %data = $this->get_all();
my $size = scalar keys %data;
$num = $size + 1;
return $num;
}
sub get_search {
my($this, $searchstring) = @_;
my($buffer, $num, $note, $date, %res, $t, $n, $match);
my $regex = $this->generate_search($searchstring);
eval $regex;
if ($@) {
print "invalid expression: \"$searchstring\"!\n";
return;
}
$match = 0;
if ($this->unchanged) {
foreach my $num (keys %{$this->{cache}}) {
$_ = $this->{cache}{$num}->{note};
eval $regex;
if ($match) {
$res{$num}->{note} = $this->{cache}{$num}->{note};
$res{$num}->{date} = $this->{cache}{$num}->{date}
}
$match = 0;
}
return %res;
}
my %data = $this->get_all();
foreach my $num(sort keys %data) {
$_ = $data{$num}->{note};
eval $regex;
if($match)
{
$res{$num}->{note} = $data{$num}->{note};
$res{$num}->{date} = $data{$num}->{data};
}
$match = 0;
}
return %res;
}
sub set_edit {
my($this, $num, $note, $date) = @_;
my %data = $this->_retrieve();
$data{$num} = {
note => $this->uen($note),
date => $this->uen($date)
};
$this->_store(\%data);
$this->changed;
}
sub set_new {
my($this, $num, $note, $date) = @_;
$this->set_edit($num, $note, $date);
}
sub set_del {
my($this, $num) = @_;
my(%data, $note, $date, $T, $setnum, $buffer, $n, $N, $t);
$setnum = 1;
%data = $this->_retrieve();
return "ERROR" if (! exists $data{$num});
delete $data{$num};
$this->_store(\%data);
$this->changed;
return;
}
sub set_recountnums {
my($this) = @_;
my(%orig, %data, $note, $date, $T, $setnum, $buffer, $n, $N, $t);
$setnum = 1;
%orig = $this->_retrieve();
foreach $N (sort {$a <=> $b} keys %orig) {
$data{$setnum} = {
note => $orig{$N}->{note},
date => $orig{$N}->{date}
};
$setnum++;
}
$this->_store(\%data);
$this->changed;
return;
}
sub uen {
my ($this, $raw) = @_;
my($crypted);
if($NOTEDB::crypt_supported == 1) {
eval {
$crypted = $this->{cipher}->encrypt($raw);
return encode_base64($crypted);
};
}
else {
return $raw;
}
}
sub ude {
my ($this, $crypted) = @_;
my($raw);
if($NOTEDB::crypt_supported == 1) {
eval {
$raw = $this->{cipher}->decrypt(decode_base64($crypted));
};
return $raw;
}
else {
return $crypted;
}
}
sub _store {
my ($this, $data) = @_;
open N, ">$this->{NOTEDB}" or die "Could not open db: $!\n";
print N Data::Dumper->Dump([$data], [qw(*data)]);
close N;
}
sub _retrieve {
my $this = shift;
if (-s $this->{NOTEDB}) {
if ($this->changed() || $this->{unread}) {
open N, "<$this->{NOTEDB}" or die "Could not open db: $!\n";
my $content = join "", <N>;
close N;
my %data;
eval $content; # creates %data
$this->{unread} = 0;
$this->{data} = \%data;
return %data;
}
}
else {
return ();
}
}
1; # keep this!
__END__
=head1 NAME
NOTEDB::text - module lib for accessing a notedb from perl
=head1 SYNOPSIS
# include the module
use NOTEDB;
# create a new NOTEDB object
$db = new NOTEDB("text", "/home/tom/.notedb", 4096, 24);
# decide to use encryption
# $key is the cipher to use for encryption
# $method must be either Crypt::IDEA or Crypt::DES
# you need Crypt::CBC, Crypt::IDEA and Crypt::DES to have installed.
$db->use_crypt($key,$method);
# do not use encryption
# this is the default
$db->no_crypt;
# get a single note
($note, $date) = $db->get_single(1);
# search for a certain note
%matching_notes = $db->get_search("somewhat");
# format of returned hash:
#$matching_notes{$numberofnote}->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
# get all existing notes
%all_notes = $db->get_all();
# format of returnes hash like the one from get_search above
# get the next noteid available
$next_num = $db->get_nextnum();
# modify a certain note
$db->set_edit(1, "any text", "23.12.2000 10:33:02");
# create a new note
$db->set_new(5, "any new text", "23.12.2000 10:33:02");
# delete a certain note
$db->set_del(5);
# turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
$db->use_crypt("passphrase", "CryptMethod");
# turn off encryption. This is the default.
$db->no_crypt();
=head1 DESCRIPTION
You can use this module for accessing a note database. This backend uses
a text file for storage and Storable for accessing the file.
Currently, NOTEDB module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
=head1 USAGE
please see the section SYNOPSIS, it says it all.
=head1 AUTHOR
Thomas Linden <tom@daemon.de>.
=cut

408
blib/lib/NOTEDB/general.pm Normal file
View File

@@ -0,0 +1,408 @@
# Perl module for note
# general database backend. see docu: perldoc NOTEDB::general
# using Config::General as backend.
package NOTEDB::general;
$NOTEDB::general::VERSION = "1.01";
use strict;
#use Data::Dumper;
use File::Spec;
use Config::General;
use MIME::Base64;
use FileHandle;
use NOTEDB;
use Fcntl qw(LOCK_EX LOCK_UN);
use Exporter ();
use vars qw(@ISA @EXPORT);
@ISA = qw(NOTEDB Exporter);
sub new {
my($this, %param) = @_;
my $class = ref($this) || $this;
my $self = {};
bless($self,$class);
$self->{dbname} = $param{dbname} || File::Spec->catfile($ENV{HOME}, ".notedb");
if(! -e $param{dbname}) {
open(TT,">$param{dbname}") or die "Could not create $param{dbname}: $!\n";
close (TT);
}
elsif(! -w $param{dbname}) {
print "$param{dbname} is not writable!\n";
exit(1);
}
$self->{mtime} = $self->get_stat();
$self->{unread} = 1;
$self->{data} = {};
$self->{LOCKFILE} = $param{dbname} . "~LOCK";
return $self;
}
sub DESTROY {
# clean the desk!
}
sub version {
my $this = shift;
return $NOTEDB::general::VERSION;
}
sub get_stat {
my ($this) = @_;
my $mtime = (stat($this->{dbname}))[9];
return $mtime;
}
sub changed {
my ($this) = @_;
my $current = $this->get_stat();
if ($current > $this->{mtime}) {
$this->{mtime} = $current;
return $current;
}
else {
return 0;
}
}
sub set_del_all {
my $this = shift;
unlink $this->{dbname};
open(TT,">$this->{dbname}") or die "Could not create $this->{dbname}: $!\n";
close (TT);
}
sub get_single {
my($this, $num) = @_;
my($address, $note, $date, $buffer, $n, $t, $buffer, );
my %data = $this->get_all();
return ($data{$num}->{note}, $data{$num}->{date});
}
sub get_all {
my $this = shift;
my($num, $note, $date, %res);
if ($this->unchanged) {
return %{$this->{cache}};
}
my %data = $this->_retrieve();
foreach my $num (keys %data) {
$res{$num}->{note} = $this->ude($data{$num}->{note});
$res{$num}->{date} = $this->ude($data{$num}->{date});
}
$this->cache(%res);
return %res;
}
sub import_data {
my ($this, $data) = @_;
my %res = $this->_retrieve();
my $pos = (scalar keys %res) + 1;
foreach my $num (keys %{$data}) {
$res{$pos}->{note} = $this->uen($data->{$num}->{note});
$res{$pos}->{date} = $this->uen($data->{$num}->{date});
$pos++;
}
$this->_store(\%res);
}
sub get_nextnum {
my $this = shift;
my($num, $te, $me, $buffer);
if ($this->unchanged) {
$num = 1;
foreach (keys %{$this->{cache}}) {
$num++;
}
return $num;
}
my %data = $this->get_all();
my $size = scalar keys %data;
$num = $size + 1;
return $num;
}
sub get_search {
my($this, $searchstring) = @_;
my($buffer, $num, $note, $date, %res, $t, $n, $match);
my $regex = $this->generate_search($searchstring);
eval $regex;
if ($@) {
print "invalid expression: \"$searchstring\"!\n";
return;
}
$match = 0;
if ($this->unchanged) {
foreach my $num (keys %{$this->{cache}}) {
$_ = $this->{cache}{$num}->{note};
eval $regex;
if ($match) {
$res{$num}->{note} = $this->{cache}{$num}->{note};
$res{$num}->{date} = $this->{cache}{$num}->{date}
}
$match = 0;
}
return %res;
}
my %data = $this->get_all();
foreach my $num(sort keys %data) {
$_ = $data{$num}->{note};
eval $regex;
if($match)
{
$res{$num}->{note} = $data{$num}->{note};
$res{$num}->{date} = $data{$num}->{data};
}
$match = 0;
}
return %res;
}
sub set_edit {
my($this, $num, $note, $date) = @_;
my %data = $this->_retrieve();
$data{$num} = {
note => $this->uen($note),
date => $this->uen($date)
};
$this->_store(\%data);
$this->changed;
}
sub set_new {
my($this, $num, $note, $date) = @_;
$this->set_edit($num, $note, $date);
}
sub set_del {
my($this, $num) = @_;
my(%data, $note, $date, $T, $setnum, $buffer, $n, $N, $t);
$setnum = 1;
%data = $this->_retrieve();
return "ERROR" if (! exists $data{$num});
delete $data{$num};
$this->_store(\%data);
$this->changed;
return;
}
sub set_recountnums {
my($this) = @_;
my(%orig, %data, $note, $date, $T, $setnum, $buffer, $n, $N, $t);
$setnum = 1;
%orig = $this->_retrieve();
foreach $N (sort {$a <=> $b} keys %orig) {
$data{$setnum} = {
note => $orig{$N}->{note},
date => $orig{$N}->{date}
};
$setnum++;
}
$this->_store(\%data);
$this->changed;
return;
}
sub uen {
my ($this, $raw) = @_;
my($crypted);
if($NOTEDB::crypt_supported == 1) {
eval {
$crypted = $this->{cipher}->encrypt($raw);
};
print $@;
}
else {
$crypted = $raw;
}
my $coded = encode_base64($crypted);
return $coded;
}
sub ude {
my ($this, $crypted) = @_;
my($raw);
if($NOTEDB::crypt_supported == 1) {
eval {
$raw = $this->{cipher}->decrypt(decode_base64($crypted));
};
}
else {
$raw = decode_base64($crypted)
}
return $raw;
}
sub _store {
my ($this, $data) = @_;
open NOTE, ">$this->{dbname}" or die "could not open $this->{dbname}: $!\n";
flock NOTE, LOCK_EX;
if (%{$data}) {
my $content = SaveConfigString($data) or die "could not serialize data: $!\n";
print NOTE $content;
}
else {
print NOTE "";
}
flock NOTE, LOCK_UN;
close NOTE;
# finally re-read the db, so that we always have the latest data
$this->_retrieve();
}
sub _retrieve {
my ($this) = @_;
my $file = $this->{dbname};
if (-s $file) {
if ($this->changed() || $this->{unread}) {
my $fh = new FileHandle "<$this->{dbname}" or die "could not open $this->{dbname}\n";
flock $fh, LOCK_EX;
my %data = ParseConfig(-ConfigFile => $fh) or die "could not read to database: $!\n";
flock $fh, LOCK_UN;
$fh->close();
$this->{unread} = 0;
$this->{data} = \%data;
return %data;
}
else {
return %{$this->{data}};
}
}
else {
return ();
}
}
1; # keep this!
__END__
=head1 NAME
NOTEDB::general - module lib for accessing a notedb from perl
=head1 SYNOPSIS
# include the module
use NOTEDB;
# create a new NOTEDB object
$db = new NOTEDB("text", "/home/tom/.notedb", 4096, 24);
# decide to use encryption
# $key is the cipher to use for encryption
# $method must be either Crypt::IDEA or Crypt::DES
# you need Crypt::CBC, Crypt::IDEA and Crypt::DES to have installed.
$db->use_crypt($key,$method);
# do not use encryption
# this is the default
$db->no_crypt;
# get a single note
($note, $date) = $db->get_single(1);
# search for a certain note
%matching_notes = $db->get_search("somewhat");
# format of returned hash:
#$matching_notes{$numberofnote}->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
# get all existing notes
%all_notes = $db->get_all();
# format of returnes hash like the one from get_search above
# get the next noteid available
$next_num = $db->get_nextnum();
# modify a certain note
$db->set_edit(1, "any text", "23.12.2000 10:33:02");
# create a new note
$db->set_new(5, "any new text", "23.12.2000 10:33:02");
# delete a certain note
$db->set_del(5);
# turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
$db->use_crypt("passphrase", "CryptMethod");
# turn off encryption. This is the default.
$db->no_crypt();
=head1 DESCRIPTION
You can use this module for accessing a note database. This backend uses
a text file for storage and Config::General for accessing the file.
Currently, NOTEDB module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
=head1 USAGE
please see the section SYNOPSIS, it says it all.
=head1 AUTHOR
Thomas Linden <tom@daemon.de>.
=cut

425
blib/lib/NOTEDB/mysql.pm Normal file
View File

@@ -0,0 +1,425 @@
#
# Perl module for note
# mysql database backend. see docu: perldoc NOTEDB::mysql
#
package NOTEDB::mysql;
$NOTEDB::mysql::VERSION = "1.51";
use DBI;
use strict;
#use Data::Dumper;
use NOTEDB;
use Exporter ();
use vars qw(@ISA @EXPORT);
@ISA = qw(NOTEDB Exporter);
sub new {
my($this, %param) = @_;
my $class = ref($this) || $this;
my $self = {};
bless($self,$class);
my $dbname = $param{dbname} || "note";
my $dbhost = $param{dbhost} || "localhost";
my $dbuser = $param{dbuser} || "";
my $dbpasswd = $param{dbpasswd} || "";
my $dbport = $param{dbport} || "";
my $fnum = "number";
my $fnote = "note";
my $fdate = "date";
my $ftopic = "topic";
my $database;
if ($dbport) {
$database = "DBI:mysql:$dbname;host=$dbhost:$dbport";
}
else {
$database = "DBI:mysql:$dbname;host=$dbhost";
}
$self->{table} = "note";
$self->{sql_getsingle} = "SELECT $fnote,$fdate,$ftopic FROM $self->{table} WHERE $fnum = ?";
$self->{sql_all} = "SELECT $fnum,$fnote,$fdate,$ftopic FROM $self->{table}";
$self->{sql_nextnum} = "SELECT max($fnum) FROM $self->{table}";
$self->{sql_incrnum} = "SELECT $fnum FROM $self->{table} ORDER BY $fnum";
$self->{sql_setnum} = "UPDATE $self->{table} SET $fnum = ? WHERE $fnum = ?";
$self->{sql_edit} = "UPDATE $self->{table} SET $fnote = ?, $fdate = ?, $ftopic = ? WHERE $fnum = ?";
$self->{sql_insertnew} = "INSERT INTO $self->{table} VALUES (?, ?, ?, ?)";
$self->{sql_del} = "DELETE FROM $self->{table} WHERE $fnum = ?";
$self->{sql_del_all} = "DELETE FROM $self->{table}";
$self->{DB} = DBI->connect($database, $dbuser, $dbpasswd) or die DBI->errstr();
return $self;
}
sub DESTROY
{
# clean the desk!
my $this = shift;
$this->{DB}->disconnect;
}
sub lock {
my($this) = @_;
# LOCK the database!
my $lock = $this->{DB}->prepare("LOCK TABLES $this->{table} WRITE")
|| die $this->{DB}->errstr();
$lock->execute() || die $this->{DB}->errstr();
}
sub unlock {
my($this) = @_;
my $unlock = $this->{DB}->prepare("UNLOCK TABLES") || die $this->{DB}->errstr;
$unlock->execute() || die $this->{DB}->errstr();
}
sub version {
my $this = shift;
return $this->{version};
}
sub get_single {
my($this, $num) = @_;
my($note, $date, $topic);
my $statement = $this->{DB}->prepare($this->{sql_getsingle}) || die $this->{DB}->errstr();
$statement->execute($num) || die $this->{DB}->errstr();
$statement->bind_columns(undef, \($note, $date, $topic)) || die $this->{DB}->errstr();
while($statement->fetch) {
$note = $this->ude($note);
if ($topic) {
$note = "$topic\n" . $note;
}
return $note, $this->ude($date);
}
}
sub get_all
{
my $this = shift;
my($num, $note, $date, %res, $topic);
if ($this->unchanged) {
return %{$this->{cache}};
}
my $statement = $this->{DB}->prepare($this->{sql_all}) or die $this->{DB}->errstr();
$statement->execute or die $this->{DB}->errstr();
$statement->bind_columns(undef, \($num, $note, $date, $topic)) or die $this->{DB}->errstr();
while($statement->fetch) {
$res{$num}->{'note'} = $this->ude($note);
$res{$num}->{'date'} = $this->ude($date);
if ($topic) {
$res{$num}->{'note'} = "$topic\n" . $res{$num}->{'note'};
}
}
$this->cache(%res);
return %res;
}
sub get_nextnum
{
my $this = shift;
my($num);
if ($this->unchanged) {
$num = 1;
foreach (keys %{$this->{cache}}) {
$num++;
}
return $num;
}
my $statement = $this->{DB}->prepare($this->{sql_nextnum}) || die $this->{DB}->errstr();
$statement->execute || die $this->{DB}->errstr();
$statement->bind_columns(undef, \($num)) || die $this->{DB}->errstr();
while($statement->fetch) {
return $num+1;
}
}
sub get_search
{
my($this, $searchstring) = @_;
my($num, $note, $date, %res, $match, $use_cache, $topic);
my $regex = $this->generate_search($searchstring);
eval $regex;
if ($@) {
print "invalid expression: \"$searchstring\"!\n";
return;
}
$match = 0;
if ($this->unchanged) {
foreach my $num (keys %{$this->{cache}}) {
$_ = $this->{cache}{$num}->{note};
eval $regex;
if ($match) {
$res{$num}->{note} = $this->{cache}{$num}->{note};
$res{$num}->{date} = $this->{cache}{$num}->{date}
}
$match = 0;
}
return %res;
}
my $statement = $this->{DB}->prepare($this->{sql_all}) or die $this->{DB}->errstr();
$statement->execute or die $this->{DB}->errstr();
$statement->bind_columns(undef, \($num, $note, $date, $topic)) or die $this->{DB}->errstr();
while($statement->fetch) {
$note = $this->ude($note);
$date = $this->ude($date);
if ($topic) {
$note = "$topic\n" . $note;
}
$_ = $note;
eval $regex;
if($match) {
$res{$num}->{'note'} = $note;
$res{$num}->{'date'} = $date;
}
$match = 0;
}
return %res;
}
sub set_edit
{
my($this, $num, $note, $date) = @_;
$this->lock;
my $statement = $this->{DB}->prepare($this->{sql_edit}) or die $this->{DB}->errstr();
$note =~ s/'/\'/g;
$note =~ s/\\/\\\\/g;
$statement->execute($this->uen($note), $this->uen($date), $num)
or die $this->{DB}->errstr();
$this->unlock;
$this->changed;
}
sub set_new
{
my($this, $num, $note, $date) = @_;
$this->lock;
my $statement = $this->{DB}->prepare($this->{sql_insertnew}) || die $this->{DB}->errstr();
my ($topic, $note) = $this->get_topic($note);
$note =~ s/'/\'/g;
$note =~ s/\\/\\\\/g;
$topic =~ s/\\/\\\\/g;
$statement->execute($num, $this->uen($note), $this->uen($date), $topic) || die $this->{DB}->errstr();
$this->unlock;
$this->changed;
}
sub set_del
{
my($this, $num) = @_;
my($note, $date, $T);
$this->lock;
($note, $date) = $this->get_single($num);
return "ERROR" if ($date !~ /^\d/);
# delete record!
my $statement = $this->{DB}->prepare($this->{sql_del}) || die $this->{DB}->errstr();
$statement->execute($num) || die $this->{DB}->errstr();
$this->unlock;
$this->changed;
return;
}
sub set_del_all
{
my($this) = @_;
$this->lock;
my $statement = $this->{DB}->prepare($this->{sql_del_all}) || die $this->{DB}->errstr();
$statement->execute() || die $this->{DB}->errstr();
$this->unlock;
$this->changed;
return;
}
sub set_recountnums {
my $this = shift;
$this->lock;
my(@count, $i, $num, $setnum, $pos);
$setnum = 1;
$pos=0; $i=0; @count = ();
my $statement = $this->{DB}->prepare($this->{sql_incrnum}) || die $this->{DB}->errstr();
$statement->execute || die $this->{DB}->errstr();
$statement->bind_columns(undef, \($num)) || die $this->{DB}->errstr();
# store real id's in an array!
while($statement->fetch) {
$count[$i] = $num;
$i++;
}
# now recount them!
my $sub_statement = $this->{DB}->prepare($this->{sql_setnum}) || die $this->{DB}->errstr();
for($pos=0;$pos<$i;$pos++) {
$setnum = $pos +1;
$sub_statement->execute($setnum,$count[$pos]) || die $this->{DB}->errstr();
}
$this->unlock;
$this->changed;
}
sub import_data {
my ($this, $data) = @_;
foreach my $num (keys %{$data}) {
my $pos = $this->get_nextnum();
$this->set_new($pos, $data->{$num}->{note}, $data->{$num}->{date});
}
}
sub uen
{
my $this = shift;
my($T);
if($NOTEDB::crypt_supported == 1) {
eval {
$T = pack("u", $this->{cipher}->encrypt($_[0]));
};
}
else {
$T = $_[0];
}
chomp $T;
return $T;
}
sub ude
{
my $this = shift;
my($T);
if($NOTEDB::crypt_supported == 1) {
eval {
$T = $this->{cipher}->decrypt(unpack("u",$_[0]))
};
return $T;
}
else {
return $_[0];
}
}
sub get_topic {
my ($this, $data) = @_;
if ($data =~ /^\//) {
my($topic, $note) = split /\n/, $data, 2;
return ($topic, $note);
}
else {
return ("", $data);
}
}
1; # keep this!
__END__
=head1 NAME
NOTEDB::mysql - module lib for accessing a notedb from perl
=head1 SYNOPSIS
# include the module
use NOTEDB;
# create a new NOTEDB object (the last 4 params are db table/field names)
$db = new NOTEDB("mysql","note","localhost","username","password","note","number","note","date");
# get a single note
($note, $date) = $db->get_single(1);
# search for a certain note
%matching_notes = $db->get_search("somewhat");
# format of returned hash:
#$matching_notes{$numberofnote}->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
# get all existing notes
%all_notes = $db->get_all();
# format of returnes hash like the one from get_search above
# get the next noteid available
$next_num = $db->get_nextnum();
# recount all noteids starting by 1 (usefull after deleting one!)
$db->set_recountnums();
# modify a certain note
$db->set_edit(1, "any text", "23.12.2000 10:33:02");
# create a new note
$db->set_new(5, "any new text", "23.12.2000 10:33:02");
# delete a certain note
$db->set_del(5);
# turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
$db->use_crypt("passphrase", "CryptMethod");
# turn off encryption. This is the default.
$db->no_crypt();
=head1 DESCRIPTION
You can use this module for accessing a note database. There are currently
two versions of this module, one version for a SQL database and one for a
binary file (note's own database-format).
However, both versions provides identical interfaces, which means, you do
not need to change your code, if you want to switch to another database format.
Currently, NOTEDB module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
=head1 USAGE
please see the section SYNOPSIS, it says it all.
=head1 AUTHOR
Thomas Linden <tom@daemon.de>.
=cut

358
blib/lib/NOTEDB/text.pm Normal file
View File

@@ -0,0 +1,358 @@
# Perl module for note
# text database backend. see docu: perldoc NOTEDB::text
# using Storable as backend.
package NOTEDB::text;
$NOTEDB::text::VERSION = "1.03";
use strict;
#use Data::Dumper;
use File::Spec;
use Storable qw(lock_nstore lock_retrieve);
use MIME::Base64;
use NOTEDB;
use Fcntl qw(LOCK_EX LOCK_UN);
use Exporter ();
use vars qw(@ISA @EXPORT);
@ISA = qw(NOTEDB Exporter);
sub new {
my($this, %param) = @_;
my $class = ref($this) || $this;
my $self = {};
bless($self,$class);
$self->{NOTEDB} = $param{dbname} || File::Spec->catfile($ENV{HOME}, ".notedb");
if(! -e $param{dbname}) {
open(TT,">$param{dbname}") or die "Could not create $param{dbname}: $!\n";
close (TT);
}
elsif(! -w $param{dbname}) {
print "$param{dbname} is not writable!\n";
exit(1);
}
$self->{LOCKFILE} = $param{dbname} . "~LOCK";
$self->{mtime} = $self->get_stat();
$self->{unread} = 1;
$self->{data} = {};
return $self;
}
sub DESTROY
{
# clean the desk!
}
sub version {
my $this = shift;
return $NOTEDB::text::VERSION;
}
sub get_stat {
my ($this) = @_;
my $mtime = (stat($this->{dbname}))[9];
return $mtime;
}
sub set_del_all {
my $this = shift;
unlink $this->{NOTEDB};
open(TT,">$this->{NOTEDB}") or die "Could not create $this->{NOTEDB}: $!\n";
close (TT);
}
sub get_single {
my($this, $num) = @_;
my($address, $note, $date, $buffer, $n, $t, $buffer, );
my %data = $this->get_all();
return ($data{$num}->{note}, $data{$num}->{date});
}
sub get_all {
my $this = shift;
my($num, $note, $date, %res);
if ($this->unchanged) {
return %{$this->{cache}};
}
my %data = $this->_retrieve();
foreach my $num (keys %data) {
$res{$num}->{note} = $this->ude($data{$num}->{note});
$res{$num}->{date} = $this->ude($data{$num}->{date});
}
$this->cache(%res);
return %res;
}
sub import_data {
my ($this, $data) = @_;
my %res = $this->_retrieve();
my $pos = (scalar keys %res) + 1;
foreach my $num (keys %{$data}) {
$res{$pos}->{note} = $this->uen($data->{$num}->{note});
$res{$pos}->{date} = $this->uen($data->{$num}->{date});
$pos++;
}
$this->_store(\%res);
}
sub get_nextnum {
my $this = shift;
my($num, $te, $me, $buffer);
if ($this->unchanged) {
my @numbers = sort { $a <=> $b } keys %{$this->{cache}};
$num = pop @numbers;
$num++;
#$num = 1;
#foreach (keys %{$this->{cache}}) {
# $num++;
#}
return $num;
}
my %data = $this->get_all();
my @numbers = sort { $a <=> $b } keys %data;
$num = pop @numbers;
$num++;
#my $size = scalar keys %data;
#$num = $size + 1;
return $num;
}
sub get_search {
my($this, $searchstring) = @_;
my($buffer, $num, $note, $date, %res, $t, $n, $match);
my $regex = $this->generate_search($searchstring);
eval $regex;
if ($@) {
print "invalid expression: \"$searchstring\"!\n";
return;
}
$match = 0;
if ($this->unchanged) {
foreach my $num (keys %{$this->{cache}}) {
$_ = $this->{cache}{$num}->{note};
eval $regex;
if ($match) {
$res{$num}->{note} = $this->{cache}{$num}->{note};
$res{$num}->{date} = $this->{cache}{$num}->{date}
}
$match = 0;
}
return %res;
}
my %data = $this->get_all();
foreach my $num(sort keys %data) {
$_ = $data{$num}->{note};
eval $regex;
if($match)
{
$res{$num}->{note} = $data{$num}->{note};
$res{$num}->{date} = $data{$num}->{data};
}
$match = 0;
}
return %res;
}
sub set_edit {
my($this, $num, $note, $date) = @_;
my %data = $this->_retrieve();
$data{$num} = {
note => $this->uen($note),
date => $this->uen($date)
};
$this->_store(\%data);
$this->changed;
}
sub set_new {
my($this, $num, $note, $date) = @_;
$this->set_edit($num, $note, $date);
}
sub set_del {
my($this, $num) = @_;
my(%data, $note, $date, $T, $setnum, $buffer, $n, $N, $t);
$setnum = 1;
%data = $this->_retrieve();
return "ERROR" if (! exists $data{$num});
delete $data{$num};
$this->_store(\%data);
$this->changed;
return;
}
sub set_recountnums {
# not required here
return;
}
sub uen {
my ($this, $raw) = @_;
my($crypted);
if($NOTEDB::crypt_supported == 1) {
eval {
$crypted = $this->{cipher}->encrypt($raw);
};
}
else {
$crypted = $raw;
}
my $coded = encode_base64($crypted);
return $coded;
}
sub ude {
my ($this, $crypted) = @_;
my($raw);
if($NOTEDB::crypt_supported == 1) {
eval {
$raw = $this->{cipher}->decrypt(decode_base64($crypted));
};
}
else {
$raw = decode_base64($crypted)
}
return $raw;
}
sub _store {
my ($this, $data) = @_;
lock_nstore($data, $this->{NOTEDB});
}
sub _retrieve {
my $this = shift;
if (-s $this->{NOTEDB}) {
if ($this->changed() || $this->{unread}) {
my $data = lock_retrieve($this->{NOTEDB});
$this->{unread} = 0;
$this->{data} = $data;
return %{$data};
}
}
else {
return ();
}
}
1; # keep this!
__END__
=head1 NAME
NOTEDB::text - module lib for accessing a notedb from perl
=head1 SYNOPSIS
# include the module
use NOTEDB;
# create a new NOTEDB object
$db = new NOTEDB("text", "/home/tom/.notedb", 4096, 24);
# decide to use encryption
# $key is the cipher to use for encryption
# $method must be either Crypt::IDEA or Crypt::DES
# you need Crypt::CBC, Crypt::IDEA and Crypt::DES to have installed.
$db->use_crypt($key,$method);
# do not use encryption
# this is the default
$db->no_crypt;
# get a single note
($note, $date) = $db->get_single(1);
# search for a certain note
%matching_notes = $db->get_search("somewhat");
# format of returned hash:
#$matching_notes{$numberofnote}->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
# get all existing notes
%all_notes = $db->get_all();
# format of returnes hash like the one from get_search above
# get the next noteid available
$next_num = $db->get_nextnum();
# modify a certain note
$db->set_edit(1, "any text", "23.12.2000 10:33:02");
# create a new note
$db->set_new(5, "any new text", "23.12.2000 10:33:02");
# delete a certain note
$db->set_del(5);
# turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
$db->use_crypt("passphrase", "CryptMethod");
# turn off encryption. This is the default.
$db->no_crypt();
=head1 DESCRIPTION
You can use this module for accessing a note database. This backend uses
a text file for storage and Storable for accessing the file.
Currently, NOTEDB module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
=head1 USAGE
please see the section SYNOPSIS, it says it all.
=head1 AUTHOR
Thomas Linden <tom@daemon.de>.
=cut

View File

528
blib/lib/note.pod Normal file
View File

@@ -0,0 +1,528 @@
# -*-perl-*-
=head1 NAME
note - a perl script for maintaining notes.
=head1 SYNPOPSIS
note [options] [ number [,number...]]
=head1 DESCRIPTION
B<note> is a small console program written in perl, which allows
you to manage notes similar to programs like "knotes" but from
the commandline. Note can use different database-backends for
notes-storage. It ships with a DBI-based mysql-module(which
can also be used for other by DBI supported DBMS), another
module, which uses a binary file for storage and a DBM module.
There are also two modules available which uses a text file.
Note supports since version 1.0.0 encryption(IDEA or DES)!
=head1 OPTIONS
=over
=item I<-c, --config file>
Use another config file than the default ~/.noterc.
=item I<-l, --list [topic]>
Lists all existing notes. If no topic were specified,
it will display a list of all existing topics.
See the section I<TOPICS> for details about topics.
=item I<-L, --longlist [topic]>
The same as I<-l> but prints also the timestamp of the notes.
=item I<-t, --topic>
Prints a list of all topics as a tree.
=item I<-T, --longtopic>
Prints the topic-tree with the notes under each topic.
=item I<-s, --search string>
Searches for <string> trough the notes database. See the section
I<SEARCHING> for details about the search engine.
=item I<-e, --edit number>
Edit the note with the number <number> using your default editor
or the one you specified in the config file.
=item I<-d, --delete number>
Delete the note with the number <number>. You can delete multiple notes
with one command. "1-4" deletes the notes 1,2,3,4. And "1,5,7" deletes
the specified ones.
=item I<-D, --Dump [file | -]>
Dumps all notes to the textfile <file>. If <file> is a "-" it will
be printed out to standard output (STDOUT).
=item I<-I, --Import file | ->
Imports a previously dumped textfile into the
note database. Data will be appended by default.
You can also specify a dash I<note -I -> instead of a <file>,
which causes note, silently to read in a dump from STDIN.
=item I<-o, --overwrite>
Only suitable for use with --Import. Overwrites an
existing notedb. Use with care.
=item I<-r, --raw>
Raw mode, output will not be formatted. Works not in interactive
mode, only on cmd-line for list and display. That means, no colors
will be used and no lines or titles.
=item I<-i, --interactive>
Start note in interactive mode. See the section I<INTERACTIVE MODE>
for details on this mode.
=item I<--encrypt cleartext>
Encrypt the given clear text string. You would need that if you want to
store the mysql password not in cleartext in the config(if you are using
the mysql backend!).
=item I<-h, --help>
Display this help screen.
=item I<-v, --version>
Display the version number.
=item B<->
If you run note just with one dash: B<note ->, then it will read in a new
note from STDIN until EOF. This makes it possible to pipe text into a new note, i.e.:
cat sometextfile | note -
=back
=head1 USAGE
=head2 GENERAL USAGE
If you don't know, how to run note, try "note -h" first.
It will tell you all available commandline options.
To create a new note, simply run "note". You can enter
the note (the length is by default limited to 4096 bytes,
which you can change from your config file if you are using
the binary backend, otherwise there is no limitation).
End by typing a . on a line itself. note will tell you the
number of the note.
If you want to view the note, type "note 1", if the notenumber
was 1.
If you want to get an overview of all notes, type "note -l".
You will get a list of all notes, containing the number,
the first line and the creation date. If topic-support is
turned on (which is by default), then all subtopics under the
current topic will be displayed first.
If you want to see the timestamps, use "-L" instead of "-l".
Read more about topics below in the section "Topics".
You can also specify the topic which notes you want to see:
"-l mytopic" does the trick.
Additional, you might want to get an overview of your topic-
structure. You can use the command "-t" in this case, which
will display a tree-view of your topic-structure. You can
use the command "-T" if you want to see the notes under each
topic too. "-T" will also show the number of each note.
To edit a certain note, type "note -e 1". It will invoke your
editor (vi or pico). You can edit it, after saving, note
will store the changed note to the database.
Of course you can drop a certain note: "note -d 1" deletes
note number 1. If a note in the middle or the beginning of
the database will be deleted, note will recount the other
existent notes. For example there are 3 notes, number 1, 2
and 3. If you delete number 2, then number 3 will become
number 2.
You can also make use of the extended delete-syntax:
To delete note 1 and 2, use "-d 1,2"
To delete note 1,2 and 3, use "-d 1-3".
=head2 SEARCHING
If you cannot remember, which note you are looking for, you
can use the search capability of note: "note -s <searchstring>".
note will search the whole note database case insensitive for
an occurence of this string and tell you the number and first-
line it has.
You can extend the searchstring using B<AND>, B<OR> ( and ) and
shell-like wildcards:
$ note -s "moses AND lenin"
or:
$ note -s "(mike OR arnold) AND (jackson OR schwarzenegger)"
If note finds a note, which first line is a topic, then it will
display it's second line.
These rules apply for the interactive search too.
You need to know, that note searches for the expression in every
note. In other words, "moses AND lenin" searches for an occurence
of "moses" and "lenin" in ONE note. Or, if you are looking for
"mike OR daniel", then it searches for an occurence of "mike" or
daniel" in ONE note. Thus a note with the text "mike oldfield" will
match that search.
=head2 TOPICS
If topic-support is turned on (which is by default), the various
notes are sorted under various topics. There is no special database
field for the topic. Instead the topic will be stored right in the
note.
If the first line of your note contains some text bordered by slashes
(or whatever you prefer, set "TopicSeparator" in your config! default
is slash), then note will consider it as the topic of this certain
note. For examle:
B</TodoList/>
If you are using topics, no data after the topic is allowed, if there
is any text, note will consider it as a subtopic! Therefore, don't for-
get to put a newline after the topic-line.
The list-command will only show you notes under this topic. If you
create a new note, it will automagically inserted under the current
topic (note will prepend the string "/topicname/" to the text of your
note).
You can create at any time from any point a new topic. Just create a new
note and type the name of the new topic bordered by slashes (or
TopicSeparator) at the first line of this note. After saving, there
will be available a new topic with one note in it.
You can create as many subtopics as you like, the format is similar to
a filesystem-path. An example, say, you want to create such a
structure:
(root - top level)
|
|----test
| |----subtopic
| | |--note 1
| | |--note 2
| |
| |--note 4
|
|--note 3
Then you may create those 4 new notes:
--- snip ---
/test/subtopic/
note 1
--- snip ---
/test/subtopic/
note 2
--- snip ---
note 3
--- snip ---
/test/
note 4
--- snip ---
I hope, you got the point ;-)
If a note does not contain the "magic" /topic/ construction on the first
line, it will be listed under the "root" of note, that is the point
you are at the startup of note.
You can subsequently move a note without a topic to a certain topic.
Simply edit it and insert at the first line the above mentioned
construction.
Note: Please don't forget the prepending and appending a slash of a
topic. You will get strange results without it!
=head2 INTERACTIVE MODE
If you start note with the commandline flag B<-i>, then it starts
with an interactive interface.
It will start with a listing under the default top-topic ("/").
You can enter the name of a topic to change to that topic. This works
similar to a filesystem structure. The current topic will be
displayed on the top of the screen.
The following commands are available:
=over
=item B<L [topic]>
This command lists all notes with a timestamp. If you specify a topic, it
will only list the notes under this topic. If you are under a certain subtopic,
then it will only display the notes under this topic.
=item B<l [topic]>
This commands behaves similar to B<L> but it does not display the timestamp.
You can achieve the same result by simply pressing enter at any time.
=item B<N>
You can create a new note by simply pressing B<N> or B<n>. You favorite
editor will be started and you can enter your note text. If you are already
under a topic then this new note will automatically go to this topic.
note adds an aditional line to the top of the note with the topic. But
you can of course specify your own topic.
Note will tell you which number it has assigned to the newly created note.
=item B<E number>
By entering B<E> or B<e> and a note-number you can edit an existing note
using your favorite editor. This way you can also move an existing note
from one topic to another one by editing the first line of the note.
=item B<D number>
B<E> or B<e> deletes one or more existing note(s). It requires a note number
or a set of note numbers. 1-5 and 1,7,9 are possible values.
After one or more notes has been deleted note will recount all remaining notes.
Say if you delete 1 and 2, then 3 will become 1, 4 will become 5 and so forth.
=item B<S [expression]>
You can search for the occurence of a text in your notes-database with the
command B<S> or B<s>. If you omit an expression note will ask you for one.
If your search criteria matches on exactly one entry, note will display
that note entry instead of displaying its number.
=item B<T>
This prints a tree-view of your topic-structure. B<T> displays the tree with
notes, B<t> displays just the topics without notes.
=item B<cd topic>
Change the actual topic under which you are. This works identical like just
entering the topic but it has some advantages. You can enter B<cd ..> if
you want to go one level up in the topic-structure. And you can enter B<cd />
to go to the top of the structure. You can always leave out the 'cd' keyword too.
Additional it is possible to enter a note-number instead of a topic name.
For this feature to be active you need to set the config option B<ShortCd>
to B<1> or B<yes>. If you use a number and the note with this number is
under a certain topic then you will "cd" to this topic. This allows you
to do kind of jumps over multiple levels of topics.
If is possible to abbreviate a topic. This works only if the abbreviation
matches on one single topic. If it matches more than one topic then the
available ones will be suggested.
=item B<? or h>
Display a short help screen.
=item B<Q>
Quit note.
=back
=head2 BACKUP
You can also dump the contents of your note-database into a
ASCII-textfile(I<-D>). You can use this file later to import it into
your note-database(-I). This is usefull, if you want quickly trans-
fer your notes from one host to another (i.e. you could mail
your note-dump form your office to home and import it there
for further use).
The dumps from the two versions of note are in the same format.
Using dumps it is also possible to reinitialize your database. You
can use the "-o" switch whcih causes note to overwrite your existing
database. This is very handy if you changed heavily your config. And
it is required, if you changed: encryption, db-driver, (binary-format)
and the password. You can use the following command for reinitializing:
$ note -D - | note -o -I -
What the hell, does this do?! Step by step:
=over
=item *
B<note -D -> creates a note-database dump and prints it out
to stantdard output.
=item *
B<|> this is the shell's pipe command. It takes the output
of the left program and gives it to the right program as
standard input.
=item *
B<note -o -I -> imports a note-database dump from standard
input and overwrites an existing database.
=back
Before you use the B<-o> switch, I consider you to make a backup!
=head2 FORMATING
Another very nice feature is the possibility to format the note-text
(as much as shell allows it). First, you can use the note-internal
"magic-strings" for colorizing. Those strings looks much like HTML:
"<green>here is a green line of text</green> no more green."
As you see, the beginning of another color starts with a tag(kinda) of
the color <colorname> and ends with an end tag </colorname>.
The following colors are available:
black, red, green, yellow, blue, magenta, cyan and white.
Beside colorizing text, you can also create bold or underlined text! If
you decide to use this (additional) feature, you need to set the
Config-Option "FormatText" to 1 which turns it on.
Usage is very straightforward, if a word (a word is defined as some
text with at least one space surrounded) is between a magic mark-
character. Here are the available things, you can do:
bold: **word**
underlined: __word__
inverse: {{word}}
hidden: //word//
The text will be formatted using the actually note-color.
The hidden formatting will use blue forground and blue background
to hide a string from the terminal, which is usefull for passwords.
If you set "FormatText" to I<simple> then the formatting can be
done this way instead:
bold: *word*
underlined: _word_
inverse: {word}
hidden: /word/
=head1 ENCRYPTION
You can turn on encryption from the config file.
Simply set UseEncryption to 1. Please note, that you need
to decide, if you want to use encryption before the first use
of note! If have already a note database and want to "migrate"
to encryption, I suggest you to follow the directions in the
file UPGRADE!
You can choose from different encryption algorythms. The default
is IDEA, but DES or BLOWFISH are also possible. You need to have
installed the following additional perl-modules on your system:
MD5
Crypt::IDEA
Crypt::DES
Crypt::CBC
After turning on encryption, note will ask you for a passphrase
everytime it runs! It will *not* store this passphrase!
So, don't forget it! Be careful!
=head1 CONFIGURATION
You can use a configuration file with note but it is not required.
Note will use default values if there is no config.
The default config file is B<~/.noterc>. You may specify another
one with the commandline flag I<--config>.
Comments start with #, empty lines will be ignored.
To turn on an option, set it to: B<1>, B<on> or B<yes>.
To turn off an option, set it to: B<0>, B<off> or B<no>.
An option consists of an atribute-value pair separated
by minimum one space (more spaces and/or tabs are allowed)
and an optional equal sign in between.
Variable names are case in-sensitive.
For a detailed explanation of each possible parameter take a look
at the supplied sample configuration file in B<config/noterc>.
=head1 AUTHOR
Thomas Linden <tom@daemon.de>
=head1 VERSION
1.3.1 (12/01/2005)
=cut

0
blib/man3/.exists Normal file
View File

View File

@@ -0,0 +1,224 @@
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "NOTEDB::binary 3pm"
.TH NOTEDB::binary 3pm "2005-10-25" "perl v5.8.4" "User Contributed Perl Documentation"
.SH "NAME"
NOTEDB::binary \- module lib for accessing a notedb from perl
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& # include the module
\& use NOTEDB;
.Ve
.PP
.Vb 2
\& # create a new NOTEDB object
\& $db = new NOTEDB("binary", "/home/tom/.notedb", 4096, 24);
.Ve
.PP
.Vb 5
\& # decide to use encryption
\& # $key is the cipher to use for encryption
\& # $method must be either Crypt::IDEA or Crypt::DES
\& # you need Crypt::CBC, Crypt::IDEA and Crypt::DES to have installed.
\& $db\->use_crypt($key,$method);
.Ve
.PP
.Vb 3
\& # do not use encryption
\& # this is the default
\& $db\->no_crypt;
.Ve
.PP
.Vb 2
\& # get a single note
\& ($note, $date) = $db\->get_single(1);
.Ve
.PP
.Vb 4
\& # search for a certain note
\& %matching_notes = $db\->get_search("somewhat");
\& # format of returned hash:
\& #$matching_notes{$numberofnote}\->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
.Ve
.PP
.Vb 3
\& # get all existing notes
\& %all_notes = $db\->get_all();
\& # format of returnes hash like the one from get_search above
.Ve
.PP
.Vb 2
\& # get the next noteid available
\& $next_num = $db\->get_nextnum();
.Ve
.PP
.Vb 2
\& # modify a certain note
\& $db\->set_edit(1, "any text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # create a new note
\& $db\->set_new(5, "any new text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # delete a certain note
\& $db\->set_del(5);
.Ve
.PP
.Vb 2
\& # turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
\& $db\->use_crypt("passphrase", "CryptMethod");
.Ve
.PP
.Vb 2
\& # turn off encryption. This is the default.
\& $db\->no_crypt();
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
You can use this module for accessing a note database. There are currently
two versions of this module, one version for a \s-1SQL\s0 database and one for a
binary file (note's own database\-format).
However, both versions provides identical interfaces, which means, you do
not need to change your code, if you want to switch to another database format.
.PP
Currently, \s-1NOTEDB\s0 module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
.SH "USAGE"
.IX Header "USAGE"
please see the section \s-1SYNOPSIS\s0, it says it all.
.SH "AUTHOR"
.IX Header "AUTHOR"
Thomas Linden <tom@daemon.de>.

202
blib/man3/NOTEDB::dbm.3pm Normal file
View File

@@ -0,0 +1,202 @@
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "NOTEDB::dbm 3pm"
.TH NOTEDB::dbm 3pm "2005-10-25" "perl v5.8.4" "User Contributed Perl Documentation"
.SH "NAME"
NOTEDB::dbm \- module lib for accessing a notedb from perl
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& # include the module
\& use NOTEDB;
.Ve
.PP
.Vb 2
\& # create a new NOTEDB object (the last 4 params are db table/field names)
\& $db = new NOTEDB("mysql","note","/home/user/.notedb/");
.Ve
.PP
.Vb 2
\& # get a single note
\& ($note, $date) = $db\->get_single(1);
.Ve
.PP
.Vb 4
\& # search for a certain note
\& %matching_notes = $db\->get_search("somewhat");
\& # format of returned hash:
\& #$matching_notes{$numberofnote}\->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
.Ve
.PP
.Vb 3
\& # get all existing notes
\& %all_notes = $db\->get_all();
\& # format of returnes hash like the one from get_search above
.Ve
.PP
.Vb 2
\& # get the next noteid available
\& $next_num = $db\->get_nextnum();
.Ve
.PP
.Vb 2
\& # recount all noteids starting by 1 (usefull after deleting one!)
\& $db\->set_recountnums();
.Ve
.PP
.Vb 2
\& # modify a certain note
\& $db\->set_edit(1, "any text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # create a new note
\& $db\->set_new(5, "any new text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # delete a certain note
\& $db\->set_del(5);
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
You can use this module for accessing a note database. This is the dbm module.
It uses the \s-1DB_FILE\s0 module to store it's data and it uses \s-1DBM\s0 files for tis purpose.
.PP
Currently, \s-1NOTEDB\s0 module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
.SH "USAGE"
.IX Header "USAGE"
please see the section \s-1SYNOPSIS\s0, it says it all.
.SH "AUTHOR"
.IX Header "AUTHOR"
Thomas Linden <tom@daemon.de>.

View File

@@ -0,0 +1,221 @@
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "NOTEDB::dumper 3pm"
.TH NOTEDB::dumper 3pm "2005-10-25" "perl v5.8.4" "User Contributed Perl Documentation"
.SH "NAME"
NOTEDB::text \- module lib for accessing a notedb from perl
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& # include the module
\& use NOTEDB;
.Ve
.PP
.Vb 2
\& # create a new NOTEDB object
\& $db = new NOTEDB("text", "/home/tom/.notedb", 4096, 24);
.Ve
.PP
.Vb 5
\& # decide to use encryption
\& # $key is the cipher to use for encryption
\& # $method must be either Crypt::IDEA or Crypt::DES
\& # you need Crypt::CBC, Crypt::IDEA and Crypt::DES to have installed.
\& $db\->use_crypt($key,$method);
.Ve
.PP
.Vb 3
\& # do not use encryption
\& # this is the default
\& $db\->no_crypt;
.Ve
.PP
.Vb 2
\& # get a single note
\& ($note, $date) = $db\->get_single(1);
.Ve
.PP
.Vb 4
\& # search for a certain note
\& %matching_notes = $db\->get_search("somewhat");
\& # format of returned hash:
\& #$matching_notes{$numberofnote}\->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
.Ve
.PP
.Vb 3
\& # get all existing notes
\& %all_notes = $db\->get_all();
\& # format of returnes hash like the one from get_search above
.Ve
.PP
.Vb 2
\& # get the next noteid available
\& $next_num = $db\->get_nextnum();
.Ve
.PP
.Vb 2
\& # modify a certain note
\& $db\->set_edit(1, "any text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # create a new note
\& $db\->set_new(5, "any new text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # delete a certain note
\& $db\->set_del(5);
.Ve
.PP
.Vb 2
\& # turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
\& $db\->use_crypt("passphrase", "CryptMethod");
.Ve
.PP
.Vb 2
\& # turn off encryption. This is the default.
\& $db\->no_crypt();
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
You can use this module for accessing a note database. This backend uses
a text file for storage and Storable for accessing the file.
.PP
Currently, \s-1NOTEDB\s0 module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
.SH "USAGE"
.IX Header "USAGE"
please see the section \s-1SYNOPSIS\s0, it says it all.
.SH "AUTHOR"
.IX Header "AUTHOR"
Thomas Linden <tom@daemon.de>.

View File

@@ -0,0 +1,221 @@
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "NOTEDB::general 3pm"
.TH NOTEDB::general 3pm "2005-10-25" "perl v5.8.4" "User Contributed Perl Documentation"
.SH "NAME"
NOTEDB::general \- module lib for accessing a notedb from perl
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& # include the module
\& use NOTEDB;
.Ve
.PP
.Vb 2
\& # create a new NOTEDB object
\& $db = new NOTEDB("text", "/home/tom/.notedb", 4096, 24);
.Ve
.PP
.Vb 5
\& # decide to use encryption
\& # $key is the cipher to use for encryption
\& # $method must be either Crypt::IDEA or Crypt::DES
\& # you need Crypt::CBC, Crypt::IDEA and Crypt::DES to have installed.
\& $db\->use_crypt($key,$method);
.Ve
.PP
.Vb 3
\& # do not use encryption
\& # this is the default
\& $db\->no_crypt;
.Ve
.PP
.Vb 2
\& # get a single note
\& ($note, $date) = $db\->get_single(1);
.Ve
.PP
.Vb 4
\& # search for a certain note
\& %matching_notes = $db\->get_search("somewhat");
\& # format of returned hash:
\& #$matching_notes{$numberofnote}\->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
.Ve
.PP
.Vb 3
\& # get all existing notes
\& %all_notes = $db\->get_all();
\& # format of returnes hash like the one from get_search above
.Ve
.PP
.Vb 2
\& # get the next noteid available
\& $next_num = $db\->get_nextnum();
.Ve
.PP
.Vb 2
\& # modify a certain note
\& $db\->set_edit(1, "any text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # create a new note
\& $db\->set_new(5, "any new text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # delete a certain note
\& $db\->set_del(5);
.Ve
.PP
.Vb 2
\& # turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
\& $db\->use_crypt("passphrase", "CryptMethod");
.Ve
.PP
.Vb 2
\& # turn off encryption. This is the default.
\& $db\->no_crypt();
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
You can use this module for accessing a note database. This backend uses
a text file for storage and Config::General for accessing the file.
.PP
Currently, \s-1NOTEDB\s0 module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
.SH "USAGE"
.IX Header "USAGE"
please see the section \s-1SYNOPSIS\s0, it says it all.
.SH "AUTHOR"
.IX Header "AUTHOR"
Thomas Linden <tom@daemon.de>.

215
blib/man3/NOTEDB::mysql.3pm Normal file
View File

@@ -0,0 +1,215 @@
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "NOTEDB::mysql 3pm"
.TH NOTEDB::mysql 3pm "2005-10-25" "perl v5.8.4" "User Contributed Perl Documentation"
.SH "NAME"
NOTEDB::mysql \- module lib for accessing a notedb from perl
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& # include the module
\& use NOTEDB;
.Ve
.PP
.Vb 2
\& # create a new NOTEDB object (the last 4 params are db table/field names)
\& $db = new NOTEDB("mysql","note","localhost","username","password","note","number","note","date");
.Ve
.PP
.Vb 2
\& # get a single note
\& ($note, $date) = $db\->get_single(1);
.Ve
.PP
.Vb 4
\& # search for a certain note
\& %matching_notes = $db\->get_search("somewhat");
\& # format of returned hash:
\& #$matching_notes{$numberofnote}\->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
.Ve
.PP
.Vb 3
\& # get all existing notes
\& %all_notes = $db\->get_all();
\& # format of returnes hash like the one from get_search above
.Ve
.PP
.Vb 2
\& # get the next noteid available
\& $next_num = $db\->get_nextnum();
.Ve
.PP
.Vb 2
\& # recount all noteids starting by 1 (usefull after deleting one!)
\& $db\->set_recountnums();
.Ve
.PP
.Vb 2
\& # modify a certain note
\& $db\->set_edit(1, "any text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # create a new note
\& $db\->set_new(5, "any new text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # delete a certain note
\& $db\->set_del(5);
.Ve
.PP
.Vb 2
\& # turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
\& $db\->use_crypt("passphrase", "CryptMethod");
.Ve
.PP
.Vb 2
\& # turn off encryption. This is the default.
\& $db\->no_crypt();
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
You can use this module for accessing a note database. There are currently
two versions of this module, one version for a \s-1SQL\s0 database and one for a
binary file (note's own database\-format).
However, both versions provides identical interfaces, which means, you do
not need to change your code, if you want to switch to another database format.
.PP
Currently, \s-1NOTEDB\s0 module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
.SH "USAGE"
.IX Header "USAGE"
please see the section \s-1SYNOPSIS\s0, it says it all.
.SH "AUTHOR"
.IX Header "AUTHOR"
Thomas Linden <tom@daemon.de>.

221
blib/man3/NOTEDB::text.3pm Normal file
View File

@@ -0,0 +1,221 @@
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "NOTEDB::text 3pm"
.TH NOTEDB::text 3pm "2005-10-25" "perl v5.8.4" "User Contributed Perl Documentation"
.SH "NAME"
NOTEDB::text \- module lib for accessing a notedb from perl
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& # include the module
\& use NOTEDB;
.Ve
.PP
.Vb 2
\& # create a new NOTEDB object
\& $db = new NOTEDB("text", "/home/tom/.notedb", 4096, 24);
.Ve
.PP
.Vb 5
\& # decide to use encryption
\& # $key is the cipher to use for encryption
\& # $method must be either Crypt::IDEA or Crypt::DES
\& # you need Crypt::CBC, Crypt::IDEA and Crypt::DES to have installed.
\& $db\->use_crypt($key,$method);
.Ve
.PP
.Vb 3
\& # do not use encryption
\& # this is the default
\& $db\->no_crypt;
.Ve
.PP
.Vb 2
\& # get a single note
\& ($note, $date) = $db\->get_single(1);
.Ve
.PP
.Vb 4
\& # search for a certain note
\& %matching_notes = $db\->get_search("somewhat");
\& # format of returned hash:
\& #$matching_notes{$numberofnote}\->{'note' => 'something', 'date' => '23.12.2000 10:33:02'}
.Ve
.PP
.Vb 3
\& # get all existing notes
\& %all_notes = $db\->get_all();
\& # format of returnes hash like the one from get_search above
.Ve
.PP
.Vb 2
\& # get the next noteid available
\& $next_num = $db\->get_nextnum();
.Ve
.PP
.Vb 2
\& # modify a certain note
\& $db\->set_edit(1, "any text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # create a new note
\& $db\->set_new(5, "any new text", "23.12.2000 10:33:02");
.Ve
.PP
.Vb 2
\& # delete a certain note
\& $db\->set_del(5);
.Ve
.PP
.Vb 2
\& # turn on encryption. CryptMethod must be IDEA, DES or BLOWFISH
\& $db\->use_crypt("passphrase", "CryptMethod");
.Ve
.PP
.Vb 2
\& # turn off encryption. This is the default.
\& $db\->no_crypt();
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
You can use this module for accessing a note database. This backend uses
a text file for storage and Storable for accessing the file.
.PP
Currently, \s-1NOTEDB\s0 module is only used by note itself. But feel free to use it
within your own project! Perhaps someone want to implement a webinterface to
note...
.SH "USAGE"
.IX Header "USAGE"
please see the section \s-1SYNOPSIS\s0, it says it all.
.SH "AUTHOR"
.IX Header "AUTHOR"
Thomas Linden <tom@daemon.de>.

566
blib/man3/note.3pm Normal file
View File

@@ -0,0 +1,566 @@
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "note 3pm"
.TH note 3pm "2005-10-25" "perl v5.8.4" "User Contributed Perl Documentation"
.SH "NAME"
note \- a perl script for maintaining notes.
.SH "SYNPOPSIS"
.IX Header "SYNPOPSIS"
note [options] [ number [,number...]]
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\fBnote\fR is a small console program written in perl, which allows
you to manage notes similar to programs like \*(L"knotes\*(R" but from
the commandline. Note can use different database-backends for
notes\-storage. It ships with a DBI-based mysql\-module(which
can also be used for other by \s-1DBI\s0 supported \s-1DBMS\s0), another
module, which uses a binary file for storage and a \s-1DBM\s0 module.
There are also two modules available which uses a text file.
Note supports since version 1.0.0 encryption(\s-1IDEA\s0 or \s-1DES\s0)!
.SH "OPTIONS"
.IX Header "OPTIONS"
.IP "\fI\-c, \-\-config file\fR" 4
.IX Item "-c, --config file"
Use another config file than the default ~/.noterc.
.IP "\fI\-l, \-\-list [topic]\fR" 4
.IX Item "-l, --list [topic]"
Lists all existing notes. If no topic were specified,
it will display a list of all existing topics.
See the section \fI\s-1TOPICS\s0\fR for details about topics.
.IP "\fI\-L, \-\-longlist [topic]\fR" 4
.IX Item "-L, --longlist [topic]"
The same as \fI\-l\fR but prints also the timestamp of the notes.
.IP "\fI\-t, \-\-topic\fR" 4
.IX Item "-t, --topic"
Prints a list of all topics as a tree.
.IP "\fI\-T, \-\-longtopic\fR" 4
.IX Item "-T, --longtopic"
Prints the topic-tree with the notes under each topic.
.IP "\fI\-s, \-\-search string\fR" 4
.IX Item "-s, --search string"
Searches for <string> trough the notes database. See the section
\&\fI\s-1SEARCHING\s0\fR for details about the search engine.
.IP "\fI\-e, \-\-edit number\fR" 4
.IX Item "-e, --edit number"
Edit the note with the number <number> using your default editor
or the one you specified in the config file.
.IP "\fI\-d, \-\-delete number\fR" 4
.IX Item "-d, --delete number"
Delete the note with the number <number>. You can delete multiple notes
with one command. \*(L"1\-4\*(R" deletes the notes 1,2,3,4. And \*(L"1,5,7\*(R" deletes
the specified ones.
.IP "\fI\-D, \-\-Dump [file | \-]\fR" 4
.IX Item "-D, --Dump [file | -]"
Dumps all notes to the textfile <file>. If <file> is a \*(L"\-\*(R" it will
be printed out to standard output (\s-1STDOUT\s0).
.IP "\fI\-I, \-\-Import file | \-\fR" 4
.IX Item "-I, --Import file | -"
Imports a previously dumped textfile into the
note database. Data will be appended by default.
You can also specify a dash \fInote \-I \-\fR instead of a <file>,
which causes note, silently to read in a dump from \s-1STDIN\s0.
.IP "\fI\-o, \-\-overwrite\fR" 4
.IX Item "-o, --overwrite"
Only suitable for use with \-\-Import. Overwrites an
existing notedb. Use with care.
.IP "\fI\-r, \-\-raw\fR" 4
.IX Item "-r, --raw"
Raw mode, output will not be formatted. Works not in interactive
mode, only on cmd-line for list and display. That means, no colors
will be used and no lines or titles.
.IP "\fI\-i, \-\-interactive\fR" 4
.IX Item "-i, --interactive"
Start note in interactive mode. See the section \fI\s-1INTERACTIVE\s0 \s-1MODE\s0\fR
for details on this mode.
.IP "\fI\-\-encrypt cleartext\fR" 4
.IX Item "--encrypt cleartext"
Encrypt the given clear text string. You would need that if you want to
store the mysql password not in cleartext in the config(if you are using
the mysql backend!).
.IP "\fI\-h, \-\-help\fR" 4
.IX Item "-h, --help"
Display this help screen.
.IP "\fI\-v, \-\-version\fR" 4
.IX Item "-v, --version"
Display the version number.
.IP "\fB\-\fR" 4
.IX Item "-"
If you run note just with one dash: \fBnote \-\fR, then it will read in a new
note from \s-1STDIN\s0 until \s-1EOF\s0. This makes it possible to pipe text into a new note, i.e.:
.Sp
.Vb 1
\& cat sometextfile | note \-
.Ve
.SH "USAGE"
.IX Header "USAGE"
.Sh "\s-1GENERAL\s0 \s-1USAGE\s0"
.IX Subsection "GENERAL USAGE"
If you don't know, how to run note, try \*(L"note \-h\*(R" first.
It will tell you all available commandline options.
.PP
To create a new note, simply run \*(L"note\*(R". You can enter
the note (the length is by default limited to 4096 bytes,
which you can change from your config file if you are using
the binary backend, otherwise there is no limitation).
End by typing a . on a line itself. note will tell you the
number of the note.
.PP
If you want to view the note, type \*(L"note 1\*(R", if the notenumber
was 1.
.PP
If you want to get an overview of all notes, type \*(L"note \-l\*(R".
You will get a list of all notes, containing the number,
the first line and the creation date. If topic-support is
turned on (which is by default), then all subtopics under the
current topic will be displayed first.
If you want to see the timestamps, use \*(L"\-L\*(R" instead of \*(L"\-l\*(R".
Read more about topics below in the section \*(L"Topics\*(R".
You can also specify the topic which notes you want to see:
\&\*(L"\-l mytopic\*(R" does the trick.
Additional, you might want to get an overview of your topic\-
structure. You can use the command \*(L"\-t\*(R" in this case, which
will display a tree-view of your topic\-structure. You can
use the command \*(L"\-T\*(R" if you want to see the notes under each
topic too. \*(L"\-T\*(R" will also show the number of each note.
.PP
To edit a certain note, type \*(L"note \-e 1\*(R". It will invoke your
editor (vi or pico). You can edit it, after saving, note
will store the changed note to the database.
.PP
Of course you can drop a certain note: \*(L"note \-d 1\*(R" deletes
note number 1. If a note in the middle or the beginning of
the database will be deleted, note will recount the other
existent notes. For example there are 3 notes, number 1, 2
and 3. If you delete number 2, then number 3 will become
number 2.
You can also make use of the extended delete\-syntax:
To delete note 1 and 2, use \*(L"\-d 1,2\*(R"
To delete note 1,2 and 3, use \*(L"\-d 1\-3\*(R".
.Sh "\s-1SEARCHING\s0"
.IX Subsection "SEARCHING"
If you cannot remember, which note you are looking for, you
can use the search capability of note: \*(L"note \-s <searchstring>\*(R".
note will search the whole note database case insensitive for
an occurence of this string and tell you the number and first\-
line it has.
.PP
You can extend the searchstring using \fB\s-1AND\s0\fR, \fB\s-1OR\s0\fR ( and ) and
shell-like wildcards:
.PP
.Vb 1
\& $ note \-s "moses AND lenin"
.Ve
.PP
or:
.PP
.Vb 1
\& $ note \-s "(mike OR arnold) AND (jackson OR schwarzenegger)"
.Ve
.PP
If note finds a note, which first line is a topic, then it will
display it's second line.
.PP
These rules apply for the interactive search too.
.PP
You need to know, that note searches for the expression in every
note. In other words, \*(L"moses \s-1AND\s0 lenin\*(R" searches for an occurence
of \*(L"moses\*(R" and \*(L"lenin\*(R" in \s-1ONE\s0 note. Or, if you are looking for
\&\*(L"mike \s-1OR\s0 daniel\*(R", then it searches for an occurence of \*(L"mike\*(R" or
daniel\*(L" in \s-1ONE\s0 note. Thus a note with the text \*(R"mike oldfield" will
match that search.
.Sh "\s-1TOPICS\s0"
.IX Subsection "TOPICS"
If topic-support is turned on (which is by default), the various
notes are sorted under various topics. There is no special database
field for the topic. Instead the topic will be stored right in the
note.
If the first line of your note contains some text bordered by slashes
(or whatever you prefer, set \*(L"TopicSeparator\*(R" in your config! default
is slash), then note will consider it as the topic of this certain
note. For examle:
.PP
.Vb 1
\& B</TodoList/>
.Ve
.PP
If you are using topics, no data after the topic is allowed, if there
is any text, note will consider it as a subtopic! Therefore, don't for\-
get to put a newline after the topic\-line.
.PP
The list-command will only show you notes under this topic. If you
create a new note, it will automagically inserted under the current
topic (note will prepend the string \*(L"/topicname/\*(R" to the text of your
note).
.PP
You can create at any time from any point a new topic. Just create a new
note and type the name of the new topic bordered by slashes (or
TopicSeparator) at the first line of this note. After saving, there
will be available a new topic with one note in it.
.PP
You can create as many subtopics as you like, the format is similar to
a filesystem\-path. An example, say, you want to create such a
structure:
.PP
.Vb 10
\& (root \- top level)
\& |
\& |\-\-\-\-test
\& | |\-\-\-\-subtopic
\& | | |\-\-note 1
\& | | |\-\-note 2
\& | |
\& | |\-\-note 4
\& |
\& |\-\-note 3
.Ve
.PP
Then you may create those 4 new notes:
.PP
.Vb 12
\& \-\-\- snip \-\-\-
\& /test/subtopic/
\& note 1
\& \-\-\- snip \-\-\-
\& /test/subtopic/
\& note 2
\& \-\-\- snip \-\-\-
\& note 3
\& \-\-\- snip \-\-\-
\& /test/
\& note 4
\& \-\-\- snip \-\-\-
.Ve
.PP
I hope, you got the point ;\-)
.PP
If a note does not contain the \*(L"magic\*(R" /topic/ construction on the first
line, it will be listed under the \*(L"root\*(R" of note, that is the point
you are at the startup of note.
.PP
You can subsequently move a note without a topic to a certain topic.
Simply edit it and insert at the first line the above mentioned
construction.
.PP
Note: Please don't forget the prepending and appending a slash of a
topic. You will get strange results without it!
.Sh "\s-1INTERACTIVE\s0 \s-1MODE\s0"
.IX Subsection "INTERACTIVE MODE"
If you start note with the commandline flag \fB\-i\fR, then it starts
with an interactive interface.
It will start with a listing under the default top-topic (\*(L"/\*(R").
You can enter the name of a topic to change to that topic. This works
similar to a filesystem structure. The current topic will be
displayed on the top of the screen.
.PP
The following commands are available:
.IP "\fBL [topic]\fR" 4
.IX Item "L [topic]"
This command lists all notes with a timestamp. If you specify a topic, it
will only list the notes under this topic. If you are under a certain subtopic,
then it will only display the notes under this topic.
.IP "\fBl [topic]\fR" 4
.IX Item "l [topic]"
This commands behaves similar to \fBL\fR but it does not display the timestamp.
You can achieve the same result by simply pressing enter at any time.
.IP "\fBN\fR" 4
.IX Item "N"
You can create a new note by simply pressing \fBN\fR or \fBn\fR. You favorite
editor will be started and you can enter your note text. If you are already
under a topic then this new note will automatically go to this topic.
note adds an aditional line to the top of the note with the topic. But
you can of course specify your own topic.
.Sp
Note will tell you which number it has assigned to the newly created note.
.IP "\fBE number\fR" 4
.IX Item "E number"
By entering \fBE\fR or \fBe\fR and a note-number you can edit an existing note
using your favorite editor. This way you can also move an existing note
from one topic to another one by editing the first line of the note.
.IP "\fBD number\fR" 4
.IX Item "D number"
\&\fBE\fR or \fBe\fR deletes one or more existing note(s). It requires a note number
or a set of note numbers. 1\-5 and 1,7,9 are possible values.
After one or more notes has been deleted note will recount all remaining notes.
Say if you delete 1 and 2, then 3 will become 1, 4 will become 5 and so forth.
.IP "\fBS [expression]\fR" 4
.IX Item "S [expression]"
You can search for the occurence of a text in your notes-database with the
command \fBS\fR or \fBs\fR. If you omit an expression note will ask you for one.
.Sp
If your search criteria matches on exactly one entry, note will display
that note entry instead of displaying its number.
.IP "\fBT\fR" 4
.IX Item "T"
This prints a tree-view of your topic\-structure. \fBT\fR displays the tree with
notes, \fBt\fR displays just the topics without notes.
.IP "\fBcd topic\fR" 4
.IX Item "cd topic"
Change the actual topic under which you are. This works identical like just
entering the topic but it has some advantages. You can enter \fBcd ..\fR if
you want to go one level up in the topic\-structure. And you can enter \fBcd /\fR
to go to the top of the structure. You can always leave out the 'cd' keyword too.
.Sp
Additional it is possible to enter a note-number instead of a topic name.
For this feature to be active you need to set the config option \fBShortCd\fR
to \fB1\fR or \fByes\fR. If you use a number and the note with this number is
under a certain topic then you will \*(L"cd\*(R" to this topic. This allows you
to do kind of jumps over multiple levels of topics.
.Sp
If is possible to abbreviate a topic. This works only if the abbreviation
matches on one single topic. If it matches more than one topic then the
available ones will be suggested.
.IP "\fB? or h\fR" 4
.IX Item "? or h"
Display a short help screen.
.IP "\fBQ\fR" 4
.IX Item "Q"
Quit note.
.Sh "\s-1BACKUP\s0"
.IX Subsection "BACKUP"
You can also dump the contents of your note-database into a
ASCII\-textfile(\fI\-D\fR). You can use this file later to import it into
your note\-database(\-I). This is usefull, if you want quickly trans\-
fer your notes from one host to another (i.e. you could mail
your note-dump form your office to home and import it there
for further use).
.PP
The dumps from the two versions of note are in the same format.
Using dumps it is also possible to reinitialize your database. You
can use the \*(L"\-o\*(R" switch whcih causes note to overwrite your existing
database. This is very handy if you changed heavily your config. And
it is required, if you changed: encryption, db\-driver, (binary\-format)
and the password. You can use the following command for reinitializing:
.PP
.Vb 1
\& $ note \-D \- | note \-o \-I \-
.Ve
.PP
What the hell, does this do?! Step by step:
.IP "\(bu" 4
\&\fBnote \-D \-\fR creates a note-database dump and prints it out
to stantdard output.
.IP "\(bu" 4
\&\fB|\fR this is the shell's pipe command. It takes the output
of the left program and gives it to the right program as
standard input.
.IP "\(bu" 4
\&\fBnote \-o \-I \-\fR imports a note-database dump from standard
input and overwrites an existing database.
.PP
Before you use the \fB\-o\fR switch, I consider you to make a backup!
.Sh "\s-1FORMATING\s0"
.IX Subsection "FORMATING"
Another very nice feature is the possibility to format the note-text
(as much as shell allows it). First, you can use the note-internal
\&\*(L"magic\-strings\*(R" for colorizing. Those strings looks much like \s-1HTML:\s0
\&\*(L"<green>here is a green line of text</green> no more green.\*(R"
As you see, the beginning of another color starts with a tag(kinda) of
the color <colorname> and ends with an end tag </colorname>.
.PP
The following colors are available:
black, red, green, yellow, blue, magenta, cyan and white.
.PP
Beside colorizing text, you can also create bold or underlined text! If
you decide to use this (additional) feature, you need to set the
Config-Option \*(L"FormatText\*(R" to 1 which turns it on.
Usage is very straightforward, if a word (a word is defined as some
text with at least one space surrounded) is between a magic mark\-
character. Here are the available things, you can do:
.PP
.Vb 4
\& bold: **word**
\& underlined: __word__
\& inverse: {{word}}
\& hidden: //word//
.Ve
.PP
The text will be formatted using the actually note\-color.
.PP
The hidden formatting will use blue forground and blue background
to hide a string from the terminal, which is usefull for passwords.
.PP
If you set \*(L"FormatText\*(R" to \fIsimple\fR then the formatting can be
done this way instead:
.PP
.Vb 4
\& bold: *word*
\& underlined: _word_
\& inverse: {word}
\& hidden: /word/
.Ve
.SH "ENCRYPTION"
.IX Header "ENCRYPTION"
You can turn on encryption from the config file.
Simply set UseEncryption to 1. Please note, that you need
to decide, if you want to use encryption before the first use
of note! If have already a note database and want to \*(L"migrate\*(R"
to encryption, I suggest you to follow the directions in the
file \s-1UPGRADE\s0!
.PP
You can choose from different encryption algorythms. The default
is \s-1IDEA\s0, but \s-1DES\s0 or \s-1BLOWFISH\s0 are also possible. You need to have
installed the following additional perl-modules on your system:
\&\s-1MD5\s0
Crypt::IDEA
Crypt::DES
Crypt::CBC
.PP
After turning on encryption, note will ask you for a passphrase
everytime it runs! It will *not* store this passphrase!
So, don't forget it! Be careful!
.SH "CONFIGURATION"
.IX Header "CONFIGURATION"
You can use a configuration file with note but it is not required.
Note will use default values if there is no config.
.PP
The default config file is \fB~/.noterc\fR. You may specify another
one with the commandline flag \fI\-\-config\fR.
.PP
Comments start with #, empty lines will be ignored.
.PP
To turn on an option, set it to: \fB1\fR, \fBon\fR or \fByes\fR.
.PP
To turn off an option, set it to: \fB0\fR, \fBoff\fR or \fBno\fR.
.PP
An option consists of an atribute-value pair separated
by minimum one space (more spaces and/or tabs are allowed)
and an optional equal sign in between.
.PP
Variable names are case in\-sensitive.
.PP
For a detailed explanation of each possible parameter take a look
at the supplied sample configuration file in \fBconfig/noterc\fR.
.SH "AUTHOR"
.IX Header "AUTHOR"
Thomas Linden <tom@daemon.de>
.SH "VERSION"
.IX Header "VERSION"
1.3.1 (12/01/2005)

0
blib/script/.exists Normal file
View File

1671
blib/script/note Executable file

File diff suppressed because it is too large Load Diff