pax_global_header00006660000000000000000000000064143170277770014531gustar00rootroot0000000000000052 comment=0bc3ac3f609314ab7b4347d4701f0a0ccdabf828 libvc-012/000077500000000000000000000000001431702777700124745ustar00rootroot00000000000000libvc-012/AUTHORS000066400000000000000000000001631431702777700135440ustar00rootroot00000000000000Andrew Hsu Rafael Laboissière Matthew Hague libvc-012/COPYING.LIB000066400000000000000000000634761431702777700141540ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 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. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. 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 library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; 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. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! libvc-012/ChangeLog000066400000000000000000000001441431702777700142450ustar00rootroot00000000000000Change log can be examined from the ViewCVS site: http://cvs.sf.net/cgi-bin/viewcvs.cgi/rolo/libvc/ libvc-012/Makefile.am000066400000000000000000000003651431702777700145340ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in ## $Id: Makefile.am,v 1.2 2003/05/10 10:14:26 ahsu Rel $ SUBDIRS = src doc test AUTOMAKE_OPTIONS = dist-bzip2 EXTRA_DIST = depcomp libvc.spec ACLOCAL_AMFLAGS = -I m4 CLEANFILES = ylwrap libvc-012/NEWS000066400000000000000000000047161431702777700132030ustar00rootroot00000000000000libvc 012 (2022-10-04) Avoid implicit declaration of functions libvc 011 (2021-13-12) * src/vc_scan.l: Hide visibility of non-api functions and variables * Fixed segfault causes by using current_vcard when parse doesn't match anything, changed file location tracking mechanism so that reading extra large vcards doesn't cause the parsing to fail early * Improve parsing times of large vcards libvc 010 (2021-01-12) * Do not call exit() * Port to Autoconf 2.71 * Clean files that are removed by the clean target of the generated Makefiles libvc 009 (2021-02-05) * Cope with libtoolize warnings regarding the m4 directory * src/vc_parse.y: Drop non yacc-compatible %defines directive libvc 008 (2021-01-30) * Properly parse multi-line values in MSDOS files, with line ending CRLF. Thanks to Adrian Edwards (MoralCode @ github) for the patch. libvc 007 (2020-07-14) * Use mktemp instead of deprecated tempfile in unit tests libvc 006 (2019-07-13) * Add unit tests * Do not install the RFC 2426 file * Fix doc-str-Lb-libvc macro in vc.3 man page libvc 005 (2017-02-19) * Minor bug fixing release libvc 004 (2017-02-18) * Remove file doc/rfc2426.txt, which has non-free licensing conditions. * Accept fields with multiple-lines values. * Fix buffer overflow bug (CVE-2006-1356) libvc 003 (2003-06-14) * Properly parses vCard version 2.1 files. This means Microsoft vCard files can now be properly parsed as well. * Searching and comparing type names and parameter names are now case insensitive. * The build now produces shared libraries as well as static libraries. libvc 002 (2003-05-15) * Parsing of parameters are now performed properly and stuffed into the `name' and `value' fields of the `vc_param_component' structure. The `str' field has been removed as a result of this (because `str' was only a silly hack to begin with). * Fixed a bug in fprintf_vcard that prevented vcards from being printed. * There now exists a libvc.spec file for Red Hat Linux. Therefore, RPMs will be created for each release from now on. libvc 001 (2003-05-12) * Initial release. This is the same vCard library that was built with previous releases of rolo. However, all occurrences of `vcard_' have now been shortened to `vc_'. Plus, the header file is now `vc.h' instead of `vcard.h'. The next binary releases of rolo and mutt_vc_query will be built with libvc. The next source releases of rolo and mutt_vc_query will have libvc as a dependency. The vc(3) man page is not finished yet. libvc-012/README000066400000000000000000000014611431702777700133560ustar00rootroot00000000000000libvc - vCard library release 003 Copyright (C) 2003 Andrew Hsu This vCard library was written using `flex' and `bison'. The library handles scanning a vCard file, parsing the vCard file into a data storage structure, manipulating the data storage structure, and writing back to file. It was originally written for `rolo', but has been split-off as a generic library for general use. Shared libraries and static libraries are produced upon a successful build. Directory contents: doc/ ...... Documentation for libvc. src/ ...... Source code of libvc. This software is maintained on SourceForge: http://rolo.sf.net/ See the `INSTALL' file for building and installation instructions. See the `COPYING.LIB' file for copying conditions. Send bugs, questions, or comments to Andrew Hsu . libvc-012/README.md000066400000000000000000000011541431702777700137540ustar00rootroot00000000000000# libvc [vCard](https://tools.ietf.org/html/rfc2426) (the Electronic Business Card) library. Fork of libvc, part of the [Rolo](http://rolo.sourceforge.net/) project, which seems abandoned. Original read me file provided in README. ## Compilation autoreconf -f -i ./configure make make install ## Simple unit tests make check The unit tests in file [run-tests](test/run-tests) need [shUnit2](https://github.com/kward/shunit2). ## Development Note: if making changes, use git update-index --assume-unchanged INSTALL to avoid automatic changes to INSTALL making it into the git history. libvc-012/THANKS000066400000000000000000000001341431702777700134050ustar00rootroot00000000000000Jen Wang Oliver Braun libvc-012/TODO000066400000000000000000000007331431702777700131670ustar00rootroot00000000000000* Finish the man pages. * Create a user's guide or tutorial. * Create a generic "get preferred" function that accepts a type a parameter. This function can then be used to retrieve the preferred EMAIL, TEL, ADR, LABEL, and possibly URL. * Have the type name, param name, and param values all stuffed into the vc_component as lowercase-only values. This will simplify the searching and comparison of these values and eliminate the need for strcasecmp in a lot of places. libvc-012/configure.ac000066400000000000000000000020411431702777700147570ustar00rootroot00000000000000# Process this file with autoconf to produce a configure script. # $Id: configure.ac,v 1.3 2003/06/14 01:54:15 ahsu Rel $ ### Versioning AC_INIT([libvc],[012],[rafael@laboissiere.net]) LIBVC_ABI_VERSION=1:4:1 AC_SUBST(LIBVC_ABI_VERSION) ### Main definitions AM_INIT_AUTOMAKE AC_PREREQ([2.71]) AC_COPYRIGHT([Copyright (C) 2003 Andrew Hsu Copyright (C) 2017, 2019-2022 Rafael Laboissière]) AC_REVISION($Revision: 1.3 $) AC_CONFIG_SRCDIR([src/vc.c]) AC_CONFIG_MACRO_DIRS([m4]) ### Checks for programs. AC_PROG_CC AC_PROG_LEX([noyywrap]) AC_PROG_YACC LT_INIT AC_CHECK_PROG(have_shunit2,shunit2,yes) AM_CONDITIONAL([HAVE_SHUNIT2], [test x$have_shunit2 = xyes]) ### 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 strcasecmp]) ### Checks for visibility suport m4_include([m4/visibility.m4]) gl_VISIBILITY ### Output files AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile test/Makefile]) AC_OUTPUT libvc-012/doc/000077500000000000000000000000001431702777700132415ustar00rootroot00000000000000libvc-012/doc/Makefile.am000066400000000000000000000002351431702777700152750ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in ## $Id: Makefile.am,v 1.2 2003/05/10 23:40:20 ahsu Exp $ man_MANS = vc.3 EXTRA_DIST = $(man_MANS) libvc-012/doc/vc.3000066400000000000000000000033041431702777700137350ustar00rootroot00000000000000.\" Process this file with .\" groff -man -Tascii vc.3 .\" $Id: vc.3,v 1.1 2003/05/10 09:24:19 ahsu Exp $ .Dd May 11, 2003 .Os .Dt VC 3 .Sh NAME .Nm vc_new , .Nm vc_delete .Nm vc_set_group , .Nm vc_set_name , .Nm vc_set_param , .Nm vc_set_value , .Nm vc_link , .Nm vc_append_with_name , .Nm vc_is_preferred , .Nm vc_get_error_message , .Nm vc_get_preferred_tel , .Nm vc_get_preferred_email , .Nm vc_get_group , .Nm vc_get_name , .Nm vc_get_param , .Nm vc_get_value , .Nm vc_param_new , .Nm vc_param_set_name , .Nm vc_param_set_value , .Nm vc_param_set_str , .Nm vc_param_link , .Nm vc_param_get_name , .Nm vc_param_get_value , .Nm vc_get_next , .Nm vc_get_next_by_name , .Nm vc_param_get_next , .Nm vc_param_get_by_name , .Nm vc_param_get_next_by_name , .Nm vc_delete , .Nm vc_delete_deep , .Nm vc_param_delete , .Nm vc_param_delete_deep , .Nm fprintf_vc_component_param , .Nm fprintf_vc_component , .Nm fprintf_vcard , .Nm parse_vcard_file , .Nm count_vcards , .Nm get_val_struct_part .Nd vCard library .Sh LIBRARY .ds doc-str-Lb-libvc vCard\~library (libvc, \-lvc) .Lb libvc .Sh SYNOPSIS .In vc.h .Ft vc_component * .Fn vc_new .Ft void .Fn vc_delete "vc_component *vc" .Ft vc_component * .Fn vc_set_group "vc_component *vc" "const char *group" .Ft vc_component * .Fn vc_set_name "vc_component *vc" "const char *name" .Ft vc_component * .Fn vc_set_param "vc_component *vc" "vc_component_param *vc_param" .Ft vc_component * .Fn vc_set_value "vc_component *vc" "const char *value" .Sh DESCRIPTION This is a library for vCard. .Pp .Sh SEE ALSO .Xr vc_new 3 , .Xr vc_delete 3 .Sh AUTHORS .An "Andrew Hsu" Aq ahsu@users.sf.net .An "Rafael Laboissière" Aq rafael@laboissiere.net .Sh BUGS Parsing parameters is not finished yet. libvc-012/libvc.spec000066400000000000000000000031301431702777700144440ustar00rootroot00000000000000# RPM spec file for Red Hat Linux # $Id: libvc.spec,v 1.2 2003/05/16 06:30:38 ahsu Rel $ Summary: Shared library for accessing and manipulating vCard files. Name: libvc Version: 003 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: System Environment/Libraries Prefix: /usr BuildRoot: %{_tmppath}/%{name}-buildroot %description The libvc library is a C library for accessing and manipulating vCard files. This package contains only the shared libraries for use by applications that need them at run-time. %package devel Summary: Static library and header file for vCard development. Group: Development/Libraries Requires: libvc = %{version} %description devel This package contains headers and static libraries for developing applications that access and manipulate vCards. The library handles scanning a vCard file, parsing the vCard file into a data storage structure, manipulating the data storage structure, and writing back to file. Install the libvc-devel package if you want to develop applications that access or manipulate vCard files. %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) %{_libdir}/*.so.* %files devel %defattr(-,root,root) %{_libdir}/*.a %{_includedir}/*.h %{_mandir}/man3/vc.3* %doc AUTHORS COPYING.LIB ChangeLog INSTALL NEWS README THANKS doc/rfc2426.txt libvc-012/m4/000077500000000000000000000000001431702777700130145ustar00rootroot00000000000000libvc-012/m4/visibility.m4000066400000000000000000000066221431702777700154530ustar00rootroot00000000000000# visibility.m4 serial 8 dnl Copyright (C) 2005, 2008, 2010-2021 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl Tests whether the compiler supports the command-line option dnl -fvisibility=hidden and the function and variable attributes dnl __attribute__((__visibility__("hidden"))) and dnl __attribute__((__visibility__("default"))). dnl Does *not* test for __visibility__("protected") - which has tricky dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on dnl Mac OS X. dnl Does *not* test for __visibility__("internal") - which has processor dnl dependent semantics. dnl Does *not* test for #pragma GCC visibility push(hidden) - which is dnl "really only recommended for legacy code". dnl Set the variable CFLAG_VISIBILITY. dnl Defines and sets the variable HAVE_VISIBILITY. AC_DEFUN([gl_VISIBILITY], [ AC_REQUIRE([AC_PROG_CC]) CFLAG_VISIBILITY= HAVE_VISIBILITY=0 if test -n "$GCC"; then dnl First, check whether -Werror can be added to the command line, or dnl whether it leads to an error because of some other option that the dnl user has put into $CC $CFLAGS $CPPFLAGS. AC_CACHE_CHECK([whether the -Werror option is usable], [gl_cv_cc_vis_werror], [gl_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Werror" AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[]], [[]])], [gl_cv_cc_vis_werror=yes], [gl_cv_cc_vis_werror=no]) CFLAGS="$gl_save_CFLAGS" ]) dnl Now check whether visibility declarations are supported. AC_CACHE_CHECK([for simple visibility declarations], [gl_cv_cc_visibility], [gl_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden" dnl We use the option -Werror and a function dummyfunc, because on some dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning dnl "visibility attribute not supported in this configuration; ignored" dnl at the first function definition in every compilation unit, and we dnl don't want to use the option in this case. if test $gl_cv_cc_vis_werror = yes; then CFLAGS="$CFLAGS -Werror" fi AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; extern __attribute__((__visibility__("default"))) int exportedvar; extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); extern __attribute__((__visibility__("default"))) int exportedfunc (void); void dummyfunc (void); int hiddenvar; int exportedvar; int hiddenfunc (void) { return 51; } int exportedfunc (void) { return 1225736919; } void dummyfunc (void) {} ]], [[]])], [gl_cv_cc_visibility=yes], [gl_cv_cc_visibility=no]) CFLAGS="$gl_save_CFLAGS" ]) if test $gl_cv_cc_visibility = yes; then CFLAG_VISIBILITY="-fvisibility=hidden" HAVE_VISIBILITY=1 fi fi AC_SUBST([CFLAG_VISIBILITY]) AC_SUBST([HAVE_VISIBILITY]) AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.]) ]) libvc-012/src/000077500000000000000000000000001431702777700132635ustar00rootroot00000000000000libvc-012/src/Makefile.am000066400000000000000000000005571431702777700153260ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in ## $Id: Makefile.am,v 1.2 2003/05/12 10:44:07 ahsu Rel $ BUILT_SOURCES = vc_parse.h AM_YFLAGS = -d AM_LFLAGS = -i include_HEADERS = vc.h lib_LTLIBRARIES = libvc.la libvc_la_SOURCES = vc.c vc_parse.y vc_scan.l libvc_la_LDFLAGS = -version-info $(LIBVC_ABI_VERSION) CLEANFILES = vc_parse.c vc_parse.h vc_scan.c libvc-012/src/vc.c000066400000000000000000000543521431702777700140500ustar00rootroot00000000000000/* * libvc - vCard library * Copyright (C) 2003 Andrew Hsu * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later * version. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * $Id: vc.c,v 1.4 2003/05/19 07:10:21 ahsu Exp $ */ #include "vc.h" #include #include #define __USE_GNU #include #define BUF_LEN 80 /*** ERROR MESSAGE ***/ static char* vc_last_error_message = NULL; /*** STRUCTS ***/ struct vc_component_tag { char *group; char *name; vc_component_param *param; char *value; vc_component *next; }; struct vc_component_param_tag { char *name; char *value; vc_component_param *next; }; /*** FUNCTION DEFINITIONS ***/ /*************************************************************************** Set/get the last error message */ void #if HAVE_VISIBILITY __attribute__((__visibility__("hidden"))) #endif vc_set_error_message (char *err_msg) { if (NULL != vc_last_error_message) { free (vc_last_error_message); } vc_last_error_message = (char *) malloc ((strlen (err_msg) + 1) * sizeof (char)); strcpy (vc_last_error_message, err_msg); } char * vc_get_error_message () { return vc_last_error_message; } /*************************************************************************** Returns a new vc_component with everything set to NULL. The user of the new vc_component will be responsible for freeing it in the future with a call to vc_delete or vc_delete_deep. */ vc_component * vc_new () { vc_component *new_vc = NULL; new_vc = (vc_component *) malloc (sizeof (vc_component)); if (NULL == new_vc) { vc_set_error_message ("unable to malloc a new vc_component"); return NULL; } else { new_vc->group = NULL; new_vc->name = NULL; new_vc->param = NULL; new_vc->value = NULL; new_vc->next = NULL; } return new_vc; } /*************************************************************************** Sets the group of a vc_component by making a copy of the given group. Does nothing if the given vc_component is NULL. Returns the given vc_component. */ vc_component * vc_set_group (vc_component * vc, const char *group) { if (NULL != vc) { free (vc->group); vc->group = strdup (group); } return vc; } /*************************************************************************** Sets the name of a vc_component by making a copy of the given name. Does nothing if the given vc_component is NULL. Returns the given vc_component. */ vc_component * vc_set_name (vc_component * vc, char *name) { if (NULL != vc) { free (vc->name); vc->name = strdup (name); } return vc; } /*************************************************************************** Appends to the linked-list of parameters in the given vc_component. Does nothing if the given vc_component is NULL. Returns the given vc_component. */ vc_component * vc_add_param (vc_component * vc, vc_component_param * vc_param) { if (NULL != vc) { vc_component_param *p = NULL; p = vc->param; if (NULL == p) { vc->param = vc_param; } else { while (NULL != p->next) { p = p->next; } p->next = vc_param; } } return vc; } /*************************************************************************** Sets the value of a vc_component by making a copy of the given value. Does nothing if the given vc_component is NULL. Returns the given vc_component. */ vc_component * vc_set_value (vc_component * vc, const char *value) { if (NULL != vc) { free (vc->value); vc->value = strdup (value); } return vc; } /*************************************************************************** Traverses to the end of the list of head and then appends tail as the next node. If head is null, does nothing. Returns head. */ vc_component * vc_link (vc_component * head, vc_component * tail) { if (NULL != head) { vc_component *vc = NULL; vc = head; while (NULL != vc->next) { vc = vc->next; } vc->next = tail; } return head; } /*************************************************************************** This is a convenience function for appending a new vc_component to the end of the list pointed to by the given vc_component. Returns a pointer to the newly created vc_component if successful, NULL otherwise. */ vc_component * vc_append_with_name (vc_component * vc, char *name) { vc_component *new_vc = NULL; if (NULL != vc) { new_vc = vc_new (); vc_set_name (new_vc, name); vc_link (vc, new_vc); } return new_vc; } /*************************************************************************** Checks the parameters of the given vc_component to see if there exists a parameter name `TYPE' with a value of `pref'. Returns a value of 1 if found, else 0. */ int vc_is_preferred (vc_component * vc) { int ret_val = 0; if (NULL != vc) { vc_component_param *vc_param = NULL; char *value = NULL; int done = 0; for (vc_param = vc_param_get_by_name (vc->param, "TYPE"); (NULL != vc_param) && (!done); vc_param = vc_param_get_next_by_name (vc_param, "TYPE")) { value = vc_param_get_value (vc_param); if (NULL != value) { if (0 == strcasecmp (value, "pref")) { ret_val = 1; done = 1; } } } } return ret_val; } /*************************************************************************** Returns the pointer to the name of the preferred telephone number of the given vc. This is done by checking for `TYPE' parameters with a value of `pref'. If no such parameter is found, then the first vc_component with the name `TEL' will be returned. Returns NULL if none found. Users of this function must not modify the contents to which the returned pointer points to. TODO: Fix the duplicate code with vc_get_preferred_email. */ char * vc_get_preferred_tel (vc_component * v) { char *tel = NULL; int done = 0; vc_component *vc = NULL; vc = vc_get_next_by_name (v, VC_TELEPHONE); tel = vc_get_value (vc); if (!vc_is_preferred (vc)) { while ((NULL != vc) && (!done)) { vc = vc_get_next_by_name (vc, VC_TELEPHONE); if (vc_is_preferred (vc)) { tel = vc_get_value (vc); done = 1; } } } return tel; } /*************************************************************************** Returns the pointer to the name of the preferred email number of the given vc. This is done by checking for `TYPE' parameters with a value of `pref'. If no such parameter is found, then the first vc_component with the name `EMAIL' will be returned. Returns NULL if none found. Users of this function must not modify the contents to which the returned pointer points to. FIXME: lots of duplicate code with vc_get_preferred_tel */ char * vc_get_preferred_email (vc_component * v) { char *email = NULL; int done = 0; vc_component *vc = NULL; vc = vc_get_next_by_name (v, VC_EMAIL); email = vc_get_value (vc); if (!vc_is_preferred (vc)) { while ((NULL != vc) && (!done)) { vc = vc_get_next_by_name (vc, VC_EMAIL); if (vc_is_preferred (vc)) { email = vc_get_value (vc); done = 1; } } } return email; } /*************************************************************************** Returns the pointer to the group of the given vc_component. Users of this function must not modify the contents to which the pointer points to (use vc_set_group function for modifying the group). Returns NULL if no group found. */ char * vc_get_group (const vc_component * vc) { char *ret_val = NULL; if (NULL != vc) { ret_val = vc->group; } return ret_val; } /*************************************************************************** Returns the pointer to the name of the given vc_component. Users of this function must not modify the contents to which the pointer points to (use vc_set_name function for modifying the name). Returns NULL if no name found. */ char * vc_get_name (const vc_component * vc) { char *ret_val = NULL; if (NULL != vc) { ret_val = vc->name; } return ret_val; } /*************************************************************************** Returns the pointer to the first parameter of the given vc_component. Users of this function may use the modify functions for vc_component_param to change the contents of the returned parameter. Returns NULL if no parameter found. */ vc_component_param * vc_get_param (const vc_component * vc) { vc_component_param *ret_val = NULL; if (NULL != vc) { ret_val = vc->param; } return ret_val; } /*************************************************************************** Returns the pointer to the value of the given vc_component. Users of this function must not modify the contents to which the pointer points to (use vc_set_value function for modifying the value). Returns NULL if no value found. */ char * vc_get_value (const vc_component * vc) { char *ret_val = NULL; if (NULL != vc) { ret_val = vc->value; } return ret_val; } /*************************************************************************** Returns a new vc_component_param with everything set to NULL. The user of the new vc_component_param will be responsible for freeing it in the future with a call to vc_param_delete or vc_param_delete_deep. */ vc_component_param * vc_param_new () { vc_component_param *new_vc_param = NULL; new_vc_param = (vc_component_param *) malloc (sizeof (vc_component_param)); if (NULL == new_vc_param) { vc_set_error_message ("unable to malloc a new vc_component_param"); return NULL; } else { new_vc_param->name = NULL; new_vc_param->value = NULL; new_vc_param->next = NULL; } return new_vc_param; } /*************************************************************************** Sets the name of a vc_component_param by making a copy of the given name. Does nothing if the given vc_component_param is NULL. Returns the given vc_component_param. */ vc_component_param * vc_param_set_name (vc_component_param * vc_param, const char *name) { if (NULL != vc_param) { free (vc_param->name); vc_param->name = strdup (name); } return vc_param; } /*************************************************************************** Sets the value of a vc_component_param by making a copy of the given value. Does nothing if the given vc_component_param is NULL. Returns the given vc_component_param. */ vc_component_param * vc_param_set_value (vc_component_param * vc_param, const char *value) { if (NULL != vc_param) { free (vc_param->value); vc_param->value = strdup (value); } return vc_param; } /*************************************************************************** Traverses to the end of the list of head and then appends tail as the next node. If head is null, does nothing. Returns head. */ vc_component_param * vc_param_link (vc_component_param * head, vc_component_param * tail) { if (NULL != head) { vc_component_param *vc_param = NULL; vc_param = head; while (NULL != vc_param->next) { vc_param = vc_param->next; } vc_param->next = tail; } return head; } /*************************************************************************** Returns the pointer to the name of the given vc_component_param. Users of this function must not modify the contents to which the pointer points to (use vc_param_set_name function for modifying the name). Returns NULL if no name found. */ char * vc_param_get_name (const vc_component_param * vc_param) { char *ret_val = NULL; if (NULL != vc_param) { ret_val = vc_param->name; } return ret_val; } /*************************************************************************** Returns the pointer to the value of the given vc_component_param. Users of this function must not modify the contents to which the pointer points to (use vc_param_set_value function for modifying the value). Returns NULL if no name found. */ char * vc_param_get_value (const vc_component_param * vc_param) { char *ret_val = NULL; if (NULL != vc_param) { ret_val = vc_param->value; } return ret_val; } /*************************************************************************** Returns the next vc_component linked to the given one. Returns NULL if none left. */ vc_component * vc_get_next (const vc_component * vc) { vc_component *ret_val = NULL; if (NULL != vc) { ret_val = vc->next; } return ret_val; } /*************************************************************************** Searches for a vc_component that matches the given name, starting with the one after the given vc_component. Returns NULL if none is found. */ vc_component * vc_get_next_by_name (vc_component * vc, const char *name) { vc_component *result_vc = NULL; vc_component *tmp_vc = NULL; int done = 0; if ((NULL != name) && (NULL != vc)) { tmp_vc = vc->next; while ((0 == done) && (NULL != tmp_vc)) { if (NULL != tmp_vc->name) { if (0 == strcasecmp (name, tmp_vc->name)) { result_vc = tmp_vc; done = 1; } } tmp_vc = tmp_vc->next; } } return result_vc; } /*************************************************************************** Returns the next vc_component_param linked to the given one. Returns NULL if none left. */ vc_component_param * vc_param_get_next (const vc_component_param * vc_param) { vc_component_param *ret_val = NULL; if (NULL != vc_param) { ret_val = vc_param->next; } return ret_val; } /*************************************************************************** Searches for a vc_component_param that matches the given name, starting with the given vc_component_param. Returns NULL if none is found. FIXME: lots of code duplicated from vc_param_get_next_by_name */ vc_component_param * vc_param_get_by_name (vc_component_param * vc_param, const char *name) { vc_component_param *result_vc_param = NULL; vc_component_param *tmp_vc_param = NULL; int done = 0; if ((NULL != name) && (NULL != vc_param)) { tmp_vc_param = vc_param; while ((0 == done) && (NULL != tmp_vc_param)) { if (NULL != tmp_vc_param->name) { if (0 == strcasecmp (name, tmp_vc_param->name)) { result_vc_param = tmp_vc_param; done = 1; } } tmp_vc_param = tmp_vc_param->next; } } return result_vc_param; } /*************************************************************************** Searches for a vc_component_param that matches the given name, starting with the one after the given vc_component_param. Returns NULL if none is found. FIXME: lots of code duplicated from vc_param_get_by_name */ vc_component_param * vc_param_get_next_by_name (vc_component_param * vc_param, const char *name) { vc_component_param *result_vc_param = NULL; vc_component_param *tmp_vc_param = NULL; int done = 0; if ((NULL != name) && (NULL != vc_param)) { tmp_vc_param = vc_param->next; while ((0 == done) && (NULL != tmp_vc_param)) { if (NULL != tmp_vc_param->name) { if (0 == strcasecmp (name, tmp_vc_param->name)) { result_vc_param = tmp_vc_param; done = 1; } } tmp_vc_param = tmp_vc_param->next; } } return result_vc_param; } /*************************************************************************** Performs a "shallow" delete of the given vc_component. This means that only the given vc_component will be freed. As a side-effect, a "deep" delete of all the associated parameters will be performed. A responsible user of this function would also remember to set the given vc_component pointer variable to NULL when this function returns. */ void vc_delete (vc_component * vc) { if (NULL != vc) { free (vc->group); free (vc->name); vc_param_delete_deep (vc->param); free (vc->value); free (vc); } } /*************************************************************************** Performs a "deep" delete of the given vc_component. This means that all the vc_components linked to the given one will also be deleted. A responsible user of this function would also remember to set the given vc_component pointer variable to NULL when this function returns. */ void vc_delete_deep (vc_component * vc) { vc_component *tmp_vc = NULL; vc_component *vc_to_free = NULL; tmp_vc = vc; while (NULL != tmp_vc) { vc_to_free = tmp_vc; tmp_vc = tmp_vc->next; vc_delete (vc_to_free); } } /*************************************************************************** Performs a "shallow" delete of the given vc_component_param. This means that only the given vc_component_param will be freed. A responsible user of this function would also remember to set the given vc_component_param pointer variable to NULL when this function returns. */ void vc_param_delete (vc_component_param * vc_param) { if (NULL != vc_param) { free (vc_param->name); free (vc_param->value); free (vc_param); } } /*************************************************************************** Performs a "deep" delete of the given vc_component_param. This means that all the vc_component_params linked to the given one will also be deleted. A responsible user of this function would also remember to set the given vc_component_param pointer variable to NULL when this function returns. */ void vc_param_delete_deep (vc_component_param * vc_param) { vc_component_param *tmp_vc_param = NULL; vc_component_param *vc_param_to_free = NULL; tmp_vc_param = vc_param; while (NULL != tmp_vc_param) { vc_param_to_free = tmp_vc_param; tmp_vc_param = tmp_vc_param->next; vc_param_delete (vc_param_to_free); } } /*************************************************************************** Prints the linked-list of vc_component_param to the given FILE pointer. */ void fprintf_vc_component_param (FILE * fp, vc_component_param * vc_param) { vc_component_param *tmp_vc_param = NULL; tmp_vc_param = vc_param; for (tmp_vc_param = vc_param; NULL != tmp_vc_param; tmp_vc_param = vc_param_get_next (tmp_vc_param)) { fprintf (fp, ";%s=%s", tmp_vc_param->name, tmp_vc_param->value); } } /*************************************************************************** Prints a single vc_component to the given FILE pointer. */ void fprintf_vc_component (FILE * fp, vc_component * vc) { if (NULL != vc) { if (NULL != vc->group) { fprintf (fp, "%s.", vc->group); } /* the name is expected to exist */ fprintf (fp, "%s", vc->name); fprintf_vc_component_param (fp, vc->param); fprintf (fp, ":"); if (NULL != vc->value) { fprintf (fp, "%s", vc->value); } fprintf (fp, "\n"); } } /*************************************************************************** Prints the entire vCard to the given FILE pointer. */ void fprintf_vcard (FILE * fp, vc_component * vcard) { vc_component *vc = NULL; vc = vcard; if (NULL != vc) { fprintf (fp, "BEGIN:VCARD\n"); for (vc = vc->next; NULL != vc; vc = vc->next) { fprintf_vc_component (fp, vc); } fprintf (fp, "END:VCARD\n"); } } /*************************************************************************** Returns the number of vCards found in the given FILE pointer. */ int count_vcards (FILE * fp) { char* line = NULL; size_t len = 0; int counter = 0; while (getline (&line, &len, fp) != EOF) if (0 == strncasecmp (line, "BEGIN:VCARD", 11)) counter++; if (line) free (line); return counter; } /*************************************************************************** Returns a new string of the contents of the section of the given string denoted by the part_index. */ char * get_val_struct_part (const char *str, int part_index) { char buf[BUF_LEN]; int i = 0; int j = 0; int part_counter = 0; int done = 0; char *result = NULL; if (NULL != str) { buf[0] = '\0'; while ('\0' != str[i] && 1 != done) { if (part_index == part_counter) { while (str[i] != ';' && i < BUF_LEN - 1) { buf[j] = str[i]; j++; i++; } buf[j] = '\0'; done = 1; } else { if (';' == str[i]) { part_counter++; } i++; } } if ('\0' != buf[0]) { result = strdup (buf); } } return result; } libvc-012/src/vc.h000066400000000000000000000126401431702777700140470ustar00rootroot00000000000000/* * libvc - vCard library * Copyright (C) 2003 Andrew Hsu * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: vc.h,v 1.3 2003/05/13 06:09:19 ahsu Exp $ */ #ifndef __VC_H #define __VC_H 1 #include /*** TYPEDEFS ***/ typedef struct vc_component_tag vc_component; typedef struct vc_component_param_tag vc_component_param; #ifdef __cplusplus extern "C" { #endif /*** PROTOTYPES ***/ /* create function for vc_component */ vc_component *vc_new (); /* modify functions for vc_component */ vc_component *vc_set_group (vc_component * vc, const char *group); vc_component *vc_set_name (vc_component * vc, char *name); vc_component *vc_add_param (vc_component * vc, vc_component_param * vc_param); vc_component *vc_set_value (vc_component * vc, const char *value); vc_component *vc_link (vc_component * head, vc_component * tail); /* convenience function */ vc_component *vc_append_with_name (vc_component * vc, char *name); int vc_is_preferred (vc_component * vc); char *vc_get_preferred_tel (vc_component * v); char *vc_get_preferred_email (vc_component * v); /* read functions for vc_component */ char *vc_get_group (const vc_component * vc); char *vc_get_name (const vc_component * vc); vc_component_param *vc_get_param (const vc_component * vc); char *vc_get_value (const vc_component * vc); /* create function for vc_component_param */ vc_component_param *vc_param_new (); /* modify functions for vc_component_param */ vc_component_param *vc_param_set_name (vc_component_param * vc_param, const char *name); vc_component_param *vc_param_set_value (vc_component_param * vc_param, const char *value); vc_component_param *vc_param_link (vc_component_param * head, vc_component_param * tail); /* read functions for vc_component_param */ char *vc_param_get_name (const vc_component_param * vc_param); char *vc_param_get_value (const vc_component_param * vc_param); /* functions for scrolling through vc_components */ vc_component *vc_get_next (const vc_component * vc); vc_component *vc_get_next_by_name (vc_component * vc, const char *name); /* functions for scrolling through vc_component_params */ vc_component_param *vc_param_get_next (const vc_component_param * vc_param); vc_component_param *vc_param_get_by_name (vc_component_param * vc_param, const char *name); vc_component_param *vc_param_get_next_by_name (vc_component_param * vc_param, const char *name); /* clean-up functions */ void vc_delete (vc_component * vc); void vc_delete_deep (vc_component * vc); void vc_param_delete (vc_component_param * vc_param); void vc_param_delete_deep (vc_component_param * vc_param); /* printing functions */ void fprintf_vc_component_param (FILE * fp, vc_component_param * vc_param); void fprintf_vc_component (FILE * fp, vc_component * vc); void fprintf_vcard (FILE * fp, vc_component * vcard); /* parsing functions */ vc_component *parse_vcard_file (FILE * fp); int count_vcards (FILE * fp); char *get_val_struct_part (const char *n, int part); /*** ENUMS ***/ enum n_parts { N_FAMILY, N_GIVEN, N_MIDDLE, N_PREFIX, N_SUFFIX }; enum adr_parts { ADR_PO_BOX, ADR_EXT_ADDRESS, ADR_STREET, ADR_LOCALITY, ADR_REGION, ADR_POSTAL_CODE, ADR_COUNTRY }; enum org_parts { ORG_NAME, ORG_UNIT_1, ORG_UNIT_2, ORG_UNIT_3, ORG_UNIT_4 }; enum geo_parts { GEO_LATITUDE, GEO_LONGITUDE }; /*** DEFINES ***/ #define VC_ADDRESS "ADR" #define VC_AGENT "AGENT" #define VC_BIRTHDAY "BDAY" #define VC_CATEGORIES "CATEGORIES" #define VC_CLASS "CLASS" #define VC_DELIVERY_LABEL "LABEL" #define VC_EMAIL "EMAIL" #define VC_FORMATTED_NAME "FN" #define VC_GEOGRAPHIC_POSITION "GEO" #define VC_KEY "KEY" #define VC_LOGO "LOGO" #define VC_MAILER "MAILER" #define VC_NAME "N" #define VC_NICKNAME "NICKNAME" #define VC_NOTE "NOTE" #define VC_ORGANIZATION "ORG" #define VC_PHOTO "PHOTO" #define VC_PRODUCT_IDENTIFIER "PRODID" #define VC_REVISION "REV" #define VC_ROLE "ROLE" #define VC_SORT_STRING "SORT-STRING" #define VC_SOUND "SOUND" #define VC_TELEPHONE "TEL" #define VC_TIME_ZONE "TZ" #define VC_TITLE "TITLE" #define VC_URL "URL" #define VC_VCARD "VCARD" #define VC_VERSION "VERSION" #ifdef __cplusplus } #endif #endif /* __VC_H */ libvc-012/src/vc_parse.y000066400000000000000000000077461431702777700152750ustar00rootroot00000000000000/* * libvc - vCard library * Copyright (C) 2003 Andrew Hsu * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: vc_parse.y,v 1.2 2003/05/15 03:47:18 ahsu Rel $ */ %{ #include "vc.h" #include #include #include #include #define YYSTYPE char* extern FILE *yyin; extern int yylex (); void yyerror (char *s); extern long chars_in_buffer(); extern void flush_buffer(); extern void start_track_position(long *pos); extern void stop_track_position(); vc_component *current_vcard = NULL; vc_component *current_vc = NULL; char *current_vc_param_name = NULL; jmp_buf #if HAVE_VISIBILITY __attribute__((__visibility__("hidden"))) #endif scan_recovery; %} %start vcard %token TOK_BEGIN_VCARD %token TOK_END_VCARD %token TOK_GROUP %token TOK_NAME %token TOK_PARAM_NAME %token TOK_PARAM_VALUE %token TOK_VALUE %% vcard : begin_line contentlines end_line { YYACCEPT; } | error '\n' { yyerrok; } ; begin_line : filler first_line | first_line ; filler : filler '\n' | '\n' ; first_line : TOK_BEGIN_VCARD '\n' { current_vcard = vc_new (); } | TOK_GROUP '.' TOK_BEGIN_VCARD '\n' { current_vcard = vc_new (); vc_set_group (current_vcard, $1); } ; end_line : TOK_END_VCARD '\n' | TOK_GROUP '.' TOK_END_VCARD '\n' ; contentlines : contentlines group_contentline | group_contentline ; group_contentline : TOK_GROUP '.' contentline { vc_set_group (current_vc, $1); } | contentline ; contentline : name params ':' value '\n' | name ':' value '\n' ; name : TOK_NAME { current_vc = vc_append_with_name (current_vcard, $1); } ; params : ';' param | params ';' param ; param : param_name '=' param_values | param_name { vc_component_param *tmp_vc_param = NULL; tmp_vc_param = vc_param_new (); vc_param_set_name (tmp_vc_param, "TYPE"); vc_param_set_value (tmp_vc_param, current_vc_param_name); vc_add_param (current_vc, tmp_vc_param); } ; param_name : TOK_PARAM_NAME { if (NULL != current_vc_param_name) { free (current_vc_param_name); current_vc_param_name = NULL; } current_vc_param_name = strdup ($1); } ; param_values : param_value | param_values ',' param_value ; param_value : TOK_PARAM_VALUE { vc_component_param *tmp_vc_param = NULL; tmp_vc_param = vc_param_new (); vc_param_set_name (tmp_vc_param, current_vc_param_name); vc_param_set_value (tmp_vc_param, $1); vc_add_param (current_vc, tmp_vc_param); } ; value : TOK_VALUE { vc_set_value (current_vc, $1); } ; %% void yyerror (char *s) { } vc_component * parse_vcard_file (FILE * fp) { vc_component *vc = NULL; current_vcard = NULL; yyin = fp; long pos = ftell(fp); start_track_position(&pos); if (!setjmp (scan_recovery)) { if (0 == yyparse ()) { vc = current_vcard; } } fseek(yyin, pos, SEEK_SET); stop_track_position(); flush_buffer(); return vc; } libvc-012/src/vc_scan.l000066400000000000000000000123431431702777700150570ustar00rootroot00000000000000/* * libvc - vCard library * Copyright (C) 2003 Andrew Hsu * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: vc_scan.l,v 1.3 2003/06/04 10:53:59 ahsu Exp $ */ %{ #define YYSTYPE char* #include "vc_parse.h" #include /** * Functions to enable only buffering one card at a time */ long #if HAVE_VISIBILITY __attribute__((__visibility__("hidden"))) #endif *track_pos = NULL; #if HAVE_VISIBILITY __attribute__((__visibility__("hidden"))) #endif void start_track_position(long *pos) { track_pos = pos; } #if HAVE_VISIBILITY __attribute__((__visibility__("hidden"))) #endif void stop_track_position() { track_pos = NULL; } static void move_pos(char *read) { if (track_pos != NULL) *track_pos += strlen(read); } #if HAVE_VISIBILITY __attribute__((__visibility__("hidden"))) #endif void flush_buffer() { YY_FLUSH_BUFFER; } /**************************************** Recovery from fatal error in flex scan ****************************************/ #define YY_FATAL_ERROR(msg) vc_flex_fatal_error (msg); extern jmp_buf scan_recovery; extern void vc_set_error_message (char *); static void vc_flex_fatal_error (char *msg) { vc_set_error_message (msg); longjmp (scan_recovery, 1); } /* TODO: clean up the token definitions to match the rfc */ %} ALPHA [\x41-\x5A\x61-\x7A] CHAR [\x01-\x7F] CR \x0D LF \x0A CRLF {CR}{LF} DIGIT [\x30-\x39] DQUOTE \x22 HTAB \x09 SP \x20 VCHAR [\x21-\x7E] WSP {SP}|{HTAB} NON-ASCII [\x80-\xFF] SAFE-CHAR {WSP}|\x21|[\x23-\x2B]|[\x2D-\x39]|[\x3C-\x7E]|{NON-ASCII} VALUE-CHAR {WSP}|{VCHAR}|{NON-ASCII} NAME-CHAR [\x21-\x2B\x2D\x2F-\x39\x3C\x3E-\x5A\x5C\x5E-\x7E] %option noyywrap %x SC_VALUE SC_PARAM SC_PARAM_VALUE %% "BEGIN:VCARD" { move_pos("BEGIN:VCARD"); yylval = NULL; return TOK_BEGIN_VCARD; } "END:VCARD" { move_pos("END:VCARD"); yylval = NULL; return TOK_END_VCARD; } {LF} { move_pos("\n"); yylval = NULL; return yytext[0]; } "." { move_pos("."); yylval = NULL; return yytext[0]; } ({ALPHA}|{DIGIT}|-)+/"." { move_pos(yytext); yylval = yytext; return TOK_GROUP; } {NAME-CHAR}+ { move_pos(yytext); yylval = yytext; return TOK_NAME; } ";" { move_pos(";"); yylval = NULL; BEGIN(SC_PARAM); return yytext[0]; } ":" { move_pos(":"); yylval = NULL; BEGIN(SC_VALUE); return yytext[0]; } { ({VALUE-CHAR}|({CRLF}|{LF}){SP})* { move_pos(yytext); yylval = yytext; return TOK_VALUE; } {LF} { move_pos("\n"); yylval = NULL; BEGIN(INITIAL); return yytext[0]; } } { ({ALPHA}|{DIGIT}|-)+ { move_pos(yytext); yylval = yytext; return TOK_PARAM_NAME; } "=" { move_pos("="); yylval = NULL; BEGIN(SC_PARAM_VALUE); return yytext[0]; } ";" { move_pos(";"); yylval = NULL; BEGIN(SC_PARAM); return yytext[0]; } ":" { move_pos(":"); yylval = NULL; BEGIN(SC_VALUE); return yytext[0]; } } { {SAFE-CHAR}* { move_pos(yytext); yylval = yytext; return TOK_PARAM_VALUE; } "," { move_pos(","); yylval = NULL; return yytext[0]; } ";" { move_pos(";"); yylval = NULL; BEGIN(SC_PARAM); return yytext[0]; } ":" { move_pos(":"); yylval = NULL; BEGIN(SC_VALUE); return yytext[0]; } } %% libvc-012/test/000077500000000000000000000000001431702777700134535ustar00rootroot00000000000000libvc-012/test/Makefile.am000066400000000000000000000000771431702777700155130ustar00rootroot00000000000000if HAVE_SHUNIT2 TESTS = run-tests endif EXTRA_DIST = run-tests libvc-012/test/run-tests000077500000000000000000000014741431702777700153530ustar00rootroot00000000000000#!/bin/sh ### Exit immediately if a command exits with a non-zero status set -e ### Get the directory of this script CURDIR=$(dirname $0) ### Include and library flags. The values of these variables can be ### overriden by the respective ones in the environment. INC=${INC:--I ../src} LIB=${LIB:-../src/.libs/libvc.a} ### Define Compiler CC=${CC:-gcc} ### Test header inclusion test_header_inclusion() { src=$(mktemp --suffix .c) cat < $src #include EOF $CC -E $INC $src > /dev/null rm -f $src } ### Test call to the function vc_new test_vc_new() { src=$(mktemp --suffix .c) cat < $src #include int main () { vc_component *v; v = vc_new (); } EOF out=$(mktemp) $CC -o $out $INC $src $LIB $out rm -f $src $out } ### Launch the unit tests . shunit2