hoz-165/ 777 0 0 0 10020663420 5133 5hoz-165/COPYING 777 0 0 43644 10000545012 6276 0 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. hoz-165/getopt.c 777 0 0 101241 10004235736 6732 0/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO #define _NO_PROTO #endif #ifdef HAVE_CONFIG_H #include #endif #if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ #include #include #endif /* GNU C library. */ #ifdef VMS #include #if HAVE_STRING_H - 0 #include #endif #endif #if defined (WIN32) && !defined (__CYGWIN32__) /* It's not Unix, really. See? Capital letters. */ #include #define getpid() GetCurrentProcessId() #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ #ifdef HAVE_LIBINTL_H #include #define _(msgid) gettext (msgid) #else #define _(msgid) (msgid) #endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = NULL; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ int __getopt_initialized = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ #include #define my_index strchr #else /* Avoid depending on library functions or files whose names are inconsistent. */ char *getenv(); static char *my_index(str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ #if !defined (__STDC__) || !__STDC__ /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen(const char *); #endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; #ifdef _LIBC /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ static const char *nonoption_flags; static int nonoption_flags_len; static int original_argc; static char *const *original_argv; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void store_args(int argc, char *const *argv) __attribute__ ((unused)); static void store_args(int argc, char *const *argv) { /* XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ original_argc = argc; original_argv = argv; } text_set_element(__libc_subinit, store_args); #endif /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ #if defined (__STDC__) && __STDC__ static void exchange(char **); #endif static void exchange(argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined (__STDC__) && __STDC__ static const char *_getopt_initialize(int, char *const *, const char *); #endif static const char *_getopt_initialize(argc, argv, optstring) int argc; char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind = 1; nextchar = NULL; posixly_correct = getenv("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; #ifdef _LIBC if (posixly_correct == NULL && argc == original_argc && argv == original_argv) { /* Bash 2.0 puts a special variable in the environment for each command it runs, specifying which ARGV elements are the results of file name wildcard expansion and therefore should not be considered as options. */ char var[100]; sprintf(var, "_%d_GNU_nonoption_argv_flags_", getpid()); nonoption_flags = getenv(var); if (nonoption_flags == NULL) nonoption_flags_len = 0; else nonoption_flags_len = strlen(nonoption_flags); } else nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal(argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { optarg = NULL; if (!__getopt_initialized || optind == 0) { optstring = _getopt_initialize(argc, argv, optstring); optind = 1; /* Don't scan ARGV[0], the program name. */ __getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #ifdef _LIBC #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ && nonoption_flags[optind] == '1')) #else #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp(argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) return -1; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index(optstring, argv[optind] [1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp(p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen(p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf(stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen(nextchar); optind++; optopt = 0; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) if (argv[optind - 1][1] == '-') /* --option */ fprintf(stderr, _ ("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf(stderr, _ ("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); nextchar += strlen(nextchar); optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf(stderr, _ ("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen(nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen(nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index(optstring, *nextchar) == NULL) { if (opterr) { if (argv[optind][1] == '-') /* --option */ fprintf(stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ fprintf(stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index(optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (opterr) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf(stderr, _("%s: illegal option -- %c\n"), argv[0], c); else fprintf(stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf(stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp(p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == strlen(p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf(stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen(nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) fprintf(stderr, _("\ %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); nextchar += strlen(nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf(stderr, _ ("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen(nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen(nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf(stderr, _ ("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt(argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal(argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* Not ELIDE_CODE. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main(argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt(argc, argv, "abc:d:0123456789"); if (c == -1) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf("option %c\n", c); break; case 'a': printf("option a\n"); break; case 'b': printf("option b\n"); break; case 'c': printf("option c with value `%s'\n", optarg); break; case '?': break; default: printf("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf("non-option ARGV-elements: "); while (optind < argc) printf("%s ", argv[optind++]); printf("\n"); } exit(0); } #endif /* TEST */ hoz-165/getopt.h 777 0 0 11761 10004235736 6726 0/* Declarations for getopt. Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GETOPT_H #define _GETOPT_H 1 #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { #if defined (__STDC__) && __STDC__ const char *name; #else char *name; #endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ #define no_argument 0 #define required_argument 1 #define optional_argument 2 #if defined (__STDC__) && __STDC__ #ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt(int argc, char *const *argv, const char *shortopts); #else /* not __GNU_LIBRARY__ */ extern int getopt(); #endif /* __GNU_LIBRARY__ */ extern int getopt_long(int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only(int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal(int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind, int long_only); #else /* not __STDC__ */ extern int getopt(); extern int getopt_long(); extern int getopt_long_only(); extern int _getopt_internal(); #endif /* __STDC__ */ #ifdef __cplusplus } #endif #endif /* _GETOPT_H */ hoz-165/getopt1.c 777 0 0 11776 10004235736 7010 0/* getopt_long and getopt_long_only entry points for GNU getopt. Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include #endif #include "getopt.h" #if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #endif #ifndef NULL #define NULL 0 #endif int getopt_long(argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal(argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only(argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal(argc, argv, options, long_options, opt_index, 1); } #endif /* Not ELIDE_CODE. */ #ifdef TEST #include int main(argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, {"create", 0, 0, 0}, {"file", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "abc:d:0123456789", long_options, &option_index); if (c == -1) break; switch (c) { case 0: printf("option %s", long_options[option_index].name); if (optarg) printf(" with arg %s", optarg); printf("\n"); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf("option %c\n", c); break; case 'a': printf("option a\n"); break; case 'b': printf("option b\n"); break; case 'c': printf("option c with value `%s'\n", optarg); break; case 'd': printf("option d with value `%s'\n", optarg); break; case '?': break; default: printf("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf("non-option ARGV-elements: "); while (optind < argc) printf("%s ", argv[optind++]); printf("\n"); } exit(0); } #endif /* TEST */ hoz-165/hoz.c 777 0 0 50764 10014424714 6222 0/* * hoz - Hacha Open Zource * Copyright (C) 2004 Gustavo Picon (http://hoz.sourceforge.net/) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #if defined(WIN32) #define HOZ_PATHSEP '\\' #else #define HOZ_PATHSEP '/' #endif #include "hoz.h" char outpath[MAXLEN]; size_t fullsize, partsize, headersize; int showprogress, forceow, simulate; /** * hoz_echo - displays something based on a code * @code: the event code * @xtra: extra information about an event * * not all the events have a xtra parameter */ void hoz_echo(const int code, const char *xtra) { char foo[1024]; foo[0] = 0; switch (code) { case 301: hoz_print(HOZ_COPYRIGHT1); hoz_lf(); hoz_print(HOZ_COPYRIGHT2); hoz_lf(); break; case 401: hoz_echo(301, NULL); hoz_lf(); sprintf(foo, HOZ_USAGE_1, xtra); hoz_print(foo); hoz_lf(); hoz_print(HOZ_USAGE_2); hoz_lf(); hoz_print(HOZ_USAGE_3); hoz_lf(); hoz_print(HOZ_USAGE_4); hoz_lf(); hoz_print(HOZ_USAGE_5); hoz_lf(); hoz_print(HOZ_USAGE_6); hoz_lf(); hoz_print(HOZ_USAGE_7); hoz_lf(); hoz_print(HOZ_USAGE_8); hoz_lf(); hoz_print(HOZ_USAGE_9); hoz_lf(); break; case 402: /* * it's gone */ break; case 403: hoz_lf(); hoz_print(HOZ_ENDDOTO); hoz_lf(); break; case 404: hoz_lf(); sprintf(foo, HOZ_NOFILE, xtra); hoz_print(foo); hoz_lf(); break; case 405: hoz_lf(); sprintf(foo, HOZ_BADHEADER, xtra); hoz_print(foo); hoz_lf(); break; case 406: hoz_lf(); sprintf(foo, HOZ_BADPARTS, xtra); hoz_print(foo); hoz_lf(); break; case 407: hoz_lf(); sprintf(foo, HOZ_ERROPENWRITE, xtra); hoz_print(foo); hoz_lf(); break; case 408: hoz_lf(); sprintf(foo, HOZ_ERROPENREAD, xtra); hoz_print(foo); hoz_lf(); break; case 409: hoz_lf(); sprintf(foo, HOZ_ERRPARTSIZE, xtra); hoz_print(foo); hoz_lf(); break; case 410: hoz_lf(); sprintf(foo, HOZ_ERRPROCESS, xtra); hoz_print(foo); hoz_lf(); break; case 411: hoz_lf(); sprintf(foo, HOZ_ERROUTNODIR, xtra); hoz_print(foo); hoz_lf(); break; case 412: hoz_lf(); sprintf(foo, HOZ_ERRWRITE, xtra); hoz_print(foo); hoz_lf(); break; case 413: sprintf(foo, HOZ_BADARGSOPT, xtra); hoz_print(foo); hoz_lf(); sprintf(foo, HOZ_HMOREINFO, xtra); hoz_print(foo); hoz_lf(); break; case 414: sprintf(foo, HOZ_BADARGSFILE, xtra); hoz_print(foo); hoz_lf(); sprintf(foo, HOZ_HMOREINFO, xtra); hoz_print(foo); hoz_lf(); break; case 415: sprintf(foo, HOZ_HMOREINFO, xtra); hoz_print(foo); hoz_lf(); break; } } /** * hoz_cut_main - cut files main function * @ifname: "file.ext" file name */ int hoz_cut_main(const char *ifname) { FILE *f_in, *f_out; /* file handles */ clock_t initime; /* to calculate the time spent */ unsigned char buf[FILESTREAMSIZE + 1], /* buffer to copy */ foo[MAXLEN], /* current 'file.n' filename */ bar[MAXLEN], /* "?????" */ baz[MAXLEN], qux; /* useless byte in the header, * must be included for compat with hacha */ size_t i, /* foobar */ len, /* bytes read */ bfile, /* bytes read in current file file.n */ btotal, /* total bytes read */ dif; double elapsed; /* total time elapsed */ char *ifnopath; /* input fname without path */ f_in = fopen(ifname, "rb"); if (!f_in) { hoz_echo(408, NULL); return 408; } i = bfile = btotal = 0; ifnopath = hoz_nopath(ifname); sprintf(baz, "%s.%u", ifnopath, i); mergepath(outpath, baz, foo); remove(foo); f_out = fopen(foo, "ab"); if (!f_out) { fclose(f_in); hoz_echo(407, foo); return 407; } fullsize = fsize(ifname); /* store the time */ initime = clock(); /* begin control byte */ /* * This code was broken, thanks Eric for reporting this * sprintf(buf, "%u", partsize); * len = strlen(buf); * qux = 24 + len + strlen(ifnopath) + ((len <= 4) ? 1 : 3); */ sprintf(buf, "%u%u%s", partsize, fullsize, ifnopath); qux = 20 + strlen(buf); /* end control byte */ strcpy(bar, "?????"); sprintf(buf, "%s%c %s%s%s%u%s%u%s", bar, qux, bar, hoz_nopath(ifname), bar, fullsize, bar, partsize, bar); len = (size_t) strlen(buf); buf[6] = buf[7] = buf[8] = 0; if (fwrite(buf, sizeof(char), len, f_out) != len) { fclose(f_in); fclose(f_out); hoz_echo(412, foo); return 412; } sprintf(bar, HOZ_CUTTOFILE, hoz_nopath(foo)); hoz_print(bar); for (;;) { if (partsize <= FILESTREAMSIZE) { len = (size_t) fread(buf, sizeof(char), FILESTREAMSIZE, f_in); if (fwrite(buf, sizeof(char), len, f_out) != len) { fclose(f_in); fclose(f_out); hoz_echo(412, foo); return 412; } if (showprogress) { hoz_print(PROGRMETERSTR); /* progress meter? */ } bfile = len; btotal += len; fclose(f_out); hoz_lf(); sprintf(bar, HOZ_PROGRESS, btotal, fullsize, (float) ((float) btotal / (float) fullsize) * 100); hoz_print(bar); hoz_lf(); if (feof(f_in)) { break; } ++i; sprintf(baz, "%s.%u", ifnopath, i); mergepath(outpath, baz, foo); remove(foo); f_out = fopen(foo, "ab"); if (!f_out) { fclose(f_in); hoz_echo(407, foo); return 407; } sprintf(bar, HOZ_CUTTOFILE, hoz_nopath(foo)); hoz_print(bar); } else { len = (size_t) fread(buf, sizeof(char), FILESTREAMSIZE, f_in); if (bfile + len < partsize) { if (fwrite(buf, sizeof(char), len, f_out) != len) { fclose(f_in); fclose(f_out); hoz_echo(412, foo); return 412; } if (showprogress) { hoz_print(PROGRMETERSTR); /* progress meter? */ } bfile += len; } else { dif = partsize - bfile; if (fwrite(buf, sizeof(char), dif, f_out) != dif) { fclose(f_in); fclose(f_out); hoz_echo(412, foo); return 412; } if (showprogress) { hoz_print(PROGRMETERSTR); /* progress meter? */ } bfile += dif; fclose(f_out); hoz_lf(); sprintf(bar, HOZ_PROGRESS, btotal, fullsize, (float) ((float) btotal / (float) fullsize) * 100); hoz_print(bar); hoz_lf(); ++i; bfile = 0; sprintf(baz, "%s.%u", ifnopath, i); mergepath(outpath, baz, foo); remove(foo); f_out = fopen(foo, "ab"); if (!f_out) { fclose(f_in); hoz_echo(407, foo); return 407; } sprintf(bar, HOZ_CUTTOFILE, hoz_nopath(foo)); hoz_print(bar); if (fwrite(buf + dif, sizeof(char), len - dif, f_out) != (len - dif)) { fclose(f_in); fclose(f_out); hoz_echo(412, foo); return 412; } if (showprogress) { hoz_print(PROGRMETERSTR); /* progress meter? */ } bfile += (len - dif); } btotal += len; if (feof(f_in)) { hoz_lf(); sprintf(bar, HOZ_PROGRESS, btotal, fullsize, (float) ((float) btotal / (float) fullsize) * 100); hoz_print(bar); hoz_lf(); break; } } } sprintf(foo, "%s.%u", ifname, ++i); remove(foo); fclose(f_in); fclose(f_out); /* if the sum of the file sizes isn't the same as the original file size * then the operation failed */ if (btotal != fullsize) { sprintf(foo, "%u/%u", btotal, fullsize); hoz_echo(410, foo); return 410; } /* calculate the time spent in this operation */ elapsed = (double) (clock() - initime) / CLOCKS_PER_SEC; elapsed = (elapsed) ? elapsed : 0.001; /* can't be 0 seconds! */ /* yes */ hoz_lf(); sprintf(bar, HOZ_CUTEND, hoz_nopath(ifname), btotal, elapsed, (size_t) ((double) btotal / elapsed), outpath); hoz_print(bar); hoz_lf(); return 0; } /** * hoz_paste_main - paste files main function * @ifname: "file.0" file name */ int hoz_paste_main(const char *ifname) { FILE *f_in, *f_out; /* file handles */ clock_t initime; /* to calculate the time spent */ unsigned char buf[FILESTREAMSIZE + 1], /* buffer to copy */ foo[MAXLEN], /* current 'file.n' filename */ bar[MAXLEN], /* blah */ basename[MAXLEN], /* base filename (file.*) */ origfname[MAXLEN], *outfname; size_t i, /* foobar */ len, /* bytes read */ bfile, /* bytes read in current file file.n */ btotal; /* total bytes read */ double elapsed; /* total time elapsed */ /* verifying that the input filename ends in ".0" */ if (ifname[strlen(ifname) - 1] != '0' || ifname[strlen(ifname) - 2] != '.') { hoz_echo(403, NULL); return 403; } /* error if the input file can't be opened */ f_in = fopen(ifname, "r"); if (!f_in) { hoz_echo(404, ifname); return 404; } fclose(f_in); /* retrieving header info */ i = hoz_paste_hr(ifname, origfname); /* if hoz_paste_hr() returns an error, end process */ if (i) { return i; } /* storing the base file name, just removing the "0" from "file.0" */ strcpy(basename, ifname); basename[strlen(basename) - 1] = 0; /* total bytes read = 0 */ btotal = 0; outfname = (char *) malloc(sizeof(char) * (strlen(origfname) + strlen(outpath) + 3)); mergepath(outpath, origfname, outfname); /* if the file exists and !forceow, ask what to do */ if (!forceow && isfile(outfname) && !hoz_replace_ask(outfname)) { free(outfname); return 302; } /* removing the output file if it already exists */ remove(outfname); /* opening the output file: (b)inary (w)rite */ f_out = fopen(outfname, "wb"); /* error if can't be openned */ if (!f_out) { hoz_echo(407, outfname); free(outfname); return 407; } /* telling the user what are we doing */ hoz_lf(); sprintf(bar, HOZ_BEGINPASTE, origfname, fullsize); hoz_print(bar); hoz_lf(); hoz_lf(); /* store the time */ initime = clock(); for (i = 0;; i++) { /* generating the "file.n" string, storing it in foo */ sprintf(foo, "%s%d", basename, i); /* openning the input file: (b)inary (r)ead */ f_in = fopen(foo, "rb"); /* bytes read in file = 0 */ bfile = 0; if (!f_in) { break; /* last file, end */ } else { /* extracting file.n... */ sprintf(bar, HOZ_PASTEFILE, hoz_nopath(foo)); hoz_print(bar); if (i == 0) { /* if we are extracting the first file (*.0), * discard the header */ fread(buf, sizeof(char), headersize, f_in); } for (;;) { /* appending file.n to the output file */ len = (size_t) fread(buf, sizeof(char), FILESTREAMSIZE, f_in); if (len) { if (fwrite(buf, sizeof(char), len, f_out) != len) { fclose(f_in); fclose(f_out); hoz_echo(412, outfname); free(outfname); return 412; } /* fwrite(buf, sizeof(char), len, f_out); *//* argh! */ btotal += len; bfile += len; } if (showprogress) { hoz_print(PROGRMETERSTR); /* progress meter? */ } if (feof(f_in)) { break; } } /* displays info... */ hoz_lf(); sprintf(bar, HOZ_PROGRESS, btotal, fullsize, (float) ((float) btotal / (float) fullsize) * 100); hoz_print(bar); hoz_lf(); } /* close the file.n handle */ fclose(f_in); if (bfile < partsize) { /* if the current file.n file is smaller than the size defined in * the file.0 header for a partial file, end process */ break; } } /* close file handles */ fclose(f_out); /* if the extracted file size isn't the same as the file defined in the * file.0 header, then the operation failed */ if (btotal != fullsize) { if (btotal < fullsize) { hoz_lf(); sprintf(bar, HOZ_PASTEMISSING, foo); hoz_print(bar); hoz_lf(); } sprintf(foo, "%u/%u", btotal, fullsize); hoz_echo(406, foo); free(outfname); return 406; } /* calculate the time spent in this operation */ elapsed = (double) (clock() - initime) / CLOCKS_PER_SEC; elapsed = (elapsed) ? elapsed : 0.001; /* can't be 0 seconds! */ /* yes */ hoz_lf(); sprintf(bar, HOZ_PASTEEND, origfname, btotal, elapsed, (size_t) ((double) btotal / elapsed), outpath); hoz_print(bar); hoz_lf(); free(outfname); return 0; } /** * hoz_paste_hr - reads the header from the file.0 file * @ifname: "file.0" filename */ int hoz_paste_hr(const char *ifname, const char *origfname) { int i, read, ssize; char buf[FILESTREAMSIZE + 1], aux[MAXLEN], *foo, *bar; FILE *f; bar = (char *) origfname; headersize = 0; ssize = FILESTREAMSIZE; if (ssize < 512) { ssize = 512; } f = fopen(ifname, "rb"); read = (int) fread(buf, sizeof(char), ssize, f); foo = buf; if (!read || strncmp(foo, "?????", 5)) { hoz_echo(405, ifname); return 405; } foo += 5; headersize += 5; i = 0; for (i = 0; *foo != '?'; foo++, i++, headersize++) { if (i == 20) { hoz_echo(405, ifname); return 405; } } if (strncmp(foo, "?????", 5)) { hoz_echo(405, ifname); return 405; } foo += 5; headersize += 5; if (*foo == '?') { hoz_echo(405, ifname); return 405; } for (i = 0; *foo != '?'; foo++, i++, headersize++) { if (i == 255) { hoz_echo(405, ifname); return 405; } *bar++ = *foo; } *bar = '\0'; if (strncmp(foo, "?????", 5)) { hoz_echo(405, ifname); return 405; } foo += 5; headersize += 5; if (*foo == '?') { hoz_echo(405, ifname); return 405; } for (i = 0; *foo != '?'; foo++, i++, headersize++) { if (i == 255) { hoz_echo(405, ifname); return 405; } aux[i] = *foo; } aux[i] = 0; fullsize = (int) atol(aux); if (!fullsize) { hoz_echo(405, ifname); return 405; } if (strncmp(foo, "?????", 5)) { hoz_echo(405, ifname); return 405; } foo += 5; headersize += 5; if (*foo == '?') { hoz_echo(405, ifname); return 405; } for (i = 0; *foo != '?'; foo++, i++, headersize++) { if (i == 255) { hoz_echo(405, ifname); return 405; } aux[i] = *foo; } aux[i] = 0; partsize = (int) atol(aux); if (!partsize) { hoz_echo(405, ifname); return 405; } if (strncmp(foo, "?????", 5)) { hoz_echo(405, ifname); return 405; } foo += 5; headersize += 5; fclose(f); return 0; } /** * fsize - Retrieves the size of a file * @path: filename */ size_t fsize(const char *path) { struct stat stats; stat(path, &stats); return (size_t) stats.st_size; } /** * isfile - a file exists? * @path: path to file */ int isfile(const char *path) { struct stat stats; return (!stat(path, &stats) && S_ISREG(stats.st_mode)); } /** * isdir - a directory exists? * @path: path to dir */ int isdir(const char *path) { struct stat stats; return (!stat(path, &stats) && S_ISDIR(stats.st_mode)); } /** * hoz_nopath - returns a file name, without the path * @file: the full filename */ char *hoz_nopath(const char *file) { char *aux; aux = (char *) (file + strlen(file)); while (*aux != HOZ_PATHSEP) { if (aux == file) { return aux; } aux--; } return aux + 1; } /** * mergepath - returns a file name, without the path * @dir: the full diectory * @fname: the full filename * @out: the output */ int mergepath(const char *dir, const char *fname, char *out) { const char *dirp; dirp = dir; if (!fname || !*fname) { return -1; } if (strcmp(dir, ".")) { while (*dirp) { *out++ = *dirp++; } if (dirp > dir && *(dirp - 1) != HOZ_PATHSEP) { *out++ = HOZ_PATHSEP; } } while (*fname) { *out++ = *fname++; } *out = '\0'; return 0; } /* * atolp(string) * returns a _positive_ number extracted from the string * if the string wasn't a number a 0 will be returned */ int atolp(const char *s) { int n = 0; char *c = (char*)s; while (*c) { if (*c >= '0' && *c <= '9') { n *= 10; n += (*c++ - '0'); } else { return 0; } } return n; } /* * atolmp(string, multiplier) * returns a _positive_ number extracted from the string and multiplies it * always returns an integer, 0 if the string wasn't a number */ int atolmp(const char *s, const int mult) { size_t n = 0, p = 0, d = 1; char *c = (char*)s; while (*c) { if (*c == '.') { if (p) { return 0; /* more than one '.' in the string? error */ } p = 1; *c++; } else if (*c >= '0' && *c <= '9') { if (p) { d *= 10; /* final decimal division */ } n *= 10; n += (*c++ - '0'); } else { return 0; } } if (d) { n /= d; } n *= (size_t)mult; if (n < 0) { printf("DA FOC!\n"); /* number is too big for size_t, error */ return 0; } return n; } hoz-165/hoz.h 777 0 0 26377 10014425136 6231 0/* * hoz - Hacha Open Zource * Copyright (C) 2004 Gustavo Picon (http://hoz.sourceforge.net/) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* #define HOZ_WIN *//* uncomment to compile for ms windows (GUI mode) */ /* #define HOZ_GTK */ /* language: Makefile will take care of these */ /* #define HOZ_LANG_EN *//* english */ /* #define HOZ_LANG_ES *//* español */ /* #define HOZ_LANG_FR *//* française */ #define HOZ_PROGRAM "HOZ" #define HOZ_VERSION "1.65" #define HOZ_URL "http://hoz.sourceforge.net/" #define HOZ_CRAUTH "Copyright (c) 2004 Gustavo Picon" #define HOZ_PROGNAME HOZ_PROGRAM " " HOZ_VERSION #define HOZ_COPYRIGHT1 HOZ_PROGNAME " " HOZ_CRAUTH /* " " __DATE__ */ #define HOZ_COPYRIGHT2 " " HOZ_URL #define PROGRMETERSTR " -" #define MAXLEN 1024 /* max length of a pathname */ #define FILESTREAMSIZE 4096 /* < 4096 */ #include #include #include #include #include #include #if defined(HOZ_LANG_EN) #define HOZ_REPLACE_C "Output file '%s' exists, replace? (Y/N) " #define HOZ_BADARGSOPT "%s: You must specify one of the '-cph' options" #define HOZ_BADARGSFILE "%s: Missing file argument" #define HOZ_HMOREINFO "Try '%s --help' for more information." #define HOZ_USAGE_1 "%s [-pvf] [-c size[K|M]] [-o outpath] inputfname" #define HOZ_USAGE_2 "Options:" #define HOZ_USAGE_3 " -c --cut cut (file->pieces)" #define HOZ_USAGE_4 " -p --paste paste (pieces->file)" #define HOZ_USAGE_5 " -v --verbose verbose output" #define HOZ_USAGE_6 " -f --force force overwrite of file when pasting" #define HOZ_USAGE_7 " -o --outpath specify an output directory" #define HOZ_USAGE_8 " -h --help print this help, then exit" #define HOZ_USAGE_9 " --version print hoz program version number, then exit" #define HOZ_ENDDOTO "ERROR: The file must end with a '.0' extension" #define HOZ_NOFILE "ERROR: File not found: %s" #define HOZ_BADHEADER "ERROR: Corrupted file header: %s" #define HOZ_BADPARTS "ERROR: Corrupted .??? files, final_size/real_size: %s" #define HOZ_ERROPENWRITE "ERROR: Cannot open file for writing: %s" #define HOZ_ERROPENREAD "ERROR: Cannot open file for reading: %s" #define HOZ_ERRPARTSIZE "ERROR: Invalid partial size: %s" #define HOZ_ERRPROCESS "ERROR: Operation failed total_files/file_size: %s" #define HOZ_ERROUTNODIR "ERROR: Output path isn't a directory: '%s'" #define HOZ_ERRWRITE "ERROR: Couldn't write to file: '%s'" #define HOZ_CUTTOFILE "* Cutting to file \"%s\": " #define HOZ_PROGRESS "* Progress: %u of %u bytes (%.2f%%)" #define HOZ_CUTEND "*** Processed file: %s (%u bytes) in %.3f seconds (%u bytes/s) [output path='%s']" #define HOZ_BEGINPASTE "*** Extracting file: \"%s\" (%u bytes)" #define HOZ_PASTEFILE "* Extracting \"%s\": " #define HOZ_PASTEMISSING "ERROR: Missing file in paste operation: '%s'" #define HOZ_PASTEEND "*** Extracted file: %s (%u bytes) in %.3f seconds (%u bytes/s) [output path='%s']" #define HOZ_REPLACE_W "File '%s' exists, replace?" #define HOZ_BADSIZE "ERROR: Invalid size: '%s'" #define HOZ_FDPASTE "Hoz/Hacha file to paste" #define HOZ_FDCUT "File to cut" #define HOZ_READY "* Ready!" #define HOZ_PSIZECAPTION "Partial size:" #define HOZ_OUTPCAPTION "Output path:" #define HOZ_CBPRGRCAPTION "Show Progress" #define HOZ_BTNCUTCAPTION "Cut" #define HOZ_BTNPASTECAPTION "Paste" #define HOZ_YESCHARS "yY" #define HOZ_NOCHARS "nN" #endif /* #if defined(HOZ_LANG_EN) */ #if defined(HOZ_LANG_ES) #define HOZ_REPLACE_C "Archivo de salida '%s' ya existe, reemplazar? (S/N) " #define HOZ_BADARGSOPT "%s: Debes especificar una de las opciones '-cph'" #define HOZ_BADARGSFILE "%s: Falta argumento de archivo" #define HOZ_HMOREINFO "Intenta '%s -help' para mas informacion." #define HOZ_USAGE_1 "%s [-pvf] [-c tamano[K|M]] [-o outpath] inputfname" #define HOZ_USAGE_2 "Opciones:" #define HOZ_USAGE_3 " -c --cut cortar (archivo->piezas)" #define HOZ_USAGE_4 " -p --paste pegar (piezas->archivo)" #define HOZ_USAGE_5 " -v --verbose info. descriptiva" #define HOZ_USAGE_6 " -f --force forzar sobreescritura de archivo al pegar" #define HOZ_USAGE_7 " -o --outpath especificar un directorio de salida" #define HOZ_USAGE_8 " -h --help ayuda" #define HOZ_USAGE_9 " --version print hoz program version number, then exit" #if defined(WIN32) && defined(HOZ_WIN) #define HOZ_BADPARTS "ERROR: Archivos .??? corruptos, tamaño_final/tamaño_real: %s" #define HOZ_ERRPARTSIZE "ERROR: Tamaño parcial no válido: %s" #define HOZ_ERRPROCESS "ERROR: Operación fallida total_archivos/tamaño_archivo: %s" #define HOZ_BADSIZE "ERROR: Tamaño no válido: '%s'" #else /* #if defined(WIN32) && defined(HOZ_WIN) */ #define HOZ_BADPARTS "ERROR: Archivos .??? corruptos, tama\xA4o_final/tama\xA4o_real: %s" #define HOZ_ERRPARTSIZE "ERROR: Tama\xA4o parcial no v\xA0lido: %s" #define HOZ_ERRPROCESS "ERROR: Operaci\xA2n fallida total_archivos/tama\xA4o_archivo: %s" #define HOZ_BADSIZE "ERROR: Tama\xA4o no v\xA0lido: '%s'" #endif /* #if defined(WIN32) && defined(HOZ_WIN) */ #define HOZ_PSIZECAPTION "Tam. parcial:" #define HOZ_ERROUTNODIR "ERROR: Path de salida no es un directorio: '%s'" #define HOZ_OUTPCAPTION "Dir destino:" #define HOZ_ENDDOTO "ERROR: El archivo debe terminar con '.0'" #define HOZ_NOFILE "ERROR: Archivo no encontrado: %s" #define HOZ_BADHEADER "ERROR: Cabecera de archivo corrupta: %s" #define HOZ_ERROPENWRITE "ERROR: No se puede abrir archivo para escritura: %s" #define HOZ_ERROPENREAD "ERROR: No se puede abrir archivo para lectura: %s" #define HOZ_ERRWRITE "ERROR: No se pudo escribir al archivo: '%s'" #define HOZ_CUTTOFILE "* Cortando a archivo: \"%s\": " #define HOZ_PROGRESS "* Progreso: %u de %u bytes (%.2f%%)" #define HOZ_CUTEND "*** Archivo cortado: %s (%u bytes) en %.3f segundos (%u bytes/s) [path de sailda='%s']" #define HOZ_BEGINPASTE "*** Pegando archivo: \"%s\" (%u bytes)" #define HOZ_PASTEFILE "* Pegando \"%s\": " #define HOZ_PASTEMISSING "ERROR: Archivo no encontrado al pegar: '%s'" #define HOZ_PASTEEND "*** Archivo pegado: %s (%u bytes) en %.3f segundos (%u bytes/s) [path de salida='%s']" #define HOZ_REPLACE_W "Archivo '%s' existe, reemplazar?" #define HOZ_FDPASTE "Archivo de Hoz/Hacha a pegar" #define HOZ_FDCUT "Archivo a cortar" #define HOZ_READY "* Listo!" #define HOZ_CBPRGRCAPTION "Mostrar Progreso" #define HOZ_BTNCUTCAPTION "Cortar" #define HOZ_BTNPASTECAPTION "Pegar" #define HOZ_YESCHARS "sS" #define HOZ_NOCHARS "nN" #endif /* #if defined(HOZ_LANG_ES) */ #if defined(HOZ_LANG_FR) #define HOZ_REPLACE_C "Ce Fichier '%s' a été déjà créé, vous êtes sûr le remplacer? (OUI/NON) " #define HOZ_BADARGSOPT "%s: Debes especificar una de las opciones '-cph'" #define HOZ_BADARGSFILE "%s: Falta argumento de archivo" #define HOZ_HMOREINFO "Intenta '%s -help' para mas informacion." #define HOZ_USAGE_1 "%s [-pvf] [-c tamano[K|M]] [-o outpath] inputfname" #define HOZ_USAGE_2 "Opciones:" #define HOZ_USAGE_3 " -c --cut cortar" #define HOZ_USAGE_4 " -p --paste pegar" #define HOZ_USAGE_5 " -v --verbose descriptivo" #define HOZ_USAGE_6 " -f --force forzar sobreescritura de archivo al pegar" #define HOZ_USAGE_7 " -o --outpath especificar un directorio de salida" #define HOZ_USAGE_8 " -h --help ayuda" #define HOZ_USAGE_9 " --version hoz version" #define HOZ_BADPARTS "ERREUR: Fichiers .??? corrompus, taille_finale/taille_real: %s" #define HOZ_ERRPARTSIZE "ERREUR: La taille partielle n'est pas valide: %s" #define HOZ_ERRPROCESS "ERREUR: Cet opératión n'est pas possible total_fichier/taille_fichier: %s" #define HOZ_ERROUTNODIR "ERROR: Output path isn't a directory: '%s'" #define HOZ_ERRWRITE "ERROR: Couldn't write to file: '%s'" #define HOZ_BADSIZE "ERREUR: Taille n'est pas valide: '%s'" #define HOZ_PSIZECAPTION "Taille parcielle:" #define HOZ_OUTPCAPTION "Output path:" #define HOZ_ENDDOTO "ERREUR: Le fichier doit terminer avec '.0'" #define HOZ_NOFILE "ERREUR: Ce fichier n'a pas été trouvé: %s" #define HOZ_BADHEADER "ERREUR: La tête de ce fichier est corrompue: %s" #define HOZ_ERROPENWRITE "ERREUR: N'est pas possible ouvrir ce ficheur pour écrire: %s" #define HOZ_ERROPENREAD "ERREUR: N'est pas possible ouvrir ce ficheur pour lire: %s" #define HOZ_CUTTOFILE "* En découpant vers le nouveau ficheur: \"%s\": " #define HOZ_PROGRESS "* Progrès: %u de %u bytes (%.2f%%)" #define HOZ_CUTEND "*** Fichier découpé: %s (%u bytes) en %.3f seconds (%u bytes/s) [output path='%s']" #define HOZ_BEGINPASTE "*** En Collant fichier: \"%s\" (%u bytes)" #define HOZ_PASTEFILE "* En découpant \"%s\": " #define HOZ_PASTEMISSING "ERROR: Missing file in paste operation: '%s'" #define HOZ_PASTEEND "*** Fichier découpé: %s (%u bytes) en %.3f seconds (%u bytes/s) [output path='%s']" #define HOZ_REPLACE_W "Ce fichier '%s' déjà existe , le remplacer?" #define HOZ_FDPASTE "Ficheur de Hoz/Hacha à coller" #define HOZ_FDCUT "Ficheur à couper" #define HOZ_READY "* Voilà!" #define HOZ_CBPRGRCAPTION "Montrer le progrès" #define HOZ_BTNCUTCAPTION "Découper" #define HOZ_BTNPASTECAPTION "Coller" #define HOZ_YESCHARS "oO" #define HOZ_NOCHARS "nN" #endif /* #if defined(HOZ_LANG_FR) */ void hoz_print(const char *); void hoz_lf(); void hoz_echo(const int, const char *); int hoz_cut_main(const char *); int hoz_paste_main(const char *); int hoz_paste_hr(const char *, const char *); size_t fsize(const char *); int isfile(const char *); int isdir(const char *); char *hoz_nopath(const char *); int hoz_replace_ask(const char *); int mergepath(const char *, const char *, char *); int atolp(const char *); int atolmp(const char*, const int); hoz-165/hoz.ico 777 0 0 1376 10000545012 6513 0 è( @€€€€€€€€€€ÀÀÀ€€€ÿÿÿÿÿÿÿÿÿÿÿÿwwwpwwwwpwwwwpwwwpwwwwwwwwwpwwwwpwwwpwwwpwpwwpwppwwppwwpwwpwwwwwwpwwwwpwwpwpwwwpÿÿÿÿ‡ÿÿƒÿÿÁþÿà|ÿðxÿøpÿÿüÿÿüÿÿøÿÿðÿàÿƒÿÿ?ÿ€ÿÀÿàÿð‡ÿðüøÀøøàøøðþðÿÿà?ÿÿÀÿÿ€ÿüÿþÿÿÿÿÀÿÿÿÿÿhoz-165/hoz_private.rc 777 0 0 172 10000545012 10050 0// THIS FILE WILL BE OVERWRITTEN BY DEV-C++! // DO NOT EDIT! A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "hoz.ico" hoz-165/hozcli.c 777 0 0 7077 10014412210 6655 0#include "hoz.h" #include "hozcli.h" #include "getopt.h" extern char outpath[MAXLEN]; extern size_t fullsize, partsize, headersize; extern int showprogress, forceow, simulate; void hoz_print(const char *str) { printf(str); } void hoz_lf() { hoz_print("\n"); } /** * main * * hoz [-pvf] [-c size[k|m|g]] [-o outpath] inputfname */ int main(int argc, char **argv) { int cflag, pflag, oflag, help; char *cval, *ifname; int c, j; int option_index; size_t size_multiplier; static struct option long_options[] = { {"cut", 1, NULL, 'c'}, {"paste", 0, NULL, 'p'}, {"verbose", 0, NULL, 'v'}, {"force", 0, NULL, 'f'}, {"outpath", 1, NULL, 'o'}, {"help", 0, NULL, 'h'}, {"version", 0, NULL, '!'}, {0, 0, NULL, 0} }; cflag = pflag = oflag = showprogress = forceow = simulate = help = 0; cval = ifname = NULL; opterr = 1; size_multiplier = 1; getcwd(outpath, MAXLEN); while (1) { option_index = 0; c = getopt_long(argc, argv, "c:pvfo:h", long_options, &option_index); if (c == -1) { break; } switch (c) { case 'c': cflag = 1; cval = optarg; break; case 'p': pflag = 1; break; case 'v': showprogress = 1; break; case 'o': oflag = 1; strcpy(outpath, optarg); break; case 'f': forceow = 1; break; case 's': simulate = 1; break; case 'h': help = 1; break; case '!': /* dummy hack, there is no short opt for --version */ hoz_echo(301, NULL); return 0; case '?': hoz_echo(415, argv[0]); return 415; } } ifname = argv[optind]; fullsize = 0; partsize = 0; if (argc < 2) { hoz_echo(413, argv[0]); return 413; } if (help) { hoz_echo(401, argv[0]); return 0; } if (!cflag && !pflag) { hoz_echo(413, argv[0]); return 413; } if (cflag) { if (cval && strlen(cval) && strchr("kKmM", cval[strlen(cval)-1])) { switch (cval[strlen(cval)-1]) { case 'k': case 'K': size_multiplier = 1024; break; case 'm': case 'M': size_multiplier = 1024*1024; break; /* case 'g': case 'G': size_multiplier = 1024*1024*1024; */ } cval[strlen(cval)-1] = '\0'; } partsize = atolmp(cval, size_multiplier); if (!partsize) { hoz_echo(409, cval); return 409; } partsize *= size_multiplier; } j = 0; if ((!ifname || !*ifname) || (oflag && (!outpath || !*outpath))) { hoz_echo(414, argv[0]); return 414; } if (!isdir(outpath)) { hoz_echo(411, outpath); return 411; } /* display the program version */ hoz_echo(301, NULL); if (cflag) { /* cut */ return hoz_cut_main(ifname); } else { /* paste */ return hoz_paste_main(ifname); } } /** * hoz_replace_ask - ask the user if an output file should be replaced * @s: filename */ int hoz_replace_ask(const char *s) { unsigned char foo[1024], bar, *baz; sprintf(foo, HOZ_REPLACE_C, s); hoz_lf(); hoz_print(foo); for (bar = 0;;) { bar = fgetc(stdin); for (baz = HOZ_YESCHARS; *baz; ++baz) { if (bar == *baz) { return 1; } } for (baz = HOZ_NOCHARS; *baz; ++baz) { if (bar == *baz) { return 0; } } } } hoz-165/hozcli.h 777 0 0 6 10004235736 6602 0 /**/ hoz-165/hozgtk.c 777 0 0 14263 10014425112 6713 0/* * Initial main.c file generated by Glade. Edit as required. * Glade will not overwrite this file. */ #ifdef HAVE_CONFIG_H # include #endif #include #include "hoz.h" #include "hozgtk.h" #include "hozgtk_i.h" #include "hozgtk_s.h" GtkWidget *window_hoz; GtkWidget *window_bs; /* badsize */ GtkWidget *window_ra; /* replaceask */ GtkWidget *window_fd; /* file dialog */ GtkTextView *rprttextview; GtkTextBuffer *rprtbuf; char hozfile[MAXLEN + 1]; int hozaction; /* 0=debug, 1=cut, 2=paste */ extern char outpath[MAXLEN]; extern size_t fullsize, partsize, headersize; extern int showprogress, forceow, simulate; void hoz_print(const char *str) { GtkTextIter iter; GtkTextMark *mark; gtk_text_buffer_get_end_iter(rprtbuf, &iter); gtk_text_buffer_insert(rprtbuf, &iter, str, -1); /* gtk_text_buffer_insert_with_tags_by_name (rprtbuf, &iter, str, -1, "char_wrap", NULL); */ mark = gtk_text_buffer_get_insert(rprtbuf); gtk_text_view_scroll_to_mark(rprttextview, mark, 0, FALSE, 0, 0); } void hoz_lf() { hoz_print("\n"); } /** * hoz_replace_ask - ask the user if an output file should be replaced * @s: filename */ int hoz_replace_ask(const char *s) { char foo[1024]; sprintf(foo, HOZ_REPLACE_W, s); window_ra = create_dialog_ra(); gtk_window_set_title(GTK_WINDOW(window_ra), HOZ_PROGRAM); gtk_label_set_label(GTK_LABEL (lookup_widget (GTK_WIDGET(window_ra), "label_msg_ra")), foo); gtk_button_set_label(GTK_BUTTON (lookup_widget (GTK_WIDGET(window_ra), "button_yes_ra")), "Ok"); gtk_button_set_label(GTK_BUTTON (lookup_widget (GTK_WIDGET(window_ra), "button_no_ra")), "Cancel"); gtk_widget_show(window_ra); /* this is an ugly hack... damn gtk "modal" dialogs */ return 0; } /** * hoz_ready - useless... */ void hoz_ready() { hoz_lf(); hoz_print(HOZ_READY); hoz_lf(); } /** * hoz_getsize - Gets the size in bytes from the size editbox */ size_t hoz_getsize() { gchar baz[101]; const gchar *foo, *qux; size_t bar, mult; foo = gtk_entry_get_text(GTK_ENTRY (lookup_widget (GTK_WIDGET(window_hoz), "entry_size"))); qux = gtk_entry_get_text(GTK_ENTRY(lookup_widget(GTK_WIDGET(window_hoz),\ "combo_entry_size"))); if (!strcmp(qux, "MiB")) { mult = 1024*1024; } else if (!strcmp(qux, "KiB")) { mult = 1024; } else { mult = 1; } bar = (size_t) atolmp((char *) foo, mult); partsize = (bar) ? bar : 0; if (!partsize && strlen(foo)) { sprintf(baz, HOZ_BADSIZE, foo); if (!window_bs) { window_bs = create_dialog_bs(); } gtk_window_set_title(GTK_WINDOW(window_bs), HOZ_PROGRAM); gtk_label_set_label(GTK_LABEL (lookup_widget (GTK_WIDGET(window_bs), "label_msg_bs")), baz); gtk_button_set_label(GTK_BUTTON (lookup_widget (GTK_WIDGET(window_bs), "okbutton_bs")), "Ok"); gtk_widget_show(window_bs); } return partsize; } /** * hoz_getoutpdir - Gets the output path from the entrybox */ int hoz_getoutpdir() { strcpy(outpath, gtk_entry_get_text(GTK_ENTRY (lookup_widget (GTK_WIDGET(window_hoz), "entry_outp")))); if (!isdir(outpath)) { hoz_echo(411, outpath); return 411; } return 0; } /** * hoz_fileop - pops up an open/save file dialog * @cutpaste: 0=cut, 1=paste */ int hoz_fileop(const int cutpaste) { window_fd = create_fileselection_fd(); { char foo[60]; sprintf(foo, "%s - %s", HOZ_PROGRAM, ((cutpaste) ? (HOZ_BTNPASTECAPTION) : (HOZ_BTNCUTCAPTION))); gtk_window_set_title(GTK_WINDOW(window_fd), foo); } gtk_widget_show(window_fd); return 0; } int main(int argc, char *argv[]) { gtk_set_locale(); gtk_init(&argc, &argv); getcwd(outpath, MAXLEN); window_hoz = create_window_hoz(); window_bs = NULL; window_fd = NULL; window_ra = NULL; hozaction = 0; rprttextview = GTK_TEXT_VIEW(lookup_widget (GTK_WIDGET(window_hoz), "textview_rprt")); rprtbuf = gtk_text_view_get_buffer(rprttextview); /* gtk_text_buffer_create_tag (rprtbuf, "char_wrap", "wrap_mode", GTK_WRAP_CHAR, NULL); */ gtk_entry_set_text(GTK_ENTRY (lookup_widget (GTK_WIDGET(window_hoz), "entry_size")), "1457152"); gtk_entry_set_text(GTK_ENTRY (lookup_widget (GTK_WIDGET(window_hoz), "entry_outp")), outpath); gtk_label_set_label(GTK_LABEL (lookup_widget (GTK_WIDGET(window_hoz), "label_outp")), HOZ_OUTPCAPTION); gtk_label_set_label(GTK_LABEL (lookup_widget (GTK_WIDGET(window_hoz), "label_size")), HOZ_PSIZECAPTION); gtk_button_set_label(GTK_BUTTON (lookup_widget (GTK_WIDGET(window_hoz), "checkbutton_prgr")), HOZ_CBPRGRCAPTION); gtk_button_set_label(GTK_BUTTON (lookup_widget (GTK_WIDGET(window_hoz), "button_cut")), HOZ_BTNCUTCAPTION); gtk_button_set_label(GTK_BUTTON (lookup_widget (GTK_WIDGET(window_hoz), "button_paste")), HOZ_BTNPASTECAPTION); { char foo[60]; sprintf(foo, "%s - Hacha Open Zource", HOZ_PROGNAME); gtk_window_set_title(GTK_WINDOW(window_hoz), foo); } hoz_echo(301, NULL); hoz_ready(); fullsize = 0; gtk_widget_show(window_hoz); gtk_main(); return 0; } hoz-165/hozgtk.h 777 0 0 257 10004235736 6670 0 /**/ void hoz_print(const char *); void hoz_lf(); int hoz_replace_ask(const char *); void hoz_ready(); size_t hoz_getsize(); int hoz_getoutpdir(); int hoz_fileop(const int); hoz-165/hozgtk_c.c 777 0 0 5063 10014423126 7176 0#ifdef HAVE_CONFIG_H # include #endif #include #include "hoz.h" #include "hozgtk.h" #include "hozgtk_c.h" #include "hozgtk_i.h" #include "hozgtk_s.h" extern char outpath[MAXLEN]; extern size_t fullsize, partsize, headersize; extern int showprogress, forceow, simulate; extern GtkWidget *window_hoz; extern GtkWidget *window_bs; extern GtkWidget *window_ra; extern GtkWidget *window_fd; extern GtkTextView *rprttextview; extern GtkTextBuffer *rprtbuf; extern char hozfile[MAXLEN + 1]; extern int hozaction; void on_window_hoz_destroy(GtkObject * object, gpointer user_data) { gtk_main_quit(); } void on_entry_size_changed(GtkEditable * editable, gpointer user_data) { /* do nothing here */ hoz_getsize(); } void on_button_cut_clicked(GtkButton * button, gpointer user_data) { hozaction = 1; if (hoz_getsize() && !hoz_getoutpdir() && !hoz_fileop(0)) { } } void on_button_paste_clicked(GtkButton * button, gpointer user_data) { hozaction = 2; if (!hoz_getoutpdir() && !hoz_fileop(1)) { } } void on_ok_button_fd_clicked(GtkButton * button, gpointer user_data) { strcpy(hozfile, gtk_file_selection_get_filename(GTK_FILE_SELECTION(window_fd))); gtk_widget_destroy(window_fd); window_fd = NULL; showprogress = (int) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (lookup_widget (GTK_WIDGET(window_hoz), "checkbutton_prgr"))); if (hozaction == 1) { hoz_cut_main(hozfile); } else if (hozaction == 2) { hoz_paste_main(hozfile); } else { hoz_print(hozfile); hoz_lf(); } hozaction = 0; hoz_ready(); } void on_cancel_button_fd_clicked(GtkButton * button, gpointer user_data) { gtk_widget_destroy(window_fd); window_fd = NULL; } void on_button_yes_ra_clicked(GtkButton * button, gpointer user_data) { forceow = 1; gtk_widget_destroy(window_ra); window_ra = NULL; hoz_paste_main(hozfile); forceow = 0; hozaction = 0; hoz_ready(); } void on_button_no_ra_clicked(GtkButton * button, gpointer user_data) { forceow = 0; gtk_widget_destroy(window_ra); window_ra = NULL; } void on_okbutton_bs_clicked(GtkButton * button, gpointer user_data) { gtk_widget_destroy(window_bs); window_bs = NULL; } void on_combo_entry_size_changed (GtkEditable *editable, gpointer user_data) { /* do nothing here */ hoz_getsize(); } hoz-165/hozgtk_c.h 777 0 0 2116 10014423214 7175 0#include void on_window_hoz_destroy(GtkObject * object, gpointer user_data); void on_entry_size_changed(GtkEditable * editable, gpointer user_data); void on_button_cut_clicked(GtkButton * button, gpointer user_data); void on_button_paste_clicked(GtkButton * button, gpointer user_data); void on_dialog_replaceask_destroy(GtkObject * object, gpointer user_data); void on_cancelbutton_clicked(GtkButton * button, gpointer user_data); void on_okbutton_clicked(GtkButton * button, gpointer user_data); void on_entry_size_changed(GtkEditable * editable, gpointer user_data); void on_entry_size_changed(GtkEditable * editable, gpointer user_data); void on_ok_button_fd_clicked(GtkButton * button, gpointer user_data); void on_cancel_button_fd_clicked(GtkButton * button, gpointer user_data); void on_button_yes_ra_clicked(GtkButton * button, gpointer user_data); void on_button_no_ra_clicked(GtkButton * button, gpointer user_data); void on_okbutton_bs_clicked(GtkButton * button, gpointer user_data); void on_combo_entry_size_changed(GtkEditable * editable, gpointer user_data); hoz-165/hozgtk_i.c 777 0 0 27351 10014422712 7230 0/* * DO NOT EDIT THIS FILE - it is generated by Glade. */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include "hozgtk_c.h" #include "hozgtk_i.h" #include "hozgtk_s.h" #define GLADE_HOOKUP_OBJECT(component,widget,name) \ g_object_set_data_full (G_OBJECT (component), name, \ gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ g_object_set_data (G_OBJECT (component), name, widget) GtkWidget* create_window_hoz (void) { GtkWidget *window_hoz; GtkWidget *fixed_hoz; GtkWidget *entry_outp; GtkWidget *entry_size; GtkWidget *checkbutton_prgr; GtkWidget *scrolledwindow_rprt; GtkWidget *textview_rprt; GtkWidget *label_outp; GtkWidget *label_size; GtkWidget *button_paste; GtkWidget *button_cut; GtkWidget *combo_size; GList *combo_size_items = NULL; GtkWidget *combo_entry_size; window_hoz = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (window_hoz, 405, 470); gtk_window_set_title (GTK_WINDOW (window_hoz), "window_hoz"); gtk_window_set_position (GTK_WINDOW (window_hoz), GTK_WIN_POS_CENTER); gtk_window_set_resizable (GTK_WINDOW (window_hoz), FALSE); gtk_window_set_destroy_with_parent (GTK_WINDOW (window_hoz), TRUE); fixed_hoz = gtk_fixed_new (); gtk_widget_show (fixed_hoz); gtk_container_add (GTK_CONTAINER (window_hoz), fixed_hoz); entry_outp = gtk_entry_new (); gtk_widget_show (entry_outp); gtk_fixed_put (GTK_FIXED (fixed_hoz), entry_outp, 104, 40); gtk_widget_set_size_request (entry_outp, 192, 24); entry_size = gtk_entry_new (); gtk_widget_show (entry_size); gtk_fixed_put (GTK_FIXED (fixed_hoz), entry_size, 104, 8); gtk_widget_set_size_request (entry_size, 104, 24); checkbutton_prgr = gtk_check_button_new_with_mnemonic ("checkbutton__prgr"); gtk_widget_show (checkbutton_prgr); gtk_fixed_put (GTK_FIXED (fixed_hoz), checkbutton_prgr, 8, 68); gtk_widget_set_size_request (checkbutton_prgr, 184, 24); scrolledwindow_rprt = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow_rprt); gtk_fixed_put (GTK_FIXED (fixed_hoz), scrolledwindow_rprt, 16, 96); gtk_widget_set_size_request (scrolledwindow_rprt, 378, 360); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_rprt), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); textview_rprt = gtk_text_view_new (); gtk_widget_show (textview_rprt); gtk_container_add (GTK_CONTAINER (scrolledwindow_rprt), textview_rprt); gtk_widget_set_size_request (textview_rprt, 50, 50); gtk_text_view_set_editable (GTK_TEXT_VIEW (textview_rprt), FALSE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview_rprt), GTK_WRAP_WORD); label_outp = gtk_label_new ("label_outp"); gtk_widget_show (label_outp); gtk_fixed_put (GTK_FIXED (fixed_hoz), label_outp, 8, 36); gtk_widget_set_size_request (label_outp, 96, 20); gtk_label_set_justify (GTK_LABEL (label_outp), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label_outp), 0, 0.5); label_size = gtk_label_new ("label_size"); gtk_widget_show (label_size); gtk_fixed_put (GTK_FIXED (fixed_hoz), label_size, 8, 8); gtk_widget_set_size_request (label_size, 96, 16); gtk_label_set_justify (GTK_LABEL (label_size), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label_size), 0, 0.5); button_paste = gtk_button_new_with_mnemonic ("button__paste"); gtk_widget_show (button_paste); gtk_fixed_put (GTK_FIXED (fixed_hoz), button_paste, 304, 40); gtk_widget_set_size_request (button_paste, 88, 25); button_cut = gtk_button_new_with_mnemonic ("button__cut"); gtk_widget_show (button_cut); gtk_fixed_put (GTK_FIXED (fixed_hoz), button_cut, 304, 8); gtk_widget_set_size_request (button_cut, 90, 25); combo_size = gtk_combo_new (); g_object_set_data (G_OBJECT (GTK_COMBO (combo_size)->popwin), "GladeParentKey", combo_size); gtk_widget_show (combo_size); gtk_fixed_put (GTK_FIXED (fixed_hoz), combo_size, 215, 8); gtk_widget_set_size_request (combo_size, 80, 25); combo_size_items = g_list_append (combo_size_items, (gpointer) "bytes"); combo_size_items = g_list_append (combo_size_items, (gpointer) "KiB"); combo_size_items = g_list_append (combo_size_items, (gpointer) "MiB"); gtk_combo_set_popdown_strings (GTK_COMBO (combo_size), combo_size_items); g_list_free (combo_size_items); combo_entry_size = GTK_COMBO (combo_size)->entry; gtk_widget_show (combo_entry_size); gtk_widget_set_size_request (combo_entry_size, 50, -2); gtk_editable_set_editable (GTK_EDITABLE (combo_entry_size), FALSE); gtk_entry_set_text (GTK_ENTRY (combo_entry_size), "bytes"); g_signal_connect ((gpointer) window_hoz, "destroy", G_CALLBACK (on_window_hoz_destroy), NULL); g_signal_connect ((gpointer) entry_size, "changed", G_CALLBACK (on_entry_size_changed), NULL); g_signal_connect ((gpointer) button_paste, "clicked", G_CALLBACK (on_button_paste_clicked), NULL); g_signal_connect ((gpointer) button_cut, "clicked", G_CALLBACK (on_button_cut_clicked), NULL); g_signal_connect ((gpointer) combo_entry_size, "changed", G_CALLBACK (on_combo_entry_size_changed), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (window_hoz, window_hoz, "window_hoz"); GLADE_HOOKUP_OBJECT (window_hoz, fixed_hoz, "fixed_hoz"); GLADE_HOOKUP_OBJECT (window_hoz, entry_outp, "entry_outp"); GLADE_HOOKUP_OBJECT (window_hoz, entry_size, "entry_size"); GLADE_HOOKUP_OBJECT (window_hoz, checkbutton_prgr, "checkbutton_prgr"); GLADE_HOOKUP_OBJECT (window_hoz, scrolledwindow_rprt, "scrolledwindow_rprt"); GLADE_HOOKUP_OBJECT (window_hoz, textview_rprt, "textview_rprt"); GLADE_HOOKUP_OBJECT (window_hoz, label_outp, "label_outp"); GLADE_HOOKUP_OBJECT (window_hoz, label_size, "label_size"); GLADE_HOOKUP_OBJECT (window_hoz, button_paste, "button_paste"); GLADE_HOOKUP_OBJECT (window_hoz, button_cut, "button_cut"); GLADE_HOOKUP_OBJECT (window_hoz, combo_size, "combo_size"); GLADE_HOOKUP_OBJECT (window_hoz, combo_entry_size, "combo_entry_size"); return window_hoz; } GtkWidget* create_fileselection_fd (void) { GtkWidget *fileselection_fd; GtkWidget *ok_button_fd; GtkWidget *cancel_button_fd; fileselection_fd = gtk_file_selection_new ("HOZ"); gtk_container_set_border_width (GTK_CONTAINER (fileselection_fd), 10); gtk_window_set_position (GTK_WINDOW (fileselection_fd), GTK_WIN_POS_CENTER); gtk_window_set_modal (GTK_WINDOW (fileselection_fd), TRUE); gtk_window_set_destroy_with_parent (GTK_WINDOW (fileselection_fd), TRUE); ok_button_fd = GTK_FILE_SELECTION (fileselection_fd)->ok_button; gtk_widget_show (ok_button_fd); GTK_WIDGET_SET_FLAGS (ok_button_fd, GTK_CAN_DEFAULT); cancel_button_fd = GTK_FILE_SELECTION (fileselection_fd)->cancel_button; gtk_widget_show (cancel_button_fd); GTK_WIDGET_SET_FLAGS (cancel_button_fd, GTK_CAN_DEFAULT); g_signal_connect_swapped ((gpointer) ok_button_fd, "clicked", G_CALLBACK (on_ok_button_fd_clicked), GTK_OBJECT (fileselection_fd)); g_signal_connect ((gpointer) cancel_button_fd, "clicked", G_CALLBACK (on_cancel_button_fd_clicked), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (fileselection_fd, fileselection_fd, "fileselection_fd"); GLADE_HOOKUP_OBJECT_NO_REF (fileselection_fd, ok_button_fd, "ok_button_fd"); GLADE_HOOKUP_OBJECT_NO_REF (fileselection_fd, cancel_button_fd, "cancel_button_fd"); return fileselection_fd; } GtkWidget* create_dialog_ra (void) { GtkWidget *dialog_ra; GtkWidget *dialog_vbox_ra; GtkWidget *label_msg_ra; GtkWidget *dialog_action_area_ra; GtkWidget *button_yes_ra; GtkWidget *button_no_ra; dialog_ra = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog_ra), "dialog_ra"); gtk_window_set_position (GTK_WINDOW (dialog_ra), GTK_WIN_POS_CENTER); gtk_window_set_modal (GTK_WINDOW (dialog_ra), TRUE); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog_ra), TRUE); dialog_vbox_ra = GTK_DIALOG (dialog_ra)->vbox; gtk_widget_show (dialog_vbox_ra); label_msg_ra = gtk_label_new ("label__msg__ra"); gtk_widget_show (label_msg_ra); gtk_box_pack_start (GTK_BOX (dialog_vbox_ra), label_msg_ra, TRUE, TRUE, 5); gtk_label_set_line_wrap (GTK_LABEL (label_msg_ra), TRUE); dialog_action_area_ra = GTK_DIALOG (dialog_ra)->action_area; gtk_widget_show (dialog_action_area_ra); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area_ra), GTK_BUTTONBOX_SPREAD); button_yes_ra = gtk_button_new_with_mnemonic ("button__yes__ra"); gtk_widget_show (button_yes_ra); gtk_dialog_add_action_widget (GTK_DIALOG (dialog_ra), button_yes_ra, 0); GTK_WIDGET_SET_FLAGS (button_yes_ra, GTK_CAN_DEFAULT); button_no_ra = gtk_button_new_with_mnemonic ("button__no__ra"); gtk_widget_show (button_no_ra); gtk_dialog_add_action_widget (GTK_DIALOG (dialog_ra), button_no_ra, 0); GTK_WIDGET_SET_FLAGS (button_no_ra, GTK_CAN_DEFAULT); g_signal_connect ((gpointer) button_yes_ra, "clicked", G_CALLBACK (on_button_yes_ra_clicked), NULL); g_signal_connect ((gpointer) button_no_ra, "clicked", G_CALLBACK (on_button_no_ra_clicked), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (dialog_ra, dialog_ra, "dialog_ra"); GLADE_HOOKUP_OBJECT_NO_REF (dialog_ra, dialog_vbox_ra, "dialog_vbox_ra"); GLADE_HOOKUP_OBJECT (dialog_ra, label_msg_ra, "label_msg_ra"); GLADE_HOOKUP_OBJECT_NO_REF (dialog_ra, dialog_action_area_ra, "dialog_action_area_ra"); GLADE_HOOKUP_OBJECT (dialog_ra, button_yes_ra, "button_yes_ra"); GLADE_HOOKUP_OBJECT (dialog_ra, button_no_ra, "button_no_ra"); return dialog_ra; } GtkWidget* create_dialog_bs (void) { GtkWidget *dialog_bs; GtkWidget *dialog_vbox_bs; GtkWidget *label_msg_bs; GtkWidget *dialog_action_area_bs; GtkWidget *okbutton_bs; dialog_bs = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog_bs), "dialog__bs"); gtk_window_set_position (GTK_WINDOW (dialog_bs), GTK_WIN_POS_CENTER); gtk_window_set_modal (GTK_WINDOW (dialog_bs), TRUE); dialog_vbox_bs = GTK_DIALOG (dialog_bs)->vbox; gtk_widget_show (dialog_vbox_bs); label_msg_bs = gtk_label_new ("label__msg__bs"); gtk_widget_show (label_msg_bs); gtk_box_pack_start (GTK_BOX (dialog_vbox_bs), label_msg_bs, TRUE, TRUE, 5); gtk_label_set_justify (GTK_LABEL (label_msg_bs), GTK_JUSTIFY_LEFT); dialog_action_area_bs = GTK_DIALOG (dialog_bs)->action_area; gtk_widget_show (dialog_action_area_bs); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area_bs), GTK_BUTTONBOX_SPREAD); okbutton_bs = gtk_button_new_from_stock ("gtk-ok"); gtk_widget_show (okbutton_bs); gtk_dialog_add_action_widget (GTK_DIALOG (dialog_bs), okbutton_bs, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS (okbutton_bs, GTK_CAN_DEFAULT); g_signal_connect ((gpointer) okbutton_bs, "clicked", G_CALLBACK (on_okbutton_bs_clicked), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (dialog_bs, dialog_bs, "dialog_bs"); GLADE_HOOKUP_OBJECT_NO_REF (dialog_bs, dialog_vbox_bs, "dialog_vbox_bs"); GLADE_HOOKUP_OBJECT (dialog_bs, label_msg_bs, "label_msg_bs"); GLADE_HOOKUP_OBJECT_NO_REF (dialog_bs, dialog_action_area_bs, "dialog_action_area_bs"); GLADE_HOOKUP_OBJECT (dialog_bs, okbutton_bs, "okbutton_bs"); return dialog_bs; } hoz-165/hozgtk_i.h 777 0 0 321 10004235736 7170 0/* * DO NOT EDIT THIS FILE - it is generated by Glade. */ GtkWidget *create_window_hoz(void); GtkWidget *create_fileselection_fd(void); GtkWidget *create_dialog_ra(void); GtkWidget *create_dialog_bs(void); hoz-165/hozgtk_s.c 777 0 0 6744 10004235736 7234 0/* * DO NOT EDIT THIS FILE - it is generated by Glade. */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include "hozgtk_s.h" GtkWidget *lookup_widget(GtkWidget * widget, const gchar * widget_name) { GtkWidget *parent, *found_widget; for (;;) { if (GTK_IS_MENU(widget)) parent = gtk_menu_get_attach_widget(GTK_MENU(widget)); else parent = widget->parent; if (!parent) parent = (GtkWidget *) g_object_get_data(G_OBJECT(widget), "GladeParentKey"); if (parent == NULL) break; widget = parent; } found_widget = (GtkWidget *) g_object_get_data(G_OBJECT(widget), widget_name); if (!found_widget) g_warning("Widget not found: %s", widget_name); return found_widget; } static GList *pixmaps_directories = NULL; /* Use this function to set the directory containing installed pixmaps. */ void add_pixmap_directory(const gchar * directory) { pixmaps_directories = g_list_prepend(pixmaps_directories, g_strdup(directory)); } /* This is an internally used function to find pixmap files. */ static gchar *find_pixmap_file(const gchar * filename) { GList *elem; /* We step through each of the pixmaps directory to find it. */ elem = pixmaps_directories; while (elem) { gchar *pathname = g_strdup_printf("%s%s%s", (gchar *) elem->data, G_DIR_SEPARATOR_S, filename); if (g_file_test(pathname, G_FILE_TEST_EXISTS)) return pathname; g_free(pathname); elem = elem->next; } return NULL; } /* This is an internally used function to create pixmaps. */ GtkWidget *create_pixmap(GtkWidget * widget, const gchar * filename) { gchar *pathname = NULL; GtkWidget *pixmap; if (!filename || !filename[0]) return gtk_image_new(); pathname = find_pixmap_file(filename); if (!pathname) { g_warning("Couldn't find pixmap file: %s", filename); return gtk_image_new(); } pixmap = gtk_image_new_from_file(pathname); g_free(pathname); return pixmap; } /* This is an internally used function to create pixmaps. */ GdkPixbuf *create_pixbuf(const gchar * filename) { gchar *pathname = NULL; GdkPixbuf *pixbuf; GError *error = NULL; if (!filename || !filename[0]) return NULL; pathname = find_pixmap_file(filename); if (!pathname) { g_warning("Couldn't find pixmap file: %s", filename); return NULL; } pixbuf = gdk_pixbuf_new_from_file(pathname, &error); if (!pixbuf) { fprintf(stderr, "Failed to load pixbuf file: %s: %s\n", pathname, error->message); g_error_free(error); } g_free(pathname); return pixbuf; } /* This is used to set ATK action descriptions. */ void glade_set_atk_action_description(AtkAction * action, const gchar * action_name, const gchar * description) { gint n_actions, i; n_actions = atk_action_get_n_actions(action); for (i = 0; i < n_actions; i++) { if (!strcmp(atk_action_get_name(action, i), action_name)) atk_action_set_description(action, i, description); } } hoz-165/hozgtk_s.h 777 0 0 2160 10004235736 7225 0/* * DO NOT EDIT THIS FILE - it is generated by Glade. */ #ifdef HAVE_CONFIG_H # include #endif #include /* * Public Functions. */ /* * This function returns a widget in a component created by Glade. * Call it with the toplevel widget in the component (i.e. a window/dialog), * or alternatively any widget in the component, and the name of the widget * you want returned. */ GtkWidget *lookup_widget(GtkWidget * widget, const gchar * widget_name); /* Use this function to set the directory containing installed pixmaps. */ void add_pixmap_directory(const gchar * directory); /* * Private Functions. */ /* This is used to create the pixmaps used in the interface. */ GtkWidget *create_pixmap(GtkWidget * widget, const gchar * filename); /* This is used to create the pixbufs used in the interface. */ GdkPixbuf *create_pixbuf(const gchar * filename); /* This is used to set ATK action descriptions. */ void glade_set_atk_action_description(AtkAction * action, const gchar * action_name, const gchar * description); hoz-165/hozwin.c 777 0 0 32554 10014676216 6743 0#include #include "hoz.h" #include "hozwin.h" HFONT g_font; HWND maindlg; HINSTANCE hinst; char nchar, hozfile[MAX_PATH + 1]; extern char outpath[MAXLEN]; extern size_t fullsize, partsize, headersize; extern int showprogress, forceow, simulate; void hoz_print(const char *str) { SendDlgItemMessage(maindlg, ID_EDIT_RPRT, EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) str); } void hoz_lf() { SendDlgItemMessage(maindlg, ID_EDIT_RPRT, EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) "\r\n"); } /** * WinMain */ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { hinst = hInstance; return (int) hoz_dlgopen(); } /** * hoz_replace_ask - ask the user if an output file should be replaced * @s: filename */ int hoz_replace_ask(const char *s) { char foo[1024]; int bar; sprintf(foo, HOZ_REPLACE_W, s); bar = MessageBox(maindlg, foo, HOZ_PROGNAME, MB_YESNO | MB_ICONQUESTION | MB_SYSTEMMODAL); return (bar == IDYES); } /** * hoz_getsize - Gets the size in bytes from the size editbox */ size_t hoz_getsize() { char foo[100], baz[61]; size_t bar, mult = 1; GetDlgItemText(maindlg, ID_EDIT_SIZE, foo, 60); switch (SendDlgItemMessage(maindlg, ID_COMBO_SIZE, CB_GETCURSEL, (WPARAM)0, (LPARAM)0)) { case 0: mult = 1; break; case 1: mult = 1024; break; case 2: mult = 1024*1024; } sprintf(baz, HOZ_BADSIZE, foo); bar = (size_t) atolmp((char*)foo, mult); partsize = (bar) ? bar : 0; if (!partsize) { MessageBox(NULL, baz, HOZ_PROGNAME, MB_ICONERROR | MB_SYSTEMMODAL); } sprintf(foo, "partsize=%u", partsize); return partsize; } /** * hoz_getoutpdir - Gets the output path from the editbox */ int hoz_getoutpdir() { GetDlgItemText(maindlg, ID_EDIT_OUTP, outpath, MAXLEN); if (!isdir(outpath)) { hoz_echo(411, outpath); return 411; } return 0; } /** * hoz_initofn - initializes an OPENFILENAME structure to open a load/save file * dialog * @ofn: pointer to OPENFILENAME * @outfile: buffer to store the filename */ void hoz_initofn(OPENFILENAME * ofn, char *outfile) { ZeroMemory(ofn, sizeof(OPENFILENAME)); ofn->lStructSize = sizeof(OPENFILENAME); ofn->hwndOwner = maindlg; /* modal dialog */ ofn->hInstance = NULL; ofn->lpstrFilter = NULL; ofn->lpstrCustomFilter = NULL; ofn->nMaxCustFilter = 0; ofn->nFilterIndex = 1; ofn->lpstrFile = outfile; ofn->nMaxFile = MAX_PATH; ofn->lpstrFileTitle = NULL; ofn->nMaxFileTitle = 0; ofn->lpstrInitialDir = NULL; ofn->lpstrTitle = NULL; ofn->lpstrDefExt = NULL; ofn->Flags = OFN_PATHMUSTEXIST | OFN_NOREADONLYRETURN | OFN_NODEREFERENCELINKS | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; /* MSDN: * "The first character of this buffer must be NULL if initialization is * not necessary." */ lstrcpy(outfile, ""); } /** * hoz_fileop - pops up an open/save file dialog * @cutpaste: 0=cut, 1=paste */ int hoz_fileop(const int cutpaste) { OPENFILENAME ofn; char file[MAX_PATH + 1], foo[1024]; hoz_initofn(&ofn, file); if (cutpaste) { /* paste */ sprintf(foo, "%s (*.0)$*.0", HOZ_FDPASTE); foo[strlen(foo) + 1] = 0; foo[strlen(HOZ_FDPASTE) + 6] = 0; ofn.lpstrFilter = foo; ofn.lpstrTitle = HOZ_PROGNAME; ofn.lpstrDefExt = "0"; } else { /* cut */ sprintf(foo, "%s (*)$*", HOZ_FDCUT); foo[strlen(foo) + 1] = 0; foo[strlen(HOZ_FDCUT) + 4] = 0; ofn.lpstrFilter = foo; ofn.lpstrTitle = HOZ_PROGNAME; ofn.lpstrDefExt = "*"; } if (GetOpenFileName(&ofn) == TRUE) { lstrcpy(hozfile, file); return 0; } return 1; } /** * hoz_loadfonts - creates a logic font in g_font (global var) * @font: font's name * @fsize: font's height * * the logic font must be removed with DeleteObject() when the program closes */ void hoz_loadfonts(const char *font, const int fsize) { LOGFONT lfont; lfont.lfHeight = fsize; lfont.lfWidth = 0; lfont.lfEscapement = 0; lfont.lfOrientation = 0; lfont.lfWeight = 200; lfont.lfItalic = 0; lfont.lfUnderline = 0; lfont.lfStrikeOut = 0; lfont.lfCharSet = ANSI_CHARSET; lfont.lfOutPrecision = OUT_DEFAULT_PRECIS; lfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; lfont.lfQuality = DEFAULT_QUALITY; lfont.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS; lstrcpy(lfont.lfFaceName, font); g_font = CreateFontIndirect(&lfont); } /** * hoz_ready - useless... */ void hoz_ready() { hoz_lf(); hoz_print(HOZ_READY); hoz_lf(); } /** * dialog_main - dialog's message handler */ LRESULT CALLBACK dialog_main(HWND hdlg, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) { case WM_INITDIALOG: maindlg = hdlg; getcwd(outpath, MAXLEN); hoz_loadfonts("Tahoma", 13); SendDlgItemMessage(maindlg, ID_EDIT_SIZE, WM_SETFONT, (WPARAM) g_font, (DWORD) TRUE); SendDlgItemMessage(maindlg, ID_BUTTON_CUT, WM_SETFONT, (WPARAM) g_font, (DWORD) TRUE); SendDlgItemMessage(maindlg, ID_BUTTON_PASTE, WM_SETFONT, (WPARAM) g_font, (DWORD) TRUE); SendDlgItemMessage(maindlg, ID_STATIC_SIZE, WM_SETFONT, (WPARAM) g_font, (DWORD) TRUE); SendDlgItemMessage(maindlg, ID_STATIC_OUTP, WM_SETFONT, (WPARAM) g_font, (DWORD) TRUE); SendDlgItemMessage(maindlg, ID_EDIT_OUTP, WM_SETFONT, (WPARAM) g_font, (DWORD) TRUE); SendDlgItemMessage(maindlg, ID_EDIT_RPRT, WM_SETFONT, (WPARAM) g_font, (DWORD) TRUE); SendDlgItemMessage(maindlg, ID_CHECK_PRGR, WM_SETFONT, (WPARAM) g_font, (DWORD) TRUE); SendDlgItemMessage(maindlg, ID_COMBO_SIZE, WM_SETFONT, (WPARAM) g_font, (DWORD) TRUE); SetDlgItemText(maindlg, ID_EDIT_SIZE, "1457152"); SetDlgItemText(maindlg, ID_EDIT_OUTP, outpath); SetDlgItemText(maindlg, ID_STATIC_SIZE, HOZ_PSIZECAPTION); SetDlgItemText(maindlg, ID_STATIC_OUTP, HOZ_OUTPCAPTION); SetDlgItemText(maindlg, ID_CHECK_PRGR, HOZ_CBPRGRCAPTION); SetDlgItemText(maindlg, ID_BUTTON_CUT, HOZ_BTNCUTCAPTION); SetDlgItemText(maindlg, ID_BUTTON_PASTE, HOZ_BTNPASTECAPTION); SendDlgItemMessage(maindlg, ID_COMBO_SIZE, CB_ADDSTRING, 0, (LPARAM)"bytes"); SendDlgItemMessage(maindlg, ID_COMBO_SIZE, CB_ADDSTRING, 0, (LPARAM)"KiB"); SendDlgItemMessage(maindlg, ID_COMBO_SIZE, CB_ADDSTRING, 0, (LPARAM)"MiB"); SendDlgItemMessage(maindlg, ID_COMBO_SIZE, CB_SETCURSEL, (WPARAM)0, (LPARAM)0); { char foo[60]; sprintf(foo, "%s - Hacha Open Zource", HOZ_PROGNAME); SendMessage(maindlg, WM_SETTEXT, (WPARAM) 0, (LPARAM) foo); } hoz_echo(301, NULL); hoz_ready(); fullsize = 0; return TRUE; case WM_COMMAND: switch (LOWORD(wparam)) { case ID_BUTTON_CUT: SendDlgItemMessage(maindlg, ID_EDIT_RPRT, EM_SETSEL, (WPARAM) 99998, (DWORD) 99999); SendDlgItemMessage(maindlg, ID_EDIT_RPRT, EM_SCROLLCARET, (WPARAM) 0, (DWORD) 0); if (hoz_getsize() && !hoz_getoutpdir() && !hoz_fileop(0)) { hoz_cut_main(hozfile); hoz_ready(); } break; case ID_BUTTON_PASTE: SendDlgItemMessage(maindlg, ID_EDIT_RPRT, EM_SETSEL, (WPARAM) 99998, (DWORD) 99999); SendDlgItemMessage(maindlg, ID_EDIT_RPRT, EM_SCROLLCARET, (WPARAM) 0, (DWORD) 0); if (!hoz_fileop(1) && !hoz_getoutpdir()) { hoz_paste_main(hozfile); hoz_ready(); } break; case ID_CHECK_PRGR: showprogress = !SendDlgItemMessage(maindlg, ID_CHECK_PRGR, BM_GETCHECK, (WPARAM) 0, (DWORD) 0); CheckDlgButton(maindlg, ID_CHECK_PRGR, showprogress); break; case ID_EDIT_RPRT: if (HIWORD(wparam) == EN_ERRSPACE) { MessageBox(NULL, "ID_EDIT_RPRT", "EN_ERRSPACE", 0); } break; case IDCANCEL: EndDialog(maindlg, LOWORD(wparam)); return TRUE; } } return FALSE; } /* Helper routine. Take an input pointer, return closest pointer that is aligned on a DWORD (4 byte) boundary. */ LPWORD lpwAlign(LPWORD lpIn) { ULONG ul; ul = (ULONG) lpIn; ul += 3; ul >>= 2; ul <<= 2; return (LPWORD) ul; } /** * hoz_dlgopen - opens the dialog */ LRESULT hoz_dlgopen() { HGLOBAL hgbl; LPDLGTEMPLATE lpdt; LPDLGITEMTEMPLATE lpdit; LPWORD lpw; LRESULT ret; hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024); if (!hgbl) return -1; lpdt = (LPDLGTEMPLATE) GlobalLock(hgbl); lpdt->style = WS_POPUP | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION | DS_CENTER; lpdt->cdit = 9; /* number of controls */ lpdt->x = -1; lpdt->y = -1; lpdt->cx = 170; lpdt->cy = 186; lpw = (LPWORD) (lpdt + 1); *lpw++ = 0; /* no menu */ *lpw++ = 0; /* predefined dialog box class (by default) */ *lpw++ = 0; /* * ID_STATIC_SIZE */ lpw = lpwAlign(lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 3; lpdit->y = 6; lpdit->cx = 40; lpdit->cy = 8; lpdit->id = ID_STATIC_SIZE; lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0082; /* static */ *lpw++ = 0; *lpw++ = 0; /* * ID_EDIT_SIZE */ lpw = lpwAlign(lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 42; lpdit->y = 4; lpdit->cx = 55; lpdit->cy = 11; lpdit->id = ID_EDIT_SIZE; lpdit->style = WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL/* | ES_NUMBER*/; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0081; /* editbox */ *lpw++ = 0; *lpw++ = 0; /* * ID_COMBO_SIZE */ lpw = lpwAlign(lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 97; lpdit->y = 4; lpdit->cx = 30; lpdit->cy = 95; lpdit->id = ID_COMBO_SIZE; lpdit->style = WS_CHILD | WS_VISIBLE | WS_BORDER | CBS_DROPDOWNLIST; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0085; /* combobox */ *lpw++ = 0; *lpw++ = 0; /* * ID_CHECK_PRGR */ lpw = lpwAlign(lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 3; lpdit->y = 27; lpdit->cx = 100; lpdit->cy = 12; lpdit->id = ID_CHECK_PRGR; lpdit->style = WS_CHILD | WS_VISIBLE | BS_CHECKBOX; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0080; /* button */ *lpw++ = 0; *lpw++ = 0; /* * ID_BUTTON_CUT */ lpw = lpwAlign(lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 132; lpdit->y = 3; lpdit->cx = 34; lpdit->cy = 12; lpdit->id = ID_BUTTON_CUT; lpdit->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0080; /* button */ *lpw++ = 0; *lpw++ = 0; /* * ID_BUTTON_PASTE */ lpw = lpwAlign(lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 132; lpdit->y = 18; lpdit->cx = 34; lpdit->cy = 12; lpdit->id = ID_BUTTON_PASTE; lpdit->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0080; *lpw++ = 0; *lpw++ = 0; /* * ID_EDIT_RPRT */ lpw = lpwAlign(lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 5; lpdit->y = 40; lpdit->cx = 161; lpdit->cy = 140; lpdit->id = ID_EDIT_RPRT; lpdit->style = WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOVSCROLL | ES_MULTILINE | ES_READONLY | WS_VSCROLL; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0081; /* editbox */ *lpw++ = 0; *lpw++ = 0; /* * ID_STATIC_OUTP */ lpw = lpwAlign(lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 3; lpdit->y = 17; lpdit->cx = 40; lpdit->cy = 8; lpdit->id = ID_STATIC_OUTP; lpdit->style = WS_CHILD | WS_VISIBLE | SS_LEFT; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0082; /* static */ *lpw++ = 0; *lpw++ = 0; /* * ID_EDIT_OUTP */ lpw = lpwAlign(lpw); lpdit = (LPDLGITEMTEMPLATE) lpw; lpdit->x = 42; lpdit->y = 17; lpdit->cx = 85; lpdit->cy = 10; lpdit->id = ID_EDIT_OUTP; lpdit->style = WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL; lpw = (LPWORD) (lpdit + 1); *lpw++ = 0xFFFF; *lpw++ = 0x0081; /* editbox */ *lpw++ = 0; *lpw++ = 0; GlobalUnlock(hgbl); ret = DialogBoxIndirect(hinst, (LPDLGTEMPLATE) hgbl, NULL, (DLGPROC) dialog_main); GlobalFree(hgbl); return ret; } hoz-165/hozwin.h 777 0 0 1207 10014670634 6715 0/* #define WINDOWS_LEAN_AND_MEAN */ #define ID_EDIT_SIZE 1001 #define ID_EDIT_RPRT 1002 #define ID_CHECK_PRGR 1003 #define ID_BUTTON_CUT 1004 #define ID_BUTTON_PASTE 1005 #define ID_STATIC_SIZE 1006 #define ID_STATIC_OUTP 1007 #define ID_EDIT_OUTP 1008 #define ID_COMBO_SIZE 1009 int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPTSTR, int); size_t hoz_getsize(); int hoz_getoutpdir(); void hoz_initofn(OPENFILENAME *, char *); int hoz_fileop(const int); void hoz_loadfonts(const char *, const int); void hoz_ready(); LRESULT CALLBACK dialog_main(HWND, UINT, WPARAM, LPARAM); LPWORD lpwAlign(LPWORD); LRESULT hoz_dlgopen(); hoz-165/Makefile 777 0 0 2525 10000545012 6654 0 CC = gcc OBJ = hoz.o hozgtk.o hozgtk_c.o hozgtk_i.o hozgtk_s.o hozcli.o LINKOBJ = hoz.o hozcli.o GLINKOBJ = hoz.o hozgtk.o hozgtk_c.o hozgtk_i.o hozgtk_s.o CFLAGS = -Wall \ -O2 \ -DG_DISABLE_DEPRECATED \ -DGDK_DISABLE_DEPRECATED \ -DGDK_PIXBUF_DISABLE_DEPRECATED \ -DGTK_DISABLE_DEPRECATED BIN = /usr/bin/hoz GBIN = /usr/bin/ghoz GTK_COMP = `pkg-config gtk+-2.0 --cflags` GTK_LINK = `pkg-config gtk+-2.0 --libs` # `pkg-config gtk+-2.0 --cflags --libs` .PHONY: all all-before all-after clean clean-custom cli gtk all: all-before $(BIN) $(GBIN) all-after cli: all-before ${BIN} all-after gtk: all-before ${GBIN} all-after clean: clean-custom rm -f $(OBJ) clean2: clean-custom rm -f $(OBJ) ${BIN} ${GBIN} hoz.o: hoz.c $(CC) -c hoz.c -o hoz.o $(CFLAGS) ${LANG} hozgtk.o: hozgtk.c $(CC) -c hozgtk.c -o hozgtk.o $(CFLAGS) $(GTK_COMP) ${LANG} hozgtk_c.o: hozgtk_c.c $(CC) -c hozgtk_c.c -o hozgtk_c.o $(CFLAGS) $(GTK_COMP) ${LANG} hozgtk_i.o: hozgtk_i.c $(CC) -c hozgtk_i.c -o hozgtk_i.o $(CFLAGS) $(GTK_COMP) ${LANG} hozgtk_s.o: hozgtk_s.c $(CC) -c hozgtk_s.c -o hozgtk_s.o $(CFLAGS) $(GTK_COMP) ${LANG} hozcli.o: hozcli.c $(CC) -c hozcli.c -o hozcli.o $(CFLAGS) ${LANG} $(BIN): $(LINKOBJ) $(CC) $(LINKOBJ) -o $(BIN) $(LIBS) $(GBIN): $(GLINKOBJ) $(CC) $(GLINKOBJ) -o $(GBIN) $(LIBS) $(GTK_LINK) hoz-165/Makefile.win 777 0 0 5155 10014676510 7467 0# Project: hoz # Makefile created by Dev-C++ 4.9.8.3 # Modified by Gustavo Picon CC = gcc.exe WINDRES = windres.exe RES = hoz_private.res OBJ = hoz-en.o hoz-es.o hoz-fr.o hozwin-en.o hozwin-es.o hozwin-fr.o \ hozcli-en.o hozcli-es.o hozcli-fr.o getopt.o getopt1.o $(RES) LINKOBJ-EN = hoz-en.o hozcli-en.o getopt.o getopt1.o LINKOBJ-ES = hoz-es.o hozcli-es.o getopt.o getopt1.o LINKOBJ-FR = hoz-fr.o hozcli-fr.o getopt.o getopt1.o WLINKOBJ-EN = hoz-en.o hozwin-en.o $(RES) WLINKOBJ-ES = hoz-es.o hozwin-es.o $(RES) WLINKOBJ-FR = hoz-fr.o hozwin-fr.o $(RES) LIBS = -L"C:/Program Files/Dev-Cpp/lib" -s -O WLIBS = -L"C:/Program Files/Dev-Cpp/lib" -mwindows -s -O INCS = -I"C:/Program Files/Dev-Cpp/include" BIN-EN = hoz-en.exe BIN-ES = hoz-es.exe BIN-FR = hoz-fr.exe WBIN-EN = whoz-en.exe WBIN-ES = whoz-es.exe WBIN-FR = whoz-fr.exe CFLAGS = $(INCS)-DBUILDING_DLL=1 -Os -Wall -fomit-frame-pointer -s\ -fexpensive-optimizations -O3 .PHONY: all all-before all-after clean clean-custom all: all-before $(BIN-EN) $(BIN-ES) $(BIN-FR) $(WBIN-EN) $(WBIN-ES) $(WBIN-FR) \ all-after clean: clean-custom rm -f $(OBJ) $(BIN-EN) $(BIN-ES) $(BIN-FR) $(WBIN-EN) $(WBIN-ES) \ $(WBIN-FR) clean2: clean-custom rm -f $(OBJ) hoz-en.o: hoz.c $(CC) -c hoz.c -o hoz-en.o $(CFLAGS) -DHOZ_LANG_EN hoz-es.o: hoz.c $(CC) -c hoz.c -o hoz-es.o $(CFLAGS) -DHOZ_LANG_ES hoz-fr.o: hoz.c $(CC) -c hoz.c -o hoz-fr.o $(CFLAGS) -DHOZ_LANG_FR hozwin-en.o: hozwin.c $(CC) -c hozwin.c -o hozwin-en.o $(CFLAGS) -DHOZ_LANG_EN hozwin-es.o: hozwin.c $(CC) -c hozwin.c -o hozwin-es.o $(CFLAGS) -DHOZ_LANG_ES hozwin-fr.o: hozwin.c $(CC) -c hozwin.c -o hozwin-fr.o $(CFLAGS) -DHOZ_LANG_FR hozcli-en.o: hozcli.c $(CC) -c hozcli.c -o hozcli-en.o $(CFLAGS) -DHOZ_LANG_EN hozcli-es.o: hozcli.c $(CC) -c hozcli.c -o hozcli-es.o $(CFLAGS) -DHOZ_LANG_ES hozcli-fr.o: hozcli.c $(CC) -c hozcli.c -o hozcli-fr.o $(CFLAGS) -DHOZ_LANG_FR getopt.o: getopt.c $(CC) -c getopt.c -o getopt.o $(CFLAGS) getopt1.o: getopt1.c $(CC) -c getopt1.c -o getopt1.o $(CFLAGS) hoz_private.res: hoz_private.rc $(WINDRES) -i hoz_private.rc -I rc -o hoz_private.res -O coff $(BIN-EN): $(LINKOBJ-EN) $(CC) $(LINKOBJ-EN) -o $(BIN-EN) $(LIBS) $(BIN-ES): $(LINKOBJ-ES) $(CC) $(LINKOBJ-ES) -o $(BIN-ES) $(LIBS) $(BIN-FR): $(LINKOBJ-FR) $(CC) $(LINKOBJ-FR) -o $(BIN-FR) $(LIBS) $(WBIN-EN): $(WLINKOBJ-EN) $(CC) $(WLINKOBJ-EN) -o $(WBIN-EN) $(WLIBS) $(WBIN-ES): $(WLINKOBJ-ES) $(CC) $(WLINKOBJ-ES) -o $(WBIN-ES) $(WLIBS) $(WBIN-FR): $(WLINKOBJ-FR) $(CC) $(WLINKOBJ-FR) -o $(WBIN-FR) $(WLIBS) hoz-165/makehoz 777 0 0 1076 10000545012 6575 0#!/bin/sh if test $# -eq 0; then echo "parms: [en|es|fr]" exit 1 fi cli="0" gtk="0" lang="-DHOZ_LANG_EN" while test $# -gt 0; do case $1 in cli) cli="1";; gtk) gtk="1";; both) cli="1" gtk="1" ;; en) lang="-DHOZ_LANG_EN";; es) lang="-DHOZ_LANG_ES";; fr) lang="-DHOZ_LANG_FR";; *) echo "Unknown parameter: " $1 exit 2 esac shift done if test ${cli} -eq 1; then make LANG=${lang} cli fi if test ${gtk} -eq 1; then make LANG=${lang} gtk fi # vim ft=sh hoz-165/README 777 0 0 11752 10014677750 6142 0HOZ - Hacha Open Zource v1.65 http://hoz.sourceforge.net/ Copyright (C) 2004 Gustavo Picon http://slashcore.com/tabo/ License: GNU/GPL # # About # HOZ is what you would call a 'file splitter'. Its file format is the same as the one used by the 'Hacha' software, a well known splitter in Spain and Latinamerica. HOZ is an open-source and portable C implementation of an 'Hacha' compatible splitter. HOZ is smaller and faster than 'Hacha'. btw, I used a 'Z' isntead of a 'S' in 'Zource' because 'hoz' is 'sickle' in spanish, and since 'hacha' is the spanish word for 'axe'... # # Install: # - Windows: Download the hoz-XX.zip file and use some of the binaries included there: hoz-en.exe CLI, english hoz-es.exe CLI, spanish hoz-fr.exe CLI, french whoz-en.exe Windows UI, english whoz-es.exe Windows UI, spanish whoz-fr.exe Windows UI, french These binaries have been compiled with the MINGW compiler included in DEV-C++, and then compressed with UPX. you can find the original binaries in noupx.zip, also included in hoz-XX.zip - Other platforms: There are two available user interfaces: CLI: All you need is make and a standard C compiler. To build type './makehoz cli' The binary generated will be named 'hoz' GTK2: You'll need make, a C compiler and GTK2 installed on your system. To build type './makehoz gtk' The binary generated will be named 'ghoz' In case you want to build the CLI and GTK2 versions at the same time, you can use './makehoz both' By default, an english version will be built. If you want a different language, you can pass another parameter to './makehoz'. Currently there are three langs supported: 'en' (english), 'es' (spanish) and 'fr' (french). So for example, if you want to make a spanish GTK2 build of HOZ, you'll have to type './makehoz gtk es' The binaries will be generated in /usr/bin, so you must have the right permissions to use './makehoz' (when in doubt, su to root). # # Use # There are two basic operations: cut and paste. Cut will 'split' a file in pieces. The size of each piece is passed as an option. Each piece will have a numeric extension, starting with 0. So for instance if you 'cut' a file called 'foo.iso', the pieces will be named 'foo.iso.0', 'foo.iso.1' and so on. Paste will 'merge' these pieces and generate and exact copy of the original file. CLI versions: type 'hoz --help' Graphical versions: Click, click, click... # # Comments # - Staring in version 2.79, 'Hacha' has an option of adding a 'CRC' code to the file pieces. This 'CRC' code _is_not_a_standard_algorithm_ and has been invented by the author of 'Hacha'. HOZ _does_not_ include an option to generate this 'CRC', or to check it when a file is 'Pasted'. Note that you can still paste files that has this 'CRC' code without problems. - The win32 binaries have been compressed with UPX. If your antivirus find an infected file (a false alarm), you can find the original binaries in noupx.zip. And please get a better antivirus software. # # Changelog: # * 1.65 (2004-Feb-18) - Added support for size suffixes in the cli mode ('K'=KiB and 'M'=MiB) - Added a size combobox in the GTK and Win32 versions, so you can select "bytes", "KiB" (1024 bytes) and "MiB" (1024*1024 bytes) - Fixed a bug in the gtk version, was showing an invalid size message when the size editbox was empty. * 1.63 (2004-Feb-11) - Added getopt_long support (--* options). Hopefully this will make Rudy happy. * 1.61 (2004-Jan-21) - Fixed a bug that could generate corrupt pieces on _very_rare_ ocassions. * 1.6 (2004-Jan-14) - Fixed a bug when pasting (forgot to remove a debug code) * 1.5 (2004-Jan-12) - Added a graphical user interface for *NIX systems, in GTK2. - Shell script for *NIX builds: './makehoz' - File operations will stop when there is no more bytes free in the filesystem. - Very minor bugfixes/improvements * 1.2: - Added an option to specify an output dir when cutting/pasting - Added an option to 'force' a file overwrite when pasting. - Corrected a bug when calculating the control byte when cutting (internal) - Now using getopt for the CLI version. - Minor bugfixes. * 1.1: First public version # # Thanks: # - Miguel Angel Orellana, for his support. - Ricardo Supo, Win32 icon. - Víctor Figueroa, french translation. - Ernesto Quiñones, reported the nasty 1.5 paste bug - Rudy Godoy, .deb packager and chichero extraordinaire - #linuxperu@freenode, la chicha - Rita, por existir # # See also: # - Hacha: The original program. Written in (ugh) Visual Basic for the win32 platform. Hacha is freeware, but not open source. http://www.hachaweb.com/ # # License # This software has been published under the GNU/GPL license. Read 'copying.txt' for more info. # # Disclaimer # The usual: published as-is, no warranty, no support. There is not a single line of SCO source code in this software. # # Contact # - Gustavo Picon hoz-165/winmake.bat 777 0 0 230 10014670742 7324 0@SET Path=%Path%;C:\Dev-Cpp\bin;C:\Program Files\Dev-Cpp\bin @make -f Makefile.win clean @make -f Makefile.win @make -f Makefile.win clean2 @PAUSE