diff --git a/build/flexcat b/build/flexcat deleted file mode 100755 index 0630f31e..00000000 Binary files a/build/flexcat and /dev/null differ diff --git a/build/flexcat/AUTHORS b/build/flexcat/AUTHORS new file mode 100644 index 00000000..fb1889fa --- /dev/null +++ b/build/flexcat/AUTHORS @@ -0,0 +1,38 @@ +/* $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +FlexCat is an Open Source development effort with the code base and +design provided by the following people: + +David Rey +Marcin Orlowski +Jens Langner +Jochen Wiedmann +Joerg Strohmayer +Thore Böckelmann + +Translations provided and maintained by following people: + +Czech: Vit Sindlar +German: Thore Böckelmann +Polish: Mariusz Danilewicz + +The development of FlexCat is hosted by SourceForge http://www.sf.net/ diff --git a/build/flexcat/COPYING b/build/flexcat/COPYING new file mode 100644 index 00000000..5b6e7c66 --- /dev/null +++ b/build/flexcat/COPYING @@ -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/build/flexcat/FlexCat_cat.h b/build/flexcat/FlexCat_cat.h new file mode 100644 index 00000000..05bb72be --- /dev/null +++ b/build/flexcat/FlexCat_cat.h @@ -0,0 +1,172 @@ + +/**************************************************************** + + This file was created automatically by `FlexCat 2.15' + from "locale/FlexCat.pot". + + Do NOT edit by hand! + +****************************************************************/ + +#ifndef FlexCat_CAT_H +#define FlexCat_CAT_H + + +#ifndef EXEC_TYPES_H +#include +#endif + +void LocalizeStringArray(STRPTR *Array); +void OpenFlexCatCatalog(); +void CloseFlexCatCatalog(); + +struct FC_String +{ + const char *Str; + const LONG Id; +}; + +extern struct FC_String FlexCat_Strings[]; + +#define MSG_USAGE_HEAD (FlexCat_Strings[0].Str) +#define _MSG_USAGE_HEAD 0 +#define MSG_USAGE (FlexCat_Strings[1].Str) +#define _MSG_USAGE 1 +#define MSG_FILEUPTODATE (FlexCat_Strings[2].Str) +#define _MSG_FILEUPTODATE 2 +#define MSG_ERR_WARNING (FlexCat_Strings[3].Str) +#define _MSG_ERR_WARNING 3 +#define MSG_ERR_ERROR (FlexCat_Strings[4].Str) +#define _MSG_ERR_ERROR 4 +#define MSG_ERR_EXPECTEDHEX (FlexCat_Strings[5].Str) +#define _MSG_ERR_EXPECTEDHEX 5 +#define MSG_ERR_EXPECTEDOCTAL (FlexCat_Strings[6].Str) +#define _MSG_ERR_EXPECTEDOCTAL 6 +#define MSG_ERR_NOLENGTHBYTES (FlexCat_Strings[7].Str) +#define _MSG_ERR_NOLENGTHBYTES 7 +#define MSG_ERR_UNKNOWNCDCOMMAND (FlexCat_Strings[8].Str) +#define _MSG_ERR_UNKNOWNCDCOMMAND 8 +#define MSG_ERR_UNEXPECTEDBLANKS (FlexCat_Strings[9].Str) +#define _MSG_ERR_UNEXPECTEDBLANKS 9 +#define MSG_ERR_NOIDENTIFIER (FlexCat_Strings[10].Str) +#define _MSG_ERR_NOIDENTIFIER 10 +#define MSG_ERR_MISSINGSTRING (FlexCat_Strings[11].Str) +#define _MSG_ERR_MISSINGSTRING 11 +#define MSG_ERR_UNKNOWNCTCOMMAND (FlexCat_Strings[12].Str) +#define _MSG_ERR_UNKNOWNCTCOMMAND 12 +#define MSG_ERR_UNKNOWNIDENTIFIER (FlexCat_Strings[13].Str) +#define _MSG_ERR_UNKNOWNIDENTIFIER 13 +#define MSG_ERR_UNKNOWNSTRINGTYPE (FlexCat_Strings[14].Str) +#define _MSG_ERR_UNKNOWNSTRINGTYPE 14 +#define MSG_ERR_NOTERMINATEBRACKET (FlexCat_Strings[15].Str) +#define _MSG_ERR_NOTERMINATEBRACKET 15 +#define MSG_ERR_NOBINCHARS (FlexCat_Strings[16].Str) +#define _MSG_ERR_NOBINCHARS 16 +#define MSG_ERR_CTGAP (FlexCat_Strings[17].Str) +#define _MSG_ERR_CTGAP 17 +#define MSG_ERR_DOUBLECTLANGUAGE (FlexCat_Strings[18].Str) +#define _MSG_ERR_DOUBLECTLANGUAGE 18 +#define MSG_ERR_DOUBLECTVERSION (FlexCat_Strings[19].Str) +#define _MSG_ERR_DOUBLECTVERSION 19 +#define MSG_ERR_WRONGRCSID (FlexCat_Strings[20].Str) +#define _MSG_ERR_WRONGRCSID 20 +#define MSG_ERR_NOMEMORY (FlexCat_Strings[21].Str) +#define _MSG_ERR_NOMEMORY 21 +#define MSG_ERR_NOCATALOGDESCRIPTION (FlexCat_Strings[22].Str) +#define _MSG_ERR_NOCATALOGDESCRIPTION 22 +#define MSG_ERR_NOCATALOGTRANSLATION (FlexCat_Strings[23].Str) +#define _MSG_ERR_NOCATALOGTRANSLATION 23 +#define MSG_ERR_NOCTVERSION (FlexCat_Strings[24].Str) +#define _MSG_ERR_NOCTVERSION 24 +#define MSG_ERR_NOCATALOG (FlexCat_Strings[25].Str) +#define _MSG_ERR_NOCATALOG 25 +#define MSG_ERR_NONEWCTFILE (FlexCat_Strings[26].Str) +#define _MSG_ERR_NONEWCTFILE 26 +#define MSG_ERR_NOCTLANGUAGE (FlexCat_Strings[27].Str) +#define _MSG_ERR_NOCTLANGUAGE 27 +#define MSG_ERR_NOSOURCE (FlexCat_Strings[28].Str) +#define _MSG_ERR_NOSOURCE 28 +#define MSG_ERR_NOSOURCEDESCRIPTION (FlexCat_Strings[29].Str) +#define _MSG_ERR_NOSOURCEDESCRIPTION 29 +#define MSG_ERR_NOCTARGUMENT (FlexCat_Strings[30].Str) +#define _MSG_ERR_NOCTARGUMENT 30 +#define MSG_ERR_CANTCHECKDATE (FlexCat_Strings[31].Str) +#define _MSG_ERR_CANTCHECKDATE 31 +#define MSG_ERR_NOCTFILENAME (FlexCat_Strings[32].Str) +#define _MSG_ERR_NOCTFILENAME 32 +#define MSG_ERR_NOCATFILENAME (FlexCat_Strings[33].Str) +#define _MSG_ERR_NOCATFILENAME 33 +#define MSG_ERR_BADPREFS (FlexCat_Strings[34].Str) +#define _MSG_ERR_BADPREFS 34 +#define MSG_ERR_BADCTLANGUAGE (FlexCat_Strings[35].Str) +#define _MSG_ERR_BADCTLANGUAGE 35 +#define MSG_ERR_DOUBLECTCODESET (FlexCat_Strings[36].Str) +#define _MSG_ERR_DOUBLECTCODESET 36 +#define MSG_ERR_BADCTCODESET (FlexCat_Strings[37].Str) +#define _MSG_ERR_BADCTCODESET 37 +#define MSG_ERR_NOCTCODESET (FlexCat_Strings[38].Str) +#define _MSG_ERR_NOCTCODESET 38 +#define MSG_ERR_ERROR_QUICK (FlexCat_Strings[39].Str) +#define _MSG_ERR_ERROR_QUICK 39 +#define MSG_ERR_BADCTVERSION (FlexCat_Strings[40].Str) +#define _MSG_ERR_BADCTVERSION 40 +#define MSG_ERR_WARNING_QUICK (FlexCat_Strings[41].Str) +#define _MSG_ERR_WARNING_QUICK 41 +#define MSG_ERR_MISSINGTRANSLATION (FlexCat_Strings[42].Str) +#define _MSG_ERR_MISSINGTRANSLATION 42 +#define MSG_ERR_EMPTYTRANSLATION (FlexCat_Strings[43].Str) +#define _MSG_ERR_EMPTYTRANSLATION 43 +#define MSG_ERR_MISMATCHINGCONTROLCHARACTERS (FlexCat_Strings[44].Str) +#define _MSG_ERR_MISMATCHINGCONTROLCHARACTERS 44 +#define MSG_ERR_DOUBLE_IDENTIFIER (FlexCat_Strings[45].Str) +#define _MSG_ERR_DOUBLE_IDENTIFIER 45 +#define MSG_ERR_STRING_TOO_SHORT (FlexCat_Strings[46].Str) +#define _MSG_ERR_STRING_TOO_SHORT 46 +#define MSG_ERR_STRING_TOO_LONG (FlexCat_Strings[47].Str) +#define _MSG_ERR_STRING_TOO_LONG 47 +#define MSG_ERR_TRAILING_ELLIPSIS (FlexCat_Strings[48].Str) +#define _MSG_ERR_TRAILING_ELLIPSIS 48 +#define MSG_ERR_NO_TRAILING_ELLIPSIS (FlexCat_Strings[49].Str) +#define _MSG_ERR_NO_TRAILING_ELLIPSIS 49 +#define MSG_ERR_TRAILING_BLANKS (FlexCat_Strings[50].Str) +#define _MSG_ERR_TRAILING_BLANKS 50 +#define MSG_ERR_NO_TRAILING_BLANKS (FlexCat_Strings[51].Str) +#define _MSG_ERR_NO_TRAILING_BLANKS 51 +#define MSG_ERR_MISMATCHING_PLACEHOLDERS (FlexCat_Strings[52].Str) +#define _MSG_ERR_MISMATCHING_PLACEHOLDERS 52 +#define MSG_ERR_MISSING_PLACEHOLDERS (FlexCat_Strings[53].Str) +#define _MSG_ERR_MISSING_PLACEHOLDERS 53 +#define MSG_ERR_EXCESSIVE_PLACEHOLDERS (FlexCat_Strings[54].Str) +#define _MSG_ERR_EXCESSIVE_PLACEHOLDERS 54 +#define MSG_ERR_NO_LEADING_BRACKET (FlexCat_Strings[55].Str) +#define _MSG_ERR_NO_LEADING_BRACKET 55 +#define MSG_ERR_NO_TRAILING_BRACKET (FlexCat_Strings[56].Str) +#define _MSG_ERR_NO_TRAILING_BRACKET 56 +#define MSG_ERR_DOUBLE_ID (FlexCat_Strings[57].Str) +#define _MSG_ERR_DOUBLE_ID 57 +#define MSG_ERR_NO_MIN_LEN (FlexCat_Strings[58].Str) +#define _MSG_ERR_NO_MIN_LEN 58 +#define MSG_ERR_NO_MAX_LEN (FlexCat_Strings[59].Str) +#define _MSG_ERR_NO_MAX_LEN 59 +#define MSG_ERR_EXTRA_CHARACTERS (FlexCat_Strings[60].Str) +#define _MSG_ERR_EXTRA_CHARACTERS 60 +#define MSG_ERR_EXTRA_CHARACTERS_ID (FlexCat_Strings[61].Str) +#define _MSG_ERR_EXTRA_CHARACTERS_ID 61 +#define MSG_ERR_NON_ASCII_CHARACTER (FlexCat_Strings[62].Str) +#define _MSG_ERR_NON_ASCII_CHARACTER 62 +#define MSG_ERR_NO_CAT_REVISION (FlexCat_Strings[63].Str) +#define _MSG_ERR_NO_CAT_REVISION 63 +#define MSG_ERR_CONVERSION_FAILED (FlexCat_Strings[64].Str) +#define _MSG_ERR_CONVERSION_FAILED 64 +#define MSG_ERR_UNKNOWN_SOURCE_CHARSET (FlexCat_Strings[65].Str) +#define _MSG_ERR_UNKNOWN_SOURCE_CHARSET 65 +#define MSG_ERR_UNKNOWN_DESTINATION_CHARSET (FlexCat_Strings[66].Str) +#define _MSG_ERR_UNKNOWN_DESTINATION_CHARSET 66 +#define MSG_ERR_INVALID_CHARS_FOUND (FlexCat_Strings[67].Str) +#define _MSG_ERR_INVALID_CHARS_FOUND 67 +#define MSG_ERR_ICONV_FAILED (FlexCat_Strings[68].Str) +#define _MSG_ERR_ICONV_FAILED 68 +#define MSG_ERR_ICONV_OPEN_FAILED (FlexCat_Strings[69].Str) +#define _MSG_ERR_ICONV_OPEN_FAILED 69 + +#endif diff --git a/build/flexcat/FlexCat_cat_other.h b/build/flexcat/FlexCat_cat_other.h new file mode 100644 index 00000000..c5c791a0 --- /dev/null +++ b/build/flexcat/FlexCat_cat_other.h @@ -0,0 +1,101 @@ + +/**************************************************************** + + This file was created automatically by `FlexCat 2.15' + from "locale/FlexCat.pot". + + Do NOT edit by hand! + +****************************************************************/ + +/**************************************************************** + + This file is a quick-hack-solution for all of you wanting + to compile FlexCat on non-amiga platform. It creates the + necessary string tables (hardcoded ATM) and functions to + make code work under any operating system. + + Carlos + +****************************************************************/ + +#ifndef FlexCat_CAT_H +#define FlexCat_CAT_H + +extern char *FlexCat_Strings[]; + +void OpenFlexCatCatalog( void ); +void CloseFlexCatCatalog( void ); + +#define MSG_USAGE_HEAD FlexCat_Strings[0] +#define MSG_USAGE FlexCat_Strings[1] +#define MSG_FILEUPTODATE FlexCat_Strings[2] +#define MSG_ERR_WARNING FlexCat_Strings[3] +#define MSG_ERR_ERROR FlexCat_Strings[4] +#define MSG_ERR_EXPECTEDHEX FlexCat_Strings[5] +#define MSG_ERR_EXPECTEDOCTAL FlexCat_Strings[6] +#define MSG_ERR_NOLENGTHBYTES FlexCat_Strings[7] +#define MSG_ERR_UNKNOWNCDCOMMAND FlexCat_Strings[8] +#define MSG_ERR_UNEXPECTEDBLANKS FlexCat_Strings[9] +#define MSG_ERR_NOIDENTIFIER FlexCat_Strings[10] +#define MSG_ERR_MISSINGSTRING FlexCat_Strings[11] +#define MSG_ERR_UNKNOWNCTCOMMAND FlexCat_Strings[12] +#define MSG_ERR_UNKNOWNIDENTIFIER FlexCat_Strings[13] +#define MSG_ERR_UNKNOWNSTRINGTYPE FlexCat_Strings[14] +#define MSG_ERR_NOTERMINATEBRACKET FlexCat_Strings[15] +#define MSG_ERR_NOBINCHARS FlexCat_Strings[16] +#define MSG_ERR_CTGAP FlexCat_Strings[17] +#define MSG_ERR_DOUBLECTLANGUAGE FlexCat_Strings[18] +#define MSG_ERR_DOUBLECTVERSION FlexCat_Strings[19] +#define MSG_ERR_WRONGRCSID FlexCat_Strings[20] +#define MSG_ERR_NOMEMORY FlexCat_Strings[21] +#define MSG_ERR_NOCATALOGDESCRIPTION FlexCat_Strings[22] +#define MSG_ERR_NOCATALOGTRANSLATION FlexCat_Strings[23] +#define MSG_ERR_NOCTVERSION FlexCat_Strings[24] +#define MSG_ERR_NOCATALOG FlexCat_Strings[25] +#define MSG_ERR_NONEWCTFILE FlexCat_Strings[26] +#define MSG_ERR_NOCTLANGUAGE FlexCat_Strings[27] +#define MSG_ERR_NOSOURCE FlexCat_Strings[28] +#define MSG_ERR_NOSOURCEDESCRIPTION FlexCat_Strings[29] +#define MSG_ERR_NOCTARGUMENT FlexCat_Strings[30] +#define MSG_ERR_CANTCHECKDATE FlexCat_Strings[31] +#define MSG_ERR_NOCTFILENAME FlexCat_Strings[32] +#define MSG_ERR_NOCATFILENAME FlexCat_Strings[33] +#define MSG_ERR_BADPREFS FlexCat_Strings[34] +#define MSG_ERR_BADCTLANGUAGE FlexCat_Strings[35] +#define MSG_ERR_DOUBLECTCODESET FlexCat_Strings[36] +#define MSG_ERR_BADCTCODESET FlexCat_Strings[37] +#define MSG_ERR_NOCTCODESET FlexCat_Strings[38] +#define MSG_ERR_ERROR_QUICK FlexCat_Strings[39] +#define MSG_ERR_BADCTVERSION FlexCat_Strings[40] +#define MSG_ERR_WARNING_QUICK FlexCat_Strings[41] +#define MSG_ERR_MISSINGTRANSLATION FlexCat_Strings[42] +#define MSG_ERR_EMPTYTRANSLATION FlexCat_Strings[43] +#define MSG_ERR_MISMATCHINGCONTROLCHARACTERS FlexCat_Strings[44] +#define MSG_ERR_DOUBLE_IDENTIFIER FlexCat_Strings[45] +#define MSG_ERR_STRING_TOO_SHORT FlexCat_Strings[46] +#define MSG_ERR_STRING_TOO_LONG FlexCat_Strings[47] +#define MSG_ERR_TRAILING_ELLIPSIS FlexCat_Strings[48] +#define MSG_ERR_NO_TRAILING_ELLIPSIS FlexCat_Strings[49] +#define MSG_ERR_TRAILING_BLANKS FlexCat_Strings[50] +#define MSG_ERR_NO_TRAILING_BLANKS FlexCat_Strings[51] +#define MSG_ERR_MISMATCHING_PLACEHOLDERS FlexCat_Strings[52] +#define MSG_ERR_MISSING_PLACEHOLDERS FlexCat_Strings[53] +#define MSG_ERR_EXCESSIVE_PLACEHOLDERS FlexCat_Strings[54] +#define MSG_ERR_NO_LEADING_BRACKET FlexCat_Strings[55] +#define MSG_ERR_NO_TRAILING_BRACKET FlexCat_Strings[56] +#define MSG_ERR_DOUBLE_ID FlexCat_Strings[57] +#define MSG_ERR_NO_MIN_LEN FlexCat_Strings[58] +#define MSG_ERR_NO_MAX_LEN FlexCat_Strings[59] +#define MSG_ERR_EXTRA_CHARACTERS FlexCat_Strings[60] +#define MSG_ERR_EXTRA_CHARACTERS_ID FlexCat_Strings[61] +#define MSG_ERR_NON_ASCII_CHARACTER FlexCat_Strings[62] +#define MSG_ERR_NO_CAT_REVISION FlexCat_Strings[63] +#define MSG_ERR_CONVERSION_FAILED FlexCat_Strings[64] +#define MSG_ERR_UNKNOWN_SOURCE_CHARSET FlexCat_Strings[65] +#define MSG_ERR_UNKNOWN_DESTINATION_CHARSET FlexCat_Strings[66] +#define MSG_ERR_INVALID_CHARS_FOUND FlexCat_Strings[67] +#define MSG_ERR_ICONV_FAILED FlexCat_Strings[68] +#define MSG_ERR_ICONV_OPEN_FAILED FlexCat_Strings[69] + +#endif diff --git a/build/flexcat/README b/build/flexcat/README new file mode 100644 index 00000000..3341be55 --- /dev/null +++ b/build/flexcat/README @@ -0,0 +1,3 @@ +Forked from: +https://github.com/adtools/flexcat + diff --git a/build/flexcat/SDI_compiler.h b/build/flexcat/SDI_compiler.h new file mode 100644 index 00000000..7b3a2eae --- /dev/null +++ b/build/flexcat/SDI_compiler.h @@ -0,0 +1,238 @@ +#ifndef SDI_COMPILER_H +#define SDI_COMPILER_H + +/* Includeheader + + Name: SDI_compiler.h + Versionstring: $VER: SDI_compiler.h 1.33 (03.06.2010) + Author: Dirk Stoecker & Jens Langner + Distribution: PD + Project page: http://www.sf.net/projects/sditools/ + Description: defines to hide compiler stuff + + 1.1 25.06.98 : created from data made by Gunter Nikl + 1.2 17.11.99 : added VBCC + 1.3 29.02.00 : fixed VBCC REG define + 1.4 30.03.00 : fixed SAVEDS for VBCC + 1.5 29.07.00 : added #undef statements (needed e.g. for AmiTCP together + with vbcc) + 1.6 19.05.01 : added STACKEXT and Dice stuff + 1.7 16.06.01 : added MorphOS specials and VARARGS68K + 1.8 21.09.02 : added MorphOS register stuff + 1.9 26.09.02 : added OFFSET macro. Thanks Frank Wille for suggestion + 1.10 18.10.02 : reverted to old MorphOS-method for GCC + 1.11 09.11.02 : added REGARGS define to MorphOS section + 1.12 18.01.04 : some adaptions for AmigaOS4 compatibility + 1.13 17.02.04 : changed ASM macros to be a simple define and added + INTERRUPT, CHIP and FAR + 1.14 02.03.04 : added UNUSED which can be used to specify a function parameter + or variable as "unused" which will not cause any compiler warning. + 1.15 02.03.04 : added special INLINE define for gcc > 3.0 version + 1.17 07.03.04 : changed INLINE definition of gcc <= 2.95.3 to be static aswell. + 1.18 21.06.04 : added USED and USED_VAR attribute to allow placing a + __attribute__((used)) to a function and a variable, taking care of + different compiler versions. + 1.19 04.07.04 : register specification for variables is not supported on MorphOS, + so we modified the REG() macro accordingly. + 1.20 28.02.05 : correct INLINE for VBCC. + 1.21 28.02.05 : cleanup __GCC__ case. + 1.22 16.05.05 : changed the vbcc/REG() macro. + added missing vbcc/VARARGS68K define. + moved morphos SDI_EmulLib Stuff into compilers.h. I know it's not + compiler specific, (Guido Mersmann) + 1.23 30.04.06 : modified to get it compatible to AROS. (Guido Mersmann) + 1.24 06.05.06 : __linearvarargs is only valid for vbcc and PPC, so I moved VARARGS68K + to prevent problems with 68K and i86 targets. (Guido Mersmann) + 1.25 21.06.07 : added NEAR to be usable for __near specification for SAS/C + 1.26 14.10.07 : added DEPRECATED macro which defaults to __attribute__((deprecated)) + for GCC compiles. + 1.27 20.03.09 : applied some changes and fixes to get the header more usable + for an AROS compilation. (Pavel Fedin) + 1.28 25.03.09 : added missing IPTR definition to make SDI_compiler.h more compatible + to AROS. (Pavel Fedin) + 1.29 25.03.09 : fixed the IPTR definition and also the use of the __M68000__ define. + 1.30 26.03.09 : fixed the IPTR definition by only defining it for non AROS targets. + 1.31 29.03.09 : added VARARGS68K definition for AROS. + 1.32 28.05.09 : added STACKED definition for non-AROS targets. + 1.33 03.06.10 : added missing SIPTR definition to make SDI_compiler.h more compatible + to AROS. + +*/ + +/* +** This is PD (Public Domain). This means you can do with it whatever you want +** without any restrictions. I only ask you to tell me improvements, so I may +** fix the main line of this files as well. +** +** To keep confusion level low: When changing this file, please note it in +** above history list and indicate that the change was not made by myself +** (e.g. add your name or nick name). +** +** Find the latest version of this file at: +** http://cvs.sourceforge.net/viewcvs.py/sditools/sditools/headers/ +** +** Jens Langner and +** Dirk Stoecker +*/ + +/* Some SDI internal header */ + +#undef ASM +#undef REG +#undef LREG +#undef CONST +#undef SAVEDS +#undef INLINE +#undef REGARGS +#undef STDARGS +#undef OFFSET +#undef INTERRUPT +#undef CHIP +#undef FAR +#undef NEAR +#undef UNUSED +#undef USED +#undef USED_VAR +#undef DEPRECATED + +/* first "exceptions" */ + +#if defined(__MAXON__) + #define STDARGS + #define STACKEXT + #define REGARGS + #define SAVEDS + #define INLINE inline +/*************************************************************************/ +#elif defined(__VBCC__) + #define STDARGS + #define STACKEXT + #define REGARGS + #define INLINE static + #define OFFSET(p,m) __offsetof(struct p,m) + + #if defined(__PPC__) + #define VARARGS68K __linearvarargs + #define REG(reg,arg) arg + #else + #define REG(reg,arg) __reg(#reg) arg + #endif +/*************************************************************************/ +#elif defined(__STORM__) + #define STDARGS + #define STACKEXT + #define REGARGS + #define INLINE inline +/*************************************************************************/ +#elif defined(__SASC) + #define ASM __asm +/*************************************************************************/ +#elif defined(__GNUC__) + #define UNUSED __attribute__((unused)) /* for functions, variables and types */ + #define USED __attribute__((used)) /* for functions only! */ + #define DEPRECATED __attribute__((deprecated)) + #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0) + #define USED_VAR USED /* for variables only! */ + #define INLINE static __inline __attribute__((always_inline)) + #endif + /* we have to distinguish between AmigaOS4 and MorphOS */ + #if defined(_M68000) || defined(__M68000) || defined(__mc68000) + #define REG(reg,arg) arg __asm(#reg) + #define LREG(reg,arg) register REG(reg,arg) + #else + #define REG(reg,arg) arg + #define SAVEDS + #define STDARGS + #define REGARGS + #define STACKEXT + #if defined(__MORPHOS__) + #define VARARGS68K __attribute__((varargs68k)) + #endif + #if defined(__AROS__) + #define VARARGS68K __stackparm + #endif + #define INTERRUPT + #define CHIP + #endif + #define FAR + #define NEAR +#elif defined(_DCC) + #define REG(reg,arg) __##reg arg + #define STACKEXT __stkcheck + #define STDARGS __stkargs + #define INLINE static +#endif + +/* then "common" ones */ + +#if !defined(ASM) + #define ASM +#endif +#if !defined(REG) + #define REG(reg,arg) register __##reg arg +#endif +#if !defined(LREG) + #define LREG(reg,arg) register arg +#endif +#if !defined(CONST) + #define CONST const +#endif +#if !defined(SAVEDS) + #define SAVEDS __saveds +#endif +#if !defined(INLINE) + #define INLINE static __inline +#endif +#if !defined(REGARGS) + #define REGARGS __regargs +#endif +#if !defined(STDARGS) + #define STDARGS __stdargs +#endif +#if !defined(STACKEXT) + #define STACKEXT __stackext +#endif +#if !defined(VARARGS68K) + #define VARARGS68K +#endif +#if !defined(OFFSET) + #define OFFSET(structName, structEntry) \ + ((char *)(&(((struct structName *)0)->structEntry))-(char *)0) +#endif +#if !defined(INTERRUPT) + #define INTERRUPT __interrupt +#endif +#if !defined(CHIP) + #define CHIP __chip +#endif +#if !defined(FAR) + #define FAR __far +#endif +#if !defined(NEAR) + #define NEAR __near +#endif +#if !defined(UNUSED) + #define UNUSED +#endif +#if !defined(USED) + #define USED +#endif +#if !defined(USED_VAR) + #define USED_VAR +#endif +#if !defined(DEPRECATED) + #define DEPRECATED +#endif +#if !defined(__AROS__) && !defined(IPTR) + #define IPTR ULONG +#endif +#if !defined(__AROS__) && !defined(SIPTR) + #define SIPTR LONG +#endif +#if !defined(__AROS__) && !defined(STACKED) + #define STACKED +#endif + +/*************************************************************************/ + +#endif /* SDI_COMPILER_H */ diff --git a/build/flexcat/asprintf.c b/build/flexcat/asprintf.c new file mode 100644 index 00000000..e3df2e25 --- /dev/null +++ b/build/flexcat/asprintf.c @@ -0,0 +1,40 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include + +extern int vasprintf(char **ptr, const char * format, va_list ap); + +int asprintf(char **ptr, const char * format, ...) +{ + va_list ap; + int ret; + + *ptr = NULL; + va_start(ap, format); + ret = vasprintf(ptr, format, ap); + va_end(ap); + + return ret; +} diff --git a/build/flexcat/configure b/build/flexcat/configure new file mode 100755 index 00000000..9e8102eb --- /dev/null +++ b/build/flexcat/configure @@ -0,0 +1,148 @@ +#!/bin/sh +# +# Copyright (c) 2016 Carsten Larsen +# Copyright (c) 2014 Poul-Henning Kamp +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +set -e + +HDRS=' + createcat.h + createcatsrc.h + createct.h + FlexCat_cat.h + FlexCat_cat_other.h + flexcat.h + globals.h + openlibs.h + readprefs.h + scancd.h + scanct.h + scanpo.h + SDI_compiler.h + showfuncs.h + swapfuncs.h + utils.h + version.h +' + +SRCS=' + asprintf.c + createcat.c + createcatsrc.c + createct.c + globals.c + locale_other.c + main.c + openlibs.c + readprefs.c + scancd.c + scanct.c + scanpo.c + showfuncs.c + strptime.c + swapfuncs.c + utils.c + vastubs.c +' + +if make -v 2>&1 | grep GNU > /dev/null 2>&1 ; then + echo "make(1) is GNU make." + BSD=false +elif [ -f /usr/share/mk/bsd.prog.mk ] ; then + echo "Found bsd.prog.mk, will use it." + BSD=true +else + echo "Defaulting to plain makefile" + BSD=false +fi + +if $BSD ; then + ( + echo '# BSD-style Makefile generated by configure' + echo 'PROG = flexcat' + for f in ${SRCS} + do + echo "SRCS += ${f}" + done + + echo 'NO_MAN = not_yet' + echo 'LDADD += -lm' + echo 'WARNS ?= 6' + echo '.include ' + ) > Makefile + + msg=", remember to run 'make depend'" +else + ( + echo '# Portable Makefile generated by configure' + echo '' + echo 'all: flexcat' + echo '' + echo "CFLAGS += -I. -Wall" + echo '' + + for f in ${HDRS} + do + b=`basename $f .h` + i=`sed -n -e '/#include.*"/{ + s/"$// + s/.*"// + p + }' $f | sort -u` + if [ "x${i}" != "x" ] ; then + echo "${b}.h: " ${i} + echo " touch ${b}.h" + echo + fi + done + + l="" + for f in ${SRCS} + do + b=`basename $f .c` + i=`sed -n -e '/#include.*"/{ + s/"$// + s/.*"// + p + }' $f | sort -u` + echo "${b}.o: ${b}.c" ${i} + echo + l="${l} ${b}.o" + done + + echo + echo "flexcat: ${l}" + echo " \${CC} \${CFLAGS} -o flexcat ${l} -lm" + echo + echo "clean:" + echo " rm -f ${l} flexcat" + echo + echo "depend:" + echo " @echo Dependencies already done" + ) > Makefile +fi + +echo "Makefile generated${msg}" diff --git a/build/flexcat/createcat.c b/build/flexcat/createcat.c new file mode 100644 index 00000000..3c93593e --- /dev/null +++ b/build/flexcat/createcat.c @@ -0,0 +1,355 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "flexcat.h" +#include "scanct.h" +#include "showfuncs.h" +#include "readprefs.h" +#include "swapfuncs.h" +#include "globals.h" +#include "utils.h" + +struct CatString *FirstCatString = NULL; /* First catalog string */ +struct CatalogChunk *FirstChunk = NULL; /* List of catalog chunks */ + +/// CatPuts + +/* CatPuts prints a string to a catalog. (The string is preceded by a + long integer containing its length and probably padded up to word + boundary or longword boundary, depending on the argument padbytes.) + The arguments countnul should be TRUE if the NUL byte at the end of + the string should be counted. */ + +int CatPuts(FILE *fp, char *str, int padbytes, int countnul, int lenbytes) +{ + uint32 reallen; + uint32 virtuallen; + uint32 chunklen; + uint32 swapped_long; + int bytesread; + char *oldstr; + char bytes[10]; + +/* Get length of string */ + + oldstr = str; + reallen = 0; + + while(*oldstr != '\0') + { + bytesread = ReadChar(&oldstr, bytes); + // substract one byte for double backslashes + if(bytesread == 2) + bytesread--; + + reallen += bytesread; + } + + virtuallen = chunklen = reallen + lenbytes; + if(countnul || chunklen % padbytes == 0) + virtuallen++; + + swapped_long = SwapLong(virtuallen); + + fwrite(&swapped_long, sizeof(virtuallen), 1, fp); + if(lenbytes > 0) + fwrite(((char *)&reallen) + sizeof(reallen) - lenbytes, lenbytes, 1, fp); + + while(*str != '\0') + { + bytesread = ReadChar(&str, bytes); + if(bytesread > 0) + fwrite(bytes + bytesread - 1, 1, 1, fp); + } + + do + { + putc('\0', fp); + } + while(++chunklen % padbytes); + + return (int)chunklen + 4; +} + +/// +/// PutCatalogChunk + +/* This puts a string chunk into the catalog */ + +int PutCatalogChunk(FILE * fp, struct CatalogChunk *cc) +{ + fwrite(&cc->ID, sizeof(cc->ID), 1, fp); + + return 4 + CatPuts(fp, cc->ChunkStr, 2, TRUE, 0); +} + +/// +/// CreateCatalog + +/* This creates a catalog */ + +void CreateCat(char *CatFile) +{ + FILE *fp; + int CatLen, HeadLen; + struct CatString *cs; + struct CatalogChunk *cc; + int i; + + if(CatVersionString == NULL && CatRcsId == NULL) + { + ShowError(MSG_ERR_NOCTVERSION); + } + + if(CatLanguage == NULL) + { + ShowError(MSG_ERR_NOCTLANGUAGE); + } + + if(strlen(CatLanguage) == 0) + { + ShowError(MSG_ERR_NOCTLANGUAGE); + } + + if(CatFile == NULL) + { + if(BaseName == NULL) + ShowError(MSG_ERR_NOCATFILENAME); + else + { + if(asprintf(&CatFile, "%s.catalog", BaseName) < 0) + MemError(); + } + } + + if((fp = fopen(CatFile, "wb")) == NULL) + { + ShowError(MSG_ERR_NOCATALOG, CatFile); + } + + if(!NoBufferedIO) + setvbuf(fp, NULL, _IOFBF, buffer_size); + + fputs("FORM0000CTLG", fp); + CatLen = 4; + + if(CatVersionString !=NULL) + { + struct CatalogChunk verChunk; + char *found; + + verChunk.ID = MAKE_ID('F', 'V', 'E', 'R'); + + verChunk.ChunkStr = strdup(CatVersionString); + + /* Replace $TODAY placeholder */ + + found = strstr(verChunk.ChunkStr, "$TODAY"); + if(found != NULL) + { + char dateStr[12]; + time_t tim; + struct tm *t; + char *verStr = NULL; + + time(&tim); + t = localtime(&tim); + + *found = '\0'; + strftime(dateStr, sizeof(dateStr), "%d.%m.%Y", t); + + if(asprintf(&verStr, "%s%s%s", verChunk.ChunkStr, dateStr, found + strlen("$TODAY")) != -1) + { + free(verChunk.ChunkStr); + verChunk.ChunkStr = verStr; + } + else + MemError(); + } + + /* Replace ".ct" with ".catalog" */ + + found = strstr(verChunk.ChunkStr, ".ct "); + if(found != NULL) + { + char *verStr = NULL; + + *found = '\0'; + if(asprintf(&verStr, "%s.catalog%s", verChunk.ChunkStr, found + 3) != -1) + { + free(verChunk.ChunkStr); + verChunk.ChunkStr = verStr; + } + } + + verChunk.ID = SwapLong(verChunk.ID); + CatLen += PutCatalogChunk(fp, &verChunk); + free(verChunk.ChunkStr); + } + else + { + struct CatalogChunk verChunk; + char *verStr = NULL; + int year = 0, month = 0, day = 0; + int version = 0, revision = 0; + char *name = NULL; + char *ptr; + + if(CatRcsId == NULL) + { + ShowError(MSG_ERR_NOCTVERSION); + } + else + { + if((ptr = strstr(CatRcsId, "$Date:")) == NULL || + sscanf(ptr + 6, " %d/%d/%d", &year, &month, &day) != 3 || + (ptr = strstr(CatRcsId, "$Revision:")) == NULL || + sscanf(ptr + 10, " %d.%d", &version, &revision) != 2) + { + ShowError(MSG_ERR_WRONGRCSID); + } + if((ptr = strstr(CatRcsId, "$Id:")) != NULL) + { + int len = 0; + char *found; + + ptr += 4; + OverSpace(&ptr); + found = ptr; + + while(*ptr != '\0' && *ptr != '$' && *ptr != ' ' && *ptr != '\t') + { + ++len; + ++ptr; + } + if((name = malloc(len + 1)) == NULL) + { + MemError(); + } + strncpy(name, found, len); + name[len] = '\0'; + } + } + + if(CatName != NULL) + { + name = CatName; + } + else if(name == NULL) + { + ShowError(MSG_ERR_NOCTVERSION); + name = (char *)""; + } + + if(asprintf(&verStr, "%cVER: %s %d.%d(%d.%d.%d)", '$', name, version, revision, day, month, year) != -1) + { + verChunk.ID = MAKE_ID('F', 'V', 'E', 'R'); + verChunk.ID = SwapLong(verChunk.ID); + verChunk.ChunkStr = verStr; + CatLen += PutCatalogChunk(fp, &verChunk); + } + else + MemError(); + } + + for(cc = FirstChunk; cc != NULL; cc = cc->Next) + { + CatLen += PutCatalogChunk(fp, cc); + } + + i = 32; + fputs("CSET", fp); + + { + int i_tmp = SwapLong(i); + + fwrite(&i_tmp, sizeof(i_tmp), 1, fp); + i_tmp = SwapLong(CodeSet); + fwrite(&i_tmp, sizeof(i_tmp), 1, fp); + i -= sizeof(i_tmp); + } + + while(i-- > 0) + { + putc('\0', fp); + } + + CatLen += 48; + fprintf(fp, "STRS0000"); + HeadLen = CatLen; + + for(cs = FirstCatString; cs != NULL; cs = cs->Next) + { + int FillUsed = FALSE; + int tmp_ID = SwapLong(cs->ID); + + if(Fill) + { + if(cs->CT_Str != NULL && cs->NotInCT == FALSE) + { + if(strlen(cs->CT_Str) == 0) + { + fwrite(&tmp_ID, sizeof(tmp_ID), 1, fp); + CatLen += 4 + CatPuts(fp, cs->CD_Str, 4, FALSE, cs->LenBytes); + FillUsed = TRUE; + } + } + else + { + fwrite(&tmp_ID, sizeof(cs->ID), 1, fp); + CatLen += 4 + CatPuts(fp, cs->CD_Str, 4, FALSE, cs->LenBytes); + FillUsed = TRUE; + } + } + + if(FillUsed == FALSE && cs->CT_Str != NULL && cs->NotInCT == FALSE && + (NoOptim ? TRUE : strcmp(cs->CT_Str, cs->CD_Str))) + { + fwrite(&tmp_ID, sizeof(tmp_ID), 1, fp); + CatLen += 4 + CatPuts(fp, cs->CT_Str, 4, FALSE, cs->LenBytes); + } + + /* printf("LB=%d\n", cs->LenBytes); */ + + } + { + int tmp_Len; + + fseek(fp, 4, SEEK_SET); + + tmp_Len = SwapLong(CatLen); + fwrite(&tmp_Len, sizeof(tmp_Len), 1, fp); + fseek(fp, HeadLen - 4, SEEK_CUR); + + CatLen -= HeadLen; + tmp_Len = SwapLong(CatLen); + fwrite(&tmp_Len, sizeof(CatLen), 1, fp); + } + + fclose(fp); +#ifdef AMIGA + SetProtection(CatFile, FILE_MASK); +#endif + Expunge(); +} + +/// diff --git a/build/flexcat/createcat.h b/build/flexcat/createcat.h new file mode 100644 index 00000000..094a2132 --- /dev/null +++ b/build/flexcat/createcat.h @@ -0,0 +1,33 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_CREATECAT_H +#define FLEXCAT_CREATECAT_H + +/* Functions */ +void CreateCat ( char *CatFile ); + +/* Variables */ +extern struct CatString *FirstCatString; +extern struct CatalogChunk *FirstChunk; + +#endif /* FLEXCAT_CREATECAT_H */ diff --git a/build/flexcat/createcatsrc.c b/build/flexcat/createcatsrc.c new file mode 100644 index 00000000..8467baea --- /dev/null +++ b/build/flexcat/createcatsrc.c @@ -0,0 +1,788 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "flexcat.h" +#include "readprefs.h" +#include "swapfuncs.h" +#include "showfuncs.h" +#include "scancd.h" +#include "scanct.h" +#include "createcat.h" +#include "globals.h" +#include "utils.h" + +enum StringTypes +{ + TYPE_C, /* Produce C strings */ + TYPE_ASSEMBLER, /* Produce Assembler strings */ + TYPE_OBERON, /* Produce Oberon strings */ + TYPE_E, /* Produce E strings. (Oops, thought + it allows only 32 bit integers? ;-) */ + TYPE_NONE /* Simple strings */ +}; + +enum OutputModes +{ + OutputMode_None, /* Nothing written yet */ + OutputMode_Bin, /* Last character written was binary */ + OutputMode_Ascii /* Last character written was Ascii */ +}; + +int OutputMode = OutputMode_None; +int OutputType = TYPE_C; + +FILE *OutputFile; +int OutputLen; +int LongStrings = TRUE; /* Generate long or short strings */ + +/// CalcRealLength + +/* This function measures the real (binary) length of source + string. It correctly process 'slash chars' (\n, \000 etc), + and gives the real length such source string have. + + Inputs: source - pointer to NULL terminated source string + Result: real length */ + +int CalcRealLength(char *source) +{ + int count = 0; + int len; + char *src = source; + char bytes[10]; + + while(*src != '\0') + { + len = ReadChar(&src, bytes); + // substract one byte for double backslashes + if(len == 2) + len--; + + count += len; + } + +/* printf("%ld: '%s'\n", count, source); */ + return count; +} + +/// +/// InitCatStringOutput + +/* InitCatStringOutput gets called before writing a catalog string as source. + Inputs: fp = file pointer to the output file + type = one of TYPE_C create C strings + TYPE_ASSEMBLER create Assembler strings + TYPE_OBERON create Oberon strings + TYPE_E create E strings + TYPE_NONE create simple strings */ + +void InitCatStringOutput(FILE *fp) +{ + OutputLen = 0; + OutputFile = fp; + OutputMode = OutputMode_None; + + switch(OutputType) + { + case TYPE_C: + case TYPE_OBERON: + putc('\"', fp); + OutputMode = OutputMode_Ascii; + break; + + case TYPE_E: + putc('\'', fp); + + case TYPE_ASSEMBLER: + case TYPE_NONE: + break; + } +} + +/// +/// SeparateCatStringOutput + +/* SeparateCatStringOutput gets called to split a catalog into + separate lines. */ + +void SeparateCatStringOutput(void) +{ + switch(OutputType) + { + case TYPE_C: + if(!LongStrings) + { + fputs("\"\\\n\t\"", OutputFile); + } + break; + + case TYPE_E: + if(!LongStrings) + { + fputs("\' +\n\t\'", OutputFile); + } + break; + + case TYPE_OBERON: + if(!LongStrings) + { + fputs("\"\n\t\"", OutputFile); + } + break; + + case TYPE_ASSEMBLER: + if(!LongStrings) + { + if(OutputMode == OutputMode_Ascii) + { + putc('\'', OutputFile); + } + putc('\n', OutputFile); + OutputMode = OutputMode_None; + } + break; + + case TYPE_NONE: + break; + } +} + +/// +/// WriteBinChar + +/* WriteBinChar writes one binary character into the source file. */ + +void WriteBinChar(int c) +{ + switch(OutputType) + { + case TYPE_C: + case TYPE_E: + case TYPE_OBERON: + switch(c) + { + case '\b': + fputs("\\b", OutputFile); + break; + + case '\n': + fputs("\\n", OutputFile); + break; + + case '\r': + fputs("\\r", OutputFile); + break; + + case '\t': + fputs("\\t", OutputFile); + break; + + case '\f': + fputs("\\f", OutputFile); + break; + + case '\0': + fputs("\\000", OutputFile); + break; + + default: + if(OutputType == TYPE_E && c == '\033') + { + fputs("\\e", OutputFile); + } + else + { + fprintf(OutputFile, "\\%c%c%c", ((c >> 6) & 3) + '0', ((c >> 3) & 7) + '0', (c & 7) + '0'); + } + break; + + } + ++OutputLen; + OutputMode = OutputMode_Bin; + break; + + case TYPE_ASSEMBLER: + switch(OutputMode) + { + case OutputMode_None: + fprintf(OutputFile, "\tdc.b\t$%02x", c & 0xff); + break; + + case OutputMode_Ascii: + putc('\'', OutputFile); + + case OutputMode_Bin: + fprintf(OutputFile, ",$%02x", c & 0xff); + break; + } + ++OutputLen; + OutputMode = OutputMode_Bin; + break; + + case TYPE_NONE: + ShowError(MSG_ERR_NOBINCHARS); + break; + } +} + +/// +/// WriteAsciiChar + +/* WriteAsciiChar writes one ascii character into the source file. */ + +void WriteAsciiChar(int c) +{ + switch(OutputType) + { + case TYPE_C: + case TYPE_OBERON: + switch(c) + { + case '\"': + fputs("\\\"", OutputFile); + break; + + default: + putc(c, OutputFile); + break; + } + ++OutputLen; + OutputMode = OutputMode_Ascii; + break; + + case TYPE_E: + switch(c) + { + case '\'': + fputs("''", OutputFile); + break; + + default: + putc(c, OutputFile); + break; + } + ++OutputLen; + OutputMode = OutputMode_Ascii; + break; + + case TYPE_ASSEMBLER: + if(c == '\'') + { + WriteBinChar(c); + } + else + { + switch(OutputMode) + { + case OutputMode_None: + fprintf(OutputFile, "\tdc.b\t\'%c", c); + break; + + case OutputMode_Ascii: + putc(c, OutputFile); + break; + + case OutputMode_Bin: + fprintf(OutputFile, ",\'%c", c); + break; + } + ++OutputLen; + OutputMode = OutputMode_Ascii; + } + break; + + case TYPE_NONE: + putc(c, OutputFile); + break; + } +} + +/// +/// TerminateCatStringOutput + +/* TerminateCatStringOutput finishes the output of a catalog string. */ + +void TerminateCatStringOutput(void) +{ + switch(OutputType) + { + case TYPE_C: + case TYPE_OBERON: + putc('\"', OutputFile); + break; + + case TYPE_E: + putc('\'', OutputFile); + break; + + case TYPE_ASSEMBLER: + switch(OutputMode) + { + case OutputMode_Ascii: + putc('\'', OutputFile); + // fall through... + + case OutputMode_Bin: + break; + + case OutputMode_None: + break; + } + break; + + case TYPE_NONE: + break; + + } + +} + +/// +/// WriteString + +/* This writes a source string. */ + +static void WriteString(FILE * fpout, char *str, int32 Len, int lenbytes, int allbytes) +{ + char bytes[10]; + int bytesread; + int needseparate = FALSE; + + InitCatStringOutput(fpout); + if(Len >= 0) + { + int i; + + for(i = lenbytes; i >= 1; i--) + { + WriteBinChar((int)((char *)&Len)[sizeof(Len) - i]); + } + + } + + while(*str != '\0') + { + bytesread = ReadChar(&str, bytes); + if(bytesread > 0) + { + if(needseparate == TRUE) + { + SeparateCatStringOutput(); + needseparate = FALSE; + } + + do + { + unsigned char c = bytes[bytesread - 1]; + + if((c >= 0x20 && c < 0x7f) || c >= 0xa0) + WriteAsciiChar((int)c); + else + WriteBinChar((int)c); + + if(allbytes == 0) + break; + } + while(--bytesread > 0); + } + else + needseparate = TRUE; + } + + TerminateCatStringOutput(); +} + +/// +/// CreateSourceFile + +/* Finally, the source creation. */ + +void CreateSourceFile(char *SourceFile, char *TemplateFile, char *CDFile) +{ + FILE *fpin, *fpout; + char *line; + char *OrigTemplateFile = TemplateFile; + + ScanFile = SourceFile; + ScanLine = 0; + + /* Open the source file. This may be found in various places. */ + + if((fpin = fopen(TemplateFile, "r")) == NULL) + { +#ifdef AMIGA + if(*prefs_sddir != '\0') + { + TemplateFile = AddFileName(prefs_sddir, OrigTemplateFile); + fpin = fopen(TemplateFile, "r"); + } +#endif + } + + if(fpin == NULL) + { +#ifdef AMIGA + char sddir[80]; + + if(GetVar(FLEXCAT_SDDIR, sddir, 80, 0) != 0) +#else + char *sddir; + + if((sddir = getenv(FLEXCAT_SDDIR)) != NULL) +#endif + { + TemplateFile = AddFileName(sddir, OrigTemplateFile); + fpin = fopen(TemplateFile, "r"); + } + } + + if(fpin == NULL) + { + TemplateFile = AddFileName(strdup(DEFAULT_FLEXCAT_SDDIR), OrigTemplateFile); + fpin = fopen(TemplateFile, "r"); + } + + if(fpin == NULL) + { + ShowError(MSG_ERR_NOSOURCEDESCRIPTION, OrigTemplateFile); + return; + } + + if((fpout = fopen(SourceFile, "w")) == NULL) + { + ShowError(MSG_ERR_NOSOURCE, SourceFile); + return; + } + + if(!NoBufferedIO) + setvbuf(fpin, NULL, _IOFBF, buffer_size); + if(!NoBufferedIO) + setvbuf(fpout, NULL, _IOFBF, buffer_size); + + while(!feof(fpin) && (line = ReadLine(fpin, FALSE)) != NULL) + { + struct CatString *cs; + int NeedRepeat; + char bytes[10]; + int bytesread; + + cs = FirstCatString; + + do + { + char *currentline = line; + + NeedRepeat = FALSE; + if(*currentline == '#' && *(++currentline) == '#') + { + ++currentline; + OverSpace(¤tline); + if(Strnicmp(currentline, "rem", 3) == 0) + { + /* We just skip this line. */ + continue; + } + + if(Strnicmp(currentline, "stringtype", 10) == 0) + { + currentline += 10; + OverSpace(¤tline); + if(Strnicmp(currentline, "c", 1) == 0) + { + OutputType = TYPE_C; + ++currentline; + } + else if(Strnicmp(currentline, "assembler", 9) == 0) + { + OutputType = TYPE_ASSEMBLER; + currentline += 9; + } + else if(Strnicmp(currentline, "oberon", 6) == 0) + { + OutputType = TYPE_OBERON; + currentline += 6; + } + else if(Strnicmp(currentline, "e", 1) == 0) + { + OutputType = TYPE_E; + ++currentline; + } + else if(Strnicmp(currentline, "none", 4) == 0) + { + OutputType = TYPE_NONE; + currentline += 4; + } + else + { + ShowWarn(MSG_ERR_UNKNOWNSTRINGTYPE); + currentline += strlen(currentline); + } + OverSpace(¤tline); + if(*currentline != '\0') + { + ShowError(MSG_ERR_EXTRA_CHARACTERS); + } + continue; + } + else if(Strnicmp(currentline, "shortstrings", 12) == 0) + { + currentline += 12; + LongStrings = FALSE; + OverSpace(¤tline); + if(*currentline != '\0') + { + ShowError(MSG_ERR_EXTRA_CHARACTERS); + } + continue; + } + } + currentline = line; + while(*currentline != '\0') + { + bytesread = ReadChar(¤tline, bytes); + if(bytesread > 0) + { + if(*bytes == '%') + { + char c = *currentline++; + + switch(c) + { + case 'b': + fputs(BaseName, fpout); + break; + + case 'n': + fprintf(fpout, "%d", NumStrings); + break; + + case 'v': + fprintf(fpout, "%d", CatVersion); + break; + + case 'l': + WriteString(fpout, Language, -1, cs->LenBytes, cs->POformat); + break; + + case 'f': + { + char *tempstr; + + if((c = *currentline++) == 'v') + { + fputs(VERS, fpout); + } + else + { + tempstr = AllocFileName(CDFile, c - '0'); + fputs(tempstr, fpout); + + free(tempstr); + } + } + break; + + case 'o': + { + char *tempstr; + + tempstr = AllocFileName(SourceFile, *currentline++ - '0'); + fputs(tempstr, fpout); + + free(tempstr); + } + break; + + case 'i': + NeedRepeat = TRUE; + if(cs != NULL) + fputs(cs->ID_Str, fpout); + break; + + case 'a': + case 't': + case 'd': + case 'x': + case 'c': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + int len = 0; + + while(c >= '0' && c <= '9') + { + len = (c - '0') + len * 10; + c = *currentline++; + } + + if(c == 'a') + { + int _len = len ? len : 4; + char *start; + char _StrLen[20 + 1]; + + snprintf(_StrLen, sizeof(_StrLen), "%020lx", (uint32)cs->ID); + start = &_StrLen[20 - _len * 2]; + while(_len > 0) + { + fprintf(fpout, "\\x%.2s", start); + start += 2; + _len--; + } + } + else if(c == 't') + { + int _len = len ? len : 4; + char *start; + char _StrLen[20 + 1]; + + snprintf(_StrLen, sizeof(_StrLen), "%020lx", (uint32)((CalcRealLength(cs->CD_Str) + 1) & 0xfffffe)); + start = &_StrLen[20 - _len * 2]; + while(_len > 0) + { + fprintf(fpout, "\\x%.2s", start); + start += 2; + _len--; + } + } + else if(c == 'c' || c == 'd' || c == 'x') + { + char buffer[20]; + + if(c == 'c') + c = 'o'; + if(len) + snprintf(buffer, sizeof(buffer), "%%0%d%c", len, c); + else + snprintf(buffer, sizeof(buffer), "%%%c", c); + + if(cs != NULL) + fprintf(fpout, buffer, cs->ID); + + } + NeedRepeat = TRUE; + } + break; + + case 'e': + NeedRepeat = TRUE; + if(cs != NULL) + fprintf(fpout, "%d", cs->Nr); + break; + + case 's': + NeedRepeat = TRUE; + if(cs != NULL) + { + char *idstr; + uint32 len = 0; + + if(cs->LenBytes) + { + idstr = cs->CD_Str; + while(*idstr != '\0') + { + bytesread = ReadChar(&idstr, bytes); + if(bytesread > 0) + { + ++len; + } + } + } + + WriteString(fpout, cs->CD_Str, cs->LenBytes ? len : (uint32)-1, cs->LenBytes, cs->POformat); + } + break; + + case '(': + NeedRepeat = TRUE; + while(*currentline != '\0' && *currentline != ')') + { + bytesread = ReadChar(¤tline, bytes); + if(bytesread > 0 && cs != NULL && cs->Next != NULL) + { + putc((int)bytes[bytesread - 1], fpout); + } + } + + if(*currentline == '\0') + { + /* FIXME: reuse MSG_ERR_NOTRAILINGBRACKET here? */ + ShowError(MSG_ERR_NOTERMINATEBRACKET); + } + else + { + ++currentline; + } + break; + + /* !!!! FIXME !!!! */ + case 'z': + { + int diff = (((CalcRealLength(cs->CD_Str) + 1) & 0xfffffe) - (CalcRealLength(cs->CD_Str))); + + NeedRepeat = TRUE; + while(diff > 0) + { + fprintf(fpout, "\\x00"); + diff--; + } + break; + } + + default: + { + int ch = *currentline++; + + putc(ch, fpout); + } + } + } + else + { + putc((int)bytes[bytesread - 1], fpout); + } + } + } + putc('\n', fpout); + } + while(NeedRepeat == TRUE && cs != NULL && (cs = cs->Next) != NULL); + + free(line); + } + fclose(fpin); + fclose(fpout); + +#ifdef AMIGA + SetProtection(SourceFile, FILE_MASK); +#endif +} + +/// diff --git a/build/flexcat/createcatsrc.h b/build/flexcat/createcatsrc.h new file mode 100644 index 00000000..eed94dee --- /dev/null +++ b/build/flexcat/createcatsrc.h @@ -0,0 +1,30 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_CREATECATSRC_H +#define FLEXCAT_CREATECATSRC_H + +/* Functions */ +void CreateSourceFile ( char *SourceFile, char *TemplateFile, + char *CDFile ); + +#endif /* FLEXCAT_CREATECATSRC_H */ diff --git a/build/flexcat/createct.c b/build/flexcat/createct.c new file mode 100644 index 00000000..e192bcc8 --- /dev/null +++ b/build/flexcat/createct.c @@ -0,0 +1,204 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "flexcat.h" +#include "readprefs.h" +#include "showfuncs.h" +#include "scancd.h" +#include "scanct.h" +#include "createcat.h" +#include "globals.h" + +/// CreateCTFile +// This creates a new catalog translation file. +void CreateCTFile(char *NewCTFile) +{ + FILE *fp; + struct CDLine *cd; + struct CatString *cs; + struct CatalogChunk *cc; + char*line; + char*ctlanguage = NULL; + + if(CatVersionString == NULL && CatRcsId == NULL) + { + ScanLine = 1; + } + + if(CatLanguage == NULL) + { +#ifdef AMIGA + char lang[80]; + + if(GetVar("language", lang, sizeof(lang), 0) != 0) + { + ctlanguage = lang; + } +#else + char *lang = NULL; + + if((lang = getenv("language")) != NULL) + { + unsigned int i; + + for(i = 0; i < strlen(lang); i++) + { + if(lang[i] == '\n') + { + lang[i] = '\0'; + break; + } + } + ctlanguage = lang; + } +#endif + } + else + ctlanguage = CatLanguage; + + if(ctlanguage == NULL) + ctlanguage = (char *)"nolanguage"; + + if(NewCTFile == NULL) + { + if(BaseName == NULL) + ShowError(MSG_ERR_NOCTFILENAME); + else + { + if(asprintf(&NewCTFile, "%s_%s.catalog", BaseName, ctlanguage) < 0) + MemError(); + } + } + if((fp = fopen(NewCTFile, "w")) == NULL) + { + ShowError(MSG_ERR_NONEWCTFILE); + } + + if(!NoBufferedIO) + setvbuf(fp, NULL, _IOFBF, buffer_size); + + { + if(CatRcsId != NULL) + { + fprintf(fp, "## rcsid %s\n", CatRcsId); + if(CatName != NULL) + fprintf(fp, "## name %s\n", CatName); + } + else + { + if(CatVersionString != NULL) + fprintf(fp, "## version %s\n", CatVersionString); + else + { + char *dateStr; + time_t tim; + struct tm *t; + + dateStr = calloc(15, 1); + time(&tim); + t = localtime(&tim); + strftime(dateStr, 12, "%d.%m.%Y", t); + + if(CatVersion != 0L) + { + if(BaseName != NULL) + fprintf(fp, "## version %cVER: %s.catalog %d. (%s)\n", '$', BaseName, CatVersion, dateStr); + else + fprintf(fp, "## version %cVER: .catalog %d. (%s)\n", '$', CatVersion, dateStr); + } + else + { + if(BaseName != NULL) + fprintf(fp, "## version %cVER: %s.catalog .0 (%s)\n", '$', BaseName, dateStr); + else + fprintf(fp, "## version %cVER: .catalog .0 (%s)\n", '$', dateStr); + } + + free(dateStr); + } + } + } + + fprintf(fp, "## language %s\n" \ + "## codeset %d\n" \ + ";\n", ctlanguage != NULL ? ctlanguage : "X", CodeSet); + for(cc = FirstChunk; cc != NULL; cc = cc->Next) + { + if(cc->ChunkStr != CatLanguage) + { + fprintf(fp, "## chunk "); + fwrite((char *)&cc->ID, sizeof(cc->ID), 1, fp); + fprintf(fp, " %s\n", cc->ChunkStr); + } + } + + for(cd = FirstCDLine, cs = FirstCatString; cd != NULL; cd = cd->Next) + { + switch(*cd->Line) + { + case '#': + fprintf(fp, ";%s\n", cd->Line); + break; + + case ';': + fprintf(fp, "%s\n", cd->Line); + break; + + default: + if(cs != NULL) + { + + /* + fprintf(fp, "%s\n", cs->ID_Str); + fprintf(fp, "%s\n", cs->CT_Str ? cs->CT_Str : ""); + putc(';', fp); + putc(' ', fp); + */ + fprintf(fp, "%s\n" \ + "%s\n" \ + "; ", cs->ID_Str, cs->CT_Str != NULL ? cs->CT_Str : ""); + for(line = cs->CD_Str; *line; ++line) + { + putc((int)*line, fp); + if(*line == '\n') + { + putc(';', fp); + putc(' ', fp); + } + } + putc('\n', fp); + if(cs->NotInCT && CT_Scanned) + fprintf(fp, ";\n" \ + "; %s\n", Msg_New); + cs = cs->Next; + } + break; + } + } + fclose(fp); +#ifdef AMIGA + SetProtection(NewCTFile, FILE_MASK); +#endif +} + +/// + diff --git a/build/flexcat/createct.h b/build/flexcat/createct.h new file mode 100644 index 00000000..ae1147d9 --- /dev/null +++ b/build/flexcat/createct.h @@ -0,0 +1,29 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copygight (C) 2002-2007 by the FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_CREATECT_H +#define FLEXCAT_CREATECT_H + +/* Functions */ +void CreateCTFile ( char *NewCTFile ); + +#endif /* FLEXCAT_CREATECT_H */ diff --git a/build/flexcat/flexcat.h b/build/flexcat/flexcat.h new file mode 100644 index 00000000..e41335c7 --- /dev/null +++ b/build/flexcat/flexcat.h @@ -0,0 +1,189 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_H +#define FLEXCAT_H + +/* Amiga enviroment? */ +#ifdef AMIGA + #include "FlexCat_cat.h" +#else + #include "FlexCat_cat_other.h" +#endif + +#include +#include +#include +#include +#include +#ifdef AMIGA + #include +#endif + +#include "version.h" + +#define VERS "FlexCat " EXE_REV_STRING +#define VSTRING VERS " [" SYSTEMSHORT "/" CPU "] (" EXE_DATE ") " EXE_COPYRIGHT +#define VERSTAG "\0$VER: " VSTRING + +#if defined(AMIGA) + #include + #if defined(_DCC) || defined(__SASC) || defined(__GNUC__) + #include + #include + #include + #include + #else + #include + #include + #include + #endif + + #ifdef tolower + #undef tolower + #endif + #define tolower ToLower +#endif + +#if defined(__MORPHOS__) || defined(__AROS__) || defined(WIN32) +#include +int asprintf(char **ptr, const char * format, ...); +int vasprintf(char **ptr, const char * format, va_list ap); +#endif + +#if defined(WIN32) + // VisualStudio has strdup() declared as being deprecated + #undef strdup + #define strdup(s) _strdup(s) +#endif + +#ifndef FALSE + #define FALSE 0 +#endif +#ifndef TRUE + #define TRUE 1 +#endif + + +#ifndef MAXPATHLEN +#define MAXPATHLEN 512 +#endif +#ifndef PATH_MAX +#define PATH_MAX 512 +#endif + +#define FLEXCAT_SDDIR "FLEXCAT_SDDIR" + +#if defined(AMIGA) + #if defined(__amigaos4__) + #include + #endif + #define FILE_MASK FIBF_EXECUTE + #define DEFAULT_FLEXCAT_SDDIR "PROGDIR:lib" +#else + #ifdef __MINGW32__ + #define DEFAULT_FLEXCAT_SDDIR "C:\\MinGW\\lib\\flexcat" + #else + #define DEFAULT_FLEXCAT_SDDIR "/usr/lib/flexcat" + #endif +#endif + + +// we have to care about own basic datatype +// definitions as flexcat may also be compiled +// on 64bit environments (e.g. linux) +// +// in fact, these definitions are borrowed from +// the OS4 SDK and we bring them onto all the +// other OSs as well.... +#if !defined(__amigaos4__) +#include +typedef uint8_t uint8; +typedef int8_t int8; + +typedef uint16_t uint16; +typedef int16_t int16; + +typedef uint32_t uint32; +typedef int32_t int32; + +#if !defined(__SASC) && ((__GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) || defined(__VBCC__)) +typedef uint64_t uint64; +typedef int64_t int64; +#else +typedef struct { unsigned long hi,lo; } uint64; /* Not exactly scalar data + * types, but the right size. + */ +typedef struct { long hi,lo; } int64; +#endif + +#ifndef AMIGA +typedef uint8 UBYTE; +typedef int8 BYTE; +typedef uint8 BYTEBITS; +typedef uint16 UWORD; +typedef int16 WORD; +typedef uint16 WORDBITS; +typedef uint32 ULONG; +typedef int32 LONG; +typedef uint32 LONGBITS; +typedef uint16 RPTR; +#endif + +#endif /* !__amigaos4__ */ + +#ifndef MAKE_ID + #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d)) +#endif + +#define MAX_NEW_STR_LEN 25 +#define BUFSIZE 4096 + +struct CDLine +{ + struct CDLine *Next; + char *Line; +}; + +struct CatString +{ + struct CatString *Next; + char *CD_Str; + char *CT_Str; + char *ID_Str; + int MinLen, MaxLen, ID, Nr, LenBytes; + int NotInCT; /* If a string is not present, we write NEW + while updating the CT file for easier work. */ + int POformat; /* Is this string a po-format string */ + +}; + +struct CatalogChunk +{ + struct CatalogChunk *Next; /* struct CatalogChunk *Next */ + ULONG ID; + char *ChunkStr; +}; + +int32 getft ( char *filename ); + +#endif /* FLEXCAT_H */ diff --git a/build/flexcat/getft.c b/build/flexcat/getft.c new file mode 100644 index 00000000..0e3aa0b1 --- /dev/null +++ b/build/flexcat/getft.c @@ -0,0 +1,74 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include "flexcat.h" + +#ifndef ZERO +# define ZERO (BPTR)NULL +#endif + +/// getft + +/* Returns the time of change. + Used for compatibility. */ +int32 getft(char *filename) +{ + int32 timestamp = 0; + #if defined(__amigaos4__) + struct ExamineData *ed; + #else // __amigaos4__ + BPTR p_flock; + struct FileInfoBlock *p_fib; + #endif // __amigaos4__ + + #if defined(__amigaos4__) + if((ed = ExamineObjectTags(EX_StringNameInput, filename, TAG_DONE)) != NULL) + { + timestamp = ed->Date.ds_Days * 86400; /* days */ + timestamp += ed->Date.ds_Minute * 60; /* minutes */ + timestamp += ed->Date.ds_Tick / TICKS_PER_SECOND; /* seconds */ + + FreeDosObject(DOS_EXAMINEDATA, ed); + } + #else // __amigaos4__ + if((p_fib = AllocDosObject(DOS_FIB, NULL)) != NULL) + { + if((p_flock = Lock(filename, ACCESS_READ)) != ZERO) + { + Examine(p_flock, p_fib); + + timestamp = p_fib->fib_Date.ds_Days * 86400; /* days */ + timestamp += p_fib->fib_Date.ds_Minute * 60; /* minutes */ + timestamp += p_fib->fib_Date.ds_Tick / TICKS_PER_SECOND; /* seconds */ + + UnLock(p_flock); + } + + FreeDosObject(DOS_FIB, p_fib); + } + #endif // __amigaos4__ + + return timestamp; +} + +/// diff --git a/build/flexcat/globals.c b/build/flexcat/globals.c new file mode 100644 index 00000000..395111ac --- /dev/null +++ b/build/flexcat/globals.c @@ -0,0 +1,42 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "flexcat.h" +#include "SDI_compiler.h" + +/// Globals +char *BaseName = NULL; /* Basename of catalog description */ +const char *Language = "english"; /* Language of catalog description */ +int CatVersion = 0; /* Version of catalog to be opened */ +int CatRevision = 0; /* Revision of catalog to be opened */ +int NumStrings = 0; /* Number of catalog strings */ +char *ScanFile; /* File currently scanned */ +int ScanLine; /* Line currently scanned */ +int GlobalReturnCode = 0; /* Will be 5 if warnings appear */ +int NumberOfWarnings = 0; /* We count warnings to be smart + and avoid Beep bombing, but + call DisplayBeep() only once */ +int buffer_size = 2048; /* Size of the I/O buffer */ + +const char USED_VAR versionCookie[] = VERSTAG; + +/// diff --git a/build/flexcat/globals.h b/build/flexcat/globals.h new file mode 100644 index 00000000..132741ea --- /dev/null +++ b/build/flexcat/globals.h @@ -0,0 +1,39 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_GLOBALS_H +#define FLEXCAT_GLOBALS_H + +/* Variables */ +extern int buffer_size; +extern char *ScanFile; +extern int ScanLine; +extern char *BaseName; +extern int LengthBytes; +extern int NumStrings; +extern char *Language; +extern int CatVersion; +extern int CatRevision; +extern int GlobalReturnCode; +extern int NumberOfWarnings; + +#endif /* FLEXCAT_GLOBALS_H */ diff --git a/build/flexcat/locale.c b/build/flexcat/locale.c new file mode 100644 index 00000000..3cac0386 --- /dev/null +++ b/build/flexcat/locale.c @@ -0,0 +1,132 @@ + +/**************************************************************** + + This file was created automatically by `FlexCat 2.15' + from "locale/FlexCat.pot". + + Do NOT edit by hand! + +****************************************************************/ + +/* Include files */ +#include +#include +#include + +#include "FlexCat_cat.h" + +/* Variables */ +struct FC_String FlexCat_Strings[] = +{ + { "Usage:", 0 }, + { " CDFILE Catalog description file to scan\n CTFILE Catalog translation file to scan\n POFILE Catalog translation in PO-style format\n CATALOG Catalog file to create\n NEWCTFILE Catalog translation file to create\n SOURCES Sources to create; must be something like SFILE=SDFILE,\n where SFILE is a source file and SDFILE is a source\n description file\n WARNCTGAPS Warn about identifiers missing in translation\n NOOPTIM Do not skip unchanged strings in translation/description\n FILL Fill missing identifiers with original text\n FLUSH Flush memory after the catalog is created\n NOBEEP No DisplayBeep() on errors and warnings\n QUIET No warnings\n NOLANGTOLOWER Prevent #language name from being lowercased\n NOBUFFEREDIO Disable I/O buffers\n MODIFIED Create catalog only if description/translation have changed\n COPYMSGNEW Copy ***NEW*** markers over from old translation\n OLDMSGNEW Custom marker in old translation\n CODESET Codeset to force in output file (e.g. 'UTF-8')\n NOAUTODATE no operation - kept for compatibility\n NOSPACES no operation - kept for compatibility", 1 }, + { "File '%s' is up to date", 2 }, + { "%s, line %d - warning:", 100 }, + { "%s, line %d - ERROR:", 101 }, + { "expected hex character (one of [0-9a-fA-F])", 102 }, + { "expected octal character (one of [0-7])", 103 }, + { "lengthbytes cannot be larger than %d (sizeof long)", 104 }, + { "unknown catalog description command", 105 }, + { "unexpected blanks", 106 }, + { "missing identifier", 107 }, + { "unexpected end of file (missing catalog strings)", 115 }, + { "unknown command in translation", 118 }, + { "'%s' missing in catalog description", 119 }, + { "unknown string type", 120 }, + { "unexpected end of line (missing ')')", 121 }, + { "binary characters in string type None", 122 }, + { "'%s' missing in catalog translation", 123 }, + { "catalog language declared twice", 124 }, + { "catalog version declared twice", 125 }, + { "incorrect RCS Id", 126 }, + { "out of memory!", 127 }, + { "cannot open catalog description '%s'", 128 }, + { "cannot open catalog translation '%s'", 129 }, + { "missing catalog translation version\nUse either '## version' or '## rcsid' and '## name'", 130 }, + { "cannot open catalog file '%s'", 131 }, + { "cannot create catalog translation '%s'", 132 }, + { "missing catalog translation language", 133 }, + { "cannot open source file '%s'", 134 }, + { "cannot open source description file '%s'", 135 }, + { "creating a catalog requires a translation file", 136 }, + { "cannot get datestamp of '%s'", 137 }, + { "Catalog translation file name not specified at command line or as basename in description", 140 }, + { "catalog file name not specified at command line or as basename in description", 141 }, + { "error processing 'FlexCat.prefs' variable, falling back to defaults\nTemplate:", 142 }, + { "invalid language in catalog translation file\nLanguage MUST be a string with alphabetical characters and no inlined or trailing spaces", 144 }, + { "catalog codeset declared twice", 146 }, + { "invalid codeset in catalog translation file\nCodeset MUST be a decimal number without any trailing spaces", 147 }, + { "missing catalog translation codeset", 148 }, + { "%s - ERROR:", 149 }, + { "invalid version string in catalog translation file\nVersion should be something like\n## version $VER: name version.revision (date)\nwithout any spaces in the name", 150 }, + { "%s - Warning:", 154 }, + { "missing translation for identifier '%s'", 155 }, + { "empty translation for identifier '%s'", 156 }, + { "mismatching trailing control characters", 157 }, + { "identifier '%s' declared twice", 159 }, + { "string too short for identifier '%s'", 160 }, + { "string too long for identifier '%s'", 161 }, + { "original string has a trailing ellipsis ('...') for identifier '%s'", 162 }, + { "original string doesn't have a trailing ellipsis ('...') for identifier '%s'", 163 }, + { "original string has trailing blanks for identifier '%s'", 164 }, + { "original string doesn't have trailing blanks for identifier '%s'", 165 }, + { "mismatching placeholders for identifier '%s'", 166 }, + { "missing placeholders for identifier '%s'", 167 }, + { "excessive placeholders for identifier '%s'", 168 }, + { "missing '(' for identifier '%s'", 169 }, + { "missing ')' for identifier '%s'", 170 }, + { "ID number used twice for identifier '%s'", 171 }, + { "expected MinLen (character '/') for identifier '%s'", 172 }, + { "expected MaxLen (character '/') for identifier '%s'", 173 }, + { "extra characters at the end of the line", 174 }, + { "extra characters at the end of the line for identifier '%s'", 175 }, + { "non-ASCII character 0x%02x found in original string for identifier '%s'", 176 }, + { "no catalog revision information found, using revision 0", 177 }, + { "UTF8 conversion failed for identifier '%s'", 178 }, + { "ERROR in CodesetsFind(): unknown source charset '%s'", 179 }, + { "ERROR in CodesetsFind(): unknown destination charset '%s'", 180 }, + { "ERROR in CodesetsConvertStr(): %d invalid characters found", 181 }, + { "ERROR in iconv(): %s", 182 }, + { "ERROR in iconv_open(): %s", 183 }, + { NULL, 0 } +}; + +static struct Catalog *FlexCatCatalog; + +void OpenFlexCatCatalog() +{ + if(LocaleBase != NULL) + { + if ((FlexCatCatalog = OpenCatalog(NULL, (STRPTR)"FlexCat.catalog", + OC_BuiltInLanguage, (STRPTR)"english", + OC_Version, 3, + TAG_DONE)) != NULL) + { + struct FC_String *fc; + + for(fc = FlexCat_Strings; fc->Str; fc++) + { + fc->Str = (const char *)GetCatalogStr(FlexCatCatalog, fc->Id, (STRPTR)fc->Str); + } + } + } +} + +void CloseFlexCatCatalog() +{ + if(FlexCatCatalog != NULL) + { + CloseCatalog(FlexCatCatalog); + FlexCatCatalog = NULL; + } +} + +void LocalizeStringArray(STRPTR *Array) +{ + STRPTR *x; + + for(x = Array; *x != NULL; x++) + { + *x = strdup(FlexCat_Strings[(int)*x].Str); + } +} diff --git a/build/flexcat/locale_other.c b/build/flexcat/locale_other.c new file mode 100644 index 00000000..b4c70574 --- /dev/null +++ b/build/flexcat/locale_other.c @@ -0,0 +1,117 @@ + +/**************************************************************** + + This file was created automatically by `FlexCat 2.15' + from "locale/FlexCat.pot". + + Do NOT edit by hand! + +****************************************************************/ + +/* Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/**************************************************************** + + This file provides at least minimal compatibility with + the AmigaOS catalog system on other platforms. It creates + the necessary string tables (hardcoded ATM) and functions + to make code work under any operating system. + + Carlos + +****************************************************************/ + +void OpenFlexCatCatalog( void ) +{} +void CloseFlexCatCatalog( void ) +{} + +const char * FlexCat_Strings[70] = { + "Usage:", + " CDFILE Catalog description file to scan\n CTFILE Catalog translation file to scan\n POFILE Catalog translation in PO-style format\n CATALOG Catalog file to create\n NEWCTFILE Catalog translation file to create\n SOURCES Sources to create; must be something like SFILE=SDFILE,\n where SFILE is a source file and SDFILE is a source\n description file\n WARNCTGAPS Warn about identifiers missing in translation\n NOOPTIM Do not skip unchanged strings in translation/description\n FILL Fill missing identifiers with original text\n FLUSH Flush memory after the catalog is created\n NOBEEP No DisplayBeep() on errors and warnings\n QUIET No warnings\n NOLANGTOLOWER Prevent #language name from being lowercased\n NOBUFFEREDIO Disable I/O buffers\n MODIFIED Create catalog only if description/translation have changed\n COPYMSGNEW Copy ***NEW*** markers over from old translation\n OLDMSGNEW Custom marker in old translation\n CODESET Codeset to force in output file (e.g. 'UTF-8')\n NOAUTODATE no operation - kept for compatibility\n NOSPACES no operation - kept for compatibility", + "File '%s' is up to date", + "%s, line %d - warning:", + "%s, line %d - ERROR:", + "expected hex character (one of [0-9a-fA-F])", + "expected octal character (one of [0-7])", + "lengthbytes cannot be larger than %d (sizeof long)", + "unknown catalog description command", + "unexpected blanks", + "missing identifier", + "unexpected end of file (missing catalog strings)", + "unknown command in translation", + "'%s' missing in catalog description", + "unknown string type", + "unexpected end of line (missing ')')", + "binary characters in string type None", + "'%s' missing in catalog translation", + "catalog language declared twice", + "catalog version declared twice", + "incorrect RCS Id", + "out of memory!", + "cannot open catalog description '%s'", + "cannot open catalog translation '%s'", + "missing catalog translation version\nUse either '## version' or '## rcsid' and '## name'", + "cannot open catalog file '%s'", + "cannot create catalog translation '%s'", + "missing catalog translation language", + "cannot open source file '%s'", + "cannot open source description file '%s'", + "creating a catalog requires a translation file", + "cannot get datestamp of '%s'", + "Catalog translation file name not specified at command line or as basename in description", + "catalog file name not specified at command line or as basename in description", + "error processing 'FlexCat.prefs' variable, falling back to defaults\nTemplate:", + "invalid language in catalog translation file\nLanguage MUST be a string with alphabetical characters and no inlined or trailing spaces", + "catalog codeset declared twice", + "invalid codeset in catalog translation file\nCodeset MUST be a decimal number without any trailing spaces", + "missing catalog translation codeset", + "%s - ERROR:", + "invalid version string in catalog translation file\nVersion should be something like\n## version $VER: name version.revision (date)\nwithout any spaces in the name", + "%s - Warning:", + "missing translation for identifier '%s'", + "empty translation for identifier '%s'", + "mismatching trailing control characters", + "identifier '%s' declared twice", + "string too short for identifier '%s'", + "string too long for identifier '%s'", + "original string has a trailing ellipsis ('...') for identifier '%s'", + "original string doesn't have a trailing ellipsis ('...') for identifier '%s'", + "original string has trailing blanks for identifier '%s'", + "original string doesn't have trailing blanks for identifier '%s'", + "mismatching placeholders for identifier '%s'", + "missing placeholders for identifier '%s'", + "excessive placeholders for identifier '%s'", + "missing '(' for identifier '%s'", + "missing ')' for identifier '%s'", + "ID number used twice for identifier '%s'", + "expected MinLen (character '/') for identifier '%s'", + "expected MaxLen (character '/') for identifier '%s'", + "extra characters at the end of the line", + "extra characters at the end of the line for identifier '%s'", + "non-ASCII character 0x%02x found in original string for identifier '%s'", + "no catalog revision information found, using revision 0", + "UTF8 conversion failed for identifier '%s'", + "ERROR in CodesetsFind(): unknown source charset '%s'", + "ERROR in CodesetsFind(): unknown destination charset '%s'", + "ERROR in CodesetsConvertStr(): %d invalid characters found", + "ERROR in iconv(): %s", + "ERROR in iconv_open(): %s" +}; diff --git a/build/flexcat/main.c b/build/flexcat/main.c new file mode 100644 index 00000000..87caf859 --- /dev/null +++ b/build/flexcat/main.c @@ -0,0 +1,429 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + ****************************************************************** + ** If you use GoldED or any other text editor featuring folding ** + ** you may want to set up "///" as fold opening phrase, and ** + ** "///" as closing one, as this source is using it. ** + ** Marcin ** + ****************************************************************** + */ + +#include "flexcat.h" +#include "readprefs.h" +#include "showfuncs.h" +#include "swapfuncs.h" +#include "scanct.h" +#include "scancd.h" +#include "scanpo.h" +#include "createcat.h" +#include "createct.h" +#include "utils.h" +#include "globals.h" +#include "createcatsrc.h" +#include "openlibs.h" + +/// isParam +int isParam(char *input_string) +{ + if(Stricmp(input_string, "catalog") == 0) + return TRUE; + if(Strnicmp(input_string, "catalog=", 8) == 0) + return TRUE; + if(Stricmp(input_string, "pofile") == 0) + return TRUE; + if(Strnicmp(input_string, "pofile=", 7) == 0) + return TRUE; + if(Stricmp(input_string, "codeset") == 0) + return TRUE; + if(Strnicmp(input_string, "codeset=", 8) == 0) + return TRUE; + if(Stricmp(input_string, "nooptim") == 0) + return TRUE; + if(Stricmp(input_string, "fill") == 0) + return TRUE; + if(Stricmp(input_string, "quiet") == 0) + return TRUE; + if(Stricmp(input_string, "flush") == 0) + return TRUE; + if(Stricmp(input_string, "nobeep") == 0) + return TRUE; + if(Stricmp(input_string, "nobufferedio") == 0) + return TRUE; + if(Strnicmp(input_string, "newctfile=", 10) == 0) + return TRUE; + if(Stricmp(input_string, "newctfile") == 0) + return TRUE; + if(Stricmp(input_string, "nolangtolower") == 0) + return TRUE; + if(Stricmp(input_string, "modified") == 0) + return TRUE; + if(Stricmp(input_string, "warnctgaps") == 0) + return TRUE; + if(Stricmp(input_string, "copymsgnew") == 0) + return TRUE; + if(Stricmp(input_string, "oldmsgnew") == 0) + return TRUE; + if(Stricmp(input_string, "?") == 0) + return TRUE; + if(Stricmp(input_string, "-h") == 0) + return TRUE; + if(Stricmp(input_string, "help") == 0) + return TRUE; + if(Stricmp(input_string, "--help") == 0) + return TRUE; + + return FALSE; +} + +/// +/// main + +/* Finally, the main function. It does nothing special + except for scanning the arguments. */ + +int main(int argc, char *argv[]) +{ + char *cdfile = NULL; + char *ctfile = NULL; + char *pofile = NULL; + char *newctfile = NULL; + char *catalog = NULL; + char *source; + char *template; + int makenewct = FALSE; + int makecatalog = FALSE; + int i; + + if(argc == 0) /* Aztec's entry point for workbench programs */ + { + fprintf(stderr, "FlexCat can't be run from Workbench!\n" \ + "\n" + "Open a Shell session and type FlexCat ?\n" \ + "for more information\n"); + exit(5); + } + + if(OpenLibs() == FALSE) + exit(20); + + OpenFlexCatCatalog(); + + /* Big Endian vs. Little Endian (both supported ;-) */ + + if(!SwapChoose()) + { + fprintf(stderr, "FlexCat is unable to determine\n" \ + "the byte order used by your system.\n" \ + "It's neither Little nor Big Endian?!.\n"); + exit(5); + } +#ifdef AMIGA + ReadPrefs(); +#endif + if(argc == 1) + { + Usage(); + } + + for(i = 1; i < argc; i++) + { + if(Strnicmp(argv[i], "catalog=", 8) == 0) + { + catalog = argv[i] + 8; + makecatalog = TRUE; + } + else if(Stricmp(argv[i], "catalog") == 0) + { + if(i == argc - 1) + { + catalog = NULL; + makecatalog = TRUE; + } + else if(i < argc - 1) + { + if(isParam(argv[i + 1]) != TRUE) + { + catalog = argv[i + 1]; + i++; + makecatalog = TRUE; + } + else + { + catalog = NULL; + makecatalog = TRUE; + } + } + } + else if(Strnicmp(argv[i], "pofile=", 7) == 0) + { + pofile = argv[i] + 7; + } + else if(Stricmp(argv[i], "pofile") == 0) + { + if(i == argc - 1) + pofile = NULL; + else if(i < argc - 1) + { + if(isParam(argv[i + 1]) != TRUE) + { + pofile = argv[i + 1]; + i++; + } + else + pofile = NULL; + } + } + else if(Strnicmp(argv[i], "codeset=", 8) == 0) + { + strcpy(DestCodeset, argv[i] + 8); + } + else if(Stricmp(argv[i], "codeset") == 0) + { + if(i == argc - 1) + DestCodeset[0] = '\0'; + else if(i < argc - 1) + { + if(isParam(argv[i + 1]) != TRUE) + { + strcpy(DestCodeset, argv[i + 1]); + i++; + } + else + DestCodeset[0] = '\0'; + } + } + else if(Stricmp(argv[i], "nooptim") == 0) + { + NoOptim = TRUE; + } + else if(Stricmp(argv[i], "fill") == 0) + { + Fill = TRUE; + } + else if(Stricmp(argv[i], "quiet") == 0) + { + Quiet = TRUE; + } + else if(Stricmp(argv[i], "flush") == 0) + { + DoExpunge = TRUE; + } + else if(Stricmp(argv[i], "nobeep") == 0) + { + NoBeep = TRUE; + } + else if(Stricmp(argv[i], "nobufferedio") == 0) + { + NoBufferedIO = TRUE; + } + else if(Strnicmp(argv[i], "newctfile=", 10) == 0) + { + newctfile = argv[i] + 10; + makenewct = TRUE; + } + else if(Stricmp(argv[i], "newctfile") == 0) + { + if(i == argc - 1) + { + newctfile = NULL; + makenewct = TRUE; + } + else if(i < argc - 1) + { + if(isParam(argv[i + 1]) != TRUE) + { + newctfile = argv[i + 1]; + i++; + makenewct = TRUE; + } + else + { + newctfile = NULL; + makenewct = TRUE; + } + } + } + else if(Stricmp(argv[i], "nolangtolower") == 0) + { + LANGToLower = FALSE; + } + else if(Stricmp(argv[i], "modified") == 0) + { + Modified = TRUE; + } + else if(Stricmp(argv[i], "warnctgaps") == 0) + { + WarnCTGaps = TRUE; + } + else if(Stricmp(argv[i], "copymsgnew") == 0) + { + CopyNEWs = TRUE; + } + else if(Stricmp(argv[i], "oldmsgnew") == 0) + { + snprintf(Old_Msg_New, sizeof(Old_Msg_New), "; %s", argv[++i]); + } + else if(Stricmp(argv[i], "noautodate") == 0 || Stricmp(argv[i], "nospaces") == 0) + { + // just swallow some no longer supported options to + // keep old scripts alive and happy + } + else if(cdfile == NULL) + { + if(Stricmp(argv[i], "?") == 0 || + Stricmp(argv[i], "-h") == 0 || + Stricmp(argv[i], "help") == 0 || + Stricmp(argv[i], "--help") == 0) + { + Usage(); + } + + cdfile = argv[i]; + + // find out file extension and depending on it + // we eiterh scan a CD file or the supplied pot file + if(strstr(cdfile, ".pot") != NULL) + { + if(!ScanPOFile(cdfile)) + MyExit(10); + } + else + { + if(!ScanCDFile(cdfile)) + MyExit(10); + } + } + else if(strchr(argv[i], '=') != NULL) + { + /* Determine basename. */ + if(BaseName == NULL && cdfile != NULL) + { + char *lslash = strrchr(cdfile, '/'); + char *ldot = strrchr(cdfile, '.'); + + if(lslash == NULL) + lslash = cdfile; + else + lslash++; + + if(ldot == NULL) + ldot = cdfile + strlen(cdfile); + + if(ldot - lslash > 0) + { + BaseName = calloc(ldot - lslash + 3, 1); + strncpy(BaseName, lslash, ldot - lslash); + } + } + + source =AllocString(argv[i]); + template = strchr(source, '='); + *template++ = '\0'; + + CreateSourceFile(source, template, cdfile); + } + else + { + if(ctfile != NULL) + { + Usage(); + } + ctfile = argv[i]; + } + } + +#ifdef AMIGA + if(Modified) + { + if(cdfile != NULL && ctfile != NULL && catalog != NULL) + { + int32 cd_time, ct_time, cat_time; + + if((cd_time = getft(cdfile)) != -1) + { + if((ct_time = getft(ctfile)) != -1) + { + if((cat_time = getft(catalog)) == -1) + cat_time = 0; + + if(cat_time > ct_time && cat_time > cd_time) + { + if(!Quiet) + { + fprintf(stderr, MSG_FILEUPTODATE, catalog); + putc('\n', stderr); + } + + MyExit(GlobalReturnCode); + } + else + { + if(!Quiet) + { + fprintf(stderr, "--> %s\n", catalog); + } + } + } + else + { + ShowError(MSG_ERR_CANTCHECKDATE, ctfile); + } + } + else + { + ShowError(MSG_ERR_CANTCHECKDATE, cdfile); + } + } + } +#endif + + if(ctfile != NULL) + { + if(!ScanCTFile(ctfile)) + MyExit(10); + } + + if(pofile != NULL) + { + if(!ScanPOFile(pofile)) + MyExit(10); + } + + if(makecatalog == TRUE) + { + if(ctfile == NULL && pofile == NULL) + { + fprintf(stderr, "%s\n", MSG_ERR_NOCTARGUMENT); + Usage(); + } + CreateCat(catalog); + } + + if(makenewct == TRUE) + { + CreateCTFile(newctfile); + } + MyExit(GlobalReturnCode); + + return 0; +} + +/// diff --git a/build/flexcat/openlibs.c b/build/flexcat/openlibs.c new file mode 100644 index 00000000..cc75cd7f --- /dev/null +++ b/build/flexcat/openlibs.c @@ -0,0 +1,109 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#if defined(AMIGA) +#include "flexcat.h" +#include "openlibs.h" +#include "utils.h" +#define __NOLIBBASE__ +#include +#include +#include +#include +#include + +#if defined(__amigaos3__) || defined(__MORPHOS__) || defined(__AROS__) +#if defined(__AROS__) +struct UtilityBase *UtilityBase = NULL; +#else +struct Library *UtilityBase = NULL; +#endif +struct IntuitionBase *IntuitionBase = NULL; +#if defined(__MORPHOS__) +struct Library *LocaleBase = NULL; +#else +struct LocaleBase *LocaleBase = NULL; +#endif +#endif +struct Library *CodesetsBase = NULL; + +#if defined(__amigaos4__) +struct CodesetsIFace *ICodesets = NULL; +#endif + + +BOOL OpenLibs(void) +{ + #if defined(__amigaos3__) || defined(__MORPHOS__) || defined(__AROS__) + if( + #if defined(__AROS__) + (UtilityBase = (struct UtilityBase *)OpenLibrary("utility.library", 37)) != NULL && + #else + (UtilityBase = OpenLibrary("utility.library", 37)) != NULL && + #endif + (IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37)) != NULL && + #if defined(__MORPHOS__) + (LocaleBase = (struct Library *)OpenLibrary("locale.library", 37)) != NULL) + #else + (LocaleBase = (struct LocaleBase *)OpenLibrary("locale.library", 37)) != NULL) + #endif + #endif + { + if((CodesetsBase = OpenLibrary(CODESETSNAME, CODESETSVER)) && + GETINTERFACE(ICodesets, CodesetsBase)) + { + return TRUE; + } + } + + return FALSE; +} + +void CloseLibs(void) +{ + #if defined(__amigaos3__) || defined(__MORPHOS__) || defined(__AROS__) + if(UtilityBase != NULL) + { + CloseLibrary((struct Library *)UtilityBase); + UtilityBase = NULL; + } + if(IntuitionBase != NULL) + { + CloseLibrary((struct Library *)IntuitionBase); + IntuitionBase = NULL; + } + if(LocaleBase != NULL) + { + CloseLibrary((struct Library *)LocaleBase); + LocaleBase = NULL; + } + #endif + + if(CodesetsBase != NULL) + { + DROPINTERFACE(ICodesets); + CloseLibrary(CodesetsBase); + CodesetsBase = NULL; + } +} + +#endif // AMIGA diff --git a/build/flexcat/openlibs.h b/build/flexcat/openlibs.h new file mode 100644 index 00000000..542162fc --- /dev/null +++ b/build/flexcat/openlibs.h @@ -0,0 +1,34 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef OPENLIBS_H +#define OPENLIBS_H 1 + +#if defined(AMIGA) +BOOL OpenLibs(void); +void CloseLibs(void); +#else +#define OpenLibs() TRUE +#define CloseLibs() ((void)0) +#endif + +#endif /* OPENLIBS_H */ diff --git a/build/flexcat/readprefs.c b/build/flexcat/readprefs.c new file mode 100644 index 00000000..04b3cb3e --- /dev/null +++ b/build/flexcat/readprefs.c @@ -0,0 +1,163 @@ +/* + * $Id$ + * + * Copyright(C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or(at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "flexcat.h" + +int WarnCTGaps = FALSE; /* Warn for missing symbols in CT file. */ +int NoOptim = FALSE; /* Put string into catalog even + if translation is equal to + description. */ +int Fill = FALSE; /* If translation of given string + is missing or empty, write + string descriptor from #?.cd + file instead. */ +int DoExpunge = FALSE; /* If TRUE, FlexCat will do an AVAIL + FLUSH-alike call after saving the catalog. */ +int NoBeep = FALSE; /* If TRUE, FlexCat won't call + DisplayBeep() any longer. */ +int Quiet = FALSE; /* Forces FlexCat to shut up. */ +int LANGToLower = TRUE; /* Shall we do ToLower() on lang's name ? + Some #?.language drivers seem to be + broken, so we provide a workaround. */ +int NoBufferedIO = FALSE; /* Shall we do buffered I/O ? */ +int Modified = FALSE; /* Shall we write the catalog ONLY + if #?.catalog is newer than + #?.c(d|t) files ? */ +char Msg_New[MAX_NEW_STR_LEN] = "***NEW***"; /* New strings in updated #?.ct */ +int CopyNEWs = FALSE; /* Shall we write the Msg_New into new strings ? */ +char Old_Msg_New[MAX_NEW_STR_LEN] = "; ***NEW***"; /* Old new string(above) used in old + CT file. Now we look if it's present + and copy it into new CT if the user + upgrades(flexcat CD CT newctfile CT */ +char DestCodeset[MAX_NEW_STR_LEN] = ""; /* To which codeset should we convert to + If empty then this signals that FlexCat + should automatically find out which codeset + to be used */ + + +char prefs_sddir[MAXPATHLEN] = "\0"; + +/// ReadPrefs + +/* Fill in options from preferences file. */ + +char ReadPrefs(void) +{ + char result = FALSE; + +#ifdef AMIGA + +#define MAX_PREFS_LEN 512 +#define FLEXCAT_PREFS "flexcat.prefs" + + enum + { + SDDIR, + MSG_NEW, + CODESET, + WARNCTGAPS, + NOOPTIM, + FILL, + FLUSH, + NOBEEP, + QUIET, + NOLANGTOLOWER, + NOBUFFEREDIO, + MODIFIED, + COPYMSGNEW, + OLDMSGNEW, + NOAUTODATE, + NOSPACES, + ARGS_COUNT + }; + + const char template[] = "SDDIR/K,MSG_NEW/K,CODESET/K,WARNCTGAPS/S,NOOPTIM/S,FILL/S,FLUSH/S,NOBEEP/S,QUIET/S,NOLANGTOLOWER/S,NOBUFFEREDIO/S,MODIFIED/S,COPYMSGNEW/S,OLDMSGNEW/K,NOAUTODATE/S,NOSPACES/S"; + LONG Results[ARGS_COUNT] = { 0 }; + char *prefs; + struct RDArgs *rda; + struct RDArgs *rdargs; + + if((prefs = malloc(2048)) != NULL) + { + if(GetVar(FLEXCAT_PREFS, prefs, 80, 0) != -1) + { + prefs = realloc(prefs, strlen(prefs) + 1); + strcat(prefs, "\n"); + + if((rda = AllocDosObject(DOS_RDARGS, TAG_DONE)) != NULL) + { + rda->RDA_Source.CS_Buffer = prefs; + rda->RDA_Source.CS_Length = strlen(prefs); + rda->RDA_Source.CS_CurChr = 0; + rda->RDA_Flags |= RDAF_NOPROMPT; + + if((rdargs = ReadArgs(template, Results, rda)) != NULL) + { + if(Results[SDDIR]) + strlcpy(prefs_sddir, (char *)Results[SDDIR], MAXPATHLEN); + + if(Results[MSG_NEW]) + strlcpy(Msg_New, (char *)Results[MSG_NEW], MAX_NEW_STR_LEN); + + if(Results[CODESET]) + strlcpy(DestCodeset, (char *)Results[CODESET], MAX_NEW_STR_LEN); + + WarnCTGaps = Results[WARNCTGAPS]; + NoOptim = Results[NOOPTIM]; + Fill = Results[FILL]; + DoExpunge = Results[FLUSH]; + NoBeep = Results[NOBEEP]; + Quiet = Results[QUIET]; + LANGToLower = !Results[NOLANGTOLOWER]; + Modified = Results[MODIFIED]; + NoBufferedIO = Results[NOBUFFEREDIO]; + CopyNEWs = Results[COPYMSGNEW]; + if(Results[OLDMSGNEW]) + snprintf(Old_Msg_New, sizeof(Old_Msg_New), "; %s", (char *)Results[OLDMSGNEW]); + + FreeArgs(rdargs); + + result = TRUE; + } + else + { + fputs(MSG_ERR_BADPREFS, stderr); + fputs(template, stderr); + fputs("\n", stderr); + DisplayBeep(NULL); + } + FreeDosObject(DOS_RDARGS, rda); + } + else + { + fputs("Error processing prefs.\n" \ + "Can't AllocDosObject()\n", stderr); + } + free(prefs); + } + } +#endif + + return(result); +} + +/// diff --git a/build/flexcat/readprefs.h b/build/flexcat/readprefs.h new file mode 100644 index 00000000..53c49aa1 --- /dev/null +++ b/build/flexcat/readprefs.h @@ -0,0 +1,45 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_READPREFS_H +#define FLEXCAT_READPREFS_H + +/* Functions */ +char ReadPrefs ( void ); + +/* Variables */ +extern char *prefs_sddir; +extern int WarnCTGaps; +extern int NoOptim; +extern int Fill; +extern int DoExpunge; +extern int NoBeep; +extern int Quiet; +extern int LANGToLower; +extern int NoBufferedIO; +extern int Modified; +extern char Msg_New[MAX_NEW_STR_LEN]; +extern int CopyNEWs; +extern char Old_Msg_New[MAX_NEW_STR_LEN]; +extern char DestCodeset[MAX_NEW_STR_LEN]; + +#endif /* FLEXCAT_READPREFS_H */ diff --git a/build/flexcat/scancd.c b/build/flexcat/scancd.c new file mode 100644 index 00000000..4a328886 --- /dev/null +++ b/build/flexcat/scancd.c @@ -0,0 +1,418 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "flexcat.h" +#include "showfuncs.h" +#include "readprefs.h" +#include "globals.h" +#include "utils.h" +#include "createcat.h" + +struct CDLine *FirstCDLine = NULL; /* First catalog description line. */ +char *HeaderName = NULL; + +/// ScanCDFile + +/* This scans the catalog description file. + Inputs: cdfile - name of the catalog description file + Result: TRUE if successful, FALSE otherwise */ + +int ScanCDFile(char *cdfile) +{ + FILE *fp; + struct CDLine *cdline, **cdptr = &FirstCDLine; + struct CatString *cs, **csptr = &FirstCatString; + char *line, *newline; + int NextID = 0; + int Result = TRUE; + int lenbytes = 0; + + ScanFile = cdfile; + ScanLine = 0; + + if((fp = fopen(cdfile, "r")) == NULL) + { + ShowErrorQuick(MSG_ERR_NOCATALOGDESCRIPTION, cdfile); + } + + if(!NoBufferedIO) + setvbuf(fp, NULL, _IOFBF, buffer_size); + + while(!feof(fp) && (line = newline = ReadLine(fp, TRUE)) != NULL) + { + if((cdline = malloc(sizeof(*cdline))) == NULL) + { + MemError(); + } + + *cdptr = cdline; + cdptr = &cdline->Next; + cdline->Next = NULL; + cdline->Line = line = AllocString(newline); + free(newline); + + if(*line == ';') + { + continue; + } + else if(*line == '#') + { + int CheckExtra = TRUE; + + /* '#' in the first column of a line is the command introducer -- + any number of # symbols, blank spaces and tabs afterwards are + skipped for compatibility with CatComp */ + + while(*line == '#' || *line == ' ' || *line == '\t') + { + ++line; + } + + if(Strnicmp(line, "language", 8) == 0) + { + char *ptr; + + line += 9; + OverSpace(&line); + Language = AllocString(line); + if(LANGToLower) + { + for(ptr = Language; *ptr; ptr++) + { + *ptr = tolower((int)*ptr); + } + } + CheckExtra = FALSE; + } + else if(Strnicmp(line, "version", 7) == 0) + { + line += 8; + OverSpace(&line); + CatVersion = strtol(line, &line, 0); + CheckExtra = TRUE; + } + else if(Strnicmp(line, "basename", 8) == 0) + { + line += 9; + OverSpace(&line); + free(BaseName); + BaseName = AllocString(line); + CheckExtra = FALSE; + } + else if(Strnicmp(line, "ifdef", 5) == 0) + { + continue; + } + else if(Strnicmp(line, "endif", 5) == 0) + { + continue; + } + else if(Strnicmp(line, "array", 5) == 0) + { + continue; + } + else if(Strnicmp(line, "header", 6) == 0) + { + line += 7; + OverSpace(&line); + free(HeaderName); + HeaderName = AllocString(line); + CheckExtra = FALSE; + + } + else if(Strnicmp(line, "lengthbytes", 11) == 0) + { + line += 12; + OverSpace(&line); + lenbytes = atoi(line); + CheckExtra = FALSE; + } + else if(Strnicmp(line, "printf_check_off", 16) == 0) + { + continue; + } + else if(Strnicmp(line, "printf_check_on", 15) == 0) + { + continue; + } + else + { + ShowWarn(MSG_ERR_UNKNOWNCDCOMMAND); + Result = FALSE; + CheckExtra = FALSE; + } + + if(CheckExtra == TRUE) + { + OverSpace(&line); + if(*line != '\0') + { + ShowError(MSG_ERR_EXTRA_CHARACTERS); + Result = FALSE; + } + } + } + else + { + char *idstr; + + /* Check for blanks at the start of line. */ + + if(*line == ' ' || *line == '\t') + { + ShowError(MSG_ERR_UNEXPECTEDBLANKS); + Result = FALSE; + OverSpace(&line); + } + + idstr = line; + while((*line >= 'a' && *line <= 'z') || + (*line >= 'A' && *line <= 'Z') || + (*line >= '0' && *line <= '9') || + (*line == '_')) + { + ++line; + } + + if(idstr == line) + { + ShowError(MSG_ERR_NOIDENTIFIER); + Result = FALSE; + } + else + { + int found; + + if((cs = malloc(sizeof(*cs))) == NULL) + { + MemError(); + } + + do + { + struct CatString *scs; + + found = TRUE; + for(scs = FirstCatString; scs != NULL; scs = scs->Next) + { + if(scs->ID == NextID) + { + found = FALSE; + ++NextID; + break; + } + } + } + while(found == FALSE); + + cs->Next = NULL; + cs->ID = NextID; + cs->MinLen = 0; + cs->MaxLen = -1; + cs->CD_Str = (char *)""; + cs->CT_Str = NULL; + cs->NotInCT = TRUE; + cs->POformat = FALSE; + + if((cs->ID_Str = malloc((line - idstr) + 1)) == NULL) + { + MemError(); + } + strncpy(cs->ID_Str, idstr, line - idstr); + cs->ID_Str[line - idstr] = '\0'; + OverSpace(&line); + + /* Check if next char in line is '('? (//) */ + + if(*line != '(') + { + ShowError(MSG_ERR_NO_LEADING_BRACKET, cs->ID_Str); + Result = FALSE; + } + else + { + char *oldstr; + struct CatString *scs; + char bytes[10]; + int bytesread, reallen; + + ++line; + OverSpace(&line); + + /* Check for default config of line (//) */ + + if(*line != '/') + { + if(*line == '+') + { + NextID = cs->ID = NextID + strtol(line, &line, 0); + } + else if(*line == '$') + { + line++; + cs->ID = NextID = strtol(line, &line, 16); + } + else + { + cs->ID = NextID = strtol(line, &line, 0); + } + OverSpace(&line); + } + + /* Check for already used identifier. */ + + for(scs = FirstCatString; scs != NULL; scs = scs->Next) + { + if(scs->ID == cs->ID) + { + ShowError(MSG_ERR_DOUBLE_ID, cs->ID_Str); + Result = FALSE; + } + if(strcmp(cs->ID_Str, scs->ID_Str) == 0) + { + ShowError(MSG_ERR_DOUBLE_IDENTIFIER, cs->ID_Str); + Result = FALSE; + } + } + + /* Check for min/len values (//) */ + + if(*line != '/') + { + ShowWarn(MSG_ERR_NO_MIN_LEN, cs->ID_Str); + Result = FALSE; + } + else + { + ++line; + OverSpace(&line); + if(*line != '/') + { + cs->MinLen = strtol(line, &line, 0); + OverSpace(&line); + } + if(*line != '/') + { + ShowWarn(MSG_ERR_NO_MAX_LEN, cs->ID_Str); + Result = FALSE; + } + else + { + ++line; + OverSpace(&line); + if(*line != ')') + { + cs->MaxLen = strtol(line, &line, 0); + OverSpace(&line); + } + if(*line != ')') + { + ShowError(MSG_ERR_NO_TRAILING_BRACKET, cs->ID_Str); + Result = FALSE; + } + else + { + ++line; + OverSpace(&line); + if(*line) + { + ShowError(MSG_ERR_EXTRA_CHARACTERS_ID, cs->ID_Str); + } + } + } + } + + /* Huh? There is no string for this definition? */ + + if((newline = ReadLine(fp, FALSE)) == FALSE) + { + ShowWarn(MSG_ERR_MISSINGSTRING); + Result = FALSE; + cs->CD_Str = (char *)""; + } + else + { + // Check if there are any non-ASCII characters contained in the line. + // This will cause a warning only, since non-ASCII characters in the + // default language are discouraged. + char *p = newline; + char c; + + while((c = *p++) != '\0') + { + if(!isascii(c)) + { + int v = (int)c; + + ShowWarn(MSG_ERR_NON_ASCII_CHARACTER, v & 0xff, cs->ID_Str); + break; + } + } + + cs->CD_Str = AllocString(newline); + free(newline); + } + + /* Get string length. */ + + oldstr = cs->CD_Str; + reallen = 0; + while(*oldstr != '\0') + { + bytesread = ReadChar(&oldstr, bytes); + if(bytesread == 2) + { + bytesread--; + } + reallen += bytesread; + } + + /* String too short. */ + + if(cs->MinLen > 0 && reallen < cs->MinLen) + { + ShowWarn(MSG_ERR_STRING_TOO_SHORT, cs->ID_Str); + } + + /* String too long. */ + + if(cs->MaxLen > 0 && reallen > cs->MaxLen) + { + ShowWarn(MSG_ERR_STRING_TOO_LONG, cs->ID_Str); + } + + cs->Nr = NumStrings; + cs->LenBytes = lenbytes; + *csptr = cs; + csptr = &cs->Next; + ++NumStrings; + } + } + } + } + + fclose(fp); + + return Result; +} + +/// diff --git a/build/flexcat/scancd.h b/build/flexcat/scancd.h new file mode 100644 index 00000000..cd2d8e02 --- /dev/null +++ b/build/flexcat/scancd.h @@ -0,0 +1,33 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_SCANCD_H +#define FLEXCAT_SCANCD_H + +/* Functions */ +int ScanCDFile ( char *cdfile ); + +/* Variables */ +extern char *HeaderName; +extern struct CDLine *FirstCDLine; + +#endif /* FLEXCAT_SCANCD_H */ diff --git a/build/flexcat/scanct.c b/build/flexcat/scanct.c new file mode 100644 index 00000000..d3b4df0d --- /dev/null +++ b/build/flexcat/scanct.c @@ -0,0 +1,471 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifdef AMIGA + #include /* This is to get locale.library/IsAlpha() */ +#endif + +// #include +// #include +#include +#include + + +#include "flexcat.h" +#include "showfuncs.h" +#include "readprefs.h" +#include "globals.h" +#include "utils.h" +#include "createcat.h" + +char *CatVersionString = NULL; /* Version string of catalog + translation (## version) */ +char *CatLanguage = NULL; /* Language of catalog translation */ +char *CatRcsId = NULL; /* RCS ID of catalog translation + (## rcsid) */ +char *CatName = NULL; /* Name of catalog translation */ +uint32 CodeSet = 0; /* Codeset of catalog translation */ +int CT_Scanned = FALSE; /* If TRUE and we are going to + write a new #?.ct file, then the + user is surely updating his own + #?.ct file, so we should write + ***NEW*** wherever necessary. */ + +#define IS_NUMBER_OR_LETTER(c) (((c) >= '0' && (c) <= '9') || \ + ((c) >= 'a' && (c) <= 'z') || \ + ((c) >= 'A' && (c) <= 'Z')) + +/// ScanCTFile + +/* This scans a catalog translation file. + Inputs: ctfile - name of the translation file to scan. + Result: TRUE if successful, FALSE otherwise. */ + +int ScanCTFile(char *ctfile) +{ + FILE *fp; + char *newline, *line, *idstr, *newidstr, *newstr; + struct CatString *cs = NULL; + int Result = TRUE; + int CodeSet_checked = 0; + + ScanFile = ctfile; + ScanLine = 0; + + if((fp = fopen(ctfile, "r")) == NULL) + { + ShowErrorQuick(MSG_ERR_NOCATALOGTRANSLATION, ctfile); + } + + if(!NoBufferedIO) + setvbuf(fp, NULL, _IOFBF, buffer_size); + + + while(!feof(fp) && (line = newline = ReadLine(fp, TRUE)) != NULL) + { + switch(*line) + { + case ';': + if(CopyNEWs == TRUE) + { + if(cs && Strnicmp(line, Old_Msg_New, (int)strlen(Old_Msg_New)) == 0) + { + cs->NotInCT = TRUE; + } + } + break; + + case '#': + + /* '#' in the first column of a line is the command introducer -- + any number of # symbols, blank spaces and tabs afterwards are + skipped for compatibility with CatComp */ + + while(*line == '#' || *line == ' ' || *line == '\t') + { + ++line; + } + + if(Strnicmp(line, "version", 7) == 0) + { + if(CatVersionString || CatRcsId || CatName) + { + ShowError(MSG_ERR_DOUBLECTVERSION); + } + line += 7; + OverSpace(&line); + // perform a slightly obfuscated check for the version cookie to + // avoid having multiple cookies in the final binary + if(line[0] == '$' && Strnicmp(&line[1], "VER:", 4) == 0) + { + CatVersionString = AllocString(line); + } + else + { + ShowError(MSG_ERR_BADCTVERSION); + } + } + else if(Strnicmp(line, "codeset", 7) == 0) + { + char *ptr; + + if(CodeSet_checked) + { + ShowError(MSG_ERR_DOUBLECTCODESET); + } + line += 7; + OverSpace(&line); + + if(!*line) + /* Missing argument for "## codeset" */ + { + ShowError(MSG_ERR_BADCTCODESET); + } + + for(ptr = line; *ptr; ptr++) + if(!isdigit((int)*ptr)) + /* Non-digit char detected */ + { + ShowError(MSG_ERR_BADCTCODESET); + } + + errno = 0; + + CodeSet = strtoul(line, &line, 0); + +/* printf("ulong_max es %lu\n",ULONG_MAX); + printf("CodeSet obtenido de strtoul es %lu\n",CodeSet);*/ + + if(errno == ERANGE && CodeSet == ULONG_MAX) + { + ShowError(MSG_ERR_BADCTCODESET); + } + + CodeSet_checked = 1; + // errno = 0; + } + else if(Strnicmp(line, "language", 8) == 0) + { + char *ptr; + + if(CatLanguage) + { + ShowError(MSG_ERR_DOUBLECTLANGUAGE); + } + line += 8; + OverSpace(&line); + CatLanguage = AddCatalogChunk(strdup("LANG"), line); + + if(LANGToLower) + for(ptr = CatLanguage; *ptr; ptr++) + *ptr = tolower((int)*ptr); + } + else if(Strnicmp(line, "chunk", 5) == 0) + { + char *ID; + + line += 5; + OverSpace(&line); + ID = line; + line += sizeof(ULONG); + OverSpace(&line); + + AddCatalogChunk(ID, AllocString(line)); + } + else if(Strnicmp(line, "rcsid", 5) == 0) + { + if(CatVersionString || CatRcsId) + { + ShowError(MSG_ERR_DOUBLECTVERSION); + } + line += 5; + OverSpace(&line); + CatRcsId = AllocString(line); + } + else if(Strnicmp(line, "name", 5) == 0) + { + if(CatVersionString || CatName) + { + ShowError(MSG_ERR_DOUBLECTVERSION); + } + line += 4; + OverSpace(&line); + CatName = AllocString(line); + } + else + { + ShowWarn(MSG_ERR_UNKNOWNCTCOMMAND); + } + + /* Stop looking for commands */ + + break; + + default: + if(*line == ' ' || *line == '\t') + { + ShowError(MSG_ERR_UNEXPECTEDBLANKS); + OverSpace(&line); + } + idstr = line; + + while(IS_NUMBER_OR_LETTER(*line) || *line == '_') + { + ++line; + } + if(idstr == line) + { + ShowError(MSG_ERR_NOIDENTIFIER); + break; + } + + if((newidstr = malloc(line - idstr + 1)) == NULL) + { + MemError(); + } + + strncpy(newidstr, idstr, line - idstr); + newidstr[line - idstr] = '\0'; + OverSpace(&line); + + if(*line) + { + ShowError(MSG_ERR_EXTRA_CHARACTERS_ID, newidstr); + } + + if((newstr = ReadLine(fp, FALSE)) != NULL) + { + for(cs = FirstCatString; cs != NULL; cs = cs->Next) + { + if(strcmp(cs->ID_Str, newidstr) == 0) + { + break; + } + } + if(cs == NULL) + { + ShowWarn(MSG_ERR_UNKNOWNIDENTIFIER, newidstr); + } + else + { + size_t reallen; + size_t cd_len; + + if(cs->CT_Str) + { + ShowError(MSG_ERR_DOUBLE_IDENTIFIER, cs->ID_Str); + Result = FALSE; + free(cs->CT_Str); + } + cs->CT_Str = AllocString(newstr); + cs->NotInCT = FALSE; + + /* Get string length */ + + reallen = strlen(cs->CT_Str); + cd_len = strlen(cs->CD_Str); + + if(cs->MinLen > 0 && reallen < (size_t)cs->MinLen) + { + ShowWarn(MSG_ERR_STRING_TOO_SHORT, cs->ID_Str); + } + if(cs->MaxLen > 0 && reallen > (size_t)cs->MaxLen) + { + ShowWarn(MSG_ERR_STRING_TOO_LONG, cs->ID_Str); + } + + // check for empty translations + if(cd_len > 0 && reallen == 0) + { + ShowWarn(MSG_ERR_EMPTYTRANSLATION, cs->ID_Str); + } + + /* Check for trailing ellipsis. */ + if(reallen >= 3 && cd_len >= 3) + { + if(strcmp(&cs->CD_Str[cd_len - 3], "...") == 0 && + strcmp(&cs->CT_Str[reallen - 3], "...") != 0) + { + ShowWarn(MSG_ERR_TRAILING_ELLIPSIS, cs->ID_Str); + } + if(strcmp(&cs->CD_Str[cd_len - 3], "...") != 0 && + strcmp(&cs->CT_Str[reallen - 3], "...") == 0) + { + ShowWarn(MSG_ERR_NO_TRAILING_ELLIPSIS, cs->ID_Str); + } + } + + + /* Check for trailing spaces. */ + if(reallen >= 1 && cd_len >= 1) + { + if(strcmp(&cs->CD_Str[cd_len - 1], " ") == 0 && + strcmp(&cs->CT_Str[reallen - 1], " ") != 0) + + { + ShowWarn(MSG_ERR_TRAILING_BLANKS, cs->ID_Str); + } + if(strcmp(&cs->CD_Str[cd_len - 1], " ") != 0 && + strcmp(&cs->CT_Str[reallen - 1], " ") == 0) + + { + ShowWarn(MSG_ERR_NO_TRAILING_BLANKS, cs->ID_Str); + } + } + + /* Check for matching placeholders */ + if(reallen >= 1 && cd_len >= 1) + { + char *cdP = cs->CD_Str; + char *ctP = cs->CT_Str; + + do + { + cdP = strchr(cdP, '%'); + ctP = strchr(ctP, '%'); + + if(cdP == NULL && ctP == NULL) + { + // no more placeholders, bail out + break; + } + else if(cdP != NULL && ctP != NULL) + { + // skip the '%' sign + cdP++; + ctP++; + + // check the placeholder only if the '%' is followed by an + // alpha-numerical character or another percent sign + if(IS_NUMBER_OR_LETTER(*cdP) || *cdP == '%') + { + if(*cdP != *ctP) + { + ShowWarn(MSG_ERR_MISMATCHING_PLACEHOLDERS, cs->ID_Str); + break; + } + // skip the second '%' sign + if(*cdP == '%') + cdP++; + if(*ctP == '%') + ctP++; + } + else if(IS_NUMBER_OR_LETTER(*ctP) || *ctP == '%') + { + // the translation uses a placeholder while the description + // uses none. + ShowWarn(MSG_ERR_EXCESSIVE_PLACEHOLDERS, cs->ID_Str); + break; + } + } + else if(cdP != NULL && ctP == NULL) + { + // skip the '%' sign + cdP++; + + // check if really a placeholder follows or just another percent sign + // the original string is allowed to contain more single percent signs than the translated string + if(IS_NUMBER_OR_LETTER(*cdP) || *cdP == '%') + { + // the description uses at least one more placeholder than the translation + ShowWarn(MSG_ERR_MISSING_PLACEHOLDERS, cs->ID_Str); + } + break; + } + else if(cdP == NULL && ctP != NULL) + { + // skip the '%' sign + ctP++; + + // check if really a placeholder follows or just another percent sign + // the translated string is allowed to contain more single percent signs than the original string + if(IS_NUMBER_OR_LETTER(*ctP) || *ctP == '%') + { + // the translation uses at least one more placeholder than the description + ShowWarn(MSG_ERR_EXCESSIVE_PLACEHOLDERS, cs->ID_Str); + } + break; + } + } + while(TRUE); + } + } + + free(newstr); + } + else + { + ShowWarn(MSG_ERR_MISSINGSTRING); + if(cs) + cs->CT_Str = (char *)""; + } + free(newidstr); + } + free(newline); + // forget the pointers as we just freed them and 'line' must not be freed again after the loop + newline = NULL; + line = NULL; + } + + if(!CodeSet_checked) + { + ShowErrorQuick(MSG_ERR_NOCTCODESET); + } + + if(!(CatVersionString || (CatRcsId && CatName))) + { + ShowErrorQuick(MSG_ERR_NOCTVERSION); + } + + // check if a translation exists for all identifiers + for(cs = FirstCatString; cs != NULL; cs = cs->Next) + { + if(cs->CT_Str == NULL) + { + ShowWarnQuick(MSG_ERR_MISSINGTRANSLATION, cs->ID_Str); + } + } + + if(line != NULL) + free(line); + + fclose(fp); + + if(WarnCTGaps) + { + for(cs = FirstCatString; cs != NULL; cs = cs->Next) + { + if(cs->CT_Str == NULL) + { + ShowWarn(MSG_ERR_CTGAP, cs->ID_Str); + } + } + } + + if(Result) + CT_Scanned = TRUE; + + return(Result); +} + +/// + diff --git a/build/flexcat/scanct.h b/build/flexcat/scanct.h new file mode 100644 index 00000000..63c4968b --- /dev/null +++ b/build/flexcat/scanct.h @@ -0,0 +1,37 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_SCANCT_H +#define FLEXCAT_SCANCT_H + +/* Functions */ +int ScanCTFile ( char *ctfile ); + +/* Variables */ +extern char *CatVersionString; +extern char *CatLanguage; +extern char *CatRcsId; +extern char *CatName; +extern int CodeSet; +extern int CT_Scanned; + +#endif /* FLEXCAT_SCANCT_H */ diff --git a/build/flexcat/scanpo.c b/build/flexcat/scanpo.c new file mode 100644 index 00000000..4880d49f --- /dev/null +++ b/build/flexcat/scanpo.c @@ -0,0 +1,875 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifdef AMIGA + #include /* This is to get locale.library/IsAlpha() */ +#endif + +#include +#include +#include + +#include "flexcat.h" +#include "showfuncs.h" +#include "readprefs.h" +#include "globals.h" +#include "utils.h" +#include "createcat.h" + +extern char *CatVersionString; +extern char *CatLanguage; +extern char *CatRcsId; +extern char *CatName; +extern int CodeSet; +extern int CT_Scanned; + +#define IS_NUMBER_OR_LETTER(c) (((c) >= '0' && (c) <= '9') || \ + ((c) >= 'a' && (c) <= 'z') || \ + ((c) >= 'A' && (c) <= 'Z')) + +#if defined(__amigaos3__) || defined(__MORPHOS__) || defined(WIN32) +char *strptime(const char *string, const char *fmt, struct tm *res); +#endif + +/// ScanCTFile + +/* This function scans a PO-style format catalog description/translation file. + + Inputs: pofile - name of the description/translation file to scan. + Result: TRUE if successful, FALSE otherwise. +*/ +int ScanPOFile(char *pofile) +{ + FILE *fp; + char *newline, *line; + int Result = TRUE; + int CodeSet_checked = FALSE; + int revision_found = FALSE; + int inHeader = TRUE; + int NextID = 0; + const char *PoSrcCharset = "utf-8"; + const char *CatDstCharset = "iso-8859-1"; + char CatVersionDate[255] = ""; + char CatProjectName[255] = ""; + struct CatString *cs = NULL; + struct CatString **csptr = &FirstCatString; + int inMsgID = FALSE; + int inMsgSTR = FALSE; + + ScanFile = pofile; + ScanLine = 0; + if((fp = fopen(pofile, "r")) == NULL) + ShowErrorQuick(MSG_ERR_NOCATALOGTRANSLATION, pofile); + + if(!NoBufferedIO) + setvbuf(fp, NULL, _IOFBF, buffer_size); + + while(!feof(fp) && (line = newline = ReadLine(fp, TRUE)) != NULL) + { + if(inHeader == TRUE) + { + if(*line == '\0') + { + inHeader = FALSE; + + // we found the end of the header so lets check if we have all + // we require to continue + if(CatVersion > 0 && CatVersionDate[0] != '\0' && CatProjectName[0] != '\0' && + CatVersionString == NULL) + { + char buf[255]; + + // warn about missing revision information + if(CatRevision == 0) + ShowWarn(MSG_ERR_NO_CAT_REVISION); + + if(strstr(CatProjectName, ".catalog") != NULL) + snprintf(buf, sizeof(buf), "$VER: %s %d.%d (%s)", CatProjectName, CatVersion, CatRevision, CatVersionDate); + else + snprintf(buf, sizeof(buf), "$VER: %s.catalog %d.%d (%s)", CatProjectName, CatVersion, CatRevision, CatVersionDate); + CatVersionString = AllocString(buf); + } + } + else switch(*line) + { + case '#': + { + // comment lines start with # + // but they may contain some valueable information for catalog + // file creation. So lets parse these lines as well + while(*line == '#' || *line == ' ' || *line == '\t') + ++line; + + if(Strnicmp(line, "version", 7) == 0) + { + line += 8; + OverSpace(&line); + CatVersion = strtol(line, &line, 0); + } + else if(Strnicmp(line, "revision", 8) == 0) + { + line += 9; + OverSpace(&line); + CatRevision = strtol(line, &line, 0); + revision_found = TRUE; + } + else if(revision_found == FALSE && + Strnicmp(line, "$Id: ", 5) == 0) + { + char *p; + + line += 6; + p = line; + + // search second space + p = strchr(p, ' '); + if(p != NULL) + { + p++; + CatRevision = strtol(p, &p, 0); + } + } + else if(revision_found == FALSE && + Strnicmp(line, "$Revision: ", 11) == 0) + { + line += 12; + CatRevision = strtol(line, &line, 0); + } + } + break; + + case '"': + { + if(Strnicmp(line, "\"Language: ", 11) == 0) + { + char *p; + const char *language = NULL; + + if(CatLanguage) + ShowError(MSG_ERR_DOUBLECTLANGUAGE); + + line += 11; + p = strchr(line, '\\'); + if(p != NULL) + *p = '\0'; + + if(Stricmp(line, "bs") == 0) // bosnian + { + language = "bosanski"; + CatDstCharset = "iso-8859-2"; + } + else if(Stricmp(line, "ca") == 0) // catalan + { + language = "català"; + CatDstCharset = "iso-8859-15"; + } + else if(Stricmp(line, "hr") == 0) // croatian + { + language = "hrvatski"; + CatDstCharset = "iso-8859-16"; + } + else if(Stricmp(line, "cs") == 0) // czech + { + language = "czech"; + CatDstCharset = "iso-8859-2"; + } + else if(Stricmp(line, "da") == 0) // danish + { + language = "dansk"; + CatDstCharset = "iso-8859-15"; + } + else if(Stricmp(line, "nl") == 0) // dutch + { + language = "nederlands"; + CatDstCharset = "iso-8859-15"; + } + else if(Stricmp(line, "en_GB") == 0) // english-british + language = "english-british"; + else if(Stricmp(line, "fi") == 0) // finnish + { + language = "suomi"; + CatDstCharset = "iso-8859-15"; + } + else if(Stricmp(line, "fr") == 0) // french + { + language = "français"; + CatDstCharset = "iso-8859-15"; + } + else if(Stricmp(line, "de") == 0) // german + { + language = "deutsch"; + CatDstCharset = "iso-8859-15"; + } + else if(Stricmp(line, "el") == 0) // greek + { + language = "greek"; + CatDstCharset = "iso-8859-7"; + } + else if(Stricmp(line, "hu") == 0) // hungarian + { + language = "magyar"; + CatDstCharset = "iso-8859-16"; + } + else if(Stricmp(line, "it") == 0) // italian + { + language = "italiano"; + CatDstCharset = "iso-8859-15"; + } + else if(Stricmp(line, "ja") == 0) // japanese + { + language = "nihongo"; + CatDstCharset = "euc-jp"; + } + else if(Stricmp(line, "ko") == 0) // korean + { + language = "hangul"; + CatDstCharset = "euc-kr"; + } + else if(Stricmp(line, "no") == 0) // norwegian + { + language = "norsk"; + CatDstCharset = "iso-8859-15"; + } + else if(Stricmp(line, "fa") == 0) // persian + { + language = "farsi"; + CatDstCharset = "utf-8"; + } + else if(Stricmp(line, "pl") == 0) // polish + { + language = "polski"; + CatDstCharset = "iso-8859-2"; + } + else if(Stricmp(line, "pt") == 0) // portuguese + language = "português"; + else if(Stricmp(line, "pt_BR") == 0) // portuguese-brazil + language = "português-brasil"; + else if(Stricmp(line, "ru") == 0) // russian + { + language = "russian"; + #if defined(AMIGA) + CatDstCharset = "Amiga-1251"; + #else + CatDstCharset = "windows-1251"; // iconv doesn't know anything about Amiga-1251 :( + #endif + } + else if(Stricmp(line, "sr") == 0) // serbian + { + language = "srpski"; + CatDstCharset = "iso-8859-16"; + } + else if(Stricmp(line, "sk") == 0) // slovakian + { + language = "slovak"; + CatDstCharset = "iso-8859-2"; + } + else if(Stricmp(line, "sl") == 0) // slovenian + { + language = "slovensko"; + CatDstCharset = "iso-8859-2"; + } + else if(Stricmp(line, "es") == 0) // spanish + { + language = "español"; + CatDstCharset = "iso-8859-15"; + } + else if(Stricmp(line, "sv") == 0) // swedish + { + language = "svenska"; + CatDstCharset = "iso-8859-15"; + } + else if(Stricmp(line, "tr") == 0) // turkish + { + language = "türkçe"; + CatDstCharset = "iso-8859-9"; + } + + if(language != NULL) + CatLanguage = AddCatalogChunk(strdup("LANG"), language); + } + else if(Strnicmp(line, "\"Language-Team: ", 16) == 0) + { + char *p; + + line += 16; + p = strchr(line, '\\'); + if(p != NULL) + *p = '\0'; + + AddCatalogChunk(strdup("AUTH"), line); + } + else if(CodeSet_checked == FALSE && + Strnicmp(line, "\"Content-Type: ", 15) == 0) + { + char *p; + + line += 16; + p = strstr(line, "charset="); + if(p != NULL) + { + char *q; + + p += 8; + + q = strchr(p, '\\'); + if(q != NULL) + *q = '\0'; + + PoSrcCharset = strdup(p); + } + + CodeSet_checked = TRUE; + } + else if(Strnicmp(line, "\"PO-Revision-Date: ", 19) == 0) + { + struct tm tm; + + line += 19; + memset(&tm, 0, sizeof(tm)); + strptime(line, "%Y-%m-%d", &tm); + strftime(CatVersionDate, sizeof(CatVersionDate), "%d.%m.%Y", &tm); + } + else if(Strnicmp(line, "\"Catalog-Name: ", 15) == 0) + { + char *p; + + line += 15; + p = strchr(line, '\\'); + if(p != NULL) + *p = '\0'; + + strcpy(CatProjectName, line); + } + else if(Strnicmp(line, "\"Project-Id-Version: ", 21) == 0 && CatProjectName[0] == '\0') + { + // fall back to the project ID as catalog name if it is not yet defined + char *p; + + line += 21; + p = strchr(line, '\\'); + if(p != NULL) + *p = '\0'; + + strcpy(CatProjectName, line); + } + } + break; + } + } + else + { + // check if we found a line starting with "msgctxt" as that signals us + // a new catalog string should be added + if(Strnicmp(line, "msgctxt \"", 9) == 0) + { + char *idstr; + + // we found a new 'msgctxt' lets clear cs + cs = NULL; + inMsgID = FALSE; + inMsgSTR = FALSE; + + line += 9; + + /* Check for blanks at the start of line. */ + if(*line == ' ' || *line == '\t') + { + ShowError(MSG_ERR_UNEXPECTEDBLANKS); + OverSpace(&line); + } + + idstr = line; + while(IS_NUMBER_OR_LETTER(*line) || *line == '_') + ++line; + + if(idstr == line) + { + ShowError(MSG_ERR_NOIDENTIFIER); + Result = FALSE; + } + else + { + int found; + + if((cs = malloc(sizeof(*cs))) == NULL) + MemError(); + + // search for the next catstring ID in case the ID + // specifier is missing "(//)" in the msgctxt + do + { + struct CatString *scs; + + found = TRUE; + for(scs = FirstCatString; scs != NULL; scs = scs->Next) + { + if(scs->ID == NextID) + { + found = FALSE; + ++NextID; + break; + } + } + } + while(found == FALSE); + + cs->Next = NULL; + cs->ID = NextID; + cs->MinLen = 0; + cs->MaxLen = -1; + cs->CD_Str = (char *)""; + cs->CT_Str = NULL; + cs->NotInCT = TRUE; + cs->POformat = TRUE; + + if((cs->ID_Str = malloc((line - idstr) + 1)) == NULL) + MemError(); + + strncpy(cs->ID_Str, idstr, line - idstr); + cs->ID_Str[line - idstr] = '\0'; + OverSpace(&line); + + /* Check if next char in line is '('? (//) */ + if(*line != '(') + { + ShowError(MSG_ERR_NO_LEADING_BRACKET, cs->ID_Str); + Result = FALSE; + } + else + { + struct CatString *scs; + + ++line; + OverSpace(&line); + + /* Check for default config of line (//) */ + if(*line != '/') + { + if(*line == '+') + NextID = cs->ID = NextID + strtol(line, &line, 0); + else if(*line == '$') + { + line++; + cs->ID = NextID = strtol(line, &line, 16); + } + else + cs->ID = NextID = strtol(line, &line, 0); + + OverSpace(&line); + } + + /* Check for already used identifier. */ + for(scs = FirstCatString; scs != NULL; scs = scs->Next) + { + if(scs->ID == cs->ID) + { + ShowError(MSG_ERR_DOUBLE_ID, cs->ID_Str); + Result = FALSE; + } + if(strcmp(cs->ID_Str, scs->ID_Str) == 0) + { + ShowError(MSG_ERR_DOUBLE_IDENTIFIER, cs->ID_Str); + Result = FALSE; + } + } + + /* Check for min/len values (//) */ + if(*line != '/') + { + ShowWarn(MSG_ERR_NO_MIN_LEN, cs->ID_Str); + Result = FALSE; + } + else + { + ++line; + OverSpace(&line); + if(*line != '/') + { + cs->MinLen = strtol(line, &line, 0); + OverSpace(&line); + } + if(*line != '/') + { + ShowWarn(MSG_ERR_NO_MAX_LEN, cs->ID_Str); + Result = FALSE; + } + else + { + ++line; + OverSpace(&line); + if(*line != ')') + { + cs->MaxLen = strtol(line, &line, 0); + OverSpace(&line); + } + if(*line != ')') + { + ShowError(MSG_ERR_NO_TRAILING_BRACKET, cs->ID_Str); + Result = FALSE; + } + else + { + ++line; + OverSpace(&line); + if(*line && *line != '\"') + ShowError(MSG_ERR_EXTRA_CHARACTERS_ID, cs->ID_Str); + } + } + } + } + + //printf("ID_Str: '%s' (%d)\n", cs->ID_Str, cs->ID); + + cs->Nr = NumStrings; + cs->LenBytes = 0; + *csptr = cs; + csptr = &cs->Next; + ++NumStrings; + } + } + else if(cs != NULL) + { + char *p; + + // if the user want to force a certain output (destination) + // codeset we set it here. + if(DestCodeset[0] != '\0') + CatDstCharset = DestCodeset; + + // Make sure double backslashes end up in a single backslash. + // We catch any double backslash followed by a zero character, + // which covers strings like "\\0" and "\\033" or "\\33" as these are + // common strings in MUI applications. + while((p = strstr(line, "\\\\0")) != NULL || (p = strstr(line, "\\\\33")) != NULL) + memmove(p, p+1, strlen(p)); + + // unquote the string + if(line[strlen(line)-1] == '"') + line[strlen(line)-1] = '\0'; + + if(Strnicmp(line, "msgid \"", 7) == 0) + { + line += 7; + + // if the string starts with we out to remove + // the rest of the string! + if(strncmp(line, "", 7) == 0) + *line = '\0'; + + if(strlen(line) > 0) + { + if((cs->CD_Str = ConvertString(line, PoSrcCharset, CatDstCharset)) == NULL) + ShowWarn(MSG_ERR_CONVERSION_FAILED, cs->ID_Str); + } + else + { + cs->CD_Str = malloc(1); + cs->CD_Str[0] = '\0'; + } + + //printf("CD_Str: '%s' '%s'\n", cs->CD_Str, line); + + inMsgID = TRUE; + inMsgSTR = FALSE; + } + else if(Strnicmp(line, "msgstr \"", 8) == 0) + { + line += 8; + + // don't search for "" here, this will be done later + // during all other checks. If the string would be erased here + // we would be no longer able to tell it apart from really + // missing translations. + if(strlen(line) > 0) + { + if((cs->CT_Str = ConvertString(line, PoSrcCharset, CatDstCharset)) == NULL) + ShowWarn(MSG_ERR_CONVERSION_FAILED, cs->ID_Str); + } + else + { + cs->CT_Str = malloc(1); + cs->CT_Str[0] = '\0'; + } + + cs->NotInCT = FALSE; + + //printf("CT_Str: '%s'\n", cs->CT_Str); + + inMsgSTR = TRUE; + inMsgID = FALSE; + } + else if(*line == '"') // line starts with " + { + line++; + + if(inMsgID == TRUE) + { + char *t; + + if((t = ConvertString(line, PoSrcCharset, CatDstCharset)) == NULL) + ShowWarn(MSG_ERR_CONVERSION_FAILED, cs->ID_Str); + else + cs->CD_Str = AddString(cs->CD_Str, t); + + //printf("CD_Str2: '%s' '%s'\n", cs->CD_Str, line); + + free(t); + } + else if(inMsgSTR == TRUE) + { + char *t; + + if((t = ConvertString(line, PoSrcCharset, CatDstCharset)) == NULL) + ShowWarn(MSG_ERR_CONVERSION_FAILED, cs->ID_Str); + else + cs->CT_Str = AddString(cs->CT_Str, t); + + //printf("CT_Str2: '%s' '%s'\n", cs->CT_Str, line); + + free(t); + } + } + } + } + } + + /* + printf("CatVersion: %d.%d\n", CatVersion, CatRevision); + printf("CatVersionDate: '%s'\n", CatVersionDate); + printf("CatVersionString: '%s'\n", CatVersionString); + printf("CatLanguage: '%s'\n", CatLanguage); + printf("PoSrcCharset: '%s'\n", PoSrcCharset); + printf("CatDstCharset: '%s'\n", CatDstCharset); + */ + + if(!CodeSet_checked) + ShowErrorQuick(MSG_ERR_NOCTCODESET); + + if(!(CatVersionString || (CatRcsId && CatName))) + ShowErrorQuick(MSG_ERR_NOCTVERSION); + + // lets translate CatDstCharset to CodeSet number + if(Stricmp(CatDstCharset, "iso-8859-1") == 0) + CodeSet = 4; + else if(Stricmp(CatDstCharset, "iso-8859-2") == 0) + CodeSet = 5; + else if(Stricmp(CatDstCharset, "iso-8859-7") == 0) + CodeSet = 10; + else if(Stricmp(CatDstCharset, "iso-8859-9") == 0) + CodeSet = 12; + else if(Stricmp(CatDstCharset, "utf-8") == 0 || Stricmp(CatDstCharset, "utf8") == 0) + CodeSet = 106; + else if(Stricmp(CatDstCharset, "iso-8859-15") == 0) + CodeSet = 111; + else if(Stricmp(CatDstCharset, "iso-8859-16") == 0) + CodeSet = 112; + else if(Stricmp(CatDstCharset, "amiga-1251") == 0 || Stricmp(CatDstCharset, "windows-1251") == 0) + CodeSet = 2104; + else + CodeSet = 0; + + // check consistenty of translations found + for(cs = FirstCatString; cs != NULL; cs = cs->Next) + { + if(cs->CT_Str == NULL) + ShowWarnQuick(MSG_ERR_MISSINGTRANSLATION, cs->ID_Str); + else + { + size_t reallen; + size_t reallen_utf8; + size_t cd_len; + + // get string length for both ASCII and UTF8 encoding + // the length check must be done against the UTF8 length, + // which might be less than the ASCII length due to certain + // UTF8 characters which are encoded with up to 3 ASCII + // characters + reallen = strlen(cs->CT_Str); + reallen_utf8 = utf8_strlen(cs->CT_Str); + cd_len = strlen(cs->CD_Str); + + // check for empty translations + if(cd_len > 0) + { + if(reallen == 0) + { + // for .po files empty strings are really missing translations + ShowWarnQuick(MSG_ERR_MISSINGTRANSLATION, cs->ID_Str); + + // now remove the cs from the list + cs->NotInCT = TRUE; + continue; + } + } + + // check for intentionally empty translations + if(strncmp(cs->CT_Str, "", 7) == 0) + cs->CT_Str[0] = '\0'; + + if(cs->MinLen > 0 && reallen_utf8 < (size_t)cs->MinLen) + ShowWarnQuick(MSG_ERR_STRING_TOO_SHORT, cs->ID_Str); + + if(cs->MaxLen > 0 && reallen_utf8 > (size_t)cs->MaxLen) + ShowWarnQuick(MSG_ERR_STRING_TOO_LONG, cs->ID_Str); + + // check for trailing ellipsis + if(reallen >= 3 && cd_len >= 3) + { + if(strcmp(&cs->CD_Str[cd_len - 3], "...") == 0 && + strcmp(&cs->CT_Str[reallen - 3], "...") != 0) + { + ShowWarnQuick(MSG_ERR_TRAILING_ELLIPSIS, cs->ID_Str); + } + + if(strcmp(&cs->CD_Str[cd_len - 3], "...") != 0 && + strcmp(&cs->CT_Str[reallen - 3], "...") == 0) + { + ShowWarnQuick(MSG_ERR_NO_TRAILING_ELLIPSIS, cs->ID_Str); + } + } + + // check for trailing spaces + if(reallen >= 1 && cd_len >= 1) + { + if(strcmp(&cs->CD_Str[cd_len - 1], " ") == 0 && + strcmp(&cs->CT_Str[reallen - 1], " ") != 0) + + { + ShowWarnQuick(MSG_ERR_TRAILING_BLANKS, cs->ID_Str); + } + + if(strcmp(&cs->CD_Str[cd_len - 1], " ") != 0 && + strcmp(&cs->CT_Str[reallen - 1], " ") == 0) + + { + ShowWarnQuick(MSG_ERR_NO_TRAILING_BLANKS, cs->ID_Str); + } + } + + // check for matching placeholders + if(reallen >= 1 && cd_len >= 1) + { + char *cdP = cs->CD_Str; + char *ctP = cs->CT_Str; + + do + { + cdP = strchr(cdP, '%'); + ctP = strchr(ctP, '%'); + + if(cdP == NULL && ctP == NULL) + { + // no more placeholders, bail out + break; + } + else if(cdP != NULL && ctP != NULL) + { + // skip the '%' sign + cdP++; + ctP++; + + // check the placeholder only if the '%' is followed by an + // alpha-numerical character or another percent sign + if(IS_NUMBER_OR_LETTER(*cdP) || *cdP == '%') + { + if(*cdP != *ctP) + { + ShowWarnQuick(MSG_ERR_MISMATCHING_PLACEHOLDERS, cs->ID_Str); + + break; + } + + // skip the second '%' sign + if(*cdP == '%') + cdP++; + if(*ctP == '%') + ctP++; + } + else if(IS_NUMBER_OR_LETTER(*ctP) || *ctP == '%') + { + // the translation uses a placeholder while the description + // uses none. + ShowWarnQuick(MSG_ERR_EXCESSIVE_PLACEHOLDERS, cs->ID_Str); + + break; + } + } + else if(cdP != NULL && ctP == NULL) + { + // skip the '%' sign + cdP++; + + // check if really a placeholder follows or just another percent sign + // the original string is allowed to contain more single percent signs than the translated string + if(IS_NUMBER_OR_LETTER(*cdP) || *cdP == '%') + { + // the description uses at least one more placeholder than the translation + ShowWarnQuick(MSG_ERR_MISSING_PLACEHOLDERS, cs->ID_Str); + } + + break; + } + else if(cdP == NULL && ctP != NULL) + { + // skip the '%' sign + ctP++; + + // check if really a placeholder follows or just another percent sign + // the translated string is allowed to contain more single percent signs than the original string + if(IS_NUMBER_OR_LETTER(*ctP) || *ctP == '%') + { + // the translation uses at least one more placeholder than the description + ShowWarnQuick(MSG_ERR_EXCESSIVE_PLACEHOLDERS, cs->ID_Str); + } + + break; + } + } + while(TRUE); + } + } + } + + if(line != NULL) + free(line); + + fclose(fp); + + if(WarnCTGaps) + { + for(cs = FirstCatString; cs != NULL; cs = cs->Next) + { + if(cs->CT_Str == NULL) + { + ShowWarn(MSG_ERR_CTGAP, cs->ID_Str); + } + } + } + + if(Result) + CT_Scanned = TRUE; + + return(Result); +} + +/// + diff --git a/build/flexcat/scanpo.h b/build/flexcat/scanpo.h new file mode 100644 index 00000000..56b20d5c --- /dev/null +++ b/build/flexcat/scanpo.h @@ -0,0 +1,31 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_SCANPO_H +#define FLEXCAT_SCANPO_H + +/* Functions */ +int ScanPOFile(char *pofile); + +/* Variables */ + +#endif /* FLEXCAT_SCANPO_H */ diff --git a/build/flexcat/showfuncs.c b/build/flexcat/showfuncs.c new file mode 100644 index 00000000..28e157cc --- /dev/null +++ b/build/flexcat/showfuncs.c @@ -0,0 +1,134 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include "flexcat.h" +#include "readprefs.h" +#include "globals.h" +#include "utils.h" + +/// ShowError + +/* This shows an error message and quits. */ + +void ShowError(const char *msg, ...) +{ + va_list args; + char header[256]; + char message[256]; + + snprintf(header, sizeof(header), MSG_ERR_ERROR, ScanFile, ScanLine); + va_start(args, msg); + vsnprintf(message, sizeof(message), msg, args); + va_end(args); + fprintf(stderr, "%s %s\n", header, message); + +#ifdef AMIGA + NumberOfWarnings++; +#endif + + MyExit(10); +} + +/// +/// ShowErrorQuick + +/* Same as ShowError but in this case we omit any line number. */ + +void ShowErrorQuick(const char *msg, ...) +{ + va_list args; + char header[256]; + char message[256]; + + snprintf(header, sizeof(header), MSG_ERR_ERROR_QUICK, ScanFile); + va_start(args, msg); + vsnprintf(message, sizeof(message), msg, args); + va_end(args); + fprintf(stderr, "%s %s\n", header, message); + +#ifdef AMIGA + NumberOfWarnings++; +#endif + + MyExit ( 10 ); +} + +/// +/// MemError + +/* This shows the 'Memory error' message. */ + +void MemError(void) +{ + ShowError(MSG_ERR_NOMEMORY); +} + +/// +/// ShowWarn + +/* This shows a warning. */ + +void ShowWarn(const char *msg, ...) +{ + if(!Quiet) + { + va_list args; + char header[256]; + char message[256]; + + snprintf(header, sizeof(header), MSG_ERR_WARNING, ScanFile, ScanLine); + va_start(args, msg); + vsnprintf(message, sizeof(message), msg, args); + va_end(args); + fprintf(stderr, "%s %s\n", header, message); + } + + NumberOfWarnings++; + GlobalReturnCode = 5; +} + +/// +/// ShowWarnQuick + +/* This shows a warning without line number. */ + +void ShowWarnQuick(const char *msg, ...) +{ + if(!Quiet) + { + va_list args; + char header[256]; + char message[256]; + + snprintf(header, sizeof(header), MSG_ERR_WARNING_QUICK, ScanFile); + va_start(args, msg); + vsnprintf(message, sizeof(message), msg, args); + va_end(args); + fprintf(stderr, "%s %s\n", header, message); + } + + NumberOfWarnings++; + GlobalReturnCode = 5; +} + +/// diff --git a/build/flexcat/showfuncs.h b/build/flexcat/showfuncs.h new file mode 100644 index 00000000..362137cd --- /dev/null +++ b/build/flexcat/showfuncs.h @@ -0,0 +1,33 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_SHOWFUNCS_H +#define FLEXCAT_SHOWFUNCS_H + +/* Functions */ +void ShowError(const char *msg, ...); +void ShowErrorQuick(const char *msg, ...); +void MemError(void); +void ShowWarn(const char *msg, ...); +void ShowWarnQuick(const char *msg, ...); + +#endif /* FLEXCAT_SHOWFUNCS_H */ diff --git a/build/flexcat/strptime.c b/build/flexcat/strptime.c new file mode 100644 index 00000000..8d8e8868 --- /dev/null +++ b/build/flexcat/strptime.c @@ -0,0 +1,314 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include + +/// strptime +// parse a date string produced by strftime() and put the success in a struct tm +enum ScanDateState +{ + SDS_DEFAULT = 0, + SDS_SPECIFIER, + SDS_DONE, + SDS_SECOND, + SDS_MINUTE, + SDS_HOUR, + SDS_DAY_OF_MONTH, + SDS_MONTH, + SDS_YEAR, + SDS_DAY_OF_WEEK, + SDS_DAY_YEAR, + SDS_IS_DST, +}; + +#define FLG_SEC (1<<0) +#define FLG_MIN (1<<1) +#define FLG_HOUR (1<<2) +#define FLG_MDAY (1<<3) +#define FLG_MON (1<<4) +#define FLG_YEAR (1<<5) +#define FLG_WDAY (1<<6) +#define FLG_YDAY (1<<7) +#define FLG_ISDST (1<<8) +#define FLG_4DIGIT_YEAR (1<<9) + +char *strptime(const char *string, const char *fmt, struct tm *res) +{ + int success = 1; + char fc; + char sc; + enum ScanDateState state = SDS_DEFAULT; + int flags = 0; + + // start with the first character in both strings + fc = *fmt++; + sc = *string++; + + while(state != SDS_DONE) + { + if(fc == '\0' && sc == '\0') + state = SDS_DONE; + + switch(state) + { + case SDS_DEFAULT: + { + if(fc == '%') + { + state = SDS_SPECIFIER; + fc = *fmt++; + } + else + { + // the format string seems to be malformed, bail out + state = SDS_DONE; + } + } + break; + + case SDS_SPECIFIER: + { + switch(fc) + { + case 'd': // %d - day number with leading zeros (01-31) + case 'e': // %e - day number with leading spaces ( 1-31) + { + flags |= FLG_MDAY; + state = SDS_DAY_OF_MONTH; + fc = *fmt++; + } + break; + + case 'm': // %m - month number with leading zeros (01-12) + { + flags |= FLG_MON; + state = SDS_MONTH; + fc = *fmt++; + } + break; + + case 'Y': // %Y - year using four digits with leading zeros + { + flags |= FLG_4DIGIT_YEAR; + } + // we fall through here + + case 'y': // %y - year using two digits with leading zeros (00-99) + { + flags |= FLG_YEAR; + state = SDS_YEAR; + fc = *fmt++; + } + break; + + case '-': + { + // ignore any switches between with/without leading zeros/spaces + fc = *fmt++; + } + break; + + default: + { + // unknown specifier, bail out + state = SDS_DONE; + } + break; + } + } + break; + + case SDS_DAY_OF_MONTH: + { + if(sc == fc) + { + // next separator in format string found + state = SDS_DEFAULT; + fc = *fmt++; + sc = *string++; + } + else if(sc >= '0' && sc <= '9') + { + // valid number found, add it to the day of month + res->tm_mday = res->tm_mday * 10 + sc - '0'; + sc = *string++; + } + else + { + // unexpected character, bail out + state = SDS_DONE; + } + } + break; + + case SDS_MONTH: + { + if(sc == fc) + { + // next separator in format string found + state = SDS_DEFAULT; + fc = *fmt++; + sc = *string++; + } + else if(sc >= '0' && sc <= '9') + { + // valid number found, add it to the month + res->tm_mon = res->tm_mon * 10 + sc - '0'; + sc = *string++; + } + else + { + // unexpected character, bail out + state = SDS_DONE; + } + } + break; + + case SDS_YEAR: + { + if(sc == fc) + { + // next separator in format string found + state = SDS_DEFAULT; + fc = *fmt++; + sc = *string++; + } + else if(sc >= '0' && sc <= '9') + { + // valid number found, add it to the year + res->tm_year = res->tm_year * 10 + sc - '0'; + sc = *string++; + } + else + { + // unexpected character, bail out + state = SDS_DONE; + } + } + break; + + default: + // nothing to do + break; + } + } + + // finally check if the calculated values are correct, but only those which + // were specified in the format string + if((flags & FLG_MDAY) || strstr(fmt, "%d") != NULL || strstr(fmt, "%-d") != NULL || strstr(fmt, "%e") != NULL) + { + if(res->tm_mday >= 1 && res->tm_mday <= 31) + { + // nothing to adjust + } + else + { + success = 0; + } + } + if((flags & FLG_MON) || strstr(fmt, "%m") != NULL || strstr(fmt, "%-m") != NULL) + { + if(res->tm_mon >= 1 && res->tm_mon <= 12) + { + // tm_mon counts from 0 to 11 + res->tm_mon--; + } + else + { + success = 0; + } + } + if((flags & FLG_YEAR) || strstr(fmt, "%y") != NULL || strstr(fmt, "%-y") != NULL || strstr(fmt, "%Y") != NULL || strstr(fmt, "%-Y") != NULL) + { + if((flags & FLG_4DIGIT_YEAR) || strstr(fmt, "%Y") != NULL || strstr(fmt, "%-Y") != NULL) + { + if(res->tm_year >= 1900) + { + // tm_year counts the years from 1900 + res->tm_year -= 1900; + } + else + { + // year numbers less than 1900 are not supported + success = 0; + } + } + else + { + // 2 digit year number, must be less than 100 + if(res->tm_year < 100) + { + if(res->tm_year < 40) + { + // tm_year counts the years from 1900 + // if the year number is less than 40 we assume a year between + // 2000 and 2039 instead of between 1900 and 1939 to allow a user + // age of at least ~70 years. + res->tm_year += 100; + } + } + // Although we expect a two digit year number for %y we got one with more digits. + // Better not fail at this even if the entered string is wrong. People tend to + // forget the correct formatting. + else if(res->tm_year >= 1900) + { + // tm_year counts the years from 1900 + res->tm_year -= 1900; + } + else + { + // numbers between 100 and 1899 are definitely not allowed + success = 0; + } + } + } + + // finally check if the day value is correct + if(success == 1 && (flags & FLG_MDAY)) + { + if(res->tm_mon == 1) + { + // February has 29 days at most, but we don't check for leap years here + if(res->tm_mday > 29) + { + success = 0; + } + } + else if(res->tm_mon == 3 || + res->tm_mon == 5 || + res->tm_mon == 8 || + res->tm_mon == 10) + { + // April, June, September and November have 30 days + if(res->tm_mday > 30) + { + success = 0; + } + } + } + + return (char *)string; +} + +/// diff --git a/build/flexcat/swapfuncs.c b/build/flexcat/swapfuncs.c new file mode 100644 index 00000000..a27bfb0b --- /dev/null +++ b/build/flexcat/swapfuncs.c @@ -0,0 +1,75 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "flexcat.h" + +/// Swappers... + +unsigned short (*SwapWord)(unsigned short r) = NULL; +uint32 (*SwapLong)(uint32 r) = NULL; + +unsigned short SwapWord21(unsigned short r) +{ + return (unsigned short)(((r & 0xff00) >> 8) | ((r & 0x00ff) << 8)); +} + +unsigned short SwapWord12(unsigned short r) +{ + return r; +} + +uint32 SwapLong4321(uint32 r) +{ + return (((r & 0xff000000) >> 24) | ((r & 0x00ff0000) >> 8) | ((r & 0x0000ff00) << 8) | ((r & 0x000000ff) << 24)); +} +uint32 SwapLong1234(uint32 r) +{ + return r; +} +/// +/// SwapChoose + +int SwapChoose(void) +{ + unsigned short w; + uint32 d; + + strncpy((char *)&w, "\1\2", 2); + strncpy((char *)&d, "\1\2\3\4", 4); + + if(w == 0x0201) + SwapWord = SwapWord21; + else if(w == 0x0102) + SwapWord = SwapWord12; + else + return 0; + + if(d == 0x04030201) + SwapLong = SwapLong4321; + else if(d == 0x01020304) + SwapLong = SwapLong1234; + else + return 0; + + return 1; +} +/// diff --git a/build/flexcat/swapfuncs.h b/build/flexcat/swapfuncs.h new file mode 100644 index 00000000..95d9e0f0 --- /dev/null +++ b/build/flexcat/swapfuncs.h @@ -0,0 +1,35 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_SWAPFUNCS_H +#define FLEXCAT_SWAPFUNCS_H + +/* Functions */ +extern uint32 ( *SwapLong ) ( uint32 r ); +extern unsigned short ( *SwapWord ) ( unsigned short r ); +unsigned short SwapWord21 ( unsigned short r ); +unsigned short SwapWord12 ( unsigned short r ); +uint32 SwapLong4321 ( uint32 r ); +uint32 SwapLong1234 ( uint32 r ); +int SwapChoose ( void ); + +#endif /* FLEXCAT_SWAPFUNCS_H */ diff --git a/build/flexcat/utils.c b/build/flexcat/utils.c new file mode 100644 index 00000000..483e7d95 --- /dev/null +++ b/build/flexcat/utils.c @@ -0,0 +1,780 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#if defined(AMIGA) + #include +#else + #include + #include +#endif + +#include "flexcat.h" +#include "readprefs.h" +#include "swapfuncs.h" +#include "showfuncs.h" +#include "scancd.h" +#include "scanct.h" +#include "createcat.h" +#include "globals.h" +#include "utils.h" +#include "openlibs.h" +#include "SDI_compiler.h" + +const char VString[] = VERS " [" SYSTEMSHORT "/" CPU "] (" EXE_DATE ")\n" EXE_COPYRIGHT; +const char EString[] = "Contact: http://sf.net/p/flexcat/"; + +/// MyExit + +void MyExit(int Code) +{ +#ifdef AMIGA + if((NumberOfWarnings > 0 || Code != 0) && !NoBeep) + DisplayBeep(NULL); +#endif + CloseFlexCatCatalog(); + CloseLibs(); + exit(Code); +} + +/// + +#ifndef AMIGA + +/* + * This array is designed for mapping upper and lower case letters + * together for a case independent comparison. The mappings are + * based upon ascii character sequences. + */ + +typedef unsigned char uc; +static const unsigned char charmap[] = +{ + (uc)'\000', (uc)'\001', (uc)'\002', (uc)'\003', (uc)'\004', (uc)'\005', (uc)'\006', (uc)'\007', + (uc)'\010', (uc)'\011', (uc)'\012', (uc)'\013', (uc)'\014', (uc)'\015', (uc)'\016', (uc)'\017', + (uc)'\020', (uc)'\021', (uc)'\022', (uc)'\023', (uc)'\024', (uc)'\025', (uc)'\026', (uc)'\027', + (uc)'\030', (uc)'\031', (uc)'\032', (uc)'\033', (uc)'\034', (uc)'\035', (uc)'\036', (uc)'\037', + (uc)'\040', (uc)'\041', (uc)'\042', (uc)'\043', (uc)'\044', (uc)'\045', (uc)'\046', (uc)'\047', + (uc)'\050', (uc)'\051', (uc)'\052', (uc)'\053', (uc)'\054', (uc)'\055', (uc)'\056', (uc)'\057', + (uc)'\060', (uc)'\061', (uc)'\062', (uc)'\063', (uc)'\064', (uc)'\065', (uc)'\066', (uc)'\067', + (uc)'\070', (uc)'\071', (uc)'\072', (uc)'\073', (uc)'\074', (uc)'\075', (uc)'\076', (uc)'\077', + (uc)'\100', (uc)'\141', (uc)'\142', (uc)'\143', (uc)'\144', (uc)'\145', (uc)'\146', (uc)'\147', + (uc)'\150', (uc)'\151', (uc)'\152', (uc)'\153', (uc)'\154', (uc)'\155', (uc)'\156', (uc)'\157', + (uc)'\160', (uc)'\161', (uc)'\162', (uc)'\163', (uc)'\164', (uc)'\165', (uc)'\166', (uc)'\167', + (uc)'\170', (uc)'\171', (uc)'\172', (uc)'\133', (uc)'\134', (uc)'\135', (uc)'\136', (uc)'\137', + (uc)'\140', (uc)'\141', (uc)'\142', (uc)'\143', (uc)'\144', (uc)'\145', (uc)'\146', (uc)'\147', + (uc)'\150', (uc)'\151', (uc)'\152', (uc)'\153', (uc)'\154', (uc)'\155', (uc)'\156', (uc)'\157', + (uc)'\160', (uc)'\161', (uc)'\162', (uc)'\163', (uc)'\164', (uc)'\165', (uc)'\166', (uc)'\167', + (uc)'\170', (uc)'\171', (uc)'\172', (uc)'\173', (uc)'\174', (uc)'\175', (uc)'\176', (uc)'\177', + (uc)'\200', (uc)'\201', (uc)'\202', (uc)'\203', (uc)'\204', (uc)'\205', (uc)'\206', (uc)'\207', + (uc)'\210', (uc)'\211', (uc)'\212', (uc)'\213', (uc)'\214', (uc)'\215', (uc)'\216', (uc)'\217', + (uc)'\220', (uc)'\221', (uc)'\222', (uc)'\223', (uc)'\224', (uc)'\225', (uc)'\226', (uc)'\227', + (uc)'\230', (uc)'\231', (uc)'\232', (uc)'\233', (uc)'\234', (uc)'\235', (uc)'\236', (uc)'\237', + (uc)'\240', (uc)'\241', (uc)'\242', (uc)'\243', (uc)'\244', (uc)'\245', (uc)'\246', (uc)'\247', + (uc)'\250', (uc)'\251', (uc)'\252', (uc)'\253', (uc)'\254', (uc)'\255', (uc)'\256', (uc)'\257', + (uc)'\260', (uc)'\261', (uc)'\262', (uc)'\263', (uc)'\264', (uc)'\265', (uc)'\266', (uc)'\267', + (uc)'\270', (uc)'\271', (uc)'\272', (uc)'\273', (uc)'\274', (uc)'\275', (uc)'\276', (uc)'\277', + (uc)'\300', (uc)'\341', (uc)'\342', (uc)'\343', (uc)'\344', (uc)'\345', (uc)'\346', (uc)'\347', + (uc)'\350', (uc)'\351', (uc)'\352', (uc)'\353', (uc)'\354', (uc)'\355', (uc)'\356', (uc)'\357', + (uc)'\360', (uc)'\361', (uc)'\362', (uc)'\363', (uc)'\364', (uc)'\365', (uc)'\366', (uc)'\367', + (uc)'\370', (uc)'\371', (uc)'\372', (uc)'\333', (uc)'\334', (uc)'\335', (uc)'\336', (uc)'\337', + (uc)'\340', (uc)'\341', (uc)'\342', (uc)'\343', (uc)'\344', (uc)'\345', (uc)'\346', (uc)'\347', + (uc)'\350', (uc)'\351', (uc)'\352', (uc)'\353', (uc)'\354', (uc)'\355', (uc)'\356', (uc)'\357', + (uc)'\360', (uc)'\361', (uc)'\362', (uc)'\363', (uc)'\364', (uc)'\365', (uc)'\366', (uc)'\367', + (uc)'\370', (uc)'\371', (uc)'\372', (uc)'\373', (uc)'\374', (uc)'\375', (uc)'\376', (uc)'\377', +}; + +/// Stricmp + +int Stricmp(const char *str1, const char *str2) +{ + unsigned char u1, u2; + + for(;;) + { + u1 = (unsigned char)*str1++; + u2 = (unsigned char)*str2++; + + if(charmap[u1] != charmap[u2]) + return charmap[u1] - charmap[u2]; + + if(u1 == '\0') + return 0; + } +} + +/// +/// Strnicmp + +int Strnicmp(const char *str1, const char *str2, int len) +{ + unsigned char u1, u2; + + for(; len != 0; --len) + { + u1 = (unsigned char)*str1++; + u2 = (unsigned char)*str2++; + if(charmap[u1] != charmap[u2]) + return charmap[u1] - charmap[u2]; + + if(u1 == '\0') + return 0; + } + + return 0; +} +#endif +/// +/// utf8_strlen + +size_t utf8_strlen(const char *str) +{ + size_t ix = strlen(str); + size_t i, q; + + for(q=0, i=0; i < ix; i++, q++) + { + int c = (unsigned char)str[i]; + + if(c >= 0 && c <= 127) + i += 0; + else if((c & 0xe0) == 0xc0) + i += 1; + else if((c & 0xf0) == 0xe0) + i += 2; + else if((c & 0xf8) == 0xf0) + i += 3; + else + return 0; // invalid utf8 + } + + return q; +} +/// +/// AllocString + +/* This allocates a string */ + +char *AllocString(const char *str) +{ + char *ptr; + + if((ptr = malloc(strlen(str) + 1)) == NULL) + MemError(); + + strcpy(ptr, str); + + return ptr; +} + +/// +/// Add a string to an already allocated one + +char *AddString(char *str, const char *astr) +{ + char *ptr; + + if((ptr = malloc(strlen(str) + strlen(astr) + 1)) == NULL) + MemError(); + + strcpy(ptr, str); + strcat(ptr, astr); + + free(str); + + return ptr; +} + +/// +/// Convert a string from one charset to another + +#ifdef AMIGA +char *ConvertString(char *str, const char *from_charset, const char *to_charset) +{ + char *result = NULL; + BOOL fromIsUTF8 = (Stricmp(from_charset, "UTF-8") == 0 || Stricmp(from_charset, "UTF8") == 0); + BOOL toIsUTF8 = (Stricmp(to_charset, "UTF-8") == 0 || Stricmp(to_charset, "UTF8") == 0); + + if(fromIsUTF8 == TRUE && toIsUTF8 == TRUE) + { + // no need to convert from UTF8 to UTF8 + // just return a plain copy of the string + result = strdup(str); + } + else + { + struct codeset *dstCodeset; + + dstCodeset = CodesetsFind((STRPTR)to_charset, + CSA_FallbackToDefault, FALSE, + TAG_DONE); + if(dstCodeset != NULL) + { + ULONG dstLen = 0; + char *dstText = NULL; + int errPtr = 0; + + if(fromIsUTF8 == TRUE) + { + dstText = CodesetsUTF8ToStr(CSA_Source, str, + CSA_DestCodeset, dstCodeset, + CSA_DestLenPtr, &dstLen, + CSA_ErrPtr, &errPtr, + TAG_DONE); + } + else + { + struct codeset *srcCodeset; + + srcCodeset = CodesetsFind((STRPTR)from_charset, + CSA_FallbackToDefault, FALSE, + TAG_DONE); + + if(srcCodeset != NULL) + { + dstText = CodesetsConvertStr(CSA_Source, str, + CSA_SourceCodeset, srcCodeset, + CSA_DestCodeset, dstCodeset, + CSA_DestLenPtr, &dstLen, + CSA_ErrPtr, &errPtr, + TAG_DONE); + } + else + ShowWarn(MSG_ERR_UNKNOWN_SOURCE_CHARSET, from_charset); + } + + if(dstText != NULL && dstLen != 0 && errPtr == 0) + { + char *buf; + + // copy the converted string into a separately allocated string + if((buf = malloc(dstLen+1)) != NULL) + { + memcpy(buf, dstText, dstLen); + buf[dstLen] = '\0'; + result = buf; + } + + CodesetsFreeA(dstText, NULL); + + if(buf == NULL) + MemError(); + } + else + { + if(errPtr != 0) + ShowWarn(MSG_ERR_INVALID_CHARS_FOUND, errPtr); + + if(dstText == NULL) + MemError(); + } + } + else + ShowWarn(MSG_ERR_UNKNOWN_DESTINATION_CHARSET, to_charset); + } + + return result; +} +#else +char *ConvertString(char *str, const char *from_charset, const char *to_charset) +{ + char *result = NULL; + iconv_t ict; + + if((ict = iconv_open(to_charset, from_charset)) != (iconv_t)-1) + { + size_t inleft = strlen(str); + char *buf; + + if((buf = malloc(inleft+1)) != NULL) + { + size_t outleft = inleft; + char *outbuf = buf; + + if(iconv(ict, &str, &inleft, &outbuf, &outleft) != (size_t)-1) + { + *outbuf = '\0'; + result = buf; + } + else + { + ShowWarn(MSG_ERR_ICONV_FAILED, strerror(errno)); + free(buf); + } + } + else + MemError(); + + iconv_close(ict); + } + else + ShowWarn(MSG_ERR_ICONV_OPEN_FAILED, strerror(errno)); + + return result; +} +#endif + +/// +/// Add catalog chunk + +/* This adds a new catalog chunk to the list of catalog + chunks. */ + +char *AddCatalogChunk(char *ID, const char *string) +{ + struct CatalogChunk *cc, **ccptr; + + if((cc = malloc(sizeof(*cc))) == NULL) + MemError(); + + cc->Next = NULL; + cc->ID = *((ULONG *)ID); + cc->ChunkStr = AllocString(string); + + /* Put the new chunk at the end of the chunk list. */ + + for(ccptr = &FirstChunk; *ccptr != NULL; ccptr = &(*ccptr)->Next) + { + } + *ccptr = cc; + + return cc->ChunkStr; +} + +/// +/// gethex + +/* This translates an hex character. */ + +int gethex(int c) +{ + if(c >= '0' && c <= '9') + return c - '0'; + else if(c >= 'a' && c <= 'f') + return c - 'a' + 10; + else if(c >= 'A' && c <= 'F') + return c - 'A' + 10; + + ShowError(MSG_ERR_EXPECTEDHEX); + + return 0; +} + +/// +/// getoctal + +/* This translates an octal digit. */ + +int getoctal(int c) +{ + if(c >= '0' && c <= '7') + return c - '0'; + + ShowError(MSG_ERR_EXPECTEDOCTAL); + + return 0; +} + +/// +/// ReadLine + +/* Reading a line is somewhat complicated in order to allow lines of any + length. + + Inputs: fp - the file, where the input comes from + AllowComment - TRUE if a leading semicolon should force the + line to be interpreted as a comment */ + +char *ReadLine(FILE *fp, UNUSED int AllowComment) +{ + char *NewLine = NULL; + int c = '\0'; + int Len = 0, LineLen = 0; + int FirstChar = TRUE; + int BackslashSeen = FALSE; + int BackslashSeenOn = 0; /* Position where the last backslash was seen. */ + int CommentLine = FALSE; /* If TRUE, we should ignore any trailing \'s */ + + while(c != EOF) + { + if(Len + 10 > LineLen) + { + NewLine = realloc(NewLine, LineLen + BUFSIZE); + LineLen += BUFSIZE; + } + + c = getc(fp); + + if(FirstChar) + { + if(c == EOF) + { + if(NewLine != NULL) + free(NewLine); + return NULL; + } + + if(c == ';') + { + CommentLine = TRUE; + } + + FirstChar = FALSE; + } + + switch(c) + { + case '\r': + break; + + case '\n': + ++ScanLine; + if(BackslashSeen) + { + NewLine[Len++] = c; + BackslashSeen = FALSE; + break; + } + c = EOF; + + case EOF: + break; + + /* Check for trailing \\ */ + case '\\': + { + if(!CommentLine) + { + if(BackslashSeen) + { + if(BackslashSeenOn ==(Len - 1)) + { + BackslashSeen = FALSE; + NewLine[Len++] = c; + break; + } + } + + BackslashSeen = TRUE; + BackslashSeenOn = Len; + } + + NewLine[Len++] = c; + break; + } + + + default: + BackslashSeen = FALSE; + NewLine[Len++] = c; + } + } + + NewLine[Len] = '\0'; + + return NewLine; + +} + +/// +/// OverSpace + +/* This removes trailing blanks. */ + +void OverSpace(char **strptr) +{ + int c; + + while((c = **strptr) == ' ' || c == '\t') + { + (*strptr)++; + } +} + +/// +/// Expunge + +void Expunge(void) +{ +#ifdef AMIGA + if(DoExpunge) + { + struct Library *localeBase; + + // this may look utterly wrong since we are trying to RemLibrary() a library + // which we just opened. But this is the most convenient way to invoke the + // Expunge() function of locale.library, which will just remove any still + // opened but unused catalog file from memory without removing locale.library + // itself. + if((localeBase = OpenLibrary( "locale.library", 0)) != NULL) + { + RemLibrary(localeBase); + CloseLibrary(localeBase); + } + } +#endif // AMIGA +} + +/// +/// ReadChar + +/* ReadChar scans an input line and translates the backslash characters. + Inputs: char * - a pointer to a string pointer; the latter points + to the next character to be read and points behind + the read bytes after executing ReadChar + dest - a pointer to a buffer, where the read bytes should be + stored + Result: number of bytes that are written to dest (between 0 and 2) */ + +int ReadChar(char **strptr, char *dest) +{ + char c; + int i; + + switch(c = *((*strptr)++)) + { + case '\\': + { + switch(c = tolower((int)*((*strptr)++))) + { + case '\n': + return(0); + break; + + case 'b': + *dest = '\b'; + break; + + case 'c': + *dest = '\233'; + break; + + case 'e': + *dest = '\033'; + break; + + case 'f': + *dest = '\f'; + break; + + case 'g': + *dest = '\007'; + break; + + case 'n': + *dest = '\n'; + break; + + case 'r': + *dest = '\r'; + break; + + case 't': + *dest = '\t'; + break; + + case 'v': + *dest = '\013'; + break; + + case 'x': + { + *dest = gethex((int)**strptr); + (*strptr)++; + c = **strptr; + if((c >= '0' && c <= '9') || + (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F')) + { + *dest =(*dest << 4) + gethex((int)c); + (*strptr)++; + } + } + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + *dest = getoctal((int)c); + + for(i = 0; i < 2; i++) + { + c = **strptr; + if(c >= '0' && c <= '7') + { + *dest =(*dest << 3) + getoctal((int)c); + (*strptr)++; + } + } + } + break; + + case ')': + case '\\': + *(dest++) = '\\'; + *dest = c; + return(2); + break; + + default: + *dest = c; + break; + } + } + break; + + default: + { + *dest = c; + } + break; + } + return(1); +} + +/// +/// AllocFileName + +/* This function creates a copy of a filename, and optionally + removes an ending and pathname components, if desired. + Inputs: filename - the filename to copy + howto - a set of bits + bit 0: 1 = remove ending, 0 = leave it + bit 1: 1 = remove pathname, 0 = leave it + Result: the copy of the filename +*/ + +char *AllocFileName(char *filename, int howto) +{ + char *tempstr, *ptr; + + if((tempstr = strdup(filename)) == NULL) + { + MemError(); + MyExit(10); + } + + /* Remove pathname components, if desired. */ + + if(howto & 2) + { + if((ptr = strchr(tempstr, ':')) != NULL) + { + tempstr = ptr + 1; + } + if((ptr = strrchr(tempstr, '/')) != NULL) + { + tempstr = ptr + 1; + } + } + + /* Remove ending, if desired. */ + + if(howto & 1) + { + if((ptr = strrchr(tempstr, '.')) != NULL) + { + *ptr = '\0'; + } + } + + return(tempstr); +} + +/// +/// AddFileName + +/* This function adds a pathname and a filename to a full + filename. + Inputs: pathname - the leading pathname + filename - the filename + Result: The new filename */ + +char *AddFileName(char *pathname, char *filename) +{ + char *buffer; + +#ifdef AMIGA + int size = strlen(pathname) + strlen(filename) + 2; + + if((buffer = malloc(size)) == NULL) + { + MemError(); + MyExit(10); + } + + strcpy(buffer, pathname); + AddPart((char *)buffer, (char *)filename, size); +#else + if(asprintf(&buffer, "%s/%s", pathname, filename) < 0) + { + MemError(); + MyExit(10); + } +#endif + + return buffer; +} + +/// +/// Usage + +/* The Usage function describes the program's calling syntax. */ + +void Usage(void) +{ + fprintf(stderr, "%s\n", VString); + fprintf(stderr, "%s\n", EString); + fprintf(stderr, + "\n" \ + "%s\n" \ + " FlexCat CDFILE/A,CTFILE,POFILE,CATALOG/K,NEWCTFILE/K,SOURCES/M,\n" \ + " WARNCTGAPS/S,NOOPTIM/S,FILL/S,FLUSH/S,NOBEEP/S,\n" \ + " QUIET/S,NOLANGTOLOWER/S,NOBUFFEREDIO/S,MODIFIED/S,\n" \ + " CODESET/K,COPYMSGNEW/S,OLDMSGNEW/K\n" \ + "\n", MSG_USAGE_HEAD); + fprintf(stderr, "%s\n", MSG_USAGE); + MyExit(5); +} + +/// +/// wbmain + +/* Dice's entry point for workbench programs */ + +#if defined(AMIGA) && defined(_DCC) +void wbmain(struct WBStartup *wbmsg) +{ + fprintf(stderr, "FlexCat can't be run from Workbench!\n\n"); + fprintf(stderr, "Open a shell session and type FlexCat\n"); + fprintf(stderr, "for syntax and more information.\n"); + + exit(5); +} +#endif +/// + diff --git a/build/flexcat/utils.h b/build/flexcat/utils.h new file mode 100644 index 00000000..281c9c70 --- /dev/null +++ b/build/flexcat/utils.h @@ -0,0 +1,61 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef FLEXCAT_UTILS_H +#define FLEXCAT_UTILS_H + +/* Functions */ +void MyExit ( int Code ); +char *AllocString ( const char *str ); +char *AddString ( char *str, const char *addedstr ); +char *ConvertString ( char *str, const char *from_charset, const char *to_charset); +char *AddCatalogChunk ( char *ID, const char *string ); +int gethex ( int c ); +int getoctal ( int c ); +char *ReadLine ( FILE * fp, int AllowComment ); +void OverSpace ( char **strptr ); +void Expunge ( void ); +int ReadChar ( char **strptr, char *dest ); +char *AllocFileName ( char *filename, int howto ); +char *AddFileName ( char *pathname, char *filename ); +void Usage ( void ); + +#if !defined(AMIGA) +int Stricmp ( const char *str1, const char *str2 ); +int Strnicmp ( const char *str1, const char *str2, int len ); +#endif // AMIGA + +size_t utf8_strlen(const char *str); + +#if defined(__amigaos3__) || defined(__MORPHOS__) +char *strptime(const char *string, const char *fmt, struct tm *res); +#endif + +#if defined(__amigaos4__) +#define GETINTERFACE(iface, base) (iface = (APTR)GetInterface((struct Library *)(base), "main", 1L, NULL)) +#define DROPINTERFACE(iface) (DropInterface((struct Interface *)iface), iface = NULL) +#else // __amigaos4__ +#define GETINTERFACE(iface, base) TRUE +#define DROPINTERFACE(iface) ((void)0) +#endif // __amigaos4__ + +#endif /* FLEXCAT_UTILS_H */ diff --git a/build/flexcat/vasprintf.c b/build/flexcat/vasprintf.c new file mode 100644 index 00000000..5b2d635b --- /dev/null +++ b/build/flexcat/vasprintf.c @@ -0,0 +1,57 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include + +#ifndef VA_COPY +#if defined(__MORPHOS__) +#define VA_COPY(dest, src) __va_copy(dest, src) +#elif defined(__AROS__) +#define VA_COPY(dest, src) va_copy(dest, src) +#else +#define VA_COPY(dest, src) (dest) = (src) +#endif +#endif + +int vasprintf(char **ptr, const char * format, va_list ap) +{ + int ret; + va_list ap2; + + *ptr = NULL; + + VA_COPY(ap2, ap); + ret = vsnprintf(NULL, 0, format, ap2); + if(ret <= 0) + return ret; + + *ptr = (char *)malloc(ret+1); + if(*ptr == NULL) + return -1; + + VA_COPY(ap2, ap); + ret = vsnprintf(*ptr, ret+1, format, ap2); + + return ret; +} diff --git a/build/flexcat/vastubs.c b/build/flexcat/vastubs.c new file mode 100644 index 00000000..fc24a93e --- /dev/null +++ b/build/flexcat/vastubs.c @@ -0,0 +1,119 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/* + Stubs for the variable argument functions of the shared libraries used. + Please note that these stubs should only be used if the compiler + suite/SDK doesn't come with own stubs/inline functions. + + Also note that these stubs are only safe on m68k machines as it + requires a linear stack layout! +*/ + +#if !defined(__AROS__) && (defined(__VBCC__) || defined(NO_INLINE_STDARG)) +#if defined(_M68000) || defined(__M68000) || defined(__mc68000) + +#include + +/* FIX V45 breakage... */ +#if INCLUDE_VERSION < 45 +#define MY_CONST_STRPTR CONST_STRPTR +#else +#define MY_CONST_STRPTR CONST STRPTR +#endif + +#include +struct Catalog *OpenCatalog(struct Locale *locale, STRPTR name, Tag tag1, ...) +{ return OpenCatalogA(locale, name, (struct TagItem *)&tag1); } + +#include +struct codeset *CodesetsFind(STRPTR name, Tag tag1, ...) +{ return CodesetsFindA(name, (struct TagItem *)&tag1); } +STRPTR CodesetsConvertStr(Tag tag1, ...) +{ return CodesetsConvertStrA((struct TagItem *)&tag1); } +STRPTR CodesetsUTF8ToStr(Tag tag1, ...) +{ return CodesetsUTF8ToStrA((struct TagItem *)&tag1); } + +#else + #error "VARGS stubs are only save on m68k systems!" +#endif // !defined(__PPC__) + +#elif defined(__AROS__) + +#include +STRPTR *CodesetsSupported(Tag tag1, ...) +{ + AROS_SLOWSTACKTAGS_PRE(tag1) + retval = (IPTR)CodesetsSupportedA((struct TagItem *)AROS_SLOWSTACKTAGS_ARG(tag1)); + AROS_SLOWSTACKTAGS_POST +} + +struct codeset *CodesetsFind(STRPTR name, Tag tag1, ...) +{ + AROS_SLOWSTACKTAGS_PRE(tag1) + retval = (IPTR)CodesetsFindA(name, (struct TagItem *)AROS_SLOWSTACKTAGS_ARG(tag1)); + AROS_SLOWSTACKTAGS_POST +} + +struct codeset *CodesetsFindBest(Tag tag1, ...) +{ + AROS_SLOWSTACKTAGS_PRE(tag1) + retval = (IPTR)CodesetsFindBestA((struct TagItem *)AROS_SLOWSTACKTAGS_ARG(tag1)); + AROS_SLOWSTACKTAGS_POST +} + +STRPTR CodesetsConvertStr(Tag tag1, ...) +{ + AROS_SLOWSTACKTAGS_PRE(tag1) + retval = (IPTR)CodesetsConvertStrA((struct TagItem *)AROS_SLOWSTACKTAGS_ARG(tag1)); + AROS_SLOWSTACKTAGS_POST +} + +struct codesetList *CodesetsListCreate(Tag tag1, ...) +{ + AROS_SLOWSTACKTAGS_PRE(tag1) + retval = (IPTR)CodesetsListCreateA((struct TagItem *)AROS_SLOWSTACKTAGS_ARG(tag1)); + AROS_SLOWSTACKTAGS_POST +} + +BOOL CodesetsListDelete(Tag tag1, ...) +{ + AROS_SLOWSTACKTAGS_PRE(tag1) + retval = (IPTR)CodesetsListDeleteA((struct TagItem *)AROS_SLOWSTACKTAGS_ARG(tag1)); + AROS_SLOWSTACKTAGS_POST +} + +STRPTR CodesetsUTF8ToStr(Tag tag1, ...) +{ + AROS_SLOWSTACKTAGS_PRE(tag1) + retval = (IPTR)CodesetsUTF8ToStrA((struct TagItem *)AROS_SLOWSTACKTAGS_ARG(tag1)); + AROS_SLOWSTACKTAGS_POST +} + +UTF8 *CodesetsUTF8Create(Tag tag1, ...) +{ + AROS_SLOWSTACKTAGS_PRE(tag1) + retval = (IPTR)CodesetsUTF8CreateA((struct TagItem *)AROS_SLOWSTACKTAGS_ARG(tag1)); + AROS_SLOWSTACKTAGS_POST +} + +#endif // defined(__VBCC__) || defined(NO_INLINE_STDARG) diff --git a/build/flexcat/version.h b/build/flexcat/version.h new file mode 100644 index 00000000..ece9d421 --- /dev/null +++ b/build/flexcat/version.h @@ -0,0 +1,89 @@ +/* + * $Id$ + * + * Copyright (C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski + * Copyright (C) 2002-2015 FlexCat Open Source Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef _VERSION_H_ +#define _VERSION_H_ + +// transforms a define into a string +#define STR(x) STR2(x) +#define STR2(x) #x + +// for setting all necessary version information +#define EXE_VERSION 2 +#define EXE_REVISION 17 +#define EXE_DATE "03.04.2015" +#define EXE_COPYRIGHT "Copyright (C) 2002-2015 FlexCat Open Source Team" + +// set the EXE_REV_STRING +#define EXE_REV_STRING STR(EXE_VERSION) "." STR(EXE_REVISION) + +// identify the system we are compiling for +#if defined(__amigaos4__) + #define SYSTEM "AmigaOS4" + #define SYSTEMSHORT "OS4" +#elif defined(__MORPHOS__) + #define SYSTEM "MorphOS" + #define SYSTEMSHORT "MOS" +#elif defined(__AROS__) + #define SYSTEM "AROS" + #define SYSTEMSHORT SYSTEM +#elif defined(__AMIGA__) + #define SYSTEM "AmigaOS3" + #define SYSTEMSHORT "OS3" +#elif defined(__linux__) + #define SYSTEM "Linux" + #define SYSTEMSHORT "linux" +#elif defined(_WIN32) + #define SYSTEM "Windows" + #define SYSTEMSHORT "WIN" +#elif defined(__APPLE__) && defined(__MACH__) + #define SYSTEM "MacOSX" + #define SYSTEMSHORT "OSX" +#else + #warning "Unsupported System - check SYSTEM define" + #define SYSTEM "???" + #define SYSTEMSHORT "???" +#endif + +// identify the CPU model +#if defined(__PPC__) || defined(__powerpc__) + #define CPU "PPC" +#elif defined(_M68060) || defined(__M68060) || defined(__mc68060) + #define CPU "m68060" +#elif defined(_M68040) || defined(__M68040) || defined(__mc68040) + #define CPU "m68040" +#elif defined(_M68030) || defined(__M68030) || defined(__mc68030) + #define CPU "m68030" +#elif defined(_M68020) || defined(__M68020) || defined(__mc68020) + #define CPU "m68k" +#elif defined(_M68000) || defined(__M68000) || defined(__mc68000) + #define CPU "m68000" +#elif defined(__i386__) + #define CPU "x86" +#elif defined(__x86_64__) + #define CPU "x86_64" +#else + #warning "Unsupported CPU model - check CPU define" + #define CPU "???" +#endif + +#endif // _VERSION_H_