diff --git a/0x49/CVS/Entries b/0x49/CVS/Entries new file mode 100644 index 0000000..db015e8 --- /dev/null +++ b/0x49/CVS/Entries @@ -0,0 +1,3 @@ +/index.html/1.1.1.1/Sat Jul 1 14:40:50 2000// +D/contents//// +D/images//// diff --git a/0x49/CVS/Repository b/0x49/CVS/Repository new file mode 100644 index 0000000..ee4a33e --- /dev/null +++ b/0x49/CVS/Repository @@ -0,0 +1 @@ +NOTE/0x49 diff --git a/0x49/CVS/Root b/0x49/CVS/Root new file mode 100644 index 0000000..9c415c0 --- /dev/null +++ b/0x49/CVS/Root @@ -0,0 +1 @@ +zarahg@cvs.htnews.sourceforge.net:/cvsroot/htnews diff --git a/0x49/contents/CVS/Entries b/0x49/contents/CVS/Entries new file mode 100644 index 0000000..861a20b --- /dev/null +++ b/0x49/contents/CVS/Entries @@ -0,0 +1,14 @@ +/about/1.1.1.1/Sat Jul 1 14:40:50 2000// +/deutsch/1.1.1.1/Sat Jul 1 14:40:50 2000// +/index/1.1.1.1/Sat Jul 1 14:40:50 2000// +/installation/1.1.1.1/Sat Jul 1 14:40:50 2000// +/license/1.1.1.1/Sat Jul 1 14:40:50 2000// +/screenshots/1.1.1.1/Sat Jul 1 14:40:50 2000// +/upgrade/1.1.1.1/Sat Jul 1 14:40:50 2000// +/usage/1.1.1.1/Sat Jul 1 14:40:50 2000// +/cvs/1.2/Sat Jul 1 14:55:31 2000// +/menu/1.2/Sat Jul 1 14:58:41 2000// +/changelog/1.2/Sun Jul 9 22:16:25 2000// +/version/1.2/Sun Jul 9 22:16:43 2000// +/download/1.4/Sun Jul 9 23:03:12 2000// +D diff --git a/0x49/contents/CVS/Repository b/0x49/contents/CVS/Repository new file mode 100644 index 0000000..67873a3 --- /dev/null +++ b/0x49/contents/CVS/Repository @@ -0,0 +1 @@ +NOTE/0x49/contents diff --git a/0x49/contents/CVS/Root b/0x49/contents/CVS/Root new file mode 100644 index 0000000..9c415c0 --- /dev/null +++ b/0x49/contents/CVS/Root @@ -0,0 +1 @@ +zarahg@cvs.htnews.sourceforge.net:/cvsroot/htnews diff --git a/0x49/contents/about b/0x49/contents/about new file mode 100644 index 0000000..484ea34 --- /dev/null +++ b/0x49/contents/about @@ -0,0 +1,13 @@ +

about note and this page

+

+The author of note is Thomas Linden. if you have any questions, suggestions, votes or even flames, please feel free to +send me an E-mail! +

+This page is hosted by ConSol* GmbH, Germany - THANKS A LOT! +

+Powered by ePerl and vi. +

+ +

+Logo created with:
+ diff --git a/0x49/contents/changelog b/0x49/contents/changelog new file mode 100644 index 0000000..e603761 --- /dev/null +++ b/0x49/contents/changelog @@ -0,0 +1,294 @@ +

changelog

+ +
+ +
+

















+ +0.1: +INITIAL RELEASE. + + diff --git a/0x49/contents/cvs b/0x49/contents/cvs new file mode 100644 index 0000000..7247410 --- /dev/null +++ b/0x49/contents/cvs @@ -0,0 +1,20 @@ +

CVS

+

+ +The whole note source tree is now maintained via CVS at sourceforge.net. + +You can browse the repository via the web: +
+http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/NOTE/?cvsroot=htnews. + +

+ +Or you can use the cvs command: +
+

+cvs -d:pserver:anonymous@cvs.htnews.sourceforge.net:/cvsroot/htnews login 
+
+cvs -z3 -d:pserver:anonymous@cvs.htnews.sourceforge.net:/cvsroot/htnews co NOTE
+
+
+When prompted for a password for anonymous, simply press the Enter key. diff --git a/0x49/contents/deutsch b/0x49/contents/deutsch new file mode 100644 index 0000000..b2e9a46 --- /dev/null +++ b/0x49/contents/deutsch @@ -0,0 +1,19 @@ +

Hinweise für deutsche Besucher

+note ist ein Konsolenprogram, mit dem man einfach Notizen verwalten + kann, ähnlich wie bei "knotes". Es ist in Perl geschrieben. Note + verwendet externe (mitgelieferte!) Module als Speicher-Backend, um + die Daten zu speichern. Momentan ist ein mysql-Modul dabei, sowie + ein "binary"-Modul, note's eigenes Datenformat und seit 1.0.5 auch ein + DBM modul. Das mysql Modul verwendet Perls Standard Modul DBI + und ist damit für alle gängigen DBMS verwendbar. + Seit Version 1.0.0 wird Verschlüsselung unterstützt(IDEA oder DES), + man kann also durchaus auch sensible Daten speichern. +

+Die Dokumentation für note liegt leider nur in englisch vor. Trotzdem müssen Deutsche +nicht ganz leer ausgehen :-) +

+Hannes Lau hat auf seiner Homepage eine kurze Beschreibung bereitgestellt (Tausend Dank!). +

+Eine ausführliche Beschreibung des Programmes ist ausserdem im +LinuxMagazin 5/2000 S. 106 erschienen (allerdings basierend auf einer +älteren Version...)!
*stolzsei* ;-) diff --git a/0x49/contents/download b/0x49/contents/download new file mode 100644 index 0000000..609781f --- /dev/null +++ b/0x49/contents/download @@ -0,0 +1,17 @@ +

downloads

+

+Here you can find the note package for free download. Follow the installation instructions in the +README file provided with the package or read the online version. +

+ newest: note-1.0.8.tar.gz
+ note-1.0.7.tar.gz
+ note-1.0.6.tar.gz
+ note-1.0.5.tar.gz
+ read the README
+ read the Changelog
+ +


+If you encounter any problems with the site above, try to use one of the following mirrors:

+ftp://www.0x49.org/pub/scip/note/ +
+http://sourceforge.net/project/filelist.php?group_id=656 diff --git a/0x49/contents/index b/0x49/contents/index new file mode 100644 index 0000000..29e5fbb --- /dev/null +++ b/0x49/contents/index @@ -0,0 +1,49 @@ +

welcome to the homepage of note by Thomas Linden

+note is a small console program written in perl, which allows +you to manage notes similar to programs like "knotes" from +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) and another +module, which uses a binary file for storage and a DBM module.
+Note supports since version 1.0.0 encryption(IDEA or DES)!

+Here is a brief list of it's features: + +

+ +

+ note is released under the terms of the Gnu Public License(GPL) + and is therefore free Software. diff --git a/0x49/contents/installation b/0x49/contents/installation new file mode 100644 index 0000000..c4e43bc --- /dev/null +++ b/0x49/contents/installation @@ -0,0 +1,42 @@ +

installation of note

+

+ Unpack the tar-ball and issue the command:
+ $ perl Makefile.PL
+ It will ask you a few questions about file destinations. + The script will find itself the proper destinations for + the files. So, if you agree with it, simply press ENTER. + However, you may decide to use other destinations. In this + case, enter it, when asked. This maybe usefull, if you are + installing it in your ome-directory and if you are not root! +

+ For installation instructions for the mysql database installation + see mysql/README. +

+ If want to use another SQL database, i.e. postgresql then set + the option "DbDriver" to the name of the responding DBI-driver + and create a symlink of this name like this: +
/usr/lib/perl5/siteperl/NOTEDB $ ln -s mysql.pm oracle.pm +
The functionality is the same, but not the name! +

+ The default binary file backend does not need any special installation + procedure, you need only to spceify a filename in your config file. +

+ The DBM backend(NOTEDB::dbm) requires the existence of a directory, + which you must specify in your config using the option "DbName". +

+ + +Configuration + + This version of note doesn't neccessarily need + a configuration file. But you can have one and change + some default values. Take a look to the file config/noterc + provided with this tarball. There are detailed instructions + about every available parameter. +
Simply copy this file into your home-directory and name it + .noterc + If you decide not to use the default database backend (a binary + file), you will *need* a configuration! + + + diff --git a/0x49/contents/license b/0x49/contents/license new file mode 100644 index 0000000..3f49b1b --- /dev/null +++ b/0x49/contents/license @@ -0,0 +1,342 @@ +

                    
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    
+    Copyright (C) 19yy  
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  , 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
diff --git a/0x49/contents/menu b/0x49/contents/menu new file mode 100644 index 0000000..c3a3630 --- /dev/null +++ b/0x49/contents/menu @@ -0,0 +1,19 @@ + +
home

installation

usage

upgrade

changelog

download

license

cvs

screenshots

deutsch

about

+


+
last updated 02.07.2000 +

+best viewed with any browser +

+ diff --git a/0x49/contents/screenshots b/0x49/contents/screenshots new file mode 100644 index 0000000..3329a3d --- /dev/null +++ b/0x49/contents/screenshots @@ -0,0 +1,16 @@ +

screenshots

+ +Yes there are also screenshots of note available :-) +
+Simply click on a tumbnail to enlarge the image! +

+ Linux +
+

+ Win32 +
+

+ BeOS +
+

+and finally here a desktop of a user with note running. diff --git a/0x49/contents/upgrade b/0x49/contents/upgrade new file mode 100644 index 0000000..2158119 --- /dev/null +++ b/0x49/contents/upgrade @@ -0,0 +1,45 @@ +

upgrade from previous version of note to 1.0.x

+

+In any case: BACKUP your existing note database!!!!!!! +The format has not changed, but some default values +(see the new config file-sample). Use this command +to save your note database with your *old* version +of note:
+ "note -D"
+This works with both the mysql and the binary version. +

+You need to reedit your configfile. Please refer to the +sample config in config/noterc. +

+


+

+This version of note has now encryption support build in. +If you decide to use it, you need to re-initialize your +note database. That's why, because your current database +is unencrypted and *if* you want to secure your data, you +need to secure everything. That means, your existing data +must be encrypted before you can use this new capability! +

+Follow this steps: +

+From now on, your data is encrypted. You will need the passphrase +you set above for decrypting it! So - don't forget it! + + diff --git a/0x49/contents/usage b/0x49/contents/usage new file mode 100644 index 0000000..821d26d --- /dev/null +++ b/0x49/contents/usage @@ -0,0 +1,350 @@ +

usage of note

+

+1. Description

+2. Topics

+3. Formatting of note-text

+4. Scripting

+5. Binary DB

+6. Mysql DB

+7. Dump Format

+8. Security

+


+

+ +

Decription

+ + If you don't know, how to run note, try "note -h" first. + It will tell you all available commandline options. +

+ To create a new note, simply run "note". You can enter + the note (the length is by default limited to 4096 bytes, + which you can change from your config file if you are using + the binary backend, therwise there is no limitation). + End by typing a . on a line itself. note will tell you the + number of the note. +

+ If you want to view the note, type "note 1", if the notenumber + was 1. +

+ If you want to get an overview of all notes, type "note -l". + You will get a list of all notes, containing the number, + the first line and the creation date. If topic-support is + turned on (which is by default), then all subtopics under the + current topic will be displayed first. +
If you want to get a listing of all + If you want to see the timestamps, use "-L" instead of "-l". + Read more about topics below in the section "Topics". + You can also specify the topic which notes you want to see: + "-l mytopic" does the trick. +
Additional, you might want to get an overview of your topic- + strcture. You can use the command "-t" in this case, which + will display a tree-view of your tpic-structure. You can + use the command "-T" if you want to see the notes under each + topic too. "-T" will also show the number of each note. +

+ To edit a certain note, type "note -e 1". It will invoke your + editor (vi or pico). You can edit it, after saving, note + will store the changed note to the database. +

+ Of course you can drop a certain note: "note -d 1" deletes + note number 1. If a note in the middle or the beginning of + the database will be deleted, note will recount the other + existent notes. For example there are 3 notes, number 1, 2 + and 3. If you delete number 2, then number 3 will become + number 2. +
You can also make use of the extended delete-syntax: + To delete note 1 and 2, use "-d 1,2" + To delete note 1,2 and 3, use "-d 1-3". +

+ If you cannot remember, which note you are looking for, you + can use the search capability of note: "note -s ". + note will search the whole note database case insensitive for + an occurence of this string and tell you the number and first- + line it have. +

+ Instead of using note from the commandline you can use the + interactive mode. Run note with "note -i". If you need assistance + type "?" or "h" at the ">" prompt. The interactive mode + provides you the most functions of note. +

+ You can also dump the contents of your note-database into a + ASCII-textfile(-D). You can use this file later to import it into + your note-database(-I). This is usefull, if you want quickly trans- + fer your notes from one host to another (i.e. you could mail + your note-dump form your office to home and import it there + for further use). +
The dumps from the two versions of note are in the same format. + Using dumps it is also possible to reinitialize your database. You + can use the "-o" switch whcih causes note to overwrite your existing + database. This is very handy if you changed heavily your config. And + it is required, if you changed: encryption, db-driver, (binary-format) + and the password. You can use the following command for reinitializing: +
$ note -D - | note -o -I - +
What the hell, does it?! Step by step: +

+ Before you use the "-o" switch, I consider yuo to make a backup! + +

+ +top

+

Topics

+ + If topic-support is turned on (which is by default), the various + notes are sorted under various topics. There is no special database + field for the topic. Instead the topic will be stored right in the + note. +
If the first line of your note contains some text bordered by slashes + (or whatever you prefer, set "TopicSeparator" in your config! default is slash), + then note will consider it as the topic of this certain note. For examle: +
/TodoList/ +
If you are using topics, no data after the topic is allowed, if there + is any text, note will consider it as a subtopic! Therefore, don't for- + get to put a newline after the topic-line. +

+ If you are in interactive mode, you can "cd" to a different note simply + by typing it's name at the command-prompt, or you can use the well-known + syntax "cd topic". +
The list-command will only show you notes under this topic. If you create + a new note, it will automagically inserted under the current topic (note + will prepend the string "/topicname/" to the text of your note). +

+ You can create at any time from any point a new topic. Just create a new + note and type the name of the new topic bordered by slashes (or TopicSeparator) + at the first line of this note. After saving, there will be available a + new topic with one note in it. +

+ You can create as many subtopics as you like, the format is similar to a + filesystem-path. An example, say, you want to create such a structure: +

+

        
+        (root - top level)
+        |
+        |----test
+        |      |----subtopic
+        |      |       |--note 1
+        |      |       |--note 2
+        |      |
+        |      |--note 4  
+        |
+        |--note 3
+
+

+ Then you may create those 4 new notes: +
+

+        --- snip ---
+        /test/subtopic/
+        note 1
+        --- snip ---
+        /test/subtopic/
+        note 2
+        --- snip ---
+        note 3
+        --- snip ---
+        /test/
+        note 4
+        --- snip ---             
+

+ I hope, you got the point ;-) +

+ + + If a note does not contain the "magic" /topic/ construction on the first + line, it will be listed under the "root" of note, that is the point you are + at the startup of note. +

+ You can subsequently move a note without a topic to a certain topic. Simply + edit it and insert at the first line the above mentioned construction. +

+ Note: Please don't forget the prepending and appending a slash of a topic. + You will get strange results without it! + + +

+ +top

+

Formatting of notes

+ + Another very nice feature is the possibility to format the note-text (as much as + shell allows it). First, you can use the note-internal "magic-strings" for color- + izing. Those strings looks much like HTML: +i
"here is a green line of text no more green." + As you see, the beginning of another color starts with a tag(kinda) of the color + and ens with an end tag . +

+ The following colors are available: + black, red, green, yellow, blue, magenta, cyan and white. +

+ Beside colorizing text, you can also create bold or underlined text! If you decide + to use this (additional) feature, you need to set the Config-Option "FormatNotes" + to 1 which turns it on. +
Usage is very straightforward, if a word (a word is defined as some text with at least + one space surrounded) is between a magic mark-character. Here are the available + things, you can do: +

+                bold:           **word**
+                underlined:     __word__
+                inverse:        {{word}}
+
+ The text will be formatted using the actually note-color. +

+ + +top

+

Scripting

+ + Since version 1.0.3 there are some additions which allows you to use note in + scripts, without user-interaction. You might run a special script as cronjob, + which adds a note under a certain topic every week. Or the like. +

+ Here are the possibilies you have: +

+ You can add a new note through a pipe, another commands output becomes + note's input: +
$ cat /var/spool/news/daily | note - +
This command adds the content of a file "daily" as a new note. Note the dash. + it stands for "Standard Input". Note will be completely silent and it will not + ask for something. +

+ Suppose you are using encryption. You might wonder, how note will get your + passphrase? The solution: You need to set up an environment variable which + contains the password: +
$ export NOTE_PASSWD=secret +
If the variable is present, note will not ask you for a passphrase! +

+ Another thingy you might find useful is the -r (--raw) command-line flag. This + turns note into raw mode , which means it will only print the + data without any formatting. Raw mode is available for list and display, + since it makes no sense, interactive mode doe not support raw mode. +

+ + + +top

+

Format of the notedb (binary backend)

+ + The database where the notes are stored is a binary fixed record length file + of the following format: + It consists of three fixed length fields per entry. The fields + have the following types: + + You can change the sizes of the fields "Note" and "Time" in + the configfile "~/.noterc". If it does not exist, the above + defaults will be used. +
If the data to be stored is smaller then the size of the field, + it will be filled with ZERO's ("\0"). The Note and the Time + fields will be uuencoded before storage. Of course, this is + no security, never mind... + +

+ +top

+

The note-database (mysql backend)

+ + The sql-database for the mysql version has the following design: +
+        +--------+---------+------+-----+---------+----------------+
+        | Field  | Type    | Null | Key | Default | Extra          |
+        +--------+---------+------+-----+---------+----------------+
+        | number | int(10) |      | PRI | 0       | auto_increment |
+        | note   | text    | YES  |     | NULL    |                |
+        | date   | text    | YES  |     | NULL    |                |
+        +--------+---------+------+-----+---------+----------------+
+
+ +

+ +top

+

Format of the ASCII-dump file (note -D)

+ + The dump of a note-database (if you use note -D) has the following + format: +
        
+        --- snip ---
+        Number: 1
+        Timestamp: 14.01.2000 00:25:01
+        This is a sample text
+        in a sample note.
+
+        Number: 2
+        Timestamp: 14.01.2000 02:37:40
+        And this is another sample
+        of a note.
+        --- snip ---
+
+

You can reimport a dump into your note-database with "note -I " + Existing notes will not overwritten, note will append the imported + data to your note-database. +

+ + +top

+

Security

+ + If you are using the MySQL driver, refer to the mysql + manual for more informations about security of mysql databases: + http://www.mysql.org/Manual_chapter/manual_Privilege_system.html +

+ If you are using notes proprietary binary driver, then + the permission 0600 of the file "~/.notedb" is strongly required! +

+ Additional, you can turn on encryption from the config file. + Simply set UseEncryption to 1. Please note, that you need + to decide, if you want to use encryption before the first use + of note! If have already a note database and want to "migrate" + to encryption, I suggest you to follow the directions in the + file UPGRADE! +

+ You can choose from different encryption algorythms. The default + is IDEA, but DES or BLOWFISH is also possible. You need to have + installed the following additional perl-modules on your system: +

+ After turning on encryption, note will ask you for a passphrase + everytime it runs! It will *not* store this passphrase! + So, don't forget it! Be careful! +

+ Once note have encrypted some data using this passphrase, you + cannot simply switch to another passphrase, because all data + within the database needs to be encrypted using the same passphrase! + If you want to change the passphrase for any reason, please read + the file UPGRADE and follow it's directions! +
Someday I will add a "change passwd" function, which will do all + these things for you. Someday, I said... + For now you can use the "re-initialze database" functionality, mentioned + earlier in the "Usage" section (at the end of the section). +

+ Note: To make sure, the encrypted data can be stored properly, + it will be uuencoded after encryption. +

+ Note: *If* you forgot your passphrase and *if* you don't have + a backup of your database without encryption, PLEASE + don't bother me with "helpme" emails! If you don't know + the phrase, then the data can't be decrypted. Even if it + is possible - I am not responsible for that! +

+ Note: How does note know, if the passphrase was incorrect? It uses the + specified phrase and encodes at least one note (the first one) + and checks if the decrypted timestamp field matches the following + expression: "^\d+\.\d+". Translated from perl to human: + the timestamp must begin with minimum one digit (possibly more), + followed by one dot, followed by minimum one digit (possibly more). + Chances are bad, that a wrong passphrase will cause a timestamp + matching the rule above. If you have other experiences, please + drop me a mail! diff --git a/0x49/contents/version b/0x49/contents/version new file mode 100644 index 0000000..b0f3d96 --- /dev/null +++ b/0x49/contents/version @@ -0,0 +1 @@ +1.0.8 diff --git a/0x49/images/CVS/Entries b/0x49/images/CVS/Entries new file mode 100644 index 0000000..a2d8974 --- /dev/null +++ b/0x49/images/CVS/Entries @@ -0,0 +1,14 @@ +/anybrow.gif/1.1.1.1/Sat Jul 1 14:40:51 2000// +/button.gif/1.1.1.1/Sat Jul 1 14:40:51 2000// +/gproc.jpg/1.1.1.1/Sat Jul 1 14:40:51 2000// +/linux.gif/1.1.1.1/Sat Jul 1 14:40:51 2000// +/msfree.gif/1.1.1.1/Sat Jul 1 14:40:51 2000// +/note-be.jpg/1.1.1.1/Sat Jul 1 14:40:52 2000// +/note-linux.gif/1.1.1.1/Sat Jul 1 14:40:51 2000// +/note-win32.gif/1.1.1.1/Sat Jul 1 14:40:51 2000// +/note.jpg/1.1.1.1/Sat Jul 1 14:40:52 2000// +/note_be_small.png/1.1.1.1/Sat Jul 1 14:40:51 2000// +/note_linux_small.png/1.1.1.1/Sat Jul 1 14:40:51 2000// +/note_win32_small.png/1.1.1.1/Sat Jul 1 14:40:51 2000// +/notes.png/1.1.1.1/Sat Jul 1 14:40:51 2000// +D diff --git a/0x49/images/CVS/Repository b/0x49/images/CVS/Repository new file mode 100644 index 0000000..45ba545 --- /dev/null +++ b/0x49/images/CVS/Repository @@ -0,0 +1 @@ +NOTE/0x49/images diff --git a/0x49/images/CVS/Root b/0x49/images/CVS/Root new file mode 100644 index 0000000..9c415c0 --- /dev/null +++ b/0x49/images/CVS/Root @@ -0,0 +1 @@ +zarahg@cvs.htnews.sourceforge.net:/cvsroot/htnews diff --git a/0x49/images/anybrow.gif b/0x49/images/anybrow.gif new file mode 100644 index 0000000..d7c0e0e Binary files /dev/null and b/0x49/images/anybrow.gif differ diff --git a/0x49/images/button.gif b/0x49/images/button.gif new file mode 100644 index 0000000..244ed01 Binary files /dev/null and b/0x49/images/button.gif differ diff --git a/0x49/images/gproc.jpg b/0x49/images/gproc.jpg new file mode 100644 index 0000000..1b8730c Binary files /dev/null and b/0x49/images/gproc.jpg differ diff --git a/0x49/images/linux.gif b/0x49/images/linux.gif new file mode 100644 index 0000000..afa21e0 Binary files /dev/null and b/0x49/images/linux.gif differ diff --git a/0x49/images/msfree.gif b/0x49/images/msfree.gif new file mode 100644 index 0000000..48248c0 Binary files /dev/null and b/0x49/images/msfree.gif differ diff --git a/0x49/images/note-be.jpg b/0x49/images/note-be.jpg new file mode 100644 index 0000000..94d5880 Binary files /dev/null and b/0x49/images/note-be.jpg differ diff --git a/0x49/images/note-linux.gif b/0x49/images/note-linux.gif new file mode 100644 index 0000000..acdfdba Binary files /dev/null and b/0x49/images/note-linux.gif differ diff --git a/0x49/images/note-win32.gif b/0x49/images/note-win32.gif new file mode 100644 index 0000000..3c379a3 Binary files /dev/null and b/0x49/images/note-win32.gif differ diff --git a/0x49/images/note.jpg b/0x49/images/note.jpg new file mode 100644 index 0000000..dbaf3be Binary files /dev/null and b/0x49/images/note.jpg differ diff --git a/0x49/images/note_be_small.png b/0x49/images/note_be_small.png new file mode 100644 index 0000000..b7ee8d1 Binary files /dev/null and b/0x49/images/note_be_small.png differ diff --git a/0x49/images/note_linux_small.png b/0x49/images/note_linux_small.png new file mode 100644 index 0000000..f42b78f Binary files /dev/null and b/0x49/images/note_linux_small.png differ diff --git a/0x49/images/note_win32_small.png b/0x49/images/note_win32_small.png new file mode 100644 index 0000000..ea3a86d Binary files /dev/null and b/0x49/images/note_win32_small.png differ diff --git a/0x49/images/notes.png b/0x49/images/notes.png new file mode 100644 index 0000000..64fa2f3 Binary files /dev/null and b/0x49/images/notes.png differ diff --git a/0x49/index.html b/0x49/index.html new file mode 100644 index 0000000..4554b04 --- /dev/null +++ b/0x49/index.html @@ -0,0 +1,86 @@ + + + + + + + + + www.0x49.org - the note homepage (<? print $src ?>) + + + +
+ + + + +
+ + + + + + + + +
+ note + ; + close VERSION; + chomp $version; + print $version; + ?> + homepage +
+ + ; + close MENU; + foreach (@menu) { + if(/\Q$me\E/) { + print "$_"; + } + else { + print; + } + } + ?> + +

 

+
+ + + + +
+; + print @lines; + close SRC; +?> +
+
+
+

+ + diff --git a/CVS/Entries b/CVS/Entries new file mode 100644 index 0000000..1cfbb0e --- /dev/null +++ b/CVS/Entries @@ -0,0 +1,12 @@ +/Makefile.PL/1.1.1.1/Sat Jul 1 14:40:50 2000// +/UPGRADE/1.1.1.1/Sat Jul 1 14:40:50 2000// +/note/1.1.1.1/Sat Jul 1 14:40:50 2000// +/stresstest.sh/1.1.1.1/Sat Jul 1 14:40:50 2000// +D/0x49//// +D/NOTEDB//// +D/bin//// +D/config//// +D/mysql//// +/Changelog/1.2/Sun Jul 9 22:08:40 2000// +/VERSION/1.2/Sun Jul 9 22:10:55 2000// +/README/1.2/Sun Jul 9 22:37:00 2000// diff --git a/CVS/Repository b/CVS/Repository new file mode 100644 index 0000000..2a7999c --- /dev/null +++ b/CVS/Repository @@ -0,0 +1 @@ +NOTE diff --git a/CVS/Root b/CVS/Root new file mode 100644 index 0000000..9c415c0 --- /dev/null +++ b/CVS/Root @@ -0,0 +1 @@ +zarahg@cvs.htnews.sourceforge.net:/cvsroot/htnews diff --git a/Changelog b/Changelog index abc280d..d90fe3e 100644 --- a/Changelog +++ b/Changelog @@ -1,127 +1,188 @@ -================================================================================== +================================================================================ + +1.1.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. + +================================================================================ + +1.0.9: jumped directly to 1.1.0, too many additions. + +================================================================================ + +1.0.8: +FIXED: typo in noterc shipped with package may caused confusion + (BLOWFISH instead of Blowfish). +CHANGED: changed the way note manages temporary filez. It uses now a + random string instead of just it's own PID. It does also change + it's umask to 077 and, if applicable (on ext2 filesystems) + issues "chattr +s" which will cause the ext2 inodes to be + zero'd after file deletion. +ADDED: A new config option allows the user to specify her own + temp-directory. The default is still /tmp. + +================================================================================ 1.0.7: FIXED: there was a bug in the search expression, use now \Q and \E. -ADDED: --config allows one to use another config than the default. +ADDED: --config allows one to use another config than the + default. -================================================================================== +================================================================================ 1.0.6: -FIXED: there were some odd bugs in commandline parsing, some options were unavailable. +FIXED: there were some odd bugs in commandline parsing, some options + were unavailable. FIXED: Forgot "PreferredEditor" config-option in the new config format. FIXED: the interactive "cd .." command has ignored the presence of a "DefaultLong" setting(and search too)... thx to Peter. -CHANGED: Optimized a little bit the output routine, now it is better to read. -ADDED: sub format and appropriate config-option for text formatting capabilities. -CHANGED: changed getconfig regexp, which allows now also to use Option = Param. -FIXED: was not possible to override config-options, which are set by default to - something. -ADDED: note chacks now, if a database os actually really encrypted and exits with - an error if it s and the user turned off encryption. This protects her from - destroying it's own database .. +CHANGED: Optimized a little bit the output routine, now it is better to + read. +ADDED: sub format and appropriate config-option for text formatting + capabilities. +CHANGED: changed getconfig regexp, which allows now also to use + Option = Param. +FIXED: was not possible to override config-options, which are set by + default to something. +ADDED: note checks now, if a database os actually really encrypted and + exits with an error if it s and the user turned off encryption. + This protects her from destroying it's own database .. -================================================================================== +================================================================================ 1.0.5: -FIXED: the T (and t respectively) printed nothing out since 1.0.3! It does - it now again... -ADDED: a new database backend added, NOTEDB::dbm, which uses DBM files for - storage. +FIXED: the T (and t respectively) printed nothing out since 1.0.3! + It does it now again... +ADDED: a new database backend added, NOTEDB::dbm, which uses DBM + files for storage. FIXED: &display-tree returns now, if there is no note, otherwise it would die because of an undefined refernce. -CHANGED: Changed the config file format completely. It is now no more a perl - file, instead it is a simple plain text file which note parses. -CHANGED: Changed the way, note loads it database backend. It uses now the - $dbdriver variable as module-name, which makes it possible easily - to write your own backend without the need to change note itself. +CHANGED: Changed the config file format completely. It is now no more + a perl file, instead it is a simple plain text file which note + parses. +CHANGED: Changed the way, note loads it database backend. It uses now + the $dbdriver variable as module-name, which makes it possible + easily to write your own backend without the need to change + note itself. FIXED: Removed Getopt::Long option "bundling", causes errors with perl 5.6.0 and is not senceful. FIXED: Added the Getopt::Long option "no_ignore_case". In 1.0.4 options were case insensitive causing -i to be interpreted as --import instead of --interactive ;-((( -ADDED: a new config option $DEFAULT_LIST, which causes note, \ - if turned to "LONG", to use long-listing as default. | - But it will still be able to use short-listing if you | - explicit specify that. | submitted by -FIXED: sub search prints now an appropriate error-message in |==> Peter Palmreuther - case no searchstring was given instead of jumping to | thanks a lot! - usage. | -CHANGED: Changed the text in the interactive help to reflect | - changes of verion 1.0.3 (t and T). / + +Thanks to Peter Palmreuter for the following fixed/additions: +ADDED: a new config option $DEFAULT_LIST, which causes note, + if turned to "LONG", to use long-listing as default. + But it will still be able to use short-listing if you + explicit specify that. +FIXED: sub search prints now an appropriate error-message in + case no searchstring was given instead of jumping to + usage. +CHANGED: Changed the text in the interactive help to reflect + changes of verion 1.0.3 (t and T). -================================================================================== +================================================================================ 1.0.4: CHANGED: Moved from @ARGV-parsing to Getopt::Long, adding options is now much easier and I do now understand my own code ;-) ADDED: --raw, the "Raw Mode", which turns off any formatting of output. -================================================================================== +================================================================================ 1.0.3: ADDED: "-" works also for --dump, but in the other direction. It causes note to dump to standard output instead into a file. -ADDED: you can specify - as filename for use with --import and if you want - to create a new note. "-" stands for standardinput and it allows you - tp pipe another commands output to note! -ADDED: you can now use an environment variable for the passphrase (when using - encryption). If it is presen, note will not ask for a passphrase. This - is very usefull in comination with the addition above, for use in - scripts. +ADDED: you can specify - as filename for use with --import and if you + want to create a new note. "-" stands for standardinput and + it allows you to pipe another commands output to note! +ADDED: you can now use an environment variable for the passphrase + (when using encryption). If it is present, note will not ask + for a passphrase. This is very useful in comination with the + addition above, for use in scripts. CHANGED: the interactive help screen is now coloured. -ADDED: -o commandline switch, which causes note to overwrite an existing - database when importing data from a previous dump. Very handy if - you want to re-initialize your db, i.e. if you changed the format. -ADDED: the long-tree-view (-T) displays now also the note-number of each - note. +ADDED: -o commandline switch, which causes note to overwrite an + existing database when importing data from a previous dump. + Very handy if you want to re-initialize your db, i.e. if you + changed the format. +ADDED: the long-tree-view (-T) displays now also the note-number of + each note. -================================================================================== +================================================================================ 1.0.2: ADDED: Topic-Tree overview command (-t or -T). ADDED: Enhanced list command in interactive mode, you can now specify a topic which notes you want to see. -CHANGED: updated the help and usage sections to reflect the additions above. +CHANGED: updated the help and usage sections to reflect the additions + above. -================================================================================== +================================================================================ 1.0.1: -FIXED: fixed bug in NOTEDB::mysql, which caused note t store NULL values - in db, if encryption was off. A really dump failure :-( +FIXED: fixed bug in NOTEDB::mysql, which caused note to store NULL + values in db, if encryption was off. A really dump failure :-( -================================================================================== +================================================================================ 1.0.0: CHANGED: removed install.sh. use now a Makefile for installation. ADDED: Encryption support. Note can now encrypt notes using IDEA or DES as encryption-protocols(symetric). -================================================================================== +================================================================================ 0.9: FIXED: There were many new bugs after my last changes *grrrrr*. fixed. Works now properly, with both backends! FIXED: and another bug: recounting of numbers did not take care about - the existing order! If you deleted note #12, then note #13 became - not neccessarily #12! Instead it becames any other number (kind of - randomly...). + the existing order! If you deleted note #12, then note #13 + became not neccessarily #12! Instead it becames any other + number (kind of randomly...). CHANGED: NOTEDB::binary set_del function changed, it does no more require a temporary file for number recount. Instead it uses get_all and stores all notes in RAM and then rewrites the database. FIXED: fixed the set_new call within note. It used 0 as the first param - (number) which is not useful since we dont have support for auto- - increment from all database backends. + (number) which is not useful since we dont have support for + autoincrement from all database backends. FIXED: fixed the function set_recountnum in NITEDB::mysql, it was also - incorrect :-((( 0.8 seemed to be a very bad early alpha........... -FIXED: there was a bug in NOTEDB::binary which caused not to recount note - numbers after deleting one :-( + incorrect :-((( 0.8 seemed to be a very bad early alpha... +FIXED: there was a bug in NOTEDB::binary which caused not to recount + note numbers after deleting one :-( -================================================================================== +================================================================================ 0.8: ADDED: NOTEDB::binary. so now 0.8 is ready for shipping ! -FIXED: regexp bug fixed. It was only possible to delete 2 items together +FIXED: regexp bug fixed. It was only possible to delete 2 items + together separated by comma ("d 1,2,3,4" deleted only 1,2!). ADDED: Some new config options which reflects the new module structure. So you can change your database backend without the need to @@ -135,40 +196,42 @@ ADDED: NOTEDB::mysql added. Perlmodule, which I will use within CHANGED: The SQL code does not use Mysql.pm anymore. Instead it is coded using the more portable DBI module. This allows one easily to switch to anther database, which is supported by DBI. -CHANGED: Locking. The db-table will now be locked before note accesses it. -FIXED: width of listings is now always the same independent of the string- - length of a certain note. +CHANGED: Locking. The db-table will now be locked before note accesses + it. +FIXED: width of listings is now always the same independent of the + stringlength of a certain note. -================================================================================== +================================================================================ 0.7: ADDED: one can now use the unix-like "cd" command to change to another topic, thus use "cd topicname" instead just typing "topicname"! -FIXED: there was a smal regex bug which maked it impossible to use such - topics: "4 test", in such a case note just displayed note number 4 - instead of cd'ing to topic "4 test". +FIXED: there was a smal regex bug which maked it impossible to use + such topics: "4 test", in such a case note just displayed note + number 4 instead of cd'ing to topic "4 test". ADDED: a new config option "$KEEP_TIMESTAMP" allows a user to disable - note's default behavior of updating the timestamp of a note after - editing it. + note's default behavior of updating the timestamp of a note + after editing it. -================================================================================== +================================================================================ 0.6: FIXED: oops - the new suptopic feature confused the commandline-mode of - note! quickly corrected! so subtopics also available from command- - line. -FIXED: a small bug fiyed, it was impossible to use -D or -I from command- - line, if $ALWAYS_INT was turned on, now it is. + note! quickly corrected! so subtopics also available from + commandline. +FIXED: a small bug fiyed, it was impossible to use -D or -I from + commandline, if $ALWAYS_INT was turned on, now it is. FIXED: fixed problem with local/global variable $time, which confused - the script under certain circumstances, now $time is no more global, - it will be read in (using &getdate) locally by &new and &edit. + the script under certain circumstances, now $time is no more + global, it will be read in (using &getdate) locally by &new + and &edit. CHANGED: The Topic separator is no longer hardcoded, one can customize - it using the $TopicSep variable, the default is now /, the backslash - will no mor work! + it using the $TopicSep variable, the default is now /, the + backslash will no more work! CHANGED: use perl buildin localtime() function instead of GNU date, which is possibly not installed on every target system (i.e. win32), therefore better portability! @@ -186,7 +249,7 @@ FIXED: A bug at line 769 causing single note where smaller than note- -================================================================================== +================================================================================ @@ -198,47 +261,53 @@ FIXED: There was another bug, which caused the list command to display -================================================================================== +================================================================================ 0.4.2: -ADDED: If run in interactive mode, note will at first do a list command. +ADDED: If run in interactive mode, note will at first do a list + command. FIXED: A bug caused note to save bogus timestamps after editing a note. -CHANGED: It does no more print 3 newlines before the menu in interactive mode. -FIXED: Some more vars will be resetted during each loop in interactive mode. - $ListType. +CHANGED: It does no more print 3 newlines before the menu in interactive + mode. +FIXED: Some more vars will be resetted during each loop in interactive + mode. $ListType. -================================================================================== +================================================================================ 0.4.1: -ADDED: The install.sh script for the mysql version is no able to install the - required Mysql module directly from CPAN, thanks to David A. Bandel! -FIXED: The mysql version did not display notes (i.e.: "note 3" did nothing) -CHANGED: Again, the sql-format of the mysql database has been changed. Now - there are only 3 fields, the number filed is the primary key, the id - field in previous versions was a waste of diskspace... +ADDED: The install.sh script for the mysql version is no able to + install the required Mysql module directly from CPAN, thanks + to David A. Bandel! +FIXED: The mysql version did not display notes (i.e.: "note 3" did + nothing) +CHANGED: Again, the sql-format of the mysql database has been changed. + Now there are only 3 fields, the number filed is the primary + key, the id field in previous versions was a waste of + diskspace... CHANGED: The format of the dump-output has been changed. -ADDED: It is now possible to import previously dumped notes into the notedb +ADDED: It is now possible to import previously dumped notes into the + notedb (dumps from both versions are compatible with each other) FIXED: the function num_bereich() had a bug, which caused ot to ignore under some circumstances one number (i.e. "note -d 4-13" did nothing). -================================================================================== +================================================================================ 0.4: CHANGED: ok, mysql support is back again (upon requests). therefore there are two different version of the script in the same time with - the same features, one for mysql and the other one for the binary - database. + the same features, one for mysql and the other one for the + binary database. ADDED: Dump to textfile capability. Later on I want to dump it into a palm readable format, any help is welcome! ADDED: interactive mode. @@ -250,17 +319,18 @@ ADDED: sub num_bereich(), which allows one to specify more then one -================================================================================== +================================================================================ 0.3: CHANGED: it uses no more a mysql database, but a binary file instead. This is much faster! -ADDED: note can display the notes with colors, it is turned off by default +ADDED: note can display the notes with colors, it is turned off by + default -================================================================================== +================================================================================ 0.2: @@ -271,7 +341,7 @@ FIXED: now numbers of notes will be recounted, if one delete one note, CHANGED: the look of the list output has been changed, similar to a table -================================================================================== +================================================================================ 0.1: INITIAL RELEASE. diff --git a/Makefile.PL b/Makefile.PL index cc0d712..1f1d904 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -2,7 +2,7 @@ # NOTEDB::mysql and NOTEDB::binary are internals # of note. # -# $Id: Makefile.PL,v 1.1 2000/04/17 17:38:49 thomas Exp thomas $ +# $Id: Makefile.PL,v 1.1.1.1 2000/07/01 14:40:50 zarahg Exp $ # # check for the existence of optional modules: sub chk_mod @@ -86,17 +86,22 @@ $install = `which install`; open M, "> Makefile" || die $!; print M qq~BIN = bin/note +MAN = note.1 LIBS = NOTEDB/mysql.pm NOTEDB/binary.pm NOTEDB/dbm.pm +CORE = NOTEDB.pm INSTBIN = $BINDIR INSTLIB = $LIBDIR +INSTMAN = /usr/man/man1 INSTALL = $install all: \@echo "done. Type make install.\\n" install: + \$(INSTALL) -m 755 \$(CORE) \$(INSTLIB) \$(INSTALL) -d -m 755 \$(INSTLIB)/NOTEDB \$(INSTALL) -m 755 \$(LIBS) \$(INSTLIB)/NOTEDB \$(INSTALL) -m 755 \$(BIN) \$(INSTBIN) + \$(INSTALL) -m 644 \$(MAN) \$(INSTMAN) ~; print "Type \"make install\" to install all files.\n\n"; diff --git a/NOTEDB.pm b/NOTEDB.pm new file mode 100644 index 0000000..c8ee73b --- /dev/null +++ b/NOTEDB.pm @@ -0,0 +1,213 @@ +# +# this is a generic module, used by note database +# backend modules. +# +# $Id$ +# +# Copyright (c) 2000 Thomas Linden + + +package NOTEDB; + +BEGIN { + # make sure, it works, otherwise encryption + # is not supported on this system! + eval { require Crypt::CBC; }; + if($@) { + $NOTEDB::crypt_supported = 0; + } + else { + $NOTEDB::crypt_supported = 1; + } +} + + +sub no_crypt { + $NOTEDB::crypt_supported = 0; +} + + +sub use_crypt { + my($this,$key,$method) = @_; + if($NOTEDB::crypt_supported == 1) { + eval { + $cipher = new Crypt::CBC($key, $method); + }; + if($@) { + $NOTEDB::crypt_supported == 0; + } + } + else{ + print "warning: Crypt::CBC not supported by system!\n"; + } +} + + +sub use_cache { + # + # this sub turns on cache support + # + my $this = shift; + $this->{use_cache} = 1; + $this->{changed} = 1; +} + +sub cache { + # + # store the whole db as hash + # if use_cache is turned on + # + my $this = shift; + if ($this->{use_cache}) { + my %res = @_; + %{$this->{cache}} = %res; + } +} + +sub unchanged { + # + # return true if $this->{changed} is true, this will + # be set to true by writing subs using $this->changed(). + # + my $this = shift; + return 0 if(!$this->{use_cache}); + if ($this->{changed}) { + $this->{changed} = 0; + return 0; + } + else { + print "%\n"; + return 1; + } +} + +sub changed { + # + # turn on $this->{changed} + # this will be used by update or create subs. + # + my $this = shift; + $this->{changed} = 1; +} + + +sub generate_search { + # + # get user input and create perlcode ready for eval + # sample input: + # "ann.a OR eg???on AND u*do$" + # resulting output: + # "$match = 1 if(/ann\.a/i or /eg...on/i and /u.*do\$/i ); + # + my($this, $string) = @_; + + my $case = "i"; + + if ($string =~ /^\/.+?\/$/) { + return $string; + } + elsif (!$string) { + return "/^/"; + } + + # we will get a / in front of the first word too! + $string = " " . $string . " "; + + # check for apostrophs + $string =~ s/(?<=\s)(\(??)("[^"]+"|\S+)(\)??)(?=\s)/$1 . $this->check_exact($2) . $3/ge; + + # remove odd spaces infront of and after »and« and »or« + $string =~ s/\s\s*(AND|OR)\s\s*/ $1 /g; + + # remove odd spaces infront of »(« and after »)« + $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 »and« and »or« + $string =~ s/(?check_or($1, $case) /ge; + + # remove slashes on »and« and »or« + $string =~ s/\/(and|or)\/$case/$1/g; + + # remove spaces inside /string/ constructs + $string =~ s/(? '.*', + '?' => '.', + '[' => '[', + ']' => ']', + '+' => '\+', + '.' => '\.', + '$' => '\$', + '@' => '\@', + ); + + # mask backslash + $str =~ s/\\/\\\\/g; + + if ($str =~ /^"/ && $str =~ /"$/) { + # mask bracket-constructs + $str =~ s/(\(|\))/\\$1/g; + } + $str =~ s/(.)/$globs{$1} || "$1"/ge; + + $str =~ s/^"//; + $str =~ s/"$//; + + # mask spaces + $str =~ s/\s/\\s/g; + return $str; +} + + + + +1; diff --git a/NOTEDB/CVS/Entries b/NOTEDB/CVS/Entries new file mode 100644 index 0000000..1a34910 --- /dev/null +++ b/NOTEDB/CVS/Entries @@ -0,0 +1,5 @@ +/README/1.1.1.1/Sat Jul 1 14:40:52 2000// +/binary.pm/1.1.1.1/Sat Jul 1 14:40:52 2000// +/dbm.pm/1.1.1.1/Sat Jul 1 14:40:52 2000// +/mysql.pm/1.1.1.1/Sat Jul 1 14:40:52 2000// +D diff --git a/NOTEDB/CVS/Repository b/NOTEDB/CVS/Repository new file mode 100644 index 0000000..cc8371e --- /dev/null +++ b/NOTEDB/CVS/Repository @@ -0,0 +1 @@ +NOTE/NOTEDB diff --git a/NOTEDB/CVS/Root b/NOTEDB/CVS/Root new file mode 100644 index 0000000..9c415c0 --- /dev/null +++ b/NOTEDB/CVS/Root @@ -0,0 +1 @@ +zarahg@cvs.htnews.sourceforge.net:/cvsroot/htnews diff --git a/NOTEDB/binary.pm b/NOTEDB/binary.pm index fac520b..003239e 100644 --- a/NOTEDB/binary.pm +++ b/NOTEDB/binary.pm @@ -1,26 +1,19 @@ #!/usr/bin/perl -# $Id: binary.pm,v 1.6 2000/06/25 19:48:00 scip Exp scip $ +# $Id: binary.pm,v 1.1.1.1 2000/07/01 14:40:52 zarahg Exp $ # Perl module for note # binary database backend. see docu: perldoc NOTEDB::binary # +package NOTEDB; + use strict; use Data::Dumper; use IO::Seekable; -package NOTEDB; +use NOTEDB; + use Fcntl qw(LOCK_EX LOCK_UN); -BEGIN { - # make sure, it works, although encryption - # not supported on this system! - eval { require Crypt::CBC; }; - if($@) { - $NOTEDB::crypt_supported = 0; - } - else { - $NOTEDB::crypt_supported = 1; - } -} - + + # Globals: my ($NOTEDB, $sizeof, $typedef,$version); my ($cipher); @@ -48,12 +41,12 @@ sub new exit(1); } - - my $TYPEDEF = "i a$MAX_NOTE a$MAX_TIME"; + my $TYPEDEF = "i a$MAX_NOTE a$MAX_TIME"; my $SIZEOF = length pack($TYPEDEF, () ); $sizeof = $SIZEOF; $typedef = $TYPEDEF; + return $self; } @@ -67,24 +60,7 @@ sub version { return $version; } -sub no_crypt { - $NOTEDB::crypt_supported = 0; -} -sub use_crypt { - my($this,$key,$method) = @_; - if($NOTEDB::crypt_supported == 1) { - eval { - $cipher = new Crypt::CBC($key, $method); - }; - if($@) { - $NOTEDB::crypt_supported == 0; - } - } - else{ - print "warning: Crypt::CBC not supported by system!\n"; - } -} sub set_del_all { @@ -94,8 +70,7 @@ sub set_del_all } -sub get_single -{ +sub get_single { my($this, $num) = @_; my($address, $note, $date, $buffer, $n, $t, $buffer, ); @@ -112,20 +87,24 @@ sub get_single flock NOTE, LOCK_UN; close NOTE; - + return $note, $date; } sub get_all { - my($this, $num, $note, $date, %res); + my $this = shift; + my($num, $note, $date, %res); + if ($this->unchanged) { + return %{$this->{cache}}; + } open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n"; - flock NOTE, LOCK_EX; - my($buffer, $t, $n); + flock NOTE, LOCK_EX; + my($buffer, $t, $n); seek(NOTE, 0, 0); # START FROM BEGINNING - while(read(NOTE, $buffer, $sizeof)) { + while(read(NOTE, $buffer, $sizeof)) { ($num, $note, $date) = unpack($typedef, $buffer); $t = ude($date); $n = ude($note); @@ -135,18 +114,27 @@ sub get_all flock NOTE, LOCK_UN; close NOTE; + $this->cache(%res); return %res; } sub get_nextnum { - my($this, $num, $te, $me, $buffer); + my $this = shift; + my($num, $te, $me, $buffer); + if ($this->unchanged) { + $num = 1; + foreach (keys %{$this->{cache}}) { + $num++; + } + return $num; + } open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n"; - flock NOTE, LOCK_EX; - - seek(NOTE, 0, 0); # START FROM BEGINNING + flock NOTE, LOCK_EX; + + seek(NOTE, 0, 0); # START FROM BEGINNING while(read(NOTE, $buffer, $sizeof)) { ($num, $te, $me) = unpack($typedef, $buffer); } @@ -160,10 +148,31 @@ sub get_nextnum sub get_search { my($this, $searchstring) = @_; - my($buffer, $num, $note, $date, %res, $t, $n); + my($buffer, $num, $note, $date, %res, $t, $n, $match); + + my $regex = $this->generate_search($searchstring); + eval $regex; + if ($@) { + print "invalid expression: \"$searchstring\"!\n"; + return; + } + $match = 0; + + if ($this->unchanged) { + foreach my $num (keys %{$this->{cache}}) { + $_ = $this->{cache}{$num}->{note}; + eval $regex; + if ($match) { + $res{$num}->{note} = $this->{cache}{$num}->{note}; + $res{$num}->{date} = $this->{cache}{$num}->{date} + } + $match = 0; + } + return %res; + } open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n"; - flock NOTE, LOCK_EX; + flock NOTE, LOCK_EX; seek(NOTE, 0, 0); # START FROM BEGINNING while(read(NOTE, $buffer, $sizeof)) @@ -171,11 +180,14 @@ sub get_search ($num, $note, $date) = unpack($typedef, $buffer); $n = ude($note); $t = ude($date); - if($n =~ /\Q$searchstring\E/i) + $_ = $n; + eval $regex; + if($match) { $res{$num}->{'note'} = $n; $res{$num}->{'date'} = $t; } + $match = 0; } flock NOTE, LOCK_UN; close NOTE; @@ -192,7 +204,7 @@ sub set_edit my $address = ($num -1 ) * $sizeof; open NOTE, "+<$NOTEDB" or die "could not open $NOTEDB\n"; - flock NOTE, LOCK_EX; + flock NOTE, LOCK_EX; seek(NOTE, $address, IO::Seekable::SEEK_SET); my $n = uen($note); @@ -203,6 +215,8 @@ sub set_edit flock NOTE, LOCK_UN; close NOTE; + + $this->changed; } @@ -220,6 +234,8 @@ sub set_new flock NOTE, LOCK_UN; close NOTE; + + $this->changed; } @@ -249,6 +265,9 @@ sub set_del } flock NOTE, LOCK_UN; close NOTE; + + $this->changed; + return; } @@ -256,14 +275,14 @@ sub set_recountnums { my($this) = @_; my(%orig, $note, $date, $T, $setnum, $buffer, $n, $N, $t); - + $setnum = 1; %orig = $this->get_all(); open NOTE, ">$NOTEDB" or die "could not open $NOTEDB\n"; flock NOTE, LOCK_EX; seek(NOTE, 0, 0); # START FROM BEGINNING - + foreach $N (sort {$a <=> $b} keys %orig) { $n = uen($orig{$N}->{'note'}); $t = uen($orig{$N}->{'date'}); @@ -274,6 +293,9 @@ sub set_recountnums } flock NOTE, LOCK_UN; close NOTE; + + $this->changed; + return; } @@ -306,6 +328,10 @@ sub ude return $T; } + + + + 1; # keep this! __END__ @@ -318,7 +344,7 @@ NOTEDB::binary - module lib for accessing a notedb from perl # include the module use NOTEDB; - + # create a new NOTEDB object $db = new NOTEDB("binary", "/home/tom/.notedb", 4096, 24); diff --git a/NOTEDB/dbm.pm b/NOTEDB/dbm.pm index cfdc0ba..74b051f 100644 --- a/NOTEDB/dbm.pm +++ b/NOTEDB/dbm.pm @@ -1,25 +1,15 @@ #!/usr/bin/perl -# $Id: dbm.pm,v 1.2 2000/06/25 19:51:11 scip Exp scip $ +# $Id: dbm.pm,v 1.1.1.1 2000/07/01 14:40:52 zarahg Exp $ # Perl module for note # DBM database backend. see docu: perldoc NOTEDB::dbm # use DB_File; #use Data::Dumper; +use NOTEDB; use strict; package NOTEDB; -BEGIN { - # make sure, it works, although encryption - # not supported on this system! - eval { require Crypt::CBC; }; - if($@) { - $NOTEDB::crypt_supported = 0; - } - else { - $NOTEDB::crypt_supported = 1; - } -} # Globals: my ($dbm_dir, $notefile, $timefile, $version, $cipher, %note, %date); @@ -52,25 +42,6 @@ sub version { return $version; } -sub no_crypt { - $NOTEDB::crypt_supported = 0; -} - -sub use_crypt { - my($this, $key, $method) = @_; - if($NOTEDB::crypt_supported == 1) { - eval { - $cipher = new Crypt::CBC($key, $method); - }; - if($@) { - $NOTEDB::crypt_supported == 0; - } - } - else{ - print "warning: Crypt::CBC not supported by system!\n"; - } -} - sub get_single { @@ -104,13 +75,23 @@ sub get_nextnum sub get_search { my($this, $searchstring) = @_; - my($num, $note, $date, %res); + my($num, $note, $date, %res, $match); + my $regex = $this->generate_search($searchstring); + eval $regex; + if ($@) { + print "invalid expression: \"$searchstring\"!\n"; + return; + } + $match = 0; foreach $num (sort {$a <=> $b} keys %date) { - if (ude($note{$num}) =~ /\Q$searchstring\E/i) { + $_ = ude($note{$num}); + eval $regex; + if ($match) { $res{$num}->{'note'} = ude($note{$num}); $res{$num}->{'date'} = ude($date{$num}); } + $match = 0; } return %res; @@ -196,6 +177,8 @@ sub ude } } + + 1; # keep this! __END__ diff --git a/NOTEDB/mysql.pm b/NOTEDB/mysql.pm index 9c47509..e9c7288 100644 --- a/NOTEDB/mysql.pm +++ b/NOTEDB/mysql.pm @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: mysql.pm,v 1.5 2000/06/25 19:50:43 scip Exp scip $ +# $Id: mysql.pm,v 1.1.1.1 2000/07/01 14:40:52 zarahg Exp $ # Perl module for note # mysql database backend. see docu: perldoc NOTEDB::binary # @@ -7,21 +7,10 @@ use DBI; use strict; use Data::Dumper; +use NOTEDB; package NOTEDB; -BEGIN { - # make sure, it works, although encryption - # not supported on this system! - eval { require Crypt::CBC; }; - if($@) { - $NOTEDB::crypt_supported = 0; - } - else { - $NOTEDB::crypt_supported = 1; - } -} - # Globals: my ($DB, $table, $fnum, $fnote, $fdate, $version, $cipher); $table = "note"; @@ -35,7 +24,6 @@ my $sql_getsingle = "SELECT $fnote,$fdate FROM $table WHERE $fnum = ?"; my $sql_all = "SELECT $fnum,$fnote,$fdate FROM $table"; my $sql_nextnum = "SELECT max($fnum) FROM $table"; my $sql_incrnum = "SELECT $fnum FROM $table ORDER BY $fnum"; -my $sql_search = "SELECT DISTINCT $fnum,$fnote,$fdate FROM $table WHERE $fnote LIKE ?"; my $sql_setnum = "UPDATE $table SET $fnum = ? WHERE $fnum = ?"; my $sql_edit = "UPDATE $table SET $fnote = ?, $fdate = ? WHERE $fnum = ?"; @@ -57,11 +45,6 @@ sub new my $database = "DBI:$dbdriver:$dbname;host=$dbhost"; $DB = DBI->connect($database, $dbuser, $dbpasswd) || die DBI->errstr(); - - # LOCK the database! - my $lock = $DB->prepare("LOCK TABLES $table WRITE") || die $DB->errstr(); - $lock->execute() || die $DB->errstr(); - return $self; } @@ -69,40 +52,36 @@ sub new sub DESTROY { # clean the desk! - my $unlock = $DB->prepare("UNLOCK TABLES") || die $DB->errstr; - $unlock->execute() || die $DB->errstr(); - $DB->disconnect || die $DB->errstr; } + +sub lock { + my($this) = @_; + # LOCK the database! + my $lock = $DB->prepare("LOCK TABLES $table WRITE") || die $DB->errstr(); + $lock->execute() || die $DB->errstr(); +} + + +sub unlock { + my($this) = @_; + my $unlock = $DB->prepare("UNLOCK TABLES") || die $DB->errstr; + $unlock->execute() || die $DB->errstr(); + $DB->disconnect || die $DB->errstr; +} + + sub version { return $version; } -sub no_crypt { - $NOTEDB::crypt_supported = 0; -} -sub use_crypt { - my($this, $key, $method) = @_; - if($NOTEDB::crypt_supported == 1) { - eval { - $cipher = new Crypt::CBC($key, $method); - }; - if($@) { - $NOTEDB::crypt_supported == 0; - } - } - else{ - print "warning: Crypt::CBC not supported by system!\n"; - } -} - -sub get_single -{ +sub get_single { my($this, $num) = @_; + my($note, $date); my $statement = $DB->prepare($sql_getsingle) || die $DB->errstr(); - + $statement->execute($num) || die $DB->errstr(); $statement->bind_columns(undef, \($note, $date)) || die $DB->errstr(); @@ -114,7 +93,13 @@ sub get_single sub get_all { - my($this, $num, $note, $date, %res); + my $this = shift; + my($num, $note, $date, %res); + + if ($this->unchanged) { + return %{$this->{cache}}; + } + my $statement = $DB->prepare($sql_all) || die $DB->errstr(); $statement->execute || die $DB->errstr(); @@ -124,6 +109,8 @@ sub get_all $res{$num}->{'note'} = ude($note); $res{$num}->{'date'} = ude($date); } + + $this->cache(%res); return %res; } @@ -131,6 +118,14 @@ sub get_all sub get_nextnum { my($this, $num); + if ($this->unchanged) { + $num = 1; + foreach (keys %{$this->{cache}}) { + $num++; + } + return $num; + } + my $statement = $DB->prepare($sql_nextnum) || die $DB->errstr(); $statement->execute || die $DB->errstr(); @@ -144,30 +139,35 @@ sub get_nextnum sub get_search { my($this, $searchstring) = @_; - my($num, $note, $date, %res); - if($NOTEDB::crypt_supported != 1) { - $searchstring = "\%$searchstring\%"; - my $statement = $DB->prepare($sql_search) || die $DB->errstr(); - $statement->execute($searchstring) || die $DB->errstr(); - $statement->bind_columns(undef, \($num, $note, $date)) - || die $DB->errstr(); - while($statement->fetch) { - $res{$num}->{'note'} = $note; - $res{$num}->{'date'} = $date; - } + my($num, $note, $date, %res, $match); + + my $regex = $this->generate_search($searchstring); + eval $regex; + if ($@) { + print "invalid expression: \"$searchstring\"!\n"; + return; + } + $match = 0; + + my %data; + if ($this->unchanged) { + %data = %{$this->{cache}}; } else { - my %res = $this->get_all(); - foreach $num (sort { $a <=> $b } keys %res) { - $note = ude($res{$num}->{'note'}); - $date = ude($res{$num}->{'date'}); - if($note =~ /\Q$searchstring\E/i) - { - $res{$num}->{'note'} = $note; - $res{$num}->{'date'} = $date; - } - } + %data = $this->get_all(); } + foreach $num (sort { $a <=> $b } keys %data) { + $note = ude($data{$num}->{'note'}); + $date = ude($data{$num}->{'date'}); + $_ = $note; + eval $regex; + if($match) { + $res{$num}->{'note'} = $note; + $res{$num}->{'date'} = $date; + } + $match = 0; + } + return %res; } @@ -177,24 +177,28 @@ sub get_search sub set_edit { my($this, $num, $note, $date) = @_; - + + $this->lock; my $statement = $DB->prepare($sql_edit) || die $DB->errstr(); - $note =~ s/'/\'/g; $note =~ s/\\/\\\\/g; $statement->execute(uen($note), uen($date), $num) || die $DB->errstr(); + $this->unlock; + $this->changed; } sub set_new { my($this, $num, $note, $date) = @_; - + $this->lock; my $statement = $DB->prepare($sql_insertnew) || die $DB->errstr(); $note =~ s/'/\'/g; - $note =~ s/\\/\\\\/g; + $note =~ s/\\/\\\\/g; $statement->execute($num, uen($note), uen($date)) || die $DB->errstr(); + $this->unlock; + $this->changed; } @@ -202,7 +206,8 @@ sub set_del { my($this, $num) = @_; my($note, $date, $T); - + + $this->lock; ($note, $date) = $this->get_single($num); return "ERROR" if ($date !~ /^\d/); @@ -210,6 +215,8 @@ sub set_del # delete record! my $statement = $DB->prepare($sql_del) || die $DB->errstr(); $statement->execute($num) || die $DB->errstr(); + $this->unlock; + $this->changed; return; } @@ -217,14 +224,19 @@ sub set_del sub set_del_all { my($this) = @_; + $this->lock; my $statement = $DB->prepare($sql_del_all) || die $DB->errstr(); $statement->execute() || die $DB->errstr(); + $this->unlock; + $this->changed; return; } -sub set_recountnums -{ +sub set_recountnums { my $this = shift; + + $this->lock; + my(@count, $i, $num, $setnum, $pos); $setnum = 1; $pos=0; $i=0; @count = (); @@ -237,13 +249,14 @@ sub set_recountnums $count[$i] = $num; $i++; } - # now recount them! my $sub_statement = $DB->prepare($sql_setnum) || die $DB->errstr(); for($pos=0;$pos<$i;$pos++) { $setnum = $pos +1; $sub_statement->execute($setnum,$count[$pos]) || die $DB->errstr(); } + $this->unlock; + $this->changed; } sub uen @@ -287,7 +300,7 @@ NOTEDB::mysql - module lib for accessing a notedb from perl # include the module use NOTEDB; - + # create a new NOTEDB object (the last 4 params are db table/field names) $db = new NOTEDB("mysql","note","localhost","username","password","note","number","note","date"); diff --git a/README b/README index 781316c..d512583 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -note 1.0.8 by Thomas Linden, 11/07/2000 +note 1.0.9 by Thomas Linden, 08/08/2000 ======================================= Introduction @@ -72,8 +72,11 @@ Features stdin as well es duming to stdout instead a file. Additional, there is an option --raw available, which prints everything out completely without formatting. + o for better performance, note can cache the database for listings + or searching. o It can be installed without root-privileges. - o Last, a while ago a user stated: "... it simply does, what it says ..." + o Last, a while ago a user stated: "... it simply does, what it + says ..." @@ -189,6 +192,18 @@ Usage note will search the whole note database case insensitive for an occurence of this string and tell you the number and first- line it have. + You can extend the searchstring using B, B ( and ) and + shell-like wildcards: + + $ note -s "moses AND lenin" + + or: + + $ note -s "(mike OR arnold) AND (jackson OR schwarzenegger)" + + If note finds a note, which first line is a topic, then it will + display it's second line. + These rules apply for the interactive search too. Instead of using note from the commandline you can use the interactive mode. Run note with "note -i". If you need assistance @@ -212,10 +227,10 @@ Usage o "note -D -" creates a note-database dump and prints it out to stantdard output. o "|" this is the shell's pipe command. It takes the output - of the left program and gives it to the right program as standard - input. - o "note -o -I -" imports a note-database dump from standard input - and overwrites an existing database. + of the left program and gives it to the right program as + standard input. + o "note -o -I -" imports a note-database dump from standard + input and overwrites an existing database. Before you use the "-o" switch, I consider yuo to make a backup! @@ -229,8 +244,9 @@ Topics field for the topic. Instead the topic will be stored right in the note. If the first line of your note contains some text bordered by slashes - (or whatever you prefer, set "TopicSeparator" in your config! default is slash), - then note will consider it as the topic of this certain note. For examle: + (or whatever you prefer, set "TopicSeparator" in your config! default + is slash), then note will consider it as the topic of this certain + note. For examle: /TodoList/ If you are using topics, no data after the topic is allowed, if there is any text, note will consider it as a subtopic! Therefore, don't for- @@ -239,17 +255,24 @@ Topics If you are in interactive mode, you can "cd" to a different note simply by typing it's name at the command-prompt, or you can use the well-known syntax "cd topic". - The list-command will only show you notes under this topic. If you create - a new note, it will automagically inserted under the current topic (note - will prepend the string "/topicname/" to the text of your note). + The list-command will only show you notes under this topic. If you + create a new note, it will automagically inserted under the current + topic (note will prepend the string "/topicname/" to the text of your + note). + You can use some enhanced capabilities of the cd command. If you turn on + the "ShortCd" parameter in your configuration, then you can cd to a + note number (and thus - to it's topic) i.e. "cd 13" jumps to the topic + of the note number 13. You can always go one level up using the "cd .." + command and you can go to the top-level topic using "cd /". You can create at any time from any point a new topic. Just create a new - note and type the name of the new topic bordered by slashes (or TopicSeparator) - at the first line of this note. After saving, there will be available a - new topic with one note in it. + note and type the name of the new topic bordered by slashes (or + TopicSeparator) at the first line of this note. After saving, there + will be available a new topic with one note in it. - You can create as many subtopics as you like, the format is similar to a - filesystem-path. An example, say, you want to create such a structure: + You can create as many subtopics as you like, the format is similar to + a filesystem-path. An example, say, you want to create such a + structure: (root - top level) | @@ -281,14 +304,15 @@ Topics If a note does not contain the "magic" /topic/ construction on the first - line, it will be listed under the "root" of note, that is the point you are - at the startup of note. + line, it will be listed under the "root" of note, that is the point + you are at the startup of note. - You can subsequently move a note without a topic to a certain topic. Simply - edit it and insert at the first line the above mentioned construction. + You can subsequently move a note without a topic to a certain topic. + Simply edit it and insert at the first line the above mentioned + construction. - Note: Please don't forget the prepending and appending a slash of a topic. - You will get strange results without it! + Note: Please don't forget the prepending and appending a slash of a + topic. You will get strange results without it! @@ -296,22 +320,22 @@ Topics Formatting of notes =================== - Another very nice feature is the possibility to format the note-text (as much as - shell allows it). First, you can use the note-internal "magic-strings" for color- - izing. Those strings looks much like HTML: + Another very nice feature is the possibility to format the note-text + (as much as shell allows it). First, you can use the note-internal + "magic-strings" for colorizing. Those strings looks much like HTML: "here is a green line of text no more green." - As you see, the beginning of another color starts with a tag(kinda) of the color - and ens with an end tag . + As you see, the beginning of another color starts with a tag(kinda) of + the color and ens with an end tag . The following colors are available: black, red, green, yellow, blue, magenta, cyan and white. - Beside colorizing text, you can also create bold or underlined text! If you decide - to use this (additional) feature, you need to set the Config-Option "FormatNotes" - to 1 which turns it on. - Usage is very straightforward, if a word (a word is defined as some text with at least - one space surrounded) is between a magic mark-character. Here are the available - things, you can do: + Beside colorizing text, you can also create bold or underlined text! If + you decide to use this (additional) feature, you need to set the + Config-Option "FormatNotes" to 1 which turns it on. + Usage is very straightforward, if a word (a word is defined as some + text with at least one space surrounded) is between a magic mark- + character. Here are the available things, you can do: bold: **word** underlined: __word__ @@ -322,30 +346,54 @@ Formatting of notes +Cache +===== + + If you have many notes stored in your database then you might + find the cache feature useful. Chaching is currently supported + by the binary and the mysql backend. Set the configuration + parameter "Cache" to "1" or "yes" to turn caching on. + Note will then use an internal copy of your notes-database for + the list/search/tree commands instead of every time accessing + the physically database. If something changed (i.e. you edited + a note or added a new one) then the database will be used and + the cache will be updated. + A "%" character at the top left of the screen indicates that + the cache is in use. + I consider you not to use the cache feature if you are using + multiple instances of note using the same database. + The cache is turned off by default. + + + + + + Scripting ========= - Since version 1.0.3 there are some additions which allows you to use note in - scripts, without user-interaction. You might run a special script as cronjob, - which adds a note under a certain topic every week. Or the like. + Since version 1.0.3 there are some additions which allows you to use + note in scripts, without user-interaction. You might run a special + script as cronjob, which adds a note under a certain topic every week. + Or the like. Here are the possibilies you have: You can add a new note through a pipe, another commands output becomes note's input: $ cat /var/spool/news/daily | note - - This command adds the content of a file "daily" as a new note. Note the dash. - it stands for "Standard Input". Note will be completely silent and it will not - ask for something. + This command adds the content of a file "daily" as a new note. Note + the dash - it stands for "Standard Input". Note will be completely + silent and it will not ask for something. - Suppose you are using encryption. You might wonder, how note will get your - passphrase? The solution: You need to set up an environment variable which - contains the password: + Suppose you are using encryption. You might wonder, how note will get + your passphrase? The solution: You need to set up an environment + variable which contains the password: $ export NOTE_PASSWD=secret If the variable is present, note will not ask you for a passphrase! - Another thingy you might find useful is the -r (--raw) command-line flag. This - turns note into raw mode , which means it will only print the + Another thingy you might find useful is the -r (--raw) command-line + flag. This turns note into raw mode , which means it will only print the data without any formatting. Raw mode is available for list and display, since it makes no sense, interactive mode doe not support raw mode. @@ -356,8 +404,8 @@ Scripting Format of the notedb (binary backend) ===================================== - The database where the notes are stored is a binary fixed record length file - of the following format: + The database where the notes are stored is a binary fixed record length + file of the following format: It consists of three fixed length fields per entry. The fields have the following types: o Number: Integer (1 byte) @@ -440,6 +488,20 @@ Security After turning on encryption, note will ask you for a passphrase everytime it runs! It will *not* store this passphrase! So, don't forget it! Be careful! + + If you are using the mysql backend and if your mysql database + requires a password then you can store an encrypted version of + your mysql password instead of the cleartext one. + You need to turn on the config-parameter "encrypt_passwd" (set it + to 1). Then you need to create an encrypted string from your + mysql-password using note's commandline option --encrypt . + Note will ask you for a passphrase which will be used to encrypt + the mysql-password. This passphrase must be exactly the same as + you use for mysql itself. That means you need to use encryption. + The string you get from this command must be saved in your config + file as attribute to "DbPasswd". Later on note will decrypt that + string using the supplied note-passphrase (that's why it must be + the same used for encrypt) and pass the result to the mysql server. Once note have encrypted some data using this passphrase, you cannot simply switch to another passphrase, because all data @@ -465,30 +527,48 @@ Security and checks if the decrypted timestamp field matches the following expression: "^\d+\.\d+". Translated from perl to human: the timestamp must begin with minimum one digit (possibly more), - followed by one dot, followed by minimum one digit (possibly more). + followed by one dot, followed by minimum one digit (possibly + more). Chances are bad, that a wrong passphrase will cause a timestamp matching the rule above. If you have other experiences, please - drop me a mail! + drop me a mail! + + For the paranoid: do not use the cache-feature, 'cause note stores a + copy of your note database in RAM if cache support is turned on. + This means an attacker could access your (unencrypted!) notes. Comments ======== You can send any comments to Thomas Linden . - If you find a bug or if you have a suggestion for improvement of the script - feel free to send me a patch ;-) + If you find a bug or if you have a suggestion for improvement of the + script feel free to send me a patch ;-) License ======= - This script comes with absolutely NO WARRANTY. It is distributed under the - terms of the GNU General Public License. Use it at your own risk :-) + This script comes with absolutely NO WARRANTY. It is distributed under + the terms of the GNU General Public License. Use it at your own risk :-) You can read the complete GPL at: http://www.gnu.org/copyleft/gpl.html + + +Recources +========= + + The command-line options and all commands of the interactive mode are + described in the supplied note(1) manpage. + You may also refer to the note website http://www.0x49.org. + + + + + Author and Copyright ==================== @@ -506,12 +586,13 @@ Contributors / Credits Jens Heunemann - sub tree. Peter Palmreuther - various additions. - And many other people who sended bug reports, feature requests. If you feel that - I forgot your name in this list, then please send me an email and I'll add you. + And many other people who sent bug reports, feature requests. If you + feel that I forgot your name in this list, then please send me an email + and I'll add you. Last changed ============ - 11/07/2000 + 08/08/2000 diff --git a/TODO b/TODO index 03ee4a3..e782377 100644 --- a/TODO +++ b/TODO @@ -1 +1,3 @@ -- dump to palm compatible format (!) any help out there? +o mysql.pm und dbm.pm generate_search testen! +o Website anpassen +o Announcement on freshmeat. diff --git a/bin/CVS/Entries b/bin/CVS/Entries new file mode 100644 index 0000000..bee8630 --- /dev/null +++ b/bin/CVS/Entries @@ -0,0 +1,2 @@ +/note/1.3/Fri Jul 21 06:41:25 2000// +D diff --git a/bin/CVS/Repository b/bin/CVS/Repository new file mode 100644 index 0000000..b54a10e --- /dev/null +++ b/bin/CVS/Repository @@ -0,0 +1 @@ +NOTE/bin diff --git a/bin/CVS/Root b/bin/CVS/Root new file mode 100644 index 0000000..9c415c0 --- /dev/null +++ b/bin/CVS/Root @@ -0,0 +1 @@ +zarahg@cvs.htnews.sourceforge.net:/cvsroot/htnews diff --git a/bin/_note b/bin/_note new file mode 100755 index 0000000..4ea2ca6 --- /dev/null +++ b/bin/_note @@ -0,0 +1,1681 @@ +#!/usr/bin/perl +# $Id: note,v 1.2 2000/07/09 22:10:03 zarahg Exp $ +# +# +# note - console notes management with database and encryption support. +# Copyright (C) 1999-2000 Thomas Linden (see README for details!) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# - Thomas Linden +# +# latest version on: +# http://www.daemon.de/software.html +# ftp://www.0x49.org/pub/scip/note/ +# + +use strict; +#use Data::Dumper; +use Getopt::Long; + +# +# prototypes +# +sub usage; # print usage message for us thumb userz :-) +sub find_editor; # returns an external editor for use +sub output; # used by &list and &display +sub C; # print colourized +sub num_bereich; # returns array from "1-4" (1,2,3,4) +sub getdate; # return pretty formatted day +sub new; # crate new note +sub edit; # edit a note +sub del; # delete a note +sub display; # display one or more notes +sub list; # note-listing +sub help; # interactive help screen +sub import; # import from notedb-dump +sub display_tree; # show nice tree-view +sub tree; # build the tree +sub print_tree; # print the tree, contributed by Jens Heunemann . THX! + + +# +# globals +# +my ( + # + # commandline options + # + $opt_, $opt_i, $opt_r, $opt_e, $opt_d, + $opt_s, $opt_t, $opt_T, $opt_l, $opt_L, $opt_c, + $opt_D, $opt_I, $opt_o, $opt_h, $opt_n, $opt_v, + + # + # set from commandline (or interactive) + # + $number, $searchstring, $dump_file, $ImportType, $NewType, $Raw, + + # + # 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, + + # + # db specifics from .noterc + # + $db, $dbname, $dbhost, $dbuser, $dbpasswd, + $table, $fnum, $fnote, $fdate, $date, $dbdriver, $libpath, + + # + # processed colors + # + $BORDERC, $_BORDERC, $NOTEC, $NUMC, $_NUMC, $_NOTEC, $TIMEC, + $_TIMEC, $TOPICC, $_TOPICC, + + # + # config presets + # + $DEFAULTDBNAME, $USER, $PATH, $CONF, + + # + # internals + # + $TYPE, $mode, $NoteKey, $TempDir, + $version, $number, $CurTopic, $CurDepth, $WantTopic, + $sizeof, %TP, $TreeType, $ListType, $SetTitle, + @ArgTopics, $key, $typedef, @NumBlock, $has_nothing, + ); + + +# +# DEFAULTS, allows one to use note without a config +# don't change them, instead use the config file! +# +$maxlen = 30; +$timelen = 22; +$date = &getdate; +$USER = getlogin || getpwuid($<); +chomp $USER; +$HOME = $ENV{'HOME'}; +$CONF = $HOME . "/.noterc"; +$dbdriver = "binary"; +$libpath = "/usr/local/lib"; +$NOTEDB = $HOME . "/.notedb"; +$MAX_NOTE = 4096; +$MAX_TIME = 64; +$COLOR = "YES"; +$BORDER_COLOR = "BLACK"; +$NUM_COLOR = "blue"; +$NOTE_COLOR = "green"; +$TIME_COLOR = "black"; +$TOPIC_COLOR = "BLACK"; +$TOPIC = 1; +$TopicSep = '/'; +$version = "1.0.8"; +if($TOPIC) +{ + $CurDepth = 1; # the current depth inside the topic "directory" structure... +} +$USE_CRYPT = "NO"; +$TempDir = "/tmp"; + + + +# +# process command line args +# +if($ARGV[0] eq "") +{ + $mode = "new"; +} +elsif($#ARGV == 0 && $ARGV[0] eq "-") { + $mode = "new"; + $NewType = 1; # read from STDIN until EOF + shift; + undef $has_nothing; +} +else +{ + Getopt::Long::Configure( qw(no_ignore_case)); + GetOptions ( + "interactive|i!" => \$opt_i, # no arg + "config|c=s" => \$opt_c, # string, required + "raw|r!" => \$opt_r, # no arg + "edit|e=i" => \$opt_e, # integer, required + "delete|d=s" => \$opt_d, # integer, required + "search|s=s" => \$opt_s, # string, required + "tree|topic|t!" => \$opt_t, # no arg + "longtopic|T!" => \$opt_T, # no arg + "list|l:s" => \$opt_l, # string, optional + "longlist|L:s" => \$opt_L, # string, optional + "dump||Dump|D:s" => \$opt_D, # string, optional + "import|Import|I:s" => \$opt_I, # string, optional + "overwrite|o!" => \$opt_o, # no arg + "help|h|?!" => \$opt_h, # no arg + "version|v!" => \$opt_v # no arg + ); + $opt_n = shift; # after that @ARGV contains eventually + # a note-number + # $opt_ is a single dash, in case of existence! + # + # determine mode + # + if($opt_i) { + $mode = "interactive"; + } + elsif(defined $opt_l || defined $opt_L) { + $mode = "list"; + if(defined $opt_l) { + @ArgTopics = split /$TopicSep/, $opt_l; + } + else { + $ListType = "LONG"; + @ArgTopics = split /$TopicSep/, $opt_L; + } + $CurDepth += $#ArgTopics + 1 if($opt_l || $opt_L); + $CurTopic = $ArgTopics[$#ArgTopics]; # use the last element everytime... + } + elsif($opt_t || $opt_T) { + $mode = "tree"; + $TreeType = "LONG" if($opt_T); + } + elsif(defined $opt_s) { + $mode = "search"; + $searchstring = $opt_s; + } + elsif($opt_e) { + $mode = "edit"; + $number = $opt_e; + } + elsif($opt_d) { + $mode = "delete"; + $number = $opt_d; + } + elsif(defined $opt_D) { + $mode = "dump"; + if(!$opt_) { + if($opt_D ne "") { + $dump_file = $opt_D; + } + else { + $dump_file = "note.dump.$$"; + print "no dumpfile specified, using $dump_file.\n"; + } + } + else { + $dump_file = "-"; # use STDIN + } + } + elsif(defined $opt_I) { + $mode = "import"; + if(!$opt_) { + if($opt_I ne "") { + $dump_file = $opt_I; + } + else { + print "Import-error! No dump_file specified!\n"; + exit(1); + } + } + else { + $dump_file = "-"; + } + } + elsif($opt_v) { + print "This is note $version by Thomas Linden .\n"; + exit(0); + } + elsif($opt_h) { + &usage; + } + else { + if($opt_c && $mode eq "" && !$opt_n) { + $mode = "new"; + } + elsif($opt_c && $mode eq "") { + $mode = ""; # huh?! + } + else { + $has_nothing = 1; + } + } + ### determine generic options + if($opt_n =~ /^[\d+\-?\,*]+$/) { + # first arg is a digit! + if($mode eq "") { + $number = $opt_n; + $mode = "display"; + undef $has_nothing; + } + else { + print "mode <$mode> does not take a numerical argument!\n"; + exit(1); + } + } + elsif($opt_n ne "") { + print "Unknown option: $opt_n\n"; + &usage; + } + if($opt_r) { + $Raw = 1; + } + if($opt_o) { + $ImportType = "overwrite"; + if(!$opt_I) { + print "--overwrite is only suitable for use with --import!\n"; + exit(1); + } + } + ##### +} +if($has_nothing && $mode eq "") +{ + &usage; +} + + +# read the configfile. +$CONF = $opt_c if($opt_c); # if given by commandline, use this. +if(-e $CONF) +{ + &getconfig($CONF); +} +elsif($opt_c) { + # only wrong, if specified by commandline! else use default values! + print STDERR "Could not open \"$CONF\": file does not exist or permission denied!\n"; + exit(1); +} + + +# Always interactive? +if($ALWAYS_INT eq "YES" && $mode ne "dump" && $mode ne "import") +{ + $mode = "interactive"; +} + +# OK ... Long-Listing shall be default ... You wanted it!!! +if($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 and binary. +push @INC, $libpath; +if($dbdriver eq "binary") { + eval { + require NOTEDB::binary; + $db = new NOTEDB($dbdriver, $NOTEDB, $MAX_NOTE, $MAX_TIME, $dbdriver); + } +} +else { + eval { + require "NOTEDB/$dbdriver.pm"; + $db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd, $table, $fnum, $fnote, $fdate); + }; +} +if($@) { + print "Unsupported database backend: NOTEDB::$dbdriver!\n"; + print "The following error has occured:\n------------------------\n" . $@ . "\n------------------------\n"; + exit 1; +} + +# add the backend version to the note version: +$version .= " " . $db->version(); + +# calculate some constants... +$BORDERC = "<$BORDER_COLOR>"; +$_BORDERC = ""; +$NUMC = "<$NUM_COLOR>"; +$_NUMC = ""; +$NOTEC = "<$NOTE_COLOR>"; +$_NOTEC = ""; +$TIMEC = "<$TIME_COLOR>"; +$_TIMEC = ""; +$TOPICC = "<$TOPIC_COLOR>"; +$_TOPICC = ""; + +$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"; + } + if(!exists $ENV{'NOTE_PASSWD'}) { + print "password: "; + eval { + local($|) = 1; + local(*TTY); + open(TTY,"/dev/tty"); + system ("stty -echo ); + print STDERR "\r\n"; + system ("stty echo ; + } + } + else { + $key = $ENV{'NOTE_PASSWD'}; + } + chomp $key; + $db->use_crypt($key,$CRYPT_METHOD); + undef $key; + # verify correctness of passwd + my ($cnote, $cdate) = $db->get_single(1); + if($cdate ne "") { + if($cdate !~ /^\d+\.\d+?/) { + print "access denied.\n"; # decrypted $date is not a number! + exit(1); + } + } #else empty! +} +else { + $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); + } + } +} + +# main loop: ############### +if($mode eq "display") +{ + &display; +} +elsif($mode eq "search") +{ + &search; +} +elsif($mode eq "list") +{ + &list; +} +elsif($mode eq "tree") +{ + &display_tree; +} +elsif($mode eq "new") +{ + &new; +} +elsif($mode eq "delete") +{ + del; +} +elsif($mode eq "edit") +{ + &edit; +} +elsif($mode eq "dump") +{ + &dump; +} +elsif($mode eq "import") +{ + &import; +} +elsif($mode eq "interactive") +{ + &interactive; +} +else +{ + #undefined :-( +} + + +exit(0); +################## EOP ################ + + + +############################### DISPLAY ################################## +sub display +{ + my($N,$match,$note,$date,$num); + # display a certain note + print "\n"; + &num_bereich; # get @NumBlock from $numer + foreach $N (@NumBlock) + { + ($note, $date) = $db->get_single($N); + if($note) + { + if($Raw) { + print "$N\n$date\n$note\n\n"; + } + else { + output($N, $note, $date, "SINGLE"); + print "\n"; + } + $match = 1; + } + } + if(!$match) + { + print "no note with that number found!\n"; + } +} +############################### SEARCH ################################## +sub search +{ + my($n,$match,$note,$date,$num,%res); + if($searchstring eq "") + { + print "No searchstring specified!\n"; + } + else { + print "searching the database $dbname for \"$searchstring\"...\n\n"; + + %res = $db->get_search($searchstring); + + foreach $num (sort { $a <=> $b } keys %res) + { + output($num, $res{$num}->{'note'}, $res{$num}->{'date'}); + $match = 1; + } + if(!$match) + { + print "no matching note found!\n"; + } + print "\n"; + } +} + + +############################### LIST ################################## +sub list +{ + my(@topic,@RealTopic, $i,$t,$n,$num,@CurItem,$top,$in,%res); + if($mode ne "interactive" && !$Raw) + { + print "\nList of all existing notes:\n\n"; + } + else { + print "\n"; + } + + # list all available notes (number and firstline) + %res = $db->get_all(); + + if($TOPIC) + { + undef %TP; + } + + foreach $num (sort { $a <=> $b } keys %res) + { + $n = $res{$num}->{'note'}; + $t = $res{$num}->{'date'}; + if($TOPIC) + { + # this allows us to have multiple topics (subtopics!) + my ($firstline,$dummy) = split /\n/, $n, 2; + if($firstline =~ /^($TopicSep)/) + { + @topic = split(/$TopicSep/,$firstline); + } + else + { + @topic = (); + } + # looks like: "\topic\" + # collect a list of topics under the current topic + if($topic[$CurDepth-1] eq $CurTopic && $topic[$CurDepth] ne "") + { + if(exists $TP{$topic[$CurDepth]}) + { + $TP{$topic[$CurDepth]}++; + } + else + { + # only if the next item *is* a topic! + $TP{$topic[$CurDepth]} = 1 if(($CurDepth) <= $#topic); + } + } + elsif($topic[$CurDepth-1] eq $CurTopic || ($topic[$CurDepth] eq "" && $CurDepth ==1)) + { + # cut the topic off the note-text + if($n =~ /^($TopicSep)/) + { + $CurItem[$i]->{'note'} = $dummy; + } + else + { + $CurItem[$i]->{'note'} = $n; + } + # save for later output() call + $CurItem[$i]->{'num'} = $num; + $CurItem[$i]->{'time'} = $t; + $i++; + # use this note for building the $PATH! + if($RealTopic[0] eq "") + { + @RealTopic = @topic; + } + } + } + else + { + output($num, $n, $t); + } + } + if($TOPIC) + { + if($CurTopic ne "") + { + undef $PATH; + foreach (@RealTopic) + { + $PATH .= $_ . $TopicSep; + last if($_ eq $CurTopic); + } + } + else + { + $PATH = $TopicSep; + } + + # we are at top level, print a list of topics... + foreach $top (sort(keys %TP)) + { + output("-", " => ". $top . "$TopicSep ($TP{$top} notes)", + " Sub Topic "); + } + #print Dumper(@CurItem); + for($in=0;$in<$i;$in++) + { + output( $CurItem[$in]->{'num'}, + $CurItem[$in]->{'note'}, + $CurItem[$in]->{'time'} ); + } + } + + print "\n"; +} + +############################### NEW ################################## +sub new +{ + my($TEMP,$editor, $date, $note, $WARN, $c, $line, $num, @topic); + $date = &getdate; + if($ALWAYS_EDIT eq "YES") + { + $TEMP = &gettemp; + # let the user edit it... + $editor = &find_editor; + if($editor) + { + system "touch", $TEMP and die $!; + system "chattr", "+s", $TEMP; # ignore errors, since only on ext2 supported! + system $editor, $TEMP; + } + else + { + print "Could not find an editor to use!\n"; + exit(0); + } + # read it in ($note) + $note = ""; + open E, "<$TEMP" or $WARN = 1; + if($WARN) + { + print "...edit process interupted! No note has been saved.\n"; + undef $WARN; + return; + } + $c = 0; + while() + { + $note = $note . $_; + } + chomp $note; + close E; + # privacy! + unlink $TEMP; + } + else + { + $note = ""; + $line = ""; + # create a new note + if($NewType) + { + # be silent! read from STDIN until EOF. + while () { $note .= $_; } + } + else + { + print "enter the text of the note, end with .\n"; + do + { + $line = ; + $note = $note . $line; + } until $line eq ".\n"; + # remove the . ! + chop $note; + chop $note; + } + } + + # since we have not number, look for the next available: + $number = $db->get_nextnum(); + if($TOPIC && $CurTopic ne "") + { + @topic = split(/$TopicSep/,$note); + if($topic[1] eq "") + { + $note = $PATH . "\n$note"; + } + } + + + $db->set_new($number,$note,$date); + + # everything ok until here! + print "note stored. it has been assigned the number $number.\n\n"; +} + + +############################### DELETE ################################## +sub del +{ + my($i,@count, $setnum, $pos, $ERR); + # delete a note + &num_bereich; # get @NumBlock from $number + foreach $_ (@NumBlock) + { + $ERR = $db->set_del($_); + if($ERR) + { + print "no note with number $_ found!\n"; + } + else + { + print "note number $_ has been deleted.\n"; + } + } + # recount the notenumbers: + $db->set_recountnums(); + + @NumBlock = (); +} + +############################### EDIT ################################## +sub edit +{ + my($keeptime, $date, $editor, $TEMP, $note, $t, $num, $match); + # edit a note + $date = &getdate; + ($note, $keeptime) = $db->get_single($number); + if($keeptime eq "") + { + print "no note with that number found!\n\n"; + exit(0) if($mode ne "interactive"); + } + $TEMP = &gettemp; + open NOTE,">$TEMP" or die "Could not open $TEMP\n"; + select NOTE; + + system "chattr", "+s", $TEMP; # ignore errors, like in new() + + print $note; + close NOTE; + select STDOUT; + $editor = &find_editor; + if($editor) + { + system $editor, $TEMP; + } + else + { + print "Could not find an editor to use!\n"; + exit(0); + } + $note = ""; + open NOTE,"<$TEMP" or die "Could not open $TEMP\n"; + + while() + { + $note = $note . $_; + } + chomp $note; + close NOTE; + + unlink $TEMP || die $!; + + if($KEEP_TIMESTAMP eq "YES") + { + $t = $keeptime; + } + else + { + $t = $date; + } + + # we got it, now save to db + $db->set_edit($number, $note, $t); + + print "note number $number has been changed.\n"; +} + + +sub dump +{ + my(%res, $num, $DUMP); + # $dump_file + if($dump_file eq "-") { + $DUMP = *STDOUT; + } + else { + open (DUMPFILE, ">$dump_file") or die "could not open $dump_file\n"; + $DUMP = *DUMPFILE; + } + select $DUMP; + %res = $db->get_all(); + foreach $num (sort { $a <=> $b } keys %res) + { + print STDOUT "dumping note number $num to $dump_file\n" if($dump_file ne "-"); + print "Number: $num\n" + ."Timestamp: $res{$num}->{'date'}\n" + ."$res{$num}->{'note'}\n"; + } + print "\n"; + close(DUMP); + select STDOUT; +} + +sub import +{ + my($num, $start, $complete, $dummi, $note, $date, $time, $number, $stdin, $DUMP); + # open $dump_file and import it into the notedb + $stdin = 1 if($dump_file eq "-"); + if($stdin) { + $DUMP = *STDIN; + } + else { + 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; + 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); + $complete = 0; + $note = ""; + $date = ""; + ($dummi,$number) = split(/\s/,$_); + } + } + elsif($_ =~ /^Timestamp:\s\d+/ && $complete == 0) + { + ($dummi,$date,$time) = split(/\s/,$_); + $date = "$date $time"; + $complete = 1; + } + else + { + $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); + } +} + + + +sub interactive +{ + my($B, $BB, $menu, $char, @LastTopic, $Channel); + $Channel = $|; + # create menu: + $B = ""; + $BB = ""; + $menu = "[" . $B . "L" . $BB . "-List "; + if($TOPIC) { + $menu .= $B . "T" . $BB . "-Topics "; + } + $menu .= $B . "N" . $BB . "-New " + . $B . "D" . $BB . "-Delete " + . $B . "S" . $BB . "-Search " + . $B . "E" . $BB . "-Edit " + . $B . "?" . $BB . "-Help " + . $B . "Q" . $BB . "-Quit] "; # $CurTopic will be empty if $TOPIC is off! + # per default let's list all the stuff: + # Initially do a list command! + $ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : ""; + &list; + + for(;;) + { + $ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : ""; + undef $SetTitle; + if($CurDepth > 2) + { + print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . ">"; + } + else + { + print C $menu . $TOPICC . $CurTopic . $_TOPICC . ">"; + } + + # endless until user press "Q" or "q"! + $char = ; + #$char = $term->readline(''); + chomp $char; + if($char =~ /^\d+\s*[\di*?,*?\-*?]*$/) + { + $ListType = ""; #overrun + # display notes + $number = $char; + &display; + } + elsif($char =~ /^n$/i) + { + # create a new one + &new; + } + elsif($char =~ /^$/) + { + &list; + } + elsif($char =~ /^l$/) + { + $ListType = ""; + &list; + } + elsif($char =~ /^L$/) + { + $ListType = "LONG"; + &list; + undef $SetTitle; + } + elsif($char =~ /^h$/i || $char =~ /^\?/) + { + # zu dumm der Mensch ;-) + &help; + } + elsif($char =~ /^d\s+([\d*?,*?\-*?]*)$/i) + { + # delete one! + $number = $1; + &del; + } + elsif($char =~ /^d$/i) + { + # we have to ask her: + print "enter number(s) of note(s) you want to delete: "; + $char = ; + chomp $char; + $number = $char; + &del; + } + elsif($char =~ /^e\s+(\d+\-*\,*\d*)/i) + { + # edit one! + $number = $1; + &edit; + } + elsif($char =~ /^e$/i) + { + # we have to ask her: + print "enter number of the note you want to edit: "; + $char = ; + chomp $char; + $number = $char; + &edit; + } + elsif($char =~ /^s\s+/i) + { + # she want's to search + $searchstring = $'; + chomp $searchstring; + &search; + } + elsif($char =~ /^s$/i) + { + # we have to ask her: + print "enter the string you want to search for: "; + $char = ; + chomp $char; + $char =~ s/^\n//; + $searchstring = $char; + &search; + } + elsif($char =~ /^q$/i) + { + # schade!!! + $| = $Channel; + print "\n\ngood bye!\n"; + exit(0); + } + elsif($char =~ /^t$/) + { + $TreeType = ""; + &display_tree; + } + elsif($char =~ /^T$/) + { + $TreeType = "LONG"; + &display_tree; + $TreeType = ""; + } + elsif($char =~ /^\.\.$/ || $char =~ /^cd\s*\.\.$/) + { + $CurDepth-- if ($CurDepth > 1); + $CurTopic = $LastTopic[$CurDepth]; + &list; + } + elsif($char =~ /^l\s+(\w+)$/) + { + # list + $WantTopic = $1; + if(exists $TP{$WantTopic}) + { + my %SaveTP = %TP; + $LastTopic[$CurDepth] = $CurTopic; + $CurTopic = $1; + $CurDepth++; + + &list; + + $CurTopic = $LastTopic[$CurDepth]; + $CurDepth--; + %TP = %SaveTP; + } + else + { + print "\nunknown command!\n"; + } + } + else + { + # unknown + my $unchar = $char; + $unchar =~ s/^cd //; # you may use cd now! + if(exists $TP{$char} || exists $TP{$unchar}) + { + $char = $unchar if(exists $TP{$unchar}); + $LastTopic[$CurDepth] = $CurTopic; + $CurTopic = $char; + $CurDepth++; + &list; + } + else + { + print "\nunknown command!\n"; + } + undef $unchar; + } + } +} + + + +sub usage +{ +print qq~This is the program note $version by Thomas Linden (c) 1999-2000. +It comes with absolutely NO WARRANTY. It is distributed under the +terms of the GNU General Public License. Use it at your own risk :-) +Usage: note [ options ] [ number [,number...]] +Options: +-h --help displays this help screen +-v --version displays the version number +-c --config use another config file than the default \~/.noterc +-l --list [] lists all existing notes If no topic were specified, + it will display a list of all existing topics. +-L --longlist [] the same as -l but prints also the timestamp +-t --topic prints a list of all topics as a tree. +-T --longtopc prints the topic-tree with the notes under each topic +-s --search searches for trough the notes database +-e --edit edit note with +-d --delete delete note with +-D --Dump [ | -] dumps the notes to the textfile . if is simply + a "-" it will printed out to standard output. +-I --Import | - imports a previously dumped textfile into the + note-database. Data will be appended by default. + You can also specify a dash "note -I -" instead of a , + which causes note, silently to read in a dump from STDIN. +-o --overwrite only suitable for use with --Import. Overwrites an + existing notedb. +-r --raw raw mode, output will not be formatted. Works not in interactive + mode, only on cmd-line for list and display. +-i --interactive interactive mode +- if you run note only with one dash: "note -", then it will + read in a new note from STDIN until EOF, this makes it + possible to pipe text into a new note. + + o if you specify only a number (i.e. "note 4"), then the note with that + number will be displayed. + o you can specify more then one number for delete and display, for example: + "note -d 3,4" deletes #3 and #4. "note 5-7" displays #5, #6 and #7. + o if you run note without any parameter and if "AlwaysInteractive" in the config + set off, then note will create a new note and prompt you for new text. + o If it finds \~/.noterc, it will process it. Refer to the manpage for more + informations about the configuration. + o In interactive mode you can get help at any time by typing "?" or "h" at + the prompt. + o If encryption support is turned on, note will ask you for a passphrase every + time it runs. You can avoid this behavior by setting the environment-variable + \$NOTE_PASSWD. You will need this for example, if you call note from a script. +~; + #my ($package, $filename, $line) = caller; + #print "called from line $line\n"; + exit 1; +} + +sub find_editor { + return $PreferredEditor || $ENV{"VISUAL"} || $ENV{"EDITOR"} || "vim" || "vi" || "pico"; +} + +#/ + +sub format { + # make text bold/underlined/inverse using current $NOTEC + # s/\[([^]]*)\]/$param{$1}/g; + my($note) = @_; + if($FormatText) { + my $BN = uc($NOTEC); + my $_BN = uc($_NOTEC); + my $UN = $NOTEC; + $UN =~ s/<(.*)>/<$1_>/; + my $_UN = $UN; + $_UN =~ s/<(.*)>/<\/$1>/; + my $IN = $NOTEC; my $_IN = $_NOTEC; + $IN =~ s/<(.*)>/<$1I>/; + $_IN =~ s/<(.*)>/<$1I>/; + #$note =~ s/ (\*)(.+)(\*) / $BN$2$_BN /g; + #$note =~ s/ (_)(.+)(_) / $UN$2$_UN /g; + #$note =~ s/ (\/)(.+)(\/) / $IN$2$_IN /g; + $note =~ s/\*\*([^\*^\*]*)\*\*/$BN$1$_BN/g; + $note =~ s/__([^_^_]*)__/$UN$1$_UN/g; + $note =~ s/{{([^}^}]*)}}/$IN$1$_IN/g; + } + $note =~ s/(<\/.*>)/$1$NOTEC/g; + $note; +} + +sub output +{ + my($SSS, $LINE, $num, $note, $time, $TYPE, $L, $LONGSPC, $R, $PathLen, $SP, $title, $CUTSPACE, + $len, $diff, $Space, $nlen, $txtlen); + ($num, $note, $time, $TYPE) = @_; + $txtlen = ($ListType eq "LONG") ? $maxlen : $timelen + $maxlen; + + $note = &format($note); + + $SSS = "-" x ($maxlen + 31); + + $nlen = length("$num"); + $LINE = "$BORDERC $SSS $_BORDERC\n"; + $L = $BORDERC . "[" . $_BORDERC; + $LONGSPC = " " x (26 - $nlen); + $R = $BORDERC . "]" . $_BORDERC; + $PathLen = length($PATH); # will be ZERO, if not in TOPIC mode! + if($TYPE ne "SINGLE") + { + if(!$SetTitle) + { + $SP = ""; + # print only if it is the first line! + $SP = " " x ($maxlen - 2 - $PathLen); + if(!$Raw) { + # no title in raw-mode! + print C $LINE; + + print C "$L $NUMC#$_NUMC "; + if($ListType eq "LONG") + { + print C " $TIMEC" . "creation date$_TIMEC "; + } + else + { + print $LONGSPC; + } + if($TOPIC) + { + print C $TOPICC . "$PATH $_TOPICC$SP$R\n"; + } + else + { + print C $NOTEC . "note$_NOTEC$SP$R\n"; + } + + print C $LINE; + } + $SetTitle = 1; + } + $title = ""; + $CUTSPACE = " " x $txtlen; + $note =~ s/\n/$CUTSPACE/g; + $len = length($note); + if($len < ($txtlen - 2 - $nlen)) + { + $diff = $txtlen - $len; + $Space = " " x $diff; + if(!$Raw) { + if($num eq "-") + { + $title = $BORDERC . $TOPICC . "\"" . $note . "\"" . $_TOPICC . $Space . "$_BORDERC"; + } + else + { + $title = $BORDERC . $NOTEC . "\"" . $note . "\"" . $_NOTEC . $Space . "$_BORDERC"; + } + } + else { + $title = $note; + } + } + else + { + $title = substr($note,0,($txtlen - 2 - $nlen)); + if(!$Raw) { + $title = $BORDERC . $NOTEC . "\"" . $title . "...\"$_NOTEC$_BORDERC"; + } + } + if($Raw) { + print "$num "; + print "$time " if($ListType eq "LONG"); + if($title =~ /^ => (.*)$TopicSep (.*)$/) { + $title = "$1$TopicSep $2"; # seems to be a topic! + } + print "$title\n"; + } + else { + # $title should now look as: "A sample note " + print C "$L $NUMC$num$_NUMC $R"; + if($ListType eq "LONG") + { + print C "$L$TIMEC" . $time . " $_TIMEC$R"; + } + print C "$L $NOTEC" . $title . "$_NOTEC $R\n"; + print C $LINE; + } + } + else + { + # we will not reach this in raw-mode, therefore no decision here! + chomp $note; + $Space = " " x (($maxlen + $timelen) - 16); + print C $LINE; + print C "$L $NUMC$num$_NUMC $R$L$TIMEC$time$_TIMEC $Space$R\n"; + print C $LINE; + print C $NOTEC . $note . $_NOTEC . "\n"; + print C $LINE; + } + +} + + + +sub C +{ + my(%Color, $default, $S, $Col, $NC, $T); + # \033[1m%30s\033[0m + %Color = ( 'black' => '0;30', + 'red' => '0;31', + 'green' => '0;32', + 'yellow' => '0;33', + 'blue' => '0;34', + 'magenta' => '0;35', + 'cyan' => '0;36', + 'white' => '0;37', + 'B' => '1;30', + 'BLACK' => '1;30', + 'RED' => '1;31', + 'GREEN' => '1;32', + 'YELLOW' => '1;33', + 'BLUE' => '1;34', + 'MAGENTA' => '1;35', + 'CYAN' => '1;36', + 'WHITE' => '1;37', + 'black_' => '4;30', + 'red_' => '4;31', + 'green_' => '4;32', + 'yellow_' => '4;33', + 'blue_' => '4;34', + 'magenta_' => '4;35', + 'cyan_' => '4;36', + 'white_' => '4;37', + 'blackI' => '7;30', + 'redI' => '7;31', + 'greenI' => '7;32', + 'yellowI' => '7;33', + 'blueI' => '7;34', + 'magentaI' => '7;35', + 'cyanI' => '7;36', + 'whiteI' => '7;37' + ); + $default = "\033[0m"; + $S = $_[0]; + foreach $Col (%Color) + { + if ($S =~ /<$Col>/g) + { + if($COLOR ne "NO") + { + $NC = "\033[" . $Color{$Col} . "m"; + $S =~ s/<$Col>/$NC/g; + $S =~ s/<\/$Col>/$default/g; + } + else + { + $S =~ s/<$Col>//g; + $S =~ s/<\/$Col>//g; + } + } + } + return $S; +} + + + +sub num_bereich +{ + my($m,@LR,@Sorted_LR,$i); + # $number is the one we want to delete! + # But does it contain kommas? + @NumBlock = (); #reset + $m = 0; + if($number =~ /\,/) + { + # accept -d 3,4,7 + @NumBlock = split(/\,/,$number); + } + elsif($number =~ /^\d+\-\d+$/) + { + # accept -d 3-9 + @LR = split(/\-/,$number); + @Sorted_LR = (); + + if($LR[0] > $LR[1]) + { + @Sorted_LR = ($LR[1], $LR[0]); + } + elsif($LR[0] == $LR[1]) + { + # 0 and 1 are the same + @Sorted_LR = ($LR[0], $LR[1]); + } + else + { + @Sorted_LR = ($LR[0], $LR[1]); + } + + for($i=$Sorted_LR[0]; $i<=$Sorted_LR[1]; $i++) + { + # from 3-6 create @NumBlock (3,4,5,6) + $NumBlock[$m] = $i; + $m++; + } + } + else + { + @NumBlock = ($number); + } + +} + +sub getdate +{ + my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + $year += 1900; + $mon += 1; + $mon =~ s/^(\d)$/0$1/; + $hour =~ s/^(\d)$/0$1/; + $min =~ s/^(\d)$/0$1/; + $sec =~ s/^(\d)$/0$1/; + $mday =~ s/^(\d)$/0$1/; + return "$mday.$mon.$year $hour:$min:$sec"; +} + + +sub gettemp +{ + my($random, @range); + @range=('0'..'9','a'..'z','A'..'Z'); + srand(time||$$); + for (0..10) { + $random .= $range[rand(int($#range)+1)]; + } + my $tempfile = $TempDir . "/" . $USER . "." . $random; + if (-e $tempfile) { + # avoid race conditions! + unlink $tempfile; + } + return $tempfile; +} + + + +sub help +{ +my $B = ""; +my $BB = ""; +my($S, $L, $T, $Q, $H, $N, $D, $E); +$L = $B . "L" . $BB . $NOTEC; +$T = $B . "T" . $BB . $NOTEC; +$Q = $B . "Q" . $BB . $NOTEC; +$H = $B . "?" . $BB . $NOTEC; +$N = $B . "N" . $BB . $NOTEC; +$D = $B . "D" . $BB . $NOTEC; +$E = $B . "E" . $BB . $NOTEC; +$S = $B . "S" . $BB . $NOTEC; + +print C qq~$BORDERC +----------------------------------------------------------------------$_BORDERC $TOPICC +HELP for interactive note $version +$_TOPICC $NOTEC +The following commands are available: +$L List notes. L=long, with timestamp and l=short without timestamp. + You can also just hit for short list. + If you specify a subtopic, then list will display it's contents, + i.e.: "l mytopic" will dislpay notes under mytopic. +$N Create a new note. +$D Delete a note. You can either hit "d 1" or "d 1-4" or just hit "d". + If you don't specify a number, you will be asked for. +$S Search trough the notes database. Usage is similar to Delete, use + a string instead of a number to search for. +$E Edit a note. Usage is similar to Delete but you can only edit note + a time. +$H This help screen. +$Q Exit the program.~; +if($TOPIC) +{ +print C qq~ +$T print a list of all existing topics as a tree. T prints the tree + with all notes under each topic. + + You can change the actual topic by simply typing it's name or by using + the command "cd", i.e. "cd mytopic". You can create a new topic by creating + a new note, the first line must be the topic borderd by slashes, i.e.: + "/newtopic/". The slash is the default topic-sepearator, but you can over- + ride this in the config! If you type just ".." instead of a topic, you will + go one step back in your topic-structure. +~; +} +print C qq~ +$NOTEC +All commands except the List and Topic commands are case insensitive. $_NOTEC $BORDERC +----------------------------------------------------------------------$_BORDERC +~; +} + + +sub display_tree { + # displays a tree of all topics + my(%TREE, %res, $n, $t, $num, @nodes, $firstline, $text, $untext); + %res = $db->get_all(); + foreach $num (keys %res) + { + $n = $res{$num}->{'note'}; + $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); + } + else + { + @nodes = ();("$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_tree(\%{$TREE{''}},"") if(%TREE); + print C $BORDERC . $_BORDERC . "\n"; +} + + +sub tree { + my($num, $text, $LocalTree, $node, @nodes) = @_; + if(@nodes) { + if(! exists $LocalTree->{$node}->{$NoteKey}) { + $LocalTree->{$node}->{$NoteKey} = []; + } + &tree($num, $text, $LocalTree->{$node}, @nodes); + } + else { + if(length($text) > ($maxlen - 5)) { + $text = substr($text, 0, ($maxlen -5)); + } + $text = $text . " (" . $NUMC . "#" . $num . $_NUMC . $NOTEC . ")" . $_NOTEC if($text ne ""); + push @{$LocalTree->{$node}->{$NoteKey}}, $text; + } +} + + +sub print_tree { + # thanks to Jens for his hints and this sub! + my $hashref=shift; + my $prefix=shift; + my @notes=@{$hashref->{$NoteKey}}; + my @subnotes=sort grep { ! /^$NoteKey$/ } keys %$hashref; + if($TreeType eq "LONG") { + for my $note (@notes) { + if($note ne "") { + print C $BORDERC ;# . $prefix. "|\n"; + print C "$prefix+---<" . $NOTEC . $note . $BORDERC . ">" . $_NOTEC . "\n"; + } + } + } + for my $index (0..$#subnotes) { + print C $BORDERC . $prefix. "|\n"; + print C "$prefix+---[" . $TOPICC . $subnotes[$index] . $BORDERC . "]\n"; + &print_tree($hashref->{$subnotes[$index]},($index == $#subnotes?"$prefix ":"$prefix| ")); + } +} + + +sub getconfig +{ + my($configfile) = @_; + my ($home, $value, $option); + # checks are already done, so trust myself and just open it! + open CONFIG, "<$configfile" || die $!; + while() { + 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/); + $dbuser = $value if (/^DbUser/); + $dbpasswd = $value if (/^DbPasswd/); + $dbname = $value if (/^DbName/); + $table = $value if (/^DbTable/); + $fnum = $value if (/^FieldNumber/); + $fnote = $value if (/^FieldNote/); + $fdate = $value if (/^FieldDate/); + $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); + $COLOR = "YES" if (/^UseColors/ && $value == 1); + $COLOR = "NO" if (/^UseColors/ && $value == 0); + $TopicSep = $value if (/^TopicSeparator/); + $maxlen = $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/); + } + chomp $home; + $home =~ s/\/*$//; # cut eventually / at the end + $HOME = eval($home); + if($NOTEDB =~ /^(~\/)(.*)$/) { + $NOTEDB = "/home/" . $USER . "/" . $2; + } + $libpath =~ s/\/*$//; + + close CONFIG; +} + + + + +__END__ +# +# $Log: note,v $ +# 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 diff --git a/bin/note b/bin/note index de90eb6..9aa51ee 100755 --- a/bin/note +++ b/bin/note @@ -1,15 +1,15 @@ #!/usr/bin/perl -# $Id: note,v 1.2 2000/07/09 22:10:03 zarahg Exp $ -# +# $Id: note,v 1.3 2000/07/21 06:41:25 zarahg Exp $ +# # # note - console notes management with database and encryption support. # Copyright (C) 1999-2000 Thomas Linden (see README for details!) -# +# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -22,7 +22,7 @@ # - Thomas Linden # # latest version on: -# http://www.daemon.de/software.html +# http://www.daemon.de/software.html # ftp://www.0x49.org/pub/scip/note/ # @@ -32,73 +32,74 @@ use Getopt::Long; # # prototypes -# -sub usage; # print usage message for us thumb userz :-) -sub find_editor; # returns an external editor for use -sub output; # used by &list and &display -sub C; # print colourized -sub num_bereich; # returns array from "1-4" (1,2,3,4) -sub getdate; # return pretty formatted day -sub new; # crate new note -sub edit; # edit a note -sub del; # delete a note -sub display; # display one or more notes -sub list; # note-listing -sub help; # interactive help screen -sub import; # import from notedb-dump -sub display_tree; # show nice tree-view -sub tree; # build the tree -sub print_tree; # print the tree, contributed by Jens Heunemann . THX! +# +sub usage; # print usage message for us thumb userz :-) +sub find_editor; # returns an external editor for use +sub output; # used by &list and &display +sub C; # print colourized +sub num_bereich; # returns array from "1-4" (1,2,3,4) +sub getdate; # return pretty formatted day +sub new; # crate new note +sub edit; # edit a note +sub del; # delete a note +sub display; # display one or more notes +sub list; # note-listing +sub help; # interactive help screen +sub import; # import from notedb-dump +sub display_tree; # show nice tree-view +sub tree; # build the tree +sub print_tree; # print the tree, contributed by Jens Heunemann . THX! # # globals # my ( - # - # commandline options - # - $opt_, $opt_i, $opt_r, $opt_e, $opt_d, - $opt_s, $opt_t, $opt_T, $opt_l, $opt_L, $opt_c, - $opt_D, $opt_I, $opt_o, $opt_h, $opt_n, $opt_v, + # + # commandline options + # + $opt_, $opt_i, $opt_r, $opt_e, $opt_d, $opt_enc, + $opt_s, $opt_t, $opt_T, $opt_l, $opt_L, $opt_c, + $opt_D, $opt_I, $opt_o, $opt_h, $opt_n, $opt_v, - # - # set from commandline (or interactive) - # - $number, $searchstring, $dump_file, $ImportType, $NewType, $Raw, - - # - # 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, + # + # set from commandline (or interactive) + # + $number, $searchstring, $dump_file, $ImportType, $NewType, $Raw, - # - # db specifics from .noterc - # - $db, $dbname, $dbhost, $dbuser, $dbpasswd, - $table, $fnum, $fnote, $fdate, $date, $dbdriver, $libpath, + # + # 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, - # - # processed colors - # - $BORDERC, $_BORDERC, $NOTEC, $NUMC, $_NUMC, $_NOTEC, $TIMEC, - $_TIMEC, $TOPICC, $_TOPICC, - - # - # config presets - # - $DEFAULTDBNAME, $USER, $PATH, $CONF, - - # - # internals - # - $TYPE, $mode, $NoteKey, $TempDir, - $version, $number, $CurTopic, $CurDepth, $WantTopic, - $sizeof, %TP, $TreeType, $ListType, $SetTitle, - @ArgTopics, $key, $typedef, @NumBlock, $has_nothing, + # + # db specifics from .noterc + # + $db, $dbname, $dbhost, $dbuser, $dbpasswd, $encrypt_passwd, $clearstring, + $table, $fnum, $fnote, $fdate, $date, $dbdriver, $libpath, + + # + # processed colors + # + $BORDERC, $_BORDERC, $NOTEC, $NUMC, $_NUMC, $_NOTEC, $TIMEC, + $_TIMEC, $TOPICC, $_TOPICC, + + # + # config presets + # + $DEFAULTDBNAME, $USER, $PATH, $CONF, + + # + # internals + # + $TYPE, $mode, $NoteKey, $TempDir, + $version, $CurTopic, $CurDepth, $WantTopic, + $sizeof, %TP, $TreeType, $ListType, $SetTitle, + @ArgTopics, $key, $typedef, @NumBlock, $has_nothing, ); @@ -126,10 +127,9 @@ $TIME_COLOR = "black"; $TOPIC_COLOR = "BLACK"; $TOPIC = 1; $TopicSep = '/'; -$version = "1.0.8"; -if($TOPIC) -{ - $CurDepth = 1; # the current depth inside the topic "directory" structure... +$version = "1.0.9"; +if ($TOPIC) { + $CurDepth = 1; # the current depth inside the topic "directory" structure... } $USE_CRYPT = "NO"; $TempDir = "/tmp"; @@ -139,207 +139,213 @@ $TempDir = "/tmp"; # # process command line args # -if($ARGV[0] eq "") -{ - $mode = "new"; +if ($ARGV[0] eq "") { + $mode = "new"; } -elsif($#ARGV == 0 && $ARGV[0] eq "-") { - $mode = "new"; - $NewType = 1; # read from STDIN until EOF - shift; - undef $has_nothing; +elsif ($#ARGV == 0 && $ARGV[0] eq "-") { + $mode = "new"; + $NewType = 1; # read from STDIN until EOF + shift; + undef $has_nothing; } -else -{ - Getopt::Long::Configure( qw(no_ignore_case)); - GetOptions ( - "interactive|i!" => \$opt_i, # no arg - "config|c=s" => \$opt_c, # string, required - "raw|r!" => \$opt_r, # no arg - "edit|e=i" => \$opt_e, # integer, required - "delete|d=s" => \$opt_d, # integer, required - "search|s=s" => \$opt_s, # string, required - "tree|topic|t!" => \$opt_t, # no arg - "longtopic|T!" => \$opt_T, # no arg - "list|l:s" => \$opt_l, # string, optional - "longlist|L:s" => \$opt_L, # string, optional - "dump||Dump|D:s" => \$opt_D, # string, optional - "import|Import|I:s" => \$opt_I, # string, optional - "overwrite|o!" => \$opt_o, # no arg - "help|h|?!" => \$opt_h, # no arg - "version|v!" => \$opt_v # no arg - ); - $opt_n = shift; # after that @ARGV contains eventually - # a note-number - # $opt_ is a single dash, in case of existence! - # - # determine mode - # - if($opt_i) { - $mode = "interactive"; - } - elsif(defined $opt_l || defined $opt_L) { - $mode = "list"; - if(defined $opt_l) { - @ArgTopics = split /$TopicSep/, $opt_l; - } - else { - $ListType = "LONG"; - @ArgTopics = split /$TopicSep/, $opt_L; - } - $CurDepth += $#ArgTopics + 1 if($opt_l || $opt_L); - $CurTopic = $ArgTopics[$#ArgTopics]; # use the last element everytime... - } - elsif($opt_t || $opt_T) { - $mode = "tree"; - $TreeType = "LONG" if($opt_T); - } - elsif(defined $opt_s) { - $mode = "search"; - $searchstring = $opt_s; - } - elsif($opt_e) { - $mode = "edit"; - $number = $opt_e; - } - elsif($opt_d) { - $mode = "delete"; - $number = $opt_d; - } - elsif(defined $opt_D) { - $mode = "dump"; - if(!$opt_) { - if($opt_D ne "") { - $dump_file = $opt_D; - } - else { - $dump_file = "note.dump.$$"; - print "no dumpfile specified, using $dump_file.\n"; - } - } - else { - $dump_file = "-"; # use STDIN - } - } - elsif(defined $opt_I) { - $mode = "import"; - if(!$opt_) { - if($opt_I ne "") { - $dump_file = $opt_I; - } - else { - print "Import-error! No dump_file specified!\n"; - exit(1); - } - } - else { - $dump_file = "-"; - } - } - elsif($opt_v) { - print "This is note $version by Thomas Linden .\n"; - exit(0); - } - elsif($opt_h) { - &usage; - } - else { - if($opt_c && $mode eq "" && !$opt_n) { - $mode = "new"; - } - elsif($opt_c && $mode eq "") { - $mode = ""; # huh?! - } - else { - $has_nothing = 1; - } - } - ### determine generic options - if($opt_n =~ /^[\d+\-?\,*]+$/) { - # first arg is a digit! - if($mode eq "") { - $number = $opt_n; - $mode = "display"; - undef $has_nothing; - } - else { - print "mode <$mode> does not take a numerical argument!\n"; - exit(1); - } - } - elsif($opt_n ne "") { - print "Unknown option: $opt_n\n"; - &usage; - } - if($opt_r) { - $Raw = 1; - } - if($opt_o) { - $ImportType = "overwrite"; - if(!$opt_I) { - print "--overwrite is only suitable for use with --import!\n"; - exit(1); - } - } - ##### +else { + Getopt::Long::Configure( qw(no_ignore_case)); + GetOptions ( + "interactive|i!" => \$opt_i, # no arg + "config|c=s" => \$opt_c, # string, required + "raw|r!" => \$opt_r, # no arg + "edit|e=i" => \$opt_e, # integer, required + "delete|d=s" => \$opt_d, # integer, required + "search|s=s" => \$opt_s, # string, required + "tree|topic|t!" => \$opt_t, # no arg + "longtopic|T!" => \$opt_T, # no arg + "list|l:s" => \$opt_l, # string, optional + "longlist|L:s" => \$opt_L, # string, optional + "dump||Dump|D:s" => \$opt_D, # string, optional + "import|Import|I:s" => \$opt_I, # string, optional + "overwrite|o!" => \$opt_o, # no arg + "help|h|?!" => \$opt_h, # no arg + "version|v!" => \$opt_v, # no arg + "encrypt=s" => \$opt_enc, # string, required + ); + $opt_n = shift; # after that @ARGV contains eventually + # a note-number + # $opt_ is a single dash, in case of existence! + # + # determine mode + # + if ($opt_i) { + $mode = "interactive"; + } + elsif (defined $opt_l || defined $opt_L) { + $mode = "list"; + if (defined $opt_l) { + @ArgTopics = split /$TopicSep/, $opt_l; + } + else { + $ListType = "LONG"; + @ArgTopics = split /$TopicSep/, $opt_L; + } + $CurDepth += $#ArgTopics + 1 if($opt_l || $opt_L); + $CurTopic = $ArgTopics[$#ArgTopics]; # use the last element everytime... + } + elsif ($opt_t || $opt_T) { + $mode = "tree"; + $TreeType = "LONG" if($opt_T); + } + elsif (defined $opt_s) { + $mode = "search"; + $searchstring = $opt_s; + } + elsif ($opt_e) { + $mode = "edit"; + $number = $opt_e; + } + elsif ($opt_d) { + $mode = "delete"; + $number = $opt_d; + } + elsif ($opt_enc) { + $mode = "encrypt_passwd"; + $clearstring = $opt_enc; + } + elsif (defined $opt_D) { + $mode = "dump"; + if (!$opt_) { + if ($opt_D ne "") { + $dump_file = $opt_D; + } + else { + $dump_file = "note.dump.$$"; + print "no dumpfile specified, using $dump_file.\n"; + } + } + else { + $dump_file = "-"; # use STDIN + } + } + elsif (defined $opt_I) { + $mode = "import"; + if (!$opt_) { + if ($opt_I ne "") { + $dump_file = $opt_I; + } + else { + print "Import-error! No dump_file specified!\n"; + exit(1); + } + } + else { + $dump_file = "-"; + } + } + elsif ($opt_v) { + print "This is note $version by Thomas Linden .\n"; + exit(0); + } + elsif ($opt_h) { + &usage; + } + else { + if ($opt_c && $mode eq "" && !$opt_n) { + $mode = "new"; + } + elsif ($opt_c && $mode eq "") { + $mode = ""; # huh?! + } + else { + $has_nothing = 1; + } + } + ### determine generic options + if ($opt_n =~ /^[\d+\-?\,*]+$/) { + # first arg is a digit! + if ($mode eq "") { + $number = $opt_n; + $mode = "display"; + undef $has_nothing; + } + else { + print "mode <$mode> does not take a numerical argument!\n"; + exit(1); + } + } + elsif ($opt_n ne "") { + print "Unknown option: $opt_n\n"; + &usage; + } + if ($opt_r) { + $Raw = 1; + } + if ($opt_o) { + $ImportType = "overwrite"; + if (!$opt_I) { + print "--overwrite is only suitable for use with --import!\n"; + exit(1); + } + } + ##### } -if($has_nothing && $mode eq "") -{ - &usage; +if ($has_nothing && $mode eq "") { + &usage; } # read the configfile. -$CONF = $opt_c if($opt_c); # if given by commandline, use this. -if(-e $CONF) -{ - &getconfig($CONF); +$CONF = $opt_c if($opt_c); # if given by commandline, use this. +if (-e $CONF) { + &getconfig($CONF); } -elsif($opt_c) { - # only wrong, if specified by commandline! else use default values! - print STDERR "Could not open \"$CONF\": file does not exist or permission denied!\n"; - exit(1); +elsif ($opt_c) { + # only wrong, if specified by commandline! else use default values! + print STDERR "Could not open \"$CONF\": file does not exist or permission denied!\n"; + exit(1); } # Always interactive? -if($ALWAYS_INT eq "YES" && $mode ne "dump" && $mode ne "import") -{ - $mode = "interactive"; +if ($ALWAYS_INT eq "YES" && $mode ne "dump" && $mode ne "import") { + $mode = "interactive"; } # OK ... Long-Listing shall be default ... You wanted it!!! -if($DEFAULT_LIST eq "LONG") -{ - # takes only precedence in commandline mode - $ListType="LONG"; +if ($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 and binary. -push @INC, $libpath; -if($dbdriver eq "binary") { - eval { - require NOTEDB::binary; - $db = new NOTEDB($dbdriver, $NOTEDB, $MAX_NOTE, $MAX_TIME, $dbdriver); - } +# configured database backend. Currently supported: +# mysql, dbm and binary. +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.pm"; + #$db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd, $table, $fnum, $fnote, $fdate); + }; } else { - eval { - require "NOTEDB/$dbdriver.pm"; - $db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd, $table, $fnum, $fnote, $fdate); - }; + eval { + require "NOTEDB/$dbdriver.pm"; + $db = new NOTEDB($dbdriver, $dbname, $dbhost, $dbuser, $dbpasswd, $table, $fnum, $fnote, $fdate); + }; } -if($@) { - print "Unsupported database backend: NOTEDB::$dbdriver!\n"; - print "The following error has occured:\n------------------------\n" . $@ . "\n------------------------\n"; - exit 1; +if ($@) { + print "Unsupported database backend: NOTEDB::$dbdriver!\n"; + print "The following error has occured:\n------------------------\n" . $@ . "\n------------------------\n"; + exit 1; } -# add the backend version to the note version: -$version .= " " . $db->version(); # calculate some constants... $BORDERC = "<$BORDER_COLOR>"; @@ -359,97 +365,110 @@ $NoteKey = $TopicSep . "notes" . $TopicSep; 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"; - } - if(!exists $ENV{'NOTE_PASSWD'}) { - print "password: "; - eval { - local($|) = 1; - local(*TTY); - open(TTY,"/dev/tty"); - system ("stty -echo ); - print STDERR "\r\n"; - system ("stty echo ; - } - } - else { - $key = $ENV{'NOTE_PASSWD'}; - } - chomp $key; - $db->use_crypt($key,$CRYPT_METHOD); - undef $key; - # verify correctness of passwd - my ($cnote, $cdate) = $db->get_single(1); - if($cdate ne "") { - if($cdate !~ /^\d+\.\d+?/) { - print "access denied.\n"; # decrypted $date is not a number! - exit(1); - } - } #else empty! +if ($USE_CRYPT eq "YES" && $NOTEDB::crypt_supported == 1) { + if ($CRYPT_METHOD eq "") { + $CRYPT_METHOD = "Crypt::IDEA"; + } + if (!exists $ENV{'NOTE_PASSWD'}) { + print "password: "; + eval { + local($|) = 1; + local(*TTY); + open(TTY,"/dev/tty"); + system ("stty -echo ); + print STDERR "\r\n"; + system ("stty echo ; + } + } + else { + $key = $ENV{'NOTE_PASSWD'}; + } + chomp $key; + if ($dbdriver eq "mysql") { + eval { + require Crypt::CBC; + my $cipher = new Crypt::CBC($key, $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); + }; + die "Could not connect do db: $@!\n" if($@); + } + $db->use_crypt($key,$CRYPT_METHOD); + undef $key; + # verify correctness of passwd + my ($cnote, $cdate) = $db->get_single(1); + if ($cdate ne "") { + if ($cdate !~ /^\d+\.\d+?/) { + print "access denied.\n"; # decrypted $date is not a number! + exit(1); + } + } #else empty! } else { - $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); - } - } + $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) { + $db->use_cache(); +} + + +# add the backend version to the note version: +$version .= " " . $db->version(); + + # main loop: ############### -if($mode eq "display") -{ - &display; +if ($mode eq "display") { + &display; } -elsif($mode eq "search") -{ - &search; +elsif ($mode eq "search") { + &search; } -elsif($mode eq "list") -{ - &list; +elsif ($mode eq "list") { + &list; } -elsif($mode eq "tree") -{ - &display_tree; +elsif ($mode eq "tree") { + &display_tree; } -elsif($mode eq "new") -{ - &new; +elsif ($mode eq "new") { + &new; } -elsif($mode eq "delete") -{ - del; +elsif ($mode eq "delete") { + del; } -elsif($mode eq "edit") -{ - &edit; +elsif ($mode eq "edit") { + &edit; } -elsif($mode eq "dump") -{ - &dump; +elsif ($mode eq "dump") { + &dump; } -elsif($mode eq "import") -{ - &import; +elsif ($mode eq "import") { + &import; } -elsif($mode eq "interactive") -{ - &interactive; +elsif ($mode eq "interactive") { + &interactive; } -else -{ - #undefined :-( +elsif ($mode eq "encrypt_passwd") { + &encrypt_passwd; +} +else { + #undefined :-( } @@ -457,963 +476,872 @@ exit(0); ################## EOP ################ +############ encrypt a given password ############## +sub encrypt_passwd { + my($key, $crypt_string); + print "password: "; + eval { + local($|) = 1; + local(*TTY); + open(TTY,"/dev/tty"); + system ("stty -echo ); + print STDERR "\r\n"; + system ("stty echo ; + } + chomp $key; + eval { + require Crypt::CBC; + my $cipher = new Crypt::CBC($key, $CRYPT_METHOD); + $crypt_string = pack("u", $cipher->encrypt($clearstring)); + }; + if ($@) { + print "Something went wrong: $@\n"; + exit 1; + } else { + print "Encrypted password:\n$crypt_string\n"; + } +} + ############################### DISPLAY ################################## sub display -{ + { my($N,$match,$note,$date,$num); - # display a certain note - print "\n"; - &num_bereich; # get @NumBlock from $numer - foreach $N (@NumBlock) - { - ($note, $date) = $db->get_single($N); - if($note) - { - if($Raw) { - print "$N\n$date\n$note\n\n"; - } - else { - output($N, $note, $date, "SINGLE"); - print "\n"; - } - $match = 1; - } - } - if(!$match) - { - print "no note with that number found!\n"; - } -} -############################### SEARCH ################################## -sub search -{ - my($n,$match,$note,$date,$num,%res); - if($searchstring eq "") - { - print "No searchstring specified!\n"; + # display a certain note + print "\n"; + &num_bereich; # get @NumBlock from $numer + foreach $N (@NumBlock) { + ($note, $date) = $db->get_single($N); + if ($note) { + if ($Raw) { + print "$N\n$date\n$note\n\n"; } else { - print "searching the database $dbname for \"$searchstring\"...\n\n"; - - %res = $db->get_search($searchstring); - - foreach $num (sort { $a <=> $b } keys %res) - { - output($num, $res{$num}->{'note'}, $res{$num}->{'date'}); - $match = 1; - } - if(!$match) - { - print "no matching note found!\n"; - } - print "\n"; + output($N, $note, $date, "SINGLE"); + print "\n"; } -} + $match = 1; + } + } + if (!$match) { + print "no note with that number found!\n"; + } + } + +############################### SEARCH ################################## +sub search + { + my($n,$match,$note,$date,$num,%res); + if ($searchstring eq "") { + print "No searchstring specified!\n"; + } + else { + print "searching the database $dbname for \"$searchstring\"...\n\n"; + + %res = $db->get_search($searchstring); + + foreach $num (sort { $a <=> $b } keys %res) { + output($num, $res{$num}->{'note'}, $res{$num}->{'date'}, "search"); + $match = 1; + } + if (!$match) { + print "no matching note found!\n"; + } + print "\n"; + } + } ############################### LIST ################################## sub list -{ - my(@topic,@RealTopic, $i,$t,$n,$num,@CurItem,$top,$in,%res); - if($mode ne "interactive" && !$Raw) - { - print "\nList of all existing notes:\n\n"; - } - else { - print "\n"; + { + my(@topic,@RealTopic, $i,$t,$n,$num,@CurItem,$top,$in,%res); + if ($mode ne "interactive" && !$Raw) { + print "\nList of all existing notes:\n\n"; + } + else { + print "\n"; + } + + # list all available notes (number and firstline) + %res = $db->get_all(); + + if ($TOPIC) { + undef %TP; + } + + foreach $num (sort { $a <=> $b } keys %res) { + $n = $res{$num}->{'note'}; + $t = $res{$num}->{'date'}; + if ($TOPIC) { + # this allows us to have multiple topics (subtopics!) + my ($firstline,$dummy) = split /\n/, $n, 2; + if ($firstline =~ /^($TopicSep)/) { + @topic = split(/$TopicSep/,$firstline); } - - # list all available notes (number and firstline) - %res = $db->get_all(); - - if($TOPIC) - { - undef %TP; - } - - foreach $num (sort { $a <=> $b } keys %res) - { - $n = $res{$num}->{'note'}; - $t = $res{$num}->{'date'}; - if($TOPIC) - { - # this allows us to have multiple topics (subtopics!) - my ($firstline,$dummy) = split /\n/, $n, 2; - if($firstline =~ /^($TopicSep)/) - { - @topic = split(/$TopicSep/,$firstline); - } - else - { - @topic = (); - } - # looks like: "\topic\" - # collect a list of topics under the current topic - if($topic[$CurDepth-1] eq $CurTopic && $topic[$CurDepth] ne "") - { - if(exists $TP{$topic[$CurDepth]}) - { - $TP{$topic[$CurDepth]}++; - } - else - { - # only if the next item *is* a topic! - $TP{$topic[$CurDepth]} = 1 if(($CurDepth) <= $#topic); - } - } - elsif($topic[$CurDepth-1] eq $CurTopic || ($topic[$CurDepth] eq "" && $CurDepth ==1)) - { + else { + @topic = (); + } + # looks like: "\topic\" + # collect a list of topics under the current topic + if ($topic[$CurDepth-1] eq $CurTopic && $topic[$CurDepth] ne "") { + if (exists $TP{$topic[$CurDepth]}) { + $TP{$topic[$CurDepth]}++; + } + else { + # only if the next item *is* a topic! + $TP{$topic[$CurDepth]} = 1 if(($CurDepth) <= $#topic); + } + } + elsif ($topic[$CurDepth-1] eq $CurTopic || ($topic[$CurDepth] eq "" && $CurDepth ==1)) { # cut the topic off the note-text - if($n =~ /^($TopicSep)/) - { - $CurItem[$i]->{'note'} = $dummy; - } - else - { - $CurItem[$i]->{'note'} = $n; - } + if ($n =~ /^($TopicSep)/) { + $CurItem[$i]->{'note'} = $dummy; + } + else { + $CurItem[$i]->{'note'} = $n; + } # save for later output() call - $CurItem[$i]->{'num'} = $num; - $CurItem[$i]->{'time'} = $t; - $i++; + $CurItem[$i]->{'num'} = $num; + $CurItem[$i]->{'time'} = $t; + $i++; # use this note for building the $PATH! - if($RealTopic[0] eq "") - { - @RealTopic = @topic; - } - } - } - else - { - output($num, $n, $t); - } - } - if($TOPIC) - { - if($CurTopic ne "") - { - undef $PATH; - foreach (@RealTopic) - { - $PATH .= $_ . $TopicSep; - last if($_ eq $CurTopic); - } - } - else - { - $PATH = $TopicSep; - } + if ($RealTopic[0] eq "") { + @RealTopic = @topic; + } + } + } + else { + output($num, $n, $t); + } + } + if ($TOPIC) { + if ($CurTopic ne "") { + undef $PATH; + foreach (@RealTopic) { + $PATH .= $_ . $TopicSep; + last if($_ eq $CurTopic); + } + } + else { + $PATH = $TopicSep; + } - # we are at top level, print a list of topics... - foreach $top (sort(keys %TP)) - { - output("-", " => ". $top . "$TopicSep ($TP{$top} notes)", - " Sub Topic "); - } - #print Dumper(@CurItem); - for($in=0;$in<$i;$in++) - { - output( $CurItem[$in]->{'num'}, - $CurItem[$in]->{'note'}, - $CurItem[$in]->{'time'} ); - } - } - - print "\n"; -} + # we are at top level, print a list of topics... + foreach $top (sort(keys %TP)) { + output("-", " => ". $top . "$TopicSep ($TP{$top} notes)", + " Sub Topic "); + } + #print Dumper(@CurItem); + for ($in=0;$in<$i;$in++) { + output( $CurItem[$in]->{'num'}, + $CurItem[$in]->{'note'}, + $CurItem[$in]->{'time'} ); + } + } + + print "\n"; + } ############################### NEW ################################## sub new -{ + { my($TEMP,$editor, $date, $note, $WARN, $c, $line, $num, @topic); - $date = &getdate; - if($ALWAYS_EDIT eq "YES") - { - $TEMP = &gettemp; - # let the user edit it... - $editor = &find_editor; - if($editor) - { - system "touch", $TEMP && die $!; - system "chattr", "+s", $TEMP; # ignore errors, since only on ext2 supported! - system $editor, $TEMP; - } - else - { - print "Could not find an editor to use!\n"; - exit(0); - } - # read it in ($note) - $note = ""; - open E, "<$TEMP" or $WARN = 1; - if($WARN) - { - print "...edit process interupted! No note has been saved.\n"; - undef $WARN; - return; - } - $c = 0; - while() - { - $note = $note . $_; - } - chomp $note; - close E; - # privacy! - unlink $TEMP; + $date = &getdate; + if ($ALWAYS_EDIT eq "YES") { + $TEMP = &gettemp; + # let the user edit it... + $editor = &find_editor; + if ($editor) { + # create the temp file + open NEW, "> $TEMP" or die $!; + close NEW; + system "chattr", "+s", $TEMP; # ignore errors, since only on ext2 supported! + system $editor, $TEMP; + } + else { + print "Could not find an editor to use!\n"; + exit(0); + } + # read it in ($note) + $note = ""; + open E, "<$TEMP" or $WARN = 1; + if ($WARN) { + print "...edit process interupted! No note has been saved.\n"; + undef $WARN; + return; + } + $c = 0; + while () { + $note = $note . $_; + } + chomp $note; + close E; + # privacy! + unlink $TEMP; + } + else { + $note = ""; + $line = ""; + # create a new note + if ($NewType) { + # be silent! read from STDIN until EOF. + while () { + $note .= $_; } - else - { - $note = ""; - $line = ""; - # create a new note - if($NewType) - { - # be silent! read from STDIN until EOF. - while () { $note .= $_; } - } - else - { - print "enter the text of the note, end with .\n"; - do - { - $line = ; - $note = $note . $line; - } until $line eq ".\n"; - # remove the . ! - chop $note; - chop $note; - } - } - - # since we have not number, look for the next available: - $number = $db->get_nextnum(); - if($TOPIC && $CurTopic ne "") - { - @topic = split(/$TopicSep/,$note); - if($topic[1] eq "") - { - $note = $PATH . "\n$note"; - } - } + } + else { + print "enter the text of the note, end with .\n"; + do + { + $line = ; + $note = $note . $line; + } until $line eq ".\n"; + # remove the . ! + chop $note; + chop $note; + } + } + + # since we have not number, look for the next available: + $number = $db->get_nextnum(); + if ($TOPIC && $CurTopic ne "") { + @topic = split(/$TopicSep/,$note); + if ($topic[1] eq "") { + $note = $PATH . "\n$note"; + } + } - $db->set_new($number,$note,$date); + $db->set_new($number,$note,$date); - # everything ok until here! - print "note stored. it has been assigned the number $number.\n\n"; -} + # everything ok until here! + print "note stored. it has been assigned the number $number.\n\n"; + } ############################### DELETE ################################## sub del -{ - my($i,@count, $setnum, $pos, $ERR); - # delete a note - &num_bereich; # get @NumBlock from $number - foreach $_ (@NumBlock) - { - $ERR = $db->set_del($_); - if($ERR) - { - print "no note with number $_ found!\n"; - } - else - { - print "note number $_ has been deleted.\n"; - } - } - # recount the notenumbers: - $db->set_recountnums(); + { + my($i,@count, $setnum, $pos, $ERR); + # delete a note + &num_bereich; # get @NumBlock from $number + foreach $_ (@NumBlock) { + $ERR = $db->set_del($_); + if ($ERR) { + print "no note with number $_ found!\n"; + } + else { + print "note number $_ has been deleted.\n"; + } + } + # recount the notenumbers: + $db->set_recountnums(); - @NumBlock = (); -} + @NumBlock = (); + } ############################### EDIT ################################## sub edit -{ + { my($keeptime, $date, $editor, $TEMP, $note, $t, $num, $match); - # edit a note - $date = &getdate; - ($note, $keeptime) = $db->get_single($number); - if($keeptime eq "") - { - print "no note with that number found!\n\n"; - exit(0) if($mode ne "interactive"); - } - $TEMP = &gettemp; - open NOTE,">$TEMP" or die "Could not open $TEMP\n"; - select NOTE; - - system "chattr", "+s", $TEMP; # ignore errors, like in new() - - print $note; - close NOTE; - select STDOUT; - $editor = &find_editor; - if($editor) - { - system $editor, $TEMP; - } - else - { - print "Could not find an editor to use!\n"; - exit(0); - } - $note = ""; - open NOTE,"<$TEMP" or die "Could not open $TEMP\n"; - - while() - { - $note = $note . $_; - } - chomp $note; - close NOTE; + # edit a note + $date = &getdate; + ($note, $keeptime) = $db->get_single($number); + if ($keeptime eq "") { + print "no note with that number found!\n\n"; + exit(0) if($mode ne "interactive"); + } + $TEMP = &gettemp; + open NOTE,">$TEMP" or die "Could not open $TEMP\n"; + select NOTE; - unlink $TEMP || die $!; + system "chattr", "+s", $TEMP; # ignore errors, like in new() - if($KEEP_TIMESTAMP eq "YES") - { - $t = $keeptime; - } - else - { - $t = $date; - } - - # we got it, now save to db - $db->set_edit($number, $note, $t); + print $note; + close NOTE; + select STDOUT; + $editor = &find_editor; + if ($editor) { + system $editor, $TEMP; + } + else { + print "Could not find an editor to use!\n"; + exit(0); + } + $note = ""; + open NOTE,"<$TEMP" or die "Could not open $TEMP\n"; - print "note number $number has been changed.\n"; -} + while () { + $note = $note . $_; + } + chomp $note; + close NOTE; + + unlink $TEMP || die $!; + + if ($KEEP_TIMESTAMP eq "YES") { + $t = $keeptime; + } + else { + $t = $date; + } + # we got it, now save to db + $db->set_edit($number, $note, $t); + + print "note number $number has been changed.\n"; + } sub dump -{ + { my(%res, $num, $DUMP); - # $dump_file - if($dump_file eq "-") { - $DUMP = *STDOUT; - } - else { - open (DUMPFILE, ">$dump_file") or die "could not open $dump_file\n"; - $DUMP = *DUMPFILE; - } - select $DUMP; - %res = $db->get_all(); - foreach $num (sort { $a <=> $b } keys %res) - { - print STDOUT "dumping note number $num to $dump_file\n" if($dump_file ne "-"); - print "Number: $num\n" - ."Timestamp: $res{$num}->{'date'}\n" - ."$res{$num}->{'note'}\n"; - } - print "\n"; - close(DUMP); - select STDOUT; -} + # $dump_file + if ($dump_file eq "-") { + $DUMP = *STDOUT; + } + else { + open (DUMPFILE, ">$dump_file") or die "could not open $dump_file\n"; + $DUMP = *DUMPFILE; + } + select $DUMP; + %res = $db->get_all(); + foreach $num (sort { $a <=> $b } keys %res) { + print STDOUT "dumping note number $num to $dump_file\n" if($dump_file ne "-"); + print "Number: $num\n" + ."Timestamp: $res{$num}->{'date'}\n" + ."$res{$num}->{'note'}\n"; + } + print "\n"; + close(DUMPFILE); + select STDOUT; + } sub import -{ + { my($num, $start, $complete, $dummi, $note, $date, $time, $number, $stdin, $DUMP); - # open $dump_file and import it into the notedb - $stdin = 1 if($dump_file eq "-"); - if($stdin) { - $DUMP = *STDIN; + # open $dump_file and import it into the notedb + $stdin = 1 if($dump_file eq "-"); + if ($stdin) { + $DUMP = *STDIN; + } + else { + 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; + while (<$DUMP>) { + chomp $_; + if ($_ =~ /^Number:\s\d+/) { + if ($start == 0) { + # we have no previous record + ($dummi,$number) = split(/\s/,$_); + $start = 1; } else { - open (DUMPFILE, "<$dump_file") or die "could not open $dump_file\n"; - $DUMP = *DUMPFILE; + # 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); + $complete = 0; + $note = ""; + $date = ""; + ($dummi,$number) = split(/\s/,$_); } - $db->set_del_all() if($ImportType ne ""); - $complete=0; - $start = 0; - 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); - $complete = 0; - $note = ""; - $date = ""; - ($dummi,$number) = split(/\s/,$_); - } - } - elsif($_ =~ /^Timestamp:\s\d+/ && $complete == 0) - { - ($dummi,$date,$time) = split(/\s/,$_); - $date = "$date $time"; - $complete = 1; - } - else - { - $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); - } -} + } + elsif ($_ =~ /^Timestamp:\s\d+/ && $complete == 0) { + ($dummi,$date,$time) = split(/\s/,$_); + $date = "$date $time"; + $complete = 1; + } + else { + $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); + } + } sub interactive -{ - my($B, $BB, $menu, $char, @LastTopic, $Channel); - $Channel = $|; - # create menu: - $B = ""; - $BB = ""; - $menu = "[" . $B . "L" . $BB . "-List "; - if($TOPIC) { - $menu .= $B . "T" . $BB . "-Topics "; - } - $menu .= $B . "N" . $BB . "-New " - . $B . "D" . $BB . "-Delete " - . $B . "S" . $BB . "-Search " - . $B . "E" . $BB . "-Edit " - . $B . "?" . $BB . "-Help " - . $B . "Q" . $BB . "-Quit] "; # $CurTopic will be empty if $TOPIC is off! - # per default let's list all the stuff: - # Initially do a list command! - $ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : ""; - &list; - - for(;;) - { - $ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : ""; - undef $SetTitle; - if($CurDepth > 2) - { - print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . ">"; - } - else - { - print C $menu . $TOPICC . $CurTopic . $_TOPICC . ">"; - } - - # endless until user press "Q" or "q"! - $char = ; - #$char = $term->readline(''); - chomp $char; - if($char =~ /^\d+\s*[\di*?,*?\-*?]*$/) - { - $ListType = ""; #overrun - # display notes - $number = $char; - &display; - } - elsif($char =~ /^n$/i) - { - # create a new one - &new; - } - elsif($char =~ /^$/) - { - &list; - } - elsif($char =~ /^l$/) - { - $ListType = ""; - &list; - } - elsif($char =~ /^L$/) - { - $ListType = "LONG"; - &list; - undef $SetTitle; - } - elsif($char =~ /^h$/i || $char =~ /^\?/) - { - # zu dumm der Mensch ;-) - &help; - } - elsif($char =~ /^d\s+([\d*?,*?\-*?]*)$/i) - { - # delete one! - $number = $1; - &del; - } - elsif($char =~ /^d$/i) - { - # we have to ask her: - print "enter number(s) of note(s) you want to delete: "; - $char = ; - chomp $char; - $number = $char; - &del; - } - elsif($char =~ /^e\s+(\d+\-*\,*\d*)/i) - { - # edit one! - $number = $1; - &edit; - } - elsif($char =~ /^e$/i) - { - # we have to ask her: - print "enter number of the note you want to edit: "; - $char = ; - chomp $char; - $number = $char; - &edit; - } - elsif($char =~ /^s\s+/i) - { - # she want's to search - $searchstring = $'; - chomp $searchstring; - &search; - } - elsif($char =~ /^s$/i) - { - # we have to ask her: - print "enter the string you want to search for: "; - $char = ; - chomp $char; - $char =~ s/^\n//; - $searchstring = $char; - &search; - } - elsif($char =~ /^q$/i) - { - # schade!!! - $| = $Channel; - print "\n\ngood bye!\n"; - exit(0); - } - elsif($char =~ /^t$/) - { - $TreeType = ""; - &display_tree; - } - elsif($char =~ /^T$/) - { - $TreeType = "LONG"; - &display_tree; - $TreeType = ""; - } - elsif($char =~ /^\.\.$/ || $char =~ /^cd\s*\.\.$/) - { - $CurDepth-- if ($CurDepth > 1); - $CurTopic = $LastTopic[$CurDepth]; - &list; - } - elsif($char =~ /^l\s+(\w+)$/) - { - # list - $WantTopic = $1; - if(exists $TP{$WantTopic}) - { - my %SaveTP = %TP; - $LastTopic[$CurDepth] = $CurTopic; - $CurTopic = $1; - $CurDepth++; - - &list; - - $CurTopic = $LastTopic[$CurDepth]; - $CurDepth--; - %TP = %SaveTP; - } - else - { - print "\nunknown command!\n"; - } - } - else - { - # unknown - my $unchar = $char; - $unchar =~ s/^cd //; # you may use cd now! - if(exists $TP{$char} || exists $TP{$unchar}) - { - $char = $unchar if(exists $TP{$unchar}); - $LastTopic[$CurDepth] = $CurTopic; - $CurTopic = $char; - $CurDepth++; - &list; - } - else - { - print "\nunknown command!\n"; - } - undef $unchar; - } - } -} + { + my($B, $BB, $menu, $char, @LastTopic, $Channel); + $Channel = $|; + # create menu: + $B = ""; + $BB = ""; + $menu = "[" . $B . "L" . $BB . "-List "; + if ($TOPIC) { + $menu .= $B . "T" . $BB . "-Topics "; + } + $menu .= $B . "N" . $BB . "-New " + . $B . "D" . $BB . "-Delete " + . $B . "S" . $BB . "-Search " + . $B . "E" . $BB . "-Edit " + . $B . "?" . $BB . "-Help " + . $B . "Q" . $BB . "-Quit] "; # $CurTopic will be empty if $TOPIC is off! + # per default let's list all the stuff: + # Initially do a list command! + $ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : ""; + &list; + for (;;) { + $ListType = ($DEFAULT_LIST eq "LONG") ? "LONG" : ""; + undef $SetTitle; + if ($CurDepth > 2) { + print C $menu . $TOPICC . "../" . $CurTopic . $_TOPICC . ">"; + } + else { + print C $menu . $TOPICC . $CurTopic . $_TOPICC . ">"; + } + # endless until user press "Q" or "q"! + $char = ; + #$char = $term->readline(''); + chomp $char; + if ($char =~ /^\d+\s*[\di*?,*?\-*?]*$/) { + $ListType = ""; #overrun + # display notes + $number = $char; + &display; + } + elsif ($char =~ /^n$/i) { + # create a new one + &new; + } + elsif ($char =~ /^$/) { + &list; + } + elsif ($char =~ /^l$/) { + $ListType = ""; + &list; + } + elsif ($char =~ /^L$/) { + $ListType = "LONG"; + &list; + undef $SetTitle; + } + elsif ($char =~ /^h$/i || $char =~ /^\?/) { + # zu dumm der Mensch ;-) + &help; + } + elsif ($char =~ /^d\s+([\d*?,*?\-*?]*)$/i) { + # delete one! + $number = $1; + &del; + } + elsif ($char =~ /^d$/i) { + # we have to ask her: + print "enter number(s) of note(s) you want to delete: "; + $char = ; + chomp $char; + $number = $char; + &del; + } + elsif ($char =~ /^e\s+(\d+\-*\,*\d*)/i) { + # edit one! + $number = $1; + &edit; + } + elsif ($char =~ /^e$/i) { + # we have to ask her: + print "enter number of the note you want to edit: "; + $char = ; + chomp $char; + $number = $char; + &edit; + } + elsif ($char =~ /^s\s+/i) { + # she want's to search + $searchstring = $'; + chomp $searchstring; + &search; + } + elsif ($char =~ /^s$/i) { + # we have to ask her: + print "enter the string you want to search for: "; + $char = ; + chomp $char; + $char =~ s/^\n//; + $searchstring = $char; + &search; + } + elsif ($char =~ /^q$/i) { + # schade!!! + $| = $Channel; + print "\n\ngood bye!\n"; + exit(0); + } + elsif ($char =~ /^t$/) { + $TreeType = ""; + &display_tree; + } + elsif ($char =~ /^T$/) { + $TreeType = "LONG"; + &display_tree; + $TreeType = ""; + } + elsif ($char =~ /^\.\.$/ || $char =~ /^cd\s*\.\.$/) { + $CurDepth-- if ($CurDepth > 1); + $CurTopic = $LastTopic[$CurDepth]; + &list; + } + elsif ($char =~ /^l\s+(\w+)$/) { + # list + $WantTopic = $1; + if (exists $TP{$WantTopic}) { + my %SaveTP = %TP; + $LastTopic[$CurDepth] = $CurTopic; + $CurTopic = $1; + $CurDepth++; + &list; + $CurTopic = $LastTopic[$CurDepth]; + $CurDepth--; + %TP = %SaveTP; + } + else { + print "\nunknown command!\n"; + } + } + else { + # unknown + my $unchar = $char; + $unchar =~ s/^cd //; # you may use cd now! + if ($unchar =~ /^\d+?$/ && $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); + } + else { + @topic = (); + } + if (@topic) { + # only jump, if, and only if there were at least one topic! + push @LastTopic, "", @topic; + $CurDepth = $#topic + 1; + $CurTopic = pop @topic; + } + &list; + } + elsif ($unchar eq $TopicSep) { + # cd / + $CurDepth = 1; + $CurTopic = ""; + &list; + } + elsif (exists $TP{$char} || exists $TP{$unchar}) { + $char = $unchar if(exists $TP{$unchar}); + $LastTopic[$CurDepth] = $CurTopic; + $CurTopic = $char; + $CurDepth++; + &list; + } + else { + print "\nunknown command!\n"; + } + undef $unchar; + } + } + } sub usage -{ -print qq~This is the program note $version by Thomas Linden (c) 1999-2000. + { + print qq~This is the program note $version by Thomas Linden (c) 1999-2000. It comes with absolutely NO WARRANTY. It is distributed under the terms of the GNU General Public License. Use it at your own risk :-) -Usage: note [ options ] [ number [,number...]] -Options: --h --help displays this help screen --v --version displays the version number --c --config use another config file than the default \~/.noterc --l --list [] lists all existing notes If no topic were specified, - it will display a list of all existing topics. --L --longlist [] the same as -l but prints also the timestamp --t --topic prints a list of all topics as a tree. --T --longtopc prints the topic-tree with the notes under each topic --s --search searches for trough the notes database --e --edit edit note with --d --delete delete note with --D --Dump [ | -] dumps the notes to the textfile . if is simply - a "-" it will printed out to standard output. --I --Import | - imports a previously dumped textfile into the - note-database. Data will be appended by default. - You can also specify a dash "note -I -" instead of a , - which causes note, silently to read in a dump from STDIN. --o --overwrite only suitable for use with --Import. Overwrites an - existing notedb. --r --raw raw mode, output will not be formatted. Works not in interactive - mode, only on cmd-line for list and display. --i --interactive interactive mode -- if you run note only with one dash: "note -", then it will - read in a new note from STDIN until EOF, this makes it - possible to pipe text into a new note. - o if you specify only a number (i.e. "note 4"), then the note with that - number will be displayed. - o you can specify more then one number for delete and display, for example: - "note -d 3,4" deletes #3 and #4. "note 5-7" displays #5, #6 and #7. - o if you run note without any parameter and if "AlwaysInteractive" in the config - set off, then note will create a new note and prompt you for new text. - o If it finds \~/.noterc, it will process it. Refer to the manpage for more - informations about the configuration. - o In interactive mode you can get help at any time by typing "?" or "h" at - the prompt. - o If encryption support is turned on, note will ask you for a passphrase every - time it runs. You can avoid this behavior by setting the environment-variable - \$NOTE_PASSWD. You will need this for example, if you call note from a script. +Usage: note [ options ] [ number [,number...]] +Read the note(1) manpage for more details. ~; - #my ($package, $filename, $line) = caller; - #print "called from line $line\n"; - exit 1; -} + exit 1; + } sub find_editor { - return $PreferredEditor || $ENV{"VISUAL"} || $ENV{"EDITOR"} || "vim" || "vi" || "pico"; + return $PreferredEditor || $ENV{"VISUAL"} || $ENV{"EDITOR"} || "vim" || "vi" || "pico"; } #/ sub format { - # make text bold/underlined/inverse using current $NOTEC - # s/\[([^]]*)\]/$param{$1}/g; - my($note) = @_; - if($FormatText) { - my $BN = uc($NOTEC); - my $_BN = uc($_NOTEC); - my $UN = $NOTEC; - $UN =~ s/<(.*)>/<$1_>/; - my $_UN = $UN; - $_UN =~ s/<(.*)>/<\/$1>/; - my $IN = $NOTEC; my $_IN = $_NOTEC; - $IN =~ s/<(.*)>/<$1I>/; - $_IN =~ s/<(.*)>/<$1I>/; - #$note =~ s/ (\*)(.+)(\*) / $BN$2$_BN /g; - #$note =~ s/ (_)(.+)(_) / $UN$2$_UN /g; - #$note =~ s/ (\/)(.+)(\/) / $IN$2$_IN /g; - $note =~ s/\*\*([^\*^\*]*)\*\*/$BN$1$_BN/g; - $note =~ s/__([^_^_]*)__/$UN$1$_UN/g; - $note =~ s/{{([^}^}]*)}}/$IN$1$_IN/g; - } - $note =~ s/(<\/.*>)/$1$NOTEC/g; - $note; + # make text bold/underlined/inverse using current $NOTEC + my($note) = @_; + if ($FormatText) { + my $BN = uc($NOTEC); + my $_BN = uc($_NOTEC); + my $UN = $NOTEC; + $UN =~ s/<(.*)>/<$1_>/; + my $_UN = $UN; + $_UN =~ s/<(.*)>/<\/$1>/; + my $IN = $NOTEC; my $_IN = $_NOTEC; + $IN =~ s/<(.*)>/<$1I>/; + $_IN =~ s/<(.*)>/<$1I>/; + $note =~ s/\*\*([^\*^\*]*)\*\*/$BN$1$_BN/g; + $note =~ s/__([^_^_]*)__/$UN$1$_UN/g; + $note =~ s/{{([^}^}]*)}}/$IN$1$_IN/g; + } + $note =~ s/(<\/.*>)/$1$NOTEC/g; + $note; } sub output -{ - my($SSS, $LINE, $num, $note, $time, $TYPE, $L, $LONGSPC, $R, $PathLen, $SP, $title, $CUTSPACE, - $len, $diff, $Space, $nlen, $txtlen); - ($num, $note, $time, $TYPE) = @_; - $txtlen = ($ListType eq "LONG") ? $maxlen : $timelen + $maxlen; - - $note = &format($note); + { + my($SSS, $LINE, $num, $note, $time, $TYPE, $L, $LONGSPC, $R, $PathLen, $SP, $title, $CUTSPACE, + $len, $diff, $Space, $nlen, $txtlen); + ($num, $note, $time, $TYPE) = @_; + $txtlen = ($ListType eq "LONG") ? $maxlen : $timelen + $maxlen; + $note = &format($note); - $SSS = "-" x ($maxlen + 31); - - $nlen = length("$num"); - $LINE = "$BORDERC $SSS $_BORDERC\n"; - $L = $BORDERC . "[" . $_BORDERC; - $LONGSPC = " " x (26 - $nlen); - $R = $BORDERC . "]" . $_BORDERC; - $PathLen = length($PATH); # will be ZERO, if not in TOPIC mode! - if($TYPE ne "SINGLE") - { - if(!$SetTitle) - { - $SP = ""; - # print only if it is the first line! - $SP = " " x ($maxlen - 2 - $PathLen); - if(!$Raw) { + $SSS = "-" x ($maxlen + 31); + $nlen = length("$num"); + $LINE = "$BORDERC $SSS $_BORDERC\n"; + $L = $BORDERC . "[" . $_BORDERC; + $LONGSPC = " " x (26 - $nlen); + $R = $BORDERC . "]" . $_BORDERC; + $PathLen = length($PATH); # will be ZERO, if not in TOPIC mode! + if ($TYPE ne "SINGLE") { + if (!$SetTitle) { + $SP = ""; + # print only if it is the first line! + $SP = " " x ($maxlen - 2 - $PathLen); + if (!$Raw) { # no title in raw-mode! - print C $LINE; - - print C "$L $NUMC#$_NUMC "; - if($ListType eq "LONG") - { - print C " $TIMEC" . "creation date$_TIMEC "; - } - else - { - print $LONGSPC; - } - if($TOPIC) - { - print C $TOPICC . "$PATH $_TOPICC$SP$R\n"; - } - else - { - print C $NOTEC . "note$_NOTEC$SP$R\n"; - } - - print C $LINE; - } - $SetTitle = 1; - } - $title = ""; - $CUTSPACE = " " x $txtlen; - $note =~ s/\n/$CUTSPACE/g; - $len = length($note); - if($len < ($txtlen - 2 - $nlen)) - { - $diff = $txtlen - $len; - $Space = " " x $diff; - if(!$Raw) { - if($num eq "-") - { - $title = $BORDERC . $TOPICC . "\"" . $note . "\"" . $_TOPICC . $Space . "$_BORDERC"; - } - else - { - $title = $BORDERC . $NOTEC . "\"" . $note . "\"" . $_NOTEC . $Space . "$_BORDERC"; - } - } - else { - $title = $note; - } - } - else - { - $title = substr($note,0,($txtlen - 2 - $nlen)); - if(!$Raw) { - $title = $BORDERC . $NOTEC . "\"" . $title . "...\"$_NOTEC$_BORDERC"; - } - } - if($Raw) { - print "$num "; - print "$time " if($ListType eq "LONG"); - if($title =~ /^ => (.*)$TopicSep (.*)$/) { - $title = "$1$TopicSep $2"; # seems to be a topic! - } - print "$title\n"; - } - else { - # $title should now look as: "A sample note " - print C "$L $NUMC$num$_NUMC $R"; - if($ListType eq "LONG") - { - print C "$L$TIMEC" . $time . " $_TIMEC$R"; - } - print C "$L $NOTEC" . $title . "$_NOTEC $R\n"; - print C $LINE; - } + print C $LINE; + print C "$L $NUMC#$_NUMC "; + if ($ListType eq "LONG") { + print C " $TIMEC" . "creation date$_TIMEC "; + } + else { + print $LONGSPC; + } + if ($TOPIC) { + print C $TOPICC . "$PATH $_TOPICC$SP$R\n"; + } + else { + print C $NOTEC . "note$_NOTEC$SP$R\n"; + } + print C $LINE; } - else - { - # we will not reach this in raw-mode, therefore no decision here! - chomp $note; - $Space = " " x (($maxlen + $timelen) - 16); - print C $LINE; - print C "$L $NUMC$num$_NUMC $R$L$TIMEC$time$_TIMEC $Space$R\n"; - print C $LINE; - print C $NOTEC . $note . $_NOTEC . "\n"; - print C $LINE; + $SetTitle = 1; + } + $title = ""; + $CUTSPACE = " " x $txtlen; + if ($TYPE eq "search") { + $note =~ s/^\Q$TopicSep\E.+?\Q$TopicSep\E\n//; + } + $note =~ s/\n/$CUTSPACE/g; + $len = length($note); + if ($len < ($txtlen - 2 - $nlen)) { + $diff = $txtlen - $len; + $Space = " " x $diff; + if (!$Raw) { + if ($num eq "-") { + $title = $BORDERC . $TOPICC . "\"" . $note . "\"" . $_TOPICC . $Space . "$_BORDERC"; + } + else { + $title = $BORDERC . $NOTEC . "\"" . $note . "\"" . $_NOTEC . $Space . "$_BORDERC"; + } } - -} + else { + $title = $note; + } + } + else { + $title = substr($note,0,($txtlen - 2 - $nlen)); + if (!$Raw) { + $title = $BORDERC . $NOTEC . "\"" . $title . "...\"$_NOTEC$_BORDERC"; + } + } + if ($Raw) { + print "$num "; + print "$time " if($ListType eq "LONG"); + if ($title =~ /^ => (.*)$TopicSep (.*)$/) { + $title = "$1$TopicSep $2"; # seems to be a topic! + } + print "$title\n"; + } + else { + # $title should now look as: "A sample note " + print C "$L $NUMC$num$_NUMC $R"; + if ($ListType eq "LONG") { + print C "$L$TIMEC" . $time . " $_TIMEC$R"; + } + print C "$L $NOTEC" . $title . "$_NOTEC $R\n"; + print C $LINE; + } + } + else { + # we will not reach this in raw-mode, therefore no decision here! + chomp $note; + $Space = " " x (($maxlen + $timelen) - 16); + print C $LINE; + print C "$L $NUMC$num$_NUMC $R$L$TIMEC$time$_TIMEC $Space$R\n"; + print C $LINE; + print C $NOTEC . $note . $_NOTEC . "\n"; + print C $LINE; + } + } sub C -{ + { my(%Color, $default, $S, $Col, $NC, $T); - # \033[1m%30s\033[0m - %Color = ( 'black' => '0;30', - 'red' => '0;31', - 'green' => '0;32', - 'yellow' => '0;33', - 'blue' => '0;34', - 'magenta' => '0;35', - 'cyan' => '0;36', - 'white' => '0;37', - 'B' => '1;30', - 'BLACK' => '1;30', - 'RED' => '1;31', - 'GREEN' => '1;32', - 'YELLOW' => '1;33', - 'BLUE' => '1;34', - 'MAGENTA' => '1;35', - 'CYAN' => '1;36', - 'WHITE' => '1;37', - 'black_' => '4;30', - 'red_' => '4;31', - 'green_' => '4;32', - 'yellow_' => '4;33', - 'blue_' => '4;34', - 'magenta_' => '4;35', - 'cyan_' => '4;36', - 'white_' => '4;37', - 'blackI' => '7;30', - 'redI' => '7;31', - 'greenI' => '7;32', - 'yellowI' => '7;33', - 'blueI' => '7;34', - 'magentaI' => '7;35', - 'cyanI' => '7;36', - 'whiteI' => '7;37' - ); - $default = "\033[0m"; - $S = $_[0]; - foreach $Col (%Color) - { - if ($S =~ /<$Col>/g) - { - if($COLOR ne "NO") - { - $NC = "\033[" . $Color{$Col} . "m"; - $S =~ s/<$Col>/$NC/g; - $S =~ s/<\/$Col>/$default/g; - } - else - { - $S =~ s/<$Col>//g; - $S =~ s/<\/$Col>//g; - } - } - } - return $S; -} + # \033[1m%30s\033[0m + %Color = ( 'black' => '0;30', + 'red' => '0;31', + 'green' => '0;32', + 'yellow' => '0;33', + 'blue' => '0;34', + 'magenta' => '0;35', + 'cyan' => '0;36', + 'white' => '0;37', + 'B' => '1;30', + 'BLACK' => '1;30', + 'RED' => '1;31', + 'GREEN' => '1;32', + 'YELLOW' => '1;33', + 'BLUE' => '1;34', + 'MAGENTA' => '1;35', + 'CYAN' => '1;36', + 'WHITE' => '1;37', + 'black_' => '4;30', + 'red_' => '4;31', + 'green_' => '4;32', + 'yellow_' => '4;33', + 'blue_' => '4;34', + 'magenta_' => '4;35', + 'cyan_' => '4;36', + 'white_' => '4;37', + 'blackI' => '7;30', + 'redI' => '7;31', + 'greenI' => '7;32', + 'yellowI' => '7;33', + 'blueI' => '7;34', + 'magentaI' => '7;35', + 'cyanI' => '7;36', + 'whiteI' => '7;37' + ); + $default = "\033[0m"; + $S = $_[0]; + foreach $Col (%Color) { + if ($S =~ /<$Col>/g) { + if ($COLOR ne "NO") { + $NC = "\033[" . $Color{$Col} . "m"; + $S =~ s/<$Col>/$NC/g; + $S =~ s/<\/$Col>/$default/g; + } + else { + $S =~ s/<$Col>//g; + $S =~ s/<\/$Col>//g; + } + } + } + return $S; + } sub num_bereich -{ + { my($m,@LR,@Sorted_LR,$i); # $number is the one we want to delete! # But does it contain kommas? - @NumBlock = (); #reset + @NumBlock = (); #reset $m = 0; - if($number =~ /\,/) - { - # accept -d 3,4,7 - @NumBlock = split(/\,/,$number); + if ($number =~ /\,/) { + # accept -d 3,4,7 + @NumBlock = split(/\,/,$number); } - elsif($number =~ /^\d+\-\d+$/) - { - # accept -d 3-9 - @LR = split(/\-/,$number); - @Sorted_LR = (); + elsif ($number =~ /^\d+\-\d+$/) { + # accept -d 3-9 + @LR = split(/\-/,$number); + @Sorted_LR = (); - if($LR[0] > $LR[1]) - { - @Sorted_LR = ($LR[1], $LR[0]); - } - elsif($LR[0] == $LR[1]) - { - # 0 and 1 are the same - @Sorted_LR = ($LR[0], $LR[1]); - } - else - { - @Sorted_LR = ($LR[0], $LR[1]); - } + if ($LR[0] > $LR[1]) { + @Sorted_LR = ($LR[1], $LR[0]); + } + elsif ($LR[0] == $LR[1]) { + # 0 and 1 are the same + @Sorted_LR = ($LR[0], $LR[1]); + } + else { + @Sorted_LR = ($LR[0], $LR[1]); + } - for($i=$Sorted_LR[0]; $i<=$Sorted_LR[1]; $i++) - { - # from 3-6 create @NumBlock (3,4,5,6) - $NumBlock[$m] = $i; - $m++; - } + for ($i=$Sorted_LR[0]; $i<=$Sorted_LR[1]; $i++) { + # from 3-6 create @NumBlock (3,4,5,6) + $NumBlock[$m] = $i; + $m++; + } } - else - { - @NumBlock = ($number); + else { + @NumBlock = ($number); } -} + } sub getdate -{ + { my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year += 1900; - $mon += 1; - $mon =~ s/^(\d)$/0$1/; + $mon += 1; + $mon =~ s/^(\d)$/0$1/; $hour =~ s/^(\d)$/0$1/; - $min =~ s/^(\d)$/0$1/; - $sec =~ s/^(\d)$/0$1/; + $min =~ s/^(\d)$/0$1/; + $sec =~ s/^(\d)$/0$1/; $mday =~ s/^(\d)$/0$1/; return "$mday.$mon.$year $hour:$min:$sec"; -} + } sub gettemp -{ - my($random, @range); - @range=('0'..'9','a'..'z','A'..'Z'); - srand(time||$$); - for (0..10) { - $random .= $range[rand(int($#range)+1)]; + { + my($random, @range); + @range=('0'..'9','a'..'z','A'..'Z'); + srand(time||$$); + for (0..10) { + $random .= $range[rand(int($#range)+1)]; + } + my $tempfile = $TempDir . "/" . $USER . "." . $random; + if (-e $tempfile) { + # avoid race conditions! + unlink $tempfile; + } + return $tempfile; } - my $tempfile = $TempDir . "/" . $USER . "." . $random; - if (-e $tempfile) { - # avoid race conditions! - unlink $tempfile; - } - return $tempfile; -} sub help -{ -my $B = ""; -my $BB = ""; -my($S, $L, $T, $Q, $H, $N, $D, $E); -$L = $B . "L" . $BB . $NOTEC; -$T = $B . "T" . $BB . $NOTEC; -$Q = $B . "Q" . $BB . $NOTEC; -$H = $B . "?" . $BB . $NOTEC; -$N = $B . "N" . $BB . $NOTEC; -$D = $B . "D" . $BB . $NOTEC; -$E = $B . "E" . $BB . $NOTEC; -$S = $B . "S" . $BB . $NOTEC; + { + my $B = ""; + my $BB = ""; + my($S, $L, $T, $Q, $H, $N, $D, $E); + $L = $B . "L" . $BB . $NOTEC; + $T = $B . "T" . $BB . $NOTEC; + $Q = $B . "Q" . $BB . $NOTEC; + $H = $B . "?" . $BB . $NOTEC; + $N = $B . "N" . $BB . $NOTEC; + $D = $B . "D" . $BB . $NOTEC; + $E = $B . "E" . $BB . $NOTEC; + $S = $B . "S" . $BB . $NOTEC; -print C qq~$BORDERC + print C qq~$BORDERC ----------------------------------------------------------------------$_BORDERC $TOPICC HELP for interactive note $version $_TOPICC $NOTEC @@ -1431,73 +1359,61 @@ $E Edit a note. Usage is similar to Delete but you can only edit note a time. $H This help screen. $Q Exit the program.~; -if($TOPIC) -{ -print C qq~ + if ($TOPIC) { + print C qq~ $T print a list of all existing topics as a tree. T prints the tree - with all notes under each topic. + with all notes under each topic.~; + } + print C qq~ - You can change the actual topic by simply typing it's name or by using - the command "cd", i.e. "cd mytopic". You can create a new topic by creating - a new note, the first line must be the topic borderd by slashes, i.e.: - "/newtopic/". The slash is the default topic-sepearator, but you can over- - ride this in the config! If you type just ".." instead of a topic, you will - go one step back in your topic-structure. -~; -} -print C qq~ -$NOTEC -All commands except the List and Topic commands are case insensitive. $_NOTEC $BORDERC +All commands except the List and Topic commands are case insensitive. +Read the note(1) manpage for more details.$BORDERC ----------------------------------------------------------------------$_BORDERC ~; -} + } sub display_tree { - # displays a tree of all topics - my(%TREE, %res, $n, $t, $num, @nodes, $firstline, $text, $untext); - %res = $db->get_all(); - foreach $num (keys %res) - { - $n = $res{$num}->{'note'}; - $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); - } - else - { - @nodes = ();("$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_tree(\%{$TREE{''}},"") if(%TREE); - print C $BORDERC . $_BORDERC . "\n"; + # displays a tree of all topics + my(%TREE, %res, $n, $t, $num, @nodes, $firstline, $text, $untext); + %res = $db->get_all(); + foreach $num (keys %res) { + $n = $res{$num}->{'note'}; + $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); + } + else { + @nodes = (); #("$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_tree(\%{$TREE{''}},"") if(%TREE); + print C $BORDERC . $_BORDERC . "\n"; } sub tree { - my($num, $text, $LocalTree, $node, @nodes) = @_; - if(@nodes) { - if(! exists $LocalTree->{$node}->{$NoteKey}) { - $LocalTree->{$node}->{$NoteKey} = []; - } - &tree($num, $text, $LocalTree->{$node}, @nodes); + my($num, $text, $LocalTree, $node, @nodes) = @_; + if (@nodes) { + if (! exists $LocalTree->{$node}->{$NoteKey}) { + $LocalTree->{$node}->{$NoteKey} = []; } - else { - if(length($text) > ($maxlen - 5)) { - $text = substr($text, 0, ($maxlen -5)); - } - $text = $text . " (" . $NUMC . "#" . $num . $_NUMC . $NOTEC . ")" . $_NOTEC if($text ne ""); - push @{$LocalTree->{$node}->{$NoteKey}}, $text; + &tree($num, $text, $LocalTree->{$node}, @nodes); + } else { + if (length($text) > ($maxlen - 5)) { + $text = substr($text, 0, ($maxlen -5)); } + $text = $text . " (" . $NUMC . "#" . $num . $_NUMC . $NOTEC . ")" . $_NOTEC if($text ne ""); + push @{$LocalTree->{$node}->{$NoteKey}}, $text; + } } @@ -1507,13 +1423,13 @@ sub print_tree { my $prefix=shift; my @notes=@{$hashref->{$NoteKey}}; my @subnotes=sort grep { ! /^$NoteKey$/ } keys %$hashref; - if($TreeType eq "LONG") { - for my $note (@notes) { - if($note ne "") { - print C $BORDERC ;# . $prefix. "|\n"; - print C "$prefix+---<" . $NOTEC . $note . $BORDERC . ">" . $_NOTEC . "\n"; - } - } + if ($TreeType eq "LONG") { + for my $note (@notes) { + if ($note ne "") { + print C $BORDERC ; # . $prefix. "|\n"; + print C "$prefix+---<" . $NOTEC . $note . $BORDERC . ">" . $_NOTEC . "\n"; + } + } } for my $index (0..$#subnotes) { print C $BORDERC . $prefix. "|\n"; @@ -1524,64 +1440,67 @@ sub print_tree { sub getconfig -{ - my($configfile) = @_; - my ($home, $value, $option); - # checks are already done, so trust myself and just open it! - open CONFIG, "<$configfile" || die $!; - while() { - 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/); - $dbuser = $value if (/^DbUser/); - $dbpasswd = $value if (/^DbPasswd/); - $dbname = $value if (/^DbName/); - $table = $value if (/^DbTable/); - $fnum = $value if (/^FieldNumber/); - $fnote = $value if (/^FieldNote/); - $fdate = $value if (/^FieldDate/); - $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); - $COLOR = "YES" if (/^UseColors/ && $value == 1); - $COLOR = "NO" if (/^UseColors/ && $value == 0); - $TopicSep = $value if (/^TopicSeparator/); - $maxlen = $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/); - } - chomp $home; - $home =~ s/\/*$//; # cut eventually / at the end - $HOME = eval($home); - if($NOTEDB =~ /^(~\/)(.*)$/) { - $NOTEDB = "/home/" . $USER . "/" . $2; - } - $libpath =~ s/\/*$//; + { + my($configfile) = @_; + my ($home, $value, $option); + # checks are already done, so trust myself and just open it! + open CONFIG, "<$configfile" || die $!; + while () { + 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/); + $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); + $COLOR = "YES" if (/^UseColors/ && $value == 1); + $COLOR = "NO" if (/^UseColors/ && $value == 0); + $TopicSep = $value if (/^TopicSeparator/); + $maxlen = $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/); + } + chomp $home; + $home =~ s/\/*$//; # cut eventually / at the end + $HOME = eval($home); + if ($NOTEDB =~ /^(~\/)(.*)$/) { + $NOTEDB = "/home/" . $USER . "/" . $2; + } + $libpath =~ s/\/*$//; - close CONFIG; -} + close CONFIG; + } @@ -1589,6 +1508,9 @@ sub getconfig __END__ # # $Log: note,v $ +# 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. # diff --git a/bin/system_and.patch b/bin/system_and.patch new file mode 100644 index 0000000..d3e669a --- /dev/null +++ b/bin/system_and.patch @@ -0,0 +1,19 @@ +*** note Mon Jul 10 00:10:03 2000 +--- _note Fri Jul 21 08:38:22 2000 +*************** +*** 635,641 **** + $editor = &find_editor; + if($editor) + { +! system "touch", $TEMP && die $!; + system "chattr", "+s", $TEMP; # ignore errors, since only on ext2 supported! + system $editor, $TEMP; + } +--- 635,641 ---- + $editor = &find_editor; + if($editor) + { +! system "touch", $TEMP and die $!; + system "chattr", "+s", $TEMP; # ignore errors, since only on ext2 supported! + system $editor, $TEMP; + } diff --git a/config/CVS/Entries b/config/CVS/Entries new file mode 100644 index 0000000..1155b76 --- /dev/null +++ b/config/CVS/Entries @@ -0,0 +1,2 @@ +/noterc/1.3/Sun Jul 9 22:37:15 2000// +D diff --git a/config/CVS/Repository b/config/CVS/Repository new file mode 100644 index 0000000..5fac8d5 --- /dev/null +++ b/config/CVS/Repository @@ -0,0 +1 @@ +NOTE/config diff --git a/config/CVS/Root b/config/CVS/Root new file mode 100644 index 0000000..9c415c0 --- /dev/null +++ b/config/CVS/Root @@ -0,0 +1 @@ +zarahg@cvs.htnews.sourceforge.net:/cvsroot/htnews diff --git a/config/noterc b/config/noterc index ee85127..dcf1adb 100644 --- a/config/noterc +++ b/config/noterc @@ -42,6 +42,8 @@ DbDriver binary #FieldNumber number #FieldNote note #FieldDate date +# uncomment for using an encrypted password, generate it with note "--encrypt" +#encrypt_passwd 1 #### specific end ### @@ -152,7 +154,16 @@ TempDirectory /home/you/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 + + +# 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 # That's all about it for now. # If you still have any questiosn, please feel free to contact # me by email: Thomas Linden diff --git a/config/rc b/config/rc new file mode 100644 index 0000000..4e1f7c0 --- /dev/null +++ b/config/rc @@ -0,0 +1,154 @@ +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 /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 + + +backend specific settings for sql backend +DbHost localhost +DbUser you +DbPasswd +DbName mynotes +DbTable note +FieldNumber number +FieldNote note +FieldDate date +use an encrypted password, generate it with note "--encrypt_passwd" +encrypt_passwd 1 +#### specific end ### + + +backend specific settings for binary(default) backend +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 ### + + +backend specific settings for DBM backend +this must be an existing directory! +#DbName /home/you/.notedbm +#### specific end ### + +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 + +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". 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 0 + + +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 30 + + +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 blue +NoteColor green +TimeColor black +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/you/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 + +That's all about it for now. +If you still have any questiosn, please feel free to contact +me by email: Thomas Linden diff --git a/mysql/CVS/Entries b/mysql/CVS/Entries new file mode 100644 index 0000000..f1d9103 --- /dev/null +++ b/mysql/CVS/Entries @@ -0,0 +1,5 @@ +/README/1.1.1.1/Sat Jul 1 14:40:52 2000// +/install.sh/1.1.1.1/Sat Jul 1 14:40:52 2000// +/permissions/1.1.1.1/Sat Jul 1 14:40:52 2000// +/sql/1.1.1.1/Sat Jul 1 14:40:52 2000// +D diff --git a/mysql/CVS/Repository b/mysql/CVS/Repository new file mode 100644 index 0000000..7e689e0 --- /dev/null +++ b/mysql/CVS/Repository @@ -0,0 +1 @@ +NOTE/mysql diff --git a/mysql/CVS/Root b/mysql/CVS/Root new file mode 100644 index 0000000..9c415c0 --- /dev/null +++ b/mysql/CVS/Root @@ -0,0 +1 @@ +zarahg@cvs.htnews.sourceforge.net:/cvsroot/htnews diff --git a/note b/note index db622a5..5107e58 100755 --- a/note +++ b/note @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: note,v 1.27 2000/05/16 23:51:35 thomas Exp thomas $ +# $Id: note,v 1.1.1.1 2000/07/01 14:40:50 zarahg Exp $ # # # note - console notes management with database and encryption support. @@ -1560,6 +1560,9 @@ sub getconfig __END__ # # $Log: note,v $ +# Revision 1.1.1.1 2000/07/01 14:40:50 zarahg +# initial import +# # Revision 1.27 2000/05/16 23:51:35 thomas # fixed many option-parsing related bugd! # diff --git a/note.1 b/note.1 new file mode 100644 index 0000000..0c3d567 --- /dev/null +++ b/note.1 @@ -0,0 +1,636 @@ +.rn '' }` +''' $RCSfile$$Revision$$Date$ +''' +''' $Log$ +''' +.de Sh +.br +.if t .Sp +.ne 5 +.PP +\fB\\$1\fR +.PP +.. +.de Sp +.if t .sp .5v +.if n .sp +.. +.de Ip +.br +.ie \\n(.$>=3 .ne \\$3 +.el .ne 3 +.IP "\\$1" \\$2 +.. +.de Vb +.ft CW +.nf +.ne \\$1 +.. +.de Ve +.ft R + +.fi +.. +''' +''' +''' Set up \*(-- to give an unbreakable dash; +''' string Tr holds user defined translation string. +''' Bell System Logo is used as a dummy character. +''' +.tr \(*W-|\(bv\*(Tr +.ie n \{\ +.ds -- \(*W- +.ds PI pi +.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +.ds L" "" +.ds R" "" +''' \*(M", \*(S", \*(N" and \*(T" are the equivalent of +''' \*(L" and \*(R", except that they are used on ".xx" lines, +''' such as .IP and .SH, which do another additional levels of +''' double-quote interpretation +.ds M" """ +.ds S" """ +.ds N" """"" +.ds T" """"" +.ds L' ' +.ds R' ' +.ds M' ' +.ds S' ' +.ds N' ' +.ds T' ' +'br\} +.el\{\ +.ds -- \(em\| +.tr \*(Tr +.ds L" `` +.ds R" '' +.ds M" `` +.ds S" '' +.ds N" `` +.ds T" '' +.ds L' ` +.ds R' ' +.ds M' ` +.ds S' ' +.ds N' ` +.ds T' ' +.ds PI \(*p +'br\} +.\" If the F register is turned on, we'll generate +.\" index entries out stderr for the following things: +.\" TH Title +.\" SH Header +.\" Sh Subsection +.\" Ip Item +.\" X<> Xref (embedded +.\" Of course, you have to process the output yourself +.\" in some meaninful fashion. +.if \nF \{ +.de IX +.tm Index:\\$1\t\\n%\t"\\$2" +.. +.nr % 0 +.rr F +.\} +.TH note 1 "note version 1.1.0" "10/Aug/2000" "Documentation" +.UC +.if n .hy 0 +.if n .na +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.de CQ \" put $1 in typewriter font +.ft CW +'if n "\c +'if t \\&\\$1\c +'if n \\&\\$1\c +'if n \&" +\\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7 +'.ft R +.. +.\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2 +. \" AM - accent mark definitions +.bd B 3 +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds ? ? +. ds ! ! +. ds / +. ds q +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10' +. ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +. ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#] +.ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u' +.ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u' +.ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#] +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +.ds oe o\h'-(\w'o'u*4/10)'e +.ds Oe O\h'-(\w'O'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds v \h'-1'\o'\(aa\(ga' +. ds _ \h'-1'^ +. ds . \h'-1'. +. ds 3 3 +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +. ds oe oe +. ds Oe OE +.\} +.rm #[ #] #H #V #F C +.SH "NAME" +note \- a perl script for maintaining notes. +.SH "SYNPOPSIS" +note [options] [ number [,number...]] +.SH "DESCRIPTION" +\fBnote\fR is a small console program written in perl, which allows +you to manage notes similar to programs like \*(L"knotes\*(R" but from +the commandline. Note can use different database-backends for +notes-storage. It ships with a DBI\-based mysql-\fImodule\fR\|(which +can also be used for other by DBI supported DBMS), another +module, which uses a binary file for storage and a DBM module. +Note supports since version 1.0.0 \fIencryption\fR\|(IDEA or DES)! +.SH "OPTIONS" +.Ip "\fI\-c, --config file\fR" 5 +Use another config file than the default ~/.noterc. +.Ip "\fI\-l, --list [topic]\fR" 5 +Lists all existing notes. If no topic were specified, +it will display a list of all existing topics. +See the section \fI\s-1TOPICS\s0\fR for details about topics. +.Ip "\fI\-L, --longlist [topic]\fR" 5 +The same as \fI\-l\fR but prints also the timestamp of the notes. +.Ip "\fI\-t, --topic\fR" 5 +Prints a list of all topics as a tree. +.Ip "\fI\-T, --longtopic\fR" 5 +Prints the topic-tree with the notes under each topic. +.Ip "\fI\-s, --search string\fR" 5 +Searches for trough the notes database. See the section +\fI\s-1SEARCHING\s0\fR for details about the search engine. +.Ip "\fI\-e, --edit number\fR" 5 +Edit the note with the number using your default editor +or the one you specified in the config file. +.Ip "\fI\-d, --delete number\fR" 5 +Delete the note with the number . You can delete multiple notes +with one command. \*(L"1-4\*(R" deletes the notes 1,2,3,4. And \*(L"1,5,7\*(R" deletes +the specified ones. +.Ip "\fI\-D, --Dump [file | \-]\fR" 5 +Dumps all notes to the textfile . If is a \*(L"\-\*(R" it will +be printed out to standard output (\s-1STDOUT\s0). +.Ip "\fI\-I, --Import file | \-\fR" 5 +Imports a previously dumped textfile into the +note database. Data will be appended by default. +You can also specify a dash \fInote \-I \-\fR instead of a , +which causes note, silently to read in a dump from \s-1STDIN\s0. +.Ip "\fI\-o, --overwrite\fR" 5 +Only suitable for use with --Import. Overwrites an +existing notedb. Use with care. +.Ip "\fI\-r, --raw\fR" 5 +Raw mode, output will not be formatted. Works not in interactive +mode, only on cmd-line for list and display. That means, no colors +will be used and no lines or titles. +.Ip "\fI\-i, --interactive\fR" 5 +Start note in interactive mode. See the section \fI\s-1INTERACTIVE\s0 \s-1MODE\s0\fR +for details on this mode. + +.Ip "\fI--encrypt cleartext\fR" 5 +Encrypt the given clear text string. You would need that if you want to +store the mysql password not in cleartext in the \fIconfig\fR\|(if you are using +the mysql backend!). +.Ip "\fI\-h, --help\fR" 5 +Display this help screen. +.Ip "\fI\-v, --version\fR" 5 +Display the version number. +.Ip "\fB\-\fR" 5 +If you run note just with one dash: \fBnote \-\fR, then it will read in a new +note from \s-1STDIN\s0 until \s-1EOF\s0. This makes it possible to pipe text into a new note, i.e.: +.Sp +.Vb 1 +\& cat sometextfile | note - +.Ve +.SH "USAGE" +.Sh "\s-1GENERAL\s0 \s-1USAGE\s0" +If you don't know, how to run note, try \*(L"note \-h\*(R" first. +It will tell you all available commandline options. +.PP +To create a new note, simply run \*(L"note\*(R". You can enter +the note (the length is by default limited to 4096 bytes, +which you can change from your config file if you are using +the binary backend, therwise there is no limitation). +End by typing a . on a line itself. note will tell you the +number of the note. +.PP +If you want to view the note, type \*(L"note 1\*(R", if the notenumber +was 1. +.PP +If you want to get an overview of all notes, type \*(L"note \-l\*(R". +You will get a list of all notes, containing the number, +the first line and the creation date. If topic-support is +turned on (which is by default), then all subtopics under the +current topic will be displayed first. +If you want to get a listing of all +If you want to see the timestamps, use \*(L"\-L\*(R" instead of \*(L"\-l\*(R". +Read more about topics below in the section \*(L"Topics\*(R". +You can also specify the topic which notes you want to see: +\*(L"\-l mytopic\*(R" does the trick. +Additional, you might want to get an overview of your topic- +strcture. You can use the command \*(L"\-t\*(R" in this case, which +will display a tree-view of your tpic-structure. You can +use the command \*(L"\-T\*(R" if you want to see the notes under each +topic too. \*(L"\-T\*(R" will also show the number of each note. +.PP +To edit a certain note, type \*(L"note \-e 1\*(R". It will invoke your +editor (vi or pico). You can edit it, after saving, note +will store the changed note to the database. +.PP +Of course you can drop a certain note: \*(L"note \-d 1\*(R" deletes +note number 1. If a note in the middle or the beginning of +the database will be deleted, note will recount the other +existent notes. For example there are 3 notes, number 1, 2 +and 3. If you delete number 2, then number 3 will become +number 2. +You can also make use of the extended delete-syntax: +To delete note 1 and 2, use \*(L"\-d 1,2\*(R" +To delete note 1,2 and 3, use \*(L"\-d 1-3\*(R". +.Sh "\s-1SEARCHING\s0" +If you cannot remember, which note you are looking for, you +can use the search capability of note: \*(L"note \-s \*(R". +note will search the whole note database case insensitive for +an occurence of this string and tell you the number and first- +line it has. +.PP +You can extend the searchstring using \fB\s-1AND\s0\fR, \fB\s-1OR\s0\fR ( and ) and +shell-like wildcards: +.PP +.Vb 1 +\& $ note -s "moses AND lenin" +.Ve +or: +.PP +.Vb 1 +\& $ note -s "(mike OR arnold) AND (jackson OR schwarzenegger)" +.Ve +If note finds a note, which first line is a topic, then it will +display it's second line. +.PP +These rules apply for the interactive search too. +.Sh "\s-1TOPICS\s0" +If topic-support is turned on (which is by default), the various +notes are sorted under various topics. There is no special database +field for the topic. Instead the topic will be stored right in the +note. +If the first line of your note contains some text bordered by slashes +(or whatever you prefer, set \*(L"TopicSeparator\*(R" in your config! default +is slash), then note will consider it as the topic of this certain +note. For examle: +.PP +.Vb 1 +\& B +.Ve +If you are using topics, no data after the topic is allowed, if there +is any text, note will consider it as a subtopic! Therefore, don't for- +get to put a newline after the topic-line. +.PP +The list-command will only show you notes under this topic. If you +create a new note, it will automagically inserted under the current +topic (note will prepend the string \*(L"/topicname/\*(R" to the text of your +note). +.PP +You can create at any time from any point a new topic. Just create a new +note and type the name of the new topic bordered by slashes (or +TopicSeparator) at the first line of this note. After saving, there +will be available a new topic with one note in it. +.PP +You can create as many subtopics as you like, the format is similar to +a filesystem-path. An example, say, you want to create such a +structure: +.PP +.Vb 10 +\& (root - top level) +\& | +\& |----test +\& | |----subtopic +\& | | |--note 1 +\& | | |--note 2 +\& | | +\& | |--note 4 +\& | +\& |--note 3 +.Ve +Then you may create those 4 new notes: +.PP +.Vb 12 +\& --- snip --- +\& /test/subtopic/ +\& note 1 +\& --- snip --- +\& /test/subtopic/ +\& note 2 +\& --- snip --- +\& note 3 +\& --- snip --- +\& /test/ +\& note 4 +\& --- snip --- +.Ve +I hope, you got the point ;\-) +.PP +If a note does not contain the \*(L"magic\*(R" /topic/ construction on the first +line, it will be listed under the \*(L"root\*(R" of note, that is the point +you are at the startup of note. +.PP +You can subsequently move a note without a topic to a certain topic. +Simply edit it and insert at the first line the above mentioned +construction. +.PP +Note: Please don't forget the prepending and appending a slash of a +topic. You will get strange results without it! +.Sh "\s-1INTERACTIVE\s0 \s-1MODE\s0" +If you start note with the commandline flag \fB\-i\fR, then it starts +with an interactive interface. +It will start with a listing under the default top-topic ("/"). +You can enter the name of a topic to change to that topic. This works +similar to a filesystem structure. The current topic will be +displayed on the top of the screen. +.PP +The following commands are available: +.Ip "\fBL [topic]\fR" 5 +This command lists all notes with a timestamp. If you specify a topic, it +will only list the notes under this topic. If you are under a certain subtopic, +then it will only display the notes under this topic. +.Ip "\fBl [topic]\fR" 5 +This commands behaves similar to \fBL\fR but it does not display the timestamp. +You can achieve the same result by simply pressing enter at any time. +.Ip "\fBN\fR" 5 +You can create a new note by simply pressing \fBN\fR or \fBn\fR. You favorite +editor will be started and you can enter your note text. If you are already +under a topic then this new note will automatically go to this topic. +note adds an aditional line to the top of the note with the topic. But +you can of course specify your own topic. +.Sp +Note will tell you which number it has assigned to the newly created note. +.Ip "\fBE number\fR" 5 +By entering \fBE\fR or \fBe\fR and a note-number you can edit an existing note +using your favorite editor. This way you can also move an existing note +from one topic to another one by editing the first line of the note. +.Ip "\fBD number\fR" 5 +\fBE\fR or \fBe\fR deletes one or more existing \fInote\fR\|(s). It requires a note number +or a set of note numbers. 1-5 and 1,7,9 are possible values. +After one or more notes has been deleted note will recount all remaining notes. +Say if you delete 1 and 2, then 3 will become 1, 4 will become 5 and so forth. +.Ip "\fBS [expression]\fR" 5 +You can search for the occurence of a text in your notes-database with the +command \fBS\fR or \fBs\fR. If you omit an expression note will ask you for one. +.Ip "\fBT\fR" 5 +This prints a tree-view of your topic-structure. \fBT\fR displays the tree with +notes, \fBt\fR displays just the topics without notes. +.Ip "\fBcd topic\fR" 5 +Change the actual topic under which you are. This works identical like just +entering the topic but it has some advantages. You can enter \fBcd ..\fR if +you want to go one level up in the topic-structure. And you can enter \fBcd /\fR +to go to the top of the structure. +Additional it is possible to enter a note-number instead of a topic name. +For this feature to be active you need to set the config option \fBShortCd\fR +to \fB1\fR or \fByes\fR. If you use a number and the note with this number is +under a certain topic then you will \*(L"cd\*(R" to this topic. This allows you +to do kind of jumps over multiple levels of topics. +.Ip "\fB? or h\fR" 5 +Display a short help screen. +.Ip "\fBQ\fR" 5 +Quit note. +.Sh "\s-1BACKUP\s0" +You can also dump the contents of your note-database into a +\s-1ASCII\s0\-\fItextfile\fR\|(\fI\-D\fR). You can use this file later to import it into +your note-\fIdatabase\fR\|(\-I). This is usefull, if you want quickly trans- +fer your notes from one host to another (i.e. you could mail +your note-dump form your office to home and import it there +for further use). +.PP +The dumps from the two versions of note are in the same format. +Using dumps it is also possible to reinitialize your database. You +can use the \*(L"\-o\*(R" switch whcih causes note to overwrite your existing +database. This is very handy if you changed heavily your config. And +it is required, if you changed: encryption, db-driver, (binary-format) +and the password. You can use the following command for reinitializing: +.PP +.Vb 1 +\& $ note -D - | note -o -I - +.Ve +What the hell, does this do?! Step by step: +.Ip "\(bu" 5 +\fBnote \-D \-\fR creates a note-database dump and prints it out +to stantdard output. +.Ip "\(bu" 5 +\fB|\fR this is the shell's pipe command. It takes the output +of the left program and gives it to the right program as +standard input. +.Ip "\(bu" 5 +\fBnote \-o \-I \-\fR imports a note-database dump from standard +input and overwrites an existing database. +.PP +Before you use the \fB\-o\fR switch, I consider you to make a backup! +.Sh "\s-1FORMATING\s0" +Another very nice feature is the possibility to format the note-text +(as much as shell allows it). First, you can use the note-internal +\*(L"magic-strings\*(R" for colorizing. Those strings looks much like \s-1HTML\s0: +\*(L"here is a green line of text no more green.\*(R" +As you see, the beginning of another color starts with a \fItag\fR\|(kinda) of +the color and ens with an end tag . +.PP +The following colors are available: +black, red, green, yellow, blue, magenta, cyan and white. +.PP +Beside colorizing text, you can also create bold or underlined text! If +you decide to use this (additional) feature, you need to set the +Config-Option \*(L"FormatNotes\*(R" to 1 which turns it on. +Usage is very straightforward, if a word (a word is defined as some +text with at least one space surrounded) is between a magic mark- +character. Here are the available things, you can do: +.PP +.Vb 3 +\& bold: **word** +\& underlined:__word__ +\& inverse:{{word}} +.Ve +The text will be formatted using the actually note-color. +.SH "ENCRYPTION" +You can turn on encryption from the config file. +Simply set UseEncryption to 1. Please note, that you need +to decide, if you want to use encryption before the first use +of note! If have already a note database and want to \*(L"migrate\*(R" +to encryption, I suggest you to follow the directions in the +file UPGRADE! +.PP +You can choose from different encryption algorythms. The default +is IDEA, but DES or BLOWFISH is also possible. You need to have +installed the following additional perl-modules on your system: +MD5 +Crypt::IDEA +Crypt::DES +Crypt::CBC +.PP +After turning on encryption, note will ask you for a passphrase +everytime it runs! It will *not* store this passphrase! +So, don't forget it! Be careful! +.SH "CONFIGURATION" +You can use a configuration file with note but it is not required. +Note will use default values if there is no config. +.PP +The default config file is \fB~/.noterc\fR. You may specify another +one with the commandline flag \fI--config\fR. +.PP +Comments start with #, empty lines will be ignored. +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). +.PP +For a detailed explanation of each possible parameter take a look +at the supplied sample configuration file in \fBconfig/noterc\fR. +.SH "SEE ALSO" +See the usage guide in the README or visit the note website: +http://www.0x49.org. +.SH "AUTHOR" +Thomas Linden + +.rn }` '' +.IX Title "NOTE 1" +.IX Name "note - a perl script for maintaining notes." + +.IX Header "NAME" + +.IX Header "SYNPOPSIS" + +.IX Header "DESCRIPTION" + +.IX Header "OPTIONS" + +.IX Item "\fI\-c, --config file\fR" + +.IX Item "\fI\-l, --list [topic]\fR" + +.IX Item "\fI\-L, --longlist [topic]\fR" + +.IX Item "\fI\-t, --topic\fR" + +.IX Item "\fI\-T, --longtopic\fR" + +.IX Item "\fI\-s, --search string\fR" + +.IX Item "\fI\-e, --edit number\fR" + +.IX Item "\fI\-d, --delete number\fR" + +.IX Item "\fI\-D, --Dump [file | \-]\fR" + +.IX Item "\fI\-I, --Import file | \-\fR" + +.IX Item "\fI\-o, --overwrite\fR" + +.IX Item "\fI\-r, --raw\fR" + +.IX Item "\fI\-i, --interactive\fR" + +.IX Item "\fI--encrypt cleartext\fR" + +.IX Item "\fI\-h, --help\fR" + +.IX Item "\fI\-v, --version\fR" + +.IX Item "\fB\-\fR" + +.IX Header "USAGE" + +.IX Subsection "\s-1GENERAL\s0 \s-1USAGE\s0" + +.IX Subsection "\s-1SEARCHING\s0" + +.IX Subsection "\s-1TOPICS\s0" + +.IX Subsection "\s-1INTERACTIVE\s0 \s-1MODE\s0" + +.IX Item "\fBL [topic]\fR" + +.IX Item "\fBl [topic]\fR" + +.IX Item "\fBN\fR" + +.IX Item "\fBE number\fR" + +.IX Item "\fBD number\fR" + +.IX Item "\fBS [expression]\fR" + +.IX Item "\fBT\fR" + +.IX Item "\fBcd topic\fR" + +.IX Item "\fB? or h\fR" + +.IX Item "\fBQ\fR" + +.IX Subsection "\s-1BACKUP\s0" + +.IX Item "\(bu" + +.IX Item "\(bu" + +.IX Item "\(bu" + +.IX Subsection "\s-1FORMATING\s0" + +.IX Header "ENCRYPTION" + +.IX Header "CONFIGURATION" + +.IX Header "SEE ALSO" + +.IX Header "AUTHOR" + diff --git a/note.pod b/note.pod new file mode 100644 index 0000000..1054309 --- /dev/null +++ b/note.pod @@ -0,0 +1,501 @@ +=head1 NAME + +note - a perl script for maintaining notes. + + +=head1 SYNPOPSIS + +note [options] [ number [,number...]] + + +=head1 DESCRIPTION + +B is a small console program written in perl, which allows +you to manage notes similar to programs like "knotes" but from +the commandline. Note can use different database-backends for +notes-storage. It ships with a DBI-based mysql-module(which +can also be used for other by DBI supported DBMS), another +module, which uses a binary file for storage and a DBM module. +Note supports since version 1.0.0 encryption(IDEA or DES)! + + +=head1 OPTIONS + + +=over + +=item I<-c, --config file> + +Use another config file than the default ~/.noterc. + + +=item I<-l, --list [topic]> + +Lists all existing notes. If no topic were specified, +it will display a list of all existing topics. +See the section I for details about topics. + +=item I<-L, --longlist [topic]> + +The same as I<-l> but prints also the timestamp of the notes. + + +=item I<-t, --topic> + +Prints a list of all topics as a tree. + + +=item I<-T, --longtopic> + +Prints the topic-tree with the notes under each topic. + + +=item I<-s, --search string> + +Searches for trough the notes database. See the section +I for details about the search engine. + + +=item I<-e, --edit number> + +Edit the note with the number using your default editor +or the one you specified in the config file. + + +=item I<-d, --delete number> + +Delete the note with the number . You can delete multiple notes +with one command. "1-4" deletes the notes 1,2,3,4. And "1,5,7" deletes +the specified ones. + + +=item I<-D, --Dump [file | -]> + +Dumps all notes to the textfile . If is a "-" it will +be printed out to standard output (STDOUT). + + +=item I<-I, --Import file | -> + +Imports a previously dumped textfile into the +note database. Data will be appended by default. +You can also specify a dash I instead of a , +which causes note, silently to read in a dump from STDIN. + + +=item I<-o, --overwrite> + +Only suitable for use with --Import. Overwrites an +existing notedb. Use with care. + + +=item I<-r, --raw> + +Raw mode, output will not be formatted. Works not in interactive +mode, only on cmd-line for list and display. That means, no colors +will be used and no lines or titles. + + +=item I<-i, --interactive> + +Start note in interactive mode. See the section I +for details on this mode. + + +=item I<--encrypt cleartext> + +Encrypt the given clear text string. You would need that if you want to +store the mysql password not in cleartext in the config(if you are using +the mysql backend!). + + +=item I<-h, --help> + +Display this help screen. + + +=item I<-v, --version> + +Display the version number. + + +=item B<-> + +If you run note just with one dash: B, then it will read in a new +note from STDIN until EOF. This makes it possible to pipe text into a new note, i.e.: + + cat sometextfile | note - + + +=back + + + + +=head1 USAGE + +=head2 GENERAL USAGE + +If you don't know, how to run note, try "note -h" first. +It will tell you all available commandline options. + +To create a new note, simply run "note". You can enter +the note (the length is by default limited to 4096 bytes, +which you can change from your config file if you are using +the binary backend, therwise there is no limitation). +End by typing a . on a line itself. note will tell you the +number of the note. + +If you want to view the note, type "note 1", if the notenumber +was 1. + +If you want to get an overview of all notes, type "note -l". +You will get a list of all notes, containing the number, +the first line and the creation date. If topic-support is +turned on (which is by default), then all subtopics under the +current topic will be displayed first. +If you want to get a listing of all +If you want to see the timestamps, use "-L" instead of "-l". +Read more about topics below in the section "Topics". +You can also specify the topic which notes you want to see: +"-l mytopic" does the trick. +Additional, you might want to get an overview of your topic- +strcture. You can use the command "-t" in this case, which +will display a tree-view of your tpic-structure. You can +use the command "-T" if you want to see the notes under each +topic too. "-T" will also show the number of each note. + +To edit a certain note, type "note -e 1". It will invoke your +editor (vi or pico). You can edit it, after saving, note +will store the changed note to the database. + +Of course you can drop a certain note: "note -d 1" deletes +note number 1. If a note in the middle or the beginning of +the database will be deleted, note will recount the other +existent notes. For example there are 3 notes, number 1, 2 +and 3. If you delete number 2, then number 3 will become +number 2. +You can also make use of the extended delete-syntax: +To delete note 1 and 2, use "-d 1,2" +To delete note 1,2 and 3, use "-d 1-3". + + + +=head2 SEARCHING + +If you cannot remember, which note you are looking for, you +can use the search capability of note: "note -s ". +note will search the whole note database case insensitive for +an occurence of this string and tell you the number and first- +line it has. + +You can extend the searchstring using B, B ( and ) and +shell-like wildcards: + + $ note -s "moses AND lenin" + +or: + + $ note -s "(mike OR arnold) AND (jackson OR schwarzenegger)" + +If note finds a note, which first line is a topic, then it will +display it's second line. + +These rules apply for the interactive search too. + + + + +=head2 TOPICS + +If topic-support is turned on (which is by default), the various +notes are sorted under various topics. There is no special database +field for the topic. Instead the topic will be stored right in the +note. +If the first line of your note contains some text bordered by slashes +(or whatever you prefer, set "TopicSeparator" in your config! default +is slash), then note will consider it as the topic of this certain +note. For examle: + + B + +If you are using topics, no data after the topic is allowed, if there +is any text, note will consider it as a subtopic! Therefore, don't for- +get to put a newline after the topic-line. + +The list-command will only show you notes under this topic. If you +create a new note, it will automagically inserted under the current +topic (note will prepend the string "/topicname/" to the text of your +note). + +You can create at any time from any point a new topic. Just create a new +note and type the name of the new topic bordered by slashes (or +TopicSeparator) at the first line of this note. After saving, there +will be available a new topic with one note in it. + +You can create as many subtopics as you like, the format is similar to +a filesystem-path. An example, say, you want to create such a +structure: + + (root - top level) + | + |----test + | |----subtopic + | | |--note 1 + | | |--note 2 + | | + | |--note 4 + | + |--note 3 + +Then you may create those 4 new notes: + + --- snip --- + /test/subtopic/ + note 1 + --- snip --- + /test/subtopic/ + note 2 + --- snip --- + note 3 + --- snip --- + /test/ + note 4 + --- snip --- + +I hope, you got the point ;-) + +If a note does not contain the "magic" /topic/ construction on the first +line, it will be listed under the "root" of note, that is the point +you are at the startup of note. + +You can subsequently move a note without a topic to a certain topic. +Simply edit it and insert at the first line the above mentioned +construction. + +Note: Please don't forget the prepending and appending a slash of a +topic. You will get strange results without it! + + + + +=head2 INTERACTIVE MODE + +If you start note with the commandline flag B<-i>, then it starts +with an interactive interface. +It will start with a listing under the default top-topic ("/"). +You can enter the name of a topic to change to that topic. This works +similar to a filesystem structure. The current topic will be +displayed on the top of the screen. + +The following commands are available: + +=over + +=item B + +This command lists all notes with a timestamp. If you specify a topic, it +will only list the notes under this topic. If you are under a certain subtopic, +then it will only display the notes under this topic. + +=item B + +This commands behaves similar to B but it does not display the timestamp. +You can achieve the same result by simply pressing enter at any time. + + +=item B + +You can create a new note by simply pressing B or B. You favorite +editor will be started and you can enter your note text. If you are already +under a topic then this new note will automatically go to this topic. +note adds an aditional line to the top of the note with the topic. But +you can of course specify your own topic. + +Note will tell you which number it has assigned to the newly created note. + +=item B + +By entering B or B and a note-number you can edit an existing note +using your favorite editor. This way you can also move an existing note +from one topic to another one by editing the first line of the note. + + +=item B + +B or B deletes one or more existing note(s). It requires a note number +or a set of note numbers. 1-5 and 1,7,9 are possible values. +After one or more notes has been deleted note will recount all remaining notes. +Say if you delete 1 and 2, then 3 will become 1, 4 will become 5 and so forth. + + +=item B + +You can search for the occurence of a text in your notes-database with the +command B or B. If you omit an expression note will ask you for one. + + +=item B + +This prints a tree-view of your topic-structure. B displays the tree with +notes, B displays just the topics without notes. + + +=item B + +Change the actual topic under which you are. This works identical like just +entering the topic but it has some advantages. You can enter B if +you want to go one level up in the topic-structure. And you can enter B +to go to the top of the structure. +Additional it is possible to enter a note-number instead of a topic name. +For this feature to be active you need to set the config option B +to B<1> or B. If you use a number and the note with this number is +under a certain topic then you will "cd" to this topic. This allows you +to do kind of jumps over multiple levels of topics. + +=item B + +Display a short help screen. + + +=item B + +Quit note. + +=back + + + + + +=head2 BACKUP + +You can also dump the contents of your note-database into a +ASCII-textfile(I<-D>). You can use this file later to import it into +your note-database(-I). This is usefull, if you want quickly trans- +fer your notes from one host to another (i.e. you could mail +your note-dump form your office to home and import it there +for further use). + +The dumps from the two versions of note are in the same format. +Using dumps it is also possible to reinitialize your database. You +can use the "-o" switch whcih causes note to overwrite your existing +database. This is very handy if you changed heavily your config. And +it is required, if you changed: encryption, db-driver, (binary-format) +and the password. You can use the following command for reinitializing: + + $ note -D - | note -o -I - + +What the hell, does this do?! Step by step: + +=over + +=item * + +B creates a note-database dump and prints it out +to stantdard output. + +=item * + +B<|> this is the shell's pipe command. It takes the output +of the left program and gives it to the right program as +standard input. + +=item * + +B imports a note-database dump from standard +input and overwrites an existing database. + +=back + +Before you use the B<-o> switch, I consider you to make a backup! + + + + + +=head2 FORMATING + +Another very nice feature is the possibility to format the note-text +(as much as shell allows it). First, you can use the note-internal +"magic-strings" for colorizing. Those strings looks much like HTML: +"here is a green line of text no more green." +As you see, the beginning of another color starts with a tag(kinda) of +the color and ens with an end tag . + +The following colors are available: +black, red, green, yellow, blue, magenta, cyan and white. + +Beside colorizing text, you can also create bold or underlined text! If +you decide to use this (additional) feature, you need to set the +Config-Option "FormatNotes" to 1 which turns it on. +Usage is very straightforward, if a word (a word is defined as some +text with at least one space surrounded) is between a magic mark- +character. Here are the available things, you can do: + + bold: **word** + underlined:__word__ + inverse:{{word}} + +The text will be formatted using the actually note-color. + + + +=head1 ENCRYPTION + +You can turn on encryption from the config file. +Simply set UseEncryption to 1. Please note, that you need +to decide, if you want to use encryption before the first use +of note! If have already a note database and want to "migrate" +to encryption, I suggest you to follow the directions in the +file UPGRADE! + +You can choose from different encryption algorythms. The default +is IDEA, but DES or BLOWFISH is also possible. You need to have +installed the following additional perl-modules on your system: +MD5 +Crypt::IDEA +Crypt::DES +Crypt::CBC + +After turning on encryption, note will ask you for a passphrase +everytime it runs! It will *not* store this passphrase! +So, don't forget it! Be careful! + + + + +=head1 CONFIGURATION + +You can use a configuration file with note but it is not required. +Note will use default values if there is no config. + +The default config file is B<~/.noterc>. You may specify another +one with the commandline flag I<--config>. + +Comments start with #, empty lines will be ignored. +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). + +For a detailed explanation of each possible parameter take a look +at the supplied sample configuration file in B. + + + + +=head1 SEE ALSO + +See the usage guide in the README or visit the note website: +http://www.0x49.org. + + + +=head1 AUTHOR + +Thomas Linden + + + + +=cut \ No newline at end of file