libbinio-libbinio-1.5/000077500000000000000000000000001352246627100147435ustar00rootroot00000000000000libbinio-libbinio-1.5/.gitignore000066400000000000000000000012671352246627100167410ustar00rootroot00000000000000Makefile Makefile.in aclocal.m4 autom4te.cache compile config.guess config.log config.status config.sub configure depcomp install-sh libtool ltmain.sh missing mkinstalldirs config.mif *.lst libbinio.pc .deps .libs src/binio.h src/config.h src/config.h.in src/*.o src/*.lo src/*.la src/stamp-h1 src/*.dsw src/*.ncb src/*.opt src/*.plg src/Debug src/Release src/*.lib src/config.bat src/*.err doc/mdate-sh doc/texinfo.tex doc/*.info* doc/stamp-vti doc/version.texi doc/libbinio.vrs doc/libbinio.vr doc/libbinio.tp doc/libbinio.toc doc/libbinio.pg doc/libbinio.log doc/libbinio.ky doc/libbinio.fns doc/libbinio.fn doc/libbinio.dvi doc/libbinio.cps doc/libbinio.cp doc/libbinio.aux doc/libbinio.tps libbinio-libbinio-1.5/AUTHORS000066400000000000000000000010241352246627100160100ustar00rootroot00000000000000All library code and documentation is written by Simon Peter , except the parts listed below. Additional Credits ------------------ System floating-point to IEEE-754 single and double floating-point format conversion functions are copyright (C) 1989 - 1991 Ken Turkowski . Used by permission. Thanks to Mike Gorchak for the QNX port and packaging! Thanks to Goetz Waschk for the Red Hat and Mandrake RPM spec files and the Mandrake packaging! libbinio-libbinio-1.5/COPYING000066400000000000000000000636501352246627100160100ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. ^L Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. ^L GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. ^L Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. ^L 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. ^L 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. ^L 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. ^L 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ^L How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! libbinio-libbinio-1.5/ChangeLog000066400000000000000000000143351352246627100165230ustar00rootroot000000000000002019-08-07 15:58 malvineous * Fix off-by-one error in memory stream. * Move from SourceForge to GitHub. * Documentation updates and support for more build environments. 2005-09-18 12:00 dynamite * INSTALL.unix, Makefile.am, NEWS, README, binio.spec, binio_mdk.spec, configure.in, libbinio.pc.in, libbinio.qpg, src/Makefile.am, src/Makefile.bt, src/libbinio.dsp: Added pkg-config script. Default install path for headers is now $(pkgincludedir). 2004-08-19 14:08 dynamite * ChangeLog: Release 1.3 2004-08-18 21:55 dynamite * INSTALL.unix, NEWS, README, doc/libbinio.texi: Updated to latest autotools. 2004-08-18 21:44 dynamite * src/binio.cpp: Fixed variable type mismatch (underflow) on 64-bit systems. 2004-08-01 18:55 dynamite * Makefile.am: Added depcomp to EXTRA_DIST 2004-05-13 16:48 dynamite * NEWS: Updated NEWS. 2003-10-15 19:43 dynamite * doc/libbinio.texi, src/binio.cpp, src/binio.h.in: Fixed bug #822863. 2003-03-08 17:02 dynamite * Makefile.bt, NEWS, binio.spec, binio_mdk.spec, configure.in, libbinio.qpg, doc/libbinio.texi, src/binfile.cpp, src/binfile.h, src/binio.cpp, src/binio.h.in, src/binwrap.cpp, src/binwrap.h: Bumped version number. 2003-03-08 00:33 dynamite * ChangeLog, Makefile.am: Release. 2003-03-04 13:46 dynamite * binio.spec: Fixed groups in redhat spec file. 2003-03-03 21:38 dynamite * doc/libbinio.texi: Added info directory entry in Software Libraries group. 2003-03-03 18:48 dynamite * AUTHORS, ChangeLog, INSTALL, NEWS, binio.spec, binio_mdk.spec: Added Red Hat & Mandrake .spec files. Thanks to Goetz Waschk! 2003-03-03 13:24 dynamite * TODO, doc/libbinio.texi: Updated documentation. 2003-02-24 11:42 dynamite * ChangeLog, libbinio.qpg: Fixed placement of files in QNX packaging file. 2003-02-20 16:43 dynamite * AUTHORS, NEWS: Updated auxiliary files. 2003-02-20 15:17 dynamite * libbinio.qpg, src/binio.cpp: QNX patches. 2003-02-04 11:46 dynamite * ChangeLog, Makefile.bt, NEWS, TODO, configure.in: Bumped version number. 2003-02-03 15:11 dynamite * ChangeLog, src/binio.cpp: GCC 3.2 fixes. RC1. 2003-02-03 14:48 dynamite * ChangeLog: Updated ChangeLog. 2003-02-02 18:37 dynamite * INSTALL.dos, Makefile.bt, Makefile.wat: DOS build fixes. 2003-01-30 18:54 dynamite * NEWS, doc/libbinio.texi: Updated documentation. 2003-01-23 17:25 dynamite * NEWS, doc/libbinio.texi, src/binfile.cpp, src/binio.cpp, src/binio.h.in, src/binstr.cpp, src/binwrap.cpp: Changed behaviour of error() and eof(). Added peekInt(), peekFloat() and ateof() methods to binistream class. Updated documentation. 2003-01-19 00:45 dynamite * NEWS, src/Makefile.am, src/binio.cpp, src/binio.h.in: Modified readString() and writeString() behaviour. Removed the delimiter default. writeString() does now report number of characters written. 2003-01-18 18:40 dynamite * NEWS, configure.in: Removed bogus config header. 2003-01-18 14:46 dynamite * ChangeLog: RELEASE: Version 1.0 2003-01-18 14:36 dynamite * ChangeLog, doc/Makefile.am: Final UNIX build fixes. RC1. 2003-01-18 14:35 dynamite * .cvsignore: Polished .cvsignore file. RC1. 2003-01-18 14:34 dynamite * Makefile.bt: Final DOS build fixes. RC1. 2003-01-18 13:11 dynamite * doc/: .cvsignore, libbinio.texi: Documentation updates. RC1. 2003-01-17 22:29 dynamite * ChangeLog, Makefile.am, Makefile.bt, NEWS, README, TODO, doc/Makefile.am, doc/libbinio.texi, src/Makefile.am: Final fixes. RC1. 2003-01-16 22:04 dynamite * src/: binfile.cpp, binfile.h, binio.cpp, binio.h.in, binstr.cpp, binwrap.cpp, libbinio.dsp: Windows build fixes. 2003-01-16 19:16 dynamite * src/: .cvsignore, Makefile.bt: Synced DOS build. 2003-01-16 18:44 dynamite * AUTHORS, TODO, configure.in, doc/libbinio.texi, src/binio.cpp, src/binio.h.in, src/binwrap.cpp, src/binwrap.h: Implemented all remaining IEEE-754 conversion routines. 2003-01-12 17:27 dynamite * doc/.cvsignore: Added some more files to cvsignore. 2003-01-11 19:27 dynamite * TODO, doc/libbinio.texi, src/Makefile.am, src/binfile.cpp, src/binfile.h, src/binio.cpp, src/binio.h.in, src/binstr.cpp, src/binstr.h, src/binwrap.cpp, src/binwrap.h: Added preliminary binsstream classes. Wrote documentation. 2003-01-07 16:47 dynamite * src/: .cvsignore, binfile.h, binio.cpp, libbinio.dsp: Windows fixes. 2003-01-07 11:34 dynamite * INSTALL, configure.in, src/binio.h.in, src/binwrap.cpp, src/binwrap.h: Fixed iostream wrappers. 2003-01-04 17:39 dynamite * src/config.bat: Removed config.bat from CVS, which was there by mistake. 2003-01-04 17:37 dynamite * src/: binfile.cpp, binfile.h, binio.cpp, binio.h.in, binwrap.cpp, binwrap.h: Finalized binfstream and made the iostream wrappers. 2003-01-03 23:39 dynamite * .cvsignore, INSTALL.dos, Makefile.bt, Makefile.wat, src/.cvsignore, src/Makefile.bt: Added DOS build target. 2003-01-03 23:16 dynamite * src/: binio.cpp, libbinio.dsp, vc6inst.bat: Windows build fixes. 2003-01-03 18:48 dynamite * configure.in, src/binfile.cpp, src/binio.cpp, src/binio.h.in, src/binwrap.cpp, src/binwrap.h: Implemented IEEE float reading and writing. 2003-01-01 22:48 dynamite * INSTALL, INSTALL.dos, INSTALL.unix, INSTALL.win32, README, src/.cvsignore, src/binfile.cpp, src/config.bat, src/libbinio.dsp: Added preliminary windows build. 2002-12-28 22:52 dynamite * configure.in, doc/.cvsignore, src/.cvsignore, src/Makefile.am, src/binio.cpp, src/binio.h.in, src/binwrap.cpp, src/binwrap.h: Implemented type size check. 2002-12-25 22:36 dynamite * ChangeLog, README, TODO, doc/libbinio.texi: Documentation fixes. 2002-12-21 13:51 dynamite * .cvsignore, doc/.cvsignore, src/.cvsignore: Added .cvsignore files. 2002-12-21 13:44 dynamite * AUTHORS, COPYING, ChangeLog, INSTALL, Makefile.am, NEWS, README, TODO, configure.in, src/Makefile.am, src/binfile.cpp, src/binfile.h, src/binio.cpp, src/binwrap.cpp, src/binwrap.h, doc/Makefile.am, doc/fdl.texi, doc/libbinio.texi, src/binio.h.in: Initial revision 2002-12-21 13:44 dynamite * AUTHORS, COPYING, ChangeLog, INSTALL, Makefile.am, NEWS, README, TODO, configure.in, src/Makefile.am, src/binfile.cpp, src/binfile.h, src/binio.cpp, src/binwrap.cpp, src/binwrap.h, doc/Makefile.am, doc/fdl.texi, doc/libbinio.texi, src/binio.h.in: Initial import. libbinio-libbinio-1.5/INSTALL000066400000000000000000000037471352246627100160070ustar00rootroot00000000000000Installation: ------------- Refer to the appropriate generic INSTALL files for your build system: INSTALL.unix All UNIX builds, including cygwin INSTALL.win32 Microsoft Visual C++ builds INSTALL.dos WATCOM C/C++ builds Appendix to 'INSTALL.dos': -------------------------- The build instructions of the WATCOM build are generic and generated automatically. They assume that the main Makefile would be called 'Makefile'. This isn't the case for AdPlug's WATCOM build! AdPlug's WATCOM Makefile is called 'Makefile.wat'. Thus, you have to give the commandline option '/f Makefile.wat' every time you run a 'wmake' command. For example, to install AdPlug, call wmake like this: wmake /f Makefile.wat install Do this similary with any other 'wmake' target. Appendix to 'INSTALL.unix': --------------------------- This project depends on GNU Autotools (autoconf, automake, libtool, and gettext), texinfo, and pkg-config. Steps to build: autoreconf --install ./configure --enable-maintainer-mode make make install Notes: --enable-maintainer-mode generates some missing files, and is currently recommended by the dev team. Extra setup for DOS and Windows builds: --------------------------------------- After you've done all steps from 'INSTALL.dos' or 'INSTALL.win32', you have to copy the file 'binio.h.in' to 'binio.h' (maybe overwriting it) in the 'src' subdirectory and then open it ('binio.h'). Set all #define's in the configuration section of the file to your preferred settings. All items are documented. Next, substitute the biggest (in size of bytes, as returned by the sizeof() operator) standard integer and floating-point types for @TYPE_INT@ and @TYPE_FLOAT@, respectively. Most of the time, you would just substitute 'long' for @TYPE_INT@ and 'double' for @TYPE_FLOAT@, but some compilers have even longer types, like 'long long' and 'long double'. If your compiler supports one of those, you can substitute them instead to be able to access even longer sections within your binary streams. libbinio-libbinio-1.5/INSTALL.dos000066400000000000000000000077561352246627100165770ustar00rootroot00000000000000Note ---- These are generic installation instructions. These instructions assume that Watcom is the default compiler of this software package. If this software supports additional compilers, aside from Watcom, it is very likely that this build system is not the default. In this case, it may well be possible that some files have different names than assumed in these instructions. Please consult the software ditribution's documentation for more information on this topic. Configuration ------------- Before you can compile anything, create a file called CONFIG.MIF in the distribution's base directory. It is best to copy the template below out of this file and modify it to fit your setup. In most cases, you just want to change the installation target directories "bindir", "includedir" and "libdir" to your standard binary, header and library directories. If you want to install the software manually and don't want to set any other options, you can just leave the whole file blank. There are numerous possibilities to configure other aspects of the distribution using the CONFIG.MIF file. You can redefine any variable of the distribution's original Makefile, any standard wmake variable (CFLAGS, LDFLAGS and the like) or specify another system type using the SYSTEM variable. Installation ------------ After configuration, run "wmake" to build the software. If you like to automatically install the software, run "wmake install". For manual installation, you have to consult the software distribution's documentation for information. After the installation, you can run "wmake clean" to delete any files created during compilation. If you must, you can even run "wmake distclean" to clean up any additionally created files and bring back your source directory into the same state it was after unpacking the distribution archive. Uninstallation -------------- You can automatically delete all installed files by running "wmake uninstall". Note that any files created after installation are being left on the device. Debugging --------- To enable debugging using the Watcom debugger, add the following line to your CONFIG.MIF file: debug = yes This will recompile all source files with source-level debugging enabled and instructs the linker to include debugging information. Be careful with the SYSTEM setting in your CONFIG.MIF file, though. Only some extenders are supported by the Watcom debugger. Some distributions may have defined a non-compatible extender by default, which you must override by specifying your own. CONFIG.MIF Template ------------------- # Makefile configuration file # Lines starting with a '#' are comments. # Variables in capital letters are distribution-specific. Be careful when # changing any of these! # If debug is set to "yes", the compiler and linker are instructed to # include debug information with the compiled objects and executables. # Default: no # This example enables debugging. #debug = yes # "bindir" is the target directory for binary (.exe) files. # Default: current directory #bindir = c:\bin # "includedir" is the target directory for header (.h) files. # Default: current directory #includedir = c:\include # "libdir" is the target directory for library (.lib) files. # Default: current directory #libdir = c:\lib # SYSTEM defines the target system. # Default: (distribution specified) #SYSTEM = # CFLAGS defines any parameters that should be passed to the C compiler. # Default: (distribution specified) #CFLAGS += # CXXFLAGS defines any parameters that should be passed to the C++ compiler. # Default: (distribution specified) #CXXFLAGS += # CPPFLAGS defines preprocessing directives passed to the C/C++ compilers. # Default: (distribution specified) #CPPFLAGS += # LDFLAGS defines any parameters passed to the linker. # Default: (distribution specified) #LDFLAGS += # LIBFLAGS defines any parameters passed to the library manager. # Default: (distribution specified) #LIBFLAGS += # ZIPFLAGS defines any parameters passed to the archive manager. # Default: (distribution specified) #ZIPFLAGS = libbinio-libbinio-1.5/INSTALL.unix000066400000000000000000000223101352246627100167540ustar00rootroot00000000000000Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. libbinio-libbinio-1.5/INSTALL.win32000066400000000000000000000027111352246627100167360ustar00rootroot00000000000000Configuration ------------- Before you can compile anything, create a file called 'config.bat' in the source subdirectory ('src', that is). It's best to copy the template below out of this file and modify it to fit your setup. In most cases, you just want to change the installation target directories "bindir", "includedir" and "libdir" to your standard binary, header and library directories. If you want to install the library manually, you can just leave the file blank. This will prevent any automatic installations. If you don't have any standard directories yet, you have to create them first. It's best to put them somewhere under your 'My Documents' folder, if you have one and name them appropriately. For example, a good fit would be 'include' for your headers, 'lib' for your libraries and 'bin' for your executables. But any other names are just as well, too. Remember to tell MSVC about your new directories. This is done through the "Tools->Options..." menu. There, select the "Directories" tab and fill in the directory names, using the appropriate listboxes. Setup ----- Start MSVC and create a new workspace. Then load the project file libbinio.dsp from the source subdirecotry into it and you're finished. config.bat Template ------------------- rem Standard libraries subdirectory set libdir=C:\My Documents\lib rem Standard headers subdirectory set includedir=C:\My Documents\include rem Standard executables subdirectory set bindir=C:\My Documents\bin libbinio-libbinio-1.5/Makefile.am000066400000000000000000000004011352246627100167720ustar00rootroot00000000000000SUBDIRS = src doc EXTRA_DIST = INSTALL.unix INSTALL.win32 INSTALL.dos Makefile.wat Makefile.bt \ libbinio.qpg binio.spec binio_mdk.spec depcomp libbinio.pc.in AUTOMAKE_OPTIONS = dist-bzip2 pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libbinio.pc libbinio-libbinio-1.5/Makefile.bt000066400000000000000000000005361352246627100170130ustar00rootroot00000000000000# libbinio Makefile for Watcom # Copyright (c) 2003 Simon Peter SUBDIRS = src AUX = doc\*.texi README AUTHORS NEWS COPYING TODO ChangeLog DIST = src\*.cpp src\*.h src\binio.h.in src\Makefile.bt $(AUX) INSTALL BINARYDIST = src\*.h src\binio.lib $(AUX) distfile = binio13s.zip binarydistfile = binio13.zip installfile = INSTALL.dos libbinio-libbinio-1.5/Makefile.wat000066400000000000000000000130461352246627100172010ustar00rootroot00000000000000# Watcom Makefile Patchwork 1.0 # Copyright (c) 2002, 2003 Simon Peter # # This (and only this) file is released under the terms and conditions # of the Nullsoft license: # # This software is provided 'as-is', without any express or implied # warranty. In no event will the authors be held liable for any damages # arising from the use of this software. # # Permission is granted to anyone to use this software for any purpose, # including commercial applications, and to alter it and redistribute it # freely, subject to the following restrictions: # # 1. The origin of this software must not be misrepresented; you must not # claim that you wrote the original software. If you use this software # in a product, an acknowledgment in the product documentation would be # appreciated but is not required. # 2. Altered source versions must be plainly marked as such, and must not be # misrepresented as being the original software. # 3. This notice may not be removed or altered from any source distribution. ### PRECONFIGURATION ### CC = wcc386 CXX = wpp386 LIB = wlib LD = wlink MAKE = wmake ZIP = pkzip CFLAGS = CXXFLAGS = CPPFLAGS = LDFLAGS = LIBFLAGS = -n -b MAKEFLAGS = /h $+$(__MAKEOPTS__)$- ZIPFLAGS = -P #SUBDIRS = #OUTPUT = LIBRARIES = OBJS = DIST = BINARYDIST = SYSTEM = dos4g #include_INST = #lib_INST = #bin_INST = debug = no installfile = install.txt submakefile = Makefile.bt configfile = config.mif #distfile = #binarydistfile = distlist = srcdist.lst binarydistlist = bindist.lst bindir = . includedir = . libdir = . #includesubdir = ### PRECONFIGURATION END ### !include $(submakefile) !include $(configfile) ### LOCAL VARIABLES ### # All subdirectory-recursive targets Recursive_Targets = all.recursive clean.recursive install.recursive & uninstall.recursive # Automatically distributed files DIST += $(submakefile) $(installfile) # Debugging support !ifeq debug yes CFLAGS += -d2 CXXFLAGS += -d2 LDFLAGS += debug all !endif ### LOCAL VARIABLES END ### ### MAIN SECTION ### .c.obj: .AUTODEPEND $(CC) $(CFLAGS) $(CPPFLAGS) $[. .cpp.obj: .AUTODEPEND $(CXX) $(CXXFLAGS) $(CPPFLAGS) $[. .obj.lib: $(LIB) $(LIBFLAGS) $@ +$< .obj.exe: $(LD) $(LDFLAGS) N $@ F {$<} LIB {$(LIBRARIES)} SYS $(SYSTEM) !ifeq SYSTEM pmodew pmwlite /C4 $@ pmwsetup /Q /B0 $@ !endif all: all.recursive $(OUTPUT) .symbolic # Recurse through subdirectories. $(Recursive_Targets): $(__MAKEFILES__) .symbolic !ifdef CurrentSubdir cd $(CurrentSubdir) $(MAKE) /f ..\$[@ $(MAKEFLAGS) MAKEFLAGS=$(MAKEFLAGS) & configfile=..\$(configfile) $* !else for %d in ($(SUBDIRS)) do & $(MAKE) /f $[@ $(MAKEFLAGS) MAKEFLAGS=$(MAKEFLAGS) & configfile=$(configfile) CurrentSubdir=%d $@ !endif !ifdef OUTPUT $(OUTPUT): $(OBJS) !endif clean: clean.recursive .symbolic for %f in ($(OBJS) $(OUTPUT) $(distlist) $(binarydistlist)) do & if exist %f del %f distclean: clean .symbolic for %f in ($(configfile) $(distfile) $(binarydistfile)) do & if exist %f del %f # Install the binaries $(bin_INST) into the directory $(bindir). Install the # headers $(include_INST) into the directory $(includesubdir), which is # located in the directory $(includedir). Install the libraries $(lib_INST) # into the directory $(libdir). If the directories do not exist, they are # created. If some of the binaries or libraries do not exist, they are also # created. install: install.recursive $(OUTPUT) .symbolic !ifdef include_INST if not exist $(includedir) mkdir $(includedir) !ifdef includesubdir if not exist $(includedir)\$(includesubdir) & mkdir $(includedir)\$(includesubdir) for %f in ($(include_INST)) do copy %f $(includedir)\$(includesubdir) !else for %f in ($(include_INST)) do copy %f $(includedir) !endif !endif !ifdef lib_INST if not exist $(libdir) mkdir $(libdir) for %f in ($(lib_INST)) do copy %f $(libdir) !endif !ifdef bin_INST if not exist $(bindir) mkdir $(bindir) for %f in ($(bin_INST)) do copy %f $(bindir) !endif # Uninstalls previously installed files. uninstall: uninstall.recursive .symbolic !ifdef include_INST !ifdef includesubdir for %f in ($(include_INST)) do del $(includedir)\$(includesubdir)\%f rmdir $(includedir)\$(includesubdir) !else for %f in ($(include_INST)) do del $(includedir)\%f !endif !endif !ifdef lib_INST for %f in ($(lib_INST)) do del $(libdir)\%f !endif !ifdef bin_INST for %f in ($(bin_INST)) do del $(bindir)\%f !endif # Create a source distribution with filename $(distfile), containing the files # $(DIST), using the program $(ZIP). Special options are in $(ZIPFLAGS). !ifdef distfile $(distlist): $(__MAKEFILES__) if exist $(distlist) del $(distlist) echo $[@ > $(distlist) for %f in ($(DIST)) do echo %f >> $(distlist) $(distfile): $(distlist) $(ZIP) $(ZIPFLAGS) $(distfile) @$(distlist) dist: $(distfile) .symbolic !endif # Create a binary distribution with filename $(binarydistfile), containing # the files $(BINARYDIST), using the program $(ZIP). Special options are in # $(ZIPFLAGS). If the binaries do not exist, they are created. !ifdef binarydistfile $(binarydistlist): $(__MAKEFILES__) if exist $(binarydistlist) del $(binarydistlist) for %f in ($(BINARYDIST)) do echo %f >> $(binarydistlist) $(binarydistfile): $(binarydistlist) $(ZIP) $(ZIPFLAGS) $(binarydistfile) @$(binarydistlist) binary-dist: all $(binarydistfile) .symbolic !endif ### MAIN SECTION END ### libbinio-libbinio-1.5/NEWS000066400000000000000000000026731352246627100154520ustar00rootroot00000000000000This is a brief overview of user-visible changes in libbinio. Changes for version 1.5: ------------------------ - Fix off-by-one error in memory streams. Changes for version 1.4: ------------------------ - Support for pkg-config on UNIX systems. - Moved default header installation directory to $pkgincludedir (aka $includedir/libbinio) to prevent filename clashes with other libraries. Changes for version 1.3: ------------------------ - Fixed a small interface bug. - Fixed data type mismatch on non-32-bit systems in peekInt(). Changes for version 1.2: ------------------------ - Ported to QNX. - Red Hat & Mandrake .spec files. Changes for version 1.1: ------------------------ - Removed unused config header file. - writeString() methods now return number of characters written. - Changed behaviour of readString(): The delimiter doesn't default to '\0' anymore. If no delimiter is given, always up to 'amount' characters are read. - error() now returns a bit field of error flags instead of just one error value. Multiple errors can now occur at once. - Added 'NotFound' error flag, indicating a file not found error. - The 'Eof' error code is now set only when reading _past_ the end of a stream, not on the last byte. - Added peekInt() and peekFloat() methods to peek an integer or a floating-point number in a stream, without extracting it. - Added ateof() method to binistream class that returns true when the stream is at the last byte. libbinio-libbinio-1.5/README000066400000000000000000000010201352246627100156140ustar00rootroot00000000000000libbinio - Binary I/O stream class library Copyright (C) 2002 - 2019 Simon Peter Website: http://adplug.github.io/libbinio Description: ------------ The binary I/O stream class library presents a platform-independent way to access binary data streams in C++. The library is hardware independent in the form that it transparently converts between the different forms of machine-internal binary data representation. It further employs no special I/O protocol and can be used on arbitrary binary data sources. libbinio-libbinio-1.5/TODO000066400000000000000000000000521352246627100154300ustar00rootroot00000000000000libbinio to do list: -------------------- libbinio-libbinio-1.5/appveyor.yml000066400000000000000000000045531352246627100173420ustar00rootroot00000000000000version: 1.5.{build} image: Visual Studio 2017 install: - ps: >- # Download nuget.exe >= 3.4.4 as earlier versions produce corrupted native .nupkg files $nugetPath = "$($env:USERPROFILE)\nuget.exe" (New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', $nugetPath) # Make the nuget.exe folder come first in the path, so it gets picked up before anything else $env:Path = $env:USERPROFILE + ";" + $env:Path # Download the CoApp tools. $msiPath = "$($env:USERPROFILE)\CoApp.Tools.Powershell.msi" (New-Object Net.WebClient).DownloadFile('http://coapp.org/files/CoApp.Tools.Powershell.msi', $msiPath) # Install the CoApp tools from the downloaded .msi. Start-Process -FilePath msiexec -ArgumentList /i, $msiPath, /quiet -Wait # Make the tools available for later PS scripts to use. $env:PSModulePath = $env:PSModulePath + ';C:\Program Files (x86)\Outercurve Foundation\Modules' Import-Module CoApp nuget: disable_publish_on_pr: true build_script: - cmd: >- @echo off "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" "%VS150COMNTOOLS%\VsMSBuildCmd.bat" appveyor-retry nuget restore contrib\vs2015\vs2015.sln FOR %%T IN (v141,v140,v120_xp) DO ( FOR %%P IN (x86,x64) DO ( FOR %%C IN (Debug,Release) DO ( echo *** Building %%T/%%P/%%C *** && msbuild contrib\vs2015\libbinio\libbinio.vcxproj /p:Configuration=%%C /p:Platform=%%P /p:PlatformToolset=%%T /p:SolutionDir=..\ /v:minimal /nologo || EXIT 1 ) ) ) before_deploy: - ps: >- # This is the CoApp .autopkg file to create. $autopkgFile = "contrib\vs2015\libbinio.autopkg" # Get the ".autopkg.template" file, replace "@version" with the Appveyor version number, then save to the ".autopkg" file. cat ($autopkgFile + ".template") | % { $_ -replace "@version", $env:appveyor_build_version } > $autopkgFile # Use the CoApp tools to create NuGet native packages from the .autopkg. Write-NuGetPackage $autopkgFile # Push all newly created .nupkg files as Appveyor artifacts for later deployment. Get-ChildItem .\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } deploy: - provider: NuGet api_key: secure: j1VV7CpBunCGtQ7rINQkkxoSeOd8ptKZEvh/FaGx8DuucNP78uLNn9W+ZVqsEoNm artifact: /.*\.nupkg/ on: branch: master libbinio-libbinio-1.5/binio.spec000066400000000000000000000040541352246627100167220ustar00rootroot00000000000000%define name binio %define version 1.5 %define release 1 Summary: Binary I/O stream class library Name: %{name} Version: %{version} Release: %{release} Source0: %{name}-%{version}.tar.bz2 URL:http://adplug.github.io/libbinio License: LGPL Group: System Environment/Libraries BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} %description The binary I/O stream class library presents a platform-independent way to access binary data streams in C++. The library is hardware independent in the form that it transparently converts between the different forms of machine-internal binary data representation. It further employs no special I/O protocol and can be used on arbitrary binary data sources. %package devel Summary: Development files for lib%name Group: Development/Libraries Requires: %name = %version-%release %description devel The binary I/O stream class library presents a platform-independent way to access binary data streams in C++. The library is hardware independent in the form that it transparently converts between the different forms of machine-internal binary data representation. It further employs no special I/O protocol and can be used on arbitrary binary data sources. This package contains C++ header files, the shared library symlink and the developer documentation for %name. %prep %setup -q %build %configure make %install rm -rf $RPM_BUILD_ROOT %makeinstall %clean rm -rf $RPM_BUILD_ROOT %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %post devel if [[ -f /usr/share/info/libbinio.info.gz ]];then /sbin/install-info /usr/share/info/libbinio.info.gz --dir=/usr/share/info/dir;fi %postun devel if [ "$1" = "0" ]; then if [[ -f /usr/share/info/libbinio.info.gz ]];then /sbin/install-info /usr/share/info/libbinio.info.gz --dir=/usr/share/info/dir --remove ;fi; fi %files %defattr(-,root,root) %doc README AUTHORS ChangeLog NEWS %_libdir/*.so.* %files devel %defattr(-,root,root) %_includedir/*.h %_libdir/*.so %_libdir/*a %_infodir/*.info* %changelog * Mon Mar 3 2003 Götz Waschk 1.2-1 - initial package libbinio-libbinio-1.5/binio_mdk.spec000066400000000000000000000063321352246627100175560ustar00rootroot00000000000000%define name binio %define version 1.4 %define release 1mdk %define libname %mklibname %name 1 Summary: Binary I/O stream class library Name: %{name} Version: %{version} Release: %{release} Source0: %{name}-%{version}.tar.bz2 URL:http://adplug.github.io/libbinio License: LGPL Group: System/Libraries BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} %description The binary I/O stream class library presents a platform-independent way to access binary data streams in C++. The library is hardware independent in the form that it transparently converts between the different forms of machine-internal binary data representation. It further employs no special I/O protocol and can be used on arbitrary binary data sources. %package -n %libname Summary: Shared library for lib%name Group: System/Libraries %description -n %libname The binary I/O stream class library presents a platform-independent way to access binary data streams in C++. The library is hardware independent in the form that it transparently converts between the different forms of machine-internal binary data representation. It further employs no special I/O protocol and can be used on arbitrary binary data sources. This package contains the shared library needed to run applications based on %name. %package -n %libname-devel Summary: Development files for lib%name Group: Development/C++ Provides: %name-devel = %version-%release Provides: lib%name-devel = %version-%release Requires: %libname = %version-%release %description -n %libname-devel The binary I/O stream class library presents a platform-independent way to access binary data streams in C++. The library is hardware independent in the form that it transparently converts between the different forms of machine-internal binary data representation. It further employs no special I/O protocol and can be used on arbitrary binary data sources. This package contains C++ header files, the shared library symlink and the developer documentation for %name. %package -n %libname-static-devel Summary: Static library for lib%name Group: Development/C++ Requires: %libname-devel = %version-%release %description -n %libname-static-devel The binary I/O stream class library presents a platform-independent way to access binary data streams in C++. The library is hardware independent in the form that it transparently converts between the different forms of machine-internal binary data representation. It further employs no special I/O protocol and can be used on arbitrary binary data sources. This package contains the static library of %name. %prep %setup -q %build %configure2_5x %make %install rm -rf $RPM_BUILD_ROOT %makeinstall_std %clean rm -rf $RPM_BUILD_ROOT %post -n %libname -p /sbin/ldconfig %postun -n %libname -p /sbin/ldconfig %post -n %libname-devel %_install_info libbinio.info %postun -n %libname-devel %_remove_install_info libbinio.info %files -n %libname %defattr(-,root,root) %doc README AUTHORS ChangeLog NEWS %_libdir/*.so.* %files -n %libname-devel %defattr(-,root,root) %_includedir/*.h %_libdir/*.so %_libdir/*.la %_infodir/*.info* %files -n %libname-static-devel %defattr(-,root,root) %_libdir/*.a %changelog * Mon Mar 3 2003 Götz Waschk 1.2-1mdk - initial package libbinio-libbinio-1.5/configure.ac000066400000000000000000000036271352246627100172410ustar00rootroot00000000000000AC_INIT(binio,1.5,[dn.tlp@gmx.net],libbinio) AC_CONFIG_SRCDIR(src/binio.cpp) AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile src/binio.h libbinio.pc]) AM_INIT_AUTOMAKE AM_MAINTAINER_MODE #AM_DISABLE_SHARED AM_PROG_LIBTOOL AC_LANG(C++) # Check for a sane C/C++ build environment. AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PROG_CXX # Check if 'long long' or 'long double' are available and use them instead. AC_CHECK_TYPE(long long, AC_SUBST(TYPE_INT,"long long"), AC_SUBST(TYPE_INT,long)) AC_CHECK_TYPE(long double, AC_SUBST(TYPE_FLOAT,"long double"), AC_SUBST(TYPE_FLOAT,double)) # Conditionally build iostream wrappers AC_ARG_ENABLE([iostream], AC_HELP_STRING([--disable-iostream], [Do not build iostream wrapper streams])) if test ${enable_iostream:=yes} = yes; then AC_CHECK_LIB(stdc++,main, AC_SUBST(ENABLE_IOSTREAM,1), AC_SUBST(ENABLE_IOSTREAM,0)) else AC_SUBST(ENABLE_IOSTREAM,0) fi # Conditionally build std::string methods AC_ARG_ENABLE([string], AC_HELP_STRING([--disable-string], [Do not build std::string methods])) if test ${enable_string:=yes} = yes; then AC_CHECK_LIB(stdc++, main, AC_SUBST(ENABLE_STRING,1), AC_SUBST(ENABLE_STRING,0)) else AC_SUBST(ENABLE_STRING,0) fi # Check if we are using the ISO standard C++ library AC_ARG_WITH([iso],AC_HELP_STRING([--with-iso], [Force ISO C++ standard library compliance])) if test x${with_iso} = xyes; then AC_SUBST(ISO_STDLIB,1) elif test x${with_iso} = xno; then AC_SUBST(ISO_STDLIB,0) else AC_CHECK_TYPE([std::basic_istream], AC_SUBST(ISO_STDLIB,1), AC_SUBST(ISO_STDLIB,0), [#include ]) fi # Conditionally build with 'math.h' (and maybe library) dependencies AC_ARG_WITH([math],AC_HELP_STRING([--without-math], [Do not build routines depending on 'math.h'])) if test ${with_math:=yes} = yes; then AC_CHECK_FUNC(ldexp, AC_SUBST(WITH_MATH,1), AC_SUBST(WITH_MATH,0)) else AC_SUBST(WITH_MATH,0) fi AC_OUTPUT libbinio-libbinio-1.5/contrib/000077500000000000000000000000001352246627100164035ustar00rootroot00000000000000libbinio-libbinio-1.5/contrib/vs2015/000077500000000000000000000000001352246627100173435ustar00rootroot00000000000000libbinio-libbinio-1.5/contrib/vs2015/README000066400000000000000000000003211352246627100202170ustar00rootroot00000000000000If ../../src/binio.h.in is changed, you must run the configure script to produce an updated binio.h. You must then copy that file to ./libbinio/binio.h, otherwise the VS2015 build will use the older binio.h. libbinio-libbinio-1.5/contrib/vs2015/libbinio.autopkg.template000066400000000000000000000025751352246627100243510ustar00rootroot00000000000000#define { // Must match the PlatformToolset options in appveyor.yml toolsets: "v141,v140,v120_xp"; } configurations { UserPlatformToolset { // Needed for VS2015 support key = "PlatformToolset"; choices: ${toolsets}; }; } nuget { nuspec { id = libbinio; // "@version" is replaced by the current Appveyor build number in the // pre-deployment script. version: @version; title: libbinio; authors: {Simon Peter}; owners: {Malvineous}; licenseUrl: "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html"; projectUrl: "https://github.com/adplug/libbinio"; iconUrl: "https://avatars2.githubusercontent.com/u/12982922?v=3&s=200"; copyright: "Copyright 2002-2016 Simon Peter"; requireLicenseAcceptance: false; description: "Binary I/O stream class library providing platform-independent binary data streams in C++"; releaseNotes: "Package upstream git version."; tags: {coapp, native, nativepackage, static}; } files { #defines { SDK_ROOT = "../../"; SolutionDir = "./"; } include: { "${SDK_ROOT}src/*.h", "${SolutionDir}libbinio/binio.h" }; docs: { "${SDK_ROOT}README", "${SDK_ROOT}COPYING" }; (${toolsets}, "Win32,x64", "release,debug") => { [${0},${1},${2}] { lib: ${SolutionDir}${0}\${1}\${2}\${pkgname}.lib; symbols: ${SolutionDir}${0}\${1}\${2}\${pkgname}.pdb; } } } targets { Defines += HAS_LIBBINIO; } } libbinio-libbinio-1.5/contrib/vs2015/libbinio/000077500000000000000000000000001352246627100211325ustar00rootroot00000000000000libbinio-libbinio-1.5/contrib/vs2015/libbinio/binio.h000066400000000000000000000107561352246627100224140ustar00rootroot00000000000000/* -*-C++-*- * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * binio.h - Binary stream I/O classes * Copyright (C) 2002, 2003, 2005 Simon Peter */ #ifndef H_BINIO_BINIO #define H_BINIO_BINIO /***** Configuration *****/ // BINIO_ENABLE_STRING - Build std::string supporting methods // // Set to 1 to build std::string supporting methods. You need the STL to // do this. #define BINIO_ENABLE_STRING 1 // BINIO_ENABLE_IOSTREAM - Build iostream wrapper classes // // Set to 1 to build the iostream wrapper classes. You need the standard // C++ library to do this. #define BINIO_ENABLE_IOSTREAM 1 // BINIO_ISO_STDLIB - Build with ISO C++ standard library compliance // // Set to 1 to build for the ISO standard C++ library (i.e. namespaces, STL and // templatized iostream). Set to 0 to build for the traditional C++ library. #define BINIO_ISO_STDLIB 1 // BINIO_WITH_MATH - Build with 'math.h' dependency to allow float conversions // // Set to 1 to also build routines that depend on the 'math.h' standard C header // file (this sometimes also implies a 'libm' or 'libmath' dependency). These // routines are needed in order to write IEEE-754 floating-point numbers on a // system that doesn't support this format natively. For only reading these // numbers, however, these routines are not needed. If set to 0, writing // IEEE-754 numbers on an incompatible system will be disabled. #define BINIO_WITH_MATH 1 /***** Implementation *****/ // Disable annoying multiple inheritance compiler warning on MSVC6 #ifdef _MSC_VER # pragma warning(disable: 4250) #endif #if BINIO_ENABLE_STRING #include #endif class binio { public: typedef enum { BigEndian = 1 << 0, FloatIEEE = 1 << 1 } Flag; typedef enum { NoError = 0, Fatal = 1 << 0, Unsupported = 1 << 1, NotOpen = 1 << 2, Denied = 1 << 3, NotFound = 1 << 4, Eof = 1 << 5 } ErrorCode; typedef enum { Set, Add, End } Offset; typedef enum { Single, Double } FType; typedef int Error; binio(); virtual ~binio(); void setFlag(Flag f, bool set = true); bool getFlag(Flag f); Error error(); bool eof(); virtual void seek(long, Offset = Set) = 0; virtual long pos() = 0; protected: typedef long long Int; typedef long double Float; typedef unsigned char Byte; // has to be unsigned! typedef int Flags; Flags my_flags; static const Flags system_flags; Error err; // Some math.h emulation functions... #if !BINIO_WITH_MATH Float pow(Float base, signed int exp); Float ldexp(Float x, signed int exp) { return x * pow(2, exp); } #endif private: static const Flags detect_system_flags(); }; class binistream: virtual public binio { public: binistream(); virtual ~binistream(); Int readInt(unsigned int size); Float readFloat(FType ft); unsigned long readString(char *str, unsigned long maxlen); unsigned long readString(char *str, unsigned long maxlen, const char delim); #if BINIO_ENABLE_STRING std::string readString(const char delim = '\0'); #endif Int peekInt(unsigned int size); Float peekFloat(FType ft); bool ateof(); void ignore(unsigned long amount = 1); protected: virtual Byte getByte() = 0; private: Float ieee_single2float(Byte *data); Float ieee_double2float(Byte *data); }; class binostream: virtual public binio { public: binostream(); virtual ~binostream(); void writeInt(Int val, unsigned int size); void writeFloat(Float f, FType ft); unsigned long writeString(const char *str, unsigned long amount = 0); #if BINIO_ENABLE_STRING unsigned long writeString(const std::string &str); #endif protected: virtual void putByte(Byte) = 0; private: void float2ieee_single(Float f, Byte *data); void float2ieee_double(Float f, Byte *data); }; class binstream: public binistream, public binostream { public: binstream(); virtual ~binstream(); }; #endif libbinio-libbinio-1.5/contrib/vs2015/libbinio/libbinio.vcxproj000066400000000000000000000154751352246627100243520ustar00rootroot00000000000000 Debug Win32 Release Win32 Debug x64 Release x64 {66BAEDE8-898E-4995-B5DE-2B2DCA373CCF} Win32Proj libbinio 8.1 StaticLibrary true v140 Unicode StaticLibrary false v140 true Unicode StaticLibrary true v140 Unicode StaticLibrary false v140 true Unicode $(MSBuildProjectDirectory);$(IncludePath) $(SolutionDir)$(PlatformToolset)\$(Platform)\$(Configuration)\ $(PlatformToolset)\$(Platform)\$(Configuration)\ Level3 Disabled WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) Windows true Level3 Disabled _DEBUG;_LIB;%(PreprocessorDefinitions) Windows true Level3 MaxSpeed true true WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) Windows true true true Level3 MaxSpeed true true NDEBUG;_LIB;%(PreprocessorDefinitions) Windows true true true libbinio-libbinio-1.5/contrib/vs2015/vs2015.sln000066400000000000000000000023761352246627100210310ustar00rootroot00000000000000 Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbinio", "libbinio\libbinio.vcxproj", "{66BAEDE8-898E-4995-B5DE-2B2DCA373CCF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {66BAEDE8-898E-4995-B5DE-2B2DCA373CCF}.Debug|x64.ActiveCfg = Debug|x64 {66BAEDE8-898E-4995-B5DE-2B2DCA373CCF}.Debug|x64.Build.0 = Debug|x64 {66BAEDE8-898E-4995-B5DE-2B2DCA373CCF}.Debug|x86.ActiveCfg = Debug|Win32 {66BAEDE8-898E-4995-B5DE-2B2DCA373CCF}.Debug|x86.Build.0 = Debug|Win32 {66BAEDE8-898E-4995-B5DE-2B2DCA373CCF}.Release|x64.ActiveCfg = Release|x64 {66BAEDE8-898E-4995-B5DE-2B2DCA373CCF}.Release|x64.Build.0 = Release|x64 {66BAEDE8-898E-4995-B5DE-2B2DCA373CCF}.Release|x86.ActiveCfg = Release|Win32 {66BAEDE8-898E-4995-B5DE-2B2DCA373CCF}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal libbinio-libbinio-1.5/libbinio.pc.in000066400000000000000000000004271352246627100174660ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: @PACKAGE@ Description: Binary I/O stream class library URL: http://adplug.github.io/libbinio Version: @VERSION@ Libs: -L${libdir} -lbinio Libs.private: -lm CFlags: -I${includedir}/@PACKAGE@ libbinio-libbinio-1.5/libbinio.qpg000066400000000000000000000137051352246627100172510ustar00rootroot00000000000000 QNX.ORG.RU Community QNX.ORG.RU Team Mike Gorchak mike@malva.ua Library libbinio 1 http://qnx.org.ru/repository 1.01 libbinio libbinio dn.tlp@gmx.net Public public http://adplug.github.io/libbinio dn.tlp@gmx.net Simon Peter http://adplug.github.io/libbinio dn.tlp@gmx.net The binary I/O stream class library presents a platform-independent way to access binary data streams in C++. The binary I/O stream class library presents a platform-independent way to access binary data streams in C++. The library is hardware independent in the form that it transparently converts between the different forms of machine-internal binary data representation. It further employs no special I/O protocol and can be used on arbitrary binary data sources. http://adplug.github.io/libbinio 1.5 Medium Stable 1 GNU General Public License Software Development/Libraries and Extensions/C++ Libraries Streams, C++, Data, Binary Console Developer repdata://LicenseUrl/COPYING libbinio-libbinio-1.5/src/000077500000000000000000000000001352246627100155325ustar00rootroot00000000000000libbinio-libbinio-1.5/src/Makefile.am000066400000000000000000000003731352246627100175710ustar00rootroot00000000000000lib_LTLIBRARIES = libbinio.la libbinio_la_SOURCES = binio.cpp binfile.cpp binwrap.cpp binstr.cpp libbinio_la_LDFLAGS = -version-info 1:0:0 pkginclude_HEADERS = binio.h binfile.h binwrap.h binstr.h EXTRA_DIST = Makefile.bt libbinio.dsp vc6inst.bat libbinio-libbinio-1.5/src/Makefile.bt000066400000000000000000000007741352246627100176060ustar00rootroot00000000000000# libbinio Makefile for WATCOM C/C++ # Copyright (c) 2003, 2005 Simon Peter # This flag is set to work around a bug in the Watcom 11.0c compiler in # conjunction with the STLport library. Without it, the compiler will crash # during compilation of some files and create very fragile code for others. CXXFLAGS = -oi+ OUTPUT = binio.lib OBJS = binio.obj binfile.obj binwrap.obj binstr.obj include_INST = binio.h binfile.h binwrap.h binstr.h lib_INST = binio.lib includesubdir = libbinio libbinio-libbinio-1.5/src/binfile.cpp000066400000000000000000000111731352246627100176510ustar00rootroot00000000000000/* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * binfile.h - Binary file I/O * Copyright (C) 2002, 2003 Simon Peter */ #include #include #include "binfile.h" /***** binfbase *****/ binfbase::binfbase() : f(NULL) { } binfbase::~binfbase() { if(f != NULL) close(); } void binfbase::close() { if(f != NULL) { if(fclose(f) == EOF) err |= Fatal; else f = NULL; } else err |= NotOpen; } void binfbase::seek(long pos, Offset offs) { int error; if(f == NULL) { err |= NotOpen; return; } switch(offs) { case Set: error = fseek(f, pos, SEEK_SET); break; case Add: error = fseek(f, pos, SEEK_CUR); break; case End: error = fseek(f, pos, SEEK_END); break; } if(error == -1) err |= Fatal; } long binfbase::pos() { long pos; if(f == NULL) { err |= NotOpen; return 0; } pos = ftell(f); if(pos == -1) { err |= Fatal; return 0; } else return pos; } /***** binifstream *****/ binifstream::binifstream() { } binifstream::binifstream(const char *filename, const Mode mode) { open(filename, mode); } #if BINIO_ENABLE_STRING binifstream::binifstream(const std::string &filename, const Mode mode) { open(filename, mode); } #endif binifstream::~binifstream() { } void binifstream::open(const char *filename, const Mode mode) { f = fopen(filename, "rb"); if(f == NULL) switch(errno) { case ENOENT: err |= NotFound; break; case EACCES: err |= Denied; break; default: err |= NotOpen; break; } } #if BINIO_ENABLE_STRING void binifstream::open(const std::string &filename, const Mode mode) { open(filename.c_str(), mode); } #endif binifstream::Byte binifstream::getByte() { int read; if(f != NULL) { read = fgetc(f); if(read == EOF) err |= Eof; return (Byte)read; } else { err |= NotOpen; return 0; } } /***** binofstream *****/ binofstream::binofstream() { } binofstream::binofstream(const char *filename, const Mode mode) { open(filename, mode); } #if BINIO_ENABLE_STRING binofstream::binofstream(const std::string &filename, const Mode mode) { open(filename, mode); } #endif binofstream::~binofstream() { } void binofstream::open(const char *filename, const Mode mode) { char *modestr = "wb"; // Check if append mode is desired if(mode & Append) modestr = "ab"; f = fopen(filename, modestr); if(f == NULL) switch(errno) { case EEXIST: case EACCES: case EROFS: err |= Denied; break; case ENOENT: err |= NotFound; break; default: err |= NotOpen; break; } } #if BINIO_ENABLE_STRING void binofstream::open(const std::string &filename, const Mode mode) { open(filename.c_str(), mode); } #endif void binofstream::putByte(Byte b) { if(f == NULL) { err |= NotOpen; return; } if(fputc(b, f) == EOF) err |= Fatal; } /***** binfstream *****/ binfstream::binfstream() { } binfstream::binfstream(const char *filename, const Mode mode) { open(filename, mode); } #if BINIO_ENABLE_STRING binfstream::binfstream(const std::string &filename, const Mode mode) { open(filename, mode); } #endif binfstream::~binfstream() { } void binfstream::open(const char *filename, const Mode mode) { char *modestr = "w+b"; // Create & at beginning int ferror = 0; // Apply desired mode if(mode & NoCreate) { if(!(mode & Append)) modestr[0] = 'r'; // NoCreate & at beginning } else if(mode & Append) // Create & append modestr[0] = 'a'; f = fopen(filename, modestr); // NoCreate & append (emulated -- not possible with standard C fopen()) if(f != NULL && (mode & Append) && (mode & NoCreate)) ferror = fseek(f, 0, SEEK_END); if(f == NULL || ferror == -1) { switch(errno) { case EEXIST: case EACCES: case EROFS: err |= Denied; break; case ENOENT: err |= NotFound; break; default: err |= NotOpen; break; } } } #if BINIO_ENABLE_STRING void binfstream::open(const std::string &filename, const Mode mode) { open(filename.c_str(), mode); } #endif libbinio-libbinio-1.5/src/binfile.h000066400000000000000000000054051352246627100173170ustar00rootroot00000000000000/* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * binfile.h - Binary file I/O * Copyright (C) 2002, 2003 Simon Peter */ #ifndef H_BINIO_BINFILE #define H_BINIO_BINFILE #include #include "binio.h" class binfbase: virtual public binio { public: typedef enum { Append = 1 << 0, NoCreate = 1 << 1 } ModeFlags; typedef int Mode; binfbase(); virtual ~binfbase(); virtual void open(const char *filename, const Mode mode) = 0; #if BINIO_ENABLE_STRING virtual void open(const std::string &filename, const Mode mode) = 0; #endif void close(); virtual void seek(long pos, Offset offs = Set); virtual long pos(); protected: FILE *f; }; class binifstream: public binistream, virtual public binfbase { public: binifstream(); binifstream(const char *filename, const Mode mode = NoCreate); #if BINIO_ENABLE_STRING binifstream(const std::string &filename, const Mode mode = NoCreate); #endif virtual ~binifstream(); virtual void open(const char *filename, const Mode mode = NoCreate); #if BINIO_ENABLE_STRING virtual void open(const std::string &filename, const Mode mode = NoCreate); #endif protected: virtual Byte getByte(); }; class binofstream: public binostream, virtual public binfbase { public: binofstream(); binofstream(const char *filename, const Mode mode = 0); #if BINIO_ENABLE_STRING binofstream(const std::string &filename, const Mode mode = 0); #endif virtual ~binofstream(); virtual void open(const char *filename, const Mode mode = 0); #if BINIO_ENABLE_STRING virtual void open(const std::string &filename, const Mode mode = 0); #endif protected: virtual void putByte(Byte b); }; class binfstream: public binifstream, public binofstream { public: binfstream(); binfstream(const char *filename, const Mode mode = 0); #if BINIO_ENABLE_STRING binfstream(const std::string &filename, const Mode mode = 0); #endif virtual ~binfstream(); virtual void open(const char *filename, const Mode mode = 0); #if BINIO_ENABLE_STRING virtual void open(const std::string &filename, const Mode mode = 0); #endif }; #endif libbinio-libbinio-1.5/src/binio.cpp000066400000000000000000000360471352246627100173500ustar00rootroot00000000000000/* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * binio.cpp - Binary stream I/O classes * Copyright (C) 2002, 2003 Simon Peter */ #include #include "binio.h" #if BINIO_WITH_MATH #include #ifdef __QNXNTO__ #define pow std::powf #endif // __QNXNTO__ // If 'math.h' doesn't define HUGE_VAL, we try to use HUGE instead. #ifndef HUGE_VAL # define HUGE_VAL HUGE #endif #endif /***** Defines *****/ #if BINIO_ENABLE_STRING // String buffer size for std::string readString() method #define STRINGBUFSIZE 256 #endif /***** binio *****/ const binio::Flags binio::system_flags = binio::detect_system_flags(); const binio::Flags binio::detect_system_flags() { Flags f = 0; // Endian test union { int word; Byte byte; } endian_test; endian_test.word = 1; if(endian_test.byte != 1) f |= BigEndian; // IEEE-754 floating-point test float fl = 6.5; Byte *dat = (Byte *)&fl; if(sizeof(float) == 4 && sizeof(double) == 8) if(f & BigEndian) { if(dat[0] == 0x40 && dat[1] == 0xD0 && !dat[2] && !dat[3]) f |= FloatIEEE; } else if(dat[3] == 0x40 && dat[2] == 0xD0 && !dat[1] && !dat[0]) f |= FloatIEEE; return f; } binio::binio() : my_flags(system_flags), err(NoError) { } binio::~binio() { } void binio::setFlag(Flag f, bool set) { if(set) my_flags |= f; else my_flags &= !f; } bool binio::getFlag(Flag f) { return (my_flags & f ? true : false); } binio::Error binio::error() { Error e = err; err = NoError; return e; } bool binio::eof() { return (err & Eof ? true : false); } /***** binistream *****/ binistream::binistream() { } binistream::~binistream() { } binistream::Int binistream::readInt(unsigned int size) { unsigned int i; Int val = 0, in; // Check if 'size' doesn't exceed our system's biggest type. if(size > sizeof(Int)) { err |= Unsupported; return 0; } for(i = 0; i < size; i++) { in = getByte(); if(getFlag(BigEndian)) val <<= 8; else in <<= i * 8; val |= in; } return val; } binistream::Float binistream::readFloat(FType ft) { if(getFlag(FloatIEEE)) { // Read IEEE-754 floating-point value unsigned int i, size; Byte in[8]; bool swap; // Determine appropriate size for given type. switch(ft) { case Single: size = 4; break; // 32 bits case Double: size = 8; break; // 64 bits } // Determine byte ordering, depending on what we do next if(system_flags & FloatIEEE) swap = getFlag(BigEndian) ^ (system_flags & BigEndian); else swap = !getFlag(BigEndian); // Read the float byte by byte, converting endianess for(i = 0; i < size; i++) if(swap) in[size - i - 1] = getByte(); else in[i] = getByte(); if(system_flags & FloatIEEE) { // Compatible system, let the hardware do the conversion switch(ft) { case Single: return *(float *)in; case Double: return *(double *)in; } } else { // Incompatible system, convert manually switch(ft) { case Single: return ieee_single2float(in); case Double: return ieee_double2float(in); } } } // User tried to read a (yet) unsupported floating-point type. Bail out. err |= Unsupported; return 0.0; } binistream::Float binistream::ieee_single2float(Byte *data) { signed int sign = data[0] >> 7 ? -1 : 1; unsigned int exp = ((data[0] << 1) & 0xff) | ((data[1] >> 7) & 1), fracthi7 = data[1] & 0x7f; Float fract = fracthi7 * 65536.0 + data[2] * 256.0 + data[3]; // Signed and unsigned zero if(!exp && !fracthi7 && !data[2] && !data[3]) return sign * 0.0; // Signed and unsigned infinity (maybe unsupported on non-IEEE systems) if(exp == 255) if(!fracthi7 && !data[2] && !data[3]) { #ifdef HUGE_VAL if(sign == -1) return -HUGE_VAL; else return HUGE_VAL; #else err |= Unsupported; if(sign == -1) return -1.0; else return 1.0; #endif } else { // Not a number (maybe unsupported on non-IEEE systems) #ifdef NAN return NAN; #else err |= Unsupported; return 0.0; #endif } if(!exp) // Unnormalized float values return sign * pow(2, -126) * fract * pow(2, -23); else // Normalized float values return sign * pow(2, exp - 127) * (fract * pow(2, -23) + 1); err |= Fatal; return 0.0; } binistream::Float binistream::ieee_double2float(Byte *data) { signed int sign = data[0] >> 7 ? -1 : 1; unsigned int exp = ((unsigned int)(data[0] & 0x7f) << 4) | (data[1] >> 4), fracthi4 = data[1] & 0xf; Float fract = fracthi4 * pow(2, 48) + data[2] * pow(2, 40) + data[3] * pow(2, 32) + data[4] * pow(2, 24) + data[5] * pow(2, 16) + data[6] * pow(2, 8) + data[7]; // Signed and unsigned zero if(!exp && !fracthi4 && !data[2] && !data[3] && !data[4] && !data[5] && !data[6] && !data[7]) return sign * 0.0; // Signed and unsigned infinity (maybe unsupported on non-IEEE systems) if(exp == 2047) if(!fracthi4 && !data[2] && !data[3] && !data[4] && !data[5] && !data[6] && !data[7]) { #ifdef HUGE_VAL if(sign == -1) return -HUGE_VAL; else return HUGE_VAL; #else err |= Unsupported; if(sign == -1) return -1.0; else return 1.0; #endif } else { // Not a number (maybe unsupported on non-IEEE systems) #ifdef NAN return NAN; #else err |= Unsupported; return 0.0; #endif } if(!exp) // Unnormalized float values return sign * pow(2, -1022) * fract * pow(2, -52); else // Normalized float values return sign * pow(2, exp - 1023) * (fract * pow(2, -52) + 1); err |= Fatal; return 0.0; } #if !BINIO_WITH_MATH binio::Float binio::pow(Float base, signed int exp) /* Our own, stripped-down version of pow() for not having to depend on 'math.h'. * This one handles float values for the base and an integer exponent, both * positive and negative. */ { int i; Float val = base; if(!exp) return 1.0; for(i = 1; i < (exp < 0 ? -exp : exp); i++) val *= base; if(exp < 0) val = 1.0 / val; return val; } #endif unsigned long binistream::readString(char *str, unsigned long maxlen) { unsigned long i; for(i = 0; i < maxlen; i++) { str[i] = (char)getByte(); if(err) { str[i] = '\0'; return i; } } return maxlen; } unsigned long binistream::readString(char *str, unsigned long maxlen, const char delim) { unsigned long i; for(i = 0; i < maxlen; i++) { str[i] = (char)getByte(); if(str[i] == delim || err) { str[i] = '\0'; return i; } } str[maxlen] = '\0'; return maxlen; } #if BINIO_ENABLE_STRING std::string binistream::readString(const char delim) { char buf[STRINGBUFSIZE + 1]; std::string tempstr; unsigned long read; do { read = readString(buf, STRINGBUFSIZE, delim); tempstr.append(buf, read); } while(read == STRINGBUFSIZE); return tempstr; } #endif binistream::Int binistream::peekInt(unsigned int size) { Int val = readInt(size); if(!err) seek(-(long)size, Add); return val; } binistream::Float binistream::peekFloat(FType ft) { Float val = readFloat(ft); if(!err) switch(ft) { case Single: seek(-4, Add); break; case Double: seek(-8, Add); break; } return val; } bool binistream::ateof() { Error olderr = err; // Save current error state bool eof_then; peekInt(1); eof_then = eof(); // Get error state of next byte err = olderr; // Restore original error state return eof_then; } void binistream::ignore(unsigned long amount) { unsigned long i; for(i = 0; i < amount; i++) getByte(); } /***** binostream *****/ binostream::binostream() { } binostream::~binostream() { } void binostream::writeInt(Int val, unsigned int size) { unsigned int i; // Check if 'size' doesn't exceed our system's biggest type. if(size > sizeof(Int)) { err |= Unsupported; return; } for(i = 0; i < size; i++) { if(getFlag(BigEndian)) putByte((val >> (size - i - 1) * 8) & 0xff); else { putByte(val & 0xff); val >>= 8; } } } void binostream::writeFloat(Float f, FType ft) { if(getFlag(FloatIEEE)) { // Write IEEE-754 floating-point value unsigned int i, size; Byte *out; bool swap; if(system_flags & FloatIEEE) { // compatible system, let the hardware do the conversion float outf = f; double outd = f; // Hardware could be big or little endian, convert appropriately swap = getFlag(BigEndian) ^ (system_flags & BigEndian); // Determine appropriate size for given type and convert by hardware switch(ft) { case Single: size = 4; out = (Byte *)&outf; break; // 32 bits case Double: size = 8; out = (Byte *)&outd; break; // 64 bits } } else { #if BINIO_WITH_MATH // incompatible system, do the conversion manually Byte buf[8]; // Our own value is always big endian, just check whether we have to // convert for a different stream format. swap = !getFlag(BigEndian); // Convert system's float to requested IEEE-754 float switch(ft) { case Single: size = 4; float2ieee_single(f, buf); break; case Double: size = 8; float2ieee_double(f, buf); break; } out = buf; // Make the value ready for writing #else // No necessary support routines to do the conversion, bail out! err |= Unsupported; return; #endif } // Write the float byte by byte, converting endianess if(swap) out += size - 1; for(i = 0; i < size; i++) { putByte(*out); if(swap) out--; else out++; } return; // We're done. } // User tried to write an unsupported floating-point type. Bail out. err |= Unsupported; } #ifdef BINIO_WITH_MATH /* * Single and double floating-point to IEEE-754 equivalent conversion functions * courtesy of Ken Turkowski. * * Copyright (C) 1989-1991 Ken Turkowski. * * All rights reserved. * * Warranty Information * Even though I have reviewed this software, I make no warranty * or representation, either express or implied, with respect to this * software, its quality, accuracy, merchantability, or fitness for a * particular purpose. As a result, this software is provided "as is," * and you, its user, are assuming the entire risk as to its quality * and accuracy. * * This code may be used and freely distributed as long as it includes * this copyright notice and the above warranty information. */ /**************************************************************** * The following two routines make up for deficiencies in many * compilers to convert properly between unsigned integers and * floating-point. Some compilers which have this bug are the * THINK_C compiler for the Macintosh and the C compiler for the * Silicon Graphics MIPS-based Iris. ****************************************************************/ #ifdef applec /* The Apple C compiler works */ # define FloatToUnsigned(f) ((unsigned long)(f)) #else # define FloatToUnsigned(f) ((unsigned long)(((long)((f) - 2147483648.0)) + 2147483647L + 1)) #endif #define SEXP_MAX 255 #define SEXP_OFFSET 127 #define SEXP_SIZE 8 #define SEXP_POSITION (32-SEXP_SIZE-1) void binostream::float2ieee_single(Float num, Byte *bytes) { long sign; register long bits; if (num < 0) { /* Can't distinguish a negative zero */ sign = 0x80000000; num *= -1; } else { sign = 0; } if (num == 0) { bits = 0; } else { Float fMant; int expon; fMant = frexp(num, &expon); if ((expon > (SEXP_MAX-SEXP_OFFSET+1)) || !(fMant < 1)) { /* NaN's and infinities fail second test */ bits = sign | 0x7F800000; /* +/- infinity */ } else { long mantissa; if (expon < -(SEXP_OFFSET-2)) { /* Smaller than normalized */ int shift = (SEXP_POSITION+1) + (SEXP_OFFSET-2) + expon; if (shift < 0) { /* Way too small: flush to zero */ bits = sign; } else { /* Nonzero denormalized number */ mantissa = (long)(fMant * (1L << shift)); bits = sign | mantissa; } } else { /* Normalized number */ mantissa = (long)floor(fMant * (1L << (SEXP_POSITION+1))); mantissa -= (1L << SEXP_POSITION); /* Hide MSB */ bits = sign | ((long)((expon + SEXP_OFFSET - 1)) << SEXP_POSITION) | mantissa; } } } bytes[0] = bits >> 24; /* Copy to byte string */ bytes[1] = bits >> 16; bytes[2] = bits >> 8; bytes[3] = bits; } #define DEXP_MAX 2047 #define DEXP_OFFSET 1023 #define DEXP_SIZE 11 #define DEXP_POSITION (32-DEXP_SIZE-1) void binostream::float2ieee_double(Float num, Byte *bytes) { long sign; long first, second; if (num < 0) { /* Can't distinguish a negative zero */ sign = 0x80000000; num *= -1; } else { sign = 0; } if (num == 0) { first = 0; second = 0; } else { Float fMant, fsMant; int expon; fMant = frexp(num, &expon); if ((expon > (DEXP_MAX-DEXP_OFFSET+1)) || !(fMant < 1)) { /* NaN's and infinities fail second test */ first = sign | 0x7FF00000; /* +/- infinity */ second = 0; } else { long mantissa; if (expon < -(DEXP_OFFSET-2)) { /* Smaller than normalized */ int shift = (DEXP_POSITION+1) + (DEXP_OFFSET-2) + expon; if (shift < 0) { /* Too small for something in the MS word */ first = sign; shift += 32; if (shift < 0) { /* Way too small: flush to zero */ second = 0; } else { /* Pretty small demorn */ second = FloatToUnsigned(floor(ldexp(fMant, shift))); } } else { /* Nonzero denormalized number */ fsMant = ldexp(fMant, shift); mantissa = (long)floor(fsMant); first = sign | mantissa; second = FloatToUnsigned(floor(ldexp(fsMant - mantissa, 32))); } } else { /* Normalized number */ fsMant = ldexp(fMant, DEXP_POSITION+1); mantissa = (long)floor(fsMant); mantissa -= (1L << DEXP_POSITION); /* Hide MSB */ fsMant -= (1L << DEXP_POSITION); first = sign | ((long)((expon + DEXP_OFFSET - 1)) << DEXP_POSITION) | mantissa; second = FloatToUnsigned(floor(ldexp(fsMant - mantissa, 32))); } } } bytes[0] = first >> 24; bytes[1] = first >> 16; bytes[2] = first >> 8; bytes[3] = first; bytes[4] = second >> 24; bytes[5] = second >> 16; bytes[6] = second >> 8; bytes[7] = second; } #endif // BINIO_WITH_MATH unsigned long binostream::writeString(const char *str, unsigned long amount) { unsigned int i; if(!amount) amount = strlen(str); for(i = 0; i < amount; i++) { putByte(str[i]); if(err) return i; } return amount; } #if BINIO_ENABLE_STRING unsigned long binostream::writeString(const std::string &str) { return writeString(str.c_str()); } #endif libbinio-libbinio-1.5/src/binio.h.in000066400000000000000000000110431352246627100174070ustar00rootroot00000000000000/* -*-C++-*- * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * binio.h - Binary stream I/O classes * Copyright (C) 2002, 2003, 2005 Simon Peter */ #ifndef H_BINIO_BINIO #define H_BINIO_BINIO /***** Configuration *****/ // BINIO_ENABLE_STRING - Build std::string supporting methods // // Set to 1 to build std::string supporting methods. You need the STL to // do this. #define BINIO_ENABLE_STRING @ENABLE_STRING@ // BINIO_ENABLE_IOSTREAM - Build iostream wrapper classes // // Set to 1 to build the iostream wrapper classes. You need the standard // C++ library to do this. #define BINIO_ENABLE_IOSTREAM @ENABLE_IOSTREAM@ // BINIO_ISO_STDLIB - Build with ISO C++ standard library compliance // // Set to 1 to build for the ISO standard C++ library (i.e. namespaces, STL and // templatized iostream). Set to 0 to build for the traditional C++ library. #define BINIO_ISO_STDLIB @ISO_STDLIB@ // BINIO_WITH_MATH - Build with 'math.h' dependency to allow float conversions // // Set to 1 to also build routines that depend on the 'math.h' standard C header // file (this sometimes also implies a 'libm' or 'libmath' dependency). These // routines are needed in order to write IEEE-754 floating-point numbers on a // system that doesn't support this format natively. For only reading these // numbers, however, these routines are not needed. If set to 0, writing // IEEE-754 numbers on an incompatible system will be disabled. #define BINIO_WITH_MATH @WITH_MATH@ /***** Implementation *****/ // Disable annoying multiple inheritance compiler warning on MSVC6 #ifdef _MSC_VER # pragma warning(disable: 4250) #endif #if BINIO_ENABLE_STRING #include #endif class binio { public: typedef enum { BigEndian = 1 << 0, FloatIEEE = 1 << 1 } Flag; typedef enum { NoError = 0, Fatal = 1 << 0, Unsupported = 1 << 1, NotOpen = 1 << 2, Denied = 1 << 3, NotFound = 1 << 4, Eof = 1 << 5 } ErrorCode; typedef enum { Set, Add, End } Offset; typedef enum { Single, Double } FType; typedef int Error; binio(); virtual ~binio(); void setFlag(Flag f, bool set = true); bool getFlag(Flag f); Error error(); bool eof(); virtual void seek(long, Offset = Set) = 0; virtual long pos() = 0; protected: typedef @TYPE_INT@ Int; typedef @TYPE_FLOAT@ Float; typedef unsigned char Byte; // has to be unsigned! typedef int Flags; Flags my_flags; static const Flags system_flags; Error err; // Some math.h emulation functions... #if !BINIO_WITH_MATH Float pow(Float base, signed int exp); Float ldexp(Float x, signed int exp) { return x * pow(2, exp); } #endif private: static const Flags detect_system_flags(); }; class binistream: virtual public binio { public: binistream(); virtual ~binistream(); Int readInt(unsigned int size); Float readFloat(FType ft); unsigned long readString(char *str, unsigned long maxlen); unsigned long readString(char *str, unsigned long maxlen, const char delim); #if BINIO_ENABLE_STRING std::string readString(const char delim = '\0'); #endif Int peekInt(unsigned int size); Float peekFloat(FType ft); bool ateof(); void ignore(unsigned long amount = 1); protected: virtual Byte getByte() = 0; private: Float ieee_single2float(Byte *data); Float ieee_double2float(Byte *data); }; class binostream: virtual public binio { public: binostream(); virtual ~binostream(); void writeInt(Int val, unsigned int size); void writeFloat(Float f, FType ft); unsigned long writeString(const char *str, unsigned long amount = 0); #if BINIO_ENABLE_STRING unsigned long writeString(const std::string &str); #endif protected: virtual void putByte(Byte) = 0; private: void float2ieee_single(Float f, Byte *data); void float2ieee_double(Float f, Byte *data); }; class binstream: public binistream, public binostream { public: binstream(); virtual ~binstream(); }; #endif libbinio-libbinio-1.5/src/binstr.cpp000066400000000000000000000042611352246627100175420ustar00rootroot00000000000000/* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * binstr.cpp - Binary I/O on standard C strings in memory * Copyright (C) 2003, 2010 Simon Peter */ #include "binstr.h" /***** binsbase *****/ binsbase::binsbase(void *str, unsigned long len) : data((Byte *)str), spos((Byte *)str), length(len) { } binsbase::~binsbase() { } void binsbase::seek(long p, Offset offs) { switch(offs) { case Set: spos = data + p; break; case Add: spos += p; break; case End: spos = data + length + p; break; } // Seek before start of data if(spos < data) { spos = data; return; } // Seek after end of data if(spos - data > length) { err |= Eof; spos = data + length; } } long binsbase::pos() { return (long)(spos - data); } /***** binisstream *****/ binisstream::binisstream(void *str, unsigned long len) : binsbase(str, len) { } binisstream::~binisstream() { } binisstream::Byte binisstream::getByte() { Byte in = 0; if(spos - data >= length) err |= Eof; else { in = *spos; spos++; } return in; } /***** binosstream *****/ binosstream::binosstream(void *str, unsigned long len) : binsbase(str, len) { } binosstream::~binosstream() { } void binosstream::putByte(Byte b) { if(spos - data >= length) { err |= Eof; } else { *spos = b; spos++; } } /***** binsstream *****/ binsstream::binsstream(void *str, unsigned long len) : binsbase(str, len), binisstream(str, len), binosstream(str, len) { } binsstream::~binsstream() { } libbinio-libbinio-1.5/src/binstr.h000066400000000000000000000032221352246627100172030ustar00rootroot00000000000000/* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * binstr.h - Binary I/O on standard C strings in memory * Copyright (C) 2003 Simon Peter */ #ifndef H_BINIO_BINSTR #define H_BINIO_BINSTR #include "binio.h" class binsbase: virtual public binio { public: binsbase(void *str, unsigned long len); virtual ~binsbase(); virtual void seek(long p, Offset offs = Set); virtual long pos(); protected: Byte *data, *spos; long length; }; class binisstream: public binistream, virtual public binsbase { public: binisstream(void *str, unsigned long len); virtual ~binisstream(); protected: virtual Byte getByte(); }; class binosstream: public binostream, virtual public binsbase { public: binosstream(void *str, unsigned long len); virtual ~binosstream(); protected: virtual void putByte(Byte b); }; class binsstream: public binisstream, public binosstream { public: binsstream(void *str, unsigned long len); virtual ~binsstream(); }; #endif libbinio-libbinio-1.5/src/binwrap.cpp000066400000000000000000000053611352246627100177050ustar00rootroot00000000000000/* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * binwrap.cpp - Binary I/O wrapper, using standard iostreams library * Copyright (C) 2002, 2003, 2009 Simon Peter */ #include "binwrap.h" #if BINIO_ENABLE_IOSTREAM /***** biniwstream *****/ biniwstream::biniwstream(istream *istr) : in(istr) { } biniwstream::~biniwstream() { } void biniwstream::seek(long pos, Offset offs) { if(!in) { err = NotOpen; return; } switch(offs) { case Set: in->seekg(pos, ios::beg); break; case Add: in->seekg(pos, ios::cur); break; case End: in->seekg(pos, ios::end); break; } } biniwstream::Byte biniwstream::getByte() { if(!in) { err = NotOpen; return 0; } if(!in->eof()) { return (Byte)in->get(); } else { err |= Eof; return 0; } } long biniwstream::pos() { if(!in) { err = NotOpen; return 0; } return (long)in->tellg(); } /***** binowstream *****/ binowstream::binowstream(ostream *ostr) : out(ostr) { } binowstream::~binowstream() { } void binowstream::seek(long pos, Offset offs) { if(!out) { err = NotOpen; return; } switch(offs) { case Set: out->seekp(pos, ios::beg); break; case Add: out->seekp(pos, ios::cur); break; case End: out->seekp(pos, ios::end); break; } } void binowstream::putByte(binio::Byte b) { if(!out) { err = NotOpen; return; } out->put((char)b); } long binowstream::pos() { if(!out) { err = NotOpen; return 0; } return (long)out->tellp(); } /***** binwstream *****/ binwstream::binwstream(iostream *str) : biniwstream(str), binowstream(str), io(str) { } binwstream::~binwstream() { } void binwstream::seek(long pos, Offset offs) { biniwstream::seek(pos, offs); binowstream::seek(pos, offs); } long binwstream::pos() { if(!io) { err = NotOpen; return 0; } return (long)io->tellg(); } binwstream::Byte binwstream::getByte() { Byte in = biniwstream::getByte(); binowstream::seek(biniwstream::pos(), Set); // sync stream position return in; } void binwstream::putByte(Byte b) { binowstream::putByte(b); biniwstream::seek(binowstream::pos(), Set); // sync stream position } #endif libbinio-libbinio-1.5/src/binwrap.h000066400000000000000000000036371352246627100173560ustar00rootroot00000000000000/* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * binwrap.h - Binary I/O wrapper, using standard iostreams library * Copyright (C) 2002, 2003 Simon Peter */ #ifndef H_BINIO_BINWRAP #define H_BINIO_BINWRAP #include "binio.h" #if BINIO_ENABLE_IOSTREAM #if BINIO_ISO_STDLIB #include using std::iostream; using std::ostream; using std::istream; using std::ios; using std::streambuf; #else #include #endif class biniwstream: public binistream { public: biniwstream(istream *istr); virtual ~biniwstream(); virtual void seek(long pos, Offset offs = Set); virtual long pos(); protected: virtual Byte getByte(); private: istream *in; }; class binowstream: public binostream { public: binowstream(ostream *ostr); virtual ~binowstream(); virtual void seek(long pos, Offset offs = Set); virtual long pos(); protected: virtual void putByte(Byte b); private: ostream *out; }; class binwstream: public biniwstream, public binowstream { public: binwstream(iostream *str); virtual ~binwstream(); virtual void seek(long pos, Offset offs = Set); virtual long pos(); protected: virtual Byte getByte(); virtual void putByte(Byte b); private: iostream *io; }; #endif #endif libbinio-libbinio-1.5/src/libbinio.dsp000066400000000000000000000104011352246627100200250ustar00rootroot00000000000000# Microsoft Developer Studio Project File - Name="libbinio" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** NICHT BEARBEITEN ** # TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=libbinio - Win32 Debug !MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE !MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl !MESSAGE !MESSAGE NMAKE /f "libbinio.mak". !MESSAGE !MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben !MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: !MESSAGE !MESSAGE NMAKE /f "libbinio.mak" CFG="libbinio - Win32 Debug" !MESSAGE !MESSAGE Für die Konfiguration stehen zur Auswahl: !MESSAGE !MESSAGE "libbinio - Win32 Release" (basierend auf "Win32 (x86) Static Library") !MESSAGE "libbinio - Win32 Debug" (basierend auf "Win32 (x86) Static Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "libbinio - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x407 /d "NDEBUG" # ADD RSC /l 0x407 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"Release\binio.lib" # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Installing library and headers... PostBuild_Cmds=call vc6inst l "Release\binio.lib" call vc6inst i *.h libbinio # End Special Build Tool !ELSEIF "$(CFG)" == "libbinio - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x407 /d "_DEBUG" # ADD RSC /l 0x407 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"Debug\biniod.lib" # Begin Special Build Tool SOURCE="$(InputPath)" PostBuild_Desc=Installing library and headers... PostBuild_Cmds=call vc6inst l "Debug\biniod.lib" call vc6inst i *.h libbinio # End Special Build Tool !ENDIF # Begin Target # Name "libbinio - Win32 Release" # Name "libbinio - Win32 Debug" # Begin Group "Quellcodedateien" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\binfile.cpp # End Source File # Begin Source File SOURCE=.\binio.cpp # End Source File # Begin Source File SOURCE=.\binstr.cpp # End Source File # Begin Source File SOURCE=.\binwrap.cpp # End Source File # End Group # Begin Group "Header-Dateien" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\binfile.h # End Source File # Begin Source File SOURCE=.\binio.h # End Source File # Begin Source File SOURCE=.\binio.h.in !IF "$(CFG)" == "libbinio - Win32 Release" # Begin Custom Build - Rewriting $(InputName)... InputDir=. InputPath=.\binio.h.in InputName=binio.h "$(InputDir)\binio.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" copy /Y $(InputPath) $(InputDir)\$(InputName) # End Custom Build !ELSEIF "$(CFG)" == "libbinio - Win32 Debug" # Begin Custom Build - Rewriting $(InputName)... InputDir=. InputPath=.\binio.h.in InputName=binio.h "$(InputDir)\binio.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" copy /Y $(InputPath) $(InputDir)\$(InputName) # End Custom Build !ENDIF # End Source File # Begin Source File SOURCE=.\binstr.h # End Source File # Begin Source File SOURCE=.\binwrap.h # End Source File # End Group # End Target # End Project libbinio-libbinio-1.5/src/vc6inst.bat000077500000000000000000000022101352246627100176140ustar00rootroot00000000000000@echo off rem This batch file installs the distribution files. rem Copyright (c) 2002 Simon Peter rem rem This file is called from MSVC6! Please do not run it manually! if "%1" == "" goto manually if "%2" == "" goto manually rem Defaults. set bindir=. set includedir=. set libdir=. rem Read configuration. if not exist config.bat goto noconfig call config.bat rem Check target directory presence. if not exist "%bindir%" mkdir "%bindir%" if not exist "%includedir%" mkdir "%includedir%" if not exist "%libdir%" mkdir "%libdir%" rem Check for includedir subdirectory. if not "%3" == "" set includedir=%includedir%\%3 if not exist "%includedir%" mkdir "%includedir%" rem Install specified file. if exist %2 goto install echo Error installing %2 - file not found! goto end :install if "%1" == "b" copy %2 "%bindir%" > nul if "%1" == "i" copy %2 "%includedir%" > nul if "%1" == "l" copy %2 "%libdir%" > nul goto end :manually echo This file is called from MSVC6! Please do not run it manually! goto end :noconfig echo No configuration file found! echo Please refer to the distribution's documentation on how to create one. goto end :end