From 9b06296eb5cef2e9ee538bee570008eed43eee46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 6 Feb 2021 19:37:28 +0800 Subject: [PATCH] Replaced the messy GNU-styled, multi-lingual documents with a single Markdown README.md. Added the GitHub repository to the document and removed the SourceForge website, my web page, and the SourceForge mailing list from the document. Removed the document license, and my PGP key from the package. Removed the signature file from the repository. Changed the license from GPLv3 to APLv2. Various fixes to avoid JetBrains IDE problem detection. --- AUTHORS | 1 - AUTHORS.zh-cn | 1 - AUTHORS.zh-tw | 1 - Build.PL | 4 +- COPYING | 674 ------------------------------------------ Changes | 62 ++-- INSTALL | 192 ------------ INSTALL.zh-cn | 167 ----------- INSTALL.zh-tw | 167 ----------- LICENSE | 202 +++++++++++++ MANIFEST | 38 --- MANIFEST.SKIP | 14 + META.yml | 13 - Makefile.PL | 6 +- NEWS | 75 ----- README | 61 ---- README.md | 505 ++++++++++++++++++++++++++++++++ README.zh-cn | 55 ---- README.zh-tw | 55 ---- SIGNATURE | 60 ---- THANKS.zh-cn | 5 - THANKS.zh-tw | 5 - TODO | 2 - TODO.zh-cn | 1 - TODO.zh-tw | 1 - UPGRADE | 74 ----- UPGRADE.zh-cn | 64 ---- UPGRADE.zh-tw | 64 ---- fdl.txt | 397 ------------------------- pgpkey.asc | 40 --- reslog | 659 ++++++++++++++++++++--------------------- reslog.en.html | 515 -------------------------------- reslog.zh-cn.html | 521 --------------------------------- reslog.zh-tw.html | 521 --------------------------------- t/00-signature.t | 16 +- t/01-exhaust.t | 179 ++++++------ t/02-several.t | 165 ++++++----- t/03-errors.t | 141 +++++---- t/_helper.pm | 728 +++++++++++++++++++++++----------------------- 39 files changed, 1707 insertions(+), 4744 deletions(-) delete mode 100644 AUTHORS delete mode 100644 AUTHORS.zh-cn delete mode 100644 AUTHORS.zh-tw delete mode 100644 COPYING delete mode 100644 INSTALL delete mode 100644 INSTALL.zh-cn delete mode 100644 INSTALL.zh-tw create mode 100644 LICENSE delete mode 100644 MANIFEST create mode 100644 MANIFEST.SKIP delete mode 100644 META.yml delete mode 100644 NEWS delete mode 100644 README create mode 100644 README.md delete mode 100644 README.zh-cn delete mode 100644 README.zh-tw delete mode 100644 SIGNATURE delete mode 100644 THANKS.zh-cn delete mode 100644 THANKS.zh-tw delete mode 100644 TODO delete mode 100644 TODO.zh-cn delete mode 100644 TODO.zh-tw delete mode 100644 UPGRADE delete mode 100644 UPGRADE.zh-cn delete mode 100644 UPGRADE.zh-tw delete mode 100644 fdl.txt delete mode 100644 pgpkey.asc delete mode 100644 reslog.en.html delete mode 100644 reslog.zh-cn.html delete mode 100644 reslog.zh-tw.html diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index d6c1a2a..0000000 --- a/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -imacat diff --git a/AUTHORS.zh-cn b/AUTHORS.zh-cn deleted file mode 100644 index 2e02909..0000000 --- a/AUTHORS.zh-cn +++ /dev/null @@ -1 +0,0 @@ -依玛猫 diff --git a/AUTHORS.zh-tw b/AUTHORS.zh-tw deleted file mode 100644 index 2ec7e15..0000000 --- a/AUTHORS.zh-tw +++ /dev/null @@ -1 +0,0 @@ -ㄌ嚎窟 diff --git a/Build.PL b/Build.PL index 4416969..89519a3 100755 --- a/Build.PL +++ b/Build.PL @@ -6,7 +6,7 @@ use Config qw(%Config); use Module::Build; # Check if there is any old file -use vars qw(%old_version); +our (%old_version); %old_version = qw(); foreach (qw(/usr/sbin/reslog.pl /usr/sbin/reslog @@ -52,7 +52,7 @@ my $build = Module::Build->new( dist_version_from => "reslog", dist_abstract => "Reverse-resolve IP in Apache log files", dist_author => "imacat ", - license => "gpl", + license => "apache_2_0", sign => 1, script_files => [ "reslog" ], diff --git a/COPYING b/COPYING deleted file mode 100644 index 94a9ed0..0000000 --- a/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. 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 -them 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 prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. 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. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey 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; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If 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 convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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 that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - 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. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -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. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - 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 -state 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 3 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, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program 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, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU 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 Lesser General -Public License instead of this License. But first, please read -. diff --git a/Changes b/Changes index 5160666..f242bd2 100644 --- a/Changes +++ b/Changes @@ -1,23 +1,37 @@ reslog change log +2020-02-06 + 1. Replaced the messy GNU-styled, multi-lingual documents with a + single Markdown README.md. + 2. Added the GitHub repository to the document, and removed the + SourceForge website, my web page, and the SourceForge mailing + list from the document. + 3. Removed the document license, and my PGP key from the package. + Removed the signature file from the repository. + 4. Changed the license from GPLv3 to APLv2. + 5. Various fixes to avoid JetBrains IDE problem detection. + +2020-02-01 + arclog is hosted on GitHub now. + 2008-11-18 - 1. INSTALL and reslog.en.html: Fixed the grammer on + 1. INSTALL and reslog.en.html: Fixed the grammar on installation with the CPAN or CPANPLUS shell, changed "install with the CPAN shell using" and "install with the CPANPLUS shell using" to "install it with the CPAN shell by running" and "install it with the CPANPLUS shell by running". - 2. INSTALL* and ahping.*.html: Changed "Fedora/Red Hat" to + 2. INSTALL* and reslog.*.html: Changed "Fedora/Red Hat" to "Red Hat/Fedora/CentOS". 2008-11-17 - 1. INSTALL and reslog.en.html: Fixed the grammer on required + 1. INSTALL and reslog.en.html: Fixed the grammar on required and optional module installation, changed "install using" and "install this using" to "install it by running". 2008-11-15 1. reslog.*.html: Fixed so that installation from source and - with shells are joint into one sentense. + with shells are joint into one sentence. 2008-11-12 1. INSTALL*, reslog.*.html: Updated information on @@ -102,7 +116,7 @@ reslog change log with $tz + (timegm(localtime)-timelocal(localtime)). This is the easy and right way to do. 4. reslog.zh-tw.html, TODO.zh-tw, TODO.zh-cn: Changed - '羉砰いゅ' to 'タ砰いゅ'. + '绻侀珨涓枃' to '姝i珨涓枃'. 2007-12-02 1. t/02-several.t: Added, to replace the t/04-hybrix.t. @@ -211,11 +225,11 @@ reslog change log static methods now. 2. reslog: Renamed the new_read() method as open_read(), the new_write() method as open_write(), the new_append() method - as open_append(). Replaced the strange architech that start + as open_append(). Replaced the strange architect that start a new instance with $ioclass, with reusing the same $io object. 3. reslog: Renamed the new_read() method as open_read(), the new_write() method as open_write(), the new_append() method - as open_append(). Replaced the strange architech that start + as open_append(). Replaced the strange architect that start a new instance with $ioclass, with reusing the same $io object. 4. reslog: Changed " -- " to " - " in comment. 5. reslog: Changed "Deal the ~ home directories under UNIX" to @@ -288,7 +302,7 @@ reslog change log 2. reslog: new() method of _private::LogFile class now opens the log file in read-only mode when keep all. 2. reslog: check_type() method of _private::LogFile class now returns - the type instead of setting $self->{"type"}, for code readibility. + the type instead of setting $self->{"type"}, for code readability. 2006-06-11 1. reslog: new() method of _private::LogFile class now initialized @@ -297,7 +311,7 @@ reslog change log 2. reslog: Upper-case the error messages in _private::LogFile. 3. reslog: check_io() method of _private::LogFile class now returns the IO object instead of setting $self->{"io"}, for code - readibility. + readability. 4. reslog: Fixed _private::LogFile::STDIN::new() method that we passed an extra empty argument to tempfile(). 5. reslog: Fixed comment, use "handler" instead of "handle". @@ -319,13 +333,13 @@ reslog change log cut-and-paste?) A correct one is supplied. 2005-05-22 version 3.07 - 1. reslog: No more checks on the availablility of STDIN and STDOUT, + 1. reslog: No more checks on the availability of STDIN and STDOUT, and no more dummy replacement created if not. It was originally to solve perl.cpan.testers 202971 when running with CPANPLUS under MSWin32, duplicating closed STDIN causes errors. But I was going - the wrong way. I was testing STDIN/STDOUT/STDRR redirection in + the wrong way. I was testing STDIN/STDOUT/STDERR redirection in shell backticks. Whether CPANPLUS closes STDIN or not should be - irrevelent. It may be a issue of the shell backticks itself. + irrelevant. It may be a issue of the shell backticks itself. Anyhow I rewrote the testing executing method and it is solve. In fact, it's still not working when STDIN and STDOUT is unavailable. But IPC::Open3 won't work on that, too. It should be safe to be @@ -352,9 +366,9 @@ reslog change log to duplicate unopened STDIN crashes directly instead of dies that can be caught by eval(). 2. t/01-plain.t, t/02-gzip.t, t/03-bzip2.t, t/04-hybrix.t: Add - option -d -d -d for more debug information when failures occure. + option -d -d -d for more debug information when failures occur. 2. t/_helper.pm: Prepend the command line to the STDERR result to - ease debuging. + ease debugging. 2005-05-18 Solaris fix. @@ -409,7 +423,7 @@ reslog change log added. Subroutine readfile() is renamed as fread(). Prototype cplist() is corrected as cp(). Subroutine rm() is removed. 6. t/01-plain.t, t/02-gzip2.t, t/03-bzip2.t, t/04-hybrix.t: I joined - subtests together and shrinked the total number of tests. They + subtests together and shrank the total number of tests. They should be one tests anyway. This way I can test more on the result. 7. t/MyHelper.pm: flist() is added so that I can test if the resulted files list is correct. Several subtests on whether a file exists @@ -444,7 +458,7 @@ reslog change log internally, even for anonymous temporary files. This simplified the locking problem. How foreign programs access file handles are not an issue anymore. - 2. Makefile.PL: MY pacakge is added. Makefile target "upgrade" is + 2. Makefile.PL: MY package is added. Makefile target "upgrade" is added to remove the old files. constants() and manifypods() methods are added to alter the default install location. Now we default to install to /sbin directory and as manpage section 8. @@ -540,7 +554,7 @@ reslog change log new I/O handlers. 4. New option --trim-suffix is added to remove certain file name suffix before appending our suffix, so that reslog can line-up - with other log file post-processers. + with other log file post-processors. 5. file utility can be used instead of File::MMagic if that is not available. 6. Term::Size is used to display the progress bar under UNIX. Under @@ -572,7 +586,7 @@ reslog change log 2002-11-13 1. Long statistic lines are split for easy reading. 2. open_src() was rewritten according to open_src() in arclog.pl, in - order to use comression with gzip and bzip2 binary executables. + order to use compression with gzip and bzip2 binary executables. 2002-11-12 1. RELEASE_NOTES was renamed as ChangeLog. @@ -588,8 +602,8 @@ reslog change log 2002-10-28 1. Fixed a bug that $WORKING_RES was not locked when opened. But it is unlocked when closed. On some systems (like Linux) you can - request unlock on a filehandle that is not previous locked, but on - some others (like MSWin32) requesting unlock on a filehande that + request unlock on a file handle that is not previous locked, but on + some others (like MSWin32) requesting unlock on a file handle that is not previous locked will cause error. $WORKING_RES doesn't really need locking at all. It is an anonymous temporary file handle, that can be accessed by this same working process only. @@ -602,7 +616,7 @@ reslog change log 1. File::MMagic and file are now used to check the file type, in addition to the file name suffix, with a more preferred order. 2. check_file_type() was added to check the file types by either - File::MMaagic or file. + File::MMagic or file. 3. check_gzip() was added to check the gzip method to use. 4. check_bzip2() was added to check the bzip2 method to use. @@ -627,11 +641,11 @@ reslog change log 2002-08-31 version 2.1.0dev1 Rewrite after almost 1 year, to be run on the newly-released Perl 5.8.0. - 1. Filehandles are now saved and passed in global named variables. + 1. File handles are now saved and passed in global named variables. This is the way it should be. The old way (initialize the file handles by duplicate the STDIN and assign them) was just not natural. It works in Perl 5.6.1, but not in Perl 5.8.0. The - duplicated filehandles are constants, which cannot be assigned new + duplicated file handles are constants, which cannot be assigned new values. 2. Indents are changed from 1 tab to 4 columns, to accommodate the Perl style guide documented in perlstyle(1). This increases the @@ -663,7 +677,7 @@ reslog change log 1. Chinese and English standard header were added. 2. Getopt::Long was introduced to parse the arguments, in replace of my own argument-parsing routine. - 3. File::Spec::Functions was introduced to handle the pathnames. + 3. File::Spec::Functions was introduced to handle the pathname. 4. Cwd was introduced to obtain the current working directory. 5. autoflush from IO::Handle was introduced, to autoflush STDOUT solely under debugging mode. diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 9a077a4..0000000 --- a/INSTALL +++ /dev/null @@ -1,192 +0,0 @@ -reslog Installation Guide - -* Table of Contents - - * System Requirements - * Installation Instruction - ** Install with ExtUtils::MakeMaker - ** Install with Module::Build - - -* System Requirements - - 1. Perl, version 5.8.0 or above. reslog uses 3-argument open() to -duplicate filehandles, which is only supported since 5.8.0. I have -not successfully port this onto earlier versions yet. Please tell me -if you made it. You can run perl -v to see your current Perl version. -If you do not have Perl, or if you have an older version of Perl, you -can download and install/upgrade it from Perl website. - -http://www.perl.com/ - - If you are using MS-Windows, you can download and install -ActiveState ActivePerl. - -http://www.activestate.com/ - - 2. Required Perl modules: None. - - 3. Optional Perl Modules - - * File::MMagic - - This is used to check the file type. If this is not - available, reslog will look for the file executable instead. - If that is not available, too, reslog will judge the file type - by its name suffix (extension). In that case reslog will fail - when reading from STDIN. - You can download and install File::MMagic from the CPAN archive - http://search.cpan.org/dist/File-MMagic/ , - or install it with the CPAN shell by running "cpan File::MMagic", - or install it with the CPANPLUS shell by running - "cpanp i File::MMagic". - Debian/Ubandu Linux users can install it by running - "apt-get install libfile-mmagic-perl". - Red Hat/Fedora/CentOS Linux users can install it by running - "yum install perl-File-MMagic". - FreeBSD users can install it by running - "ports install p5-File-MMagic". - ActivePerl users can install it by running - "ppm install File::MMagic". - The alternative file.exe for MS-Windows can be obtained from - the GnuWin32 home page: http://gnuwin32.sourceforge.net/. - Be sure to save it as file.exe somewhere in your PATH. - - It is preferred to use File::MMagic. The file executable - seems to make mistakes occationally. - - * Compress::Zlib - - This is used to support read/write of gzip compressed files. - It is only needed when gzip compressed files are encountered. - If it is not available when needed, reslog will try to use the - gzip executable instead. If that is not available, too, reslog - will fail. - You can download and install Compress::Zlib from the CPAN archive - http://search.cpan.org/dist/Compress-Zlib/ , - or install it with the CPAN shell by running "cpan Compress::Zlib", - or install it with the CPANPLUS shell by running - "cpanp i Compress::Zlib". - Debian/Ubandu Linux users can install it by running - "apt-get install libcompress-zlib-perl". - Red Hat/Fedora/CentOS Linux users can install it by running - "yum install perl-Compress-Zlib". - FreeBSD users can install it by running - "ports install p5-Compress-Zlib". - ActivePerl users can install it by running - "ppm install Compress::Zlib". - The alternative gzip.exe for MS-Windows can be obtained from - the gzip home page: http://www.gzip.org/. - Be sure to save it as gzip.exe somewhere in your PATH. - - * Compress::Bzip2, version 2 or above - - This is used to support read/write of bzip2 compressed - files. It is only needed when bzip2 compressed files are - encountered. If it is not available when needed, reslog will - try to use the bzip2 executable instead. If that is not - available, too, reslog will fail. Notice that older versions - before 2 does not work, since file I/O compression were not - implemented yet. - You can download and install Compress::Bzip2 from the CPAN archive - http://search.cpan.org/dist/Compress-Bzip2/ , - or install it with the CPAN shell by running "cpan Compress::Bzip2", - or install it with the CPANPLUS shell by running - "cpanp i Compress::Bzip2". - Debian/Ubandu Linux users can install it by running - "apt-get install libcompress-bzip2-perl". - Red Hat/Fedora/CentOS Linux users can install it by running - "yum install perl-Compress-Bzip2". - FreeBSD users can install it by running - "ports install p5-Compress-Bzip2". - ActivePerl users can install it by running - "ppm install Compress::Bzip2". - The alternative bzip2.exe for MS-Windows can be obtained from - the bzip2 home page: http://www.bzip.org/. - Be sure to save it as bzip2.exe somewhere in your PATH. - - * Term::ReadKey - - This is used to display the progress bar. Without this - reslog will not display the progress bar, but nothing else is - different. The progress bar is a good visual representation of - what reslog is currently doing. - You can download and install Term::ReadKey from the CPAN archive - http://search.cpan.org/dist/TermReadKey/ , - or install it with the CPAN shell by running "cpan Term::ReadKey", - or install it with the CPANPLUS shell by running - "cpanp i Term::ReadKey". - Debian/Ubandu Linux users can install it by running - "apt-get install libterm-readkey-perl". - Red Hat/Fedora/CentOS Linux users can install it by running - "yum install perl-TermReadKey". - FreeBSD users can install it by running - "ports install p5-Term-ReadKey". - ActivePerl users can install it by running - "ppm install Term::ReadKey". - - -* Installation Instruction - - If you are upgrading from reslog 3.10 or earlier, or if you are -upgrading from reslog.pl 3.02 or earlier, please read UPGRADE for some -upgrade instruction. - -** Install with ExtUtils::MakeMaker - - reslog uses standard Perl installation with ExtUtils::MakeMaker. -Follow these steps: - - % perl Makefile.PL - % make - % make test - % make install - - When running make install, make sure you have the priviledge to -write to the installation location. This usually requires the root -priviledge. - - If you are using ActivePerl under MS-Windows, you should use -nmake instead of make. nmake can be obtained from the Microsoft FTP -site. - -ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe - - If you want to install into another location, you can set the -PREFIX. For example, to install into your home when you are not -root: - - % perl Makefile.PL PREFIX=/home/jessica - - Refer to the docuemntation of ExtUtils::MakeMaker for more -installation options (by running perldoc ExtUtils::MakeMaker). - - -** Install with Module::Build - - You can install with Module::Build instead, if you prefer. -Follow these steps: - - % perl Build.PL - % ./Build - % ./Build test - % ./Build install - - When running ./Build install, make sure you have the priviledge to -write to the installation location. This usually requires the root -priviledge. - - If you want to install into another location, you can set the ---prefix. For example, to install into your home when you are not -root: - - % perl Build.PL --prefix=/home/jessica - - Refer to the docuemntation of Module::Build for more -installation options (by running perldoc Module::Build). - - -imacat -2008-11-17 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/INSTALL.zh-cn b/INSTALL.zh-cn deleted file mode 100644 index bcde67f..0000000 --- a/INSTALL.zh-cn +++ /dev/null @@ -1,167 +0,0 @@ -reslog 安装指南 - -◎目录 - - ◎系统需求 - ◎安装指南 - ◎◎以 ExtUtils::MakeMaker 安装 - ◎◎以 Module::Build 安装 - - -◎系统需求 - - 1. Perl 5.8.0 或以上。 reslog 使用三参数的 open() 以复制档案操作, -我还不知道怎么改写到更早的版本上执行。若你可以改写到更早的版本上执行, -请告诉我。你可以输入 perl -v 查询你目前的 Perl 版本。目前大多数的 Unix -系统都有 Perl 。如果你没有 Perl 或需要升级,可以到 Perl 网站下载安装最 -新版 Perl 。 - - http://www.perl.com/ - - 若你用 MS-Windows ,可以下载安装 ActiveState 公司的 ActivePerl 。 - - http://www.activestate.com/ - - 2. 需搭配的 Perl 模组:无。 - - 3. 选配的 Perl 模组: - - * File::MMagic - - 这是检查档案类型用的。若没有安装, reslog 会试著去找 file 程 - 式代替。若还找不到, reslog 会改用档尾(副档名)判断档案类型。这 - 时若从标准输入读档, reslog 会无法判断。 - 你可以由 CPAN 模组库下载安装 File::MMagic : - http://search.cpan.org/dist/File-MMagic/ , - 或用 CPAN Shell 执行 cpan File::MMagic 安装, - 或用 CPANPLUS Shell 执行 cpanp i File::MMagic 安装。 - 若你是 Debian/Ubandu Linux 使用者,可以执行 - apt-get install libfile-mmagic-perl 安装。 - 若你是 Red Hat/Fedora/CentOS Linux 使用者,可以执行 - yum install perl-File-MMagic 安装。 - 若你是 FreeBSD 使用者,可以执行 - ports install p5-File-MMagic 安装。 - 若你是 ActivePerl 使用者,可以执行 - ppm install File::MMagic 安装。 - 若你要在 MS-Windows 下使用 file.exe 程式,可以由 - GnuWin32 网站下载: http://gnuwin32.sourceforge.net/ 。 - 请确认下载后,存档在系统的路径下,档名为 file.exe 。 - - 建议用 File::MMagic 。 file 程式偶尔会误判。 - - * Compress::Zlib - - 这是处理 gzip 压缩档用的,只有处理 gzip 压缩档时才会用到。若 - 要用时没有安装, reslog 会试著改用 gzip 程式代替。若还找不到, - reslog 就无法执行。 - 你可以由 CPAN 模组库下载安装 Compress::Zlib : - http://search.cpan.org/dist/Compress-Zlib/ , - 或用 CPAN Shell 执行 cpan Compress::Zlib 安装, - 或用 CPANPLUS Shell 执行 cpanp i Compress::Zlib 安装。 - 若你是 Debian/Ubandu Linux 使用者,可以执行 - apt-get install libcompress-zlib-perl 安装。 - 若你是 Red Hat/Fedora/CentOS Linux 使用者,可以执行 - yum install perl-Compress-Zlib 安装。 - 若你是 FreeBSD 使用者,可以执行 - ports install p5-Compress-Zlib 安装。 - 若你是 ActivePerl 使用者,可以执行 - ppm install Compress::Zlib 安装。 - 若你要在 MS-Windows 下使用 gzip.exe 程式,可以由 - gzip 网站下载: http://www.gzip.org/ 。 - 请确认下载后,存档在系统的路径下,档名为 gzip.exe 。 - - * Compress::Bzip2 第二版以上 - - 这是支援读写 bzip2 压缩档用的,只有处理 bzip2 压缩档时才会用 - 到。若要用时没有安装, reslog 会试著改用 bzip2 程式代替。若还找 - 不到, reslog 就无法执行。 - 你可以由 CPAN 模组库下载安装 Compress::Bzip2 : - http://search.cpan.org/dist/Compress-Bzip2/ , - 或用 CPAN Shell 执行 cpan Compress::Bzip2 安装, - 或用 CPANPLUS Shell 执行 cpanp i Compress::Bzip2 安装。 - 若你是 Debian/Ubandu Linux 使用者,可以执行 - apt-get install libcompress-bzip2-perl 安装。 - 若你是 Red Hat/Fedora/CentOS Linux 使用者,可以执行 - yum install perl-Compress-Bzip2 安装。 - 若你是 FreeBSD 使用者,可以执行 - ports install p5-Compress-Bzip2 安装。 - 若你是 ActivePerl 使用者,可以执行 - ppm install Compress::Bzip2 安装。 - 若你要在 MS-Windows 下使用 bzip2.exe 程式,可以由 - bzip2 网站下载: http://www.bzip.org/ 。 - 请确认下载后,存档在系统的路径下,档名为 bzip2.exe 。 - - * Term::ReadKey - - 这是显示进度列用的,若没有安装,就不会显示进度列。此外不会有 - 任何问题。进度列可以让你对 reslog 的工作进度一目了然。 - 你可以由 CPAN 模组库下载安装 Term::ReadKey : - http://search.cpan.org/dist/TermReadKey/ , - 或用 CPAN Shell 执行 cpan Term::ReadKey 安装, - 或用 CPANPLUS Shell 执行 cpanp i Term::ReadKey 安装。 - 若你是 Debian/Ubandu Linux 使用者,可以执行 - apt-get install libterm-readkey-perl 安装。 - 若你是 Red Hat/Fedora/CentOS Linux 使用者,可以执行 - yum install perl-TermReadKey 安装。 - 若你是 FreeBSD 使用者,可以执行 - ports install p5-Term-ReadKey 安装。 - 若你是 ActivePerl 使用者,可以执行 - ppm install Term::ReadKey 安装。 - - -◎安装指南 - - 若你是由 reslog 3.10 以前的版本升级,或是由 reslog.pl 3.02 以前的 -版本升级,请参阅 UPGRADE.zh-tw 档的升级说明。 - -◎◎以 ExtUtils::MakeMaker 安装 - - reslog 用 Perl 标准的 ExtUtils::MakeMaker 安装,程序如下: - - % perl Makefile.PL - % make - % make test - % make install - - 在 make install 前,请先确认你有在安装目录存档的权限。通常这时候 -要切换为 root ,才能安装存档。 - - 若你是用 MS-Windows 下的 ActivePerl , make 请改用 nmake 。 nmake -可由微软的 FTP 站下载: - - ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe - - 若要安装到其它地方,请设定好 PREFIX 。例如,一般使用者,要安装在 -自己的目录下时: - - % perl Makefile.PL PREFIX=/home/jessica - - 要知道更多安装选项的细节,请参阅 ExtUtils::MakeMaker 的说明(请执 -行 perldoc ExtUtils::MakeMaker )。 - - -◎◎以 Module::Build 安装 - - 若你喜欢,也可以用 Module::Build 安装,程序如下: - - % perl Build.PL - % ./Build - % ./Build test - % ./Build install - - 在 ./Build install 前,请先确认你有在安装目录存档的权限。通常这时 -候要切换为 root ,才能安装存档。 - - 若要安装到其它地方,请设定好 --prefix 。例如,一般使用者,要安装 -在自己的目录下时: - - % perl Build.PL --prefix=/home/jessica - - 要知道更多安装选项的细节,请参阅 Module::Build 的说明(请执行 -perldoc Module::Build )。 - - -依玛猫 -2008-11-18 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/INSTALL.zh-tw b/INSTALL.zh-tw deleted file mode 100644 index f062017..0000000 --- a/INSTALL.zh-tw +++ /dev/null @@ -1,167 +0,0 @@ -reslog 杆玭 - -》ヘ魁 - - 》╰参惠― - 》杆玭 - 》》 ExtUtils::MakeMaker 杆 - 》》 Module::Build 杆 - - -》╰参惠― - - 1. Perl 5.8.0 ┪ reslog ㄏノ把计 open() 狡籹郎巨 -и临ぃ笵或э糶Νセ磅︽璝﹑э糶Νセ磅︽ -叫禗и﹑块 perl -v 琩高﹑ヘ玡 Perl セヘ玡计 Unix -╰参常Τ Perl 狦﹑⊿Τ Perl ┪惠璶狜 Perl 呼更杆程 -穝 Perl  - - http://www.perl.com/ - - 璝﹑ノ MS-Windows 更杆 ActiveState そ ActivePerl  - - http://www.activestate.com/ - - 2. 惠穎皌 Perl 家舱礚 - - 3. 匡皌 Perl 家舱 - - * File::MMagic - - 硂琌浪琩郎摸ノ璝⊿Τ杆 reslog 穦刚帝т file 祘 - Α蠢璝临тぃ reslog 穦эノ郎Ю捌郎耞郎摸硂 - 璝眖夹非块弄郎 reslog 穦礚猭耞 - ﹑パ CPAN 家舱畐更杆 File::MMagic  - http://search.cpan.org/dist/File-MMagic/  - ┪ノ CPAN Shell 磅︽ cpan File::MMagic 杆 - ┪ノ CPANPLUS Shell 磅︽ cpanp i File::MMagic 杆 - 璝﹑琌 Debian/Ubandu Linux ㄏノ磅︽ - apt-get install libfile-mmagic-perl 杆 - 璝﹑琌 Red Hat/Fedora/CentOS Linux ㄏノ磅︽ - yum install perl-File-MMagic 杆 - 璝﹑琌 FreeBSD ㄏノ磅︽ - ports install p5-File-MMagic 杆 - 璝﹑琌 ActivePerl ㄏノ磅︽ - ppm install File::MMagic 杆 - 璝﹑璶 MS-Windows ㄏノ file.exe 祘Αパ - GnuWin32 呼更 http://gnuwin32.sourceforge.net/  - 叫絋粄更郎╰参隔畖郎 file.exe  - - 某ノ File::MMagic  file 祘Α案焊穦粇 - - * Compress::Zlib - - 硂琌矪瞶 gzip 溃罽郎ノΤ矪瞶 gzip 溃罽郎穦ノ璝 - 璶ノ⊿Τ杆 reslog 穦刚帝эノ gzip 祘Α蠢璝临тぃ - reslog 碞礚猭磅︽ - ﹑パ CPAN 家舱畐更杆 Compress::Zlib  - http://search.cpan.org/dist/Compress-Zlib/  - ┪ノ CPAN Shell 磅︽ cpan Compress::Zlib 杆 - ┪ノ CPANPLUS Shell 磅︽ cpanp i Compress::Zlib 杆 - 璝﹑琌 Debian/Ubandu Linux ㄏノ磅︽ - apt-get install libcompress-zlib-perl 杆 - 璝﹑琌 Red Hat/Fedora/CentOS Linux ㄏノ磅︽ - yum install perl-Compress-Zlib 杆 - 璝﹑琌 FreeBSD ㄏノ磅︽ - ports install p5-Compress-Zlib 杆 - 璝﹑琌 ActivePerl ㄏノ磅︽ - ppm install Compress::Zlib 杆 - 璝﹑璶 MS-Windows ㄏノ gzip.exe 祘Αパ - gzip 呼更 http://www.gzip.org/  - 叫絋粄更郎╰参隔畖郎 gzip.exe  - - * Compress::Bzip2 材 - - 硂琌や穿弄糶 bzip2 溃罽郎ノΤ矪瞶 bzip2 溃罽郎穦ノ - 璝璶ノ⊿Τ杆 reslog 穦刚帝эノ bzip2 祘Α蠢璝临т - ぃ reslog 碞礚猭磅︽ - ﹑パ CPAN 家舱畐更杆 Compress::Bzip2  - http://search.cpan.org/dist/Compress-Bzip2/  - ┪ノ CPAN Shell 磅︽ cpan Compress::Bzip2 杆 - ┪ノ CPANPLUS Shell 磅︽ cpanp i Compress::Bzip2 杆 - 璝﹑琌 Debian/Ubandu Linux ㄏノ磅︽ - apt-get install libcompress-bzip2-perl 杆 - 璝﹑琌 Red Hat/Fedora/CentOS Linux ㄏノ磅︽ - yum install perl-Compress-Bzip2 杆 - 璝﹑琌 FreeBSD ㄏノ磅︽ - ports install p5-Compress-Bzip2 杆 - 璝﹑琌 ActivePerl ㄏノ磅︽ - ppm install Compress::Bzip2 杆 - 璝﹑璶 MS-Windows ㄏノ bzip2.exe 祘Αパ - bzip2 呼更 http://www.bzip.org/  - 叫絋粄更郎╰参隔畖郎 bzip2.exe  - - * Term::ReadKey - - 硂琌陪ボ秈ノ璝⊿Τ杆碞ぃ穦陪ボ秈ぃ穦Τ - ヴ拜肈秈琵﹑癸 reslog 秈ヘ罙礛 - ﹑パ CPAN 家舱畐更杆 Term::ReadKey  - http://search.cpan.org/dist/TermReadKey/  - ┪ノ CPAN Shell 磅︽ cpan Term::ReadKey 杆 - ┪ノ CPANPLUS Shell 磅︽ cpanp i Term::ReadKey 杆 - 璝﹑琌 Debian/Ubandu Linux ㄏノ磅︽ - apt-get install libterm-readkey-perl 杆 - 璝﹑琌 Red Hat/Fedora/CentOS Linux ㄏノ磅︽ - yum install perl-TermReadKey 杆 - 璝﹑琌 FreeBSD ㄏノ磅︽ - ports install p5-Term-ReadKey 杆 - 璝﹑琌 ActivePerl ㄏノ磅︽ - ppm install Term::ReadKey 杆 - - -》杆玭 - - 璝﹑琌パ reslog 3.10 玡セ狜┪琌パ reslog.pl 3.02 玡 -セ狜叫把綷 UPGRADE.zh-tw 郎狜弧 - -》》 ExtUtils::MakeMaker 杆 - - reslog ノ Perl 夹非 ExtUtils::MakeMaker 杆祘 - - % perl Makefile.PL - % make - % make test - % make install - -  make install 玡叫絋粄﹑Τ杆ヘ魁郎舦硄盽硂 -璶ち传 root 杆郎 - - 璝﹑琌ノ MS-Windows  ActivePerl  make 叫эノ nmake  nmake -パ稬硁 FTP 更 - - ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe - - 璝璶杆ㄤウよ叫砞﹚ PREFIX ㄒㄏノ璶杆 -ヘ魁 - - % perl Makefile.PL PREFIX=/home/jessica - - 璶笵杆匡兜灿竊叫把綷 ExtUtils::MakeMaker 弧叫磅 -︽ perldoc ExtUtils::MakeMaker  - - -》》 Module::Build 杆 - - 璝﹑尺舧ノ Module::Build 杆祘 - - % perl Build.PL - % ./Build - % ./Build test - % ./Build install - -  ./Build install 玡叫絋粄﹑Τ杆ヘ魁郎舦硄盽硂 -璶ち传 root 杆郎 - - 璝璶杆ㄤウよ叫砞﹚ --prefix ㄒㄏノ璶杆 -ヘ魁 - - % perl Build.PL --prefix=/home/jessica - - 璶笵杆匡兜灿竊叫把綷 Module::Build 弧叫磅︽ -perldoc Module::Build  - - -ㄌ嚎窟 -2008-11-18 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/MANIFEST b/MANIFEST deleted file mode 100644 index 51cf8a2..0000000 --- a/MANIFEST +++ /dev/null @@ -1,38 +0,0 @@ -AUTHORS -AUTHORS.zh-cn -AUTHORS.zh-tw -Build.PL -Changes -COPYING -fdl.txt -INSTALL -INSTALL.zh-cn -INSTALL.zh-tw -Makefile.PL -MANIFEST This list of files -META.yml -NEWS -pgpkey.asc -README -README.zh-cn -README.zh-tw -reslog -reslog.en.html -reslog.zh-cn.html -reslog.zh-tw.html -SIGNATURE -t/00-signature.t -t/01-exhaust.t -t/02-several.t -t/03-errors.t -t/99-pod.t -t/_helper.pm -THANKS -THANKS.zh-cn -THANKS.zh-tw -TODO -TODO.zh-cn -TODO.zh-tw -UPGRADE -UPGRADE.zh-cn -UPGRADE.zh-tw diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..4b50038 --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1,14 @@ +^blib/ +^Makefile$ +^Build$ +^_build/ +^MANIFEST\.bak$ +^MYMETA\.yml$ +^MYMETA\.json$ +^SIGNATURE$ +^pm_to_blib$ +^\.git/ +^\.gitignore$ +^\.idea/ +^excludes/ +^t/logs.*/ diff --git a/META.yml b/META.yml deleted file mode 100644 index 51e5d55..0000000 --- a/META.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- #YAML:1.0 -name: reslog -version: 3.16 -abstract: Reverse-resolve IP in Apache log files -license: gpl -author: - - imacat -generated_by: ExtUtils::MakeMaker version 6.38 -distribution_type: module -requires: -meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.3.html - version: 1.3 diff --git a/Makefile.PL b/Makefile.PL index a3ca196..a97d33d 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -7,7 +7,7 @@ use Config qw(%Config); use ExtUtils::MakeMaker; # Check if there is any old file -use vars qw(%old_version); +our (%old_version); %old_version = qw(); foreach (qw(/usr/sbin/reslog.pl /usr/sbin/reslog @@ -49,7 +49,7 @@ EOT } # Optional prerequisite modules -use vars qw(%OPT_PREREQ); +our (%OPT_PREREQ); %OPT_PREREQ = ( "File::MMagic" => 0, "Compress::Zlib" => 0, @@ -72,7 +72,7 @@ WriteMakefile( VERSION_FROM => "reslog", ABSTRACT => "Reverse-resolve IP in Apache log files", AUTHOR => "imacat ", - LICENSE => "gpl", + LICENSE => "apache_2_0", PREREQ_PM => { }, SIGN => 1, diff --git a/NEWS b/NEWS deleted file mode 100644 index 38e5d09..0000000 --- a/NEWS +++ /dev/null @@ -1,75 +0,0 @@ -New in 3.16: -* Fixed a bug with empty files created with Compress::Bzip2. - -New in 3.15: -* Fixed the minimal required Perl version in the Makefile.PL - installation. - -New in 3.14: -* Documentation fixes. -* Test suite fixes. - -New in 3.13: -* Many code enhancements, bug fixes, test suite enhancements and documentation fixes. Download reslog version 3.13. - -New in 3.12: -* Fixed the error when there is no IP to be resolved. - -New in 3.11: -* Fixed the problem with non-threaded Perl. -* Fixed the bug checking STDIN file type with the file program. -* Moved files back to the Perl default installation directories. -* Added support for installation with Module::Build. - -New in 3.10: -* Documentation fixes. - -New in 3.09: -* License updated to GPLv3 -* Options can now be specified as "-ddd" instead of "-d -d -d", - with "bundling" used in Geoip::Long. -* Various fixes. - -New in 3.08: -* Documentation fixes. - -New in 3.07: -* Now reslog works on Linux, MS-Windows, Cygwin, Solaris, FreeBSD - and MacOSX Darwin. - -New in 3.06: -* Test suite fixes. - -New in 3.05: -* Fixed a bug that unavailable STDIN may cause error. - -New in 3.04: -* Fixed a typo when loading File::MMagic. - -New in 3.03: -* Default installation directory moved back to /sbin. Added - "make upgrade" to remove files from the old versions. -* Fixed errors with flock() locking. - -New in 3.02: -* Run on MS-Windows and Cygwin. -* Various fixes. - -New in 3.01: -* Fixed a serious bug that --suffix and --trim-suffix was obtaining - wrong value. - -New in 3.00: -* ithreads Threading support is added so that it is really fast now. -* bzip2 compression is supported. -* Compressing and decompressing using gzip and bzip2 executables - without installing Compress::Zlib and Compress::Bzip2 is now - possible, although discouraged. -* Certain file name suffix can be removed before outputing the result - file, so that it can be line-up with other log file filters. - -New in 2.1.0dev2: -* Documentation fixes. - -New in 2.1.0dev1: -* Fixed the problem that it wouldn't run with Perl 5.8.0. diff --git a/README b/README deleted file mode 100644 index 4e9054e..0000000 --- a/README +++ /dev/null @@ -1,61 +0,0 @@ -reslog - Reverse-resolve IP in Apache log files - - Copyright (c) 2000-2007 imacat. - - 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 3 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, see . - - reslog reverse-resolves IP in the Apache log files. These log files can -then be analyzed by another program, like Analog. You can think of it as a -replacement of Apache HostNameLookups directive, in the sense that it resolves -the client IP altogether once a day. - - -* Documentation - - Type "perldoc reslog" to read the reslog manual. - - -* Installation - - Read INSTALL for instructions on how to install reslog. - - -* News, Changes and Updates - - Refer to the Changes for changes, bug fixes, updates, new functions, etc. - - -* Support - - reslog's website is at http://reslog.sourceforge.net/. Visit the website -for the current information of reslog. - - reslog has a mailing list reslog-users@lists.sourceforge.net. If you have -any question, comment, bug report, patch, please send it to the mailing list. -Join the list at https://lists.sourceforge.net/lists/listinfo/reslog-users . -Do not send mails directly to me unless you have private business with me. -The mailing list has an archive. People having the same trouble as you may -search the archive, find the answer and save a lot of time. - - -* License - - This program is distributed under GNU Gneral Pulbic License (GPL). Please -refer to the COPYING file for the copyright and the license of this program. - - -imacat ^_*' -2007-11-26 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..5fe1546 --- /dev/null +++ b/README.md @@ -0,0 +1,505 @@ +`reslog` - Reverse-resolve IP in Apache log files +=============================================== + + +Description +----------- + +`reslog` reverse-resolves IP in the [Apache] log files. These log +files can then be analyzed by another program, like [Analog]. You can +think of it as a replacement of Apache `HostNameLookups` directive, in +the sense that it batch resolves the client IP once a day. + +[Apache]: https://httpd.apache.org +[Analog]: https://www.c-amie.co.uk/software/analog + + +Caution +------- + +* *Resolving takes long time*. This is mainly caused by the look up: + Network packets may be filtered by firewalls; DNS servers may not be + correctly configured; may not be up working; may sit in slow network + sections; may be old slow machines; may have traffic jam鈥 etc. All + these problems are beyond our control. + +* If it stops in the middle of its execution, as when the user hits a + `Ctrl-Break`, it may leave a temporary working file. The next time + it runs, it stops when it sees that temporary working file at the + first sight. Please process that file first. You can resolve it + again, just like an ordinary log file. + +* `reslog` needs temporary working space. Disk space is cheaper and + is more available than memory. However, this means that it needs + free temporary disk space about 2 times of the size of the + uncompressed source log file (10 times if using memory). Please + make sure you have that much free space. + +* `reslog` does not support IPv6 yet. + +* I suggest that you install [File::MMagic] instead of counting on the + `file` executable. The internal magic file of File::MMagic works + better than the `file` executable. `reslog` treats everything not + gzip nor bzip2 compressed as plain text. When a compressed log file + is wrongly recognized as an image, `reslog` treats it as plain text, + reads directly from it, and fails. This does not hurt the source + log files, but is still annoying. + +[File::MMagic]: https://metacpan.org/release/File-MMagic + + +System Requirement +------------------ + +1. Perl, version 5.8.0 or above. `reslog` uses 3-argument open() to + duplicate file handles, which is only supported since 5.8.0. I + have not successfully port this onto earlier versions yet. Please + tell me if you made it. You can run `perl -v` to see your current + Perl version. If you do not have Perl, or if you have an older + version of Perl, you can download and install/upgrade it from the + [Perl website]. If you are using MS-Windows, you can download and + install [ActiveState ActivePerl]. + +2. Required Perl modules: None. + +3. Optional Perl modules: + + * [File::MMagic] + + This is used to check the file type. If this is not available, + `reslog` tries the `file` executable instead. If that is not + available, too, `reslog` judges the file type by its name suffix + (extension). In that case `reslog` fails when reading from + `STDIN`. You can download and install File::MMagic from the CPAN + archive, or install it with the CPAN shell: + + cpan File::MMagic + + or with the CPANPLUS shell: + + cpanp i File::MMagic + + For Debian/Ubuntu: + + sudo apt install libfile-mmagic-perl + + For Red Hat/Fedora/CentOS: + + sudo yum install perl-File-MMagic + + For FreeBSD: + + ports install p5-File-MMagic + + For ActivePerl: + + ppm install File-MMagic + + The alternative `file.exe` for MS-Windows can be obtained from + the [GnuWin32] home page. Be sure to save it as `file.exe` + somewhere in your `PATH`. + + * [Compress::Zlib] + + This is used to support reading/writing the gzip compressed + files. It is only needed when gzip compressed files are + encountered. If it is not available, `reslog` tries the `gzip` + executable instead. If that is not available, too, `reslog` + fails. You can download and install Compress::Zlib from the CPAN + archive, or install it with the CPAN shell: + + cpan Compress::Zlib + + or with the CPANPLUS shell: + + cpanp i Compress::Zlib + + For Debian/Ubuntu: + + sudo apt install libcompress-zlib-perl + + For Red Hat/Fedora/CentOS: + + sudo yum install perl-Compress-Zlib + + For FreeBSD: + + ports install p5-Compress-Zlib + + For ActivePerl: + + ppm install Compress-Zlib + + The alternative `gzip.exe` for MS-Windows can be obtained from + [the gzip website]. Be sure to save it as `gzip.exe` somewhere + in your `PATH`. + + * [Compress::Bzip2] version 2 or above. + + This is used to support reading/writing the bzip2 compressed + files. It is only needed when bzip2 compressed files are + encountered. If it is not available, `reslog` tries the `bzip2` + executable instead. If that is not available, too, `reslog` + fails. Notice that older versions before 2 does not work, since + the file I/O compression was not implemented yet. You can + download and install Compress::Bzip2 from the CPAN archive, or + install it with the CPAN shell: + + cpan Compress::Bzip2 + + or with the CPANPLUS shell: + + cpanp i Compress::Bzip2 + + For Debian/Ubuntu: + + sudo apt install libcompress-bzip2-perl + + For Red Hat/Fedora/CentOS: + + sudo yum install perl-Compress-Bzip2 + + For FreeBSD: + + ports install p5-Compress-Bzip2 + + For ActivePerl: + + ppm install Compress-Bzip2 + + The alternative `bzip2.exe` for MS-Windows can be obtained from + [the bzip2 website]. Be sure to save it as `bzip2.exe` somewhere + in your `PATH`. + + * [Term::ReadKey] + + This is used to display the progress bar. The progress bar is a + good visual feedback of what `reslog` is currently doing, but + `reslog` is safe without it. You can download and install + Term::ReadKey from the CPAN archive, or install it with the + CPAN shell: + + cpan Term::ReadKey + + or with the CPANPLUS shell: + + cpanp i Term::ReadKey + + For Debian/Ubuntu: + + sudo apt install libterm-readkey-perl + + For Red Hat/Fedora/CentOS: + + sudo yum install perl-TermReadKey + + For FreeBSD: + + ports install p5-Term-ReadKey + + For ActivePerl: + + ppm install TermReadKey + +[Perl website]: https://www.perl.org +[ActiveState ActivePerl]: https://www.activestate.com +[File::MMagic]: https://metacpan.org/release/File-MMagic +[GnuWin32]: http://gnuwin32.sourceforge.net +[Compress::Zlib]: https://metacpan.org/release/Compress-Zlib +[the gzip website]: https://www.gzip.org +[Compress::Bzip2]: https://metacpan.org/release/Compress-Bzip2 +[the bzip2 website]: http://www.bzip.org +[Term::ReadKey]: https://metacpan.org/release/TermReadKey + + +Download +-------- + +`reslog` is hosted is on鈥 + +* [reslog project on GitHub] + +* [reslog project on SourceForge] + +You can always download the newest version of `reslog` from鈥 + +* [reslog download on SourceForge] + +* [Tavern IMACAT鈥檚 FTP directory] + +imacat鈥檚 PGP public key is at鈥 + +* [imacat鈥檚 PGP key at Tavern IMACAT鈥檚] + +[reslog project on GitHub]: https://github.com/imacat/reslog +[reslog project on SourceForge]: https://sf.net/p/reslog +[reslog download on SourceForge]: https://sourceforge.net/projects/reslog/files +[Tavern IMACAT鈥檚 FTP directory]: https://ftp.imacat.idv.tw/pub/reslog/ +[imacat鈥檚 PGP key at Tavern IMACAT鈥檚]: https://www.imacat.idv.tw/me/pgpkey.asc + + +Install +------- + +If you are upgrading from `reslog` 3.10 or earlier, or if you are +upgrading from `reslog.pl` 3.02 or earlier, please read the upgrade +instruction later in this document. + +### Install with [ExtUtils::MakeMaker] + +`reslog` uses standard Perl installation with ExtUtils::MakeMaker. +Follow these steps: + + % perl Makefile.PL + % make + % make test + % make install + +When running `make install`, make sure you have the privilege to +write to the installation location. This usually requires the `root` +privilege. + +If you are using ActivePerl under MS-Windows, you should use `nmake` +instead of `make`. [nmake can be obtained from the Microsoft FTP site.] + +If you want to install into another location, you can set the +`PREFIX`. For example, to install into your home when you are not +`root`: + + % perl Makefile.PL PREFIX=/home/jessica + +Refer to the documentation of ExtUtils::MakeMaker for more +installation options (by running `perldoc ExtUtils::MakeMaker`). + +### Install with [Module::Build] + +You can install with Module::Build instead, if you prefer. Follow +these steps: + + % perl Build.PL + % ./Build + % ./Build test + % ./Build install + +When running `./Build install`, make sure you have the privilege to +write to the installation location. This usually requires the `root` +privilege. + +If you want to install into another location, you can set the +`--prefix`. For example, to install into your home when you are not +`root`: + + % perl Build.PL --prefix=/home/jessica + +Refer to the documentation of Module::Build for more installation +options (by running `perldoc Module::Build`). + +[ExtUtils::MakeMaker]: https://metacpan.org/release/ExtUtils-MakeMaker +[nmake can be obtained from the Microsoft FTP site.]: ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe +[Module::Build]: https://metacpan.org/release/Module-Build + + +Upgrade Instruction +------------------- + +Here are a few hints for people upgrading from 3.10 or earlier: + +### The Default Installation Location Is at `/usr/bin` + +Also, the man page is at `/usr/share/man/man1/reslog.1`. This is to +follow Perl鈥檚 standard convention, and to avoid breaking +ExtUtils::MakeMaker with future versions. + +When you run `perl Makefile.PL` or `perl Build.PL`, it hints a +list of existing old files to be removed. Please delete them +manually. + +If you saved them in other places, you have to delete them yourself. + +Also, if you have any scripts or cron jobs that are running `reslog`, +remember to modify your script for the new `reslog` location. Of +course, you can copy `reslog` to the original location. It still +works. + + +Here are a few hints for people upgrading from 3.02 or earlier: + +### The Script Name is Changed from `reslog.pl` to `reslog` + +This is obvious. If you have any scripts or cron jobs that are +running `reslog`, remember to modify your script for the new name. +Of course, you can rename `reslog` to `reslog.pl`. It still works. + +The reason I changed the script and project name is that: A dot `.` +in the project name is not valid everywhere. At least SourceForge +don鈥檛 accept it. Besides, `reslog` is enough for a script name under +UNIX. The `.pl` file name suffix/extension may be convenient on +MS-Windows, but MS-Windows users won鈥檛 run it with explorer file name +association anyway, and there is a `pl2bat` to convert `reslog` to +`reslog.bat`, which would make more sense. The only disadvantage is +that I was using `UltraEdit`, which depends on the file name extension +for the syntax highlighting rules. I can manually set it anyway. I鈥檓 +using `gedit` on Linux now. This is not a problem anymore. + + +### You Need Perl 5.8.0 or Above + +`reslog` now has threading to speed up resolving, which requires +Perl鈥檚 `ithreads` threading module support that鈥檚 only available since +5.8.0. You can still disable threading if it causes troubles to you, +but the code itself need it. If you are using a Perl before 5.8.0, +please upgrade it. You can run `perl -v` to see your current Perl +version. + + +### The Default Keep Mode is Now `delete` + +The documentation said the default keep mode is `delete`, but `reslog` +actually did a `restart`. :p This is fixed. If you are running with +the default keep mode, remember to fix it. + + +### The Argument of `--keep` and `--override` Options Are Required Now + +Support for omitting the `--keep` or `--override` arguments are +removed. This helps to avoid confusion for the log file name and the +option arguments. + + +### Specifying One `STDIN` No Longer Trigger Everything to `STDOUT` + +When resolving multiple files, `STDIN` can output to `STDOUT` now, +with other files output to where they should be. Specifying one +`STDIN` no longer writes everything to `STDOUT`. If you want to write +everything to `STDOUT`, be sure to add the `--stdout` option. + + +Options +------- + + ./reslog [options] [logfile鈥 + ./reslog [-h|-v] + +* `logfile` + + The log file to be resolved. You can specify multiple log files. + If not specified, it reads from `STDIN` and outputs to `STDOUT`. + You can also specify `-` to read from `STDIN`. Result of `STDIN` + goes to `STDOUT`. `gzip` or `bzip2` compressed files are supported. + +* `-k`, `--keep mode` + + What to keep in the source file. The following modes are supported: + + * `a`, `all` + + Keep the source file after records are archived. + + * `r`, `restart` + + Restart the source file after records are resolved. + + * `d`, `delete` + + Delete the source file after records are resolved. This is the + default. + +* `-o`, `--override mode` + + What to do with the existing resolved files. The following modes + are supported: + + * `o`, `overwrite` + + Overwrite existing target files. + + * `a`, `append` + + Append the records to existing target files. + + * `f`, `fail` + + Stop processing whenever a target file exists, to prevent + destroying existing files by accident. This is the default. + +* `-s`, `--suffix suf` + + The suffix to be appended to the output file. If not specified, + the default is `.resolved`. + +* `-t`, `--trim-suffix suf` + + The suffix to be trimmed from the input file name before appending + the above suffix. Default is none. If you are running several log + file filters, this can help you trim the suffix of the previous one. + +* `-n`, `--num-threads num` + + Number of threads to run simultaneously. The default is 10. Use 0 + to disable threading. Your system must support threading itself. + This option has no effect for systems that do not support threading. + +* `-c`, `--stdout` + + Output the result to `STDOUT`. + +* `-d`, `--debug` + + Show the detailed debugging messages. More `-d` to be more + detailed. + +* `-q`, `--quiet` + + Hush! Only yell on error. + +* `-h`, `--help` + + Display the help message and exit. + +* `-v`, `--version` + + Output version information and exit. + + +Documentation +------------- + +Type `perldoc reslog` to read the `reslog` manual. + + +News, Changes and Updates +------------------------- + +Refer to the `Changes` for changes, bug fixes, updates, new functions, +etc. + + +Support +------- + +The `reslog` project is hosted on GitHub. Address your issues on the +GitHub issue tracker https://github.com/imacat/reslog/issues. + + +License +------- + + Copyright (C) 2000-2021 imacat. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +imacat ^_*' +2007/12/4 + +https://www.imacat.idv.tw diff --git a/README.zh-cn b/README.zh-cn deleted file mode 100644 index 022cb38..0000000 --- a/README.zh-cn +++ /dev/null @@ -1,55 +0,0 @@ -reslog - Apache 记录档 IP 反查程式 - - 版权所有 (c) 2000-2007 依玛猫 - - 本程式是自由软体,您可以遵照自由软体基金会 (Free Software Foundation) - 出版的 GNU 通用公共许可证条款 (GNU General Public License) 第三版来修 - 改和重新发布这一程式,或者自由选择使用任何更新的版本。 - - 发布这一程式的目的是希望它有用,但没有任何担保。甚至没有适合特定目的 - 而隐含的担保。更详细的情况请参阅 GNU 通用公共许可证。 - - 您应该已经和程式一起收到一份 GNU 通用公共许可证的副本。如果还没有,参 - 阅。 - -  reslog 是记录档反查程式,用来反查 Apache 记录档里 IP 的主机名称。查过后, -可以套用像 Analog 之类的记录档统计程式。你可以把它当做 Apache HostNameLookups -指令的替代品,每天一次反查当天所有的 IP 。 - - -◎说明文件 - -  请输入 perldoc reslog ,阅读 reslog 的说明。 - - -◎安装指南 - -  请详阅 INSTALL.zh-tw 档案的安装指南。 - - -◎更新、修正说明 - -  请详阅 Changes 档案的更新说明,以了解新增功能、问题修正、更新等。 - - -◎技术支援 - -  reslog 的网站在 http://reslog.sourceforge.net/ ,请随时上网了解最新讯息。 - -  reslog 有一个邮件通讯 reslog-users@lists.sourceforge.net ,若有任何问题、 -建议、问题回报、修补程式,请寄到邮件通讯上。请连上 -https://lists.sourceforge.net/lists/listinfo/reslog-users 加入我们的邮件通讯 -。除非是私人事务,否则请不要直接写信给我。邮件通讯会自动归档,日后若其他人有 -相同问题,可以直接在通讯旧档中找到答案,节省大家宝贵的时间。 - - -◎版权声明 - -  本程式依 GNU 通用公共许可证 (GPL) 版权发布,请参考 COPYING 档案的说明,了 -解本程式的版权授权内容。 - - -依玛猫 imacat ^_*' -2007-11-26 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/README.zh-tw b/README.zh-tw deleted file mode 100644 index 8e724a4..0000000 --- a/README.zh-tw +++ /dev/null @@ -1,55 +0,0 @@ -reslog - Apache 癘魁郎 IP は琩祘Α - - 舦┮Τ (c) 2000-2007 ㄌ嚎窟 - - セ祘Α琌パ硁砰眤宽酚パ硁砰膀穦 (Free Software Foundation) -  GNU 硄ノそ砛靡兵蹿 (GNU General Public License) 材ㄓ - э㎝穝祇硂祘Α┪パ匡拒ㄏノヴ穝セ - - 祇硂祘Αヘ琌辨ウΤノ⊿Τヴ踞玂⊿Τ続疭﹚ヘ - τ留踞玂冈灿薄猵叫把綷 GNU 硄ノそ砛靡 - - 眤莱赣竒㎝祘Α癬Μ GNU 硄ノそ砛靡捌セ狦临⊿Τ把 - 綷 - -reslog 琌癘魁郎は琩祘Αノㄓは琩 Apache 癘魁郎 IP 诀嘿琩筁 -甅ノ钩 Analog ぇ摸癘魁郎参璸祘Α﹑рウ讽暗 Apache HostNameLookups -蠢珇–ぱΩは琩讽ぱ┮Τ IP  - - -》弧ゅン - -叫块 perldoc reslog 綷弄 reslog 弧 - - -》杆玭 - -叫冈綷 INSTALL.zh-tw 郎杆玭 - - -》穝タ弧 - -叫冈綷 Changes 郎穝弧罙秆穝糤拜肈タ穝单 - - -》м砃や穿 - -reslog 呼 http://reslog.sourceforge.net/ 叫繦呼罙秆程穝癟 - -reslog Τ秎ン硄癟 reslog-users@lists.sourceforge.net 璝Τヴ拜肈 -某拜肈厨干祘Α叫盚秎ン硄癟叫硈 -https://lists.sourceforge.net/lists/listinfo/reslog-users и秎ン硄癟 -埃獶琌╬ㄆ叭玥叫ぃ璶钡糶獺倒и秎ン硄癟穦笆耴郎ら璝ㄤΤ -拜肈钡硄癟侣郎いт氮竊產腳禥丁 - - -》舦羘 - -セ祘Αㄌ GNU 硄ノそ砛靡 (GPL) 舦祇叫把σ COPYING 郎弧罙 -秆セ祘Α舦甭舦ず甧 - - -ㄌ嚎窟 imacat ^_*' -2007-11-26 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/SIGNATURE b/SIGNATURE deleted file mode 100644 index d7df3ed..0000000 --- a/SIGNATURE +++ /dev/null @@ -1,60 +0,0 @@ -This file contains message digests of all files listed in MANIFEST, -signed via the Module::Signature module, version 0.55. - -To verify the content in this distribution, first make sure you have -Module::Signature installed, then type: - - % cpansign -v - -It will check each file's integrity, as well as the signature's -validity. If "==> Signature verified OK! <==" is not displayed, -the distribution may already have been compromised, and you should -not run its Makefile.PL or Build.PL. - ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -SHA1 91ced1a733e7448edc19eab22482508d58d7b284 AUTHORS -SHA1 c4c98cc9e7ac5e119752587d0322280a7a71d205 AUTHORS.zh-cn -SHA1 eb60ee204fcf7244fc0774ac34d05a35a281e82b AUTHORS.zh-tw -SHA1 f53e1e68c754efbcfc53ea967696a8671984447a Build.PL -SHA1 8624bcdae55baeef00cd11d5dfcfa60f68710a02 COPYING -SHA1 42632c78bf9e9342ae14210ca950ff00062ddd2b Changes -SHA1 f7bc1bef076475c9431f0c63624e2ab3033b8764 INSTALL -SHA1 79721949017a665473a2e153fd8d87c80825fd2b INSTALL.zh-cn -SHA1 b1d57a65f4615ec3d5ab0b835378bae1e024ba40 INSTALL.zh-tw -SHA1 a18724385a8fb946bda27e9931237d8c2a6933df MANIFEST -SHA1 dd16bfeaae712a00a4de3e68c5f481202cb26125 META.yml -SHA1 68ff538f6e43ffec964106a6036bcd430e26620d Makefile.PL -SHA1 480f86cf076a309356773b88f9ba438383084cd1 NEWS -SHA1 843feea16b78f493dc75fe0522d32da01a47d689 README -SHA1 0baa56bf2c4996141c65f3e22bd85f71b8ef66e8 README.zh-cn -SHA1 13a621e560350253ae43d4a1a68c61a204aa3e16 README.zh-tw -SHA1 52bb31d47dbadf06f520770a7a15852240620d05 THANKS -SHA1 e5df3a0192f9349821008f003ba10e5bddc4d13a THANKS.zh-cn -SHA1 e0addd6f8f0c3414094df574853af6dac53ecf7d THANKS.zh-tw -SHA1 48f5fff8ffb487089aa9fdcb9279ba3fd1c508c0 TODO -SHA1 00e67ef5268c66e8648c5f14da8e7912e2c2f9c5 TODO.zh-cn -SHA1 2e45a15082ae9630230235d7538dec63c6df18c8 TODO.zh-tw -SHA1 b76525cba62910e04d30162efa5dc2d01aba0c97 UPGRADE -SHA1 4a73e7d68ebc13536e5eac889dc345da210dd871 UPGRADE.zh-cn -SHA1 01f4180ffa5285ed96e7aa882bf205573c35146b UPGRADE.zh-tw -SHA1 bd75d59f9d7d9731bfabdc48ecd19e704d218e38 fdl.txt -SHA1 520fdcf4374af210380db9e0fdaea44c904a15fc pgpkey.asc -SHA1 700b11dfc01b4c76f05d391e3c125278f644c56b reslog -SHA1 41a536e18f36778b9ff933825ef0a1f7a1981b21 reslog.en.html -SHA1 6145e6f46918eee110b4d03fe9b9ea3dd6fc3314 reslog.zh-cn.html -SHA1 9b211e9952a151906a00600c85ff0c3378926a61 reslog.zh-tw.html -SHA1 525f414c7a0aadc61240a4b0959ca2cda7514c75 t/00-signature.t -SHA1 4c364eda95b34511f7b44d80cb933d151b6d2319 t/01-exhaust.t -SHA1 59d3566284c629bed1e217665b689dd8d2fb0e9e t/02-several.t -SHA1 575fbed4b769731be070e4b7b78ed89de98d6054 t/03-errors.t -SHA1 b85626024d610808bd0909989dcfb9fb20a40485 t/99-pod.t -SHA1 84b9f1582dbce493e1fd5ac9b8580786e0dfc152 t/_helper.pm ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.7 (GNU/Linux) - -iD8DBQFHVgHGi9gubzC5S1wRAjzCAJ9FOyU/0SG08ixiWMpPIaO5Nhm63QCgnUON -sKqVvHQZhcBU4PNl7DkpsQE= -=Zbq7 ------END PGP SIGNATURE----- diff --git a/THANKS.zh-cn b/THANKS.zh-cn deleted file mode 100644 index 9494a05..0000000 --- a/THANKS.zh-cn +++ /dev/null @@ -1,5 +0,0 @@ -  感谢 SourceForge 提供架设 reslog 专案。 -  感谢 Chen-hsiu Huang 回报 $WORKING_RES 开 -档时未锁档的错误。 -  感谢 CPAN 提供架设 reslog 专案。 -  感谢 SourceForge 提供 compile farm 各种平台供专案测试。 diff --git a/THANKS.zh-tw b/THANKS.zh-tw deleted file mode 100644 index 22e125f..0000000 --- a/THANKS.zh-tw +++ /dev/null @@ -1,5 +0,0 @@ -稰谅 SourceForge 矗ㄑ琜砞 reslog 盡 -稰谅 Chen-hsiu Huang 厨 $WORKING_RES 秨 -郎ゼ玛郎岿粇 -稰谅 CPAN 矗ㄑ琜砞 reslog 盡 -稰谅 SourceForge 矗ㄑ compile farm 贺キㄑ盡代刚 diff --git a/TODO b/TODO deleted file mode 100644 index a132d2b..0000000 --- a/TODO +++ /dev/null @@ -1,2 +0,0 @@ - 1. Multi-lingual support, with Traditional and Simplified Chinese - messages. diff --git a/TODO.zh-cn b/TODO.zh-cn deleted file mode 100644 index a7592fa..0000000 --- a/TODO.zh-cn +++ /dev/null @@ -1 +0,0 @@ - 1. 多语化,加上正简中文讯息。 diff --git a/TODO.zh-tw b/TODO.zh-tw deleted file mode 100644 index fcf3af6..0000000 --- a/TODO.zh-tw +++ /dev/null @@ -1 +0,0 @@ - 1. 粂てタ虏いゅ癟 diff --git a/UPGRADE b/UPGRADE deleted file mode 100644 index 1429be3..0000000 --- a/UPGRADE +++ /dev/null @@ -1,74 +0,0 @@ -Upgrade Instruction - - Here are a few hints for people upgrading from 3.10 or earlier: - -* The Default Installation Location Is at /usr/bin - - Also, the man page is at /usr/share/man/man1/reslog.1. This is to follow -Perl's standard convension, and to avoid breaking ExtUtils::MakeMaker with -future versions. - - When you run "perl Makefile.PL" or "perl Build.PL", it will hint a list of -old files found to be removed. Please delete them manually. - - If you saved them in other places, you have to delete them yourself. - - Also, if you have any scripts or cron jobs that are running reslog, remember -to modify your script for the new reslog location. Of course, you can copy -reslog to the original location. It will still work. - - - Here are a few hints for people upgrading from 3.02 or earlier: - - -* The Script Name is Changed from reslog.pl to reslog - - This is obvious. If you have any scripts or cron jobs that are running -reslog, remember to modify your script for the new name. Of course, you can -rename reslog to reslog.pl. It will still work. - - The reason I changed the script and project name is that: A dot "." in -the project name is not valid everywhere. At least SourceForge don't accept -it. Besides, "reslog" is enough for a script name under UNIX. The ".pl" file -name suffix/extension may be convienent for MS-Windows, but MS-Windows users -won't run it with explorer file name association anyway, and there is a pl2bat -to convert "reslog" to "reslog.bat", which would make more sense. The only -disadvantage is that I use UltraEdit, which depends on the file name extension -for the automatic syntax highlighting rules. But this is not much trouble. I -can manuall set it anyway. - - -* You Need Perl 5.8.0 or Above - - reslog now has threading to speed up resolving, which requires Perl's -ithreads threading module support that's only available since 5.8.0. You can -still disable threading if it causes troubles to you, but the code itself need -it. If you are using a Perl before 5.8.0, please upgrade it. You can run -"perl -v" to see your current Perl version. - - -* The Default Keep Mode is Now "delete" - - The documentation said the default keep mode is "delete", but the script -actually did a "restart". :p This is fixed. If you are running with the -default keep mode, remember to fix it. - - -* The Argument of --keep and --override Options Are Required Now - - Support for omitting --keep or --override argument is removed. This helps -avoiding confusion for the log file name and the option arguments. - - -* Specifying STDIN Will No Longer Trigger STDOUT - - When resolving multiple files, STDIN can output to STDOUT now, with other -files output to where they should be. Specifying an STDIN will no longer -automatically trigger outputing everything to STDOUT. If you want to output -everything to STDOUT, be sure to add the --stdout option. - - -imacat -2007-11-26 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/UPGRADE.zh-cn b/UPGRADE.zh-cn deleted file mode 100644 index 4db776b..0000000 --- a/UPGRADE.zh-cn +++ /dev/null @@ -1,64 +0,0 @@ -升级指南 - -  若你由 3.10 或之前的版本升级,请阅读以下说明: - -◎预设安装目录为 /usr/bin - -  说明档则在 /usr/share/man/man1/reslog.1 。这是为符合 Perl 的标准安装流程, -敝免破坏 ExtUtils::MakeMaker 的预设设定,造成日后升级的问题。 - -  执行 perl Makefile.PL 或 perl Build.PL 时,会提示你所在系统上发现的的旧档 -案。请自行删除。若你程式存在其它地方,请记得要自己删掉。 - -  若你有写程式,或设定 cron 排程来执行 reslog ,请记得更改档名。不过你也可以 -把 reslog 存到原来的目录去,不会有任何问题。 - - -  若你由 3.02 或之前的版本升级,请阅读以下说明: - -◎档名由 reslog.pl 改为 reslog - -  这很明显吧。 :p 若你有写程式,或设定 cron 排程来执行 reslog ,请记得更改档 -名。不过你也可以把 reslog 改名回原来的 reslog.pl ,不会有任何问题。 - -  改名原因如下:专案名称含「.」会处处碰壁。 SourceForget 就不接受含「.」的专 -案名称。此外,程式名称 reslog 在 UNIX 下就可以跑了。副档名 .pl 虽然在 -MS-Windows 下方便,但反正 MS-Windows 下也不会直接点两下依副档名执行。而且还有 -pl2bat 可以把 reslog 转成 reslog.bat ,这样反而比较合理。唯一不便的是我用的编 -辑器 UltraEdit 依副档名决定程式语言语法标示,不过这也没什么大不了,手动设程式 -语言就好了。 - - -◎ Perl 5.8.0 版以上 - -  新版的 reslog 用多线程加速反查,要用到 Perl 5.8.0 之后的新 ithread 多线程 -模式。你若不想用多线程功能,可以不用,不过程式码本身,还是要用到 ithread 。若 -你用的是 5.8.0 以前的 Perl 版本,请升级你的 Perl 。你可以输入 perl -v 查询你目 -前的 Perl 版本。 - - -◎预设 keep 原记录档保留模式是 delete - -  我在说明文件上写,预设 keep 原记录档保留模式是 delete 删除,可是其实程式真 -正跑的是 restart 归零。 :p 这个问题已经修好了。如果你依预设保留模式执行,请记 -得要修正。 - - -◎ --keep 和 --override 选项现在一定要加模式参数 - -  以前可以直接用 --keep 和 --override 选项,不加参数,现在一定要加参数,以避 -免混淆选项的参数和要处理的记录档名。 - - -◎读取标准输入 STDIN 不会自动启动标准输出 STDOUT 模式 - -  一次读取多个档案时,只有标准输入 STDIN 的结果会输出到标准输出,其它档案都 -会输出到各自该输出的档案去。以前一次读取多档时,或其中有一个是标准输入,则会全 -部输出到标准输出去,现在不会了。若你需要把全部的结果输出到标准输出,请加上 ---stdout 选项。 - - -依玛猫 -2007-11-26 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/UPGRADE.zh-tw b/UPGRADE.zh-tw deleted file mode 100644 index 301e32f..0000000 --- a/UPGRADE.zh-tw +++ /dev/null @@ -1,64 +0,0 @@ -狜玭 - -璝﹑パ 3.10 ┪ぇ玡セ狜叫綷弄弧 - -》箇砞杆ヘ魁 /usr/bin - -弧郎玥 /usr/share/man/man1/reslog.1 硂琌才 Perl 夹非杆瑈祘 -蓖瘆胊 ExtUtils::MakeMaker 箇砞砞﹚硑Θら狜拜肈 - -磅︽ perl Makefile.PL ┪ perl Build.PL 穦矗ボ﹑┮╰参祇瞷侣郎 -叫︽埃璝﹑祘Αㄤウよ叫癘眔璶奔 - -璝﹑Τ糶祘Α┪砞﹚ cron 逼祘ㄓ磅︽ reslog 叫癘眔э郎ぃ筁﹑ -р reslog ㄓヘ魁ぃ穦Τヴ拜肈 - - -璝﹑パ 3.02 ┪ぇ玡セ狜叫綷弄弧 - -》郎パ reslog.pl э reslog - -硂陪 :p 璝﹑Τ糶祘Α┪砞﹚ cron 逼祘ㄓ磅︽ reslog 叫癘眔э郎 -ぃ筁﹑р reslog эㄓ reslog.pl ぃ穦Τヴ拜肈 - -э盡嘿.穦矪矪窱纠 SourceForget 碞ぃ钡.盡 -嘿祘Α嘿 reslog  UNIX 碞禲捌郎 .pl 瘤礛 -MS-Windows よ獽はタ MS-Windows ぃ穦钡翴ㄢㄌ捌郎磅︽τ临Τ -pl2bat р reslog 锣Θ reslog.bat 硂妓はτゑ耕瞶斑ぃ獽琌иノ絪 -胯竟 UltraEdit ㄌ捌郎∕﹚祘Α粂ē粂猭夹ボぃ筁硂⊿ぐ或ぃも笆砞祘Α -粂ē碞 - - -》 Perl 5.8.0  - -穝 reslog ノ絬祘硉は琩璶ノ Perl 5.8.0 ぇ穝 ithread 絬祘 -家Α﹑璝ぃ稱ノ絬祘ぃノぃ筁祘Α絏セō临琌璶ノ ithread 璝 -﹑ノ琌 5.8.0 玡 Perl セ叫狜﹑ Perl ﹑块 perl -v 琩高﹑ヘ -玡 Perl セ - - -》箇砞 keep 癘魁郎玂痙家Α琌 delete - -и弧ゅン糶箇砞 keep 癘魁郎玂痙家Α琌 delete 埃琌ㄤ龟祘Α痷 -タ禲琌 restart 耴箂 :p 硂拜肈竒狦﹑ㄌ箇砞玂痙家Α磅︽叫癘 -眔璶タ - - -》 --keep ㎝ --override 匡兜瞷﹚璶家Α把计 - -玡钡ノ --keep ㎝ --override 匡兜ぃ把计瞷﹚璶把计磷 -睼瞔匡兜把计㎝璶矪瞶癘魁郎 - - -》弄夹非块 STDIN ぃ穦笆币笆夹非块 STDOUT 家Α - -Ω弄郎Τ夹非块 STDIN 挡狦穦块夹非块ㄤウ郎常 -穦块赣块郎玡Ω弄郎┪ㄤいΤ琌夹非块玥穦 -场块夹非块瞷ぃ穦璝﹑惠璶р场挡狦块夹非块叫 ---stdout 匡兜 - - -ㄌ嚎窟 -2007-11-26 -imacat@mail.imacat.idv.tw -http://www.imacat.idv.tw/ diff --git a/fdl.txt b/fdl.txt deleted file mode 100644 index 4a0fe1c..0000000 --- a/fdl.txt +++ /dev/null @@ -1,397 +0,0 @@ - GNU Free Documentation License - Version 1.2, November 2002 - - - Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - -0. PREAMBLE - -The purpose of this License is to make a manual, textbook, or other -functional and useful document "free" in the sense of freedom: to -assure everyone the effective freedom to copy and redistribute it, -with or without modifying it, either commercially or noncommercially. -Secondarily, this License preserves for the author and publisher a way -to get credit for their work, while not being considered responsible -for modifications made by others. - -This License is a kind of "copyleft", which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - - -1. APPLICABILITY AND DEFINITIONS - -This License applies to any manual or other work, in any medium, that -contains a notice placed by the copyright holder saying it can be -distributed under the terms of this License. Such a notice grants a -world-wide, royalty-free license, unlimited in duration, to use that -work under the conditions stated herein. The "Document", below, -refers to any such manual or work. Any member of the public is a -licensee, and is addressed as "you". You accept the license if you -copy, modify or distribute the work in a way requiring permission -under copyright law. - -A "Modified Version" of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A "Secondary Section" is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (Thus, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The "Invariant Sections" are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. If a -section does not fit the above definition of Secondary then it is not -allowed to be designated as Invariant. The Document may contain zero -Invariant Sections. If the Document does not identify any Invariant -Sections then there are none. - -The "Cover Texts" are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. A Front-Cover Text may -be at most 5 words, and a Back-Cover Text may be at most 25 words. - -A "Transparent" copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, that is suitable for revising the document -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup, or absence of markup, has been arranged to thwart -or discourage subsequent modification by readers is not Transparent. -An image format is not Transparent if used for any substantial amount -of text. A copy that is not "Transparent" is called "Opaque". - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML, PostScript or PDF designed for human modification. Examples of -transparent image formats include PNG, XCF and JPG. Opaque formats -include proprietary formats that can be read and edited only by -proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML, PostScript or PDF produced by some word -processors for output purposes only. - -The "Title Page" means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, "Title Page" means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. - -A section "Entitled XYZ" means a named subunit of the Document whose -title either is precisely XYZ or contains XYZ in parentheses following -text that translates XYZ in another language. (Here XYZ stands for a -specific section name mentioned below, such as "Acknowledgements", -"Dedications", "Endorsements", or "History".) To "Preserve the Title" -of such a section when you modify the Document means that it remains a -section "Entitled XYZ" according to this definition. - -The Document may include Warranty Disclaimers next to the notice which -states that this License applies to the Document. These Warranty -Disclaimers are considered to be included by reference in this -License, but only as regards disclaiming warranties: any other -implication that these Warranty Disclaimers may have is void and has -no effect on the meaning of this License. - - -2. VERBATIM COPYING - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section 3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. - - -3. COPYING IN QUANTITY - -If you publish printed copies (or copies in media that commonly have -printed covers) of the Document, numbering more than 100, and the -Document's license notice requires Cover Texts, you must enclose the -copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a computer-network location from which the general network-using -public has access to download using public-standard network protocols -a complete Transparent copy of the Document, free of added material. -If you use the latter option, you must take reasonably prudent steps, -when you begin distribution of Opaque copies in quantity, to ensure -that this Transparent copy will remain thus accessible at the stated -location until at least one year after the last time you distribute an -Opaque copy (directly or through your agents or retailers) of that -edition to the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. - - -4. MODIFICATIONS - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission. -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has fewer than five), - unless they release you from this requirement. -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher. -D. Preserve all the copyright notices of the Document. -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below. -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice. -H. Include an unaltered copy of this License. -I. Preserve the section Entitled "History", Preserve its Title, and add - to it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section Entitled "History" in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence. -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the "History" section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission. -K. For any section Entitled "Acknowledgements" or "Dedications", - Preserve the Title of the section, and preserve in the section all - the substance and tone of each of the contributor acknowledgements - and/or dedications given therein. -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles. -M. Delete any section Entitled "Endorsements". Such a section - may not be included in the Modified Version. -N. Do not retitle any existing section to be Entitled "Endorsements" - or to conflict in title with any Invariant Section. -O. Preserve any Warranty Disclaimers. - -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section Entitled "Endorsements", provided it contains -nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. - - -5. COMBINING DOCUMENTS - -You may combine the Document with other documents released under this -License, under the terms defined in section 4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice, and that you preserve all their Warranty Disclaimers. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections Entitled "History" -in the various original documents, forming one section Entitled -"History"; likewise combine any sections Entitled "Acknowledgements", -and any sections Entitled "Dedications". You must delete all sections -Entitled "Endorsements". - - -6. COLLECTIONS OF DOCUMENTS - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. - - -7. AGGREGATION WITH INDEPENDENT WORKS - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, is called an "aggregate" if the copyright -resulting from the compilation is not used to limit the legal rights -of the compilation's users beyond what the individual works permit. -When the Document is included in an aggregate, this License does not -apply to the other works in the aggregate which are not themselves -derivative works of the Document. - -If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one half of -the entire aggregate, the Document's Cover Texts may be placed on -covers that bracket the Document within the aggregate, or the -electronic equivalent of covers if the Document is in electronic form. -Otherwise they must appear on printed covers that bracket the whole -aggregate. - - -8. TRANSLATION - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section 4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License, and all the license notices in the -Document, and any Warranty Disclaimers, provided that you also include -the original English version of this License and the original versions -of those notices and disclaimers. In case of a disagreement between -the translation and the original version of this License or a notice -or disclaimer, the original version will prevail. - -If a section in the Document is Entitled "Acknowledgements", -"Dedications", or "History", the requirement (section 4) to Preserve -its Title (section 1) will typically require changing the actual -title. - - -9. TERMINATION - -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document is void, and will -automatically terminate your rights under this License. However, -parties who have received copies, or rights, from you under this -License will not have their licenses terminated so long as such -parties remain in full compliance. - - -10. FUTURE REVISIONS OF THIS LICENSE - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. See -http://www.gnu.org/copyleft/. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License "or any later version" applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. - - -ADDENDUM: How to use this License for your documents - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and -license notices just after the title page: - - Copyright (c) YEAR YOUR NAME. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.2 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled "GNU - Free Documentation License". - -If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, -replace the "with...Texts." line with this: - - with the Invariant Sections being LIST THEIR TITLES, with the - Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. - -If you have Invariant Sections without Cover Texts, or some other -combination of the three, merge those two alternatives to suit the -situation. - -If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, -to permit their use in free software. diff --git a/pgpkey.asc b/pgpkey.asc deleted file mode 100644 index bd75349..0000000 --- a/pgpkey.asc +++ /dev/null @@ -1,40 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.4.1 (GNU/Linux) - -mQGiBD0kfGQRBADaGggoSHTZ8P17j92IMMxWPpML0TdvbhzW5iFF7a5th0xCn9od -pHVwc2YxuEulwDz0LJUx2IwwbttftHcJafcH51vk57Qq2+hvNAE1o9a/MWReMIwv -KfBi3Q1bVxWIjVPDbHd+ZUbbo0pozbfrHEaRPQ0qR+/ZgK5+V6WJiLElrwCgsCQy -FGfo72h5p46w7MrW4qSmalkD/RMcVmPkszF5J0N9pWlgcJ/fTYlMKIit3V/W/fru -L4KkUT3d9CMcJSBZrcVlXlDbPeBF8L7vl46NImd4xfnRKLwOuAy67Tld6CbC+UWz -rv6472rGetTTaj7iBH5nR62BQUmaLK6W6Q8vFOrqIBqXEz5iJ+RLYpIxH5M8gOz5 -7b7GBACIZaPaMVzIbTqnysDCgKEQqOyFbpgcGfSH52xH3XXeNrJhuenJFvBbeV8J -RgmKSnn1ZixFHJ261uGu5kOA1CQemNrTgZRaeHDu6mdZALdbxpLXp9DeOC/oTUWa -1O2xmAWcZZo+63s0MciC9zDrRjlNuGcVOiHZZLh9P9vEfoJos7Qu5L6d55Gq6LKT -IChpbWFjYXQpIDxpbWFjYXRAbWFpbC5pbWFjYXQuaWR2LnR3PoheBBMRAgAeBQJC -iLwmAhsDBgsJCAcDAgMVAgMDFgIBAh4BAheAAAoJEIvYLm8wuUtcmnYAnRQCNXWc -vgtk4CiTTBWqGWWZRjViAKCn/F6maM9R5RzuC1L5ER27f0AjbrkEDQQ9JHzZEBAA -owxPPj1TOZKGuav0eKopd8RrwFQ51P0FY85WyTAsCWg/KGcJIXFKwJ/r4U381iQd -z+16+E6oOzTIs/iwnkSKmfWx2M46uXdIa/VkLChZzHpCVDHeVICGE5sbECNS2gYD -CRx/Jl/FnXNaeaI0RZm3i4gf204bvqsPm+epI/BOW4cZmbkqSd4BuG2/i7y/BZzP -NhVseNVe2qhWFxs4Hj5S6y6xYSuuPLC4mZrkA7x1J9tq+wUt6z0mwIdRhEaK5iE5 -PB44XiwGKW02sLt5CQXDW/DbqXlyu6VP90iVjWLg0ftI28dULipw2n6u0DIGIxfL -i4dDf0gcYyqDF++aMWYTlB7a89Vt055dp7NC59VaqltW9DgKnxkiTUMxZ3HtqA67 -rwKtwKY3CQyuIYil31AQy0izi4fIu6MRznLtwHAfaqsB0Nej+kFl1XSUspe3P6ea -YzMs7on0X0KvPDWPo7AMz0Y/ex/XzYwR2+IzijTnaakH5TS7da0LKXb3FTV/PuIR -UgH3P/yOwRyOU4VLWqcyLxBJuMlX1WVz3UdNfHwRfm+jqPktP0qnQ9ZrFk3VEOGv -0hMvCeqj3Vw5CziYCTm3YiDG4OLPpUN3ByF944cUCYKwoGYEUKUf0vXPvUYdshqB -D49RyI0oy2nZstSt+iVefuCyWBYEyqIDu0eRGWY8FRMAAwUQAI/jMOnq6mP7mfbs -qq1ugXtx0r7cKNge0ebB/TA37ZLCo2UTdoxk/AsuGx1MK6kKJh3Zkxz89jb84CXA -jZbYbLOGhFioHCyiqfJwFbR7Abhsoo1NuEAtibJpFUm0oHym/Tjc4Xwht7cf52+8 -USfC918mFzmbPDOuIpkcHjGzXFztgDiMlX7iDrMvX2QOLzhp+g/I/pyAhAcKH8Eo -vcKeYOoQIM7hpP0eTZxgCDdRw9SpodU0/rTL6UzA4iXMcqncspH0OjfT5gxj3cOo -ofhaPxsIoqllZA/V/x7CeykdNE5L5SYv3c0NBnTMe9kV4K8V0JHTyz7N3ipiWJHP -VObvgdrJyA9YYCpgorfE7a1rtmLPfr5evrTuKP+VMEInqvA0mAxzX/HsbtsA+bNn -g6c5WibjO/kDKgfZfHFrPlLPiSSBVn9ygEySdlBuXpb5c7wft/YV0FyVAikbhY3l -3jJYmQ7kBxrtoIH9jK6Ff8rw7qbyBg6fDPoC3gevNdmoVtk5vTcKQTxPKlCeXTtE -JYfKDvX0BDkV8Wdizit03Sp0StpeietlX5vYQDyefp+w5J3k2SrbkEczzGZzXHq/ -5pm36cC0N0rA8ZW7JOpkThjZIJ733Y5DwtzhWqdUubWiCMmC7HfGmpI0OdV6QF8p -kCKXIsJ90Uiep0lEDNQZg4Y96kuUiEYEGBECAAYFAj0kfNoACgkQi9gubzC5S1xO -uACdELzJCBgMJVZ9siHwn48X2rXdQnIAn0yagIZfaIS0CfCamwcYeMfKcQQV -=GeL3 ------END PGP PUBLIC KEY BLOCK----- diff --git a/reslog b/reslog index 3ca1e7b..6bdb607 100755 --- a/reslog +++ b/reslog @@ -1,40 +1,39 @@ #! /usr/bin/perl -w # reslog: Reverse-resolve IP in Apache log files -# Copyright (c) 2000-2007 imacat -# -# 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 3 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, see . +# Copyright (c) 2000-2021 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -# First written: 2000-12-22 +# First written: 2000/12/22 package main; use 5.008; use strict; use warnings; use base qw(Exporter); -use vars qw(@EXPORT @EXPORT_OK); +our (@EXPORT, @EXPORT_OK); BEGIN { @EXPORT = qw(); push @EXPORT, qw(OVERRIDE_OVERWRITE OVERRIDE_APPEND OVERRIDE_FAIL); push @EXPORT, qw(KEEP_ALL KEEP_RESTART KEEP_DELETE); -push @EXPORT, qw(TYPE_PLAIN TYPE_GZIP TYPE_BZIP2); -push @EXPORT, qw(TMP_SUFFIX whereis rel2abs); +push @EXPORT, qw(TYPE_TEXT TYPE_GZIP TYPE_BZIP2); +push @EXPORT, qw(TMP_SUFFIX where_is rel2abs); @EXPORT_OK = @EXPORT; # Prototype declaration sub main(); sub parse_args(); -sub whereis($); +sub where_is($); sub rel2abs($;$); } @@ -49,7 +48,7 @@ use Getopt::Long qw(GetOptions); use IO::Handle; our ($THIS_FILE, $VERBOSE); -use vars qw($VERSION); +our ($VERSION); $THIS_FILE = basename($0); $VERSION = "3.16"; $VERBOSE = 1; @@ -66,7 +65,7 @@ use constant KEEP_RESTART => "restart"; use constant KEEP_DELETE => "delete"; use constant DEFAULT_KEEP => KEEP_DELETE; # The file types -use constant TYPE_PLAIN => "text/plain"; +use constant TYPE_TEXT => "text/plain"; use constant TYPE_GZIP => "application/x-gzip"; use constant TYPE_BZIP2 => "application/x-bzip2"; # Other constants @@ -74,16 +73,16 @@ use constant TMP_SUFFIX => ".tmp-reslog"; use constant DEFAULT_SUFFIX => ".resolved"; use constant DEFAULT_STDOUT => 0; use constant DEFAULT_THREADS => 10; -use constant DEFAULT_PROGBAR => 1; +use constant DEFAULT_IS_PROGRESS_BAR => 1; -our (%CONF, @LOGFILES, $RESOLVER, $PROGBAR, $STDIN, $STDOUT); -use vars qw(%WHEREIS); +our (%CONF, @LOGFILES, $RESOLVER, $PROGRESS_BAR, $STDIN, $STDOUT); +our (%WHERE_IS); -use vars qw($VERMSG $HELPMSG); -our $SHORTHELP; -$VERMSG = "$THIS_FILE v$VERSION by imacat "; -$SHORTHELP = "Try `$THIS_FILE --help' for more information."; -$HELPMSG = << "EOF"; +our ($VER_MSG, $HELP_MSG); +our $SHORT_HELP; +$VER_MSG = "$THIS_FILE v$VERSION by imacat "; +$SHORT_HELP = "Try `$THIS_FILE --help' for more information."; +$HELP_MSG = << "EOF"; Usage: $THIS_FILE [options] [logfile...] Resolve IPs from the Apache access log. @@ -122,14 +121,14 @@ EOF main; exit 0; -# main: Main program +# Main program sub main() { local ($_, %_); - my ($c, $t0); - + my $c; + # Parse the arguments parse_args; - + # Create the temporary working files $_->create_temp foreach @LOGFILES; # Read the source files to temporary working files @@ -143,16 +142,16 @@ sub main() { $_->write_result foreach @LOGFILES; # Remove the temporary working files $_->remove_temp foreach @LOGFILES; - + print STDERR "Done. " . (time - $^T) . " seconds elapsed.\n" if $VERBOSE > 0; return; } -# parse_args: Parse the arguments +# Parse the arguments sub parse_args() { local ($_, %_); - + %CONF = qw(); # Get the arguments eval { @@ -187,11 +186,11 @@ sub parse_args() { "stdout|c!"=>sub { $CONF{"STDOUT"} = $_[1]; }, "debug|d+"=>\$VERBOSE, "quiet|q"=>sub { $VERBOSE-- if $VERBOSE > 0; }, - "help|h"=>sub { print $HELPMSG; exit 0; }, - "version|v"=>sub { print "$VERMSG\n"; exit 0; }); + "help|h"=>sub { print $HELP_MSG; exit 0; }, + "version|v"=>sub { print "$VER_MSG\n"; exit 0; }); }; - die "$THIS_FILE: $@$SHORTHELP\n" if $@ ne ""; - + die "$THIS_FILE: $@$SHORT_HELP\n" if $@ ne ""; + # Check the arguments # Arguments are log files @LOGFILES = qw(); @@ -200,39 +199,39 @@ sub parse_args() { $_ = shift @ARGV; # Treat /dev/stdin as - on UNIX-like systems $_ = "-" if $_ eq "/dev/stdin" && devnull eq "/dev/null"; - die "$THIS_FILE: $_: You can only specify a file once\n$SHORTHELP\n" + die "$THIS_FILE: $_: You can only specify a file once\n$SHORT_HELP\n" if exists $_{$_}; push @LOGFILES, $_; $_{$_} = 1; } @LOGFILES = qw(-) if @LOGFILES == 0; - + # Save the original STDIN and STDOUT open $STDIN, "<&", \*STDIN or die "$THIS_FILE: STDIN: $!"; open $STDOUT, ">&", \*STDOUT or die "$THIS_FILE: STDOUT: $!"; - + # Set the verbose level autoflush STDERR if $VERBOSE > 1; - $CONF{"PROGBAR"} = DEFAULT_PROGBAR; - $CONF{"PROGBAR"} = 0 if $VERBOSE == 0 || $VERBOSE > 2 || !-t STDERR; - if ($CONF{"PROGBAR"}) { + $CONF{"IS_PROGRESS_BAR"} = DEFAULT_IS_PROGRESS_BAR; + $CONF{"IS_PROGRESS_BAR"} = 0 if $VERBOSE == 0 || $VERBOSE > 2 || !-t STDERR; + if ($CONF{"IS_PROGRESS_BAR"}) { # Check if we have Term::ReadKey - $CONF{"PROGBAR"} = 0 unless eval { require Term::ReadKey; 1; }; + $CONF{"IS_PROGRESS_BAR"} = 0 unless eval { require Term::ReadKey; 1; }; } - + # Set the default STDOUT mode $CONF{"STDOUT"} = DEFAULT_STDOUT if !exists $CONF{"STDOUT"}; - # If outputing to STDOUT + # If writing to STDOUT if ($CONF{"STDOUT"}) { # Warn if not overwrite - warn "$THIS_FILE: Nonsense to override mode \"fail\" when outputing to STDOUT.\n" + warn "$THIS_FILE: Nonsense to override mode \"fail\" when writing to STDOUT.\n" if exists $CONF{"OVERRIDE"} && $CONF{"OVERRIDE"} eq OVERRIDE_FAIL; # Always use overwrite $CONF{"OVERRIDE"} = OVERRIDE_OVERWRITE; # Default keep mode changed to keep all $CONF{"KEEP"} = KEEP_ALL if !exists $CONF{"KEEP"}; } - + # Set the default number of threads if (!defined $Config::Config{"useithreads"}) { warn "$THIS_FILE: Threading disabled because your OS or Perl does not support it.\n" @@ -240,7 +239,7 @@ sub parse_args() { $CONF{"THREADS"} = 0; } $CONF{"THREADS"} = DEFAULT_THREADS if !exists $CONF{"THREADS"}; - + # Set the default keep mode $CONF{"KEEP"} = DEFAULT_KEEP if !exists $CONF{"KEEP"}; # Set the default override mode @@ -252,48 +251,48 @@ sub parse_args() { # The suffix to be appended cannot be the same as the suffix to be trimmed die "$THIS_FILE: " . $CONF{"SUFFIX"} . ": Suffix cannot be the same as the suffix to be trimmed.\n" if defined $CONF{"TRIM_SUFFIX"} && $CONF{"TRIM_SUFFIX"} eq $CONF{"SUFFIX"}; - + # Initialize the resolver if ($CONF{"THREADS"}) { - $RESOLVER = new _private::Resolver::Threaded; + $RESOLVER = _private::Resolver::Threaded->new; } else { - $RESOLVER = new _private::Resolver; + $RESOLVER = _private::Resolver->new; } - + # Check the log files - @LOGFILES = map new _private::LogFile($_), @LOGFILES; - + @LOGFILES = map _private::LogFile->new($_), @LOGFILES; + return; } -# whereis: Find an executable +# Find an executable # Code inspired from CPAN::FirstTime -sub whereis($) { +sub where_is($) { local ($_, %_); my ($file, $path); $file = $_[0]; - return $WHEREIS{$file} if exists $WHEREIS{$file}; + return $WHERE_IS{$file} if exists $WHERE_IS{$file}; foreach my $dir (path) { print STDERR " Checking $dir ... " if $VERBOSE > 3; if (defined($path = MM->maybe_command(catfile($dir, $file)))) { print STDERR "$path\n found " if $VERBOSE > 3; - return ($WHEREIS{$file} = $path); + return ($WHERE_IS{$file} = $path); } print STDERR "no\n" if $VERBOSE > 3; } - return ($WHEREIS{$file} = undef); + return ($WHERE_IS{$file} = undef); } -# rel2abs: Convert a relative path to an absolute path +# Convert a relative path to an absolute path sub rel2abs($;$) { local ($_, %_); my ($path, $base); ($path, $base) = @_; - + # Turn the base absolute $base = cwd unless defined $base; $base = rel2abs $base if !file_name_is_absolute $base; - + # Deal with the ~ user home directories under UNIX if (defined $Config::Config{"d_getpwent"}) { @_ = splitdir($path); @@ -318,10 +317,10 @@ sub rel2abs($;$) { $path = catfile @_; } } - + # Append the current directory if relative $path = catfile($base, $path) unless file_name_is_absolute $path; - + @_ = splitdir($path); # Split into directory components # Add an empty filename level if last level is a directory push @_, "" if ($_[@_-1] eq curdir || $_[@_-1] eq updir); @@ -341,13 +340,13 @@ sub rel2abs($;$) { } -# _private::ProgressBar: The progress bar displayer +# _private::ProgressBar: The progress bar display package _private::ProgressBar; use 5.008; use strict; use warnings; -# new: Initialize the progrss bar handler +# Initialize the progress bar handler sub new : method { local ($_, %_); my ($class, $self, $label, $total); @@ -356,18 +355,18 @@ sub new : method { $self->{"label"} = $label; $self->{"total"} = $total; $self->{"start"} = time; - $self->{"lastline"} = undef; + $self->{"last_line"} = undef; require Term::ReadKey; return $self; } -# update: Update the progress bar +# Update the progress bar sub update : method { local ($_, %_); my ($self, $cur, $label, $width, $elapsed, $min, $sec, $bar, $line); ($self, $cur, $label) = @_; $label = $self->{"label"} if !defined $label; - + # Not enough space for a progress bar return if ($width = (Term::ReadKey::GetTerminalSize())[0] - 30) < 1; # Calculate the elapsed time @@ -380,11 +379,11 @@ sub update : method { $line = sprintf "\r%-14.14s [%-".$width."s] %3.0f%% %02d:%02d", $label, $bar, ($cur / $self->{"total"}) * 100, $min, $sec; # Print if changed - if (!defined $self->{"lastline"} || $self->{"lastline"} ne $line) { + if (!defined $self->{"last_line"} || $self->{"last_line"} ne $line) { # Print it print STDERR "\r$line"; # Record the current line - $self->{"lastline"} = $line; + $self->{"last_line"} = $line; } # Finished print STDERR "\n" if $cur == $self->{"total"}; @@ -410,24 +409,24 @@ use constant MAGIC_PM => "File::MMagic"; use constant MAGIC_EXEC => "file"; use constant MAGIC_SUFFIX => "suffix"; -use vars qw($MAGIC_METHOD $MAGIC); +our ($MAGIC_METHOD, $MAGIC); BEGIN { undef $MAGIC_METHOD; undef $MAGIC; } -# new: Initialize the source log file processer +# Initialize the source log file processor sub new : method { local ($_, %_); my ($class, $self, $file, $FH, $f0); ($class, $file) = @_; - + # STDIN is another class if ($file eq "-") { $class .= "::STDIN"; return $class->new(@_[1...$#_]); } - + $self = bless {}, $class; $self->{"stdin"} = 0; $self->{"keep"} = $CONF{"KEEP"}; @@ -436,12 +435,12 @@ sub new : method { $self->{"trim_suffix"} = $CONF{"TRIM_SUFFIX"}; $self->{"stdout"} = $CONF{"STDOUT"}; $self->{"tmp"} = undef; - + # Load the File::MMagic first before opening anything, or the seek # method will not be loaded into IO::Handle $self->check_magic; - $self->{"checktype"} = $file if $MAGIC_METHOD eq MAGIC_EXEC; - + $self->{"check_type"} = $file if $MAGIC_METHOD eq MAGIC_EXEC; + $self->{"file"} = rel2abs $file; ($f0, $file) = ($file, $self->{"file"}); # Open the file @@ -453,7 +452,7 @@ sub new : method { flock $FH, LOCK_EX; } $self->{"FH"} = $FH; - + # Check the file type print STDERR "Checking file type of $f0 ... " if $VERBOSE > 1; $self->{"type"} = $self->check_type; @@ -462,11 +461,11 @@ sub new : method { $self->{"io"} = $self->check_io; # Check the output file availability $self->check_output; - + return $self; } -# create_temp: Create the temporary working file +# Create the temporary working file sub create_temp : method { local ($_, %_); my ($self, $temp, $FHT); @@ -480,7 +479,7 @@ sub create_temp : method { return $FHT; } -# remove_temp: Remove the temporary working file +# Remove the temporary working file sub remove_temp : method { local ($_, %_); my ($self, $temp, $FHT); @@ -493,7 +492,7 @@ sub remove_temp : method { return; } -# read_source: Read the source file +# Read the source file sub read_source : method { local ($_, %_); my ($self, $file, $FHT, $count); @@ -515,7 +514,7 @@ sub read_source : method { return $count;; } -# write_result: Write the result file +# Write the result file sub write_result : method { local ($_, %_); my ($self, $file, $FHT, $FH, $count); @@ -528,7 +527,7 @@ sub write_result : method { flock $FH, LOCK_EX; } if ($self->{"override"} eq OVERRIDE_OVERWRITE) { - print STDERR "Outputing to $file ... " if $VERBOSE > 1; + print STDERR "Writing to $file ... " if $VERBOSE > 1; print STDERR "\n" if $VERBOSE > 2; $self->{"io"}->open_write($file, $FH); } else { @@ -536,7 +535,7 @@ sub write_result : method { print STDERR "\n" if $VERBOSE > 2; $self->{"io"}->open_append($file, $FH); } - print STDERR " Outputing result records ... " if $VERBOSE > 2; + print STDERR " Writing result records ... " if $VERBOSE > 2; seek $FHT, 0, SEEK_SET or die "$THIS_FILE: $!"; $count = 0; while (defined($_ = <$FHT>)) { @@ -549,18 +548,18 @@ sub write_result : method { return $count;; } -# check_type: Check the source file type +# Check the source file type sub check_type : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); $self = $_[0]; ($file, $FH) = ($self->{"file"}, $self->{"FH"}); - + # Check the file type checker to use $self->check_magic; die "$THIS_FILE: Cannot check STDIN from the filename suffix.\n" if $self->{"stdin"} && $MAGIC_METHOD eq MAGIC_SUFFIX; - + # Check by file name suffix # Check by file name suffix on empty files, too. # Compress::Bzip2 2 creates empty files that confuses further processing. @@ -568,19 +567,19 @@ sub check_type : method { return TYPE_GZIP if $file =~ /\.gz$/; return TYPE_BZIP2 if $file =~ /\.bz2$/; # Otherwise we assume it to be text/plain - return TYPE_PLAIN; + return TYPE_TEXT; } - + # Check the file format # Check by File::MMagic if ($MAGIC_METHOD eq MAGIC_PM) { $_ = $MAGIC->checktype_filehandle($FH); seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; - + # Check by the file program } elsif ($MAGIC_METHOD eq MAGIC_EXEC) { flock $FH, LOCK_UN; - @_ = ($MAGIC, $self->{"checktype"}); + @_ = ($MAGIC, $self->{"check_type"}); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; # Start the process @@ -597,15 +596,15 @@ sub check_type : method { flock $FH, LOCK_EX; } } - + # Check the returned file type text return TYPE_GZIP if /gzip/i; return TYPE_BZIP2 if /bzip2/i; # Default everything to text/plain - return TYPE_PLAIN; + return TYPE_TEXT; } -# check_io: Check the I/O handler to use +# Check the I/O handler to use sub check_io : method { local ($_, %_); my $self; @@ -618,12 +617,12 @@ sub check_io : method { return _private::IO::Plain->new; } -# check_output: Check the availability of the output file +# Check the availability of the output file sub check_output : method { local ($_, %_); - my ($self, $file, $dir, $suf, $temp, $FHT); + my ($self, $file, $dir, $suf); $self = $_[0]; - + if ($self->{"type"} eq TYPE_GZIP) { ($file, $dir, $suf) = fileparse $self->{"file"}, ".gz"; } elsif ($self->{"type"} eq TYPE_BZIP2) { @@ -635,38 +634,38 @@ sub check_output : method { # Trim the suffix to be removed ($file, $dir) = fileparse $dir . $file, $self->{"trim_suffix"} if defined $self->{"trim_suffix"}; - + # Is its directory writable? We need to create the temporary working - # file and possibly the ouput file there. - die "$THIS_FILE: $dir: Permission denied\n$SHORTHELP\n" + # file and possibly the output file there. + die "$THIS_FILE: $dir: Permission denied\n$SHORT_HELP\n" if !-w $dir; - + # Check the temporary working file $self->{"temp"} = $dir . $file . TMP_SUFFIX; $_ = $self->{"temp"}; # Does the temporary working file exists? - die "$THIS_FILE: $_: Temporary working file exists\n$SHORTHELP\n" + die "$THIS_FILE: $_: Temporary working file exists\n$SHORT_HELP\n" if -e $_; - + # Check the output file # STDOUT if ($self->{"stdout"}) { $self->{"output"} = undef; # STDOUT - always overwrite it $self->{"override"} = OVERRIDE_OVERWRITE; - + # Ordinary output file } else { $self->{"output"} = $dir . $file . $self->{"suffix"} . $suf; # Output exists - is it writable? if (-e $self->{"output"}) { - die "$THIS_FILE: " . $self->{"output"} . ": File exists\n$SHORTHELP\n" + die "$THIS_FILE: " . $self->{"output"} . ": File exists\n$SHORT_HELP\n" if $self->{"override"} eq OVERRIDE_FAIL; - die "$THIS_FILE: " . $self->{"output"} . ": Not a file\n$SHORTHELP\n" + die "$THIS_FILE: " . $self->{"output"} . ": Not a file\n$SHORT_HELP\n" if !-f $self->{"output"}; - die "$THIS_FILE: " . $self->{"output"} . ": Permission denied\n$SHORTHELP\n" + die "$THIS_FILE: " . $self->{"output"} . ": Permission denied\n$SHORT_HELP\n" if !-w $self->{"output"}; - + # Output does not exist - always overwrite it } else { $self->{"override"} = OVERRIDE_OVERWRITE; @@ -675,15 +674,15 @@ sub check_output : method { return; } -# check_magic: Check the file type checker to use +# Check the file type checker to use sub check_magic : method { local ($_, %_); my $self; $self = $_[0]; - + # Checked before return $MAGIC_METHOD if defined $MAGIC_METHOD; - + print STDERR "Checking file type checker to use ... " if $VERBOSE > 1; print STDERR "\n Checking File::MMagic ... " if $VERBOSE > 2; # Check if we have File::MMagic @@ -697,11 +696,11 @@ sub check_magic : method { print STDERR "no\n" if $VERBOSE > 2; $@ =~ s/^(Can't locate \S+ in \@INC).*\n/$1\n/; # ' warn "$@" if $VERBOSE == 1; - + # Looking for file from PATH print STDERR " Checking file ... " if $VERBOSE > 2; # Found in PATH - if (defined($MAGIC = whereis "file")) { + if (defined($MAGIC = where_is "file")) { print STDERR "$MAGIC\nfound " if $VERBOSE > 2; print STDERR "$MAGIC\n" if $VERBOSE > 1; warn "$THIS_FILE: We will check with $MAGIC instead\n" @@ -710,7 +709,7 @@ sub check_magic : method { } # Not found print STDERR "no\n" if $VERBOSE > 2; - + # Check by file name suffix print STDERR " Fall back using file name suffix instead\n" if $VERBOSE > 2; print STDERR "file name suffix\n" if $VERBOSE > 1; @@ -734,15 +733,15 @@ use IO::Handle; use Fcntl qw(:flock :seek); use File::Temp qw(tempfile unlink0); -# new: Initialize the source log file processer +# Initialize the source log file processor sub new : method { local ($_, %_); my ($class, $self, $file, $FH, $tmp); ($class, $file) = @_; - + # We only initialize STDIN return $file if ref($file) ne "" || $file ne "-"; - + $self = bless {}, $class; $self->{"stdin"} = 1; $self->{"keep"} = KEEP_ALL; @@ -751,17 +750,17 @@ sub new : method { $self->{"trim_suffix"} = undef; $self->{"stdout"} = 1; $self->{"tmp"} = undef; - + # Load the File::MMagic first before opening anything, or the seek # method will not be loaded into IO::Handle $self->check_magic; - + # Save STDIN to somewhere $file = "the STDIN buffer"; if ($_private::LogFile::MAGIC_METHOD eq _private::LogFile::MAGIC_EXEC) { ($FH, $tmp) = tempfile(undef, UNLINK => 1) or die "$THIS_FILE: tempfile: $!"; - $self->{"checktype"} = $tmp; + $self->{"check_type"} = $tmp; $self->{"tmp"} = $tmp; } else { undef $tmp; @@ -775,7 +774,7 @@ sub new : method { } seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 1; - + # Check the file type print STDERR "Checking file type of STDIN ... " if $VERBOSE > 1; $self->{"type"} = $self->check_type; @@ -784,16 +783,16 @@ sub new : method { $self->{"io"} = $self->check_io; # Set the output file $self->{"output"} = undef; - + # Unlink the temporarily working file first if ($_private::LogFile::MAGIC_METHOD eq _private::LogFile::MAGIC_EXEC) { unlink0($FH, $tmp) or die "$THIS_FILE: $tmp: $!"; } - + return $self; } -# create_temp: Create the temporary working file +# Create the temporary working file sub create_temp : method { local ($_, %_); $_ = $_[0]; @@ -804,7 +803,7 @@ sub create_temp : method { return $_->{"FHT"}; } -# remove_temp: Remove the temporary working file +# Remove the temporary working file sub remove_temp : method { local ($_, %_); $_ = $_[0]; @@ -824,22 +823,22 @@ BEGIN { import main; } -use vars qw($GZIP_IO $BZIP2_IO); +our ($GZIP_IO, $BZIP2_IO); BEGIN { undef $GZIP_IO; undef $BZIP2_IO; } -# new: Initialize the I/O handler interface +# Initialize the I/O handler interface sub new : method { bless {}, $_[0]; } -# check_gzip: Check for compression method of gzip +# Check for compression method of gzip sub check_gzip : method { local ($_, %_); - + # Checked before return ref($GZIP_IO)->new if defined $GZIP_IO; - + # See whether Compress::Zlib or gzip print STDERR "Checking gzip I/O handler to use ... " if $VERBOSE > 1; print STDERR "\n Checking Compress::Zlib ... " if $VERBOSE > 2; @@ -852,29 +851,29 @@ sub check_gzip : method { # Not found print STDERR "no\n" if $VERBOSE > 2; # It's OK not to warn - + # Looking for gzip from PATH print STDERR " Checking gzip... " if $VERBOSE > 2; # Found in PATH - if (defined($_ = whereis "gzip")) { + if (defined($_ = where_is "gzip")) { print STDERR "$_\nfound " if $VERBOSE > 2; print STDERR "$_\n" if $VERBOSE > 1; return ($GZIP_IO = _private::IO::Gzip::Exec->new); } # Not found print STDERR "no\n" if $VERBOSE > 2; - + print STDERR "not found\n" if $VERBOSE > 1; - die "$THIS_FILE: Necessary Compress::Zlib or gzip not available.\n$SHORTHELP\n"; + die "$THIS_FILE: Necessary Compress::Zlib or gzip not available.\n$SHORT_HELP\n"; } -# check_bzip2: Check for compression method of bzip2 +# Check for compression method of bzip2 sub check_bzip2 : method { local ($_, %_); - + # Checked before return ref($BZIP2_IO)->new if defined $BZIP2_IO; - + # See whether Compress::Bzip2 or bzip2 print STDERR "Checking bzip2 I/O handler to use ... " if $VERBOSE > 1; print STDERR "\n Checking Compress::Bzip2 ... " if $VERBOSE > 2; @@ -887,20 +886,20 @@ sub check_bzip2 : method { # Not found print STDERR "no\n" if $VERBOSE > 2; # It's OK not to warn - + # Looking for bzip2 from PATH print STDERR " Checking bzip2... " if $VERBOSE > 2; # Found in PATH - if (defined($_ = whereis "bzip2")) { + if (defined($_ = where_is "bzip2")) { print STDERR "$_\nfound " if $VERBOSE > 2; print STDERR "$_\n" if $VERBOSE > 1; return ($BZIP2_IO = _private::IO::Bzip2::Exec->new); } # Not found print STDERR "no\n" if $VERBOSE > 2; - + print STDERR "not found\n" if $VERBOSE > 1; - die "$THIS_FILE: Necessary Compress::Bzip2 or bzip2 not available.\n$SHORTHELP\n"; + die "$THIS_FILE: Necessary Compress::Bzip2 or bzip2 not available.\n$SHORT_HELP\n"; } @@ -916,7 +915,7 @@ import main; use Fcntl qw(:flock :seek); -# open_read: Open the file for reading +# Open the file for reading sub open_read : method { local ($_, %_); my ($self, $file, $FH); @@ -932,7 +931,7 @@ sub open_read : method { return; } -# open_write: Open the file for writing +# Open the file for writing sub open_write : method { local ($_, %_); my ($self, $file, $FH); @@ -948,7 +947,7 @@ sub open_write : method { return; } -# open_append: Open the file for appending +# Open the file for appending sub open_append : method { local ($_, %_); my ($self, $file, $FH); @@ -964,7 +963,7 @@ sub open_append : method { return; } -# readline: Read a line from the I/O stream +# Read a line from the I/O stream sub readline : method { local ($_, %_); my ($self, $FH); @@ -973,7 +972,7 @@ sub readline : method { return <$FH>; } -# write: Output data to the I/O stream +# Output data to the I/O stream sub write : method { local ($_, %_); my ($self, $file, $FH); @@ -983,14 +982,14 @@ sub write : method { return; } -# close: Close the I/O stream +# Close the I/O stream sub close : method { local ($_, %_); my ($self, $keep, $tmp, $file, $FH); ($self, $keep, $tmp) = @_; $keep = KEEP_ALL if @_ < 2; ($file, $FH) = ($self->{"file"}, $self->{"FH"}); - + # Restart the file if ($keep eq KEEP_RESTART) { # Empty the source file @@ -998,13 +997,12 @@ sub close : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - } - + CORE::close $FH or die "$THIS_FILE: $file: $!"; delete $self->{"FH"}; delete $self->{"file"}; - + # Delete the file if ($keep eq KEEP_DELETE) { print STDERR " Deleting file ... " if $VERBOSE > 2; @@ -1032,7 +1030,7 @@ import main; use Fcntl qw(:flock :seek); use File::Temp qw(tempfile); -# open_read: Open the file for reading +# Open the file for reading sub open_read : method { local ($_, %_); my ($self, $file, $FH); @@ -1053,7 +1051,7 @@ sub open_read : method { return; } -# open_write: Open the file for writing +# Open the file for writing sub open_write : method { local ($_, %_); my ($self, $file, $FH); @@ -1074,7 +1072,7 @@ sub open_write : method { return; } -# open_append: Open the file for appending +# Open the file for appending sub open_append : method { local ($_, %_); my ($self, $file, $FH, $gz); @@ -1089,7 +1087,7 @@ sub open_append : method { } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); import Compress::Zlib qw(gzopen); - + # Save the original data if file has content so that file size is # greater than 0. STDOUT is always of size 0. if ((stat $FH)[7] > 0) { @@ -1107,7 +1105,7 @@ sub open_append : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Decompress the buffer and save to our file print STDERR " Attaching buffer with gzopen(..., \"rb\") ... " if $VERBOSE > 2; $gzt = gzopen($FHT, "rb") or die "$THIS_FILE: tempfile: $!"; @@ -1115,7 +1113,7 @@ sub open_append : method { print STDERR " Attaching file with gzopen(..., \"wb9\") ... " if $VERBOSE > 2; $gz = gzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2; $count = 0; while (($n = $gzt->gzreadline($_)) != 0) { @@ -1125,19 +1123,19 @@ sub open_append : method { } close $FHT or die "$THIS_FILE: tempfile: $!"; print STDERR "$count records\n" if $VERBOSE > 2; - + # A whole new file } else { print STDERR " Attaching file with gzopen(..., \"wb9\") ... " if $VERBOSE > 2; $gz = gzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + $self->{"gz"} = $gz; return; } -# readline: Read a line from the I/O stream +# Read a line from the I/O stream sub readline : method { local ($_, %_); my ($self, $file, $gz, $n); @@ -1148,7 +1146,7 @@ sub readline : method { return $_; } -# write: Output data to the I/O stream +# Output data to the I/O stream sub write : method { local ($_, %_); my ($self, $file, $gz); @@ -1158,14 +1156,14 @@ sub write : method { return; } -# close: Close the I/O stream +# Close the I/O stream sub close : method { local ($_, %_); my ($self, $keep, $tmp, $file, $FH, $gz); ($self, $keep, $tmp) = @_; $keep = KEEP_ALL if @_ < 2; ($file, $FH, $gz) = ($self->{"file"}, $self->{"FH"}, $self->{"gz"}); - + # Restart the file if ($keep eq KEEP_RESTART) { # Empty the source file @@ -1173,7 +1171,7 @@ sub close : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Create empty compressed content print STDERR " Applying empty compressed content ... " if $VERBOSE > 2; $_ = gzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; @@ -1182,7 +1180,7 @@ sub close : method { undef $gz; print STDERR "done\n" if $VERBOSE > 2; } - + if (defined $gz) { $gz->gzclose and die "$THIS_FILE: $file: " . $gz->gzerror; } @@ -1190,7 +1188,7 @@ sub close : method { delete $self->{"gz"}; delete $self->{"FH"}; delete $self->{"file"}; - + # Delete the file if ($keep eq KEEP_DELETE) { print STDERR " Deleting file ... " if $VERBOSE > 2; @@ -1218,12 +1216,12 @@ import main; use Fcntl qw(:flock :seek); use File::Temp qw(tempfile); -use vars qw($EXEC); +our ($EXEC); BEGIN { undef $EXEC; } -# open_read: Open the file for reading +# Open the file for reading sub open_read : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -1238,8 +1236,8 @@ sub open_read : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "gzip" if !defined $EXEC; - + $EXEC = where_is "gzip" if !defined $EXEC; + @_ = ($EXEC, "-cdf"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1259,7 +1257,7 @@ sub open_read : method { return; } -# open_write: Open the file for writing +# Open the file for writing sub open_write : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -1274,8 +1272,8 @@ sub open_write : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "gzip" if !defined $EXEC; - + $EXEC = where_is "gzip" if !defined $EXEC; + @_ = ($EXEC, "-c9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1295,7 +1293,7 @@ sub open_write : method { return; } -# open_append: Open the file for appending +# Open the file for appending sub open_append : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -1310,8 +1308,8 @@ sub open_append : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "gzip" if !defined $EXEC; - + $EXEC = where_is "gzip" if !defined $EXEC; + # Save the original data if file has content so that file size is # greater than 0. STDOUT is always of size 0. if ((stat $FH)[7] > 0) { @@ -1329,7 +1327,7 @@ sub open_append : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Decompress the buffer and save to our file @_ = ($EXEC, "-cdf"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; @@ -1346,7 +1344,7 @@ sub open_append : method { # Restore STDIN open STDIN, "<&", $STDIN or die "$THIS_FILE: STDIN: $!"; print STDERR "done\n" if $VERBOSE > 2; - + @_ = ($EXEC, "-c9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1362,7 +1360,7 @@ sub open_append : method { # Restore STDOUT open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; - + print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2; $count = 0; while (defined($_ = <$PHT>)) { @@ -1372,7 +1370,7 @@ sub open_append : method { close $PHT or die "$THIS_FILE: $CMDT: $!"; close $FHT or die "$THIS_FILE: tempfile: $!"; print STDERR "$count records\n" if $VERBOSE > 2; - + # A whole new file } else { @_ = ($EXEC, "-c9f"); @@ -1391,12 +1389,12 @@ sub open_append : method { open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + ($self->{"CMD"}, $self->{"PH"}) = ([@_], $PH); return; } -# readline: Read a line from the I/O stream +# Read a line from the I/O stream sub readline : method { local ($_, %_); my ($self, $PH); @@ -1405,7 +1403,7 @@ sub readline : method { return <$PH>; } -# write: Output data to the I/O stream +# Output data to the I/O stream sub write : method { local ($_, %_); my ($self, $CMD, $PH); @@ -1415,14 +1413,14 @@ sub write : method { return; } -# close: Close the I/O stream +# Close the I/O stream sub close : method { local ($_, %_); my ($self, $keep, $tmp, $file, $FH, $CMD, $PH); ($self, $keep, $tmp) = @_; $keep = KEEP_ALL if @_ < 2; ($file, $FH) = ($self->{"file"}, $self->{"FH"}); - + # Restart the file if ($keep eq KEEP_RESTART) { # Empty the source file @@ -1430,10 +1428,10 @@ sub close : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Create empty compressed content print STDERR " Applying empty compressed content ... " if $VERBOSE > 2; - $EXEC = whereis "gzip" if !defined $EXEC; + $EXEC = where_is "gzip" if !defined $EXEC; @_ = ($EXEC, "-c9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1450,7 +1448,7 @@ sub close : method { open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + ($CMD, $PH) = (join(" ", @{$self->{"CMD"}}), $self->{"PH"}); CORE::close $PH or die "$THIS_FILE: $CMD: $!"; CORE::close $FH or die "$THIS_FILE: $file: $!"; @@ -1458,7 +1456,7 @@ sub close : method { delete $self->{"CMD"}; delete $self->{"FH"}; delete $self->{"file"}; - + # Delete the file if ($keep eq KEEP_DELETE) { print STDERR " Deleting file ... " if $VERBOSE > 2; @@ -1486,7 +1484,7 @@ import main; use Fcntl qw(:flock :seek); use File::Temp qw(tempfile); -# open_read: Open the file for reading +# Open the file for reading sub open_read : method { local ($_, %_); my ($self, $file, $FH); @@ -1507,7 +1505,7 @@ sub open_read : method { return; } -# open_write: Open the file for writing +# Open the file for writing sub open_write : method { local ($_, %_); my ($self, $file, $FH); @@ -1528,7 +1526,7 @@ sub open_write : method { return; } -# open_append: Open the file for appending +# Open the file for appending sub open_append : method { local ($_, %_); my ($self, $file, $FH, $bz); @@ -1543,7 +1541,7 @@ sub open_append : method { } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); import Compress::Bzip2 qw(bzopen); - + # Save the original data if file has content so that file size is # greater than 0. STDOUT is always of size 0. if ((stat $FH)[7] > 0) { @@ -1561,7 +1559,7 @@ sub open_append : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Decompress the buffer and save to our file print STDERR " Attaching buffer with bzopen(..., \"rb\") ... " if $VERBOSE > 2; $bzt = bzopen($FHT, "rb") or die "$THIS_FILE: tempfile: $!"; @@ -1569,7 +1567,7 @@ sub open_append : method { print STDERR " Attaching file with bzopen(..., \"wb9\") ... " if $VERBOSE > 2; $bz = bzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2; $count = 0; while (($n = $bzt->bzreadline($_)) != 0) { @@ -1580,19 +1578,19 @@ sub open_append : method { } close $FHT or die "$THIS_FILE: tempfile: $!"; print STDERR "$count records\n" if $VERBOSE > 2; - + # A whole new file } else { print STDERR " Attaching file with bzopen(..., \"wb9\") ... " if $VERBOSE > 2; $bz = bzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + $self->{"bz"} = $bz; return; } -# readline: Read a line from the I/O stream +# Read a line from the I/O stream sub readline : method { local ($_, %_); my ($self, $file, $bz, $n); @@ -1603,7 +1601,7 @@ sub readline : method { return $_; } -# write: Output data to the I/O stream +# Output data to the I/O stream sub write : method { local ($_, %_); my ($self, $file, $bz); @@ -1614,14 +1612,14 @@ sub write : method { return; } -# close: Close the I/O stream +# Close the I/O stream sub close : method { local ($_, %_); my ($self, $keep, $tmp, $file, $FH, $bz); ($self, $keep, $tmp) = @_; $keep = KEEP_ALL if @_ < 2; ($file, $FH, $bz) = ($self->{"file"}, $self->{"FH"}, $self->{"bz"}); - + # Restart the file if ($keep eq KEEP_RESTART) { # Empty the source file @@ -1629,7 +1627,7 @@ sub close : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Create empty compressed content print STDERR " Applying empty compressed content ... " if $VERBOSE > 2; $_ = bzopen($FH, "wb9") or die "$THIS_FILE: $file: $!"; @@ -1638,7 +1636,7 @@ sub close : method { undef $bz; print STDERR "done\n" if $VERBOSE > 2; } - + if (defined $bz) { $bz->bzclose and die "$THIS_FILE: $file: " . $bz->bzerror; } @@ -1646,7 +1644,7 @@ sub close : method { delete $self->{"bz"}; delete $self->{"FH"}; delete $self->{"file"}; - + # Delete the file if ($keep eq KEEP_DELETE) { print STDERR " Deleting file ... " if $VERBOSE > 2; @@ -1674,12 +1672,12 @@ import main; use Fcntl qw(:flock :seek); use File::Temp qw(tempfile); -use vars qw($EXEC); +our ($EXEC); BEGIN { undef $EXEC; } -# open_read: Open the file for reading +# Open the file for reading sub open_read : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -1694,8 +1692,8 @@ sub open_read : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "bzip2" if !defined $EXEC; - + $EXEC = where_is "bzip2" if !defined $EXEC; + @_ = ($EXEC, "-cdf"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1715,7 +1713,7 @@ sub open_read : method { return; } -# open_write: Open the file for writing +# Open the file for writing sub open_write : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -1730,8 +1728,8 @@ sub open_write : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "bzip2" if !defined $EXEC; - + $EXEC = where_is "bzip2" if !defined $EXEC; + @_ = ($EXEC, "-9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1751,7 +1749,7 @@ sub open_write : method { return; } -# open_append: Open the file for appending +# Open the file for appending sub open_append : method { local ($_, %_); my ($self, $file, $FH, $PH, $CMD); @@ -1766,8 +1764,8 @@ sub open_append : method { flock $FH, LOCK_UN; } ($self->{"file"}, $self->{"FH"}) = ($file, $FH); - $EXEC = whereis "bzip2" if !defined $EXEC; - + $EXEC = where_is "bzip2" if !defined $EXEC; + # Save the original data if file has content so that file size is # greater than 0. STDOUT is always of size 0. if ((stat $FH)[7] > 0) { @@ -1785,7 +1783,7 @@ sub open_append : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Decompress the buffer and save to our file @_ = ($EXEC, "-cdf"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; @@ -1802,7 +1800,7 @@ sub open_append : method { # Restore STDIN open STDIN, "<&", $STDIN or die "$THIS_FILE: STDIN: $!"; print STDERR "done\n" if $VERBOSE > 2; - + @_ = ($EXEC, "-9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1818,7 +1816,7 @@ sub open_append : method { # Restore STDOUT open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; - + print STDERR " Reading old records back from the buffer ... " if $VERBOSE > 2; $count = 0; while (defined($_ = <$PHT>)) { @@ -1828,7 +1826,7 @@ sub open_append : method { close $PHT or die "$THIS_FILE: $CMDT: $!"; close $FHT or die "$THIS_FILE: tempfile: $!"; print STDERR "$count records\n" if $VERBOSE > 2; - + # A whole new file } else { @_ = ($EXEC, "-9f"); @@ -1847,12 +1845,12 @@ sub open_append : method { open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + ($self->{"CMD"}, $self->{"PH"}) = ([@_], $PH); return; } -# readline: Read a line from the I/O stream +# Read a line from the I/O stream sub readline : method { local ($_, %_); my ($self, $PH); @@ -1861,7 +1859,7 @@ sub readline : method { return <$PH>; } -# write: Output data to the I/O stream +# Output data to the I/O stream sub write : method { local ($_, %_); my ($self, $CMD, $PH); @@ -1871,14 +1869,14 @@ sub write : method { return; } -# close: Close the I/O stream +# Close the I/O stream sub close : method { local ($_, %_); my ($self, $keep, $tmp, $file, $FH, $CMD, $PH); ($self, $keep, $tmp) = @_; $keep = KEEP_ALL if @_ < 2; ($file, $FH) = ($self->{"file"}, $self->{"FH"}); - + # Restart the file if ($keep eq KEEP_RESTART) { my ($CMD, $PH); @@ -1887,10 +1885,10 @@ sub close : method { seek $FH, 0, SEEK_SET or die "$THIS_FILE: $file: $!"; truncate $FH, 0 or die "$THIS_FILE: $file: $!"; print STDERR "done\n" if $VERBOSE > 2; - + # Create empty compressed content print STDERR " Applying empty compressed content ... " if $VERBOSE > 2; - $EXEC = whereis "bzip2" if !defined $EXEC; + $EXEC = where_is "bzip2" if !defined $EXEC; @_ = ($EXEC, "-9f"); @_ = map "\"$_\"", @_ if $^O eq "MSWin32"; $CMD = join " ", @_; @@ -1907,7 +1905,7 @@ sub close : method { open STDOUT, ">&", $STDOUT or die "$THIS_FILE: STDOUT: $!"; print STDERR "done\n" if $VERBOSE > 2; } - + ($CMD, $PH) = (join(" ", @{$self->{"CMD"}}), $self->{"PH"}); CORE::close $PH or die "$THIS_FILE: $CMD: $!"; CORE::close $FH or die "$THIS_FILE: $file: $!"; @@ -1915,7 +1913,7 @@ sub close : method { delete $self->{"CMD"}; delete $self->{"FH"}; delete $self->{"file"}; - + # Delete the file if ($keep eq KEEP_DELETE) { print STDERR " Deleting file ... " if $VERBOSE > 2; @@ -1938,7 +1936,7 @@ use 5.008; use strict; use warnings; -# parse_line: Parse the line to get an IP address +# Parse the line to get an IP address sub parse_line : method { local ($_, %_); $_ = $_[1]; @@ -1948,7 +1946,7 @@ sub parse_line : method { return; } -# replace_line: Replace the line with the resolved result +# Replace the line with the resolved result sub replace_line : method { local ($_, %_); $_ = $_[1]; @@ -1968,7 +1966,7 @@ import main; use Socket qw(inet_aton AF_INET); -use vars qw(%H_ERRNO %WSAERROR); +our (%H_ERRNO, %WSA_ERROR); BEGIN { %H_ERRNO = (-1 => "NETDB_INTERNAL", 0 => "NETDB_SUCCESS", @@ -1977,7 +1975,7 @@ BEGIN { 3 => "NO_RECOVERY", 4 => "NO_DATA"); # Windows Sockets Error Codes -%WSAERROR = ( 10093 => "WSANOTINITIALISED", +%WSA_ERROR = ( 10093 => "WSANOTINITIALISED", 10050 => "WSAENETDOWN", 11001 => "WSAHOST_NOT_FOUND", 11002 => "WSATRY_AGAIN", @@ -1989,7 +1987,7 @@ BEGIN { 10004 => "WSAEINTR"); } -# new: Initialize the resolver +# Initialize the resolver sub new : method { local ($_, %_); my ($class, $self); @@ -1997,29 +1995,29 @@ sub new : method { $self = bless {}, $class; $self->{"threaded"} = 0; $self->{"IP"} = []; - $self->{"PKIP"} = {}; + $self->{"PK_IP"} = {}; $self->{"RESULT"} = {}; $self->{"DONE"} = 0; return $self; } -# add: Add an IP address +# Add an IP address sub add : method { local ($_, %_); - my ($self, $ip, $pkip); + my ($self, $ip, $pk_ip); ($self, $ip) = @_; # Skip malformed lines return unless defined $ip; # Skip duplicated IP - return if exists ${$self->{"PKIP"}}{$ip}; + return if exists ${$self->{"PK_IP"}}{$ip}; # Skip malformed IP - return unless defined($pkip = inet_aton $ip); + return unless defined($pk_ip = inet_aton $ip); push @{$self->{"IP"}}, $ip; - ${$self->{"PKIP"}}{$ip} = $pkip; + ${$self->{"PK_IP"}}{$ip} = $pk_ip; return; } -# result: Return the resolved result of an IP address +# Return the resolved result of an IP address sub result : method { local ($_, %_); my ($self, $ip); @@ -2028,33 +2026,33 @@ sub result : method { return $ip; } -# sort: Sort the IP +# Sort the IP sub sort : method { local ($_, %_); - my ($self, $IP, $PKIP); + my ($self, $IP, $PK_IP); $self = $_[0]; - ($IP, $PKIP) = ($self->{"IP"}, $self->{"PKIP"}); - $IP = [CORE::sort { $$PKIP{$a} cmp $$PKIP{$b} } @$IP]; + ($IP, $PK_IP) = ($self->{"IP"}, $self->{"PK_IP"}); + $IP = [CORE::sort { $$PK_IP{$a} cmp $$PK_IP{$b} } @$IP]; return; } -# resolve_all: Resolve the collected IP +# Resolve the collected IP sub resolve_all : method { local ($_, %_); my ($self, $t0, $IP, $RESULT); $self = $_[0]; ($IP, $RESULT) = ($self->{"IP"}, $self->{"RESULT"}); $t0 = time; - print STDERR "Resolving IP ... " if ($VERBOSE == 1 || $VERBOSE == 2) && !$CONF{"PROGBAR"}; - - # Sort to group neighber IP together for faster process + print STDERR "Resolving IP ... " if ($VERBOSE == 1 || $VERBOSE == 2) && !$CONF{"IS_PROGRESS_BAR"}; + + # Sort to group neighbor IP together for faster process $self->sort; - $PROGBAR = _private::ProgressBar->new("", scalar(@$IP)); + $PROGRESS_BAR = _private::ProgressBar->new("", scalar(@$IP)); for ($_ = 0; $_ < @$IP; $_++) { $self->resolve_ip($_); } - - print STDERR "done\n" if ($VERBOSE == 1 || $VERBOSE == 2) && !$CONF{"PROGBAR"}; + + print STDERR "done\n" if ($VERBOSE == 1 || $VERBOSE == 2) && !$CONF{"IS_PROGRESS_BAR"}; printf STDERR "Resolved %d IP from %d (%3.2f%%) in %d seconds\n", scalar(keys %$RESULT), scalar(@$IP), scalar(keys %$RESULT)*100/scalar(@$IP), @@ -2063,17 +2061,17 @@ sub resolve_all : method { return; } -# show_result: Show the result +# Show the result sub show_result : method { local ($_, %_); my ($self, $idx, $result, $IP, $label); ($self, $idx, $result) = @_; $IP = $self->{"IP"}; # Show the progress bar - if ($CONF{"PROGBAR"}) { + if ($CONF{"IS_PROGRESS_BAR"}) { $self->{"DONE"}++; $label = sprintf "%d/%d", $self->{"DONE"}, scalar(@$IP); - $PROGBAR->update($self->{"DONE"}, $label); + $PROGRESS_BAR->update($self->{"DONE"}, $label); # Show detail result } elsif ($VERBOSE > 2) { printf STDERR "[%d/%d] %s => %s\n", @@ -2085,33 +2083,33 @@ sub show_result : method { # Methods below are specific to DNS reverse-resolve, but can be overwrite for other type # of resolving, like GeoIP. -# resolve_ip: Resolve an IP +# Resolve an IP sub resolve_ip : method { local ($_, %_); my ($self, $idx, $ip, $name, $result, $errno); ($self, $idx) = @_; $ip = ${$self->{"IP"}}[$idx]; $? = 0 if $? != 0; - $name = gethostbyaddr ${$self->{"PKIP"}}{$ip}, AF_INET; + $name = gethostbyaddr ${$self->{"PK_IP"}}{$ip}, AF_INET; $errno = $?; # Found if (defined $name) { ${$self->{"RESULT"}}{$ip} = $name; $result = $name; - + # Not found } else { - # MSWin32 use Windows Sockets Error Codes + # MSWin32 use Windows Sockets Error Codes if ($^O eq "MSWin32") { # Error not returned if (!defined $errno) { $result = "failed (no error given)"; # Error not defined - } elsif (!exists $WSAERROR{$errno}) { + } elsif (!exists $WSA_ERROR{$errno}) { $result = "failed (error = $errno)"; # Report the error } else { - $result = "failed ($WSAERROR{$errno})"; + $result = "failed ($WSA_ERROR{$errno})"; } # Others use h_errno } else { @@ -2154,41 +2152,41 @@ sub resolve_in_a_thread($$); use Fcntl qw(:flock); -# new: Initialize the resolver +# Initialize the resolver sub new : method { my ($class, $self); $class = $_[0]; $self = $class->SUPER::new; $self->{"threaded"} = 1; - $self->{"CURINDEX"} = 0; + $self->{"CURRENT_INDEX"} = 0; share $self->{"IP"}; - share $self->{"PKIP"}; + share $self->{"PK_IP"}; share $self->{"RESULT"}; share $self->{"DONE"}; - share $self->{"CURINDEX"}; + share $self->{"CURRENT_INDEX"}; return $self; } -# resolve_all: Resolve the collected IP +# Resolve the collected IP sub resolve_all : method { local ($_, %_); my ($self, $t0, $IP, $RESULT); $self = $_[0]; ($IP, $RESULT) = ($self->{"IP"}, $self->{"RESULT"}); $t0 = time; - print STDERR "Resolving IP ... " if ($VERBOSE == 1 || $VERBOSE == 2) && !$CONF{"PROGBAR"}; - - # Sort to group neighber IP together for faster process + print STDERR "Resolving IP ... " if ($VERBOSE == 1 || $VERBOSE == 2) && !$CONF{"IS_PROGRESS_BAR"}; + + # Sort to group neighbor IP together for faster process $self->sort; - $PROGBAR = _private::ProgressBar->new("", scalar(@$IP)); + $PROGRESS_BAR = _private::ProgressBar->new("", scalar(@$IP)); # Start the thread workers for ($_ = 0, @_ = qw(); $_ < $CONF{"THREADS"}; $_++) { push @_, threads->new(\&resolve_in_a_thread, $self, $_+1); } # Wait for everyone to end $_->join foreach @_; - - print STDERR "done\n" if ($VERBOSE == 1 || $VERBOSE == 2) && !$CONF{"PROGBAR"}; + + print STDERR "done\n" if ($VERBOSE == 1 || $VERBOSE == 2) && !$CONF{"IS_PROGRESS_BAR"}; printf STDERR "Resolved %d IP from %d (%3.2f%%) in %d seconds\n", scalar(keys %$RESULT), scalar(@$IP), scalar(keys %$RESULT)*100/scalar(@$IP), @@ -2197,7 +2195,7 @@ sub resolve_all : method { return; } -# show_result: Show the result +# Show the result sub show_result : method { local ($_, %_); my ($self, $idx, $result, $IP, $label); @@ -2206,11 +2204,11 @@ sub show_result : method { # Lock to prevent simultaneous write to STDERR flock STDERR, LOCK_EX; # Show the progress bar - if ($CONF{"PROGBAR"}) { + if ($CONF{"IS_PROGRESS_BAR"}) { lock $self->{"DONE"}; $self->{"DONE"}++; $label = sprintf "%d/%d", $self->{"DONE"}, scalar(@$IP); - $PROGBAR->update($self->{"DONE"}, $label); + $PROGRESS_BAR->update($self->{"DONE"}, $label); # Show detail result } elsif ($VERBOSE > 2) { printf STDERR "[t%d:%d/%d] %s => %s\n", @@ -2221,7 +2219,7 @@ sub show_result : method { return; } -# resolve_in_a_thread: Proform URL checks in a thread +# Perform URL checks in a thread sub resolve_in_a_thread($$) { local ($_, %_); my ($self, $tno, $IP); @@ -2235,7 +2233,7 @@ sub resolve_in_a_thread($$) { } # Check until the end $self->resolve_ip($_) - while ($_ = $self->newidx) < @$IP; + while ($_ = $self->new_idx) < @$IP; if ($VERBOSE > 2) { flock STDERR, LOCK_EX; print STDERR "Thread $tno finished.\n"; @@ -2244,13 +2242,13 @@ sub resolve_in_a_thread($$) { return; } -# newidx: Obtain a new index -sub newidx($$) { +# Obtain a new index +sub new_idx($$) { local ($_, %_); my $self; $self = $_[0]; - lock $self->{"CURINDEX"}; - return $self->{"CURINDEX"}++; + lock $self->{"CURRENT_INDEX"}; + return $self->{"CURRENT_INDEX"}++; } @@ -2267,40 +2265,37 @@ reslog - Reverse-resolve IP in Apache log files =head1 DESCRIPTION -F resolves IPs in L log files. The result can -then be analyzed by another program, like Analog. You can think -of it as a replacement of the L C -directive, in the sense that it resolves client IPs altogether once a -day. +F resolves IPs in L log files. The result can then +be analyzed by another program, like Analog. You can think of it as a +replacement of the L C directive, in the +sense that it batch resolves client IPs once a day. -I. This is mainly caused by resolving: +I. This is mainly caused by the look up: Network packets may be filtered by firewalls; DNS servers may not be correctly configured; may not be up working; may sit in slow network sections; may be old slow machines; may have traffic jam... etc. All -these reasons are out of our control. +these problems are c our control. If it stops in the middle of its execution, as when the user hits a C, it may leave a temporary working file. The next time -it runs, it will stop when it sees that temporary working file at the +it runs, it stops when it sees that temporary working file at the first sight. Please process that file first. You can resolve it again, just like an ordinary log file. -This prorgam needs temporary working space. Between memory and disk -space, I choose disk space, since it is cheaper and may be available -in more environments. However, this means that it needs free -temporary disk space about 2 times of the size of the source log log -file (10 times if using memory). Please make sure you have that much -free space. +F needs temporary working space. Disk space is cheaper and is +more available than memory. However, this means that it needs free +temporary disk space about 2 times of the size of the source log file +(10 times if using memory). Please make sure you have that much free +space. -I suggest you to install L instead of -counting on the file executable. The internal magic file of -L seems to work better than the +I suggest that you install L instead +of counting on the L executable. The internal magic +file of L works better than the L executable. F treats everything not L nor L compressed as plain text. When a compressed log file is wrongly recognized as an image, -F will treat it as plain text, read log records directly from -it and fail. This failure does not hurt the source log files, but is -still annoying. +F treats it as plain text, reads directly from it, and fails. +This does not hurt the source log files, but is still annoying. =head1 OPTIONS @@ -2308,68 +2303,66 @@ still annoying. =item logfile -The log file to be resolved. If not specified, it will read from -C and output to C. You can also specify C<-> to read -from C. Multiple log files are supported. If one of these -files are C, it will output to C. L -or L compressed files are supported, too. +The log file to be resolved. You can specify multiple log files. If +not specified, it reads from C and outputs to C. You +can also specify C<-> to read from C. Result of C +goes to C. gzip or bzip2 compressed files are supported. -=item -k,--keep mode +=item -k, --keep mode -What to keep in the source file. Currently the following modes are -supported: +What to keep in the source file. The following modes are supported: =over -=item a,all +=item a, all Keep the source file after records are resolved. -=item r,restart +=item r, restart Restart the source file after records are resolved. -=item d,delete +=item d, delete Delete the source file after records are resolved. This is the default. =back -=item -o,--override mode +=item -o, --override mode -Whether we should overwrite the existing resolved files. Currently -the following modes are supported: +What to do with the existing resolved files. The following modes are +supported: =over -=item o,overwrite +=item o, overwrite Overwrite any existing target file. -=item a,append +=item a, append Append the records to the existing target file. -=item f,fail +=item f, fail Stop processing whenever a target file exists, to prevent destroying any existing files by accident. This is the default. =back -=item -s,--suffix suf +=item -s, --suffix suf The suffix to be appended to the output file. If not specified, the default is C<.resolved>. -=item -t,--trim-suffix suf +=item -t, --trim-suffix suf The suffix to be trimmed from the input file name before appending the above suffix. Default is none. If you are running several log file filters, this can help you trim the suffix of the previous one. -=item -n,--num-threads n +=item -n, --num-threads n Number of threads to run simultaneously. The default is 10. Use 0 to disable threading. This option has no effect on systems that does @@ -2385,7 +2378,7 @@ Show the detailed debugging messages. =item -q, --quiet -Shihhhhhh. Only yell when errors. +Hush! Only yell on error. =item -h, --help @@ -2422,20 +2415,10 @@ along with this program. If not, see L. imacat . -You may visit reslog's website at: -L, -L or -L. - =head1 BUGS -reslog has a mailing list reslog-users@lists.sourceforge.net. If you -have any question, comment, bug report, patch, please send it to the -mailing list. You may join the mailing list at -L. Do not -send mails directly to me unless you have private business with me. -The mailing list has an archive. People having the same trouble as -you may search the archive, find the answer and save a lot of time. +The F project is hosted on GitHub. Address your issues on the +GitHub issue tracker https://github.com/imacat/reslog/issues. =head1 TODO diff --git a/reslog.en.html b/reslog.en.html deleted file mode 100644 index eeb81c2..0000000 --- a/reslog.en.html +++ /dev/null @@ -1,515 +0,0 @@ - - - - - - - - - - - - - - - -reslog Version 3.16 - - - -
- 正體中文 | - 简体中文 | - English -
-
- - -
- - -

reslog Version 3.16

- - -

What’s New?

- -
- -
2007-12-04
- -
-

reslog version 3.16 is released. This release fixed a bug with empty files created with Compress::Bzip2. Download reslog version 3.16.

-
- - -
2007-12-03
- -
-

reslog version 3.15 is released. Fixed the minimal required Perl version in the Makefile.PL installation. Upgrade is not necessary if you have installed reslog version 3.13 or later. Download reslog version 3.15.

-
- - -
2007-12-03
- -
-

reslog version 3.14 is released. There are several documentation and test suite fixes. Upgrade is not necessary if you have installed reslog version 3.13. Download reslog version 3.14.

-
- - -
2007-12-03
- -
-

reslog version 3.13 is released. There are many code enhancements, bug fixes, test suite enhancements and documentation fixes. Download reslog version 3.13.

-
- - -
2007-07-23
- -
-

reslog version 3.12 is released. Fixed the error when there is no IP to be resolved. Download reslog version 3.12.

-
- - -
2007-07-23
- -
-

reslog version 3.11 is released. Fixed the problem with non-threaded Perl. Fixed the bug checking STDIN file type with the file program. Moved files back to the Perl default installation directories. Added support for installation with Module::Build. Download reslog version 3.11.

-
- - -
2007-07-22
- -
-

reslog version 3.10 is released. Documentation fixes. Download reslog version 3.10.

-
- - -
2007-07-21
- -
-

reslog version 3.09 is released. License updated to GPLv3, and various fixes. Download reslog version 3.09.

-
- - -
2005-05-22
- -
-

reslog version 3.08 is released. Documentation fixes. Download reslog version 3.08.

-
- - -
2005-05-22
- -
-

reslog version 3.07 is released. Clean up the code so that it works on more platforms. Now it works on Linux, MS-Windows, Cygwin, Solaris, FreeBSD and MacOSX Darwin. Download reslog version 3.07.

-
- - -
2005-05-16
- -
-

reslog version 3.06 is released. Rewrite the test suite so that the result is more correct, accuate and meaningful. Download reslog version 3.06.

-
- - -
2005-05-08
- -
-

reslog version 3.05 is released. Fixed a bug that unavailable STDIN may cause error. Download reslog version 3.05.

-
- - -
2005-05-08
- -
-

reslog version 3.04 is released. Fixed a typo when loading File::MMagic. Download reslog version 3.04.

-
- - -
2005-05-08
- -
-

reslog version 3.03 is released. Default installation directory moved back to /sbin. make upgrade is added to remove files from the old versions. flock() policy is redesigned for consistency and less errors. Download reslog version 3.03.

-
- - -
2005-05-02
- -
-

reslog version 3.02 is released. Resolver is now independent from the main program. Successfully tested and run on MS-Windows and Cygwin. Several small bugs are solved. Download reslog version 3.02.

-
- - -
2005-04-26
- -
-

reslog version 3.01 is released. A serious bug that --suffix and --trim-suffix was obtaining wrong value is fixed. You should upgrade to version 3.01 immediately if you were using 3.00. Download reslog version 3.01.

-
- - -
2005-04-26
- -
-

reslog version 3.00 is released. I rewrote everything. The code is now object-oriented. ithreads Threading support is added so that it is really fast now. bzip2 compression is supported. Compressing and decompressing using gzip and bzip2 executables without installing Compress::Zlib and Compress::Bzip2 is now possible, although discouraged. Certain file name suffix can be removed before outputing the result file, so that it can be line-up with other log file filters. Download reslog version 3.00.

-
- - -
2002-09-18
- -
-

reslog.pl version 2.1.0dev2 is released. This release corrects several documentation errors. It also adds SourceForge in the documentations as one of the sources of reslog.pl. You can think of it as a Source Forge Memorial Release. :p You don’t have to upgrade to this version in a rush. Download reslog.pl version 2.1.0dev2.

-
- - -
2002-09-17
- -
-

reslog.pl is hosted at SourceForge now! Congratulations! (Although I’m still trying hard to get it working at this time… ^^; )

-
- - -
2002-08-31
- -
-

reslog.pl version 2.1.0dev1 is released. This release fixes the problem that it wouldn’t run with Perl 5.8.0. I marked it as dev because I wish I can implement Compress::Bzip2 and ExtUtils::MakeMaker in the 2.1.0 stable release. But it is is in fact very stable. Download reslog.pl version 2.1.0dev1.

-
- -
- - -

Description

- -

reslog reverse-resolves IP in the Apache log files. These log files can then be analyzed by another program, like Analog. You can think of it as a replacement of Apache HostNameLookups directive, in the sense that it resolves the client IP altogether once a day.

- - -

Caution

- -
    - -
  • Resolving takes long time. This is mainly caused by resolving: Network packets may be filtered by firewalls; DNS servers may not be correctly configured; may not be up working; may sit in slow network sections; may be old slow machines; may have traffic jam… etc. All these reasons are out of our control.

  • - -
  • If it stops in the middle of its execution, as when the user hits a Ctrl-Break, it may leave a temporary working file. The next time it runs, it will stop when it sees that temporary working file at the first sight. Please process that file first. You can resolve it again, just like an ordinary log file.

  • - -
  • This prorgam needs temporary working space. Between memory and disk space, I choose disk space, since it is cheaper and may be available in more environments. However, this means that it needs free temporary disk space about 2 times of the size of the uncompressed source log log file (10 times if using memory). Please make sure you have that much free space.

  • - -
  • reslog does not support IPv6 yet.

  • - -
  • I suggest you to install File::MMagic instead of counting on the file executable. The internal magic file of File::MMagic seems to work better than the file executable. reslog treats everything not gzip nor bzip2 compressed as plain text. When a compressed log file is wrongly recognized as an image, reslog will treat it as plain text, read log records directly from it and fail. This failure does not hurt the source log files, but is still annoying.

  • - -
- - -

System Requirement

- -
    -
  1. Perl, version 5.8.0 or above. reslog uses 3-argument open() to duplicate filehandles, which is only supported since 5.8.0. I have not successfully port this onto earlier versions yet. Please tell me if you made it. You can run perl -v to see your current Perl version. If you do not have Perl, or if you have an older version of Perl, you can download and install/upgrade it from Perl website. If you are using MS-Windows, you can download and install ActiveState ActivePerl.

  2. - -
  3. Required Perl modules: None.

  4. - -
  5. Optional Perl modules:

    - -
    -
    File::MMagic
    - -
    -

    This is used to check the file type. If this is not available, reslog will look for the file executable instead. If that is not available, too, reslog will judge the file type by its name suffix (extension). In that case reslog will fail when reading from STDIN. You can download and install File::MMagic from the CPAN archive, or install it with the CPAN shell by running cpan File::MMagic, or install it with the CPANPLUS shell by running cpanp i Term::ReadKey. Debian/Ubandu Linux users can install it by running apt-get install libfile-mmagic-perl. Red Hat/Fedora/CentOS Linux users can install it by running yum install perl-File-MMagic. FreeBSD users can install it by running ports install p5-File-MMagic. ActivePerl users can install it by running ppm install File::MMagic. The alternative file.exe for MS-Windows can be obtained from the GnuWin32 home page. Be sure to save it as file.exe somewhere in your PATH.

    - -

    It is preferred to use File::MMagic. The file executable seems to make mistakes occationally.

    -
    - -
    Compress::Zlib
    - -
    -

    This is used to support read/write of gzip compressed files. It is only needed when gzip compressed files are encountered. If it is not available when needed, reslog will try to use the gzip executable instead. If that is not available, too, reslog will fail. You can download and install Compress::Zlib from the CPAN archive, or install it with the CPAN shell by running cpan Compress::Zlib, or install it with the CPANPLUS shell by running cpanp i Compress::Zlib. Debian/Ubandu Linux users can install it by running apt-get install libcompress-zlib-perl. Red Hat/Fedora/CentOS Linux users can install it by running yum install perl-Compress-Zlib. FreeBSD users can install it by running ports install p5-Compress-Zlib. ActivePerl users can install it by running ppm install Compress::Zlib. The alternative gzip.exe for MS-Windows can be obtained from the gzip home page. Be sure to save it as gzip.exe somewhere in your PATH.

    -
    - -
    Compress::Bzip2, version 2 or above
    - -
    -

    This is used to support read/write of bzip2 compressed files. It is only needed when bzip2 compressed files are encountered. If it is not available when needed, reslog will try to use the bzip2 executable instead. If that is not available, too, reslog will fail. Notice that older versions before 2 does not work, since file I/O compression were not implemented yet. You can download and install Compress::Bzip2 from the CPAN archive, or install it with the CPAN shell by running cpan Compress::Bzip2, or install it with the CPANPLUS shell by running cpanp i Compress::Bzip2. Debian/Ubandu Linux users can install it by running apt-get install libcompress-bzip2-perl. Red Hat/Fedora/CentOS Linux users can install it by running yum install perl-Compress-Bzip2. FreeBSD users can install it by running ports install p5-Compress-Bzip2. ActivePerl users can install it by running ppm install Compress::Bzip2. The alternative bzip2.exe for MS-Windows can be obtained from the bzip2 home page. Be sure to save it as bzip2.exe somewhere in your PATH.

    -
    - -
    Term::ReadKey
    - -
    -

    This is used to display the progress bar. Without this reslog won’t display the progress bar, but nothing else is different. The progress bar is a good visual representation of what reslog is currently doing. You can download and install Term::ReadKey from the CPAN archive, or install it with the CPAN shell by running cpan Term::ReadKey, or install it with the CPANPLUS shell by running cpanp i Term::ReadKey. Debian/Ubandu Linux users can install it by running apt-get install libterm-readkey-perl. Red Hat/Fedora/CentOS Linux users can install it by running yum install perl-TermReadKey. FreeBSD users can install it by running ports install p5-Term-ReadKey. ActivePerl users can install it by running ppm install Term::ReadKey.

    -
    -
    -
  6. -
- - -

Download

- -

reslog’s official websites is at…

- - - -

You can always download the newest version of reslog from…

- - - -

imacat’s PGP public key is at…

- - - - -

Install

- -

If you are upgrading from reslog 3.10 or earlier, or if you are upgrading from reslog.pl 3.02 or earlier, please read UPGRADE for some upgrade instruction.

- -

Install with ExtUtils::MakeMaker

- -

reslog uses standard Perl installation with ExtUtils::MakeMaker. Follow these steps:

- -
-% perl Makefile.PL
-% make
-% make test
-% make install
-
- -

When running make install, make sure you have the priviledge to write to the installation location. This usually requires the root priviledge.

- -

If you are using ActivePerl under MS-Windows, you should use nmake instead of make. nmake can be obtained from the Microsoft FTP site.

- -

If you want to install into another location, you can set the PREFIX. For example, to install into your home when you are not root:

- -
-% perl Makefile.PL PREFIX=/home/jessica
-
- -

Refer to the docuemntation of ExtUtils::MakeMaker for more installation options (by running perldoc ExtUtils::MakeMaker).

- - -

Install with Module::Build

- -

You can install with Module::Build instead, if you prefer. Follow these steps:

- -
-% perl Build.PL
-% ./Build
-% ./Build test
-% ./Build install
-
- -

When running ./Build install, make sure you have the priviledge to write to the installation location. This usually requires the root priviledge.

- -

If you want to install into another location, you can set the --prefix. For example, to install into your home when you are not root:

- -
-% perl Build.PL --prefix=/home/jessica
-
- -

Refer to the docuemntation of Module::Build for more installation options (by running perldoc Module::Build).

- - -

Options

- -
-./reslog [options] [logfile…]
-./reslog [-h|-v]
-
- - -
-
logfile
- -
-

The log file to be resolved. Multiple log files are supported. If not specified, it will read from STDIN and output to STDOUT. You can also specify - to read from STDIN. Result of STDIN will go to STDOUT. gzip or bzip2 compressed files are supported, too.

-
- - -
-k, --keep mode
- -
-

What to keep in the source file. Currently the following modes are supported:

- - -
-
a, all
- -
-

Keep the source file after records are archived.

-
- - -
r, restart
- -
-

Restart the source file after records are resolved.

-
- - -
d, delete
- -
-

Delete the source file after records are resolved. This is the default.

-
-
-
- - -
-o, --override mode
- -
-

Whether we should overwrite the existing resolved files. Currently the following modes are supported:

- - -
-
o, overwrite
- -
-

Overwrite existing target files.

-
- - -
a, append
- -
-

Append the records to existing target files.

-
- - -
f, fail
- -
-

Stop processing whenever a target file exists, to prevent destroying existing files by accident. This is the default.

-
-
-
- - -
-s, --suffix suf
- -
-

The suffix to be appended to the output file. If not specified, the default is .resolved.

-
- - -
-t, --trim-suffix suf
- -
-

The suffix to be trimmed from the input file name before appending the above suffix. Default is none. If you are running several log file filters, this can help you trim the suffix of the previous one.

-
- - -
-n, --num-threads num
- -
-

Number of threads to run simultaneously. The default is 10. Use 0 to disable threading. Your system must support threading itself. This option has no effect for systems that do not support threading.

-
- - -
-c, --stdout
- -
-

Output the result to STDOUT.

-
- - -
-d, --debug
- -
-

Show the detailed debugging messages. More -d to be more detailed.

-
- - -
-q, --quiet
- -
-

Shihhhhhh. Only yell when errors.

-
- - -
-h, --help
- -
-

Display the help message and exit.

-
- - -
-v, --version
- -
-

Output version information and exit.

-
-
- - -

Copyright

- -

Copyright © 2001-2007 imacat.

- -

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 3 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, see <http://www.gnu.org/licenses/>.

- - -

Release Notes

- -

Please read the NEWS for the new functions and bug fixes.

- - -

Support

- -

reslog is hosted on SourceForge, CPAN and Tavern IMACAT’s. For the latest infomation, see

- - - -

There is a reslog mailing list hosted at SourceForge. Please submit your questions, suggestions or bug reports there. It is a Mailman mailing list. For more information, see the reslog mailing list page. Alternatively, you can send a mail to the e-mail command mailbox with the subject help for a list of available e-mail commands.

- -
- - -
- - - - diff --git a/reslog.zh-cn.html b/reslog.zh-cn.html deleted file mode 100644 index 3163f47..0000000 --- a/reslog.zh-cn.html +++ /dev/null @@ -1,521 +0,0 @@ - - - - - - - - - - - - - - - -reslog 3.16 版 - - - -
- 正體中文 | - 简体中文 | - English -
-
- - -
- - -

reslog 3.16 版

- - -

最新消息

- -
- -
2007-12-04
- -
-

reslog 最新版本 3.16 。新版修正 Compress::Bzip2 制作的空档所产生的问题。下载 reslog 3.16 版

-
- - -
2007-12-03
- -
-

reslog 最新版本 3.16 。修正 Makefile.PL 安装所需最低 Perl 版本的错误。若你之前安装了 reslog 3.13 版或之后的版本,不需要升级新版。下载 reslog 3.16 版

-
- - -
2007-12-03
- -
-

reslog 最新版本 3.14 。新版有好几个说明文件、测试程式修正。若你之前安装了 reslog 3.13 版,不需要升级新版。下载 reslog 3.14 版

-
- - -
2007-12-03
- -
-

reslog 最新版本 3.13 。新版有很多程式码改进、错误修正、测试程式改进、说明文件修正。下载 reslog 3.13 版

-
- - -
2007-07-23
- -
-

reslog 最新版本 3.12 。修正无 IP 反解时的错误。下载 reslog 3.12 版

-
- - -
2007-07-23
- -
-

reslog 最新版本 3.11 。修正在无线程 Perl 上执行的问题,以 file 程式检查标准输入档案类型的问题,修正安装档案位置以符合 Perl 标准安装设定,并加上支援用 Module::Build 安装。下载 reslog 3.11 版

-
- - -
2007-07-22
- -
-

reslog 最新版本 3.10 。说明文件修正。下载 reslog 3.10 版

-
- - -
2007-07-21
- -
-

reslog 最新版本 3.09 。版权更新为 GPLv3 ,及多项问题修正。下载 reslog 3.09 版

-
- - -
2005-05-22
- -
-

reslog 最新版本 3.08 。说明文件修正。下载 reslog 3.08 版

-
- - -
2005-05-22
- -
-

reslog 最新版本 3.07 。重整程式码,以便在更多平台上执行。目前可在下列平台上执行: LinuxMS-WindowsCygwinSolarisFreeBSDMacOSX Darwin下载 reslog 3.07 版

-
- - -
2005-05-16
- -
-

reslog 最新版本 3.06 。重整测试程式,以使测试结果更正确、有效。下载 reslog 3.06 版

-
- - -
2005-05-08
- -
-

reslog 最新版本 3.05 。修正标准输入不可用时会产生错误的问题。下载 reslog 3.05 版

-
- - -
2005-05-08
- -
-

reslog 最新版本 3.04 。修正载入 File::MMagic 时的别字。下载 reslog 3.04 版

-
- - -
2005-05-08
- -
-

reslog 最新版本 3.03 。预设安装目录改回到 /sbin ,加上 make upgrade 以删除旧版档案,并解决了之前档案锁定方法不一的问题。下载 reslog 3.03 版

-
- - -
2005-05-02
- -
-

reslog 最新版本 3.02 。反查程式现在与主程式互相独立,在 MS-WindowsCygwin 上测试执行无误,并解决了好几个小问题。下载 reslog 3.02 版

-
- - -
2005-04-26
- -
-

reslog 最新版本 3.01 。修正了一个严重的错误,错使 --suffix--trim-suffix 处理了错误的档尾。若你下载安装了 3.01 版,请立即升级更新。下载 reslog 3.01 版

-
- - -
2005-04-26
- -
-

reslog 最新版本 3.00 。我用物件导向模式,从头重写。新加上 ithreads 多线程功能,大幅加快执行速度。支援 bzip2 压缩档。支援用 gzipbzip2 程式解压缩,不需安装 Compress::ZlibCompress::Bzip2 模组(不建议使用)。可先裁掉某些档尾,再加上我们的档尾,以便和其他记录档处理程式一起作业。下载 reslog 3.00 版

-
- - -
2002-09-18
- -
-

reslog.pl 最新版本 2.1.0dev2 。本版修正了几个说明文件的错误,并把 SourceForge 加进 reslog.pl 的下载网址中。你可以把它当做SourceForge 纪念版。原则上,不需要急著升级。下载 reslog.pl 2.1.0dev2 版

-
- - -
2002-09-17
- -
-

好消息! reslog.pl 已开始架设於 SourceForge 罗!(虽然我几乎还完全搞不清楚要怎么架…摸索中… ^^; )

-
- - -
2002-08-31
- -
-

reslog.pl 最新版本 2.1.0dev1 。本版修正了无法在 Perl 5.8.0 执行的错误。我暂时还把她当成是 dev 研发版,因为我想在 2.1.0 正式版的时候,支援 Compress::Bzip2ExtUtils::MakeMaker 。不过她其实很稳定。下载 reslog.pl 2.1.0dev2 版

-
- -
- - -

说明

- -

reslog 是记录档的反查程式,用来反查 Apache 记录档里 IP 的主机名称。查过后,可以套用像 Analog 之类的记录档统计程式。你可以把它当做 Apache HostNameLookups 指令的替代品,每天一次反查当天所有的 IP

- - -

注意事项

- -
    - -
  • 反查网域名称很耗时间。时间主要耗在查询上:防火墙过滤网路封包,网域名称伺服器设错、没有开机、位在慢速网路上、等级太低反应慢、网路塞车…等。这些外部因素,都不是程式本身能控制的。

  • - -
  • 若程式半途中断,如按了 Ctrl-Break ,可能会残余一个暂时工作档。下次执行时碰到残存的暂时工作档,程式会拒绝执行跳出。请先处理残存的暂时工作档。你可以把暂时工作档当成原来的记录档来用,重新反查。

  • - -
  • 本程式需要很多暂存资料的空间。硬碟和记忆体比起来,价格便宜,用起来也比较省,所以我用硬碟暂存。这个程式需要原记录档解压后两倍以上的硬碟空间,才能执行(用记忆体暂存的话要用十倍)。请检查硬碟空间够不够。

  • - -
  • reslog 尚未支援 IPv6

  • - -
  • 我建议安装 File::MMagic ,尽量不要用 file 程式。 File::MMagic 内建的档案类型表好像比 file 程式准确。若不是 gzipbzip2 压缩档, reslog 会把视为当成纯文字档。若压缩档被误判为图档, reslog 会当成纯文字档,直接读记录,并以错误结束。就算错误也不会弄乱原记录档,不过多少有点麻烦。

  • - -
- - -

系统需求

- -
    -
  1. Perl 5.8.0 以上。 reslog 用三个参数的 open() 来复制档案操作,我还不知道怎么改写到更早的版本上执行。若你可以改写到更早的版本上执行,请告诉我。你可以输入 perl -v 查询你目前的 Perl 版本。如果你没有 Perl 或需要升级,可以到 Perl 网站下载安装最新版 Perl 。若你是用 MS-Windows ,可以到 ActiveState 公司下载 ActivePerl 安装。

  2. - -
  3. 需搭配的 Perl 模组:无。

  4. - -
  5. 选配的 Perl 模组:

    - -
    -
    File::MMagic
    - -
    -

    这是检查档案类型用的。若没有安装, reslog 会找 file 程式代替。若还找不到, reslog 会改用档尾(副档名)判断档案类型。这时若从标准输入读档, reslog 就无法判断了。你可以CPAN 模组库下载安装 File::MMagic ,或用 CPAN Shell 执行 cpan File::MMagic 安装,或用 CPANPLUS Shell 执行 cpanp i File::MMagic 安装。若你是 Debian/Ubandu Linux 使用者,可以执行 apt-get install libfile-mmagic-perl 安装。若你是 Red Hat/Fedora/CentOS Linux 使用者,可以执行 yum install perl-File-MMagic 安装。若你是 FreeBSD 使用者,可以执行 ports install p5-File-MMagic 安装。若你是 ActivePerl 使用者,可以执行 ppm install File::MMagic 安装。若你要在 MS-Windows 下使用 file.exe 程式,可以由 GnuWin32 网站下载。请确认下载后,存档在系统的路径下,档名为 file.exe

    - -

    建议用 File::MMagicfile 程式偶尔会误判。

    -
    - -
    Compress::Zlib
    - -
    -

    这是处理 gzip 压缩档用的,只有在处理 gzip 压缩档才会用到。若要用时没有安装, reslog 会试著改用 gzip 程式代替。若还找不到, reslog 就无法执行。你可以CPAN 模组库下载安装 Compress::Zlib ,或用 CPAN Shell 执行 cpan Compress::Zlib 安装,或用 CPANPLUS Shell 执行 cpanp i Compress::Zlib 安装。若你是 Debian/Ubandu Linux 使用者,可以执行 apt-get install libcompress-zlib-perl 安装。若你是 Red Hat/Fedora/CentOS Linux 使用者,可以执行 yum install perl-Compress-Zlib 安装。若你是 FreeBSD 使用者,可以执行 ports install p5-Compress-Zlib 安装。若你是 ActivePerl 使用者,可以执行 ppm install Compress::Zlib 安装。若你要在 MS-Windows 下使用 gzip.exe 程式,可以由 gzip 网站下载。请确认下载后,存档在系统的路径下,档名为 gzip.exe

    -
    - -
    Compress::Bzip2 第二版以上
    - -
    -

    这是处理 bzip2 压缩档用的,只有在处理 bzip2 压缩档才会用到。若要用时没有安装, reslog 会试著改用 bzip2 程式代替。若还找不到, reslog 就无法执行。你可以CPAN 模组库下载安装 Compress::Bzip2 ,或用 CPAN Shell 执行 cpan Compress::Bzip2 安装,或用 CPANPLUS Shell 执行 cpanp i Compress::Bzip2 安装。若你是 Debian/Ubandu Linux 使用者,可以执行 apt-get install libcompress-bzip2-perl 安装。若你是 Red Hat/Fedora/CentOS Linux 使用者,可以执行 yum install perl-Compress-Bzip2 安装。若你是 FreeBSD 使用者,可以执行 ports install p5-Compress-Bzip2 安装。若你是 ActivePerl 使用者,可以执行 ppm install Compress::Bzip2 安装。若你要在 MS-Windows 下使用 bzip2.exe 程式,可以由 bzip2 网站下载。请确认下载后,存档在系统的路径下,档名为 bzip2.exe

    -
    - -
    Term::ReadKey
    - -
    -

    这是显示进度列用的,若没有安装,就不会显示进度列。此外不会有任何问题。进度列可以让你对 reslog 的工作进度一目了然。你可以CPAN 模组库下载安装 Term::ReadKey ,或用 CPAN Shell 执行 cpan Term::ReadKey 安装,或用 CPANPLUS Shell 执行 cpanp i Term::ReadKey 安装。若你是 Debian/Ubandu Linux 使用者,可以执行 apt-get install libterm-readkey-perl 安装。若你是 Red Hat/Fedora/CentOS Linux 使用者,可以执行 yum install perl-TermReadKey 安装。若你是 FreeBSD 使用者,可以执行 ports install p5-Term-ReadKey 安装。若你是 ActivePerl 使用者,可以执行 ppm install Term::ReadKey 安装。

    -
    -
    -
  6. -
- - -

下载

- -

reslog 的官方网站在:

- - - -

最新版 reslog 可由下列位址下载:

- - - -

依玛猫的 PGP 公钥在:

- - - - -

安装

- -

若你是由 reslog 3.10 以前的版本升级,或是由 reslog.pl 3.02 以前的版本升级,请参阅 UPGRADE.zh-cn 档的升级说明。

- -

ExtUtils::MakeMaker 安装

- -

reslogPerl 标准的 ExtUtils::MakeMaker 安装,程序如下:

- -
-% perl Makefile.PL
-% make
-% make test
-% make install
-
- -

make install 前,请先确认你有在安装目录存档的权限。通常这时候要切换为 root ,才能安装存档。

- -

若你是用 MS-Windows 下的 ActivePerlmake 请改用 nmakenmake 可由微软的 FTP 站下载

- -

若要安装到其它地方,请设定好 PREFIX 。例如,一般使用者,要安装在自己的目录下时:

- -
-% perl Makefile.PL PREFIX=/home/jessica
-
- -

要知道更多安装选项的细节,请参阅 ExtUtils::MakeMaker 的说明(请执行 perldoc ExtUtils::MakeMaker )。

- - -

Module::Build 安装

- -

若你喜欢,也可以用 Module::Build 安装,程序如下:

- -
-% perl Build.PL
-% ./Build
-% ./Build test
-% ./Build install
-
- -

./Build install 前,请先确认你有在安装目录存档的权限。通常这时候要切换为 root ,才能安装存档。

- -

若要安装到其它地方,请设定好 --prefix 。例如,一般使用者,要安装在自己的目录下时:

- -
-% perl Build.PL --prefix=/home/jessica
-
- -

要知道更多安装选项的细节,请参阅 Module::Build 的说明(请执行 perldoc Module::Build )。

- - -

命令列参数

- -
-./reslog [参数] [记录档…]
-./reslog [-h|-v]
-
- - -
-
记录档
- -
-

要反查的记录档。可同时指定好几个档案。若没有指定,会从标准输入读记录档,再写到标准输出。你也可以设定成-,来从标准输入读记录档,从标准输入读取的记录,反查后会送到标准输出。支援 gzipbzip2 压缩档。

-
- - -
-o, --override 模式
- -
-

如果有同名的反查结果档,该怎么办。目前有下列模式:

- - -
-
o, overwrite
- -
-

盖掉旧档。

-
- - -
a, append
- -
-

和旧档加在一起。

-
- - -
f, fail
- -
-

结束程式,以免不小心破坏旧档。预设是结束程式。

-
-
-
- - -
-k, --keep 模式
- -
-

原记录档要怎么处理。目前有下列模式:

- - -
-
a, all
- -
-

保留原档。

-
- - -
r, restart
- -
-

反查后,原记录档归零。

-
- - -
d, delete
- -
-

反查后,删除原记录档。预设是删除原记录档。

-
-
-
- - -
-s, --suffix 档尾
- -
-

反查结果档要加上的档尾。预设的档尾是 .resolved

-
- - -
-t, --trim-suffix 档尾
- -
-

加上我们的档尾前,先去掉的原档档尾。预设是不去档尾。若你用好几个记录档处理程式处理记录档,可以用这个选项,去掉之前程式加的档尾。

-
- - -
-n, --num-threads 线程数
- -
-

反查时,同时执行的线程数。预设值是 10 。若不要用多线程反查,请设为 0 。系统本身要支援多线程。若系统本身不支援多线程,本选项没有作用。

-
- - -
-c, --stdout
- -
-

把结果输出到标准输出。

-
- - -
-d, --debug
- -
-

显示详细的执行过程。

-
- - -
-q, --quiet
- -
-

没事不要吵。 :p

-
- - -
-h, --help
- -
-

显示程式说明。

-
- - -
-v, --version
- -
-

显示程式版本。

-
-
- - -

版权声明

- -

版权所有 © 2001-2007 依玛猫。依玛猫保有所有权利。

- -

本程式是自由软体,您可以遵照自由软体基金会 (Free Software Foundation) 出版的 GNU 通用公共许可证条款 (GNU General Public License) 第三版来修改和重新发布这一程式,或者自由选择使用任何更新的版本。

- -

发布这一程式的目的是希望它有用,但没有任何担保。甚至没有适合特定目的而隐含的担保。更详细的情况请参阅 GNU 通用公共许可证

- -

您应该已经和程式一起收到一份 GNU 通用公共许可证的副本。如果还没有,参阅<http://www.gnu.org/licenses/>

- - -

版本纪录

- -

请阅读 NEWS 档,查看程式的演变、新增的功能和修补的错误。

- - -

支援协助

- -

reslog 网站架在 SourceForgeCPAN旅舍依玛。索取最新资讯,请驾临:

- - - -

SourceForge 上有一个 reslog 的邮件通讯 。使用上的问题、建议或错误回报,请提到通讯上讨论。它是 Mailman 的邮件通讯。若要加入,请到 reslog 邮件通讯的网页 。你也可以写信到 E-mail 指令信箱,标题填上 help ,索取 E-mail 指令说明。

- -
- - -
- - - - diff --git a/reslog.zh-tw.html b/reslog.zh-tw.html deleted file mode 100644 index ea38dc2..0000000 --- a/reslog.zh-tw.html +++ /dev/null @@ -1,521 +0,0 @@ - - - - - - - - - - - - - - - -reslog 3.16  - - - -
- タ砰いゅ | - 简蔨いゅ | - English -
-
- - -
- - -

reslog 3.16 

- - -

程穝

- -
- -
2007-12-04
- -
-

reslog 程穝セ 3.16 穝タ Compress::Bzip2 籹郎┮玻ネ拜肈更 reslog 3.16 

-
- - -
2007-12-03
- -
-

reslog 程穝セ 3.15 タ Makefile.PL 杆┮惠程 Perl セ岿粇璝﹑ぇ玡杆 reslog 3.13 ┪ぇセぃ惠璶狜穝更 reslog 3.15 

-
- - -
2007-12-03
- -
-

reslog 程穝セ 3.14 穝Τ碭弧ゅン代刚祘Αタ璝﹑ぇ玡杆 reslog 3.13 ぃ惠璶狜穝更 reslog 3.14 

-
- - -
2007-12-03
- -
-

reslog 程穝セ 3.13 穝Τ祘Α絏э秈岿粇タ代刚祘Αэ秈弧ゅンタ更 reslog 3.13 

-
- - -
2007-07-23
- -
-

reslog 程穝セ 3.12 タ礚 IP は秆岿粇更 reslog 3.12 

-
- - -
2007-07-23
- -
-

reslog 程穝セ 3.11 タ礚絬祘 Perl 磅︽拜肈 file 祘Α浪琩夹非块郎摸拜肈タ杆郎竚才 Perl 夹非杆砞﹚や穿ノ Module::Build 杆更 reslog 3.11 

-
- - -
2007-07-22
- -
-

reslog 程穝セ 3.10 弧ゅンタ更 reslog 3.10 

-
- - -
2007-07-21
- -
-

reslog 程穝セ 3.09 舦穝 GPLv3 の兜拜肈タ更 reslog 3.09 

-
- - -
2005-05-22
- -
-

reslog 程穝セ 3.08 弧ゅンタ更 reslog 3.08 

-
- - -
2005-05-22
- -
-

reslog 程穝セ 3.07 俱祘Α絏獽キ磅︽ヘ玡キ磅︽ LinuxMS-WindowsCygwinSolarisFreeBSDMacOSX Darwin更 reslog 3.07 

-
- - -
2005-05-16
- -
-

reslog 程穝セ 3.06 俱代刚祘Αㄏ代刚挡狦タ絋Τ更 reslog 3.06 

-
- - -
2005-05-08
- -
-

reslog 程穝セ 3.05 タ夹非块ぃノ穦玻ネ岿粇拜肈更 reslog 3.05 

-
- - -
2005-05-08
- -
-

reslog 程穝セ 3.04 タ更 File::MMagic 更 reslog 3.04 

-
- - -
2005-05-08
- -
-

reslog 程穝セ 3.03 箇砞杆ヘ魁э /sbin  make upgrade 埃侣郎秆∕ぇ玡郎玛﹚よ猭ぃ拜肈更 reslog 3.03 

-
- - -
2005-05-02
- -
-

reslog 程穝セ 3.02 は琩祘Α瞷籔祘Αが縒ミ MS-WindowsCygwin 代刚磅︽礚粇秆∕碭拜肈更 reslog 3.02 

-
- - -
2005-04-26
- -
-

reslog 程穝セ 3.01 タ腨岿粇岿ㄏ --suffix--trim-suffix 矪瞶岿粇郎Ю璝﹑更杆 3.01 叫ミ狜穝更 reslog 3.01 

-
- - -
2005-04-26
- -
-

reslog 程穝セ 3.00 иノン旧家Α眖繷糶穝 ithreads 絬祘碩е磅︽硉や穿 bzip2 溃罽郎や穿ノ gzipbzip2 祘Α秆溃罽ぃ惠杆 Compress::ZlibCompress::Bzip2 家舱ぃ某ㄏノ掉奔琘ㄇ郎Юи郎Ю獽㎝ㄤ癘魁郎矪瞶祘Α癬穨更 reslog 3.00 

-
- - -
2002-09-18
- -
-

reslog.pl 程穝セ 2.1.0dev2 セタ碭弧ゅン岿粇р SourceForge 秈 reslog.pl 更呼い﹑рウ讽暗SourceForge ├玥ぃ惠璶帝狜更 reslog.pl 2.1.0dev2 

-
- - -
2002-09-17
- -
-

 reslog.pl 秨﹍琜砞 SourceForge 舘瘤礛и碭临Ч穌ぃ睲贰璶或琜…篘い… ^^; 

-
- - -
2002-08-31
- -
-

reslog.pl 程穝セ 2.1.0dev1 セタ礚猭 Perl 5.8.0 磅︽岿粇и既临р讽Θ琌 dev 祇и稱 2.1.0 タΑや穿 Compress::Bzip2ExtUtils::MakeMaker ぃ筁ㄤ龟铆﹚更 reslog.pl 2.1.0dev2 

-
- -
- - -

弧

- -

reslog 琌癘魁郎は琩祘Αノㄓは琩 Apache 癘魁郎 IP 诀嘿琩筁甅ノ钩 Analog ぇ摸癘魁郎参璸祘Α﹑рウ讽暗 Apache HostNameLookups 蠢珇–ぱΩは琩讽ぱ┮Τ IP

- - -

猔種ㄆ兜

- -
    - -
  • は琩呼办嘿丁丁璶琩高ň鲤筁耾呼隔呼办嘿狝竟砞岿⊿Τ秨诀篊硉呼隔单びは莱篊呼隔峨ó…单硂ㄇ场常ぃ琌祘Αセō北

  • - -
  • 璝祘Α硚い耞 Ctrl-Break 穦摧緇既郎Ω磅︽窱摧既郎祘Α穦┶荡磅︽铬叫矪瞶摧既郎﹑р既郎讽Θㄓ癘魁郎ㄓノ穝は琩

  • - -
  • セ祘Α惠璶既戈丁祑盒㎝癘拘砰ゑ癬ㄓ基獽﹜ノ癬ㄓゑ耕┮иノ祑盒既硂祘Α惠璶癘魁郎秆溃ㄢ祑盒丁磅︽ノ癘拘砰既杠璶ノ叫浪琩祑盒丁镑ぃ镑

  • - -
  • reslog ﹟ゼや穿 IPv6

  • - -
  • и某杆 File::MMagic 鲸秖ぃ璶ノ file 祘Α File::MMagic ず郎摸钩ゑ file 祘Α非絋璝ぃ琌 gzipbzip2 溃罽郎 reslog 穦р跌讽Θゅ郎璝溃罽郎砆粇瓜郎 reslog 穦讽Θゅ郎钡弄癘魁岿粇挡碞衡岿粇ぃ穦睹癘魁郎ぃ筁ぶΤ翴陈沸

  • - -
- - -

╰参惠―

- -
    -
  1. Perl 5.8.0  reslog ノ把计 open() ㄓ狡籹郎巨и临ぃ笵或э糶Νセ磅︽璝﹑э糶Νセ磅︽叫禗и﹑块 perl -v 琩高﹑ヘ玡 Perl セ狦﹑⊿Τ Perl ┪惠璶狜 Perl 呼更杆程穝 Perl 璝﹑琌ノ MS-Windows  ActiveState そ更 ActivePerl 杆

  2. - -
  3. 惠穎皌 Perl 家舱礚

  4. - -
  5. 匡皌 Perl 家舱

    - -
    -
    File::MMagic
    - -
    -

    硂琌浪琩郎摸ノ璝⊿Τ杆 reslog 穦т file 祘Α蠢璝临тぃ reslog 穦эノ郎Ю捌郎耞郎摸硂璝眖夹非块弄郎 reslog 碞礚猭耞﹑CPAN 家舱畐更杆 File::MMagic ┪ノ CPAN Shell 磅︽ cpan File::MMagic 杆┪ノ CPANPLUS Shell 磅︽ cpanp i File::MMagic 杆璝﹑琌 Debian/Ubandu Linux ㄏノ磅︽ apt-get install libfile-mmagic-perl 杆璝﹑琌 Red Hat/Fedora/CentOS Linux ㄏノ磅︽ yum install perl-File-MMagic 杆璝﹑琌 FreeBSD ㄏノ磅︽ ports install p5-File-MMagic 杆璝﹑琌 ActivePerl ㄏノ磅︽ ppm install File::MMagic 杆璝﹑璶 MS-Windows ㄏノ file.exe 祘Αパ GnuWin32 呼更叫絋粄更郎╰参隔畖郎 file.exe

    - -

    某ノ File::MMagicfile 祘Α案焊穦粇

    -
    - -
    Compress::Zlib
    - -
    -

    硂琌矪瞶 gzip 溃罽郎ノΤ矪瞶 gzip 溃罽郎穦ノ璝璶ノ⊿Τ杆 reslog 穦刚帝эノ gzip 祘Α蠢璝临тぃ reslog 碞礚猭磅︽﹑CPAN 家舱畐更杆 Compress::Zlib ┪ノ CPAN Shell 磅︽ cpan Compress::Zlib 杆┪ノ CPANPLUS Shell 磅︽ cpanp i Compress::Zlib 杆璝﹑琌 Debian/Ubandu Linux ㄏノ磅︽ apt-get install libcompress-zlib-perl 杆璝﹑琌 Red Hat/Fedora/CentOS Linux ㄏノ磅︽ yum install perl-Compress-Zlib 杆璝﹑琌 FreeBSD ㄏノ磅︽ ports install p5-Compress-Zlib 杆璝﹑琌 ActivePerl ㄏノ磅︽ ppm install Compress::Zlib 杆璝﹑璶 MS-Windows ㄏノ gzip.exe 祘Αパ gzip 呼更叫絋粄更郎╰参隔畖郎 gzip.exe

    -
    - -
    Compress::Bzip2 材
    - -
    -

    硂琌矪瞶 bzip2 溃罽郎ノΤ矪瞶 bzip2 溃罽郎穦ノ璝璶ノ⊿Τ杆 reslog 穦刚帝эノ bzip2 祘Α蠢璝临тぃ reslog 碞礚猭磅︽﹑CPAN 家舱畐更杆 Compress::Bzip2 ┪ノ CPAN Shell 磅︽ cpan Compress::Bzip2 杆┪ノ CPANPLUS Shell 磅︽ cpanp i Compress::Bzip2 杆璝﹑琌 Debian/Ubandu Linux ㄏノ磅︽ apt-get install libcompress-bzip2-perl 杆璝﹑琌 Red Hat/Fedora/CentOS Linux ㄏノ磅︽ yum install perl-Compress-Bzip2 杆璝﹑琌 FreeBSD ㄏノ磅︽ ports install p5-Compress-Bzip2 杆璝﹑琌 ActivePerl ㄏノ磅︽ ppm install Compress::Bzip2 杆璝﹑璶 MS-Windows ㄏノ bzip2.exe 祘Αパ bzip2 呼更叫絋粄更郎╰参隔畖郎 bzip2.exe

    -
    - -
    Term::ReadKey
    - -
    -

    硂琌陪ボ秈ノ璝⊿Τ杆碞ぃ穦陪ボ秈ぃ穦Τヴ拜肈秈琵﹑癸 reslog 秈ヘ罙礛﹑CPAN 家舱畐更杆 Term::ReadKey ┪ノ CPAN Shell 磅︽ cpan Term::ReadKey 杆┪ノ CPANPLUS Shell 磅︽ cpanp i Term::ReadKey 杆璝﹑琌 Debian/Ubandu Linux ㄏノ磅︽ apt-get install libterm-readkey-perl 杆璝﹑琌 Red Hat/Fedora/CentOS Linux ㄏノ磅︽ yum install perl-TermReadKey 杆璝﹑琌 FreeBSD ㄏノ磅︽ ports install p5-Term-ReadKey 杆璝﹑琌 ActivePerl ㄏノ磅︽ ppm install Term::ReadKey 杆

    -
    -
    -
  6. -
- - -

更

- -

reslog ﹛よ呼

- - - -

程穝 reslog パ更

- - - -

ㄌ嚎窟 PGP そ芲

- - - - -

杆

- -

璝﹑琌パ reslog 3.10 玡セ狜┪琌パ reslog.pl 3.02 玡セ狜叫把綷 UPGRADE.zh-tw 郎狜弧

- -

ExtUtils::MakeMaker 杆

- -

reslogPerl 夹非 ExtUtils::MakeMaker 杆祘

- -
-% perl Makefile.PL
-% make
-% make test
-% make install
-
- -

make install 玡叫絋粄﹑Τ杆ヘ魁郎舦硄盽硂璶ち传 root 杆郎

- -

璝﹑琌ノ MS-Windows  ActivePerlmake 叫эノ nmakenmake パ稬硁 FTP 更

- -

璝璶杆ㄤウよ叫砞﹚ PREFIX ㄒㄏノ璶杆ヘ魁

- -
-% perl Makefile.PL PREFIX=/home/jessica
-
- -

璶笵杆匡兜灿竊叫把綷 ExtUtils::MakeMaker 弧叫磅︽ perldoc ExtUtils::MakeMaker 

- - -

Module::Build 杆

- -

璝﹑尺舧ノ Module::Build 杆祘

- -
-% perl Build.PL
-% ./Build
-% ./Build test
-% ./Build install
-
- -

./Build install 玡叫絋粄﹑Τ杆ヘ魁郎舦硄盽硂璶ち传 root 杆郎

- -

璝璶杆ㄤウよ叫砞﹚ --prefix ㄒㄏノ璶杆ヘ魁

- -
-% perl Build.PL --prefix=/home/jessica
-
- -

璶笵杆匡兜灿竊叫把綷 Module::Build 弧叫磅︽ perldoc Module::Build 

- - -

㏑把计

- -
-./reslog [把计] [癘魁郎…]
-./reslog [-h|-v]
-
- - -
-
癘魁郎
- -
-

璶は琩癘魁郎﹚碭郎璝⊿Τ﹚穦眖夹非块弄癘魁郎糶夹非块﹑砞﹚Θ-ㄓ眖夹非块弄癘魁郎眖夹非块弄癘魁は琩穦癳夹非块や穿 gzipbzip2 溃罽郎

-
- - -
-o, --override 家Α
- -
-

狦Τは琩挡狦郎赣或快ヘ玡Τ家Α

- - -
-
o, overwrite
- -
-

籠奔侣郎

-
- - -
a, append
- -
-

㎝侣郎癬

-
- - -
f, fail
- -
-

挡祘Αぃみ瘆胊侣郎箇砞琌挡祘Α

-
-
-
- - -
-k, --keep 家Α
- -
-

癘魁郎璶或矪瞶ヘ玡Τ家Α

- - -
-
a, all
- -
-

玂痙郎

-
- - -
r, restart
- -
-

は琩癘魁郎耴箂

-
- - -
d, delete
- -
-

は琩埃癘魁郎箇砞琌埃癘魁郎

-
-
-
- - -
-s, --suffix 郎Ю
- -
-

は琩挡狦郎璶郎Ю箇砞郎Ю琌 .resolved

-
- - -
-t, --trim-suffix 郎Ю
- -
-

и郎Ю玡奔郎郎Ю箇砞琌ぃ郎Ю璝﹑ノ碭癘魁郎矪瞶祘Α矪瞶癘魁郎ノ硂匡兜奔ぇ玡祘Α郎Ю

-
- - -
-n, --num-threads 絬祘计
- -
-

は琩磅︽絬祘计箇砞琌 10 璝ぃ璶ノ絬祘は琩叫砞 0 ╰参セō璶や穿絬祘璝╰参セōぃや穿絬祘セ匡兜⊿Τノ

-
- - -
-c, --stdout
- -
-

р挡狦块夹非块

-
- - -
-d, --debug
- -
-

陪ボ冈灿磅︽筁祘

-
- - -
-q, --quiet
- -
-

⊿ㄆぃ璶 :p

-
- - -
-h, --help
- -
-

陪ボ祘Α弧

-
- - -
-v, --version
- -
-

陪ボ祘Αセ

-
-
- - -

舦羘

- -

舦┮Τ © 2001-2007 ㄌ嚎窟ㄌ嚎窟玂Τ┮Τ舦

- -

セ祘Α琌パ硁砰眤宽酚パ硁砰膀穦 (Free Software Foundation)  GNU 硄ノそ砛靡兵蹿 (GNU General Public License) 材ㄓэ㎝穝祇硂祘Α┪パ匡拒ㄏノヴ穝セ

- -

祇硂祘Αヘ琌辨ウΤノ⊿Τヴ踞玂⊿Τ続疭﹚ヘτ留踞玂冈灿薄猵叫把綷 GNU 硄ノそ砛靡

- -

眤莱赣竒㎝祘Α癬Μ GNU 硄ノそ砛靡捌セ狦临⊿Τ把綷<http://www.gnu.org/licenses/>

- - -

セ魁

- -

叫綷弄 NEWS 郎琩祘Α簍跑穝糤㎝干岿粇

- - -

や穿

- -

reslog 呼琜 SourceForgeCPANㄌ嚎程穝戈癟叫緍羬

- - - -

SourceForge Τ reslog 秎ン硄癟 ㄏノ拜肈某┪岿粇厨叫矗硄癟癚阶ウ琌 Mailman 秎ン硄癟璝璶叫 reslog 秎ン硄癟呼 ﹑糶獺 E-mail 獺絚夹肈恶 help  E-mail 弧

- -
- - -
- - - - diff --git a/t/00-signature.t b/t/00-signature.t index 1cf917c..50a7346 100755 --- a/t/00-signature.t +++ b/t/00-signature.t @@ -1,17 +1,23 @@ #!/usr/bin/perl + use strict; print "1..1\n"; -if (!-s 'SIGNATURE') { +if (!$ENV{TEST_SIGNATURE}) { + print "ok 1 # skip Set the environment variable", + " TEST_SIGNATURE to enable this test\n"; +} +elsif (!-s 'SIGNATURE') { print "ok 1 # skip No signature file found\n"; } elsif (!eval { require Module::Signature; 1 }) { print "ok 1 # skip ", - "Next time around, consider install Module::Signature, ", - "so you can verify the integrity of this distribution.\n"; + "Next time around, consider install Module::Signature, ", + "so you can verify the integrity of this distribution.\n"; } -elsif (!eval { require Socket; Socket::inet_aton('pgp.mit.edu') }) { - print "ok 1 # skip Cannot connect to the keyserver\n"; +elsif (!eval { require Socket; Socket::inet_aton('pool.sks-keyservers.net') }) { + print "ok 1 # skip ", + "Cannot connect to the keyserver\n"; } else { (Module::Signature::verify() == Module::Signature::SIGNATURE_OK()) diff --git a/t/01-exhaust.t b/t/01-exhaust.t index 5bd1f96..0b2c682 100755 --- a/t/01-exhaust.t +++ b/t/01-exhaust.t @@ -1,20 +1,19 @@ #! /usr/bin/perl -w # Test all the possible combination of options -# Copyright (c) 2005-2007 imacat -# -# 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 3 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, see . +# Copyright (c) 2005-2021 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # This file is combined from 01-plain.t, 02-gzip.t and 03-bzip2.t. @@ -32,99 +31,99 @@ use File::Spec::Functions qw(catdir catfile updir devnull); use FindBin; use lib $FindBin::Bin; use _helper; -use vars qw($WORKDIR $tno $reslog); +our ($WORKDIR, $tno, $reslog); $WORKDIR = catdir($FindBin::Bin, "logs"); $tno = 0; $reslog = catfile($FindBin::Bin, updir, "blib", "script", "reslog"); # Test each source log file type -foreach my $st (@SRCTYPES) { +foreach my $st (@SOURCE_TYPES) { # Test each source file content type - foreach my $sct (@CNTTYPES) { - # Test each keep type - foreach my $kt (@KEEPTYPES) { - # Test each override type - foreach my $ot (@OVERTYPES) { + foreach my $sct (@CONTENT_TYPES) { + # Test each keep mode + foreach my $keep (@KEEP_MODES) { + # Test each override mode + foreach my $override (@OVERRIDE_MODES) { # Test each existing file content type my @ecnttypes; - if (!$$ot{"mkex"}) { + if (!$$override{"exists"}) { # Existing file content type is meaningless # if there is no existing file. @ecnttypes = (1); } else { - # mkrndlog_noip() does not make a difference than - # mkrndlog_normal() as an existing file. - @ecnttypes = grep $$_{"title"} ne "log file without IP", - @CNTTYPES; + # make_resolved_log_file() does not make a difference than + # make_log_file() as an existing file. + @ecnttypes = grep $$_{"title"} ne "resolved log file", + @CONTENT_TYPES; } foreach my $ect (@ecnttypes) { # Test each suffix type - foreach my $suft (@SUFTYPES) { + foreach my $suffix (@SUFFICES) { # Test each trim-suffix type - foreach my $tsuft (@TSUFTYPES) { + foreach my $trim_suffix (@TRIM_SUFFIX) { $_ = eval { return if $$st{"skip"}; - my ($title, $cmd, $retno, $out, $err, $logfile); + my ($title, $cmd, $ret_no, $out, $err, $logfile); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); - my ($fs, $fo, $cs, $csr, $co, $suf, $tsuf); + my ($fs, $fo, $cs, $csr, $co, $suf, $trim_suf); rmtree $WORKDIR; mkpath $WORKDIR; $title = join ", ", $$st{"title"}, $$sct{"title"}, - $$kt{"title"}, $$ot{"title"}, - $$suft{"title"}, $$tsuft{"title"}; - $logfile = randword; - $suf = defined $$suft{"suf"}? $$suft{"suf"}: "." . randword; - if (defined $$tsuft{"suf"}) { - $tsuf = $$tsuft{"suf"}; + $$keep{"title"}, $$override{"title"}, + $$suffix{"title"}, $$trim_suffix{"title"}; + $logfile = random_word; + $suf = defined $$suffix{"suf"}? $$suffix{"suf"}: "." . random_word; + if (defined $$trim_suffix{"suf"}) { + $trim_suf = $$trim_suffix{"suf"}; } else { - do { $tsuf = "." . randword; } until $tsuf ne $suf; + do { $trim_suf = "." . random_word; } until $trim_suf ne $suf; } - $fs = catfile($WORKDIR, "$logfile$tsuf" . $$st{"suf"}); + $fs = catfile($WORKDIR, "$logfile$trim_suf" . $$st{"suf"}); ($cs, $csr) = &{$$sct{"sub"}}($fs); - if ($$ot{"mkex"}) { + if ($$override{"exists"}) { $fo = catfile($WORKDIR, "$logfile$suf" . $$st{"suf"}); $co = (&{$$ect{"sub"}}($fo))[0]; } @fle = qw(); - push @fle, basename($fs) if !($$ot{"ok"} && $$kt{"del"}); - if ($$ot{"ok"}) { + push @fle, basename($fs) if !($$override{"ok"} && $$keep{"del"}); + if ($$override{"ok"}) { push @fle, "$logfile$suf" . $$st{"suf"}; } else { - push @fle, basename($fo) if !$$kt{"del"} || $$ot{"mkex"}; + push @fle, basename($fo) if !$$keep{"del"} || $$override{"exists"}; } - prsrvsrc $WORKDIR; - @_ = ($reslog, qw(-d -d -d -n 1), @{$$kt{"opts"}}, - @{$$ot{"opts"}}, &{$$suft{"opts"}}($suf), - &{$$tsuft{"opts"}}($tsuf), $fs); + preserve_source $WORKDIR; + @_ = ($reslog, qw(-d -d -d -n 1), @{$$keep{"opts"}}, + @{$$override{"opts"}}, &{$$suffix{"opts"}}($suf), + &{$$trim_suffix{"opts"}}($trim_suf), $fs); $cmd = join " ", @_; - ($retno, $out, $err) = runcmd "", @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd "", @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file %trf = qw(); # Resulted file type by file - if (!($$ot{"ok"} && $$kt{"del"})) { + if (!($$override{"ok"} && $$keep{"del"})) { $fr = $fs; $frb = basename($fr); - $cef{$frb} = $$kt{"keep"} || !$$ot{"ok"}? $cs: ""; + $cef{$frb} = $$keep{"keep"} || !$$override{"ok"}? $cs: ""; $tef{$frb} = $$st{"type"}; - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - if ($$ot{"ok"} || $$ot{"mkex"}) { + if ($$override{"ok"} || $$override{"exists"}) { $frb = "$logfile$suf" . $$st{"suf"}; $fr = catfile($WORKDIR, $frb); - $cef{$frb} = &{$$ot{"ce"}}($co, $csr); + $cef{$frb} = &{$$override{"ce"}}($co, $csr); $tef{$frb} = $$st{"type"}; - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } die "$title\n$cmd\n$out$err" - unless $$ot{"ok"}? $retno == 0: $retno != 0; + unless $$override{"ok"}? $ret_no == 0: $ret_no != 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr} + unless has_no_file || $trf{$fr} eq $tef{$fr} || ($tef{$fr} eq TYPE_BZIP2 && -z catfile($WORKDIR, $fr)); die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; @@ -132,57 +131,57 @@ foreach my $st (@SRCTYPES) { 1; }; skip($$st{"skip"}, $_, 1, $@); - cleanup $_ || $$st{"skip"}, $WORKDIR, ++$tno; + clean_up $_ || $$st{"skip"}, $WORKDIR, ++$tno; die unless $_ || $$st{"skip"}; } } } } - + # 37: From file to STDOUT $_ = eval { return if $$st{"skip"}; - my ($title, $cmd, $retno, $out, $err, $logfile, $result); + my ($title, $cmd, $ret_no, $out, $err, $logfile, $result); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); - my ($fs, $fo, $cs, $csr, $co); + my ($fs, $cs, $csr); rmtree $WORKDIR; mkpath $WORKDIR; $title = join ", ", "From file to STDOUT", $$sct{"title"}, - $$st{"title"}, $$kt{"title"}; - $logfile = randword; - do { $result = randword; } until $result ne $logfile; + $$st{"title"}, $$keep{"title"}; + $logfile = random_word; + do { $result = random_word; } until $result ne $logfile; $fs = catfile($WORKDIR, "$logfile" . $$st{"suf"}); ($cs, $csr) = &{$$sct{"sub"}}($fs); @fle = qw(); - push @fle, basename($fs) if !$$kt{"cdel"}; + push @fle, basename($fs) if !$$keep{"cdel"}; push @fle, $result . $$st{"suf"}; - prsrvsrc $WORKDIR; - @_ = ($reslog, qw(-d -d -d -n 1 -c), @{$$kt{"opts"}}, $fs); + preserve_source $WORKDIR; + @_ = ($reslog, qw(-d -d -d -n 1 -c), @{$$keep{"opts"}}, $fs); $cmd = join " ", @_; - ($retno, $out, $err) = runcmd "", @_; - frwrite(catfile($WORKDIR, $result . $$st{"suf"}), $out); - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd "", @_; + write_raw_file(catfile($WORKDIR, $result . $$st{"suf"}), $out); + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file %trf = qw(); # Resulted file type by file - if (!$$kt{"cdel"}) { + if (!$$keep{"cdel"}) { $fr = $fs; $frb = basename($fr); - $cef{$frb} = $$kt{"ckeep"}? $cs: ""; + $cef{$frb} = $$keep{"ckeep"}? $cs: ""; $tef{$frb} = $$st{"type"}; - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } $frb = $result . $$st{"suf"}; $fr = catfile($WORKDIR, $frb); ($cef{$frb}, $tef{$frb}) = ($csr, $$st{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - die "$title\n$cmd\n$out$err" unless $retno == 0; + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + die "$title\n$cmd\n$out$err" unless $ret_no == 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr} + unless has_no_file || $trf{$fr} eq $tef{$fr} || ($tef{$fr} eq TYPE_BZIP2 && -z catfile($WORKDIR, $fr)); die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; @@ -190,33 +189,33 @@ foreach my $st (@SRCTYPES) { 1; }; skip($$st{"skip"}, $_, 1, $@); - cleanup $_ || $$st{"skip"}, $WORKDIR, ++$tno; + clean_up $_ || $$st{"skip"}, $WORKDIR, ++$tno; die unless $_ || $$st{"skip"}; } - + # 85: From STDIN to STDOUT $_ = eval { return if $$st{"skip"}; - my ($title, $cmd, $retno, $out, $err, $logfile, $result); + my ($title, $cmd, $ret_no, $out, $err, $logfile, $result); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); - my ($fs, $fo, $cs, $csr, $co); + my ($fs, $cs, $csr); rmtree $WORKDIR; mkpath $WORKDIR; $title = join ", ", "From STDIN to STDOUT", $$sct{"title"}, $$st{"title"}; - $logfile = randword; - do { $result = randword; } until $result ne $logfile; + $logfile = random_word; + do { $result = random_word; } until $result ne $logfile; $fs = catfile($WORKDIR, "$logfile" . $$st{"suf"}); ($cs, $csr) = &{$$sct{"sub"}}($fs); @fle = qw(); push @fle, basename($fs); push @fle, $result . $$st{"suf"}; - prsrvsrc $WORKDIR; + preserve_source $WORKDIR; @_ = ($reslog, qw(-d -d -d -n 1)); $cmd = join(" ", @_) . " < $fs"; - ($retno, $out, $err) = runcmd frread $fs, @_; - frwrite(catfile($WORKDIR, $result . $$st{"suf"}), $out); - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd read_raw_file $fs, @_; + write_raw_file(catfile($WORKDIR, $result . $$st{"suf"}), $out); + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -225,17 +224,17 @@ foreach my $st (@SRCTYPES) { $frb = basename($fr); $cef{$frb} = $cs; $tef{$frb} = $$st{"type"}; - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); $frb = $result . $$st{"suf"}; $fr = catfile($WORKDIR, $frb); ($cef{$frb}, $tef{$frb}) = ($csr, $$st{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - die "$title\n$cmd\n$out$err" unless $retno == 0; + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + die "$title\n$cmd\n$out$err" unless $ret_no == 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr} + unless has_no_file || $trf{$fr} eq $tef{$fr} || ($tef{$fr} eq TYPE_BZIP2 && -z catfile($WORKDIR, $fr)); die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; @@ -243,7 +242,7 @@ foreach my $st (@SRCTYPES) { 1; }; skip($$st{"skip"}, $_, 1, $@); - cleanup $_ || $$st{"skip"}, $WORKDIR, ++$tno; + clean_up $_ || $$st{"skip"}, $WORKDIR, ++$tno; die unless $_ || $$st{"skip"}; } } diff --git a/t/02-several.t b/t/02-several.t index 7d3d9f2..2ab6b4d 100755 --- a/t/02-several.t +++ b/t/02-several.t @@ -1,20 +1,19 @@ #! /usr/bin/perl -w # Test processing several log files at once -# Copyright (c) 2007 imacat -# -# 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 3 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, see . +# Copyright (c) 2007-2021 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # This file replaces 04-hybrix.t. @@ -32,7 +31,7 @@ use File::Spec::Functions qw(catdir catfile updir); use FindBin; use lib $FindBin::Bin; use _helper; -use vars qw($WORKDIR $tno $reslog); +our ($WORKDIR, $tno, $reslog); $WORKDIR = catdir($FindBin::Bin, "logs"); $tno = 0; @@ -40,35 +39,35 @@ $reslog = catfile($FindBin::Bin, updir, "blib", "script", "reslog"); # 1: Source log files listed as the arguments $_ = eval { - my ($title, $cmd, $retno, $out, $err, %logfiles); + my ($title, $cmd, $ret_no, $out, $err, %logfiles); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); - my ($num, @fs, @fo, @cs, @csr, @co, @st, $suf, $tsuf); + my ($num, @fs, @fo, @cs, @csr, @co, @st, $suf, $trim_suf); rmtree $WORKDIR; mkpath $WORKDIR; $title = join ", ", "several log files", "all listed as arguments"; - $suf = "." . randword; - do { $tsuf = "." . randword; } until $tsuf ne $suf; + $suf = "." . random_word; + do { $trim_suf = "." . random_word; } until $trim_suf ne $suf; # (2-4 times available compression) log files - $_ = 2 + (nogzip? 0: 2) + (nobzip2? 0: 2); + $_ = 2 + (has_no_gzip? 0: 2) + (has_no_bzip2? 0: 2); $num = $_ + int rand $_; - %_ = qw(); + my %types = qw(); # At least 2 files for each available compression - foreach my $st (@SRCTYPES) { - next if ($$st{"type"} eq TYPE_GZIP && nogzip) - || ($$st{"type"} eq TYPE_BZIP2 && nobzip2); - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; + foreach my $st (@SOURCE_TYPES) { + next if ($$st{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$st{"type"} eq TYPE_BZIP2 && has_no_bzip2); + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; } # Set random compression on the rest files - foreach (grep !exists $_{$_}, (0...$num-1)) { + foreach (grep !exists $types{$_}, (0...$num-1)) { do { - $_{$_} = $SRCTYPES[int rand @SRCTYPES]; - } until !(${$_{$_}}{"type"} eq TYPE_GZIP && nogzip) - && !(${$_{$_}}{"type"} eq TYPE_BZIP2 && nobzip2); + $types{$_} = $SOURCE_TYPES[int rand @SOURCE_TYPES]; + } until !(${$types{$_}}{"type"} eq TYPE_GZIP && has_no_gzip) + && !(${$types{$_}}{"type"} eq TYPE_BZIP2 && has_no_bzip2); } - @st = map $_{$_}, (0...$num-1); + @st = map $types{$_}, (0...$num-1); @fs = qw(); @fo = qw(); @cs = qw(); @@ -78,27 +77,27 @@ $_ = eval { %logfiles = qw(); for (my $k = 0; $k < $num; $k++) { my ($logfile, $cs, $csr, $co); - do { $logfile = randword } until !exists $logfiles{$logfile}; + do { $logfile = random_word } until !exists $logfiles{$logfile}; $logfiles{$logfile} = 1; - push @fs, catfile($WORKDIR, "$logfile$tsuf" . ${$st[$k]}{"suf"}); + push @fs, catfile($WORKDIR, "$logfile$trim_suf" . ${$st[$k]}{"suf"}); push @fo, catfile($WORKDIR, "$logfile$suf" . ${$st[$k]}{"suf"}); - ($cs, $csr) = mkrndlog_normal $fs[$k]; + ($cs, $csr) = make_log_file $fs[$k]; push @cs, $cs; push @csr, $csr; push @fle, basename($fo[$k]); # 1: create existing file, 0: no existing file if (int rand 1) { - $co = (mkrndlog_normal $fo[$k])[0]; + $co = (make_log_file $fo[$k])[0]; push @co, $co; } else { push @co, ""; } } - prsrvsrc $WORKDIR; - @_ = ($reslog, qw(-d -d -d -o a), "-s", $suf, "-t", $tsuf, @fs); + preserve_source $WORKDIR; + @_ = ($reslog, qw(-d -d -d -o a), "-s", $suf, "-t", $trim_suf, @fs); $cmd = join(" ", @_); - ($retno, $out, $err) = runcmd "", @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd "", @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -107,66 +106,66 @@ $_ = eval { $fr = $fo[$k]; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($co[$k] . $csr[$k], ${$st[$k]}{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - die "$title\n$cmd\n$out$err" unless $retno == 0; + die "$title\n$cmd\n$out$err" unless $ret_no == 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; ok($_, 1, $@); -cleanup $_, $WORKDIR, ++$tno; +clean_up $_, $WORKDIR, ++$tno; # 2-4: One of the source log files is read from STDIN # The file type at STDIN -foreach my $ststdin (@SRCTYPES) { +foreach my $st_stdin (@SOURCE_TYPES) { my $skip; $skip = 0; $_ = eval { - if ( ($$ststdin{"type"} eq TYPE_GZIP && nogzip) - || ($$ststdin{"type"} eq TYPE_BZIP2 && nobzip2)) { + if ( ($$st_stdin{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$st_stdin{"type"} eq TYPE_BZIP2 && has_no_bzip2)) { $skip = 1; return; } - my ($title, $cmd, $retno, $out, $err, %logfiles); + my ($title, $cmd, $ret_no, $out, $err, %logfiles); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); - my ($num, @fs, @fo, @cs, @csr, @co, @st, $suf, $tsuf, $stdin); + my ($num, @fs, @fo, @cs, @csr, @co, @st, $suf, $trim_suf, $stdin); rmtree $WORKDIR; mkpath $WORKDIR; $title = join ", ", "several log files", "one read from STDIN", - "STDIN " . $$ststdin{"title"}; - $suf = "." . randword; - do { $tsuf = "." . randword; } until $tsuf ne $suf; + "STDIN " . $$st_stdin{"title"}; + $suf = "." . random_word; + do { $trim_suf = "." . random_word; } until $trim_suf ne $suf; # (2-4 times available compression) log files - $_ = 2 + (nogzip? 0: 2) + (nobzip2? 0: 2); + $_ = 2 + (has_no_gzip? 0: 2) + (has_no_bzip2? 0: 2); $num = $_ + int rand $_; - %_ = qw(); + my %types = qw(); # At least 2 files for each available compression - foreach my $st (@SRCTYPES) { - next if ($$st{"type"} eq TYPE_GZIP && nogzip) - || ($$st{"type"} eq TYPE_BZIP2 && nobzip2); - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; + foreach my $st (@SOURCE_TYPES) { + next if ($$st{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$st{"type"} eq TYPE_BZIP2 && has_no_bzip2); + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; } # Set random compression on the rest files - foreach (grep !exists $_{$_}, (0...$num-1)) { + foreach (grep !exists $types{$_}, (0...$num-1)) { do { - $_{$_} = $SRCTYPES[int rand @SRCTYPES]; - } until !(${$_{$_}}{"type"} eq TYPE_GZIP && nogzip) - && !(${$_{$_}}{"type"} eq TYPE_BZIP2 && nobzip2); + $types{$_} = $SOURCE_TYPES[int rand @SOURCE_TYPES]; + } until !(${$types{$_}}{"type"} eq TYPE_GZIP && has_no_gzip) + && !(${$types{$_}}{"type"} eq TYPE_BZIP2 && has_no_bzip2); } # Choose the STDIN from the matching compression - @_ = grep ${$_{$_}}{"type"} eq $$ststdin{"type"}, (0...$num-1); + @_ = grep ${$types{$_}}{"type"} eq $$st_stdin{"type"}, (0...$num-1); $stdin = $_[int rand @_]; - @st = map $_{$_}, (0...$num-1); + @st = map $types{$_}, (0...$num-1); @fs = qw(); @fo = qw(); @cs = qw(); @@ -176,37 +175,37 @@ foreach my $ststdin (@SRCTYPES) { %logfiles = qw(); for (my $k = 0; $k < $num; $k++) { my ($logfile, $cs, $csr, $co); - do { $logfile = randword } until !exists $logfiles{$logfile}; + do { $logfile = random_word } until !exists $logfiles{$logfile}; $logfiles{$logfile} = 1; - push @fs, catfile($WORKDIR, "$logfile$tsuf" . ${$st[$k]}{"suf"}); + push @fs, catfile($WORKDIR, "$logfile$trim_suf" . ${$st[$k]}{"suf"}); if ($k == $stdin) { - do { $_ = randword } until !exists $logfiles{$_}; + do { $_ = random_word } until !exists $logfiles{$_}; $logfiles{$_} = 1; push @fo, catfile($WORKDIR, "$_" . ${$st[$k]}{"suf"}); } else { push @fo, catfile($WORKDIR, "$logfile$suf" . ${$st[$k]}{"suf"}); } - ($cs, $csr) = mkrndlog_normal $fs[$k]; + ($cs, $csr) = make_log_file $fs[$k]; push @cs, $cs; push @csr, $csr; push @fle, basename($fs[$k]) if $k == $stdin; push @fle, basename($fo[$k]); # 1: create existing file, 0: no existing file if ($k != $stdin && int rand 1) { - $co = (mkrndlog_normal $fo[$k])[0]; + $co = (make_log_file $fo[$k])[0]; push @co, $co; } else { push @co, ""; } } - prsrvsrc $WORKDIR; + preserve_source $WORKDIR; @_ = @fs; $_[$stdin] = "-"; - @_ = ($reslog, qw(-d -d -d -o a), "-s", $suf, "-t", $tsuf, @_); + @_ = ($reslog, qw(-d -d -d -o a), "-s", $suf, "-t", $trim_suf, @_); $cmd = join(" ", @_) . " < " . $fs[$stdin]; - ($retno, $out, $err) = runcmd frread $fs[$stdin], @_; - frwrite($fo[$stdin], $out); - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd read_raw_file $fs[$stdin], @_; + write_raw_file($fo[$stdin], $out); + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -214,25 +213,25 @@ foreach my $ststdin (@SRCTYPES) { $fr = $fs[$stdin]; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($cs[$stdin], ${$st[$stdin]}{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); for (my $k = 0; $k < $num; $k++) { $fr = $fo[$k]; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($co[$k] . $csr[$k], ${$st[$k]}{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } - die "$title\n$cmd\n$out$err" unless $retno == 0; + die "$title\n$cmd\n$out$err" unless $ret_no == 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; skip($skip, $_, 1, $@); - cleanup $_ || $skip, $WORKDIR, ++$tno; + clean_up $_ || $skip, $WORKDIR, ++$tno; die if !$_ && !$skip; } diff --git a/t/03-errors.t b/t/03-errors.t index 6ff6e1c..87beb68 100755 --- a/t/03-errors.t +++ b/t/03-errors.t @@ -1,20 +1,19 @@ #! /usr/bin/perl -w # Test the errors that should be captured. -# Copyright (c) 2007 imacat -# -# 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 3 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, see . +# Copyright (c) 2007-2021 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. use 5.005; use strict; @@ -30,35 +29,35 @@ use File::Spec::Functions qw(catdir catfile updir); use FindBin; use lib $FindBin::Bin; use _helper; -use vars qw($WORKDIR $reslog $tno); +our ($WORKDIR, $reslog, $tno); $WORKDIR = catdir($FindBin::Bin, "logs"); $reslog = catfile($FindBin::Bin, updir, "blib", "script", "reslog"); $tno = 0; # 1-6: Trim suffix is the same as suffix -foreach my $st (@SRCTYPES) { +foreach my $st (@SOURCE_TYPES) { # 1: Trim suffix is the same as suffix $_ = eval { return if $$st{"skip"}; - my ($title, $cmd, $retno, $out, $err, $logfile); + my ($title, $cmd, $ret_no, $out, $err, $logfile); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); - my ($fs, $fo, $cs, $csr, $co, $suf); + my ($fs, $cs, $csr, $suf); rmtree $WORKDIR; mkpath $WORKDIR; $title = join ", ", "Trim suffix is the same as suffix", $$st{"title"}; - $logfile = randword; - $suf = "." . randword; + $logfile = random_word; + $suf = "." . random_word; $fs = catfile($WORKDIR, "$logfile" . $$st{"suf"}); - ($cs, $csr) = mkrndlog_normal $fs; + ($cs, $csr) = make_log_file $fs; @fle = qw(); push @fle, basename($fs); - prsrvsrc $WORKDIR; + preserve_source $WORKDIR; @_ = ($reslog, qw(-d -d -d -n 1), "-s", $suf, "-t", $suf, $fs); $cmd = join " ", @_; - ($retno, $out, $err) = runcmd "", @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd "", @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -66,13 +65,13 @@ foreach my $st (@SRCTYPES) { $fr = $fs; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($cs, $$st{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - die "$title\n$cmd\n$out$err" unless $retno != 0; + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + die "$title\n$cmd\n$out$err" unless $ret_no != 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr} + unless has_no_file || $trf{$fr} eq $tef{$fr} || ($tef{$fr} eq TYPE_BZIP2 && -z catfile($WORKDIR, $fr)); die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; @@ -80,29 +79,29 @@ foreach my $st (@SRCTYPES) { 1; }; skip($$st{"skip"}, $_, 1, $@); - cleanup $_ || $$st{"skip"}, $WORKDIR, ++$tno; - + clean_up $_ || $$st{"skip"}, $WORKDIR, ++$tno; + # 2: Default suffix and trim suffix is set to .resolved $_ = eval { return if $$st{"skip"}; - my ($title, $cmd, $retno, $out, $err, $logfile); + my ($title, $cmd, $ret_no, $out, $err, $logfile); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); - my ($fs, $fo, $cs, $csr, $co, $suf); + my ($fs, $cs, $csr, $suf); rmtree $WORKDIR; mkpath $WORKDIR; $title = join ", ", "Default suffix and trim suffix is set to .resolved", $$st{"title"}; - $logfile = randword; + $logfile = random_word; $suf = ".resolved"; $fs = catfile($WORKDIR, "$logfile" . $$st{"suf"}); - ($cs, $csr) = mkrndlog_normal $fs; + ($cs, $csr) = make_log_file $fs; @fle = qw(); push @fle, basename($fs); - prsrvsrc $WORKDIR; + preserve_source $WORKDIR; @_ = ($reslog, qw(-d -d -d -n 1), "-t", $suf, $fs); $cmd = join " ", @_; - ($retno, $out, $err) = runcmd "", @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd "", @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -110,13 +109,13 @@ foreach my $st (@SRCTYPES) { $fr = $fs; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($cs, $$st{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); - die "$title\n$cmd\n$out$err" unless $retno != 0; + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); + die "$title\n$cmd\n$out$err" unless $ret_no != 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr} + unless has_no_file || $trf{$fr} eq $tef{$fr} || ($tef{$fr} eq TYPE_BZIP2 && -z catfile($WORKDIR, $fr)); die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; @@ -124,40 +123,40 @@ foreach my $st (@SRCTYPES) { 1; }; skip($$st{"skip"}, $_, 1, $@); - cleanup $_ || $$st{"skip"}, $WORKDIR, ++$tno; + clean_up $_ || $$st{"skip"}, $WORKDIR, ++$tno; } # 7: A same log file is specified more than once $_ = eval { - my ($title, $cmd, $retno, $out, $err, %logfiles); + my ($title, $cmd, $ret_no, $out, $err, %logfiles); my ($fr, $frb, @fle, $fle, $flr, %cef, %crf, %tef, %trf); - my ($num, @fs, @fo, @cs, @csr, @co, @st, $suf, $tsuf, $dup); + my ($num, @fs, @fo, @cs, @csr, @co, @st, $suf, $trim_suf, $dup); rmtree $WORKDIR; mkpath $WORKDIR; $title = "A same log file is specified more than once"; - $suf = "." . randword; - do { $tsuf = "." . randword; } until $tsuf ne $suf; + $suf = "." . random_word; + do { $trim_suf = "." . random_word; } until $trim_suf ne $suf; # (2-4 times available compression) log files - $_ = 2 + (nogzip? 0: 2) + (nobzip2? 0: 2); + $_ = 2 + (has_no_gzip? 0: 2) + (has_no_bzip2? 0: 2); $num = $_ + int rand $_; - %_ = qw(); + my %types = qw(); # At least 2 files for each available compression - foreach my $st (@SRCTYPES) { - next if ($$st{"type"} eq TYPE_GZIP && nogzip) - || ($$st{"type"} eq TYPE_BZIP2 && nobzip2); - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; - @_ = grep !exists $_{$_}, (0...$num-1); - $_{$_[int rand @_]} = $st; + foreach my $st (@SOURCE_TYPES) { + next if ($$st{"type"} eq TYPE_GZIP && has_no_gzip) + || ($$st{"type"} eq TYPE_BZIP2 && has_no_bzip2); + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; + @_ = grep !exists $types{$_}, (0...$num-1); + $types{$_[int rand @_]} = $st; } # Set random compression on the rest files - foreach (grep !exists $_{$_}, (0...$num-1)) { + foreach (grep !exists $types{$_}, (0...$num-1)) { do { - $_{$_} = $SRCTYPES[int rand @SRCTYPES]; - } until !(${$_{$_}}{"type"} eq TYPE_GZIP && nogzip) - && !(${$_{$_}}{"type"} eq TYPE_BZIP2 && nobzip2); + $types{$_} = $SOURCE_TYPES[int rand @SOURCE_TYPES]; + } until !(${$types{$_}}{"type"} eq TYPE_GZIP && has_no_gzip) + && !(${$types{$_}}{"type"} eq TYPE_BZIP2 && has_no_bzip2); } - @st = map $_{$_}, (0...$num-1); + @st = map $types{$_}, (0...$num-1); @fs = qw(); @fo = qw(); @cs = qw(); @@ -167,31 +166,31 @@ $_ = eval { %logfiles = qw(); for (my $k = 0; $k < $num; $k++) { my ($logfile, $cs, $csr, $co); - do { $logfile = randword } until !exists $logfiles{$logfile}; + do { $logfile = random_word } until !exists $logfiles{$logfile}; $logfiles{$logfile} = 1; - push @fs, catfile($WORKDIR, "$logfile$tsuf" . ${$st[$k]}{"suf"}); + push @fs, catfile($WORKDIR, "$logfile$trim_suf" . ${$st[$k]}{"suf"}); push @fo, catfile($WORKDIR, "$logfile$suf" . ${$st[$k]}{"suf"}); - ($cs, $csr) = mkrndlog_normal $fs[$k]; + ($cs, $csr) = make_log_file $fs[$k]; push @cs, $cs; push @csr, $csr; push @fle, basename($fs[$k]); # 1: create existing file, 0: no existing file if (int rand 1) { - $co = (mkrndlog_normal $fo[$k])[0]; + $co = (make_log_file $fo[$k])[0]; push @co, $co; push @fle, basename($fo[$k]); } else { push @co, ""; } } - prsrvsrc $WORKDIR; + preserve_source $WORKDIR; $dup = $fs[int rand @fs]; $_ = int rand(@fs + 1); @_ = (@fs[0...$_-1], $dup, @fs[$_...$#fs]); - @_ = ($reslog, qw(-d -d -d -o a), "-s", $suf, "-t", $tsuf, @_); + @_ = ($reslog, qw(-d -d -d -o a), "-s", $suf, "-t", $trim_suf, @_); $cmd = join(" ", @_); - ($retno, $out, $err) = runcmd "", @_; - ($fle, $flr) = (join(" ", sort @fle), flist $WORKDIR); + ($ret_no, $out, $err) = run_cmd "", @_; + ($fle, $flr) = (join(" ", sort @fle), list_files $WORKDIR); %cef = qw(); # Expected content by file %tef = qw(); # Expected file type by file %crf = qw(); # Resulted content by file @@ -200,24 +199,24 @@ $_ = eval { $fr = $fs[$k]; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($cs[$k], ${$st[$k]}{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); if ($co[$k] ne "") { $fr = $fo[$k]; $frb = basename($fr); ($cef{$frb}, $tef{$frb}) = ($co[$k], ${$st[$k]}{"type"}); - ($crf{$frb}, $trf{$frb}) = (fread $fr, ftype $fr); + ($crf{$frb}, $trf{$frb}) = (read_file $fr, file_type $fr); } } - die "$title\n$cmd\n$out$err" unless $retno != 0; + die "$title\n$cmd\n$out$err" unless $ret_no != 0; die "$title\n$cmd\nresult files incorrect.\nGot: $flr\nExpected: $fle\nOutput:\n$out$err" unless $flr eq $fle; foreach $fr (@fle) { die "$title\n$cmd\n$fr: result type incorrect.\nGot: $trf{$fr}\nExpected: $tef{$fr}\nOutput:\n$out$err" - unless nofile || $trf{$fr} eq $tef{$fr}; + unless has_no_file || $trf{$fr} eq $tef{$fr}; die "$title\n$cmd\n$fr: result incorrect.\nGot:\n$crf{$fr}\nExpected:\n$cef{$fr}\nOutput:\n$out$err" unless $crf{$fr} eq $cef{$fr}; } 1; }; ok($_, 1, $@); -cleanup $_, $WORKDIR, ++$tno; +clean_up $_, $WORKDIR, ++$tno; diff --git a/t/_helper.pm b/t/_helper.pm index 0457834..2040271 100644 --- a/t/_helper.pm +++ b/t/_helper.pm @@ -1,17 +1,17 @@ # _helper.pm - A simple test suite helper -# Copyright (c) 2005-2007 imacat -# +# Copyright (c) 2005-2021 imacat +# # 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 3 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, see . @@ -20,36 +20,36 @@ use 5.005; use strict; use warnings; use base qw(Exporter); -use vars qw($VERSION @EXPORT); +our ($VERSION, @EXPORT); $VERSION = "0.05"; -@EXPORT = qw(); -push @EXPORT, qw(fread frread fwrite frwrite); -push @EXPORT, qw(runcmd whereis ftype flist prsrvsrc cleanup); -push @EXPORT, qw(nofile nogzip nobzip2); -push @EXPORT, qw(mkrndlog_normal mkrndlog_noip mkrndlog_empty); -push @EXPORT, qw(randword); -push @EXPORT, qw(TYPE_PLAIN TYPE_GZIP TYPE_BZIP2); -push @EXPORT, qw(@CNTTYPES @SRCTYPES @KEEPTYPES @OVERTYPES @SUFTYPES @TSUFTYPES); +@EXPORT = qw( + read_file read_raw_file write_file write_raw_file + run_cmd where_is file_type list_files preserve_source clean_up + has_no_file has_no_gzip has_no_bzip2 + make_log_file make_resolved_log_file make_empty_log_file + random_word + TYPE_TEXT TYPE_GZIP TYPE_BZIP2 + @CONTENT_TYPES @SOURCE_TYPES @KEEP_MODES @OVERRIDE_MODES @SUFFICES @TRIM_SUFFIX); # Prototype declaration -sub thisfile(); -sub fread($); -sub frread($); -sub fwrite($$); -sub frwrite($$); -sub runcmd($@); -sub whereis($); -sub ftype($); -sub flist($); -sub prsrvsrc($); -sub cleanup($$$); -sub nofile(); -sub nogzip(); -sub nobzip2(); -sub mkrndlog_normal($); -sub mkrndlog_noip($); -sub mkrndlog_empty($); -sub randword(); -sub randip(); +sub this_file(); +sub read_file($); +sub read_raw_file($); +sub write_file($$); +sub write_raw_file($$); +sub run_cmd($@); +sub where_is($); +sub file_type($); +sub list_files($); +sub preserve_source($); +sub clean_up($$$); +sub has_no_file(); +sub has_no_gzip(); +sub has_no_bzip2(); +sub make_log_file($); +sub make_resolved_log_file($); +sub make_empty_log_file($); +sub random_word(); +sub random_ip(); use ExtUtils::MakeMaker qw(); use Fcntl qw(:seek); @@ -60,410 +60,418 @@ use File::Spec::Functions qw(splitdir catdir catfile path); use File::Temp qw(tempfile); use Socket; -use vars qw(%WHEREIS $NOFILE $NOGZIP $NOBZIP2 $RANDIP); -%WHEREIS = qw(); -undef $NOFILE; -undef $NOGZIP; -undef $NOBZIP2; -undef $RANDIP; +our (%WHERE_IS, $HAS_NO_FILE, $HAS_NO_GZIP, $HAS_NO_BZIP2, $RANDOM_IP); +%WHERE_IS = qw(); +undef $HAS_NO_FILE; +undef $HAS_NO_GZIP; +undef $HAS_NO_BZIP2; +undef $RANDOM_IP; -use constant TYPE_PLAIN => "text/plain"; +use constant TYPE_TEXT => "text/plain"; use constant TYPE_GZIP => "application/x-gzip"; use constant TYPE_BZIP2 => "application/x-bzip2"; -use vars qw(@CNTTYPES @SRCTYPES @KEEPTYPES @OVERTYPES @SUFTYPES @TSUFTYPES); -# All the countent type information -@CNTTYPES = ( { "title" => "normal log file", - "sub" => \&mkrndlog_normal, }, - { "title" => "log file without IP", - "sub" => \&mkrndlog_noip, }, - { "title" => "empty log file", - "sub" => \&mkrndlog_empty, }, ); +our (@CONTENT_TYPES, @SOURCE_TYPES, @KEEP_MODES, @OVERRIDE_MODES, @SUFFICES, + @TRIM_SUFFIX); +# All the content type information +@CONTENT_TYPES = ( + { "title" => "normal log file", + "sub" => \&make_log_file, }, + { "title" => "resolved log file", + "sub" => \&make_resolved_log_file, }, + { "title" => "empty log file", + "sub" => \&make_empty_log_file, }, ); # All the source type information -@SRCTYPES = ( { "title" => "plain text source", - "type" => TYPE_PLAIN, - "suf" => "", - "skip" => 0, }, - { "title" => "gzip source", - "type" => TYPE_GZIP, - "suf" => ".gz", - "skip" => nogzip, }, - { "title" => "bzip2 source", - "type" => TYPE_BZIP2, - "suf" => ".bz2", - "skip" => nobzip2, }, ); -# All the keep type information -@KEEPTYPES = ( { "title" => "keep default", - "opts" => [], - "del" => 1, - "keep" => 0, - "cdel" => 0, - "ckeep" => 1, }, - { "title" => "keep all", - "opts" => [qw(-k a)], - "del" => 0, - "keep" => 1, - "cdel" => 0, - "ckeep" => 1, }, - { "title" => "keep delete", - "opts" => [qw(-k d)], - "del" => 1, - "keep" => 0, - "cdel" => 1, - "ckeep" => 0, }, - { "title" => "keep restart", - "opts" => [qw(-k r)], - "del" => 0, - "keep" => 0, - "cdel" => 0, - "ckeep" => 0, }, ); -# All the override type information -@OVERTYPES = ( { "title" => "override no existing", - "opts" => [], - "mkex" => 0, - "ok" => 1, - "ce" => sub { $_[1]; }, }, - { "title" => "override default", - "opts" => [], - "mkex" => 1, - "ok" => 0, - "ce" => sub { $_[0]; }, }, - { "title" => "override overwrite", - "opts" => [qw(-o o)], - "mkex" => 1, - "ok" => 1, - "ce" => sub { $_[1]; }, }, - { "title" => "override append", - "opts" => [qw(-o a)], - "mkex" => 1, - "ok" => 1, - "ce" => sub { $_[0] . $_[1]; }, }, - { "title" => "override fail", - "opts" => [qw(-o f)], - "mkex" => 1, - "ok" => 0, - "ce" => sub { $_[0]; }, }, ); +@SOURCE_TYPES = ( + { "title" => "plain text source", + "type" => TYPE_TEXT, + "suf" => "", + "skip" => 0, }, + { "title" => "gzip source", + "type" => TYPE_GZIP, + "suf" => ".gz", + "skip" => has_no_gzip, }, + { "title" => "bzip2 source", + "type" => TYPE_BZIP2, + "suf" => ".bz2", + "skip" => has_no_bzip2, }, ); +# All the keep mode information +@KEEP_MODES = ( + { "title" => "keep default", + "opts" => [], + "del" => 1, + "keep" => 0, + "cdel" => 0, + "ckeep" => 1, }, + { "title" => "keep all", + "opts" => [qw(-k a)], + "del" => 0, + "keep" => 1, + "cdel" => 0, + "ckeep" => 1, }, + { "title" => "keep delete", + "opts" => [qw(-k d)], + "del" => 1, + "keep" => 0, + "cdel" => 1, + "ckeep" => 0, }, + { "title" => "keep restart", + "opts" => [qw(-k r)], + "del" => 0, + "keep" => 0, + "cdel" => 0, + "ckeep" => 0, }, ); +# All the override mode information +@OVERRIDE_MODES = ( + { "title" => "override no existing", + "opts" => [], + "exists" => 0, + "ok" => 1, + "ce" => sub { $_[1]; }, }, + { "title" => "override default", + "opts" => [], + "exists" => 1, + "ok" => 0, + "ce" => sub { $_[0]; }, }, + { "title" => "override overwrite", + "opts" => [qw(-o o)], + "exists" => 1, + "ok" => 1, + "ce" => sub { $_[1]; }, }, + { "title" => "override append", + "opts" => [qw(-o a)], + "exists" => 1, + "ok" => 1, + "ce" => sub { $_[0] . $_[1]; }, }, + { "title" => "override fail", + "opts" => [qw(-o f)], + "exists" => 1, + "ok" => 0, + "ce" => sub { $_[0]; }, }, ); # All the suffix information -@SUFTYPES = ( { "title" => "default suffix", - "suf" => ".resolved", - "opts" => sub { }, }, - { "title" => "custom suffix", - "suf" => undef, - "opts" => sub { ("-s", $_[0]); }, }, ); +@SUFFICES = ( + { "title" => "default suffix", + "suf" => ".resolved", + "opts" => sub { }, }, + { "title" => "custom suffix", + "suf" => undef, + "opts" => sub { ("-s", $_[0]); }, }, ); # All the trim-suffix information -@TSUFTYPES = ( { "title" => "default trim-suffix", - "suf" => "", - "opts" => sub { }, }, - { "title" => "custom trim-suffix", - "suf" => undef, - "opts" => sub { ("-t", $_[0]); }, }, ); +@TRIM_SUFFIX = ( + { "title" => "default trim-suffix", + "suf" => "", + "opts" => sub { }, }, + { "title" => "custom trim-suffix", + "suf" => undef, + "opts" => sub { ("-t", $_[0]); }, }, ); -# thisfile: Return the name of this file -sub thisfile() { basename($0); } +# Return the name of this file +sub this_file() { basename($0); } -# fread: A simple reader to read a log file in any supported format -sub fread($) { +# A simple reader to read a log file in any supported format +sub read_file($) { local ($_, %_); my ($file, $content); $file = $_[0]; - + # non-existing file return undef if !-e $file; - + # a gzip compressed file if ($file =~ /\.gz$/) { # Compress::Zlib if (eval { require Compress::Zlib; - import Compress::Zlib qw(gzopen); + Compress::Zlib->import(qw(gzopen)); 1; }) { + use Compress::Zlib qw(gzopen); my ($FH, $gz); $content = ""; - open $FH, $file or die thisfile . ": $file: $!"; - $gz = gzopen($FH, "rb") or die thisfile . ": $file: $!"; + open $FH, $file or die this_file . ": $file: $!"; + $gz = gzopen($FH, "rb") or die this_file . ": $file: $!"; while (1) { ($gz->gzread($_, 10240) != -1) - or die thisfile . ": $file: " . $gz->gzerror; + or die this_file . ": $file: " . $gz->gzerror; $content .= $_; last if length $_ < 10240; } - $gz->gzclose and die thisfile . ": $file: " . $gz->gzerror; + $gz->gzclose and die this_file . ": $file: " . $gz->gzerror; return $content; - + # gzip executable } else { my ($PH, $CMD); - $CMD = whereis "gzip"; + $CMD = where_is "gzip"; $CMD = "\"$CMD\" -cd \"$file\""; - open $PH, "$CMD |" or die thisfile . ": $CMD: $!"; + open $PH, "$CMD |" or die this_file . ": $CMD: $!"; $content = join "", <$PH>; - close $PH or die thisfile . ": $CMD: $!"; + close $PH or die this_file . ": $CMD: $!"; return $content; } - + # a bzip compressed file } elsif ($file =~ /\.bz2$/) { # Compress::Bzip2 if (eval { require Compress::Bzip2; - import Compress::Bzip2 2.00; - import Compress::Bzip2 qw(bzopen); + Compress::Bzip2->import(2.00); + Compress::Bzip2->import(qw(bzopen)); 1; }) { my ($FH, $bz); $content = ""; - open $FH, $file or die thisfile . ": $file: $!"; - $bz = bzopen($FH, "rb") or die thisfile . ": $file: $!"; + open $FH, $file or die this_file . ": $file: $!"; + $bz = bzopen($FH, "rb") or die this_file . ": $file: $!"; while (1) { ($bz->bzread($_, 10240) != -1) - or die thisfile . ": $file: " . $bz->bzerror; + or die this_file . ": $file: " . $bz->bzerror; $content .= $_; last if length $_ < 10240; } - $bz->bzclose and die thisfile . ": $file: " . $bz->bzerror; + $bz->bzclose and die this_file . ": $file: " . $bz->bzerror; return $content; - + # bzip2 executable } else { my ($PH, $CMD); - $CMD = whereis "bzip2"; + $CMD = where_is "bzip2"; $CMD = "bzip2 -cd \"$file\""; - open $PH, "$CMD |" or die thisfile . ": $CMD: $!"; + open $PH, "$CMD |" or die this_file . ": $CMD: $!"; $content = join "", <$PH>; - close $PH or die thisfile . ": $CMD: $!"; + close $PH or die this_file . ": $CMD: $!"; return $content; } - + # a plain text file } else { my $FH; - open $FH, $file or die thisfile . ": $file: $!"; + open $FH, $file or die this_file . ": $file: $!"; $content = join "", <$FH>; - close $FH or die thisfile . ": $file: $!"; + close $FH or die this_file . ": $file: $!"; return $content; } } -# frread: A raw file reader -sub frread($) { +# A raw file reader +sub read_raw_file($) { local ($_, %_); my ($file, $content, $FH, $size); $file = $_[0]; - + # non-existing file return undef if !-e $file; - + $size = (stat $file)[7]; - open $FH, $file or die thisfile . ": $file: $!"; - binmode $FH or die thisfile . ": $file: $!"; + open $FH, $file or die this_file . ": $file: $!"; + binmode $FH or die this_file . ": $file: $!"; (read($FH, $content, $size) == $size) - or die thisfile . ": $file: $!"; - close $FH or die thisfile . ": $file: $!"; + or die this_file . ": $file: $!"; + close $FH or die this_file . ": $file: $!"; return $content; } -# fwrite: A simple writer to write a log file in any supported format -sub fwrite($$) { +# A simple writer to write a log file in any supported format +sub write_file($$) { local ($_, %_); my ($file, $content); ($file, $content) = @_; - + # a gzip compressed file if ($file =~ /\.gz$/) { # Compress::Zlib if (eval { require Compress::Zlib; - import Compress::Zlib qw(gzopen); + Compress::Zlib->import(qw(gzopen)); 1; }) { my ($FH, $gz); - open $FH, ">$file" or die thisfile . ": $file: $!"; - $gz = gzopen($FH, "wb9") or die thisfile . ": $file: $!"; + open $FH, ">$file" or die this_file . ": $file: $!"; + $gz = gzopen($FH, "wb9") or die this_file . ": $file: $!"; ($gz->gzwrite($content) == length $content) - or die thisfile . ": $file: " . $gz->gzerror; - $gz->gzclose and die thisfile . ": $file: " . $gz->gzerror; + or die this_file . ": $file: " . $gz->gzerror; + $gz->gzclose and die this_file . ": $file: " . $gz->gzerror; return; - + # gzip executable } else { my ($PH, $CMD); - $CMD = whereis "gzip"; + $CMD = where_is "gzip"; $CMD = "\"$CMD\" -c9f > \"$file\""; - open $PH, "| $CMD" or die thisfile . ": $CMD: $!"; - print $PH $content or die thisfile . ": $CMD: $!"; - close $PH or die thisfile . ": $CMD: $!"; + open $PH, "| $CMD" or die this_file . ": $CMD: $!"; + print $PH $content or die this_file . ": $CMD: $!"; + close $PH or die this_file . ": $CMD: $!"; return; } - + # a bzip compressed file } elsif ($file =~ /\.bz2$/) { # Compress::Bzip2 if (eval { require Compress::Bzip2; - import Compress::Bzip2 2.00; - import Compress::Bzip2 qw(bzopen); + Compress::Bzip2->import(2.00); + Compress::Bzip2->import(qw(bzopen)); 1; }) { my ($FH, $bz); - open $FH, ">$file" or die thisfile . ": $file: $!"; - $bz = bzopen($FH, "wb9") or die thisfile . ": $file: $!"; + open $FH, ">$file" or die this_file . ": $file: $!"; + $bz = bzopen($FH, "wb9") or die this_file . ": $file: $!"; if ($content ne "") { ($bz->bzwrite($content, length $content) == length $content) - or die thisfile . ": $file: " . $bz->bzerror; + or die this_file . ": $file: " . $bz->bzerror; } - $bz->bzclose and die thisfile . ": $file: " . $bz->bzerror; + $bz->bzclose and die this_file . ": $file: " . $bz->bzerror; return; - + # bzip2 executable } else { my ($PH, $CMD); - $CMD = whereis "bzip2"; + $CMD = where_is "bzip2"; $CMD = "\"$CMD\" -9f > \"$file\""; - open $PH, "| $CMD" or die thisfile . ": $CMD: $!"; - print $PH $content or die thisfile . ": $CMD: $!"; - close $PH or die thisfile . ": $CMD: $!"; + open $PH, "| $CMD" or die this_file . ": $CMD: $!"; + print $PH $content or die this_file . ": $CMD: $!"; + close $PH or die this_file . ": $CMD: $!"; return; } - + # a plain text file } else { my $FH; - open $FH, ">$file" or die thisfile . ": $file: $!"; - print $FH $content or die thisfile . ": $file: $!"; - close $FH or die thisfile . ": $file: $!"; + open $FH, ">$file" or die this_file . ": $file: $!"; + print $FH $content or die this_file . ": $file: $!"; + close $FH or die this_file . ": $file: $!"; return; } } -# frwrite: A raw file writer -sub frwrite($$) { +# A raw file writer +sub write_raw_file($$) { local ($_, %_); my ($file, $content, $FH); ($file, $content) = @_; - - open $FH, ">$file" or die thisfile . ": $file: $!"; - binmode $FH or die thisfile . ": $file: $!"; - print $FH $content or die thisfile . ": $file: $!"; - close $FH or die thisfile . ": $file: $!"; + + open $FH, ">$file" or die this_file . ": $file: $!"; + binmode $FH or die this_file . ": $file: $!"; + print $FH $content or die this_file . ": $file: $!"; + close $FH or die this_file . ": $file: $!"; return; } -# runcmd: Run a command and return the result -sub runcmd($@) { +# Run a command and return the result +sub run_cmd($@) { local ($_, %_); - my ($retno, $out, $err, $in, @cmd, $cmd, $OUT, $ERR, $STDOUT, $STDERR, $PH); + my ($ret_no, $out, $err, $in, @cmd, $cmd, $OUT, $ERR, $STDOUT, $STDERR, $PH); ($in, @cmd) = @_; - + $err = "Running " . join(" ", map "\"$_\"", @cmd) . "\n"; $out = ""; - - open $STDOUT, ">&", \*STDOUT or die thisfile . ": STDOUT: $!"; - open $STDERR, ">&", \*STDERR or die thisfile . ": STDERR: $!"; - $OUT = tempfile or die thisfile . ": tempfile: $!"; - binmode $OUT or die thisfile . ": tempfile: $!"; - $ERR = tempfile or die thisfile . ": tempfile: $!"; - binmode $ERR or die thisfile . ": tempfile: $!"; - open STDOUT, ">&", $OUT or die thisfile . ": tempfile: $!"; - binmode STDOUT or die thisfile . ": tempfile: $!"; - open STDERR, ">&", $ERR or die thisfile . ": tempfile: $!"; - binmode STDERR or die thisfile . ": tempfile: $!"; - + + open $STDOUT, ">&", \*STDOUT or die this_file . ": STDOUT: $!"; + open $STDERR, ">&", \*STDERR or die this_file . ": STDERR: $!"; + $OUT = tempfile or die this_file . ": tempfile: $!"; + binmode $OUT or die this_file . ": tempfile: $!"; + $ERR = tempfile or die this_file . ": tempfile: $!"; + binmode $ERR or die this_file . ": tempfile: $!"; + open STDOUT, ">&", $OUT or die this_file . ": tempfile: $!"; + binmode STDOUT or die this_file . ": tempfile: $!"; + open STDERR, ">&", $ERR or die this_file . ": tempfile: $!"; + binmode STDERR or die this_file . ": tempfile: $!"; + $cmd = join " ", map "\"$_\"", @cmd; if ($^O eq "MSWin32") { - open $PH, "| $cmd" or die thisfile . ": $cmd: $!"; + open $PH, "| $cmd" or die this_file . ": $cmd: $!"; } else { - open $PH, "|-", @cmd or die thisfile . ": $cmd: $!"; + open $PH, "|-", @cmd or die this_file . ": $cmd: $!"; } - binmode $PH or die thisfile . ": $cmd: $!"; - print $PH $in or die thisfile . ": $cmd: $!"; + binmode $PH or die this_file . ": $cmd: $!"; + print $PH $in or die this_file . ": $cmd: $!"; close $PH; - $retno = $?; - - open STDOUT, ">&", $STDOUT or die thisfile . ": tempfile: $!"; - open STDERR, ">&", $STDERR or die thisfile . ": tempfile: $!"; - - seek $OUT, 0, SEEK_SET or die thisfile . ": tempfile: $!"; + $ret_no = $?; + + open STDOUT, ">&", $STDOUT or die this_file . ": tempfile: $!"; + open STDERR, ">&", $STDERR or die this_file . ": tempfile: $!"; + + seek $OUT, 0, SEEK_SET or die this_file . ": tempfile: $!"; $out = join "", <$OUT>; - close $OUT or die thisfile . ": tempfile: $!"; - seek $ERR, 0, SEEK_SET or die thisfile . ": tempfile: $!"; + close $OUT or die this_file . ": tempfile: $!"; + seek $ERR, 0, SEEK_SET or die this_file . ": tempfile: $!"; $err = join "", <$ERR>; - close $ERR or die thisfile . ": tempfile: $!"; - - return ($retno, $out, $err); + close $ERR or die this_file . ": tempfile: $!"; + + return ($ret_no, $out, $err); } -# whereis: Find an executable +# Find an executable # Code inspired from CPAN::FirstTime -sub whereis($) { +sub where_is($) { local ($_, %_); my ($file, $path); $file = $_[0]; - return $WHEREIS{$file} if exists $WHEREIS{$file}; + return $WHERE_IS{$file} if exists $WHERE_IS{$file}; foreach my $dir (path) { - return ($WHEREIS{$file} = $path) + return ($WHERE_IS{$file} = $path) if defined($path = MM->maybe_command(catfile($dir, $file))); } - return ($WHEREIS{$file} = undef); + return ($WHERE_IS{$file} = undef); } -# ftype: Find the file type -sub ftype($) { +# Find the file type +sub file_type($) { local ($_, %_); my $file; $file = $_[0]; return undef unless -e $file; # Use File::MMagic if (eval { require File::MMagic; 1; }) { - $_ = new File::MMagic->checktype_filename($file); + $_ = File::MMagic->new->checktype_filename($file); return TYPE_GZIP if /gzip/; return TYPE_BZIP2 if /bzip2/; # All else are text/plain - return TYPE_PLAIN; + return TYPE_TEXT; } # Use file executable - if (defined($_ = whereis "file")) { + if (defined($_ = where_is "file")) { $_ = join "", `"$_" "$file"`; return TYPE_GZIP if /gzip/; return TYPE_BZIP2 if /bzip2/; # All else are text/plain - return TYPE_PLAIN; + return TYPE_TEXT; } # No type checker available return undef; } -# flist: Obtain the files list in a directory -sub flist($) { +# Obtain the files list in a directory +sub list_files($) { local ($_, %_); my ($dir, $DH); $dir = $_[0]; @_ = qw(); - opendir $DH, $dir or die thisfile . ": $dir: $!"; + opendir $DH, $dir or die this_file . ": $dir: $!"; while (defined($_ = readdir $DH)) { next if $_ eq "." || $_ eq ".." || !-f "$dir/$_"; push @_, $_; } - closedir $DH or die thisfile . ": $dir: $!"; + closedir $DH or die this_file . ": $dir: $!"; return join " ", sort @_; } -# prsrvsrc: Preserve the source test files -sub prsrvsrc($) { +# Preserve the source test files +sub preserve_source($) { local ($_, %_); my ($dir, $DH); $dir = $_[0]; @_ = qw(); - opendir $DH, $dir or die thisfile . ": $dir: $!"; + opendir $DH, $dir or die this_file . ": $dir: $!"; while (defined($_ = readdir $DH)) { next if $_ eq "." || $_ eq ".." || !-f "$dir/$_"; push @_, $_; } - closedir $DH or die thisfile . ": $dir: $!"; + closedir $DH or die this_file . ": $dir: $!"; rmtree "$dir/source"; mkpath "$dir/source"; - frwrite "$dir/source/$_", frread "$dir/$_" + write_raw_file "$dir/source/$_", read_raw_file "$dir/$_" foreach @_; return; } -# cleanup: Clean up the test files -sub cleanup($$$) { +# Clean up the test files +sub clean_up($$$) { local ($_, %_); - my ($r, $dir, $testno, $testname, $c); - ($r, $dir, $testno) = @_; + my ($r, $dir, $test_no, $test_name, $c); + ($r, $dir, $test_no) = @_; # Nothing to clean up return unless -e $dir; # Success @@ -472,56 +480,56 @@ sub cleanup($$$) { return; } # Fail - keep the test files for debugging - $testname = basename((caller)[1]); - $testname =~ s/\.t$//; + $test_name = basename((caller)[1]); + $test_name =~ s/\.t$//; $c = 1; - $c++ while -e ($_ = "$dir.$testname.$testno.$c"); - rename $dir, $_ or die thisfile . ": $dir, $_: $!"; + $c++ while -e ($_ = "$dir.$test_name.$test_no.$c"); + rename $dir, $_ or die this_file . ": $dir, $_: $!"; return; } -# nofile: If we have the file type checker somewhere -sub nofile() { - $NOFILE = eval { require File::MMagic; 1; } - || defined whereis "file"? +# If we have the file type checker somewhere +sub has_no_file() { + $HAS_NO_FILE = eval { require File::MMagic; 1; } + || defined where_is "file"? 0: "File::MMagic or file executable not available" - if !defined $NOFILE; - return $NOFILE; + if !defined $HAS_NO_FILE; + return $HAS_NO_FILE; } -# nogzip: If we have gzip support somewhere -sub nogzip() { - $NOGZIP = eval { require Compress::Zlib; 1; } - || defined whereis "gzip"? +# If we have gzip support somewhere +sub has_no_gzip() { + $HAS_NO_GZIP = eval { require Compress::Zlib; 1; } + || defined where_is "gzip"? 0: "Compress::Zlib or gzip executable not available" - if !defined $NOGZIP; - return $NOGZIP; + if !defined $HAS_NO_GZIP; + return $HAS_NO_GZIP; } -# nobzip2: If we have bzip2 support somewhere -sub nobzip2() { - $NOBZIP2 = eval { require Compress::Bzip2; import Compress::Bzip2 2.00; 1; } - || defined whereis "bzip2"? +# If we have bzip2 support somewhere +sub has_no_bzip2() { + $HAS_NO_BZIP2 = eval { require Compress::Bzip2; Compress::Bzip2->import(2.00); 1; } + || defined where_is "bzip2"? 0: "Compress::Bzip2 v2 or bzip2 executable not available" - if !defined $NOBZIP2; - return $NOBZIP2; + if !defined $HAS_NO_BZIP2; + return $HAS_NO_BZIP2; } -# mkrndlog_normal: Create a normal random log file -sub mkrndlog_normal($) { +# Create a normal random log file +sub make_log_file($) { local ($_, %_); my ($file, $hosts, @host_is_ip, @logs, $t, $content, $malformed, $tz); - my (%rlogs, $rcontent); + my (%resolved_logs, $resolved_content); $file = $_[0]; - + @logs = qw(); - %rlogs = qw(); - + %resolved_logs = qw(); + # Start from sometime in the past year $t = time - int rand(86400*365); # Time zone $tz = (-12 + (int rand 53) / 2) * 3600; - + # 3-5 hosts $hosts = 3 + int rand 3; # Host type: 1: IP, 0: domain name @@ -531,28 +539,28 @@ sub mkrndlog_normal($) { $host_is_ip[int rand $hosts] = 1 while grep($_ == 1, @host_is_ip) < 2; foreach my $is_ip (@host_is_ip) { - my ($host, $rhost, $user, $htver, @hlogs, $hlogs); + my ($host, $resolved_host, $user, $http_ver, @host_logs, $count); if ($is_ip) { # Generate a random IP - ($host, $rhost) = randip; - + ($host, $resolved_host) = random_ip; + } else { # Generate a random domain name # 3-5 levels, end with net or com $_ = 2 + int rand 3; @_ = qw(); - push @_, randword while @_ < $_; + push @_, random_word while @_ < $_; push @_, (qw(net com))[int rand 2]; $host = join ".", @_; - $rhost = $host; + $resolved_host = $host; } - $user = (0, 0, 1)[int rand 3]? "-": randword; - $htver = (qw(HTTP/1.1 HTTP/1.1 HTTP/1.1 HTTP/1.0))[int rand 4]; + $user = (0, 0, 1)[int rand 3]? "-": random_word; + $http_ver = (qw(HTTP/1.1 HTTP/1.1 HTTP/1.1 HTTP/1.0))[int rand 4]; # 3-5 log entries foreach host - $hlogs = 3 + int rand 3; - @hlogs = qw(); - while (@hlogs < $hlogs) { - my ($ttxt, $method, $url, $dirs, @dirs, $type, $status, $size); + $count = 3 + int rand 3; + @host_logs = qw(); + while (@host_logs < $count) { + my ($time, $method, $url, $dirs, @dirs, $type, $status, $size); my $record; # 0-2 seconds later $t += int rand 3; @@ -560,24 +568,24 @@ sub mkrndlog_normal($) { @_ = gmtime($t + $tz); $_[5] += 1900; $_[4] = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$_[4]]; - $ttxt = sprintf "%02d/%s/%04d:%02d:%02d:%02d %+05d", + $time = sprintf "%02d/%s/%04d:%02d:%02d:%02d %+05d", @_[3,4,5,2,1,0], int($tz / 3600) * 100 + ($tz - int($tz / 3600) * 3600) / 60; - + $method = (qw(GET GET GET HEAD POST))[int rand 5]; - + # Generate a random URL # 0-3 levels of directories $dirs = int rand 4; @dirs = qw(); - push @dirs, "/" . randword while @dirs < $dirs; + push @dirs, "/" . random_word while @dirs < $dirs; $type = ("", qw(html html txt css png jpg))[int rand 7]; if ($type eq "") { $url = join("", @dirs) . "/"; } else { - $url = join("", @dirs) . "/" . randword . ".$type"; + $url = join("", @dirs) . "/" . random_word . ".$type"; } - + $status = (200, 200, 200, 200, 304, 400, 403, 404)[int rand 8]; if ($status == 304) { $size = 0; @@ -585,24 +593,24 @@ sub mkrndlog_normal($) { $size = 200 + int rand 35000; } $record = sprintf "%s - %s [%s] \"%s %s %s\" %d %d\n", - $host, $user, $ttxt, $method, $url, $htver, $status, $size; - $rlogs{$record} = sprintf "%s - %s [%s] \"%s %s %s\" %d %d\n", - $rhost, $user, $ttxt, $method, $url, $htver, $status, $size; - push @hlogs, $record; + $host, $user, $time, $method, $url, $http_ver, $status, $size; + $resolved_logs{$record} = sprintf "%s - %s [%s] \"%s %s %s\" %d %d\n", + $resolved_host, $user, $time, $method, $url, $http_ver, $status, $size; + push @host_logs, $record; } - push @logs, @hlogs; + push @logs, @host_logs; # 0-5 seconds later $t += int rand 6; } - + # Insert 1-2 malformed lines $malformed = 1 + int rand 2; while ($malformed > 0) { - my ($line, $pos); + my $line; # Generate the random malformed line $_ = 3 + int rand 5; @_ = qw(); - push @_, randword while @_ < $_; + push @_, random_word while @_ < $_; $line = join(" ", @_) . ".\n"; $line =~ s/^(.)/uc $1/e; # The position to insert the line @@ -610,93 +618,93 @@ sub mkrndlog_normal($) { @logs = (@logs[0...$_], $line, @logs[$_+1...$#logs]); $malformed--; } - + # Compose the content $content = join "", @logs; - $rcontent = join "", map exists $rlogs{$_}? $rlogs{$_}: $_, @logs; + $resolved_content = join "", map exists $resolved_logs{$_}? $resolved_logs{$_}: $_, @logs; # Output the file - fwrite($file, $content); + write_file($file, $content); # Return the content - return ($content, $rcontent); + return ($content, $resolved_content); } -# mkrndlog_noip: Create a random log file without IP. -sub mkrndlog_noip($) { +# Create a random log file that are fully resolved. +sub make_resolved_log_file($) { local ($_, %_); my ($file, $hosts, @logs, $t, $content, $malformed, $tz); $file = $_[0]; - + @logs = qw(); - + # Start from sometime in the past year $t = time - int rand(86400*365); # Time zone $tz = (-12 + (int rand 53) / 2) * 3600; - + # 3-5 hosts $hosts = 3 + int rand 3; for (my $i = 0; $i < $hosts; $i++) { - my ($host, $user, $htver, @hlogs, $hlogs); + my ($host, $user, $http_ver, @host_logs, $count); # Generate a random domain name # 3-5 levels, end with net or com $_ = 2 + int rand 3; @_ = qw(); - push @_, randword while @_ < $_; + push @_, random_word while @_ < $_; push @_, (qw(net com))[int rand 2]; $host = join ".", @_; - $user = (0, 0, 1)[int rand 3]? "-": randword; - $htver = (qw(HTTP/1.1 HTTP/1.1 HTTP/1.1 HTTP/1.0))[int rand 4]; + $user = (0, 0, 1)[int rand 3]? "-": random_word; + $http_ver = (qw(HTTP/1.1 HTTP/1.1 HTTP/1.1 HTTP/1.0))[int rand 4]; # 3-5 log entries foreach host - $hlogs = 3 + int rand 3; - @hlogs = qw(); - while (@hlogs < $hlogs) { - my ($ttxt, $method, $url, $dirs, @dirs, $type, $status, $size); + $count = 3 + int rand 3; + @host_logs = qw(); + while (@host_logs < $count) { + my ($time, $method, $url, $dirs, @dirs, $type, $status, $size); # 0-2 seconds later $t += int rand 3; # Time text @_ = gmtime($t + $tz); $_[5] += 1900; $_[4] = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$_[4]]; - $ttxt = sprintf "%02d/%s/%04d:%02d:%02d:%02d %+05d", + $time = sprintf "%02d/%s/%04d:%02d:%02d:%02d %+05d", @_[3,4,5,2,1,0], int($tz / 3600) * 100 + ($tz - int($tz / 3600) * 3600) / 60; - + $method = (qw(GET GET GET HEAD POST))[int rand 5]; - + # Generate a random URL # 0-3 levels of directories $dirs = int rand 4; @dirs = qw(); - push @dirs, "/" . randword while @dirs < $dirs; + push @dirs, "/" . random_word while @dirs < $dirs; $type = ("", qw(html html txt css png jpg))[int rand 7]; if ($type eq "") { $url = join("", @dirs) . "/"; } else { - $url = join("", @dirs) . "/" . randword . ".$type"; + $url = join("", @dirs) . "/" . random_word . ".$type"; } - + $status = (200, 200, 200, 200, 304, 400, 403, 404)[int rand 8]; if ($status == 304) { $size = 0; } else { $size = 200 + int rand 35000; } - push @hlogs, sprintf "%s - %s [%s] \"%s %s %s\" %d %d\n", - $host, $user, $ttxt, $method, $url, $htver, $status, $size; + push @host_logs, sprintf "%s - %s [%s] \"%s %s %s\" %d %d\n", + $host, $user, $time, $method, $url, $http_ver, $status, $size; } - push @logs, @hlogs; + push @logs, @host_logs; # 0-5 seconds later $t += int rand 6; } - + # Insert 1-2 malformed lines $malformed = 1 + int rand 2; while ($malformed > 0) { - my ($line, $pos); + my $line; # Generate the random malformed line $_ = 3 + int rand 5; @_ = qw(); - push @_, randword while @_ < $_; + push @_, random_word while @_ < $_; $line = join(" ", @_) . ".\n"; $line =~ s/^(.)/uc $1/e; # The position to insert the line @@ -704,47 +712,51 @@ sub mkrndlog_noip($) { @logs = (@logs[0...$_], $line, @logs[$_+1...$#logs]); $malformed--; } - + # Compose the content $content = join "", @logs; # Output the file - fwrite($file, $content); + write_file($file, $content); # Return the content return ($content, $content); } -# mkrndlog_empty: Create an empty log file. -sub mkrndlog_empty($) { +# Create an empty log file. +sub make_empty_log_file($) { local ($_, %_); $_ = $_[0]; - fwrite($_, ""); + write_file($_, ""); return ("", ""); } -# randword: Supply a random English word -sub randword() { +# Supply a random English word +sub random_word() { local ($_, %_); @_ = qw( -culminates spector thule tamil sages fasten bothers intricately librarian -mist criminate impressive scissor trance standardizing enabler athenians -planers decisions salvation wetness fibers cowardly winning call stockton -bifocal rapacious steak reinserts overhaul glaringly playwrights wagoner -garland hampered effie messy despaired orthodoxy bacterial bernardine driving -danization vapors uproar sects litmus sutton lacrosse); +hard-to-find striped poor scene miniature marble error shelter clear settle +march breath tested symptomatic delicate road punish grain fabulous camp +authority love system placid bake maddening sleep precious crabby lovely jolly +wrist park common volleyball tick judicious degree alluring hydrant oatmeal +aboard light spare delirious unwritten unnatural existence deadpan cagey +disastrous station fear dam adorable grape event silent extra-large shame meaty +husky drag religion extra-small pot valuable deceive obese seed history +wholesale tremble delightful leather cabbage death tub loss twig hate noxious +trashy sleet bleach quizzical familiar nappy teaching private yak turkey foolish +concentrate reject tacit goofy men ajar communicate); return $_[int rand @_]; } -# randip: Supply a random IP +# Supply a random IP # Big public web companies have more reliable reverse DNS -sub randip() { +sub random_ip() { local ($_, %_); # Initialize our resolvable IP pool - if (!defined $RANDIP) { + if (!defined $RANDOM_IP) { my (@ip, @hosts); - $RANDIP = {}; + $RANDOM_IP = {}; @ip = qw(); # Famous websites - they are resolved to several IPs, and their - # reverse domain is guarenteed by the akadns.net service. + # reverse domain is guaranteed by the akadns.net service. foreach my $host (qw(www.google.com www.yahoo.com www.microsoft.com)) { # Find the addresses @@ -764,7 +776,7 @@ sub randip() { # Not match next if $_ ne $ip; # OK. Record it. - $$RANDIP{$ip} = $host; + $$RANDOM_IP{$ip} = $host; } # Hosts reliably resolve to themselves @hosts = qw(); @@ -790,16 +802,16 @@ sub randip() { # Not match next if $_ ne $host; # OK. Record it. - $$RANDIP{$ip} = $host; + $$RANDOM_IP{$ip} = $host; } } - # 1: Resolvables - if (keys %$RANDIP > 0 && int rand 2) { - @_ = sort keys %$RANDIP; + # 1: Resolvable + if (keys %$RANDOM_IP > 0 && int rand 2) { + @_ = sort keys %$RANDOM_IP; $_ = $_[int rand @_]; - return ($_, $$RANDIP{$_}); + return ($_, $$RANDOM_IP{$_}); } - # 0: Unresolvables + # 0: Unresolvable # Use loopback (127.0.0.0/8) and link local (169.254.0.0/16) do { if (int rand 2) {