hnb-1.9.18/0000755000175000017500000000000010217446121011737 5ustar jimjim00000000000000hnb-1.9.18/COPYING0000644000175000017500000004313107723016222012777 0ustar jimjim00000000000000 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) 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) year 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. hnb-1.9.18/Makefile0000644000175000017500000000154607723016222013410 0ustar jimjim00000000000000 src/hnb: src/*.c src/*.h src/*.inc src/hnbrc.inc (cd src;make) install: src/hnb install -D src/hnb /usr/local/bin/hnb install -D -m444 doc/hnb.1 /usr/local/man/man1/hnb.1 clean: (cd src;make clean) (cd util;make clean) rm -f *~ rcupdate: updaterc updaterc: src/hnbrc.inc src/hnbrc.inc: doc/hnbrc (cd util;make) echo -n "\"">src/hnbrc.inc cat doc/hnbrc | util/asc2c >> src/hnbrc.inc echo "\"">>src/hnbrc.inc tar: updaterc clean hnb.spec config.h mkdir hnb-`cat VERSION` cp -r * hnb-`cat VERSION`; tar cvzf ../hnb-`cat VERSION`.tar.gz hnb-`cat VERSION` rm -rf hnb-`cat VERSION` config.h: VERSION cp config.h config.h.tmp cat config.h.tmp | sed 's/VERSION .*/VERSION "'"`cat VERSION`"'"/' > config.h rm config.h.tmp hnb.spec: VERSION mv hnb.spec hnb.spec.tmp cat hnb.spec.tmp | sed "s/Version:.*/Version: `cat VERSION`/" > hnb.spec rm hnb.spec.tmp hnb-1.9.18/README0000755000175000017500000002776407723016222012645 0ustar jimjim00000000000000HIERARCHICAL NOTEBOOK hierarchical notebook (hnb) is program to organise, many kinds of data in one place, for example addresses, to-do lists, ideas, book "reviews", brainstorming, organising a speech, making a structured packing list random notes, and probably many more I haven't thought of yet.. HOW TO GET hnb? new releases and information about hnb will appear at hnb's home page http://sourceforge.net/projects/hnb/ INSTALLING hnb if you've got a source release you must first compile hnb,.. see further down in this file for instructions. Windows the windows binary distribution, is a .zip file containing the executable, this README file, an sample database, and the license for hnb's use. the binary is stand alone, so you can just copy it wherever you'd like it to reside. Linux the Linux binary distribution is a .tar.gz file containing the executable, this README file, a an sample database, and the license for hnb's use. The binary is dynamically linked against ncurses just place it anywhere in your path.. like /usr/bin, /usr/local/bin or /home/user/bin COMPILING hnb hnb uses a custom Makefile, that should work on most unix'ish systems with a curses library. make su (enter root password) make install USAGE DOCUMENTATION If you start hnb without any parameters and no default database, or with the -t or --tutorial option, hnb will load a special tutorial database. CHANGELOG 1.9.18 fixed segfault reported by thomas sattler, due to faulty handling of NULL input in node_get fixed segfault occuring when selecting the first menu item directly added autosave, and warning for concurrent sessions 1.9.17 bug fix, when saving hnb DTD, I also saved the text attribute removed the format names from prefs.c,.. now the string specified is used instead, (makes extending easier) improved the tokenizer for libcli, it now acts almost exactly as bash, even the hooks for understanding $variable_expansion is included in the code, uses a single malloc various bug fixes cleanups and merging of commands, e.g. go_root, go_recurse, and go_backrecurse are now go search now is a single command taking direction and query as arguments. changed escape to be the key used to bring up the menu,.. and remapped ^Q to be quit (again) 1.9.16 attempts to fix the compile on OSX renaming mergesort to node_mergesort due to nameclash only compiling the static lib made indent and outdent only work when there is no data typed already, (thus making > and < allowed typed in navigation mode as long as they're not the first character typed. removed errors appearing with -pedantic (at least here) removing all macros with variable arguments replacing them with va_list removing inline statements from libcli created an utility function for string replacements, that I inserted into all the various import/export filters. added a function "insert_cal " which inserts the specified month/year in a fashion that makes hnb useable as a simple timeplanner as well. (when I get around to adding support for clones, this might be interesting) allowing the user to use <,>,+ and - when typing in new data without erratic behavior, and not the need to enter edit mode. (except if it is the first char of the data) fixed an issue with creating the first child, and pressing insert, and various other commands,.. added rpm spec file from Asgeir Nilsen made file_opml and file_hnb interpret all attributes implemented buffered reading for the xml tokenizer changed the function prototype for functions that register with libcli, they must now register with an int (int argc, char **argv, void *data) function overhauled hnb to use this API, some more refinement might be needed in someplaces, but it seems to work OK for now. added a menu that is accesed from F9 1.9.15 outdent fixed to be more efficient and work as intended added export context changed all import/export functions to use the query variable if filename passed is * 1.9.14 bugfix: The new sort and shuffle functions could result in dataloss when saved. new feature: expand/collapse and expand_all/collapse_all are new bindable functions, expand/collapse is bound to +/- in the default config file, they force portions of the tree to stay open even when you leave it. 1.9.13 Apparently I broke the nasty quick-sort I had implemented, when I changed the way the tree was stored. Implemented a Merge-sort which is faster anyways. Improved the behavior of non fixed navigation when the whole tree is displayed. Added a shuffle function (not currently bound), I used it while developing the new mergesort, but someone might find it useful. 1.9.12 Changed the datastructure to use a "assosciation list" for storing the actual data. Will move all tags, like checkbox to this structure. Should actually make it possible to do the addition of start end date and other "columns" a breeze, perhaps even automatic for some export/import formats modified tree_duplicate to use the new node_duplicate function, and a modified version of the import_node which takes a single node with data set as input. added import_node_text which disregards all other data items 1.9.11 changed node_swap to only swap relational pointers, thus making it easier to extend the data stored in Node later thus also changing and move node, indent/out-dent and sort to accommodate for a truer swap fixed a bug with editing of newly introduced child note: should perhaps move ui_action_edit into a built-in command that is handled specially since it now needs special attention by being a subcommand to ui_action_command 1.9.4-1.9.10 feb 2003 re-implementation of positioning of selection bar in non fixed mode massive code cleanup and separation separation of variables from prefs.* to static variables in the code modules where they belonged integration with spell checker (Ispell, but through prefs it could easily be made Aspell instead) new preferences format ability to execute commands and running mail-client / web-browser if a node or it's children contain url's / mail addresses OPML import and export postscript export htmlcss export save_state and restore_state for single level undo where needed new XML tokenizer cut/paste functionality 1.9.3 jan 2003 stabilising of the code ability to use default terminal colours, (patch from NN) 1.9.1 oct 2002 option to remember current position in hnb file when saving/loading cleaned up most of the help-system code further code separation 1.9.0 oct 2002 fixed the movement behaviour when going to the parent node,.. the screen jumped too much separated the various export and load filters into own files used my new libcli for the cli code, and as "glue" in some code spots reverted to a manual makefile instead of autoconf/automake improvements to dynamic key-bindings, multiple key-bindings for each action, all key-bindings in various context got their own choice in the preferences. The first of the actual key-bindings shown as help added some more bindings for the node editor, (skip word and bskip word, hooks for even more) 1.8 30 aug 2001 changed the default window scrolling behaviour to move the selection bar instead of the whole screen when possible integrated libxml support changes from orang@imonk.com added flag to keep whitespace when loading XML file 1.7 6 jul 2001 made the tutorial save-able, if opened in place of the default database fixed sorting segfault BSD curses workaround,.. does it work? changed percentage calculation algorithm cleanup of the node drawing code integrated priorities integrated Andrew J. Webers libxml2 import/export filters preferences items mouse bullet mode prefs revision checking priority colours bold mode colours configurable keyboard redefinition 1.6 25 may 2001 generic XML import and export filter preferences colour settings todobox fixes percentage calculations fixes XML tag shortcuts macrofied node. 1.5 19 may 2001 switched to autoconf/automake joining/splitting of nodes. hooks for priority setting (press ^P on a to-do node) added import/export of XML optimisations update to man-page update documentation default format is now XML commented all header-functions 1.4 16 may 2001 added preferences saving/loading replaced tab char in display with a space. removal of temporary node, when issuing insert in a new leaf. cli mode, for use in scripts etc. pipe export by Karsten Hilbert automatic generation of README.html 1.3 14 may 2001 bloat various feedback changes debug mode for my own sake added collapse-views 1.2 12 may 2001 added mouse navigation code cleanups improved navigation in edit mode improved pgup/pgdn 1.1 10 may 2001 ran all the files through indent indent -bad -bap -br -ts4 -ce -ci4 -i4 -cli4 -cbi0 -ss -di0 -nbc -npsl -T Node -brs -ip4 -bbo --line-length78 changed the editor cursor minor code tweaks and cleanups added manpage by Andras BALI switched to bold indication of subnodes fixed grabbing of nodes (copy/move) improved tree.c, multiple trees are now possible 1.0 21 april 2001 changed ctrl+space for marking to ctrl+g in win32 port bullet system for all nodes ( +/- [X] [ ] ) added copying feature better user feedback when moving various fixes 0.9 15 april 2001 end of easter holdidays undefined keyboard debugging in win32 port added in-binary tutorial, and export mode for the include file changed curses mode to raw upon request from Marck Rintsch, ctrl+s now saves the file added more visual feedback when saving, quitting and such added an standard bullet on all entries. 0.8 15 april 2001 ascii export html export (doesn't escape any html by itself) latex export doesn't work for deeper nesting levels than four postscript export based on the latex export uses system calls and requires latex, and dvips loading(insertion) of an external file into the db added done percentage 0.7 13 april 2001 rearranged input structures added todo checkboxes added error display remade the help system fixed resizing made search case insensitive refined search control interface 0.6b 11 april 2001 the guadec hacked fixes on strics computer worked on search ability fixed the display of confirm mode in curses ui. added reparenting cleaned up node_remove added load,save and display of todo in standard file format changed to bz2 format on distribution file 0.5 help item's update added insert in the interface 0.4 march 2001 added registry functions small bugfix for node recurse() (go right, and to top) fixed tab'ing into children of empty nodes bug fixed wordwrap 0.3 15.oct 2000 first rendition of cgi-bin browser wordwrap added registry added resize functionality pageup/pagedown changes to help/confirming interface AUTHORS hnb authors Øyvind Kolås project maintainer Andras BALI Debian Package manual page Karsten Hilbert pipe export Martin van Beilen various todo/done issues in the code Andrew J Weber libxml2 import/export BUGS slashes (/) inside nodes are not escaped correctly in cli mode bullets/todo boxes, doesn't check that the line is writable (top of screen on multi-line nodes) TODO buffer limits they are high,.. but a really long node might crash it more entities on each node current entities: priority title/data todo item done/not done future items: created date modified date due date, for project planning details dialog for each node to modify such things cronological id purge todo items on lower levels curses interface "context" menu for mouse mode gtk 2.0 start make a dead tree copy of the source for examination enscript *.h *.c -E --output uts.ps -U 2 -j make it stop outdent when - is pressed without being in edit mode,.. and characters are typed. hnb-1.9.18/VERSION0000644000175000017500000000000707723016222013007 0ustar jimjim000000000000001.9.18 hnb-1.9.18/config.h0000644000175000017500000000016407723016222013361 0ustar jimjim00000000000000 #define PACKAGE "hnb" #define VERSION "1.9.18" #ifdef WIN32 #define snprintf(a,b,args...) sprintf(a,args) #endif hnb-1.9.18/doc/0000755000175000017500000000000007723016222012507 5ustar jimjim00000000000000hnb-1.9.18/doc/hnb.10000755000175000017500000000344007723016222013344 0ustar jimjim00000000000000.TH HNB SECTION "May 15, 2001" .SH NAME hnb \- Hierarchical notebook .SH SYNOPSIS .B hnb [\fIfile\fP] [\fIoptions\fP] [\fIcommand\fP [\fIcommand\fP] .. ] .SH DESCRIPTION This manual page documents briefly the \fBhnb\fP hierarchical notebook. \fBhnb\fP is an ncurses program to organize many kinds of data in one place, for example addresses, todo lists, ideas, book reviews or to store snippets of brainstorming, to make a structured packing list or just to take random notes. It can export ascii/html/latex/postscript, supports todo checkboxes, checkbox trees with percentages and searching. \fBhnb\fP uses a simple ascii file for storing your notes. This file can be specified on the command line. If not specified, ~/.hnb is loaded (or created if missing). .SH OPTIONS \fBhnb\fP can be invoked with the following options: .TP .B \-h, \-\-help Show summary of options. .TP .B \-v, \-\-version Show version of program. .TP .B \-t, \-\-tutorial Load the tutorial instead of a database. .TP .B \-rc <\fIfile\fP> Load an other config file than default. .TP .B \-ui Specify user interface to use. .TP .B \-e Run commands in noninteractive mode (start hnb with the cli ui and type `help' to get more information). .SH FILES .IP ~/.hnb The default file for your notes. To use an other, specify its name on the command line. .IP ~/.hnbrc The default configuration file. To load an other config file than default, use the \fB-rc\fP command-line option. .SH SEE ALSO For more information on the usage of the program, load the tutorial or press \fBF1\fP in the program. hnb homepage: http://hnb.sourceforge.net .SH AUTHOR hnb was written by 0yvind Kolas . This manual page was written by Andras Bali , for the Debian GNU/Linux system (but may be used by others). hnb-1.9.18/doc/hnbrc0000644000175000017500000003612407723016222013534 0ustar jimjim00000000000000# configuration file for hnb, # # use a tab-spacing of 4 when editing this file, or edit it thorugh # hnb with "hnb -a ~/.hnbrc" to take advantage of the indentation in it # # (please be aware that this is the configuration file for a development version, # things might change drastically soon,.. or perhaps later) ##### bullets # what kind of bullets are displayed before each item ##### samples #bullet_parent " -" #bullet_parent " *" #bullet_parent " ·" #bullet_parent_expanded " +" #bullet_parent_expanded " *" #bullet_parent_expanded " ·" #bullet_leaf " *" #bullet_leaf " -" bullet_leaf " ·" bullet_parent " +" bullet_parent_expanded " -" ##### user interface ##### display format # defining how each node is displayed, the display string syntax is # interpreted as follows: # # spaces turn into real spaces, i means indentation, - means bullet, # d means the real data of the node, x is a temporary placeholder for # upcoming column-types,. (for debugging only) # # i and x can take an argument specifying how many characters wide # the field should be # # until further features are added, only the multiplier after # indentation actually does something # # indicates node number (actually line number when used as a folding editor) ##### samples #display_format # "i4- d" display_format "i4- d" ##### fixed focus # lock the selection bar to a position 1/3 down the screen fixedfocus "0" ##### external commands ##### http:// handler # what command is executed when a user wants a action performed on a # entry containing an URL # # * is substituted for the URL # # the X ones have their error and standard output redirected to dev/null # and are put into the background to keep hnb running afterwards ##### samples #web_command "opera -remote 'openURL(*)' > /dev/null 2>&1 &" #web_command "netscape -remote 'openURL(*)' > /dev/null 2>&1 &" #web_command "netscape -remote 'openURL(*,new-window)' > /dev/null 2>&1 &" #web_command "mozilla -remote 'openURL(*)' > /dev/null 2>&1 &" #web_command "mozilla -remote 'openURL(*,new-window)' > /dev/null 2>&1 &" #web_command "konqueror * > /dev/null 2>&1 &" #web_command "galeon -n > /dev/null 2>&1 &" web_command "w3m *" #web_command "lynx *" #web_commend "rxvt -fn fixed -rv +sb -e w3m * > /dev/null 2>&1 &" #web_command "opera -remote 'openURL(*,new-window)' > /dev/null 2>&1 &" ##### mail@handler # what command is executed when a user wants a action performed on a # entry containing a mail-address # # * is substituted for the mail-address # ## samples #mail_command "xterm -rv pine * > /dev/null 2>&1 &" #mail_command "xterm -rv +sb -e mutt * > /dev/null 2>&1 &" #mail_command "pine *" mail_command "mutt *" ##### spell checking # the spell-checker used # ## samples #spell_command "aspell -c" #spell_command "ispell -x" #spell_command "ispell -x -damerican" #spell_command "ispell -x -dbritish" #spell_command "ispell -x -dbokmål" #spell_command "ispell -x -dnynorsk" spell_command "ispell -x" ##### file formats ##### Default Format # hnb, opml, xml, ascii are possible choices format "hnb" ##### Remember current position in tree # wheter hnb remembers the current position in a file, (currently # supported by the hnb DTD only, but might easily be extended since # it fakes it with a XML comment) 1=true 0=false savepos "1" ##### XML format ##### XML Cuddling # When loading xml files, should data be allowed on # the same line as tags? xml_cuddle "0" ##### Autosave # when nodes_changed reaches above threshold, invoke autosave autosave_threshold "15" autosave_threshold_nodes_changed "0" # if change has occured but is less than threshold, save when number # of "ticks"/keypresses, invoke autosave autosave_timeout "50" autosave_timer "0" ##### Color/style # color scheme configuration, syntax is: # "style " # legal items are shown below # colors are: blue, cyan, green, red, magenta, yellow, black and white # attributes are: normal, reverse, bold, underline macro define 'style_standard' style menuitem default/default reverse style menutext cyan/default normal style parentnode default/default bold style node default/default normal style bullet cyan/default normal style selected yellow/red bold style parentselected yellow/red bold style background default/default normal end macro define 'style_alternate' style menuitem red/white normal style menutext black/white normal style parentnode default/default bold style node default/default normal style bullet yellow/default normal style selected yellow/blue normal style parentselected yellow/blue bold style background default/default normal end macro style_standard ##### key-bindings # # syntax: # "bind " # # multiple actions can be chained together by using the virtual key ".." # as the following key-binding # ################################################## context main helptext "ESC| menu || |F2| save || |F5| commandline || |return| edit | bind f1 'status "Take a look at ~/.hnbrc to check out the configuration"' bind .. 'status "there you will also find details about the available keybindings."' bind .. 'status "please feel free to contribute more useful keybindings and helptexts..."' bind esc menu bind ^Q 'context quitsave' bind f5 'commandline' bind .. 'status --clear' bind f6 'macro m_spellcheck' macro define m_spellcheck context spellcheck save_state spell end bind ^E 'context export' bind ^L 'context import' bind ^F 'macro m_search' macro define m_search context search save_state getquery "enter keyword to search for" search -f "$query" end bind f9 menu bind f10 'context user' bind ^G 'context grab' bind .. 'save_state' bind ^A 'action' bind up up bind down down bind left left bind right right bind npage pagedown bind ppage pageup bind home "go root" bind return edit bind del remove bind ins insert_below bind .. edit bind tab complete bind ^T toggle_todo bind ^D toggle_done bind > indent bind < outdent bind f2 save bind ^X save_state bind .. cut bind ^C copy bind ^V paste bind .. down bind ^S save_state bind .. sort bind backspace backspace bind backspace2 backspace bind sleft "movenode left" bind sright "movenode right" bind sprevious "movenode up" bind snext "movenode down" bind + expand bind - collapse bind ^Z restore_state context nodeedit helptext "editing node | |ESC| revert || |return| confirm" bind up up bind down down bind left left bind right right bind return confirm bind esc cancel bind ^S split bind ^J join bind backspace backspace bind backspace2 backspace bind ^A bol bind home bol bind ^E eol bind end eol bind del delete context lineedit helptext lineedit bind up up bind down down bind left left bind right right bind return confirm bind esc cancel bind tab complete bind backspace backspace bind backspace2 backspace bind del delete bind ^A bol bind home bol bind ^E eol bind end eol context confirm helptext " y | | j | |return| confirm || |any key| cancel" bind y confirm bind j confirm bind return confirm bind any cancel context quitsave helptext "Save on exit? | | Y |es | J |a || | N |o || |ESC| cancel" bind Y save bind .. quit bind y save bind .. quit bind J save bind .. quit bind j save bind .. quit bind N quit bind n quit bind esc "context main" bind any unbound context spellcheck helptext "Spellchecking | |Space| next node |ESC| cancel |F6,Return| confirm changes" bind space "go recurse" bind .. spell bind down "go recurse" bind .. spell bind up "go backrecurse" bind .. spell bind return "context main" bind f6 "context main" bind esc restore_state bind .. "context main" bind any unbound context grab helptext "Node grabbed | |return| |space| drop here || |ESC| cancel" bind esc restore_state bind .. "context main" bind return "context main" bind space "context main" bind left "movenode left" bind right "movenode right" bind up "movenode up" bind down "movenode down" bind any unbound context export helptext "Export | | A |scii || | H |tml html| C |ss | P |ostscript | O |PML |ESC| cancel " macro define m_export_ascii save_state go root getquery 'what file should I save the ASCII output in?' export_ascii $query restore_state context main end macro define m_export_html save_state go root getquery 'what file should I save the HTML output in?' export_html $query context main restore_state end macro define m_export_htmlcss save_state go root getquery 'what file should I save the HTML/CSS output in?' export_htmlcss $query context main restore_state end macro define m_export_opml save_state go root getquery 'what file should I save the OPML output in?' export_opml $query context main restore_state end macro define m_export_ps save_state go root getquery 'what file should I save the PostScript output in?' export_ps $query context main restore_state end bind esc "context main" bind A "macro m_export_ascii" bind a "macro m_export_ascii" bind H "macro m_export_html" bind h "macro m_export_html" bind C "macro m_export_htmlcss" bind c "macro m_export_htmlcss" bind O "macro m_export_opml" bind o "macro m_export_opml" bind P "macro m_export_ps" bind p "macro m_export_ps" bind any unbound context import helptext "Import | | A |scii | O |PML | H |hnb |ESC| cancel " bind esc .. bind .. "context main" bind A .. bind .. 'getquery "what file should I import ASCII from?"' bind .. 'import_ascii "$query"' bind .. 'context main' bind a .. bind .. 'getquery "what file should I import ASCII from?"' bind .. 'import_ascii "$query"' bind .. 'context main' bind O .. bind .. 'getquery "what file should I import OPML from?"' bind .. 'import_opml "$query"' bind .. 'context main' bind o .. bind .. 'getquery "what file should I import OPML from?"' bind .. 'import_opml "$query"' bind .. 'context main' bind H .. bind .. 'getquery "what file should I import HNB data from?"' bind .. 'import_hnb "$query"' bind .. 'context main' bind h .. bind .. 'getquery "what file should I import HNB data from?"' bind .. 'import_hnb "$query"' bind .. 'context main' bind any unbound context search helptext "Searching | |ESC| cancel || | n |ext || | p |revious || |space|/|return| go" bind down 'search -f "$query"' bind up 'search -b "$query"' bind P 'search -b "$query"' bind p 'search -b "$query"' bind n 'search -f "$query"' bind N 'search -f "$query"' bind return "context main" bind esc "context main" bind .. restore_state bind any unbound context user helptext "Usermenu | |ESC| cancel |F1| ispell language |F2| browser command |F3| expand all |F4| collapse all" bind esc "context main" bind f1 "context user_ispell" bind f2 "context user_browser" bind f3 "expand --all" bind .. "context main" bind f4 "collapse --all" bind .. "context main" bind any "unbound" context user_ispell helptext "Language for ispell: | |F1| Br.english |F2| Am.english |F3| Norwegian bokmål |F4| Norwegian nynorsk" bind f1 'spell_command "ispell -x -damerican"' bind .. 'context main' bind f2 'spell_command "ispell -x -dbritish"' bind .. 'context main' bind f3 'spell_command "ispell -x -dbokmål"' bind .. 'context main' bind f4 'spell_command "ispell -x -dnynorsk"' bind .. 'context main' bind esc 'context main' bind any unbound context user_browser helptext "Browser action: | |F1| w3m replace hnb |F2| w3m in rxvt |F3| Opera, new tab |F4| Mozilla new window" bind f1 'browser_command "w3m *"' bind .. 'context main' bind f2 'web_commend "xterm -T \"w3m spawned from hnb\" -fn fixed -rv +sb -e w3m * > /dev/null 2>&1 &"' bind .. 'context main' bind f3 'web_command "opera -remote 'openURL(*,new-window)' > /dev/null 2>&1 &"' bind .. 'context main' bind f4 'web_command "mozilla -remote 'openURL(*,new-window)' > /dev/null 2>&1 &"' bind .. 'context main' bind esc 'context main' bind any unbound ##### key related options ##### escdelay # how long the program should wait before accepting that ESC(27d) is the # ESC key and not the start of an escape sequence # increase this number if you are using hnb over a slow network link # value given is in ms (1/1000seconds) # escdelay 100 ##### menu definition ##### file menu "File" "------------" "" menu "File" "save F2" "save" menu "File" "save as.. " "macro saveas" macro define saveas getquery db_file 'fila to save' save_state go root export_$format $db_file restore_state end menu "File" "revert " "revert" menu "File" "------------" "" menu "File" "export ^E" "context export" menu "File" "import ^L" "context import" menu "File" "------------" "" menu "File" "spell chk F6" "macro m_spellcheck" menu "File" "expand all" "expand --all" menu "File" "collapse all" "collapse --all" menu "File" "statistics" "macro stats" macro define stats status "file: \"$db_file\" format:$format" mem stats end menu "File" "------------" "" menu "File" "exit ^Q" "context quitsave" ##### edit menu "Edit" "---------" "" menu "Edit" "copy ^C" "copy" menu "Edit" "cut ^X" "cut" menu "Edit" "paste ^V" "paste" menu "Edit" "---------" "" menu "Edit" "Search ^F" "macro m_search" ##### entry menu "Entry" "--------------" "" menu "Entry" "edit return" "edit" menu "Entry" "delete del" "remove" menu "Entry" "--------------" "" menu "Entry" "do action ^A" "action" menu "Entry" "indent >" "indent" menu "Entry" "outdent <" "outdent" menu "Entry" "toggle todo ^T" "toggle_todo" menu "Entry" "toggle done ^D" "toggle_done" menu "Entry" "expand +" "expand" menu "Entry" "collapse -" "collapse" ##### level menu "Level" "------------" "" menu "Level" "sort ^S" "sort -a" menu "Level" "sort (desc.)" "sort -d" menu "Level" "shuffle " "sort -r" ##### context main macro define m_about status "hnb - hierarchical notebook http://hnb.sourceforge.net/" status "(c) Øyvind Kolås 2001-2003 pippin@users.sourceforge.net" end macro m_about hnb-1.9.18/doc/Documentation.hnb0000644000175000017500000004553207723016222016022 0ustar jimjim00000000000000 ]> Introduction to hnb Introducing hnb hnb is an hierarchical notebook, that is an editor that focuses on editing and managing information in a hierarchical manner. This type of editor is also known as an outline editor. hnb was written as a personal itch of the author, he knew no other such program and thought out how he wanted it to work. Some of the additional features in hnb have been inspired by other similar programs. I the author, Øyvind Kolås <pippin@users.sourceforge.net> use hnb to maintain my contact list, my to-do lists, my calendar, writing documentation, reports, random ideas, and structuring various content. Installing hnb Unix prepackaged binaries prepackaged binaries for hnb exist for some operating-systems/distributions, these might not be the latest versions. Andras Bali maintains a Debian package of hnb, which can be installed by issuing apt-get install hnb Patrick Li maintains a Free-BSD ports package of hnb, I don't know how to install it on Free-BSD. compiling hnb comes packaged in a tar.gz file, this file contains a Makefile, hopefully installing hnb is as simple as: make su <enter root password> make install platform specific workarounds SuSE Linux: SuSE Linux doesn't install ncurses as curses, which ncurses actually does by default if it is allowed to. Changing the CFLAGS line in src/Makefile to -lncurses instead of -lcurses makes hnb compile on SuSE OS X / Darwin: the preprocessor that OS X uses doesn't work properly. Adding -no-cpp-precomp to the Makefile should make it compile properly on OS/X as well Starting hnb When you start hnb it automatically loads the default database, ~/.hnb and lets you edit it, this is to make it convenient to have your personal information like contacts and to-do list readily available. If ~/.hnb doesn't exist a sample database will be loaded instead The full commandline usage for hnb is hnb [options] [filename] [-e "comand" ["command" ["command" ..]]] options: -h or --help show recognized options -a or --ascii use tab indented ASCII for loading/saving database ASCII doesn't remember attributes like to-do status, done etc. -o or --opml use OPML DTD for loading/saving database -x or --xml invoke hnb as a XML editor --hnb use hnb DTD for loading/saving database, this is the default unless you've changed it in the preferences file running commands by running hnb -e "go_root" "oexport_htmlcss test.html" hnb will load the default database, go to the start of the database, and export it with the htmlcss filter to a file called test.html In the latest version hnb also contains a menu that can be invoked by pressing ESC, more commands are available by invoking the commandline (F5). Quitting hnb By pressing ctrl+q, hnb will ask you whether you want to quit or save and quit, press ESC to cancel Importing data To import the contents of another file, you press ^L (Ctrk+L), you will then get a list of choices of format to import from. Choose the desired format Enter the relative or full path of the filename you want imported. hnb will add that file under the current level. Exporting data To export the current tree to another file. press ^E (ctrl+E) Choose the desired format Enter the relative or full path of the filename you want to write to. Printing hnb doesn't support printing to a printer directly, but by using an intermediate format you can get some quite good printouts, a good candidate is the HTML/CSS format. Using Outlines Managing entries Navigating amongst entries The arrow keys will move you amongst the entries in the tree, you may also start typing the name of a entry that exist on the current level, and hnb will take you to the entry that matches what you've typed, pressing tab twice will enter the sub-level of the current entry, this behavior is modeled after the name completion in Unix shells. PageUp/PageDown will skip a large amount of entries up and down. Home will bring you to the "root" (the first entry) of the tree. Searching ^F will ask you for a search term, you may thereafter navigate amongst the occurrences of the search term with up/down n/p, pressing space or return will make you stop where you found the substring, ESC will bring you back to where you started the search. Moving entries You can move entries either by pressing shift and using the arrow keys, the entry will then move within the constraints of the hierarchical structure. You can also move entries by cutting and pasting a entry, this has much of the same effect, cut is instantiated with ^C and the paste command is ^V Adding entries Pressing insert will add a new entry below the current. You will also immediately enter edit mode. You may also exploit the fact that searching by keyboard for a entry that doesn't exist, and pressing enter, will create the entry name that you entered. Deleting entries If you press delete the current entry will be deleted, if it has children you will be asked to confirm the action. Cutting can also be used to remove data, no confirmation will be asked whether you want to fulfill you action or not, but the data will be available from the clipboard. Indenting and Outdenting entries > will move the current entry and all the following entries of the same level to be children of the preceding entry. < will move the current entry and all the following entries of the same level to follow the parent of the preceding entry. Expanding and Collapsing entries expanding pressing '+' on a entry with sub entries will display the sub entries even when you're not within them, thus displaying a larger portion of the tree. collapsing Pressing '-' has the opposite effect of '+' it hides the expanded entries operations working on the whole outline pressing F10 brings up the user menu,.. a menu where miscellany commands that don't fit anywhere else are added,.. here you may expand or collapse all entries in the current tree. Editing entries Pressing Return will start editing the current entry, now the cursor keys move between the characters of the data in the entry instead amongst the entries (most) Default editing shortcuts Splitting entries When editing a entry you may press ^S, the entry being edited will be split in the current position. The data to the left of the cursor will be retained in the current entry, whilst the remaining data will be inserted in a new entry below. Joining entries Pressing ^J whilst editing a entry will join the following entry, (as long as it doesn't have sub-nodes) will merge the data in; at the end of the entry being edited. Spell-checking By default hnb is configured to use ispell for spell-checking. Pressing F6 will spell-check the current entry Ispell will start and guide you through the unmatched words in the current entry. Thereafter you can press space to spell check the next entry, escape to cancel the changes or return to accept the changes made. Sorting entries pressing ctrl+s will sort the entries on the current level Other features Todo-list mode ^T toggles checkmarks instead of bullets,. ^D checks or unchecks the checkmarks. percentages are shown for unchecked parents that have checked subentries Using URLs If an entry contains a web url ^A will bring up the configured web browser, (see your ~/.hnbrc for more information about configuration) Calendars From the commandline you can issue a command like "insert_cal 3 2003" to insert a calendar template. Using Email addresses If an entry contains a email-address ^A will bring up the configured mail client, (see your ~/.hnbrc for more information about configuration) Configuring hnb Nothing here yet, please examine your ~/.hnbrc (created automatically the first time you run hnb) for information. sample data This is a stripped down version of the authors default database.. the real database contains >4000 entires contacts frodo baggins or perhaps underhill 555-12341324 frode@bagend.net merry meridoc somthing 555-23234324 peregrin took aka pippin pippin@users.sourceforge.net sam gamgee samwise 555-12341234 sam@gamgee.com calendar 2003 March Sat_01 Sun_02 Mon 03 Tue 04 Wed 05 Thu 06 Fri 07 Sat_08 Sun_09 Mon 10 Tue 11 remember to do some stuff Wed 12 Thu 13 Fri 14 Sat_15 Sun_16 got some sub entries on my todolist here,.. Mon 17 Tue 18 Wed 19 Thu 20 Fri 21 Sat_22 Sun_23 Mon 24 Tue 25 Wed 26 Thu 27 Fri 28 Sat_29 Sun_30 Mon 31 2003 April Tue 01 Aprils Fool need to find some good ideas for jokes Wed 02 Thu 03 Fri 04 Sat_05 Sun_06 Mon 07 Tue 08 Wed 09 Thu 10 Fri 11 Sat_12 Sun_13 Mon 14 Tue 15 Wed 16 Thu 17 Fri 18 Sat_19 Sun_20 Mon 21 Tue 22 Wed 23 Thu 24 Fri 25 Sat_26 Sun_27 Mon 28 Tue 29 Wed 30 to-do hnb todo force all expanded clones calendar new documentation start asdfasdfadsf blah asdfasdf asdfasdf revert to last saved version known bugs insert bug press right type data press insert data is lost,.. show all of bottommost node when possible menu working dynamic display of keybindings (unprobable) add real percentages again,.. so I don't have to fake it like I did above on new documentation,.. autosave school notes from exam cramming,.. paper outlines ... work I've removed quite a lot of the stuff I actually keep in my database... movie manuscripts one of them made,.. some of them in planning,. I don't want everybody to see them,.. but it's an actual node in my database bookmarks http://hnb.sourceforge.net/ norwegian short film festivals http://www.kortfilmfestivalen.no/ http://www.minimalen.com/ news k5 http://www.kuro5hin.org/ slashdot http://slashdot.org/ nettavisen http://www.nettavisen.no/ dagbladet http://www.dagbladet.no/ vg http://www.vg.no/ fark.com http://www.fark.com/ quotes Peoples Front To Reunite Gondwanaland: "Stop the Laurasian Separatist Movement!" slashdot disbelief To anyone who is still stubborn enough to insist that BlackICE Defender is actually good for something: PLEASE do not write to me. I don't want to hear it. I'm a scientist who will not find your mystic beliefs to be compelling. I respect your right to your own opinions, no matter how blatantly they fly in the face of logic and reality. That is, after all, the nature of faith. Happy computing. I suggest prayer. the movie zardoz The gun is good. The penis is evil. The penis shoots seeds, and makes new life, and poisons the earth with a plague of men, as once it was. But the gun shoots death, and purifies the earth of the filth of brutals. Go forth and kill! old I keep a 'trashbin' where I stow away outdated entries,.. just to be able to search it,.. and save it later,.. If you are seeing this the first time running hnb, use your arrow keys to navigate this manual to familiarize yourself with hnb. hnb-1.9.18/doc/Documentation.html0000644000175000017500000004504307723016222016214 0ustar jimjim00000000000000 tree exported from hnb
Introduction to hnb
Introducing hnb
hnb is an hierarchical notebook, that is an editor that focuses on editing and managing information in a hierarchical manner. This type of editor is also known as outline editors.
hnb was written as a personal itch of the author, he knew no other such program and thought out how he wanted it to work. Some of the additional features in hnb have been inspired by other similar programs.
I, that is Øyvind Kolås <pippin@users.sourceforge.net> use hnb to maintain my contact list, my to-do lists, my calendar, writing documentation and reports.
Installing hnb
Unix
prepackaged binaries
prepackaged binaries for hnb exist for some operating-systems/distributions, these might not be the latest versions.
Andras Bali maintains a Debian package of hnb, which can be installed by issuing
apt-get install hnb
Patrick Li maintains a Free-BSD ports package of hnb, I don't know how to install it on Free-BSD.
compiling
hnb comes packaged in a tar.gz file, this file contains a Makefile, hopefully installing hnb is as simple as:
make
su
<enter root password>
make install
platform specific workarounds
SuSE Linux:
SuSE Linux doesn't install ncurses as curses, which ncurses actually does by default if it is allowed to. Changing the CFLAGS line in src/Makefile to -lncurses instead of -lcurses makes hnb compile on SuSE
OS X / Darwin:
the preprocessor that OS X uses doesn't work properly. Adding -no-cpp-precomp to the Makefile should make it compile properly on OS/X as well
Starting hnb
When you start hnb it automatically loads the default database, ~/.hnb and lets you edit it, this is to make it convenient to have your personal information like contacts and to-do list readily available.
If ~/.hnb doesn't exist a sample database will be loaded instead
The full commandline usage for hnb is
hnb [options] [filename] [-e 'comand' ['command' ['command' ..]]]
options:
-h or --help show recognized options
-a or --ascii use tab indented ASCII for loading/saving database
ASCII doesn't remember attributes like to-do status, done etc.
-o or --opml use OPML DTD for loading/saving database
-x or --xml invoke hnb as a XML editor
--hnb use hnb DTD for loading/saving database, this is the default unless you've changed it in the preferences file
running commands
by running
hnb -e 'go_root' 'oexport_htmlcss test.html'
hnb will load the default database, go to the start of the database, and export it with the htmlcss filter to a file called test.html
In the latest version hnb also contains a menu that can be invoked by pressing F9, for advanced commands the commandline (F5) is preferred.
Quitting hnb
By pressing ESC, hnb will ask you whether you want to save or not, if you press ESC again hnb will return to normal operation.
Importing data
To import the contents of another file, you press ^L (Ctrk+L), you will then get a list of choices of format to import from.
Choose the desired format
Enter the relative or full path of the filename you want imported.
hnb will add that file under the current level.
Exporting data
To export the current tree to another file.
press ^E (ctrl+E)
Choose the desired format
Enter the relative or full path of the filename you want to write to.
Printing
hnb doesn't support printing to a printer directly, but by using an intermediate format you can get some quite good printouts, a good candidate is the HTML/CSS format.
Using Outlines
Managing entries
Navigating amongst entries
The arrow keys will move you amongst the entries in the tree, you may also start typing the name of a entry that exist on the current level, and hnb will take you to the entry that matches what you've typed, pressing tab twice will enter the sub-level of the current entry, this behavior is modeled after the name completion in Unix shells.
PageUp/PageDown will skip a large amount of entries up and down.
Home will bring you to the 'root' (the first entry) of the tree.
Searching
^F will ask you for a search term, you may thereafter navigate amongst the occurrences of the search term with up/down n/p, pressing space or return will make you stop where you found the substring, ESC will bring you back to where you started the search.
Moving entries
You can move entries either by pressing shift and using the arrow keys, the entry will then move within the constraints of the hierarchical structure.
You can also move entries by cutting and pasting a entry, this has much of the same effect, cut is instantiated with ^C and the paste command is ^V
Adding entries
Pressing insert will add a new entry below the current. You will also immediately enter edit mode.
You may also exploit the fact that searching by keyboard for a entry that doesn't exist, and pressing enter, will create the entry name that you entered.
Deleting entries
If you press delete the current entry will be deleted, if it has children you will be asked to confirm the action.
Cutting can also be used to remove data, no confirmation will be asked whether you want to fulfill you action or not, but the data will be available from the clipboard.
Indenting and Outdenting entries
> will move the current entry and all the following entries of the same level to be children of the preceding entry.
< will move the current entry and all the following entries of the same level to follow the parent of the preceding entry.
Expanding and Collapsing entries
expanding
pressing '+' on a entry with sub entries will display the sub entries even when you're not within them, thus displaying a larger portion of the tree.
collapsing
Pressing '-' has the opposite effect of '+' it hides the expanded entries
operations working on the whole outline
pressing F10 brings up the user menu,.. a menu where miscellany commands that don't fit anywhere else are added,.. here you may expand or collapse all entries in the current tree.
Editing entries
Pressing Return will start editing the current entry, now the cursor keys move between the characters of the data in the entry instead amongst the entries
(most) Default editing shortcuts
Splitting entries
When editing a entry you may press ^S, the entry being edited will be split in the current position. The data to the left of the cursor will be retained in the current entry, whilst the remaining data will be inserted in a new entry below.
Joining entries
Pressing ^J whilst editing a entry will join the following entry, (as long as it doesn't have sub-nodes) will merge the data in; at the end of the entry being edited.
Spell-checking
By default hnb is configured to use ispell for spell-checking.
Pressing F6 will spell-check the current entry
Ispell will start and guide you through the unmatched words in the current entry.
Thereafter you can press space to spell check the next entry, escape to cancel the changes or return to accept the changes made.
Sorting entries
pressing ctrl+s will sort the entries on the current level
Other features
Todo-list mode
^T toggles checkmarks instead of bullets,. ^D checks or unchecks the checkmarks.
percentages are shown for unchecked parents that have checked subentries
Using URL's
If an entry contains a web url ^A will bring up the configured web browser, (see your ~/.hnbrc for more information about configuration)
Calendars
From the commandline you can issue a command like 'insert_cal 3 2003' to insert a calendar template.
Using Email addresses
If an entry contains a email-address ^A will bring up the configured mail client, (see your ~/.hnbrc for more information about configuration)
Configuring hnb
Nothing here yet, please examine your ~/.hnbrc (created automatically the first time you run hnb) for information.
sample data
This is a stripped down version of the authors default database.. the real database contains >4000 entires
contacts
frodo baggins
or perhaps underhill
555-12341324
frode@bagend.net
merry
meridoc somthing
555-23234324
peregrin took
aka pippin
pippin@users.sourceforge.net
sam gamgee
samwise
555-12341234
sam@gamgee.com
calendar
2003 March
Sat_01
Sun_02
Mon 03
Tue 04
Wed 05
Thu 06
Fri 07
Sat_08
Sun_09
Mon 10
Tue 11 remember to do some stuff
Wed 12
Thu 13
Fri 14
Sat_15
Sun_16
got some sub entries on my todolist here,..
Mon 17
Tue 18
Wed 19
Thu 20
Fri 21
Sat_22
Sun_23
Mon 24
Tue 25
Wed 26
Thu 27
Fri 28
Sat_29
Sun_30
Mon 31
2003 April
Tue 01 Aprils Fool
need to find some good ideas for jokes
Wed 02
Thu 03
Fri 04
Sat_05
Sun_06
Mon 07
Tue 08
Wed 09
Thu 10
Fri 11
Sat_12
Sun_13
Mon 14
Tue 15
Wed 16
Thu 17
Fri 18
Sat_19
Sun_20
Mon 21
Tue 22
Wed 23
Thu 24
Fri 25
Sat_26
Sun_27
Mon 28
Tue 29
Wed 30
to-do
hnb todo
force all expanded
clones
calendar
new documentation
start
asdfasdfadsf
blah
asdfasdf
asdfasdf
revert to last saved version
known bugs
insert bug
press right
type data
press insert
data is lost,..
show all of bottommost node when possible
menu
add real percentages again,.. so I don't have to fake it like I did above on new documentation,..
school
notes from exam cramming,..
paper outlines
...
work
I've removed quite a lot of the stuff I actually keep in my database...
movie manuscripts
one of them made,.. some of them in planning,.
I don't want everybody to see them,..
but it's an actual node in my database
bookmarks
http://hnb.sourceforge.net/
norwegian short film festivals
http://www.kortfilmfestivalen.no/
http://www.minimalen.com/
news
k5
http://www.kuro5hin.org/
slashdot
http://slashdot.org/
nettavisen
http://www.nettavisen.no/
dagbladet
http://www.dagbladet.no/
vg
http://www.vg.no/
fark.com
http://www.fark.com/
quotes
Peoples Front To Reunite Gondwanaland: 'Stop the Laurasian Separatist Movement!'
slashdot
disbelief
To anyone who is still stubborn enough to insist that BlackICE Defender is actually good for something: PLEASE do not write to me. I don't want to hear it. I'm a scientist who will not find your mystic beliefs to be compelling. I respect your right to your own opinions, no matter how blatantly they fly in the face of logic and reality. That is, after all, the nature of faith. Happy computing. I suggest prayer.
the movie zardoz
The gun is good. The penis is evil. The penis shoots seeds, and makes new life, and poisons the earth with a plague of men, as once it was. But the gun shoots death, and purifies the earth of the filth of brutals. Go forth and kill!
old
I keep a 'trashbin' where I stow away outdated entries,.. just to be able to search it,.. and save it later,..
hnb-1.9.18/hnb.spec0000644000175000017500000000164407723016222013372 0ustar jimjim00000000000000Name: hnb Version: 1.9.18 Release: 1 Summary: HNB - Hierarchical Notebook License: GPL Group: Applications/Productivity Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-root Packager: Asgeir Nilsen %description hnb is a curses program to structure many kinds of data in one place, for example addresses, to-do lists, ideas, book reviews or to store snippets of brainstorming. Writing structured documents and speech outlines. The default format is XML but hnb can also export to ASCII and HTML. External programs may be used for more advanced conversions of the XML data. %prep %setup -q %build make %install rm -fr $RPM_BUILD_ROOT install -D src/hnb $RPM_BUILD_ROOT%{_bindir}/hnb install -D -m444 doc/hnb.1 $RPM_BUILD_ROOT%{_mandir}/man1/hnb.1 %clean rm -fr $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc README COPYING %{_bindir}/hnb %{_mandir}/man1/hnb.1* %changelog hnb-1.9.18/src/0000755000175000017500000000000007723016224012533 5ustar jimjim00000000000000hnb-1.9.18/src/ui.c0000644000175000017500000000570507723016222013321 0ustar jimjim00000000000000/* * ui.c -- the part of hnb that calls curses * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include "tree.h" #include "ui_overlay.h" #include "ui.h" #include "prefs.h" #include "cli.h" #define UI_C #include "ui.h" int nodes_above; int active_line; int nodes_below; int ui_inited = 0; void ui_init () { initscr (); clear (); intrflush (stdscr, TRUE); keypad (stdscr, TRUE); nonl (); raw (); /* enable binding ctl+c,ctrl+q,ctrl+z .. */ noecho (); if (prefs.fixedfocus) { active_line = LINES / 3; } else { active_line = 1; } #ifdef NCURSES_VERSION /* 20021129 RVE - assign terminal default colors to color number -1 */ use_default_colors (); define_key ("\x7f", KEY_BACKSPACE); define_key ("\033[11~", KEY_F (1)); define_key ("\033[28-", KEY_F (1)); define_key ("\033OP", KEY_F (1)); define_key ("\033[OP", KEY_F (1)); define_key ("\033[12~", KEY_F (2)); define_key ("\033[13~", KEY_F (3)); define_key ("\033[A", KEY_UP); define_key ("\033OA", KEY_UP); define_key ("\033[B", KEY_DOWN); define_key ("\033OB", KEY_DOWN); define_key ("\033[C", KEY_RIGHT); define_key ("\033OC", KEY_RIGHT); define_key ("\033[D", KEY_LEFT); define_key ("\033OD", KEY_LEFT); define_key ("\033[3~", KEY_DC); define_key ("\033[7~", KEY_HOME); define_key ("\033[8~", KEY_END); define_key ("\033[OH", KEY_HOME); define_key ("\033[OF", KEY_END); define_key ("\033O2A", KEY_SPREVIOUS); define_key ("\033[a", KEY_SPREVIOUS); define_key ("\033O2B", KEY_SNEXT); define_key ("\033[b", KEY_SNEXT); define_key ("\033[c", KEY_SRIGHT); define_key ("\033[d", KEY_SLEFT); define_key ("\033O2C", KEY_SRIGHT); define_key ("\033O2D", KEY_SLEFT); #endif ui_inited = 1; cli_width = COLS; if (has_colors ()) { start_color (); } ui_style_restore_color (); nodes_above = active_line; nodes_below = LINES - active_line; } void ui_end () { clear (); refresh (); endwin (); ui_inited = 0; } /*extern Node *pos; */ int ui_input () { int c; refresh(); c = getch (); switch (c) { #ifdef KEY_RESIZE case KEY_RESIZE: if (prefs.fixedfocus) { active_line = LINES / 3; } cli_width = COLS; c = getch (); return ui_action_ignore; #endif } return (c); } hnb-1.9.18/src/ui.h0000644000175000017500000000301607723016222013317 0ustar jimjim00000000000000#ifndef UI_H #define UI_H #include "ui_binding.h" #include #include "ui_style.h" #include "ui_draw.h" #include "ui_cli.h" /* actions checked for by hnb.c */ /* must have both of these bound to backspace for some reason*/ /* the third one to work with win32 pdcurses thingy */ /*#define UI_BACKSPACE 127 #define UI_BACKSPACE2 KEY_BACKSPACE #define UI_BACKSPACE3 8mencoder stream.dump -ovc lavc -lavcopts vcodec=mpeg4:vpass=2:vbitrate=905:vhq:v4mv:keyint=120 -oac copy -o spawn_p2.avi */ /* initializes the curses ui sets keyboard mode etc. */ void ui_init (); /* returns the terminal to the state it had before ui_init */ void ui_end (); /* waits until a curses event occurs, translates it according to the defines above in this file, and returns the new value. (also processes some of the events like resize itself) */ int ui_input (); /* used for approximately guessing how much we should skip when page up/page down is requested. */ extern int hnb_edit_posup; extern int hnb_edit_posdown; extern int ui_inited; void ui_getstr (char *prompt, char *datastorage); #define undefined_key(a,c)\ {if(c!=ui_action_ignore){\ docmdf(pos,"status \"No action assigned to '%s'(%id) in %s-mode\"",tidy_keyname(keyname(c)),c,a);\ }}\ #define info(a)\ {set_status(a);\ }\ #define infof(a,b)\ {char msg[80];\ sprintf(msg,a,b);\ set_status(msg);\ }\ #ifdef WIN32 #undef undefined_key /*pdcurses in windows defines control keys etc.. flashing errors is not nice */ #define undefined_key(a,c) #endif #endif /* UI_H */ hnb-1.9.18/src/Makefile0000644000175000017500000000266107723016222014176 0ustar jimjim00000000000000LIBS=-lncurses libcli/libcli.a CFLAGS=-I.. -Ilibcli -DHAVE_CONFIG_H -Wall -pedantic -g CFILES=$(wildcard *.c) OBJS=$(patsubst %.c,%.o,$(CFILES)) %.o: %.c *.h $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< hnb: libcli/libcli.a Makefile $(OBJS) init_subsystems.c *.h *.inc $(CC) -o hnb $(OBJS) $(LIBS) $(CFLAGS) # strip hnb libcli/libcli.a: libcli/*.c (cd libcli;make libcli.a) libcli/libcli_p.a: libcli/*.c (cd libcli;make libcli_p.a) init_subsystems.c: *.c echo "/* this file is autogenerated, do not edit */">init_subsystems.c cat *.c | grep "^\!init_" | sort | sed -e "s/^\!/void /g">>init_subsystems.c echo "">>init_subsystems.c echo "void init_subsystems(){">>init_subsystems.c cat *.c | grep "^\!init_" | sort | sed -e "s/^\!/ /g">>init_subsystems.c echo "}">>init_subsystems.c clean: rm -f xml_debug hnb $(OBJS) *~ cli_*.inc (cd libcli;make clean) hnb_p: *.c libcli/libcli_p.a init_subsystems.c $(CC) -o hnb_p *.c -pg -lncurses_p libcli/libcli_p.a -I.. -Ilibcli -DHAVE_CONFIG_H ps: xml_states.ps xml_states.ps: xml.dot dot -Tps xml.dot > xml_states.ps hnb1: cc -o hnb -lcurses -I.. -DHAVE_CONFIG_H -Ilibcli libcli/cli.c libcli/cli_history.c *.c -Wall hnb2: cc -o hnb -lncurses -I.. -DHAVE_CONFIG_H -Ilibcli libcli/cli.c libcli/cli_history.c *.c -Wall hnb3: /path/to/cross-compiler/cc -o hnb /usr/local/cross-tools/i386-mingw32msvc/lib/pdcurses.a libcli/libcli.a -I.. -DHAVE_CONFIG_H -Ilibcli libcli/cli.c libcli/cli_history.c *.c -Wall hnb-1.9.18/src/file_opml.c0000644000175000017500000001227007723016222014645 0ustar jimjim00000000000000/* * file_opml.c -- generic xml import/export filters for hnb * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include "xml_tok.h" #include "cli.h" #include "tree.h" #include "file.h" #include "prefs.h" #include "query.h" #include "util_string.h" #define indent(count,char) {int j;for(j=0;j",">", "&","&", "\"",""", "'","'", NULL }; static char *xmlunquote[]={ "<","<", ">",">", "&","&", ""","\"", "'","'", NULL }; /* *INDENT-ON* */ static void opml_export_nodes (FILE * file, Node *node, int level) { while (node) { fprintf (file, "\n"); indent (level, "\t"); fprintf (file, "attrib; while(att){ char *quoted=string_replace(att->data,xmlquote); fprintf (file, " %s=\"%s\"", att->name, quoted); free(quoted); att=att->next; } } if (node_right (node)) { fprintf (file, ">"); opml_export_nodes (file, node_right (node), level + 1); fprintf (file, "\n"); indent (level, "\t"); fprintf (file, ""); } else { fprintf (file, " />"); } node = node_down (node); } } static int export_opml (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc>=2?argv[1]:""; FILE *file; if (!strcmp (filename, "-")) file = stdout; else file = fopen (filename, "w"); if (!file) { cli_outfunf ("opml export, unable to open \"%s\"", filename); return (int) node; } fprintf (file, "\n\ \n\ \n\ \n\ outline exported from hnb\n\ \n\ \n\ \n\ \n\ \n\ \n\ 20\n\ 20\n\ 200\n\ 200\n\ \n\ \n", argc==3?argv[2]:"1", VERSION); opml_export_nodes (file, node, 0); fprintf (file, "\n\n\n"); if (file != stdout) fclose (file); cli_outfunf ("opml export, wrote data to \"%s\"", filename); return (int) node; } static int import_opml (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc==2?argv[1]:""; char *rdata; int type; int in_body = 0; int in_outlineelement = 0; int level = -1; xml_tok_state *s; import_state_t ist; Node *tempnode=NULL; FILE *file; file = fopen (filename, "r"); if (!file) { cli_outfunf ("opml import, unable to open \"%s\"", filename); return (int) node; } s = xml_tok_init (file); init_import (&ist, node); while (((type = xml_tok_get (s, &rdata)) != t_eof) && (type != t_error)) { if (type == t_error) { cli_outfunf ("opml import error, parsing og '%s', line:%i %s", filename, s->line_no, rdata); fclose (file); return (int) node; } if (in_body) { if (type == t_tag && !strcmp (rdata, "outline")) { level++; in_outlineelement = 1; tempnode=node_new(); continue; } if (in_outlineelement && type == t_att){ char *att_name=strdup(rdata); char *unquoted; if(xml_tok_get(s,&rdata)!=t_val){ cli_outfun("import_opml: hmm I don't think this is according to OPML,.."); }; unquoted=string_replace(rdata,xmlunquote); node_set(tempnode,att_name,unquoted); free(unquoted); free(att_name); continue; } if ((type == t_endtag || type == t_closeemptytag) && !strcmp (rdata, "outline")) { in_outlineelement = 0; import_node(&ist, level, tempnode); /* will free tempnode */ tempnode=NULL; } if ((type == t_closetag || type == t_closeemptytag) && !strcmp (rdata, "outline")) { level--; continue; } } else { if (type == t_tag && !strcmp (rdata, "body")) in_body = 1; } } if (node_getflag (node, F_temp)) node = node_remove (node); /* remove temporary node, if tree was empty */ cli_outfunf ("opml import - imported \"%s\" %i lines", filename, s->line_no); xml_tok_cleanup (s); return (int) node; } /* !init_file_opml(); */ void init_file_opml () { cli_add_command ("export_opml", export_opml, ""); cli_add_command ("import_opml", import_opml, ""); } hnb-1.9.18/src/hnb.c0000644000175000017500000002146707723016222013456 0ustar jimjim00000000000000/* * hnb.c -- the main app, of hierarchical notebook, an personal database * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ /* TODO: noder som forsvinner ved: std. oppretting redigering gå til parent -- sannsynlig grunn: feil håndtering av temporary attributte */ #if HAVE_CONFIG_H #include #endif #include #include #include #include #include "tree.h" #include "ui_cli.h" #include "cli.h" #include "ui.h" #include "prefs.h" #include "file.h" #include "evilloop.h" static void usage (const char *av0) { fprintf (stderr, "\nusage: %s [database] [options] [command [command] ..]\n", av0); fprintf (stderr, "\n\ Hierarchical NoteBook by Øyvind Kolås \n\ It is distributed under the GNU General Public License\n\ \n\ default database: '%s'\n", prefs.default_db_file); fprintf (stderr, "\n\ Options:\n\ \n\ \t-h --help this message\n\ \t-v --version prints the version\n\ \t-t --tutorial loads the tutorial instead of a database\n\ \n\ \t-a --ascii load ascii ascii\n\ \t --hnb load hnb DTD\n\ \t-o --opml load OPML DTD\n\ \t-x --xml load general xml\n"); #ifdef USE_LIBXML fprintf (stderr, "\t-s --stylized load stylized xml (using libxml2)\n"); #endif fprintf (stderr, "\n\ \t-rc specify other config file\n\ \t-ui interface to use, ( curses(default) or cli)\n\ \t-e execute commands\n\ \n\n"); } void init_subsystems (); int main (int argc, char **argv) { Node *pos; int argno; /* current commandline argument in focus */ int recover=0; /* wheter in recover mode */ struct { /* initilaized defaults */ int version; int usage; int def_db; char format[64]; int ui; int tutorial; char *dbfile; char *rcfile; char *cmd; } cmdline = { 0, /* version */ 0, /* usage */ 1, /* load default db */ "", /*format to load by default */ 1, /* ui */ 0, /* tutorial */ NULL, NULL, NULL}; { /*parse commandline */ for (argno = 1; argno < argc; argno++) { if (!strcmp (argv[argno], "-h") || !strcmp (argv[argno], "--help")) { cmdline.usage = 1; } else if (!strcmp (argv[argno], "-v") || !strcmp (argv[argno], "--version")) { cmdline.version = 1; } else if (!strcmp (argv[argno], "-t") || !strcmp (argv[argno], "--tutorial")) { cmdline.tutorial = 1; } else if (!strcmp (argv[argno], "-a") || !strcmp (argv[argno], "--ascii")) { strcpy(cmdline.format,"ascii"); } else if (!strcmp (argv[argno], "-hnb") || !strcmp (argv[argno], "--hnb")) { strcpy(cmdline.format,"hnb"); } else if (!strcmp (argv[argno], "-o") || !strcmp (argv[argno], "-opml") || !strcmp (argv[argno], "--opml")) { strcpy(cmdline.format,"opml"); } else if (!strcmp (argv[argno], "-x") || !strcmp (argv[argno], "-gx") || !strcmp (argv[argno], "--xml")) { strcpy(cmdline.format,"xml"); #ifdef USE_LIBXML } else if (!strcmp (argv[argno], "-s") || !strcmp (argv[argno], "-sx") || !strcmp (argv[argno], "--stylized")) { strcpy(cmdline.format,"sxml"); #endif } else if (!strcmp (argv[argno], "-ui")) { if (!strcmp (argv[++argno], "curses")) { cmdline.ui = 1; } else if (!strcmp (argv[argno], "cli")) { cmdline.ui = 2; } else if (!strcmp (argv[argno], "gtk") || !strcmp (argv[argno], "gtk+")) { cmdline.ui = 3; } else if (!strcmp (argv[argno], "keygrab")) { cmdline.ui = 4; } else { fprintf (stderr, "unknown interface %s\n", argv[argno]); exit (1); } } else if (!strcmp (argv[argno], "-rc")) { cmdline.rcfile = argv[++argno]; } else if (!strcmp (argv[argno], "-e")) { /* actually just a dummy option to specify default db */ if (!cmdline.dbfile) { cmdline.def_db = 1; cmdline.dbfile = (char *) -1; } } else { if (argv[argno][0] == '-') { fprintf (stderr, "unknown option %s\n", argv[argno]); exit (1); } else if (!cmdline.dbfile) { cmdline.dbfile = argv[argno]; cmdline.def_db = 0; } else { cmdline.cmd = argv[argno]; cmdline.ui = 0; argno++; break; /* stop processing cmd args */ } } } } init_subsystems (); if (cmdline.usage) { usage (argv[0]); exit (0); } if (cmdline.version) { fprintf (stderr, "%s %s\n", PACKAGE, VERSION); exit (0); } if (cmdline.rcfile) { strcpy (prefs.rc_file, cmdline.rcfile); } if (!file_check (prefs.rc_file)) { write_default_prefs (); fprintf (stderr, "created %s for hnb preferences file\n", prefs.rc_file); sleep (1); } if (cmdline.ui == 1) ui_init (); load_prefs (); /* ovveride the prefs with commandline specified options */ if (cmdline.tutorial) prefs.tutorial = 1; if (cmdline.format[0] ) { /* format specified */ strcpy(prefs.format, cmdline.format); } if (cmdline.def_db) { strcpy (prefs.db_file, prefs.default_db_file); if (!file_check (prefs.db_file)) prefs.tutorial = 2; } else { strcpy (prefs.db_file, cmdline.dbfile); } pos = tree_new (); if (!prefs.tutorial) { int oldpos = -1; char file_to_load[4096]; strcpy(file_to_load, prefs.db_file); { /* check for recovery file */ char recovery_file[4096]; FILE *tfile; struct stat statbuf; unsigned int file_modified; stat(prefs.db_file, &statbuf); file_modified=statbuf.st_ctime; sprintf(recovery_file, "%s_hnb_rescue", prefs.db_file); tfile = fopen(recovery_file, "r"); if(tfile){ char response[1024]="_"; int got_response=0; unsigned int rescue_modified; int ui_was_inited=ui_inited; stat(recovery_file, &statbuf); rescue_modified=statbuf.st_ctime; if(ui_inited) ui_end(); fclose(tfile); while(!got_response){ fprintf(stderr,"hnb recovery file (%s) exists\n\ This could mean that a prior instance of hnb is still running or that hnb\n\ was aborted.\n", recovery_file); if(rescue_modified"); fgets(response,10,stdin); switch(response[0]){ case 'a': return 0; break; case 'd': remove(recovery_file); got_response=1; break; case 'r': strcpy(file_to_load, recovery_file); recover=1; got_response=1; break; case 'o': got_response = 1; prefs.readonly = 1; break; default: break; } } if(ui_was_inited) ui_init(); } } if (!recover && ( !strcmp(prefs.format,"hnb") || !strcmp(prefs.format,"opml") || !strcmp(prefs.format,"xml") ) ) { if (!xml_check (file_to_load)) { fprintf (stderr, "%s does not seem to be a xml file, aborting.\n", file_to_load); if (ui_inited) ui_end (); exit (1); } if (prefs.savepos) oldpos = xml_getpos (file_to_load); } { char buf[4096]; if(recover) sprintf (buf, "import_binary %s", file_to_load); else sprintf (buf, "import_%s %s", prefs.format, file_to_load); pos = docmd (pos, buf); } if (oldpos != -1) { while (oldpos--) pos = node_recurse (pos); } } if (prefs.tutorial) { if (prefs.tutorial != 2) prefs.db_file[0] = (char) 255; /* disable saving */ pos = docmd (pos, "import_help"); pos = docmd (pos, "status ''"); pos = docmd (pos, "status 'navigate the documentation with your cursor keys'"); } switch (cmdline.ui) { case 1: pos = evilloop (pos); ui_end (); break; case 0: pos = (Node *) cli_docmd (cmdline.cmd, pos); while (argno < argc) { pos = (Node *) cli_docmd (argv[argno++], pos); } break; case 2: pos = cli (pos); break; case 3: printf ("gtk+ interface not implemented\n"); break; case 4: ui_init (); { int c = 0; while (c != 'q') { char buf[100]; c = getch (); sprintf (buf, "[%i] [%c]\n", c, c); addstr (buf); }} ui_end (); break; } cli_cleanup (); tree_free (pos); return 0; } hnb-1.9.18/src/evilloop.h0000644000175000017500000000033107723016222014530 0ustar jimjim00000000000000#ifndef EVILLOOP_H #define EVILLOOP_H Node *evilloop (Node *pos); #define BUFFERLENGTH 4096 /* is currently set to 4096,.. should be removed and replaced by rigid code*/ extern char inputbuf[BUFFERLENGTH]; #endif hnb-1.9.18/src/ui_cli.c0000644000175000017500000001203707723016222014144 0ustar jimjim00000000000000/* * ui_cli.c -- the glue that binds various modules into the interpreter * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include "tree.h" #include "file.h" #include "path.h" #include "prefs.h" #include "cli.h" #include #include #include #include "ui_cli.h" /* strips the ending node off a path */ static char *path_strip (char *path) { /* FIXME add double // escaping when node2path gets it */ int j = strlen (path); while (j > 0) { if (path[j - 1] == '/') { path[j] = 0; return path; } j--; } return path; } static int add (int argc,char **argv, void *data) { Node *pos = (Node *) data; Node *tnode; if(argc==1){ cli_outfunf("usage: %s ",argv[0]); return 0; } if (argc==2) { cli_outfun ("empty node added\n"); } tnode = node_insert_down (node_bottom (pos)); node_set (tnode, TEXT, argv[1]); return (int) pos; } static int addc (int argc,char **argv, void *data) { Node *pos = (Node *) data; Node *tnode; if(argc==1){ cli_outfunf("usage: %s [new subentry]",argv[0]); return 0; } tnode = node_exact_match (argv[1], pos); if (!tnode) { cli_outfun ("specified parent not found"); return (int) pos; } if (node_right (tnode)) { tnode=node_bottom(tnode); } else { tnode=node_insert_right(tnode); } if(argc==2) node_set (tnode, TEXT, ""); else node_set (tnode, TEXT, argv[2]); return (int) pos; } static int pwd (int argc,char **argv, void *data) { Node *pos = (Node *) data; cli_outfun (path_strip (node2path (pos))); cli_outfun ("\n"); return (int) pos; } static int cd (int argc, char **argv, void *data) { Node *pos = (Node *) data; Node *tnode = pos; if(argc==1){ return (int)node_root(pos); } if (!strcmp (argv[1], "..")){ if (node_left (tnode) != 0) return (int) (node_left (tnode)); } tnode = path2node (argv[1], pos); if (tnode) { tnode = node_right (tnode); } if (!tnode) { cli_outfun ("no such node\n"); return (int) pos; } return (int) tnode; return (int) pos; } #include static void pre_command (char *commandline) { char *c = commandline; if (commandline) { while (isspace ((unsigned char)*c)) c++; if (*c == '#') commandline[0] = '\0'; if (*c == '\0') commandline[0] = '\0'; } } static int ls (int argc, char **argv, void *data) { Node *pos = (Node *) data; Node *tnode; int recurse = 0; int indicate_sub = 1; int startlevel; tnode = node_top (pos); startlevel = nodes_left (tnode); while (tnode) { if (recurse) { int j; for (j = nodes_left (tnode); j > startlevel; j--) { printf ("\t"); } } cli_outfunf( "%s %s %s",fixnullstring(node_get (tnode, TEXT)), indicate_sub? node_right(tnode)?"(..)":"" :"", tnode==pos?"<":"" ); if (recurse) { tnode = node_recurse (tnode); if (nodes_left (tnode) < startlevel) tnode = 0; } else { tnode = node_down (tnode); } } return (int) pos; } /* !init_ui_cli(); */ void init_ui_cli (void) { static int inited = 0; if (!inited) { inited = 1; cli_precmd = pre_command; cli_add_command ("add", add, ""); cli_add_command ("ls", ls, ""); cli_add_help("add","inserts an new entry at the current position"); cli_add_command ("addc", addc, " "); cli_add_help("addc","inserts a new entry under the node named parent, with the text og string"); cli_add_command ("cd", cd, ""); cli_add_command ("pwd", pwd, ""); cli_add_help ("pwd", "echoes the current path"); } } Node *docmd (Node *pos, const char *commandline) { int ret; char *cmdline = strdup (commandline); ret = cli_docmd (cmdline, pos); free (cmdline); return (Node *) ret; } Node *docmdf (Node *pos,char *format, ...){ va_list arglist; char buf[128]; va_start( arglist, format ); vsnprintf(buf,127,format,arglist); va_end(arglist); buf[127]=0; return docmd(pos,buf); } extern int quit_hnb; /* from evilloop. */ Node *cli (Node *pos) { char commandline[4096]; fprintf (stderr, "Welcome to %s %s\ntype ? or help for more information\n", PACKAGE, VERSION); do { fflush (stdout); fprintf (stdout, "%s>", path_strip (node2path (pos))); fflush (stdout); fgets (commandline, 4096, stdin); commandline[strlen (commandline) - 1] = 0; pos = (Node *) cli_docmd (commandline, pos); } while (!quit_hnb); return pos; } hnb-1.9.18/src/ui_cli.h0000644000175000017500000000102007723016222014137 0ustar jimjim00000000000000#ifndef CLI_H #define CLI_H #include #include "cli.h" /* Initialize ui_cli module */ void init_ui_cli (void); /** execute specified command line as if we stood on pos in the tree @returns new position, if position changes due to the action. */ Node *docmd (Node *pos, const char *commandline); Node *docmdf (Node *pos,char *format, ...); /* enter an read eval loop executing commandlines Returns: new position, if position changes due to the actions done. */ Node *cli (Node *pos); #endif /* CLI_H */ hnb-1.9.18/src/file.c0000644000175000017500000001060707723016222013620 0ustar jimjim00000000000000/* * file.c -- utility functions for import/export hnb * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include "tree.h" #include "file.h" #include "prefs.h" #include "ui_cli.h" void init_import (import_state_t * is, Node *node) { is->npos = node; is->startlevel = nodes_left (node); } /* * * @return the node inserted * */ Node *import_node_text (import_state_t * is, int level, char *data) { int node_level; level += is->startlevel; while ((node_level = nodes_left (is->npos)) > level) is->npos = node_left (is->npos); if (node_level == level) is->npos = node_insert_down (is->npos); if (node_level < level) is->npos = node_insert_right (is->npos); node_set (is->npos, TEXT, data); return is->npos; } /* * * @return the node inserted, no need to free the node afterwards * */ Node *import_node (import_state_t * is, int level, Node *node) { int node_level; level += is->startlevel; while ((node_level = nodes_left (is->npos)) > level) is->npos = node_left (is->npos); if (node_level == level) is->npos = node_insert_down (is->npos); if (node_level < level) is->npos = node_insert_right (is->npos); node_swap (node, is->npos); node_free (is->npos); is->npos = node; return is->npos; } /* returns 1 if the first couple of lines of file contains 'xml' */ int xml_check (char *filename) { FILE *file; char buf[bufsize]; int j; file = fopen (filename, "r"); if (file == NULL) return -1; for (j = 0; j < 2; j++) { if (fgets (buf, bufsize, file) == NULL) { fclose (file); return 0; } if (strstr (buf, "xml") != 0) { fclose (file); return 1; } } fclose (file); return 0; } /* returns the node number stored in the comment, if available */ int xml_getpos (char *filename) { FILE *file; char buf[bufsize]; char *s; int j; file = fopen (filename, "r"); if (file == NULL) return -1; for (j = 0; j < 2; j++) { if (fgets (buf, bufsize, file) == NULL) { fclose (file); return 0; } if ((s = strstr (buf, " #include "tokenizer.h" #define TOKEN_MAXSIZE 512 char token_seperator = '/'; char *tokenize (char *haystack) { static char empty[2] = ""; static char token[TOKEN_MAXSIZE]; static char buffer[TOKEN_MAXSIZE]; static int pos = 0; int tokenpos = 0; if (strlen (haystack) >= TOKEN_MAXSIZE) return (empty); /* safety precaution */ if (haystack[0] != 0) { /* new tokenization */ pos = 0; token[0] = 0; strcpy (buffer, haystack); } else { if (pos == 0) return (empty); /* we cannot start with an empty string */ } if (pos >= strlen (buffer)) return (empty); /* this is the end */ while (buffer[pos] != 0) { if (buffer[pos] == token_seperator) { if (buffer[pos + 1] == token_seperator) { /* escaped seperator char */ pos++; } else { pos++; if (buffer[pos] == 0) { /* child of last */ buffer[pos + 1] = token_seperator; buffer[pos + 2] = 0; buffer[pos] = token_seperator; } if ((pos == 1)) { /* "root" */ token[0] = token_seperator; token[1] = 0; } return (token); } } token[tokenpos++] = buffer[pos++]; token[tokenpos] = 0; } return (token); } hnb-1.9.18/src/tokenizer.h0000644000175000017500000000127407723016223014721 0ustar jimjim00000000000000extern char token_seperator; /* tokenize parses a string into tokens (seperate arguements) the global char token_seperator defines what character delimits the tokens. The first call to tokenize should have the input string as the argument. Subsequent calls should have the argument set to "", as tokenize will work on a copy of the original string and keep record of it's progress. when tokenize sees two token_seperator chars in a row, it will think of this as a single seperator character within a token tokenize will also return the token_seperator char in a string if it is placed first or last in the input string. (c) Øyvind Kolås 2000 */ char *tokenize (char *haystack); hnb-1.9.18/src/file_html.c0000644000175000017500000001274307723016223014650 0ustar jimjim00000000000000/* * file_html.c -- html export filter for hnb * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include "cli.h" #include "tree.h" #include "file.h" #include "query.h" #include "util_string.h" #define indent(count,char) {int j;for(j=0;j", ">", "ø", "ø", "Ø", "Ø", "å", "å", "Å", "Å", "æ", "æ", "Æ", "Æ",NULL }; /* *INDENT-ON* */ static int export_html (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc==2?argv[1]:""; Node *tnode; int level, flags, startlevel, lastlevel, cnt; char *cdata; FILE *file; if (!strcmp (filename, "-")) file = stdout; else file = fopen (filename, "w"); if (!file) { cli_outfunf ("html export, unable to open \"%s\"", filename); return (int) node; } startlevel = nodes_left (node); tnode = node; lastlevel = 0; fprintf (file, "\n\ \n\ \n\ tree exported from hnb\n\ \n\ \n\
    \n"); while ((tnode != 0) & (nodes_left (tnode) >= startlevel)) { level = nodes_left (tnode) - startlevel; flags = node_getflags (tnode); cdata = fixnullstring (node_get (tnode, TEXT)); if (level > lastlevel) { indent (level - 1, "\t"); fprintf (file, "
      \n"); } if (level < lastlevel) { int level_diff = lastlevel - level; for (; level_diff; level_diff--) { indent (level + level_diff - 1, "\t"); fprintf (file, "
    \n"); } } indent (level, "\t"); if (cdata[0] != 0) { char *quoted=string_replace(cdata,htmlquote); fprintf (file, "
  • %s
  • \n", quoted); free(quoted); } else { fprintf (file, "\n"); } lastlevel = level; tnode = node_recurse (tnode); } level = 0; { int level_diff = lastlevel - level; for (; level_diff; level_diff--) { for (cnt = 0; cnt <= level + level_diff - 1; cnt++) fprintf (file, "\t"); fprintf (file, "
\n"); } } fprintf (file, "\n"); if (file != stdout) fclose (file); cli_outfunf ("html export, saved output in \"%s\"", filename); return (int) node; } static void htmlcss_export_nodes (FILE * file, Node *node, int level) { while (node) { char *data = fixnullstring (node_get (node, TEXT)); char *quoted=string_replace(data,htmlquote); fprintf (file, "\n"); indent (level, "\t"); fprintf (file, "
",level+1); fprintf (file, "%s", quoted); free(quoted); if (node_right (node)) { htmlcss_export_nodes (file, node_right (node), level + 1); fprintf (file, "\n"); indent (level, "\t"); fprintf (file, "
"); } else { fprintf (file, ""); } node = node_down (node); } } static int export_htmlcss (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc==2?argv[1]:""; FILE *file; if (!strcmp (filename, "-")) file = stdout; else file = fopen (filename, "w"); if (!file) { cli_outfunf ("html export, unable to open \"%s\"", filename); return (int) node; } fprintf (file, "\n\ \n\ \n\ \n\ tree exported from hnb\n\ \n\ \n\ \n"); htmlcss_export_nodes (file, node, 0); fprintf (file, "\n\n"); if (file != stdout) fclose (file); cli_outfunf ("html css export, saved output in \"%s\"", filename); return (int) node; } /* !init_file_html(); */ void init_file_html () { cli_add_command ("export_html", export_html, ""); cli_add_command ("export_htmlcss", export_htmlcss, ""); } hnb-1.9.18/src/libcli/0000755000175000017500000000000007723016223013770 5ustar jimjim00000000000000hnb-1.9.18/src/libcli/Makefile0000644000175000017500000000101107723016223015421 0ustar jimjim00000000000000CFLAGS = -Wall OBJS = cli.o cli_history.o cli_tokenize.o all: libcli.a libcli.so test-static test-shared clean: rm -f *.o *.a *.so test-s* *~ libcli.a: $(OBJS) ar rc libcli.a cli*.o libcli_p.a: $(CC) -pg -c cli.c $(CC) -pg -c cli_history.c ar rcs libcli_p.a cli*.o libcli.so: $(OBJS) $(CC) -shared cli*.o -o libcli.so $(CFLAGS) $(LIBS) test-static: test.o libcli.a $(CC) -o test-static test.o libcli.a $(CFLAGS) $(LIBS) test-shared: test.o libcli.so $(CC) -o test-shared test.o -L. -lcli $(CFLAGS) $(LIBS) hnb-1.9.18/src/libcli/cli.c0000644000175000017500000002427107723016223014711 0ustar jimjim00000000000000/* libcli -- a small commandline interpreter libraray * Copyright (C) 2002 Øyvind Kolås * * 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. */ #include #include #include #include #include "cli.h" #include "cli_tokenize.h" /*#define HIDE_NULL_HELP */ /* TODO: allow removal of commands/variables scripts? (with simple flow-control?) */ #ifdef WIN32 #define snprintf(a,b,args...) sprintf(a,args) #endif /* wordwrapping outputting function */ static void default_output(char *data){ #define COLS 78 char *tbuf=malloc(COLS+1); char *word=malloc(COLS+1); char *bp=tbuf, *wp=word, *dp=data; *bp=*wp='\0'; while(1+1==2){ if(isspace((unsigned char)*dp) || *dp=='\0'){ if( (bp-tbuf) + (wp-word) +1 < COLS){ strcpy(bp,word); bp+=(wp-word); *(bp++)=' '; *bp='\0'; wp=word; *wp='\0'; } else { printf(tbuf);printf("\n"); bp=tbuf; *bp='\0'; strcpy(bp,word); bp+=(wp-word); *(bp++)=' '; *bp='\0'; wp=word; *wp='\0'; } if(!*dp)break; } else { if(wp-word>=COLS){ printf("%s\n",tbuf); printf("%s\n",word); wp=word; } *(wp++)=*dp; *wp='\0'; } dp++; } printf("%s\n",tbuf); free(word); free(tbuf); } static void default_unknown_command (int argc,char **argv, void *data){ cli_outfunf ("unknown command '%s' type '?' to see allowed commands.\n",argv[0]); } void (*cli_outfun) (char *) = default_output; void (*cli_precmd) (char *) = NULL; void (*cli_postcmd) (char *) = NULL; void (*cli_unknown) (int,char **,void *) = default_unknown_command; int cli_width = 40; void cli_outfunf(char *format, ...){ va_list arglist; char buf[128]; va_start( arglist, format ); vsnprintf(buf,127,format,arglist); va_end(arglist); buf[127]=0; cli_outfun(buf); } static int item_matches (const char *itemname); typedef struct ItemT { char *name; /* what the user types */ int (*func) (int argc,char **argv, void *data); /* function that is the command */ int *integer; /* pointer to integer (set to NULL if string) */ char *string; /* pointer to string (set to NULL if integer) */ char *usage; /* helptext for this command */ char *help; int flags; struct ItemT *next; } ItemT; #define is_command(a) (a->func && (a->integer==NULL) && (a->string==NULL)) #define is_variable(a) (!is_command(a)) static ItemT *items = NULL; void cli_add_item (char *name, int *integer, char *string, int (*func) (int argc,char **argv, void *data), char *usage) { ItemT *titem = items; while(titem){ if(!strcmp(titem->name,name)){ cli_outfunf ("libcli: attempted to add item '%s' more than once\n", name); return; } titem=titem->next; } titem=items; if (!titem) { titem = items = malloc (sizeof (ItemT)); titem->next = NULL; } else { ItemT *tmp; while (titem->next && ((strcmp ((titem->next)->name, name)) < 0)) { titem = titem->next; } tmp = titem->next; titem->next = malloc (sizeof (ItemT)); titem = titem->next; titem->next = tmp; } titem->name = strdup (name); titem->func = func; titem->integer = integer; titem->string = string; if(usage)titem->usage = strdup (usage); titem->help=strdup(""); if (strcmp (items->name, titem->name) > 0) { ItemT *tmp = items; ItemT *tmp_next = titem->next; items = titem; items->next = tmp; items->next->next = tmp_next; } } void cli_add_help(char *name, char *helptext){ ItemT *titem = items; while (titem) { if (!strcmp (name, titem->name)){ free(titem->help); titem->help=strdup(helptext); return; } titem=titem->next; } cli_outfunf("libcli: attempted to add help for '%s' which is not registered",name); } static int help (int argc,char **argv, void *data); static int vars (int argc,char **argv, void *data); static int inited = 0; void cli_cleanup(void){ inited=0; cli_outfun = default_output; cli_precmd = NULL; cli_postcmd = NULL; cli_unknown = default_unknown_command; cli_width = 40; while(items){ ItemT *titem=items; if(items->name)free(items->name); if(items->usage)free(items->usage); if(items->help)free(items->help); items=items->next; free(titem); titem=NULL; } } static void init_cli (void) { cli_add_command ("?", help, "? - this listing"); cli_add_command ("show_vars", vars, "show all variables"); inited = 1; } int cli_calllevel=0; int cli_docmd (char *commandline, void *data) { int largc=0; char **largv; ItemT *titem = items; int ret=(int)data; cli_calllevel++; if (cli_precmd) cli_precmd (commandline); if (!inited) { init_cli (); titem = items; inited = 1; } largv=argv_tokenize(commandline); if(largv)largc=argc_of_argv(largv); if((!largc) || largv[0][0]=='\0' ){ free(largv); return ret; } while (titem) { if (!strcmp (largv[0], titem->name)) { if (is_command (titem)) { ret=titem->func (largc,largv, data); if (cli_postcmd) cli_postcmd (commandline); cli_calllevel--; free(largv); return ret; } else if (is_variable (titem)) { if (largc==1) { if (titem->string) { cli_outfunf ("%s\t[%s]\t- %s\n", titem->name, titem->string, titem->usage); } else if (titem->integer) { cli_outfunf ("%s\t[%i]\t- %s\n", titem->name, *titem->integer, titem->usage); } else { cli_outfunf ("%s\tis a broken variable\n", titem->name); } } else { if (titem->integer) *titem->integer = atoi (largv[1]); if (titem->string) strcpy (titem->string, largv[1]); if (titem->func) ret=titem->func (largc,largv, data); } if (cli_postcmd) cli_postcmd (commandline); cli_calllevel--; free(largv); return ret; } } titem = titem->next; } if(cli_unknown) cli_unknown(1,&commandline,data); if (cli_postcmd) cli_postcmd (commandline); cli_calllevel--; free(largv); return ret; } static char newcommand[100]; static int item_matches (const char *itemname) { int matches = 0; ItemT *titem = items; while (titem) { if (!strncmp (itemname, titem->name, strlen (itemname))) matches++; titem = titem->next; } return matches; } char *cli_complete (const char *commandline) { int matches = 0; char str_matches[4096]=""; strncpy (newcommand, commandline, 99); newcommand[99] = 0; if (commandline[0]) { matches = item_matches (newcommand); if (matches == 1) { ItemT *titem = items; while (titem) { if (!strncmp (newcommand, titem->name, strlen (newcommand))) { int pos; strcpy (newcommand, titem->name); pos = strlen (newcommand); newcommand[pos++] = ' '; newcommand[pos] = '\0'; break; } titem = titem->next; } } else if (matches > 1) { ItemT *titem = items; strcpy(str_matches,"matches: "); while (titem) { if (!strncmp (newcommand, titem->name, strlen (newcommand))) { strcat (str_matches,titem->name); strcat (str_matches," "); } titem = titem->next; } cli_outfun(str_matches); while (item_matches (newcommand) == matches) { ItemT *titem = items; while (titem) { int len = strlen (newcommand); if (!strncmp (newcommand, titem->name, len)) { strcpy (newcommand, titem->name); newcommand[len + 1] = '\0'; if(!strcmp(newcommand,titem->name)){ return newcommand; } break; } titem = titem->next; } } newcommand[strlen (newcommand) - 1] = '\0'; } else { cli_outfunf ("no match"); } } return newcommand; } /* internal commands */ static int help (int argc,char **argv, void *data) { if (argc == 1) { /* show all help */ ItemT *titem = items; cli_outfunf ("available commands:"); while (titem) { #ifdef HIDE_NULL_HELP if(titem->usage) #endif if (is_command (titem)) cli_outfunf ("%14s %s", titem->name, titem->usage); titem = titem->next; }; } else { /* show help for specified command */ ItemT *titem = items; cli_outfunf ("HELP for '%s'", argv[1] ); while (titem) { if (is_command (titem)) { if (!strcmp (argv[1], titem->name)) { cli_outfunf ("usage: %s %s", titem->name, titem->usage); if(titem->help[0]){ cli_outfun (""); cli_outfun(titem->help); } return(int)data; } } titem = titem->next; } cli_outfunf ("unknown command '%s'", argv[1]); } return(int)data; } static int vars (int argc, char **argv, void *data) { ItemT *titem = items; cli_outfunf ("all variables:"); while (titem) { #ifdef HIDE_NULL_HELP if(titem->usage) #endif if (is_variable (titem)) { if (titem->string) { cli_outfunf ("%15s [%s]\t- %s", titem->name, titem->string, titem->usage); } else if (titem->integer) { cli_outfunf ("%15s [%i]\t- %s", titem->name, *titem->integer, titem->usage); } else { cli_outfunf ("%s\tis a broken variable", titem->name); } } titem = titem->next; } cli_outfunf ("----------------"); cli_outfunf ("to change a variable: \"variablename newvalue\""); return(int)data; } char *cli_getstring(char *variable){ ItemT *titem = items; while (titem) { if (is_variable (titem)) { if (!strcmp (variable, titem->name)) { if(titem->string) return(titem->string); if(titem->integer) return NULL; /* FIXME: use a static buffer perhaps */ } } titem = titem->next; } return ""; } #include int cli_load_file(char *filename){ char buf[255]; FILE *file; file=fopen(filename,"r"); if(!file){ return -1; } while(fgets(buf,255,file)){ char *c=strchr(buf,'\n'); char *t; t=buf; if(c)*c='\0'; if(*buf){ while(*t==' ' || *t=='\t')t++; cli_docmd(buf,NULL); } } fclose(file); return 0; } hnb-1.9.18/src/libcli/cli.h0000644000175000017500000000467707723016223014726 0ustar jimjim00000000000000/* libcli -- a small commandline interpreter libraray * Copyright (C) 2002 Øyvind Kolås * * 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. */ /* helper function takes a orig.inal string a char array of 40 to put first word in and a pointer to a string to store the tail pointer in split on spaces and tabs cli_split(commandline, char head[40], &tailstring); */ #ifndef LIBCLI_H #define LIBCLI_H #include void argv_sanity(void); void cli_split(char *orig, char *head, char **tail); void cli_add_help(char *name,char *helptext); void cli_cleanup(void); void cli_add_item (char *name, int *integer, char *string, int (*func) (int argc,char **argv, void *data), char *usage); #define cli_add_int(name,integer,usage)\ cli_add_item (name, integer, NULL, NULL, usage) #define cli_add_string(name,string,usage)\ cli_add_item (name, NULL, string, NULL, usage) #define cli_add_command(name,func,usage) \ cli_add_item(name, NULL, NULL, func, usage) int cli_load_file(char *filename); char *cli_complete (const char *commandline); /* returns a completed commandline */ int cli_docmd (char *commandline, void *data); /* run commandline */ extern void (*cli_outfun) (char *); /* the outputting function assign cli_outfun a void function that takes a string to use something other than printf */ void cli_outfunf( char *format, ... ); #ifdef WIN32 #define snprintf(a,b,args...) sprintf(a,args) #endif extern void (*cli_precmd) (char *); /* cstuff to run before executing commands */ extern void (*cli_postcmd) (char *); /* stuff to run after executing commands */ extern void(*cli_unknown) (int,char **,void *); /* handler for unmatched commands */ extern int cli_width; /* wrap width of output window */ #include "cli_history.h" #endif /* LIBCLI_H */ hnb-1.9.18/src/libcli/test.c0000644000175000017500000000265207723016223015120 0ustar jimjim00000000000000/* libcli -- a small commandline interpreter libraray * Copyright (C) 2002 Øyvind Kolås * * 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. */ #include #include #include "cli.h" int integer=0; char string[40]="not set"; int echo(int argc,char **argv, void *data){ printf("tokens:%i\n",argc); while(*argv) printf("[%s]\n",*(argv++)); return 0; } int main(){ char command[100]=""; cli_add_command("echo",echo,"outputs it's parameters"); cli_add_int("int",&integer,"a integer"); cli_add_string("string",string,"a string"); cli_load_file("macrotest"); while( strcmp(command,"quit") && strcmp(command,"q")){ printf(">"); fgets(command,100,stdin); command[strlen(command)-1]=0; /* remove newline */ cli_docmd(command,NULL); } return 0; } hnb-1.9.18/src/libcli/Documentation.html0000644000175000017500000000603607723016223017474 0ustar jimjim00000000000000 tree exported from hnb
  • the commandline interpreter (cli) used was developed specifically for this application, but it is made not in any way dependant on any other thing than c.
  • programming with libcli
    • adding commands and variables
      • adding a command to the interpreter is done by issuing the macro
      • cli_add_command("commandname", callback, "description");
      • where callback is a function of the form
      • int callback(char *params);
      • the string passed to the callback is the string remaining when the command is chopped of the commandline
      • variables can be added with either
      • cli_add_int("variablename", &integer_variable, "description");
      • cli_add_string("variablename", &string_variable, "description");
      • or by calling the real add function
      • cli_add_item("variablename", &integerdata, &stringdata, callback, "description");
      • the callback will be issued whenever the variable is set, a variable can have both integer and string attached at the same time
    • running commands
      • when issuing cli_docmd("commandline") the interpreter will run the commandline and return with the value given to the callback function assosicated
      • this function is usually wrapped up in a macro making it possible to use printf style formatting
      • #define docmdf(args...) \
        • do{ char buf[100];\
        • snprintf (buf, 99, args);\
        • cli_docmd(buf);\
        • }while(0)
    • commandline completion
      • char *cli_complete(const char *commandline);
      • returns a completion fo the given commandline.
      • the string returned is statically allocated
      • if there is no match a message is printed on the output
      • if there is multiple matches the matches are listed on the output, and the commandline is expanded in such a manner that it rquals the first characters
    • customisation
      • by default cli outputs to standard output, when embedding it in an application this is often not what you want.
      • cli_outfun can be assigned a void functino that takes a string as parameter
      • cli_width should be assigned the width in characters of the output device
      • cli_precmd can be assigned a void function taking the commandline as a parameter to be executed before each command
      • cli_postcmd can be assigned a void function taking the commandline as a parameter to be executed after each command
    • history
      • libcli also provides a simple history facility
      • if you call cli_history_add("commandline"); for every function you execute,
      • char *cli_historyprev();
      • and
      • char *cli_historynext();
      • will allow you to page back and forward in the history
hnb-1.9.18/src/libcli/COPYING0000644000175000017500000004307607723016223015035 0ustar jimjim00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, 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 Appendix: 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., 675 Mass Ave, Cambridge, MA 02139, 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. hnb-1.9.18/src/libcli/cli_history.c0000644000175000017500000000377307723016223016476 0ustar jimjim00000000000000/* libcli -- a small commandline interpreter libraray * Copyright (C) 2002 Øyvind Kolås * * 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. */ #include #define HISTORY_SIZE 64 #define MAXLEN 100 static char history[HISTORY_SIZE][MAXLEN] = { {0} }; static unsigned int readpos = 0; static unsigned int writepos = 0; static unsigned int skiptwoforward = 0; static void init (void) { static int done = 0; if (!done) { done = 1; memset (history, 0, sizeof (history)); } readpos %= HISTORY_SIZE; writepos %= HISTORY_SIZE; } void cli_historyadd (char *string) { init (); if (!string[0]) return; /* don't bother with empty strings */ strncpy (history[writepos], string, MAXLEN - 1); history[writepos][99] = 0; readpos = writepos; writepos++; readpos %= HISTORY_SIZE; writepos %= HISTORY_SIZE; history[writepos][0] = 0; /* for å hindre wraparound i tid */ } char *cli_historyprev () { char *ret; init (); ret = history[readpos]; if (!ret[0]) return ""; /* nothing there */ readpos--; readpos %= HISTORY_SIZE; writepos %= HISTORY_SIZE; skiptwoforward = 1; return ret; } char *cli_historynext () { char *ret; readpos++; if (skiptwoforward) readpos++; init (); ret = history[readpos]; if (!ret[0]) readpos = writepos - 1; readpos %= HISTORY_SIZE; writepos %= HISTORY_SIZE; skiptwoforward = 0; return ret; } hnb-1.9.18/src/libcli/cli_history.h0000644000175000017500000000161207723016223016471 0ustar jimjim00000000000000/* libcli -- a small commandline interpreter libraray * Copyright (C) 2002 Øyvind Kolås * * 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. */ char *cli_historynext (void); char *cli_historyprev (void); void cli_historyadd (char *string); hnb-1.9.18/src/libcli/macrotest0000644000175000017500000000007107723016223015712 0ustar jimjim00000000000000macro_add tmacro echo line one echo line two macro_end hnb-1.9.18/src/libcli/cli_tokenize.c0000644000175000017500000002143207723016223016615 0ustar jimjim00000000000000/* * cli_tokenize.c -- tokenizer for libcli * * Copyright (C) 2003 Øyvind Kolås * * 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, 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. */ #include #include #include #include enum actions{ a_nil =0, /* do nothing, (just change state) */ a_eat =1<<1, /* increment input position */ a_store =1<<2, /* increment length of string, append char to string */ a_new =1<<3 /* increment number of strings, clear output string */ , a_varstore=1<<4, /* add char to variable name */ a_varclear=1<<5, /* clear variable name */ a_varinsert=1<<6 /* retrieve variable by name, and append to string */ , a_hexstore1=1<<7, /* store first char of hexsequence */ a_hexstore2=1<<8, /* store second char of hexsequence */ a_hexclear=1<<9, /* clear stored hexsequence */ a_hexinsert=1<<10 /* append hexvalue to string */ }; enum tokenize_string_states{ s_null=0, s_start, s_quo, s_delimit, s_wpp, s_wescape, s_waddchar, s_wvar, s_qpp, s_qescape, s_qaddchar, s_qvar, s_app, s_aescape, s_end }; static char *c_ws=" \n\r\t"; /* white space charstring */ typedef struct { int state; /* the state we're in */ char *chars; /* chars that this rule applies to, NULL if range is to be used*/ unsigned char r_start; /* start of range this rule applies to */ unsigned char r_end; /* end of range this rule applies to */ int action; /* action to be when performing rule */ unsigned char storechar; /* action is store and this is non null, store this instead of input */ int next_state; /* the state we should change to */ } rule_entry; #define max_rules 16 /* maximum number of rules for a state */ #ifdef TESTit #define cli_getstring dummy_get_variable static char * dummy_get_variable(char *name){ static char *dummy=""; return dummy; } #endif #ifndef TESTit char *cli_getstring(char *variable); #endif static rule_entry state_table[s_end][max_rules]; /* adds a rule to the state_table */ static void a(int state, int next_state, char *chars, unsigned char r_start, unsigned char r_end, int action, unsigned char storechar){ rule_entry *r=&state_table[state][0]; while(r->state)r++; r->state=state; r->r_start=r_start; r->r_end=r_end; if(chars) r->chars=strdup(chars); r->action=action; r->next_state=next_state; r->storechar=storechar; } /* *INDENT-OFF* */ static void init_state_table(void){ static int inited=0; if(inited)return; inited=1; memset(state_table,0,sizeof(state_table)); a(s_start, s_start, c_ws, 0,0, a_eat, 0); a(s_start, s_quo, NULL, 0,255, a_nil, 0); a(s_quo, s_delimit, c_ws, 0,0, a_eat+a_new, 0); a(s_quo, s_qpp, NULL, '"','"', a_eat, 0); a(s_quo, s_app, NULL, '\'','\'', a_eat, 0); a(s_quo, s_end, NULL, '\0','\0', a_nil+a_new, 0); a(s_quo, s_wvar, NULL, '$','$', a_eat+a_varclear,0); a(s_quo, s_wpp, NULL, 0,255, a_eat+a_store, 0); a(s_delimit,s_delimit, c_ws, 0,0, a_eat, 0); a(s_delimit,s_end, NULL, '\0','\0', a_nil, 0); a(s_delimit,s_quo, NULL, 0,255, a_nil, 0); a(s_wpp, s_wescape, NULL, '\\','\\', a_eat, 0); a(s_wpp, s_quo, c_ws, 0,0, a_nil, 0); a(s_wpp, s_quo, NULL, '\0','\0', a_nil, 0); a(s_wpp, s_wvar, NULL, '$','$', a_eat+a_varclear,0); a(s_wpp, s_wpp, NULL, 0,255, a_eat+a_store, 0); a(s_wvar, s_wvar, NULL, 'a','z', a_varstore+a_eat,0); a(s_wvar, s_wvar, NULL, 'A','Z', a_varstore+a_eat,0); a(s_wvar, s_wvar, NULL, '0','9', a_varstore+a_eat,0); a(s_wvar, s_wvar, NULL, '_','_', a_varstore+a_eat,0); a(s_wvar, s_wpp, NULL, 0,255, a_varinsert, 0); a(s_wescape, s_quo, NULL, '\0','\0', a_nil, 0); a(s_wescape, s_wpp, NULL, 'n','n', a_eat+a_store, '\n'); a(s_wescape, s_wpp, NULL, 'r','r', a_eat+a_store, '\r'); a(s_wescape, s_wpp, NULL, 't','t', a_eat+a_store, '\t'); a(s_wescape, s_wpp, NULL, 0,255, a_eat+a_store, 0); a(s_qpp, s_quo, NULL, '"','"', a_eat, 0); a(s_qpp, s_qescape, NULL, '\\','\\', a_eat, 0); a(s_qpp, s_quo, NULL, '\0','\0', a_nil, 0); a(s_qpp, s_qvar, NULL, '$','$', a_eat+a_varclear,0); a(s_qpp, s_qpp, NULL, 0,255, a_eat+a_store, 0); a(s_qvar, s_qvar, NULL, 'a','z', a_varstore+a_eat,0); a(s_qvar, s_qvar, NULL, 'A','Z', a_varstore+a_eat,0); a(s_qvar, s_qvar, NULL, '0','9', a_varstore+a_eat,0); a(s_qvar, s_qvar, NULL, '_','_', a_varstore+a_eat,0); a(s_qvar, s_qpp, NULL, 0,255, a_varinsert, 0); a(s_qescape, s_quo, NULL, '\0','\0', a_nil, 0); a(s_qescape, s_qpp, NULL, 'n','n', a_eat+a_store, '\n'); a(s_qescape, s_qpp, NULL, 'r','r', a_eat+a_store, '\r'); a(s_qescape, s_qpp, NULL, 't','t', a_eat+a_store, '\t'); a(s_qescape, s_qpp, NULL, 0,255, a_eat+a_store, 0); a(s_app, s_quo, NULL, '\'','\'', a_eat, 0); a(s_app, s_aescape, NULL, '\\','\\', a_eat, 0); a(s_app, s_quo, NULL, '\0','\0', a_nil, 0); a(s_app, s_app, NULL, 0,255, a_eat+a_store, 0); a(s_aescape, s_quo, NULL, '\0','\0', a_nil, 0); a(s_aescape, s_app, NULL, 'n','n', a_eat+a_store, '\n'); a(s_aescape, s_app, NULL, 'r','r', a_eat+a_store, '\r'); a(s_aescape, s_app, NULL, 't','t', a_eat+a_store, '\t'); a(s_aescape, s_app, NULL, 0,255, a_eat+a_store, 0); } /* *INDENT-ON* */ static int is_oneof (char c, char *chars) { while (*chars) { if (c == *chars) return 1; chars++; } return 0; } #define MAX_VARNAMELENGTH 128 char **argv_tokenize(char *input_string){ char **argv=NULL; char *output; unsigned char varname[MAX_VARNAMELENGTH]=""; int varname_pos=0; init_state_table(); /* first we calculate and allocate space for the argv structure */ { int state=s_start; int tokens=0; int total_length=0; unsigned char *input=(unsigned char*)input_string; while(state!=s_end ){ rule_entry *r=&state_table[state][0]; while(r->state){ if( r->chars){ if(is_oneof(*input,r->chars)) break; } else { if ((*input >= r->r_start) && (*input <= r->r_end) ) break; } r++; } if(r->action & a_varclear){ varname_pos=0; varname[varname_pos]=0; } if( (r->action & a_varstore) && varname_posaction & a_varinsert){ total_length+=strlen(cli_getstring(varname)); varname_pos=0; varname[varname_pos]=0; } if(r->action & a_store) total_length++; if(r->action & a_eat) input++; if(r->action & a_new) tokens++; state=r->next_state; } argv=malloc( sizeof(char*)*(tokens+1) /* pointers and terminating NULL */ +sizeof(char)*(total_length+tokens)); /* character data and NUL for all strings */ memset(argv, 0, sizeof(char*)*(tokens+1)+sizeof(char)*(total_length+tokens)); output=(char *)argv + sizeof(char*)*(tokens+1); argv[0]=output; } /* then we make a second pass and actually fill up the argv structure */ { int state=s_start; int tokens=0; unsigned char *input=(unsigned char*)input_string; while(state!=s_end ){ rule_entry *r=&state_table[state][0]; while(r->state){ if( r->chars){ if(is_oneof(*input,r->chars)) break; } else { if ((*input >= r->r_start) && (*input <= r->r_end) ) break; } r++; } if(r->action & a_varclear){ varname_pos=0; varname[varname_pos]=0; } if( (r->action & a_varstore) && varname_posaction & a_varinsert){ strcpy(output,cli_getstring(varname)); output+=strlen(cli_getstring(varname)); } if(r->action & a_store){ if(r->storechar){ *(output++)=r->storechar; } else { *(output++)=*input; } } if(r->action & a_eat) input++; if(r->action & a_new){ *output=0; argv[++tokens]=++output; } state=r->next_state; } argv[tokens]=NULL; } return argv; } int argc_of_argv(char **argv){ int count=0; if(!argv)return 0; while(*(argv++))count++; return count; } #ifdef TESTit int main(int argc, char **argv){ char *input="hello$foo world"; char **largv; largv=argv_tokenize(input); printf("%i\n",argc_of_argv(largv)); {char **tlargv=largv; while(*tlargv){ printf("[%s]",*tlargv); tlargv++; } } printf("\n"); free(largv); return 0; } #endif hnb-1.9.18/src/libcli/cli_tokenize.h0000644000175000017500000000011107723016223016611 0ustar jimjim00000000000000char **argv_tokenize(char *input_string); int argc_of_argv(char **argv); hnb-1.9.18/src/libcli/cli_tokenize.ps0000644000175000017500000005305207723016223017020 0ustar jimjim00000000000000%!PS-Adobe-2.0 %%Creator: dot version 1.7.16 (Wed Feb 6 02:14:52 MST 2002) %%For: (pippin) Øyvind Kolås,,, %%Title: libcli_tokenizer %%Pages: (atend) %%BoundingBox: 35 71 581 721 %%EndComments save %%BeginProlog /DotDict 200 dict def DotDict begin /setupLatin1 { mark /EncodingVector 256 array def EncodingVector 0 ISOLatin1Encoding 0 255 getinterval putinterval EncodingVector dup 306 /AE dup 301 /Aacute dup 302 /Acircumflex dup 304 /Adieresis dup 300 /Agrave dup 305 /Aring dup 303 /Atilde dup 307 /Ccedilla dup 311 /Eacute dup 312 /Ecircumflex dup 313 /Edieresis dup 310 /Egrave dup 315 /Iacute dup 316 /Icircumflex dup 317 /Idieresis dup 314 /Igrave dup 334 /Udieresis dup 335 /Yacute dup 376 /thorn dup 337 /germandbls dup 341 /aacute dup 342 /acircumflex dup 344 /adieresis dup 346 /ae dup 340 /agrave dup 345 /aring dup 347 /ccedilla dup 351 /eacute dup 352 /ecircumflex dup 353 /edieresis dup 350 /egrave dup 355 /iacute dup 356 /icircumflex dup 357 /idieresis dup 354 /igrave dup 360 /dcroat dup 361 /ntilde dup 363 /oacute dup 364 /ocircumflex dup 366 /odieresis dup 362 /ograve dup 365 /otilde dup 370 /oslash dup 372 /uacute dup 373 /ucircumflex dup 374 /udieresis dup 371 /ugrave dup 375 /yacute dup 377 /ydieresis % Set up ISO Latin 1 character encoding /starnetISO { dup dup findfont dup length dict begin { 1 index /FID ne { def }{ pop pop } ifelse } forall /Encoding EncodingVector def currentdict end definefont } def /Times-Roman starnetISO def /Times-Italic starnetISO def /Times-Bold starnetISO def /Times-BoldItalic starnetISO def /Helvetica starnetISO def /Helvetica-Oblique starnetISO def /Helvetica-Bold starnetISO def /Helvetica-BoldOblique starnetISO def /Courier starnetISO def /Courier-Oblique starnetISO def /Courier-Bold starnetISO def /Courier-BoldOblique starnetISO def cleartomark } bind def %%BeginResource: procset /coord-font-family /Times-Roman def /default-font-family /Times-Roman def /coordfont coord-font-family findfont 8 scalefont def /InvScaleFactor 1.0 def /set_scale { dup 1 exch div /InvScaleFactor exch def dup scale } bind def % styles /solid { } bind def /dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def /dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def /invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def /bold { 2 setlinewidth } bind def /filled { } bind def /unfilled { } bind def /rounded { } bind def /diagonals { } bind def % hooks for setting color /nodecolor { sethsbcolor } bind def /edgecolor { sethsbcolor } bind def /graphcolor { sethsbcolor } bind def /nopcolor {pop pop pop} bind def /beginpage { % i j npages /npages exch def /j exch def /i exch def /str 10 string def npages 1 gt { gsave coordfont setfont 0 0 moveto (\() show i str cvs show (,) show j str cvs show (\)) show grestore } if } bind def /set_font { findfont exch scalefont setfont } def % draw aligned label in bounding box aligned to current point /alignedtext { % width adj text /text exch def /adj exch def /width exch def gsave width 0 gt { text stringwidth pop adj mul 0 rmoveto } if [] 0 setdash text show grestore } def /boxprim { % xcorner ycorner xsize ysize 4 2 roll moveto 2 copy exch 0 rlineto 0 exch rlineto pop neg 0 rlineto closepath } bind def /ellipse_path { /ry exch def /rx exch def /y exch def /x exch def matrix currentmatrix newpath x y translate rx ry scale 0 0 1 0 360 arc setmatrix } bind def /endpage { showpage } bind def /layercolorseq [ % layer color sequence - darkest to lightest [0 0 0] [.2 .8 .8] [.4 .8 .8] [.6 .8 .8] [.8 .8 .8] ] def /setlayer {/maxlayer exch def /curlayer exch def layercolorseq curlayer get aload pop sethsbcolor /nodecolor {nopcolor} def /edgecolor {nopcolor} def /graphcolor {nopcolor} def } bind def /onlayer { curlayer ne {invis} if } def /onlayers { /myupper exch def /mylower exch def curlayer mylower lt curlayer myupper gt or {invis} if } def /curlayer 0 def %%EndResource %%EndProlog %%BeginSetup 14 default-font-family set_font 1 setmiterlimit % /arrowlength 10 def % /arrowwidth 5 def % make sure pdfmark is harmless for PS-interpreters other than Distiller /pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse % make '<<' and '>>' safe on PS Level 1 devices /languagelevel where {pop languagelevel}{1} ifelse 2 lt { userdict (<<) cvn ([) cvn load put userdict (>>) cvn ([) cvn load put } if %%EndSetup %%Page: 1 1 %%PageBoundingBox: 36 72 581 721 %%PageOrientation: Portrait gsave 35 71 546 650 boxprim clip newpath 36 72 translate 0 0 1 beginpage 0.5538 set_scale 0 0 translate 0 rotate [ /CropBox [36 72 581 721] /PAGES pdfmark 0.000 0.000 0.000 graphcolor 14.00 /Times-Roman set_font % start gsave 10 dict begin 43 584 30 30 ellipse_path stroke 43 584 34 34 ellipse_path stroke gsave 10 dict begin 43 579 moveto 29 -0.5 (start) alignedtext end grestore end grestore % start -> start newpath 67 608 moveto 72 623 64 636 43 636 curveto 26 636 18 628 18 616 curveto stroke 0.000 0.000 0.000 edgecolor newpath 15 618 moveto 19 608 lineto 20 618 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 43 641 moveto 38 -0.5 (ws eat) alignedtext end grestore % quo gsave 10 dict begin 205 584 27 18 ellipse_path stroke gsave 10 dict begin 205 579 moveto 26 -0.5 (quo) alignedtext end grestore end grestore % start -> quo newpath 78 584 moveto 105 584 142 584 169 584 curveto stroke 0.000 0.000 0.000 edgecolor newpath 168 582 moveto 178 584 lineto 168 587 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 128 589 moveto 49 -0.5 (default) alignedtext end grestore % end gsave 10 dict begin 699 1126 27 27 ellipse_path stroke 699 1126 31 31 ellipse_path stroke gsave 10 dict begin 699 1121 moveto 25 -0.5 (end) alignedtext end grestore end grestore % quo -> end newpath 206 602 moveto 207 617 207 638 208 656 curveto 212 721 214 893 250 947 curveto 333 1066 380 1090 518 1134 curveto 566 1149 624 1142 660 1135 curveto stroke 0.000 0.000 0.000 edgecolor newpath 658 1133 moveto 668 1134 lineto 658 1138 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 437 1132 moveto 60 -0.5 (\\0 new nil) alignedtext end grestore % delimit gsave 10 dict begin 437 934 34 18 ellipse_path stroke gsave 10 dict begin 437 929 moveto 47 -0.5 (delimit) alignedtext end grestore end grestore % quo -> delimit newpath 206 602 moveto 207 614 208 627 208 629 curveto 215 690 207 858 250 902 curveto 261 913 344 924 396 929 curveto stroke 0.000 0.000 0.000 edgecolor newpath 393 926 moveto 403 930 lineto 393 931 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 303 928 moveto 78 -0.5 (ws new+eat) alignedtext end grestore % qpp gsave 10 dict begin 437 822 27 18 ellipse_path stroke gsave 10 dict begin 437 817 moveto 26 -0.5 (qpp) alignedtext end grestore end grestore % quo -> qpp newpath 208 602 moveto 216 637 232 713 250 734 curveto 285 772 310 757 356 780 curveto 359 781 387 796 409 807 curveto stroke 0.000 0.000 0.000 edgecolor newpath 409 804 moveto 416 811 lineto 406 808 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 303 785 moveto 25 -0.5 (" eat) alignedtext end grestore % app gsave 10 dict begin 437 485 27 18 ellipse_path stroke gsave 10 dict begin 437 480 moveto 25 -0.5 (app) alignedtext end grestore end grestore % quo -> app newpath 210 566 moveto 221 534 242 468 250 462 curveto 289 435 310 455 356 462 curveto 358 462 382 469 404 476 curveto stroke 0.000 0.000 0.000 edgecolor newpath 403 473 moveto 412 478 lineto 402 478 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 303 468 moveto 21 -0.5 (' eat) alignedtext end grestore % wvar gsave 10 dict begin 437 298 29 18 ellipse_path stroke gsave 10 dict begin 437 293 moveto 36 -0.5 (wvar) alignedtext end grestore end grestore % quo -> wvar newpath 208 566 moveto 208 565 208 565 208 564 curveto 223 500 212 475 250 423 curveto 272 393 362 340 409 314 curveto stroke 0.000 0.000 0.000 edgecolor newpath 405 313 moveto 415 310 lineto 408 318 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 303 431 moveto 92 -0.5 ($ eat+varclear) alignedtext end grestore % wpp gsave 10 dict begin 699 200 27 18 ellipse_path stroke gsave 10 dict begin 699 195 moveto 30 -0.5 (wpp) alignedtext end grestore end grestore % quo -> wpp newpath 207 566 moveto 211 516 226 378 250 341 curveto 341 198 576 194 664 198 curveto stroke 0.000 0.000 0.000 edgecolor newpath 662 196 moveto 672 198 lineto 662 201 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 437 246 moveto 111 -0.5 (default eat+store) alignedtext end grestore % delimit -> end newpath 445 952 moveto 458 977 484 1023 518 1051 curveto 561 1085 621 1106 660 1117 curveto stroke 0.000 0.000 0.000 edgecolor newpath 659 1114 moveto 668 1119 lineto 658 1119 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 1115 moveto 30 -0.5 (\\0 nil) alignedtext end grestore % delimit -> quo newpath 207 611 moveto 207 618 208 624 208 625 curveto 210 637 241 847 250 857 curveto 284 891 312 859 356 878 curveto 369 883 398 904 418 919 curveto stroke 0.000 0.000 0.000 edgecolor newpath 205 612 moveto 206 602 lineto 210 612 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 303 883 moveto 67 -0.5 (default nil) alignedtext end grestore % delimit -> delimit newpath 459 948 moveto 468 959 460 970 437 970 curveto 419 970 410 963 412 954 curveto stroke 0.000 0.000 0.000 edgecolor newpath 408 956 moveto 415 948 lineto 413 958 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 437 975 moveto 38 -0.5 (ws eat) alignedtext end grestore % qpp -> quo newpath 211 610 moveto 218 631 230 660 250 678 curveto 288 710 316 681 356 710 curveto 400 740 402 759 429 805 curveto stroke 0.000 0.000 0.000 edgecolor newpath 209 612 moveto 209 602 lineto 214 611 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 303 715 moveto 25 -0.5 (" eat) alignedtext end grestore % qpp -> quo newpath 207 610 moveto 208 612 208 614 208 616 curveto 210 628 212 631 214 643 curveto 230 714 196 755 250 804 curveto 295 843 372 836 411 828 curveto stroke 0.000 0.000 0.000 edgecolor newpath 205 612 moveto 207 602 lineto 210 612 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 303 838 moveto 30 -0.5 (\\0 nil) alignedtext end grestore % qpp -> qpp newpath 455 836 moveto 461 847 455 858 437 858 curveto 423 858 416 852 417 844 curveto stroke 0.000 0.000 0.000 edgecolor newpath 414 845 moveto 419 836 lineto 419 846 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 437 863 moveto 111 -0.5 (default eat+store) alignedtext end grestore % qescape gsave 10 dict begin 699 794 37 18 ellipse_path stroke gsave 10 dict begin 699 789 moveto 52 -0.5 (qescape) alignedtext end grestore end grestore % qpp -> qescape newpath 456 809 moveto 472 799 495 785 518 780 curveto 573 766 589 773 644 780 curveto 648 780 653 781 659 783 curveto stroke 0.000 0.000 0.000 edgecolor newpath 658 780 moveto 667 785 lineto 657 785 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 785 moveto 25 -0.5 (\\ eat) alignedtext end grestore % qvar gsave 10 dict begin 699 1005 27 18 ellipse_path stroke gsave 10 dict begin 699 1000 moveto 31 -0.5 (qvar) alignedtext end grestore end grestore % qpp -> qvar newpath 443 840 moveto 443 843 444 845 444 845 curveto 463 877 480 876 500 907 curveto 511 922 505 931 518 944 curveto 529 955 619 981 667 996 curveto stroke 0.000 0.000 0.000 edgecolor newpath 665 993 moveto 674 998 lineto 664 998 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 992 moveto 92 -0.5 ($ eat+varclear) alignedtext end grestore % app -> quo newpath 235 574 moveto 266 563 315 546 356 528 curveto 377 518 400 506 416 497 curveto stroke 0.000 0.000 0.000 edgecolor newpath 239 575 moveto 229 576 lineto 238 570 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 303 573 moveto 21 -0.5 (' eat) alignedtext end grestore % app -> quo newpath 216 560 moveto 225 536 225 521 250 504 curveto 263 495 361 489 410 486 curveto stroke 0.000 0.000 0.000 edgecolor newpath 219 559 moveto 213 567 lineto 215 557 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 303 509 moveto 30 -0.5 (\\0 nil) alignedtext end grestore % app -> app newpath 455 499 moveto 461 510 455 521 437 521 curveto 423 521 416 515 417 507 curveto stroke 0.000 0.000 0.000 edgecolor newpath 414 508 moveto 419 499 lineto 419 509 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 437 526 moveto 111 -0.5 (default eat+store) alignedtext end grestore % aescape gsave 10 dict begin 699 494 36 18 ellipse_path stroke gsave 10 dict begin 699 489 moveto 51 -0.5 (aescape) alignedtext end grestore end grestore % app -> aescape newpath 446 468 moveto 463 438 497 378 518 368 curveto 568 342 598 337 644 368 curveto 647 370 673 433 689 469 curveto stroke 0.000 0.000 0.000 edgecolor newpath 690 466 moveto 692 476 lineto 686 468 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 373 moveto 25 -0.5 (\\ eat) alignedtext end grestore % wvar -> wvar newpath 456 312 moveto 463 323 457 334 437 334 curveto 421 334 414 327 415 319 curveto stroke 0.000 0.000 0.000 edgecolor newpath 412 320 moveto 418 312 lineto 416 322 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 437 339 moveto 170 -0.5 (A..Z,a..z,0..9,-,_ varstore,eat ) alignedtext end grestore % wvar -> wpp newpath 466 296 moveto 522 291 641 282 644 280 curveto 665 268 680 244 689 225 curveto stroke 0.000 0.000 0.000 edgecolor newpath 686 226 moveto 692 218 lineto 690 228 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 296 moveto 110 -0.5 (default varinsert) alignedtext end grestore % wpp -> quo newpath 205 560 moveto 206 491 214 295 250 245 curveto 354 102 469 173 644 191 curveto 658 192 665 192 674 193 curveto stroke 0.000 0.000 0.000 edgecolor newpath 208 556 moveto 205 566 lineto 203 556 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 437 171 moveto 36 -0.5 (ws nil) alignedtext end grestore % wpp -> quo newpath 205 558 moveto 206 534 207 497 208 465 curveto 212 396 203 209 250 160 curveto 371 33 481 104 644 166 curveto 663 172 672 175 684 185 curveto stroke 0.000 0.000 0.000 edgecolor newpath 208 556 moveto 205 566 lineto 203 556 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 437 116 moveto 30 -0.5 (\\0 nil) alignedtext end grestore % wpp -> wvar newpath 466 282 moveto 481 273 500 263 518 256 curveto 547 244 631 219 674 207 curveto stroke 0.000 0.000 0.000 edgecolor newpath 468 284 moveto 458 286 lineto 466 279 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 261 moveto 92 -0.5 ($ eat+varclear) alignedtext end grestore % wpp -> wpp newpath 717 214 moveto 723 225 717 236 699 236 curveto 685 236 678 230 679 222 curveto stroke 0.000 0.000 0.000 edgecolor newpath 676 223 moveto 681 214 lineto 681 224 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 699 241 moveto 111 -0.5 (default eat+store) alignedtext end grestore % wescape gsave 10 dict begin 937 176 39 18 ellipse_path stroke gsave 10 dict begin 937 171 moveto 56 -0.5 (wescape) alignedtext end grestore end grestore % wpp -> wescape newpath 719 213 moveto 729 218 742 225 754 228 curveto 809 241 828 248 880 228 curveto 887 225 901 212 913 201 curveto stroke 0.000 0.000 0.000 edgecolor newpath 912 198 moveto 921 193 lineto 916 202 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 817 245 moveto 25 -0.5 (\\ eat) alignedtext end grestore % wescape -> quo newpath 205 557 moveto 206 528 207 482 208 442 curveto 211 363 191 144 250 92 curveto 356 0 752 50 880 106 curveto 910 120 916 130 932 157 curveto 932 157 932 157 933 158 curveto stroke 0.000 0.000 0.000 edgecolor newpath 208 556 moveto 205 566 lineto 203 556 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 58 moveto 30 -0.5 (\\0 nil) alignedtext end grestore % wescape -> wpp newpath 735 196 moveto 779 192 853 185 898 180 curveto stroke 0.000 0.000 0.000 edgecolor newpath 736 198 moveto 726 197 lineto 736 193 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 817 198 moveto 95 -0.5 (n eat+store\(\\n\)) alignedtext end grestore % wescape -> wpp newpath 719 178 moveto 729 170 741 161 754 157 curveto 808 140 825 149 880 157 curveto 889 158 899 161 908 164 curveto stroke 0.000 0.000 0.000 edgecolor newpath 721 179 moveto 713 185 lineto 718 176 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 817 162 moveto 87 -0.5 (t eat+store\(\\t\)) alignedtext end grestore % wescape -> wpp newpath 705 173 moveto 719 148 726 137 754 124 curveto 806 102 827 106 880 124 curveto 906 133 914 140 928 158 curveto stroke 0.000 0.000 0.000 edgecolor newpath 708 173 moveto 702 182 lineto 703 172 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 817 132 moveto 89 -0.5 (r eat+store\(\\r\)) alignedtext end grestore % wescape -> wpp newpath 710 224 moveto 722 243 730 253 754 264 curveto 806 285 830 287 880 264 curveto 913 248 917 233 932 201 curveto 933 199 934 196 934 194 curveto stroke 0.000 0.000 0.000 edgecolor newpath 709 228 moveto 706 218 lineto 714 225 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 817 285 moveto 111 -0.5 (default eat+store) alignedtext end grestore % qescape -> quo newpath 230 600 moveto 236 601 242 602 250 605 curveto 424 662 488 631 644 726 curveto 671 742 679 748 694 776 curveto stroke 0.000 0.000 0.000 edgecolor newpath 231 603 moveto 222 598 lineto 232 598 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 437 665 moveto 30 -0.5 (\\0 nil) alignedtext end grestore % qescape -> qpp newpath 452 799 moveto 474 772 483 758 518 746 curveto 571 726 591 728 644 746 curveto 668 753 675 759 689 776 curveto stroke 0.000 0.000 0.000 edgecolor newpath 455 799 moveto 447 805 lineto 451 796 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 751 moveto 95 -0.5 (n eat+store\(\\n\)) alignedtext end grestore % qescape -> qpp newpath 453 845 moveto 467 864 490 890 518 902 curveto 570 923 597 931 644 902 curveto 676 882 690 837 696 812 curveto stroke 0.000 0.000 0.000 edgecolor newpath 452 848 moveto 448 839 lineto 456 845 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 925 moveto 87 -0.5 (t eat+store\(\\t\)) alignedtext end grestore % qescape -> qpp newpath 468 835 moveto 510 849 585 869 644 846 curveto 662 839 677 823 687 811 curveto stroke 0.000 0.000 0.000 edgecolor newpath 468 838 moveto 460 832 lineto 470 833 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 861 moveto 89 -0.5 (r eat+store\(\\r\)) alignedtext end grestore % qescape -> qpp newpath 471 819 moveto 526 815 628 806 644 804 curveto 651 803 658 802 664 801 curveto stroke 0.000 0.000 0.000 edgecolor newpath 474 821 moveto 464 820 lineto 474 816 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 819 moveto 111 -0.5 (default eat+store) alignedtext end grestore % qvar -> qpp newpath 443 849 moveto 444 852 444 855 444 855 curveto 449 863 452 863 458 870 curveto 461 872 499 904 500 907 curveto 506 917 510 1003 518 1011 curveto 561 1047 589 1014 644 1011 curveto 653 1010 663 1009 672 1008 curveto stroke 0.000 0.000 0.000 edgecolor newpath 441 850 moveto 441 840 lineto 446 849 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 1032 moveto 110 -0.5 (default varinsert) alignedtext end grestore % qvar -> qvar newpath 717 1019 moveto 723 1030 717 1041 699 1041 curveto 685 1041 678 1035 679 1027 curveto stroke 0.000 0.000 0.000 edgecolor newpath 676 1028 moveto 681 1019 lineto 681 1029 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 699 1046 moveto 170 -0.5 (A..Z,a..z,0..9,-,_ varstore,eat ) alignedtext end grestore % aescape -> quo newpath 238 590 moveto 242 591 246 591 250 592 curveto 297 596 309 592 356 592 curveto 485 589 532 644 644 583 curveto 679 564 678 546 694 512 curveto stroke 0.000 0.000 0.000 edgecolor newpath 241 593 moveto 231 589 lineto 241 588 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 437 612 moveto 30 -0.5 (\\0 nil) alignedtext end grestore % aescape -> app newpath 458 506 moveto 473 520 495 538 518 546 curveto 572 563 592 566 644 546 curveto 662 539 677 523 687 511 curveto stroke 0.000 0.000 0.000 edgecolor newpath 457 509 moveto 452 500 lineto 461 505 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 564 moveto 95 -0.5 (n eat+store\(\\n\)) alignedtext end grestore % aescape -> app newpath 472 487 moveto 492 488 514 489 518 490 curveto 546 491 618 492 662 493 curveto stroke 0.000 0.000 0.000 edgecolor newpath 474 490 moveto 464 487 lineto 474 485 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 497 moveto 87 -0.5 (t eat+store\(\\t\)) alignedtext end grestore % aescape -> app newpath 470 476 moveto 511 465 584 451 644 466 curveto 656 469 667 474 677 480 curveto stroke 0.000 0.000 0.000 edgecolor newpath 472 478 moveto 462 478 lineto 471 473 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 471 moveto 89 -0.5 (r eat+store\(\\r\)) alignedtext end grestore % aescape -> app newpath 460 466 moveto 476 454 497 440 518 434 curveto 572 418 593 413 644 434 curveto 671 444 676 454 690 476 curveto stroke 0.000 0.000 0.000 edgecolor newpath 463 467 moveto 454 471 lineto 460 463 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 581 439 moveto 111 -0.5 (default eat+store) alignedtext end grestore endpage grestore %%PageTrailer %%EndPage: 1 %%Trailer %%Pages: 1 end restore %%EOF hnb-1.9.18/src/libcli/cli_tokenize.pdf0000644000175000017500000001460607723016223017151 0ustar jimjim00000000000000%PDF-1.2 %Çì¢ 6 0 obj <> stream xœ½[Û®\7r}ï¯h’Á8;$‹×ÇÈc„3râ Æ–4c$_ŸµªXäîcYJ=èÍk±.«.;ñøoþÿô|ùùò÷ÿ’¯ÿññò-þü×K•p¡…ëó¥ä1ÿ¾ÙßµþÍ!óÏÿ¼¼¿Äë—|Œ$×_ð÷?_Ƈ´q•QÊ yORz"G*õšcHGK×^âQûXí§Kk8`J«§9°ˆ/àMß¼§792F̤‡vH^[xûéâ‡ðžuê¹ÂË[<]¾»ÄÇÚéfÞ“CnGnבó%âà)9ž®fmœ´Œ#a¤÷Ôž9­àí½ïêé5e\}i½µì»Í6î6Oá=ëÜs…—÷àÝ~F¯²Äüïéùú߃5Ƶ}€”ßÿp1ž‰×†O0ä?=_þöã§·>ýîûÿºüÓ÷×o/£Ž£ãv9€š±+ä#ë£ãžØS·ÆÓæ#Û‹R³ JÕ†7í«§¥~Ô˜±BÃÐ|jGܪé-Zì[uŸ/ ï\¤­“ÜÐÓùÀ>ävùá±ËW̘Ÿ°0ŽÁËÿòñúîí¾}l=8Ù‰OfOdÔv ›×ÄW}¡šAÓ¸ÚO—XZ9úPb=ÒØ Ìö~ÂÝêðȶÞNkocÂ<ñN=xq‹G¹$‚O[Iw\òóŸþ¸©…öL¥Xê1âê‰"w| Ö‰Çx!“l‚ç‘ËWyAšÛi Ùòá’ ¦’†Ä[ð"x÷ÃÛ?Ýö“ƒI!s×Zq'^eµG=õAÉ”¼ÚpC*¶Ð#¹ÑÛO‹M2ÕYV‘âÔ€žÞõH" FA;è‘ MT@¨ƒ8=eâs0//×1£ÀÎÀêr9+”ÄŸ•³VŸÑ‰¬ <”R‰ü ÖR®#µ©ÚÇ çíÖAa­a‚¿º~Ž«„àC©µzPpIO)4ù[Ÿx{sÕ1yf­àí¹Çæ*ÉÑèã+À— Û{Ìöæª5b{®ðâsÔÎ*™nŒ áÛ;®ÛuY0”\E›lд¬a—H.édÐÅV"ÐtY”­`ŽØ“R<Êâ*rQ]\uš¡ I¦Ù“T‘qDïDIMÌP&[™~@B²UÃA3Ô]TUéY•SÏ£lÕr 5`UZýÍ ®“öžn”q•÷ŒBpœH* âÙLåmeªtìŽT³^gÍ_mÛ<5{2d.*O鹨‘X;Ì6YÊŽàü„>ÿÅç¨PDUÀÿ§ZÿóÛ¿RT'–Ú=Ñ Ùoµ‹›À&MÙ²d²”#4• :K΃±&c©8šÚH QVÜ#¦mÔÓÒT`£Â¶±ؤk_8¦¢Bx˜œ|ÛįÐ{å56H,…"¶"±þš,õ{PìéöîD¶é@˜òQ·÷KäåÃ@׋ùª†Ä½½}ïqÅWXmÛaû0)À~Àòø ¥ò¢oáííì~æ¹À݇úx1`ФÑ$ƒú¿Ü©*ƒAg¾#ðýzð$î3r úp.¨µhHÔ¿RÀ=81O| ê¢Rçµõ»Áð1èÈÂxfâÏçÝlÔí4žÃÊ|¨ TC=û¸Ê,?ýñû­…ºƒÞ ¥Á·vt"ð€Àüh×H_\¶;™§³Aw$ăn46}ë çšÞG¡™ÏÛ) °¾<éгy¼xÝ”ÎîH¡ÚÎgwdõ>½ýé `¬ùžêšYP»R‡¨Ñ .ñ”x¹RFؾ?\Π#˜‚Œ #ºU£ÅH¥ó4ƒÀdwÎg ¼Adz 3BâˆÁç(ª*?˜¢ŠlyÏ£¨&”!öS´àÍ›;-æÑ÷[]ã)ƒ@*•²3Q­8ølŸ2Ž¹Ùœ;ä ¼í7;ÛšwöÇawTÕ^Á­bÌtöæ’Zë±Bkϧž©I;]ª¸ôăעA²*3•L›Ñ†«Ù#¯zu…Á¤¨B‹âð¢f/ÆZŒ+ôèÌ©ÑbB…CCÞ@'x£B}&Ø‚Š‘íÉEet±àµ-><`&‹ñ ) û•Õ¦°{d5b»Îm_jú’¿iª4aÈD!LËÈê;ˆæbFšSÍÄžÂ(•cÁ9Æ @Þ*J‰!¤À²©k*^ ’3_G/Í*I4$ ïSeÛC®(á¼EΤçHz´ÿÔ]ÉšX¬tZñÓ êsF–µ´Öh톰DÃD¢nµGk5WÍÒ Î qÓà"ž3dMo9õnè‰dðÛ¼ÖŒ'4õÏ™q‡=‰’0ú‰`àÿ ñ@F6ºF13Ý>mÐö=bJ¤lX$у„%XÀõ»ŠF_¡SA·Õ¼{?ÉmeA’æZ_!]ÂJÓˆ~·ôÐ?Ç¿}óö8þç›p㛿ûæß¯03*g߀,×ÏÄ­…Ø‘–þž¯D³*žqSÞdl¶Xae·ž°Cšû†ü4‘ 8ê$[¤Ø›…º¿[O[–,¨9¹Âc”·Å9)1'ðŠ+Œp5,|Î1~|ÿñ݇³·êu8ËöÌ‹d†ÀÆò5]’´m®©1a»ªÉX˜n+”=•ؤ¨Aj']`Tr¨DÈEO±ê’IÊÕV’í¸»žmÖ¼(!¢¹’a†ÔƼ&Ò¡àø8±ËJÐÞÛ|ÓÔÜ»ŸôòôGe'ÊX—:¦­öà}Hš†öc§4Zᆳ߬X"1ÈCSN 戌™z*Ã*&…¡ šÕï¸rÇUª¦Ó&¶¨Šÿ`Sü Øý˘2Aª@¥†ßðîW‚ÆDÂ9;yBÃˉʵmW-IvÑàƒË"jàbÖg™1ØÐ·R•5ãy)7 lî(r"ˆ2•µNVä5amGÃ4Vy|1ù±S‰ˆ¢;AS0N©¡3S'k žÅ[fþc¶éA•¥²z`a›ÍˆÉ*Òz2ÝP8Ü%¨Í”VÓ|]‚a!ºy’Û©§' ÷?H…ÎÏè=f¿‹J&¨#'ó ‹{T4Ü¿BxI#7“…™¸¾“O—1·Ç="Ôp·ÂjÛ˜á=”(&ïç ±¥‹ïám̘§X#ü”¾Â‹{<Š Tdr¯œ^à#Eh4A‘ŨŠ!“åoÇ(¡w_qce2J‰£†"Ñkm&Yà»1þ 6Äý´"¯L~ÙSXnëbË?ÿ…½g®"©"ŸUôÓc؉ÄÌô#£ýäÎC¤e¥¶œ²¢"ϪP‹nnZYW’2(»‡8{=ÈL™U³  ¾¹&ï·ªzƒ‹½ó»_Ia¥šýr1Œ#jEqN]Ë`À„.…ûsZĆ„hà¾{gêZ6§ìwQÃjKýXXËÜq 0Ãhv o(åb·òÎQ£%0s,Z(5É}ãU42éJëqÊQ÷é)° qÁ§{Ê}º£Ã0q!ÇçMË¨ÑæÓÆVT+,ÂUXu*äÞ(;±hfY©¤%R[Ä|F‰ŒJ£§‰•³EFuÓ"}IAƒc[Ó“r©åÖ9ðÄé, é‚•×NöÒE! à…g%ê‡{Ò}¸#ÌÌše %N©Y­þ,“ùÚøýû•ga¢A‰­¢K¡OÌ”ªÆYwqFfñJ±MÑOn&5„_>g5cykO˜…™_ihk†¨föØ]ó3¹VÊpŸ³ç™³óWѺ/÷|Ü7‡ERÁ‚:Œík†D ×îŽL™iâ@Ä ,:cíBUû°ò«ZX¯™ƒ¤yN)Íò{žI˜Ä;͘.@aÅX˜_¹1‚ŽÈ¡*îâwëYOc8,cŽ‹+áfúmÞäqÇ Å ÝÚ×ìȪÍД¶¦°}(â§b®CØ´§mwšs^A¨ûH„(ʤ™EqUðžÈb0ÁÙV¢µ1J†™ŠŒ:¿"ä]TsGžæ+6aÕ÷Çg.‘UÄQC5¹4Ñú‚¯ýN’´«à­f½7u]$´ÈM Ôíeˆ*™e„&߀ùšö=ׯÇj·ö!1¦Çõ5ñò`r+2ýñ5rççìñ5c73t–ì_MVyU&ì:c™š†ï|_çïÕœõeRgõ‰×HÓºo Cs^Ûô™ŸhNª”‘m€1h¥2l§fX8Ë©B-Áäxò&;j~>ÝiÂÌ6WÕ²2•-§O¸h{Äå8Ú±RÕÌòó©ÇÒ·„wr¾6@YÁ ¡ä¯(=ÌQ•¢ù©$Y+R"ây*z¶w Ä{<R)—²li%„é.R#óùñƒì8ƾÙĨ¬‰âÁa•s},‚½²’À†Óº{]úèj£–)ÔS{& õÛWõEY€ÄÏX#ÌøY¬-›#V†uÍͩ뷇Ê}BwÀ“ gÜ"£(ûjVJ‰ë¥ÌN{Ïâ:rÙy,&e­úPô«ç¬ÈŰŒï{;iÊå¯F.L÷þÈÅÄÜÈZ4¢åxBï˜9ÉY4"üú·l±õÛ)vÑœ£g±¥¥¥{Ú‹b{Æ´<¢ß /Ë#?mYa¡Wuèb9ÏS>»=žÕâ·R­¯Ja;naä®–¯ã–YZ#Ä9Eã·@©QÓÑ s%jÙáJO/²ÑÑÐOMD?$¬+ !üžd*ÁVr"ÁÛ‡#Ëîø"§/\ì·=¾y- VU·¯z³nì=ã÷¼Ê:<¢ß ¨Ô63̬!™¡ªðznÑË8$Ç;æ ³ÈàÔ·>4ç—-û¿> ™ÈÀ?y-¡ûÒ'%¾D ílhÒd3)A ä•·•D¸š6G¤XgzÛ)J3f/ª„Õü'9Ú¦Ë$ü¦“¦J÷-WŠöüQ§“ç×G”¤f”¡».S†%r_^pUÞôËØåÛËÿ§"„Àendstream endobj 7 0 obj 5517 endobj 10 0 obj <> endobj 11 0 obj <> endobj 5 0 obj <> /Contents 6 0 R >> endobj 3 0 obj << /Type /Pages /Kids [ 5 0 R ] /Count 1 /CropBox [64 108 549 685] >> endobj 1 0 obj <> endobj 4 0 obj <> endobj 9 0 obj <> endobj 8 0 obj <> endobj 2 0 obj <>endobj xref 0 12 0000000000 65535 f 0000005927 00000 n 0000006164 00000 n 0000005842 00000 n 0000005975 00000 n 0000005682 00000 n 0000000015 00000 n 0000005602 00000 n 0000006103 00000 n 0000006030 00000 n 0000005622 00000 n 0000005652 00000 n trailer << /Size 12 /Root 1 0 R /Info 2 0 R >> startxref 6216 %%EOF hnb-1.9.18/src/libcli/cli_tokenize.dot0000644000175000017500000000405007723016223017156 0ustar jimjim00000000000000digraph "libcli_tokenizer" { epsilon=0.01; maxiter=1000; start=4; center=1; size="9,9"; edgehandles=0; rankdir=LR; "start" [shape = doublecircle]; "end" [shape = doublecircle level=1]; "start" -> "start" [label="ws eat"] "start" -> "quo" [label="default"] "quo" -> "delimit" [label="ws new+eat"] "quo" -> "qpp" [label="\" eat"] "quo" -> "app" [label="\' eat"] "quo" -> "end" [label="\\0 new nil"] "quo" -> "wvar" [label="$ eat+varclear"] "quo" -> "wpp" [label="default eat+store"] "delimit" -> "delimit" [label="ws eat"] "delimit" -> "end" [label="\\0 nil"] "delimit" -> "quo" [label="default nil"] "wpp" -> "wescape" [label="\\ eat"] "wpp" -> "quo" [label="ws nil"] "wpp" -> "quo" [label="\\0 nil"] "wpp" -> "wvar" [label="$ eat+varclear"] "wpp" -> "wpp" [label="default eat+store"] "wvar" -> "wvar" [label="A..Z,a..z,0..9,-,_ varstore,eat "] "wvar" -> "wpp" [label="default varinsert"] "wescape" -> "quo" [label="\\0 nil"] "wescape" -> "wpp" [label="n eat+store(\\n)"] "wescape" -> "wpp" [label="t eat+store(\\t)"] "wescape" -> "wpp" [label="r eat+store(\\r)"] "wescape" -> "wpp" [label="default eat+store"] "qpp" -> "qescape" [label="\\ eat"] "qpp" -> "quo" [label="\" eat"] "qpp" -> "quo" [label="\\0 nil"] "qpp" -> "qvar" [label="$ eat+varclear"] "qpp" -> "qpp" [label="default eat+store"] "qescape" -> "quo" [label="\\0 nil"] "qescape" -> "qpp" [label="n eat+store(\\n)"] "qescape" -> "qpp" [label="t eat+store(\\t)"] "qescape" -> "qpp" [label="r eat+store(\\r)"] "qescape" -> "qpp" [label="default eat+store"] "qvar" -> "qvar" [label="A..Z,a..z,0..9,-,_ varstore,eat "] "qvar" -> "qpp" [label="default varinsert"] "app" -> "aescape" [label="\\ eat"] "app" -> "quo" [label="\' eat"] "app" -> "quo" [label="\\0 nil"] "app" -> "app" [label="default eat+store"] "aescape" -> "quo" [label="\\0 nil"] "aescape" -> "app" [label="n eat+store(\\n)"] "aescape" -> "app" [label="t eat+store(\\t)"] "aescape" -> "app" [label="r eat+store(\\r)"] "aescape" -> "app" [label="default eat+store"] } hnb-1.9.18/src/node.c0000644000175000017500000000774007723016223013633 0ustar jimjim00000000000000 /* * node.c -- definition of hnb's nodes * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #include #include #include "node.h" #include "assert.h" Node *node_new () { Node *node = (Node *) malloc (sizeof (Node)); memset (node, 0, (sizeof (Node))); /* node->flags=1<<3;*/ return node; } Node *node_duplicate (Node *node) { Node *newnode; Node_AttItem *att; assert (node); if (!node) return NULL; newnode = (Node *) malloc (sizeof (Node)); if (!newnode) return NULL; memcpy (newnode, node, sizeof (Node)); newnode->attrib = NULL; att = node->attrib; while (att) { node_set (newnode, att->name, att->data); att = att->next; } return newnode; } void node_free (Node *node) { while (node->attrib) { node_unset (node, node->attrib->name); } free (node); } /* returns pointer to character data of attribute NULL if it isn't set */ char *node_get (Node *node,char *name) { Node_AttItem *att; if(!node) return NULL; att = node->attrib; while (att) { if (!strcmp (att->name, name)) { return att->data; } att = att->next; } return NULL; } /* sets the named attribute to the value of *data */ void node_set (Node *node, char *name, char *data) { Node_AttItem *att; att = node->attrib; while (att) { if (!strcmp (att->name, name)) { free (att->data); att->data = strdup (data); return; } att = att->next; } /* did not find the requested att, inserting new one, (stack wise) */ att = (Node_AttItem *) malloc (sizeof (Node_AttItem)); att->next = node->attrib; att->data = strdup (data); att->name = strdup (name); node->attrib = att; return; } void node_unset (Node *node, char *name) { Node_AttItem *att; Node_AttItem **prev; prev = &(node->attrib); att = node->attrib; while (att) { if (!strcmp (att->name, name)) { free (att->data); free (att->name); *prev = att->next; free (att); return; } prev = &(att->next); att = att->next; } /* no such node */ return; } /* FIXME: the rest of this file isn't actually used for anything but debugging yet,..*/ #include "cli.h" #include int cmd_att_set (int argc, char **argv, void *data) { Node *pos = (Node *) data; if(argc!=3){ cli_outfunf("usage: %s ",argv[0]); return (int) pos; } node_set (pos, argv[1], argv[2]); return (int) pos; } int cmd_att_get (int argc, char **argv, void *data) { Node *pos = (Node *) data; char *cdata; if(argc!=2){ cli_outfunf("usage: %s ",argv[0]); return (int) pos; } cdata = node_get (pos, argv[1]); if (cdata) cli_outfun (cdata); return (int) pos; } int cmd_att_clear (int argc, char **argv, void *data) { Node *pos = (Node *) data; if(argc!=2){ cli_outfunf("usage: %s ",argv[0]); return (int) pos; } node_unset (pos, argv[1]); return (int) pos; } int cmd_att_list (int argc,char **argv, void *data) { Node_AttItem *att; Node *pos = (Node *) data; att = pos->attrib; while (att) { cli_outfunf ("%s: [%s]", att->name, att->data); att = att->next; } return (int) pos; } /* !init_nodetest(); */ void init_nodetest () { cli_add_command ("att_set", cmd_att_set, ""); cli_add_command ("att_get", cmd_att_get, ""); cli_add_command ("att_clear", cmd_att_clear, ""); cli_add_command ("att_list", cmd_att_list, ""); } hnb-1.9.18/src/node.h0000644000175000017500000000606407723016223013636 0ustar jimjim00000000000000/** what about creating keys that are used for the data stored in nodes? **/ /** @file definition of node Datastructure for the nodes in the tree is defined in this file, */ #ifndef NODE_H #define NODE_H typedef struct Node_AttItem { char *name; char *data; struct Node_AttItem *next; } Node_AttItem; /* Datastructure for the nodes in the tree is defined in this file. Structure of a node,.. don't acces them directly use the other functions in this file to acces them. */ typedef struct Node { struct Node *up, *down, *left, *right; unsigned int flags; Node_AttItem *attrib; } Node; char *node_get (Node *node, char *name); void node_set (Node *node, char *name, char *data); void node_unset (Node *node, char *name); /* convenience macro for the rest of this header*/ #define if_node(a,b) ((a)?(b):0) /* macros to determine if there is a node immedieatly next to the specified in a driection, returns 0 if there isn't the node if there is. Returns: node, 0 if none */ #define node_up(node) if_node((node),(node)->up) #define node_down(node) if_node((node),(node)->down) #define node_right(node) if_node((node),(node)->right) #define node_left(node) if_node((node),(node)->left) /* sets all the flags of a node, if it exists Returns: New flags, or 0 if node didn't exist */ #define node_setflags(node,tflags) if_node((node),(node)->flags=(tflags)) /* gets all the flags of a node, if it exists Returns: flags, or 0 if node didn't exist */ #define node_getflags(node) if_node((node),((node)->flags)) /* returns the state of the specified flag Returns: 1 if flag is set 0 if not */ #define node_getflag(node,flag) if_node((node),((node)->flags&(flag)?1:0)) /* sets the specified flag if state is 1, turns of the flag if state is 0 */ #define node_setflag(node,flag,state)\ {if(state){node_setflags((node),(node)->flags|(flag));}\ else {node_setflags((node), (node)->flags & ( (flag) ^0xffff));}} /* ansi c complained too much about value computed not used so I reverted to a new macro function above not returinging flags */ #define old_node_setflag(node,flag,state)\ (state? node_setflags(node,node->flags|flag)\ /*else*/: node_setflags(node, node->flags & ( flag ^0xffff)) ) /* toggles the specified flag, Returns: 1 if flag were set 0 if flag were turned of */ #define node_toggleflag(node,flag) ( node_setflags((node), (node)->flags^(flag) ) &flag) /* getting of node percentage Returns: priority, or 0 if node didn't exist */ #define node_getpercent_done(node) (node?(node->percent_done):-1) /* sets priority of a node, if it exists Returns: New priority, or 0 if node didn't exist */ #define node_setpercent_done(node,new_percent_done) (node?(node->percent_done=new_percent_done):-1) #define node_getsize(node) (node?(node->size):-1) #define node_setsize(node,new_size) (node?(node->size=new_size):-1) /* allocates a new node, seta all data to zero Returns: new node */ Node *node_new (); Node *node_duplicate (Node *node); /* frees a node an it's related variables */ void node_free (Node *node); #endif /* NODE_H */ hnb-1.9.18/src/spell.c0000644000175000017500000000547507723016223014030 0ustar jimjim00000000000000/* * spell.c -- spell checking for hnb * * Copyright (C) 2003 Øyvind Kolås * * 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, 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. */ /**************/ #include "tree.h" #include "cli.h" #include "prefs.h" #include "ui.h" #include #include #include #include #include #include static char spell_command[255] = "ispell"; #include /* * this is simplistic approach,.. should perhaps have another one that checks for * url/email address substring,.. and launches an app based on that? * */ static void spell_node (Node *node) { char tempfilename[32] = "/tmp/hnb-XXXXXX"; char commandline[255]; char corrected[4096]; int ui_was_inited = ui_inited; int tempfile = mkstemp (tempfilename); write (tempfile, fixnullstring (node_get (node, TEXT)), strlen (node_get (node, TEXT))); sprintf (commandline, "%s %s", spell_command, tempfilename); if (ui_was_inited) ui_end (); system (commandline); close (tempfile); tempfile = open (tempfilename, O_RDONLY); { int len = read (tempfile, corrected, sizeof (corrected)); corrected[len] = 0; node_set (node, TEXT, corrected); } close (tempfile); unlink (tempfilename); if (ui_was_inited){ ui_init (); docmd(node,"tree_changed"); } } static int spell_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; if(prefs.readonly){ cli_outfun("readonly flag set, avoiding changes"); return (int)data; } if (argc==2 && (!strcmp (argv[1], "-r"))) { int startlevel; Node *node = pos; startlevel = nodes_left (node); while ((node != 0) && (nodes_left (node) >= startlevel)) { spell_node (node); node = node_recurse (node); } } else { spell_node (pos); } return (int) pos; } /* !init_spell(); */ void init_spell () { cli_add_command ("spell", spell_cmd, "[-r]"); cli_add_help ("spell", "Spellchecks the current node, or all children and following siblings recursively (if -r specified), using the command defined in 'spell_command'"); cli_add_string ("spell_command", spell_command, "Command executed when spell checking a node, a temporary file is written and passed as an argument"); } hnb-1.9.18/src/path.c0000644000175000017500000001421207723016223013632 0ustar jimjim00000000000000/* * path.c -- converts paths into node pointers and vice versa * * Copyright (C) 2001,2001 Øyvind Kolås * * 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, 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. */ #include #include #include #include "tree.h" #include "tokenizer.h" #include "path.h" /* converts a best matching node to the path.. (path tokens start as specified) */ Node *matchpath2node (char *path, Node *start) { char *token; Node *node; /* should perhaps be a relative start node? */ node = start; token_seperator = '/'; token = tokenize (path); if (!strcmp (token, "/")) { node = node_root (start); token = tokenize (""); if (token[0] != '/') /* this is returned if there was only a "/" in path dunno why */ node = node_match (token, node); if (!node) return 0; } else { node = node_match (token, node); if (!node) return 0; } token = tokenize (""); while (token[0] != 0) { if (node_right (node)) node = node_right (node); if (strcmp (token, "/")) /* it is not the lonely / at the end */ node = node_match (token, node); if (!node) return 0; token = tokenize (""); } return (node); } /** converts a pathstring to a node in the tree, ps, the tokenizer escapes double //'s as a single / without splitting the things at the sides a /// means,.. a slash at the end of token, and new token coming */ Node *path2node (char *path, Node *start) { char *token; Node *node; /* should perhaps be a relative start node? */ node = start; token_seperator = '/'; token = tokenize (path); if (!strcmp (token, "/")) { node = node_root (start); token = tokenize (""); if (token[0] != '/') /* this is returned if there was only a "/" in path dunno why */ node = node_exact_match (token, node); if (!node) return 0; } else { node = node_exact_match (token, node); if (!node) return 0; } token = tokenize (""); while (token[0] != 0) { if (node_right (node)) node = node_right (node); if (strcmp (token, "/")) /* it is not the lonely / at the end */ node = node_exact_match (token, node); if (!node) return 0; token = tokenize (""); } return (node); } /* same as above,.. but forcing and recursive (creates the nodes as we go if they don't exist) */ Node *path2node_make (char *path, Node *root) { char *token; Node *node; /* should perhaps be a relative start node? */ node = root; token_seperator = '/'; token = tokenize (path); if (!strcmp (token, "/")) { node = root; token = tokenize (""); if (token[0] != 0) { Node *tnode; tnode = node_exact_match (token, node); /* something is amiss here? */ if (tnode == 0) { tnode = node_insert_down (node); node_set (tnode, TEXT, token); } node = tnode; } } else { node = node_exact_match (token, node); } token = tokenize (""); while (token[0] != 0) { if (node_right (node)) { node = node_right (node); if (strcmp (token, "/")) { /* it is not the lonely / at the end */ Node *tnode; tnode = node_exact_match (token, node); if (tnode == 0) { tnode = node_insert_down (node); node_set (tnode, TEXT, token); } node = tnode; } } else { /* we must create a child */ node = node_insert_right (node); if (strcmp (token, "/")) { /* it is not the lonely / at the end */ node_set (node, TEXT, token); } } token = tokenize (""); } /* if there is a node below,.. we should remove it,... we don't want duplicate entries.. */ if (node_up (node)) node = node_remove (node_up (node)); return (node); } /* creates an absolute path like /aaa/bbb/ccc for the node (ccc) specified returns the path from a static array */ char *node2path (Node *node) { static char path[2048]; int pos = 0; int levels = nodes_left (node); int cnt; path[pos] = '/'; path[++pos] = 0; for (cnt = levels; cnt >= 0; cnt--) { int cnt2; Node *tnode = node; for (cnt2 = 0; cnt2 < cnt; cnt2++) tnode = node_left (tnode); strcpy (&path[pos], fixnullstring (node_get (tnode, TEXT))); pos = strlen (path); path[pos] = '/'; path[++pos] = 0; } path[--pos] = 0; return (path); } char *node2no_path (Node *node) { static char path[512]; int pos = 0; int levels = nodes_left (node); int cnt; path[pos] = '/'; path[++pos] = 0; for (cnt = levels; cnt >= 0; cnt--) { int cnt2; Node *tnode = node; for (cnt2 = 0; cnt2 < cnt; cnt2++) tnode = node_left (tnode); /*strcpy(&path[pos], tnode->data); */ sprintf (&path[pos], "%i", nodes_up (tnode)); pos = strlen (path); path[pos] = '/'; path[++pos] = 0; } path[--pos] = 0; return (path); } /* /0/3/2/ means: / goto root 0 go down none / go right 3 go down three / go right 2 go down two / go right*/ Node *no_path2node (char *path, Node *root) { char *token; Node *node; /* should perhaps be a relative start node? */ node = root; token_seperator = '/'; token = tokenize (path); if (!strcmp (token, "/")) { node = root; token = tokenize (""); if (token[0] != 0) { int no = atoi (token); for (; no > 0; no--) node = node_down (node); } } else { int no = atoi (token); for (; no > 0; no--) node = node_down (node); } token = tokenize (""); while (token[0] != 0) { if (node_right (node)) node = node_right (node); if (strcmp (token, "/")) { /* it is not the lonely / at the end */ int no = atoi (token); for (; no > 0; no--) node = node_down (node); } token = tokenize (""); } return (node); } typedef struct Path { struct Path *parent; struct Node *node; } Path; hnb-1.9.18/src/path.h0000644000175000017500000000164407723016223013644 0ustar jimjim00000000000000#ifndef PATH_H #define PATH_H /* converts a pathstring to a node in the tree, ps, the tokenizer escapes double //'s as a single / without splitting the things at the sides a /// means,.. a slash at the end of token, and new token coming */ Node *path2node (char *path, Node *root); Node *matchpath2node (char *path, Node *root); /* same as above,.. but forcing and recursive (creates the nodes as we go if they don't exist) */ Node *path2node_make (char *path, Node *root); /* create an absolute path like /aaa/bbb/ccc for the node (ccc) specified FIXME: it uses a static char array,.. that is reused.. probably not the best way.. but.. */ char *node2path (Node *node); /* numeric paths... /0/3/2/ means: / goto root 0 go down none / go right 3 go down three / go right 2 go down two / go right */ Node *no_path2node (char *path, Node *root); char *node2no_path (Node *node); #endif /*PATH_H */ hnb-1.9.18/src/tree.c0000644000175000017500000002313507723016223013641 0ustar jimjim00000000000000/* * tree.c -- a general tree structure for use with hnb * * Copyright (C) 2001,2002 Øyvind Kolås * * 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, 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. */ /* there is one a little bit strange thing about this tree, it have the root at the top but at the left.. (like the model presented to the user) */ #include #include #include #include #include "tree.h" char TEXT[5] = "text"; Node *node_recurse (Node *node) { if (node_right (node)) return node_right (node); if (node_down (node)) return node_down (node); while (node_left (node)) { if (node_down (node_left (node))) return node_down (node_left (node)); node = node_left (node); } return 0; } Node *node_backrecurse (Node *node) { if (node_up (node)) { node = node_up (node); while (node_right (node)) { node = node_right (node); node = node_bottom (node); } return (node); } return (node_left (node)); } int node_no (Node *node) { int no = 0; while (node) { node = node_backrecurse (node); no++; } return no; } Node *node_top (Node *node) { if (node == 0) return 0; while (node_up (node)) node = node_up (node); return (node); } Node *node_bottom (Node *node) { if (node == 0) return 0; while (node_down (node)) node = node_down (node); return node; } Node *node_insert_up (Node *node) { Node *temp, *new = node_new (); temp = node->up; new->up = temp; new->down = node; node->up = new; if (temp) temp->down = new; new->left = node->left; if (node_left (new)) { /* make tree consistent */ if (node_right (node_left (node)) == node) { temp = node_left (new); temp->right = new; } } return new; } Node *node_insert_down (Node *node) { Node *temp, *new = node_new (); temp = node->down; new->down = temp; new->up = node; node->down = new; if (temp) temp->up = new; new->left = node->left; return new; } Node *node_insert_right (Node *node) { Node *new = node_new (); if ((!node) || (node->right)) { free (new); return 0; } new->left = node; node->right = new; return new; } unsigned int nodes_left (Node *node) { unsigned int level = 0; while ((node = node_left (node))) level++; return level; } unsigned int nodes_up (Node *node) { unsigned int level = 0; while ((node = node_up (node))) level++; return level; } unsigned int nodes_down (Node *node) { unsigned int level = 0; while ((node = node_down (node))) level++; return level; } unsigned int nodes_right (Node *node) { unsigned int level = 0; while ((node = node_right (node))) level++; return (level); } Node *node_remove (Node *node) { Node *tup = node->up, *tdown = node->down; /* if we're wiping the tree, add a temp node for later reference to the empty tree */ if ((node_left (node) == 0) && (node_up (node) == 0) && (node_down (node) == 0)) { Node *tnode = node_insert_down (node); node_setflag (tnode, F_temp, 1); tdown = node_down (node); } /* remove all children */ while (node_right (node)) node_remove (node_right (node)); /* close the gap in the linked list */ if (tup) tup->down = tdown; if (tdown) tdown->up = tup; /* if we are a top-most child (parent says we are master of our siblings) */ if ((node_left (node)) && (node_right (node_left (node)) == node)) { if (tdown) /* rearrange parents pointer */ node->left->right = tdown; else { /* if no siblings remove ourselves, and return parent */ Node *tnode = node_left (node); node->left->right = 0; node_free (node); return tnode; } } node_free (node); if (tup) return tup; if (tdown) return tdown; printf ("we're not where we should be\n"); return 0; } Node *node_match (char *match, Node *where) { Node *node; node = node_top (where); /* do I want a match from top, or from where? */ if (!match[0]) return 0; do { if (strncmp (fixnullstring (node_get (node, TEXT)), match, strlen (match)) == 0) return node; } while ((node = node_down (node))); return 0; } Node *node_exact_match (char *match, Node *where) { Node *node; node = node_top (where); /* see node_match */ if (!match[0]) return 0; do { if (strcmp (fixnullstring (node_get (node, TEXT)), match) == 0) return node; } while ((node = node_down (node))); return 0; } /* this is a commodity funciton, and I didn't want to code it myself,.. I searched the fine web, found, cut'd, 'n', pasted.. url: http://www.brokersys.com/snippets/STRISTR.C */ /* ** Designation: StriStr ** ** Call syntax: char *stristr(char *String, char *Pattern) ** ** Description: This function is an ANSI version of strstr() with ** case insensitivity. ** ** Return item: char *pointer if Pattern is found in String, else ** pointer to 0 ** ** Rev History: 07/04/95 Bob Stout ANSI-fy ** 02/03/94 Fred Cole Original ** ** Hereby donated to public domain. */ static char *stristr (const char *String, const char *Pattern) { char *pptr, *sptr, *start; int slen, plen; for (start = (char *) String, pptr = (char *) Pattern, slen = strlen (String), plen = strlen (Pattern); /* while string length not shorter than pattern length */ slen >= plen; start++, slen--) { /* find start of pattern in string */ while (toupper (*start) != toupper (*Pattern)) { start++; slen--; /* if pattern longer than string */ if (slen < plen) return (NULL); } sptr = start; pptr = (char *) Pattern; while (toupper (*sptr) == toupper (*pptr)) { sptr++; pptr++; /* if end of pattern then pattern was found */ if ('\0' == *pptr) return (start); } } return (NULL); } /*returns the next recursive node having match as a substring, or NULL if not found starting from where. */ Node *node_recursive_match (char *match, Node *where) { if (!match[0]) return NULL; where = node_recurse (where); /* skip forward */ while (where) { if (stristr (fixnullstring (node_get (where, TEXT)), match) != NULL) /* case insensitive */ return where; where = node_recurse (where); } return NULL; } Node *node_backrecursive_match (char *match, Node *where) { if (!match[0]) return NULL; where = node_backrecurse (where); /* skip forward */ while (where) { if (stristr (fixnullstring (node_get (where, TEXT)), match) != NULL) /* case insensitive */ return where; where = node_backrecurse (where); } return NULL; } Node *tree_new () { Node *root; root = node_new (); node_setflags (root, F_temp); return root; } Node *node_root (Node *node) { while (node_left (node)) node = node_left (node); node = node_top (node); return node; } void tree_free (Node *node) { Node *root = node_root (node); while (node_down (root)) node_remove (node_down (root)); root = node_remove (root); node_free (root); return; } /* swaps the positions in the tree of the two specified nodes */ void node_swap (Node *nodeA, Node *nodeB) { Node *Aup, *Aleft, *Aright, *Adown; Node *Bup, *Bleft, *Bright, *Bdown; if ((!nodeB) || (!nodeA)) return; if (nodeB == nodeA) return; if (nodeB->right == nodeA || nodeA->right == nodeB) { return; /* can't swap parent and child,.. (nor deeper levels actually) */ } if ((nodeB->down == nodeA) && (nodeA->up == nodeB)) { /* special case neighbours,.. normalize first */ Node *tnode = nodeA; nodeA = nodeB; nodeB = tnode; } Aup = node_up (nodeA); Adown = node_down (nodeA); Aleft = node_left (nodeA); Aright = node_right (nodeA); Bup = node_up (nodeB); Bdown = node_down (nodeB); Bleft = node_left (nodeB); Bright = node_right (nodeB); if ((nodeA->down == nodeB) && (nodeB->up == nodeA)) { /* special case, neighbours */ if (Aup) Aup->down = nodeB; nodeB->up = Aup; if (Bdown) Bdown->up = nodeA; nodeA->down = Bdown; nodeA->up = nodeB; nodeB->down = nodeA; if (Aleft) if (Aleft->right == nodeA) Aleft->right = nodeB; return; } if (Aup) Aup->down = nodeB; nodeB->up = Aup; if (Adown) Adown->up = nodeB; nodeB->down = Adown; if (Aleft) { if (Aleft->right == nodeA) Aleft->right = nodeB; } nodeB->left = Aleft; if (Bup) Bup->down = nodeA; nodeA->up = Bup; if (Bdown) Bdown->up = nodeA; nodeA->down = Bdown; if (Bleft) { if (Bleft->right == nodeB) Bleft->right = nodeA; } nodeA->left = Bleft; } #include "file.h" Node *tree_duplicate (Node *source, Node *target) { int level, startlevel; import_state_t ist; Node *tnode; tnode = node_duplicate (source); tnode->up = tnode->down = tnode->left = tnode->right = NULL; node_swap (tnode, target); node_free (target); target = tnode; init_import (&ist, target); if (node_right (source)) { source = node_right (source); startlevel = nodes_left (source); while ((source) && (nodes_left (source) >= startlevel)) { Node *tnode; level = nodes_left (source) - startlevel + 1; tnode = node_duplicate (source); /* clear out all references to other nodes */ tnode->up = tnode->down = tnode->left = tnode->right = NULL; import_node (&ist, level, tnode); source = node_recurse (source); } } return target; } hnb-1.9.18/src/tree.h0000644000175000017500000001054407723016223013646 0ustar jimjim00000000000000#ifndef TREE_H #define TREE_H #include "node.h" /*flag (attribute) definitions*/ enum { F_hidden = 1 << 0, F_readonly = 1 << 1, F_temp = 1 << 2, F_expanded = 1 << 3, F_visible = 1 << 12 }; /* creates a new tree and returns a node pointing to it don't store this node for reference, keep updating your pointer into the tree with the pointers returned from other functions. Returns: new tree */ Node *tree_new (); /* Given a node in a tree, this function returns a pointer to the root of the tree Returns: tree root */ Node *node_root (Node *node); /* frees a whole tree from memory, by reference to one of it's nodes */ void tree_free (Node *node); /*returns the topmost of the siblings on the level of node Returns: level top */ Node *node_top (Node *node); /*returns the bottommost of the sibling on the lvel of node Returns: level bottom */ Node *node_bottom (Node *node); /* inserts a new node above node, returns the new node Returns: new node */ Node *node_insert_up (Node *node); /* inserts a new node below node, returns the new node Returns: new node */ Node *node_insert_down (Node *node); /*inserts a child for node, if there already is a child, 0 is returned Returns: new node */ Node *node_insert_right (Node *node); /* the number of nodes above Returns: number of nodes */ unsigned int nodes_up (Node *node); /* the number of nodes below Returns: number of nodes */ unsigned int nodes_down (Node *node); /* the number of nodes to the left (level of node) Returns: number of nodes */ unsigned int nodes_left (Node *node); unsigned int nodes_right (Node *node); /* removes node and it's children, returns: the 'nearest' still existing node (up or down or left of specified node) Returns: nearby node */ Node *node_remove (Node *node); /* finds a node starting with match amongst the siblings of where returns 0 if no match found or no match string given Returns: matching node or NULL */ Node *node_match (char *match, Node *where); /* same as above, but must match whole node Returns: matching node or NULL */ Node *node_exact_match (char *match, Node *where); /* returns the next node with a case insensitive substring match from where. Returns: matching node or NULL */ Node *node_recursive_match (char *match, Node *where); /* returns the next node with a case insensitive substring match from where. Returns: matching node or NULL */ Node *node_backrecursive_match (char *match, Node *where); /* swaps the contents of two nodes */ void node_swap (Node *nodeA, Node *nodeB); /* returns the next node, doing a recursive traversal of the tree Returns: next recursive node or 0 if none */ Node *node_recurse (Node *node); /* returns the previous node, doing a recursive traversal of the tree backwards Returns: next back recursive node or 0 if none */ Node *node_backrecurse (Node *node); /* returns the number of this node in the database */ int node_no (Node *node); /* included from node.h (most of these are actually macros but can be used as if functions) determines if there is a node immedietly next to the specified node in given direction, returns the node if there is 0 otherwise Node *node_up(node); Node *node_down(node); Node *node_left(node); Node *node_right(node); sets all the flags of a node, if it exists Returns: New flags, or 0 if node didn't exist int node_setflags(node,flags); gets all the flags of a node, if it exists Returns: flags, or 0 if node didn't exist int node_getflags(node); returns the state of the specified flag Returns: 1 if flag is set 0 if not int node_getflag(node,flag); sets the specified flag if state is 1, turns of the flag if state is 0 Returns: new flags int node_setflag(node,flag); toggles the specified flag, Returns: 1 if flag were set 0 if flag were turned of int node_toggleflag(node,flag); gets priority of node Returns: priority, or 0 if node didn't exist int node_getpriority(node); sets priority of a node, if it exists Returns: New priority, or 0 if node didn't exist int node_setpriority(node,priority); sets and gets the data for a node, does neccesary allocating and freeing as well. char *node_setdata(Node *node,char *data); Returns: pointer to data char *node_getdata(Node *node); */ Node *tree_duplicate (Node *source, Node *target); extern char TEXT[5]; #define fixnullstring(str) ((str)?(str):"") #endif /* TREE_H */ hnb-1.9.18/src/file_help.c0000644000175000017500000000523207723016223014627 0ustar jimjim00000000000000/* * file_help.c -- tutorial import and export filters for hnb * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include "cli.h" #include "tree.h" #include "file.h" #include "query.h" #include "util_string.h" /* *INDENT-OFF* */ static char *helpquote[]={ "\"", "\\\\", "\"", "\\\"",NULL }; /* *INDENT-ON* */ static int export_help (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc==2?argv[1]:""; Node *tnode; int level, flags, startlevel, lastlevel, cnt; char *cdata; FILE *file; file = fopen (filename, "w"); if (!file) { cli_outfunf ("help export, unable to open \"%s\"", filename); return (int) node; } startlevel = nodes_left (node); tnode = node; lastlevel = 0; fprintf (file, "#define i(a,b,c) do{Node *tnode=node_new();node_set(tnode,TEXT,b);node_setflags(tnode,c);import_node(&ist,a,tnode);}while(0)\n\n"); while ((tnode != 0) & (nodes_left (tnode) >= startlevel)) { char *quoted; level = nodes_left (tnode) - startlevel; flags = node_getflags (tnode); cdata = fixnullstring (node_get (tnode, TEXT)); quoted=string_replace(cdata,helpquote); for (cnt = 0; cnt < level; cnt++) fprintf (file, "\t"); fprintf (file, "i(%i,\"%s\",%i);\n", level, quoted, flags); free(quoted); lastlevel = level; tnode = node_recurse (tnode); } level = 0; fclose (file); cli_outfunf ("help export, wrote data to \"%s\"", filename); return (int) node; } static int import_help (int argc, char **argv, void *data) { Node *node = (Node *) data; import_state_t ist; init_import (&ist, node); #include "tutorial.inc" if (node_getflag (node, F_temp)) node = node_remove (node); return (int) (node); } /* !init_file_help(); */ void init_file_help () { cli_add_command ("export_help", export_help, ""); cli_add_command ("import_help", import_help, ""); } hnb-1.9.18/src/state.c0000644000175000017500000000414107723016223014016 0ustar jimjim00000000000000/* * state.c -- a simplistic undo/redo kind of system * * Copyright (C) 2003 Øyvind Kolås * * 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, 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. */ #include #include #include #include "tree.h" #include "file.h" #include "prefs.h" #include "ui_cli.h" static Node *savedtree = NULL; static int save_state_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; Node *i; Node *j; if (savedtree != NULL) { tree_free (savedtree); } savedtree = node_new (); i = node_root (pos); j = savedtree; do { j = savedtree = tree_duplicate (i, j); i = node_down (i); j = node_insert_down (j); } while (i != NULL); j = node_remove (j); { int no; no = node_no (pos); savedtree = node_root (savedtree); while (--no) savedtree = node_recurse (savedtree); } return (int) pos; } static int restore_state_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; if (savedtree != NULL) { Node *temp; temp = pos; pos = savedtree; savedtree = temp; tree_free (savedtree); savedtree = NULL; } return (int) pos; } /* !init_keepstate(); */ void init_keepstate () { cli_add_command ("save_state", save_state_cmd, ""); cli_add_help ("save_state", "Saves a copy of the current tree and selected node in memory"); cli_add_command ("restore_state", restore_state_cmd, ""); cli_add_help ("restore_state", "Restores the copy of the tree saved with save_state"); } hnb-1.9.18/src/ui_draw.c0000644000175000017500000004234107723016223014334 0ustar jimjim00000000000000/* * ui_draw.c -- drawing of a nodes and trees using curses * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include "tree.h" #include "tree_todo.h" #include #include #include "curses.h" #include "stdio.h" #include "prefs.h" #include "ui_overlay.h" #define UI_C #include "ui.h" #include "ui_draw.h" #include "cli.h" #include #include #define KEEPLINES 5 int nodes_above; int active_line; int nodes_below; static Node *up (Node *sel, Node *node) { if (node_up (node) && node_getflag( node_up (node), F_expanded)) { node = node_up (node); while (node_right (node) && node_getflag(node,F_expanded)) { node = node_right (node); node = node_bottom (node); } return (node); } else { if (node_up (node)) return (node_up (node)); else return (node_left (node)); } return node_left (node); } static Node *down (Node *sel, Node *node) { if (node_getflag(node,F_expanded)) { return node_recurse (node); } else { if (node_down (node)) { return (node_down (node)); } else { while (node != 0) { node = node_left (node); if (node_down (node)) return (node_down (node)); } } } return NULL; } int startlevel = 0; int hnb_edit_posup = 0; /*contains the cursor pos for up/down */ int hnb_edit_posdown = 0; /*from here when in editing mode */ enum { drawmode_test = 0, drawmode_normal, drawmode_selected, drawmode_edit, drawmode_completion }; /* draws the actual node data with word wrapping, should be reengineered into a general * linewrapping function. * * */ static int draw_textblock (int line_start, int col_start, int width, int cursor_pos, Node *node, int drawmode) { int col_end = col_start + width; unsigned char word[200]; /* current word being rendered */ int wpos = 0; /* position in current word */ int dpos = 0; /* position in data */ int col; /* current column */ int lines_used = 1; int cursor_state = 0; int cx = 0, cy = 0; /* coordinates to draw cursor at */ unsigned char *data = (unsigned char *) fixnullstring (node_get (node, TEXT)); col = col_start; word[0] = 0; if (drawmode == drawmode_edit) { hnb_edit_posup = 0; hnb_edit_posdown = strlen ((char *) data); } switch (drawmode) { case drawmode_test: break; case drawmode_completion: if (node_right (node)) { ui_style (ui_style_parentnode); } else { ui_style (ui_style_node); } break; case drawmode_selected: if (node_right (node)) { ui_style (ui_style_parentselected); } else { ui_style (ui_style_selected); } break; case drawmode_normal: case drawmode_edit: default: if (node_right (node)) { ui_style (ui_style_parentnode); } else { ui_style (ui_style_node); } break; } while ((dpos == 0) || data[dpos - 1]) { /* loop through data + \0 */ switch (data[dpos]) { case '\0': /* \0 as well,.. to print last word */ case ' ': case '\t': case '\n': case '\r': /* all whitespace is treated as spaces */ if (col + wpos + 1 >= col_end) { /* reached margin */ if (drawmode == drawmode_edit) { if (cursor_state == 0) hnb_edit_posup = cursor_pos - (col - col_start); if (cursor_state == 1) { hnb_edit_posdown = cursor_pos + (col - col_start); cursor_state = 2; } } col = col_start; lines_used++; if (lines_used + line_start >= LINES) return lines_used; } if (drawmode != drawmode_test) { if (line_start + lines_used - 1 >= 0) { move (line_start + lines_used - 1, col); /* must break the word in two due to differnt text formatting */ if (drawmode == drawmode_completion && cursor_state == 0 && dpos >= cursor_pos) { int i; for (i = 0; i < wpos - (dpos - cursor_pos); i++) addch (word[i]); if (node_right (node)) { ui_style (ui_style_parentselected); } else { ui_style (ui_style_selected); } for (i = wpos - (dpos - cursor_pos); i < wpos; i++) addch (word[i]); } else { addstr ((char *) word); } if (data[dpos]) addch (' '); } } switch (drawmode) { case drawmode_edit: if (cursor_state == 0 && dpos >= cursor_pos) { cy = line_start + lines_used - 1; cx = col - (dpos - cursor_pos) + wpos; cursor_state = 1; } break; case drawmode_completion: if (cursor_state == 0 && dpos >= cursor_pos) { if (node_right (node)) { ui_style (ui_style_parentselected); } else { ui_style (ui_style_selected); } cursor_state = 1; } default: break; } col += wpos + 1; word[wpos = 0] = 0; break; default: if (wpos < 198) { word[wpos++] = data[dpos]; word[wpos] = 0; } break; } dpos++; } /* draw the cursor */ if (drawmode == drawmode_edit) { move (cy, cx); if (node_right (node)) { ui_style (ui_style_parentselected); } else { ui_style (ui_style_selected); } addch (data[cursor_pos]); if (node_right (node)) { ui_style (ui_style_parentnode); } else { ui_style (ui_style_node); } } return lines_used; } static int draw_dummy (int line, int col, int width, Node *node, int drawmode) { if (width == 0) width = 1; if (drawmode != drawmode_test) { int j; move (line, col); ui_style (ui_style_bullet); for (j = 0; j < width; j++) { addch ('X'); } } return width; } static int draw_spacing (int line, int col, int width, Node *node, int drawmode) { if (width == 0) width = 1; if (drawmode != drawmode_test) { int j; move (line, col); ui_style (ui_style_background); for (j = 0; j < width; j++) { addch (' '); } } return width; } static char bullet_leaf[4] = " ·"; static char bullet_parent[4] = " +"; static char bullet_parent_expanded[4] = " -"; static int draw_bullet (int line, int col, int width, Node *node, int drawmode) { int asize; int perc; /* if(width==0)*/ width = 3; perc = calc_percentage_size (node, &asize); { ui_style (ui_style_bullet); move (line, col); switch (perc) { case -1: if (drawmode != drawmode_test) addstr ((node_right (node)) ? node_getflag(node,F_expanded) ? bullet_parent_expanded : bullet_parent : bullet_leaf); break; case 0: if (drawmode != drawmode_test) addstr ("[ ]"); break; case 2000: if (drawmode != drawmode_test) addstr ("[X]"); break; default:{ char str[100]; snprintf (str, 4, "%2i%%", perc); if (drawmode != drawmode_test) addstr (str); } } } return width; } static char *node2no_path (Node *node) { static char path[512]; int pos = 0; int levels = nodes_left (node); int cnt; path[0] = 0; for (cnt = levels; cnt >= 0; cnt--) { int cnt2; Node *tnode = node; for (cnt2 = 0; cnt2 < cnt; cnt2++) tnode = node_left (tnode); sprintf (&path[pos], "%i", nodes_up (tnode) + 1); pos = strlen (path); path[pos] = '.'; path[++pos] = 0; } path[--pos] = 0; return (path); } static int draw_node_no (int line, int col, int width, Node *node, int drawmode) { char str[100] = ""; if (width == 0) width = 4; ui_style (ui_style_bullet); move (line, col); snprintf (str, 5, "%4i", node_no (node)); if (drawmode != drawmode_test) { addstr (str); } return width; } static int draw_nr (int line, int col, int width, Node *node, int drawmode) { char str[100] = ""; if (width == 0) width = 3; ui_style (ui_style_bullet); move (line, col); snprintf (str, 5, "%3i", nodes_up (node) + 1); if (drawmode != drawmode_test) { addstr (str); } return width; } static int draw_anr (int line, int col, int width, Node *node, int drawmode) { char str[100] = ""; char fstr[20]; if (width == 0) width = 8; ui_style (ui_style_bullet); move (line, col); snprintf (fstr, 8, "%%%is", width); snprintf (str, width + 2, fstr, node2no_path (node)); if (drawmode != drawmode_test) { addstr (str); } return width; } static int node_getval(Node *node, char *name){ char *got=node_get(node,name); if(!got)return -1; return(atoi(got)); } static int draw_debug (int line, int col, int width, Node *node, int drawmode) { int asize; int size = node_getval (node,"size"); int perc; width = 40; if (drawmode != drawmode_test) { ui_style (ui_style_background); move (line, col); perc = calc_percentage_size (node, &asize); { char str[64]; sprintf (str, "(%i/%i) ", (perc == 2000 ? 100 : perc * asize) / 100, asize); if (drawmode != drawmode_test) addstr (str); } { perc = calc_percentage_size (node, &asize); attrset (A_NORMAL); { char str[256]; sprintf (str, "size:%i a_size:%i %i%% ", node_getval (node,"size"), size, perc); addstr (str); } } if (node_calc_size (node) != -1) { char str[10]; sprintf (str, "%4.1f ", (float) node_calc_size (node) / 10.0); addstr (str); } } return width; } #define MAX_COLUMNS 20 static int draw_indent (int line, int col, int width, Node *node, int drawmode) { if (width == 0) width = 4; return width * nodes_left (node); } enum { col_spacing = 0, col_indent, col_nr, col_anr, col_bullet, col_data, col_debug, col_percentage, col_node_no, col_dummy, col_terminate }; static int (*col_fun[col_terminate + 1]) (int line, int col, int width, Node *node, int drawmode) = { draw_spacing, draw_indent, draw_nr, draw_anr, draw_bullet, draw_spacing, draw_debug, draw_spacing, draw_node_no, draw_dummy, draw_dummy}; static struct { int type; int width; } col_def[MAX_COLUMNS] = { { col_indent, 4}, { col_spacing, 1}, { col_bullet, 3}, { col_spacing, 1}, { col_data, 0}, { col_spacing, 1}, { col_dummy, 10}, { col_spacing, 2}, { col_dummy, 10}, { col_spacing, 1}, { col_terminate, 0} }; /* FIXME: make backup?,.. and make sure data is present,.., make possiblity to write back? */ int display_format_cmd (int argc, char **argv, void *data) { char *p = argv[1]; int width; int type; int col_no = 0; if(argc<2){ return (int)data; } do { width = 0; type = col_spacing; switch (*p) { case 'i': type = col_indent; if (isdigit (*(p + 1))) { width = atoi (p + 1); while (isdigit ((unsigned char)*(p + 1))) p++; } break; case 'd': type = col_data; if (isdigit (*(p + 1))) { width = atoi (p + 1); while (isdigit ((unsigned char)*(p + 1))) p++; } break; case 'D': type = col_debug; if (isdigit (*(p + 1))) { width = atoi (p + 1); while (isdigit ((unsigned char)*(p + 1))) p++; } break; case 'x': type = col_dummy; if (isdigit (*(p + 1))) { width = atoi (p + 1); while (isdigit ((unsigned char)*(p + 1))) p++; } break; case '1': type = col_nr; if (*(p + 1) == '.') { type = col_anr; p++; } if (isdigit (*(p + 1))) { width = atoi (p + 1); while (isdigit ((unsigned char)*(p + 1))) p++; } break; case '-': type = col_bullet; if (isdigit (*(p + 1))) { width = atoi (p + 1); while (isdigit ((unsigned char)*(p + 1))) p++; } break; case '#': type = col_node_no; if (isdigit (*(p + 1))) { width = atoi (p + 1); while (isdigit ((unsigned char)*(p + 1))) p++; } break; case ' ': type = col_spacing; while (' ' == ((unsigned char)*(p + 1))) { p++; width++; } break; default: cli_outfunf ("td not_parsed(%c)", *p); break; } col_def[col_no].type = type; col_def[col_no].width = width; col_no++; } while (*(++p)); col_def[col_no].type = col_terminate; return (int) data; } /* * @param line_start which line on the display the first line of the draw node is on * @param level the indentation level of this item * @param node the node to draw * @param cursor_pos different meanings in different modes, testmode: none * highlightmode: none, edit_mode: the position in the data * that should be highlighted, * completion: the number of matched chars in data * * @param draw_mode 1=draw, 0=test * * @return number of lines needed to draw item **/ static int draw_item (int line_start, int cursor_pos, Node *node, int drawmode) { int col_no = 0; int lines_used = 1; int col_start = 0; int col_end = COLS; col_start = 0; /* draw columns before col_data */ while (col_def[col_no].type != col_data && col_def[col_no].type != col_terminate) { col_start += col_fun[col_def[col_no].type] (line_start, col_start, col_def[col_no].width, node, drawmode); col_no++; } /* fastforward to end of col_def */ while (col_def[col_no].type != col_terminate) col_no++; col_no--; /* draw columns after col_data */ while (col_no && col_def[col_no].type != col_data) { int width = col_fun[col_def[col_no].type] (line_start, col_end - col_def[col_no].width, col_def[col_no].width, node, drawmode_test); col_end -= col_fun[col_def[col_no].type] (line_start, col_end - width, width, node, drawmode); col_no--; } lines_used = draw_textblock (line_start, col_start, (col_end - col_start), cursor_pos, node, drawmode); return lines_used; } extern int hnb_nodes_up; extern int hnb_nodes_down; #define MAXLINES 512 static int line_nodeno[MAXLINES] = { 0 }; void ui_draw (Node *node, char *input, int edit_mode) { int lines; static struct { int self; int prev; } node_numb = { 1, 1}; if (!prefs.fixedfocus) { node_numb.prev = node_numb.self; node_numb.self = node_no (node); if (node_numb.self > node_numb.prev) { active_line++; } else if (node_numb.self < node_numb.prev) { active_line--; } { int i; for (i = 0; i < ((LINES < MAXLINES) ? LINES : MAXLINES); i++) if (line_nodeno[i] == node_numb.self) { active_line = i; break; } } if (node_numb.self == 1) { /* jumped to root, always bring nodes to top of screen */ active_line = 1; } { int i; for (i = 0; i < ((LINES < MAXLINES) ? LINES : MAXLINES); i++) line_nodeno[i] = 0; } { int maxline = LINES - KEEPLINES; if (active_line > maxline) /*if we overlap with help,.. move up */ active_line = maxline; if (active_line < KEEPLINES) active_line = KEEPLINES; } }; nodes_above = active_line; nodes_below = LINES - active_line; { hnb_nodes_up = 0; hnb_nodes_down = 0; erase (); /* draw nodes above selected node */ { Node *prev_down = node; /* to aid pgup/pgdn */ int line = active_line; Node *tnode = up (node, node); while (tnode) { draw_item (line -= draw_item (0, 0, tnode, drawmode_test), 0, tnode, drawmode_normal); line_nodeno[line] = node_no (tnode); if (node_down (tnode) == prev_down) { hnb_nodes_up++; prev_down = tnode; } tnode = up (node, tnode); if (active_line - nodes_above >= line) tnode = 0; } } /* draw the currently selected item */ line_nodeno[active_line] = node_no (node); if (edit_mode) { lines = draw_item (active_line, (int) input, node, drawmode_edit); } else { lines = draw_item (active_line, strlen (input), node, drawmode_completion); } /* draw items below current item */ { Node *prev_up = node; /* to aid pgup/pgdn */ Node *tnode = down (node, node); lines += active_line; if (lines >= LINES) tnode = 0; while (tnode) { line_nodeno[lines] = node_no (tnode); lines += draw_item (lines, 0, tnode, drawmode_normal); if (node_up (tnode) == prev_up) { hnb_nodes_down++; prev_up = tnode; } tnode = down (node, tnode); if (lines >= LINES) tnode = 0; } } } help_draw (ui_current_scope); move (LINES - 1, COLS - 1); /* refresh ();*/ hnb_nodes_up++; hnb_nodes_down++; } /* !init_ui_draw(); */ void init_ui_draw () { cli_add_command ("display_format", display_format_cmd, ""); cli_add_help ("display_format", "\ defines how each node is displayed, the display string syntax is \ interpreted as follows: \ spaces turn into real spaces, i means indentation, - means bullet, \ d means the real data of the node, x is a temporary placeholder for \ upcoming columntypes,. (for debugging only) \ i and x can take an argument specifying how many characters wide \ the field should be"); cli_add_string ("bullet_leaf", bullet_leaf, ""); cli_add_string ("bullet_parent", bullet_parent, ""); cli_add_string ("bullet_parent_expanded", bullet_parent_expanded, ""); } hnb-1.9.18/src/prefs.c0000644000175000017500000000514607723016223014023 0ustar jimjim00000000000000/* * prefs.c -- preferences and global variable mangement of hnb * * Copyright (C) 2001,2003 Øyvind Kolås * * 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, 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. */ #define PREFS_C #include #include #include "tree.h" #include "ui.h" #include "path.h" #include "prefs.h" #include "cli.h" #include "ui_cli.h" #include "file.h" Tprefs prefs = { "hnb", /*format; */ 0, /*tutorial; */ "", /*rc_file[100]; */ "", /*db_file[100]; */ "", /*default_db_file[100]; */ 1, /*showpercent */ 0, /*fixed focusbar */ 0, /*save position */ 0 /*readonly */ }; typedef struct { char name[4]; int color; } ColornameT; /* !init_prefs(); */ void init_prefs () { #ifndef WIN32 sprintf (prefs.rc_file, "%s/.hnbrc", getenv ("HOME")); sprintf (prefs.default_db_file, "%s/.hnb", getenv ("HOME")); #endif #ifdef WIN32 sprintf (prefs.rc_file, "C:\\hnb.rc"); sprintf (prefs.default_db_file, "C:\\hnb_data"); #endif cli_add_string ("format", prefs.format, "the format of the current file"); cli_add_string ("rc_file", prefs.rc_file, ""); cli_add_string ("db_file", prefs.db_file, ""); cli_add_string ("default_db_file", prefs.default_db_file, ""); cli_add_int ("showpercent", &prefs.showpercent, ""); cli_add_int ("fixedfocus", &prefs.fixedfocus, ""); cli_add_int ("savepos", &prefs.savepos, ""); cli_add_int ("readonly", &prefs.readonly, ""); #ifdef NCURSES_VERSION cli_add_int ("escdelay", &ESCDELAY, "how long does curses wait before it decides ESC is ESC and not a coded key sequence"); #endif } void write_default_prefs () { FILE *file; file = fopen (prefs.rc_file, "w"); fprintf (file, #include "hnbrc.inc" ); fclose (file); } void load_prefs (void) { if (xml_check (prefs.rc_file)) { printf ("seems like your current ~/.hnbrc is outdated (it's xml the new format\n\ is plain text,.. remove it and let hnb make a new default\n"); exit (0); } cli_load_file (prefs.rc_file); } hnb-1.9.18/src/prefs.h0000644000175000017500000000100007723016223014011 0ustar jimjim00000000000000#ifndef PREFS_H #define PREFS_H #define RC_REV 8 /* global struct used to remeber user preferences */ typedef struct { char format[128]; int tutorial; char rc_file[100]; char db_file[100]; char default_db_file[100]; int showpercent; int fixedfocus; int savepos; int readonly; } Tprefs; extern Tprefs prefs; /* initializes preferences with default values */ void init_prefs (); /* load preferences, from prefs.rc_file */ void load_prefs (void); void write_default_prefs (); #endif /* PREFS_H */ hnb-1.9.18/src/ui_menu.c0000644000175000017500000000636107723016223014345 0ustar jimjim00000000000000#include "tree.h" #include "cli.h" #include "ui.h" #include "ui_style.h" #include int ui_menu_is_not_implemented_yet; typedef struct MenuT{ char *label; char *command; int width; } MenuT; #define MENU_MAX_COLS 10 #define MENU_MAX_ROWS 20 static MenuT menu[MENU_MAX_COLS][MENU_MAX_ROWS]; static int xpos_forcol(int colno){ int cumulated=0; int col; for(col=0;col':' '); else move(row,xpos_forcol(col)+1); ui_style(ui_style_menuitem); addstr(menu[col][row].label); {int i=menu[col][0].width-strlen(menu[col][row].label); while(i--)addch(' '); } ui_style(ui_style_menutext); addch((col==cur_col && row==cur_row)?'<':' '); } } move (LINES - 1, COLS - 1); } static Node *menu_do(Node *pos){ static int row=0,col=0; int stop=0; Tbinding *c; while(!stop){ draw_menu(pos,col,row); c=parsekey(ui_input(),ui_scope_nodeedit); switch(c->action){ case ui_action_right: if(menu[col+1][0].label) col++; else col=0; while(!menu[col][row].label) row--; break; case ui_action_left: if(col>0) col--; else while(menu[col+1][0].label) col++; while(!menu[col][row].label) row--; break; case ui_action_up: if(row>1) row--; else while(menu[col][row+1].label) row++; break; case ui_action_down: if(menu[col][row+1].label) row++; else while(row>1) row--; break; case ui_action_cancel: stop=1; break; case ui_action_confirm: if(row)pos=docmd(pos,menu[col][row].command); stop=1; break; default: break; } } return pos; } static int cmd_menu(int argc,char **argv,void *data){ Node *pos=(Node *)data; if(argc==1){ /* draw menu */ return (int)menu_do(pos); } else if(argc==4){ char *submenu=argv[1]; char *label=argv[2]; char *command=argv[3]; int col=0,row=0; /* locate right submenu */ while(colmenu[col][0].width) menu[col][0].width=menu[col][row].width; } return(int)pos; } /* !init_ui_menu(); */ void init_ui_menu(void){ cli_add_command("menu",cmd_menu,""); memset(menu,0,sizeof(menu)); } #if 0 macro define commandline 1 commandline 2 commandline 3 commandline 4 end menu file "save (F2)" "save" menu file "revert" "revert" menu file "quit" "quit" menu edit "copy ^C" "copy" menu edit "cut ^X" "cut" menu edit "paste ^V" "paste" #endif hnb-1.9.18/src/statcmds.c0000644000175000017500000000537607723016223014533 0ustar jimjim00000000000000/* * statcmds.c -- commands that output various statistics * * Copyright (C) 2003 Øyvind Kolås * * 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, 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. */ #include "tree.h" #include "cli.h" #include #ifndef WIN32 static int mem_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; { int VmSize; FILE *file; file = fopen ("/proc/self/stat", "r"); if (!file) return (int) pos; fscanf (file, "%*i %*s %*s %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %*i %i", &VmSize); fclose (file); cli_outfunf ("Memory used: %2.2fmb (%ib)", (float) (VmSize / 1024.0 / 1024.0), VmSize); } { int free, buffers, cached; FILE *file; file = fopen ("/proc/meminfo", "r"); if (!file) return (int) pos; fscanf (file, "%*s %*s %*s %*s %*s %*s %*s %*i %*i %i %i %i", &free, &buffers, &cached); fclose (file); cli_outfunf ("Memory free: %2.2fmb (+buffers/cache: %2.2fmb)", (float) (free / 1024.0 / 1024.0), (float) ((free + buffers + cached) / 1024.0 / 1024.0)); } return (int) pos; } #endif /* !init_mem(); */ void init_mem () { #ifndef WIN32 cli_add_command ("mem", mem_cmd, ""); cli_add_help ("mem", "Reports memory usage of application"); #endif } #include static int count_words (unsigned char *str) { int words = 0; unsigned char *p = str; do { if (!isspace (*p)) { words++; while (*p && (!isspace (*p))) p++; } else { p++; } } while (*p); return words; } static int stats_cmd (int argc, char **argv, void *data) { int words = 0, leaves = 0, nodes = 0; Node *pos = (Node *) data; Node *node = node_root (pos); while (node) { nodes++; words += count_words ((unsigned char *)fixnullstring (node_get (node, TEXT))); if (!node_right (node)) leaves++; node = node_recurse (node); } cli_outfunf ("nodes:%i, leaves:%i words:%i", nodes, leaves, words); return (int) pos; } /* !init_stats(); */ void init_stats () { cli_add_command ("stats", stats_cmd, ""); cli_add_help ("stats", "Reoprts number of items, leaf items and total number of words in tree"); } hnb-1.9.18/src/ui_binding.c0000644000175000017500000002614007723016223015010 0ustar jimjim00000000000000/* * ui_binding.c -- management of keybindings * * Copyright (C) 2001,2001 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include "tree.h" #include "prefs.h" #include #include "cli.h" /* should be moved to keybinding file */ #include /* should be moved to keybinding file */ #include #include #include "ui.h" static int scope_count = ui_scope_tempterm; char *ui_scope_names[MAX_SCOPES] = { "main", "confirm", "nodeedit", "lineedit" }; static char *ui_action_names[ui_action_terminator - 512] = { "backspace", "bkill_word", "bol", "bottom", "bskipword", "cancel", "command", "complete", "confirm", "delete", "down", "eol", "ignore", "join", "kill_line", "kill_to_bol", "kill_to_eol", "kill_word", "left", "pagedown", "pageup", "quit", "right", "skipword", "split", "top", "unbound", "up", }; typedef struct { int code; char *name; } keydbitm; static keydbitm keydb[] = { {KEY_BREAK, "break"}, {KEY_DOWN, "down"}, {KEY_UP, "up"}, {KEY_LEFT, "left"}, {KEY_RIGHT, "right"}, {KEY_HOME, "home"}, {KEY_BACKSPACE, "backspace"}, {KEY_F (1), "f1"}, {KEY_F (2), "f2"}, {KEY_F (3), "f3"}, {KEY_F (4), "f4"}, {KEY_F (5), "f5"}, {KEY_F (6), "f6"}, {KEY_F (7), "f7"}, {KEY_F (8), "f8"}, {KEY_F (9), "f9"}, {KEY_F (10), "f10"}, {KEY_F (11), "f11"}, {KEY_F (12), "f12"}, {KEY_DC, "del"}, {KEY_IC, "ins"}, {KEY_EIC, "eic"}, {KEY_NPAGE, "npage"}, {KEY_PPAGE, "ppage"}, {KEY_ENTER, "enter"}, {KEY_LL, "ll"}, {KEY_A1, "a1"}, {KEY_A3, "a3"}, {KEY_B2, "b2"}, {KEY_C1, "c1"}, {KEY_C3, "c3"}, {KEY_BEG, "beg"}, {KEY_CANCEL, "cancel"}, {KEY_CLOSE, "close"}, {KEY_COMMAND, "command"}, {KEY_COPY, "copy"}, {KEY_CREATE, "create"}, {KEY_END, "end"}, {KEY_EXIT, "exit"}, {KEY_FIND, "find"}, {KEY_HELP, "help"}, {KEY_MARK, "mark"}, {KEY_MESSAGE, "message"}, {KEY_MOVE, "move"}, {KEY_NEXT, "next"}, {KEY_OPEN, "open"}, {KEY_OPTIONS, "options"}, {KEY_PREVIOUS, "previous"}, {KEY_REDO, "redo"}, {KEY_REFERENCE, "reference"}, {KEY_REFRESH, "refresh"}, {KEY_REPLACE, "replace"}, {KEY_RESTART, "restart"}, {KEY_RESUME, "resume"}, {KEY_SAVE, "save"}, {KEY_SBEG, "sbeg"}, {KEY_SCANCEL, "scancel"}, {KEY_SCOMMAND, "scommand"}, {KEY_SCOPY, "scopy"}, {KEY_SCREATE, "screate"}, {KEY_SDC, "sdc"}, {KEY_SDL, "sdl"}, {KEY_SELECT, "select"}, {KEY_SEND, "send"}, {KEY_SEOL, "seol"}, {KEY_SEXIT, "sexit"}, {KEY_SFIND, "sfind"}, {KEY_SHELP, "shelp"}, {KEY_SHOME, "shome"}, {KEY_SIC, "sic"}, {KEY_SLEFT, "sleft"}, {KEY_SMESSAGE, "smessage"}, {KEY_SMOVE, "smove"}, {KEY_SNEXT, "snext"}, {KEY_SOPTIONS, "soptions"}, {KEY_SPREVIOUS, "sprevious"}, {KEY_SPRINT, "sprint"}, {KEY_SREDO, "sredo"}, {KEY_SREPLACE, "sreplace"}, {KEY_SRIGHT, "sright"}, {KEY_SRSUME, "srsume"}, {KEY_SSAVE, "ssave"}, {KEY_SSUSPEND, "ssupsend"}, {KEY_SUNDO, "sundo"}, {KEY_SUSPEND, "suspend"}, {KEY_UNDO, "undo"}, {' ', "space"}, {0, "^space"}, {1, "^A"}, {2, "^B"}, {3, "^C"}, {4, "^D"}, {5, "^E"}, {6, "^F"}, {7, "^G"}, {8, "backspace2"}, {9, "tab"}, {10, "^J"}, {11, "^K"}, {12, "^L"}, {13, "return"}, {14, "^N"}, {15, "^O"}, {16, "^P"}, {17, "^Q"}, {18, "^R"}, {19, "^S"}, {20, "^T"}, {21, "^U"}, {22, "^V"}, {23, "^W"}, {24, "^X"}, {25, "^Y"}, {26, "^Z"}, {27, "esc"}, {999, ".."}, {1000, "any"}, /* special key used to trap all keys (i.e. avoid typing without editing) */ }; #define MAX_BINDINGS 255 /* maximum number of bound functions in one context */ Tbinding ui_binding[MAX_SCOPES][MAX_BINDINGS]; static int ui_binding_count[MAX_SCOPES] = { 0 }; static int string2scope (char *str) { int j = 0; while (j < scope_count) { if (!strcmp (str, ui_scope_names[j])) return j; j++; } if (j < MAX_SCOPES - 2) { ui_scope_names[j] = strdup (str); scope_count++; return j; } printf ("scope limit exceeded\n"); exit (0); } static int string2action (char *str) { int j = 0; while (j < ui_action_terminator - 512) { if (!strcmp (ui_action_names[j], str)) return j + 512; j++; } return -1; } static int string2keycode (char *str) { int i; if (strlen (str) == 1) /* a string consisting og just one char,.. is a single key */ return str[0]; for (i = 0; i < sizeof (keydb) / sizeof (keydbitm); i++) if (!strcmp (keydb[i].name, str)) return (keydb[i].code); return -1; } int ui_current_scope = 0; static int ui_context_cmd (int argc, char **argv, void *data) { if(argc<2){ cli_outfunf("usage: %s ",argv[0]); return(int)data; } ui_current_scope = string2scope (argv[1]); return (int) data; } static void makebinding (int scope_no, int key, int action, char *action_name, char *action_params) { ui_binding[scope_no][ui_binding_count[scope_no]].key = key; ui_binding[scope_no][ui_binding_count[scope_no]].action = action; ui_binding[scope_no][ui_binding_count[scope_no]].action_name = strdup (action_name); ui_binding[scope_no][ui_binding_count[scope_no]].action_param = strdup (action_params); ui_binding_count[scope_no]++; } static int ui_bind_cmd (int argc, char **argv, void *data) { /* char context[40];*/ char *key; char *action; if(argc<3){ cli_outfunf("error in bindings %s %s %s %s\n",argv[0],argv[1],argv[2],argv[3]); return (int)data; } key=argv[1]; action=argv[2]; if (string2action (action) != -1) { makebinding (ui_current_scope, string2keycode (key), string2action (action), action, ""); } else { makebinding (ui_current_scope, string2keycode (key), ui_action_command, "command", action); } return (int) data; } static Tbinding keyproxy = { 0, 0, "key", "key" }; Tbinding *lastbinding; Tbinding *parsekey (int key, int scope) { int j = 0; while (j < ui_binding_count[scope]) { if (key == ui_binding[scope][j].key) { lastbinding = &ui_binding[scope][j]; return lastbinding; } else if (ui_binding[scope][j].key == 1000 /* anykey */ ) { lastbinding = &ui_binding[scope][j]; *((int *) &lastbinding->action_param[0]) = key; return lastbinding; } j++; } keyproxy.action = key; keyproxy.key = key; lastbinding = &keyproxy; return lastbinding; } static char *unboundstr = "><"; char *resolve_binding (int scope, int action) { int no = 0; while (no < ui_binding_count[scope]) { if (action == ui_binding[scope][no].action) return tidy_keyname (keyname (ui_binding[scope][no].key)); no++; } return unboundstr; } /* * Function to make a keynames returned from curses a little nicer * */ char *tidy_keyname (const char *keyname) { static char buf[100]; strcpy (buf, keyname); if (!strncmp (buf, "KEY_", 4)) { memmove (buf, buf + 4, sizeof (buf) - 4); } if (buf[1] == '(') { memmove (buf + 1, buf + 2, sizeof (buf) - 3); /* Function keys */ if (buf[2] == ')') memmove (buf + 2, buf + 3, sizeof (buf) - 4); if (buf[3] == ')') memmove (buf + 3, buf + 4, sizeof (buf) - 5); } if (!strcmp (buf, "IC")) return "ins"; if (!strcmp (buf, "DC")) return "del"; if (!strcmp (buf, "UP")) return "up"; if (!strcmp (buf, "^M")) return "return"; if (!strcmp (buf, "^I")) return "tab"; if (!strcmp (buf, "END")) return "end"; if (!strcmp (buf, "^[")) return "esc"; if (!strcmp (buf, "^@")) return "^space"; if (!strcmp (buf, " ")) return "space"; if (!strcmp (buf, "BACKSPACE")) return "backspace"; if (strlen (buf) > 3) { char *c = buf; while (*c) { *c = tolower (*c); c++; } } return buf; } /* !init_ui_binding(); */ static int dummy_cmd (int argc, char **argv, void *data) { return (int) data; } void init_ui_binding () { cli_add_command ("bind", ui_bind_cmd, " [parameter]"); cli_add_help ("bind", "Binds the action, to the specified key, subsequent actions my be bound by using the virtual key '..' thus chaining them together into a small script."); cli_add_command ("context", ui_context_cmd, ""); cli_add_help ("context", "Changes context, context may be one of 'main', 'lineedit', 'nodeedit', 'confirm' or any other userdefined context."); /* dummy commands to show the 'builtins' */ /* cli_add_command ("backspace", dummy_cmd, ""); cli_add_help ("backspace", "erase the preceding character"); cli_add_command ("delete", dummy_cmd, ""); cli_add_help ("delete", "erase the following character"); cli_add_command ("down", dummy_cmd, ""); cli_add_command ("left", dummy_cmd, ""); cli_add_command ("right", dummy_cmd, ""); cli_add_command ("up", dummy_cmd, ""); cli_add_help ("down", "moves the cursor or selection down"); cli_add_help ("left", "moves the cursor or selection left"); cli_add_help ("right", "moves the cursor or selection right"); cli_add_help ("up", "moves the cursor or selection up"); cli_add_command ("bkill_word", dummy_cmd, ""); cli_add_command ("kill_word", dummy_cmd, ""); cli_add_help ("bkill_word", "erases the preceding word"); cli_add_help ("bkill_word", "erases the following word"); cli_add_command ("bol", dummy_cmd, ""); cli_add_help ("bol", "move cursor to beginning of line"); cli_add_command ("top", dummy_cmd, ""); cli_add_command ("bottom", dummy_cmd, ""); cli_add_help ("top", "move to the topmost sibling of the current entry"); cli_add_help ("bottom", "move to the bottommost sibling of the current entry"); cli_add_command ("bskipword", dummy_cmd, ""); cli_add_command ("cancel", dummy_cmd, ""); cli_add_command ("complete", dummy_cmd, ""); cli_add_help ("complete", "output possible completions of entered command or variable"); cli_add_command ("confirm", dummy_cmd, ""); cli_add_help ("confirm", "confirm the question posed, (used in dialogs asking for the users' consent)"); cli_add_command ("eol", dummy_cmd, ""); cli_add_help ("eol", "move to the end of the line"); cli_add_command ("ignore", dummy_cmd, ""); cli_add_command ("join", dummy_cmd, ""); cli_add_command ("split", dummy_cmd, ""); cli_add_help ("join", "join the currently edited node with the following sibling"); cli_add_help ("split", "split the currently edited node at the cursor location"); cli_add_command ("kill_line", dummy_cmd, ""); cli_add_help ("kill_line", "erase the currently edited line"); cli_add_command ("kill_to_bol", dummy_cmd, ""); cli_add_command ("kill_to_eol", dummy_cmd, ""); cli_add_command ("pagedown", dummy_cmd, ""); cli_add_command ("pageup", dummy_cmd, ""); cli_add_command ("skipword", dummy_cmd, ""); cli_add_command ("unbound", dummy_cmd, ""); cli_add_help ("unbound", "give a message indicating that the pressed key is not bound in the current context"); */ } hnb-1.9.18/src/tree_sort.c0000644000175000017500000001001207723016223014676 0ustar jimjim00000000000000/* * tree_sort.c -- function to sort a level of nodes * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #include #include #include #include #include "tree.h" #include "cli.h" static int cmp_random (Node *b, Node *a) { return (random () % 3) - 1; } static int is_done(Node *n){ char *r=node_get(n,"done"); if(!r)return 0; if(!strcmp(r,"yes")) return 1; return 0; } static int cmp_todo (Node *a, Node *b) { if (!(a->flags) && !(b->flags)) return (strcasecmp (fixnullstring (node_get (a, TEXT)), fixnullstring (node_get (b, TEXT)))); if (node_get(a,"done") && !node_get(b,"done")) return 1; /* all todos at top */ if (!node_get(a,"done") && node_get(b,"done")) return -1; if (node_get(a,"done") && node_get(b, "done")) { if (!is_done(a) && is_done(b) ) return 1; /* not done */ if (is_done(a) && !is_done(b) ) return -1; } return (strcasecmp (fixnullstring (node_get (a, TEXT)), fixnullstring (node_get (b, TEXT)))); } static Node *merge (Node *nodeA, Node *nodeB, int (*cmp) (Node *a, Node *b)) { Node *thead, *tnode; if (!nodeA) return nodeB; if (!nodeB) return nodeA; /* first move the smallest of the head nodes to our head */ if (cmp (nodeA, nodeB) <= 0) { /* a is smaller than or equal to b */ thead = nodeA; nodeA = nodeA->down; thead->down = NULL; } else { /* b is smaller than or equal to a */ thead = nodeB; nodeB = nodeB->down; thead->down = NULL; } tnode = thead; /* merge while we get data from both lists */ while (nodeA && nodeB) { if (cmp (nodeA, nodeB) <= 0) { /* a is smaller than or equal to b */ tnode->down = nodeA; nodeA->up = tnode; tnode = nodeA; nodeA = nodeA->down; } else { /* b is smaller than or equal to a */ tnode->down = nodeB; nodeB->up = tnode; tnode = nodeB; nodeB = nodeB->down; } } /* add remainder of remaining list */ if (nodeA) { tnode->down = nodeA; nodeA->up = tnode; } else if (nodeB) { tnode->down = nodeB; nodeB->up = tnode; } else { tnode->down = NULL; } return thead; } /* */ static Node *node_mergesort (Node *head, int size, int (*cmp) (Node *a, Node *b)) { if (size == 1) { return head; } else { Node *top = head, *bottom = head; int topsize = size / 2, bottomsize = topsize + (size % 2); int j = topsize; while (j--) bottom = node_down (bottom); node_up (bottom)->down = NULL; bottom->up = NULL; top = node_mergesort (top, topsize, cmp); bottom = node_mergesort (bottom, bottomsize, cmp); return merge (top, bottom, cmp); } } static int cmp_descending(Node *a,Node *b){ return cmp_todo(b,a); } static int sort_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; int (*cmp) (Node *a, Node *b)=cmp_todo; if(argc>1){ if(!strcmp(argv[1],"-a"))cmp=cmp_todo; else if(!strcmp(argv[1],"-d"))cmp=cmp_descending; else if(!strcmp(argv[1],"-r"))cmp=cmp_random; } node_mergesort (node_top (pos), nodes_down (node_top (pos)) + 1, cmp); if (node_left (pos)) node_left (pos)->right = node_top (pos); return (int) pos; } /* !init_sort(); */ void init_sort () { cli_add_command ("sort", sort_cmd, "[-r|-a|-d]"); cli_add_help ("sort", "Sorts the siblings of the currently selected node, the way the nodes is sorted can be specified -a=ascending -d=descending -r=random(shuffle"); } hnb-1.9.18/src/tutorial.inc0000644000175000017500000002326207723016223015075 0ustar jimjim00000000000000#define i(a,b,c) do{Node *tnode=node_new();node_set(tnode,TEXT,b);node_setflags(tnode,c);import_node(&ist,a,tnode);}while(0) i(0,"Using Outlines",0); i(1,"Managing entries",0); i(2,"Navigating amongst entries",0); i(3,"The arrow keys will move you amongst the entries in the tree, you may also start typing the name of a entry that exist on the current level, and hnb will take you to the entry that matches what you've typed, pressing tab twice will enter the sub-level of the current entry, this behavior is modeled after the name completion in Unix shells.",0); i(3,"PageUp/PageDown will skip a large amount of entries up and down.",0); i(3,"Home will bring you to the \\root\\ (the first entry) of the tree.",0); i(3,"Searching",0); i(4,"^F will ask you for a search term, you may thereafter navigate amongst the occurrences of the search term with up/down n/p, pressing space or return will make you stop where you found the substring, ESC will bring you back to where you started the search.",0); i(2,"Moving entries",0); i(3,"You can move entries either by pressing shift and using the arrow keys, the entry will then move within the constraints of the hierarchical structure.",0); i(3,"You can also move entries by cutting and pasting a entry, this has much of the same effect, cut is instantiated with ^C and the paste command is ^V",0); i(2,"Adding entries",0); i(3,"Pressing insert will add a new entry below the current. You will also immediately enter edit mode.",0); i(3,"You may also exploit the fact that searching by keyboard for a entry that doesn't exist, and pressing enter, will create the entry name that you entered.",0); i(2,"Deleting entries",0); i(3,"If you press delete the current entry will be deleted, if it has children you will be asked to confirm the action.",0); i(3,"Cutting can also be used to remove data, no confirmation will be asked whether you want to fulfill you action or not, but the data will be available from the clipboard.",0); i(2,"Indenting and Outdenting entries",0); i(3,"> will move the current entry and all the following entries of the same level to be children of the preceding entry.",0); i(3,"< will move the current entry and all the following entries of the same level to follow the parent of the preceding entry.",0); i(2,"Expanding and Collapsing entries",0); i(3,"expanding",0); i(4,"pressing '+' on a entry with sub entries will display the sub entries even when you're not within them, thus displaying a larger portion of the tree.",0); i(3,"collapsing",0); i(4,"Pressing '-' has the opposite effect of '+' it hides the expanded entries",0); i(3,"operations working on the whole outline",0); i(4,"pressing F10 brings up the user menu,.. a menu where miscellany commands that don't fit anywhere else are added,.. here you may expand or collapse all entries in the current tree.",0); i(1,"Editing entries",0); i(2,"Pressing Return will start editing the current entry, now the cursor keys move between the characters of the data in the entry instead amongst the entries",0); i(2,"(most) Default editing shortcuts",0); i(2,"Splitting entries",0); i(3,"When editing a entry you may press ^S, the entry being edited will be split in the current position. The data to the left of the cursor will be retained in the current entry, whilst the remaining data will be inserted in a new entry below.",0); i(2,"Joining entries",0); i(3,"Pressing ^J whilst editing a entry will join the following entry, (as long as it doesn't have sub-nodes) will merge the data in; at the end of the entry being edited.",0); i(1,"Spell-checking",0); i(2,"By default hnb is configured to use ispell for spell-checking.",0); i(2,"Pressing F6 will spell-check the current entry",0); i(2,"Ispell will start and guide you through the unmatched words in the current entry.",0); i(2,"Thereafter you can press space to spell check the next entry, escape to cancel the changes or return to accept the changes made.",0); i(1,"Sorting entries",0); i(2,"pressing ctrl+s will sort the entries on the current level",0); i(0,"Other features",0); i(1,"Todo-list mode",0); i(2,"^T toggles checkmarks instead of bullets,. ^D checks or unchecks the checkmarks.",0); i(2,"percentages are shown for unchecked parents that have checked subentries",0); i(1,"Using URLs",0); i(2,"If an entry contains a web url ^A will bring up the configured web browser, (see your ~/.hnbrc for more information about configuration)",0); i(1,"Calendars",0); i(2,"From the commandline you can issue a command like \\insert_cal 3 2003\\ to insert a calendar template.",0); i(1,"Using Email addresses",0); i(2,"If an entry contains a email-address ^A will bring up the configured mail client, (see your ~/.hnbrc for more information about configuration)",0); i(0,"Configuring hnb",0); i(1,"Nothing here yet, please examine your ~/.hnbrc (created automatically the first time you run hnb) for information.",0); i(0,"sample data",0); i(1,"This is a stripped down version of the authors default database.. the real database contains >4000 entires",0); i(1,"contacts",0); i(2,"frodo baggins",0); i(3,"or perhaps underhill",0); i(3,"555-12341324",0); i(3,"frode@bagend.net",0); i(2,"merry",0); i(3,"meridoc somthing",0); i(3,"555-23234324",0); i(2,"peregrin took",0); i(3,"aka pippin",0); i(3,"pippin@users.sourceforge.net",0); i(2,"sam gamgee",0); i(3,"samwise",0); i(3,"555-12341234",0); i(3,"sam@gamgee.com",0); i(1,"calendar",0); i(2,"2003 March",0); i(3,"Sat_01 ",0); i(3,"Sun_02 ",0); i(3,"Mon 03 ",0); i(3,"Tue 04 ",0); i(3,"Wed 05 ",0); i(3,"Thu 06 ",0); i(3,"Fri 07 ",0); i(3,"Sat_08 ",0); i(3,"Sun_09 ",0); i(3,"Mon 10 ",0); i(3,"Tue 11 remember to do some stuff",0); i(3,"Wed 12 ",0); i(3,"Thu 13 ",0); i(3,"Fri 14 ",0); i(3,"Sat_15 ",0); i(3,"Sun_16 ",0); i(4,"got some sub entries on my todolist here,..",0); i(3,"Mon 17 ",0); i(3,"Tue 18 ",0); i(3,"Wed 19 ",0); i(3,"Thu 20 ",0); i(3,"Fri 21 ",0); i(3,"Sat_22 ",0); i(3,"Sun_23 ",0); i(3,"Mon 24 ",0); i(3,"Tue 25 ",0); i(3,"Wed 26 ",0); i(3,"Thu 27 ",0); i(3,"Fri 28 ",0); i(3,"Sat_29 ",0); i(3,"Sun_30 ",0); i(3,"Mon 31 ",0); i(2,"2003 April",0); i(3,"Tue 01 Aprils Fool",0); i(4,"need to find some good ideas for jokes",0); i(3,"Wed 02 ",0); i(3,"Thu 03 ",0); i(3,"Fri 04 ",0); i(3,"Sat_05 ",0); i(3,"Sun_06 ",0); i(3,"Mon 07 ",0); i(3,"Tue 08 ",0); i(3,"Wed 09 ",0); i(3,"Thu 10 ",0); i(3,"Fri 11 ",0); i(3,"Sat_12 ",0); i(3,"Sun_13 ",0); i(3,"Mon 14 ",0); i(3,"Tue 15 ",0); i(3,"Wed 16 ",0); i(3,"Thu 17 ",0); i(3,"Fri 18 ",0); i(3,"Sat_19 ",0); i(3,"Sun_20 ",0); i(3,"Mon 21 ",0); i(3,"Tue 22 ",0); i(3,"Wed 23 ",0); i(3,"Thu 24 ",0); i(3,"Fri 25 ",0); i(3,"Sat_26 ",0); i(3,"Sun_27 ",0); i(3,"Mon 28 ",0); i(3,"Tue 29 ",0); i(3,"Wed 30 ",0); i(1,"to-do",0); i(2,"hnb todo",0); i(3,"force all expanded",0); i(3,"clones",0); i(3,"calendar",0); i(3,"new documentation",0); i(4,"start",0); i(4,"asdfasdfadsf",0); i(4,"blah",0); i(4,"asdfasdf",0); i(4,"asdfasdf",0); i(3,"revert to last saved version",0); i(3,"known bugs",0); i(4,"insert bug",0); i(5,"press right",0); i(5,"type data",0); i(5,"press insert",0); i(5,"data is lost,..",0); i(3,"show all of bottommost node when possible",0); i(3,"menu",0); i(4,"working",0); i(4,"dynamic display of keybindings",0); i(5,"(unprobable)",0); i(3,"add real percentages again,.. so I don't have to fake it like I did above on new documentation,..",0); i(3,"autosave",0); i(1,"school",0); i(2,"notes from exam cramming,..",0); i(2,"paper outlines",0); i(2,"...",0); i(1,"work",0); i(2,"I've removed quite a lot of the stuff I actually keep in my database...",0); i(1,"movie manuscripts",0); i(2,"one of them made,.. some of them in planning,.",0); i(2,"I don't want everybody to see them,..",0); i(2,"but it's an actual node in my database",0); i(1,"bookmarks",0); i(2,"http://hnb.sourceforge.net/",0); i(2,"norwegian short film festivals",0); i(3,"http://www.kortfilmfestivalen.no/",0); i(3,"http://www.minimalen.com/",0); i(2,"news",0); i(3,"k5",0); i(4,"http://www.kuro5hin.org/",0); i(3,"slashdot",0); i(4,"http://slashdot.org/",0); i(3,"nettavisen",0); i(4,"http://www.nettavisen.no/",0); i(3,"dagbladet",0); i(4,"http://www.dagbladet.no/",0); i(3,"vg",0); i(4,"http://www.vg.no/",0); i(3,"fark.com",0); i(4,"http://www.fark.com/",0); i(1,"quotes ",0); i(2,"Peoples Front To Reunite Gondwanaland: \\Stop the Laurasian Separatist Movement!\\ ",0); i(2,"slashdot ",0); i(3,"disbelief ",0); i(4,"To anyone who is still stubborn enough to insist that BlackICE Defender is actually good for something: PLEASE do not write to me. I don't want to hear it. I'm a scientist who will not find your mystic beliefs to be compelling. I respect your right to your own opinions, no matter how blatantly they fly in the face of logic and reality. That is, after all, the nature of faith. Happy computing. I suggest prayer. ",0); i(2,"the movie zardoz",0); i(3,"The gun is good. The penis is evil. The penis shoots seeds, and makes new life, and poisons the earth with a plague of men, as once it was. But the gun shoots death, and purifies the earth of the filth of brutals. Go forth and kill!",0); i(1,"old",0); i(2,"I keep a 'trashbin' where I stow away outdated entries,.. just to be able to search it,.. and save it later,..",0); i(0,"",0); i(0,"If you are seeing this the first time running hnb, use your arrow keys to navigate this manual to familiarize yourself with hnb.",0); hnb-1.9.18/src/ui_binding.h0000644000175000017500000000212707723016223015014 0ustar jimjim00000000000000 #ifndef UI_BINDING_H #define UI_BINDING_H typedef struct { int key; int action; char *action_name; char *action_param; } Tbinding; enum { ui_scope_main, ui_scope_confirm, ui_scope_nodeedit, ui_scope_lineedit, ui_scope_tempterm }; enum { ui_action_backspace = 512, ui_action_bkill_word, ui_action_bol, ui_action_bottom, ui_action_bskipword, ui_action_cancel, ui_action_command, ui_action_complete, ui_action_confirm, ui_action_delete, ui_action_down, ui_action_eol, ui_action_ignore, ui_action_join, ui_action_kill_line, ui_action_kill_to_bol, ui_action_kill_to_eol, ui_action_kill_word, ui_action_left, ui_action_pagedown, ui_action_pageup, ui_action_quit, ui_action_right, ui_action_skipword, ui_action_split, ui_action_top, ui_action_unbound, ui_action_up, ui_action_terminator }; #define MAX_SCOPES 16 extern char *ui_scope_names[MAX_SCOPES]; extern Tbinding *lastbinding; extern int ui_current_scope; Tbinding *parsekey (int key, int scope); char *tidy_keyname (const char *keyname); char *resolve_binding (int scope, int action); #endif /* UI_BINDING_H */ hnb-1.9.18/src/file_ascii.c0000644000175000017500000000674707723016223015003 0ustar jimjim00000000000000/* * file_ascii.c -- ascii import and export filters for hnb * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include "cli.h" #include "tree.h" #include "file.h" #include "query.h" #define indent(count,char) {int j;for(j=0;j= startlevel)) { level = nodes_left (tnode) - startlevel; flags = node_getflags (tnode); cdata = fixnullstring (node_get (tnode, TEXT)); ascii_export_node (file, level, flags, cdata); tnode = node_recurse (tnode); } if (file != stdout) fclose (file); cli_outfunf ("ascii export, wrote output to \"%s\"", filename); return (int) node; } /* !init_file_ascii(); */ void init_file_ascii () { cli_add_command ("export_ascii", export_ascii, ""); cli_add_command ("import_ascii", import_ascii, ""); cli_add_int ("ascii_margin", &ascii_margin, "the margin that ascii export wraps at (-1=no wrap)"); } hnb-1.9.18/src/xml_tok.h0000644000175000017500000000200507723016223014355 0ustar jimjim00000000000000#ifndef XML_TOK_H /* xml/html tokenizer (c) Øyvind Kolås 2002 */ #define inbufsize 4096 #define outbufsize 4096 enum { t_none, t_whitespace, t_prolog, t_dtd, t_comment, t_word, t_tag, t_closetag, t_closeemptytag, t_endtag, t_att, t_val, t_eof, t_entity, t_error }; typedef struct { FILE *file_in; int state; char rbuf[outbufsize]; char curtag[outbufsize]; int c; int c_held; unsigned char inbuf[inbufsize]; int inbuflen; int inbufpos; int line_no; } xml_tok_state; xml_tok_state *xml_tok_init (FILE * file_in); void xml_tok_cleanup (xml_tok_state * t); /* get an xml token * @param data pointer to pointer to string where the result * ing data should be put * @return token type * */ int xml_tok_get (xml_tok_state * t, char **data); /** get a html token * same as above, but tries to balance bad html parse * trees, tries to do an automatic transformation from * html to xhtml */ int html_tok_get (xml_tok_state * t, char **data); #define XML_TOK_H #endif /*XML_TOK_H */ hnb-1.9.18/src/actions.c0000644000175000017500000001076707723016223014351 0ustar jimjim00000000000000/* * actions.c -- binding of external applications according to nodedata * * Copyright (C) 2001,2003 Øyvind Kolås * * 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, 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. */ /**************/ #include "tree.h" #include "cli.h" #include "ui.h" #include #include #include #include /*static char url[1024]=""; static char address[1024]="";*/ static char web_command[255] = "galeon -n *"; static char mail_command[255] = "rxvt -rv +sb -e mutt *"; static int cmd_system(int argc, char **argv, void *data){ Node *pos=(Node *)data; int ui_was_inited = ui_inited; if (argc>1) { if (ui_was_inited) ui_end (); system (argv[1]); if (ui_was_inited) ui_init (); } return (int)pos; } static int action_node (Node *node) { char cmdline[512] = ""; char *start = NULL; int ui_was_inited = ui_inited; if (!strncmp ("exec ", fixnullstring (node_get (node, TEXT)), 5)) { sprintf (cmdline, "%s > /dev/null 2>&1 &", fixnullstring (node_get (node, TEXT)) + 5); } else if ((start = strstr (fixnullstring (node_get (node, TEXT)), "http://"))) { char url[200]; char *dest; dest = url; while (*start && !isspace ((unsigned char)*start)) { *dest = *start; dest++; start++; } *dest = 0; { char *cs = web_command; char *cd = cmdline; while (*cs) { if (*cs == '*') { strcat (cd, url); strcat (cd, cs + 1); cli_outfunf ("shelling out: %s", cmdline); //strcat(cd,"> /dev/null 2>&1 &"); break; } else { *cd = *cs; *(++cd) = '\0'; } cs++; } } } else if ((start = strchr (fixnullstring (node_get (node, TEXT)), '@'))) { char mail_address[200]; char *dest; dest = mail_address; while (start > fixnullstring (node_get (node, TEXT)) && !isspace ((unsigned char)*start)) start--; while (*start && !isspace (*start)) { *dest = *start; dest++; start++; } *dest = 0; { char *cs = mail_command; char *cd = cmdline; while (*cs) { if (*cs == '*') { strcat (cd, mail_address); strcat (cd, cs + 1); cli_outfunf ("shelling out: %s", cmdline); //strcat(cd,"> /dev/null 2>&1 &"); break; } else { *cd = *cs; *(++cd) = '\0'; } cs++; } } } if (cmdline[0]) { if (ui_was_inited) ui_end (); system (cmdline); if (ui_was_inited) ui_init (); return 0; } return -1; } /* * this is simplistic approach,.. should perhaps have another one that checks for * url/email address substring,.. and launches an app based on that? * */ static int cmd_action (int argc, char **argv, void *data) { Node *pos = (Node *) data; Node *node = node_right (pos); while (node) { if (!action_node (node)) return (int) pos; node = node_down (node); } if (!action_node (pos)) { return (int) pos; } else { cli_outfunf ("nothing to do"); return (int) pos; } /*** ***/ } /* !init_exec_cmd(); */ void init_exec_cmd () { cli_add_command ("system", cmd_system, ""); cli_add_command ("action", cmd_action, ""); cli_add_help ("action", "executes an external shell according to node content, it first checks the direct children \ then the current node. If it contains an http:// url, the command described in browser_command is executed, if it \ contains a '@' the characters surrounding it is interpreted as an mail address and the mail_command is executed \ and if the data starts with 'exec' the rest of the data is executed verbatim."); cli_add_string ("web_command", web_command, "Command executed when opening url's * is subsituted with the url"); cli_add_string ("mail_command", mail_command, "Command executed when sending mail to a mailaddress * is substituted with the address"); /* cli_add_string("url",url,"url used as parameter for webcommand"); cli_add_string("address",address,"email address used as parameter for mail_command); */} hnb-1.9.18/src/file_xml.c0000644000175000017500000001773007723016223014505 0ustar jimjim00000000000000/* * file_ascii.c -- generic xml import/export filters for hnb * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include "xml_tok.h" #include "cli.h" #include "tree.h" #include "file.h" #include "prefs.h" #include "query.h" #include "util_string.h" #define indent(count,char) {int j;for(j=0;j",">", "&","&", "\"",""", "'","'", NULL }; static char *xmlunquote[]={ "<","<", ">",">", "&","&", ""","\"", "'","'", NULL }; /* returns the first occurence of one of the needles, or 0 (termination) if not found, return 0*/ static int findchar (char *haystack, char *needles) { int j = 0; int k; while (haystack[j]) { for (k = 0; k < strlen (needles) + 1; k++) if (haystack[j] == needles[k]) return j; j++; } return 0; } static void xml_export_nodes (FILE * file, Node *node, int level) { char tag[bufsize]; int flags; char *data; static int no_quote = 0; while (node) { int data_start = 0; tag[0] = 0; flags = node_getflags (node); data = fixnullstring (node_get (node, TEXT)); indent (level, " "); if (data[0] == '<') { /* calculate start tag, if any */ strcpy (tag, data); data_start = findchar (tag, ">") + 1; tag[data_start] = 0; if (data[1] == '!' || data[1] == '?') { no_quote++; } } if (no_quote) fprintf (file, "%s%s", tag, &data[data_start]); else{ char *quoted=string_replace(&data[data_start],xmlquote); fprintf (file, "%s%s", tag, quoted); free(quoted); } if (data[0] == '<') { /* calculate end tag */ strcpy (tag, data); tag[findchar (tag, " \t>") + 1] = 0; tag[findchar (tag, " \t>")] = '>'; tag[0] = '/'; } if (node_right (node)) { fprintf (file, "\n"); xml_export_nodes (file, node_right (node), level + 1); indent (level, " "); if (data[0] == '<') { if (data[1] == '!' && data[2] == '-') { fprintf (file, " -->\n"); } else if (tag[1] != '?' && tag[1] != '!') { fprintf (file, "<%s\n", tag); } else { fprintf (file, "\n"); } } } else { if (data[0] == '<' && data[strlen (data) - 2] != '/') { if (data[1] == '!' && data[2] == '-') { fprintf (file, " -->\n"); } else if (tag[1] != '?' && tag[1] != '!') { fprintf (file, "<%s\n", tag); } else { fprintf (file, "\n"); } } else fprintf (file, "\n"); } if (data[0] == '<' && (data[1] == '!' || data[1] == '?')) { no_quote--; } node = node_down (node); } } static int export_xml (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc==2?argv[1]:""; FILE *file; if (!strcmp (filename, "-")) file = stdout; else file = fopen (filename, "w"); if (!file) { cli_outfunf ("xml export, unable to open \"%s\"", filename); return (int) node; } xml_export_nodes (file, node, 0); if (file != stdout) fclose (file); cli_outfunf ("xml export, wrote data to \"%s\"", filename); return (int) node; } /* joins up tags with data if there is data as the first child of the tag.*/ static Node *xml_cuddle_nodes (Node *node) { Node *tnode; char *tdata; char data[bufsize]; tnode = node_root (node); while (tnode) { if (node_right (tnode)) { tdata = fixnullstring (node_get (node_right (tnode), TEXT)); if (tdata[0] != '<') { /* not a child tag */ strcpy (data, fixnullstring (node_get (tnode, TEXT))); strcat (data, " "); strcat (data, tdata); node_set (tnode, TEXT, data); node_remove (node_right (tnode)); } } tnode = node_recurse (tnode); } return (node); } static int import_xml (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc==2?argv[1]:""; char *rdata; int type; int level = 0; char nodedata[4096]; xml_tok_state *s; import_state_t ist; int got_data = 0; FILE *file; nodedata[0] = 0; file = fopen (filename, "r"); if (!file) { cli_outfunf ("xml import, unable to open \"%s\"", filename); return (int) node; } s = xml_tok_init (file); init_import (&ist, node); while (((type = xml_tok_get (s, &rdata)) != t_eof)) { if (type == t_error) { cli_outfunf ("xml import error, parsing og '%s', line:%i %s", filename, s->line_no,rdata); fclose (file); return (int) node; } switch (type) { case t_prolog: sprintf (nodedata, "", rdata); import_node_text (&ist, level, nodedata); nodedata[0] = 0; got_data = 0; break; case t_dtd: sprintf (nodedata, "", rdata); import_node_text (&ist, level, nodedata); nodedata[0] = 0; got_data = 0; break; case t_comment: sprintf (nodedata, "", rdata); import_node_text (&ist, level, nodedata); break; case t_tag: if (got_data) { char *unquoted=string_replace(nodedata,xmlunquote); import_node_text (&ist, level, unquoted); free(unquoted); got_data = 0; nodedata[0] = 0; } sprintf (nodedata, "<%s", rdata); break; case t_att: sprintf (&nodedata[strlen (nodedata)], " %s=", rdata); break; case t_val: if (strchr (rdata, '"')) { sprintf (&nodedata[strlen (nodedata)], "'%s'", rdata); } else { if (strchr (rdata, '\'')) { sprintf (&nodedata[strlen (nodedata)], "\"%s\"", rdata); } else { sprintf (&nodedata[strlen (nodedata)], "\"%s\"", rdata); } } break; case t_endtag: sprintf (&nodedata[strlen (nodedata)], ">"); import_node_text (&ist, level, nodedata); nodedata[0] = 0; level++; break; case t_closeemptytag: sprintf (&nodedata[strlen (nodedata)], "/>"); import_node_text (&ist, level, nodedata); nodedata[0] = 0; break; case t_closetag: if (got_data) { char *unquoted=string_replace(nodedata,xmlunquote); import_node_text (&ist, level, unquoted); free(unquoted); got_data = 0; nodedata[0] = 0; } level--; sprintf (nodedata, "", rdata); nodedata[0] = 0; break; case t_whitespace: if (got_data) { strcpy (&nodedata[strlen (nodedata)], " "); } break; case t_word: strcpy (&nodedata[strlen (nodedata)], rdata); got_data = 1; break; case t_entity: got_data = 1; sprintf (&nodedata[strlen (nodedata)], "&%s;", rdata); break; default: break; } } if (node_getflag (node, F_temp)) node = node_remove (node); /* remove temporary node, if tree was empty */ if (xml_cuddle) node = xml_cuddle_nodes (node); cli_outfunf ("xml import - imported \"%s\" %i lines", filename, s->line_no); xml_tok_cleanup (s); return (int) node; } /* !init_file_xml(); */ void init_file_xml () { cli_add_command ("export_xml", export_xml, ""); cli_add_command ("import_xml", import_xml, ""); cli_add_help ("export_xml", "Exports the current node, it's siblings and all sublevels to 'filename' as if it was xml markup.\ (load an xml file with import_xml or hnb -x file.xml to see how it should be inside hnb."); cli_add_help ("import_xml", "Imports 'filename' and inserts it's contents at the current level."); cli_add_int ("xml_cuddle", &xml_cuddle, "join the data with nodes if no tags within tag"); } hnb-1.9.18/src/clipboard.c0000644000175000017500000000472007723016223014640 0ustar jimjim00000000000000/* * clipboard.c -- cut,copy and paste for hnb * * * Copyright (C) 2001,2003 Øyvind Kolås * * 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, 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. */ #include "tree.h" #include "prefs.h" #include "ui.h" #include /************************* clipboard ************************************/ static Node *clipboard = NULL; static int copy_cmd (int argc,char **argv, void *data) { Node *pos = (Node *) data; if (clipboard != NULL) { tree_free (clipboard); } clipboard = node_new (); clipboard = tree_duplicate (pos, clipboard); return (int) pos; } static int cut_cmd (int argc,char **argv, void *data) { Node *pos = (Node *) data; if(prefs.readonly){ cli_outfun("readonly flag set, avoiding tree change"); return (int)data; } if (clipboard != NULL) { tree_free (clipboard); } clipboard = node_new (); clipboard = tree_duplicate (pos, clipboard); pos = node_remove (pos); docmd(pos,"tree_changed"); return (int) pos; } static int paste_cmd (int argc,char **argv, void *data) { Node *pos = (Node *) data; if (clipboard == NULL) { docmd (pos, "status no data in clipboard"); } else { Node *temp; if(prefs.readonly){ cli_outfun("readonly flag set, avoiding insertion"); return (int)data; } temp = node_insert_down (pos); tree_duplicate (clipboard, temp); docmd(pos,"tree_changed"); } return (int) pos; } /* !init_clipboard(); */ void init_clipboard () { cli_add_command ("copy", copy_cmd, ""); cli_add_help ("copy", "Stores the current node, and it's subtree in the clipboard"); cli_add_command ("cut", cut_cmd, ""); cli_add_help ("cut", "Moves the current node, and it's subtree to the clipboard"); cli_add_command ("paste", paste_cmd, ""); cli_add_help ("paste", "Inserts the contents of the clipboard at the current position in the tree."); } hnb-1.9.18/src/search.c0000644000175000017500000000413507723016223014146 0ustar jimjim00000000000000/* * search.c -- recursive search for hnb * * * Copyright (C) 2001,2003 Øyvind Kolås * * 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, 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. */ #include #include "tree.h" #include "prefs.h" #include "ui.h" #include #include "query.h" /************** search ************************/ static int search(int argc,char **argv,void *data){ Node *pos=(Node *)data; if(argc==2){ if(strcmp(argv[1],"-b")||strcmp(argv[1],"-f")){ pos=node_recursive_match( argv[1],pos); if (pos == NULL) { docmdf (pos, "status 'reached bottom of tree and \\'%s\\' not found'", argv[1]); return (int) data; } } } else if(argc>2){ if(!strcmp(argv[1],"-b")){ pos=node_backrecursive_match( argv[2],pos); if (pos == NULL) { docmdf (pos, "status 'reached top of tree and \\'%s\\' not found'", argv[2]); return (int) data; } } else if(!strcmp(argv[1],"-f")){ pos=node_recursive_match( argv[2],pos); if (pos == NULL) { docmdf (pos, "status 'reached bottom of tree and \\'%s\\' not found'", argv[2]); return (int) data; } } return (int)pos; } cli_outfunf("usage: %s [-b|-f] ",argv[0]); return (int)pos; } /* !init_search(); */ void init_search () { cli_add_command ("search",search,"[-b|-f] "); cli_add_help("search","searches either -b(ackwards) or -f(orwards) in the tree for the next entry with a substring matching the specified string"); } hnb-1.9.18/src/ui_overlay.h0000644000175000017500000000015007723016223015055 0ustar jimjim00000000000000#ifndef UI_OVERLAY_H #define UI_OVERLAY_H void help_draw (int scope); void status_draw (void); #endif hnb-1.9.18/src/evilloop.c0000644000175000017500000002004507723016223014530 0ustar jimjim00000000000000/* * evilloop.c -- The event loop / heart of execution for hnb * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #include #include #include "tree.h" #include "tree_todo.h" #include "ui.h" #include "file.h" #include "prefs.h" #include "ui_cli.h" #include "cli.h" #include "evilloop.h" #include "util_string.h" char inputbuf[BUFFERLENGTH]; static int forced_up = 0; static int forced_down = 0; int hnb_nodes_down; int hnb_nodes_up; const char *collapse_names[] = { "all (standard)", "all but first level of children", "show whole tree", "show path of current level", "" }; static Node *node_forced_up ( Node *node) { if (node_up (node) && node_getflag( node_up (node), F_expanded)) { node = node_up (node); while (node_right (node) && node_getflag(node,F_expanded)) { node = node_right (node); node = node_bottom (node); } return (node); } else { if (node_up (node)) return (node_up (node)); else return (node_left (node)); } return node_left (node); } static Node *node_forced_down ( Node *node) { if (node_getflag(node,F_expanded)) { return node_recurse (node); } else { if (node_down (node)) { return (node_down (node)); } else { while (node != 0) { node = node_left (node); if (node_down (node)) return (node_down (node)); } } } return NULL; } /* removes *pos if it is a temporary node, then returns 1 * otherwize returns 0 */ static int remove_temp (Node **pos) { if (node_getflag (*pos, F_temp)) { *pos = node_remove ((*pos)); node_update_parents_todo ((*pos)); docmd(*pos,"tree_changed"); return 1; } return 0; } static char *no_remove_temp_commands[]={ "insert_below", "edit", "indent", "outdent", "expand", "collapse", "paste", NULL }; static char *keep_inputbuf[]={ "indent", "outdent", "expand", "collapse", NULL }; int quit_hnb=0; static int cmd_quit(int argc,char **argv,void *data){ Node *pos=(Node *)data; quit_hnb=1; return (int)pos; } /* !init_quit(); */ void init_quit(){ cli_add_command("quit",cmd_quit,""); cli_add_help("quit","quits hnb, no questions asked"); cli_add_command("q",cmd_quit,""); cli_add_help("q","quits hnb, no questions asked"); } Node *evilloop (Node *pos) { cli_outfun = set_status; while (!quit_hnb) { Tbinding *binding; ui_draw (pos, inputbuf, 0); binding = parsekey (ui_input (), ui_current_scope); do { switch (binding->action) { case ui_action_quit: remove_temp (&pos); quit_hnb = 1; break; case ui_action_command: if(!string_isoneof(binding->action_param, no_remove_temp_commands)) remove_temp (&pos); pos = docmd (pos, binding->action_param); if(!string_isoneof(binding->action_param,keep_inputbuf)) inputbuf[0] = 0; break; case ui_action_top: remove_temp (&pos); inputbuf[0] = 0; pos = node_top (pos); break; case ui_action_bottom: remove_temp (&pos); inputbuf[0] = 0; pos = node_bottom (pos); break; case ui_action_up: if (!remove_temp (&pos)) { if(forced_up){ if (node_forced_up (pos)){ pos = node_forced_up (pos); } } else { if (node_up (pos)){ pos = node_up (pos); } } } inputbuf[0] = 0; break; case ui_action_down: if (!remove_temp (&pos)) { if(forced_down){ if(node_forced_down(pos)) pos = node_forced_down (pos); } else { if(node_down(pos)) pos = node_down (pos); } inputbuf[0] = 0; break; } case ui_action_pagedown: remove_temp (&pos); inputbuf[0] = 0; { int n; for (n = 0; n < hnb_nodes_down; n++) if (node_down (pos)) { pos = node_down (pos); } } break; case ui_action_pageup: remove_temp (&pos); inputbuf[0] = 0; { int n; for (n = 0; n < hnb_nodes_up; n++) if (node_up (pos)) pos = node_up (pos); } break; case ui_action_left: if (!remove_temp (&pos)) { if (node_left (pos)) pos = node_left (pos); } inputbuf[0] = 0; break; case ui_action_right: if (node_right (pos)) { pos = node_right (pos); } else { if (fixnullstring (node_get (pos, TEXT))[0]) { node_insert_right (pos); if (node_getflag (pos, F_temp)) node_setflag (pos, F_temp, 0); if (!strcmp(fixnullstring(node_get(pos,"type")),"todo")){ node_set (node_right (pos), "type","todo"); node_set (node_right (pos), "done","no"); } node_setflag (node_right (pos), F_temp, 1); pos = node_right (pos); } } inputbuf[0] = 0; break; case ui_action_complete: if (strcmp (inputbuf, fixnullstring (node_get (pos, TEXT))) == 0) { if (node_right (pos)) { pos = node_right (pos); } else { if (fixnullstring (node_get (pos, TEXT))[0]) { node_insert_right (pos); if (node_getflag (pos, F_temp)) node_setflag (pos, F_temp, 0); if (!strcmp(fixnullstring(node_get(pos,"type")),"todo")){ node_set (node_right (pos), "type","todo"); node_set (node_right (pos), "done","no"); } node_setflag (node_right (pos), F_temp, 1); pos = node_right (pos); } } inputbuf[0] = 0; } else { strcpy (inputbuf, fixnullstring (node_get (pos, TEXT))); } break; case ui_action_cancel: if (node_getflag (pos, F_temp)) { pos = node_remove (pos); } else { /*stop = ui_quit (pos); */ } inputbuf[0] = 0; break; case ui_action_backspace: if (!strlen (inputbuf)) { /*pos = ui_remove (pos); */ } else { inputbuf[strlen (inputbuf) - 1] = 0; if (node_getflag (pos, F_temp)) if (node_up (pos)) pos = node_remove (pos); } break; case ui_action_unbound: undefined_key (ui_scope_names[ui_current_scope], binding->key != 1000 ? binding->key : *((int *) &binding-> action_param[0])); case ui_action_ignore: break; default: if (binding->action > 31 && binding->action < 255) { /* input for buffer */ inputbuf[strlen (inputbuf) + 1] = 0; inputbuf[strlen (inputbuf)] = binding->action; } else undefined_key (ui_scope_names[ui_current_scope], binding->key != 1000 ? binding-> key : *((int *) &binding-> action_param[0])); break; } } while ((++binding)->key == 999); if (strlen (inputbuf)) { if (node_getflag (pos, F_temp)) { node_set (pos, TEXT, inputbuf); } else { if (node_match (inputbuf, pos)) { pos = node_match (inputbuf, pos); } else { pos = node_insert_down (node_bottom (pos)); node_setflag (pos, F_temp, 1); node_set (pos, TEXT, inputbuf); if (node_left (pos)) if (!strcmp(fixnullstring(node_get(node_left(pos),"type")),"todo")){ node_set (pos, "type","todo"); node_set (pos, "done","no"); } } } } else { docmd(pos, "autosave_check_timeout"); } } return pos; } /* !init_evilloop(); */ void init_evilloop () { cli_add_int ("forced_up", &forced_up, "wether movement upwards is forced beyond first sibling"); cli_add_int ("forced_down", &forced_down, "wether movement downwards is forced beyond last sibling"); } hnb-1.9.18/src/ui_edit.c0000644000175000017500000002222407723016223014322 0ustar jimjim00000000000000/* * ui_edit.c -- lineeditor/(readline like stuff) and bindings side of nodecontent editor * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #include #include #include "tree.h" #include "ui.h" #include "prefs.h" #include "ui_overlay.h" #include "evilloop.h" #include static int ui_edit_cmd (int argc, char **argv, void *data) { Tbinding *c; int stop = 0; static int cursor_pos; /* static char *data_backup;*/ Node *node_backup; int tempscope = ui_current_scope; char input[BUFFERLENGTH]; Node *pos = (Node *) data; ui_current_scope = ui_scope_nodeedit; memset (input, 0, sizeof (input)); if(prefs.readonly){ cli_outfun("readonly flag set, avoiding tree change"); ui_current_scope = tempscope; return (int)data; } if (inputbuf[0]) { /* there is data in the inputbuffer,.. we should not edit, but handle that data instead... this doesn't really belong here,.. but the hack works */ if (node_getflag (pos, F_temp)) { node_setflag (pos, F_temp, 0); } else { pos = node_insert_down (node_bottom (pos)); node_set (pos, TEXT, inputbuf); if (!strcmp(fixnullstring(node_get(node_left(pos),"type")),"todo")){ node_set (pos, "type","todo"); node_set (pos, "done","no"); } } ui_current_scope = tempscope; docmd(pos,"tree_changed"); return (int) pos; } node_backup = node_duplicate (pos); input[0] = 0; strcpy (&input[0], fixnullstring (node_get (pos, TEXT))); cursor_pos = strlen (input); input[cursor_pos] = ' '; input[cursor_pos + 1] = 0; input[cursor_pos + 2] = 0; while (!stop) { node_set (pos, TEXT, input); ui_draw (pos, (char *) cursor_pos, 1); c = parsekey (ui_input (), ui_scope_nodeedit); switch (c->action) { case ui_action_right: if (cursor_pos < (strlen (input) - 1)) cursor_pos++; break; case ui_action_left: if (cursor_pos) cursor_pos--; break; case ui_action_skipword: if (cursor_pos < (strlen (input) - 1)) cursor_pos++; while ((cursor_pos < (strlen (input) - 1)) && isalpha (input[cursor_pos])) cursor_pos++; while ((cursor_pos < (strlen (input) - 1)) && !isalpha (input[cursor_pos])) cursor_pos++; break; case ui_action_bskipword: if (cursor_pos) cursor_pos--; while (cursor_pos && !isalpha (input[cursor_pos])) cursor_pos--; while ((cursor_pos - 1) && isalpha (input[cursor_pos - 1])) cursor_pos--; if (isalpha (input[cursor_pos - 1])) cursor_pos--; break; case ui_action_kill_line: cursor_pos = 0; input[cursor_pos] = ' '; input[cursor_pos + 1] = 0; input[cursor_pos + 2] = 0; break; case ui_action_bol: cursor_pos = 0; break; case ui_action_eol: cursor_pos = strlen (input) - 1; break; case ui_action_up: if (hnb_edit_posup >= 0) cursor_pos = hnb_edit_posup; break; case ui_action_down: if (hnb_edit_posdown < strlen (input)) cursor_pos = hnb_edit_posdown; else cursor_pos = strlen (input) - 1; break; case ui_action_cancel: node_set (pos, TEXT, fixnullstring (node_get (node_backup, TEXT))); stop = 1; break; case ui_action_confirm: input[strlen (input) - 1] = 0; node_set (pos, TEXT, input); stop = 1; docmd(pos, "tree_changed"); break; case ui_action_delete: if (cursor_pos < (strlen (input) - 1)) { cursor_pos++; if (cursor_pos) { memmove (&input[cursor_pos - 1], &input[cursor_pos], strlen (input) - cursor_pos); input[strlen (input) - 1] = 0; cursor_pos--; } } break; case ui_action_backspace: if (cursor_pos) { memmove (&input[cursor_pos - 1], &input[cursor_pos], strlen (input) - cursor_pos); input[strlen (input) - 1] = 0; cursor_pos--; } break; case ui_action_split: input[strlen (input) - 1] = 0; node_insert_down (pos); if (input[cursor_pos] == ' ') node_set (node_down (pos), TEXT, &input[cursor_pos + 1]); else node_set (node_down (pos), TEXT, &input[cursor_pos]); input[cursor_pos] = ' '; input[cursor_pos + 1] = 0; break; case ui_action_join: if (node_down (pos)) { cursor_pos = strlen (input); strcpy (&input[cursor_pos - 1], fixnullstring (node_get (node_down (pos), TEXT))); input[strlen (input)] = ' '; input[strlen (input) + 1] = 0; if (node_right (node_down (pos))) { docmd (pos, "status refusing to remove node after join, because it has children"); } else { node_remove (node_down (pos)); } cursor_pos--; } break; case ui_action_unbound: undefined_key (ui_scope_names[ui_scope_nodeedit], c->key != 1000 ? c->key : *((int *) &c-> action_param[0])); case ui_action_ignore: break; default: if (c->action > 31 && c->action < 255) { /* input for buffer */ memmove (&input[cursor_pos + 1], &input[cursor_pos], strlen (input) - cursor_pos + 1); input[cursor_pos++] = c->action; } else { undefined_key (ui_scope_names[ui_scope_nodeedit], c->key != 1000 ? c->key : *((int *) &c-> action_param[0])); } break; } } node_free (node_backup); ui_current_scope = tempscope; return (int) data; } int ui_getstr_loc (char *input, int x, int y, int maxlen) { int stop = 0; Tbinding *c; int cursor_pos = strlen (input); char *data_backup = strdup (input); input[cursor_pos] = ' '; input[cursor_pos + 1] = 0; input[cursor_pos + 2] = 0; if (x == -1 && y == -1) { getyx (stdscr, y, x); } while (!stop) { move (y, x); clrtoeol (); move (y, x); ui_style (ui_style_menutext); addstr (input); move (y, x + cursor_pos); move (y, x + cursor_pos); ui_style (ui_style_selected); addch (input[cursor_pos]); move (LINES - 1, COLS - 1); c = parsekey (ui_input (), ui_scope_lineedit); switch (c->action) { case ui_action_right: if (cursor_pos < (strlen (input) - 1)) cursor_pos++; break; case ui_action_left: if (cursor_pos) cursor_pos--; break; case ui_action_up: /* strcpy(input,cli_historyprev()); cursor_pos=strlen(input); input[cursor_pos] = ' '; input[cursor_pos + 1] = 0; input[cursor_pos + 2] = 0; */ break; case ui_action_down: /* strcpy(input,cli_historynext()); cursor_pos=strlen(input); input[cursor_pos] = ' '; input[cursor_pos + 1] = 0; input[cursor_pos + 2] = 0; */ break; case ui_action_bol: cursor_pos = 0; break; case ui_action_eol: cursor_pos = strlen (input) - 1; break; case ui_action_complete: if (cursor_pos == strlen (input) - 1) { char *tmpcommand; input[cursor_pos] = 0; tmpcommand = cli_complete (input); strcpy (input, tmpcommand); cursor_pos = strlen (tmpcommand); input[cursor_pos] = ' '; input[cursor_pos + 1] = 0; input[cursor_pos + 2] = 0; status_draw (); refresh (); } break; case ui_action_cancel: strcpy (&input[0], data_backup); input[strlen (input) - 1] = 0; stop = 1; input[0] = 0; break; case ui_action_confirm: input[strlen (input) - 1] = 0; /* cli_historyadd(input); */ stop = 1; break; case ui_action_delete: if (cursor_pos < (strlen (input) - 1)) { cursor_pos++; if (cursor_pos) { memmove (&input[cursor_pos - 1], &input[cursor_pos], strlen (input) - cursor_pos); input[strlen (input) - 1] = 0; cursor_pos--; } } break; case ui_action_backspace: if (cursor_pos) { memmove (&input[cursor_pos - 1], &input[cursor_pos], strlen (input) - cursor_pos); input[strlen (input) - 1] = 0; cursor_pos--; } break; default: if (c->action > 31 && c->action < 255) { /* input for buffer */ memmove (&input[cursor_pos + 1], &input[cursor_pos], strlen (input) - cursor_pos + 1); input[cursor_pos++] = c->action; } break; } } free (data_backup); return (input[0]); } void ui_getstr (char *prompt, char *datastorage) { move (LINES - 2, 0); ui_style (ui_style_menuitem); addstr (prompt); clrtoeol (); move (LINES - 1, 0); ui_style (ui_style_menuitem); addstr (">"); ui_style (ui_style_menutext); addch (' '); ui_getstr_loc (datastorage, -1, -1, 80); } /* !init_ui_edit(); */ void init_ui_edit () { cli_add_command ("edit", ui_edit_cmd, ""); cli_add_help ("edit", "Invokes the node editor for the current node."); } hnb-1.9.18/src/ui_draw.h0000644000175000017500000000044307723016223014336 0ustar jimjim00000000000000#ifndef UI_DRAW_H #define UI_DRAW_H /** draw the interface using curses, current node is node *input varies from mode to mode, in GETSTR mode input is owerwritten with the value input */ void ui_draw (Node *node, char *input, int edit_mode); void set_status (char *message); #endif hnb-1.9.18/src/ui_overlay.c0000644000175000017500000001125007723016223015053 0ustar jimjim00000000000000/* * ui_overlay.c -- help and status display for hnb * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include "tree.h" #include "ui.h" #include "ui_binding.h" #include "evilloop.h" /* ui_overlay current node dirtyness scope_no (and thus name and help texts) status status_display_counter,.. */ static char *ui_helptext[MAX_SCOPES] = { 0 }; static int ui_helptext_cmd (int argc, char **argv, void *data) { if(argc>1) ui_helptext[ui_current_scope] = strdup (argv[1]); return (int) data; } #define MAX_STATUS_LINES 100 static char status_line[MAX_STATUS_LINES][128] = { "" }; static int status_ttl = 0; static void status (char *message, int ttl) { int i; for (i = 0; i < MAX_STATUS_LINES - 1; i++) strncpy (status_line[i], status_line[i + 1], 128); strncpy (&status_line[MAX_STATUS_LINES - 1][0], message, 128); status_ttl += ttl; if (status_ttl >= MAX_STATUS_LINES) status_ttl = MAX_STATUS_LINES - 1; if (status_ttl >= LINES - 2) status_ttl = LINES - 3; } void set_status (char *message) { char *tbuf, *word, *bp, *dp, *wp; int width; if (!COLS) width = 60; else width = COLS + 1 - 2; bp = tbuf = malloc (width); wp = word = malloc (width); dp = message; *bp = *wp = '\0'; while (1 + 1 == 2) { if (isspace ((unsigned char)*dp) || *dp == '\0') { if ((bp - tbuf) + (wp - word) + 1 < width) { strcpy (bp, word); bp += (wp - word); *(bp++) = ' '; *bp = '\0'; wp = word; *wp = '\0'; } else { status (tbuf, 1); bp = tbuf; *bp = '\0'; strcpy (bp, word); bp += (wp - word); *(bp++) = ' '; *bp = '\0'; wp = word; *wp = '\0'; } if (!*dp) break; } else { if (wp - word >= width - 1) { status (tbuf, 1); status (word, 1); wp = word; } *(wp++) = *dp; *wp = '\0'; } dp++; } status (tbuf, 1); free (word); free (tbuf); } static int ui_status_cmd (int argc, char **argv, void *data) { if(argc==2 && (!strcmp(argv[1],"-c") || !strcmp(argv[1],"--clear"))){ status_ttl=0; } else if(argc>1){ /* FIXME: should handle more than one string on commandline */ set_status (argv[1]); if(!ui_inited) cli_outfun(argv[1]); } return (int) data; } void status_draw (void) { int j; for (j = 0; j < status_ttl; j++) { move (status_ttl - j - 1, 0); ui_style (ui_style_menuitem); addstr (" "); ui_style (ui_style_background); addstr (" "); ui_style (ui_style_menutext); addstr (status_line[MAX_STATUS_LINES - j - 1]); move (status_ttl - j - 1, strlen (status_line[MAX_STATUS_LINES - j - 1]) + 2); clrtoeol (); } if (status_ttl > 0) status_ttl--; } void help_draw (int scope) { if (!ui_inited) return; status_draw (); move (LINES - 1, 0); ui_style (ui_style_menuitem); { unsigned char *p = (unsigned char *) ui_helptext[scope]; int style_is_menuitem = 1; while (*p) { switch (*p) { case '|': if (*(p + 1) == '|') { addch ('|'); p++; } else { if (style_is_menuitem) { ui_style (ui_style_menutext); } else { ui_style (ui_style_menuitem); } style_is_menuitem = !style_is_menuitem; } break; default: addch (*p); break; } p++; } } clrtoeol (); ui_style (ui_style_background); } /* !init_ui_overlay(); */ void init_ui_overlay () { cli_add_command ("helptext", ui_helptext_cmd, ""); cli_add_help ("helptext", "Defines the helptext for the current context, the character | alternates between the menuitem and the menutext styles, || is the escape sequence for a single pipe."); cli_add_command ("status", ui_status_cmd, "<-c|--clear|message>"); cli_add_command ("echo", ui_status_cmd, "<-c|--clear|message>"); cli_add_help ("status", "Adds 'message' as the newest status line, if -c or --clear\ is specified, all pending status messages will be cleared off the screen"); cli_add_help("echo","alias for status"); } hnb-1.9.18/src/hnbrc.inc0000644000175000017500000004232707723016223014331 0ustar jimjim00000000000000"# configuration file for hnb,\n\ #\n\ # use a tab-spacing of 4 when editing this file, or edit it thorugh\n\ # hnb with \"hnb -a ~/.hnbrc\" to take advantage of the indentation in it\n\ #\n\ # (please be aware that this is the configuration file for a development version,\n\ # things might change drastically soon,.. or perhaps later)\n\ \n\ ##### bullets\n\ # what kind of bullets are displayed before each item\n\ ##### samples\n\ #bullet_parent \" -\"\n\ #bullet_parent \" *\"\n\ #bullet_parent \" ·\"\n\ #bullet_parent_expanded \" +\"\n\ #bullet_parent_expanded \" *\"\n\ #bullet_parent_expanded \" ·\"\n\ #bullet_leaf \" *\"\n\ #bullet_leaf \" -\"\n\ bullet_leaf \" ·\"\n\ bullet_parent \" +\"\n\ bullet_parent_expanded \" -\"\n\ \n\ ##### user interface\n\ ##### display format\n\ # defining how each node is displayed, the display string syntax is\n\ # interpreted as follows:\n\ #\n\ # spaces turn into real spaces, i means indentation, - means bullet,\n\ # d means the real data of the node, x is a temporary placeholder for\n\ # upcoming column-types,. (for debugging only)\n\ #\n\ # i and x can take an argument specifying how many characters wide\n\ # the field should be\n\ #\n\ # until further features are added, only the multiplier after\n\ # indentation actually does something\n\ # # indicates node number (actually line number when used as a folding editor)\n\ ##### samples\n\ #display_format # \"i4- d\"\n\ display_format \"i4- d\"\n\ \n\ ##### fixed focus\n\ # lock the selection bar to a position 1/3 down the screen\n\ fixedfocus \"0\"\n\ \n\ \n\ ##### external commands\n\ ##### http:// handler\n\ # what command is executed when a user wants a action performed on a\n\ # entry containing an URL\n\ # \n\ # * is substituted for the URL\n\ #\n\ # the X ones have their error and standard output redirected to dev/null\n\ # and are put into the background to keep hnb running afterwards\n\ ##### samples\n\ #web_command \"opera -remote 'openURL(*)' > /dev/null 2>&1 &\"\n\ #web_command \"netscape -remote 'openURL(*)' > /dev/null 2>&1 &\"\n\ #web_command \"netscape -remote 'openURL(*,new-window)' > /dev/null 2>&1 &\"\n\ #web_command \"mozilla -remote 'openURL(*)' > /dev/null 2>&1 &\"\n\ #web_command \"mozilla -remote 'openURL(*,new-window)' > /dev/null 2>&1 &\"\n\ #web_command \"konqueror * > /dev/null 2>&1 &\"\n\ #web_command \"galeon -n > /dev/null 2>&1 &\"\n\ web_command \"w3m *\"\n\ #web_command \"lynx *\"\n\ #web_commend \"rxvt -fn fixed -rv +sb -e w3m * > /dev/null 2>&1 &\"\n\ #web_command \"opera -remote 'openURL(*,new-window)' > /dev/null 2>&1 &\"\n\ \n\ ##### mail@handler\n\ # what command is executed when a user wants a action performed on a\n\ # entry containing a mail-address\n\ # \n\ # * is substituted for the mail-address\n\ #\n\ ## samples\n\ #mail_command \"xterm -rv pine * > /dev/null 2>&1 &\"\n\ #mail_command \"xterm -rv +sb -e mutt * > /dev/null 2>&1 &\"\n\ #mail_command \"pine *\"\n\ mail_command \"mutt *\"\n\ \n\ ##### spell checking\n\ # the spell-checker used\n\ #\n\ ## samples\n\ #spell_command \"aspell -c\"\n\ #spell_command \"ispell -x\"\n\ #spell_command \"ispell -x -damerican\"\n\ #spell_command \"ispell -x -dbritish\"\n\ #spell_command \"ispell -x -dbokmål\"\n\ #spell_command \"ispell -x -dnynorsk\"\n\ spell_command \"ispell -x\"\n\ \n\ \n\ ##### file formats\n\ ##### Default Format\n\ # hnb, opml, xml, ascii are possible choices\n\ format \"hnb\"\n\ \n\ ##### Remember current position in tree\n\ # wheter hnb remembers the current position in a file, (currently\n\ # supported by the hnb DTD only, but might easily be extended since\n\ # it fakes it with a XML comment) 1=true 0=false\n\ savepos \"1\"\n\ \n\ ##### XML format\n\ ##### XML Cuddling\n\ # When loading xml files, should data be allowed on \n\ # the same line as tags?\n\ xml_cuddle \"0\"\n\ ##### Autosave\n\ # when nodes_changed reaches above threshold, invoke autosave\n\ autosave_threshold \"15\"\n\ autosave_threshold_nodes_changed \"0\"\n\ \n\ # if change has occured but is less than threshold, save when number\n\ # of \"ticks\"/keypresses, invoke autosave\n\ autosave_timeout \"50\"\n\ autosave_timer \"0\"\n\ \n\ \n\ \n\ ##### Color/style\n\ # color scheme configuration, syntax is:\n\ # \"style \"\n\ # legal items are shown below\n\ # colors are: blue, cyan, green, red, magenta, yellow, black and white\n\ # attributes are: normal, reverse, bold, underline\n\ \n\ macro define 'style_standard' \n\ style menuitem default/default reverse\n\ style menutext cyan/default normal\n\ style parentnode default/default bold\n\ style node default/default normal\n\ style bullet cyan/default normal\n\ style selected yellow/red bold\n\ style parentselected yellow/red bold\n\ style background default/default normal\n\ end\n\ macro define 'style_alternate' \n\ style menuitem red/white normal\n\ style menutext black/white normal\n\ style parentnode default/default bold\n\ style node default/default normal\n\ style bullet yellow/default normal\n\ style selected yellow/blue normal\n\ style parentselected yellow/blue bold\n\ style background default/default normal\n\ end\n\ \n\ macro style_standard\n\ ##### key-bindings\n\ #\n\ # syntax: \n\ # \"bind \"\n\ #\n\ # multiple actions can be chained together by using the virtual key \"..\"\n\ # as the following key-binding\n\ #\n\ ##################################################\n\ \n\ context main\n\ helptext \"ESC| menu || |F2| save || |F5| commandline || |return| edit |\n\ bind f1 'status \"Take a look at ~/.hnbrc to check out the configuration\"'\n\ bind .. 'status \"there you will also find details about the available keybindings.\"'\n\ bind .. 'status \"please feel free to contribute more useful keybindings and helptexts...\"'\n\ \n\ bind esc menu\n\ bind ^Q 'context quitsave'\n\ \n\ bind f5 'commandline'\n\ bind .. 'status --clear'\n\ \n\ bind f6 'macro m_spellcheck'\n\ macro define m_spellcheck\n\ context spellcheck\n\ save_state\n\ spell\n\ end\n\ \n\ bind ^E 'context export'\n\ bind ^L 'context import'\n\ bind ^F 'macro m_search'\n\ macro define m_search\n\ context search\n\ save_state\n\ getquery \"enter keyword to search for\"\n\ search -f \"$query\"\n\ end\n\ \n\ bind f9 menu\n\ bind f10 'context user'\n\ \n\ bind ^G 'context grab'\n\ bind .. 'save_state'\n\ \n\ bind ^A 'action'\n\ bind up up\n\ bind down down\n\ bind left left\n\ bind right right\n\ bind npage pagedown\n\ bind ppage pageup\n\ bind home \"go root\"\n\ \n\ \n\ bind return edit\n\ bind del remove\n\ \n\ bind ins insert_below\n\ bind .. edit\n\ \n\ bind tab complete\n\ bind ^T toggle_todo\n\ bind ^D toggle_done\n\ bind > indent\n\ bind < outdent\n\ bind f2 save\n\ \n\ bind ^X save_state\n\ bind .. cut\n\ \n\ bind ^C copy\n\ \n\ bind ^V paste\n\ bind .. down\n\ \n\ bind ^S save_state\n\ bind .. sort\n\ \n\ bind backspace backspace\n\ bind backspace2 backspace\n\ \n\ bind sleft \"movenode left\"\n\ bind sright \"movenode right\"\n\ bind sprevious \"movenode up\"\n\ bind snext \"movenode down\"\n\ \n\ bind + expand\n\ bind - collapse\n\ \n\ bind ^Z restore_state\n\ \n\ context nodeedit\n\ helptext \"editing node | |ESC| revert || |return| confirm\"\n\ bind up up\n\ bind down down\n\ bind left left\n\ bind right right\n\ \n\ bind return confirm\n\ bind esc cancel\n\ \n\ bind ^S split\n\ bind ^J join\n\ \n\ bind backspace backspace\n\ bind backspace2 backspace\n\ \n\ bind ^A bol\n\ bind home bol\n\ bind ^E eol\n\ bind end eol\n\ \n\ bind del delete\n\ \n\ context lineedit\n\ helptext lineedit\n\ \n\ bind up up\n\ bind down down\n\ bind left left\n\ bind right right\n\ \n\ bind return confirm\n\ bind esc cancel\n\ bind tab complete\n\ \n\ bind backspace backspace\n\ bind backspace2 backspace\n\ bind del delete\n\ \n\ bind ^A bol\n\ bind home bol\n\ bind ^E eol\n\ bind end eol\n\ \n\ context confirm\n\ helptext \" y | | j | |return| confirm || |any key| cancel\"\n\ \n\ bind y confirm\n\ bind j confirm\n\ bind return confirm\n\ \n\ bind any cancel\n\ \n\ context quitsave\n\ helptext \"Save on exit? | | Y |es | J |a || | N |o || |ESC| cancel\"\n\ bind Y save\n\ bind .. quit\n\ \n\ bind y save\n\ bind .. quit\n\ \n\ bind J save\n\ bind .. quit\n\ \n\ bind j save\n\ bind .. quit\n\ \n\ bind N quit\n\ bind n quit\n\ \n\ bind esc \"context main\"\n\ bind any unbound\n\ \n\ context spellcheck\n\ helptext \"Spellchecking | |Space| next node |ESC| cancel |F6,Return| confirm changes\"\n\ \n\ bind space \"go recurse\"\n\ bind .. spell\n\ \n\ bind down \"go recurse\"\n\ bind .. spell\n\ \n\ bind up \"go backrecurse\"\n\ bind .. spell\n\ \n\ bind return \"context main\"\n\ bind f6 \"context main\"\n\ \n\ bind esc restore_state\n\ bind .. \"context main\"\n\ \n\ bind any unbound\n\ context grab\n\ helptext \"Node grabbed | |return| |space| drop here || |ESC| cancel\"\n\ bind esc restore_state\n\ bind .. \"context main\"\n\ bind return \"context main\"\n\ bind space \"context main\"\n\ bind left \"movenode left\"\n\ bind right \"movenode right\"\n\ bind up \"movenode up\"\n\ bind down \"movenode down\"\n\ bind any unbound\n\ context export\n\ helptext \"Export | | A |scii || | H |tml html| C |ss | P |ostscript | O |PML |ESC| cancel \"\n\ macro define m_export_ascii\n\ save_state\n\ go root\n\ getquery 'what file should I save the ASCII output in?'\n\ export_ascii $query\n\ restore_state\n\ context main\n\ end\n\ macro define m_export_html\n\ save_state\n\ go root\n\ getquery 'what file should I save the HTML output in?'\n\ export_html $query\n\ context main\n\ restore_state\n\ end\n\ macro define m_export_htmlcss\n\ save_state\n\ go root\n\ getquery 'what file should I save the HTML/CSS output in?'\n\ export_htmlcss $query\n\ context main\n\ restore_state\n\ end\n\ macro define m_export_opml\n\ save_state\n\ go root\n\ getquery 'what file should I save the OPML output in?'\n\ export_opml $query\n\ context main\n\ restore_state\n\ end\n\ macro define m_export_ps\n\ save_state\n\ go root\n\ getquery 'what file should I save the PostScript output in?'\n\ export_ps $query\n\ context main\n\ restore_state\n\ end\n\ bind esc \"context main\"\n\ bind A \"macro m_export_ascii\"\n\ bind a \"macro m_export_ascii\"\n\ bind H \"macro m_export_html\"\n\ bind h \"macro m_export_html\"\n\ bind C \"macro m_export_htmlcss\"\n\ bind c \"macro m_export_htmlcss\"\n\ bind O \"macro m_export_opml\"\n\ bind o \"macro m_export_opml\"\n\ bind P \"macro m_export_ps\"\n\ bind p \"macro m_export_ps\" \n\ bind any unbound\n\ context import\n\ helptext \"Import | | A |scii | O |PML | H |hnb |ESC| cancel \"\n\ \n\ bind esc ..\n\ bind .. \"context main\"\n\ bind A ..\n\ bind .. 'getquery \"what file should I import ASCII from?\"'\n\ bind .. 'import_ascii \"$query\"'\n\ bind .. 'context main'\n\ bind a ..\n\ bind .. 'getquery \"what file should I import ASCII from?\"'\n\ bind .. 'import_ascii \"$query\"'\n\ bind .. 'context main'\n\ bind O ..\n\ bind .. 'getquery \"what file should I import OPML from?\"'\n\ bind .. 'import_opml \"$query\"'\n\ bind .. 'context main'\n\ bind o ..\n\ bind .. 'getquery \"what file should I import OPML from?\"'\n\ bind .. 'import_opml \"$query\"'\n\ bind .. 'context main'\n\ bind H ..\n\ bind .. 'getquery \"what file should I import HNB data from?\"'\n\ bind .. 'import_hnb \"$query\"'\n\ bind .. 'context main'\n\ bind h ..\n\ bind .. 'getquery \"what file should I import HNB data from?\"'\n\ bind .. 'import_hnb \"$query\"'\n\ bind .. 'context main'\n\ \n\ bind any unbound\n\ context search\n\ helptext \"Searching | |ESC| cancel || | n |ext || | p |revious || |space|/|return| go\"\n\ bind down 'search -f \"$query\"'\n\ bind up 'search -b \"$query\"'\n\ bind P 'search -b \"$query\"'\n\ bind p 'search -b \"$query\"'\n\ bind n 'search -f \"$query\"'\n\ bind N 'search -f \"$query\"'\n\ \n\ bind return \"context main\"\n\ \n\ bind esc \"context main\"\n\ bind .. restore_state\n\ \n\ bind any unbound\n\ context user\n\ helptext \"Usermenu | |ESC| cancel |F1| ispell language |F2| browser command |F3| expand all |F4| collapse all\"\n\ bind esc \"context main\"\n\ \n\ bind f1 \"context user_ispell\"\n\ bind f2 \"context user_browser\"\n\ bind f3 \"expand --all\"\n\ bind .. \"context main\"\n\ \n\ bind f4 \"collapse --all\"\n\ bind .. \"context main\"\n\ \n\ bind any \"unbound\"\n\ \n\ context user_ispell\n\ helptext \"Language for ispell: | |F1| Br.english |F2| Am.english |F3| Norwegian bokmål |F4| Norwegian nynorsk\"\n\ bind f1 'spell_command \"ispell -x -damerican\"'\n\ bind .. 'context main'\n\ \n\ bind f2 'spell_command \"ispell -x -dbritish\"'\n\ bind .. 'context main'\n\ \n\ bind f3 'spell_command \"ispell -x -dbokmål\"'\n\ bind .. 'context main'\n\ \n\ bind f4 'spell_command \"ispell -x -dnynorsk\"'\n\ bind .. 'context main'\n\ \n\ bind esc 'context main'\n\ bind any unbound\n\ \n\ context user_browser\n\ helptext \"Browser action: | |F1| w3m replace hnb |F2| w3m in rxvt |F3| Opera, new tab |F4| Mozilla new window\"\n\ bind f1 'browser_command \"w3m *\"'\n\ bind .. 'context main'\n\ \n\ bind f2 'web_commend \"xterm -T \\\"w3m spawned from hnb\\\" -fn fixed -rv +sb -e w3m * > /dev/null 2>&1 &\"'\n\ bind .. 'context main'\n\ \n\ bind f3 'web_command \"opera -remote 'openURL(*,new-window)' > /dev/null 2>&1 &\"'\n\ bind .. 'context main'\n\ \n\ bind f4 'web_command \"mozilla -remote 'openURL(*,new-window)' > /dev/null 2>&1 &\"'\n\ bind .. 'context main'\n\ \n\ bind esc 'context main'\n\ bind any unbound\n\ \n\ \n\ ##### key related options\n\ ##### escdelay\n\ # how long the program should wait before accepting that ESC(27d) is the\n\ # ESC key and not the start of an escape sequence\n\ # increase this number if you are using hnb over a slow network link\n\ # value given is in ms (1/1000seconds)\n\ #\n\ escdelay 100\n\ ##### menu definition\n\ ##### file\n\ menu \"File\" \"------------\" \"\"\n\ menu \"File\" \"save F2\" \"save\"\n\ menu \"File\" \"save as.. \" \"macro saveas\"\n\ macro define saveas\n\ getquery db_file 'fila to save'\n\ save_state\n\ go root\n\ export_$format $db_file\n\ restore_state\n\ end\n\ menu \"File\" \"revert \" \"revert\" \n\ menu \"File\" \"------------\" \"\"\n\ menu \"File\" \"export ^E\" \"context export\"\n\ menu \"File\" \"import ^L\" \"context import\"\n\ menu \"File\" \"------------\" \"\"\n\ menu \"File\" \"spell chk F6\" \"macro m_spellcheck\"\n\ menu \"File\" \"expand all\" \"expand --all\"\n\ menu \"File\" \"collapse all\" \"collapse --all\"\n\ menu \"File\" \"statistics\" \"macro stats\"\n\ macro define stats\n\ status \"file: \\\"$db_file\\\" format:$format\"\n\ mem\n\ stats \n\ end\n\ menu \"File\" \"------------\" \"\"\n\ menu \"File\" \"exit ^Q\" \"context quitsave\"\n\ ##### edit\n\ menu \"Edit\" \"---------\" \"\"\n\ menu \"Edit\" \"copy ^C\" \"copy\"\n\ menu \"Edit\" \"cut ^X\" \"cut\"\n\ menu \"Edit\" \"paste ^V\" \"paste\"\n\ menu \"Edit\" \"---------\" \"\"\n\ menu \"Edit\" \"Search ^F\" \"macro m_search\"\n\ ##### entry\n\ menu \"Entry\" \"--------------\" \"\"\n\ menu \"Entry\" \"edit return\" \"edit\"\n\ menu \"Entry\" \"delete del\" \"remove\"\n\ menu \"Entry\" \"--------------\" \"\"\n\ menu \"Entry\" \"do action ^A\" \"action\"\n\ menu \"Entry\" \"indent >\" \"indent\"\n\ menu \"Entry\" \"outdent <\" \"outdent\"\n\ menu \"Entry\" \"toggle todo ^T\" \"toggle_todo\"\n\ menu \"Entry\" \"toggle done ^D\" \"toggle_done\"\n\ menu \"Entry\" \"expand +\" \"expand\"\n\ menu \"Entry\" \"collapse -\" \"collapse\"\n\ ##### level\n\ menu \"Level\" \"------------\" \"\"\n\ menu \"Level\" \"sort ^S\" \"sort -a\"\n\ menu \"Level\" \"sort (desc.)\" \"sort -d\"\n\ menu \"Level\" \"shuffle \" \"sort -r\"\n\ #####\n\ context main\n\ macro define m_about\n\ status \"hnb - hierarchical notebook http://hnb.sourceforge.net/\"\n\ status \"(c) Øyvind Kolås 2001-2003 pippin@users.sourceforge.net\"\n\ end\n\ \n\ macro m_about\n\ " hnb-1.9.18/src/tree_misc.c0000644000175000017500000002013407723016223014650 0ustar jimjim00000000000000/* * tree_misc.c -- various functions bindable/callable from hnb, should be seperated * out into seperate files * * Copyright (C) 2001,2003 Øyvind Kolås * * 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, 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. */ #include #include "tree.h" #include "node.h" #include "prefs.h" #include "ui.h" #include "ui_cli.h" #include "evilloop.h" static int cmd_movenode (int argc, char **argv, void *data) { Node *pos = (Node *) data; if(argc<2){ cli_outfunf("usage: %s ",argv[0]); return (int)pos; } if(prefs.readonly){ cli_outfun("readonly flag set, avoiding tree change"); return (int)data; } if (!strcmp (argv[1], "left")) { if (node_left (pos)) { Node *tnode; tnode = node_insert_down (node_left (pos)); node_swap (pos, tnode); node_remove (tnode); } } else if (!strcmp (argv[1], "right")) { if (node_up (pos)) { Node *tnode; tnode = node_up (pos); if (!node_right (tnode)) { tnode = node_insert_right (tnode); } else { tnode = node_insert_down (node_bottom (node_right (tnode))); } node_swap (pos, tnode); node_remove (tnode); } } else if (!strcmp (argv[1], "up")) { if (node_up (pos)) { node_swap (pos, node_up (pos)); } } else if (!strcmp (argv[1], "down")) { if (node_down (pos)) { node_swap (pos, node_down (pos)); } } docmd(pos,"tree_changed"); return (int) pos; } /* !init_movenode(); */ void init_movenode () { cli_add_command ("movenode", cmd_movenode, ""); } static int cmd_go(int argc, char **argv, void *data){ Node *pos=(Node *)data; if(argc!=2){ cli_outfunf("usage: %s "); return (int)pos; } if(!strcmp(argv[1],"up")){ if(node_up(pos)) pos=node_up(pos); } else if(!strcmp(argv[1],"down")){ if(node_down(pos)) pos=node_down(pos); } else if(!strcmp(argv[1],"left")){ if(node_left(pos)) pos=node_left(pos); } else if(!strcmp(argv[1],"right")){ if(node_right(pos)) pos=node_right(pos); } else if(!strcmp(argv[1],"recurse")){ if(node_recurse(pos)) pos=node_recurse(pos); } else if(!strcmp(argv[1],"backrecurse")){ if(node_backrecurse(pos)) pos=node_backrecurse(pos); } else if(!strcmp(argv[1],"root")){ pos=node_root(pos); } else if(!strcmp(argv[1],"top")){ pos=node_top(pos); } else if(!strcmp(argv[1],"bottom")){ pos=node_bottom(pos); } return (int)pos; } /* !init_go(); */ void init_go () { cli_add_command ("go", cmd_go, ""); cli_add_help ("go", "change current position in the tree"); } #include "evilloop.h" #include "ctype.h" #include "ui_binding.h" static int cmd_outdent (int argc, char **argv, void *data) { Node *pos = (Node *) data; if(inputbuf[0] && isprint(lastbinding->key)){ /* evil workaround */ if (lastbinding->key > 31 && lastbinding->key < 255) { /* input for buffer */ inputbuf[strlen (inputbuf) + 1] = 0; inputbuf[strlen (inputbuf)] = lastbinding->key; } return (int)pos; } if(prefs.readonly){ cli_outfun("readonly flag set, avoiding tree change"); return (int)data; } if (node_left (pos)) { Node *target_node = node_left (pos); Node *last_node = node_bottom (pos); Node *first_node = pos; Node *prev_up = node_up (pos); Node *prev_target_down = node_down (target_node); Node *tnode; tnode = first_node; while (tnode != last_node) { tnode->left = target_node->left; tnode = tnode->down; }; tnode->left = target_node->left; first_node->up = target_node; target_node->down = first_node; last_node->down = prev_target_down; if (prev_target_down) prev_target_down->up = last_node; if (prev_up) { prev_up->down = NULL; } else { target_node->right = NULL; } docmd(pos,"tree_changed"); } return (int) pos; } /* FIXME: no real need for a temporary node */ static int cmd_indent (int argc, char **argv, void *data) { Node *pos = (Node *) data; if(inputbuf[0] && isprint(lastbinding->key)){ /* evil workaround */ if (lastbinding->key > 31 && lastbinding->key < 255) { /* input for buffer */ inputbuf[strlen (inputbuf) + 1] = 0; inputbuf[strlen (inputbuf)] = lastbinding->key; } return (int)pos; } if(prefs.readonly){ cli_outfun("readonly flag set, avoiding tree change"); return (int)data; } if (node_up (pos)) { Node *tnode, *snode; tnode = node_up (pos); if (!node_right (tnode)) { tnode = node_insert_right (tnode); } else { tnode = node_insert_down (node_bottom (node_right (tnode))); } node_swap (pos, tnode); snode = tnode; node_up (snode)->down = NULL; snode->up = pos; pos->down = snode; while (snode) { snode->left = pos->left; snode = node_down (snode); } node_remove (node_down (pos)); docmd(pos,"tree_changed"); } return (int) pos; } /* !init_outdent_indent(); */ void init_outdent_indent () { cli_add_command ("outdent", cmd_outdent, ""); cli_add_help ("outdent", "moves the active item and the following siblings one level to the left"); cli_add_command ("indent", cmd_indent, ""); cli_add_help ("indent", "moves the active item and the following siblings one level to the right"); } static int remove_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; if(prefs.readonly){ cli_outfun("readonly flag set, avoiding tree change"); return (int)data; } if (node_right (pos)) { Tbinding *c; int tempscope = ui_current_scope; ui_current_scope = ui_scope_confirm; docmdf (pos, "status 'node has children, really remove?'"); ui_draw (pos, "", 0); ui_current_scope = tempscope; c = parsekey (ui_input (), ui_scope_confirm); if (c->action == ui_action_confirm) { docmd (pos, "save_state"); pos = node_remove (pos); docmd(pos,"tree_changed"); } } else { docmd (pos, "save_state"); pos = node_remove (pos); docmd(pos,"tree_changed"); } return (int) pos; } /* !init_remove(); */ void init_remove () { cli_add_command ("remove", remove_cmd, ""); cli_add_help ("remove", "Removes the active node, if it has children a confirmation dialog pops up."); } static int commandline_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; char commandline[80]; do { strcpy (commandline, ""); ui_draw (pos, "", 0); ui_getstr ("commandline interface, enter blank command to cancel", commandline); if (commandline[0]) pos = docmd (pos, commandline); } while (commandline[0] && strcmp(commandline,"q") && strcmp(commandline,"quit")); return (int) pos; } /* !init_commandline(); */ void init_commandline () { cli_add_command ("commandline", commandline_cmd, ""); cli_add_help ("commandline", "Invokes the interactive commandline in curses mode."); } static int insert_below_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; if(prefs.readonly){ cli_outfun("readonly flag set, avoiding tree change"); return (int)data; } if (node_getflag (pos, F_temp)) { node_toggleflag (pos, F_temp); } else { pos = node_insert_down (pos); if (node_left (pos)) if (!strcmp(fixnullstring(node_get(node_left(pos),"type")),"todo")){ node_set (pos, "type","todo"); node_set (pos, "done","no"); } } inputbuf[0] = 0; docmd(pos,"tree_changed"); return (int) pos; } /* !init_insertbelow(); */ void init_insertbelow () { cli_add_command ("insert_below", insert_below_cmd, ""); cli_add_help ("insert_below", "Adds a new node immediatly below the active"); } /* TODO: setting of attributes,.. percentage, size, donebydate etc. */ hnb-1.9.18/src/file_ps.c0000644000175000017500000002013707723016223014322 0ustar jimjim00000000000000/* * file_ps.c -- postscript export filter for hnb * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include "cli.h" #include "tree.h" #include "file.h" #include "query.h" #include "util_string.h" #define indent(count,char) {int j;for(j=0;j - make a new encoded font \n\ /newfontname exch def /fontname exch def /fontdict fontname findfont def /newfont fontdict\n\ maxlength dict def fontdict { exch dup /FID eq { pop pop } { exch newfont 3 1\n\ roll put } ifelse } forall newfont /FontName newfontname put encoding_vector\n\ length 256 eq { newfont /Encoding encoding_vector put } if newfontname newfont\n\ definefont pop } def\n\ \n\ /encoding_vector [ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n\ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n\ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n\ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n\ /.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent\n\ /ampersand /quoteright /parenleft /parenright /asterisk /plus /comma /hyphen\n\ /period /slash /zero /one /two /three /four /five /six /seven /eight /nine\n\ /colon /semicolon /less /equal /greater /question /at /A /B /C /D /E /F /G /H\n\ /I /J /K /L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash\n\ /bracketright /asciicircum /underscore /quoteleft /a /b /c /d /e /f /g /h /i\n\ /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar\n\ /braceright /tilde /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n\ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n\ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n\ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n\ /.notdef /.notdef /.notdef /space /exclamdown /cent /sterling /currency /yen\n\ /brokenbar /section /dieresis /copyright /ordfeminine /guillemotleft\n\ /logicalnot /hyphen /registered /macron /degree /plusminus /twosuperior\n\ /threesuperior /acute /mu /paragraph /bullet /cedilla /onesuperior\n\ /ordmasculine /guillemotright /onequarter /onehalf /threequarters /questiondown\n\ /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave\n\ /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth\n\ /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash\n\ /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls /agrave\n\ /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla /egrave /eacute\n\ /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde\n\ /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave\n\ /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis \n\ ] def\n\ \n\ /Times-Roman /Times-Roman-IL1 MF\n\ /Times-Italic /Times-Italic-IL1 MF\n\ /Times-Bold /Times-Bold-IL1 MF\n\ /Helvetica /Helvetica-IL1 MF\n\ /Helvetica-Oblique /Helvetica-Oblique-IL1 MF\n\ /Helvetica-Bold /Helvetica-Bold-IL1 MF\n\ \n\ /textbox {\n\ margins 10 rom 12 LG lm tm moveto } def\n\ /midpage { pw rm sub 2 div fm translate\n\ textbox numbering 10 ss} def\n\ /1upA4 { _Z minidict begin\n\ /p1 { gsave midpage\n\ /jump { bm tm gt { showpage grestore p1 } if\n\ } def } def p1\n\ } def\n\ /newpage { 10 neg TM tm pop jump } def\n\ %% close file\n\ /close { showpage grestore clear end ZZ } def\n\ /minidict 90 dict def \n\ minidict begin \n\ /gs /gsave load def \n\ /gr /grestore load def \n\ /a { tm exch sub TM lm tm moveto } bind def\n\ /Q { lg 8 div a } def\n\ /H { lg 2 div a } def\n\ /L { lg a } def \n\ /centre { dup stringwidth pop 2 div rm 2 div\n\ exch sub lm add tm moveto } bind def\n\ /numbering { gs rm 2 div bm 25 sub moveto\n\ pg pg 1 add PG 4 string cvs 7 ss show gr } def\n\ /find { search { pop 3 -1 roll 1 add 3 1 roll }\n\ { pop exit } ifelse } def\n\ /spacecount { 0 exch ( ) { find } loop } def\n\ /toofar? { ( ) search pop dup stringwidth pop\n\ currentpoint pop add rm gt } bind def\n\ /pagejump { jump toofar? { L jump s s }\n\ { s s } ifelse } def\n\ /s /show load def %% \n\ /n { bm tm gt { jump s L } { s L } ifelse} bind def\n\ /c { centre s L } def \n\ /S { dup spacecount { pagejump } repeat pop } def\n\ /P { S L } bind def \n\ /J { P } def \n\ /T { lm pop tm moveto } def %% tabs\n\ /F { findfont exch scalefont setfont } bind def\n\ /rom { /Times-Roman-IL1 F } def\n\ /it { /Times-Italic-IL1 F } def\n\ /bol { /Times-Bold-IL1 F } def\n\ /ss { /Helvetica-IL1 F } def\n\ /si { /Helvetica-Oblique-IL1 } def\n\ /sb { /Helvetica-Bold-IL1 F } def\n\ \n\ end %% close minidict: *this is important*\n\ %%%% EndResource\n\ \n\ \n\ %%%%BeginPageSetup \n\ 1upA4 %% open the page \n\ %%%%EndPageSetup \n\ 0 a\n\ \n\ %%%%BeginScript \n\ 12 si 0 a\n\ 12 sb (hnb postscript export) c 11 ss L\n\ "); while ((tnode != 0) & (nodes_left (tnode) >= startlevel)) { level = nodes_left (tnode) - startlevel; flags = node_getflags (tnode); cdata = fixnullstring (node_get (tnode, TEXT)); ps_export_node (file, level, flags, cdata); if (node_up (tnode) && node_up (tnode) == node_backrecurse (tnode)) fprintf (file, " H\n"); tnode = node_recurse (tnode); } fprintf (file, "\ %%%%Trailer \n\ close\n\ %%%%EOF\n"); cli_outfunf ("postscript export, saved output to \"%s\"", filename); if (file != stdout) fclose (file); return (int) node; } /* !init_file_ps(); */ void init_file_ps () { cli_add_command ("export_ps", export_ps, ""); cli_add_help ("export_ps", "Exports the current node, it's siblings and all sublevels to a postscript file suitable for printing"); } hnb-1.9.18/src/init_subsystems.c0000644000175000017500000000313507723016223016144 0ustar jimjim00000000000000/* this file is autogenerated, do not edit */ void init_autosave(); void init_cal(); void init_cli_macro(); void init_clipboard(); void init_commandline(); void init_evilloop(); void init_exec_cmd(); void init_expanded(); void init_file(); void init_file_ascii(); void init_file_binary(); void init_file_help(); void init_file_hnb(); void init_file_html(); void init_file_opml(); void init_file_ps(); void init_file_xml(); void init_go(); void init_insertbelow(); void init_keepstate(); void init_mem(); void init_movenode(); void init_nodetest(); void init_outdent_indent(); void init_prefs(); void init_query(); void init_quit(); void init_remove(); void init_search(); void init_sort(); void init_spell(); void init_stats(); void init_tree_todo(); void init_ui_binding(); void init_ui_cli(); void init_ui_draw(); void init_ui_edit(); void init_ui_menu(); void init_ui_overlay(); void init_ui_style(); void init_subsystems(){ init_autosave(); init_cal(); init_cli_macro(); init_clipboard(); init_commandline(); init_evilloop(); init_exec_cmd(); init_expanded(); init_file(); init_file_ascii(); init_file_binary(); init_file_help(); init_file_hnb(); init_file_html(); init_file_opml(); init_file_ps(); init_file_xml(); init_go(); init_insertbelow(); init_keepstate(); init_mem(); init_movenode(); init_nodetest(); init_outdent_indent(); init_prefs(); init_query(); init_quit(); init_remove(); init_search(); init_sort(); init_spell(); init_stats(); init_tree_todo(); init_ui_binding(); init_ui_cli(); init_ui_draw(); init_ui_edit(); init_ui_menu(); init_ui_overlay(); init_ui_style(); } hnb-1.9.18/src/ui_style.c0000644000175000017500000001020107723016223014525 0ustar jimjim00000000000000/* * ui.c -- management of colors and attributes for hnb * * Copyright (C) 2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include "tree.h" #include "prefs.h" #include "ui.h" #include "cli.h" typedef struct { char name[16]; short fg; short bg; int att; } styleitm; static styleitm styledb[] = { {"reserved", 0, 0, 0}, {"menuitem", -1, -1, A_REVERSE}, {"menutext", -1, -1, A_NORMAL}, {"node", -1, -1, A_NORMAL}, {"parentnode", -1, -1, A_BOLD}, {"bullet", -1, -1, A_NORMAL}, {"selected", -1, -1, A_REVERSE}, {"parentselected", -1, -1, A_REVERSE | A_BOLD}, {"background", -1, -1, A_NORMAL}, }; void ui_style (int style_no) { attrset (styledb[style_no].att); } typedef struct { char name[4]; int color; } ColornameT; static ColornameT colorname[] = { {"bla", COLOR_BLACK}, {"blu", COLOR_BLUE}, {"cya", COLOR_CYAN}, {"red", COLOR_RED}, {"gre", COLOR_GREEN}, {"mag", COLOR_MAGENTA}, {"yel", COLOR_YELLOW}, {"whi", COLOR_WHITE}, /* 20021129 RVE - default terminal colors */ #ifdef NCURSES_VERSION {"def", -1}, #endif {"", 0} }; static int name2color (const char *name_in) { char name[10]; int j; strncpy (name, name_in, 10); name[9] = 0; j = 0; while (colorname[j].name[0]) { if (strstr (name, colorname[j].name)) return colorname[j].color; j++; } #ifdef NCURSES_VERSION return -1; #endif return (COLOR_WHITE); } static int string2style (char *str) { int j = 0; while (j < ui_style_terminator) { if (!strcmp (styledb[j].name, str)) return j; j++; } return -1; } void ui_style_restore_color () { int no; for (no = 1; no <= 8; no++) { init_pair (no, styledb[no].fg, styledb[no].bg); } } static int ui_style_cmd (int argc, char **argv, void *data) { char *item; char *colors; char *atts; if(argc!=4){ cli_outfunf("usage: %i "); return (int)data; } item=argv[1]; colors=argv[2]; atts=argv[3]; { int style_no = string2style (item); char *color2; if (style_no == -1) { printf ("unknown style 'style [%s] %s %s'\n", item, colors, atts); return (int) data; } color2 = strchr (colors, '/'); color2[0] = '\0'; color2++; init_pair (style_no, name2color (colors), name2color (color2)); styledb[style_no].fg = name2color (colors); styledb[style_no].bg = name2color (color2); styledb[style_no].att = A_NORMAL | COLOR_PAIR (style_no); if (strstr (atts, "standout")) styledb[style_no].att |= A_STANDOUT; if (strstr (atts, "underline")) styledb[style_no].att |= A_UNDERLINE; if (strstr (atts, "reverse")) styledb[style_no].att |= A_REVERSE; if (strstr (atts, "blink")) styledb[style_no].att |= A_BLINK; if (strstr (atts, "dim")) styledb[style_no].att |= A_DIM; if (strstr (atts, "bold")) styledb[style_no].att |= A_BOLD; if (style_no == ui_style_background) { bkgdset (' ' + COLOR_PAIR (ui_style_background)); } } return (int) data; } /* !init_ui_style(); */ void init_ui_style () { cli_add_command ("style", ui_style_cmd, " "); cli_add_help ("style", "Changes the drawing style of 'element' available colors: \ black, blue, cyan, red, green, magenta, yellow, white and default which uses the standard colors \ of the terminal. Attrbutes are one or more of: standout, underline, reverse, blink, dim and bold. \ Available elements are: menuitem, menutext, parentnode, node, bullet, selected, parentselected and background."); } hnb-1.9.18/src/attic/0000755000175000017500000000000007723016223013636 5ustar jimjim00000000000000hnb-1.9.18/src/attic/add_ons/0000755000175000017500000000000007723016223015245 5ustar jimjim00000000000000hnb-1.9.18/src/attic/add_ons/file_dot.c0000644000175000017500000000234107723016223017176 0ustar jimjim00000000000000/* !cli cli_add_command ("export_dot", export_dot, ""); !clid int export_dot (); */ #if HAVE_CONFIG_H #include #endif #include #include "cli.h" #include "tree.h" #include "file.h" #define indent(count,char) {int j;for(j=0;j \"%s\";\n", node_getdata (parent), node_getdata (node)); } else { fprintf (file, "\"%s\" -> \"%s\";\n", "hnb", node_getdata (node)); } } int export_dot (char *params, void *data) { Node *node = (Node *) data; char *filename = params; Node *tnode; int startlevel; FILE *file; file_error[0] = 0; if (!strcmp (filename, "-")) file = stdout; else file = fopen (filename, "w"); if (!file) { sprintf (file_error, "dot export, unable to open \"%s\"", filename); return (int) node; } startlevel = nodes_left (node); tnode = node; fprintf (file, "digraph hnb{\nrankdir=LR;\n"); while ((tnode != 0) & (nodes_left (tnode) >= startlevel)) { dot_export_node (file, tnode); tnode = node_recurse (tnode); } fprintf (file, "}\n"); if (file != stdout) fclose (file); return (int) node; } hnb-1.9.18/src/attic/add_ons/file_libxml.c0000644000175000017500000001362407723016223017705 0ustar jimjim00000000000000/* !cli cli_add_command ("export_libxml", export_libxml, ""); !cli cli_add_command ("import_libxml", import_libxml, ""); !clid int import_libxml (); !clid int export_libxml (); */ #if HAVE_CONFIG_H #include #endif #include #include "cli.h" #include "tree.h" #include "file.h" /* FIXME: the code in this file has not been updated yet */ /*prints a b chars to file */ #define indent(a,b) {int j;for(j=0;j #include #define XMLCHAR(n) (const xmlChar *)(const char *)n static xmlDocPtr xmldoc = NULL; #endif void libxml_export_data (FILE * file, char *data) { int i = 0; while (data[i]) { switch (data[i]) { case '<': fprintf (file, "<"); break; case '>': fprintf (file, ">"); break; case '&': fprintf (file, "&"); break; case '\'': fprintf (file, "'"); break; case '"': fprintf (file, """); break; default: fputc (data[i], file); break; } i++; } fprintf (file, "\n"); } static char *libxml_export_node_pre (FILE * file, Node *node, int flags, char *data_orig) { int i = 1; int j; char *data; char prefix[] = "(hnbnode) "; unsigned char priority; if (data_orig[0] != '(' && flags & F_todo) { data = (char *) malloc (strlen (data_orig) + strlen (prefix) + 1); sprintf (data, "%s%s", prefix, data_orig); } else { data = strdup (data_orig); } if (data[0] == '(') { while (data[i] != ')') { if (data[i] == 0) { libxml_export_data (file, data); return data; } i++; } data[i] = 0; j = i + 1; while (data[j] == ' ' || data[j] == '\t') { j++; } priority = node_getpriority (node); fprintf (file, "<%s title=\"%s\" ", &data[1], &data[j]); if (flags & F_todo) { fprintf (file, "todo=\"%s\" ", (flags & F_done) ? "done" : ""); } if (priority != 0) { fprintf (file, "priority=\"%i\" ", priority); } fprintf (file, ">\n"); } else { libxml_export_data (file, data); } return data; } static void libxml_export_node_post (FILE * file, int flags, char *data) { int i = 1; if (data[0] == '(') { while (data[i]) { if (data[i] == ' ' || data[i] == '\t') { data[i] = 0; break; } i++; } fprintf (file, "\n", &data[1]); } } void libxml_rec (Node *node, FILE * file) { int i; Node *tnode; int flags; char *data; char *moddata; flags = node_getflags (node); data = node_getdata (node); moddata = libxml_export_node_pre (file, node, flags, data); tnode = node_right (node); while (tnode) { libxml_rec (tnode, file); tnode = node_down (tnode); } libxml_export_node_post (file, flags, moddata); free (moddata); } void libxml_export (Node *node, char *filename) { FILE *file; file_error[0] = 0; file = fopen (filename, "w"); if (!file) return -1; while (node) { libxml_rec (node, file); node = node_down (node); } fclose (file); return 0; } Node *libxml_populate (import_state_t * is, xmlNodePtr root, int level) { xmlNodePtr cur = root->children; xmlAttrPtr prop; char *data, *s; int flags = 0; char attrstring[bufsize]; char *sbuf = NULL; int len = 1; static char *notitle = ""; static char *delim = "\n"; unsigned char priority = 0; data = notitle; while (cur) { if (!xmlIsBlankNode (cur)) { if (xmlNodeIsText (cur)) { s = strdup ((char *) cur->content); data = strtok (s, delim); while (data) { import_node (is, level, flags, 0, data); data = strtok (NULL, delim); } free (s); } else { priority = 0; sbuf = (char *) malloc (1); sbuf[0] = 0; prop = cur->properties; while (prop) { if (!strcmp ("title", prop->name)) { data = xmlGetProp (cur, XMLCHAR ("title")); } else if (!strcmp ("priority", prop->name)) { priority = (unsigned char) atol (xmlGetProp (cur, XMLCHAR ("priority"))); } else if (!strcmp ("todo", prop->name)) { flags |= F_todo; if (!strcmp ("done", xmlGetProp (cur, XMLCHAR ("todo")))) { flags |= F_done; } } else { snprintf (attrstring, bufsize, " %s=\"%s\"", prop->name, xmlGetProp (cur, XMLCHAR (prop-> name))); len += strlen (attrstring); sbuf = (char *) realloc (sbuf, len); strcat (sbuf, attrstring); } prop = prop->next; } #if 0 if (xmlGetProp (cur, XMLCHAR ("title"))) { data = xmlGetProp (cur, XMLCHAR ("title")); } else { data = notitle; } if (xmlGetProp (cur, XMLCHAR ("todo"))) { flags |= F_todo; if (!strcmp ("done", xmlGetProp (cur, XMLCHAR ("todo")))) { flags |= F_done; } } #endif s = (char *) malloc (strlen (cur->name) + strlen (data) + strlen (sbuf) + 4); if (strcmp ("hnbnode", cur->name)) { sprintf (s, "(%s%s) %s", cur->name, sbuf, data); } else { sprintf (s, "%s", data); } import_node (is, level, flags, priority, s); free (s); flags = 0; } libxml_populate (is, cur, level + 1); } cur = cur->next; } return; } Node *libxml_import (Node *node, char *filename) { FILE *file; char *data; unsigned int bsize; import_state_t ist; file_error[0] = 0; bsize = 6; data = (char *) malloc (bsize + 1); sprintf (data, "\n"); file = fopen (filename, "r"); if (file == NULL) { return node; } while (!feof (file) && !ferror (file)) { data = (char *) realloc ((void *) data, bsize + bufsize); bsize += fread (&data[bsize], 1, bufsize, file); } fclose (file); data = (char *) realloc ((void *) data, bsize + 8); sprintf (&data[bsize], "\n"); bsize += 8; xmldoc = xmlParseMemory (data, bsize); init_import (&ist, node); libxml_populate (&ist, xmldoc->children, 0); if (node_getflags (node) & F_temp) node = node_remove (node); return (node); } #endif hnb-1.9.18/src/ui_style.h0000644000175000017500000000050507723016223014540 0ustar jimjim00000000000000#ifndef UI_STYLE_H #define UI_STYLE_H enum { ui_style_menuitem = 1, ui_style_menutext, ui_style_node, ui_style_parentnode, ui_style_bullet, ui_style_selected, ui_style_parentselected, ui_style_background, ui_style_terminator }; void ui_style (int style_no); void ui_style_restore_color (); #endif /*UI_STYLE_H */ hnb-1.9.18/src/tree_todo.c0000644000175000017500000001525507723016223014672 0ustar jimjim00000000000000/* * tree_todo.c -- functions relating to completion calculations * * Copyright (C) 2002,2003 Øyvind Kolås * * 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, 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. */ #include #include #include #include #include "tree.h" #include "prefs.h" void node_update_parents_todo (Node *pos) { #if 0 Node *tnode = node_top (pos); if (node_left (pos) && node_getflag (node_left (pos), F_todo) && !node_getflag (pos, F_temp)) { int status = -1; while (tnode && status) { if (node_getflag (tnode, F_todo)) { status = 1; if (!node_getflag (tnode, F_done)) status = 0; } tnode = node_down (tnode); } tnode = node_left (pos); if (status == 1) { /* all todo nodes were checked */ node_setflag (tnode, F_done, 1); node_update_parents_todo (tnode); } else if (status == 0) { /* one or more todo node were unchecked */ node_setflag (tnode, F_done, 0); node_update_parents_todo (tnode); } } #endif } static int node_getval(Node *node, char *name){ char *got; got=node_get(node,name); if(!got)return -1; return(atoi(got)); } /* a traversal calculation of completion level */ int node_calc_complete (Node *node) { int percent_sum = 0; int nodes = 0; if (strcmp(fixnullstring(node_get(node,"type")),"todo")) return -1; /* node has no completion status */ if (node_get(node,"done") && !strcmp(node_get(node,"done"),"yes")) return 2000; /* this node is done */ if (node_getval (node,"percent_done") != -1) return node_getval (node,"percent_done") * 10; if (!node_right (node)) return 0; /* no undone children,.. completly undone */ node = node_right (node); while (node) { switch (node_calc_complete (node)) { case -1: break; case 2000: percent_sum += 1000; nodes++; break; default: percent_sum += node_calc_complete (node); nodes++; break; } node = node_down (node); } if (nodes) return (percent_sum) / (nodes); return 0; } static int prefs_bullet_empty = 0; /*could be made a preference, but I'm not sure */ /** @return -1, no todo information, 0 not started, 1..1000 = 1..100% , 2000 = done */ int done_status (Node *a) { int completion; if (prefs.showpercent) { completion = node_calc_complete (a); } else { if (!strcmp(fixnullstring(node_get(a,"type")),"todo")){ if (node_get(a,"done") && !strcmp(node_get(a,"done"),"yes")) { completion = 2000; } else { completion = 0; } } else { completion = -1; } } /* FIXME this is the wrong location for this code,.. must fixup the drawing code */ if (!prefs_bullet_empty && completion == -1) { char *data = fixnullstring (node_get (a, TEXT)); int j = 0; completion = -2; while (data[j]) { if (data[j++] != ' ') { completion = -1; break; } } } return completion; } int node_calc_size (Node *node) { int size_sum = 0; int nodes = 0; if (strcmp(fixnullstring(node_get(node,"type")),"todo")) return -1; /* node has no completion status */ if (node_getval (node,"size") != -1) return node_getval (node,"size"); if (!node_right (node)) { /* leaf node */ if (node_getval (node,"size") != -1) return node_getval (node,"size"); else return 10; /* default size value */ } node = node_right (node); while (node) { switch (node_calc_complete (node)) { case -1: break; default: size_sum += node_calc_size (node); nodes++; break; } node = node_down (node); } if (nodes) return (size_sum); return 10; /* no of the children had any time,.. so we default to 1 */ } #define def_size 1 /** @param Node *node the node that we calculate for @param *retsize a parameter to put accumulated size in @return -1 no todo information, 0 not started, 1..1000 1..100% , 2000 done percentage */ int calc_percentage_size (Node *node, int *retsize) { int percentage = node_getval (node,"percent_done"); int size = node_getval (node,"size"); int size_todo = 0; int size_done = 0; int childnodes = 0; Node *tnode; if (strcmp(fixnullstring(node_get(node,"type")),"todo")) { /* bail out if not todo info set */ *retsize = -1; return -1; } tnode = node_right (node); while (tnode) { int rsize, rperc; rperc = calc_percentage_size (tnode, &rsize); switch (rperc) { case -1: break; case 2000: if (rsize != -1) size_todo += rsize; size_done += rsize * 100; childnodes++; break; default: if (rsize != -1) size_todo += rsize; size_done += rsize * rperc; childnodes++; break; } tnode = node_down (tnode); } if (!childnodes) { size_todo = def_size; size_done = 0; } if (size != -1) { if (childnodes) size += size_todo; } else { size = size_todo; } *retsize = size; if (node_get(node,"done") && !strcmp(node_get(node,"done"),"yes")) return 2000; if (percentage != -1) { return percentage; } else { percentage = size_done / size_todo; } return percentage; } #include "cli.h" static int toggle_todo_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; if (strcmp(fixnullstring(node_get(pos,"type")),"todo")) { /* bail out if not todo info set */ node_set(pos,"type","todo"); node_set(pos,"done","no"); } else { node_unset(pos,"type"); } return (int) pos; } static int toggle_done_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; if (strcmp(fixnullstring(node_get(pos,"type")),"todo")) { /* bail out if not todo info set */ return (int) pos; } if (!strcmp(fixnullstring(node_get(pos,"done")),"yes")) { /* bail out if not todo info set */ node_set(pos,"done","no"); } else { node_set(pos,"done","yes"); } return (int) pos; } /* !init_tree_todo(); */ void init_tree_todo () { cli_add_command ("toggle_todo", toggle_todo_cmd, ""); cli_add_help ("toggle_todo", "Toggles visiblity and usage of the checkbox for the currently active item."); cli_add_command ("toggle_done", toggle_done_cmd, ""); cli_add_help ("toggle_done", "Toggles visiblity and usage of the checkbox for the currently active item."); } hnb-1.9.18/src/tree_todo.h0000644000175000017500000000113707723016223014671 0ustar jimjim00000000000000#ifndef TREE_TODO_H #define TREE_TODO_H #include "node.h" /* checks/unchecks the todo boxes of parents according to the status of current node and siblings. */ void node_update_parents_todo (Node *pos); /** @returns an integer between 0 and 1000 according to the completion status of the nodes children */ int node_calc_complete (Node *node); /** @returns the accumulated size of the nodes children */ int node_calc_size (Node *node); /*returns the completion status a node should have*/ int done_status (Node *a); #endif /* TREE_TODO_H */ int calc_percentage_size (Node *node, int *resize); hnb-1.9.18/src/xml_tok.c0000644000175000017500000002621407723016223014360 0ustar jimjim00000000000000/* * xml_tok.c -- pull based xml tokenizer * * Copyright (C) 2002 Øyvind Kolås * * 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, 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. */ #include #include #include #include #include "xml_tok.h" enum { s_null = 0, s_start, s_tag, s_tagnamestart, s_tagname, s_tagnamedone, s_intag, s_attstart, s_attname, s_attdone, s_att, s_atteq, s_eqquot, s_eqvalstart, s_eqapos, s_eqaposval, s_eqaposvaldone, s_eqval, s_eqvaldone, s_eqquotval, s_eqquotvaldone, s_tagend, s_empty, s_emptyend, s_whitespace, s_whitespacedone, s_entitystart, s_entity, s_entitydone, s_word, s_worddone, s_tagclose, s_tagclosenamestart, s_tagclosename, s_tagclosedone, s_tagexcl, s_commentdash1, s_commentdash2, s_incomment, s_commentenddash1, s_commentenddash2, s_commentdone, s_dtd, s_prolog, s_prologq, s_prologdone, s_eof, s_error }; char *c_ws = " \n\r\t"; enum { c_nil = 0, c_eat = 1, /* request that another char be used for the next state */ c_store = 2 /* store the current char in the output buffer */ }; typedef struct { int state; char *chars; unsigned char r_start; unsigned char r_end; int next_state; int resetbuf; int charhandling; int return_type; /* if set return current buf, with type set to the type */ } state_entry; #define max_entries 20 static state_entry state_table[s_error][max_entries]; static void a (int state, char *chars, unsigned char r_start, unsigned char r_end, int charhandling, int next_state) { int no = 0; while (state_table[state][no].state != s_null) no++; state_table[state][no].state = state; state_table[state][no].r_start = r_start; if (chars) state_table[state][no].chars = strdup (chars); state_table[state][no].r_end = r_end; state_table[state][no].charhandling = charhandling; state_table[state][no].next_state = next_state; } static void r (int state, int return_type, int next_state) { state_table[state][0].state = state; state_table[state][0].return_type = return_type; state_table[state][0].next_state = next_state; } /* *INDENT-OFF* */ void init_statetable(void){ static int inited=0; if(inited)return; inited=1; memset(state_table,0,sizeof(state_table)); a(s_start, "<", 0,0, c_eat, s_tag); a(s_start, c_ws, 0,0, c_eat+c_store, s_whitespace); a(s_start, "&", 0,0, c_eat, s_entitystart); a(s_start, NULL, 0,255, c_eat+c_store, s_word); a(s_tag, c_ws, 0,0, c_eat, s_tag); a(s_tag, "/", 0,0, c_eat, s_tagclose); a(s_tag, "!", 0,0, c_eat, s_tagexcl); a(s_tag, "?", 0,0, c_eat, s_prolog); a(s_tag, NULL, 0,255, c_eat+c_store, s_tagnamestart); a(s_tagclose, NULL, 0,255, c_eat+c_store, s_tagclosenamestart); a(s_tagclosenamestart, ">", 0,0, c_eat, s_tagclosedone); a(s_tagclosenamestart, NULL, 0,255, c_eat+c_store, s_tagclosename); a(s_tagclosename, ">", 0,0, c_eat, s_tagclosedone); a(s_tagclosename, NULL, 0,255, c_eat+c_store, s_tagclosename); r(s_tagclosedone, t_closetag, s_start); a(s_whitespace, c_ws, 0,0, c_eat+c_store, s_whitespace); a(s_whitespace, NULL, 0,255, c_nil, s_whitespacedone); r(s_whitespacedone, t_whitespace, s_start); a(s_entitystart,";", 0,0, c_eat, s_entitydone); a(s_entitystart,NULL, 0,255, c_eat+c_store, s_entity); a(s_entity, ";", 0,0, c_eat, s_entitydone); a(s_entity,NULL, 0,255, c_eat+c_store, s_entity); r(s_entitydone, t_entity, s_start); a(s_word, c_ws, 0,0, c_nil, s_worddone); a(s_word, "<&", 0,0, c_nil, s_worddone); a(s_word, NULL, 0,255, c_eat+c_store, s_word); r(s_worddone, t_word, s_start); a(s_tagnamestart,c_ws, 0,0, c_nil, s_tagnamedone); a(s_tagnamestart, "/>", 0,0, c_nil, s_tagnamedone); a(s_tagnamestart,NULL, 0,255, c_eat+c_store, s_tagname); a(s_tagname, c_ws, 0,0, c_nil, s_tagnamedone); a(s_tagname, "/>", 0,0, c_nil, s_tagnamedone); a(s_tagname, NULL, 0,255, c_eat+c_store, s_tagname); r(s_tagnamedone, t_tag, s_intag); a(s_intag, c_ws, 0,0, c_eat, s_intag); a(s_intag, ">", 0,0, c_eat, s_tagend); a(s_intag, "/", 0,0, c_eat, s_empty); a(s_intag, NULL, 0,255, c_eat+c_store, s_attstart); a(s_attstart, c_ws, 0,0, c_eat, s_attdone); a(s_attstart, "=/>", 0,0, c_nil, s_attdone); a(s_attstart, NULL, 0,255, c_eat+c_store, s_attname); a(s_attname, "=/>", 0,0, c_nil, s_attdone); a(s_attname, c_ws, 0,0, c_eat, s_attdone); a(s_attname, NULL, 0,255, c_eat+c_store, s_attname); r(s_attdone, t_att, s_att); a(s_att, c_ws, 0,0, c_eat, s_att); a(s_att, "=", 0,0, c_eat, s_atteq); a(s_att, NULL, 0,255, c_eat, s_intag); a(s_atteq, "'", 0,0, c_eat, s_eqapos); a(s_atteq, "\"", 0,0, c_eat, s_eqquot); a(s_atteq, c_ws, 0,0, c_eat, s_atteq); a(s_atteq, NULL, 0,255, c_nil, s_eqval); a(s_eqapos, "'", 0,0, c_eat, s_eqaposvaldone); a(s_eqapos, NULL, 0,255, c_eat+c_store, s_eqaposval); a(s_eqaposval, "'", 0,0, c_eat, s_eqaposvaldone); a(s_eqaposval, NULL, 0,255, c_eat+c_store, s_eqaposval); r(s_eqaposvaldone, t_val, s_intag); a(s_eqquot, "\"", 0,0, c_eat, s_eqquotvaldone); a(s_eqquot, NULL, 0,255, c_eat+c_store, s_eqquotval); a(s_eqquotval, "\"", 0,0, c_eat, s_eqquotvaldone); a(s_eqquotval, NULL, 0,255, c_eat+c_store, s_eqquotval); r(s_eqquotvaldone, t_val, s_intag); a(s_eqval, c_ws, 0,0, c_nil, s_eqvaldone); a(s_eqval, "/>", 0,0, c_nil, s_eqvaldone); a(s_eqval, NULL, 0,255, c_eat+c_store, s_eqval); r(s_eqvaldone, t_val, s_intag); r(s_tagend, t_endtag, s_start); a(s_empty, ">",0,0, c_eat, s_emptyend); a(s_empty, NULL,0,255, c_eat, s_empty); r(s_emptyend, t_closeemptytag, s_start); a(s_prolog, "?",0,0, c_eat, s_prologq); a(s_prolog, NULL,0,255, c_eat+c_store, s_prolog); a(s_prologq, ">",0,0, c_eat, s_prologdone); a(s_prologq, NULL,0,255, c_eat+c_store, s_prolog); r(s_prologdone, t_prolog, s_start); a(s_tagexcl, "-",0,0, c_eat, s_commentdash1); a(s_tagexcl, "D",0,0, c_nil, s_dtd); a(s_tagexcl, NULL,0,255, c_eat, s_start); a(s_commentdash1, "-",0,0, c_eat, s_commentdash2); a(s_commentdash1, NULL,0,255, c_eat, s_error); a(s_commentdash2, "-",0,0, c_eat, s_commentenddash1); a(s_commentdash2, NULL,0,255, c_eat+c_store, s_incomment); a(s_incomment , "-",0,0, c_eat, s_commentenddash1); a(s_incomment , NULL,0,255, c_eat+c_store, s_incomment); a(s_commentenddash1, "-",0,0, c_eat, s_commentenddash2); a(s_commentenddash1, NULL,0,255, c_eat+c_store, s_incomment); a(s_commentenddash2, ">",0,0, c_eat, s_commentdone); a(s_commentenddash2, NULL,0,255, c_eat+c_store, s_incomment); r(s_commentdone, t_comment, s_start); } /* *INDENT-ON* */ static int is_oneof (char c, char *chars) { while (*chars) { if (c == *chars) return 1; chars++; } return 0; } static int nextchar (xml_tok_state * t) { int ret; if(! (t->inbufposinbuflen) ){ t->inbuflen= fread(t->inbuf,1,inbufsize,t->file_in); t->inbufpos=0; if(!t->inbuflen) return -1; } ret=(int) t->inbuf[t->inbufpos++]; if(ret=='\n') t->line_no++; return ret; } int xml_tok_get (xml_tok_state * t, char **data) { int rbuflen = 0; state_entry *s; init_statetable (); t->rbuf[rbuflen] = 0; while (2 + 2 == 4) { if (!t->c_held) { t->c = nextchar (t); if (t->c == -1) return t_eof; t->c_held = 1; } if (t->state == s_dtd) { /* FIXME: should make better code for skipping DTD */ /* int angle = 0;*/ int squote = 0; int dquote = 0; int abracket = 1; /* int sbracket = 0;*/ t->rbuf[rbuflen++] = t->c; t->rbuf[rbuflen] = 0; while (abracket) { switch (t->c = nextchar (t)) { case -1: return t_eof; case '<': if ((!squote) && (!dquote)) abracket++; break; case '>': if ((!squote) && (!dquote)) abracket--; break; case '"': case '\'': case '[': case ']': default: break; } t->rbuf[rbuflen++] = t->c; t->rbuf[rbuflen] = 0; } t->c_held = 0; t->state = s_start; t->rbuf[--rbuflen] = 0; return t_dtd; } s = &state_table[t->state][0]; while (s->state) { if (s->return_type != t_none) { *data = t->rbuf; t->state = s->next_state; if (s->return_type == t_tag) strcpy (t->curtag, t->rbuf); if (s->return_type == t_endtag) *data = t->curtag; if (s->return_type == t_closeemptytag) *data = t->curtag; return s->return_type; } if ((s->chars && is_oneof (t->c, s->chars)) || ((s->r_start + s->r_end) && (t->c >= s->r_start && t->c <= s->r_end))) { if (s->charhandling & c_store) { t->rbuf[rbuflen++] = t->c; t->rbuf[rbuflen] = 0; } if (s->charhandling & c_eat) { t->c_held = 0; } t->state = s->next_state; break; } s++; } } return t_eof; } xml_tok_state *xml_tok_init (FILE * file_in) { xml_tok_state *ret; ret = calloc (1, sizeof (xml_tok_state)); ret->file_in = file_in; ret->state = s_start; return ret; } void xml_tok_cleanup (xml_tok_state * t) { free (t); } char *empty_tags[] = { "img", "IMG", "br", "BR", "hr", "HR", "META", "meta", "link", "LINK", NULL }; char *endomission_tags[] = { "li", "LI", "p", "P", "td", "TD", "tr", "TR", NULL }; int string_is_oneof (char *s, char **ss) { while (*ss) { if (!strcmp (s, *ss)) return 1; ss++; } return 0; } int html_tok_get (xml_tok_state * s, char **data) { static int got_a_stored_tag = 0; static char stored_tag[4096]; static int stored_type = t_eof; static char opentags[64][64]; static int level = 0; char *rdata; int type; if (got_a_stored_tag) { got_a_stored_tag = 0; *data = (char *) &stored_tag; return stored_type; } type = xml_tok_get (s, &rdata); switch (type) { case t_tag: if (level >= 0) { if (!strcmp (opentags[level - 1], rdata)) { got_a_stored_tag = 1; strcpy (stored_tag, rdata); stored_type = type; return t_closetag; } } strcpy (opentags[level], rdata); level++; break; case t_endtag: *data = rdata; if (string_is_oneof (rdata, empty_tags)) { level--; return t_closeemptytag; } break; case t_closeemptytag: case t_closetag: /* FIXME: do more than one level */ level--; if (strcmp (opentags[level], rdata)) { fprintf (stderr, "%s/%s\n", opentags[level], rdata); got_a_stored_tag = 1; stored_type = t_closetag; strcpy (stored_tag, rdata); level--; return t_closetag; } break; default: break; } *data = rdata; return type; } hnb-1.9.18/src/file_hnb.c0000644000175000017500000001425107723016223014447 0ustar jimjim00000000000000/* * file_ascii.c -- hnb XML-dtd import and export filters for hnb * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include "xml_tok.h" #include "cli.h" #include "tree.h" #include "file.h" #include "prefs.h" #include "query.h" #include "util_string.h" #define indent(count,char) {int j;for(j=0;j" , ">", "&" , "&", "\"", """, "'" , "'", NULL }; static char *xmlunquote[]={ "<" , "<", ">" , ">", "&" , "&", """ , "\"", "'" , "'", NULL }; /* *INDENT-ON* */ static void hnb_export_nodes (FILE * file, Node *node, int level) { while (node) { char *data = fixnullstring (node_get (node, TEXT)); fprintf (file, "\n"); indent (level, "\t"); fprintf (file, "attrib; while(att){ char *quoted; if(strcmp(att->name,TEXT)){ /* the text attirbute is the only specially handled attribute */ quoted=string_replace(att->data,xmlquote); fprintf (file, " %s=\"%s\"", att->name, quoted); free(quoted); } att=att->next; } } fprintf (file, ">"); { char *quoted=string_replace(data,xmlquote); fprintf (file, "%s", quoted); free(quoted); } if (node_right (node)) { hnb_export_nodes (file, node_right (node), level + 1); fprintf (file, "\n"); indent (level, "\t"); fprintf (file, ""); } else { fprintf (file, ""); } node = node_down (node); } } static int export_hnb (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc>=2?argv[1]:""; FILE *file; if (!strcmp (filename, "-")) file = stdout; else file = fopen (filename, "w"); if (!file) { cli_outfunf ("hnb export, unable to open \"%s\"", filename); return (int) node; } fprintf (file, "\n\ \n\ \n\ \n\ \n\ \n\ ]>\n\ \n\ ", (argc==3)?argv[2]:"", VERSION); hnb_export_nodes (file, node, 0); fprintf (file, "\n\n"); if (file != stdout) fclose (file); cli_outfunf ("hnb export, wrote data to \"%s\"", filename); return (int) node; } static int import_hnb (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc==2?argv[1]:""; char *rdata; int type; int in_tree = 0; int level = -1; char nodedata[4096]; int nodedatapos = 0; int in_data = 0; int in_nodetag = 0; xml_tok_state *s; import_state_t ist; Node *tempnode=NULL; FILE *file; file = fopen (filename, "r"); if (!file) { cli_outfunf ("hnb import, unable to open \"%s\"", filename); return (int) node; } s = xml_tok_init (file); init_import (&ist, node); while (((type = xml_tok_get (s, &rdata)) != t_eof) && (type != t_error)) { if (type == t_error) { cli_outfunf ("hnb import error, parsing og '%s' line:%i, %s", filename, s->line_no, rdata); fclose (file); return (int) node; } if (in_tree) { if (type == t_tag && !strcmp (rdata, "node")) { level++; tempnode=node_new(); in_nodetag=1; continue; } if(in_nodetag && type == t_att){ char *att_name=strdup(rdata); if(xml_tok_get(s,&rdata)!=t_val){ cli_outfun("import_hnb,.. hmpf...."); }; {char *unquoted=string_replace(rdata,xmlunquote); node_set(tempnode,att_name,unquoted); free(unquoted); } if(!strcmp(att_name,"done")){ /* to make older files conform */ node_set(tempnode,"type","todo"); } free(att_name); continue; } if ( (type == t_endtag || type == t_closeemptytag) && !strcmp(rdata,"node")){ in_nodetag=0; continue; } if (type == t_tag && !strcmp (rdata, "data")) { nodedatapos = 0; nodedata[nodedatapos] = 0; in_data = 1; } if (in_data) { switch (type) { case t_whitespace: if (nodedatapos) nodedata[nodedatapos++] = ' '; nodedata[nodedatapos] = 0; break; case t_entity: sprintf (&nodedata[strlen (nodedata)], "&%s;", rdata); nodedatapos+=strlen(rdata)+2; break; case t_word: strcpy (&nodedata[nodedatapos], rdata); nodedatapos = strlen (nodedata); break; default: break; } } if (type == t_closetag && !strcmp (rdata, "data")) { char *unquoted=string_replace(nodedata,xmlunquote); node_set(tempnode,TEXT,unquoted); free(unquoted); import_node (&ist, level, tempnode); tempnode=NULL; in_data = 0; } if (type == t_closetag && !strcmp (rdata, "node")) { level--; } if (type == t_closetag && !strcmp (rdata, "tree")) in_tree = 0; } else { if (type == t_tag && !strcmp (rdata, "tree")) in_tree = 1; } } if (node_getflag (node, F_temp)) node = node_remove (node); /* remove temporary node, if tree was empty */ cli_outfunf ("hnb import - imported \"%s\" %i lines", filename, s->line_no); xml_tok_cleanup (s); return (int) node; } /* !init_file_hnb(); */ void init_file_hnb () { cli_add_command ("export_hnb", export_hnb, ""); cli_add_command ("import_hnb", import_hnb, ""); } hnb-1.9.18/src/xml.dot0000644000175000017500000000706507723016223014052 0ustar jimjim00000000000000digraph "xml_states" { epsilon=0.0000001; maxiter=1000; start=3; center=1; size="7,8"; edgehandles=0; /* rankdir=LR;*/ /* ordering=out;*/ "start" [shape = doublecircle]; "start" -> "tag" [label="<"] "tag" -> "tagexcl" [label="!"] "tag" -> "tag" [label="ws"] "tagexcl"-> "swallowdtd" [label="D"] "swallowdtd"-> "start" [label="ret"] "swallowdtd"-> "swallowdtd" [label="in dtd"] "tagexcl"-> "commentdash1" [label="-"] "commentdash1"-> "commentdash2" [label="-"] "commentdash2"-> "incomment" [label="!-"] "commentdash2"-> "commentenddash1" [label="-"] "incomment"->"incomment" "incomment" -> "commentenddash1" [label="-"] "commentenddash1" -> "incomment" [label="!-"] "commentenddash1" -> "commentenddash2" [label="-"] "commentenddash2" -> "incomment" [label="!-"] "commentenddash2" -> "commentdone" [label=">"] "commentdone" -> "start" [label="ret"] "tag" -> "prolog" [label="?"] "prolog" -> "prologq" [label="?"] "prolog" -> "prolog" [label="!?"] "prologq" -> "prolog" [label="!>"] "prologq" -> "prologdone" [label=">"] "prologdone" -> "start" "tag" -> "tagnamestart" [label="a..Z"] "tagnamestart" -> "tagname" [label="a..Z"] "tagnamestart" -> "tagnamestart" [label="ws"] "tagname" -> "tagname" [label="a..Z,0..9"] "tagname" -> "tagnamedone" [label="ws,/,>"] "tagnamedone" -> "intag" [label="ret"] "tag" -> "tagclose" [label="/"] "tagclose" -> "tagclosenamestart" [label="a..Z"] "tagclosenamestart" -> "tagclosename" [label="a..Z"] "tagclosenamestart" -> "tagclosedone" [label=">"] "tagclosename" -> "tagclosename" [label="a..Z"] "tagclosename" -> "tagclosedone" [label=">"] "tagclosedone" -> "start" [label="ret"] "start" -> "whitespace" [label="ws"] "whitespace" -> "whitespace" [label="ws"] "whitespace" -> "whitespacedone" [label="!ws"] "whitespacedone" -> "start" [label="ret"] "start" -> "entitystart" [label="&"] "entitystart" -> "entity" [label="!;"] "entity" -> "entity" [label="!;"] "entity" -> "entitydone" [label=";"] "entitydone" -> "start" "start" -> "word" [label="."] "word" -> "word" [label="."] "word" -> "worddone" [label="<,ws,&"] "worddone" -> "start" [label="ret"] "intag" -> "intag" [label="ws"] "intag" -> "tagend" [label=">"] "intag" -> "empty" [label="/"] "empty" -> "empty" [label="ws"] "empty" -> "emptyend" [label=">"] "intag" -> "attstart" [label="a..Z,0..9"] "attstart" -> "attname" [label="a..Z,0..9"] "attstart" -> "attdone" [label="ws,/,>"] "attname" -> "attname" [label="a..Z,0..9"] "attname" -> "attdone" [label="ws"] "attdone" -> "intag" [label="ws"] "attdone" -> "att" [label="ret"] "att" -> "atteq" [label="="] "att" -> "att" [label="ws"] "att" -> "intag" [label="*"] "atteq" -> "atteq" [label="ws"] "atteq" -> "eqapos" [label="'"] "eqapos" -> "eqaposval" [label="!'"] "eqapos" -> "eqaposvaldone" [label="'"] "eqaposval" -> "eqaposval" [label="!'"] "eqaposval" -> "eqaposvaldone" [label="'"] "eqaposvaldone" -> "intag" [label="ret"] "atteq" -> "eqquot" [label="\""] "eqquot" -> "eqquotval" [label="!\""] "eqquot" -> "eqquotvaldone" [label="\""] "eqquotval" -> "eqquotval" [label="!\""] "eqquotval" -> "eqquotvaldone" [label="\""] "eqquotvaldone" -> "intag" [label="ret"] "atteq" -> "eqval" [label="!ws"] "eqval" -> "eqval" [label="!ws"] "eqval" -> "eqvaldone" [label="ws"] "eqvaldone" -> "intag" [label="ret"] "tagend" -> "start" "emptyend" -> "start" } hnb-1.9.18/src/xml_states.pdf0000644000175000017500000002526107723016223015416 0ustar jimjim00000000000000%PDF-1.2 %Çì¢ 6 0 obj <> stream xœ¥}YGvæ{ýŠ’l!ßÎØ#`»Ø~°[ÀóFP´»*±%r¨ñ¿÷ùΙ¤È2 1¢"c;û÷çç㑞üOÿûþõéç§ßýk}þ÷OOÿBÿlåxNmϯO­-ý÷‹ü»—Êÿ.þÏ?>ýï矞Êcåù×§ôüÏôÿ?=•y¬ÇhÏ=ù82Må=¹¬GÏeôãq$jÏõHé¹ô5½{ûýSée<Ê6¢Íñh#f°¶®A_xOê˜Ëg8z¬kh›¾°]Øß·Îp9Çû§?ÐIr}´~:›öäJë7œm>Ò¢+:ÊcåXWÛ8[¦3•ÑF~Œmkog³žc>ê|öŽ–O÷§m>›ìÂFø¾u†Ë9p¶ŸŸ£†ýçýëóÿúc=·Gš5?ÿðoO‚5X±=*}×S{¬öüÃëÓ_úüî—Ïÿã‡ÿxú§žÿå)Ç|ncÔGYtOÖ1Szäç\jyÖ´YÓã¨Ï9ã¯ÙÛïŸr.ùÑc@€âß[Sç§ñÞCpoóÙ¾ÇxŒmmÓ¶a;Öïϸ{A9·GO•¾o4Ûàúüîßý~¤@¾D*è!¥Z}=ç5Gž•³=çNwÞèk&|I'hè¡5}1Ês®€ÞèŽ0‚Pín‚*Ÿè§=pÏ¥ýùÝûqQNÔcˆmt)öØøÊý‘ÓvWØØ†5ÀÄ^úØgÑû{AÝ\ó1wÄ]Ädv€ÿúÉÒZÍà£rïµÚoeG¸×#íÌ eGI‘éTÕ¹‰7"Ñ# ó ¢¾„ÃÜ7a#|×:Ãåw¡ÞòxäZNPÿðÓç?}þÏ3ãÜ8s…ü4âD` ã žBèæh¯’À„•¼ªu¬ÇÂt=¥?×ÞÓ£V’0DãDÑ-ÑŒ½n¬¤åT /Ú‚¼ ]fb-`Ž 2ŠúËÑ0²Í^¹óé©î˜ÑöÔj…¹¦3Rˆ‹= @ÛNuµn$× µþÒ廒©70Ë{1ê¤ïSˆ™ ±8ˆYôÑ×ìªlk:Ô£GðÂ'P¼ñ%³|6Âw­3\Nq³êHtGýÌO>þòã7PÊeÍZõÁ¢fbÅš©9+DM‡R›îØñ£B»*Óñ£öJ:._Ð `!p¡µÇü ¾*¬Ëv@g–åéÒç…ÆS?2¨ï.~Ð>ˆ(Û ?›B°šà™W!iWë|mâBâ™DfeŠÐÑv½Âz& GšGJâä`º$tM ŠøT;qÏ„C Læ562#ÇË6Ʈ⦅P¸È`¹%A?£MVš}0Ľ‡ˆ•öY\Žd!ôé£4–xÚ¦s/ºÚ#ò:è¼Ù'ˆ¶,/´§N@Ñ J@ _BÛ$fu6À¶(ß_Ïp[£Y¨!DØDŸª€}øï_vüXŒ ÄÒ?,Äk['Q˜ Ë´ÊÑWy”¼šn žSßbýBoŠfYd¥@1«c VÓBwí-|öñèçÖÀ+Ÿæ;?G½Ž ÚÞ!°JuצJ§h°S¡ ƒ,lÄe ‹7 Ö!ò¯6½Ú×·º=ýü¼û»p¦Õ‰´òç?ÿòñåcèÚ9sj¬‹7P!ÝÏ"S ÚyŸ¬S§>DákØ`Æ–Ú Æ‰DPUÁG3T"û26Ë7í¨oQ¡Ò"4c|ÿg Ò Í8€£G©±pA¬fí9' ²8‚Pwlo;9[’³M 0ô%ʶ`[Ôï/g¸MÎÄKiê 9ÿôîõÃÅð¼z¯ÑÓIÙ6N² ü)ÚØ˜P4´¦èµM¡·÷‚žZ¹¹MϤ²URáwx¿{<þOãHãÑvˆ[‡’äj¡c;§5AÓ“PqÛ3é“åQ7¦àm§jëQº´ Œjm‰ kÛ„\÷¨?á6]“fИ‰îÿòñÓ‡ ؤÙL¨>¾,àÝ(”©ÞäĽù ë3i™C‹mÌS({ÍÁYã'˜¾ªNÿDÚ‹ø´›†eÖ}hÓE”œOÐþ]ëeŒÖ;V ú=‰´’ ŸRÊlö$`ð‚»à*°6l\Âvh%6¢ÒÅômkëô…÷4Öc|†ƒôš2c mÃ*Ö]Øß·Îp9Çm»¸’É h ñO¿¾{yùøëŸ7mö€_¤Ã„;Lè6¤VÂD£;†aäšC†Ð¦K:Œ@l¼á(d‰±¹“ èІà ÀKº’®c rD‰>¹bZ—4\0û–ÀÀhŒŠ–ì¶%3Úo%´Æ üc¼4±®O¬Ç œ 3¶Xm'íhrÐÝ–àêŒNàmaô(mC]"°Äö`|×:Áå÷Õ:BSðœ KÞ|}%[úÇwŸþ˜6<Éi×JèºÂ vÆG!½ †ùo¯àS–¤˜ÔXbl"þF¦@9*;Ž["3i ‡+`90ŒŽÇâØÈwÞ –ø<òÝm,9@gg4ùÛͳ\.îGdìÑý¡pà’ü…‰û>)-RéÏÕ/6?Ë@$ü­Âæ E†Ó¢8ϤsÂõzÙšÎA­'aºûÔøË€›0{[ÜqÖ¡Èî8Û‡³Œ#÷uûä¤K¦y"?ýô|b¡°XèöëÀј4¼®ÅØGƒeTgS&i€=UoCâ Ýc@¸ZLàmYÇz É!Ì!@)VÐ6îW÷`#|:Áå÷ý°D}h'e¶+'Éq]ŒÐW \Êt–yA'AÆm9ô¤tÁ⨰îgQ”olWxšˆçI’%¾ÃW_ }…sv{ô0kàÀYPNו3(ÂÖJüL8ƒ÷€T±°Ä*lšR$Úæ@T…ÜôPês|ïMY@מBNÄítº1ø} mCË=ØÛ¡Mp9Ã} 7HpÀ’†‡B}s½Ÿqñuë)eô6 Ƽa/´È®®÷>‡xÓR¿ÀõBáz‡ Q|Ìm€w8zöA2Kü_ßÄk&žF*U=ËÂ×èï…dýe±: ‚ž+3F[û½°#,a#:ð8û ÞÖ5¡±žR9¤£$·Ê¶„¶ß?ù&´'¶Í\OqæLà4-øI];¡øéÇ‹Ö0 ‡àø%JNâ~—s…À£]ÐöÙ6ÑV–ilâ5¨Ô:+´Ë,¨„`m’@1`°vêIDäÖ”ž(&…+¤p5é=™W()ìHòݦÂF ¤wgX~K0­´é´dËdZë$COè°ïkL¶Û*YAܬÅÔ¼ØÂ)“”1ÒõjSôIZ+° “lZܬ0}ª—‚þÿG*i)M šˆDl>5D†àÞ ¸è£·Ó©¿ÁÇŠT÷×­§Ö*Q†Ä ÎF¥Öæ”Vb}D‡œ|†hËœ„"=à ŒLgèD!"_CÛÌÈdÚã»Ô®ç¸ÏɈI€ƒ èŠùœlÓZ.l *H¹±Mçí99hãç™ØÚ3\¤¾ªöÌåfÁ—€cÅÇÜWXi°¯&Œï¯ì™›;ö™velJFÂI‘ Z” ˜Ò–ònôL”ÛŽ° ´W³÷Üc_·ÃÐqžé->â9o0PgíBiÇxØdPz‰ 1ì5z*tCÚ|ð¢{v@‹—X©Ú6Ž6YOAX¢4ŸÁÛºX¸õ4Î9ñJ.±4»­Ïóíꇗíߎi‰$%m‘¸PJõ¤›üiK’X}BŸ3‚{uáK¶_b1}4vcø+t Ä:é Ò±YHúØÍCˆT€@4 \Jq·/4d²ÁfŸÝ—½ˆ´Â¦ÝÐ6p ßo²×Büåc,\`?ˆ6YA>šJ5àjíL_z¬m¼æ‹ <&Ô³mìÃ.pkÓ‘4Kw ‚€n¬°ÓÎL/‰hrxq+¢ÃÃqŸØ? œÙì°ÝR÷PKAðepx‹ìŽ4Î]"qÜØ)Uà±Ñ×¶÷t†pBêÔ@Hk&à«Ç ¤y ù Žÿî!ôCÌQ|3èÃ×Öv÷wôI‰kmî>ïQo]‚ÐÃ-œOvš¿/qÐ&<€ h˜¨Í`mwjD¸ë|uçùîðó]Øß·Îp9Çí8@ÄmëÉŸ!¾Ÿ÷»ªÈu__‚Ò®:ûRÁ¾»{ûhדÓ|ÜÛG=‰\ˆ4_K¤"³'#‚%â+%–VD}õ1Ð!;G^3Iš7NHRHæo^ÃÛX%÷·yû6,AŠá,hâ¬(سˆƒ•#IFtÐÊÁÄ/u—Ã6Fðá[N²:П2.¦mhEÏCè´ÀëÚõ€ãgpßHî Ô‘ ñ°ÑíÜßËLêž|XÑ#.(BeŽW™‹*éØ}ZAXÖƒD åYgˆ¶y˜¢G|P>ƒz | ÷bù.l„ïRf¸žã.yà¶34ï{ yœ¥õ ip,¾.Òê[‚‹µÀB#î_¡#hɼ/ ß:+‡uìˆ —ê}4 Ä+ ½Bûyñ]cÓè6Ü‘"ïÁæÃúý7¼Û–—´òîþnA?ÒãÍ”×o+ƒúâ#ˆì8^˜3Ùð5&ímì|riËV_¶1’ˆ…«ñ|"—nr\•n.l$+ ¬J:Ž·#Tï="ÝrKe“f¹"û¨Ÿ¤[FLÎjo¾o1æmò œh".òmËQÊŒ¼É7ï±hÜ™!Þ2¢}cC9‰_Ńk„üÑ,ïÙä3¨ì²%\¸Ùìï¾gýþr†ûI dö޳¯^³ö„† û#d›ç”Äi 9#¬<àBí@I>ƒN¡"S‘–MJùå¾MH!Ÿá@.èÆ¬Ïù –jeáG7 ·ÐÞ9MAÃ-ÑtØY†[r%Ðl±ÖŒ¬#Öu"Ü}nñ}x¸%Ƽ-Ü…(#µxƒ!Žþýñx¬8cÇ&®¢G„M†ñ‘#¢’‘¢ÜׯdFâd±ˆsÃWc3xÛDIôˆ°ñTù.®|6Âw©3\Îq¿.‚ m˜a›¸RŒ?É+ϸQÊäH"]Ëb.¹ ÷ƒcl;q=<~H%õjÁÝd—;°¢ò*“‹ìwûî>ê“-RÎ1—_?}ÿ»ï7]EsL"ð=8!ZÈ-0²¥Ú„O9Mº8HE÷äôï­e¾XëШ‰­® ŸßÃ.¾a´.G¸­Å“Ù<{½^öŠƒxxÞ3¼e°S;¢hHçÌ jYÛžì–΃\¿ps:Oeǰ;”*k€Èæo(pÉ@”z ºœ Ö…¤Ý“žá”`›Îäê‰IæL÷¶ßnôŸ"°üqÌ^,í˜ú$^Š}qÚ±od;ºõMiÇ)Ål`ÜóŽÚVÙãMÞcÑ¢£4w.›êÎæí8´öªÃɀ̀Éü  „pgT¥lj Æ¹omšÃz´¸º Ú„Ÿ…‘jjˋث«£Ïª«}'þ„IŒy[uuYªTüFyõDÎ]ÚË«½GË«ÇVjõÕ¨—?dÄhfìXK)ê«£mQïÑúh›Àʧm‰¨¯¶MØÛ¤Np9Åýz-ø‚N™ñŒÉ9KGs3£&³@™á\®É´4h«É,xdqõ¨É¤3dy—Ck2KG!QÙj2-ïø5™ðÅ¥u®Éün‡:rFJó”pšÅŽÈ‰dËz°Ÿ­-ÔÆ:#ذ=[‚Ê-4ˆöEÝÙhœwæÄS4ôšBí®hC"9 ZElpœ hŸìayõô7+zÙÎR¼ŸÎTàaXç÷væ@»ë{qéëÖ#øÍH8â}oBÙ X[¦½à†:£(J÷¦a¯uvû׊ü>¿“‡ïÀFØu‚ËÞòàK/§úUyï%.‰¨€B'‹†w"‹² Î…YJ­`Gk§Š†jºDACø© ŠÆÅùë­D¯ƒe#Š¿Ûàœ¤ÚÏ£× Orp­¿d¤4°©T<7ËÛ7ï‘èuŠçäèV[áÇ3´øžÏí}R~ÿ;ñðuŒy[øšnŒÐâô°À~rÔÈ¡¼ÐÝ Þ£þ€†€Æáé7ljw'4ÎEŒÌšv$-(Ô¬í6ôˆWÀgP•Ý×p¿‚ïÂFø¾u†Ë9n£9"Ç ¿‚àùIøBîP f]êPh¹ù¯8bÊã”nEbËú0IbOTø˜ äõfBã«?G²ÿn“ü–ê(ÊdH~S³¬*-Ú’d½©› ÉǦ^VTɧlêeE‚,‰çXæœr<_F±wÀ*|‰x¶PŸîk¨&å‹üµ¬”ys¦wµ>Ó¼>ºAßm{&ŶƒIVçžç)GÝó‡2ã 'àÚ•À ñ½)d4uF^›ÁÛÆ,½G„”O dåK¸”óMØÛ¤Np9ÅíDm&ÚqR?þòã‰öëÀ¦v9WGžÌ”DÎU˜Ëüƒ:*?0%]¯x‡‹Œtbko•tDWÂÈ6I÷÷ßÿúéû¿Ü¨ßÓ´Õ—]Q"ÎÆ¡¾´†Ôœ/sV.&¯Ïc¯­®°F!â f^á®õÔ5}Ñ?lËJ)ôN›Ì4N)ØÒqóìôUé7Õ¹0²½\ÛŒKIX·o»6N˜++ÈsD)Ò7-ÒˆcGüé;(\j§=/=Ö6?ØQQ_ž#ظ˜Õfø§¤–©ØC>[á9lýׯâÜ+Ï%å³ô SWLr–|× (%&0{D –tâh{”ÐzÒÁOd”“ zD#¡©”6ÇË ¹s„\⧯±ŸÆ«A»Q,éö`Ðnö@èe«½Š­œÂãGŽÊ*Èü7j¯@&¨~ОŒœ „ßu†h[]”÷Xí•Í`µW¶†×^ù.l„íÒf¸œã¶¹{ Óù\{ÅAÕ=ºÿ-<‘g[ è½#Aø JÄgç73ŠCQÁÇŸ cê|„ åJ^®ànj˘Y³ÖôuØb~C”tNö™ï5W§zv웋 U_“ÓôúÑø¹ÃŠÌ²oÏz;¤ú¥ÇÛú*Ë—¡™w5.o‹ˆ*j¥:Ûã"p@#ª‚Ok¼,MqiTì¸]u°÷Žª–°\` !î­Þ7o«Ãú¹ÇÛJÇ_|DÁ*x¿9U᫟•2:ƒŒ–¹rÍ¥‰ pp¨}}{Þ"*m„!2ÛIxˆªn´=J9©T)WUÊB>6; Œö‚6#*#rÖSÔ=FÛèÂ{”r|¥,_ÃiÏwa#l—:Ãõ·C §žiïÝçÏç°•E#¼Þ1Á»X£ÞÑ„óœºbQô½²‹î“ñFÌX[½cÆ;2y+w´*ûì~‚ÿgÒû:\ð..Ý ½GË÷8 x,/ײ¨\”oq}ÒŒ26~‡Û Öö*½è‘:>Ÿ¡p[@_ŸÿæÛÕ/Û¿ qß-[ Aü¯’ð2‰à$/A%”!·øHò¢:6®B݈£#÷j ¢â„€5Üj@´g Êx¬R{íµ‚4ê'O¬X0 !cîoèñøÅ†î—”R{ç¬tà2'Ò@þ»û`µB3ºi€¼z'­°ÖÑÙ*˹pñ?¿Q‡§ÿX›i#ú’¼%í»ÐQ/Û©¤½Ÿ[‰àL>Sú×Ä¡éKvVÐ:"n¨úä'Ñ-¿‚°‘ý¢dÃòË>¦¡Ù †U~  ^0àÈ£6ª¼Ûz7ò˜¸\h¯úÜT+Ë}¨0Ìgïœ:¦¥Í„ŸY}&‹Ý‘__@º.“xeE›¹9R‰+öu ´{AgKãÑö‚€erXr*r2$—£–Äï÷ódïaS‡Û­éµ'¸Ö ž|l~–6ÐQ®‰¿WosvM’·ÞtìbøÇmoËÌÚ´'eÉúH“ÊÕÕ5¬ÍÌwá#|—:Ãå÷y\#ÞÃ9±¤î ãqÛ³®•òÛW¯a-ðlÏÐEbK°ÉüÝR"±…dz ¸Ýüâ†19†`cîC»ðC»xé˜_gCã Ý9=×Ð.[‘.[Q·º¸Â¾vˆ·{Ûóç.=Ö6éòÅGT8y™jfOº*5ðDs»Û„ä½ËŠB«²ÉŠi™y➦rß/Þ$Ìá·À‚ýÍFã/ÐXšÜ ÀÅ8È ¬íÐFDÛ±Ú{€£)DŒLÜ¥æ2œÎpÞ}S‘пm„äU•” ‚ß yC¹;§ðÚßày ,>m€p›£ºN{°VêÔvp¡ôí3x[Ö;A£®àp½ôkh{ã6Âvi3\ÎqŸà=Æ&øž‡ùa«l¾p¥×­§H¦µñ4ÿÜøŒG}]ÈXCF6 §Ý^ïl‰ÅÇÜgdòÈf—,̸¢z† õ†ê½2‡2D¶ÞðyOåà°¡zÆïø¤æ¨žGc¡½£:}³´ˆ^7ÒcHo"qEõ†;ªk*P†ÿµ3­¨ÈFàO2×ÂmÕ6ÿ}DŶ¬­kÕ­§°Põ½¶5´Í©­² áûÖ.ç¸ê{™2ÜÑI²x>üüîÏ?}ëJm–¶UDÄY;³™W…M¥3®ãw„·\.tÃusæð/ Œ‚Ÿ”쪿Ú2¥`#@î= °Ì窱èBò}ßA>§ø<‚UcoȽGf3@m ¹ïB{bß2Ãõ÷³Ì9ÿ ñŸÿïÇM7À K°Uzcƒi#üH§üàÝ4'‘%¼V…ß6ªDÐ pÍ'ÏÐr[ØV.¤‰£óGœp?Ǿ€u÷_l/LÎÛ(Üz X©°¯Û‰g¢À2܇<$a=€U«Ógð¶ƒ"zÜ6ƒÛÖ ·]Øß·Îp9ÇmpÓ­c]àýåÝËFà°wàï‡T˜šFà®Å ¥Ì¸èƒÙW‚Gp1 /(H“ãžvU¸îƾà\“©mþcÉýŒC: ¼÷L „²ïÅEy]UZïé\hœ ³¸v«€1Ù³)Ö4ºlÚFhÚŸÏàmY8"=i-βˆ°ñî¾-¡M¤.ËìïºEÿürˆûï²T¶ÔáΚµn ý òÄùJ„tSsŠ‘ž9P‹Üص”ÊJR½?øÁ¼„z\ðH(úv*ÿ„Tôg-mÔçF2tXyfEtÉ)—7i¬(ô¯R’?‡˜1ßýÕrÑI[èŠuÖ32çð&¼ÜÇ:;kmðÐ6@žÕ-¥#ŽÜøK›ÁÚº@n=•1Ûgè„éL.º†¶tÝ…ð}ë —sÜ'r¤ p’:ai?CýìSsÕØMä8g¼°3“;72¬:<Ä¡†h`0b£“k<?Á£¨“¦üŠaB¥>½ZîJªxnwÜ•#Áe°BÙ$/À0.Áõ†¸ƒÁ;Û8aþ†)¶âÔ©€"ûŸñ«Ï–4Öhj{#uïé‡(|uHÐ|CZs;7}1´ÔA÷aƒ^b–}Sv‡€ÙN½È™ý¼n‰½íÞFžÊÜÈ»QoEF¦8÷-©½^‚Ãkø˜ûÏ ‘ŒWŽ$Wù»oxÔ!§Þ‹„Ìd±@Hf´“>DŠjEöLu eÝÊ9ľ°BÊ„€ §H±.¾ÀœÓÂØ µºÈw·*;uéÕ ×ÖÜè¢ÂÔ§½^fÞCÄK>^ªi@‘´åÅ3‹‹;eÞv˵ÇÚáq±ž<×>Œä]> J= Wí›ÈCGŸ¬ýr„ç‚Q“žN¿púÇÝ“ê¯Ï¬ç…%ŽÅMÜAÌN}:w°âé×x ·)>-ÖPÞÅ …Äøtöm쯜JÉnÚAôˆl§ÿ&a|*ûM5í`ª,1ÂÔ`Ó¼í,C{\¼ë &ýu ¿[ÛƒvØíóë!îëþx’¦\´(ÿ'íàb“¼FiÖÆu³b ­„H£ ü£¦× EЮó;¦6æ¾'gšgõ l€ Cf׬CE{n…$†¹öpP(ùµàß³­1ƒµ]pGˆvŸAE¿¯áÊïÂFØ®u‚ó!î?íÒá=k ñóÛ.G›òÓy‰ý¿L [:Ïàú°$P7ÊÊ#NR7ú°Zs‹Ð DÓI×_é“:ó„„ Íΰ5àté£Lºø/ Ÿ í7,ÑŸÔ Õ CíL®Ø‹'¦X;¨0zD3°~LÊÛ W»j@´"/$¹n` Ý Æ¼I9àMg•h'}Ò‚¨pèÏYé>I;à'#ì—œÞîl/È»ª£Ék>‰“ë¢S^ó‘·{Ü{¬ôÛOw%xóÆ8á˜~ÙÕƒÍÒ·×STØïow±¾ñãD\Ýy6‰™õöd›-^p·˜m…­?°žp{)BC°‡‹3üzƒû‚³ˆ2Ì«ý•ë _‚Bƒ ±½ßTzç@¼øàû§SÓ†m_üÏiAã)ºÌqq”^¢Ö/÷‹m¯ÐèÛàÌŒ?ã£/K¼àÉyì^•¨ûkÄË{ÿM œPÁ76þ’@5âîœû+¦Aе5Ý™æ=KÔ<üž7²kå^_m4—ƒ8&¼/KxÜö¡½lCÌ5u_yííäa9ù%ªRvÍ#zDoX ¥lBjy㬰›Öˆ‰~‰hK²SlÕ,l ×r¢ÐJË í³ Ë]RºŒ§.ð’q¨¨glk¼]í@‚+Y›Úq .˜½"Kh»fŸ±E[~ÆÁÂ.[ù9jÎ0‡fÍ’ 8öŸq˜ð:Íýá—?áŠÇ„‡x ß–¢íÖĵÇÚFp_|DÆû>„âøÉ¹àÔíÏx1…ÈyCÔ]×Õ>týzðoŒíºþä@Þí"XÇêoƶñ¿ÿoª .endstream endobj 7 0 obj 9833 endobj 5 0 obj <> /Contents 6 0 R >> endobj 3 0 obj << /Type /Pages /Kids [ 5 0 R ] /Count 1 >> endobj 1 0 obj <> endobj 4 0 obj <> endobj 10 0 obj <> endobj 11 0 obj <> endobj 9 0 obj <> endobj 8 0 obj <> endobj 2 0 obj <>endobj xref 0 12 0000000000 65535 f 0000010157 00000 n 0000010454 00000 n 0000010098 00000 n 0000010205 00000 n 0000009938 00000 n 0000000015 00000 n 0000009918 00000 n 0000010393 00000 n 0000010320 00000 n 0000010260 00000 n 0000010290 00000 n trailer << /Size 12 /Root 1 0 R /Info 2 0 R >> startxref 10610 %%EOF hnb-1.9.18/src/tokenize.ps0000644000175000017500000004056507723016223014740 0ustar jimjim00000000000000%!PS-Adobe-2.0 %%Creator: dot version 1.7.16 (Wed Feb 6 02:14:52 MST 2002) %%For: (pippin) Øyvind Kolås,,, %%Title: str_tokenize %%Pages: (atend) %%BoundingBox: 53 186 559 606 %%EndComments save %%BeginProlog /DotDict 200 dict def DotDict begin /setupLatin1 { mark /EncodingVector 256 array def EncodingVector 0 ISOLatin1Encoding 0 255 getinterval putinterval EncodingVector dup 306 /AE dup 301 /Aacute dup 302 /Acircumflex dup 304 /Adieresis dup 300 /Agrave dup 305 /Aring dup 303 /Atilde dup 307 /Ccedilla dup 311 /Eacute dup 312 /Ecircumflex dup 313 /Edieresis dup 310 /Egrave dup 315 /Iacute dup 316 /Icircumflex dup 317 /Idieresis dup 314 /Igrave dup 334 /Udieresis dup 335 /Yacute dup 376 /thorn dup 337 /germandbls dup 341 /aacute dup 342 /acircumflex dup 344 /adieresis dup 346 /ae dup 340 /agrave dup 345 /aring dup 347 /ccedilla dup 351 /eacute dup 352 /ecircumflex dup 353 /edieresis dup 350 /egrave dup 355 /iacute dup 356 /icircumflex dup 357 /idieresis dup 354 /igrave dup 360 /dcroat dup 361 /ntilde dup 363 /oacute dup 364 /ocircumflex dup 366 /odieresis dup 362 /ograve dup 365 /otilde dup 370 /oslash dup 372 /uacute dup 373 /ucircumflex dup 374 /udieresis dup 371 /ugrave dup 375 /yacute dup 377 /ydieresis % Set up ISO Latin 1 character encoding /starnetISO { dup dup findfont dup length dict begin { 1 index /FID ne { def }{ pop pop } ifelse } forall /Encoding EncodingVector def currentdict end definefont } def /Times-Roman starnetISO def /Times-Italic starnetISO def /Times-Bold starnetISO def /Times-BoldItalic starnetISO def /Helvetica starnetISO def /Helvetica-Oblique starnetISO def /Helvetica-Bold starnetISO def /Helvetica-BoldOblique starnetISO def /Courier starnetISO def /Courier-Oblique starnetISO def /Courier-Bold starnetISO def /Courier-BoldOblique starnetISO def cleartomark } bind def %%BeginResource: procset /coord-font-family /Times-Roman def /default-font-family /Times-Roman def /coordfont coord-font-family findfont 8 scalefont def /InvScaleFactor 1.0 def /set_scale { dup 1 exch div /InvScaleFactor exch def dup scale } bind def % styles /solid { } bind def /dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def /dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def /invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def /bold { 2 setlinewidth } bind def /filled { } bind def /unfilled { } bind def /rounded { } bind def /diagonals { } bind def % hooks for setting color /nodecolor { sethsbcolor } bind def /edgecolor { sethsbcolor } bind def /graphcolor { sethsbcolor } bind def /nopcolor {pop pop pop} bind def /beginpage { % i j npages /npages exch def /j exch def /i exch def /str 10 string def npages 1 gt { gsave coordfont setfont 0 0 moveto (\() show i str cvs show (,) show j str cvs show (\)) show grestore } if } bind def /set_font { findfont exch scalefont setfont } def % draw aligned label in bounding box aligned to current point /alignedtext { % width adj text /text exch def /adj exch def /width exch def gsave width 0 gt { text stringwidth pop adj mul 0 rmoveto } if [] 0 setdash text show grestore } def /boxprim { % xcorner ycorner xsize ysize 4 2 roll moveto 2 copy exch 0 rlineto 0 exch rlineto pop neg 0 rlineto closepath } bind def /ellipse_path { /ry exch def /rx exch def /y exch def /x exch def matrix currentmatrix newpath x y translate rx ry scale 0 0 1 0 360 arc setmatrix } bind def /endpage { showpage } bind def /layercolorseq [ % layer color sequence - darkest to lightest [0 0 0] [.2 .8 .8] [.4 .8 .8] [.6 .8 .8] [.8 .8 .8] ] def /setlayer {/maxlayer exch def /curlayer exch def layercolorseq curlayer get aload pop sethsbcolor /nodecolor {nopcolor} def /edgecolor {nopcolor} def /graphcolor {nopcolor} def } bind def /onlayer { curlayer ne {invis} if } def /onlayers { /myupper exch def /mylower exch def curlayer mylower lt curlayer myupper gt or {invis} if } def /curlayer 0 def %%EndResource %%EndProlog %%BeginSetup 14 default-font-family set_font 1 setmiterlimit % /arrowlength 10 def % /arrowwidth 5 def % make sure pdfmark is harmless for PS-interpreters other than Distiller /pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse % make '<<' and '>>' safe on PS Level 1 devices /languagelevel where {pop languagelevel}{1} ifelse 2 lt { userdict (<<) cvn ([) cvn load put userdict (>>) cvn ([) cvn load put } if %%EndSetup %%Page: 1 1 %%PageBoundingBox: 54 187 559 606 %%PageOrientation: Portrait gsave 53 186 506 420 boxprim clip newpath 54 187 translate 0 0 1 beginpage 0.6412 set_scale 0 0 translate 0 rotate [ /CropBox [54 187 559 606] /PAGES pdfmark 0.000 0.000 0.000 graphcolor 14.00 /Times-Roman set_font % start gsave 10 dict begin 43 361 30 30 ellipse_path stroke 43 361 34 34 ellipse_path stroke gsave 10 dict begin 43 356 moveto 29 -0.5 (start) alignedtext end grestore end grestore % start -> start newpath 67 385 moveto 72 400 64 413 43 413 curveto 26 413 18 405 18 393 curveto stroke 0.000 0.000 0.000 edgecolor newpath 15 395 moveto 19 385 lineto 20 395 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 43 418 moveto 18 -0.5 (ws) alignedtext end grestore % wnew gsave 10 dict begin 210 492 32 18 ellipse_path stroke gsave 10 dict begin 210 487 moveto 42 -0.5 (wnew) alignedtext end grestore end grestore % start -> wnew newpath 63 389 moveto 75 405 89 423 96 430 curveto 110 441 151 463 180 477 curveto stroke 0.000 0.000 0.000 edgecolor newpath 178 473 moveto 186 480 lineto 176 478 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 128 471 moveto 49 -0.5 (default) alignedtext end grestore % qnew gsave 10 dict begin 210 360 30 18 ellipse_path stroke gsave 10 dict begin 210 355 moveto 38 -0.5 (qnew) alignedtext end grestore end grestore % start -> qnew newpath 78 361 moveto 105 360 143 360 171 360 curveto stroke 0.000 0.000 0.000 edgecolor newpath 170 358 moveto 180 360 lineto 170 363 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 128 365 moveto 5 -0.5 (") alignedtext end grestore % anew gsave 10 dict begin 210 210 29 18 ellipse_path stroke gsave 10 dict begin 210 205 moveto 37 -0.5 (anew) alignedtext end grestore end grestore % start -> anew newpath 56 329 moveto 67 314 77 308 96 292 curveto 124 268 158 244 182 228 curveto stroke 0.000 0.000 0.000 edgecolor newpath 179 227 moveto 189 223 lineto 182 231 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 128 297 moveto 1 -0.5 (') alignedtext end grestore % end gsave 10 dict begin 210 305 27 18 ellipse_path stroke gsave 10 dict begin 210 300 moveto 25 -0.5 (end) alignedtext end grestore end grestore % start -> end newpath 74 346 moveto 83 341 91 338 96 336 curveto 110 330 147 320 174 313 curveto stroke 0.000 0.000 0.000 edgecolor newpath 174 311 moveto 184 311 lineto 175 315 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 128 341 moveto 13 -0.5 (\\0) alignedtext end grestore % wpp gsave 10 dict begin 369 562 27 18 ellipse_path stroke gsave 10 dict begin 369 557 moveto 30 -0.5 (wpp) alignedtext end grestore end grestore % wnew -> wpp newpath 236 503 moveto 264 516 310 536 340 549 curveto stroke 0.000 0.000 0.000 edgecolor newpath 338 545 moveto 346 552 lineto 336 550 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 292 545 moveto 49 -0.5 (default) alignedtext end grestore % wescape gsave 10 dict begin 513 573 39 18 ellipse_path stroke gsave 10 dict begin 513 568 moveto 56 -0.5 (wescape) alignedtext end grestore end grestore % wnew -> wescape newpath 241 496 moveto 293 501 389 513 396 515 curveto 416 520 452 540 479 554 curveto stroke 0.000 0.000 0.000 edgecolor newpath 480 552 moveto 488 559 lineto 478 556 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 369 520 moveto 5 -0.5 (\\) alignedtext end grestore % wpp -> wpp newpath 387 576 moveto 393 587 387 598 369 598 curveto 355 598 348 592 349 584 curveto stroke 0.000 0.000 0.000 edgecolor newpath 346 585 moveto 351 576 lineto 351 586 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 369 603 moveto 49 -0.5 (default) alignedtext end grestore % wpp -> wescape newpath 396 564 moveto 415 566 442 567 464 569 curveto stroke 0.000 0.000 0.000 edgecolor newpath 464 567 moveto 474 570 lineto 464 571 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 424 571 moveto 5 -0.5 (\\) alignedtext end grestore % returntoken gsave 10 dict begin 726 289 52 18 ellipse_path stroke gsave 10 dict begin 726 284 moveto 82 -0.5 (returntoken) alignedtext end grestore end grestore % wpp -> returntoken newpath 392 552 moveto 458 523 646 440 656 430 curveto 661 425 700 339 702 334 curveto 705 328 706 327 708 322 curveto 708 322 709 319 712 316 curveto stroke 0.000 0.000 0.000 edgecolor newpath 710 315 moveto 716 307 lineto 714 317 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 513 530 moveto 32 -0.5 (ws \\0) alignedtext end grestore % wescape -> returntoken newpath 539 559 moveto 553 552 568 543 574 539 curveto 614 511 631 508 656 468 curveto 673 442 664 431 674 403 curveto 675 402 699 347 715 314 curveto stroke 0.000 0.000 0.000 edgecolor newpath 712 315 moveto 718 307 lineto 716 317 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 624 531 moveto 13 -0.5 (\\0) alignedtext end grestore % waddchar gsave 10 dict begin 726 618 45 18 ellipse_path stroke gsave 10 dict begin 726 613 moveto 68 -0.5 (waddchar) alignedtext end grestore end grestore % wescape -> waddchar newpath 549 581 moveto 584 588 639 599 678 608 curveto stroke 0.000 0.000 0.000 edgecolor newpath 677 605 moveto 686 610 lineto 676 610 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 624 606 moveto 49 -0.5 (default) alignedtext end grestore % returntoken -> start newpath 80 380 moveto 113 396 163 415 210 416 curveto 210 416 210 416 513 416 curveto 577 415 602 439 656 406 curveto 665 400 697 337 702 329 curveto 705 324 706 323 708 319 curveto 712 313 714 310 717 307 curveto stroke 0.000 0.000 0.000 edgecolor newpath 81 383 moveto 73 377 lineto 83 379 lineto closepath fill 0.000 0.000 0.000 edgecolor % waddchar -> wpp newpath 395 579 moveto 403 584 410 588 414 590 curveto 431 596 435 596 452 600 curveto 542 619 565 629 656 625 curveto 665 624 674 624 682 623 curveto stroke 0.000 0.000 0.000 edgecolor newpath 396 583 moveto 389 575 lineto 399 578 lineto closepath fill 0.000 0.000 0.000 edgecolor % qpp gsave 10 dict begin 369 332 27 18 ellipse_path stroke gsave 10 dict begin 369 327 moveto 26 -0.5 (qpp) alignedtext end grestore end grestore % qnew -> qpp newpath 239 355 moveto 266 351 305 344 334 339 curveto stroke 0.000 0.000 0.000 edgecolor newpath 333 337 moveto 343 337 lineto 334 342 lineto closepath fill 0.000 0.000 0.000 edgecolor % qpp -> returntoken newpath 376 314 moveto 399 275 408 256 452 237 curveto 533 202 638 243 691 270 curveto stroke 0.000 0.000 0.000 edgecolor newpath 691 267 moveto 698 274 lineto 688 271 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 513 245 moveto 13 -0.5 (\\0) alignedtext end grestore % qpp -> qpp newpath 387 346 moveto 393 357 387 368 369 368 curveto 355 368 348 362 349 354 curveto stroke 0.000 0.000 0.000 edgecolor newpath 346 355 moveto 351 346 lineto 351 356 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 369 373 moveto 49 -0.5 (default) alignedtext end grestore % qescape gsave 10 dict begin 513 354 37 18 ellipse_path stroke gsave 10 dict begin 513 349 moveto 52 -0.5 (qescape) alignedtext end grestore end grestore % qpp -> qescape newpath 395 336 moveto 415 339 444 344 468 347 curveto stroke 0.000 0.000 0.000 edgecolor newpath 468 345 moveto 478 348 lineto 468 349 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 424 346 moveto 5 -0.5 (\\) alignedtext end grestore % swallow_term gsave 10 dict begin 513 284 60 18 ellipse_path stroke gsave 10 dict begin 513 279 moveto 99 -0.5 (swallow_term) alignedtext end grestore end grestore % qpp -> swallow_term newpath 392 322 moveto 399 320 407 317 414 314 curveto 429 309 445 303 460 299 curveto stroke 0.000 0.000 0.000 edgecolor newpath 459 297 moveto 469 296 lineto 460 302 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 424 319 moveto 5 -0.5 (") alignedtext end grestore % qescape -> returntoken newpath 543 343 moveto 565 335 591 326 592 326 curveto 620 317 650 309 675 302 curveto stroke 0.000 0.000 0.000 edgecolor newpath 674 300 moveto 684 300 lineto 675 305 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 624 331 moveto 13 -0.5 (\\0) alignedtext end grestore % qaddchar gsave 10 dict begin 726 430 43 18 ellipse_path stroke gsave 10 dict begin 726 425 moveto 64 -0.5 (qaddchar) alignedtext end grestore end grestore % qescape -> qaddchar newpath 543 365 moveto 580 378 643 401 684 415 curveto stroke 0.000 0.000 0.000 edgecolor newpath 684 412 moveto 693 418 lineto 683 417 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 624 408 moveto 49 -0.5 (default) alignedtext end grestore % swallow_term -> returntoken newpath 573 285 moveto 602 286 635 287 665 288 curveto stroke 0.000 0.000 0.000 edgecolor newpath 664 286 moveto 674 288 lineto 664 291 lineto closepath fill 0.000 0.000 0.000 edgecolor % qaddchar -> qpp newpath 393 352 moveto 399 356 405 359 414 365 curveto 461 390 565 425 592 430 curveto 609 432 651 432 683 431 curveto stroke 0.000 0.000 0.000 edgecolor newpath 392 354 moveto 385 347 lineto 395 350 lineto closepath fill 0.000 0.000 0.000 edgecolor % app gsave 10 dict begin 369 158 27 18 ellipse_path stroke gsave 10 dict begin 369 153 moveto 25 -0.5 (app) alignedtext end grestore end grestore % anew -> app newpath 236 201 moveto 263 193 305 179 335 169 curveto stroke 0.000 0.000 0.000 edgecolor newpath 335 166 moveto 345 166 lineto 336 171 lineto closepath fill 0.000 0.000 0.000 edgecolor % app -> returntoken newpath 395 163 moveto 447 174 557 196 574 201 curveto 612 212 622 213 656 230 curveto 683 244 696 247 713 265 curveto stroke 0.000 0.000 0.000 edgecolor newpath 714 262 moveto 718 271 lineto 710 265 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 513 206 moveto 13 -0.5 (\\0) alignedtext end grestore % app -> swallow_term newpath 381 174 moveto 396 195 423 229 452 252 curveto 454 254 464 259 475 264 curveto stroke 0.000 0.000 0.000 edgecolor newpath 475 261 moveto 483 268 lineto 473 266 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 424 242 moveto 1 -0.5 (') alignedtext end grestore % app -> app newpath 387 172 moveto 393 183 387 194 369 194 curveto 355 194 348 188 349 180 curveto stroke 0.000 0.000 0.000 edgecolor newpath 346 181 moveto 351 172 lineto 351 182 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 369 199 moveto 49 -0.5 (default) alignedtext end grestore % aescape gsave 10 dict begin 513 106 36 18 ellipse_path stroke gsave 10 dict begin 513 101 moveto 51 -0.5 (aescape) alignedtext end grestore end grestore % app -> aescape newpath 386 144 moveto 397 136 408 127 414 124 curveto 431 117 450 113 468 110 curveto stroke 0.000 0.000 0.000 edgecolor newpath 467 108 moveto 477 109 lineto 467 113 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 424 132 moveto 5 -0.5 (\\) alignedtext end grestore % aescape -> returntoken newpath 549 102 moveto 580 101 625 103 656 126 curveto 679 144 705 221 718 263 curveto stroke 0.000 0.000 0.000 edgecolor newpath 720 261 moveto 721 271 lineto 715 263 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 624 131 moveto 13 -0.5 (\\0) alignedtext end grestore % aaddchar gsave 10 dict begin 726 33 42 18 ellipse_path stroke gsave 10 dict begin 726 28 moveto 63 -0.5 (aaddchar) alignedtext end grestore end grestore % aescape -> aaddchar newpath 540 94 moveto 561 84 587 72 592 70 curveto 621 59 654 50 681 44 curveto stroke 0.000 0.000 0.000 edgecolor newpath 679 42 moveto 689 42 lineto 680 47 lineto closepath fill 0.000 0.000 0.000 edgecolor gsave 10 dict begin 624 78 moveto 49 -0.5 (default) alignedtext end grestore % aaddchar -> app newpath 379 133 moveto 399 104 415 97 452 79 curveto 510 52 530 59 592 48 curveto 623 43 658 39 684 37 curveto stroke 0.000 0.000 0.000 edgecolor newpath 382 133 moveto 374 140 lineto 378 130 lineto closepath fill 0.000 0.000 0.000 edgecolor endpage grestore %%PageTrailer %%EndPage: 1 %%Trailer %%Pages: 1 end restore %%EOF hnb-1.9.18/src/autosave.c0000644000175000017500000000610607723016223014530 0ustar jimjim00000000000000/* * autosave.c -- the core of the autosave functionality * * * Copyright (C) 2001,2003 Øyvind Kolås * * 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, 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. */ #include #include #include "tree.h" #include "prefs.h" #include "ui.h" #include static int nodes_changed=0; /* counter for number of changes since saves */ static int autosave_threshold=0; /* autosave for every autosave_threshold nodes_changed */ static int autosave_timeout=50; /* ticks to wait for autosaving, if there is nodes changed */ static int autosave_timer=0; static int autosave_sync=1; static void autosave_invoke(Node *pos){ if (prefs.db_file[0]!= (char) 255) { /* magic value when tutorial is shown */ { char buf[4096]; sprintf (buf, "export_binary %s_hnb_rescue", prefs.db_file); docmd (node_root(pos), buf); cli_outfunf("autosaved, %i nodes changed\n",nodes_changed); } } if(autosave_sync) sync(); nodes_changed=0; autosave_timer=0; } static int tree_changed_cmd (int argc, char **argv, void *data) { /* TODO: add increment handling, for "extreme changes" */ Node *pos = (Node *) data; nodes_changed++; if(autosave_threshold<=nodes_changed) autosave_invoke(pos); return (int) pos; } static int autosave_check_timeout (int argc, char **argv, void *data) { Node *pos = (Node *) data; if(nodes_changed){ autosave_timer++; if(autosave_timeout && autosave_timeout < autosave_timer){ autosave_invoke(pos); } } return (int) pos; } /* !init_autosave(); */ void init_autosave () { cli_add_command ("tree_changed", tree_changed_cmd, "[increment]"); cli_add_help ("tree_changed", "used internally to drive the autosave functionality, for severe changes, pass a high number(1000), to make sure the radical changes are saved _NOW_, otherwise don't pass an increment"); cli_add_command ("autosave_check_timeout", autosave_check_timeout, ""); cli_add_int ("autosave_timeout", &autosave_timeout, "number of ticks before autosaving after change"); cli_add_int ("autosave_sync", &autosave_sync, "whether the filesystem should be synced after autosave"); cli_add_int ("autosave_timer", &autosave_timer, "number of ticks since unsaved change"); cli_add_int ("autosave_threshold", &autosave_threshold, "save for evrery autosave_threshold nodes changed"); cli_add_int ("autosave_threshold_nodes_changed", &nodes_changed, "counter for number of changes since save"); } hnb-1.9.18/src/expanded.c0000644000175000017500000000527107723016223014473 0ustar jimjim00000000000000/* * expanded.c -- functions to expand/unexpand nodes * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #include "tree.h" #include "cli.h" #define NULL 0 #include "evilloop.h" #include "ctype.h" #include "ui_binding.h" static int cmd_expand (int argc,char **argv, void *data) { Node *pos = (Node *) data; if(argc==1){ if(inputbuf[0] && isprint(lastbinding->key)){ /* evil workaround */ if (lastbinding->key > 31 && lastbinding->key < 255) { /* input for buffer */ inputbuf[strlen (inputbuf) + 1] = 0; inputbuf[strlen (inputbuf)] = lastbinding->key; } return (int)pos; } node_setflag(pos,F_expanded,1); } else if((!strcmp(argv[1],"-a"))||(!strcmp(argv[1],"--all"))){ Node *tnode = node_root (pos); while (tnode) { node_setflag(tnode,F_expanded,1); tnode = node_recurse (tnode); } cli_outfun ("expanded all nodes"); } return (int) pos; } static int cmd_collapse (int argc,char **argv, void *data) { Node *pos = (Node *) data; if(argc==1){ if(inputbuf[0] && isprint(lastbinding->key)){ /* evil workaround */ if (lastbinding->key > 31 && lastbinding->key < 255) { /* input for buffer */ inputbuf[strlen (inputbuf) + 1] = 0; inputbuf[strlen (inputbuf)] = lastbinding->key; } return (int)pos; } node_setflag(pos,F_expanded,0); } else if((!strcmp(argv[1],"-a"))||(!strcmp(argv[1],"--all"))){ Node *tnode = node_root (pos); while (tnode) { node_setflag(tnode,F_expanded,0); tnode = node_recurse (tnode); } cli_outfun ("collapsed all nodes"); } return (int) pos; } /* !init_expanded(); */ void init_expanded () { cli_add_command ("expand", cmd_expand, "[--all|-a]"); cli_add_help ("expand", "expand the current entry, thus showing it's subentries, if the\ parameter -a is given, all nodes in the tree will be expaned"); cli_add_command ("collapse", cmd_collapse, ""); cli_add_help ("collapse", "collapse the current entrys subentries, if the\ parameter -a is given, all nodes in the tree will be expaned"); } hnb-1.9.18/src/query.c0000644000175000017500000000303707723016223014046 0ustar jimjim00000000000000/* * query.c -- querying the user for input * * * Copyright (C) 2001,2003 Øyvind Kolås * * 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, 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. */ #include #include "tree.h" #include "prefs.h" #include "ui.h" #include static char query[100]; static int getquery_cmd (int argc, char **argv, void *data) { Node *pos = (Node *) data; strcpy (query, ""); if(argc==2) ui_getstr (argv[1], &query[0]); else ui_getstr ("enter string", &query[0]); return (int) pos; } /* !init_query(); */ void init_query () { cli_add_command ("getquery", getquery_cmd, ""); cli_add_help ("getquery", "Input a string from the user (put into the variable query, used by amongst other function the search function, and at least some of the export/import functions"); cli_add_string ("query", query, "last query (also settable as a variable)"); } hnb-1.9.18/src/query.h0000644000175000017500000000154207723016223014052 0ustar jimjim00000000000000/* * query.h -- querying the user for input * * * Copyright (C) 2001,2003 Øyvind Kolås * * 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, 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. */ extern char query[100]; hnb-1.9.18/src/cli_history.o0000644000175000017500000002136407723016223015250 0ustar jimjim00000000000000ELF!<4( .shstrtab.text.data.data1.stab.index.stab.indexstr.comment.strtab.symtab.rela.textã¿ %¤ à €¤€ ¢ â$  ”¡@’%¤ à ¢ ?â$ ¢ à`  ?à$`ÇàèÇàèã¿ ð' DÿÿÞæ DàLà€¤€Çàè+ª`à`¥, £, ¤€£,  €-¬ ” c@’Àà`¥, £, ¤€£, ¤€¢ cÀ,€â`¤üâ$ à`¢ â%`à   ?à$ à`  ?à%`¥, £, ¤€£,  €À,ÇàèÇàè㿘ÿÿ£+ª`æ`¥,à£,ऀ£,à €#¢`¤ä'¿øàL €¤€;º`€¢$àâ%`¢ `?â%`¢`à`  ?à$`  à%`€º€°@Çàè㿘%¤ à ¢ â$ à €¤€ `à$ ÿÿn'¦ààà¥, £, ¤€£,  €#¢`ºàO`€¤€àà $ à$à%¤ à ¢ ?â$ ¢ à`  ?à$`À$  @à'¿ü°Çàè°ÇàèI<G4cli_history.cXs ; V=3.1 ; R=Sun WorkShop 6 update 1 C 5.2 2000/09/11/home/users/p/pi/pippin/hnb-1.9.16/src; /opt/SUNWspro/WS6U1/bin/acc -Xs -YP,:/usr/ucblib:/opt/SUNWspro/WS6U1/bin/../lib:/opt/SUNWspro/WS6U1/bin:/usr/ccs/lib:/usr/lib -I.. -DHAVE_CONFIG_H -Ilibcli -I/usr/ucbinclude -c libcli/cli_history.c -Qoption acomp -xp@(#)string.h 1.24 99/08/10 SMI@(#)string_iso.h 1.2 99/11/09 SMI@(#)feature_tests.h 1.18 99/07/26 SMI@(#)isa_defs.h 1.20 99/05/04 SMIacomp: Sun WorkShop 6 update 1 C 5.2 2000/09/11cli_history.chistoryreadposwriteposskiptwoforwardinitcli_historynextcli_historyprevstrncpycli_historyaddmemsetÿñ( 7l<(ÈL€˜\dÜs  @ H L ¼ À Ü à ì Œ  ¬ ° Ì Ð , 0 ` d € „ ¨ ¬ 4] ˜ðˆ˜œ$ *ÀI9 ¹BÂzJ<à R   hnb-1.9.18/src/util_string.c0000644000175000017500000000402307723016223015240 0ustar jimjim00000000000000/* * util_string.c -- string utility functions for hnb * * Copyright (C) 2003 Øyvind Kolås * * 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, 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. */ #include #include #include #include int string_isoneof(char *string, char **strings){ while(*strings){ if(!strcmp(string,*strings)) return 1; strings++; } return 0; } char *string_replace(char *string, char **mappings ){ char *newstring; if(!string) return NULL; /* allocate new string */ { int oldlen=strlen(string); int newlen=oldlen; char *inpos=string; while(*inpos){ int match=0; char **cmap=mappings; while(*cmap && !match){ if(!strncmp(inpos,*cmap, strlen(*cmap) )){ inpos+=strlen(*cmap); newlen+=(strlen(*(cmap+1))-strlen(*(cmap))); match=1; } cmap+=2; } if(!match) inpos++; } newstring=malloc(newlen+1); /* add room for \0 */ } if(!newstring) return NULL; /* build new string */ { char *inpos=string; char *outpos=newstring; while(*inpos){ int match=0; char **cmap=mappings; while(*cmap && !match){ if(!strncmp(inpos,*cmap, strlen(*cmap) )){ strcpy(outpos,*(cmap+1)); outpos+=strlen(*(cmap+1)); inpos+=strlen(*cmap); match=1; } cmap+=2; } if(!match){ *(outpos++)=*(inpos++); } } *outpos='\0'; } return newstring; } hnb-1.9.18/src/util_string.h0000644000175000017500000000015207723016223015244 0ustar jimjim00000000000000char *string_replace(char *string, char **mappings ); int string_isoneof(char *string, char **strings); hnb-1.9.18/src/cal.c0000644000175000017500000000556207723016223013445 0ustar jimjim00000000000000/* * cal.c -- feature to insert a calendar in hnb * * Copyright (C) 2003 Øyvind Kolås * * 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, 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. */ /**************/ #include "tree.h" #include "cli.h" #include "ui.h" #include "file.h" #include "prefs.h" #include #include #include static char *const wday[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", " "}; static char *const mname[] = { "", "January", "February", "March", "April", "May" ,"June", "July", "August", "September", "October", "November" , "December"}; static int insert_cal(int argc, char **argv, void *data){ Node *pos=(void *)data; int year; int month; import_state_t ist; if( (argc!=3) || (atoi(argv[1])>12 )){ cli_outfunf("usage: %s ", argv[0]); return (int)data; } month=atoi(argv[1]); year=atoi(argv[2]); if(prefs.readonly){ cli_outfun("readonly flag set, avoiding insertion"); return (int)data; } if(year<2000){ /* nasty,.. y2k like fix,.. but,.. it's just here */ year+=2000; } init_import(&ist, pos); { char tmpstr[40]; sprintf(tmpstr,"%i %s", year, mname[month]); import_node_text(&ist, 0, tmpstr); { struct tm tdata; tdata.tm_year = year - 1900; tdata.tm_mon = month - 1; tdata.tm_mday = 1; tdata.tm_hour = 0; tdata.tm_min = 0; tdata.tm_sec = 1; tdata.tm_isdst = -1; mktime (&tdata); while(tdata.tm_mon==month-1){ sprintf (tmpstr,"%s%c%02i\n", wday[tdata.tm_wday], (tdata.tm_wday==0 || tdata.tm_wday==6)?'_':' ', tdata.tm_mday); import_node_text(&ist, 1, tmpstr); /* I prefer not to plan on this level import_node_text(&ist, 2, "08:00"); import_node_text(&ist, 2, "09:00"); import_node_text(&ist, 2, "10:00"); import_node_text(&ist, 2, "11:00"); import_node_text(&ist, 2, "12:00"); import_node_text(&ist, 2, "13:00"); import_node_text(&ist, 2, "14:00"); import_node_text(&ist, 2, "15:00"); import_node_text(&ist, 2, "16:00"); import_node_text(&ist, 2, "17:00"); */ tdata.tm_mday++; mktime (&tdata); } } } docmd(pos,"tree_changed"); return (int)pos; } /* !init_cal(); */ void init_cal(){ cli_add_command ("insert_cal", insert_cal, " "); } hnb-1.9.18/src/cli_macro.c0000644000175000017500000000610607723016223014631 0ustar jimjim00000000000000/* * macro.c -- adding macro defining capabilities to libcli * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #define MAX_MACRO_LINES 512 #include "tree.h" #include #include "cli.h" #include "ui_cli.h" #include #include static void (*precmd_backup) (char *)=NULL; typedef struct MacroT{ char *name; char **commands; struct MacroT *next; } MacroT; static MacroT *macro = NULL; static char **cur_cmd = NULL; static void macro_pre_command (char *commandline) { char *c = commandline; if (commandline) { while (isspace ((unsigned char)*c)) c++; if (*c == '#') commandline[0] = '\0'; if (*c == '\0') commandline[0] = '\0'; if(!strcmp(c,"end")){ *cur_cmd=NULL; cli_precmd=precmd_backup; commandline[0]= '\0'; } else { *cur_cmd=strdup(c); cur_cmd++; commandline[0]= '\0'; /* don't let the cli run the macro whilst we're doing this */ } } } static MacroT *lookup_macro(char *name){ MacroT *tmacro=macro; while(tmacro){ if(!strcmp(name,tmacro->name)) return tmacro; tmacro=tmacro->next; } return NULL; } static Node *do_macro(MacroT *macro, Node *pos){ char **curcmd=macro->commands; while(*curcmd){ pos=docmd(pos,*curcmd); curcmd++; } return pos; } static int cmd_macro (int argc, char **argv, void *data) { Node *pos=(Node *)data; if(argc==1){ cli_outfunf("usage: %s ....",argv[0]); } else if(argc==2){ MacroT *tmacro=lookup_macro(argv[1]); if(tmacro){ return (int)do_macro(tmacro,pos); } else { cli_outfunf("no such macro defined '%s'",argv[1]); } /* run macro */ } else if(argc==3) { if(!strcmp(argv[1],"define") ){ if(lookup_macro(argv[2])){ cli_outfunf("error macro %s already exist,.. this might turn out badly,.. " ,argv[2]); return (int) pos; } else { MacroT *tmacro; if(!macro){ macro=calloc(1,sizeof(MacroT)); tmacro=macro; } else { tmacro=macro; while(tmacro->next) tmacro=tmacro->next; tmacro->next=calloc(1,sizeof(MacroT)); tmacro=tmacro->next; } tmacro->name=strdup(argv[2]); tmacro->commands=calloc(sizeof(char *),MAX_MACRO_LINES); cur_cmd=(tmacro->commands); precmd_backup=cli_precmd; cli_precmd=macro_pre_command; } } } return (int) pos; } /* !init_cli_macro(); */ void init_cli_macro (void) { cli_add_command ("macro", cmd_macro, ""); cli_add_help ("macro", ""); } hnb-1.9.18/src/.hnb.c.swo0000600000175000017500000005000007723016223014315 0ustar jimjim00000000000000b0VIM 6.1Î6H?[ÄÝpippincompis~pippin/code/hnb-1.9.18pre/src/hnb.c3210#"! Utpÿ€•Jad¤ à JÜÇŽxeUGB,ÿþúçæ§Œˆ‡q]?;876Í © ‡ 5 2 1 0   ö è Þ Ô ¤ Š W R H > *  æ Ü Ò Ã ¾ ¯ ® — ƒ ‚ o F 3 -     î í â à ß } return 0; tree_free (pos); cli_cleanup (); } break; ui_end (); }} addstr (buf); sprintf (buf, "[%i] [%c]\n", c, c); c = getch (); char buf[100]; while (c != 'q') { int c = 0; { ui_init (); case 4: break; printf ("gtk+ interface not implemented\n"); case 3: break; pos = cli (pos); case 2: break; } pos = (Node *) cli_docmd (argv[argno++], pos); while (argno < argc) { pos = (Node *) cli_docmd (cmdline.cmd, pos); case 0: break; ui_end (); pos = evilloop (pos); case 1: switch (cmdline.ui) { } pos = docmd (pos, "status 'navigate the documentation with your cursor keys'"); pos = docmd (pos, "status ''"); pos = docmd (pos, "import_help"); prefs.db_file[0] = (char) 255; /* disable saving */ if (prefs.tutorial != 2) if (prefs.tutorial) { } } pos = node_recurse (pos); while (oldpos--) if (oldpos != -1) { } pos = docmd (pos, buf); sprintf (buf, "import_%s %s", prefs.format, file_to_load); char buf[4096]; { } oldpos = xml_getpos (file_to_load); if (prefs.savepos) } exit (1); ui_end (); if (ui_inited) file_to_load); "%s does not seem to be a xml file, aborting.\n", fprintf (stderr, if (!xml_check (file_to_load)) {ad€ý´±jgΆzw(ß ’ ~ . å ¬ ¨ § ¤ ƒ q d T Q L  ú æ ß Þ Ê ¶ ¢ ¡ Ž z i Y F 4   ù ÷ å ¤ š ƒ ;  ý Ê ³ § £ ƒ ] !  ùÙ¸’€6/ç¤|trqXWV53'íìô§™†|l\L?0⸥ŒxX- àÉŸnU+ùßµ†b6 罓eB } else if (!strcmp (argv[argno], "-x") strcpy(cmdline.format,"opml"); || !strcmp (argv[argno], "--opml")) { || !strcmp (argv[argno], "-opml") } else if (!strcmp (argv[argno], "-o") strcpy(cmdline.format,"hnb"); || !strcmp (argv[argno], "--hnb")) { } else if (!strcmp (argv[argno], "-hnb") strcpy(cmdline.format,"ascii"); || !strcmp (argv[argno], "--ascii")) { } else if (!strcmp (argv[argno], "-a") cmdline.tutorial = 1; || !strcmp (argv[argno], "--tutorial")) { } else if (!strcmp (argv[argno], "-t") cmdline.version = 1; || !strcmp (argv[argno], "--version")) { } else if (!strcmp (argv[argno], "-v") cmdline.usage = 1; || !strcmp (argv[argno], "--help")) { if (!strcmp (argv[argno], "-h") for (argno = 1; argno < argc; argno++) { { /*parse commandline */ NULL, NULL, NULL}; 0, /* tutorial */ 1, /* ui */ "", /*format to load by default */ 1, /* load default db */ 0, /* usage */ 0, /* version */ } cmdline = { char *cmd; char *rcfile; char *dbfile; int tutorial; int ui; char format[64]; int def_db; int usage; int version; struct { /* initilaized defaults */ /* current commandline argument in focus */ int argno; Node *pos;{int main (int argc, char **argv)void init_subsystems ();}\n\n");\t-e execute commands\n\\t-ui interface to use, ( curses(default) or cli)\n\\t-rc specify other config file\n\ fprintf (stderr, "\n\#endif fprintf (stderr, "\t-s --stylized load stylized xml (using libxml2)\n");#ifdef USE_LIBXML\t-x --xml load general xml\n");\t-o --opml load OPML DTD\n\\t --hnb load hnb DTD\n\\t-a --ascii load ascii ascii\n\\n\\t-t --tutorial loads the tutorial instead of a database\n\\t-v --version prints the version\n\\t-h --help this message\n\\n\Options:\n\ fprintf (stderr, "\n\default database: '%s'\n", prefs.default_db_file);\n\It is distributed under the GNU General Public License\n\Hierarchical NoteBook by Øyvind Kolås \n\ fprintf (stderr, "\n\ av0); "\nusage: %s [database] [options] [command [command] ..]\n", fprintf (stderr,{static void usage (const char *av0)#include "evilloop.h"#include "file.h"#include "prefs.h"#include "ui.h"#include "cli.h"#include "ui_cli.h"#include "tree.h"#include #include #include #endif#include #if HAVE_CONFIG_H*/ sannsynlig grunn: feil håndtering av temporary attributte -- gå til parent redigering std. oppretting TODO: noder som forsvinner ved:/* */ * Temple Place - Suite 330, Boston, MA 02111-1307, USA. * this program; if not, write to the Free Software Foundation, Inc., 59 * You should have received a copy of the GNU General Public License along with * * more details. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * This program is distributed in the hope that it will be useful, but WITHOUT * * version. * Software Foundation; either version 2, or (at your option) any later * the terms of the GNU General Public License as published by the Free * This program is free software; you can redistribute it and/or modify it under * * Copyright (C) 2001-2003 Øyvind Kolås * * hnb.c -- the main app, of hierarchical notebook, an personal database/*adƒ•Ø«‰wM%óÐÉ›nY*é ¼ § t _ R   ÿ Ñ ­ € C (  ì æ Ú ¹ ~ o M *   ä Ï Á • Š † ƒ ‚ m l V C 7 4 3  ê Þ Û Ú Ã ™ – • ” p V   øõôÞÐÏ¿¾½€iS!ùöõÞ­Šsi?<;'&ûàß·´’tc'ñÓº˜…us_EÄ·ž‘~cM4%òåÖ«•ˆycVH;5/ ÿüÖ°„ƒ… ) { !strcmp(prefs.format,"xml") !strcmp(prefs.format,"opml") || if (!strcmp(prefs.format,"hnb") || } } ui_init(); if(ui_was_inited) } } break; default: break; got_response=1; case 'o': break; got_response=1; strcpy(file_to_load, recovery_file); case 'r': break; got_response=1; remove(recovery_file); case 'd': switch(response[0]){ gets(response);[d|r|o]>", recovery_file);o)pen read_only\n\r)recover\n\d)elete recovery file\n\was aborted.This could mean that a prior instance of hnb is still running or that hnb fprintf(stderr,"hnb recovery file (%s) exists\n\ while(!got_response){ fclose(tfile); ui_end(); if(ui_inited) int ui_was_inited=ui_inited; int got_response=0; char response[1024]="_"; if(tfile){ tfile = fopen(recovery_file, "r"); sprintf(recovery_file, "%s_hnb_rescue", prefs.db_file); FILE *tfile; char recovery_file[4096]; { /* check for recovery file */ strcpy(file_to_load, prefs.db_file); char file_to_load[4096]; int oldpos = -1; if (!prefs.tutorial) { pos = tree_new (); } strcpy (prefs.db_file, cmdline.dbfile); } else { prefs.tutorial = 2; if (!file_check (prefs.db_file)) strcpy (prefs.db_file, prefs.default_db_file); if (cmdline.def_db) { } strcpy(prefs.format, cmdline.format); if (cmdline.format[0] ) { /* format specified */ prefs.tutorial = 1; if (cmdline.tutorial) /* ovveride the prefs with commandline specified options */ load_prefs (); ui_init (); if (cmdline.ui == 1) } sleep (1); prefs.rc_file); fprintf (stderr, "created %s for hnb preferences file\n", write_default_prefs (); if (!file_check (prefs.rc_file)) { } strcpy (prefs.rc_file, cmdline.rcfile); if (cmdline.rcfile) { } exit (0); fprintf (stderr, "%s %s\n", PACKAGE, VERSION); if (cmdline.version) { } exit (0); usage (argv[0]); if (cmdline.usage) { init_subsystems (); } } } } break; /* stop processing cmd args */ argno++; cmdline.ui = 0; cmdline.cmd = argv[argno]; } else { cmdline.def_db = 0; cmdline.dbfile = argv[argno]; } else if (!cmdline.dbfile) { exit (1); fprintf (stderr, "unknown option %s\n", argv[argno]); if (argv[argno][0] == '-') { } else { } cmdline.dbfile = (char *) -1; cmdline.def_db = 1; if (!cmdline.dbfile) { /* actually just a dummy option to specify default db */ } else if (!strcmp (argv[argno], "-e")) { cmdline.rcfile = argv[++argno]; } else if (!strcmp (argv[argno], "-rc")) { } exit (1); fprintf (stderr, "unknown interface %s\n", argv[argno]); } else { cmdline.ui = 4; } else if (!strcmp (argv[argno], "keygrab")) { cmdline.ui = 3; || !strcmp (argv[argno], "gtk+")) { } else if (!strcmp (argv[argno], "gtk") cmdline.ui = 2; } else if (!strcmp (argv[argno], "cli")) { cmdline.ui = 1; if (!strcmp (argv[++argno], "curses")) { } else if (!strcmp (argv[argno], "-ui")) {#endif strcpy(cmdline.format,"sxml"); || !strcmp (argv[argno], "--stylized")) { || !strcmp (argv[argno], "-sx") } else if (!strcmp (argv[argno], "-s")#ifdef USE_LIBXML strcpy(cmdline.format,"xml"); || !strcmp (argv[argno], "--xml")) { || !strcmp (argv[argno], "-gx")hnb-1.9.18/src/file_binary.c0000644000175000017500000001023607723016224015164 0ustar jimjim00000000000000/* * file_binary.c -- binary fileformat, version specific and for internal use only * * Copyright (C) 2001-2003 Øyvind Kolås * * 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, 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. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include "cli.h" #include "tree.h" #include "file.h" #include "prefs.h" #include "query.h" #include "util_string.h" #define char2int(c1,c2,c3,c4) ((c1)+256*(c2)+256*256*(c3)+256*256*256*(c4)) static unsigned int hnb_binary_header = char2int('h','n','b','\n'); static unsigned int hnb_binary_version = 1; #define indent(count,char) {int j;for(j=0;jattrib; while(att){ attributes++; att=att->next; } } fwrite(&level, sizeof(int), 1, file); fwrite(&attributes, sizeof(int), 1, file); {Node_AttItem *att=node->attrib; while(att){ int len=strlen(att->name); fwrite(&len,sizeof(int),1,file); fwrite(att->name,1,len, file); len=strlen(att->data); fwrite(&len,sizeof(int),1,file); fwrite(att->data,1,len, file); att=att->next; } } if (node_right (node)) { binary_export_nodes (file, node_right (node), level + 1); } node = node_down (node); } } static int export_binary (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc>=2?argv[1]:""; FILE *file; if (!strcmp (filename, "-")) file = stdout; else file = fopen (filename, "w"); if (!file) { cli_outfunf ("binary export, unable to open \"%s\"", filename); return (int) node; } fwrite (&hnb_binary_header, 4, 1, file); fwrite (&hnb_binary_version, 4, 1, file); binary_export_nodes (file, node, 0); cli_outfunf ("binary export, wrote data to \"%s\"", filename); return (int) node; } static int import_binary (int argc, char **argv, void *data) { Node *node = (Node *) data; char *filename = argc==2?argv[1]:""; import_state_t ist; int moredata=1; FILE *file; file = fopen (filename, "r"); if (!file) { cli_outfunf ("binary import, unable to open \"%s\"", filename); return (int) node; } {int header,version; fread(&header, sizeof(int), 1, file); fread(&version, sizeof(int), 1, file); if(header!=hnb_binary_header || version!=hnb_binary_version){ cli_outfunf("binary import, header mismatch"); } } init_import(&ist, node); while(moredata){ int attributes; int level; moredata=fread(&level, sizeof(int), 1, file); if(!moredata) break; fread(&attributes, sizeof(int),1,file); if(!moredata) break; if(level || attributes){ Node *temp_node=node_new(); while(attributes){ int len; char *att_name; char *att_data; fread(&len, sizeof(int),1,file); att_name=malloc(len+1); fread(att_name,1,len,file); att_name[len]='\0'; fread(&len, sizeof(int),1,file); att_data=malloc(len+1); fread(att_data,1,len,file); att_data[len]='\0'; node_set(temp_node, att_name, att_data); free(att_name); free(att_data); attributes--; } import_node(&ist,level,temp_node); temp_node=NULL; } } if(node_getflag(node,F_temp)) node=node_remove(node); cli_outfunf("binary import - imported \"%s\"",filename); return (int) node; } /* !init_file_binary(); */ void init_file_binary () { cli_add_command ("export_binary", export_binary, ""); cli_add_command ("import_binary", import_binary, ""); } hnb-1.9.18/src/.file_binary.c.swp0000600000175000017500000005000007723016224016033 0ustar jimjim00000000000000b0VIM 6.14L?,»êpippincompis~pippin/code/hnb-1.9.18pre/src/file_binary.c3210#"! Utpÿƒ…adk‹ƒýª§`] Ä|pmÕ ˆ w t $ Û ¢ ž œ Š v o n [ G 3 2 !   ü é Ö ½ ¼ p o + ÿ þ ³ ² ± l j Z F # ü é ä à Ü ´ ‡ † c S 4  ìѬ‰upliN òïí쯭j]\>-'ø¶¡žsHG! àßËÉÈÇŠˆkE0ï៊‡†pHß­©¦¥‹žŽ|oHäÎÁ­™tX att_name=malloc(len+1); fread(&len, sizeof(int),1,file); char *att_data; char *att_name; int len; while(attributes){ Node *temp_node=node_new(); if(level || attributes){ fread(&attributes, sizeof(int),1,file); fread(&level, sizeof(int), 1, file); int level; int attribute init_import(&ist, node); } } cli_outfunf("binary import, header mismatch"); if(header!=hnb_binary_header || version!=hnb_binary_version){ fread(&version, sizeof(int), 1, file); fread(&header, sizeof(int), 1, file); {int header,version; } return (int) node; cli_outfunf ("binary import, unable to open \"%s\"", filename); if (!file) { file = fopen (filename, "r"); FILE *file; int moredata=1; import_state_t ist; char *filename = argc==2?argv[1]:""; Node *node = (Node *) data;{static int import_binary (int argc, char **argv, void *data)} return (int) node; cli_outfunf ("binary export, wrote data to \"%s\"", filename); binary_export_nodes (file, node, 0); fwrite (&hnb_binary_version, 4, 1, file); fwrite (&hnb_binary_header, 4, 1, file); } return (int) node; cli_outfunf ("binary export, unable to open \"%s\"", filename); if (!file) { file = fopen (filename, "w"); else file = stdout; if (!strcmp (filename, "-")) FILE *file; char *filename = argc>=2?argv[1]:""; Node *node = (Node *) data;{static int export_binary (int argc, char **argv, void *data)} } node = node_down (node); } binary_export_nodes (file, node_right (node), level + 1); if (node_right (node)) { } } att=att->next; fwrite(att->data,1,len, file); fwrite(&len,sizeof(int),1,file); len=strlen(att->data); fwrite(att->name,1,len, file); fwrite(&len,sizeof(int),1,file); int len=strlen(att->name); while(att){ {Node_AttItem *att=node->attrib; fwrite(&attributes, sizeof(int), 1, file); fwrite(&level, sizeof(int), 1, file); } } att=att->next; attributes++; while(att){ {Node_AttItem *att=node->attrib; int attributes=0; while (node) {{static void binary_export_nodes (FILE * file, Node *node, int level)#define indent(count,char) {int j;for(j=0;j#include #include #endif#include #if HAVE_CONFIG_H */ * Temple Place - Suite 330, Boston, MA 02111-1307, USA. * this program; if not, write to the Free Software Foundation, Inc., 59 * You should have received a copy of the GNU General Public License along with * * more details. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * This program is distributed in the hope that it will be useful, but WITHOUT * * version. * Software Foundation; either version 2, or (at your option) any later * the terms of the GNU General Public License as published by the Free * This program is free software; you can redistribute it and/or modify it under * * Copyright (C) 2001-2003 Øyvind Kolås * * file_binary.c -- binary fileformat, version specific and for internal use only /*adË [ àÈ£‡gO"úè㽩¥¢¡‚h.,ý ú á ß ž ] [ } cli_add_command ("import_binary", import_binary, ""); cli_add_command ("export_binary", export_binary, "");{void init_file_binary ()*/!init_file_binary();/*} return (int) node; cli_outfunf("binary import - imported \"%s\"",filename); node=node_remove(node); if(node_getflag(node,F_temp)) } } temp_node=NULL; import_node(&ist,level,temp_node); } attributes--; free(att_data); free(att_name); node_set(temp_node, att_name, att_data); att_data[len]='\0'; fread(att_data,1,len,file); att_data=malloc(len+1); fread(&len, sizeof(int),1,file); att_name[len]='\0'; fread(att_name,1,len,file);ad$|þìÚ͆\EB'òåѽ˜| att_name=malloc(len+1); fread(&len, sizeof(int),1,file); char *att_data; char *att_name; int len; while(attributes){ Node *temp_node=node_new(); if(level || attributes){ if(!moredata) break; fread(&attributes, sizeof(int),1,file); if(!moredata) break; moredata=fread(&level, sizeof(int), 1, file); int level; int attributes; while(moredata){ hnb-1.9.18/util/0000755000175000017500000000000007723016224012721 5ustar jimjim00000000000000hnb-1.9.18/util/asc2c.c0000755000175000017500000000152607723016224014067 0ustar jimjim00000000000000#include #define bufsize 4096 void asc2c (FILE *file_in,FILE *file_out,int cmpr){ char buf[100]; char prev; int bpos; while(fgets(buf,100,file_in)!=NULL){ bpos=0; while(buf[bpos]){ switch(buf[bpos]){ case 13:case ' ':case 10:case '\t': if(cmpr){ if(prev!=' '&&prev!='>')fprintf(file_out," "); prev=' '; } else { switch(buf[bpos]){ case ' ':fprintf(file_out," ");break; case '\t':fprintf(file_out," ");break; case 10:fprintf(file_out,"\\n\\\n");break; } } break; case '\\':fprintf(file_out,"\\\\");prev=buf[bpos];break; case '\"':fprintf(file_out,"\\\"");prev=buf[bpos];break; default: fprintf(file_out,"%c",buf[bpos]); prev=buf[bpos]; break; } bpos++; } } } int main(int argc,char **argv){ asc2c(stdin,stdout,argc-1); return 0; } hnb-1.9.18/util/Makefile0000644000175000017500000000004207723016224014355 0ustar jimjim00000000000000all: asc2c clean: rm -f asc2c *~