CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
#
|
|
|
|
|
|
# this is a generic module, used by note database
|
|
|
|
|
|
# backend modules.
|
|
|
|
|
|
#
|
2012-02-10 20:30:38 +01:00
|
|
|
|
# Copyright (c) 2000-2004 Thomas Linden <tom@daemon.de>
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package NOTEDB;
|
|
|
|
|
|
|
2012-02-10 20:31:13 +01:00
|
|
|
|
use Exporter ();
|
|
|
|
|
|
use vars qw(@ISA @EXPORT $crypt_supported);
|
|
|
|
|
|
|
|
|
|
|
|
$NOTEDB::VERSION = "1.31";
|
2012-02-10 20:27:05 +01:00
|
|
|
|
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
BEGIN {
|
2012-02-10 20:24:51 +01:00
|
|
|
|
# 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;
|
|
|
|
|
|
}
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub no_crypt {
|
2012-02-10 20:24:51 +01:00
|
|
|
|
$NOTEDB::crypt_supported = 0;
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub use_crypt {
|
2012-02-10 20:24:51 +01:00
|
|
|
|
my($this,$key,$method) = @_;
|
|
|
|
|
|
my($cipher);
|
|
|
|
|
|
if($NOTEDB::crypt_supported == 1) {
|
|
|
|
|
|
eval {
|
|
|
|
|
|
$cipher = new Crypt::CBC($key, $method);
|
|
|
|
|
|
};
|
|
|
|
|
|
if($@) {
|
2012-02-10 20:31:13 +01:00
|
|
|
|
print "warning: Crypt::$method not supported by system!\n";
|
|
|
|
|
|
$NOTEDB::crypt_supported = 0;
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
}
|
2012-02-10 20:24:51 +01:00
|
|
|
|
else {
|
|
|
|
|
|
$this->{cipher} = $cipher;
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
}
|
2012-02-10 20:24:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
else{
|
|
|
|
|
|
print "warning: Crypt::CBC not supported by system!\n";
|
|
|
|
|
|
}
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
2012-02-10 20:24:51 +01:00
|
|
|
|
#my $res = qq(\$match = 1 if($string););
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
return qq(\$match = 1 if($string););
|
2012-02-10 20:24:51 +01:00
|
|
|
|
#print $res . "\n";
|
|
|
|
|
|
#return $res;
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) = @_;
|
|
|
|
|
|
|
2012-02-10 20:24:51 +01:00
|
|
|
|
my %wildcards = (
|
|
|
|
|
|
'*' => '.*',
|
|
|
|
|
|
'?' => '.',
|
|
|
|
|
|
'[' => '[',
|
|
|
|
|
|
']' => ']',
|
|
|
|
|
|
'+' => '\+',
|
|
|
|
|
|
'.' => '\.',
|
|
|
|
|
|
'$' => '\$',
|
|
|
|
|
|
'@' => '\@',
|
|
|
|
|
|
'/' => '\/',
|
|
|
|
|
|
'|' => '\|',
|
|
|
|
|
|
'}' => '\}',
|
|
|
|
|
|
'{' => '\{',
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
);
|
|
|
|
|
|
|
2012-02-10 20:24:51 +01:00
|
|
|
|
my %escapes = (
|
|
|
|
|
|
'*' => '\*',
|
|
|
|
|
|
'?' => '\?',
|
|
|
|
|
|
'[' => '[',
|
|
|
|
|
|
']' => ']',
|
|
|
|
|
|
'+' => '\+',
|
|
|
|
|
|
'.' => '\.',
|
|
|
|
|
|
'$' => '\$',
|
|
|
|
|
|
'@' => '\@',
|
|
|
|
|
|
'(' => '\(',
|
|
|
|
|
|
')' => '\)',
|
|
|
|
|
|
'/' => '\/',
|
|
|
|
|
|
'|' => '\|',
|
|
|
|
|
|
'}' => '\}',
|
|
|
|
|
|
'{' => '\{',
|
|
|
|
|
|
);
|
|
|
|
|
|
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
# mask backslash
|
|
|
|
|
|
$str =~ s/\\/\\\\/g;
|
|
|
|
|
|
|
2012-02-10 20:24:51 +01:00
|
|
|
|
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
if ($str =~ /^"/ && $str =~ /"$/) {
|
|
|
|
|
|
# mask bracket-constructs
|
2012-02-10 20:24:51 +01:00
|
|
|
|
$str =~ s/(.)/$escapes{$1} || "$1"/ge;
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
$str =~ s/(.)/$wildcards{$1} || "$1"/ge;
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$str =~ s/^"//;
|
|
|
|
|
|
$str =~ s/"$//;
|
|
|
|
|
|
|
|
|
|
|
|
# mask spaces
|
|
|
|
|
|
$str =~ s/\s/\\s/g;
|
|
|
|
|
|
return $str;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-10 20:30:38 +01:00
|
|
|
|
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}) {
|
2012-02-10 20:31:13 +01:00
|
|
|
|
umask 022;
|
2012-02-10 20:30:38 +01:00
|
|
|
|
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 {
|
2012-02-10 20:31:13 +01:00
|
|
|
|
print $@;
|
2012-02-10 20:30:38 +01:00
|
|
|
|
print " timeout\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub unlock {
|
|
|
|
|
|
my ($this) = @_;
|
|
|
|
|
|
unlink $this->{LOCKFILE};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CHANGED: does no more use the external touch command to create a new
file, use perls open() instead.
CHANGED: excluded some of the help texts from the usage message and the
interactive help command to a manpage.
ADDED: new commandline flag "--encrypt" which one can use to encrypt
the mysql database password. This will be decrypted before
connecting to the db. There is also a new config file option
"encrypt_passwd" which indicates an encrypted db-password.
ADDED: another new config option "ShortCd", which can be set to "yes"
or 1 and if set, then a command like "cd 13" would jump
directly to the topic of the note with the number 13.
ADDED: now you can at any time cd back to the "root" of the
topic-structure using the command "cd /".
CHANGED: mysql.pm does now only do a table-lock on single write
accesses, no more on the whole session. This allows one to
access the same db twice or more.
FIXED: Changed README and Changelog for readability on 80 by 25
displays. And changed indentation of the note script itself.
ADDED: NOTEDB.pm - a generic module, which holds some methods, which
are used by binary.pm, mysql.pm and dbm.pm.
ADDED: NOTEDB.pm generate_search(), which allows one to
use AND, OR and various combinations of them using ( and ).
ADDED: a search does now return the 2nd line of a note if a matching
note's first line is a topic.
CHANGED: use "unshift" instead of push to add $libpath to @INC.
ADDED: a new feature, Caching of notes. supported by binary.pm and
mysql.pm. To turn it on, one need to set "Cache" in the config
to a true value.
2012-02-10 20:22:49 +01:00
|
|
|
|
1;
|