firestring/0000755000000000000000000000000010023641010011343 5ustar 00000000000000firestring/README0000644000000000000000000000204707713511012012240 0ustar 00000000000000FireString Library ------------------ (c) 2000 Ian Gulliver under the GNU Public License, Version 2. See GPL for more details. Parts of this library are taken from dstr and dconf, part of LibD: * Copyright (C) 2001-2002 Andres Salomon From libfirestring(3): "libfirestring is a string handling library that provides maximum length aware string handling functions to programs. Several functions provide saner interfaces than the standard libc functions. libfirestring also provides functions that are in most libc's but not provided for by ANSI C, enabling programmers to write ANSI C-compliant code while using such safe functions (strcasecmp, strncasecmp, snprintf). "libfirestring also includes functions for dealing with reading configuration files in an easy to program fashion." This library uses long long, which is part of the C99 standard (previously a GNU extension). Your compiler needs to support this in order for FireString to work. If you have questions or comments, you can reach me at ian@penguinhosting.net. firestring/GPL0000644000000000000000000004313107711512260011730 0ustar 00000000000000 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. firestring/firemake/0000755000000000000000000000000010023641010013126 5ustar 00000000000000firestring/firemake/binaries0000644000000000000000000000533310023641010014651 0ustar 00000000000000#!/bin/sh #require prefix #require strip #require makefiletop #phase config #phase makefile #after makefile_makefiletop case $PHASE in config) dispn "Reading firemake.binaries..." BINARIES=`cut -d ':' -f 1 firemake.binaries 2>/dev/null` disp "done" dispn "Reading firemake.sbinaries..." SBINARIES=`cut -d ':' -f 1 firemake.sbinaries 2>/dev/null` disp "done" dispn "Reading firemake.suidbinaries..." SUIDBINARIES=`cut -d ':' -f 1 firemake.suidbinaries 2>/dev/null` FULLBINARIES="$BINARIES $SBINARIES $SUIDBINARIES" dispn "Reading firemake.noinstall..." NOINSTALL=`cat firemake.noinstall 2>/dev/null` disp "done" ;; makefile) disp "Writing binary creation entries..." for BINARY in $FULLBINARIES; do dispn " $BINARY..." DEPS="`grep \"^$BINARY:\" firemake.binaries 2>/dev/null | cut -d ':' -f 2` `grep \"^$BINARY:\" firemake.sbinaries 2>/dev/null | cut -d ':' -f 2` `grep \"^$BINARY:\" firemake.suidbinaries 2>/dev/null | cut -d ':' -f 2`" $ECHO "$BINARY: $DEPS" $ECHO " $CC $FM_CFLAGS $FM_LDFLAGS -o $BINARY $DEPS $FM_STATICLIBS $FM_LIBS" $ECHO BINARYLIST="$BINARYLIST $BINARY" BINARY_CLEANLIST="$BINARY_CLEANLIST $BINARY $DEPS" disp "done" if module dependencies; then DEPPREPEND="$PREPEND" PREPEND="$PREPEND " customdeplist "$DEPS" PREPEND="$DEPPREPEND" fi done dispn "Writing binary index entry..." $ECHO "binaries: $BINARYLIST" $ECHO disp "done" disp "Writing binary install entries..." $ECHO "install_binaries: $BINARYLIST" for BINARY in $BINARIES; do $ECHO "$NOINSTALL" | grep "^$BINARY\$" >/dev/null 2>/dev/null if test "$?" = "0"; then disp " skipping $BINARY" else dispn " $BINARY..." $ECHO " $INSTALL $BINARY \$(BINDIR) $INSTALL_USER $INSTALL_GROUP 0755" if test "$STRIP" != ""; then $ECHO " $STRIP \$(BINDIR)/$BINARY" fi disp "done" fi done for BINARY in $SBINARIES; do $ECHO "$NOINSTALL" | grep "^$BINARY\$" >/dev/null 2>/dev/null if test "$?" = "0"; then disp " skipping $BINARY" else dispn " $BINARY..." $ECHO " $INSTALL $BINARY \$(SBINDIR) $INSTALL_USER $INSTALL_GROUP 0755" if test "$STRIP" != ""; then $ECHO " $STRIP \$(SBINDIR)/$BINARY" fi disp "done" fi done for BINARY in $SUIDBINARIES; do $ECHO "$NOINSTALL" | grep "^$BINARY\$" >/dev/null 2>/dev/null if test "$?" = "0"; then disp " skipping $BINARY" else dispn " $BINARY..." $ECHO " $INSTALL $BINARY \$(BINDIR) $INSTALL_USER $INSTALL_GROUP 4755" if test "$STRIP" != ""; then $ECHO " $STRIP \$(BINDIR)/$BINARY" fi disp "done" fi done $ECHO dispn "Writing binary cleanup entry..." $ECHO "clean_binaries:" $ECHO " rm -f $BINARY_CLEANLIST" $ECHO disp "done" ;; esac firestring/firemake/c990000644000000000000000000000157007660737511013511 0ustar 00000000000000#!/bin/sh #require cc #require cflags #phase init #after init_cc #after init_cflags #phase header case $PHASE in init) C99="0" dispn "Checking for C99 compatible compiler..." if test "`basename $CC`" = "gcc"; then VER=`$CC --version | head -1 | cut -d ' ' -f 3` MVER=`$ECHO "$VER" | cut -d '.' -f 1` if test "$MVER" -ge "3"; then disp "gcc $VER (>= 3.0.0) found, C99 support activated" C99="1" else disp "gcc $VER (< 3.0.0) found, no C99 support" fi else disp "compiler not gcc, no C99 support" fi if test "$C99" = "1"; then disp "Adding \"-std=c99\" to CFLAGS" FM_CFLAGS="$FM_CFLAGS -std=c99" fi ;; header) if test "$C99" = "0"; then disp "Removing \"inline\" and \"restrict\" keyworks from source" $ECHO "#define inline" $ECHO "#define restrict" else disp "C99 is supported, no header changes needed" fi ;; esac firestring/firemake/cc0000644000000000000000000000054010016724024013446 0ustar 00000000000000#!/bin/sh #phase init dispn "Checking for a compiler..." if test "$CC" != ""; then disp "found in environment: \"$CC\"" elif (gcc --version >/dev/null 2>/dev/null; test "$?" = "0"); then disp "found gcc" CC="gcc" elif (CC=`which cc`; test "$?" = "0" -a -x "$CC"); then disp "found cc" CC="cc" else disp "not found, unable to continue" exit 1 fi firestring/firemake/cflags0000644000000000000000000000102007660737511014332 0ustar 00000000000000#!/bin/sh #require cc #phase init #after init_cc dispn "Attempting to determine correct CFLAGS..." if test ! "$CFLAGS" = ""; then disp "CFLAGS provided by environment: \"$CFLAGS\"" FM_CFLAGS="$CFLAGS" elif test "`basename $CC`" = "gcc"; then disp "compiler is gcc, using \"-O20 -fstrict-aliasing -funroll-loops -fexpensive-optimizations -fomit-frame-pointer\"" FM_CFLAGS="-O20 -fstrict-aliasing -funroll-loops -fexpensive-optimizations -fomit-frame-pointer" else disp "compiler is unknown, using \"-O\"" FM_CFLAGS="-O" fi firestring/firemake/compiletest0000644000000000000000000000504107777066361015441 0ustar 00000000000000#!/bin/sh #require cc #require cflags #phase library disp "Loading compile testing helper function" rm -f compiletest.log library_test() { $ECHO "$1" > compiletest.c $ECHO " == START PROGRAM == $1 == END PROGRAM ==" >>compiletest.log $ECHO "== EXECUTING: $CC $FM_CFLAGS $2 -c -o compiletest.o compiletest.c $3 == " >>compiletest.log $CC $FM_CFLAGS $2 -c -o compiletest.o compiletest.c $3 >>compiletest.log 2>>compiletest.log if test "$?" = "0"; then rm -f compiletest.o compiletest.c $ECHO "== COMPILE OK ==" >>compiletest.log true return else rm -f compiletest.o compiletest.c $ECHO "== COMPILE FAIL ==" >>compiletest.log false return fi } shared_test() { $ECHO "$1" > compiletest.c $ECHO " == START PROGRAM == $1 == END PROGRAM ==" >>compiletest.log $ECHO "== EXECUTING: $CC $FM_CFLAGS $FM_LDFLAGS $FM_SHAREDFLAGS $2 -o compiletest.so compiletest.c $3 == " >>compiletest.log $CC $FM_CFLAGS $FM_LDFLAGS $FM_SHAREDFLAGS $2 -o compiletest.so compiletest.c $3 >>compiletest.log 2>>compiletest.log if test "$?" = "0"; then rm -f compiletest.so compiletest.c $ECHO "== COMPILE OK ==" >>compiletest.log true return else rm -f compiletest.so compiletest.c $ECHO "== COMPILE FAIL ==" >>compiletest.log false return fi } compile_test() { $ECHO "$1" > compiletest.c $ECHO " == START PROGRAM == $1 == END PROGRAM ==" >>compiletest.log $ECHO "== EXECUTING: $CC $FM_CFLAGS $FM_LDFLAGS $2 -o compiletest compiletest.c $3 == " >>compiletest.log $CC $FM_CFLAGS $FM_LDFLAGS $2 -o compiletest compiletest.c $3 >>compiletest.log 2>>compiletest.log if test "$?" = "0"; then $ECHO "== COMPILE OK ==" >>compiletest.log $ECHO "== EXECUTING: ./compiletest ==" >>compiletest.log ./compiletest >>compiletest.log 2>>compiletest.log if test "$?" = "0"; then rm -f compiletest compiletest.c $ECHO "== RUN OK ==" >>compiletest.log true return else rm -f compiletest compiletest.c $ECHO "== RUN FAIL ==" >>compiletest.log false return fi else rm -f compiletest compiletest.c $ECHO "== COMPILE FAIL ==" >>compiletest.log false return fi } compile_test_wrapper() { # Args: # $1 - Program # $2 - CFLAGS # $3 - LDFLAGS # $4 - LIBS if (compile_test "$1" "$2 $3" "$4" > /dev/null); then disp "found" if test "$2" != ""; then disp "Adding \"$2\" to CFLAGS" FM_CFLAGS="$FM_CFLAGS $2" fi if test "$3" != ""; then disp "Adding \"$3\" to LDFLAGS" FM_LDFLAGS="$FM_LDFLAGS $3" fi if test "$4" != ""; then disp "Adding \"$4\" to LIBS" FM_LIBS="$FM_LIBS $4" fi return 0 else return 1 fi } firestring/firemake/gcvt0000644000000000000000000000053407777066361014056 0ustar 00000000000000#!/bin/sh #require compiletest #require cflags #phase init #after init_cflags case $PHASE in init) dispn "Checking for gcvt()..." PROGRAM="#include int main () { char buf[16]; gcvt(1.0,8,buf); return 0; }" compile_test_wrapper "$PROGRAM" "-DHAVE_GCVT" "" "" || \ disp "not found, some functionality may be missing" ;; esac firestring/firemake/headers0000644000000000000000000000072107763174445014522 0ustar 00000000000000#!/bin/sh #require prefix #require makefiletop #phase config #phase makefile #after makefile_makefiletop case $PHASE in config) dispn "Reading firemake.headers..." HEADERS=`cat firemake.headers 2>/dev/null` disp "done" ;; makefile) dispn "Writing header installation entry..." $ECHO "install_headers:" for HEADER in $HEADERS; do $ECHO " $INSTALL $HEADER \$(INCLUDEDIR) $INSTALL_USER $INSTALL_GROUP 0644" done $ECHO disp "done" ;; esac firestring/firemake/id0000644000000000000000000000035707660737511013503 0ustar 00000000000000#!/bin/sh #phase init dispn "Checking for id..." if /usr/xpg4/bin/id 2>/dev/null; then disp "found, /usr/xpg4/bin/id" ID="/usr/xpg4/bin/id" elif id 2>/dev/null; then disp "found, id" ID="id" else disp "not found, aborting" exit 1 fi firestring/firemake/install0000644000000000000000000000241707777066507014565 0ustar 00000000000000#!/bin/sh #require id #require makefiletop #phase init #after init_id #phase makefile #after makefile_makefiletop case $PHASE in init) dispn "Creating installation script..." $ECHO "#!/bin/sh FILENAME="\$2/\`basename \$1\`" mkdir -p \$2 cp -f \$1 \$FILENAME chown \$3:\$4 \$FILENAME chmod \$5 \$FILENAME" > copy.sh chmod 0755 copy.sh INSTALL="./copy.sh" disp "done" dispn "Checking for installation username..." INSTALL_GROUP=`$ID -ng root` if test "$?" = "0"; then INSTALL_USER=root disp "found, \"root\"" else disp "none found, aborting" exit 1 fi dispn "Checking for installation group name..." if test "$INSTALL_GROUP" = ""; then disp "none found, aborting" exit 1 else disp "found, \"$INSTALL_GROUP\"" fi ;; makefile) dispn "Writing install entry..." $ECHO -n "install:" if module binaries; then $ECHO -n " install_binaries" fi if module libraries; then $ECHO -n " install_libraries" fi if module man; then $ECHO -n " install_man" fi if module headers; then $ECHO -n " install_headers" fi if module conf; then $ECHO -n " install_conf" fi $ECHO $ECHO disp "done" dispn "Writing install cleanup entry..." $ECHO "clean_install:" $ECHO " rm -f $INSTALL" $ECHO disp "done" ;; esac firestring/firemake/libraries0000644000000000000000000000625310016724024015044 0ustar 00000000000000#!/bin/sh #require prefix #require compiletest #require cflags #require version #phase init #after init_cflags #phase config #phase makefile #after makefile_makefiletop case $PHASE in init) PROGRAM="int foo() { return 0; }" dispn "Checking if your compiler supports -fPIC..." if library_test "$PROGRAM" "-fPIC" ""; then disp "yes, adding \"-fPIC\" to CFLAGS" FM_CFLAGS="$FM_CFLAGS -fPIC" else disp "no, hoping we don't need it" fi dispn "Checking if your compiler supports -shared..." if shared_test "$PROGRAM" "-shared" ""; then disp "yes, adding \"-shared\" to SHAREDFLAGS" FM_SHAREDFLAGS="$FM_SHAREDFLAGS -shared" else disp "no, hoping we don't need it" fi dispn "Checking if your compiler supports -dynamiclib -lcc_dynamic..." # this is a bad hack for Darwin if shared_test "$PROGRAM" "-dynamiclib" "-lcc_dynamic"; then disp "yes:" disp " Adding \"-dynamiclib\" to SHAREDFLAGS" FM_SHAREDFLAGS="$FM_SHAREDFLAGS -dynamiclib" disp " Adding \"-dynamiclib\" to SHAREDLIBS" FM_SHAREDLIBS="$FM_SHAREDLIBS -lcc_dynamic" else disp "no, hoping we don't need it" fi rm -f compiletest.c.* dispn "Checking for SONAME support..." if shared_test "$PROGRAM" "-Wl,-soname,testname.so.0" ""; then disp "yes" FM_SONAME="-Wl,-soname," else disp "no" FM_SONAME="" fi ;; config) dispn "Reading firemake.libraries..." LIBRARIES=`cut -d ':' -f 1 firemake.libraries 2>/dev/null` disp "done" ;; makefile) VERSION2=`$ECHO "$VERSION" | cut -d . -f 1-2` disp "Writing library creation entries..." for LIBRARY in $LIBRARIES; do dispn " $LIBRARY..." DEPS=`grep "^$LIBRARY:" firemake.libraries | cut -d ':' -f 2` $ECHO "$LIBRARY: $LIBRARY.a $LIBRARY.so.$VERSION" $ECHO $ECHO "$LIBRARY.a: $DEPS" $ECHO " rm -f $LIBRARY.a" $ECHO " ar cru $LIBRARY.a $DEPS $FM_STATICLIBS" $ECHO " ranlib $LIBRARY.a || $ECHO \"Ignore ranlib errors.\"" $ECHO if test "$FM_SONAME" != ""; then SOTEMP="$FM_SONAME$LIBRARY.so.$VERSION2" else SOTEMP="" fi $ECHO "$LIBRARY.so.$VERSION: $DEPS" $ECHO " $CC $FM_CFLAGS $FM_LDFLAGS $FM_SHAREDFLAGS $SOTEMP -o $LIBRARY.so.$VERSION $DEPS $FM_STATICLIBS $FM_LIBS $FM_SHAREDLIBS" $ECHO LIBRARYLIST="$LIRBRARYLIST $LIBRARY" LIBRARY_CLEANLIST="$LIBRARY_CLEANLIST ${LIBRARY}.a ${LIBRARY}.so.$VERSION $DEPS" disp "done" if module dependencies; then DEPPREPEND="$PREPEND" PREPEND="$PREPEND " customdeplist "$DEPS" PREPEND="$DEPPREPEND" fi done dispn "Writing library index entry..." $ECHO "libraries: $LIBRARYLIST" $ECHO disp "done" disp "Writing library install entries..." $ECHO "install_libraries: $LIBRARYLIST" for LIBRARY in $LIBRARIES; do dispn " $LIBRARY..." $ECHO " $INSTALL ${LIBRARY}.a \$(LIBDIR) $INSTALL_USER $INSTALL_GROUP 0755" $ECHO " $INSTALL ${LIBRARY}.so.$VERSION \$(LIBDIR) $INSTALL_USER $INSTALL_GROUP 0755" $ECHO " ln -sf ${LIBRARY}.so.$VERSION \$(LIBDIR)/${LIBRARY}.so.$VERSION2" $ECHO " ln -sf ${LIBRARY}.so.$VERSION \$(LIBDIR)/${LIBRARY}.so" disp "done" done $ECHO dispn "Writing library cleanup entry..." $ECHO "clean_libraries:" $ECHO " rm -f $LIBRARY_CLEANLIST" $ECHO disp "done" ;; esac firestring/firemake/makefiletop0000644000000000000000000000427507777066361015421 0ustar 00000000000000#!/bin/sh #require prefix #require make #phase makefile dispn "Writing Makefile top entries..." if test "$MAKE_CONDSET" = "y"; then $ECHO "PREFIX ?= $FM_PREFIX" if test "$FM_MANDIRSTRICT" = "y"; then $ECHO "MANDIR ?= $FM_MANDIR" else $ECHO "MANDIR ?= \$(PREFIX)/man" fi if test "$FM_CONFDIRSTRICT" = "y"; then $ECHO "CONFDIR ?= $FM_CONFDIR" else $ECHO "CONFDIR ?= \$(PREFIX)/etc" fi if test "$FM_BINDIRSTRICT" = "y"; then $ECHO "BINDIR ?= $FM_BINDIR" else $ECHO "BINDIR ?= \$(PREFIX)/bin" fi if test "$FM_SBINDIRSTRICT" = "y"; then $ECHO "SBINDIR ?= $FM_SBINDIR" else $ECHO "SBINDIR ?= \$(PREFIX)/sbin" fi if test "$FM_LIBDIRSTRICT" = "y"; then $ECHO "LIBDIR ?= $FM_LIBDIR" else $ECHO "LIBDIR ?= \$(PREFIX)/lib" fi if test "$FM_INCLUDEDIRSTRICT" = "y"; then $ECHO "INCLUDEDIR ?= $FM_INCLUDEDIR" else $ECHO "INCLUDEDIR ?= \$(PREFIX)/include" fi else $ECHO "PREFIX = $FM_PREFIX" $ECHO "MANDIR = $FM_MANDIR" $ECHO "CONFDIR = $FM_CONFDIR" $ECHO "BINDIR = $FM_BINDIR" $ECHO "SBINDIR = $FM_SBINDIR" $ECHO "LIBDIR = $FM_LIBDIR" $ECHO "INCLUDEDIR = $FM_INCLUDEDIR" fi $ECHO $ECHO "all:" if module subdir; then # make even inside parents; brute force dependency handling for SUBDIR in $FM_SUBDIRS; do $ECHO " cd $SUBDIR && \$(MAKE) all && cd .." done fi if module binaries; then $ECHO " \$(MAKE) binaries" fi if module libraries; then $ECHO " \$(MAKE) libraries" fi $ECHO $ECHO $ECHO ".c.o:" $ECHO " $CC $FM_CFLAGS -DCONFDIR=\"\\\"\$(CONFDIR)\\\"\" -DBINDIR=\"\\\"\$(BINDIR)\\\"\" -DSBINDIR=\"\\\"\$(SBINDIR)\\\"\" -DLIBDIR=\"\\\"\$(LIBDIR)\\\"\" -DMANDIR=\"\\\"\$(MANDIR)\\\"\" -c -o \$@ \$<" $ECHO $ECHO "clean:" if module subdir; then for SUBDIR in $FM_CLEAN_SUBDIRS; do $ECHO " cd $SUBDIR && \$(MAKE) clean && cd .." done fi if module binaries; then $ECHO " \$(MAKE) clean_binaries" fi if module libraries; then $ECHO " \$(MAKE) clean_libraries" fi $ECHO $ECHO "distclean:" $ECHO " \$(MAKE) clean" if module subdir; then for SUBDIR in $FM_CLEAN_SUBDIRS; do $ECHO " cd $SUBDIR && \$(MAKE) distclean && cd .." done fi if module install; then $ECHO " \$(MAKE) clean_install" fi $ECHO " rm -f Makefile compiletest.log dependencies.log firemake.h" $ECHO disp "done" firestring/firemake/man0000644000000000000000000000360207763174445013663 0ustar 00000000000000#!/bin/sh #require makefiletop #require prefix #phase config #phase makefile #after makefile_makefiletop case $PHASE in config) dispn "Checking for manpages for section 1..." MAN1=`ls man/*.1 2>/dev/null` disp "done" dispn "Checking for manpages for section 3..." MAN3=`ls man/*.3 2>/dev/null` disp "done" dispn "Checking for manpages for section 5..." MAN5=`ls man/*.5 2>/dev/null` disp "done" dispn "Checking for manpages for section 6..." MAN6=`ls man/*.6 2>/dev/null` disp "done" dispn "Checking for manpages for section 7..." MAN7=`ls man/*.7 2>/dev/null` disp "done" dispn "Checking for manpages for section 8..." MAN8=`ls man/*.8 2>/dev/null` disp "done" ;; makefile) disp "Writing manpage installation entries..." $ECHO "install_man:" if test "$MAN1" != ""; then dispn " Section 1..." for MAN in $MAN1; do $ECHO " $INSTALL $MAN \$(MANDIR)/man1 $INSTALL_USER $INSTALL_GROUP 0644" done disp "done" fi if test "$MAN3" != ""; then dispn " Section 3..." for MAN in $MAN3; do $ECHO " $INSTALL $MAN \$(MANDIR)/man3 $INSTALL_USER $INSTALL_GROUP 0644" done disp "done" fi if test "$MAN5" != ""; then dispn " Section 5..." for MAN in $MAN5; do $ECHO " $INSTALL $MAN \$(MANDIR)/man5 $INSTALL_USER $INSTALL_GROUP 0644" done disp "done" fi if test "$MAN6" != ""; then dispn " Section 6..." for MAN in $MAN6; do $ECHO " $INSTALL $MAN \$(MANDIR)/man6 $INSTALL_USER $INSTALL_GROUP 0644" done disp "done" fi if test "$MAN7" != ""; then dispn " Section 7..." for MAN in $MAN7; do $ECHO " $INSTALL $MAN \$(MANDIR)/man7 $INSTALL_USER $INSTALL_GROUP 0644" done disp "done" fi if test "$MAN8" != ""; then dispn " Section 8..." for MAN in $MAN8; do $ECHO " $INSTALL $MAN \$(MANDIR)/man8 $INSTALL_USER $INSTALL_GROUP 0644" done disp "done" fi $ECHO ;; esac firestring/firemake/math0000644000000000000000000000065607777066361014051 0ustar 00000000000000#!/bin/sh #require compiletest #require cflags #phase init #after init_cflags #phase header case $PHASE in init) dispn "Checking for math library..." PROGRAM="#include int main () { sin(1.0); return 0; }" compile_test_wrapper "$PROGRAM" "" "" "-lm" || \ { disp "not found, unable to continue" exit 1 } ;; header) disp "Adding \"#include \" to header" $ECHO "#include " ;; esac firestring/firemake/prefix0000644000000000000000000000376307763174445014415 0ustar 00000000000000#!/bin/sh #require cflags #phase init #after init_cflags dispn "Attempting to determine correct PREFIX..." if test ! "$PREFIX" = ""; then disp "PREFIX provided by environment: \"$PREFIX\"" FM_PREFIX="$PREFIX" else disp "prefix is unknown, using \"/usr/local\"" FM_PREFIX="/usr/local" fi dispn "Attempting to determine correct BINDIR..." if test ! "$BINDIR" = ""; then disp "BINDIR provided by environment: \"$BINDIR\"" FM_BINDIRSTRICT="y" FM_BINDIR="$BINDIR" else disp "bindir is unknown, deriving from PREFIX: \"$FM_PREFIX/bin\"" FM_BINDIR="$FM_PREFIX/bin" fi dispn "Attempting to determine correct SBINDIR..." if test ! "$SBINDIR" = ""; then disp "SBINDIR provided by environment: \"$SBINDIR\"" FM_SBINDIRSTRICT="y" FM_SBINDIR="$SBINDIR" else disp "sbindir is unknown, deriving from PREFIX: \"$FM_PREFIX/sbin\"" FM_SBINDIR="$FM_PREFIX/sbin" fi dispn "Attempting to determine correct MANDIR..." if test ! "$MANDIR" = ""; then disp "MANDIR provided by environment: \"$MANDIR\"" FM_MANDIRSTRICT="y" FM_MANDIR="$MANDIR" else disp "mandir is unknown, deriving from PREFIX: \"$FM_PREFIX/man\"" FM_MANDIR="$FM_PREFIX/man" fi dispn "Attempting to determine correct CONFDIR..." if test ! "$CONFDIR" = ""; then disp "CONFDIR provided by environment: \"$CONFDIR\"" FM_CONFDIRSTRICT="y" FM_CONFDIR="$CONFDIR" else disp "confdir is unknown, deriving from PREFIX: \"$FM_PREFIX/etc\"" FM_CONFDIR="$FM_PREFIX/etc" fi dispn "Attempting to determine correct LIBDIR..." if test ! "$LIBDIR" = ""; then disp "LIBDIR provided by environment: \"$LIBDIR\"" FM_LIBDIRSTRICT="y" FM_LIBDIR="$LIBDIR" else disp "libdir is unknown, deriving from PREFIX: \"$FM_PREFIX/lib\"" FM_LIBDIR="$FM_PREFIX/lib" fi dispn "Attempting to determine correct INCLUDEDIR..." if test ! "$INCLUDEDIR" = ""; then disp "INCLUDEDIR provided by environment: \"$INCLUDEDIR\"" FM_INCLUDEDIRSTRICT="y" FM_INCLUDEDIR="$INCLUDEDIR" else disp "includedir is unknown, deriving from PREFIX: \"$FM_PREFIX/include\"" FM_INCLUDEDIR="$FM_PREFIX/include" fi firestring/firemake/strip0000644000000000000000000000025507660737511014245 0ustar 00000000000000#!/bin/sh #phase init dispn "Checking for strip..." if strip -V 2>/dev/null; then disp "found strip" STRIP="strip" else disp "not found, continuing without" STRIP="" fi firestring/firemake/make0000644000000000000000000000041007763174445014017 0ustar 00000000000000#!/bin/sh #phase init dispn "Checking to see if make supports \"?=\"..." rm -f Makefile echo "PREFIX ?= /usr/local" > Makefile echo "all:" >> Makefile make >/dev/null 2>&1 if test "$?" = "0"; then disp "yes" MAKE_CONDSET="y" else disp "no" MAKE_CONDSET="n" fi firestring/firemake/version0000644000000000000000000000054207711277061014564 0ustar 00000000000000#!/bin/sh #require cflags #phase config dispn "Reading firemake.version..." VERSION=`cat firemake.version 2>/dev/null` if test "$?" = "0"; then disp "done, \"$VERSION\"" else disp "not found, using \"0.0.0\"" VERSION="0.0.0" fi dispn "Adding -DVERSION=\"\\\"$VERSION\\\"\" to CFLAGS..." FM_CFLAGS="$FM_CFLAGS -DVERSION=\"\\\"$VERSION\\\"\"" disp done firestring/firemake/dependencies0000644000000000000000000000345107773045515015534 0ustar 00000000000000#!/bin/sh #require cc #require cflags #phase library #phase init #after init_cflags case $PHASE in library) disp "Loading dependency helper function" rm -f dependencies.log customdeplist() { for DEP in $1; do JUNK=`$ECHO "$BUILTDEPS" | grep "$DEP"` if test "$?" != "0"; then # haven't built this one yet BUILTDEPS="$BUILTDEPS $DEP" CNAME=`echo "$DEP" | sed 's/\\.o\$/.c/'` customdeps "$CNAME" "$DEP" fi done } customdeps() { if test "$CC_DEPENDENCY" = "n"; then return fi dispn "Generating customized build rule for $1..." $ECHO "Generating dependencies with \"$CC $FM_CFLAGS -M $1\" (errors print below):" >> dependencies.log $CC $FM_CFLAGS -M $1 2>>dependencies.log if test "$?" != "0"; then disp "unable to generate dependencies; this file probably won't build. Aborting (check dependencies.log for details)" exit 1 fi $ECHO >> dependencies.log $ECHO " $CC $FM_CFLAGS -DCONFDIR=\"\\\"\$(CONFDIR)\\\"\" -DBINDIR=\"\\\"\$(BINDIR)\\\"\" -DSBINDIR=\"\\\"\$(SBINDIR)\\\"\" -DLIBDIR=\"\\\"\$(LIBDIR)\\\"\" -DMANDIR=\"\\\"\$(MANDIR)\\\"\" -c -o $2 $1" $ECHO disp "done" } ;; init) dispn "Checking for compiler dependency support..." $ECHO "#include int main() { return 0; }" > deptest.c $ECHO "Testing \"$CC $FM_CFLAGS -M deptest.c\":" >> dependencies.log DEPOUTPUT=`$CC $FM_CFLAGS -M deptest.c` RESULT="$?" $ECHO "Result is $RESULT" >> dependencies.log $ECHO "Output is: $DEPOUTPUT " >> dependencies.log if test "$RESULT" = "0"; then JUNK=`$ECHO "$DEPOUTPUT" | grep stdio` if test "$?" = "0"; then disp "found" CC_DEPENDENCY="y" else disp "found but broken, skipping" CC_DEPENDENCY="n" fi else disp "not found, skipping" CC_DEPENDENCY="n" fi rm -f deptest.c ;; esac firestring/configure0000755000000000000000000000521210023641010013252 0ustar 00000000000000#!/bin/sh #configure - FireMake configuratin script #Copyright (C) 2002 Ian Gulliver # #This program is free software; you can redistribute it and/or modify #it under the terms of version 2 of the GNU General Public License as #published by the Free Software Foundation. # #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 VERSION="1.9.9" ECHO=echo if test -f /usr/ucb/echo; then ECHO=/usr/ucb/echo fi disp() { if test ! "$LASTN" = "1"; then $ECHO -n "$PREPEND" 1>&2 fi LASTN="0" $ECHO "$1" 1>&2 } dispn() { if test ! "$LASTN" = "1"; then $ECHO -n "$PREPEND" 1>&2 fi LASTN="1" $ECHO -n "$1" 1>&2 } module() { test -f firemake/$1 } PHASES="library init config header makefile" disp "FireMake v$VERSION starting...."; disp disp "= Starting dependency check =" for MODULE in `ls firemake`; do REQ=`grep "^#require " firemake/$MODULE 2>/dev/null | cut -d ' ' -f 2`; if test "$?" = "0"; then # module has requirements, check that these modules exist for FILE in $REQ; do if test ! -f firemake/$FILE; then disp " Module $MODULE requires module $FILE which is not present; aborting" exit 1; fi done fi done disp "= Done with dependency check =" disp for PHASE in $PHASES; do disp "= Starting $PHASE phase =" case "$PHASE" in init) exec > /dev/null ;; config) exec > /dev/null ;; header) exec > firemake.h ;; makefile) exec > Makefile ;; esac NEWDATA="1" while test "$NEWDATA" = "1"; do NEWDATA="0" for MODULE in `ls firemake`; do $ECHO "$DID " | grep " ${PHASE}_${MODULE} " > /dev/null if test ! "$?" = "0"; then grep "^#phase $PHASE" firemake/$MODULE > /dev/null 2>/dev/null if test "$?" = "0"; then SAT="1" DEPS=`grep "^#after ${PHASE}_" firemake/$MODULE | cut -d ' ' -f 2`; if test "$?" = "0"; then #runtime dependencies for DEP in $DEPS; do $ECHO "$DID " | grep " ${DEP} " > /dev/null if test ! "$?" = "0"; then SAT="0" fi done fi if test "$SAT" = "1"; then # dependencies satisfied PREPEND=" " . firemake/$MODULE unset PREPEND DID="$DID ${PHASE}_${MODULE}" NEWDATA="1" fi fi fi done done disp "= Done with $PHASE phase =" disp done disp "Finished configuring. Now just run \"make\"" firestring/firemake.binaries0000644000000000000000000000003607505674730014675 0ustar 00000000000000tester: firestring.o tester.o firestring/firemake.headers0000644000000000000000000000001507506132775014510 0ustar 00000000000000firestring.h firestring/firemake.libraries0000644000000000000000000000003407505674730015053 0ustar 00000000000000libfirestring: firestring.o firestring/firemake.noinstall0000644000000000000000000000000707505674730015102 0ustar 00000000000000tester firestring/firemake.version0000644000000000000000000000000710023641010014532 0ustar 000000000000000.9.12 firestring/firestring.c0000644000000000000000000011241010023360406013671 0ustar 00000000000000/* firestring.c - FireString replacement string functions Copyright (C) 2000 Ian Gulliver This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. 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 Parts of this library are taken from dstr and dconf, part of LibD: * Copyright (C) 2001-2002 Andres Salomon */ #define _FIRESTRING_C #include #include #include #include #include #include #include #include #include #include "firemake.h" #include "firestring.h" #define max(a,b) (a > b ? a : b) #define min(a,b) (a < b ? a : b) static void firestring_int_errorhandler(); static const char tagstring[] = "$Id: firestring.c,v 1.107 2004/03/09 14:47:53 ian Exp $"; const char firestring_version[] = VERSION; static void (*error_handler)() = firestring_int_errorhandler; struct xml_encoding { char character; char *entity; }; static const char base64_encode_table[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; static const char base64_decode_table[] = { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 0, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 }; static const char hex_decode_table[] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 16, 16, 16, 16, 16, 16, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 }; #define XML_UNSAFE "<>\"&" #define XML_WORSTCASE 6 static const struct xml_encoding xml_decode_table[] = { { '<', "<" }, { '>', ">" }, { '"', """ }, { '&', "&" }, { ' ', " " }, { '\xa1', "¡" }, { '\xa2', "¢" }, { '\xa3', "£" }, { '\xa4', "¤" }, { '\xa5', "¥" }, { '\xa6', "¦" }, { '\xa7', "§" }, { '\xa8', "¨" }, { '\xa9', "©" }, { '\xaa', "ª" }, { '\xab', "«" }, { '\xac', "¬" }, { '\xad', "­" }, { '\xae', "®" }, { '\xaf', "¯" }, { '\xb0', "°" }, { '\xb1', "±" }, { '\xb2', "²" }, { '\xb3', "³" }, { '\xb4', "´" }, { '\xb5', "µ" }, { '\xb6', "¶" }, { '\xb7', "·" }, { '\xb8', "¸" }, { '\xb9', "¹" }, { '\xba', "º" }, { '\xbb', "»" }, { '\xbc', "¼" }, { '\xbd', "½" }, { '\xbe', "¾" }, { '\xbf', "¿" }, { '\xc0', "À" }, { '\xc1', "Á" }, { '\xc2', "Â" }, { '\xc3', "Ã" }, { '\xc4', "Ä" }, { '\xc5', "Å" }, { '\xc6', "Æ" }, { '\xc7', "Ç" }, { '\xc8', "È" }, { '\xc9', "É" }, { '\xca', "Ê" }, { '\xcb', "Ë" }, { '\xcc', "Ì" }, { '\xcd', "Í" }, { '\xce', "Î" }, { '\xcf', "Ï" }, { '\xd0', "Ð" }, { '\xd1', "Ñ" }, { '\xd2', "Ò" }, { '\xd3', "Ó" }, { '\xd4', "Ô" }, { '\xd5', "Õ" }, { '\xd6', "Ö" }, { '\xd7', "×" }, { '\xd8', "Ø" }, { '\xd9', "Ù" }, { '\xda', "Ú" }, { '\xdb', "Û" }, { '\xdc', "Ü" }, { '\xdd', "Ý" }, { '\xde', "Þ" }, { '\xdf', "ß" }, { '\xe0', "à" }, { '\xe1', "á" }, { '\xe2', "â" }, { '\xe3', "ã" }, { '\xe4', "ä" }, { '\xe5', "å" }, { '\xe6', "æ" }, { '\xe7', "ç" }, { '\xe8', "è" }, { '\xe9', "é" }, { '\xea', "ê" }, { '\xeb', "ë" }, { '\xec', "ì" }, { '\xed', "í" }, { '\xee', "î" }, { '\xef', "ï" }, { '\xf0', "ð" }, { '\xf1', "ñ" }, { '\xf2', "ò" }, { '\xf3', "ó" }, { '\xf4', "ô" }, { '\xf5', "õ" }, { '\xf6', "ö" }, { '\xf7', "÷" }, { '\xf8', "ø" }, { '\xf9', "ù" }, { '\xfa', "ú" }, { '\xfb', "û" }, { '\xfc', "ü" }, { '\xfd', "ý" }, { '\xfe', "þ" }, { '\xff', "ÿ" }, { '\0', NULL } }; static void firestring_int_errorhandler() { perror("Allocation failed"); exit(EXIT_FAILURE); } void firestring_set_error_handler(void (*e)()) { error_handler = e; } void *firestring_malloc(const size_t size) { char *output; output = malloc(size); if (output == NULL) error_handler(); return output; } void *firestring_realloc(void * old, const size_t new) { char *output; output = realloc(old,new); if (output == NULL) error_handler(); return output; } char *firestring_strdup(const char * restrict const input) { /* allocate and return pointer to duplicate string */ char * restrict output; size_t s; if (input == NULL) return NULL; s = strlen(input) + 1; output = firestring_malloc(s); memcpy(output,input,s); return(output); } void firestring_strncpy(char * restrict const to, const char * restrict const from, const size_t size) { strncpy(to,from,size); to[size - 1]= '\0'; return; } void firestring_strncat(char * restrict const to, const char * restrict const from, const size_t size) { size_t l; l = strlen(to); firestring_strncpy(&to[l],from,size - l); return; } static inline int showdate(char * const dest, const int space, const time_t t) { struct tm bt; int i; if (space < 18) return -1; localtime_r(&t,&bt); i = strftime(dest,18,"%Y%m%dT%H:%M:%S",&bt); if (i != 17) return -1; return 17; } static inline int shownum_unsigned(unsigned long long m, const int padzero, int numpad, char * const numbuf, const int space) { int power; /* smallest power of 10 greater than m */ long long multiple = 1; int r; char f; int i = 0; for (power = 0; multiple <= m; power++) multiple *= 10; /* fixup 0 case, which shouldn't really display in technical terms */ power = max(power,1); multiple = max(multiple,10); f = padzero == 1 ? '0' : ' '; if (power > space || numpad > space) return -1; if (power < numpad) { numpad -= power; for (; i < numpad; i++) numbuf[i] = f; } for (;power > 0; power--) { multiple /= 10; r = m / multiple; numbuf[i++] = '0' + r; m -= r * multiple; } return i; } static inline int shownum_funsigned(const double m, const int padzero, int numpad, char * const numbuf, const int space) { char f; int i,j; f = padzero == 1 ? '0' : ' '; if (numpad > space) return -1; j = numpad; if (j == 0) j = 6; if (space < j) j = space; #ifdef HAVE_GCVT gcvt((const double) m,j,numbuf); #else numbuf[0] = '\0'; #endif i = strlen(numbuf); if (i >= numpad) return i; memmove(&numbuf[numpad - i],numbuf,i); for (i = numpad - i; i; i--) numbuf[i-1] = f; return numpad; } static inline int shownum_signed(const long long n, const int padzero, const int numpad, char * const numbuf, const int space) { unsigned long long m; int i = 0; m = (unsigned long long) (n < 0 ? n * -1 : n); if ((long long) m != n) { numbuf[0] = '-'; i = shownum_unsigned(m,padzero,numpad - 1,&numbuf[1],space - 1); if (i == -1) return -1; else return i + 1; } else return shownum_unsigned(m,padzero,numpad,numbuf,space); } static inline int shownum_fsigned(const double n, const int padzero, const int numpad, char * const numbuf, const int space) { double m; int i = 0; m = n < 0.0 ? n * -1.0 : n; if (m != n) { numbuf[0] = '-'; i = shownum_funsigned(m,padzero,numpad - 1,&numbuf[1],space - 1); if (i == -1) return -1; else return i + 1; } else return shownum_funsigned(m,padzero,numpad,numbuf,space); } long firestring_fprintf(FILE * restrict stream, const char * restrict const format, ...) { va_list ap; long o; va_start(ap,format); o = firestring_vfprintfe(stream,&ESTR_D((char *)format),ap); va_end(ap); return o; } long firestring_fprintfe(FILE * restrict stream, const struct firestring_estr_t * restrict const format, ...) { va_list ap; long o; va_start(ap,format); o = firestring_vfprintfe(stream,format,ap); va_end(ap); return o; } long firestring_printf(const char * restrict const format, ...) { va_list ap; long o; va_start(ap,format); o = firestring_vfprintfe(stdout,&ESTR_D((char *)format),ap); va_end(ap); return o; } long firestring_printfe(const struct firestring_estr_t * restrict const format, ...) { va_list ap; long o; va_start(ap,format); o = firestring_vfprintfe(stdout,format,ap); va_end(ap); return o; } long firestring_snprintf(char * restrict const out, const long size, const char * restrict const format, ...) { va_list ap; struct firestring_estr_t o; va_start(ap,format); o.s = out; o.l = 0; o.a = size - 1; firestring_estr_vsprintf(&o,format,ap); va_end(ap); firestring_estr_0(&o); return o.l; } int firestring_strncasecmp(const char * restrict const s1, const char * restrict const s2, const long n) { long s; for (s = 0; s < n; s++) { if (tolower((unsigned char) s1[s]) != tolower((unsigned char) s2[s])) { if (tolower((unsigned char) s1[s]) < tolower((unsigned char) s2[s])) return -1; else return 1; } if (s1[s] == '\0') return 0; } return 0; } int firestring_strcasecmp(const char * restrict const s1, const char * restrict const s2) { /* case-insensitive string comparison, ignores tail of longer string */ size_t s; char c1, c2; for (s = 0; (s1[s] != '\0') && (s2[s] != '\0') && (tolower((unsigned char) s1[s]) == tolower((unsigned char) s2[s])); s++); c1 = tolower((unsigned char) s1[s]); c2 = tolower((unsigned char) s2[s]); if (c1 == c2) return 0; else if (c1 < c2) return -1; else return 1; } char *firestring_concat (const char * restrict const s, ...) { const char *curr; size_t len = 0; va_list va; char * restrict ret = NULL; /* get length */ va_start(va,s); curr = s; while (curr != NULL) { len += strlen(curr); curr = va_arg(va, const char *); } va_end(va); /* allocate string */ if (len) { ret = firestring_malloc(len + 1); *ret = '\0'; } /* copy */ va_start(va,s); curr = s; while (curr != NULL) { strcat(ret,curr); curr = va_arg(va, const char *); } va_end(va); return ret; } char *firestring_chomp(char *s) { /* remove trailing whitespace */ char *end = s; if (end != NULL) { end = &s[strlen(s) - 1]; while (isspace(*end)) { *end = '\0'; if (end == s) break; end--; } } return s; } char *firestring_chug(char * s) { /* ignore frontal whitespace */ if (s != NULL) { while (isspace(*s)) s++; } return s; } char *firestring_trim(char *s) { return firestring_chug(firestring_chomp(s)); } void firestring_estr_alloc(struct firestring_estr_t * const f, const long a) { if (a + 1 > UINT_MAX) { errno = EINVAL; error_handler(); } f->s = firestring_malloc(a + 1); f->a = a; f->l = 0; } void firestring_estr_expand(struct firestring_estr_t * const f, const long a) { if (f->a >= a) return; if (a + 1 > UINT_MAX) { errno = EINVAL; error_handler(); } f->s = firestring_realloc(f->s, a + 1); f->a = a; } void firestring_estr_free(struct firestring_estr_t * const f) { if (f->s != NULL) free(f->s); f->a = 0; f->l = 0; f->s = NULL; } void firestring_estr_0(struct firestring_estr_t * const f) { if (f->s != NULL) f->s[f->l] = '\0'; } int firestring_estr_read(struct firestring_estr_t * const f, const int fd) { long i; if (f->l == f->a) return 2; i = read(fd,&f->s[f->l],f->a - f->l); if (i == -1 && errno == EAGAIN) return 0; if (i <= 0) return 1; f->l += i; return 0; } long firestring_estr_sprintf(struct firestring_estr_t * restrict const o, const char * restrict const format, ...) { va_list ap; va_start(ap,format); return firestring_estr_vsprintfe(o,&ESTR_D((char *)format),ap); } long firestring_estr_sprintfe(struct firestring_estr_t * restrict const o, const struct firestring_estr_t * restrict const format, ...) { va_list ap; va_start(ap,format); return firestring_estr_vsprintfe(o,format,ap); } long firestring_estr_vsprintf(struct firestring_estr_t * restrict const o, const char * restrict const format, va_list ap) { return firestring_estr_vsprintfe(o,&ESTR_D((char *)format),ap); } long firestring_estr_vsprintfe(struct firestring_estr_t * restrict const o, const struct firestring_estr_t * restrict const format, va_list ap) { size_t f,tl; const char *tempchr; const struct firestring_estr_t *e; int b = 0; int padzero, numpad; int m; time_t t; #define SIGNED_NUMBER(type) \ m = shownum_signed((long long) va_arg(ap,type),padzero,numpad,&o->s[o->l],o->a - o->l); \ if (m == -1) \ b = 1; \ else \ o->l += m; #define UNSIGNED_NUMBER(type) \ m = shownum_unsigned((unsigned long long) va_arg(ap,type),padzero,numpad,&o->s[o->l],o->a - o->l); \ if (m == -1) \ b = 1; \ else \ o->l += m; #define FSIGNED_NUMBER(type) \ m = shownum_fsigned((double) va_arg(ap,type),padzero,numpad,&o->s[o->l],o->a - o->l); \ if (m == -1) \ b = 1; \ else \ o->l += m; o->l = 0; for (f = 0; f < format->l && o->l < o->a && b == 0; f++) { if (format->s[f] == '%') { padzero = 0; numpad = 0; eformatcheck: switch(format->s[++f]) { case '0': if (numpad == 0 && padzero == 0) { padzero = 1; goto eformatcheck; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': numpad = (numpad * 10) + (format->s[f] - '0'); goto eformatcheck; case 's': tempchr = va_arg(ap,const char *); if (tempchr == NULL) tempchr = "(null)"; tl = strlen(tempchr); if (tl + o->l > o->a) b = 1; else { memcpy(&o->s[o->l],tempchr,tl); o->l += tl; } break; case 'e': e = va_arg(ap,const struct firestring_estr_t *); if (e == NULL) break; if (e->l + o->l > o->a) b = 1; else { memcpy(&o->s[o->l],e->s,e->l); o->l += e->l; } break; case 'd': /* signed int */ SIGNED_NUMBER(int) break; case 'l': /* signed long */ SIGNED_NUMBER(long) break; case 'u': /* unsigned int */ UNSIGNED_NUMBER(unsigned int) break; case 'y': /* unsigned long */ UNSIGNED_NUMBER(unsigned long) break; case 'g': /* signed long long */ SIGNED_NUMBER(long long) break; case 'o': /* unsigned long long */ UNSIGNED_NUMBER(unsigned long long) break; case 'f': /* double */ FSIGNED_NUMBER(double); break; case 't': /* time */ t = va_arg(ap,time_t); m = showdate(&o->s[o->l],o->a - o->l,t); if (m == -1) b = 1; else o->l += m; break; case '%': o->s[o->l++] = '%'; break; } } else o->s[o->l++] = format->s[f]; } return o->l; } long firestring_vfprintf(FILE *stream, const char * restrict const format, va_list ap) { return firestring_vfprintfe(stream,&ESTR_D((char *)format),ap); } long firestring_vfprintfe(FILE *stream, const struct firestring_estr_t * restrict const format, va_list ap) { size_t f,tl; const char *tempchr; const struct firestring_estr_t *e; int padzero, numpad; #define NUMSTRING_MAX 256 char numbuf[NUMSTRING_MAX]; int out = 0; int m; time_t t; #undef SIGNED_NUMBER #undef UNSIGNED_NUMBER #undef FSIGNED_NUMBER #define SIGNED_NUMBER(type) \ m = shownum_signed((long long) va_arg(ap,type),padzero,numpad,numbuf,NUMSTRING_MAX); \ out += m; \ fwrite(numbuf,m,1,stream); #define UNSIGNED_NUMBER(type) \ m = shownum_unsigned((unsigned long long) va_arg(ap,type),padzero,numpad,numbuf,NUMSTRING_MAX); \ out += m; \ fwrite(numbuf,m,1,stream); #define FSIGNED_NUMBER(type) \ m = shownum_fsigned((double) va_arg(ap,type),padzero,numpad,numbuf,NUMSTRING_MAX); \ out += m; \ fwrite(numbuf,m,1,stream); for (f = 0; f < format->l; f++) { if (format->s[f] == '%') { padzero = 0; numpad = 0; eformatcheck: switch(format->s[++f]) { case '0': if (numpad == 0 && padzero == 0) { padzero = 1; goto eformatcheck; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': numpad = (numpad * 10) + (format->s[f] - '0'); goto eformatcheck; case 's': tempchr = va_arg(ap,const char *); if (tempchr == NULL) tempchr = "(null)"; tl = strlen(tempchr); out += tl; fwrite(tempchr,tl,1,stream); break; case 'e': e = va_arg(ap,const struct firestring_estr_t *); if (e == NULL) break; out += e->l; fwrite(e->s,e->l,1,stream); break; case 'd': /* signed int */ SIGNED_NUMBER(int) break; case 'l': /* signed long */ SIGNED_NUMBER(long) break; case 'u': /* unsigned int */ UNSIGNED_NUMBER(unsigned int) break; case 'y': /* unsigned long */ UNSIGNED_NUMBER(unsigned long) break; case 'g': /* signed long long */ SIGNED_NUMBER(long long) break; case 'o': /* unsigned long long */ UNSIGNED_NUMBER(unsigned long long) break; case 'f': /* double */ FSIGNED_NUMBER(double); break; case 't': /* time */ t = va_arg(ap,time_t); m = showdate(numbuf,NUMSTRING_MAX,t); fwrite(numbuf,m,1,stream); out += m; break; case '%': out++; fwrite("%",1,1,stream); break; } } else { out++; fwrite(&format->s[f],1,1,stream); } } return out; } long firestring_estr_strchr(const struct firestring_estr_t * const f, const char c, const long start) { long i; for (i = start; i < f->l; i++) if (f->s[i] == c) return i; return -1; } long firestring_estr_strstr(const struct firestring_estr_t * restrict const f, const char * restrict s, const long start) { long i; long l; l = strlen(s); for (i = start; i <= f->l - l; i++) if (memcmp(&f->s[i],s,l) == 0) return i; return -1; } long firestring_estr_stristr(const struct firestring_estr_t * restrict const f, const char * restrict s, const long start) { long i; long j; long l; l = strlen(s); for (i = start; i <= f->l - l; i++) { for (j = 0; j < l; j++) if (tolower(f->s[i+j]) != tolower(s[j])) break; if (j == l) return i; } return -1; } int firestring_estr_starts(const struct firestring_estr_t * restrict const f, const char * restrict const s) { return firestring_estr_estarts(f,&ESTR_D((char *)s)); } int firestring_estr_ends(const struct firestring_estr_t * restrict const f, const char * restrict const s) { return firestring_estr_eends(f,&ESTR_D((char *)s)); } int firestring_estr_strcasecmp(const struct firestring_estr_t * restrict const f, const char * restrict const s) { long i; if (f->l != strlen(s)) return 1; for (i = 0; i < f->l; i++) if (tolower(f->s[i]) != tolower(s[i])) return 1; return 0; } int firestring_estr_strcmp(const struct firestring_estr_t * restrict const f, const char * restrict const s) { long i; if (f->l != strlen(s)) return 1; for (i = 0; i < f->l; i++) if (f->s[i] !=s[i]) return 1; return 0; } int firestring_estr_strcpy(struct firestring_estr_t * restrict const f, const char * restrict const s) { long l; l = strlen(s); if (f->a < l) return 1; f->l = l; memcpy(f->s,s,l); return 0; } int firestring_estr_astrcpy(struct firestring_estr_t * restrict const f, const char * restrict const s) { long l; l = strlen(s); firestring_estr_expand(f,f->l + l); f->l = l; memcpy(f->s,s,l); return 0; } int firestring_estr_strcat(struct firestring_estr_t * restrict const f, const char * restrict const s) { long l; l = strlen(s); if (l + f->l > f->a) return 1; memcpy(&f->s[f->l],s,l); f->l += l; return 0; } int firestring_estr_astrcat(struct firestring_estr_t * restrict const f, const char * restrict const s) { long l; l = strlen(s); firestring_estr_expand(f,f->l + l); memcpy(&f->s[f->l],s,l); f->l += l; return 0; } int firestring_estr_estrcasecmp(const struct firestring_estr_t * restrict const t, const struct firestring_estr_t * restrict const f, const long start) { long i; if (f->l != t->l - start) return 1; for (i = 0; i < f->l; i++) if (tolower(f->s[i]) != tolower(t->s[i + start])) return 1; return 0; } int firestring_estr_estrncasecmp(const struct firestring_estr_t * restrict const t, const struct firestring_estr_t * restrict const f, const long length, const long start) { long i; for (i = 0; i < length; i++) if (tolower(f->s[i]) != tolower(t->s[i + start])) return 1; return 0; } int firestring_estr_estrcpy(struct firestring_estr_t * restrict const t, const struct firestring_estr_t * restrict const f, const long start) { if (f->l - start > t->a) return 1; t->l = f->l - start; memcpy(t->s,&f->s[start],t->l); return 0; } int firestring_estr_aestrcpy(struct firestring_estr_t * restrict const t, const struct firestring_estr_t * restrict const f, const long start) { firestring_estr_expand(t,f->l - start); return firestring_estr_estrcpy(t,f,start); } int firestring_estr_munch(struct firestring_estr_t * const t, const long length) { if (length > t->l) return 1; t->l -= length; memmove(t->s,&t->s[length],t->l); return 0; } void firestring_estr_chomp(struct firestring_estr_t * const s) { /* remove trailing whitespace */ while (s->l > 0 && isspace(s->s[s->l - 1])) s->l--; } void firestring_estr_chug(struct firestring_estr_t * const s) { /* remove leading whitespace */ while (s->l > 0 && isspace(s->s[0])) { s->s++; s->l--; s->a--; } } void firestring_estr_ip_chug(struct firestring_estr_t * const s) { /* remove leading whitespace in place */ long start = 0; while (start < s->l && isspace(s->s[start])) start++; memmove(s->s,&s->s[start],s->l - start); s->l -= start; } void firestring_estr_trim(struct firestring_estr_t * const s) { firestring_estr_chug(s); firestring_estr_chomp(s); } void firestring_estr_ip_trim(struct firestring_estr_t * const s) { firestring_estr_ip_chug(s); firestring_estr_chomp(s); } int firestring_estr_estrcmp(const struct firestring_estr_t * restrict const t, const struct firestring_estr_t * restrict const f, const long start) { long i; if (f->l != t->l - start) return 1; for (i = 0; i < f->l; i++) if (f->s[i] != t->s[i + start]) return 1; return 0; } int firestring_estr_estrcat(struct firestring_estr_t * restrict const t, const struct firestring_estr_t * restrict const f, const long start) { if (f->l - start + t->l > t->a) return 1; memcpy(&t->s[t->l],&f->s[start],f->l - start); t->l += f->l - start; return 0; } int firestring_estr_aestrcat(struct firestring_estr_t * restrict const t, const struct firestring_estr_t * restrict const f, const long start) { firestring_estr_expand(t,t->l + (f->l - start)); return firestring_estr_estrcat(t,f,start); } long firestring_estr_estrstr(const struct firestring_estr_t * restrict const haystack, const struct firestring_estr_t * restrict const needle, const long start) { long i,l; l = haystack->l - needle->l; for (i = start; i <= l; i++) { if (memcmp(&haystack->s[i],needle->s,needle->l) == 0) return i; } return -1; } long firestring_estr_estristr(const struct firestring_estr_t * restrict const haystack, const struct firestring_estr_t * restrict const needle, const long start) { long i,j,l; l = haystack->l - needle->l; for (i = start; i <= l; i++) { for (j = 0; j < needle->l; j++) if (tolower(haystack->s[i+j]) != tolower(needle->s[j])) break; if (j == needle->l) return i; } return -1; } int firestring_estr_estarts(const struct firestring_estr_t * restrict const f, const struct firestring_estr_t * restrict const s) { long i; if (f->l < s->l) return 1; for (i = 0; i < s->l; i++) if (tolower(f->s[i]) != tolower(s->s[i])) return 1; return 0; } int firestring_estr_eends(const struct firestring_estr_t * restrict const f, const struct firestring_estr_t * restrict const s) { long i,t; if (f->l < s->l) return 1; t = f->l - s->l; for (i = f->l - 1; i >= t; i--) if (tolower(f->s[i]) != tolower(s->s[i - t])) return 1; return 0; } int firestring_estr_replace(struct firestring_estr_t * const dest, const struct firestring_estr_t * const source, const struct firestring_estr_t * const to, const struct firestring_estr_t * const from) { int i = 0, oldi = 0; struct firestring_estr_t tempe; dest->l = 0; while ((i = firestring_estr_estrstr(source,from,i)) != -1) { tempe.s = &source->s[oldi]; tempe.l = tempe.a = i - oldi; if (firestring_estr_estrcat(dest,&tempe,0) != 0) return 1; if (firestring_estr_estrcat(dest,to,0) != 0) return 1; i = oldi = i + from->l; } tempe.s = &source->s[oldi]; tempe.l = tempe.a = source->l - oldi; if (firestring_estr_estrcat(dest,&tempe,0) != 0) return 1; return 0; } int firestring_estr_areplace(struct firestring_estr_t * const dest, const struct firestring_estr_t * const source, const struct firestring_estr_t * const to, const struct firestring_estr_t * const from) { int i = 0, oldi = 0; struct firestring_estr_t tempe; dest->l = 0; while ((i = firestring_estr_estrstr(source,from,i)) != -1) { tempe.s = &source->s[oldi]; tempe.l = tempe.a = i - oldi; if (firestring_estr_aestrcat(dest,&tempe,0) != 0) return 1; if (firestring_estr_aestrcat(dest,to,0) != 0) return 1; i = oldi = i + from->l; } tempe.s = &source->s[oldi]; tempe.l = tempe.a = source->l - oldi; if (firestring_estr_aestrcat(dest,&tempe,0) != 0) return 1; return 0; } int firestring_estr_tolower(struct firestring_estr_t * const dest, const struct firestring_estr_t * const source, const long start) { long i; if (source->l - start > dest->a) return 1; for (i = start; i < source->l; i++) dest->s[i - start] = tolower(source->s[i]); return 0; } int firestring_estr_toupper(struct firestring_estr_t * const dest, const struct firestring_estr_t * const source, const long start) { long i; if (source->l - start > dest->a) return 1; for (i = start; i < source->l; i++) dest->s[i - start] = toupper(source->s[i]); return 0; } int firestring_hextoi(const char * const input) { char o1, o2; o1 = hex_decode_table[(int)input[0]]; if (o1 == 16) return -1; o2 = hex_decode_table[(int)input[1]]; if (o2 == 16) return -1; return (o1 << 4) | o2; } int firestring_estr_base64_encode(struct firestring_estr_t * restrict const t, const struct firestring_estr_t * restrict const f) { long i; unsigned char *s, *d; s = (unsigned char *)f->s; d = (unsigned char *)t->s; if (f->l * 4 / 3 > t->a - 4) return 1; t->l = 0; for (i = 0; i < f->l - 2; i += 3) { d[t->l++] = base64_encode_table[s[i] >> 2]; d[t->l++] = base64_encode_table[(s[i] << 4 | s[i+1] >> 4) % 64]; d[t->l++] = base64_encode_table[(s[i+1] << 2 | s[i+2] >> 6) % 64]; d[t->l++] = base64_encode_table[s[i+2] % 64]; } if (i == f->l - 1) { d[t->l++] = base64_encode_table[s[i] >> 2]; d[t->l++] = base64_encode_table[(s[i] << 4) % 64]; d[t->l++] = '='; d[t->l++] = '='; } else if (i == f->l - 2) { d[t->l++] = base64_encode_table[s[i] >> 2]; d[t->l++] = base64_encode_table[(s[i] << 4 | s[i+1] >> 4) % 64]; d[t->l++] = base64_encode_table[(s[i+1] << 2) % 64]; d[t->l++] = '='; } return 0; } int firestring_estr_base64_decode(struct firestring_estr_t * const t, const struct firestring_estr_t * const f) { long i,j,o; unsigned char tempblock[4]; if (f->l * 3 / 4 > t->a - 3) return 1; o = 0; for (i = 0; i < f->l - 3; i += 4) { for (j = 0; j < 4; j++) { tempblock[j] = (unsigned char) f->s[i + j]; if (base64_decode_table[(int)tempblock[j]] == 64) { if (++i > f->l - 4) goto base64_end; j--; continue; } } t->s[o++] = base64_decode_table[(int)tempblock[0]] << 2 | base64_decode_table[(int)tempblock[1]] >> 4; t->s[o++] = base64_decode_table[(int)tempblock[1]] << 4 | base64_decode_table[(int)tempblock[2]] >> 2; t->s[o++] = base64_decode_table[(int)tempblock[2]] << 6 | base64_decode_table[(int)tempblock[3]]; } if (tempblock[3] == '=') o--; if (tempblock[2] == '=') o--; base64_end: t->l = o; return 0; } int firestring_estr_xml_encode(struct firestring_estr_t * restrict const t, const struct firestring_estr_t * restrict const f) { long i,j,k; if (t->a < f->l * XML_WORSTCASE) return 1; t->l = 0; for (i = 0; i < f->l; i++) { if (strchr(XML_UNSAFE,f->s[i])) { for (j = 0; xml_decode_table[j].entity != NULL; j++) if (xml_decode_table[j].character == f->s[i]) break; if (xml_decode_table[j].entity == NULL) return 1; k = strlen(xml_decode_table[j].entity); memcpy(&t->s[t->l],xml_decode_table[j].entity,k); t->l += k; } else t->s[t->l++] = f->s[i]; } return 0; } int firestring_estr_xml_decode(struct firestring_estr_t * const t, const struct firestring_estr_t * const f) { long i = 0, o = 0; long j,k,l; int tempint; if (t->a < f->l) return 1; while ((j = firestring_estr_strchr(f,'&',i)) != -1) { memmove(&t->s[o],&f->s[i],j - i); o += j - i; if (f->s[j + 1] == '#') { /* numeric */ k = firestring_estr_strchr(f,';',j + 1); if (k == -1) /* unterminated entity */ return 1; if (f->s[j + 2] == 'x') { /* hex */ j += 3; for (l = j; l < k; l += 2) { tempint = firestring_hextoi(&f->s[l]); if (tempint == -1) /* invalid hex */ return 1; t->s[o++] = tempint; } } else { /* decimal */ if (k - j < 3 || k - j > 5) return 1; /* too long or too short */ t->s[o++] = (char) atoi(&f->s[j + 2]); } i = k + 1; } else { /* symbolic */ for (l = 0; xml_decode_table[l].entity != NULL; l++) { k = strlen(xml_decode_table[l].entity); if (j + l < f->l && memcmp(&f->s[j],xml_decode_table[l].entity,k) == 0) break; } if (xml_decode_table[l].entity == NULL) /* unknown entity */ return 1; t->s[o++] = xml_decode_table[l].character; i = j + strlen(xml_decode_table[l].entity); } } memmove(&t->s[o],&f->s[i],f->l - i); t->l = o + (f->l - i); return 0; } /* strip quotes, escape chars, and trailing chars from the string. */ static enum firestring_conf_parse_line_result strip_quotes(char **line) { char *s, *last_quote = NULL; int escaped = 0; if (line == NULL || *line == NULL) return FSC_MALFORMED; /* if unquoted, just strip whitespace, and nothing else */ *line = firestring_chug(firestring_chomp(*line)); if (**line != '"') return FSC_VALID; /* if quoted, strip initial quote, locate the trailing quote, and get rid of escape chars */ *line = *line + 1; for (s = *line; *s != '\0'; s++) { switch (*s) { case '\\': escaped = 1; memmove(s, s + 1, strlen(s) - 1); if (*s == '\0') s--; /* force a break from the for loop */ else if (*s == '\n') { memmove(s, s + 1, strlen(s) - 1); /* drop newline from string */ s[strlen(s) - 2] = '\0'; } else if (s[0] == '\r' && s[1] == '\n') { memmove(s, s + 2, strlen(s) - 1); /* or dos-style CRLF crap */ s[strlen(s) - 3] = '\0'; } else s[strlen(s) - 1] = '\0'; break; case '"': if (!escaped) last_quote = s; escaped = 0; break; default: escaped = 0; } } if (last_quote == NULL) return FSC_INCOMPLETE; *last_quote = '\0'; return FSC_VALID; } /* handle include keyword; the way we detect infinite include loops is to add a conf variable w/ the filename. */ static enum firestring_conf_parse_line_result keyword_include_handler(char *line, struct firestring_conf_t **conf) { char *sig; line = firestring_chug(firestring_chomp(line)); sig = firestring_concat("inside_include_handler_", line, NULL); if (firestring_conf_find(*conf, sig) == NULL) { *conf = firestring_conf_add(*conf, sig, ""); *conf = firestring_conf_parse_next(line, *conf); *conf = firestring_conf_delete(*conf, sig); } free(sig); return FSC_VALID; } enum firestring_conf_parse_line_result firestring_conf_parse_line(const char *line, const struct firestring_conf_keyword_t keywords[], struct firestring_conf_t **conf, char **context) { enum firestring_conf_parse_line_result err; char *curr, *ptr, *var = NULL, *val = NULL; int i; if (context == NULL || conf == NULL) return FSC_MALFORMED; /* prepend previous line, if it was incomplete */ curr = firestring_concat(*context ? *context : "", line, NULL); ptr = firestring_chug(curr); /* check if the line starts w/ a keyword; if so, call the callback */ for (i=0; keywords[i].keyword != NULL; i++) { if (strncmp(keywords[i].keyword, ptr, strlen(keywords[i].keyword)) == 0) { if (keywords[i].callback != NULL) err = keywords[i].callback(ptr + strlen(keywords[i].keyword), conf); else err = FSC_VALID; goto done; } } /* not a keyword; must be an assignment. split apart. */ val = strchr(ptr, '='); if (val == NULL) { err = FSC_MALFORMED; goto done; } *val++ = '\0'; var = firestring_chomp(ptr); /* and finally, strip quotes */ err = strip_quotes(&val); done: if (err == FSC_INCOMPLETE) { ptr = *context; *context = firestring_concat(*context ? *context : "", line, NULL); if (ptr) free(ptr); } else if (*context != NULL) { free(*context); *context = NULL; } if (err == FSC_VALID) { *conf = firestring_conf_add(*conf, var, val); } free(curr); return err; } static struct firestring_conf_keyword_t default_keywords[] = { { "include ", &keyword_include_handler }, { "#", NULL }, /* ignore comments */ { NULL, NULL }, }; struct firestring_conf_t *firestring_conf_parse_next(const char * const filename, struct firestring_conf_t *prev) { struct firestring_conf_t *conf = prev; char buf[512], *ctx = NULL; FILE *fp; fp = fopen(filename, "r"); if (fp != NULL) { while (fgets(buf, sizeof(buf), fp) != NULL) { firestring_conf_parse_line(buf, default_keywords, &conf, &ctx); } fclose(fp); } return conf; } struct firestring_conf_t *firestring_conf_parse(const char * const filename) { return firestring_conf_parse_next(filename, NULL); } struct firestring_conf_t *firestring_conf_add(struct firestring_conf_t * restrict const next, const char * restrict const var, const char * restrict const value) { /* insert config val in list, return new list head */ struct firestring_conf_t *conf; if (var != NULL && value != NULL) { conf = firestring_malloc(sizeof(*conf)); conf->next = next; conf->var = firestring_strdup(var); conf->value = firestring_strdup(value); } else conf = next; return conf; } struct firestring_conf_t *firestring_conf_delete(struct firestring_conf_t *conf, const char *var) { struct firestring_conf_t *prev = NULL, *head = conf; while (conf != NULL) { if (firestring_strcasecmp(conf->var, var) == 0) { free(conf->var); free(conf->value); if (prev) prev->next = conf->next; if (head == conf) head = conf->next; free(conf); break; } prev = conf; conf = conf->next; } return head; } char *firestring_conf_find(const struct firestring_conf_t * restrict config, const char * restrict const var) { /* find in list and return pointer to config val */ return firestring_conf_find_next(config,var,NULL); } char *firestring_conf_find_next(const struct firestring_conf_t * restrict config, const char * restrict const var, const char * const prev) { int canreturn = 0; if (prev == NULL) canreturn = 1; while (config != NULL) { if (firestring_strcasecmp(config->var, var) == 0) { if (canreturn == 1) return config->value; else if (config->value == prev) canreturn = 1; } config = config->next; } return NULL; } void firestring_conf_free(struct firestring_conf_t * config) { struct firestring_conf_t *next; while (config != NULL) { next = config->next; free(config->var); free(config->value); free(config); config = next; } } firestring/firestring.h0000644000000000000000000002052310023360406013701 0ustar 00000000000000/* firestring.h - FireString string function declarations Copyright (C) 2000 Ian Gulliver This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. 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 */ #ifndef _FIRESTRING_H #define _FIRESTRING_H #include #include #include #include #ifndef _FIRESTRING_C extern const char *firestring_version; #endif #define ESTR_S(x) ((struct firestring_estr_t) { x, sizeof(x), sizeof(x) - 1 }) #define ESTR_D(x) ((struct firestring_estr_t) { x, strlen(x), strlen(x) }) struct firestring_conf_t { char *var; char *value; struct firestring_conf_t *next; }; enum firestring_conf_parse_line_result { FSC_INCOMPLETE = -1, FSC_VALID = 0, FSC_MALFORMED = 1, }; struct firestring_conf_keyword_t { const char *keyword; enum firestring_conf_parse_line_result (*callback)(char *line, struct firestring_conf_t **conf); }; struct firestring_estr_t { char *s; long a; long l; }; void firestring_set_error_handler(void (*e)()); void *firestring_malloc(const size_t size); void *firestring_realloc(void *old, const size_t new); char *firestring_strdup(const char * const input); void firestring_strncpy(char * const to, const char * const from, const size_t size); void firestring_strncat(char * const to, const char * const from, const size_t size); long firestring_printf(const char * const format, ...); long firestring_fprintf(FILE *stream, const char * const format, ...); long firestring_vfprintf(FILE *stream, const char * const format, va_list ap); long firestring_printfe(const struct firestring_estr_t * const format, ...); long firestring_fprintfe(FILE *stream, const struct firestring_estr_t * const format, ...); long firestring_vfprintfe(FILE *stream, const struct firestring_estr_t * const format, va_list ap); long firestring_snprintf(char * const out, const long size, const char * const format, ...); int firestring_strncasecmp(const char * const s1, const char * const s2, const long n); int firestring_strcasecmp(const char * const s1, const char * const s2); char *firestring_concat(const char *s, ...); char *firestring_chomp(char *s); char *firestring_chug(char *s); char *firestring_trim(char *s); int firestring_hextoi(const char * const input); /* estr functions */ void firestring_estr_alloc(struct firestring_estr_t * const f, const long a); void firestring_estr_expand(struct firestring_estr_t * const f, const long a); void firestring_estr_free(struct firestring_estr_t * const f); int firestring_estr_base64_encode(struct firestring_estr_t * const t, const struct firestring_estr_t * const f); int firestring_estr_base64_decode(struct firestring_estr_t * const t, const struct firestring_estr_t * const f); int firestring_estr_xml_encode(struct firestring_estr_t * const t, const struct firestring_estr_t * const f); int firestring_estr_xml_decode(struct firestring_estr_t * const t, const struct firestring_estr_t * const f); int firestring_estr_read(struct firestring_estr_t * const f, const int fd); long firestring_estr_sprintf(struct firestring_estr_t * const o, const char * const format, ...); long firestring_estr_vsprintf(struct firestring_estr_t * const o, const char * const format, va_list ap); long firestring_estr_sprintfe(struct firestring_estr_t * const o, const struct firestring_estr_t * const format, ...); long firestring_estr_vsprintfe(struct firestring_estr_t * const o, const struct firestring_estr_t * const format, va_list ap); long firestring_estr_strchr(const struct firestring_estr_t * const f, const char c, const long start); long firestring_estr_strstr(const struct firestring_estr_t * const f, const char * const s, const long start); long firestring_estr_stristr(const struct firestring_estr_t * const f, const char * const s, const long start); int firestring_estr_starts(const struct firestring_estr_t * const f, const char * const s); int firestring_estr_ends(const struct firestring_estr_t * const f, const char * const s); int firestring_estr_estarts(const struct firestring_estr_t * const f, const struct firestring_estr_t * const s); int firestring_estr_eends(const struct firestring_estr_t * const f, const struct firestring_estr_t * const s); int firestring_estr_strcasecmp(const struct firestring_estr_t * const f, const char * const s); int firestring_estr_strcmp(const struct firestring_estr_t * const f, const char * const s); int firestring_estr_strcpy(struct firestring_estr_t * const f, const char * const s); int firestring_estr_astrcpy(struct firestring_estr_t * const f, const char * const s); int firestring_estr_strcat(struct firestring_estr_t * const f, const char * const s); int firestring_estr_astrcat(struct firestring_estr_t * const f, const char * const s); int firestring_estr_estrcasecmp(const struct firestring_estr_t * const t, const struct firestring_estr_t * const f, const long start); int firestring_estr_estrncasecmp(const struct firestring_estr_t * const t, const struct firestring_estr_t * const f, const long length, const long start); int firestring_estr_estrcpy(struct firestring_estr_t * const t, const struct firestring_estr_t * const f, const long start); int firestring_estr_aestrcpy(struct firestring_estr_t * const t, const struct firestring_estr_t * const f, const long start); int firestring_estr_munch(struct firestring_estr_t * const t, const long length); void firestring_estr_chomp(struct firestring_estr_t * const s); void firestring_estr_chug(struct firestring_estr_t * const s); void firestring_estr_ip_chug(struct firestring_estr_t * const s); void firestring_estr_trim(struct firestring_estr_t * const s); void firestring_estr_ip_trim(struct firestring_estr_t * const s); int firestring_estr_estrcmp(const struct firestring_estr_t * const t, const struct firestring_estr_t * const f, const long start); int firestring_estr_estrcat(struct firestring_estr_t * const t, const struct firestring_estr_t * const f, const long start); int firestring_estr_aestrcat(struct firestring_estr_t * const t, const struct firestring_estr_t * const f, const long start); long firestring_estr_estrstr(const struct firestring_estr_t * const haystack, const struct firestring_estr_t * const needle, const long start); long firestring_estr_estristr(const struct firestring_estr_t * const haystack, const struct firestring_estr_t * const needle, const long start); int firestring_estr_replace(struct firestring_estr_t * const dest, const struct firestring_estr_t * const source, const struct firestring_estr_t * const to, const struct firestring_estr_t * const from); int firestring_estr_areplace(struct firestring_estr_t * const dest, const struct firestring_estr_t * const source, const struct firestring_estr_t * const to, const struct firestring_estr_t * const from); int firestring_estr_tolower(struct firestring_estr_t * const dest, const struct firestring_estr_t * const source, const long start); int firestring_estr_toupper(struct firestring_estr_t * const dest, const struct firestring_estr_t * const source, const long start); void firestring_estr_0(struct firestring_estr_t * const f); /* configuration system functions */ struct firestring_conf_t *firestring_conf_parse(const char * const filename); struct firestring_conf_t *firestring_conf_parse_next(const char * const filename, struct firestring_conf_t *prev); enum firestring_conf_parse_line_result firestring_conf_parse_line(const char *line, const struct firestring_conf_keyword_t keywords[], struct firestring_conf_t **conf, char **context); struct firestring_conf_t *firestring_conf_add(struct firestring_conf_t * const next, const char * const var, const char * const value); struct firestring_conf_t *firestring_conf_delete(struct firestring_conf_t *conf, const char *var); char *firestring_conf_find(const struct firestring_conf_t *config, const char * const var); char *firestring_conf_find_next(const struct firestring_conf_t *config, const char * const var, const char * const prev); void firestring_conf_free(struct firestring_conf_t *config); #endif firestring/tester.c0000644000000000000000000002720410023641010013022 0ustar 00000000000000#include #include #include #include #include #include #include "firemake.h" #include "firestring.h" void error_handler() { fprintf(stderr,"Error handler functions properly\n"); } int main() { char buffer[1024]; long long i = 1024; struct firestring_estr_t out, in; struct firestring_conf_t *value; int f; firestring_estr_alloc(&out,1000); firestring_estr_alloc(&in,200); firestring_estr_sprintf(&out,"-5551212: '%d'\n",-5551212); write(1,out.s,out.l); firestring_snprintf(buffer,1024,"8675309: '%d'\n",8675309); printf("%s",buffer); firestring_snprintf(buffer,1024,"-5551212: '%d'\n",-5551212); printf("%s",buffer); firestring_snprintf(buffer,1024,"3: '%d'\n",3); printf("%s",buffer); firestring_snprintf(buffer,1024,"0: '%d'\n",0); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%3d (3): '%3d'\n",3); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%3d (0): '%3d'\n",0); printf("%s",buffer); firestring_snprintf(buffer,1024,"5.9382: '%f'\n",5.9382); printf("%s",buffer); firestring_snprintf(buffer,1024,"-5.9382: '%f'\n",-5.9382); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%10f (-5.9382): '%10f'\n",-5.9382); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%010f (-5.9382): '%010f'\n",-5.9382); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%4f (-5.9382): '%4f'\n",-5.9382); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%4f (5.9382): '%4f'\n",5.9382); printf("%s",buffer); firestring_snprintf(buffer,1024,"38: '%d'\n",38); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%03d (1): '%03d'\n",1); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%050d (-123456): '%050d'\n",-123456); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%010d (-123456): '%010d'\n",-123456); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%50d (-123456): '%50d'\n",-123456); printf("%s",buffer); firestring_snprintf(buffer,1024,"%%s %%d %%s %%d %%s %%s: %s %d %s %d %s %s\n","foo",2002,"bar",38,"fluffernutter","humbug"); printf("%s",buffer); firestring_snprintf(buffer,1024,"the cow says moo: '%s'\n","the cow says moo"); printf("%s",buffer); firestring_snprintf(buffer,1024,"(null): '%s'\n",NULL); printf("%s",buffer); firestring_snprintf(buffer,1024,"long long bah: %g %s\n",i,"bah"); printf("%s",buffer); firestring_snprintf(buffer,5,"%d",1234); printf("5,1234: '%s'\n",buffer); firestring_snprintf(buffer,5,"%d",12345); printf("5,12345: '%s'\n",buffer); firestring_snprintf(buffer,6,"%s","foobar"); printf("6,foobar: '%s'\n",buffer); firestring_snprintf(buffer,7,"%s","foobar"); printf("7,foobar: '%s'\n",buffer); printf("'aardvark'/'zebra': %d\n",firestring_strcasecmp("aardvark","zebra")); printf("'zebra'/'aardvark': %d\n",firestring_strcasecmp("zebra","aardvark")); printf("'zebra'/'zebra': %d\n",firestring_strcasecmp("zebra","zebra")); printf("'zebra'/'zebra1': %d\n",firestring_strcasecmp("zebra","zebra1")); printf("'zebra1'/'zebra': %d\n",firestring_strcasecmp("zebra1","zebra")); printf("'zebra1'/'zebra' [5]: %d\n",firestring_strncasecmp("zebra1","zebra",5)); printf("'zebra1'/'zebra' [6]: %d\n",firestring_strncasecmp("zebra1","zebra",6)); printf("'zebra'/'zebra1' [6]: %d\n",firestring_strncasecmp("zebra","zebra1",6)); firestring_estr_strcpy(&in,"zebra"); firestring_estr_strcpy(&out,"zebra"); printf("'zebra' (e) in 'zebra': %ld\n",firestring_estr_estrstr(&in,&out,0)); firestring_estr_strcpy(&in,"ZeBrA"); firestring_estr_strcpy(&out,"zebra"); printf("'zebra' (e) in 'ZeBrA': %ld\n",firestring_estr_estrstr(&in,&out,0)); firestring_estr_strcpy(&in,"virus.exe"); firestring_estr_strcpy(&out,".exe"); printf("'.exe' (e) in 'virus.exe': %ld\n",firestring_estr_estrstr(&in,&out,0)); firestring_estr_strcpy(&in,"virus.exe.scr"); firestring_estr_strcpy(&out,".exe"); printf("'.exe' (e) in 'virus.exe.scr': %ld\n",firestring_estr_estrstr(&in,&out,0)); firestring_estr_strcpy(&in,"zebra"); firestring_estr_strcpy(&out,"zebra"); printf("'zebra' (ei) in 'zebra': %ld\n",firestring_estr_estristr(&in,&out,0)); firestring_estr_strcpy(&in,"ZeBrA"); firestring_estr_strcpy(&out,"zebra"); printf("'zebra' (ei) in 'ZeBrA': %ld\n",firestring_estr_estristr(&in,&out,0)); firestring_estr_strcpy(&in,"virus.exe"); firestring_estr_strcpy(&out,".exe"); printf("'.exe' (ei) in 'virus.exe': %ld\n",firestring_estr_estristr(&in,&out,0)); firestring_estr_strcpy(&in,"vIrUs.eXe"); firestring_estr_strcpy(&out,".exe"); printf("'.exe' (ei) in 'vIrUs.eXe': %ld\n",firestring_estr_estristr(&in,&out,0)); firestring_estr_strcpy(&in,"virus.exe.scr"); firestring_estr_strcpy(&out,".exe"); printf("'.exe' (ei) in 'virus.exe.scr': %ld\n",firestring_estr_estristr(&in,&out,0)); firestring_estr_strcpy(&in,"ViRuS.ExE.ScR"); firestring_estr_strcpy(&out,".exe"); printf("'.exe' (ei) in 'ViRuS.ExE.ScR': %ld\n",firestring_estr_estristr(&in,&out,0)); firestring_estr_strcpy(&in,"virus.exe"); printf("'.exe' in 'virus.exe': %ld\n",firestring_estr_strstr(&in,".exe",0)); firestring_estr_strcpy(&in,"ViRuS.ExE"); printf("'.exe' (i) in 'ViRuS.ExE': %ld\n",firestring_estr_stristr(&in,".exe",0)); firestring_estr_strcpy(&in,"ViRuS.ExE"); firestring_estr_strcpy(&out,".bat"); printf("'.bat' on the end of 'ViRuS.ExE': %d\n",firestring_estr_eends(&in,&out)); firestring_estr_strcpy(&in,"ViRuS.ExE"); firestring_estr_strcpy(&out,".exe"); printf("'.exe' on the end of 'ViRuS.ExE': %d\n",firestring_estr_eends(&in,&out)); firestring_estr_strcpy(&in,"ViRuS.ExE"); firestring_estr_strcpy(&out,"tbear"); printf("'tbear' on the start of 'ViRuS.ExE': %d\n",firestring_estr_estarts(&in,&out)); firestring_estr_strcpy(&in,"ViRuS.ExE"); firestring_estr_strcpy(&out,"virus"); printf("'virus' on the start of 'ViRuS.ExE': %d\n",firestring_estr_estarts(&in,&out)); firestring_estr_strcpy(&in,"\r.\r\n"); firestring_estr_strcpy(&out,".\r\n"); printf("'.\\r\\n' on the start of '\\r.\\r\\n': %d\n",firestring_estr_eends(&in,&out)); firestring_estr_strcpy(&in,"testuser1"); firestring_estr_base64_encode(&out,&in); firestring_estr_0(&out); printf("base64_encode('testuser1'): %s\n",out.s); firestring_estr_strcpy(&in,"testuser12"); firestring_estr_base64_encode(&out,&in); firestring_estr_0(&out); printf("base64_encode('testuser12'): %s\n",out.s); firestring_estr_strcpy(&in,"testuser123"); firestring_estr_base64_encode(&out,&in); firestring_estr_0(&out); printf("base64_encode('testuser123'): %s\n",out.s); firestring_estr_strcpy(&in,"dGVzdHVzZXIx"); firestring_estr_base64_decode(&out,&in); firestring_estr_0(&out); printf("base64_decode('dGVzdHVzZXIx'): %s\n",out.s); firestring_estr_strcpy(&in,"dGVzdHVzZXIxMg=="); firestring_estr_base64_decode(&out,&in); firestring_estr_0(&out); printf("base64_decode('dGVzdHVzZXIxMg=='): %s\n",out.s); firestring_estr_strcpy(&in,"dGVzdHVzZXIxMjM="); firestring_estr_base64_decode(&out,&in); firestring_estr_0(&out); printf("base64_decode('dGVzdHVzZXIxMjM='): %s\n",out.s); firestring_estr_strcpy(&in,"dGVzdHVzZXI\nxMjM="); firestring_estr_base64_decode(&in,&in); firestring_estr_0(&in); printf("base64_decode('dGVzdHVzZXI\\nxMjM=') -- in place: %s\n",in.s); firestring_estr_strcpy(&in,"Aladdin:open sesame"); firestring_estr_base64_encode(&out,&in); firestring_estr_0(&out); printf("base64_encode('Aladdin:open sesame'): %s\n",out.s); firestring_estr_strcpy(&in,"QWxhZGRpbjpvcGVuIHNlc2FtZQ=="); firestring_estr_base64_decode(&out,&in); firestring_estr_0(&out); printf("base64_decode('QWxhZGRpbjpvcGVuIHNlc2FtZQ=='): %s\n",out.s); firestring_estr_strcpy(&in,"QWxhZGRpbjpvcGVuIHNlc2FtZQ=="); firestring_estr_base64_decode(&in,&in); firestring_estr_0(&in); printf("base64_decode('QWxhZGRpbjpvcGVuIHNlc2FtZQ==') -- in place: %s\n",in.s); firestring_estr_strcpy(&in,"QWxhZGRpbjpvcGVuIHNlc2FtZQ=\n="); firestring_estr_base64_decode(&in,&in); firestring_estr_0(&in); printf("base64_decode('QWxhZGRpbjpvcGVuIHNlc2FtZQ=\\n=') -- in place: %s\n",in.s); firestring_estr_strcpy(&in,"QWxhZGRpbjpvcGVuIHNlc2FtZQ== "); firestring_estr_base64_decode(&in,&in); firestring_estr_0(&in); printf("base64_decode('QWxhZGRpbjpvcGVuIHNlc2FtZQ== ') -- in place: %s\n",in.s); f = open("/dev/urandom",O_RDONLY); if (f == -1) { perror("open"); exit(1); } if (read(f,in.s,200) != 200) { perror("read"); exit(1); } in.l = 200; firestring_estr_base64_encode(&out,&in); firestring_estr_0(&out); printf("base64_encode(random data): %s\n",out.s); firestring_estr_strcpy(&in,"test of xml decode"); firestring_estr_xml_decode(&out,&in); firestring_estr_0(&out); printf("xml_decode('test of xml decode'): %s\n",out.s); firestring_estr_strcpy(&in,"test of xml decode & foo"); firestring_estr_xml_decode(&out,&in); firestring_estr_0(&out); printf("xml_decode('test of xml decode & foo'): %s\n",out.s); firestring_estr_strcpy(&in,"test of xml decode & foo"); firestring_estr_xml_decode(&in,&in); firestring_estr_0(&in); printf("xml_decode('test of xml decode & foo') -- in place: %s\n",in.s); firestring_estr_strcpy(&in,""there is no spoon & the cat's in the cradle""); firestring_estr_xml_decode(&out,&in); firestring_estr_0(&out); printf("xml_decode('"there is no spoon & the cat's in the cradle"'): %s\n",out.s); firestring_estr_strcpy(&in," U ©"); firestring_estr_xml_decode(&out,&in); firestring_estr_0(&out); printf("xml_decode(' U ©'): %s\n",out.s); firestring_estr_strcpy(&in,""there is no spoon & the cat's in the cradle""); firestring_estr_xml_decode(&out,&in); firestring_estr_0(&out); printf("xml_decode('"there is no spoon & the cat's in the cradle"'): %s\n",out.s); firestring_estr_strcpy(&in," U ©"); firestring_estr_xml_decode(&out,&in); firestring_estr_0(&out); printf("xml_decode(' U ©'): %s\n",out.s); firestring_estr_strcpy(&in,"\"there is no spoon & the cat's <> in the cradle\""); firestring_estr_xml_encode(&out,&in); firestring_estr_0(&out); printf("xml_encode('\"there is no spoon & the cat's <> in the cradle\"'): %s\n",out.s); firestring_estr_strcpy(&in,"\"test of {replaceme} replace function {replaceme}\""); firestring_estr_replace(&out,&in,&(struct firestring_estr_t) { "REPLACED", 8, 8 },&(struct firestring_estr_t) { "{replaceme}", 11, 11 }); firestring_printf("replace('test of {replaceme} replace function {replaceme}\"','REPLACED','{replaceme}'): '%e'\n",&out); firestring_estr_strcpy(&in,"\"test of {replaceme} replace function {replaceme}\""); firestring_estr_replace(&out,&in,&(struct firestring_estr_t) { "REPLACED123456", 14, 14 },&(struct firestring_estr_t) { "{replaceme}", 11, 11 }); firestring_printf("replace('test of {replaceme} replace function {replaceme}\"','REPLACED123456','{replaceme}'): '%e'\n",&out); value = firestring_conf_parse("/tmp/firestring.conf"); printf("firestring_conf_parse('/tmp/firestring.conf') -- testvar: %s\n",value == NULL ? "failed" : firestring_conf_find(value,"testvar")); printf("firestring_conf_parse('/tmp/firestring.conf') -- testvar2: %s\n",value == NULL ? "failed" : firestring_conf_find(value,"testvar2")); { char *target_user = NULL; while ((target_user = firestring_conf_find_next(value,"target_user",target_user)) != NULL) printf("firestring_conf_find_next('target_user'): %s\n",target_user); } firestring_printf("firestring_printf() test\n"); firestring_fprintf(stderr,"firestring_fprintf() test\n"); firestring_estr_strcpy(&in,"this is an estr"); firestring_printf("test: %e\n",&in); firestring_printf("time: %t\n",time(NULL)); firestring_set_error_handler(error_handler); firestring_malloc(-1); firestring_estr_free(&in); firestring_estr_free(&out); return 0; } firestring/man/0000755000000000000000000000000010023641010012116 5ustar 00000000000000firestring/man/firestring_chomp.30000644000000000000000000000101307452476233015570 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_chomp 3 2002-03-31 .SH NAME firestring_chomp \- trim excess whitespace from the end of a string .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "char *firestring_chomp(char *" "s" ")" .SH DESCRIPTION firestring_chomp() removes any whitespace at the end of the string .IR s. The string is modified in place and returned as well. .SH RETURN VALUE .I s after having been modified. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_chug.30000644000000000000000000000100207452476233015406 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_chug 3 2002-03-31 .SH NAME firestring_chug \- trim excess whitespace from the beginning of a string .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "char *firestring_chug(char *" "s" ")" .SH DESCRIPTION firestring_chug() removes whitespace from the beginning of the string .I s and returns the result. .SH RETURN VALUE Returns .I s with any leading whitespace removed. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_concat.30000644000000000000000000000130307452476233015733 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_concat 3 2002-03-31 .SH NAME firestring_concat \- concatenate strings .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "char *firestring_concat(const char *" "s" ", " "..." ")" .SH DESCRIPTION firestring_concat() expects a set of .IR "const char *" 's to nil-terminated strings. It returns a dynamically allocated string containing all of the input strings concatenated. .SH RETURN VALUE A pointer to a dynamically allocated string. This string should be freed by passing the pointer to .BR free (3) when the program is finished with it, to avoid memory leaks. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_conf_add.30000644000000000000000000000141007452476233016220 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_conf_add 3 2002-03-31 .SH NAME firestring_conf_add \- add an entry to a configuration structure .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "struct firestring_conf_t *firestring_conf_add(struct firestring_conf_t *" "next" ", const char *" "var" ", const char *" "value" ")" .SH DESCRIPTION firestring_conf_add() adds an entry to the configuration structure .I next with variable name .I var and the value .IR value. This function is provided to allow programs to manually add configuration settings. .SH RETURN VALUE Returns a new pointer for the configuration structure. This pointer should be used in all future operations. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_conf_delete.30000644000000000000000000000134607660766255016751 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_conf_delete 3 2002-03-31 .SH NAME firestring_conf_delete \- remove an entry from a configuration structure .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "struct firestring_conf_t *firestring_conf_delete(struct firestring_conf_t *" "conf" ", const char *" "var" ")" .SH DESCRIPTION firestring_conf_delete() removes the entry named .I var from the configuration structure .IR conf . This function is provided to allow programs to manually remove configuration settings. .SH RETURN VALUE Returns a new pointer for the configuration structure. This pointer should be used in all future operations. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_conf_find.30000644000000000000000000000142307452476233016414 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_conf_find 3 2002-03-31 .SH NAME firestring_conf_find \- retrieve a value from a configuration structure .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "const char *firestring_conf_find(struct firestring_conf_t *" "config" ", const char *" "var" ")" .SH DESCRIPTION firestring_conf_find() retrieves the value of the variable .I var from the configuration structure .IR config. If there is more than one variable with the name .IR var, firestring_conf_find() returns the one with precedence (the last one added). .SH RETURN VALUE Returns a .I const char * to the value of the variable, or .I NULL if there is no variable by the name .IR var . .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_conf_find_next.30000644000000000000000000000160707455371107017453 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_conf_find_next 3 2002-03-31 .SH NAME firestring_conf_find_next \- retrieve an array value from a configuration structure .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "const char *firestring_conf_find_next(struct firestring_conf_t *" "config" ", const char *" "var" ", const char *" "prev" ")" .SH DESCRIPTION firestring_conf_find_next() retrieves a subsequent value of the variable .I var from the configuration structure .IR config. .I prev is a pointer previously returned by firestring_conf_find() or firestring_conf_find_next(). If .I prev is .IR NULL , firestring_conf_find_next() acts like firestring_conf_find(). .SH RETURN VALUE Returns a .I const char * to the next value of the variable, or .I NULL if there are no further values for .IR var . .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_conf_free.30000644000000000000000000000115207452616636016417 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_conf_free 3 2002-03-31 .SH NAME firestring_conf_free \- free memory used by a configuration structure .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_conf_free(struct firestring_conf_t *" "config" ")" .SH DESCRIPTION firestring_conf_free() frees all the memory used by the configuration structure .IR config. This will cause any pointers previously returned by firestring_conf_find() or firestring_conf_find_next() to be invalid. .SH RETURN VALUE Nothing. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_conf_parse.30000644000000000000000000000213007564040315016572 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_conf_parse 3 2002-03-31 .SH NAME firestring_conf_parse \- read and parse a configuration file .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "struct firestring_conf_t *firestring_conf_parse(const char *" "filename" ")" .SH DESCRIPTION firestring_conf_parse() attempts to read a configuration from .I filename and parse the results into a structure that it then returns. .HP The support configuration format is fairly flexible: .br # Configuration file example .br # These are comments .br variable_name = value .br variable_name2=value .br variable_name3="quoted value" .br variable_name4="array value 1" .br variable_name4="array value 2" .P .B include as a variable name is special; it causes firestring to parse the file referenced by the value, overriding any previous values (although they are still accessible as arrays). .SH RETURN VALUE Returns a pointer to a structure containing the data read from the config file, or .I NULL if the file cannot be opened. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_conf_parse_next.30000644000000000000000000000133307564040347017641 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_conf_parse_next 3 2002-11-11 .SH NAME firestring_conf_parse_next \- add on to a previously parsed file .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "struct firestring_conf_t *firestring_conf_parse_next(const char *" "filename" ", struct firestring_conf_t *" "previous" ")" .SH DESCRIPTION firestring_conf_parse_next() attempts to read a configuration from .I filename and add the results to the previous values, overriding that are already set. .SH RETURN VALUE Returns a pointer to a structure containing the data read from the config file, or .I NULL if the file cannot be opened. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_0.30000644000000000000000000000101107501263341015641 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_0 3 2002-06-10 .SH NAME firestring_estr_0 \- append a trailing nil to an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_estr_0(struct firestring_estr_t *" "estring" ")" .SH DESCRIPTION firestring_estr_0() appends a trailing nil ('\\0') to .I estring so that estring->s can be used in functions expecting normal C strings. .SH RETURN VALUE None. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_aestrcat.30000644000000000000000000000123107706774115017331 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_estrcat 3 2003-07-21 .SH NAME firestring_estr_aestrcat \- concatentate an estring onto another estring, expanding the destination if necessary .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_aestrcat(struct firestring_estr_t *" "destination" ", struct firestring_estr_t *" "source" ", int " "start" ")" .SH DESCRIPTION firestring_estr_aestrcat() copys the contents of .I source from the index .I start onto the end of .IR destination , expanding .I destination if necessary. .SH RETURN VALUE 0 .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_aestrcpy.30000644000000000000000000000122707706774115017362 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_aestrcpy 3 2003-07-21 .SH NAME firestring_estr_aestrcpy \- copy an estring into another estring, expanding the destination if necessary .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_aestrcpy(struct firestring_estr_t *" "destination" ", struct firestring_estr_t *" "source" ", int " "start" ")" .SH DESCRIPTION firestring_estr_aestrcpy() copys the contents of .I source from the index .I start into .IR destination , expanding .I destination to fit the data if necessary. .SH RETURN VALUE 0 .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_alloc.30000644000000000000000000000115207501255004016577 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_alloc 3 2002-06-10 .SH NAME firestring_estr_alloc \- allocate space for an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_estr_alloc(struct firestring_estr_t *" "estring" ", int " "size" ")" .SH DESCRIPTION firestring_estr_alloc() uses .BR firestring_malloc (3) to allocate .I size bytes in .IR estring . It resets the length of .I estring to 0 and stores the size with the string to facilitate safe operations later. .SH RETURN VALUE None. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_areplace.30000644000000000000000000000134207707003661017272 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_replace 3 2003-07-21 .SH NAME firestring_estr_replace \- Replace occurences of one string with another, allocating space if needed .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_replace(struct firestring_estr_t * const " dest ", const struct firestring_estr_t * const " source ", const struct firestring_estr_t * const " to ", const struct firestring_estr_t * const " from ) .SH DESCRIPTION firestring_estr_replace() copies .I source into .IR dest , replacing all instances from .I from with .IR to . It allocates more space in .I dest if needed. .SH RETURN VALUE 0 .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_astrcat.30000644000000000000000000000104307706774115017165 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_astrcat 3 2003-07-21 .SH NAME firestring_estr_astrcat \- concatenate a string onto an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_astrcat(struct firestring_estr_t *" "estring" ", const char *" "string" ")" .SH DESCRIPTION firestring_estr_astrcat() copys the contents of .I string onto the end of .IR estring , expanding .I estring if necessary. .SH RETURN VALUE 0 .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_astrcpy.30000644000000000000000000000107107706774115017212 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_astrcpy 3 2003-07-21 .SH NAME firestring_estr_astrcpy \- copy a string into an estring, expanding the destination if necessary .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_astrcpy(struct firestring_estr_t *" "estring" ", const char *" "string" ")" .SH DESCRIPTION firestring_estr_astrcpy() copys the contents of .I string into .IR estring , expanding .I estring if necessary. .SH RETURN VALUE 0 .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_base64_decode.30000644000000000000000000000162007564453006020107 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_base64_decode 3 2002-09-21 .SH NAME firestring_estr_base64_decode \- decode an estring encoded via base64 into another estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_base64_decode(struct firestring_estr_t *" "destination" ", struct firestring_estr_t *" "source" ")" .SH DESCRIPTION firestring_estr_base64_decode() decodes the contents of .I source using the base64 algorithm into .IR destination , provided that there is room in .IR destination . The minimum required space in destination is the length of source * 3 / 4 + 3. The buffers .I source and .I destination may be the same estring. .SH RETURN VALUE 0 if the string was decoded successfully; 1 if there was insufficient space in .I destination for the decoding to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_base64_encode.30000644000000000000000000000150407543171730020120 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_base64_encode 3 2002-09-21 .SH NAME firestring_estr_base64_encode \- encode an estring via base64 into another estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_base64_encode(struct firestring_estr_t *" "destination" ", struct firestring_estr_t *" "source" ")" .SH DESCRIPTION firestring_estr_base64_encode() encodes the contents of .I source using the base64 algorithm into .IR destination , provided that there is room in .IR destination . The minimum required space in destination is the length of source * 4 / 3 + 4. .SH RETURN VALUE 0 if the string was encoded successfully; 1 if there was insufficient space in .I destination for the encoding to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_chomp.30000644000000000000000000000100007713511012016602 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_chomp 3 2003-05-15 .SH NAME firestring_estr_chomp \- remove whitespace from the end of an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_estr_chomp(struct firestring_estr_t *" "string" ")" .SH DESCRIPTION firestring_estr_chomp shortens .I string until the string ends with a non-whitespace character or is empty. .SH RETURN VALUE None. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_ends.30000644000000000000000000000106007705600723016444 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_ends 3 2002-06-10 .SH NAME firestring_estr_ends \- check case-insensitively if an estring ends with a string .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_ends(struct firestring_estr_t *" "estring" ", const char *" "string" ")" .SH DESCRIPTION firestring_estr_ends() checks case-insensitively if .I string appears at the end of .IR estring . .SH RETURN VALUE 0 on success; 1 on failure. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_estrcasecmp.30000644000000000000000000000115207501262311020015 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_estrcasecmp 3 2002-06-10 .SH NAME firestring_estr_estrcasecmp \- compare two estrings case-insensitively .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_estrcasecmp(struct firestring_estr_t *" "estring1" ", struct firestring_estr_t *" "estring2" ", int " "start" ")" .SH DESCRIPTION firestring_estr_estrcasecmp() compares .I estring1 from .I start on with .I estring2 case-insensitively. .SH RETURN VALUE 0 if the strings match; 1 if they do not. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_estrcat.30000644000000000000000000000135207501262747017170 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_estrcat 3 2002-06-10 .SH NAME firestring_estr_estrcat \- concatentate an estring onto another estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_estrcat(struct firestring_estr_t *" "destination" ", struct firestring_estr_t *" "source" ", int " "start" ")" .SH DESCRIPTION firestring_estr_estrcat() copys the contents of .I source from the index .I start onto the end of .IR destination , provided that there is room in .IR destination . .SH RETURN VALUE 0 if the string was copied successfully; 1 if there was insufficient space in .I destination for the copy to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_estrcmp.30000644000000000000000000000102307505117574017174 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_estrcmp 3 2002-06-10 .SH NAME firestring_estr_estrcmp \- compare two estrings .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_estrcmp(struct firestring_estr_t *" "estring1" ", struct firestring_estr_t *" "estring1" ")" .SH DESCRIPTION firestring_estr_estrcmp() compares .I estring1 and .IR estring2 . .SH RETURN VALUE 0 if the strings match; 1 if they do not. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_estrcpy.30000644000000000000000000000132707501262747017216 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_estrcpy 3 2002-06-10 .SH NAME firestring_estr_estrcpy \- copy an estring into another estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_estrcpy(struct firestring_estr_t *" "destination" ", struct firestring_estr_t *" "source" ", int " "start" ")" .SH DESCRIPTION firestring_estr_estrcpy() copys the contents of .I source from the index .I start into .IR destination , provided that there is room in .IR destination . .SH RETURN VALUE 0 if the string was copied successfully; 1 if there was insufficient space in .I destination for the copy to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_estristr.30000644000000000000000000000132407501263223017367 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_estristr 3 2002-06-10 .SH NAME firestring_estr_estristr \- search for an estring case-insensitively in an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_estristr(struct firestring_estr_t *" "haystack" ", struct firestring_estr_t *" "needle" ", const int " "start" ")" .SH DESCRIPTION firestring_estr_estristr() searches .I haystack case-insensitively from the index .I start to the end of the string for the estring .IR needle . .SH RETURN VALUE The index of the beginning of the string on success; -1 if the string did not occur in the range. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_estrncasecmp.30000644000000000000000000000124407501262311020175 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_estrncasecmp 3 2002-06-10 .SH NAME firestring_estr_estrncasecmp \- compare two estring segments case-insensitively .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_estrncasecmp(struct firestring_estr_t *" "estring1" ", struct firestring_estr_t *" "estring2" ", int " "length" ", int " "start" ")" .SH DESCRIPTION firestring_estr_estrncasecmp() compares .I lengths bytes of .I estring1 from .I start on with .I estring2 case-insensitively. .SH RETURN VALUE 0 if the string segments match; 1 if they do not. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_estrstr.30000644000000000000000000000125207501263223017216 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_estrstr 3 2002-06-10 .SH NAME firestring_estr_estrstr \- search for an estring in an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_estrstr(struct firestring_estr_t *" "haystack" ", struct firestring_estr_t *" "needle" ", const int " "start" ")" .SH DESCRIPTION firestring_estr_estrstr() searches .I haystack from the index .I start to the end of the string for the estring .IR needle . .SH RETURN VALUE The index of the beginning of the string on success; -1 if the string did not occur in the range. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_expand.30000644000000000000000000000112607543171730016776 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_expand 3 2002-09-21 .SH NAME firestring_estr_expand \- expand an estring's space to a minimum length .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_estr_expand(struct firestring_estr_t *" "estring" ", int " "size" ")" .SH DESCRIPTION firestring_estr_expand() uses .BR firestring_realloc (3) to allocate at least .I size bytes in .IR estring . If .I estring is already this size or greater, it does nothing. .SH RETURN VALUE None. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_free.30000644000000000000000000000104407501255004016426 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_free 3 2002-06-10 .SH NAME firestring_estr_free \- free space allocated to an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_estr_free(struct firestring_estr_t *" "estring" ")" .SH DESCRIPTION firestring_estr_free() frees any space allocated to .I estring and stores a size of 0 with the string to prevent accidental writes back to the freed space. .SH RETURN VALUE None. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_munch.30000644000000000000000000000112007660766256016640 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_munch 3 2003-05-15 .SH NAME firestring_estr_munch \- remove characters from the beginning of an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_munch(struct firestring_estr_t *" "string" ", const long " length ")" .SH DESCRIPTION firestring_estr_munch removes the first .I length characters from .IR string. .SH RETURN VALUE 0 on success, non-zero if there were not enough characters in the string to begin with. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_read.30000644000000000000000000000135607501705226016434 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_read 3 2002-06-10 .SH NAME firestring_estr_read \- read from a file descriptor into an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_read(struct firestring_estr_t *" "estring" ", int " "fd" ")" .SH DESCRIPTION firestring_estr_read() .BR read (2)'s as much data as is available from .I fd and will fit in .I estring onto the end of the data that is already there. It updates the length of the string accordingly. .SH RETURN VALUE 0 on success. 1 with errno set properly if read returns an error or indicates EOF. 2 if there is no space in the buffer for further reads. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_replace.30000644000000000000000000000157407707003661017140 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_replace 3 2003-07-21 .SH NAME firestring_estr_replace \- Replace occurences of one string with another .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_replace(struct firestring_estr_t * const " dest ", const struct firestring_estr_t * const " source ", const struct firestring_estr_t * const " to ", const struct firestring_estr_t * const " from ) .SH DESCRIPTION firestring_estr_replace() copies .I source into .IR dest , replacing all instances from .I from with .IR to . If there is insufficient space in .IR dest , the function returns 1 and the contents of .I dest are undefined. .SH RETURN VALUE 0 if the replacement was successful; 1 if there was insufficient space in .I destination for the replacement to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_sprintf.30000644000000000000000000000123507660766256017222 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_sprintf 3 2003-05-15 .SH NAME firestring_estr_sprintf \- .BR snprintf (3) into an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_estr_sprintf(struct firestring_estr_t *" "out" ", const char * const " "format" ", " "..." ")" .SH DESCRIPTION firestring_estr_sprintf() behaves exactly like .BR firestring_snprintf (3) except that it writes to an estring (which contains the size internally, so size is not needed as a parameter). .SH RETURN VALUE Returns the number of bytes written to .IR out . .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_starts.30000644000000000000000000000110007501257614017027 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_starts 3 2002-06-10 .SH NAME firestring_estr_starts \- check case-insensitively if an estring starts with a string .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_starts(struct firestring_estr_t *" "estring" ", const char *" "string" ")" .SH DESCRIPTION firestring_estr_starts() checks case-insensitively if .I string appears at the beginning of .IR estring . .SH RETURN VALUE 0 on success; 1 on failure. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_strcasecmp.30000644000000000000000000000107207501260174017656 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_strcasecmp 3 2002-06-10 .SH NAME firestring_estr_strcasecmp \- compare an estring and a string case-insensitively .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_strcasecmp(struct firestring_estr_t *" "estring" ", const char *" "string" ")" .SH DESCRIPTION firestring_estr_strcasecmp() compares .I estring and .I string case-insensitively. .SH RETURN VALUE 0 if the strings match; 1 if they do not. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_strcat.30000644000000000000000000000122707504420305017011 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_strcat 3 2002-06-10 .SH NAME firestring_estr_strcat \- concatenate a string onto an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_strcat(struct firestring_estr_t *" "estring" ", const char *" "string" ")" .SH DESCRIPTION firestring_estr_strcat() copys the contents of .I string onto the end of .IR estring , provided that there is room in .IR estring . .SH RETURN VALUE 0 if the string was copied successfully; 1 if there was insufficient space in .I estring for the copy to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_strchr.30000644000000000000000000000121107501256747017025 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_strchr 3 2002-06-10 .SH NAME firestring_estr_strchr \- search for a character in an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_strchr(struct firestring_estr_t *" "estring" ", const char " "c" ", const int " "start" ")" .SH DESCRIPTION firestring_estr_strchr() searches .I estring from the index .I start to the end of the string for the character .IR c . .SH RETURN VALUE The index of the character found on success; -1 if the character did not occur in the range. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_strcmp.30000644000000000000000000000100607501261150017012 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_strcmp 3 2002-06-10 .SH NAME firestring_estr_strcmp \- compare an estring and a string .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_strcmp(struct firestring_estr_t *" "estring" ", const char *" "string" ")" .SH DESCRIPTION firestring_estr_strcmp() compares .I estring and .IR string . .SH RETURN VALUE 0 if the strings match; 1 if they do not. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_strcpy.30000644000000000000000000000120507501261662017037 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_strcpy 3 2002-06-10 .SH NAME firestring_estr_strcpy \- copy a string into an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_strcpy(struct firestring_estr_t *" "estring" ", const char *" "string" ")" .SH DESCRIPTION firestring_estr_strcpy() copys the contents of .I string into .IR estring , provided that there is room in .IR estring . .SH RETURN VALUE 0 if the string was copied successfully; 1 if there was insufficient space in .I estring for the copy to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_stristr.30000644000000000000000000000127507501257614017236 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_stristr 3 2002-06-10 .SH NAME firestring_estr_stristr \- search case-insensitively for a string in an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_stristr(struct firestring_estr_t *" "estring" ", const char *" "string" ", const int " "start" ")" .SH DESCRIPTION firestring_estr_stristr() searches .I estring case-insensitively from the index .I start to the end of the string for the string .IR string . .SH RETURN VALUE The index of the beginning of the string on success; -1 if the string did not occur in the range. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_strstr.30000644000000000000000000000122307501257130017047 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_strstr 3 2002-06-10 .SH NAME firestring_estr_strstr \- search for a string in an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_strstr(struct firestring_estr_t *" "estring" ", const char *" "string" ", const int " "start" ")" .SH DESCRIPTION firestring_estr_strstr() searches .I estring from the index .I start to the end of the string for the string .IR string . .SH RETURN VALUE The index of the beginning of the string on success; -1 if the string did not occur in the range. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_tolower.30000644000000000000000000000145107707006563017216 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_tolower 3 2003-07-21 .SH NAME firestring_estr_tolower \- convert all letters in an estring to lower case .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_tolower(struct firestring_estr_t *" "dest" ", struct firestring_estr_t *" "source" ", const long " start ")" .SH DESCRIPTION firestring_estr_tolower() copies the data in .I source starting at position .I start to .IR dest , replacing any uppercase characters with lowercase ones by using .IR tolower (3). .I source and .I dest can be the same string. .SH RETURN VALUE 0 if the string was copied successfully; 1 if there was insufficient space in .I destination for the copy to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_toupper.30000644000000000000000000000145107707006563017221 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_toupper 3 2003-07-21 .SH NAME firestring_estr_toupper \- convert all letters in an estring to upper case .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_toupper(struct firestring_estr_t *" "dest" ", struct firestring_estr_t *" "source" ", const long " start ")" .SH DESCRIPTION firestring_estr_toupper() copies the data in .I source starting at position .I start to .IR dest , replacing any lowercase characters with uppercase ones by using .IR toupper (3). .I source and .I dest can be the same string. .SH RETURN VALUE 0 if the string was copied successfully; 1 if there was insufficient space in .I destination for the copy to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_vsprintf.30000644000000000000000000000134407660766256017411 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_vsprintf 3 2003-05-15 .SH NAME firestring_estr_vsprintf \- .BR snprintf (3) into an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_estr_vsprintf(struct firestring_estr_t *" "out" ", const char * const " "format" ", va_list " ap ")" .SH DESCRIPTION firestring_estr_vsprintf() behaves exactly like .BR firestring_snprintf (3) except that it writes to an estring (which contains the size internally, so size is not needed as a parameter), and it takes an stdarg object instead of a list of arguments. .SH RETURN VALUE Returns the number of bytes written to .IR out . .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_xml_decode.30000644000000000000000000000164307543171730017626 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_xml_decode 3 2002-09-21 .SH NAME firestring_estr_xml_decode \- decode an estring from XML quoted data into ASCII into another estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_xml_decode(struct firestring_estr_t *" "destination" ", struct firestring_estr_t *" "source" ")" .SH DESCRIPTION firestring_estr_xml_decode() decodes the contents of .I source by converting XML entities back into their ASCII/ISO equivalents. It places the output in .IR destination , provided that there is room in .IR destination . The minimum required space in destination is the length of source; in fact, they can be the same estring. .SH RETURN VALUE 0 if the string was decoded successfully; 1 if there was insufficient space in .I destination for the decoding to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_xml_encode.30000644000000000000000000000154407543171730017640 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_xml_encode 3 2002-09-21 .SH NAME firestring_estr_xml_encode \- encode an estring into another estring for transmission inside XML data .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_xml_encode(struct firestring_estr_t *" "destination" ", struct firestring_estr_t *" "source" ")" .SH DESCRIPTION firestring_estr_xml_encode() encodes the contents of .I source by escaping characters that might trigger XML processing into .IR destination , provided that there is room in .IR destination . The minimum required space in destination is the length of source * 6. .SH RETURN VALUE 0 if the string was encoded successfully; 1 if there was insufficient space in .I destination for the encoding to occur. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_fprintf.30000644000000000000000000000111507660766256016145 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_fprintf 3 2003-05-15 .SH NAME firestring_fprintf \- .BR fprintf (3) with extended firestring types .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_fprintf(FILE * " stream ", const char * const " "format" ", " "..." ")" .SH DESCRIPTION firestring_fprintf() behaves exactly like .BR firestring_snprintf (3) except that it writes to the STDIO stream specified by .IR stream . .SH RETURN VALUE Returns the number of bytes written. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_hextoi.30000644000000000000000000000114107543171730015757 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_hextoi 3 2002-09-21 .SH NAME firestring_hextoi \- return a numerical value for a 2 digit hex string .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_hextoi(char *" "input" ")" .SH DESCRIPTION firestring_hextoi takes a string .I s with the first two characters as hex digits and converts the value to a integer. .SH RETURN VALUE Returns the hex value between 0 and 255 (inclusive), or -1 if the first two characters of .I s are not valid hex digits. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_malloc.30000644000000000000000000000134307451703045015730 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_malloc 3 2002-03-31 .SH NAME firestring_malloc \- .BR malloc (3) with internal result checking .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void *firestring_malloc(const size_t " "size" ")" .SH DESCRIPTION firestring_malloc() acts exactly like .BR malloc (3) except that it detects malloc failures, prints an error and .BR exit (3) with exit status EXIT_FAILURE. In most programs, malloc failures are unrecoverable, and this is the preferred behaviour. .SH RETURN VALUE If firestring_malloc() returns, it .B always returns a new memory area of .I size bytes. It .B never returns .IR NULL. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_printf.30000644000000000000000000000105007660766256015775 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_printf 3 2003-05-15 .SH NAME firestring_printf \- .BR printf (3) with extended firestring types .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_printf(const char * const " "format" ", " "..." ")" .SH DESCRIPTION firestring_printf() behaves exactly like .BR firestring_snprintf (3) except that it writes to the STDIO stream .IR stdout . .SH RETURN VALUE Returns the number of bytes written. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_realloc.30000644000000000000000000000144407451703045016104 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_realloc 3 2002-03-31 .SH NAME firestring_realloc \- .BR realloc (3) with internal result checking .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void *firestring_realloc(void *" "old" ", const size_t " "new" ")" .SH DESCRIPTION firestring_realloc() acts exactly like .BR realloc (3) except that it detects realloc failures, prints an error and .BR exit (3) with exit status EXIT_FAILURE. In most programs, realloc failures are unrecoverable, and this is the preferred behaviour. .SH RETURN VALUE If firestring_realloc() returns, it .B always returns a string of .I new bytes containing the data from .I old at the beginning. It .B never returns .IR NULL. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_set_error_handler.30000644000000000000000000000212507707003661020162 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_set_error_handler 3 2003-07-21 .SH NAME firestring_set_error_handler \- set the function to be called on an allocation failure .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_set_error_handler(void (*" "e" ")())" .SH DESCRIPTION firestring_set_error_handler() takes the name of a function that takes no parameters and returns void. This function will be called whenever firestring fails to allocate memory. As memory allocation failures are fatal to most programs, firestring does not return errors when functions fail to allocate memory; it simply calls this function, which it expects to call .I exit() or .I abort() or in some way terminate execution of the program. It probably is not safe to pass a function that returns, unless you have a framework in place for passing the allocation failure information back to the code calling the firestring function. The default function calls .I perror() and then .IR exit(). .SH RETURN VALUE None .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_snprintf.30000644000000000000000000000257707660766256016355 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_snprintf 3 2003-05-15 .SH NAME firestring_snprintf \- .BR snprintf (3) provided as a replacement so programs can maintain ANSI C compliance .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_snprintf(char * " "out" ", const size_t " "size" ", const char * const " "format" ", " "..." ")" .SH DESCRIPTION firestring_snprintf() writes a maximum of .I size bytes to .I out based on the formatting rules specified in .I format and the further arguments provided. .LP As .BR snprintf (3) is not a ANSI C function, firestring_snprintf() is provided as a replacement for programs wishing to maintain ANSI C compliance. It acts much like .BR snprintf (3), except that it only uses single-letter format tags, and only supports a subset of the common formats. .HP Formats supported: .br %s - char * .br %d - int .br %l - long .br %u - unsigned int .br %y - unsigned long .br %g - signed long long .br %o - unsigned long long .br %f - double .br %t - time_t (printed in ISO format) .br %e - struct firestring_estr_t * .LP The %s type handles NULL values by displaying the string "(null)". All numeric types support zero padding through the standard %02d format. .SH RETURN VALUE Returns the number of bytes written to .I out not including the trailing nil. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_strcasecmp.30000644000000000000000000000115007474172741016631 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_strcasecmp 3 2002-03-31 .SH NAME firestring_strcasecmp \- .BR strcasecmp (3) provided as a replacement so programs can maintain ANSI C compliance .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_strcasecmp(const char * const " "s1" ", const char * const " "s2" ")" .SH DESCRIPTION firestring_strcasecmp() compares .I s1 and .I s2 in a case insensitive fashion. .SH RETURN VALUE Returns .I -1 if s1 < s2, .I 1 if s1 > s2, and and .I 0 if the strings match. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_strdup.30000644000000000000000000000135007451703045016000 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_strdup 3 2002-03-31 .SH NAME firestring_strdup \- .BR strdup (3) with internal result checking .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "char *firestring_strdup(const char * const " "input" ")" .SH DESCRIPTION firestring_strdup() acts exactly like .BR strdup (3) except that it detects malloc failures, prints an error and .BR exit (3) with exit status EXIT_FAILURE. In most programs, malloc failures are unrecoverable, and this is the preferred behaviour. .SH RETURN VALUE If firestring_strdup() returns, it .B always returns a copy of the string .IR input . It .B never returns .IR NULL . .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_strncasecmp.30000644000000000000000000000130707660766256017022 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_strncasecmp 3 2003-05-15 .SH NAME firestring_strncasecmp \- .BR strncasecmp (3) provided as a replacement so programs can maintain ANSI C compliance .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_strncasecmp(const char * const " "s1" ", const char * const " "s2" ", const long " "n" ")" .SH DESCRIPTION firestring_strcasecmp() compares the first .I size bytes of .I s1 and .I s2 in a case insensitive fashion. .SH RETURN VALUE Returns .I -1 if the first .I n bytes of s1 < s2, .I 1 if the s2 segment > s1, and .I 0 if the strings segments do match. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_strncat.30000644000000000000000000000146107451703045016140 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_strncat 3 2002-03-31 .SH NAME firestring_strncat \- .BR strncat (3) with slightly saner semantics .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_strncat(char * const " "to" ", const char * const " "from" ", const size_t " "size" ")" .SH DESCRIPTION firestring_strncpy() acts like .BR strncat (3) except that .I to will always contain a trailing nil, even if the function runs out of space and the .I size argument is the maximum size of all of .IR to , not just the amount of space remaining in it. In simpler terms, firestring_strncat() appends the string .I from to .IR to , where .I to is a buffer of .I size bytes. .SH RETURN VALUE Always succeeds. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_strncpy.30000644000000000000000000000111307451703045016156 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_strncpy 3 2002-03-31 .SH NAME firestring_strncpy \- .BR strncpy (3) with slightly saner semantics .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_strncpy(char * const " "to" ", const char * const " "from" ", const size_t " "size" ")" .SH DESCRIPTION firestring_strncpy() acts like .BR strncpy (3) except that .I to will always contain a trailing nil, even if the function runs out of space. .SH RETURN VALUE Always succeeds. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_vfprintf.30000644000000000000000000000122107705600723016313 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_vfprintf 3 2003-05-15 .SH NAME firestring_vfprintf \- .BR vfprintf (3) with extended firestring types .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_vfprintf(FILE * " stream ", const char * const " "format" ", va_list " ap ")" .SH DESCRIPTION firestring_vfprintf() behaves exactly like .BR firestring_snprintf (3) except that it writes to the STDIO stream specified by .IR stream and accepts a stdarg object instead of a list of arguments. .SH RETURN VALUE Returns the number of bytes written. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/libfirestring.30000644000000000000000000000772310023641010015056 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH libfirestring 3 2002-03-31 .SH NAME libfirestring \- library for safe, fast string handling .SH SYNOPSIS .B #include .br .B -lfirestring .SH DESCRIPTION libfirestring is a string handling library that provides maximum length aware string handling functions to programs. Several functions provide saner interfaces than the standard libc functions. libfirestring also provides functions that are in most libc's but not provided for by ANSI C, enabling programmers to write ANSI C-compliant code while using such safe functions (strcasecmp, strncasecmp, snprintf). libfirestring provides a set of functions for dealing with EStrings. EStrings are binary-safe objects that, when used with the firestring functions, are overflow safe, because they include allocated memory size information with them. libfirestring also includes functions for dealing with reading configuration files in an easy to program fashion. .HP Miscellaneous functions: .br .BR firestring_malloc (3) .br .BR firestring_realloc (3) .HP Starting-letter keys (for String and EString functions): .br .I n Length-safe (takes a .B size argument) .br .I e EString (length-safe and binary-safe, takes a .B struct firestring_estr_t argument) .br .I i Case-insensitive .br .I a Automatically expands EString to correct size (possible memory DoS attack in some cases) .br .I s Writes into a provided instead of to a stream .br .I f Writes into a specified stream instead of to standard output .HP Base library functions: .br .BR firestring_set_error_handler (3) .HP String functions: .br .BR firestring_strdup (3) .br .BR firestring_strncpy (3) .br .BR firestring_strncat (3) .br .BR firestring_snprintf (3) .br .BR firestring_strncasecmp (3) .br .BR firestring_strcasecmp (3) .br .BR firestring_concat (3) .br .BR firestring_chomp (3) .br .BR firestring_chug (3) .br .BR firestring_trim (3) .br .BR firestring_hextoi (3) .HP EString functions: .br .BR firestring_estr_alloc (3) .br .BR firestring_estr_expand (3) .br .BR firestring_estr_free (3) .br .BR firestring_estr_read (3) .br .BR firestring_estr_sprintf (3) .br .BR firestring_estr_sprintfe (3) .br .BR firestring_estr_vsprintf (3) .br .BR firestring_estr_vsprintfe (3) .br .BR firestring_estr_printf (3) .br .BR firestring_estr_printfe (3) .br .BR firestring_estr_fprintf (3) .br .BR firestring_estr_fprintfe (3) .br .BR firestring_estr_vfprintf (3) .br .BR firestring_estr_vfprintfe (3) .br .BR firestring_estr_strchr (3) .br .BR firestring_estr_strstr (3) .br .BR firestring_estr_stristr (3) .br .BR firestring_estr_starts (3) .br .BR firestring_estr_estarts (3) .br .BR firestring_estr_ends (3) .br .BR firestring_estr_eends (3) .br .BR firestring_estr_strcasecmp (3) .br .BR firestring_estr_strcmp (3) .br .BR firestring_estr_strcpy (3) .br .BR firestring_estr_astrcpy(3) .br .BR firestring_estr_strcat (3) .br .BR firestring_estr_astrcat(3) .br .BR firestring_estr_estrcasecmp (3) .br .BR firestring_estr_estrncasecmp (3) .br .BR firestring_estr_estrcpy (3) .br .BR firestring_estr_aestrcpy (3) .br .BR firestring_estr_estrcat (3) .br .BR firestring_estr_aestrcat (3) .br .BR firestring_estr_estrstr (3) .br .BR firestring_estr_estristr (3) .br .BR firestring_estr_replace (3) .br .BR firestring_estr_areplace (3) .br .BR firestring_estr_toupper (3) .br .BR firestring_estr_tolower (3) .br .BR firestring_estr_munch (3) .br .BR firestring_estr_chomp (3) .br .BR firestring_estr_chug (3) .br .BR firestring_estr_trim (3) .br .BR firestring_estr_0 (3) .br .BR firestring_estr_base64_encode (3) .br .BR firestring_estr_base64_decode (3) .br .BR firestring_estr_xml_encode (3) .br .BR firestring_estr_xml_decode (3) .HP Configuration file functions: .br .BR firestring_conf_parse (3) .br .BR firestring_conf_add (3) .br .BR firestring_conf_find (3) .br .BR firestring_conf_find_next (3) .br .BR firestring_conf_free (3) .SH FILES /usr/local/include/firestring.h .br /usr/local/lib/libfirestring.so .br /usr/local/lib/libfirestring.a .SH AUTHOR Ian Gulliver firestring/man/firestring_estr_chug.30000644000000000000000000000164107712223277016451 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_chug 3 2003-07-30 .SH NAME firestring_estr_chug \- remove whitespace from the beginning of an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_estr_chug(struct firestring_estr_t *" "string" ")" .SH DESCRIPTION firestring_estr_chug shortens .I string by moving the start forward until the string begins with a non-whitespace character or is empty. .SH CAVEATS This function moves the starting pointer inside .IR string . If .I string was allocated with .IR firestring_estr_alloc (3), (as opposed to constructed manually pointing inside other memory), future calls to .IR firestring_estr_free (3) will fail if this function trimmed any space from the start of the string. In these cases, use .IR firestring_estr_ip_chug (3) instead. .SH RETURN VALUE None. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_ip_chug.30000644000000000000000000000107207712223277017137 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_ip_chug 3 2003-07-31 .SH NAME firestring_estr_ip_chug \- remove whitespace from the beginning of an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_estr_ip_chug(struct firestring_estr_t *" "string" ")" .SH DESCRIPTION firestring_estr_ip_chug shortens .I string "in place" by copying data back to the beginning of the string starting at the first non-whitespace character. .SH RETURN VALUE None. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_ip_trim.30000644000000000000000000000117707712223277017172 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_ip_trim 3 2003-07-31 .SH NAME firestring_estr_ip_trim \- remove whitespace from the beginning and end of an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_estr_trim(struct firestring_estr_t *" "string" ")" .SH DESCRIPTION firestring_estr_trim removes whitespace from the beginning and end of .IR string . It uses .IR firestring_estr_ip_chug (3) instead of .IR firestring_estr_chug (3), so the resulting estring can still be freed normally. .SH RETURN VALUE None. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_trim.30000644000000000000000000000156307712223277016501 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_trim 3 2003-07-30 .SH NAME firestring_estr_trim \- remove whitespace from the beginning and end of an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "void firestring_estr_trim(struct firestring_estr_t *" "string" ")" .SH DESCRIPTION firestring_estr_trim removes whitespace from the beginning and end of .IR string . .SH CAVEATS This function moves the starting pointer inside .IR string . If .I string was allocated with .IR firestring_estr_alloc (3), (as opposed to constructed manually pointing inside other memory), future calls to .IR firestring_estr_free (3) will fail if this function trimmed any space from the start of the string. In these cases, use .IR firestring_estr_ip_trim (3) instead. .SH RETURN VALUE None. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_trim.30000644000000000000000000000110407712002441015417 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_trim 3 2003-07-30 .SH NAME firestring_trim \- trim excess whitespace from the start and end of a string .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "char *firestring_trim(char *" "s" ")" .SH DESCRIPTION firestring_trim() removes any whitespace at the beginning and end of the string .IR s. A new pointer to the string (as the start may have moved) is returned .SH RETURN VALUE A pointer inside .I s to the new start of the string. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_sprintfe.30000644000000000000000000000141410016723511017336 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_sprintfe 3 2004-02-24 .SH NAME firestring_estr_sprintfe \- .BR firestring_estr_sprintf (3) with an estring format .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_estr_sprintfe(struct firestring_estr_t *" "out" ", struct firestring_estr_t *" "format" ", " "..." ")" .SH DESCRIPTION firestring_estr_sprintfe() behaves exactly like .BR firestring_estr_snprintf (3) except that it takes an estring format argument, so the format can contain arbitrary binary data. However, please note that user user-input data as the format string is .BR INSECURE . .SH RETURN VALUE Returns the number of bytes written to .IR out . .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_vsprintfe.30000644000000000000000000000142610016723511017527 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_vsprintfe 3 2004-02-24 .SH NAME firestring_estr_vsprintfe \- .BR firestring_estr_vsprintf (3) with an estring format .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_estr_vsprintfe(struct firestring_estr_t *" "out" ", struct firestring_estr_t *" "format" ", va_list " ap ")" .SH DESCRIPTION firestring_estr_vsprintfe() behaves exactly like .BR firestring_estr_vsprintf (3) except that it takes an estring format argument, so the format can contain arbitrary binary data. However, please note that user user-input data as the format string is .BR INSECURE . .SH RETURN VALUE Returns the number of bytes written to .IR out . .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_eends.30000644000000000000000000000110410023640747016605 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_eends 3 2004-03-10 .SH NAME firestring_estr_eends \- check case-insensitively if an estring ends with an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_eends(struct firestring_estr_t *" "estring" ", struct firestring_estr_t *" "needle" ")" .SH DESCRIPTION firestring_estr_eends() checks case-insensitively if .I needle appears at the end of .IR estring . .SH RETURN VALUE 0 on success; 1 on failure. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_estr_estarts.30000644000000000000000000000112210023640747017174 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_estr_estarts 3 2004-03-10 .SH NAME firestring_estr_estarts \- check case-insensitively if an estring starts with an estring .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "int firestring_estr_starts(struct firestring_estr_t *" "estring" ", struct firestring_estr_t *" "needle" ")" .SH DESCRIPTION firestring_estr_starts() checks case-insensitively if .I needle appears at the beginning of .IR estring . .SH RETURN VALUE 0 on success; 1 on failure. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_fprintfe.30000644000000000000000000000130410023640406016261 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_fprintfe 3 2004-03-10 .SH NAME firestring_fprintfe \- .BR fprintf (3) with an estring format .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_fprintfe(FILE * " stream ", struct firestring_estr_t *" "format" ", " "..." ")" .SH DESCRIPTION firestring_fprintfe() behaves exactly like .BR firestring_fprintf (3) except that it takes an estring format argument, so the format can contain arbitrary binary data. However, please note that user user-input data as the format string is .BR INSECURE . .SH RETURN VALUE Returns the number of bytes written. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_printfe.30000644000000000000000000000126610023640406016122 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_printfe 3 2004-03-10 .SH NAME firestring_printfe \- .BR firestring_printf (3) with an estring format .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_printfe(struct firestring_estr_t *" "format" ", " "..." ")" .SH DESCRIPTION firestring_printfe() behaves exactly like .BR firestring_printf (3) except that it takes an estring format argument, so the format can contain arbitrary binary data. However, please note that user user-input data as the format string is .BR INSECURE . .SH RETURN VALUE Returns the number of bytes written. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3) firestring/man/firestring_vfprintfe.30000644000000000000000000000133210023640406016450 0ustar 00000000000000.\" (C) 2002 Ian Gulliver .TH firestring_vfprintfe 3 2004-03-10 .SH NAME firestring_vfprintfe \- .BR firestring_vfprintf (3) with an estring format .SH SYNOPSIS .B #include .br .B -lfirestring .LP .BI "long firestring_vfprintfe(FILE * " stream ", struct firestring_estr_t *" "format" ", va_list " ap ")" .SH DESCRIPTION firestring_vfprintfe() behaves exactly like .BR firestring_vfprintf (3) except that it takes an estring format argument, so the format can contain arbitrary binary data. However, please note that user user-input data as the format string is .BR INSECURE . .SH RETURN VALUE Returns the number of bytes written. .SH AUTHOR Ian Gulliver .SH SEE ALSO .BR libfirestring (3)