pax_global_header00006660000000000000000000000064141466370500014520gustar00rootroot0000000000000052 comment=64a232a1055fcc8078442b5c82660905d36984b2 rolo-019/000077500000000000000000000000001414663705000123465ustar00rootroot00000000000000rolo-019/AUTHORS000066400000000000000000000001151414663705000134130ustar00rootroot00000000000000Andrew Hsu Rafael Laboissière rolo-019/COPYING000066400000000000000000000431311414663705000134030ustar00rootroot00000000000000 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. rolo-019/ChangeLog000066400000000000000000000001041414663705000141130ustar00rootroot00000000000000Change log can be examined at GitHub: https://github.com/libvc/rolo rolo-019/INSTALL000066400000000000000000000366261414663705000134140ustar00rootroot00000000000000Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell command './configure && make && make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the 'README' file for instructions specific to this package. Some packages provide this 'INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The 'configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a 'Makefile' in each directory of the package. It may also create one or more '.h' files containing system-dependent definitions. Finally, it creates a shell script 'config.status' that you can run in the future to recreate the current configuration, and a file 'config.log' containing compiler output (useful mainly for debugging 'configure'). It can also use an optional file (typically called 'config.cache' and enabled with '--cache-file=config.cache' or simply '-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how 'configure' could check whether to do them, and mail diffs or instructions to the address given in the 'README' so they can be considered for the next release. If you are using the cache, and at some point 'config.cache' contains results you don't want to keep, you may remove or edit it. The file 'configure.ac' (or 'configure.in') is used to create 'configure' by a program called 'autoconf'. You need 'configure.ac' if you want to change it or regenerate 'configure' using a newer version of 'autoconf'. The simplest way to compile this package is: 1. 'cd' to the directory containing the package's source code and type './configure' to configure the package for your system. Running 'configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type 'make' to compile the package. 3. Optionally, type 'make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type 'make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the 'make install' phase executed with root privileges. 5. Optionally, type 'make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior 'make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing 'make clean'. To also remove the files that 'configure' created (so you can compile the package for a different kind of computer), type 'make distclean'. There is also a 'make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type 'make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide 'make distcheck', which can by used by developers to test that all other targets like 'make install' and 'make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the 'configure' script does not know about. Run './configure --help' for details on some of the pertinent environment variables. You can give 'configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU 'make'. 'cd' to the directory where you want the object files and executables to go and run the 'configure' script. 'configure' automatically checks for the source code in the directory that 'configure' is in and in '..'. This is known as a "VPATH" build. With a non-GNU 'make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use 'make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple '-arch' options to the compiler but only a single '-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the 'lipo' tool if you have problems. Installation Names ================== By default, 'make install' installs the package's commands under '/usr/local/bin', include files under '/usr/local/include', etc. You can specify an installation prefix other than '/usr/local' by giving 'configure' the option '--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option '--exec-prefix=PREFIX' to 'configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like '--bindir=DIR' to specify different values for particular kinds of files. Run 'configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of '${prefix}', so that specifying just '--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to 'configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the 'make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, 'make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of '${prefix}'. Any directories that were specified during 'configure', but not in terms of '${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the 'DESTDIR' variable. For example, 'make install DESTDIR=/alternate/directory' will prepend '/alternate/directory' before all installation names. The approach of 'DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of '${prefix}' at 'configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving 'configure' the option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. Some packages pay attention to '--enable-FEATURE' options to 'configure', where FEATURE indicates an optional part of the package. They may also pay attention to '--with-PACKAGE' options, where PACKAGE is something like 'gnu-as' or 'x' (for the X Window System). The 'README' should mention any '--enable-' and '--with-' options that the package recognizes. For packages that use the X Window System, 'configure' can usually find the X include and library files automatically, but if it doesn't, you can use the 'configure' options '--x-includes=DIR' and '--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of 'make' will be. For these packages, running './configure --enable-silent-rules' sets the default to minimal output, which can be overridden with 'make V=1'; while running './configure --disable-silent-rules' sets the default to verbose, which can be overridden with 'make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX 'make' updates targets which have the same timestamps as their prerequisites, which makes it generally unusable when shipped generated files such as 'configure' are involved. Use GNU 'make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its '' header file. The option '-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put '/usr/ucb' early in your 'PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in '/usr/bin'. So, if you need '/usr/ucb' in your 'PATH', put it _after_ '/usr/bin'. On Haiku, software installed for all users goes in '/boot/common', not '/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features 'configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, 'configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the '--build=TYPE' option. TYPE can either be a short name for the system type, such as 'sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file 'config.sub' for the possible values of each field. If 'config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option '--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with '--host=TYPE'. Sharing Defaults ================ If you want to set default values for 'configure' scripts to share, you can create a site shell script called 'config.site' that gives default values for variables like 'CC', 'cache_file', and 'prefix'. 'configure' looks for 'PREFIX/share/config.site' if it exists, then 'PREFIX/etc/config.site' if it exists. Or, you can set the 'CONFIG_SITE' environment variable to the location of the site script. A warning: not all 'configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to 'configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the 'configure' command line, using 'VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified 'gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an Autoconf limitation. Until the limitation is lifted, you can use this workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash 'configure' Invocation ====================== 'configure' recognizes the following options to control how it operates. '--help' '-h' Print a summary of all of the options to 'configure', and exit. '--help=short' '--help=recursive' Print a summary of the options unique to this package's 'configure', and exit. The 'short' variant lists options used only in the top level, while the 'recursive' variant lists options also present in any nested packages. '--version' '-V' Print the version of Autoconf used to generate the 'configure' script, and exit. '--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally 'config.cache'. FILE defaults to '/dev/null' to disable caching. '--config-cache' '-C' Alias for '--cache-file=config.cache'. '--quiet' '--silent' '-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to '/dev/null' (any error messages will still be shown). '--srcdir=DIR' Look for the package's source code in directory DIR. Usually 'configure' can determine that directory automatically. '--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. '--no-create' '-n' Run the configure checks, but stop before creating any output files. 'configure' also accepts some other, not widely useful, options. Run 'configure --help' for more details. rolo-019/Makefile.am000066400000000000000000000003451414663705000144040ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in ## $Id: Makefile.am,v 1.9 2003/05/14 10:03:31 ahsu Exp $ SUBDIRS = src doc test AUTOMAKE_OPTIONS = check-news dist-bzip2 EXTRA_DIST = depcomp test/contacts.vcf rolo.spec rolo-019/NEWS000066400000000000000000000144021414663705000130460ustar00rootroot00000000000000Rolo 019 (2021-11-22) * Fix compilation warnings and update to Autoconf 2.71 (no visible changes for users) Rolo 018 (2021-09-13) * Also, use format string literals in src/help.c (forgotten in the previous releases). Rolo 017 (2021-09-13) * Also, use format string literals in src/edit.c (forgotten in release v016) Rolo 016 (2021-09-12) * Use format string literals in ncurses functions * Suggest khard in README.md Rolo 015 (2021-08-27) * Use mktemp instead of tempfile in the unit test Rolo 014 (2019-01-30) * Add unit test suite. * Minor tweaks in configure.ac Rolo 013 (2017-08-18) * Do not install the (inexistent) file rfc2426.txt * Minor tweaks in configure.ac Rolo 012 (2017-02-18) * The sources now are maintained at GitHub (https://github.com/libvc/rolo) * Rafael Laboissière is the new maintainer. * Added support for displaying UTF-8 encoded entries. * Does not create the default contacts file (~/.rolo/contacts.vcf) when option -f is used. * Display multiple addresses present in the entries. * Display the value of "TYPE" attributes. * Fix some bugs yielding segmentation faults. * Display unlimited number of NOTE fields. Rolo 011 (2003-05-20) * Searching is now fixed and the results are appearing properly on the screen. Searches are now performed case-insensitive. * Added ability to search forwards or backwards for the next match. * There is now a dependency on libvc if you want to perform your own build of rolo. You can download libvc from the rolo web site (see the README file for the web address). * The mutt_vc_query utility is no longer distributed with rolo. It is now a separate package. You can download mutt_vc_query from the rolo web site (see the README file for the web address). Rolo 010 (2003-05-04) * Added a new utility for mutt's `query_command' called `mutt_vc_query'. This utility will allow a mutt user to query the email addresses in `contacts.vcf' with the `Q' command in mutt. See the README file for how to implement. Rolo 009 (2003-04-26) * Preferred telephone number and email addresses are now displayed in the index screen (but only if the parameter is specified exactly as TYPE=pref). A cleaner way of parsing out the parameter values is in the works. * Added a few more `convenience functions' to the vcard API. * Help screen has been updated. * Man page has been updated with the mdoc template format as specified in mdoc(7). Rolo 008 (2003-04-20) * Revamped the entire libvcard with a brand-spanking-new API. Now there are only two typedefs that the user programmer needs to know about: vcard_component and vcard_component_param. * Added more telephone numbers and email addresses to the telecommunications display screen. * Added ability to use the left and right arrow keys to switch between the 5 groups in the view screen. * Source code will also be distributed in Tar/Bzip2 format from now on. Rolo 007 (2003-04-10) * The view screen has now been simplified to 5 groupings. The help screen has been updated to reflect these changes. Rolo 006 (2003-04-04) * The view screen is now split-up into 8 screens for grouping the contact entry into managable viewing sections. More vCard properties have been added to the view screen as a result of this grouping format--entries such as longitude and latitude. The grouping format is based on the sections described in the RFC 2426 specifications for vCard version 3.0. * VCard entries are now read from file with the vCard lines in the order that they appear. This eliminates the funny problem of having the vcard lines displayed in the reverse order that they appear in the contacts.vcf file when editing. * A man page has been created for rolo(1). * Updated the view help screen to match the functionality implemented. Rolo 005 (2003-03-29) * A datafile is created upon the startup of rolo if it does not already exist. The datafile is at $HOME/.rolo/contacts.vcf. * Fixed a core dump upon adding the first entry in an empty datafile. * Performance improvements for those cases where an edit, add, or delete is aborted--the index refresh is spared in those circumstances. * Updated the help screens to match the functionality implemented thus far. Rolo 004 (2003-03-23) * Added `edit' functionality. Press the `e' key in the index screen or the view screen to use. The editor defined in the environment variable EDITOR will be used for editing the entry. * Users can now add a new entry by pressing the `a' key in the index screen. The editor defined in the environment variable EDITOR will be used for creating the new entry. * Added `delete' functionality. Press the `d' key in the index screen to use. It will only ask for confirmation once before proceeding and there is no way to undo the delete, so be careful. * And, of course, all these extra features are documented in the index help screen which can be reached by pressing the `h' key. Rolo 003 (2003-03-07) * Now sorts ascending by family name on startup. * Added `sort' functionality to the index screen. Press the `s' key to use. * Added `filter' functionality to the index screen. Press the `f' key to use. * Added `remove filter' functionality to the index screen. Type `F' to use. * And, of course, all these extra features are documented in the index help screen which can be reached by pressing the `h' key. * Can resize to larger dimensions in an xterm window without crashing. Rolo 002 (2003-02-28) * The source code is now distributed with a proper `configure' script. Refer to the `INSTALL' file for details on how to use it to compile and install Rolo. This means Rolo should be able to run on a more diverse list of operating systems and environments (thanks to autoconf and automake). * The help screens should be more relevant to the screens they give help about. * An example data file can be found in the `test' directory. After rolo is installed, the example data file can be loaded by using the `-f' option on rolo. Rolo 001 (2003-02-22) * This is the first release of the Rolo package. It has been developed and tested on FreeBSD 4.7. Keep in mind that you will need a file in your `%{HOME}/.rolo/' directory titled `contacts.vcf' and in the same format as the `data.vcf' file format (which is in vCard 3.0 format). This release only has capabilities to read from the file and display the entries to screen. rolo-019/README000066400000000000000000000027321414663705000132320ustar00rootroot00000000000000rolo - contact management software release 011 Copyright (C) 2003 Andrew Hsu Rolo keeps track of your contacts and display them to you with a text-based menu. Rolo strives to be a well-constructed tool for complimenting text-based email programs-such as mutt. It utilizes the vCard version 3.0 format for storing its contacts and it interfaces with the end-user through a NCurses front-end. Rolo is written in ANSI C and uses Automake and Autoconf to manage its build system. Rolo makes uses of the NCurses library and the menu library that compliments NCurses. It has been developed and tested thoroughly on FreeBSD, but the code was designed to be as non-platform specific as possible. To add a new contact in rolo, type `a' in the index screen. This will pop open your "favorite editor" so you can compose a new vCard file by hand. This may be a little low-level for some people, so an example vCard file has been provided in the `test' directory. If rolo is installed using an rpm file, the example file can be found in: /usr/share/doc/rolo-011/contacts.vcf Directory contents: doc/ .............. Documentation for Rolo. src/ .............. Source code for the rolo user interface. test/ ............. Test data for rolo. This software is maintained on SourceForge: http://rolo.sf.net/ See the `INSTALL' file for building and installation instructions. See the `COPYING' file for copying conditions. Send bugs, questions, or comments to Andrew Hsu . rolo-019/README.md000066400000000000000000000010551414663705000136260ustar00rootroot00000000000000# rolo [vCard](https://tools.ietf.org/html/rfc2426) viewer and editor. Fork of the [Rolo](http://rolo.sourceforge.net/) project by Andrew Hsu, which seems abandoned. Original read me file provided in README. You may also be interested in [khard](https://github.com/scheibler/khard), an "address book for the Linux console" which can read and write vCard files stored locally. ## Compilation autoreconf -f -i ./configure make make install If shunit2 is installed on the system, then the [unit tests](test/run-tests) will be exercised. rolo-019/THANKS000066400000000000000000000003441414663705000132620ustar00rootroot00000000000000Tony Granberg Gregor Hoffleit Xavier Serpaggi Jen Wang Oliver Braun rolo-019/TODO000066400000000000000000000017531414663705000130440ustar00rootroot00000000000000* Implement a form-based interface for the user to add and edit contacts. * Create a raw-view display of a contact's vCard entry accessable through the view screen or the index screen. * Create a man page for rolorc(5). * Add the ability for the user to specify colors of menu bar, text, background, highlighted text, etc. in the rolorc file. * Allow the user to save a contact's public key value to a file. * Allow the user to save a contact's photograph data to a file. * Allow the user to save a contact's sound data to a file. * Implement read-only mode when the user executes rolo with the `-r' option. * Allow user to export a rolo contact to a file (CSV, vCard 3.0, vCard 2.1, TSV, html, etc.) * Allow the user to import a contact from a file (CSV, vCard 3.0, TSV, Outlook vCard, Netscape vCard, Evolution vCard, etc.) * Allow the user to view a photo (implemented by launching an external program that can display images--this external program could be specified in the rolorc file). rolo-019/configure.ac000066400000000000000000000022671414663705000146430ustar00rootroot00000000000000# Process this file with autoconf to produce a configure script. # $Id: configure.ac,v 1.18 2004/07/25 12:07:00 ahsu Exp $ AC_INIT([rolo],[019],[rafael@laboissiere.net]) AM_INIT_AUTOMAKE AC_PREREQ([2.71]) AC_COPYRIGHT([Copyright (C) 2003 Andrew Hsu Copyright (C) 2017, 2019, 2021 Rafael Laboissière]) AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_HEADERS([config.h]) # Checks for programs. AC_PROG_CC # Checks for libraries. AC_CHECK_LIB(vc, vc_new) AC_CHECK_LIB(ncursesw, newwin) AC_CHECK_LIB(menuw, new_menu) CFLAGS="$CFLAGS -I/usr/include/ncursesw/" # Glib settings LIBS="$LIBS $(pkg-config glib-2.0 --libs)" CFLAGS="$CFLAGS $(pkg-config glib-2.0 --cflags)" # Libunac settings LIBS="$LIBS $(pkg-config unac --libs)" CFLAGS="$CFLAGS $(pkg-config unac --cflags)" # Checks for header files. AC_CHECK_INCLUDES_DEFAULT # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST # Checks for library functions. AC_FUNC_MALLOC AC_CHECK_FUNCS([strdup strstr]) AC_CHECK_PROG(HAS_SHUNIT2,shunit2,yes) if test x"$HAS_SHUNIT2" != x"yes" ; then AC_MSG_WARN([shunit2 not found. Unit tests will be skipped.]) fi AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile test/Makefile]) AC_OUTPUT rolo-019/doc/000077500000000000000000000000001414663705000131135ustar00rootroot00000000000000rolo-019/doc/Makefile.am000066400000000000000000000002371414663705000151510ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in ## $Id: Makefile.am,v 1.1 2003/02/27 13:50:45 ahsu Rel $ man_MANS = rolo.1 EXTRA_DIST = $(man_MANS) rolo-019/doc/rolo.1000066400000000000000000000027761414663705000141640ustar00rootroot00000000000000.\" Process this file with .\" groff -man -Tascii rolo.1 .\" .\" $Id: rolo.1,v 1.4 2003/04/03 14:29:52 ahsu Rel $ .Dd April 26, 2003 .Os .Dt ROLO 1 .Sh NAME .Nm rolo .Nd text-based contact management software .Sh SYNOPSIS .Nm rolo .Op Fl r .Op Fl f Ar datafile .Nm rolo .Op Fl v .Nm rolo .Op Fl V .Sh DESCRIPTION Rolo keeps track of your contacts and display them to you with a text-based menu. Rolo strives to be a well-constructed tool for complimenting text-based email programs-such as mutt. It utilizes the vCard version 3.0 format for storing its contacts and it interfaces with the end-user through a NCurses front-end. .Pp The options are as follows: .Bl -tag -offset indent -width "-V" .It -r Open the data file in read-only mode. This essentially disables adding, editing, and deleting contacts. .It -f Use the specified file as the data file. .It -v Display the version. .It -V Display the copyright and license. .El .Sh ENVIRONMENT .Bl -tag -width "ROLO_EDITOR" .It ROLO_EDITOR If ROLO_EDITOR is set, its value is used as the name of the program to invoke when displaying contact entries in advanced edit. If ROLO_EDITOR is not set, then EDITOR is used. If EDITOR is also not set, the default value of /usr/bin/editor is used. .El .Sh FILES .Bl -tag -width "~/.rolo/contacts.vcf" -compact .It Pa ~/.rolo/contacts.vcf Default data file that rolo reads upon startup. .El .Sh SEE ALSO .Xr vi 1 .Sh AUTHORS .An "Andrew Hsu" Aq ahsu@users.sf.net .Sh BUGS The read-only option does not work. The configuration file is not used. rolo-019/rolo.spec000066400000000000000000000021451414663705000141770ustar00rootroot00000000000000# RPM spec file for Red Hat Linux # $Id: rolo.spec_rh,v 1.1 2003/05/14 12:39:29 ahsu Exp $ Summary: Text-based contact management software. Name: rolo Version: 011 Release: 1 Source: http://osdn.dl.sourceforge.net/sourceforge/rolo/%{name}-%{version}.tar.gz License: GPL URL: http://rolo.sf.net/ Packager: Andrew Hsu Distribution: Red Hat Linux Vendor: Andrew Hsu Group: Applications/Productivity BuildRoot: %{_tmppath}/%{name}-buildroot BuildRequires: libvc Prefix: /usr %description Rolo keeps track of contacts and displays with a text-based menu. It strives to be a well-constructed tool for complementing text-based email programs. It utilizes the vCard version 3.0 format for storing its contacts and interfaces with the end-user through an NCurses front-end. %prep %setup -q %build ./configure --prefix=/usr --mandir=/usr/share/man make %install rm -rf $RPM_BUILD_ROOT make DESTDIR=$RPM_BUILD_ROOT install %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %{_bindir}/* %{_mandir}/man1/* %doc AUTHORS ChangeLog COPYING INSTALL NEWS README THANKS TODO test/contacts.vcf doc/rfc2426.txt rolo-019/src/000077500000000000000000000000001414663705000131355ustar00rootroot00000000000000rolo-019/src/Makefile.am000066400000000000000000000006401414663705000151710ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in ## $Id: Makefile.am,v 1.8 2003/05/20 01:11:55 ahsu Exp $ bin_PROGRAMS = rolo rolo_SOURCES = main.c \ index.c index.h \ view.c view.h \ edit.c edit.h \ help.c help.h \ delete.c delete.h \ add.c add.h \ entry.c entry.h \ search.c search.h rolo-019/src/add.c000066400000000000000000000111441414663705000140320ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include "add.h" #include #include #include #include #include #include #include #include #include #include static void append_to_datafile (const char *datafile, const char *new_entry_filename); static char *basename (const char *path); static const char *editor = NULL; static const char *editor_basename = NULL; /*************************************************************************** */ static void append_to_datafile (const char *datafile, const char *new_entry_filename) { FILE *tfp = NULL; FILE *dfp = NULL; FILE *efp = NULL; char tmp_datafile[PATH_MAX]; int ch = 0; int rc = 0; vc_component *v = NULL; strcpy (tmp_datafile, datafile); strcat (tmp_datafile, ".tmp"); dfp = fopen (datafile, "r"); tfp = fopen (tmp_datafile, "w"); efp = fopen (new_entry_filename, "r"); v = parse_vcard_file (efp); fclose (efp); /* entry file no longer needed */ /* copy the datafile into the temp datafile */ ch = getc (dfp); while (ch != EOF) { putc (ch, tfp); ch = getc (dfp); } fclose (dfp); /* datafile no longer needed */ /* copy the new entry into the temp file */ putc ('\n', tfp); fprintf_vcard (tfp, v); fclose (tfp); /* temp file no longer needed */ /* replace the datafile with the temp datafile */ rename (tmp_datafile, datafile); if (-1 == rc) { fprintf (stderr, "error with rename...\n"); perror ("rolo"); } } /*************************************************************************** */ int add_entry (const char *datafile) { FILE *fp = NULL; int fd; char filename[PATH_MAX] = "/tmp/rolo-XXXXXX"; pid_t process_id = 0; int status = 0; struct stat sb; time_t modified_time = 0; int ret_val = -1; /* open a temp file for editing */ fd = mkstemp (filename); fp = fdopen (fd, "w"); fprintf (fp, "BEGIN:VCARD\n"); fprintf (fp, "VERSION:3.0\n"); fprintf (fp, "FN:\n"); fprintf (fp, "N:;\n"); fprintf (fp, "END:VCARD\n"); fclose (fp); fp = NULL; /* record when the file has been modified */ stat (filename, &sb); modified_time = sb.st_mtime; endwin (); process_id = fork (); if (process_id < 0) { /* could not fork... check errno */ } else if (0 == process_id) { /* child is running */ /* replace process image with the editor */ execlp (editor, editor_basename, filename, NULL); _exit (2); /* execlp failed */ } else { /* parent is running */ waitpid (process_id, &status, 0); } /* check if the temp file has been modified */ stat (filename, &sb); if (modified_time != sb.st_mtime) { /* need to change the datafile */ append_to_datafile (datafile, filename); ret_val = ADD_SUCCESSFUL; } else { ret_val = ADD_ABORTED; } remove (filename); /* put everything back to normal */ refresh (); initscr (); keypad (stdscr, TRUE); /* enable keypad for use of arrow keys */ nonl (); /* tell curses not to do NL->CR/NL on output */ cbreak (); /* take input chars immediately */ noecho (); return ret_val; } /*************************************************************************** */ void set_add_editor (const char *str) { editor = str; editor_basename = basename (editor); } /*************************************************************************** */ static char * basename (const char *path) { char *beginning = NULL; char *retval = NULL; beginning = strrchr (path, '/'); if (NULL == beginning) { retval = strdup (path); } else { retval = strdup (beginning); } return retval; } rolo-019/src/add.h000066400000000000000000000017131414663705000140400ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ enum add_entry_results { ADD_SUCCESSFUL, ADD_ABORTED }; extern void set_add_editor (const char *str); extern int add_entry (const char *datafile); rolo-019/src/delete.c000066400000000000000000000045621414663705000145520ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include "delete.h" #include #include #include #include #include /*************************************************************************** */ int delete_entry (const char *datafile, long pos) { FILE *tfp = NULL; FILE *dfp = NULL; char tmp_datafile[PATH_MAX]; vc_component *v = NULL; int ch = 0; long i = 0; int rc = 0; wmove (stdscr, LINES - 1, 0); wclrtoeol (stdscr); wprintw (stdscr, "Delete selected item? [Y]es [N]o: "); ch = wgetch (stdscr); wmove (stdscr, LINES - 1, 0); wclrtoeol (stdscr); if ('y' != tolower (ch)) { return DELETE_ABORTED; } /* open a temp file for editing */ strcpy (tmp_datafile, datafile); strcat (tmp_datafile, ".tmp"); dfp = fopen (datafile, "r"); tfp = fopen (tmp_datafile, "w"); /* copy the datafile into the temp file but only upto where to change */ i = 0; ch = getc (dfp); while (ch != EOF && i < pos) { putc (ch, tfp); ch = getc (dfp); i++; } fseek (dfp, pos, SEEK_SET); v = parse_vcard_file (dfp); /* copy the rest of the datafile over to the temp file */ ch = getc (dfp); while (ch != EOF) { putc (ch, tfp); ch = getc (dfp); } fclose (dfp); /* datafile no longer needed */ fclose (tfp); /* temp file no longer needed */ /* replace the datafile with the temp datafile */ rename (tmp_datafile, datafile); if (-1 == rc) { fprintf (stderr, "error with rename...\n"); perror ("rolo"); } return DELETE_SUCCESSFUL; } rolo-019/src/delete.h000066400000000000000000000017411414663705000145530ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include #include enum delete_entry_results { DELETE_SUCCESSFUL, DELETE_ABORTED }; extern int delete_entry (const char *datafile, long pos); rolo-019/src/edit.c000066400000000000000000000164011414663705000142300ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include "edit.h" #include #include #include #include #include #include #include #define MENU_BAR_STRING "q:Quit h:Help" /*** PROTOTYPES ***/ static void print_header (); static void print_footer (const char *fn); static char *basename (const char *path); static void update_datafile (const char *datafile, long pos, const char *new_entry_filename); /*** STATIC VARIABLES ***/ static WINDOW *win = NULL; static WINDOW *sub = NULL; static void (*display_help) (void); static const char *editor = NULL; static const char *editor_basename = NULL; /*************************************************************************** */ static void update_datafile (const char *datafile, long pos, const char *new_entry_filename) { FILE *tfp = NULL; FILE *dfp = NULL; FILE *efp = NULL; char tmp_datafile[PATH_MAX]; int ch = 0; long i = 0; int rc = 0; strcpy (tmp_datafile, datafile); strcat (tmp_datafile, ".tmp"); dfp = fopen (datafile, "r"); tfp = fopen (tmp_datafile, "w"); /* copy the datafile into the temp file but only upto where to change */ i = 0; ch = getc (dfp); while (ch != EOF && i < pos) { putc (ch, tfp); ch = getc (dfp); i++; } efp = fopen (new_entry_filename, "r"); /* copy the new entry into the temp file */ putc ('\n', tfp); ch = getc (efp); while (ch != EOF) { putc (ch, tfp); ch = getc (efp); } fclose (efp); /* entry file no longer needed */ /* move to just after the changed entry position */ fseek (dfp, pos, SEEK_SET); parse_vcard_file (dfp); /* copy the rest of the datafile over to the temp file */ ch = getc (dfp); while (ch != EOF) { putc (ch, tfp); ch = getc (dfp); } fclose (dfp); /* datafile no longer needed */ fclose (tfp); /* temp file no longer needed */ /* replace the datafile with the temp datafile */ rename (tmp_datafile, datafile); if (-1 == rc) { fprintf (stderr, "error with rename...\n"); perror ("rolo"); } } /*************************************************************************** */ void init_edit () { editor_basename = basename (editor); win = newwin (0, 0, 0, 0); sub = derwin (win, LINES - 3, COLS, 1, 0); keypad (win, TRUE); /* enable keypad for use of arrow keys */ print_header (); } /*************************************************************************** */ static void print_header () { char *header_str = NULL; int i = 0; header_str = (char *) malloc (sizeof (char) * (COLS + 2)); strncpy (header_str, MENU_BAR_STRING, COLS); for (i = strlen (MENU_BAR_STRING); i < COLS; i++) { header_str[i] = ' '; } header_str[COLS] = '\n'; header_str[COLS + 1] = '\0'; wattron (win, A_REVERSE); wprintw (win, "%s", header_str); wstandend (win); free (header_str); } /*************************************************************************** */ static void print_footer (const char *fn) { char *footer_str = NULL; int i = 0; footer_str = (char *) malloc (sizeof (char) * (COLS + 2)); for (i = 0; i < COLS; i++) { footer_str[i] = '-'; } /* * ("---[ editing: %s ]---\n", fn); */ footer_str[COLS] = '\n'; footer_str[COLS + 1] = '\0'; wattron (win, A_REVERSE); mvwprintw (win, LINES - 2, 0, "%s", footer_str); wstandend (win); free (footer_str); } /*************************************************************************** */ void set_edit_editor (const char *str) { editor = str; } /*************************************************************************** */ static char * basename (const char *path) { char *beginning = NULL; char *retval = NULL; beginning = strrchr (path, '/'); if (NULL == beginning) { retval = strdup (path); } else { retval = strdup (beginning); } return retval; } /*************************************************************************** */ int edit_entry (const char *datafile, long pos) { FILE *fp = NULL; int fd; char filename[PATH_MAX] = "/tmp/rolo-XXXXXX"; pid_t process_id = 0; int status = 0; struct stat sb; time_t modified_time = 0; vc_component *v = NULL; int ret_val = -1; /* retrieve the entry for editing */ fp = fopen (datafile, "r"); fseek (fp, pos, SEEK_SET); v = parse_vcard_file (fp); fclose (fp); fp = NULL; /* open a temp file for editing */ fd = mkstemp (filename); fp = fdopen (fd, "w"); /* dump the entry into the temp file for editing */ fprintf_vcard (fp, v); fclose (fp); fp = NULL; /* record when the file has been modified */ stat (filename, &sb); modified_time = sb.st_mtime; endwin (); process_id = fork (); if (process_id < 0) { /* could not fork... check errno */ } else if (0 == process_id) { /* child is running */ /* replace process image with the editor */ execlp (editor, editor_basename, filename, NULL); _exit (2); /* execlp failed */ } else { /* parent is running */ waitpid (process_id, &status, 0); } /* check if the temp file has been modified */ stat (filename, &sb); if (modified_time != sb.st_mtime) { /* need to change the datafile */ update_datafile (datafile, pos, filename); ret_val = EDIT_SUCCESSFUL; } else { ret_val = EDIT_ABORTED; } remove (filename); /* put everything back to normal */ refresh (); initscr (); keypad (stdscr, TRUE); /* enable keypad for use of arrow keys */ nonl (); /* tell curses not to do NL->CR/NL on output */ cbreak (); /* take input chars immediately */ noecho (); return ret_val; } /*************************************************************************** */ int process_edit_commands () { bool done = FALSE; int ch = 0; int command = 0; while (!done) { ch = wgetch (win); switch (ch) { case 'h': (*display_help) (); touchwin (win); wrefresh (win); wrefresh (sub); break; case 'q': done = TRUE; break; default: beep (); break; } } return command; } /*************************************************************************** */ void set_edit_help_fcn (void (*fcn) (void)) { display_help = fcn; } rolo-019/src/edit.h000066400000000000000000000022371414663705000142370ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include #include enum edit_commands { EDIT_COMMAND_INDEX }; enum edit_entry_results { EDIT_SUCCESSFUL, EDIT_ABORTED }; extern void set_edit_help_fcn (void (*fcn) (void)); extern void set_edit_editor (const char *str); extern void init_edit (); extern int edit_entry (const char *datafile, long pos); extern int process_edit_commands (); rolo-019/src/entry.c000066400000000000000000000315061414663705000144470ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include "entry.h" #include #include #include #include #include #include #include #define MENU_PRINT_FORMAT_SIZE 80 static int cmp_tel (const char *desc_a, const char *desc_b); static int cmp_email (const char *desc_a, const char *desc_b); static int cmp_given_n (const char *desc_a, const char *desc_b); static int cmp_desc_by_tel (const void *a, const void *b); static int cmp_desc_by_email (const void *a, const void *b); static int cmp_desc_by_given_n (const void *a, const void *b); static int cmp_desc_by_family_n (const void *a, const void *b); static char *construct_menu_name (const char *family_name, const char *given_name, const char *email, const char *tel); static void set_menu_print_format (char *menu_print_format, const char* fn, const char* gn, const char* em); /*************************************************************************** */ static int cmp_tel (const char *desc_a, const char *desc_b) { int i = 0; int n = 0; int ret_val = 0; for (i = 57, n = 74; i < n; i++) { if (tolower (desc_a[i]) > tolower (desc_b[i])) { ret_val = 1; break; } else if (tolower (desc_a[i]) < tolower (desc_b[i])) { ret_val = -1; break; } } return ret_val; } /*************************************************************************** */ static int cmp_email (const char *desc_a, const char *desc_b) { int i = 0; int n = 0; int ret_val = 0; for (i = 26, n = 56; i < n; i++) { if (tolower (desc_a[i]) > tolower (desc_b[i])) { ret_val = 1; break; } else if (tolower (desc_a[i]) < tolower (desc_b[i])) { ret_val = -1; break; } } return ret_val; } /*************************************************************************** */ static int cmp_given_n (const char *desc_a, const char *desc_b) { int i = 0; int n = 0; int ret_val = 0; for (i = 13, n = 25; i < n; i++) { if (tolower (desc_a[i]) > tolower (desc_b[i])) { ret_val = 1; break; } else if (tolower (desc_a[i]) < tolower (desc_b[i])) { ret_val = -1; break; } } return ret_val; } /*************************************************************************** */ static int cmp_desc_by_tel (const void *a, const void *b) { int ret_val = 0; entry_node **ena = NULL; entry_node **enb = NULL; ena = (entry_node **) a; enb = (entry_node **) b; ret_val = cmp_tel ((*ena)->description, (*enb)->description); if (0 == ret_val) { ret_val = strcmp ((*ena)->description, (*enb)->description); } return ret_val; } /*************************************************************************** */ static int cmp_desc_by_email (const void *a, const void *b) { int ret_val = 0; entry_node **ena = NULL; entry_node **enb = NULL; ena = (entry_node **) a; enb = (entry_node **) b; ret_val = cmp_email ((*ena)->description, (*enb)->description); if (0 == ret_val) { ret_val = strcmp ((*ena)->description, (*enb)->description); } return ret_val; } /*************************************************************************** */ static int cmp_desc_by_given_n (const void *a, const void *b) { int ret_val = 0; entry_node **ena = NULL; entry_node **enb = NULL; char* ena_desc = NULL; char* enb_desc = NULL; char* pure_a = NULL; char* pure_b = NULL; size_t length[1] = {0}; int a_alloc = 1; int b_alloc = 1; ena = (entry_node **) a; enb = (entry_node **) b; ena_desc = (*ena)->description; enb_desc = (*enb)->description; /* Try to convert the strings from UTF-8 and fall back to the original strings if it fails */ if (unac_string ("UTF-8", ena_desc, strlen (ena_desc), &pure_a, length)) { pure_a = ena_desc; a_alloc = 0; } if (unac_string ("UTF-8", enb_desc, strlen (enb_desc), &pure_b, length)) { pure_b = enb_desc; b_alloc = 0; } ret_val = cmp_given_n (pure_a, pure_b); if (0 == ret_val) { ret_val = strcmp (pure_a, pure_b); } if (a_alloc) free (pure_a); if (b_alloc) free (pure_b); return ret_val; } /*************************************************************************** */ static int cmp_desc_by_family_n (const void *a, const void *b) { int ret_val = 0; entry_node **ena = NULL; entry_node **enb = NULL; char* ena_desc = NULL; char* enb_desc = NULL; char* pure_a = NULL; char* pure_b = NULL; size_t length[1] = {0}; int a_alloc = 1; int b_alloc = 1; ena = (entry_node **) a; enb = (entry_node **) b; ena_desc = (*ena)->description; enb_desc = (*enb)->description; /* Try to convert the strings from UTF-8 and fall back to the original strings if it fails */ if (unac_string ("UTF-8", ena_desc, strlen (ena_desc), &pure_a, length)) { pure_a = ena_desc; a_alloc = 0; } if (unac_string ("UTF-8", enb_desc, strlen (enb_desc), &pure_b, length)) { pure_b = enb_desc; b_alloc = 0; } ret_val = strcmp (pure_a, pure_b); if (a_alloc) free (pure_a); if (b_alloc) free (pure_b); return ret_val; } /*************************************************************************** Sorts the array of entries using the quick sort algorithm. */ void sort_entries (entry_node ** entries, int count, int sort_by) { switch (sort_by) { case SORT_ENTRIES_BY_FAMILY_N: qsort (entries, count, sizeof (entry_node *), cmp_desc_by_family_n); break; case SORT_ENTRIES_BY_GIVEN_N: qsort (entries, count, sizeof (entry_node *), cmp_desc_by_given_n); break; case SORT_ENTRIES_BY_EMAIL: qsort (entries, count, sizeof (entry_node *), cmp_desc_by_email); break; case SORT_ENTRIES_BY_TEL: qsort (entries, count, sizeof (entry_node *), cmp_desc_by_tel); break; default: break; } } /*************************************************************************** Filters the given linked list of entries by keeping only those nodes that match the filter_string. Returns the number of nodes that are left out. */ int filter_entries (entry_node * entries_ll, const char *filter_string) { int count = 0; entry_node *e = NULL; entry_node *prev = NULL; /* first check if there is a filter string */ if (NULL != filter_string) { /* remember: the first node is a dummy node */ prev = entries_ll; e = entries_ll->next; while (e != NULL) { if (NULL == strstr (e->description, filter_string)) { /* must delete node */ prev->next = e->next; free_entry_node (e); e = prev->next; count++; } else { /* skip node, move on */ prev = e; e = e->next; } } } /* the number of deleted nodes */ return count; } /*************************************************************************** */ entry_node ** entries_lltoa (entry_node * entries_ll, int count) { entry_node **entries_a = NULL; entry_node *e = NULL; int i = 0; entries_a = (entry_node **) malloc (sizeof (entry_node *) * count); for (i = 0, e = entries_ll->next; i < count; i++) { entries_a[i] = e; e = e->next; } return entries_a; } /*************************************************************************** */ void free_entries_array_but_leave_data (entry_node ** entries_array, int count) { int i = 0; for (i = 0; i < count; i++) { free (entries_array[i]); } free (entries_array); } /*************************************************************************** Frees an entry node. The user of this function must also remember to set the pointer to NULL after calling this function for cleanliness. */ void free_entry_node (entry_node * e) { if (NULL != e) { free (e->description); free (e->fpos); free (e); } } /*************************************************************************** Allocates memory for an entry node and initialises the pointers in the structure to NULL. */ entry_node * new_entry_node () { entry_node *e = NULL; e = (entry_node *) malloc (sizeof (entry_node)); if (NULL == e) { endwin (); fprintf (stderr, "unable to malloc an entry_node\n"); exit (1); } else { e->description = NULL; e->fpos = NULL; e->next = NULL; } return e; } /*************************************************************************** Parses the data file for entries one at a time and stuffs them into a linked list. */ int get_entries (FILE * fp, entry_node * entries_ll) { int i = 0; vc_component *v = NULL; vc_component *vc = NULL; char *email = NULL; char *tel = NULL; char *family_name = NULL; char *given_name = NULL; char *desc = NULL; int count = 0; entry_node *entry = NULL; fpos_t *fpos = NULL; fpos = (fpos_t *) malloc (sizeof (fpos_t)); fgetpos (fp, fpos); v = parse_vcard_file (fp); while (NULL != v) { count++; entry = new_entry_node (); entry->next = entries_ll->next; entries_ll->next = entry; entry->fpos = fpos; fpos = NULL; /* * retrive the name value */ vc = vc_get_next_by_name (v, VC_NAME); family_name = get_val_struct_part (vc_get_value (vc), N_FAMILY); given_name = get_val_struct_part (vc_get_value (vc), N_GIVEN); /* * retrive the preferred email value */ email = vc_get_preferred_email (v); /* * retrive the preferred telephone value */ tel = vc_get_preferred_tel (v); /* * put them together */ desc = construct_menu_name (family_name, given_name, email, tel); entry->description = desc; /* * cleanup */ free (family_name); free (given_name); family_name = NULL; given_name = NULL; vc_delete_deep (v); v = NULL; fpos = (fpos_t *) malloc (sizeof (fpos_t)); fgetpos (fp, fpos); v = parse_vcard_file (fp); } return count; } /*************************************************************************** Constructs a string containing the description part of a menu_item. The user of this function must remember to free the returned string at some point in the future. */ static char * construct_menu_name (const char *family_name, const char *given_name, const char *email, const char *tel) { char *menu_name = NULL; char menu_print_format[MENU_PRINT_FORMAT_SIZE]; int x = 0; int y = 0; /* FIXME: get the y and x vals from arguments passed to this function so that this module will not need to rely on ncurses.h */ getmaxyx (stdscr, y, x); /* Allow enough room for UTF-8 characters */ menu_name = (char *) malloc (sizeof (char) * 2 * x); set_menu_print_format (menu_print_format, family_name, given_name, email); sprintf (menu_name, menu_print_format, family_name ? family_name : "", given_name ? given_name : "", email ? email : "", tel ? tel : ""); return menu_name; } /*************************************************************************** Sets the print format string given a width. */ static void set_menu_print_format (char *menu_print_format, const char* fn, const char* gn, const char* em) { int fn_len, gn_len, em_len; fn_len = gn_len = 12; em_len = 30; if (fn) fn_len += strlen (fn) - g_utf8_strlen (fn, -1); if (gn) gn_len += strlen (gn) - g_utf8_strlen (gn, -1); if (em) em_len += strlen (em) - g_utf8_strlen (em, -1); snprintf (menu_print_format, MENU_PRINT_FORMAT_SIZE, "%%-%d.%ds %%-%d.%ds %%-%d.%ds %%-18.18s", fn_len, fn_len, gn_len, gn_len, em_len, em_len); /* 75 characters long -- fits into 80 character wide screen */ /* strcpy (menu_print_format, "%-12.12s %-12.12s %-30.30s %-18.18s"); */ } rolo-019/src/entry.h000066400000000000000000000034361414663705000144550ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include /*** STRUCTS ***/ /* FIXME: move this struct to entry.c and abstract out the manipulation of the struct so that the user of this module does not have to know what is inside of the struct */ struct entry_node_tag { char *description; fpos_t *fpos; struct entry_node_tag *next; }; typedef struct entry_node_tag entry_node; enum sort_entries_by { SORT_ENTRIES_BY_FAMILY_N, SORT_ENTRIES_BY_GIVEN_N, SORT_ENTRIES_BY_EMAIL, SORT_ENTRIES_BY_TEL }; extern entry_node **entries_lltoa (entry_node * entries_ll, int count); extern void sort_entries (entry_node ** entries, int count, int sort_by); extern void free_entry_node (entry_node * e); extern int get_entries (FILE * fp, entry_node * entries_ll); extern entry_node *new_entry_node (); extern int filter_entries (entry_node * entries_ll, const char *filter_string); extern void free_entries_array_but_leave_data (entry_node ** entries_array, int count); rolo-019/src/help.c000066400000000000000000000163461414663705000142430ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id: help.c,v 1.13 2003/05/20 01:08:52 ahsu Exp $ */ #include "help.h" #include #include #include #define MENU_BAR_STRING "Press any key to exit this screen" enum help_window { HELP_INDEX, HELP_VIEW, HELP_EDIT }; /*** PROTOTYPES ***/ static void print_header (); static void print_footer (const char *text); static void process_help_commands (); /*** STATIC VARIABLES ***/ static WINDOW *win = NULL; static WINDOW *sub = NULL; /*************************************************************************** */ void init_help () { win = newwin (0, 0, 0, 0); sub = derwin (win, LINES - 3, COLS, 1, 0); /* scrollok (sub, TRUE); */ print_header (); } /*************************************************************************** The help screen for the index. */ void show_index_help () { werase (sub); wprintw (sub, "q quit the program\n"); /* wprintw (sub, " move to the first entry\n"); wprintw (sub, " move to the next entry\n"); wprintw (sub, " move to the previous entry\n"); wprintw (sub, " scroll up a page\n"); wprintw (sub, " scroll down a page\n"); wprintw (sub, " move to the last entry\n"); */ wprintw (sub, " view the details of an entry\n"); wprintw (sub, "g move to the first entry\n"); wprintw (sub, "j move to the next entry\n"); wprintw (sub, "k move to the previous entry\n"); wprintw (sub, "b scroll up a page\n"); wprintw (sub, " scroll down a page\n"); wprintw (sub, "G move to the last entry\n"); wprintw (sub, "v view the details of an entry\n"); /* wprintw (sub, "V view the vCard format of an entry\n"); */ wprintw (sub, "s sort the entries in ascending order\n"); /* wprintw (sub, "S sort the entries in descending order\n"); */ wprintw (sub, "f filter the entries\n"); wprintw (sub, "F remove the filter\n"); wprintw (sub, "/ search the index screen with a given string\n"); wprintw (sub, "n search forwards for the next search result\n"); wprintw (sub, "N search backwards for the next search result\n"); wprintw (sub, "a add a new entry using a text editor\n"); /* wprintw (sub, "a add a new entry using a form\n"); */ wprintw (sub, "e edit an entry\n"); wprintw (sub, "d delete an entry\n"); /* wprintw(sub, "t tag/un-tag an entry\n"); */ /* wprintw(sub, "x export an entry\n"); */ wprintw (sub, "h show help for key bindings (what you are viewing now)\n"); print_footer ("Help for the index screen"); touchwin (win); wrefresh (sub); wrefresh (win); process_help_commands (); } /*************************************************************************** The help screen for viewing entries. */ void show_view_help () { werase (sub); wprintw (sub, "q exit to index screen\n"); wprintw (sub, "i exit to index screen\n"); wprintw (sub, " move to the next entry\n"); wprintw (sub, " move to the previous entry\n"); wprintw (sub, " cycle backwards through the details screen\n"); wprintw (sub, " cycle forwards through the details screen\n"); wprintw (sub, "j move to the next entry\n"); wprintw (sub, "k move to the previous entry\n"); wprintw (sub, "e edit the entry\n"); wprintw (sub, "1 view the identification details\n"); wprintw (sub, "2 view the geographic position details\n"); wprintw (sub, "3 view the telecommunication details\n"); wprintw (sub, "4 view the organization details\n"); wprintw (sub, "5 view the miscellaneous details\n"); wprintw (sub, "h show help for key bindings (what you are viewing now)\n"); print_footer ("Help for the view screen"); touchwin (win); wrefresh (sub); wrefresh (win); process_help_commands (); } /*************************************************************************** The help screen for editing entries. */ void show_edit_help () { werase (sub); wprintw (sub, "This is help documentation for edit."); print_footer ("Help for the edit screen"); touchwin (win); wrefresh (sub); wrefresh (win); process_help_commands (); } /*************************************************************************** Prints the header for the help screen. */ static void print_header () { char *header_str = NULL; int i = 0; header_str = (char *) malloc (sizeof (char) * (COLS + 2)); strncpy (header_str, MENU_BAR_STRING, COLS); for (i = strlen (MENU_BAR_STRING); i < COLS; i++) { header_str[i] = ' '; } header_str[COLS] = '\n'; header_str[COLS + 1] = '\0'; wattron (win, A_REVERSE); wprintw (win, "%s", header_str); wstandend (win); free (header_str); } /*************************************************************************** Prints the footer for the help screen. */ static void print_footer (const char *text) { char *footer_str = NULL; char *help_block = NULL; int help_block_len = 0; int i = 0; footer_str = (char *) malloc (sizeof (char) * (COLS + 2)); for (i = 0; i < COLS; i++) { footer_str[i] = '-'; } if (NULL != text) { help_block_len = strlen (text) + 10; help_block = (char *) malloc (sizeof (char) * (help_block_len + 1)); sprintf (help_block, "---[ %s ]---", text); for (i = 0; i < help_block_len; i++) { footer_str[i] = help_block[i]; } free (help_block); } footer_str[COLS] = '\n'; footer_str[COLS + 1] = '\0'; wattron (win, A_REVERSE); mvwprintw (win, LINES - 2, 0, "%s", footer_str); wstandend (win); free (footer_str); } /*************************************************************************** Processes the help screen input commands. */ static void process_help_commands () { bool done = FALSE; int ch = 0; while (!done) { ch = wgetch (sub); switch (ch) { case 'j': /* wscrl (sub, 1); */ wrefresh (sub); break; case 'k': /* wscrl (sub, -1); */ wrefresh (sub); break; case 'q': done = TRUE; break; default: done = TRUE; break; } } } rolo-019/src/help.h000066400000000000000000000017051414663705000142410ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include extern void init_help (); extern void show_view_help (); extern void show_edit_help (); extern void show_index_help (); rolo-019/src/index.c000066400000000000000000000414771414663705000144250ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id: index.c,v 1.19 2003/05/22 08:37:34 ahsu Exp $ */ #include "entry.h" #include "index.h" #include "search.h" #include #include #include #include #include #define MENU_BAR_STRING "q:Quit v:View e:Edit a:Add d:Delete h:Help" #ifndef CTRL #define CTRL(x) ((x) & 0x1f) #endif /*** STATIC PROTOTYPES ***/ static void print_footer (const char *filename, int entries); static void print_header (); static void index_search (); static void index_search_next (); static void index_search_prev (); static ITEM **get_items (entry_node ** entries, int count); static void filter_menu (); static void unfilter_menu (); static void sort_ascending (int sort_by); static void sort_descending (int sort_by); static int scroll_to_result (ITEM * found_item); static void clear_message_bar (MENU * m); /*** STATIC VARIABLES ***/ static void (*display_help) (void); static MENU *menu = NULL; static WINDOW *win = NULL; static WINDOW *sub = NULL; static const char *datafile = NULL; static char *filter_string = NULL; static ITEM **items = NULL; static int g_sort_by = -1; /*************************************************************************** */ void finish_index () { unpost_menu (menu); free_menu (menu); menu = NULL; free_items (items); items = NULL; } /*************************************************************************** Initializes the index window by openning the data file, populating the menu items, and setting up the header and footer. */ void init_index (const char *filename) { int count = 0; int deleted = 0; int rows = 0; int cols = 0; FILE *fp = NULL; entry_node *entries_ll = NULL; entry_node **entries_array = NULL; /* have to get the win and sub pointers setup early */ win = stdscr; scale_menu (menu, &rows, &cols); /* get the size required for menu */ sub = derwin (win, rows, cols, 1, 0); /* remember: first node is a dummy node */ entries_ll = new_entry_node (); datafile = filename; fp = fopen (datafile, "r"); if (NULL == fp) { endwin (); /* exit gracefully */ fprintf (stderr, "unable to open file: %s\n", filename); exit (1); } count = count_vcards (fp); rewind (fp); /* this should get a linked list */ count = get_entries (fp, entries_ll); fclose (fp); /* this should reduce the linked list if need be */ deleted = filter_entries (entries_ll, filter_string); count -= deleted; /* index the linked list in an array */ entries_array = entries_lltoa (entries_ll, count); free_entry_node (entries_ll); entries_ll = NULL; /* use the array to sort */ if (-1 == g_sort_by) { g_sort_by = SORT_ENTRIES_BY_FAMILY_N; } sort_entries (entries_array, count, g_sort_by); /* construct the items array and cleanup */ items = get_items (entries_array, count); free_entries_array_but_leave_data (entries_array, count); entries_array = NULL; menu = get_menu (items); /* set the menu hook to clear the message bar */ set_item_init (menu, clear_message_bar); /* initialize the menu_userptr to NULL (to be used as search string) */ set_menu_userptr (menu, NULL); print_header (); print_footer (filename, count); set_menu_win (menu, win); set_menu_sub (menu, sub); post_menu (menu); } /*************************************************************************** */ static ITEM ** get_items (entry_node ** entries, int count) { int i = 0; ITEM **items; char *line_number = NULL; items = (ITEM **) malloc (sizeof (ITEM *) * (count + 1)); for (i = 0; i < count; i++) { line_number = (char *) malloc (sizeof (char) * 4); sprintf (line_number, "%3i", (i + 1) % 1000); items[i] = new_item (line_number, (entries[i])->description); set_item_userptr (items[i], (entries[i])->fpos); } items[i] = (ITEM *) NULL; return items; } /*************************************************************************** Cleans up the two-dimensional array of items. */ void free_items (ITEM ** items) { char *name = NULL; char *description = NULL; fpos_t *fpos = NULL; int i = 0; while ((ITEM *) NULL != items[i]) { name = (char *) item_name (items[i]); free (name); description = (char *) item_description (items[i]); free (description); fpos = (fpos_t *) item_userptr (items[i]); free (fpos); free_item (items[i]); i++; } free (items); } /*************************************************************************** Sets up a new menu. */ MENU * get_menu (ITEM ** items) { MENU *menu = NULL; int x = 0; int y = 0; getmaxyx (win, y, x); menu = new_menu (items); set_menu_format (menu, y - 3, 1); /* LINE rows, 1 column */ return menu; } /*************************************************************************** Displays the header for the index window. */ static void print_header () { char *header_str = NULL; int i = 0; int x = 0; int y = 0; getmaxyx (win, y, x); header_str = (char *) malloc (sizeof (char) * (x + 1)); strncpy (header_str, MENU_BAR_STRING, x); for (i = strlen (MENU_BAR_STRING); i < x; i++) { header_str[i] = ' '; } header_str[x] = '\0'; wattron (win, A_REVERSE); mvwprintw (win, 0, 0, "%s", header_str); wstandend (win); free (header_str); } /*************************************************************************** Displays a footer that will adjust its contents based on the width of the screen. */ static void print_footer (const char *filename, int entries) { char *footer_str = NULL; char *rolo_block = NULL; int rolo_block_len = 0; char *entries_block = NULL; int entries_block_len = 0; int i = 0; int j = 0; int x = 0; int y = 0; getmaxyx (win, y, x); footer_str = (char *) malloc (sizeof (char) * (x + 1)); /* * set a default footer of all dashes */ for (i = 0; i < x; i++) { footer_str[i] = '-'; } rolo_block_len = strlen (filename) + 16; entries_block_len = 23; /* * add the `rolo' block only if there is enough room */ if (rolo_block_len + entries_block_len <= x) { rolo_block = (char *) malloc (sizeof (char) * (rolo_block_len + 1)); sprintf (rolo_block, "---[ rolo: %s ]---", filename); for (i = 0; i < rolo_block_len; i++) { footer_str[i] = rolo_block[i]; } free (rolo_block); } /* * add the `entries' block only if there is enough room */ if (entries_block_len <= x) { entries_block = (char *) malloc (sizeof (char) * (entries_block_len + 1)); sprintf (entries_block, "---[ entries: %i ]---", entries % 1000); entries_block_len = strlen (entries_block); for (i = x - entries_block_len, j = 0; j < entries_block_len; i++, j++) { footer_str[i] = entries_block[j]; } free (entries_block); } footer_str[x] = '\0'; wattron (win, A_REVERSE); mvwprintw (win, LINES - 2, 0, "%s", footer_str); wstandend (win); free (footer_str); } /*************************************************************************** Display the index to the end-user. */ void display_index () { redrawwin (win); wrefresh (win); } /*************************************************************************** Handle input from the end-user. */ int process_index_commands () { bool done = FALSE; int return_command = 0; int ch = 0; while (!done) { ch = wgetch (win); switch (ch) { case KEY_NPAGE: case ' ': case KEY_C3: menu_driver (menu, REQ_SCR_DPAGE); break; case '/': index_search (); break; case 'a': return_command = INDEX_COMMAND_ADD; clear_message_bar (menu); done = TRUE; break; case KEY_PPAGE: case 'b': case KEY_A3: menu_driver (menu, REQ_SCR_UPAGE); break; case 'd': return_command = INDEX_COMMAND_DELETE; clear_message_bar (menu); done = TRUE; break; case 'e': return_command = INDEX_COMMAND_EDIT; clear_message_bar (menu); done = TRUE; break; case 'f': filter_menu (); break; case 'F': unfilter_menu (); break; case KEY_HOME: case 'g': case KEY_A1: menu_driver (menu, REQ_FIRST_ITEM); break; case KEY_END: case 'G': case KEY_C1: menu_driver (menu, REQ_LAST_ITEM); break; case 'h': (*display_help) (); touchwin (win); wrefresh (win); wrefresh (sub); clear_message_bar (menu); break; case KEY_DOWN: case 'j': menu_driver (menu, REQ_NEXT_ITEM); break; case KEY_UP: case 'k': menu_driver (menu, REQ_PREV_ITEM); break; case 'n': index_search_next (); break; case 'N': index_search_prev (); break; case 'q': clear_message_bar (menu); return_command = INDEX_COMMAND_QUIT; done = TRUE; break; case 's': sort_ascending (SORT_ENTRIES_BY_FAMILY_N); break; case 'S': sort_descending (SORT_ENTRIES_BY_FAMILY_N); break; case 't': menu_driver (menu, REQ_TOGGLE_ITEM); clear_message_bar (menu); break; case KEY_ENTER: case 13: case 'v': return_command = INDEX_COMMAND_VIEW; clear_message_bar (menu); done = TRUE; break; case 'V': return_command = INDEX_COMMAND_RAW_VIEW; clear_message_bar (menu); done = TRUE; break; default: beep (); break; } } return return_command; } /*************************************************************************** */ void select_next_item () { menu_driver (menu, REQ_NEXT_ITEM); } /*************************************************************************** */ void select_previous_item () { menu_driver (menu, REQ_PREV_ITEM); } /*************************************************************************** */ ITEM * get_current_item () { return current_item (menu); } /*************************************************************************** */ int get_entry_number (const ITEM * item) { return (1 + item_index (item)); } /*************************************************************************** */ void set_index_help_fcn (void (*fcn) (void)) { display_help = fcn; } /*************************************************************************** */ static void sort_ascending (int sort_by) { int ch = 0; wmove (win, LINES - 1, 0); wclrtoeol (win); wprintw (win, "Sort ascending by [F]amily Name, [G]iven Name, [E]mail, [T]el: "); ch = wgetch (win); wmove (win, LINES - 1, 0); wclrtoeol (win); switch (tolower (ch)) { case 'f': g_sort_by = SORT_ENTRIES_BY_FAMILY_N; break; case 'g': g_sort_by = SORT_ENTRIES_BY_GIVEN_N; break; case 'e': g_sort_by = SORT_ENTRIES_BY_EMAIL; break; case 't': g_sort_by = SORT_ENTRIES_BY_TEL; break; default: return; break; } finish_index (); init_index (datafile); display_index (); } /*************************************************************************** */ static void sort_descending (int sort_by) { int ch = 0; wmove (win, LINES - 1, 0); wclrtoeol (win); wprintw (win, "Sort descending by [F]amily Name, [G]iven Name, [E]mail, [T]el: "); ch = wgetch (win); wmove (win, LINES - 1, 0); wclrtoeol (win); switch (tolower (ch)) { case 'f': g_sort_by = SORT_ENTRIES_BY_FAMILY_N; break; case 'g': g_sort_by = SORT_ENTRIES_BY_GIVEN_N; break; case 'e': g_sort_by = SORT_ENTRIES_BY_EMAIL; break; case 't': g_sort_by = SORT_ENTRIES_BY_TEL; break; default: return; break; } finish_index (); init_index (datafile); display_index (); } /*************************************************************************** */ void refresh_index () { int count = 0; int current_index = 0; ITEM *item = NULL; ITEM **items = NULL; item = current_item (menu); if (NULL == item) { finish_index (); init_index (datafile); display_index (); return; } current_index = item_index (item); finish_index (); init_index (datafile); display_index (); count = item_count (menu); items = menu_items (menu); current_index = current_index >= count ? count : current_index; if (items != NULL) set_current_item (menu, items[current_index]); } /*************************************************************************** */ static void unfilter_menu () { if (NULL != filter_string) { free (filter_string); } filter_string = NULL; finish_index (); init_index (datafile); display_index (); } /*************************************************************************** */ static void filter_menu () { char f_string[80]; ITEM *found_item = NULL; wmove (win, LINES - 1, 0); wclrtoeol (win); wprintw (win, "Filter: "); nocbreak (); echo (); wscanw (win, "%s", f_string); cbreak (); noecho (); wmove (win, LINES - 1, 0); wclrtoeol (win); if (NULL != filter_string) { free (filter_string); } filter_string = strdup (f_string); finish_index (); init_index (datafile); display_index (); } /*************************************************************************** Search for the entered search string in the index index screen. This will move the cursor and print a status message line at the bottom of the screen. */ static void index_search () { char search_string[80]; wmove (win, LINES - 1, 0); wclrtoeol (win); wprintw (win, "Search for: "); nocbreak (); echo (); wscanw (win, "%s", search_string); cbreak (); noecho (); set_menu_search_string (menu, search_string); index_search_next (); } /*************************************************************************** */ static int scroll_to_result (ITEM * found_item) { int direction = 0; if (NULL != found_item) { int current_index = -1; int found_index = -1; current_index = item_index (current_item (menu)); found_index = item_index (found_item); direction = found_index > current_index ? REQ_SCR_DPAGE : REQ_SCR_UPAGE; while (FALSE == item_visible (found_item)) { menu_driver (menu, direction); } set_current_item (menu, found_item); } return direction; } /*************************************************************************** */ static void clear_message_bar (MENU * m) { WINDOW *w = NULL; w = menu_win (m); wmove (w, LINES - 1, 0); wclrtoeol (w); } /*************************************************************************** */ static void index_search_next () { ITEM *found_item = NULL; int direction = 0; found_item = search_menu (menu, REQ_SCR_DPAGE); direction = scroll_to_result (found_item); switch (direction) { case 0: wmove (win, LINES - 1, 0); wclrtoeol (win); mvwprintw (win, LINES - 1, 0, "Not found."); beep (); break; case REQ_SCR_UPAGE: mvwprintw (win, LINES - 1, 0, "Search wrapped to top."); break; default: break; } } /*************************************************************************** */ static void index_search_prev () { ITEM *found_item = NULL; int direction = 0; found_item = search_menu (menu, REQ_SCR_UPAGE); direction = scroll_to_result (found_item); switch (direction) { case 0: wmove (win, LINES - 1, 0); wclrtoeol (win); mvwprintw (win, LINES - 1, 0, "Not found."); beep (); break; case REQ_SCR_DPAGE: mvwprintw (win, LINES - 1, 0, "Search wrapped to bottom."); break; default: break; } } rolo-019/src/index.h000066400000000000000000000027021414663705000144160ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include enum index_commands { INDEX_COMMAND_VIEW, INDEX_COMMAND_RAW_VIEW, INDEX_COMMAND_EDIT, INDEX_COMMAND_ADD, INDEX_COMMAND_DELETE, INDEX_COMMAND_QUIT }; /*** PROTOTYPES ***/ extern void init_index (const char *dirpath); extern MENU *get_menu (ITEM ** items); extern void display_index (); extern int process_index_commands (); extern void free_items (ITEM ** items); extern void select_next_item (); extern void select_previous_item (); extern ITEM *get_current_item (); extern int get_entry_number (const ITEM * item); extern void set_index_help_fcn (void (*fcn) (void)); extern void finish_index (); extern void refresh_index (); rolo-019/src/main.c000066400000000000000000000340411414663705000142270ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include #include "add.h" #include "view.h" #include "delete.h" #include "edit.h" #include "index.h" #include "help.h" #include #include #include #include #include #include #include #include #include #include #include #include #if HAVE_CONFIG_H #include "config.h" #else #define PACKAGE_STRING "rolo" #endif #define DEFAULT_HOME_ROLO_DIR ".rolo" #define DEFAULT_FILENAME "contacts.vcf" /*** GLOBALS ***/ enum win_states { WINDOW_INDEX, WINDOW_VIEW, WINDOW_RAW_VIEW, WINDOW_EDIT, WINDOW_DELETE, WINDOW_ADD }; char data_path[PATH_MAX]; /*** PROTOTYPES ***/ static void finish (int sig); static void resize (int sig); static void set_defaults (); static void process_command_line_args (int argc, char *const *argv); static void display_usage (const char *prog_name); static void display_version (); static void set_contacts_file (); static void display_license (); static char *get_env_editor (); /*************************************************************************** Gets the editor to invoke from the environment settings. If none of the environment settings are set, then the default value of `vi' will be returned. The user of this function must remember to free the returned string. */ static char * get_env_editor () { char *editor = NULL; editor = getenv ("ROLO_EDITOR"); if (NULL == editor) { editor = getenv ("EDITOR"); if (NULL == editor) { editor = strdup ("/usr/bin/editor"); return editor; } } return strdup (editor); } /*************************************************************************** This is called upon when the window is resized. */ static void resize (int sig) { finish_index (); endwin (); refresh (); initscr (); keypad (stdscr, TRUE); /* enable keypad for use of arrow keys */ nonl (); /* tell curses not to do NL->CR/NL on output */ cbreak (); /* take input chars immediately */ noecho (); init_index (data_path); display_index (); refresh (); } /*************************************************************************** This is called upon when the program is asked to finish. */ static void finish (int sig) { finish_index (); endwin (); exit (0); } /*************************************************************************** Sets the default program startup values. */ static void set_defaults () { char default_datafile[PATH_MAX]; char *home = NULL; char *editor = NULL; if (strlen (data_path) == 0) { home = getenv ("HOME"); if (NULL != home) { int result = 1; struct stat sb; strcpy (default_datafile, home); result = stat (default_datafile, &sb); if (-1 == result) { fprintf (stderr, "home directory unavailable\n"); exit (1); } strncat (default_datafile, "/", 1); strncat (default_datafile, DEFAULT_HOME_ROLO_DIR, strlen (DEFAULT_HOME_ROLO_DIR)); result = stat (default_datafile, &sb); if (-1 == result) { if (ENOENT == errno) { mkdir (default_datafile, S_IRWXU); } else { exit (1); } } strncat (default_datafile, "/", 1); strncat (default_datafile, DEFAULT_FILENAME, strlen (DEFAULT_FILENAME)); result = stat (default_datafile, &sb); if (-1 == result) { if (ENOENT == errno) { FILE *fp; fp = fopen (default_datafile, "w"); if (NULL == fp) { fprintf (stderr, "unable to open file %s\n", default_datafile); exit (1); } fclose (fp); } else { exit (1); } } } else { fprintf (stderr, "unable to deterime home directory"); exit (1); } strcpy (data_path, default_datafile); } editor = get_env_editor (); set_edit_editor (editor); set_add_editor (editor); } /*************************************************************************** Ouputs how to use the program. */ static void display_usage (const char *prog_name) { printf ("usage: %s [-r] [-f ]\n", prog_name); printf (" %s -v\n", prog_name); printf (" %s -V\n", prog_name); printf (" %s -h\n", prog_name); printf ("options:\n"); printf (" -r open the contact file as read-only\n"); printf (" -f specify a contact file to use\n"); printf (" -v display version\n"); printf (" -V display copyright and license\n"); printf (" -h this help message\n"); } /*************************************************************************** Outputs a one-line version statement. */ static void display_version () { printf ("%s\n", PACKAGE_STRING); } /*************************************************************************** Outputs the software license. */ static void display_license () { printf ("rolo - contact management software\n"); printf ("Copyright (C) 2003 Andrew Hsu\n"); printf ("Copyright (C) 2017, 2019, 2021 Rafael Laboissière\n"); printf ("\n"); printf ("This program is free software;"); printf (" you can redistribute it and/or modify\n"); printf ("it under the terms of the"); printf (" GNU General Public License as published by\n"); printf ("the Free Software Foundation;"); printf (" either version 2 of the License, or\n"); printf ("(at your option) any later version.\n"); printf ("\n"); printf ("This program is distributed"); printf (" in the hope that it will be useful,\n"); printf ("but WITHOUT ANY WARRANTY;"); printf (" without even the implied warranty of\n"); printf ("MERCHANTABILITY or FITNESS FOR A PARTICULAR"); printf (" PURPOSE. See the\n"); printf ("GNU General Public License for more details.\n"); printf ("\n"); printf ("You should have received a copy of"); printf (" the GNU General Public License\n"); printf ("along with this program;"); printf (" if not, write to the Free Software\n"); printf ("Foundation, Inc., 59 Temple Place, Suite 330,"); printf (" Boston, MA 02111-1307 USA\n"); } /*************************************************************************** Helper function for setting the contact file. */ static void set_contacts_file () { strncpy (data_path, optarg, PATH_MAX); data_path[PATH_MAX - 1] = '\0'; } /*************************************************************************** Parses the command-line arguments. */ static void process_command_line_args (int argc, char *const *argv) { int ch = -1; data_path [0] = '\0'; while (-1 != (ch = getopt (argc, argv, "rf:vVh"))) { switch (ch) { case 'r': /* FIXME: implement read-only option */ break; case 'f': set_contacts_file (); break; case 'v': display_version (); exit (0); break; case 'V': display_license (); exit (0); break; case 'h': case '?': default: display_usage (argv[0]); exit (0); } } } /*************************************************************************** The main function. */ int main (int argc, char *argv[]) { vc_component *v = NULL; fpos_t *fpos = NULL; long pos = 0; FILE *fp = NULL; ITEM *it = NULL; int entry_number = 0; bool done = FALSE; int win_state = WINDOW_INDEX; int command = 0; process_command_line_args (argc, argv); set_defaults (); /* * process_environment_variables(); * process_configuration_file(); */ signal (SIGINT, finish); /* catch interrupt for exiting */ signal (SIGWINCH, resize); /* catch interrupt for resizing */ setlocale (LC_ALL, ""); initscr (); keypad (stdscr, TRUE); /* enable keypad for use of arrow keys */ nonl (); /* tell curses not to do NL->CR/NL on output */ cbreak (); /* take input chars immediately */ noecho (); init_index (data_path); set_index_help_fcn (show_index_help); init_view (); set_view_help_fcn (show_view_help); init_edit (); set_edit_help_fcn (show_edit_help); init_help (); while (!done) { switch (win_state) { case WINDOW_INDEX: /*------------------- display the index -------------------*/ display_index (); command = process_index_commands (); switch (command) { case INDEX_COMMAND_VIEW: win_state = WINDOW_VIEW; break; case INDEX_COMMAND_RAW_VIEW: win_state = WINDOW_RAW_VIEW; break; case INDEX_COMMAND_EDIT: win_state = WINDOW_EDIT; break; case INDEX_COMMAND_ADD: win_state = WINDOW_ADD; break; case INDEX_COMMAND_DELETE: win_state = WINDOW_DELETE; break; case INDEX_COMMAND_QUIT: done = TRUE; break; default: break; } break; case WINDOW_RAW_VIEW: /*------------------------------------------------- view the currently selected item with the pager -------------------------------------------------*/ it = get_current_item (); /* only display if there is an item that is selected */ if (NULL == it) { v = NULL; } else { fpos = (fpos_t *) item_userptr (it); fp = fopen (data_path, "r"); fsetpos (fp, fpos); v = parse_vcard_file (fp); fclose (fp); } if (v != NULL) { raw_view (v); vc_delete_deep (v); v = NULL; } win_state = WINDOW_INDEX; break; case WINDOW_VIEW: /*---------------------------------- view the currently selected item ----------------------------------*/ it = get_current_item (); /* only display if there is an item that is selected */ if (NULL == it) { v = NULL; } else { fpos = (fpos_t *) item_userptr (it); fp = fopen (data_path, "r"); fsetpos (fp, fpos); v = parse_vcard_file (fp); fclose (fp); } if (v != NULL) { entry_number = get_entry_number (it); view_vcard (entry_number, v); command = process_view_commands (); switch (command) { case VIEW_COMMAND_EDIT: win_state = WINDOW_EDIT; break; case VIEW_COMMAND_INDEX: win_state = WINDOW_INDEX; break; case VIEW_COMMAND_PREVIOUS: select_previous_item (); win_state = WINDOW_VIEW; break; case VIEW_COMMAND_NEXT: select_next_item (); win_state = WINDOW_VIEW; break; default: break; } } else { win_state = WINDOW_INDEX; } vc_delete_deep (v); v = NULL; break; case WINDOW_EDIT: /*-------------- edit a vcard --------------*/ it = get_current_item (); /* only display if there is an item that is selected */ if (NULL != it) { fpos = (fpos_t *) item_userptr (it); fp = fopen (data_path, "r"); fsetpos (fp, fpos); pos = ftell (fp); fclose (fp); fp = NULL; if (EDIT_SUCCESSFUL == edit_entry (data_path, pos)) { refresh_index (); } } win_state = WINDOW_INDEX; break; case WINDOW_ADD: if (ADD_SUCCESSFUL == add_entry (data_path)) { refresh_index (); } win_state = WINDOW_INDEX; break; case WINDOW_DELETE: it = get_current_item (); /* only delete if there is an item that is selected */ if (NULL != it) { fpos = (fpos_t *) item_userptr (it); fp = fopen (data_path, "r"); fsetpos (fp, fpos); pos = ftell (fp); fclose (fp); fp = NULL; if (DELETE_SUCCESSFUL == delete_entry (data_path, pos)) { refresh_index (); } } win_state = WINDOW_INDEX; break; default: break; } } finish (0); exit (EXIT_SUCCESS); return (0); } rolo-019/src/search.c000066400000000000000000000125031414663705000145470ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id: search.c,v 1.5 2003/05/22 05:04:54 ahsu Exp $ */ #include "search.h" #include #include #include static int strstr_nocase (const char *haystack, const char *needle); static ITEM *search_menu_forwards (MENU * menu); static ITEM *search_menu_backwards (MENU * menu); /*************************************************************************** Searches for the needle in the haystack without worrying about the case. Returns 1 if found, 0 otherwise. */ static int strstr_nocase (const char *haystack, const char *needle) { int result = 0; if (NULL != haystack && NULL != needle) { char tmp_haystack[80]; char tmp_needle[80]; int len = 0; int i = 0; strncpy (tmp_haystack, haystack, sizeof (tmp_haystack) - 1); tmp_haystack[sizeof (tmp_haystack) - 1] = '\0'; strncpy (tmp_needle, needle, sizeof (tmp_needle) - 1); tmp_needle[sizeof (tmp_haystack) - 1] = '\0'; len = strlen (tmp_haystack); for (i = 0; i < len; i++) { tmp_haystack[i] = tolower (tmp_haystack[i]); } len = strlen (tmp_needle); for (i = 0; i < len; i++) { tmp_needle[i] = tolower (tmp_needle[i]); } if (NULL != strstr (tmp_haystack, tmp_needle)) { result = 1; } } return result; } /*************************************************************************** */ void set_menu_search_string (MENU * menu, const char *search_string) { void *userptr = NULL; userptr = menu_userptr (menu); if (NULL != userptr) { free (userptr); } if (NULL == search_string) { set_menu_userptr (menu, NULL); } else { set_menu_userptr (menu, strdup (search_string)); } } /*************************************************************************** Perform the search for an item using the stored search string in the user_ptr. */ ITEM * search_menu (MENU * menu, int initial_direction) { ITEM *result_item = NULL; switch (initial_direction) { case REQ_SCR_DPAGE: result_item = search_menu_forwards (menu); break; case REQ_SCR_UPAGE: result_item = search_menu_backwards (menu); break; default: break; } return result_item; } static ITEM * search_menu_forwards (MENU * menu) { char *search_string = NULL; ITEM *result_item = NULL; /* the search string is stored in the menu user pointer */ search_string = (char *) menu_userptr (menu); if (NULL != search_string) { int i = -1; int current_index = -1; int count = -1; ITEM **items = NULL; int found = 0; bool done = FALSE; current_index = item_index (current_item (menu)); count = item_count (menu); items = menu_items (menu); /* start search from the item immediately after the current item */ for (i = current_index + 1; i < count && !found; i++) { found = strstr_nocase (item_description (items[i]), search_string); } if (!found) { /* start search from the beginning (i.e. wrap around) */ for (i = 0; i <= current_index && !found; i++) { found = strstr_nocase (item_description (items[i]), search_string); } } if (found) { result_item = items[i - 1]; } } return result_item; } static ITEM * search_menu_backwards (MENU * menu) { char *search_string = NULL; ITEM *result_item = NULL; /* the search string is stored in the menu user pointer */ search_string = (char *) menu_userptr (menu); if (NULL != search_string) { int i = -1; int current_index = -1; ITEM **items = NULL; int found = 0; bool done = FALSE; current_index = item_index (current_item (menu)); items = menu_items (menu); /* start search from the item immediately before the current item */ for (i = current_index - 1; i >= 0 && !found; i--) { found = strstr_nocase (item_description (items[i]), search_string); } if (!found) { int count = -1; count = item_count (menu); /* start search from the end (i.e. wrap around) */ for (i = count - 1; i >= current_index && !found; i--) { found = strstr_nocase (item_description (items[i]), search_string); } } if (found) { result_item = items[i + 1]; } } return result_item; } rolo-019/src/search.h000066400000000000000000000020041414663705000145470ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id: search.h,v 1.2 2003/05/22 05:04:54 ahsu Exp $ */ #include extern void set_menu_search_string (MENU * menu, const char *search_string); extern ITEM *search_menu (MENU * menu, int initial_direction); rolo-019/src/view.c000066400000000000000000000413341414663705000142600ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include "view.h" #include #include #include #include #include #include #include #define MENU_BAR_STRING "i:Index h:Help 1:Ident 2:Geo 3:Tel 4:Org 5:Misc" #define HEADING_IDENT_STRING "IDENTIFICATION" #define HEADING_GEO_STRING "GEOGRAPHIC POSITION" #define HEADING_TEL_STRING "TELECOMMUNICATION" #define HEADING_ORG_STRING "ORGANIZATION" #define HEADING_MISC_STRING "MISCELLANEOUS" /*** PROTOTYPES ***/ static void print_header (); static void print_footer (int entry_number, const char *fn); static void view_ident (); static void view_geo (); static void view_tel (); static void view_org (); static void view_misc (); static char *basename (const char *path); static void view_left (); static void view_right (); enum view_modes { VIEW_IDENT = 1, VIEW_GEO, VIEW_TEL, VIEW_ORG, VIEW_MISC }; /*** STATIC VARIABLES ***/ static WINDOW *win = NULL; static WINDOW *sub = NULL; static void (*display_help) (void); static vc_component *g_v = NULL; static int g_mode = 1; /*************************************************************************** */ static void view_left () { switch (g_mode) { case VIEW_IDENT: view_misc (); break; case VIEW_GEO: view_ident (); break; case VIEW_TEL: view_geo (); break; case VIEW_ORG: view_tel (); break; case VIEW_MISC: view_org (); break; default: break; } } /*************************************************************************** */ static void view_right () { switch (g_mode) { case VIEW_IDENT: view_geo (); break; case VIEW_GEO: view_tel (); break; case VIEW_TEL: view_org (); break; case VIEW_ORG: view_misc (); break; case VIEW_MISC: view_ident (); break; default: break; } } /*************************************************************************** Initialize the view window without displaying it to the end-user. */ void init_view () { win = newwin (0, 0, 0, 0); sub = derwin (win, LINES - 3, COLS, 1, 0); print_header (); keypad (win, TRUE); /* enable keypad for use of arrow keys */ } /*************************************************************************** */ static char * basename (const char *path) { char *beginning = NULL; char *retval = NULL; beginning = strrchr (path, '/'); if (NULL == beginning) { retval = strdup (path); } else { retval = strdup (beginning); } return retval; } /*************************************************************************** */ static void view_ident () { vc_component *vc = NULL; char *val = NULL; int x = 0; int y = 0; g_mode = VIEW_IDENT; werase (sub); x = (COLS - strlen (HEADING_IDENT_STRING)) / 2; y = 1; wattron (sub, A_UNDERLINE); mvwprintw (sub, y, x, HEADING_IDENT_STRING); wstandend (sub); wmove (sub, 3, 0); vc = vc_get_next_by_name (g_v, VC_FORMATTED_NAME); val = vc_get_value (vc); wprintw (sub, "Name : %s\n", val ? val : ""); vc = vc_get_next_by_name (g_v, VC_NICKNAME); val = vc_get_value (vc); wprintw (sub, "Nickname : %s\n", val ? val : ""); vc = vc_get_next_by_name (g_v, VC_BIRTHDAY); val = vc_get_value (vc); wprintw (sub, "Birthday : %s\n", val ? val : ""); wprintw (sub, "\n"); vc = vc_get_next_by_name (g_v, VC_URL); val = vc_get_value (vc); wprintw (sub, "URL : %s\n", val ? val : ""); vc = vc_get_next_by_name (g_v, VC_PHOTO); val = vc_get_value (vc); wprintw (sub, "Photo : %s\n", val ? val : ""); vc = vc_get_next_by_name (g_v, VC_SOUND); val = vc_get_value (vc); wprintw (sub, "Sound : %s\n", val ? val : ""); wprintw (sub, "\n"); vc = vc_get_next_by_name (g_v, VC_CATEGORIES); val = vc_get_value (vc); wprintw (sub, "Categories : %s\n", val ? val : ""); vc = vc_get_next_by_name (g_v, VC_REVISION); val = vc_get_value (vc); wprintw (sub, "Revision : %s\n", val ? val : ""); vc = g_v; do { vc = vc_get_next_by_name (vc, VC_NOTE); val = vc_get_value (vc); wprintw (sub, "Note : %s\n", val ? val : ""); } while (val); touchwin (win); wrefresh (sub); wrefresh (win); } /*************************************************************************** */ static void view_geo () { vc_component *vc = NULL; vc_component_param *vcp = NULL; char *type = NULL; char *str = NULL; char *val = NULL; int x = 0; int y = 0; g_mode = VIEW_GEO; werase (sub); x = (COLS - strlen (HEADING_GEO_STRING)) / 2; y = 1; wattron (sub, A_UNDERLINE); mvwprintw (sub, y, x, HEADING_GEO_STRING); wstandend (sub); wmove (sub, 3, 0); vc = vc_get_next_by_name (g_v, VC_GEOGRAPHIC_POSITION); val = vc_get_value (vc); str = get_val_struct_part (val, GEO_LATITUDE); wprintw (sub, "Latitude : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, GEO_LONGITUDE); wprintw (sub, "Longitude : %s\n", str ? str : ""); free (str); wprintw (sub, "\n"); vc = vc_get_next_by_name (g_v, VC_TIME_ZONE); val = vc_get_value (vc); wprintw (sub, "Time Zone : %s\n", val ? val : ""); wprintw (sub, "\n"); vc = g_v; while (vc = vc_get_next_by_name (vc, VC_ADDRESS)) { vcp = vc ? vc_param_get_by_name (vc_get_param (vc), "type") : NULL; type = vcp ? vc_param_get_value (vcp) : NULL; wprintw (sub, type ? "[%s]\n" : "%s", type ? type : ""); val = vc_get_value (vc); str = get_val_struct_part (val, ADR_PO_BOX); wprintw (sub, "Post Office Box : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, ADR_EXT_ADDRESS); wprintw (sub, "Extended Address : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, ADR_STREET); wprintw (sub, "Street Address : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, ADR_LOCALITY); wprintw (sub, "Locality : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, ADR_REGION); wprintw (sub, "Region : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, ADR_POSTAL_CODE); wprintw (sub, "Postal Code : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, ADR_COUNTRY); wprintw (sub, "Country : %s\n", str ? str : ""); free (str); wprintw (sub, "\n"); } touchwin (win); wrefresh (sub); wrefresh (win); } /*************************************************************************** */ static void view_tel () { vc_component *vc = NULL; vc_component_param *vcp = NULL; char *val = NULL; char *type = NULL; char fmt [80]; char tmp [80]; int x = 0; int y = 0; int len = -1; g_mode = VIEW_TEL; werase (sub); x = (COLS - strlen (HEADING_TEL_STRING)) / 2; y = 1; wattron (sub, A_UNDERLINE); mvwprintw (sub, y, x, HEADING_TEL_STRING); wstandend (sub); wmove (sub, 3, 0); len = -1; vc = g_v; while (vc = vc_get_next_by_name (vc, VC_TELEPHONE)) { vcp = vc ? vc_param_get_by_name (vc_get_param (vc), "type") : NULL; if (vcp) { type = vc_param_get_value (vcp); if ((len < 0) | (len < strlen (type))) len = strlen (type) + 2; /* take parentheses into account */ } } vc = g_v; while (vc = vc_get_next_by_name (vc, VC_TELEPHONE)) { vcp = vc ? vc_param_get_by_name (vc_get_param (vc), "type") : NULL; type = vcp ? vc_param_get_value (vcp) : NULL; val = vc ? vc_get_value (vc) : NULL; snprintf (fmt, 79, "Telephone %%%ds : %%s\n", len); snprintf (tmp, 79, type ? "(%s)" : "", type); wprintw (sub, fmt, tmp, val ? val : ""); } wprintw (sub, "\n"); len = -1; vc = g_v; while (vc = vc_get_next_by_name (vc, VC_EMAIL)) { vcp = vc ? vc_param_get_by_name (vc_get_param (vc), "type") : NULL; if (vcp) { type = vc_param_get_value (vcp); if ((len < 0) | (len < strlen (type))) len = strlen (type) + 2; /* take parentheses into account */ } } vc = g_v; while (vc = vc_get_next_by_name (vc, VC_EMAIL)) { vcp = vc ? vc_param_get_by_name (vc_get_param (vc), "type") : NULL; type = vcp ? vc_param_get_value (vcp) : NULL; val = vc ? vc_get_value (vc) : NULL; snprintf (fmt, 79, "Email Address %%%ds : %%s\n", len); snprintf (tmp, 79, type ? "(%s)" : "", type); wprintw (sub, fmt, tmp, val ? val : ""); } wprintw (sub, "\n"); vc = vc_get_next_by_name (g_v, VC_MAILER); val = vc_get_value (vc); wprintw (sub, "Email Mailer : %s\n", val ? val : ""); touchwin (win); wrefresh (sub); wrefresh (win); } /*************************************************************************** */ static void view_org () { vc_component *vc = NULL; char *str = NULL; char *val = NULL; int x = 0; int y = 0; g_mode = VIEW_ORG; werase (sub); x = (COLS - strlen (HEADING_ORG_STRING)) / 2; y = 1; wattron (sub, A_UNDERLINE); mvwprintw (sub, y, x, HEADING_ORG_STRING); wstandend (sub); wmove (sub, 3, 0); vc = vc_get_next_by_name (g_v, VC_TITLE); val = vc_get_value (vc); wprintw (sub, "Title : %s\n", val ? val : ""); vc = vc_get_next_by_name (g_v, VC_ROLE); val = vc_get_value (vc); wprintw (sub, "Role : %s\n", val ? val : ""); wprintw (sub, "\n"); vc = vc_get_next_by_name (g_v, VC_ORGANIZATION); val = vc_get_value (vc); str = get_val_struct_part (val, ORG_NAME); wprintw (sub, "Organization Name : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, ORG_UNIT_1); wprintw (sub, "Organizational Unit #1 : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, ORG_UNIT_2); wprintw (sub, "Organizational Unit #2 : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, ORG_UNIT_3); wprintw (sub, "Organizational Unit #3 : %s\n", str ? str : ""); free (str); str = get_val_struct_part (val, ORG_UNIT_4); wprintw (sub, "Organizational Unit #4 : %s\n", str ? str : ""); free (str); wprintw (sub, "\n"); vc = vc_get_next_by_name (g_v, VC_LOGO); val = vc_get_value (vc); wprintw (sub, "Logo : %s\n", val ? val : ""); vc = vc_get_next_by_name (g_v, VC_AGENT); val = vc_get_value (vc); wprintw (sub, "Agent : %s\n", val ? val : ""); touchwin (win); wrefresh (sub); wrefresh (win); } /*************************************************************************** */ static void view_misc () { vc_component *vc = NULL; char *str = NULL; char *val = NULL; int x = 0; int y = 0; g_mode = VIEW_MISC; werase (sub); x = (COLS - strlen (HEADING_MISC_STRING)) / 2; y = 1; wattron (sub, A_UNDERLINE); mvwprintw (sub, y, x, HEADING_MISC_STRING); wstandend (sub); wmove (sub, 3, 0); vc = vc_get_next_by_name (g_v, VC_SORT_STRING); val = vc_get_value (vc); wprintw (sub, "Sort String : %s\n", val ? val : ""); vc = vc_get_next_by_name (g_v, VC_CLASS); val = vc_get_value (vc); wprintw (sub, "Class : %s\n", val ? val : ""); vc = vc_get_next_by_name (g_v, VC_KEY); val = vc_get_value (vc); wprintw (sub, "Public Key : %s\n", val ? val : ""); touchwin (win); wrefresh (sub); wrefresh (win); } /*************************************************************************** Display the given vCard to the end-user. */ void view_vcard (int entry_number, vc_component * v) { vc_component *vc = NULL; char *val = NULL; g_v = v; vc = vc_get_next_by_name (g_v, VC_FORMATTED_NAME); val = vc_get_value (vc); print_footer (entry_number, val ? val : ""); switch (g_mode) { case VIEW_IDENT: view_ident (); break; case VIEW_GEO: view_geo (); break; case VIEW_TEL: view_tel (); break; case VIEW_ORG: view_org (); break; case VIEW_MISC: view_misc (); break; default: break; } } /*************************************************************************** Prints the header to the window buffer, but does not display it to the end-user. */ static void print_header () { char *header_str = NULL; int i = 0; header_str = (char *) malloc (sizeof (char) * (COLS + 2)); strncpy (header_str, MENU_BAR_STRING, COLS); for (i = strlen (MENU_BAR_STRING); i < COLS; i++) { header_str[i] = ' '; } header_str[COLS] = '\n'; header_str[COLS + 1] = '\0'; wattron (win, A_REVERSE); wprintw (win, "%s", header_str); wstandend (win); free (header_str); } /*************************************************************************** Prints the footer to the window buffer, but does not display it to the end-user. The contents of the footer depends on the width of the screen. */ static void print_footer (int entry_number, const char *fn) { char *footer_str = NULL; char *entry_block = NULL; int entry_block_len = 0; int i = 0; footer_str = (char *) malloc (sizeof (char) * (COLS + 2)); /**************************************** initialize the footer string to dashes ****************************************/ for (i = 0; i < COLS; i++) { footer_str[i] = '-'; } if (NULL != fn) { entry_block_len = strlen (fn) + 18 + 3; /* 3 for entry_number */ } else { entry_block_len = 17 + 3; /* 3 for entry_number */ } /**************************************************** add the `entry' block only if there is enough room ****************************************************/ if (entry_block_len <= COLS) { entry_block = (char *) malloc (sizeof (char) * (entry_block_len + 1)); if (NULL != fn) { sprintf (entry_block, "---[ entry %i: %s ]---", entry_number % 1000, fn); } else { sprintf (entry_block, "---[ entry %i ]---", entry_number % 1000); } entry_block_len = strlen (entry_block); for (i = 0; i < entry_block_len; i++) { footer_str[i] = entry_block[i]; } free (entry_block); } footer_str[COLS] = '\n'; footer_str[COLS + 1] = '\0'; wattron (win, A_REVERSE); mvwprintw (win, LINES - 2, 0, "%s", footer_str); wstandend (win); free (footer_str); } /*************************************************************************** Handle input from the end-user. */ int process_view_commands () { bool done = FALSE; int ch = 0; int command = 0; while (!done) { ch = wgetch (win); switch (ch) { case '1': view_ident (); break; case '2': view_geo (); break; case '3': view_tel (); break; case '4': view_org (); break; case '5': view_misc (); break; case KEY_DOWN: case 'j': command = VIEW_COMMAND_NEXT; done = TRUE; break; case KEY_UP: case 'k': command = VIEW_COMMAND_PREVIOUS; done = TRUE; break; case 'e': command = VIEW_COMMAND_EDIT; done = TRUE; break; case 'h': (*display_help) (); touchwin (win); wrefresh (win); wrefresh (sub); break; case 'i': case 'q': command = VIEW_COMMAND_INDEX; g_mode = VIEW_IDENT; done = TRUE; break; case 'V': raw_view (g_v); break; case KEY_LEFT: view_left (); break; case KEY_RIGHT: view_right (); break; default: beep (); break; } } return command; } /*************************************************************************** */ void set_view_help_fcn (void (*fcn) (void)) { display_help = fcn; } /*************************************************************************** */ void raw_view (const vc_component * v) { /* FIXME: have a simple scrolling raw display of the vcard */ } rolo-019/src/view.h000066400000000000000000000023201414663705000142550ustar00rootroot00000000000000/* * rolo - contact management software * Copyright (C) 2003 Andrew Hsu * * 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 * * $Id$ */ #include #include /*** GLOBALS ***/ enum view_commands { VIEW_COMMAND_EDIT, VIEW_COMMAND_INDEX, VIEW_COMMAND_PREVIOUS, VIEW_COMMAND_NEXT }; /*** PROTOTYPES ***/ extern void init_view (); extern void view_vcard (int entry_number, vc_component * v); extern int process_view_commands (); extern void set_view_help_fcn (void (*fcn) (void)); extern void raw_view (const vc_component * v); rolo-019/test/000077500000000000000000000000001414663705000133255ustar00rootroot00000000000000rolo-019/test/Makefile.am000066400000000000000000000001721414663705000153610ustar00rootroot00000000000000all: @if [ "$(HAS_SHUNIT2)" = yes ] ; then \ ./run-tests ; \ else \ echo "Unit tests skipped" ; \ fi rolo-019/test/contacts.vcf000066400000000000000000000122461414663705000156500ustar00rootroot00000000000000BEGIN:VCARD FN:Mr. John Q. Public\, Esq. N:Public;John;Quinlan;Mr.;Esq. NICKNAME:Robbie BDAY:1996-04-15 ADR;TYPE=dom,home,postal,parcel:;;123 Main Street;Any Town;CA;91921-1234 LABEL;TYPE=dom,home,postal,parcel:Mr.John Q. Public\, Esq.\nMail Drop: TNE QB\n123 Main Street\nAny Town\, CA 91921-1234\nU.S.A. TEL;TYPE=work,voice,pref,msg:+1-213-555-1234 EMAIL;TYPE=internet:jqpublic@xyz.dom1.com MAILER:PigeonMail 2.1 TZ:-05:00 GEO:37.386013;-122.082932 TITLE:Director\, Research and Development ROLE:Programmer LOGO;VALUE=uri:http://www.abc.com/pub/logos/abccorp.jpg AGENT;VALUE=uri:CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com ORG:ABC\, Inc.;North American Division;Marketing CATEGORIES:TRAVEL AGENT NOTE:This fax number is operational 0800 to 1715 EST\, Mon-Fri. PRODID:-//ONLINE DIRECTORY//NONSGML Version 1//EN REV:1997-11-15 SOUND;TYPE=BASIC;VALUE=uri:CID:JOHNQPUBLIC.part8.19960229T080000.xyzMail@host1.com UID:19950401-080045-40000F192713-0052 URL:http://www.swbyps.restaurant.french/~chezchic.html VERSION:3.0 CLASS:PUBLIC END:VCARD BEGIN:vCard VERSION:3.0 FN:Frank Dawson N:Dawson;Frank ORG:Lotus Development Corporation ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive;Raleigh;NC;27613-3502;U.S.A. TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515 TEL;TYPE=FAX,WORK:+1-919-676-9564 EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com EMAIL;TYPE=INTERNET:fdawson@earthlink.net URL:http://home.earthlink.net/~fdawson END:vCard BEGIN:vCard VERSION:3.0 FN:Tim Howes N:Howes;Tim ORG:Netscape Communications Corp. ADR;TYPE=WORK:;;501 E. Middlefield Rd.;Mountain View;CA; 94043;U.S.A. TEL;TYPE=VOICE,MSG,WORK:+1-415-937-3419 TEL;TYPE=FAX,WORK:+1-415-528-4164 EMAIL;TYPE=INTERNET:howes@netscape.com END:vCard BEGIN:VCARD VERSION:3.0 N:Szyslak;Moe FN:Moe Szyslak ORG:Moe's Tavern TITLE:Manger ROLE:Bartender EMAIL:moe@moes-tavern.com TEL:+1-123-555-4444 END:VCARD BEGIN:VCARD VERSION:3.0 FN:Ed Ng N:Ng;Ed EMAIL:ed@ng.zz TEL:+64-9-555-0000 END:VCARD BEGIN:VCARD VERSION:3.0 N:Chow;Stephen FN:Stephen Chow EMAIL:stephen@chow.com.hk TEL:+852-1234-5678 TZ:+07:00 MAILER:Pine 4.0 END:VCARD BEGIN:VCARD VERSION:3.0 FN:Mr. Andrew Hsu N:Hsu;Andrew; EMAIL;TYPE=internet:ahsu@users.sf.net LABEL:10 Baker Street\nBoston TEL:+1-617-492-1111 END:VCARD BEGIN:VCARD VERSION:3.0 N:Preston;Bill;S.;Mr.;Esq. FN:Bill S. Preston EMAIL:bill@san-dimas-high.edu TEL:+1-420-555-8765 TZ:-08:00 END:VCARD BEGIN:VCARD VERSION:3.0 N:Kirk;James;T. EMAIL:jtk@enterprise.earth.net TEL:+123-4567-39492 BDAY:2133-10-10 END:VCARD BEGIN:VCARD N:Clark;Helen FN:Helen Clark TEL:+64-4-471-9998 EMAIL:pm@ministers.govt.nz TZ:+12:00 END:VCARD BEGIN:VCARD VERSION:2.1 N:Friday;Fred EMAIL:ff@uu.nn TEL;WORK;VOICE:+1-213-555-1234 TEL;WORK;FAX:+1-213-555-5678 END:VCARD BEGIN:VCARD VERSION:2.1 N:Martin;Stephen EMAIL:marty@i.have.no.email.address TEL;HOME;VOICE:+1 (210) 555-1357 TEL;HOME;FAX:+1 (210) 555-0864 ADR;WORK;PARCEL;POSTAL;DOM:123 Cliff Ave.;Big Town;CA;97531 END:VCARD BEGIN:VCARD VERSION:3.0 N:Reagan;Nancy;;; FN:Nancy Reagan NICKNAME:The Boss EMAIL;TYPE=internet:nancy@reagan.com TEL:+1-555-222-1111 END:VCARD BEGIN:VCARD VERSION:3.0 FN:Mr. Abbot Aikman N:Aikman;Abbot;;; EMAIL;TYPE=internet:aa@yahoo.com TEL:+1-234-633-9593 TZ:-07:00 MAILER:Pine 4.0 REV:2002-11-26 NOTE:This man eats nails for breakfast. X-SHOESIZE:9 NICKNAME:Mr. Twix BDAY:1980-07-07 END:VCARD BEGIN:VCARD VERSION:3.0 N:Winter;Alex;;; EMAIL:alex@winter.com TEL:+1-413-545-2911 X-SHOESIZE:5 FN:Alex Winter END:VCARD BEGIN:VCARD VERSION:3.0 N:Bush;Barbara;;; FN:Barbara Bush EMAIL;TYPE=internet:bb@bush.com TEL:+1-555-000-1111 END:VCARD BEGIN:VCARD VERSION:3.0 FN:Bob Doe N:Doe;Bob;;; EMAIL:bd@theinternet.net TEL:+22-565-124-6778 END:VCARD BEGIN:VCARD VERSION:3.0 FN:Burger King N:Burger King TEL:+1-284-555-2212 ADR:;;72 Armagh Street;Dullsville;MS;01219 END:VCARD BEGIN:VCARD VERSION:3.0 N:Kline;Calvin;;; FN:Calvin Kline EMAIL;TYPE=internet:underwear@clothingmaker.net TEL:+1-333-222-1923 END:VCARD BEGIN:VCARD VERSION:3.0 N:Tracy;Richard;;; FN:Dick Tracy NICKNAME:Guy EMAIL;TYPE=internet:dick@watch.com TEL:+1-555-222-0001 END:VCARD BEGIN:VCARD VERSION:3.0 FN:Fred Flintstone N:Flintsone;Frederick;;; EMAIL:fred.flintstone@bedrock.net TEL:+1-2-3-4 TZ:-02:00 REV:2001-11-26 NOTE:He wears no shoes. X-SHOESIZE:12 NICKNAME:Fred END:VCARD BEGIN:VCARD VERSION:3.0 N:Smith;John;;; EMAIL;TYPE=internet:jsmith@hotmail.com TEL:+1-413-545-1515 X-SHOESIZE:9 END:VCARD BEGIN:VCARD VERSION:3.0 N:Frog;Kermit;D.;; FN:Kermit D. Frog TITLE:Entertainer EMAIL:frog@legs.com TEL:+1-555-222-9284 END:VCARD BEGIN:VCARD VERSION:3.0 N:Roe;Louis;;; FN:Louis Roe NICKNAME:Lou EMAIL:lou@evergreen.com TEL:+7-2-342-112 BDAY:1980-09-09 END:VCARD BEGIN:VCARD VERSION:3.0 N:Apharsathchites;Almondiblahtaim;;; EMAIL;TYPE=internet:aapharsathchites@apharsathchites-home.co.uk ADR:P.O. Box 923453;Lederle Graduate Research Centre;94853 Massachusetts Avenue;North Flandersville;XA;493923-3434 NICKNAME:Apharasath FN:Miss Almondiblahtaim Apharsathchites II TEL:+1-555-111-1111 END:VCARD BEGIN:VCARD VERSION:3.0 N:Thomson;Nigel;;; EMAIL;TYPE=internet:nt@yahoos.com TEL:+420-2607-1234-1234 BDAY:2001-10-10 END:VCARD BEGIN:VCARD VERSION:3.0 FN:Ronald McDonald N:McDonald;Ronald;;; EMAIL;TYPE=internet:ron@mcdonald.com TEL:+1-422-555-8768 END:VCARD rolo-019/test/run-tests000077500000000000000000000042161414663705000152220ustar00rootroot00000000000000#!/bin/sh # rolo - contact management software # Copyright (C) 2019 Rafael Laboissière # 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 3 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, see . ### Redirect standard error into standard output exec 2>&1 ### Exit immediately if a command exits with a non-zero status set -e ### Get the directory of this script (for access to configure.ac and ### contacts.vcf) CURDIR=$(dirname $0) CONFIGURE_AC=$CURDIR/../configure.ac CONTACTS=$CURDIR/contacts.vcf ### Rolo command. Can be set as an environment variable when ### launching this script. Defaults to the compiled version in ../src. ROLO=${ROLO:-$CURDIR/../src/rolo} ### Test whether the -v option works test_rolo_version() { command="$ROLO -v" output="$($command)" prog=$(grep AC_INIT\( $CONFIGURE_AC | cut -d[ -f2 | cut -d] -f1) version=$(grep AC_INIT\( $CONFIGURE_AC | cut -d[ -f3 | cut -d] -f1) assertEquals "$prog $version" "$output" } ### Simple test for the help screen test_rolo_startup_and_help() { echo hqq | TERM=dumb $ROLO -f $CONTACTS > /dev/null } ### Test search and deletion commands test_rolo_search_and_delete() { vcf=$(mktemp) cp $CONTACTS $vcf name=Burger echo "/$name dyq" | TERM=dumb $ROLO -f $vcf > /dev/null assertEquals "" "$(grep $name $vcf || true)" rm -f $vcf } ### Test the edit command via $ROLO_EDITOR test_rolo_move_and_edit() { vcf=$(mktemp) cp $CONTACTS $vcf name="Alex Winter" output=$(echo Geq | ROLO_EDITOR=cat TERM=dumb $ROLO -f $vcf | grep "$name" || true) assertEquals "FN:$name" "$output" rm -f $vcf } ### Launch the unit tests . shunit2