commit fdb4e4cd363323829ebf0fd12172e4e5c6755652 Author: agibert Date: Wed Nov 12 02:25:22 2008 +0000 Initial creation. diff --git a/GNU-FDL.txt b/GNU-FDL.txt new file mode 100644 index 0000000..b42936b --- /dev/null +++ b/GNU-FDL.txt @@ -0,0 +1,355 @@ + GNU Free Documentation License + Version 1.1, March 2000 + + Copyright (C) 2000 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. + + +0. PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +written document "free" in the sense of freedom: to assure everyone +the effective freedom to copy and redistribute it, with or without +modifying it, either commercially or noncommercially. Secondarily, +this License preserves for the author and publisher a way to get +credit for their work, while not being considered responsible for +modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + + +1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work that contains a +notice placed by the copyright holder saying it can be distributed +under the terms of this License. The "Document", below, refers to any +such manual or work. Any member of the public is a licensee, and is +addressed as "you". + +A "Modified Version" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall subject +(or to related matters) and contains nothing that could fall directly +within that overall subject. (For example, if the Document is in part a +textbook of mathematics, a Secondary Section may not explain any +mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, whose contents can be viewed and edited directly and +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup has been designed to thwart or discourage +subsequent modification by readers is not Transparent. A copy that is +not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML designed for human modification. Opaque formats include +PostScript, PDF, proprietary formats that can be read and edited only +by proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML produced by some word processors for output +purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + + +2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + + +3. COPYING IN QUANTITY + +If you publish printed copies of the Document numbering more than 100, +and the Document's license notice requires Cover Texts, you must enclose +the copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a publicly-accessible computer-network location containing a complete +Transparent copy of the Document, free of added material, which the +general network-using public has access to download anonymously at no +charge using public-standard network protocols. If you use the latter +option, you must take reasonably prudent steps, when you begin +distribution of Opaque copies in quantity, to ensure that this +Transparent copy will remain thus accessible at the stated location +until at least one year after the last time you distribute an Opaque +copy (directly or through your agents or retailers) of that edition to +the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + + +4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +A. Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. +B. List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has less than five). +C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. +D. Preserve all the copyright notices of the Document. +E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. +F. Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. +G. Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. +H. Include an unaltered copy of this License. +I. Preserve the section entitled "History", and its title, and add to + it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section entitled "History" in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. +J. Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the "History" section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. +K. In any section entitled "Acknowledgements" or "Dedications", + preserve the section's title, and preserve in the section all the + substance and tone of each of the contributor acknowledgements + and/or dedications given therein. +L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. +M. Delete any section entitled "Endorsements". Such a section + may not be included in the Modified Version. +N. Do not retitle any existing section as "Endorsements" + or to conflict in title with any Invariant Section. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties--for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + + +5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections entitled "History" +in the various original documents, forming one section entitled +"History"; likewise combine any sections entitled "Acknowledgements", +and any sections entitled "Dedications". You must delete all sections +entitled "Endorsements." + + +6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + + +7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, does not as a whole count as a Modified Version +of the Document, provided no compilation copyright is claimed for the +compilation. Such a compilation is called an "aggregate", and this +License does not apply to the other self-contained works thus compiled +with the Document, on account of their being thus compiled, if they +are not themselves derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one quarter +of the entire aggregate, the Document's Cover Texts may be placed on +covers that surround only the Document within the aggregate. +Otherwise they must appear on covers around the whole aggregate. + + +8. TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License provided that you also include the +original English version of this License. In case of a disagreement +between the translation and the original English version of this +License, the original English version will prevail. + + +9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document except +as expressly provided for under this License. Any other attempt to +copy, modify, sublicense or distribute the Document 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. + + +10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation 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. See +http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. + + +ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (c) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.1 + or any later version published by the Free Software Foundation; + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +If you have no Invariant Sections, write "with no Invariant Sections" +instead of saying which ones are invariant. If you have no +Front-Cover Texts, write "no Front-Cover Texts" instead of +"Front-Cover Texts being LIST"; likewise for Back-Cover Texts. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. diff --git a/GNU-GPL.txt b/GNU-GPL.txt new file mode 100644 index 0000000..5b6e7c6 --- /dev/null +++ b/GNU-GPL.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..43659dd --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,52 @@ +# $RCSfile: ReadMe.txt,v $ +# $Revision: 1.1 $ +# $Name: $ +# $Date: 2008/11/12 02:25:22 $ +# $Author: agibert $ + + + + + +Welcome to IMR (Interlinking Message Router) ! + + + +This program is DIAMIS Cristal message transformer. It can convert XML Cristal messages to old flat message format and vice versa. +Thanks to its fully configurability, IMR can virtually convert any file format. +Message are read from and writen to different media: file, MQSeries ans Tuxedo Queues. + +This is the initial and origianal release of IMR. +This version has been in production between April 2005 and February 2008 and no bug has been detected ! + + +This release of IMR supports the following OS: + - Mandriva Linux 2005 (Developement), + - HP UX (Production). + + + +Authors: + - Architecture and team leading : A. Gibert + - Conception, Development and Tests: A. Gibert, H. Moussaid, D. Olivon, E. Renaud (Coignet) + + + +IMR is now licensed under the GPL GNU Licenses. +For more information, please read the corresponding source file headers. +The license details can be found in the GNU-GPL.txt and GNU-FDL.txt files. + +IMR depend on: + - libnode V2.1.0-1 (http://www.rx3.org/dvp/?dvp=libnode), + - libxml2 V2.6.9 (http://www.xmlsoft.org/), + - libz V1.1.4 ((C) 1995-2002 Jean-loup Gailly and Mark Adler). +These libraries are currently distributed with IMR. Please check their corresponding licenses. + + + +Enjoy it! + +Your IMR Team. + +arnaud@rx3.net +http://www.rx3.org/dvp/?dvp=imr diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt new file mode 100644 index 0000000..38addd7 --- /dev/null +++ b/ReleaseNotes.txt @@ -0,0 +1,17 @@ +# $RCSfile: ReleaseNotes.txt,v $ +# $Revision: 1.1 $ +# $Name: $ +# $Date: 2008/11/12 02:25:22 $ +# $Author: agibert $ + + + + + +------------------------------------------------------------------------------------------------------------------------------------ +IMR V 1.0.0-1 - A. Gibert / H. Moussaid / D. Olivon / E. Renaud (Coignet) - 01/04/05 +------------------------------------------------------------------------------------------------------------------------------------ + +- Intial Version, released for MICOT/Target project (Banque de France - Paris), +- This version has been in production between April 2005 and February 2008. +- GPL Release. diff --git a/ToDo.txt b/ToDo.txt new file mode 100644 index 0000000..fb711f7 --- /dev/null +++ b/ToDo.txt @@ -0,0 +1,12 @@ +# $RCSfile: ToDo.txt,v $ +# $Revision: 1.1 $ +# $Name: $ +# $Date: 2008/11/12 02:25:22 $ +# $Author: agibert $ + + + + + +- Remove libnode and libxml from source and use them externally, +- Support the forth comming libnode in order to support C99 standards... diff --git a/doc/IMR-Architecture_Generale.odp b/doc/IMR-Architecture_Generale.odp new file mode 100644 index 0000000..983cb0f Binary files /dev/null and b/doc/IMR-Architecture_Generale.odp differ diff --git a/doc/IMR-Architecture_Generale.odt b/doc/IMR-Architecture_Generale.odt new file mode 100644 index 0000000..be5b115 Binary files /dev/null and b/doc/IMR-Architecture_Generale.odt differ diff --git a/doc/IMR-DCT-Mapping_Manager.odt b/doc/IMR-DCT-Mapping_Manager.odt new file mode 100644 index 0000000..116e1d1 Binary files /dev/null and b/doc/IMR-DCT-Mapping_Manager.odt differ diff --git a/doc/IMR-DCT-Static_Data_Manager.odt b/doc/IMR-DCT-Static_Data_Manager.odt new file mode 100644 index 0000000..b19978b Binary files /dev/null and b/doc/IMR-DCT-Static_Data_Manager.odt differ diff --git a/doc/IMR-MCD.pdf b/doc/IMR-MCD.pdf new file mode 100755 index 0000000..ed30117 Binary files /dev/null and b/doc/IMR-MCD.pdf differ diff --git a/doc/IMR-MPD.pdf b/doc/IMR-MPD.pdf new file mode 100755 index 0000000..51c0415 Binary files /dev/null and b/doc/IMR-MPD.pdf differ diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..4a58285 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,179 @@ +#------------------------------------------------------------------------------ +# General Makefile +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:22 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ +# Makefile Target: clean all install uninstall clean-lib clean-bin +# lib bin install-lib install-bin uninstall-lib +# uninstall-bin +# Default Makefile Target: all +# Makefile Support Switches: ORACLE_SUPPORT TUX_SUPPORT MQS_SUPPORT +# Makefile Switches: VERBOSE WARNING DEBUG OPTIMIZE STATIC DYNAMIC +# Makefile Switches: PROFILE STRIP DOTI DOLINT EFENCE DMALLOC PURIFY +# Default Makefile Switches: STATIC=1 DEBUG=1 +# Makefile Variables: CC SUBDIR +# Default Makefile Variables: SQLCHECK=FULL +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Constants +#------------------------------------------------------------------------------ + +MAKE = make +SHELL = bash + + + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +ifdef VERBOSE + QUIET= + SILENT= +else + QUIET=@ + SILENT=-s +endif + + + +LIB= libz \ + libnode \ + libxml \ + liblog_mng \ + libstatic_data_mng \ + libio_mng \ + libmapping_mng \ + libmsg_router \ + sd_appl_struct \ + sd_cnv_struct \ + sd_fmtattr_struct \ + sd_fmt_struct \ + sd_mappath_struct \ + sd_msg_struct \ + sd_msgmap_struct + +BIN= imrd \ +# imrc + +SUBDIR= $(LIB) $(BIN) + + + + + +#------------------------------------------------------------------------------ +# External targets +#------------------------------------------------------------------------------ + +all: + + + +clean all install uninstall: + $(QUIET)$(MAKE) $(SILENT) $(MAKEOVERRIDES) make-$@ + + + +lib: + $(QUIET)$(MAKE) $(SILENT) SUBDIR="$(LIB)" $(MAKEOVERRIDES) all + +bin: + $(QUIET)$(MAKE) $(SILENT) SUBDIR="$(BIN)" $(MAKEOVERRIDES) all + +clean-lib install-lib uninstall-lib: + $(QUIET)$(MAKE) $(SILENT) SUBDIR="$(LIB)" $(MAKEOVERRIDES) $(patsubst %-lib, %, $@) + +clean-bin install-bin uninstall-bin: + $(QUIET)$(MAKE) $(SILENT) SUBDIR="$(BIN)" $(MAKEOVERRIDES) $(patsubst %-bin, %, $@) + + + + + +#------------------------------------------------------------------------------ +# Internal targets +#------------------------------------------------------------------------------ + +make-clean make-all make-install make-uninstall: $(SUBDIR) + + + + + +#------------------------------------------------------------------------------ +# Rules +#------------------------------------------------------------------------------ + +$(SUBDIR): + @echo Making $(patsubst make-%, %, $(MAKECMDGOALS)) into $@... + $(QUIET)$(MAKE) $(SILENT) -C $@/src ECHO_HEAD="\t$@: " $(MAKEOVERRIDES) $(patsubst make-%, %, $(MAKECMDGOALS)) + @echo Completed $(patsubst make-%, %, $(MAKECMDGOALS)) into $@ ! + + + + + +#------------------------------------------------------------------------------ +# Suffixes +#------------------------------------------------------------------------------ + +.PHONY: clean clean-lib clean-bin make-clean all make-all lib bin install install-lib install-bin make-install uninstall uninstall-lib uninstall-bin make-uninstall $(SUBDIR) +ifdef PURIFY + .NOTPARALLEL: +endif + + + + + +#------------------------------------------------------------------------------ +# Dependencies +#------------------------------------------------------------------------------ + +$(BIN): $(LIB) + + + +ifneq (,$(findstring clean,$(MAKECMDGOALS))) +all: clean +install: clean +endif + +ifneq (,$(findstring uninstall,$(MAKECMDGOALS))) +all: uninstall +install: uninstall +endif diff --git a/src/Makefile_rule.mk b/src/Makefile_rule.mk new file mode 100644 index 0000000..aa7f68a --- /dev/null +++ b/src/Makefile_rule.mk @@ -0,0 +1,280 @@ +#------------------------------------------------------------------------------ +# Makefile Rule Definitions +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:22 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ +# Makefile Target: clean all dep install uninstall +# Default Makefile Target: all +# Makefile Support Switches: ORACLE_SUPPORT TUX_SUPPORT MQS_SUPPORT +# Makefile Switches: VERBOSE WARNING DEBUG OPTIMIZE STATIC DYNAMIC +# Makefile Switches: PROFILE STRIP DOTI DOLINT EFENCE DMALLOC PURIFY +# Default Makefile Switches: STATIC=1 DEBUG=1 +# Makefile Variables: CC SQLCHECK +# Default Makefile Variables: SQLCHECK=FULL +# Tuxedo Server Tag: TXSERVICE_NAME TXSERVICE_TYPE +# Tuxedo Service Type: NONE TX_SERVER_OXA TX_CLIENT_ORA +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +TARGET_FILES= $(TARGET) +INSTALL_FILES= $(TARGET) +UNINSTALL_FILES= $(TARGET) + +ifeq ($(suffix $(TARGET)),$(SHLIB_SUFFIX)) + INSTALL_DIR= $(GLOBAL_LIB_DIR) + TARGET_FILES+= $(TARGET:$(SHLIB_SUFFIX)=.a) + INSTALL_FILES+= $(TARGET:$(SHLIB_SUFFIX)=.a) + UNINSTALL_FILES+= $(TARGET:$(SHLIB_SUFFIX)=.a) .pure $(TARGET:$(SHLIB_SUFFIX)=_pure_*$(SHLIB_SUFFIX)) $(TARGET:$(SHLIB_SUFFIX)=_pure_*.a) + + ifdef DOLINT + LINT_TARGET= llib-l$(subst lib,,$(basename $(TARGET))).ln + LINT_LIB= $(LINT_TARGET) + TARGET_FILES+= $(LINT_TARGET) + INSTALL_FILES+= $(LINT_TARGET) + UNINSTALL_FILES+= $(LINT_TARGET) + endif +else + ifeq ($(suffix $(TARGET)),.xml) + INSTALL_DIR= $(GLOBAL_LIB_DIR)/imr + else + INSTALL_DIR= $(GLOBAL_BIN_DIR) + + ifdef DOLINT + LINT_FILE= $(basename $(TARGET)).lint + LINT_LIB= + TARGET_FILES+= $(LINT_FILE) + endif + endif +endif + +ifdef DOTI + TARGET_FILES+= $(OBJ:.o=.i) +endif + + + + + +#------------------------------------------------------------------------------ +# External targets +#------------------------------------------------------------------------------ + +all: dep + $(QUIET)$(MAKE) $(SILENT) $(MAKEOVERRIDES) build + +clean: + @echo -e '$(ECHO_HEAD)Cleaning up...' + $(QUIET)$(RM) -f \ + $(shell for file in $(OBJ:.o=); \ + do \ + if [ -f $$file.pc ]; \ + then \ + echo $$file.c $$file.lis; \ + fi; \ + done) \ + $(OBJ:.o=.dep) \ + $(OBJ:.o=.i) \ + $(OBJ:.o=.ln) \ + $(OBJ:.o=.sublint) \ + $(OBJ:.o=_pure_*) \ + $(OBJ) \ + $(TARGET_FILES) \ + llib-l$(subst lib,,$(basename $(TARGET))).ln \ + llib-l$(subst lib,,$(basename $(TARGET))).sublint \ + BS-*.c BS-*.o \ + BS-*_pure_* \ + BC-*.c BC-*.o \ + BC-*_pure_* \ + logfile* \ + .pure + +install: $(patsubst %,$(INSTALL_DIR)/%,$(INSTALL_FILES)) + +uninstall: + $(QUIET)for file in $(UNINSTALL_FILES); \ + do \ + echo -e "$(ECHO_HEAD)Uninstalling $$file from $(INSTALL_DIR)..."; \ + $(RM) -f $(INSTALL_DIR)/$$file; \ + done + +dep: + $(QUIET)$(MAKE) $(SILENT) $(MAKEOVERRIDES) depend + + + + + +#------------------------------------------------------------------------------ +# Internal targets +#------------------------------------------------------------------------------ + +depend: $(OBJ:.o=.dep) + +build: $(TARGET_FILES) + + + + + +#------------------------------------------------------------------------------ +# Rules +#------------------------------------------------------------------------------ + +%.dep : %.c + @echo -e '$(ECHO_HEAD)Dependencing $<...' + $(QUIET)$(MAKEDEP) $(MAKEDEP_FLAGS) -o.o $< >$@ + $(QUIET)$(MAKEDEP) $(MAKEDEP_FLAGS) -o.i $< >>$@ + +%.c : %.pc + @echo -e '$(ECHO_HEAD)Procing $<...' + $(QUIET)$(PROC) $(DEVNULL) $(PROC_FLAGS) oname=$@ iname=$< $(PROC_FILTER) + +%.i : %.c + @echo -e '$(ECHO_HEAD)Precompilling $<...' + $(QUIET)$(CPP) $(CPPFLAGS) $(INCLUDE) -o $@ $< + +%.ln : %.c + @echo -e '$(ECHO_HEAD)Linting $<...' + $(QUIET)$(LINT) $(LINTFLAGS) $(INCLUDE) -c > $(<:.c=.sublint) $< + +%.o : %.c + @echo -e '$(ECHO_HEAD)Compilling $<...' + $(QUIET)$(CC) $(CFLAGS) $(INCLUDE) -o $@ $< + +$(LINT_LIB): $(OBJ:.o=.ln) + @echo -e '$(ECHO_HEAD)Lib Linting $@...' + $(QUIET)$(LINT) $(LINTFLAGS) -o $(subst lib,,$(basename $(TARGET))) > $(@:.ln=.sublint) $(OBJ:.o=.ln) + +%$(SHLIB_SUFFIX): %.o + @echo -e '$(ECHO_HEAD)Linking $@...' + $(QUIET)$(LD) $(LDFLAGS) -o $@ $(OBJ) + +%.a : %.o + @echo -e '$(ECHO_HEAD)Linking $@...' + $(QUIET)$(AR) $(ARFLAGS) $@ $(OBJ) + +%.lint : %.ln + @echo -e '$(ECHO_HEAD)Link Linting $@...' + $(QUIET)$(LINT) $(LINTFLAGS) $(LINTLIBS) $< >$@ + +% : %.o +ifeq ($(TXSERVICE_TYPE),TX_SERVER_OXA) + @echo -e '$(ECHO_HEAD)Building Tuxedo server $@... ' + $(QUIET)$(PRELINK) $(TXBLDSRV) $(TXBLD_FLAGS) -o $@ -f "$(OBJ)" $(TXBLD_LIB) -s "$(TXSERVICE_NAME)" $(PRELINK_FILTER) +else + ifeq ($(TXSERVICE_TYPE),TX_CLIENT_ORA) + @echo -e '$(ECHO_HEAD)Building Tuxedo client $@...' + $(QUIET)$(PRELINK) $(TXBLDCLN) $(TXBLD_FLAGS) -o $@ -f "$(OBJ)" $(TXBLD_LIB) $(PRELINK_FILTER) + ifndef DEBUG + $(QUIET)$(RM) BC-*.c + endif + else + @echo -e '$(ECHO_HEAD)Linking $@...' + ifdef PURIFY + @echo -e '$(ECHO_HEAD)Purifing $@... ' + $(PURIFIER) $(PURIFIER_FLAGS) $(CC) $(LINK_FLAGS) -o $@ $(OBJ) $(LIB) $(PRELINK_FILTER) + else + $(QUIET)$(CC) $(LINK_FLAGS) -o $@ $(OBJ) $(LIB) + endif + endif +endif +ifdef DEBUG + ifeq ($(OS),HP-UX) + @echo -e '$(ECHO_HEAD)Pxdbing $@...' + $(QUIET)$(PXDB) $(PXDBFLAGS) $@ + endif +else + ifdef STRIP + @echo -e '$(ECHO_HEAD)Striping $@...' + $(QUIET)$(STRIPPER) $@ + endif +endif + +%.xml : %.xml.m4 + @echo -e '$(ECHO_HEAD)M4ing $@... ' + $(QUIET)$(M4) $(M4_FLAGS) > $@ $< + +$(INSTALL_DIR)/%: $(INSTALL_DIR) all + @echo -e '$(ECHO_HEAD)Installing $(subst $(INSTALL_DIR)/,,$@) into $(INSTALL_DIR)...' + $(QUIET)$(CP) $(subst $(INSTALL_DIR)/,,$@) $(INSTALL_DIR) + +$(INSTALL_DIR): + @echo -e '$(ECHO_HEAD)Creatinging $(INSTALL_DIR)...' + $(QUIET)$(MKDIR) $(INSTALL_DIR) + + + + + +#------------------------------------------------------------------------------ +# Suffixes +#------------------------------------------------------------------------------ + +.SECONDARY: $(OBJ:.o=.c) $(OBJ:.o=.dep) $(OBJ:.o=.ln) $(OBJ:.o=.sublint) +.SUFFIXES: .pc .c .h .dep .i .ln .sublint .o $(SHLIB_SUFFIX) .a .lint +.PHONY: clean all dep install uninstall build depend +.DELETE_ON_ERROR: + + + + + +#------------------------------------------------------------------------------ +# Dependencies +#------------------------------------------------------------------------------ + +$(OBJ): Makefile $(MAKEFILE_GLOB) $(MAKEFILE_PATH) +$(TARGET_FILES): $(OBJ) $(OBJ_RAW) Makefile $(MAKEFILE_GLOB) $(MAKEFILE_PATH) + +ifneq ($(suffix $(TARGET)),$(SHLIB_SUFFIX)) + ifneq ($(suffix $(TARGET)),.xml) + $(TARGET): $(patsubst %,$(GLOBAL_LIB_DIR)/lib%$(SHLIB_SUFFIX),$(LIB_LIST)) + endif +endif + +ifneq (,$(findstring clean,$(MAKECMDGOALS))) +dep: clean +endif + +ifneq (,$(findstring uninstall,$(MAKECMDGOALS))) +dep: uninstall +endif + +ifeq ($(MAKECMDGOALS),build) + ifneq (,$(OBJ)) + -include $(OBJ:.o=.dep) + endif +endif diff --git a/src/Makefile_template.mk b/src/Makefile_template.mk new file mode 100644 index 0000000..90c00da --- /dev/null +++ b/src/Makefile_template.mk @@ -0,0 +1,65 @@ +#------------------------------------------------------------------------------ +# Local Makefile +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:22 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Var include +#------------------------------------------------------------------------------ + +include ../../Makefile_var.mk + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +TARGET= lib_xxx$(SHLIB_SUFFIX) + +OBJ= module1.o \ + module2.o \ + lib_xxx.o + +EXTRA_INC= ../zzz + +EXTRA_LIB= -lzzz + + + +#------------------------------------------------------------------------------ +# Rule include +#------------------------------------------------------------------------------ + +include ../../Makefile_rule.mk diff --git a/src/Makefile_var.mk b/src/Makefile_var.mk new file mode 100644 index 0000000..aead75b --- /dev/null +++ b/src/Makefile_var.mk @@ -0,0 +1,497 @@ +#------------------------------------------------------------------------------ +# Makefile Var Definitions +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:22 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Curent Module Dir +#------------------------------------------------------------------------------ + +LOCAL_INC_DIR= ../include + + + +#------------------------------------------------------------------------------ +# Global Dir +#------------------------------------------------------------------------------ + +GLOBAL_INC_DIR= ../../include +GLOBAL_BIN_DIR= ../../../bin +GLOBAL_LIB_DIR= ../../../lib + +LIB_LIST= msg_router mapping_mng io_mng static_data_mng log_mng xml node z + + + +#------------------------------------------------------------------------------ +# Constants +#------------------------------------------------------------------------------ + +MAKE = make +MAKEDEP = makedepend +SHELL = bash +RM = rm +MKDIR = mkdir -p +CP = cp +CAT = cat +M4 = m4 +PROC = proc +CC = +#CC = cc +#CC = gcc +CPP = $(CC) +LD = +#LD = ld +#LD = $(CC) +AR = ar +TXBLDSRV = buildserver +TXBLDCLN = buildclient +TXMKFML = mkfldhdr +TXMKVIEW = viewc +PXDB = pxdb +LINT = lint +STRIPPER = strip +PURIFIER = purify + +COMMA = , + + + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +OS = $(shell uname) + +ifndef CC + ifeq ($(OS),HP-UX) + CC= cc + LD= ld + else + CC= gcc + LD= gcc + endif +endif + +ifdef VERBOSE + QUIET= + SILENT= + PROC_FILTER= + PRELINK_FILTER= + TXBLDSRV+= -v + TXBLDCLN+= -v +else + QUIET=@ + SILENT=-s + PROC_FILTER=| grep -v -e '^$$' -e '^Pro' -e '^(c)' \ + -e '^Copyright' -e '^System default option'; \ + [[ $${PIPESTATUS[0]} = 0 ]] + PRELINK_FILTER=2>&1 | grep -v -e '^Purify' \ + -e '^Instrumenting: '; \ + [[ $${PIPESTATUS[0]} = 0 ]] +endif + +ifdef DYNAMIC + STATIC= +else + STATIC=1 +endif + +ifdef OPTIMIZE + DEBUG= +else + DEBUG=1 +endif + +ifdef DEBUG + TXBLDSRV+= -k +endif + +ifndef SQLCHECK + SQLCHECK=FULL +endif + +ifndef ORACLE_SUPPORT + ifndef ORACLE_HOME + ORACLE_SUPPORT = 0 + else + ORACLE_SUPPORT = 1 + endif +endif + +ifndef TUX_SUPPORT + ifndef TUXDIR + TUX_SUPPORT = 0 + else + TUX_SUPPORT = 1 + endif +endif + +ifndef MQS_SUPPORT + ifndef MQM_HOME + MQS_SUPPORT = 0 + else + MQS_SUPPORT = 1 + endif +endif + + + +# Flags Init +INCLUDE= +LIB_cc= +LIB_gcc= +LIB= +M4_FLAGS= +MAKEDEP_FLAGS= +PROC_FLAGS= +CPPFLAGS= +CPPFLAGS_cc= +CPPFLAGS_gcc= +CFLAGS= +CFLAGS_cc= +CFLAGS_gcc= +LDFLAGS= +TXBLD_FLAGS= +TXBLD_FLAGS_cc= +TXBLD_FLAGS_gcc= +LDFLAGS= +LDFLAGS_cc= +LDFLAGS_gcc= +LINK_FLAGS= +LINK_FLAGS_cc= +LINK_FLAGS_gcc= +ARFLAGS= + + + + +PURIFIER_FLAGS= -user-path=$(shell echo "$(patsubst %,lib%/src,$(LIB_LIST)) imrd/src" | sed 's/ /\:/g') + +ifdef PURIFY + PRELINK=echo -e '$(ECHO_HEAD)Purifing $@... '; \ + export CC="$(PURIFIER) $(PURIFIER_FLAGS) $(CC)"; +endif + + + +ifeq ($(ORACLE_SUPPORT),1) + INCLUDE+= -I$(ORACLE_HOME)/precomp/public + LIB+= -L$(ORACLE_HOME)/lib -lclntsh + M4_FLAGS+= -DORACLE_SUPPORT + MAKEDEP_FLAGS+= -DORACLE_SUPPORT + PROC_FLAGS+= DEFINE=ORACLE_SUPPORT + CPPFLAGS+= -DORACLE_SUPPORT + CFLAGS+= -DORACLE_SUPPORT +endif + +ifeq ($(TUX_SUPPORT),1) + INCLUDE+= -I$(TUXDIR)/include + LIB+= -L$(TUXDIR)/lib -lfml -lfml32 -ltux + M4_FLAGS+= -DTUX_SUPPORT + MAKEDEP_FLAGS+= -DTUX_SUPPORT + PROC_FLAGS+= DEFINE=TUX_SUPPORT + CPPFLAGS+= -DTUX_SUPPORT + CFLAGS+= -DTUX_SUPPORT +endif + +ifeq ($(MQS_SUPPORT),1) + INCLUDE+= -I$(MQM_HOME)/inc + LIB+= -L$(MQM_HOME)/lib64 -lmqic + M4_FLAGS+= -DMQS_SUPPORT + MAKEDEP_FLAGS+= -DMQS_SUPPORT + PROC_FLAGS+= DEFINE=MQS_SUPPORT + CPPFLAGS+= -DMQS_SUPPORT + CFLAGS+= -DMQS_SUPPORT +endif + + + +# OS Dependant Flags + +ifeq ($(OS),HP-UX) + SHLIB_SUFFIX= .sl + M4_FLAGS:= -B100000 -S100000 $(M4_FLAGS) + MAKEDEP_FLAGS+= -z -D _HPUX_SOURCE -D __hpux + PROC_FLAGS+= DEFINE=_PA_RISC2_0 + CPPFLAGS+= -D _HPUX_SOURCE -D __hpux + CFLAGS+= -D _HPUX_SOURCE -D __hpux + LDFLAGS+= -b + LDFLAGS+= + + ifeq ($(ARCH),32BITS) + MAKEDEP_FLAGS+= + CPPFLAGS_cc+= +DD32 + CPPFLAGS_gcc+= + CFLAGS_cc+= +DD32 + CFLAGS_gcc+= + TXBLD_FLAGS_cc+= +DD32 + TXBLD_FLAGS_gcc+= + LINK_FLAGS_cc+= +DD32 + LINK_FLAGS_gcc+= + LDFLAGS_cc+= + LDFLAGS_gcc+= + endif + + ifeq ($(ARCH),64BITS) + MAKEDEP_FLAGS+= -D__LP64__ + CPPFLAGS_cc+= +DD64 + CPPFLAGS_gcc+= + CFLAGS_cc+= +DD64 + CFLAGS_gcc+= + TXBLD_FLAGS_cc+= +DD64 + TXBLD_FLAGS_gcc+= + LINK_FLAGS_cc+= +DD64 + LINK_FLAGS_gcc+= + LDFLAGS_cc+= + LDFLAGS_gcc+= + endif +else + SHLIB_SUFFIX= .so + M4_FLAGS+= + MAKEDEP_FLAGS+= + PROC_FLAGS+= + CPPFLAGS+= + CFLAGS+= + LDFLAGS+= -shared +endif + + + +# Compiler Dependant Flags + +INCLUDE+= -I. \ + $(patsubst %,-I../../lib%/include,$(LIB_LIST)) \ + -I$(GLOBAL_INC_DIR) \ + $(shell for inc in $(EXTRA_INC); \ + do \ + echo "-I$$inc "; \ + done) + + + +ifeq ($(SQLCHECK),FULL) +PROC_FLAGS+= USERID=$(USR_IMRMGR)/$(PWD_IMRMGR) +endif + +PROC_FLAGS+= SQLCHECK=$(SQLCHECK) \ + RELEASE_CURSOR=NO \ + HOLD_CURSOR=YES \ + MAXOPENCURSOR=100 \ + DBMS=V7 \ + MODE=ORACLE \ + CODE=ANSI_C \ + $(patsubst -I%,INCLUDE=%,$(INCLUDE)) + + + + +CPPFLAGS_cc+= -P -C -Ae -w +CPPFLAGS_gcc+= -E -C + +CFLAGS_cc+= -c -Ae +z +CFLAGS_gcc+= -c -fpic -pipe + +TXBLD_FLAGS_cc+= -Wl,+s,-Bimmediate +TXBLD_FLAGS_gcc+= + +LDFLAGS_cc+= +LDFLAGS_gcc+= + +LINK_FLAGS_cc+= +LINK_FLAGS_gcc+= + + + +ifdef DEBUG + CFLAGS_cc+= -g + CFLAGS_gcc+= -g + TXBLD_FLAGS_cc+= -g + TXBLD_FLAGS_gcc+= -g + LDFLAGS_cc+= + LDFLAGS_gcc+= + LINK_FLAGS_cc+= -g + LINK_FLAGS_gcc+= -g +endif + +ifdef OPTIMIZE + CFLAGS_cc+= -O + CFLAGS_gcc+= -O3 + TXBLD_FLAGS_cc+= -O + TXBLD_FLAGS_gcc+= -O3 + LDFLAGS_cc+= + LDFLAGS_gcc+= -O3 + LINK_FLAGS_cc+= -O + LINK_FLAGS_gcc+= -Wl,-O3 +endif + +ifdef PROFILE + CFLAGS_cc+= -pg + CFLAGS_gcc+= -pg + TXBLD_FLAGS_cc+= -pg + TXBLD_FLAGS_gcc+= -pg +endif + + + +ifdef WARNING + CFLAGS_cc+=+w1 +M2 + CFLAGS_gcc+=-Wformat -Wnonnull -Wimplicit -Wmain -Wmissing-braces \ + -Wparentheses -Wsequence-point -Wreturn-type -Wswitch \ + -Wswitch-default -Wswitch-enum -Wtrigraphs -Wunused \ + -Wuninitialized -Wunknown-pragmas -Wstrict-aliasing -W \ + -Wfloat-equal -Wundef -Wendif-labels -Wshadow \ + -Wpointer-arith -Wbad-function-cast -Wcast-qual \ + -Wcast-align -Wwrite-strings -Wconversion \ + -Wsign-compare -Waggregate-return -Wstrict-prototypes \ + -Wmissing-prototypes -Wmissing-declarations \ + -Wmissing-noreturn -Wmissing-format-attribute -Wpacked \ + -Wredundant-decls -Wnested-externs -Wunreachable-code \ + -Winline -Wlong-long -Wdisabled-optimization + TXBLD_FLAGS_cc+=+w1 +M2 + TXBLD_FLAGS_gcc+=-Wformat -Wnonnull -Wimplicit -Wmain -Wmissing-braces \ + -Wparentheses -Wsequence-point -Wreturn-type -Wswitch \ + -Wswitch-default -Wswitch-enum -Wtrigraphs -Wunused \ + -Wuninitialized -Wunknown-pragmas -Wstrict-aliasing -W \ + -Wfloat-equal -Wundef -Wendif-labels -Wshadow \ + -Wpointer-arith -Wbad-function-cast -Wcast-qual \ + -Wcast-align -Wwrite-strings -Wconversion \ + -Wsign-compare -Waggregate-return -Wstrict-prototypes \ + -Wmissing-prototypes -Wmissing-declarations \ + -Wmissing-noreturn -Wmissing-format-attribute -Wpacked \ + -Wredundant-decls -Wnested-externs -Wunreachable-code \ + -Winline -Wlong-long -Wdisabled-optimization +endif + + + +ifdef EFENCE +else + ifdef DMALLOC + CFLAGS+= -DDMALLOC + endif +endif + + + +ifdef STATIC + ifeq ($(CC),cc) + LIB+= -Wl,-a,archive_shared + + ifeq ($(ARCH),64BITS) + LIB+= -Wl,+forceload + else + LIB+= -Wl,-E + endif + else + LIB+= -Wl,-export-dynamic,-whole-archive,-Bstatic + endif +endif + +LIB+= -L$(GLOBAL_LIB_DIR) \ + $(patsubst %,-l%,$(LIB_LIST)) + +ifdef STATIC + ifeq ($(CC),cc) + ifeq ($(ARCH),64BITS) + LIB+= -Wl,+noforceload + endif + + LIB+= -Wl,-a,shared_archive + else + LIB+= -Wl,-no-whole-archive,-Bdynamic + endif +endif + +ifdef EFENCE + LIB+= -lefence -lrt +else + ifdef DMALLOC + LIB+= -ldmalloc + endif +endif + +LIB_cc+= -lnsl -lm -lpthread + +LIB_gcc+= -lpthread -lm -ldl + + + +TXBLD_LIB= -f "$(LIB) -ltmib" + + + +TXSERVICE_NAME= $(shell if [ -f $(TARGET).c ]; \ + then \ + grep TXSERVICE_NAME $(TARGET).c | \ + sed "s/.*: //"; \ + fi) +TXSERVICE_TYPE= $(shell if [ -f $(TARGET).c ]; \ + then \ + grep TXSERVICE_TYPE $(TARGET).c | \ + sed "s/.*: //"; \ + fi) + + + +PXDBFLAGS= -s on $(EXTRA_PXDBFLAGS) + + + +LINTFLAGS= $(EXTRA_LINTFLAGS) + +LINTLIBS= $(GLOBAL_LIB_DIR)/*.ln + + + +# Flags Merging + +MAKEDEP_FLAGS+= $(INCLUDE) -f- $(EXTRA_MAKEDEP_FLAGS) +PROC_FLAGS+= $(EXTRA_PROC_FLAGS) +CPPFLAGS+= $(CPPFLAGS_$(CPP)) $(EXTRA_CPPFLAGS) +CFLAGS+= $(CFLAGS_$(CC)) $(EXTRA_CFLAGS) +LINK_FLAGS+= $(LINK_FLAGS_$(CC)) $(EXTRA_LINK_FLAGS) +LDFLAGS+= $(LDFLAGS_$(CC)) $(EXTRA_LDFLAGS) +LIB+= $(LIB_$(CC)) $(EXTRA_LIB) +ARFLAGS+= -cr $(EXTRA_ARFLAGS) +TXBLD_FLAGS+= -f "$(TXBLD_FLAGS_$(CC))" -r $(ORACLE_RM) $(EXTRA_TXBLD_FLAGS) + + + +ifeq ($(CC),gcc) + TXBLDSRV:=CC=cc.gcc; $(TXBLDSRV) + TXBLDCLN:=CC=cc.gcc; $(TXBLDCLN) +endif diff --git a/src/imrc/src/Makefile b/src/imrc/src/Makefile new file mode 100644 index 0000000..4c685d0 --- /dev/null +++ b/src/imrc/src/Makefile @@ -0,0 +1,59 @@ +#------------------------------------------------------------------------------ +# Local Makefile +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + +#------------------------------------------------------------------------------ +# Constants +#------------------------------------------------------------------------------ + +MAKEFILE_GLOB= ../../Makefile_glob.mk +MAKEFILE_PATH= ../../Makefile_path.mk + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +TARGET= lib_xxx.sl + +OBJ= module1.o \ + module2.o \ + lib_xxx.o + +EXTRA_INC= ../zzz + +EXTRA_LIB= -lzzz + + + +#------------------------------------------------------------------------------ +# Include +#------------------------------------------------------------------------------ + +include $(MAKEFILE_GLOB) diff --git a/src/imrd/src/Makefile b/src/imrd/src/Makefile new file mode 100644 index 0000000..193f269 --- /dev/null +++ b/src/imrd/src/Makefile @@ -0,0 +1,65 @@ +#------------------------------------------------------------------------------ +# Local Makefile +#------------------------------------------------------------------------------ +# $Workfile: Makefile $ +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:22 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Var include +#------------------------------------------------------------------------------ + +include ../../Makefile_var.mk + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +TARGET= imrd + +OBJ= imrd.o + +EXTRA_INC= + +EXTRA_LIB= + + + +#------------------------------------------------------------------------------ +# Rule include +#------------------------------------------------------------------------------ + +include ../../Makefile_rule.mk diff --git a/src/imrd/src/imrd.c b/src/imrd/src/imrd.c new file mode 100644 index 0000000..30a2a32 --- /dev/null +++ b/src/imrd/src/imrd.c @@ -0,0 +1,1140 @@ +/*----------------------------------------------------------------------------*/ +/* $Workfile: imrd.c $ */ +/*----------------------------------------------------------------------------*/ +/* $Author: agibert $ */ +/* $Date: 2008/11/12 02:25:22 $ */ +/* $Revision: 1.1 $ */ +/* $Label: $ */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _IMRD_C_ + +#include "imrd.h" + + + + + + + +/*----------------------------------------------------------------------------*/ +/* Config_Init */ +/*----------------------------------------------------------------------------*/ +/* Config_Ptr: Config structure to initialize */ +/* ArgC: Argument number */ +/* ArgV: Argument tab */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Config_Init( IMRT_Config *Config_Ptr, int ArgC, char **ArgV) +{ + struct stat stat_buf; + IMRT_Module_Id module_id; + + + /* LM Init */ + + strcpy( Config_Ptr->LM.Log_File, "-"); + + Config_Ptr->LM.Module_Nb = IMRD_MODULE_NB; + + for( module_id = 0; module_id < IMRD_MODULE_NB; module_id++) + { + if( module_id == IMRD_MODULE_ID_UNKNOWN) + { + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_TRACE][ module_id] = IMRD_LOG_LEVEL_UNSET; + + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_TRACE][ module_id] = IMRD_LOG_LEVEL_UNSET; + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_INFO][ module_id] = IMRD_LOG_LEVEL_DEFAULT; + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_WARNING][ module_id] = IMRD_LOG_LEVEL_DEFAULT; + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_ERROR][ module_id] = IMRD_LOG_LEVEL_DEFAULT; + } + else + { + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_TRACE][ module_id] = IMRD_LOG_LEVEL_UNSET; + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_INFO][ module_id] = IMRD_LOG_LEVEL_UNSET; + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_WARNING][ module_id] = IMRD_LOG_LEVEL_UNSET; + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_ERROR][ module_id] = IMRD_LOG_LEVEL_UNSET; + } + } + + + + /* SDM Init */ + + Config_Ptr->SDM.Flag = IMRD_SDM_FLAG_XML; + + strncpy( Config_Ptr->SDM.Lib_Path, dirname( ArgV[0]), IMRD_PATH_LEN); + strncat( Config_Ptr->SDM.Lib_Path, "/../lib/imr", IMRD_PATH_LEN); + + if( ( stat( Config_Ptr->SDM.Lib_Path, &stat_buf) == -1) || ( ! S_ISDIR( stat_buf.st_mode))) + { + strcpy( Config_Ptr->SDM.Lib_Path, "."); + } + + + + /* MM Init */ + + Config_Ptr->MM.XML_Format = IMRD_FALSE; + + + + /* MR Init */ + + Config_Ptr->MR.Mapping_Forced = IMRD_FALSE; + Config_Ptr->MR.Continue_Forced = IMRD_FALSE; + Config_Ptr->MR.Read_Mode = IMRD_READ_MODE_WAIT; + Config_Ptr->MR.Log_Id_Struct_Input.Bit_Nb = 0; + Config_Ptr->MR.Log_Id_Struct_Input.Log_Size = 0; + Config_Ptr->MR.Log_Id_Struct_Input.Log_Id_Bit_Ptr = NULL; + Config_Ptr->MR.Log_Id_Struct_Output.Bit_Nb = 0; + Config_Ptr->MR.Log_Id_Struct_Output.Log_Size = 0; + Config_Ptr->MR.Log_Id_Struct_Output.Log_Id_Bit_Ptr = NULL; + + + + /* IMRD Init */ + + strcpy( Config_Ptr->IMRD.Medium_URL_Input, "file://\\nMSG_BREAK\\n@in.txt"); + strcpy( Config_Ptr->IMRD.Appl_Name_Input, "bo_raw"); + Config_Ptr->IMRD.Appl_Id_Input = IMRD_APPL_ID_UNDEFINEDED; + + strcpy( Config_Ptr->IMRD.Medium_URL_Output, "file://\\nMSG_BREAK\\n@out.txt"); + strcpy( Config_Ptr->IMRD.Appl_Name_Output, "cristal_raw"); + Config_Ptr->IMRD.Appl_Id_Output = IMRD_APPL_ID_UNDEFINEDED; + + strcpy( Config_Ptr->IMRD.Medium_URL_Trash, "file://\\nMSG_BREAK\\n@trash.txt"); + + Config_Ptr->IMRD.Version_Mode = IMRD_FALSE; + Config_Ptr->IMRD.Help_Mode = IMRD_FALSE; + Config_Ptr->IMRD.Dump_Mode = IMRD_SDM_FLAG_UNKNOWN; + Config_Ptr->IMRD.Core_Dump = IMRD_FALSE; + + + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Config_Deinit */ +/*----------------------------------------------------------------------------*/ +/* Config_Ptr: Config structure to deinitialize */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Config_Deinit( IMRT_Config *Config_Ptr) +{ + if( Config_Ptr->MR.Log_Id_Struct_Input.Log_Id_Bit_Ptr != NULL) + { + free( Config_Ptr->MR.Log_Id_Struct_Input.Log_Id_Bit_Ptr); + } + + if( Config_Ptr->MR.Log_Id_Struct_Output.Log_Id_Bit_Ptr) + { + free( Config_Ptr->MR.Log_Id_Struct_Output.Log_Id_Bit_Ptr); + } + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Args_Parse */ +/*----------------------------------------------------------------------------*/ +/* Config_Ptr: Configuration structure to update */ +/* ArgC: Argument number */ +/* ArgV: Argument tab */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Args_Parse( IMRT_Config *Config_Ptr, int ArgC, char **ArgV) +{ + int arg_cur, i, j; + char value_tmp[ IMRD_ARG_NAME_SIZE]; + IMRT_Module_Id module_id; + + + for( arg_cur = 1; arg_cur < ArgC; arg_cur++) + { + for( i = 0; + ( i < IMRD_ARG_NB) && ( strcmp( IMRG_Arg_Tab[i].Name_Short, ArgV[arg_cur]) != 0) && ( strcmp( IMRG_Arg_Tab[i].Name_Long, ArgV[arg_cur]) != 0); + i++); + + + + if( ( i > 0) && ( i < IMRD_ARG_NB)) + { + + switch( i) + { + case IMRD_ARG_VERSION: + { + Config_Ptr->IMRD.Version_Mode = IMRD_TRUE; + + break; + } + + case IMRD_ARG_HELP: + { + Config_Ptr->IMRD.Help_Mode = IMRD_TRUE; + + break; + } + + case IMRD_ARG_VERBOSE_LEVEL_DEFAULT: + { + if( ( arg_cur + 1) < ArgC) + { + strncpy( value_tmp, ArgV[ ++arg_cur], IMRD_ARG_NAME_LEN); + + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_TRACE][ IMRD_MODULE_ID_UNKNOWN] = atoi( value_tmp); + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[ i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_VERBOSE_LEVEL_MODULE: + { + if( ( arg_cur + 2) < ArgC ) + { + strncpy( value_tmp, ArgV[ ++arg_cur], IMRD_ARG_NAME_LEN); + j = atoi( value_tmp); + + strncpy( value_tmp, ArgV[ ++arg_cur], IMRD_ARG_NAME_LEN); + + for( module_id = 1; + ( module_id < IMRD_MODULE_NB) && ( strcmp( value_tmp, IMRG_IMRD_Base.Module_Entry_Tab[ module_id].Module_Ptr->Name) != 0); + module_id++); + + if( module_id == IMRD_MODULE_NB) + { + IMRD_LM_LOG_ERROR_1( "Module not found [%s] !", value_tmp); + + return( IMRS_KO); + } + + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_TRACE][ module_id] = j; + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[ i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_LOG_FILE: + { + if( ( arg_cur + 1) < ArgC) + { + strncpy( ( char *) Config_Ptr->LM.Log_File, ArgV[ ++arg_cur], IMRD_PATH_LEN); + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[ i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_SD_READ_XML: + { + Config_Ptr->SDM.Flag = IMRD_SDM_FLAG_XML; + + break; + } + + case IMRD_ARG_SD_READ_SQL: + { + Config_Ptr->SDM.Flag = IMRD_SDM_FLAG_SQL; + + break; + } + + case IMRD_ARG_SD_WRITE_XML: + { + Config_Ptr->IMRD.Dump_Mode = IMRD_SDM_FLAG_XML; + + break; + } + + case IMRD_ARG_SD_WRITE_SQL: + { + Config_Ptr->IMRD.Dump_Mode = IMRD_SDM_FLAG_SQL; + + break; + } + + case IMRD_ARG_LIBRARY_DIR: + { + if( ( arg_cur + 1) < ArgC) + { + strncpy( ( char *) Config_Ptr->SDM.Lib_Path, ArgV[ ++arg_cur], IMRD_PATH_LEN); + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[ i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_MEDIUM_URL_INPUT: + { + if( ( arg_cur + 1) < ArgC) + { + strncpy( ( char *) Config_Ptr->IMRD.Medium_URL_Input, ArgV[ ++arg_cur], IMRD_MEDIUM_URL_LEN); + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[ i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_APPL_NAME_INPUT: + { + if( ( arg_cur + 1) < ArgC) + { + strncpy( ( char *) Config_Ptr->IMRD.Appl_Name_Input, ArgV[ ++arg_cur], IMRD_APPL_NAME_LEN); + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_APPL_ID_INPUT: + { + if( ( arg_cur + 1) < ArgC) + { + strncpy( value_tmp, ArgV[++arg_cur], IMRD_ARG_NAME_LEN); + + Config_Ptr->IMRD.Appl_Id_Input = atoi( value_tmp); + Config_Ptr->IMRD.Appl_Name_Input[0] = '\0'; + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_MEDIUM_URL_OUTPUT: + { + if( ( arg_cur + 1) < ArgC) + { + strncpy( ( char *) Config_Ptr->IMRD.Medium_URL_Output, ArgV[ ++arg_cur], IMRD_MEDIUM_URL_LEN); + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[ i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_APPL_NAME_OUTPUT: + { + if( ( arg_cur + 1) < ArgC) + { + strncpy( ( char *) Config_Ptr->IMRD.Appl_Name_Output, ArgV[ ++arg_cur], IMRD_APPL_NAME_LEN); + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_APPL_ID_OUTPUT: + { + if( ( arg_cur + 1) < ArgC) + { + strncpy( value_tmp, ArgV[ ++arg_cur], IMRD_ARG_NAME_LEN); + + Config_Ptr->IMRD.Appl_Id_Output = atoi( value_tmp); + Config_Ptr->IMRD.Appl_Name_Output[0] = '\0'; + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_MEDIUM_URL_TRASH: + { + if( ( arg_cur + 1) < ArgC) + { + strncpy( ( char *) Config_Ptr->IMRD.Medium_URL_Trash, ArgV[ ++arg_cur], IMRD_MEDIUM_URL_LEN); + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[ i].Name_Short); + + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_MAPPING_FORCED: + { + Config_Ptr->MR.Mapping_Forced = IMRD_TRUE; + + break; + } + + case IMRD_ARG_CONTINUE_FORCED: + { + Config_Ptr->MR.Continue_Forced = IMRD_TRUE; + + break; + } + + case IMRD_ARG_NO_WAIT: + { + Config_Ptr->MR.Read_Mode = IMRD_READ_MODE_NO_WAIT; + + break; + } + + case IMRD_ARG_XML_FORMAT: + { + Config_Ptr->MM.XML_Format = IMRD_TRUE; + + break; + } + + case IMRD_ARG_CORE_DUMP: + { + Config_Ptr->IMRD.Core_Dump = IMRD_TRUE; + + break; + } + + case IMRD_ARG_LOG_ID_INPUT_MSG : + { + if( ( arg_cur + 2) < ArgC) + { + if( atoi( ArgV[ arg_cur + 1]) < 0) + { + IMRD_LM_LOG_ERROR_1( "Invalid Log_Id_Offset: [%s] !", ArgV[ arg_cur + 1]); + + return( IMRS_KO); + } + + if( atoi( ArgV[ arg_cur + 2]) <= 0) + { + IMRD_LM_LOG_ERROR_1( "Invalid Log_Id_Size: [%d] !", ArgV[ arg_cur + 2]); + + return( IMRS_KO); + } + + if( ( Config_Ptr->MR.Log_Id_Struct_Input.Log_Id_Bit_Ptr = + realloc( Config_Ptr->MR.Log_Id_Struct_Input.Log_Id_Bit_Ptr, + ( ( Config_Ptr->MR.Log_Id_Struct_Input.Bit_Nb + 1)) * sizeof( IMRT_Log_Id_Bit))) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate Input Log_Id_Bit_Ptr (%d) !", errno); + + return( IMRS_KO); + } + + Config_Ptr->MR.Log_Id_Struct_Input.Log_Id_Bit_Ptr[ Config_Ptr->MR.Log_Id_Struct_Input.Bit_Nb].Offset = atoi( ArgV[ ++arg_cur]); + Config_Ptr->MR.Log_Id_Struct_Input.Log_Id_Bit_Ptr[ Config_Ptr->MR.Log_Id_Struct_Input.Bit_Nb].Size = atoi( ArgV[ ++arg_cur]); + Config_Ptr->MR.Log_Id_Struct_Input.Log_Size += atoi( ArgV[ arg_cur]); + Config_Ptr->MR.Log_Id_Struct_Input.Bit_Nb++; + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[ i].Name_Short); + return( IMRS_KO); + } + + break; + } + + case IMRD_ARG_LOG_ID_OUTPUT_MSG : + { + if( ( arg_cur + 2) < ArgC) + { + if( atoi( ArgV[ arg_cur + 1]) < 0) + { + IMRD_LM_LOG_ERROR_1( "Invalid Log_Id_Offset: [%s] !", ArgV[ arg_cur + 1]); + + return( IMRS_KO); + } + + if( atoi( ArgV[ arg_cur + 2]) <= 0) + { + IMRD_LM_LOG_ERROR_1( "Invalid Log_Id_Size: [%d] !", ArgV[ arg_cur + 2]); + + return( IMRS_KO); + } + + if( ( Config_Ptr->MR.Log_Id_Struct_Output.Log_Id_Bit_Ptr = + realloc( Config_Ptr->MR.Log_Id_Struct_Output.Log_Id_Bit_Ptr, + ( ( Config_Ptr->MR.Log_Id_Struct_Output.Bit_Nb + 1)) * sizeof( IMRT_Log_Id_Bit))) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate Output Log_Id_Bit_Ptr (%d) !", errno); + + return( IMRS_KO); + } + + Config_Ptr->MR.Log_Id_Struct_Output.Log_Id_Bit_Ptr[ Config_Ptr->MR.Log_Id_Struct_Output.Bit_Nb].Offset = atoi( ArgV[ ++arg_cur]); + Config_Ptr->MR.Log_Id_Struct_Output.Log_Id_Bit_Ptr[ Config_Ptr->MR.Log_Id_Struct_Output.Bit_Nb].Size = atoi( ArgV[ ++arg_cur]); + Config_Ptr->MR.Log_Id_Struct_Output.Log_Size += atoi( ArgV[ arg_cur]); + Config_Ptr->MR.Log_Id_Struct_Output.Bit_Nb++; + } + else + { + IMRD_LM_LOG_ERROR_1( "Missing argument value [%s] !", IMRG_Arg_Tab[ i].Name_Short); + return( IMRS_KO); + } + + break; + } + + + default: + { + IMRD_LM_LOG_ERROR_1( "Internal parse error [%d] !", i); + + return( IMRS_KO); + } + } + } + else + { + IMRD_LM_LOG_ERROR_1( "Unreconized argument: (%s) !", ArgV[arg_cur]); + + return( IMRS_KO); + } + } + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Args_Log */ +/*----------------------------------------------------------------------------*/ +/* Config_Ptr: Configuration structure to dump */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Args_Log( IMRT_Config *Config_Ptr) +{ + IMRT_Module_Id module_id; + int idx; + + + IMRD_LM_LOG_INFO_3( "Lib_Dir: [%s] Static_Data_Read: [%s] Static_Data_Write: [%s]", + Config_Ptr->SDM.Lib_Path, + ( ( Config_Ptr->SDM.Flag == IMRD_SDM_FLAG_XML) ? "XML" : ( ( Config_Ptr->SDM.Flag == IMRD_SDM_FLAG_SQL) ? "SQL" : "Unknown")), + ( ( Config_Ptr->IMRD.Dump_Mode == IMRD_SDM_FLAG_XML) ? "XML" : ( ( Config_Ptr->IMRD.Dump_Mode == IMRD_SDM_FLAG_SQL) ? "SQL" : "Unknown"))); + IMRD_LM_LOG_INFO_3( "Mapping_Forced: [%s] Continue_Forced: [%s] Read_Mode: [%s]", + ( ( Config_Ptr->MR.Mapping_Forced == IMRD_TRUE) ? "True" : "False"), + ( ( Config_Ptr->MR.Continue_Forced == IMRD_TRUE) ? "True" : "False"), + ( ( Config_Ptr->MR.Read_Mode == IMRD_READ_MODE_WAIT) ? "Wait" : ( ( Config_Ptr->MR.Read_Mode == IMRD_READ_MODE_NO_WAIT) ? "No Wait" : "Unknown"))); + IMRD_LM_LOG_INFO_2( "XML_Format: [%s] Core_Dump: [%s]", ( ( Config_Ptr->MM.XML_Format == IMRD_TRUE) ? "True" : "False"), ( ( Config_Ptr->IMRD.Core_Dump == IMRD_TRUE) ? "True" : "False")); + IMRD_LM_LOG_INFO_1( "Medium_URL_Input: [%s]", Config_Ptr->IMRD.Medium_URL_Input); + IMRD_LM_LOG_INFO_1( "Medium_URL_Output: [%s]", Config_Ptr->IMRD.Medium_URL_Output); + IMRD_LM_LOG_INFO_1( "Medium_URL_Trash: [%s]", Config_Ptr->IMRD.Medium_URL_Trash); + IMRD_LM_LOG_INFO_0( "Log Level Tab: Module Id Trace Info Warning Error"); + + for( module_id = 0; module_id < IMRD_MODULE_NB; module_id++) + { + IMRD_LM_LOG_INFO_5( "Log Level tab: [%-34s]: (%3d) (%3d) (%3d) (%3d)", + ( ( IMRG_IMRD_Base.Module_Entry_Tab[ module_id].Module_Ptr == NULL) ? "Default" : IMRG_IMRD_Base.Module_Entry_Tab[ module_id].Module_Ptr->Name_Long), + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_TRACE][ module_id], + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_INFO][ module_id], + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_WARNING][ module_id], + Config_Ptr->LM.Level_Tab[ IMRD_LOG_TYPE_ID_ERROR][ module_id]); + } + + for( idx = 0 ; idx < Config_Ptr->MR.Log_Id_Struct_Input.Bit_Nb; idx++) + { + IMRD_LM_LOG_INFO_2( "Log_Id_Bit_Input: Offset: (%5d) Size: (%5d)", + Config_Ptr->MR.Log_Id_Struct_Input.Log_Id_Bit_Ptr[ idx].Offset, + Config_Ptr->MR.Log_Id_Struct_Input.Log_Id_Bit_Ptr[ idx].Size); + } + + for( idx = 0 ; idx < Config_Ptr->MR.Log_Id_Struct_Output.Bit_Nb; idx++) + { + IMRD_LM_LOG_INFO_2( "Log_Id_Bit_Output: Offset: (%5d) Size: (%5d)", + Config_Ptr->MR.Log_Id_Struct_Output.Log_Id_Bit_Ptr[ idx].Offset, + Config_Ptr->MR.Log_Id_Struct_Output.Log_Id_Bit_Ptr[ idx].Size); + } + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Version_Log */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Version_Log() +{ + IMRT_Module_Id module_id; + + + for( module_id = 0; module_id < IMRD_MODULE_NB; module_id++) + { + if( IMRG_IMRD_Base.Module_Entry_Tab[ module_id].Module_Ptr != NULL) + { + IMRD_LM_LOG_INFO_2( "[%-4s]: [%s]", IMRG_IMRD_Base.Module_Entry_Tab[ module_id].Module_Ptr->Name, IMRG_IMRD_Base.Module_Entry_Tab[ module_id].Module_Ptr->Version); + } + } + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Version_Print */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Version_Print() +{ + IMRT_Module_Id module_id; + + + for( module_id = 0; module_id < IMRD_MODULE_NB; module_id++) + { + if( IMRG_IMRD_Base.Module_Entry_Tab[ module_id].Module_Ptr != NULL) + { + fprintf( stderr, "[%-4s]: [%s]\n", IMRG_IMRD_Base.Module_Entry_Tab[ module_id].Module_Ptr->Name, IMRG_IMRD_Base.Module_Entry_Tab[ module_id].Module_Ptr->Version); + } + } + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Help_Print */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Help_Print( void) +{ + int i; + + + for( i = 0; i < IMRD_ARG_NB; i++) + { + if( IMRG_Arg_Tab[i].Name_Short[0] != '\0') + fprintf( stderr, "%-6s%-25s%s\n", IMRG_Arg_Tab[i].Name_Short, IMRG_Arg_Tab[i].Name_Long, IMRG_Arg_Tab[i].Help); + } + + return( IMRS_OK); +} + + + + + + +/*----------------------------------------------------------------------------*/ +/* Lib_Open */ +/*----------------------------------------------------------------------------*/ +/* Module_Entry_Ptr: Module to open */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Lib_Open( IMRT_Module_Entry *Module_Entry_Ptr) +{ + IMRT_Status status; + + + if( Module_Entry_Ptr->Module_Ptr->Lib.Open_Ptr != NULL) + { + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_0, "Opening %s library...", Module_Entry_Ptr->Module_Ptr->Name_Long); + + if( ( status = Module_Entry_Ptr->Module_Ptr->Lib.Open_Ptr( Module_Entry_Ptr->Config_Ptr)) != IMRS_OK) + { + Module_Entry_Ptr->Status = IMRD_LIB_STATUS_ERROR; + + IMRD_LM_LOG_ERROR_1( "Can't open %s library !", Module_Entry_Ptr->Module_Ptr->Name_Long); + } + else + { + Module_Entry_Ptr->Status = IMRD_LIB_STATUS_OPENED; + + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_0, "%s library opened !", Module_Entry_Ptr->Module_Ptr->Name_Long); + } + } + + return( status); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Libs_Open */ +/*----------------------------------------------------------------------------*/ +/* Module_Entry_Tab: Module tab */ +/* Module_Nb: Number of module */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Libs_Open( IMRT_Module_Entry *Module_Entry_Tab, IMRT_Module_Id Module_Nb) +{ + IMRT_Status status; + IMRT_Module_Id i; + + + for( i = 0, status = IMRS_OK; ( i < Module_Nb) && ( status == IMRS_OK); i++) + { + if( ( Module_Entry_Tab[i].Module_Ptr != NULL) + && ( Module_Entry_Tab[i].Module_Ptr->Type == IMRD_MODULE_TYPE_LIBRARY) + && ( Module_Entry_Tab[i].Module_Ptr->Lib.Open_Ptr != NULL) + && ( Module_Entry_Tab[i].Status == IMRD_LIB_STATUS_CLOSED)) + { + status = Lib_Open( &( Module_Entry_Tab[i])); + } + } + + return( status); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Lib_Close */ +/*----------------------------------------------------------------------------*/ +/* Module_Entry_Ptr: Module to close */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Lib_Close( IMRT_Module_Entry *Module_Entry_Ptr) +{ + IMRT_Status status; + + + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_0, "Closinging %s library...", Module_Entry_Ptr->Module_Ptr->Name_Long); + + if( ( status = Module_Entry_Ptr->Module_Ptr->Lib.Close_Ptr()) != IMRS_OK) + { + Module_Entry_Ptr->Status = IMRD_LIB_STATUS_ERROR; + + IMRD_LM_LOG_ERROR_1( "Can't close %s library !", Module_Entry_Ptr->Module_Ptr->Name_Long); + } + else + { + Module_Entry_Ptr->Status = IMRD_LIB_STATUS_CLOSED; + + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_0, "%s library closed !", Module_Entry_Ptr->Module_Ptr->Name_Long); + } + + return( status); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Libs_Close */ +/*----------------------------------------------------------------------------*/ +/* Module_Entry_Tab: Module tab */ +/* Module_Nb: Number of module */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Libs_Close( IMRT_Module_Entry *Module_Entry_Tab, IMRT_Module_Id Module_Nb) +{ + IMRT_Status status; + IMRT_Module_Id i; + + + for( i = ( Module_Nb - 1), status = IMRS_OK; ( i > -1) && ( status == IMRS_OK); i--) + { + if( ( Module_Entry_Tab[i].Module_Ptr != NULL) && ( Module_Entry_Tab[i].Module_Ptr->Lib.Open_Ptr != NULL)) + { + if( Module_Entry_Tab[i].Status == IMRD_LIB_STATUS_OPENED) + { + status = Lib_Close( &( Module_Entry_Tab[i])); + } + else + { + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_0, "%s library not opened !", Module_Entry_Tab[i].Module_Ptr->Name_Long); + } + } + } + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Signal_Trap */ +/*------------------------------------------------------------------------------*/ + +void Signal_Trap( int Sig_Num) +{ + + fprintf( stderr, "Signal: (%d) !\n", Sig_Num); + + switch( Sig_Num) + { + case SIGBUS: + case SIGSEGV: + { + if( ( IMRG_Base.Sig_Trapped == SIGBUS) || ( IMRG_Base.Sig_Trapped == SIGSEGV)) + { + fprintf( stderr, "Imediate exit !!!\n"); + exit( -1); + } + else + { + fprintf( stderr, "Long Jumping...\n"); + IMRG_Base.Sig_Trapped = Sig_Num; + + siglongjmp( IMRG_Base.SigLongJmp_Env, 1); + } + + break; + } + + case SIGINT: + case SIGQUIT: + case SIGTERM: + default: + { + if( IMRG_Base.Sig_Trapped != 0) + { + fprintf( stderr, "Signal rejected: (%d) !\n", Sig_Num); + } + else + { + IMRG_Base.Sig_Trapped = Sig_Num; + } + + break; + } + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Signal_Init */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Signal_Init() +{ + int rc; + struct sigaction act = {0}; + + act.sa_handler = Signal_Trap; + + + if( ( rc = sigaction( SIGINT, &act, &( IMRG_IMRD_Base.OAct_Int))) != 0) + { + IMRD_LM_LOG_ERROR_2( "Can't trap signal (%d) errno: (%d) !", SIGINT, errno); + + return( IMRS_KO); + } + + if( ( rc = sigaction( SIGQUIT, &act, &( IMRG_IMRD_Base.OAct_Quit))) != 0) + { + IMRD_LM_LOG_ERROR_2( "Can't trap signal (%d) errno: (%d) !", SIGQUIT, errno); + + return( IMRS_KO); + } + + if( ( rc = sigaction( SIGTERM, &act, &( IMRG_IMRD_Base.OAct_Int))) != 0) + { + IMRD_LM_LOG_ERROR_2( "Can't trap signal (%d) errno: (%d) !", SIGTERM, errno); + + return( IMRS_KO); + } + + if( IMRG_IMRD_Base.Config.IMRD.Core_Dump == IMRD_FALSE) + { + if( ( rc = sigaction( SIGBUS, &act, &( IMRG_IMRD_Base.OAct_Bus))) != 0) + { + IMRD_LM_LOG_ERROR_2( "Can't trap signal (%d) errno: (%d) !", SIGBUS, errno); + + return( IMRS_KO); + } + + if( ( rc = sigaction( SIGSEGV, &act, &( IMRG_IMRD_Base.OAct_SegV))) != 0) + { + IMRD_LM_LOG_ERROR_2( "Can't trap signal (%d) errno: (%d) !", SIGSEGV, errno); + + return( IMRS_KO); + } + } + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* main */ +/*----------------------------------------------------------------------------*/ +/* ArgC: Argument number */ +/* ArgV: Argument tab */ +/*----------------------------------------------------------------------------*/ + +int main( int ArgC, char **ArgV) +{ + IMRT_Status status; + NDT_Status nd_status; + int exit_status; + IMRT_Config *config_ptr = &( IMRG_IMRD_Base.Config); + IMRT_Module_Id module_id; + + + if( sigsetjmp( IMRG_Base.SigLongJmp_Env, 1) != 0 ) + { + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_0, "Exiting on signal (%d)...", IMRG_Base.Sig_Trapped); + + ND_Library_StdErr_Set( NULL); + exit_status = 0; + } + else + { + if( ( status = Config_Init( config_ptr, ArgC, ArgV)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't init config !"); + + exit( -1); + } + + if( ( status = Args_Parse( config_ptr, ArgC, ArgV)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't parse args !"); + + exit( -1); + } + + if( ( status = Signal_Init()) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't init signals !"); + + exit( -1); + } + + if( config_ptr->IMRD.Version_Mode == IMRD_TRUE) + { + Version_Print(); + exit( 0); + } + + if( config_ptr->IMRD.Help_Mode == IMRD_TRUE) + { + Help_Print(); + exit( 0); + } + + if( ( status = Lib_Open( &( IMRG_IMRD_Base.Module_Entry_Tab[1]))) != IMRS_OK) + { + exit( -1); + } + + if( ( status = Version_Log()) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't log versions !"); + + exit( -1); + } + + if( ( nd_status = ND_Library_Open( NDD_TRUE)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't open node library (%d) !", nd_status); + + exit( -1); + } + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Node library opened !"); + + if( ( status = Libs_Open( IMRG_IMRD_Base.Module_Entry_Tab, IMRD_MODULE_NB)) != IMRS_OK) + { + exit_status = -1; + } + else + { + if( ( status = Args_Log( config_ptr)) != IMRS_OK) + { + exit_status = -1; + } + else + { + switch( config_ptr->IMRD.Dump_Mode) + { + case IMRD_SDM_FLAG_XML: + { + if( IMR_SDM_XML_Dump() != IMRS_OK) + { + exit_status = -1; + } + else + { + exit_status = 0; + } + + break; + } + + case IMRD_SDM_FLAG_SQL: + { + if( IMR_SDM_SQL_Dump() != IMRS_OK) + { + exit_status = -1; + } + else + { + exit_status = 0; + } + + break; + } + + default: + { + if( ( config_ptr->IMRD.Appl_Id_Input == IMRD_APPL_ID_UNDEFINEDED) && ( IMR_SDM_Appl_Id_Get( &( config_ptr->IMRD.Appl_Id_Input), config_ptr->IMRD.Appl_Name_Input) != IMRS_OK)) + { + IMRD_LM_LOG_ERROR_1( "Can't get Appl_Id from [%s] !", config_ptr->IMRD.Appl_Name_Input); + + exit_status = -1; + } + else + { + if( ( config_ptr->IMRD.Appl_Id_Output == IMRD_APPL_ID_UNDEFINEDED) && ( IMR_SDM_Appl_Id_Get( &( config_ptr->IMRD.Appl_Id_Output), config_ptr->IMRD.Appl_Name_Output) != IMRS_OK)) + { + IMRD_LM_LOG_ERROR_1( "Can't get Appl_Id from [%s] !", config_ptr->IMRD.Appl_Name_Output); + + exit_status = -1; + } + else + { + IMRD_LM_LOG_INFO_2( "Appl_Name_Input: [%s] Appl_Id_Input: (%d)", config_ptr->IMRD.Appl_Name_Input, config_ptr->IMRD.Appl_Id_Input); + IMRD_LM_LOG_INFO_2( "Appl_Name_Output: [%s] Appl_Id_Output: (%d)", config_ptr->IMRD.Appl_Name_Output, config_ptr->IMRD.Appl_Id_Output); + + if( ( status = IMR_MR_Proceed( config_ptr->IMRD.Medium_URL_Output, config_ptr->IMRD.Appl_Id_Output, config_ptr->IMRD.Medium_URL_Trash, config_ptr->IMRD.Medium_URL_Input, config_ptr->IMRD.Appl_Id_Input)) != IMRS_OK) + { + exit_status = -1; + } + else + { + exit_status = 0; + } + } + } + + break; + } + } + } + } + } + + if( ( status = Libs_Close( IMRG_IMRD_Base.Module_Entry_Tab, IMRD_MODULE_NB)) != IMRS_OK) + { + exit_status = -1; + } + + if( ( nd_status = ND_Library_Close()) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't close node library (%d)", nd_status); + + exit_status = -1; + } + else + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Node library closed !"); + } + + if( ( status = Config_Deinit( config_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't deinit config !"); + + exit_status = -1; + } + + exit( exit_status); +} diff --git a/src/imrd/src/imrd.h b/src/imrd/src/imrd.h new file mode 100644 index 0000000..837cdb4 --- /dev/null +++ b/src/imrd/src/imrd.h @@ -0,0 +1,415 @@ +/*----------------------------------------------------------------------------*/ +/* File: imrd.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _IMRD_H_ +#define _IMRD_H_ + + + +#include + + + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Return Status */ +/*----------------------------------------------------------------------------*/ + + + + + +/*----------------------------------------------------------------------------*/ +/* Module Definitions */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_IMRD_MODULE_ID ( IMRT_Module_Id) 6 +#define IMRD_IMRD_MODULE_NAME ( IMRT_Module_Name) "imrd" +#define IMRD_IMRD_MODULE_NAME_LONG ( IMRT_Module_Name_Long) "Interlinking Message Router Daemon" +#define IMRD_IMRD_MODULE_VERSION ( IMRT_Module_Version) "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:22 $ $Workfile: imrd.h $" + +#define IMRD_MODULE_PTR &IMRG_IMRD_Module + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Definitions */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_Module_Entry +{ + IMRT_Module *Module_Ptr; + IMRT_Lib_Status Status; + IMRT_Lib_Config *Config_Ptr; +} IMRT_Module_Entry; + + + +typedef struct IMRT_IMRD_Config +{ + IMRT_Medium_URL Medium_URL_Input, Medium_URL_Output, Medium_URL_Trash; + IMRT_Appl_Name Appl_Name_Input, Appl_Name_Output; + IMRT_Appl_Id Appl_Id_Input, Appl_Id_Output; + IMRT_Boolean Version_Mode, Help_Mode; + IMRT_SDM_Flag Dump_Mode; + IMRT_Boolean Core_Dump; +} IMRT_IMRD_Config; + + + +typedef struct IMRT_Config +{ + IMRT_LM_Config LM; + IMRT_SDM_Config SDM; + IMRT_IOM_Config IOM; + IMRT_MM_Config MM; + IMRT_MR_Config MR; + IMRT_IMRD_Config IMRD; +} IMRT_Config; + + + +#define IMRD_MODULE_NB ( IMRT_Module_Id) 7 + + + +typedef struct IMRT_IMRD_Base +{ +// IMRT_Module_Nb Module_Nb; + IMRT_Module_Entry Module_Entry_Tab[ IMRD_MODULE_NB]; + IMRT_Config Config; + int Sig_Trapped; + sigjmp_buf SigLongJmp_Env; + struct sigaction OAct_Int, OAct_Quit, OAct_Term, OAct_Bus, OAct_SegV; + +} IMRT_IMRD_Base; + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +IMRT_Module IMRG_IMRD_Module = +{ + IMRD_IMRD_MODULE_ID, + IMRD_IMRD_MODULE_NAME, + IMRD_IMRD_MODULE_NAME_LONG, + IMRD_IMRD_MODULE_VERSION, + IMRD_MODULE_TYPE_OBJECT, + { + IMRD_LIB_STATUS_UNKNOWN, + NULL, + NULL + } +}; + + + +IMRT_IMRD_Base IMRG_IMRD_Base = +{ +// IMRD_LIB_NB, + { + { NULL, IMRD_LIB_STATUS_UNKNOWN, NULL}, + { &IMRG_LM_Module, IMRD_LIB_STATUS_CLOSED, (IMRT_Lib_Config *) &( IMRG_IMRD_Base.Config.LM)}, + { &IMRG_SDM_Module, IMRD_LIB_STATUS_CLOSED, (IMRT_Lib_Config *) &( IMRG_IMRD_Base.Config.SDM)}, + { &IMRG_IOM_Module, IMRD_LIB_STATUS_CLOSED, (IMRT_Lib_Config *) &( IMRG_IMRD_Base.Config.IOM)}, + { &IMRG_MM_Module, IMRD_LIB_STATUS_CLOSED, (IMRT_Lib_Config *) &( IMRG_IMRD_Base.Config.MM)}, + { &IMRG_MR_Module, IMRD_LIB_STATUS_CLOSED, (IMRT_Lib_Config *) &( IMRG_IMRD_Base.Config.MR)}, + { &IMRG_IMRD_Module, IMRD_LIB_STATUS_UNKNOWN, (IMRT_Lib_Config *) &( IMRG_IMRD_Base.Config.IMRD)} + }, + { + { "", 0, { 0 } }, + { IMRD_SDM_FLAG_UNKNOWN, ""}, + { NULL}, + { IMRD_FALSE}, + { IMRD_FALSE, IMRD_READ_MODE_WAIT}, + { "", "", "", "", "", 0, 0, IMRD_FALSE, IMRD_FALSE, IMRD_SDM_FLAG_UNKNOWN, IMRD_FALSE} + } +}; + + + +IMRT_Base IMRG_Base = +{ + 0, + {0} +}; + + + +#define IMRD_ARG_NAME_LEN ( short) 63 +#define IMRD_ARG_NAME_SIZE ( short) (IMRD_ARG_NAME_LEN + 1) + +typedef char IMRT_Arg_Name[ IMRD_ARG_NAME_SIZE]; + + + +#define IMRD_ARG_HELP_LEN ( short) 128 +#define IMRD_ARG_HELP_SIZE ( short) 128 + +typedef char IMRT_Arg_Help[ IMRD_ARG_HELP_SIZE]; + + + +typedef short IMRT_ARG_ID; + +#define IMRD_ARG_NB ( IMRT_ARG_ID) 25 + +#define IMRD_ARG_UNKNOWN ( IMRT_ARG_ID) 0 +#define IMRD_ARG_VERSION ( IMRT_ARG_ID) 1 +#define IMRD_ARG_HELP ( IMRT_ARG_ID) 2 +#define IMRD_ARG_VERBOSE_LEVEL_DEFAULT ( IMRT_ARG_ID) 3 +#define IMRD_ARG_VERBOSE_LEVEL_MODULE ( IMRT_ARG_ID) 4 +#define IMRD_ARG_LOG_FILE ( IMRT_ARG_ID) 5 +#define IMRD_ARG_SD_READ_XML ( IMRT_ARG_ID) 6 +#define IMRD_ARG_SD_READ_SQL ( IMRT_ARG_ID) 7 +#define IMRD_ARG_SD_WRITE_XML ( IMRT_ARG_ID) 8 +#define IMRD_ARG_SD_WRITE_SQL ( IMRT_ARG_ID) 9 +#define IMRD_ARG_LIBRARY_DIR ( IMRT_ARG_ID) 10 +#define IMRD_ARG_MEDIUM_URL_INPUT ( IMRT_ARG_ID) 11 +#define IMRD_ARG_MEDIUM_URL_OUTPUT ( IMRT_ARG_ID) 12 +#define IMRD_ARG_MEDIUM_URL_TRASH ( IMRT_ARG_ID) 13 +#define IMRD_ARG_APPL_NAME_INPUT ( IMRT_ARG_ID) 14 +#define IMRD_ARG_APPL_NAME_OUTPUT ( IMRT_ARG_ID) 15 +#define IMRD_ARG_APPL_ID_INPUT ( IMRT_ARG_ID) 16 +#define IMRD_ARG_APPL_ID_OUTPUT ( IMRT_ARG_ID) 17 +#define IMRD_ARG_MAPPING_FORCED ( IMRT_ARG_ID) 18 +#define IMRD_ARG_CONTINUE_FORCED ( IMRT_ARG_ID) 19 +#define IMRD_ARG_NO_WAIT ( IMRT_ARG_ID) 20 +#define IMRD_ARG_XML_FORMAT ( IMRT_ARG_ID) 21 +#define IMRD_ARG_CORE_DUMP ( IMRT_ARG_ID) 22 +#define IMRD_ARG_LOG_ID_INPUT_MSG ( IMRT_ARG_ID) 23 +#define IMRD_ARG_LOG_ID_OUTPUT_MSG ( IMRT_ARG_ID) 24 + + +typedef struct IMRT_Arg +{ + IMRT_Arg_Name Name_Short; + IMRT_Arg_Name Name_Long; + IMRT_Arg_Help Help; +} IMRT_Arg; + + + +IMRT_Arg IMRG_Arg_Tab[ IMRD_ARG_NB] = +{ + { "", "", "Unknown"}, + { "-V", "--version", "Print version"}, + { "-h", "--help", "Print this help"}, + { "-vld", "--verbose_level_default", "Set the genral verbose level"}, + { "-vlm", "--verbose_level_module", "Set the module verbose level"}, + { "-lf", "--log_file", "Set log file"}, +#ifdef ORACLE_SUPPORT + { "-sdrx", "--static_data_read_xml", "Read static data from xml repository"}, + { "-sdrs", "--static_data_read_sql", "Read static data from sql repository"}, + { "-sdwx", "--static_data_write_xml", "Write static data to xml repository"}, + { "-sdws", "--static_data_write_sql", "Write static data to sql repository"}, +#else + { "", "", "None"}, + { "", "", "None"}, + { "", "", "None"}, + { "", "", "None"}, +#endif /* ORACLE_SUPPORT */ + { "-ld", "--library_dir", "Set imr library dir"}, + { "-mui", "--medium_url_input", "Set input medium url"}, + { "-muo", "--medium_url_output", "Set output medium url"}, + { "-mut", "--medium_url_trash", "Set trash medium url"}, + { "-ani", "--appl_name_input", "Set input appl name"}, + { "-ano", "--appl_name_output", "Set output appl name"}, + { "-aii", "--appl_id_input", "Set input appl id"}, + { "-aio", "--appl_id_output", "Set output appl id"}, + { "-mf", "--mapping_forced", "Output bad mapped buffer"}, + { "-cf", "--continue_forced", "Continue on mapping error"}, + { "-nw", "--no_wait", "Don't wait if nothing to read"}, + { "-xf", "--xml_format", "Format xml output buffer"}, + { "-cd", "--core_dump", "Dump core on SIGSEGV and SIGBUS"}, + { "-iim", "--id_input_message", "Log Id input message"}, + { "-iom", "--id_output_message", "Log Id output message"} +}; + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* Config_Init */ +/*----------------------------------------------------------------------------*/ +/* Config_Ptr: Config structure to initialize */ +/* ArgC: Argument number */ +/* ArgV: Argument tab */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Config_Init( IMRT_Config *, int, char **); + + + +/*----------------------------------------------------------------------------*/ +/* Config_Deinit */ +/*----------------------------------------------------------------------------*/ +/* Config_Ptr: Config structure to deinitialize */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Config_Deinit( IMRT_Config *); + + + +/*----------------------------------------------------------------------------*/ +/* Args_Parse */ +/*----------------------------------------------------------------------------*/ +/* Config_Ptr: Configuration structure to update */ +/* ArgC: Argument number */ +/* ArgV: Argument tab */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Args_Parse( IMRT_Config *, int, char **); + + + +/*----------------------------------------------------------------------------*/ +/* Args_Log */ +/*----------------------------------------------------------------------------*/ +/* Config_Ptr: Configuration structure to dump */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Args_Log( IMRT_Config *); + + + +/*----------------------------------------------------------------------------*/ +/* Version_Log */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Version_Log( void); + + + +/*----------------------------------------------------------------------------*/ +/* Version_Print */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Version_Print( void); + + + +/*----------------------------------------------------------------------------*/ +/* Help_Print */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Help_Print( void); + + + +/*----------------------------------------------------------------------------*/ +/* Lib_Open */ +/*----------------------------------------------------------------------------*/ +/* Module_Entry_Ptr: Module to open */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Lib_Open( IMRT_Module_Entry *); + + + +/*----------------------------------------------------------------------------*/ +/* Libs_Open */ +/*----------------------------------------------------------------------------*/ +/* Module_Entry_Tab: Module tab */ +/* Module_Nb: Number of module */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Libs_Open( IMRT_Module_Entry *, IMRT_Module_Id); + + + +/*----------------------------------------------------------------------------*/ +/* Lib_Close */ +/*----------------------------------------------------------------------------*/ +/* Module_Entry_Ptr: Module to close */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Lib_Close( IMRT_Module_Entry *); + + + +/*----------------------------------------------------------------------------*/ +/* Libs_Close */ +/*----------------------------------------------------------------------------*/ +/* Module_Entry_Tab: Module tab */ +/* Module_Nb: Number of module */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Libs_Close( IMRT_Module_Entry *, IMRT_Module_Id); + + + +/*------------------------------------------------------------------------------*/ +/* Signal_Trap */ +/*------------------------------------------------------------------------------*/ + +void Signal_Trap( int); + + + +/*----------------------------------------------------------------------------*/ +/* Signal_Init */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Signal_Init(); + + + +/*----------------------------------------------------------------------------*/ +/* main */ +/*----------------------------------------------------------------------------*/ +/* ArgC: argument number */ +/* ArgV: Argument tab */ +/*----------------------------------------------------------------------------*/ + +int main( int, char **); + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/include/imr.h b/src/include/imr.h new file mode 100644 index 0000000..d62c6c7 --- /dev/null +++ b/src/include/imr.h @@ -0,0 +1,702 @@ +/*----------------------------------------------------------------------------*/ +/* File: imr.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _IMR_H_ +#define _IMR_H_ + + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + + + + + +#define TRACE 1 + + + +/*----------------------------------------------------------------------------*/ +/* Global definitions */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Boolean; + +#define IMRD_FALSE ( IMRT_Boolean) 0 +#define IMRD_TRUE ( IMRT_Boolean) 1 + +#define IMRD_NO 'n' +#define IMRD_YES 'y' + +#define IMRD_MAX(A,B) (((A) < (B)) ? (B) : (A)) +#define IMRD_MIN(A,B) (((A) > (B)) ? (B) : (A)) + + + + + +/*----------------------------------------------------------------------------*/ +/* Status definition */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Status; + +#define IMRS_OK ( IMRT_Status) 0 + +#define IMRS_KO ( IMRT_Status) 1 +#define IMRS_NO_IDENT ( IMRT_Status) -2 +#define IMRS_BAD_FORMAT ( IMRT_Status) -3 +#define IMRS_ROLLBACK ( IMRT_Status) -4 + +#define IMRS_NO_DATA ( IMRT_Status) 3 +#define IMRS_SIGNAL ( IMRT_Status) 4 + + + +/*----------------------------------------------------------------------------*/ +/* Module and Lib definitions */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Module_Id; + +#define IMRD_MODULE_ID_UNKNOWN (IMRT_Module_Id) 0 + +#define IMRD_MODULE_NB_MAX (IMRT_Module_Id) 10 + + + +typedef char *IMRT_Module_Name; + + +typedef char *IMRT_Module_Name_Long; + + + +typedef char *IMRT_Module_Version; + + + +typedef short IMRT_Module_Type; + +#define IMRD_MODULE_TYPE_UNKNOWN ( IMRT_Module_Type) 0 +#define IMRD_MODULE_TYPE_OBJECT ( IMRT_Module_Type) 1 +#define IMRD_MODULE_TYPE_LIBRARY ( IMRT_Module_Type) 2 + + + +typedef short IMRT_Lib_Status; + +#define IMRD_LIB_STATUS_UNKNOWN ( IMRT_Lib_Status) 0 +#define IMRD_LIB_STATUS_CLOSED ( IMRT_Lib_Status) 1 +#define IMRD_LIB_STATUS_OPENED ( IMRT_Lib_Status) 2 +#define IMRD_LIB_STATUS_ERROR ( IMRT_Lib_Status) 3 + + + +typedef struct IMRT_Lib_Config +{ + char *dummy; +} IMRT_Lib_Config; + + + +typedef IMRT_Status ( IMRT_Lib_Open)( IMRT_Lib_Config *); +typedef IMRT_Status ( IMRT_Lib_Close)( void); + + + +typedef struct IMRT_Lib +{ + IMRT_Lib_Status Status; + IMRT_Lib_Open *Open_Ptr; + IMRT_Lib_Close *Close_Ptr; +} IMRT_Lib; + + + +typedef struct IMRT_Module +{ + IMRT_Module_Id Id; + IMRT_Module_Name Name; + IMRT_Module_Name_Long Name_Long; + IMRT_Module_Version Version; + IMRT_Module_Type Type; + IMRT_Lib Lib; +} IMRT_Module; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Path definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_PATH_LEN ( short) 255 +#define IMRD_PATH_SIZE ( short) ( IMRD_PATH_LEN + 1) + +typedef char IMRT_Path[ IMRD_PATH_SIZE]; + +typedef short IMRT_Lib_Flag; +#define IRMD_LIB_FLAG_SDM_XML (IMRT_Lib_Flag)0 +#define IRMD_LIB_FLAG_SDM_SQL (IMRT_Lib_Flag)1 + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Tag definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_TAG_LEN ( short) 100 +#define IMRD_TAG_SIZE ( short) ( IMRD_TAG_LEN + 1) + +typedef char IMRT_Tag[ IMRD_TAG_SIZE]; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Cnv_Id definition */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Cnv_Id; + +#define IMRD_CNV_ID_UNKNOWN ( IMRT_Cnv_Id) 0 + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Cnv_Name definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_CNV_NAME_LEN ( short) 65 +#define IMRD_CNV_NAME_SIZE ( short) ( IMRD_CNV_NAME_LEN + 1) + +typedef char IMRT_Cnv_Name[ IMRD_CNV_NAME_SIZE]; + +#define IMRD_CNV_NAME_UNKNOWN "Unknown" + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Cnv_Attr definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_CNV_ATTR_LEN ( short) 20 +#define IMRD_CNV_ATTR_SIZE ( short) ( IMRD_CNV_ATTR_LEN + 1) + +typedef char IMRT_Cnv_Attr[ IMRD_CNV_ATTR_SIZE]; + +#define IMRD_CNV_ATTR_UNKNOWN "UNKNOWN" + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Cnv definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_Cnv +{ + IMRT_Cnv_Id Id; + IMRT_Cnv_Name Name; +} IMRT_Cnv; + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Field definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_FIXED_SIZE_UNKNOWN ( size_t) -1 + + + +#define IMRD_NAME_LEN ( short) 255 +#define IMRD_NAME_SIZE ( short) ( IMRD_NAME_LEN + 1) + +typedef char IMRT_Field_Name[ IMRD_NAME_SIZE]; + + + +#define IMRD_VALUE_ID_LEN ( short) 20 +#define IMRD_VALUE_ID_SIZE ( short) ( IMRD_VALUE_ID_LEN + 1) + +typedef char IMRT_Field_Value_Id[ IMRD_VALUE_ID_SIZE]; + + +#define IMRD_EXIST_LEN ( short) 1 +#define IMRD_EXIST_SIZE ( short) ( IMRD_EXIST_LEN + 1) + +typedef char IMRT_Field_Exist[ IMRD_EXIST_SIZE]; + + +#define IMRD_VALUE_LEN ( short) 150 +#define IMRD_VALUE_SIZE ( short) ( IMRD_VALUE_LEN + 1) + +typedef char IMRT_Value[ IMRD_VALUE_SIZE]; + + + +typedef struct IMRT_Field_Fixed +{ + size_t Offset; + size_t Size; + IMRT_Value Def_Val; + IMRT_Cnv *Cnv_Ptr; + IMRT_Cnv_Attr Cnv_Attr; +} IMRT_Field_Fixed; + + + +#define IMRD_FML_TAG_LEN ( short) 50 +#define IMRD_FML_TAG_SIZE ( short) ( IMRD_FML_TAG_LEN + 1) + +typedef char IMRT_FML_Tag[ IMRD_FML_TAG_SIZE]; + + +#define IMRD_FML_TAG_UNKNOWN "" + + + + + +typedef struct IMRT_Field_FML +{ + IMRT_FML_Tag Tag; + IMRT_Value Def_Val; + IMRT_Cnv *Cnv_Ptr; + IMRT_Cnv_Attr Cnv_Attr; +} IMRT_Field_FML; + + + +#define IMRD_XML_TAG_LEN ( short) 150 +#define IMRD_XML_TAG_SIZE ( short) ( IMRD_XML_TAG_LEN + 1) + +typedef char IMRT_XML_Tag[ IMRD_XML_TAG_SIZE]; + +#define IMRD_XML_TAG_UNKNOWN "" + + + +typedef struct IMRT_Field_XML +{ + IMRT_XML_Tag Tag; + IMRT_Value Def_Val; + IMRT_Cnv *Cnv_Ptr; + IMRT_Cnv_Attr Cnv_Attr; +} IMRT_Field_XML; + + + +#define IMRD_TAGGED_TAG_LEN ( short) 20 +#define IMRD_TAGGED_TAG_SIZE ( short) ( IMRD_TAGGED_TAG_LEN + 1) + +typedef char IMRT_Tagged_Tag[ IMRD_TAGGED_TAG_SIZE]; + +#define IMRD_TAGGED_TAG_UNKNOWN "" + + + + +typedef struct IMRT_Field_Tagged +{ + IMRT_Tagged_Tag Tag; + IMRT_Value Def_Val; + IMRT_Cnv *Cnv_Ptr; + IMRT_Cnv_Attr Cnv_Attr; +} IMRT_Field_Tagged; + + + +#define IMRD_INTERNAL_TAG_LEN ( short) 20 +#define IMRD_INTERNAL_TAG_SIZE ( short) ( IMRD_INTERNAL_TAG_LEN + 1) + +typedef char IMRT_Internal_Tag[ IMRD_INTERNAL_TAG_SIZE]; + +#define IMRD_INTERNAL_TAG_UNKNOWN "" + + + + +typedef struct IMRT_Field_Internal +{ + IMRT_Internal_Tag Tag; + IMRT_Value Def_Val; + IMRT_Cnv *Cnv_Ptr; + IMRT_Cnv_Attr Cnv_Attr; +} IMRT_Field_Internal; + + + + +typedef short IMRT_Delimited_Id; + +#define IMRD_DELIMITED_ID_UNKNOWN ( IMRT_Delimited_Id) -1 + + + +typedef struct IMRT_Field_Delimited +{ + IMRT_Delimited_Id Id; + IMRT_Value Def_Val; + IMRT_Cnv *Cnv_Ptr; + IMRT_Cnv_Attr Cnv_Attr; +} IMRT_Field_Delimited; + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Field_Id definition */ +/*----------------------------------------------------------------------------*/ + +typedef int IMRT_Field_Id; + +#define IMRD_FIELD_ID_UNKNOWN ( IMRT_Field_Id) 0 + + + +typedef struct IMRT_Field +{ + IMRT_Field_Id Id; + IMRT_Field_Name Name; + IMRT_Field_Value_Id Value_Id; + IMRT_Boolean Exist; + IMRT_Field_Fixed Fixed; + IMRT_Field_FML FML; + IMRT_Field_XML XML; + IMRT_Field_Tagged Tagged; + IMRT_Field_Internal Internal; + IMRT_Field_Delimited Delimited; +} IMRT_Field; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_FieldMap_Id definition */ +/*----------------------------------------------------------------------------*/ + +typedef int IMRT_FieldMap_Id; + +#define IMRD_FIELDMAP_ID_UNKNOWN ( IMRT_FieldMap_Id) 0 + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_FieldMap definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_FieldMap +{ + IMRT_FieldMap_Id Id; + IMRT_Field *Field_Input_Ptr; + IMRT_Field *Field_Output_Ptr; +} IMRT_FieldMap; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Msg definition */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Msg_Id; + +#define IMRD_MSG_ID_UNKNOWN ( IMRT_Msg_Id ) 0 + + + +typedef char IMRT_Msg_Name[ IMRD_NAME_SIZE]; + +#define IMRD_MSG_NAME_UNKNOWN "UNKNOWN" + + + +typedef struct IMRT_Msg +{ + IMRT_Msg_Id Id; + IMRT_Msg_Name Name; + size_t Size; + NDT_Root *Field_Struct_Ptr; +} IMRT_Msg; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Fmt definition */ +/*----------------------------------------------------------------------------*/ + + + +/* #define IMRT_LG_MESSAGE_TYPE 60 */ + + + +typedef int IMRT_Fmt_Id; + +#define IMRD_FMT_ID_UNKNOWN ( IMRT_Fmt_Id) 0 + + + +#define IMRD_FMT_NAME_LEN ( short) 20 +#define IMRD_FMT_NAME_SIZE ( short) ( IMRD_FMT_NAME_LEN + 1) + +typedef char IMRT_Fmt_Name[ IMRD_FMT_NAME_SIZE]; + +#define IMRD_FMT_NAME_UNKNOWN "Unknown" + + + + +typedef short IMRT_Branche_Id; + +#define IMRD_BRANCHE_ID_UNKNOWN ( IMRT_Branche_Id ) 0 + + + +typedef short IMRT_FmtAttr_Id; + +#define IMRD_FMTATTR_ID_UNKNOWN ( IMRT_FmtAttr_Id) 0 + + + +#define IMRD_FMTATTR_NAME_LEN ( short) 65 +#define IMRD_FMTATTR_NAME_SIZE ( short) ( IMRD_FMTATTR_NAME_LEN + 1) + +typedef char IMRT_FmtAttr_Name[ IMRD_FMTATTR_NAME_SIZE]; + +#define IMRD_FMTATTR_NAME_UNKNOWN "unknown" + + + + +#define IMRD_FMTATTR_VALUE_LEN ( short) 20 +#define IMRD_FMTATTR_VALUE_SIZE ( short) ( IMRD_FMTATTR_VALUE_LEN + 1) + +typedef char IMRT_FmtAttr_Value[ IMRD_FMTATTR_VALUE_SIZE]; + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_FmtAttr definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_FmtAttr +{ + IMRT_FmtAttr_Id Id; + IMRT_FmtAttr_Name Name; + IMRT_FmtAttr_Value Value; +} IMRT_FmtAttr; + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_FmtMsg definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_FmtMsg +{ + IMRT_Msg *Msg_Ptr; + IMRT_Branche_Id Branche_Id; + IMRT_FmtAttr *FmtAttr_Ptr; +} IMRT_FmtMsg; + + + + +typedef struct IMRT_Fmt +{ + IMRT_Fmt_Id Id; + IMRT_Fmt_Name Name; + NDT_Root *FmtMsg_Struct_Ptr; +} IMRT_Fmt; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Appl_Id definition */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Appl_Id; + +#define IMRD_APPL_ID_UNKNOWN ( IMRT_Appl_Id) 0 + +#define IMRD_APPL_ID_UNDEFINEDED ( IMRT_Appl_Id) -1 + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Appl_Name definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_APPL_NAME_LEN ( short) 30 +#define IMRD_APPL_NAME_SIZE ( short) ( IMRD_APPL_NAME_LEN + 1) + +typedef char IMRT_Appl_Name[ IMRD_APPL_NAME_SIZE]; + +#define IMRD_APPL_NAME_UNKNOWN "UNKNOWN" + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Buffer definition */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Dir_Id; + +#define IMRD_DIR_ID_UNKNOWN ( IMRT_Dir_Id) 0 +#define IMRD_DIR_ID_IN ( IMRT_Dir_Id) 1 +#define IMRD_DIR_ID_OUT ( IMRT_Dir_Id) 2 + + + +typedef short IMRT_Buffer_Status; + +#define IMRD_BUFFER_STATUS_UNKNOWN ( IMRT_Buffer_Status) 0 +#define IMRD_BUFFER_STATUS_ALLOCATED ( IMRT_Buffer_Status) 1 +#define IMRD_BUFFER_STATUS_FREED ( IMRT_Buffer_Status) 2 + + + +typedef short IMRT_Buffer_Flag; + +#define IMRD_BUFFER_FLAG_UNKNOWN ( IMRT_Buffer_Flag) 0 +#define IMRD_BUFFER_FLAG_OPENED ( IMRT_Buffer_Flag) 1 +#define IMRD_BUFFER_FLAG_CLOSED ( IMRT_Buffer_Flag) 2 + + + +typedef char IMRT_Buffer_Data; + + + +typedef struct IMRT_Buffer +{ + IMRT_Msg_Id Msg_Id; + IMRT_Appl_Id Appl_Id_Input; + IMRT_Appl_Id Appl_Id_Output; + IMRT_Dir_Id Dir_Id; + IMRT_Fmt_Id Fmt_Id; + IMRT_FmtAttr_Value FmtAttr_Value; + IMRT_Buffer_Status Status; + IMRT_Buffer_Flag Flag; + size_t Data_Buf_Len; + size_t Data_Buf_Size; + IMRT_Buffer_Data *Data_Buf_Ptr; + IMRT_Boolean Data_Tmp_Changed; + IMRT_Buffer_Data *Data_Tmp_Ptr; +} IMRT_Buffer; + + + +typedef short IMRT_Buffer_Id; + +#define IMRT_BUFFER_ID_MAX_NB ( IMRT_Buffer_Id) 50 + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_IOM_Read_Mode definition */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Read_Mode; + +#define IMRD_READ_MODE_UNKNOWN ( IMRT_Read_Mode) 0 +#define IMRD_READ_MODE_WAIT ( IMRT_Read_Mode) 1 +#define IMRD_READ_MODE_NO_WAIT ( IMRT_Read_Mode) 2 + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Base */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_Base +{ + int Sig_Trapped; + sigjmp_buf SigLongJmp_Env; +} IMRT_Base; + + + +# ifdef _IMRD_C_ + +# else + +extern IMRT_Base IMRG_Base; + +# endif + + + + +/*----------------------------------------------------------------------------*/ +/* IMR libraries */ +/*----------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include + +#endif diff --git a/src/libio_mng/include/io_mng.h b/src/libio_mng/include/io_mng.h new file mode 100644 index 0000000..8f0441e --- /dev/null +++ b/src/libio_mng/include/io_mng.h @@ -0,0 +1,459 @@ +/*----------------------------------------------------------------------------*/ +/* $Workfile: io_mng.h $ */ +/*----------------------------------------------------------------------------*/ +/* $Author: agibert $ */ +/* $Date: 2008/11/12 02:25:22 $ */ +/* $Revision: 1.1 $ */ +/* $Label: $ */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _IO_MNG_H_ +#define _IO_MNG_H_ + + + +#include + +#ifdef TUX_SUPPORT +# include +# include +# include +#endif + +#ifdef MQS_SUPPORT +# include +#endif + + + + +/*----------------------------------------------------------------------------*/ +/* IMRD_IOM_API definition */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBIO_MNG_ +# define IMRD_IOM_API +# else +# define IMRD_IOM_API extern +# endif + + + + + +/*----------------------------------------------------------------------------*/ +/* IOM_Config definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_IOM_Config +{ + char *dummy; + +} IMRT_IOM_Config; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_File_Delim definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_FILE_DELIM_LEN (short) 32 +#define IMRD_FILE_DELIM_SIZE (short) ( IMRD_FILE_DELIM_LEN + 1) + +typedef char IMRT_File_Delim[ IMRD_FILE_DELIM_SIZE]; + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_File_Buffer definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_FILE_BUFFER_LEN (size_t) 4096 +#define IMRD_FILE_BUFFER_SIZE (size_t) ( IMRD_FILE_BUFFER_LEN + 1) + +typedef char IMRT_File_Buffer; + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium_File definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_Medium_File +{ + IMRT_File_Delim Delim; + size_t Delim_Len; + size_t Msg_Len; + IMRT_Path Path; + FILE *Handle_Ptr; + IMRT_File_Buffer *Buffer_Ptr; + size_t Buffer_Len; + IMRT_File_Buffer *Cur_Ptr; + +} IMRT_Medium_File; + + + +#ifdef TUX_SUPPORT +/*----------------------------------------------------------------------------*/ +/* IMRT_Tux_Queue_Name definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_TUX_QUEUE_NAME_LEN ( short) 255 +#define IMRD_TUX_QUEUE_NAME_SIZE ( short) ( IMRD_TUX_QUEUE_NAME_LEN + 1) + +typedef char IMRT_Tux_Queue_Name[ IMRD_TUX_QUEUE_NAME_SIZE]; + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Tux_Queue_Space definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_TUX_QUEUE_SPACE_LEN ( short) 255 +#define IMRD_TUX_QUEUE_SPACE_SIZE ( short) ( IMRD_TUX_QUEUE_SPACE_LEN + 1) + +typedef char IMRT_Tux_Queue_Space[ IMRD_TUX_QUEUE_SPACE_SIZE]; + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Tux_Open_Info definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_TUX_OPEN_INFO_LEN ( short) 255 +#define IMRD_TUX_OPEN_INFO_SIZE ( short) ( IMRD_TUX_OPEN_INFO_LEN + 1) + +typedef char IMRT_Tux_Open_Info[ IMRD_TUX_OPEN_INFO_SIZE]; + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Tux_Lmid definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_TUX_LMID_LEN ( short) 255 +#define IMRD_TUX_LMID_SIZE ( short) ( IMRD_TUX_LMID_LEN + 1) + +typedef char IMRT_Tux_Lmid[ IMRD_TUX_LMID_SIZE]; + + + +#define IMRD_TUX_BUFFER_SIZE ( size_t) 10000 + +typedef FBFR32 IMRT_Tux_Buffer; + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium_Tux definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_Medium_Tux +{ + IMRT_Tux_Queue_Space Queue_Space; + IMRT_Tux_Queue_Name Queue_Name; + +} IMRT_Medium_Tux; +#endif /* MQS_SUPPORT */ + + + +#ifdef MQS_SUPPORT +/*----------------------------------------------------------------------------*/ +/* IMRT_MQS_Queue_Manager definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_MQS_QUEUE_MNG_LEN ( short) 255 +#define IMRD_MQS_QUEUE_MNG_SIZE ( short) ( IMRD_MQS_QUEUE_MNG_LEN + 1) + +typedef char IMRT_MQS_Queue_Mng[ IMRD_MQS_QUEUE_MNG_SIZE]; + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_MQS_Queue_Name definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_MQS_QUEUE_NAME_LEN ( short) 255 +#define IMRD_MQS_QUEUE_NAME_SIZE ( short) ( IMRD_MQS_QUEUE_NAME_LEN + 1) + +typedef char IMRT_MQS_Queue_Name[ IMRD_MQS_QUEUE_NAME_SIZE]; + + + + +#define IMRD_MQS_BUFFER_LEN (size_t) 4096 +#define IMRD_MQS_BUFFER_SIZE (size_t) ( IMRD_MQS_BUFFER_LEN + 1) + +typedef MQBYTE IMRT_MQS_Buffer; + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Mediul_MQS definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_Medium_MQS +{ + IMRT_MQS_Queue_Mng Queue_Mng; + IMRT_MQS_Queue_Name Queue_Name; + MQHCONN Conn_Hdl; + MQHOBJ Obj_Hdl; + +} IMRT_Medium_MQS; +#endif /* MQS_SUPPORT */ + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium definitions */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_MEDIUM_NAME_LEN ( short) 64 +#define IMRD_MEDIUM_NAME_SIZE ( short) ( IMRD_MEDIUM_NAME_LEN + 1) + +typedef char IMRT_Medium_Name[ IMRD_MEDIUM_NAME_SIZE]; + + + +typedef short IMRT_Medium_Type; + +#define IMRD_MEDIUM_TYPE_UNKNOWN ( IMRT_Medium_Type) 0 +#define IMRD_MEDIUM_TYPE_FILE ( IMRT_Medium_Type) 1 + +#ifdef MQS_SUPPORT +# define IMRD_MEDIUM_TYPE_TUX ( IMRT_Medium_Type) 2 +#endif /* TUX_SUPPORT */ + +#ifdef MQS_SUPPORT +# define IMRD_MEDIUM_TYPE_MQS ( IMRT_Medium_Type) 3 +#endif /* MQS_SUPPORT */ + + + +typedef short IMRT_Medium_Status; + +#define IMRD_MEDIUM_STATUS_UNKNOWN ( IMRT_Medium_Status) 0 +#define IMRD_MEDIUM_STATUS_OPENED ( IMRT_Medium_Status) 1 +#define IMRD_MEDIUM_STATUS_CLOSED ( IMRT_Medium_Status) 2 + + + +#define IMRD_MEDIUM_URL_LEN ( short) 255 +#define IMRD_MEDIUM_URL_SIZE ( short) ( IMRD_MEDIUM_URL_LEN + 1) + +typedef char IMRT_Medium_URL[ IMRD_MEDIUM_URL_SIZE]; + + + +#define IMRD_MEDIUM_PATH_LEN ( short) 255 +#define IMRD_MEDIUM_PATH_SIZE ( short) ( IMRD_MEDIUM_PATH_LEN + 1) + +typedef char IMRT_Medium_Path[ IMRD_MEDIUM_PATH_SIZE]; + +typedef short IMRT_Medium_Tran_Flag; + +#define IMRD_MEDIUM_TRAN_FLAG_UNKNOWN ( IMRT_Medium_Tran_Flag) 0 +#define IMRD_MEDIUM_TRAN_FLAG_IN ( IMRT_Medium_Tran_Flag) 1 +#define IMRD_MEDIUM_TRAN_FLAG_OUT ( IMRT_Medium_Tran_Flag) 2 + + +typedef struct IMRT_Medium +{ + IMRT_Medium_Name Name; + IMRT_Medium_Type Type; + IMRT_Medium_Status Status; + IMRT_Medium_URL URL; + IMRT_Appl_Id Appl_Id_Input; + IMRT_Appl_Id Appl_Id_Output; + IMRT_Dir_Id Dir_Id; + IMRT_Medium_Tran_Flag Tran_Flag; + size_t Byte_Nb; + size_t Msg_Nb; + + IMRT_Medium_File File; + +#ifdef TUX_SUPPORT + IMRT_Medium_Tux Tux; +#endif /* TUX_SUPPORT */ + +#ifdef MQS_SUPPORT + IMRT_Medium_MQS MQS; +#endif /* MQS_SUPPORT */ + +} IMRT_Medium; + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Tran definitions */ +/*----------------------------------------------------------------------------*/ + +typedef int IMRT_Medium_Nb; + +typedef struct IMRT_Tran +{ + IMRT_Medium **Medium_Ptr_Tab; + IMRT_Medium_Nb Medium_Nb; + +} IMRT_Tran; + + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBIO_MNG_ + +# else + +extern IMRT_Module IMRG_IOM_Module; + +# endif + + + + + + + +/******************************************************************************/ +/*IO Manager API */ +/******************************************************************************/ + + + +/*----------------------------------------------------------------------------*/ +/* Open IO Manager */ +/*----------------------------------------------------------------------------*/ +/* IOM_Config_Ptr: Setup IOM init mode */ +/*----------------------------------------------------------------------------*/ + +IMRD_IOM_API IMRT_Status IMR_IOM_Library_Open( IMRT_IOM_Config *); + + + +/*----------------------------------------------------------------------------*/ +/* Close IO Manager */ +/*----------------------------------------------------------------------------*/ + +IMRD_IOM_API IMRT_Status IMR_IOM_Library_Close( void); + + + +/*----------------------------------------------------------------------------*/ +/* Open Medium */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr_Ptr: Reference to the Pointer to the opened medium */ +/* Medium_Name: Name of the medium */ +/* Medium_URL: Medium URL to open */ +/* Appl_Id_Input: Input application Id link with the medium */ +/* Appl_Id_Output: Output application Id link with the medium */ +/* Dir_Id: Medium open direction */ +/*----------------------------------------------------------------------------*/ + +IMRD_IOM_API IMRT_Status IMR_IOM_Medium_Open( IMRT_Medium **, IMRT_Medium_Name, IMRT_Medium_URL, IMRT_Appl_Id, IMRT_Appl_Id, IMRT_Dir_Id); + + + +/*----------------------------------------------------------------------------*/ +/* Close Medium */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to close */ +/*----------------------------------------------------------------------------*/ + +IMRD_IOM_API IMRT_Status IMR_IOM_Medium_Close( IMRT_Medium *); + + + +/*----------------------------------------------------------------------------*/ +/* Read Medium */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Ptr: Pointer to the buffer to write */ +/* Medium_Ptr: Pointer to the medium to read */ +/* Read_Mode: Read mode */ +/*----------------------------------------------------------------------------*/ + +IMRD_IOM_API IMRT_Status IMR_IOM_Medium_Read( IMRT_Buffer *, IMRT_Medium *, IMRT_Read_Mode); + + + +/*----------------------------------------------------------------------------*/ +/* Write Medium */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to write */ +/* Buffer_Ptr: Pointer to the buffer to read */ +/*----------------------------------------------------------------------------*/ + +IMRD_IOM_API IMRT_Status IMR_IOM_Medium_Write( IMRT_Medium *, IMRT_Buffer *); + + + +/*----------------------------------------------------------------------------*/ +/* Tran Begin */ +/*----------------------------------------------------------------------------*/ +/* Tran_Ptr_Ptr: Reference to the pointer of the transaction to begin */ +/* Medium_Count: Number of medium to enclose into the transaction */ +/* Medium_1_Ptr: Pointer to the first medium */ +/* ... */ +/*----------------------------------------------------------------------------*/ + +IMRD_IOM_API IMRT_Status IMR_IOM_Tran_Begin( IMRT_Tran **, IMRT_Medium_Nb, IMRT_Medium *, ...); + + + +/*----------------------------------------------------------------------------*/ +/* Tran Commit */ +/*----------------------------------------------------------------------------*/ +/* Tran_Ptr: Pointer to the transaction to commit */ +/*----------------------------------------------------------------------------*/ + +IMRD_IOM_API IMRT_Status IMR_IOM_Tran_Commit( IMRT_Tran *); + + + +/*----------------------------------------------------------------------------*/ +/* Tran Rollback */ +/*----------------------------------------------------------------------------*/ +/* Tran_Ptr: Pointer to the transaction to rollback */ +/*----------------------------------------------------------------------------*/ + +IMRD_IOM_API IMRT_Status IMR_IOM_Tran_Rollback( IMRT_Tran *); + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libio_mng/src/Makefile b/src/libio_mng/src/Makefile new file mode 100644 index 0000000..2f00a10 --- /dev/null +++ b/src/libio_mng/src/Makefile @@ -0,0 +1,74 @@ +#------------------------------------------------------------------------------ +# Local Makefile +#------------------------------------------------------------------------------ +# $Workfile: Makefile $ +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:22 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Var include +#------------------------------------------------------------------------------ + +include ../../Makefile_var.mk + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +TARGET= libio_mng$(SHLIB_SUFFIX) + +OBJ= libio_mng.o \ + io_hdl_file.o + +ifeq ($(TUX_SUPPORT),1) + OBJ+= io_hdl_tux.o +endif + +ifeq ($(MQS_SUPPORT),1) + OBJ+= io_hdl_mqs.o +endif + +EXTRA_INC= + +EXTRA_LIB= + + + +#------------------------------------------------------------------------------ +# Rule include +#------------------------------------------------------------------------------ + +include ../../Makefile_rule.mk diff --git a/src/libio_mng/src/io_hdl_file.c b/src/libio_mng/src/io_hdl_file.c new file mode 100644 index 0000000..cd15384 --- /dev/null +++ b/src/libio_mng/src/io_hdl_file.c @@ -0,0 +1,541 @@ +/*----------------------------------------------------------------------------*/ +/* File: io_hdl_file.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBIO_MNG_ +#define _IO_HDL_FILE_C_ + + + +#include "io_hdl_file.h" + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Open */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to open */ +/* Medium_Path: Medium Path to open */ +/* Dir_Id: Medium open direction */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_File_Open( IMRT_Medium *Medium_Ptr, IMRT_Medium_Path Medium_Path, IMRT_Dir_Id Dir_Id) +{ + char *type_ptr, *path_ptr, *read_ptr, *write_ptr; + + + if( Dir_Id == IMRD_DIR_ID_IN) + { + type_ptr = "r"; + } + else + { + if( Dir_Id == IMRD_DIR_ID_OUT) + { + type_ptr = "w"; + } + else + { + IMRD_LM_LOG_ERROR_1( "Invalid Dir_Id (%d) !", Dir_Id); + + return( IMRS_KO); + } + } + + if( ( path_ptr = strstr( Medium_Path, "@")) != NULL) + { + if( ( path_ptr == Medium_Path) || ( ( path_ptr - Medium_Path + 1) == strlen( Medium_Path))) + { + IMRD_LM_LOG_ERROR_1( "Invalid file path [%s] !", Medium_Path); + + return( IMRS_KO); + } + + for( read_ptr = Medium_Path, write_ptr = Medium_Ptr->File.Delim; read_ptr < path_ptr; read_ptr++, write_ptr++) + { + if( ( *read_ptr == '\\') && ( read_ptr < ( path_ptr - 1))) + { + switch( *( read_ptr + 1)) + { + case 'n': + { + *write_ptr = '\n'; + break; + } + + case 't': + { + *write_ptr = '\t'; + break; + } + + case '\\': + { + *write_ptr = '\n'; + break; + } + + default: + { + *write_ptr = '?'; + break; + } + } + + read_ptr++; + } + else + { + *write_ptr = *read_ptr; + } + } + + *write_ptr = '\0'; + + Medium_Ptr->File.Delim_Len = write_ptr - Medium_Ptr->File.Delim; + Medium_Ptr->File.Msg_Len = 0; + + strcpy( Medium_Ptr->File.Path, ( path_ptr + 1)); + } + else + { + if( ( path_ptr = strstr( Medium_Path, "#")) != NULL) + { + if( ( path_ptr == Medium_Path) || ( ( path_ptr - Medium_Path + 1) == strlen( Medium_Path))) + { + IMRD_LM_LOG_ERROR_1( "Invalid file path [%s] !", Medium_Path); + + return( IMRS_KO); + } + + Medium_Ptr->File.Delim_Len = 0; + Medium_Ptr->File.Delim[ Medium_Ptr->File.Delim_Len] = '\0'; + + Medium_Ptr->File.Msg_Len = atoi( Medium_Path); + + if( Medium_Ptr->File.Msg_Len <= 0) + { + IMRD_LM_LOG_ERROR_1( "Invalid message len [%s] !", Medium_Path); + + return( IMRS_KO); + } + + strcpy( Medium_Ptr->File.Path, ( path_ptr + 1)); + } + else + { + Medium_Ptr->File.Delim_Len = 0; + Medium_Ptr->File.Delim[ Medium_Ptr->File.Delim_Len] = '\0'; + + Medium_Ptr->File.Msg_Len = 0; + + strcpy( Medium_Ptr->File.Path, Medium_Path); + } + } + + if( ( Medium_Ptr->File.Handle_Ptr = fopen( Medium_Ptr->File.Path, type_ptr)) == NULL) + { + IMRD_LM_LOG_ERROR_2( "Can't open file [%s] (%d) !", Medium_Ptr->File.Path, errno); + + return( IMRS_KO); + } + + if( ( Medium_Ptr->File.Buffer_Ptr = malloc( IMRD_FILE_BUFFER_SIZE)) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate File_Buffer (%d) !", errno); + + return( IMRS_KO); + } + + Medium_Ptr->File.Buffer_Len = 0; + Medium_Ptr->File.Cur_Ptr = Medium_Ptr->File.Buffer_Ptr + IMRD_FILE_BUFFER_LEN; + + IMRD_LM_LOG_TRACE_4( IMRD_LOG_LEVEL_VERBOSE_1, "File: [%s] mode: [%s] delim: [%s] len: [%ld] opened !", Medium_Ptr->File.Path, type_ptr, Medium_Ptr->File.Delim, Medium_Ptr->File.Msg_Len); + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Close */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to close */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_File_Close( IMRT_Medium *Medium_Ptr) +{ + if( Medium_Ptr->File.Buffer_Ptr != NULL) + { + free( Medium_Ptr->File.Buffer_Ptr); + } + + if( fclose( Medium_Ptr->File.Handle_Ptr) == EOF) + { + IMRD_LM_LOG_ERROR_2( "Can't close file [%s] (%d) !", Medium_Ptr->File.Path, errno); + + return( IMRS_KO); + } + + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_1, "File: [%s] closed !", Medium_Ptr->File.Path); + + return( IMRS_OK); +} + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Mem_Str */ +/*----------------------------------------------------------------------------*/ +/* Occur_Ptr_Ptr: Pointer to the first occurrence */ +/* Area_Ptr: Memory Area */ +/* Area_Size: Size of the Area_Ptr */ +/* Search_Ptr: Area to search in Area_Ptr */ +/* Search_Size: Size of the Search_Ptr */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_File_Mem_Str( char **Occur_Ptr_Ptr, const char *Area_Ptr, size_t Area_Size, const char *Search_Ptr, size_t Search_Size) +{ + + char * Pos = (char *)Area_Ptr; + + *Occur_Ptr_Ptr = NULL; + + while((Pos != NULL) && (*Occur_Ptr_Ptr == NULL)) + { + Pos = memchr(Pos, Search_Ptr[0], Area_Size - (Pos - Area_Ptr)); + if ((Area_Size - (Pos - Area_Ptr)) < Search_Size) + { + Pos = NULL; + } + else + { + if (Pos != NULL) + { + if (memcmp(Pos, Search_Ptr, Search_Size) == 0) + { + *Occur_Ptr_Ptr = Pos; + } + else + { + Pos += 1; + } + } + } + } + + return( IMRS_OK); +} + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Read */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Ptr: Buffer to write data in */ +/* Read_Len_Ptr: Number of byte readen */ +/* Medium_Path: Medium to read */ +/* Read_Mode: Read mode */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_File_Read( IMRT_Buffer *Buffer_Ptr, size_t *Read_Len_Ptr, IMRT_Medium *Medium_Ptr, IMRT_Read_Mode Read_Mode) +{ + IMRT_Buffer_Data *next_ptr; + IMRT_Buffer_Data *delim_ptr; + IMRT_Buffer_Data *buffer_data_ptr = NULL; + size_t buffer_data_size = 1; + size_t copy_data_size = 0; + size_t read_buffer_len = IMRD_FILE_BUFFER_LEN - Medium_Ptr->File.Delim_Len; + IMRT_Status status_tmp; + + *Read_Len_Ptr = 0; + + if( Medium_Ptr->File.Msg_Len > 0) /* Msg_Len split mode */ + { + do + { + if( Medium_Ptr->File.Cur_Ptr >= ( Medium_Ptr->File.Buffer_Ptr + Medium_Ptr->File.Buffer_Len)) /* File needs to be read */ + { + Medium_Ptr->File.Cur_Ptr = Medium_Ptr->File.Buffer_Ptr; + + Medium_Ptr->File.Buffer_Len = fread( Medium_Ptr->File.Buffer_Ptr, sizeof( char), IMRD_FILE_BUFFER_LEN, Medium_Ptr->File.Handle_Ptr); + + if( ferror( Medium_Ptr->File.Handle_Ptr) != 0) + { + IMRD_LM_LOG_ERROR_2( "Can't read file [%s] (%d) !", Medium_Ptr->File.Path, ferror( Medium_Ptr->File.Handle_Ptr)); + + return( IMRS_KO); + } + } + + copy_data_size = IMRD_MIN( ( Medium_Ptr->File.Buffer_Len - ( Medium_Ptr->File.Cur_Ptr - Medium_Ptr->File.Buffer_Ptr)), + ( Medium_Ptr->File.Msg_Len - buffer_data_size + 1)); + + if( copy_data_size != 0) + { + if( ( buffer_data_ptr = realloc( buffer_data_ptr, ( buffer_data_size + copy_data_size))) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate Buffer_Data (%d) !", errno); + + return( IMRS_KO); + } + + memcpy( ( buffer_data_ptr + buffer_data_size - 1), Medium_Ptr->File.Cur_Ptr, copy_data_size); /* Copy data from read buffer to copy buffer */ + buffer_data_size += copy_data_size; + + Medium_Ptr->File.Cur_Ptr += copy_data_size; + } + } + while( ( buffer_data_size < Medium_Ptr->File.Msg_Len) && ( Medium_Ptr->File.Buffer_Len > 0)); + } + else /* Delimitor split mode */ + { + do + { + if( Medium_Ptr->File.Cur_Ptr >= ( Medium_Ptr->File.Buffer_Ptr + read_buffer_len)) /* File needs to be read */ + { + if( Medium_Ptr->File.Cur_Ptr < ( Medium_Ptr->File.Buffer_Ptr + IMRD_FILE_BUFFER_LEN)) /* Footer needs to be moved to header */ + { + Medium_Ptr->File.Buffer_Len += Medium_Ptr->File.Buffer_Ptr - Medium_Ptr->File.Cur_Ptr; + memcpy( Medium_Ptr->File.Buffer_Ptr, Medium_Ptr->File.Cur_Ptr, Medium_Ptr->File.Buffer_Len); + } + else + { + Medium_Ptr->File.Buffer_Len = 0; /* Buffer is empty */ + } + + Medium_Ptr->File.Cur_Ptr = Medium_Ptr->File.Buffer_Ptr; + + Medium_Ptr->File.Buffer_Len += fread( ( Medium_Ptr->File.Buffer_Ptr + Medium_Ptr->File.Buffer_Len), + sizeof( char), ( IMRD_FILE_BUFFER_LEN - Medium_Ptr->File.Buffer_Len), + Medium_Ptr->File.Handle_Ptr); + + if( ferror( Medium_Ptr->File.Handle_Ptr) != 0) + { + IMRD_LM_LOG_ERROR_2( "Can't read file [%s] (%d) !", Medium_Ptr->File.Path, ferror( Medium_Ptr->File.Handle_Ptr)); + + return( IMRS_KO); + } + } + + status_tmp = IO_Hdl_File_Mem_Str(&delim_ptr, Medium_Ptr->File.Cur_Ptr, Medium_Ptr->File.Buffer_Len - (Medium_Ptr->File.Cur_Ptr - Medium_Ptr->File.Buffer_Ptr), Medium_Ptr->File.Delim, Medium_Ptr->File.Delim_Len); + + if( ( Medium_Ptr->File.Delim_Len == 0) || ( delim_ptr == NULL)) /* Seek delim. */ + { + delim_ptr = Medium_Ptr->File.Buffer_Ptr + IMRD_MIN( Medium_Ptr->File.Buffer_Len, read_buffer_len); /* No delimitor */ + next_ptr = delim_ptr; + } + else + { + next_ptr = delim_ptr + Medium_Ptr->File.Delim_Len; /* Delimitor found */ + *Read_Len_Ptr = *Read_Len_Ptr + Medium_Ptr->File.Delim_Len; + } + + copy_data_size = delim_ptr - Medium_Ptr->File.Cur_Ptr; + + if( copy_data_size != 0) + { + if( ( buffer_data_ptr = realloc( buffer_data_ptr, ( buffer_data_size + copy_data_size))) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate Buffer_Data (%d) !", errno); + + return( IMRS_KO); + } + + memcpy( ( buffer_data_ptr + buffer_data_size - 1), Medium_Ptr->File.Cur_Ptr, copy_data_size); /* Copy data from read buffer to copy buffer */ + buffer_data_size += copy_data_size; + + Medium_Ptr->File.Cur_Ptr = next_ptr; + } + } + while( ( next_ptr == delim_ptr) && ( Medium_Ptr->File.Buffer_Len >= read_buffer_len)); + } + + if( IMR_SDM_Fmt_Id_Get( &( Buffer_Ptr->Fmt_Id), "Fixed") != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't get FmtId: (%d) !", Buffer_Ptr->Fmt_Id); + + return( IMRS_KO); + } + + if( buffer_data_size <= 1) + { + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_1, "No more data to read from file: [%s] !", Medium_Ptr->File.Path); + + return( IMRS_NO_DATA); + } + else + { + buffer_data_ptr[ ( buffer_data_size - 1)] = '\0'; + + Buffer_Ptr->Data_Buf_Ptr = buffer_data_ptr; + Buffer_Ptr->Data_Buf_Len = buffer_data_size - 1; + Buffer_Ptr->Data_Buf_Size = buffer_data_size; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_ALLOCATED; + + *Read_Len_Ptr = *Read_Len_Ptr + buffer_data_size - 1; + + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Read (%d) bytes from file: [%s] ", Buffer_Ptr->Data_Buf_Len, Medium_Ptr->File.Path); + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Write */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to write data to */ +/* Write_Len_Ptr: Number of byte writen */ +/* Buffer_Ptr: Buffer to read */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_File_Write( IMRT_Medium *Medium_Ptr, size_t *Write_Len_Ptr, IMRT_Buffer *Buffer_Ptr) +{ + char *padding_buffer_ptr; + long padding_len; + + + *Write_Len_Ptr = 0; + + if( ( Medium_Ptr->File.Delim_Len != 0) && ( Medium_Ptr->Msg_Nb > 0)) + { + *Write_Len_Ptr = fwrite( Medium_Ptr->File.Delim, sizeof( char), Medium_Ptr->File.Delim_Len, Medium_Ptr->File.Handle_Ptr); + + if( ferror( Medium_Ptr->File.Handle_Ptr) != 0) + { + IMRD_LM_LOG_ERROR_2( "Can't write file [%s] (%d) !", Medium_Ptr->URL, ferror( Medium_Ptr->File.Handle_Ptr)); + + return( IMRS_KO); + } + } + + padding_len = Medium_Ptr->File.Msg_Len - Buffer_Ptr->Data_Buf_Len; + + if( Medium_Ptr->File.Msg_Len != 0 ) + { + if( padding_len < 2) + { + IMRD_LM_LOG_ERROR_2( "Buffer size: (%d) too big for message split size: (%d) !", Buffer_Ptr->Data_Buf_Len, Medium_Ptr->File.Msg_Len); + + return( IMRS_KO); + } + + if( ( padding_buffer_ptr = malloc( padding_len)) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate padding_buffer (%d) !", errno); + + return( IMRS_KO); + } + + memset( padding_buffer_ptr, ' ', padding_len); + + padding_buffer_ptr[0] = '\0'; + padding_buffer_ptr[1] = '\0'; + } + + *Write_Len_Ptr += fwrite( Buffer_Ptr->Data_Buf_Ptr, sizeof( char), Buffer_Ptr->Data_Buf_Len, Medium_Ptr->File.Handle_Ptr); + + if( ferror( Medium_Ptr->File.Handle_Ptr) != 0) + { + IMRD_LM_LOG_ERROR_2( "Can't write data in file [%s] (%d) !", Medium_Ptr->URL, ferror( Medium_Ptr->File.Handle_Ptr)); + + return( IMRS_KO); + } + + if( Medium_Ptr->File.Msg_Len != 0 ) + { + *Write_Len_Ptr += fwrite( padding_buffer_ptr, sizeof( char), padding_len, Medium_Ptr->File.Handle_Ptr); + + free( padding_buffer_ptr); + + if( ferror( Medium_Ptr->File.Handle_Ptr) != 0) + { + IMRD_LM_LOG_ERROR_2( "Can't write padding in file [%s] (%d) !", Medium_Ptr->URL, ferror( Medium_Ptr->File.Handle_Ptr)); + + return( IMRS_KO); + } + } + + fflush( Medium_Ptr->File.Handle_Ptr); + + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Wrote (%d) bytes to file: [%s] ", *Write_Len_Ptr, Medium_Ptr->File.Path); + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Begin */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_File_Begin( IMRT_Medium *Medium_Ptr) +{ + return(IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Commit */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_File_Commit( IMRT_Medium *Medium_Ptr) +{ + return(IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Rollback */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_File_Rollback( IMRT_Medium *Medium_Ptr) +{ + return(IMRS_OK); +} diff --git a/src/libio_mng/src/io_hdl_file.h b/src/libio_mng/src/io_hdl_file.h new file mode 100644 index 0000000..264d5e6 --- /dev/null +++ b/src/libio_mng/src/io_hdl_file.h @@ -0,0 +1,149 @@ +/*----------------------------------------------------------------------------*/ +/* File: libio_mng.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _IO_HDL_FILE_H_ +#define _IO_HDL_FILE_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* Defines */ +/*----------------------------------------------------------------------------*/ + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _IO_HDL_FILE_C_ + +IMRT_Status IO_Hdl_File_Open( IMRT_Medium *, IMRT_Medium_Path, IMRT_Dir_Id); +IMRT_Status IO_Hdl_File_Close( IMRT_Medium *); +IMRT_Status IO_Hdl_File_Mem_Str( char **, const char *, size_t, const char *, size_t); +IMRT_Status IO_Hdl_File_Read( IMRT_Buffer *, size_t *, IMRT_Medium *, IMRT_Read_Mode); +IMRT_Status IO_Hdl_File_Write( IMRT_Medium *, size_t *, IMRT_Buffer *); +IMRT_Status IO_Hdl_File_Begin( IMRT_Medium *Medium_Ptr); +IMRT_Status IO_Hdl_File_Commit( IMRT_Medium *Medium_Ptr); +IMRT_Status IO_Hdl_File_Rollback( IMRT_Medium *Medium_Ptr); + + +# else + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Open */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to open */ +/* Medium_Path: Medium Path to open */ +/* Dir_Id: Medium open direction */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_File_Open( IMRT_Medium *, IMRT_Medium_Path, IMRT_Dir_Id); + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Close */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to close */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_File_Close( IMRT_Medium *); + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Read */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Ptr: Buffer to write data in */ +/* Read_Len_Ptr: Number of byte readen */ +/* Medium_Path: Medium to read */ +/* Read_Mode: Read mode */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_File_Read( IMRT_Buffer *, size_t *, IMRT_Medium *, IMRT_Read_Mode); + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Write */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium towrite data to */ +/* Write_Len_Ptr: Number of byte writen */ +/* Buffer_Ptr: Buffer to read */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_File_Write( IMRT_Medium *, size_t *, IMRT_Buffer *); + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Begin */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ +extern IMRT_Status IO_Hdl_File_Begin( IMRT_Medium *Medium_Ptr); + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Commit */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ +extern IMRT_Status IO_Hdl_File_Commit( IMRT_Medium *Medium_Ptr); + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_File_Rollback */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ +extern IMRT_Status IO_Hdl_File_Rollback( IMRT_Medium *Medium_Ptr); + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libio_mng/src/io_hdl_mqs.c b/src/libio_mng/src/io_hdl_mqs.c new file mode 100644 index 0000000..63fcd69 --- /dev/null +++ b/src/libio_mng/src/io_hdl_mqs.c @@ -0,0 +1,433 @@ +/*----------------------------------------------------------------------------*/ +/* File: io_hdl_mqs.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBIO_MNG_ +#define _IO_HDL_MQS_C_ + + + +#include "io_hdl_mqs.h" + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Open */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to open */ +/* Medium_Path: Medium Path to open */ +/* Dir_Id: Medium open direction */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_MQS_Open( IMRT_Medium *Medium_Ptr, IMRT_Medium_Path Medium_Path, IMRT_Dir_Id Dir_Id) +{ + MQLONG comp_code; /* completion code */ + MQLONG reason_code; /* reason code */ + char *pos_slash_ptr; + MQOD od = {MQOD_DEFAULT}; /* Object Descriptor */ + MQLONG options; /* MQOPEN/MQCLOSE options */ + + + if( Dir_Id == IMRD_DIR_ID_IN) + { + /*positionnenment des option d'ouverture du de la Queue*/ + options = MQOO_INPUT_AS_Q_DEF | MQOO_FAIL_IF_QUIESCING; /* open queue for input but not if MQM stopping */ + } + else + { + if( Dir_Id == IMRD_DIR_ID_OUT) + { + /*positionnenment des option d'ouverture du de la Queue*/ + options = MQOO_OUTPUT | MQOO_FAIL_IF_QUIESCING; /* open queue for output but not if MQM stopping */ + } + else + { + IMRD_LM_LOG_ERROR_1( "Invalid Dir_Id (%d) !", Dir_Id); + + return( IMRS_KO); + } + } + + pos_slash_ptr = strstr( Medium_Path, "/"); + + if( pos_slash_ptr == NULL) + { + IMRD_LM_LOG_ERROR_1( "Invalid mqs path [%s] !", Medium_Path); + return( IMRS_KO); + } + + strncpy( Medium_Ptr->MQS.Queue_Mng, Medium_Path, strlen( Medium_Path) - strlen( pos_slash_ptr)); + Medium_Ptr->MQS.Queue_Mng[ strlen( Medium_Path) - strlen( pos_slash_ptr)] = '\0'; + + strcpy( Medium_Ptr->MQS.Queue_Name, ( pos_slash_ptr + 1)); + + /*queue manager connection*/ + MQCONN( Medium_Ptr->MQS.Queue_Mng, &( Medium_Ptr->MQS.Conn_Hdl), &comp_code, &reason_code); + + if( comp_code == MQCC_FAILED) + { + IMRD_LM_LOG_ERROR_2( "MQCONN ended with reason code (%d) for this path [%s] !", reason_code, Medium_Path); + + return( IMRS_KO); + } + + strcpy( od.ObjectName, Medium_Ptr->MQS.Queue_Name); + + /*open the queue*/ + MQOPEN( Medium_Ptr->MQS.Conn_Hdl, &od, options, &( Medium_Ptr->MQS.Obj_Hdl), &comp_code, &reason_code); + + /* report reason, if any; stop if failed */ + if( reason_code != MQRC_NONE) + { + IMRD_LM_LOG_ERROR_2( "MQOPEN ended with reason code (%d) for this path [%s] !", reason_code, Medium_Path); + + return( IMRS_KO); + } + + if( comp_code == MQCC_FAILED) + { + IMRD_LM_LOG_ERROR_1( "Unable to open queue for this path [%s] !", Medium_Path); + + return( IMRS_KO); + } + else + { + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Queue_Mng: [%s] Queue: [%s] Dir: [%s] opened !", Medium_Ptr->MQS.Queue_Mng, Medium_Ptr->MQS.Queue_Name, ( ( Dir_Id == IMRD_DIR_ID_IN) ? "in" : ( ( Dir_Id == IMRD_DIR_ID_OUT) ? "out" : "unknown"))); + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Close */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to close */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_MQS_Close( IMRT_Medium *Medium_Ptr) +{ + MQLONG comp_code; /* completion code */ + MQLONG reason_code; /* reason code */ + char *pos_slash_ptr; + MQOD od = {MQOD_DEFAULT}; /* Object Descriptor */ + + + MQCLOSE( Medium_Ptr->MQS.Conn_Hdl, &( Medium_Ptr->MQS.Obj_Hdl), MQCO_NONE, &comp_code, &reason_code); + + if( reason_code != MQRC_NONE) + { + IMRD_LM_LOG_ERROR_2( "MQCLOSE ended with reason code [%d] for queue: [%s] !", reason_code, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_KO); + } + + MQDISC( &Medium_Ptr->MQS.Conn_Hdl, &comp_code, &reason_code); + + /* report reason, if any */ + if( reason_code != MQRC_NONE) + { + IMRD_LM_LOG_ERROR_2( "MQCLOSE ended with reason code [%d] for queue: [%s] !", reason_code, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_KO); + } + else + { + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Queue_Mng: [%s] Queue: [%s] closed !", Medium_Ptr->MQS.Queue_Mng, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Read */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Ptr: Buffer to write data in */ +/* Read_Len_Ptr: Number of byte writen */ +/* Medium_Path: Medium to read */ +/* Read_Mode: Read mode */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_MQS_Read( IMRT_Buffer *Buffer_Ptr, size_t *Read_Len_Ptr, IMRT_Medium *Medium_Ptr, IMRT_Read_Mode Read_Mode) +{ + MQLONG comp_code; /* completion code */ + MQLONG reason_code; /* reason code */ + IMRT_MQS_Buffer *buffer_ptr; + MQLONG buffer_len; + MQGMO gmo = {MQGMO_DEFAULT}; /* get message options */ + MQMD md = {MQMD_DEFAULT}; /* Message Descriptor */ + + + + + switch( Read_Mode) + { + case IMRD_READ_MODE_WAIT: + { + gmo.Options = MQGMO_WAIT ; + break; + } + + case IMRD_READ_MODE_NO_WAIT: + { + gmo.Options = MQGMO_NO_WAIT ; + break; + } + + default: + { + IMRD_LM_LOG_ERROR_1( "Unknown Read_Mode: (%d) !", Read_Mode); + + return( IMRS_KO); + } + } + + gmo.Options |= MQGMO_CONVERT; + + if( Medium_Ptr->Tran_Flag == IMRD_MEDIUM_TRAN_FLAG_IN) + { + gmo.Options |= MQGMO_SYNCPOINT; + } + +// gmo.WaitInterval = MQWI_UNLIMITED; + gmo.WaitInterval = 10000; + + if( ( buffer_ptr = malloc( IMRD_MQS_BUFFER_SIZE)) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate MQS Buffer (%d) !", errno); + + return( IMRS_KO); + } + + memcpy( md.MsgId, MQMI_NONE, sizeof(md.MsgId)); + memcpy( md.CorrelId, MQCI_NONE, sizeof(md.CorrelId)); + md.Encoding = MQENC_NATIVE; + md.CodedCharSetId = MQCCSI_Q_MGR; + + do + { + + MQGET( Medium_Ptr->MQS.Conn_Hdl, Medium_Ptr->MQS.Obj_Hdl, &md, &gmo, IMRD_MQS_BUFFER_SIZE, buffer_ptr, &buffer_len, &comp_code, &reason_code); + + } while( ( Read_Mode == IMRD_READ_MODE_WAIT) && ( reason_code == MQRC_NO_MSG_AVAILABLE) && ( IMRG_Base.Sig_Trapped == 0)); + + if( reason_code != MQRC_NONE) + { + if( reason_code == MQRC_NO_MSG_AVAILABLE) + { + free( buffer_ptr); + + if( IMRG_Base.Sig_Trapped == 0) + { + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "No more data to read from Queue_Mng: [%s] Queue: [%s] !", Medium_Ptr->MQS.Queue_Mng, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_NO_DATA); + } + else + { + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Signal received during reading from Queue_Mng: [%s] Queue: [%s] !", Medium_Ptr->MQS.Queue_Mng, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_SIGNAL); + } + } + else + { + if( reason_code == MQRC_TRUNCATED_MSG_FAILED) + { + IMRD_LM_LOG_ERROR_2( "MQGET failed: truncated message rc: [%d] for queue: [%s] !", reason_code, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_KO); + } + else + { + IMRD_LM_LOG_ERROR_2( "MQGET failed: rc: [%d] for queue: [%s] !", reason_code, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_KO); + } + } + } + else + { + if( comp_code == MQCC_FAILED) + { + IMRD_LM_LOG_ERROR_2( "MQGET failed: ??? rc: [%d] for queue: [%s] !", reason_code, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_KO); + } + else + { + + buffer_ptr[ buffer_len] = '\0'; /* add terminator */ + + Buffer_Ptr->Data_Buf_Ptr = (IMRT_Buffer_Data *)buffer_ptr; + Buffer_Ptr->Data_Buf_Len = (size_t)buffer_len; + Buffer_Ptr->Data_Buf_Size = IMRD_MQS_BUFFER_SIZE; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_ALLOCATED; + + *Read_Len_Ptr = Buffer_Ptr->Data_Buf_Len; + + if( IMR_SDM_Fmt_Id_Get( &( Buffer_Ptr->Fmt_Id), "Fixed") != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't get FmtId: (%d) !", Buffer_Ptr->Fmt_Id); + + return( IMRS_KO); + } + else + { + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Read (%d) bytes from Queue_Mng: [%s] Queue: [%s] !", Buffer_Ptr->Data_Buf_Len, Medium_Ptr->MQS.Queue_Mng, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_OK); + } + } + } +} + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Write */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to write data to */ +/* Write_Len_Ptr: Number of byte writen */ +/* Buffer_Ptr: Buffer to read */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_MQS_Write( IMRT_Medium *Medium_Ptr, size_t *Write_Len_Ptr, IMRT_Buffer *Buffer_Ptr) +{ + MQLONG comp_code; /* completion code */ + MQLONG reason_code; /* reason code */ + MQPMO pmo = {MQPMO_DEFAULT}; /* put message options */ + MQMD md = {MQMD_DEFAULT}; /* Message Descriptor */ + + + memcpy( md.Format, MQFMT_STRING, (size_t)MQ_FORMAT_LENGTH); + + pmo.Options |= MQPMO_NEW_MSG_ID | MQPMO_NEW_CORREL_ID; + + if( Medium_Ptr->Tran_Flag == IMRD_MEDIUM_TRAN_FLAG_IN) + { + pmo.Options |= MQPMO_SYNCPOINT; + } + + MQPUT( Medium_Ptr->MQS.Conn_Hdl, Medium_Ptr->MQS.Obj_Hdl, &md, &pmo, (MQLONG)( Buffer_Ptr->Data_Buf_Len), Buffer_Ptr->Data_Buf_Ptr, &comp_code, &reason_code); + + if( reason_code != MQRC_NONE) + { + IMRD_LM_LOG_ERROR_2( "MQPUT failed: (%d) for queue: [%s] !", reason_code, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_KO); + } + else + { + *Write_Len_Ptr = Buffer_Ptr->Data_Buf_Len; + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Wrote (%d) bytes to Queue_Mng: [%s] Queue: [%s]!", *Write_Len_Ptr, Medium_Ptr->MQS.Queue_Mng, Medium_Ptr->MQS.Queue_Name); + + return( IMRS_OK); + } +} + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Begin */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_MQS_Begin( IMRT_Medium *Medium_Ptr) +{ + + return(IMRS_OK); + +} + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Commit */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium */ +/*----------------------------------------------------------------------------*/ + + +IMRT_Status IO_Hdl_MQS_Commit( IMRT_Medium *Medium_Ptr) +{ + MQLONG comp_code; /* completion code */ + MQLONG reason_code; /* reason code */ + IMRT_Status status; + + status = IMRS_OK; + + MQCMIT(Medium_Ptr->MQS.Conn_Hdl, + &comp_code, + &reason_code); + if( reason_code != MQRC_NONE) + { + IMRD_LM_LOG_ERROR_2( "MQCMIT failed: (%d) for queue: [%s] !", reason_code, Medium_Ptr->MQS.Queue_Name); + status = IMRS_KO; + } + return(status); + +} + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Rollback */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_MQS_Rollback( IMRT_Medium *Medium_Ptr) +{ + MQLONG comp_code; /* completion code */ + MQLONG reason_code; /* reason code */ + IMRT_Status status; + + status = IMRS_OK; + + MQBACK(Medium_Ptr->MQS.Conn_Hdl, + &comp_code, + &reason_code); + if( reason_code != MQRC_NONE) + { + IMRD_LM_LOG_ERROR_2( "MQBACK failed: (%d) for queue: [%s] !", reason_code, Medium_Ptr->MQS.Queue_Name); + status = IMRS_KO; + } + + return(status); + +} diff --git a/src/libio_mng/src/io_hdl_mqs.h b/src/libio_mng/src/io_hdl_mqs.h new file mode 100644 index 0000000..53a4167 --- /dev/null +++ b/src/libio_mng/src/io_hdl_mqs.h @@ -0,0 +1,149 @@ +/*----------------------------------------------------------------------------*/ +/* File: io_hdl_mqs.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _IO_HDL_MQS_H_ +#define _IO_HDL_MQS_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* Defines */ +/*----------------------------------------------------------------------------*/ + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _IO_HDL_MQS_C_ + +IMRT_Status IO_Hdl_MQS_Open( IMRT_Medium *, IMRT_Medium_Path, IMRT_Dir_Id); +IMRT_Status IO_Hdl_MQS_Close( IMRT_Medium *); +IMRT_Status IO_Hdl_MQS_Read( IMRT_Buffer *, size_t *, IMRT_Medium *, IMRT_Read_Mode); +IMRT_Status IO_Hdl_MQS_Write( IMRT_Medium *, size_t *, IMRT_Buffer *); +IMRT_Status IO_Hdl_MQS_Commit( IMRT_Medium *); +IMRT_Status IO_Hdl_MQS_Rollback( IMRT_Medium *); +IMRT_Status IO_Hdl_MQS_Begin( IMRT_Medium *); + +# else + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Open */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to open */ +/* Medium_Path: Medium Path to open */ +/* Dir_Id: Medium open direction */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_MQS_Open( IMRT_Medium *, IMRT_Medium_Path, IMRT_Dir_Id); + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Close */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to close */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_MQS_Close( IMRT_Medium *); + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Read */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Ptr: Buffer to write data in */ +/* Read_Len_Ptr: Number of byte writen */ +/* Medium_Path: Medium to read */ +/* Read_Mode: Read mode */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_MQS_Read( IMRT_Buffer *, size_t *, IMRT_Medium *, IMRT_Read_Mode); + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Write */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium towrite data to */ +/* Write_Len_Ptr: Number of byte writen */ +/* Buffer_Ptr: Buffer to read */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_MQS_Write( IMRT_Medium *, size_t *, IMRT_Buffer *); + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Commit */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_MQS_Commit( IMRT_Medium *); + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Rollback */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_MQS_Rollback( IMRT_Medium *); + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_MQS_Begin */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_MQS_Begin( IMRT_Medium *); + + + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libio_mng/src/io_hdl_tux.c b/src/libio_mng/src/io_hdl_tux.c new file mode 100644 index 0000000..089ff16 --- /dev/null +++ b/src/libio_mng/src/io_hdl_tux.c @@ -0,0 +1,595 @@ +/*----------------------------------------------------------------------------*/ +/* File: io_hdl_tux.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBIO_MNG_ +#define _IO_HDL_TUX_C_ + + + +#include "io_hdl_tux.h" + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Open */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to open */ +/* Medium_Path: Medium Path to open */ +/* Dir_Id: Medium open direction */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_Tux_Open( IMRT_Medium *Medium_Ptr, IMRT_Medium_Path Medium_Path, IMRT_Dir_Id Dir_Id) +{ + char *Pos_Slash_Ptr; + + + Pos_Slash_Ptr = strstr(Medium_Path, "/"); + + if(Pos_Slash_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_1( "Invalid tux path [%s] !", Medium_Path); + + return( IMRS_KO); + } + else + { + strncpy(Medium_Ptr->Tux.Queue_Space, Medium_Path, strlen(Medium_Path) - strlen(Pos_Slash_Ptr)); + Medium_Ptr->Tux.Queue_Space[strlen(Medium_Path) - strlen(Pos_Slash_Ptr)] = '\0'; + + strcpy(Medium_Ptr->Tux.Queue_Name, (Pos_Slash_Ptr + 1)); + + if( Queue_Exist( Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_2( "Tux Queue doesn't exist: Queue_Space: [%s] Queue: [%s] !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name); + return( IMRS_KO); + } + else + { + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Queue_Space: [%s] Queue: [%s] opened !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name); + + return( IMRS_OK); + } + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Close */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to close */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_Tux_Close( IMRT_Medium *Medium_Ptr) +{ + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Queue_Space: [%s] Queue: [%s] closed !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name); + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Read */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Ptr: Buffer to write data in */ +/* Read_Len_Ptr: Number of byte writen */ +/* Medium_Path: Medium to read */ +/* Read_Mode: Read mode */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_Tux_Read( IMRT_Buffer *Buffer_Ptr, size_t *Read_Len_Ptr, IMRT_Medium *Medium_Ptr, IMRT_Read_Mode Read_Mode) +{ + IMRT_Tux_Buffer *Tux_Buffer_Ptr = NULL; + TPQCTL queue_param; + long len; + long flags; + + + memset(queue_param.corrid, '\0', sizeof(queue_param.corrid)); + + switch( Read_Mode) + { + case IMRD_READ_MODE_WAIT: + { + queue_param.flags = TPQWAIT; + break; + } + + case IMRD_READ_MODE_NO_WAIT: + { + break; + } + + + default: + { + IMRD_LM_LOG_ERROR_1( "Unknown Read_Mode: (%d) !", Read_Mode); + + return( IMRS_KO); + } + } + + queue_param.diagnostic = 0L; + + if( ( Tux_Buffer_Ptr = (IMRT_Tux_Buffer *)tpalloc(IMRD_FML_TYPE_32, NULL, IMRD_TUX_BUFFER_SIZE)) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate Tux_Buffer_Ptr [%s] !", tpstrerror(tperrno)); + + return( IMRS_KO); + } + + if( Finit32( (IMRT_Tux_Buffer *)Tux_Buffer_Ptr, (FLDLEN32)IMRD_TUX_BUFFER_SIZE) == -1) + { + IMRD_LM_LOG_ERROR_1( "Can't initialize Tux_Buffer_Ptr [%s] !", Fstrerror32(Ferror32)); + + return( IMRS_KO); + } + + + if( tpdequeue( Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name, &queue_param, (char **)&Tux_Buffer_Ptr, &len, TPNOTIME) == -1) + { + switch( tperrno) + { + case TPGOTSIG: + { + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Signal received during reading from QSpace [%s] QueueName [%s] !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name); + + return( IMRS_SIGNAL); + } + + default: + { + switch( queue_param.diagnostic) + { + case QMENOMSG: + { + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "No more data to read from QSpace [%s] QueueName [%s] !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name); + + return( IMRS_NO_DATA); + } + + default: + { + IMRD_LM_LOG_ERROR_4( "Can't read buffer from QSpace [%s] QueueName [%s] : [%s] [%d] !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name, tpstrerror(tperrno), queue_param.diagnostic); + + return( IMRS_KO); + } + } + } + } + } + else + { + Buffer_Ptr->Data_Buf_Ptr = (IMRT_Buffer_Data *)Tux_Buffer_Ptr; + Buffer_Ptr->Data_Buf_Len = Fused32( Tux_Buffer_Ptr); + Buffer_Ptr->Data_Buf_Size = Fsizeof32( Tux_Buffer_Ptr); + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_ALLOCATED; + + *Read_Len_Ptr = Buffer_Ptr->Data_Buf_Len; + + if( IMR_SDM_Fmt_Id_Get( &( Buffer_Ptr->Fmt_Id), "FML") != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't get FmtId !"); + + return( IMRS_KO); + } + else + { + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Read (%d) bytes from Queue_Space: [%s] Queue: [%s] !", Buffer_Ptr->Data_Buf_Len, Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name); + + return( IMRS_OK); + } + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Write */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to write data to */ +/* Write_Len_Ptr: Number of byte writen */ +/* Buffer_Ptr: Buffer to read */ +/* Write_Len_Ptr: Number of byte writen */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_Tux_Write( IMRT_Medium *Medium_Ptr, size_t *Write_Len_Ptr, IMRT_Buffer *Buffer_Ptr) +{ + TPQCTL queue_param; + + memset( queue_param.corrid, '\0', sizeof( queue_param.corrid)); + queue_param.flags = 0L; + queue_param.diagnostic = 0L; + + if( tpenqueue( Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name, &queue_param, Buffer_Ptr->Data_Buf_Ptr, 0, TPNOFLAGS) == -1) + { + IMRD_LM_LOG_ERROR_3( "Can't write buffer to QSpace [%s] QueueName [%s] : [%s] !", Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name, tpstrerror(tperrno) ); + + + return( IMRS_KO); + } + else + { + *Write_Len_Ptr = Buffer_Ptr->Data_Buf_Len; + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Wrote (%d) bytes to Queue_Space: [%s] Queue: [%s]!", *Write_Len_Ptr, Medium_Ptr->Tux.Queue_Space, Medium_Ptr->Tux.Queue_Name); + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Queue_Alloc */ +/*----------------------------------------------------------------------------*/ +/* Buf_Ptr_Ptr: Tuxedo Buffer */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Queue_Alloc( IMRT_Tux_Buffer **Buf_Ptr_Ptr) +{ + if( ( *Buf_Ptr_Ptr = (IMRT_Tux_Buffer *)tpalloc( IMRD_FML_TYPE_32, NULL, IMRD_TUX_BUFFER_SIZE)) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't tpalloc Buffer: [%s] !", tpstrerror( tperrno)); + + return( IMRS_KO); + } + + if( Finit32( (IMRT_Tux_Buffer *)*Buf_Ptr_Ptr, (FLDLEN32)IMRD_TUX_BUFFER_SIZE) == -1) + { + IMRD_LM_LOG_ERROR_1( "Can't Finit32 Buffer: [%s] !", Fstrerror32( Ferror32)); + + return( IMRS_KO); + } + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Queue_Free */ +/*----------------------------------------------------------------------------*/ +/* Buf_Ptr: Tuxedo Buffer */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Queue_Free( IMRT_Tux_Buffer *Buf_Ptr) +{ + if( Buf_Ptr != NULL) + { + tpfree( (char *)Buf_Ptr); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Queue_Exist_Mib */ +/*----------------------------------------------------------------------------*/ +/* Queue_Space: Queue Space Name */ +/* Queue_Name: Queue Name */ +/* Request_Buf_Ptr: Request Tuxedo Buffer */ +/* Response_Buf_Ptr: Response Tuxedo Buffer */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Queue_Exist_Mib( IMRT_Tux_Queue_Space Queue_Space, IMRT_Tux_Queue_Name Queue_Name, IMRT_Tux_Buffer *Request_Buf_Ptr, IMRT_Tux_Buffer *Response_Buf_Ptr) +{ + IMRT_Tux_Lmid lmid; + long fldid1, fldid2; + long nb_occurs = 0L; + long rlen = 0L; + IMRT_Tux_Open_Info open_info; + char *qmconfig, *appqspacename; + int i; + + + if( Fchg32( Request_Buf_Ptr, TA_OPERATION, 0, "GET", 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_OPERATION: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( Fchg32( Request_Buf_Ptr, TA_CLASS, 0, "T_GROUP", 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_CLASS: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( Fchg32( Request_Buf_Ptr, TA_TMSNAME, 0, "TMS_QM", 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_TMSNAME: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + fldid1 = TA_OPENINFO; + if( Fchg32( Request_Buf_Ptr, TA_FILTER, 0, (char *)&fldid1, 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_FILTER: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + fldid2 = TA_LMID; + if( Fchg32( Request_Buf_Ptr, TA_FILTER, 1, (char *)&fldid2, 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_FILTER: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( tpcall( IMRD_TMIB_SERVICE, (void *)Request_Buf_Ptr,0, (char**)&Response_Buf_Ptr, &rlen, 0L) < 0) + { + IMRD_LM_LOG_ERROR_1( "Error tpcall: [%s] !", tpstrerror( tperrno)); + return( IMRS_KO); + } + + if( Fget32( Response_Buf_Ptr, TA_OCCURS, 0, (char *)&nb_occurs, NULL) == -1 ) + { + IMRD_LM_LOG_ERROR_1( "Fget32 TA_OCCURS: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + for( i=0; i < nb_occurs; i++) + { + if( Fget32( Response_Buf_Ptr, TA_OPENINFO, i, open_info, NULL) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fget32 TA_OPENINFO: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + qmconfig = (char *)strchr(open_info, ':')+1; + appqspacename = (char *)strchr(qmconfig, ':'); + appqspacename[0] = 0; + appqspacename++; + + if( strcmp( appqspacename, Queue_Space) == 0) + { + i = nb_occurs; + } + } + + if( Fget32( Response_Buf_Ptr, TA_LMID, 0, lmid, NULL) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fget32 TA_LMID: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( Finit32( (FBFR32 *)Request_Buf_Ptr, (FLDLEN32)IMRD_TUX_BUFFER_SIZE) == -1 ) + { + IMRD_LM_LOG_ERROR_1( "Finit32 Buffer1: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( Finit32( (FBFR32 *)Response_Buf_Ptr, (FLDLEN32)IMRD_TUX_BUFFER_SIZE) == -1 ) + { + IMRD_LM_LOG_ERROR_1( "Finit32 Buffer2: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( Fchg32( Request_Buf_Ptr, TA_OPERATION, 0, "GET", 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_OPERATION: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( Fchg32( Request_Buf_Ptr, TA_CLASS, 0, "T_APPQ", 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_CLASS: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( Fchg32( Request_Buf_Ptr, TA_APPQSPACENAME, 0, Queue_Space, 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_APPQSPACENAME: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( Fchg32( Request_Buf_Ptr, TA_APPQNAME, 0, Queue_Name, 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_APPQNAME: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( Fchg32( Request_Buf_Ptr, TA_QMCONFIG, 0, qmconfig, 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_QMCONFIG: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( Fchg32( Request_Buf_Ptr, TA_LMID, 0, lmid, 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_LMID: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + fldid1 = TA_APPQNAME; + if( Fchg32( Request_Buf_Ptr, TA_FILTER, 0, (char *)&fldid1, 0) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fchg32 TA_FILTER: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( tpcall( IMRD_TMIB_SERVICE, (void *)Request_Buf_Ptr, 0, (char**)&Response_Buf_Ptr, &rlen, 0L) < 0) + { + IMRD_LM_LOG_ERROR_1( "Error tpcall: [%s] !", tpstrerror( tperrno)); + return( IMRS_KO); + } + + if( Fget32( Response_Buf_Ptr, TA_OCCURS, 0, (char *)&nb_occurs, NULL) == -1) + { + IMRD_LM_LOG_ERROR_1( "Fget32 TA_OCCURS: [%s] !", Fstrerror32( Ferror32)); + return( IMRS_KO); + } + + if( nb_occurs != 0) + { + return( IMRS_OK); + } + else + { + return( IMRS_KO); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Exist_Queue */ +/*----------------------------------------------------------------------------*/ +/* Queue_Space: Queue Space Name */ +/* Queue_Name: Queue Name */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Queue_Exist( IMRT_Tux_Queue_Space Queue_Space, IMRT_Tux_Queue_Name Queue_Name) +{ + IMRT_Status status; + IMRT_Tux_Buffer *Request_Buffer_Ptr, *Response_Buffer_Ptr; + + + if( ( status = Queue_Alloc( &Request_Buffer_Ptr)) == IMRS_OK) + { + if( ( status = Queue_Alloc( &Response_Buffer_Ptr)) == IMRS_OK) + { + status = Queue_Exist_Mib( Queue_Space, Queue_Name, Request_Buffer_Ptr, Response_Buffer_Ptr); + + Queue_Free( Response_Buffer_Ptr); + } + + Queue_Free( Request_Buffer_Ptr); + } + + return( status); +} + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Begin */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IO_Hdl_Tux_Begin( IMRT_Medium *Medium_Ptr) +{ + long flags ; + IMRT_Status status; + + flags = 0; + status = IMRS_OK; + + + if(IMRG_HDL_TUX_MODE == IMRD_HDL_TUX_NOT_IN_TRANS) + { + if( tpbegin(IMRD_HDL_TUX_TIME_OUT,flags) == -1) + { + IMRD_LM_LOG_ERROR_1( "Tpbegin error: [%s] !", tpstrerror(tperrno)); + status = IMRS_KO; + } + else + { + IMRG_HDL_TUX_MODE = IMRD_HDL_TUX_IN_TRANS; + } + } + return(status); + + +} + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Commit */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ +IMRT_Status IO_Hdl_Tux_Commit( IMRT_Medium *Medium_Ptr) +{ + long flags ; + IMRT_Status status; + + flags = 0; + status = IMRS_OK; + + if(IMRG_HDL_TUX_MODE == IMRD_HDL_TUX_IN_TRANS) + { + if( tpcommit(flags) == -1) + { + IMRD_LM_LOG_ERROR_1( "Tpcommit error: [%s] !", tpstrerror(tperrno)); + status = IMRS_KO; + } + else + { + IMRG_HDL_TUX_MODE = IMRD_HDL_TUX_NOT_IN_TRANS; + } + } + return(status); + +} + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Rollback */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ +IMRT_Status IO_Hdl_Tux_Rollback( IMRT_Medium *Medium_Ptr) +{ + long flags ; + IMRT_Status status; + + flags = 0; + status = IMRS_OK; + + if(IMRG_HDL_TUX_MODE == IMRD_HDL_TUX_IN_TRANS) + { + if( tpabort(flags) == -1) + { + IMRD_LM_LOG_ERROR_1( "Tabort error: [%s] !", tpstrerror(tperrno)); + status = IMRS_KO; + } + else + { + IMRG_HDL_TUX_MODE = IMRD_HDL_TUX_NOT_IN_TRANS; + } + } + + return(status); + +} diff --git a/src/libio_mng/src/io_hdl_tux.h b/src/libio_mng/src/io_hdl_tux.h new file mode 100644 index 0000000..b26092c --- /dev/null +++ b/src/libio_mng/src/io_hdl_tux.h @@ -0,0 +1,171 @@ +/*----------------------------------------------------------------------------*/ +/* File: io_hdl_tux.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _IO_HDL_TUX_H_ +#define _IO_HDL_TUX_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* Defines */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_FML_TYPE_32 "FML32" +#define IMRD_TMIB_SERVICE ".TMIB" +#define IMRD_HDL_TUX_TIME_OUT 0 + + + +typedef short IMRT_HDL_TUX_TRAN_MODE ; + +#define IMRD_HDL_TUX_IN_TRANS (IMRT_HDL_TUX_TRAN_MODE)1 +#define IMRD_HDL_TUX_NOT_IN_TRANS (IMRT_HDL_TUX_TRAN_MODE)0 + +# ifdef _IO_HDL_TUX_C_ + +IMRT_HDL_TUX_TRAN_MODE IMRG_HDL_TUX_MODE = IMRD_HDL_TUX_NOT_IN_TRANS ; + +# endif /* _IO_HDL_TUX_C_ */ + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _IO_HDL_TUX_C_ + +IMRT_Status IO_Hdl_Tux_Open( IMRT_Medium *, IMRT_Medium_Path, IMRT_Dir_Id); +IMRT_Status IO_Hdl_Tux_Close( IMRT_Medium *); +IMRT_Status IO_Hdl_Tux_Read( IMRT_Buffer *, size_t *, IMRT_Medium *, IMRT_Read_Mode); +IMRT_Status IO_Hdl_Tux_Write( IMRT_Medium *, size_t *, IMRT_Buffer *); +IMRT_Status Queue_Alloc( IMRT_Tux_Buffer **); +IMRT_Status Queue_Free( IMRT_Tux_Buffer *); +IMRT_Status Queue_Exist_Mib( IMRT_Tux_Queue_Space , IMRT_Tux_Queue_Name , IMRT_Tux_Buffer *, IMRT_Tux_Buffer *); +IMRT_Status Queue_Exist( IMRT_Tux_Queue_Space , IMRT_Tux_Queue_Name); +IMRT_Status IO_Hdl_Tux_Begin( IMRT_Medium *Medium_Ptr); +IMRT_Status IO_Hdl_Tux_Commit( IMRT_Medium *Medium_Ptr); +IMRT_Status IO_Hdl_Tux_Rollback( IMRT_Medium *Medium_Ptr); + +# else + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Open */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to open */ +/* Medium_Path: Medium Path to open */ +/* Dir_Id: Medium open direction */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_Tux_Open( IMRT_Medium *, IMRT_Medium_Path, IMRT_Dir_Id); + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Close */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to close */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_Tux_Close( IMRT_Medium *); + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Read */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Ptr: Buffer to write data in */ +/* Read_Len_Ptr: Number of byte writen */ +/* Medium_Path: Medium to read */ +/* Read_Mode: Read mode */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_Tux_Read( IMRT_Buffer *, size_t *, IMRT_Medium *, IMRT_Read_Mode); + + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Write */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium towrite data to */ +/* Write_Len_Ptr: Number of byte writen */ +/* Buffer_Ptr: Buffer to read */ +/*----------------------------------------------------------------------------*/ + +extern IMRT_Status IO_Hdl_Tux_Write( IMRT_Medium *, size_t *, IMRT_Buffer *); + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Begin */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ +extern IMRT_Status IO_Hdl_Tux_Begin( IMRT_Medium *Medium_Ptr); + + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Commit */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ +extern IMRT_Status IO_Hdl_Tux_Commit( IMRT_Medium *Medium_Ptr); + +/*----------------------------------------------------------------------------*/ +/* IO_Hdl_Tux_Rollback */ +/*----------------------------------------------------------------------------*/ +/* IMRT_Medium *Medium_Ptr */ +/*----------------------------------------------------------------------------*/ +extern IMRT_Status IO_Hdl_Tux_Rollback( IMRT_Medium *Medium_Ptr); + + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif + + + + diff --git a/src/libio_mng/src/libio_mng.c b/src/libio_mng/src/libio_mng.c new file mode 100644 index 0000000..4e59803 --- /dev/null +++ b/src/libio_mng/src/libio_mng.c @@ -0,0 +1,542 @@ +/*----------------------------------------------------------------------------*/ +/* $Workfile: libio_mng.c $ */ +/*----------------------------------------------------------------------------*/ +/* $Author: agibert $ */ +/* $Date: 2008/11/12 02:25:22 $ */ +/* $Revision: 1.1 $ */ +/* $Label: $ */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBIO_MNG_ +#define _LIBIO_MNG_C_ + +#include "libio_mng.h" + + + + + + + +/******************************************************************************/ +/* IO Manager API */ +/******************************************************************************/ + + + +/*----------------------------------------------------------------------------*/ +/* Open IO Manager */ +/*----------------------------------------------------------------------------*/ +/* Lib_Flag: Setup IOM init mode */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_IOM_Library_Open( IMRT_IOM_Config *Config_Ptr) +{ + if( IMRG_IOM_Module.Lib.Status != IMRD_LIB_STATUS_CLOSED) + { + IMRD_LM_LOG_ERROR_0( "Library not closed !"); + + return( IMRS_KO); + } + else + { + IMRG_IOM_Module.Lib.Status = IMRD_LIB_STATUS_OPENED; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Library opened !"); + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Close IO Manager */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_IOM_Library_Close() +{ + if( IMRG_IOM_Module.Lib.Status != IMRD_LIB_STATUS_OPENED) + { + IMRD_LM_LOG_ERROR_0( "Library not opened !"); + + return( IMRS_KO); + } + else + { + IMRG_IOM_Module.Lib.Status = IMRD_LIB_STATUS_CLOSED; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Library closed !"); + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Parse Medium URL */ +/*----------------------------------------------------------------------------*/ +/* Hdl_Name: Handler name parsed */ +/* Medium_Path: Medium path parsed */ +/* Medium_URL: Medium URL to parse */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IOM_URL_Parse( IMRT_IO_Hdl_Name Hdl_Name, IMRT_Medium_Path Medium_Path, IMRT_Medium_URL Medium_URL) +{ + char *ptr; + + + if( ( ( ptr = strstr( Medium_URL, "://")) == NULL) || ( ptr == Medium_URL) || ( ( ptr - Medium_URL + 3) == strlen( Medium_URL))) + { + return( IMRS_KO); + } + + strncpy( Hdl_Name, Medium_URL, ( ptr - Medium_URL)); + Hdl_Name[ ptr - Medium_URL] = '\0'; + + strcpy( Medium_Path, ( ptr + 3)); + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Get Medium Type from Handler Name */ +/*----------------------------------------------------------------------------*/ +/* Medium_Type_Ptr: Medium type to return */ +/* Handler_Name: IO Handler Name */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IOM_Medium_Type_Get( IMRT_Medium_Type *Medium_Type_Ptr, IMRT_IO_Hdl_Name Hdl_Name) +{ + IMRT_Medium_Type i; + + + for( i = 0; ( i < IMRD_IO_HDL_NB) && ( strcmp( IMRG_IOM_Base.IO_Hdl_Tab[i].Name, Hdl_Name) != 0) ; i++); + + if( i < IMRD_IO_HDL_NB) + { + *Medium_Type_Ptr = i; + return( IMRS_OK); + } + else + { + return( IMRS_KO); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Open Medium */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr_Ptr: Reference to the Pointer to the opened medium */ +/* Medium_Name: Name of the medium */ +/* Medium_URL: Medium URL to open */ +/* Appl_Id_Input: Input application Id link with the medium */ +/* Appl_Id_Output: Output application Id link with the medium */ +/* Dir_Id: Medium open direction */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_IOM_Medium_Open( IMRT_Medium **Medium_Ptr_Ptr, IMRT_Medium_Name Medium_Name, IMRT_Medium_URL Medium_URL, IMRT_Appl_Id Appl_Id_Input, IMRT_Appl_Id Appl_Id_Output, IMRT_Dir_Id Dir_Id) +{ + IMRT_Status status; + IMRT_IO_Hdl_Name hdl_name; + IMRT_Medium_Path medium_path; + IMRT_Medium_Type medium_type; + + + if( ( status = IOM_URL_Parse( hdl_name, medium_path, Medium_URL)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't parse URL [%s] !", Medium_URL); + + return( IMRS_KO); + } + + if( ( status = IOM_Medium_Type_Get( &medium_type, hdl_name)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't get medium type [%s] !", hdl_name); + + return( IMRS_KO); + } + + if( ( *Medium_Ptr_Ptr = malloc( sizeof( IMRT_Medium))) == NULL) + { + IMRD_LM_LOG_ERROR_2( "Can't allocate Medium [%s]: (%d) !", Medium_Name, errno); + + return( IMRS_KO); + } + + strcpy( ( *Medium_Ptr_Ptr)->Name, Medium_Name); + ( *Medium_Ptr_Ptr)->Type = medium_type; + ( *Medium_Ptr_Ptr)->Status = IMRD_MEDIUM_STATUS_CLOSED; + strcpy( ( *Medium_Ptr_Ptr)->URL, Medium_URL); + ( *Medium_Ptr_Ptr)->Appl_Id_Input = Appl_Id_Input; + ( *Medium_Ptr_Ptr)->Appl_Id_Output = Appl_Id_Output; + ( *Medium_Ptr_Ptr)->Dir_Id = Dir_Id; + ( *Medium_Ptr_Ptr)->Tran_Flag = IMRD_MEDIUM_TRAN_FLAG_OUT; + ( *Medium_Ptr_Ptr)->Byte_Nb = 0; + ( *Medium_Ptr_Ptr)->Msg_Nb = 0; + + + if( IMRG_IOM_Base.IO_Hdl_Tab[ medium_type].Open_Ptr( *Medium_Ptr_Ptr, medium_path, Dir_Id) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't open Medium [%s] !", Medium_Name); + free( *Medium_Ptr_Ptr); + + return( IMRS_KO); + } + else + { + ( *Medium_Ptr_Ptr)->Status = IMRD_MEDIUM_STATUS_OPENED; + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Close Medium */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to close */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_IOM_Medium_Close( IMRT_Medium *Medium_Ptr) +{ + if( Medium_Ptr->Status == IMRD_MEDIUM_STATUS_OPENED) + { + if( IMRG_IOM_Base.IO_Hdl_Tab[ Medium_Ptr->Type].Close_Ptr( Medium_Ptr) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't close Medium !"); + + return( IMRS_KO); + } + } + + IMRD_LM_LOG_INFO_4( "Medium [%s]: (%d) bytes %s in (%d) messages.", Medium_Ptr->Name, Medium_Ptr->Byte_Nb, ( ( Medium_Ptr->Dir_Id == IMRD_DIR_ID_IN) ? "read" : "writen"), Medium_Ptr->Msg_Nb); + + free( Medium_Ptr); + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Read Medium */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Ptr: Pointer to the buffer to write */ +/* Medium_Ptr: Pointer to the medium to read */ +/* Read_Mode: Read mode */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_IOM_Medium_Read( IMRT_Buffer *Buffer_Ptr, IMRT_Medium *Medium_Ptr, IMRT_Read_Mode Read_Mode) +{ + size_t read_len; + IMRT_Status status; + + + if( Medium_Ptr->Status == IMRD_MEDIUM_STATUS_OPENED) + { + if( ( status = IMRG_IOM_Base.IO_Hdl_Tab[ Medium_Ptr->Type].Read_Ptr( Buffer_Ptr, &read_len, Medium_Ptr, Read_Mode)) == IMRS_KO) + { + IMRD_LM_LOG_ERROR_1( "Can't read Medium [%s] !", Medium_Ptr->Name); + + return( IMRS_KO); + } + + if( status == IMRS_OK) + { + Medium_Ptr->Byte_Nb += read_len; + Medium_Ptr->Msg_Nb++; + + Buffer_Ptr->Appl_Id_Input = Medium_Ptr->Appl_Id_Input; + Buffer_Ptr->Appl_Id_Output = Medium_Ptr->Appl_Id_Output; + Buffer_Ptr->Dir_Id = Medium_Ptr->Dir_Id; + Buffer_Ptr->Flag = IMRD_BUFFER_FLAG_CLOSED; + } + } + else + { + IMRD_LM_LOG_ERROR_1( "Can't read closed Medium [%s] !", Medium_Ptr->Name); + + return( IMRS_KO); + } + + return( status); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Write Medium */ +/*----------------------------------------------------------------------------*/ +/* Medium_Ptr: Pointer to the medium to write */ +/* Buffer_Ptr: Pointer to the buffer to read */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_IOM_Medium_Write( IMRT_Medium *Medium_Ptr, IMRT_Buffer *Buffer_Ptr) +{ + size_t write_len; + + + if( Medium_Ptr->Status == IMRD_MEDIUM_STATUS_OPENED) + { + if( IMRG_IOM_Base.IO_Hdl_Tab[ Medium_Ptr->Type].Write_Ptr( Medium_Ptr, &write_len, Buffer_Ptr) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't write Medium [%s]!", Medium_Ptr->Name); + + return( IMRS_KO); + } + + Medium_Ptr->Byte_Nb += write_len; + Medium_Ptr->Msg_Nb++; + } + else + { + IMRD_LM_LOG_ERROR_1( "Can't write closed Medium [%s]!", Medium_Ptr->Name); + + return( IMRS_KO); + } + + return( IMRS_OK); +} + + + + + + +/*----------------------------------------------------------------------------*/ +/* Tran Begin */ +/*----------------------------------------------------------------------------*/ +/* Tran_Ptr_Ptr: Reference to the pointer of the transaction to begin */ +/* Medium_Count: Number of medium to enclose into the transaction */ +/* Medium_1_Ptr: Pointer to the first medium */ +/* ... */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_IOM_Tran_Begin( IMRT_Tran **Tran_Ptr_Ptr, IMRT_Medium_Nb Medium_Nb, IMRT_Medium *Medium_1_Ptr, ...) +{ + int index; + va_list medium_list; + IMRT_Medium *medium_ptr; + IMRT_Status status; + + + status = IMRS_OK; + medium_ptr = NULL; + + if( Medium_Nb != 0) + { + va_start( medium_list, Medium_1_Ptr); + + + if( ( *Tran_Ptr_Ptr = (IMRT_Tran *)malloc( sizeof( IMRT_Tran))) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't malloc Tran: (%d) !", errno); + return( IMRS_KO); + } + + if( ( (*Tran_Ptr_Ptr)->Medium_Ptr_Tab = (IMRT_Medium **)malloc( sizeof(IMRT_Medium **) * Medium_Nb)) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't malloc Tran Medium_Ptr_Tab: (%d) !", errno); + return( IMRS_KO); + } + + (*Tran_Ptr_Ptr)->Medium_Nb = Medium_Nb; + + for( index = 0; index < Medium_Nb; index++) + { + if( index == 0) + { + ( ( *Tran_Ptr_Ptr)->Medium_Ptr_Tab)[index] = Medium_1_Ptr; + + medium_ptr = Medium_1_Ptr; + } + else + { + medium_ptr = (IMRT_Medium *)va_arg( medium_list, IMRT_Medium *); + if( medium_ptr != NULL) + { + (*Tran_Ptr_Ptr)->Medium_Ptr_Tab[index] = medium_ptr; + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't get medium !"); + status = IMRS_KO; + } + } + + if( status == IMRS_OK) + { + status = IMRG_IOM_Base.IO_Hdl_Tab[medium_ptr->Type].Begin_Ptr( medium_ptr); + + if( status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Begin failed for Medium [%s] !", medium_ptr->Name); + } + else + { + (*Tran_Ptr_Ptr)->Medium_Ptr_Tab[index]->Tran_Flag = IMRD_MEDIUM_TRAN_FLAG_IN; + } + } + + } + va_end( medium_list); + } + else + { + IMRD_LM_LOG_ERROR_1( "BEGIN : Invalid number of medium (%d) !",Medium_Nb ); + status = IMRS_KO ; + } + + return( status); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Tran Commit */ +/*----------------------------------------------------------------------------*/ +/* Tran_Ptr: Pointer to the transaction to commit */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_IOM_Tran_Commit( IMRT_Tran *Tran_Ptr) +{ + IMRT_Status status; + int index; + + + status = IMRS_OK; + + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_1, "Medium Nb to commit: (%d)", Tran_Ptr->Medium_Nb ); + + for( index = 0; index < Tran_Ptr->Medium_Nb; index++) + { + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Medium [%s] Tran_Flag: (%d)", Tran_Ptr->Medium_Ptr_Tab[index]->Name, Tran_Ptr->Medium_Ptr_Tab[index]->Tran_Flag); + + if( Tran_Ptr->Medium_Ptr_Tab[index]->Tran_Flag == IMRD_MEDIUM_TRAN_FLAG_IN) + { + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_1, "Commiting medium [%s]...",Tran_Ptr->Medium_Ptr_Tab[index]->Name); + + status = IMRG_IOM_Base.IO_Hdl_Tab[Tran_Ptr->Medium_Ptr_Tab[index]->Type].Commit_Ptr(Tran_Ptr->Medium_Ptr_Tab[index]); + + if( status == IMRS_OK) + { + Tran_Ptr->Medium_Ptr_Tab[index]->Tran_Flag = IMRD_MEDIUM_TRAN_FLAG_OUT; + } + else + { + IMRD_LM_LOG_ERROR_1( "Commit failed for medium [%s] !", Tran_Ptr->Medium_Ptr_Tab[index]->Name); + } + } + + } + + if( Tran_Ptr->Medium_Ptr_Tab != NULL) + { + free( Tran_Ptr->Medium_Ptr_Tab); + } + + free( Tran_Ptr); + + return( status); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Tran Rollback */ +/*----------------------------------------------------------------------------*/ +/* Tran_Ptr: Pointer to the transaction to rollback */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_IOM_Tran_Rollback( IMRT_Tran *Tran_Ptr) +{ + + IMRT_Status status; + int index; + + + status = IMRS_OK; + + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_1, "Medium Nb to rollback: (%d)", Tran_Ptr->Medium_Nb ); + + for( index = 0; index < Tran_Ptr->Medium_Nb; index++) + { + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Medium [%s] Tran_Flag: (%d)", Tran_Ptr->Medium_Ptr_Tab[index]->Name, Tran_Ptr->Medium_Ptr_Tab[index]->Tran_Flag); + + if( Tran_Ptr->Medium_Ptr_Tab[index]->Tran_Flag == IMRD_MEDIUM_TRAN_FLAG_IN) + { + status = IMRG_IOM_Base.IO_Hdl_Tab[Tran_Ptr->Medium_Ptr_Tab[index]->Type].Rollback_Ptr(Tran_Ptr->Medium_Ptr_Tab[index]); + + if(status == IMRS_OK) + { + Tran_Ptr->Medium_Ptr_Tab[index]->Tran_Flag = IMRD_MEDIUM_TRAN_FLAG_OUT; + } + else + { + IMRD_LM_LOG_ERROR_1( "Rollback failed for medium [%s] !", Tran_Ptr->Medium_Ptr_Tab[index]->Name); + } + } + } + + if( Tran_Ptr->Medium_Ptr_Tab != NULL) + { + free( Tran_Ptr->Medium_Ptr_Tab); + } + + free( Tran_Ptr); + + return( status); +} + + + + + diff --git a/src/libio_mng/src/libio_mng.h b/src/libio_mng/src/libio_mng.h new file mode 100644 index 0000000..de0cd6b --- /dev/null +++ b/src/libio_mng/src/libio_mng.h @@ -0,0 +1,194 @@ +/*----------------------------------------------------------------------------*/ +/* File: libio_mng.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _LIBIO_MNG_H_ +#define _LIBIO_MNG_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* Lib Definitions */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_IOM_MODULE_ID ( IMRT_Module_Id) 3 +#define IMRD_IOM_MODULE_NAME ( IMRT_Module_Name) "iom" +#define IMRD_IOM_MODULE_NAME_LONG ( IMRT_Module_Name_Long) "IO Manager" +#define IMRD_IOM_MODULE_VERSION ( IMRT_Module_Version) "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:22 $ $Workfile: libio_mng.h $" + +#define IMRD_MODULE_PTR &IMRG_IOM_Module + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Definitions */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_IO_HDL_NAME_LEN (short) 255 +#define IMRD_IO_HDL_NAME_SIZE (short) ( IMRD_IO_HDL_NAME_LEN + 1) + +typedef char IMRT_IO_Hdl_Name[ IMRD_IO_HDL_NAME_SIZE]; + + + +typedef IMRT_Status ( IMRT_IO_Hdl_Open) ( IMRT_Medium *, IMRT_Medium_Path, IMRT_Dir_Id); +typedef IMRT_Status ( IMRT_IO_Hdl_Close)( IMRT_Medium *); +typedef IMRT_Status ( IMRT_IO_Hdl_Read) ( IMRT_Buffer *, size_t *, IMRT_Medium *, IMRT_Read_Mode); +typedef IMRT_Status ( IMRT_IO_Hdl_Write)( IMRT_Medium *, size_t *, IMRT_Buffer *); +typedef IMRT_Status ( IMRT_IO_Hdl_Begin) ( IMRT_Medium *); +typedef IMRT_Status ( IMRT_IO_Hdl_Commit) ( IMRT_Medium *); +typedef IMRT_Status ( IMRT_IO_Hdl_Rollback)( IMRT_Medium *); + + + +typedef struct IMRT_IO_Hdl +{ + IMRT_IO_Hdl_Name Name; + IMRT_IO_Hdl_Open *Open_Ptr; + IMRT_IO_Hdl_Close *Close_Ptr; + IMRT_IO_Hdl_Read *Read_Ptr; + IMRT_IO_Hdl_Write *Write_Ptr; + IMRT_IO_Hdl_Begin *Begin_Ptr; + IMRT_IO_Hdl_Commit *Commit_Ptr; + IMRT_IO_Hdl_Rollback *Rollback_Ptr; + + +} IMRT_IO_Hdl; + + + +typedef short IMRT_IO_Hdl_Nb; + +#define IMRD_IO_HDL_NB ( IMRT_IO_Hdl_Nb) 4 + + + +typedef struct IMRT_IO_Base +{ + IMRT_IO_Hdl IO_Hdl_Tab[ IMRD_IO_HDL_NB]; +} IMRT_IO_Base; + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBIO_MNG_C_ + +IMRT_Status IOM_URL_Parse( IMRT_IO_Hdl_Name, IMRT_Medium_Path, IMRT_Medium_URL); +IMRT_Status IOM_Medium_Type_Get( IMRT_Medium_Type *, IMRT_IO_Hdl_Name); + +# endif + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Includes */ +/*----------------------------------------------------------------------------*/ + +#include "io_hdl_file.h" + +#ifdef TUX_SUPPORT +# include "io_hdl_tux.h" +#endif /* TUX_SUPPORT */ + +#ifdef MQS_SUPPORT +# include "io_hdl_mqs.h" +#endif /* MQS_SUPPORT */ + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBIO_MNG_C_ + +IMRT_IO_Base IMRG_IOM_Base = +{ + { + { "Unknown", NULL, NULL, NULL, NULL, NULL, NULL, NULL}, + { "file", IO_Hdl_File_Open, IO_Hdl_File_Close, IO_Hdl_File_Read, IO_Hdl_File_Write,IO_Hdl_File_Begin,IO_Hdl_File_Commit,IO_Hdl_File_Rollback }, + +#ifdef TUX_SUPPORT + { "tux", IO_Hdl_Tux_Open, IO_Hdl_Tux_Close, IO_Hdl_Tux_Read, IO_Hdl_Tux_Write, IO_Hdl_Tux_Begin, IO_Hdl_Tux_Commit, IO_Hdl_Tux_Rollback}, +#endif /* TUX_SUPPORT */ + +#ifdef MQS_SUPPORT + { "mqs", IO_Hdl_MQS_Open, IO_Hdl_MQS_Close, IO_Hdl_MQS_Read, IO_Hdl_MQS_Write, IO_Hdl_MQS_Begin, IO_Hdl_MQS_Commit, IO_Hdl_MQS_Rollback}, +#endif /* MQS_SUPPORT */ + } +}; + + + +IMRT_Module IMRG_IOM_Module = +{ + IMRD_IOM_MODULE_ID, + IMRD_IOM_MODULE_NAME, + IMRD_IOM_MODULE_NAME_LONG, + IMRD_IOM_MODULE_VERSION, + IMRD_MODULE_TYPE_LIBRARY, + { + IMRD_LIB_STATUS_CLOSED, + ( IMRT_Lib_Open *) &IMR_IOM_Library_Open, + ( IMRT_Lib_Close *) &IMR_IOM_Library_Close + } +}; + +# else + +extern IMRT_IO_Base IMRG_IOM_Base; +extern IMRT_Module IMRG_IOM_Module; + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/liblog_mng/include/log_mng.h b/src/liblog_mng/include/log_mng.h new file mode 100644 index 0000000..bd9e98d --- /dev/null +++ b/src/liblog_mng/include/log_mng.h @@ -0,0 +1,397 @@ +/*----------------------------------------------------------------------------*/ +/* File: log_mng.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _LOG_MNG_H_ +#define _LOG_MNG_H_ + + + +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRD_LM_API definition */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBLOG_MNG_ +# define IMRD_LM_API +# else +# define IMRD_LM_API extern +# endif + + + + + +/*----------------------------------------------------------------------------*/ +/* Status definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRS_LM_LOG (IMRT_Status) 2 + + + +/*----------------------------------------------------------------------------*/ +/* Log Type definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_LOG_TYPE_NB (short) 5 + + + +typedef short IMRT_Log_Type_Id; + +#define IMRD_LOG_TYPE_ID_UNKNOWN (IMRT_Log_Type_Id) 0 +#define IMRD_LOG_TYPE_ID_TRACE (IMRT_Log_Type_Id) 1 +#define IMRD_LOG_TYPE_ID_INFO (IMRT_Log_Type_Id) 2 +#define IMRD_LOG_TYPE_ID_WARNING (IMRT_Log_Type_Id) 3 +#define IMRD_LOG_TYPE_ID_ERROR (IMRT_Log_Type_Id) 4 + + + +typedef char *IMRT_Log_Type_Name; + +#define IMRD_LOG_TYPE_NAME_UNKNOWN (IMRT_Log_Type_Name) "???" +#define IMRD_LOG_TYPE_NAME_TRACE (IMRT_Log_Type_Name) "TRA" +#define IMRD_LOG_TYPE_NAME_INFO (IMRT_Log_Type_Name) "INF" +#define IMRD_LOG_TYPE_NAME_WARNING (IMRT_Log_Type_Name) "WRN" +#define IMRD_LOG_TYPE_NAME_ERROR (IMRT_Log_Type_Name) "ERR" + + + + + +/*----------------------------------------------------------------------------*/ +/* Log Level definition */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Log_Level; + +#define IMRD_LOG_LEVEL_UNSET ( IMRT_Log_Level) -1 + +#define IMRD_LOG_LEVEL_MIN ( IMRT_Log_Level) 0 +#define IMRD_LOG_LEVEL_MAX ( IMRT_Log_Level) 999 + +#define IMRD_LOG_LEVEL_VERBOSE_0 ( IMRT_Log_Level) 10 +#define IMRD_LOG_LEVEL_VERBOSE_1 ( IMRT_Log_Level) 20 +#define IMRD_LOG_LEVEL_VERBOSE_2 ( IMRT_Log_Level) 30 + +#define IMRD_LOG_LEVEL_DEFAULT ( IMRT_Log_Level) 10 + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_File_Name definition */ +/*----------------------------------------------------------------------------*/ + +typedef char *IMRT_File_Name; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Line_Id definition */ +/*----------------------------------------------------------------------------*/ + +typedef long IMRT_Line_Id; + + + + + +/*----------------------------------------------------------------------------*/ +/* Log Fmt definition */ +/*----------------------------------------------------------------------------*/ + +typedef char *IMRT_Log_Fmt; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Log_Id_Bit definition */ +/*----------------------------------------------------------------------------*/ + +typedef size_t IMRT_Log_Id_Bit_Offset; +typedef size_t IMRT_Log_Id_Bit_Size; + + + +typedef struct IMRT_Log_Id_Bit +{ + IMRT_Log_Id_Bit_Offset Offset; + IMRT_Log_Id_Bit_Size Size; +} IMRT_Log_Id_Bit; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Log_Id_Struct definition */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Bit_Nb; +typedef size_t IMRT_Log_Size; + + + +typedef struct IMRT_Log_Id_Struct +{ + IMRT_Bit_Nb Bit_Nb; + IMRT_Log_Size Log_Size; + IMRT_Log_Id_Bit *Log_Id_Bit_Ptr; +} IMRT_Log_Id_Struct; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Log_Msg_Header definition */ +/*----------------------------------------------------------------------------*/ + +typedef char *IMRT_Log_Id_Header; + + + + + +/*----------------------------------------------------------------------------*/ +/* LM_Config definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_LM_Config +{ + IMRT_Path Log_File; + IMRT_Module_Id Module_Nb; + IMRT_Log_Level Level_Tab[ IMRD_LOG_TYPE_NB][ IMRD_MODULE_NB_MAX]; +} IMRT_LM_Config; + + + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBLOG_MNG_ + +# else + +extern IMRT_Module IMRG_LM_Module; + +# endif + + + + + + + +/******************************************************************************/ +/* Log Manager API */ +/******************************************************************************/ + +/*----------------------------------------------------------------------------*/ +/* Log Trace Macros */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_LM_LOG_TRACE_0( Level, Fmt) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_TRACE, (Level), IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt)) != IMRS_OK) return( IMRS_KO); +#define IMRD_LM_LOG_TRACE_1( Level, Fmt, Arg1) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_TRACE, (Level), IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_TRACE_2( Level, Fmt, Arg1, Arg2) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_TRACE, (Level), IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_TRACE_3( Level, Fmt, Arg1, Arg2, Arg3) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_TRACE, (Level), IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_TRACE_4( Level, Fmt, Arg1, Arg2, Arg3, Arg4) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_TRACE, (Level), IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_TRACE_5( Level, Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_TRACE, (Level), IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5)) != IMRS_OK) return(IMRS_KO); + + + +/*----------------------------------------------------------------------------*/ +/* Log Info Macros */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_LM_LOG_INFO_0( Fmt) if(IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_INFO, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt)) != IMRS_OK ) return(IMRS_KO); +#define IMRD_LM_LOG_INFO_1( Fmt, Arg1) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_INFO, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1)) != IMRS_OK) return(IMRS_KO) ; +#define IMRD_LM_LOG_INFO_2( Fmt, Arg1, Arg2) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_INFO, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_INFO_3( Fmt, Arg1, Arg2, Arg3) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_INFO, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_INFO_4( Fmt, Arg1, Arg2, Arg3, Arg4) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_INFO, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_INFO_5( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_INFO, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5)) != IMRS_OK) return(IMRS_KO); + + + +/*----------------------------------------------------------------------------*/ +/* Log Warning Macros */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_LM_LOG_WARNING_0( Fmt) if(IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_WARNING, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_WARNING_1( Fmt, Arg1) if(IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_WARNING, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_WARNING_2( Fmt, Arg1, Arg2) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_WARNING, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_WARNING_3( Fmt, Arg1, Arg2, Arg3) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_WARNING, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_WARNING_4( Fmt, Arg1, Arg2, Arg3, Arg4) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_WARNING, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_WARNING_5( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_WARNING, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5)) != IMRS_OK) return(IMRS_KO); + + + +/*----------------------------------------------------------------------------*/ +/* Log Error Macros */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_LM_LOG_ERROR_0( Fmt) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_ERROR, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_ERROR_1( Fmt, Arg1) if(IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_ERROR, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1)) != IMRS_OK) return(IMRS_KO) ; +#define IMRD_LM_LOG_ERROR_2( Fmt, Arg1, Arg2) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_ERROR, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_ERROR_3( Fmt, Arg1, Arg2, Arg3) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_ERROR, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_ERROR_4( Fmt, Arg1, Arg2, Arg3, Arg4) if(IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_ERROR, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4)) != IMRS_OK) return(IMRS_KO); +#define IMRD_LM_LOG_ERROR_5( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) if( IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_ERROR, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5)) != IMRS_OK ) return(IMRS_KO); + + + +/*----------------------------------------------------------------------------*/ +/* Exec Trace Macros */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_LM_STREAM_OUT stream_out + +#define IMRD_LM_EXEC_TRACE( Level, Msg_Pre, Func, Msg_Post) \ + { \ + FILE *stream_out; \ + \ + \ + if( IMR_LM_Log_Trigger( IMRD_LOG_TYPE_ID_TRACE, (Level), IMRD_MODULE_PTR) == IMRS_LM_LOG) \ + { \ + stream_out = IMR_LM_Stream_Out_Get(); \ + \ + IMR_LM_Log_Write( IMRD_LOG_TYPE_ID_TRACE, (Level), IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_FALSE, (Msg_Pre)); \ + (Func); \ + fprintf( stream_out, "%s%s", (Msg_Post), "\n"); \ + fflush( stream_out); \ + } \ + } + + + +/*----------------------------------------------------------------------------*/ +/* Log Buffer Id Macro */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_LM_LOG_BUFFER_ID( Buffer_Ptr, Log_Id_Struct_Ptr, Log_Id_Header) if( IMR_LM_Log_Buffer_Id( (Buffer_Ptr), (Log_Id_Struct_Ptr), (Log_Id_Header), IMRD_LOG_TYPE_ID_INFO, IMRD_LOG_LEVEL_DEFAULT, IMRD_MODULE_PTR, __FILE__, __LINE__, IMRD_TRUE) != IMRS_OK) return(IMRS_KO); + + + + + +/*----------------------------------------------------------------------------*/ +/* Open Log Manager */ +/*----------------------------------------------------------------------------*/ +/* LM_Config_Ptr: Setup LM init mode */ +/*----------------------------------------------------------------------------*/ + +IMRD_LM_API IMRT_Status IMR_LM_Library_Open( IMRT_LM_Config *); + + + +/*----------------------------------------------------------------------------*/ +/* Close Log Manager */ +/*----------------------------------------------------------------------------*/ + +IMRD_LM_API IMRT_Status IMR_LM_Library_Close( void); + + + +/*----------------------------------------------------------------------------*/ +/* LM_Stream_Out_Get */ +/*----------------------------------------------------------------------------*/ + +IMRD_LM_API FILE *IMR_LM_Stream_Out_Get( void); + + + +/*----------------------------------------------------------------------------*/ +/* LM_Log_Trigger */ +/*----------------------------------------------------------------------------*/ +/* Log_Type_Id: Type id of log */ +/* Log_Level: Level of log */ +/* Module_Ptr: Loger module pointer */ +/*----------------------------------------------------------------------------*/ + +IMRD_LM_API IMRT_Status IMR_LM_Log_Trigger( IMRT_Log_Type_Id, IMRT_Log_Level, IMRT_Module *); + + + +/*----------------------------------------------------------------------------*/ +/* LM_Log_Write */ +/*----------------------------------------------------------------------------*/ +/* Log_Type_Id: Type id of log */ +/* Log_Level: Level of log */ +/* Module_Ptr: Loger module pointer */ +/* File_Name: Loger file name */ +/* Line_Id: Loger line id */ +/* LF_Flag: Add or not a LF at EOF */ +/* Log_Fmt: Format string a la printf */ +/* ...: Optional args */ +/*----------------------------------------------------------------------------*/ + +IMRD_LM_API IMRT_Status IMR_LM_Log_Write( IMRT_Log_Type_Id, IMRT_Log_Level, IMRT_Module *, IMRT_File_Name, IMRT_Line_Id, IMRT_Boolean, IMRT_Log_Fmt, ...); + + + +/*----------------------------------------------------------------------------*/ +/* Log_Buffer_Id */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Ptr: buffer to identify */ +/* Log_Id_Struct_Ptr: Log_Id_Heap to use */ +/* Log_Id_Header_Ptr: message to log as header */ +/* Log_Type_Id: Type id of log */ +/* Log_Level: Level of log */ +/* Module_Ptr: Loger module pointer */ +/* File_Name: Loger file name */ +/* Line_Id: Loger line id */ +/* LF_Flag: Add or not a LF at EOF */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_LM_Log_Buffer_Id( IMRT_Buffer *, IMRT_Log_Id_Struct *, IMRT_Log_Id_Header, IMRT_Log_Type_Id, IMRT_Log_Level, IMRT_Module *, IMRT_File_Name, IMRT_Line_Id, IMRT_Boolean); + + + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/liblog_mng/src/Makefile b/src/liblog_mng/src/Makefile new file mode 100644 index 0000000..a1889b4 --- /dev/null +++ b/src/liblog_mng/src/Makefile @@ -0,0 +1,65 @@ +#------------------------------------------------------------------------------ +# Local Makefile +#------------------------------------------------------------------------------ +# $Workfile: Makefile $ +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:22 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Var include +#------------------------------------------------------------------------------ + +include ../../Makefile_var.mk + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +TARGET= liblog_mng$(SHLIB_SUFFIX) + +OBJ= liblog_mng.o + +EXTRA_INC= + +EXTRA_LIB= + + + +#------------------------------------------------------------------------------ +# Rule include +#------------------------------------------------------------------------------ + +include ../../Makefile_rule.mk diff --git a/src/liblog_mng/src/liblog_mng.c b/src/liblog_mng/src/liblog_mng.c new file mode 100644 index 0000000..3b68757 --- /dev/null +++ b/src/liblog_mng/src/liblog_mng.c @@ -0,0 +1,362 @@ +/*----------------------------------------------------------------------------*/ +/* $Workfile: liblog_mng.c $ */ +/*----------------------------------------------------------------------------*/ +/* $Author: agibert $ */ +/* $Date: 2008/11/12 02:25:22 $ */ +/* $Revision: 1.1 $ */ +/* $Label: $ */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBLOG_MNG_ +#define _LIBLOG_MNG_C_ + +#include "liblog_mng.h" + + + + + + + +/*----------------------------------------------------------------------------*/ +/* Open Log Manager */ +/*----------------------------------------------------------------------------*/ +/* Lib_Flag: Setup IOM init mode */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_LM_Library_Open( IMRT_LM_Config *Config_Ptr) +{ + IMRT_Module_Id module_id; + IMRT_Log_Type_Id log_type_id; + + + if( IMRG_LM_Module.Lib.Status != IMRD_LIB_STATUS_CLOSED) + { + IMRD_LM_LOG_ERROR_0( "Library not closed !"); + + return( IMRS_KO); + } + else + { + strcpy( IMRG_LM_Base.Config.Log_File, Config_Ptr->Log_File); + + if( strcmp( Config_Ptr->Log_File, "-") == 0) + { + IMRG_LM_Base.Stream_Out = stderr; + } + else + { + if( ( IMRG_LM_Base.Stream_Out = fopen( Config_Ptr->Log_File, "a")) == NULL) + { + IMRD_LM_LOG_ERROR_2( "Can't open log file [%s] (%d) !", IMRG_LM_Base.Config.Log_File, errno); + + return( IMRS_KO); + } + } + + + + IMRG_LM_Base.Config.Module_Nb = Config_Ptr->Module_Nb; + + for( module_id = 0; module_id < IMRG_LM_Base.Config.Module_Nb; module_id++) + { + for( log_type_id = 0; log_type_id < IMRD_LOG_TYPE_NB; log_type_id++) + { + IMRG_LM_Base.Config.Level_Tab[ log_type_id][ module_id] = Config_Ptr->Level_Tab[ log_type_id][ module_id]; + } + } + + IMRG_LM_Module.Lib.Status = IMRD_LIB_STATUS_OPENED; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Library opened !"); + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Close Log Manager */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_LM_Library_Close() +{ + if( IMRG_LM_Module.Lib.Status != IMRD_LIB_STATUS_OPENED) + { + IMRD_LM_LOG_ERROR_0( "Library not opened !"); + + return( IMRS_KO); + } + else + { + if( ( IMRG_LM_Base.Stream_Out != stderr) && ( fclose( IMRG_LM_Base.Stream_Out) == EOF)) + { + IMRD_LM_LOG_ERROR_2( "Can't close log file [%s] (%d) !", IMRG_LM_Base.Config.Log_File, errno); + + return( IMRS_KO); + } + + IMRG_LM_Module.Lib.Status = IMRD_LIB_STATUS_CLOSED; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Library closed !"); + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* LM_Stream_Out_Get */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +FILE *IMR_LM_Stream_Out_Get( void) +{ + if( IMRG_LM_Base.Stream_Out == NULL) + { + return( stderr); + } + else + { + return( IMRG_LM_Base.Stream_Out); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* LM_Log_Trigger */ +/*----------------------------------------------------------------------------*/ +/* Log_Type_Id: Type id of log */ +/* Log_Level: Level of log */ +/* Module_Ptr: Loger module pointer */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_LM_Log_Trigger( IMRT_Log_Type_Id Log_Type_Id, IMRT_Log_Level Log_Level, IMRT_Module *Module_Ptr) +{ + FILE *Stream_Out; + + + Stream_Out = IMR_LM_Stream_Out_Get(); + + if( ( Log_Type_Id < 0) || ( Log_Type_Id >= IMRD_LOG_TYPE_NB)) + { + fprintf( Stream_Out, "liblog_mng: %s: Invalid Log_Type_Id (%d) !\n", __FILE__, errno); + + return( IMRS_KO); + } + + if( IMRG_LM_Module.Lib.Status == IMRD_LIB_STATUS_OPENED) + { + if ( IMRG_LM_Base.Config.Level_Tab[ Log_Type_Id][ Module_Ptr->Id] != IMRD_LOG_LEVEL_UNSET) + { + if( Log_Level > IMRG_LM_Base.Config.Level_Tab[ Log_Type_Id][ Module_Ptr->Id]) + { + return( IMRS_OK); + } + } + else + { + if( Log_Level > IMRG_LM_Base.Config.Level_Tab[ Log_Type_Id][ IMRD_MODULE_ID_UNKNOWN]) + { + return( IMRS_OK); + } + } + } + else + { + if( Log_Type_Id == IMRD_LOG_TYPE_ID_TRACE) + { + return( IMRS_OK); + } + } + + return( IMRS_LM_LOG); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* LM_Log_Write */ +/*----------------------------------------------------------------------------*/ +/* Log_Type_Id: Type id of log */ +/* Log_Level: Level of log */ +/* Module_Ptr: Loger module pointer */ +/* File_Name: Loger file name */ +/* Line_Id: Loger line id */ +/* LF_Flag: Add or not a LF at EOF */ +/* Log_Fmt: Format string a la printf */ +/* ...: Optional args */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_LM_Log_Write( IMRT_Log_Type_Id Log_Type_Id, IMRT_Log_Level Log_Level, IMRT_Module *Module_Ptr, IMRT_File_Name File_Name, IMRT_Line_Id Line_Id, IMRT_Boolean LF_Flag, IMRT_Log_Fmt Log_Fmt, ...) +{ + va_list args; + FILE *Stream_Out; + IMRT_Status status; + char fmt[255]; + struct timeval cur_timeval; + struct tm *tm_ptr; + int rc; + + + Stream_Out = IMR_LM_Stream_Out_Get(); + + if( ( status = IMR_LM_Log_Trigger( Log_Type_Id, Log_Level, Module_Ptr)) != IMRS_LM_LOG) + { + return( status); + } + + gettimeofday( &cur_timeval, NULL); + + if( ( tm_ptr = localtime( &( cur_timeval.tv_sec))) == NULL) + { + fprintf( Stream_Out, "liblog_mng: %s: can't convert localtime (%d) !\n", __FILE__, errno); + + return( IMRS_KO); + } + + va_start( args, Log_Fmt); + + sprintf( fmt, "%02d/%02d/%02d %02d:%02d:%02d.%04d %3s %03d %-4s %-21s %-4d %s%s", + ( tm_ptr->tm_year - 100), tm_ptr->tm_mon, tm_ptr->tm_mday, tm_ptr->tm_hour, tm_ptr->tm_min, tm_ptr->tm_sec, ( cur_timeval.tv_usec / 100), + IMRG_LM_Base.Log_Type_Tab[ Log_Type_Id], Log_Level, Module_Ptr->Name, File_Name, Line_Id, + Log_Fmt, + ( ( LF_Flag == IMRD_TRUE) ? "\n" : "")); + + rc = vfprintf( Stream_Out, fmt, args); + + if( rc < 0) + { + fprintf(stderr, "liblog_mng: Can't log messages (%d) !!!\n", errno); + ND_Library_StdErr_Set( NULL); + return(IMRS_KO); + } + + fflush( Stream_Out); + + va_end( args); + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Log_Buffer_Id */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Ptr: buffer to identify */ +/* Log_Id_Struct_Ptr: Log_Id_Heap to use */ +/* Log_Id_Header_Ptr: message to log as header */ +/* Log_Type_Id: Type id of log */ +/* Log_Level: Level of log */ +/* Module_Ptr: Loger module pointer */ +/* File_Name: Loger file name */ +/* Line_Id: Loger line id */ +/* LF_Flag: Add or not a LF at EOF */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_LM_Log_Buffer_Id( IMRT_Buffer *Buffer_Ptr, IMRT_Log_Id_Struct *Log_Id_Struct_Ptr, IMRT_Log_Id_Header Log_Id_Header, IMRT_Log_Type_Id Log_Type_Id, IMRT_Log_Level Log_Level, IMRT_Module *Module_Ptr, IMRT_File_Name File_Name, IMRT_Line_Id Line_Id, IMRT_Boolean LF_Flag) +{ + IMRT_Status status; + char *log_string, *log_ptr, *buf_ptr; + int idx; + + + if( Log_Id_Struct_Ptr->Bit_Nb > 0 ) + { + if( Log_Id_Struct_Ptr->Log_Id_Bit_Ptr != NULL) + { + if( Buffer_Ptr->Data_Buf_Ptr != NULL) + { + /* allocation = taille total des Id + ( deux crochets + un espace entre chaque id ) * le nombre d'Id */ + + if( ( log_string = malloc( Log_Id_Struct_Ptr->Log_Size + ( 3 * Log_Id_Struct_Ptr->Bit_Nb) + 1)) != NULL) + { + for( idx = 0, log_ptr = log_string; idx < Log_Id_Struct_Ptr->Bit_Nb; idx++) + { + *(log_ptr++) = ' '; + *(log_ptr++) = '['; + + for( buf_ptr = Buffer_Ptr->Data_Buf_Ptr + Log_Id_Struct_Ptr->Log_Id_Bit_Ptr[ idx].Offset; + ( *buf_ptr != '\0') && ( buf_ptr < ( Buffer_Ptr->Data_Buf_Ptr + + Log_Id_Struct_Ptr->Log_Id_Bit_Ptr[ idx].Offset + + Log_Id_Struct_Ptr->Log_Id_Bit_Ptr[ idx].Size)); + buf_ptr++) + { + *(log_ptr++) = isprint( *buf_ptr) ? *buf_ptr : '.'; + } + + *(log_ptr++) = ']'; + } + + *log_ptr = '\0'; + + IMR_LM_Log_Write( Log_Type_Id, Log_Level, Module_Ptr, File_Name, Line_Id, LF_Flag, "%s%s", Log_Id_Header, log_string); + + free( log_string); + + status = IMRS_OK; + } + else + { + IMRD_LM_LOG_ERROR_1( "Allocation error ! (%d)", errno); + status = IMRS_KO; + } + + } + else + { + IMRD_LM_LOG_ERROR_0( "Buffer data NULL !"); + status = IMRS_KO; + } + } + else + { + IMRD_LM_LOG_ERROR_0( "Log_Id_Bit_Ptr Null !"); + status = IMRS_KO; + } + } + else + { + status = IMRS_OK; + } + + return( status); +} diff --git a/src/liblog_mng/src/liblog_mng.h b/src/liblog_mng/src/liblog_mng.h new file mode 100644 index 0000000..9874633 --- /dev/null +++ b/src/liblog_mng/src/liblog_mng.h @@ -0,0 +1,141 @@ +/*----------------------------------------------------------------------------*/ +/* File: liblog_mng.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _LIBLOG_MNG_H_ +#define _LIBLOG_MNG_H_ + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include +#include + + + + +/*----------------------------------------------------------------------------*/ +/* Lib Definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_LM_MODULE_ID ( IMRT_Module_Id) 1 +#define IMRD_LM_MODULE_NAME ( IMRT_Module_Name) "lm" +#define IMRD_LM_MODULE_NAME_LONG ( IMRT_Module_Name_Long) "Log Manager" +#define IMRD_LM_MODULE_VERSION ( IMRT_Module_Version) "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:22 $ $Workfile: liblog_mng.h $" + +#define IMRD_MODULE_PTR &IMRG_LM_Module + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Definitions */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_LM_Base +{ + IMRT_Log_Type_Name Log_Type_Tab[ IMRD_LOG_TYPE_NB]; + IMRT_LM_Config Config; + FILE *Stream_Out; +} IMRT_LM_Base; + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBLOG_MNG_C_ + +# endif + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Includes */ +/*----------------------------------------------------------------------------*/ + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBLOG_MNG_C_ + +IMRT_LM_Base IMRG_LM_Base = +{ + { IMRD_LOG_TYPE_NAME_UNKNOWN, IMRD_LOG_TYPE_NAME_TRACE, IMRD_LOG_TYPE_NAME_INFO, IMRD_LOG_TYPE_NAME_WARNING, IMRD_LOG_TYPE_NAME_ERROR}, + { "", 0, { 0 } }, + NULL +}; + + + +IMRT_Module IMRG_LM_Module = +{ + IMRD_LM_MODULE_ID, + IMRD_LM_MODULE_NAME, + IMRD_LM_MODULE_NAME_LONG, + IMRD_LM_MODULE_VERSION, + IMRD_MODULE_TYPE_LIBRARY, + { + IMRD_LIB_STATUS_CLOSED, + ( IMRT_Lib_Open *) &IMR_LM_Library_Open, + ( IMRT_Lib_Close *) &IMR_LM_Library_Close + } +}; + +# else + +extern IMRT_LM_Base IMRG_LM_Base; +extern IMRT_Module IMRG_LM_Module; + +# endif + + + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libmapping_mng/include/mapping_mng.h b/src/libmapping_mng/include/mapping_mng.h new file mode 100644 index 0000000..ed53e79 --- /dev/null +++ b/src/libmapping_mng/include/mapping_mng.h @@ -0,0 +1,159 @@ +/*----------------------------------------------------------------------------*/ +/* File: mapping_mng.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _MAPPING_MNG_H_ +#define _MAPPING_MNG_H_ + + + +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRD_MM_API definition */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBMAPPING_MNG_C_ +# define IMRD_MM_API +# else +# define IMRD_MM_API extern +# endif + + + + + + + +/*----------------------------------------------------------------------------*/ +/* MM_Config definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_MM_Config +{ + IMRT_Boolean XML_Format; +} IMRT_MM_Config; + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBMAPPING_MNG_ + +# else + +extern IMRT_Module IMRG_MM_Module; + +# endif + + + + + + + +/******************************************************************************/ +/* Mapping Manager API */ +/******************************************************************************/ + + + +/*----------------------------------------------------------------------------*/ +/* Open Mapping Manager */ +/*----------------------------------------------------------------------------*/ + +IMRD_MM_API IMRT_Status IMR_MM_Library_Open( IMRT_MM_Config *); + + + +/*----------------------------------------------------------------------------*/ +/* Close Mapping Manager */ +/*----------------------------------------------------------------------------*/ + +IMRD_MM_API IMRT_Status IMR_MM_Library_Close( void); + + + +/*----------------------------------------------------------------------------*/ +/* Buffer allocation */ +/*----------------------------------------------------------------------------*/ +/* (O) Buffer_Ptr_Ptr : Buffer pointer pointer */ +/*----------------------------------------------------------------------------*/ + +IMRD_MM_API IMRT_Status IMR_MM_Buffer_Alloc( IMRT_Buffer **); + + +/*----------------------------------------------------------------------------*/ +/* Buffer free */ +/*----------------------------------------------------------------------------*/ +/* (IO) Buffer_Ptr_Ptr : Buffer pointer pointer */ +/*----------------------------------------------------------------------------*/ + +IMRD_MM_API IMRT_Status IMR_MM_Buffer_Free( IMRT_Buffer **); + + +/*----------------------------------------------------------------------------*/ +/* Buffer check */ +/*----------------------------------------------------------------------------*/ +/* (I) Buffer_Ptr : Buffer pointer */ +/*----------------------------------------------------------------------------*/ + +IMRD_MM_API IMRT_Status IMR_MM_Buffer_Check (IMRT_Buffer *); + + +/*----------------------------------------------------------------------------*/ +/* Buffer list */ +/*----------------------------------------------------------------------------*/ +/* (I) Buffer_Ptr : Buffer pointer */ +/* (I) texte : Text to print */ +/*----------------------------------------------------------------------------*/ + +IMRD_MM_API IMRT_Status IMR_MM_Buffer_List( IMRT_Buffer *, char *); + + +/*----------------------------------------------------------------------------*/ +/* Buffer mapping */ +/*----------------------------------------------------------------------------*/ +/* (I) Output_Buffer_Ptr : Output buffer pointer */ +/* (I) Input_Buffer_Ptr : Input buffer pointer */ +/*----------------------------------------------------------------------------*/ + +IMRD_MM_API IMRT_Status IMR_MM_Buffer_Map( IMRT_Buffer *, IMRT_Buffer *); + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libmapping_mng/src/Makefile b/src/libmapping_mng/src/Makefile new file mode 100644 index 0000000..8be00f1 --- /dev/null +++ b/src/libmapping_mng/src/Makefile @@ -0,0 +1,81 @@ +#------------------------------------------------------------------------------ +# Local Makefile +#------------------------------------------------------------------------------ +# $Workfile: Makefile $ +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:22 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Var include +#------------------------------------------------------------------------------ + +include ../../Makefile_var.mk + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +TARGET= libmapping_mng$(SHLIB_SUFFIX) + +OBJ= libmapping_mng.o \ + map_scheduler.o \ + buffer_mng.o \ + cnv_hdl_pad_right.o \ + cnv_hdl_pad_left.o \ + cnv_hdl_pad_num.o \ + cnv_hdl_strip_right.o \ + cnv_hdl_strip_left.o \ + cnv_hdl_cut_right.o \ + cnv_hdl_strip_num.o \ + fmt_hdl_fixed.o \ + fmt_hdl_xml.o \ + fmt_hdl_dltd.o + +ifeq ($(TUX_SUPPORT),1) + OBJ+= fmt_hdl_fml.o +endif + +EXTRA_INC= + +EXTRA_LIB= + + + +#------------------------------------------------------------------------------ +# Rule include +#------------------------------------------------------------------------------ + +include ../../Makefile_rule.mk diff --git a/src/libmapping_mng/src/buffer_mng.c b/src/libmapping_mng/src/buffer_mng.c new file mode 100644 index 0000000..ed79e5f --- /dev/null +++ b/src/libmapping_mng/src/buffer_mng.c @@ -0,0 +1,1276 @@ +/*----------------------------------------------------------------------------*/ +/* File: buffer_mng.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _BUFFER_MNG_C_ + +#include "buffer_mng.h" + + +IMRT_Status MM_Buffer_DeInit() +{ + IMRT_Status status; + char *func_name = "MM_Buffer_DeInit"; + int indice; + IMRT_StrHdl_Fmt_Func *StrHdl_Fmt_dynamic_ptr; + IMRT_StrHdl_Cnv_Func *StrHdl_Cnv_dynamic_ptr; + + + status = IMRS_OK; + indice = 0; + StrHdl_Fmt_dynamic_ptr = NULL; + StrHdl_Cnv_dynamic_ptr = NULL; + + if ((IMRG_MM_StrHdl_Fmt_Func_Tab != NULL) && (IMRG_MM_StrHdl_Cnv_Func_Tab != NULL)) + { + while ( (status == IMRS_OK) + && (indice < IMRG_Taille_Fmt_Max) ) + { + StrHdl_Fmt_dynamic_ptr = &(IMRG_MM_StrHdl_Fmt_Func_Tab[indice]); + + if (( StrHdl_Fmt_dynamic_ptr != NULL) && (StrHdl_Fmt_dynamic_ptr->DeInit_Ptr != NULL)) + { + status = StrHdl_Fmt_dynamic_ptr->DeInit_Ptr(); + } + indice++; + } + + + indice = 0; + + while ( (status == IMRS_OK) + && (indice < IMRG_Taille_Cnv_Max) ) + { + StrHdl_Cnv_dynamic_ptr = &(IMRG_MM_StrHdl_Cnv_Func_Tab[indice]); + + if ((StrHdl_Cnv_dynamic_ptr != NULL) && (StrHdl_Cnv_dynamic_ptr->DeInit_Ptr != NULL)) + { + status = StrHdl_Cnv_dynamic_ptr->DeInit_Ptr(); + } + indice++; + } + } + + if ( IMRG_MM_StrHdl_Fmt_Func_Tab != NULL) + { + free( IMRG_MM_StrHdl_Fmt_Func_Tab ); + } + + if ( IMRG_MM_StrHdl_Cnv_Func_Tab != NULL) + { + free( IMRG_MM_StrHdl_Cnv_Func_Tab ); + } + + IMRG_Input_Buffer_Ptr = NULL; + IMRG_Output_Buffer_Ptr = NULL; + IMRG_Taille_Fmt_Max = 0; + IMRG_Taille_Cnv_Max = 0; + + + return ( status ); +} + +IMRT_Status MM_Buffer_Init() +{ + + IMRT_Status status; + char *func_name = "MM_Buffer_Init"; + + + status = IMRS_OK; + IMRG_Input_Buffer_Ptr = NULL; + IMRG_Output_Buffer_Ptr = NULL; + IMRG_Taille_Fmt_Max = 0; + IMRG_Taille_Cnv_Max = 0; + IMRG_MM_StrHdl_Fmt_Func_Tab = NULL; + IMRG_MM_StrHdl_Cnv_Func_Tab = NULL; + + handle = dlopen (NULL , RTLD_LAZY); + if (handle == NULL) + { + IMRD_LM_LOG_ERROR_1("dlopen failed [%s]" , dlerror()); + status = IMRS_KO; + } + + + status = IMR_SDM_Fmt_Proceed(IMR_MM_Fmt_Add); + + if ( status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1("Format proceed ended with status (%d)" , status); + } + else + { + status = IMR_SDM_Cnv_Proceed(IMR_MM_Cnv_Add); + if ( status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1("Conversion functions proceed ended with status (%d)" , status); + } + + } + + + return ( status ); + +} + + +IMRT_Status IMR_MM_Fmt_Add(IMRT_Fmt_Id Format_Id , IMRT_Fmt_Name Format_Name , IMRT_Fmt_Id Fmt_Id_Nb) +{ + IMRT_Status status; + char *func_name = "IMR_MM_Fmt_Add"; + size_t tableau_size; + IMRT_StrHdl_Fmt_Func *StrHdl_Fmt_dynamic_ptr; + char func_ptr_name[100]; + char ptr_name[100]; + IMRT_Boolean fmt_is_unknown; + IMRT_Boolean it_is_OK; + + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "Initialisation format demand : Begin"); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_2 , "Format Id : (%d) name : (%s)" , Format_Id , Format_Name); + + fmt_is_unknown = IMRD_FALSE; + it_is_OK = IMRD_TRUE; + status = IMRS_OK; + StrHdl_Fmt_dynamic_ptr = NULL; + + memset( func_ptr_name, '\0', sizeof(func_ptr_name) ); + memset( ptr_name, '\0', sizeof(ptr_name) ); + + if (strcmp(Format_Name,IMRD_FMT_NAME_UNKNOWN) == 0) + fmt_is_unknown = IMRD_TRUE; + + if (IMRG_MM_StrHdl_Fmt_Func_Tab == NULL) + { + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Format_Id Max : (%d)" , Fmt_Id_Nb); + tableau_size = (sizeof(IMRT_StrHdl_Fmt_Func) * Fmt_Id_Nb); + IMRG_MM_StrHdl_Fmt_Func_Tab = (IMRT_StrHdl_Fmt_Func *) malloc( tableau_size ); + if (IMRG_MM_StrHdl_Fmt_Func_Tab== NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("malloc IMRG_MM_StrHdl_Fmt_Func_Tab failed" ); + } + else + { + memset( IMRG_MM_StrHdl_Fmt_Func_Tab, '\0', tableau_size ); + IMRG_Taille_Fmt_Max = Fmt_Id_Nb; + } + } + + if (status == IMRS_OK) + { + StrHdl_Fmt_dynamic_ptr = &(IMRG_MM_StrHdl_Fmt_Func_Tab[Format_Id]); + strcpy( StrHdl_Fmt_dynamic_ptr->Nom , Format_Name); + + strcpy(ptr_name , "Init"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Init_Ptr = ( IMRT_MM_Fmt_Hdl_Init *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Init_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + + if (it_is_OK) + { + strcpy(ptr_name , "DeInit"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->DeInit_Ptr = ( IMRT_MM_Fmt_Hdl_DeInit *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->DeInit_Ptr == NULL) &&( !fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Data_Free"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Data_Free_Ptr = (IMRT_MM_Fmt_Hdl_Data_Free *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Data_Free_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Ident"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Ident_Ptr = (IMRT_MM_Fmt_Hdl_Ident *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Ident_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Open"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Open_Ptr = (IMRT_MM_Fmt_Hdl_Open *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Open_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Close"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Close_Ptr = (IMRT_MM_Fmt_Hdl_Close *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Close_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Data_List"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Data_List_Ptr = (IMRT_MM_Fmt_Hdl_Data_List *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Data_List_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Copy"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Copy_Ptr = (IMRT_MM_Fmt_Hdl_Copy *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Copy_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Flush"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Flush_Ptr = (IMRT_MM_Fmt_Hdl_Flush *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Flush_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Get"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Get_Ptr = (IMRT_MM_Fmt_Hdl_Get *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Get_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Convert"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Cnv_Ptr = (IMRT_MM_Fmt_Hdl_Cnv *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Cnv_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Put"); + sprintf(func_ptr_name,"MM_%s_StrHdl_%s",Format_Name,ptr_name); + StrHdl_Fmt_dynamic_ptr->Put_Ptr = (IMRT_MM_Fmt_Hdl_Put *)dlsym(handle , func_ptr_name); + if ((StrHdl_Fmt_dynamic_ptr->Put_Ptr == NULL) && (!fmt_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK && StrHdl_Fmt_dynamic_ptr->Init_Ptr != NULL) + { + status = StrHdl_Fmt_dynamic_ptr->Init_Ptr(); + if (status == IMRS_KO) + IMRD_LM_LOG_ERROR_0("Initialisation handlers failed" ); + } + + if (!it_is_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Pointeur null et format different de unknown" ); + IMRD_LM_LOG_ERROR_1("dlsym failed [%s]", dlerror()); + } + + } + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Initialisation format demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); + +} + +IMRT_Status IMR_MM_Cnv_Add(IMRT_Cnv_Id Conv_Id , IMRT_Cnv_Name Conv_Name , IMRT_Cnv_Id Conv_Id_Nb) +{ + IMRT_Status status; + char *func_name = "IMR_MM_Cnv_Add"; + size_t tableau_size; + IMRT_StrHdl_Cnv_Func *StrHdl_Cnv_dynamic_ptr; + char func_ptr_name[100]; + char ptr_name[100]; + IMRT_Boolean cnv_is_unknown; + IMRT_Boolean it_is_OK; + + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "Initialisation conversion function demand : Begin"); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_2 , "Conversion Id : (%d) name : (%s)" , Conv_Id , Conv_Name); + + + cnv_is_unknown = IMRD_FALSE; + it_is_OK = IMRD_TRUE; + status = IMRS_OK; + StrHdl_Cnv_dynamic_ptr = NULL; + + memset( func_ptr_name, '\0', sizeof(func_ptr_name) ); + memset( ptr_name, '\0', sizeof(ptr_name) ); + + if (strcmp(Conv_Name,IMRD_CNV_NAME_UNKNOWN)==0) + cnv_is_unknown = IMRD_TRUE; + + if (IMRG_MM_StrHdl_Cnv_Func_Tab == NULL) + { + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Conv_Id Max : (%d)" , Conv_Id_Nb); + tableau_size = (sizeof(IMRT_StrHdl_Cnv_Func) * Conv_Id_Nb); + IMRG_MM_StrHdl_Cnv_Func_Tab = (IMRT_StrHdl_Cnv_Func *) malloc( tableau_size ); + if (IMRG_MM_StrHdl_Cnv_Func_Tab== NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("malloc IMRG_MM_StrHdl_Cnv_Func_Tab failed" ); + } + else + { + memset( IMRG_MM_StrHdl_Cnv_Func_Tab, '\0', tableau_size ); + IMRG_Taille_Cnv_Max = Conv_Id_Nb; + } + } + + if (status == IMRS_OK) + { + StrHdl_Cnv_dynamic_ptr = &(IMRG_MM_StrHdl_Cnv_Func_Tab[Conv_Id]); + strcpy( StrHdl_Cnv_dynamic_ptr->Nom , Conv_Name); + strcpy(ptr_name , "Init"); + sprintf(func_ptr_name,"MM_%s_%s",Conv_Name,ptr_name); + StrHdl_Cnv_dynamic_ptr->Init_Ptr = ( IMRT_MM_Cnv_Init *)dlsym(handle , func_ptr_name); + if ((StrHdl_Cnv_dynamic_ptr->Init_Ptr == NULL) && (!cnv_is_unknown)) + it_is_OK = IMRD_FALSE; + + if (it_is_OK) + { + strcpy(ptr_name , "DeInit"); + sprintf(func_ptr_name,"MM_%s_%s",Conv_Name,ptr_name); + StrHdl_Cnv_dynamic_ptr->DeInit_Ptr = ( IMRT_MM_Cnv_DeInit *)dlsym(handle , func_ptr_name); + if ((StrHdl_Cnv_dynamic_ptr->DeInit_Ptr == NULL) && ( !cnv_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + if (it_is_OK) + { + strcpy(ptr_name , "Convert"); + sprintf(func_ptr_name,"MM_%s_%s",Conv_Name,ptr_name); + StrHdl_Cnv_dynamic_ptr->Convert_Ptr = (IMRT_MM_Convert *)dlsym(handle , func_ptr_name); + if ((StrHdl_Cnv_dynamic_ptr->Convert_Ptr == NULL) && ( !cnv_is_unknown)) + it_is_OK = IMRD_FALSE; + } + + + if (it_is_OK && StrHdl_Cnv_dynamic_ptr->Init_Ptr != NULL) + { + status = StrHdl_Cnv_dynamic_ptr->Init_Ptr(); + if (status == IMRS_KO) + IMRD_LM_LOG_ERROR_0("Initialisation convert failed" ); + } + + if (!it_is_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Pointeur null et Fonction de conversion differente de unknown" ); + IMRD_LM_LOG_ERROR_1("dlsym failed [%s]", dlerror()); + } + + } + + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Initialisation conversion function demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); + +} + + +IMRT_Status MM_Buffer_List( IMRT_Buffer *Buffer_Ptr, char *texte) +{ + char status_str[10]; + char flag_str[10]; + IMRT_Fmt_Id fmt_id; + IMRT_Status status; + + + status = IMRS_OK; + fmt_id = IMRD_FMT_ID_UNKNOWN; + + if (Buffer_Ptr == NULL) + { + IMRD_LM_LOG_WARNING_0("Buffer pointer NULL"); + } + else + { + switch( Buffer_Ptr->Status) + { + case IMRD_BUFFER_STATUS_ALLOCATED : strcpy( status_str, "ALLOCATED"); break; + case IMRD_BUFFER_STATUS_FREED : strcpy( status_str, "FREED"); break; + default : strcpy( status_str, "UNKNOWN"); break; + } + + switch (Buffer_Ptr->Flag) + { + case IMRD_BUFFER_FLAG_OPENED : strcpy( flag_str, "OPENED"); break; + case IMRD_BUFFER_FLAG_CLOSED : strcpy( flag_str, "CLOSED"); break; + default : strcpy( flag_str, "UNKNOWN"); break; + } + + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Buffer: [%s] Address: (0x%X)", texte, Buffer_Ptr); + + if( ( status = Buffer_Format_Check( Buffer_Ptr->Fmt_Id)) == IMRS_OK) + { + fmt_id = Buffer_Ptr->Fmt_Id; + } + else + { + fmt_id = IMRD_FMT_ID_UNKNOWN; + } + + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Appl_Id_Input: (%2d) Appl_Id_Output: (%2d) Dir_Id: (%2d)", Buffer_Ptr->Appl_Id_Input, Buffer_Ptr->Appl_Id_Output, Buffer_Ptr->Dir_Id); + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Fmt_Id: (%2d) [%9s] Msg_Id: (%2d)", Buffer_Ptr->Fmt_Id, IMRG_MM_StrHdl_Fmt_Func_Tab[fmt_id].Nom, Buffer_Ptr->Msg_Id); + IMRD_LM_LOG_TRACE_4( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Status: (%2d) [%9s] Flag: (%2d) [%7s]", Buffer_Ptr->Status, status_str, Buffer_Ptr->Flag, flag_str); + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Format attribute: [%s]" , Buffer_Ptr->FmtAttr_Value); + + if (IMRG_MM_StrHdl_Fmt_Func_Tab != NULL) + { + if ( IMRG_MM_StrHdl_Fmt_Func_Tab[fmt_id].Data_List_Ptr == NULL) + { + IMRD_LM_LOG_WARNING_1( "Null Fonction List for [%s] format", IMRG_MM_StrHdl_Fmt_Func_Tab[fmt_id].Nom); + } + else + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Data_List_Ptr(Buffer_Ptr); + } + } + } + + return ( status ); +} + +IMRT_Status MM_Buffer_Alloc (IMRT_Buffer **Buffer_Ptr_Ptr) +{ + IMRT_Buffer *buffer_Ptr; + IMRT_Status status; + char *func_name = "MM_Buffer_Alloc"; + + + status = IMRS_OK; + buffer_Ptr = (IMRT_Buffer *) malloc( sizeof(IMRT_Buffer) ); + + + if (buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (buffer_Ptr->FmtAttr_Value == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("buffer_Ptr->FmtAttr_Value NULL" ); + } + else + if (Buffer_Ptr_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + *Buffer_Ptr_Ptr = buffer_Ptr; + buffer_Ptr->Appl_Id_Input = IMRD_APPL_ID_UNKNOWN; + buffer_Ptr->Appl_Id_Output = IMRD_APPL_ID_UNKNOWN; + buffer_Ptr->Dir_Id = IMRD_DIR_ID_UNKNOWN; + buffer_Ptr->Fmt_Id = IMRD_FMT_ID_UNKNOWN; + strcpy(buffer_Ptr->FmtAttr_Value , IMRD_FMTATTR_NAME_UNKNOWN); + buffer_Ptr->Msg_Id = IMRD_MSG_ID_UNKNOWN; + buffer_Ptr->Status = IMRD_BUFFER_STATUS_UNKNOWN; + buffer_Ptr->Flag = IMRD_BUFFER_FLAG_UNKNOWN; + buffer_Ptr->Data_Buf_Ptr = NULL; + buffer_Ptr->Data_Tmp_Ptr = NULL; + buffer_Ptr->Data_Tmp_Changed = IMRD_FALSE; + buffer_Ptr->Data_Buf_Size = 0; + buffer_Ptr->Data_Buf_Len = 0; + } + + return ( status ); +} + +IMRT_Status Buffer_Data_Free( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "Buffer_Data_Free"; + + status = IMRS_OK; + + /* recherche du handler */ + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (IMRG_MM_StrHdl_Fmt_Func_Tab == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Format tab pointer NULL" ); + } + else + { + status = Buffer_Format_Check( Buffer_Ptr->Fmt_Id ); + + if (status == IMRS_OK) + { + if (IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Data_Free_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("fonction Data_Free = NULL pour format %s" , + IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Nom); + } + else + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Data_Free_Ptr(Buffer_Ptr); + } + } + } + + + return ( status ); +} + +IMRT_Status MM_Buffer_Free (IMRT_Buffer **Buffer_Ptr_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_Buffer_Free"; + + + status = IMRS_OK; + + if (*Buffer_Ptr_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + /* il y a des donnees dans Data_Buf_Ptr ou dans Data_Tmp_Ptr */ + if ( ((*Buffer_Ptr_Ptr)->Status == IMRD_BUFFER_STATUS_ALLOCATED) || + ((*Buffer_Ptr_Ptr)->Flag == IMRD_BUFFER_FLAG_OPENED) ) + { + status = Buffer_Data_Free( *Buffer_Ptr_Ptr ); + } + free(*Buffer_Ptr_Ptr); + *Buffer_Ptr_Ptr = NULL; + } + + return ( status ) ; +} + +IMRT_Status MM_Buffer_Clear (IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_Buffer_Clear"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + /* il y a des donnees dans Data_Buf_Ptr ou dans Data_Tmp_Ptr */ + if ( (Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) || + (Buffer_Ptr->Flag == IMRD_BUFFER_FLAG_OPENED) ) + { + status = Buffer_Data_Free( Buffer_Ptr); + } + if (status == IMRS_OK) + { + Buffer_Ptr->Fmt_Id = IMRD_FMT_ID_UNKNOWN; + Buffer_Ptr->Msg_Id = IMRD_MSG_ID_UNKNOWN; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_UNKNOWN; + Buffer_Ptr->Flag = IMRD_BUFFER_FLAG_UNKNOWN; + } + } + + return ( status ); +} + +IMRT_Status Buffer_Format_Check( IMRT_Fmt_Id Format ) +{ + IMRT_Status status; + char *func_name = "Buffer_Format_Check"; + + status = IMRS_OK; + + if ( (Format >= 0) && (Format < IMRG_Taille_Fmt_Max)) + status =IMRS_OK; + else + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Format %d incorrect" , Format ); + } + + return ( status ); +} + +IMRT_Status MM_Buffer_Ident_Update( IMRT_Buffer *Buffer_Ptr, + IMRT_Fmt_Id Format, + IMRT_FmtAttr_Value Fmt_Attr , + IMRT_Msg_Id Type) +{ + IMRT_Status status; + char *func_name = "MM_Buffer_Ident_Update"; + + status = IMRS_OK; + + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->FmtAttr_Value == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer_Ptr->FmtAttr_Value NULL" ); + } + if (Fmt_Attr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("FmtAttr NULL" ); + } + else + { + status = Buffer_Format_Check( Format ); + if (status == IMRS_OK) + { + /* si le buffer est ouvert le fermer avant de changer de format */ + if ( (Buffer_Ptr->Flag == IMRD_BUFFER_FLAG_OPENED) + && ( (Buffer_Ptr->Fmt_Id != Format) || + (strcmp(Buffer_Ptr->FmtAttr_Value,Fmt_Attr) !=0) ) ) + { + status = MM_Buffer_Close(Buffer_Ptr); + } + } + if (status == IMRS_OK) + { + Buffer_Ptr->Fmt_Id = Format; + strcpy(Buffer_Ptr->FmtAttr_Value , Fmt_Attr); + Buffer_Ptr->Msg_Id = Type; + } + } + + return ( status ); +} + +IMRT_Status MM_Buffer_Ident(IMRT_Msg_Id Msg_Id_Ident , IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_Buffer_Ident"; + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + if (IMRG_MM_StrHdl_Fmt_Func_Tab == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Format tab pointer NULL" ); + } + else + { + if (Buffer_Ptr->Flag != IMRD_BUFFER_FLAG_OPENED) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer not open" ); + } + else + { + status = Buffer_Format_Check(Buffer_Ptr->Fmt_Id); + if (status == IMRS_OK) + { + if (IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Ident_Ptr == NULL) + { + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "fonction Ident = NULL pour format %s" , + IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Nom); + } + else + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Ident_Ptr(&Msg_Id_Ident, Buffer_Ptr); + } + } + if (status == IMRS_OK) + { + Buffer_Ptr->Msg_Id = Msg_Id_Ident; + } + } + } + } + + + return ( status ); + +} + + +IMRT_Status MM_Buffer_Open( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Fmt_Id format_temp; + short indice; + IMRT_Status status; + char *func_name = "MM_Buffer_Open"; + + + status = IMRS_OK; + indice = 0; + format_temp = IMRD_FMT_ID_UNKNOWN; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + format_temp = Buffer_Ptr->Fmt_Id; + if (Buffer_Ptr->Flag !=IMRD_BUFFER_FLAG_OPENED) + { + + /* controle validite du format */ + status = Buffer_Format_Check( format_temp ); + + if (IMRG_MM_StrHdl_Fmt_Func_Tab == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Format tab pointer NULL" ); + } + else + { + /* format non identifie */ + if ( format_temp == IMRD_FMT_ID_UNKNOWN ) + { + if ( Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer not allocated" ); + } + else + { + indice = 0; + status = IMRS_BAD_FORMAT; + while ( (status == IMRS_BAD_FORMAT) + && (indice < IMRG_Taille_Fmt_Max) ) + { + if (IMRG_MM_StrHdl_Fmt_Func_Tab[indice].Open_Ptr == NULL) + { + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "fonction Open = NULL pour format %s" , + IMRG_MM_StrHdl_Fmt_Func_Tab[indice].Nom); + } + else + { format_temp = indice; + status = IMRG_MM_StrHdl_Fmt_Func_Tab[indice].Open_Ptr( Buffer_Ptr); + } + indice++; + } + } + } + /* format identifie */ + else + { + if (status == IMRS_OK) + { + if (IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Open_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("fonction Open = NULL pour format %s" , + IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Nom); + } + else + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Open_Ptr( Buffer_Ptr); + } + } + } + } + + if (status == IMRS_OK) + { + Buffer_Ptr->Flag = IMRD_BUFFER_FLAG_OPENED; + if (Buffer_Ptr->Fmt_Id != format_temp) + Buffer_Ptr->Fmt_Id = format_temp; + + } + } + } + + + return ( status ); +} + +IMRT_Status MM_Buffer_Close(IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_Buffer_Close"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + if (Buffer_Ptr->Flag !=IMRD_BUFFER_FLAG_CLOSED) + { + status = Buffer_Format_Check( Buffer_Ptr->Fmt_Id ); + if (status == IMRS_OK) + { + if (Buffer_Ptr->Flag == IMRD_BUFFER_FLAG_OPENED) + { + if (IMRG_MM_StrHdl_Fmt_Func_Tab == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Format tab pointer NULL" ); + } + else + { + if (IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Close_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("fonction Close = NULL pour format %s" , + IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Nom); + } + else + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[Buffer_Ptr->Fmt_Id].Close_Ptr(Buffer_Ptr); + } + } + } + } + if (status == IMRS_OK) + { + Buffer_Ptr->Flag = IMRD_BUFFER_FLAG_CLOSED; + } + } + } + + return ( status ); +} + +/* La fonction suivante n'est pas implementee pour le moment */ +/* Le nom des applications n'est connue que du static data manager */ +IMRT_Status Buffer_Application_Check( IMRT_Appl_Id Application ) +{ + IMRT_Status status; + char *func_name = "Buffer_Application_Check"; + + + status =IMRS_OK; + + + + return ( status ); +} + +IMRT_Status Buffer_Direction_Check( IMRT_Dir_Id Direction ) +{ + IMRT_Status status; + char *func_name = "Buffer_Direction_Check"; + + + if ((Direction == IMRD_DIR_ID_UNKNOWN) || + (Direction == IMRD_DIR_ID_IN ) || + (Direction == IMRD_DIR_ID_OUT ) ) + status =IMRS_OK; + else + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Incorrect direction %d" , Direction ); + } + + + return ( status ); +} + +IMRT_Status Buffer_Statut_Check( IMRT_Buffer_Status Statut ) +{ + IMRT_Status status; + char *func_name = "Buffer_Statut_Check"; + + + if ((Statut == IMRD_BUFFER_STATUS_UNKNOWN ) || + (Statut == IMRD_BUFFER_STATUS_ALLOCATED) || + (Statut == IMRD_BUFFER_STATUS_FREED ) ) + status =IMRS_OK; + else + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Incorrect status %d" , Statut ); + } + + return ( status ); +} + +IMRT_Status Buffer_Etat_Check( IMRT_Buffer_Flag Flag ) +{ + IMRT_Status status; + char *func_name = "Buffer_Etat_Check"; + + + if ((Flag == IMRD_BUFFER_FLAG_UNKNOWN) || + (Flag == IMRD_BUFFER_FLAG_OPENED ) || + (Flag == IMRD_BUFFER_FLAG_CLOSED ) ) + status =IMRS_OK; + else + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Incorrect Flag %d" , Flag ) + } + + return ( status ); +} + +IMRT_Status MM_Buffer_Check( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_Buffer_Check"; + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + if ( ( Buffer_Application_Check(Buffer_Ptr->Appl_Id_Input ) == IMRS_OK ) && + ( Buffer_Application_Check(Buffer_Ptr->Appl_Id_Output ) == IMRS_OK ) && + ( Buffer_Direction_Check (Buffer_Ptr->Dir_Id ) == IMRS_OK ) && + ( Buffer_Format_Check (Buffer_Ptr->Fmt_Id ) == IMRS_OK ) && + ( Buffer_Statut_Check (Buffer_Ptr->Status ) == IMRS_OK ) && + ( Buffer_Etat_Check (Buffer_Ptr->Flag ) == IMRS_OK ) ) + status = IMRS_OK; + else + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer check failed" ); + } + } + + return ( status ); +} + +IMRT_Status MM_Buffer_Copy( IMRT_Buffer *Output_Buffer_Ptr, IMRT_Buffer *Input_Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_Buffer_Copy"; + + + status = IMRS_OK; + + + if (Input_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Input buffer pointer NULL" ); + } + else + if (Output_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Output buffer pointer NULL" ); + } + else + if (IMRG_MM_StrHdl_Fmt_Func_Tab == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Format tab pointer NULL" ); + } + else + { + /* buffer non identifie => demande identification */ + if ( (Input_Buffer_Ptr->Fmt_Id == IMRD_FMT_ID_UNKNOWN) || (Input_Buffer_Ptr->Msg_Id == IMRD_MSG_ID_UNKNOWN) ) + { + status = MM_Buffer_Open( Input_Buffer_Ptr ); + } + + /* s'assurer que les donnees sont dans Data_Buf */ + if ( status == IMRS_OK ) + { + if (IMRG_MM_StrHdl_Fmt_Func_Tab[Input_Buffer_Ptr->Fmt_Id].Flush_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("fonction Flush = NULL pour format %s" , + IMRG_MM_StrHdl_Fmt_Func_Tab[Input_Buffer_Ptr->Fmt_Id].Nom); + } + else + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[Input_Buffer_Ptr->Fmt_Id].Flush_Ptr(Input_Buffer_Ptr); + } + } + + /* reinitialiser le buffer destinataire */ + if (status == IMRS_OK) + { + status = MM_Buffer_Clear( Output_Buffer_Ptr ); + } + + /* mise a jour du format et du type du buffer destinataire */ + if (status == IMRS_OK) + { + status = MM_Buffer_Ident_Update(Output_Buffer_Ptr, + Input_Buffer_Ptr->Fmt_Id, + Input_Buffer_Ptr->FmtAttr_Value, + Input_Buffer_Ptr->Msg_Id); + } + + /* mise a jour des applications et direction du buffer destinataire */ + if (status == IMRS_OK) + { + Output_Buffer_Ptr->Appl_Id_Input = Input_Buffer_Ptr->Appl_Id_Input ; + Output_Buffer_Ptr->Appl_Id_Output = Input_Buffer_Ptr->Appl_Id_Output ; + Output_Buffer_Ptr->Dir_Id = Input_Buffer_Ptr->Dir_Id ; + } + + + /* mise a jour de l'attribut du format du buffer destinataire */ + if (status == IMRS_OK) + { + strcpy(Output_Buffer_Ptr->FmtAttr_Value , Input_Buffer_Ptr->FmtAttr_Value) ; + } + + + /* copie des donnees du buffer source dans le buffer destinataire */ + if (status == IMRS_OK) + { + if (IMRG_MM_StrHdl_Fmt_Func_Tab[Input_Buffer_Ptr->Fmt_Id].Copy_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("fonction Copy = NULL pour format %s" , + IMRG_MM_StrHdl_Fmt_Func_Tab[Input_Buffer_Ptr->Fmt_Id].Nom); + } + else + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[Input_Buffer_Ptr->Fmt_Id].Copy_Ptr(Output_Buffer_Ptr, + Input_Buffer_Ptr); + } + } + if (status == IMRS_OK) + { + Output_Buffer_Ptr->Flag = IMRD_BUFFER_FLAG_CLOSED; + } + } + + + return ( status ); +} + +IMRT_Status MM_Buffer_Map(IMRT_Buffer *Output_Buffer_Ptr, + IMRT_Buffer *Input_Buffer_Ptr, + IMRT_MsgMap *MsgMap_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_Buffer_Map"; + + status = IMRS_OK; + + if (Input_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Input buffer pointer NULL" ); + } + else + if (Output_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Output buffer pointer NULL" ); + } + else + { + if ( ( Input_Buffer_Ptr->Flag != IMRD_BUFFER_FLAG_OPENED ) || + ( Output_Buffer_Ptr->Flag != IMRD_BUFFER_FLAG_OPENED ) ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer input or output not open" ); + } + else + { + IMRG_Input_Buffer_Ptr = Input_Buffer_Ptr; + IMRG_Output_Buffer_Ptr = Output_Buffer_Ptr; + status = IMR_SDM_MsgMap_Proceed( MsgMap_Ptr, IMR_MM_Buffer_FieldMap); + if (status != IMRS_OK) + IMRD_LM_LOG_ERROR_1("MsgMap proceed ended with status (%d)" , status); + IMRG_Input_Buffer_Ptr = NULL; + IMRG_Output_Buffer_Ptr = NULL; + } + } + + + return ( status ); +} + +IMRT_Status IMR_MM_Buffer_FieldMap( IMRT_Field *Field_Output_Ptr , IMRT_Field *Field_Input_Ptr ) +{ + IMRT_Buffer *buffer_ptr; + IMRT_Buffer_Data *data_In_ptr; + IMRT_Buffer_Data *data_Out_ptr; + IMRT_Status status; + size_t field_len; + IMRT_Boolean cnv_OK; + char *func_name = "IMR_MM_Buffer_FieldMap"; + + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Field map demand : Begin"); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Input name : (%s) Field Output name : (%s)" , Field_Input_Ptr->Name , Field_Output_Ptr->Name); + + status = IMRS_OK; + cnv_OK =IMRD_TRUE; + data_In_ptr = NULL; + data_Out_ptr = NULL; + buffer_ptr = NULL; + field_len = 0L; + + if (IMRG_Input_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Input buffer pointer NULL" ); + } + else + if (IMRG_Output_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Output buffer pointer NULL" ); + } + else + if (IMRG_MM_StrHdl_Fmt_Func_Tab == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Format tab pointer NULL" ); + } + else + { + buffer_ptr = IMRG_Input_Buffer_Ptr; + if (IMRG_MM_StrHdl_Fmt_Func_Tab[buffer_ptr->Fmt_Id].Get_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("fonction Get = NULL pour format %s" , + IMRG_MM_StrHdl_Fmt_Func_Tab[buffer_ptr->Fmt_Id].Nom); + } + else + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[buffer_ptr->Fmt_Id].Get_Ptr(&data_In_ptr, + Field_Input_Ptr, + buffer_ptr , + &field_len ); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_2 , "Data and len after get [%s] : (%ld)",data_In_ptr,field_len); + } + + + if (status == IMRS_OK) + { + buffer_ptr = IMRG_Output_Buffer_Ptr; + if (IMRG_MM_StrHdl_Fmt_Func_Tab[buffer_ptr->Fmt_Id].Cnv_Ptr == NULL) + { + cnv_OK = IMRD_FALSE; + IMRD_LM_LOG_WARNING_1("fonction de convertion nulle pour handler de format %s" , + IMRG_MM_StrHdl_Fmt_Func_Tab[buffer_ptr->Fmt_Id].Nom); + } + else + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[buffer_ptr->Fmt_Id].Cnv_Ptr(&data_Out_ptr, + data_In_ptr, + Field_Output_Ptr, + &field_len, + IMRG_MM_StrHdl_Cnv_Func_Tab); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_2 , "Data and len after convert [%s] : (%ld)",data_Out_ptr,field_len); + } + } + + if (status == IMRS_OK) + { + if (IMRG_MM_StrHdl_Fmt_Func_Tab[buffer_ptr->Fmt_Id].Put_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("fonction Put = NULL pour format %s" , + IMRG_MM_StrHdl_Fmt_Func_Tab[buffer_ptr->Fmt_Id].Nom); + if (cnv_OK) + { + free(data_Out_ptr); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "liberation du data_Out_ptr" ); + } + else + { + free(data_In_ptr); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "liberation du data_In_ptr" ); + } + } + else + { + if (cnv_OK) + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[buffer_ptr->Fmt_Id].Put_Ptr(data_Out_ptr, + Field_Output_Ptr, + buffer_ptr, + field_len); + } + else + { + status = IMRG_MM_StrHdl_Fmt_Func_Tab[buffer_ptr->Fmt_Id].Put_Ptr(data_In_ptr, + Field_Output_Ptr, + buffer_ptr, + field_len); + } + } + } + } + + MM_Buffer_List( buffer_ptr, " Buffer after put"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Field map demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} diff --git a/src/libmapping_mng/src/buffer_mng.h b/src/libmapping_mng/src/buffer_mng.h new file mode 100644 index 0000000..4caec3c --- /dev/null +++ b/src/libmapping_mng/src/buffer_mng.h @@ -0,0 +1,175 @@ +/*----------------------------------------------------------------------------*/ +/* File: buffer_mng.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _BUFFER_MNG_H_ +#define _BUFFER_MNG_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Local Includes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _BUFFER_MNG_C_ + +# include "fmt_hdl_fixed.h" +# include "fmt_hdl_xml.h" + +# ifdef TUX_SUPPORT +# include "fmt_hdl_fml.h" +# endif /* TUX_SUPPORT */ + +# include "cnv_hdl_pad_right.h" +# include "cnv_hdl_pad_left.h" +# include "cnv_hdl_strip_right.h" +# include "cnv_hdl_strip_left.h" +# include "cnv_hdl_cut_right.h" +# include "cnv_hdl_strip_num.h" + +#endif + +/*----------------------------------------------------------------------------*/ +/* Local definition */ +/*----------------------------------------------------------------------------*/ + +#ifdef _BUFFER_MNG_C_ + + + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Init)( void ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_DeInit)( void ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Data_Free)( IMRT_Buffer * ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Ident)( IMRT_Msg_Id *, IMRT_Buffer * ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Open)( IMRT_Buffer * ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Close)( IMRT_Buffer * ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Data_List)( IMRT_Buffer * ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Copy)( IMRT_Buffer * , IMRT_Buffer * ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Flush)( IMRT_Buffer * ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Get)( IMRT_Buffer_Data ** , IMRT_Field * , IMRT_Buffer * , size_t * ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Cnv)( IMRT_Buffer_Data ** , IMRT_Buffer_Data * , IMRT_Field * , size_t *, IMRT_StrHdl_Cnv_Func * ); + typedef IMRT_Status (IMRT_MM_Fmt_Hdl_Put)( IMRT_Buffer_Data * , IMRT_Field * , IMRT_Buffer * , size_t ); + + typedef struct IMRT_StrHdl_Fmt_Func + + { IMRT_Fmt_Name Nom; + IMRT_MM_Fmt_Hdl_Init *Init_Ptr; + IMRT_MM_Fmt_Hdl_DeInit *DeInit_Ptr; + IMRT_MM_Fmt_Hdl_Data_Free *Data_Free_Ptr; + IMRT_MM_Fmt_Hdl_Ident *Ident_Ptr; + IMRT_MM_Fmt_Hdl_Open *Open_Ptr; + IMRT_MM_Fmt_Hdl_Close *Close_Ptr; + IMRT_MM_Fmt_Hdl_Data_List *Data_List_Ptr; + IMRT_MM_Fmt_Hdl_Copy *Copy_Ptr; + IMRT_MM_Fmt_Hdl_Flush *Flush_Ptr; + IMRT_MM_Fmt_Hdl_Get *Get_Ptr; + IMRT_MM_Fmt_Hdl_Cnv *Cnv_Ptr; + IMRT_MM_Fmt_Hdl_Put *Put_Ptr; + + } IMRT_StrHdl_Fmt_Func; + + + + +#endif + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +#ifdef _BUFFER_MNG_C_ + + void *handle; + IMRT_Buffer *IMRG_Input_Buffer_Ptr; + IMRT_Buffer *IMRG_Output_Buffer_Ptr; + + + IMRT_StrHdl_Fmt_Func *IMRG_MM_StrHdl_Fmt_Func_Tab; + IMRT_Fmt_Id IMRG_Taille_Fmt_Max; + + IMRT_Cnv_Id IMRG_Taille_Cnv_Max; + + +#endif + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _BUFFER_MNG_C_ + + IMRT_Status MM_Buffer_Init ( void ); + IMRT_Status MM_Buffer_DeInit ( void ); + IMRT_Status IMR_MM_Fmt_Add ( IMRT_Fmt_Id , IMRT_Fmt_Name , IMRT_Fmt_Id ); + IMRT_Status IMR_MM_Cnv_Add ( IMRT_Cnv_Id , IMRT_Cnv_Name , IMRT_Cnv_Id ); + IMRT_Status MM_Buffer_List ( IMRT_Buffer * , char * ); + IMRT_Status MM_Buffer_Alloc ( IMRT_Buffer ** ); + IMRT_Status MM_Buffer_Free ( IMRT_Buffer ** ); + IMRT_Status MM_Buffer_Clear ( IMRT_Buffer * ); + IMRT_Status MM_Buffer_Ident ( IMRT_Msg_Id , IMRT_Buffer *); + IMRT_Status MM_Buffer_Open ( IMRT_Buffer * ); + IMRT_Status MM_Buffer_Close ( IMRT_Buffer * ); + IMRT_Status MM_Buffer_Copy ( IMRT_Buffer * , IMRT_Buffer * ); + IMRT_Status MM_Buffer_Map ( IMRT_Buffer * , IMRT_Buffer * , IMRT_MsgMap * ); + IMRT_Status MM_Buffer_Ident_Update ( IMRT_Buffer * , IMRT_Fmt_Id , IMRT_FmtAttr_Value , IMRT_Msg_Id ); + IMRT_Status Buffer_Application_Check( IMRT_Appl_Id ); + IMRT_Status Buffer_Direction_Check ( IMRT_Dir_Id ); + IMRT_Status Buffer_Format_Check ( IMRT_Fmt_Id ); + IMRT_Status Buffer_Statut_Check ( IMRT_Buffer_Status ); + IMRT_Status Buffer_Etat_Check ( IMRT_Buffer_Flag ); + IMRT_Status MM_Buffer_Check ( IMRT_Buffer * ); + IMRT_Status Buffer_Data_Free ( IMRT_Buffer * ); + IMRT_Status IMR_MM_Buffer_FieldMap ( IMRT_Field * , IMRT_Field * ); + +#else + + extern IMRT_Status MM_Buffer_Init ( void ); + extern IMRT_Status MM_Buffer_DeInit ( void ); + extern IMRT_Status MM_Buffer_List ( IMRT_Buffer * , char * ); + extern IMRT_Status MM_Buffer_Alloc ( IMRT_Buffer ** ); + extern IMRT_Status MM_Buffer_Free ( IMRT_Buffer ** ); + extern IMRT_Status MM_Buffer_Clear ( IMRT_Buffer * ); + extern IMRT_Status MM_Buffer_Ident ( IMRT_Msg_Id , IMRT_Buffer *); + extern IMRT_Status MM_Buffer_Open ( IMRT_Buffer * ); + extern IMRT_Status MM_Buffer_Close ( IMRT_Buffer * ); + extern IMRT_Status MM_Buffer_Check ( IMRT_Buffer * ); + extern IMRT_Status MM_Buffer_Copy ( IMRT_Buffer * , IMRT_Buffer * ); + extern IMRT_Status MM_Buffer_Map ( IMRT_Buffer * , IMRT_Buffer * , IMRT_MsgMap * ); + extern IMRT_Status MM_Buffer_Ident_Update ( IMRT_Buffer * , IMRT_Fmt_Id , IMRT_FmtAttr_Value , IMRT_Msg_Id ); + +#endif + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libmapping_mng/src/cnv_hdl_cut_right.c b/src/libmapping_mng/src/cnv_hdl_cut_right.c new file mode 100644 index 0000000..5dd9161 --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_cut_right.c @@ -0,0 +1,113 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_cut_right.c */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _CNV_HANDLER_CUT_RIGHT_C_ + +#include "cnv_hdl_cut_right.h" + +IMRT_Status MM_Cut_Right_Init() +{ + return (IMRS_OK); +} + +IMRT_Status MM_Cut_Right_DeInit() +{ + + return (IMRS_OK); +} + +IMRT_Status MM_Cut_Right_Convert(IMRT_Buffer_Data *Data_Out_Ptr , IMRT_Buffer_Data *Data_In_Ptr , size_t * Len_Ptr , size_t size , IMRT_Cnv_Attr Cnv_Attr ) +{ + IMRT_Status status; + int nb_char_to_rm; + int cpt; + /*char attr;*/ + size_t len_tmp; + IMRT_Buffer_Data *data_tmp_ptr; + char *func_name = "MM_Cut_Right_Convert"; + + + status = IMRS_OK; + cpt = 0; + + if (Len_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Len pointer NULL" ); + status = IMRS_KO; + } + else if (Data_In_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Input pointer NULL" ); + status = IMRS_KO; + } + else + if (Data_Out_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Output pointer NULL" ); + status = IMRS_KO; + } + else + { + len_tmp = *Len_Ptr ; + nb_char_to_rm = atoi(Cnv_Attr); + if (len_tmp > size) + { + IMRD_LM_LOG_ERROR_0("Field Len > size" ); + status = IMRS_KO; + } + else + if ((size_t)nb_char_to_rm > len_tmp) + { + IMRD_LM_LOG_ERROR_2("Nb of char : (%d) > len (%ld)" , nb_char_to_rm , len_tmp); + status = IMRS_KO; + } + else + if (nb_char_to_rm <= 0) + { + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Nb of char : (%d) Nothing to delete" , nb_char_to_rm); + status = IMRD_STATUS_NOTHING_TO_DO; + } + } + + if (status == IMRS_OK) + { + + memcpy(Data_Out_Ptr , Data_In_Ptr , (len_tmp - nb_char_to_rm)); + + Data_Out_Ptr[(len_tmp - nb_char_to_rm)] = '\0'; + + *Len_Ptr = (len_tmp - nb_char_to_rm) ; + } + + if (status == IMRD_STATUS_NOTHING_TO_DO) + status = IMRS_OK; + + return (status); +} + diff --git a/src/libmapping_mng/src/cnv_hdl_cut_right.h b/src/libmapping_mng/src/cnv_hdl_cut_right.h new file mode 100644 index 0000000..5539402 --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_cut_right.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_cut_right.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _CNV_HANDLER_CUT_RIGHT_H_ +#define _CNV_HANDLER_CUT_RIGHT_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _CNV_HANDLER_CUT_RIGHT_C_ + + IMRT_Status MM_Cut_Right_Init ( void ); + IMRT_Status MM_Cut_Right_DeInit ( void ); + IMRT_Status MM_Cut_Right_Convert( IMRT_Buffer_Data * , IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#else + extern IMRT_Status MM_Cut_Right_Init ( void ); + extern IMRT_Status MM_Cut_Right_DeInit ( void ); + extern IMRT_Status MM_Cut_Right_Convert( IMRT_Buffer_Data * , IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#endif + +/*----------------------------------------------------------------------------*/ + +#endif + + diff --git a/src/libmapping_mng/src/cnv_hdl_pad_left.c b/src/libmapping_mng/src/cnv_hdl_pad_left.c new file mode 100644 index 0000000..3e10458 --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_pad_left.c @@ -0,0 +1,111 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_pad_left.c */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _CNV_HANDLER_PAD_LEFT_C_ + +#include "cnv_hdl_pad_left.h" + +IMRT_Status MM_Pad_Left_Init() +{ + return (IMRS_OK); +} + +IMRT_Status MM_Pad_Left_DeInit() +{ + + return (IMRS_OK); +} + +IMRT_Status MM_Pad_Left_Convert(IMRT_Buffer_Data *Data_Out_Ptr , IMRT_Buffer_Data *Data_In_Ptr , size_t * Len_Ptr , size_t size , IMRT_Cnv_Attr Cnv_Attr ) +{ + IMRT_Status status; + char attr; + size_t compteur; + size_t len_tmp; + size_t offset; + IMRT_Buffer_Data *data_tmp_ptr; + char *func_name = "MM_Pad_Left_Convert"; + + + + status = IMRS_OK; + compteur = 0L; + offset = 0L; + attr = '0'; + + len_tmp = *Len_Ptr ; + + if (Len_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Len pointer NULL" ); + status = IMRS_KO; + } + else + if (Data_In_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Input pointer NULL" ); + status = IMRS_KO; + } + else + if (Data_Out_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Output pointer NULL" ); + status = IMRS_KO; + } + else + { + len_tmp = *Len_Ptr ; + if (len_tmp > size) + { + IMRD_LM_LOG_ERROR_0("Field Len > size" ); + status = IMRS_KO; + } + else + { + offset = size - len_tmp; + + attr = Cnv_Attr[0]; + + memcpy(Data_Out_Ptr + offset , Data_In_Ptr , len_tmp); + data_tmp_ptr = Data_Out_Ptr; + + for (compteur = 0L ; compteur < offset ; compteur++) + { + data_tmp_ptr[compteur] = attr; + } + + data_tmp_ptr[size] = '\0'; + *Len_Ptr = size ; + } + } + + + return (status); +} + diff --git a/src/libmapping_mng/src/cnv_hdl_pad_left.h b/src/libmapping_mng/src/cnv_hdl_pad_left.h new file mode 100644 index 0000000..3077683 --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_pad_left.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_pad_left.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _CNV_HANDLER_PAD_LEFT_H_ +#define _CNV_HANDLER_PAD_LEFT_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _CNV_HANDLER_PAD_LEFT_C_ + + IMRT_Status MM_Pad_Left_Init ( void ); + IMRT_Status MM_Pad_Left_DeInit ( void ); + IMRT_Status MM_Pad_Left_Convert( IMRT_Buffer_Data * ,IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#else + extern IMRT_Status MM_Pad_Left_Init ( void ); + extern IMRT_Status MM_Pad_Left_DeInit ( void ); + extern IMRT_Status MM_Pad_Left_Convert( IMRT_Buffer_Data * ,IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#endif + +/*----------------------------------------------------------------------------*/ + +#endif + + diff --git a/src/libmapping_mng/src/cnv_hdl_pad_num.c b/src/libmapping_mng/src/cnv_hdl_pad_num.c new file mode 100644 index 0000000..6c49359 --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_pad_num.c @@ -0,0 +1,81 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_pad_left.c */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _CNV_HANDLER_PAD_NUM_C_ + +#include "cnv_hdl_pad_num.h" + + + +IMRT_Status MM_Pad_Num_Init() +{ + return (IMRS_OK); +} + +IMRT_Status MM_Pad_Num_DeInit() +{ + + return (IMRS_OK); +} + +IMRT_Status MM_Pad_Num_Convert(IMRT_Buffer_Data *Data_Out_Ptr , IMRT_Buffer_Data *Data_In_Ptr , size_t * Len_Ptr , size_t size , IMRT_Cnv_Attr Cnv_Attr ) +{ + IMRT_Status status; + char attr_space[2] ; + char attr_zero[2] ; + IMRT_Buffer_Data *Tmp_Ptr; + char *func_name = "MM_Pad_Num_Convert"; + + + status = IMRS_OK; + strcpy(attr_space , " "); + strcpy(attr_zero , "0"); + + Tmp_Ptr = (IMRT_Buffer_Data *)malloc(size + 1L); + if (Tmp_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Memory allocation failed"); + status = IMRS_KO; + } + else + { + memset(Tmp_Ptr, '\0', (size + 1L)); + + status = MM_Strip_Num_Convert(Tmp_Ptr , Data_In_Ptr , Len_Ptr , size , attr_zero ); + + if (status == IMRS_OK) + status = MM_Pad_Left_Convert(Data_Out_Ptr , Tmp_Ptr , Len_Ptr , size , attr_zero ); + } + if (Tmp_Ptr != NULL) + free(Tmp_Ptr); + + return (status); + +} + diff --git a/src/libmapping_mng/src/cnv_hdl_pad_num.h b/src/libmapping_mng/src/cnv_hdl_pad_num.h new file mode 100644 index 0000000..4e71b9f --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_pad_num.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_pad_left.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _CNV_HANDLER_PAD_NUM_H_ +#define _CNV_HANDLER_PAD_NUM_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _CNV_HANDLER_PAD_LEFT_C_ + + IMRT_Status MM_Pad_Num_Init ( void ); + IMRT_Status MM_Pad_Num_DeInit ( void ); + IMRT_Status MM_Pad_Num_Convert( IMRT_Buffer_Data * ,IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#else + extern IMRT_Status MM_Pad_Num_Init ( void ); + extern IMRT_Status MM_Pad_Num_DeInit ( void ); + extern IMRT_Status MM_Pad_Num_Convert( IMRT_Buffer_Data * ,IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#endif + +/*----------------------------------------------------------------------------*/ + +#endif + + diff --git a/src/libmapping_mng/src/cnv_hdl_pad_right.c b/src/libmapping_mng/src/cnv_hdl_pad_right.c new file mode 100644 index 0000000..6774a07 --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_pad_right.c @@ -0,0 +1,100 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_pad_right.c */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _CNV_HANDLER_PAD_RIGHT_C_ + +#include "cnv_hdl_pad_right.h" + +IMRT_Status MM_Pad_Right_Init() +{ + return (IMRS_OK); +} + +IMRT_Status MM_Pad_Right_DeInit() +{ + + return (IMRS_OK); +} + + +IMRT_Status MM_Pad_Right_Convert(IMRT_Buffer_Data *Data_Out_Ptr , IMRT_Buffer_Data *Data_In_Ptr , size_t * Len_Ptr , size_t size , IMRT_Cnv_Attr Cnv_Attr ) +{ + IMRT_Status status; + char attr; + size_t compteur; + size_t len_tmp; + IMRT_Buffer_Data *data_tmp_ptr; + char *func_name = "MM_Pad_Right_Convert"; + + + status = IMRS_OK; + compteur = 0L; + attr = '0'; + + len_tmp = *Len_Ptr ; + + if (len_tmp > size) + { + IMRD_LM_LOG_ERROR_0("Field Len > size" ); + status = IMRS_KO; + } + else + { + if (Data_In_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Input pointer NULL" ); + status = IMRS_KO; + } + else + if (Data_Out_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Output pointer NULL" ); + status = IMRS_KO; + } + else + { + attr = Cnv_Attr[0]; + + memcpy(Data_Out_Ptr , Data_In_Ptr , len_tmp); + data_tmp_ptr = Data_Out_Ptr + len_tmp ; + + for (compteur = 0L ; compteur < (size - len_tmp) ; compteur++) + { + data_tmp_ptr[compteur] = attr; + } + + data_tmp_ptr[compteur] = '\0'; + *Len_Ptr = size ; + } + } + + + return (status); +} + diff --git a/src/libmapping_mng/src/cnv_hdl_pad_right.h b/src/libmapping_mng/src/cnv_hdl_pad_right.h new file mode 100644 index 0000000..ea54a7f --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_pad_right.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_pad_right.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _CNV_HANDLER_PAD_RIGHT_H_ +#define _CNV_HANDLER_PAD_RIGHT_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _CNV_HANDLER_PAD_RIGHT_C_ + + IMRT_Status MM_Pad_Right_Init ( void ); + IMRT_Status MM_Pad_Right_DeInit ( void ); + IMRT_Status MM_Pad_Right_Convert( IMRT_Buffer_Data * ,IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#else + extern IMRT_Status MM_Pad_Right_Init ( void ); + extern IMRT_Status MM_Pad_Right_DeInit ( void ); + extern IMRT_Status MM_Pad_Right_Convert( IMRT_Buffer_Data * ,IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#endif + +/*----------------------------------------------------------------------------*/ + +#endif + + diff --git a/src/libmapping_mng/src/cnv_hdl_strip_left.c b/src/libmapping_mng/src/cnv_hdl_strip_left.c new file mode 100644 index 0000000..c9b295f --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_strip_left.c @@ -0,0 +1,128 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_strip_left.c */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _CNV_HANDLER_STRIP_LEFT_C_ + +#include "cnv_hdl_strip_left.h" + +IMRT_Status MM_Strip_Left_Init() +{ + return (IMRS_OK); +} + +IMRT_Status MM_Strip_Left_DeInit() +{ + + return (IMRS_OK); +} + +IMRT_Status MM_Strip_Left_Convert(IMRT_Buffer_Data *Data_Out_Ptr , IMRT_Buffer_Data *Data_In_Ptr , size_t * Len_Ptr , size_t size , IMRT_Cnv_Attr Cnv_Attr ) +{ + IMRT_Status status; + char attr; + size_t compteur; + size_t len_tmp; + IMRT_Buffer_Data *data_tmp_ptr; + IMRT_Buffer_Data *data_tmp_idx_ptr; + char *func_name = "MM_Strip_Left_Convert"; + + + status = IMRS_OK; + + + if (Len_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Len pointer NULL" ); + status = IMRS_KO; + } + else + if (Data_In_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Input pointer NULL" ); + status = IMRS_KO; + } + else + if (Data_Out_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Output pointer NULL" ); + status = IMRS_KO; + } + else + { + len_tmp = *Len_Ptr ; + if (len_tmp > size) + { + IMRD_LM_LOG_ERROR_0("Field Len > size" ); + status = IMRS_KO; + } + else + { + attr = Cnv_Attr[0]; + + data_tmp_ptr = (IMRT_Buffer_Data *)malloc(size + 1L); + if(data_tmp_ptr == NULL) + { + /*erreur allocation */ + IMRD_LM_LOG_ERROR_0("Memory allocation failed"); + status = IMRS_KO; + } + else + { + memset( data_tmp_ptr, '\0' , (size + 1L) ); + data_tmp_idx_ptr = data_tmp_ptr; + memcpy(data_tmp_ptr , Data_In_Ptr , len_tmp) ; + data_tmp_ptr[len_tmp] = '\0'; + memset( Data_Out_Ptr, '\0' , (size + 1L) ); + + compteur = 0L; + + while ((data_tmp_idx_ptr[0L] == attr) && (compteur < *Len_Ptr)) + { + data_tmp_idx_ptr++; + len_tmp--; + compteur++; + } + + data_tmp_idx_ptr[len_tmp] = '\0'; + + memcpy(Data_Out_Ptr , data_tmp_idx_ptr , len_tmp + 1L); + + *Len_Ptr = len_tmp ; + + free(data_tmp_ptr); + } + } + + } + + + return (status); + +} + diff --git a/src/libmapping_mng/src/cnv_hdl_strip_left.h b/src/libmapping_mng/src/cnv_hdl_strip_left.h new file mode 100644 index 0000000..a40b107 --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_strip_left.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_strip_left.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _CNV_HANDLER_STRIP_LEFT_H_ +#define _CNV_HANDLER_STRIP_LEFT_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _CNV_HANDLER_STRIP_LEFT_C_ + + IMRT_Status MM_Strip_Left_Init ( void ); + IMRT_Status MM_Strip_Left_DeInit ( void ); + IMRT_Status MM_Strip_Left_Convert( IMRT_Buffer_Data * , IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#else + extern IMRT_Status MM_Strip_Left_Init ( void ); + extern IMRT_Status MM_Strip_Left_DeInit ( void ); + extern IMRT_Status MM_Strip_Left_Convert( IMRT_Buffer_Data * , IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#endif + +/*----------------------------------------------------------------------------*/ + +#endif + + diff --git a/src/libmapping_mng/src/cnv_hdl_strip_num.c b/src/libmapping_mng/src/cnv_hdl_strip_num.c new file mode 100644 index 0000000..c89bc8f --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_strip_num.c @@ -0,0 +1,80 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_strip_num.c */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _CNV_HANDLER_STRIP_NUM_C_ + +#include "cnv_hdl_strip_num.h" + +IMRT_Status MM_Strip_Num_Init() +{ + return (IMRS_OK); +} + +IMRT_Status MM_Strip_Num_DeInit() +{ + + return (IMRS_OK); +} + +IMRT_Status MM_Strip_Num_Convert(IMRT_Buffer_Data *Data_Out_Ptr , IMRT_Buffer_Data *Data_In_Ptr , size_t * Len_Ptr , size_t size , IMRT_Cnv_Attr Cnv_Attr ) +{ + IMRT_Status status; + char attr_space[2] ; + char attr_zero[2] ; + IMRT_Buffer_Data *Data_Tmp_Ptr; + char *func_name = "MM_Strip_Num_Convert"; + + + status = IMRS_OK; + strcpy(attr_space , " "); + strcpy(attr_zero , "0"); + + Data_Tmp_Ptr = (IMRT_Buffer_Data *)malloc(size + 1L); + if (Data_Tmp_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Memory allocation failed"); + status = IMRS_KO; + } + else + { + memset(Data_Tmp_Ptr, '\0', (size + 1L)); + + status = MM_Strip_Left_Convert(Data_Tmp_Ptr , Data_In_Ptr , Len_Ptr , size , attr_space ); + + if (status == IMRS_OK) + status = MM_Strip_Left_Convert(Data_Out_Ptr , Data_Tmp_Ptr , Len_Ptr , size , attr_zero ); + } + + if(Data_Tmp_Ptr != NULL) + free(Data_Tmp_Ptr); + + return (status); + +} + diff --git a/src/libmapping_mng/src/cnv_hdl_strip_num.h b/src/libmapping_mng/src/cnv_hdl_strip_num.h new file mode 100644 index 0000000..282cb20 --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_strip_num.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_strip_num.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _CNV_HANDLER_STRIP_NUM_H_ +#define _CNV_HANDLER_STRIP_NUM_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _CNV_HANDLER_STRIP_NUM_C_ + + IMRT_Status MM_Strip_Num_Init ( void ); + IMRT_Status MM_Strip_Num_DeInit ( void ); + IMRT_Status MM_Strip_Num_Convert( IMRT_Buffer_Data * , IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#else + extern IMRT_Status MM_Strip_Num_Init ( void ); + extern IMRT_Status MM_Strip_Num_DeInit ( void ); + extern IMRT_Status MM_Strip_Num_Convert( IMRT_Buffer_Data * , IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#endif + +/*----------------------------------------------------------------------------*/ + +#endif + + diff --git a/src/libmapping_mng/src/cnv_hdl_strip_right.c b/src/libmapping_mng/src/cnv_hdl_strip_right.c new file mode 100644 index 0000000..a314387 --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_strip_right.c @@ -0,0 +1,105 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_strip_right.c */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _CNV_HANDLER_STRIP_RIGHT_C_ + +#include "cnv_hdl_strip_right.h" + +IMRT_Status MM_Strip_Right_Init() +{ + return (IMRS_OK); +} + +IMRT_Status MM_Strip_Right_DeInit() +{ + + return (IMRS_OK); +} + +IMRT_Status MM_Strip_Right_Convert(IMRT_Buffer_Data *Data_Out_Ptr , IMRT_Buffer_Data *Data_In_Ptr , size_t * Len_Ptr , size_t size , IMRT_Cnv_Attr Cnv_Attr ) +{ + IMRT_Status status; + char attr; + size_t len_tmp; + IMRT_Buffer_Data *data_tmp_ptr; + char *func_name = "MM_Strip_Right_Convert"; + + + status = IMRS_OK; + + + if (Len_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Len pointer NULL" ); + status = IMRS_KO; + } + else + if (Data_In_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Input pointer NULL" ); + status = IMRS_KO; + } + else + if (Data_Out_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Output pointer NULL" ); + status = IMRS_KO; + } + else + { + len_tmp = *Len_Ptr ; + if (len_tmp > size) + { + IMRD_LM_LOG_ERROR_0("Field Len > size" ); + status = IMRS_KO; + } + else + { + attr = Cnv_Attr[0]; + + data_tmp_ptr = Data_In_Ptr + len_tmp ; + + + while ((data_tmp_ptr > Data_In_Ptr) && (*(--data_tmp_ptr) == attr) ) + { + len_tmp--; + } + + if (Data_Out_Ptr != Data_In_Ptr) + memcpy(Data_Out_Ptr , Data_In_Ptr , len_tmp); + Data_Out_Ptr[len_tmp] = '\0'; + + *Len_Ptr = len_tmp ; + } + } + + + return (status); +} + diff --git a/src/libmapping_mng/src/cnv_hdl_strip_right.h b/src/libmapping_mng/src/cnv_hdl_strip_right.h new file mode 100644 index 0000000..acbd5f4 --- /dev/null +++ b/src/libmapping_mng/src/cnv_hdl_strip_right.h @@ -0,0 +1,59 @@ +/*----------------------------------------------------------------------------*/ +/* File: cnv_hdl_strip_right.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _CNV_HANDLER_STRIP_RIGHT_H_ +#define _CNV_HANDLER_STRIP_RIGHT_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _CNV_HANDLER_STRIP_RIGHT_C_ + + IMRT_Status MM_Strip_Right_Init ( void ); + IMRT_Status MM_Strip_Right_DeInit ( void ); + IMRT_Status MM_Strip_Right_Convert( IMRT_Buffer_Data * , IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#else + extern IMRT_Status MM_Strip_Right_Init ( void ); + extern IMRT_Status MM_Strip_Right_DeInit ( void ); + extern IMRT_Status MM_Strip_Right_Convert( IMRT_Buffer_Data * , IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +#endif + +/*----------------------------------------------------------------------------*/ + +#endif + + diff --git a/src/libmapping_mng/src/field.tbls.h b/src/libmapping_mng/src/field.tbls.h new file mode 100644 index 0000000..c581e0d --- /dev/null +++ b/src/libmapping_mng/src/field.tbls.h @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------*/ +/* File: field.tbls.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +/* fname fldid */ +/* ----- ----- */ +#define FML_MSG_TXT ((FLDID32)201327012) /* number: 420 type: carray */ diff --git a/src/libmapping_mng/src/fmt_hdl_dltd.c b/src/libmapping_mng/src/fmt_hdl_dltd.c new file mode 100644 index 0000000..a415295 --- /dev/null +++ b/src/libmapping_mng/src/fmt_hdl_dltd.c @@ -0,0 +1,1079 @@ +/*----------------------------------------------------------------------------*/ +/* File: fmt_hdl_dltd.c */ +/* Comptage des occurences : la premiere est numerotee 0 */ +/* La zone de donnees Data_Tmp_Ptr du buffer contient la prochaine occurence */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _DELIMITED_HANDLER_C_ + +#include "fmt_hdl_dltd.h" + +IMRT_Status MM_Delimited_StrHdl_Init() +{ + IMRG_Delimited_Buffer_Ident_Ptr = NULL; + return (IMRS_OK); +} + +IMRT_Status MM_Delimited_StrHdl_DeInit() +{ + return (IMRS_OK); +} + +IMRT_Status Delimited_Hdl_DataBuf_Alloc( IMRT_Buffer *Buffer_Ptr, size_t Taille_Alloc ) +{ + IMRT_Buffer_Data *data_Ptr; + IMRT_Status status; + IMRT_Delimited_TmpId * TmpId_Ptr; + char *func_name = "Delimited_Hdl_DataBuf_Alloc"; + + + status = IMRS_OK; + data_Ptr = NULL; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) + { + if (Taille_Alloc > Buffer_Ptr->Data_Buf_Size) + { + data_Ptr = (IMRT_Buffer_Data *) realloc ( (void *) Buffer_Ptr->Data_Buf_Ptr, Taille_Alloc ); + if (data_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Realloc error"); + } + else + { + memset( data_Ptr + Buffer_Ptr->Data_Buf_Size, '\0', Taille_Alloc - Buffer_Ptr->Data_Buf_Size ); + Buffer_Ptr->Data_Buf_Ptr = data_Ptr; + Buffer_Ptr->Data_Buf_Size = Taille_Alloc; + } + } + } + else + { + data_Ptr = (IMRT_Buffer_Data *) malloc ( Taille_Alloc ); + if (data_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Malloc error"); + } + else + { + memset( data_Ptr, '\0', Taille_Alloc ); + Buffer_Ptr->Data_Buf_Ptr = data_Ptr; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_ALLOCATED; + Buffer_Ptr->Data_Buf_Size = Taille_Alloc; + Buffer_Ptr->Data_Buf_Len = 0; + } + + if (status == IMRS_OK) + { + TmpId_Ptr = (IMRT_Delimited_TmpId *) malloc ( sizeof(IMRT_Delimited_TmpId)); + if (TmpId_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Malloc error"); + free(Buffer_Ptr->Data_Buf_Ptr); + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_FREED; + Buffer_Ptr->Data_Buf_Size = 0; + } + else + { + /* Initialisation de la premiere occurence a 0 */ + memset( TmpId_Ptr, '\0', sizeof(IMRT_Delimited_TmpId) ); + TmpId_Ptr->TmpId = 0; + Buffer_Ptr->Data_Tmp_Ptr = (IMRT_Buffer_Data *)(TmpId_Ptr); + } + } + + } + + + return ( status ); +} + +IMRT_Status MM_Delimited_StrHdl_Data_Free( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_Delimited_StrHdl_Data_Free"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) + { + if(Buffer_Ptr->Data_Buf_Ptr != NULL) + { + free(Buffer_Ptr->Data_Buf_Ptr); + } + Buffer_Ptr->Data_Buf_Ptr = NULL; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_FREED; + Buffer_Ptr->Data_Buf_Size = 0; + Buffer_Ptr->Data_Buf_Len = 0; + if(Buffer_Ptr->Data_Tmp_Ptr != NULL) + free(Buffer_Ptr->Data_Tmp_Ptr); + Buffer_Ptr->Data_Tmp_Ptr = NULL; + Buffer_Ptr->Data_Tmp_Changed = IMRD_FALSE; + Buffer_Ptr->Data_Tmp_Ptr = NULL; + } + + return ( status ); +} + +IMRT_Status Delimited_Hdl_Format_Ident( IMRT_Buffer *Buffer_Ptr ) +{ + IMRT_Status status; + char *func_name = "Delimited_Hdl_Format_Ident"; + + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) + { + status = IMRS_OK; + } + else + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer not allocated"); + } + + + return ( status ); +} + +IMRT_Status MM_Delimited_StrHdl_Ident( IMRT_Msg_Id *Msg_Id_Ident_Ptr, + IMRT_Buffer *Buffer_Ptr ) +{ + + IMRT_Fmt_Id Format; + IMRT_Status status; + IMRT_Msg_Id *Msg_Id_Tmp; + char *func_name = "MM_Delimited_StrHdl_Ident"; + + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Msg_Id_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Msg_Id_Ident_Ptr NULL" ); + } + else + { + Format = Buffer_Ptr->Fmt_Id; + Msg_Id_Tmp = Msg_Id_Ident_Ptr; + status = IMRS_OK; + + IMRG_Delimited_Buffer_Ident_Ptr = Buffer_Ptr; + /* Le Msg_Id transmis au SDM est le point de depart de l'identification */ + /* C'est egalement le resultat qui sera inclus dans le buffer */ + status = IMR_SDM_MsgIdent_Proceed(Format, + Msg_Id_Tmp, + IMR_MM_Delimited_StrHdl_Field_Value, + IMR_MM_Delimited_StrHdl_Field_Exist, + IMR_MM_Delimited_StrHdl_Msg_Size); + IMRG_Delimited_Buffer_Ident_Ptr = NULL; + + Msg_Id_Ident_Ptr = Msg_Id_Tmp; + } + + return ( status ); + +} + +IMRT_Status Delimited_Hdl_TmpId_Init( IMRT_Buffer *Buffer_Ptr , short nb_occ) +{ + IMRT_Status status; + IMRT_Delimited_TmpId * TmpId_Ptr; + char *func_name = "Delimited_Hdl_TmpId_Init"; + + status = IMRS_OK; + TmpId_Ptr = NULL; + TmpId_Ptr = (IMRT_Delimited_TmpId *) malloc ( sizeof(IMRT_Delimited_TmpId)); + if (TmpId_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Malloc error"); + } + else + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer null"); + } + else + { + /* Initialisation de la premiere occurence a 0 */ + memset( TmpId_Ptr, '\0', sizeof(IMRT_Delimited_TmpId) ); + TmpId_Ptr->TmpId = nb_occ; + Buffer_Ptr->Data_Tmp_Ptr = (IMRT_Buffer_Data *)(TmpId_Ptr); + } + + + return status; +} + + + +IMRT_Status Delimited_Hdl_Occ_Count( IMRT_Buffer_Data *data_ptr , short *nb_occ , IMRT_FmtAttr_Value attr) +{ + IMRT_Status status; + IMRT_Buffer_Data *deb_data_ptr; + IMRT_Boolean loop_end; + short cpt; + char indicateur[2]; + char *delim_ptr; + IMRT_FmtAttr_Value delimiteur; + char *func_name = "Delimited_Hdl_Occ_Count"; + + status = IMRS_OK; + deb_data_ptr = NULL; + loop_end = IMRD_FALSE; + + + if (nb_occ == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Nb occ pointer null"); + } + else + if ((data_ptr == NULL) || (strcmp(attr , "")==0)) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Error : data pointer NULL or attribute is an empty string"); + } + + if ( status == IMRS_OK ) + { + strcpy(delimiteur , ""); + strncpy(indicateur , attr , 1); + indicateur[1] = '\0'; + delim_ptr = NULL; + delim_ptr = (attr); + delim_ptr++; + strcpy(delimiteur , delim_ptr); + + + /* Controle de validite de l'indicateur */ + if ((strcmp(indicateur , "S") != 0) && (strcmp(indicateur , "T") != 0)) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Indicateur non correct [%s]",indicateur); + } + } + + + + if (status == IMRS_OK) + { + if (strcmp(data_ptr , "") == 0) + { + cpt = 0; + } + else + { + /* La premiŠre occurence est la 0 */ + cpt = 0; + /* positionnement au debut de la chaine */ + deb_data_ptr = data_ptr; + /* boucle de comptage des occurrences */ + while (!loop_end) + { + deb_data_ptr = (IMRT_Buffer_Data *)strstr((const char *)deb_data_ptr , (const char *)delimiteur); + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_2, "attr [%s]" , delimiteur); + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_2, "deb_data_ptr [%s]" , deb_data_ptr); + + if (deb_data_ptr != NULL) + { + cpt++; + deb_data_ptr++; + } + else + loop_end = IMRD_TRUE; + } + + } + /* si l'indicateur est S il faut rajouter une occurence */ + if ((cpt != 0)&&(strcmp(indicateur , "S") == 0)) + cpt++; + + *nb_occ = cpt; + } + + return status; +} + + +IMRT_Status MM_Delimited_StrHdl_Open( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Msg_Id type_temp; + IMRT_Status status; + IMRT_Delimited_TmpId *TmpId_Ptr; + IMRT_Boolean flag_init; + short nb_occ; + char *func_name = "MM_Delimited_StrHdl_Open"; + + + + status = IMRS_OK; + nb_occ = 0; + flag_init = IMRD_FALSE; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + type_temp = Buffer_Ptr->Msg_Id; + if (Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_2, "Le buffer n'a pas le status allocated"); + /* Cas d'open du buffer en ecriture */ + /* le type du message est passe */ + /* par le SDM : il doit donc etre connu */ + if (type_temp == IMRD_MSG_ID_UNKNOWN) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Msg Id unknown"); + } + else + { + status = Delimited_Hdl_DataBuf_Alloc( Buffer_Ptr, DELIMITED_TAILLE_ALLOC ); + } + } + else /* le status est allocated */ + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_2, "Le buffer a le status allocated"); + + /* comptage du nombre d'occurences */ + status = Delimited_Hdl_Occ_Count( Buffer_Ptr->Data_Buf_Ptr , &nb_occ , Buffer_Ptr->FmtAttr_Value); + if (Buffer_Ptr->Data_Tmp_Ptr != NULL) + { + TmpId_Ptr = (IMRT_Delimited_TmpId *)Buffer_Ptr->Data_Tmp_Ptr; + if (TmpId_Ptr->TmpId != nb_occ) + { + flag_init = IMRD_TRUE; + free(Buffer_Ptr->Data_Tmp_Ptr); + } + } + else + { + flag_init = IMRD_TRUE; + } + + if ((status == IMRS_OK) && (flag_init == IMRD_TRUE)) + { + /* initialisation de Data_Tmp_Ptr avec le nombre d'occurence */ + status = Delimited_Hdl_TmpId_Init(Buffer_Ptr , nb_occ); + } + + + if (status == IMRS_OK) + { + /* controle du format (inutile actuellement) */ + status = Delimited_Hdl_Format_Ident( Buffer_Ptr ) ; + if (status != IMRS_OK) + { + status = IMRS_BAD_FORMAT; + } + } + } + } + + return ( status ); +} + + + +IMRT_Status MM_Delimited_StrHdl_Close( IMRT_Buffer *Buffer_Ptr) +{ + char *func_name = "MM_Delimited_StrHdl_Close"; + IMRT_Status status; + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + status = MM_Delimited_StrHdl_Flush( Buffer_Ptr ); + if ((status == IMRS_OK) && (Buffer_Ptr->Data_Tmp_Ptr != NULL)) + { + free(Buffer_Ptr->Data_Tmp_Ptr); + Buffer_Ptr->Data_Tmp_Ptr = NULL; + } + } + + return ( status ); +} + +IMRT_Status MM_Delimited_StrHdl_Flush( IMRT_Buffer *Buffer_Ptr) +{ + char *func_name = "MM_Delimited_StrHdl_Flush"; + + return (IMRS_OK); +} + + + +IMRT_Status MM_Delimited_StrHdl_Data_List( IMRT_Buffer *Buffer_Ptr) +{ + + if (Buffer_Ptr == NULL) + { + IMRD_LM_LOG_WARNING_0("Buffer pointer NULL" ); + } + else + { + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Data_Buf_Ptr_Size: (%d) Data_Buf_Ptr_Len: (%d) Data_Buf_Ptr: (0x%X)", Buffer_Ptr->Data_Buf_Size, Buffer_Ptr->Data_Buf_Len, Buffer_Ptr->Data_Buf_Ptr); + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_2, "Buffer_List: Data_Buf: [%s]", Buffer_Ptr->Data_Buf_Ptr); + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Data_Tmp_Changed: (%d) Data_Tmp_Ptr: (0x%X)", Buffer_Ptr->Data_Tmp_Changed, Buffer_Ptr->Data_Tmp_Ptr); + if (Buffer_Ptr->Data_Tmp_Ptr != NULL) + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_2, "Buffer_List: TmpId: (%d)", (short )( ( (IMRT_Delimited_TmpId *)(Buffer_Ptr->Data_Tmp_Ptr))->TmpId)); + } + + return (IMRS_OK); +} + + + +IMRT_Status MM_Delimited_StrHdl_Copy( IMRT_Buffer *Output_Buffer_Ptr, IMRT_Buffer *Input_Buffer_Ptr ) +{ + IMRT_Status status; + char *func_name = "MM_Delimited_StrHdl_Copy"; + + + status = IMRS_OK; + + if (Input_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Input buffer pointer NULL" ); + } + else + if (Output_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Output buffer pointer NULL" ); + } + else + /* controle donnees dans Input_Buffer */ + if (Input_Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer input not allocated"); + } + /* le buffer destinataire ne doit pas comporter de données */ + else if ( ( Output_Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) || + ( Output_Buffer_Ptr->Data_Tmp_Ptr != NULL) ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer output not allocated or Data_Tmp_Ptr no NULL"); + } + else + { + status = Delimited_Hdl_DataBuf_Alloc(Output_Buffer_Ptr, Input_Buffer_Ptr->Data_Buf_Size); + if (status == IMRS_OK) + { + memcpy( Output_Buffer_Ptr->Data_Buf_Ptr, + Input_Buffer_Ptr->Data_Buf_Ptr, + Input_Buffer_Ptr->Data_Buf_Size); + Output_Buffer_Ptr->Data_Buf_Len = Input_Buffer_Ptr->Data_Buf_Len; + if (Input_Buffer_Ptr->Data_Tmp_Ptr != NULL) + { + memcpy( Output_Buffer_Ptr->Data_Tmp_Ptr, + Input_Buffer_Ptr->Data_Tmp_Ptr, + sizeof(IMRT_Delimited_TmpId)); + } + } + } + + + return ( status ); +} + +IMRT_Status Delimited_Hdl_Field_Exist(IMRT_Field *Field_Ptr , IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "Delimited_Hdl_Field_Exist"; + + + status = IMRS_OK; + + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field pointer NULL" ); + } + else + if (Field_Ptr->Delimited.Id >= ((IMRT_Delimited_TmpId *)(Buffer_Ptr->Data_Tmp_Ptr))->TmpId) + { + status = IMRS_NO_IDENT; + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Field not exist"); + } + + + return ( status ); + +} + +IMRT_Status MM_Delimited_StrHdl_Get(IMRT_Buffer_Data **Data_Ptr_Ptr, IMRT_Field *Field_Ptr, + IMRT_Buffer *Buffer_Ptr , size_t *len ) +{ + IMRT_Buffer_Data *data_ptr; + IMRT_Buffer_Data *deb_data_ptr; + IMRT_Buffer_Data *end_data_ptr; + IMRT_Status status; + IMRT_Status status_ret; + char *delim_ptr; + IMRT_FmtAttr_Value delimiteur; + size_t sizeTmp; + size_t delimLen; + char indicateur[2]; + short indice; + + char *func_name = "MM_Delimited_StrHdl_Get"; + + + status = IMRS_OK; + deb_data_ptr = NULL; + end_data_ptr = NULL; + sizeTmp = 0L; + indice = 0; + + if (Data_Ptr_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Ptr_Ptr NULL"); + } + else if (len == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("len pointer NULL"); + } + else if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer_Ptr NULL"); + } + else if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else if (strcmp((Buffer_Ptr->FmtAttr_Value) , "") == 0) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Delimiteur vide"); + } + + + if ( status == IMRS_OK ) + { + strncpy(indicateur , Buffer_Ptr->FmtAttr_Value , 1); + indicateur[1] = '\0'; + strcpy(delimiteur , ""); + delim_ptr = (Buffer_Ptr->FmtAttr_Value); + delim_ptr++; + strcpy(delimiteur , delim_ptr); + delimLen = strlen(delimiteur); + } + + /* Controle de validite de l'indicateur */ + if ((strcmp(indicateur , "S") != 0) && (strcmp(indicateur , "T") != 0)) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Indicateur non correct [%s]",indicateur); + } + + + /* Controle de validite de l'Id */ + if (status == IMRS_OK) + { + if (Field_Ptr->Delimited.Id == IMRD_DELIMITED_ID_UNKNOWN) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Occurence Delimited unknown"); + } + } + + /* Controle de l'existence du champ */ + if (status == IMRS_OK) + status = Delimited_Hdl_Field_Exist(Field_Ptr , Buffer_Ptr); + /* Le champ n'existe pas => on prend la valeur par defaut */ + if (status == IMRS_NO_IDENT) + { + sizeTmp = strlen(Field_Ptr->Delimited.Def_Val); + data_ptr = (IMRT_Buffer_Data *) malloc ( sizeTmp + 1); + if (data_ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Malloc error"); + } + else + { + memset( data_ptr, '\0', sizeTmp + 1 ); + memcpy(data_ptr , Field_Ptr->Delimited.Def_Val , sizeTmp ); + *(data_ptr + sizeTmp) = '\0'; + *Data_Ptr_Ptr = data_ptr; + status = IMRS_OK; + } + } + /* le champ existe => on extrait la valeur */ + else if (status == IMRS_OK) + { + /* positionnement au debut de la chaine */ + deb_data_ptr = Buffer_Ptr->Data_Buf_Ptr; + /* Placement sur la bonne occurence */ + while ((indice < Field_Ptr->Delimited.Id)&&(status == IMRS_OK)) + { + deb_data_ptr = (IMRT_Buffer_Data *)strstr((const char *)deb_data_ptr , (const char *)delimiteur); + if (deb_data_ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Search occurence error"); + } + else + { + deb_data_ptr = deb_data_ptr + delimLen ; + indice++; + } + } + /*positionnement a la fin de la chaine */ + end_data_ptr = (IMRT_Buffer_Data *)strstr((const char *)deb_data_ptr , (const char *)delimiteur); + if (end_data_ptr == NULL) + { + /* Si l'indicateur est S */ + /* Si c'est la derniere occurence il n'y a pas de delimiteur */ + if (strcmp(indicateur , "S") == 0) + sizeTmp = (Buffer_Ptr->Data_Buf_Len - (deb_data_ptr - (Buffer_Ptr->Data_Buf_Ptr))); + else + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Incorrect format"); + } + } + else + { + sizeTmp = end_data_ptr - deb_data_ptr ; + } + data_ptr = (IMRT_Buffer_Data *) malloc ( sizeTmp + 1); + if (data_ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Malloc error"); + } + else + { + memset( data_ptr, '\0', sizeTmp + 1 ); + memcpy(data_ptr , deb_data_ptr , sizeTmp ); + *(data_ptr + sizeTmp) = '\0'; + *Data_Ptr_Ptr = data_ptr; + } + } + + if (status == IMRS_OK) + { + *len = sizeTmp; + } + + + return ( status ); +} + + +IMRT_Status IMR_MM_Delimited_StrHdl_Msg_Size( size_t Msg_Size ) +{ + IMRT_Status status; + char *func_name = "IMR_MM_Delimited_StrHdl_Msg_Size"; + + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Size msg demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Msg_Size : (%ld)" , Msg_Size); + + + /* Erreur de referentiel */ + status = IMRS_KO; + IMRD_LM_LOG_WARNING_0("Referential error ; this should never happen"); + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Size msg demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + + +IMRT_Status IMR_MM_Delimited_StrHdl_Field_Exist( IMRT_Field *Field_Ptr ) +{ + IMRT_Status status; + char *func_name = "IMR_MM_Delimited_StrHdl_Field_Exist"; + + status = IMRS_OK; + + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + { + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Existing field demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Input name : [%s]" , Field_Ptr->Name); + + if (IMRG_Delimited_Buffer_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL"); + } + else + { + status = Delimited_Hdl_Field_Exist( Field_Ptr, IMRG_Delimited_Buffer_Ident_Ptr); + } + } + + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Existing field demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + + return ( status ); +} + + +IMRT_Status IMR_MM_Delimited_StrHdl_Field_Value( IMRT_Field *Field_Ptr , IMRT_Field_Value_Id Value_Id ) +{ + IMRT_Buffer_Data *data_ptr; + IMRT_Status status; + size_t field_len; + char *func_name = "IMR_MM_Delimited_StrHdl_Field_Value"; + + status = IMRS_OK; + + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + { + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Value demand : Begin"); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Input name : [%s] Value Id : [%s]" , Field_Ptr->Name , Value_Id); + + + field_len = 0L; + + if (IMRG_Delimited_Buffer_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL"); + } + else + { + status = MM_Delimited_StrHdl_Get(&data_ptr, Field_Ptr, IMRG_Delimited_Buffer_Ident_Ptr , &field_len); + } + if (status == IMRS_OK) + { + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Value extracted : [%s]" , data_ptr); + if (strcmp(data_ptr, Value_Id) != 0) + { + status = IMRS_NO_IDENT; + } + free(data_ptr); + } + } + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Field Value demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + +IMRT_Status MM_Delimited_StrHdl_Convert(IMRT_Buffer_Data **Data_Output_Ptr , IMRT_Buffer_Data *Data_Input_Ptr , IMRT_Field *Field_Ptr, + size_t *len , IMRT_StrHdl_Cnv_Func *Cnv_Func_Tab ) +{ + IMRT_Status status; + IMRT_Buffer_Data *data_tmp_Ptr = NULL; + size_t size; + char *func_name = "MM_Delimited_StrHdl_Convert"; + + + + status = IMRS_OK; + + if (Data_Output_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Output_Ptr NULL"); + } + else if (Cnv_Func_Tab == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Cnv_Func_Tab NULL"); + } + else if (len == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("len pointer NULL"); + } + else if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + if (Data_Input_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Input_Ptr NULL"); + } + else + { + size = Field_Ptr->Fixed.Size; + + data_tmp_Ptr = (IMRT_Buffer_Data *)malloc(size + 1L); + memset( data_tmp_Ptr, '\0' , (size + 1L) ); + + + /* Appel de la fonction de convertion */ + + if ((Field_Ptr->Delimited.Cnv_Ptr == NULL) ||(Cnv_Func_Tab[Field_Ptr->Delimited.Cnv_Ptr->Id].Convert_Ptr == NULL)) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1 , "Pas de fonction de conversion"); + + if (Data_Input_Ptr != NULL) + { + *Data_Output_Ptr = data_tmp_Ptr; + memcpy(*Data_Output_Ptr,Data_Input_Ptr,*len); + } + } + else + { + status = Cnv_Func_Tab[Field_Ptr->Delimited.Cnv_Ptr->Id].Convert_Ptr( data_tmp_Ptr, + Data_Input_Ptr, + len , + size , + Field_Ptr->Delimited.Cnv_Attr ); + *Data_Output_Ptr = data_tmp_Ptr; + } + } + + if (Data_Input_Ptr != NULL) + free(Data_Input_Ptr); + + + return ( status ); + +} + +IMRT_Status MM_Delimited_StrHdl_Put(IMRT_Buffer_Data *Data_Ptr, IMRT_Field *Field_Ptr, + IMRT_Buffer *Buffer_Ptr , size_t len ) +{ + IMRT_Buffer_Data *data_buf_ptr; + size_t data_len; + size_t delim_len; + size_t data_max_len; + IMRT_Delimited_TmpId *TmpId_Ptr; + char *delim_ptr; + int occ; + IMRT_FmtAttr_Value delimiteur; + char indicateur[2]; + IMRT_Status status; + char *func_name = "MM_Delimited_StrHdl_Put"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer_Ptr NULL"); + } + else if (strcmp((Buffer_Ptr->FmtAttr_Value) , "") == 0) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Delimiteur vide"); + } + else if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else if (Data_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("data pointer NULL"); + } + + if ( status == IMRS_OK ) + { + strcpy(delimiteur , ""); + strncpy(indicateur , Buffer_Ptr->FmtAttr_Value , 1); + indicateur[1] = '\0'; + delim_ptr = NULL; + delim_ptr = (Buffer_Ptr->FmtAttr_Value); + delim_ptr++; + strcpy(delimiteur , delim_ptr); + delim_len = strlen(delimiteur); + + + /* Controle de validite de l'indicateur */ + if ((strcmp(indicateur , "S") != 0) && (strcmp(indicateur , "T") != 0)) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Indicateur non correct [%s]",indicateur); + } + } + + /* Controle de validite du delimiteur */ + if ( status == IMRS_OK ) + { + if (strcmp(delimiteur , "") == 0) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Delimiteur vide"); + } + } + + if ( status == IMRS_OK ) + { + /* Controle de validite de l'Id */ + if (Field_Ptr->Delimited.Id == IMRD_DELIMITED_ID_UNKNOWN) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Occurence Delimited unknown"); + } + } + + if ( status == IMRS_OK ) + { + occ = (((IMRT_Delimited_TmpId *)(Buffer_Ptr->Data_Tmp_Ptr))->TmpId); + /* la len est recuperee de la fonction de convertion */ + data_len = len; + + TmpId_Ptr = (IMRT_Delimited_TmpId *)Buffer_Ptr->Data_Tmp_Ptr; + + + /* Controle de l' occurence */ + if (Field_Ptr->Delimited.Id > occ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_2("Occurence (%d) not valid in [%s]",Field_Ptr->Delimited.Id,func_name); + } + } + + if ( status == IMRS_OK ) + { + /* Controle de la taille */ + data_max_len = Buffer_Ptr->Data_Buf_Len + data_len + delim_len; + if (Buffer_Ptr->Data_Buf_Size <= data_max_len) + status = Delimited_Hdl_DataBuf_Alloc( Buffer_Ptr, data_max_len + 1 ); + } + + + /* l'indicateur est 'S' */ + + if (( status == IMRS_OK )&&(strcmp(indicateur , "S")) == 0) + { + /* insertion de la valeur dans les donnees du buffer */ + + data_buf_ptr = Buffer_Ptr->Data_Buf_Ptr + Buffer_Ptr->Data_Buf_Len ; + + /* on n'insere le d‚limiteur qu'a partir de la deuxieme occurence (1) */ + if (occ != 0) + { + memcpy(data_buf_ptr, delimiteur, delim_len); + memcpy(data_buf_ptr + delim_len , Data_Ptr , data_len) ; + Buffer_Ptr->Data_Buf_Len = data_max_len; + } + else + { + memcpy(data_buf_ptr , Data_Ptr , data_len) ; + Buffer_Ptr->Data_Buf_Len = Buffer_Ptr->Data_Buf_Len + data_len ; + } + occ++; + TmpId_Ptr->TmpId = (IMRT_Delimited_Id)occ; + } + else /* l'indicateur est 'T' */ + if (( status == IMRS_OK )&&(strcmp(indicateur , "T") == 0)) + { + /* insertion de la valeur dans les donnees du buffer */ + data_buf_ptr = Buffer_Ptr->Data_Buf_Ptr + Buffer_Ptr->Data_Buf_Len ; + + /* on insere systematiquement le d‚limiteur en fin de chaine */ + memcpy(data_buf_ptr , Data_Ptr , data_len) ; + memcpy(data_buf_ptr + data_len , delimiteur, delim_len); + Buffer_Ptr->Data_Buf_Len = data_max_len; + occ++; + TmpId_Ptr->TmpId = (IMRT_Delimited_Id)occ; + + } + + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_2 , "Prochaine occurence apres put (%d)",TmpId_Ptr->TmpId); + + if (Data_Ptr != NULL) + free(Data_Ptr); + + + + return ( status ); +} diff --git a/src/libmapping_mng/src/fmt_hdl_dltd.h b/src/libmapping_mng/src/fmt_hdl_dltd.h new file mode 100644 index 0000000..0a0622b --- /dev/null +++ b/src/libmapping_mng/src/fmt_hdl_dltd.h @@ -0,0 +1,115 @@ +/*----------------------------------------------------------------------------*/ +/* File: fmt_hdl_dltd.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _DELIMITED_HANDLER_H_ +#define _DELIMITED_HANDLER_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + + + +/*----------------------------------------------------------------------------*/ +/* Local definition */ +/*----------------------------------------------------------------------------*/ + +#ifdef _DELIMITED_HANDLER_C_ + +# define DELIMITED_TAILLE_ALLOC 100000 + + typedef struct IMRT_Delimited_TmpId + { + IMRT_Delimited_Id TmpId; + } IMRT_Delimited_TmpId; + + +#endif + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ +#ifdef _DELIMITED_HANDLER_C_ + + IMRT_Buffer *IMRG_Delimited_Buffer_Ident_Ptr; + +#endif + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _DELIMITED_HANDLER_C_ + + IMRT_Status MM_Delimited_StrHdl_Init ( void ); + IMRT_Status MM_Delimited_StrHdl_DeInit ( void ); + IMRT_Status Delimited_Hdl_DataBuf_Alloc ( IMRT_Buffer * , size_t ); + IMRT_Status MM_Delimited_StrHdl_Data_Free ( IMRT_Buffer * ); + IMRT_Status Delimited_Hdl_Format_Ident ( IMRT_Buffer * ); + IMRT_Status MM_Delimited_StrHdl_Ident ( IMRT_Msg_Id * , IMRT_Buffer * ); + IMRT_Status Delimited_Hdl_Occ_Count ( IMRT_Buffer_Data * , short * , IMRT_FmtAttr_Value ); + IMRT_Status Delimited_Hdl_TmpId_Init ( IMRT_Buffer * , short ); + IMRT_Status MM_Delimited_StrHdl_Open ( IMRT_Buffer * ); + IMRT_Status MM_Delimited_StrHdl_Close ( IMRT_Buffer * ); + IMRT_Status MM_Delimited_StrHdl_Flush ( IMRT_Buffer * ); + IMRT_Status MM_Delimited_StrHdl_Flush ( IMRT_Buffer * ); + IMRT_Status MM_Delimited_StrHdl_Data_List ( IMRT_Buffer * ); + IMRT_Status MM_Delimited_StrHdl_Copy ( IMRT_Buffer * , IMRT_Buffer * ); + IMRT_Status Delimited_Hdl_Field_Exist ( IMRT_Field * , IMRT_Buffer * ); + IMRT_Status MM_Delimited_StrHdl_Get ( IMRT_Buffer_Data ** , IMRT_Field * , IMRT_Buffer * , size_t * ); + IMRT_Status MM_Delimited_StrHdl_Convert ( IMRT_Buffer_Data ** , IMRT_Buffer_Data * , IMRT_Field * , size_t *, IMRT_StrHdl_Cnv_Func * ); + IMRT_Status MM_Delimited_StrHdl_Put ( IMRT_Buffer_Data * , IMRT_Field * , IMRT_Buffer * , size_t ); + IMRT_Status IMR_MM_Delimited_StrHdl_Field_Value ( IMRT_Field * , IMRT_Field_Value_Id); + IMRT_Status IMR_MM_Delimited_StrHdl_Field_Exist ( IMRT_Field * ); + IMRT_Status IMR_MM_Delimited_StrHdl_Msg_Size ( size_t ); +#else + + extern IMRT_Status MM_Delimited_StrHdl_Init ( void ); + extern IMRT_Status MM_Delimited_StrHdl_DeInit ( void ); + extern IMRT_Status MM_Delimited_StrHdl_Library_Open ( void ); + extern IMRT_Status MM_Delimited_StrHdl_Data_Free ( IMRT_Buffer * ); + extern IMRT_Status MM_Delimited_StrHdl_Ident ( IMRT_Msg_Id * , IMRT_Buffer * ); + extern IMRT_Status MM_Delimited_StrHdl_Open ( IMRT_Buffer * ); + extern IMRT_Status MM_Delimited_StrHdl_Close ( IMRT_Buffer * ); + extern IMRT_Status MM_Delimited_StrHdl_Flush ( IMRT_Buffer * ); + extern IMRT_Status MM_Delimited_StrHdl_Flush ( IMRT_Buffer * ); + extern IMRT_Status MM_Delimited_StrHdl_Data_List ( IMRT_Buffer * ); + extern IMRT_Status MM_Delimited_StrHdl_Copy ( IMRT_Buffer * , IMRT_Buffer * ); + extern IMRT_Status MM_Delimited_StrHdl_Get ( IMRT_Buffer_Data ** , IMRT_Field * , IMRT_Buffer * , size_t * ); + extern IMRT_Status MM_Delimited_StrHdl_Convert ( IMRT_Buffer_Data ** , IMRT_Buffer_Data * , IMRT_Field * , size_t *, IMRT_StrHdl_Cnv_Func * ); + extern IMRT_Status MM_Delimited_StrHdl_Put ( IMRT_Buffer_Data * , IMRT_Field * , IMRT_Buffer * , size_t ); + +#endif + +/*----------------------------------------------------------------------------*/ + +#endif + diff --git a/src/libmapping_mng/src/fmt_hdl_fixed.c b/src/libmapping_mng/src/fmt_hdl_fixed.c new file mode 100644 index 0000000..cd02ef6 --- /dev/null +++ b/src/libmapping_mng/src/fmt_hdl_fixed.c @@ -0,0 +1,744 @@ +/*----------------------------------------------------------------------------*/ +/* File: fmt_hdl_fixed.c */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _FIXED_HANDLER_C_ + +#include "fmt_hdl_fixed.h" + +IMRT_Status MM_Fixed_StrHdl_Init() +{ + IMRG_Fixed_Buffer_Ident_Ptr = NULL; + return (IMRS_OK); +} + +IMRT_Status MM_Fixed_StrHdl_DeInit() +{ + + return (IMRS_OK); +} +IMRT_Status Fixed_Hdl_DataBuf_Alloc( IMRT_Buffer *Buffer_Ptr, size_t Taille_Alloc ) +{ + IMRT_Buffer_Data *data_Ptr; + IMRT_Status status; + char *func_name = "Fixed_Hdl_DataBuf_Alloc"; + + + status = IMRS_OK; + data_Ptr = NULL; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) + { + if (Taille_Alloc > Buffer_Ptr->Data_Buf_Size) + { + data_Ptr = (IMRT_Buffer_Data *) realloc ( (void *) Buffer_Ptr->Data_Buf_Ptr, Taille_Alloc ); + if (data_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Realloc error"); + } + else + { + memset( data_Ptr + Buffer_Ptr->Data_Buf_Size, '\0', Taille_Alloc - Buffer_Ptr->Data_Buf_Size ); + Buffer_Ptr->Data_Buf_Ptr = data_Ptr; + Buffer_Ptr->Data_Buf_Size = Taille_Alloc; + } + } + } + else + { + data_Ptr = (IMRT_Buffer_Data *) malloc ( Taille_Alloc ); + if (data_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Malloc error"); + } + else + { + memset( data_Ptr, '\0', Taille_Alloc ); + Buffer_Ptr->Data_Buf_Ptr = data_Ptr; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_ALLOCATED; + Buffer_Ptr->Data_Buf_Size = Taille_Alloc; + Buffer_Ptr->Data_Buf_Len = 0; + } + } + + + return ( status ); +} + +IMRT_Status MM_Fixed_StrHdl_Data_Free( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_Fixed_StrHdl_Data_Free"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) + { + free(Buffer_Ptr->Data_Buf_Ptr); + Buffer_Ptr->Data_Buf_Ptr = NULL; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_FREED; + Buffer_Ptr->Data_Buf_Size = 0; + Buffer_Ptr->Data_Buf_Len = 0; + } + + return ( status ); +} + +IMRT_Status Fixed_Hdl_Format_Ident( IMRT_Buffer *Buffer_Ptr ) +{ + IMRT_Status status; + char *func_name = "Fixed_Hdl_Format_Ident"; + + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) + { + status = IMRS_OK; + } + else + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer not allocated"); + } + + + return ( status ); +} + +IMRT_Status MM_Fixed_StrHdl_Ident( IMRT_Msg_Id *Msg_Id_Ident_Ptr, + IMRT_Buffer *Buffer_Ptr ) +{ + + IMRT_Fmt_Id Format; + IMRT_Status status; + IMRT_Msg_Id *Msg_Id_Tmp; + char *func_name = "MM_Fixed_StrHdl_Ident"; + + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Msg_Id_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Msg_Id_Ident_Ptr NULL" ); + } + else + { + Format = Buffer_Ptr->Fmt_Id; + Msg_Id_Tmp = Msg_Id_Ident_Ptr; + status = IMRS_OK; + + IMRG_Fixed_Buffer_Ident_Ptr = Buffer_Ptr; + /* Le Msg_Id transmis au SDM est le point de depart de l'identification */ + /* C'est egalement le resultat qui sera inclus dans le buffer */ + status = IMR_SDM_MsgIdent_Proceed(Format, + Msg_Id_Tmp, + IMR_MM_Fixed_StrHdl_Field_Value, + IMR_MM_Fixed_StrHdl_Field_Exist, + IMR_MM_Fixed_StrHdl_Msg_Size); + IMRG_Fixed_Buffer_Ident_Ptr = NULL; + + Msg_Id_Ident_Ptr = Msg_Id_Tmp; + } + + + return ( status ); + +} + +IMRT_Status MM_Fixed_StrHdl_Open( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Msg_Id type_temp; + IMRT_Status status; + char *func_name = "MM_Fixed_StrHdl_Open"; + + + status = IMRS_OK; + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + type_temp = Buffer_Ptr->Msg_Id; + /* absence de données */ + if (Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + /* Cas d'open du buffer en ecriture */ + /* le type du message est passe */ + /* par le SDM : il doit donc etre connu */ + if (type_temp == IMRD_MSG_ID_UNKNOWN) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Msg Id unknown"); + } + else + { + status = Fixed_Hdl_DataBuf_Alloc( Buffer_Ptr, FIXED_TAILLE_ALLOC ); + } + } + else + { + /* controle du format */ + status = Fixed_Hdl_Format_Ident( Buffer_Ptr ) ; + if (status != IMRS_OK) + { + status = IMRS_BAD_FORMAT; + } + } + } + + + + return ( status ); +} + + +IMRT_Status MM_Fixed_StrHdl_Close( IMRT_Buffer *Buffer_Ptr) +{ + char *func_name = "MM_Fixed_StrHdl_Close"; + + + return (IMRS_OK); +} + +IMRT_Status MM_Fixed_StrHdl_Flush( IMRT_Buffer *Buffer_Ptr) +{ + char *func_name = "MM_Fixed_StrHdl_Flush"; + + return (IMRS_OK); +} + + + +IMRT_Status MM_Fixed_StrHdl_Data_List( IMRT_Buffer *Buffer_Ptr) +{ + if (Buffer_Ptr == NULL) + { + IMRD_LM_LOG_WARNING_0("Buffer pointer NULL" ); + } + else + { + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Data_Buf_Ptr_Size: (%d) Data_Buf_Ptr_Len: (%d) Data_Buf_Ptr: (0x%X)", Buffer_Ptr->Data_Buf_Size, Buffer_Ptr->Data_Buf_Len, Buffer_Ptr->Data_Buf_Ptr); + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_2, "Buffer_List: Data_Buf: [%s]", Buffer_Ptr->Data_Buf_Ptr); + + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Data_Tmp_Changed: (%d) Data_Tmp_Ptr: (0x%X)", Buffer_Ptr->Data_Tmp_Changed, Buffer_Ptr->Data_Tmp_Ptr); + if (Buffer_Ptr->Data_Tmp_Ptr != NULL) + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_2, "Buffer_List: Data_Tmp: [%s]", Buffer_Ptr->Data_Tmp_Ptr); + } + + return (IMRS_OK); +} + + + +IMRT_Status MM_Fixed_StrHdl_Copy( IMRT_Buffer *Output_Buffer_Ptr, IMRT_Buffer *Input_Buffer_Ptr ) +{ + IMRT_Status status; + char *func_name = "MM_Fixed_StrHdl_Copy"; + + + status = IMRS_OK; + + if (Input_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Input buffer pointer NULL" ); + } + else + if (Output_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Output buffer pointer NULL" ); + } + else + /* controle donnees dans Input_Buffer */ + if (Input_Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer input not allocated"); + } + /* le buffer destinataire ne doit pas comporter de données */ + else if ( ( Output_Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) || + ( Output_Buffer_Ptr->Data_Tmp_Ptr != NULL) ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer output not allocated or Data_Tmp_Ptr no NULL"); + } + else + { + status = Fixed_Hdl_DataBuf_Alloc(Output_Buffer_Ptr, Input_Buffer_Ptr->Data_Buf_Size); + if (status == IMRS_OK) + { + memcpy( Output_Buffer_Ptr->Data_Buf_Ptr, + Input_Buffer_Ptr->Data_Buf_Ptr, + Input_Buffer_Ptr->Data_Buf_Size); + Output_Buffer_Ptr->Data_Buf_Len = Input_Buffer_Ptr->Data_Buf_Len; + } + } + + + return ( status ); +} + +IMRT_Status Fixed_Hdl_Field_Exist(IMRT_Field *Field_Ptr , IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "Fixed_Hdl_Field_Exist"; + + /* En fixed, pas de cas de champ inexistant */ + + status = IMRS_OK; + + return ( status ); + +} + + +IMRT_Status MM_Fixed_StrHdl_Get(IMRT_Buffer_Data **Data_Ptr_Ptr, IMRT_Field *Field_Ptr, + IMRT_Buffer *Buffer_Ptr , size_t *len ) +{ + IMRT_Buffer_Data *data_ptr; + IMRT_Status status; + int offsetTmp; + size_t sizeTmp; + char *func_name = "MM_Fixed_StrHdl_Get"; + + + status = IMRS_OK; + data_ptr = NULL; + offsetTmp = 0; + sizeTmp = 0L; + + if (Data_Ptr_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Ptr_Ptr NULL"); + } + else if (len == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("len pointer NULL"); + } + else if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer_Ptr NULL"); + } + else if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + /* Controle de validite de la taille */ + if (Field_Ptr->Fixed.Size == IMRD_FIXED_SIZE_UNKNOWN) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Size Fixed unknown"); + } + + + if (status == IMRS_OK) + { + /* controle sur l'offset */ + if (Field_Ptr->Fixed.Offset > Buffer_Ptr->Data_Buf_Len ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field offset out of data len"); + } + } + + /* Controle de l'existence du champ */ + if (status == IMRS_OK) + { + status = Fixed_Hdl_Field_Exist(Field_Ptr , Buffer_Ptr); + } + + /* Le champ n'existe pas => on prend la valeur par defaut */ + /* Actuellement, ca ne peut pas arriver en Fixed */ + if (status == IMRS_NO_IDENT) + { + sizeTmp = strlen(Field_Ptr->Fixed.Def_Val); + data_ptr = (IMRT_Buffer_Data *) malloc ( sizeTmp + 1); + if (data_ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Malloc error"); + } + else + { + memset( data_ptr, '\0', sizeTmp + 1 ); + memcpy(data_ptr , Field_Ptr->Fixed.Def_Val , sizeTmp ); + *(data_ptr + sizeTmp) = '\0'; + *Data_Ptr_Ptr = data_ptr; + status = IMRS_OK; + } + + } + else if (status == IMRS_OK) + { + /* cas ou Field_Ptr->Fixed.Size = 0 => on prend tout le champ */ + /* idem si offset + size > len du message */ + if((Field_Ptr->Fixed.Size == 0L) ||( Field_Ptr->Fixed.Offset + Field_Ptr->Fixed.Size > Buffer_Ptr->Data_Buf_Len ) ) + { + sizeTmp = Buffer_Ptr->Data_Buf_Len - Field_Ptr->Fixed.Offset; + } + else + { + sizeTmp = Field_Ptr->Fixed.Size; + } + data_ptr = (IMRT_Buffer_Data *) malloc ( sizeTmp + 1); + if (data_ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Malloc error"); + } + else + { + memcpy( data_ptr, + Buffer_Ptr->Data_Buf_Ptr + Field_Ptr->Fixed.Offset, + sizeTmp); + *(data_ptr + sizeTmp) = '\0'; + *Data_Ptr_Ptr = data_ptr; + } + + } + + if (status == IMRS_OK) + { + *len = sizeTmp; + } + + + + return ( status ); +} + + +IMRT_Status IMR_MM_Fixed_StrHdl_Msg_Size ( size_t Msg_Size) +{ + IMRT_Status status; + char *func_name = "IMR_MM_Fixed_StrHdl_Msg_Size"; + + if (IMRG_Fixed_Buffer_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL"); + } + else + { + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Size msg demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Msg_Size : (%ld)" , Msg_Size); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Length of the buffer data : (%ld)" , IMRG_Fixed_Buffer_Ident_Ptr->Data_Buf_Len); + + status = IMRS_OK; + + if (Msg_Size != IMRG_Fixed_Buffer_Ident_Ptr->Data_Buf_Len) + status = IMRS_NO_IDENT; + } + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Size msg demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + + +IMRT_Status IMR_MM_Fixed_StrHdl_Field_Exist( IMRT_Field *Field_Ptr ) +{ + IMRT_Status status; + char *func_name = "IMR_MM_Fixed_StrHdl_Field_Exist"; + + status = IMRS_OK; + + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + { + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Existing field demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Input name : [%s]" , Field_Ptr->Name); + + if (IMRG_Fixed_Buffer_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL"); + } + else + { + status = Fixed_Hdl_Field_Exist( Field_Ptr, IMRG_Fixed_Buffer_Ident_Ptr); + } + } + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Existing field demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + +IMRT_Status IMR_MM_Fixed_StrHdl_Field_Value( IMRT_Field *Field_Ptr , IMRT_Field_Value_Id Value_Id ) +{ + IMRT_Buffer_Data *data_ptr; + IMRT_Status status; + size_t field_len; + char *func_name = "IMR_MM_Fixed_StrHdl_Field_Value"; + + status = IMRS_OK; + + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + { + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Value demand : Begin"); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Input name : [%s] Value Id : [%s]" , Field_Ptr->Name , Value_Id); + + field_len = 0L; + status = IMRS_OK; + + if (IMRG_Fixed_Buffer_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL"); + } + else + { + status = MM_Fixed_StrHdl_Get(&data_ptr, Field_Ptr, IMRG_Fixed_Buffer_Ident_Ptr , &field_len ); + } + + if (status == IMRS_OK) + { + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Value extracted : [%s]" , data_ptr); + if (strcmp(data_ptr, Value_Id) != 0) + { + status = IMRS_NO_IDENT; + } + free(data_ptr); + } + } + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Field Value demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + +IMRT_Status MM_Fixed_StrHdl_Convert(IMRT_Buffer_Data **Data_Output_Ptr , IMRT_Buffer_Data *Data_Input_Ptr , IMRT_Field *Field_Ptr, + size_t *len , IMRT_StrHdl_Cnv_Func *Cnv_Func_Tab ) +{ + IMRT_Status status; + size_t size; + char *func_name = "MM_Fixed_StrHdl_Convert"; + + + + + status = IMRS_OK; + + if (Cnv_Func_Tab == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Cnv_Func_Tab NULL"); + } + else if (Data_Output_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Output_Ptr NULL"); + } + else if (len == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("len pointer NULL"); + } + else if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + if (Data_Input_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Input_Ptr NULL"); + } + else + { + size = Field_Ptr->Fixed.Size ; + + *Data_Output_Ptr = (IMRT_Buffer_Data *)malloc(size + 1L); + if (*Data_Output_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("*Data_Output_Ptr NULL"); + } + else + { + memset(*Data_Output_Ptr, '\0' , (size + 1L) ); + + /* Appel de la fonction de convertion */ + if ((Field_Ptr->Fixed.Cnv_Ptr == NULL) || (Cnv_Func_Tab[Field_Ptr->Fixed.Cnv_Ptr->Id].Convert_Ptr == NULL)) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1 , "Pas de fonction de conversion"); + + if (Data_Input_Ptr != NULL) + memcpy(*Data_Output_Ptr,Data_Input_Ptr,*len); + } + else + { + status = Cnv_Func_Tab[Field_Ptr->Fixed.Cnv_Ptr->Id].Convert_Ptr(*Data_Output_Ptr, + Data_Input_Ptr, + len , + size , + Field_Ptr->Fixed.Cnv_Attr); + } + } + } + + if (Data_Input_Ptr != NULL) + free(Data_Input_Ptr); + + + return ( status ); + +} + + +IMRT_Status MM_Fixed_StrHdl_Put(IMRT_Buffer_Data *Data_Ptr, IMRT_Field *Field_Ptr, + IMRT_Buffer *Buffer_Ptr , size_t len ) +{ + IMRT_Buffer_Data *data_buf_ptr; + size_t data_len; + size_t data_max_len; + IMRT_Status status; + char *func_name = "MM_Fixed_StrHdl_Put"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer_Ptr NULL"); + } + else if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else if (Data_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("data pointer NULL"); + } + else + /* Controle de validite de la taille */ + if (Field_Ptr->Fixed.Size == IMRD_FIXED_SIZE_UNKNOWN) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Size Fixed unknown"); + } + + if (status == IMRS_OK) + { + if (strcmp(Data_Ptr , "") == 0) + status = IMRD_STATUS_NOTHING_TO_DO; + } + + + if ( status == IMRS_OK ) + { + data_len = len ; + data_max_len = Field_Ptr->Fixed.Offset + data_len ; + + /* controle sur la valeur */ + if ( data_len > Field_Ptr->Fixed.Size ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_2("Data len (%ld) superior to data size (%ld)",data_len , Field_Ptr->Fixed.Size); + } + else if ( Buffer_Ptr->Data_Buf_Size <= data_max_len ) + { + status = Fixed_Hdl_DataBuf_Alloc( Buffer_Ptr, data_max_len + 1 ); + } + } + + if ( status == IMRS_OK ) + { + /* insertion de la valeur dans les donnees du buffer */ + data_buf_ptr = Buffer_Ptr->Data_Buf_Ptr + Field_Ptr->Fixed.Offset; + memcpy(data_buf_ptr, Data_Ptr, data_len); + + if ( Buffer_Ptr->Data_Buf_Len < data_max_len ) + { + Buffer_Ptr->Data_Buf_Len = data_max_len; + } + } + + if (status == IMRD_STATUS_NOTHING_TO_DO) + status = IMRS_OK; + + if (Data_Ptr != NULL) + free(Data_Ptr); + + + return ( status ); +} + diff --git a/src/libmapping_mng/src/fmt_hdl_fixed.h b/src/libmapping_mng/src/fmt_hdl_fixed.h new file mode 100644 index 0000000..007b2aa --- /dev/null +++ b/src/libmapping_mng/src/fmt_hdl_fixed.h @@ -0,0 +1,104 @@ +/*----------------------------------------------------------------------------*/ +/* File: fmt_hdl_fixed.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _FIXED_HANDLER_H_ +#define _FIXED_HANDLER_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Local definition */ +/*----------------------------------------------------------------------------*/ + +#ifdef _FIXED_HANDLER_C_ + +# define FIXED_TAILLE_ALLOC 100000 + +#endif + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ +#ifdef _FIXED_HANDLER_C_ + + IMRT_Buffer *IMRG_Fixed_Buffer_Ident_Ptr; + +#endif + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _FIXED_HANDLER_C_ + + IMRT_Status MM_Fixed_StrHdl_Init ( void ); + IMRT_Status MM_Fixed_StrHdl_DeInit ( void ); + IMRT_Status Fixed_Hdl_DataBuf_Alloc ( IMRT_Buffer * , size_t ); + IMRT_Status MM_Fixed_StrHdl_Data_Free ( IMRT_Buffer * ); + IMRT_Status Fixed_Hdl_Format_Ident ( IMRT_Buffer * ); + IMRT_Status MM_Fixed_StrHdl_Ident ( IMRT_Msg_Id * , IMRT_Buffer * ); + IMRT_Status MM_Fixed_StrHdl_Open ( IMRT_Buffer * ); + IMRT_Status MM_Fixed_StrHdl_Close ( IMRT_Buffer * ); + IMRT_Status MM_Fixed_StrHdl_Flush ( IMRT_Buffer * ); + IMRT_Status MM_Fixed_StrHdl_Data_List ( IMRT_Buffer * ); + IMRT_Status MM_Fixed_StrHdl_Copy ( IMRT_Buffer * , IMRT_Buffer * ); + IMRT_Status Fixed_Hdl_Field_Exist ( IMRT_Field * , IMRT_Buffer * ); + IMRT_Status MM_Fixed_StrHdl_Get ( IMRT_Buffer_Data ** , IMRT_Field * , IMRT_Buffer * , size_t * ); + IMRT_Status MM_Fixed_StrHdl_Convert ( IMRT_Buffer_Data ** , IMRT_Buffer_Data * , IMRT_Field * , size_t *, IMRT_StrHdl_Cnv_Func * ); + IMRT_Status MM_Fixed_StrHdl_Put ( IMRT_Buffer_Data * , IMRT_Field * , IMRT_Buffer * , size_t ); + IMRT_Status IMR_MM_Fixed_StrHdl_Field_Value ( IMRT_Field * , IMRT_Field_Value_Id); + IMRT_Status IMR_MM_Fixed_StrHdl_Field_Exist ( IMRT_Field * ); + IMRT_Status IMR_MM_Fixed_StrHdl_Msg_Size ( size_t ); + +#else + + extern IMRT_Status MM_Fixed_StrHdl_Init ( void ); + extern IMRT_Status MM_Fixed_StrHdl_DeInit ( void ); + extern IMRT_Status MM_Fixed_StrHdl_Library_Open ( void ); + extern IMRT_Status MM_Fixed_StrHdl_Data_Free ( IMRT_Buffer * ); + extern IMRT_Status MM_Fixed_StrHdl_Ident ( IMRT_Msg_Id * , IMRT_Buffer * ); + extern IMRT_Status MM_Fixed_StrHdl_Open ( IMRT_Buffer * ); + extern IMRT_Status MM_Fixed_StrHdl_Close ( IMRT_Buffer * ); + extern IMRT_Status MM_Fixed_StrHdl_Flush ( IMRT_Buffer * ); + extern IMRT_Status MM_Fixed_StrHdl_Data_List ( IMRT_Buffer * ); + extern IMRT_Status MM_Fixed_StrHdl_Copy ( IMRT_Buffer * , IMRT_Buffer * ); + extern IMRT_Status MM_Fixed_StrHdl_Get ( IMRT_Buffer_Data ** , IMRT_Field * , IMRT_Buffer * , size_t * ); + extern IMRT_Status MM_Fixed_StrHdl_Convert ( IMRT_Buffer_Data ** , IMRT_Buffer_Data * , IMRT_Field * , size_t *, IMRT_StrHdl_Cnv_Func * ); + extern IMRT_Status MM_Fixed_StrHdl_Put ( IMRT_Buffer_Data * , IMRT_Field * , IMRT_Buffer * , size_t ); + +#endif + +/*----------------------------------------------------------------------------*/ + +#endif + diff --git a/src/libmapping_mng/src/fmt_hdl_fml.c b/src/libmapping_mng/src/fmt_hdl_fml.c new file mode 100644 index 0000000..f6d72a2 --- /dev/null +++ b/src/libmapping_mng/src/fmt_hdl_fml.c @@ -0,0 +1,835 @@ +/*----------------------------------------------------------------------------*/ +/* File: fmt_hdl_fml.c */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _FML_HANDLER_C_ + +#include "fmt_hdl_fml.h" + + +IMRT_Status MM_FML_StrHdl_Init() +{ + IMRG_FML_Buffer_Ident_Ptr = NULL; + return (IMRS_OK); +} + +IMRT_Status MM_FML_StrHdl_DeInit() +{ + + return (IMRS_OK); +} + +IMRT_Status FML_Hdl_DataBuf_Alloc( IMRT_Buffer *Buffer_Ptr ) +{ + IMRT_Status status; + int retour; + char *func_name = "FML_Hdl_DataBuf_Alloc"; + FBFR32 *tpFBbuf; + + + + tpFBbuf = NULL; + status = IMRS_OK; + retour = 0; + + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + tpFBbuf = (FBFR32 *)tpalloc((char *) IMRD_FML_TYPE , NULL, Fneeded32(IMRD_FML_MAX_FLD, IMRD_FML_SIZE) ); + + if (tpFBbuf == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Error tpalloc"); + } + + if (status == IMRS_OK) + { + + retour = Finit32(tpFBbuf, (FLDLEN32) Fsizeof32(tpFBbuf)); + + if (retour == -1) + { + if (Ferror32 == FNOSPACE) + { + IMRD_LM_LOG_ERROR_0("Ferror32 = FNOSPACE"); + } + else if (Ferror32 == FALIGNERR) + { + IMRD_LM_LOG_ERROR_0("Ferror32 = FALIGNERR"); + } + else if (Ferror32 == FNOTFLD) + { + IMRD_LM_LOG_ERROR_0("Ferror32 = FNOTFLD"); + } + else if (Ferror32 == FEINVAL) + { + IMRD_LM_LOG_ERROR_0("Ferror32 = FEINVAL"); + } + else if (Ferror32 == FBADFLD) + { + IMRD_LM_LOG_ERROR_0("Ferror32 = FBADFLD"); + } + status = IMRS_KO; + tpfree((char *)tpFBbuf); + } + } + + + if (status == IMRS_OK) + { + Buffer_Ptr->Data_Buf_Ptr = (IMRT_Buffer_Data *)tpFBbuf; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_ALLOCATED; + Buffer_Ptr->Data_Buf_Size = IMRD_FML_SIZE; + Buffer_Ptr->Data_Buf_Len = 0; + + } + } + + + + return status; + +} + + +IMRT_Status MM_FML_StrHdl_Data_Free( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_FML_StrHdl_Data_Free"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) + { + tpfree((char *)Buffer_Ptr->Data_Buf_Ptr); + Buffer_Ptr->Data_Buf_Ptr = NULL; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_FREED; + Buffer_Ptr->Data_Buf_Size = 0; + Buffer_Ptr->Data_Buf_Len = 0; + } + + return ( status ); +} + + +IMRT_Status FML_Hdl_Format_Ident( IMRT_Buffer *Buffer_Ptr ) +{ + IMRT_Status status; + char *func_name = "FML_Hdl_Format_Ident"; + + + status = IMRS_KO; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) + { + /* Controle du format FML */ + if (Fnum32((FBFR32 *)Buffer_Ptr->Data_Buf_Ptr) != -1) + { + status = IMRS_OK; + } + } + else + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer not allocated"); + } + + + return ( status ); +} + +IMRT_Status MM_FML_StrHdl_Ident( IMRT_Msg_Id *Msg_Id_Ident_Ptr, + IMRT_Buffer *Buffer_Ptr ) +{ + + IMRT_Fmt_Id Format; + IMRT_Status status; + IMRT_Msg_Id *Msg_Id_Tmp; + char *func_name = "MM_FML_StrHdl_Ident"; + + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Msg_Id_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Msg_Id_Ident_Ptr NULL" ); + } + else + { + Format = Buffer_Ptr->Fmt_Id; + Msg_Id_Tmp = Msg_Id_Ident_Ptr; + status = IMRS_OK; + + IMRG_FML_Buffer_Ident_Ptr = Buffer_Ptr; + /* Le Msg_Id transmis au SDM est le point de depart de l'identification */ + /* C'est egalement le resultat qui sera inclus dans le buffer */ + status = IMR_SDM_MsgIdent_Proceed(Format, + Msg_Id_Tmp, + IMR_MM_FML_StrHdl_Field_Value, + IMR_MM_FML_StrHdl_Field_Exist, + IMR_MM_FML_StrHdl_Msg_Size); + IMRG_FML_Buffer_Ident_Ptr = NULL; + + Msg_Id_Ident_Ptr = Msg_Id_Tmp; + } + + + return ( status ); + +} + +IMRT_Status MM_FML_StrHdl_Open( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Msg_Id type_temp; + IMRT_Status status; + char *func_name = "MM_FML_StrHdl_Open"; + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + type_temp = Buffer_Ptr->Msg_Id; + + /* absence de données */ + if (Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + /* Cas d'open du buffer en ecriture */ + /* le type du message est passe */ + /* par le SDM : il doit donc etre connu */ + if (type_temp == IMRD_MSG_ID_UNKNOWN) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Msg Id unknown"); + } + else + { + status = FML_Hdl_DataBuf_Alloc( Buffer_Ptr ); + } + } + else + { + /* controle du format */ + status = FML_Hdl_Format_Ident( Buffer_Ptr ); + /* format non reconnu */ + if (status != IMRS_OK) + status = IMRS_BAD_FORMAT; + } + } + + + + return ( status ); +} + +IMRT_Status MM_FML_StrHdl_Close( IMRT_Buffer *Buffer_Ptr) +{ + char *func_name = "MM_FML_StrHdl_Close"; + + return (IMRS_OK); +} + +IMRT_Status MM_FML_StrHdl_Flush( IMRT_Buffer *Buffer_Ptr) +{ + char *func_name = "MM_FML_StrHdl_Flush"; + + return (IMRS_OK); +} + +IMRT_Status MM_FML_StrHdl_Data_List( IMRT_Buffer *Buffer_Ptr) +{ + if (Buffer_Ptr == NULL) + { + IMRD_LM_LOG_WARNING_0("Buffer pointer NULL" ); + } + else + { + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Data_Buf_Ptr_Size: (%d) Data_Buf_Ptr_Len: (%d) Data_Buf_Ptr: (0x%X)", Buffer_Ptr->Data_Buf_Size, Buffer_Ptr->Data_Buf_Len, Buffer_Ptr->Data_Buf_Ptr); + + IMRD_LM_EXEC_TRACE( IMRD_LOG_LEVEL_VERBOSE_2, "Buffer_List: Data_Tmp: [", Ffprint32( (FBFR32 *)Buffer_Ptr->Data_Buf_Ptr, IMRD_LM_STREAM_OUT), "]"); + + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Data_Tmp_Changed: (%d) Data_Tmp_Ptr: (0x%X)", Buffer_Ptr->Data_Tmp_Changed, Buffer_Ptr->Data_Tmp_Ptr); + + if (Buffer_Ptr->Data_Tmp_Ptr != NULL) + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_2, "Buffer_List: Data_Tmp: [%s]", Buffer_Ptr->Data_Tmp_Ptr); + } + + return( IMRS_OK); +} + +IMRT_Status MM_FML_StrHdl_Copy( IMRT_Buffer *Output_Buffer_Ptr, IMRT_Buffer *Input_Buffer_Ptr ) +{ + IMRT_Status status; + char *func_name = "MM_FML_StrHdl_Copy"; + + + status = IMRS_OK; + + if (Input_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Input buffer pointer NULL" ); + } + else + if (Output_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Output buffer pointer NULL" ); + } + else + /* controle donnees dans Input_Buffer */ + if (Input_Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0( "Buffer input not allocated"); + } + /* le buffer destinataire ne doit pas comporter de donnees */ + else if ( ( Output_Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) || + ( Output_Buffer_Ptr->Data_Tmp_Ptr != NULL) ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer output not allocated or Data_Tmp_Ptr no NULL"); + } + else + { + status = FML_Hdl_DataBuf_Alloc(Output_Buffer_Ptr); + if (status == IMRS_OK) + { + /* copie de buffer FML */ + Fcpy32((FBFR32 *)Output_Buffer_Ptr->Data_Buf_Ptr , (FBFR32 *)Input_Buffer_Ptr->Data_Buf_Ptr); + Output_Buffer_Ptr->Data_Buf_Len = Fused32((FBFR32 *)Output_Buffer_Ptr->Data_Buf_Ptr); + + /* doit on faire la maj du size et du len pour le FML ??? */ + } + } + + + return ( status ); +} + + +IMRT_Status FML_Hdl_Field_Exist(IMRT_Field *Field_Ptr , IMRT_Buffer *Buffer_Ptr , FLDID32 FML_Field) +{ + IMRT_Status status; + FLDOCC32 retour; + char *func_name = "FML_Hdl_Field_Exist"; + + + status = IMRS_OK; + retour = 0; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field pointer NULL" ); + } + else + { + retour = Foccur32((FBFR32 *)Buffer_Ptr->Data_Buf_Ptr, FML_Field); + + if (retour == 0 ) + { + status = IMRS_NO_IDENT; + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Field not exist"); + } + else if (retour == -1 ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Foccur32 error [%s]" , Fstrerror32(Ferror32)); + } + } + + + return ( status ); + +} + + +/* dans la fonction get, il conviendra d'etudier la necessite ou non de developper : + - la conversion des types + - la possibilite de champ multi-occurrence +*/ +IMRT_Status MM_FML_StrHdl_Get(IMRT_Buffer_Data **Data_Ptr_Ptr, IMRT_Field *Field_Ptr, + IMRT_Buffer *Buffer_Ptr , size_t *len ) +{ + IMRT_Buffer_Data *data_ptr; + IMRT_Status status; + int retour; + FLDID32 FML_Field; + size_t sizeTmp; + char *func_name = "MM_FML_StrHdl_Get"; + + + + status = IMRS_OK; + retour = 0; + data_ptr = NULL; + sizeTmp = 0L; + + if (Data_Ptr_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Ptr_Ptr NULL"); + } + else if (len == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("len pointer NULL"); + } + else if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer_Ptr NULL"); + } + else if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + /* Controle de validite du tag */ + if (strcmp(Field_Ptr->FML.Tag ,IMRD_FML_TAG_UNKNOWN) == 0) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Tag FML unknown"); + } + + if (status == IMRS_OK) + { + FML_Field = Fldid32( Field_Ptr->FML.Tag ); + + if ( FML_Field == BADFLDID ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Fldid32 %s BADFLDID error",Field_Ptr->FML.Tag ); + } + } + + if (status == IMRS_OK) + { + status = FML_Hdl_Field_Exist(Field_Ptr , Buffer_Ptr , FML_Field); + } + /* Le champ n'existe pas => on prend la valeur par defaut */ + if (status == IMRS_NO_IDENT) + { + sizeTmp = strlen(Field_Ptr->FML.Def_Val); + data_ptr = (IMRT_Buffer_Data *) malloc ( sizeTmp + 1); + if (data_ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Malloc error"); + } + else + { + memset( data_ptr, '\0', sizeTmp + 1 ); + memcpy(data_ptr , Field_Ptr->FML.Def_Val , sizeTmp ); + *(data_ptr + sizeTmp) = '\0'; + *Data_Ptr_Ptr = data_ptr; + status = IMRS_OK; + } + } + /* le champ existe => on extrait la valeur */ + else if (status == IMRS_OK) + { + /*data_ptr = (IMRT_Buffer_Data *) malloc ( (Field_Ptr->Fixed.Size + 1)); + memset( data_ptr, '\0', Field_Ptr->Fixed.Size + 1 );*/ + data_ptr = (IMRT_Buffer_Data *) malloc ( IMRD_FML_SIZE); + memset( data_ptr, '\0', IMRD_FML_SIZE ); + retour = (IMRT_Status)Fget32((FBFR32 *)Buffer_Ptr->Data_Buf_Ptr, + FML_Field, + (FLDOCC32 )0L, + (char *)data_ptr, + 0); + + + if (retour == -1) + { + IMRD_LM_LOG_ERROR_3("Fget32 failed with error [%s] Field (%d) [%s]" , Fstrerror32(Ferror32) , FML_Field, Fname32(FML_Field)); + status = IMRS_KO; + } + else + { + *Data_Ptr_Ptr = data_ptr; + sizeTmp = (size_t) strlen(data_ptr); + } + } + + if (status == IMRS_OK) + { + *len = sizeTmp; + } + + + return ( status ); +} + + +IMRT_Status IMR_MM_FML_StrHdl_Msg_Size ( size_t Msg_Size) +{ + IMRT_Status status; + char *func_name = "IMR_MM_FML_StrHdl_Msg_Size"; + + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Size msg demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Msg_Size : (%ld)" , Msg_Size); + + /* Erreur de referentiel */ + status = IMRS_KO; + IMRD_LM_LOG_WARNING_0("Referential error ; this should never happen"); + + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Size msg demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + + +IMRT_Status IMR_MM_FML_StrHdl_Field_Exist( IMRT_Field *Field_Ptr ) +{ + IMRT_Status status; + FLDID32 FML_Field; + char *func_name = "IMR_MM_FML_StrHdl_Field_Exist"; + + status = IMRS_OK; + + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + { + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Existing field demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Input name : [%s]" , Field_Ptr->Name); + + if (IMRG_FML_Buffer_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL"); + } + + if (status == IMRS_OK) + { + FML_Field = Fldid32( Field_Ptr->FML.Tag ); + } + + if ( FML_Field == BADFLDID ) + { + status = IMRS_NO_IDENT; + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Field [%s] BADFLDID error",Field_Ptr->FML.Tag ); + } + + if (status == IMRS_OK) + { + status = FML_Hdl_Field_Exist(Field_Ptr , IMRG_FML_Buffer_Ident_Ptr , FML_Field); + } + } + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Existing field demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + +IMRT_Status IMR_MM_FML_StrHdl_Field_Value( IMRT_Field *Field_Ptr , IMRT_Field_Value_Id Value_Id ) +{ + IMRT_Buffer_Data *data_ptr; + IMRT_Status status; + size_t field_len; + char *func_name = "IMR_MM_FML_StrHdl_Field_Value"; + + status = IMRS_OK; + + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + { + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Value demand : Begin"); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Input name : [%s] Value Id : [%s]" , Field_Ptr->Name , Value_Id); + + field_len = 0L; + + if (IMRG_FML_Buffer_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL"); + } + else + { + status = MM_FML_StrHdl_Get(&data_ptr, Field_Ptr, IMRG_FML_Buffer_Ident_Ptr , &field_len ); + } + if (status == IMRS_OK) + { + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Value extracted : [%s]" , data_ptr); + if (strcmp(data_ptr, Value_Id) != 0) + { + status = IMRS_NO_IDENT; + } + free(data_ptr); + } + } + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Field Value demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + +IMRT_Status MM_FML_StrHdl_Convert(IMRT_Buffer_Data **Data_Output_Ptr , IMRT_Buffer_Data *Data_Input_Ptr , IMRT_Field *Field_Ptr, + size_t *len , IMRT_StrHdl_Cnv_Func *Cnv_Func_Tab ) +{ + IMRT_Status status; + size_t size; + char *func_name = "MM_FML_StrHdl_Convert"; + + status = IMRS_OK; + + if (len == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("len pointer NULL"); + } + else if (Data_Output_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Output_Ptr NULL"); + } + else + { + size = *len ; + *Data_Output_Ptr = (IMRT_Buffer_Data *)malloc(size + 1L); + if (*Data_Output_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("*Data_Output_Ptr NULL"); + } + else + { + memset( *Data_Output_Ptr, '\0' , (size + 1L) ); + } + + if (status == IMRS_OK) + { + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + if (Data_Input_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Input_Ptr NULL"); + } + else if (Cnv_Func_Tab == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Cnv_Func_Tab NULL"); + } + else + { + /* Appel de la fonction de convertion */ + if ((Field_Ptr->FML.Cnv_Ptr == NULL) || (Cnv_Func_Tab[Field_Ptr->FML.Cnv_Ptr->Id].Convert_Ptr == NULL)) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1 , "Pas de fonction de conversion"); + + if (Data_Input_Ptr != NULL) + memcpy(*Data_Output_Ptr,Data_Input_Ptr,*len); + } + else + { + status = Cnv_Func_Tab[Field_Ptr->FML.Cnv_Ptr->Id].Convert_Ptr(*Data_Output_Ptr, + Data_Input_Ptr, + len, + size , + Field_Ptr->FML.Cnv_Attr ); + } + + } + } + } + + if (Data_Input_Ptr != NULL) + free(Data_Input_Ptr); + + + return ( status ); + +} + +IMRT_Status MM_FML_StrHdl_Put(IMRT_Buffer_Data *Data_Ptr, IMRT_Field *Field_Ptr, + IMRT_Buffer *Buffer_Ptr , size_t len ) +{ + IMRT_Buffer_Data *data_buf_ptr; + FLDID32 FML_Field; + FLDLEN32 FML_maxlen; + IMRT_Status status; + int retour; + char *func_name = "MM_FML_StrHdl_Put"; + size_t longueur; + int FML_Field_Type; + + status = IMRS_OK; + retour = 0; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer_Ptr NULL"); + } + else if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else if (Data_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("data pointer NULL"); + } + else + /* Controle de validite du tag */ + if (strcmp(Field_Ptr->FML.Tag ,IMRD_FML_TAG_UNKNOWN) == 0) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Tag FML unknown"); + } + + if ((status == IMRS_OK) && (strcmp(Data_Ptr , "") == 0)) + status = IMRD_STATUS_NOTHING_TO_DO; + + if (status == IMRS_OK) + { + FML_maxlen = (FLDLEN32)0L; + FML_Field = Fldid32( Field_Ptr->FML.Tag ); + if ( FML_Field == BADFLDID ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Fldid32 %s BADFLDID error",Field_Ptr->FML.Tag ); + } + else + { + FML_Field_Type = Fldtype32(FML_Field); + if (FML_Field_Type == FLD_CARRAY) + { + longueur = len; + } + else + { + longueur = 0L; + } + + retour = Fadd32((FBFR32 *)Buffer_Ptr->Data_Buf_Ptr, + FML_Field, + (char *)Data_Ptr, + (FLDLEN32) longueur); + + if (retour == -1) + { + if (Ferror32 == FNOSPACE) + /* prevoir la realloc */ + { + IMRD_LM_LOG_ERROR_0("Ferror32 = FNOSPACE"); + } + else if (Ferror32 == FALIGNERR) + { + IMRD_LM_LOG_ERROR_0("Ferror32 = FALIGNERR"); + } + else if (Ferror32 == FNOTFLD) + { + IMRD_LM_LOG_ERROR_0("Ferror32 = FNOTFLD"); + } + else if (Ferror32 == FEINVAL) + { + IMRD_LM_LOG_ERROR_0("Ferror32 = FEINVAL"); + } + else if (Ferror32 == FBADFLD) + { + IMRD_LM_LOG_ERROR_0("Ferror32 = FBADFLD"); + } + status = IMRS_KO; + } + } + } + + if (status == IMRS_OK) + { + /* Mise a jour de la taille du buffer */ + Buffer_Ptr->Data_Buf_Len = (Buffer_Ptr->Data_Buf_Len) + Fsizeof32((FBFR32 *)Buffer_Ptr->Data_Buf_Ptr); + } + + if (status == IMRD_STATUS_NOTHING_TO_DO) + status = IMRS_OK; + + if (Data_Ptr != NULL) + free(Data_Ptr); + + + return ( status ); +} diff --git a/src/libmapping_mng/src/fmt_hdl_fml.h b/src/libmapping_mng/src/fmt_hdl_fml.h new file mode 100644 index 0000000..5716d28 --- /dev/null +++ b/src/libmapping_mng/src/fmt_hdl_fml.h @@ -0,0 +1,108 @@ +/*----------------------------------------------------------------------------*/ +/* File: fmt_hdl_xml.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _FML_HANDLER_H_ +#define _FML_HANDLER_H_ + +#include "fml.h" +#include "fml32.h" +#include "atmi.h" +#include "field.tbls.h" +#include "userlog.h" + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Local definition */ +/*----------------------------------------------------------------------------*/ + +#ifdef _FML_HANDLER_C_ + + #define IMRD_FML_TYPE "FML32" + #define IMRD_FML_SIZE (FLDLEN32)10000L + #define IMRD_FML_MAX_FLD (FLDOCC32)50L + +#endif + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +#ifdef _FML_HANDLER_C_ + + IMRT_Buffer *IMRG_FML_Buffer_Ident_Ptr; + +#endif + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _FML_HANDLER_C_ + + IMRT_Status MM_FML_StrHdl_Init ( void ); + IMRT_Status MM_FML_StrHdl_DeInit ( void ); + IMRT_Status FML_Hdl_DataBuf_Alloc ( IMRT_Buffer * ); + IMRT_Status MM_FML_StrHdl_Data_Free ( IMRT_Buffer * ); + IMRT_Status FML_Hdl_Format_Ident ( IMRT_Buffer * ); + IMRT_Status MM_FML_StrHdl_Ident ( IMRT_Msg_Id * , IMRT_Buffer * ); + IMRT_Status MM_FML_StrHdl_Open ( IMRT_Buffer * ); + IMRT_Status MM_FML_StrHdl_Close ( IMRT_Buffer * ); + IMRT_Status MM_FML_StrHdl_Flush ( IMRT_Buffer * ); + IMRT_Status MM_FML_StrHdl_Data_List ( IMRT_Buffer * ); + IMRT_Status MM_FML_StrHdl_Copy ( IMRT_Buffer * , IMRT_Buffer * ); + IMRT_Status FML_Hdl_Field_Exist ( IMRT_Field * , IMRT_Buffer * , FLDID32 ); + IMRT_Status MM_FML_StrHdl_Get (IMRT_Buffer_Data ** , IMRT_Field * , IMRT_Buffer * , size_t * ); + IMRT_Status MM_FML_StrHdl_Convert (IMRT_Buffer_Data ** , IMRT_Buffer_Data * , IMRT_Field * , size_t *, IMRT_StrHdl_Cnv_Func * ); + IMRT_Status MM_FML_StrHdl_Put (IMRT_Buffer_Data * , IMRT_Field * , IMRT_Buffer * , size_t ); + IMRT_Status IMR_MM_FML_StrHdl_Field_Value ( IMRT_Field * , IMRT_Field_Value_Id); + IMRT_Status IMR_MM_FML_StrHdl_Field_Exist ( IMRT_Field * ); + IMRT_Status IMR_MM_FML_StrHdl_Msg_Size ( size_t ); + +#else + + extern IMRT_Status MM_FML_StrHdl_Init ( void ); + extern IMRT_Status MM_FML_StrHdl_DeInit ( void ); + extern IMRT_Status MM_FML_StrHdl_Data_Free ( IMRT_Buffer * ); + extern IMRT_Status MM_FML_StrHdl_Ident ( IMRT_Msg_Id * , IMRT_Buffer * ); + extern IMRT_Status MM_FML_StrHdl_Open ( IMRT_Buffer * ); + extern IMRT_Status MM_FML_StrHdl_Close ( IMRT_Buffer * ); + extern IMRT_Status MM_FML_StrHdl_Flush ( IMRT_Buffer * ); + extern IMRT_Status MM_FML_StrHdl_Data_List ( IMRT_Buffer * ); + extern IMRT_Status MM_FML_StrHdl_Copy ( IMRT_Buffer * , IMRT_Buffer * ); + extern IMRT_Status MM_FML_StrHdl_Get (IMRT_Buffer_Data ** , IMRT_Field * , IMRT_Buffer * , size_t * ); + extern IMRT_Status MM_FML_StrHdl_Convert (IMRT_Buffer_Data ** , IMRT_Buffer_Data * , IMRT_Field * , size_t *, IMRT_StrHdl_Cnv_Func * ); + extern IMRT_Status MM_FML_StrHdl_Put (IMRT_Buffer_Data * , IMRT_Field * , IMRT_Buffer * , size_t ); + +#endif + +#endif diff --git a/src/libmapping_mng/src/fmt_hdl_xml.c b/src/libmapping_mng/src/fmt_hdl_xml.c new file mode 100644 index 0000000..7240df3 --- /dev/null +++ b/src/libmapping_mng/src/fmt_hdl_xml.c @@ -0,0 +1,1260 @@ +/*----------------------------------------------------------------------------*/ +/* File: fmt_hdl_.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _XML_HANDLER_C_ + +#include "fmt_hdl_xml.h" + +IMRT_Status MM_XML_StrHdl_Init() +{ + IMRG_XML_Buffer_Ident_Ptr = NULL; + return (IMRS_OK); +} + +IMRT_Status MM_XML_StrHdl_DeInit() +{ + + return (IMRS_OK); +} + +IMRT_Status XML_Hdl_DataTemp_Alloc( IMRT_Buffer *Buffer_Ptr ) +{ + xmlDocPtr xml_doc_ptr=NULL; + IMRT_Status status; + char *func_name = "XML_Hdl_DataTemp_Alloc"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Data_Tmp_Ptr == NULL) + { + if ( Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) + { + xml_doc_ptr = xmlParseMemory( (char *) Buffer_Ptr->Data_Buf_Ptr, Buffer_Ptr->Data_Buf_Size); + } + else + { + xml_doc_ptr = xmlNewDoc ((xmlChar *) IMRD_XML_VERSION); + } + if ( xml_doc_ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Pointer xml_doc_ptr NULL"); + } + else + { + Buffer_Ptr->Data_Tmp_Ptr = (IMRT_Buffer_Data *) xml_doc_ptr; + Buffer_Ptr->Data_Tmp_Changed = IMRD_FALSE; + } + } + + return ( status ); +} + +IMRT_Status XML_Hdl_DataTemp_Free( IMRT_Buffer *Buffer_Ptr ) +{ + IMRT_Status status; + char *func_name = "XML_Hdl_DataTemp_Free"; + + + status = IMRS_OK; + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Data_Tmp_Ptr != NULL) + { + xmlFreeDoc( (xmlDocPtr) Buffer_Ptr->Data_Tmp_Ptr); + xmlCleanupParser(); + Buffer_Ptr->Data_Tmp_Ptr = NULL; + Buffer_Ptr->Data_Tmp_Changed = IMRD_FALSE; + } + + return ( status ); +} + +IMRT_Status XML_Hdl_DataBuf_Free( IMRT_Buffer *Buffer_Ptr ) +{ + IMRT_Status status; + char *func_name = "XML_Hdl_DataBuf_Free"; + + + status = IMRS_OK; + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) + { + xmlFree(Buffer_Ptr->Data_Buf_Ptr); + Buffer_Ptr->Data_Buf_Ptr = NULL; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_FREED; + Buffer_Ptr->Data_Buf_Size = 0; + Buffer_Ptr->Data_Buf_Len = 0; + } + + return ( status ); +} + +IMRT_Status MM_XML_StrHdl_Data_Free( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_XML_StrHdl_Data_Free"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + if ( XML_Hdl_DataBuf_Free( Buffer_Ptr ) != IMRS_OK ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Error XML_Hdl_DataBuf_Free"); + + } + if ( XML_Hdl_DataTemp_Free( Buffer_Ptr ) != IMRS_OK ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Error XML_Hdl_DataTemp_Free"); + } + } + + + return ( status ); +} + +IMRT_Status XML_Hdl_Format_Ident( IMRT_Buffer *Buffer_Ptr ) +{ + IMRT_Status status; + char *func_name = "XML_Hdl_Format_Ident"; + + + status = IMRS_KO; + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer not allocated"); + } + else + { + if (*Buffer_Ptr->Data_Buf_Ptr == (IMRT_Buffer_Data) '<') + { + status = IMRS_OK; + } + } + + + return ( status ); +} + +IMRT_Status MM_XML_StrHdl_Ident( IMRT_Msg_Id *Msg_Id_Ident_Ptr, + IMRT_Buffer *Buffer_Ptr ) +{ + + IMRT_Fmt_Id Format; + IMRT_Status status; + IMRT_Msg_Id *Msg_Id_Tmp; + char *func_name = "MM_XML_StrHdl_Ident"; + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Msg_Id_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Msg_Id_Ident_Ptr NULL" ); + } + else + { + Format = Buffer_Ptr->Fmt_Id; + Msg_Id_Tmp = Msg_Id_Ident_Ptr; + + IMRG_XML_Buffer_Ident_Ptr = Buffer_Ptr; + /* Le Msg_Id transmis au SDM est le point de depart de l'identification */ + /* C'est egalement le resultat qui sera inclus dans le buffer */ + status = IMR_SDM_MsgIdent_Proceed(Format, + Msg_Id_Tmp, + IMR_MM_XML_StrHdl_Field_Value, + IMR_MM_XML_StrHdl_Field_Exist, + IMR_MM_XML_StrHdl_Msg_Size); + IMRG_XML_Buffer_Ident_Ptr = NULL; + + Msg_Id_Ident_Ptr = Msg_Id_Tmp; + } + + + return ( status ); + +} + +IMRT_Status MM_XML_StrHdl_Open( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Msg_Id type_temp; + IMRT_Status status; + char *func_name = "MM_XML_StrHdl_Open"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Buffer_Ptr->Data_Tmp_Ptr != NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Pointer Data_Tmp_Ptr NULL"); + } + else + { + type_temp = Buffer_Ptr->Msg_Id; + /* absence de donnees */ + if (Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + /* Cas d'open du buffer en ecriture */ + /* le type du message est passe */ + /* par le SDM : il doit donc etre connu */ + if (type_temp == IMRD_MSG_ID_UNKNOWN) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Msg Id unknown"); + } + else + { + status = XML_Hdl_DataTemp_Alloc( Buffer_Ptr ); + Buffer_Ptr->Data_Tmp_Changed = IMRD_TRUE; + } + } + else + { + /* controle du format */ + status = XML_Hdl_Format_Ident( Buffer_Ptr ); + if (status != IMRS_OK) + status = IMRS_BAD_FORMAT; + else + /* acces aux donnees */ + status = XML_Hdl_DataTemp_Alloc( Buffer_Ptr ); + } + } + + return ( status ); +} + +IMRT_Status MM_XML_StrHdl_Close( IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "MM_XML_StrHdl_Close"; + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + { + status = MM_XML_StrHdl_Flush( Buffer_Ptr ); + if ((status == IMRS_OK) && (Buffer_Ptr->Data_Tmp_Ptr != NULL)) + { + status = XML_Hdl_DataTemp_Free( Buffer_Ptr ); + } + } + + return ( status ); +} + +IMRT_Status MM_XML_StrHdl_Flush( IMRT_Buffer *Buffer_Ptr) +{ + xmlChar *mem_Ptr; + int size; + IMRT_Status status; + char *func_name = "MM_XML_StrHdl_Flush"; + + + status = IMRS_OK; + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if ((Buffer_Ptr->Data_Tmp_Ptr != NULL) && (Buffer_Ptr->Data_Tmp_Changed == IMRD_TRUE)) + { + if ( Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED ) + { + status = XML_Hdl_DataBuf_Free( Buffer_Ptr ); + } + + if ( status == IMRS_OK ) + { + + /* Dump an XML document in memory and return the #xmlChar * and it's size in bytes. + It's up to the caller to free the memory with xmlFree(). + The resulting byte array is zero terminated, though the last 0 is not included + in the returned size. */ + xmlDocDumpFormatMemory( (xmlDocPtr) Buffer_Ptr->Data_Tmp_Ptr, &mem_Ptr, &size, + ( ( IMRG_MM_Base.Config.XML_Format == IMRD_TRUE) ? 1 : 0)); + + if (mem_Ptr != NULL) + { + Buffer_Ptr->Data_Buf_Ptr = (IMRT_Buffer_Data *) mem_Ptr; + Buffer_Ptr->Status = IMRD_BUFFER_STATUS_ALLOCATED; + Buffer_Ptr->Data_Buf_Size = size + 1; + Buffer_Ptr->Data_Buf_Len = size; + Buffer_Ptr->Data_Tmp_Changed = IMRD_FALSE; + } + else + { + status == IMRS_KO; + IMRD_LM_LOG_ERROR_0("Pointer mem_Ptr = NULL after xmlDocDumpMemory"); + } + } + } + + + return ( status ); +} + +IMRT_Status MM_XML_StrHdl_Data_List( IMRT_Buffer *Buffer_Ptr) +{ + + if (Buffer_Ptr == NULL) + { + IMRD_LM_LOG_WARNING_0("Buffer pointer NULL" ); + } + else + { + IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Data_Buf_Ptr_Size: (%d) Data_Buf_Ptr_Len: (%d) Data_Buf_Ptr: (0x%X)", Buffer_Ptr->Data_Buf_Size, Buffer_Ptr->Data_Buf_Len, Buffer_Ptr->Data_Buf_Ptr); + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_2, "Buffer_List: Data_Buf: [%s]", Buffer_Ptr->Data_Buf_Ptr); + + IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "Buffer_List: Data_Tmp_Changed: (%d) Data_Tmp_Ptr: (0x%X)", Buffer_Ptr->Data_Tmp_Changed, Buffer_Ptr->Data_Tmp_Ptr); + + if (Buffer_Ptr->Data_Tmp_Ptr != NULL) + { + IMRD_LM_EXEC_TRACE( IMRD_LOG_LEVEL_VERBOSE_2, "Buffer_List: Data_Tmp: [", xmlDocFormatDump( IMRD_LM_STREAM_OUT, (xmlDocPtr) Buffer_Ptr->Data_Tmp_Ptr, 1), "]"); + } + } + + return ( IMRS_OK); +} + + + +IMRT_Status MM_XML_StrHdl_Copy( IMRT_Buffer *Output_Buffer_Ptr, IMRT_Buffer *Input_Buffer_Ptr ) +{ + IMRT_Status status; + char *func_name = "MM_XML_StrHdl_Copy"; + + + status = IMRS_OK; + + if (Input_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Input buffer pointer NULL" ); + } + else + if (Output_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Output buffer pointer NULL" ); + } + else + /* controle donnees dans Input_Buffer */ + if (Input_Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer input not allocated"); + } + /* le buffer destinataire ne doit pas comporter de donnees */ + else if ( ( Output_Buffer_Ptr->Status == IMRD_BUFFER_STATUS_ALLOCATED) || + ( Output_Buffer_Ptr->Data_Tmp_Ptr != NULL) ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer output not allocated or Data_Tmp_Ptr no NULL"); + } + else + { + Output_Buffer_Ptr->Data_Buf_Ptr = (IMRT_Buffer_Data *) malloc ( Input_Buffer_Ptr->Data_Buf_Size ); + if (Output_Buffer_Ptr->Data_Buf_Ptr != NULL) + { + memcpy( Output_Buffer_Ptr->Data_Buf_Ptr, + Input_Buffer_Ptr->Data_Buf_Ptr, + Input_Buffer_Ptr->Data_Buf_Size); + Output_Buffer_Ptr->Status = IMRD_BUFFER_STATUS_ALLOCATED; + Output_Buffer_Ptr->Data_Buf_Size = Input_Buffer_Ptr->Data_Buf_Size; + Output_Buffer_Ptr->Data_Buf_Len = Input_Buffer_Ptr->Data_Buf_Len; + } + else + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Pointer Data_Buf_Ptr of output buffer is NULL"); + } + } + + + return ( status ); +} + +IMRT_Status XML_Hdl_Field_Exist(IMRT_Field *Field_Ptr , IMRT_Buffer *Buffer_Ptr) +{ + IMRT_Status status; + xmlXPathContextPtr context; + xmlNodeSetPtr nodeset; + xmlXPathObjectPtr result; + xmlDocPtr xml_doc_ptr; + xmlChar *xpath; + + char *func_name = "XML_Hdl_Field_Exist"; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL" ); + } + else + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field pointer NULL" ); + } + else + if (Buffer_Ptr->Data_Tmp_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Tmp_Ptr of buffer is NULL"); + } + else + { + xml_doc_ptr = (xmlDocPtr) Buffer_Ptr->Data_Tmp_Ptr; + xpath = (xmlChar *) Field_Ptr->XML.Tag; + context = xmlXPathNewContext(xml_doc_ptr); + result = xmlXPathEvalExpression(xpath, context); + if (result == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("XPath eval expression pointer NULL" ); + } + else + { + + if(xmlXPathNodeSetIsEmpty(result->nodesetval)) + { + status = IMRS_NO_IDENT; + } + else + { + nodeset = result->nodesetval; + + if (nodeset->nodeNr != 1) + { + status = IMRS_NO_IDENT; + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "number of occurences not equal to one for %s",Field_Ptr->Name); + } + } + xmlXPathFreeContext(context); + xmlXPathFreeObject(result); + } + } + + + + + return ( status ); + +} + + +IMRT_Status MM_XML_StrHdl_Get(IMRT_Buffer_Data **Data_Ptr_Ptr, IMRT_Field *Field_Ptr, + IMRT_Buffer *Buffer_Ptr , size_t *len ) +{ + IMRT_Buffer_Data *data_ptr; + int sizeTmp; + xmlXPathContextPtr context; + xmlXPathObjectPtr result; + xmlNodeSetPtr nodeset; + xmlDocPtr xml_doc_ptr; + xmlChar *xpath, + *xml_data_ptr; + IMRT_Status status; + char *func_name = "MM_XML_StrHdl_Get"; + + + status = IMRS_OK; + *Data_Ptr_Ptr = NULL; + data_ptr = NULL; + sizeTmp = 0; + + if (Data_Ptr_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Ptr_Ptr NULL"); + } + else if (len == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("len pointer NULL"); + } + else if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer_Ptr NULL"); + } + else if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + + /* Controle de validite du tag */ + if ((status == IMRS_OK) && (strcmp(Field_Ptr->XML.Tag ,IMRD_XML_TAG_UNKNOWN) == 0)) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Tag XML unknown"); + } + + /* controle donnees dans le buffer */ + if ((status == IMRS_OK) && (Buffer_Ptr->Data_Tmp_Ptr == NULL)) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Tmp_Ptr of buffer is NULL"); + } + else + { + xml_doc_ptr = (xmlDocPtr) Buffer_Ptr->Data_Tmp_Ptr; + xpath = (xmlChar *) Field_Ptr->XML.Tag; + context = xmlXPathNewContext(xml_doc_ptr); + result = xmlXPathEvalExpression(xpath, context); + if (result == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("XPath eval expression pointer NULL" ); + } + else if(xmlXPathNodeSetIsEmpty(result->nodesetval)) + { + status = IMRS_NO_IDENT; + } + xmlXPathFreeContext(context); + } + + + + /* le champ existe => on extrait la valeur */ + if (status == IMRS_OK) + { + nodeset = result->nodesetval; + /* nombre d'occurences */ + if (nodeset->nodeNr != 1) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("number of occurences not equal to one for %s",Field_Ptr->Name); + } + else + { + xml_data_ptr = xmlNodeListGetString(xml_doc_ptr, nodeset->nodeTab[0]->xmlChildrenNode, 1); + if (xml_data_ptr == NULL) + { + status = IMRS_NO_IDENT; + } + else + { + + sizeTmp = strlen((char *)xml_data_ptr) + 1; + +// IMRD_LM_LOG_TRACE_2( IMRD_LOG_LEVEL_VERBOSE_1, "[%s] (%d)", xml_data_ptr, sizeTmp); + + if( ( *Data_Ptr_Ptr = (IMRT_Buffer_Data *)malloc( sizeTmp)) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0 ( "Can't allocate memory..."); + } + else + { + UTF8Toisolat1( (unsigned char *)*Data_Ptr_Ptr, &sizeTmp, xml_data_ptr, &sizeTmp); + +// IMRD_LM_LOG_TRACE_3( IMRD_LOG_LEVEL_VERBOSE_1, "[%s] (%d) (%d)", xml_data_ptr, sizeTmp, strlen( *Data_Ptr_Ptr)); + + sizeTmp = strlen( *Data_Ptr_Ptr); + } + + xmlFree( xml_data_ptr); + } + } + + } + + /* Le champ n'existe pas => on prend la valeur par defaut */ + if (status == IMRS_NO_IDENT) + { + sizeTmp = strlen(Field_Ptr->XML.Def_Val); + data_ptr = (IMRT_Buffer_Data *) malloc ( sizeTmp + 1); + if (data_ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Malloc error on data_ptr"); + } + else + { + memset( data_ptr, '\0', sizeTmp + 1 ); + memcpy(data_ptr , Field_Ptr->XML.Def_Val , sizeTmp ); + *(data_ptr + sizeTmp) = '\0'; + *Data_Ptr_Ptr = data_ptr; + status = IMRS_OK; + } + } + + if (status == IMRS_OK) + { + *len = sizeTmp; + } + + if(result != NULL) + xmlXPathFreeObject(result); + + return ( status ); +} + + +IMRT_Status IMR_MM_XML_StrHdl_Msg_Size ( size_t Msg_Size) +{ + IMRT_Status status; + char *func_name = "IMR_MM_XML_StrHdl_Msg_Size"; + + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Size msg demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Msg_Size : (%ld)" , Msg_Size); + + /* Erreur de referentiel */ + status = IMRS_KO; + IMRD_LM_LOG_WARNING_0("Referential error ; this should never happen"); + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Size msg demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + + +IMRT_Status IMR_MM_XML_StrHdl_Field_Exist( IMRT_Field *Field_Ptr ) +{ + IMRT_Status status; + char *func_name = "IMR_MM_XML_StrHdl_Field_Exist"; + + status = IMRS_OK; + + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + { + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Existing field demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Input name : [%s]" , Field_Ptr->Name); + + if (IMRG_XML_Buffer_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL"); + } + else + { + status = XML_Hdl_Field_Exist( Field_Ptr, IMRG_XML_Buffer_Ident_Ptr); + } + } + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Existing field demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + +IMRT_Status IMR_MM_XML_StrHdl_Field_Value( IMRT_Field *Field_Ptr , IMRT_Field_Value_Id Value_Id ) +{ + IMRT_Buffer_Data *data_ptr; + IMRT_Status status; + size_t field_len; + char *func_name = "IMR_MM_XML_StrHdl_Field_Value"; + + status = IMRS_OK; + + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + { + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Value demand : Begin"); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_1 , "Field Input name : [%s] Value Id : [%s]" , Field_Ptr->Name , Value_Id); + + field_len = 0L; + + if (IMRG_XML_Buffer_Ident_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL"); + } + else + { + status = MM_XML_StrHdl_Get(&data_ptr, Field_Ptr, IMRG_XML_Buffer_Ident_Ptr , &field_len ); + } + + if (status == IMRS_OK) + { + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Value extracted : [%s]" , data_ptr); + if (strcmp(data_ptr, Value_Id) != 0) + { + status = IMRS_NO_IDENT; + } + free(data_ptr); + } + } + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_2 , "Field Value demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "============================================================================") + + return ( status ); +} + +IMRT_Status MM_XML_StrHdl_Convert(IMRT_Buffer_Data **Data_Output_Ptr , IMRT_Buffer_Data *Data_Input_Ptr , IMRT_Field *Field_Ptr, + size_t *len , IMRT_StrHdl_Cnv_Func *Cnv_Func_Tab ) +{ + IMRT_Status status; + size_t size; + char *func_name = "MM_XML_StrHdl_Convert"; + + + + + status = IMRS_OK; + + if (len == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("len pointer NULL"); + } + else if (Data_Output_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Output_Ptr NULL"); + } + else if (Cnv_Func_Tab == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Cnv_Func_Tab NULL"); + } + else + { + size = *len ; + + *Data_Output_Ptr = (IMRT_Buffer_Data *)malloc(size + 1L); + if (*Data_Output_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("*Data_Output_Ptr NULL"); + } + else + { + memset( *Data_Output_Ptr, '\0' , (size + 1L) ); + + if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else + if (Data_Input_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Input_Ptr NULL"); + } + else + { + /* Appel de la fonction de convertion */ + if ((Field_Ptr->XML.Cnv_Ptr == NULL) || (Cnv_Func_Tab[Field_Ptr->XML.Cnv_Ptr->Id].Convert_Ptr == NULL)) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1 , "Pas de fonction de conversion"); + + if (Data_Input_Ptr != NULL) + memcpy(*Data_Output_Ptr,Data_Input_Ptr,*len); + } + else + { + status = Cnv_Func_Tab[Field_Ptr->XML.Cnv_Ptr->Id].Convert_Ptr(*Data_Output_Ptr, + Data_Input_Ptr, + len, + size , + Field_Ptr->XML.Cnv_Attr ); + } + } + } + } + + if (Data_Input_Ptr != NULL) + free(Data_Input_Ptr); + + + return ( status ); + +} + +IMRT_Status MM_XML_DInit_StructPath(IMRT_PARSE_PATH_XML * Parse_PathStruct_Ptr) +{ + int indexe = 0; + IMRT_Status status = IMRS_OK; + + if(Parse_PathStruct_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Parse_PathStruct_Ptr NULL"); + } + else + { + if(Parse_PathStruct_Ptr->Father_Table != NULL) + { + for(indexe=0; indexe < Parse_PathStruct_Ptr->Nb_Father; indexe++) + { + if(Parse_PathStruct_Ptr->Father_Table[indexe] != NULL) + { + free(Parse_PathStruct_Ptr->Father_Table[indexe]); + } + } + free(Parse_PathStruct_Ptr->Father_Table); + } + Parse_PathStruct_Ptr->Nb_Father = 0; + } + return(status); +} + +IMRT_Status MM_XML_Proceed_Path( IMRT_PARSE_PATH_XML * PathXml_Ptr, IMRT_Buffer_Data * value, xmlDocPtr xml_doc_ptr) +{ + xmlNodePtr xml_cur_node_ptr; + xmlNodePtr root_node_ptr; + xmlNodePtr xml_node1_ptr; + xmlNodePtr xml_father_node_ptr; + xmlNodePtr xml_brother_node_ptr; + xmlAttrPtr Attribute_Ptr; + + int indexe = 0; + IMRT_Status status; + + + status = IMRS_OK; + + if (PathXml_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("PathXml_Ptr NULL"); + } + else if (value == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("value NULL"); + } + else + if (xml_doc_ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("xml_doc_ptr NULL"); + } + else + { + + xml_cur_node_ptr = xmlDocGetRootElement(xml_doc_ptr); + + for(indexe = 0; indexe < PathXml_Ptr->Nb_Father; indexe++) + { + + while( ( xml_cur_node_ptr != NULL) && + (strcmp((const char*)xml_cur_node_ptr->name , + (const char*)PathXml_Ptr->Father_Table[indexe]) != 0) + ) + { + xml_brother_node_ptr = xml_cur_node_ptr; + xml_cur_node_ptr = xml_cur_node_ptr->next; + + } + + if(xml_cur_node_ptr == NULL) + { + /*il faut creer le root**/ + if(indexe == IMRD_FIRST_NODE ) + { + xml_father_node_ptr = xmlNewNode ( NULL, (const xmlChar *) PathXml_Ptr->Father_Table[indexe]); + if(xml_father_node_ptr != NULL) + { + xmlDocSetRootElement( xml_doc_ptr, xml_father_node_ptr ); + xml_cur_node_ptr = xml_father_node_ptr; + } + else + { + /*echec de la creation du nouveau noeud on sort*/ + status = IMRS_KO; + break; + } + } + else /*il faut creer un fils*/ + { + xml_cur_node_ptr = xmlNewChild( xml_father_node_ptr, NULL, (const xmlChar *) (const xmlChar *) PathXml_Ptr->Father_Table[indexe], NULL); + if(xml_cur_node_ptr != NULL) + { + xml_father_node_ptr= xml_cur_node_ptr; + + } + else + { + /*echec de la creation du nouveau noeud on sort*/ + status = IMRS_KO; + break; + } + } + } + else + { + xml_father_node_ptr = xml_cur_node_ptr; + xml_cur_node_ptr = xml_cur_node_ptr->xmlChildrenNode; + + } + } + /*Tout les pere existaient ou on ete crees*/ + /*creation d'un fils (feuille et insertion de sa valeur*/ + /*le pere vien d'être cree c'est le noeud courant*/ + /*si le mode est egale à 0 alors on est mode creation + le neoud pere vient d'être cree c'est le noeud courant*/ + xml_cur_node_ptr = xmlNewChild( xml_father_node_ptr, NULL, (const xmlChar *) PathXml_Ptr->Soon_Name, NULL); + if(xml_cur_node_ptr != NULL) + { + xml_node1_ptr = xmlNewText( (const xmlChar *) value ); + + if( PathXml_Ptr->Attribute_present == IMRS_OK ) + { + Attribute_Ptr = xmlNewProp(xml_cur_node_ptr,(const xmlChar *)PathXml_Ptr->Attribute_Name,(const xmlChar *)PathXml_Ptr->Attribute_Value); + } + + xmlAddChild(xml_cur_node_ptr,xml_node1_ptr); + } + else + { + status = IMRS_KO; + } + } + + + return(status); +} + +IMRT_Status MM_XML_SplitAttribute( IMRT_PARSE_PATH_XML * PathXml_Ptr ) +{ + char * pos_deb_attribute_ptr = NULL; + char * pos_fin_attribute_ptr = NULL; + size_t len_attribute_value; + static const char SEP_XPATH_DEB [] = "["; + static const char SEP_XPATH_FIN [] = "]"; + static const char SEP_ATTRIBUTE [] = "@"; + IMRT_Status status; + + + if (PathXml_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("PathXml_Ptr NULL"); + } + else + { + memset(PathXml_Ptr->Attribute_Name, '\0',sizeof(PathXml_Ptr->Attribute_Name)); + memset(PathXml_Ptr->Attribute_Value, '\0',sizeof(PathXml_Ptr->Attribute_Value)); + len_attribute_value = 0; + status = IMRS_OK; + + pos_deb_attribute_ptr = strstr((const char*)PathXml_Ptr->Soon_Name,SEP_XPATH_DEB); + pos_fin_attribute_ptr = strstr((const char*)PathXml_Ptr->Soon_Name,SEP_XPATH_FIN); + PathXml_Ptr->Attribute_present = IMRS_KO; + + + if( (pos_deb_attribute_ptr != NULL) && (pos_fin_attribute_ptr != NULL) ) + { + + + if(PathXml_Ptr->Soon_Name[(pos_deb_attribute_ptr -PathXml_Ptr->Soon_Name)+1 ] == '@') + { + /*on se positionne sur le debut de l'occurence*/ + pos_deb_attribute_ptr = pos_deb_attribute_ptr +2; + + pos_fin_attribute_ptr = strstr(PathXml_Ptr->Soon_Name,"="); + strncpy(PathXml_Ptr->Attribute_Name,pos_deb_attribute_ptr,(pos_fin_attribute_ptr - pos_deb_attribute_ptr)); + PathXml_Ptr->Attribute_Name[(pos_fin_attribute_ptr - pos_deb_attribute_ptr)] = '\0'; + + /*on se positionne au debut de la valeur*/ + pos_deb_attribute_ptr = pos_fin_attribute_ptr+1; + + len_attribute_value = (size_t) ( (PathXml_Ptr->Soon_Name + strlen(PathXml_Ptr->Soon_Name)) - pos_deb_attribute_ptr ) -3; + strncpy(PathXml_Ptr->Attribute_Value,pos_deb_attribute_ptr+1,len_attribute_value); + PathXml_Ptr->Attribute_present = IMRS_OK ; + } + + pos_deb_attribute_ptr = strstr((const char*)PathXml_Ptr->Soon_Name,SEP_XPATH_DEB); + PathXml_Ptr->Soon_Name[(pos_deb_attribute_ptr - PathXml_Ptr->Soon_Name)] = '\0'; + } + } + + return(status); +} + +IMRT_Status MM_XML_Split_Path( IMRT_Buffer_Data * Chaine_Ptr , IMRT_PARSE_PATH_XML * PathXml_Ptr ) +{ + int indexe = 0; + size_t len =0; + const char SEP_XML [] = "/"; + char * sep_position_prec = NULL; + char * sep_position_suiv = NULL; + char SEP_XML_CHAR = '/'; + IMRT_Status status; + +/*initialisation */ + + + if( Chaine_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("Le pointeur chaine a traiter est NULL"); + status = IMRS_KO; + } + else + if( PathXml_Ptr == NULL) + { + IMRD_LM_LOG_ERROR_0("PathXml_Ptr NULL"); + status = IMRS_KO; + } + else + { + PathXml_Ptr->Father_Table = NULL; + memset(PathXml_Ptr->Soon_Name, '\0', sizeof(PathXml_Ptr->Soon_Name)); + PathXml_Ptr->Nb_Father = 0; + len = strlen(Chaine_Ptr); + status = IMRS_OK; + + /*calcul du nombre de pere */ + for( indexe=0; indexe Nb_Father++; + } + } + /*si la chaîne commence par un / on en tien pas compte*/ + if(Chaine_Ptr[0] == SEP_XML_CHAR) + { + sep_position_suiv = Chaine_Ptr +1; + sep_position_prec = Chaine_Ptr +1; + PathXml_Ptr->Nb_Father = PathXml_Ptr->Nb_Father -1; + } + else + { + sep_position_suiv = Chaine_Ptr ; + sep_position_prec = Chaine_Ptr; + } + /* allocation du tableau de peres */ + PathXml_Ptr->Father_Table = (IMRT_FATHER_TABLE)malloc(sizeof(char *) * PathXml_Ptr->Nb_Father); + if( PathXml_Ptr->Father_Table == NULL) + { + /*erreur d'allocation memoire**/ + IMRD_LM_LOG_ERROR_0("Erreur allocation memoire"); + status = IMRS_KO; + } + else + { + for(indexe = 0 ; indexe < PathXml_Ptr->Nb_Father; indexe++) + { + PathXml_Ptr->Father_Table[indexe] = (char *)malloc(IMRD_FATHER_SIZE); + if(PathXml_Ptr->Father_Table[indexe] == NULL) + { + /*erreur allocation */ + IMRD_LM_LOG_ERROR_0("Erreur allocation memoire"); + status = IMRS_KO; + break ; + } + + } + + /*eclatement de la chaîne sur le n elemment on a + n-1 noeud et le n ieme elment est une feuille*/ + if(status == IMRS_OK) + { + for(indexe =0; indexe <= PathXml_Ptr->Nb_Father; indexe++) + { + /*on est a la fin de la chaine c'est une feuille */ + if( indexe == PathXml_Ptr->Nb_Father ) + { + strncpy(PathXml_Ptr->Soon_Name,sep_position_suiv,((Chaine_Ptr +len) - sep_position_suiv)); + PathXml_Ptr->Soon_Name[((Chaine_Ptr +len) - sep_position_suiv)] = '\0'; + status = MM_XML_SplitAttribute(PathXml_Ptr); + } + else + { + /*recopie des pere dans le tableau */ + sep_position_suiv = strstr((const char *)sep_position_suiv, SEP_XML); + if( sep_position_suiv != NULL) + { + strncpy(PathXml_Ptr->Father_Table[indexe], sep_position_prec, (sep_position_suiv - sep_position_prec)); + PathXml_Ptr->Father_Table[indexe][( sep_position_suiv - sep_position_prec)] = '\0'; + + sep_position_suiv = sep_position_suiv+1; + sep_position_prec = sep_position_suiv; + } + } + } + + } + } + } + return(status); +} + + + + +IMRT_Status MM_XML_StrHdl_Put(IMRT_Buffer_Data *Data_Ptr, IMRT_Field *Field_Ptr, + IMRT_Buffer *Buffer_Ptr , size_t len ) +{ + char *func_name = "MM_XML_StrHdl_Put"; + IMRT_Status status; + xmlDocPtr xml_doc_ptr; + IMRT_Buffer_Data tagxml_tab[IMRD_XML_TAG_LEN]; + IMRT_PARSE_PATH_XML Path_XML_Struct; + + + status = IMRS_OK; + + if (Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer_Ptr NULL"); + } + else if (Field_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Field_Ptr NULL"); + } + else if (Data_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("data pointer NULL"); + } + else + { + /* Controle de validite du tag */ + if (strcmp(Field_Ptr->XML.Tag ,IMRD_XML_TAG_UNKNOWN) == 0) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Tag XML unknown"); + } + } + + + if ((status == IMRS_OK) && (strcmp(Data_Ptr , "") == 0)) + status = IMRD_STATUS_NOTHING_TO_DO; + + if (status == IMRS_OK) + { + /* controle sur le buffer et la valeur */ + if (Buffer_Ptr->Data_Tmp_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer pointer NULL"); + } + else + { + xml_doc_ptr = (xmlDocPtr) Buffer_Ptr->Data_Tmp_Ptr; + strcpy( tagxml_tab, (IMRT_Buffer_Data *) Field_Ptr->XML.Tag); + //status = MM_XML_Init_StructPath(&Path_XML_Struct); + + if(status == IMRS_OK) + { + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_2 , "Tag xml [%s] ",tagxml_tab); + status = MM_XML_Split_Path( tagxml_tab ,&Path_XML_Struct ); + if(status == IMRS_OK) + { + status = MM_XML_Proceed_Path( &Path_XML_Struct,Data_Ptr, xml_doc_ptr); + } + } + status = MM_XML_DInit_StructPath(&Path_XML_Struct); + } + } + + if (status == IMRS_OK) + { + /* Mise a jour de la taille du buffer */ + Buffer_Ptr->Data_Buf_Len = (Buffer_Ptr->Data_Buf_Len) + len; + } + + if (status == IMRD_STATUS_NOTHING_TO_DO) + status = IMRS_OK; + + if (Data_Ptr != NULL) + free(Data_Ptr); + + return(status); +} + + diff --git a/src/libmapping_mng/src/fmt_hdl_xml.h b/src/libmapping_mng/src/fmt_hdl_xml.h new file mode 100644 index 0000000..49c7cc7 --- /dev/null +++ b/src/libmapping_mng/src/fmt_hdl_xml.h @@ -0,0 +1,135 @@ +/*----------------------------------------------------------------------------*/ +/* File: fmt_hdl_xml.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _XML_HANDLER_H_ +#define _XML_HANDLER_H_ + +#include +#include + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + + +/*----------------------------------------------------------------------------*/ +/* Local definition */ +/*----------------------------------------------------------------------------*/ + +#ifdef _XML_HANDLER_C_ + +# define IMRD_XML_VERSION "1.0" +# define IMRD_XML_BALISE "/" +# define IMRD_SOON_SIZE 100 +# define IMRD_FIRST_NODE 0 +# define IMRD_FATHER_SIZE 100 +# define IMRD_ATTIBUTE_SIZE 100 + + typedef int IMRT_NB_FATHER ; + typedef char ** IMRT_FATHER_TABLE; + + + typedef struct IMRT_PARSE_PATH_XML + { + IMRT_NB_FATHER Nb_Father; + IMRT_Status Attribute_present; + IMRT_FATHER_TABLE Father_Table; + char Soon_Name[IMRD_SOON_SIZE]; + char Attribute_Name[IMRD_ATTIBUTE_SIZE]; + char Attribute_Value[IMRD_ATTIBUTE_SIZE]; + + }IMRT_PARSE_PATH_XML; + +#endif + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +#ifdef _XML_HANDLER_C_ + + IMRT_Buffer *IMRG_XML_Buffer_Ident_Ptr; + +#endif + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +#ifdef _XML_HANDLER_C_ + + IMRT_Status MM_XML_StrHdl_Init ( void ); + IMRT_Status MM_XML_StrHdl_DeInit ( void ); + IMRT_Status XML_Hdl_DataTemp_Alloc ( IMRT_Buffer * ); + IMRT_Status XML_Hdl_DataTemp_Free ( IMRT_Buffer * ); + IMRT_Status XML_Hdl_DataBuf_Free ( IMRT_Buffer * ); + IMRT_Status MM_XML_StrHdl_Data_Free ( IMRT_Buffer * ); + IMRT_Status XML_Hdl_Format_Ident ( IMRT_Buffer * ); + IMRT_Status MM_XML_StrHdl_Ident ( IMRT_Msg_Id * , IMRT_Buffer * ); + IMRT_Status MM_XML_StrHdl_Open ( IMRT_Buffer * ); + IMRT_Status MM_XML_StrHdl_Close ( IMRT_Buffer * ); + IMRT_Status MM_XML_StrHdl_Flush ( IMRT_Buffer * ); + IMRT_Status MM_XML_StrHdl_Data_List ( IMRT_Buffer * ); + IMRT_Status MM_XML_StrHdl_Copy ( IMRT_Buffer * , IMRT_Buffer * ); + IMRT_Status XML_Hdl_Field_Exist ( IMRT_Field * , IMRT_Buffer * ); + IMRT_Status MM_XML_StrHdl_Get ( IMRT_Buffer_Data ** , IMRT_Field * , IMRT_Buffer * , size_t * ); + IMRT_Status MM_XML_StrHdl_Convert ( IMRT_Buffer_Data ** , IMRT_Buffer_Data * , IMRT_Field * , size_t *, IMRT_StrHdl_Cnv_Func * ); + IMRT_Status MM_XML_StrHdl_Put ( IMRT_Buffer_Data * , IMRT_Field * , IMRT_Buffer * , size_t ); + IMRT_Status IMR_MM_XML_StrHdl_Field_Value ( IMRT_Field * , IMRT_Field_Value_Id); + IMRT_Status IMR_MM_XML_StrHdl_Field_Exist ( IMRT_Field * ); + IMRT_Status IMR_MM_XML_StrHdl_Msg_Size ( size_t ); + IMRT_Status MM_XML_DInit_StructPath (IMRT_PARSE_PATH_XML * ); + IMRT_Status MM_XML_Proceed_Path ( IMRT_PARSE_PATH_XML * , IMRT_Buffer_Data * , xmlDocPtr ); + IMRT_Status MM_XML_Split_Path ( IMRT_Buffer_Data * Chaine_Ptr , IMRT_PARSE_PATH_XML * PathXml_Ptr ); + IMRT_Status MM_XML_SplitAttribute ( IMRT_PARSE_PATH_XML * PathXml_Ptr ); +#else + + extern IMRT_Status MM_XML_StrHdl_Init ( void ); + extern IMRT_Status MM_XML_StrHdl_DeInit ( void ); + extern IMRT_Status MM_XML_StrHdl_Data_Free ( IMRT_Buffer * ); + extern IMRT_Status MM_XML_StrHdl_Ident ( IMRT_Msg_Id * , IMRT_Buffer * ); + extern IMRT_Status MM_XML_StrHdl_Open ( IMRT_Buffer * ); + extern IMRT_Status MM_XML_StrHdl_Close ( IMRT_Buffer * ); + extern IMRT_Status MM_XML_StrHdl_Flush ( IMRT_Buffer * ); + extern IMRT_Status MM_XML_StrHdl_Data_List ( IMRT_Buffer * ); + extern IMRT_Status MM_XML_StrHdl_Copy ( IMRT_Buffer * , IMRT_Buffer * ); + extern IMRT_Status MM_XML_StrHdl_Get ( IMRT_Buffer_Data ** , IMRT_Field * , IMRT_Buffer * , size_t * ); + extern IMRT_Status MM_XML_StrHdl_Convert ( IMRT_Buffer_Data ** , IMRT_Buffer_Data * , IMRT_Field * , size_t *, IMRT_StrHdl_Cnv_Func * ); + extern IMRT_Status MM_XML_StrHdl_Put ( IMRT_Buffer_Data * , IMRT_Field * , IMRT_Buffer * , size_t ); + +#endif + +/*----------------------------------------------------------------------------*/ + +#endif + diff --git a/src/libmapping_mng/src/libmapping_mng.c b/src/libmapping_mng/src/libmapping_mng.c new file mode 100644 index 0000000..adc92fe --- /dev/null +++ b/src/libmapping_mng/src/libmapping_mng.c @@ -0,0 +1,259 @@ +/*----------------------------------------------------------------------------*/ +/* $Workfile: libmapping_mng.c $ */ +/*----------------------------------------------------------------------------*/ +/* $Author: agibert $ */ +/* $Date: 2008/11/12 02:25:23 $ */ +/* $Revision: 1.1 $ */ +/* $Label: $ */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _LIBMAPPING_MNG_C_ + +#include "libmapping_mng.h" + + + + + + + +/******************************************************************************/ +/* Mapping Manager API */ +/******************************************************************************/ + + + +/*----------------------------------------------------------------------------*/ +/* Open Mapping Manager */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MM_Library_Open( IMRT_MM_Config *Config) +{ + IMRT_Status status; + + + if( IMRG_MM_Module.Lib.Status != IMRD_LIB_STATUS_CLOSED) + { + IMRD_LM_LOG_ERROR_0( "Library not closed !"); + + return( IMRS_KO); + } + else + { + IMRG_MM_Base.Config.XML_Format = Config->XML_Format; + + status = IMRS_OK; + + status = MM_Schedul_Init( ); + + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0("Error MM_Schedul_Init in IMR_MM_Library_Open"); + } + else + { + status = MM_Buffer_Init( ) ; + } + + + if( status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't open library !"); + } + else + { + IMRG_MM_Module.Lib.Status = IMRD_LIB_STATUS_OPENED; + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Library opened !"); + } + + return( status); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Close Mapping Manager */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MM_Library_Close() +{ + IMRT_Status status; + + + if( IMRG_MM_Module.Lib.Status != IMRD_LIB_STATUS_OPENED) + { + IMRD_LM_LOG_ERROR_0( "Library not opened !"); + + return( IMRS_KO); + } + else + { + status = IMRS_OK; + + status = MM_Schedul_DeInit( ); + + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0("Error MM_Schedul_DeInit in IMR_MM_Library_Close"); + } + else + { + status = MM_Buffer_DeInit( ) ; + } + + if( status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't close library !"); + } + else + { + IMRG_MM_Module.Lib.Status = IMRD_LIB_STATUS_CLOSED; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Library closed !"); + } + + return( status) ; + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Buffer allocation */ +/*----------------------------------------------------------------------------*/ +/* (O) Buffer_Ptr_Ptr : Buffer pointer pointer */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MM_Buffer_Alloc( IMRT_Buffer **Buffer_Ptr_Ptr) +{ + IMRT_Status status; + + status = IMRS_OK; + + status = MM_Buffer_Alloc( Buffer_Ptr_Ptr ) ; + + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0("Error MM_Buffer_Alloc"); + } + else + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Allocated buffer success"); + } + + return (status) ; +} + + +/*----------------------------------------------------------------------------*/ +/* Buffer free */ +/*----------------------------------------------------------------------------*/ +/* (IO) Buffer_Ptr_Ptr : Buffer pointer pointer */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MM_Buffer_Free( IMRT_Buffer **Buffer_Ptr_Ptr) +{ + IMRT_Status status; + + status = IMRS_OK; + + status = MM_Buffer_Free( Buffer_Ptr_Ptr ) ; + + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0("Error MM_Buffer_Free"); + } + else + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Freed buffer success"); + } + + return (status) ; + +} + + +/*----------------------------------------------------------------------------*/ +/* Buffer check */ +/*----------------------------------------------------------------------------*/ +/* (I) Buffer_Ptr : Buffer pointer */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MM_Buffer_Check (IMRT_Buffer *Buffer_Ptr) +{ + + IMRT_Status status; + + status = IMRS_OK; + + status = MM_Buffer_Check( Buffer_Ptr ) ; + + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0("Error MM_Buffer_Check in IMR_MM_Buffer_Check"); + } + else + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Check buffer success"); + } + + return (status) ; + +} + + +/*----------------------------------------------------------------------------*/ +/* Buffer list */ +/*----------------------------------------------------------------------------*/ +/* (I) Buffer_Ptr : Buffer pointer */ +/* (I) texte : Text to print */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MM_Buffer_List( IMRT_Buffer *Buffer_Ptr, char *texte) +{ + return( MM_Buffer_List( Buffer_Ptr, texte ) ); +} + + +/*----------------------------------------------------------------------------*/ +/* Buffer mapping */ +/*----------------------------------------------------------------------------*/ +/* (I) Output_Buffer_Ptr : Output buffer pointer */ +/* (I) Input_Buffer_Ptr : Input buffer pointer */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MM_Buffer_Map( IMRT_Buffer *Output_Buffer_Ptr, IMRT_Buffer *Input_Buffer_Ptr) +{ + return ( MM_Schedul_Buffer_Map( Output_Buffer_Ptr, Input_Buffer_Ptr ) ); +} + + diff --git a/src/libmapping_mng/src/libmapping_mng.h b/src/libmapping_mng/src/libmapping_mng.h new file mode 100644 index 0000000..d3d23b1 --- /dev/null +++ b/src/libmapping_mng/src/libmapping_mng.h @@ -0,0 +1,142 @@ +/*----------------------------------------------------------------------------*/ +/* File: libmapping_mng.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _LIBMAPPING_MNG_H_ +#define _LIBMAPPING_MNG_H_ + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* Lib Definitions */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_MM_MODULE_ID ( IMRT_Module_Id) 4 +#define IMRD_MM_MODULE_NAME ( IMRT_Module_Name) "mm" +#define IMRD_MM_MODULE_NAME_LONG ( IMRT_Module_Name_Long) "Mapping Manager" +#define IMRD_MM_MODULE_VERSION ( IMRT_Module_Version) "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: libmapping_mng.h $" + +#define IMRD_MODULE_PTR &IMRG_MM_Module + + + + + +/*----------------------------------------------------------------------------*/ +/* Local definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_STATUS_NOTHING_TO_DO (IMRT_Status) 4 + +typedef IMRT_Status (IMRT_MM_Cnv_Init)( void ); +typedef IMRT_Status (IMRT_MM_Cnv_DeInit)( void ); +typedef IMRT_Status (IMRT_MM_Convert)( IMRT_Buffer_Data * , IMRT_Buffer_Data * , size_t * , size_t , IMRT_Cnv_Attr ); + +typedef struct IMRT_StrHdl_Cnv_Func + +{ IMRT_Cnv_Name Nom; + IMRT_MM_Cnv_Init *Init_Ptr; + IMRT_MM_Cnv_DeInit *DeInit_Ptr; + IMRT_MM_Convert *Convert_Ptr; +} IMRT_StrHdl_Cnv_Func; + +/* a virer apres les tests */ +IMRT_StrHdl_Cnv_Func *IMRG_MM_StrHdl_Cnv_Func_Tab; + + + +typedef struct IMRT_MM_Base +{ + IMRT_MM_Config Config; +} IMRT_MM_Base; + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + + + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBMAPPING_MNG_C_ + +IMRT_MM_Base IMRG_MM_Base = +{ + { IMRD_FALSE} +}; + + + +IMRT_Module IMRG_MM_Module = +{ + IMRD_MM_MODULE_ID, + IMRD_MM_MODULE_NAME, + IMRD_MM_MODULE_NAME_LONG, + IMRD_MM_MODULE_VERSION, + IMRD_MODULE_TYPE_LIBRARY, + { + IMRD_LIB_STATUS_CLOSED, + ( IMRT_Lib_Open *) &IMR_MM_Library_Open, + ( IMRT_Lib_Close *) &IMR_MM_Library_Close + } +}; + +# else + +extern IMRT_MM_Base IMRG_MM_Base; +extern IMRT_Module IMRG_MM_Module; + +# endif + + + + + +#endif diff --git a/src/libmapping_mng/src/map_scheduler.c b/src/libmapping_mng/src/map_scheduler.c new file mode 100644 index 0000000..1b11370 --- /dev/null +++ b/src/libmapping_mng/src/map_scheduler.c @@ -0,0 +1,484 @@ +/*----------------------------------------------------------------------------*/ +/* File: map_scheduler.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMAPPING_MNG_ +#define _MAP_SCHEDULER_C_ + +#include "map_scheduler.h" + +IMRT_Status MM_Schedul_Buffer_Map( IMRT_Buffer *Output_Buffer_Ptr, IMRT_Buffer *Input_Buffer_Ptr) +{ + IMRT_Status status; + short indice; + IMRT_Fmt_Id format_temp; + char *func_name = "MM_Schedul_Buffer_Map"; + + status = IMRS_OK; + indice = 0; + format_temp = Input_Buffer_Ptr->Fmt_Id; + + /* controles sur les buffers */ + status = Schedul_Buffers_Check(Input_Buffer_Ptr, Output_Buffer_Ptr); + + /* fermeture des buffers */ + if (status == IMRS_OK) + { + status = MM_Buffer_Close(Input_Buffer_Ptr); + } + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0("Buffer input close failed"); + } + else + { + status = MM_Buffer_Close(Output_Buffer_Ptr); + } + + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0("Buffer output close failed"); + } + else + { + /* initialisation du tableau */ + Buffer_Tab[0] = Input_Buffer_Ptr; + Buffer_Tab[1] = Output_Buffer_Ptr; + for (indice = 2; indice < IMRT_BUFFER_ID_MAX_NB; indice++) + Buffer_Tab[indice] = NULL; + + Input_Buffer_Ptr->Fmt_Id = IMRD_FMT_ID_UNKNOWN ; + status = MM_Buffer_Open( Input_Buffer_Ptr ); + + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_2 , "Values before MapMath proceed begin :"); + IMRD_LM_LOG_TRACE_3(IMRD_LOG_LEVEL_VERBOSE_2 , "Output Application : Id (%d) Fmt_Id (%d) Msg type Id (%d)" , Output_Buffer_Ptr->Appl_Id_Output , Output_Buffer_Ptr->Fmt_Id , Output_Buffer_Ptr->Msg_Id); + IMRD_LM_LOG_TRACE_3(IMRD_LOG_LEVEL_VERBOSE_2 , "Input Application : Id (%d) Fmt_Id (%d) Msg type Id (%d)" , Input_Buffer_Ptr->Appl_Id_Input , Input_Buffer_Ptr->Fmt_Id , Input_Buffer_Ptr->Msg_Id); + + + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0("Buffer input open failed"); + Input_Buffer_Ptr->Fmt_Id = format_temp; + } + else + { + status = IMR_SDM_MapPath_Proceed( Input_Buffer_Ptr->Appl_Id_Output, + Output_Buffer_Ptr->Fmt_Id, + Output_Buffer_Ptr->Msg_Id, + Input_Buffer_Ptr->Appl_Id_Input, + Input_Buffer_Ptr->Fmt_Id, + Input_Buffer_Ptr->Msg_Id, + IMR_MM_Schedul_Map, + IMR_MM_Schedul_Copy, + IMR_MM_Schedul_Ident); + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1("MapPath proceed ended with status (%d)", status); + } + } + } + + indice = 2; + while (indice < IMRT_BUFFER_ID_MAX_NB) + { + if (Buffer_Tab[indice] != NULL) + { + if (MM_Buffer_Free(&Buffer_Tab[indice]) != IMRS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Buffer (%d) free failed" , indice); + } + } + indice++; + } + + if (MM_Buffer_Close(Input_Buffer_Ptr) != IMRS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer input close failed"); + } + if (MM_Buffer_Close(Output_Buffer_Ptr) != IMRS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Buffer output close failed"); + } + + Buffer_Tab[0] = NULL; + Buffer_Tab[1] = NULL; + + return ( status ); +} + +IMRT_Status Schedul_Buffers_Check( IMRT_Buffer *Input_Buffer_Ptr, IMRT_Buffer *Output_Buffer_Ptr) +{ + IMRT_Status status; + char *func_name = "Schedul_Buffers_Check"; + + + status = IMRS_OK; + + if (Input_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Input buffer pointer NULL"); + } + else + if (Output_Buffer_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Output buffer pointer NULL"); + } + else + { + if (MM_Buffer_Check(Input_Buffer_Ptr) != IMRS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Check buffer input failed"); + } + if (MM_Buffer_Check(Output_Buffer_Ptr) != IMRS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Check buffer output failed"); + } + if (Input_Buffer_Ptr->Appl_Id_Input == IMRD_APPL_ID_UNDEFINEDED) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Application input buffer equal to undefineded"); + } + if (Input_Buffer_Ptr->Status != IMRD_BUFFER_STATUS_ALLOCATED) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Status input buffer equal to unknown"); + } + if (Input_Buffer_Ptr->Data_Buf_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Data_Buf_Ptr input buffer equal to NULL"); + } + } + + return ( status ); +} + + +IMRT_Status IMR_MM_Schedul_Ident( IMRT_Fmt_Id *Format_Ptr, + IMRT_Msg_Id *Type, + IMRT_Buffer_Id Ident_Buffer_Indice, + IMRT_Boolean Ident_Total ) +{ + IMRT_Status status; + IMRT_Msg_Id TypeTmp; + char *func_name = "IMR_MM_Schedul_Ident"; + + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Ident buffer demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Ident buffer demand : Buffer : (%d)" , Ident_Buffer_Indice); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Ident buffer demand : Format Id : (%d)" , *Format_Ptr); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Ident buffer demand : Msg type : (%d)" , *Type); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Ident buffer demand : Total ident : (%d)" , Ident_Total); + + status = IMRS_OK; + TypeTmp = IMRD_MSG_ID_UNKNOWN; + + /* controle valeur de l'indice */ + if ( ( Ident_Buffer_Indice < 0 ) || ( Ident_Buffer_Indice >= IMRT_BUFFER_ID_MAX_NB ) ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Buffer (%d) out of bounds" , Ident_Buffer_Indice); + } + /* controle allocation d'un buffer pour l'indice */ + else if ( Buffer_Tab[Ident_Buffer_Indice] == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Buffer (%d) not allocated" , Ident_Buffer_Indice); + } + else + { + TypeTmp = Buffer_Tab[Ident_Buffer_Indice]->Msg_Id; + + if (Ident_Total == IMRD_TRUE) // identification totale + { + status = MM_Buffer_Ident_Update(Buffer_Tab[Ident_Buffer_Indice], + IMRD_FMT_ID_UNKNOWN, + IMRD_FMTATTR_NAME_UNKNOWN, + IMRD_MSG_ID_UNKNOWN); + } + } + + if ( status != IMRS_OK ) + { + IMRD_LM_LOG_ERROR_0("MM_Buffer_Ident_Update failed"); + } + else + { + status = MM_Buffer_Open ( Buffer_Tab[Ident_Buffer_Indice] ); + } + + if ( status != IMRS_OK ) + { + IMRD_LM_LOG_ERROR_1("Buffer (%d) not open" , Ident_Buffer_Indice); + } + else + { + status = MM_Buffer_Ident ( *Type , Buffer_Tab[Ident_Buffer_Indice] ); + } + + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0("MM_Buffer_Ident failed"); + } + else + { + *Format_Ptr = Buffer_Tab[Ident_Buffer_Indice]->Fmt_Id; + *Type = Buffer_Tab[Ident_Buffer_Indice]->Msg_Id; + } + + + if ((status != IMRS_OK) && (status != IMRS_KO)) + { + status = IMRS_OK; + } + + MM_Buffer_List( Buffer_Tab[Ident_Buffer_Indice], " CB Ident end"); + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Ident buffer demand end : Format Id : (%d)" , *Format_Ptr); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Ident buffer demand end : Msg type : (%d)" , *Type); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Ident buffer demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + + return ( status ); +} + +IMRT_Status IMR_MM_Schedul_Copy( IMRT_Buffer_Id Output_Buffer_Indice, IMRT_Buffer_Id Input_Buffer_Indice) +{ + IMRT_Status status; + IMRT_Buffer *buffer_ptr; + char *func_name = "IMR_MM_Schedul_Copy"; + + + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Copy buffer demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Copy buffer demand : Buffer Target : (%d)" , Output_Buffer_Indice); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Copy buffer demand : Buffer Source : (%d)" , Input_Buffer_Indice); + + + status = IMRS_OK; + buffer_ptr = NULL; + + /* controle la validite des indices */ + if ( ( Input_Buffer_Indice < 0 ) || ( Input_Buffer_Indice >= IMRT_BUFFER_ID_MAX_NB ) || + ( Output_Buffer_Indice < 0 ) || ( Output_Buffer_Indice >= IMRT_BUFFER_ID_MAX_NB ) ) + { + IMRD_LM_LOG_ERROR_2("Buffer input with indice (%d) or output with indice (%d) out of bounds" , Input_Buffer_Indice , Output_Buffer_Indice); + status = IMRS_KO; + } + else if ( Buffer_Tab[Input_Buffer_Indice] == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Buffer with indice (%d) not initialized" , Input_Buffer_Indice); + } + /* allocation du buffer destinataire si necessaire */ + else if ( Buffer_Tab[Output_Buffer_Indice] == NULL) + { + status = MM_Buffer_Alloc(&buffer_ptr); + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0("Error MM_Buffer_Alloc"); + } + else + { + Buffer_Tab[Output_Buffer_Indice] = buffer_ptr; + } + } + MM_Buffer_List( Buffer_Tab[Input_Buffer_Indice], " Before Copy Buffer In"); + if (status == IMRS_OK) + { + status = MM_Buffer_Copy( Buffer_Tab[Output_Buffer_Indice], Buffer_Tab[Input_Buffer_Indice]); + } + MM_Buffer_List( Buffer_Tab[Output_Buffer_Indice], " After Copy Buffer Out"); + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Copy buffer demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + + return ( status ); +} + +/*----------------------------------------------------------------------------*/ +/* Buffer Mapping CallBack */ +/*----------------------------------------------------------------------------*/ +/* (I) Buffer_Id_Target: Target buffer id */ +/* (I) Fmt_Target: Target format */ +/* (I) Buffer_Id_Src: Source buffer id */ +/* (I) Fmt_Src: Source format */ +/* (I) MsgMap: Message Map to use */ +/* (I) Clear_Flag: Clear or not output buffer */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MM_Schedul_Map( IMRT_Buffer_Id Buffer_Id_Target , + IMRT_Fmt_Id Fmt_Target, + IMRT_FmtAttr_Value Fmt_Target_Attr , + IMRT_Buffer_Id Buffer_Id_Src , + IMRT_Fmt_Id Fmt_Src , + IMRT_FmtAttr_Value Fmt_Src_Attr , + IMRT_MsgMap *MsgMap_ptr , + IMRT_MapCmd_Flag Clear_Flag) + +{ + IMRT_Buffer *input_buffer_ptr, + *output_buffer_ptr; + IMRT_Status status; + char *func_name = "IMR_MM_Schedul_Map"; + + + status = IMRS_OK; + input_buffer_ptr = NULL; + output_buffer_ptr = NULL; + + + /* controle buffers */ + if ( ( Buffer_Id_Src < 0 ) || ( Buffer_Id_Src >= IMRT_BUFFER_ID_MAX_NB ) || + ( Buffer_Id_Target < 0 ) || ( Buffer_Id_Target >= IMRT_BUFFER_ID_MAX_NB ) ) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_2("Indices buffer input (%d) or output (%d) out of bounds" , Buffer_Id_Src,Buffer_Id_Target); + } + else if ( Buffer_Tab[Buffer_Id_Src] == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1("Buffer with indice (%d) not allocated ",Buffer_Id_Src); + } + else if (Fmt_Src_Attr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Source format attribute NULL"); + } + else if (Fmt_Target_Attr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Target format attribute NULL"); + } + else if (MsgMap_ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Message map pointer NULL"); + } + else if (MsgMap_ptr->Msg_Input_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Message input pointer NULL"); + } + else if (MsgMap_ptr->Msg_Output_Ptr == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0("Message output pointer NULL"); + } + + if ( status == IMRS_OK ) + { + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "Mapping buffer demand : Begin"); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Mapping buffer demand : MsgMap : (%s)" , (char *) MsgMap_ptr->Name); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_1 , "Mapping buffer demand : indices Buffers : Src (%d) : Tgt (%d)" , Buffer_Id_Src , Buffer_Id_Target); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_1 , "Mapping buffer demand : formats : Src (%d) : Tgt (%d)" , Fmt_Src , Fmt_Target); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_1 , "Mapping buffer demand : Attributs : Src (%s) : Tgt (%s)" , Fmt_Src_Attr , Fmt_Target_Attr); + IMRD_LM_LOG_TRACE_2(IMRD_LOG_LEVEL_VERBOSE_1 , "Mapping buffer demand : Types de msg : Src (%s) : Tgt (%s)" , (char *) MsgMap_ptr->Msg_Input_Ptr->Name , (char *) MsgMap_ptr->Msg_Output_Ptr->Name); + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Mapping buffer demand : Flag buffer clear : (%d)" , Clear_Flag); + + input_buffer_ptr = Buffer_Tab[Buffer_Id_Src]; + if ( Buffer_Tab[Buffer_Id_Target] == NULL) + { + status = MM_Buffer_Alloc(&output_buffer_ptr); + if ( status != IMRS_OK ) + { + IMRD_LM_LOG_ERROR_1("MM_Buffer_Alloc failed for buffer output (%d)",Buffer_Id_Target); + } + else + { + Buffer_Tab[Buffer_Id_Target] = output_buffer_ptr; + } + + } + else if ( Clear_Flag == IMRD_TRUE ) + { + output_buffer_ptr = Buffer_Tab[Buffer_Id_Target]; + status = MM_Buffer_Clear(output_buffer_ptr); + } + else + { + output_buffer_ptr = Buffer_Tab[Buffer_Id_Target]; + } + } + /* mise a jour des formats et types des buffers */ + if ( status == IMRS_OK ) + { + status = MM_Buffer_Ident_Update(input_buffer_ptr, + Fmt_Src, + Fmt_Src_Attr, + MsgMap_ptr->Msg_Input_Ptr->Id); + } + if ( status == IMRS_OK ) + { + status =MM_Buffer_Ident_Update( output_buffer_ptr, + Fmt_Target, + Fmt_Target_Attr, + MsgMap_ptr->Msg_Output_Ptr->Id); + } + /* ouverture des buffers */ + if ( status == IMRS_OK ) + { + status = MM_Buffer_Open( input_buffer_ptr); + } + if ( status == IMRS_OK ) + { + MM_Buffer_Open( output_buffer_ptr); + } + + MM_Buffer_List( input_buffer_ptr, " Input Buffer Before Mapping"); + + if ( status == IMRS_OK ) + { + status = MM_Buffer_Map( output_buffer_ptr, input_buffer_ptr, MsgMap_ptr); + } + + MM_Buffer_List( output_buffer_ptr, " Output Buffer after Mapping"); + + IMRD_LM_LOG_TRACE_1(IMRD_LOG_LEVEL_VERBOSE_1 , "Mapping buffer demand : End with status : (%d)" , status); + IMRD_LM_LOG_TRACE_0(IMRD_LOG_LEVEL_VERBOSE_1 , "============================================================================") + + return ( status ); +} + +IMRT_Status MM_Schedul_Init() +{ + return (IMRS_OK); +} + +IMRT_Status MM_Schedul_DeInit() +{ + return (IMRS_OK); +} diff --git a/src/libmapping_mng/src/map_scheduler.h b/src/libmapping_mng/src/map_scheduler.h new file mode 100644 index 0000000..fa502e7 --- /dev/null +++ b/src/libmapping_mng/src/map_scheduler.h @@ -0,0 +1,88 @@ +/*----------------------------------------------------------------------------*/ +/* File: map_scheduler.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _MAP_SCHEDULER_H_ +#define _MAP_SCHEDULER_H_ + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include "libmapping_mng.h" + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +#ifdef _MAP_SCHEDULER_C_ + + IMRT_Buffer *Buffer_Tab[IMRT_BUFFER_ID_MAX_NB]; + +#endif + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ +#ifdef _MAP_SCHEDULER_C_ + + IMRT_Status MM_Schedul_Init ( void ); + IMRT_Status MM_Schedul_DeInit ( void ); + IMRT_Status MM_Schedul_Buffer_Map ( IMRT_Buffer * , IMRT_Buffer * ); + IMRT_Status Schedul_Buffers_Check ( IMRT_Buffer * , IMRT_Buffer * ); + IMRT_Status IMR_MM_Schedul_Ident ( IMRT_Fmt_Id * , IMRT_Msg_Id *, IMRT_Buffer_Id , IMRT_Boolean ); + IMRT_Status IMR_MM_Schedul_Copy ( IMRT_Buffer_Id , IMRT_Buffer_Id ); + +/*----------------------------------------------------------------------------*/ +/* Buffer Mapping CallBack */ +/*----------------------------------------------------------------------------*/ +/* (I) Buffer_Id_Target: Target buffer id */ +/* (I) Fmt_Target: Target format */ +/* (I) Fmt_Attr_Target: Target format attribute */ +/* (I) Buffer_Id_Src: Source buffer id */ +/* (I) Fmt_Src: Source format */ +/* (I) Fmt_Attr_Src: Source format attribute */ +/* (I) MsgMap: Message Map to use */ +/* (I) Clear_Flag: Clear or donn't clear output buffer */ +/*----------------------------------------------------------------------------*/ + IMRT_Status IMR_MM_Schedul_Map( IMRT_Buffer_Id, IMRT_Fmt_Id, IMRT_FmtAttr_Value, IMRT_Buffer_Id, IMRT_Fmt_Id, IMRT_FmtAttr_Value, IMRT_MsgMap *, IMRT_MapCmd_Flag); + +/*----------------------------------------------------------------------------*/ + + +#else + + extern IMRT_Status MM_Schedul_Init ( void ); + extern IMRT_Status MM_Schedul_DeInit ( void ); + extern IMRT_Status MM_Schedul_Buffer_Map ( IMRT_Buffer * , IMRT_Buffer * ); + +#endif + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libmsg_router/include/msg_router.h b/src/libmsg_router/include/msg_router.h new file mode 100644 index 0000000..505f53f --- /dev/null +++ b/src/libmsg_router/include/msg_router.h @@ -0,0 +1,132 @@ +/*----------------------------------------------------------------------------*/ +/* File: msg_router.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _MSG_ROUTER_H_ +#define _MSG_ROUTER_H_ + + + +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRD_MR_API definition */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBMSG_ROUTER_ +# define IMRD_MR_API +# else +# define IMRD_MR_API extern +# endif + + + + + +/*----------------------------------------------------------------------------*/ +/* MR_Config definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_MR_Config +{ + IMRT_Boolean Mapping_Forced; + IMRT_Boolean Continue_Forced; + IMRT_Read_Mode Read_Mode; + IMRT_Log_Id_Struct Log_Id_Struct_Input; + IMRT_Log_Id_Struct Log_Id_Struct_Output; +} IMRT_MR_Config; + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBMSG_ROUTER_ + +# else + +extern IMRT_Module IMRG_MR_Module; + +# endif + + + + + + + +/******************************************************************************/ +/* Msg Router API */ +/******************************************************************************/ + + + +/*----------------------------------------------------------------------------*/ +/* Open Msg Router */ +/*----------------------------------------------------------------------------*/ +/* Lib_Flag: Setup MR init mode */ +/*----------------------------------------------------------------------------*/ + +IMRD_MR_API IMRT_Status IMR_MR_Library_Open( IMRT_MR_Config *); + + + +/*----------------------------------------------------------------------------*/ +/* Close Msg Router */ +/*----------------------------------------------------------------------------*/ + +IMRD_MR_API IMRT_Status IMR_MR_Library_Close( void); + + + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Message Routing */ +/*----------------------------------------------------------------------------*/ +/* Medium_URL_Output: Output medium URL */ +/* Appl_Id_Output: Output application Id */ +/* Medium_URL_Input: Trash Medium URL */ +/* Medium_URL_Input: Input Medium URL */ +/* Appl_Id_Input: Input Application Id */ +/*----------------------------------------------------------------------------*/ + +IMRD_MR_API IMRT_Status IMR_MR_Proceed( IMRT_Medium_URL, IMRT_Appl_Id, IMRT_Medium_URL, IMRT_Medium_URL, IMRT_Appl_Id); + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libmsg_router/src/Makefile b/src/libmsg_router/src/Makefile new file mode 100644 index 0000000..4235e6d --- /dev/null +++ b/src/libmsg_router/src/Makefile @@ -0,0 +1,65 @@ +#------------------------------------------------------------------------------ +# Local Makefile +#------------------------------------------------------------------------------ +# $Workfile: Makefile $ +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:23 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Var include +#------------------------------------------------------------------------------ + +include ../../Makefile_var.mk + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +TARGET= libmsg_router$(SHLIB_SUFFIX) + +OBJ= libmsg_router.o + +EXTRA_INC= + +EXTRA_LIB= + + + +#------------------------------------------------------------------------------ +# Rule include +#------------------------------------------------------------------------------ + +include ../../Makefile_rule.mk diff --git a/src/libmsg_router/src/libmsg_router.c b/src/libmsg_router/src/libmsg_router.c new file mode 100644 index 0000000..0f3185b --- /dev/null +++ b/src/libmsg_router/src/libmsg_router.c @@ -0,0 +1,544 @@ +/*----------------------------------------------------------------------------*/ +/* $Workfile: libmsg_router.c $ */ +/*----------------------------------------------------------------------------*/ +/* $Author: agibert $ */ +/* $Date: 2008/11/12 02:25:23 $ */ +/* $Revision: 1.1 $ */ +/* $Label: $ */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBMSG_ROUTER_ +#define _LIBMSG_ROUTER_C_ + +#include "libmsg_router.h" + + + + + + + +/******************************************************************************/ +/* Msg Router API */ +/******************************************************************************/ + + + +/*----------------------------------------------------------------------------*/ +/* Open Msg Router */ +/*----------------------------------------------------------------------------*/ +/* Lib_Flag: Setup MR init mode */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MR_Library_Open( IMRT_MR_Config *Config_Ptr) +{ + int idx; + + + if( IMRG_MR_Module.Lib.Status != IMRD_LIB_STATUS_CLOSED) + { + IMRD_LM_LOG_ERROR_0( "Library not closed !"); + + return( IMRS_KO); + } + else + { + IMRG_MR_Base.Config.Mapping_Forced = Config_Ptr->Mapping_Forced; + IMRG_MR_Base.Config.Continue_Forced = Config_Ptr->Continue_Forced; + IMRG_MR_Base.Config.Read_Mode = Config_Ptr->Read_Mode; + + if( Config_Ptr->Log_Id_Struct_Input.Bit_Nb != 0) + { + IMRG_MR_Base.Config.Log_Id_Struct_Input.Bit_Nb = Config_Ptr->Log_Id_Struct_Input.Bit_Nb; + IMRG_MR_Base.Config.Log_Id_Struct_Input.Log_Size = Config_Ptr->Log_Id_Struct_Input.Log_Size; + + if( ( IMRG_MR_Base.Config.Log_Id_Struct_Input.Log_Id_Bit_Ptr = + malloc( IMRG_MR_Base.Config.Log_Id_Struct_Input.Bit_Nb * sizeof( IMRT_Log_Id_Bit))) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate Input Log_Id_Bit_Ptr (%d) !", errno); + + return( IMRS_OK); + } + + for( idx = 0; idx < IMRG_MR_Base.Config.Log_Id_Struct_Input.Bit_Nb; idx++) + { + IMRG_MR_Base.Config.Log_Id_Struct_Input.Log_Id_Bit_Ptr[idx].Offset = Config_Ptr->Log_Id_Struct_Input.Log_Id_Bit_Ptr[idx].Offset; + IMRG_MR_Base.Config.Log_Id_Struct_Input.Log_Id_Bit_Ptr[idx].Size = Config_Ptr->Log_Id_Struct_Input.Log_Id_Bit_Ptr[idx].Size; + } + } + + if( Config_Ptr->Log_Id_Struct_Output.Bit_Nb != 0) + { + IMRG_MR_Base.Config.Log_Id_Struct_Output.Bit_Nb = Config_Ptr->Log_Id_Struct_Output.Bit_Nb; + IMRG_MR_Base.Config.Log_Id_Struct_Output.Log_Size = Config_Ptr->Log_Id_Struct_Output.Log_Size; + + if( ( IMRG_MR_Base.Config.Log_Id_Struct_Output.Log_Id_Bit_Ptr = + malloc( IMRG_MR_Base.Config.Log_Id_Struct_Output.Bit_Nb * sizeof( IMRT_Log_Id_Bit))) == NULL) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate Output Log_Id_Bit_Ptr (%d) !", errno); + + return( IMRS_OK); + } + + for( idx = 0; idx < IMRG_MR_Base.Config.Log_Id_Struct_Output.Bit_Nb; idx++) + { + IMRG_MR_Base.Config.Log_Id_Struct_Output.Log_Id_Bit_Ptr[idx].Offset = Config_Ptr->Log_Id_Struct_Output.Log_Id_Bit_Ptr[idx].Offset; + IMRG_MR_Base.Config.Log_Id_Struct_Output.Log_Id_Bit_Ptr[idx].Size = Config_Ptr->Log_Id_Struct_Output.Log_Id_Bit_Ptr[idx].Size; + } + } + + IMRG_MR_Module.Lib.Status = IMRD_LIB_STATUS_OPENED; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Library opened !"); + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Close Msg Router */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MR_Library_Close() +{ + if( IMRG_MR_Module.Lib.Status != IMRD_LIB_STATUS_OPENED) + { + IMRD_LM_LOG_ERROR_0( "Library not opened !"); + + return( IMRS_KO); + } + else + { + if( IMRG_MR_Base.Config.Log_Id_Struct_Input.Bit_Nb != 0) + { + free( IMRG_MR_Base.Config.Log_Id_Struct_Input.Log_Id_Bit_Ptr); + } + + if( IMRG_MR_Base.Config.Log_Id_Struct_Output.Bit_Nb != 0) + { + free( IMRG_MR_Base.Config.Log_Id_Struct_Output.Log_Id_Bit_Ptr); + } + + IMRG_MR_Module.Lib.Status = IMRD_LIB_STATUS_CLOSED; + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Library closed !"); + + return( IMRS_OK); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Close all allocated resources */ +/*----------------------------------------------------------------------------*/ +/* Buffer_Input_Ptr: Input buffer */ +/* Buffer_Output_Ptr: Output buffer */ +/* Medium_Input_Ptr: Input Medium */ +/* Medium_Output_Ptr: Output Medium */ +/* Medium_Trash_Ptr: Output Medium */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status Close_All( IMRT_Buffer *Buffer_Input_Ptr, IMRT_Buffer *Buffer_Output_Ptr, + IMRT_Medium *Medium_Input_Ptr, IMRT_Medium *Medium_Output_Ptr, IMRT_Medium *Medium_Trash_Ptr) +{ + IMRT_Status status; + + + if( Buffer_Output_Ptr != NULL) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Freeing output buffer..."); + + if( ( status = IMR_MM_Buffer_Free( &Buffer_Output_Ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't free output buffer (%d) !", status); + } + } + + if( Buffer_Input_Ptr != NULL) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Freeing input buffer..."); + + if( ( status = IMR_MM_Buffer_Free( &Buffer_Input_Ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't free input buffer (%d) !", status); + } + } + + if( Medium_Trash_Ptr != NULL) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Closing trash medium..."); + + if( ( status = IMR_IOM_Medium_Close( Medium_Trash_Ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't close trash medium (%d) !", status); + } + } + + if( Medium_Output_Ptr != NULL) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Closing output medium..."); + + if( ( status = IMR_IOM_Medium_Close( Medium_Output_Ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't close output medium (%d) !", status); + } + } + + if( Medium_Input_Ptr != NULL) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Closing input medium..."); + + if( ( status = IMR_IOM_Medium_Close( Medium_Input_Ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't close input medium (%d) !", status); + } + } + + return( IMRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Message Routing */ +/*----------------------------------------------------------------------------*/ +/* Medium_URL_Output: Output medium URL */ +/* Appl_Id_Output: Output application Id */ +/* Medium_URL_Input: Input Medium URL */ +/* Appl_Id_Input: Input Application Id */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_MR_Proceed( IMRT_Medium_URL Medium_URL_Output, IMRT_Appl_Id Appl_Id_Output, + IMRT_Medium_URL Medium_URL_Trash, + IMRT_Medium_URL Medium_URL_Input, IMRT_Appl_Id Appl_Id_Input) +{ + IMRT_Status status, return_status = IMRS_OK; + IMRT_Boolean data = IMRD_TRUE; + IMRT_Appl_Id appl_id_raw; + IMRT_Buffer *buffer_input_ptr = NULL, *buffer_output_ptr = NULL; + IMRT_Medium *medium_input_ptr = NULL, *medium_output_ptr = NULL, *medium_trash_ptr = NULL; + IMRT_Tran *tran_ptr = NULL; + + + if( sigsetjmp( IMRG_Base.SigLongJmp_Env, 1) != 0 ) + { + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_0, "Exiting on signal (%d)...", IMRG_Base.Sig_Trapped); + + Close_All( buffer_input_ptr, buffer_output_ptr, medium_input_ptr, medium_output_ptr, medium_trash_ptr); + + return( IMRS_OK); + } + + if( IMR_SDM_Appl_Id_Get( &appl_id_raw, "raw") != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't get Appl_Id from [%s] !", "raw"); + + return( IMRS_KO); + } + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Opening input medium..."); + + if( ( status = IMR_IOM_Medium_Open( &medium_input_ptr, "Input", Medium_URL_Input, Appl_Id_Input, Appl_Id_Output, IMRD_DIR_ID_IN)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't open input medium (%d) !", status); + + return_status = IMRS_KO; + } + else + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Opening output medium..."); + + if( ( status = IMR_IOM_Medium_Open( &medium_output_ptr, "Output", Medium_URL_Output, Appl_Id_Input, Appl_Id_Output, IMRD_DIR_ID_OUT)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't open output medium (%d) !", status); + + return_status = IMRS_KO; + } + else + { + if( IMRG_MR_Base.Config.Continue_Forced == IMRD_TRUE) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Opening trash medium..."); + + if( ( status = IMR_IOM_Medium_Open( &medium_trash_ptr, "Trash", Medium_URL_Trash, appl_id_raw, appl_id_raw, IMRD_DIR_ID_OUT)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't open trash medium (%d) !", status); + + return_status = IMRS_KO; + } + } + + if( return_status == IMRS_OK) + { + do + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Allocating input buffer..."); + + if( ( status = IMR_MM_Buffer_Alloc( &buffer_input_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate input buffer (%d) !", status); + + return_status = IMRS_KO; + } + else + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Begining transaction..."); + + if( ( status = IMR_IOM_Tran_Begin( &tran_ptr, 2, medium_output_ptr, medium_input_ptr)) == IMRS_KO) + { + IMRD_LM_LOG_ERROR_1( "Can't begin transaction (%d) !", status); + + return_status = IMRS_KO; + } + else + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Reading input medium..."); + + if( ( status = IMR_IOM_Medium_Read( buffer_input_ptr, medium_input_ptr, IMRG_MR_Base.Config.Read_Mode)) == IMRS_KO) + { + IMRD_LM_LOG_ERROR_1( "Can't read input buffer (%d) !", status); + + return_status = IMRS_KO; + } + else + { + if( status == IMRS_NO_DATA) + { + + + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "No more data to read..."); + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Rollbaking transaction..."); + + if( ( status = IMR_IOM_Tran_Rollback( tran_ptr)) == IMRS_KO) + { + IMRD_LM_LOG_ERROR_1( "Can't rollback transaction (%d) !", status); + + return_status = IMRS_KO; + } + else + { + return_status = IMRS_NO_DATA; + } + } + else + { + if( status == IMRS_SIGNAL) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Read interupted by a signal !"); + + return_status = status; + } + else + { + IMR_MM_Buffer_List( buffer_input_ptr, "Input Buffer"); + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Allocating output buffer..."); + + if( ( status = IMR_MM_Buffer_Alloc( &buffer_output_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't allocate output buffer (%d) !", status); + + return_status = IMRS_KO; + } + else + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Maping input buffer to output buffer..."); + + if( ( status = IMR_MM_Buffer_Map( buffer_output_ptr, buffer_input_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't map buffers (%d) !", status); + + if( IMRG_MR_Base.Config.Mapping_Forced == IMRD_TRUE) + { + data = IMRD_TRUE; + } + else + { + data = IMRD_FALSE; + } + + if( IMRG_MR_Base.Config.Continue_Forced == IMRD_TRUE) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Writing trash medium..."); + + if( ( status = IMR_IOM_Medium_Write( medium_trash_ptr, buffer_input_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't write input buffer (%d) !", status); + + return_status = IMRS_KO; + } + } + else + { + return_status = IMRS_KO; + } + } + else + { + data = IMRD_TRUE; + } + + IMR_MM_Buffer_List( buffer_output_ptr, "Output Buffer"); + + if( data == IMRD_TRUE) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Writing output medium..."); + + if( ( status = IMR_IOM_Medium_Write( medium_output_ptr, buffer_output_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't write output buffer (%d) !", status); + + return_status = IMRS_KO; + } + } + + if( return_status != IMRS_OK) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Rollbaking transaction..."); + + if( ( status = IMR_IOM_Tran_Rollback( tran_ptr)) == IMRS_KO) + { + IMRD_LM_LOG_ERROR_1( "Can't rollback transaction (%d) !", status); + + return_status = IMRS_KO; + } + } + else + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Comiting transaction..."); + + if( ( status = IMR_IOM_Tran_Commit( tran_ptr)) == IMRS_KO) + { + IMRD_LM_LOG_ERROR_1( "Can't commit transaction (%d) !", status); + + return_status = IMRS_KO; + } + + IMRD_LM_LOG_BUFFER_ID( buffer_input_ptr, &IMRG_MR_Base.Config.Log_Id_Struct_Input, IMRD_MR_LOG_ID_HEADER_MSG_INPUT); + IMRD_LM_LOG_BUFFER_ID( buffer_output_ptr, &IMRG_MR_Base.Config.Log_Id_Struct_Output, IMRD_MR_LOG_ID_HEADER_MSG_OUTPUT); + } + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Freeing output buffer..."); + + if( ( status = IMR_MM_Buffer_Free( &buffer_output_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't free output buffer (%d) !", status); + + return_status = IMRS_KO; + } + + buffer_output_ptr = NULL; + } + } + } + } + } + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Freeing input buffer..."); + + if( ( status = IMR_MM_Buffer_Free( &buffer_input_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't free input buffer (%d) !", status); + + return_status = IMRS_KO; + } + + buffer_input_ptr = NULL; + } + } + while( ( return_status == IMRS_OK) && ( IMRG_Base.Sig_Trapped == 0)); + + switch( return_status) + { + case IMRS_OK: + case IMRS_NO_DATA: + case IMRS_SIGNAL: + { + return_status = IMRS_OK; + break; + } + + case IMRS_KO: + default: + { + return_status = IMRS_KO; + break; + } + } + + if( IMRG_MR_Base.Config.Continue_Forced == IMRD_TRUE) + { + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Closing trash medium..."); + + if( ( status = IMR_IOM_Medium_Close( medium_trash_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't close trash medium (%d) !", status); + + return_status = IMRS_KO; + } + + medium_trash_ptr = NULL; + } + } + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Closing output medium..."); + + if( ( status = IMR_IOM_Medium_Close( medium_output_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't close output medium (%d) !", status); + + return_status = IMRS_KO; + } + + medium_output_ptr = NULL; + } + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Closing input medium..."); + + if( ( status = IMR_IOM_Medium_Close( medium_input_ptr)) != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Can't close input medium (%d) !", status); + + return_status = IMRS_KO; + } + + medium_input_ptr = NULL; + } + + return( return_status); +} + + diff --git a/src/libmsg_router/src/libmsg_router.h b/src/libmsg_router/src/libmsg_router.h new file mode 100644 index 0000000..a1e7e33 --- /dev/null +++ b/src/libmsg_router/src/libmsg_router.h @@ -0,0 +1,146 @@ +/*----------------------------------------------------------------------------*/ +/* File: libmsg_router.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _LIBMSG_ROUTER_H_ +#define _LIBMSG_ROUTER_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* Lib Definitions */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_MR_MODULE_ID ( IMRT_Module_Id) 5 +#define IMRD_MR_MODULE_NAME ( IMRT_Module_Name) "mr" +#define IMRD_MR_MODULE_NAME_LONG ( IMRT_Module_Name_Long) "Message Router" +#define IMRD_MR_MODULE_VERSION ( IMRT_Module_Version) "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: libmsg_router.h $" + +#define IMRD_MODULE_PTR &IMRG_MR_Module + + + +typedef struct IMRT_MR_Base +{ + IMRT_MR_Config Config; +} IMRT_MR_Base; + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Definitions */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_MR_LOG_ID_HEADER_MSG_INPUT ( IMRT_Log_Id_Header) "Input Message Id:" +#define IMRD_MR_LOG_ID_HEADER_MSG_OUTPUT ( IMRT_Log_Id_Header) "Output Message Id:" + + + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBMSG_ROUTER_C_ + +IMRT_Status Close_All( IMRT_Buffer *, IMRT_Buffer *, IMRT_Medium *, IMRT_Medium *, IMRT_Medium *); + +# endif + + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Includes */ +/*----------------------------------------------------------------------------*/ + + + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBMSG_ROUTER_C_ + +IMRT_MR_Base IMRG_MR_Base = +{ + { + IMRD_FALSE, + IMRD_READ_MODE_WAIT + } +}; + +IMRT_Module IMRG_MR_Module = +{ + IMRD_MR_MODULE_ID, + IMRD_MR_MODULE_NAME, + IMRD_MR_MODULE_NAME_LONG, + IMRD_MR_MODULE_VERSION, + IMRD_MODULE_TYPE_LIBRARY, + { + IMRD_LIB_STATUS_CLOSED, + ( IMRT_Lib_Open *) &IMR_MR_Library_Open, + ( IMRT_Lib_Close *) &IMR_MR_Library_Close + } +}; + +# else + +extern IMRT_MR_Base IMRG_MR_Base; +extern IMRT_Module IMRG_MR_Module; + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libnode/GNU-FDL.txt b/src/libnode/GNU-FDL.txt new file mode 100644 index 0000000..b42936b --- /dev/null +++ b/src/libnode/GNU-FDL.txt @@ -0,0 +1,355 @@ + GNU Free Documentation License + Version 1.1, March 2000 + + Copyright (C) 2000 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. + + +0. PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +written document "free" in the sense of freedom: to assure everyone +the effective freedom to copy and redistribute it, with or without +modifying it, either commercially or noncommercially. Secondarily, +this License preserves for the author and publisher a way to get +credit for their work, while not being considered responsible for +modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + + +1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work that contains a +notice placed by the copyright holder saying it can be distributed +under the terms of this License. The "Document", below, refers to any +such manual or work. Any member of the public is a licensee, and is +addressed as "you". + +A "Modified Version" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall subject +(or to related matters) and contains nothing that could fall directly +within that overall subject. (For example, if the Document is in part a +textbook of mathematics, a Secondary Section may not explain any +mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, whose contents can be viewed and edited directly and +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup has been designed to thwart or discourage +subsequent modification by readers is not Transparent. A copy that is +not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML designed for human modification. Opaque formats include +PostScript, PDF, proprietary formats that can be read and edited only +by proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML produced by some word processors for output +purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + + +2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + + +3. COPYING IN QUANTITY + +If you publish printed copies of the Document numbering more than 100, +and the Document's license notice requires Cover Texts, you must enclose +the copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a publicly-accessible computer-network location containing a complete +Transparent copy of the Document, free of added material, which the +general network-using public has access to download anonymously at no +charge using public-standard network protocols. If you use the latter +option, you must take reasonably prudent steps, when you begin +distribution of Opaque copies in quantity, to ensure that this +Transparent copy will remain thus accessible at the stated location +until at least one year after the last time you distribute an Opaque +copy (directly or through your agents or retailers) of that edition to +the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + + +4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +A. Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. +B. List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has less than five). +C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. +D. Preserve all the copyright notices of the Document. +E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. +F. Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. +G. Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. +H. Include an unaltered copy of this License. +I. Preserve the section entitled "History", and its title, and add to + it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section entitled "History" in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. +J. Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the "History" section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. +K. In any section entitled "Acknowledgements" or "Dedications", + preserve the section's title, and preserve in the section all the + substance and tone of each of the contributor acknowledgements + and/or dedications given therein. +L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. +M. Delete any section entitled "Endorsements". Such a section + may not be included in the Modified Version. +N. Do not retitle any existing section as "Endorsements" + or to conflict in title with any Invariant Section. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties--for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + + +5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections entitled "History" +in the various original documents, forming one section entitled +"History"; likewise combine any sections entitled "Acknowledgements", +and any sections entitled "Dedications". You must delete all sections +entitled "Endorsements." + + +6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + + +7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, does not as a whole count as a Modified Version +of the Document, provided no compilation copyright is claimed for the +compilation. Such a compilation is called an "aggregate", and this +License does not apply to the other self-contained works thus compiled +with the Document, on account of their being thus compiled, if they +are not themselves derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one quarter +of the entire aggregate, the Document's Cover Texts may be placed on +covers that surround only the Document within the aggregate. +Otherwise they must appear on covers around the whole aggregate. + + +8. TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License provided that you also include the +original English version of this License. In case of a disagreement +between the translation and the original English version of this +License, the original English version will prevail. + + +9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document except +as expressly provided for under this License. Any other attempt to +copy, modify, sublicense or distribute the Document 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. + + +10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation 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. See +http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. + + +ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (c) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.1 + or any later version published by the Free Software Foundation; + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +If you have no Invariant Sections, write "with no Invariant Sections" +instead of saying which ones are invariant. If you have no +Front-Cover Texts, write "no Front-Cover Texts" instead of +"Front-Cover Texts being LIST"; likewise for Back-Cover Texts. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. diff --git a/src/libnode/GNU-GPL.txt b/src/libnode/GNU-GPL.txt new file mode 100644 index 0000000..5b6e7c6 --- /dev/null +++ b/src/libnode/GNU-GPL.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/src/libnode/GNU-LGPL.txt b/src/libnode/GNU-LGPL.txt new file mode 100644 index 0000000..b1e3f5a --- /dev/null +++ b/src/libnode/GNU-LGPL.txt @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/src/libnode/ReadMe.txt b/src/libnode/ReadMe.txt new file mode 100644 index 0000000..5b2e6ac --- /dev/null +++ b/src/libnode/ReadMe.txt @@ -0,0 +1,44 @@ +# %RCSfile: ReadMe.txt,v % +# %Revision: 2.8 % +# %Name: libnode-2_1_0-1 % +# %Date: 2005/01/24 01:19:50 % +# %Author: agibert % + + + + + +Welcome to LibNode 2.1.x ! + + + +This release of LibNode supports the following OS: + - Linux 2.2.x, 2.4.x and 2.6.x (tested on RedHat & Mandrake), + - Solaris 2.6, + - Windows NT4, 2000 and XP. + + + +The support of LibVer is now optional (To enable it, use: make _LIBVER_SUPPORT=1 all). + +LibNode support LibShMem 2.0.0 and LibDataStr 2.0.0 ! + + + +Warning: Associated documentation (including the comments !) is outdated... +Please read demo and ndbench code. + + + +Libnode is licensed under the LGPL/GPL GNU Licenses. +For more information, please read the corresponding source file headers. +The license details can be found in the GNU-GPL.txt, GNU-LGPL.txt and GNU-FDL.txt files. + + + +Enjoy it! + +Your LibNode Team. + +arnaud@rx3.net +http://www.rx3.org/dvp/libnode diff --git a/src/libnode/ReleaseNotes.txt b/src/libnode/ReleaseNotes.txt new file mode 100644 index 0000000..d631beb --- /dev/null +++ b/src/libnode/ReleaseNotes.txt @@ -0,0 +1,220 @@ +# %RCSfile: ReleaseNotes.txt,v % +# %Revision: 2.20 % +# %Name: libnode-2_1_0-1 % +# %Date: 2005/01/24 00:50:55 % +# %Author: agibert % + + + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.1.0-1 - A. Gibert - 24/01/05 +------------------------------------------------------------------------------------------------------------------------------------ + +All: This new LibNode branch (2.1.x) should support the forthcoming new LibShMem branch (2.0.x), +LibNode: Add symbol lookup support for manager, allocator and desallocator functions call, + New Allocator and desallocator API interace, + Code cleanup, +NDBench: DS_Open now support an arg in order to use or not symbol lookup, + Add test-*-s.ndb batch files witch use symbol lookup. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.7-1 - A. Gibert - 20/01/05 +------------------------------------------------------------------------------------------------------------------------------------ + +All: Add to Makefile.var auto version label detection from CVS Tag. + This should be the final release of the 2.0 branch, + This new release is developped for the MICOT/Target project (Banque de France - Paris). +LibNode: Minor bug fixes in ND_*_Info_Print() functions and ND_Library_StdErr_Set alias defines. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.6-1 - A. Gibert - 24/08/04 +------------------------------------------------------------------------------------------------------------------------------------ + +All: Generate *-c executables with checking mode enabled (ND_MODE=1), + Code clean up and more cleanly indented, + This new release is developped for the MICOT/Target project (Banque de France - Paris), +LibNode: Add OpenStruct tracing support (Enabled by ND_MODE=1 and Debug=1), + Re-implement for Unix and Windows target, full address checking in ND_Address_Check(), +NDDemo0: Add LibNode 2.0.6 support: Add ND_Library_Open/Close() calls, +NDBench: Add Lib_Open, Lib_Close, Index_Value_Break and Index_Node_Break command, + Improve random number generation, + Add test-10.ndb and test-errror.ndb batch files. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.5-1 - A. Gibert / M. Regimbeau - 28/07/03 +------------------------------------------------------------------------------------------------------------------------------------ + +All: Add a new Makefile system (Makefile.rule and Makefile.var), + Add 'make distrib' support, + Add libnode.spec file, + Move node.h from lib directory to include directory. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.4-1 - A. Gibert - 29/07/02 +------------------------------------------------------------------------------------------------------------------------------------ + +All: This release of libnode pass with sucess valgrind test on linux. +LibNode: Add and use ND_Index_Clear() private API, +NbBench: Add fclose() call at the end of batch_run. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.3-1 - A. Gibert - 09/04/02 +------------------------------------------------------------------------------------------------------------------------------------ + +All: Fix Microsoft Visual Project to generate Debug and Release config correctly, +LibNode: Change index type numeric print value from decimal to hexa in ND_Index_Info_Print() API, +LibNode: Add new cases in ND_Index_Convert() handling (List->List:FIFO and List->List:LIFO), +LibNode: Generate in Debug mode libnoded.lib, libnoded.dll, libnoded_a.lib, +LibNode: Generate in Release mode libnode.lib, libnode.dll, libnode_a.lib, +Demo0: Generate in Debug mode demo0d.exe and in Release mode demo0d.exe, +NbBench: Generate in Debug mode ndbenchd.exe and in Release mode ndbenchd.exe. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.2-2 - A. Gibert - 01/03/02 +------------------------------------------------------------------------------------------------------------------------------------ + +All: Add GNU-GPL.txt, GNU-LGPL.txt and GNU-FDL.txt license files, +All: Add license stuff in ReandMe. +LibNode: Add LGPL header in libnode.c, libnode.h and node.h, +LibNode: Replace GPL by LGPL in libnode.rc, +Demo0: Add GPL header in demo0.c, +NbBench: Add GPL header in ndbench.c. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.2-1 - A. Gibert - 27/02/02 +------------------------------------------------------------------------------------------------------------------------------------ + +All: Makefiles now generate static and dynamic objects, +All: Add no libver support in Makefiles, +LibNode: VisualStudio Project now generate Windows DLL and use libnode.rc resource file, +LibNode: Rename Index_Open_Nb into Index_Open_Count, +LibNode: Fix bugs in ND_Node_Root_Alloc() on Index_Open_Count handling, +LibNode: Minor fix into ND_DataStruct_Check_I() and ND_Index_Check_I() functions, +NbBench: Implement Index_Close and Index_Info_Print functions. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.1-1 - A. Gibert - 28/11/01 +------------------------------------------------------------------------------------------------------------------------------------ + +LibNode: Fix the error level of TIMAS_KO: it's now an error status. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.0-1 - A. Gibert - 26/11/01 +------------------------------------------------------------------------------------------------------------------------------------ + +All: Merge the main CVS trunc with the win32 branche (2.0.0-alpha5), + Switch file release to 2.0. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.0-alpha5 - A. Gibert - 25/10/01 +------------------------------------------------------------------------------------------------------------------------------------ + +LibNode: Add Open/Close Index support, +LibNode: Fix return code next to empty struct manipulations, +NdBench: Add full multi index support. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.0-alpha4 - A. Gibert - 28/09/01 +------------------------------------------------------------------------------------------------------------------------------------ + +All: Add optional libver support, +LibNode: Fix missing recursive offset args, +LibNode: Start to fix some return code of empty struct manipulations, +NdBench: Fix local stack pointer big bug. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.0-alpha3 - A. Gibert - 18/9/01 +------------------------------------------------------------------------------------------------------------------------------------ + +New manager args interface (again !), +ndbench support batch mode. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.0-alpha2 - A. Gibert - 08/09/01 +------------------------------------------------------------------------------------------------------------------------------------ + +Re-enable libver support for unix, +Bug fixes, +Code cleanup. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 2.0.0-alpha1 - A. Gibert - 07/09/01 +------------------------------------------------------------------------------------------------------------------------------------ + +Add Full win32 support, +Remove libver support, +Multi index support, +New manager args format, +Major Code cleanup et standardisation. +This new version (2.0.x) is developped for the TIMA project (Misys IBS - France). + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 1.0.0 - S. Mas / A. Gibert - 18/07/00 +------------------------------------------------------------------------------------------------------------------------------------ + +Unix (Linux and Solaris) version only, for BDM project (Société Générale - Paris) +Major code rewrite. + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 0.2.2 - A. Gibert - 01/06/93 +------------------------------------------------------------------------------------------------------------------------------------ + +Embeded version on OS/2 2.1 (Companie Générale des Eaux - Paris) + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 0.2.1 - A. Gibert - 01/04/92 +------------------------------------------------------------------------------------------------------------------------------------ + +Amiga and PC support (Bareau de Draguignan - Ste Maxime). + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 0.2.0 - A. Gibert - 01/03/91 +------------------------------------------------------------------------------------------------------------------------------------ + +C version aided by p2c tools on Pyramid (Swansee University - Wales). + + + +------------------------------------------------------------------------------------------------------------------------------------ +LibNode V 0.1.0 - A. Gibert - 01/12/90 +------------------------------------------------------------------------------------------------------------------------------------ + +Inital version in Pascal on Pyramid (Swansee University - Wales). diff --git a/src/libnode/ToDo.txt b/src/libnode/ToDo.txt new file mode 100644 index 0000000..e7ef09a --- /dev/null +++ b/src/libnode/ToDo.txt @@ -0,0 +1,14 @@ +# %RCSfile: ToDo.txt,v % +# %Revision: 2.5 % +# %Name: libnode-2_1_0-1 % +# %Date: 2005/01/24 01:19:50 % +# %Author: agibert % + + + + + +- Check LibShMem/LibDataStr support (via symbol lookup support), +- Add Cache Value option, +- New English documentation (man/tex), +- Improve API consitency. diff --git a/src/libnode/demo/nddemo0.c b/src/libnode/demo/nddemo0.c new file mode 100644 index 0000000..444ce55 --- /dev/null +++ b/src/libnode/demo/nddemo0.c @@ -0,0 +1,686 @@ +/*---------------------------------------------------------------------------------*/ +/* %RCSfile: nddemo0.c,v % */ +/*---------------------------------------------------------------------------------*/ +/* %Revision: 2.8 % */ +/* %Name: libnode-2_1_0-1 % */ +/* %Date: 2004/08/23 22:48:37 % */ +/* %Author: agibert % */ +/*---------------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------------*/ +/* This file is part of LibNode */ +/* */ +/* LibNode is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public Licence as published by */ +/* the Free Software Foundation; either version 2 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* LibNode 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 General Public License */ +/* along with LibNode; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/*---------------------------------------------------------------------------------*/ + + + + + +#include +#include + +#include + + + +#define DEMO_FILE_NAME "nddemo0.dat" +#define STRING_LEN ( short) 1024 +#define STRING_SIZE ( short) ( STRING_LEN + 1) +#define VAL_LEN ( short) 64 +#define VAL_SIZE ( short) ( VAL_LEN + 1) +#define INDEX_NB ( short) 4 + +#define NDD_CMD_INDEX0_PRINT ( NDT_Command) 64 +#define NDD_CMD_INDEX1_PRINT ( NDT_Command) 65 +#define NDD_CMD_INDEX2_PRINT ( NDT_Command) 66 +#define NDD_CMD_INDEX3_PRINT ( NDT_Command) 67 + + + +typedef struct Demo_Value +{ + char Val0[ VAL_SIZE]; + char Val1[ VAL_SIZE]; + char Val2[ VAL_SIZE]; + char Val3[ VAL_SIZE]; +} Demo_Value; + + + +/*---------------------------------------------------------------------------------*/ +/* Prototypes */ +/*---------------------------------------------------------------------------------*/ + +NDT_Status Demo_DS_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +void DataStruct_Load( NDT_Root *, FILE *); +void DataStruct_Load( NDT_Root *, FILE *); +void Demo( char *, short); +int main( int, char **); + + + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +NDT_Status Demo_DS_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "%Revision: 2.8 % %Name: libnode-2_1_0-1 % %Date: 2004/08/23 22:48:37 % %Author: agibert %"; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + Demo_Value *Value_ptr = (Demo_Value *)va_arg( Args, Demo_Value *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case NDD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + break; + } + + case NDD_CMD_INDEX1_PRINT: + { + *Reply_Index_Id_Ptr = 1; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + break; + } + + case NDD_CMD_INDEX2_PRINT: + { + *Reply_Index_Id_Ptr = 2; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + break; + } + + case NDD_CMD_INDEX3_PRINT: + { + *Reply_Index_Id_Ptr = 3; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + break; + } + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + Demo_Value **Value_Ptr_Ptr = va_arg( Args, Demo_Value **); + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Value_Ptr_Ptr = (Demo_Value *)malloc( sizeof(Demo_Value))) == NULL) + { + return(NDS_ERRMEM); + } + else + { + (*Value_Ptr_Ptr)->Val0[0] = '\0'; + (*Value_Ptr_Ptr)->Val1[0] = '\0'; + (*Value_Ptr_Ptr)->Val2[0] = '\0'; + (*Value_Ptr_Ptr)->Val3[0] = '\0'; + + return( NDS_OK); + } + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + Demo_Value *Value_Ptr = (Demo_Value *)va_arg( Args, Demo_Value *); + + + Command_Name = "NDD_CMD_VALUE_FREE"; + + free( Value_Ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + Demo_Value *Value1_Ptr = va_arg( Args, Demo_Value *); + Demo_Value *Value2_Ptr = va_arg( Args, Demo_Value *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case 0: + { + int rc; + + + rc = strcmp( Value1_Ptr->Val0, Value2_Ptr->Val0); + + if( rc < 0) + { + return( NDS_LOWER); + } + else + { + if( rc > 0) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + case 1: + { + int val1 = atoi( Value1_Ptr->Val1); + int val2 = atoi( Value2_Ptr->Val1); + + + if( val1 < val2) + { + return( NDS_LOWER); + } + else + { + if( val1 > val2) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + case 2: + { + int val1 = strlen( Value1_Ptr->Val2); + int val2 = strlen( Value2_Ptr->Val2); + + + if( val1 < val2) + { + return( NDS_LOWER); + } + else + { + if( val1 > val2) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + printf( "Unknown COMP idx (%d) !\n", Index_Id); + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + + Demo_Value *Value_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + fprintf( Out, "Val0: (%s) Val1: (%s) Val2: (%s) Val3: (%s)\n", + Value_Ptr->Val0, Value_Ptr->Val1, Value_Ptr->Val2, Value_Ptr->Val3); + + return( NDS_OK); + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( NDS_OK); + } + + default: + { + printf( "Demo_DS_Manager() called with an undefined command %d\n", Command); + return( NDS_ERRAPI); + } + } + + printf( "Demo_DS_Manager() called with command %d (%s)\n", Command, Command_Name); + return( NDS_OK); +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +void DataStruct_Load( NDT_Root *ds_ptr, FILE *demo_file) +{ + NDT_Status status; + char *str; + char input_string[STRING_SIZE]; + char val0[VAL_SIZE], val1[VAL_SIZE], val2[VAL_SIZE], val3[VAL_SIZE]; + Demo_Value *value_ptr; + + + while( !feof( demo_file)) + { + str = fgets( input_string, STRING_SIZE, demo_file); + if( ( (const int)str != EOF) && ( str != NULL)) + { + if( strlen( input_string) >= STRING_LEN) + { + printf( "Input line too long ! Skipping ..."); + + while( !feof( demo_file) && strlen( input_string) >= STRING_LEN) + { + printf( "."); + str = fgets( input_string, STRING_SIZE, demo_file); + } + + printf("\n"); + } + else + { + if( input_string[0] != '#') + { + if( sscanf( input_string, "%s %s %s %s\n", val0, val1, val2, val3) != 4) + { + printf( "Input line scaning error... Skipping !\n"); + } + else + { + printf( "Input line read: \t(%s)\t(%s)\t(%s)\t(%s)\n", val0, val1, val2, val3); + printf( "Allocate Vallue: "); + + if( ( status = ND_Value_Alloc( ds_ptr, (void **)&value_ptr)) != NDS_OK) + { + printf( "ND_Value_Alloc() failed (%d) !\n", status); + } + else + { + printf( "Ok !\n"); + + strcpy( value_ptr->Val0, val0); + strcpy( value_ptr->Val1, val1); + strcpy( value_ptr->Val2, val2); + strcpy( value_ptr->Val3, val3); + + printf( "Add Vallue: "); + + if( ( status = ND_DataStruct_Value_Add( ds_ptr, (void **)value_ptr)) != NDS_OK) + { + printf( "ND_Value_Add() failed (%d) !\n", status); + } + else + { + printf( "Ok !\n"); + } + } + } + } + } + } + } +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +void DataStruct_Dump( NDT_Root *ds_ptr) +{ + NDT_Status status; + + + printf( "Print DataStructure Info:\n"); + + if( ( status = ND_DataStruct_Info_Print( stdout, ds_ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK) + { + printf( "ND_DataStruct_Info_Print() failed (%d) !\n", status); + } + + printf( "\n"); + + + + printf( "Traverse DataStructure Index 0:\n"); + + if( ( status = ND_DataStruct_Traverse( ds_ptr, NDD_CMD_INDEX0_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse() failed (%d) !\n", status); + } + + printf( "\n"); + + + + printf( "Traverse DataStructure Index 1:\n"); + + if( ( status = ND_DataStruct_Traverse( ds_ptr, NDD_CMD_INDEX1_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse() failed (%d) !\n", status); + } + + printf( "\n"); + + + + printf( "Traverse DataStructure Index 2:\n"); + + if( ( status = ND_DataStruct_Traverse( ds_ptr, NDD_CMD_INDEX2_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse() failed (%d) !\n", status); + } + + printf( "\n"); + + + + printf( "Traverse DataStructure Index 3:\n"); + + if( ( status = ND_DataStruct_Traverse( ds_ptr, NDD_CMD_INDEX3_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse() failed (%d) !\n", status); + } + + printf( "\n"); +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +void Demo( char *Demo_File_Name, short Optimized_Mode) +{ + NDT_Status status; + NDT_Root *demo_ds_ptr; + NDT_Index_Type index_type_initial_tab[INDEX_NB] = + { + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO) + }; + NDT_Index_Type index_type_final_tab[INDEX_NB] = + { + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO) + }; + NDT_Index_Type *index_type_ptr; + FILE *demo_file; + + + printf( "Open library: "); + + if( ( status = ND_Library_Open( NDD_TRUE)) != NDS_OK) + { + printf( "ND_Library_Open() failed (%d) !\n", status); + } + else + { + printf( "Ok !\n"); + + printf( "Create demo DataStructure: "); + + if( Optimized_Mode) + { + index_type_ptr = index_type_initial_tab; + } + else + { + index_type_ptr = index_type_final_tab; + } + + if( ( status = ND_DataStruct_Open( &demo_ds_ptr, INDEX_NB, index_type_ptr, "Demo_DS_Manager", Demo_DS_Manager, NULL, NULL, NULL, NULL,0, NULL)) != NDS_OK) + { + printf( "ND_DataStruct_Open() failed (%d) !\n", status); + } + else + { + printf( "Ok !\n"); + + printf( "Open demo datafile: "); + + if( ( demo_file = fopen( Demo_File_Name, "r")) == NULL) + { + printf( "fopen() failed (%d/%s) !\n", errno, strerror(errno)); + } + else + { + printf( "Ok !\n"); + + + + printf( "\n\n\nLaod Data File:\n\n"); + DataStruct_Load( demo_ds_ptr, demo_file); + + if( Optimized_Mode) + { + printf( "\n\n\nInitial Structure Dump:\n\n"); + DataStruct_Dump( demo_ds_ptr); + + printf( "Convert data structure: "); + + if( ( status = ND_DataStruct_Convert( demo_ds_ptr, index_type_final_tab)) != NDS_OK) + { + printf( "ND_DataStruct_Convert() failed (%d) !\n", status); + } + else + { + printf( "Ok !\n"); + } + } + + + + printf( "\n\n\nFinal Structure Dump:\n\n"); + DataStruct_Dump( demo_ds_ptr); + + printf( "Close demo datafile: "); + + if( fclose( demo_file) != 0) + { + printf( "fclose() failed (%d/%s) !\n", errno, strerror(errno)); + } + else + { + printf( "Ok !\n"); + } + } + + + printf( "Close demo DataStructure: "); + + if( ( status = ND_DataStruct_Close( demo_ds_ptr)) != NDS_OK) + { + printf( "ND_DataStruct_Close() failed (%d) !\n", status); + } + else + { + printf( "Ok !\n"); + } + } + + printf( "Close library: "); + + if( ( status = ND_Library_Close()) != NDS_OK) + { + printf( "ND_Library_Close() failed (%d) !\n", status); + } + else + { + printf( "Ok !\n"); + } + } +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +int main( int argc, char **argv) +{ + printf( "Non Optimized Demo\n------------------\n\n\n"); + Demo( DEMO_FILE_NAME, 0); + + printf( "\n\n\n\n\nOptimized Demo\n--------------\n\n\n"); + Demo( DEMO_FILE_NAME, 1); +} diff --git a/src/libnode/demo/nddemo0.dat b/src/libnode/demo/nddemo0.dat new file mode 100644 index 0000000..07ddfe8 --- /dev/null +++ b/src/libnode/demo/nddemo0.dat @@ -0,0 +1,15 @@ +#--------------------------------------------------------------------------------- +# %RCSfile: nddemo0.dat,v % +#--------------------------------------------------------------------------------- +# %Revision: 2.1 % +# %Name: libnode-2_1_0-1 % +# %Date: 2003/07/16 00:17:02 % +# %Author: agibert % +#--------------------------------------------------------------------------------- +ggg 1 xxxxxx example +aaa 7 x this +bbb 6 xxx is +ccc 5 xxxxx a +ddd 4 xxxx really +eee 3 xxxxxxx good +fff 2 xx libnode diff --git a/src/libnode/include/node.h b/src/libnode/include/node.h new file mode 100644 index 0000000..2d83cda --- /dev/null +++ b/src/libnode/include/node.h @@ -0,0 +1,926 @@ +/*----------------------------------------------------------------------------*/ +/* $Workfile: node.h $ */ +/*----------------------------------------------------------------------------*/ +/* $Author: agibert $ */ +/* $Date: 2008/11/12 02:25:23 $ */ +/* $Revision: 1.1 $ */ +/* $Label: $ */ +/*----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------------*/ +/* %RCSfile: node.h,v % */ +/*---------------------------------------------------------------------------------*/ +/* %Revision: 2.12 % */ +/* %Name: libnode-2_1_0-1 % */ +/* %Date: 2005/01/20 00:00:25 % */ +/* %Author: agibert % */ +/*---------------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------------*/ +/* This file is part of LibNode */ +/* */ +/* LibNode is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU Lesser General Public Licence as published by */ +/* the Free Software Foundation; either version 2.1 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* LibNode 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 LibNode; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/*---------------------------------------------------------------------------------*/ + + + + + + +#ifndef _LIBNODE_H_ +# define _LIBNODE_H_ + +# ifdef __cplusplus +extern "C" { +# endif + +# include +# include +# include +# include + +# ifdef _LIBVER_SUPPORT +# include +# endif + + + + + + + +#define NDD_TRUE 1 + +#define NDD_FALSE 0 + +#define NDD_MIN(A,B) ((A > B) ? B : A) + +#define NDD_MAX(A,B) ((A < B) ? B : A) + + + +/* + Différence de profondeur entre la branche la plus courte et + la plus longue d'un arbre. + Le dépassement de ce seuil provoque le rééquilibrage de l'arbre +*/ + +#define DEF_MAX_DIF 100 + +/* Types de structure */ + +typedef short NDT_Root_Type; + +typedef int NDT_Index_Type; + +#define NDD_INDEX_MSK 0xffff +#define NDD_INDEX_RMSK 0x0000 + +#define NDD_INDEX_STATUS_UNKNOWN 0x0000 +#define NDD_INDEX_STATUS_OPENED 0x0001 +#define NDD_INDEX_STATUS_CLOSED 0x0002 +#define NDD_INDEX_STATUS_MSK (NDD_INDEX_STATUS_UNKNOWN | NDD_INDEX_STATUS_OPENED | NDD_INDEX_STATUS_CLOSED) +#define NDD_INDEX_STATUS_RMSK (NDD_INDEX_MSK ^ NDD_INDEX_STATUS_MSK) + +#define ND_INDEX_STATUS_VALUE_UNKNOWN_IS( v) ( ( (v) & NDD_INDEX_STATUS_MSK) == NDD_INDEX_STATUS_UNKNOWN) +#define ND_INDEX_STATUS_VALUE_OPENED_IS( v) ( ( (v) & NDD_INDEX_STATUS_MSK) == NDD_INDEX_STATUS_OPENED) +#define ND_INDEX_STATUS_VALUE_CLOSED_IS( v) ( ( (v) & NDD_INDEX_STATUS_MSK) == NDD_INDEX_STATUS_CLOSED) +#define ND_INDEX_STATUS_UNKNOWN_IS( r, i) ND_INDEX_STATUS_VALUE_UNKNOWN_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_STATUS_OPENED_IS( r, i) ND_INDEX_STATUS_VALUE_OPENED_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_STATUS_CLOSED_IS( r, i) ND_INDEX_STATUS_VALUE_CLOSED_IS( (r)->Index_Tab[(i)].Type) + +#define ND_INDEX_STATUS_VALUE_ASCII_GET( v) ( ND_INDEX_STATUS_VALUE_UNKNOWN_IS( (v)) ? "UNKNOWN" : ( ND_INDEX_STATUS_VALUE_OPENED_IS( (v)) ? "OPENED" : ( ND_INDEX_STATUS_VALUE_CLOSED_IS( (v)) ? "CLOSED" : "???"))) +#define ND_INDEX_STATUS_ASCII_GET( r, i) ND_INDEX_STATUS_VALUE_ASCII_GET( (r)->Index_Tab[(i)].Type) + + + +#define NDD_INDEX_TYPE_UNKNOWN 0x0000 +#define NDD_INDEX_TYPE_LIST 0x0010 +#define NDD_INDEX_TYPE_TREE 0x0020 +#define NDD_INDEX_TYPE_MSK (NDD_INDEX_TYPE_UNKNOWN | NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE) +#define NDD_INDEX_TYPE_RMSK (NDD_INDEX_MSK ^ NDD_INDEX_TYPE_MSK) + +#define ND_INDEX_TYPE_VALUE_UNKNOWN_IS( v) ( ( (v) & NDD_INDEX_TYPE_MSK) == NDD_INDEX_TYPE_UNKNOWN) +#define ND_INDEX_TYPE_VALUE_LIST_IS( v) ( ( (v) & NDD_INDEX_TYPE_MSK) == NDD_INDEX_TYPE_LIST) +#define ND_INDEX_TYPE_VALUE_TREE_IS( v) ( ( (v) & NDD_INDEX_TYPE_MSK) == NDD_INDEX_TYPE_TREE) + +#define ND_INDEX_TYPE_UNKNOWN_IS( r, i) ND_INDEX_TYPE_VALUE_UNKNOWN_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_TYPE_LIST_IS( r, i) ND_INDEX_TYPE_VALUE_LIST_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_TYPE_TREE_IS( r, i) ND_INDEX_TYPE_VALUE_TREE_IS( (r)->Index_Tab[(i)].Type) + +#define ND_INDEX_TYPE_VALUE_ASCII_GET( v) ( ND_INDEX_TYPE_VALUE_UNKNOWN_IS( (v)) ? "UNKNOWN" : ( ND_INDEX_TYPE_VALUE_LIST_IS( (v)) ? "LIST" : ( ND_INDEX_TYPE_VALUE_TREE_IS( (v)) ? "TREE" : "???"))) + +#define ND_INDEX_TYPE_ASCII_GET( r, i) ND_INDEX_TYPE_VALUE_ASCII_GET( (r)->Index_Tab[(i)].Type) + + + +#define NDD_INDEX_SUBTYPE_UNKNOWN 0x0000 +#define NDD_INDEX_SUBTYPE_FIFO 0x0100 /* principe de la file d'attente (First In First Out) */ +#define NDD_INDEX_SUBTYPE_LILO NDD_INDEX_SUBTYPE_FIFO +#define NDD_INDEX_SUBTYPE_LIFO 0x0200 /* principe de la pile (First In Last Out) */ +#define NDD_INDEX_SUBTYPE_FILO NDD_INDEX_SUBTYPE_LIFO +#define NDD_INDEX_SUBTYPE_SORTED 0x0300 /* liste triée */ +#define NDD_INDEX_SUBTYPE_UNBALANCED 0x0400 +#define NDD_INDEX_SUBTYPE_BALANCED 0x0500 /* arbre auto-équilibré */ +#define NDD_INDEX_SUBTYPE_MSK ( NDD_INDEX_SUBTYPE_UNKNOWN | NDD_INDEX_SUBTYPE_FIFO | NDD_INDEX_SUBTYPE_FILO | NDD_INDEX_SUBTYPE_SORTED | NDD_INDEX_SUBTYPE_UNBALANCED | NDD_INDEX_SUBTYPE_BALANCED) +#define NDD_INDEX_SUBTYPE_RMSK (NDD_INDEX_MSK ^ NDD_INDEX_SUBTYPE_MSK) + +#define ND_INDEX_SUBTYPE_VALUE_UNKNOWN_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_UNKNOWN) +#define ND_INDEX_SUBTYPE_VALUE_FIFO_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_FIFO) +#define ND_INDEX_SUBTYPE_VALUE_LILO_IS( v) ND_INDEX_SUBTYPE_VALUE_FIFO_IS( v) +#define ND_INDEX_SUBTYPE_VALUE_LIFO_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_LIFO) +#define ND_INDEX_SUBTYPE_VALUE_FILO_IS( v) ND_INDEX_SUBTYPE_LIFO_IS( r, i) +#define ND_INDEX_SUBTYPE_VALUE_SORTED_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_SORTED) +#define ND_INDEX_SUBTYPE_VALUE_UNBALANCED_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_UNBALANCED) +#define ND_INDEX_SUBTYPE_VALUE_BALANCED_IS( v) ( ( (v) & NDD_INDEX_SUBTYPE_MSK) == NDD_INDEX_SUBTYPE_BALANCED) + +#define ND_INDEX_SUBTYPE_UNKNOWN_IS( r, i) ND_INDEX_SUBTYPE_VALUE_UNKNOWN_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_SUBTYPE_FIFO_IS( r, i) ND_INDEX_SUBTYPE_VALUE_FIFO_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_SUBTYPE_LILO_IS( r, i) ND_INDEX_SUBTYPE_VALUE_LILO_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_SUBTYPE_LIFO_IS( r, i) ND_INDEX_SUBTYPE_VALUE_LIFO_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_SUBTYPE_FILO_IS( r, i) ND_INDEX_SUBTYPE_VALUE_FILO_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_SUBTYPE_SORTED_IS( r, i) ND_INDEX_SUBTYPE_VALUE_SORTED_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_SUBTYPE_UNBALANCED_IS( r, i) ND_INDEX_SUBTYPE_VALUE_UNBALANCED_IS( (r)->Index_Tab[(i)].Type) +#define ND_INDEX_SUBTYPE_BALANCED_IS( r, i) ND_INDEX_SUBTYPE_VALUE_BALANCED_IS( (r)->Index_Tab[(i)].Type) + +#define ND_INDEX_SUBTYPE_VALUE_ASCII_GET( v) ( ND_INDEX_SUBTYPE_VALUE_UNKNOWN_IS( v) ? "UNKNOWN" : ( ND_INDEX_SUBTYPE_VALUE_FIFO_IS( v) ? "FIFO" : ( ND_INDEX_SUBTYPE_VALUE_LIFO_IS( v) ? "LIFO" : ( ND_INDEX_SUBTYPE_VALUE_SORTED_IS( v) ? "SORTED" : ( ND_INDEX_SUBTYPE_VALUE_UNBALANCED_IS( v) ? "UNBALANCED" : ( ND_INDEX_SUBTYPE_VALUE_BALANCED_IS( v) ? "BALANCED" : "???")))))) +#define ND_INDEX_SUBTYPE_ASCII_GET( r, i) ND_INDEX_SUBTYPE_VALUE_ASCII_GET( (r)->Index_Tab[(i)].Type) + + + +/* Commandes du manager */ + +typedef int NDT_Command; + +#define NDD_CMD_UNKNOWN (NDT_Command)0 +#define NDD_CMD_MANAGER_VERSION (NDT_Command)1 +#define NDD_CMD_INDEX_GET (NDT_Command)2 +#define NDD_CMD_VALUE_ALLOC (NDT_Command)3 +#define NDD_CMD_VALUE_FREE (NDT_Command)4 +#define NDD_CMD_VALUE_COMP (NDT_Command)5 +#define NDD_CMD_VALUE_ADD (NDT_Command)6 +#define NDD_CMD_VALUE_REMOVE (NDT_Command)7 +#define NDD_CMD_VALUE_PRINT (NDT_Command)8 +#define NDD_CMD_VALUE_FIND (NDT_Command)9 +#define NDD_CMD_INFO_PRINT (NDT_Command)10 + +#define NDD_CMD_USER_TRAVERSE (NDT_Command)17 + + +typedef char *NDT_Command_Name; +typedef char *NDT_Version_Name; + + + +/* Types de réponse du manager ou code retour des diverses fonctions */ + +typedef int NDT_Status; + +#define ND_ERROR(s) ((s) <= 0) /* All negative or 0 status are errors */ + +#define NDS_OK 1 +#define NDS_KO 0 + +#define NDS_YES 1 +#define NDS_NO 0 + +#define NDS_EQUAL 1 +#define NDS_GREATER 2 +#define NDS_LOWER 3 + +#define NDS_ERRMEM -1 /* Problème d'allocation mémoire */ +#define NDS_ERRAPI -2 /* Utilisation incorrecte des API */ + + + +typedef short NDT_Index_Id; +typedef short NDT_Index_Nb; + +#define NDD_INDEX_UNKNOWN (NDT_Index_Id)-1 +#define NDD_INDEX_PRIMARY (NDT_Index_Id)0 + + + +struct NDT_Root; +struct NDT_Node; + + + +/* Pointeur de fonction sur le manager */ + +#define NDD_MANAGER_NAME_LEN_MAX 64 +#define NDD_MANAGER_NAME_SIZE_MAX (NDD_MANAGER_NAME_LEN_MAX + 1) + +typedef char *NDT_Manager_Name; + +typedef NDT_Status NDT_Manager( struct NDT_Root *, NDT_Index_Id, struct NDT_Node *, NDT_Command, va_list); + + +/* Pointeur de fonction sur l'allocateur */ + +#define NDD_ALLOCATOR_NAME_LEN_MAX 64 +#define NDD_ALLOCATOR_NAME_SIZE_MAX (NDD_ALLOCATOR_NAME_LEN_MAX + 1) + +typedef char *NDT_Allocator_Name; + +typedef NDT_Status NDT_Allocator( void **, size_t, void *); + + +/* Pointeur de fonction sur le désallocateur */ + +#define NDD_DESALLOCATOR_NAME_LEN_MAX 64 +#define NDD_DESALLOCATOR_NAME_SIZE_MAX (NDD_DESALLOCATOR_NAME_LEN_MAX + 1) + +typedef char *NDT_Desallocator_Name; + +typedef NDT_Status NDT_Desallocator( void *, void *); + + + + +typedef struct NDT_Index +{ + NDT_Index_Type Type; /* Type de la structure (liste, arbre ... ) */ + + long Node_Number; /* Nombre de noeuds dans la structure */ + long Min_Depth; /* Profondeur minimale de l'arbre */ + long Max_Depth; /* Profondeur maximale de l'arbre */ + long Max_Dif; /* Différence maximale autorisée entre la branche la plus courte et la plus longue */ + long Nb_Equ; /* Nombre de réquilibrages réalisés sur l'arbre */ + struct NDT_Node *Head; /* Noeud de tête */ + struct NDT_Node *Tail; /* Noeud de queue */ + struct NDT_Node *Save; /* Pointeur de sauvegarde (utile pour la fonction de restauration) */ + +} NDT_Index; + + + +typedef struct NDT_Root +{ +/* NDT_Root_Type Type;*/ /* Root Structure Type */ +/* NDT_DataStruct_Type DS_Type;*/ /* Type de la structure (liste, arbre ... ) */ + + NDT_Manager *Manager_Ptr; /* Pointeur sur la fonction manager */ + char Manager_Name[NDD_MANAGER_NAME_SIZE_MAX]; /* Nom de la fonction manager */ + NDT_Allocator *Allocator_Ptr; /* Pointeur sur la fonction d'allocation */ + char Allocator_Name[NDD_ALLOCATOR_NAME_SIZE_MAX]; /* Nom de la fonction d'allocation */ + NDT_Desallocator *Desallocator_Ptr; /* Pointeur sur la fonction de désallocation */ + char Desallocator_Name[NDD_DESALLOCATOR_NAME_SIZE_MAX]; /* Nom de la fonction de désallocation */ + + short Own_Value; /* Indique si la structure est propriétaire de ses valeurs */ + void *User_Ptr; /* Pointeur utilisable librement par l'utilisateur */ + + NDT_Index_Nb Index_Nb; + NDT_Index_Nb Index_Open_Count; + NDT_Index Index_Tab[1]; + +} NDT_Root; + + + +typedef struct NDT_DataStruct +{ + + NDT_Root *Root_Ptr; + + NDT_Manager *Manager_Ptr; /* Manager function pointer */ + NDT_Allocator *Allocator_Ptr; /* Allocator function pointer */ + NDT_Desallocator *Desallocator_Ptr; /* Desallocator function pointer */ + +} NDT_DataStruct; + + + +/* Structure de noeud */ + +typedef struct NDT_Node +{ + NDT_Root *Root; + NDT_Index_Id Index; + struct NDT_Node *Parent; + struct NDT_Node *Left; + struct NDT_Node *Right; + void *Value; +} NDT_Node; + + + +typedef int NDT_Recursive_Mode; +typedef int NDT_Recursive_Depth; +typedef int NDT_Recursive_Offset; + +#define NDD_RECURSIVE_MODE_UNKNOWN (NDT_Recursive_Mode)0x00 +#define NDD_RECURSIVE_MODE_PARENT (NDT_Recursive_Mode)0x01 +#define NDD_RECURSIVE_MODE_CHILD (NDT_Recursive_Mode)0x02 +#define NDD_RECURSIVE_MODE_PARENT_CHILD (NDT_Recursive_Mode)0x03 + +#define ND_RECURSIVE_PARENT_IS(m) (m & NDD_RECURSIVE_MODE_PARENT) +#define ND_RECURSIVE_CHILD_IS(m) (m & NDD_RECURSIVE_MODE_CHILD) + +#define ND_RECURSIVE_PRINT_OFFSET 8 + + + +/* Définition des alias de l'API */ + +#ifndef ND_MODE +#define ND_MODE 0 +#endif + +#if ND_MODE == 1 /* API sans vérification des arguments */ + +#define ND_Library_Open ND_Library_Open_I +#define ND_Library_Close ND_Library_Close_I +#define ND_Library_StdErr_Set ND_Library_StdErr_Set_I + +#define ND_DataStruct_Open ND_DataStruct_Open_I +#define ND_DataStruct_Close ND_DataStruct_Close_I +#define ND_DataStruct_Flush ND_DataStruct_Flush_I +#define ND_DataStruct_Check ND_DataStruct_Check_I +#define ND_DataStruct_Convert ND_DataStruct_Convert_I +#define ND_DataStruct_Reorg ND_DataStruct_Reorg_I +#define ND_DataStruct_Traverse_V ND_DataStruct_Traverse_VI +#define ND_DataStruct_Traverse ND_DataStruct_Traverse_I +#define ND_DataStruct_Info_Print ND_DataStruct_Info_Print_I +#define ND_DataStruct_Value_Add ND_DataStruct_Value_Add_I +#define ND_DataStruct_Value_Remove ND_DataStruct_Value_Remove_I +#define ND_DataStruct_Value_Print ND_DataStruct_Value_Print_I +#define ND_DataStruct_Value_Find ND_DataStruct_Value_Find_I + +#define ND_Index_Open ND_Index_Open_I +#define ND_Index_Close ND_Index_Close_I +#define ND_Index_Flush ND_Index_Flush_I +#define ND_Index_Check ND_Index_Check_I +#define ND_Index_Convert ND_Index_Convert_I +#define ND_Index_Reorg ND_Index_Reorg_I +#define ND_Index_Traverse_V ND_Index_Traverse_VI +#define ND_Index_Traverse ND_Index_Traverse_I +#define ND_Index_Info_Print ND_Index_Info_Print_I +#define ND_Index_Value_Add ND_Index_Value_Add_I +#define ND_Index_Value_Remove ND_Index_Value_Remove_I +#define ND_Index_Value_Print ND_Index_Value_Print_I +#define ND_Index_Node_Add ND_Index_Node_Add_I +#define ND_Index_Node_Remove ND_Index_Node_Remove_I +#define ND_Index_Node_First_Get ND_Index_Node_First_Get_I +#define ND_Index_Node_Last_Get ND_Index_Node_Last_Get_I +#define ND_Index_Node_Next_Get ND_Index_Node_Next_Get_I +#define ND_Index_Node_Previous_Get ND_Index_Node_Previous_Get_I +#define ND_Index_Node_Find ND_Index_Node_Find_I + +#define ND_Node_Root_Get ND_Node_Root_Get_I + +#define ND_Value_Alloc ND_Value_Alloc_I +#define ND_Value_Free ND_Value_Free_I + +#define ND_Manager_Exec_V ND_Manager_Exec_VI +#define ND_Manager_Exec ND_Manager_Exec_I +#define ND_Allocator_Exec ND_Allocator_Exec_I +#define ND_Desallocator_Exec ND_Desallocator_Exec_I + +#else /* API avec vérification des arguments */ + +#define ND_Library_Open ND_Library_Open_C +#define ND_Library_Close ND_Library_Close_C +#define ND_Library_StdErr_Set ND_Library_StdErr_Set_C + +#define ND_DataStruct_Open ND_DataStruct_Open_C +#define ND_DataStruct_Close ND_DataStruct_Close_C +#define ND_DataStruct_Flush ND_DataStruct_Flush_C +#define ND_DataStruct_Check ND_DataStruct_Check_C +#define ND_DataStruct_Convert ND_DataStruct_Convert_C +#define ND_DataStruct_Reorg ND_DataStruct_Reorg_C +#define ND_DataStruct_Traverse_V ND_DataStruct_Traverse_VC +#define ND_DataStruct_Traverse ND_DataStruct_Traverse_C +#define ND_DataStruct_Info_Print ND_DataStruct_Info_Print_C +#define ND_DataStruct_Value_Add ND_DataStruct_Value_Add_C +#define ND_DataStruct_Value_Remove ND_DataStruct_Value_Remove_C +#define ND_DataStruct_Value_Print ND_DataStruct_Value_Print_C +#define ND_DataStruct_Value_Find ND_DataStruct_Value_Find_C + +#define ND_Index_Open ND_Index_Open_C +#define ND_Index_Close ND_Index_Close_C +#define ND_Index_Flush ND_Index_Flush_C +#define ND_Index_Check ND_Index_Check_C +#define ND_Index_Convert ND_Index_Convert_C +#define ND_Index_Reorg ND_Index_Reorg_C +#define ND_Index_Traverse_V ND_Index_Traverse_VC +#define ND_Index_Traverse ND_Index_Traverse_C +#define ND_Index_Info_Print ND_Index_Info_Print_C +#define ND_Index_Value_Add ND_Index_Value_Add_C +#define ND_Index_Value_Remove ND_Index_Value_Remove_C +#define ND_Index_Value_Print ND_Index_Value_Print_C +#define ND_Index_Node_Add ND_Index_Node_Add_C +#define ND_Index_Node_Remove ND_Index_Node_Remove_C +#define ND_Index_Node_First_Get ND_Index_Node_First_Get_C +#define ND_Index_Node_Last_Get ND_Index_Node_Last_Get_C +#define ND_Index_Node_Next_Get ND_Index_Node_Next_Get_C +#define ND_Index_Node_Previous_Get ND_Index_Node_Previous_Get_C +#define ND_Index_Node_Find ND_Index_Node_Find_C + +#define ND_Node_Root_Get ND_Node_Root_Get_C + +#define ND_Value_Alloc ND_Value_Alloc_C +#define ND_Value_Free ND_Value_Free_C + +#define ND_Manager_Exec_V ND_Manager_Exec_VC +#define ND_Manager_Exec ND_Manager_Exec_C +#define ND_Allocator_Exec ND_Allocator_Exec_C +#define ND_Desallocator_Exec ND_Desallocator_Exec_C + +#endif + + + +/*------------------------------------------------------------------------------*/ + +# if defined(_WIN32) && !defined(LIBNODE_STATIC) +# ifndef _LIBNODE_C_ +# define NDD_DLL_API __declspec(dllimport) +# else +# define NDD_DLL_API __declspec(dllexport) +# endif +# else +# define NDD_DLL_API +# endif + + + +/*------------------------------------------------------------------------------*/ +/* Initialisation du contexte de la librairie */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Library_Open_I ( int Debug_Mode ); +NDD_DLL_API NDT_Status ND_Library_Open_C ( int Debug_Mode ); + + + +/*------------------------------------------------------------------------------*/ +/* Fermeture du contexte de la librairie */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Library_Close_I( void); +NDD_DLL_API NDT_Status ND_Library_Close_C( void); + + + +/*------------------------------------------------------------------------------*/ +/* Définition de la sortie standard des messages d'erreur de la librairie */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Library_StdErr_Set_I( FILE *); +NDD_DLL_API NDT_Status ND_Library_StdErr_Set_C( FILE *); + + + +/*------------------------------------------------------------------------------*/ +/* Création d'une nouvelle structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: adresse d'un pointeur sur la racine de la nouvelle structure */ +/* (I) Type: type de la structure.de données (liste ou arbre binaire) */ +/* (I) Allocator: pointeur vers la fonction d'allocation */ +/* (I) Desallocator: pointeur vers la fonction de désallocation */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/* (I) Own_Value : indique si la structure est propriétaire de ses valeurs */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Open_I( NDT_Root **, NDT_Index_Nb, NDT_Index_Type *, NDT_Manager_Name, NDT_Manager *, NDT_Allocator_Name, NDT_Allocator *, NDT_Desallocator_Name, NDT_Desallocator *, short, void *); +NDD_DLL_API NDT_Status ND_DataStruct_Open_C( NDT_Root **, NDT_Index_Nb, NDT_Index_Type *, NDT_Manager_Name, NDT_Manager *, NDT_Allocator_Name, NDT_Allocator *, NDT_Desallocator_Name, NDT_Desallocator *, short, void *); + + + +/*------------------------------------------------------------------------------*/ +/* Destruction d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Close_I( NDT_Root *); +NDD_DLL_API NDT_Status ND_DataStruct_Close_C( NDT_Root *); + + + +/*------------------------------------------------------------------------------*/ +/* Destruction d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Flush_I( NDT_Root *); +NDD_DLL_API NDT_Status ND_DataStruct_Flush_C( NDT_Root *); + + + +/*------------------------------------------------------------------------------*/ +/* Function de réparation d'une structure : */ +/* - vérifie que tous les noeuds sont correctement liés les uns aux autres */ +/* - corrige les informations statistiques de la racine */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure */ +/* (O) Nb_Detected : pointeur sur le nombre d'erreurs */ +/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs */ +/* (I) Out : flux de sortie du rapport */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Check_I( NDT_Root *, int *, int *, FILE *); +NDD_DLL_API NDT_Status ND_DataStruct_Check_C( NDT_Root *, int *, int *, FILE *); + + + +/*------------------------------------------------------------------------------*/ +/* Réorganisation d'une structure de données : */ +/* - ordonnancement d'une liste non ordonnée */ +/* - réquilibrage d'un arbre non auto-équilibré */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Reorg_I( NDT_Root *); +NDD_DLL_API NDT_Status ND_DataStruct_Reorg_C( NDT_Root *); + + + +/*------------------------------------------------------------------------------*/ +/* Conversion d'une structure de données d'un type en un autre */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Target_Type: type de structure cible */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Convert_I( NDT_Root *, NDT_Index_Type *); +NDD_DLL_API NDT_Status ND_DataStruct_Convert_C( NDT_Root *, NDT_Index_Type *); + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Command: Commande à exécuter sur chaque noeud traversé */ +/* (I) Data: pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Traverse_VI( NDT_Root *, NDT_Command, va_list); +NDD_DLL_API NDT_Status ND_DataStruct_Traverse_VC( NDT_Root *, NDT_Command, va_list); +NDD_DLL_API NDT_Status ND_DataStruct_Traverse_I( NDT_Root *, NDT_Command, ...); +NDD_DLL_API NDT_Status ND_DataStruct_Traverse_C( NDT_Root *, NDT_Command, ...); + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'informations sur une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Info_Print_I( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset); +NDD_DLL_API NDT_Status ND_DataStruct_Info_Print_C( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset); + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'une valeur à une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Value: pointeur sur la valeur à ajouter */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Value_Add_I( NDT_Root *, void *); +NDD_DLL_API NDT_Status ND_DataStruct_Value_Add_C( NDT_Root *, void *); + + + +/*------------------------------------------------------------------------------*/ +/* Suppression du premier noeud correspondant à une valeur donnée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Reference_Value : pointeur sur la valeur de référence */ +/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Value_Remove_I( NDT_Root *, void *); +NDD_DLL_API NDT_Status ND_DataStruct_Value_Remove_C( NDT_Root *, void *); + + + +/*------------------------------------------------------------------------------*/ +/* Affichage de la valeur de tous les noeuds d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_DataStruct_Value_Print_VI( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, va_list); +NDD_DLL_API NDT_Status ND_DataStruct_Value_Print_I( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, ...); +NDD_DLL_API NDT_Status ND_DataStruct_Value_Print_C( FILE *, NDT_Root *, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, ...); + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud à partir d'une valeur */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (O) Node : pointeur sur le noeud à récuperer */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_VI( void **, NDT_Root *, void *, va_list); +NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_VC( void **, NDT_Root *, void *, va_list); +NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_I( void **, NDT_Root *, void *, ...); +NDD_DLL_API NDT_Status ND_DataStruct_Value_Find_C( void **, NDT_Root *, void *, ...); + + + +/*------------------------------------------------------------------------------*/ +/* Create a new index (not yet implemented !) */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: adresse d'un pointeur sur la racine de la nouvelle structure */ +/* (I) Type: type de la structure.de données (liste ou arbre binaire) */ +/* (I) Allocator: pointeur vers la fonction d'allocation */ +/* (I) Desallocator: pointeur vers la fonction de désallocation */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/* (I) Own_Value : indique si la structure est propriétaire de ses valeurs */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Open_I( NDT_Root *, NDT_Index_Id, NDT_Index_Type); +NDD_DLL_API NDT_Status ND_Index_Open_C( NDT_Root *, NDT_Index_Id, NDT_Index_Type); + + + +/*------------------------------------------------------------------------------*/ +/* Remove an Index (not yet implemented !) */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Close_I( NDT_Root *, NDT_Index_Id); +NDD_DLL_API NDT_Status ND_Index_Close_C( NDT_Root *, NDT_Index_Id); + + + +/*------------------------------------------------------------------------------*/ +/* Remove an Index (not yet implemented !) */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Flush_I( NDT_Root *, NDT_Index_Id); +NDD_DLL_API NDT_Status ND_Index_Flush_C( NDT_Root *, NDT_Index_Id); + + + +/*------------------------------------------------------------------------------*/ +/* Function de réparation d'une structure : */ +/* - vérifie que tous les noeuds sont correctement liés les uns aux autres */ +/* - corrige les informations statistiques de la racine */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure */ +/* (O) Nb_Detected : pointeur sur le nombre d'erreurs */ +/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs */ +/* (I) Out : flux de sortie du rapport */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Check_I( NDT_Root *, NDT_Index_Id, int *, int *, FILE *); +NDD_DLL_API NDT_Status ND_Index_Check_C( NDT_Root *, NDT_Index_Id, int *, int *, FILE *); + + + +/*------------------------------------------------------------------------------*/ +/* Conversion d'une structure de données d'un type en un autre */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Target_Type: type de structure cible */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Convert_I ( NDT_Root *, NDT_Index_Id, NDT_Index_Type); +NDD_DLL_API NDT_Status ND_Index_Convert_C ( NDT_Root *, NDT_Index_Id, NDT_Index_Type); + + + +/*------------------------------------------------------------------------------*/ +/* Réorganisation d'une structure de données : */ +/* - ordonnancement d'une liste non ordonnée */ +/* - réquilibrage d'un arbre non auto-équilibré */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Reorg_I( NDT_Root *, NDT_Index_Id); +NDD_DLL_API NDT_Status ND_Index_Reorg_C( NDT_Root *, NDT_Index_Id); + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Command: Commande à exécuter sur chaque noeud traversé */ +/* (I) Data: pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Traverse_VI( NDT_Root *, NDT_Index_Id, NDT_Command, va_list); +NDD_DLL_API NDT_Status ND_Index_Traverse_VC( NDT_Root *, NDT_Index_Id, NDT_Command, va_list); +NDD_DLL_API NDT_Status ND_Index_Traverse_I( NDT_Root *, NDT_Index_Id, NDT_Command, ...); +NDD_DLL_API NDT_Status ND_Index_Traverse_C( NDT_Root *, NDT_Index_Id, NDT_Command, ...); + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Command: Commande à exécuter sur chaque noeud traversé */ +/* (I) Data: pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Info_Print_I( FILE *, NDT_Root *, NDT_Index_Id, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset); +NDD_DLL_API NDT_Status ND_Index_Info_Print_C( FILE *, NDT_Root *, NDT_Index_Id, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset); + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'une valeur à une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Value: pointeur sur la valeur à ajouter */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Value_Add_I( NDT_Root *, NDT_Index_Id, void *); +NDD_DLL_API NDT_Status ND_Index_Value_Add_C( NDT_Root *, NDT_Index_Id, void *); + + + +/*------------------------------------------------------------------------------*/ +/* Suppression du premier noeud correspondant à une valeur donnée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Reference_Value : pointeur sur la valeur de référence */ +/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Value_Remove_I( NDT_Root *, NDT_Index_Id, void *); +NDD_DLL_API NDT_Status ND_Index_Value_Remove_C( NDT_Root *, NDT_Index_Id, void *); + + + +/*------------------------------------------------------------------------------*/ +/* Affichage de la valeur de tous les noeuds d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Value_Print_VI( FILE *, NDT_Root *, NDT_Index_Id, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, va_list); +NDD_DLL_API NDT_Status ND_Index_Value_Print_I( FILE *, NDT_Root *, NDT_Index_Id, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, ...); +NDD_DLL_API NDT_Status ND_Index_Value_Print_C( FILE *, NDT_Root *, NDT_Index_Id, NDT_Recursive_Mode, NDT_Recursive_Depth, NDT_Recursive_Offset, ...); + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'un noeud à une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Node: pointeur sur le noeud à ajouter */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Node_Add_I( NDT_Root *, NDT_Index_Id, NDT_Node *); +NDD_DLL_API NDT_Status ND_Index_Node_Add_C( NDT_Root *, NDT_Index_Id, NDT_Node *); + + + +/*------------------------------------------------------------------------------*/ +/* Suppression d'un noeud dans une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Node: pointeur sur le noeud à supprimer de la structure de données */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Node_Remove_I( NDT_Node *); +NDD_DLL_API NDT_Status ND_Index_Node_Remove_C( NDT_Node *); + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du premier noeud d'une structure */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine dont on cherche le premier noeud */ +/* (O) Node : pointeur sur le noeud à récupérer */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Node_First_Get_I( NDT_Node **, NDT_Root *, NDT_Index_Id); +NDD_DLL_API NDT_Status ND_Index_Node_First_Get_C( NDT_Node **, NDT_Root *, NDT_Index_Id); + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du dernier noeud d'une structure */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine dont on cherche le dernier noeud */ +/* (O) Node : pointeur sur le noeud à récupérer */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Node_Last_Get_I( NDT_Node **, NDT_Root *, NDT_Index_Id); +NDD_DLL_API NDT_Status ND_Index_Node_Last_Get_C( NDT_Node **, NDT_Root *, NDT_Index_Id); + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du noeud suivant */ +/*------------------------------------------------------------------------------*/ +/* (I) Node: pointeur sur le noeud dont on cherche le suivant */ +/* (O) Next_Node : pointeur sur le noeud suivant */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Node_Next_Get_I( NDT_Node **, NDT_Node *); +NDD_DLL_API NDT_Status ND_Index_Node_Next_Get_C( NDT_Node **, NDT_Node *); + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du noeud précédant */ +/*------------------------------------------------------------------------------*/ +/* (I) Node: pointeur sur le noeud dont on cherche le précédant */ +/* (O) Prev_Node : pointeur sur le noeud précédant */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Node_Previous_Get_I( NDT_Node **, NDT_Node *); +NDD_DLL_API NDT_Status ND_Index_Node_Previous_Get_C( NDT_Node **, NDT_Node *); + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud à partir d'une valeur */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (O) Node : pointeur sur le noeud à récuperer */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Index_Node_Find_VI( NDT_Node **, NDT_Root *, NDT_Index_Id, void *, va_list); +NDD_DLL_API NDT_Status ND_Index_Node_Find_VC( NDT_Node **, NDT_Root *, NDT_Index_Id, void *, va_list); +NDD_DLL_API NDT_Status ND_Index_Node_Find_I( NDT_Node **, NDT_Root *, NDT_Index_Id, void *, ...); +NDD_DLL_API NDT_Status ND_Index_Node_Find_C( NDT_Node **, NDT_Root *, NDT_Index_Id, void *, ...); + + + +/*------------------------------------------------------------------------------*/ +/* Récupération de la racine d'une structure */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: Adresse du pointeur sur la racine à récupérer */ +/* (I) Node: pointeur sur le noeud dont on cherche la racine */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Node_Root_Get_I( NDT_Root **, NDT_Node *); +NDD_DLL_API NDT_Status ND_Node_Root_Get_C( NDT_Root **, NDT_Node *); + + + +/*------------------------------------------------------------------------------*/ +/* Allocation d'une valeur d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (O) Value : adresse d'un pointeur sur la valeur à allouer */ +/* (I) ... : arguments relatifs à l'allocation de la valeur */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Value_Alloc_I( NDT_Root *, void **, ...); +NDD_DLL_API NDT_Status ND_Value_Alloc_C( NDT_Root *, void **, ...); + + + +/*------------------------------------------------------------------------------*/ +/* Désallocation d'une valeur d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Value: pointeur sur la valeur à désallouer */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Value_Free_I( NDT_Root *, void *); +NDD_DLL_API NDT_Status ND_Value_Free_C( NDT_Root *, void *); + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction Manager dont le nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction manager à exécuter */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Manager_Exec_VI( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +NDD_DLL_API NDT_Status ND_Manager_Exec_VC( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +NDD_DLL_API NDT_Status ND_Manager_Exec_I( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, ...); +NDD_DLL_API NDT_Status ND_Manager_Exec_C( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, ...); + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction d'allocation dont le nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction à exécuter */ +/* (O) Ptr : adresse d'un pointeur sur la zone à allouer */ +/* (I) Size : taille de la zone à allouer */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Allocator_Exec_I( void **, size_t, NDT_Allocator_Name, NDT_Allocator *, void *); +NDD_DLL_API NDT_Status ND_Allocator_Exec_C( void **, size_t, NDT_Allocator_Name, NDT_Allocator *, void *); + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction de désallocation le dont nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction à exécuter */ +/* (I) Function : nom de la fonction à exécuter */ +/* (I) Ptr : adresse de la zone à désallouer */ +/* (I) Data : pointeur de données utiles au désallocateur */ +/*------------------------------------------------------------------------------*/ +NDD_DLL_API NDT_Status ND_Desallocator_Exec_I( void *, NDT_Desallocator_Name, NDT_Desallocator *, void *); +NDD_DLL_API NDT_Status ND_Desallocator_Exec_C( void *, NDT_Desallocator_Name, NDT_Desallocator *, void *); + + + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/src/libnode/src/Makefile b/src/libnode/src/Makefile new file mode 100644 index 0000000..bbd7722 --- /dev/null +++ b/src/libnode/src/Makefile @@ -0,0 +1,42 @@ +#------------------------------------------------------------------------------ +# Local Makefile +#------------------------------------------------------------------------------ +# $Workfile: Makefile $ +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:23 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Var include +#------------------------------------------------------------------------------ + +include ../../Makefile_var.mk + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +TARGET= libnode$(SHLIB_SUFFIX) + +OBJ= libnode.o + +#EXTRA_INC= + +#EXTRA_LIB= + + + +#------------------------------------------------------------------------------ +# Rule include +#------------------------------------------------------------------------------ + +include ../../Makefile_rule.mk diff --git a/src/libnode/src/libnode.c b/src/libnode/src/libnode.c new file mode 100644 index 0000000..3145883 --- /dev/null +++ b/src/libnode/src/libnode.c @@ -0,0 +1,5819 @@ +/*----------------------------------------------------------------------------*/ +/* $Workfile: libnode.c $ */ +/*----------------------------------------------------------------------------*/ +/* $Author: agibert $ */ +/* $Date: 2008/11/12 02:25:23 $ */ +/* $Revision: 1.1 $ */ +/* $Label: $ */ +/*----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------------*/ +/* %RCSfile: libnode.c,v % */ +/*---------------------------------------------------------------------------------*/ +/* %Revision: 2.15 % */ +/* %Name: libnode-2_1_0-1 % */ +/* %Date: 2005/01/19 23:59:41 % */ +/* %Author: agibert % */ +/*---------------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------------*/ +/* This file is part of LibNode */ +/* */ +/* LibNode is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU Lesser General Public Licence as published by */ +/* the Free Software Foundation; either version 2.1 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* LibNode 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 LibNode; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/*---------------------------------------------------------------------------------*/ + + + + + +#define _LIBNODE_C_ + +#include + +#ifdef _LIBVER_SUPPORT +VER_INFO_EXPORT( libnode, "%Revision: 2.15 %", "%Name: libnode-2_1_0-1 %", __FILE__, "%Author: agibert %") +#endif + +char IMRG_ND_WHAT_IDENT[] = "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: libnode.c $"; + + + + + + + +/*------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------*/ +/* Node Manager Template */ +/*------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Default_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "%Revision: 2.15 % %Name: libnode-2_1_0-1 % %Date: 2005/01/19 23:59:41 % %Author: agibert %"; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + /* + case NDT_CMD_SOME_USER_CMD: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_SOME_OTHER_CMD; + break; + } + + ... + */ + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + /* + if( ( *Value_Ptr_Ptr = (void *)malloc( sizeof(void))) == NULL) + { + return(NDS_ERRMEM); + } + else + { + ... + + return( NDS_OK); + } + */ + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_FREE"; + + /* + free( Value_Ptr); + + return( NDS_OK); + */ + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + /* + switch( Index_Id) + { + case 0: + { + int rc; + + + rc = strcmp( Value1_Ptr->..., Value2_Ptr->...); + + if( rc < 0) + { + return(NDS_LOWER); + } + else + { + if( rc > 0) + { + return(NDS_GREATER); + } + else + { + return(NDS_EQUAL); + } + } + } + + case 1: + { + int val1 = atoi(Value1_Ptr->...); + int val2 = atoi(Value2_Ptr->...); + + + if( val1 < val2) + { + return(NDS_LOWER); + } + else + { + if( val1 > val2) + { + return(NDS_GREATER); + } + else + { + return(NDS_EQUAL); + } + } + } + + case 2: + { + ... + } + + default: + { + printf( "Unknown COMP idx (%d) !\n", Index_Id); + return( NDS_KO); + } + } + + return( NDS_OK); + */ + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_ADD"; + + /* + return( NDS_OK); + */ + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + /* + return( NDS_OK); + */ + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + /* + fprintf( Out, "...\n", Value_Ptr->..., ...); + + return( NDS_OK); + */ + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + + + Command_Name = "NDD_CMD_INFO_PRINT"; + + /* + return( NDS_OK); + */ + } + + case NDD_CMD_USER_TRAVERSE: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + + + Command_Name = "NDD_CMD_USER_TRAVERSE"; + + /* + return( NDS_OK); + */ + } + + default: + { + printf( "ND_Default_Manager() called with an undefined command %d\n", Command); + return(NDS_ERRAPI); + } + } + + printf( "ND_Default_Manager() called with command %d (%s)\n", Command, Command_Name); + return(NDS_OK); +} + + + + + + + +/*------------------------------------------------------------------------------*/ +/* OpenStruct Manager */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_OpenStruct_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "%Revision: 2.15 % %Name: libnode-2_1_0-1 % %Date: 2005/01/19 23:59:41 % %Author: agibert %"; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_FREE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case 0: + { + if( Value1_Ptr < Value2_Ptr) + { + return(NDS_LOWER); + } + else + { + if( Value1_Ptr > Value2_Ptr) + { + return(NDS_GREATER); + } + else + { + return(NDS_EQUAL); + } + } + } + + default: + { + printf( "Unknown COMP idx (%d) !\n", Index_Id); + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + return( NDS_OK); + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + + void *Value_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( ND_DataStruct_Info_Print_I( Out, (NDT_Root *)Value_Ptr, Recursive_Mode, --Recursive_Depth, ++Recursive_Offset)); + } + + default: + { + printf( "OpenStruct_Manager() called with an undefined command %d\n", Command); + return( NDS_ERRAPI); + } + } + + printf( "OpenStruct_Manager() called with command %d (%s)\n", Command, Command_Name); + return( NDS_OK); +} + + + + + + + +/*------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------*/ +/* FONCTIONS PUBLIQUES */ +/*------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------*/ + + + + + +/*------------------------------------------------------------------------------*/ +/* Initialisation du contexte de la librairie */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Library_Open_I( int Debug_Mode) +{ + NDG_Base.Debug_Mode = Debug_Mode; + NDG_Base.Open_Status = NDD_TRUE; + + if( Debug_Mode == NDD_TRUE) + { + ND_Library_StdErr_Set_I( stderr); + } + +#if !defined(_WIN32) + if( ( NDG_Base.DL_Ptr = dlopen( NULL, ( RTLD_NOW | RTLD_GLOBAL))) == NULL) + { + sprintf( NDG_Base.Err_String, "Error ND_Library_Open: can't dlopen [%s]", dlerror()); + ND_Error_Print(); + + return( NDS_KO); + } +#endif + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Initialisation du contexte de la librairie */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Library_Open_C( int Debug_Mode) +{ + NDT_Status status; + + + if( NDG_Base.Open_Status != NDD_FALSE) + { + sprintf( NDG_Base.Err_String, "Error ND_Library_Open_C: library is not closed"); + ND_Error_Print(); + + return( NDS_KO); + } + else + { + if( Debug_Mode == NDD_TRUE) + { + if( ( status = ND_DataStruct_Open_I( &(NDG_Base.OpenStruct_Ptr), 1, NDG_Base.OpenStruct_Index_Type, "ND_OpenStruct_Manager", ND_OpenStruct_Manager, NULL, NULL, NULL, NULL, 0, NULL)) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_Library_Open_C: can't open OpenStruct"); + ND_Error_Print(); + + return( NDS_KO); + } + } + } + + return( ND_Library_Open_I( Debug_Mode)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Fermeture du contexte de la librairie */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Library_Close_I( void) +{ + NDT_Symbol *Symbol, *Next_Symbol; + + + /* Désallocation de la table des symboles locale */ + + Symbol = NDG_Base.Symbol_First_Ptr; + + while( Symbol) + { + Next_Symbol = Symbol->Next; + free( Symbol->Name); + free( Symbol); + Symbol = Next_Symbol; + } + + NDG_Base.Symbol_First_Ptr = (NDT_Symbol *)NULL; + +#if !defined(_WIN32) +/* + if( dlclose( NDG_Base.DL_Ptr) != 0) + { + sprintf( NDG_Base.Err_String, "Error ND_Library_Open: can't dlclose [%s]", dlerror()); + ND_Error_Print(); + + return( NDS_KO); + } +*/ +/* dlclose buggy on HPUX... 8^/ */ +#endif + + NDG_Base.Open_Status = NDD_FALSE; + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Fermeture du contexte de la librairie */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Library_Close_C( void) +{ + NDT_Status status; + + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Library_Close_C: library is not opened"); + ND_Error_Print(); + + return( NDS_KO); + } + + if( ( NDG_Base.Debug_Mode == NDD_TRUE) && ( NDG_Base.Err_Stream != NULL)) + { + if( NDG_Base.OpenStruct_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number > 0) + { + sprintf( NDG_Base.Err_String, "Error ND_Library_Close_C: Unclosed DataStruct:"); + ND_Error_Print(); + + if( ( status = ND_DataStruct_Info_Print_I( NDG_Base.Err_Stream, NDG_Base.OpenStruct_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_Library_Close_C: can't print OpenStruct info"); + ND_Error_Print(); + + return( NDS_KO); + } + } + + if( ( status = ND_DataStruct_Close_I( NDG_Base.OpenStruct_Ptr)) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_Library_Close_C: can't close OpenStruct"); + ND_Error_Print(); + + return( NDS_KO); + } + } + + return( ND_Library_Close_I()); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Définition de la sortie standard des messages d'erreur de la librairie */ +/*------------------------------------------------------------------------------*/ +/* (I) Out : flux de sortie de l'affichage des messages d'erreur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Library_StdErr_Set_I( FILE *Out) +{ + NDG_Base.Err_Stream = Out; + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Définition de la sortie standard des messages d'erreur de la librairie */ +/*------------------------------------------------------------------------------*/ +/* (I) Out : flux de sortie de l'affichage des messages d'erreur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Library_StdErr_Set_C( FILE *Out) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Library_StdErr_Set_C: library is not opened"); + ND_Error_Print(); + + return( NDS_KO); + } + + return( ND_Library_StdErr_Set_I( Out)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Création d'une nouvelle structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: adresse d'un pointeur sur la racine de la nouvelle structure */ +/* (I) Type: type de la structure.de données (liste ou arbre binaire) */ +/* (I) Allocator: pointeur vers la fonction d'allocation */ +/* (I) Desallocator: pointeur vers la fonction de désallocation */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/* (I) Own_Value : indique si la structure est propriétaire de ses valeurs */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Open_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Type) +{ + NDT_Status status; + NDT_Node *node_ptr; + + + if( ( status = ND_Index_Clear( Root_Ptr, Index_Id)) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: Index cleaning error"); + ND_Error_Print(); + + return( NDS_KO); + } + + Root_Ptr->Index_Tab[Index_Id].Type = Type & NDD_INDEX_STATUS_RMSK | NDD_INDEX_STATUS_OPENED ; + + Root_Ptr->Index_Open_Count++; + + if( Index_Id != NDD_INDEX_PRIMARY) + { + if( ( status = ND_Index_Node_First_Get_I( &node_ptr, Root_Ptr, NDD_INDEX_PRIMARY)) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: can't get first primary index node"); + ND_Error_Print(); + + return( NDS_KO); + } + + while( node_ptr != NULL) + { + if( ( status = ND_Index_Value_Add_I( Root_Ptr, Index_Id, node_ptr->Value)) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: can't add value"); + ND_Error_Print(); + + return( NDS_KO); + } + + if( ( status = ND_Index_Node_Next_Get_I( &node_ptr, node_ptr)) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: can't get next node"); + ND_Error_Print(); + + return( NDS_KO); + } + } + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Création d'une nouvelle structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: adresse d'un pointeur sur la racine de la nouvelle structure */ +/* (I) Type: type de la structure.de données (liste ou arbre binaire) */ +/* (I) Allocator: pointeur vers la fonction d'allocation */ +/* (I) Desallocator: pointeur vers la fonction de désallocation */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/* (I) Own_Value : indique si la structure est propriétaire de ses valeurs */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Open_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Type) +{ + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Open_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Open_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !ND_INDEX_STATUS_CLOSED_IS( Root_Ptr, Index_Id)) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Open_C: index is not closed"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( ( Root_Ptr->Index_Open_Count == 0) && ( Index_Id != NDD_INDEX_PRIMARY)) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: fist opened index should be the primary"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Open_I( Root_Ptr, Index_Id, Type)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Création d'une nouvelle structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: adresse d'un pointeur sur la racine de la nouvelle structure */ +/* (I) Type: type de la structure.de données (liste ou arbre binaire) */ +/* (I) Allocator: pointeur vers la fonction d'allocation */ +/* (I) Desallocator: pointeur vers la fonction de désallocation */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/* (I) Own_Value : indique si la structure est propriétaire de ses valeurs */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr, + NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, NDT_Desallocator_Name Desallocator_Name, NDT_Desallocator *Desallocator_Ptr, short Own_Value, void *Data) +{ + NDT_Status status; + NDT_Manager_Name Real_Manager_Name; + NDT_Manager *Real_Manager_Ptr; + NDT_Allocator_Name Real_Allocator_Name; + NDT_Allocator *Real_Allocator_Ptr; + NDT_Desallocator_Name Real_Desallocator_Name; + NDT_Desallocator *Real_Desallocator_Ptr; + + + /* Valeurs par défaut des fonctions d'allocation et de désallocation */ + +#if defined(_WIN32) + if( ( Manager_Name != NULL) && ( Manager_Ptr == NULL)) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Open_I: no symbol lookup support, Manager_Ptr shouldn't be NULL"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } +#endif + + if( ( Manager_Name != NULL) || ( Manager_Ptr != NULL)) + { + Real_Manager_Name = Manager_Name; + Real_Manager_Ptr = Manager_Ptr; + } + else + { + Real_Manager_Name = "ND_Default_Manager"; + Real_Manager_Ptr = ND_Default_Manager; + } + +#if defined(_WIN32) + if( ( Allocator_Name != NULL) && ( Allocator_Ptr == NULL)) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Open_I: no symbol lookup support, Allocator_Ptr shouldn't be NULL"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } +#endif + + if( ( Allocator_Name != NULL) || ( Allocator_Ptr != NULL)) + { + Real_Allocator_Name = Allocator_Name; + Real_Allocator_Ptr = Allocator_Ptr; + } + else + { + Real_Allocator_Name = "ND_Default_Allocator"; + Real_Allocator_Ptr = ND_Default_Allocator; + } + +#if defined(_WIN32) + if( ( Desallocator_Name != NULL) && ( Desallocator_Ptr == NULL)) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Open_I: no symbol lookup support, Desallocator_Ptr shouldn't be NULL"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } +#endif + + if( ( Desallocator_Name != NULL) || ( Desallocator_Ptr != NULL)) + { + Real_Desallocator_Name = Desallocator_Name; + Real_Desallocator_Ptr = Desallocator_Ptr; + } + else + { + Real_Desallocator_Name = "ND_Default_Desallocator"; + Real_Desallocator_Ptr = ND_Default_Desallocator; + } + + status = ND_Node_Root_Alloc( Root_Ptr_Ptr, Index_Nb, Type_Ptr, Real_Manager_Name, Real_Manager_Ptr, Real_Allocator_Name, Real_Allocator_Ptr, Real_Desallocator_Name, Real_Desallocator_Ptr, Own_Value, Data); + + if( ND_ERROR( status)) return( status); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Création d'une nouvelle structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: adresse d'un pointeur sur la racine de la nouvelle structure */ +/* (I) Type: type de la structure.de données (liste ou arbre binaire) */ +/* (I) Allocator: pointeur vers la fonction d'allocation */ +/* (I) Desallocator: pointeur vers la fonction de désallocation */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/* (I) Own_Value : indique si la structure est propriétaire de ses valeurs */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Open_C( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr, + NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, NDT_Desallocator_Name Desallocator_Name, NDT_Desallocator *Desallocator_Ptr, short Own_Value, void *Data_Ptr) +{ + NDT_Status status; + + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Open_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( ( status = ND_DataStruct_Open_I( Root_Ptr_Ptr, Index_Nb, Type_Ptr, Manager_Name, Manager_Ptr, Allocator_Name, Allocator_Ptr, Desallocator_Name, Desallocator_Ptr, Own_Value, Data_Ptr)) != NDS_OK) + { + return( status); + } + + if( ( NDG_Base.Debug_Mode == NDD_TRUE) && ( NDG_Base.Open_Status == NDD_TRUE)) + { + if( ( status = ND_DataStruct_Value_Add_I( NDG_Base.OpenStruct_Ptr, (void **)*Root_Ptr_Ptr)) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Open_C: can't add value in OpenStruct"); + ND_Error_Print(); + + return( NDS_KO); + } + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Destruction d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données à détruire */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Close_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + NDT_Status status; + + + if( ( Root_Ptr->Index_Open_Count != 1) && ( Index_Id == NDD_INDEX_PRIMARY)) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Close_I: the primary should be the last closed"); + ND_Error_Print(); + return(NDS_ERRAPI); + } + + status = ND_Index_Flush_I( Root_Ptr, Index_Id); + if( ND_ERROR( status)) return( status); + + Root_Ptr->Index_Tab[ Index_Id].Type = Root_Ptr->Index_Tab[ Index_Id].Type & NDD_INDEX_STATUS_RMSK | NDD_INDEX_STATUS_CLOSED; + + Root_Ptr->Index_Open_Count--; + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Destruction d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données à détruire */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Close_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Close_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Close_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !ND_INDEX_STATUS_OPENED_IS( Root_Ptr, Index_Id)) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Close_C: index is not opened"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Close_I( Root_Ptr, Index_Id)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Destruction d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données à détruire */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Close_I( NDT_Root *Root_Ptr) +{ + NDT_Status status; + + + status = ND_DataStruct_Flush_I( Root_Ptr); + if( ND_ERROR( status)) return( status); + + return( ND_Node_Root_Free( Root_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Destruction d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données à détruire */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Close_C( NDT_Root *Root_Ptr) +{ + NDT_Status status; + + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Close_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if (!Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Close_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( ( status = ND_DataStruct_Close_I( Root_Ptr)) != NDS_OK) + { + return( status); + } + + if( NDG_Base.Debug_Mode == NDD_TRUE) + { + if( ( status = ND_DataStruct_Value_Remove_I( NDG_Base.OpenStruct_Ptr, (void *)Root_Ptr)) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Close_I: can't remove value from OpenStruct"); + ND_Error_Print(); + + return( NDS_KO); + } + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données à détruire */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Flush_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + NDT_Status status; + NDT_Node *Node_Ptr, *Next_Node_Ptr; + + + ND_Index_Node_First_Get_I( &Node_Ptr, Root_Ptr, Index_Id); + + while( Node_Ptr) + { + Next_Node_Ptr = NULL; + ND_Index_Node_Next_Get_I( &Next_Node_Ptr, Node_Ptr); + + if( Index_Id == NDD_INDEX_PRIMARY) + { + status = ND_Manager_Exec_I( Root_Ptr, Index_Id, Node_Ptr, NDD_CMD_VALUE_FREE, Node_Ptr->Value); + if( ND_ERROR( status)) return( status); + } + else + { + status = ND_Manager_Exec_I( Root_Ptr, Index_Id, Node_Ptr, NDD_CMD_VALUE_REMOVE, Node_Ptr->Value); + if( ND_ERROR( status)) return( status); + } + + status = ND_Index_Node_Remove_I( Node_Ptr); + if( ND_ERROR( status)) return( status); + + status = ND_Node_Free( Root_Ptr, Node_Ptr); + if (ND_ERROR( status)) return( status); + + Node_Ptr = Next_Node_Ptr; + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Destruction d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données à détruire */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Flush_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Flush_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Flush_C: structure root is null"); + ND_Error_Print(); + + return(NDS_ERRAPI); + } + + return( ND_Index_Flush_I( Root_Ptr, Index_Id)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Destruction d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données à détruire */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Flush_I( NDT_Root *Root_Ptr) +{ + NDT_Status status; + NDT_Index_Id index_id; + + + for( index_id = ( Root_Ptr->Index_Nb - 1); index_id >= 0 ; index_id--) + { + status = ND_Index_Flush_I( Root_Ptr, index_id); + if( ND_ERROR( status)) return( status); + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Destruction d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: pointeur sur la racine de la structure de données à détruire */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Flush_C( NDT_Root *Root_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Flush_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if (!Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Flush_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return ND_DataStruct_Flush_I( Root_Ptr); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Function de réparation d'une structure : */ +/* - vérifie que tous les noeuds sont correctement liés les uns aux autres */ +/* - corrige les informations statistiques de la racine */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure */ +/* (O) Nb_Detected : pointeur sur le nombre d'erreurs détectées */ +/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrigées */ +/* (I) Out : flux de sortie du rapport */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Check_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Detected_Nb_Ptr, int *Corrected_Nb_Ptr, FILE *Out) +{ + *Detected_Nb_Ptr = 0; + *Corrected_Nb_Ptr = 0; + + + if( ND_INDEX_STATUS_OPENED_IS( Root_Ptr, Index_Id)) + { + if( ND_INDEX_TYPE_LIST_IS( Root_Ptr, Index_Id)) + { + ND_List_Check( Root_Ptr, Index_Id, Detected_Nb_Ptr, Corrected_Nb_Ptr, Out); + } + else if( ND_INDEX_TYPE_TREE_IS( Root_Ptr, Index_Id)) + { + ND_Tree_Check( Root_Ptr, Index_Id, Detected_Nb_Ptr, Corrected_Nb_Ptr, Out); + } + else + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Check_I: unknown structure type (%d) in structure (%p:%d)\n", Root_Ptr->Index_Tab[Index_Id].Type, Root_Ptr, Index_Id); + ND_Error_Print(); + + (*Detected_Nb_Ptr)++; + return( NDS_OK); + } + + /* Affichage du résultat de la procédure de vérification */ + + if( *Detected_Nb_Ptr == 0) + { + fprintf( Out, "No error detected in the node structure (%p:%d)\n", Root_Ptr, Index_Id); + } + else + { + fprintf( Out, "%d/%d error(s) corrected in the node structure (%p:%d)\n", *Corrected_Nb_Ptr, *Detected_Nb_Ptr, Root_Ptr, Index_Id); + } + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Function de réparation d'une structure : */ +/* - vérifie que tous les noeuds sont correctement liés les uns aux autres */ +/* - corrige les informations statistiques de la racine */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure */ +/* (O) Nb_Detected : pointeur sur le nombre d'erreurs détectées */ +/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrigées */ +/* (I) Out : flux de sortie du rapport */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Check_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Nb_Detected_Ptr, int *Nb_Corrected_Ptr, FILE *Out) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Check_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Check_C: structure root is null"); + ND_Error_Print(); + + (*Nb_Detected_Ptr)++; + + return(NDS_ERRAPI); + } + + if( !Out) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Check_C: the stream descriptor is null"); + ND_Error_Print(); + + return(NDS_ERRAPI); + } + + return( ND_Index_Check_I( Root_Ptr, Index_Id, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Function de réparation d'une structure : */ +/* - vérifie que tous les noeuds sont correctement liés les uns aux autres */ +/* - corrige les informations statistiques de la racine */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure */ +/* (O) Nb_Detected : pointeur sur le nombre d'erreurs détectées */ +/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrigées */ +/* (I) Out : flux de sortie du rapport */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Check_I( NDT_Root *Root_Ptr, int *Error_Detected_Nb_Ptr, int *Error_Corrected_Nb_Ptr, FILE *Out) +{ + NDT_Status status; + NDT_Index_Id index_id; + int index_error_detected_nb, index_error_corrected_nb; + + + for( index_id = 0; index_id < Root_Ptr->Index_Nb; index_id++) + { + status = ND_Index_Check_I( Root_Ptr, index_id, &index_error_detected_nb, &index_error_corrected_nb, Out); + if( ND_ERROR(status)) return(status); + + *Error_Detected_Nb_Ptr = *Error_Detected_Nb_Ptr + index_error_detected_nb; + *Error_Corrected_Nb_Ptr = *Error_Corrected_Nb_Ptr + index_error_corrected_nb; + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Function de réparation d'une structure : */ +/* - vérifie que tous les noeuds sont correctement liés les uns aux autres */ +/* - corrige les informations statistiques de la racine */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure */ +/* (O) Nb_Detected : pointeur sur le nombre d'erreurs détectées */ +/* (O) Nb_Corrected : pointeur sur le nombre d'erreurs corrigées */ +/* (I) Out : flux de sortie du rapport */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Check_C( NDT_Root *Root_Ptr, int *Nb_Detected_Ptr, int *Nb_Corrected_Ptr, FILE *Out) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Check_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Check_C: structure root is null"); + ND_Error_Print(); + (*Nb_Detected_Ptr)++; + + return( NDS_ERRAPI); + } + + if( !Out) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Check_C: the stream descriptor is null"); + ND_Error_Print(); + return( NDS_ERRAPI); + } + + return( ND_DataStruct_Check_I( Root_Ptr, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Conversion d'une structure de données d'un type en un autre */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à convertir */ +/* (I) Target_Type : type de structure cible */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Convert_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Target_Type) +{ + NDT_Status rc; + + + if( ND_INDEX_STATUS_OPENED_IS( Root_Ptr, Index_Id)) + { + switch( Root_Ptr->Index_Tab[Index_Id].Type & NDD_INDEX_TYPE_MSK) + { + case NDD_INDEX_TYPE_LIST: + { + + switch( Target_Type & ( NDD_INDEX_TYPE_MSK | NDD_INDEX_SUBTYPE_MSK)) + { + case( NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED): + { + rc = ND_List_Sort( Root_Ptr, Index_Id); + if( ND_ERROR( rc)) return( rc); + + Root_Ptr->Index_Tab[Index_Id].Type = Target_Type; + + return( rc); + } + + case( NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO): + case( NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_LIFO): + { + Root_Ptr->Index_Tab[Index_Id].Type = Target_Type; + + return( NDS_OK); + } + + + case( NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED): + case( NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_UNBALANCED): + { + rc = ND_List_Sort( Root_Ptr, Index_Id); + if( rc != NDS_OK) return( rc); + + rc = ND_Tree_Make( Root_Ptr, Index_Id); + if( ND_ERROR( rc)) return( rc); + + Root_Ptr->Index_Tab[Index_Id].Type = Target_Type; + + return( rc); + } + + default: + { + return( NDS_KO); + } + } + + break; + } + + case NDD_INDEX_TYPE_TREE: + { + switch( Target_Type & ( NDD_INDEX_TYPE_MSK | NDD_INDEX_SUBTYPE_MSK)) + { + case( NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED): + case( NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO): + case( NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_LIFO): + { + + rc = ND_List_Make( Root_Ptr, Index_Id); + if( ND_ERROR( rc)) return( rc); + + Root_Ptr->Index_Tab[Index_Id].Type = Target_Type; + + return( rc); + } + + default: + { + return( NDS_KO); + } + } + + break; + } + + default: + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Convert_I: unknown structure type (%d)", Root_Ptr->Index_Tab[Index_Id].Type); + ND_Error_Print (); + return NDS_ERRAPI; + } + } + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Conversion d'une structure de données d'un type en un autre */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à convertir */ +/* (I) Target_Type : type de structure cible */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Convert_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Target_Type) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Convert_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Convert_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Convert_I( Root_Ptr, Index_Id, Target_Type)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Conversion d'une structure de données d'un type en un autre */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à convertir */ +/* (I) Target_Type : type de structure cible */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Convert_I( NDT_Root *Root_Ptr, NDT_Index_Type *Target_Type_Ptr) +{ + NDT_Status rc; + NDT_Index_Nb idx; + + + for( idx = 0; idx < Root_Ptr->Index_Nb; idx++) + { + rc = ND_Index_Convert_I( Root_Ptr, idx, Target_Type_Ptr[idx]); + if( ND_ERROR(rc)) return rc; + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Conversion d'une structure de données d'un type en un autre */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à convertir */ +/* (I) Target_Type : type de structure cible */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Convert_C( NDT_Root *Root_Ptr, NDT_Index_Type *Target_Type_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Convert_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Convert_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Target_Type_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Convert_C: target type ptr is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_DataStruct_Convert_I( Root_Ptr, Target_Type_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Réorganisation d'une structure de données */ +/* - ordonnancement d'une liste non ordonnée */ +/* - réquilibrage d'un arbre non auto-équilibré */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à supprimer */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Reorg_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + NDT_Status status; + + + if( ND_INDEX_STATUS_OPENED_IS( Root_Ptr, Index_Id)) + { + if( ( status = ND_INDEX_TYPE_LIST_IS( Root_Ptr, Index_Id))) + { + if ( !ND_INDEX_SUBTYPE_SORTED_IS( Root_Ptr, Index_Id)) + { + if( ( status = ND_List_Sort( Root_Ptr, Index_Id)) != NDS_OK) + { + return( status); + } + } + } + else + { + if( ND_INDEX_TYPE_TREE_IS( Root_Ptr, Index_Id)) + { + if( ( status = ND_Tree_Equalize( Root_Ptr, Index_Id)) != NDS_OK) + { + return( status); + } + } + else + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Reorg_C: unknown structure type (%d) in structure (%p:%d)\n", Root_Ptr->Index_Tab[Index_Id].Type, Root_Ptr, Index_Id); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + } + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Réorganisation d'une structure de données */ +/* - ordonnancement d'une liste non ordonnée */ +/* - réquilibrage d'un arbre non auto-équilibré */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à supprimer */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Reorg_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Reorg_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Reorg_C: structure root is null"); + ND_Error_Print (); + + return( NDS_ERRAPI); + } + + return( ND_Index_Reorg_I( Root_Ptr, Index_Id)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Réorganisation d'une structure de données */ +/* - ordonnancement d'une liste non ordonnée */ +/* - réquilibrage d'un arbre non auto-équilibré */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à supprimer */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Reorg_I( NDT_Root *Root_Ptr) +{ + NDT_Status status; + NDT_Index_Id index_id; + + + for( index_id = 0; index_id < Root_Ptr->Index_Nb; index_id++) + { + status = ND_Index_Reorg_I( Root_Ptr, index_id); + if( ND_ERROR( status)) return status; + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Réorganisation d'une structure de données */ +/* - ordonnancement d'une liste non ordonnée */ +/* - réquilibrage d'un arbre non auto-équilibré */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à supprimer */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Reorg_C( NDT_Root *Root_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Reorg_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Reorg_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_DataStruct_Reorg_I( Root_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à parcourir */ +/* (I) Command : Commande à exécuter sur chaque noeud traversé */ +/* (I) Data : pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Traverse_VI( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Command Command, va_list Args) +{ + NDT_Status rc; + NDT_Node *Node_Ptr, *Next_Node_Ptr; + + + ND_Index_Node_First_Get_I( &Node_Ptr, Root_Ptr, Index_Id); + + while( Node_Ptr) + { + Next_Node_Ptr = NULL; + ND_Index_Node_Next_Get_I( &Next_Node_Ptr, Node_Ptr); + + switch (Command) + { + case NDD_CMD_VALUE_REMOVE: + case NDD_CMD_VALUE_FREE: + { + + rc = ND_Manager_Exec_I( Root_Ptr, Index_Id, Node_Ptr, Command, Node_Ptr->Value, Args); + if (ND_ERROR( rc)) return rc; + + rc = ND_Index_Node_Remove_I( Node_Ptr); + if( ND_ERROR( rc)) return rc; + + rc = ND_Node_Free( Root_Ptr, Node_Ptr); + if (ND_ERROR(rc)) return rc; + + break; + } + + default: + { + rc = ND_Manager_Exec_I( Root_Ptr, Index_Id, Node_Ptr, Command, Next_Node_Ptr, Args); + if (ND_ERROR( rc)) return rc; + + break; + } + } + + Node_Ptr = Next_Node_Ptr; + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à parcourir */ +/* (I) Command : Commande à exécuter sur chaque noeud traversé */ +/* (I) Data : pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Traverse_VC( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Command Command, va_list Args) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Traverse_VC: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_VC: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Traverse_VI( Root_Ptr, Index_Id, Command, Args)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à parcourir */ +/* (I) Command : Commande à exécuter sur chaque noeud traversé */ +/* (I) Data : pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Traverse_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Command Command, ...) +{ + NDT_Status status; + va_list args; + NDT_Node *Node_Ptr, *Next_Node_Ptr; + + + va_start( args, Command); + + ND_Index_Node_First_Get_I( &Node_Ptr, Root_Ptr, Index_Id); + + status = NDS_OK; + + while( Node_Ptr) + { + Next_Node_Ptr = NULL; + ND_Index_Node_Next_Get_I( &Next_Node_Ptr, Node_Ptr); + + switch (Command) + { + case NDD_CMD_VALUE_REMOVE: + case NDD_CMD_VALUE_FREE: + { + + status = ND_Manager_Exec_I( Root_Ptr, Index_Id, Node_Ptr, Command, Node_Ptr->Value, args); + if( ND_ERROR( status)) return( status); + + status = ND_Index_Node_Remove_I( Node_Ptr); + if( ND_ERROR( status)) return( status); + + status = ND_Node_Free( Root_Ptr, Node_Ptr); + if (ND_ERROR( status)) return( status); + + break; + } + + default: + { + status = ND_Manager_Exec_I( Root_Ptr, Index_Id, Node_Ptr, Command, Next_Node_Ptr, args); + if( ND_ERROR( status)) return( status); + + break; + } + } + + Node_Ptr = Next_Node_Ptr; + } + + va_end( args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à parcourir */ +/* (I) Command : Commande à exécuter sur chaque noeud traversé */ +/* (I) Data : pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Traverse_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Command Command, ...) +{ + NDT_Status status; + va_list args; + + + va_start( args, Command); + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + status = ND_Index_Traverse_VI( Root_Ptr, Index_Id, Command, args); + + va_end( args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à parcourir */ +/* (I) Command : Commande à exécuter sur chaque noeud traversé */ +/* (I) Data : pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Traverse_VI( NDT_Root *Root_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Status status; + NDT_Index_Id new_index; + NDT_Command new_cmd; + + + status = ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_PRIMARY, NULL, NDD_CMD_INDEX_GET, &new_index, &new_cmd, Command, NULL); + if( ND_ERROR(status)) return( status); + + return( ND_Index_Traverse_VI( Root_Ptr, new_index, new_cmd, Args)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à parcourir */ +/* (I) Command : Commande à exécuter sur chaque noeud traversé */ +/* (I) Data : pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Traverse_VC( NDT_Root *Root_Ptr, NDT_Command Command, va_list Args) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_VC: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_VC: structure root is null"); + ND_Error_Print(); + return( NDS_ERRAPI); + } + + return( ND_DataStruct_Traverse_VI( Root_Ptr, Command, Args)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à parcourir */ +/* (I) Command : Commande à exécuter sur chaque noeud traversé */ +/* (I) Data : pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Traverse_I( NDT_Root *Root_Ptr, NDT_Command Command, ...) +{ + NDT_Status status; + va_list args; + NDT_Index_Id new_index; + NDT_Command new_cmd; + + + va_start( args, Command); + + status = ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_PRIMARY, NULL, NDD_CMD_INDEX_GET, &new_index, &new_cmd, Command, NULL); + if( ND_ERROR( status)) return( status); + + status = ND_Index_Traverse_VI( Root_Ptr, new_index, new_cmd, args); + + va_end( args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ +/* commande sur chacun d'eux */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à parcourir */ +/* (I) Command : Commande à exécuter sur chaque noeud traversé */ +/* (I) Data : pointeur de données utilisateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Traverse_C( NDT_Root *Root_Ptr, NDT_Command Command, ...) +{ + NDT_Status status; + va_list args; + + + va_start( args, Command); + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Taverse_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Traverse_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + status = ND_DataStruct_Traverse_VI( Root_Ptr, Command, args); + + va_end( args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'informations sur une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset) +{ + NDT_Status status; + char offset[255]; + + + if( ND_RECURSIVE_PARENT_IS( Recursive_Mode)) + { + memset( offset, ' ', Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET); + offset[Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET] = '\0'; + + fprintf( Out, "%s Index Id: (%d)\tType: (%#06x) [%s:%s:%s]\tNode Nb: (%d)\tHead: (%s%p)\tTail: (%s%p)\n%s Min Depth: (%d)\tMax Depth: (%d)\tMax Dif: (%d)\tNb Equ: (%d)\tSave: (%s%p)\n\n", + offset, Index_Id, Root_Ptr->Index_Tab[Index_Id].Type, ND_INDEX_STATUS_ASCII_GET( Root_Ptr, Index_Id), ND_INDEX_TYPE_ASCII_GET( Root_Ptr, Index_Id), ND_INDEX_SUBTYPE_ASCII_GET( Root_Ptr, Index_Id), + Root_Ptr->Index_Tab[Index_Id].Node_Number, + NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Head, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Tail, + offset, Root_Ptr->Index_Tab[Index_Id].Min_Depth, Root_Ptr->Index_Tab[Index_Id].Max_Depth, Root_Ptr->Index_Tab[Index_Id].Max_Dif, Root_Ptr->Index_Tab[Index_Id].Nb_Equ, + NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Save); + } + + if( ND_RECURSIVE_CHILD_IS(Recursive_Mode)) + { + status = ND_Index_Traverse_I( Root_Ptr, Index_Id, NDD_CMD_INFO_PRINT, Out, NDD_RECURSIVE_MODE_PARENT_CHILD, Recursive_Depth, Recursive_Offset); + } + else + { + status = NDS_OK; + } + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'informations sur une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Info_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Info_Print_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Info_Print_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Out) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Info_Print_C: the stream descriptor is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Info_Print_I( Out, Root_Ptr, Index_Id, Recursive_Mode, Recursive_Depth, Recursive_Offset)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'informations sur une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset) +{ + NDT_Status status; + NDT_Index_Nb idx; + NDT_Version_Name version_name; + char offset[255]; + + + if( ND_RECURSIVE_PARENT_IS( Recursive_Mode)) + { + memset( offset, ' ', Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET); + offset[Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET] = '\0'; + + status = ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_UNKNOWN, NULL, NDD_CMD_MANAGER_VERSION, &version_name); + if( ND_ERROR( status)) return( status); + + fprintf( Out, "%sRoot: (%s%p)\tIndex Nb: (%d)\tIndex Open Count: (%d)\tManager: (%s%p) [%s]\n%sAllocator: (%s%p) [%s]\tDesallocator: (%s%p) [%s]\tUser: (%s%p)\n%sManager Version: [%s]\n\n", + offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr, Root_Ptr->Index_Nb, Root_Ptr->Index_Open_Count, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Manager_Ptr, Root_Ptr->Manager_Name, + offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Allocator_Ptr, Root_Ptr->Allocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Desallocator_Ptr, Root_Ptr->Desallocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->User_Ptr, + offset, version_name); + } + + if( ND_RECURSIVE_CHILD_IS( Recursive_Mode)) + { + for( idx = NDD_INDEX_PRIMARY; idx < Root_Ptr->Index_Nb; idx++) + { + status = ND_Index_Info_Print_I( Out, Root_Ptr, idx, NDD_RECURSIVE_MODE_PARENT, 0, Recursive_Offset); + if( ND_ERROR( status)) return( status); + } + + return( ND_Index_Info_Print_I( Out, Root_Ptr, NDD_INDEX_PRIMARY, NDD_RECURSIVE_MODE_CHILD, Recursive_Depth, Recursive_Offset)); + } + else + { + return( NDS_OK); + } +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'informations sur une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Info_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Info_Print_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf (NDG_Base.Err_String, "Error ND_DataStruct_Info_Print_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Out) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Info_Print_C: the stream descriptor is null"); + ND_Error_Print(); + return( NDS_ERRAPI); + } + + return( ND_DataStruct_Info_Print_I( Out, Root_Ptr, Recursive_Mode, Recursive_Depth, Recursive_Offset)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'une valeur à une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Value : pointeur sur la valeur à ajouter à la structure de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Value_Add_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr) +{ + NDT_Status status; + + + if( ND_INDEX_TYPE_LIST_IS( Root_Ptr, Index_Id)) + { + status = ND_List_Value_Add( Root_Ptr, Index_Id, Value_Ptr); + if(ND_ERROR( status)) return( status); + } + else if( ND_INDEX_TYPE_TREE_IS( Root_Ptr, Index_Id)) + { + status = ND_Tree_Value_Add( Root_Ptr, Index_Id, Value_Ptr); + if(ND_ERROR( status)) return( status); + } + else + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Add_I: unknown structure type (%d)", Root_Ptr->Index_Tab[Index_Id].Type); + ND_Error_Print(); + return( NDS_ERRAPI); + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'une valeur à une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Value : pointeur sur la valeur à ajouter à la structure de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Value_Add_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Add_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Add_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Value_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Add_C: the value to add is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Value_Add_I( Root_Ptr, Index_Id, Value_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'une valeur à une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Value : pointeur sur la valeur à ajouter à la structure de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Value_Add_I( NDT_Root *Root_Ptr, void *Value_Ptr) +{ + NDT_Status status; + NDT_Index_Id index_id; + + + for( index_id = 0; index_id < Root_Ptr->Index_Nb; index_id++) + { + if( ND_INDEX_STATUS_OPENED_IS( Root_Ptr, index_id)) + { + status = ND_Index_Value_Add_I( Root_Ptr, index_id, Value_Ptr); + if( ND_ERROR( status)) return( status); + } + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'une valeur à une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Value : pointeur sur la valeur à ajouter à la structure de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Value_Add_C( NDT_Root *Root_Ptr, void *Value_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Add_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Add_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Value_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DatatStruct_Value_Add_C: the value to add is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_DataStruct_Value_Add_I( Root_Ptr, Value_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Suppression du premier noeud correspondant à une valeur donnée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Reference_Value : pointeur sur la valeur de référence */ +/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Value_Remove_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr) +{ + NDT_Status status; + NDT_Node *node_ptr; + + + /* Recherche du premier noeud correspondant à la valeur de référence */ + + status = ND_Index_Node_Find_I( &node_ptr, Root_Ptr, Index_Id, Value_Ptr); + if( ND_ERROR( status)) return( status); + + if( !node_ptr) return( NDS_OK); + + /* manager call */ + + status = ND_Manager_Exec_I( Root_Ptr, Index_Id, node_ptr, NDD_CMD_VALUE_REMOVE, Value_Ptr); + if (ND_ERROR( status)) return( status); + + /* Retrait du noeud de la structure */ + + status = ND_Index_Node_Remove_I( node_ptr); + if( ND_ERROR( status)) return( status); + + /* Désallocation du noeud */ + + status = ND_Node_Free( Root_Ptr, node_ptr); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Suppression du premier noeud correspondant à une valeur donnée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Reference_Value : pointeur sur la valeur de référence */ +/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Value_Remove_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Remove_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Remove_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Value_Ptr) + { + sprintf (NDG_Base.Err_String, "Error ND_Index_Value_Remove_C: the value is null"); + ND_Error_Print (); + + return( NDS_ERRAPI); + } + + return( ND_Index_Value_Remove_I( Root_Ptr, Index_Id, Value_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Suppression du premier noeud correspondant à une valeur donnée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Reference_Value : pointeur sur la valeur de référence */ +/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Value_Remove_I( NDT_Root *Root_Ptr, void *Value_Ptr) +{ + NDT_Status status; + NDT_Index_Id index_id; + + + for( index_id = 0; index_id < Root_Ptr->Index_Nb; index_id++) + { + if( ND_INDEX_STATUS_OPENED_IS( Root_Ptr, index_id)) + { + status = ND_Index_Value_Remove_I( Root_Ptr, index_id, Value_Ptr); + if( ND_ERROR( status)) return( status); + } + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Suppression du premier noeud correspondant à une valeur donnée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Reference_Value : pointeur sur la valeur de référence */ +/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Value_Remove_C( NDT_Root *Root_Ptr, void *Value_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Remove_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Remove_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Value_Ptr) + { + sprintf (NDG_Base.Err_String, "Error ND_DataStruct_Value_Remove_C: the value is null"); + ND_Error_Print (); + + return( NDS_ERRAPI); + } + + return( ND_DataStruct_Value_Remove_I( Root_Ptr, Value_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à afficher */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Index_Value_Print_VI( FILE *Out, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, va_list Args) +{ + NDT_Status status; + + + status = ND_Index_Traverse_I( Root_Ptr, Index_Id, NDD_CMD_VALUE_PRINT, Out, Recursive_Mode, Recursive_Depth, Recursive_Offset, Args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à afficher */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Index_Value_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...) +{ + NDT_Status status; + va_list user_args; + + + va_start( user_args, Recursive_Offset); + + status = ND_Index_Traverse_I( Root_Ptr, Index_Id, NDD_CMD_VALUE_PRINT, Out, Recursive_Mode, Recursive_Depth, Recursive_Offset, user_args); + + va_end( user_args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à afficher */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Value_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...) +{ + NDT_Status status; + va_list user_args; + + + va_start( user_args, Recursive_Offset); + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Print_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Print_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Out) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Value_Print_C: the stream descriptor is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + status = ND_Index_Value_Print_VI( Out, Root_Ptr, Index_Id, Recursive_Mode, Recursive_Depth, Recursive_Offset, user_args); + + va_end( user_args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à afficher */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_DataStruct_Value_Print_VI( FILE *Out, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, va_list User_Args) +{ + NDT_Status status; + + status = ND_DataStruct_Traverse_I( Root_Ptr, NDD_CMD_VALUE_PRINT, Out, Recursive_Mode, Recursive_Depth, Recursive_Offset, User_Args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à afficher */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_DataStruct_Value_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...) +{ + NDT_Status status; + va_list user_args; + + + va_start( user_args, Recursive_Offset); + + status = ND_DataStruct_Traverse_I( Root_Ptr, NDD_CMD_VALUE_PRINT, Out, Recursive_Mode, Recursive_Depth, Recursive_Offset, user_args); + + va_end( user_args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affichage d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données à afficher */ +/* (I) Out : flux de sortie */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Value_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...) +{ + NDT_Status status; + va_list user_args; + + + va_start( user_args, Recursive_Offset); + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Print_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Print_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Out) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Print_C: the stream descriptor is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + status = ND_DataStruct_Value_Print_VI( Out, Root_Ptr, Recursive_Mode, Recursive_Depth, Recursive_Offset, user_args); + + va_end( user_args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'un noeud à une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Node : pointeur sur le noeud à ajouter */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Add_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr ) +{ + if( ND_INDEX_TYPE_LIST_IS( Root_Ptr, Index_Id)) return ND_List_Node_Add( Root_Ptr, Index_Id, Node_Ptr); + else if( ND_INDEX_TYPE_TREE_IS( Root_Ptr, Index_Id)) return ND_Tree_Node_Add( Root_Ptr, Index_Id, Node_Ptr); + else + { + sprintf (NDG_Base.Err_String, "Error ND_Index_Node_Add_I: unknown structure type (%d)", Root_Ptr->Index_Tab[Index_Id].Type); + ND_Error_Print (); + return( NDS_ERRAPI); + } + + return( NDS_KO); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'un noeud à une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (I) Node : pointeur sur le noeud à ajouter */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Add_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Add_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf (NDG_Base.Err_String, "Error ND_Index_Node_Add_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Node_Ptr) + { + sprintf (NDG_Base.Err_String, "Error ND_Index_Node_Add_C: the node to add is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Node_Add_I( Root_Ptr, Index_Id, Node_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Suppression d'un noeud dans une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Node: pointeur sur le noeud à supprimer */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Remove_I( NDT_Node *Node_Ptr) +{ + NDT_Root *root_ptr; + NDT_Index_Id index_id; + + + root_ptr = Node_Ptr->Root; + index_id = Node_Ptr->Index; + + if( ND_INDEX_TYPE_LIST_IS( root_ptr, index_id)) return ND_List_Node_Remove( Node_Ptr); + else if( ND_INDEX_TYPE_TREE_IS( root_ptr, index_id)) + { + NDT_Node **tmp_ptr_ptr; + + /* On récupère l'adresse du lien entre le noeud à supprimer et son père */ + + if( Node_Ptr->Parent) + { + /* Cas général */ + + if( Node_Ptr == Node_Ptr->Parent->Left) tmp_ptr_ptr = &(Node_Ptr->Parent->Left); + else tmp_ptr_ptr = &(Node_Ptr->Parent->Right); + } + else + { + /* Cas du noeud racine */ + + tmp_ptr_ptr = NULL; + } + + if( Node_Ptr->Right) + { + NDT_Node *Right_Node_Ptr = Node_Ptr->Right; + NDT_Node *Left_Node_Ptr = Node_Ptr->Left; + NDT_Node *First_Node_Ptr; + + /* + On sauve le fils gauche du noeud à supprimer dans un pointeur de + sauvegarde pour pouvoir le récupérer au cas où la procédure serait + interrompue (recovery). + */ + + root_ptr->Index_Tab[index_id].Save = Left_Node_Ptr; + + /* On remplace le noeud supprimé par son sous-arbre droit */ + + if( !tmp_ptr_ptr) root_ptr->Index_Tab[index_id].Head = root_ptr->Index_Tab[index_id].Tail = Node_Ptr->Right; + else *tmp_ptr_ptr = Node_Ptr->Right; + + Right_Node_Ptr->Parent = Node_Ptr->Parent; + + /* On attache le sous-arbre gauche au premier noeud du sous-arbre droit */ + + if( root_ptr->Index_Tab[index_id].Save) + { + First_Node_Ptr = ND_Tree_Node_First_Recursive_Get(Right_Node_Ptr); + + First_Node_Ptr->Left = root_ptr->Index_Tab[index_id].Save; + + root_ptr->Index_Tab[index_id].Save->Parent = First_Node_Ptr; + + root_ptr->Index_Tab[index_id].Save = NULL; + } + } + else + { + /* On remplace le noeud supprimé par son sous-arbre gauche */ + + if( !tmp_ptr_ptr) root_ptr->Index_Tab[index_id].Head = root_ptr->Index_Tab[index_id].Tail = Node_Ptr->Left; + else *tmp_ptr_ptr = Node_Ptr->Left; + + if( Node_Ptr->Left) Node_Ptr->Left->Parent = Node_Ptr->Parent; + } + + root_ptr->Index_Tab[index_id].Node_Number--; + + /* Pas de mise à jour des informations de profondeur : trop coûteux */ + + Node_Ptr->Root = NULL; + Node_Ptr->Index = NDD_INDEX_UNKNOWN; + Node_Ptr->Left = NULL; + Node_Ptr->Right = NULL; + Node_Ptr->Parent = NULL; + } + else + { + sprintf (NDG_Base.Err_String, "Error ND_Index_Node_Remove_I: unknown structure type (%d)", root_ptr->Index_Tab[index_id].Type); + ND_Error_Print (); + return(NDS_ERRAPI); + } + + return(NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Suppression d'un noeud dans une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Node: pointeur sur le noeud à supprimer */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Remove_C( NDT_Node *Node_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Remove_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Node_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Remove_C: the node to remove is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Node_Remove_I( Node_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du premier noeud d'une structure */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine dont on cherche le premier noeud */ +/* (O) First_Node : adresse du pointeur sur le premier noeud */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_First_Get_I( NDT_Node **First_Node_Ptr_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + *First_Node_Ptr_Ptr = NULL; + + if( ND_INDEX_TYPE_LIST_IS(Root_Ptr, Index_Id)) *First_Node_Ptr_Ptr = (Root_Ptr->Index_Tab)[Index_Id].Head; + + else if( ND_INDEX_TYPE_TREE_IS(Root_Ptr, Index_Id)) *First_Node_Ptr_Ptr = ND_Tree_Node_First_Recursive_Get( Root_Ptr->Index_Tab[Index_Id].Head); + + // if(!*First_Node_Ptr_Ptr) return(NDS_KO); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du premier noeud d'une structure */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine dont on cherche le premier noeud */ +/* (O) First_Node : adresse du pointeur sur le premier noeud */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_First_Get_C( NDT_Node **First_Node_Ptr_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_First_Get_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_First_Get_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Node_First_Get_I( First_Node_Ptr_Ptr, Root_Ptr, Index_Id)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du dernier noeud d'une structure */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine dont on cherche le dernier noeud */ +/* (O) Last_Node : adresse du pointeur sur le premier noeud */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Last_Get_I ( NDT_Node **Last_Node_Ptr_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + *Last_Node_Ptr_Ptr = NULL; + + if( ND_INDEX_TYPE_LIST_IS(Root_Ptr, Index_Id)) *Last_Node_Ptr_Ptr = Root_Ptr->Index_Tab[Index_Id].Tail; + + else if( ND_INDEX_TYPE_TREE_IS(Root_Ptr, Index_Id)) *Last_Node_Ptr_Ptr = ND_Tree_Node_Last_Recursive_Get( Root_Ptr->Index_Tab[Index_Id].Head); + + // if(!*Last_Node_Ptr_Ptr) return(NDS_KO); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du dernier noeud d'une structure */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine dont on cherche le dernier noeud */ +/* (O) Last_Node : adresse du pointeur sur le premier noeud */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Last_Get_C( NDT_Node **Last_Node_Ptr_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Last_Get_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Last_Get_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Node_Last_Get_I( Last_Node_Ptr_Ptr, Root_Ptr, Index_Id)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du noeud suivant */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud dont on cherche le suivant */ +/* (O) Next_Node : adresse du pointeur sur le noeud suivant */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Next_Get_I ( NDT_Node **Next_Node_Ptr_Ptr, NDT_Node *Node_Ptr) +{ + if( ND_INDEX_TYPE_LIST_IS( Node_Ptr->Root, Node_Ptr->Index)) + { + *Next_Node_Ptr_Ptr = Node_Ptr->Right; + } + else if( ND_INDEX_TYPE_TREE_IS( Node_Ptr->Root, Node_Ptr->Index)) + { + if( !Node_Ptr->Right) + { + *Next_Node_Ptr_Ptr = ND_Tree_Parent_Next_Recursive_Get(Node_Ptr); + } + else + { + *Next_Node_Ptr_Ptr = ND_Tree_Node_First_Recursive_Get(Node_Ptr->Right); + } + } + + // if(!*Next_Node_Ptr_Ptr) return(NDS_KO); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du noeud suivant */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud dont on cherche le suivant */ +/* (O) Next_Node : adresse du pointeur sur le noeud suivant */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Next_Get_C( NDT_Node **Next_Node_Ptr_Ptr, NDT_Node *Node_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Next_Get_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Node_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Next_Get_C: node is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Node_Next_Get_I( Next_Node_Ptr_Ptr, Node_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du noeud précédant */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud dont on cherche le précédant */ +/* (O) Prev_Node : adresse du pointeur sur le noeud suivant */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Previous_Get_I( NDT_Node **Prev_Node_Ptr_Ptr, NDT_Node *Node_Ptr) +{ + if( ND_INDEX_TYPE_LIST_IS( Node_Ptr->Root, Node_Ptr->Index)) *Prev_Node_Ptr_Ptr = Node_Ptr->Left; + + if( ND_INDEX_TYPE_TREE_IS( Node_Ptr->Root, Node_Ptr->Index)) + { + if( !Node_Ptr->Left) + { + *Prev_Node_Ptr_Ptr = ND_Tree_Parent_Previous_Recursive_Get( Node_Ptr); + } + else + { + *Prev_Node_Ptr_Ptr = ND_Tree_Node_Last_Recursive_Get( Node_Ptr->Left); + } + } + + // if( !*Prev_Node_Ptr_Ptr) return( NDS_KO); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupération du noeud précédant */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud dont on cherche le précédant */ +/* (O) Prev_Node : adresse du pointeur sur le noeud suivant */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Previous_Get_C( NDT_Node **Prev_Node_Ptr_Ptr, NDT_Node *Node_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Previous_Get_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Node_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Previous_Get_C: node is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Index_Node_Previous_Get_I( Prev_Node_Ptr_Ptr, Node_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud à partir d'une valeur */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (O) Node : adresse du pointeur sur le noeud à récuperer */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Find_VI( NDT_Node **Node_Ptr_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr, va_list Args) +{ + if( ND_INDEX_TYPE_LIST_IS( Root_Ptr, Index_Id)) + { + *Node_Ptr_Ptr = ND_List_Node_Find( Root_Ptr, Index_Id, Value_Ptr, Args); + } + else if ( ND_INDEX_TYPE_TREE_IS( Root_Ptr, Index_Id)) + { + *Node_Ptr_Ptr = ND_Tree_Node_Find( Root_Ptr, Index_Id, Value_Ptr, Args); + } + else + { + sprintf (NDG_Base.Err_String, "Error ND_Index_Node_Find_VI: unknown structure type (%d)", Root_Ptr->Index_Tab[Index_Id].Type); + ND_Error_Print (); + + return( NDS_KO); + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud à partir d'une valeur */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (O) Node : adresse du pointeur sur le noeud à récuperer */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Find_VC( NDT_Node **Node_Ptr_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr, va_list Args) +{ + NDT_Status status; + + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_VC: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_VC: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Value_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_VC: the value to find is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + status = ND_Index_Node_Find_VI( Node_Ptr_Ptr, Root_Ptr, Index_Id, Value_Ptr, Args); + + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud à partir d'une valeur */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (O) Node : adresse du pointeur sur le noeud à récuperer */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Find_I( NDT_Node **Node_Ptr_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr, ...) +{ + va_list user_args; + + + va_start( user_args, Value_Ptr); + + if( ND_INDEX_TYPE_LIST_IS( Root_Ptr, Index_Id)) + { + *Node_Ptr_Ptr = ND_List_Node_Find( Root_Ptr, Index_Id, Value_Ptr, user_args); + } + else if ( ND_INDEX_TYPE_TREE_IS( Root_Ptr, Index_Id)) + { + *Node_Ptr_Ptr = ND_Tree_Node_Find( Root_Ptr, Index_Id, Value_Ptr, user_args); + } + else + { + sprintf (NDG_Base.Err_String, "Error ND_Index_Node_Find_I: unknown structure type (%d)", Root_Ptr->Index_Tab[Index_Id].Type); + ND_Error_Print (); + } + + va_end( user_args); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud à partir d'une valeur */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (O) Node : adresse du pointeur sur le noeud à récuperer */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Node_Find_C( NDT_Node **Node_Ptr_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr, ...) +{ + NDT_Status status; + va_list user_args; + + + va_start( user_args, Value_Ptr); + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Value_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Node_Find_C: the value to find is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + status = ND_Index_Node_Find_VI( Node_Ptr_Ptr, Root_Ptr, Index_Id, Value_Ptr, user_args); + + va_end( user_args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud à partir d'une valeur */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (O) Node : adresse du pointeur sur le noeud à récuperer */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Value_Find_VI( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, void *Ref_Value_Ptr, va_list Args) +{ + NDT_Status status; + NDT_Index_Id new_index; + NDT_Command new_cmd; + NDT_Node *node_ptr; + + + status = ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_PRIMARY, NULL, NDD_CMD_INDEX_GET, &new_index, &new_cmd, NDD_CMD_VALUE_FIND, Ref_Value_Ptr); + if( ND_ERROR(status)) return( status); + + status = ND_Index_Node_Find_VI( &node_ptr, Root_Ptr, new_index, Ref_Value_Ptr, Args); + if( ND_ERROR(status)) return( status); + + if( node_ptr != NULL) + { + *Value_Ptr_Ptr = node_ptr->Value; + } + else + { + *Value_Ptr_Ptr = NULL; + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud à partir d'une valeur */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (O) Node : adresse du pointeur sur le noeud à récuperer */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Value_Find_VC( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, void *Ref_Value_Ptr, va_list Args) +{ + NDT_Status status; + + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_VC: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_VC: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Ref_Value_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_VC: the ref value to find is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + status = ND_DataStruct_Value_Find_VI( Value_Ptr_Ptr, Root_Ptr, Ref_Value_Ptr, Args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud à partir d'une valeur */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (O) Node : adresse du pointeur sur le noeud à récuperer */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Value_Find_I( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, void *Ref_Value_Ptr, ...) +{ + NDT_Status status; + va_list user_args; + NDT_Index_Id new_index; + NDT_Command new_cmd; + NDT_Node *node_ptr; + + + va_start( user_args, Ref_Value_Ptr); + + status = ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_PRIMARY, NULL, NDD_CMD_INDEX_GET, &new_index, &new_cmd, NDD_CMD_VALUE_FIND, Ref_Value_Ptr); + if( ND_ERROR(status)) return( status); + + status = ND_Index_Node_Find_VI( &node_ptr, Root_Ptr, new_index, Ref_Value_Ptr, user_args); + if( ND_ERROR(status)) return( status); + + if( node_ptr != NULL) + { + *Value_Ptr_Ptr = node_ptr->Value; + } + else + { + *Value_Ptr_Ptr = NULL; + } + + va_end( user_args); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud à partir d'une valeur */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (O) Node : adresse du pointeur sur le noeud à récuperer */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_DataStruct_Value_Find_C( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, void *Ref_Value_Ptr, ...) +{ + NDT_Status status; + va_list user_args; + + + va_start( user_args, Ref_Value_Ptr); + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Ref_Value_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Find_C: the ref value to find is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + status = ND_DataStruct_Value_Find_VI( Value_Ptr_Ptr, Root_Ptr, Ref_Value_Ptr, user_args); + + va_end( user_args); + + return(status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupération de la racine d'une structure */ +/*------------------------------------------------------------------------------*/ +/* (O) Root : adresse du pointeur sur la racine à récupérer */ +/* (I) Node : pointeur sur le noeud dont on cherche la racine */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Node_Root_Get_I( NDT_Root **Root_Ptr_Ptr, NDT_Node *Node_Ptr) +{ + *Root_Ptr_Ptr = Node_Ptr->Root; + + return NDS_OK; +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupération de la racine d'une structure */ +/*------------------------------------------------------------------------------*/ +/* (O) Root : adresse du pointeur sur la racine à récupérer */ +/* (I) Node : pointeur sur le noeud dont on cherche la racine */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Node_Root_Get_C( NDT_Root **Root_Ptr_Ptr, NDT_Node *Node_Ptr ) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Node_Root_Get_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Node_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Node_Root_Get_C: node is null"); + ND_Error_Print(); + + return(NDS_ERRAPI); + } + + return( ND_Node_Root_Get_I( Root_Ptr_Ptr, Node_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Allocation d'une valeur d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (O) Value : adresse d'un pointeur sur la valeur à allouer */ +/* (I) ... : arguments relatifs à l'allocation de la valeur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Value_Alloc_I( NDT_Root *Root_Ptr, void **Value_Ptr_Ptr, ...) +{ + NDT_Status rc; + va_list user_args; + + + /* Récupération des arguments pour l'allocation de la valeur */ + + va_start( user_args, Value_Ptr_Ptr); + + /* Appel du manager */ + + rc = ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_UNKNOWN, NULL, NDD_CMD_VALUE_ALLOC, Value_Ptr_Ptr, user_args); + + va_end( user_args); + + return( rc); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Allocation d'une valeur d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure de données */ +/* (O) Value : adresse d'un pointeur sur la valeur à allouer */ +/* (I) ... : arguments relatifs à l'allocation de la valeur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Value_Alloc_C( NDT_Root *Root_Ptr, void **Value_Ptr_Ptr, ...) +{ + NDT_Status rc; + va_list user_args; + + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Value_Alloc_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Value_Alloc_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + /* Récupération des arguments pour l'allocation de la valeur */ + + va_start( user_args, Value_Ptr_Ptr); + + /* Appel du manager */ + + rc = ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_UNKNOWN, NULL, NDD_CMD_VALUE_ALLOC, Value_Ptr_Ptr, user_args); + + va_end( user_args); + + return( rc); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Désallocation d'une valeur d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Value: pointeur sur la valeur à désallouer */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Value_Free_I( NDT_Root *Root_Ptr, void *Value_Ptr) +{ + return( ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_UNKNOWN, NULL, NDD_CMD_VALUE_FREE, Value_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Désallocation d'une valeur d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure de données */ +/* (I) Value: pointeur sur la valeur à désallouer */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Value_Free_C( NDT_Root *Root_Ptr, void *Value_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Value_Free_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Value_Free_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Value_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Value_Free_C: the value to free is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + /* Appel du manager */ + + return( ND_Value_Free_I( Root_Ptr, Value_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction Manager dont le nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction manager à exécuter */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Manager_Exec_VI( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Status status; + NDT_Manager *manager_ptr; + + + if( Root_Ptr->Manager_Ptr != NULL) + { + manager_ptr = Root_Ptr->Manager_Ptr; + } + else + { + if( ND_Symbol_Find( (void **)&manager_ptr, Root_Ptr->Manager_Name) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "ND_Manager_Exec_VI: cant't find manger function"); + ND_Error_Print(); + + return( NDS_KO); + } + } + + status = manager_ptr( Root_Ptr, Index_Id, Node_Ptr, Command, Args); + + return( status); +} + + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction Manager dont le nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction manager à exécuter */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Manager_Exec_VC( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Status status; + + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_VC: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_VC: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr->Manager_Ptr || !*(Root_Ptr->Manager_Ptr)) + { + sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_VC: undefined function name"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + status = ND_Manager_Exec_VI( Root_Ptr, Index_Id, Node_Ptr, Command, Args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction Manager dont le nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction manager à exécuter */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Manager_Exec_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, ...) +{ + NDT_Status status; + va_list args; + NDT_Manager *manager_ptr; + + + va_start( args, Command); + + if( Root_Ptr->Manager_Ptr != NULL) + { + manager_ptr = Root_Ptr->Manager_Ptr; + } + else + { + if( ND_Symbol_Find( (void **)&manager_ptr, Root_Ptr->Manager_Name) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "ND_Manager_Exec_I: cant't find manger function"); + ND_Error_Print(); + + return( NDS_KO); + } + } + + status = manager_ptr( Root_Ptr, Index_Id, Node_Ptr, Command, args); + + va_end( args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction Manager dont le nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction manager à exécuter */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Manager_Exec_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, ...) +{ + NDT_Status status; + va_list args; + + + va_start( args, Command); + + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr) + { + sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_C: structure root is null"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( !Root_Ptr->Manager_Ptr || !*(Root_Ptr->Manager_Ptr)) + { + sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_C: undefined function name"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + status = ND_Manager_Exec_VI( Root_Ptr, Index_Id, Node_Ptr, Command, args); + + va_end( args); + + return( status); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction d'allocation dont le nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction à exécuter */ +/* (O) Ptr : adresse d'un pointeur sur la zone à allouer */ +/* (I) Size : taille de la zone à allouer */ +/* (I) Data : données utilisateur utiles à l'allocateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Allocator_Exec_I( void **Ptr_Ptr, size_t Size, NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, void *Data_Ptr) +{ + NDT_Allocator *allocator_ptr; + + + if( Allocator_Ptr != NULL) + { + allocator_ptr = Allocator_Ptr; + } + else + { + if( ND_Symbol_Find( (void **)&allocator_ptr, Allocator_Name) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_I: cant't find allocator function"); + ND_Error_Print(); + + return( NDS_KO); + } + } + + return allocator_ptr( Ptr_Ptr, Size, Data_Ptr); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction d'allocation dont le nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction à exécuter */ +/* (O) Ptr : adresse d'un pointeur sur la zone à allouer */ +/* (I) Size : taille de la zone à allouer */ +/* (I) Data : données utilisateur utiles à l'allocateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Allocator_Exec_C( void **Ptr_Ptr, size_t Size, NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, void *Data_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Allocator_Exec_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( ( Allocator_Name == NULL) && ( Allocator_Ptr == NULL)) + { + sprintf( NDG_Base.Err_String, "Error ND_Allocator_Exec_C: undefined function name"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Allocator_Exec_I( Ptr_Ptr, Size, Allocator_Name, Allocator_Ptr, Data_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction de désallocation dont nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction à exécuter */ +/* (I) Ptr : adresse de la zone à désallouer */ +/* (I) Data : données utilisateur utiles à l'allocateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Desallocator_Exec_I( void *Ptr, NDT_Desallocator_Name Desallocator_Name, NDT_Desallocator *Desallocator_Ptr, void *Data_Ptr) +{ + NDT_Desallocator *desallocator_ptr; + + + if( Desallocator_Ptr != NULL) + { + desallocator_ptr = Desallocator_Ptr; + } + else + { + if( ND_Symbol_Find( (void **)&desallocator_ptr, Desallocator_Name) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_Manager_Exec_I: cant't find desallocator function"); + ND_Error_Print(); + + return( NDS_KO); + } + } + + return( desallocator_ptr( Ptr, Data_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Exécution d'une fonction de désallocation dont nom est passé en paramètre */ +/*------------------------------------------------------------------------------*/ +/* (I) Function : nom de la fonction à exécuter */ +/* (I) Ptr : adresse de la zone à désallouer */ +/* (I) Data : données utilisateur utiles à l'allocateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Desallocator_Exec_C( void *Ptr, NDT_Desallocator_Name Desallocator_Name, NDT_Desallocator *Desallocator_Ptr, void *Data_Ptr) +{ + if( NDG_Base.Open_Status != NDD_TRUE) + { + sprintf( NDG_Base.Err_String, "Error ND_Desallocator_Exec_C: library is not open"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + if( ( Desallocator_Name == NULL) && ( Desallocator_Ptr == NULL)) + { + sprintf( NDG_Base.Err_String, "Error ND_Desallocator_Exec_C: undefined function name"); + ND_Error_Print(); + + return( NDS_ERRAPI); + } + + return( ND_Desallocator_Exec_I( Ptr, Desallocator_Name, Desallocator_Ptr, Data_Ptr)); +} + + + + + + + +/*------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------*/ +/* PRIVATE FUNCTIONS */ +/*------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------------*/ +/* Symbol Lookup */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Symbol_Find( void **Ptr_Ptr, const char *Symbol_Name) +{ +#if !defined(_WIN32) + NDT_Symbol *Symbol_Ptr; + + + /* Recherche du symbole dans la table des symboles locale */ + + Symbol_Ptr = NDG_Base.Symbol_First_Ptr; + + while( Symbol_Ptr) + { + if( !strcmp( Symbol_Ptr->Name, Symbol_Name)) + { + *Ptr_Ptr = Symbol_Ptr->Ptr; + return( NDS_OK); + } + else + { + Symbol_Ptr = Symbol_Ptr->Next; + } + } + + + /* Si le symbole n'a pas été trouvée dans la table des symboles locale, on l'y ajoute */ + + if( ( *Ptr_Ptr = dlsym( NDG_Base.DL_Ptr, (const char *)Symbol_Name)) == NULL) + { + sprintf( NDG_Base.Err_String, "Error ND_Symbol_Find: unable to find \"%s\"' in symbol table (%s)", Symbol_Name, dlerror()); + ND_Error_Print(); + + return( NDS_KO); + } + + Symbol_Ptr = (NDT_Symbol *)malloc( sizeof( NDT_Symbol)); + if( Symbol_Ptr == NULL) + { + sprintf( NDG_Base.Err_String, "Error ND_Symbol_Find: no more memory"); + ND_Error_Print(); + + return( NDS_KO); + } + else + { + Symbol_Ptr->Name = strdup (Symbol_Name); + Symbol_Ptr->Ptr = *Ptr_Ptr; + Symbol_Ptr->Next = NDG_Base.Symbol_First_Ptr; + + NDG_Base.Symbol_First_Ptr = Symbol_Ptr; + } +#endif + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Allocation d'un noeud */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure */ +/* (O) Node : adresse du pointeur sur le nouveau noeud */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Node_Alloc( NDT_Root *Root_Ptr, NDT_Node **Node_Ptr_Ptr ) +{ + NDT_Status rc; + + + rc = ND_Allocator_Exec_I( (void **)Node_Ptr_Ptr, sizeof(NDT_Node), Root_Ptr->Allocator_Name, Root_Ptr->Allocator_Ptr, Root_Ptr->User_Ptr); + if( ND_ERROR( rc)) return( rc); + + (*Node_Ptr_Ptr)->Root = NULL; + (*Node_Ptr_Ptr)->Index = NDD_INDEX_UNKNOWN; + (*Node_Ptr_Ptr)->Parent = NULL; + (*Node_Ptr_Ptr)->Left = NULL; + (*Node_Ptr_Ptr)->Right = NULL; + (*Node_Ptr_Ptr)->Value = NULL; + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Désallocation d'un noeud */ +/*------------------------------------------------------------------------------*/ +/* (I) Root: pointeur sur la racine de la structure */ +/* (I) Node : pointeur sur le noeud à détruire */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Node_Free( NDT_Root *Root_Ptr, NDT_Node *Node_Ptr) +{ + return( ND_Desallocator_Exec_I( Node_Ptr, Root_Ptr->Desallocator_Name, Root_Ptr->Desallocator_Ptr, Root_Ptr->User_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Création d'une nouvelle structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: adresse d'un pointeur sur la racine de la nouvelle structure */ +/* (I) Type: type de la structure.de données (liste ou arbre binaire) */ +/* (I) Allocator: pointeur vers la fonction d'allocation */ +/* (I) Desallocator: pointeur vers la fonction de désallocation */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/* (I) Own_Value : indique si la structure est propriétaire de ses valeurs */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Index_Clear( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_UNKNOWN; + + Root_Ptr->Index_Tab[Index_Id].Head = NULL; + Root_Ptr->Index_Tab[Index_Id].Tail = NULL; + Root_Ptr->Index_Tab[Index_Id].Save = NULL; + + Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF; + + Root_Ptr->Index_Tab[Index_Id].Node_Number = 0; + Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0; + Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG; + Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0; + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Allocation d'une racine de structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) New_Root: adresse du pointeur sur la nouvelle racine */ +/* (I) Type: type de la structure de données */ +/* (I) Allocator: pointeur vers la fonction d'allocation */ +/* (I) Desallocator: pointeur vers la fonction de désallocation */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, char *Manager_Name, NDT_Manager *Manager_Ptr, char *Allocator_Name, NDT_Allocator *Allocator_Ptr, char *Desallocator_Name, NDT_Desallocator *Desallocator_Ptr, short Own_Value, void *Data_Ptr) +{ + NDT_Status status; + NDT_Index_Id index_id; + + + status = ND_Allocator_Exec_I( (void **)Root_Ptr_Ptr, ( sizeof( NDT_Root) + sizeof(NDT_Index) * (Index_Nb - 1)), Allocator_Name, Allocator_Ptr, Data_Ptr); + if( ND_ERROR(status)) return( status); + + if( strlen(Manager_Name) > NDD_MANAGER_NAME_LEN_MAX) return( NDS_ERRAPI); + strcpy( (*Root_Ptr_Ptr)->Manager_Name, Manager_Name); + (*Root_Ptr_Ptr)->Manager_Ptr = Manager_Ptr; + + if( strlen(Allocator_Name) > NDD_ALLOCATOR_NAME_LEN_MAX) return( NDS_ERRAPI); + strcpy( (*Root_Ptr_Ptr)->Allocator_Name, Allocator_Name); + (*Root_Ptr_Ptr)->Allocator_Ptr = Allocator_Ptr; + + if( strlen(Desallocator_Name) > NDD_DESALLOCATOR_NAME_LEN_MAX) return( NDS_ERRAPI); + strcpy( (*Root_Ptr_Ptr)->Desallocator_Name, Desallocator_Name); + (*Root_Ptr_Ptr)->Desallocator_Ptr = Desallocator_Ptr; + + (*Root_Ptr_Ptr)->Own_Value = Own_Value; + (*Root_Ptr_Ptr)->User_Ptr = Data_Ptr; + + (*Root_Ptr_Ptr)->Index_Nb = Index_Nb; + (*Root_Ptr_Ptr)->Index_Open_Count = 0; + + for( index_id = 0; index_id < Index_Nb; index_id++) + { + if( ( Type_Ptr[index_id] & NDD_INDEX_STATUS_MSK) == NDD_INDEX_STATUS_OPENED) + { + status = ND_Index_Open_I( *Root_Ptr_Ptr, index_id, Type_Ptr[index_id]); + if( ND_ERROR( status)) return( status); + } + else + { + if( ( status = ND_Index_Clear( *Root_Ptr_Ptr, index_id)) != NDS_OK) + { + sprintf( NDG_Base.Err_String, "Error ND_Index_Open_I: Index cleaning error"); + ND_Error_Print(); + return( NDS_KO); + } + + ( *Root_Ptr_Ptr)->Index_Tab[index_id].Type = NDD_INDEX_STATUS_CLOSED; + } + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Désallocation de la racine d'une structure de donnée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine à détruire */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Node_Root_Free( NDT_Root *Root_Ptr) +{ + return( ND_Desallocator_Exec_I( Root_Ptr, Root_Ptr->Desallocator_Name, Root_Ptr->Desallocator_Ptr, Root_Ptr->User_Ptr)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'un noeud à une liste chaînée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la liste */ +/* (I) New_Node : pointeur sur le noeud à ajouter */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_List_Node_Add( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *New_Node_Ptr) +{ + /* Ajout dans une liste triée */ + + if( ND_INDEX_SUBTYPE_SORTED_IS( Root_Ptr, Index_Id)) + { + NDT_Node *node_ptr; + NDT_Status rc; + + + New_Node_Ptr->Root = Root_Ptr; + New_Node_Ptr->Index = Index_Id; + New_Node_Ptr->Parent = New_Node_Ptr->Left = New_Node_Ptr->Right = NULL; + + /* + Une liste triée peut être orientée de 2 manières : + + - FIFO : un noeud sera inséré APRES un noeud de même valeur (par défaut) + - FILO : un noeud sera inséré AVANT un noeud de même valeur + */ + + if( ND_INDEX_SUBTYPE_LIFO_IS( Root_Ptr, Index_Id)) + { + /* Pour une liste triée orientée FILO, on parcourt la liste en sens normal */ + + node_ptr = Root_Ptr->Index_Tab[Index_Id].Head; + + while( node_ptr) + { + rc = ND_Manager_Exec_I( Root_Ptr, Index_Id, node_ptr, NDD_CMD_VALUE_COMP, New_Node_Ptr->Value, node_ptr->Value, NULL); + + if(rc == NDS_GREATER) + node_ptr = node_ptr->Right; + else + { + /* On insère avant le noeud courant si le nouveau noeud est de valeur inférieure ou égale */ + + New_Node_Ptr->Left = node_ptr->Left; + New_Node_Ptr->Right = node_ptr; + + if(!node_ptr->Left) Root_Ptr->Index_Tab[Index_Id].Head = New_Node_Ptr; + else node_ptr->Left->Right = New_Node_Ptr; + + node_ptr->Left = New_Node_Ptr; + node_ptr = NULL; + } + } + + /* Insertion en queue de liste si le noeud n'a pas été inséré */ + + if(!New_Node_Ptr->Left && !New_Node_Ptr->Right) + { + if( !Root_Ptr->Index_Tab[Index_Id].Tail) Root_Ptr->Index_Tab[Index_Id].Head = Root_Ptr->Index_Tab[Index_Id].Tail = New_Node_Ptr; + else + { + Root_Ptr->Index_Tab[Index_Id].Tail->Right = New_Node_Ptr; + New_Node_Ptr->Left = Root_Ptr->Index_Tab[Index_Id].Tail; + Root_Ptr->Index_Tab[Index_Id].Tail = New_Node_Ptr; + } + } + } + else + { + /* Pour une liste triée orientée FIFO, on parcourt la liste dans le sens inverse */ + + node_ptr = Root_Ptr->Index_Tab[Index_Id].Tail; + while( node_ptr) + { + rc = ND_Manager_Exec_I( Root_Ptr, Index_Id, node_ptr, NDD_CMD_VALUE_COMP, New_Node_Ptr->Value, node_ptr->Value, NULL); + + /* On insère après le noeud courant si le nouveau noeud est de valeur strictement supérieure ou égale */ + + if( rc == NDS_LOWER) node_ptr = node_ptr->Left; + else + { + New_Node_Ptr->Left = node_ptr; + New_Node_Ptr->Right = node_ptr->Right; + + if( !node_ptr->Right) Root_Ptr->Index_Tab[Index_Id].Tail = New_Node_Ptr; + else node_ptr->Right->Left = New_Node_Ptr; + + node_ptr->Right = New_Node_Ptr; + node_ptr = NULL; + } + } + + /* Insertion en tête de liste si le noeud n'a pas été inséré */ + + if( !New_Node_Ptr->Left && !New_Node_Ptr->Right) + { + if( !Root_Ptr->Index_Tab[Index_Id].Head) Root_Ptr->Index_Tab[Index_Id].Head = Root_Ptr->Index_Tab[Index_Id].Tail = New_Node_Ptr; + else + { + Root_Ptr->Index_Tab[Index_Id].Head->Left = New_Node_Ptr; + New_Node_Ptr->Right = Root_Ptr->Index_Tab[Index_Id].Head; + Root_Ptr->Index_Tab[Index_Id].Head = New_Node_Ptr; + } + } + } + + Root_Ptr->Index_Tab[Index_Id].Node_Number++; + + return( NDS_OK); + } + else + { + /* FIFO = ajout en queue de liste */ + + if( ND_INDEX_SUBTYPE_FIFO_IS( Root_Ptr, Index_Id)) + { + New_Node_Ptr->Root = Root_Ptr; + New_Node_Ptr->Index = Index_Id; + New_Node_Ptr->Parent = NULL; + New_Node_Ptr->Left = Root_Ptr->Index_Tab[Index_Id].Tail; + New_Node_Ptr->Right = NULL; + + if( !Root_Ptr->Index_Tab[Index_Id].Head) Root_Ptr->Index_Tab[Index_Id].Head = New_Node_Ptr; + else Root_Ptr->Index_Tab[Index_Id].Tail->Right = New_Node_Ptr; + + Root_Ptr->Index_Tab[Index_Id].Tail = New_Node_Ptr; + Root_Ptr->Index_Tab[Index_Id].Node_Number++; + + return( NDS_OK); + } + + /* FILO = ajout en tête de liste */ + + if( ND_INDEX_SUBTYPE_LIFO_IS( Root_Ptr, Index_Id)) + { + + New_Node_Ptr->Root = Root_Ptr; + New_Node_Ptr->Index = Index_Id; + New_Node_Ptr->Parent = NULL; + New_Node_Ptr->Left = NULL; + New_Node_Ptr->Right = Root_Ptr->Index_Tab[Index_Id].Head; + + if( !Root_Ptr->Index_Tab[Index_Id].Tail) Root_Ptr->Index_Tab[Index_Id].Tail = New_Node_Ptr; + else Root_Ptr->Index_Tab[Index_Id].Head->Left = New_Node_Ptr; + + Root_Ptr->Index_Tab[Index_Id].Head = New_Node_Ptr; + Root_Ptr->Index_Tab[Index_Id].Node_Number++; + + return( NDS_OK); + } + } + + printf( "ND_List_Node_Add: unknown list type (%d)\n", Root_Ptr->Index_Tab[Index_Id].Type); + return( NDS_ERRAPI); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'une nouvelle valeur à une liste */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la liste */ +/* (I) Value : pointeur sur la valeur à ajouter */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_List_Value_Add( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr) +{ + NDT_Status rc; + NDT_Node *node_ptr; + + + rc = ND_Node_Alloc( Root_Ptr, &node_ptr); + if( ND_ERROR(rc)) return(rc); + + node_ptr->Value = Value_Ptr; + +// return ND_List_Node_Add( Root, Node); + + rc = ND_List_Node_Add( Root_Ptr, Index_Id, node_ptr); + if( ND_ERROR(rc)) + { + return( rc); + } + else + { + return( ND_Manager_Exec_I( Root_Ptr, Index_Id, node_ptr, NDD_CMD_VALUE_ADD, Value_Ptr, NULL)); + } +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Ajout d'un noeud à un arbre binaire */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'arbre */ +/* (I) Value : pointeur sur la valeur à ajouter */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Tree_Value_Add( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr) +{ + NDT_Status rc; + NDT_Node *node_ptr; + + + rc = ND_Node_Alloc( Root_Ptr, &node_ptr); + if( ND_ERROR(rc)) return(rc); + + node_ptr->Value = Value_Ptr; + +// return ND_Tree_Node_Add( Root, Node); + + rc = ND_Tree_Node_Add( Root_Ptr, Index_Id, node_ptr); + if( ND_ERROR(rc)) + { + return( rc); + } + else + { + return ND_Manager_Exec_I( Root_Ptr, Index_Id, node_ptr, NDD_CMD_VALUE_ADD, Value_Ptr, NULL); + } +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche une valeur dans une liste et retourne le noeud correspondant */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la liste */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +NDT_Node *ND_List_Node_Find( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr, va_list User_Args) +{ + NDT_Node *node_ptr; + NDT_Status rc; + + + node_ptr = Root_Ptr->Index_Tab[Index_Id].Head; + + if( ND_INDEX_SUBTYPE_SORTED_IS( Root_Ptr, Index_Id)) + { + /* Pour les listes triées, la recherche peut être optimisée */ + + while( node_ptr) + { + rc = ND_Manager_Exec_I( Root_Ptr, Index_Id, node_ptr, NDD_CMD_VALUE_COMP, Value_Ptr, node_ptr->Value, User_Args); + + switch( rc) + { + case NDS_EQUAL: + { + return(node_ptr); + } + + case NDS_LOWER: + { + /* Ce n'est pas a peine de continuer car on a déjà dépassé la valeur recherchée */ + + return(NULL); + } + + case NDS_GREATER: + { + node_ptr = node_ptr->Right; + break; + } + } + } + } + else + { + /* Pour les listes non triées, il faut parcourir toute la liste */ + + while( node_ptr && ( ND_Manager_Exec_I( Root_Ptr, Index_Id, node_ptr, NDD_CMD_VALUE_COMP, Value_Ptr, node_ptr->Value, User_Args) != NDS_EQUAL)) + { + node_ptr = node_ptr->Right; + } + } + + return( node_ptr); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud dans un arbre et retourne le pointeur sur le noeud */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'abre */ +/* (I) Value : pointeur sur la valeur à rechercher */ +/* (I) Data : pointeur de données */ +/*------------------------------------------------------------------------------*/ + +/*------------------------------ Recursive Kernel ------------------------------*/ + +NDT_Node *ND_Tree_Node_Recursive_Find( NDT_Node *Node_Ptr, void *Value_Ptr, va_list User_Args) +{ + NDT_Status answer; + + + if( !Node_Ptr) return(NULL); + + answer = ND_Manager_Exec_I( Node_Ptr->Root, Node_Ptr->Index, Node_Ptr, NDD_CMD_VALUE_COMP, Value_Ptr, Node_Ptr->Value, User_Args); + + /* Noeud trouvé */ + + if( answer == NDS_EQUAL) return(Node_Ptr); + + /* Continuation de la recherche par appel récursif */ + + if( answer == NDS_LOWER) return( ND_Tree_Node_Recursive_Find( Node_Ptr->Left, Value_Ptr, User_Args)); + + if( answer == NDS_GREATER) return( ND_Tree_Node_Recursive_Find( Node_Ptr->Right, Value_Ptr, User_Args)); + + return( NULL); +} + + + +/*-------------------------------- main body ---------------------------------*/ + +NDT_Node *ND_Tree_Node_Find( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, void *Value_Ptr, va_list User_Args) +{ + return( ND_Tree_Node_Recursive_Find( Root_Ptr->Index_Tab[Index_Id].Head, Value_Ptr, User_Args)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche du premier noeud parent situé après */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud */ +/*------------------------------------------------------------------------------*/ + +NDT_Node *ND_Tree_Parent_Next_Recursive_Get( NDT_Node *Node_Ptr) +{ + if( !Node_Ptr->Parent) return( NULL); + + if( Node_Ptr == Node_Ptr->Parent->Right) return( ND_Tree_Parent_Next_Recursive_Get( Node_Ptr->Parent)); + + return( Node_Ptr->Parent); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Recherche du premier noeud parent situé avant */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud */ +/*------------------------------------------------------------------------------*/ + +NDT_Node *ND_Tree_Parent_Previous_Recursive_Get( NDT_Node *Node_Ptr) +{ + if( !Node_Ptr->Parent) return( NULL); + + if( Node_Ptr == Node_Ptr->Parent->Left) return( ND_Tree_Parent_Previous_Recursive_Get( Node_Ptr->Parent)); + + return( Node_Ptr->Parent); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Supprime le noeud d'une liste */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud à supprimer */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_List_Node_Remove( NDT_Node *Node_Ptr) +{ + if( !Node_Ptr->Left) Node_Ptr->Root->Index_Tab[Node_Ptr->Index].Head = Node_Ptr->Right; + else Node_Ptr->Left->Right = Node_Ptr->Right; + + if( !Node_Ptr->Right) Node_Ptr->Root->Index_Tab[Node_Ptr->Index].Tail = Node_Ptr->Left; + else Node_Ptr->Right->Left = Node_Ptr->Left; + + Node_Ptr->Root->Index_Tab[Node_Ptr->Index].Node_Number--; + + Node_Ptr->Root = NULL; + Node_Ptr->Index = NDD_INDEX_UNKNOWN; + Node_Ptr->Left = NULL; + Node_Ptr->Right = NULL; + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Conversion d'un arbre en liste chaînée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine du la structure à convertir */ +/*------------------------------------------------------------------------------*/ + +/*------------------------------- Recursive Kernel -----------------------------*/ + +NDT_Status ND_List_Recursive_Make( NDT_Node *Node_Ptr, NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + NDT_Node *right_node_ptr; + + + if( !Node_Ptr) return NDS_OK; + + if( ND_List_Recursive_Make( Node_Ptr->Left, Root_Ptr, Index_Id) != NDS_OK) return NDS_KO; + + right_node_ptr = Node_Ptr->Right; + + if( ND_List_Node_Add( Root_Ptr, Index_Id, Node_Ptr) != NDS_OK) return NDS_KO; + + return( ND_List_Recursive_Make( right_node_ptr, Root_Ptr, Index_Id)); +} + + + +/*--------------------------------- main body --------------------------------*/ + +NDT_Status ND_List_Make( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + NDT_Node *node_ptr; + + + node_ptr = Root_Ptr->Index_Tab[Index_Id].Head; + + Root_Ptr->Index_Tab[Index_Id].Head = NULL; + Root_Ptr->Index_Tab[Index_Id].Tail = NULL; + Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF; + Root_Ptr->Index_Tab[Index_Id].Node_Number = 0; + Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0; + Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG; + Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0; + Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO; + + return( ND_List_Recursive_Make( node_ptr, Root_Ptr, Index_Id)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Conversion d'une structure en arbre binaire */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine du la structure à convertir */ +/* (I) Type : type du futur arbre */ +/*------------------------------------------------------------------------------*/ + +/*------------------------------- Recursive Kernel -----------------------------*/ + +NDT_Node *ND_Tree_Recursive_Make( long Depth, long Node_Number, NDT_Node *Node_Ptr ) +{ + long middle_pos, left_len, right_len, i; + NDT_Node *left_node_ptr, *middle_node_ptr, *right_node_ptr; + + + if( !Node_Ptr) return( NULL); + + /* On calcule le milieu de la liste */ + + middle_pos = Node_Number / 2 + 1; + middle_node_ptr = Node_Ptr; + + for( i = 1; i < middle_pos; i++) middle_node_ptr = middle_node_ptr->Right; + + /* On coupe la liste en deux */ + + if( middle_node_ptr->Left) + { + middle_node_ptr->Left->Right = NULL; + left_node_ptr = Node_Ptr; + left_len = middle_pos - 1; + } + else + { + left_node_ptr = NULL; + left_len = 0; + } + + if( middle_node_ptr->Right) + { + middle_node_ptr->Right->Left = NULL; + right_node_ptr = middle_node_ptr->Right; + right_len = Node_Number - middle_pos; + } + else + { + right_node_ptr = NULL; + right_len = 0; + } + + /* Construction des sous-arbres */ + + middle_node_ptr->Left = ND_Tree_Recursive_Make( Depth + 1, left_len, left_node_ptr); + + middle_node_ptr->Right = ND_Tree_Recursive_Make( Depth + 1, right_len, right_node_ptr); + + if( middle_node_ptr->Left) middle_node_ptr->Left->Parent = middle_node_ptr; + + if( middle_node_ptr->Right) middle_node_ptr->Right->Parent = middle_node_ptr; + + /* Mise à jour des informations statistiques de la structure */ + + middle_node_ptr->Root->Index_Tab[middle_node_ptr->Index].Node_Number++; + + if( !middle_node_ptr->Left && !middle_node_ptr->Right) + { + /* + Si le noeud courant est une feuille, on met éventuellement à jour + les longueurs minimale et maximale des branches de l'arbre + */ + + if( Depth > middle_node_ptr->Root->Index_Tab[middle_node_ptr->Index].Max_Depth) + { + middle_node_ptr->Root->Index_Tab[middle_node_ptr->Index].Max_Depth = Depth; + } + + if( Depth < middle_node_ptr->Root->Index_Tab[middle_node_ptr->Index].Min_Depth) + { + middle_node_ptr->Root->Index_Tab[middle_node_ptr->Index].Min_Depth = Depth; + } + } + + return( middle_node_ptr); +} + + + +/*--------------------------------- main body --------------------------------*/ + +NDT_Status ND_Tree_Make( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id ) +{ + NDT_Status rc; + NDT_Node *node_ptr; + long node_number; + + + if( ND_INDEX_SUBTYPE_SORTED_IS( Root_Ptr, Index_Id)) + { + rc = ND_List_Sort( Root_Ptr, Index_Id); + if( ND_ERROR(rc)) return( rc); + } + + node_ptr = Root_Ptr->Index_Tab[Index_Id].Head; + node_number = Root_Ptr->Index_Tab[Index_Id].Node_Number; + + Root_Ptr->Index_Tab[Index_Id].Head = NULL; + Root_Ptr->Index_Tab[Index_Id].Tail = NULL; + Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF; + Root_Ptr->Index_Tab[Index_Id].Node_Number = 0; + Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0; + Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG; + Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0; + Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED; + + Root_Ptr->Index_Tab[Index_Id].Head = Root_Ptr->Index_Tab[Index_Id].Tail = ND_Tree_Recursive_Make( 1, node_number, node_ptr); + + return( NDS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Equilibrage d'un arbre binaire */ +/*----------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'arbre */ +/*----------------------------------------------------------------------------*/ + +NDT_Status ND_Tree_Equalize( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + NDT_Status rc; + NDT_Index_Type type; + long max_dif, nb_equ; + + + type = Root_Ptr->Index_Tab[Index_Id].Type; + max_dif = Root_Ptr->Index_Tab[Index_Id].Max_Dif; + nb_equ = Root_Ptr->Index_Tab[Index_Id].Nb_Equ; + + rc = ND_List_Make( Root_Ptr, Index_Id); + if( ND_ERROR(rc)) return(rc); + + Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED; + + rc = ND_Tree_Make( Root_Ptr, Index_Id); + if( ND_ERROR(rc)) return(rc); + + Root_Ptr->Index_Tab[Index_Id].Type = type; + Root_Ptr->Index_Tab[Index_Id].Max_Dif = max_dif; + Root_Ptr->Index_Tab[Index_Id].Nb_Equ = nb_equ + 1; + + return( NDS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Retourne la profondeur de la plus grande branche à partir d'un noeud */ +/*----------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud */ +/*----------------------------------------------------------------------------*/ + +long ND_Tree_MaxDepth_Get( NDT_Node *Node_Ptr) +{ + long Max_Left, Max_Right; + + + if( !Node_Ptr) return( 0); + + Max_Left = ND_Tree_MaxDepth_Get( Node_Ptr->Left); + + Max_Right = ND_Tree_MaxDepth_Get( Node_Ptr->Right); + + return( NDD_MAX( Max_Left, Max_Right) + 1 ); +} + +/*----------------------------------------------------------------------------*/ +/* Retourne la profondeur de la plus petite branche à partir d'un noeud */ +/*----------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud */ +/*----------------------------------------------------------------------------*/ + +long ND_Tree_MinDepth_Get( NDT_Node *Node_Ptr) +{ + long Min_Left, Min_Right; + + + if( !Node_Ptr) return( 0); + + Min_Left = ND_Tree_MinDepth_Get( Node_Ptr->Left); + + Min_Right = ND_Tree_MinDepth_Get( Node_Ptr->Right); + + return( NDD_MIN( Min_Left, Min_Right) + 1 ); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Ajoute un noeud à un arbre */ +/*----------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'arbre */ +/* (I) Node : pointeur sur le noeud à ajouter */ +/*----------------------------------------------------------------------------*/ + +/*------------------------------ Recursive Kernel ----------------------------*/ + +void ND_Tree_Node_Recursive_Add( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Parent_Node, NDT_Node **Node_Ptr_Ptr, long Depth, NDT_Node *New_Node_Ptr ) +{ + if( *Node_Ptr_Ptr) + { + /* Appel récursif */ + + if( ND_Manager_Exec_I( Root_Ptr, Index_Id, (*Node_Ptr_Ptr), NDD_CMD_VALUE_COMP, New_Node_Ptr->Value, (*Node_Ptr_Ptr)->Value, NULL) == NDS_LOWER) + ND_Tree_Node_Recursive_Add( Root_Ptr, Index_Id, (*Node_Ptr_Ptr), &((*Node_Ptr_Ptr)->Left), Depth + 1, New_Node_Ptr); + else + ND_Tree_Node_Recursive_Add( Root_Ptr, Index_Id, (*Node_Ptr_Ptr), &((*Node_Ptr_Ptr)->Right), Depth + 1, New_Node_Ptr); + } + else + { + long Max_Depth, Min_Depth; + + /* Rattachement du nouveau noeud à l'arbre */ + + New_Node_Ptr->Root = Root_Ptr; + New_Node_Ptr->Index = Index_Id; + New_Node_Ptr->Parent = Parent_Node; + + *Node_Ptr_Ptr = New_Node_Ptr; + + /* Mise à jour des informations statistiques de la structure */ + + Root_Ptr->Index_Tab[Index_Id].Node_Number++; + + Max_Depth = ND_Tree_MaxDepth_Get( New_Node_Ptr); + + Min_Depth = ND_Tree_MinDepth_Get( New_Node_Ptr); + + if( Max_Depth + Depth - 1 > Root_Ptr->Index_Tab[Index_Id].Max_Depth) Root_Ptr->Index_Tab[Index_Id].Max_Depth = Max_Depth + Depth - 1; + + if( Min_Depth + Depth - 1 < Root_Ptr->Index_Tab[Index_Id].Min_Depth) Root_Ptr->Index_Tab[Index_Id].Min_Depth = Min_Depth + Depth - 1 ; + } +} + + + +/*-------------------------------- main body ---------------------------------*/ + +NDT_Status ND_Tree_Node_Add( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr) +{ + ND_Tree_Node_Recursive_Add( Root_Ptr, Index_Id, NULL, &(Root_Ptr->Index_Tab[Index_Id].Head), 1, Node_Ptr); + + if( ND_INDEX_SUBTYPE_BALANCED_IS( Root_Ptr, Index_Id) && Root_Ptr->Index_Tab[Index_Id].Max_Depth - Root_Ptr->Index_Tab[Index_Id].Min_Depth > Root_Ptr->Index_Tab[Index_Id].Max_Dif) + return( ND_Tree_Equalize( Root_Ptr, Index_Id)); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Ajoute tous les noeud d'une liste à un arbre */ +/*------------------------------------------------------------------------------*/ +/* (I) Tree_Root : pointeur sur la racine de l'arbre */ +/* (I) List_Root : pointeur sur la racine de la liste */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Tree_List_Add( NDT_Root *Tree_Root_Ptr, NDT_Index_Id Tree_Index_Id, NDT_Root *List_Root_Ptr, NDT_Index_Id List_Index_Id) +{ + NDT_Status rc; + NDT_Node *node_ptr; + + + node_ptr = List_Root_Ptr->Index_Tab[List_Index_Id].Head; + + while( node_ptr) + { + rc = ND_Tree_Node_Add( Tree_Root_Ptr, Tree_Index_Id, node_ptr); + if( ND_ERROR( rc)) return( rc); + node_ptr = node_ptr->Right; + } + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Affiche toutes les informations d'une structure de données */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la structure */ +/*------------------------------------------------------------------------------*/ + +/*------------------------------- Recursive Kernel -----------------------------*/ + +void ND_Tree_Recursive_Print( NDT_Node *Node_Ptr, long Depth, FILE *Out) +{ + const int BRANCH_LEN = 4; + + + if( !Node_Ptr) return; + + if( Node_Ptr->Right) + { + ND_Tree_Recursive_Print( Node_Ptr->Right, Depth + 1, Out); + fprintf( Out, "%*s/\n", (int)(Depth * BRANCH_LEN - 1), ""); + } + + fprintf( Out, "%*s (%p) ", (int)((Depth - 1) * BRANCH_LEN), "", Node_Ptr); + +/* Affichage des toutes les informations (noeud et valeur) : + +if( Node->Root) fprintf( Out, "Root=%p ", Node->Root); +if( Node->Parent) fprintf( Out, "Parent=%p ", Node->Parent); +if( Node->Left) fprintf( Out, "Left=%p ", Node->Left); +if( Node->Right) fprintf( Out, "Right=%p ", Node->Right); + +fprintf( Out, "Value=["); +ND_Manager_Exec( Node->Root->Manager, NDD_CMD_PRINT_VALUE, Node->Value, Out); +fprintf( Out, "]\n"); +*/ + +/* Affichage de la valeur seule : */ + + ND_Manager_Exec_I( Node_Ptr->Root, Node_Ptr->Index, Node_Ptr, NDD_CMD_VALUE_PRINT, Node_Ptr->Value, Out, NULL); + fprintf( Out, "\n"); + + if( Node_Ptr->Left) + { + fprintf( Out, "%*s\\\n", (int)( Depth * BRANCH_LEN - 1), ""); + ND_Tree_Recursive_Print( Node_Ptr->Left, Depth + 1, Out); + } +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Function de comparaison de noeuds (pour le quick sort) */ +/*------------------------------------------------------------------------------*/ + +int ND_Node_Compare( void **Node1_Ptr_Ptr, void **Node2_Ptr_Ptr) +{ + NDT_Status rc; + + + rc = ND_Manager_Exec_I( ( ( NDT_Node *)( *Node1_Ptr_Ptr))->Root, ( ( NDT_Node *)(*Node1_Ptr_Ptr))->Index, *Node1_Ptr_Ptr, NDD_CMD_VALUE_COMP, ( (NDT_Node *) (*Node1_Ptr_Ptr))->Value, ( ( NDT_Node *)( *Node2_Ptr_Ptr))->Value, NULL); + + switch( (int)rc) + { + case NDS_EQUAL: return( 0); + case NDS_LOWER: return( -1); + case NDS_GREATER: return( 1); + + default: + { + sprintf( NDG_Base.Err_String, "Error ND_Node_Compare : incorrect return code from the manager: %d", rc); + ND_Error_Print(); + + return( 0); + } + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Ordonne une liste chaînée : */ +/*----------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la liste à trier */ +/*----------------------------------------------------------------------------*/ + +NDT_Status ND_List_Sort( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id) +{ + int i; + NDT_Node *node_ptr; + void **tab; + + + if( Root_Ptr->Index_Tab[Index_Id].Node_Number < 2) return NDS_OK; + + /* Allocation d'un tableau de pointeur de noeuds */ + + tab = (void **)malloc( Root_Ptr->Index_Tab[Index_Id].Node_Number * sizeof( NDT_Node *)); + + /* On remplit le tableau avec les noeuds de la structure à trier */ + + i = 0; + node_ptr = Root_Ptr->Index_Tab[Index_Id].Head; + + while( node_ptr) + { + tab[i] = node_ptr; + node_ptr = node_ptr->Right; + i++; + } + + /* Tri du tableau de pointeurs de noeuds */ + + qsort( (void *)tab, (size_t)( Root_Ptr->Index_Tab[Index_Id].Node_Number), sizeof( NDT_Node *), ( int (*)( const void *, const void *))&ND_Node_Compare); + + /* On met à jour les liens entre les noeuds */ + + for( i = 0; i < Root_Ptr->Index_Tab[Index_Id].Node_Number; i++) + { + node_ptr = (NDT_Node *)tab[i]; + + node_ptr->Left = (i ? (NDT_Node *)( tab[i - 1]) : NULL); + node_ptr->Right = (i != Root_Ptr->Index_Tab[Index_Id].Node_Number - 1 ? (NDT_Node *)( tab[i + 1]) : NULL); + } + + Root_Ptr->Index_Tab[Index_Id].Head = (NDT_Node *)( tab[0]); + Root_Ptr->Index_Tab[Index_Id].Tail = (NDT_Node *)( tab[Root_Ptr->Index_Tab[Index_Id].Node_Number - 1]); + + /* Désallocation du tableau */ + + free(tab); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupère le premier noeud dans un sous-arbre */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud racine du sous-arbre */ +/*------------------------------------------------------------------------------*/ + +NDT_Node *ND_Tree_Node_First_Recursive_Get( NDT_Node *Node_Ptr) +{ + if( !Node_Ptr) return NULL; + + if( !Node_Ptr->Left) return( Node_Ptr); + + return( ND_Tree_Node_First_Recursive_Get( Node_Ptr->Left)); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Récupère le dernier noeud dans un sous-arbre */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud racine du sous-arbre */ +/*------------------------------------------------------------------------------*/ + +NDT_Node *ND_Tree_Node_Last_Recursive_Get( NDT_Node *Node_Ptr) +{ + if( !Node_Ptr) return NULL; + + if( !Node_Ptr->Right) return( Node_Ptr); + + return ND_Tree_Node_Last_Recursive_Get( Node_Ptr->Right); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Redéfinition de la fonction malloc() avec retour de type NDT_Status */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Default_Allocator( void **Ptr_Ptr, size_t Size, void *Data_Ptr) +{ + *Ptr_Ptr = malloc( Size); + + + if( !*Ptr_Ptr) return( NDS_ERRMEM); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Redéfinition de la fonction free() avec retour de type NDT_Status */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Default_Desallocator( void *Ptr, void *Data_Ptr) +{ + if( !Ptr) return( NDS_ERRAPI); + + free( Ptr); + + return( NDS_OK); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Function de vérification d'une liste : */ +/*------------------------------------------------------------------------------*/ + +void ND_List_Check( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Nb_Detected_Ptr, int *Nb_Corrected_Ptr, FILE *Out) +{ + /* On vérifie les liens entre les noeuds */ + + ND_List_Link_Check( Root_Ptr, Index_Id, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out); + + /* On vérifie les valeurs des noeuds */ + + ND_Value_Check( Root_Ptr, Index_Id, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Function de vérification et correction des liens entre noeuds d'une liste */ +/*------------------------------------------------------------------------------*/ + +void ND_List_Link_Check( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Nb_Detected_Ptr, int *Nb_Corrected_Ptr, FILE *Out) +{ + NDT_Node *node_ptr; + int left2right_node_number = 0; + int right2left_node_number = 0; + + + /* + On commence à vérifier si l'on trouve le même nombre de noeuds + en parcourant la liste de droite à gauche, puis de gauche à droite + */ + + node_ptr = Root_Ptr->Index_Tab[Index_Id].Head; + + while( node_ptr) + { + left2right_node_number++; + node_ptr = node_ptr->Right; + } + + node_ptr = Root_Ptr->Index_Tab[Index_Id].Tail; + + while( node_ptr) + { + right2left_node_number++; + node_ptr = node_ptr->Left; + } + + /* Cas où tout est OK */ + + if( left2right_node_number == Root_Ptr->Index_Tab[Index_Id].Node_Number && left2right_node_number == right2left_node_number) return; + + /* Cas où le nombre de noeuds n'a simplement pas été mis à jour au niveau de la racine */ + + if( left2right_node_number == right2left_node_number) + { + Root_Ptr->Index_Tab[Index_Id].Node_Number = left2right_node_number; + fprintf( Out, "\t- number of node has been corrected on structure %p:%d\n", Root_Ptr, Index_Id); + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + return; + } + + /* Cas où le parcours de gauche à droite est plus complet : il manque un lien 'Left' */ + + if( left2right_node_number > right2left_node_number) + { + node_ptr = Root_Ptr->Index_Tab[Index_Id].Head; + + while( node_ptr) + { + if( node_ptr->Right && ( node_ptr->Right->Left != node_ptr)) + { + fprintf( Out, "\t- link 'Left' has been corrected on node %p of structure %p:%d\n", node_ptr->Right, Root_Ptr, Index_Id); + node_ptr->Right->Left = node_ptr; + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + if( !node_ptr->Right && ( node_ptr != Root_Ptr->Index_Tab[Index_Id].Tail)) + { + fprintf( Out, "\t- link 'Tail' has been corrected on structure %p:%d\n", Root_Ptr, Index_Id); + Root_Ptr->Index_Tab[Index_Id].Tail = node_ptr; + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + node_ptr = node_ptr->Right; + } + + if( Root_Ptr->Index_Tab[Index_Id].Node_Number != left2right_node_number) + { + fprintf( Out, "\t- number of node has been corrected on structure %p:%d\n", Root_Ptr, Index_Id); + Root_Ptr->Index_Tab[Index_Id].Node_Number = left2right_node_number; + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + return; + } + + /* Cas où le parcours de droite à gauche est plus complet : il manque un lien 'Right' */ + + if( right2left_node_number > left2right_node_number) + { + node_ptr = Root_Ptr->Index_Tab[Index_Id].Tail; + + while( node_ptr) + { + if( node_ptr->Left && ( node_ptr->Left->Right != node_ptr)) + { + fprintf( Out, "\t- link 'Right' has been corrected on node %p of list %p:%d\n", node_ptr->Left, Root_Ptr, Index_Id); + node_ptr->Left->Right = node_ptr; + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + if( !node_ptr->Left && ( node_ptr != Root_Ptr->Index_Tab[Index_Id].Head)) + { + fprintf( Out, "\t- link 'Head' has been corrected on the structure root %p:%d\n", Root_Ptr, Index_Id); + Root_Ptr->Index_Tab[Index_Id].Head = node_ptr; + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + node_ptr = node_ptr->Left; + } + + if( Root_Ptr->Index_Tab[Index_Id].Node_Number != right2left_node_number) + { + fprintf( Out, "\t- number of node has been corrected on structure %p:%d\n", Root_Ptr, Index_Id); + Root_Ptr->Index_Tab[Index_Id].Node_Number = right2left_node_number; + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + } +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Function de vérification des valeurs des noeuds d'une liste */ +/*------------------------------------------------------------------------------*/ + +void ND_Value_Check( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Nb_Detected, int *Nb_Corrected, FILE *Out) +{ + NDT_Node *node_ptr, *next_node_ptr; + + + /* Chaque noeud sans valeur est purement et simplement supprimé de la liste */ + + ND_Index_Node_First_Get_I( &node_ptr, Root_Ptr, Index_Id); + + while( node_ptr) + { + ND_Index_Node_Next_Get_I( &next_node_ptr, node_ptr); + + if( !node_ptr->Value) + { + fprintf( Out, "\t- node %p has been removed from structure %p:%d because no value is attached to it\n", node_ptr, Root_Ptr, Index_Id); + + ND_Index_Node_Remove_I( node_ptr); + + node_ptr = next_node_ptr; + + (*Nb_Detected)++; + (*Nb_Corrected)++; + } + else if( ND_Address_Check( node_ptr->Value) != NDS_OK) + { + fprintf (Out, "\t- node %p has been removed from structure %p:%d because its value cannot be accessed\n", node_ptr, Root_Ptr, Index_Id); + + ND_Index_Node_Remove_I( node_ptr); + + node_ptr = next_node_ptr; + + (*Nb_Detected)++; + (*Nb_Corrected)++; + } + else ND_Index_Node_Next_Get( &node_ptr, node_ptr); + } +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Function de vérification d'un arbre : */ +/*------------------------------------------------------------------------------*/ + +void ND_Tree_Check( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Nb_Detected_Ptr, int *Nb_Corrected_Ptr, FILE *Out) +{ + /* On vérifie les liens entre les noeuds */ + + ND_Tree_Link_Check( Root_Ptr, Index_Id, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out); + + /* On vérifie les valeurs attachées aux noeuds */ + + ND_Value_Check( Root_Ptr, Index_Id, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out); + + /* On met à jour les informations statistiques de la racine */ + + Root_Ptr->Index_Tab[Index_Id].Max_Depth = ND_Tree_MaxDepth_Get( Root_Ptr->Index_Tab[Index_Id].Head); + Root_Ptr->Index_Tab[Index_Id].Min_Depth = ND_Tree_MaxDepth_Get( Root_Ptr->Index_Tab[Index_Id].Head); +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Function de vérification et correction des liens entre noeuds d'un arbre */ +/*------------------------------------------------------------------------------*/ + +void ND_Tree_Link_Check( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, int *Nb_Detected_Ptr, int *Nb_Corrected_Ptr, FILE *Out) +{ + /* On vérifie les liens 'Parent' et les liens 'Root' de chaque noeud */ + + if( Root_Ptr->Index_Tab[Index_Id].Head) + { + if( Root_Ptr->Index_Tab[Index_Id].Head->Root != Root_Ptr) + { + Root_Ptr->Index_Tab[Index_Id].Head->Root = Root_Ptr; + fprintf( Out, "\t- link 'Root' has been corrected on node %p of structure %p:%d\n", Root_Ptr->Index_Tab[Index_Id].Head, Root_Ptr, Index_Id); + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + ND_Tree_Link_Recursive_Check( Root_Ptr->Index_Tab[Index_Id].Head, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out); + } + + /* + On vérifie si le lien 'Save' contient un noeud (cela signifie + que la procédure ND_Node_Remove n'a pas été jusqu'à son terme). + */ + + if( Root_Ptr->Index_Tab[Index_Id].Save) + { + NDT_Node *node_ptr; + + + /* On attache le noeud contenu dans 'Save' à l'arbre s'il n'existe pas déjà */ + + if( ND_Index_Node_Find_I( &node_ptr, Root_Ptr, Index_Id, Root_Ptr->Index_Tab[Index_Id].Save->Value, NULL) != NDS_OK) + { + ND_Index_Node_Add_I( Root_Ptr, Index_Id, Root_Ptr->Index_Tab[Index_Id].Save); + fprintf( Out, "\t- saved node %p has been restored to structure %p:%d\n", Root_Ptr->Index_Tab[Index_Id].Save, Root_Ptr, Index_Id); + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + Root_Ptr->Index_Tab[Index_Id].Save = NULL; + } +} + + + +/*------------------------------ Recursive Kernel ------------------------------*/ + +void ND_Tree_Link_Recursive_Check( NDT_Node *Node_Ptr, int *Nb_Detected_Ptr, int *Nb_Corrected_Ptr, FILE *Out) +{ + if( Node_Ptr->Left) + { + if( Node_Ptr->Left->Root != Node_Ptr->Root) + { + Node_Ptr->Left->Root = Node_Ptr->Root; + fprintf( Out, "\t- link 'Root' has been corrected on node %p of structure %p:%d\n", Node_Ptr->Left, Node_Ptr->Root, Node_Ptr->Index); + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + if( Node_Ptr->Left->Parent != Node_Ptr) + { + Node_Ptr->Left->Parent = Node_Ptr; + fprintf( Out, "\t- link 'Parent' has been corrected on node %p of structure %p:%d\n", Node_Ptr->Left, Node_Ptr->Root, Node_Ptr->Index); + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + /* Appel récursif */ + + ND_Tree_Link_Recursive_Check( Node_Ptr->Left, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out); + } + + if( Node_Ptr->Right) + { + if( Node_Ptr->Right->Root != Node_Ptr->Root) + { + Node_Ptr->Right->Root = Node_Ptr->Root; + fprintf( Out, "\t- link 'Root' has been corrected on node %p of structure %p:%d\n", Node_Ptr->Right, Node_Ptr->Root, Node_Ptr->Index); + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + if( Node_Ptr->Right->Parent != Node_Ptr) + { + Node_Ptr->Right->Parent = Node_Ptr; + fprintf( Out, "\t- link 'Parent' has been corrected on node %p of structure %p:%d\n", Node_Ptr->Right, Node_Ptr->Root, Node_Ptr->Index); + (*Nb_Detected_Ptr)++; + (*Nb_Corrected_Ptr)++; + } + + /* Appel récursif */ + + ND_Tree_Link_Recursive_Check( Node_Ptr->Right, Nb_Detected_Ptr, Nb_Corrected_Ptr, Out); + } +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Target address access try */ +/*------------------------------------------------------------------------------*/ + +NDT_Status ND_Address_Check( void *Address) +{ +#if !defined(_WIN32) + NDT_Status status; + int rc; + int test; + struct sigaction act = {0}, oact_bus, oact_segv; + + act.sa_handler = ND_Signal_Trap; + + NDG_Base.Sig_Trapped = 0; + + + + /* Trap SIGBUS and SIGSEGV */ + + if( ( rc = sigaction( SIGBUS, &act, &oact_bus)) != 0) + { + sprintf( NDG_Base.Err_String, "Error ND_Address_Check: sigaction (Add SIGBUS Hdl) rc: %d errno: %d", rc, errno); + ND_Error_Print(); + + return( NDS_KO); + } + + if( ( rc = sigaction( SIGSEGV, &act, &oact_segv)) != 0) + { + sprintf( NDG_Base.Err_String, "Error ND_Address_Check: sigaction (Add SIGSEGV Hdl) rc: %d errno: %d", rc, errno); + ND_Error_Print(); + + return( NDS_KO); + } + + + + /* Target address access try */ + + if( sigsetjmp( NDG_Base.SigLongJmp_Env, 1) == 0 ) + { + test = *( (int *)Address); + + status = NDS_OK; + } + else + { + status = NDS_KO; + } + + + + /* Untrap SIGBUS and SIGSEGV */ + + if( ( rc = sigaction( SIGBUS, &oact_bus, &act)) != 0) + { + sprintf( NDG_Base.Err_String, "Error ND_Address_Check: sigaction (Remove SIGBUS Hdl) rc: %d errno: %d", rc, errno); + ND_Error_Print(); + + return( NDS_KO); + } + + if( ( rc = sigaction( SIGSEGV, &oact_segv, &act)) != 0) + { + sprintf( NDG_Base.Err_String, "Error ND_Address_Check: sigaction (Remove SIGSEGV Hdl) rc: %d errno: %d", rc, errno); + ND_Error_Print(); + + return( NDS_KO); + } + + return( status); +#else + NDT_Status status; + int test; + void (__cdecl *old_sigsegv_sighandler)(int); + + + NDG_Base.Sig_Trapped = 0; + + + + /* Trap SIGSEGV */ + + if( ( old_sigsegv_sighandler = signal( SIGSEGV, ND_Signal_Trap)) == SIG_ERR) + { + sprintf( NDG_Base.Err_String, "Error ND_Address_Check: signal (Add SIGSEGV Hdl) errno: %d", errno); + ND_Error_Print(); + + return( NDS_KO); + } + + + + /* Target address access try */ + + if( setjmp( NDG_Base.SigLongJmp_Env) == 0 ) + { + test = *( (int *)Address); + + status = NDS_OK; + } + else + { + status = NDS_KO; + } + + + + /* Untrap SIGSEGV */ + + if( ( old_sigsegv_sighandler = signal( SIGSEGV, old_sigsegv_sighandler)) == SIG_ERR) + { + sprintf( NDG_Base.Err_String, "Error ND_Address_Check: signal (Remove SIGSEGV Hdl) errno: %d", errno); + ND_Error_Print(); + + return( NDS_KO); + } + + return( status); +#endif +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Trap d'un signal */ +/*------------------------------------------------------------------------------*/ + +void ND_Signal_Trap( int Sig_Num) +{ + NDG_Base.Sig_Trapped = Sig_Num; + +#if !defined(_WIN32) + siglongjmp( NDG_Base.SigLongJmp_Env, 1); +#else + longjmp( NDG_Base.SigLongJmp_Env, 1); +#endif +} + + + + + +/*------------------------------------------------------------------------------*/ +/* Routine d'affichage d'un message d'erreur */ +/*------------------------------------------------------------------------------*/ + +void ND_Error_Print( void) +{ + if( NDG_Base.Err_Stream) fprintf( ( NDG_Base.Err_Stream == (FILE *)-1 ) ? stderr : NDG_Base.Err_Stream, "%s\n", NDG_Base.Err_String); +} diff --git a/src/libnode/src/libnode.h b/src/libnode/src/libnode.h new file mode 100644 index 0000000..6793135 --- /dev/null +++ b/src/libnode/src/libnode.h @@ -0,0 +1,356 @@ +/*----------------------------------------------------------------------------*/ +/* $Workfile: libnode.h $ */ +/*----------------------------------------------------------------------------*/ +/* $Author: agibert $ */ +/* $Date: 2008/11/12 02:25:23 $ */ +/* $Revision: 1.1 $ */ +/* $Label: $ */ +/*----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------------*/ +/* %RCSfile: libnode.h,v % */ +/*---------------------------------------------------------------------------------*/ +/* %Revision: 2.9 % */ +/* %Name: libnode-2_1_0-1 % */ +/* %Date: 2005/01/19 23:59:42 % */ +/* %Author: agibert % */ +/*---------------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------------*/ +/* This file is part of LibNode */ +/* */ +/* LibNode is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU Lesser General Public Licence as published by */ +/* the Free Software Foundation; either version 2.1 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* LibNode 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 LibNode; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/*---------------------------------------------------------------------------------*/ + + + + + +#include +#include +#include +#include +#include +#include +#include + + + +/* Utilisation des API de la LIBNODE sans vérification des arguments */ + +#define ND_MODE 1 + +#include + + + + + + + +#ifdef __linux +# define NDD_PRINTF_PTR_PREFIX "" +#else +# define NDD_PRINTF_PTR_PREFIX "0x" +#endif + + + + + +#define NDD_HUGE_LONG ( long) 0xFFFFFFL + + + +/* Table des symboles locale */ + +struct NDT_Symbol; + +typedef struct NDT_Symbol +{ + void *Ptr; + char *Name; + struct NDT_Symbol *Next; +} NDT_Symbol; + + + +/* LibNode Global Base Structure */ + +typedef struct NDT_Base +{ + int Open_Status; + int Debug_Mode; + char Err_String[512]; + FILE *Err_Stream; + int Sig_Trapped; +#if !defined(_WIN32) + sigjmp_buf SigLongJmp_Env; +#else + jmp_buf SigLongJmp_Env; +#endif + NDT_Symbol *Symbol_First_Ptr; + void *DL_Ptr; + NDT_Index_Type OpenStruct_Index_Type[1]; + NDT_Root *OpenStruct_Ptr; +} NDT_Base; + +NDT_Base NDG_Base = +{ + NDD_FALSE, + NDD_TRUE, + "", + (FILE *) -1, + 0, + {0}, + (NDT_Symbol *) NULL, + NULL, + { NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO}, + (NDT_Root *) NULL +}; + + + + + +/*------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------*/ +/* Fonctions et procédures privées de la librairie (moyen niveau) */ +/*------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------------*/ +/* Manager par défaut */ +/*------------------------------------------------------------------------------*/ +/* (I) va_list Arguments : Liste d'arguments contextuels */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Default_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); + +/*------------------------------------------------------------------------------*/ +/* OpenStruct Manager */ +/*------------------------------------------------------------------------------*/ +/* (I) va_list Arguments : Liste d'arguments contextuels */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_OpenStruct_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); + +/*------------------------------------------------------------------------------*/ +/* Redéfinition de la fonction malloc() avec retour de type NDT_Status */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Default_Allocator( void **, size_t, void *); + +/*------------------------------------------------------------------------------*/ +/* Redéfinition de la fonction free() avec retour de type NDT_Status */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Default_Desallocator( void *, void *); + +/*------------------------------------------------------------------------------*/ +/* Création d'un noeud */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : adresse de la racine pour laquelle on crée un noeud */ +/* (O) New_Node : adresse du pointeur sur le nouveau noeud */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Node_Alloc( NDT_Root * Root, NDT_Node ** New_Node); + +/*------------------------------------------------------------------------------*/ +/* Destruction d'un noeud */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : adresse de la racine dans laquelle on détruit un noeud */ +/* (I) Node : pointeur sur le noeud à détruire */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Node_Free( NDT_Root *, NDT_Node *); + +/*------------------------------------------------------------------------------*/ +/* Création d'une nouvelle structure de données */ +/*------------------------------------------------------------------------------*/ +/* (O) Root: adresse d'un pointeur sur la racine de la nouvelle structure */ +/* (I) Type: type de la structure.de données (liste ou arbre binaire) */ +/* (I) Allocator: pointeur vers la fonction d'allocation */ +/* (I) Desallocator: pointeur vers la fonction de désallocation */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/* (I) Own_Value : indique si la structure est propriétaire de ses valeurs */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Index_Clear( NDT_Root *, NDT_Index_Id); + +/*------------------------------------------------------------------------------*/ +/* Création de la racine d'une structure de données quelconque */ +/*------------------------------------------------------------------------------*/ +/* (O) New_Root : adresse du pointeur sur la nouvelle racine */ +/* (I) Type : type de la structure de données */ +/* (I) Allocater : pointeur vers la fonction d'allocation */ +/* (I) Desallocater : pointeur vers la fonction de désallocation */ +/* (I) Data : pointeur de données utiles à l'allocateur */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Node_Root_Alloc( NDT_Root **, NDT_Index_Nb, NDT_Index_Type[], char *, NDT_Manager *, char *, NDT_Allocator *, char *, NDT_Desallocator *, short, void *); + +/*------------------------------------------------------------------------------*/ +/* Destruction d'une racine */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine à détruire */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Node_Root_Free( NDT_Root *); + +/*------------------------------------------------------------------------------*/ +/* Ajout d'un noeud à une liste chaînée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la liste */ +/* (I) New_Node : pointeur sur le noeud à ajouter */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_List_Node_Add( NDT_Root *, NDT_Index_Id, NDT_Node *); + +/*------------------------------------------------------------------------------*/ +/* Ajout d'une nouvelle valeur à une liste */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la liste */ +/* (I) Value : pointeur sur la valeur à ajouter */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_List_Value_Add( NDT_Root *, NDT_Index_Id, void *); + +/*------------------------------------------------------------------------------*/ +/* Ajout d'un noeud à un arbre binaire */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'arbre */ +/* (I) Value : pointeur sur la valeur à ajouter */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Tree_Value_Add( NDT_Root *, NDT_Index_Id, void *); + +/*------------------------------------------------------------------------------*/ +/* Supprime le noeud d'une liste */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud à supprimer */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_List_Node_Remove( NDT_Node *); + +/*------------------------------------------------------------------------------*/ +/* Conversion d'une structure en liste chaînée */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine du la structure à convertir */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_List_Make( NDT_Root *, NDT_Index_Id); + +/*------------------------------------------------------------------------------*/ +/* Recherche une valeur dans une liste et retourne le noeud correspondant */ +/*------------------------------------------------------------------------------*/ +NDT_Node *ND_List_Node_Find( NDT_Root *, NDT_Index_Id, void *, va_list); + +/*------------------------------------------------------------------------------*/ +/* Recherche un noeud dans un arbre et retourne le pointeur sur le noeud */ +/*------------------------------------------------------------------------------*/ +NDT_Node *ND_Tree_Node_Find( NDT_Root *, NDT_Index_Id, void *, va_list); + +/*------------------------------------------------------------------------------*/ +/* Conversion d'une structure en arbre binaire */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine du la structure à convertir */ +/* (I) Type : type du futur arbre */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Tree_Make( NDT_Root *, NDT_Index_Id); + +/*------------------------------------------------------------------------------*/ +/* Equilibrage d'un arbre */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'arbre */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Tree_Equalize( NDT_Root *, NDT_Index_Id); + +/*------------------------------------------------------------------------------*/ +/* Retourne la profondeur de la plus grande branche à partir d'un noeud */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud */ +/*------------------------------------------------------------------------------*/ +long ND_Tree_MaxDepth_Get( NDT_Node *); + +/*------------------------------------------------------------------------------*/ +/* Retourne la profondeur de la plus petite branche à partir d'un noeud */ +/*------------------------------------------------------------------------------*/ +/* (I) Node : pointeur sur le noeud */ +/*------------------------------------------------------------------------------*/ +long ND_Tree_MinDepth_Get( NDT_Node *); + +/*------------------------------------------------------------------------------*/ +/* Ajout d'un noeud à un arbre binaire */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de l'arbre */ +/* (I) Node : pointeur sur le noeud à ajouter */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Tree_Node_Add( NDT_Root *, NDT_Index_Id, NDT_Node *); + +/*------------------------------------------------------------------------------*/ +/* Ajoute tous les noeud d'une liste à un arbre */ +/*------------------------------------------------------------------------------*/ +/* (I) Tree_Root : pointeur sur la racine de l'arbre */ +/* (I) List_Root : pointeur sur la racine de la liste */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_Tree_List_Add( NDT_Root *, NDT_Index_Id, NDT_Root *, NDT_Index_Id); + +/*------------------------------------------------------------------------------*/ +/* Fonction de comparaison de noeuds (pour le quick sort) */ +/*------------------------------------------------------------------------------*/ +int ND_Node_Compare( void **, void **); + +/*------------------------------------------------------------------------------*/ +/* Ordonne une liste chaînée selon l'algorithme du tri à bulle */ +/*------------------------------------------------------------------------------*/ +/* (I) Root : pointeur sur la racine de la liste à trier */ +/*------------------------------------------------------------------------------*/ +NDT_Status ND_List_Sort( NDT_Root *, NDT_Index_Id); + + + + + + +/*------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------*/ +/* PRIVATE FUNCTIONS */ +/*------------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------------*/ + +void ND_List_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *); + +void ND_List_Link_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *); + +void ND_Value_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *); + +void ND_Tree_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *); + +void ND_Tree_Link_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *); + +NDT_Status ND_List_Recursive_Make( NDT_Node *, NDT_Root *, NDT_Index_Id); + +NDT_Node *ND_Tree_Recursive_Make( long, long, NDT_Node *); + +void ND_Tree_Node_Recursive_Add( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Node **, long , NDT_Node *); + +NDT_Node *ND_Tree_Node_First_Recursive_Get( NDT_Node *); + +NDT_Node *ND_Tree_Node_Last_Recursive_Get( NDT_Node *); + +NDT_Node *ND_Tree_Node_Recursive_Find( NDT_Node *, void *, va_list); + +NDT_Node *ND_Tree_Parent_Next_Recursive_Get( NDT_Node *); + +NDT_Node *ND_Tree_Parent_Previous_Recursive_Get( NDT_Node *); + +void ND_Tree_Recursive_Print( NDT_Node *, long, FILE *); + +void ND_Tree_Link_Recursive_Check( NDT_Node *, int *, int *, FILE *); + +NDT_Status ND_Symbol_Find( void **, const char *); + +void ND_Error_Print( void); + +void ND_Signal_Trap( int); + +NDT_Status ND_Address_Check( void *); diff --git a/src/libnode/util/ndbench.c b/src/libnode/util/ndbench.c new file mode 100644 index 0000000..6e232a0 --- /dev/null +++ b/src/libnode/util/ndbench.c @@ -0,0 +1,1602 @@ +/*---------------------------------------------------------------------------------*/ +/* %RCSfile: ndbench.c,v % */ +/*---------------------------------------------------------------------------------*/ +/* %Revision: 2.9 % */ +/* %Name: libnode-2_1_0-1 % */ +/* %Date: 2005/01/20 00:07:27 % */ +/* %Author: agibert % */ +/*---------------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------------*/ +/* This file is part of LibNode */ +/* */ +/* LibNode is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public Licence as published by */ +/* the Free Software Foundation; either version 2 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* LibNode 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 General Public License */ +/* along with LibNode; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/*---------------------------------------------------------------------------------*/ + + + + + +/*---------------------------------------------------------------------------------*/ +/* Includes */ +/*---------------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include + + + +#ifdef _WIN32 +# include +#else +# include +#endif + +#ifdef _LIBVER_SUPPORT +# include +#endif + + + + + +/*---------------------------------------------------------------------------------*/ +/* Defines */ +/*---------------------------------------------------------------------------------*/ + +#ifdef _LIBVER_SUPPORT +VER_INFO_EXPORT( ndbench, "%Revision: 2.9 %", "%Name: libnode-2_1_0-1 %", __FILE__, "%Author: agibert %"); +# define USAGE "Usage : %s [ --help | --version [-v] | --batch_run ]\n" +#else +# define USAGE "Usage : %s [ --help | --batch_run ]\n" +#endif + +#include + + + +#define QUIT 0 +#define LIB_OPEN 1 +#define LIB_CLOSE 2 +#define DS_OPEN 3 +#define DS_CLOSE 4 +#define DS_FLUSH 5 +#define DS_CHECK 6 +#define DS_REORG 7 +#define DS_INFO_PRINT 8 +#define DS_VALUE_ADD 9 +#define DS_VALUE_REMOVE 10 +#define DS_VALUE_PRINT 11 +#define DS_VALUE_FIND 12 +#define INDEX_LIST_OPEN 13 +#define INDEX_TREE_OPEN 14 +#define INDEX_CLOSE 15 +#define INDEX_FLUSH 16 +#define INDEX_CHECK 17 +#define INDEX_LIST_SUBTYPE_SET 18 +#define INDEX_LIST_TO_TREE 19 +#define INDEX_TREE_SUBTYPE_SET 20 +#define INDEX_TREE_TO_LIST 21 +#define INDEX_REORG 22 +#define INDEX_INFO_PRINT 23 +#define INDEX_VALUE_PRINT 24 +#define INDEX_VALUE_BREAK 25 +#define INDEX_NODE_BREAK 26 +#define BATCH_RUN 27 + +#define COMMAND_NB 28 + +#define INDEX_NB 32 + + + +#define DS_STATE_UNKNOWN 0 +#define DS_STATE_OPENED 1 +#define DS_STATE_CLOSED 2 + + + +#define ARG_SIZE ( 32 + 1) + + + +#define BUF_LEN 99 +#define BUF_SIZE (BUF_LEN + 1) + + + + + +/*---------------------------------------------------------------------------------*/ +/* Types */ +/*---------------------------------------------------------------------------------*/ + +typedef struct Command +{ + + short id; + char Name[25]; + char FullName[64]; + short DS_State; + NDT_Index_Type Index_Type; + +} Command; + +typedef char Arg[32 + 1]; + + + +/* Mesure des temps d'exécution */ + +#ifdef _WIN32 + +typedef struct +{ + double sec; + struct _timeb start; + struct _timeb stop; +} cpt; + +# define t_start(x) { _ftime( &(x.start));} +# define t_stop(x) { _ftime( &(x.stop)); x.sec = (double)(x.stop.time) - (double)(x.start.time) + ((double)(x.stop.millitm) - (double)(x.start.millitm)) / 1000;} +# define seed_get(x) (int)( (x).start.time) + +#else + +typedef struct +{ + double sec; + struct timeval start; + struct timeval stop; +} cpt; + +# define t_start(x) { gettimeofday( &((x).start), NULL);} +# define t_stop(x) { gettimeofday( &((x).stop), NULL); (x).sec = (double)((x).stop.tv_sec) - (double)((x).start.tv_sec) + ((double)((x).stop.tv_usec) - (double)((x).start.tv_usec)) / 1000000;} +# define seed_get(x) (int)( (x).start.tv_sec) + +#endif + +cpt t_exec; + + + +/* Définition des valeurs attachées aux noeuds de la structure */ + +typedef struct +{ + int Id; + char *Nom; +} T_Module; + + + +NDT_Index_Type idx_type_tab[INDEX_NB]; + +NDT_Index_Type idx_type_fifo = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO; + +NDT_Index_Type idx_type_sorted_list = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED; + +NDT_Index_Type idx_type_balanced_tree = NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED; + + + + + +/*---------------------------------------------------------------------------------*/ +/* Prototype */ +/*---------------------------------------------------------------------------------*/ + +NDT_Status Module_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); + +void Menu_Print( FILE *, NDT_Root *); +void Command_Get( int *, char **, char **, FILE *, FILE *, short); +void Command_Exec_Begin_Print( FILE *, int); +void Command_Exec_End_Print( FILE *, int, cpt, int); +void Command_Index_Range_Get( FILE *, int *, int *, char *, FILE *, int, char *); +void Command_Exec( NDT_Root **, FILE *, int, char *, char *, FILE *); +void Batch_Run( NDT_Root **, FILE *, FILE *, short); + + + + + +/*---------------------------------------------------------------------------------*/ +/* Global Variable */ +/*---------------------------------------------------------------------------------*/ + +Command Command_Tab[] = +{ + { QUIT, "Quit", "Quit", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { LIB_OPEN, "Lib_Open", "Open Library", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { LIB_CLOSE, "Lib_Close", "Close Library", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { DS_OPEN, "DS_Open", "Open DataStructure", ( DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { DS_CLOSE, "DS_Close", "Close DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { DS_FLUSH, "DS_Flush", "Flush DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { DS_CHECK, "DS_Check", "Check DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { DS_REORG, "DS_Reorg", "Reorg DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { DS_INFO_PRINT, "DS_Info_Print", "Print DataStructure Informations", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { DS_VALUE_ADD, "DS_Value_Add", "Add Values to DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { DS_VALUE_REMOVE, "DS_Value_Remove", "Remove Values from DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { DS_VALUE_PRINT, "DS_Value_Print", "Print DataStructure Values", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { DS_VALUE_FIND, "DS_Value_Find", "Find Values in DataStructure", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { INDEX_LIST_OPEN, "Index_List_Open", "Open List Index", ( DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { INDEX_TREE_OPEN, "Index_Tree_Open", "Open Tree Index", ( DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { INDEX_CLOSE, "Index_Close", "Close Index", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { INDEX_FLUSH, "Index_Flush", "Flush Index", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { INDEX_CHECK, "Index_Check", "Check Index", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { INDEX_LIST_SUBTYPE_SET, "Index_List_SubType_Set", "Set List SubType", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST)}, + { INDEX_LIST_TO_TREE, "Index_List_To_Tree", "Convert List to Tree", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST)}, + { INDEX_TREE_SUBTYPE_SET, "Index_Tree_SubType_Set", "Set Tree SubType", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_TREE)}, + { INDEX_TREE_TO_LIST, "Index_Tree_To_List", "Convert Tree to List", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_TREE)}, + { INDEX_REORG, "Index_Reorg", "Reorg Index", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { INDEX_INFO_PRINT, "Index_Info_Print", "Print Index Informations", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { INDEX_VALUE_PRINT, "Index_Value_Print", "Print Index Values", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { INDEX_VALUE_BREAK, "Index_Value_Break", "Break Index Value", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { INDEX_NODE_BREAK, "Index_Node_Break", "Break Index Node", ( DS_STATE_OPENED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)}, + { BATCH_RUN, "Batch_Run", "Run NDBench Bach", ( DS_STATE_OPENED | DS_STATE_CLOSED), ( NDD_INDEX_TYPE_LIST | NDD_INDEX_TYPE_TREE)} +}; + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "%Revision: 2.9 % %Name: libnode-2_1_0-1 % %Date: 2005/01/20 00:07:27 % %Author: agibert %"; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + T_Module **Module_Ptr_Ptr = (T_Module **)va_arg( Args, T_Module **); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + /* + case NDT_CMD_SOME_USER_CMD: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_SOME_OTHER_CMD; + break; + } + ... + */ + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + T_Module **Module_Ptr_Ptr = (T_Module **)va_arg( Args, T_Module **); + va_list user_args = (va_list)va_arg( Args, va_list); + char *Nom = (char *)va_arg( user_args, char *); + int Id = (int)va_arg( user_args, int); + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Module_Ptr_Ptr = (T_Module *)malloc( sizeof(T_Module))) != NULL) + { + (*Module_Ptr_Ptr)->Nom = strdup(Nom); + (*Module_Ptr_Ptr)->Id = Id; + + return( NDS_OK); + } + else + { + return( NDS_KO); + } + + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + T_Module *Module_Ptr = (T_Module *)va_arg( Args, T_Module *); + + + Command_Name = "NDD_CMD_VALUE_FREE"; + + + free( Module_Ptr->Nom); + free( Module_Ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + T_Module *Value1 = (T_Module *)va_arg( Args, T_Module *); + T_Module *Value2 = (T_Module *)va_arg( Args, T_Module *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + if( ( Index_Id >= 0) && ( Index_Id < INDEX_NB)) + { + int rc; + + + rc = Value1->Id - Value2->Id; + + if( rc < 0) + { + return(NDS_LOWER); + } + else + { + if( rc > 0) + { + return(NDS_GREATER); + } + else + { + return(NDS_EQUAL); + } + } + } + else + { + printf( "Unknown COMP idx (%d) !\n", Index_Id); + return( NDS_KO); + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + + T_Module *Module_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + fprintf( Out, "Id=%d\tNom=\"%s\"\n", Module_Ptr->Id, Module_Ptr->Nom); + + return( NDS_OK); + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( NDS_OK); + + } + + default: + { + printf( "Module_Manager() called with an undefined command %d\n", Command); + return( NDS_ERRAPI); + + } + } + + printf( "Module_Manager() called with command %d (%s)\n", Command, Command_Name); + return( NDS_OK); +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +void Menu_Print( FILE *File_Output, NDT_Root *DS_Ptr) +{ + short i; + char headc; + + + fprintf( File_Output, "\n-----------------------------------------------------------------------\nMenu :\n"); + + for( i = 0; i < COMMAND_NB; i++) + { + if( ( DS_Ptr && ( Command_Tab[i].DS_State & DS_STATE_OPENED) && ( DS_Ptr->Index_Tab[0].Type & Command_Tab[i].Index_Type)) + || ( !DS_Ptr && ( Command_Tab[i].DS_State & DS_STATE_CLOSED))) + { + headc = '-'; + } + else + { + headc = '*'; + } + + fprintf( File_Output, "\t%c (%2d) [%s]%*s%s\n", headc, i, Command_Tab[i].Name, ( 25 - strlen(Command_Tab[i].Name)), " ", Command_Tab[i].FullName); + } +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +void Command_Get( int *choice, char **arg1, char **arg2, FILE *File_Output, FILE *File_Input, short Interactive_Flag) +{ + char buf[100]; + char *tmp_arg1, *tmp_arg2; + + + do + { + if( Interactive_Flag) + { + fprintf( File_Output, "\nChoice ? "); + } + + if( fgets( buf, BUF_LEN, File_Input) != NULL) + { + while( ( buf[ strlen( buf) - 1] == '\r') || ( buf[ strlen( buf) - 1] == '\n') || ( buf[ strlen( buf) - 1] == '\t') || ( buf[ strlen( buf) - 1] == ' ')) + { + buf[ strlen( buf) - 1] = '\0'; + } + + if( isdigit( *buf)) + { + *choice = atoi( buf); + } + else + { + for( *choice = 0; ( *choice < COMMAND_NB) && ( strncmp( buf, Command_Tab[*choice].Name, strlen(Command_Tab[*choice].Name))) ; (*choice)++); + } + + if( ( *choice < 0) || ( *choice >= COMMAND_NB)) + { + if( strlen( buf) != 0) fprintf( File_Output, "\nUndefined choice (%s) !\n",buf); + + *choice = -1; + *arg1 = NULL; + *arg2 = NULL; + } + else + { + if( ( tmp_arg1 = strstr( buf, " ")) != NULL) + { + tmp_arg1++; + + if( ( tmp_arg2 = strstr( tmp_arg1, " ")) != NULL) + { + *tmp_arg2 = '\0'; + tmp_arg2++; + + *arg2 = malloc( ARG_SIZE); + if( *arg2 != NULL) strcpy( *arg2, tmp_arg2); + } + else + { + *arg2 = NULL; + } + + *arg1 = malloc( ARG_SIZE); + if( *arg1 != NULL) strcpy( *arg1, tmp_arg1); + } + else + { + *arg1 = NULL; + *arg2 = NULL; + } + } + } + else + { + *choice = 0; + *arg1 = NULL; + *arg2 = NULL; + } + } + while( *choice == -1); +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +void Command_Exec_Begin_Print( FILE *File_Output, int Choice) +{ + fprintf( File_Output, "%s: %s...\n", Command_Tab[Choice].Name, Command_Tab[Choice].FullName); + fflush( File_Output); +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +void Command_Exec_End_Print( FILE *File_Output, int Choice, cpt T_Exec, int nb) +{ + if( nb == 1) + { + fprintf( File_Output, "%s: Completed in (%.4f) second !\n", Command_Tab[Choice].Name, T_Exec.sec); + } + else + { + fprintf( File_Output, "%s: Completed in (%.4f) second, (%.2f) per second !\n", Command_Tab[Choice].Name, T_Exec.sec, nb / T_Exec.sec); + } +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +void Command_Index_Range_Get( FILE *File_Output, int *Low, int *High, char *Arg, FILE *File_Input, int Choice, char *Obj_Name) +{ + char buf[100]; + char *tmp; + + + if( Arg == NULL) + { + fprintf( File_Output, "%s: %s range (?-?) : ", Command_Tab[Choice].Name, Obj_Name); + fgets( buf, BUF_LEN, File_Input); + + Arg = buf; + } + + tmp = strstr( Arg, "-"); + + if( tmp != NULL) + { + *tmp = '\0'; + *Low = atoi( Arg); + tmp++; + *High = atoi( tmp); + + if( ( *High < *Low) || ( !strcmp( Obj_Name, "Index") && ( *High >= INDEX_NB))) + { + fprintf( File_Output, "%s: Invalit range (%d-%d) !\n", Command_Tab[Choice].Name, *Low, *High); + *Low = *High = -1; + } + } + else + { + fprintf( File_Output, "%s: Invalit range !\n", Command_Tab[Choice].Name); + *Low = *High = -1; + } +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, char *Arg1, char *Arg2, FILE *File_Input) +{ + int low, high, i, j, nb_removed, Nb_Detected, Nb_Corrected; + T_Module Ref_Module, *Module_Ptr; + char buf[BUF_SIZE]; + NDT_Index_Type index_subtype; + + + fprintf( File_Output, "\n"); + + switch( Choice) + { + case QUIT: + { + break; + } + + case LIB_OPEN: + { + Command_Exec_Begin_Print( File_Output, Choice); + + if( Arg1 == NULL) + { + fprintf( File_Output, "Library_Open: Debug Mode ( 0:OFF | 1:ON) ? "); + fgets( buf, BUF_LEN, File_Input); + + Arg1 = buf; + } + + Choice = atoi( Arg1); + + t_start( t_exec); + ND_Library_Open( Choice); + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, 1); + break; + } + + case LIB_CLOSE: + { + Command_Exec_Begin_Print( File_Output, Choice); + + t_start( t_exec); + ND_Library_Close(); + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, 1); + break; + } + + case DS_OPEN: + { + Command_Exec_Begin_Print( File_Output, Choice); + + if( Arg1 == NULL) + { + fprintf( File_Output, "DataStruct_Open: Symbol Lookup ( 0:OFF | 1:ON) ? "); + fgets( buf, BUF_LEN, File_Input); + + Arg1 = buf; + } + + Choice = atoi( Arg1); + + for( i = 0; i < INDEX_NB; i++) + { + idx_type_tab[i] = NDD_INDEX_STATUS_CLOSED; + } + + t_start( t_exec); + if( Choice == 0) + { + ND_DataStruct_Open( DS_Ptr_Ptr, INDEX_NB, idx_type_tab, "Module_Manager", Module_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL); + } + else + { + ND_DataStruct_Open( DS_Ptr_Ptr, INDEX_NB, idx_type_tab, "Module_Manager", NULL, NULL, NULL, NULL, NULL, NDD_TRUE, NULL); + } + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, 1); + break; + } + + case DS_CLOSE: + { + Command_Exec_Begin_Print( File_Output, Choice); + + t_start( t_exec); + ND_DataStruct_Close( *DS_Ptr_Ptr); + t_stop( t_exec); + + *DS_Ptr_Ptr = NULL; + + Command_Exec_End_Print( File_Output, Choice, t_exec, 1); + break; + } + + case DS_FLUSH: + { + Command_Exec_Begin_Print( File_Output, Choice); + + t_start( t_exec); + ND_DataStruct_Flush( *DS_Ptr_Ptr); + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, 1); + break; + } + + case DS_CHECK: + { + Command_Exec_Begin_Print( File_Output, Choice); + + Nb_Corrected = Nb_Detected = 0; + + t_start( t_exec); + ND_DataStruct_Check( *DS_Ptr_Ptr, &Nb_Detected, &Nb_Corrected, File_Output); + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, 1); + break; + } + + case DS_REORG: + { + Command_Exec_Begin_Print( File_Output, Choice); + + t_start( t_exec); + ND_DataStruct_Reorg( *DS_Ptr_Ptr); + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, 1); + break; + } + + case DS_INFO_PRINT: + { + Command_Exec_Begin_Print( File_Output, Choice); + + ND_DataStruct_Info_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0); + + break; + } + + case DS_VALUE_ADD: + { + int order; + + + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Value"); + + if( low != -1) + { + if( Arg2 == NULL) + { + fprintf( File_Output, "DS_Value_Add: Add order ( 0:croissant | 1:decroissant) ? "); + fgets( buf, BUF_LEN ,stdin); + + Arg2 = buf; + } + + order = atoi( Arg2); + + fprintf( File_Output, "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...\n", low, high, order); + fflush( File_Output); + + t_start( t_exec); + + if( order == 0) + { + i = low; + j = high + 1; + + while( i < j) + { + if( ND_Value_Alloc( *DS_Ptr_Ptr, (void **)&Module_Ptr, "x", i) == NDS_OK) + { + ND_DataStruct_Value_Add( *DS_Ptr_Ptr, Module_Ptr); + } + else + { + fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n"); + break; + } + + i++; + } + } + else + { + i = high; + j = low - 1; + + while( i > j) + { + if( ND_Value_Alloc( *DS_Ptr_Ptr, (void **)&Module_Ptr, "x", i) == NDS_OK) + { + ND_DataStruct_Value_Add( *DS_Ptr_Ptr, Module_Ptr); + } + else + { + fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n"); + break; + } + + i--; + } + } + + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case DS_VALUE_REMOVE: + { + int order; + nb_removed = 0; + + + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Value"); + + if( low != -1) + { + if( Arg2 == NULL) + { + fprintf( File_Output, "\nDS_Value_Remove: Remove order (croissant=0 | decroissant=1) ? "); + fgets( buf, BUF_LEN, File_Input); + + Arg2 = buf; + } + + order = atoi( Arg2); + + t_start( t_exec); + + if( order == 0) + { + i = low; + j = high + 1; + + while( i < j) + { + Ref_Module.Id = i; + + if( ( ND_DataStruct_Value_Find( (void **)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module) == NDS_OK) && ( Module_Ptr != NULL)) + { + if( ND_DataStruct_Value_Remove( *DS_Ptr_Ptr, (void **)&Module_Ptr) == NDS_OK) + { + nb_removed++; + ND_Value_Free( *DS_Ptr_Ptr, Module_Ptr); + } + } + + i++; + } + } + else + { + i = high; + j = low - 1; + t_start( t_exec); + + while( i > j) + { + Ref_Module.Id = i; + + if( ( ND_DataStruct_Value_Find( (void **)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module) == NDS_OK) && ( Module_Ptr != NULL)) + { + if( ND_DataStruct_Value_Remove( *DS_Ptr_Ptr, (void **)&Module_Ptr) == NDS_OK) + { + nb_removed++; + ND_Value_Free( *DS_Ptr_Ptr, Module_Ptr); + } + } + + i--; + } + } + + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case DS_VALUE_PRINT: + { + Command_Exec_Begin_Print( File_Output, Choice); + + ND_DataStruct_Value_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0); + break; + } + + case DS_VALUE_FIND: + { + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Search"); + + if( low != -1) + { + fprintf( File_Output, "DS_Value_Find: from: (%d) to: (%d)...\n", low, high); + fflush( File_Output); + + i = low; + j = high + 1; + + t_start( t_exec); + + while( i < j) + { + Ref_Module.Id = low + (int)( (double)( high - low) * rand() / ( RAND_MAX + 1.0)); + ND_DataStruct_Value_Find( (void *)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module); + i++; + } + + t_stop (t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case INDEX_LIST_OPEN: + { + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + fprintf( File_Output, "Index_List_Open: Opening a FIFO List from: (%d) to: (%d)...\n", low, high); + fflush( File_Output); + + t_start( t_exec); + + for( i = low; i <= high; i++) + { + ND_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_fifo); + } + + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case INDEX_TREE_OPEN: + { + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + + fprintf( File_Output, "Index_Tree_Open: Opening a balanced Tree from: (%d) to: (%d)...\n", low, high); + fflush( File_Output); + + t_start( t_exec); + + for( i = low; i <= high; i++) + { + ND_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_balanced_tree); + } + + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case INDEX_CLOSE: + { + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + + fprintf( File_Output, "Index_Close: Closing index from: (%d) to: (%d)...\n", low, high); + fflush( File_Output); + + t_start( t_exec); + + for( i = high; i >= low; i--) + { + ND_Index_Close( *DS_Ptr_Ptr, (NDT_Index_Id)i); + } + + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case INDEX_LIST_SUBTYPE_SET: + { + int subtype; + + + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + if( Arg2 == NULL) + { + fprintf( File_Output, "Index_List_SubType_Set: List SubType ( 0:FIFO | 1:LIFO | 2:Sorted) ? "); + fgets( buf, BUF_LEN, File_Input); + + Arg2 = buf; + } + + subtype = atoi( Arg2); + + switch( subtype) + { + case 0: + { + index_subtype = NDD_INDEX_SUBTYPE_FIFO; + break; + } + + case 1: + { + index_subtype = NDD_INDEX_SUBTYPE_FILO; + break; + } + + case 2: + { + index_subtype = NDD_INDEX_SUBTYPE_SORTED; + break; + } + + default: + { + index_subtype = NDD_INDEX_SUBTYPE_UNKNOWN; + printf ("Index_List_SubType_Set: Invalid selection (%d) !\n", subtype); + break; + } + } + + if( index_subtype != NDD_INDEX_SUBTYPE_UNKNOWN) + { + fprintf( File_Output, "Index_List_SubType_Set: Setting List SubType to: (%d) (%s) !\n", index_subtype, ND_INDEX_SUBTYPE_VALUE_ASCII_GET( index_subtype)); + + t_start( t_exec); + + for( i = low; i <= high; i++) + { + if( ND_INDEX_TYPE_LIST_IS( *DS_Ptr_Ptr, i)) + { + (*DS_Ptr_Ptr)->Index_Tab[i].Type = ( (*DS_Ptr_Ptr)->Index_Tab[i].Type & NDD_INDEX_SUBTYPE_RMSK) | index_subtype; + } + else + { + fprintf( File_Output, "Index_List_SubType_Set: Error: index (%d) is not a List !\n", i); + } + } + + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + } + + break; + } + + case INDEX_TREE_SUBTYPE_SET: + { + int subtype; + + + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + if( Arg2 == NULL) + { + fprintf( File_Output, "Index_Tree_SubType_Set: Tree SubType (0:UnBalanced | 1:Balanced) ? "); + fgets( buf, BUF_LEN, stdin); + + Arg2 = buf; + } + + subtype = atoi( Arg2); + + switch( subtype) + { + case 0: + { + index_subtype = NDD_INDEX_SUBTYPE_UNBALANCED; + break; + } + + case 1: + { + index_subtype = NDD_INDEX_SUBTYPE_BALANCED; + break; + } + + default: + { + index_subtype = NDD_INDEX_SUBTYPE_UNKNOWN; + printf ("Index_Tree_SubType_Set: Invalid selection (%d)!\n", subtype); + break; + } + } + + if( index_subtype != NDD_INDEX_SUBTYPE_UNKNOWN) + { + + t_start( t_exec); + + for( i = low; i <= high; i++) + { + if( ND_INDEX_TYPE_TREE_IS( *DS_Ptr_Ptr, i)) + { + (*DS_Ptr_Ptr)->Index_Tab[i].Type = ( (*DS_Ptr_Ptr)->Index_Tab[i].Type & NDD_INDEX_SUBTYPE_RMSK) | index_subtype; + } + else + { + fprintf( File_Output, "Index_Tree_SubType_Set: Error: index (%d) is not a Tree !\n", i); + } + } + + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + } + + break; + } + + case INDEX_REORG: + { + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + t_start( t_exec); + + for( i = low; i <= high; i++) + { + fprintf( File_Output, "Index_Reorg: Reorganizing index (%d)...\n", i); + fflush( File_Output); + + ND_Index_Reorg( *DS_Ptr_Ptr, (NDT_Index_Id)i); + } + + t_stop( t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case INDEX_TREE_TO_LIST: + { + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + t_start( t_exec); + + for( i = low; i <= high; i++) + { + fprintf( File_Output, "Index_Tree_To_List: Converting Index (%d)...\n", i); + fflush( File_Output); + + ND_Index_Convert( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_sorted_list); + } + + t_stop (t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case INDEX_LIST_TO_TREE: + { + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + t_start( t_exec); + + for( i = low; i <= high; i++) + { + fprintf( File_Output, "Index_List_To_Tree: Converting Index (%d)...\n", i); + fflush( File_Output); + + ND_Index_Convert( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_balanced_tree); + } + + t_stop (t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case INDEX_INFO_PRINT: + { + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + fprintf( File_Output, "Index_Info_Print: Printing index from: (%d) to: (%d)...\n", low, high); + fflush( File_Output); + + for( i = low; i <= high; i++) + { + ND_Index_Info_Print( File_Output, *DS_Ptr_Ptr, (NDT_Index_Id)i, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0); + } + } + + break; + } + + case INDEX_VALUE_PRINT: + { + fprintf( File_Output, "DS_Value_Print:\n"); + fflush( File_Output); + + ND_DataStruct_Value_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0); + break; + } + + case INDEX_VALUE_BREAK: + { + int position; + NDT_Node *node_ptr; + + + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + if( Arg2 == NULL) + { + fprintf( File_Output, "Index_Value_Break: Value position (0:Head | 1:Tail | 2:Random) ? "); + fgets( buf, BUF_LEN, stdin); + + Arg2 = buf; + } + + position = atoi( Arg2); + + fprintf( File_Output, "Index_Value_Break: Breaking %s values from index : (%d) to: (%d)...\n", + ( position == 0 ) ? "Head" : ( ( position == 1) ? "Tail" : "Random"), + low, high); + fflush( File_Output); + + t_start( t_exec); + + fprintf( File_Output, "Index_Value_Break: Breaking value of nodes: "); + fflush( File_Output); + + for( i = low; i <= high; i++) + { + switch( position) + { + case 0: + { + node_ptr =(*DS_Ptr_Ptr)->Index_Tab[i].Head; + break; + } + + case 1: + { + node_ptr=(*DS_Ptr_Ptr)->Index_Tab[i].Tail; + break; + } + + case 2: + { + j = (int)( (double)( (*DS_Ptr_Ptr)->Index_Tab[i].Node_Number) * rand() / ( RAND_MAX + 1.0)); + + for( node_ptr = (*DS_Ptr_Ptr)->Index_Tab[i].Head; j > 0; j--) + { + node_ptr = node_ptr->Right; + } + + break; + } + } + + fprintf( File_Output, "0x(%x)", node_ptr); + fflush( File_Output); + + node_ptr->Value = (void *)-1; + } + + t_stop (t_exec); + + fprintf( File_Output, "\n"); + fflush( File_Output); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case INDEX_NODE_BREAK: + { + + break; + } + + case INDEX_CHECK: + { + Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); + + if( low != -1) + { + t_start( t_exec); + + for( i = low; i <= high; i++) + { + fprintf( File_Output, "Index_Check: Checking Index (%d)...\n", i); + fprintf( File_Output, "Index_Check: "); + fflush( File_Output); + + Nb_Corrected = Nb_Detected = 0; + ND_Index_Check( *DS_Ptr_Ptr, (NDT_Index_Id)i, &Nb_Detected, &Nb_Corrected, File_Output); + } + + t_stop (t_exec); + + Command_Exec_End_Print( File_Output, Choice, t_exec, high - low); + } + + break; + } + + case BATCH_RUN: + { + FILE *file_input; + + + if( Arg1 == NULL) + { + fprintf( File_Output, "Batch_Run: Batch file name ? "); + + fgets( buf, BUF_LEN, stdin); + buf[ strlen( buf) - 1] = '\0'; + Arg1 = buf; + } + + file_input = fopen( Arg1, "r"); + + if( file_input == NULL) + { + fprintf( File_Output, "Batch_Run: Can't open file (%s)!\n", Arg1); + } + else + { + fprintf( File_Output, "\n\n--------------------------------------------------------------------------------\n"); + fprintf( File_Output, "Batch_Run: Starting execution (%s)...\n", Arg1); + Batch_Run( DS_Ptr_Ptr, File_Output, file_input, 0); + fprintf( File_Output, "\n"); + fprintf( File_Output, "Batch_Run: Ending execution (%s)...\n", Arg1); + + fclose( file_input); + } + + break; + } + + default: + { + fprintf( File_Output, "\nUndefined command (%d) !\n", Choice); + } + } +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +void Batch_Run( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, FILE *File_Input, short Interactive_Flag) +{ + int choice; + char *arg1, *arg2; + + + do + { + if( Interactive_Flag) + { + Menu_Print( File_Output, *DS_Ptr_Ptr); + } + + Command_Get( &choice, &arg1, &arg2, File_Output, File_Input, Interactive_Flag); + + if( ( choice != QUIT) && ( choice != -1)) + { + Command_Exec( DS_Ptr_Ptr, File_Output, choice, arg1, arg2, File_Input); + } + + if( arg1 != NULL) free( arg1); + if( arg2 != NULL) free( arg2); + } + while( choice != QUIT); +} + + + + + +/*---------------------------------------------------------------------------------*/ +/* */ +/*---------------------------------------------------------------------------------*/ + +int main( int argc, char **argv) +{ + NDT_Root *ds_ptr = NULL; + + + /* Init Random numbers... */ + + t_start( t_exec); + t_stop( t_exec); + srand( seed_get(t_exec)); + + + + /* Args Parsing */ + + if( argc >= 2) + { + if( !strcmp( argv[1], "--help")) + { + fprintf( stderr, USAGE, argv[0]); + return( 1); + } +#ifdef _LIBVER_SUPPORT + else if( !strcmp( argv[1], "--version")) + { + if( argc >= 3 && !strcmp( argv[2], "-v")) + { + return( VER_Object_Print( stdout, VERD_VERBOSE)); + } + else + { + return( VER_Object_Print( stdout, VERD_MINIMAL)); + } + } +#endif + else if( !strcmp( argv[1], "--batch_run")) + { + /* Batch Mode */ + + Command_Exec( &ds_ptr, stdout, BATCH_RUN, argv[2], NULL, stdin); + + return( 0); + } + else + { + fprintf( stderr, USAGE, argv[0]); + return( -1); + } + } + + + + /* Interactive Mode */ + + Batch_Run( &ds_ptr, stdout, stdin, 1); + + return( 0); +} diff --git a/src/libnode/util/test-10-s.ndb b/src/libnode/util/test-10-s.ndb new file mode 100644 index 0000000..cf2138c --- /dev/null +++ b/src/libnode/util/test-10-s.ndb @@ -0,0 +1,10 @@ +Lib_Open 0 +DS_Open 1 +Index_List_Open 0-0 +DS_Value_Add 1-10 0 +DS_Value_Find 1-10 +Index_List_To_Tree 0-0 +DS_Value_Find 1-10 +DS_Check +DS_Close +Lib_Close diff --git a/src/libnode/util/test-10.ndb b/src/libnode/util/test-10.ndb new file mode 100644 index 0000000..76e86c8 --- /dev/null +++ b/src/libnode/util/test-10.ndb @@ -0,0 +1,10 @@ +Lib_Open 0 +DS_Open 0 +Index_List_Open 0-0 +DS_Value_Add 1-10 0 +DS_Value_Find 1-10 +Index_List_To_Tree 0-0 +DS_Value_Find 1-10 +DS_Check +DS_Close +Lib_Close diff --git a/src/libnode/util/test-100K-s.ndb b/src/libnode/util/test-100K-s.ndb new file mode 100644 index 0000000..5429713 --- /dev/null +++ b/src/libnode/util/test-100K-s.ndb @@ -0,0 +1,10 @@ +Lib_Open 0 +DS_Open 1 +Index_List_Open 0-0 +DS_Value_Add 1-100000 0 +DS_Value_Find 49900-50100 +Index_List_To_Tree 0-0 +DS_Value_Find 1-100000 +DS_Check +DS_Close +Lib_Close diff --git a/src/libnode/util/test-100K.ndb b/src/libnode/util/test-100K.ndb new file mode 100644 index 0000000..a0279e7 --- /dev/null +++ b/src/libnode/util/test-100K.ndb @@ -0,0 +1,10 @@ +Lib_Open 0 +DS_Open 0 +Index_List_Open 0-0 +DS_Value_Add 1-100000 0 +DS_Value_Find 49900-50100 +Index_List_To_Tree 0-0 +DS_Value_Find 1-100000 +DS_Check +DS_Close +Lib_Close diff --git a/src/libnode/util/test-10K-s.ndb b/src/libnode/util/test-10K-s.ndb new file mode 100644 index 0000000..3586b39 --- /dev/null +++ b/src/libnode/util/test-10K-s.ndb @@ -0,0 +1,10 @@ +Lib_Open 0 +DS_Open 1 +Index_List_Open 0-0 +DS_Value_Add 1-10000 0 +DS_Value_Find 4000-6000 +Index_List_To_Tree 0-0 +DS_Value_Find 1-10000 +DS_Check +DS_Close +Lib_Close diff --git a/src/libnode/util/test-10K.ndb b/src/libnode/util/test-10K.ndb new file mode 100644 index 0000000..088f6e4 --- /dev/null +++ b/src/libnode/util/test-10K.ndb @@ -0,0 +1,10 @@ +Lib_Open 0 +DS_Open 0 +Index_List_Open 0-0 +DS_Value_Add 1-10000 0 +DS_Value_Find 4000-6000 +Index_List_To_Tree 0-0 +DS_Value_Find 1-10000 +DS_Check +DS_Close +Lib_Close diff --git a/src/libnode/util/test-1M-s.ndb b/src/libnode/util/test-1M-s.ndb new file mode 100644 index 0000000..87d9c6d --- /dev/null +++ b/src/libnode/util/test-1M-s.ndb @@ -0,0 +1,10 @@ +Lib_Open 0 +DS_Open 1 +Index_List_Open 0-0 +DS_Value_Add 1-1000000 0 +DS_Value_Find 499990-500010 +Index_List_To_Tree 0-0 +DS_Value_Find 1-1000000 +DS_Check +DS_Close +Lib_Close diff --git a/src/libnode/util/test-1M.ndb b/src/libnode/util/test-1M.ndb new file mode 100644 index 0000000..5ccf43c --- /dev/null +++ b/src/libnode/util/test-1M.ndb @@ -0,0 +1,10 @@ +Lib_Open 0 +DS_Open 0 +Index_List_Open 0-0 +DS_Value_Add 1-1000000 0 +DS_Value_Find 499990-500010 +Index_List_To_Tree 0-0 +DS_Value_Find 1-1000000 +DS_Check +DS_Close +Lib_Close diff --git a/src/libnode/util/test-all.ndb b/src/libnode/util/test-all.ndb new file mode 100644 index 0000000..cc341de --- /dev/null +++ b/src/libnode/util/test-all.ndb @@ -0,0 +1,9 @@ +Batch_Run test-error.ndb +Batch_Run test-10.ndb +Batch_Run test-10-s.ndb +Batch_Run test-10K.ndb +Batch_Run test-10K-s.ndb +Batch_Run test-100K.ndb +Batch_Run test-100K-s.ndb +Batch_Run test-1M.ndb +Batch_Run test-1M-s.ndb diff --git a/src/libnode/util/test-error.ndb b/src/libnode/util/test-error.ndb new file mode 100644 index 0000000..df0ddbe --- /dev/null +++ b/src/libnode/util/test-error.ndb @@ -0,0 +1,15 @@ +DS_Open 0 +Lib_Open 0 +DS_Open 0 +Index_List_Open 0-0 +DS_Value_Add 1-10 0 +Lib_Close +Lib_Open 1 +DS_Open 0 +Index_List_Open 0-0 +DS_Value_Add 1-10 0 +Index_Value_Break 0-0 0 +Index_Value_Break 0-0 1 +Index_Value_Break 0-0 2 +DS_Check +Lib_Close diff --git a/src/libstatic_data_mng/include/static_data_mng.h b/src/libstatic_data_mng/include/static_data_mng.h new file mode 100644 index 0000000..82712be --- /dev/null +++ b/src/libstatic_data_mng/include/static_data_mng.h @@ -0,0 +1,420 @@ +/*----------------------------------------------------------------------------*/ +/* File: static_data_mng.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _STATIC_DATA_MNG_H_ +#define _STATIC_DATA_MNG_H_ + + + +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRD_API definition */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBSTATIC_DATA_MNG_C_ +# define IMRD_SDM_API +# else +# define IMRD_SDM_API extern +# endif + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_SDM_Config */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_SDM_Flag; + +#define IMRD_SDM_FLAG_UNKNOWN ( IMRT_SDM_Flag) 0 +#define IMRD_SDM_FLAG_XML ( IMRT_SDM_Flag) 1 +#define IMRD_SDM_FLAG_SQL ( IMRT_SDM_Flag) 2 + + + +typedef struct +{ + IMRT_SDM_Flag Flag; + IMRT_Path Lib_Path; +} IMRT_SDM_Config; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_MsgMap_Id definition */ +/*----------------------------------------------------------------------------*/ + +typedef int IMRT_MsgMap_Id; + +#define IMRD_MSGMAP_ID_UNKNOWN ( IMRT_MsgMap_Id) 0 + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_MsgMap definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_MsgMap +{ + IMRT_MsgMap_Id Id; + char Name[IMRD_NAME_SIZE]; + IMRT_Msg *Msg_Input_Ptr; + IMRT_Msg *Msg_Output_Ptr; + NDT_Root *FieldMap_Struct_Ptr; +} IMRT_MsgMap; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Jump definition */ +/*----------------------------------------------------------------------------*/ + +typedef struct IMRT_Jump +{ + IMRT_Fmt *Fmt_Ptr; + IMRT_Msg *Msg_Ptr; + int Branche_Id; +} IMRT_Jump; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_MapCmd */ +/*----------------------------------------------------------------------------*/ + +/*#define IMRD_JUMP_NB_MAX ( short) 40*/ + + + +typedef short IMRT_MapCmd_Id; + + + +typedef short IMRT_MapCmd_Type; + +#define IMRD_MAPCMD_TYPE_UNKNOWN ( IMRT_MapCmd_Type) 0 +#define IMRD_MAPCMD_TYPE_MAP ( IMRT_MapCmd_Type) 1 +#define IMRD_MAPCMD_TYPE_COPY ( IMRT_MapCmd_Type) 2 +#define IMRD_MAPCMD_TYPE_IDENT ( IMRT_MapCmd_Type) 3 +#define IMRD_MAPCMD_TYPE_GOTO ( IMRT_MapCmd_Type) 4 + + + +typedef short IMRT_MapCmd_Branch_Id; + + + +typedef short IMRT_MapCmd_Flag; + + + +typedef struct IMRT_MapCmd +{ + IMRT_MapCmd_Id MapCmd_Id; + IMRT_MapCmd_Type TypeCmd; + IMRT_MapCmd_Branch_Id Branche_Id; + IMRT_Boolean Ident_Total; + IMRT_Msg *Ident_First_Msg_Ptr; + IMRT_Fmt *Fmt_Input_Ptr; + IMRT_FmtAttr *FmtAttr_Input_Ptr; + IMRT_Fmt *Fmt_Output_Ptr; + IMRT_FmtAttr *FmtAttr_Output_Ptr; + IMRT_Buffer_Id Buffer_Id_Input; + IMRT_Buffer_Id Buffer_Id_Output; + IMRT_Buffer_Id Buffer_Id_Ident; + IMRT_MapCmd_Flag Clear_Flag; + IMRT_MsgMap *MsgMap_Ptr; + IMRT_MapCmd_Branch_Id Goto_Branche_Id; + int JmpTbleNbElts; + IMRT_Jump *Jump_Tab; +} IMRT_MapCmd; + + + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBSTATIC_DATA_MNG_ + +# else + +extern IMRT_Module IMRG_SDM_Module; + +# endif + + + + + + + +/******************************************************************************/ +/* Static Data Manager Client CallBack */ +/******************************************************************************/ + + + +/*----------------------------------------------------------------------------*/ +/* Format Add CallBack */ +/*----------------------------------------------------------------------------*/ +/* (I) Fmt_Id: Format id */ +/* (I) Fmt_Name: Format name */ +/* (I) Fmt_Id_Nb: Total number of format */ +/*----------------------------------------------------------------------------*/ + +typedef IMRT_Status IMRT_SDMCB_Fmt_Add( IMRT_Fmt_Id, IMRT_Fmt_Name, IMRT_Fmt_Id); + + + +/*----------------------------------------------------------------------------*/ +/* Convert Add CallBack */ +/*----------------------------------------------------------------------------*/ +/* (I) Cnv_Id: Convert id */ +/* (I) Cnv_Name: Convert name */ +/* (I) Cnv_Id_Nb: Total number of convert */ +/*----------------------------------------------------------------------------*/ + +typedef IMRT_Status IMRT_SDMCB_Cnv_Add( IMRT_Cnv_Id, IMRT_Cnv_Name, IMRT_Cnv_Id); + + + +/*----------------------------------------------------------------------------*/ +/* Buffer Mapping CallBack */ +/*----------------------------------------------------------------------------*/ +/* (I) Buffer_Id_Target: Target buffer id */ +/* (I) Fmt_Target: Target format */ +/* (I) Fmt_Attr_Target: Target format attribute */ +/* (I) Buffer_Id_Src: Source buffer id */ +/* (I) Fmt_Src: Source format */ +/* (I) Fmt_Attr_Src: Source format attribute */ +/* (I) MsgMap: Message Map to use */ +/* (I) Clear_Flag: Clear or donn't clear output buffer */ +/*----------------------------------------------------------------------------*/ + +typedef IMRT_Status IMRT_SDMCB_Buffer_Map( IMRT_Buffer_Id, IMRT_Fmt_Id, IMRT_FmtAttr_Value, IMRT_Buffer_Id, IMRT_Fmt_Id, IMRT_FmtAttr_Value, IMRT_MsgMap *, IMRT_MapCmd_Flag); + + + +/*----------------------------------------------------------------------------*/ +/* Buffer Copy CallBack */ +/*----------------------------------------------------------------------------*/ +/* (I) Buffer_Id_Target: Target buffer id */ +/* (I) Buffer_Id_Src: Source buffer id */ +/*----------------------------------------------------------------------------*/ + +typedef IMRT_Status IMRT_SDMCB_Buffer_Copy( IMRT_Buffer_Id, IMRT_Buffer_Id); + + + +/*----------------------------------------------------------------------------*/ +/* Buffer Identification CallBack */ +/*----------------------------------------------------------------------------*/ +/* (O) Fmt_Id_Ptr: Buffer format to return */ +/* (I/O) Msg_Id_Ptr: Buffer message id to read (if not total) and return */ +/* (I) Buffer_Id_Ptr: Id of the buffer to identify */ +/* (I) Ident_Total: True if total identification */ +/*----------------------------------------------------------------------------*/ + +typedef IMRT_Status IMRT_SDMCB_Buffer_Ident( IMRT_Fmt_Id *, IMRT_Msg_Id *, IMRT_Buffer_Id, IMRT_Boolean); + + + +/*----------------------------------------------------------------------------*/ +/* Field Mapping CallBack */ +/*----------------------------------------------------------------------------*/ +/* (I) Field_Target_Ptr: Target Field pointer */ +/* (I) Field_Source_Ptr: Source Field pointer */ +/*----------------------------------------------------------------------------*/ + +typedef IMRT_Status IMRT_SDMCB_Field_Map( IMRT_Field *, IMRT_Field *); + + + +/*----------------------------------------------------------------------------*/ +/* Field Ident CallBack */ +/*----------------------------------------------------------------------------*/ +/* (I) FieldMap_Ptr: FielMap pointer */ +/*----------------------------------------------------------------------------*/ + +typedef IMRT_Status IMRT_SDMCB_Ident_Field_Value( IMRT_Field *, IMRT_Field_Value_Id); + + +typedef IMRT_Status IMRT_SDMCB_Ident_Field_Exist( IMRT_Field *); + + +typedef IMRT_Status IMRT_SDMCB_Ident_Msg_Size( size_t); + + + + + +/******************************************************************************/ +/* Static Data Manager API */ +/******************************************************************************/ + + + +/*----------------------------------------------------------------------------*/ +/* Open Static Data Manager */ +/*----------------------------------------------------------------------------*/ +/* Lib_Flag: Setup SDM init mode (XML, SQL, ...) */ +/*----------------------------------------------------------------------------*/ + +IMRD_SDM_API IMRT_Status IMR_SDM_Library_Open( IMRT_SDM_Config *); + + + +/*----------------------------------------------------------------------------*/ +/* Close Static Data Manager */ +/*----------------------------------------------------------------------------*/ + +IMRD_SDM_API IMRT_Status IMR_SDM_Library_Close( void); + + + +/*----------------------------------------------------------------------------*/ +/* Dump Data Structures to SQL files */ +/*----------------------------------------------------------------------------*/ +IMRD_SDM_API IMRT_Status IMR_SDM_SQL_Dump(void); + + + +/*----------------------------------------------------------------------------*/ +/* Dump Data Structures to XML files */ +/*----------------------------------------------------------------------------*/ +IMRD_SDM_API IMRT_Status IMR_SDM_XML_Dump(void); + + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Format */ +/*----------------------------------------------------------------------------*/ +/* (I) CCB_Fmt_Add_Ptr: Format add callback */ +/*----------------------------------------------------------------------------*/ + +IMRD_SDM_API IMRT_Status IMR_SDM_Fmt_Proceed( IMRT_SDMCB_Fmt_Add *); + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Convert */ +/*----------------------------------------------------------------------------*/ +/* (I) CCB_Cnv_Add_Ptr: Convert add callback */ +/*----------------------------------------------------------------------------*/ +IMRD_SDM_API IMRT_Status IMR_SDM_Cnv_Proceed( IMRT_SDMCB_Cnv_Add *); + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Convert */ +/*----------------------------------------------------------------------------*/ +/* (I) CCB_Cnv_Add_Ptr: Convert add callback */ +/*----------------------------------------------------------------------------*/ + +IMRD_SDM_API IMRT_Status IMR_SDM_Cnv_Proceed( IMRT_SDMCB_Cnv_Add *); + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Mapping Path */ +/*----------------------------------------------------------------------------*/ +/* (I) Appl_Id_Target: Target buffer application id */ +/* (I) Fmt_Id_Target: Target buffer format id */ +/* (I) Msg_Id_Target: Target buffer message id */ +/* (I) ApplId_Src: Source buffer application id */ +/* (I) Fmt_Id_Src: Source buffer format id */ +/* (I) Msg_Id_Src: Source buffer message id */ +/* (I) CCB_Buffer_Map_Ptr: Buffer mapping callback */ +/* (I) CCB_Buffer_Copy_Ptr: Buffer copy callback */ +/* (I) CCB_Buffer_Ident_Ptr: Buffer identification callback */ +/*----------------------------------------------------------------------------*/ + +IMRD_SDM_API IMRT_Status IMR_SDM_MapPath_Proceed( IMRT_Appl_Id, IMRT_Fmt_Id, IMRT_Msg_Id, + IMRT_Appl_Id, IMRT_Fmt_Id, IMRT_Msg_Id, + IMRT_SDMCB_Buffer_Map *, IMRT_SDMCB_Buffer_Copy *, IMRT_SDMCB_Buffer_Ident *); + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Buffer Mapping */ +/*----------------------------------------------------------------------------*/ +/* (I) MsgMap_Ptr: Message map pointer */ +/* (I) CCB_Field_Map_Ptr: Field mapping callback */ +/*----------------------------------------------------------------------------*/ + +IMRD_SDM_API IMRT_Status IMR_SDM_MsgMap_Proceed( IMRT_MsgMap *, IMRT_SDMCB_Field_Map *); + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Message Identification */ +/*----------------------------------------------------------------------------*/ +/* (I) Fmt_Id: Target buffer format id */ +/* (I) Msg_Id: Target buffer message id */ +/* (I) CCB_Field_Ident_Ptr: Field ident callback */ +/*----------------------------------------------------------------------------*/ + +IMRD_SDM_API IMRT_Status IMR_SDM_MsgIdent_Proceed( IMRT_Fmt_Id, IMRT_Msg_Id *, IMRT_SDMCB_Ident_Field_Value *, IMRT_SDMCB_Ident_Field_Exist *, IMRT_SDMCB_Ident_Msg_Size *); + + + +/*----------------------------------------------------------------------------*/ +/* Convert Buffer Format Name to Buffer Format Id */ +/*----------------------------------------------------------------------------*/ + +IMRD_SDM_API IMRT_Status IMR_SDM_Fmt_Id_Get( IMRT_Fmt_Id *, const IMRT_Fmt_Name); + + + +/*----------------------------------------------------------------------------*/ +/* Convert Buffer Appli Name to Buffer Appli Id */ +/*----------------------------------------------------------------------------*/ +IMRD_SDM_API IMRT_Status IMR_SDM_Appl_Id_Get( IMRT_Appl_Id *, const IMRT_Appl_Name); + + + +#endif diff --git a/src/libstatic_data_mng/src/Makefile b/src/libstatic_data_mng/src/Makefile new file mode 100644 index 0000000..dfc6541 --- /dev/null +++ b/src/libstatic_data_mng/src/Makefile @@ -0,0 +1,79 @@ +#------------------------------------------------------------------------------ +# Local Makefile +#------------------------------------------------------------------------------ +# $Workfile: Makefile $ +#------------------------------------------------------------------------------ +# $Author: agibert $ +# $Date: 2008/11/12 02:25:23 $ +# $Revision: 1.1 $ +# $Label: $ +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# IMR - Interlinking Message Router +# Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) +# mailto:arnaud@rx3.net +# http://www.rx3.org/dvp/?dvp=imr +#------------------------------------------------------------------------------ +# This file is part of IMR +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#------------------------------------------------------------------------------ + + + + + +#------------------------------------------------------------------------------ +# Var include +#------------------------------------------------------------------------------ + +include ../../Makefile_var.mk + + + +#------------------------------------------------------------------------------ +# Variables +#------------------------------------------------------------------------------ + +TARGET= libstatic_data_mng$(SHLIB_SUFFIX) + +OBJ= libstatic_data_mng.o \ + arc_hdl_xml.o \ + buffer_info_mng.o \ + mapping_info_mng.o \ + struct_info_mng.o \ + buffer_info_xml.o \ + mapping_info_xml.o \ + struct_info_xml.o + +ifeq ($(ORACLE_SUPPORT),1) + OBJ+= arc_hdl_sql.o \ + buffer_info_sql.o \ + mapping_info_sql.o \ + struct_info_sql.o +endif + +EXTRA_INC= + +EXTRA_LIB= + + + +#------------------------------------------------------------------------------ +# Rule include +#------------------------------------------------------------------------------ + +include ../../Makefile_rule.mk diff --git a/src/libstatic_data_mng/src/arc_hdl_sql.h b/src/libstatic_data_mng/src/arc_hdl_sql.h new file mode 100644 index 0000000..6e660fc --- /dev/null +++ b/src/libstatic_data_mng/src/arc_hdl_sql.h @@ -0,0 +1,101 @@ +/*----------------------------------------------------------------------------*/ +/* File: arc_hdl_sql.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _ARC_HDL_SQL_H_ +# define _ARC_HDL_SQL_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include +# include + + +/*----------------------------------------------------------------------------*/ +/* Global variables */ +/*----------------------------------------------------------------------------*/ +# ifdef _ARC_HDL_SQL_PC_ + +typedef short IMRT_DB_Open_Flag; + +#define IMRD_DB_OPEN_FLAG_UNKNOWN ( IMRT_DB_Open_Flag) 0 +#define IMRD_DB_OPEN_FLAG_OPENED ( IMRT_DB_Open_Flag) 1 +#define IMRD_DB_OPEN_FLAG_CLOSED ( IMRT_DB_Open_Flag) 2 + + + +typedef struct IMRT_SDM_SQL_Base +{ + IMRT_DB_Open_Flag Open_Flag; + +} IMRT_SDM_SQL_Base; + + + +IMRT_SDM_SQL_Base IMRG_SDM_SQL_Base = +{ + IMRD_DB_OPEN_FLAG_CLOSED +}; + +# endif + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _ARC_HDL_SQL_PC_ + +IMRT_Status SDM_HDR_SQL_Init(IMRT_SDM_Flag Flag); +IMRT_Status SDM_HDR_SQL_DInit(void); +IMRT_Status SDM_SQL_ConnectOra(void); +IMRT_Status SDM_SQL_DisconnectOra(void); +IMRT_Status SDM_SQL_Set_Struct_Version(IMRT_Data_Version *, char *); + +# else + +extern IMRT_Status SDM_HDR_SQL_Init(IMRT_SDM_Flag Flag); +extern IMRT_Status SDM_HDR_SQL_DInit(void); +extern IMRT_Status SDM_SQL_ConnectOra(void); +extern IMRT_Status SDM_SQL_DisconnectOra(void); +extern IMRT_Status SDM_SQL_Set_Struct_Version(IMRT_Data_Version *, char *); + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/arc_hdl_sql.pc b/src/libstatic_data_mng/src/arc_hdl_sql.pc new file mode 100644 index 0000000..e15cf67 --- /dev/null +++ b/src/libstatic_data_mng/src/arc_hdl_sql.pc @@ -0,0 +1,185 @@ +/*----------------------------------------------------------------------------*/ +/* File: arc_hdl_sql.pc */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _ARC_HDL_SQL_PC_ + +#include "arc_hdl_sql.h" + + +IMRT_Status SDM_HDR_SQL_Init(IMRT_SDM_Flag Flag) +{ + IMRT_Status status; + + status = IMRS_OK; + + if (Flag == IMRD_SDM_FLAG_SQL) + { + status = SDM_SQL_ConnectOra(); + if (status == IMRS_OK) + { + IMRG_SDM_SQL_Base.Open_Flag = IMRD_DB_OPEN_FLAG_OPENED; + } + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_HDR_SQL_DInit(void) +{ + IMRT_Status status; + + status = IMRS_OK; + + if (IMRG_SDM_SQL_Base.Open_Flag == IMRD_DB_OPEN_FLAG_OPENED) + { + status = SDM_SQL_DisconnectOra(); + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_ConnectOra(void) +{ + IMRT_Status status; + const char sFunctionName []="SDM_SQL_ConnectOra"; + EXEC SQL BEGIN DECLARE SECTION; + VARCHAR vConnectString[50]; + EXEC SQL END DECLARE SECTION; + + status = IMRS_OK; + strcpy ( (char *) vConnectString.arr, "/"); + vConnectString.len = strlen( (char *) vConnectString.arr ); + + EXEC SQL CONNECT :vConnectString ; + if (sqlca.sqlcode != 0) + { + IMRD_LM_LOG_ERROR_3("Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_DisconnectOra(void) +{ + IMRT_Status status; + const char sFunctionName []="SDM_SQL_DisconnectOra"; + + status = IMRS_OK; + + EXEC SQL COMMIT WORK RELEASE; + if (sqlca.sqlcode != 0) + { + IMRD_LM_LOG_ERROR_3("Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Set_Struct_Version(IMRT_Data_Version *Data_Version_Ptr, char *Component_Ptr) +{ + const char sFunctionName []="SDM_SQL_Get_Struct_Version"; + IMRT_Status status; + + EXEC SQL BEGIN DECLARE SECTION; + VARCHAR vVersName[IMRD_SDMD_VERS_NAME_LEN]; + VARCHAR vVersLabel[IMRD_SDMD_VERS_LABEL_LEN]; + VARCHAR vVersDate[IMRD_SDMD_VERS_DATE_LEN]; + + short hIndVersName; + short hIndVersLabel; + short hIndVersDate; + EXEC SQL END DECLARE SECTION; + + + /* initialisation */ + status = IMRS_OK; + + strcpy((char*) vVersName.arr, Component_Ptr); + vVersName.len = strlen((char*) vVersName.arr ); + + memset(vVersLabel.arr, '\0', (size_t) IMRD_SDMD_VERS_LABEL_LEN); + memset(vVersDate.arr, '\0', (size_t) IMRD_SDMD_VERS_DATE_LEN); + + EXEC SQL DECLARE cur_imr_version CURSOR FOR + SELECT VERS_LABEL, VERS_DATE + FROM IMR_DATA_VERSION + WHERE VERS_NAME = :vVersName; + + EXEC SQL OPEN cur_imr_version; + + EXEC SQL FETCH cur_imr_version + INTO :vVersLabel:hIndVersLabel, + :vVersDate:hIndVersDate; + + if (sqlca.sqlcode == 0) + { + if (hIndVersLabel >= 0) + { + strcpy(Data_Version_Ptr->Label, (char*)vVersLabel.arr); + } + else + { + Data_Version_Ptr->Label[0] = '\0'; + } + + if (hIndVersDate >= 0) + { + strcpy(Data_Version_Ptr->Date, (char*)vVersDate.arr); + } + else + { + Data_Version_Ptr->Date[0] = '\0'; + } + } + else + { + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_version; + + return(status); + +} + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + diff --git a/src/libstatic_data_mng/src/arc_hdl_xml.c b/src/libstatic_data_mng/src/arc_hdl_xml.c new file mode 100644 index 0000000..1f2b3dc --- /dev/null +++ b/src/libstatic_data_mng/src/arc_hdl_xml.c @@ -0,0 +1,76 @@ +/*----------------------------------------------------------------------------*/ +/* File: arc_hdl_xml.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _ARC_HDL_XML_C_ + +#include "arc_hdl_xml.h" + + + + + +/*----------------------------------------------------------------------------*/ +/*Raise Error */ +/*ctx : contexte avec lequele la fonction est appelée */ +/*functionname : nom de la focntion qui léve l'erreur */ +/*lib_error : libellé de l'erreur */ +/*code : code de l'erreur */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status SDM_HDR_XML_Init(IMRT_SDM_Flag Flag) +{ + + return(IMRS_OK); + +} + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_HDR_XML_DInit(void) +{ + + return(IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +void SDM_RaiseError(xmlParserCtxt * Ctx_Sax_Ptr, IMRT_Error * Struct_Error_Ptr ,IMRT_Status * Flag_Error , + const char* functionname, const char* lib_error, const int code ) +{ + + fprintf(stderr,"\nRaise error <%s>",lib_error); + Ctx_Sax_Ptr->sax = &ErrorSAXHandlerStruct; + *Flag_Error = IMRS_KO; + Struct_Error_Ptr->errorCode = code; + strcpy(Struct_Error_Ptr->libError,lib_error) ; + strcpy(Struct_Error_Ptr->function,functionname); +} diff --git a/src/libstatic_data_mng/src/arc_hdl_xml.h b/src/libstatic_data_mng/src/arc_hdl_xml.h new file mode 100644 index 0000000..532b540 --- /dev/null +++ b/src/libstatic_data_mng/src/arc_hdl_xml.h @@ -0,0 +1,113 @@ +/*----------------------------------------------------------------------------*/ +/* File: arc_hdl_xml.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _ARC_HDL_XML_H_ +# define _ARC_HDL_XML_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include + + + +# ifdef _ARC_HDL_XML_C_ +/*-----------------------------------------------------------------------------*/ +/*Globale Variable */ +/*-----------------------------------------------------------------------------*/ + + +xmlSAXHandler ErrorSAXHandlerStruct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + NULL, + NULL, + NULL +}; +# else +extern xmlSAXHandler ErrorSAXHandlerStruct; + +# endif +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _ARC_HDL_XML_C_ + +IMRT_Status SDM_HDR_XML_Init(IMRT_SDM_Flag Flag); +IMRT_Status SDM_HDR_XML_DInit(void); +void SDM_RaiseError(xmlParserCtxt * Ctx_Sax_Ptr, IMRT_Error * Struct_Erro_Ptr ,IMRT_Status * Flag_Error , + const char* functionname, const char* lib_error, const int code ); + +# else + +extern IMRT_Status SDM_HDR_XML_Init(IMRT_SDM_Flag Flag); +extern IMRT_Status SDM_HDR_XML_DInit(void); +extern void SDM_RaiseError(xmlParserCtxt * Ctx_Sax_Ptr, IMRT_Error * Struct_Erro_Ptr ,IMRT_Status * Flag_Error , + const char* functionname, const char* lib_error, const int code ); + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/buffer_info_mng.c b/src/libstatic_data_mng/src/buffer_info_mng.c new file mode 100644 index 0000000..20dad2b --- /dev/null +++ b/src/libstatic_data_mng/src/buffer_info_mng.c @@ -0,0 +1,2909 @@ +/*----------------------------------------------------------------------------*/ +/* File: buffer_info_mng.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _BUFFER_INFO_MNG_C_ + +#include "buffer_info_mng.h" + +IMRT_Status SDM_DataStruct_Finalize(NDT_Root *ds_Ptr, NDT_Index_Type *Index_Type_Ptr, short hMaxEntries) +{ + NDT_Status nd_status; + IMRT_Status status; + short Compteur; + + Compteur = 0; + status = IMRS_OK; + + do + { + if (Compteur == 0) + { + nd_status = ND_DataStruct_Convert(ds_Ptr, Index_Type_Ptr); + + if(nd_status != NDS_OK) + { + + status = IMRS_KO; + } + } + else + { + nd_status = ND_Index_Open(ds_Ptr, Compteur, Index_Type_Ptr[Compteur]); + if(nd_status != NDS_OK) + { + + status = IMRS_KO; + } + } + + Compteur = Compteur + 1; + } while((nd_status == NDS_OK)&&(Compteur < hMaxEntries)); + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +void SDM_IniTableCritere(IMRT_Status Table[],const int NbElement) +{ + int i; + for(i =0; iInputAppli != IMRD_APPL_ID_UNKNOWN) && + (Critere->InputAppli != myMapPath->Appl_Input_Ptr->Id) && + (myMapPath->Appl_Input_Ptr->Id != IMRD_APPL_ID_UNKNOWN) + ) + { + CitereTable[SDMD_CRI_IA] = IMRS_KO; + } + if( (Critere->OutputAppli != IMRD_APPL_ID_UNKNOWN ) && + (Critere->OutputAppli != myMapPath->Appl_Output_Ptr->Id) && + (myMapPath->Appl_Output_Ptr->Id != IMRD_APPL_ID_UNKNOWN ) + ) + { + CitereTable[SDMD_CRI_OA] = IMRS_KO; + } + if( (Critere->InputFormat != IMRD_FMT_ID_UNKNOWN) && + (Critere->InputFormat != myMapPath->Fmt_Input_Ptr->Id) && + (myMapPath->Fmt_Input_Ptr->Id != IMRD_FMT_ID_UNKNOWN) + ) + { + CitereTable[SDMD_CRI_IF] = IMRS_KO; + } + if( (Critere->OutputFormat != IMRD_FMT_ID_UNKNOWN) && + (Critere->OutputFormat != myMapPath->Fmt_Output_Ptr->Id) && + (myMapPath->Fmt_Output_Ptr->Id != IMRD_FMT_ID_UNKNOWN) + ) + { + CitereTable[SDMD_CRI_OF] = IMRS_KO; + } + + *Valide=IMRS_OK; + for(indexe =0; indexe Id < Value2_Ptr->Id) + { + return( NDS_LOWER); + } + else + { + if( Value1_Ptr->Id > Value2_Ptr->Id) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + case 1: + { + int rc; + + + rc=strcmp( Value1_Ptr->Name, Value2_Ptr->Name); + + if( rc <0) + { + return( NDS_LOWER); + } + else + { + if( rc > 0) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + + IMRT_Appl *Value_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + fprintf( Out, "Name: (%s) \n", Value_Ptr->Name); + return( NDS_OK); + + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_Appl *Appl_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + fprintf( Out, "INSERT INTO IMR_APPLI(APPLI_ID, APPLI_NAME) VALUES(%d, '%s');\n", + Appl_Ptr->Id, Appl_Ptr->Name); + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_Appl *Appl_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t<%s>\n", IMRD_SDMD_TAG_APPLI); + + fprintf( Out, "\t\t<%s>%s\n", + IMRD_SDMD_TAG_NAME, Appl_Ptr->Name, IMRD_SDMD_TAG_NAME); + + fprintf( Out, "\t\n", IMRD_SDMD_TAG_APPLI); + + return( NDS_OK); + } + + default: + { + IMRD_LM_LOG_ERROR_1( "SDM_Appl_Manager() called with an undefined command %d\n", Command); + return NDS_ERRAPI; + } + } + + + return NDS_OK; +} + + + + +/*----------------------------------------------------------------------------*/ +/* FmtAttr Manager */ +/*----------------------------------------------------------------------------*/ + +NDT_Status SDM_FmtAttr_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + IMRT_Status status; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + *Version_Name_Ptr = "Revision: 2.1 Name: libnode-2_0_4-1 Date: 2002/02/28 22:00:35 Author: agibert "; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + IMRT_FmtAttr *Value_ptr = (IMRT_FmtAttr *)va_arg( Args, IMRT_FmtAttr *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case IMRD_SDMD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + + break; + } + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_FmtAttr **Value_Ptr_Ptr = va_arg( Args, IMRT_FmtAttr **); + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Value_Ptr_Ptr = (IMRT_FmtAttr *)malloc( sizeof(IMRT_FmtAttr))) == NULL) + { + return( NDS_ERRMEM); + } + else + { + SDM_InitFmtAttr(*Value_Ptr_Ptr); + return( NDS_OK); + } + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_FmtAttr *Value_Ptr = (IMRT_FmtAttr *)va_arg( Args, IMRT_FmtAttr *); + Command_Name = "NDD_CMD_VALUE_FREE"; + + free( Value_Ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_FmtAttr *Value1_Ptr = va_arg( Args, IMRT_FmtAttr *); + IMRT_FmtAttr *Value2_Ptr = va_arg( Args, IMRT_FmtAttr *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case 0: + { + if( Value1_Ptr->Id < Value2_Ptr->Id) + { + return( NDS_LOWER); + } + else + { + if( Value1_Ptr->Id > Value2_Ptr->Id) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + case 1: + { + int rc; + + + rc=strcmp( Value1_Ptr->Name, Value2_Ptr->Name); + + if( rc <0) + { + return( NDS_LOWER); + } + else + { + if( rc > 0) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + IMRD_LM_LOG_ERROR_1( "SDM_FmtAttr_Manager Unknown COMP idx (%d) !\n", Index_Id); + + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + + IMRT_FmtAttr *FmtAttr_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + fprintf( Out, "Id: (%d) Name: (%s) Value: (%s) \n", FmtAttr_Ptr->Id, FmtAttr_Ptr->Name, FmtAttr_Ptr->Value); + return( NDS_OK); + + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + IMRT_FmtAttr *FmtAttr_Ptr = Node_Ptr->Value; + + char * FmtAttr_Value_convert_Ptr; + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + FmtAttr_Value_convert_Ptr = (char *) malloc(IMRD_FMTATTR_VALUE_SIZE); + status = SDM_ConvertAttributeInv(FmtAttr_Ptr->Value, FmtAttr_Value_convert_Ptr); + fprintf( Out, "INSERT INTO IMR_FMT_ATTR(FMTATTR_ID, FMTATTR_NAME, FMTATTR_VALUE) VALUES(%d, '%s', '%s');\n", + FmtAttr_Ptr->Id, FmtAttr_Ptr->Name, FmtAttr_Value_convert_Ptr); + free(FmtAttr_Value_convert_Ptr); + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + IMRT_FmtAttr *FmtAttr_Ptr = Node_Ptr->Value; + + char * FmtAttr_Value_convert_Ptr; + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t<%s>\n", IMRD_SDMD_TAG_FMTATTR); + + fprintf( Out, "\t\t<%s>%s\n", + IMRD_SDMD_TAG_NAME, FmtAttr_Ptr->Name, IMRD_SDMD_TAG_NAME); + + FmtAttr_Value_convert_Ptr = (char *) malloc(IMRD_FMTATTR_VALUE_SIZE); + status = SDM_ConvertAttributeInv(FmtAttr_Ptr->Value, FmtAttr_Value_convert_Ptr); + fprintf( Out, "\t\t<%s>%s\n", + IMRD_SDMD_TAG_VALUE, FmtAttr_Value_convert_Ptr, IMRD_SDMD_TAG_VALUE); + + fprintf( Out, "\t\n", IMRD_SDMD_TAG_FMTATTR); + free(FmtAttr_Value_convert_Ptr); + + return( NDS_OK); + } + + default: + { + IMRD_LM_LOG_ERROR_1( "SDM_FmtAttr_Manager() called with an undefined command %d\n", Command); + return NDS_ERRAPI; + } + } + + + return NDS_OK; +} + + + + +/*----------------------------------------------------------------------------*/ +/* FmtMsg Manager */ +/*----------------------------------------------------------------------------*/ + +NDT_Status SDM_FmtMsg_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + NDT_Status status; + IMRT_Status statuscb; + /*static short Num_Ordre=0;*/ + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + *Version_Name_Ptr = "Revision: 2.1 Name: libnode-2_0_4-1 Date: 2002/02/28 22:00:35 Author: agibert "; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + IMRT_FmtMsg * Value_ptr = (IMRT_FmtMsg *)va_arg( Args, IMRT_FmtMsg *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case IMRD_SDMD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + + break; + } + + case IMRD_SDMD_CMD_EXECUTE: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_EXECUTE; + + break; + } + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_FmtMsg **Value_Ptr_Ptr = va_arg( Args, IMRT_FmtMsg **); + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Value_Ptr_Ptr = (IMRT_FmtMsg *)malloc( sizeof(IMRT_FmtMsg))) == NULL) + { + return( NDS_ERRMEM); + } + else + { + SDM_InitFmtMsg(*Value_Ptr_Ptr); + + return( NDS_OK); + } + + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + /*IMRT_Fmt *Value_Ptr = (IMRT_Fmt *)va_arg( Args, IMRT_Fmt *); + + + Command_Name = "NDD_CMD_VALUE_FREE"; + + free( Value_Ptr->FmtAttr_Ptr); + free( Value_Ptr);*/ + + + IMRT_FmtMsg *Value_Ptr = (IMRT_FmtMsg *)va_arg( Args, IMRT_FmtMsg *); + + Command_Name = "NDD_CMD_VALUE_FREE"; + + free( Value_Ptr); + + return( NDS_OK); + + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Msg * Value1_Ptr = (IMRT_Msg *)va_arg( Args, NDT_Node *); + IMRT_Msg * Value2_Ptr = (IMRT_Msg *)va_arg( Args, NDT_Node *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case 0: + { + int rc; + + + rc = strcmp( Value1_Ptr->Name, Value1_Ptr->Name); + + if( rc < 0) + { + return( NDS_LOWER); + } + else + { + if( rc > 0) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + IMRD_LM_LOG_ERROR_1("SDM_FmtMsg_Manager Unknown COMP idx (%d) !\n", Index_Id); + + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + IMRT_FmtMsg *Value_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + fprintf( Out, "\tFmtMsg - Msg Name: (%s) Branche Id: (%d) Attribute: (%s)\n", Value_Ptr->Msg_Ptr->Name, Value_Ptr->Branche_Id, Value_Ptr->FmtAttr_Ptr->Value); + + return( NDS_OK); + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( NDS_OK); + } + case NDD_CMD_EXECUTE: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + va_list user_args = (va_list)va_arg( Args, va_list); + IMRT_SDM_IdentMessage * IdentStruct_Ptr = (IMRT_SDM_IdentMessage *)va_arg(lib_args,IMRT_SDM_IdentMessage *); + + IMRT_FmtMsg *FmtMsg_Ptr = (IMRT_FmtMsg *)Node_Ptr->Value; + IMRT_Msg *Msg_Ptr = (IMRT_Msg *)FmtMsg_Ptr->Msg_Ptr; + + Command_Name = "NDD_CMD_EXECUTE"; + status = NDS_OK; + statuscb = IMRS_OK; + + if (IdentStruct_Ptr->Mode == IMRD_SKIP_MODE) + { + if (IdentStruct_Ptr->Id == Msg_Ptr->Id) + { + IdentStruct_Ptr->Mode = IMRD_NORMALE_MODE; + IdentStruct_Ptr->Branche_Id = FmtMsg_Ptr->Branche_Id; + } + } + else + { + if (FmtMsg_Ptr->Branche_Id == IdentStruct_Ptr->Branche_Id) + { + if(Msg_Ptr->Size != 0 ) + { + statuscb = IdentStruct_Ptr->Ident_Msg_SizeFunc_Ptr(Msg_Ptr->Size); + } + + if(statuscb == IMRS_OK) + { + status = ND_DataStruct_Traverse( Msg_Ptr->Field_Struct_Ptr, IMRD_SDMD_CMD_EXECUTE, stdout, NDD_RECURSIVE_MODE_PARENT, IdentStruct_Ptr); + + if(status == NDS_OK) + { + strcpy( IdentStruct_Ptr->Type, Msg_Ptr->Name); + IdentStruct_Ptr->Id = Msg_Ptr->Id; + status = NDS_IDENT_OK; + } + else if(status == NDS_KO) + { + status = NDS_KO; + } + else + { + status = NDS_OK; + } + } + else if(statuscb == IMRS_NO_IDENT) + { + status = NDS_OK; + } + else + { + status = NDS_KO; + } + } + else + { + status = NDS_NO_IDENT; + } + } + + return (status); + } + + case IMRD_SDMD_CMD_CHECK_FMT_ATTR: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + /*FILE *Out = (FILE *)va_arg( user_args, FILE *);*/ + IMRT_Msg *Msg_Ptr = (IMRT_Msg *)va_arg( user_args, IMRT_Msg *); + IMRT_FmtAttr *FmtAttr_Ptr = (IMRT_FmtAttr *)va_arg( user_args, IMRT_FmtAttr *); + + IMRT_FmtMsg *FmtMsg_Ptr = Node_Ptr->Value; + + Command_Name = "IMRD_SDMD_CMD_CHECK_FMT_ATTR"; + + if((FmtMsg_Ptr->Msg_Ptr == Msg_Ptr) && + (FmtMsg_Ptr->FmtAttr_Ptr == FmtAttr_Ptr)) + { + return( NDS_NODE_FOUND); + } + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + IMRT_Fmt_Id Fmt_Id = (IMRT_Fmt_Id)va_arg( user_args, IMRT_Fmt_Id); + short *Num_Ordre = (short *)va_arg( user_args, short *); + + IMRT_FmtMsg *FmtMsg_Ptr = Node_Ptr->Value; + IMRT_FmtAttr_Id FmtAttr_Id; + + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + *Num_Ordre += 1; + if (FmtMsg_Ptr->FmtAttr_Ptr == NULL) + { + FmtAttr_Id = IMRD_FMTATTR_ID_UNKNOWN; + } + else + { + FmtAttr_Id = FmtMsg_Ptr->FmtAttr_Ptr->Id; + } + + fprintf( Out, "INSERT INTO IMR_FMT_MSG(MSG_ID, FORMAT_ID, FMTATTR_Id, NUM_ORDRE_FMT_MSG, FMTMSG_BRANCHE_ID) VALUES(%d, %d, %d, %d, %d);\n", + FmtMsg_Ptr->Msg_Ptr->Id, Fmt_Id, FmtAttr_Id, *Num_Ordre, FmtMsg_Ptr->Branche_Id); + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_FmtMsg *FmtMsg_Ptr = Node_Ptr->Value; + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t\t<%s>\n", IMRD_SDMD_TAG_FMTMSG); + + fprintf( Out, "\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_NAME, FmtMsg_Ptr->Msg_Ptr->Name, IMRD_SDMD_TAG_NAME); + + fprintf( Out, "\t\t\t<%s>%d\n", + IMRD_SDMD_TAG_BRANCHE_ID, FmtMsg_Ptr->Branche_Id, IMRD_SDMD_TAG_BRANCHE_ID); + + if (FmtMsg_Ptr->FmtAttr_Ptr != NULL) + { + if (strcmp(FmtMsg_Ptr->FmtAttr_Ptr->Name, IMRD_FMTATTR_NAME_UNKNOWN) != 0) + { + fprintf( Out, "\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_FMTATTR_NAME, FmtMsg_Ptr->FmtAttr_Ptr->Name, IMRD_SDMD_TAG_FMTATTR_NAME); + } + } + + + fprintf( Out, "\t\t\n", IMRD_SDMD_TAG_FMTMSG); + + return( NDS_OK); + } + + default: + { + IMRD_LM_LOG_ERROR_1("SDM_FmtMsg_Manager() called with an undefined command %d\n", Command); + + return( NDS_ERRAPI); + } + } + return( NDS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Fmt Manager */ +/*----------------------------------------------------------------------------*/ + +NDT_Status SDM_Fmt_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + NDT_Status status; + IMRT_Status imr_status; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "Revision: 2.1 Name: libnode-2_0_4-1 Date: 2002/02/28 22:00:35 Author: agibert "; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + IMRT_Fmt * Value_ptr = (IMRT_Fmt *)va_arg( Args, IMRT_Fmt *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case IMRD_SDMD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + + break; + } + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Fmt **Value_Ptr_Ptr = va_arg( Args, IMRT_Fmt **); + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Value_Ptr_Ptr = (IMRT_Fmt *)malloc( sizeof(IMRT_Fmt))) == NULL) + { + return( NDS_ERRMEM); + } + else + { + SDM_InitFormat(*Value_Ptr_Ptr); + + if( ( status = ND_DataStruct_Open( &((*Value_Ptr_Ptr)->FmtMsg_Struct_Ptr), IMRD_SDMD_INDEX_NB, index_type_initial_tab, "SDM_FmtMsg_Manager", SDM_FmtMsg_Manager, NULL, NULL, NULL, NULL,0, NULL)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Open() Format failed (%d) !\n", status); + } + return( NDS_OK); + } + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Fmt *Value_Ptr = (IMRT_Fmt *)va_arg( Args, IMRT_Fmt *); + + + Command_Name = "NDD_CMD_VALUE_FREE"; + + if( ( status = ND_DataStruct_Close( Value_Ptr->FmtMsg_Struct_Ptr)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() Format failed (%d) !\n", status); + return( status); + } + free( Value_Ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Fmt *Value1_Ptr = va_arg( Args, IMRT_Fmt *); + IMRT_Fmt *Value2_Ptr = va_arg( Args, IMRT_Fmt *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + + case 0: + { + if( Value1_Ptr->Id < Value2_Ptr->Id) + { + return( NDS_LOWER); + } + else + { + if( Value1_Ptr->Id > Value2_Ptr->Id) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + case 1: + { + int rc; + + + rc=strcmp( Value1_Ptr->Name, Value2_Ptr->Name); + + if( rc <0) + { + return( NDS_LOWER); + } + else + { + if( rc > 0) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + IMRD_LM_LOG_ERROR_1( "Unknown COMP idx (%d) !\n", Index_Id); + + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + + IMRT_Fmt *Value_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + fprintf( Out, "Format - Name: (%s) \n",Value_Ptr->Name); + + return( ND_DataStruct_Value_Print( Out, Value_Ptr->FmtMsg_Struct_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, --Recursive_Depth, ++Recursive_Offset)); + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_EXECUTE: + { /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + IMRT_Fmt * Value_Ptr = (IMRT_Fmt*)Node_Ptr->Value; + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + IMRT_SDMCB_Fmt_Add * FmtProceedFunc = ( IMRT_SDMCB_Fmt_Add *)va_arg(lib_args, IMRT_SDMCB_Fmt_Add *); + + imr_status = FmtProceedFunc(Value_Ptr->Id, Value_Ptr->Name, IMRG_SDM_Base.RootFmt->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + if(imr_status == IMRS_OK) + { + status = NDS_OK; + } + else + { + status = NDS_KO; + } + + return(status); + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_Fmt *Fmt_Ptr = Node_Ptr->Value; + short Num_Ordre=0; + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + fprintf( Out, "INSERT INTO IMR_FORMAT(FORMAT_ID, FORMAT_NAME) VALUES(%d, '%s');\n", + Fmt_Ptr->Id, Fmt_Ptr->Name); + + if( ( status = ND_DataStruct_Traverse( Fmt_Ptr->FmtMsg_Struct_Ptr, IMRD_SDMD_CMD_API_SQL_DUMP, Out, Fmt_Ptr->Id, &Num_Ordre)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Traverse failed (%d)...\n",status); + return(NDS_KO); + } + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_Fmt *Fmt_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t<%s>\n", IMRD_SDMD_TAG_FORMAT); + + fprintf( Out, "\t\t<%s>%s\n", + IMRD_SDMD_TAG_NAME, Fmt_Ptr->Name, IMRD_SDMD_TAG_NAME); + + if( ( status = ND_DataStruct_Traverse( Fmt_Ptr->FmtMsg_Struct_Ptr, IMRD_SDMD_CMD_API_XML_DUMP, Out)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Traverse failed (%d)...\n",status); + return(NDS_KO); + } + + fprintf( Out, "\t\n", IMRD_SDMD_TAG_FORMAT); + + return( NDS_OK); + } + + default: + { + IMRD_LM_LOG_ERROR_1( "SDM_Fmt_Manager() called with an undefined command %d\n", Command); + + return( NDS_ERRAPI); + } + } + + + + return( NDS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* MapCmd Manager */ +/*----------------------------------------------------------------------------*/ + +NDT_Status SDM_MapCmd_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + SDMT_CritereRecChemin * Recherche = NULL; + IMRT_Status statusTmp; + char functioname[] = "SDM_MapCmd_Manager"; + int i; + + + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "Revision: 2.1 Name: libnode-2_0_4-1 Date: 2002/02/28 22:00:35 Author: agibert "; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + IMRT_MapCmd * Value_ptr = (IMRT_MapCmd *)va_arg( Args, IMRT_MapCmd *); + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case IMRD_SDMD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + break; + } + + case IMRD_SDMD_CMD_EXECUTE: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_EXECUTE; + break; + } + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + break; + } + } + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_MapCmd **Value_Ptr_Ptr = va_arg( Args, IMRT_MapCmd **); + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Value_Ptr_Ptr = (IMRT_MapCmd *)malloc( sizeof(IMRT_MapCmd))) == NULL) + { + return( NDS_ERRMEM); + } + else + { + SDM_InitMapCmd( *Value_Ptr_Ptr); + return( NDS_OK); + } + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_MapCmd *Value_Ptr = (IMRT_MapCmd *)va_arg( Args, IMRT_MapCmd *); + + Command_Name = "NDD_CMD_VALUE_FREE"; + + free(Value_Ptr->Jump_Tab); + free( Value_Ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_MapCmd *Value1_Ptr = va_arg( Args, IMRT_MapCmd *); + IMRT_MapCmd *Value2_Ptr = va_arg( Args, IMRT_MapCmd *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case 0: + { + if( Value1_Ptr->MapCmd_IdMapCmd_Id) + { + return( NDS_LOWER); + } + else + { + if( Value1_Ptr->MapCmd_Id > Value2_Ptr->MapCmd_Id) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + IMRD_LM_LOG_ERROR_1( "Unknown COMP idx (%d) !\n", Index_Id); + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + + IMRT_MapCmd *Value_Ptr = Node_Ptr->Value; + char Local_Ident_Total; + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + if( Value_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_MAP) + { + fprintf( Out,"type_commande (mapper)\n"); + } + else if( Value_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_COPY) + { + fprintf( Out,"type_commande (copier)\n"); + } + else if( Value_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_IDENT) + { + fprintf( Out,"type_commande (identifier)\n"); + } + else if( Value_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_GOTO) + { + fprintf( Out,"type_commande (go_to)\n"); + } + + if (Value_Ptr->Ident_Total == IMRD_TRUE) + { + Local_Ident_Total = IMRD_YES; + } + else + { + Local_Ident_Total = IMRD_NO; + } + + fprintf( Out, "IdMapCmd: (%d) Ident_Total: (%c) InputFormat: (%s) InputFormat_Attr: (%s) OutputFormat: (%s) OutputFormat_Attr: (%s) \n Branche_id (%d) OutputBuffer: (%d) InputBuffer : (%d) MappingRule: (%s) NumBufferToIdent (%d) \n", + Value_Ptr->MapCmd_Id, Local_Ident_Total, Value_Ptr->Fmt_Input_Ptr->Name, Value_Ptr->FmtAttr_Input_Ptr->Value, + Value_Ptr->Fmt_Output_Ptr->Name,Value_Ptr->FmtAttr_Output_Ptr->Value, Value_Ptr->Branche_Id, + Value_Ptr->Buffer_Id_Input,Value_Ptr->Buffer_Id_Output, + Value_Ptr->MsgMap_Ptr->Name , Value_Ptr->Buffer_Id_Ident); + + return( NDS_OK); + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( NDS_OK); + } + + case NDD_CMD_EXECUTE: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + IMRT_MapCmd * Value_Ptr = (IMRT_MapCmd*)Node_Ptr->Value; + IMRT_Status statuscb; + int branche =-1; + IMRT_Fmt_Id Format; + NDT_Status status; + NDT_Node *node_ptr_input; + NDT_Node *node_ptr_output; + IMRT_Msg_Id BufferType; + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + va_list user_args = (va_list)va_arg( Args, va_list); + SDMT_CritereRecChemin *Recherche = (SDMT_CritereRecChemin *)va_arg(lib_args,SDMT_CritereRecChemin *); + IMRT_Mode_Traverse * Mode_Normal_Erreur_Ptr = (IMRT_Mode_Traverse *)va_arg(lib_args, IMRT_Mode_Traverse *); + + + Command_Name = "NDD_CMD_EXECUTE"; + statuscb = IMRS_OK; + + if(Value_Ptr->Branche_Id == Recherche->Branche_id) + { + switch(Value_Ptr->TypeCmd) + { + case IMRD_MAPCMD_TYPE_MAP: + { + statuscb = Recherche->CallBackBCommandeMap(Value_Ptr->Buffer_Id_Output , + Value_Ptr->Fmt_Output_Ptr->Id, + ( (Value_Ptr->FmtAttr_Output_Ptr == NULL) ? NULL : Value_Ptr->FmtAttr_Output_Ptr->Value), + Value_Ptr->Buffer_Id_Input, + Value_Ptr->Fmt_Input_Ptr->Id , + ( (Value_Ptr->FmtAttr_Input_Ptr == NULL) ? NULL : Value_Ptr->FmtAttr_Input_Ptr->Value), + Value_Ptr->MsgMap_Ptr , + Value_Ptr->Clear_Flag); + break; + } + + case IMRD_MAPCMD_TYPE_COPY: + { + statuscb = Recherche->CallBackCommandeCopy(Value_Ptr->Buffer_Id_Output, Value_Ptr->Buffer_Id_Input); + break; + } + + case IMRD_MAPCMD_TYPE_IDENT: + { + IMRT_Status found = IMRS_KO; + Format = IMRD_FMT_ID_UNKNOWN; + BufferType = Value_Ptr->Ident_First_Msg_Ptr->Id; + statuscb = Recherche->CallBackCommandeIdent(&Format, + &BufferType, + Value_Ptr->Buffer_Id_Ident, + Value_Ptr->Ident_Total); + if(statuscb == IMRS_OK) + { + for(i=0; iJmpTbleNbElts; i++) + { + if ((Format == Value_Ptr->Jump_Tab[i].Fmt_Ptr->Id) && + (BufferType == Value_Ptr->Jump_Tab[i].Msg_Ptr->Id)) + { + Recherche->Branche_id = Value_Ptr->Jump_Tab[i].Branche_Id; + found = IMRS_OK; + } + } + + if(found == IMRS_KO) + { + statuscb = IMRS_KO; + } + } + + break; + } + + case IMRD_MAPCMD_TYPE_GOTO: + { + Recherche->Branche_id = Value_Ptr->Goto_Branche_Id; + + break; + } + + default: + { + strcpy(Recherche->FataError.function,functioname); + Recherche->FataError.errorCode = SDMD_CODE_ERROR_7; + strcpy(Recherche->FataError.libError,SDMD_LIB_ERROR_7); + + return( NDS_KO); + } + } + + if (*Mode_Normal_Erreur_Ptr == IMRD_NORMALE_MODE) + { + if (statuscb != IMRS_OK) + { + *Mode_Normal_Erreur_Ptr = IMRD_ERREUR_MODE; + Recherche->Branche_id = IMRD_LATEST_BRANCHE; + } + } + } + + return( NDS_OK); + } + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + int MapPath_Id = (int)va_arg( user_args, int); + IMRT_MapCmd *MapCmd_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + fprintf( Out, "INSERT INTO IMR_MAPCMD(MAPCMD_ID, MAPCMD_TYPE, CURRENT_BRANCHE_ID) VALUES(%d, %d, %d);\n", + MapCmd_Ptr->MapCmd_Id, MapCmd_Ptr->TypeCmd, MapCmd_Ptr->Branche_Id); + + fprintf( Out, "INSERT INTO IMR_CMD_MAP_PATH(MAP_PATH_ID, MAPCMD_ID) VALUES(%d, %d);\n", + MapPath_Id, MapCmd_Ptr->MapCmd_Id); + + if(MapCmd_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_IDENT) + { + if(MapCmd_Ptr->Ident_Total == IMRD_FALSE) + { + fprintf( Out, "INSERT INTO IMR_CMD_IDENT(MAPCMD_ID, IDENT_BUFFER_ID, IDENT_TOTAL, IDENT_FIRST_MSG_ID) VALUES(%d, %d, '%c', %d);\n", + MapCmd_Ptr->MapCmd_Id, MapCmd_Ptr->Buffer_Id_Ident, IMRD_NO, MapCmd_Ptr->Ident_First_Msg_Ptr->Id); + } + else + { + fprintf( Out, "INSERT INTO IMR_CMD_IDENT(MAPCMD_ID, IDENT_BUFFER_ID, IDENT_TOTAL, IDENT_FIRST_MSG_ID) VALUES(%d, %d, '%c', %d);\n", + MapCmd_Ptr->MapCmd_Id, MapCmd_Ptr->Buffer_Id_Ident, IMRD_YES, MapCmd_Ptr->Ident_First_Msg_Ptr->Id); + } + + for(i=0; iJmpTbleNbElts; i++) + { + fprintf( Out, "INSERT INTO IMR_JUMP_TABLE(MAPCMD_ID, MSG_ID, FORMAT_ID, NUM_ORDRE_JUMP, IDENT_BRANCHE_ID) VALUES(%d, %d, %d, %d, %d);\n", + MapCmd_Ptr->MapCmd_Id, MapCmd_Ptr->Jump_Tab[i].Msg_Ptr->Id, MapCmd_Ptr->Jump_Tab[i].Fmt_Ptr->Id, i, MapCmd_Ptr->Jump_Tab[i].Branche_Id); + } + + } + else if(MapCmd_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_MAP) + { + fprintf( Out, "INSERT INTO IMR_CMD_MAP(MAPCMD_ID, FORMAT_IN_ID, FMTATTR_IN_ID, FORMAT_OUT_ID, FMTATTR_OUT_ID, MSG_MAP_ID, MAP_BUFFER_ID_INPUT, MAP_BUFFER_ID_OUTPUT, CLEAR_FLAG) VALUES(%d, %d, %d, %d, %d, %d, %d, %d, %d);\n", + MapCmd_Ptr->MapCmd_Id, MapCmd_Ptr->Fmt_Input_Ptr->Id, MapCmd_Ptr->FmtAttr_Input_Ptr->Id, MapCmd_Ptr->Fmt_Output_Ptr->Id, MapCmd_Ptr->FmtAttr_Output_Ptr->Id, + MapCmd_Ptr->MsgMap_Ptr->Id, MapCmd_Ptr->Buffer_Id_Input, MapCmd_Ptr->Buffer_Id_Output, MapCmd_Ptr->Clear_Flag); + } + else if(MapCmd_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_COPY) + { + fprintf( Out, "INSERT INTO IMR_CMD_COPY(MAPCMD_ID, COPY_BUFFER_ID_INPUT, COPY_BUFFER_ID_OUTPUT) VALUES(%d, %d, %d);\n", + MapCmd_Ptr->MapCmd_Id, MapCmd_Ptr->Buffer_Id_Input, MapCmd_Ptr->Buffer_Id_Output); + } + else if(MapCmd_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_GOTO) + { + fprintf( Out, "INSERT INTO IMR_CMD_GOTO(MAPCMD_ID, GOTO_BRANCHE_ID) VALUES(%d, %d);\n", + MapCmd_Ptr->MapCmd_Id, MapCmd_Ptr->Goto_Branche_Id); + } + + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_MapCmd *MapCmd_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t\t\t<%s>\n", IMRD_SDMD_TAG_MAPCMD); + + fprintf( Out, "\t\t\t\t<%s>%d\n", + IMRD_SDMD_TAG_BRANCHE_ID, MapCmd_Ptr->Branche_Id, IMRD_SDMD_TAG_BRANCHE_ID); + + if(MapCmd_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_IDENT) + { + fprintf( Out, "\t\t\t\t<%s>\n", IMRD_SDMD_TAG_IDENTIFIER); + + fprintf( Out, "\t\t\t\t\t<%s>%d\n", + IMRD_SDMD_TAG_NUMBUFFER, MapCmd_Ptr->Buffer_Id_Ident, IMRD_SDMD_TAG_NUMBUFFER); + + if(MapCmd_Ptr->Ident_Total == IMRD_FALSE) + { + fprintf( Out, "\t\t\t\t\t<%s>%c\n", + IMRD_SDMD_TAG_IDENTTOTAL, IMRD_NO, IMRD_SDMD_TAG_IDENTTOTAL); + } + else + { + fprintf( Out, "\t\t\t\t\t<%s>%c\n", + IMRD_SDMD_TAG_IDENTTOTAL, IMRD_YES, IMRD_SDMD_TAG_IDENTTOTAL); + } + + if(MapCmd_Ptr->Ident_First_Msg_Ptr != NULL) + { + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_TYPE, MapCmd_Ptr->Ident_First_Msg_Ptr->Name, IMRD_SDMD_TAG_TYPE); + } + + for(i=0; iJmpTbleNbElts; i++) + { + fprintf( Out, "\t\t\t\t\t<%s>\n", IMRD_SDMD_TAG_GO_TO); + fprintf( Out, "\t\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_FORMAT, MapCmd_Ptr->Jump_Tab[i].Fmt_Ptr->Name, IMRD_SDMD_TAG_FORMAT); + + fprintf( Out, "\t\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_TYPE, MapCmd_Ptr->Jump_Tab[i].Msg_Ptr->Name, IMRD_SDMD_TAG_TYPE); + + fprintf( Out, "\t\t\t\t\t\t<%s>%d\n", + IMRD_SDMD_TAG_BRANCHE_ID, MapCmd_Ptr->Jump_Tab[i].Branche_Id, IMRD_SDMD_TAG_BRANCHE_ID); + fprintf( Out, "\t\t\t\t\t\n", IMRD_SDMD_TAG_GO_TO); + } + + fprintf( Out, "\t\t\t\t\n", IMRD_SDMD_TAG_IDENTIFIER); + } + else if(MapCmd_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_MAP) + { + fprintf( Out, "\t\t\t\t<%s>\n", IMRD_SDMD_TAG_MAPPER); + + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_INPUTFORMAT, MapCmd_Ptr->Fmt_Input_Ptr->Name, IMRD_SDMD_TAG_INPUTFORMAT); + + if(strcmp(MapCmd_Ptr->FmtAttr_Input_Ptr->Value, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_INPUTFORMAT_ATTR, MapCmd_Ptr->FmtAttr_Input_Ptr->Name, IMRD_SDMD_TAG_INPUTFORMAT_ATTR); + } + + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_OUTPUTFORMAT, MapCmd_Ptr->Fmt_Output_Ptr->Name, IMRD_SDMD_TAG_OUTPUTFORMAT); + + if(strcmp(MapCmd_Ptr->FmtAttr_Output_Ptr->Value, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_OUTPUTFORMAT_ATTR, MapCmd_Ptr->FmtAttr_Output_Ptr->Name, IMRD_SDMD_TAG_OUTPUTFORMAT_ATTR); + } + + fprintf( Out, "\t\t\t\t\t<%s>%d\n", + IMRD_SDMD_TAG_INPUTBUFFER, MapCmd_Ptr->Buffer_Id_Input, IMRD_SDMD_TAG_INPUTBUFFER); + + fprintf( Out, "\t\t\t\t\t<%s>%d\n", + IMRD_SDMD_TAG_OUTPUTBUFFER, MapCmd_Ptr->Buffer_Id_Output, IMRD_SDMD_TAG_OUTPUTBUFFER); + + if(MapCmd_Ptr->Clear_Flag != 0) + { + fprintf( Out, "\t\t\t\t\t<%s>%d\n", + IMRD_SDMD_TAG_CLEARFLAG, MapCmd_Ptr->Clear_Flag, IMRD_SDMD_TAG_CLEARFLAG); + } + + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_MSGMAP, MapCmd_Ptr->MsgMap_Ptr->Name, IMRD_SDMD_TAG_MSGMAP); + + fprintf( Out, "\t\t\t\t\n", IMRD_SDMD_TAG_MAPPER); + } + else if(MapCmd_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_COPY) + { + fprintf( Out, "\t\t\t\t<%s>\n", IMRD_SDMD_TAG_COPIE); + + fprintf( Out, "\t\t\t\t\t<%s>%d\n", + IMRD_SDMD_TAG_INPUTBUFFER, MapCmd_Ptr->Buffer_Id_Input, IMRD_SDMD_TAG_INPUTBUFFER); + + fprintf( Out, "\t\t\t\t\t<%s>%d\n", + IMRD_SDMD_TAG_OUTPUTBUFFER, MapCmd_Ptr->Buffer_Id_Output, IMRD_SDMD_TAG_OUTPUTBUFFER); + + fprintf( Out, "\t\t\t\t\n", IMRD_SDMD_TAG_COPIE); + } + else if(MapCmd_Ptr->TypeCmd == IMRD_MAPCMD_TYPE_GOTO) + { + fprintf( Out, "\t\t\t\t<%s>\n", IMRD_SDMD_TAG_GO_TO); + + fprintf( Out, "\t\t\t\t\t<%s>%d\n", + IMRD_SDMD_TAG_BRANCHE_ID, MapCmd_Ptr->Goto_Branche_Id, IMRD_SDMD_TAG_BRANCHE_ID); + + fprintf( Out, "\t\t\t\t\n", IMRD_SDMD_TAG_GO_TO); + } + + fprintf( Out, "\t\t\t\n", IMRD_SDMD_TAG_MAPCMD); + + return( NDS_OK); + } + + default: + { + IMRD_LM_LOG_ERROR_1( "with an undefined command %d\n", Command); + + return( NDS_ERRAPI); + } + } + + return( NDS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* MapPath Manager */ +/*----------------------------------------------------------------------------*/ + +NDT_Status SDM_MapPath_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + NDT_Status status; + SDMT_CritereRecChemin *Recherche = NULL; + IMRT_Status TableCritere[SDMD_NB_CRITERE_CHEMIN]; + IMRT_Status Valide; + char functioname[] = "Manager_MapPath"; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "Revision: 2.1 Name: libnode-2_0_4-1 Date: 2002/02/28 22:00:35 Author: agibert "; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + IMRT_MapPath *Value_ptr = (IMRT_MapPath *)va_arg( Args, IMRT_MapPath *); + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case IMRD_SDMD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + break; + } + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + break; + } + } + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_MapPath **Value_Ptr_Ptr = va_arg( Args, IMRT_MapPath **); + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Value_Ptr_Ptr = (IMRT_MapPath *)malloc( sizeof(IMRT_MapPath))) == NULL) + { + return(NDS_ERRMEM); + } + else + { + SDM_InitMapPath(*Value_Ptr_Ptr); + if( ( status = ND_DataStruct_Open( &(*Value_Ptr_Ptr)->MapCmd_Struct_Ptr, IMRD_SDMD_INDEX_NB, index_type_initial_tab, "SDM_MapCmd_Manager", SDM_MapCmd_Manager, NULL, NULL, NULL, NULL,0,NULL)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Open() MapCmd failed (%d) !\n", status); + return(NDS_KO); + } + + return( NDS_OK); + } + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_MapPath *Value_Ptr = (IMRT_MapPath *)va_arg( Args, IMRT_MapPath *); + + Command_Name = "NDD_CMD_VALUE_FREE"; + if(Value_Ptr->MapCmd_Struct_Ptr != NULL) + { if( ( status = ND_DataStruct_Close(Value_Ptr->MapCmd_Struct_Ptr)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !\n", status); + return(status); + } + } + + free( Value_Ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + IMRT_MapPath *Value1_Ptr = va_arg( Args, IMRT_MapPath *); + IMRT_MapPath *Value2_Ptr = va_arg( Args, IMRT_MapPath *); + va_list user_args = (va_list)va_arg( Args, va_list); + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case 0: + { + if( Value1_Ptr->idMapPath< Value2_Ptr->idMapPath) + { + return(NDS_LOWER); + } + else + { + if( Value1_Ptr->idMapPath > Value2_Ptr->idMapPath) + { + return(NDS_GREATER); + } + else + { + return(NDS_EQUAL); + } + } + } + + default: + { + IMRD_LM_LOG_ERROR_1( "Unknown COMP idx (%d) !\n", Index_Id); + return( NDS_KO); + } + } /* end switch */ + + return( NDS_OK); + + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + + IMRT_MapPath *Value_Ptr = Node_Ptr->Value; + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + + fprintf( Out, "idMapPath: (%d) InputFormat: (%s) OutputFormat: (%s) InputAppli: (%s) OutputAppli: (%s) \n", + Value_Ptr->idMapPath, + Value_Ptr->Fmt_Input_Ptr->Name, + Value_Ptr->Fmt_Output_Ptr->Name, + Value_Ptr->Appl_Input_Ptr->Name, + Value_Ptr->Appl_Output_Ptr->Name); + + return( ND_DataStruct_Value_Print( Out, Value_Ptr->MapCmd_Struct_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, --Recursive_Depth, ++Recursive_Offset)); + + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode =(NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + + IMRT_MapPath *MapPath_Ptr = Node_Ptr->Value; + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( ND_DataStruct_Info_Print( Out, MapPath_Ptr->MapCmd_Struct_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, --Recursive_Depth, ++Recursive_Offset)); + } + case NDD_CMD_FIND_MAPPATH: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + + + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + SDMT_CritereRecChemin *Recherche = (SDMT_CritereRecChemin *)va_arg( user_args, SDMT_CritereRecChemin *); + + IMRT_MapPath *Value_Ptr = Node_Ptr->Value; + IMRT_Mode_Traverse Mode_Normal_Erreur = IMRD_NORMALE_MODE; + + Command_Name = "NDD_CMD_FIND_MAPPATH"; + + SDM_CompareCritereMapPath(TableCritere, SDMD_NB_CRITERE_CHEMIN,Recherche, Value_Ptr, &Valide); + /*le chemin de mappin vérifie les critére de la demande + on va traverser la structure MapCmd qui contient toutes + les commandes pour le chemin de mapping sélectionné + */ + if(Valide == IMRS_OK) + { + + IMRD_LM_LOG_TRACE_1( IMRD_LOG_LEVEL_VERBOSE_1, "Mappath match Id : <%d>", Value_Ptr->idMapPath); + status = (IMRT_Status)ND_DataStruct_Traverse( Value_Ptr->MapCmd_Struct_Ptr, IMRD_SDMD_CMD_EXECUTE, stdout, NDD_RECURSIVE_MODE_PARENT,Recherche, &Mode_Normal_Erreur); + if ((status != NDS_OK) || (Mode_Normal_Erreur != IMRD_NORMALE_MODE)) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Traverse() failed (%d) !\n", status); + return(NDS_KO); + } + + return(NDS_NODE_FOUND); + } + return (NDS_OK); + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_MapPath *MapPath_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + fprintf( Out, "INSERT INTO IMR_MAPPATH(MAP_PATH_ID, APPLI_IN_ID, APPLI_OUT_ID, FORMAT_IN_ID, FORMAT_OUT_ID) VALUES(%d, %d, %d, %d, %d);\n", + MapPath_Ptr->idMapPath, MapPath_Ptr->Appl_Input_Ptr->Id, MapPath_Ptr->Appl_Output_Ptr->Id, MapPath_Ptr->Fmt_Input_Ptr->Id, MapPath_Ptr->Fmt_Output_Ptr->Id); + + if( ( status = ND_DataStruct_Traverse( MapPath_Ptr->MapCmd_Struct_Ptr, IMRD_SDMD_CMD_API_SQL_DUMP, Out, MapPath_Ptr->idMapPath)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Traverse failed (%d)...\n",status); + return(NDS_KO); + } + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_MapPath *MapPath_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t<%s>\n", IMRD_SDMD_TAG_MAPPATH); + + fprintf( Out, "\t\t<%s>%s\n", + IMRD_SDMD_TAG_INPUTAPPLI, MapPath_Ptr->Appl_Input_Ptr->Name, IMRD_SDMD_TAG_INPUTAPPLI); + + fprintf( Out, "\t\t<%s>%s\n", + IMRD_SDMD_TAG_OUTPUTAPPLI, MapPath_Ptr->Appl_Output_Ptr->Name, IMRD_SDMD_TAG_OUTPUTAPPLI); + + fprintf( Out, "\t\t<%s>%s\n", + IMRD_SDMD_TAG_INPUTFORMAT, MapPath_Ptr->Fmt_Input_Ptr->Name, IMRD_SDMD_TAG_INPUTFORMAT); + + fprintf( Out, "\t\t<%s>%s\n", + IMRD_SDMD_TAG_OUTPUTFORMAT, MapPath_Ptr->Fmt_Output_Ptr->Name, IMRD_SDMD_TAG_OUTPUTFORMAT); + + + if( ( status = ND_DataStruct_Traverse( MapPath_Ptr->MapCmd_Struct_Ptr, IMRD_SDMD_CMD_API_XML_DUMP, Out)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Traverse failed (%d)...\n",status); + return(NDS_KO); + } + + fprintf( Out, "\t\n", IMRD_SDMD_TAG_MAPPATH); + + return( NDS_OK); + } + + default: + { + IMRD_LM_LOG_ERROR_1("called with an undefined command %d\n", Command); + + return( NDS_ERRAPI); + } + } + + return( NDS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_BufferInfo_Init(IMRT_SDM_Config * Lib_Config_Ptr) +{ + IMRT_Status status; + + if(Lib_Config_Ptr->Flag == IMRD_SDM_FLAG_XML) + { + status = SDM_XML_BufferInfo_Init(Lib_Config_Ptr->Lib_Path); + } + else + { +#ifdef ORACLE_SUPPORT + status = SDM_SQL_BufferInfo_Init(); +#else + status = IMRS_OK; +#endif /* ORACLE_SUPPORT */ + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_Close_RootMapPath(void) +{ + IMRT_Status status; + NDT_Status nd_status; + + status = IMRS_OK; + + if(IMRG_SDM_Base.RootMapPath != NULL) + { + if (IMRG_SDM_Base.RootMapPath->User_Ptr != NULL) + { + free(IMRG_SDM_Base.RootMapPath->User_Ptr); + } + + if( ( nd_status = ND_DataStruct_Close(IMRG_SDM_Base.RootMapPath)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "RootMapPath ND_DataStruct_Close() failed (%d) !\n", nd_status); + status = IMRS_KO; + } + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_Close_RootAppl(void) +{ + IMRT_Status status; + NDT_Status nd_status; + + status = IMRS_OK; + + if(IMRG_SDM_Base.RootAppl != NULL) + { + if (IMRG_SDM_Base.RootAppl->User_Ptr != NULL) + { + free(IMRG_SDM_Base.RootAppl->User_Ptr); + } + + if( ( nd_status = ND_DataStruct_Close(IMRG_SDM_Base.RootAppl)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1("ND_DataStruct_Close() failed (%d) !\n", nd_status); + status = IMRS_KO; + } + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_Close_RootFmtAttr(void) +{ + IMRT_Status status; + NDT_Status nd_status; + + status = IMRS_OK; + + if(IMRG_SDM_Base.RootFmtAttr != NULL) + { + if (IMRG_SDM_Base.RootFmtAttr->User_Ptr != NULL) + { + free(IMRG_SDM_Base.RootFmtAttr->User_Ptr); + } + + if( ( nd_status = ND_DataStruct_Close(IMRG_SDM_Base.RootFmtAttr)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1("ND_DataStruct_Close() failed (%d) !\n", nd_status); + status = IMRS_KO; + } + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_Close_RootFmt(void) +{ + IMRT_Status status; + NDT_Status nd_status; + + status = IMRS_OK; + + if(IMRG_SDM_Base.RootFmt != NULL) + { + if (IMRG_SDM_Base.RootFmt->User_Ptr != NULL) + { + free(IMRG_SDM_Base.RootFmt->User_Ptr); + } + + if( ( nd_status = ND_DataStruct_Close(IMRG_SDM_Base.RootFmt)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !\n", nd_status); + status = IMRS_KO; + } + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_BufferInfo_DInit(void) +{ + IMRT_Status status, StatusMapPath, StatusAppl, StatusFmtAttr, StatusFmt; + + status = IMRS_OK; + + StatusMapPath = SDM_Close_RootMapPath(); + StatusAppl = SDM_Close_RootAppl(); + StatusFmtAttr = SDM_Close_RootFmtAttr(); + StatusFmt = SDM_Close_RootFmt(); + + if((StatusMapPath == IMRS_KO)||(StatusAppl == IMRS_KO)||(StatusFmtAttr == IMRS_KO)||(StatusFmt == IMRS_KO)) + { + status = IMRS_KO; + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_MapPath_Proceed( IMRT_Appl_Id Appl_Id_Target, IMRT_Fmt_Id Fmt_Id_Target, IMRT_Msg_Id Msg_Id_Target, + IMRT_Appl_Id ApplId_Src, IMRT_Fmt_Id Fmt_Id_Src, IMRT_Msg_Id Msg_Id_Src, + IMRT_SDMCB_Buffer_Map *CCB_Buffer_Map_Ptr, + IMRT_SDMCB_Buffer_Copy *CCB_Buffer_Copy_Ptr, + IMRT_SDMCB_Buffer_Ident *CCB_Buffer_Ident_Ptr) + +{ + SDMT_CritereRecChemin Recherche; + NDT_Node * node_ptr; + IMRT_Status status; + IMRT_MapPath mymappath; + + Recherche.Branche_id = 0; + Recherche.InputAppli = ApplId_Src; + Recherche.OutputAppli= Appl_Id_Target; + Recherche.InputFormat = Fmt_Id_Src; + Recherche.OutputFormat = Fmt_Id_Target; + Recherche.InputType = Msg_Id_Src; + Recherche.OutputType = Msg_Id_Target; + Recherche.CallBackCommandeIdent = CCB_Buffer_Ident_Ptr; + Recherche.CallBackBCommandeMap = CCB_Buffer_Map_Ptr; + Recherche.CallBackCommandeCopy = CCB_Buffer_Copy_Ptr; + + status = (IMRT_Status)ND_DataStruct_Traverse( IMRG_SDM_Base.RootMapPath, NDD_CMD_FIND_MAPPATH, stdout,&Recherche); + + if(status != NDS_NODE_FOUND) + { + status = IMRS_KO; + } + else + { + status = IMRS_OK; + } + return(status); +} + +IMRT_Status SDM_MsgIdent_Proceed( IMRT_Fmt_Id Fmt_Id, IMRT_Msg_Id *Msg_Id, IMRT_SDMCB_Ident_Field_Value *CCB_Ident_Field_Value_Ptr, IMRT_SDMCB_Ident_Field_Exist *CCB_Ident_Field_Exist_Ptr, IMRT_SDMCB_Ident_Msg_Size *CCB_Ident_Msg_Size_Ptr) +{ +/*IMRT_SDMCB_Field_Ident *CCB_Field_Ident_Ptr*/ + + IMRT_Status status; + IMRT_Fmt Fmt; + IMRT_Fmt * Fmt2; + NDT_Root * FmtMsg_Ptr ; + NDT_Node * node_ptr; + IMRT_SDM_IdentMessage Struct_Indent; + char functionname [] = "IMR_IdentificationMessage"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + + Struct_Indent.Ident_Msg_SizeFunc_Ptr = CCB_Ident_Msg_Size_Ptr; + Struct_Indent.Ident_Field_ExistFunc_Ptr = CCB_Ident_Field_Exist_Ptr; + Struct_Indent.Ident_Field_ValueFunc_Ptr = CCB_Ident_Field_Value_Ptr; + + Struct_Indent.Id = *Msg_Id; + Struct_Indent.Mode = IMRD_SKIP_MODE; + + + /*recherche de la liste des message en fonction du format*/ + Fmt.Id = Fmt_Id; + if((status = (IMRT_Status)ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmt, + IMRD_SDMD_FMT_IDX_ID, &Fmt, NULL)) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_LIB_ERROR_8,Fmt.Id); + status = IMRS_KO; + } + else + { + Fmt2 = (IMRT_Fmt *)node_ptr->Value; + FmtMsg_Ptr = Fmt2->FmtMsg_Struct_Ptr; + status = (IMRT_Status)ND_DataStruct_Traverse( FmtMsg_Ptr, IMRD_SDMD_CMD_EXECUTE, stdout, NDD_RECURSIVE_MODE_PARENT,&Struct_Indent); + + if(status == (IMRT_Status)NDS_IDENT_OK) + { + *Msg_Id = Struct_Indent.Id; + status = IMRS_OK; + } + else if((status == (IMRT_Status)NDS_KO)) + { + status = IMRS_KO; + snprintf(DescErr,sizeof(DescErr),SDMD_LIB_ERROR_9,Fmt.Name); + } + else + { + *Msg_Id = IMRD_MSG_ID_UNKNOWN; + status = IMRS_OK; + } + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_Fmt_Proceed( IMRT_SDMCB_Fmt_Add *CCB_Fmt_Add_Ptr) +{ + + IMRT_Status status; + NDT_Status nd_status; + + status = IMRS_OK; + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootFmt, IMRD_SDMD_CMD_EXECUTE, stdout, NDD_RECURSIVE_MODE_PARENT, CCB_Fmt_Add_Ptr)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1("ND_DataStruct_Traverse() failed (%d) !\n", nd_status); + status = IMRS_KO; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +void SDM_InitMapCmd(IMRT_MapCmd * mymapcmd) +{ + int i; + mymapcmd->MapCmd_Id = 0; + mymapcmd->TypeCmd = IMRD_MAPCMD_TYPE_UNKNOWN; + mymapcmd->Fmt_Input_Ptr = NULL; + mymapcmd->FmtAttr_Input_Ptr = NULL; + mymapcmd->Fmt_Output_Ptr = NULL; + mymapcmd->FmtAttr_Output_Ptr = NULL; + mymapcmd->Branche_Id = -1; + mymapcmd->Buffer_Id_Input = -1; + mymapcmd->Buffer_Id_Output = -1; + mymapcmd->MsgMap_Ptr = NULL; + mymapcmd->Buffer_Id_Ident = -1; + mymapcmd->Clear_Flag = 0; + mymapcmd->Goto_Branche_Id = -1; + mymapcmd->Ident_Total = IMRD_TRUE; + mymapcmd->Ident_First_Msg_Ptr = NULL; + mymapcmd->JmpTbleNbElts = 0; + mymapcmd->Jump_Tab = NULL; + /*for( i =0 ; iJump_Tab[i].Fmt_Ptr = NULL; + mymapcmd->Jump_Tab[i].Msg_Ptr = NULL; + mymapcmd->Jump_Tab[i].Branche_Id = -1; + } */ + +} + + +void SDM_InitMapPath(IMRT_MapPath * mymappath) +{ + mymappath->idMapPath = 0; + mymappath->Fmt_Input_Ptr = NULL; + mymappath->Fmt_Output_Ptr = NULL; + mymappath->Appl_Input_Ptr = NULL; + mymappath->Appl_Output_Ptr = NULL; + mymappath->MapCmd_Struct_Ptr =NULL; +} + +void SDM_InitFormat(IMRT_Fmt * myformat) +{ + myformat->Id= IMRD_FMT_ID_UNKNOWN; + memset(myformat->Name,0,sizeof(myformat->Name)); +} + +void SDM_InitFmtAttr(IMRT_FmtAttr * myFmtAttr) +{ + myFmtAttr->Id = IMRD_FMTATTR_ID_UNKNOWN; + strcpy(myFmtAttr->Name, IMRD_FMTATTR_NAME_UNKNOWN); + memset(myFmtAttr->Value,'\0',sizeof(myFmtAttr->Value)); +} + +void SDM_InitFmtMsg(IMRT_FmtMsg * myFmtMsg) +{ + myFmtMsg->Msg_Ptr = NULL; + myFmtMsg->Branche_Id = IMRD_BRANCHE_ID_UNKNOWN; + myFmtMsg->FmtAttr_Ptr = NULL; +} + + +void SDM_InitAppl(IMRT_Appl * Appl_Ptr) +{ + Appl_Ptr->Id = IMRD_APPL_ID_UNKNOWN; + memset(Appl_Ptr->Name,0,sizeof(Appl_Ptr->Name)); +} diff --git a/src/libstatic_data_mng/src/buffer_info_mng.h b/src/libstatic_data_mng/src/buffer_info_mng.h new file mode 100644 index 0000000..ea1ea95 --- /dev/null +++ b/src/libstatic_data_mng/src/buffer_info_mng.h @@ -0,0 +1,258 @@ +/*----------------------------------------------------------------------------*/ +/* File: buffer_info_mng.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _BUFFER_INFO_MNG_H_ +# define _BUFFER_INFO_MNG_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include + + +/*----------------------------------------------------------------------------*/ +/* Local definition */ +/*----------------------------------------------------------------------------*/ + + +/*----------------------------------------------------------------------------*/ +/* XML TAG */ +/*----------------------------------------------------------------------------*/ +#define IMRD_SDMD_FMTATTR_STRUCT "fmtattr_struct" +#define IMRD_SDMD_APPLI_STRUCT "appl_struct" +#define IMRD_SDMD_FMT_STRUCT "fmt_struct" +#define IMRD_SDMD_MAPPATH_STRUCT "mappath_struct" + +/* Nom des fichiers pour le chargement XML */ +#define SDMD_FMTATTR_FILE "sd_fmtattr_struct.xml" +#define SDMD_APPLI_FILE "sd_appl_struct.xml" +#define SDMD_FORMAT_FILE "sd_fmt_struct.xml" +#define SDMD_MAPPATH_FILE "sd_mappath_struct.xml" + + + +#define SDMD_CRI_IA 0 /*Critére input appli*/ +#define SDMD_CRI_OA 1 /*Critére output appli*/ +#define SDMD_CRI_IF 2 /*Critére input format*/ +#define SDMD_CRI_OF 3 /*Critére output format*/ +#define SDMD_CRI_IT 4 /*Critére input type*/ +#define SDMD_CRI_OT 5 /*Critére ouput type*/ + +#define SDMD_NB_CRITERE_CHEMIN 4 + + +typedef struct IMRT_Appl +{ + IMRT_Appl_Id Id; + IMRT_Appl_Name Name ; + +} IMRT_Appl; + +typedef struct IMRT_MapPath +{ + int idMapPath; + IMRT_Fmt * Fmt_Input_Ptr; + IMRT_Fmt * Fmt_Output_Ptr; + IMRT_Appl * Appl_Input_Ptr; + IMRT_Appl * Appl_Output_Ptr; + NDT_Root * MapCmd_Struct_Ptr; +} IMRT_MapPath; + + +/*typedef struct SDMT_FmtMsg +{ + char name [IMRD_NAME_LEN]; + IMRT_Msg * msg; + +} SDMT_FmtMsg; +*/ + + +typedef struct SDMT_CritereRecChemin +{ + IMRT_Appl_Id InputAppli; + IMRT_Appl_Id OutputAppli; + IMRT_Fmt_Id InputFormat; + IMRT_Fmt_Id OutputFormat; + IMRT_Msg_Id InputType; + IMRT_Msg_Id OutputType; + int Branche_id; + IMRT_Error FataError; + IMRT_SDMCB_Buffer_Ident * CallBackCommandeIdent; + IMRT_SDMCB_Buffer_Map * CallBackBCommandeMap; + IMRT_SDMCB_Buffer_Copy * CallBackCommandeCopy; + +} SDMT_CritereRecChemin; + +/********************************************************************/ +/* Les index du Manager SDM_Appl_Manager */ +/********************************************************************/ +#define IMRD_SDMD_APPL_STRUCT_IDX_NB (short)2 + +static NDT_Index_Type Appl_Struct_initial_idx_tab[IMRD_SDMD_APPL_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED), + (NDD_INDEX_STATUS_CLOSED) +}; + +static NDT_Index_Type Appl_Struct_final_idx_tab[IMRD_SDMD_APPL_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED) +}; + +#define IMRD_SDMD_APPL_IDX_ID (short)0 +#define IMRD_SDMD_APPL_IDX_NAME (short)1 + +/********************************************************************/ +/* Les index du Manager SDM_FmtAttr_Manager */ +/********************************************************************/ +#define IMRD_SDMD_FMTATTR_STRUCT_IDX_NB (short)2 + +static NDT_Index_Type FmtAttr_Struct_initial_idx_tab[IMRD_SDMD_FMTATTR_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED), + (NDD_INDEX_STATUS_CLOSED) +}; + +static NDT_Index_Type FmtAttr_Struct_final_idx_tab[IMRD_SDMD_FMTATTR_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED) +}; + +#define IMRD_SDMD_FMTATTR_IDX_ID (short)0 +#define IMRD_SDMD_FMTATTR_IDX_NAME (short)1 + + +/********************************************************************/ +/* Les index du Manager SDM_Fmt_Manager */ +/********************************************************************/ +#define IMRD_SDMD_FMT_STRUCT_IDX_NB (short)2 + +static NDT_Index_Type Fmt_Struct_initial_idx_tab[IMRD_SDMD_FMT_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED), + (NDD_INDEX_STATUS_CLOSED) +}; + +static NDT_Index_Type Fmt_Struct_final_idx_tab[IMRD_SDMD_FMT_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED) +}; + +#define IMRD_SDMD_FMT_IDX_ID (short)0 +#define IMRD_SDMD_FMT_IDX_NAME (short)1 + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _BUFFER_INFO_MNG_C_ +IMRT_Status SDM_DataStruct_Finalize(NDT_Root *, NDT_Index_Type *, short ); +NDT_Status SDM_Appl_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +NDT_Status SDM_FmtAttr_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +NDT_Status SDM_FmtMsg_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +NDT_Status SDM_Fmt_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +NDT_Status SDM_MapCmd_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +NDT_Status SDM_MapPath_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +IMRT_Status SDM_MapPath_Proceed( IMRT_Appl_Id Appl_Id_Target, IMRT_Fmt_Id Fmt_Id_Target, IMRT_Msg_Id Msg_Id_Target, + IMRT_Appl_Id ApplId_Src, IMRT_Fmt_Id Fmt_Id_Src, IMRT_Msg_Id Msg_Id_Src, + IMRT_SDMCB_Buffer_Map *CCB_Buffer_Map_Ptr, + IMRT_SDMCB_Buffer_Copy *CCB_Buffer_Copy_Ptr, + IMRT_SDMCB_Buffer_Ident *CCB_Buffer_Ident_Ptr); +IMRT_Status SDM_Fmt_Proceed( IMRT_SDMCB_Fmt_Add *CCB_Fmt_Add_Ptr); +void SDM_CompareCritereMapPath(IMRT_Status CitereTable[], + const int NbCritere, + SDMT_CritereRecChemin * Critere, + IMRT_MapPath * myMapPath, + IMRT_Status *Valide ); +void SDM_IniTableCritere(IMRT_Status Table[],const int NbElement); +void SDM_InitMapCmd(IMRT_MapCmd * mymapcmd); +void SDM_InitMapPath(IMRT_MapPath * mymappath); +void SDM_InitFormat(IMRT_Fmt * myformat); +void SDM_InitFmtAttr(IMRT_FmtAttr * myFmtAttr); +void SDM_InitFmtMsg(IMRT_FmtMsg * myFmtMsg); +void SDM_InitAppl(IMRT_Appl * Appl_Ptr); +IMRT_Status SDM_BufferInfo_Init(IMRT_SDM_Config * Lib_Config_Ptr); +IMRT_Status SDM_Close_RootMapPath(void); +IMRT_Status SDM_Close_RootAppl(void); +IMRT_Status SDM_Close_RootFmtAttr(void); +IMRT_Status SDM_Close_RootFmt(void); +IMRT_Status SDM_BufferInfo_DInit(void); + +# else + +extern IMRT_Status SDM_DataStruct_Finalize(NDT_Root *ds_Ptr, NDT_Index_Type *Index_Id_Ptr, short hMaxEntries); +extern NDT_Status SDM_Appl_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern NDT_Status SDM_FmtAttr_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern NDT_Status SDM_FmtMsg_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern NDT_Status SDM_Fmt_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern NDT_Status SDM_MapCmd_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern NDT_Status SDM_MapPath_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern IMRT_Status SDM_MapPath_Proceed( IMRT_Appl_Id Appl_Id_Target, IMRT_Fmt_Id Fmt_Id_Target, IMRT_Msg_Id Msg_Id_Target, + IMRT_Appl_Id ApplId_Src, IMRT_Fmt_Id Fmt_Id_Src, IMRT_Msg_Id Msg_Id_Src, + IMRT_SDMCB_Buffer_Map *CCB_Buffer_Map_Ptr, + IMRT_SDMCB_Buffer_Copy *CCB_Buffer_Copy_Ptr, + IMRT_SDMCB_Buffer_Ident *CCB_Buffer_Ident_Ptr); +extern IMRT_Status SDM_Fmt_Proceed( IMRT_SDMCB_Fmt_Add *CCB_Fmt_Add_Ptr); +extern IMRT_Status SDM_BufferInfo_Init(IMRT_SDM_Config * Lib_Config_Ptr); +extern IMRT_Status SDM_Close_RootMapPath(void); +extern IMRT_Status SDM_Close_RootAppl(void); +extern IMRT_Status SDM_Close_RootFmtAttr(void); +extern IMRT_Status SDM_Close_RootFmt(void); +extern IMRT_Status SDM_BufferInfo_DInit(void); +# endif + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Includes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _BUFFER_INFO_MNG_C_ + +# include "buffer_info_xml.h" +# include "buffer_info_sql.h" + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/buffer_info_sql.h b/src/libstatic_data_mng/src/buffer_info_sql.h new file mode 100644 index 0000000..f7a5644 --- /dev/null +++ b/src/libstatic_data_mng/src/buffer_info_sql.h @@ -0,0 +1,113 @@ +/*----------------------------------------------------------------------------*/ +/* File: buffer_info_sql.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _BUFFER_INFO_SQL_H_ +# define _BUFFER_INFO_SQL_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _BUFFER_INFO_SQL_PC_ + +IMRT_Status SDM_SQL_BufferInfo_Init(); +IMRT_Status SDM_SQL_Load_FmtAttr(NDT_Root **myRootFmtAttr_Ptr_Ptr); +IMRT_Status SDM_SQL_Load_Appli(NDT_Root **myRootAppli_Ptr_Ptr); +IMRT_Status SDM_SQL_Load_Format(NDT_Root **myRootFormat_Ptr_Ptr); +IMRT_Status SDM_SQL_LoadFmtMsg(IMRT_Fmt *myFormat_Ptr); +IMRT_Status SDM_SQL_Load_MapPath(NDT_Root **myRootMapPath_Ptr_Ptr); +IMRT_Status SDM_SQL_LoadMapCmd(IMRT_MapPath *myMapPath_Ptr); +IMRT_Status SDM_SQL_Load_JumpTable(IMRT_Jump **JumpTable_Ptr_Ptr, int *JumpTableNbElt_Ptr, IMRT_MapCmd_Id IdMapCmd); +IMRT_Status SDM_SQL_Dump_FmtAttr_Header(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_FmtAttr_Body(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_FmtAttr_Footer(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_FmtAttr(void); +IMRT_Status SDM_SQL_Dump_Appli_Header(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Appli_Body(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Appli_Footer(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Appli(void); +IMRT_Status SDM_SQL_Dump_Format_Header(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Format_Body(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Format_Footer(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Format(void); +IMRT_Status SDM_SQL_Dump_MapPath_Header(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_MapPath_Body(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_MapPath_Footer(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_MapPath(void); +IMRT_Status SDM_SQL_BufferInfo_Dump(void); + +# else + +extern IMRT_Status SDM_SQL_BufferInfo_Init(); +extern IMRT_Status SDM_SQL_Load_FmtAttr(NDT_Root **myRootFmtAttr_Ptr_Ptr); +extern IMRT_Status SDM_SQL_Load_Appli(NDT_Root **myRootAppli_Ptr_Ptr); +extern IMRT_Status SDM_SQL_Load_Format(NDT_Root **myRootFormat_Ptr_Ptr); +extern IMRT_Status SDM_SQL_LoadFmtMsg(IMRT_Fmt *myFormat_Ptr); +extern IMRT_Status SDM_SQL_Load_MapPath(NDT_Root **myRootMapPath_Ptr_Ptr); +extern IMRT_Status SDM_SQL_LoadMapCmd(IMRT_MapPath *myMapPath_Ptr); +extern IMRT_Status SDM_SQL_Load_JumpTable(IMRT_Jump **JumpTable_Ptr_Ptr, int *JumpTableNbElt_Ptr, IMRT_MapCmd_Id IdMapCmd); +extern IMRT_Status SDM_SQL_Dump_FmtAttr_Header(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_FmtAttr_Body(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_FmtAttr_Footer(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_FmtAttr(void); +extern IMRT_Status SDM_SQL_Dump_Appli_Header(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Appli_Body(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Appli_Footer(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Appli(void); +extern IMRT_Status SDM_SQL_Dump_Format_Header(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Format_Body(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Format_Footer(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Format(void); +extern IMRT_Status SDM_SQL_Dump_MapPath_Header(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_MapPath_Body(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_MapPath_Footer(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_MapPath(void); +extern IMRT_Status SDM_SQL_BufferInfo_Dump(void); + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/buffer_info_sql.pc b/src/libstatic_data_mng/src/buffer_info_sql.pc new file mode 100644 index 0000000..4849aed --- /dev/null +++ b/src/libstatic_data_mng/src/buffer_info_sql.pc @@ -0,0 +1,1476 @@ +/*----------------------------------------------------------------------------*/ +/* File: buffer_info_sql.pc */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _BUFFER_INFO_SQL_PC_ + +#include "buffer_info_sql.h" + + +IMRT_Status SDM_SQL_BufferInfo_Init() +{ + IMRT_Status status, StatusTmp; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading FmtAttr..."); + status = SDM_SQL_Load_FmtAttr(&(IMRG_SDM_Base.RootFmtAttr)); + if(status == IMRS_OK) + { + IMRD_LM_LOG_INFO_1( "FmtAtt loaded: (%d)", IMRG_SDM_Base.RootFmtAttr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading Fmt..."); + status = SDM_SQL_Load_Format(&(IMRG_SDM_Base.RootFmt)); + if(status == IMRS_OK) + { + IMRD_LM_LOG_INFO_1( "Fmt loaded: (%d)", IMRG_SDM_Base.RootFmt->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading Appl..."); + status = SDM_SQL_Load_Appli(&(IMRG_SDM_Base.RootAppl)); + if(status == IMRS_OK) + { + IMRD_LM_LOG_INFO_1( "Appl loaded: (%d)", IMRG_SDM_Base.RootAppl->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading MapPath..."); + status = SDM_SQL_Load_MapPath(&(IMRG_SDM_Base.RootMapPath)); + if(status == IMRS_OK) + { + IMRD_LM_LOG_INFO_1( "MapPath loaded: (%d)", IMRG_SDM_Base.RootMapPath->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't load MapPath !"); + StatusTmp = SDM_Close_RootFmtAttr(); + StatusTmp = SDM_Close_RootFmt(); + StatusTmp = SDM_Close_RootAppl(); + } + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't load Appl !"); + StatusTmp = SDM_Close_RootFmtAttr(); + StatusTmp = SDM_Close_RootFmt(); + } + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't load Fmt !"); + StatusTmp = SDM_Close_RootFmtAttr(); + } + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't load FmtAttr !"); + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Load_FmtAttr(NDT_Root **myRootFmtAttr_Ptr_Ptr) +{ + const char sFunctionName []="SDM_SQL_Load_FmtAttr"; + NDT_Status nd_status; + IMRT_Status status, statusTmp; + NDT_Index_Type *index_type_ptr; + IMRT_FmtAttr *myFmtAttr; + IMRT_Data_Version *Data_Version_Ptr; + + EXEC SQL BEGIN DECLARE SECTION; + IMRT_FmtAttr_Id hFmtAttrId; + VARCHAR vFmtAttrName[IMRD_FMTATTR_NAME_SIZE]; + VARCHAR vFmtAttrValue[IMRD_FMTATTR_VALUE_SIZE]; + short hIndFmtAttrId; + short hIndFmtAttrName; + short hIndFmtAttrValue; + EXEC SQL END DECLARE SECTION; + + + /* initialisation */ + index_type_ptr = FmtAttr_Struct_initial_idx_tab; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + status = SDM_SQL_Set_Struct_Version(Data_Version_Ptr, "FmtAttr"); + if (status != IMRS_OK) + { + return(IMRS_KO); + } + + nd_status = ND_DataStruct_Open(myRootFmtAttr_Ptr_Ptr, IMRD_SDMD_FMTATTR_STRUCT_IDX_NB,index_type_ptr, "SDM_FmtAttr_Manager",SDM_FmtAttr_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Open -- SDM_FmtAttr_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + EXEC SQL DECLARE cur_imr_fmt_attr CURSOR FOR + SELECT FMTATTR_ID, FMTATTR_NAME, FMTATTR_VALUE + FROM IMR_FMT_ATTR + ORDER BY FMTATTR_ID ASC; + + EXEC SQL OPEN cur_imr_fmt_attr; + do + { + memset(vFmtAttrName.arr, '\0', (size_t) IMRD_FMTATTR_NAME_SIZE); + memset(vFmtAttrValue.arr, '\0', (size_t) IMRD_FMTATTR_VALUE_SIZE); + + EXEC SQL FETCH cur_imr_fmt_attr + INTO :hFmtAttrId:hIndFmtAttrId, + :vFmtAttrName:hIndFmtAttrName, + :vFmtAttrValue:hIndFmtAttrValue; + + if (sqlca.sqlcode == 0) + { + /* creation d'un nouvelle objet FmtAttr */ + nd_status = ND_Value_Alloc( *myRootFmtAttr_Ptr_Ptr, (void **)&(myFmtAttr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- SDM_FmtAttr_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + /* Ajout de l'objet Appli */ + myFmtAttr->Id = hFmtAttrId; + if(hIndFmtAttrName >= 0) + { + strcpy(myFmtAttr->Name, (char *) vFmtAttrName.arr); + } + + if(hIndFmtAttrValue >= 0) + { + statusTmp = SDM_ConvertAttribute((char *) vFmtAttrValue.arr, myFmtAttr->Value); + } + + nd_status = ND_DataStruct_Value_Add( *myRootFmtAttr_Ptr_Ptr, (void *)(myFmtAttr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Value_Add -- SDM_FmtAttr_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_fmt_attr; + } + + if(status == IMRS_OK) + { + index_type_ptr = FmtAttr_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(*myRootFmtAttr_Ptr_Ptr, index_type_ptr, IMRD_SDMD_FMTATTR_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump(*myRootFmtAttr_Ptr_Ptr);*/ + } + else + { + nd_status = ND_DataStruct_Close(*myRootFmtAttr_Ptr_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + status == IMRS_KO; + } + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Load_Appli(NDT_Root **myRootAppli_Ptr_Ptr) +{ + const char sFunctionName []="SDM_SQL_Load_Appli"; + NDT_Status nd_status; + IMRT_Status status; + NDT_Index_Type *index_type_ptr; + IMRT_Appl *myAppli; + IMRT_Data_Version *Data_Version_Ptr; + + EXEC SQL BEGIN DECLARE SECTION; + IMRT_Appl_Id hAppliId; + VARCHAR vAppliName[IMRD_APPL_NAME_SIZE]; + short hIndAppliId; + short hIndAppliName; + EXEC SQL END DECLARE SECTION; + + + /* initialisation */ + index_type_ptr = Appl_Struct_initial_idx_tab; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + status = SDM_SQL_Set_Struct_Version(Data_Version_Ptr, "Appl"); + if (status != IMRS_OK) + { + return(IMRS_KO); + } + + nd_status = ND_DataStruct_Open(myRootAppli_Ptr_Ptr, IMRD_SDMD_APPL_STRUCT_IDX_NB,index_type_ptr, "SDM_Appl_Manager",SDM_Appl_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Open -- SDM_Appl_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + EXEC SQL DECLARE cur_imr_appli CURSOR FOR + SELECT APPLI_ID, APPLI_NAME + FROM IMR_APPLI + ORDER BY APPLI_ID ASC; + + EXEC SQL OPEN cur_imr_appli; + do + { + memset(vAppliName.arr, '\0', (size_t) IMRD_APPL_NAME_SIZE); + + EXEC SQL FETCH cur_imr_appli + INTO :hAppliId:hIndAppliId, + :vAppliName:hIndAppliName; + + if (sqlca.sqlcode == 0) + { + /* creation d'un nouvelle objet appli */ + nd_status = ND_Value_Alloc( *myRootAppli_Ptr_Ptr, (void **)&(myAppli)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- SDM_Appl_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + /* Ajout de l'objet Appli */ + myAppli->Id = hAppliId; + strcpy(myAppli->Name, (char *) vAppliName.arr); + + nd_status = ND_DataStruct_Value_Add( *myRootAppli_Ptr_Ptr, (void *)(myAppli)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Value_Add -- SDM_Appl_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_appli; + } + + if(status == IMRS_OK) + { + index_type_ptr = Appl_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(*myRootAppli_Ptr_Ptr, index_type_ptr, IMRD_SDMD_APPL_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump(*myRootAppli_Ptr_Ptr);*/ + } + else + { + nd_status = ND_DataStruct_Close(*myRootAppli_Ptr_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + status == IMRS_KO; + } + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Load_Format(NDT_Root **myRootFormat_Ptr_Ptr) +{ + const char sFunctionName []="SDM_SQL_Load_Format"; + NDT_Status nd_status; + IMRT_Status status; + NDT_Index_Type *index_type_ptr; + IMRT_Fmt *myFmt_Ptr; + IMRT_Data_Version *Data_Version_Ptr; + + EXEC SQL BEGIN DECLARE SECTION; + IMRT_Fmt_Id hFormatId; + VARCHAR vFormatName[IMRD_FMT_NAME_SIZE]; + short hIndFormatId; + short hIndFormatName; + EXEC SQL END DECLARE SECTION; + + /* initialisation */ + index_type_ptr = Fmt_Struct_initial_idx_tab; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + status = SDM_SQL_Set_Struct_Version(Data_Version_Ptr, "Fmt"); + if (status != IMRS_OK) + { + return(IMRS_KO); + } + + nd_status = ND_DataStruct_Open(myRootFormat_Ptr_Ptr, IMRD_SDMD_FMT_STRUCT_IDX_NB,index_type_ptr, "SDM_Fmt_Manager",SDM_Fmt_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Open -- SDM_Fmt_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + EXEC SQL DECLARE cur_imr_format CURSOR FOR + SELECT FORMAT_ID, FORMAT_NAME + FROM IMR_FORMAT + ORDER BY FORMAT_ID ASC; + + EXEC SQL OPEN cur_imr_format; + do + { + memset(vFormatName.arr, '\0', (size_t) IMRD_FMT_NAME_SIZE); + + EXEC SQL FETCH cur_imr_format + INTO :hFormatId:hIndFormatId, + :vFormatName:hIndFormatName; + if (sqlca.sqlcode == 0) + { + /* creation d'un nouveau objet format */ + nd_status = ND_Value_Alloc( *myRootFormat_Ptr_Ptr, (void **)&(myFmt_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- SDM_Fmt_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + /* Ajout de l'objet Format */ + myFmt_Ptr->Id = hFormatId; + strcpy(myFmt_Ptr->Name, (char *) vFormatName.arr); + + status = SDM_SQL_LoadFmtMsg(myFmt_Ptr); + + if (status == IMRS_OK) + { + /* Add */ + nd_status = ND_DataStruct_Value_Add( *myRootFormat_Ptr_Ptr, (void *)(myFmt_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Value_Add -- SDM_Fmt_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_format; + + if(status == IMRS_OK) + { + index_type_ptr = Fmt_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(*myRootFormat_Ptr_Ptr, index_type_ptr, IMRD_SDMD_FMT_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump( *myRootFormat_Ptr_Ptr);*/ + } + else + { + if(myFmt_Ptr->FmtMsg_Struct_Ptr != NULL) + { + nd_status = ND_DataStruct_Close(myFmt_Ptr->FmtMsg_Struct_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + } + } + + nd_status = ND_DataStruct_Close(*myRootFormat_Ptr_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + } + } + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_LoadFmtMsg(IMRT_Fmt *myFormat_Ptr) +{ + const char sFunctionName []="SDM_SQL_LoadFmtMsg"; + NDT_Status nd_status; + IMRT_Status status, statusTmp; + NDT_Node *node_ptr; + IMRT_Msg message; + IMRT_FmtMsg *myFmtMsg_Ptr; + IMRT_FmtAttr fmtattr; + + EXEC SQL BEGIN DECLARE SECTION; + IMRT_Msg_Id hMsgId; + IMRT_FmtAttr_Id hFmtAttrId; + IMRT_Branche_Id hFmtMsgBrancheId; + + short hIndMsgId; + short hIndFmtAttrId; + short hIndFmtMsgBrancheId; + EXEC SQL END DECLARE SECTION; + + + status = IMRS_OK; + + EXEC SQL DECLARE cur_imr_fmt_msg CURSOR FOR + SELECT MSG_ID, FMTATTR_ID, FMTMSG_BRANCHE_ID + FROM IMR_FMT_MSG + WHERE FORMAT_ID = :myFormat_Ptr->Id + ORDER BY NUM_ORDRE_FMT_MSG ASC; + + EXEC SQL OPEN cur_imr_fmt_msg; + do + { + EXEC SQL FETCH cur_imr_fmt_msg + INTO :hMsgId:hIndMsgId, + :hFmtAttrId:hIndFmtAttrId, + :hFmtMsgBrancheId:hIndFmtMsgBrancheId; + if (sqlca.sqlcode == 0) + { + /* Allacation de ListField */ + nd_status = ND_Value_Alloc( myFormat_Ptr->FmtMsg_Struct_Ptr, (void **)&(myFmtMsg_Ptr)); + if (nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- Field failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + /*recherch du message avec le nom*/ + message.Id = hMsgId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, + IMRD_SDMD_MSG_IDX_ID, &message, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche Message <%d> !", message.Id); + status = IMRS_KO; + } + else + { + myFmtMsg_Ptr->Msg_Ptr = node_ptr->Value; + } + + if(status == IMRS_OK) + { + if(hIndFmtMsgBrancheId >= 0) + { + myFmtMsg_Ptr->Branche_Id = hFmtMsgBrancheId; + } + + if(hIndFmtAttrId >= 0) + { + fmtattr.Id = hFmtAttrId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmtAttr, + IMRD_SDMD_FMTATTR_IDX_ID, &fmtattr, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du FmtAttr <%d> !", fmtattr.Id); + status = IMRS_KO; + } + else + { + myFmtMsg_Ptr->FmtAttr_Ptr = node_ptr->Value; + } + } + + if(status == IMRS_OK) + { + nd_status = ND_DataStruct_Value_Add( myFormat_Ptr->FmtMsg_Struct_Ptr, (void *)(myFmtMsg_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_Value_Add() failed (%d) !", nd_status); + status = IMRS_KO; + } + } + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_fmt_msg; + + if(status != IMRS_OK) + { + free(myFmtMsg_Ptr); + } + /*if(status != IMRS_OK) + { + nd_status = ND_Value_Free(myFormat_Ptr->FmtMsg_Struct_Ptr, (void **)&(myFmtMsg_Ptr)); + printf("1111111 %d pointer %lx\n", nd_status, myFmtMsg_Ptr); + }*/ + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Load_MapPath(NDT_Root **myRootMapPath_Ptr_Ptr) +{ + const char sFunctionName []="SDM_SQL_Load_MapPath"; + NDT_Status nd_status; + IMRT_Status status; + NDT_Index_Type *index_type_ptr; + IMRT_MapPath *myMapPath_Ptr; + NDT_Node *node_ptr; + IMRT_MsgMap msgmap; + IMRT_Appl appli; + IMRT_Fmt fmt; + IMRT_Msg msg; + IMRT_Data_Version *Data_Version_Ptr; + + EXEC SQL BEGIN DECLARE SECTION; + short hMapPathId; + IMRT_Fmt_Id hFormatInId; + IMRT_Fmt_Id hFormatOutId; + IMRT_Appl_Id hAppliInId; + IMRT_Appl_Id hAppliOutId; + short hIndMapPathId; + short hIndFormatInId; + short hIndFormatOutId; + short hIndAppliInId; + short hIndAppliOutId; + EXEC SQL END DECLARE SECTION; + + /*initialisation des indexes*/ + index_type_ptr = index_type_initial_tab; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + status = SDM_SQL_Set_Struct_Version(Data_Version_Ptr, "MapPath"); + if (status != IMRS_OK) + { + return(IMRS_KO); + } + + nd_status = ND_DataStruct_Open(myRootMapPath_Ptr_Ptr, IMRD_SDMD_INDEX_NB, index_type_ptr, "SDM_MapPath_Manager",SDM_MapPath_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Open -- SDM_MapPath_Manager failed (%d) !", sFunctionName, nd_status); + return(IMRS_KO); + } + else + { + EXEC SQL DECLARE cur_imr_map_path CURSOR FOR + SELECT MAP_PATH_ID, APPLI_IN_ID, APPLI_OUT_ID, FORMAT_IN_ID, FORMAT_OUT_ID + FROM IMR_MAPPATH + ORDER BY MAP_PATH_ID ASC; + + EXEC SQL OPEN cur_imr_map_path; + do + { + + EXEC SQL FETCH cur_imr_map_path + INTO :hMapPathId:hIndMapPathId, + :hAppliInId:hIndAppliInId, + :hAppliOutId:hIndAppliOutId, + :hFormatInId:hIndFormatInId, + :hFormatOutId:hIndFormatOutId; + if (sqlca.sqlcode == 0) + { + nd_status = ND_Value_Alloc( *myRootMapPath_Ptr_Ptr, (void **)&(myMapPath_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- SDM_MapPath_Manager failed (%d) !", sFunctionName, nd_status); + return(IMRS_KO); + } + else + { + myMapPath_Ptr->idMapPath = hMapPathId; + /* APPLI IN */ + appli.Id = hAppliInId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootAppl, + IMRD_SDMD_APPL_IDX_ID, &appli, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du IN Appli <%d> !", appli.Id); + return(IMRS_KO); + } + else + { + myMapPath_Ptr->Appl_Input_Ptr = node_ptr->Value; + } + /* APPLI OUT */ + appli.Id = hAppliOutId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootAppl, + IMRD_SDMD_APPL_IDX_ID, &appli, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du OUT Appli <%d> !", appli.Id); + return(IMRS_KO); + } + else + { + myMapPath_Ptr->Appl_Output_Ptr = node_ptr->Value; + } + /* FORMAT IN */ + fmt.Id = hFormatInId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmt, + IMRD_SDMD_FMT_IDX_ID, &fmt, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du Format IN <%d> !", fmt.Id); + return(IMRS_KO); + } + else + { + myMapPath_Ptr->Fmt_Input_Ptr = node_ptr->Value; + } + /* FORMAT OUT */ + fmt.Id = hFormatOutId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmt, + IMRD_SDMD_FMT_IDX_ID, &fmt, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du Format OUT <%d> !", fmt.Id); + return(IMRS_KO); + } + else + { + myMapPath_Ptr->Fmt_Output_Ptr = node_ptr->Value; + } + + status = SDM_SQL_LoadMapCmd(myMapPath_Ptr); + if (status == IMRS_OK) + { + /*** Add ***/ + nd_status = ND_DataStruct_Value_Add(*myRootMapPath_Ptr_Ptr, (void *)(myMapPath_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Value_Add -- SDM_MapPath_Manager failed (%d) !", sFunctionName, nd_status); + return(IMRS_KO); + } + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_map_path; + + if(status == IMRS_OK) + { + /*SDM_DataStruct_Dump(*myRootMapPath_Ptr_Ptr);*/ + } + else + { + if(myMapPath_Ptr->MapCmd_Struct_Ptr != NULL) + { + nd_status = ND_DataStruct_Close(myMapPath_Ptr->MapCmd_Struct_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + } + } + + nd_status = ND_DataStruct_Close(*myRootMapPath_Ptr_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + } + } + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_LoadMapCmd(IMRT_MapPath *myMapPath_Ptr) + +{ + const char sFunctionName []="SDM_SQL_LoadMapCmd"; + NDT_Status nd_status; + IMRT_Status status, statusTmp; + NDT_Index_Type *index_type_ptr; + NDT_Node *node_ptr; + IMRT_MapCmd *myMapCmd_Ptr; + IMRT_MsgMap msgmap; + IMRT_Fmt fmt; + IMRT_Msg Msg; + int myJumpTableNbElt; + IMRT_Jump myJumpTable; + IMRT_FmtAttr fmtattr; + + EXEC SQL BEGIN DECLARE SECTION; + short hMapCmdId; + short hMapCmdType; + IMRT_MapCmd_Branch_Id hCurrentBrancheId; + short hCopyBufferIdInput; + short hCopyBufferIdOutput; + IMRT_Fmt_Id hFormatInId; + IMRT_FmtAttr_Id hFmtAttrInId; + IMRT_Fmt_Id hFormatOutId; + IMRT_FmtAttr_Id hFmtAttrOutId; + IMRT_MsgMap_Id hMsgMapId; + short hMapBufferIdInput; + short hMapBufferIdOutput; + short hClearFlag; + short hBufferIdIdent; + char IdentTotal; + IMRT_Msg_Id hIdentFirstMsgId; + IMRT_MapCmd_Branch_Id hGotoBrancheId; + + short hIndMapCmdId; + short hIndMapCmdType; + short hIndCurrentBrancheId; + short hIndCopyBufferIdInput; + short hIndCopyBufferIdOutput; + short hIndFormatInId; + short hIndFmtAttrInId; + short hIndFormatOutId; + short hIndFmtAttrOutId; + short hIndMsgMapId; + short hIndMapBufferIdInput; + short hIndMapBufferIdOutput; + short hIndClearFlag; + short hIndBufferIdIdent; + short hIndIdentTotal; + short hIndIdentFirstMsgId; + short hIndGotoBrancheId; + EXEC SQL END DECLARE SECTION; + + /*initialisation des indexes*/ + index_type_ptr = index_type_initial_tab; + status = IMRS_OK; + myJumpTableNbElt = 0; + + EXEC SQL DECLARE cur_imr_cmd_map_path CURSOR FOR + SELECT A.MAPCMD_ID, B.MAPCMD_TYPE, B.CURRENT_BRANCHE_ID, + C.COPY_BUFFER_ID_INPUT, C.COPY_BUFFER_ID_OUTPUT, + D.FORMAT_IN_ID, D.FMTATTR_IN_ID, D.FORMAT_OUT_ID, D.FMTATTR_OUT_ID, + D.MSG_MAP_ID, D.MAP_BUFFER_ID_INPUT, D.MAP_BUFFER_ID_OUTPUT, D.CLEAR_FLAG, + F.IDENT_BUFFER_ID, F.IDENT_TOTAL, F.IDENT_FIRST_MSG_ID, G.GOTO_BRANCHE_ID + FROM IMR_CMD_MAP_PATH A, IMR_MAPCMD B, IMR_CMD_COPY C, + IMR_CMD_MAP D, IMR_CMD_IDENT F, IMR_CMD_GOTO G + WHERE A.MAPCMD_ID = B.MAPCMD_ID + AND B.MAPCMD_ID = C.MAPCMD_ID(+) + AND B.MAPCMD_ID = D.MAPCMD_ID(+) + AND B.MAPCMD_ID = F.MAPCMD_ID(+) + AND B.MAPCMD_ID = G.MAPCMD_ID(+) + AND A.MAP_PATH_ID = :myMapPath_Ptr->idMapPath + ORDER BY A.MAPCMD_ID ASC; + + EXEC SQL OPEN cur_imr_cmd_map_path; + do + { + + EXEC SQL FETCH cur_imr_cmd_map_path + INTO :hMapCmdId:hIndMapCmdId, + :hMapCmdType:hIndMapCmdType, + :hCurrentBrancheId:hIndCurrentBrancheId, + :hCopyBufferIdInput:hIndCopyBufferIdInput, + :hCopyBufferIdOutput:hIndCopyBufferIdOutput, + :hFormatInId:hIndFormatInId, + :hFmtAttrInId:hIndFmtAttrInId, + :hFormatOutId:hIndFormatOutId, + :hFmtAttrOutId:hIndFmtAttrOutId, + :hMsgMapId:hIndMsgMapId, + :hMapBufferIdInput:hIndMapBufferIdInput, + :hMapBufferIdOutput:hIndMapBufferIdOutput, + :hClearFlag:hIndClearFlag, + :hBufferIdIdent:hIndBufferIdIdent, + :IdentTotal:hIndIdentTotal, + :hIdentFirstMsgId:hIndIdentFirstMsgId, + :hGotoBrancheId:hIndGotoBrancheId; + + if (sqlca.sqlcode == 0) + { + /* Alloc */ + nd_status = ND_Value_Alloc( myMapPath_Ptr->MapCmd_Struct_Ptr, (void **)&(myMapCmd_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- MapCmd failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + /* Add */ + /********************************************************/ + myMapCmd_Ptr->MapCmd_Id = hMapCmdId; + myMapCmd_Ptr->TypeCmd = hMapCmdType; + if (hIndCurrentBrancheId >= 0) + myMapCmd_Ptr->Branche_Id = hCurrentBrancheId; + if (hMapCmdType == IMRD_MAPCMD_TYPE_MAP) + { + if (hIndMapBufferIdInput >= 0) + myMapCmd_Ptr->Buffer_Id_Input = hMapBufferIdInput; + if (hIndMapBufferIdOutput >= 0) + myMapCmd_Ptr->Buffer_Id_Output = hMapBufferIdOutput; + } + else if (hMapCmdType == IMRD_MAPCMD_TYPE_COPY) + { + if (hIndCopyBufferIdInput >= 0) + myMapCmd_Ptr->Buffer_Id_Input = hCopyBufferIdInput; + if (hIndCopyBufferIdOutput >= 0) + myMapCmd_Ptr->Buffer_Id_Output = hCopyBufferIdOutput; + } + if (hIndClearFlag >= 0) + myMapCmd_Ptr->Clear_Flag = hClearFlag; + if (hIndBufferIdIdent >= 0) + myMapCmd_Ptr->Buffer_Id_Ident = hBufferIdIdent; + if (hIndIdentTotal >= 0) + { + if (IdentTotal == IMRD_YES) + myMapCmd_Ptr->Ident_Total = IMRD_TRUE; + else + myMapCmd_Ptr->Ident_Total = IMRD_FALSE; + } + if (hIndIdentFirstMsgId >= 0) + { + Msg.Id = hIdentFirstMsgId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, + IMRD_SDMD_MSG_IDX_ID, &Msg, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du Message <%d> !", Msg.Id); + status = IMRS_KO; + } + else + { + myMapCmd_Ptr->Ident_First_Msg_Ptr = node_ptr->Value; + } + } + + /********************************************************/ + + if (hMapCmdType == IMRD_MAPCMD_TYPE_GOTO) + { + myMapCmd_Ptr->Goto_Branche_Id = hGotoBrancheId; + } + + if (hMapCmdType == IMRD_MAPCMD_TYPE_MAP) + { + /* FORMAT IN */ + fmt.Id = hFormatInId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmt, + IMRD_SDMD_FMT_IDX_ID, &fmt, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du Format IN <%d> !", fmt.Id); + status = IMRS_KO; + } + else + { + myMapCmd_Ptr->Fmt_Input_Ptr = node_ptr->Value; + } + + if (hIndFmtAttrInId >= 0) + { + fmtattr.Id = hFmtAttrInId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmtAttr, + IMRD_SDMD_FMTATTR_IDX_ID, &fmtattr, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du FmtAttr IN <%d> !", fmtattr.Id); + status = IMRS_KO; + } + else + { + myMapCmd_Ptr->FmtAttr_Input_Ptr = node_ptr->Value; + } + } + /* FORMAT OUT */ + fmt.Id = hFormatOutId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmt, + IMRD_SDMD_FMT_IDX_ID, &fmt, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du Format OUT <%d> !", fmt.Id); + status = IMRS_KO; + } + else + { + myMapCmd_Ptr->Fmt_Output_Ptr = node_ptr->Value; + } + + if (hIndFmtAttrOutId >= 0) + { + fmtattr.Id = hFmtAttrOutId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmtAttr, + IMRD_SDMD_FMTATTR_IDX_ID, &fmtattr, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du FmtAttr OUT <%d> !", fmtattr.Id); + status = IMRS_KO; + } + else + { + myMapCmd_Ptr->FmtAttr_Output_Ptr = node_ptr->Value; + } + } + /* MsgMap */ + msgmap.Id = hMsgMapId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsgMap, + IMRD_SDMD_MSGMAP_IDX_ID, &msgmap, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du MSGMAP <%d> !", msgmap.Id); + status = IMRS_KO; + } + else + { + myMapCmd_Ptr->MsgMap_Ptr = node_ptr->Value; + } + } + /*********** Jump Table ************/ + if((hMapCmdType == IMRD_MAPCMD_TYPE_IDENT)&&(status == IMRS_OK)) + { + status = SDM_SQL_Load_JumpTable(&(myMapCmd_Ptr->Jump_Tab), &myJumpTableNbElt, hMapCmdId); + if (status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors du chargement de la Jump Table : <%d> !", status); + } + else + { + myMapCmd_Ptr->JmpTbleNbElts = myJumpTableNbElt; + } + } + + nd_status = ND_DataStruct_Value_Add( myMapPath_Ptr->MapCmd_Struct_Ptr, (void *)(myMapCmd_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Value_Add -- MapCmd failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if(status != IMRS_OK) + { + free(myMapCmd_Ptr); + } + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_cmd_map_path; + + return(status); + +} + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Load_JumpTable(IMRT_Jump **JumpTable_Ptr_Ptr, int * JumpTableNbElt_Ptr ,IMRT_MapCmd_Id IdMapCmd) +{ + IMRT_Status status; + NDT_Status nd_status; + const char sFunctionName []="SDM_SQL_Load_JumpTable"; + + EXEC SQL BEGIN DECLARE SECTION; + IMRT_Msg_Id hMsgId; + IMRT_Fmt_Id hFormatId; + short hBrancheIdIdent; + short hIndMsgId; + short hIndFormatId; + short hIndBrancheIdIdent; + EXEC SQL END DECLARE SECTION; + + IMRT_Fmt fmt; + IMRT_Msg msg; + NDT_Node *node_ptr; + IMRT_Jump *jump_ptr; + short IndexTable; + + status = IMRS_OK; + IndexTable = -1; + jump_ptr = NULL; + + EXEC SQL DECLARE cur_imr_jump_table CURSOR FOR + SELECT MSG_ID, FORMAT_ID, IDENT_BRANCHE_ID + FROM IMR_JUMP_TABLE + WHERE MAPCMD_ID = :IdMapCmd + ORDER BY NUM_ORDRE_JUMP ASC; + + EXEC SQL OPEN cur_imr_jump_table; + do + { + + EXEC SQL FETCH cur_imr_jump_table + INTO :hMsgId:hIndMsgId, + :hFormatId:hIndFormatId, + :hBrancheIdIdent:hIndBrancheIdIdent; + + if (sqlca.sqlcode == 0) + { + IndexTable = IndexTable + 1; + *JumpTableNbElt_Ptr = IndexTable + 1; + jump_ptr = (IMRT_Jump *)realloc((void *)*JumpTable_Ptr_Ptr , + (size_t)((IndexTable + 1) * sizeof(IMRT_Jump))); + if (jump_ptr == NULL) + { + IMRD_LM_LOG_ERROR_0( "Erreur lors de la reallocation de la Jump Table !"); + return(IMRS_KO); + } + else + { + *JumpTable_Ptr_Ptr = jump_ptr; + if (hIndBrancheIdIdent >= 0) + (*JumpTable_Ptr_Ptr)[IndexTable].Branche_Id = hBrancheIdIdent; + } + + /* FORMAT */ + fmt.Id = hFormatId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmt, + IMRD_SDMD_FMT_IDX_ID, &fmt, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche Message <%d> !", fmt.Id); + return(IMRS_KO); + } + else + { + (*JumpTable_Ptr_Ptr)[IndexTable].Fmt_Ptr = node_ptr->Value; + } + /* Msg */ + msg.Id = hMsgId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, + IMRD_SDMD_MSG_IDX_ID, &msg, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche Message <%d> !", msg.Id); + return(IMRS_KO); + } + else + { + (*JumpTable_Ptr_Ptr)[IndexTable].Msg_Ptr = node_ptr->Value; + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)); + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_jump_table; + + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_FmtAttr_Header(FILE *dump_file) +{ + fprintf(dump_file, "---------------------------------------------------\n"); + fprintf(dump_file, "-- Init file of IMR_FMT_ATTR --\n"); + fprintf(dump_file, "---------------------------------------------------\n\n"); + fprintf(dump_file, "INSERT INTO IMR_DATA_VERSION(VERS_NAME, VERS_LABEL, VERS_DATE) VALUES('FmtAttr', '%s', '%s');\n\n", + ((IMRT_Data_Version *)(IMRG_SDM_Base.RootFmtAttr->User_Ptr))->Label, + ((IMRT_Data_Version *)(IMRG_SDM_Base.RootFmtAttr->User_Ptr))->Date); + fprintf(dump_file, "Delete IMR_FMT_ATTR;\n\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_FmtAttr_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootFmtAttr, IMRD_SDMD_CMD_API_SQL_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0( "SQL Dump RootFmtAttr failed !"); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_FmtAttr_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\nCommit;\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_FmtAttr(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, "init_imr_fmt_attr.sql"); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_SQL_Dump_FmtAttr_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_FmtAttr_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_FmtAttr_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Appli_Header(FILE *dump_file) +{ + fprintf(dump_file, "---------------------------------------------------\n"); + fprintf(dump_file, "-- Init file of IMR_APPLI --\n"); + fprintf(dump_file, "---------------------------------------------------\n\n"); + fprintf(dump_file, "INSERT INTO IMR_DATA_VERSION(VERS_NAME, VERS_LABEL, VERS_DATE) VALUES('Appl', '%s', '%s');\n\n", + ((IMRT_Data_Version *)(IMRG_SDM_Base.RootAppl->User_Ptr))->Label, + ((IMRT_Data_Version *)(IMRG_SDM_Base.RootAppl->User_Ptr))->Date); + fprintf(dump_file, "Delete IMR_APPLI;\n\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Appli_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootAppl, IMRD_SDMD_CMD_API_SQL_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0( "SQL Dump RootAppl failed !"); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Appli_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\nCommit;\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Appli(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, "init_imr_appli.sql"); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_SQL_Dump_Appli_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_Appli_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_Appli_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Format_Header(FILE *dump_file) +{ + fprintf(dump_file, "---------------------------------------------------\n"); + fprintf(dump_file, "-- Init file of IMR_FORMAT & IMR_FMT_MSG --\n"); + fprintf(dump_file, "---------------------------------------------------\n\n"); + fprintf(dump_file, "INSERT INTO IMR_DATA_VERSION(VERS_NAME, VERS_LABEL, VERS_DATE) VALUES('Fmt', '%s', '%s');\n\n", + ((IMRT_Data_Version *)(IMRG_SDM_Base.RootFmt->User_Ptr))->Label, + ((IMRT_Data_Version *)(IMRG_SDM_Base.RootFmt->User_Ptr))->Date); + fprintf(dump_file, "Delete IMR_FMT_MSG;\n\n"); + fprintf(dump_file, "Delete IMR_FORMAT;\n\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Format_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootFmt, IMRD_SDMD_CMD_API_SQL_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0( "SQL Dump RootFmt failed !"); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Format_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\nCommit;\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Format(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, "init_imr_format.sql"); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_SQL_Dump_Format_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_Format_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_Format_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_MapPath_Header(FILE *dump_file) +{ + fprintf(dump_file, "---------------------------------------------------\n"); + fprintf(dump_file, "-- Init file of IMR_MAPPATH & IMR_CMD_MAP_PATH --\n"); + fprintf(dump_file, "-- IMR_MAPCMD & IMR_CMD_IDENT --\n"); + fprintf(dump_file, "-- IMR_JUMP_TABLE & IMR_CMD_MAP --\n"); + fprintf(dump_file, "-- IMR_CMD_GOTO & IMR_CMD_COPY --\n"); + fprintf(dump_file, "---------------------------------------------------\n\n"); + fprintf(dump_file, "INSERT INTO IMR_DATA_VERSION(VERS_NAME, VERS_LABEL, VERS_DATE) VALUES('MapPath', '%s', '%s');\n\n", + ((IMRT_Data_Version *)(IMRG_SDM_Base.RootMapPath->User_Ptr))->Label, + ((IMRT_Data_Version *)(IMRG_SDM_Base.RootMapPath->User_Ptr))->Date); + fprintf(dump_file, "Delete IMR_CMD_COPY;\n\n"); + fprintf(dump_file, "Delete IMR_CMD_GOTO;\n\n"); + fprintf(dump_file, "Delete IMR_CMD_MAP;\n\n"); + fprintf(dump_file, "Delete IMR_JUMP_TABLE;\n\n"); + fprintf(dump_file, "Delete IMR_CMD_IDENT;\n\n"); + fprintf(dump_file, "Delete IMR_MAPCMD;\n\n"); + fprintf(dump_file, "Delete IMR_CMD_MAP_PATH;\n\n"); + fprintf(dump_file, "Delete IMR_MAPPATH;\n\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_MapPath_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootMapPath, IMRD_SDMD_CMD_API_SQL_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0( "SQL Dump RootMapPath failed !"); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_MapPath_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\nCommit;\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_MapPath(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, "init_imr_mappath.sql"); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_SQL_Dump_MapPath_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_MapPath_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_MapPath_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_BufferInfo_Dump(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + status = SDM_SQL_Dump_Appli(); + + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_Format(); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_MapPath(); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_FmtAttr(); + if(status == IMRS_OK) + { + strcpy(dump_filename, "init_imr_mapcmd_type.sql"); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + fprintf(dump_file, "---------------------------------------------------\n"); + fprintf(dump_file, "-- Init file of IMR_MAPCMD_TYPE --\n"); + fprintf(dump_file, "---------------------------------------------------\n\n"); + fprintf(dump_file, "Delete IMR_MAPCMD_TYPE;\n\n"); + + fprintf(dump_file, "INSERT INTO IMR_MAPCMD_TYPE(MAPCMD_TYPE) VALUES(0);\n"); + fprintf(dump_file, "INSERT INTO IMR_MAPCMD_TYPE(MAPCMD_TYPE) VALUES(1);\n"); + fprintf(dump_file, "INSERT INTO IMR_MAPCMD_TYPE(MAPCMD_TYPE) VALUES(2);\n"); + fprintf(dump_file, "INSERT INTO IMR_MAPCMD_TYPE(MAPCMD_TYPE) VALUES(3);\n"); + fprintf(dump_file, "INSERT INTO IMR_MAPCMD_TYPE(MAPCMD_TYPE) VALUES(4);\n"); + + fprintf(dump_file, "\nCommit;\n"); + + fclose( dump_file); + } + } + } + } + } + + return(status); +} +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ diff --git a/src/libstatic_data_mng/src/buffer_info_xml.c b/src/libstatic_data_mng/src/buffer_info_xml.c new file mode 100644 index 0000000..8f908d2 --- /dev/null +++ b/src/libstatic_data_mng/src/buffer_info_xml.c @@ -0,0 +1,1837 @@ +/*----------------------------------------------------------------------------*/ +/* File: buffer_info_xml.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _BUFFER_INFO_XML_C_ + +#include "buffer_info_xml.h" + + + +IMRT_Status SDM_XML_BufferInfo_Init(IMRT_Path Lib_Path) +{ + SDMT_BufferInfo_Contexte Buffer_Info_Ctx; + IMRT_Status status, StatusTmp; + char Xml_File_Name[255]; + + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading FmtAttr..."); + + Buffer_Info_Ctx.flagerror = 0; + Buffer_Info_Ctx.CptFmtAttr = IMRD_FMTATTR_ID_UNKNOWN; + memset(Buffer_Info_Ctx.PathArray,0,sizeof(Buffer_Info_Ctx.PathArray)); + Buffer_Info_Ctx.PresentLevelTag = IMRD_SDMD_MIN_LEVEL_TAG; + memset(Xml_File_Name,0,sizeof(Xml_File_Name)); + strcpy(Xml_File_Name, Lib_Path); + strcat(Xml_File_Name, "/"); + strcat(Xml_File_Name, SDMD_FMTATTR_FILE); + + status = SDM_XML_Load_FmtAttr(Xml_File_Name, &(Buffer_Info_Ctx)); + + if(status == IMRS_OK) + { + IMRG_SDM_Base.RootFmtAttr = Buffer_Info_Ctx.RootFmtAttr; + + IMRD_LM_LOG_INFO_1( "FmtAtt loaded: (%d)", IMRG_SDM_Base.RootFmtAttr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading Fmt..."); + + Buffer_Info_Ctx.flagerror = 0; + Buffer_Info_Ctx.CptFmt = IMRD_FMT_ID_UNKNOWN; + memset(Buffer_Info_Ctx.PathArray,0,sizeof(Buffer_Info_Ctx.PathArray)); + Buffer_Info_Ctx.PresentLevelTag = IMRD_SDMD_MIN_LEVEL_TAG; + memset(Xml_File_Name,0,sizeof(Xml_File_Name)); + strcpy(Xml_File_Name, Lib_Path); + strcat(Xml_File_Name, "/"); + strcat(Xml_File_Name, SDMD_FORMAT_FILE); + + status = SDM_XML_Load_Format(Xml_File_Name, &(Buffer_Info_Ctx)); + + if(status == IMRS_OK) + { + IMRG_SDM_Base.RootFmt = Buffer_Info_Ctx.RootFormat; + + IMRD_LM_LOG_INFO_1( "Fmt loaded: (%d)", IMRG_SDM_Base.RootFmt->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading Appl..."); + + memset(Buffer_Info_Ctx.PathArray,0,sizeof(Buffer_Info_Ctx.PathArray)); + Buffer_Info_Ctx.PresentLevelTag = IMRD_SDMD_MIN_LEVEL_TAG; + Buffer_Info_Ctx.CptAppl = IMRD_APPL_ID_UNKNOWN; + memset(Xml_File_Name,0,sizeof(Xml_File_Name)); + strcpy(Xml_File_Name, Lib_Path); + strcat(Xml_File_Name, "/"); + strcat(Xml_File_Name, SDMD_APPLI_FILE); + + status = SDM_XML_Load_Appli(Xml_File_Name, &(Buffer_Info_Ctx)); + if(status == IMRS_OK) + { + IMRG_SDM_Base.RootAppl = Buffer_Info_Ctx.RootAppli; + + IMRD_LM_LOG_INFO_1( "Appl loaded: (%d)", IMRG_SDM_Base.RootAppl->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading MapPath..."); + + Buffer_Info_Ctx.NbMapPath = 0 ; + Buffer_Info_Ctx.NbMapCmd = 0 ; + memset(Buffer_Info_Ctx.PathArray,0,sizeof(Buffer_Info_Ctx.PathArray)); + Buffer_Info_Ctx.PresentLevelTag = IMRD_SDMD_MIN_LEVEL_TAG; + memset(Xml_File_Name,0,sizeof(Xml_File_Name)); + strcpy(Xml_File_Name, Lib_Path); + strcat(Xml_File_Name, "/"); + strcat(Xml_File_Name, SDMD_MAPPATH_FILE); + status = SDM_XML_Load_MapPath(Xml_File_Name, &(Buffer_Info_Ctx)); + if(status == IMRS_OK) + { + IMRG_SDM_Base.RootMapPath = Buffer_Info_Ctx.RootMapPath; + + IMRD_LM_LOG_INFO_1( "MapPath loaded: (%d)", IMRG_SDM_Base.RootMapPath->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't load MapPath !"); + + StatusTmp = SDM_Close_RootFmtAttr(); + StatusTmp = SDM_Close_RootFmt(); + StatusTmp = SDM_Close_RootAppl(); + } + + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't load Appl !"); + + StatusTmp = SDM_Close_RootFmtAttr(); + StatusTmp = SDM_Close_RootFmt(); + } + } + else + { + StatusTmp = SDM_Close_RootFmtAttr(); + + IMRD_LM_LOG_ERROR_0( "Can't load Fmt !"); + } + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't load FmtAttr !"); + } + + return(status); + +} + + + +static IMRT_Status error(SDMT_BufferInfo_Contexte *ctx , const char *msg, ...) +{ + xmlParserCtxt * SaxCtx; + + SaxCtx = ctx->SaxCtxHdl; + + IMRD_LM_LOG_ERROR_1( "CallBack error: <%s> !",msg); + + SaxCtx->sax = &ErrorSAXHandlerStruct; + ctx->flagerror = 1; + ctx->FataError.errorCode = SDMD_XML_CODE_ERROR_1; + strcpy(ctx->FataError.libError,msg) ; + +} + +IMRT_Status startElementNsAppli( SDMT_BufferInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes) +{ + NDT_Status nd_status; + const char functionname [] = "startElementNsAppli"; + char DescErr [IMRD_SDMD_DESCERR_LEN]; + + if(strcmp((const char*)localname, IMRD_SDMD_TAG_APPLI) == 0) + { + /*création d'un nouvelle objet appli*/ + if( ( nd_status = ND_Value_Alloc( ctx->RootAppli, (void **)&(ctx->CurrentAppli)) != NDS_OK)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_APPLI); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + } +} + + +IMRT_Status startElementNsFmtAttr( SDMT_BufferInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes) +{ + NDT_Status nd_status; + const char functionname [] = "startElementNsFmtAttr"; + char DescErr [IMRD_SDMD_DESCERR_LEN]; + + if(strcmp((const char*)localname, IMRD_SDMD_TAG_FMTATTR) == 0) + { + /*création d'un nouvelle objet FmtAttr*/ + if( ( nd_status = ND_Value_Alloc( ctx->RootFmtAttr, (void **)&(ctx->CurrentFmtAttr)) != NDS_OK)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_FMTATTR); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + } + +} + + +IMRT_Status startElementNsFmt( SDMT_BufferInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes) +{ + NDT_Status nd_status; + const char functionname [] = "startElementNsFmt"; + char DescErr [IMRD_SDMD_DESCERR_LEN]; + + + if(strcmp((const char*)localname,IMRD_SDMD_TAG_FORMAT) == 0) + { + /*création d'un nouvel objet format*/ + if(( nd_status = ND_Value_Alloc( ctx->RootFormat, (void **)&(ctx->CurrentFormat)) != NDS_OK)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_FORMAT); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + else + { + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + } + else if (strcmp((const char*)localname,IMRD_SDMD_TAG_FMTMSG) == 0) + { + /*creation d'un nouvel objet FmtMsg*/ + if( ( nd_status = ND_Value_Alloc( ctx->CurrentFormat->FmtMsg_Struct_Ptr, (void **)&(ctx->CurrentFmtMsg)) != NDS_OK)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_3, IMRD_SDMD_TAG_FMTMSG); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname , DescErr, SDMD_XML_CODE_ERROR_3 ); + } + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + +} + +IMRT_Status startElementNsMapPath( SDMT_BufferInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes) +{ + NDT_Status nd_status; + const char functionname [] = "startElementNsMapPath"; + char DescErr [IMRD_SDMD_DESCERR_LEN]; + IMRT_Jump *jump_ptr; + + if(strcmp((const char *)localname, IMRD_SDMD_TAG_MAPPATH) == 0) + { + /*creation d'un nouvel objet MapPath*/ + if( ( nd_status = ND_Value_Alloc(ctx->RootMapPath,(void **)&(ctx->CurrentMapPath)) != NDS_OK)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_3, IMRD_SDMD_TAG_MAPPATH); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname ,DescErr, SDMD_XML_CODE_ERROR_3); + } + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_MAPCMD) == 0) + { + /*creation d'un nouvel objet MapCmd*/ + if( ( nd_status = ND_Value_Alloc( ctx->CurrentMapPath->MapCmd_Struct_Ptr, (void **)&(ctx->CurrentMapCmd)) != NDS_OK)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_3, IMRD_SDMD_TAG_MAPCMD); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname , DescErr, SDMD_XML_CODE_ERROR_3 ); + } + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + else if ((strcmp((const char *)localname, IMRD_SDMD_TAG_MAPPER) == 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_COPIE) == 0) + ) + { + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + else if(strcmp((const char *)localname, IMRD_SDMD_TAG_IDENTIFIER) == 0) + { + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + ctx->IdxJpTble = 0; + } + else if(strcmp((const char*)localname,IMRD_SDMD_TAG_GO_TO)== 0) + { + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + + if (ctx->PresentLevelTag == IMRD_SDMD_LEVEL_TAG_3) + { + jump_ptr = (IMRT_Jump *)realloc((void *)ctx->CurrentMapCmd->Jump_Tab , + (size_t)((ctx->CurrentMapCmd->JmpTbleNbElts + 1) * sizeof(IMRT_Jump))); + if (jump_ptr == NULL) + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_3, "Jump Table"); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname , DescErr, SDMD_XML_CODE_ERROR_3); + } + else + { + ctx->CurrentMapCmd->Jump_Tab = jump_ptr; + ctx->CurrentMapCmd->JmpTbleNbElts++; + } + } + } + +} + + + +IMRT_Status endElementNsAppli( SDMT_BufferInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI) +{ + NDT_Status nd_status; + IMRT_Status status_tmp; + const char fonctionname [] ="endElementNsAppli"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + + if(strcmp((const char*)localname, IMRD_SDMD_TAG_APPLI) == 0) + { + /*insertion de l'appli courante*/ + /*insertion du format*/ + ctx->CurrentAppli->Id = ctx->CptAppl; + if( ( nd_status = ND_DataStruct_Value_Add( ctx->RootAppli, (void *)(ctx->CurrentAppli))) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_3, IMRD_SDMD_TAG_APPLI); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_3 ); + } + ctx->CptAppl ++; + } + else if(strcmp((const char*)localname, IMRD_SDMD_TAG_NAME) == 0) + { + strcpy(ctx->CurrentAppli->Name, ctx->value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_VERSION) == 0) + { + IMRD_LM_LOG_INFO_1( "[Appl]: [%s]", ctx->value); + status_tmp = SDM_Set_Struct_Version((IMRT_Data_Version *)ctx->RootAppli->User_Ptr, (char *)ctx->value); + } +} + + +IMRT_Status endElementNsFmtAttr( SDMT_BufferInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI) +{ + NDT_Status nd_status; + IMRT_Status status, status_tmp; + const char fonctionname [] ="endElementNsFmtAttr"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + + if(strcmp((const char*)localname, IMRD_SDMD_TAG_FMTATTR) == 0) + { + ctx->CurrentFmtAttr->Id = ctx->CptFmtAttr; + if( ( nd_status = ND_DataStruct_Value_Add( ctx->RootFmtAttr, (void *)(ctx->CurrentFmtAttr))) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_3, IMRD_SDMD_TAG_FMTATTR); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_3 ); + } + ctx->CptFmtAttr ++; + } + else if(strcmp((const char*)localname, IMRD_SDMD_TAG_NAME) == 0) + { + strcpy(ctx->CurrentFmtAttr->Name, ctx->value); + } + else if(strcmp((const char*)localname, IMRD_SDMD_TAG_VALUE) == 0) + { + memset(ctx->CurrentFmtAttr->Value,'\0', IMRD_FMTATTR_VALUE_SIZE); + status = SDM_ConvertAttribute(ctx->value, ctx->CurrentFmtAttr->Value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_VERSION) == 0) + { + IMRD_LM_LOG_INFO_1( "[FmtAtt]: [%s]", ctx->value); + status_tmp = SDM_Set_Struct_Version((IMRT_Data_Version *)ctx->RootFmtAttr->User_Ptr, (char *)ctx->value); + } +} + + +IMRT_Status endElementNsMapPath( SDMT_BufferInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI) +{ + NDT_Node * node_ptr; + NDT_Status nd_status; + IMRT_Status status, status_tmp; + IMRT_MsgMap msgmap; + IMRT_Appl appli; + IMRT_Fmt fmt; + IMRT_Msg msg; + IMRT_FmtAttr FmtAttr; + char fonctionname [] = "endElementNsMapPath"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + + + if (strcmp((const char *)localname, IMRD_SDMD_TAG_FORMAT) == 0) + { + + strcpy(fmt.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmt, + IMRD_SDMD_FMT_IDX_NAME, &fmt, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_FORMAT, fmt.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapCmd->Jump_Tab[ctx->IdxJpTble].Fmt_Ptr = node_ptr->Value; + } + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_BRANCHE_ID) == 0) + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_1: /* IMRD_SDMD_TAG_MAPCMD */ + { + ctx->CurrentMapCmd->Branche_Id = atoi(ctx->value); + break; + } + + case IMRD_SDMD_LEVEL_TAG_2: /* Command go_to */ + { + ctx->CurrentMapCmd->Goto_Branche_Id = atoi(ctx->value); + break; + } + + case IMRD_SDMD_LEVEL_TAG_3: /* Jump Table */ + { + ctx->CurrentMapCmd->Jump_Tab[ctx->IdxJpTble].Branche_Id = atoi(ctx->value); + break; + } + + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_MAPPATH_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_TYPE) == 0) + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_2: + { + strcpy(msg.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, + IMRD_SDMD_MSG_IDX_NAME, &msg, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_TYPE, msg.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapCmd->Ident_First_Msg_Ptr = node_ptr->Value; + } + break; + } + + case IMRD_SDMD_LEVEL_TAG_3: + { + strcpy(msg.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, + IMRD_SDMD_MSG_IDX_NAME, &msg, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_TYPE, msg.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapCmd->Jump_Tab[ctx->IdxJpTble].Msg_Ptr = node_ptr->Value; + } + break; + } + + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_MAPPATH_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_INPUTFORMAT) == 0) + { + strcpy(fmt.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmt, + IMRD_SDMD_FMT_IDX_NAME, &fmt, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_INPUTFORMAT, fmt.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_2: + { + ctx->CurrentMapCmd->Fmt_Input_Ptr = node_ptr->Value; + break; + } + + case IMRD_SDMD_LEVEL_TAG_0: + { + ctx->CurrentMapPath->Fmt_Input_Ptr = node_ptr->Value; + break; + } + + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_MAPPATH_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_INPUTFORMAT_ATTR) == 0) + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_2: + { + + strcpy(FmtAttr.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmtAttr, + IMRD_SDMD_FMTATTR_IDX_NAME, &FmtAttr, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_TYPE, FmtAttr.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapCmd->FmtAttr_Input_Ptr = node_ptr->Value; + } + + break; + } + + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_MAPPATH_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_OUTPUTFORMAT) == 0) + { + strcpy(fmt.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmt, + IMRD_SDMD_FMT_IDX_NAME, &fmt, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_OUTPUTFORMAT, fmt.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_2: + { + ctx->CurrentMapCmd->Fmt_Output_Ptr = node_ptr->Value; + break; + } + + case IMRD_SDMD_LEVEL_TAG_0: + { + ctx->CurrentMapPath->Fmt_Output_Ptr = node_ptr->Value; + break; + } + + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_MAPPATH_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_OUTPUTFORMAT_ATTR) == 0) + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_2: + { + strcpy(FmtAttr.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmtAttr, + IMRD_SDMD_FMTATTR_IDX_NAME, &FmtAttr, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_TYPE, FmtAttr.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapCmd->FmtAttr_Output_Ptr = node_ptr->Value; + } + break; + } + + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_MAPPATH_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_INPUTBUFFER) == 0) + { + ctx->CurrentMapCmd->Buffer_Id_Input = atoi(ctx->value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_OUTPUTBUFFER) == 0) + { + ctx->CurrentMapCmd->Buffer_Id_Output = atoi(ctx->value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_NUMBUFFER) == 0) + { + ctx->CurrentMapCmd->Buffer_Id_Ident = atoi(ctx->value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_INPUTAPPLI) == 0) + { + strcpy(appli.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootAppl, + IMRD_SDMD_APPL_IDX_NAME, &appli, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_INPUTAPPLI, appli.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapPath->Appl_Input_Ptr = node_ptr->Value; + } + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_OUTPUTAPPLI) == 0) + { + strcpy(appli.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootAppl, + IMRD_SDMD_APPL_IDX_NAME, &appli, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_INPUTAPPLI, appli.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapPath->Appl_Output_Ptr = node_ptr->Value; + } + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_IDENTTOTAL) == 0) + { + if(*(ctx->value) == IMRD_YES) + { + ctx->CurrentMapCmd->Ident_Total = IMRD_TRUE; + } + else + { + ctx->CurrentMapCmd->Ident_Total = IMRD_FALSE; + } + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_MSGMAP) == 0) + { + strcpy(msgmap.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsgMap, + IMRD_SDMD_MSGMAP_IDX_NAME, &msgmap, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_MSGMAP, msgmap.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapCmd->MsgMap_Ptr = node_ptr->Value; + } + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_CLEARFLAG) == 0) + { + ctx->CurrentMapCmd->Clear_Flag = atoi(ctx->value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_GO_TO) == 0) + { + ctx->CurrentMapCmd->TypeCmd = IMRD_MAPCMD_TYPE_GOTO; + if(ctx->PresentLevelTag == IMRD_SDMD_LEVEL_TAG_3) + { + ctx->IdxJpTble++; + + } + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_IDENTIFIER) == 0) + { + ctx->CurrentMapCmd->TypeCmd = IMRD_MAPCMD_TYPE_IDENT; + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + ctx->IdxJpTble = 0; + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_MAPPER) == 0) + { + ctx->CurrentMapCmd->TypeCmd = IMRD_MAPCMD_TYPE_MAP; + + if (ctx->CurrentMapCmd->FmtAttr_Input_Ptr == NULL) + { + strcpy(FmtAttr.Name, IMRD_FMTATTR_NAME_UNKNOWN); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmtAttr, + IMRD_SDMD_FMTATTR_IDX_NAME, &FmtAttr, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_TYPE, FmtAttr.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapCmd->FmtAttr_Input_Ptr = node_ptr->Value; + } + } + if (ctx->CurrentMapCmd->FmtAttr_Output_Ptr == NULL) + { + strcpy(FmtAttr.Name, IMRD_FMTATTR_NAME_UNKNOWN); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmtAttr, + IMRD_SDMD_FMTATTR_IDX_NAME, &FmtAttr, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_TYPE, FmtAttr.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapCmd->FmtAttr_Output_Ptr = node_ptr->Value; + } + } + + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_COPIE) == 0) + { + ctx->CurrentMapCmd->TypeCmd = IMRD_MAPCMD_TYPE_COPY; + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_MAPCMD) == 0) + { + if(ctx->CurrentMapCmd->Ident_First_Msg_Ptr == NULL) + { + msg.Id = IMRD_MSG_ID_UNKNOWN; + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, + IMRD_SDMD_MSG_IDX_ID, &msg, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_TYPE, "unknown" ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentMapCmd->Ident_First_Msg_Ptr = node_ptr->Value; + } + } + + if (ctx->CurrentMapCmd->TypeCmd == IMRD_MAPCMD_TYPE_MAP) + { + status = SDM_Control_Fmt_Attr(ctx->CurrentMapCmd->MsgMap_Ptr->Msg_Input_Ptr, + ctx->CurrentMapCmd->Fmt_Input_Ptr->FmtMsg_Struct_Ptr, + ctx->CurrentMapCmd->FmtAttr_Input_Ptr); + + if (status == IMRS_OK) + { + status = SDM_Control_Fmt_Attr(ctx->CurrentMapCmd->MsgMap_Ptr->Msg_Output_Ptr, + ctx->CurrentMapCmd->Fmt_Output_Ptr->FmtMsg_Struct_Ptr, + ctx->CurrentMapCmd->FmtAttr_Output_Ptr); + + if (status != IMRS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_LIB_ERROR_11 ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_CODE_ERROR_11 ); + } + } + else + { + snprintf(DescErr,sizeof(DescErr),SDMD_LIB_ERROR_11 ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_CODE_ERROR_11 ); + } + } + + ctx->CurrentMapCmd->MapCmd_Id = ctx->NbMapCmd; + if( ( nd_status = ND_DataStruct_Value_Add( ctx->CurrentMapPath->MapCmd_Struct_Ptr, (void *)(ctx->CurrentMapCmd))) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_2,IMRD_SDMD_TAG_MAPCMD ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_2 ); + } + ctx->NbMapCmd++; + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_MAPPATH) == 0) + { + ctx->CurrentMapPath->idMapPath = ctx->NbMapPath; + + if( ( nd_status = ND_DataStruct_Value_Add( ctx->RootMapPath, (void *)(ctx->CurrentMapPath))) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_2,IMRD_SDMD_TAG_MAPPATH ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_2 ); + } + ctx->NbMapPath++; + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_VERSION) == 0) + { + IMRD_LM_LOG_INFO_1( "[MapPath]: [%s]", ctx->value); + status_tmp = SDM_Set_Struct_Version((IMRT_Data_Version *)ctx->RootMapPath->User_Ptr, (char *)ctx->value); + } + +} + + +IMRT_Status endElementNsFmt ( SDMT_BufferInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI) +{ + NDT_Node * node_ptr; + NDT_Status nd_status; + IMRT_Status status, status_tmp; + IMRT_Msg message; + IMRT_FmtAttr FmtAttr; + const char functionname [] = "endElementNsFmt"; + char DescErr [IMRD_SDMD_DESCERR_LEN]; + + + if (strcmp((const char *)localname, IMRD_SDMD_TAG_NAME) == 0) + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_0: + { + strcpy(ctx->CurrentFormat->Name, ctx->value); + break; + } + case IMRD_SDMD_LEVEL_TAG_1: + { + /*recherch du message avec le nom*/ + strcpy(message.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, + IMRD_SDMD_MSG_IDX_NAME, &message, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5, IMRD_SDMD_TAG_FORMAT); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + else + { + ctx->CurrentFmtMsg->Msg_Ptr = node_ptr->Value; + } + + break; + } + + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_FORMAT_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_BRANCHE_ID) == 0) + { + ctx->CurrentFmtMsg->Branche_Id = atoi(ctx->value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_FMTATTR_NAME) == 0) + { + strcpy(FmtAttr.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmtAttr, + IMRD_SDMD_FMTATTR_IDX_NAME, &FmtAttr, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_TYPE, FmtAttr.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentFmtMsg->FmtAttr_Ptr = node_ptr->Value; + } + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_FORMAT) == 0) + { + + /*insertion du format*/ + ctx->CurrentFormat->Id = ctx->CptFmt; + if( ( nd_status = ND_DataStruct_Value_Add( ctx->RootFormat, (void *)(ctx->CurrentFormat))) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_FORMAT); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + ctx->CptFmt ++; + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_FMTMSG) == 0) + { + if( ( nd_status = ND_DataStruct_Value_Add( ctx->CurrentFormat->FmtMsg_Struct_Ptr, (void *)(ctx->CurrentFmtMsg))) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5, IMRD_SDMD_TAG_FMTMSG); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_VERSION) == 0) + { + IMRD_LM_LOG_INFO_1( "[Fmt]: [%s]", ctx->value); + status_tmp = SDM_Set_Struct_Version((IMRT_Data_Version *)ctx->RootFormat->User_Ptr, (char *)ctx->value); + } +} + + + +IMRT_Status Buff_Info_characters(SDMT_BufferInfo_Contexte * ctx , const xmlChar *ch, int len) +{ + char output[40]; + int i; + + memset(ctx->value,0, sizeof(ctx->value)); + + for (i = 0;(ivalue[i] = ch[i]; + ctx->value[i] = 0; +} + + + +IMRT_Status SDM_XML_Load_Appli( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte) +{ + IMRT_Status status; + NDT_Status nd_status; + char * docname = NULL; + NDT_Index_Type *index_type_ptr; + xmlDocPtr doc = NULL; + xmlDtdPtr dtd; + xmlParserCtxtPtr ctxt =NULL; + xmlSAXHandlerPtr SAXHandler; + xmlSAXHandlerPtr SAXHandler_Sav; + const char functionname []="SDM_XML_Load_Appli"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + IMRT_Data_Version *Data_Version_Ptr; + + LIBXML_TEST_VERSION + xmlKeepBlanksDefault(0); + xmlSAXDefaultVersion(2); + xmlLineNumbersDefault(1); + + status = IMRS_OK; + docname = demo_file; + ctxt = xmlNewParserCtxt(); + /*initialisation des indexes*/ + index_type_ptr = Appl_Struct_initial_idx_tab; + + + if(ctxt != NULL) + { + mycontexte->flagerror = IMRS_OK; + SAXHandler = &SaxAppliHandlerStruct; + mycontexte->SaxCtxHdl = ctxt; + ctxt->userData = mycontexte; + SAXHandler_Sav = ctxt->sax; + ctxt->sax = SAXHandler; + ctxt->sax2 = 1 ; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + Data_Version_Ptr->Label[0] = '\0'; + Data_Version_Ptr->Date[0] = '\0'; + if( ( nd_status = ND_DataStruct_Open(&(mycontexte->RootAppli),IMRD_SDMD_APPL_STRUCT_IDX_NB,index_type_ptr, "SDM_Appl_Manager",SDM_Appl_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr)) != NDS_OK) + { + status = IMRS_KO; + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_APPLI); + SDM_RaiseError(mycontexte->SaxCtxHdl,&(mycontexte->FataError),&(mycontexte->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + else + { + doc = xmlCtxtReadFile(ctxt,docname,NULL,XML_PARSE_DTDATTR+XML_PARSE_DTDVALID); + if (ctxt->lastError.code != XML_ERR_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_3( "Erreur de parsing du fichier (%s): (%s) line (%d) !", docname, ctxt->lastError.message, ctxt->lastError.line); + } + else if(mycontexte->flagerror != IMRS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "%s !", mycontexte->FataError.libError); + } + else + { + index_type_ptr =Appl_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(mycontexte->RootAppli,index_type_ptr, IMRD_SDMD_APPL_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump(mycontexte->RootAppli);*/ + } + } + + if((status != IMRS_OK)&&(mycontexte->RootAppli != NULL)) + { + free(mycontexte->RootAppli->User_Ptr); + nd_status = ND_DataStruct_Close(mycontexte->RootAppli); + } + + ctxt->sax = SAXHandler_Sav ; + xmlFreeParserCtxt(ctxt); + } + else + { + status = IMRS_KO; + } + + return(status); + +} + + +IMRT_Status SDM_XML_Load_FmtAttr( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte) +{ + IMRT_Status status; + NDT_Status nd_status; + char * docname = NULL; + NDT_Index_Type *index_type_ptr; + xmlDocPtr doc = NULL; + xmlDtdPtr dtd; + xmlParserCtxtPtr ctxt =NULL; + xmlSAXHandlerPtr SAXHandler; + xmlSAXHandlerPtr SAXHandler_Sav; + const char functionname[]= "SDM_XML_Load_FmtAttr"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + IMRT_Data_Version *Data_Version_Ptr; + + LIBXML_TEST_VERSION + xmlKeepBlanksDefault(0); + xmlSAXDefaultVersion(2); + xmlLineNumbersDefault(1); + + status = IMRS_OK; + docname = demo_file; + ctxt = xmlNewParserCtxt(); + /*initialisation des indexes*/ + index_type_ptr = FmtAttr_Struct_initial_idx_tab; + + if(ctxt != NULL) + { + mycontexte->flagerror = IMRS_OK; + SAXHandler = &SaxFmtAttrHandlerStruct; + mycontexte->SaxCtxHdl = ctxt; + ctxt->userData = mycontexte; + SAXHandler_Sav = ctxt->sax; + ctxt->sax = SAXHandler; + ctxt->sax2 = 1 ; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + Data_Version_Ptr->Label[0] = '\0'; + Data_Version_Ptr->Date[0] = '\0'; + if( ( nd_status = ND_DataStruct_Open(&(mycontexte->RootFmtAttr),IMRD_SDMD_FMTATTR_STRUCT_IDX_NB,index_type_ptr, "SDM_FmtAttr_Manager",SDM_FmtAttr_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr)) != NDS_OK) + { + status = IMRS_KO; + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_FMTATTR); + SDM_RaiseError(mycontexte->SaxCtxHdl,&(mycontexte->FataError),&(mycontexte->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + else + { + doc = xmlCtxtReadFile(ctxt,docname,NULL,XML_PARSE_DTDATTR+XML_PARSE_DTDVALID); + if (ctxt->lastError.code != XML_ERR_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_3( "Erreur de parsing du fichier (%s): (%s) line (%d) !", docname, ctxt->lastError.message, ctxt->lastError.line); + } + else if(mycontexte->flagerror != IMRS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "%s !", mycontexte->FataError.libError); + } + else + { + index_type_ptr = FmtAttr_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(mycontexte->RootFmtAttr, index_type_ptr, IMRD_SDMD_FMTATTR_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump( mycontexte->RootFmtAttr);*/ + } + } + + if((status != IMRS_OK)&&(mycontexte->RootFmtAttr != NULL)) + { + free(mycontexte->RootFmtAttr->User_Ptr); + nd_status = ND_DataStruct_Close(mycontexte->RootFmtAttr); + } + + ctxt->sax = SAXHandler_Sav ; + xmlFreeParserCtxt(ctxt); + } + else + { + status = IMRS_KO; + } + + return(status); + +} + + + +IMRT_Status SDM_XML_Load_Format( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte) +{ + IMRT_Status status; + NDT_Status nd_status; + char * docname = NULL; + NDT_Index_Type *index_type_ptr; + xmlDocPtr doc = NULL; + xmlDtdPtr dtd; + xmlParserCtxtPtr ctxt =NULL; + xmlSAXHandlerPtr SAXHandler_Sav; + xmlSAXHandlerPtr SAXHandler; + const char functionname[]= "SDM_XML_Load_Format"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + IMRT_Data_Version *Data_Version_Ptr; + + LIBXML_TEST_VERSION + xmlKeepBlanksDefault(0); + xmlSAXDefaultVersion(2); + xmlLineNumbersDefault(1); + + status = IMRS_OK; + docname = demo_file; + ctxt = xmlNewParserCtxt(); + /*initialisation des indexes*/ + index_type_ptr = Fmt_Struct_initial_idx_tab; + + if(ctxt != NULL) + { + mycontexte->flagerror = IMRS_OK; + SAXHandler = &SaxFmtHandlerStruct; + mycontexte->SaxCtxHdl = ctxt; + ctxt->userData = mycontexte; + SAXHandler_Sav = ctxt->sax; + ctxt->sax = SAXHandler; + ctxt->sax2 = 1 ; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + Data_Version_Ptr->Label[0] = '\0'; + Data_Version_Ptr->Date[0] = '\0'; + if( ( nd_status = ND_DataStruct_Open(&(mycontexte->RootFormat),IMRD_SDMD_FMT_STRUCT_IDX_NB,index_type_ptr, "SDM_Fmt_Manager",SDM_Fmt_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr)) != NDS_OK) + { + status = IMRS_KO; + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_FORMAT); + SDM_RaiseError(mycontexte->SaxCtxHdl,&(mycontexte->FataError),&(mycontexte->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + else + { + doc = xmlCtxtReadFile(ctxt,docname,NULL,XML_PARSE_DTDATTR+XML_PARSE_DTDVALID); + if (ctxt->lastError.code != XML_ERR_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_3( "Erreur de parsing du fichier (%s): (%s) line (%d) !", docname, ctxt->lastError.message, ctxt->lastError.line); + } + else if(mycontexte->flagerror != IMRS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "%s !", mycontexte->FataError.libError); + } + else + { + index_type_ptr = Fmt_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(mycontexte->RootFormat, index_type_ptr, IMRD_SDMD_FMT_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump( mycontexte->RootFormat);*/ + } + } + + if((status != IMRS_OK)&&(mycontexte->RootFormat != NULL)) + { + free(mycontexte->RootFormat->User_Ptr); + nd_status = ND_DataStruct_Close(mycontexte->RootFormat); + } + + ctxt->sax = SAXHandler_Sav ; + xmlFreeParserCtxt(ctxt); + } + else + { + status = IMRS_KO; + } + + return(status); + +} + + + +IMRT_Status SDM_XML_Load_MapPath( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte) +{ + IMRT_Status status; + NDT_Status nd_status; + char * docname = NULL; + NDT_Index_Type *index_type_ptr; + xmlDocPtr doc = NULL; + xmlDtdPtr dtd; + xmlParserCtxtPtr ctxt =NULL; + xmlSAXHandlerPtr SAXHandler; + xmlSAXHandlerPtr SAXHandler_Sav; + const char functionname []="SDM_XML_Load_MapPath"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + IMRT_Data_Version *Data_Version_Ptr; + + + LIBXML_TEST_VERSION + xmlKeepBlanksDefault(0); + xmlSAXDefaultVersion(2); + xmlLineNumbersDefault(1); + + status = IMRS_OK; + docname = demo_file; + ctxt = xmlNewParserCtxt(); + /*initialisation des indexes*/ + index_type_ptr = index_type_initial_tab; + + if(ctxt != NULL) + { + mycontexte->flagerror = IMRS_OK; + SAXHandler = &SaxMapPathHandlerStruct; + mycontexte->SaxCtxHdl = ctxt; + ctxt->userData = mycontexte; + SAXHandler_Sav = ctxt->sax ; + ctxt->sax = SAXHandler; + ctxt->sax2 = 1 ; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + Data_Version_Ptr->Label[0] = '\0'; + Data_Version_Ptr->Date[0] = '\0'; + if( ( nd_status = ND_DataStruct_Open(&(mycontexte->RootMapPath), IMRD_SDMD_INDEX_NB, index_type_ptr, "SDM_MapPath_Manager",SDM_MapPath_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr)) != NDS_OK) + { + status = IMRS_KO; + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_MAPPATH); + SDM_RaiseError(mycontexte->SaxCtxHdl,&(mycontexte->FataError),&(mycontexte->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + else + { + doc = xmlCtxtReadFile(ctxt,docname,NULL,XML_PARSE_DTDATTR+XML_PARSE_DTDVALID); + if (ctxt->lastError.code != XML_ERR_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_3( "Erreur de parsing du fichier (%s): (%s) line (%d) !", docname, ctxt->lastError.message, ctxt->lastError.line); + } + else if(mycontexte->flagerror != IMRS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "%s !", mycontexte->FataError.libError); + } + else + { + /*SDM_DataStruct_Dump(mycontexte->RootMapPath);*/ + } + } + + if(status != IMRS_OK) + { + if(mycontexte->CurrentMapPath != NULL) + { + if(mycontexte->CurrentMapPath->MapCmd_Struct_Ptr != NULL) + { + nd_status = ND_DataStruct_Close(mycontexte->CurrentMapPath->MapCmd_Struct_Ptr); + if(nd_status == NDS_OK) + { + free(mycontexte->CurrentMapPath); + } + } + } + if(mycontexte->CurrentMapCmd != NULL) + { + free(mycontexte->CurrentMapCmd); + } + + if(mycontexte->CurrentFormat != NULL) + { + if(mycontexte->CurrentFormat->FmtMsg_Struct_Ptr != NULL) + { + nd_status = ND_DataStruct_Close(mycontexte->CurrentFormat->FmtMsg_Struct_Ptr); + if(nd_status == NDS_OK) + { + free(mycontexte->CurrentFormat); + } + } + + } + + if(mycontexte->CurrentFmtMsg != NULL) + { + free(mycontexte->CurrentFmtMsg); + } + if (mycontexte->CurrentAppli != NULL) + { + free(mycontexte->CurrentAppli); + } + + if(mycontexte->RootMapPath != NULL) + { + free(mycontexte->RootMapPath->User_Ptr); + nd_status = ND_DataStruct_Close(mycontexte->RootMapPath); + } + + if(mycontexte->RootFormat != NULL) + { + free(mycontexte->RootFormat->User_Ptr); + nd_status = ND_DataStruct_Close(mycontexte->RootFormat); + } + + if(mycontexte->RootFmtAttr != NULL) + { + free(mycontexte->RootFmtAttr->User_Ptr); + nd_status = ND_DataStruct_Close(mycontexte->RootFmtAttr); + } + + if(mycontexte->RootAppli != NULL) + { + free(mycontexte->RootAppli->User_Ptr); + nd_status = ND_DataStruct_Close(mycontexte->RootAppli); + } + } + + ctxt->sax = SAXHandler_Sav ; + xmlFreeParserCtxt(ctxt); + } /* end if(ctxt != NULL) */ + else + { + status = IMRS_KO; + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_FmtAttr_Header(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n"); + fprintf(dump_file, "<%s>\n", IMRD_SDMD_FMTATTR_STRUCT); + fprintf(dump_file, "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: buffer_info_xml.c $\n", + ((IMRT_Data_Version *)IMRG_SDM_Base.RootFmtAttr->User_Ptr)->Label, + ((IMRT_Data_Version *)IMRG_SDM_Base.RootFmtAttr->User_Ptr)->Date); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_FmtAttr_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootFmtAttr, IMRD_SDMD_CMD_API_XML_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "XML Dump RootFmtAttr failed (%d) !", nd_status); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_FmtAttr_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n", IMRD_SDMD_FMTATTR_STRUCT); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_FmtAttr(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, SDMD_FMTATTR_FILE); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_XML_Dump_FmtAttr_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_FmtAttr_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_FmtAttr_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Appli_Header(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n"); + fprintf(dump_file, "<%s>\n", IMRD_SDMD_APPLI_STRUCT); + fprintf(dump_file, "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: buffer_info_xml.c $\n", + ((IMRT_Data_Version *)IMRG_SDM_Base.RootAppl->User_Ptr)->Label, + ((IMRT_Data_Version *)IMRG_SDM_Base.RootAppl->User_Ptr)->Date); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Appli_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootAppl, IMRD_SDMD_CMD_API_XML_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "XML Dump RootAppl failed (%d) !", nd_status); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Appli_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n", IMRD_SDMD_APPLI_STRUCT); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Appli(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, SDMD_APPLI_FILE); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_XML_Dump_Appli_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_Appli_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_Appli_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Format_Header(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n"); + fprintf(dump_file, "<%s>\n", IMRD_SDMD_FMT_STRUCT); + fprintf(dump_file, "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: buffer_info_xml.c $\n", + ((IMRT_Data_Version *)IMRG_SDM_Base.RootFmt->User_Ptr)->Label, + ((IMRT_Data_Version *)IMRG_SDM_Base.RootFmt->User_Ptr)->Date); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Format_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootFmt, IMRD_SDMD_CMD_API_XML_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "XML Dump RootFmt failed (%d) !", nd_status); + } + else + { + status = IMRS_OK; + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Format_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n", IMRD_SDMD_FMT_STRUCT); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Format(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, SDMD_FORMAT_FILE); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_XML_Dump_Format_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_Format_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_Format_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_MapPath_Header(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n"); + fprintf(dump_file, "<%s>\n", IMRD_SDMD_MAPPATH_STRUCT); + fprintf(dump_file, "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: buffer_info_xml.c $\n", + ((IMRT_Data_Version *)IMRG_SDM_Base.RootMapPath->User_Ptr)->Label, + ((IMRT_Data_Version *)IMRG_SDM_Base.RootMapPath->User_Ptr)->Date); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_MapPath_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootMapPath, IMRD_SDMD_CMD_API_XML_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "XML Dump RootMapPath failed (%d) !", nd_status); + } + else + { + status = IMRS_OK; + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_MapPath_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n", IMRD_SDMD_MAPPATH_STRUCT); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_MapPath(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, SDMD_MAPPATH_FILE); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_XML_Dump_MapPath_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_MapPath_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_MapPath_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_BufferInfo_Dump(void) +{ + IMRT_Status status; + + status = SDM_XML_Dump_Appli(); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_Format(); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_MapPath(); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_FmtAttr(); + } + } + } + + return(status); + +} + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ +IMRT_Status SDM_ConvertAttribute(char * Attribute_ptr, char * Attribute_convert_ptr) +{ + + char * read_ptr ; + char * write_ptr; + IMRT_Status status; + char *unescaped; + char sHexa[4]; + + status = IMRS_OK; + + for( read_ptr = Attribute_ptr, write_ptr =Attribute_convert_ptr ; *read_ptr != '\0'; read_ptr++, write_ptr++) + { + + if (*read_ptr == '%') + { + memset(sHexa, '\0', sizeof(sHexa)); + strncpy(sHexa, read_ptr, 3); + write_ptr = (char *)xmlURIUnescapeString(sHexa, strlen(sHexa), write_ptr); + read_ptr ++; + read_ptr ++; + } + else + { + if( ( *read_ptr == '\\') && ( *(read_ptr+1) != '\0') ) + { + switch( *( read_ptr + 1)) + { + case 'n': + { + *write_ptr = '\n'; + break; + } + + case 't': + { + *write_ptr = '\t'; + break; + } + + case '\\': + { + *write_ptr = '\\'; + break; + } + + case 'r': + { + *write_ptr = '\r'; + break; + } + + case 'T': + { + *write_ptr = 'T'; + break; + } + + case 'S': + { + *write_ptr = 'S'; + break; + } + + default: + { + *write_ptr = '?'; + break; + } + } + + read_ptr++; + } + else + { + if (( *read_ptr == '\n') || (*read_ptr == '\t')) + { + // *write_ptr = ''; + } + else + { + *write_ptr = *read_ptr; + } + } + } + } + + *write_ptr = '\0'; + + return(status); +} + + +IMRT_Status SDM_ConvertAttributeInv(char * Attrinute_Ptr, char * Attribute_convert_ptr) +{ + const xmlChar * string_to_escape = (xmlChar *)Attrinute_Ptr; + const xmlChar * list = (xmlChar *)"TS"; + xmlChar * Ret=NULL; + + memset(Attribute_convert_ptr, '\0', IMRD_FMTATTR_VALUE_SIZE); + Ret = xmlURIEscapeStr(string_to_escape, list); + if (Ret != NULL) + { + strcpy(Attribute_convert_ptr, (char *)Ret); + } + xmlFree(Ret); + + return(IMRS_OK); +} + + +IMRT_Status SDM_Control_Fmt_Attr(IMRT_Msg * Msg_Ptr, NDT_Root * FmtMsg_Struct_Ptr, IMRT_FmtAttr * FmtAttr_Ptr) +{ + IMRT_Status status; + NDT_Status nd_status; + + status = IMRS_OK; + + if (strcmp(FmtAttr_Ptr->Name , IMRD_FMTATTR_NAME_UNKNOWN) != 0) + { + nd_status = ND_DataStruct_Traverse(FmtMsg_Struct_Ptr, IMRD_SDMD_CMD_CHECK_FMT_ATTR, Msg_Ptr, FmtAttr_Ptr); + if (nd_status == NDS_NODE_FOUND) + { + status = IMRS_OK; + } + else + { + status = IMRS_KO; + } + } + + return(status); +} diff --git a/src/libstatic_data_mng/src/buffer_info_xml.h b/src/libstatic_data_mng/src/buffer_info_xml.h new file mode 100644 index 0000000..599cd00 --- /dev/null +++ b/src/libstatic_data_mng/src/buffer_info_xml.h @@ -0,0 +1,426 @@ +/*----------------------------------------------------------------------------*/ +/* File: buffer_info_xml.h */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _BUFFER_INFO_XML_H_ +# define _BUFFER_INFO_XML_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include + +/*----------------------------------------------------------------------------*/ +/* Locale Constantes */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_SDMD_TAG_FMTATTR "fmtattr" +#define IMRD_SDMD_TAG_FMTATTR_NAME "fmtattr_name" + + +/*definition des tags xml pour le chargement des structure Format et FmtMsg*/ +#define IMRD_SDMD_TAG_FORMAT "format" +#define IMRD_SDMD_TAG_FMTMSG "fmtmsg" + +/*definition des tags xml pour le chargement de la structure Application*/ + +#define IMRD_SDMD_TAG_APPLI "appli" + +/*definition des tags xml pour le chargement de les structures MapPath et MapCmd*/ +#define IMRD_SDMD_TAG_MAPPATH "mappath" +#define IMRD_SDMD_TAG_INPUTAPPLI "inputappli" +#define IMRD_SDMD_TAG_OUTPUTAPPLI "outputappli" +#define IMRD_SDMD_TAG_INPUTFORMAT "inputformat" +#define IMRD_SDMD_TAG_INPUTFORMAT_ATTR "inputformat_attr" +#define IMRD_SDMD_TAG_OUTPUTFORMAT "outputformat" +#define IMRD_SDMD_TAG_OUTPUTFORMAT_ATTR "outputformat_attr" +#define IMRD_SDMD_TAG_MAPCMD "mapcmd" +#define IMRD_SDMD_TAG_BRANCHE_ID "branche_id" +#define IMRD_SDMD_TAG_MAPPER "mapper" +#define IMRD_SDMD_TAG_CLEARFLAG "clearflag" +#define IMRD_SDMD_TAG_INPUTBUFFER "inputbuffer" +#define IMRD_SDMD_TAG_OUTPUTBUFFER "outputbuffer" +#define IMRD_SDMD_TAG_IDENTIFIER "identifier" +#define IMRD_SDMD_TAG_NUMBUFFER "numbuffer" +#define IMRD_SDMD_TAG_GO_TO "go_to" +#define IMRD_SDMD_TAG_TYPE "type" +#define IMRD_SDMD_TAG_COPIE "copie" +#define IMRD_SDMD_TAG_IDENTTOTAL "identtotal" +#define IMRD_SDMD_TAG_ATTRIBUTE "attribute" +#define IMRD_SDMD_TAG_VALUE "value" + + +/*----------------------------------------------------------------------------*/ +/* Local definition */ +/*----------------------------------------------------------------------------*/ + + +typedef IMRT_Status (* xml_endeElement)(void * ctx, const xmlChar * localname, const xmlChar * prefix, const xmlChar * URI); + +typedef struct SDMT_BufferInfo_Contexte +{ + char value[IMRD_SDMD_VALUE_LEN]; + IMRT_Array_Xml_Path PathArray; + IMRT_Level_Tag PresentLevelTag; + int IdxJpTble; + int NbMapPath; + int NbMapCmd; + IMRT_Appl_Id CptAppl; + IMRT_FmtAttr_Id CptFmtAttr; + IMRT_Fmt_Id CptFmt; + IMRT_MapPath * CurrentMapPath; + IMRT_MapCmd * CurrentMapCmd; + IMRT_Appl * CurrentAppli; + IMRT_FmtMsg * CurrentFmtMsg; + IMRT_Fmt * CurrentFormat; + IMRT_FmtAttr * CurrentFmtAttr; + NDT_Root * RootFmtAttr; + NDT_Root * RootFormat; + NDT_Root * RootAppli; + NDT_Root * RootMapPath; + xmlParserCtxt * SaxCtxHdl; + IMRT_Error FataError; + IMRT_Status flagerror; +}SDMT_BufferInfo_Contexte; + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _BUFFER_INFO_XML_C_ + +static IMRT_Status error(SDMT_BufferInfo_Contexte *ctx , const char *msg, ...); + +IMRT_Status startElementNsFmtAttr( SDMT_BufferInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); + +IMRT_Status startElementNsAppli( SDMT_BufferInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); + +IMRT_Status startElementNsFmt( SDMT_BufferInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); + +IMRT_Status startElementNsMapPath( SDMT_BufferInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); + +IMRT_Status endElementNsAppli( SDMT_BufferInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); + +IMRT_Status endElementNsFmtAttr( SDMT_BufferInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); + +IMRT_Status endElementNsFmt ( SDMT_BufferInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); + +IMRT_Status endElementNsMapPath( SDMT_BufferInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); + +IMRT_Status Buff_Info_characters(SDMT_BufferInfo_Contexte * ctx , const xmlChar *ch, int len); + +IMRT_Status SDM_XML_Load_FmtAttr( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte); +IMRT_Status SDM_XML_Load_Appli( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte); +IMRT_Status SDM_XML_Load_Format( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte); +IMRT_Status SDM_XML_Load_MapPath( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte); +IMRT_Status SDM_XML_BufferInfo_Init(IMRT_Path Lib_Path); +IMRT_Status SDM_Dump_XML_FmtAttr_Header(FILE *dump_file); +IMRT_Status SDM_Dump_XML_FmtAttr_Body(FILE *dump_file); +IMRT_Status SDM_Dump_XML_FmtAttr_Footer(FILE *dump_file); +IMRT_Status SDM_Dump_XML_FmtAttr(void); +IMRT_Status SDM_Dump_XML_Appli_Header(FILE *dump_file); +IMRT_Status SDM_Dump_XML_Appli_Body(FILE *dump_file); +IMRT_Status SDM_Dump_XML_Appli_Footer(FILE *dump_file); +IMRT_Status SDM_Dump_XML_Appli(void); +IMRT_Status SDM_Dump_XML_Format_Header(FILE *dump_file); +IMRT_Status SDM_Dump_XML_Format_Body(FILE *dump_file); +IMRT_Status SDM_Dump_XML_Format_Footer(FILE *dump_file); +IMRT_Status SDM_XML_Dump_Format(void); +IMRT_Status SDM_XML_Dump_MapPath_Header(FILE *dump_file); +IMRT_Status SDM_XML_Dump_MapPath_Body(FILE *dump_file); +IMRT_Status SDM_XML_Dump_MapPath_Footer(FILE *dump_file); +IMRT_Status SDM_XML_Dump_MapPath(void); +IMRT_Status SDM_XML_BufferInfo_Dump(void); +IMRT_Status SDM_ConvertAttribute(char * Attrinute_ptr, char * Attribute_convert_ptr); +IMRT_Status SDM_ConvertAttributeInv(char * Attrinute_Ptr, char * Attribute_convert_ptr); +IMRT_Status SDM_Control_Fmt_Attr(IMRT_Msg *, NDT_Root *, IMRT_FmtAttr *); +# else + +extern IMRT_Status SDM_XML_Load_FmtAttr( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte); +extern IMRT_Status SDM_XML_Load_Appli( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte); +extern IMRT_Status SDM_XML_Load_Format( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte); +extern IMRT_Status SDM_XML_Load_MapPath( char *demo_file, SDMT_BufferInfo_Contexte *mycontexte); +extern IMRT_Status SDM_XML_BufferInfo_Init(IMRT_Path Lib_Path); +extern IMRT_Status SDM_Dump_XML_FmtAttr_Header(FILE *dump_file); +extern IMRT_Status SDM_Dump_XML_FmtAttr_Body(FILE *dump_file); +extern IMRT_Status SDM_Dump_XML_FmtAttr_Footer(FILE *dump_file); +extern IMRT_Status SDM_Dump_XML_FmtAttr(void); +extern IMRT_Status SDM_Dump_XML_Appli_Header(FILE *dump_file); +extern IMRT_Status SDM_Dump_XML_Appli_Body(FILE *dump_file); +extern IMRT_Status SDM_Dump_XML_Appli_Footer(FILE *dump_file); +extern IMRT_Status SDM_Dump_XML_Appli(void); +extern IMRT_Status SDM_Dump_XML_Format_Header(FILE *dump_file); +extern IMRT_Status SDM_Dump_XML_Format_Body(FILE *dump_file); +extern IMRT_Status SDM_Dump_XML_Format_Footer(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_Format(void); +extern IMRT_Status SDM_XML_Dump_MapPath_Header(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_MapPath_Body(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_MapPath_Footer(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_MapPath(void); +extern IMRT_Status SDM_XML_BufferInfo_Dump(void); +extern IMRT_Status SDM_Control_Fmt_Attr(IMRT_Msg *, NDT_Root *, IMRT_FmtAttr *); +# endif + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ +# ifdef _BUFFER_INFO_XML_C_ + +/*xmlSAXHandler Buff_Info_Error_SAX_Hdl_Struct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + NULL, + NULL, + NULL + };*/ +xmlSAXHandler SaxFmtHandlerStruct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (charactersSAXFunc)(Buff_Info_characters), + NULL, + NULL, + NULL, + NULL, + (errorSAXFunc)(error), + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + (startElementNsSAX2Func)(startElementNsFmt), + (endElementNsSAX2Func)(endElementNsFmt), + NULL +}; + + +xmlSAXHandler SaxAppliHandlerStruct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (charactersSAXFunc)(Buff_Info_characters), + NULL, + NULL, + NULL, + NULL, + (errorSAXFunc)error, + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + (startElementNsSAX2Func)(startElementNsAppli), + (endElementNsSAX2Func)(endElementNsAppli), + NULL +}; + +xmlSAXHandler SaxFmtAttrHandlerStruct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (charactersSAXFunc)(Buff_Info_characters), + NULL, + NULL, + NULL, + NULL, + (errorSAXFunc)error, + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + (startElementNsSAX2Func)(startElementNsFmtAttr), + (endElementNsSAX2Func)(endElementNsFmtAttr), + NULL +}; + + +xmlSAXHandler SaxMapPathHandlerStruct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (charactersSAXFunc)(Buff_Info_characters), + NULL, + NULL, + NULL, + NULL, + (errorSAXFunc)error, + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + (startElementNsSAX2Func)(startElementNsMapPath), + (endElementNsSAX2Func)(endElementNsMapPath), + NULL +}; + + + + +# endif + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/libstatic_data_mng.c b/src/libstatic_data_mng/src/libstatic_data_mng.c new file mode 100644 index 0000000..e374596 --- /dev/null +++ b/src/libstatic_data_mng/src/libstatic_data_mng.c @@ -0,0 +1,527 @@ +/*----------------------------------------------------------------------------*/ +/* $Workfile: libstatic_data_mng.c $ */ +/*----------------------------------------------------------------------------*/ +/* $Author: agibert $ */ +/* $Date: 2008/11/12 02:25:23 $ */ +/* $Revision: 1.1 $ */ +/* $Label: $ */ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* File: libstatic_data_mng.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _LIBSTATIC_DATA_MNG_C_ + +#include "libstatic_data_mng.h" + + + + + + + +/******************************************************************************/ +/* Static Data Manager API */ +/******************************************************************************/ + +/*----------------------------------------------------------------------------*/ +/* Open Static Data Manager */ +/*----------------------------------------------------------------------------*/ +/* Lib_Flag: Setup SDM init mode (XML, SQL, ...) */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_SDM_Library_Open( IMRT_SDM_Config * Lib_Config_Ptr) +{ + IMRT_Status status, StatusTmp; + NDT_Status nd_status; + + + + if( IMRG_SDM_Module.Lib.Status != IMRD_LIB_STATUS_CLOSED) + { + IMRD_LM_LOG_ERROR_0( "Library not closed !"); + + return( IMRS_KO); + } + else + { +#ifdef ORACLE_SUPPORT + if(( (status = SDM_HDR_SQL_Init(Lib_Config_Ptr->Flag)) != IMRS_OK)||( (status = SDM_HDR_XML_Init(Lib_Config_Ptr->Flag)) != IMRS_OK)) + { + status = IMRS_KO; + } +#else + status = IMRS_OK; +#endif /* ORACLE_SUPPORT */ + + if( status == IMRS_OK ) + { + status = SDM_StructInfo_Init(Lib_Config_Ptr); + if( status == IMRS_OK ) + { + status = SDM_MapInfo_Init(Lib_Config_Ptr); + if( status == IMRS_OK ) + { + status = SDM_BufferInfo_Init(Lib_Config_Ptr); + if( status != IMRS_OK ) + { + StatusTmp = SDM_MapInfo_DInit(); + StatusTmp = SDM_StructInfo_DInit(); + } + } + else + { + StatusTmp = SDM_StructInfo_DInit(); + } + } + + } + + if( status == IMRS_OK) + { + IMRG_SDM_Module.Lib.Status = IMRD_LIB_STATUS_OPENED; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Library opened !"); + } + + return(status); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Close Static Data Manager */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_SDM_Library_Close( void) +{ + IMRT_Status status; + + + if( IMRG_SDM_Module.Lib.Status != IMRD_LIB_STATUS_OPENED) + { + IMRD_LM_LOG_ERROR_0( "Library not opened !"); + + return( IMRS_KO); + } + else + { + status = IMRS_OK; + + if( ((status = SDM_BufferInfo_DInit()) != IMRS_OK)|| + ((status = SDM_MapInfo_DInit()) != IMRS_OK)|| + ((status = SDM_StructInfo_DInit()) != IMRS_OK)|| + +#ifdef ORACLE_SUPPORT + ((status = SDM_HDR_SQL_DInit()) != IMRS_OK)|| +#endif /* ORACLE_SUPPORT */ + + ((status = SDM_HDR_XML_DInit()) != IMRS_OK) ) + { + status = IMRS_KO; + } + else + { + IMRG_SDM_Module.Lib.Status = IMRD_LIB_STATUS_CLOSED; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_1, "Library closed !"); + } + + return(status); + } +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Format */ +/*----------------------------------------------------------------------------*/ +/* (I) CCB_Fmt_Add_Ptr: Format add callback */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_SDM_Fmt_Proceed( IMRT_SDMCB_Fmt_Add *CCB_Fmt_Add_Ptr) +{ + IMRT_Status status; + + status = SDM_Fmt_Proceed(CCB_Fmt_Add_Ptr); + + return(status); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Convert */ +/*----------------------------------------------------------------------------*/ +/* (I) CCB_Cnv_Add_Ptr: Convert add callback */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_SDM_Cnv_Proceed( IMRT_SDMCB_Cnv_Add *CCB_Cnv_Add_Ptr) +{ + IMRT_Status status; + + status = SDM_Cnv_Proceed(CCB_Cnv_Add_Ptr); + + return(status); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Mapping Path */ +/*----------------------------------------------------------------------------*/ +/* (I) Appl_Id_Target: Target buffer application id */ +/* (I) Fmt_Id_Target: Target buffer format id */ +/* (I) Msg_Id_Target: Target buffer message id */ +/* (I) ApplId_Src: Source buffer application id */ +/* (I) Fmt_Id_Src: Source buffer format id */ +/* (I) Msg_Id_Src: Source buffer message id */ +/* (I) CCB_Buffer_Map_Ptr: Buffer mapping callback */ +/* (I) CCB_Buffer_Copy_Ptr: Buffer copy callback */ +/* (I) CCB_Buffer_Ident_Ptr: Buffer identification callback */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_SDM_MapPath_Proceed( IMRT_Appl_Id Appl_Id_Target, IMRT_Fmt_Id Fmt_Id_Target, IMRT_Msg_Id Msg_Id_Target, + IMRT_Appl_Id ApplId_Src, IMRT_Fmt_Id Fmt_Id_Src, IMRT_Msg_Id Msg_Id_Src, + IMRT_SDMCB_Buffer_Map *CCB_Buffer_Map_Ptr, + IMRT_SDMCB_Buffer_Copy *CCB_Buffer_Copy_Ptr, + IMRT_SDMCB_Buffer_Ident *CCB_Buffer_Ident_Ptr) +{ + IMRT_Status status; + + status = SDM_MapPath_Proceed(Appl_Id_Target,Fmt_Id_Target,Msg_Id_Target, + ApplId_Src,Fmt_Id_Src, Msg_Id_Src, + CCB_Buffer_Map_Ptr, + CCB_Buffer_Copy_Ptr, + CCB_Buffer_Ident_Ptr); + +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Buffer Mapping */ +/*----------------------------------------------------------------------------*/ +/* (I) MsgMap_Ptr: Message map pointer */ +/* (I) CCB_Field_Map_Ptr: Field mapping callback */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_SDM_MsgMap_Proceed( IMRT_MsgMap *MsgMap_Ptr, IMRT_SDMCB_Field_Map *CCB_Field_Map_Ptr) +{ + + IMRT_Status status; + + status = IMRS_OK; + + if(SDM_MsgMap_Proceed(MsgMap_Ptr,CCB_Field_Map_Ptr) != NDS_OK) + { + status = IMRS_KO; + } + + return(status); + +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Proceed Message Identification */ +/*----------------------------------------------------------------------------*/ +/* (I) Fmt_Id: Target buffer format id */ +/* (O) Msg_Id_Ptr: Target buffer message id to return */ +/* (I) CCB_Field_Ident_Ptr: Field ident callback */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_SDM_MsgIdent_Proceed( IMRT_Fmt_Id Fmt_Id, IMRT_Msg_Id *Msg_Id, IMRT_SDMCB_Ident_Field_Value *CCB_Ident_Field_Value_Ptr, + IMRT_SDMCB_Ident_Field_Exist *CCB_Ident_Field_Exist_Ptr, IMRT_SDMCB_Ident_Msg_Size *CCB_Ident_Msg_Size_Ptr) +{ + IMRT_Status status; + + status = SDM_MsgIdent_Proceed( Fmt_Id, Msg_Id, CCB_Ident_Field_Value_Ptr, CCB_Ident_Field_Exist_Ptr, CCB_Ident_Msg_Size_Ptr); + +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Convert Buffer Format Name to Buffer Format Id */ +/*----------------------------------------------------------------------------*/ +/* (O) Fmt_Id_Ptr: Buffer format id */ +/* (I) Fmt_Name: Buffer format name */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_SDM_Fmt_Id_Get( IMRT_Fmt_Id *Fmt_Id_Ptr, const IMRT_Fmt_Name Fmt_Name) +{ + IMRT_Status status; + NDT_Status nd_status; + NDT_Node *node_ptr; + IMRT_Fmt Fmt; + + + strcpy(Fmt.Name, Fmt_Name); + + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootFmt, + IMRD_SDMD_FMT_IDX_NAME,&Fmt,NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + printf("\nErreur lors de la recherche de Format Name <%s>\n", Fmt_Name); + status = IMRS_KO; + } + else + { + *Fmt_Id_Ptr = ( ( IMRT_Fmt *)( node_ptr->Value))->Id; + status = IMRS_OK; + } + + return(status); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Convert Buffer Appli Name to Buffer Appli Id */ +/*----------------------------------------------------------------------------*/ +/* (O) Appl_Id_Ptr: Buffer appli id */ +/* (I) Appl_Name: Buffer appli name */ +/*----------------------------------------------------------------------------*/ + +IMRT_Status IMR_SDM_Appl_Id_Get( IMRT_Appl_Id *Appl_Id_Ptr, const IMRT_Appl_Name Appl_Name) +{ + IMRT_Status status; + NDT_Status nd_status; + NDT_Node *node_ptr; + IMRT_Appl Appli; + + + strcpy(Appli.Name, Appl_Name); + + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootAppl, + IMRD_SDMD_APPL_IDX_NAME,&Appli,NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + printf("\nErreur lors de la recherche de Appli Name <%s>\n", Appl_Name); + status = IMRS_KO; + } + else + { + *Appl_Id_Ptr = ( ( IMRT_Appl *)( node_ptr->Value))->Id; + status = IMRS_OK; + } + + return(status); +} + + + +void SDM_DataStruct_Dump( NDT_Root *ds_ptr ) +{ + NDT_Status status; + + + printf( "Print DataStructure Info:\n"); + + if( ( status = ND_DataStruct_Info_Print( stdout, ds_ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK) + { + printf( "ND_DataStruct_Info_Print() failed (%d) !\n", status); + } + + printf( "\n"); + printf( "Traverse DataStructure Index 0:\n"); + + if( ( status = ND_DataStruct_Traverse( ds_ptr, IMRD_SDMD_CMD_INDEX0_PRINT, stdout, NDD_RECURSIVE_MODE_PARENT, 0)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse() failed (%d) !\n", status); + } +} + + + + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status IMR_SDM_SQL_Dump(void) +{ + IMRT_Status status; + +#ifdef ORACLE_SUPPORT + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "SQL Dump ..."); + + status = SDM_SQL_StructInfo_Dump(); + if(status == IMRS_OK) + { + status = SDM_SQL_MapInfo_Dump(); + if(status == IMRS_OK) + { + status = SDM_SQL_BufferInfo_Dump(); + } + } +#else + status = IMRS_OK; +#endif /* ORACLE_SUPPORT */ + + return(status); +} + + + + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status IMR_SDM_XML_Dump(void) +{ + IMRT_Status status; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "XML Dump ..."); + + status = SDM_XML_StructInfo_Dump(); + if(status == IMRS_OK) + { + status = SDM_XML_MapInfo_Dump(); + if(status == IMRS_OK) + { + status = SDM_XML_BufferInfo_Dump(); + } + } + + return(status); + +} + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_Set_Struct_Version(IMRT_Data_Version *Data_Version_Ptr, char *Version_String_Ptr) +{ + char *Pos1_Ptr, *Pos2_Ptr; + char *Pos3_Ptr; + char Label[IMRD_SDMD_VERS_LABEL_LEN]; + char Date[IMRD_SDMD_VERS_DATE_LEN]; + int i; + + strcpy(Label, ""); + strcpy(Date, ""); + + Pos1_Ptr = strstr( Version_String_Ptr, "Label:"); + if (Pos1_Ptr != NULL) + { + Pos2_Ptr = strstr( Pos1_Ptr, "$"); + if (Pos2_Ptr == NULL) + { + return(IMRS_KO); + } + + strncpy(Label, Pos1_Ptr+6, Pos2_Ptr - Pos1_Ptr - 6); + Label[Pos2_Ptr - Pos1_Ptr - 6]='\0'; + Pos3_Ptr = Label; + i = strlen(Pos3_Ptr); + while((Pos3_Ptr[0] == ' ') && (i >= 0)) + { + Pos3_Ptr ++; + i --; + } + + i = strlen(Pos3_Ptr); + while((Pos3_Ptr[i-1] == ' ') && (i > 0)) + { + i --; + } + + if (i > 0) + { + strncpy(Data_Version_Ptr->Label, Pos3_Ptr, i); + Data_Version_Ptr->Label[i]= '\0'; + } + + Pos1_Ptr = strstr( Version_String_Ptr, "Date:"); + if (Pos1_Ptr != NULL) + { + Pos2_Ptr = strstr( Pos1_Ptr, "$"); + if (Pos2_Ptr == NULL) + { + return(IMRS_KO); + } + + strncpy(Date, Pos1_Ptr+5, Pos2_Ptr - Pos1_Ptr - 5); + Date[Pos2_Ptr - Pos1_Ptr - 5]='\0'; + Pos3_Ptr = Date; + i = strlen(Pos3_Ptr); + while((Pos3_Ptr[0] == ' ') && (i >= 0)) + { + Pos3_Ptr ++; + i --; + } + + i = strlen(Pos3_Ptr); + while((Pos3_Ptr[i-1] == ' ') && (i > 0)) + { + i --; + } + + if (i > 0) + { + strncpy(Data_Version_Ptr->Date, Pos3_Ptr, i); + Data_Version_Ptr->Date[i]= '\0'; + } + } + else + { + return(IMRS_KO); + } + } + else + { + return(IMRS_KO); + } + + return(IMRS_OK); + +} diff --git a/src/libstatic_data_mng/src/libstatic_data_mng.h b/src/libstatic_data_mng/src/libstatic_data_mng.h new file mode 100644 index 0000000..5ca0662 --- /dev/null +++ b/src/libstatic_data_mng/src/libstatic_data_mng.h @@ -0,0 +1,319 @@ +/*----------------------------------------------------------------------------*/ +/* File: libstatic_data_mng.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _LIBSTATIC_DATA_MNG_H_ +#define _LIBSTATIC_DATA_MNG_H_ + + + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +#include +#include +#include +#include + + + + + +/*----------------------------------------------------------------------------*/ +/* Lib Definitions */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_SDM_MODULE_ID ( IMRT_Module_Id) 2 +#define IMRD_SDM_MODULE_NAME ( IMRT_Module_Name) "sdm" +#define IMRD_SDM_MODULE_NAME_LONG ( IMRT_Module_Name_Long) "Static Data Manager" +#define IMRD_SDM_MODULE_VERSION ( IMRT_Module_Version) "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: libstatic_data_mng.h $" + +#define IMRD_MODULE_PTR &IMRG_SDM_Module + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_SDMD_FUNCTION_NAME_LEN 20 +#define IMRD_SDMD_LIB_ERROR_LEN 60 +#define IMRD_SDMD_VALUE_LEN 255 +#define IMRD_SDMD_MARKUP_LEN 255 +#define IMRD_SDMD_DESCERR_LEN 60 + +#define IMRD_SDMD_SEP_NAME "-" +#define IMRD_SDMD_EMPTY_STRING "" + +#define IMRD_SDMD_CMD_INDEX0_PRINT (NDT_Command)64 +#define IMRD_SDMD_CMD_EXECUTE (NDT_Command)68 +#define NDD_CMD_EXECUTE (NDT_Command)20 + +#define IMRD_SDMD_CMD_API_XML_FILE_DUMP (NDT_Command)70 +#define IMRD_SDMD_CMD_API_SQL_FILE_DUMP (NDT_Command)71 +#define IMRD_SDMD_CMD_API_SQL_DDBB_DUMP (NDT_Command)72 + +#define IMRD_SDMD_CMD_API_XML_DUMP (NDT_Command)80 +#define IMRD_SDMD_CMD_API_SQL_DUMP (NDT_Command)81 +#define NDD_CMD_FIND_MAPPATH (NDT_Command)82 + +#define IMRD_SDMD_CMD_CHECK_FMT_ATTR (NDT_Command)83 + +/*définition de code retour spécifique pour la lib_node*/ + +#define NDS_NODE_FOUND (NDT_Status)-1000 +#define NDS_IDENT_OK (NDT_Status)-1010 +#define NDS_NO_IDENT (NDT_Status)-1020 +/**/ + + +#define IMRD_SDMD_MAX_LINE_DUMP_FILE 500 + +#define IMRD_SDMD_INDEX_NB (short)1 + +#define IMRD_SDMD_TAG_VERSION "version" +#define IMRD_SDMD_TAG_NAME "name" +#define IMRD_SDMD_TAG_MSGMAP "msgmap" +#define IMRD_SDMD_MSGMAP_IDX_ID (short)0 +#define IMRD_SDMD_MSGMAP_IDX_NAME (short)1 + +/*Liste des codes erreurs*/ +#define SDMD_XML_CODE_ERROR_1 1 +#define SDMD_XML_LIB_ERROR_1 "Balise non reconnu" +#define SDMD_XML_CODE_ERROR_2 2 +#define SDMD_XML_LIB_ERROR_2 "Insertion de l'objet %s impossible" +#define SDMD_XML_CODE_ERROR_3 3 +#define SDMD_XML_LIB_ERROR_3 "allocationde l'objet %s impossible" +#define SDMD_XML_CODE_ERROR_4 4 +#define SDMD_XML_LIB_ERROR_4 "l'objet %s de valeur %s est absent" +#define SDMD_XML_CODE_ERROR_5 5 +#define SDMD_XML_LIB_ERROR_5 "Impossible d'ouvrir la strcuture %s" +#define SDMD_CODE_ERROR_6 6 +#define SDMD_LIB_ERROR_6 "Impossible de trouvers un chemin de mapping" +#define SDMD_CODE_ERROR_7 7 +#define SDMD_LIB_ERROR_7 "La commande %d n'est pas une commande connut" +#define SDMD_CODE_ERROR_8 8 +#define SDMD_LIB_ERROR_8 "Le format %s n'est pas un présent dans la liste des formats" +#define SDMD_CODE_ERROR_9 9 +#define SDMD_LIB_ERROR_9 "Indentification du message impossible" + +#define SDMD_XML_CODE_ERROR_10 10 +#define SDMD_XML_LIB_ERROR_10 "Erreur de chargement du fichier XML %s" + +#define SDMD_CODE_ERROR_11 11 +#define SDMD_LIB_ERROR_11 "Erreur de control de coherence de Format Attribute" + + +#define IMRD_SDMD_VERS_NAME_LEN 30 +#define IMRD_SDMD_VERS_LABEL_LEN 30 +#define IMRD_SDMD_VERS_DATE_LEN 30 + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Mode_Traverse definition */ +/*----------------------------------------------------------------------------*/ + +typedef short IMRT_Mode_Traverse; + +#define IMRD_SKIP_MODE ( IMRT_Mode_Traverse) 0 +#define IMRD_NORMALE_MODE ( IMRT_Mode_Traverse) 1 +#define IMRD_ERREUR_MODE ( IMRT_Mode_Traverse) 2 + + +#define IMRD_LATEST_BRANCHE ( IMRT_Branche_Id) 100 + +static NDT_Index_Type index_type_initial_tab[IMRD_SDMD_INDEX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED) +}; + +typedef struct IMRT_Error +{ + char function [IMRD_SDMD_FUNCTION_NAME_LEN]; + int errorCode; + char libError[IMRD_SDMD_LIB_ERROR_LEN]; +} IMRT_Error; + + +typedef struct IMRT_SDM_Base +{ + NDT_Root * RootMsg; + NDT_Root * RootMsgMap; + NDT_Root * RootFmtAttr; + NDT_Root * RootFmt; + NDT_Root * RootAppl; + NDT_Root * RootMapPath; + NDT_Root * RootCnv; +} IMRT_SDM_Base; + +typedef struct IMRT_SDM_IdentMessage +{ + IMRT_Msg_Name Type; + IMRT_Msg_Id Id; + IMRT_Mode_Traverse Mode; + IMRT_Branche_Id Branche_Id; + IMRT_SDMCB_Ident_Msg_Size *Ident_Msg_SizeFunc_Ptr; + IMRT_SDMCB_Ident_Field_Exist *Ident_Field_ExistFunc_Ptr; + IMRT_SDMCB_Ident_Field_Value *Ident_Field_ValueFunc_Ptr; +} IMRT_SDM_IdentMessage; + + +typedef struct IMRT_Data_Version +{ + char Label [IMRD_SDMD_VERS_LABEL_LEN]; + char Date[IMRD_SDMD_VERS_DATE_LEN]; +} IMRT_Data_Version; + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Array_Xml_Path definition */ +/*----------------------------------------------------------------------------*/ + +#define IMRD_SDMD_MIN_LEVEL_TAG ( short ) -1 +#define IMRD_SDMD_MAX_LEVEL_TAG ( short ) 10 +#define IMRD_SDMD_LEVEL_TAG_0 ( short ) 0 +#define IMRD_SDMD_LEVEL_TAG_1 ( short ) 1 +#define IMRD_SDMD_LEVEL_TAG_2 ( short ) 2 +#define IMRD_SDMD_LEVEL_TAG_3 ( short ) 3 +#define IMRD_SDMD_LEVEL_TAG_4 ( short ) 4 +#define IMRD_SDMD_LEVEL_TAG_5 ( short ) 5 +#define IMRD_SDMD_LEVEL_TAG_6 ( short ) 6 +#define IMRD_SDMD_LEVEL_TAG_7 ( short ) 7 +#define IMRD_SDMD_LEVEL_TAG_8 ( short ) 8 +#define IMRD_SDMD_LEVEL_TAG_9 ( short ) 9 +#define IMRD_SDMD_SIZE_TAG_LEN ( short ) 30 +#define IMRD_SDMD_SIZE_TAG_SIZE ( short ) ( IMRD_SDMD_SIZE_TAG_LEN + 1) + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Array_Xml_Path definition */ +/*----------------------------------------------------------------------------*/ + +typedef char IMRT_Level_Name[IMRD_SDMD_SIZE_TAG_SIZE]; + +typedef IMRT_Level_Name IMRT_Array_Xml_Path[IMRD_SDMD_MAX_LEVEL_TAG]; + + + + + +/*----------------------------------------------------------------------------*/ +/* IMRT_Level_Tag definition */ +/*----------------------------------------------------------------------------*/ +typedef short IMRT_Level_Tag; + + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _LIBSTATIC_DATA_MNG_C_ + +void SDM_DataStruct_Dump( NDT_Root * ); +IMRT_Status SDM_Set_Struct_Version(IMRT_Data_Version *, char *); +# else + +extern void SDM_DataStruct_Dump( NDT_Root * ); +extern IMRT_Status SDM_Set_Struct_Version(IMRT_Data_Version *, char *); +# endif + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Includes */ +/*----------------------------------------------------------------------------*/ + +#include "arc_hdl_xml.h" + +#ifdef ORACLE_SUPPORT +# include "arc_hdl_sql.h" +#endif /* ORACLE_SUPPORT */ + +#include "buffer_info_mng.h" +#include "mapping_info_mng.h" +#include "struct_info_mng.h" + + + + + +/*----------------------------------------------------------------------------*/ +/* Global Variables */ +/*----------------------------------------------------------------------------*/ + + +# ifdef _LIBSTATIC_DATA_MNG_C_ + +IMRT_SDM_Base IMRG_SDM_Base; + + + +IMRT_Module IMRG_SDM_Module = +{ + IMRD_SDM_MODULE_ID, + IMRD_SDM_MODULE_NAME, + IMRD_SDM_MODULE_NAME_LONG, + IMRD_SDM_MODULE_VERSION, + IMRD_MODULE_TYPE_LIBRARY, + { + IMRD_LIB_STATUS_CLOSED, + ( IMRT_Lib_Open *) &IMR_SDM_Library_Open, + ( IMRT_Lib_Close *) &IMR_SDM_Library_Close + } +}; + +# else + +extern IMRT_SDM_Base IMRG_SDM_Base; +extern IMRT_Module IMRG_SDM_Module; + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/mapping_info_mng.c b/src/libstatic_data_mng/src/mapping_info_mng.c new file mode 100644 index 0000000..d589d6a --- /dev/null +++ b/src/libstatic_data_mng/src/mapping_info_mng.c @@ -0,0 +1,843 @@ +/*----------------------------------------------------------------------------*/ +/* File: mapping_info_mng.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _MAPPING_INFO_MNG_C_ + +#include "mapping_info_mng.h" + + + + +/*----------------------------------------------------------------------------*/ +/* FieldMap Manager */ +/*----------------------------------------------------------------------------*/ + +NDT_Status SDM_FieldMap_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "Revision: 2.1 Name: libnode-2_0_4-1 Date: 2002/02/28 22:00:35 Author: agibert "; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + IMRT_FieldMap * Value_ptr = (IMRT_FieldMap *)va_arg( Args, IMRT_FieldMap *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case IMRD_SDMD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + + break; + } + case IMRD_SDMD_CMD_EXECUTE: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_EXECUTE; + + break; + } + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_FieldMap **Value_Ptr_Ptr = va_arg( Args, IMRT_FieldMap **); + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Value_Ptr_Ptr = (IMRT_FieldMap *)malloc( sizeof(IMRT_FieldMap))) == NULL) + { + return( NDS_ERRMEM); + } + else + { + SDM_InitFieldMap( *Value_Ptr_Ptr); + + return( NDS_OK); + } + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_FieldMap *Value_Ptr = (IMRT_FieldMap *)va_arg( Args, IMRT_FieldMap *); + + + Command_Name = "NDD_CMD_VALUE_FREE"; + + free( Value_Ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_FieldMap *Value1_Ptr = va_arg( Args, IMRT_FieldMap *); + IMRT_FieldMap *Value2_Ptr = va_arg( Args, IMRT_FieldMap *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case 0: + { + if( Value1_Ptr->Id < Value2_Ptr->Id) + { + return( NDS_LOWER); + } + else + { + if( Value1_Ptr->Id > Value2_Ptr->Id) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + printf( "Unknown COMP idx (%d) !\n", Index_Id); + + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + + IMRT_FieldMap *Value_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + fprintf( Out, "Id: (%d) InputField: (%s) OutputField: (%s)\n", + Value_Ptr->Id, Value_Ptr->Field_Input_Ptr->Name, Value_Ptr->Field_Output_Ptr->Name); + + return( NDS_OK); + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( NDS_OK); + } + + case NDD_CMD_EXECUTE: + { /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + IMRT_FieldMap * Value_Ptr = (IMRT_FieldMap*)Node_Ptr->Value; + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + va_list user_args = (va_list)va_arg( Args, va_list); + IMRT_SDMCB_Field_Map * MappingFieldFunc = ( IMRT_SDMCB_Field_Map *)va_arg(lib_args, IMRT_SDMCB_Field_Map *); + IMRT_Status status; + + status = MappingFieldFunc(Value_Ptr->Field_Output_Ptr, Value_Ptr->Field_Input_Ptr); + if (status == IMRS_KO) + { + return( NDS_KO); + } + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + IMRT_MsgMap_Id MsgMap_Id = (IMRT_MsgMap_Id)va_arg( user_args, IMRT_MsgMap_Id); + IMRT_FieldMap *FieldMap_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + fprintf( Out, "INSERT INTO IMR_FIELD_MAP(FIELD_MAP_ID, MSG_MAP_ID, FIELD_IN_ID, FIELD_OUT_ID) VALUES(%d, %d, %d, %d);\n", + FieldMap_Ptr->Id, MsgMap_Id, FieldMap_Ptr->Field_Input_Ptr->Id, FieldMap_Ptr->Field_Output_Ptr->Id); + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_FieldMap *FieldMap_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t\t\t<%s>\n\t\t\t\t<%s>%s\n\t\t\t\t<%s>%s\n\t\t\t\n", IMRD_SDMD_TAG_FIELDMAP, + IMRD_SDMD_TAG_INPUTFIELD, FieldMap_Ptr->Field_Input_Ptr->Name, IMRD_SDMD_TAG_INPUTFIELD, + IMRD_SDMD_TAG_OUTPUTFIELD, FieldMap_Ptr->Field_Output_Ptr->Name, IMRD_SDMD_TAG_OUTPUTFIELD, + IMRD_SDMD_TAG_FIELDMAP); + + return( NDS_OK); + } + + default: + { + printf( "SDM_FieldMap_Manager() called with an undefined command %d\n", Command); + + return( NDS_ERRAPI); + } + } + + printf( "SDM_FieldMap_Manager() called with command %d (%s)\n", Command, Command_Name); + + return( NDS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* MsgMap Manager */ +/*----------------------------------------------------------------------------*/ + +NDT_Status SDM_MsgMap_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + NDT_Status status; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "Revision: 2.1 Name: libnode-2_0_4-1 Date: 2002/02/28 22:00:35 Author: agibert "; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + IMRT_MsgMap * Value_ptr = (IMRT_MsgMap *)va_arg( Args, IMRT_MsgMap *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case IMRD_SDMD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + + break; + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + *Reply_Index_Id_Ptr = IMRD_SDMD_MSGMAP_IDX_ID; + *Reply_Command_Ptr = IMRD_SDMD_CMD_API_SQL_DUMP; + break; + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + *Reply_Index_Id_Ptr = IMRD_SDMD_MSGMAP_IDX_ID; + *Reply_Command_Ptr = IMRD_SDMD_CMD_API_XML_DUMP; + break; + } + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Value_Ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_MsgMap **Value_Ptr_Ptr = va_arg( Args, IMRT_MsgMap **); + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Value_Ptr_Ptr = (IMRT_MsgMap *)malloc( sizeof(IMRT_MsgMap))) == NULL) + { + return( NDS_ERRMEM); + } + else + { + SDM_InitMsgMap(*Value_Ptr_Ptr); + + if( ( status = ND_DataStruct_Open( &(*Value_Ptr_Ptr)->FieldMap_Struct_Ptr, IMRD_SDMD_INDEX_NB, index_type_initial_tab, "SDM_FieldMap_Manager", SDM_FieldMap_Manager, NULL, NULL, NULL, NULL,0, NULL)) != NDS_OK) + { + printf( "ND_DataStruct_Open() FieldMap failed (%d) !\n", status); + } + + return( NDS_OK); + } + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_MsgMap *Value_Ptr = (IMRT_MsgMap *)va_arg( Args, IMRT_MsgMap *); + + + Command_Name = "NDD_CMD_VALUE_FREE"; + + if(Value_Ptr->FieldMap_Struct_Ptr != NULL) + { if( ( status = ND_DataStruct_Close(Value_Ptr->FieldMap_Struct_Ptr)) != NDS_OK) + { + printf( "ND_DataStruct_Close() failed (%d) !\n", status); + + return(status); + } + } + + free( Value_Ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_MsgMap *Value1_Ptr = va_arg( Args, IMRT_MsgMap *); + IMRT_MsgMap *Value2_Ptr = va_arg( Args, IMRT_MsgMap *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case IMRD_SDMD_MSGMAP_IDX_ID: + { + if( Value1_Ptr->Id < Value2_Ptr->Id) + { + return( NDS_LOWER); + } + else + { + if( Value1_Ptr->Id > Value2_Ptr->Id) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + case IMRD_SDMD_MSGMAP_IDX_NAME: + { + int rc; + + + rc=strcmp( Value1_Ptr->Name, Value2_Ptr->Name); + + if( rc <0) + { + return( NDS_LOWER); + } + else + { + if( rc > 0) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + printf( "Unknown COMP idx (%d) !\n", Index_Id); + + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Value_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + + IMRT_MsgMap *Value_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + printf("Adresse avant traverse (%x)\n",Value_Ptr); + + fprintf( Out, "Name: (%s) InputMsgName: (%s) OutputMsgName: (%s) \n", + Value_Ptr->Name, Value_Ptr->Msg_Input_Ptr->Name, Value_Ptr->Msg_Output_Ptr->Name); + + return( ND_DataStruct_Value_Print( Out, Value_Ptr->FieldMap_Struct_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, --Recursive_Depth, ++Recursive_Offset)); + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Value_Ptr = Node_Ptr->Value; + */ + + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + + IMRT_MsgMap *Msg_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( ND_DataStruct_Info_Print( Out, Msg_Ptr->FieldMap_Struct_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, --Recursive_Depth, ++Recursive_Offset)); + } + + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_MsgMap *MsgMap_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + fprintf( Out, "INSERT INTO IMR_MSG_MAP(MSG_MAP_ID, MSG_MAP_NAME, MSG_IN_ID, MSG_OUT_ID) VALUES(%d, '%s', %d, %d);\n", + MsgMap_Ptr->Id, MsgMap_Ptr->Name, MsgMap_Ptr->Msg_Input_Ptr->Id, MsgMap_Ptr->Msg_Output_Ptr->Id); + + if( ( status = ND_DataStruct_Traverse( MsgMap_Ptr->FieldMap_Struct_Ptr, IMRD_SDMD_CMD_API_SQL_DUMP, Out, MsgMap_Ptr->Id)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse failed (%d)...\n"); + return(NDS_KO); + } + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Value_Ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_MsgMap *MsgMap_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t<%s>\n\t\t<%s>%s\n\t\t<%s>%s\n\t\t<%s>%s\n\t\t<%s>\n", IMRD_SDMD_TAG_MSGMAP, + IMRD_SDMD_TAG_NAME, MsgMap_Ptr->Name, IMRD_SDMD_TAG_NAME, + IMRD_SDMD_TAG_INPUTMSG, MsgMap_Ptr->Msg_Input_Ptr->Name, IMRD_SDMD_TAG_INPUTMSG, + IMRD_SDMD_TAG_OUTPUTMSG, MsgMap_Ptr->Msg_Output_Ptr->Name, IMRD_SDMD_TAG_OUTPUTMSG, + IMRD_SDMD_TAG_FIELDMAPSTRUCT); + + if( ( status = ND_DataStruct_Traverse( MsgMap_Ptr->FieldMap_Struct_Ptr, IMRD_SDMD_CMD_API_XML_DUMP, Out)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse failed (%d)...\n"); + return(NDS_KO); + } + + fprintf( Out, "\t\t\n\t\n", IMRD_SDMD_TAG_FIELDMAPSTRUCT, IMRD_SDMD_TAG_MSGMAP); + + return( NDS_OK); + } + + + default: + { + printf( "SDM_MsgMap_Manager() called with an undefined command %d\n", Command); + + return( NDS_ERRAPI); + } + } + + printf( "SDM_MsgMap_Manager() called with command %d (%s)\n", Command, Command_Name); + + return( NDS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_MapInfo_Init(IMRT_SDM_Config * Lib_Config_Ptr) +{ + IMRT_Status status; + if(Lib_Config_Ptr->Flag == IMRD_SDM_FLAG_XML) + { + status = SDM_XML_MapInfo_Init(Lib_Config_Ptr->Lib_Path); + } + else + { +#ifdef ORACLE_SUPPORT + status = SDM_SQL_MapInfo_Init(); +#else + status = IMRS_OK; +#endif /* ORACLE_SUPPORT */ + } + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_Close_RootMsgMap(void) +{ + IMRT_Status status; + NDT_Status nd_status; + + status = IMRS_OK; + + if(IMRG_SDM_Base.RootMsgMap != NULL) + { + if (IMRG_SDM_Base.RootMsgMap->User_Ptr != NULL) + { + free(IMRG_SDM_Base.RootMsgMap->User_Ptr); + } + + if( ( nd_status = ND_DataStruct_Close(IMRG_SDM_Base.RootMsgMap)) != NDS_OK) + { + printf( "RootMsgMap ND_DataStruct_Close() failed (%d) !\n", nd_status); + status = IMRS_KO; + } + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_MapInfo_DInit(void) +{ + IMRT_Status status, StatusMsgMap; + NDT_Status nd_status; + + status = IMRS_OK; + + StatusMsgMap = SDM_Close_RootMsgMap(); + + if(StatusMsgMap == IMRS_KO) + { + status = IMRS_KO; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_MsgMap_Proceed( IMRT_MsgMap *MsgMap_Ptr, IMRT_SDMCB_Field_Map *CCB_Field_Map_Ptr) +{ + + NDT_Status status; + + if( ( status = ND_DataStruct_Traverse( MsgMap_Ptr->FieldMap_Struct_Ptr, IMRD_SDMD_CMD_EXECUTE, stdout, NDD_RECURSIVE_MODE_PARENT,CCB_Field_Map_Ptr)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse() failed (%d) !\n", status); + } + return((IMRT_Status)status); +} + +void SDM_InitMsgMap(IMRT_MsgMap * mymsgmap) +{ + memset(mymsgmap->Name,0,sizeof(mymsgmap->Name)); + mymsgmap->Msg_Input_Ptr = NULL; + mymsgmap->Msg_Output_Ptr = NULL; + mymsgmap->FieldMap_Struct_Ptr = NULL; +} + +void SDM_InitFieldMap(IMRT_FieldMap * myfieldmap) +{ + myfieldmap->Id = IMRD_FIELDMAP_ID_UNKNOWN; + myfieldmap->Field_Input_Ptr = NULL; + myfieldmap->Field_Output_Ptr = NULL; +} diff --git a/src/libstatic_data_mng/src/mapping_info_mng.h b/src/libstatic_data_mng/src/mapping_info_mng.h new file mode 100644 index 0000000..fcdc407 --- /dev/null +++ b/src/libstatic_data_mng/src/mapping_info_mng.h @@ -0,0 +1,118 @@ +/*----------------------------------------------------------------------------*/ +/* File: mapping_info_mng.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _MAPPING_INFO_MNG_H_ +# define _MAPPING_INFO_MNG_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include + + +/*----------------------------------------------------------------------------*/ +/* XML TAG */ +/*----------------------------------------------------------------------------*/ +#define IMRD_SDMD_TAG_MSGMAP_STRUCT "msgmap_struct" + +/* Nom des fichiers pour le chargement XML */ +#define SDMD_MSGMAP_FILE "sd_msgmap_struct.xml" + + +/********************************************************************/ +/* Les index du Manager SDM_MsgMap_Manager */ +/********************************************************************/ +#define IMRD_SDMD_MSGMAP_STRUCT_IDX_NB (short)2 + +static NDT_Index_Type MsgMap_Struct_initial_idx_tab[IMRD_SDMD_MSGMAP_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED), + (NDD_INDEX_STATUS_CLOSED) +}; + +static NDT_Index_Type MsgMap_Struct_final_idx_tab[IMRD_SDMD_MSGMAP_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED) +}; + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _MAPPING_INFO_MNG_C_ + +NDT_Status SDM_FieldMap_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +NDT_Status SDM_MsgMap_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +IMRT_Status SDM_MapInfoInfo_Init(IMRT_Lib_Flag Lib_Flag); +IMRT_Status SDM_Close_RootMsgMap(void); +IMRT_Status SDM_MapInfo_Init(IMRT_SDM_Config * Lib_Config_Ptr); +IMRT_Status SDM_MapInfo_DInit(void); +IMRT_Status SDM_MsgMap_Proceed( IMRT_MsgMap *MsgMap_Ptr, IMRT_SDMCB_Field_Map *CCB_Field_Map_Ptr); +void SDM_InitMsgMap(IMRT_MsgMap * mymsgmap); +void SDM_InitFieldMap(IMRT_FieldMap * myfieldmap); + +# else + +extern NDT_Status SDM_FieldMap_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern NDT_Status SDM_MsgMap_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern IMRT_Status SDM_MapInfo_Init(IMRT_SDM_Config * Lib_Config_Ptr); +extern IMRT_Status SDM_Close_RootMsgMap(void); +extern IMRT_Status SDM_MapInfo_DInit(void); +extern IMRT_Status SDM_MsgMap_Proceed( IMRT_MsgMap *MsgMap_Ptr, IMRT_SDMCB_Field_Map *CCB_Field_Map_Ptr); + +# endif + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Includes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _MAPPING_INFO_MNG_C_ + +# include "mapping_info_xml.h" +# include "mapping_info_sql.h" + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/mapping_info_sql.h b/src/libstatic_data_mng/src/mapping_info_sql.h new file mode 100644 index 0000000..fb308f0 --- /dev/null +++ b/src/libstatic_data_mng/src/mapping_info_sql.h @@ -0,0 +1,79 @@ +/*----------------------------------------------------------------------------*/ +/* File: mapping_info_sql.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _MAPPING_INFO_SQL_H_ +# define _MAPPING_INFO_SQL_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _MAPPING_INFO_SQL_PC_ + +IMRT_Status SDM_SQL_MapInfo_Init(void); +IMRT_Status SDM_SQL_Load_MsgMap(NDT_Root **myRootMsgMap_Ptr_Ptr); +IMRT_Status SDM_SQL_LoadFieldMap(IMRT_MsgMap *myMsgMap); +IMRT_Status SDM_SQL_Dump_MsgMap_Header(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_MsgMap_Body(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_MsgMap_Footer(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_MsgMap(void); +IMRT_Status SDM_SQL_MapInfo_Dump(void); + +# else + +extern IMRT_Status SDM_SQL_MapInfo_Init(void); +extern IMRT_Status SDM_SQL_Load_MsgMap(NDT_Root **myRootMsgMap_Ptr_Ptr); +extern IMRT_Status SDM_SQL_LoadFieldMap(IMRT_MsgMap *myMsgMap); +extern IMRT_Status SDM_SQL_Dump_MsgMap_Header(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_MsgMap_Body(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_MsgMap_Footer(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_MsgMap(void); +extern IMRT_Status SDM_SQL_MapInfo_Dump(void); + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/mapping_info_sql.pc b/src/libstatic_data_mng/src/mapping_info_sql.pc new file mode 100644 index 0000000..57f3608 --- /dev/null +++ b/src/libstatic_data_mng/src/mapping_info_sql.pc @@ -0,0 +1,402 @@ +/*----------------------------------------------------------------------------*/ +/* File: mapping_info_sql.pc */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _MAPPING_INFO_SQL_PC_ + +#include "mapping_info_sql.h" + +IMRT_Status SDM_SQL_MapInfo_Init(void) +{ + IMRT_Status status; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading MsgMap..."); + status = SDM_SQL_Load_MsgMap(&(IMRG_SDM_Base.RootMsgMap)); + + if(status == IMRS_OK) + { + IMRD_LM_LOG_INFO_1( "MsgMap loaded: (%d)", IMRG_SDM_Base.RootMsgMap->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't load MsgMap !"); + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Load_MsgMap(NDT_Root **myRootMsgMap_Ptr_Ptr) +{ + const char sFunctionName []="SDM_SQL_Load_MsgMap"; + NDT_Status nd_status; + IMRT_Status status; + NDT_Index_Type *index_type_ptr; + IMRT_Msg message; + NDT_Node *node_ptr; + IMRT_MsgMap *myMsgMap_Ptr; + IMRT_Data_Version *Data_Version_Ptr; + + EXEC SQL BEGIN DECLARE SECTION; + IMRT_MsgMap_Id hMsgMapId; + VARCHAR vMsgMapName[IMRD_NAME_SIZE]; + IMRT_Msg_Id hMsgInId; + IMRT_Msg_Id hMsgOutId; + + short hIndMsgMapId; + short hIndMsgMapName; + short hIndMsgInId; + short hIndMsgOutId; + EXEC SQL END DECLARE SECTION; + + + /*initialisation des indexes*/ + index_type_ptr = MsgMap_Struct_initial_idx_tab; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + status = SDM_SQL_Set_Struct_Version(Data_Version_Ptr, "MsgMap"); + if (status != IMRS_OK) + { + return(IMRS_KO); + } + + nd_status = ND_DataStruct_Open(myRootMsgMap_Ptr_Ptr, IMRD_SDMD_MSGMAP_STRUCT_IDX_NB, index_type_ptr, "SDM_MsgMap_Manager",SDM_MsgMap_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr); + if (nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Open -- SDM_MsgMap_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + EXEC SQL DECLARE cur_imr_msg_map CURSOR FOR + SELECT MSG_MAP_ID, MSG_MAP_NAME, MSG_IN_ID, MSG_OUT_ID + FROM IMR_MSG_MAP + ORDER BY MSG_MAP_ID ASC; + + EXEC SQL OPEN cur_imr_msg_map; + do + { + memset(vMsgMapName.arr, '\0', (size_t) IMRD_NAME_SIZE); + + EXEC SQL FETCH cur_imr_msg_map + INTO :hMsgMapId:hIndMsgMapId, + :vMsgMapName:hIndMsgMapName, + :hMsgInId:hIndMsgInId, + :hMsgOutId:hIndMsgOutId; + if (sqlca.sqlcode == 0) + { + /* creation d'un nouveau objet MsgMap */ + nd_status = ND_Value_Alloc( *myRootMsgMap_Ptr_Ptr, (void **)&(myMsgMap_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- SDM_MsgMap_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + myMsgMap_Ptr->Id = hMsgMapId; + strcpy(myMsgMap_Ptr->Name, (char *) vMsgMapName.arr); + /**** Message InPut ****/ + message.Id = hMsgInId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, + IMRD_SDMD_MSG_IDX_ID, &message, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du Message IN <%d> !", message.Id); + status = IMRS_KO; + } + else + { + myMsgMap_Ptr->Msg_Input_Ptr = node_ptr->Value; + } + /**** Message OutPut ****/ + message.Id = hMsgOutId; + nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, + IMRD_SDMD_MSG_IDX_ID, &message, NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du Message Out <%d> !", message.Id); + status = IMRS_KO; + } + else + { + myMsgMap_Ptr->Msg_Output_Ptr = node_ptr->Value; + } + + status = SDM_SQL_LoadFieldMap(myMsgMap_Ptr); + if (status == IMRS_OK) + { + /* Ajout du message */ + nd_status = ND_DataStruct_Value_Add( *myRootMsgMap_Ptr_Ptr, (void *)myMsgMap_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Value_Add -- SDM_MsgMap_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_msg_map; + + if(status == IMRS_OK) + { + index_type_ptr = MsgMap_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(*myRootMsgMap_Ptr_Ptr, index_type_ptr, IMRD_SDMD_MSGMAP_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump(*myRootMsgMap_Ptr_Ptr);*/ + } + else + { + if(myMsgMap_Ptr->FieldMap_Struct_Ptr != NULL) + { + nd_status = ND_DataStruct_Close(myMsgMap_Ptr->FieldMap_Struct_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + } + } + + nd_status = ND_DataStruct_Close(*myRootMsgMap_Ptr_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + } + } + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_LoadFieldMap(IMRT_MsgMap *myMsgMap_Ptr) +{ + const char sFunctionName []="SDM_SQL_LoadFieldMap"; + NDT_Status nd_status; + IMRT_Status status; + IMRT_Field myField; + NDT_Node *node_ptr; + IMRT_FieldMap *myFieldMap_Ptr; + + EXEC SQL BEGIN DECLARE SECTION; + IMRT_FieldMap_Id hFieldMapId; + IMRT_Field_Id hFieldInId; + IMRT_Field_Id hFieldOutId; + + short hIndFieldMapId; + short hIndFieldInId; + short hIndFieldOutId; + EXEC SQL END DECLARE SECTION; + + status = IMRS_OK; + + EXEC SQL DECLARE cur_imr_field_map CURSOR FOR + SELECT FIELD_MAP_ID, FIELD_IN_ID, FIELD_OUT_ID + FROM IMR_FIELD_MAP + WHERE MSG_MAP_ID = :myMsgMap_Ptr->Id + ORDER BY FIELD_MAP_ID ASC; + + EXEC SQL OPEN cur_imr_field_map; + do + { + + EXEC SQL FETCH cur_imr_field_map + INTO :hFieldMapId:hIndFieldMapId, + :hFieldInId:hIndFieldInId, + :hFieldOutId:hIndFieldOutId; + + if (sqlca.sqlcode == 0) + { + /* Allacation de FieldMap */ + nd_status = ND_Value_Alloc( myMsgMap_Ptr->FieldMap_Struct_Ptr, (void **)&(myFieldMap_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- FieldMap failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + /* Ajout du Field */ + myFieldMap_Ptr->Id = hFieldMapId; + /**** Field InPut ****/ + myField.Id = hFieldInId; + nd_status = ND_Index_Node_Find(&node_ptr, myMsgMap_Ptr->Msg_Input_Ptr->Field_Struct_Ptr, + IMRD_SDMD_FIELD_IDX_ID,&myField,NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du In Field <%d> !", hFieldInId); + status = IMRS_KO; + } + else + { + myFieldMap_Ptr->Field_Input_Ptr = node_ptr->Value; + } + /**** Field OutPut ****/ + myField.Id = hFieldOutId; + nd_status = ND_Index_Node_Find(&node_ptr, myMsgMap_Ptr->Msg_Output_Ptr->Field_Struct_Ptr, + IMRD_SDMD_FIELD_IDX_ID,&myField,NULL); + if((nd_status != NDS_OK)||(node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche du In Field <%d> !", hFieldOutId); + status = IMRS_KO; + } + else + { + myFieldMap_Ptr->Field_Output_Ptr = node_ptr->Value; + } + + nd_status = ND_DataStruct_Value_Add( myMsgMap_Ptr->FieldMap_Struct_Ptr, (void *)(myFieldMap_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Value_Add -- FieldMap failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if(status != IMRS_OK) + { + free(myFieldMap_Ptr); + } + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_field_map; + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_MsgMap_Header(FILE *dump_file) +{ + fprintf(dump_file, "---------------------------------------------------\n"); + fprintf(dump_file, "-- Init file of IMR_MSG_MAP & IMR_FIELD_MAP --\n"); + fprintf(dump_file, "---------------------------------------------------\n\n"); + fprintf(dump_file, "INSERT INTO IMR_DATA_VERSION(VERS_NAME, VERS_LABEL, VERS_DATE) VALUES('MsgMap', '%s', '%s');\n\n", + ((IMRT_Data_Version *)(IMRG_SDM_Base.RootMsgMap->User_Ptr))->Label, + ((IMRT_Data_Version *)(IMRG_SDM_Base.RootMsgMap->User_Ptr))->Date); + fprintf(dump_file, "Delete IMR_FIELD_MAP;\n\n"); + fprintf(dump_file, "Delete IMR_MSG_MAP;\n\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_MsgMap_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootMsgMap, IMRD_SDMD_CMD_API_SQL_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0( "SQL Dump RootMsgMap failed !"); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_MsgMap_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\nCommit;\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_MsgMap(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, "init_imr_msg_map.sql"); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_SQL_Dump_MsgMap_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_MsgMap_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_MsgMap_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_MapInfo_Dump(void) +{ + IMRT_Status status; + + status = SDM_SQL_Dump_MsgMap(); + + return(status); + +} + + + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ diff --git a/src/libstatic_data_mng/src/mapping_info_xml.c b/src/libstatic_data_mng/src/mapping_info_xml.c new file mode 100644 index 0000000..6cf0258 --- /dev/null +++ b/src/libstatic_data_mng/src/mapping_info_xml.c @@ -0,0 +1,547 @@ +/*----------------------------------------------------------------------------*/ +/* File: mapping_info_xml.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _MAPPING_INFO_XML_C_ + +#include "mapping_info_xml.h" + + +IMRT_Status SDM_MsgMap_Ctxt_Close(SDMT_MsgMap_Contexte * MsgMap_Ctx_Ptr) +{ + NDT_Status nd_status; + + if(MsgMap_Ctx_Ptr->RootMsgMap != NULL) + { + if( ( nd_status = ND_DataStruct_Close(MsgMap_Ctx_Ptr->RootMsgMap)) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "MsgMap Struct close failed: (%d) !", nd_status); + } + } + + if(MsgMap_Ctx_Ptr->SaxCtxHdl != NULL) + { + xmlFreeParserCtxt(MsgMap_Ctx_Ptr->SaxCtxHdl); + } + +} + + + + + +IMRT_Status SDM_XML_MapInfo_Init(IMRT_Path Lib_Path) +{ + SDMT_MsgMap_Contexte MsgMap_Ctx; + IMRT_Status status; + char Xml_File_Name[255]; + + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading MsgMap..."); + + MsgMap_Ctx.flagerror = 0; + + MsgMap_Ctx.CptMsgMap = IMRD_MSGMAP_ID_UNKNOWN; + MsgMap_Ctx.CptFieldMap = IMRD_FIELDMAP_ID_UNKNOWN; + memset(MsgMap_Ctx.PathArray,0,sizeof(MsgMap_Ctx.PathArray)); + MsgMap_Ctx.PresentLevelTag = IMRD_SDMD_MIN_LEVEL_TAG; + + memset(Xml_File_Name,0,sizeof(Xml_File_Name)); + strcpy(Xml_File_Name, Lib_Path); + strcat(Xml_File_Name, "/"); + strcat(Xml_File_Name, SDMD_MSGMAP_FILE); + + status = SDM_XML_Load_MsgMap(Xml_File_Name, &(MsgMap_Ctx)); + + if(status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't load MsgMap !"); + } + else + { + IMRG_SDM_Base.RootMsgMap = MsgMap_Ctx.RootMsgMap; + IMRD_LM_LOG_INFO_1( "MsgMap loaded: (%d)", IMRG_SDM_Base.RootMsgMap->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + } + + return(status); +} + + + + + +static IMRT_Status error(SDMT_MsgMap_Contexte *ctx , const char *msg, ...) +{ + xmlParserCtxt * SaxCtx; + + SaxCtx = ctx->SaxCtxHdl; + + IMRD_LM_LOG_ERROR_1( "CallBack error: <%s> !",msg); + + SaxCtx->sax = &ErrorSAXHandlerStruct; + ctx->flagerror = 1; + ctx->FataError.errorCode = SDMD_XML_CODE_ERROR_1; + strcpy(ctx->FataError.libError,msg) ; +} + + + + + +IMRT_Status startElementNsMap( SDMT_MsgMap_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes) +{ + NDT_Status nd_status; + const char functionname [] = "startElementNsMap"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + + + if(strcmp((const char*)localname,IMRD_SDMD_TAG_FIELDMAP) == 0) + { + if( ( nd_status = ND_Value_Alloc( ctx->CurrentMsgMap->FieldMap_Struct_Ptr, (void **)&(ctx->CurrentFieldMap)) != NDS_OK)) + { + IMRD_LM_LOG_ERROR_1( "ND_Value_Alloc() failed (%d) !", nd_status); + + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_3,IMRD_SDMD_TAG_FIELDMAP); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname , DescErr, SDMD_XML_CODE_ERROR_3 ); + } + else + { + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + } + else if(strcmp((const char*)localname, IMRD_SDMD_TAG_MSGMAP) == 0) + { + if( ( nd_status = ND_Value_Alloc( ctx->RootMsgMap, (void **)&(ctx->CurrentMsgMap)) != NDS_OK)) + { + IMRD_LM_LOG_ERROR_1( "ND_Value_Alloc() failed (%d) !", nd_status); + + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_3,IMRD_SDMD_TAG_MSGMAP); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname , DescErr, SDMD_XML_CODE_ERROR_3 ); + } + else + { + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + } + else if(strcmp((const char*)localname, IMRD_SDMD_TAG_FIELDMAPSTRUCT) == 0) + { + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + +} + + + + + +IMRT_Status endElementNsMap( SDMT_MsgMap_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI) +{ + IMRT_Status status_tmp; + NDT_Node * node_ptr; + NDT_Status nd_status; + IMRT_Msg message; + IMRT_Field field; + const char functionname [] = "endElementNsMap"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + + + if (strcmp((const char *)localname, IMRD_SDMD_TAG_NAME) == 0) + { + strcpy(ctx->CurrentMsgMap->Name, ctx->value); + } + else if (strcmp((const char*)localname,IMRD_SDMD_TAG_INPUTMSG) == 0) + { + strcpy(message.Name,ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, IMRD_SDMD_MSG_IDX_NAME, &message, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "IN Msg lookup failed: [%s] !", ctx->value); + + snprintf(DescErr,sizeof(DescErr), SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_INPUTMSG,message.Name); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror),functionname,DescErr,SDMD_XML_CODE_ERROR_4); + } + else + { + ctx->CurrentMsgMap->Msg_Input_Ptr = node_ptr->Value; + } + } + else if (strcmp((const char*)localname,IMRD_SDMD_TAG_OUTPUTMSG) == 0) + { + strcpy(message.Name,ctx->value); + if( ( ( nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootMsg, IMRD_SDMD_MSG_IDX_NAME,&message,NULL)) != NDS_OK)|| + ( node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "OUT Msg lookup failed: [%s] !", ctx->value); + + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_OUTPUTMSG,message.Name); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror),functionname,DescErr,SDMD_XML_CODE_ERROR_4); + } + else + { + ctx->CurrentMsgMap->Msg_Output_Ptr = node_ptr->Value; + } + } + else if (strcmp((const char*)localname,IMRD_SDMD_TAG_INPUTFIELD) == 0) + { + strcpy(field.Name, ctx->value); + if( ( ( nd_status = ND_Index_Node_Find(&node_ptr, ctx->CurrentMsgMap->Msg_Input_Ptr->Field_Struct_Ptr, IMRD_SDMD_FIELD_IDX_NAME,&field,NULL)) != NDS_OK)|| + ( node_ptr == NULL)) + { + printf("\nErreur lors de la recherche du In Field <%s> %s\n",ctx->value, ctx->CurrentMsgMap->Msg_Input_Ptr->Name); + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_INPUTFIELD,field.Name); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror),functionname,DescErr,SDMD_XML_CODE_ERROR_4); + } + else + { + ctx->CurrentFieldMap->Field_Input_Ptr = node_ptr->Value; + } + } + else if (strcmp((const char*)localname,IMRD_SDMD_TAG_OUTPUTFIELD) == 0) + { + strcpy(field.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find(&node_ptr, ctx->CurrentMsgMap->Msg_Output_Ptr->Field_Struct_Ptr, + IMRD_SDMD_FIELD_IDX_NAME,&field,NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_OUTPUTFIELD, field.Name); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror),functionname,DescErr,SDMD_XML_CODE_ERROR_4); + } + else + { + ctx->CurrentFieldMap->Field_Output_Ptr = node_ptr->Value; + } + } + else if (strcmp((const char*)localname,IMRD_SDMD_TAG_FIELDMAP) == 0) + { + ctx->CurrentFieldMap->Id = ctx->CptFieldMap; + + /*Creation de l'identifiant name de l'objet FieldMap*/ + if( ( nd_status = ND_DataStruct_Value_Add( ctx->CurrentMsgMap->FieldMap_Struct_Ptr, (void *)(ctx->CurrentFieldMap))) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "FieldMap add failed: (%d) !", nd_status); + + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_2,IMRD_SDMD_TAG_FIELDMAP ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname , DescErr, SDMD_XML_CODE_ERROR_2 ); + } + else + { + ctx->CptFieldMap ++; + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + } + else if (strcmp((const char*)localname, IMRD_SDMD_TAG_MSGMAP) == 0) + { + ctx->CptMsgMap ++; + ctx->CurrentMsgMap->Id = ctx->CptMsgMap; + + /*Creation de l'identifiant name de l'objet MsgMap*/ + if( ( nd_status = ND_DataStruct_Value_Add( ctx->RootMsgMap, (void *)(ctx->CurrentMsgMap))) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "MsgMap add failed: (%d) !", nd_status); + + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_2,IMRD_SDMD_TAG_MSGMAP ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), functionname , DescErr, SDMD_XML_CODE_ERROR_2 ); + } + else + { + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + } + else if (strcmp((const char*)localname, IMRD_SDMD_TAG_FIELDMAPSTRUCT) == 0) + { + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_VERSION) == 0) + { + IMRD_LM_LOG_INFO_1( "[MsgMap]: [%s]", ctx->value); + status_tmp = SDM_Set_Struct_Version((IMRT_Data_Version *)ctx->RootMsgMap->User_Ptr, (char *)ctx->value); + } + +} + + + + + +IMRT_Status Map_Info_characters(SDMT_MsgMap_Contexte * ctx , const xmlChar *ch, int len) +{ + char output[40]; + int i; + + memset(ctx->value,0, sizeof(ctx->value)); + + for (i = 0;(ivalue[i] = ch[i]; + ctx->value[i] = 0; + +} + +IMRT_Status SDM_XML_Load_MsgMap( char *demo_file, SDMT_MsgMap_Contexte *mycontexte) +{ + IMRT_Status status; + NDT_Status nd_status; + char * docname = NULL; + NDT_Index_Type *index_type_ptr; + xmlDocPtr doc = NULL; + xmlDtdPtr dtd; + xmlParserCtxtPtr ctxt =NULL; + xmlSAXHandlerPtr SAXHandler; + xmlSAXHandlerPtr SAXHandler_sav; + const char functionname[] ="SDM_XML_Load_MsgMap"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + IMRT_Data_Version *Data_Version_Ptr; + + LIBXML_TEST_VERSION + xmlKeepBlanksDefault(0); + xmlSAXDefaultVersion(2); + xmlLineNumbersDefault(1); + + status = IMRS_OK; + docname = demo_file; + ctxt = xmlNewParserCtxt(); + + /*initialisation des indexes*/ + index_type_ptr = MsgMap_Struct_initial_idx_tab; + + if(ctxt != NULL) + { + mycontexte->flagerror = IMRS_OK; + SAXHandler = &SaxMapHandlerStruct; + mycontexte->SaxCtxHdl = ctxt; + ctxt->userData = mycontexte; + SAXHandler_sav = ctxt->sax; + ctxt->sax = SAXHandler; + ctxt->sax2 = 1 ; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + Data_Version_Ptr->Label[0] = '\0'; + Data_Version_Ptr->Date[0] = '\0'; + if( ( nd_status = ND_DataStruct_Open(&(mycontexte->RootMsgMap), IMRD_SDMD_MSGMAP_STRUCT_IDX_NB, index_type_ptr, "SDM_MsgMap_Manager",SDM_MsgMap_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr)) != NDS_OK) + { + status = IMRS_KO; + + IMRD_LM_LOG_ERROR_1( "Can't open RootMsgMap: (%d) !", nd_status); + + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_MSGMAP); + SDM_RaiseError(mycontexte->SaxCtxHdl,&(mycontexte->FataError),&(mycontexte->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + else + { + doc = xmlCtxtReadFile(ctxt,docname,NULL,XML_PARSE_DTDATTR+XML_PARSE_DTDVALID); + if (ctxt->lastError.code != XML_ERR_OK) + { + status = IMRS_KO; + printf("Erreur de parsing du fichier %s.\n%s\n", docname, ctxt->lastError.message); + } + else if(mycontexte->flagerror != IMRS_OK) + { + status = IMRS_KO; + printf("%s\n", mycontexte->FataError.libError); + } + else + { + index_type_ptr = MsgMap_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(mycontexte->RootMsgMap,index_type_ptr, IMRD_SDMD_MSGMAP_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump( mycontexte->RootMsgMap);*/ + } + } + + if((status != IMRS_OK)&&(mycontexte->RootMsgMap != NULL)) + { + if(mycontexte->CurrentMsgMap != NULL) + { + if(mycontexte->CurrentMsgMap->FieldMap_Struct_Ptr != NULL) + { + nd_status = ND_DataStruct_Close(mycontexte->CurrentMsgMap->FieldMap_Struct_Ptr); + } + if(nd_status = NDS_OK) + { + free(mycontexte->CurrentMsgMap); + } + } + + if(mycontexte->CurrentFieldMap != NULL) + { + free(mycontexte->CurrentFieldMap); + } + if(mycontexte->RootMsgMap != NULL) + { + nd_status = ND_DataStruct_Close(mycontexte->RootMsgMap); + } + } + + + ctxt->sax = SAXHandler_sav; + xmlFreeParserCtxt(ctxt); + } + else + { + status = IMRS_KO; + } + + return(status); +} + + + + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_MsgMap_Header(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n"); + fprintf(dump_file, "<%s>\n", IMRD_SDMD_TAG_MSGMAP_STRUCT); + fprintf(dump_file, "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: mapping_info_xml.c $\n", + ((IMRT_Data_Version *)IMRG_SDM_Base.RootMsgMap->User_Ptr)->Label, + ((IMRT_Data_Version *)IMRG_SDM_Base.RootMsgMap->User_Ptr)->Date); + return( IMRS_OK); + +} + + + + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_MsgMap_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootMsgMap, IMRD_SDMD_CMD_API_XML_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + printf( "XML Dump RootMsgMap failed (%d)...\n"); + } + else + { + status = IMRS_OK; + } + + return(status); +} + + + + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_MsgMap_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n", IMRD_SDMD_TAG_MSGMAP_STRUCT); + + return( IMRS_OK); +} + + + + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_MsgMap(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, SDMD_MSGMAP_FILE); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + printf( "Can't open dump file (%s) !\n", dump_filename); + } + else + { + status = SDM_XML_Dump_MsgMap_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_MsgMap_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_MsgMap_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); +} + + + + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_MapInfo_Dump(void) +{ + IMRT_Status status; + + status = SDM_XML_Dump_MsgMap(); + + return(status); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ diff --git a/src/libstatic_data_mng/src/mapping_info_xml.h b/src/libstatic_data_mng/src/mapping_info_xml.h new file mode 100644 index 0000000..6d3ffb3 --- /dev/null +++ b/src/libstatic_data_mng/src/mapping_info_xml.h @@ -0,0 +1,202 @@ +/*----------------------------------------------------------------------------*/ +/* File: mapping_info_xml.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _MAPPING_INFO_XML_H_ +# define _MAPPING_INFO_XML_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include + +/*----------------------------------------------------------------------------*/ +/* Local constantes */ +/*----------------------------------------------------------------------------*/ + +/*definition des tags xml pour le chargement des structure MsgMap et FieldMap*/ + +#define IMRD_SDMD_TAG_NAME "name" +#define IMRD_SDMD_TAG_INPUTMSG "inputmessage" +#define IMRD_SDMD_TAG_OUTPUTMSG "outputmessage" +#define IMRD_SDMD_TAG_FIELDMAP "fieldmap" +#define IMRD_SDMD_TAG_FIELDMAPSTRUCT "fieldmapstruct" +#define IMRD_SDMD_TAG_INPUTFIELD "inputfield" +#define IMRD_SDMD_TAG_OUTPUTFIELD "outputfield" +#define IMRD_SDMD_TAG_MSGFIELDMAPSTRUCT "msgfieldmapstruct" + + + +/*----------------------------------------------------------------------------*/ +/* Local Definition */ +/*----------------------------------------------------------------------------*/ + + +typedef struct SDMT_MsgMap_Contexte +{ + char value[IMRD_SDMD_VALUE_LEN]; + IMRT_Array_Xml_Path PathArray; + IMRT_Level_Tag PresentLevelTag; + IMRT_MsgMap_Id CptMsgMap; + IMRT_FieldMap_Id CptFieldMap; + IMRT_FieldMap * CurrentFieldMap; + IMRT_MsgMap * CurrentMsgMap; + NDT_Root * RootMsgMap; + xmlParserCtxt * SaxCtxHdl; + IMRT_Error FataError; + IMRT_Status flagerror; +}SDMT_MsgMap_Contexte; + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _MAPPING_INFO_XML_C_ + +static IMRT_Status error(SDMT_MsgMap_Contexte *ctx , const char *msg, ...); +IMRT_Status Map_Info_characters(SDMT_MsgMap_Contexte * ctx , const xmlChar *ch, int len); +IMRT_Status endElementNsMap( SDMT_MsgMap_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); +IMRT_Status startElementNsMap( SDMT_MsgMap_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); +IMRT_Status SDM_XML_Load_MsgMap( char *demo_file, SDMT_MsgMap_Contexte *mycontexte); +IMRT_Status SDM_MsgMap_Ctxt_Close(SDMT_MsgMap_Contexte * MsgMap_Ctx_Ptr); +IMRT_Status SDM_XML_MapInfo_Init(IMRT_Path Lib_Path); +IMRT_Status SDM_XML_Dump_MsgMap_Header(FILE *dump_file); +IMRT_Status SDM_XML_Dump_MsgMap_Body(FILE *dump_file); +IMRT_Status SDM_XML_Dump_MsgMap_Footer(FILE *dump_file); +IMRT_Status SDM_XML_Dump_MsgMap(void); +IMRT_Status SDM_XML_MapInfo_Dump(void); + +# else + +extern IMRT_Status SDM_XML_Load_MsgMap( char *demo_file, SDMT_MsgMap_Contexte *mycontexte); +extern IMRT_Status SDM_XML_MapInfo_Init(IMRT_Path Lib_Path); +extern IMRT_Status SDM_XML_Dump_MsgMap_Header(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_MsgMap_Body(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_MsgMap_Footer(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_MsgMap(void); +extern IMRT_Status SDM_XML_MapInfo_Dump(void); + +# endif + + +# ifdef _MAPPING_INFO_XML_C_ + + +/*xmlSAXHandler Map_Info_Error_SAX_Hdl_Struct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + NULL, + NULL, + NULL + };*/ + +xmlSAXHandler SaxMapHandlerStruct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (charactersSAXFunc)(Map_Info_characters), + NULL, + NULL, + NULL, + NULL, + (errorSAXFunc)(error), + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + (startElementNsSAX2Func)(startElementNsMap), + (endElementNsSAX2Func)(endElementNsMap), + NULL +}; + + +# endif + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/struct_info_mng.c b/src/libstatic_data_mng/src/struct_info_mng.c new file mode 100644 index 0000000..0ee2312 --- /dev/null +++ b/src/libstatic_data_mng/src/struct_info_mng.c @@ -0,0 +1,1684 @@ +/*----------------------------------------------------------------------------*/ +/* File: struct_info_mng.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _STRUCT_INFO_MNG_C_ + +#include "struct_info_mng.h" + + + + +/*----------------------------------------------------------------------------*/ +/* Cnv Manager */ +/*----------------------------------------------------------------------------*/ + +NDT_Status SDM_Cnv_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + *Version_Name_Ptr = "Revision: 2.1 Name: libnode-2_0_4-1 Date: 2002/02/28 22:00:35 Author: agibert "; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Cnv_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + IMRT_Cnv *Cnv_ptr = (IMRT_Cnv *)va_arg( Args, IMRT_Cnv *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case IMRD_SDMD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + + break; + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + *Reply_Index_Id_Ptr = IMRD_SDMD_CNV_IDX_ID; + *Reply_Command_Ptr = IMRD_SDMD_CMD_API_SQL_DUMP; + break; + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + *Reply_Index_Id_Ptr = IMRD_SDMD_CNV_IDX_ID; + *Reply_Command_Ptr = IMRD_SDMD_CMD_API_XML_DUMP; + break; + } + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Cnv_ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Cnv **Cnv_ptr_Ptr = va_arg( Args, IMRT_Cnv **); + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Cnv_ptr_Ptr = (IMRT_Cnv *)malloc( sizeof(IMRT_Cnv))) == NULL) + { + return( NDS_ERRMEM); + } + else + { + SDM_InitCnv(*Cnv_ptr_Ptr); + return( NDS_OK); + } + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Cnv_ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Cnv *Cnv_ptr = (IMRT_Cnv *)va_arg( Args, IMRT_Cnv *); + Command_Name = "NDD_CMD_VALUE_FREE"; + + free( Cnv_ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Cnv *Value1_Ptr = va_arg( Args, IMRT_Cnv *); + IMRT_Cnv *Value2_Ptr = va_arg( Args, IMRT_Cnv *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case IMRD_SDMD_CNV_IDX_ID: + { + if( Value1_Ptr->Id < Value2_Ptr->Id) + { + return( NDS_LOWER); + } + else + { + if( Value1_Ptr->Id > Value2_Ptr->Id) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + case IMRD_SDMD_CNV_IDX_NAME: + { + int rc; + + + rc=strcmp( Value1_Ptr->Name, Value2_Ptr->Name); + + if( rc <0) + { + return( NDS_LOWER); + } + else + { + if( rc > 0) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + printf( "Unknown COMP idx (%d) !\n", Index_Id); + + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Cnv_ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Cnv_ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Cnv_ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + + IMRT_Cnv *Cnv_ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + fprintf( Out, "Id: (%d) Name: (%s)\n", Cnv_ptr->Id, Cnv_ptr->Name); + return( NDS_OK); + + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Cnv_ptr = Node_Ptr->Value; + */ + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_EXECUTE: + { /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Cnv_ptr = Node_Ptr->Value; + */ + IMRT_Cnv * Cnv_ptr = (IMRT_Cnv*)Node_Ptr->Value; + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + IMRT_SDMCB_Cnv_Add * CnvProceedFunc = ( IMRT_SDMCB_Cnv_Add *)va_arg(lib_args, IMRT_SDMCB_Cnv_Add *); + + CnvProceedFunc(Cnv_ptr->Id, Cnv_ptr->Name, IMRG_SDM_Base.RootCnv->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Cnv_ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_Cnv *Cnv_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + fprintf( Out, "INSERT INTO IMR_CNV(CNV_ID, CNV_NAME) VALUES(%d, '%s');\n", + Cnv_Ptr->Id, Cnv_Ptr->Name); + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Cnv_ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_Cnv *Cnv_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t<%s>\n", IMRD_SDMD_TAG_CNV); + + fprintf( Out, "\t\t<%s>%s\n", IMRD_SDMD_TAG_NAME, Cnv_Ptr->Name, IMRD_SDMD_TAG_NAME); + + fprintf( Out, "\t\n", IMRD_SDMD_TAG_CNV); + + + return( NDS_OK); + } + + default: + { + printf( "SDM_Cnv_Manager() called with an undefined command %d\n", Command); + return NDS_ERRAPI; + } + } + + printf( "SDM_Cnv_Manager() called with command %d (%s)\n", Command, Command_Name); + return NDS_OK; +} + + +/*----------------------------------------------------------------------------*/ +/* Field Manager */ +/*----------------------------------------------------------------------------*/ + +NDT_Status SDM_Field_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + NDT_Status status; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "Revision: 2.1 Name: libnode-2_0_4-1 Date: 2002/02/28 22:00:35 Author: agibert "; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + IMRT_Field * Field_ptr = (IMRT_Field *)va_arg( Args, IMRT_Field *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case IMRD_SDMD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + + break; + } + + case IMRD_SDMD_CMD_EXECUTE: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_EXECUTE; + break; + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + *Reply_Index_Id_Ptr = IMRD_SDMD_FIELD_IDX_ID; + *Reply_Command_Ptr = IMRD_SDMD_CMD_API_SQL_DUMP; + break; + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + *Reply_Index_Id_Ptr = IMRD_SDMD_FIELD_IDX_ID; + *Reply_Command_Ptr = IMRD_SDMD_CMD_API_XML_DUMP; + break; + } + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Field_ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Field **Field_ptr_Ptr = va_arg( Args, IMRT_Field **); + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Field_ptr_Ptr = (IMRT_Field *)malloc( sizeof(IMRT_Field))) == NULL) + { + return( NDS_ERRMEM); + } + else + { + SDM_InitField(*Field_ptr_Ptr); + + return( NDS_OK); + } + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Field_ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Field *Field_ptr = (IMRT_Field *)va_arg( Args, IMRT_Field *); + + + Command_Name = "NDD_CMD_VALUE_FREE"; + + free( Field_ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Field *Value1_Ptr = va_arg( Args, IMRT_Field *); + IMRT_Field *Value2_Ptr = va_arg( Args, IMRT_Field *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case IMRD_SDMD_FIELD_IDX_ID: + { + if( Value1_Ptr->Id < Value2_Ptr->Id) + { + return( NDS_LOWER); + } + else + { + if( Value1_Ptr->Id > Value2_Ptr->Id) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + case IMRD_SDMD_FIELD_IDX_NAME: + { + int rc; + + + rc=strcmp( Value1_Ptr->Name, Value2_Ptr->Name); + + if( rc <0) + { + return( NDS_LOWER); + } + else + { + if( rc > 0) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + printf( "Unknown COMP idx (%d) !\n", Index_Id); + + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Field_ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Field_ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Field_ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + + IMRT_Field *Field_ptr = Node_Ptr->Value; + char Local_Exist; + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + if (Field_ptr->Exist == IMRD_TRUE) + { + Local_Exist = IMRD_YES; + } + else + { + Local_Exist = IMRD_NO; + } + + fprintf( Out, "Name: (%s) Valueid: (%s) Exist: (%c)\n\tFixed - offset: (%d) size: (%d) Def_Val: (%s) Cnv_Name: (%s) Cnv_Attr: (%s)\n\tFML - tag: (%s) Def_Val: (%s) Cnv_Name: (%s) Cnv_Attr: (%s)\n\tXML - Tag: (%s) Def_Val: (%s) Cnv_Name: (%s) Cnv_Attr: (%s)\n\tTagged - Tag: (%s) Def_Val: (%s) Cnv_Name: (%s) Cnv_Attr: (%s)\n\tInternal - Tag: (%s) Def_Val: (%s) Cnv_Name: (%s) Cnv_Attr: (%s)\n\tDelimited - Id: (%d) Def_Val: (%s) Cnv_Name: (%s) Cnv_Attr: (%s)\n", + Field_ptr->Name, Field_ptr->Value_Id, Local_Exist, + Field_ptr->Fixed.Offset, Field_ptr->Fixed.Size, Field_ptr->Fixed.Def_Val, Field_ptr->Fixed.Cnv_Ptr->Name, Field_ptr->Fixed.Cnv_Attr, + Field_ptr->FML.Tag, Field_ptr->FML.Def_Val, Field_ptr->FML.Cnv_Ptr->Name, Field_ptr->FML.Cnv_Attr, + Field_ptr->XML.Tag, Field_ptr->XML.Def_Val, Field_ptr->XML.Cnv_Ptr->Name, Field_ptr->XML.Cnv_Attr, + Field_ptr->Tagged.Tag, Field_ptr->Tagged.Def_Val, Field_ptr->Tagged.Cnv_Ptr->Name, Field_ptr->Tagged.Cnv_Attr, + Field_ptr->Internal.Tag, Field_ptr->Internal.Def_Val, Field_ptr->Internal.Cnv_Ptr->Name, Field_ptr->Internal.Cnv_Attr, + Field_ptr->Delimited.Id, Field_ptr->Delimited.Def_Val, Field_ptr->Delimited.Cnv_Ptr->Name, Field_ptr->Delimited.Cnv_Attr); + + return( NDS_OK); + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Field_ptr = Node_Ptr->Value; + */ + + Command_Name = "NDD_CMD_INFO_PRINT"; + + return( NDS_OK); + } + + case NDD_CMD_EXECUTE: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + void *Field_ptr = Node_Ptr->Value; + */ + IMRT_Field * Field_ptr = (IMRT_Field *)Node_Ptr->Value; + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + va_list user_args = (va_list)va_arg( Args, va_list); + IMRT_SDM_IdentMessage * IdentStruct = (IMRT_SDM_IdentMessage *)va_arg(lib_args,IMRT_SDM_IdentMessage *); + + if(Field_ptr->Exist == IMRD_TRUE) + { + status = IdentStruct-> Ident_Field_ExistFunc_Ptr(Field_ptr); + + + /*if( ((Next_Node_Ptr == NULL) && (status == (NDT_Status)IMRS_NO_IDENT)) || (status == (NDT_Status)IMRS_KO)) + { + return( NDS_KO); + } + else if (status = (NDT_Status)IMRS_OK) + { + return(NDS_IDENT_OK); + }*/ + + if( status != IMRS_OK) + { + return(status); + } + } + + if(strcmp(Field_ptr->Value_Id, IMRD_SDMD_EMPTY_STRING) != 0) + { + status = IdentStruct-> Ident_Field_ValueFunc_Ptr(Field_ptr, Field_ptr->Value_Id); + + + /*if( ((Next_Node_Ptr == NULL) && (status == (NDT_Status)IMRS_NO_IDENT)) || (status == (NDT_Status)IMRS_KO) ) + { + return( NDS_KO); + } + else if (status == (NDT_Status)IMRS_OK) + { + return(NDS_IDENT_OK); + }*/ + + if( status != IMRS_OK) + { + return(status); + } + + } + + return(NDS_OK); + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Field_ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + IMRT_Field_Id MsgId = (IMRT_Field_Id)va_arg( user_args, IMRT_Field_Id); + + IMRT_Field *Field_Ptr = Node_Ptr->Value; + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + fprintf( Out, "INSERT INTO IMR_FIELD(FIELD_ID, FIELD_NAME, MSG_ID, FIELD_VALUEID, FIELD_EXIST) VALUES(%d, '%s', %d, '%s', ", + Field_Ptr->Id, Field_Ptr->Name, MsgId, Field_Ptr->Value_Id); + + if(Field_Ptr->Exist == IMRD_TRUE) + { + fprintf( Out, "'%c');\n", IMRD_YES); + } + else + { + fprintf( Out, "'%c');\n", IMRD_NO); + } + + + + if(Field_Ptr->Fixed.Size != -1) + { + fprintf( Out, "INSERT INTO IMR_FIXEDFIELD(FIELD_ID, FIXED_FIELD_OFFSET, FIXED_FIELD_SIZE, FIXED_FIELD_CNV_ID, FIXED_FIELD_CNV_ATTR, FIXED_FIELD_DEF_VAL) VALUES(%d, %d, %d, ", + Field_Ptr->Id, Field_Ptr->Fixed.Offset, Field_Ptr->Fixed.Size); + + if(Field_Ptr->Fixed.Cnv_Ptr != NULL) + { + fprintf( Out, "%d, '%s', '%s');\n", + Field_Ptr->Fixed.Cnv_Ptr->Id, Field_Ptr->Fixed.Cnv_Attr, Field_Ptr->Fixed.Def_Val); + } + else + { + fprintf( Out, "NULL, '%s', '%s');\n", + Field_Ptr->Fixed.Cnv_Attr, Field_Ptr->Fixed.Def_Val); + } + } + + if(strcmp(Field_Ptr->FML.Tag, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "INSERT INTO IMR_FMLFIELD(FIELD_ID, FML_FIELD_TAG, FML_FIELD_CNV_ID, FML_FIELD_CNV_ATTR, FML_FIELD_DEF_VAL) VALUES(%d, '%s', ", + Field_Ptr->Id, Field_Ptr->FML.Tag); + + if(Field_Ptr->FML.Cnv_Ptr != NULL) + { + fprintf( Out, "%d, '%s', '%s');\n", + Field_Ptr->FML.Cnv_Ptr->Id, Field_Ptr->FML.Cnv_Attr, Field_Ptr->FML.Def_Val); + } + else + { + fprintf( Out, "NULL, '%s', '%s');\n", + Field_Ptr->FML.Cnv_Attr, Field_Ptr->FML.Def_Val); + } + } + + if(strcmp(Field_Ptr->XML.Tag, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "INSERT INTO IMR_XMLFIELD(FIELD_ID, XML_FIELD_TAG, XML_FIELD_CNV_ID, XML_FIELD_CNV_ATTR, XML_FIELD_DEF_VAL) VALUES(%d, '%s', ", + Field_Ptr->Id, Field_Ptr->XML.Tag); + + if(Field_Ptr->XML.Cnv_Ptr != NULL) + { + fprintf( Out, "%d, '%s', '%s');\n", + Field_Ptr->XML.Cnv_Ptr->Id, Field_Ptr->XML.Cnv_Attr, Field_Ptr->XML.Def_Val); + } + else + { + fprintf( Out, "NULL, '%s', '%s');\n", + Field_Ptr->XML.Cnv_Attr, Field_Ptr->XML.Def_Val); + } + } + + if(strcmp(Field_Ptr->Tagged.Tag, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "INSERT INTO IMR_TAGGEDFIELD(FIELD_ID, TAGGED_FIELD_TAG, TAGGED_FIELD_CNV_ID, TAGGED_FIELD_CNV_ATTR, TAGGED_FIELD_DEF_VAL) VALUES(%d, '%s', ", + Field_Ptr->Id, Field_Ptr->Tagged.Tag); + + if(Field_Ptr->Tagged.Cnv_Ptr != NULL) + { + fprintf( Out, "%d, '%s', '%s');\n", + Field_Ptr->Tagged.Cnv_Ptr->Id, Field_Ptr->Tagged.Cnv_Attr, Field_Ptr->Tagged.Def_Val); + } + else + { + fprintf( Out, "NULL, '%s', '%s');\n", + Field_Ptr->Tagged.Cnv_Attr, Field_Ptr->Tagged.Def_Val); + } + } + + if(strcmp(Field_Ptr->Internal.Tag, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "INSERT INTO IMR_INTERNALFIELD(FIELD_ID, INTERNAL_FIELD_TAG, INTERNAL_FIELD_CNV_ID, INTERNAL_FIELD_CNV_ATTR, INTERNAL_FIELD_DEF_VAL) VALUES(%d, '%s', ", + Field_Ptr->Id, Field_Ptr->Internal.Tag); + + if(Field_Ptr->Internal.Cnv_Ptr != NULL) + { + fprintf( Out, "%d, '%s', '%s');\n", + Field_Ptr->Internal.Cnv_Ptr->Id, Field_Ptr->Internal.Cnv_Attr, Field_Ptr->Internal.Def_Val); + } + else + { + fprintf( Out, "NULL, '%s', '%s');\n", + Field_Ptr->Internal.Cnv_Attr, Field_Ptr->Internal.Def_Val); + } + } + + if(Field_Ptr->Delimited.Id != IMRD_DELIMITED_ID_UNKNOWN) + { + fprintf( Out, "INSERT INTO IMR_DELIMITEDFIELD(FIELD_ID, DELIMITED_FIELD_ID, DELIMITED_FIELD_CNV_ID, DELIMITED_FIELD_CNV_ATTR, DELIMITED_FIELD_DEF_VAL) VALUES(%d, %d, ", + Field_Ptr->Id, Field_Ptr->Delimited.Id); + + if(Field_Ptr->Delimited.Cnv_Ptr != NULL) + { + fprintf( Out, "%d, '%s', '%s');\n", + Field_Ptr->Delimited.Cnv_Ptr->Id, Field_Ptr->Delimited.Cnv_Attr, Field_Ptr->Delimited.Def_Val); + } + else + { + fprintf( Out, "NULL, '%s', '%s');\n", + Field_Ptr->Delimited.Cnv_Attr, Field_Ptr->Delimited.Def_Val); + } + } + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Field_ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_Field *Field_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t\t<%s>\n", IMRD_SDMD_TAG_FIELD); + + if(strcmp(Field_Ptr->Name, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t<%s>%s\n", IMRD_SDMD_TAG_NAME, Field_Ptr->Name, IMRD_SDMD_TAG_NAME); + } + + if(strcmp(Field_Ptr->Value_Id, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t<%s>%s\n", IMRD_SDMD_TAG_VALUEID, Field_Ptr->Value_Id, IMRD_SDMD_TAG_VALUEID); + } + + if(Field_Ptr->Exist == IMRD_TRUE) + { + fprintf( Out, "\t\t\t<%s>%c\n", IMRD_SDMD_TAG_EXIST, IMRD_YES, IMRD_SDMD_TAG_EXIST); + } + + if((Field_Ptr->Fixed.Size != -1)||(Field_Ptr->Fixed.Cnv_Ptr != NULL)||(strcmp(Field_Ptr->Fixed.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0)) + { + fprintf( Out, "\t\t\t<%s>\n\t\t\t\t<%s>%d\n\t\t\t\t<%s>%d\n", IMRD_SDMD_TAG_FIXED, + IMRD_SDMD_TAG_OFFSET, Field_Ptr->Fixed.Offset, IMRD_SDMD_TAG_OFFSET, + IMRD_SDMD_TAG_SIZE, Field_Ptr->Fixed.Size, IMRD_SDMD_TAG_SIZE); + + if(Field_Ptr->Fixed.Cnv_Ptr != NULL) + { + fprintf( Out, "\t\t\t\t<%s>\n\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_CNV, + IMRD_SDMD_TAG_NAME, Field_Ptr->Fixed.Cnv_Ptr->Name, IMRD_SDMD_TAG_NAME); + + if(strcmp(Field_Ptr->Fixed.Cnv_Attr, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_ATTRIBUTE, Field_Ptr->Fixed.Cnv_Attr, IMRD_SDMD_TAG_ATTRIBUTE); + } + + fprintf( Out, "\t\t\t\t\n", IMRD_SDMD_TAG_CNV); + } + + if(strcmp(Field_Ptr->Fixed.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_DEFVAL, Field_Ptr->Fixed.Def_Val, IMRD_SDMD_TAG_DEFVAL); + } + + fprintf( Out, "\t\t\t\n", IMRD_SDMD_TAG_FIXED); + } + + + if((strcmp(Field_Ptr->Tagged.Tag, IMRD_SDMD_EMPTY_STRING) != 0)|| + (Field_Ptr->Tagged.Cnv_Ptr != NULL)|| + (strcmp(Field_Ptr->Tagged.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0)) + { + fprintf( Out, "\t\t\t<%s>\n\t\t\t\t<%s>%s\n", IMRD_SDMD_TAG_TAGGED, + IMRD_SDMD_TAG_NAME, Field_Ptr->Tagged.Tag, IMRD_SDMD_TAG_NAME); + + if(Field_Ptr->Tagged.Cnv_Ptr != NULL) + { + fprintf( Out, "\t\t\t\t<%s>\n\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_CNV, + IMRD_SDMD_TAG_NAME, Field_Ptr->Tagged.Cnv_Ptr->Name, IMRD_SDMD_TAG_NAME); + + if(strcmp(Field_Ptr->Tagged.Cnv_Attr, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_ATTRIBUTE, Field_Ptr->Tagged.Cnv_Attr, IMRD_SDMD_TAG_ATTRIBUTE); + } + + fprintf( Out, "\t\t\t\t\n", IMRD_SDMD_TAG_CNV); + } + + if(strcmp(Field_Ptr->Tagged.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_DEFVAL, Field_Ptr->Tagged.Def_Val, IMRD_SDMD_TAG_DEFVAL); + } + + fprintf( Out, "\t\t\t\n", IMRD_SDMD_TAG_TAGGED); + + } + + if((strcmp(Field_Ptr->Internal.Tag, IMRD_SDMD_EMPTY_STRING) != 0)|| + (Field_Ptr->Internal.Cnv_Ptr != NULL)|| + (strcmp(Field_Ptr->Internal.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0)) + { + fprintf( Out, "\t\t\t<%s>\n\t\t\t\t<%s>%s\n", IMRD_SDMD_TAG_INTERNE, + IMRD_SDMD_TAG_NAME, Field_Ptr->Internal.Tag, IMRD_SDMD_TAG_NAME); + + if(Field_Ptr->Internal.Cnv_Ptr != NULL) + { + fprintf( Out, "\t\t\t\t<%s>\n\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_CNV, + IMRD_SDMD_TAG_NAME, Field_Ptr->Internal.Cnv_Ptr->Name, IMRD_SDMD_TAG_NAME); + + if(strcmp(Field_Ptr->Internal.Cnv_Attr, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_ATTRIBUTE, Field_Ptr->Internal.Cnv_Attr, IMRD_SDMD_TAG_ATTRIBUTE); + } + + fprintf( Out, "\t\t\t\t\n", IMRD_SDMD_TAG_CNV); + } + + if(strcmp(Field_Ptr->Internal.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_DEFVAL, Field_Ptr->Internal.Def_Val, IMRD_SDMD_TAG_DEFVAL); + } + + fprintf( Out, "\t\t\t\n", IMRD_SDMD_TAG_INTERNE); + + } + + + if((strcmp(Field_Ptr->FML.Tag, IMRD_SDMD_EMPTY_STRING) != 0)|| + (Field_Ptr->FML.Cnv_Ptr != NULL)|| + (strcmp(Field_Ptr->FML.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0)) + { + fprintf( Out, "\t\t\t<%s>\n\t\t\t\t<%s>%s\n", IMRD_SDMD_TAG_FML, + IMRD_SDMD_TAG_NAME, Field_Ptr->FML.Tag, IMRD_SDMD_TAG_NAME); + + if(Field_Ptr->FML.Cnv_Ptr != NULL) + { + fprintf( Out, "\t\t\t\t<%s>\n\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_CNV, + IMRD_SDMD_TAG_NAME, Field_Ptr->FML.Cnv_Ptr->Name, IMRD_SDMD_TAG_NAME); + + if(strcmp(Field_Ptr->FML.Cnv_Attr, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_ATTRIBUTE, Field_Ptr->FML.Cnv_Attr, IMRD_SDMD_TAG_ATTRIBUTE); + } + + fprintf( Out, "\t\t\t\t\n", IMRD_SDMD_TAG_CNV); + } + + if(strcmp(Field_Ptr->FML.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_DEFVAL, Field_Ptr->FML.Def_Val, IMRD_SDMD_TAG_DEFVAL); + } + + fprintf( Out, "\t\t\t\n", IMRD_SDMD_TAG_FML); + + } + + if((strcmp(Field_Ptr->XML.Tag, IMRD_SDMD_EMPTY_STRING) != 0)|| + (Field_Ptr->XML.Cnv_Ptr != NULL)|| + (strcmp(Field_Ptr->XML.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0)) + { + fprintf( Out, "\t\t\t<%s>\n\t\t\t\t<%s>%s\n", IMRD_SDMD_TAG_XML, + IMRD_SDMD_TAG_NAME, Field_Ptr->XML.Tag, IMRD_SDMD_TAG_NAME); + + if(Field_Ptr->XML.Cnv_Ptr != NULL) + { + fprintf( Out, "\t\t\t\t<%s>\n\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_CNV, + IMRD_SDMD_TAG_NAME, Field_Ptr->XML.Cnv_Ptr->Name, IMRD_SDMD_TAG_NAME); + + if(strcmp(Field_Ptr->XML.Cnv_Attr, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_ATTRIBUTE, Field_Ptr->XML.Cnv_Attr, IMRD_SDMD_TAG_ATTRIBUTE); + } + + fprintf( Out, "\t\t\t\t\n", IMRD_SDMD_TAG_CNV); + } + + if(strcmp(Field_Ptr->XML.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_DEFVAL, Field_Ptr->XML.Def_Val, IMRD_SDMD_TAG_DEFVAL); + } + + fprintf( Out, "\t\t\t\n", IMRD_SDMD_TAG_XML); + + } + + + if((Field_Ptr->Delimited.Id != IMRD_DELIMITED_ID_UNKNOWN)|| + (Field_Ptr->Delimited.Cnv_Ptr != NULL)|| + (strcmp(Field_Ptr->Delimited.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0)) + { + fprintf( Out, "\t\t\t<%s>\n\t\t\t\t<%s>%d\n", IMRD_SDMD_TAG_DELIMITED, + IMRD_SDMD_TAG_ID, Field_Ptr->Delimited.Id, IMRD_SDMD_TAG_ID); + + if(Field_Ptr->Delimited.Cnv_Ptr != NULL) + { + fprintf( Out, "\t\t\t\t<%s>\n\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_CNV, + IMRD_SDMD_TAG_NAME, Field_Ptr->Delimited.Cnv_Ptr->Name, IMRD_SDMD_TAG_NAME); + + if(strcmp(Field_Ptr->Delimited.Cnv_Attr, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_ATTRIBUTE, Field_Ptr->Delimited.Cnv_Attr, IMRD_SDMD_TAG_ATTRIBUTE); + } + + fprintf( Out, "\t\t\t\t\n", IMRD_SDMD_TAG_CNV); + } + + if(strcmp(Field_Ptr->Delimited.Def_Val, IMRD_SDMD_EMPTY_STRING) != 0) + { + fprintf( Out, "\t\t\t\t<%s>%s\n", + IMRD_SDMD_TAG_DEFVAL, Field_Ptr->Delimited.Def_Val, IMRD_SDMD_TAG_DEFVAL); + } + + fprintf( Out, "\t\t\t\n", IMRD_SDMD_TAG_DELIMITED); + } + + fprintf( Out, "\t\t\n", IMRD_SDMD_TAG_FIELD); + + return( NDS_OK); + } + + + default: + { + printf( "SDM_Field_Manager() called with an undefined command %d\n", Command); + + return( NDS_ERRAPI); + } + } + + printf( "SDM_Field_Manager() called with command %d (%s)\n", Command, Command_Name); + + return( NDS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* Msg Manager */ +/*----------------------------------------------------------------------------*/ + +NDT_Status SDM_Msg_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list Args) +{ + NDT_Command_Name Command_Name; + NDT_Status status; + + + switch( Command) + { + case NDD_CMD_MANAGER_VERSION: + { + NDT_Version_Name *Version_Name_Ptr = (NDT_Version_Name *)va_arg( Args, NDT_Version_Name *); + + + Command_Name = "NDD_CMD_MANAGER_VERSION"; + + *Version_Name_Ptr = "Revision: 2.1 Name: libnode-2_0_4-1 Date: 2002/02/28 22:00:35 Author: agibert "; + + return( NDS_OK); + } + + case NDD_CMD_INDEX_GET: + { + /* + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + void *Value_ptr = (void *)va_arg( Args, void *); + */ + NDT_Index_Id *Reply_Index_Id_Ptr = (NDT_Index_Id *)va_arg( Args, NDT_Index_Id *); + NDT_Command *Reply_Command_Ptr = (NDT_Command *)va_arg( Args, NDT_Command *); + NDT_Command Cmd = (NDT_Command)va_arg( Args, NDT_Command); + IMRT_Msg *Msg_ptr = (IMRT_Msg *)va_arg( Args, IMRT_Msg *); + + + Command_Name = "NDD_CMD_INDEX_GET"; + + switch(Cmd) + { + case IMRD_SDMD_CMD_INDEX0_PRINT: + { + *Reply_Index_Id_Ptr = 0; + *Reply_Command_Ptr = NDD_CMD_VALUE_PRINT; + + break; + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + *Reply_Index_Id_Ptr = IMRD_SDMD_MSG_IDX_ID; + *Reply_Command_Ptr = IMRD_SDMD_CMD_API_SQL_DUMP; + break; + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + *Reply_Index_Id_Ptr = IMRD_SDMD_MSG_IDX_ID; + *Reply_Command_Ptr = IMRD_SDMD_CMD_API_XML_DUMP; + break; + } + + default: + { + *Reply_Index_Id_Ptr = Index_Id; + *Reply_Command_Ptr = Cmd; + + break; + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ALLOC: + { + /* + void **Msg_ptr_Ptr = (void **)va_arg( Args, void **); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Msg **Msg_ptr_Ptr = va_arg( Args, IMRT_Msg **); + NDT_Index_Type *index_type_ptr; + + + Command_Name = "NDD_CMD_VALUE_ALLOC"; + + if( ( *Msg_ptr_Ptr = (IMRT_Msg *)malloc( sizeof(IMRT_Msg))) == NULL) + { + return( NDS_ERRMEM); + } + else + { + + SDM_InitMessage(*Msg_ptr_Ptr); + + index_type_ptr = Msg_Struct_initial_idx_tab; + + if( ( status = ND_DataStruct_Open( &(*Msg_ptr_Ptr)->Field_Struct_Ptr, IMRD_SDMD_FIELD_STRUCT_IDX_NB, index_type_ptr, "SDM__Field_Manager", SDM_Field_Manager, NULL, NULL, NULL, NULL,0, NULL)) != NDS_OK) + { + printf( "ND_DataStruct_Open() Field failed (%d) !\n", status); + return(NDS_KO); + } + + return( NDS_OK); + } + } + + case NDD_CMD_VALUE_FREE: + { + /* + void *Msg_ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Msg *Msg_ptr = (IMRT_Msg *)va_arg( Args, IMRT_Msg *); + + + Command_Name = "NDD_CMD_VALUE_FREE"; + if(Msg_ptr->Field_Struct_Ptr != NULL) + { if( ( status = ND_DataStruct_Close(Msg_ptr->Field_Struct_Ptr)) != NDS_OK) + { + printf( "ND_DataStruct_Close() failed (%d) !\n", status); + return(status); + } + } + + free( Msg_ptr); + + return( NDS_OK); + } + + case NDD_CMD_VALUE_COMP: + { + /* + void *Value1_Ptr = (void *)va_arg( Args, void *); + void *Value2_Ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + IMRT_Msg *Value1_Ptr = va_arg( Args, IMRT_Msg *); + IMRT_Msg *Value2_Ptr = va_arg( Args, IMRT_Msg *); + + + Command_Name = "NDD_CMD_VALUE_COMP"; + + switch( Index_Id) + { + case IMRD_SDMD_MSG_IDX_ID: + { + if( Value1_Ptr->Id < Value2_Ptr->Id) + { + return( NDS_LOWER); + } + else + { + if( Value1_Ptr->Id > Value2_Ptr->Id) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + case IMRD_SDMD_MSG_IDX_NAME: + { + int rc; + + rc = strcmp( Value1_Ptr->Name, Value2_Ptr->Name); + + if( rc < 0) + { + return( NDS_LOWER); + } + else + { + if( rc > 0) + { + return( NDS_GREATER); + } + else + { + return( NDS_EQUAL); + } + } + } + + default: + { + printf( "Unknown COMP idx (%d) !\n", Index_Id); + return( NDS_KO); + } + } + + return( NDS_OK); + } + + case NDD_CMD_VALUE_ADD: + { + /* + void *Msg_ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_ADD"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_REMOVE: + { + /* + void *Msg_ptr = (void *)va_arg( Args, void *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + */ + + Command_Name = "NDD_CMD_VALUE_REMOVE"; + + return( NDS_OK); + } + + case NDD_CMD_VALUE_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Msg_ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + + IMRT_Msg *Msg_ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_VALUE_PRINT"; + + printf("Adresse avant traverse (%x)\n",Msg_ptr); + + fprintf( Out, "Type: (%s) Size: (%d) \n", + Msg_ptr->Name, Msg_ptr->Size); + + return( ND_DataStruct_Value_Print( Out, Msg_ptr->Field_Struct_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, --Recursive_Depth, ++Recursive_Offset)); + + } + + case NDD_CMD_INFO_PRINT: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + va_list user_args = (va_list)va_arg( lib_args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Msg_ptr = Node_Ptr->Value; + */ + + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list lib_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( lib_args, FILE *); + NDT_Recursive_Mode Recursive_Mode = (NDT_Recursive_Mode)va_arg( lib_args, NDT_Recursive_Mode); + NDT_Recursive_Depth Recursive_Depth = (NDT_Recursive_Depth)va_arg( lib_args, NDT_Recursive_Depth); + NDT_Recursive_Offset Recursive_Offset = (NDT_Recursive_Offset)va_arg( lib_args, NDT_Recursive_Offset); + + IMRT_Msg *Msg_Ptr = Node_Ptr->Value; + + + Command_Name = "NDD_CMD_INFO_PRINT"; + + + return( ND_DataStruct_Info_Print( Out, Msg_Ptr->Field_Struct_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, --Recursive_Depth, ++Recursive_Offset)); + + } + + case IMRD_SDMD_CMD_API_SQL_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Msg_ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_Msg *Msg_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_SQL_DUMP"; + + fprintf( Out, "INSERT INTO IMR_MSG(MSG_ID, MSG_NAME, MSG_SIZE) VALUES(%d, '%s', %d);\n", + Msg_Ptr->Id, Msg_Ptr->Name, Msg_Ptr->Size); + + if( ( status = ND_DataStruct_Traverse( Msg_Ptr->Field_Struct_Ptr, IMRD_SDMD_CMD_API_SQL_DUMP, Out, Msg_Ptr->Id)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse failed (%d)...\n"); + return(NDS_KO); + } + + return( NDS_OK); + } + + case IMRD_SDMD_CMD_API_XML_DUMP: + { + /* + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + user_type user_data = (user_type)va_arg( user_args, user_type); + ... = (...)va_arg( user_args, ...); + + void *Msg_ptr = Node_Ptr->Value; + */ + NDT_Node *Next_Node_Ptr = (NDT_Node *)va_arg( Args, NDT_Node *); + va_list user_args = (va_list)va_arg( Args, va_list); + FILE *Out = (FILE *)va_arg( user_args, FILE *); + + IMRT_Msg *Msg_Ptr = Node_Ptr->Value; + + + Command_Name = "IMRD_SDMD_CMD_API_XML_DUMP"; + + fprintf( Out, "\t<%s>\n\t\t<%s>%s\n", IMRD_SDMD_TAG_MESSAGE, + IMRD_SDMD_TAG_NAME, Msg_Ptr->Name, IMRD_SDMD_TAG_NAME); + + if(Msg_Ptr->Size != 0) + { + fprintf( Out, "\t\t<%s>%ld\n", + IMRD_SDMD_TAG_SIZE, Msg_Ptr->Size, IMRD_SDMD_TAG_SIZE); + } + + if( ( status = ND_DataStruct_Traverse( Msg_Ptr->Field_Struct_Ptr, IMRD_SDMD_CMD_API_XML_DUMP, Out)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse failed (%d)...\n"); + return(NDS_KO); + } + + fprintf( Out, "\t\n", IMRD_SDMD_TAG_MESSAGE); + + return( NDS_OK); + } + + default: + { + printf( "SDM_Msg_Manager() called with an undefined command %d\n", Command); + + return( NDS_ERRAPI); + } + } + + printf( "SDM_Msg_Manager() called with command %d (%s)\n", Command, Command_Name); + + return( NDS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_StructInfo_Init(IMRT_SDM_Config * Lib_Config_Ptr) +{ + IMRT_Status status; + + if(Lib_Config_Ptr->Flag == IMRD_SDM_FLAG_XML) + { + status= SDM_XML_StructInfo_Init(Lib_Config_Ptr->Lib_Path); + } + else + { +#ifdef ORACLE_SUPPORT + status = SDM_SQL_StructInfo_Init(); +#else + status = IMRS_OK; +#endif /* ORACLE_SUPPORT */ + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_Close_RootCnv(void) +{ + IMRT_Status status; + NDT_Status nd_status; + + status = IMRS_OK; + + if(IMRG_SDM_Base.RootCnv != NULL) + { + if (IMRG_SDM_Base.RootCnv->User_Ptr != NULL) + { + free(IMRG_SDM_Base.RootCnv->User_Ptr); + } + + if( ( nd_status = ND_DataStruct_Close(IMRG_SDM_Base.RootCnv)) != NDS_OK) + { + printf( "RootCnv ND_DataStruct_Close() failed (%d) !\n", nd_status); + status = IMRS_KO; + } + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_Close_RootMsg(void) +{ + IMRT_Status status; + NDT_Status nd_status; + + status = IMRS_OK; + + if(IMRG_SDM_Base.RootMsg != NULL) + { + if (IMRG_SDM_Base.RootMsg->User_Ptr != NULL) + { + free(IMRG_SDM_Base.RootMsg->User_Ptr); + } + + if( ( nd_status = ND_DataStruct_Close(IMRG_SDM_Base.RootMsg)) != NDS_OK) + { + printf( "RootMsg ND_DataStruct_Close() failed (%d) !\n", nd_status); + status = IMRS_KO; + } + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_StructInfo_DInit(void) +{ + IMRT_Status status, StatusCnv, StatusMsg; + + status = IMRS_OK; + + StatusCnv = SDM_Close_RootCnv(); + StatusMsg = SDM_Close_RootMsg(); + + if((StatusCnv == IMRS_KO)||(StatusMsg == IMRS_KO)) + { + status = IMRS_KO; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_Cnv_Proceed( IMRT_SDMCB_Cnv_Add *CCB_Cnv_Add_Ptr) +{ + + IMRT_Status status; + NDT_Status nd_status; + + status = IMRS_OK; + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootCnv, IMRD_SDMD_CMD_EXECUTE, stdout, NDD_RECURSIVE_MODE_PARENT, CCB_Cnv_Add_Ptr)) != NDS_OK) + { + printf( "ND_DataStruct_Traverse() failed (%d) !\n", nd_status); + status = IMRS_KO; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +void SDM_InitMessage(IMRT_Msg * mymessage) +{ + mymessage->Id = IMRD_MSG_ID_UNKNOWN; + memset(mymessage->Name,0,sizeof(mymessage->Name)); + mymessage->Size = 0; + mymessage->Field_Struct_Ptr = NULL; +} + +void SDM_InitField(IMRT_Field * myfield) +{ + memset(myfield->Name,0,sizeof(myfield->Name)); + memset(myfield->Value_Id,0,sizeof(myfield->Value_Id)); + myfield->Exist = IMRD_FALSE; + + myfield->Fixed.Offset = 0; + myfield->Fixed.Size = -1; + memset(myfield->Fixed.Def_Val,'\0',sizeof(myfield->Fixed.Def_Val)); + myfield->Fixed.Cnv_Ptr = NULL; + memset(myfield->Fixed.Cnv_Attr,0,sizeof(myfield->Fixed.Cnv_Attr)); + + memset(myfield->XML.Tag,0,sizeof(myfield->XML.Tag)); + memset(myfield->XML.Def_Val,'\0',sizeof(myfield->XML.Def_Val)); + myfield->XML.Cnv_Ptr = NULL; + memset(myfield->XML.Cnv_Attr,0,sizeof(myfield->XML.Cnv_Attr)); + + memset(myfield->FML.Tag,0,sizeof(myfield->FML.Tag)); + memset(myfield->FML.Def_Val,'\0',sizeof(myfield->FML.Def_Val)); + myfield->FML.Cnv_Ptr = NULL; + memset(myfield->FML.Cnv_Attr,0,sizeof(myfield->FML.Cnv_Attr)); + + memset(myfield->Tagged.Tag,0,sizeof(myfield->Tagged.Tag)); + memset(myfield->Tagged.Def_Val,'\0',sizeof(myfield->Tagged.Def_Val)); + myfield->Tagged.Cnv_Ptr = NULL; + memset(myfield->Tagged.Cnv_Attr,0,sizeof(myfield->Tagged.Cnv_Attr)); + + memset(myfield->Internal.Tag,0,sizeof(myfield->Internal.Tag)); + memset(myfield->Internal.Def_Val,'\0',sizeof(myfield->Internal.Def_Val)); + myfield->Internal.Cnv_Ptr = NULL; + memset(myfield->Internal.Cnv_Attr,0,sizeof(myfield->Internal.Cnv_Attr)); + + myfield->Delimited.Id = IMRD_DELIMITED_ID_UNKNOWN; + memset(myfield->Delimited.Def_Val,'\0',sizeof(myfield->Delimited.Def_Val)); + myfield->Delimited.Cnv_Ptr = NULL; + memset(myfield->Delimited.Cnv_Attr,0,sizeof(myfield->Delimited.Cnv_Attr)); +} + +void SDM_InitCnv(IMRT_Cnv * Cnv_Ptr) +{ + Cnv_Ptr->Id = IMRD_CNV_ID_UNKNOWN; + memset(Cnv_Ptr->Name,0,sizeof(Cnv_Ptr->Name)); +} + + diff --git a/src/libstatic_data_mng/src/struct_info_mng.h b/src/libstatic_data_mng/src/struct_info_mng.h new file mode 100644 index 0000000..1474f06 --- /dev/null +++ b/src/libstatic_data_mng/src/struct_info_mng.h @@ -0,0 +1,170 @@ +/*----------------------------------------------------------------------------*/ +/* File: struct_info_mng.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _STRUCT_INFO_MNG_H_ +# define _STRUCT_INFO_MNG_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include + + +/*----------------------------------------------------------------------------*/ +/* XML TAG */ +/*----------------------------------------------------------------------------*/ +#define IMRD_SDMD_TAG_CNV_STRUCT "cnv_struct" +#define IMRD_SDMD_TAG_MSG_STRUCT "msg_struct" + + +/* Nom des fichiers pour le chargement XML */ +#define SDMD_MSGFIELD_FILE "sd_msg_struct.xml" +#define SDMD_CNV_FILE "sd_cnv_struct.xml" + + +/********************************************************************/ +/* Les index du Manager SDM_Msg_Manager */ +/********************************************************************/ +#define IMRD_SDMD_MSG_STRUCT_IDX_NB (short)2 + +static NDT_Index_Type Msg_Struct_initial_idx_tab[IMRD_SDMD_MSG_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED), + (NDD_INDEX_STATUS_CLOSED) +}; + +static NDT_Index_Type Msg_Struct_final_idx_tab[IMRD_SDMD_MSG_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED) +}; + +#define IMRD_SDMD_MSG_IDX_ID (short)0 +#define IMRD_SDMD_MSG_IDX_NAME (short)1 + + +/********************************************************************/ +/* Les index du Manager SDM_Field_Manager */ +/********************************************************************/ +#define IMRD_SDMD_FIELD_STRUCT_IDX_NB (short)2 + +static NDT_Index_Type Field_Struct_initial_idx_tab[IMRD_SDMD_FIELD_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED), + (NDD_INDEX_STATUS_CLOSED) +}; + +static NDT_Index_Type Field_Struct_final_idx_tab[IMRD_SDMD_FIELD_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED) +}; + +#define IMRD_SDMD_FIELD_IDX_ID (short)0 +#define IMRD_SDMD_FIELD_IDX_NAME (short)1 + + +/********************************************************************/ +/* Les index du Manager SDM_Cnv_Manager */ +/********************************************************************/ +#define IMRD_SDMD_CNV_STRUCT_IDX_NB (short)2 + +static NDT_Index_Type Cnv_Struct_initial_idx_tab[IMRD_SDMD_CNV_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED), + (NDD_INDEX_STATUS_CLOSED) +}; + +static NDT_Index_Type Cnv_Struct_final_idx_tab[IMRD_SDMD_CNV_STRUCT_IDX_NB] = +{ + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED), + (NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED) +}; + +#define IMRD_SDMD_CNV_IDX_ID (short)0 +#define IMRD_SDMD_CNV_IDX_NAME (short)1 + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _STRUCT_INFO_MNG_C_ + +NDT_Status SDM_Cnv_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +NDT_Status SDM_Field_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +NDT_Status SDM_Msg_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +IMRT_Status SDM_StructInfo_Init(IMRT_SDM_Config * Lib_Config_Ptr); +IMRT_Status SDM_Close_RootCnv(void); +IMRT_Status SDM_Close_RootMsg(void); +IMRT_Status SDM_StructInfo_DInit(void); +IMRT_Status SDM_Cnv_Proceed( IMRT_SDMCB_Cnv_Add *CCB_Cnv_Add_Ptr); +void SDM_InitMessage(IMRT_Msg * mymessage); +void SDM_InitField(IMRT_Field * myfield); +void SDM_InitCnv(IMRT_Cnv * Cnv_Ptr); + +# else + +extern NDT_Status SDM_Cnv_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern NDT_Status SDM_Field_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern NDT_Status SDM_Msg_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list); +extern IMRT_Status SDM_StructInfo_Init(IMRT_SDM_Config * Lib_Config_Ptr); +extern IMRT_Status SDM_Close_RootCnv(void); +extern IMRT_Status SDM_Close_RootMsg(void); +extern IMRT_Status SDM_StructInfo_DInit(void); +extern IMRT_Status SDM_Cnv_Proceed( IMRT_SDMCB_Cnv_Add *CCB_Cnv_Add_Ptr); + +# endif + + + + + +/*----------------------------------------------------------------------------*/ +/* Local Includes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _STRUCT_INFO_MNG_C_ + +# include "struct_info_xml.h" +# include "struct_info_sql.h" + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/struct_info_sql.h b/src/libstatic_data_mng/src/struct_info_sql.h new file mode 100644 index 0000000..673febc --- /dev/null +++ b/src/libstatic_data_mng/src/struct_info_sql.h @@ -0,0 +1,87 @@ +/*----------------------------------------------------------------------------*/ +/* File: struct_info_sql.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _STRUCT_INFO_SQL_H_ +# define _STRUCT_INFO_SQL_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include + + + + + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _STRUCT_INFO_SQL_PC_ + +IMRT_Status SDM_SQL_StructInfo_Init(void); +IMRT_Status SDM_SQL_Load_Cnv(NDT_Root **myRootCnv_Ptr_Ptr); +IMRT_Status SDM_SQL_Load_MsgAndField(NDT_Root **myRootMessage_Ptr_Ptr); +IMRT_Status SDM_SQL_LoadFieldMsg(IMRT_Msg *myMsg_Ptr); +IMRT_Status SDM_SQL_Dump_Msg_Header(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Msg_Body(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Msg_Footer(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Msg(void); +IMRT_Status SDM_SQL_Dump_Cnv_Header(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Cnv_Body(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Cnv_Footer(FILE *dump_file); +IMRT_Status SDM_SQL_Dump_Cnv(void); + +# else + +extern IMRT_Status SDM_SQL_StructInfo_Init(void); +extern IMRT_Status SDM_SQL_Load_Cnv(NDT_Root **myRootCnv_Ptr_Ptr); +extern IMRT_Status SDM_SQL_Load_MsgAndField(NDT_Root **myRootMessage_Ptr_Ptr); +extern IMRT_Status SDM_SQL_LoadFieldMsg(IMRT_Msg *myMsg_Ptr); +extern IMRT_Status SDM_SQL_Dump_Msg_Header(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Msg_Body(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Msg_Footer(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Msg(void); +extern IMRT_Status SDM_SQL_Dump_Cnv_Header(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Cnv_Body(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Cnv_Footer(FILE *dump_file); +extern IMRT_Status SDM_SQL_Dump_Cnv(void); + +# endif + + + + + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libstatic_data_mng/src/struct_info_sql.pc b/src/libstatic_data_mng/src/struct_info_sql.pc new file mode 100644 index 0000000..efb33d6 --- /dev/null +++ b/src/libstatic_data_mng/src/struct_info_sql.pc @@ -0,0 +1,825 @@ +/*----------------------------------------------------------------------------*/ +/* File: struct_info_sql.pc */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _STRUCT_INFO_SQL_PC_ + +#include "struct_info_sql.h" + + +IMRT_Status SDM_SQL_StructInfo_Init(void) +{ + IMRT_Status status, StatusTmp; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading Cnv..."); + status = SDM_SQL_Load_Cnv(&(IMRG_SDM_Base.RootCnv)); + if(status == IMRS_OK) + { + IMRD_LM_LOG_INFO_1( "Cnv loaded: (%d)", IMRG_SDM_Base.RootCnv->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading Msg and Field..."); + status = SDM_SQL_Load_MsgAndField(&(IMRG_SDM_Base.RootMsg)); + + if(status == IMRS_OK) + { + IMRD_LM_LOG_INFO_1( "Msg and Field loaded: (%d)", IMRG_SDM_Base.RootMsg->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't load Msg and Field !"); + StatusTmp = SDM_Close_RootCnv(); + } + + } + else + { + IMRD_LM_LOG_ERROR_0( "Can't load Cnv !"); + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Load_Cnv(NDT_Root **myRootCnv_Ptr_Ptr) +{ + const char sFunctionName []="SDM_SQL_Load_Cnv"; + NDT_Status nd_status; + IMRT_Status status; + NDT_Index_Type *index_type_ptr; + IMRT_Cnv *myCnv_Ptr; + IMRT_Data_Version *Data_Version_Ptr; + + EXEC SQL BEGIN DECLARE SECTION; + IMRT_Cnv_Id hCnvId; + VARCHAR vCnvName[IMRD_CNV_NAME_SIZE]; + short hIndCnvId; + short hIndCnvName; + EXEC SQL END DECLARE SECTION; + + /*initialisation des indexes*/ + index_type_ptr = Cnv_Struct_initial_idx_tab; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + status = SDM_SQL_Set_Struct_Version(Data_Version_Ptr, "Cnv"); + if (status != IMRS_OK) + { + return(IMRS_KO); + } + + nd_status = ND_DataStruct_Open(myRootCnv_Ptr_Ptr, IMRD_SDMD_CNV_STRUCT_IDX_NB,index_type_ptr, "SDM_Cnv_Manager",SDM_Cnv_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Open -- SDM_Cnv_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + EXEC SQL DECLARE cur_imr_cnv_hdr CURSOR FOR + SELECT CNV_ID, CNV_NAME + FROM IMR_CNV; + + EXEC SQL OPEN cur_imr_cnv_hdr; + do + { + memset(vCnvName.arr, '\0', (size_t) IMRD_CNV_NAME_SIZE); + + EXEC SQL FETCH cur_imr_cnv_hdr + INTO :hCnvId:hIndCnvId, + :vCnvName:hIndCnvName; + + if (sqlca.sqlcode == 0) + { + /* création d'un nouvelle objet CNV */ + nd_status = ND_Value_Alloc( *myRootCnv_Ptr_Ptr, (void **)&(myCnv_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- SDM_Cnv_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + /* Ajout de l'objet CNV */ + myCnv_Ptr->Id = hCnvId; + strcpy(myCnv_Ptr->Name, (char *) vCnvName.arr); + + nd_status = ND_DataStruct_Value_Add( *myRootCnv_Ptr_Ptr, (void *)(myCnv_Ptr)); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Value_Add -- SDM_Cnv_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_cnv_hdr; + + if(status == IMRS_OK) + { + index_type_ptr = Cnv_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(*myRootCnv_Ptr_Ptr, index_type_ptr, IMRD_SDMD_CNV_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump(*myRootCnv_Ptr_Ptr);*/ + } + else + { + nd_status = ND_DataStruct_Close(*myRootCnv_Ptr_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + } + } + + } + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Load_MsgAndField(NDT_Root **myRootMessage_Ptr_Ptr) +{ + const char sFunctionName []="SDM_SQL_Load_MsgAndField"; + NDT_Status nd_status; + IMRT_Status status; + NDT_Index_Type *index_type_ptr; + IMRT_Msg *myMsg_Ptr; + IMRT_Data_Version *Data_Version_Ptr; + + EXEC SQL BEGIN DECLARE SECTION; + IMRT_Msg_Id hMsgId; + VARCHAR vMsgName[IMRD_NAME_SIZE]; + short hMsgSize; + short hIndMsgId; + short hIndMsgName; + short hIndMsgSize; + EXEC SQL END DECLARE SECTION; + + /*initialisation des indexes*/ + index_type_ptr = Msg_Struct_initial_idx_tab; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + status = SDM_SQL_Set_Struct_Version(Data_Version_Ptr, "Msg-Field"); + if (status != IMRS_OK) + { + return(IMRS_KO); + } + + nd_status = ND_DataStruct_Open(myRootMessage_Ptr_Ptr, IMRD_SDMD_MSG_STRUCT_IDX_NB, index_type_ptr, "SDM_Msg_Manager",SDM_Msg_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr); + if (nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Open -- SDM_Msg_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + EXEC SQL DECLARE cur_imr_msg CURSOR FOR + SELECT MSG_ID, MSG_NAME, MSG_SIZE + FROM IMR_MSG; + + EXEC SQL OPEN cur_imr_msg; + do + { + memset(vMsgName.arr, '\0', (size_t) IMRD_NAME_SIZE); + EXEC SQL FETCH cur_imr_msg + INTO :hMsgId:hIndMsgId, + :vMsgName:hIndMsgName, + :hMsgSize:hIndMsgSize; + if (sqlca.sqlcode == 0) + { + nd_status = ND_Value_Alloc( *myRootMessage_Ptr_Ptr, (void **)&(myMsg_Ptr)); + if (nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- SDM_Msg_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + myMsg_Ptr->Id = hMsgId; + if (hIndMsgName >= 0) + strcpy(myMsg_Ptr->Name, (char *) vMsgName.arr); + if (hIndMsgSize >= 0) + myMsg_Ptr->Size = hMsgSize; + + status = SDM_SQL_LoadFieldMsg(myMsg_Ptr); + if (status == IMRS_OK) + { + /* Ajout du message */ + nd_status = ND_DataStruct_Value_Add( *myRootMessage_Ptr_Ptr, (void *)(myMsg_Ptr)); + if (nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Value_Add -- SDM_Msg_Manager failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_msg; + + if(status == IMRS_OK) + { + index_type_ptr = Msg_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(*myRootMessage_Ptr_Ptr, index_type_ptr, IMRD_SDMD_MSG_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump( *myRootMessage_Ptr_Ptr);*/ + } + else + { + if(myMsg_Ptr->Field_Struct_Ptr != NULL) + { + nd_status = ND_DataStruct_Close(myMsg_Ptr->Field_Struct_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + } + } + + nd_status = ND_DataStruct_Close(*myRootMessage_Ptr_Ptr); + if(nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_DataStruct_Close() failed (%d) !", nd_status); + } + } + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_LoadFieldMsg(IMRT_Msg *myMsg_Ptr) +{ + const char sFunctionName []="SDM_SQL_LoadFieldMsg"; + NDT_Status nd_status; + IMRT_Status status; + IMRT_Field *myField_Ptr; + NDT_Node *node_ptr; + IMRT_Cnv myCnv; + + EXEC SQL BEGIN DECLARE SECTION; + IMRT_Field_Id hFieldId; + VARCHAR vFieldName[IMRD_NAME_SIZE]; + VARCHAR vFieldValueid[IMRD_VALUE_ID_SIZE]; + VARCHAR vFieldExist[IMRD_EXIST_SIZE]; + long hFieldFixedOffset; + long hFieldFixedSize; + VARCHAR vFieldFixedDefVal[IMRD_VALUE_SIZE]; + IMRT_Cnv_Id hFieldFixedCnvId; + VARCHAR vFieldFixedCnvAttr[IMRD_CNV_ATTR_SIZE]; + VARCHAR vFieldFmlTag[IMRD_FML_TAG_SIZE]; + VARCHAR vFieldFmlDefVal[IMRD_VALUE_SIZE]; + IMRT_Cnv_Id hFieldFmlCnvId; + VARCHAR vFieldFmlCnvAttr[IMRD_CNV_ATTR_SIZE]; + VARCHAR vFieldXmlTag[IMRD_XML_TAG_SIZE]; + VARCHAR vFieldXmlDefVal[IMRD_VALUE_SIZE]; + IMRT_Cnv_Id hFieldXmlCnvId; + VARCHAR vFieldXmlCnvAttr[IMRD_CNV_ATTR_SIZE]; + VARCHAR vFieldTaggedTag[IMRD_TAGGED_TAG_SIZE]; + VARCHAR vFieldTaggedDefVal[IMRD_VALUE_SIZE]; + IMRT_Cnv_Id hFieldTaggedCnvId; + VARCHAR vFieldTaggedCnvAttr[IMRD_CNV_ATTR_SIZE]; + VARCHAR vFieldInternalTag[IMRD_INTERNAL_TAG_SIZE]; + VARCHAR vFieldInternalDefVal[IMRD_VALUE_SIZE]; + IMRT_Cnv_Id hFieldInternalCnvId; + VARCHAR vFieldInternalCnvAttr[IMRD_CNV_ATTR_SIZE]; + IMRT_Delimited_Id hFieldDelimitedId; + VARCHAR vFieldDelimitedDefVal[IMRD_VALUE_SIZE]; + IMRT_Cnv_Id hFieldDelimitedCnvId; + VARCHAR vFieldDelimitedCnvAttr[IMRD_CNV_ATTR_SIZE]; + + short hIndFieldId; + short hIndFieldName; + short hIndFieldValueid; + short hIndFieldExist; + short hIndFieldFixedOffset; + short hIndFieldFixedSize; + short hIndFieldFixedDefVal; + short hIndFieldFixedCnvId; + short hIndFieldFixedCnvAttr; + short hIndFieldFmlTag; + short hIndFieldFmlDefVal; + short hIndFieldFmlCnvId; + short hIndFieldFmlCnvAttr; + short hIndFieldXmlTag; + short hIndFieldXmlDefVal; + short hIndFieldXmlCnvId; + short hIndFieldXmlCnvAttr; + short hIndFieldTaggedTag; + short hIndFieldTaggedDefVal; + short hIndFieldTaggedCnvId; + short hIndFieldTaggedCnvAttr; + short hIndFieldInternalTag; + short hIndFieldInternalDefVal; + short hIndFieldInternalCnvId; + short hIndFieldInternalCnvAttr; + short hIndFieldDelimitedId; + short hIndFieldDelimitedDefVal; + short hIndFieldDelimitedCnvId; + short hIndFieldDelimitedCnvAttr; + EXEC SQL END DECLARE SECTION; + + status = IMRS_OK; + + EXEC SQL DECLARE cur_imr_field CURSOR FOR + SELECT IMR_FIELD.FIELD_ID, + IMR_FIELD.FIELD_NAME, + IMR_FIELD.FIELD_VALUEID, + IMR_FIELD.FIELD_EXIST, + IMR_FIXEDFIELD.FIXED_FIELD_OFFSET, + IMR_FIXEDFIELD.FIXED_FIELD_SIZE, + IMR_FIXEDFIELD.FIXED_FIELD_CNV_ID, + IMR_FIXEDFIELD.FIXED_FIELD_CNV_ATTR, + IMR_FIXEDFIELD.FIXED_FIELD_DEF_VAL, + IMR_FMLFIELD.FML_FIELD_TAG, + IMR_FMLFIELD.FML_FIELD_CNV_ID, + IMR_FMLFIELD.FML_FIELD_CNV_ATTR, + IMR_FMLFIELD.FML_FIELD_DEF_VAL, + IMR_XMLFIELD.XML_FIELD_TAG, + IMR_XMLFIELD.XML_FIELD_CNV_ID, + IMR_XMLFIELD.XML_FIELD_CNV_ATTR, + IMR_XMLFIELD.XML_FIELD_DEF_VAL, + IMR_TAGGEDFIELD.TAGGED_FIELD_TAG, + IMR_TAGGEDFIELD.TAGGED_FIELD_CNV_ID, + IMR_TAGGEDFIELD.TAGGED_FIELD_CNV_ATTR, + IMR_TAGGEDFIELD.TAGGED_FIELD_DEF_VAL, + IMR_INTERNALFIELD.INTERNAL_FIELD_TAG, + IMR_INTERNALFIELD.INTERNAL_FIELD_CNV_ID, + IMR_INTERNALFIELD.INTERNAL_FIELD_CNV_ATTR, + IMR_INTERNALFIELD.INTERNAL_FIELD_DEF_VAL, + IMR_DELIMITEDFIELD.DELIMITED_FIELD_ID, + IMR_DELIMITEDFIELD.DELIMITED_FIELD_CNV_ID, + IMR_DELIMITEDFIELD.DELIMITED_FIELD_CNV_ATTR, + IMR_DELIMITEDFIELD.DELIMITED_FIELD_DEF_VAL + FROM IMR_FIELD, IMR_FIXEDFIELD, IMR_FMLFIELD, IMR_XMLFIELD, + IMR_TAGGEDFIELD, IMR_INTERNALFIELD, IMR_DELIMITEDFIELD + WHERE IMR_FIELD.FIELD_ID = IMR_FIXEDFIELD.FIELD_ID(+) + AND IMR_FIELD.FIELD_ID = IMR_FMLFIELD.FIELD_ID(+) + AND IMR_FIELD.FIELD_ID = IMR_XMLFIELD.FIELD_ID(+) + AND IMR_FIELD.FIELD_ID = IMR_TAGGEDFIELD.FIELD_ID(+) + AND IMR_FIELD.FIELD_ID = IMR_INTERNALFIELD.FIELD_ID(+) + AND IMR_FIELD.FIELD_ID = IMR_DELIMITEDFIELD.FIELD_ID(+) + AND IMR_FIELD.MSG_ID = :myMsg_Ptr->Id; + + EXEC SQL OPEN cur_imr_field; + do + { + memset(vFieldName.arr, '\0', (size_t) IMRD_NAME_SIZE); + memset(vFieldValueid.arr, '\0', (size_t) IMRD_VALUE_ID_SIZE); + memset(vFieldExist.arr, '\0', (size_t) IMRD_EXIST_SIZE); + memset(vFieldFixedDefVal.arr, '\0', (size_t) IMRD_VALUE_SIZE); + memset(vFieldFixedCnvAttr.arr, '\0', (size_t) IMRD_CNV_ATTR_SIZE); + memset(vFieldFmlTag.arr, '\0', (size_t) IMRD_FML_TAG_SIZE); + memset(vFieldFmlDefVal.arr, '\0', (size_t) IMRD_VALUE_SIZE); + memset(vFieldFmlCnvAttr.arr, '\0', (size_t) IMRD_CNV_ATTR_SIZE); + memset(vFieldXmlTag.arr, '\0', (size_t) IMRD_XML_TAG_SIZE); + memset(vFieldXmlDefVal.arr, '\0', (size_t) IMRD_VALUE_SIZE); + memset(vFieldXmlCnvAttr.arr, '\0', (size_t) IMRD_CNV_ATTR_SIZE); + memset(vFieldTaggedTag.arr, '\0', (size_t) IMRD_TAGGED_TAG_SIZE); + memset(vFieldTaggedDefVal.arr, '\0', (size_t) IMRD_VALUE_SIZE); + memset(vFieldTaggedCnvAttr.arr, '\0', (size_t) IMRD_CNV_ATTR_SIZE); + memset(vFieldInternalTag.arr, '\0', (size_t) IMRD_INTERNAL_TAG_SIZE); + memset(vFieldInternalDefVal.arr, '\0', (size_t) IMRD_VALUE_SIZE); + memset(vFieldInternalCnvAttr.arr, '\0', (size_t) IMRD_CNV_ATTR_SIZE); + memset(vFieldDelimitedDefVal.arr, '\0', (size_t) IMRD_VALUE_SIZE); + memset(vFieldDelimitedCnvAttr.arr, '\0', (size_t) IMRD_CNV_ATTR_SIZE); + + EXEC SQL FETCH cur_imr_field + INTO :hFieldId:hIndFieldId, + :vFieldName:hIndFieldName, + :vFieldValueid:hIndFieldValueid, + :vFieldExist:hIndFieldExist, + :hFieldFixedOffset:hIndFieldFixedOffset, + :hFieldFixedSize:hIndFieldFixedSize, + :hFieldFixedCnvId:hIndFieldFixedCnvId, + :vFieldFixedCnvAttr:hIndFieldFixedCnvAttr, + :vFieldFixedDefVal:hIndFieldFixedDefVal, + :vFieldFmlTag:hIndFieldFmlTag, + :hFieldFmlCnvId:hIndFieldFmlCnvId, + :vFieldFmlCnvAttr:hIndFieldFmlCnvAttr, + :vFieldFmlDefVal:hIndFieldFmlDefVal, + :vFieldXmlTag:hIndFieldXmlTag, + :hFieldXmlCnvId:hIndFieldXmlCnvId, + :vFieldXmlCnvAttr:hIndFieldXmlCnvAttr, + :vFieldXmlDefVal:hIndFieldXmlDefVal, + :vFieldTaggedTag:hIndFieldTaggedTag, + :hFieldTaggedCnvId:hIndFieldTaggedCnvId, + :vFieldTaggedCnvAttr:hIndFieldTaggedCnvAttr, + :vFieldTaggedDefVal:hIndFieldTaggedDefVal, + :vFieldInternalTag:hIndFieldInternalTag, + :hFieldInternalCnvId:hIndFieldInternalCnvId, + :vFieldInternalCnvAttr:hIndFieldInternalCnvAttr, + :vFieldInternalDefVal:hIndFieldInternalDefVal, + :hFieldDelimitedId:hIndFieldDelimitedId, + :hFieldDelimitedCnvId:hIndFieldDelimitedCnvId, + :vFieldDelimitedCnvAttr:hIndFieldDelimitedCnvAttr, + :vFieldDelimitedDefVal:hIndFieldDelimitedDefVal; + + if (sqlca.sqlcode == 0) + { + /* Allacation de ListField */ + nd_status = ND_Value_Alloc( myMsg_Ptr->Field_Struct_Ptr, (void **)&(myField_Ptr)); + if (nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_Value_Alloc -- Field failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + else + { + /* Ajout du Field */ + myField_Ptr->Id = hFieldId; + strcpy(myField_Ptr->Name, (char *) vFieldName.arr); + if (hIndFieldValueid >= 0) + strcpy(myField_Ptr->Value_Id, (char *) vFieldValueid.arr); + if (hIndFieldExist >= 0) + { + if(vFieldExist.arr[0] == IMRD_YES) + { + myField_Ptr->Exist = IMRD_TRUE; + } + else + { + myField_Ptr->Exist = IMRD_FALSE; + } + } + + if (hIndFieldFixedOffset >= 0) + myField_Ptr->Fixed.Offset = hFieldFixedOffset; + if (hIndFieldFixedSize >= 0) + myField_Ptr->Fixed.Size = hFieldFixedSize; + if (hIndFieldFixedDefVal >= 0) + strcpy(myField_Ptr->Fixed.Def_Val, (char *) vFieldFixedDefVal.arr); + if (hIndFieldFixedCnvId >= 0) + { + myCnv.Id = hFieldFixedCnvId; + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootCnv, + IMRD_SDMD_CNV_IDX_ID, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche de Cnv <%d> !", myCnv.Id); + status = IMRS_KO; + } + else + { + myField_Ptr->Fixed.Cnv_Ptr = node_ptr->Value; + } + } + + if (hIndFieldFixedCnvAttr >= 0) + strcpy(myField_Ptr->Fixed.Cnv_Attr, (char *) vFieldFixedCnvAttr.arr); + + if (hIndFieldFmlTag >= 0) + strcpy(myField_Ptr->FML.Tag, (char *) vFieldFmlTag.arr); + if (hIndFieldFmlDefVal >= 0) + strcpy(myField_Ptr->FML.Def_Val, (char *) vFieldFmlDefVal.arr); + if (hIndFieldFmlCnvId >= 0) + { + myCnv.Id = hFieldFmlCnvId; + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootCnv, + IMRD_SDMD_CNV_IDX_ID, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche de Cnv <%d> !", myCnv.Id); + status = IMRS_KO; + } + else + { + myField_Ptr->FML.Cnv_Ptr = node_ptr->Value; + } + } + if (hIndFieldFmlCnvAttr >= 0) + strcpy(myField_Ptr->FML.Cnv_Attr, (char *) vFieldFmlCnvAttr.arr); + + if (hIndFieldXmlTag >= 0) + strcpy(myField_Ptr->XML.Tag, (char *) vFieldXmlTag.arr); + if (hIndFieldXmlDefVal >= 0) + strcpy(myField_Ptr->XML.Def_Val, (char *) vFieldXmlDefVal.arr); + if (hIndFieldXmlCnvId >= 0) + { + myCnv.Id = hFieldXmlCnvId; + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootCnv, + IMRD_SDMD_CNV_IDX_ID, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche de Cnv <%d> !", myCnv.Id); + status = IMRS_KO; + } + else + { + myField_Ptr->XML.Cnv_Ptr = node_ptr->Value; + } + } + if (hIndFieldXmlCnvAttr >= 0) + strcpy(myField_Ptr->XML.Cnv_Attr, (char *) vFieldXmlCnvAttr.arr); + + if (hIndFieldTaggedTag >= 0) + strcpy(myField_Ptr->Tagged.Tag, (char *) vFieldTaggedTag.arr); + if (hIndFieldTaggedDefVal >= 0) + strcpy(myField_Ptr->Tagged.Def_Val, (char *) vFieldTaggedDefVal.arr); + if (hIndFieldTaggedCnvId >= 0) + { + myCnv.Id = hFieldTaggedCnvId; + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootCnv, + IMRD_SDMD_CNV_IDX_ID, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche de Cnv <%d> !", myCnv.Id); + status = IMRS_KO; + } + else + { + myField_Ptr->Tagged.Cnv_Ptr = node_ptr->Value; + } + } + if (hIndFieldTaggedCnvAttr >= 0) + strcpy(myField_Ptr->Tagged.Cnv_Attr, (char *) vFieldTaggedCnvAttr.arr); + + if (hIndFieldInternalTag >= 0) + strcpy(myField_Ptr->Internal.Tag, (char *) vFieldInternalTag.arr); + if (hIndFieldInternalDefVal >= 0) + strcpy(myField_Ptr->Internal.Def_Val, (char *) vFieldInternalDefVal.arr); + if (hIndFieldInternalCnvId >= 0) + { + myCnv.Id = hFieldInternalCnvId; + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootCnv, + IMRD_SDMD_CNV_IDX_ID, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche de Cnv <%d> !", myCnv.Id); + status = IMRS_KO; + } + else + { + myField_Ptr->Internal.Cnv_Ptr = node_ptr->Value; + } + } + if (hIndFieldInternalCnvAttr >= 0) + strcpy(myField_Ptr->Internal.Cnv_Attr, (char *) vFieldInternalCnvAttr.arr); + + if (hIndFieldDelimitedId >= 0) + myField_Ptr->Delimited.Id = hFieldDelimitedId; + if (hIndFieldDelimitedDefVal >= 0) + strcpy(myField_Ptr->Delimited.Def_Val, (char *) vFieldDelimitedDefVal.arr); + if (hIndFieldDelimitedCnvId >= 0) + { + myCnv.Id = hFieldDelimitedCnvId; + if(((nd_status = ND_Index_Node_Find( &node_ptr, IMRG_SDM_Base.RootCnv, + IMRD_SDMD_CNV_IDX_ID, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + IMRD_LM_LOG_ERROR_1( "Erreur lors de la recherche de Cnv <%d> !", myCnv.Id); + status = IMRS_KO; + } + else + { + myField_Ptr->Delimited.Cnv_Ptr = node_ptr->Value; + } + } + if (hIndFieldDelimitedCnvAttr >= 0) + strcpy(myField_Ptr->Delimited.Cnv_Attr, (char *) vFieldDelimitedCnvAttr.arr); + + nd_status = ND_DataStruct_Value_Add( myMsg_Ptr->Field_Struct_Ptr, (void *)(myField_Ptr)); + if (nd_status != NDS_OK) + { + IMRD_LM_LOG_ERROR_2( "%s : ND_DataStruct_Value_Add -- Field failed (%d) !", sFunctionName, nd_status); + status = IMRS_KO; + } + } + } + } while((sqlca.sqlcode == 0)&&(nd_status == NDS_OK)&&(status == IMRS_OK)); + + if(status != IMRS_OK) + { + free(myField_Ptr); + } + + if (sqlca.sqlcode < 0) + { + IMRD_LM_LOG_ERROR_3( "Erreur %s. Erreur Oracle : %d - %s !", sFunctionName, sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); + status = IMRS_KO; + } + + EXEC SQL CLOSE cur_imr_field; + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Msg_Header(FILE *dump_file) +{ + fprintf(dump_file, "---------------------------------------------------------\n"); + fprintf(dump_file, "-- Init file of IMR_MSG & IMR_FIELD & IMR_FMLFIELD --\n"); + fprintf(dump_file, "-- IMR_XMLFIELD & IMR_DELIMITEDFIELD --\n"); + fprintf(dump_file, "-- IMR_FIXEDFIELD & IMR_TAGGEDFIELD --\n"); + fprintf(dump_file, "-- IMR_INTERNALFIELD --\n"); + fprintf(dump_file, "---------------------------------------------------------\n\n"); + fprintf(dump_file, "INSERT INTO IMR_DATA_VERSION(VERS_NAME, VERS_LABEL, VERS_DATE) VALUES('Msg-Field', '%s', '%s');\n\n", + ((IMRT_Data_Version *)IMRG_SDM_Base.RootMsg->User_Ptr)->Label, + ((IMRT_Data_Version *)IMRG_SDM_Base.RootMsg->User_Ptr)->Date); + fprintf(dump_file, "Delete IMR_INTERNALFIELD;\n\n"); + fprintf(dump_file, "Delete IMR_TAGGEDFIELD;\n\n"); + fprintf(dump_file, "Delete IMR_FIXEDFIELD;\n\n"); + fprintf(dump_file, "Delete IMR_DELIMITEDFIELD;\n\n"); + fprintf(dump_file, "Delete IMR_XMLFIELD;\n\n"); + fprintf(dump_file, "Delete IMR_FMLFIELD;\n\n"); + fprintf(dump_file, "Delete IMR_FIELD;\n\n"); + fprintf(dump_file, "Delete IMR_MSG;\n\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Msg_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootMsg, IMRD_SDMD_CMD_API_SQL_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0( "SQL Dump RootMsg failed !"); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Msg_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\nCommit;\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Msg(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, "init_imr_msg.sql"); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_SQL_Dump_Msg_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_Msg_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_Msg_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Cnv_Header(FILE *dump_file) +{ + fprintf(dump_file, "---------------------------------------------------\n"); + fprintf(dump_file, "-- Init file of IMR_CNV --\n"); + fprintf(dump_file, "---------------------------------------------------\n\n"); + fprintf(dump_file, "INSERT INTO IMR_DATA_VERSION(VERS_NAME, VERS_LABEL, VERS_DATE) VALUES('Cnv', '%s', '%s');\n\n", + ((IMRT_Data_Version *)IMRG_SDM_Base.RootCnv->User_Ptr)->Label, + ((IMRT_Data_Version *)IMRG_SDM_Base.RootCnv->User_Ptr)->Date); + fprintf(dump_file, "Delete IMR_CNV;\n\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Cnv_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootCnv, IMRD_SDMD_CMD_API_SQL_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_0( "SQL Dump RootCnv failed !"); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Cnv_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\nCommit;\n"); + return( IMRS_OK); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_Dump_Cnv(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, "init_imr_cnv.sql"); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + IMRD_LM_LOG_ERROR_1( "Can't open dump file (%s) !", dump_filename); + } + else + { + status = SDM_SQL_Dump_Cnv_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_Cnv_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_Cnv_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_SQL_StructInfo_Dump(void) +{ + IMRT_Status status; + + status = SDM_SQL_Dump_Cnv(); + if(status == IMRS_OK) + { + status = SDM_SQL_Dump_Msg(); + } + + return(status); + +} + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ diff --git a/src/libstatic_data_mng/src/struct_info_xml.c b/src/libstatic_data_mng/src/struct_info_xml.c new file mode 100644 index 0000000..7c4fb87 --- /dev/null +++ b/src/libstatic_data_mng/src/struct_info_xml.c @@ -0,0 +1,943 @@ +/*----------------------------------------------------------------------------*/ +/* File: struct_info_xml.c */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#define _LIBSTATIC_DATA_MNG_ +#define _STRUCT_INFO_XML_C_ + +#include "struct_info_xml.h" + + +IMRT_Status SDM_XML_StructInfo_Init(IMRT_Path Lib_Path) +{ + SDMT_StructInfo_Contexte StructInfo_Ctx; + IMRT_Status status, StatusTmp; + char Xml_File_Name[255]; + + StructInfo_Ctx.flagerror = 0; + StructInfo_Ctx.CptCnv = IMRD_CNV_ID_UNKNOWN; + + + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading Cnv..."); + + memset(Xml_File_Name,0,sizeof(Xml_File_Name)); + strcpy(Xml_File_Name, Lib_Path); + strcat(Xml_File_Name, "/"); + strcat(Xml_File_Name, SDMD_CNV_FILE); + status = SDM_XML_Load_Cnv((char *)Xml_File_Name, &(StructInfo_Ctx)); + if(status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't load Cnv !"); + } + else + { + IMRG_SDM_Base.RootCnv = StructInfo_Ctx.RootCnv; + + IMRD_LM_LOG_INFO_1( "Cnv loaded: (%d)", IMRG_SDM_Base.RootCnv->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + + StructInfo_Ctx.CptMsg = IMRD_MSG_ID_UNKNOWN; + StructInfo_Ctx.CptField = IMRD_FIELD_ID_UNKNOWN; + memset(StructInfo_Ctx.PathArray,0,sizeof(StructInfo_Ctx.PathArray)); + StructInfo_Ctx.PresentLevelTag = IMRD_SDMD_MIN_LEVEL_TAG; + + IMRD_LM_LOG_TRACE_0( IMRD_LOG_LEVEL_VERBOSE_0, "Loading Msg and Field..."); + + memset(Xml_File_Name,0,sizeof(Xml_File_Name)); + strcpy(Xml_File_Name, Lib_Path); + strcat(Xml_File_Name, "/"); + strcat(Xml_File_Name, SDMD_MSGFIELD_FILE); + + status = SDM_XML_Load_MsgAndField((char *)Xml_File_Name, &(StructInfo_Ctx)); + + if(status != IMRS_OK) + { + IMRD_LM_LOG_ERROR_0( "Can't load Msg and Field !"); + StatusTmp = SDM_Close_RootCnv(); + } + else + { + IMRG_SDM_Base.RootMsg = StructInfo_Ctx.RootMessage; + + IMRD_LM_LOG_INFO_1( "Msg and Field loaded: (%d)", IMRG_SDM_Base.RootMsg->Index_Tab[NDD_INDEX_PRIMARY].Node_Number); + } + } + + return(status); + +} + + +static IMRT_Status error(SDMT_StructInfo_Contexte *ctx , const char *msg, ...) +{ + xmlParserCtxt * SaxCtx; + + SaxCtx = ctx->SaxCtxHdl; + + IMRD_LM_LOG_ERROR_1( "CallBack error: <%s> !",msg); + + SaxCtx->sax = &ErrorSAXHandlerStruct; + ctx->flagerror = 1; + ctx->FataError.errorCode = SDMD_XML_CODE_ERROR_1; + strcpy(ctx->FataError.libError,msg) ; +} + + +IMRT_Status startElementNsCnv( SDMT_StructInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes) +{ + NDT_Status status; + + if(strcmp((const char*)localname,IMRD_SDMD_TAG_CNV) == 0) + { + /*création d'un nouvelle objet Cnv*/ + if( ( status = ND_Value_Alloc( ctx->RootCnv, (void **)&(ctx->CurrentCnv)) != NDS_OK)) + { + IMRD_LM_LOG_ERROR_1( "ND_Value_Alloc() failed (%d) !", status); + } + } + +} + + +IMRT_Status startElementNS( SDMT_StructInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes) +{ + NDT_Status status; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + const char fonctionname [] = "startElementNS"; + + + if(strcmp((const char *)localname, IMRD_SDMD_TAG_MESSAGE) == 0) + { + /*création d'un objet msg*/ + if( ( status = ND_Value_Alloc( ctx->RootMessage, (void **)&(ctx->CurrentMessage))) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_3,IMRD_SDMD_TAG_MESSAGE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr,SDMD_XML_CODE_ERROR_3); + } + + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_FIELD) == 0) + { + if( ( status = ND_Value_Alloc( ctx->CurrentMessage->Field_Struct_Ptr, (void **)&(ctx->CurrentField))) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_3,IMRD_SDMD_TAG_MESSAGE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_3 ); + } + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + else if ((strcmp((const char *)localname, IMRD_SDMD_TAG_FIXED) == 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_INTERNE) == 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_TAGGED) == 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_XML) == 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_DELIMITED)== 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_FML) == 0) + ) + { + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_CNV) == 0) + { + ctx->PresentLevelTag = ctx->PresentLevelTag + 1; + strcpy(ctx->PathArray[ctx->PresentLevelTag], (char*)localname); + } + +} + + +IMRT_Status endElementNsCnv( SDMT_StructInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI) +{ + IMRT_Status status_tmp; + NDT_Status status; + const char fonctionname [] ="endElementNsCnv"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + + if(strcmp((const char*)localname, IMRD_SDMD_TAG_CNV) == 0) + { + ctx->CurrentCnv->Id = ctx->CptCnv; + if( ( status = ND_DataStruct_Value_Add( ctx->RootCnv, (void *)(ctx->CurrentCnv))) != NDS_OK) + { + IMRD_LM_LOG_ERROR_1( "ND_Value_Alloc() failed (%d) !", status); + + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_3,IMRD_SDMD_TAG_CNV); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_3 ); + } + ctx->CptCnv ++; + } + + if(strcmp((const char*)localname, IMRD_SDMD_TAG_NAME) == 0) + { + strcpy(ctx->CurrentCnv->Name, ctx->value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_VERSION) == 0) + { + IMRD_LM_LOG_INFO_1( "[Cnv]: [%s]", ctx->value); + status_tmp = SDM_Set_Struct_Version((IMRT_Data_Version *)ctx->RootCnv->User_Ptr, (char *)ctx->value); + } +} + + +IMRT_Status endElementNS( SDMT_StructInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI) +{ + IMRT_Status status_tmp; + NDT_Status status; + xmlParserCtxt * SaxCtx; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + const char fonctionname [] = "endElementNS"; + NDT_Node *node_ptr; + IMRT_Cnv myCnv; + NDT_Status nd_status; + NDT_Index_Type *index_type_ptr; + + if (strcmp((const char *)localname, IMRD_SDMD_TAG_NAME) == 0) + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_0: + { + strcpy(ctx->CurrentMessage->Name, ctx->value); + break; + } + case IMRD_SDMD_LEVEL_TAG_1: + { + strcpy(ctx->CurrentField->Name, ctx->value); + break; + } + case IMRD_SDMD_LEVEL_TAG_2: + { + if(strcmp(ctx->PathArray[ctx->PresentLevelTag], IMRD_SDMD_TAG_INTERNE) == 0) + { + strcpy(ctx->CurrentField->Internal.Tag, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag], IMRD_SDMD_TAG_TAGGED) == 0) + { + strcpy(ctx->CurrentField->Tagged.Tag, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag], IMRD_SDMD_TAG_XML) == 0) + { + strcpy(ctx->CurrentField->XML.Tag, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag], IMRD_SDMD_TAG_FML) == 0) + { + strcpy(ctx->CurrentField->FML.Tag, ctx->value); + } + + break; + } + case IMRD_SDMD_LEVEL_TAG_3: + { + if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_FIXED) == 0) + { + strcpy(myCnv.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, ctx->RootCnv, + IMRD_SDMD_CNV_IDX_NAME, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_CNV, myCnv.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentField->Fixed.Cnv_Ptr = node_ptr->Value; + } + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_INTERNE) == 0) + { + strcpy(myCnv.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, ctx->RootCnv, + IMRD_SDMD_CNV_IDX_NAME, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_CNV, myCnv.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentField->Internal.Cnv_Ptr = node_ptr->Value; + } + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_TAGGED) == 0) + { + strcpy(myCnv.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, ctx->RootCnv, + IMRD_SDMD_CNV_IDX_NAME, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_CNV, myCnv.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentField->Tagged.Cnv_Ptr = node_ptr->Value; + } + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_XML) == 0) + { + strcpy(myCnv.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, ctx->RootCnv, + IMRD_SDMD_CNV_IDX_NAME, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_CNV, myCnv.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentField->XML.Cnv_Ptr = node_ptr->Value; + } + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_FML) == 0) + { + strcpy(myCnv.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, ctx->RootCnv, + IMRD_SDMD_CNV_IDX_NAME, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_CNV, myCnv.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentField->FML.Cnv_Ptr = node_ptr->Value; + } + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_DELIMITED) == 0) + { + strcpy(myCnv.Name, ctx->value); + if(((nd_status = ND_Index_Node_Find( &node_ptr, ctx->RootCnv, + IMRD_SDMD_CNV_IDX_NAME, &myCnv, NULL)) != NDS_OK)|| + (node_ptr == NULL)) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_4,IMRD_SDMD_TAG_CNV, myCnv.Name ); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_4 ); + } + else + { + ctx->CurrentField->Delimited.Cnv_Ptr = node_ptr->Value; + } + } + + break; + } + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_MSGFIELD_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_SIZE) == 0) + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_0: + { + ctx->CurrentMessage->Size = atoi(ctx->value); + break; + } + case IMRD_SDMD_LEVEL_TAG_2: + { + ctx->CurrentField->Fixed.Size = atoi(ctx->value); + break; + } + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_MSGFIELD_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_ATTRIBUTE) == 0) + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_3: + { + if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_FIXED) == 0) + { + strcpy(ctx->CurrentField->Fixed.Cnv_Attr, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_INTERNE) == 0) + { + strcpy(ctx->CurrentField->Internal.Cnv_Attr, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_TAGGED) == 0) + { + strcpy(ctx->CurrentField->Tagged.Cnv_Attr, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_XML) == 0) + { + strcpy(ctx->CurrentField->XML.Cnv_Attr, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_FML) == 0) + { + strcpy(ctx->CurrentField->FML.Cnv_Attr, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag-1], IMRD_SDMD_TAG_DELIMITED) == 0) + { + strcpy(ctx->CurrentField->Delimited.Cnv_Attr, ctx->value); + } + + break; + } + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_MSGFIELD_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_DEFVAL) == 0) + { + switch(ctx->PresentLevelTag) + { + case IMRD_SDMD_LEVEL_TAG_2: + { + if(strcmp(ctx->PathArray[ctx->PresentLevelTag], IMRD_SDMD_TAG_FIXED) == 0) + { + strcpy(ctx->CurrentField->Fixed.Def_Val, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag], IMRD_SDMD_TAG_INTERNE) == 0) + { + strcpy(ctx->CurrentField->Internal.Def_Val, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag], IMRD_SDMD_TAG_TAGGED) == 0) + { + strcpy(ctx->CurrentField->Tagged.Def_Val, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag], IMRD_SDMD_TAG_XML) == 0) + { + strcpy(ctx->CurrentField->XML.Def_Val, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag], IMRD_SDMD_TAG_FML) == 0) + { + strcpy(ctx->CurrentField->FML.Def_Val, ctx->value); + } + else if(strcmp(ctx->PathArray[ctx->PresentLevelTag], IMRD_SDMD_TAG_DELIMITED) == 0) + { + strcpy(ctx->CurrentField->Delimited.Def_Val, ctx->value); + } + + break; + } + default: + { + snprintf(DescErr, sizeof(DescErr), SDMD_XML_LIB_ERROR_10, SDMD_MSGFIELD_FILE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_10); + } + } /* end switch */ + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_OFFSET) == 0) + { + ctx->CurrentField->Fixed.Offset = atoi(ctx->value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_ID) == 0) + { + ctx->CurrentField->Delimited.Id = atoi(ctx->value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_VALUEID) == 0) + { + strcpy(ctx->CurrentField->Value_Id, ctx->value); + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_EXIST) == 0) + { + if(*(ctx->value) == IMRD_YES) + { + ctx->CurrentField->Exist = IMRD_TRUE; + } + else + { + ctx->CurrentField->Exist = IMRD_FALSE; + } + } + else if ( (strcmp((const char*)localname, IMRD_SDMD_TAG_MESSAGE)== 0) ) + { + + ctx->CurrentMessage->Id = ctx->CptMsg; + + index_type_ptr = Field_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(ctx->CurrentMessage->Field_Struct_Ptr, index_type_ptr, IMRD_SDMD_FIELD_STRUCT_IDX_NB); + if(status == IMRS_KO) + { + printf("Erreur lors de la finalisation de Field_Struct_Ptr \n"); + } + + if( ( nd_status = ND_DataStruct_Value_Add( ctx->RootMessage, (void *)(ctx->CurrentMessage))) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_2,IMRD_SDMD_TAG_MESSAGE); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_2 ); + } + ctx->CptMsg++; + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if( (strcmp((const char*)localname, IMRD_SDMD_TAG_FIELD)== 0) ) + { + ctx->CptField++; + ctx->CurrentField->Id = ctx->CptField; + + if( ( nd_status = ND_DataStruct_Value_Add( ctx->CurrentMessage->Field_Struct_Ptr, (void *)(ctx->CurrentField))) != NDS_OK) + { + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_2,IMRD_SDMD_TAG_FIELD); + SDM_RaiseError(ctx->SaxCtxHdl,&(ctx->FataError),&(ctx->flagerror), fonctionname , DescErr, SDMD_XML_CODE_ERROR_2 ); + } + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if ((strcmp((const char *)localname, IMRD_SDMD_TAG_FIXED) == 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_INTERNE) == 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_TAGGED) == 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_XML) == 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_DELIMITED)== 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_CNV) == 0) || + (strcmp((const char *)localname, IMRD_SDMD_TAG_FML) == 0) + ) + { + memset(ctx->PathArray[ctx->PresentLevelTag],0,sizeof(IMRD_SDMD_SIZE_TAG_SIZE)); + ctx->PresentLevelTag = ctx->PresentLevelTag - 1; + } + else if (strcmp((const char *)localname, IMRD_SDMD_TAG_VERSION) == 0) + { + IMRD_LM_LOG_INFO_1( "[Msg-Field]: [%s]", ctx->value); + status_tmp = SDM_Set_Struct_Version((IMRT_Data_Version *)ctx->RootMessage->User_Ptr, (char *)ctx->value); + } +} + +IMRT_Status charactersDebug(SDMT_StructInfo_Contexte * ctx , const xmlChar *ch, int len) +{ + char output[40]; + int i; + + memset(ctx->value,0, sizeof(ctx->value)); + + for (i = 0;(ivalue[i] = ch[i]; + ctx->value[i] = 0; + +} + + +IMRT_Status SDM_XML_Load_Cnv( char *demo_file, SDMT_StructInfo_Contexte *mycontexte) +{ + IMRT_Status status; + NDT_Status nd_status; + char * docname = NULL; + NDT_Index_Type *index_type_ptr; + xmlDocPtr doc = NULL; + xmlDtdPtr dtd; + xmlParserCtxtPtr ctxt =NULL; + xmlSAXHandlerPtr SAXHandler; + xmlSAXHandlerPtr SAXHandler_Sav; + const char functionname []="SDM_XML_Load_Cnv"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + IMRT_Data_Version *Data_Version_Ptr; + + LIBXML_TEST_VERSION + xmlKeepBlanksDefault(0); + xmlSAXDefaultVersion(2); + xmlLineNumbersDefault(1); + + status = IMRS_OK; + docname = demo_file; + ctxt = xmlNewParserCtxt(); + /*initialisation des indexes*/ + index_type_ptr = Appl_Struct_initial_idx_tab; + + + if(ctxt != NULL) + { + mycontexte->flagerror = IMRS_OK; + SAXHandler = &SaxCnvHandlerStruct; + mycontexte->SaxCtxHdl = ctxt; + ctxt->userData = mycontexte; + SAXHandler_Sav = ctxt->sax; + ctxt->sax = SAXHandler; + ctxt->sax2 = 1 ; + + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + Data_Version_Ptr->Label[0] = '\0'; + Data_Version_Ptr->Date[0] = '\0'; + if( ( nd_status = ND_DataStruct_Open(&(mycontexte->RootCnv),IMRD_SDMD_CNV_STRUCT_IDX_NB,index_type_ptr, "SDM_Cnv_Manager",SDM_Cnv_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr)) != NDS_OK) + { + status = IMRS_KO; + printf( "ND_DataStruct_Open() failed (%d) !\n", nd_status); + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_CNV); + SDM_RaiseError(mycontexte->SaxCtxHdl,&(mycontexte->FataError),&(mycontexte->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + else + { + /* DAHBI ND_DataStruct_Info_Print(stderr, mycontexte->RootCnv, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);*/ + doc = xmlCtxtReadFile(ctxt, docname, NULL, XML_PARSE_DTDATTR+XML_PARSE_DTDVALID); + if (ctxt->lastError.code != XML_ERR_OK) + { + status = IMRS_KO; + printf("Erreur de parsing du fichier %s.\n%s\n", docname, ctxt->lastError.message); + } + else if(mycontexte->flagerror != IMRS_OK) + { + status = IMRS_KO; + printf("%s\n", mycontexte->FataError.libError); + } + else + { + index_type_ptr = Cnv_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(mycontexte->RootCnv,index_type_ptr, IMRD_SDMD_CNV_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump(mycontexte->RootCnv);*/ + } + } + + if((status != IMRS_OK)&&(mycontexte->RootCnv != NULL)) + { + if(mycontexte->CurrentCnv != NULL) + { + free(mycontexte->CurrentCnv); + } + nd_status = ND_DataStruct_Close(mycontexte->RootCnv); + } + + ctxt->sax = SAXHandler_Sav; + xmlFreeParserCtxt(ctxt); + } /* end if(ctxt != NULL) */ + else + { + status = IMRS_KO; + } + + return(status); + +} + + +IMRT_Status SDM_XML_Load_MsgAndField( char *demo_file, SDMT_StructInfo_Contexte * mycontexte) +{ + IMRT_Status status; + NDT_Status nd_status; + char * docname = NULL; + NDT_Index_Type *index_type_ptr; + xmlDocPtr doc = NULL; + xmlDtdPtr dtd; + xmlParserCtxtPtr ctxt =NULL; + xmlSAXHandlerPtr debugSAXHandler; + xmlSAXHandlerPtr SAXHandler_Sav; + const char functionname []="SDM_XML_Load_MsgAndField"; + char DescErr[IMRD_SDMD_DESCERR_LEN]; + IMRT_Data_Version *Data_Version_Ptr; + + LIBXML_TEST_VERSION + xmlKeepBlanksDefault(0); + xmlSAXDefaultVersion(2); + xmlLineNumbersDefault(1); + + status = IMRS_OK; + docname = demo_file; + ctxt = xmlNewParserCtxt(); + /*initialisation des indexes*/ + index_type_ptr = Msg_Struct_initial_idx_tab; + + if(ctxt != NULL) + { + mycontexte->flagerror = IMRS_OK; + debugSAXHandler = &debugSAXHandlerStruct; + mycontexte->SaxCtxHdl = ctxt; + ctxt->userData = mycontexte; + SAXHandler_Sav = ctxt->sax; + ctxt->sax = debugSAXHandler; + ctxt->sax2 = 1 ; + + /*xmlSetGenericErrorFunc(NULL,CatchError);*/ + Data_Version_Ptr = (IMRT_Data_Version *) malloc(sizeof(IMRT_Data_Version)); + Data_Version_Ptr->Label[0] = '\0'; + Data_Version_Ptr->Date[0] = '\0'; + if( ( nd_status = ND_DataStruct_Open(&(mycontexte->RootMessage),IMRD_SDMD_MSG_STRUCT_IDX_NB, index_type_ptr, "SDM__Msg_Manager",SDM_Msg_Manager, NULL, NULL, NULL, NULL,0, Data_Version_Ptr)) != NDS_OK) + { + status = IMRS_KO; + snprintf(DescErr,sizeof(DescErr),SDMD_XML_LIB_ERROR_5,IMRD_SDMD_TAG_MESSAGE); + SDM_RaiseError(mycontexte->SaxCtxHdl,&(mycontexte->FataError),&(mycontexte->flagerror), functionname, DescErr, SDMD_XML_CODE_ERROR_5 ); + } + else + { + doc = xmlCtxtReadFile(ctxt, docname, NULL, XML_PARSE_DTDATTR+XML_PARSE_DTDVALID); + if (ctxt->lastError.code != XML_ERR_OK) + { + status = IMRS_KO; + printf("Erreur de parsing du fichier %s.\n%s\n", docname, ctxt->lastError.message); + } + else if(mycontexte->flagerror != IMRS_OK) + { + status = IMRS_KO; + printf("%s\n", mycontexte->FataError.libError); + } + else + { + index_type_ptr = Msg_Struct_final_idx_tab; + status = SDM_DataStruct_Finalize(mycontexte->RootMessage, index_type_ptr, IMRD_SDMD_MSG_STRUCT_IDX_NB); + /*SDM_DataStruct_Dump( mycontexte->RootMessage);*/ + } + } + + if(status != IMRS_OK) + { + if( mycontexte->CurrentMessage != NULL) + { + if(mycontexte->CurrentMessage->Field_Struct_Ptr != NULL) + { + nd_status = ND_DataStruct_Close(mycontexte->CurrentMessage->Field_Struct_Ptr); + } + if( nd_status != NDS_OK) + { + free(mycontexte->CurrentMessage); + } + } + if(mycontexte->CurrentField != NULL) + { + free(mycontexte->CurrentField); + } + if(mycontexte->RootMessage != NULL) + { + nd_status = ND_DataStruct_Close(mycontexte->RootMessage); + } + /*if(mycontexte->RootCnv != NULL) + { + nd_status = ND_DataStruct_Close(mycontexte->RootCnv); + }*/ + } + + ctxt->sax = SAXHandler_Sav; + xmlFreeParserCtxt(ctxt); + } + else + { + status = IMRS_KO; + } + + return(status); + +} + + + +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Cnv_Header(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n"); + fprintf(dump_file, "<%s>\n", IMRD_SDMD_TAG_CNV_STRUCT); + fprintf(dump_file, "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: struct_info_xml.c $\n", + ((IMRT_Data_Version *)IMRG_SDM_Base.RootCnv->User_Ptr)->Label, + ((IMRT_Data_Version *)IMRG_SDM_Base.RootCnv->User_Ptr)->Date); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Cnv_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootCnv, IMRD_SDMD_CMD_API_XML_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + printf( "XML Dump RootCnv failed (%d)...\n"); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Cnv_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n", IMRD_SDMD_TAG_CNV_STRUCT); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Cnv(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, SDMD_CNV_FILE); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + printf( "Can't open dump file (%s) !\n", dump_filename); + } + else + { + status = SDM_XML_Dump_Cnv_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_Cnv_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_Cnv_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Msg_Header(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n"); + fprintf(dump_file, "<%s>\n", IMRD_SDMD_TAG_MSG_STRUCT); + fprintf(dump_file, "@(#) VERSIONIMR: $Label: $ $Date: 2008/11/12 02:25:23 $ $Workfile: struct_info_xml.c $\n", + ((IMRT_Data_Version *)IMRG_SDM_Base.RootMsg->User_Ptr)->Label, + ((IMRT_Data_Version *)IMRG_SDM_Base.RootMsg->User_Ptr)->Date); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Msg_Body(FILE *dump_file) +{ + IMRT_Status status; + NDT_Status nd_status; + + if( ( nd_status = ND_DataStruct_Traverse( IMRG_SDM_Base.RootMsg, IMRD_SDMD_CMD_API_XML_DUMP, dump_file)) != NDS_OK) + { + status = IMRS_KO; + printf( "XML Dump RootMsg failed (%d)...\n"); + } + else + { + status = IMRS_OK; + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Msg_Footer(FILE *dump_file) +{ + fprintf(dump_file, "\n"); + fprintf(dump_file, "\n", IMRD_SDMD_TAG_MSG_STRUCT); + return( IMRS_OK); + +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_Dump_Msg(void) +{ + IMRT_Status status; + char dump_filename[255]; + FILE *dump_file; + + strcpy(dump_filename, SDMD_MSGFIELD_FILE); + + if( ( dump_file = fopen( dump_filename, "w")) == NULL) + { + status = IMRS_KO; + printf( "Can't open dump file (%s) !\n", dump_filename); + } + else + { + status = SDM_XML_Dump_Msg_Header(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_Msg_Body(dump_file); + if(status == IMRS_OK) + { + status = SDM_XML_Dump_Msg_Footer(dump_file); + } + } + + fclose( dump_file); + } + + return(status); +} +/******************************************************************************/ +/******************************************************************************/ +/******************************************************************************/ +IMRT_Status SDM_XML_StructInfo_Dump(void) +{ + IMRT_Status status; + + status = SDM_XML_Dump_Cnv(); + + if(status == IMRS_OK) + { + status = SDM_XML_Dump_Msg(); + } + + return(status); +} + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ diff --git a/src/libstatic_data_mng/src/struct_info_xml.h b/src/libstatic_data_mng/src/struct_info_xml.h new file mode 100644 index 0000000..9f6776f --- /dev/null +++ b/src/libstatic_data_mng/src/struct_info_xml.h @@ -0,0 +1,277 @@ +/*----------------------------------------------------------------------------*/ +/* File: struct_info_xml.h */ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* IMR - Interlinking Message Router */ +/* Copyright (C) 2005 Arnaud G. Gibert & Others (See ReadMe.txt) */ +/* mailto:arnaud@rx3.net */ +/* http://www.rx3.org/dvp/?dvp=imr */ +/*----------------------------------------------------------------------------*/ +/* This file is part of IMR */ +/* */ +/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/*----------------------------------------------------------------------------*/ + +#ifndef _STRUCT_INFO_XML_H_ +# define _STRUCT_INFO_XML_H_ + + + +/*----------------------------------------------------------------------------*/ +/* Global Include */ +/*----------------------------------------------------------------------------*/ + +# include + +/*----------------------------------------------------------------------------*/ +/* Local constantes */ +/*----------------------------------------------------------------------------*/ + +/*definition des tags xml pour le chargement des structure Msg et Field*/ +#define IMRD_SDMD_TAG_MESSAGE "message" +#define IMRD_SDMD_TAG_FIELD "field" +#define IMRD_SDMD_TAG_VALUEID "valueid" +#define IMRD_SDMD_TAG_FIXED "fixed" +#define IMRD_SDMD_TAG_OFFSET "offset" +#define IMRD_SDMD_TAG_SIZE "size" +#define IMRD_SDMD_TAG_TAGGED "tagged" +#define IMRD_SDMD_TAG_TAG "tag" +#define IMRD_SDMD_TAG_INTERNE "interne" +#define IMRD_SDMD_TAG_INTERNAL_NAME "internal_name" +#define IMRD_SDMD_TAG_FORMAT "format" +#define IMRD_SDMD_TAG_XML "xml" +#define IMRD_SDMD_TAG_FML "fml" +#define IMRD_SDMD_TAG_DELIMITED "delimited" +#define IMRD_SDMD_TAG_ID "id" +#define IMRD_SDMD_TAG_DEFVAL "defval" +#define IMRD_SDMD_TAG_CNV "cnv" +#define IMRD_SDMD_TAG_ATTRIBUTE "attribute" +#define IMRD_SDMD_TAG_EXIST "exist" + + +/*----------------------------------------------------------------------------*/ +/* Local Definition */ +/*----------------------------------------------------------------------------*/ + + + +typedef struct SDMT_StructInfo_Contexte +{ + char value[IMRD_SDMD_VALUE_LEN]; + IMRT_Array_Xml_Path PathArray; + IMRT_Level_Tag PresentLevelTag; + IMRT_Msg_Id CptMsg; + IMRT_Field_Id CptField; + IMRT_Cnv_Id CptCnv; + IMRT_Field * CurrentField; + IMRT_Msg * CurrentMessage; + IMRT_Cnv * CurrentCnv; + NDT_Root * RootMessage; + NDT_Root * RootCnv; + xmlParserCtxt * SaxCtxHdl; + IMRT_Error FataError; + IMRT_Status flagerror; +}SDMT_StructInfo_Contexte; + +/*----------------------------------------------------------------------------*/ +/* Prototypes */ +/*----------------------------------------------------------------------------*/ + +# ifdef _STRUCT_INFO_XML_C_ + +static IMRT_Status error(SDMT_StructInfo_Contexte *ctx , const char *msg, ...); + +IMRT_Status startElementNsCnv( SDMT_StructInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); + +IMRT_Status startElementNS( SDMT_StructInfo_Contexte * ctx , + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); + +IMRT_Status endElementNsCnv( SDMT_StructInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); + +IMRT_Status endElementNS( SDMT_StructInfo_Contexte * ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); + +IMRT_Status charactersDebug(SDMT_StructInfo_Contexte * ctx , const xmlChar *ch, int len); + +IMRT_Status SDM_XML_Load_Cnv( char *demo_file, SDMT_StructInfo_Contexte *mycontexte); +IMRT_Status SDM_XML_Load_MsgAndField( char *demo_file, SDMT_StructInfo_Contexte * mycontexte); +IMRT_Status SDM_XML_StructInfo_Init(IMRT_Path Lib_Path); +IMRT_Status SDM_XML_Dump_Cnv_Header(FILE *dump_file); +IMRT_Status SDM_XML_Dump_Cnv_Body(FILE *dump_file); +IMRT_Status SDM_XML_Dump_Cnv_Footer(FILE *dump_file); +IMRT_Status SDM_XML_Dump_Cnv(void); +IMRT_Status SDM_XML_Dump_Msg_Header(FILE *dump_file); +IMRT_Status SDM_XML_Dump_Msg_Body(FILE *dump_file); +IMRT_Status SDM_XML_Dump_Msg_Footer(FILE *dump_file); +IMRT_Status SDM_XML_Dump_Msg(void); +IMRT_Status SDM_XML_StructInfo_Dump(void); + +# else + +extern IMRT_Status SDM_XML_Load_Cnv( char *demo_file, SDMT_StructInfo_Contexte *mycontexte); +extern IMRT_Status SDM_XML_Load_MsgAndField( char *demo_file, SDMT_StructInfo_Contexte * mycontexte); +extern IMRT_Status SDM_XML_StructInfo_Init(IMRT_Path Lib_Path); +extern IMRT_Status SDM_XML_Dump_Cnv_Header(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_Cnv_Body(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_Cnv_Footer(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_Cnv(void); +extern IMRT_Status SDM_XML_Dump_Msg_Header(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_Msg_Body(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_Msg_Footer(FILE *dump_file); +extern IMRT_Status SDM_XML_Dump_Msg(void); +extern IMRT_Status SDM_XML_StructInfo_Dump(void); + +# endif + +/*----------------------------------------------------------------------------*/ +/* Globale Variables */ +/*----------------------------------------------------------------------------*/ + +# ifdef _STRUCT_INFO_XML_C_ + +/*xmlSAXHandler ErrorSAXHandlerStruct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + NULL, + NULL, + NULL + };*/ + +xmlSAXHandler SaxCnvHandlerStruct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (charactersSAXFunc)(charactersDebug), + NULL, + NULL, + NULL, + NULL, + (errorSAXFunc)error, + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + (startElementNsSAX2Func)(startElementNsCnv), + (endElementNsSAX2Func)(endElementNsCnv), + NULL +}; +xmlSAXHandler debugSAXHandlerStruct = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (charactersSAXFunc)(charactersDebug), + NULL, + NULL, + NULL, + NULL, + (errorSAXFunc)(error), + NULL, + NULL, + NULL, + NULL, + 1, + NULL, + (startElementNsSAX2Func)(startElementNS), + (endElementNsSAX2Func)(endElementNS), + NULL +}; + + + +# endif + +/*----------------------------------------------------------------------------*/ + +#endif diff --git a/src/libxml/AUTHORS b/src/libxml/AUTHORS new file mode 100644 index 0000000..cf2e9a6 --- /dev/null +++ b/src/libxml/AUTHORS @@ -0,0 +1,5 @@ +Daniel Veillard +Bjorn Reese +William Brack +Igor Zlatkovic for the Windows port +Aleksey Sanin diff --git a/src/libxml/COPYING b/src/libxml/COPYING new file mode 100644 index 0000000..417e955 --- /dev/null +++ b/src/libxml/COPYING @@ -0,0 +1,27 @@ +Except where otherwise noted in the source code (e.g. the files hash.c, +list.c and the trio files, which are covered by a similar licence but +with different Copyright notices) all the files are: + + Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is fur- +nished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- +NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- +NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of Daniel Veillard shall not +be used in advertising or otherwise to promote the sale, use or other deal- +ings in this Software without prior written authorization from him. + diff --git a/src/libxml/ChangeLog b/src/libxml/ChangeLog new file mode 100644 index 0000000..09ed24a --- /dev/null +++ b/src/libxml/ChangeLog @@ -0,0 +1,20389 @@ +Sun Apr 18 23:45:46 CEST 2004 Daniel Veillard + + * configure.in: preparing 2.6.9 release + * doc/* News: updated and rebuilt the docs + +Sun Apr 18 22:51:43 CEST 2004 Daniel Veillard + + * xpath.c: relaxed id() to not check taht the name(s) passed + are actually NCName, decided this in agreement with Aleksey Sanin + since existing specs like Visa3D broke that conformance checking + and other tools seems to not implement it sigh... + * SAX2.c: check attribute decls for xml:id and the value is an + NCName. + * test/xmlid/id_err* result/xmlid/id_err*: added error testing + +Sun Apr 18 21:46:17 CEST 2004 Daniel Veillard + + * xpath.c: work around Microsoft compiler NaN bug raise reported + by Mark Vakoc + * xmlschemas.c include/libxml/schemasInternals.h + include/libxml/xmlerror.h: fixed a recusive extention schemas + compilation error raised by taihei goi + +Sun Apr 18 16:57:02 CEST 2004 Daniel Veillard + + * libxml.spec.in: keep the ChangeLog compressed + * xmlreader.c: fix a segfault when using Close() + * python/tests/Makefile.am python/tests/reader8.py: test for + the Close() reader API. + +Sat Apr 17 22:42:13 HKT 2004 William Brack + + * xmlschemas.c, xmlwriter.c, doc/examples/parse4.c, + doc/examples/io2.c: minor warning cleanup (no change to logic) + * xinclude: fixed return value for internal function + xmlXIncludeLoadFallback (now always 0 or -1) + +Sat Apr 17 21:32:32 HKT 2004 William Brack + + * valid.c: small enhancement to fix bug 139791 + +Fri Apr 16 18:44:47 CEST 2004 Daniel Veillard + + * xmlschemas.c include/libxml/schemasInternals.h + include/libxml/xmlerror.h: applied patches from Kasimier Buchcik + for the attribute use support + * test/schemas/attruse* result/schemas/attruse*: added the + tests to the regression suite. + +Fri Apr 16 18:22:25 CEST 2004 Daniel Veillard + + * xmlsave.c: move the TODO as comments as the function while not + finished are usable as-is + * xmlschemas.c include/libxml/xmlerror.h: patch from Kasimier Buchcik + implementing union + * test/schemas/union_0_0.x* result/schemas/union_0_0*: added example + * python/Makefile.am: applied fix from Mike Hommey + +Fri Apr 16 23:58:42 HKT 2004 William Brack + + * parser.c: fixed problem with detecting external dtd + encoding (bug 135229). + * Makefile.am: minor change to test label + +Fri Apr 16 16:09:31 HKT 2004 William Brack + + * xinclude.c: fixed problem causing duplicate fallback + execution (bug 139520) + * test/XInclude/docs/fallback2.xml result/XInclude/fallback2.*: + added testcase + +Fri Apr 9 23:49:37 CEST 2004 Daniel Veillard + + * SAX2.c include/libxml/tree.h: adding xml:id draft support + * Makefile.am test/xmlid/id_tst* result/xmlid/id_tst*: adding + 4 first regression tests + +Fri Apr 9 11:56:08 CEST 2004 Daniel Veillard + + * libxml.spec.in: fixing Red Hat bug #120482 , libxml2-python + should depend on the version of python used to compile it. + +Mon Apr 5 09:07:24 CEST 2004 Daniel Veillard + + * HTMLparser.c: applied patch from James Bursa, frameset should + close head. + +Fri Apr 2 22:02:24 HKT 2004 William Brack + + * relaxng.c: fixed problem in xmlRelaxNGCompareNameClasses + which was causing check-relaxng-test-suite.py test 351 to fail. + +Fri Apr 2 17:03:48 HKT 2004 William Brack + + * nanohttp.c: implemented fix for M$ IIS redirect provided + by Ian Hummel + * relaxng.c: fixed problem with notAllowed compilation + (bug 138793) + +Thu Apr 1 22:07:52 CEST 2004 Daniel Veillard + + * uri.c: fix for xmlUriEscape on "http://user@somewhere.com" + from Mark Vakoc. + +2004-04-01 Johan Dahlin + + * python/.cvsignore: Add generated files, to make cvs silent. + +Thu Apr 1 12:41:36 CEST 2004 Daniel Veillard + + * xmlschemas.c: small signed-ness patch from Steve Little + +Wed Mar 31 17:47:28 CEST 2004 Daniel Veillard + + * xmlregexp.c: patched a bug in parsing production 1 and 2 of + xmlschemas regexp that William pointed out while working on + #134120 + * test/regexp/branch result/regexp/branch: added a specific + regression test + +Wed Mar 31 09:50:32 HKT 2004 William Brack + + * Makefile.am: added PYTHONPATH to python tests for Schemas + and RelaxNG + * test/xsdtest/xsdtestsuite.xml: added testfile for + SchemasPythonTests + +Mon Mar 29 16:56:49 CEST 2004 Daniel Veillard + + * doc/examples/examples.xsl doc/examples/index.html: added + information about compiling on Unix + +Mon Mar 29 14:18:12 CEST 2004 Daniel Veillard + + * catalog.c: fixes the comments for xmlCatalogDump and xmlDumpACatalog + * doc/*: rebuilt to update + +Sun Mar 28 18:11:41 CEST 2004 Daniel Veillard + + * xmlsave.c: optimize indentation based on the new context + +Sun Mar 28 14:17:10 CEST 2004 Daniel Veillard + + * doc/examples/xpath2.c doc/examples/xpath2.res: handle and explain + a very tricky problem when modifying the tree based on an XPath + result query. + +Sat Mar 27 09:56:14 PST 2004 William Brack + + * relaxng.c: fixed problem with IS_COMPILABLE flag + (bug 130216) + +Fri Mar 26 18:28:32 CET 2004 Daniel Veillard + + * parser.c: applied patch from Dave Beckett to correct line number + errors when using push with CDATA + +Fri Mar 26 14:53:58 CET 2004 Daniel Veillard + + * doc/examples/xpath1.c: added a test template + * doc/examples/xpath2.c doc/examples/xpath2.res doc/examples/*: + added a new example, and make valgrind target + +Fri Mar 26 11:47:29 CET 2004 Daniel Veillard + + * parser.c: apply fix for #136693 + +Thu Mar 25 20:21:01 MST 2004 John Fleck + + * doc/examples/io2.c + * doc/examples/io2.res + add xmlDocDumpMemory example in response to mailing list FAQ + (rebuilt xml and html also) + +Thu Mar 25 10:33:05 CET 2004 Daniel Veillard + + * debugXML.c testXPath.c xmllint.c xmlschemastypes.c: applied + patch from Mark Vakoc avoiding using xmlParse* option and use + xmlRead* instead + * win32/Makefile.bcb: patch to Borland C++ builder from Eric Zurcher + to avoid problems with some pathnames. + +Tue Mar 23 12:35:08 CET 2004 Daniel Veillard + + * configure.in doc/* News: preparing 2.6.8 release, updated and rebuilt + the docs. + * Makefile.am: use valgring fro the new Python based regression tests + +Mon Mar 22 20:07:27 CET 2004 Daniel Veillard + + * relaxng.c: remove a memory leak on schemas type facets. + * check-relaxng-test-suite.py check-relaxng-test-suite2.py + check-xsddata-test-suite.py: reduce verbosity + * configure.in Makefile.am: incorporated the Python regressions + tests for Relax-NG and Schemas Datatype to "make tests" + +Mon Mar 22 16:16:18 CET 2004 Daniel Veillard + + * xmlwriter.c include/libxml/xmlwriter.h doc/* : applied patch from + Alfred Mickautsch for better DTD support. + * SAX2.c HTMLparser.c parser.c xinclude.c xmllint.c xmlreader.c + xmlschemas.c: fixed bug #137867 i.e. fixed properly the way + reference counting is handled in the XML parser which had the + side effect of removing a lot of hazardous cruft added to try + to fix the problems associated as they popped up. + * xmlIO.c: FILE * close fixup for stderr/stdout + +Sun Mar 21 19:19:41 HKT 2004 William Brack + + * relaxng.c: added an error message when an element is not + found within a (bug 126093) + +Sat Mar 20 22:25:18 HKT 2004 William Brack + + * xmlregexp.c: enhanced the logic of parsing char groups to + better handle initial or ending '-' (bug 135972) + +Sat Mar 20 19:26:03 HKT 2004 William Brack + + * relaxng.c: added check for external reference in + xmlRelaxNGGetElements (bug 137718) + * test/relaxng/rngbug-001.*, result/relaxng/rngbug-001*: added + regression test for above + +Wed Mar 17 16:37:22 HKT 2004 William Brack + + * nanohttp.c: added a close for the local file descriptor + (bug 137474) + +Mon Mar 15 15:46:59 CET 2004 Daniel Veillard + + * xmlsave.c: switched the output routines to use the new context. + +Mon Mar 15 10:37:18 HKT 2004 William Brack + + * relaxng.c: enhanced to ignore XML_XINCLUDE_START and XML_XINCLUDE_END + nodes (bug 137153) + +Sun Mar 14 13:19:20 CET 2004 Daniel Veillard + + * xmlschemastypes.c: applied patch from John Belmonte for anyURI. + +Wed Mar 10 17:22:48 CET 2004 Daniel Veillard + + * parser.c: fix bug reported by Holger Rauch + * test/att8 result/noent/att8 result/att8 result/att8.rdr + result/att8.sax: added the test to th regression suite + +Wed Mar 10 19:42:22 HKT 2004 William Brack + + * doc/search.php: Minor change for later verson of php requiring + $HTTP_GET_VARS. + +Wed Mar 10 00:12:31 HKT 2004 William Brack + + * tree.c: Changed the flag to xmlDocCopyNode (and similar routines), + previously used only for recursion, to use a value of '2' to + indicate copy properties & namespaces, but not children. + * xinclude.c: changed the handling of ranges to use the above new + facility. Fixes Bug 134268. + +Tue Mar 9 18:48:51 HKT 2004 William Brack + + * win32/Makefile.bcb, win32/Makefile.mingw, win32/Makefile.msvc: + added new module xmlsave with patch supplied by Eric Zurcher + (second attempt - don't know what happened to the first one!) + +Tue Mar 9 09:59:25 CET 2004 Daniel Veillard + + * python/libxml.c python/libxml.py: applied patch from Anthony Carrico + providing Python bindings for the Canonicalization C14N support. + +Mon Mar 8 11:12:23 CET 2004 Hagen Moebius + + * .cvsignore and python/.cvsignore patched + +Mon Mar 8 22:33:14 HKT 2004 William Brack + + * xinclude.c: enhanced to assure that if xpointer is called + for a document, the XML_PARSE_NOENT flag is set before parsing + the included document so that entities will automatically get + taken care of. + * xpointer.c: corrected code so that, if an XML_ENTITY_REF node + is encountered, it will log it and not crash (bug 135713) + +Sun Mar 7 19:03:48 HKT 2004 William Brack + + * xinclude.c: modified to make sub-includes inherit the + parse flags from the parent document (bug 132597) + +Fri Mar 5 01:13:22 CET 2004 Daniel Veillard + + * xmlschemas.c: QName handling fixes for the XML Schemas + support from Adam Dickmeiss + * test/schemas/po1_0.xsd: also fix the schemas + * test/schemas/ns[12]* result/schemas/ns[12]*: added the specific + regression tests + +Thu Mar 4 23:03:02 CET 2004 Daniel Veillard + + * configure.in doc/Makefile.am include/libxml/Makefile.am: + paalied patch from Julio M. Merino Vidal fixing bug #134751 + to fix --with-html-dir option. + * doc/*: rebuilt fully the docs + * doc/html/libxml-xmlsave.html: new file from new header. + +Thu Mar 4 16:57:50 CET 2004 Daniel Veillard + + * debugXML.c testHTML.c tree.c doc/examples/*.c + include/libxml/xmlsave.h: fixing compilation bug with some options + disabled as well as --with-minimum should fix #134695 + +Thu Mar 4 15:00:45 CET 2004 Daniel Veillard + + * xmlcatalog.c: allow fallback to URI lookup when SYSTEM fails, + should close #134092 + +Thu Mar 4 14:39:38 CET 2004 Daniel Veillard + + * Makefile.am tree.c xmlsave.c include/libxml/xmlsave.h: commiting + the new xmlsave module before the actuall big code change. + +Thu Mar 4 12:38:53 CET 2004 Daniel Veillard + + * xmlschemas.c: applied patch from Adam Dickmeiss for mixed content + * test/schemas/mixed* result/schemas/mixed*: added his regression + tests too. + +Mon Mar 1 15:22:06 CET 2004 Daniel Veillard + + * testSAX.c: fix a compilation problem about a missing timb include + +Sat Feb 28 22:35:32 HKT 2004 William Brack + + * testSAX.c: small enhancement to prevent trying to print + strings with null pointers (caused "make tests" errors on + HP-UX) + +Thu Feb 26 20:19:40 MST 2004 John Fleck + + * doc/xmllint.xml + * doc/xmllint.1 + * doc/xmllint.html + * doc/xmlcatalog_man.xml + * doc/xmlcatalog.1 + * doc/xmlcatalog_man.html + applying patch from Mike Hommey to clarify XML_CATALOG_FILES + use + +Thu Feb 26 23:47:43 CET 2004 Daniel Veillard + + * Makefile.am: patch for cross-compilation to Windows from + Christophe de VIENNE. + +Thu Feb 26 18:52:11 HKT 2004 William Brack + + * doc/*.html, doc/html/*.html: regenerated docs using older + version of xsltproc pending resolution of AVT problem + +Thu Feb 26 10:56:29 CET 2004 Daniel Veillard + + * Makefile.am: applied patch from Charles Bozeman to not use + the system xmllint. + +Wed Feb 25 18:07:05 CET 2004 Daniel Veillard + + * include/libxml/xmlexports.h: applied patch from Roland Schwingel + for MingW + +Wed Feb 25 13:57:25 CET 2004 Daniel Veillard + + * Makefile.am catalog.c configure.in: applied a cleanup patch + from Peter Breitenlohner + * tree.c: removed a doc build warning by fixing a param comment + * doc/* : rebuilt the docs + +Wed Feb 25 13:33:07 CET 2004 Daniel Veillard + + * valid.c HTMLparser.c: avoid ID error message if using + HTML_PARSE_NOERROR should fix #130762 + +Wed Feb 25 12:50:53 CET 2004 Daniel Veillard + + * debugXML.c relaxng.c valid.c xinclude.c xmllint.c xmlreader.c: + fixing compilation and link option when configuring with + --without-valid should fix #135309 + +Wed Feb 25 11:36:06 CET 2004 Daniel Veillard + + * catalog.c: fixed the main issues reported by Peter Breitenlohner + * parser.c: cleanup + * valid.c: speedup patch from Petr Pajas + +Wed Feb 25 16:07:14 HKT 2004 William Brack + + * xpath.c: fixed a memory leak (xmlXPathLangFunction) reported + on the list by Mike Hommey + +Mon Feb 23 17:28:34 CET 2004 Daniel Veillard + + * doc/* NEWS configure.in: preparing 2.6.7 release, updated and + rebuilt the documentation. + +Mon Feb 23 11:52:12 CET 2004 Daniel Veillard + + * python/tests/*.py: applied patch from Malcolm Tredinnick + to avoid tabs in python sources, should fix #135095 + +Sun Feb 22 23:16:23 CET 2004 Daniel Veillard + + * testSAX.c: add --timing option + * relaxng.c: use the psvi field of the nodes instead of _private + which may be used for other purposes. + +Sat Feb 21 16:57:48 CET 2004 Daniel Veillard + + * encoding.c: small patch to try to fix a warning with Sun One compiler + +Sat Feb 21 16:22:35 CET 2004 Daniel Veillard + + * encoding.c: small patch removing a warning with MS compiler. + +Sat Feb 21 13:52:30 CET 2004 Daniel Veillard + + * debugXML.c: added "relaxng" option to the debugging shell + * Makefile.am test/errors/* result/errors/*: some regression tests + for some error tests cases. + +Fri Feb 20 09:56:47 CET 2004 Daniel Veillard + + * tree.c: xmlAttrSerializeTxtContent don't segfault if NULL + is passed. + * test/att7 result//att7*: adding an old regression test + laying around on my laptop + +Thu Feb 19 17:33:36 CET 2004 Daniel Veillard + + * xmlreader.c: fixed xmllint --memory --stream memory consumption + on large file by using xmlParserInputBufferCreateStatic() with + the mmap'ed file + +Thu Feb 19 13:56:53 CET 2004 Daniel Veillard + + * tree.c: some clarification in xmlDocDumpMemory() documentation + * xmllint.c: fixed xmllint --stream --timing to get timings back + +Wed Feb 18 15:20:42 CET 2004 Daniel Veillard + + * parser.c: fixed a problem in push mode when attribute contains + unescaped '>' characters, fixes bug #134566 + * test/att6 result//att6*: added the test to the regression suite + +Tue Feb 17 17:26:31 CET 2004 Daniel Veillard + + * valid.c: removing a non-linear behaviour from ID/IDREF raised + by Petr Pajas. Call xmlListAppend instead of xmlListInsert in + xmlAddRef + +Tue Feb 17 13:27:27 CET 2004 Daniel Veillard + + * python/tests/indexes.py python/tests/reader.py: indicated + encoding of the test file, needed for python 2.3 + +Tue Feb 17 21:08:11 HKT 2004 William Brack + + * xpath.c: fixed problem with numbers having > 19 + fractional places (bug 133921) + +Tue Feb 17 12:47:20 CET 2004 Daniel Veillard + + * xpath.c: applied optimization patch from Petr Pajas + +Tue Feb 17 12:39:08 CET 2004 Daniel Veillard + + * xmlwriter.c include/libxml/xmlwriter.h: applied update + from Alfred Mickautsch and the added patch from Lucas Brasilino + +Sun Feb 15 12:01:30 CET 2004 Daniel Veillard + + * benchmark.png index.html xml.html: updating the benchmark + graph and using a PNG instead of a GIF + * xmlreader.c: updated the TODO + +Sat Feb 14 18:55:40 MST 2004 John Fleck + + * doc/tutorial/xmltutorial.xml + * doc/tutorial/xmltutorial.pdf + * doc/tutorial/*.html + Fix bug in XPath example in the tutorial, thanks to Carlos, whose + last name I don't know, for pointing this out + +Thu Feb 12 16:28:12 CET 2004 Daniel Veillard + + * NEWS configure.in: preparing release of 2.6.6 + * doc/*: updated the docs and rebuilt them + +Thu Feb 12 13:41:16 CET 2004 Daniel Veillard + + * xmlregexp.c: fixing bug #132930 with the provided patch, a bit + suspicious about it but this is fairly contained and regression + tests still passes. + * test/schemas/all1* result/schemas/all1*: added the test to + the regression suite. + +Thu Feb 12 12:54:26 CET 2004 Daniel Veillard + + * parser.c: fixed bug #132575 about finding the end of the + internal subset in push mode. + * test/intsubset.xml result/intsubset.xml* result/noent/intsubset.xml: + added the test to the regression suite + +Wed Feb 11 14:19:31 CET 2004 Daniel Veillard + + * parserInternals.c xmlIO.c encoding.c include/libxml/parser.h + include/libxml/xmlIO.h: added xmlByteConsumed() interface + * doc/*: updated the benchmark rebuilt the docs + * python/tests/Makefile.am python/tests/indexes.py: added a + specific regression test for xmlByteConsumed() + * include/libxml/encoding.h rngparser.c tree.c: small cleanups + +Wed Feb 11 08:13:58 HKT 2004 William Brack + + * encoding.c: applied patch supplied by Christophe Dubach + to fix problem with --with-minimum configuration + (bug 133773) + * nanoftp.c: fixed potential buffer overflow problem, + similar to fix just applied to nanohttp.c. + +Mon Feb 9 18:40:21 CET 2004 Igor Zlatkovic + + * nanohttp.c: fixed the fix for the buffer overflow, thanx + William :-) + +Mon Feb 9 22:37:14 HKT 2004 William Brack + + * acinclude.m4, configure.in: fixed problem concerning + determining SOCKLEN_T as pointed out by Daniel Richard G. + on the mailing list + +Mon Feb 9 15:31:24 CET 2004 Igor Zlatkovic + + * nanohttp.c: fixed buffer overflow reported by Yuuichi Teranishi + +Mon Feb 9 13:45:59 CET 2004 Daniel Veillard + + * xpath.c: small patch from Philip Ludlam to avoid warnings. + +Mon Feb 9 13:41:47 CET 2004 Daniel Veillard + + * encoding.c: applied a small patch from Alfred Mickautsch + to avoid an out of bound error in isolat1ToUTF8() + +Mon Feb 9 13:35:50 CET 2004 Daniel Veillard + + * xinclude.c: remove the warning on the 2001 namespace + * parser.c parserInternals.c xpath.c: remove some warnings + when compiling with MSVC6 + * nanohttp.c: applied a patch when using _WINSOCKAPI_ + +Sun Feb 8 12:09:55 HKT 2004 William Brack + + * xinclude.c: added a small hack to fix interference between + my fixes for bugs 132585 and 132588. + * python/libxml.c: fixed problem with serialization of namespace + reported on the mailing list by Anthony Carrico + +Sat Feb 7 16:53:11 HKT 2004 William Brack + + * xinclude.c: fixed problem with function xmlXIncludeCopyRange + (bug 133686). + +Fri Feb 6 21:03:41 HKT 2004 William Brack + + * xmlwriter.c: fixed problem with return value of + xmlTextWriterWriteIndent() (bug 133297) + +Fri Feb 6 19:07:04 HKT 2004 William Brack + + * xinclude.c: changed coding to output good XIncludes when + one or more bad ones are present (bug 132588) + +Fri Feb 6 17:34:21 HKT 2004 William Brack + + * xinclude.c: corrected handling of empty fallback condition + (bug 132585) + +Fri Feb 6 15:28:36 HKT 2004 William Brack + + * HTMLparser.c: added initialisation for ctxt->vctxt + in HTMLInitParser (bug 133127) + * valid.c: minor cosmetic change (removed ATTRIBUTE_UNUSED + from several function params) + +Tue Feb 3 16:48:57 PST 2004 William Brack + + * xinclude.c: fixed problem regarding freeing of dictionary + when there are errors within an XInclude file (bug 133106). + Thanks to Oleg Paraschenko for the assistance. + +Tue Feb 3 09:53:18 PST 2004 William Brack + + * xmlschemastypes.c: fixed validation of maxLength with no + content using patch submitted by Eric Haszlakiewicz + (bug 133259) + +Tue Feb 3 09:21:09 CET 2004 Igor Zlatkovic + + * include/libxml/xmlreader.h include/libxml/xmlmemory.h: added + calling convention to the public function prototypes (rep by + Cameron Johnson) + * include/libxml/xmlexports.h: fixed mingw+msys compilation + (rep by Mikhail Grushinskiy) + +Mon Feb 2 20:22:18 PST 2004 William Brack + + * xmlwriter.c: enhanced output indenting (bug 133264) + +Mon Feb 2 16:13:33 PST 2004 William Brack + + * xmlreader.c, include/libxml/xmlreader.h: applied patch from + Steve Ball to provide structured error reports. + +Sun Feb 1 01:48:14 PST 2004 William Brack + + * tree.c, include/libxml/tree.h: moved serialization of + attribute text data (xmlSerializeContent) into a separate + routine (xmlSerializeTxtContent) so it can be used by xmlwriter.c + * xmlwriter.c: changed handling of attribute string to use the + routine above (fixed bug 131548) + +Sat Jan 31 08:22:02 MST 2004 John Fleck 2.6, rebuild + html - this time doing it correctly :-) + +Fri Jan 30 20:45:36 MST 2004 John Fleck + + * doc/examples/examples.xml + * doc/examples/*.html + add note that reader examples need libmxl2 > 2.6, rebuild + html + +Thu Jan 29 23:51:48 PST 2004 William Brack + + * xpath.c: added (void *) type override to prevent + warning on Solaris (Bug 132671) + +Wed Jan 28 07:20:37 MST 2004 John Fleck + + * doc/examples/Makefile.am + per Jan. 15 email to the list from oliverst, the index.html + file from this directory wasn't making it into the tarball + +Mon Jan 26 18:01:00 CET 2004 Daniel Veillard + + * acinclude.m4: applied fix from Alexander Winston for a problem + related to automake-1.8 , c.f. #132513 and #129861 + +Mon Jan 26 12:53:11 CET 2004 Daniel Veillard + + * doc/examples/index.py: don't rely on . being on the path for + make tests, should keep Mr. Crozat quiet until next time... + +Sun Jan 25 21:45:03 CET 2004 Daniel Veillard + + * configure.in NEWS doc/*: preparing release 2.6.5, rebuilt the + docs, checked rngparser stuff does not end up in the tarball + +Sun Jan 25 20:59:20 CET 2004 Daniel Veillard + + * python/libxml.c: applied patch from Frederic Peters + fixing the wrong arg order in xpath callback in bug #130980 + +Sun Jan 25 20:52:09 CET 2004 Daniel Veillard + + * xinclude.c: fixing #130453 XInclude element with no href attribute + * relaxng.c rngparser.c include/libxml2/relaxng.h: fully integrating + the compact syntax will require more work, postponed for the + 2.6.5 release. + +Sat Jan 24 09:30:22 CET 2004 Daniel Veillard + + * include/libxml/schemasInternals.h xmlschemas.c: applied patch from + Steve Ball to avoid a double-free. + +Fri Jan 23 14:03:21 CET 2004 Daniel Veillard + + * doc/examples/*: added io1.c an example ox xmlIO usage and io1.res + test result, fixed a awful lot of memory leaks showing up in + testWriter.c, changed the examples and the Makefiles to test + memory leaks. + * xmlwriter.c: fixed a memory leak + * Makefile.am: run the doc/examples regression tests as part of + make tests + * xpath.c include/libxml/xpath.h: added xmlXPathCtxtCompile() to + compile an XPath expression within a context, currently the goal + is to be able to reuse the XSLT stylesheet dictionnary, but this + opens the door to others possible optimizations. + * dict.c include/libxml/dict.h: added xmlDictCreateSub() which allows + to build a new dictionnary based on another read-only dictionnary. + This is needed for XSLT to keep the stylesheet dictionnary read-only + while being able to reuse the strings for the transformation + dictionnary. + * xinclude.c: fixed a dictionnar reference counting problem occuring + when document parsing failed. + * testSAX.c: adding option --repeat for timing 100times the parsing + * doc/* : rebuilt all the docs + +Thu Jan 22 14:17:05 2004 Aleksey Sanin + + * xmlmemory.c: make xmlReallocLoc() accept NULL pointer + +Thu Jan 22 08:26:20 CET 2004 Daniel Veillard + + * xmlschemastypes.c: applied patch from John Belmonte for + normalizedString datatype support. + +Thu Jan 22 10:43:22 HKT 2004 William Brack + + * xpath.c: fixed problem with union when last() is used + in predicate (bug #131971) + * xpointer.c: minor change to comment for doc generation + +Wed Jan 21 17:03:17 CET 2004 Daniel Veillard + + * parser.c: fixed bug #131745 raised by Shaun McCance with the + suggested patch + +Wed Jan 21 10:59:55 CET 2004 Daniel Veillard + + * xmlwriter.c: applied patch from Alfred Mickautsch fixing a memory + leak reported on the list. + +Thu Jan 15 00:48:46 CET 2004 Daniel Veillard + + * python/generator.py python/tests/tstLastError.py: applied + patch from Stephane Bidoul to add enums to the Python bindings. + +Tue Jan 13 21:50:05 CET 2004 Daniel Veillard + + * testHTML.c: another small patch from Mark Vadoc + +Tue Jan 13 21:39:58 CET 2004 Daniel Veillard + + * HTMLparser.c relaxng.c testRelax.c testSchemas.c: applied + patch from Mark Vadoc to not use SAX1 unless necessary. + +Mon Jan 12 17:22:57 CET 2004 Daniel Veillard + + * dict.c parser.c xmlstring.c: some parser optimizations, + xmllint --memory --timing --repeat --stream ./db10000.xml + went down from 16.5 secs to 15.5 secs. + +Thu Jan 8 17:57:50 CET 2004 Daniel Veillard + + * xmlschemas.c: removed a memory leak remaining from the switch + to a dictionnary for string allocations c.f. #130891 + +Thu Jan 8 17:48:46 CET 2004 Daniel Veillard + + * xmlreader.c: fixing some problem if configured --without-xinclude + c.f. #130902 + +Thu Jan 8 17:42:48 CET 2004 Daniel Veillard + + * configure.in: changed AC_OUTPUT() macro to avoid a cygwin problem + c.f. #130896 + +Thu Jan 8 00:36:00 CET 2004 Daniel Veillard + + * win32/Makefile.bcb win32/Makefile.mingw win32/Makefile.msvc: + applying patch from Mark Vakoc for Windows + * doc/catalog.html doc/encoding.html doc/xml.html: applied doc + fixes from Sven Zimmerman + +Tue Jan 6 23:51:46 CET 2004 Daniel Veillard + + * python/libxml2-python-api.xml python/libxml_wrap.h python/types.c + python/tests/Makefile.am python/tests/tstLastError.py: applied + patch from Stephane Bidoul for structured error handling from + python, and the associated test + +Tue Jan 6 23:18:11 HKT 2004 William Brack + + * configure.in: fixed Bug130593 + * xmlwriter.c: fixed compilation warning + +Tue Jan 6 15:15:23 CET 2004 Daniel Veillard + + * include/libxml/xmlstring.h: fixed the comment in the header + * doc/*: rebuilt the docs + +Tue Jan 6 19:40:04 HKT 2004 William Brack + + * encoding.c, parser.c, xmlstring.c, Makefile.am, + include/libxml/Makefile.am, include/libxml/catalog.c, + include/libxml/chvalid.h, include/libxml/encoding.h, + include/libxml/parser.h, include/libxml/relaxng.h, + include/libxml/tree.h, include/libxml/xmlwriter.h, + include/libxml/xmlstring.h: + moved string and UTF8 routines out of parser.c and encoding.c + into a new module xmlstring.c with include file + include/libxml/xmlstring.h mostly using patches from Reid + Spencer. Since xmlChar now defined in xmlstring.h, several + include files needed to have a #include added for safety. + * doc/apibuild.py: added some additional sorting for various + references displayed in the APIxxx.html files. Rebuilt the + docs, and also added new file for xmlstring module. + * configure.in: small addition to help my testing; no effect on + normal usage. + * doc/search.php: added $_GET[query] so that persistent globals + can be disabled (for recent versions of PHP) + +Mon Jan 5 20:47:07 MST 2004 John Fleck + + * doc/tutorial/customfo.xsl + * doc/tutorial/customhtml.xsl + update custom tutorial-building stylesheets in preparation + for tutorial update + +Tue Jan 6 00:10:33 CET 2004 Daniel Veillard + + * rngparser.c: commiting the compact relax ng parser. It's not + completely finished, it's not integrated but I want to save the + current state + +Mon Jan 5 22:22:48 HKT 2004 William Brack + + * doc/apibuild.py, doc/APIconstructors.html, doc/libxml2-refs.xml, + win32/libxml2.def.src: fixed apibuild.py's generation of + "constructors" to be in alphabetical order (instead of previous + random sequence); regenerated resulting files. + +Mon Jan 5 14:03:59 CET 2004 Daniel Veillard + + * xmlwriter.c: applied patch from Lucas Brasilino fixing an indent + problem. + +Sun Jan 4 18:54:29 MST 2004 John Fleck + + * doc/newapi.xsl: change background color of function + declaration to improve readability + * doc/*: rebuild docs with new stylesheet + +Sun Jan 4 22:45:14 HKT 2004 William Brack + + * parser.c, include/libxml/parser.h: added a routine + xmlStrncatNew to create a new string from 2 frags. + * tree.c: added code to check if node content is from + dictionary before trying to change or concatenate. + +Sun Jan 4 08:57:51 HKT 2004 William Brack + + * xmlmemory.c: applied suggestion from Miloslav Trmac (see + Bug 130419) and eliminated xmlInitMemoryDone. More + improvement needed. + * xml2-config.in: added an additional flag (--exec-prefix) to + allow library directory to be different from include directory + (Bug 129558). + +Fri Jan 2 21:22:18 CET 2004 Daniel Veillard + + * error.c: applied patch from Stéphane Bidoul for structured error + reporting. + +Fri Jan 2 21:03:17 CET 2004 Daniel Veillard + + * include/libxml/xmlwriter.h xmlwriter.c: applied the patch from + Lucas Brasilino to add indentation support to xmlWriter + +Fri Jan 2 22:58:29 HKT 2004 William Brack + + * xinclude.c: fixed problem with "recursive" include (fallback + contains another include - Bug 129969) + +Fri Jan 2 11:40:06 CET 2004 Daniel Veillard + + * SAX2.c: found and fixed a bug misallocating some non + blank text node strings from the dictionnary. + * xmlmemory.c: fixed a problem with the memory debug mutex + release. + +Wed Dec 31 22:02:37 HKT 2003 William Brack + + * xinclude.c: fixed problem caused by wrong dictionary + reference count, reported on the list by Christopher + Grayce. + +Wed Dec 31 15:55:55 HKT 2003 William Brack + + * python/generator.py, python/libxml2class.txt: fixed problem + pointed out by Stéphane Bidoul on the list. + * xinclude.c, xpointer.c, xpath.c, include/libxml/xpointer.h: + completed modifications required to fix Bug 129967 (at last!). + Now wait to see how long before further trouble... + +Tue Dec 30 16:26:13 HKT 2003 William Brack + + * parser.c, xmlmemory.c, include/libxml/xmlmemory.h: Fixed + memory leak reported by Dave Beckett + * xmlschemas.c: Removed spurious comment reported on the mailing + list + * xinclude.c, xpath.c, xpointer.c, libxml/include/xpointer.h: + Further work on Bug 129967 concerning xpointer range handling + and range-to function; much better, but still not complete + +Mon Dec 29 18:08:05 CET 2003 Daniel Veillard + + * valid.c: xmlValidateElement could crash for element holding a + namespace declaration but not in a namespace. Oliver Fischer + provided the example. + +Mon Dec 29 11:29:31 CET 2003 Daniel Veillard + + * xmllint.c: issue validation status on stderr, not stdout as suggested + by Pawel Palucha + * result/relaxng/*: this change slightly all the output from RNG + regressions. + +Mon Dec 28 10:47:32 HKT 2003 William Brack + + * xmlschemas.c: edited a couple of comments in accordance with + posting on the mailing list (no logic change) + * xpointer.c: working on Bug 129967, added check for NULL + nodeset to prevent crash. Further work required. + * xpath.c: working on Bug 129967, added code to handle + XPATH_LOCATIONSET in RANGETO code, also added code to + handle it in xmlXPathEvaluatePredicateResult. Further + work required. + +Sat Dec 27 12:32:58 HKT 2003 William Brack + + * xmlschemas.c: added tests for xs:all to assure minOccurs + and maxOccurs <= 1 (Bug 130020) + +Sat Dec 27 09:53:06 HKT 2003 William Brack + + * xmlregexp.c: fixed xmlFAParseCharRange for Unicode ranges + with patch from Charles Bozeman. + +Fri Dec 26 14:03:41 HKT 2003 William Brack + + * xmlregexp.c: fixed problem causing segfault on validation error + condition (reported on mailing list) + +Thu Dec 25 21:16:22 HKT 2003 William Brack + + * xmlschemas.c: fixed missing dictionaries for Memory and Doc + parser contexts (problem reported on mailing list) + * doc/apibuild.py: small change to prevent duplicate lines + on API functions list. It will take effect the next time + the docs are rebuilt. + +Wed Dec 24 12:54:25 CET 2003 Daniel Veillard + + * configure.in NEWS doc/*: updated the docs and prepared a new + release 2.6.4 + +Wed Dec 24 12:07:52 CET 2003 Daniel Veillard + + * legacy.c: remove deprecated warning on startElement() + +Wed Dec 24 12:04:35 CET 2003 Daniel Veillard + + * xinclude.c result/XInclude/nodes2.*: XInclude xpointer support + was broken with the new namespace. Fixes #129932 + +Wed Dec 24 00:29:30 CET 2003 Daniel Veillard + + * xmlschemas.c include/libxml/schemasInternals.h: types might be + redefined in includes, quick fix to allow this but lacks the + equality of the redefinition test. + +Tue Dec 23 15:14:37 HKT 2003 William Brack + + * valid.c: fixed bug concerning validation using external + dtd of element with mutiple namespace declarations + (Bug 129821) + +Tue Dec 23 11:41:42 HKT 2003 William Brack + + * tree.c: inhibited production of "(null):" in xmlGetNodePath + when node has default namespace (Bug 129710) + +Tue Dec 23 09:29:14 HKT 2003 William Brack + + * xpath.c: small enhancement to xmlXPathCmpNodes to assure + document order for attributes is retained (Bug 129331) + +Mon Dec 22 19:06:16 CET 2003 Daniel Veillard + + * parser.c xmlreader.c: change xmlReadFd() xmlCtxtReadFd() + xmlReaderNewFd() xmlReaderForFd(), change those to not close + the file descriptor. Updated the comment, should close #129683 + +Mon Dec 22 00:34:09 CET 2003 Daniel Veillard + + * xinclude.c: fixed a serious problem in XInclude #129021 + +Sun Dec 21 13:59:54 CET 2003 Daniel Veillard + + * parser.c: fixed bug #129489, propagation of parsing flags + in entities. + * parser.c xmlreader.c: improved the comments of parsing options + +Sun Dec 21 18:14:04 HKT 2003 William Brack + + * python/Makefile.am, python/tests/Makefile.am, + doc/Makefile.am: applied fixes to allow build from + 'outside' directory (Bug 129172) + +Sat Dec 20 16:42:07 MST 2003 John Fleck + + * tree.c - add explanation of namespace inheritance when + ns is NULL to xmlNewChild and xmlNewTextChild API doc + +Sat Dec 20 18:17:28 HKT 2003 William Brack + + * include/libxml/xpathInternals.h: undid last change (my + bad). Put necessary fix in libxslt/libexslt instead. + * include/libxml/DOCBparser.h: put test for __GCC__ on + warning directive (Bug 129105) + +Sat Dec 20 10:48:37 HKT 2003 William Brack + + * include/libxml/xpathInternals.h: fixed xmlXPathReturnString + to cater for NULL pointer (bug 129561) + * globals.c: added comment to suppress documentation warning + * doc/apibuild.py: fixed problem which caused last APIchunkxx.html + to be lost. Rebuilt doc/* (including adding APIchunk26.html) + +Fri Dec 19 18:24:02 CET 2003 Daniel Veillard + + * xmlreader.c: trying to fix #129692 xmlTextReaderExpand() when + using an xmlReaderWalker() + +Thu Dec 18 20:10:34 MST 2003 John Fleck + + * tree.c: fix misc. typos in doc comments + * include/libxml/tree.h: elaborate on macro define doc comments + * doc/*: rebuild docs + +Wed Dec 17 16:07:33 CET 2003 Daniel Veillard + + * doc/examples/*: don't call the result files .out but .res as + the Makefiles tend to try generating binaries for .out targets... + +Tue Dec 16 20:53:54 MST 2003 John Fleck + + * doc/html/libxml-pattern.html: - cvs add API docs for new + pattern stuff + +Tue Dec 16 20:40:40 MST 2003 John Fleck + + * tree.c + * doc/*: + Elaborate in documentation discussion of xmlNewChild + and xmlNewTextChild. Thanks to Steve Lenti for pointing + out the usefulness of a more explicit explanation of the + reserved character escaping issue. + +Fri Dec 12 15:55:15 CET 2003 Daniel Veillard + + * xmlcatalog.c: applied patch from Stefan Kost + +Thu Dec 11 15:15:31 CET 2003 Daniel Veillard + + * doc/examples/testWriter.c: applied small fix from Lucas Brasilino + +Thu Dec 11 14:55:22 CET 2003 Igor Zlatkovic + + * win32/Makefile.* win32/configure.js: Added pattern support + +Wed Dec 10 14:11:20 CET 2003 Daniel Veillard + + * configure.in doc/* libxml.spec.in: preparing release of + libxml2-2.6.3, updated and regenerated the docs. + +Wed Dec 10 11:43:33 CET 2003 Daniel Veillard + + * SAX2.c pattern.c: removed some compilation warnings + +Wed Dec 10 11:16:29 CET 2003 Daniel Veillard + + * xmllint.c: fixing bug #119264 xmllint failing to report + serialization errors in some cases. + +Tue Dec 9 23:50:23 CET 2003 Daniel Veillard + + * entities.c: fixed an XML entites content serialization + potentially triggered by XInclude, see #126817 + +Tue Dec 9 16:12:50 CET 2003 Daniel Veillard + + * xmlwriter.c: applied the patch to xmlTextWriterStartPI() + suggested by Daniel Schulman in #128313 + +Tue Dec 9 15:18:32 CET 2003 Daniel Veillard + + * configure.in Makefile.am: another patch from Kenneth Haley + for Mingw, c.f. #128787 + +Tue Dec 9 15:07:09 CET 2003 Daniel Veillard + + * include/libxml/xmlexports.h: applied patch from Kenneth Haley + for compiling on Mingw see #128786 + +Tue Dec 9 14:52:59 CET 2003 Daniel Veillard + + * xmllint.c: some flags were not passed down correctly as + parsing options. Fixes #126806 + +Tue Dec 9 12:29:26 CET 2003 Daniel Veillard + + * xinclude.c xmllint.c xmlreader.c include/libxml/xinclude.h + include/libxml/xmlerror.h: augmented the XInclude API + to be able to pass XML parser flags down to the Inclusion + process. Also resynchronized with the Last Call W3C Working + Draft 10 November 2003 for the xpointer attribute. + * Makefile.am test/XInclude/docs/nodes[23].xml + result/XInclude/*: augmented the tests for the new namespace and + testing the xpointer attribute, changed the way error messages + are tested + * doc/*: regenerated the documentation + +Mon Dec 8 18:38:26 CET 2003 Daniel Veillard + + * error.c: filter warning messages if the global setting blocks them + * xinclude.c xmlreader.c include/libxml/xinclude.h + include/libxml/xmlerror.h: updated the change of namespace at + the XInclude level, raise a warning if the old one is found, + and some cleanup + +Mon Dec 8 13:09:39 CET 2003 Daniel Veillard + + * tree.c: tentative fix for #126117 character reference in + attributes output problem in some cornercase. + +Mon Dec 8 11:08:45 CET 2003 Daniel Veillard + + * python/libxml.py: tried to fix the problems reported in + bug #126735 + * xpath.c SAX2.c error.c parser.c valid.c include/libxml/xmlerror.h: + fixed again some problem trying to use the structured error + handlers, c.f. bug #126735 + * result/VC/ElementValid: tiny change due to the fix + +Sun Dec 7 22:27:31 CET 2003 Daniel Veillard + + * error.c: fixed __xmlRaiseError to use structured error handlers + defined by xmlSetStructuredErrorFunc(), fixes bug #126211 + +Sun Dec 7 20:30:53 CET 2003 Daniel Veillard + + * parser.c: attempt to fix #126211 ... + +Fri Dec 5 17:07:29 CET 2003 Daniel Veillard + + * pattern.c xmlreader.c xmllint.c include/libxml/pattern.h + include/libxml/xmlreader.h: fixed the pattern interfaces + but not yet the parser to handle the namespaces. + * doc/examples/reader3.c doc/*: fixed the example, rebuilt the docs. + +Fri Dec 5 15:49:44 CET 2003 Daniel Veillard + + * globals.c xmlwriter.c doc/apibuild.py include/libxml/globals.h + include/libxml/pattern.h include/libxml/schemasInternals.h + include/libxml/xmlexports.h include/libxml/xmlwriter.h: cleanup + the make rebuild in doc, this include new directive to stop + documentation warnings + * doc/* doc/html/*: rebuilt the docs + * pattern.c xmlreader.c include/libxml/pattern.h + include/libxml/xmlreader.h: adding xmlTextReaderPreservePattern() + to save nodes while scanning the tree with the reader, cleanup + the way element were freed, and xmlTextReaderPreserve() + implementation, the API might change for namespace binding support + when compiling patterns. + * doc/examples/*: added reader3.c exposing the xmlTextReaderPreserve() + +Thu Dec 4 15:10:57 CET 2003 Daniel Veillard + + * python/libxml.py: oops forgot to modify/commit the new code. + +Thu Dec 4 13:29:19 CET 2003 Daniel Veillard + + * python/generator.py python/libxml.c python/libxml_wrap.h: + cleanup the output buffer support to at least get the basic + to work + * python/tests/outbuf.py python/tests/serialize.py: fixes and + cleanup. + * include/libxml/xmlwriter.h: cleanup + +Wed Dec 3 21:38:56 MST 2003 John Fleck + + * include/libxml/xmlversion.h.in + * doc/*: add WITH_TRIO comment so it shows up in the docs, rebuild + docs + +Wed Dec 3 13:10:08 CET 2003 Daniel Veillard + + * config.h.in configure.in xmlregexp.c: fix bug #128401 affecting + regexp quantifiers + +Tue Dec 2 23:29:56 CET 2003 Daniel Veillard + + * pattern.c include/libxml/pattern.h: adding the pattern node + selection code. Inheried in part from libxslt but smaller. + * Makefile.am configure.in include/libxml/xmlversion.h.in: + integrated the pattern module, made it a configure time option + * xmllint.c: added --pattern to test when doing --stream + +Tue Dec 2 11:25:25 CET 2003 Daniel Veillard + + * xmlreader.c: fixed a problem in xmlreader validation when + streaming exposed by reader2 example. + +Mon Dec 1 20:40:51 MST 2003 John Fleck + + * doc/xml.html + * doc/docs.html: + add reference to the Code Examples page to docs.html list + of resources + +Mon Dec 1 12:30:28 CET 2003 Igor Zlatkovic + + * win32/Makefile.bcb win32/configure.js: Applied the BCB patch + from Eric + +Sun Nov 30 21:33:37 MST 2003 John Fleck + + * include/libxml/xinclude.h + * doc/*: Add comments for macro definitions in xinclude.h and + rebuild the docs + +Sun Nov 30 21:06:29 MST 2003 John Fleck + + * doc/docdescr.doc + Updating William's explanation of how to build docs, + reflecting Daniel's new docs build system + +Sat Nov 29 18:38:22 HKT 2003 William Brack + + * xmlmemory.c: enhanced by adding mutex to protect global + structures in a multi-threading environment. This fixed + some random errors on the Threads regression tests. + +Fri Nov 28 21:39:49 MST 2003 John Fleck + + * doc/xml.html doc/python.html: fix tst.py text, which didn't + import sys + +Fri Nov 28 17:28:47 HKT 2003 William Brack + + * encoding.c, include/libxml/encoding.h: Enhanced the handling of + UTF-16, UTF-16LE and UTF-16BE encodings. Now UTF-16 output is + handled internally by default, with proper BOM and UTF-16LE + encoding. Native UTF-16LE and UTF-16BE encoding will not generate + BOM on output, and will be automatically recognized on input. + * test/utf16lebom.xml, test/utf16bebom.xml, result/utf16?ebom*: + added regression tests for above. + +Thu Nov 27 19:25:10 CET 2003 Igor Zlatkovic + + * win32/Makefile.* win32/configure.js: Modified to allow coexistent + build with all compilers. Added C-Runtime option for MSVC. Included + xmlWriter. + * xmlwriter.c: Added IN_LIBXML macro + +Wed Nov 26 21:54:01 CET 2003 Igor Zlatkovic + + * win32/Makefile.bcb: applied patch from Eric + +Wed Nov 26 21:33:14 CET 2003 Daniel Veillard + + * include/libxml/tree.h: stefan on IRC pointed out that XML_GET_LINE + is broken on 2.6.x + +Tue Nov 25 18:39:44 CET 2003 Daniel Veillard + + * entities.c: fixed #127877, never output " in element content + * result/isolat3 result/slashdot16.xml result/noent/isolat3 + result/noent/slashdot16.xml result/valid/REC-xml-19980210.xml + result/valid/index.xml result/valid/xlink.xml: this changes the + output of a few tests + +Tue Nov 25 16:36:21 CET 2003 Daniel Veillard + + * include/libxml/schemasInternals.h include/libxml/xmlerror.h + testSchemas.c xmlschemas.c: added xsd:include support, fixed + testSchemas behaviour when a schemas failed to parse. + * test/schemas/vdv-* result/schemas/vdv-first5_0_0*: added one + test for xsd:include from Eric Van der Vlist + +Tue Nov 25 08:18:12 CET 2003 Daniel Veillard + + * parser.c: swapped the attribute defaulting and attribute checking + parts of parsing a new element start, fixes bug #127772 + * result/valid/127772.* test/valid/127772.xml + test/valid/dtds/127772.dtd: added the example in the regression tests + +Tue Nov 25 08:00:15 CET 2003 Daniel Veillard + + * parser.c: moved xmlCleanupThreads() to the end of xmlCleanupParser() + to avoid bug #127851 + +Mon Nov 24 15:26:21 CET 2003 Daniel Veillard + + * xmlregexp.c: fixing some Negative Character Group and + Character Class Subtraction handling. + +Mon Nov 24 14:01:57 CET 2003 Daniel Veillard + + * xmlregexp.c xmlschemas.c: more XML Schemas fixes based + on Eric van der Vlist examples + * result/schemas/vdv-first4* test/schemas/vdv-first4*: + added regression tests + * doc/examples/Makefile.am doc/examples/index.py: do not + regenerate the index on make all target, but only on + make rebuild to avoid troubles. + +Sat Nov 22 21:35:42 CET 2003 Daniel Veillard + + * xmlschemas.c xmlschemastypes.c include/libxml/xmlerror.h + include/libxml/schemasInternals.h: lot of bug fixes, cleanup, + starting to add proper namespace support too. + * test/schemas/* result/schemas/*: added a number of tests + fixed the result from some regression tests too. + +Fri Nov 21 20:50:59 MST 2003 John Fleck + + * doc/xml.html, docs.html: remove reference to gtk-doc now that + Daniel has removed it, fix link to George's IBM article, other + minor edits + +Fri Nov 21 01:26:00 CET 2003 Daniel Veillard + + * xmlschemas.c: applied patch from Robert Stepanek to start + import os schemas support, cleaned up stuff and the patch. + * test/schemas/import0_0.* result/schemas/import0_0_0*: added test + to regression, fixed a few regressions too. + +Thu Nov 20 22:58:00 CET 2003 Daniel Veillard + + * HTMLparser.c: applied two parsing fixes from James Bursa + +Thu Nov 20 19:20:46 CET 2003 Daniel Veillard + + * doc/examples/*: added two xmlReader examples + * xmlreader.c: cleaned up some bugs in the process + +Thu Nov 20 12:54:30 CET 2003 Daniel Veillard + + * xmlwriter.c include/libxml/xmlwriter.h: applied patch from + Alfred Mickautsch, bugfixes and comments + * doc/examples/*: added his test as the xmlWriter example + * doc/html/ doc/*.html: this resulted in some improvements + * include/libxml/hash.h: fixed an inclusion problem when + wasn't preceeded by + +Wed Nov 19 17:19:35 CET 2003 Daniel Veillard + + * xinclude.c: fix an error message + * doc/examples/*: added tree2 example from Lucas Brasilino + +Wed Nov 19 17:50:47 HKT 2003 William Brack + + * doc/newapi.xsl: improve the sort sequence for page content + * doc/html/*.html: regenerate the web pages + +Wed Nov 19 00:48:56 CET 2003 Daniel Veillard + + * Makefile.am: do not package cvs versioning temp files. + * doc/apibuild.py doc/libxml2-api.xml doc/newapi.xsl: more cleanup, + slightly improved the API xml format, fixed a lot of small + rendering problems + * doc/html/libxml*.html: rebuilt + +Tue Nov 18 21:51:15 CET 2003 Daniel Veillard + + * include/libxml/*.h include/libxml/*.h.in: modified the file + header to add more informations, painful... + * genChRanges.py genUnicode.py: updated to generate said changes + in headers + * doc/apibuild.py: extract headers, add them to libxml2-api.xml + * *.html *.xsl *.xml: updated the stylesheets to flag geprecated + APIs modules. Updated the stylesheets, some cleanups, regenerated + * doc/html/*.html: regenerated added back book1 and libxml-lib.html + +Tue Nov 18 14:43:16 CET 2003 Daniel Veillard + + * doc/Makefile.am doc/*.xsl doc/*.html doc/apibuild.py: cleaned up + the build process to remove all remains from the old gtk-doc + inherited, libxml2-refs.xml is now generated by apibuild.py, the + stylesheets have been improved, and the API*html now generated + are XHTML1 valid too + +Tue Nov 18 14:28:32 HKT 2003 William Brack + + * genChRanges.py, chvalid.c, include/libxml/chvalid.h: minor + enhancement to prevent comment with unreferenced variable. + * threads.c xmlreader.c xmlwriter.c: edited some comments to + improve auto-generation of documentation + * apibuild.py: minor change to an error message + +Mon Nov 17 17:55:51 CET 2003 Daniel Veillard + + * doc/apibuild.py doc/libxml2-api.xml doc/newapi.xsl: more cleanup, + improving navigation + * doc/html/*.html: updated the result + +Mon Nov 17 14:54:38 CET 2003 Daniel Veillard + + * doc/Makefile.am doc/apibuild.py doc/libxml2-api.xml doc/newapi.xsl: + improvement of the stylesheets, fixed a API generation problem, + switched the stylesheet and Makefile to build the HTML output. + * doc/html/*.html: complete update, ditched some old files, might + introduce some breakage... + +Mon Nov 17 12:50:28 CET 2003 Daniel Veillard + + * doc/newapi.xsl: lot of improvements, this starts looking good + enough to be usable. + +Mon Nov 17 00:58:09 CET 2003 Daniel Veillard + + * doc/newapi.xsl: stylesheet to build HTML pages from the + API XML description, Work in Progress + +Sun Nov 16 16:03:24 HKT 2003 William Brack + + * xpath.c: fixed bug 126976 (string != empty nodeset + should be false) + +Sun Nov 16 14:00:08 HKT 2003 William Brack + + * doc/html/*.html: Finally - found the problem with the + page generation (XMLPUBFUN not recognized by gtkdoc). + Re-created the pages using a temporary version of + include/libxml/*.h. + * testOOMlib.c,include/libxml/encoding.h, + include/libxml/schemasInternals.h,include/libxml/valid.h, + include/libxml/xlink.h,include/libxml/xmlwin32version.h, + include/libxml/xmlwin32version.h.in, + include/libxml/xpathInternals.h: minor edit of comments + to help automatic documentation generation + * doc/docdescr.doc: small elaboration + * doc/examples/test1.c,doc/examples/Makefile.am: re-commit + (messed up on last try) + * xmlreader.c: minor change to clear warning. + +Sat Nov 15 19:20:32 CET 2003 Daniel Veillard + + * Copyright: fixed some wording + * libxml.spec.in: make sure doc/examples is packaged + * include/libxml/tree.h valid.c xmlreader.c: fixed the really + annoying problem about xmlRemoveID and xmlReader streaming. + Thing looks fixed now, had to add a doc reference to the + xmlID structure though... + +Sat Nov 15 09:53:36 MST 2003 John Fleck + + * doc/docdescr.doc: added description of man page building + +Sat Nov 15 19:08:22 HKT 2003 William Brack + + * doc/html/libxml-chvalid.html, doc/html/libxml-dict.html, + doc/html/libxml-list.html, doc/html/libxml-testOOMlib.html, + doc/html/libxml-wincecompat, doc/html/winsockcompat.html, + doc/html/libxml-xmlexports.html, doc/html/libxml-xmlversion.html, + doc/html/libxml-xmlwin32version.html, doc/html/libxml-xmlwriter.html: + added missing pages for the website. + +Sat Nov 15 18:23:48 HKT 2003 William Brack + + * doc/Makefile.am doc/*.html doc/html/*.html: rebuilt the + generated pages (again), manually restored doc/html/index.html + and manually edited generated file doc/gnome-xml.xml to put + in appropriate headings. + * doc/docdescr.doc: new file to describe details of the + document generation (helps my memory for the next time) + * genChRanges.py,chvalid.c,include/libxml/chvalid.h: minor + enhancement to please the automatic documentation generation. + +Fri Nov 14 23:47:31 HKT 2003 William Brack + + * catalog.c,relaxng.c,testAutomata.c,xpointer.c,genChRanges.py, + chvalid.c,include/libxml/chvalid.h,doc/examples/test1.c: + minor error cleanup for gcc-3.3.[12] compilation warnings. + +Fri Nov 14 15:08:13 HKT 2003 William Brack + + * tree.c: minor changes to some comments + * doc/*.html: rebuilt the generated HTML pages for changes + from jfleck (bug 126945) + +Thu Nov 13 12:44:14 CET 2003 Daniel Veillard + + * doc/examples/*: added Dodji's example, added output handling + +Thu Nov 13 11:35:35 CET 2003 Daniel Veillard + + * doc/examples/*: added Aleksey XPath example, fixed bugs + in the indexer + +Wed Nov 12 23:48:26 CET 2003 Daniel Veillard + + * doc/*: integrating the examples in the navigation menus + * doc/examples/*: added make tests, updated the navigation, + added a new test, cleanups, updates. + +Wed Nov 12 17:50:36 CET 2003 Daniel Veillard + + * doc/*.html: rebuilt the generated HTML pages + * doc/examples/*: updated the stylesheets, added a synopsis, + Makefile.am is now generated by index.py + +Wed Nov 12 01:38:16 CET 2003 Daniel Veillard + + * doc/site.xsl doc/examples/Makefile.am doc/examples/index.html: + added autogeneration of a web page for the examples + * doc/examples/example1.c doc/examples/.cvsignore + doc/examples/examples.xml doc/examples/index.py: updated the + informations extracted, improved the format and indexing. + +Tue Nov 11 22:08:59 CET 2003 Daniel Veillard + + * check-xinclude-test-suite.py: less verbose on difference + * libxml.spec.in: cleanup + * parser.c: fixed xmlCleanupParser() doc + * doc/Makefile.am doc/apibuild.py doc/libxml2-api.xml + doc/examples/Makefile.am doc/examples/example1.c + doc/examples/examples.xml doc/examples/index.py + doc/examples/test1.xml: work on adding C examples and + generating automated information about those. examples.xml + is autogenerated describing the examples. + * example/Makefile.am: cleanup + +Mon Nov 10 23:47:03 HKT 2003 William Brack + + * genUnicode.py, xmlunicode.c, include/libxml/xmlunicode.h: + fixed missing '-' in block names, enhanced the hack for + ABI aliasing. + +Sun Nov 9 20:28:21 HKT 2003 William Brack + + * genUnicode.py, xmlunicode.c, include/libxml/xmlunicode.h, + python/libxml2class.txt: enhanced for range checking, + updated to Unicode version 4.0.1 (API docs also updated) + * python/generator.py: minor change to fix a warning + +Wed Nov 5 23:46:36 CET 2003 Daniel Veillard + + * Makefile.am: apply fix from Karl Eichwalder for script path + +Wed Nov 5 10:49:20 CET 2003 Daniel Veillard + + * win32/configure.js: applied patch from Mark Vakoc to simplify + his work from CVS checkouts. + +Tue Nov 4 21:16:47 MST 2003 John Fleck + + * doc/xmlreader.html: minor cleanups + +Tue Nov 4 15:52:28 PST 2003 William Brack + + * include/libxml/xmlversion.h.in: changed macro ATTRIBUTE_UNUSED + for gcc so that, if undefined, it's defined as + __attribute__((unused)) + +Tue Nov 4 15:28:07 PST 2003 William Brack + + * python/generator.py: small enhancement to assure ATTRIBUTE_UNUSED + appears after the variable declaration. + * valid.c: trivial change to eliminate a warning message + +Tue Nov 4 11:24:04 CET 2003 Daniel Veillard + + * configure.in NEWS doc/*: preparing release 2.6.2, updated and + rebuilt the docs + +Tue Nov 4 09:38:46 CET 2003 Daniel Veillard + + * xmllint.c: change --html to make sure we use the HTML serialization + rule by default when HTML parser is used, add --xmlout to allow to + force the XML serializer on HTML. + * HTMLtree.c: ugly tweak to fix the output on

element and + solve #125093 + * result/HTML/*: this changes the output of some tests + +Mon Nov 3 17:51:28 CET 2003 Daniel Veillard + + * xinclude.c: fixed bug #125812, about XPointer in XInclude + failing but not returning an error. + +Mon Nov 3 17:18:22 CET 2003 Daniel Veillard + + * valid.c: fixed bug #125811 related to DTD post validation + where the DTD doesn't pertain to a document. + +Mon Nov 3 15:25:58 CET 2003 Daniel Veillard + + * parser.c xmlIO.c include/libxml/parserInternals.h: implemented + the XML_PARSE_NONET parser option. + * xmllint.c: converted xmllint.c to use the option instead of + relying on the global resolver variable. + +Mon Nov 3 13:26:32 CET 2003 Daniel Veillard + + * xinclude.c xmlreader.c include/libxml/xinclude.h: adding XInclude + support to the reader interface. Lot of testing of the walker, + various bug fixes. + * xmllint.c: added --walker and made sure --xinclude --stream --debug + works as expected + * Makefile.am result/dtd11.rdr result/ent6.rdr test/dtd11 test/ent6 + result/XInclude/*.rdr: added regression tests for the walker and + XInclude xmlReader support, had to slightly change a couple of tests + because the walker can't distinguish from + +Sat Nov 1 17:42:27 CET 2003 Daniel Veillard + + * tree.c nanohttp.c threads.c: second BeOS patch from + Marcin 'Shard' Konicki + +Fri Oct 31 15:35:20 CET 2003 Daniel Veillard + + * parser.c: always generate line numbers + +Fri Oct 31 11:53:46 CET 2003 Daniel Veillard + + * parser.c: fixed another regression introduced in fixing #125823 + +Fri Oct 31 11:33:18 CET 2003 Daniel Veillard + + * python/libxml.c: previous fix for #124044 was broken, correct + fix provided. + * HTMLparser.c parser.c parserInternals.c xmlIO.c: fix xmlStopParser() + and the error handlers to address #125877 + +Thu Oct 30 23:10:46 CET 2003 Daniel Veillard + + * parser.c: side effect of #123105 patch, namespace resolution + would fail when defined in internal entities, fixes #125823 + +Thu Oct 30 14:10:42 CET 2003 Daniel Veillard + + * python/libxml.c: be more defensive in the xmlReader python bindings + fixing bug #124044 + +Thu Oct 30 11:14:31 CET 2003 Daniel Veillard + + * valid.c: the a-posteriori DTD validation code was not validating + the namespace declarations, this fixes #124110 + +Wed Oct 29 14:13:03 PDT 2003 William Brack + + * xmlIO.c: enhanced to bypass compression detection code + when input file is stdin (bug 125801) + +Wed Oct 29 18:21:00 CET 2003 Daniel Veillard + + * xmlIO.c: fix needed when HTTP is not compiled in by Mark Vakoc + +Wed Oct 29 18:05:53 CET 2003 Daniel Veillard + + * xpath.c: more fixes about unregistering objects + * include/libxml/relaxng.h: applied patch from Mark Vakoc + missing _cplusplus processing clause + +Wed Oct 29 07:49:52 2003 Aleksey Sanin + + * include/libxml/parser.h parser.c: added xmlStrVPrintf function + +Wed Oct 29 14:37:40 CET 2003 Daniel Veillard + + * nanoftp.c nanohttp.c testThreads.c threads.c: applied patch from + Marcin 'Shard' Konicki to provide BeOS thread support. + +Wed Oct 29 14:20:14 CET 2003 Daniel Veillard + + * xmlschemas.c include/libxml/xmlschemas.h: applied patch + from Steve Ball to make a schema parser from a preparsed document. + +Wed Oct 29 13:52:25 CET 2003 Daniel Veillard + + * tree.c: applied a couple of patches from Mark Lilback about text + nodes coalescing + +Wed Oct 29 12:16:52 CET 2003 Daniel Veillard + + * xpath.c: change suggested by Anthony Carrico when unregistering + a namespace prefix to a context + * hash.c: be more careful about calling callbacks with NULL payloads. + +Wed Oct 29 00:04:26 CET 2003 Daniel Veillard + + * configure.in NEWS doc/*: preparing release 2.6.1, updated and + regenerated docs and APIs + * parser.c: cleanup and last change to fix #123105 + +Tue Oct 28 23:02:29 CET 2003 Daniel Veillard + + * HTMLparser.c: Fix #124907 by simply backporting the same + fix as for the XML parser + * result/HTML/doc3.htm.err: change to ID detecting modified one + test result. + +Tue Oct 28 22:28:50 CET 2003 Daniel Veillard + + * parser.c include/libxml/parser.h: included a new function + to reuse a Push parser context, based on Graham Bennett original + code + * valid.c: in HTML, a name in an input is not an ID + * TODO: bug list update + +Tue Oct 28 19:54:37 CET 2003 Daniel Veillard + + * xpath.c: applied patch from nico@xtradyne.com for #125030 + +Tue Oct 28 16:42:16 CET 2003 Daniel Veillard + + * Makefile.am: cleanup + * error.c valid.c include/libxml/xmlerror.h: fixing bug #125653 + sometimes the error handlers can get a parser context on DTD + errors, and sometime they don't. So be very careful when trying + to grab those informations. + +Tue Oct 28 15:26:18 CET 2003 Daniel Veillard + + * tree.c: applied patch from Kasimier Buchcik which fixes a + problem in xmlSearchNs introduced in 2.6.0 + +Tue Oct 28 14:57:03 CET 2003 Daniel Veillard + + * parser.c: fixed #123263, the encoding is mandatory in a textdecl. + +Tue Oct 28 13:48:52 CET 2003 Daniel Veillard + + * tree.c: fix bug #125047 about serializing when finding a + document fragment node. + +Mon Oct 27 11:11:29 EST 2003 Daniel Veillard + + * testSAX.c: fix bug #125592 need a NULL check + * include/libxml/chvalid.h: rename a parameter + +Mon Oct 27 09:43:48 EST 2003 Daniel Veillard + + * parser.c: applied patch from #123105 about defaulted attributes + from element coming from an entity + +Mon Oct 27 21:12:27 HKT 2003 William Brack + + * xmllint.c: fixed warning message from IRIX (bug 125182) + * python/libxml.py: removed tabs, replaced with spaces + (bug 125572) + +Mon Oct 27 06:17:30 EST 2003 Daniel Veillard + + * libxml.h parserInternals.c xmlIO.c: make sure we report errors + if xmlNewInputFromFile() fails. + * xmlreader.c: avoid using _private for the node or document + elements. + +Sat Oct 25 17:33:59 CEST 2003 Igor Zlatkovic + + * win32/configure.js: added declaration for verMicroSuffix + +Fri Oct 24 23:08:17 CEST 2003 Daniel Veillard + + * libxml.m4: applied patch from Patrick Welche provided in + bug #125432 , future proofing the .m4 file. + * parser.c: resetting the context should also reset the error + * TODO: problem of conformance w.r.t. E20 was raised in the + XML Core telconf and libxml2 isn't conformant there. + +Wed Oct 22 14:33:05 CEST 2003 Daniel Veillard + + * xmlwriter.c: applied patch from Alfred Mickautsch fixing #125180 + +Wed Oct 22 10:50:31 CEST 2003 Daniel Veillard + + * chvalid.c genChRanges.py: Stephane Bidoul pointed out another + small glitch missing a const + +Wed Oct 22 10:43:21 CEST 2003 Daniel Veillard + + * chvalid.c genChRanges.py: Stephane Bidoul pointed out that + it doesn't define IN_LIBXML + +Tue Oct 21 21:14:55 CEST 2003 Daniel Veillard + + * win32/Makefile.mingw: typo pointed out by Stephane Bidoul + +Tue Oct 21 11:26:36 CEST 2003 Daniel Veillard + + * win32/Makefile.bcb win32/Makefile.mingw win32/Makefile.msvc + win32/configure.js: set of Win32 patches for 2.6.0 by Joachim Bauch + +Tue Oct 21 02:07:22 CEST 2003 Daniel Veillard + + * tree.c: last minute patch from Eric Zurcher making it into 2.6.0 + +Tue Oct 21 02:03:03 CEST 2003 Daniel Veillard + + * configure.in NEWS doc/libxml2.xsa: preparing libxml2-2.6.0 + * doc/*: updated and regenerated the docs and API + +Tue Oct 21 01:01:55 CEST 2003 Daniel Veillard + + * SAX2.c error.c tree.c: moved the line number to their proper + field in elements now. + +Tue Oct 21 00:28:20 CEST 2003 Daniel Veillard + + * configure.in xmlwriter.c Makefile.am include/libxml/xmlwriter.h + include/libxml/Makefile.am include/libxml/xmlversion.h.in: + added the xmlWriter module contributed by Alfred Mickautsch + * include/libxml/tree.h: added room for line and extra information + * xmlreader.c python/tests/reader6.py: bugfixing some problem some + of them introduced in September + * win32/libxml2.def.src doc/libxml2-api.xml: regenerated the API + +Mon Oct 20 19:02:53 CEST 2003 Daniel Veillard + + * Makefile.am configure.in xmldwalk.c xmlreader.c + include/libxml/Makefile.am include/libxml/xmldwalk.h + include/libxml/xmlversion.h.in: removing xmldwalk module + since it got merged with the xmlreader. + * parser.c: cleanup + * win32/libxml2.def.src python/libxml2class.txt doc/libxml2-api.xml: + rebuilt the API + * python/tests/Makefile.am python/tests/reader7.py + python/tests/walker.py: adding regression testing for the + new xmlreader APIs, new APIs for reader creation, including + makeing reader "walker" operating on preparsed document trees. + +Sun Oct 20 22:37:03 HKT 2003 William Brack + + * entities.c, valid.c: fixed problem reported on the mailing + list by Melvyn Sopacua - wrong argument order on functions + called through xmlHashScan. + +Sun Oct 19 23:57:45 CEST 2003 Daniel Veillard + + * valid.c xmlIO.c: fixes for compiling using --with-minimum + +Sun Oct 19 23:46:04 CEST 2003 Daniel Veillard + + * tree.c: cleanup xmlNodeGetContent() reusing xmlNodeBufGetContent(), + tested it through the xslt regression suite. + +Sun Oct 19 22:42:16 CEST 2003 Daniel Veillard + + * tree.c include/libxml/tree.h: adding xmlNodeBufGetContent() + allowing to grab the content without forcing allocations. + * python/libxml2class.txt doc/libxml2-api.xml: rebuilt the API + * xpath.c xmldwalk.c: removed a couple of comment errors. + +Sun Oct 19 16:39:36 CEST 2003 Daniel Veillard + + * parser.c: applied patch from Chris Anderson to change back + memcmp with CMPx() + +Sun Oct 19 16:24:19 CEST 2003 Daniel Veillard + + * HTMLparser.c: fixed to not send NULL to %s printing + * python/tests/error.py result/HTML/doc3.htm.err + result/HTML/test3.html.err result/HTML/wired.html.err + result/valid/t8.xml.err result/valid/t8a.xml.err: cleaning + up some of the regression tests error + +Sun Oct 19 15:31:43 CEST 2003 Daniel Veillard + + * include/libxml/nanohttp.h include/libxml/parserInternals.h + include/libxml/xmlIO.h nanohttp.c parserInternals.c xmlIO.c: + Fixed the HTTP<->parser interraction, which should fix 2 long + standing bugs #104790 and #124054 , this also fix the fact that + HTTP error code (> 400) should not generate data, we usually + don't want to parse the HTML error information instead of the + resource looked at. + +Sun Oct 19 19:20:48 HKT 2003 William Brack + + * doc/Makefile.am: enhanced the installation of tutorial files + to avoid installing CVS subdirectories (bug 122943) + +Sun Oct 19 17:33:27 HKT 2003 William Brack + + * xmlIO.c: fixed segfault when input file not present + * tree.c: changed output formatting of XML_CDATA_SECTION + (bug 120917) + +Sun Oct 19 00:15:38 HKT 2003 William Brack + + * include/libxml/parserInternals.h HTMLparser.c HTMLtree.c + SAX2.c catalog.c debugXML.c entities.c parser.c relaxng.c + testSAX.c tree.c valid.c xmlschemas.c xmlschemastypes.c + xpath.c: Changed all (?) occurences where validation macros + (IS_xxx) had single-byte arguments to use IS_xxx_CH instead + (e.g. IS_BLANK changed to IS_BLANK_CH). This gets rid of + many warning messages on certain platforms, and also high- + lights places in the library which may need to be enhanced + for proper UTF8 handling. + +Sat Oct 18 20:34:18 HKT 2003 William Brack + + * genChRanges.py, chvalid.c, include/libxml/chvalid.h, + doc/apibuild.py: enhanced to include enough comments to + make the api doc generation happy. + +Sat Oct 18 07:28:25 EDT 2003 Daniel Veillard + + * nanohttp.c xmlIO.c include/libxml/nanohttp.h: starting work + to fix the HTTP/XML parser integration. + +Sat Oct 18 11:04:32 CEST 2003 Daniel Veillard + + * xmlreader.c include/libxml/xmlreader.h: added new APIs + for creating reader from sources or reusing a reader with + a new source, like the xmlReadxx and xmlCtxtReadxxx + * win32/libxml2.def.src doc/libxml2-api.xml doc/apibuild.py + doc/Makefile.am: regenerated the APIs + * doc/xml.html: applied a patch from Stefan Kost for namesapce docs + +Sat Oct 18 12:46:02 HKT 2003 William Brack + + * genChRanges.py, chvalid.c, include/libxml/chvalid.h, + include/libxml/parserInternals.h: enhanced macros to avoid + breaking ABI from previous versions. + * catalog.c, parser.c, tree.c: modified to use IS_* macros + defined in parserInternals.h. Makes maintenance much easier. + * testHTML.c, testSAX.c, python/libxml.c: minor fixes to avoid + compilation warnings + * configuration.in: fixed pushHTML test error; enhanced for + better devel (me) testing + +Fri Oct 17 14:38:54 CEST 2003 Daniel Veillard + + * legacy.c: remove the warning for startDocument(), as it is used by + glade (or glade-python) + * parser.c relaxng.c xmlschemastypes.c: fixed an assorted set of + invalid accesses found by running some Python based regression + tests under valgrind. There is still a few leaks reported by the + relaxng regressions which need some attention. + * doc/Makefile.am: fixed a make install problem c.f. #124539 + * include/libxml/parserInternals.h: addition of xmlParserMaxDepth + patch from crutcher + +Wed Oct 15 12:47:33 CEST 2003 Daniel Veillard + + * parser.c: Marc Liyanage pointed out that xmlCleanupParser() + was missing xmlCleanupInputCallbacks and xmlCleanupOutputCallbacks + calls. + +Wed Oct 15 10:16:47 CEST 2003 Daniel Veillard + + * vms/build_libxml.com trionan.c: VMS patch from Craig A. Berry + +Mon Oct 13 21:46:25 CEST 2003 Daniel Veillard + + * Makefile.am: small fix from Bjorn Reese + +Mon Oct 13 15:59:25 CEST 2003 Daniel Veillard + + * valid.c: fix a call missing arguments + +Sun Oct 12 18:42:18 HKT 2003 William Brack + + * genChRanges.py, chvalid.c, include/libxml/chvalid.h: fixed + a bug in the range search; enhanced range generation (inline code + if a small number of intervals); enhanced the readability of the + output files. + +Sun Oct 12 00:52:14 CEST 2003 Daniel Veillard + + * chvalid.def chvalid.c include/libxml/chvalid.h: rebuilt + chvalid.def from scratch based on XML 2nd edition REC + and regenerated the code. + +Sat Oct 11 22:54:13 CEST 2003 Daniel Veillard + + * check-xml-test-suite.py: removed some annoying warnings + * chvalid.def chvalid.c include/libxml/chvalid.h: fixed a bug + in the PubidChars definition, regenerated, there is still + a bug left somewhere + * genChRanges.py: save the header directly in include/libxml/ + * configure.in: I generated a 2.6.0beta6 earlier today + +Sat Oct 11 23:32:47 HKT 2003 William Brack + + * fixed small error on previous commit (chvalid.h in + base dir instead of include directory) + +Sat Oct 11 23:11:22 HKT 2003 William Brack + + * genChRange.py, chvalid.def, chvalid.c, include/libxml/chvalid.h: + new files for a different method for doing range validation + of character data. + * Makefile.am, parserInternals.c, include/libxml/Makefile.am, + include/libxml/parserInternals.h: modified for new range method. + * catalog.c: small enhance for warning message (using one + of the new range routines) + +Sat Oct 11 13:24:57 CEST 2003 Daniel Veillard + + * valid.c include/libxml/valid.h: adding an serror field to + the validation context breaks the ABI for the xmlParserCtxt + structure since it's embedded by content and not by reference + +Sat Oct 11 12:46:49 CEST 2003 Daniel Veillard + + * configure.in: patch from Mike Hommey + * threads.c: applied Windows patch from Jesse Pelton and Stephane + Bidoul + * parser.c: fix the potentially nasty access to ctxt->serror + without checking first that the SAX block is version 2 + +Fri Oct 10 21:34:01 CEST 2003 Daniel Veillard + + * SAX2.c: fixed a nasty bug with interning some text strings + * configure.in: prepare for beta5 of 2.6.0 + * libxml.h nanoftp.c nanohttp.c xmlIO.c include/libxml/xmlerror.h: + better error handling for I/O and converted FTP and HTTP + * parser.c: fixed another bug + +Fri Oct 10 16:45:20 CEST 2003 Daniel Veillard + + * SAX2.c: fixed uninitialized new field. + * result/VC/OneID2 result/relaxng/*.err: fixed a typo updating + all messages + +Fri Oct 10 16:19:17 CEST 2003 Daniel Veillard + + * include/libxml/tree.h: make room in Doc, Element, Attributes + for PSVI type informations. + +Fri Oct 10 16:08:02 CEST 2003 Daniel Veillard + + * HTMLparser.c c14n.c catalog.c error.c globals.c parser.c + parserInternals.c relaxng.c valid.c xinclude.c xmlIO.c xmlregexp.c + xmlschemas.c xpath.c xpointer.c include/libxml/globals.h + include/libxml/parser.h include/libxml/valid.h + include/libxml/xmlerror.h: Setting up the framework for structured + error reporting, touches a lot of modules, but little code now + the error handling trail has been cleaned up. + +Fri Oct 10 14:29:42 CEST 2003 Daniel Veillard + + * c14n.c include/libxml/xmlerror.h: converted the C14N module too + +Fri Oct 10 13:40:51 CEST 2003 Daniel Veillard + + * xpath.c: cleanup + * xpointer.c include/libxml/xmlerror.h: migrated XPointer module + to the new error mechanism + +Fri Oct 10 12:49:53 CEST 2003 Daniel Veillard + + * error.c xmlschemas.c: a bit of cleanup + * result/schemas/*.err: updated with the new result strings + +Fri Oct 10 03:58:39 PDT 2003 William Brack + + * xpath.c: fixed bug 124061 + +Fri Oct 10 02:47:22 CEST 2003 Daniel Veillard + + * Makefile.am: cleanup + * encoding.c: fix a funny typo + * error.c xmlschemas.c xmlschemastypes.c include/libxml/xmlerror.h: + converted the Schemas code to the new error handling. PITA, + still need to check output from regression tests. + +Thu Oct 9 15:13:53 CEST 2003 Daniel Veillard + + * HTMLtree.c include/libxml/xmlerror.h: converted too + * tree.c: small cleanup + +Thu Oct 9 13:44:57 CEST 2003 Daniel Veillard + + * xinclude.c: comment fix + * catalog.c include/libxml/xmlerror.h: migrating the catalog code + to the new infrastructure + +Thu Oct 9 00:36:03 CEST 2003 Daniel Veillard + + * xmlIO.c: final error handling cleanup + * xinclude.c error.c: converted XInclude to the new error handling + * include/libxml/xmlerror.h: added XInclude errors + +Wed Oct 8 23:31:23 CEST 2003 Daniel Veillard + + * parser.c: bug in compression saving was crashing galeon + reported by teuf + +Wed Oct 8 21:18:12 CEST 2003 Daniel Veillard + + * error.c tree.c xmlIO.c xmllint.c: more cleanup through the + I/O error path + +Wed Oct 8 20:57:27 CEST 2003 Daniel Veillard + + * xmlIO.c: better handling of error cases + +Wed Oct 8 13:51:14 CEST 2003 Daniel Veillard + + * xmlIO.c xmllint.c include/libxml/xmlerror.h: first pass at + cleaning up error handling in the I/O module. + +Wed Oct 8 10:52:05 CEST 2003 Daniel Veillard + + * xmlregexp.c include/libxml/xmlerror.h: error handling + cleanup of the Regexp module. + +Wed Oct 8 01:09:05 CEST 2003 Daniel Veillard + + * tree.c: converting the tree module too + * error.c include/libxml/xmlerror.h: created a simpler internal + error reporting function. + +Tue Oct 7 23:19:39 CEST 2003 Daniel Veillard + + * error.c include/libxml/xmlerror.h include/libxml/xpath.h + include/libxml/xpathInternals.h xpath.c: cleaning up XPath + error reporting that time. + * threads.c: applied the two patches for TLS threads + on Windows from Jesse Pelton + * parser.c: tiny safety patch for xmlStrPrintf() make sure the + return is always zero terminated. Should also help detecting + passing wrong buffer size easilly. + * result/VC/* result/valid/rss.xml.err result/valid/xlink.xml.err: + updated the results to follow the errors string generated by + last commit. + +Tue Oct 7 14:16:45 CEST 2003 Daniel Veillard + + * relaxng.c include/libxml/xmlerror.h: last cleanup of error + handling in the Relax-NG module. + +Tue Oct 7 13:30:39 CEST 2003 Daniel Veillard + + * error.c relaxng.c include/libxml/xmlerror.h: switched Relax-NG + module to teh new error reporting. Better default report, adds + the element associated if found, context and node are included + in the xmlError + * python/tests/reader2.py: the error messages changed. + * result/relaxng/*: error message changed too. + +Mon Oct 6 10:46:35 CEST 2003 Daniel Veillard + + * win32/Makefile.bcb win32/Makefile.mingw win32/Makefile.msvc + win32/configure.js: applied patch from Stéphane Bidoul to + fix the compilation of 2.6.0 code on Win32 + +Mon Oct 6 10:16:30 CEST 2003 Daniel Veillard + + * check-xml-test-suite.py: fixing the script + * parser.c: replace sequences of RAW && NXT(.) == '.' with + memcmp calls, seems to not break conformance, slightly inflate + the size of the gcc generated code though. + +Sun Oct 5 23:30:48 CEST 2003 Daniel Veillard + + * parserInternals.c parser.c valid.c include/libxml/parserInternals.h: + more cleanup of error handling in parserInternals, sharing the + routine for memory errors. + +Sun Oct 5 15:49:14 CEST 2003 Daniel Veillard + + * HTMLparser.c Makefile.am legacy.c parser.c parserInternals.c + include/libxml/xmlerror.h: more code cleanup, especially around + error messages, the HTML parser has now been upgraded to the new + handling. + * result/HTML/*: a few changes in the resulting error messages + +Sat Oct 4 23:06:41 CEST 2003 Daniel Veillard + + * parser.c include/libxml/xmlerror.h: more error/warning + handling cleanups, the XML parser module should be okay now. + +Sat Oct 4 01:58:27 CEST 2003 Daniel Veillard + + * Makefile.am configure.in xmldwalk.c include/libxml/Makefile.am + include/libxml/xmldwalk.h include/libxml/xmlversion.h.in: + integrated the xmlDocWalker API given by Alfred Mickautsch, + and providing an xmlReader like API but working on a xmlDocPtr. + +Sat Oct 4 00:18:29 CEST 2003 Daniel Veillard + + * Makefile.am: more cleanup in make tests + * error.c valid.c parser.c include/libxml/xmlerror.h: more work + in the transition to the new error reporting strategy. + * python/tests/reader2.py result/VC/* result/valid/*: + few changes in the strings generated by the validation output + +Fri Oct 3 00:19:02 CEST 2003 Daniel Veillard + + * Makefile.am: changed 'make tests' to use a concise output, + scrolling to see where thing broke wasn't pleasant + * configure.in: some beta4 preparation, but not ready yet + * error.c globals.c include/libxml/globals.h include/libxml/xmlerror.h: + new error handling code, last error informations are stored + in the parsing context or a global variable, new APIs to + handle the xmlErrorPtr type. + * parser.c parserInternals.c valid.c : started migrating to the + new error handling code, it's a royal pain. + * include/libxml/parser.h include/libxml/parserInternals.h: + moved the definition of xmlNewParserCtxt() + * parser.c: small potential buffer access problem in push code + provided by Justin Fletcher + * result/*.sax result/VC/PENesting* result/namespaces/* + result/valid/*.err: some error messages were sligthly changed. + +Thu Oct 2 13:01:13 2003 Aleksey Sanin + + * include/libxml/parser.h parser.c: introduced xmlStrPrintf + function (wrapper around snprintf) + +Wed Oct 1 21:12:06 CEST 2003 Daniel Veillard + + * entities.c: Fix error on output of high codepoint charref like + 􏿿 , reported by Eric Hanchrow + +Wed Oct 1 14:20:10 CEST 2003 Daniel Veillard + + * DOCBparser.c include/libxml/DOCBparser.h: let's see how much + of a pain murrayc is really gonna be. + +Wed Oct 1 11:03:40 CEST 2003 Daniel Veillard + + * xmlreader.c: Applied fix for bug #123481 reported by Peter Derr + +Tue Sep 30 15:34:31 CEST 2003 Daniel Veillard + + * entities.c legacy.c parser.c: made the predefined entities + static predefined structures to avoid the work, memory and + hazards associated to initialization/cleanup. + +Tue Sep 30 14:30:47 CEST 2003 Daniel Veillard + + * HTMLparser.c Makefile.am configure.in legacy.c parser.c + parserInternals.c testHTML.c xmllint.c include/libxml/HTMLparser.h + include/libxml/parser.h include/libxml/parserInternals.h + include/libxml/xmlversion.h.in: added a new configure + option --with-push, some cleanups, chased code size anomalies. + Now a library configured --with-minimum is around 150KB, + sounds good enough. + +Tue Sep 30 12:31:00 AEST 2003 Malcolm Tredinnick + + * libxml-2.0-uninstalled.pc.in: New file for building against + uninstalled libxml2 builds. + * configure.in, Makefile.am: Support the *-uninstalled.pc file. + * .cvsignore: Ignore the new generated *.pc file. + +Tue Sep 30 02:38:16 CEST 2003 Daniel Veillard + + * Makefile.am SAX.c SAX2.c configure.in globals.c parser.c + parserInternals.c testReader.c testSAX.c xmlIO.c xmllint.c + xmlreader.c example/gjobread.c include/libxml/xmlversion.h.in: + added 2 new configure option: --with-reader --with-sax1 + to allow removing the reader or non-xmlReadxxx() interfaces. + +Mon Sep 29 19:58:26 CEST 2003 Daniel Veillard + + * configure.in entities.c tree.c valid.c xmllint.c + include/libxml/tree.h include/libxml/xmlversion.h.in: + Adding a configure option to remove tree manipulation + code which is not strictly needed by the parser. + +Mon Sep 29 15:23:41 CEST 2003 Daniel Veillard + + * nanoftp.c nanohttp.c: last finishing touch to the BeOS + patch from Marcin 'Shard' Konicki + +Mon Sep 29 15:15:08 CEST 2003 Daniel Veillard + + * HTMLtree.c SAX2.c c14n.c catalog.c configure.in debugXML.c + encoding.c entities.c nanoftp.c nanohttp.c parser.c relaxng.c + testAutomata.c testC14N.c testHTML.c testRegexp.c testRelax.c + testSchemas.c testXPath.c threads.c tree.c valid.c xmlIO.c + xmlcatalog.c xmllint.c xmlmemory.c xmlreader.c xmlschemas.c + example/gjobread.c include/libxml/HTMLtree.h include/libxml/c14n.h + include/libxml/catalog.h include/libxml/debugXML.h + include/libxml/entities.h include/libxml/nanohttp.h + include/libxml/relaxng.h include/libxml/tree.h + include/libxml/valid.h include/libxml/xmlIO.h + include/libxml/xmlschemas.h include/libxml/xmlversion.h.in + include/libxml/xpathInternals.h python/libxml.c: + Okay this is scary but it is just adding a configure option + to disable output, this touches most of the files. + +Mon Sep 29 12:53:56 CEST 2003 Daniel Veillard + + * xmlmemory.c: better fix, avoids breaking the python bindings + +Mon Sep 29 11:21:33 CEST 2003 Daniel Veillard + + * xmlmemory.c: fix a compilation problem when configuring + with debug but without mem-debug + +Sun Sep 28 20:53:17 CEST 2003 Daniel Veillard + + * Makefile.am: cleanup, creating a new legacy.c module, + made sure make tests ran in reduced conditions + * SAX.c SAX2.c configure.in entities.c globals.c parser.c + parserInternals.c tree.c valid.c xlink.c xmlIO.c xmlcatalog.c + xmlmemory.c xpath.c xmlmemory.c include/libxml/xmlversion.h.in: + increased the modularization, allow to configure out + validation code and legacy code, added a configuration + option --with-minimum compiling only the mandatory code + which then shrink to 200KB. + +Sun Sep 28 02:15:07 CEST 2003 Daniel Veillard + + * parser.c: fix a bug raised by the Mips compiler. + * include/libxml/SAX.h include/libxml/parser.h: move the + SAXv1 block definitions to parser.h fixes bug #123380 + * xmlreader.c include/libxml/xmlreader.h: reinstanciate + the attribute and element pool borken 2 commits ago. + Start playing with an entry point to preserve a subtree. + * entities.c: remove a warning. + +Sat Sep 27 12:19:38 PDT 2003 William Brack + + * encoding.c, parser.c, relaxng.c: further (final?) minor + changes for compilation warnings. No change to logic. + +Fri Sep 26 18:03:42 PDT 2003 William Brack + + * parser.c: fixed small problem with missing entities (test/ent2) + +Sat Sep 27 01:25:39 CEST 2003 Daniel Veillard + + * parser.c: William's change allowed to spot a nasty bug in xmlDoRead + if the result is not well formed that ctxt->myDoc is not NULL + and uses the context dictionnary. + +Fri Sep 26 21:09:34 CEST 2003 Daniel Veillard + + * parser.c: other patches from William Brack to avoid + compilation warnings on AIX. + +Fri Sep 26 11:03:08 PDT 2003 William Brack + + * HTMLparser.c, entities.c, xmlreader.c: minor change to + avoid compilation warnings on some (e.g. AIX) systems + +Fri Sep 26 16:49:25 CEST 2003 Daniel Veillard + + * parserInternals.c: fixed a backward compatibility problem + when formatting "deprecated SAXv1 function ignorableWhitespace" + could be reproduced by xmllint --format + +Fri Sep 26 15:50:44 CEST 2003 Daniel Veillard + + * doc/libxml2-api.xml: rebuilt the API + * xmllint.c doc/xmllint.1 doc/xmllint.xml: added the new options + --nocdata and --nsclean to remove CDATA section and surperfluous + namespace declarations + * parser.c SAX2.c: implementation of the 2 new options + +Fri Sep 26 14:41:53 CEST 2003 Daniel Veillard + + * HTMLparser.c testHTML.c xmllint.c include/libxml/HTMLparser.h: + added the same htmlRead APIs than their XML counterparts + * include/libxml/parser.h: new parser options, not yet implemented, + added an options field to the context. + * tree.c: patch from Shaun McCance to fix bug #123238 when ]]> + is found within a cdata section. + * result/noent/cdata2 result/cdata2 result/cdata2.rdr + result/cdata2.sax test/cdata2: add one more cdata test + +Thu Sep 25 23:03:23 CEST 2003 Daniel Veillard + + * parser.c xmllint.c doc/libxml2-api.xml include/libxml/parser.h: + Changed the new xmlRead/xmlCtxtRead APIs to have an extra + base URL parameter when not loading from a file or URL. + +Thu Sep 25 16:23:58 CEST 2003 Daniel Veillard + + * configure.in: preparing a beta3 solving the ABI problems + * globals.c parser.c parserInternals.c testHTML.c HTMLparser.c SAX.c + include/libxml/globals.h include/libxml/SAX.h: make sure the + global variables for the default SAX handler are V1 ones to + avoid ABI compat problems. + * xmlreader.c: cleanup of uneeded code + * hash.c: fix a comment + +Thu Sep 25 14:16:51 CEST 2003 Daniel Veillard + + * SAX2.c hash.c parser.c include/libxml/xmlexports.h + include/libxml/xmlmemory.h include/libxml/xmlversion.h.in: + fixing some comments to avoid warnings from apibuild.py + +Wed Sep 24 23:42:08 CEST 2003 Daniel Veillard + + * win32/configure.js: patch from Stephane Bidoul for configuring + the beta2 version #123104 + +Wed Sep 24 23:17:59 CEST 2003 Daniel Veillard + + * Makefile.am: adding repeated parsing and validating tests + * SAX2.c parser.c tree.c include/libxml/parser.h: make the new + DOM tree building interfaces use the dictionary from the + parsing context to build the element and attributes names + as well as formatting spaces and short text nodes + * include/libxml/dict.h dict.c: added some reference counting + for xmlDictPtr because they can be shared by documents and + a parser context. + * xmlreader.c: a bit of cleanup, remove the specific tree freeing + functions and use the standard ones now. + * xmllint.c: add --nodict + * python/libxml.c: fix a stupid bug so that ns() works on + attribute nodes. + +Tue Sep 23 23:07:45 CEST 2003 Daniel Veillard + + * parser.c include/libxml/parser.h: adding a new set of + API for parsing xmlReadDoc() xmlReadFile() ... xmlReadIO() + and xmlCtxtReadDoc() ... xmlCtxtReadIO(). That with + a clear define of xmlParserOption, xmlCtxtUseOptions() + should simplify custom parsing without being tempted to + use global variables, and xmlCtxtReset() should allow reuse + of a context for multiple parsing. + * xmllint.c: switched to use xmlReadXXX, allow options to + be used simultaneously with less troubles. + * tree.c: simple warning removal + * doc/apibuild.py: small fix + * doc/libxml2-api.xml win32/libxml2.def.src: updated + +Tue Sep 23 11:15:23 CEST 2003 Daniel Veillard + + * parser.c: revert xmlCreateDocParserCtxt() since this break + the parseDoc() python bindings + +Tue Sep 23 11:00:18 CEST 2003 Daniel Veillard + + * parser.c: make sure xmlDetectSAX2() is called only at + parsing time to avoid breaking apps changing the SAX + callbacks after context allocation, change xmlCreateDocParserCtxt() + to use an immutable buffer instead of a copy + +Tue Sep 23 09:40:33 CEST 2003 Daniel Veillard + + * xmlIO.c: applied patch from Markus Keim fixing a problem + with I/O callback registration. + * include/libxml/xmlerror.h: fixed #122994 comment numbering + for xmlParserErrors + +Mon Sep 22 12:21:11 CEST 2003 Daniel Veillard + + * tree.c include/libxml/tree.h: the uri arg to xmlNodeSetBase is + really a const xmlChar* + * xmlreader.c include/libxml/xmlreader.h: addin the + xmlTextReaderConstString() to get an interned string from + the reader + +Sun Sep 20 17:22:20 PDT 2003 William Brack + + * error.c: fixed a warning message (trivial) + * doc/search.php: removed incorrect warning message when word + search not found in last of multiple tables (bug 119535) + +Fri Sep 19 14:26:28 CEST 2003 Daniel Veillard + + * configure.in: preparing a 2.6.0-beta2 release + * xmlIO.c: avoid a warning + * tree.c: avoid duplicate code in xmlReplaceNode as pointed out + by Chris Ryland + * include/libxml/dict.h: add a QName access lookup to the + dictionary. + * xmlreader.c include/libxml/xmlreader.h: adding const access + based on the dictionary interface for string read from the + reader, the node content access is still TODO, it's too different + +Fri Sep 19 00:01:08 CEST 2003 Daniel Veillard + + * SAX2.c: fixing namespace DTD validations + * result/valid/ns2.xml result/valid/ns.xml: the output of defaulted + namespaces is slightly different now. + * Makefile.am: report the memory used in Timingtests (as well as time) + +Thu Sep 18 15:29:46 CEST 2003 Daniel Veillard + + * Makefile.am: add streaming on memory regression tests, found + bad bugs in the reader interface + * xmlreader.c: fixing bugs w.r.t. very large names, and special + condition in end of file. + * xmlIO.c tree.c include/libxml/tree.h include/libxml/xmlIO.h: + adding immutable buffers, and parser input based on those, + but this should not be used (yet) for general parsing + * parser.c: added a comment about using immutable buffers for + general parsing. + * result/bigname.xml.rdr result/bigname2.xml.rdr: fixing the + output of the regression tests + * xmllint.c: using the immutable buffers when streaming on + mmaped file (--stream --memory) + +Thu Sep 18 12:04:50 CEST 2003 Daniel Veillard + + * dict.c: the last patch broke unicity of returned strings, removed + +Thu Sep 18 00:31:02 CEST 2003 Daniel Veillard + + * Makefile.am: add a Timingtests target to check bad behaviour + from the streaming engine + * dbgen.pl dbgenattr.pl: perl script to generate big instances + * xmlreader.c: fix a bad behaviour on large buffer inputs + +Wed Sep 17 23:25:47 CEST 2003 Daniel Veillard + + * dict.c xmlreader.c: two small improvements + +Wed Sep 17 22:53:32 CEST 2003 Daniel Veillard + + * parserInternals.c: avoid a leak with previous patch + +Wed Sep 17 22:06:11 CEST 2003 Daniel Veillard + + * python/libxml.c: use stderr and not stdout for default errors + in python environment bug #122552 + +Wed Sep 17 21:33:57 CEST 2003 Daniel Veillard + + * parserInternals.c: small fix from Rob Richards for input filename + * xmllint.c: fixes for --repeat and --memory/--stream for speed tests + * xmlIO: adding a guard in one function + +Wed Sep 17 15:57:44 CEST 2003 Daniel Veillard + + * SAX2.c xmlreader.c include/libxml/parser.h: more performance hunting + reducing memory allocation and free and avoiding expensive routines + +Wed Sep 17 12:23:41 CEST 2003 Daniel Veillard + + * SAX2.c parser.c parserInternals.c xmlreader.c: started messing + seriously with per-document dict and element and attribute nodes + reuse in the xmlReader. This seems to lead to an interesting + speedup of the xmlReader already. + +Wed Sep 17 01:07:56 CEST 2003 Daniel Veillard + + * dict.c include/libxml/dict.h: do string allocations in large + pools, allowing to find if a string pertain to a dict quickly + * xmllint.c: fix --stream --repeat --timing + * Makefile.am: the testThreads run output should be seen. + +Mon Sep 15 16:46:28 CEST 2003 Daniel Veillard + + * SAX2.c include/libxml/parser.h: starting work on reusing the + parser dictionary for the element and attribute tag names. + Add pools for Element and Attributes in the parser context, + which should help speeding up the reader. + * Makefile.am result/*.rdr : adding non-python reader regression + tests. + +Mon Sep 15 14:54:42 CEST 2003 Daniel Veillard + + * SAX2.c parser.c valid.c: starting to cleanup some of the + problems exposed by the W3C/NIST regression suite. + * result/ent7.sax result/xml2.sax: small fixes. + +Mon Sep 15 11:46:47 CEST 2003 Daniel Veillard + + * parser.c: more parser error factoring + +Sun Sep 14 21:53:39 PDT 2003 William Brack + + * HTMLtree.c: Fixed bug 121394 - missing ns on attributes + +Sun Sep 14 21:43:32 CEST 2003 Daniel Veillard + + * parser.c include/libxml/xmlerror.h: factoring of more + error handling code, serious size reduction and more lisibility + of the resulting code. + * parserInternals.c parser.c include/libxml/parserInternals.h + include/libxml/parser.h: changing the way VC:Proper Group/PE Nesting + checks are done, use a counter for entities. Entities where freed and + reallocated at the same address failing the check. + * tree.c: avoid a warning + * result/valid/* result/VC/*: this slightly changes some validation + error messages. + +Sun Sep 14 11:03:27 PDT 2003 William Brack + + * valid.c: fixed bug 121759 - early declaration of + attribute-list in external DTD + +Sat Sep 13 14:42:11 CEST 2003 Daniel Veillard + + * parser.c include/libxml/xmlerror.h: starting cleaning up + error handling, factorize error processing + * doc/xmllint.html: update of the page, remove --sgml + +Sat Sep 13 02:13:50 CEST 2003 Daniel Veillard + + * Makefile.am DOCBparser.c parserInternals.c testDocbook.c + xmllint.c doc/xmllint.xml doc/xmllint.1: removing the + broken pseudo SGML DocBook parser code. + +Fri Sep 12 17:24:11 CEST 2003 Daniel Veillard + + * xpath.c: fix a problem with strcpy() in xmlXPathFormatNumber() + valgrind pointed out the strings overlapped. cleanup . + +Fri Sep 12 11:43:12 CEST 2003 Daniel Veillard + + * tree.c: applied speedup to xmlSearchNs() as suggested by + Luca Padovani. Cleaned up xmlSearchNsByHref() in the process + applying the same trick. + +Fri Sep 12 01:36:20 CEST 2003 Daniel Veillard + + * parser.c parserInternals.c tree.c include/libxml/parser.h + include/libxml/xmlerror.h: adding namespace checkings + while making sure they still parse as wellformed documents. + Add an nsWellFormed status report to the context, and + provide new appropriate error codes. + * Makefile.am result/namespaces/* test/namespaces/*: add + specific regression testing for the new namespace support + * test/att5 result/noent/att5 result/att5 result/att5.sax: + add more coverage for the attribute parsing and normalization + code. + +Fri Sep 12 01:34:19 CEST 2003 Daniel Veillard + + * threads.c: backport of a thread bugfix from 2_5_X branch + +Thu Sep 11 18:29:18 CEST 2003 Daniel Veillard + + * parser.c: fixed a bug in one corner case of attribute parsing. + +Thu Sep 11 16:21:53 CEST 2003 Daniel Veillard + + * configure.in doc/* : 2.6.0beta1 changes + * SAX2.c hash.c parser.c parserInternals.c: Fixing attribute + normalization, might not be totally fixed but this should + make sure SAX event provide the right strings for attributes + except entities for which libxml2 is different by default + This should fix #109564 + * result/attrib.xml.sax result/ent3.sax result/p3p.sax: minor changes + in attribute callback values + * result/c14n/with-comments/example-4 + result/c14n/without-comments/example-4: this also fixes a subtle + bug in the canonicalization tests. + +Wed Sep 10 12:38:44 CEST 2003 Daniel Veillard + + Time to commit 3 days of work rewriting the parser internal, + fixing bugs and migrating to SAX2 interface by default. There + is some work letf TODO, like namespace validation and attributes + normalization (this break C14N right now) + * Makefile.am: fixed the test rules + * include/libxml/SAX2.h include/libxml/parser.h + include/libxml/parserInternals.h SAX2.c parser.c + parserInternals.c: changing the parser, migrating to SAX2, + adding new interface to switch back to SAX1 or initialize a + SAX block for v1 or v2. Most of the namespace work is done + below SAX, as well as attribute defaulting + * globals.c: changed initialization of the default SAX handlers + * hash.c tree.c include/libxml/hash.h: added QName specific handling + * xmlIO.c: small fix + * xmllint.c testSAX.c: provide a --sax1 switch to test the old + version code path + * result/p3p result/p3p.sax result/noent/p3p test/p3p: the new code + pointed out a typo in a very old test namespace + +Sun Sep 7 19:58:33 PTD 2003 William Brack + + * xmlIO.c include/libxml/xmlIO.h parser.c: Implemented detection + of compressed files, setting doc->compressed appropriately + (bug #120503). + +Sun Sep 7 22:53:06 CEST 2003 Daniel Veillard + + * parser.c: try to cope with the fact that apps may still + have allocated smaller SAX callbak block + +Sun Sep 7 11:11:45 CEST 2003 Daniel Veillard + + * dict.c: allow to give -1 for undefined length in lookups + * include/libxml/parser.h parser.c parserInternals.c testSAX.c: + first round of work on the new SAX2 interfaces, the API + will change but commiting before changing for historical + reference. + +Sat Sep 6 10:55:01 PTD 2003 William Brack + + * SAX2.c, xmlIO.c: fixed bug #121210 (callback to sax->error, + sax->warning with wrong params). + +Fri Sep 5 10:33:42 CEST 2003 Daniel Veillard + + * include/libxml/globals.h: patch from Stéphane Bidoul to export + globals entry points to the python bindings + +Wed Sep 3 15:24:41 CEST 2003 Daniel Veillard + + * HTMLparser.c: when creating a DOCTYPE use "html" lowercase + by default instead of "HTML" + * parser.c xmlreader.c: optimization, gain a few % parsing speed by + avoiding calls to "areBlanks" when not needed. + * include/libxml/parser.h include/libxml/tree.h: some structure + extensions for future work on using per-document dictionaries. + +Wed Sep 3 15:08:06 CEST 2003 Daniel Veillard + + * Makefile.am results/*.sax SAXResult/*: removing the SAXresults + tree, keeping result in the same tree, added SAXtests to the + default "make tests" + +Tue Sep 2 15:59:04 CEST 2003 Igor Zlatkovic + + * include/libxml/xmlexports.h: defined additional macros which + affect exports and added mingw section + +Mon Sep 1 15:15:18 PDT 2003 William Brack + + * doc/index.py: fixed problem parsing xhtml docs + * doc/xmlreader.html,doc/guidelines.html: small modification + to avoid problem in python parsing. + * doc/search.php: fixed upper case filename problem for XSLT docs + +Mon Sep 1 22:55:09 CEST 2003 Daniel Veillard + + * xinclude.c: patch from Mark Vakoc that allows compiling + with XInclude but without XPointer support. + +Mon Sep 1 22:31:38 CEST 2003 Daniel Veillard + + * configure.in xml2-config.in: Applied a patch from Kevin P. Fleming + to add --libtool-libs option to xml2-config script. + +Sun Aug 31 21:52:12 PDT 2003 William Brack + + * doc/README.docs, doc/Makefile.am: new file added, + giving some description of the documentation generation process + * doc/search.php: fixed problem with upper case on filenames + +Fri Aug 29 12:25:01 CEST 2003 Igor Zlatkovic + + * win32/Makefile.bcb: updates by Eric Zurcher + +Thu Aug 28 22:58:38 PDT 2003 William Brack + + * doc/apibuild.py, doc/libxml2-api.xml: enhanced code + to compensate for pollution from Igor's header taint + (quick before Daniel notices) + +Thu Aug 28 23:01:36 CEST 2003 Daniel Veillard + + * SAX2.c: fixed a namespace error on attribute reporting bug + pointed out by Tobias Reif + * test/p3p result/p3p result/noent/p3p: this test case was wrong + using xmlsn instead of xmlns... + +Thu Aug 28 18:25:07 CEST 2003 Igor Zlatkovic + + * include/libxml/globals.h include/libxml/xmlexports.h: fixed + typos reported by Mark Vakoc + +Thu Aug 28 08:59:51 MDT 2003 John Fleck + + add: + * doc/tutorial/api.html + * doc/tutorial/ar01s09.html + * doc/tutorial/includexpath.c + updated + * doc/tutorial/*.html + fix my bad - forgot to check in new files when I last + updated + + +Thu Aug 28 14:31:13 CEST 2003 Igor Zlatkovic + + * win32/Makefile.bcb: new file, support for Borland C++ + * xmllint.c: fixed time inclusion for various compilers + +Thu Aug 28 12:32:59 CEST 2003 Igor Zlatkovic + + * parser.c parserInternals.c DOCBparser.c HTMLparser.c: added + few casts to shut the compiler warnings + +Thu Aug 28 12:23:51 CEST 2003 Igor Zlatkovic + + * win32/Makefile.* win32/configure.js: fixed for mingw + +Thu Aug 28 10:01:44 CEST 2003 Daniel Veillard + + * globals.c threads.c: fixing bug #120870 try to avoid problem + with uninitialized mutexes + +Wed Aug 27 16:12:41 CEST 2003 Daniel Veillard + + * relaxng.c: fixed an error reporting bug in Relax-NG when we end + up with multiple states, select the "best" one. Fix #120682 + * result/relaxng/tutor11_2_3.err: small change resulting + +Wed Aug 27 11:25:25 CEST 2003 Daniel Veillard + + * xmlschemastypes.c: applied base64 support patch from Anthony Carrico + +Wed Aug 27 10:58:51 CEST 2003 Igor Zlatkovic + + * include/libxml/[threads-xpointer].h: realigned parameters + after taint + +Wed Aug 27 09:59:54 CEST 2003 Igor Zlatkovic + + * include/libxml/xmlexports.h: fixed defs for Borland compiler, + as reported by Eric Zurcher + +Tue Aug 26 15:54:04 CEST 2003 Daniel Veillard + + * relaxng.c: fixed bug #120386 again a problem introduced when + trying to reuse automata for content validation. Fix a bug report + problem on zeroOrMore + * result/relaxng/tutor3_7_err: change slightly error reporting. + +Mon Aug 25 13:24:57 CEST 2003 Daniel Veillard + + * include/libxml/Makefile.am: make sure the new header will + be included when generating a new distribution. + +Mon Aug 25 12:37:05 CEST 2003 Daniel Veillard + + * relaxng.c: fixed a couple of stupid bugs in the state allocation + routines which led to bug #120040 and the ones reported by + Martijn Faassen + +Mon Aug 25 12:37:23 CEST 2003 Igor Zlatkovic + + * include/libxml/parserInternals.h include/libxml/relaxng.h + include/libxml/SAX.h include/libxml/SAX2.h: realigned the + parameters after taint. + +Mon Aug 25 11:16:01 CEST 2003 Igor Zlatkovic + + * include/libxml/xmlversion.h.in: moved export defs to a separate + file for consistency. + * include/libxml/xmlexports.h: new file, contains export defs. + +Mon Aug 25 11:01:49 CEST 2003 Igor Zlatkovic + + * include/libxml/*.h genUnicode.py: exportability taint + of the headers. + +Thu Aug 21 12:37:46 CEST 2003 Daniel Veillard + + * SAX.c: make the deprecated interfaces log an error message + to be sure it won't get used. + +Thu Aug 21 00:50:32 CEST 2003 Daniel Veillard + + * Makefile.am SAX2.c include/libxml/Makefile.am include/libxml/SAX2.h: + Adding new version of the SAX interface, it's not there yet, + currently just preparing the work + * globals.c parser.c SAX.c include/libxml/SAX.h + include/libxml/globals.h include/libxml/parser.h: doing some + refactoring of the SAXv1 interfaces, obsoleting a bunch of them + while keeping functionalities, preparing SAX2 integration. + * dict.c: small cleanup. + +Wed Aug 20 00:20:01 CEST 2003 Daniel Veillard + + * tree.c: fixes a small bug introduced in last commit and detected + by valgrind. + +Tue Aug 19 16:54:18 CEST 2003 Daniel Veillard + + * dict.c hash.c: optimization when freeing hash tables. + * parser.c xmlIO.c include/libxml/tree.h: some tuning of buffer + allocations + * parser.c parserInternals.c include/libxml/parser.h: keep a + single allocated block for all the attributes callbacks, + avoid useless malloc()/free() + * tree.c: do not realloc() when growing a buffer if the buffer + ain't full, malloc/memcpy/free avoid copying memory. + +Mon Aug 18 18:37:01 CEST 2003 Daniel Veillard + + * xmllint.c doc/xmllint.xml doc/xmllint.1: added option + --dtdvalidfpi for Tobias Reif + +Mon Aug 18 14:03:03 CEST 2003 Daniel Veillard + + * dict.c include/libxml/dict.h Makefile.am include/libxml/Makefile.am: + new dictionary module to keep a single instance of the names used + by the parser + * DOCBparser.c HTMLparser.c parser.c parserInternals.c valid.c: + switched all parsers to use the dictionary internally + * include/libxml/HTMLparser.h include/libxml/parser.h + include/libxml/parserInternals.h include/libxml/valid.h: + Some of the interfaces changed as a result to receive or return + "const xmlChar *" instead of "xmlChar *", this is either + insignificant from an user point of view or when the returning + value changed, those function are really parser internal methods + that no user code should really change + * doc/libxml2-api.xml doc/html/*: the API interface changed and + the docs were regenerated + +Sun Aug 17 23:05:38 CEST 2003 Daniel Veillard + + * parser.c: applied patch to xmlCleanupParser from Dave Beckett + +Sat Aug 16 22:53:42 HKT 2003 William Brack + + * doc/parsedecl.py, doc/libxml2-refs.xml, doc/API*.html: + fixed part (2) of bug 119535 (wrong alpha case on filenames) + +Sat Aug 16 20:35:28 HKT 2003 William Brack + + * doc/API*.html, doc/html/*: regenerated API documentation + for xmlsoft.org (part of Bug 119535) + +Fri Aug 15 14:58:37 HKT 2003 William Brack + + * encoding.c, threads.c, include/libxml/HTMLparser.h, + doc/libxml2-api.xml: Minor changes to comments, etc. for + improving documentation generation + * doc/Makefile.am: further adjustment to auto-generation of + win32/libxml2.def.src + +Fri Aug 15 02:24:20 CEST 2003 Daniel Veillard + + * News configure.in: preparing libxml2-2.5.10 release + * doc/* : updated the doc and rebuilt + +Fri Aug 15 01:55:53 CEST 2003 Daniel Veillard + + * parser.c: fixing the xmlSAXParseDTD bug #119536 raised by + Malcolm Tredinnick with the patch he suggested. + +Fri Aug 15 01:37:10 CEST 2003 Daniel Veillard + + * HTMLparser.c: allocation error #119784 raised by Oliver Stoeneberg + +Fri Aug 15 00:41:58 CEST 2003 Daniel Veillard + + * uri.c: fixing an use of strcpy() where both strings overlap + pointed out by valgrind. + +Thu Aug 14 17:10:39 CEST 2003 Daniel Veillard + + * DOCBparser.c globals.c include/libxml/xmlmemory.h: get rid of + some compilation warnings. + * xinclude.c: fix the performance problem reported by Kevin Ruscoe + plus some cleanup and better error reporting. + +Thu Aug 14 14:13:43 CEST 2003 Daniel Veillard + + * encoding.c: applied UTF-16 encoding handling patch provided by + Mark Itzcovitz + * encoding.c parser.c: more cleanup and fixes for UTF-16 when + not having iconv support. + +Thu Aug 14 03:19:08 CEST 2003 Daniel Veillard + + * Makefile.am configure.in example/Makefile.am libxml.h nanoftp.c + nanohttp.c xmllint.c: Applied patch from Mikhail Grushinskiy for + mingw compiler on Windows. + +Thu Aug 14 02:28:36 CEST 2003 Daniel Veillard + + * parser.c: fixed the serious CPU usage problem reported by + Grant Goodale + * HTMLparser.c: applied patch from Oliver Stoeneberg about a free + missing in htmlSAXParseDoc + +Tue Aug 12 22:48:10 HKT 2003 William Brack + + * doc/Makefile.am: Removed dependency from libxml2.def.src + +Tue Aug 12 18:55:08 HKT 2003 William Brack + + * autogen.sh: took away the requirement for automake-1.4, + changed the messages for getting auto* tools to current + gnu pages. + * configure.in: added check for Linux Dec alpha requiring + -ieee flag, fixed test for ipv6 + * trionan.c: fixed problem for compiling on Linux Dec alpha + using native compiler + * doc/Makefile.am: implemented regeneration of win32/libxml2.def.src + whenever libxml2-api.xml is changed. + +Mon Aug 11 17:02:23 CEST 2003 Daniel Veillard + + * parser.c: cleaning up a problem when parsing UTF-16 and libiconv + is not used. + +Sun Aug 10 08:13:22 HKT 2003 William Brack + + * win32/libxml2.def.src: renerated with fixed libxml2-api.xml + +Sun Aug 10 00:22:55 CEST 2003 Daniel Veillard + + * News configure.in: preparing libxml2-2.5.9 release + * doc/* : updated the doc and rebuilt + +Sat Aug 9 20:00:13 CEST 2003 Daniel Veillard + + * include/libxml/xmlreader.h doc/libxml2-api.xml: changing an enum + definition to get a correct API XML description. This was apparently + breaking Windows build. + +Sat Aug 9 13:41:21 CEST 2003 Daniel Veillard + + * HTMLparser.c: fixed a nasty bug #119387, bad heuristic from + the progressive HTML parser front-end on large character data + island leading to an erroneous end of data detection by the + parser. Some cleanup too to get closer from the XML progressive + parser. + +Sat Aug 9 00:42:47 HKT 2003 William Brack + + * win32/configure.js: Added in support for the ISO8859X + module (patch provided by Jesse Pelton) + +Fri Aug 8 15:56:32 CEST 2003 Daniel Veillard + + * HTMLtree.c tree.c threads.c: hum try to avoid some troubles + when the library is not initialized and one try to save, the + locks in threaded env might not been initialized, playing safe + * xmlschemastypes.c: apply patch for hexBinary from Charles Bozeman + * test/schemas/hexbinary_* result/schemas/hexbinary_*: also added + his tests to the regression suite. + +Fri Aug 8 18:47:38 HKT 2003 William Brack + + * win32/defgen.xsl, win32/libxml2.def.src: Bug 119343 + (with apologies to Igor) - Enhanced handling of docb and + nanohttp. + +Thu Aug 7 21:13:22 HKT 2003 William Brack + + * encoding.c: further small changes for warnings when + configured with --with-iconv=no + +Wed Aug 6 12:32:11 HKT 2003 William Brack + + * error.c trionan.[ch] testThreads.c python/generator.py: + further small changes to elminate most of the remaining + warnings. + +Tue Aug 5 23:51:21 HKT 2003 William Brack + + * error.c HTMLparser.c testC14N.c testHTML.c testURI.c + xmlcatalog.c xmlmemory.c xmlreader.c xmlschemastypes.c + python/libxml.c include/libxml/xmlmemory.h: small changes + to syntax to get rid of compiler warnings. No changes + to logic. + +Mon Aug 4 22:40:54 CEST 2003 Daniel Veillard + + * doc/libxml2-api.xml doc/html/*: rebuilt the API and docs. + +Mon Aug 4 21:40:34 CEST 2003 Daniel Veillard + + * tree.c: fixed a small problem in the patch for #118763 + * result/HTML/doc3.htm*: this reverts back to the previous result + +Sun Aug 3 21:41:49 EDT 2003 Daniel Veillard + + * doc/FAQ.html doc/xml.html: applied doc patch to xml.html + and rebuilt, apparently some C++ wrappers are not available, + c.f. bug #118943 + +Sun Aug 3 21:30:31 EDT 2003 Daniel Veillard + + * tree.c: fixing HTML attribute serialization bug #118763 + applying a modified version of the patch from Bacek + * result/HTML/doc3.htm*: this modifies the output from one test + +Sun Aug 3 21:02:30 EDT 2003 Daniel Veillard + + * tree.c include/libxml/tree.h: added a new API to split a + QName without generating any memory allocation + * valid.c: fixed another problem with namespaces on element + in mixed content case + * python/tests/reader2.py: updated the testcase with + Bjorn Reese fix to reader for unsignificant white space + * parser.c HTMLparser.c: cleanup. + +Sun Aug 3 20:55:40 EDT 2003 Daniel Veillard + + * catalog.c: trying to fix #118754 of possible recursion in the + catalogs. Not fantastically happy about the current fix since + it's likely to break under very thread intensive concurrent + access to the catalog. Better solution might to keep the depth + an extra argument to the resolution functions. + +Sun Aug 3 18:56:54 EDT 2003 Daniel Veillard + + * valid.c: fixed bug #118712 about mixed content, and namespaced + element names. + * test/valid/mixed_ns.xml result/valid/mixed_ns*: added a check + in the regression tests + +Fri Aug 1 23:55:23 HKT 2003 William Brack + + Coninuing work on bug 118559 + * DOCBparser.c: removed 2 unsed vars + * xmlregexp.c: changed some numeric const to their enum symbols + * xmlreader.c: changed one var define from int to enum + (a little more to be done, awaiting co-ordination) + * relaxng.c: deleted one unused var + * xmllint.c: deleted some unused vars, changed one arg + val from int to enum + * testHTML.c, testDocbook.c: changed some arg vals to enum const + * xmlIO.c: fixed typo from last night (small warning msg) + +Thu Jul 31 22:44:33 HKT 2003 William Brack + + Working on bug 118559 + * error.c: deleted unused variable + * parserInternals.c: deleted unneeded 'const' qualifier + * parser.c: changed variable type for enum temp storage + * xmlIO.c: changed debugging var to be inside #ifdef + * valid.c: removed unused variable + * HTMLparser.c: removed some unneeded 'const' qualifiers + * xpath.c: added some type casts, removed some unused vars + * xinclude.c: added one type cast + * nanohttp.c: repositioned some #ifdef to avoid unused var + * nanoftp.c: removed unused var + +Wed Jul 30 14:57:55 EDT 2003 Daniel Veillard + + * HTMLparser.c: applied a patch from William Brack about + the problem of parsing very large HTML instance with comments + as raised by Nick Kew + +Wed Jul 30 12:29:38 EDT 2003 Daniel Veillard + + * xmlreader.c include/libxml/xmlreader.h: applying cleanup + patch from Bjorn Reese for xmlTextReaderNodeType() and + significant whitespace. There is an enum for node type + values now. + +Wed Jul 30 11:08:21 EDT 2003 Daniel Veillard + + * encoding.c: applying patch from Peter Jacobi to added + ISO-8859-x encoding support when iconv is not available + * configure.in include/libxml/xmlversion.h.in + include/libxml/xmlwin32version.h.in: added the glue needed + at the configure level and made it the default for Windows + +Tue Jul 29 16:43:48 EDT 2003 Daniel Veillard + + * python/generator.py python/libxml.c python/libxml2class.txt: + patch from Joachim Bauch + cleanup for Relax NG error callbacks + in python + +Tue Jul 29 12:46:08 EDT 2003 Daniel Veillard + + * parser.c parserInternals.c tree.c: applied Peter Jacobi encoding + cleanup patch, and also avoided a possible memory leak + +Tue Jul 29 09:28:09 EDT 2003 Daniel Veillard + + * encoding.c: fix the previous commit + +Tue Jul 29 12:28:17 HKT 2003 William Brack + + * HTMLparser.c: fixed problem with comments reported by Nick Kew + * encoding.c: added routines xmlUTF8Size and xmlUTF8Charcmp for + some future cleanup of UTF8 handling + +Mon Jul 28 16:39:14 EDT 2003 Daniel Veillard + + * xpath.c: applied a change suggested by Sean Griffin in bug + #118494 about a memory leak in EXSLT + +Sun Jul 27 14:30:56 EDT 2003 Daniel Veillard + + * relaxng.c: fixed a Relax-NG compilation/streaming bug introduced + when fixing the previous Relax-NG bugs + * result/relaxng/*: This slightly changes the output messages of + some regression tests. + * configure.in: added support of -with-fexceptions for nested C++ + support. + +Thu Jul 24 15:46:02 MDT 2003 John Fleck + + * doc/tutorial/apa.html + * doc/tutorial/apb.html + * doc/tutorial/apc.html + * doc/tutorial/apd.html + * doc/tutorial/ape.html + * doc/tutorial/apf.html + * doc/tutorial/apg.html + * doc/tutorial/aph.html + * doc/tutorial/ar01s02.html + * doc/tutorial/ar01s03.html + * doc/tutorial/ar01s04.html + * doc/tutorial/ar01s05.html + * doc/tutorial/ar01s06.html + * doc/tutorial/ar01s07.html + * doc/tutorial/ar01s08.html + * doc/tutorial/index.html + * doc/tutorial/ix01.html + * doc/tutorial/xmltutorial.pdf + * doc/tutorial/xmltutorial.xml + update tutorial with XPath example + + +Thu Jul 24 17:07:06 IST 2003 Daniel Veillard + + * SAX.c parser.c: fixing a bug about a special case of namespace + handling, this closes bug #116841 + +Wed Jul 23 20:52:36 IST 2003 Daniel Veillard + + * relaxng.c result/relaxng/*: checked and fixed the compilation + of RNG schemas, fixes a couple of bugs #117097 and #117001 . + This slightly changes the output messages of some regression tests. + +Wed Jul 23 15:15:08 IST 2003 Daniel Veillard + + * xmlreader.c: fixed an out of bound error #118052 , the good + part if that base64 code was not in use yet ... + +Tue Jul 22 19:42:15 MDT 2003 John Fleck + + * doc/xmllint.html + include html version of the xmllint man page, so an + up-to-date version is visible on the Web + +Mon Jul 21 21:53:43 IST 2003 Daniel Veillard + + * xinclude.c include/libxml/xinclude.h: added a new API + xmlXIncludeProcessTree() to process XInclude only on a subtree + this should fix bug #115385 + +Fri Jul 18 17:11:42 CEST 2003 Daniel Veillard + + * relaxng.c include/libxml/relaxng.h: adding Get interface for + the error callback and parameters of parsing and validation + contexts + * xmlreader.c: patch to fix bug #117702 about incomplete Read() + on text nodes. + +Wed Jul 16 23:15:53 CEST 2003 Daniel Veillard + + * parserInternals.c: patch from Dodji Seketeli about UTF16 BOM + when using the push XML parser. + * result/utf16bom.xml result/noent/utf16bom.xml test/utf16bom.xml: + added the test to the regression suite. + +Tue Jul 15 22:03:13 CEST 2003 Daniel Veillard + + * globals.c: add xmlThrDefMutex = NULL in xmlCleanupGlobals() + as suggested by Rob Richards + +Tue Jul 15 15:30:55 CEST 2003 Daniel Veillard + + * DOCBparser.c HTMLparser.c entities.c parser.c relaxng.c + xmlschemas.c xpath.c: removed some warnings by casting xmlChar + to unsigned int and a couple of others. + +Fri Jul 11 16:44:22 CEST 2003 Daniel Veillard + + * xmlschemastypes.c: fixes a segfault on empty hexBinary strings + +Thu Jul 10 16:02:47 CEST 2003 Daniel Veillard + + * nanoftp.c nanohttp.c: cleanup patches from Peter Breitenlohner + +Tue Jul 8 16:02:19 CEST 2003 Daniel Veillard + + * globals.c threads.c: fixes some problem when freeing unititialized + mutexes + +Tue Jul 8 14:15:07 CEST 2003 Daniel Veillard + + * nanoftp.c nanohttp.c: the modules should not import + directly, some cleanups + * xmlschemas.c: Peter Sobisch found a nasty bug in the Schemas + validation code. + +Mon Jul 7 18:00:51 CEST 2003 Daniel Veillard + + * win32/configure.js: Jesse Pelton pointed out a problem in the + javascript code. + +Mon Jul 7 16:39:31 CEST 2003 Daniel Veillard + + * NEWS doc/*: regenerated + * nanoftp.c nanohttp.c: might fix includes problems with the + Ipv6 support on solaris + * tree.c: patch from Markus Keim about xmlHasNsProp() on attributes + defined as #IMPLIED + +Sun Jul 6 23:09:13 CEST 2003 Daniel Veillard + + * configure.in doc/*: preparing release 2.5.8 + * nanohttp.c: changed some preprocessor block + * xmlschemastypes.c: applied patch from Charles Bozeman adding + hexBinary schema datatype and adding support for totalDigits and + fractionDigits facets. + +Sun Jul 6 19:56:18 CEST 2003 Daniel Veillard + + * debugXML.c xpath.c: fixed 2 bugs pointed in #116448 + +Sun Jul 6 19:34:17 CEST 2003 Daniel Veillard + + * xinclude.c: fixed bug #116095 removing the error message when + reapplying XInclude to a document. + +Sat Jul 5 22:40:23 CEST 2003 Daniel Veillard + + * xmlIO.c: applied small changes to portability layer for + compilation on DJGPP Ms-DOS compiler. + +Sat Jul 5 22:30:25 CEST 2003 Daniel Veillard + + * parser.c HTMLparser.c: use the character() SAX callback + if the cdataBlock ain't defined. + * xpath.c: fix bug #115349 allowing compilation when configured + with --without-xpath since the Schemas code needs NAN and co. + +Sat Jul 5 00:51:30 HKT 2003 William Brack + + Fixed problem with multi-threading, shown by the test program + testThreads. After fix, ran mutiple tests on various speed + machines (single and dual processor X86), which all seem okay. + + * catalog.c: added missing xmlRMutexUnlock in xmlLoadCatalog + + * threads.c: added missing initialisation for condition variable + in xmlNewRMutex. + +Sat Jun 21 16:10:24 CEST 2003 Daniel Veillard + + Applying IPv6 patch from Archana Shah + closing bug #114837 + + * configure.in: Added checks for IPv6 support and getaddrinfo(). + + * acconfig.h: Defined HAVE_GETADDRINFO and SUPPORT_IP6. + + * config.h.in: Defined HAVE_GETADDRINFO and SUPPORT_IP6. + + * nanoftp.c: Structure xmlNanoFTPCtxt contains either sockaddr_storage + field or sockaddr_in field, depending upon the availability of IPv6 + support. + have_ipv6(): Added to check for run-time IPv6 support. + (xmlNanoFTPScanURL), (xmlNanoFTPUpdateURL), (xmlNanoFTPScanProxy): + Modified to parse a URI with IPv6 address given in []. + (xmlNanoFTPConnect): Changed to use getaddrinfo for address + resolution, if it is available on the system, as gethostbyname + does not return IPv6 addresses on some platforms. + (xmlNanoFTPGetConnection): Modified type of dataAddr variable to + sockaddr_storage or sockaddr_in depending upon the IPv6 support. + Sending EPSV, EPRT or PASV, PORT depending upon the type of address + we are dealing with. + + * nanohttp.c: (have_ipv6): Added to check for run-time IPv6 support. + (xmlNanoHTTPScanURL), (xmlNanoHTTPScanProxy): Modified to parse + a URI with IPv6 address given in []. + (xmlNanoHTTPConnectHost): Modified to use getaddrinfo if it is + available on the system. Also IPv6 addresses will be resolved by + gethostbyname only if IPv6 run-time support is available. + (xmlNanoHTTPConnectAttempt): Modified to deal with IPv6 address. + +Sat Jun 14 18:46:51 CEST 2003 Igor Zlatkovic + + * win32/configure.js include/win32config.h + include/libxml/xmlversion.h.in: Applied the patch for BCB + by Eric Zurcher. + +Fri Jun 13 14:27:19 CEST 2003 Daniel Veillard + + * doc/Makefile.am doc/html/*: reverted back patch for #113521, + due to #115104 and while fixing #115101 . HTML URLs must not + be version dependant. + +Fri Jun 13 12:03:30 CEST 2003 Daniel Veillard + + * entities.c: do not generate " for " outside of attributes + * result//*: this changes the output of some tests + +Mon Jun 9 12:28:58 CEST 2003 Daniel Veillard + + * parser.c xmlIO.c: trying to fix #114277 about when file + remapping and escaping should really be attempted. + +Mon Jun 9 11:06:09 CEST 2003 Daniel Veillard + + * doc/*: applied a patch from Gman for building docs + * valid.c xmllint.c include/libxml/valid.h: applied a patch from + Gary Pennington to provide an allocator for xmlValidCtxt + * xmlreader.c: applied patch from Jacek Konieczny fixing bug + #113580 about data not being passed immediately. + +Thu Jun 5 11:31:02 CEST 2003 Daniel Veillard + + * tree.c: applied a couple of patches from Mark Itzcovitz + to handle saving back "UTF-16" documents. + +Mon Jun 2 21:56:15 MVT 2003 Daniel Veillard + + * relaxng.c xmlschemas.c include/libxml/schemasInternals.h: commiting + some work done while in the Maldives (hence the timezone on the + laptop !) + * result/schemas/length3* test/schemas/deter0_* + test/schemas/group0_*: some tests added too + +Mon Jun 2 15:34:17 CEST 2003 Daniel Veillard + + * encoding.c: small fix + * xmlIO.c: fixed an error message + +Tue May 20 14:21:23 CEST 2003 Daniel Veillard + + * parserInternals.c: fixing Red Hat bug #91013 where xmllint was + accepting an improper UTF8 sequence + +Sat May 17 12:53:11 CEST 2003 Igor Zlatkovic + + * threads.c: applied the patch from Stéphane Bidoul for getting + rid of extra threads in a dynamic library. + * win32/configure.js: threads default to 'native' now. + +Fri May 16 13:17:52 EDT 2003 Daniel Veillard + + * HTMLtree.c: fixing bug #112904: html output method escaped + plus sign character in URI attribute. + +Thu May 15 18:06:18 EDT 2003 Daniel Veillard + + * build_glob.py global.data globals.c parser.c + include/libxml/globals.h: patch from Stéphane Bidoul for setting + up threads global defaults. + * doc/libxml2-api.xml: this extends the API with new functions + * python/tests/Makefile.am python/tests/reader2.py + python/tests/thread2.py: integrated the associated testcase and + fixed the error string used in reader2 + +Wed May 14 14:56:46 EDT 2003 Daniel Veillard + + * configure.in libxml.spec.in python/Makefile.am: trying + to conciliate --with-python= requirements and RPM builds, + a PITA really... + +Tue May 13 18:30:34 EDT 2003 Daniel Veillard + + * HTMLparser.c: oops last commit introduced a memory leak. + +Tue May 13 18:10:38 EDT 2003 Daniel Veillard + + * xmllint.c doc/xmllint.xml: added --nonet option + * doc/Makefile.am: fixing #112803 by adding --nonet when calling + xsltproc or xmllint + * doc/xmllint.xml doc/xmllint.1: also added --schema doc and + rebuilt + * HTMLparser.c: cleaned up the HTML parser context build when + using an URL + +Tue May 13 16:35:04 EDT 2003 Daniel Veillard + + * libxml.spec.in: added a comment about bug #112902 + +Mon May 12 21:58:00 EDT 2003 William Brack + + * minor cleanup of configure '--help' display + * error.c: enhanced xmlParserPrintFileContext to fix bug #109942 + +Mon May 12 17:53:30 EDT 2003 Daniel Veillard + + * tree.c: PI nodes in external subset were not freed :-\ + fixes bug #112842 + +Mon May 12 11:23:27 EDT 2003 Daniel Veillard + + * xmllint.c: added --schema option to run WXS schema validation + * xmlschemas.c xmlschemastypes.c include/libxml/schemasInternals.h: + tried to improve error reporting in the Schema code, some cleanup + too. + +Sun May 11 16:13:20 EDT 2003 Daniel Veillard + + * xmlschemas.c: fixed some problems in the handling of errors, + and attributes addressed by references. + * test/schemas/* result/schemas/*: dropped the verbosity level + and added a couple of new tests + +Sat May 10 16:01:21 EDT 2003 Daniel Veillard + + * relaxng.c: Stéphane Bidoul found an off by one addressing + error on the error handling. + +Fri May 9 19:08:20 EDT 2003 Daniel Veillard + + * xmlschemastypes.c: trying to fix #112673 + +Fri May 9 18:14:16 EDT 2003 Daniel Veillard + + * DOCBparser.c catalog.c parser.c relaxng.c: removed multiple + warning, this fixed a bug and should close #111574 + +Fri May 9 15:34:32 EDT 2003 Daniel Veillard + + * xmlschemas.c: fixing bug #104081 with xs:all with an element + holding minOccurs="0" + * test/schemas/all_* result/schemas/all_*: added some regression + tests for that bug + * xmllint.c xmlreader.c: patches from Joerg Schmitz-Linneweber and + Garry Pennington to compile without schemas support. + +Thu May 1 10:02:35 CEST 2003 Daniel Veillard + + * tree.c: fixed a problem with xmlUnlinkNode() for DTDs. + +Wed Apr 30 14:16:08 CEST 2003 Daniel Veillard + + * xml2-config.in: try to fix Red hat bug #89957, do not + output -L/usr/lib64 + * xmlreader.c: fixed a typo in a comment + +Tue Apr 29 07:32:02 MDT 2003 John Fleck + + * doc/tutorial/aph.html, ix01.html + forgot to cvs add the new files. Thanks to Roland van Laar + for pointing this out + +Tue Apr 29 14:36:49 CEST 2003 Daniel Veillard + + * xmlschemas.c doc/libxml2-api.xml: fixing a function comment + * doc/Makefile.am doc/apibuild.py doc/gnome-xml.sgml: switching + to the XML/XSLT doc generation closing #111799 + * doc/html/*: complete update of the HTML results + +Mon Apr 28 14:51:41 CEST 2003 Igor Zlatkovic + + * win32/defgen.xsl: fixed the conditional for unicode map, + removed hardcoded schema entries + +Mon Apr 28 02:19:00 CEST 2003 Igor Zlatkovic + + * win32/defgen.xsl: new file, stylesheet for generating + win32/libxml2.def.src from doc/libxml2-api.xml + * win32/libxml2.def.src: is autogenerated from now on, changes + to this file will not appear here anymore + +Mon Apr 28 00:12:11 CEST 2003 Daniel Veillard + + * win32/configure.js python/setup.py.in: applied patch + from Stéphane Bidoul for the Python bindings on the new + release. + +Sun Apr 27 17:56:21 CEST 2003 Igor Zlatkovic + + * debugXML.c: included libxml/uri.h for xmlCanonicPath + declaration + * win32/configure.js: thread-enabled build is now default + * win32/libxml2.def.src: added more exports + +Sun Apr 27 00:23:05 CEST 2003 Daniel Veillard + + * NEWS doc/*.xsl doc/*.html: updated the web site separated + developers from common pages, made the transition to XHTML1, + added validity checking to the makefile rules. + +Sat Apr 26 23:17:51 CEST 2003 Daniel Veillard + + * parser.c: fix for xmlIOParseDTD same as previous and reported + by Petr Pajas + +Sat Apr 26 15:26:04 CEST 2003 Daniel Veillard + + * parser.c: applied fix to xmlSAXParseDTD from Malcolm Tredinnick + closing #111638 + +Sat Apr 26 14:00:58 CEST 2003 Daniel Veillard + + * python/generator.py: fixed a problem in the generator where + the way functions are remapped as methods on classes was + not symetric and dependant on python internal hash order, + as reported by Stéphane Bidoul + +Fri Apr 25 21:52:33 MDT 2003 John Fleck + + * doc/tutorial: + xmltutorial.xml + xmltutorial.pdf + *.html + add appendix on generating compiler flags, more indexing + +Sat Apr 26 01:10:48 CEST 2003 Daniel Veillard + + * triodef.h vms/build_libxml.com: applied patch from Craig A. Berry + to get libxml-2.5.7 to compile on OpenVMS + +Fri Apr 25 18:42:35 CEST 2003 Daniel Veillard + + * parser.c: fixing an xmlParseDTD bug raised by Petr Pajas + +Fri Apr 25 15:20:29 CEST 2003 Daniel Veillard + + * doc/Makefile.am doc/xmlcatalog.1 doc/xmlcatalog_man.xml + doc/xmllint.1 doc/xmllint.xml: automated the generation of the + man page based on xsltproc and a stylesheet PI in the XML. + +Fri Apr 25 12:37:33 CEST 2003 Daniel Veillard + + * doc/xmllint.*: trying to fix #110541 where   generated + character preventing rendering by the man command. + +Fri Apr 25 01:09:23 CEST 2003 Daniel Veillard + + * NEWS configure.in: preparing release 2.5.7 + * doc/*: updated and rebuilt the docs + * doc/apibuild.py: fixed the script + +Thu Apr 24 19:11:12 CEST 2003 Daniel Veillard + + * Makefile.am doc/apibuild.py: make sure the OOM code don't + get in the way of the builds + * doc/libxml2-api.xml python/libxml2class.txt: automatic update + +Thu Apr 24 18:01:46 CEST 2003 Daniel Veillard + + * Makefile.am testOOM.c testOOMlib.[ch] : integrated the Out Of + Memory test from Havoc Pennington #109368 + * SAX.c parser.c parserInternals.c tree.c uri.c valid.c + xmlmemory.c xmlreader.c xmlregexp.c include/libxml/tree.h + include/libxml/parser.h: a lot of memory allocation cleanups + based on the results of the OOM testing + * check-relaxng-test-suite2.py: seems I forgot to commit the + script. + +Wed Apr 23 17:16:41 CEST 2003 Daniel Veillard + + * xmlschemastypes.c: trivial fix for 109774 removing a warning + +Wed Apr 23 15:49:32 CEST 2003 Daniel Veillard + + * DOCBparser.c SAX.c catalog.c debugXML.c parser.c: try to find + more places where xmlCanonicPath() must be used to convert + filenames to URLs, trying to fix #111088 + +Wed Apr 23 09:35:12 CEST 2003 Daniel Veillard + + * python/libxml.c python/libxml.py: applied patch from + Brent M Hendricks adding binding for xmlCatalogAddLocal + +Tue Apr 22 15:18:01 CEST 2003 Daniel Veillard + + * HTMLparser.c: tried to fix #98879 again in a more solid + way. + +Tue Apr 22 13:58:43 CEST 2003 Igor Zlatkovic + + * win32/libxml2.def.src: added more exports from the relaxng and + xmlreader clan + +Tue Apr 22 10:35:13 CEST 2003 Daniel Veillard + + * SAX.c test/valid/ns* test/result/ns*: applied the patch + provided by Brent Hendricks fixing #105992 and integrated the + examples in the testsuite. + +Tue Apr 22 01:06:09 CEST 2003 Daniel Veillard + + * TODO: updated a bit + * configure.in: fixed the comment, threads now default to on + * parserInternals.c: fixed an erroneous xmlMallocAtomic() call + +Mon Apr 21 23:33:38 CEST 2003 Daniel Veillard + + * globals.c libxml.h parser.c parserInternals.c tree.c xmllint.c + xmlreader.c include/libxml/parser.h: a lot of performance work + especially the speed of streaming through the reader and push + interface. Some thread related optimizations. Nearly doubled the + speed of parsing through the reader. + +Sun Apr 20 10:36:05 MDT 2003 John Fleck + + * doc/xmllint.xml + * doc/xmllint.1 + update man page to explain use of --stream + +Sat Apr 19 02:03:24 CEST 2003 Daniel Veillard + + * DOCBparser.c HTMLparser.c c14n.c catalog.c encoding.c globals.c + nanohttp.c parser.c parserInternals.c relaxng.c tree.c uri.c + xmlmemory.c xmlreader.c xmlregexp.c xpath.c xpointer.c + include/libxml/globals.h include/libxml/xmlmemory.h: added + xmlMallocAtomic() to be used when allocating blocks which + do not contains pointers, add xmlGcMemSetup() and xmlGcMemGet() + to allow registering the full set of functions needed by + a garbage collecting allocator like libgc, ref #109944 + +Fri Apr 18 16:37:41 CEST 2003 Daniel Veillard + + * configure.in: switched to have thread support enabled by default, + didn't got troubles with ABI compatibility on Linux, hope it + won't break on strange OSes, if yes, report the system ID + * doc/libxml2-api.xml: just rebuilt the API + +Fri Apr 18 14:31:15 CEST 2003 Daniel Veillard + + * libxml.h include/libxml/parser.h parser.c xmlIO.c DOCBparser.c: + added support for large file, tested with a 3+GB instance, + and some cleanup. + * catalog.c: added a TODO + * Makefile.am: added some "make tests" comments + +Thu Apr 17 14:51:57 CEST 2003 Daniel Veillard + + * relaxng.c: some cleanups + * doc/xmlreader.html: extended the document to cover RelaxNG and + tree operations + * python/tests/Makefile.am python/tests/reader[46].py: added some + xmlReader example/regression tests + * result/relaxng/tutor*.err: updated the output of a number of tests + +Thu Apr 17 11:35:37 CEST 2003 Daniel Veillard + + * relaxng.c: valgrind pointed out an uninitialized variable error. + +Thu Apr 17 11:06:28 CEST 2003 Daniel Veillard + + * include/libxml/relaxng.h relaxng.c include/libxml/xmlreader.h + xmlreader.c: augnemting the APIs, cleanups. + * parser.c: cleanup bug #111005 + * xmlIO.c: added some missing comments + +Wed Apr 16 17:46:50 CEST 2003 Daniel Veillard + + * relaxng.c xmllint.c: more work on RelaxNG streaming validation + trying to improve the subset compiled, and more testing. + * doc/downloads.html doc/xml.html doc/xmlmem.html: some updates on the + documentation + * test/relaxng/tutor11_1_3.xml: fixes the DTD path + * result/relaxng/*.err: fix some of the outputs + +Wed Apr 16 01:28:15 CEST 2003 Daniel Veillard + + * relaxng.c xmlreader.c xmllint.c include/libxml/relaxng.h + include/libxml/xmlreader.h: implemented streaming of + RelaxNG (when possible) on top of the xmlReader interface, + provided it as xmllint --stream --relaxng .rng .xml + This seems to mostly work. + * Makefile.am: updated to test RelaxNG streaming + +Mon Apr 14 18:08:33 CEST 2003 Daniel Veillard + + * relaxng.c include/libxml/relaxng.h: integrated the regexp + based validity checking of fragments of the document for + which the RNG can be compiled to regexps. Works on all regression + tests, only fix needed is related to error messages. + +Sun Apr 13 21:51:00 CEST 2003 Daniel Veillard + + * relaxng.c xmlregexp.c include/libxml/xmlautomata.h + include/libxml/xmlregexp.h: Starting work precompiling + parts of RelaxNG schemas. Not plugged onto validity checking + yet, just the regexp building part. Needed to extend some + of the automata and regexp APIs. + +Fri Apr 11 21:36:21 CEST 2003 Daniel Veillard + + * xmllint.c xmlreader.c include/libxml/xmlreader.h: make sure + xmllint --stream and xmllint --stream --valid returns errors + code appropriately + +Fri Apr 11 10:59:24 CEST 2003 Daniel Veillard + + * xmlreader.c include/libxml/xmlreader.h: Added the Expand() + and Next() operation to work on subtrees within the reader + framework. + * doc/libxml2-api.xml python/libxml2class.txt: resulting updates + * python/tests/reader5.py: added an example for those new + functions of the reader. + +Thu Apr 10 23:38:13 CEST 2003 Daniel Veillard + + * HTMLtree.c: patch from Vasily Tchekalkin to fix #109865 + +Thu Apr 10 15:32:44 CEST 2003 Daniel Veillard + + * xmlreader.c: fixing HasValue for namespace as raised by + Denys Duchier + +Wed Apr 9 14:07:18 CEST 2003 Daniel Veillard + + * HTMLparser.c include/libxml/HTMLparser.h: exported + htmlCreateMemoryParserCtxt() it was static + +Wed Apr 9 13:21:48 CEST 2003 Daniel Veillard + + * xmlschemas.c xmlschemastypes.c include/libxml/xmlschemas.h: + update from Charles Bozeman for date and duration types + * test/schemas/date_0.* test/schemas/dur_0.* + result/schemas/date_0.* result/schemas/dur_0.*: updated too + +Mon Apr 7 12:19:26 CEST 2003 Daniel Veillard + + * tree.c valid.c xpath.c include/libxml/tree.h include/libxml/valid.h: + fixing bug #107129, removing excessive allocation and calls + to *printf in the code to build QName strings. + +Sat Apr 5 11:41:36 CEST 2003 Igoe Zlatkovic + + * win32/libxml2.def.src: fixed conditional exports, reported by + Luke Murray. + +Fri Apr 4 18:08:00 CEST 2003 Daniel Veillard + + * parser.c: fixed a possible problem with xmlRecoverMemory() + +Thu Apr 3 17:24:44 CEST 2003 Daniel Veillard + + * trio.c trio.h triodef.h trionan.c trionan.h triop.h triostr.c + triostr.h: Bjorn sent an update for the TRIO portability layer. + +Tue Apr 1 21:57:26 CEST 2003 Igor Zlatkovic + + * win32/libxml2.def.src: exported new functions + +Tue Apr 1 13:09:46 CEST 2003 Daniel Veillard + + * configure.in NEWS: preparing release 2.5.6 + * doc/*: updated and rebuilt the docs + +Tue Apr 1 11:52:15 CEST 2003 Daniel Veillard + + * SAX.c: fixed an uninitialized memory access pointed by valgrind + on C14Ntests + +Tue Apr 1 00:12:28 CEST 2003 Daniel Veillard + + * relaxng.c: one more fixup of error message reporting + +Mon Mar 31 18:36:32 CEST 2003 Daniel Veillard + + * relaxng.c: more work on bug #109225, and fixed an uninitialized + variable pointed out by valgrind + +Mon Mar 31 18:05:22 CEST 2003 Daniel Veillard + + * relaxng.c: try to work on bug #109225 and provide better + error reports. + * result/relaxng/* : this change the output of a number of tests + * xinclude.c: fixing the parsed entity redefinition problem + raised on the list. + * test/schemas/date_0.xsd: updated the date test c.f. E2-12 + +Mon Mar 31 13:19:04 CEST 2003 Daniel Veillard + + * xmlschemastypes.c: fixed date comparison to handle the tzo + The only failures left are disagreements on Notations and + '+1' not being allowed for ulong, uint, ushort and ubyte. + +Mon Mar 31 12:11:47 CEST 2003 Daniel Veillard + + * xmlschemastypes.c: fixed gMonth parsing routine accordingly + to the XML Schemas errata + http://www.w3.org/2001/05/xmlschema-errata#e2-12 + +Sun Mar 30 23:04:18 CEST 2003 Daniel Veillard + + * relaxng.c xmlschemastypes.c: more work on XML Schemas datatypes + and facets support. Currently only schemas with binHex or + base64 don't compile. A few error left in the test suite: + found 1035 test instances: 919 success 23 failures + most are gdate or gdateyear failing check, and a few cases where + James clark tests results are strange. + * valid.c: allow to reuse the Notation checking routine without + having a validation context. + * SAX.c: removed a #if 0 + +Sat Mar 29 17:35:05 CET 2003 Daniel Veillard + + * xinclude.c: forgot to apply one check from #106931 patch + * xmlschemastypes.c: more work on XML Schemas datatypes + +Sat Mar 29 11:49:25 CET 2003 Daniel Veillard + + * relaxng.c include/libxml/relaxng.h xmlschemastypes.c: more work + on cleaning up XML Schemas datatypes based on James Clark tests + test/xsdtest/xsdtest.xml + +Fri Mar 28 14:24:08 CET 2003 Daniel Veillard + + * relaxng.c: implemented comparisons for Schemas values. + * xmlschemastypes.c include/libxml/xmlschemastypes.h: fixed + some bugs in duration handling, comparisons for durations + and decimals, removed all memory leaks pointed out by James + testsuite. Current status is now + found 238 test schemas: 197 success 41 failures + found 1035 test instances: 803 success 130 failures + +Fri Mar 28 00:41:55 CET 2003 Daniel Veillard + + * xmlschemas.c include/libxml/xmlschemas.h: fixed bugs and memory + leaks in the W3C XML Schemas code + * xmlschemastypes.c: implemented nonPositiveInteger + * test/schemas/length2_0.xsd result/schemas/length2_0_0.err: + fixed the test and result. + +Thu Mar 27 22:23:07 CET 2003 Daniel Veillard + + * HTMLparser.c tree.c: two patches from James Bursa on the HTML + parser and a typo + * xmlschemastypes.c: reindenting, fixing a memory access + problem with dates. + +Thu Mar 27 15:53:35 CET 2003 Daniel Veillard + + * parser.c: fixing #109227 providing more context in case of + start/end tag mismatch + * python/tests/ctxterror.py python/tests/readererr.py: update the + tests accordingly + +Thu Mar 27 15:22:41 CET 2003 Daniel Veillard + + * xinclude.c: should fix #109327 errors on memory accesses + +Thu Mar 27 15:06:13 CET 2003 Daniel Veillard + + * HTMLtree.c: Fixed reopening of #78662

+ is an URI reference + +Wed Mar 26 22:38:39 CET 2003 Daniel Veillard + + * xpath.c: fixed bug #109160 on non-ASCII IDs + +Wed Mar 26 17:30:37 CET 2003 Daniel Veillard + + * parser.c: Norm suggested a nicer error message for xml:space values + errors + +Wed Mar 26 01:34:19 CET 2003 Daniel Veillard + + * xpath.c include/libxml/xpath.h: first part of the fix to + performance bug #108905, adds xmlXPathOrderDocElems() providing + document order for nodes. + * python/libxml.c: Python may require TRIO as Albert Chin pointed out + +Tue Mar 25 16:07:00 CET 2003 Daniel Veillard + + * xmlschemastypes.c: removing a warning with Sun compiler + bug #109154 + +Tue Mar 25 07:02:56 MST 2003 John Fleck + + * doc/xmllint.xml + * doc/xmllint.1 + update xmllint man page with --relaxng option + +Tue Mar 25 12:07:03 CET 2003 Daniel Veillard + + * python/setup.py.in : was missing "drv_libxml2.py" + +Mon Mar 24 19:38:05 CET 2003 Daniel Veillard + + * tree.c xpath.c: some changes related to the new way of + handling Result Value Tree, before 2.5.5 + +Mon Mar 24 16:36:23 CET 2003 Daniel Veillard + + * configure.in NEWS: preparing release 2.5.5 + * doc/* : updated the documentation and regenerated it. + +Mon Mar 24 14:56:01 CET 2003 Daniel Veillard + + * xpath.c: fixed some problems related to #75813 about handling + of Result Value Trees + +Sun Mar 23 22:57:20 CET 2003 Daniel Veillard + + * uri.c: applied a set of patches from Lorenzo Viali correcting + URI parsing errors. + +Sun Mar 23 22:00:14 CET 2003 Daniel Veillard + + * parser.c: validity status was not passed back when validating in + entities, but raised by Oliver Fischer + +Sun Mar 23 21:30:50 CET 2003 Daniel Veillard + + * HTMLtree.c: avoid escaping ',' in URIs + +Sun Mar 23 12:57:00 CET 2003 Daniel Veillard + + * parser.c: fixing bug #108976 get the ID/REFs to reference + the ID in the document content and not in the entity copy + * SAX.c include/libxml/parser.h: more checking of the ID/REF + stuff, better solution for #107208 + * xmlregexp.c: removed a direct printf, dohhh + * xmlreader.c: fixed a bug on streaming validation of empty + elements in entities + * result/VC/ElementValid8 test/VCM/v20.xml result/valid/xhtml1.xhtml: + cleanup of the validation tests + * test/valid/id* test/valid/dtds/destfoo.ent result/valid/id*: + added more ID/IDREF tests to the suite + +Sat Mar 22 23:38:08 CET 2003 Daniel Veillard + + * xmlreader.c: fixed #107043 removing 2 warnings with Sun One + compiler. + +Sat Mar 22 18:50:45 CET 2003 Daniel Veillard + + * relaxng.c: valgrind'ed and cleaned up a couple of memory issues. + +Sat Mar 22 16:15:50 CET 2003 Daniel Veillard + + * SAX.c: fix bug #107208 avoid false duplicates when ID/REFs are + defined in entities content + +Sat Mar 22 15:53:27 CET 2003 Daniel Veillard + + * SAX.c: Fixed validation bug #108858 on namespace names using + entities and reported by Brent Hendricks + * xmllint.c: report xmlTextReaderHasValue() result in --stream + --debug output. + +Sat Mar 22 13:32:39 CET 2003 Daniel Veillard + + * xmlreader.c: fixed bug #108801 reported by Malcolm Tredinnick + about the DocType node not being reported sometimes. + * python/tests/reader.py: added to test to the regression checks + +Sat Mar 22 01:57:40 CET 2003 Daniel Veillard + + * xmlreader.c: fixed bug #108546 on long CDATA (or text nodes) + reported by Edd Dumbill + +Sat Mar 23 01:00:24 CET 2003 Daniel Veillard + + * HTMLparser.c parser.c parserInternals.c: patch from + johan@evenhuis.nl for #107937 fixing some line counting + problems, and some other cleanups. + * result/HTML/: this result in some line number changes + +Fri Mar 21 22:19:14 CET 2003 Daniel Veillard + + * configure.in Makefile.am: fixed Red Hat bug #86118 use libxml2.spec + instead of libxml.spec + * relaxng.c: fixed some of the error reporting excessive + verbosity + * catalog.c debugXML.c valid.c xmlreader.c xmlschemas.c xpath.c + xmlschemastypes.c: removed some warnings from gcc + * doc/libxml2-api.xml: rebuilt + +Fri Mar 21 17:25:23 CET 2003 Daniel Veillard + + * relaxng.c: another optimization, for choice this time + * result/relaxng/spec1* result/relaxng/tutor12_1* + result/relaxng/tutor3_7: cleanups. + +Fri Mar 21 13:41:23 CET 2003 Daniel Veillard + + * relaxng.c: fixed xmlRelaxNGNodeMatchesList + * test/relaxng/testsuite.xml: augmented the test suite + * result/relaxng/spec1* result/relaxng/tutor12_1*: this fixes + some schemas validation tests in the presence of foreign + namespaces. + +Fri Mar 21 02:23:34 CET 2003 Daniel Veillard + + * relaxng.c: added another interleave speedup. + +Thu Mar 20 17:22:00 CET 2003 Daniel Veillard + + * xmlschemastypes.c: added integer and fixed one of the + IDREFS regression tests pbm + * result/relaxng/docbook_0.err: updated + +Wed Mar 19 21:58:47 CET 2003 Daniel Veillard + + * valid.c xmlschemastypes.c: attempt to cope with ID/IDREF(S) + declared both in the DTD and in the Schemas + * relaxng.c: more debug, added a big optimization for + * test/relaxng/testsuite.xml: augmented the testsuite + * test/relaxng/ result/relaxng: added the RelaxNG spec and a + DocBook example to the regression tests + +Wed Mar 19 11:34:10 CET 2003 Daniel Veillard + + * check-xsddata-test-suite.py: cosmetic change for output + * relaxng.c: try to minimize calls to malloc/free for states. + +Tue Mar 18 17:50:31 CET 2003 Daniel Veillard + + * tree.c: removed a warning + * xmlschemastypes.c: more cleanup, added ENTITY and ENTITIES + support + * check-relaxng-test-suite.py check-xsddata-test-suite.py: + cleanup/improvements of the regression tests batch + * test/relaxng/testsuite.xml: augmented libxml2 own testsuite + +Tue Mar 18 12:36:22 CET 2003 Daniel Veillard + + * relaxng.c: fixed error msg cleanup deallocation + * xmlschemastypes.c: added a function to handle lists of + atomic types, added support for IDREFS + +Tue Mar 18 01:28:15 CET 2003 Daniel Veillard + + * relaxng.c valid.c xmlschemastypes.c: added Datatype ID + and IDREF, usable from RelaxNG now + * include/libxml/xmlschemastypes.h: need to add a new interface + because the validation modifies the infoset + * test/relaxng/testsuite.xml: extended the testsuite + +Mon Mar 17 16:34:07 CET 2003 Daniel Veillard + + * relaxng.c: fixed the last core RelaxNG bug known #107083, + shemas datatype ID/IDREF support still missing though. + * xmlreader.c: fix a crashing bug with prefix raised by + Merijn Broeren + * test/relaxng/testsuite.xml: augmented the testsuite with + complex inheritance tests + +Sun Mar 16 18:45:50 CET 2003 Daniel Veillard + + * relaxng.c: switched back to the previous Relax-NG code base, + the derivation algorithm need severe constraining code to avoid + combinatorial explosion. Fixed the problem with Sebastian Rahtz + TEI based example and other bugs + * result/relaxng/*err: updated the results + * test/relaxng/testsuite.xml: started a new test suite + +Sat Mar 15 22:26:46 CET 2003 Daniel Veillard + + * relaxng.c include/libxml/relaxng.h: After coming to the conclusion + that the original RelaxNG validation code was un-fixeable, it got + rewritten to use the derivation algorithm from James Clark and + redebugged it (nearly) from scratch: + found 373 test schemas: 372 success 1 failures + found 529 test instances: 529 success 0 failures + +Tue Mar 11 12:08:23 CET 2003 Daniel Veillard + + * SAX.c parser.c: fix some recursion problems introduced in the + last release. + * relaxng.c: more debugging of the RNG validation engine, still + problems though. + +Mon Mar 10 14:10:47 CET 2003 Daniel Veillard + + * Makefile.am: stop generating wrong result file with * in name + * relaxng.c: fixing the include bug raised by Sebastian Rahtz + * result/relaxng/demo* test/relaxng/demo: added the tests from + Sebastian reproducing the problem. + +Sun Mar 9 18:02:31 MST 2003 John Fleck + + * doc/xmllint.1: regenerating man page from xmllint.xml to pick + up Aleksey's change + +Sun Mar 9 13:53:16 2003 Aleksey Sanin + + * xmllint.c doc/xmllint.xml: use $XMLLINT_INDENT environment + variable to control the indentation for the xmllint "--format" + option + +Sat Mar 8 14:27:43 CET 2003 Igor Zlatkovic + + * encoding.c: applied Gennady's patch against buffer overrun + +Fri Mar 7 19:29:40 CET 2003 Daniel Veillard + + * test/xsdtest/xsdtest.xml uri.c: after and exchange with James + Clark it appeared I had bug in URI parsing code ... + * relaxng.c include/libxml/relaxng.h: completely revamped error + reporting to not loose message from optional parts. + * xmllint.c: added timing for RNG validation steps + * result/relaxng/*: updated the result, all error messages changed + +Fri Mar 7 15:18:32 CET 2003 Daniel Veillard + + * xpath.c: fix bug #107804, the algorithm used for document order + computation was failing on attributes. + +Thu Mar 6 22:35:50 CET 2003 Daniel Veillard + + * valid.c: fix bug #107764 , possibility of buffer overflow + in xmlValidDebug() + +Wed Mar 5 17:41:37 CET 2003 Daniel Veillard + + * nanoftp.c include/libxml/nanoftp.h: adding xmlNanoFTPDele() + from Philipp Dunkel + +Wed Mar 5 10:57:09 CET 2003 Daniel Veillard + + * xmlschemastype.c: made powten array static it should not be exported + * HTMLparser.c: fix bug #107361 by reusing the code from the XML + parser function. + * testHTML.c: get rid of valgrind messages on the HTML SAX tests + +Fri Feb 28 00:23:00 CET 2003 Daniel Veillard + + * tree.c: fixed a node dump crash on attributes + * test/xsdtest/xsdtest.xml test/xsdtest/xsdtest.xsl: fixed + an URI test bug and get better output. + +Thu Feb 27 22:28:40 CET 2003 Daniel Veillard + + * check-xsddata-test-suite.py: give more infos + * relaxng.c: fix a bug reported by Sebastian Rahtz and + REF->DEF in attribute values. + +Thu Feb 27 21:09:32 CET 2003 Daniel Veillard + + * check-xsddata-test-suite.py test/xsdtest/xsdtest.xml + test/xsdtest/xsdtest.xsl: import of the XSD Datatype + regression tests from James Clark. + +Thu Feb 27 18:40:04 CET 2003 Daniel Veillard + + * relaxng.c xmlschemas.c xmlschemastypes.c + include/libxml/xmlschemastypes.h: added param support for relaxng + type checking, started to increment the pool of simple types + registered, still much work to be done on simple types and + facets checkings. + +Wed Feb 26 16:45:39 CET 2003 Daniel Veillard + + * entities.c: fixes again one of the problem raised by + James Clark in #106788 + +Wed Feb 26 15:46:48 CET 2003 Daniel Veillard + + * relaxng.c: Fixed a couple of problem raised by James Clark + in bug #107083, the support for ID/IDREF/IDREFS at the WXS + datatype level still not fixed though. + +Mon Feb 24 21:09:19 CET 2003 Daniel Veillard + + * configure.in: preparing release 2.5.4 + * doc/*: updated and rebuilt the docs + * relaxng.c: removed warnings + * result/relaxng/*: updated the results + +Mon Feb 24 20:53:17 CET 2003 Daniel Veillard + + * valid.c: fixes a DTD regexp generation problem. + +Mon Feb 24 20:12:57 CET 2003 Daniel Veillard + + * parser.c: fixes bug #105998 about false detection of + attribute consumption loop. + +Mon Feb 24 19:14:57 CET 2003 Daniel Veillard + + * xinclude.c: Fixes bug #106931 in XInclude entities merging. + +Mon Feb 24 18:50:35 CET 2003 Daniel Veillard + + * SAX.c: fixed bug #105992 + +Mon Feb 24 18:14:16 CET 2003 Daniel Veillard + + * tree.c: fixed xmlSetProp and al. when the node passed is not an + element. + * relaxng.c: fixed bugs 7.3 (though not complete) and memory leaks + found 373 test schemas: 369 success 4 failures + found 529 test instances: 525 success 4 failures + * check-relaxng-test-suite.py: added memory debug reporting + +Mon Feb 24 12:41:54 CET 2003 Daniel Veillard + + * uri.c parser.c: some warning removal on Igor's patch + * tree.c: seems I messed up with #106788 fix + * python/libxml.c: fixed some base problems when Python provides + the resolver. + * relaxng.c: fixed the interleave algorithm + found 373 test schemas: 364 success 9 failures + found 529 test instances: 525 success 4 failures + the resulting failures are bug in the algorithm from 7.3 and + lack of support for params + +Sun Feb 23 14:49:39 CET 2003 Daniel Veillard + + * parser.c: another fix for nodeinfo in entities problem + * tree.c entities.c: fixed bug #106788 from James Clark + some spaces need to be serialized as character references. + +Sat Feb 22 18:28:16 CET 2003 Igor Zlatkovic + + * parser.c uri.c: fixed the bug I introduced in the path + handling, reported by Sebastian Bergmann + +Sat Feb 22 00:19:48 CET 2003 Daniel Veillard + + * parser.c: fixing some nodeinfo in entities problem raised + by Glenn W. Bach + * relaxng.c: implemented the first section 7.3 check + * result/relaxng/*: updated the results + +Fri Feb 21 18:12:19 CET 2003 Daniel Veillard + + * relaxng.c: fixed some problems in the previous commit + and finished implementing 4.16 rules checking + found 373 test schemas: 353 success 20 failures + found 529 test instances: 519 success 6 failures + * result/relaxng/*: updated the results + +Fri Feb 21 16:37:39 CET 2003 Daniel Veillard + + * relaxng.c: implemented checks from section 7.2 + +Thu Feb 20 16:00:31 CET 2003 Daniel Veillard + + * relaxng.c: implemented the checks from section 7.1, fixed + some of the 4.20 and 4.21 problems. + found 373 test schemas: 338 success 35 failures + found 529 test instances: 519 success 6 failures + * result/relaxng/*: updated the results + +Thu Feb 20 01:09:24 CET 2003 Daniel Veillard + + * relaxng.c: implemented the 4.20 and 4.21 simplification rules. + * result/relaxng/*: updated the results + +Wed Feb 19 18:30:30 CET 2003 Daniel Veillard + + * relaxng.c: more bugfixes + * result/relaxng/*: updated the results + +Wed Feb 19 15:39:56 CET 2003 Igor Zlatkovic + + * DOCBparser.c: obsoleted xmlNormalizeWindowsPath + * HTMLparser.c: obsoleted xmlNormalizeWindowsPath + * SAX.c: ensured xmlDoc.URL is always canonic + * parser.c: obsoleted xmlNormalizeWindowsPath + * uri.c include/libxml/uri.h: introduced xmlCanonicPath + * xmlIO.c include/libxml/xmlIO.h: obsoleted xmlNormalizeWindowsPath + * win32/libxml2.def.src: added few exports + + +Wed Feb 19 14:26:51 CET 2003 Daniel Veillard + + * Makefile.am configure.in: patched to have shared libraries + for Python regression tests and static binaries for gdb debug + in my development environment + * relaxng.c: more bugfixes + found 373 test schemas: 296 success 77 failures + found 529 test instances: 516 success 8 failures + * result/relaxng/*: updated the results + +Wed Feb 19 01:17:48 CET 2003 Daniel Veillard + + * relaxng.c: guess what ! Relax-NG bugfixing, what a surprize... + +Tue Feb 18 22:09:50 CET 2003 Daniel Veillard + + * xmlschemastypes.c: float/double check bugfix + * tree.c include/libxml/tree.h: exported a function for NMTOKEN + validation + * xmlreader.c: add a TODO for Jody + * relaxng.c: bugfix bugfix bugfix + found 373 test schemas: 300 success 73 failures + found 529 test instances: 507 success 10 failures + * result/relaxng/*: updated the results + +Tue Feb 18 00:33:17 CET 2003 Daniel Veillard + + * relaxng.c check-relaxng-test-suite.py: more RelaxNG bug hunting + +Mon Feb 17 18:23:32 CET 2003 Daniel Veillard + + * relaxng.c check-relaxng-test-suite.py: more work on the + RelaxNG implementation conformance testing. + found 373 test schemas: 284 success 89 failures + found 529 test instances: 448 success 47 failures + * result/relaxng/*: updated the results + +Sun Feb 16 16:48:38 CET 2003 Daniel Veillard + + * ChangeLog tree.c doc/libxml-doc.el doc/libxml2-api.xml: applied + a patch from Kjartan Maraas to fix some typos + +Sun Feb 16 16:40:52 CET 2003 Daniel Veillard + + * relaxng.c: more bug-hunting + * testRelax.c include/libxml/relaxng.h: added --tree to dump the + intermediate rng tree + * python/generator.py: patch from Stephane Bidoul to fix the generator + on python < 2.2 + +Fri Feb 14 17:49:26 CET 2003 Daniel Veillard + + * check-relaxng-test-suite.py relaxng.c: more testing on the + Relax-NG front, cleaning up the regression tests failures + current state and I forgot support for "mixed": + found 373 test schemas: 280 success 93 failures + found 529 test instances: 401 success 68 failures + * tree.c include/libxml/tree.h xmlschemastypes.c: finished and + moved the Name, NCName and QName validation routine in tree.c + * uri.c: fixed handling of URI ending up with #, i.e. having + an empty fragment ID. + * result/relaxng/*: updated the results + +Thu Feb 13 16:49:24 CET 2003 Daniel Veillard + + * check-xinclude-test-suite.py: improved the script accordingly + to the XInclude regression tests updates + * xpointer.c: Implemented XPointer element() Scheme W3C PR of 13 + November 2002 + * result/XPath/xptr/chapterschildseq result/XPath/xptr/vidchildseq + test/XPath/xptr/chapterschildseq test/XPath/xptr/vidchildseq: + augmented the Xpointer testsuite for the element() scheme + +Thu Feb 13 12:00:30 CET 2003 Daniel Veillard + + * relaxng.c: added TODO for the DTD compatibility spec + * xinclude.c: more bug fixes driven by the testsuite + +Tue Feb 11 19:01:02 CET 2003 Daniel Veillard + + * check-xinclude-test-suite.py xinclude.c: Work on the W3C/NIST + regression tests for XInclude, improved the script, improving + XInclude error reporting mechanism + +Mon Feb 10 17:19:14 CET 2003 Daniel Veillard + + * NEWS doc/* configure.in: preparing release 2.5.3 + +Mon Feb 10 17:11:22 CET 2003 Daniel Veillard + + * tree.c: trying to fix #104934 about some XHTML1 serialization + issues. + +Mon Feb 10 16:41:13 CET 2003 Daniel Veillard + + * encoding.c xmlIO.c: fixing bug #104646 about iconv based + encoding conversion when the input buffer stops in the + middle of a multibyte char + +Mon Feb 10 15:24:47 CET 2003 Daniel Veillard + + * test/relaxng/OASIS/spectest.xml: OASIS RelaxNG testsuite + * check-relaxng-test-suite.py: python script to run regression + against OASIS RelaxNG testsuite + * relaxng.c: some cleanup tweaks + * HTMLparser.c globals.c: cleanups in comments + * doc/libxml2-api.xml: updated the API + * result/relaxng/*: errors moved files, so large diffs but + no changes at the semantic level. + +Mon Feb 10 01:00:31 CET 2003 Daniel Veillard + + * tree.c: fixing #105678 problem when dumping a namespace node. + +Mon Feb 10 00:30:01 CET 2003 Daniel Veillard + + * xpath.c: fixed doc comment problems + * python/generator.py python/libxml_wrap.h python/types.c: adding + RelaxNG wrappers + * python/tests/Makefile.am python/tests/relaxng.py: added a specific + test of those early Python RelaxNG bindings + +Sun Feb 9 15:18:43 CET 2003 Daniel Veillard + + * libxml.spec.in: fixes a libtool problem on AMD 64bits builds + * relaxng.c: found the validation problem I had with interleave + when not covering all remaining siblings + * Makefile.am test.relaxng/* result/relaxng/*: augmented the + testsuite and check the RNG schemas against the RNG schemas + given in appendix A + +Sat Feb 8 18:55:43 CET 2003 Igor Zlatkovic + + * win32/Makefile.msvc: updates for RelaxNG + * win32/Makefile.mingw: updates for RelaxNG + * win32/libxml2.def.src: added RelaxNG exports + +Fri Feb 7 14:00:53 CET 2003 Daniel Veillard + + * xinclude.c: applied another bug fix from Sean Chittenden + +Fri Feb 7 13:34:08 CET 2003 Daniel Veillard + + * configure.in xmllint.c: I f...ed up the default configuration + of schemas and --relaxng option display in xmllint, pointed by + Morus Walter. + * xlink.c: Sean Chittenden pointed a couple of errors in the XLink + detection module, fixes bug #105374. + +Fri Feb 7 01:43:38 CET 2003 Daniel Veillard + + * xmlschemastypes.c: added the boolean base type. + +Thu Feb 6 10:23:52 CET 2003 Daniel Veillard + + * xmlschemastypes.c: started implementing some of the missing + default simple types + * result/relaxng/*: updated the results + +Wed Feb 5 15:28:04 CET 2003 Daniel Veillard + + * NEWS doc/*: updated the docs, ready for 2.5.2 release + +Wed Feb 5 14:15:59 CET 2003 Daniel Veillard + + * HTMLparser.c tree.c xmlIO.c: comments cleanups + * Makefile.am: use xmllint for doing the RelaxNG tests + * configure.in: preparing 2.5.2 made schemas support default to + on instead of off + * relaxng.c: removed the verbosity + * xmllint.c: added --relaxng option + * python/generator.py python/libxml_wrap.h: prepared the integration + of the new RelaxNG module and schemas + * result/relaxng/*: less verbose output + +Wed Feb 5 12:00:36 CET 2003 Daniel Veillard + + * valid.c: do not run content model validation if the + content is not determinist + +Wed Feb 5 11:43:58 CET 2003 Daniel Veillard + + * SAX.c: added the redefinition of namespaced attribute + check that was missing as Fabrice Desré pointed out. + +Wed Feb 5 11:09:29 CET 2003 Daniel Veillard + + * HTMLparser.c include/libxml/HTMLparser.h: applied HTML + improvements from Nick Kew, allowing to do more checking + to HTML elements and attributes. + +Tue Feb 4 23:47:06 CET 2003 Daniel Veillard + + * xinclude.c: fixing bug #105137 about entities declaration + needing to be copied to the including document. + +Tue Feb 4 20:26:22 CET 2003 Daniel Veillard + + * catalog.c: fixed bug #104817 with delegateURI + * xpath.c: fixing bugs #104123 and #104125 + +Tue Feb 4 17:12:56 CET 2003 Daniel Veillard + + * configure.in valid.c xmlreader.c python/libxml_wrap.h + python/types.c: fixing #104096 to compile without regexps + +Tue Feb 4 16:31:55 CET 2003 Daniel Veillard + + * valid.c: fixing bug #103969 forgot to add an epsilon transition + when building the automata for elem* + +Tue Feb 4 16:21:07 CET 2003 Daniel Veillard + + * HTMLparser.c: applied patch from Arne de Bruijn fixing + bug #103827 + +Tue Feb 4 16:17:09 CET 2003 Daniel Veillard + + * HTMLparser.c: updating a comment, fixing #103776 + +Tue Feb 4 16:05:53 CET 2003 Daniel Veillard + + * parser.c: fixing bug 105049 for validity checking of content + within recursive entities. + +Tue Feb 4 15:40:54 CET 2003 Daniel Veillard + + * HTMLparser.c: try to fix # 105049 + * relaxng.c xmlschemastypes.c: a couple of changes and extensions + * tree.c: updated a function comment + +Tue Feb 4 00:20:58 CET 2003 Daniel Veillard + + * relaxng: more work on grammars and refs/defs + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Mon Feb 3 14:16:59 CET 2003 Daniel Veillard + + * relaxng: more work on name classes, except support + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Mon Feb 3 11:56:05 CET 2003 Daniel Veillard + + * relaxng: more work on name classes, the "validate all" schemas + seems to work now. + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Mon Feb 3 09:50:26 CET 2003 Daniel Veillard + + * python/libxml.c: removed an unprotedted debug message Aleksi Suhonen + * parser.c: put a guard against infinite document depth, basically + trying to avoid another kind of DoS attack. + * relaxng.c: some code w.r.t. nameClasses + +Sun Feb 2 17:01:43 CET 2003 Daniel Veillard + + * test/relaxng/* result/relaxng/*: check all the namespace support + was actually correct based on tutorial section 10. + +Sun Feb 2 15:33:38 CET 2003 Daniel Veillard + + * relaxng: include seems to work okay now + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Sat Feb 1 19:44:58 CET 2003 Daniel Veillard + + * relaxng.c: a bit of work done in the train back. + * test/relaxng/*: added one of the include tests + +Thu Jan 30 14:06:55 CET 2003 Daniel Veillard + + * relaxng: more work done in the train + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Wed Jan 29 23:44:58 CET 2003 Daniel Veillard + + * relaxng.c: debugging of externalRef + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Wed Jan 29 22:06:04 CET 2003 Daniel Veillard + + * relaxng.c: more work on Relax-NG, implementing externalRef + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + * Makefile.am: cleanup to Relaxtests target + +Wed Jan 29 00:08:38 CET 2003 Daniel Veillard + + * relaxng.c: more work on Relax-NG, implementing interleave + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Tue Jan 28 21:56:49 CET 2003 Daniel Veillard + + * relaxng.c: more work on Relax-NG, implementing interleave + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Mon Jan 27 07:35:29 MST 2003 John Fleck + + * doc/tutorial/customfo.xsl + * doc/tutorial/customhtml.xsl + adding stylesheet customizations used to generate fo + for pdf and html + +Mon Jan 27 13:29:43 CET 2003 Daniel Veillard + + * relaxng.c: more work on Relax-NG + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + * xmlschemastypes.c: added a number of base type definition but not + the associated checks, those are still TODOs + +Sun Jan 26 17:37:06 MST 2003 John Fleck + + in docs/tutorial: + * apa.html + * apb.html + * apc.html + * apd.html + * ape.html + * apf.html + * apg.html + * ar01s02.html + * ar01s03.html + * ar01s04.html + * ar01s05.html + * ar01s06.html + * ar01s07.html + * ar01s08.html + * index.html + * xmltutorial.pdf + * xmltutorial.xml + add index to tutorial + +Sun Jan 26 17:02:29 MST 2003 John Fleck + + * doc/xmlcatalog.1 + * doc/xmlcatalog_man.html + * doc/xmlcatalog_man.xml + belatedly fixing bug #93622 (adds rewriteURI type to + "--add" option in xmlcatalog man page + +Sun Jan 26 20:47:26 CET 2003 Daniel Veillard + + * xmlcatalog.c xmllint.c: applied patch for NetBSD by + Julio Merino, closing #104475 + +Sun Jan 26 20:38:43 CET 2003 Daniel Veillard + + * relaxng.c: more work on Relax-NG + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Sun Jan 26 01:49:58 CET 2003 Daniel Veillard + + * relaxng.c: more work on Relax-NG + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Sat Jan 25 18:59:54 CET 2003 Daniel Veillard + + * README: updated the policy on private mail answers + * relaxng.c: more work on Relax-NG + * test/relaxng/* result/relaxng/*: augmented/updated the + regression tests + +Fri Jan 24 15:12:44 CET 2003 Daniel Veillard + + * error.c parser.c tree.c: applied a documentation patch from + Stefan Kost + +Fri Jan 24 02:00:50 CET 2003 Daniel Veillard + + * relaxng.c: more work on Relax-NG + * doc/*: regenerated the docs + * test/relaxng/* result/relaxng/*: updated and augmented the + Relax-NG regression tests and results + +Thu Jan 23 19:26:20 CET 2003 Daniel Veillard + + * Makefile.am configure.in relaxng.c include/libxml/relaxng.h: + First commit of the new Relax-NG validation code, not generally + useful yet. + * test/relaxng/* result/relaxng/*: current state of the regression + tests + +Thu Jan 23 19:22:54 CET 2003 Daniel Veillard + + * tree.c: minimized the memory allocated for GetContent + and a bit of cleanup. + +Thu Jan 23 17:41:37 CET 2003 Daniel Veillard + + * python/generator.py: seems there is no good reasons to + not generate bindings for XPointer + +Tue Jan 21 13:19:35 CET 2003 Daniel Veillard + + * xmlreader.c doc/apibuild.py: applied a new patch from + Stéphane Bidoul for cleanups + * doc/libxml2-api.xml: rebuilt the API description with + new entry points + +Mon Jan 20 23:25:00 CET 2003 Daniel Veillard + + * xmlreader.c python/drv_libxml2.py python/generator.py + python/libxml.c python/libxml.py python/libxml_wrap.h + python/types.c: patch from Stéphane Bidoul for better per + context error message APIs + * python/tests/ctxterror.py python/tests/readererr.py: + update of the tests + +Sun Jan 19 17:09:28 MST 2003 John Fleck + + * doc/guidelines.html + grammar and spelling cleanup + +Fri Jan 17 00:31:30 CET 2003 Daniel Veillard + + * xmlreader.c include/libxml/xmlreader.h python/generator.py + python/libxml.c python/libxml.py win32/libxml2.def.src: applied + a patch from Stéphane Bidoul to allow per XMLtextReader error + and warning handling + * python/tests/Makefile.am python/tests/readererr.py: adding the + specific regression test + +Tue Jan 14 17:00:08 CET 2003 Daniel Veillard + + * xpath.c: Alexey Efimov pointed out that concat('a', 'b', ) + should raise a syntax error + +Tue Jan 14 15:39:14 CET 2003 Daniel Veillard + + * python/libxml.c: cleanup patch from Stéphane Bidoul + +Tue Jan 14 14:41:18 CET 2003 Daniel Veillard + + * encoding.c: fixing bug #103100 with a dummy UTF8ToUTF8 copy + +Tue Jan 14 12:40:29 CET 2003 Daniel Veillard + + * python/generator.py python/libxml.c python/libxml.py + python/libxml_wrap.h python/types.c: applied and fixed a patch + from Stéphane Bidoul to provide per parser error handlers at the + Python level. + * python/tests/Makefile.am python/tests/ctxterror.py: added a + regression test for it. + +Tue Jan 14 01:15:04 CET 2003 Daniel Veillard + + * xmlreader.c: fixed the streaming property of the reader, + it was generating tree faster than consuming it. Pointed out + by Nate Myers + * tree.c: fixed a bug in xmlSaveFormatFileEnc if passed a NULL doc + +Sun Jan 12 22:18:02 CET 2003 Igor Zlatkovic + + * win32/libxml2.def.src: added more xmlreader and other exports + +Fri Jan 10 18:04:32 CET 2003 Daniel Veillard + + * xpath.c: fix to the XPath implementation for parent and + ancestors axis when operating on a Result Value Tree. + Fixes bug #100271 + +Fri Jan 10 17:07:01 CET 2003 Daniel Veillard + + * nanoftp.c nanohttp.c xmlIO.c: patch from Stefano Zacchiroli + to fix some URI/file escaping problems + +Fri Jan 10 16:20:34 CET 2003 Daniel Veillard + + * python/generator.py: fixed a bug raised by Raymond Wiker, + docSetRootElement() should not raise an exception if the + return is None + +Fri Jan 10 14:13:03 CET 2003 Daniel Veillard + + * python/libxml.py python/libxml.c python/libxml2-python-api.xml: + fixed bug #102181 by applying the suggested change and fixing + the generation/registration problem. + +Fri Jan 10 13:47:55 CET 2003 Daniel Veillard + + * HTMLparser.c: fixed bug #102960 by reusing the XML name parsing + routines. + +Fri Jan 10 00:16:49 CET 2003 Daniel Veillard + + * parser.c: one more IsEmptyElement crazyness, that time in + external parsed entities if substitution is asked. + * python/tests/reader3.py: added a specific test. + +Thu Jan 9 22:35:31 CET 2003 Daniel Veillard + + * python/drv_libxml2.py: update from Stéphane Bidoul: python 2.1 + support and improved error handler registration + +Thu Jan 9 14:16:38 CET 2003 Daniel Veillard + + * HTMLtree.c tree.c: fixes #102920 about namespace handling in + HTML output and section 16.2 "HTML Output Method" of XSLT-1.0 + * README: fixed a link + +Wed Jan 8 18:32:25 CET 2003 Daniel Veillard + + * configure.in doc/* NEWS: preparing 2.5.1 release + * SAX.c parser.c: fixing XmlTextReader bug + +Wed Jan 8 00:13:01 CET 2003 Daniel Veillard + + * SAX.c: fuck, I introduced a memory leak on external parsed + entities in 2.5.0 :-( + +Tue Jan 7 12:12:45 CET 2003 Daniel Veillard + + * xmllint.c: another fix needed as pointed by Christophe Merlet + for --stream --debug if compiled without debug support. + +Mon Jan 6 20:53:08 MST 2003 John Fleck + + * doc/xmllint.xml + * doc/xmllint.1: + update man page with --stream and --chkregister + +Tue Jan 7 01:17:26 CET 2003 Daniel Veillard + + * globals.c: fixed --with-threads compile + * xmllint.c: fixed --without-debug compile + * include/libxml/globals.h: cleanup + * include/libxml/schemasInternals.h: add a missing include + +Mon Jan 6 14:06:07 CET 2003 Daniel Veillard + + * configure.in NEWS: preparing 2.5.0 release + * SAX.c: only warn in pedantic mode about namespace name + brokeness + * globals.c: fix a doc generation problem + * uri.c: fix #101520 + * doc/*: updated and rebuilt the doc for the release, includuding + stylesheet update + * python/Makefile.am: fix a filename bug + +Mon Jan 6 12:05:12 CET 2003 Daniel Veillard + + * doc/tutorial/* : fixed #101894 if doc == NULL xmlFreeDoc + should not be called. + +Mon Jan 6 11:59:09 CET 2003 Daniel Veillard + + * libxml-2.0.pc.in: applied the patch to fix #101894 + +Sun Jan 5 23:35:47 CET 2003 Daniel Veillard + + * tree.c : applied patch from Lukas Schroeder for register callbacks + * valid.c: modified patch from Lukas Schroeder to test + register callbacks with --chkregister + +Sun Jan 5 02:23:20 CET 2003 Daniel Veillard + + * xmlreader.c: seriously changed the way data are pushed to + the underlying parser, go by block of 512 bytes instead of + tryng to detect tag boundaries at that level. Changed the + way empty element are detected and tagged. + * python/tests/reader.py python/tests/reader2.py + python/tests/reader3.py: small changes mostly due to context + reporting being different and DTD node being reported. Some + errors previously undetected are now caught and fixed. + * doc/xmlreader.html: flagged last section as TODO + +Sat Jan 4 20:40:28 CET 2003 Daniel Veillard + + * python/libxml.py: integrated the Python 2.2 optimizations + from Hannu Krosing, while maintaining compatibility with + 1.5 and 2.1 + +Sat Jan 4 17:33:17 CET 2003 Daniel Veillard + + * xmllint.c: a bit of cleanup + * xmlreader.c: small fix + * doc/xmlreader.html: more work on the XmlTextReader tutorial + * python/libxml.py: a few fixes pointed out by Hannu Krosing + +Sat Jan 4 13:46:14 CET 2003 Daniel Veillard + + * python/setup.py.in: patch from Stéphane Bidoul to include + drv_libxml2.py in setup.py + +Sat Jan 4 01:43:06 CET 2003 Daniel Veillard + + * doc/xmlreader.html: starting documenting the new XmlTextReader + interface. + +Fri Jan 3 17:18:32 CET 2003 Daniel Veillard + + * xmllint.c: added the --stream flag to use the TextReader API + * xmlreader.c: small performance tweak + +Fri Jan 3 13:50:55 CET 2003 Daniel Veillard + + * xmlreader.c python/tests/reader2py: okay the DTD validation + code on top of the XMLTextParser API should be solid now. + +Fri Jan 3 02:17:18 CET 2003 Daniel Veillard + + * xmlreader.c python/tests/reader2py: Fixing some more mess + with validation and recursive entities while using the + reader interface, it's getting a bit messy... + +Thu Jan 2 15:15:26 CET 2003 Daniel Veillard + + * xmlreader.c python/tests/reader.py: another couple of problem + related to IsEmptyElement reported by Stéphane Bidoul needed + some fixes. + +Thu Jan 2 13:57:07 CET 2003 Daniel Veillard + + * libxml.spec.in python/Makefile.am python/drv_libxml2.py: + integrated drv_libxml2.py Python xml.sax driver from Stéphane Bidoul + based on the python XmlTextReader interface. + +Wed Jan 1 22:05:40 CET 2003 Daniel Veillard + + * tree.c: backing out one change in the last patch which broke the + regression tests + +Wed Jan 1 21:57:28 CET 2003 Daniel Veillard + + * global.data globals.c tree.c include/libxml/globals.h: applied + an old patch from Lukas Schroeder to track node creation and + destruction. Probably missing a lot of references at the moment + and not usable reliably. + +Wed Jan 1 20:12:07 CET 2003 Daniel Veillard + + * NEWS doc/Makefile.am doc/news.xsl: generate the NEWS file + from doc/news.html and a stylesheet + +Wed Jan 1 16:09:57 CET 2003 Daniel Veillard + + * xmlreader.c python/tests/reader.py: fixed another couple of + xmlreader bugs reported by Stéphane Bidoul and added tests. + +Wed Jan 1 15:42:54 CET 2003 Daniel Veillard + + * xmlreader.c python/tests/reader2.py: fixed another validity + checking in external parsed entities raised by Stéphane Bidoul + and added a specific regression test. + * python/tests/reader3.py: cleanup + +Tue Dec 31 15:44:02 CET 2002 Daniel Veillard + + * xmlreader.c python/tests/reader2.py: fixed a problem with + validation within entities pointed by Stéphane Bidoul, augmented + the tests to catch those. + +Tue Dec 31 12:15:37 CET 2002 Daniel Veillard + + * python/generator.py: modified the generator to allow keeping + class references when creating new classes, needed to fix a bug + pointed by Stéphane Bidoul where the input buffer of the + xmlTextReader instance gets destroyed if the python wrapper for + the input is not referenced anymore. + +Mon Dec 30 19:39:36 CET 2002 Daniel Veillard + + * xmlreader.c python/tests/reader.py: fixed another pair of problem + pointed by Stéphane Bidoul: depth start at 0 and a parse problem. + +Mon Dec 30 13:36:50 CET 2002 Daniel Veillard + + * xmlreader.c python/tests/reader.py: fixed another problem + pointed by Stéphane Bidoul + +Mon Dec 30 12:39:55 CET 2002 Daniel Veillard + + * xmlreader.c python/tests/reader.py: fixed a limit case problem + with "" + +Mon Dec 30 11:53:44 CET 2002 Daniel Veillard + + * SAX.c: warn on xmlns:prefix="foo" + * xmlreader.c python/tests/reader.py: fixed a couple of problem + for namespace attributes handling. + +Mon Dec 30 00:59:07 CET 2002 Daniel Veillard + + * entities.c parser.c tree.c include/libxml/entities.h: Fixed + a really nasty problem raised by a DocBook XSLT transform + provided by Sebastian Bergmann + +Sun Dec 29 12:13:18 CET 2002 Daniel Veillard + + * xmlreader.c python/tests/reader.py: fixed a bug pointed out + by Stéphane Bidoul and integrated it into the tests + +Sat Dec 28 23:49:12 CET 2002 Daniel Veillard + + * xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: + extended the XmlTextReader API a bit, addding accessors for + the current doc and node, and an entity substitution mode for + the parser. + * python/libxml.py python/libxml2class.txt: related updates + * python/tests/Makefile.am python/tests/reader.py + python/tests/reader2.py python/tests/reader3.py: updated a bit + the old tests and added a new one to test the entities handling + +Sat Dec 28 22:11:57 CET 2002 Daniel Veillard + + * python/generator.py python/libxml2class.txt + python/tests/reader.py python/tests/reader2.py: changed the + generator to provide casing for the XmlTextReader similar to + C# so that examples and documentation are more directly transposable. + Fixed the couple of tests in the suite. + +Sat Dec 28 15:55:32 CET 2002 Daniel Veillard + + * doc/guidelines.html: added a document on guildeline for + publishing and deploying XML + +Fri Dec 27 20:35:15 CET 2002 Daniel Veillard + + * valid.c xmlreader.c: final touch running DTD validation + on the XmlTextReader + * python/tests/Makefile.am python/tests/reader2.py: added a + specific run based on the examples from test/valid/*.xml + +Fri Dec 27 15:17:20 CET 2002 Daniel Veillard + + * python/libxml.py: added a few predefined xmlTextReader parser + configuration values. + +Fri Dec 27 12:57:22 CET 2002 Daniel Veillard + + * python/libxml_wrap.h: trying to fix #102037 + +Fri Dec 27 12:18:14 CET 2002 Daniel Veillard + + * SAX.c: fixing bug #95296, when the predefined entities + are redefined in the DTD the default one must be used + instead anyway. + +Wed Dec 25 19:22:06 MST 2002 John Fleck + + * doc/xmllint.xml + * doc/xmllint.1 + Add discussion of XML_DEBUG_CATALOG to xmllint man + page - bug #100907 + + +Mon Dec 23 16:54:22 CET 2002 Daniel Veillard + + * xmlreader.c: Fixed the empty node detection to avoid reporting + an inexistant close tag. + +Mon Dec 23 15:42:24 CET 2002 Daniel Veillard + + * python/libxml.c python/setup.py.in: patch from Stéphane Bidoul + for Python 2.1 + +Sun Dec 22 11:24:06 CET 2002 Daniel Veillard + + * testC14N.c vms/config.vms: applied Craig A. Berry patches for VMS + +Fri Dec 20 11:27:49 CET 2002 Daniel Veillard + + * doc/libxml2-api.xml python/tests/reader.py: one really need + to provide the base URI information when creating a reader parser + from an input stream. Updated the API and the example using it. + +Fri Dec 20 01:11:30 CET 2002 Daniel Veillard + + * testReader.c xmlreader.c valid.c include/libxml/tree.h + include/libxml/valid.h include/libxml/xmlreader.h: working on + DTD validation on top of xml reader interfaces. Allows to + validate arbitrary large instances. This required some extensions + to the valid module interface and augmenting the size of xmlID + and xmlRef structs a bit. + * uri.c xmlregexp.c: simple cleanup. + +Wed Dec 18 15:51:22 CET 2002 Daniel Veillard + + * xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: more + work on the xml reader interfaces. + * AUTHORS MAINTAINERS doc/* win32/*: updated Igor's mail and the + Web page for the Windows binaries. + +Tue Dec 17 19:31:07 CET 2002 Daniel Veillard + + * xmlIO.c: applied a patch for VMS following the report by + Nigel Hall + +Tue Dec 17 11:29:41 CET 2002 Daniel Veillard + + * parser.c: the parseStartTag bug fix wasn't complete. + +Mon Dec 16 23:00:05 CET 2002 Daniel Veillard + + * parser.c: Vyacheslav Pindyura managed to trigger a bug in + parseStartTag, fixing it. + * test/att4 result/att4 result/noent/att4: adding the test + * xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: added + more methods to XmlTextReader. + +Mon Dec 16 19:31:16 CET 2002 Igor Zlatkovic + + * win32/libxml2.def.src: added more xml reader exports + * win32/Makefile.msvc win32/Makefile.mingw: added xml reader interface + to the build + +Mon Dec 16 06:36:54 MST 2002 John Fleck + + * doc/tutorial/xmltutorial.xml + plus generated html and pdf + Updating tutorial again based on further comments from Niraj + Tolia on the last iteration + +Sun Dec 15 21:27:30 MST 2002 John Fleck + + * doc/tutorial/xmltutorial.xml + * doc/tutorial/includekeyword.c + * doc/tutorial/includegetattribute.c + plus generated html and pdf + Adding fix from Niraj Tolia to tutorial to properly free memory. + + +Mon Dec 16 00:34:25 CET 2002 Daniel Veillard + + * xmlreader.c include/libxml/xmlreader.h doc/libxml2-api.xml: added + more methods of XmlTextReader. + * python/libxml2class.txt python/tests/reader.py: this increased the + methods in the bndings, augmented the test to check those new + functions. + +Sat Dec 14 23:57:39 CET 2002 Daniel Veillard + + * xmlreader.c doc/libxml2-api.xml: added the close and getattribute + methods of XmlTextReader. + * python/generator.py python/libxml_wrap.h python/types.c + python/libxml2class.txt: added the reader to the Python bindings + * python/tests/Makefile.am python/tests/reader.py: added a specific + test for the Python bindings of the Reader APIs + * parser.c: small cleanup. + +Fri Dec 13 11:39:44 CET 2002 Daniel Veillard + + * xinclude.c: fallback was only copying the first child not the + full child list of the fallback element, closes #89684 as reopened + by Bernd Kuemmerlen + +Thu Dec 12 13:34:59 CET 2002 Igor Zlatkovic + + * win32/libxml2.def.src: exported htmlNodeDumpOutput + +Thu Dec 12 10:59:11 CET 2002 Daniel Veillard + + * configure.in: preparing release of 2.4.30 + * doc/apibuild.py doc/libxml2-api.xml: fixups to the api builder, + gives enum values, fix functype return type, put back fields in + structs + * doc/*: updated the docs rebuilt + +Thu Dec 12 01:09:34 CET 2002 Daniel Veillard + + * HTMLtree.c include/libxml/HTMLtree.h: patch from Mark Vadok + about htmlNodeDumpOutput location. + * xpath.c: removed an undefined function signature + * doc/apibuild.py doc/libxml2-api.xml: the script was exporting + too many symbols in the API breaking the python bindings. + Updated with the libxslt/libexslt changes. + +Wed Dec 11 20:26:15 CET 2002 Daniel Veillard + + * configure.in: preparing release of 2.4.29 + * doc/*: rebuilt the docs and API + * xmlreader.c: a few more fixes for the XmlTextReader API + +Wed Dec 11 18:01:15 CET 2002 Igor Zlatkovic + + * include/win32config.h: applied mingw patch from Magnus Henoch + +Wed Dec 11 16:58:48 CET 2002 Daniel Veillard + + * catalog.c doc/libxml2-api.xml: a bit more cleanup + +Wed Dec 11 14:54:47 CET 2002 Daniel Veillard + + * doc/apibuild.py doc/libxml2-api.xml doc/Makefile.am: new API + building Python script, does the C parsing directly, generates + a better API description including structure fieds defs and + enums. Still a couple of bugs, but good enough for the python + wrappers now. + * DOCBparser.c SAX.c nanohttp.c parser.c parserInternals.c tree.c + valid.c xmlIO.c xmlmemory.c xmlreader.c xmlregexp.c xmlschemas.c + include/libxml/schemasInternals.h include/libxml/tree.h: more + cleanup based on the python analysis script reports. + * libxml.spec.in: make sure the API XML description is part of the + devel package. + +Tue Dec 10 16:16:34 CET 2002 Daniel Veillard + + * DOCBparser.c HTMLparser.c c14n.c debugXML.c encoding.c hash.c + nanoftp.c nanohttp.c parser.c parserInternals.c testC14N.c + testDocbook.c threads.c tree.c valid.c xmlIO.c xmllint.c xmlmemory.c + xmlreader.c xmlregexp.c xmlschemas.c xmlschemastypes.c xpath.c: + code cleanup, especially the function comments. + * tree.c: fixed a small bug when freeing nodes which are XInclude ones. + +Mon Dec 9 15:08:17 CET 2002 Daniel Veillard + + * Makefile.am xmlreader.c include/libxml/Makefile.am + include/libxml/xmlreader.h: Adding a new set of APIs based on + the C# TextXmlReader API but converted to C. Allow to parse + in constant memory usage, far simpler to program and explain + than the SAX like APIs, unfinished but working. + * testReader.c: test program + +Sun Dec 8 18:36:01 CET 2002 Igor Zlatkovic + + * win32/libxml2.def.src: applied YALDSP from Mark Vakoc + +Wed Dec 4 16:08:49 CET 2002 Daniel Veillard + + * tree.c: Chip turner indicated that XHTML1 serialization + rule for style actually break on both IE and Mozilla, + try to avoid the rule if escaping ain't necessary + +Wed Dec 4 12:43:28 CET 2002 Daniel Veillard + + * nanhttp.c: handle HTTP URL escaping, problem reported by + Glen Nakamura and Stefano Zacchiroli + +Sat Nov 30 12:19:17 CET 2002 Daniel Veillard + + * DOCBparser.c HTMLparser.c parser.c valid.c xpath.c: code cleanup + +Thu Nov 28 12:53:22 CET 2002 Daniel Veillard + + * uri.c: Johann Richard pointed out some XPointer problems for + URN based URI references in XInclude. Modified the URI parsing + and saving routines to allow correct parsing and saving of + XPointers, especially when attached to "opaque" scheme accordingly + to RFC 2396 + +Wed Nov 27 20:36:08 CET 2002 Daniel Veillard + + * HTMLtree.c include/libxml/HTMLtree.h: applied the same kind + of refactoring to the HTML saving code. + * doc/libxml2-*.xml doc/API*.html: slight API changes got reflected + in the doc. + +Wed Nov 27 12:40:16 CET 2002 Daniel Veillard + + * tree.c include/libxml/tree.h: refactored the XML dump of a node + to a buffer API to reuse the generic dump to an OutputIO layer, + this reduces code, fixes xmlNodeDump() for XHTML, also made + xmlNodeDump() now return the number of byte written. + +Wed Nov 27 09:00:00 CET 2002 Daniel Veillard + + * python/setup.py.in: another patch from Stéphane Bidoul for + Python bindings on Windows + * doc/parsedecl.py: small cleanup + +Mon Nov 25 17:28:53 CET 2002 Daniel Veillard + + * libxml.spec.in configure.in: add a line in %changelog for releases + +Mon Nov 25 14:18:27 CET 2002 Daniel Veillard + + * parser.c: patch from Marcus Clarke fixing a problem in entities + parsing that was detected in KDe documentations environment. + +Mon Nov 24 14:13:21 CET 2002 ERDI Gergo + + * python/libxml.c (libxml_prev): Return the previous as opposed to + the next node (I guess this is the result of some cut & paste programming:) + +Sat Nov 23 17:22:22 CET 2002 Daniel Veillard + + * doc/Makefile.am: Jan Rafaj pointed a bug in the Makefile. + +Sat Nov 23 12:21:24 CET 2002 Daniel Veillard + + * python/generator.py python/libxml.c python/setup.py.in: trying + to fix the Python bindings build on Windows (Stéphane Bidoul) + +Fri Nov 22 22:41:34 CEST 2002 Igor Zlatkovic + + * win32/configure.js: added option for python bindings + * win32/libxml2.def.src: added more exports + +Fri Nov 22 18:50:34 CET 2002 Igor Zlatkovic + + * win32/Makefile.mingw: fixed unresolved symbols when linking with + pthreads + * win32/wince/*: applied updates to Windows CE port from Javier + +Fri Nov 22 15:51:22 CET 2002 Daniel Veillard + + * configure.in: preparing 2.4.28 + * libxml.spec.in doc/Makefile.am: some cleanup + * doc/*: updated the news and regenerated. + +Fri Nov 22 14:15:14 CET 2002 Daniel Veillard + + * HTMLparser.c: final touch at closing #87235

end tags + need to be generated. + * result/HTML/cf_128.html result/HTML/test2.html result/HTML/test3.html: + this change slightly the output of a few tests + * doc/*: regenerated + +Fri Nov 22 13:26:19 CET 2002 Daniel Veillard + + * parserInternals.c: fixing bug #99190 when UTF8 document are + parsed using the progressive parser and the end of the chunk + is in the middle of an UTF8 multibyte character. + +Fri Nov 22 13:13:00 HKT 2002 William Brack + + * threads.c: fixed initialization problem in xmlNewGlobalState + which was causing crash. + * globals.c: removed duplicate call to initxmlDefaultSAXHandler + in xmlInitializeGlobalState. + * parserInternals.c: cleaned up ctxt->sax initialisation. + +Thu Nov 21 15:05:45 CET 2002 Daniel Veillard + + * tree.c include/libxml/tree.h: modified the existing APIs + to handle XHTML1 serialization rules automatically, also add + xmlIsXHTML() to libxml2 API. Some tweaking to make sure + libxslt serialization uses it when needed without changing + the library API. + * test/xhtml1 result/noent/xhtml1 result/valid/xhtml1.xhtml + result/xhtml1: added a new test specifically for xhtml1 output + and updated the result of one XHTML1 test + +Wed Nov 20 14:24:56 CET 2002 Daniel Veillard + + * xinclude.c parserInternals.c encoding.c: fixed #99082 + for xi:include encoding="..." support on text includes. + * result/XInclude/tstencoding.xml test/XInclude/docs/tstencoding.xml + test/XInclude/ents/isolatin.txt : added a specific regression test + * python/generator.py python/libxml2class.txt: fixed the generator + the new set of comments generated for doc/libxml2-api.xml were + breaking the python generation. + +Tue Nov 19 23:25:47 CET 2002 Daniel Veillard + + * doc/Makefile.am: repair some problem if gtk-doc fail or such + * configure.in: patch for Solaris on new autoconf closes #98880 + * doc/parsedecl.py: repair the frigging API building script, + did I say that python xmllib sucks ? + * doc/libxml2-api.xml doc/libxml2-refs.xml: regenerated, reordering + and some comment are no more truncated. + +Tue Nov 19 09:09:04 CET 2002 Daniel Veillard + + * parser.c: Martin Stoilov pointed out a potential leak in + xmlCreateMemoryParserCtxt + +Mon Nov 18 16:05:51 CET 2002 Daniel Veillard + + * HTMLparser.c: fixed bug #98879 a corner case when 0 is + included in HTML documents and using the push parser. + +Mon Nov 18 00:11:24 CET 2002 ERDI Gergo + + * configure.in (PYTHON_SITE_PACKAGES): If --with-python is + specified, look for the Python interpreter not just in the + specified root but also in the specified location. Fixes #98825 + +Sun Nov 17 23:36:06 CET 2002 Daniel Veillard + + * python/libxml.c: fixing bug #98792 , node may have no doc + and dereferencing without checking ain't good ... + +Sun Nov 17 10:25:43 CET 2002 Daniel Veillard + + * configure.in: preparing release 2.4.27 + * doc/* : updated and rebuilt the docs + * doc/Makefile.am libxml.spec.in: try to make sure the tutorial + and all the docs are actually packaged and in the final RPMs + * parser.c parserInternals.c include/libxml/parser.h: restore + xmllint --recover feature. + +Sat Nov 16 16:30:25 CET 2002 Daniel Veillard + + * parser.c xpath.c: fixing #96925 wich was also dependent on the + processing of parsed entities, and XPath computation on sustitued + entities. + * testXPath.c: make sure entities are substitued. + +Fri Nov 15 16:22:54 CET 2002 Daniel Veillard + + * parser.c: fixed #96594, which was totally dependent on the + processing of internal parsed entities, which had to be changed. + +Fri Nov 15 12:16:07 CET 2002 Daniel Veillard + + * Makefile.am python/Makefile.am python/tests/Makefile.am: + trying to fix bug #98517 about building outside the source tree + * doc/xml.html doc/FAQ.html: fixed the link to libiconv #94585 + +Thu Nov 14 18:41:55 CEST 2002 Igor Zlatkovic + + * include/win32config.h: cleanup + * win32/Makefile.mingw: integrated mingw in JScript configure + * win32/Makefile.msvc: modified to allow mingw coexistence + * win32/configure.js: integrated mingw + * win32/Readme.txt: cleanup + +Tue Nov 12 22:06:45 CET 2002 Daniel Veillard + + * HTMLparser.c: strengthen the guard in the Pop macros, + like in the XML parser, closes bug #97315 + +Tue Nov 12 21:56:39 CET 2002 Daniel Veillard + + * include/libxml/parser.h: fixed bug #98338 , fatalError SAX + callback is never used. + +Tue Nov 12 13:32:50 CET 2002 Daniel Veillard + + * parserInternals.c: fixed the initialization of the SAX structure + which was breaking xsltproc + * xpath.c: patch from Petr Pajas for CDATA nodes + * tree.c: patch from Petr Pajas improving xmlGetNodePath() + * parser.c include/libxml/parser.h: patch from Peter Jones + removing a leak in xmlSAXParseMemory() and adding the + function xmlSAXParseMemoryWithData() + +Mon Nov 11 20:47:03 MST 2002 John Fleck + + adding pdf of tutorial, changing web page to link to it + * doc/tutorial/xmltutorial.pdf + * doc/xml.html + * doc/docs.html + +Sun Nov 10 20:48:57 MST 2002 John Fleck + + * doc/tutorial/ar01s08.html + adding file what I forgot for tutorial + + +Sun Nov 10 20:33:13 MST 2002 John Fleck + + Adding encoding discussion to tutorial + Added: + * doc/tutorial/images/*.png: DocBook admonition image files + * doc/tutorial/apf.html, apg.html: new generated html + * doc/tutorial/includeconvert.c: conversion code entity file + changed: + * doc/tutorial/xmltutorial.xml: DocBook original + * doc/tutorial/*.html: generated html + +Fri Nov 8 17:59:32 CEST 2002 Igor Zlatkovic + + * include/libxml/*.h: retired xmlwin32version.h + * doc/Makefile.am: retired xmlwin32version.h + * win32/configure.js: retired xmlwin32version.h + +Fri Nov 8 16:55:47 CEST 2002 Igor Zlatkovic + + * win32/libxml2.def.src: exported additional symbols + * include/libxml/xmlmemory.h: exported the rest of the xmlMem* + sisterhood + +Fri Nov 8 16:08:13 CET 2002 Daniel Veillard + + * globals.c: fixed a typo pointed out by Igor + * xpath.c: try to speed up node compare using line numbers + if available. + +Thu Nov 7 15:16:02 CET 2002 Daniel Veillard + + * tree.c: make xmlFreeNode() handle attributes correctly. + +Wed Nov 6 23:51:11 CET 2002 Igor Zlatkovic + + * catalog.c: completed the #96963 fix, as reported by Karl + Eichwalder + +Wed Nov 6 16:48:44 CET 2002 Daniel Veillard + + * xpointer.c: tried to fix bug #97852 reported by Nicolas Noffke + +Sun Nov 3 10:43:44 CET 2002 Daniel Veillard + + * Makefile.am: switched the order of a couple of includes + to fix bugs #97100 + +Thu Oct 31 17:11:46 CEST 2002 Igor Zlatkovic + + * catalog.c: fixed bug #96963, reverted to the old behaviour of + xmlLoadCatalogs that used to separate directories with a ':'. + +Thu Oct 31 16:55:21 CEST 2002 Igor Zlatkovic + + * threads.c: improvements to the Windows-side of thread handling + * testThreads.c: conditionally excluded unistd.h + * testThradsWin32.c: broke overlong lines + * include/win32config.h: adapted thread-related macros to the new + scheme and for pthreads on Windows + * win32/Makefile.msvc: introduced a more flexible thread build, + added testThreads[Win32].c to the build + * win32/configure.js: introduced a more flexible thread config + +2002-10-31 John Fleck + + * doc/xml.html (and, by implication, FAQ.html) + added UTF-8 conversaion FAQ from Marcus Labib Iskander + +Tue Oct 29 18:32:33 CET 2002 Igor Zlatkovic + + * configure.in: removed xmlwin32version.h + * include/libxml/Makefile.am: removed xmlwin32version.h + +Mon Oct 28 14:01:29 CET 2002 Daniel Veillard + + * tree.c: applied patch from Brian Stafford to fix a bug + in xmlReconciliateNs() + +Mon Oct 28 13:51:55 CET 2002 Daniel Veillard + + * tree.c: applied patch from Christian Glahn to allow + xmlNewChild() on document fragment nodes + +Sat Oct 26 15:27:00 CEST 2002 Daniel Veillard + + * parser.c: Christian Glahn found a problem with a recent + patch to xmlParseBalancedChunkMemoryRecover() + * xmlschemas.c: Charles Bozeman fixed some Schemas validation + problems + * result/schemas/elem* result/schemas/seq* test/schemas.elem* + test/schemas/seq*: added the test cases from Charles + +Wed Oct 23 16:42:29 CEST 2002 Daniel Veillard + + * Makefile.am config.h.in libxml.spec.in doc/Makefile.am: + serious cleanup of the spec file and associated changes + in the Makefiles. + * valid.c: try to remove some warnings on x86_64 + +Wed Oct 23 10:53:42 CEST 2002 Daniel Veillard + + * include/Makefile.am: added winsockcompat.h to EXTRA_DIST to + fix bug #96586 + +Tue Oct 22 21:13:06 CEST 2002 Daniel Veillard + + * HTMLparser.c: Mikhail Sogrine pointed out a bug in HTML + parsing, applied his patch + * result/HTML/attrents.html result/HTML/attrents.html.err + result/HTML/attrents.html.sax test/HTML/attrents.html: + added the test and result case provided by Mikhail Sogrine + +Tue Oct 22 19:33:20 CEST 2002 Daniel Veillard + + * vms/build_libxml.com vms/config.vms vms/readme.vms + include/libxml/parser.h include/libxml/parserInternals.h + include/libxml/tree.h include/libxml/xmlIO.h + HTMLparser.c catalog.c debugXML.c parser.c parserInternals.c + tree.c triodef.h trionan.c uri.c xmlIO.c xpath.c: + Applied the VMS update patch from Craig A. Berry + * doc/*.html: update + +Tue Oct 22 16:27:31 CEST 2002 Daniel Veillard + + * include/libxml/encoding.h encoding.c: made xmlGetUTF8Char public + +Tue Oct 22 16:25:18 CEST 2002 Daniel Veillard + + * debugXML.c: adding a grep command to --shell in xmllint + for T.V. Raman + +Tue Oct 22 16:23:57 CEST 2002 Daniel Veillard + + * xmlcatalog.c: tried to fix some of the problem with --sgml + +Mon Oct 21 09:57:10 CEST 2002 Daniel Veillard + + * parser.c: tried to fix bug #91500 where doc->children may + be overriden by a call to xmlParseBalancedChunkMemory() + +Mon Oct 21 09:04:32 CEST 2002 Daniel Veillard + + * catalog.c: tried to fix bug #90945 w.r.t. parsing of system + identifiers in SGML catalogs containing '&' + +Sun Oct 20 23:31:47 CEST 2002 Daniel Veillard + + * python/types.c: fixed bugs when passing result value tree + to Python functions. + +Fri Oct 18 13:18:53 CEST 2002 Daniel Veillard + + * configure.in: preparing the release of 2.4.26 + * doc/*: updated and rebuilt the documentation + +Wed Oct 16 20:01:46 CEST 2002 Daniel Veillard + + * parser.c: fixed a XML Namespace compliance bug reported by + Alexander Grimalovsky + +Wed Oct 16 17:18:42 CEST 2002 Daniel Veillard + + * HTMLtree.c: fixed serialization of script and style when + they are not lowercase (i.e. added using the API to the tree). + +Wed Oct 16 16:31:05 CEST 2002 Daniel Veillard + + * valid.c: make xmlValidateDocument emit a warning msg if there + is no DTD, pointed by Christian Glahn + +Wed Oct 16 16:05:38 CEST 2002 Daniel Veillard + + * xmlregexp.c xmlschemas.c: fixed the validation of sequences + content model when some of the blocks have min or max, and a couple + of bugs found in the process. + * result/schemas/list0* test/schemas/list0*: added some specific + regression tests + +Tue Oct 15 12:41:01 CEST 2002 Daniel Veillard + + * README: updated the contact informations + +Tue Oct 15 10:35:57 CEST 2002 Daniel Veillard + + * Makefile.am: use test -f instead of test -e since Solaris /bin/sh + misses it, reported by Peter Bray. + +Mon Oct 14 17:37:32 CEST 2002 Daniel Veillard + + * tree.c: investigating xmlNodeGetContent() on namespace nodes + and removed a few warnings + +Mon Oct 14 13:12:55 CEST 2002 Daniel Veillard + + * parser.c: Christian Glahn found a small bug in the push parser. + * xmlIO.c include/libxml/xmlIO.h: cleaned up and made xmlCheckFilename + public + +Wed Oct 9 23:11:02 CEST 2002 Daniel Veillard + + * xmlschemas.c include/libxml/xmlschemas.h: added + xmlSchemaNewMemParserCtxt to parse a schemas from a memory area + * testSchemas.c: added --memory to test the new interface + +Wed Oct 9 16:22:54 CEST 2002 Daniel Veillard + + * doc/index.py doc/search.php: integrated the XSLT indexing, + a few fixed in the indexer, added a scope selection at the + search level. + +Wed Oct 9 12:18:37 CEST 2002 Daniel Veillard + + * valid.c: Joe Marcus Clarke reported a segfault on FBsd + this was due to uninitialized parts of the validation context + +Tue Oct 8 23:24:20 CEST 2002 Daniel Veillard + + * debugXML.c: applied patch from Mark Vakoc except the API + change, preserved it. + * doc/*: updated the docs to point to the search engine for + information lookup or before bug/help reports. + +Tue Oct 8 18:53:31 CEST 2002 Daniel Veillard + + * doc/index.py doc/search.php: added mailing-list archives + indexing and lookup + +Tue Oct 8 10:25:07 CEST 2002 Daniel Veillard + + * tree.c: patch from Mark Vakoc to fix xmlNodeGetPath() + +Mon Oct 7 13:12:03 CEST 2002 Daniel Veillard + + * doc/index.py: improved HTML indexing + * doc/search.php: make the queries also lookup the HTML based indexes + +Sun Oct 6 23:50:29 CEST 2002 Daniel Veillard + + * doc/index.py: added HTML page indexing + +Fri Oct 4 15:33:55 CEST 2002 Igor Zlatkovic + + * xmlIO.c: extended Windows path normalisation to fix the base + problem in libxslt. + * catalog.c: fixed list handling in XML_CATALOG_FILES + +Fri Oct 4 13:43:02 CEST 2002 Daniel Veillard + + * valid.c: typo/bug found by Christian Glahn + +Sun Sep 29 19:44:10 CEST 2002 Igor Zlatkovic + + * xmlIO.c: applied Windows CE patch from Javier. + * win32/wince: new directory, contains support for the PocketPC + with Windows CE from Javier. + * include/win32config.h: reorganised, removed duplicate + definitions and applied WinCE patch from Javier. + * include/wsockcompat.h: new file, now contains WinSock + compatibility macros. + * win32/Makefile.msvc: introduced double-run compilation. + +Thu Sep 26 19:48:06 CEST 2002 Daniel Veillard + + * configure.in include/libxml/xmlwin32version.h: preparing release + of 2.4.25 + * doc/*: updated and regenerated teh docs and web pages. + +Thu Sep 26 17:33:46 CEST 2002 Daniel Veillard + + * SAX.c valid.c include/libxml/valid.h: fixed bug #92518 validation + error were not covering namespace declarations. + * result/valid/dia.xml test/valid/dia.xml: the test wasn't valid, + it was missing the attribute declaration for the namespace + * result/VC/NS3: the fix now report breakages in that test + +Thu Sep 26 14:39:07 CEST 2002 Daniel Veillard + + * HTMLtree.c: fixing bug #94241 on HTML boolean attributes + +Thu Sep 26 14:25:33 CEST 2002 Daniel Veillard + + * doc/*: added the 3 new modules xmlregexp xmlautomata and xmlunicode + and regenerated the docs and web site + +Thu Sep 26 11:45:42 CEST 2002 Daniel Veillard + + * xinclude.c xmlschemas.c xmlschemastypes.c xpath.c: make sure + ATTRIBUTE_UNUSED is always put after the attribute declaration, + not before + +Thu Sep 26 11:33:28 CEST 2002 Daniel Veillard + + * python/generator.py python/libxml2class.txt: fixed a stupid error + breaking the python API + +Thu Sep 26 00:31:46 CEST 2002 Daniel Veillard + + * trio.c trio.h triodef.h trionan.c trionan.h triop.h + triostr.c triostr.h: applied a trio update patch from + Bjorn Reese which should work with MinGW + +Thu Sep 26 00:21:18 CEST 2002 Daniel Veillard + + * tree.c: improving some documentation comments + * xmlregexp.c: found and fixed a mem leak with python regression tests + * doc/*: rebuilt the doc and the API XML file including the + xmlregexp.h xmlautomata.h and xmlunicode.h headers + * python/generator.py python/libxml2class.txt python/libxml_wrap.h + python/types.c: added access to the XML Schemas regexps from + python + * python/tests/Makefile.am python/tests/regexp.py: added a + simple regexp bindings test + +Tue Sep 24 08:10:48 MDT 2002 John Fleck + + * doc/xml.html: + fixing ftp links - thanks to Vitaly Ostanin + +Tue Sep 24 16:08:17 CEST 2002 Daniel Veillard + + * xmlregexp.c: fixed the data callback on transition functionality + which was broken when using the compact form + * result/schemas/*: updated the results, less verbose, all tests + pass like before + * DOCBparser.c testAutomata.c testC14N.c testSchemas.c testThreads.c + testXPath.c valid.c xinclude.c xmllint.c xmlregexp.c xmlschemas.c + xmlschemastypes.c xpath.c python/libxml.c: removed a bunch of + annoying warnings + * xpath.c: try to provide better error report when possible + +Sat Sep 21 14:56:37 CEST 2002 Daniel Veillard + + * Makefile.am: fixed a breakage raised by Jacob + +Fri Sep 20 20:08:18 CEST 2002 Igor Zlatkovic + + * include/win32config.h: added HAVE_ERRNO_H definition for parts + which don't use sockets + +Fri Sep 20 18:40:50 CEST 2002 Igor Zlatkovic + + * win32/Makefile.msvc: applied zlib patch from Daniel Gehriger + * win32/configure.js: applied zlib patch from Daniel Gehriger + +Fri Sep 20 15:40:14 CEST 2002 Igor Zlatkovic + + * win32/configure.js: applied the patch from Mark Vakoc for + regexp support + * win32/libxml2.def.src: applied the patch from Mark Vakoc + for regexp support + +Fri Sep 20 15:35:33 CEST 2002 Daniel Veillard + + * xmlschemastypes.c: as pointed by Igor Float and Double + parsing ain't finished yet + +Fri Sep 20 14:00:16 CEST 2002 Daniel Veillard + + * Makefile.am configure.in: trying to fix #88412 by bypassing + all the python subdir if python ain't detected + +Thu Sep 19 21:46:53 CEST 2002 Daniel Veillard + + * Makefile.am configure.in include/libxml/xmlversion.h.in: + made configuring with regexps/automata/unicode the default + but without schemas ATM + * testRegexp.c valid.c xmlregexp.c include/libxml/xmlregexp.h: + fixed the regexp based DTD validation performance and memory + problem by switching to a compact form for determinist regexps + and detecting the determinism property in the process. Seems + as fast as the old DTD validation specific engine :-) despite + the regexp built and compaction process. + +Wed Sep 18 18:27:26 CEST 2002 Daniel Veillard + + * valid.c: determinism is debugged, new DTD checking code now works + but xmlFAComputesDeterminism takes far too much CPU and the whole + set usues too much memory to be really usable as-is + +Wed Sep 18 00:54:30 CEST 2002 Daniel Veillard + + * tree.c: fixed another stupid bug in xmlGetNodePath() + * xmllint.c: --version now report the options compiled in + +Tue Sep 17 23:48:07 CEST 2002 Daniel Veillard + + * HTMLparser.c: small cleanup + * valid.c xmlregexp.c: switched DTD validation to use only regexp + when configured with them. A bit of debugging around the determinism + checks is still needed + +Tue Sep 17 21:22:25 CEST 2002 Daniel Veillard + + * python/libxml_wrap.h: stupid bug found by mattam@netcourrier.com + +Tue Sep 17 19:58:26 CEST 2002 Daniel Veillard + + * xmlIO.c: small portability glitch fixed. + +Mon Sep 17 12:38:08 CEST 2002 Daniel Veillard + + * xmlschemastypes.c: incomplete steps for real/double support + * testAutomata.c include/libxml/xmlautomata.h + include/libxml/xmlregexp.h: avoiding a compilation problem + * valid.c include/libxml/valid.h: starting the work toward using + the regexps for actual DTD validation + +Fri Sep 13 16:46:14 CEST 2002 Daniel Veillard + + * hash.c: cosmetic cleanup + * valid.c include/libxml/tree.h include/libxml/valid.h: started + integrating a DTD validation layer based on the regexps + +Thu Sep 12 18:01:29 CEST 2002 Daniel Veillard + + * xmlregexp.c xmlschemas.c: fixed a bug reported by Jeff Goff, + the determinism was tested before eliminating the epsilon + transitions :-( + +Thu Sep 12 16:57:45 CEST 2002 Daniel Veillard + + * python/generator.py python/libxml.c python/libxml.py + python/libxml2-python-api.xml python/libxml2class.txt + python/libxml_wrap.h python/types.c: updated the python + bindings, added code for easier File I/O, and the ability to + define a resolver from Python fixing bug #91635 + * python/tests/Makefile.am python/tests/inbuf.py + python/tests/outbuf.py python/tests/pushSAXhtml.py + python/tests/resolver.py python/tests/serialize.py: updated + and augmented the set of Python tests. + +Tue Sep 10 21:05:28 CEST 2002 Igor Zlatkovic + + * win32/configure.js: added more readme info for the binary + package. + +Tue Sep 10 14:15:18 CEST 2002 Daniel Veillard + + * xmlIO.c: fixed a stupid out of bound array error + +Tue Sep 10 13:09:14 CEST 2002 Daniel Veillard + + * include/libxml/xmlIO.h xmlIO.c parser.c HTMLparser.c DOCBparser.c: + messing around with support for Windows path, cleanups, + trying to identify and fix the various code path to the + filename access. Added xmlNormalizeWindowsPath() + +Thu Sep 5 16:19:18 CEST 2002 Daniel Veillard + + * error.c valid.c: working on better error reporting of validity + errors, especially providing an accurate context. + * result/valid/xlink.xml.err result/valid/rss.xml.err: better + error reports in those cases. + +Thu Sep 5 13:29:47 CEST 2002 Daniel Veillard + + * DOCBparser.c HTMLparser.c c14n.c entities.c list.c + parser.c parserInternals.c xmlIO.c: get rid of all the + perror() calls made in the library execution paths. This + should fix both #92059 and #92385 + +Thu Sep 5 13:13:17 CEST 2002 Daniel Veillard + + * xmllint.c: memory leak reporting was broken after a change + of the preprocessor symbol used to activate it. + +Thu Sep 5 13:10:57 CEST 2002 Daniel Veillard + + * tree.c: try to make the copy function work for node of + type XML_DOCUMENT_FRAG_NODE, they are only created by the + DOM layers though, not libxml2 itself. + +Thu Sep 5 12:57:38 CEST 2002 Daniel Veillard + + * valid.c: try to provide file and line informations, not all + messages are covered, but it's a (good) start + +Thu Sep 5 12:49:35 CEST 2002 Daniel Veillard + + * xinclude.c: reimplemented a large part of the XInclude + processor, trying to minimize resources used, James Henstridge + provided a huge test case which was exhibiting severe memory + consumption problems. + +Thu Sep 5 10:07:13 CEST 2002 Daniel Veillard + + * python/Makefile.am: applied patch from Christophe Merlet to + reestablish DESTDIR + +Wed Sep 4 14:13:34 CEST 2002 Daniel Veillard + + * libxml.spec.in: fixes libary path for x86_64 AMD + +Tue Sep 3 21:14:19 MDT 2002 John Fleck + + * doc/tutorial/includekeyword.c + * doc/tutorial/xmltutorial.xml: + (plus resulting generated html files) + fixing one spot I missed in the tutorial where I hadn't freed + memory properly + +Sat Aug 31 19:31:17 MDT 2002 John Fleck + + * doc/tutorial/includeaddattribute.c + * doc/tutorial/includeaddkeyword.c + * doc/tutorial/includegetattribute.c + * doc/tutorial/includekeyword.c + * doc/tutorial/xmltutorial.xml + * doc/tutorial/*.html: + update tutorial to properly free memory (thanks to Christopher + R. Harris for pointing out that this needs to be done) + * doc/tutorial/images/callouts/*.png: + added image files so the callouts are graphical, making it + easier to read ( use "--param callout.graphics 1" to generate + html with graphical callouts) + +Wed Aug 28 13:44:54 CEST 2002 Daniel Veillard + + * doc/Libxml2-Logo-180x168.gif doc/Libxml2-Logo-90x34.gif: + nice logos generated by Marc Liyanage + * doc/site.xsl *.html: changed the stylesheet to show the new + logo and regenerated the pages + +Sun Aug 25 16:38:05 CEST 2002 Daniel Veillard + + * xmlIO.c: handle Windows sepecific file://localhost/ semantic ... + +Thu Aug 22 22:03:19 CEST 2002 Daniel Veillard + + * xpath.c: possible mem leak patch from Jason Adams + +Thu Aug 22 17:27:30 CEST 2002 Daniel Veillard + + * xpath.c: integrated xf:escape-uri() from Wesley Terpstra + in the XQuery namespace + * configure.in: preparing 2.4.24 + * doc/*.html: updated the web pages + +Thu Aug 22 16:19:42 CEST 2002 Daniel Veillard + + * python/generator.py: closing bug #85258 by generating conditional + compile check to avoid linking to routines not configured in. + +2002-08-22 Havoc Pennington + + * autogen.sh: update error message for missing automake + +Thu Aug 22 11:45:50 CEST 2002 Daniel Veillard + + * python/Makefile.am: typo in target name resulted in libxml2.py + to not be rebuilt. fixed DESTDIR similary to the libxslt one. + +Thu Aug 22 09:15:00 CEST 2002 Daniel Veillard + + * win32/win32/Makefile.mingw: updated with version from + Elizabeth Barham at http://soggytrousers.net/repository/ + +Tue Aug 20 16:40:48 CEST 2002 Igor Zlatkovic + + * win32/Makefile.msvc: added the prefix location to the include + and lib search path. + +2002-08-18 Havoc Pennington + + * autogen.sh: hardcode aclocal-1.4/automake-1.4 so that users with + both automake 1.6 and 1.4 installed get the right automake. Means + compilation from CVS will now require the latest automake 1.4 + release, or manually creating symlinks called "automake-1.4" and + "aclocal-1.4" + +Wed Aug 14 18:54:19 CEST 2002 Daniel Veillard + + * configure.in python/Makefile.am: more AMD 64 induced changes from + Frederic Crozat + +Wed Aug 14 16:43:53 CEST 2002 Daniel Veillard + + * xinclude.c: oops I was missing the xml:base fixup too + * result/XInclude/*.xml: this adds xml:base attributes to most + results of the tests + +Wed Aug 14 16:05:37 CEST 2002 Daniel Veillard + + * xinclude.c: quick but apparently working implementation of + xi:fallback, should close bug #89684 + * Makefile.am test/XInclude/docs/fallback.xml + result/XInclude/fallback.xml: added a basic test for fallback, + and run with --nowarning to avoid a spurious warning + * configure.in: applied patch from Frederic Crozat for python + bindings on AMD 64bits machines. + +Wed Aug 14 10:47:46 CEST 2002 Daniel Veillard + + * parser.c: xmlSAXUserParseMemory() really ought to fail if + the caller don't pass a SAX callback block. + +Wed Aug 14 10:29:02 CEST 2002 Daniel Veillard + + * tree.c: applied the same fix for the XML-1.0 namespace to + xmlSearchNsByHref() as was done for xmlSearchNs() + +Mon Aug 12 16:52:08 CEST 2002 Daniel Veillard + + * libxml.3: small cleanup of the man page + * HTMLtree.c: fixed a potential problem raised by Petr Vandrovec + when serializing HREF attributes generated by XSLT. + +Mon Aug 12 15:24:05 CEST 2002 Daniel Veillard + + * HTMLtree.c include/libxml/HTMLtree.h: integrated a cleaned up + version of Marc Liyanage' patch for boolean attributes in HTML + output + +Mon Aug 12 14:11:59 CEST 2002 Daniel Veillard + + * python/tests/serialize.py: fixed the test results, indenting + behaviour changed slightly + +Thu Aug 8 11:00:26 2002 Aleksey Sanin + + * win32/dsp/libxml2.def.src win32/libxml2.def.src: added + new c14n function to Windows def files + +Fri Aug 2 16:46:46 2002 Aleksey Sanin + + * c14n.c: fixed a memory leak in c14n code + +Sat Aug 3 00:15:06 CEST 2002 Daniel Veillard + + * parser.c include/libxml/parser.h: adding a new API for Christian + Glahn: xmlParseBalancedChunkMemoryRecover + * valid.c: patch from Rick Jones for some grammar cleanup in + validation messages + * result/VC/* result/valid/*: this slightly change some of the + regression tests outputs + +Thu Aug 1 14:50:28 CEST 2002 Daniel Veillard + + * tree.c: trying to fix a problem in namespaced attribute handling + raised by Christian Glahn + +Thu Aug 1 12:17:30 CEST 2002 Daniel Veillard + + * encoding.c include/libxml/encoding.h: Opening the interface + xmlNewCharEncodingHandler as requested in #89415 + * python/generator.py python/setup.py.in: applied cleanup + patches from Marc-Andre Lemburg + * tree.c: fixing bug #89332 on a specific case of loosing + the XML-1.0 namespace on xml:xxx attributes + +Wed Jul 31 23:27:42 2002 Aleksey Sanin + + * c14n.c include/libxml/c14n.h: fixed one more c14n + namespaces + corner case from new Merlin's test suite and added a callback + that will be used to improve xmlsec performance + + +Mon Jul 29 18:22:00 CEST 2002 Daniel Veillard + + * HTMLtree.c: trying to fix the