mirror of
https://codeberg.org/scip/note.git
synced 2025-12-16 20:21:04 +01:00
-
This commit is contained in:
20
Changelog
20
Changelog
@@ -1,3 +1,23 @@
|
||||
1.2.7:
|
||||
ADDED: new config option: ReadOnly
|
||||
ADDED: new database backend: NOTEDB::text, which uses the Storable
|
||||
module.
|
||||
CHANGED: the data import will now written to db once.
|
||||
CHANGED: added global database locking support, which is usually
|
||||
useful in multiuser environments.
|
||||
ADDED: new database backend: NOTEDB::general, which uses the
|
||||
Config::General module.
|
||||
CLEANUP: almost everywhere
|
||||
CHANGED: noterc config format changed! especially the config for
|
||||
backend drivers has changed a lot.
|
||||
CHANGED: the configuration variables are now stored in a hash, this
|
||||
saved some global variables, the driver variables are stored
|
||||
in an extra hash, which contains one key per driver, this
|
||||
hash gets supplied to the driver backend module 1:1.
|
||||
CHANGED: the libpath variable has been removed, it didnt't work either.
|
||||
use now .. instead, so that a local installation for a non
|
||||
root user is still possible.
|
||||
================================================================================
|
||||
1.2.6:
|
||||
FIXED: the binary driver (NOTEDB::binary) encounters now if a note
|
||||
entry is bigger then MaxNoteByte. It prints the overlapping
|
||||
|
||||
57
NOTEDB.pm
57
NOTEDB.pm
@@ -2,7 +2,7 @@
|
||||
# this is a generic module, used by note database
|
||||
# backend modules.
|
||||
#
|
||||
# Copyright (c) 2000-2003 Thomas Linden <tom@daemon.de>
|
||||
# Copyright (c) 2000-2004 Thomas Linden <tom@daemon.de>
|
||||
|
||||
|
||||
package NOTEDB;
|
||||
@@ -241,4 +241,59 @@ sub check_exact {
|
||||
|
||||
|
||||
|
||||
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}) {
|
||||
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 " timeout\n";
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub unlock {
|
||||
my ($this) = @_;
|
||||
unlink $this->{LOCKFILE};
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@@ -3,38 +3,44 @@
|
||||
# Perl module for note
|
||||
# binary database backend. see docu: perldoc NOTEDB::binary
|
||||
#
|
||||
package NOTEDB;
|
||||
package NOTEDB::binary;
|
||||
|
||||
$NOTEDB::binary::VERSION = "1.10";
|
||||
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
#use Data::Dumper;
|
||||
use IO::Seekable;
|
||||
use File::Spec;
|
||||
|
||||
use NOTEDB;
|
||||
|
||||
use Fcntl qw(LOCK_EX LOCK_UN);
|
||||
|
||||
use NOTEDB;
|
||||
use Exporter ();
|
||||
use vars qw(@ISA @EXPORT);
|
||||
@ISA = qw(NOTEDB Exporter);
|
||||
|
||||
|
||||
sub new
|
||||
{
|
||||
my($this, $dbdriver, $dbname, $MAX_NOTE, $MAX_TIME) = @_;
|
||||
|
||||
|
||||
sub new {
|
||||
my($this, %param) = @_;
|
||||
|
||||
my $class = ref($this) || $this;
|
||||
my $self = {};
|
||||
bless($self,$class);
|
||||
|
||||
if(! -e $dbname) {
|
||||
open(TT,">$dbname") or die "Could not create $dbname: $!\n";
|
||||
$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 $dbname) {
|
||||
print "$dbname is not writable!\n";
|
||||
elsif(! -w $self->{NOTEDB}) {
|
||||
print "$self->{NOTEDB} is not writable!\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$self->{version} = "(NOTEDB::binary, 1.8)";
|
||||
$self->{NOTEDB} = $dbname;
|
||||
|
||||
my $TYPEDEF = "i a$MAX_NOTE a$MAX_TIME";
|
||||
my $SIZEOF = length pack($TYPEDEF, () );
|
||||
@@ -42,6 +48,7 @@ sub new
|
||||
$self->{sizeof} = $SIZEOF;
|
||||
$self->{typedef} = $TYPEDEF;
|
||||
$self->{maxnote} = $MAX_NOTE;
|
||||
$self->{LOCKFILE} = $self->{NOTEDB} . "~LOCK";
|
||||
|
||||
return $self;
|
||||
}
|
||||
@@ -54,7 +61,7 @@ sub DESTROY
|
||||
|
||||
sub version {
|
||||
my $this = shift;
|
||||
return $this->{version};
|
||||
return $NOTEDB::binary::VERSION;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +123,13 @@ sub get_all
|
||||
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
|
||||
{
|
||||
@@ -365,6 +379,31 @@ sub warn_if_too_big {
|
||||
}
|
||||
}
|
||||
|
||||
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!
|
||||
|
||||
@@ -4,32 +4,42 @@
|
||||
# DBM database backend. see docu: perldoc NOTEDB::dbm
|
||||
#
|
||||
|
||||
package NOTEDB;
|
||||
package NOTEDB::dbm;
|
||||
|
||||
$NOTEDB::dbm::VERSION = "1.40";
|
||||
|
||||
use DB_File;
|
||||
use Data::Dumper;
|
||||
use NOTEDB;
|
||||
use strict;
|
||||
use Exporter ();
|
||||
use vars qw(@ISA @EXPORT %note %date);
|
||||
@ISA = qw(NOTEDB Exporter);
|
||||
|
||||
|
||||
|
||||
|
||||
# Globals:
|
||||
my (%note, %date);
|
||||
|
||||
|
||||
sub new
|
||||
{
|
||||
my($this, $dbdriver, $dbm_dir) = @_;
|
||||
my($this, %param) = @_;
|
||||
my $class = ref($this) || $this;
|
||||
my $self = {};
|
||||
bless($self,$class);
|
||||
|
||||
my $notefile = "note.dbm";
|
||||
my $timefile = "date.dbm";
|
||||
$self->{version} = "(NOTEDB::dbm, 1.2)";
|
||||
my $notefile = "note.dbm";
|
||||
my $timefile = "date.dbm";
|
||||
my $dbm_dir = $param{directory} || File::Spec->catfile($ENV{HOME}, ".note_dbm");
|
||||
|
||||
tie %note, "DB_File", "$dbm_dir/$notefile" || die $!;
|
||||
tie %date, "DB_File", "$dbm_dir/$timefile" || die $!;
|
||||
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;
|
||||
}
|
||||
@@ -66,6 +76,14 @@ sub get_all
|
||||
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
|
||||
{
|
||||
|
||||
402
NOTEDB/general.pm
Normal file
402
NOTEDB/general.pm
Normal file
@@ -0,0 +1,402 @@
|
||||
# Perl module for note
|
||||
# general database backend. see docu: perldoc NOTEDB::general
|
||||
# using Config::General as backend.
|
||||
|
||||
package NOTEDB::general;
|
||||
|
||||
$NOTEDB::general::VERSION = "1.00";
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
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;
|
||||
|
||||
my $content = SaveConfigString($data) or die "could not serialize data: $!\n";
|
||||
print NOTE $content;
|
||||
|
||||
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
|
||||
@@ -1,31 +1,41 @@
|
||||
#!/usr/bin/perl
|
||||
# $Id: mysql.pm,v 1.3 2000/08/11 00:05:58 zarahg Exp $
|
||||
#
|
||||
# Perl module for note
|
||||
# mysql database backend. see docu: perldoc NOTEDB::mysql
|
||||
#
|
||||
|
||||
|
||||
package NOTEDB;
|
||||
package NOTEDB::mysql;
|
||||
|
||||
$NOTEDB::mysql::VERSION = "1.50";
|
||||
|
||||
use DBI;
|
||||
use strict;
|
||||
use Data::Dumper;
|
||||
#use Data::Dumper;
|
||||
use NOTEDB;
|
||||
|
||||
use Exporter ();
|
||||
use vars qw(@ISA @EXPORT);
|
||||
@ISA = qw(NOTEDB Exporter);
|
||||
|
||||
|
||||
sub new
|
||||
{
|
||||
# no prototype, because of the bin-version, which takes only a filename!
|
||||
|
||||
my($this, $dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd,
|
||||
$table, $fnum, $fnote, $fdate, $dbport) = @_;
|
||||
|
||||
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 $database;
|
||||
if ($dbport) {
|
||||
$database = "DBI:$dbdriver:$dbname;host=$dbhost:$dbport";
|
||||
@@ -34,8 +44,7 @@ sub new
|
||||
$database = "DBI:$dbdriver:$dbname;host=$dbhost";
|
||||
}
|
||||
|
||||
$self->{version} = "(NOTEDB::mysql, 1.5)";
|
||||
$self->{table} = $table;
|
||||
$self->{table} = "table";
|
||||
|
||||
$self->{sql_getsingle} = "SELECT $fnote,$fdate FROM $self->{table} WHERE $fnum = ?";
|
||||
$self->{sql_all} = "SELECT $fnum,$fnote,$fdate FROM $self->{table}";
|
||||
@@ -278,6 +287,14 @@ sub set_recountnums {
|
||||
$this->changed;
|
||||
}
|
||||
|
||||
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 uen
|
||||
{
|
||||
my $this = shift;
|
||||
|
||||
355
NOTEDB/text.pm
Normal file
355
NOTEDB/text.pm
Normal file
@@ -0,0 +1,355 @@
|
||||
# Perl module for note
|
||||
# text database backend. see docu: perldoc NOTEDB::text
|
||||
# using Storable as backend.
|
||||
|
||||
package NOTEDB::text;
|
||||
|
||||
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";
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
sub DESTROY
|
||||
{
|
||||
# clean the desk!
|
||||
}
|
||||
|
||||
sub version {
|
||||
my $this = shift;
|
||||
return $this->{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, );
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
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}) {
|
||||
my $data = lock_retrieve($this->{NOTEDB});
|
||||
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
|
||||
33
README
33
README
@@ -1,4 +1,4 @@
|
||||
note 1.2.6 by Thomas Linden, 30/06/2004
|
||||
note 1.3.0 by Thomas Linden, 11/01/2005
|
||||
=======================================
|
||||
|
||||
Introduction
|
||||
@@ -21,16 +21,25 @@ which you can use with note:
|
||||
for data storage and requires the module DB_FILE,
|
||||
which is part of the perl standard distribution.
|
||||
See below for more details about the DBM module.
|
||||
|
||||
o NOTEDB::general - uses the module Config::General
|
||||
for storage, which makes the data file portable,
|
||||
since it is a plain ascii file (binary content
|
||||
will be base64 encoded).
|
||||
o NOTEDB::text - uses the Storable module for data
|
||||
storage (a serializer). Storable is included with
|
||||
perl, and since it's written in C, it's very fast.
|
||||
But the resulting data files are not that portable
|
||||
as the once of NOTEDB::general are.
|
||||
|
||||
|
||||
Where to get?
|
||||
=============
|
||||
|
||||
By now at
|
||||
http://www.daemon.de/note/
|
||||
By now you can download it at http://www.daemon.de/NOTE.
|
||||
If you are using debian, you can apt-get it. If you are
|
||||
using gentoo, you can emerge it.
|
||||
|
||||
You may also try your nearest tucows mirror.
|
||||
You may also try your nearest tucows or freshmeat mirror.
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +47,8 @@ You may also try your nearest tucows mirror.
|
||||
Features
|
||||
========
|
||||
|
||||
o Three different database backends, mysql(DBI), dbm, binary(bin file).
|
||||
o Several different database backends, mysql(DBI), dbm,
|
||||
binary(bin file), general and text (text files).
|
||||
o Commandline interface using the standard perl module
|
||||
Getopt::Long, which allows you to use short or long
|
||||
command-line options.
|
||||
@@ -96,6 +106,8 @@ You need the following things:
|
||||
o Getopt::Long (part of perl std ditribution)
|
||||
o Term::ReadLine and optionally Term::ReadLine::Gnu if
|
||||
you want to use the auto-completion and history functionality.
|
||||
o Config::General if you want to use the NOTEDB::general
|
||||
backend.
|
||||
|
||||
|
||||
Installation
|
||||
@@ -119,14 +131,11 @@ After that, you are ready to install. Become root and issue:
|
||||
# make install
|
||||
|
||||
The installation process installs all modules for every available
|
||||
data backend (binary, dbm and mysql). The default note configuration
|
||||
does not require additional perl modules.
|
||||
data backends. The default note configuration does not require
|
||||
additional perl modules.
|
||||
If you want to use the mysql backend refer to the installation
|
||||
instructions for the mysql database installation in mysql/README.
|
||||
|
||||
The DBM backend(NOTEDB::dbm) requires the existence of a directory,
|
||||
which you must specify in your config using the option "DbName".
|
||||
|
||||
If you want to use encryption support, you will need at least
|
||||
Crypt:CBC and Crypt::Blowfish (or Crypt::DES or whatever).
|
||||
|
||||
@@ -205,4 +214,4 @@ and I'll add you.
|
||||
Last changed
|
||||
============
|
||||
|
||||
30/06/2004
|
||||
11/01/2005
|
||||
|
||||
563
bin/note
563
bin/note
@@ -23,12 +23,19 @@
|
||||
# http://www.daemon.de/note/
|
||||
#
|
||||
|
||||
BEGIN {
|
||||
# works on unix or cygwin only!
|
||||
my $path = $0;
|
||||
$path =~ s#/[^/]*$##;
|
||||
unshift @INC, "$path/..";
|
||||
}
|
||||
|
||||
use strict;
|
||||
no strict 'refs';
|
||||
#use Data::Dumper;
|
||||
use Getopt::Long;
|
||||
use FileHandle;
|
||||
use File::Spec;
|
||||
#use Data::Dumper;
|
||||
|
||||
|
||||
#
|
||||
@@ -66,22 +73,11 @@ my (
|
||||
#
|
||||
# set from commandline (or interactive)
|
||||
#
|
||||
$number, $searchstring, $dump_file, $ImportType, $NewType, $Raw,
|
||||
$number, $searchstring, $dump_file, $ImportType, $NewType, $Raw, $TOPIC,
|
||||
|
||||
#
|
||||
# options from config file .noterc
|
||||
#
|
||||
$maxlen, $timelen, $TOPIC, $NOTEDB, $MAX_TIME, $PreferredEditor,
|
||||
$ALWAYS_INT, $KEEP_TIMESTAMP, $COLOR, $ALWAYS_EDIT, $HOME, $FormatText,
|
||||
$BORDER_COLOR, $NOTE_COLOR, $NUM_COLOR, $TOPIC_COLOR, $MAX_NOTE,
|
||||
$USE_CRYPT, $CRYPT_METHOD, $TopicSep, $DEFAULT_LIST, $TIME_COLOR, $SHORT_CD,
|
||||
$USE_CACHE, $AUTO_CLEAR,
|
||||
|
||||
#
|
||||
# db specifics from .noterc
|
||||
#
|
||||
$db, $dbname, $dbhost, $dbport, $dbuser, $dbpasswd, $encrypt_passwd, $clearstring,
|
||||
$table, $fnum, $fnote, $fdate, $date, $dbdriver, $libpath,
|
||||
# configuration options
|
||||
%conf, %driver,
|
||||
|
||||
#
|
||||
# processed colors
|
||||
@@ -97,9 +93,9 @@ my (
|
||||
#
|
||||
# internals
|
||||
#
|
||||
$TYPE, $mode, $NoteKey, $TempDir, %Color, @LastTopic,
|
||||
$version, $CurTopic, $CurDepth, $WantTopic,$time_format,
|
||||
$sizeof, %TP, $TreeType, $ListType, $SetTitle,
|
||||
$TYPE, $mode, $NoteKey, %Color, @LastTopic, $timelen, $maxlen,
|
||||
$version, $CurTopic, $CurDepth, $WantTopic, $db,
|
||||
$sizeof, %TP, $TreeType, $ListType, $SetTitle, $clearstring,
|
||||
@ArgTopics, $key, $typedef, @NumBlock, $has_nothing, @completion_topics, @completion_notes,
|
||||
);
|
||||
|
||||
@@ -108,40 +104,31 @@ my (
|
||||
# DEFAULTS, allows one to use note without a config
|
||||
# don't change them, instead use the config file!
|
||||
#
|
||||
$maxlen = 50;
|
||||
my $keepmaxlen = "auto";
|
||||
$timelen = 22;
|
||||
$date = &getdate;
|
||||
|
||||
$conf{dbdriver} = "binary";
|
||||
$conf{color} = 1;
|
||||
$conf{border_color} = "bold";
|
||||
$conf{num_color} = "blue";
|
||||
$conf{note_color} = "green";
|
||||
$conf{time_color} = "blue";
|
||||
$conf{topic_color} = "bold";
|
||||
$conf{topicsep} = '/';
|
||||
$conf{use_crypt} = 0;
|
||||
$conf{tempdirectory} = File::Spec->tmpdir();
|
||||
$conf{always_int} = 1;
|
||||
$conf{always_edit} = 1;
|
||||
$conf{auto_clear} = 1;
|
||||
|
||||
$CONF = File::Spec->catfile($ENV{HOME}, ".noterc");
|
||||
$USER = getlogin || getpwuid($<);
|
||||
chomp $USER;
|
||||
$HOME = $ENV{'HOME'};
|
||||
$CONF = File::Spec->catfile($HOME, ".noterc");
|
||||
$dbdriver = "binary";
|
||||
$NOTEDB = File::Spec->catfile($HOME, ".notedb");
|
||||
$MAX_NOTE = 4096;
|
||||
$MAX_TIME = 84;
|
||||
$COLOR = "YES";
|
||||
$BORDER_COLOR = "bold";
|
||||
$NUM_COLOR = "blue";
|
||||
$NOTE_COLOR = "green";
|
||||
$TIME_COLOR = "blue";
|
||||
$TOPIC_COLOR = "bold";
|
||||
$TOPIC = 1;
|
||||
$TopicSep = '/';
|
||||
$version = "1.2.6";
|
||||
if ($TOPIC) {
|
||||
$CurDepth = 1; # the current depth inside the topic "directory" structure...
|
||||
}
|
||||
$USE_CRYPT = "NO";
|
||||
$TempDir = File::Spec->tmpdir();
|
||||
# mysql stuff
|
||||
$table = "note";
|
||||
$fnote = "note";
|
||||
$fdate = "date";
|
||||
$fnum = "number";
|
||||
$ALWAYS_INT = "YES";
|
||||
$ALWAYS_EDIT = "YES";
|
||||
$AUTO_CLEAR = "YES";
|
||||
$version = "1.3.0";
|
||||
$CurDepth = 1; # the current depth inside the topic "directory" structure...
|
||||
$maxlen = "auto";
|
||||
$timelen = 22;
|
||||
|
||||
|
||||
|
||||
# colors available
|
||||
# \033[1m%30s\033[0m
|
||||
@@ -227,11 +214,11 @@ else {
|
||||
elsif (defined $opt_l || defined $opt_L) {
|
||||
$mode = "list";
|
||||
if (defined $opt_l) {
|
||||
@ArgTopics = split /$TopicSep/, $opt_l;
|
||||
@ArgTopics = split /$conf{topicsep}/, $opt_l;
|
||||
}
|
||||
else {
|
||||
$ListType = "LONG";
|
||||
@ArgTopics = split /$TopicSep/, $opt_L;
|
||||
@ArgTopics = split /$conf{topicsep}/, $opt_L;
|
||||
}
|
||||
$CurDepth += $#ArgTopics + 1 if($opt_l || $opt_L);
|
||||
$CurTopic = $ArgTopics[$#ArgTopics]; # use the last element everytime...
|
||||
@@ -357,70 +344,48 @@ if ($mode eq "encrypt_passwd") {
|
||||
}
|
||||
|
||||
# Always interactive?
|
||||
if ($ALWAYS_INT eq "YES" && $mode ne "dump" && $mode ne "import") {
|
||||
if ($conf{always_int} && $mode ne "dump" && $mode ne "import") {
|
||||
$mode = "interactive";
|
||||
}
|
||||
|
||||
# OK ... Long-Listing shall be default ... You wanted it!!!
|
||||
if ($DEFAULT_LIST eq "LONG") {
|
||||
if ($conf{default_list} eq "LONG") {
|
||||
# takes only precedence in commandline mode
|
||||
$ListType="LONG";
|
||||
}
|
||||
|
||||
|
||||
|
||||
# *if* loading of the config was successful, try to load the
|
||||
# configured database backend. Currently supported:
|
||||
# mysql, dbm and binary.
|
||||
if ($libpath) {
|
||||
unshift @INC, $libpath;
|
||||
}
|
||||
|
||||
if ($dbdriver eq "binary") {
|
||||
eval {
|
||||
require NOTEDB::binary;
|
||||
$db = new NOTEDB($dbdriver, $NOTEDB, $MAX_NOTE, $MAX_TIME, $dbdriver);
|
||||
};
|
||||
}
|
||||
elsif ($dbdriver eq "mysql") {
|
||||
# do the new() later because of the encrypted password!
|
||||
eval {
|
||||
require NOTEDB::mysql;
|
||||
};
|
||||
die "mysql backend unsupported: $@\n" if($@);
|
||||
}
|
||||
else {
|
||||
eval {
|
||||
require "NOTEDB::$dbdriver";
|
||||
$db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd, $table, $fnum, $fnote, $fdate);
|
||||
};
|
||||
}
|
||||
if ($@) {
|
||||
die "$dbdriver backend unsupported: $@\n";
|
||||
}
|
||||
|
||||
|
||||
# calculate some constants...
|
||||
$BORDERC = "<$BORDER_COLOR>";
|
||||
$_BORDERC = "</$BORDER_COLOR>";
|
||||
$NUMC = "<$NUM_COLOR>";
|
||||
$_NUMC = "</$NUM_COLOR>";
|
||||
$NOTEC = "<$NOTE_COLOR>";
|
||||
$_NOTEC = "</$NOTE_COLOR>";
|
||||
$TIMEC = "<$TIME_COLOR>";
|
||||
$_TIMEC = "</$TIME_COLOR>";
|
||||
$TOPICC = "<$TOPIC_COLOR>";
|
||||
$_TOPICC = "</$TOPIC_COLOR>";
|
||||
$BORDERC = "<$conf{border_color}>";
|
||||
$_BORDERC = "</$conf{border_color}>";
|
||||
$NUMC = "<$conf{num_color}>";
|
||||
$_NUMC = "</$conf{num_color}>";
|
||||
$NOTEC = "<$conf{note_color}>";
|
||||
$_NOTEC = "</$conf{note_color}>";
|
||||
$TIMEC = "<$conf{time_color}>";
|
||||
$_TIMEC = "</$conf{time_color}>";
|
||||
$TOPICC = "<$conf{topic_color}>";
|
||||
$_TOPICC = "</$conf{topic_color}>";
|
||||
|
||||
$NoteKey = $conf{topicsep} . "notes" . $conf{topicsep};
|
||||
|
||||
|
||||
|
||||
$NoteKey = $TopicSep . "notes" . $TopicSep;
|
||||
|
||||
# default permissions on new files (tmp)
|
||||
umask 077;
|
||||
|
||||
# check if the user wants to use encryption:
|
||||
if ($USE_CRYPT eq "YES" && $NOTEDB::crypt_supported == 1) {
|
||||
if ($CRYPT_METHOD eq "") {
|
||||
$CRYPT_METHOD = "Crypt::IDEA";
|
||||
|
||||
# load the parent module
|
||||
&load_driver(1);
|
||||
|
||||
|
||||
# check wether the user wants to use encryption:
|
||||
if ($conf{use_crypt} && $NOTEDB::crypt_supported == 1) {
|
||||
if ($conf{crypt_method} eq "") {
|
||||
$conf{crypt_method} = "Crypt::IDEA";
|
||||
}
|
||||
if (!exists $ENV{'NOTE_PASSWD'}) {
|
||||
print "password: ";
|
||||
@@ -442,18 +407,21 @@ if ($USE_CRYPT eq "YES" && $NOTEDB::crypt_supported == 1) {
|
||||
$key = $ENV{'NOTE_PASSWD'};
|
||||
}
|
||||
chomp $key;
|
||||
if ($dbdriver eq "mysql") {
|
||||
if ($conf{dbdriver} eq "mysql") {
|
||||
eval {
|
||||
require Crypt::CBC;
|
||||
my $cipher = new Crypt::CBC($key, $CRYPT_METHOD);
|
||||
my $cipher = new Crypt::CBC($key, $conf{crypt_method});
|
||||
# decrypt the dbpasswd, if it's encrypted!
|
||||
my $dbpasswd = $cipher->decrypt(unpack("u",$dbpasswd)) if($encrypt_passwd);
|
||||
$db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser,
|
||||
$dbpasswd, $table, $fnum, $fnote, $fdate, $dbport);
|
||||
$driver{mysql}->{dbpasswd} =
|
||||
$cipher->decrypt(unpack("u", $driver{mysql}->{dbpasswd})) if($driver{mysql}->{encrypt_passwd});
|
||||
&load_driver();
|
||||
};
|
||||
die "Could not connect do db: $@!\n" if($@);
|
||||
}
|
||||
$db->use_crypt($key,$CRYPT_METHOD);
|
||||
else {
|
||||
&load_driver();
|
||||
}
|
||||
$db->use_crypt($key,$conf{crypt_method});
|
||||
undef $key;
|
||||
# verify correctness of passwd
|
||||
my ($cnote, $cdate) = $db->get_single(1);
|
||||
@@ -462,33 +430,31 @@ if ($USE_CRYPT eq "YES" && $NOTEDB::crypt_supported == 1) {
|
||||
print "access denied.\n"; # decrypted $date is not a number!
|
||||
exit(1);
|
||||
}
|
||||
} #else empty database!
|
||||
} #else empty database!
|
||||
}
|
||||
else {
|
||||
if ($dbdriver eq "mysql") {
|
||||
$db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser,
|
||||
$dbpasswd, $table, $fnum, $fnote, $fdate, $dbport);
|
||||
}
|
||||
$db->no_crypt;
|
||||
# does: NOTEDB::crypt_supported = 0;
|
||||
my ($cnote, $cdate) = $db->get_single(1);
|
||||
if ($cdate ne "") {
|
||||
if ($cdate !~ /^\d+\.\d+?/) {
|
||||
print "$NOTEDB seems to be encrypted!\n";
|
||||
exit(1);
|
||||
}
|
||||
&load_driver();
|
||||
$db->no_crypt;
|
||||
|
||||
# does: NOTEDB::crypt_supported = 0;
|
||||
my ($cnote, $cdate) = $db->get_single(1);
|
||||
if ($cdate ne "") {
|
||||
if ($cdate !~ /^\d+\.\d+?/) {
|
||||
print "notedb seems to be encrypted!\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# do we use the db cache?
|
||||
if ($USE_CACHE) {
|
||||
if ($conf{use_cache}) {
|
||||
$db->use_cache();
|
||||
}
|
||||
|
||||
|
||||
# add the backend version to the note version:
|
||||
$version .= " " . $db->version();
|
||||
$version .= ", " . $conf{dbdriver} . " " . $db->version();
|
||||
|
||||
|
||||
# main loop: ###############
|
||||
@@ -529,7 +495,7 @@ sub encrypt_passwd {
|
||||
chomp $key;
|
||||
eval {
|
||||
require Crypt::CBC;
|
||||
my $cipher = new Crypt::CBC($key, $CRYPT_METHOD);
|
||||
my $cipher = new Crypt::CBC($key, $conf{crypt_method});
|
||||
$crypt_string = pack("u", $cipher->encrypt($clearstring));
|
||||
};
|
||||
if ($@) {
|
||||
@@ -574,7 +540,7 @@ sub search {
|
||||
print "No searchstring specified!\n";
|
||||
}
|
||||
else {
|
||||
print "searching the database $dbname for \"$searchstring\"...\n\n";
|
||||
print "searching the database $conf{dbname} for \"$searchstring\"...\n\n";
|
||||
|
||||
%res = $db->get_search($searchstring);
|
||||
my $nummatches = scalar keys %res;
|
||||
@@ -618,8 +584,8 @@ sub list {
|
||||
if ($TOPIC) {
|
||||
# this allows us to have multiple topics (subtopics!)
|
||||
my ($firstline,$dummy) = split /\n/, $n, 2;
|
||||
if ($firstline =~ /^($TopicSep)/) {
|
||||
@topic = split(/$TopicSep/,$firstline);
|
||||
if ($firstline =~ /^($conf{topicsep})/) {
|
||||
@topic = split(/$conf{topicsep}/,$firstline);
|
||||
}
|
||||
else {
|
||||
@topic = ();
|
||||
@@ -637,7 +603,7 @@ sub list {
|
||||
}
|
||||
elsif ($topic[$CurDepth-1] eq $CurTopic || ($topic[$CurDepth] eq "" && $CurDepth ==1)) {
|
||||
# cut the topic off the note-text
|
||||
if ($n =~ /^($TopicSep)/) {
|
||||
if ($n =~ /^($conf{topicsep})/) {
|
||||
$CurItem[$i]->{'note'} = $dummy;
|
||||
}
|
||||
else {
|
||||
@@ -663,19 +629,19 @@ sub list {
|
||||
# only if there were notes under current topic
|
||||
undef $PATH;
|
||||
foreach (@RealTopic) {
|
||||
$PATH .= $_ . $TopicSep;
|
||||
$PATH .= $_ . $conf{topicsep};
|
||||
last if($_ eq $CurTopic);
|
||||
}
|
||||
}
|
||||
else {
|
||||
# it is an empty topic, no notes here
|
||||
$PATH = join $TopicSep, @LastTopic;
|
||||
$PATH .= $TopicSep . $CurTopic . $TopicSep;
|
||||
$PATH =~ s/^\Q$TopicSep$TopicSep\E/$TopicSep/;
|
||||
$PATH = join $conf{topicsep}, @LastTopic;
|
||||
$PATH .= $conf{topicsep} . $CurTopic . $conf{topicsep};
|
||||
$PATH =~ s/^\Q$conf{topicsep}$conf{topicsep}\E/$conf{topicsep}/;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$PATH = $TopicSep;
|
||||
$PATH = $conf{topicsep};
|
||||
}
|
||||
|
||||
@completion_topics = ();
|
||||
@@ -683,7 +649,7 @@ sub list {
|
||||
# we are at top level, print a list of topics...
|
||||
foreach $top (sort(keys %TP)) {
|
||||
push @completion_topics, $top;
|
||||
output("-", " => ". $top . "$TopicSep ($TP{$top} notes)",
|
||||
output("-", " => ". $top . "$conf{topicsep} ($TP{$top} notes)",
|
||||
" Sub Topic ");
|
||||
}
|
||||
#print Dumper(@CurItem);
|
||||
@@ -701,9 +667,16 @@ sub list {
|
||||
############################### NEW ##################################
|
||||
sub new {
|
||||
my($TEMP,$editor, $date, $note, $WARN, $c, $line, $num, @topic);
|
||||
if ($conf{readonly}) {
|
||||
print "readonly\n";
|
||||
return;
|
||||
}
|
||||
$date = &getdate;
|
||||
if ($ALWAYS_EDIT eq "YES") {
|
||||
return if $db->lock();
|
||||
if ($conf{always_edit}) {
|
||||
$TEMP = &gettemp;
|
||||
# security!
|
||||
unlink $TEMP;
|
||||
# let the user edit it...
|
||||
$editor = &find_editor;
|
||||
if ($editor) {
|
||||
@@ -715,6 +688,7 @@ sub new {
|
||||
}
|
||||
else {
|
||||
print "Could not find an editor to use!\n";
|
||||
$db->unlock();
|
||||
exit(0);
|
||||
}
|
||||
# read it in ($note)
|
||||
@@ -723,6 +697,7 @@ sub new {
|
||||
if ($WARN) {
|
||||
print "...edit process interupted! No note has been saved.\n";
|
||||
undef $WARN;
|
||||
$db->unlock();
|
||||
return;
|
||||
}
|
||||
$c = 0;
|
||||
@@ -759,12 +734,13 @@ sub new {
|
||||
# look if the note was empty, so don't store it!
|
||||
if ($note =~ /^\s*$/) {
|
||||
print "...your note was empty and will not be saved.\n";
|
||||
$db->unlock();
|
||||
return;
|
||||
}
|
||||
# since we have not a number, look for the next one available:
|
||||
$number = $db->get_nextnum();
|
||||
if ($TOPIC && $CurTopic ne "") {
|
||||
@topic = split(/$TopicSep/,$note);
|
||||
@topic = split(/$conf{topicsep}/,$note);
|
||||
if ($topic[1] eq "") {
|
||||
$note = $PATH . "\n$note";
|
||||
}
|
||||
@@ -772,14 +748,22 @@ sub new {
|
||||
$db->set_new($number,$note,$date);
|
||||
# everything ok until here!
|
||||
print "note stored. it has been assigned the number $number.\n\n";
|
||||
$db->unlock();
|
||||
}
|
||||
|
||||
|
||||
############################### DELETE ##################################
|
||||
sub del {
|
||||
my($i,@count, $setnum, $pos, $ERR);
|
||||
if ($conf{readonly}) {
|
||||
print "readonly\n";
|
||||
return;
|
||||
}
|
||||
# delete a note
|
||||
&num_bereich; # get @NumBlock from $number
|
||||
|
||||
return if $db->lock();
|
||||
|
||||
foreach $_ (@NumBlock) {
|
||||
$ERR = $db->set_del($_);
|
||||
if ($ERR) {
|
||||
@@ -792,19 +776,35 @@ sub del {
|
||||
# recount the notenumbers:
|
||||
$db->set_recountnums();
|
||||
|
||||
$db->unlock();
|
||||
@NumBlock = ();
|
||||
}
|
||||
|
||||
############################### EDIT ##################################
|
||||
sub edit {
|
||||
my($keeptime, $date, $editor, $TEMP, $note, $t, $num, $match, $backup);
|
||||
if ($conf{readonly}) {
|
||||
print "readonly\n";
|
||||
return;
|
||||
}
|
||||
# edit a note
|
||||
$date = &getdate;
|
||||
|
||||
return if $db->lock();
|
||||
|
||||
($note, $keeptime) = $db->get_single($number);
|
||||
if ($keeptime eq "") {
|
||||
print "no note with that number found!\n\n";
|
||||
exit(0) if($mode ne "interactive");
|
||||
print "no note with that number found ($number)!\n\n";
|
||||
if($mode ne "interactive") {
|
||||
$db->unlock();
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
$db->unlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$TEMP = &gettemp;
|
||||
open NOTE,">$TEMP" or die "Could not open $TEMP\n";
|
||||
select NOTE;
|
||||
@@ -837,7 +837,7 @@ sub edit {
|
||||
unlink $TEMP || die $!;
|
||||
|
||||
if ($note ne $backup) {
|
||||
if ($KEEP_TIMESTAMP eq "YES") {
|
||||
if ($conf{keep_timestamp}) {
|
||||
$t = $keeptime;
|
||||
}
|
||||
else {
|
||||
@@ -851,6 +851,7 @@ sub edit {
|
||||
else {
|
||||
print "note number $number has not changed, no save done.\n";
|
||||
}
|
||||
$db->unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -878,7 +879,7 @@ sub dump {
|
||||
}
|
||||
|
||||
sub import {
|
||||
my($num, $start, $complete, $dummi, $note, $date, $time, $number, $stdin, $DUMP);
|
||||
my($num, $start, $complete, $dummi, $note, $date, $time, $number, $stdin, $DUMP, %data);
|
||||
# open $dump_file and import it into the notedb
|
||||
$stdin = 1 if($dump_file eq "-");
|
||||
if ($stdin) {
|
||||
@@ -888,26 +889,27 @@ sub import {
|
||||
open (DUMPFILE, "<$dump_file") or die "could not open $dump_file\n";
|
||||
$DUMP = *DUMPFILE;
|
||||
}
|
||||
$db->set_del_all() if($ImportType ne "");
|
||||
$complete=0;
|
||||
$start = 0;
|
||||
|
||||
$complete = $start = 0;
|
||||
$number = 1;
|
||||
while (<$DUMP>) {
|
||||
chomp $_;
|
||||
if ($_ =~ /^Number:\s\d+/) {
|
||||
if ($start == 0) {
|
||||
# we have no previous record
|
||||
($dummi,$number) = split(/\s/,$_);
|
||||
$start = 1;
|
||||
}
|
||||
else {
|
||||
# we got a complete record, save it!
|
||||
$number = $db->get_nextnum();
|
||||
$db->set_new($number,$note, $date);
|
||||
print "note number $number from $dump_file inserted into notedb.\n" if(!$stdin);
|
||||
$data{$number} = {
|
||||
date => $date,
|
||||
note => $note
|
||||
};
|
||||
print "fetched note number $number from $dump_file from $date.\n" if(!$stdin);
|
||||
$complete = 0;
|
||||
$note = "";
|
||||
$date = "";
|
||||
($dummi,$number) = split(/\s/,$_);
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
elsif ($_ =~ /^Timestamp:\s\d+/ && $complete == 0) {
|
||||
@@ -919,17 +921,23 @@ sub import {
|
||||
$note .= $_ . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($note ne "" && $date ne "") {
|
||||
# the last record, if existent
|
||||
$number = $db->get_nextnum();
|
||||
$db->set_new($number,$note, $date);
|
||||
print "note number $number from $dump_file inserted into notedb.\n" if(!$stdin);
|
||||
$data{$number} = {
|
||||
data => $date,
|
||||
note => $note
|
||||
};
|
||||
print "fetched note number $number from $dump_file from $date.\n" if(!$stdin);
|
||||
}
|
||||
}
|
||||
|
||||
$db->set_del_all() if($ImportType ne "");
|
||||
$db->import_data(\%data);
|
||||
}
|
||||
|
||||
sub determine_width {
|
||||
# determine terminal wide, if possible
|
||||
if ($keepmaxlen eq "auto") {
|
||||
if ($maxlen eq "auto") {
|
||||
eval {
|
||||
my $wide = `stty -a`;
|
||||
if ($wide =~ /columns (\d+?);/) {
|
||||
@@ -949,7 +957,7 @@ sub determine_width {
|
||||
|
||||
sub clear {
|
||||
# first, try to determine the terminal height
|
||||
return if(!$AUTO_CLEAR);
|
||||
return if(!$conf{auto_clear});
|
||||
my $hoch;
|
||||
eval {
|
||||
my $height = `stty -a`;
|
||||
@@ -989,7 +997,7 @@ sub interactive {
|
||||
# per default let's list all the stuff:
|
||||
# Initially do a list command!
|
||||
&determine_width;
|
||||
$ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : "";
|
||||
$ListType = ($conf{default_list} eq "LONG") ? "LONG" : "";
|
||||
&list;
|
||||
|
||||
my ($term, $prompt, $attribs);
|
||||
@@ -1001,7 +1009,7 @@ sub interactive {
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
$ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : "";
|
||||
$ListType = ($conf{default_list} eq "LONG") ? "LONG" : "";
|
||||
undef $SetTitle;
|
||||
if ($CurDepth > 2) {
|
||||
print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . ">";
|
||||
@@ -1140,13 +1148,13 @@ sub interactive {
|
||||
# unknown
|
||||
my $unchar = $char;
|
||||
$unchar =~ s/^cd //; # you may use cd <topic> now!
|
||||
if ($unchar =~ /^\d+?$/ && $SHORT_CD) {
|
||||
if ($unchar =~ /^\d+?$/ && $conf{short_cd}) {
|
||||
# just a number!
|
||||
my @topic;
|
||||
my ($cnote, $cdate) = $db->get_single($unchar);
|
||||
my ($firstline,$dummy) = split /\n/, $cnote, 2;
|
||||
if ($firstline =~ /^($TopicSep)/) {
|
||||
@topic = split(/$TopicSep/,$firstline);
|
||||
if ($firstline =~ /^($conf{topicsep})/) {
|
||||
@topic = split(/$conf{topicsep}/,$firstline);
|
||||
}
|
||||
else {
|
||||
@topic = ();
|
||||
@@ -1160,7 +1168,7 @@ sub interactive {
|
||||
}
|
||||
&list;
|
||||
}
|
||||
elsif ($unchar eq $TopicSep) {
|
||||
elsif ($unchar eq $conf{topicsep}) {
|
||||
# cd /
|
||||
$CurDepth = 1;
|
||||
$CurTopic = "";
|
||||
@@ -1215,7 +1223,7 @@ Read the note(1) manpage for more details.
|
||||
}
|
||||
|
||||
sub find_editor {
|
||||
return $PreferredEditor || $ENV{"VISUAL"} || $ENV{"EDITOR"} || "vi";
|
||||
return $conf{preferrededitor} || $ENV{"VISUAL"} || $ENV{"EDITOR"} || "vi";
|
||||
}
|
||||
|
||||
#/
|
||||
@@ -1223,7 +1231,7 @@ sub find_editor {
|
||||
sub format {
|
||||
# make text bold/underlined/inverse using current $NOTEC
|
||||
my($note) = @_;
|
||||
if ($FormatText) {
|
||||
if ($conf{formattext}) {
|
||||
# prepare colors to be used for replacement
|
||||
my $BN = uc($NOTEC);
|
||||
my $_BN = uc($_NOTEC);
|
||||
@@ -1236,7 +1244,7 @@ sub format {
|
||||
$IN =~ s/<(.*)>/<$1I>/;
|
||||
$_IN =~ s/<(.*)>/<$1I>/;
|
||||
|
||||
if ($FormatText eq "simple") {
|
||||
if ($conf{formattext} eq "simple") {
|
||||
$note =~ s/\*([^\*]*)\*/$BN$1$_BN/g;
|
||||
$note =~ s/_([^_]*)_/$UN$1$_UN/g;
|
||||
$note =~ s/{([^}]*)}/$IN$1$_IN/g;
|
||||
@@ -1299,7 +1307,7 @@ sub output {
|
||||
$title = "";
|
||||
$CUTSPACE = " " x $txtlen;
|
||||
if ($TYPE eq "search") {
|
||||
$note =~ s/^\Q$TopicSep\E.+?\Q$TopicSep\E\n//;
|
||||
$note =~ s/^\Q$conf{topicsep}\E.+?\Q$conf{topicsep}\E\n//;
|
||||
}
|
||||
$note =~ s/\n/$CUTSPACE/g;
|
||||
$len = length($note);
|
||||
@@ -1328,8 +1336,8 @@ sub output {
|
||||
if ($Raw) {
|
||||
print "$num ";
|
||||
print "$time " if($ListType eq "LONG");
|
||||
if ($title =~ /^ => (.*)$TopicSep (.*)$/) {
|
||||
$title = "$1$TopicSep $2"; # seems to be a topic!
|
||||
if ($title =~ /^ => (.*)$conf{topicsep} (.*)$/) {
|
||||
$title = "$1$conf{topicsep} $2"; # seems to be a topic!
|
||||
}
|
||||
print "$title\n";
|
||||
}
|
||||
@@ -1363,7 +1371,7 @@ sub C {
|
||||
$S = $_[0];
|
||||
foreach $Col (%Color) {
|
||||
if ($S =~ /<$Col>/g) {
|
||||
if ($COLOR ne "NO") {
|
||||
if ($conf{color}) {
|
||||
$NC = "\033[" . $Color{$Col} . "m";
|
||||
$S =~ s/<$Col>/$NC/g;
|
||||
$S =~ s/<\/$Col>/$default/g;
|
||||
@@ -1426,8 +1434,8 @@ sub getdate {
|
||||
$min =~ s/^(\d)$/0$1/;
|
||||
$sec =~ s/^(\d)$/0$1/;
|
||||
$mday =~ s/^(\d)$/0$1/;
|
||||
if ($time_format) {
|
||||
my $back = $time_format;
|
||||
if ($conf{time_format}) {
|
||||
my $back = $conf{time_format};
|
||||
$back =~ s/YYYY/$year/;
|
||||
$back =~ s/YY/substr($year, 1, 2)/e;
|
||||
$back =~ s/MM/$mon/;
|
||||
@@ -1448,7 +1456,7 @@ sub gettemp {
|
||||
for (0..10) {
|
||||
$random .= $range[rand(int($#range)+1)];
|
||||
}
|
||||
my $tempfile = $TempDir . "/" . $USER . "." . $random;
|
||||
my $tempfile = File::Spec->catfile($conf{tempdirectory}, $USER . $random);
|
||||
if (-e $tempfile) {
|
||||
# avoid race conditions!
|
||||
unlink $tempfile;
|
||||
@@ -1512,19 +1520,19 @@ sub display_tree {
|
||||
$t = $res{$num}->{'date'};
|
||||
# this allows us to have multiple topics (subtopics!)
|
||||
my ($firstline,$text,$untext) = split /\n/, $n, 3;
|
||||
if ($firstline =~ /^($TopicSep)/) {
|
||||
$firstline =~ s/($TopicSep)*$//; #remove TopicSepatator
|
||||
@nodes = split(/$TopicSep/,$firstline);
|
||||
if ($firstline =~ /^($conf{topicsep})/) {
|
||||
$firstline =~ s/($conf{topicsep})*$//; #remove TopicSepatator
|
||||
@nodes = split(/$conf{topicsep}/,$firstline);
|
||||
}
|
||||
else {
|
||||
@nodes = (); #("$TopicSep");
|
||||
@nodes = (); #("$conf{topicsep}");
|
||||
$text = $firstline;
|
||||
}
|
||||
&tree($num, $text, \%TREE, @nodes);
|
||||
}
|
||||
#return if ($num == 0);
|
||||
# now that we have build our tree (in %TREE) go on t display it:
|
||||
print C $BORDERC . "\n[" . $TopicSep . $BORDERC . "]\n";
|
||||
print C $BORDERC . "\n[" . $conf{topicsep} . $BORDERC . "]\n";
|
||||
&print_tree(\%{$TREE{''}},"") if(%TREE);
|
||||
print C $BORDERC . $_BORDERC . "\n";
|
||||
}
|
||||
@@ -1578,58 +1586,31 @@ sub getconfig {
|
||||
chomp;
|
||||
next if(/^\s*$/ || /^\s*#/);
|
||||
my ($option,$value) = split /\s\s*=?\s*/, $_, 2;
|
||||
$value =~ s/\s*$//;
|
||||
$home = $value if (/^Home/);
|
||||
$libpath = $value if (/^LibPath/);
|
||||
$dbdriver = $value if (/^DbDriver/);
|
||||
$dbhost = $value if (/^DbHost/);
|
||||
$dbport = $value if (/^DbPort/);
|
||||
$dbuser = $value if (/^DbUser/);
|
||||
$dbpasswd = $value if (/^DbPasswd/);
|
||||
$encrypt_passwd = $value if (/^encrypt_passwd/);
|
||||
$dbname = $value if (/^DbName/);
|
||||
$table = $value if (/^DbTable/);
|
||||
$fnum = $value if (/^FieldNumber/);
|
||||
$fnote = $value if (/^FieldNote/);
|
||||
$fdate = $value if (/^FieldDate/);
|
||||
$SHORT_CD = $value if (/^ShortCd/);
|
||||
$NOTEDB = $value if (/^NoteDb/);
|
||||
$MAX_NOTE = $value if (/^MaxNoteByte/);
|
||||
$MAX_TIME = $value if (/^MaxTimeByte/);
|
||||
$CRYPT_METHOD = $value if (/^CryptMethod/);
|
||||
$USE_CRYPT = "YES" if (/^UseEncryption/ && $value == 1);
|
||||
$USE_CRYPT = undef if (/^UseEncryption/ && $value == 0);
|
||||
$ALWAYS_INT = "YES" if (/^AlwaysInteractive/ && $value == 1);
|
||||
$ALWAYS_INT = undef if (/^AlwaysInteractive/ && $value == 0);
|
||||
$DEFAULT_LIST = "LONG" if (/^DefaultLong/ && $value == 1);
|
||||
$DEFAULT_LIST = undef if (/^DefaultLong/ && $value == 0);
|
||||
$ALWAYS_EDIT = "YES" if (/^AlwaysEditor/ && $value == 1);
|
||||
$ALWAYS_EDIT = undef if (/^AlwaysEditor/ && $value == 0);
|
||||
$KEEP_TIMESTAMP = "YES" if (/^KeepTimeStamp/ && $value == 1);
|
||||
$KEEP_TIMESTAMP = undef if (/^KeepTimeStamp/ && $value == 0);
|
||||
$AUTO_CLEAR = "YES" if (/^AutoClear/ && $value == 1);
|
||||
$COLOR = "YES" if (/^UseColors/ && $value == 1);
|
||||
$COLOR = "NO" if (/^UseColors/ && $value == 0);
|
||||
$TopicSep = $value if (/^TopicSeparator/);
|
||||
$maxlen = $keepmaxlen = $value if (/^MaxLen/);
|
||||
$BORDER_COLOR = $value if (/^BorderColor/);
|
||||
$NUM_COLOR = $value if (/^NumberColor/);
|
||||
$NOTE_COLOR = $value if (/^NoteColor/);
|
||||
$TIME_COLOR = $value if (/^TimeColor/);
|
||||
$TOPIC_COLOR = $value if (/^TopicColor/);
|
||||
$PreferredEditor = $value if (/^PreferredEditor/);
|
||||
$FormatText = $value if (/^FormatText/);
|
||||
$TempDir = $value if (/^TempDirectory/);
|
||||
$USE_CACHE = $value if (/^Cache/);
|
||||
$time_format = $value if (/^TimeFormat/);
|
||||
$AUTO_CLEAR = $value if (/^AutoClear/);
|
||||
}
|
||||
|
||||
if ($NOTEDB =~ /^(~\/)(.*)$/) {
|
||||
$NOTEDB = File::Spec->catfile($HOME, $2);
|
||||
}
|
||||
$value =~ s/\s*$//;
|
||||
$value =~ s/\s*#.*$//;
|
||||
if ($value =~ /^(~\/)(.*)$/) {
|
||||
$value = File::Spec->catfile($ENV{HOME}, $2);
|
||||
}
|
||||
|
||||
$libpath = (File::Spec->splitpath($libpath))[1];
|
||||
if ($value =~ /^(yes|on|1)$/i) {
|
||||
$value = 1;
|
||||
}
|
||||
elsif ($value =~ /^(no|off|0)$/i) {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
$option = lc($option);
|
||||
|
||||
if ($option =~ /^(.+)::(.*)$/) {
|
||||
# driver option
|
||||
$driver{$1}->{$2} = $value;
|
||||
}
|
||||
else {
|
||||
# other option
|
||||
$conf{$option} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
close CONFIG;
|
||||
}
|
||||
@@ -1660,125 +1641,27 @@ sub complete {
|
||||
}
|
||||
}
|
||||
|
||||
sub load_driver {
|
||||
my ($parent) = @_;
|
||||
|
||||
if ($parent) {
|
||||
my $pkg = "NOTEDB";
|
||||
if ($@) {
|
||||
die "Could not load the NOTEDB module: $@\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
# load the backend driver
|
||||
my $pkg = "NOTEDB::$conf{dbdriver}";
|
||||
eval "use $pkg;";
|
||||
if ($@) {
|
||||
die "$conf{dbdriver} backend unsupported: $@\n";
|
||||
}
|
||||
else {
|
||||
$db = $pkg->new(%{$driver{$conf{dbdriver}}});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__END__
|
||||
#
|
||||
# $Log: note,v $
|
||||
# Revision 1.11 2000/12/09 21:56:08 zarahg
|
||||
# cvs update to 1.1.2, but incomplete, more to come
|
||||
#
|
||||
# Revision 1.10 2000/08/19 13:38:33 zarahg
|
||||
# .
|
||||
#
|
||||
# Revision 1.9 2000/08/14 14:14:20 zarahg
|
||||
# changed bug in cd .. after cd <number>, $PATH was empty.
|
||||
#
|
||||
# Revision 1.8 2000/08/14 11:21:34 zarahg
|
||||
# hmmm... the default size for time was too small :-(
|
||||
#
|
||||
# Revision 1.7 2000/08/14 10:59:26 zarahg
|
||||
# moved %Color hash from ::C() to ::main, displaying is now faster.
|
||||
#
|
||||
# Revision 1.6 2000/08/14 10:27:26 zarahg
|
||||
# use now better color defaults and added 2 new color values, bold an white_black
|
||||
#
|
||||
# Revision 1.5 2000/08/11 00:05:58 zarahg
|
||||
# 1.1.0 beta2 ready for testing
|
||||
#
|
||||
# Revision 1.4 2000/08/10 09:21:56 zarahg
|
||||
# ready for 1.1.0 shipping, lots of changes/additions, see Changelog
|
||||
#
|
||||
# Revision 1.3 2000/07/21 06:41:25 zarahg
|
||||
# 638: precedence bug fixed
|
||||
#
|
||||
# Revision 1.2 2000/07/09 22:10:03 zarahg
|
||||
# tempfile management more secure now. new option TempDirectory. thx to Donald.
|
||||
#
|
||||
# Revision 1.30 2000/07/09 21:59:48 scip
|
||||
# secure temp files
|
||||
#
|
||||
# Revision 1.29 2000/06/25 20:13:23 scip
|
||||
# *** empty log message ***
|
||||
#
|
||||
# Revision 1.28 2000/06/25 19:51:51 scip
|
||||
# changed pattern matching of seraching(\@ ... \E)
|
||||
# added --config option
|
||||
#
|
||||
# Revision 1.27 2000/05/16 23:51:35 thomas
|
||||
# fixed many option-parsing related bugd!
|
||||
#
|
||||
# Revision 1.26 2000/05/13 01:05:17 thomas
|
||||
# changed config format and fixed some bugs
|
||||
# as well as some other additions...
|
||||
#
|
||||
# Revision 1.25 2000/05/11 23:42:43 thomas
|
||||
# --tree changed to --topic
|
||||
#
|
||||
# Revision 1.24 2000/05/10 22:59:44 thomas
|
||||
# updated usage to reflect --raw and build it into output
|
||||
# and display subs.
|
||||
#
|
||||
# Revision 1.23 2000/05/10 22:19:04 thomas
|
||||
# changed to Getopt::Long, added --raw
|
||||
#
|
||||
# Revision 1.22 2000/05/01 18:51:40 thomas
|
||||
# added "-" to sub dump
|
||||
#
|
||||
# Revision 1.21 2000/05/01 00:17:27 thomas
|
||||
# *** empty log message ***
|
||||
#
|
||||
# Revision 1.20 2000/04/30 23:31:38 thomas
|
||||
# added -o and coloured sub help.
|
||||
#
|
||||
# Revision 1.19 2000/04/30 16:07:23 thomas
|
||||
# *** empty log message ***
|
||||
#
|
||||
# Revision 1.18 2000/04/30 14:58:21 thomas
|
||||
# updated the usage and help subs
|
||||
#
|
||||
# Revision 1.17 2000/04/30 14:44:38 thomas
|
||||
# added colors to the tree functions
|
||||
#
|
||||
# Revision 1.16 2000/04/30 14:28:38 thomas
|
||||
# added the t command, which displays a topic-tree.
|
||||
# and enhanced the list command in interactive mode
|
||||
#
|
||||
# Revision 1.15 2000/03/19 23:41:04 thomas
|
||||
# changed set_del, now no extra TEMP file is required!
|
||||
# instead I get it from $this->get_all() !
|
||||
# Revision 1.14 2000/03/19 22:51:49 thomas
|
||||
# Bug in NOTEDB::binary fixed, recount of nubers was
|
||||
# incorrect.
|
||||
#
|
||||
# Revision 1.13 2000/03/19 11:53:32 thomas
|
||||
# edit bug fixed (ude => uen)
|
||||
#
|
||||
# Revision 1.12 2000/03/19 03:06:51 thomas
|
||||
# backend support completed.
|
||||
# mysql and binary backends now excluded in separate files
|
||||
#
|
||||
# Revision 1.11 2000/03/18 00:16:47 thomas
|
||||
# added NOTEDB::mysql and changed note to work with that.
|
||||
# thus, from now on there is only one script to maintain and
|
||||
# it is possible to provide more bacjends as well as making
|
||||
# additional scripts upon them, i.e. cgi script...
|
||||
#
|
||||
# Revision 1.8 2000/03/13 22:48:43 thomas
|
||||
# small width bug fixed
|
||||
#
|
||||
# Revision 1.7 2000/03/08 23:11:19 tom
|
||||
# added cd
|
||||
#
|
||||
# Revision 1.6 2000/03/08 22:50:41 tom
|
||||
# Added the $KEEP_TIMESTAMP option and fixed a bug regarding topic names
|
||||
# and invalid resolution of them in case it started with "1 name".
|
||||
#
|
||||
# Revision 1.5 2000/02/25 20:59:30 tom
|
||||
# corrected small timestamp problem in &edit and &new
|
||||
#
|
||||
# Revision 1.4 2000/02/25 13:24:11 tom
|
||||
# fixed a small bug, that caused to use the last line for a note title instead the 2nd.
|
||||
#
|
||||
# Revision 1.3 2000/02/25 11:28:53 tom
|
||||
# all changes from bin version applied to sql version
|
||||
|
||||
172
bin/rc
Normal file
172
bin/rc
Normal file
@@ -0,0 +1,172 @@
|
||||
# 1.2.7 -*- sh -*-
|
||||
# This is a sample config for the note script
|
||||
# There are useful defaults set in note itself.
|
||||
#
|
||||
# Copy it to your $HOME as .noterc
|
||||
#
|
||||
# note is Copyright (c) 1999-2000 Thomas Linden.
|
||||
# You can contact me per email: <tom@daemon.de>
|
||||
#
|
||||
# comments start with #, empty lines will be ignored.
|
||||
# 1 turns an option on, 0 turns it off.
|
||||
# An option consists of an atribute-value pair separated
|
||||
# by minimum one space (more spaces and/or tabs are allowed)
|
||||
|
||||
|
||||
# Your home directory, better do not change it!
|
||||
# can be an environment variable or a path
|
||||
Home $ENV{'HOME'}
|
||||
|
||||
|
||||
# specify the path, where the NOTEDB lib directory
|
||||
# resides. This will only used if it is not
|
||||
# installed inside the perl-lib directory structure!
|
||||
LibPath ..
|
||||
|
||||
|
||||
# you need to decide which database backend you want
|
||||
# to use. Please refer to the corresponding documentation
|
||||
# for closer information about the certain backend!
|
||||
# Currently supported types: "binary", "dbm" or "mysql".
|
||||
# You must also edit/uncomment one section below for the
|
||||
# backend you want to use!
|
||||
DbDriver general
|
||||
|
||||
|
||||
|
||||
# backend specific settings for binary(default) backend
|
||||
NoteDb /home/tlin/dev/note-1.2.7/bin/notedb.txt
|
||||
# Define the maximum bytes fields can have in a
|
||||
|
||||
MaxNoteByte 32768
|
||||
MaxTimeByte 64
|
||||
|
||||
|
||||
|
||||
# You can use encryption with note, that means notes and
|
||||
# timestamps will be stored encrypted. This is supported
|
||||
# by every db-backend.
|
||||
# Set to 1 to turn it on. The Default is 0 (off)
|
||||
UseEncryption 1
|
||||
|
||||
# Specify the encryption protocol. The appropriate perl
|
||||
# module needs to be installed. Possible velues are
|
||||
# IDEA, DES or Blowfish, the default is IDEA.
|
||||
CryptMethod Blowfish
|
||||
|
||||
|
||||
# You can run note always in interactive mode by simply
|
||||
# typing "note". Set this option to 1 to turn it on.
|
||||
# The default is 0 (off).
|
||||
AlwaysInteractive 0
|
||||
|
||||
|
||||
# In interactive mode, note issues a list command if you
|
||||
# simply hit enter. By turning this on, it will issue a
|
||||
# longlist command instead if you hit just enter.
|
||||
# The default is 0 (off)
|
||||
DefaultLong 0
|
||||
|
||||
|
||||
|
||||
# You can use an external editor everytime from note instead
|
||||
# of STDIN for creating new notes. Set to 1 to turn it on.
|
||||
# The default is 0 (off).
|
||||
AlwaysEditor 1
|
||||
|
||||
|
||||
# uncomment and edit it, if you want to use another
|
||||
# editor than the default $EDITOR or as fallback vi.
|
||||
#PreferredEditor emacs
|
||||
|
||||
|
||||
# If you dont prefer that note updates the timestamp of a
|
||||
# note after editing, turn this on. It will
|
||||
# keep the original timestamp if this option is set.
|
||||
# The default is 0(off), to turn it on set to 1.
|
||||
KeepTimeStamp 0
|
||||
|
||||
|
||||
# You can specify your own topic separator here.
|
||||
# the default topic separator is a normal slash: "/"
|
||||
# see README for details about topics!
|
||||
TopicSeparator /
|
||||
|
||||
|
||||
# The maximum width for displaying a note, in CHARS.
|
||||
# Depends on your screen-size. You can set it to
|
||||
# "auto", if you wish that note sould determine the
|
||||
# available size, but it experimental, be aware!
|
||||
MaxLen auto
|
||||
|
||||
|
||||
# note can use colors for output, set this option to
|
||||
# 1, if you don't want it, or if your terminal does
|
||||
# not support it, set to 0. The default is 1 (on).
|
||||
UseColors 1
|
||||
|
||||
|
||||
# Color-definitions of the various items. Will only
|
||||
# take effect, if "UseColors" is turned on!
|
||||
BorderColor BLACK
|
||||
NumberColor RED
|
||||
NoteColor blue
|
||||
TimeColor green
|
||||
TopicColor BLACK
|
||||
|
||||
|
||||
# The following colors are available:
|
||||
# black, red, green, yellow, blue, magenta, cyan and white.
|
||||
# for bold color write it uppercase (BLACK will be bold black)
|
||||
# for underlined color append an underscore (blue_ will be underlined blue)
|
||||
# for inverted color append an "I" (greenI will be inverted green)
|
||||
|
||||
|
||||
# Additional to colors, you can also do a little bit of formatting your
|
||||
# notes (bold, underlined, italic), see README!
|
||||
# You need to set this Option to 1, if you decide to make use of this
|
||||
# capabily
|
||||
FormatText 1
|
||||
|
||||
|
||||
# You might specify your own directory for temporary files.
|
||||
# note needs to create some temp files during editing of notes.
|
||||
# You could protect this directory using the command: chmod 700 directory.
|
||||
# The default is /tmp
|
||||
TempDirectory /home/tlin/tmp
|
||||
|
||||
|
||||
|
||||
# You can jump to a topic by typing "cd 13" in interactive mode.
|
||||
# You need to set thi soption to 1 if you want to use this feature.
|
||||
ShortCd 1
|
||||
|
||||
|
||||
|
||||
# note can use a cached copy of the note database for list/tree/search
|
||||
# this is currently only supported by the binary and the mysql backends
|
||||
# set it to 1 to turn it on, the default is 0 (off)
|
||||
Cache 0
|
||||
|
||||
|
||||
|
||||
# you can define your very own time format for time stamps
|
||||
# YY - the last 2 digits of a year
|
||||
# YYYY - year
|
||||
# MM - month
|
||||
# DD - day
|
||||
# hh - hours
|
||||
# mm - minutes
|
||||
# ss - seconds
|
||||
# This is the default: (18.10.2000 21:32:08)
|
||||
TimeFormat DD.MM.YYYY hh:mm:ss
|
||||
|
||||
|
||||
|
||||
AutoClear = 0
|
||||
|
||||
|
||||
# That's all about it for now.
|
||||
# If you still have any questiosn, please feel free to contact
|
||||
# me by email: Thomas Linden <tom@daemon.de>
|
||||
|
||||
327
config/noterc
327
config/noterc
@@ -1,164 +1,176 @@
|
||||
# note 1.2.6 -*- sh -*-
|
||||
#
|
||||
# This is a sample config for the note script
|
||||
# There are useful defaults set in note itself.
|
||||
#
|
||||
# Copy it to your $HOME as .noterc
|
||||
#
|
||||
# note is Copyright (c) 1999-2004 Thomas Linden.
|
||||
# You can contact me per email: <tom@daemon.de>
|
||||
#
|
||||
# comments start with #, empty lines will be ignored.
|
||||
# 1 turns an option on, 0 turns it off.
|
||||
# An option consists of an atribute-value pair separated
|
||||
# by minimum one space (more spaces and/or tabs are allowed)
|
||||
# note 1.3.0 -*- sh -*-
|
||||
#
|
||||
# This is a sample config for the note script
|
||||
# There are useful defaults set in note itself.
|
||||
#
|
||||
# Copy it to your $HOME as .noterc
|
||||
#
|
||||
# note is Copyright (c) 1999-2004 Thomas Linden.
|
||||
# You can contact me per email: <tom@daemon.de>
|
||||
#
|
||||
# Comments start with #, empty lines will be ignored.
|
||||
#
|
||||
# To turn on an option, set it to: 1, on or yes
|
||||
# To turn off an option, set it to: 0, off or 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.
|
||||
#
|
||||
# Refer to the manpage to learn more about the config
|
||||
|
||||
|
||||
|
||||
|
||||
# specify the path, where the NOTEDB lib directory
|
||||
# resides. This will only used if it is not
|
||||
# installed inside the perl-lib directory structure!
|
||||
#LibPath /usr/local/lib
|
||||
|
||||
|
||||
# you need to decide which database backend you want
|
||||
# to use. Please refer to the corresponding documentation
|
||||
# for closer information about the certain backend!
|
||||
# Currently supported types: "binary", "dbm" or "mysql".
|
||||
# You must also edit/uncomment one section below for the
|
||||
# backend you want to use!
|
||||
DbDriver binary
|
||||
#
|
||||
# you need to decide which database backend you want
|
||||
# to use. Please refer to the corresponding documentation
|
||||
# for closer information about the certain backend!
|
||||
# Currently supported types: "binary", "dbm", "mysql",
|
||||
# "general" or "text".
|
||||
# You must also edit/uncomment one section below for the
|
||||
# backend you want to use!
|
||||
dbdriver = binary
|
||||
|
||||
|
||||
|
||||
#
|
||||
# backend specific settings for sql backend
|
||||
#
|
||||
#DbHost localhost
|
||||
#DbPort
|
||||
#DbUser you
|
||||
#DbPasswd
|
||||
#DbName mynotes
|
||||
#DbTable note
|
||||
#FieldNumber number
|
||||
#FieldNote note
|
||||
#FieldDate date
|
||||
# uncomment for using an encrypted password, generate it
|
||||
# with note "--encrypt"
|
||||
#encrypt_passwd 1
|
||||
#### specific end ###
|
||||
#
|
||||
# BINARY backend (the default)
|
||||
binary::dbname = ~/.notedb # filename
|
||||
binary::MaxNoteByte = 4096 # max bytes per note entry
|
||||
binary::MaxTimeByte = 64 # max bytes for the date
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# backend specific settings for binary(default) backend
|
||||
#
|
||||
# where to store the database (filename)
|
||||
NoteDb ~/.notedb
|
||||
#
|
||||
# Define the maximum bytes fields can have in a
|
||||
# note-entry. Do not change MaxTimeByte to less than 64!
|
||||
MaxNoteByte 4096
|
||||
MaxTimeByte 64
|
||||
#### specific end ###
|
||||
#
|
||||
# MYSQL backend
|
||||
mysql::dbhost = localhost # hostname
|
||||
mysql::dbport = 3306 # tcp port
|
||||
mysql::dbuser = you # db login
|
||||
mysql::dbpasswd = # db password
|
||||
mysql::dbname = # database name (default: note)
|
||||
mysql::encrypt_passwd = 0 # mysql::dbpasswd is
|
||||
# encrypted (note --encrypt)
|
||||
|
||||
|
||||
# backend specific settings for DBM backend
|
||||
#
|
||||
# Directory where to store the dbm files
|
||||
#DbName /home/you/.notedbm
|
||||
#### specific end ###
|
||||
#
|
||||
# DBM backend
|
||||
dbm::directory = ~/.notedbm # directory
|
||||
|
||||
|
||||
|
||||
# You can use encryption with note, that means notes and
|
||||
# timestamps will be stored encrypted. This is supported
|
||||
# by every db-backend.
|
||||
# Set to 1 to turn it on. The Default is 0 (off)
|
||||
UseEncryption 0
|
||||
#
|
||||
# GENERAL backend
|
||||
general::dbname = ~/.notedb # filename
|
||||
|
||||
|
||||
#
|
||||
# TEXT backend
|
||||
text::dbname = ~/.notedb # filename
|
||||
|
||||
|
||||
|
||||
# Specify the encryption protocol. The appropriate perl
|
||||
# module needs to be installed. Possible velues are
|
||||
# IDEA, DES or Blowfish, the default is IDEA.
|
||||
CryptMethod IDEA
|
||||
#
|
||||
# You can use encryption with note, that means notes and
|
||||
# timestamps will be stored encrypted. This is supported
|
||||
# by every db-backend.
|
||||
UseEncryption = NO
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Specify the encryption protocol. The appropriate perl
|
||||
# module needs to be installed. Possible velues are
|
||||
# IDEA, DES or Blowfish, the default is IDEA.
|
||||
CryptMethod = IDEA
|
||||
|
||||
|
||||
|
||||
#
|
||||
# You can run note always in interactive mode by simply
|
||||
# typing "note". The default is: YES.
|
||||
AlwaysInteractive = YES
|
||||
|
||||
|
||||
|
||||
# You can run note always in interactive mode by simply
|
||||
# typing "note". Set this option to 1 to turn it on.
|
||||
# The default is 1 (on).
|
||||
AlwaysInteractive 1
|
||||
#
|
||||
# In interactive mode, note issues a list command if you
|
||||
# simply hit enter. By turning this on, it will issue a
|
||||
# longlist command instead if you hit just enter.
|
||||
# The default is: NO
|
||||
DefaultLong = NO
|
||||
|
||||
|
||||
|
||||
# In interactive mode, note issues a list command if you
|
||||
# simply hit enter. By turning this on, it will issue a
|
||||
# longlist command instead if you hit just enter.
|
||||
# The default is 0 (off)
|
||||
DefaultLong 0
|
||||
#
|
||||
# You can use an external editor everytime from note instead
|
||||
# of STDIN for creating new notes. The default is: NO
|
||||
AlwaysEditor = NO
|
||||
|
||||
|
||||
|
||||
# You can use an external editor everytime from note instead
|
||||
# of STDIN for creating new notes. Set to 1 to turn it on.
|
||||
# The default is 0 (off).
|
||||
AlwaysEditor 0
|
||||
#
|
||||
# By default, note looks in the environment for a variable
|
||||
# $EDITOR or, if this is not the case, for $VISUAL and as
|
||||
# fallback it uses 'vi'.
|
||||
# You can override this by setting this variable here.
|
||||
PreferredEditor =
|
||||
|
||||
|
||||
|
||||
# uncomment and edit it, if you want to use another
|
||||
# editor than the default $EDITOR or as fallback vi.
|
||||
#PreferredEditor emacs
|
||||
#
|
||||
# If you don't prefer that note updates the timestamp of a
|
||||
# note after editing, turn this on. It will
|
||||
# keep the original timestamp if this option is set.
|
||||
# The default is: NO
|
||||
KeepTimeStamp = NO
|
||||
|
||||
|
||||
|
||||
# If you dont prefer that note updates the timestamp of a
|
||||
# note after editing, turn this on. It will
|
||||
# keep the original timestamp if this option is set.
|
||||
# The default is 0(off), to turn it on set to 1.
|
||||
KeepTimeStamp 0
|
||||
#
|
||||
# You can specify your own topic separator here.
|
||||
# The default topic separator is a normal slash: "/"
|
||||
TopicSeparator = /
|
||||
|
||||
|
||||
|
||||
# You can specify your own topic separator here.
|
||||
# the default topic separator is a normal slash: "/"
|
||||
# see README for details about topics!
|
||||
TopicSeparator /
|
||||
#
|
||||
# The maximum width for displaying a note, in CHARS.
|
||||
# Depends on your screen-size. You can set it to
|
||||
# "auto", if you wish that note should determine the
|
||||
# available size automatically.
|
||||
MaxLen = auto
|
||||
|
||||
|
||||
|
||||
# The maximum width for displaying a note, in CHARS.
|
||||
# Depends on your screen-size. You can set it to
|
||||
# "auto", if you wish that note should determine the
|
||||
# available size.
|
||||
MaxLen auto
|
||||
#
|
||||
# Turn this off if you dont want note to automatically
|
||||
# clear the screen after displaying something and after
|
||||
# exit. The default is: YES
|
||||
AutoClear = YES
|
||||
|
||||
|
||||
|
||||
# Set this to 0 if you dont want note to automatically
|
||||
# clear the screen after displaying something and after
|
||||
# exit (feature introduced in 1.2.1).
|
||||
AutoClear 1
|
||||
#
|
||||
# note can use colors for output, turn this of, if
|
||||
# you don't like it, or if your terminal does
|
||||
# not support it. The default is: YES
|
||||
UseColors = YES
|
||||
|
||||
|
||||
|
||||
# note can use colors for output, set this option to
|
||||
# 1, if you don't want it, or if your terminal does
|
||||
# not support it, set to 0. The default is 1 (on).
|
||||
UseColors 1
|
||||
|
||||
|
||||
|
||||
# Color-definitions of the various items. Will only
|
||||
# take effect, if "UseColors" is turned on!
|
||||
#
|
||||
# The following colors are available:
|
||||
# black, red, green, yellow, blue, magenta, cyan and white.
|
||||
# for bold color write it uppercase (BLACK will be bold black)
|
||||
# for underlined color append an underscore (blue_ will be underlined blue)
|
||||
# for inverted color append an "I" (greenI will be inverted green)
|
||||
#
|
||||
# Color-definitions of the various items. Will only
|
||||
# take effect, if "UseColors" is turned on!
|
||||
#
|
||||
# The following colors are available:
|
||||
# black, red, green, yellow, blue, magenta, cyan and white.
|
||||
#
|
||||
# For bold color write it uppercase (BLACK will be bold black).
|
||||
# For underlined color append an underscore (blue_ will be underlined blue).
|
||||
# For inverted color append an "I" (greenI will be inverted green).
|
||||
BorderColor BLACK
|
||||
NumberColor blue
|
||||
NoteColor green
|
||||
@@ -166,52 +178,65 @@ TimeColor black
|
||||
TopicColor BLACK
|
||||
|
||||
|
||||
|
||||
# Additional to colors, you can also do a little bit of formatting your
|
||||
# notes (bold, underlined, italic), see README!
|
||||
# You need to set this Option to 1, if you decide to make use of this
|
||||
# capabily. You can also set it to 'simple' to achieve a simplified syntax.
|
||||
FormatText 1
|
||||
|
||||
#
|
||||
# Additional to colors, you can also do a little bit of formatting your
|
||||
# notes (bold, underlined, italic) text. The default is: YES.
|
||||
FormatText = YES
|
||||
|
||||
|
||||
|
||||
# You might specify your own directory for temporary files.
|
||||
# note needs to create some temp files during editing of notes.
|
||||
# You could protect this directory using the command: chmod 700 directory.
|
||||
# The default is /tmp
|
||||
TempDirectory /home/you/tmp
|
||||
#
|
||||
# You might specify your own directory for temporary files.
|
||||
# note needs to create some temp files during editing of notes.
|
||||
# You could protect this directory using the command: chmod 700 directory.
|
||||
# The default is: /tmp
|
||||
TempDirectory = ~/tmp
|
||||
|
||||
|
||||
|
||||
# You can jump to a topic by typing "cd 13" in interactive mode.
|
||||
# You need to set thi soption to 1 if you want to use this feature.
|
||||
ShortCd 0
|
||||
#
|
||||
# You can jump to a topic by typing "cd 13" in interactive mode.
|
||||
# The deault is: NO
|
||||
ShortCd = NO
|
||||
|
||||
|
||||
|
||||
# note can use a cached copy of the note database for list/tree/search
|
||||
# this is currently only supported by the binary and the mysql backends
|
||||
# set it to 1 to turn it on, the default is 0 (off)
|
||||
Cache 0
|
||||
#
|
||||
# note can use a cached copy of the note database for list/tree/search
|
||||
# this is currently only supported by the binary and the mysql backends,
|
||||
# the general and text backends have an internal cache.
|
||||
# The default is: NO
|
||||
Cache = NO
|
||||
|
||||
|
||||
|
||||
# you can define your very own time format for time stamps
|
||||
# YY - the last 2 digits of a year
|
||||
# YYYY - year
|
||||
# MM - month
|
||||
# DD - day
|
||||
# hh - hours
|
||||
# mm - minutes
|
||||
# ss - seconds
|
||||
# This is the default: (18.10.2000 21:32:08)
|
||||
TimeFormat DD.MM.YYYY hh:mm:ss
|
||||
#
|
||||
# You can define your very own time format for time stamps
|
||||
# YY - the last 2 digits of a year
|
||||
# YYYY - year
|
||||
# MM - month
|
||||
# DD - day
|
||||
# hh - hours
|
||||
# mm - minutes
|
||||
# ss - seconds
|
||||
# This is the default: (18.10.2000 21:32:08)
|
||||
TimeFormat = DD.MM.YYYY hh:mm:ss
|
||||
|
||||
|
||||
|
||||
#
|
||||
# You can make note readonly which is useful for database copies
|
||||
# The default is: NO
|
||||
ReadOnly = NO
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# That's all about it for now.
|
||||
# If you still have any questiosn, please feel free to contact
|
||||
# me by email: Thomas Linden <tom@daemon.de>
|
||||
#
|
||||
#
|
||||
# That's all about it for now.
|
||||
# If you still have any questiosn, please feel free to contact
|
||||
# me by email: Thomas Linden <tom@daemon.de>
|
||||
#
|
||||
#
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# installs note
|
||||
# This is the installer for the mysql version only!
|
||||
|
||||
echo "Welcome to note `cat VERSION` installation."
|
||||
echo "Welcome to note `cat ../VERSION` installation."
|
||||
echo "the install script will ask you a view questions,"
|
||||
echo "make sure to answer them correctly!"
|
||||
echo
|
||||
|
||||
16
note.pod
16
note.pod
@@ -1,3 +1,5 @@
|
||||
# -*-perl-*-
|
||||
|
||||
=head1 NAME
|
||||
|
||||
note - a perl script for maintaining notes.
|
||||
@@ -16,6 +18,7 @@ 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)!
|
||||
|
||||
|
||||
@@ -495,9 +498,16 @@ 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.
|
||||
1 turns an option on, 0 turns it off.
|
||||
|
||||
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).
|
||||
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>.
|
||||
@@ -513,6 +523,6 @@ Thomas Linden <tom@daemon.de>
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.2.6 (30/06/2004)
|
||||
1.3.0 (11/01/2005)
|
||||
|
||||
=cut
|
||||
|
||||
Reference in New Issue
Block a user