dtaus-0.9/0000755000076500007650000000000011233255546011220 5ustar joeyjoeydtaus-0.9/dtaus.h0000644000076500007650000000212210104764260012500 0ustar joeyjoey/* dtaus.h - Datentraegeraustausch mit einer Bank Copyright (c) 1996,8 Martin Schulze This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. $Id: dtaus.h,v 1.3 2004-08-06 20:23:12 joey Exp $ */ #ifndef _DTAUS_H_ #define _DTAUS_H_ void dtaus2control (char *cdtaus, char *ccontrol); int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck, char *latex); #endif /* _DTAUS_H_ */ dtaus-0.9/COPYING0000644000076500007650000004307006501244244012252 0ustar joeyjoey GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. dtaus-0.9/dtaus.cls0000644000076500007650000000146010104762777013051 0ustar joeyjoey% This is only a sample file. Some macros don't do anything and % others only provide barely any layout. However, it can be adjusted % for your organisation to provide a nice page with header, footer and % whatnot, if you like. \NeedsTeXFormat{LaTeX2e} \ProvidesClass{dtaus} \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} \ProcessOptions \LoadClass[11pt, a4paper]{article} \RequirePackage[latin1]{inputenc} \RequirePackage[T1]{fontenc} \RequirePackage{german} \thispagestyle{empty} \newcommand{\header}{} \newcommand{\footer}{} \newcommand{\headline}[1]{\centerline{\LARGE\textbf{#1}}\vspace{1cm}} \newcommand{\subheadline}[1]{\centerline{\Large\textbf{#1}}\vspace{0.7cm}} \newcommand{\tabline}[2]{#1 \dotfill & #2\\} \newcommand{\signature}{% \hrulefill Ort, Datum \hfill Unterschrift } dtaus-0.9/dtaus.50000644000076500007650000001276710101727342012432 0ustar joeyjoey.\" dtaus - Converter for DTAUS files .\" Copyright (c) 2000,1,3 Martin Schulze .\" .\" This program is free software; you can redistribute it and/ormodify .\" it under the terms of the GNU General Public License as published by .\" the Free Software Foundation; either version 2 of the License, or .\" (at your option) any later version. .\" .\" This program is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with this program; if not, write to the Free Software .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. .\" .TH DTAUS 5 "17 November 2001" "" "" .SH NAME dtaus \- Converter for DTAUS files .SH DESCRIPTION The .BR dtaus (1) program reads and writes German DTAUS files. DTAUS is an semi-acronym for .BR D aten T räger AUS tausch. It is used by German credit institutes in order to implement money exchanges between accounts and credit institutes. These files are always called .IR DTAUS0.TXT . Since they are shipped in a weird ascii format that is not quite readable and writable for human beings a special control format was invented. The .BR dtaus (1) program reads and writes such a control file and generates a proper DTAUS file if requested or decodes one. .SH "CONTROL FILE" The control file implements a very simple format which was invented only for use with the .BR dtaus (1) program. Like with many *nix configuration files empty lines and those beginning with a hash mark (``#'') are ignored. The remaining file is splitted into three major parts: one BEGIN record (representing the A record), several regular records (representing C records) and one optional END record (representing the E record), which is ignored when the control file is read but is extracted from the bank file if one is decoded. Here's a short sample for a control file: BEGIN { Art \fItype\fR Name Martin Schulze Konto 123545 BLZ 2004002 Ausfuehrung 23.12.2001 Euro } { Transaktion \fItransaction\fR Name Martha Schulze Konto 98832 BLZ 2004003 Betrag 20.00 Zweck Gebühr Wohnheimnetz Text Anschluß u. 11+12.97 } ... Please note that several field names are used in both the BEGIN and the regular record. When used in the BEGIN record they denote your name and your bank account. When used in a regular record they are affiliated with your customers data. You may use up to 15 fields entitled as .BR Text . They will be recorded one by one and stored into additional data records using the same order. This way you could add a detailed description of the type of money transfer if you like. The contents of the field .B Zweck are most probably what the customer will see on their bank statements. The field .B Ausfuehrung is optional and denotes the day when the entire transaction should be processed. The date has to be given as DD.MM.YYYY and will be translated into the resulting bank file literally. It may not be younger than the creation date of the file which will automatically be inserted by .BR dtaus (1). The processing date also may not be more than 15 years later than the creation date. .SS Explanation of type One of the following: .TP .I LK Lastschrift Kundenseitig .TP .I GK Gutschrift Kundenseitig .TP .I LB Lastschrift Bankseitig .TP .I GB Gutschrift Bankseitig .SS Explanation of transaction One of the following: .TP .I Einzug Bankeinzug .TP .I Gutschrift Überweisung .TP .IR Vermögen " [JJJJ]" Vermögenswirksame Leistung mit Sparzulage. Als Argument kann das Jahr angegeben werden, für das diese Leistung gilt. Wenn es weggelassen, wird, verwendet .B dtaus das aktuelle Jahr. Vom Jahr wird nur die letzte Ziffer verwendet, es muß daher auch nicht vollständig angegeben werden. .TP .IR Vermoegen " [JJJJ]" Wie .IR Vermögen , jedoch ohne Umlaut. .TP .I E-Cash Lastschrift aus Verfügung im elecctronic Cash-System .TP .I E-Cash-A Lastschrift aus Verfügung im elecctronic Cash-System mit ausländischer Karte. .PP You may only use one of these for the entire file. You are not allowed to switch between Einzug and Gutschrift within the same file. If you require the credit institute to process both types, you'll have to provide two separate diskettes. .SS "Support for Euro" From January 1st 2002 the currency in many European countries, Germany is among these, changes to Euro. Hence, money transfer changes from DM (formerly known as ``Deutsche Mark'') to Euro. The format specification of DTAUS was meant for DM but was modified in 2001 to support Euro as well. The current version of .BR dtaus (1) supports both currencies. It defaults to using Euro, however. To switch to DM, simply add the keyword .B DM (or .B Euro respectively if this version was compiled without Euro support as default) to the BEGIN record. If no currency keyword is given, the compiled in decides (upstream source defaults to Euro). .SS "Character Encoding" German Umlauts are converted into two 7-bit characters on the fly so you don't need to care about them. Since the .I DTAUS0.TXT file only uses uppercase letters every text is also converted to uppercase. Except for the way records are delimited the format should be self explanatory. .SH "SEE ALSO" .BR dtaus (1). DTAUS files use a special but simple and publically documented format. It is included in the distribution of .BR dtaus (1) as .IR dtaus.txt . dtaus-0.9/dtaus.10000644000076500007650000002064510104764322012422 0ustar joeyjoey.\" dtaus - Converter for DTAUS files .\" Copyright (c) 1998,2001 Martin Schulze .\" .\" This program is free software; you can redistribute it and/ormodify .\" it under the terms of the GNU General Public License as published by .\" the Free Software Foundation; either version 2 of the License, or .\" (at your option) any later version. .\" .\" This program is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with this program; if not, write to the Free Software .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. .\" .TH DTAUS 1 "17 November 2001" "" "" .SH NAME dtaus \- Converter for DTAUS files .SH SYNOPSIS .B dtaus .RB [ " \-d " .IR dtaus " ]" .RB [ " \-c " .IR control " ]" .RB [ " \-b " .IR begleit " ]" .RB [ " \-l " .RI " [" begleit "] ]" .RB [ " \-o " .IR kontroll " ]" .BR -dtaus " | " -control .SH DESCRIPTION This program can read and write German DTAUS files. DTAUS is an semi-acronym for .BR D aten T räger AUS tausch. It is used by German credit institutes in order to manage mass money exchanges between customer accounts and credit institutes. Due to its limited availability and usefulness most of the documentation is held in German. This program is only useful in Germany or for companies that act in Germany. For a complete description of the control file please refer to .I dtaus.txt and .BR dtaus (5) from this distribution. .SH OPTIONS You have to specify exactly one of .BR \-dtaus " or " \-control . .TP .B \-dtaus Liest die Kontrolldatei ein und erzeugt daraus die Bankdatei sowie alle anderen benötigten Dateien. .TP .B \-control Liest eine Bankdatei ein und erzeugt daraus die Kontrolldatei, dekodiert eine bereits erstellte Bankdatei. .TP .BI \-d " dtaus" Explizite Angabe des Dateinamens für die Bankdatei. Voreingestellt ist .BR dtaus0.txt , was von der Bank als einziger Dateiname auf der Diskette erwartet wird. Für Testzwecke oder zur Weiterverarbeitung darf hier die spezielle Datei ``-'' angegeben werden, wodurch .B dtaus angewiesen wird, auf die Standardausgabe zu schreiben. .TP .BI \-c " control" Explizite Angabe des Dateinamens der Steuerdatei. Voreingestellt ist .BR dtaus0.ctl . Da dieser Name jedoch nur intern verwendet wird, ist er keinen Beschränkungen unterlegen. In dieser Datei befinden sich die gesamten visuell lesbaren Informationen für den Geldverkehr. Diese Datei muß für die Bank in das spezielle DTAUS-Format konvertiert werden. Das geschieht mit dem Schalter .BR \-dtaus . .TP .BI \-b " begleit" Explizite Angabe des Dateinamens des Begleitzettels. Voreingestellt ist .BR dtaus0.doc . Da dieser Name jedoch nur intern verwendet wird, ist er keinen Beschränkungen unterlegen. Diese Datei muß ausgedruckt und der Diskette unterschrieben beigelegt werden. .TP .BI \-l " \fR[\fIbegleit\fR]\fI" LaTeX-Ausgabe des Begleit-Zettels erwünscht. Diese Datei wird normalerweise nicht geschrieben. Voreingestellt ist .B dtaus0.tex als Dateiname, es kann jedoch ein anderer angegeben werden. Für die Compilierung wird .I dtaus.cls benötigt. Diesem Programm liegt eine einfache Implementierung bei, idealerweise wird jedoch eine lokal angepaßte Klasse verwendet, die Kopf- und Fußzeilen mit Logos und Adressen realisiert. .TP .BI \-o " kontroll" Explizite Angabe des Dateinamens für die Kontrolldatei. Voreingestellt ist .BR dtaus0.sik . Da dieser Name jedoch nur intern verwendet wird, ist er keinen Beschränkungen unterlegen. Es ist ratsam, diese Datei gut aufzubewahren oder auszudrucken und abzuheften. Dieses ist neben der Steuer- und Bankdatei die einzige Aufschlüsselung des getätigten Geldverkehrs. .SH BESCHREIBUNG Deutsche Banken bieten für Großkunden oder Kunden mit vielen ähnlichen Überweisungen oder Bankeinzügen (auch Lastschriften genannt) die Möglichkeit des papierlosen Geldverkehrs über den Beleglosen Datenträgeraustausch an. Hierbei wird nicht mehr für jede Überweisung oder jeden Einzug ein eigenes Formular benötigt, sondern zusammengehörige Aufträge werden in einer Massensendung verpackt gemeinsam verarbeitet. Hier ist jedoch Vorsicht geboten, denn auf dem eigenen Konto erscheint lediglich eine einzige Kontobewegung. Wenn Geld eingezogen wird, enthält der Kontoauszug nur die Gesamtsumme, wenn Geld überwiesen wird, ist auf dem Kontoauszug nur die Gesamtsumme notiert. Es ist daher immens wichtig, die Ursprungsdaten aufzubewahren bzw. die Kontrolldatei auszudrucken und abzuheften. Um an diesem Verfahren teilzunehmen, das den Geldverkehr für Organisationen erheblich vereinfachen kann, muß mit der jeweiligen Bank eine gesonderte Vereinbarung getroffen werden, in der die speziellen Bestimmungen für diesen Datenträgeraustausch akzeptiert werden. Durch das einfache Format der Steuerdatei läßt sich dieses Verfahren leicht mit einer Datenbank oder einem größeren Programm koppeln. In der Tat entstand das Programm nach Aufbau des ersten Wohnheimnetzes in Oldenburg (Oldbg.) und der ernüchternden Erkenntnis, daß die vom Kassenwart verwendeten Programme für den Datenträgeraustausch weder zuverlässig noch nachvollziehbar arbeiteten und somit Ersatz geschaffen werden mußte. Die technische und finanzielle Verwaltung des Wohnheimnetzes fand über ein Linux-System mit Datenbankanbindung sowie .B dtaus statt. .SH BESONDERHEITEN Bei der Verwendung dieses Programms müssen wenigstens die folgenden Dinge beachtet werden, es sind Vorgaben von den beteiligten Banken. .TP 1. Die Diskette muß mit dem MSDOS-Dateisystem beschrieben sein. .TP 2. Auf einer Diskette darf nur eine einzige DTAUS-Datei enthalten sein, die den Dateinamen .B DTAUS0.TXT trägt. .TP 3. Der Diskette muß ein Begleitzettel beigelegt werden, der einige Angaben erneut enthält sowie persönlich unterschrieben ist. Dieser Begleitzettel wird von .B dtaus automatisch erzeugt und voreingestellt in der Datei .B dtaus0.doc gespeichert, die nur noch ausgedruckt und unterschrieben werden muß. .TP 4. Um den Beleglosen Datenträgeraustausch nutzen zu können, muß vorher eine Zusatzvereinbarung mit der Bank getroffen werden. .TP 5. Die Angaben zum Verwendungszweck haben sich ausschließlich auf den jeweiligen Zahlungsverkehrsvorgang zu beziehen. Verwendungszweckangaben dürfen nicht die Übermittlung einer gesonderten Nachricht außerhalb des Zahlungsverkehrs (z.B. Rechnung, Lohn- und Gehaltsabrechnung) ersetzen. Werbetexte dürfen in den Verwendungszweckangaben nicht enthalten sein. .TP 6. Der Kunde ist verpflichtet, den Inhalt der von ihm gelieferten Datenträger mindestens für einen Zeitraum von zehn Kalendertagen ab Einlieferung in der Form nachweisbar zu halten, daß dem Institut auf Anforderung kurzfristig besonders gekennzeichnete Duplikatsdatenträger geliefert werden können. .TP 7. Der Rückruf eines Datenträgers ist ausgeschlossen, sobald das Kreditinstitut mit dessen Verarbeitung begonnen hat. Einzelne Überweisungen und Lastschriften können nach Verarbeitung eines Datenträgers nur außerhalb des Datenträgeraustauschverfahrens zurückgerufen werden. .TP 8. Das Kreditinstitut führt Konsistenzprüfungen der auf dem Datenträger gespeicherten Datei durch. Schlägt diese fehl, können einzelne Datensätze von der Bearbeitung ausgeschlossen oder der gesamte Auftrag verworfen werden. .TP 9. Ergeben sich bei der Kontrolle der Datenträger durch das Kreditinstitut Fehler, so wird es die fehlerhaften Datensätze in ihrem vollständigen Inhalt nachweisen und sie dem Kunden unverzüglich mitteilen. .TP 10. Das Kreditinstitut gibt dem Kunden die von ihm erhaltenen Datenträger zurück. Sie können meistens schon am nächsten Werktag in der Filiale abgeholt werden. .TP 11. Gutschriften und Belastungen, die auf einem an den Kunden ausgelieferten Datenträger enthalten sind, werden als Sammelbuchungen auf dem Konto des Kunden gebucht. .TP 12. In einer Bankdatei kann ein Ausführungsdatum angegeben werden, wenn die Bearbeitung der Diskette zu einem späteren Zeitpunkt als der Abgabe der Datei gewünscht wird. Dieses Datum darf jedoch nicht jünger als das Erstellungsdatum (wird automatisch von .B dtaus eingefügt) sein und höchstens 15 Kalendertage über dem Erstellungsdatum liegen. .SH "RETURN VALUES" On success, zero is returned. On error, 1 is returned. .SH "SEE ALSO" .BR dtaus (5). DTAUS files use a special but simple and publically documented format. It is included in the distribution of .B dtaus as .IR dtaus.txt . dtaus-0.9/latex.c0000644000076500007650000000623010104764110012466 0ustar joeyjoey/* latex.c - Belegloser Datenträgeraustausch mit einer Bank Copyright (c) 2004 Martin Schulze This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. $Id: latex.c,v 1.1 2004-08-06 20:21:28 joey Exp $ */ #include #include "bigint.h" #define LATEX_HEADER "%% Automatically generated by dtaus, requires dtaus.cls from the\n\ %% source distribution or derivative class.\n\ %%\n\ \\documentclass{dtaus}\n\ \n\ \\begin{document}\n\ \n\ \\header\n\ \n\ \\headline{Begleitzettel}\n\ \n\ \\subheadline{Belegloser Datenträgeraustausch}\n\ " #define LATEX_FOOTER "\\vfill\n\ \n\ \\signature\n\ \n\ \\footer\n\ \n\ \\end{document}\n\ " #define LATEX_TYPE "\\subheadline{%s}\n\n" #define LATEX_TAB_BEGIN "\\begin{tabular}{l@{ : }l}\n" #define LATEX_TAB_END "\\end{tabular}\n\n" #define LATEX_TAB_ROW "\\tabline{%s}{%s}\n" void generate_latex_receipt ( char *fname, char *type, char *created, char *todo, char *currency, int quantity, char *sum_val, char *sum_kto, char *sum_blz, char *kto, char *blz ) { FILE *f; char tmp[10]; if (!(f = fopen(fname, "w"))) { fprintf (stderr, "Cannot open LaTeX output file %s, ignoring.\n", fname); return; } /* fopen() */ fprintf (f, LATEX_HEADER); fprintf (f, LATEX_TYPE, type); fprintf (f, LATEX_TAB_BEGIN); fprintf (f, LATEX_TAB_ROW, "VOL", ""); fprintf (f, LATEX_TAB_ROW, "Erstellungsdatum", created); if (todo) fprintf (f, LATEX_TAB_ROW, "Ausführugsdatum", todo); fprintf (f, LATEX_TAB_ROW, "Währung", currency); snprintf (tmp, sizeof (tmp), "%d", quantity); fprintf (f, LATEX_TAB_ROW, "Anzahl", tmp); fprintf (f, LATEX_TAB_ROW, "Summe", sum_val); fprintf (f, LATEX_TAB_ROW, "Kontrollsumme Kontonummern", sum_kto); fprintf (f, LATEX_TAB_ROW, "Kontrollsumme Bankleitzahlen", sum_blz); fprintf (f, LATEX_TAB_ROW, "Unsere Kontonummer", kto); fprintf (f, LATEX_TAB_ROW, "Unsere Bankleitzahl", blz); fprintf (f, LATEX_TAB_END); fprintf (f, LATEX_FOOTER); fclose (f); } /* -------------------- \subheadline{Sammeleinziehungsauftrag} \begin{tabular}{l@{ : }l} \tabline{VOL}{} \tabline{Erstellungsdatum}{05.08.04} \tabline{Ausführugsdatum}{24.12.2001} \tabline{Währung}{Euro} \tabline{Anzahl}{2} \tabline{Summe}{50.00} \tabline{Kontrollsumme Kontonummern}{2469134} \tabline{Kontrollsumme Bankleitzahlen}{94221630} \tabline{Unsere Kontonummer}{0000123545} \tabline{Unsere Bankleitzahl}{02004002} \end{tabular} -------------------- */ dtaus-0.9/Makefile0000644000076500007650000000214110302424751012646 0ustar joeyjoey# Makefile - Belegloser Datenträgeraustausch mit einer Bank # Copyright (c) 1996,8,2000,4 Martin Schulze # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. # # $Id: Makefile,v 1.8 2005-08-22 19:39:21 joey Exp $ # # Needs the bigint module # CC = gcc CFLAGS = -Wall -O3 OBJS = dtaus.o main.o bigint.o latex.o dtaus: $(OBJS) $(CC) -o dtaus $(OBJS) test_bigint: bigint.o test_bigint.o clean: rm -f *.o dtaus test_bigint dtaus-0.9/dtaus.c0000644000076500007650000010631411233115377012506 0ustar joeyjoey/* dtaus.c - Belegloser Datenträgeraustausch mit einer Bank Copyright (c) 1996,8,2001-4,5,9 Martin Schulze This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. $Id: dtaus.c,v 1.48 2009-07-26 18:05:51 joey Exp $ */ #include "dtaus.h" #include "bigint.h" #include #include #include #include #include #include #include "latex.h" #define DEFAULT_EURO #ifndef DEFAULT_EURO int use_euro = 0; #else int use_euro = 1; #endif /* * First: Some control structures */ typedef struct { char *name; unsigned short int pos; unsigned short int len; int type; } dtaus_record; #define REC_A 1 #define REC_C 2 #define REC_E 3 #define REQ 1 #define OPT 2 #define IGN 3 dtaus_record recA[] = { {"Art", 5, 2, REQ}, {"Name", 23, 27, REQ}, {"Konto", 60, 10, REQ}, {"BLZ", 7, 8, REQ}, {"Referenz", 70, 10, OPT}, {"Datum", 50, 6, IGN}, {"Ausfuehrung", 95, 8, OPT}, {"Currency", 127, 1, OPT}, {"Euro", 127, 1, OPT}, {"DM", 127, 1, OPT}, {NULL, 0, 0, 0} }; #define A_TRANS 0 #define A_NAME 1 #define A_KTO 2 #define A_BLZ 3 #define A_REF 4 #define A_DATE 5 #define A_TODO 6 #define A_CURR 7 #define A_EURO 8 #define A_DM 9 #define A_LEN 10 #define A_LOOP 7 dtaus_record recC[] = { {"Name", 93, 27, REQ}, {"Konto", 21, 10, REQ}, {"BLZ", 13, 8, REQ}, {"Transaktion", 44, 5, REQ}, #ifndef DEFAULT_EURO {"Betrag", 50, 11, REQ}, #else {"Betrag", 79, 11, REQ}, #endif {"Zweck", 155, 27, REQ}, {"myName", 128, 27, OPT}, {"myKonto", 69, 10, OPT}, {"myBLZ", 61, 8, OPT}, {"Text", 187, 29, OPT}, {"Extension", 216, 29, OPT}, {"Currency", 182, 1, IGN}, #ifndef DEFAULT_EURO {"Betrag-Euro", 79, 11, IGN}, #else {"Betrag-DM", 50, 11, IGN}, #endif {NULL, 0, 0, 0} }; #define C_NAME 0 #define C_KTO 1 #define C_BLZ 2 #define C_TRANS 3 #define C_VAL 4 #define C_ZWECK 5 #define C_MYNAM 6 #define C_MYKTO 7 #define C_MYBLZ 8 #define C_TEXT 9 #define C_EXT 10 #define C_EURO 11 #ifndef DEFAULT_EURO #define C_EUR 12 #else #define C_DM 12 #endif #define C_LEN 13 #define C_LOOP 11 #define MAX_TEXT 14 dtaus_record recE[] = { {"Anzahl", 10, 7, IGN}, #ifndef DEFAULT_EURO {"Summe", 17, 13, IGN}, #else {"Summe", 64, 13, IGN}, #endif {"Kontos", 30, 17, IGN}, {"BLZs", 47, 17, IGN}, #ifndef DEFAULT_EURO {"Summe-Euro", 64, 13, IGN}, #else {"Summe-DM", 17, 13, IGN}, #endif {NULL, 0, 0, 0} }; #define E_COUNT 0 #define E_VAL 1 #define E_KTO 2 #define E_BLZ 3 #ifndef DEFAULT_EURO #define E_EUR 4 #else #define E_DM 4 #endif #define E_LEN 5 /* * Second: Some low level routines */ size_t dtaus_nextrec (void **buf, FILE *f) { memset (buf, 0, 128); return fread(buf, 128, 1, f); } char *upcase(char *s) { static char x[100]; static char *xp; char *cp; for (cp=s,xp=x; *cp; cp++,xp++) { if (strchr(" 0123456789.,&-/+*$%ABCDEFGHIJKLMNOPQRSTUVWXYZ",*cp)) { *xp = *cp; } else if (strchr("abcdefghijklmnopqrstuvwxyz",*cp)) { *xp = toupper(*cp); } else if (strchr ("üÜäÄöÖß", *cp)) { switch (*cp) { case 'ü': *(xp++) = 'U'; *xp='E'; break; case 'Ü': *(xp++) = 'U'; *xp='E'; break; case 'ä': *(xp++) = 'A'; *xp='E'; break; case 'Ä': *(xp++) = 'A'; *xp='E'; break; case 'ö': *(xp++) = 'O'; *xp='E'; break; case 'Ö': *(xp++) = 'O'; *xp='E'; break; case 'ß': *(xp++) = 'S'; *xp='S'; break; } } else /* * Filter out all other characters since credit institutes won't * accept the file otherwise. */ *xp = ' '; } *xp = '\0'; return x; } char *downcase(char *s) { static char x[100]; char *cp; memset (x, 0, sizeof (x)); strncpy (x, s, 99); for (cp=x;*cp;cp++) if (isupper(*cp)) *cp = tolower(*cp); return x; } char *strip_spaces (char *s) { int i; char *p; for (i=strlen(s);(s[i-1] == ' '||s[i-1] == '\t')&&i>0; i--) s[i-1] = '\0'; for (p=s; *p==' '; p++); return p; } char *strip_zeros (char *s) { char *p; for (p=s; *p=='0'; p++); return p; } char *strip_nondigits (char *s) { char *p; char *x; for (x=s,p=s;*x;x++) if (isdigit (*x)) *(p++) = *x; *(p++) = '\0'; return s; } char dtaus_char (void *buf, unsigned int pos) { static char res; char *bufp = (char *)buf; bufp+=pos; memcpy(&res, bufp, 1); return res; } char *string2real(char *s) { static char res[20]; char *cp = s; cp+=strlen(s)-2; strncpy(res, s, strlen(s)-2); res[strlen(s)-2] = '.'; res[strlen(s)-1] = s[strlen(s)-2]; res[strlen(s)] = s[strlen(s)-1]; return res; } char *real2string(char *s) { static char res[20]; char *cp; char *xp; /* only to avoid a GCC warning */ strncpy(res, s, sizeof(res)-1); res[sizeof(res)-1] = 0; for (cp=res; *cp&&!(*cp == ',')&&!(*cp == '.');cp++); if ((cp-res) >= (sizeof(res)-3)) { /* Bail out, since the number is too large, shouldn't be possible though. */ fprintf (stderr, "Value %s too large.\n", res); exit (1); } if (*cp == '.' || *cp == ',') { if (*(cp+1)) { /* 1st decimal place */ xp = cp+1; if (*xp && isdigit(*xp)) *(cp++) = *xp; else *(cp++) = '0'; /* 2nd decimal place */ xp = cp+1; if (*xp && isdigit(*xp)) *(cp++) = *xp; else *(cp++) = '0'; } else { *(cp++) = '0'; *(cp++) = '0'; } } else { *(cp++) = '0'; *(cp++) = '0'; } *cp = '\0'; return res; } /* * Return the last digit of the year as character */ char get_date_lastdigit() { time_t timer; struct tm *loctime; timer = time ( NULL ); loctime = localtime(&timer); return loctime->tm_year % 10 + '0'; } char *string2trans (char *s) { static char res[30]; res[0] = '\0'; if (!strcmp(s, "04000")) sprintf (res, "Abbuchung"); else if (!strcmp(s, "05000")) sprintf (res, "Einzug"); else if (!strcmp(s, "05005")) sprintf (res, "E-Cash"); else if (!strcmp(s, "05006")) sprintf (res, "E-Cash-A"); else if (!strcmp(s, "51000")) sprintf (res, "Gutschrift"); else if (!strcmp(s, "53000")) sprintf (res, "Lohn"); else if (!strncmp(s, "5400", 4)) sprintf (res, "Vermögen %c",s[4]); /* else if (!strcmp(s, "56000")) sprintf (res, ""); / * Überweisung öffentlicher Kassen */ return res; } char *trans2string (char *s) { static char res[30]; char *cp; res[0] = '\0'; if (!strcmp(s, "Abbuchung")) sprintf (res, "04000"); else if (!strcmp(s, "Einzug")) sprintf (res, "05000"); else if (!strcmp(s, "E-Cash")) sprintf (res, "05005"); else if (!strcmp(s, "E-Cash-A")) sprintf (res, "05006"); else if (!strcmp(s, "Gutschrift")) sprintf (res, "51000"); else if (!strcmp(s, "Lohn")) sprintf (res, "53000"); else { cp = NULL; if (!strncmp(s, "Vermögen", 8)) cp = s+8; if (!strncmp(s, "Vermoegen", 9)) cp = s+9; if (!cp) { fprintf (stderr, "Unbekannte Transaktion `%s'\n", res); exit (1); } /* Vermögen --> 5400 Vermögen 8 -> 5400<8> Vermögen 2003 -> 5400<3> */ if (*cp) while (!isspace(*cp)) cp++; while (isspace(*cp)) cp++; if (!*cp || !isdigit(*cp)) sprintf (res, "5400%c",get_date_lastdigit()); else { while (isdigit(*cp)) cp++; sprintf (res, "5400%c",*(cp-1)); } } /* else if (!strcmp(s, "")) sprintf (res, "56000"); / * Überweisung öffentlicher Kassen */ return res; } char *string2ext (char *s) { static char res[30]; res[0] = '\0'; if (!strcmp(s, "01")) sprintf (res, "Kunde"); else if (!strcmp(s, "02")) sprintf (res, "Text"); else if (!strcmp(s, "03")) sprintf (res, "Auftraggeber"); return res; } char *ext2string (char *s) { static char res[3]; res[0] = '\0'; if (!strcmp(s, "Kunde")) sprintf (res, "01"); else if (!strcmp(s, "Text")) sprintf (res, "02"); else if (!strcmp(s, "Auftraggeber")) sprintf (res, "03"); return res; } unsigned long int dtaus_int(void *buf, unsigned int pos, unsigned int len) { char tmp[30]; char *bufp = (char *)buf; static unsigned long int res; bufp+=pos; memcpy(tmp, bufp, len); tmp[len] = '\0'; sscanf(tmp, "%lu", &res); return res; } /* * returns the first word in this line, returns it and shortens the * line. */ char *extract_ident (char *line) { char *c, *x, *y; static char word[30]; if (strlen(line) > 0) { x = strchr (line, ' '); y = strchr (line, '\t'); if (!x && !y) { strncpy(word, downcase(line), 29); line[0] = '\0'; return word; } /* Check which index returns the lower value, and check if the value is non-NULL */ if ((c = (x && x len) { q=s+len; *(q--) = '\0'; return s; } q=s+len; *(q--) = '\0'; for (p=s+strlen(s)-1;p>=s;p--) *(q--)=*p; for (;q>=s;) *(q--)='0'; return s; } int rec_index(char *ident, int type) { int i; dtaus_record *rec = NULL; switch (type) { case REC_A: rec = recA; break; case REC_C: rec = recC; break; case REC_E: rec = recE; break; } for (i=0; (rec[i].name); i++) { if (!strcmp(ident, downcase(rec[i].name))) return i; } return -1; } size_t control_nextline (void **buf, int len, FILE *f) { char line[100]; char tmp[100]; char *cp; int i; memset (line, 0, sizeof(line)); memset (buf, 0, len); cp = line; while (!strlen(line) && (cp = fgets(line, 100, f))) { if (strlen(line)) { if (line[0] != '#') { if (line[strlen(line)-1] != '\n') { strcpy(tmp, line); while (tmp[strlen(tmp)-1] != '\n' && (cp = fgets(tmp, 100, f))); } else line[strlen(line)-1] = '\0'; if (line[strlen(line)-1] == '\r') line[strlen(line)-1] = '\0'; for (i=strlen(line);(line[i-1] == ' '||line[i-1] == '\t')&&i>0; i--) line[i-1] = '\0'; } else line[0] = '\0'; } } for (cp=line; *cp==' '; cp++); if (strlen(cp)) { memcpy(buf, cp, strlen(cp)); return 1; } else return 0; } /* * Return the current date nicely formatted */ char *get_date() { static char res[10]; time_t timer; struct tm *loctime; timer = time ( NULL ); loctime = localtime(&timer); sprintf(res, "%02d.%02d.%02d", loctime->tm_mday, loctime->tm_mon+1, loctime->tm_year % 100); return res; } /* * Prepare a record A according to the specs. * See dtaus.txt for explanation */ void dtaus_prepareA (char *buf) { int i; time_t timer; struct tm *loctime; char tmp[10]; memset (buf, 0, 129); timer = time ( NULL ); loctime = localtime(&timer); buf[0] = '0'; buf[1] = '1'; buf[2] = '2'; buf[3] = '8'; buf[4] = 'A'; for (i=15;i<15+8; i++) buf[i] = '0'; /* A5 */ sprintf(tmp, "%02d%02d%02d", loctime->tm_mday, loctime->tm_mon+1, loctime->tm_year % 100); for (i=0; i<6; i++) buf[50+i] = tmp[i]; /* A7 (Date) */ for (i=56;i<56+4; i++) buf[i] = ' '; /* A8 */ for (i=70;i<70+10; i++) buf[i] = '0'; /* A10 */ for (i=80;i<80+48; i++) buf[i] = ' '; /* A11 */ if (use_euro) buf[recA[A_CURR].pos] = '1'; /* A12 (Currency) */ else buf[recA[A_CURR].pos] = ' '; /* A12 (Currency) */ } /* * Prepare a record C according to the specs. * See dtaus.txt for explanation */ void dtaus_prepareC (char *buf, int normaltext, int maxtext) { int i; int appendix = 0; memset (buf, 0, 257); if (normaltext) appendix = 1; appendix += maxtext; i = 187 + (appendix * 29); /* Bail out if the number is too large, shouldn't be possible though */ if (i >= 1000) exit (1); buf[0] = (i/1000)+48;i-=(i/1000)*100; buf[1] = (i/100)+48;i-=(i/100)*100; buf[2] = (i/10)+48;i-=(i/10)*10; buf[3] = i+48; buf[4] = 'C'; for (i=31;i<31+13; i++) buf[i] = '0'; /* C6 */ buf[49] = ' '; /* C8 */ for (i=50;i<50+11; i++) buf[i] = '0'; /* C9 (Betrag) */ for (i=79;i<79+11; i++) buf[i] = '0'; /* C12 (Betrag Euro) */ for (i=90;i<90+3; i++) buf[i] = ' '; /* C13 */ for (i=93;i<90+27; i++) buf[i] = ' '; /* C14a (Kunde) */ for (i=120;i<120+8; i++) buf[i] = ' '; /* C14b */ if (use_euro) buf[recC[C_EURO].pos] = '1'; /* C17a (Currency) */ else buf[recC[C_EURO].pos] = ' '; /* C17a (Currency) */ for (i=183;i<183+2; i++) buf[i] = ' '; /* C17b */ for (i=187;i<187+(29*2); i++) buf[i] = ' '; /* C19-C22 (misc text) */ for (i=245;i<245+11; i++) buf[i] = ' '; /* C23 */ buf[185+0] = (appendix/10)+48;appendix-=(appendix/10)*10; buf[185+1] = appendix+48; } /* * Prepare a record E according to the specs. * See dtaus.txt for explanation */ void dtaus_prepareE (char *buf) { int i; memset (buf, 0, 129); buf[0] = '0'; buf[1] = '1'; buf[2] = '2'; buf[3] = '8'; buf[4] = 'E'; for (i=5;i<5+5; i++) buf[i] = ' '; /* E3 */ for (i=17;i<17+13; i++) buf[i] = '0'; /* E8 (Check Betrag) */ for (i=64;i<64+13; i++) buf[i] = '0'; /* E8 (Check Euro) */ for (i=77;i<77+51; i++) buf[i] = ' '; /* E9 */ } int dtaus_writeA(FILE *f, char **values) { char buf[129]; char tmp[30]; int i; for (i=0; (recA[i].name); i++) if ((recA[i].type == REQ) && !values[i]) { fprintf (stderr, "Anfangsdatensatz ist nicht vollständig, kein %s.\n", recA[i].name); return 0; } if (!(((values[A_TRANS][0] == 'L')||(values[A_TRANS][0] == 'G')) &&((values[A_TRANS][1] == 'B')||(values[A_TRANS][1] == 'K')))) { fprintf (stderr, "Ungültiger Typ, nur LK, GK, LB oder GB erlaubt.\n"); return 0; } i=A_NAME;if (values[i] && strlen(values[i]) > recA[i].len) values[i][recA[i].len] = '\0'; dtaus_prepareA(buf); buf[5] = values[A_TRANS][0]; buf[6] = values[A_TRANS][1]; sprintf (tmp, "%s", padzeroclip (strip_nondigits (values[A_BLZ]),recA[A_BLZ].len)); for (i=0; i recC[i].len) values[i][recC[i].len-2] = '\0'; i=C_ZWECK;if (values[i] && strlen(values[i]) > recC[i].len) values[i][recC[i].len] = '\0'; i=C_MYNAM;if (values[i] && strlen(values[i]) > recC[i].len) values[i][recC[i].len] = '\0'; i=C_TEXT;if (values[i] && strlen(values[i]) > recC[i].len) values[i][recC[i].len] = '\0'; dtaus_prepareC (buf, values[C_TEXT] != NULL, maxtext); for (i=0; i<5; i++) buf[recC[C_TRANS].pos+i] = tmp[i]; if (values[C_MYBLZ]) sprintf (tmp, "%s", padzeroclip (strip_nondigits (values[C_MYBLZ]),8)); else sprintf (tmp, "%s", padzeroclip (strip_nondigits (valuesA[A_BLZ]),8)); for (i=0; i 1) { fieldnr=1; while (fieldnr 0) { res = div (extC, 4); extC = res.quot; if (res.rem) extC++; } } if (dtaus_nextrec((void *)buf, fdtaus) != 1) memset (buf, 0, sizeof(buf)); /* * Are there extension records that we have to check? * * 2nd half of the AND is wrong, but since dtaus < 0.5 wrote 01 * instead of 00 we should let it in so it can read its own * old files... *sigh* */ while (extC > 0 && dtaus_char(buf,4) != 'C' && dtaus_char(buf,4) != 'E') { for (index=0; index < 4; index++) { if ((dtaus_char(buf,index*29) != ' ')) { bufp = buf + index*29; memcpy(x, bufp, 2); tmp[2] = '\0'; bufp+=2; memcpy(tmp, bufp, recC[C_TEXT].len-2); tmp[recC[C_TEXT].len-2] = '\0'; printctln(fcontrol, string2ext(x), strip_spaces(tmp)); } } if (dtaus_nextrec((void *)buf, fdtaus) != 1) memset (buf, 0, sizeof(buf)); extC--; } fprintf(fcontrol, "}\n"); } } /* * Record E lesen * (gelesen ist er eigentlich schon...) */ if (dtaus_char(buf,4) == 'E') { if (dtaus_char(buf,4) == 'E') { fprintf(fcontrol, "\nEND {\n"); for (index=E_COUNT; index <= E_BLZ; index++) { #ifndef DEFAULT_EURO if (use_euro && index == E_VAL) index = E_EUR; #else if (!use_euro && index == E_VAL) index = E_DM; #endif bufp = buf + recE[index].pos; memcpy(tmp, bufp, recE[index].len); tmp[recE[index].len] = '\0'; #ifndef DEFAULT_EURO if (index == E_VAL || index == E_EUR) #else if (index == E_VAL || index == E_DM) #endif printctln(fcontrol, recE[E_VAL].name, strip_zeros(string2real(tmp))); else printctln(fcontrol, recE[index].name, strip_zeros(tmp)); #ifndef DEFAULT_EURO if (use_euro && index == E_EUR) index = E_VAL; #else if (!use_euro && index == E_DM) index = E_VAL; #endif } fprintf(fcontrol, "}\n"); } else { fprintf (stderr, "Das ist kein Abschlußdatensatz.\n"); return; } } else { fprintf (stderr, "Der Abschlußdatensatz ist leer oder kaputt.\n"); return; } fclose(fcontrol); fclose(fdtaus); } int control2dtaus (char *ccontrol, char *cdtaus, char *cbeleg, char *ccheck, char *latex) { FILE *fdtaus, *fcontrol, *fbeleg, *fcheck; void *buf; char *ident; int recindex; char line[100]; char *valA[A_LEN], *valC[C_LEN]; int count; bigint sum_val, sum_blz, sum_kto, bi; char **text = NULL; char *cp; int textindex = 0; int len, i; char *type = NULL; char *currency = NULL; char date_todo[11]; char ssum_val[30], ssum_kto[30], ssum_blz[30]; if (!cdtaus) { if (!(fdtaus = fopen("dtaus0.txt", "w"))) return 0; } else { if (!strcmp (cdtaus, "-")) fdtaus = stdout; else if (!(fdtaus = fopen(cdtaus, "w"))) return 0; } if (!ccontrol) { if (!(fcontrol = fopen("dtaus0.ctl", "r"))) if (!(fcontrol = fopen("DTAUS0.CTL", "r"))) return 0; } else { if (!strcmp (ccontrol, "-")) fcontrol = stdin; else if (!(fcontrol = fopen(ccontrol, "r"))) return 0; } if (!cbeleg) { if (!(fbeleg = fopen("dtaus0.doc", "w"))) return 0; } else { if (!(fbeleg = fopen(cbeleg, "w"))) return 0; } if (!ccheck) fcheck = stdout; else if (!(fcheck = fopen(ccheck, "w"))) return 0; if ((buf = (char *)malloc (512)) == NULL) return 0; /* * Record A lesen */ memset (valA, 0, sizeof(valA)); control_nextline ((void *)line, 100, fcontrol); ident = extract_ident(line); if (!strcmp(ident, "begin") && (line[0] == '{')) { control_nextline ((void *)line, 100, fcontrol); while (strlen(line) && line[0] != '}') { ident = extract_ident(line); if ((recindex = rec_index(ident, REC_A)) != -1) { if (recA[recindex].type != IGN) if ((valA[recindex] = (char *)malloc (strlen(line)+1)) != NULL) strcpy(valA[recindex], line); } else { if (! strcasecmp (ident, "euro")) use_euro = 1; if (! strcasecmp (ident, "dm")) use_euro = 0; } control_nextline ((void *)line, 100, fcontrol); } if (((recindex = rec_index("art", REC_A)) != -1) && valA[recindex] && strlen(valA[recindex])) { if (valA[recindex][0] == 'L') type = strdup ("Sammeleinziehungsauftrag"); else if (valA[recindex][0] == 'G') type = strdup ("Sammelueberweisungsauftrag"); else type = strdup ("Sammelauftrag"); if (use_euro) currency = strdup ("Euro"); else currency = strdup ("DM"); if (valA[A_TODO]) sprintf (date_todo, valA[A_TODO]); else memset (date_todo, 0, sizeof (date_todo)); fprintf(fbeleg, "\n\n"); fprintf(fbeleg, "\n Begleitzettel\n\n"); fprintf(fbeleg, "\n Belegloser Datentraegeraustausch\n\n"); fprintf(fbeleg, "\n %s\n\n", type); fprintf(fbeleg, "\n VOL ........................:\n"); fprintf(fbeleg, "\n Erstellungsdatum ...........: %s\n", get_date()); if (strlen(date_todo)) { fprintf(fbeleg, "\n Ausfuehrungsdatum ..........: %s\n", date_todo); } fprintf(fbeleg, "\n Waehrung ...................: %s\n", currency); } if (!dtaus_writeA(fdtaus, valA)) { fprintf (stderr, "Konnte den Anfangsdatensatz nicht schreiben.\n"); return 0; } fprintf (fcheck, "\n\n\n"); if (valA[recindex][0] == 'L') fprintf (fcheck, " Sammeleinziehungsauftrag\n\n"); else if (valA[recindex][0] == 'G') fprintf (fcheck, " Sammelueberweisungsauftrag\n\n"); else fprintf (fcheck, " Sammelauftrag\n\n"); fprintf (fcheck, " Erstellungsdatum : %s\n\n", get_date()); if (use_euro) fprintf (fcheck, " Waehrung : Euro\n\n\n"); else fprintf (fcheck, " Waehrung : DM\n\n\n"); fprintf (fcheck, " %-10s %-8s %-30s %12s\n", "Kontonr.", "BLZ", "Name", "Betrag"); fprintf (fcheck, " --------------------------------------------------------------------\n"); } else { fprintf (stderr, "Datei fängt nicht mit dem Anfangsdatensatz (BEGIN) an.\n"); return 0; } /* * Record C lesen */ count = 0; sum_val = bigint_int(0); sum_blz = bigint_int(0); sum_kto = bigint_int(0); memset (valC, 0, sizeof(valC)); control_nextline ((void *)line, 100, fcontrol); if (line[0] == '{') { while (strlen(line) && line[0] == '{') { control_nextline ((void *)line, 100, fcontrol); if (text) { for (textindex=0; textindex < MAX_TEXT && text[textindex]; textindex++) free (text[textindex]); free (text); text = NULL; } while (strlen(line) && line[0] != '}') { ident = extract_ident(line); if ((recindex = rec_index(ident, REC_C)) != -1) if (recC[recindex].type != IGN) { /* * Special exception to support multiple Text fields */ if (recindex == C_TEXT && valC[recindex]) { if (!text) { if ((text = (char **)malloc ((MAX_TEXT+1) * sizeof (char *))) == NULL) return 0; else { textindex = 0; memset (text, 0, (MAX_TEXT+1) * sizeof (char *)); } } if (textindex < MAX_TEXT) { if ((cp = (char *)malloc (strlen (line) + 1)) == NULL) return 0; strcpy (cp, line); cp[strlen (line)] = '\0'; text[textindex++] = cp; } } else { len = strlen(line); if (recindex == C_VAL) { /* Convert commas to dots for later processing */ for (i=0; line[i]; i++) if (line[i] == ',') line[i] = '.'; if ((cp = strchr (line, '.')) == NULL) { if (strlen(line) > 9) { fprintf (stderr, "Betrag %s zu gross (max. 9 Stellen)\n", line); return 0; } if ((valC[recindex] = (char *)malloc (strlen(line)+4)) == NULL) return 0; sprintf (valC[recindex], "%s.00", line); } else if ( ((len = cp - line + 3)) < strlen (line)) { if (cp - line > 9) { fprintf (stderr, "Betrag %s zu gross (max. 9.2 Stellen)\n", line); return 0; } if ((valC[recindex] = (char *)malloc (len+1)) == NULL) return 0; strncpy (valC[recindex], line, len); valC[recindex][len] = '\0'; } else { if (cp - line > 9) { fprintf (stderr, "Betrag %s zu gross (max. 9.2 Stellen)\n", line); return 0; } if ((valC[recindex] = (char *)malloc (strlen(line)+1)) == NULL) return 0; strcpy(valC[recindex], line); } } else { if ((valC[recindex] = (char *)malloc (strlen(line)+1)) == NULL) return 0; strcpy(valC[recindex], line); } } } control_nextline ((void *)line, 100, fcontrol); } if (!dtaus_writeC(fdtaus, valA, valC, text)) { fprintf (stderr, "Konnte den regulären Datensatz nicht schreiben.\n"); return 0; } count++; bi = bigint_string(real2string(valC[C_VAL])); sum_val = bigint_add(sum_val, bi); bi = bigint_string(valC[C_BLZ]); sum_blz = bigint_add(sum_blz, bi); bi = bigint_string(valC[C_KTO]); sum_kto = bigint_add(sum_kto, bi); fprintf (fcheck, " %10s %8s %-30s %12s\n", valC[C_KTO], valC[C_BLZ], valC[C_NAME], valC[C_VAL]); for (recindex=0; recindex This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. $Id: main.c,v 1.20 2004-08-06 21:14:06 joey Exp $ */ static char version[] = "0.7"; #include #include #include #include #include #include "dtaus.h" #define FN_DTAUS "dtaus0.txt" #define FN_CONTROL "dtaus0.ctl" #define FN_BELEG "dtaus0.doc" #define FN_CHECK "dtaus0.sik" #define FN_LATEX "dtaus0.tex" char *dtaus = FN_DTAUS; char *control = FN_CONTROL; char *beleg = FN_BELEG; char *check = FN_CHECK; char *latex = NULL; void help () { printf ("dtaus - Belegloser Datenträgeraustausch mit einer Bank\n\n"); printf (" -dtaus Erzeugt eine Bankdatei\n"); printf (" -control Liest eine Bankdatei und erzeugt die Kontrolldatei\n"); printf ("\n"); printf (" -d Bankdatei [%s]\n", FN_DTAUS); printf (" -c Steuerdatei [%s]\n", FN_CONTROL); printf (" -b Begleitzettel für die Bank [%s]\n", FN_BELEG); printf (" -l [] Begleitzettel als LaTeX [%s]\n", FN_LATEX); printf (" -o Kontrolldatei zum Abheften [%s]\n", FN_CHECK); } #define DTAUS 1 #define CONTROL 2 int main (int argc, char **argv) { int action = 0; int i = 0; struct stat sbuf; while (argc - i > 1) { i++; if ( !strcmp(argv[i], "-h") ) { help(); exit(0); } else if ( !strcmp(argv[i], "-v") ) { printf ("dtaus version %s - Copyright (c) 1997,8,2001,4 by Martin Schulze \n", version); exit (0); } else if ( !strcmp(argv[i], "-d") ) { if (argc - i > 1) { i++; dtaus = argv[i]; } } else if ( !strcmp(argv[i], "-c") ) { if (argc - i > 1) { i++; control = argv[i]; } } else if ( !strcmp(argv[i], "-b") ) { if (argc - i > 1) { i++; beleg = argv[i]; } } else if ( !strcmp(argv[i], "-l") ) { if (argc - i > 1 && argv[i+1][0] != '-') { i++; latex = argv[i]; } else latex = FN_LATEX; } else if ( !strcmp(argv[i], "-o") ) { if (argc - i > 1) { i++; check = argv[i]; } } else if ( !strcmp(argv[i], "-dtaus") ) { action = DTAUS; } else if ( !strcmp(argv[i], "-control") ) { action = CONTROL; } } if (action == DTAUS) { if (!strcmp("-", control) || !stat(control, &sbuf)) { if (control2dtaus (control, dtaus, beleg, check, latex) == 0) exit (1); } else { fprintf( stderr, "Can't stat %s\n", control); exit (1); } } else if (action == CONTROL) { if (!strcmp("-", dtaus) || !stat(dtaus, &sbuf)) dtaus2control (dtaus, control); else { fprintf( stderr, "Can't stat %s\n", dtaus); exit (1); } } else { fprintf (stderr, "Keine Routine angegeben (-dtaus bzw. -control vergessen).\n"); exit (1); } exit (0); } dtaus-0.9/latex.h0000644000076500007650000000231410104764110012472 0ustar joeyjoey/* latex.h - Datentraegeraustausch mit einer Bank Copyright (c) 2004 Martin Schulze This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. $Id: latex.h,v 1.1 2004-08-06 20:21:28 joey Exp $ */ #ifndef _LATEX_H_ #define _LATEX_H_ void generate_latex_receipt ( char *fname, char *type, char *created, char *todo, char *currency, int quantity, char *sum_val, char *sum_kto, char *sum_blz, char *kto, char *blz ); #endif /* _LATEX_H_ */ dtaus-0.9/TODO0000644000076500007650000000125307421111252011676 0ustar joeyjoey$Id: TODO,v 1.7 2002-01-15 20:35:54 joey Exp $ TODO List --------- . Include consistency test for dtaus files. It is possible to check all BLZ and KTO against some patterns. At ping.de some algorithms were implemented. There's also a list of valid BLZs somewhere . Add some nice GUI for control file creation . Maybe add some plausibility tests for ``Ausfuehrung'' . Add some regression tests for automatic testing of patches . In case of an error, pass the status error though the exit() routine. . In case of an error, files are written half-way, ending with buggy files. Maybe ftrunc() or unlink() them. Martin Schulze dtaus-0.9/README0000644000076500007650000000460710150603261012073 0ustar joeyjoey$Id: README,v 1.9 2004-11-23 09:45:21 joey Exp $ This package contains one executable that is able to read and write DTAUS files that are commonly used in Germany. DTAUS is an acronym for DatenTrägerAUStausch. It is used by credit institutes in order to transfer commands for money exchanges between bank accounts. DTAUS files use a special but simple and freely documented format. I've attached a written down version in dtaus.txt in this distribution. As DTAUS uses very long integer values you can't rely on regular C long integer variables. Therefore this package includes a small (and incomplete) library that deals with large integer numbers. At the moment it only contains routines that are needed by dtaus but you're invited to improve it and send back appropriate patches to me. The library is called bigint and is included in this package. I've been told that one can use StarFinanz to transmit DTAUS files (via W32, though) to the bank without the need to use T-Online. More Information ---------------- I have set up a couple of web pages describing the dtaus package as well as collecting additional information that may be useful to dtaus users. Please check out: There is a mailing list set up on lists.infodrom.org that deals with DTAUS and appropriate issues. If you have questions or suggestions please subscribe to the list and post there. The source code for this package is also available through anonymous CVS at :pserver:anonymous@cvs.infodrom.org:/var/cvs/infodrom using the module dtaus. Accessing this is described in detail at the web pages mentioned above. Please don't contact me personally if you don't have confidential questions or information. Please use the mailing list from above instead. Using the mailing list has a couple of advantages. Your question and comments are archived publically and properly so they can be used later as well. As another bonus somebody else than me could answer a question, hence not incrementing my workload and it's more difficult to forget about it. The submission address for the mailing list is: infodrom-dtaus@lists.infodrom.org To subscribe, send a mail to majordomo@lists.infodrom.org with the body "subscribe infodrom-dtaus" -- or send a mail to SmartList at infodrom-dtaus-request@lists.infodrom.org with the subject "subscribe". Good luck! Martin Schulze dtaus-0.9/sample.ctl0000644000076500007650000000245307375564257013227 0ustar joeyjoey# dtaus -dtaus -d sample.txt -c sample.ctl -b sample.doc -o sample.sik BEGIN { Art LK Name Martin Schulze Konto 123545 BLZ 2004002 Ausfuehrung 24.12.2001 Euro } { Transaktion Einzug Name Martha Schulze Konto 1234567 BLZ 47110815 Betrag 30.00 Zweck Gebühr Wohnheimnetz Text Anschluß u. 11+12.97 } { Transaktion Einzug Name Misia Schulze Konto 1234567 BLZ 47110815 Betrag 20.00 Zweck Gebühr Wohnheimnetz Text 11+12.97 } # Das Resultat: (Zeilenumbrüche nur für die Lesbarkeit) # # 0128ALK0200400200000000MARTIN SCHULZE 101101 00001235450000000000 # 0216C02004002471108150001234567000000000000005000 0000000300002004002000012354500000000000 MARTHA SCHULZE MARTIN SCHULZE GEBUEHR WOHNHEIMNETZ 0102ANSCHLUSS U. 11+12.97 # 0216C02004002471108150001234567000000000000005000 0000000200002004002000012354500000000000 MISIA SCHULZE MARTIN SCHULZE GEBUEHR WOHNHEIMNETZ 010211+12.97 # 0128E 0000002000000000500000000000002469134000000000942216300000000000000 dtaus-0.9/ChangeLog0000644000076500007650000001012511233255413012762 0ustar joeyjoey2009-07-27 Martin Schulze * Version 0.9 * Contribution of bigint_sub() and bigint_cmp() by Jens Rohler * Corrected the initial bigint_int() routine so that arithmetic works as expected * Corrected handling of too large values * Several minor corrections * Fixed the "Referenz"-Option within A-Records by Peter Schlaile 2004-08-07 Martin Schulze * Version 0.7 * Added support for the 'Begleitzettel' via LaTeX document * Corrected string handling for arguments (Martin Schulte) * Corrected handling of files "-" for stdin/stdout (Martin Schulte) * Corrected support for vermögenswirksame Leistungen * Added back support for DM, tidied up some code, updated the documentation * Safely parse values and correct their format to nnnnn.pp 2002-01-01 Martin Schulze * Version 0.6 * EURO is the default currency from now on * Don't print empty date fields 2001-12-19 Martin Schulze * Version 0.5.1 * Prettyprint dates * Output Betrag-Euro as Betrag so the file can be used as input again. 2001-11-25 Martin Schulze * Version 0.5 * This release was sponsored by USEtec * Improved documentation * Added support for additional text fields, up to 15 can be added to a single job. The 16th Text field will be ignored as well as any following. * Properly distinguish between LK/LB and GK/GB in internal files * Added currency to output files to be clear about DM or EUR * Added support for special files "-" as placeholder for stdin/stdout for dtaus and control files * Added support for Euro. There's a define in dtaus.c that can make the code default to Euro instead of DM. Alternatively simply add the keyword ``Euro'' to the A record (the begin { ... } record). All values are calculated and stored in Euro then. * Added support for "Ausführungsdatum" which tells the bank to process the entire job at a given time instead of asap. Please read the manpages to find out which restrictions have to match. * Updated the format specification since it was modified from credit institutes. 2000-01-04 Martin Schulze * Version 0.4 * Added short description for control files * Ensured that BLZ and KTO consist only of digits, even if the user has specified something different. Banks won't accept files otherwise. * Applied fix for a y2k issue that prevents some banks from accepting the files. 1998-11-16 Martin Schulze * Added information about different types of dtaus files to README file. * Better support for "Gutschriften", the former version forgot to write this where needed. Fixed now. 1998-10-15 Martin Schulze * Version 0.3 * While implementing zero-padded fields I've also implemented clippings so numbers that are too big won't hurt the binary DTAUS file. * Added better support for zero-padded numbers. sprintf() from libc4 had no problems accepting `%08s' while this didn't produce zero-padded strings with libc5 and libc6. Now we've got our own routine to handle these. Thanks to Peter Tobias for notifying me. Fri Jul 3 13:28:28 1998 Martin Schulze * Version 0.2.1 * Wrote a small manpage * Added some hooks for the new european currency Euro, it's not yet implemented * main.c: Added test for file existance before opening them and leaving out unnecessary empty files * dtaus.c: Fixed buffer overrun problem within dtaus module Wed Jun 4 16:02:59 1997 Martin Schulze * Version 0.2 * Wrote main.c as a user program around the library. Tue Jun 3 19:35:02 1997 Martin Schulze * Switched to CVS Mon Jun 2 21:12:56 1997 Martin Schulze * First official use of this module in 'Artis Studinetz Manager', artisman for the students home at Artillerieweg 55a in Oldenburg, Germany. dtaus-0.9/test_bigint.c0000644000076500007650000001004410302424751013666 0ustar joeyjoey/* test_bigint.c - Testcase for big positive integer numbers Copyright (c) 2005 Martin Schulze This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. $Id: test_bigint.c,v 1.1 2005-08-22 19:39:21 joey Exp $ */ #include "bigint.h" #include #include int nrtest = 0; int compare (bigint is, char *should) { char s[30]; nrtest++; bigint_sprintf (s, "%s", is); if (!strcmp(s, should)) { printf ("Test %d passed, %s == %s\n", nrtest, s, should); return 1; } else { fprintf (stderr, "Test %d failed, %s != %s\n", nrtest, s, should); return 0; } } int main() { bigint foo, bar, baz; char s[20]; int passed = 0; int i; /* Test 1: Representing zero */ foo = bigint_int (0); passed += compare (foo, "0"); /* Test 2: Representing nonzero */ foo = bigint_int (654321); passed += compare (foo, "654321"); /* Test 3: Representing BIGINT_MAX */ foo = bigint_int (BIGINT_MAX); sprintf (s, "%d", BIGINT_MAX); passed += compare (foo, s); /* Test 4: BIGINT_MAX + 1 */ foo = bigint_int (BIGINT_MAX); bar = bigint_int (1); baz = bigint_add (foo, bar); sprintf (s, "%d", BIGINT_MAX); s[strlen(s)-1] = '1'; passed += compare (baz, s); /* Test 5: BIGINT_MAX - 1 */ foo = bigint_int (BIGINT_MAX); bar = bigint_int (1); baz = bigint_sub (foo, bar); sprintf (s, "%d", BIGINT_MAX); for (i=0;s[i];i++) s[i] = '9'; s[strlen(s)-1] = '\0'; passed += compare (baz, s); /* Test 6: BIGINT_MAX + 1 -1 */ foo = bigint_int (BIGINT_MAX); bar = bigint_int (1); baz = bigint_add (foo, bar); foo = bigint_sub (baz, bar); sprintf (s, "%d", BIGINT_MAX); passed += compare (foo, s); /* Test 7: BIGINT_MAX + 1234 */ foo = bigint_int (BIGINT_MAX); bar = bigint_int (1234); baz = bigint_add (foo, bar); sprintf (s, "%d", BIGINT_MAX); sprintf (s+6, "%d", 1234); passed += compare (baz, s); /* Test 8: BIGINT_MAX + 1234 - 1234 */ foo = bigint_sub (baz, bar); sprintf (s, "%d", BIGINT_MAX); passed += compare (foo, s); /* Test 9: BIGINT_MAX - 100000000 */ foo = bigint_int (BIGINT_MAX); bar = bigint_int (100000000); baz = bigint_sub (foo, bar); sprintf (s, "%d", 900000000); passed += compare (baz, s); /* Test 10: BIGINT_MAX + BIGINT_MAX */ foo = bigint_int (BIGINT_MAX); baz = bigint_add (foo, foo); sprintf (s, "%d", BIGINT_MAX); s[0] = '2'; passed += compare (baz, s); /* Test 11: BIGINT_MAX - BIGINT_MAX */ foo = bigint_int (BIGINT_MAX); baz = bigint_sub (foo, foo); passed += compare (baz, "0"); /* Test 12: BIGINT_MAX + ( BIGINT_MAX -1) */ foo = bigint_int (BIGINT_MAX); baz = bigint_sub (foo, foo); passed += compare (baz, "0"); /* Test 13: BIGINT_MAX-1 + 1 */ foo = bigint_int (BIGINT_MAX-1); bar = bigint_int (1); baz = bigint_add (foo, bar); sprintf (s, "%d", BIGINT_MAX); passed += compare (baz, s); /* Test 14: BIGINT_MAX-1 + 2 */ foo = bigint_int (BIGINT_MAX-1); bar = bigint_int (2); baz = bigint_add (foo, bar); sprintf (s, "%d", BIGINT_MAX); s[strlen(s)-1] = '1'; passed += compare (baz, s); /* Test 15: BIGINT_MAX + BIGINT_MAX-1 */ foo = bigint_int (BIGINT_MAX); bar = bigint_int (BIGINT_MAX-1); baz = bigint_add (foo, bar); sprintf (s, "%d", BIGINT_MAX); for (i=1;s[i];i++) s[i]='9'; passed += compare (baz, s); printf ("%d tests passed\n", passed); if (passed < nrtest) printf ("%d tests failed\n", nrtest-passed); return 0; } dtaus-0.9/bigint.c0000644000076500007650000000742510303522302012630 0ustar joeyjoey/* bigint.c - Manage big positive integer numbers Copyright (c) 1996,2001,5 Martin Schulze This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. $Id: bigint.c,v 1.8 2005-08-26 05:12:34 joey Exp $ */ #include "bigint.h" #include #include #include bigint bigint_add(bigint a, bigint b) { int i; unsigned long int tmp; bigint c; for (i=0; i= BIGINT_MAX) { c.val[i] = tmp - BIGINT_MAX; if (i= b.val[i]) { a.val[i] = a.val[i] - b.val[i]; continue; } tmp = b.val[i]; tmp = tmp - a.val[i]; a.val[i] = 0; t = i; while (1) { if (t+1 >= BIGINT_LEN) { fprintf(stderr, "Error in bigint_sub.\n"); return bigint_int(0); } if ( a.val[t+1] == 0 ) { t++; continue; } a.val[t+1] = a.val[t+1] - 1; while(t >= 0) { rem = bigint_add(rem, bigint_int(a.val[t])); a.val[t] = BIGINT_MAX - 1; t--; } a.val[i] = a.val[i] - tmp; a = bigint_add(a, bigint_int(1)); a = bigint_add(a, rem); break; } } return a; } bigint bigint_int(int num) { bigint x; int i; if (num < 0) { fprintf(stderr, "Trying to assign negative value to bigint.\n"); num = 0; } for (i=0; i BIGINT_PREC) cp += (strlen(x) - BIGINT_PREC); strcpy(tmp, cp); *cp = '\0'; sscanf(tmp, "%lu", &a.val[i]); } } free (x); } return a; } void bigint_sprintf (char *res, char *format, bigint a) { char s[(BIGINT_PREC*BIGINT_LEN)+1]; char tmp[BIGINT_PREC+1]; char form[6]; int i, max; memset (s, 0, sizeof(s)); sprintf(form, "%%0%dlu", BIGINT_PREC); max = BIGINT_LEN; for (;max>0 && !a.val[max-1];max--); if (max == 0) s[0] = '0'; for (i=0; i=0; i--) { if (a.val[i] > b.val[i]) return 1; if (a.val[i] < b.val[i]) return -1; if (a.val[i] == b.val[i]) continue; } return 0; } dtaus-0.9/bigint.h0000644000076500007650000000265310303522274012643 0ustar joeyjoey/* bigint.h - Manage big positive integer numbers Copyright (c) 1996 Martin Schulze This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. $Id: bigint.h,v 1.3 2005-08-26 05:12:28 joey Exp $ */ /* * 4294967295 is max (unsigned long int) */ #ifndef _BIGINT_H_ #define _BIGINT_H_ #define BIGINT_LEN 2 #define BIGINT_MAX 1000000000 #define BIGINT_PREC 9 typedef struct { unsigned long int val[BIGINT_LEN]; } bigint; bigint bigint_add(bigint a, bigint b); bigint bigint_sub(bigint a, bigint b); bigint bigint_int(int num); bigint bigint_string(char *s); void bigint_sprintf (char *res, char *format, bigint a); /* compares two bigints a < b => -1 a > b => 1 a == b => 0 */ int bigint_cmp(bigint a, bigint b); #endif /* _BIGINT_H_ */