COPYING100644 0 0 43113 6605070121 10207 0ustar rootroot 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 Appendix: 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. README100644 0 0 10224 6713043512 10035 0ustar rootroot 2 May 1999 README (page 1 of 2) fb is known to run under the following operating systems: IRIX, Linux, SunOS, and Windows 95, 98, & NT For UNIX (Linux) users only: fb can read directories if they are readable under the file system. And fb can read devices such as drives, CD-ROMs, etc.; because, as you know, under UNIX (Linux) a device is just another file. The only code for fb is fb.c. For IRIX, Linux, and SunOS the code is ready to compile. After the NO WARRANTY statement at the top of the code are some commented-out preprocessor directives: o If you wish to compile for MS-DOS, uncomment-out the appropriate #define directive. o If you are using a Borland compiler for MS-DOS, uncomment-out the indicated #define for Borland. This will result in Borland's chsize(...) being used rather than ftruncate(...). This occurs in only two places in the code. o If your compiler does not support the long long data type, there is an additional #define directive you will need to uncomment-out. o If you will be using fb under Linux running on a PC, you may, if you wish, uncomment-out the appropriate #define directive for this case. This only affects what characters are considered non-printable and should allow you to see as many characters as possible. This occurs in only one place in the code. If you wish to modify which characters are treated as non-printable (and displayed as a period), simply modify the appropriate part of the code (it is clearly indicated). Under MSDOS files are open by default as text and not as binary files. Also standard input (stdin) is opened as text. To change this so that files are opened as binary, the DOS_BINARY flag must be set to the appropriate flag to pass in the call to open(...). This is currently set to O_BINARY. (Where this is set is clearly indicated.) This may not be the flag for your system. You might find the correct flag to use by looking in the header file fcntl.h in your system's include or include/sys directory. Also, to change the mode of stdin from text to binary a call to setmode(...) is made. But this function may either not be available for your system or might have a different name. You might be able to find the appropriate function by looking in the io.h header file. You should have, in addition to this README file, the following: COPYING <-- the GNU General Public License fb.doc <-- fb manual (plain ASCII version of man page) fb.1 <-- fb man page fb.c <-- fb source code The inspiration for the translate method in fb 1.4 was John Walker's xd utility (http://www.fourmilab.ch). 2 May 1999 README (page 2 of 2) Note for Linux/UNIX users: fb -snl File is similar to od -Ad -v -tx1 File fb o File1 File2 is similar to cmp -l File1 File2 Be aware, however, that, unlike fb and od, cmp starts counting bytes from 1 rather than 0. fb . File1 File2 is similar to cmp -s File1 File2 except that the exit status of fb is richer; distinguishing between bytes differing, sizes differing, or both. fb a . File1 File2 has the same effect as cat File1 >> File2 fb c Num1.Num2 File1 File2 is the same as dd if=File1 of=File2 bs=1 skip=Num1 count=Num3 where Num3 = Num2 - Num1 Report any bugs to John Howard Swaby polymath@uwyo.edu fb web page: http://home.mho.net/jswaby/fb.html 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. fb.1100644 0 0 24445 6713165751 7652 0ustar rootroot.TH FB 1 "2 May 1999" \" -*- nroff -*- .SH NAME fb \- binary file viewer, editor, and manipulator .SH SYNOPSIS .B fb [[-AaBbCcDdEeHhKkLlNnOoSsTt] [-i INC] [-r RNG] [-p PS] File] | [r RNG BYTE File] | [a|c RNG File1 [File2]] | [t[ ]b|d|h|o File1 [File2]] | [b|d|h|o|-|. File1 File2] | [- c|h|n|v] .SH DESCRIPTION .B fb provides interactive browsing of a file or the contents of a file can be streamed (without interaction) to standard output. The file can be viewed in binary, octal, decimal, hexadecimal, or characters. Optionally, .B fb will read standard input if option \-t is in effect and "\-" is given as the file name. Output consists of "pages" of one or more lines. Each line of a page consists of the offset from the beginning of the file in decimal (optional if non-interactive), followed first by one or more columns of an optional numeric display in either binary, octal, decimal, or hexadecimal; and this, in turn, followed by an optional character display; however, at least one of the two displays must be present. Unprintable characters will show as a period. By default, .B fb has a hexadecimal numeric display along with a character display. .LP .B fb also has a limited editing capability if invoked with the -e option and the file is writable. In edit mode, the user can specify which bytes in the file to overwrite. These bytes can be overwritten in either binary, octal, decimal, hexadecimal, or character formats. The format in effect is in agreement with the current display. .LP .B fb also has five helper methods: append, copy, translate, replace, and compare. The append method allows for copying a selection of the contents of one file to the end of another or the same file. If the second file does not exist, it is created. The copy method allows for copying a selection of the contents of one file to another or the same file. Be aware that the second file is overwritten; in particular, copying a file to itself will reduce the file to the size of the portion that was copied. .LP The translate method will convert either binary, octal, decimal, or hexadecimal numbers in one file into bytes and copy these bytes to another or the same file. Or the translate will convert numbers from standard input into bytes and copy these to a file. The numbers can optionally be delimited with any character that is not a digit for the given base and is not the character "|". The "|" character is used to indicate the start of a comment. The "|" character and all characters after it to the end of line will be ignored. At any place in the file where the numbers are not delimited, 8 digits (for binary), 3 digits (for octal and decimal), and 2 digits (for hexadecimal) will be converted at a time. .LP The replace method will replace all of the bytes in a specified portion of a file with a particular value. .LP The compare method will report the offsets where two files differ and the value of the bytes (in binary, decimal, hexadecimal, or octal) at these offsets till the end of the shortest file. If the lengths of the files are different, it will also report the end of file (EOF) for both files. The exit status of the compare method is one of five values: 0 - files the same, 1 - an error has occurred, 2 - bytes differ, 3 - sizes differ, and 4 - bytes and sizes differ. Optionally the compare method can report only if the files differ and how or it can run silent: returning only the exit status. .SS OPTIONS .TP Base options: .TP .I -b Binary numbers (8 columns). .TP .I -B Binary numbers (16 columns). .TP .I -d Decimal numbers (16 columns). .TP .I -D Decimal numbers (32 columns). .TP .I -h Hexadecimal numbers (16 columns). .TP .I -H Hexadecimal numbers (32 columns). .TP .I -o Octal numbers (16 columns). .TP .I -O Octal numbers (32 columns). .TP Display options: .TP .I -a Suppress offset addresses. (Ignored if effective mode is interactive.) .TP .I -A Display offset addresses. .TP .I -c Characters only (64 columns). .TP .I -C Characters only (128 columns). .TP .I -k Numeric display is compressed (no spaces between numbers). .TP .I -K Numeric display is not compressed (spaces between numbers). .TP .I -l Suppress column labels. .TP .I -L Display column labels. .TP .I -n Exclude supplemental character display. .TP .I -N Include supplemental character display. .TP Mode options: .TP .I -e Edit mode. (Ignored if effective mode is non-interactive.) .TP .I -E Read-only mode. .TP .I -s Stream output (non-interactive mode). .TP .I -S Interactive mode. (Will nullify previous -s or -t options.) .TP .I -t Read from standard input and stream output (non-interactive mode). (Will nullify previous -S or -T options.) Note: File name MUST be "-". .TP .I -T Read from File. .TP Options with arguments: .TP .I "-i INC" Increment page INC bytes. INC is a nonnegative integer. 0 sets increment to default, (number of rows)*(number of columns). .TP .I "-r RNG" Portion of File to browse. RNG is Start | [Start].[Stop]; where Start (default: 0) and Stop (default: end of file) are the starting and stopping offsets of File. .TP .I "-p PS" Page size. PS is Rw | [Rw].[Cl]. Rw is number of rows, range [0..64] (default: 16). Cl is number of columns, range [0..128] (default: specified by either the base option or -c,-C options). Note: 0 for either Rw or Cl will also invoke their defaults. .TP Note: Options are evaluated left-to-right. When options are mutually exclusive, only last one is effective. .TP .B "fb File" is the same as .B "fb -hAEKLNST -p . -r . -i 0 File" .TP Append and Copy methods: .TP .B "fb a RNG File1 [File2]" .TP .B "fb c RNG File1 [File2]" Copy bytes in range RNG from File1 and append/copy to File1 or optional File2. RNG is Start | [Start].[Stop]; where Start (default: 0) is the offset in File1 where copying should start and Stop (default: end of file) is offset where copying should stop. .TP Translate method: .TP .B "fb t[ ]b|d|h|o File1 [File2]" Convert binary|decimal|hexadecimal|octal numbers in File1 (or standard input if no space is present between "t" and base indicator) into bytes and copy bytes to File1 (or to optional File2 if input is NOT from standard input). See under notes (below) for more information. .TP Replace method: .TP .B "fb r RNG BYTE File" Replace bytes in range RNG of File with value BYTE [0..255]. RNG is Start | [Start].[Stop]; where Start (default: 0) is the offset in File where replacement should start and Stop (default: end of file) is the offset where replacement should stop. .TP Compare method: .TP .B "fb b|d|h|o|-|. File1 File2" Report offsets and byte values (in binary|decimal|hexadecimal|octal) where File1 and File2 differ till end of shortest file. If file lengths differ, report end of file (EOF) for both files. With option "-" report only if files differ and how. With option "." return exit status only: 0 - files the same, 1 - error, 2 - bytes differ, 3 - sizes differ, 4 - bytes and sizes differ. .TP Switches: .TP .B "- c" List interactive commands. .TP .B "- h" Display help page. .TP .B "- n" Display notes concerning .B fb. .TP .B "- v" Show current version information. .sp Note: A space MUST be present between "-" and either c, h, n, or v. .SS COMMANDS .TP .I + Set increment size INC to and increment. .TP .I - Set increment size INC to - and increment. .TP .I * Increment * INC bytes. .TP .I Increment INC bytes. .TP .I - Set INC to -INC and increment. .TP .I + Set INC to default (rows * columns) and increment. .TP .I # Display current value of INC. .TP .I Go to file offset position . .TP .I @ Overwrite bytes starting at position . (Edit mode only.) .TP .I b Binary display (default 8 columns). .TP .I B Binary display (default 16 columns). .TP .I d Decimal display (default 16 columns). .TP .I D Decimal display (default 32 columns). .TP .I h Hexadecimal display (default 16 columns). .TP .I H Hexadecimal display (default 32 columns). .TP .I o Octal display (default 16 columns). .TP .I O Octal display (default 32 columns). .TP .I c Character display only (default 64 columns). .TP .I C Character display only (default 128 columns). .TP .I [r].[c] If r is nonzero, set number of rows to r (range: [1..64]). If c is nonzero, override column defaults of above alphabetic commands and set number of columns to c (range [1..128]). .TP .I A.[c] Display according to A (=b|B|d|D|h|H|o|O|c|C) and restore default column settings if c not present or zero; otherwise, override column defaults and set number of columns to c. .TP .I | Toggle between supplemental character display present or absent. .TP .I / Toggle between column labels or no column labels. .TP .I ! Toggle between compressed or uncompressed numeric display. .TP .I Go to previous marked position. (Initial marked position is 0.) .TP .I ? Display list of commands. .TP .I Q Terminate program. (Not case sensitive.) .SH NOTES .TP + Program terminates if it reads past the last byte of the file. .TP + To prevent skewing of column labels when reading some files (e.g. a growing file) pass the program a maximum file size in the argument to the -r option. .TP + Overwriting, command @ (edit mode only), will accept input according to the current numeric base and will accept character strings (byte values in the range [32..126]) when no numeric display is present. .TP + Enter "<>" to toggle between two file positions. .TP + Files open for writing are also open for reading (see exception below). .TP + The command "." is null. .TP + Translate method: fb t[ ]b|d|h|o File1 [File2] .TP - All characters from "|" to end of line are ignored for input lines. .TP - If File1 and File2 are not the same file, File2 is open for writing only. .TP - Numbers in input may be delimited by any non-digit for base 2|8|10|16 with the exception of the "|" character. If not delimited, 8|3|3|2 digits will be converted at a time. .TP - Example: "fb -als File | fb th File.out" results in File and File.out having identical contents. .SH EXIT STATUS .B fb returns .TP .B 1 if an error occurred. .P .TP .B 0 if there were no errors .P with the exception of the compare method. In this case .B fb returns, if there were no errors, either .TP .B 0 files the same, .TP .B 2 bytes differ, .TP .B 3 sizes differ, or .TP .B 4 bytes and sizes differ. .SH AUTHOR .nf John Howard Swaby .IR polymath@uwyo.edu .fi .SH VERSION .B fb 1.5 (2 May 1999) .SH SEE ALSO dd(1), od(1) fb.c100644 0 0 106577 6713042135 7751 0ustar rootroot/* fb.c File Browser Author: John Howard Swaby Version: 1.5 Date: 2 May 1999 Copyright (C) 1998, 1999 John Howard Swaby 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. John Howard Swaby polymath@uwyo.edu */ /* For MS-DOS */ /* #define MSDOS */ /* For Linux running on a PC: Used below to exclude non-printable characters */ /* #define LINUX_PC */ /* For the Borland compiler: Used below because Borland uses chsize whereas everyone else uses ftruncate */ /* #define BORLAND */ /* For compilers without data type long long */ /* #define LONG_ONLY */ #include #include #include #include #include #include #include #ifdef MSDOS #include /* DOS_BINARY should be defined as the flag used in open(...) to read files as binary -- this might be found in fcntl.h */ #define DOS_BINARY O_BINARY #else #define DOS_BINARY 0 #endif #define STDIN 0 short command(int); void setHeader(char*,char*,short); short finishLine(char*,char*,short); void setWidth(char*); void setFormat(char*); char* isNum(char*,short); short clrInput(char*,short); void contin(char*); void diff(char**,char*); void chng(char**,char*); void move(int,char**,char*); void tran(int,char**,char*,char,unsigned short); void listCmds1(short); void listCmds2(void); void usage(char*,short); void info(char**,char*); void help(char*); unsigned short bk, noStop = 1, edit = 0, compress = 0; unsigned short ln = 0, rw = 16, rl, len, charOnly, showChar = 1, interact = 1, head = 1, err, cnt = 1, inc = 0, base, usrWidth = 0; #ifdef LONG_ONLY unsigned long fpos, stop, start = 0, mfpos = 0, ofpos = 0; #else unsigned long long fpos, stop, start = 0, mfpos = 0, ofpos = 0; #endif long efpos, delta; unsigned char c; char fill[10], fs[6], hs[6], oh[2048], h[2048]; char *sp, numerals[23]; int fd = STDIN; int main(int argc,char** argv) { unsigned short ok = 1, argLast, lastArg, showAddr = 1; unsigned short j, i = 0, cont, argIdx, sl, cmd; char *p, *t, s[2048], line[2048], buffer[129], sc[2]; t = p = *argv; while( *p ) { #ifdef MSDOS if( *p=='\\' ) #else if( *p=='/' ) #endif t = p; ++p; } p = *(t+1)&&t!=*argv?t+1:t; #ifdef MSDOS t = p; while( *t ) if( *t=='.' ) *t = '\0'; else ++t; #endif if( argc==1 ) usage(p,0); strcpy(numerals,"fedcbaFEDCBA9876543210"); if( argc==3&&argv[1][0]=='-'&&!argv[1][1]&&!argv[2][1] ) info(argv,p); else if( argc==4&&(argv[1][0]=='b'||argv[1][0]=='d'||argv[1][0]=='h'|| argv[1][0]=='o'||argv[1][0]=='-'||argv[1][0]=='.')&&!argv[1][1] ) diff(argv,p); else if( argc==5&&argv[1][0]=='r'&&!argv[1][1] ) chng(argv,p); else if( 32 ) { while( argIdx64?64:rl?rl:16; usrWidth = 0; ln = 0; if( (sp=strstr(argv[argIdx],"."))&&sp[1] ) { ln = atoi(sp+1); ln = ln>128?128:ln; usrWidth = (ln!=0); } } else usage(p,1); break; case 'i': if( ++argIdx0)) ) ++fpos; } else { efpos = fpos = start; lseek(fd,efpos,SEEK_SET); } setFormat(s); if( (cont=(read(fd,&c,1)>0&&(noStop||fposstart ) start = 0; else if( start+delta>LONG_MAX ) { inc = 0; delta = bk; start = LONG_MAX; } else start += delta; efpos = fpos = start; if( lseek(fd,efpos,SEEK_SET)<0 ) { fprintf(stderr,"%s: An error has occurred while attempting",p); fprintf(stderr," to\n%*s position in file ",strlen(p),""); fprintf(stderr,"stream. This may be corrected\n"); fprintf(stderr,"%*s by either adjusting or ",strlen(p),""); fprintf(stderr,"removing the -i option.\n"); exit(1); } } start = fpos; ofpos = mfpos; } if( interact&&fpos>LONG_MAX ) { if( i ) finishLine(line,buffer,i); printf("\n<< Browsing limit: Use a non-interactive mode to "); printf("see more of this file. >>\n"); exit(0); } cont = cnt&&read(fd,&c,1)>0&&(noStop||fpos'&&!sp[1] ) start = ofpos; else if( *sp=='*'&&sp[1]&&isNum(sp+1,0) ) { num = strtol(sp+1,(char**)NULL,10); inum = inc?delta:bk; if( inum<0&&-inum*num>start ) num = 0; else num = start+inum*num; start = num; } else if( *sp=='/'&&!sp[1] ) { if( head=!head ) setHeader(h,oh,1); } else if( *sp=='|'&&!sp[1] ) { showChar = !showChar; if( head ) setHeader(h,oh,0); } else if( *sp=='+'&&sp[1]&&isNum(sp+1,0) ) { start += delta = strtol(sp+1,(char**)NULL,10); inc = 1; } else if( *sp=='-'&&!sp[1] ) { delta = -(inc?delta:bk); inc = 1; if( delta<0&&-delta>start ) start = 0; else start += delta; } else if( *sp=='-'&&sp[1]&&isNum(sp+1,0) ) { delta = -strtol(sp+1,(char**)NULL,10); inc = 1; if( delta<0&&-delta>start ) start = 0; else start += delta; } else if( *sp=='?'&&!sp[1] ) { listCmds1(edit); contin(""); listCmds2(); contin(""); if( head ) printf("%s\n",h); } else if( *sp=='#'&&!sp[1] ) { printf("INC = "); if( inc ) printf("%ld ",delta); printf("%sdefault%s%ld)",inc?"(":"",inc?": ":" (",bk); contin(" "); if( head ) printf("%s\n",h); } else if( *sp=='!'&&!sp[1] ) { compress = !compress; if( head ) setHeader(h,oh,0); } else if( strstr("BbCcDdHhOo",sc)&& (!sp[1]||sp[1]=='.'&&isNum(sp+2,0)) ) { if( sp[1]=='.'||!usrWidth ) { usrWidth = 0; if( sp[1]=='.'&&(cl=atoi(sp+2))>0 ) { usrWidth = 1; ln = cl>128?128:cl; bk = rw*ln; } else setWidth(sc); delta = inc?delta:bk; } setFormat(sc); if( head ) setHeader(h,oh,0); } else if( tp=isNum(sp,1) ) { if( (cl=atoi(tp+1))>0 ) { ln = cl>128?128:cl; usrWidth = 1; if( head ) setHeader(h,oh,0); } if( (rl=atoi(sp))>0 ) rw = rl>64?64:rl; bk = rw*ln; delta = inc?delta:bk; } else if( edit&&*sp=='@'&&sp[1]&&isNum(sp+1,0) ) { efpos = strtol(sp+1,(char**)NULL,10); lseek(fd,efpos,SEEK_SET); if( read(fd,&value,1)>0 ) { lseek(fd,-1,SEEK_CUR); tp = numerals+22-base-(base==16?6:0); *t = '@'; while( *t&&read(fd,&value,1)>0 ) { printf("%0*ld:%s",len,efpos,!base?" ":compress?"":" "); while( !fgets(t,2048,stdin) ); stp = t; bad = clrInput(t,base); if( *t ) { if( bad ) { lseek(fd,-1,SEEK_CUR); printf("Invalid characters in input.\n"); } else if( base ) { lseek(fd,-1,SEEK_CUR); num = 1; ttp = stp; while( num&&*stp ) if( *stp==' ' ) ++stp; else { sc[0] = *ttp = *stp; num = (strstr(tp,sc)!=NULL); ++ttp; ++stp; } *ttp = '\0'; if( !num ) printf("Base %d number invalid.\n",base); else if( (num=strtoul(t,(char**)NULL,base))>255 ) printf("Value out of range [0..%s].\n", base==2?"11111111":base==8?"377": base==10?"255":"FF"); else { value = num; write(fd,&value,1); ++efpos; } } else { do { lseek(fd,-1,SEEK_CUR); write(fd,stp,1); ++stp; ++efpos; } while( *stp&&read(fd,&value,1)>0 ); } } } } else contin("Offset out of range "); if( head ) printf("%s\n",h); } else if( isNum(sp,0) ) start = strtol(sp,(char**)NULL,10); else { contin("Unrecognized command "); if( head ) printf("%s\n",h); } if( stay ) { if( start>LONG_MAX ) start = LONG_MAX; efpos = fpos = start; lseek(fd,efpos,SEEK_SET); } } } return *sp; } short finishLine(char* line,char* buffer,short i) { short j; printf("%s",line); if( showChar||charOnly ) { buffer[i] = '\0'; for(j=i;j> Press Enter to continue: ",s); while( !fgets(t,2048,stdin) ); clrInput(t,1); } void diff(char** argv,char* p) { short i, j, u, zero; int n1, n2; #ifdef LONG_ONLY unsigned long f1 = 0, f2 = 0; #else unsigned long long f1 = 0, f2 = 0; #endif unsigned char c1[8192], c2[8192]; int fdo; if( (fd=open(argv[2],O_RDONLY|DOS_BINARY))<0 ) { if( argv[1][0]!='.' ) fprintf(stderr,"%s: Can't open file \"%s\".\n",p,argv[2]); exit(1); } if( (fdo=open(argv[3],O_RDONLY|DOS_BINARY))<0 ) { if( argv[1][0]!='.' ) fprintf(stderr,"%s: Can't open file \"%s\".\n",p,argv[3]); exit(1); } fs[0] = '\0'; if( argv[1][0]=='d' ) { ln = 3; strcpy(fs,"%3u %3u\n"); } else if( argv[1][0]=='h' ) { ln = 2; strcpy(fs,"%2X %2X\n"); } else if( argv[1][0]=='o' ) { ln = 3; strcpy(fs,"%3o %3o\n"); } else if( argv[1][0]=='b' ) ln = 8; sprintf(h,"%ld",LONG_MAX); len = strlen(h); fpos = u = 0; f1 += n1 = read(fd,c1,8192); f2 += n2 = read(fdo,c2,8192); while( n1>0||n2>0 ) { for(i=0;i255 ) usage(p,1); value = num; if( (fd=open(argv[4],O_RDWR|DOS_BINARY))<0 ) { fprintf(stderr,"%s: Can't open file \"%s\" for reading and writing.\n", p,argv[4]); exit(1); } efpos = start; lseek(fd,efpos,SEEK_SET); while( read(fd,&c,1)>0&&(noStop||efpos0 ) { fprintf(stderr,"%s: Cannot append to file \"%s\".\n",p,argv[argc-1]); exit(1); } efpos = lseek(fd,0,SEEK_END); if( read(fd,&c,1)>0 ) { fprintf(stderr,"%s: Cannot append from file \"%s\".\n",p,argv[3]); exit(1); } } ffpos = fpos = start; lseek(fd,ffpos,SEEK_SET); ffpos = 0; while( read(fd,&c,1)>0&&(noStop||fpos0 ) { for(j=0;j255 ) { fprintf(stderr,"%s: Value %s out of range [0..%s].\n",p, fill,base==8?"377":"255"); exit(1); } else { b = num; write(fdo,&b,1); ++efpos; } i = 0; if( digit ) fill[i++] = c; else digits = 0; } } if( !digit&&(c=='|'||c=='\n') ) cmnts = (c!='\n'&&(cmnts||c=='|')); } if( n2>0 ) n2 = read(fd,buf,8192); } close(fd); #ifdef BORLAND chsize(fdo,efpos); #else ftruncate(fdo,efpos); #endif close(fdo); exit(0); } void listCmds1(short showEdCmd) { printf(" + Set increment INC to and"); printf(" increment.\n"); printf(" - Set increment INC to - and"); printf(" increment.\n"); printf(" * Increment * INC bytes.\n"); printf(" Increment INC bytes.\n"); printf(" - Set INC to -INC and increment.\n"); printf(" + Set INC to default (rows * columns) and increment.\n"); printf(" # Display current value of INC.\n"); printf(" Go to file offset position .\n"); if( showEdCmd ) { printf(" @ Overwrite bytes starting at position . "); printf(" (Edit mode only.)\n"); } printf(" b|B Binary display (default 8|16 columns).\n"); printf(" d|D Decimal display (default 16|32 columns).\n"); printf(" h|H Hexadecimal display (default 16|32 columns).\n"); printf(" o|O Octal display (default 16|32 columns).\n"); printf(" c|C Character display only (default 64|128 columns).\n"); } void listCmds2(void) { printf(" [r].[c] If r is nonzero, set number of rows to r"); printf(" (range [1..64]).\n"); printf(" If c is nonzero, override column defaults of above"); printf(" alphabetic\n"); printf(" commands and set number of columns to c"); printf(" (range [1..128]).\n"); printf(" A.[c] Display according to A (=b|B|d|D|h|H|o|O|c|C)"); printf(" and restore\n"); printf(" default column settings if c not present or zero; "); printf("otherwise,\n"); printf(" override column defaults and set number of columns "); printf("to c.\n"); printf(" | Toggle between supplemental character display "); printf("present or absent.\n"); printf(" / Toggle between column labels or no column labels.\n"); printf(" ! Toggle between compressed or uncompressed numeric "); printf("display.\n"); printf(" Go to previous marked position. (Initial marked"); printf(" position is 0.)\n"); printf(" ? Display this list of commands.\n"); printf(" Q|q Terminate program.\n"); } void usage(char* p,short u) { FILE* fp; fp = u==1?stderr:stdout; fprintf(fp,"Usage: %s\n [- c|h|n|v] | [[-AaBbCcDdEeHhKkLlNnOoSsTt]",p); fprintf(fp," [-i INC] [-r RNG] [-p PS] File] |\n"); fprintf(fp," [r RNG BYTE File] | [a|c RNG File1 [File2]] | "); fprintf(fp,"[t[ ]b|d|h|o File1 [File2]] |\n"); fprintf(fp," [b|d|h|o|-|. File1 File2]\n"); fprintf(fp,"Enter: %s\n - h for help, - n for notes, ",p); fprintf(fp,"- v for version, or - c for commands.\n"); if( u<2 ) exit(u); } void info(char** argv,char* p) { if( argv[2][0]=='h' ) { usage(p,2); help(p); exit(0); } else if( argv[2][0]=='n' ) { printf("+ Program terminates if it reads past the last byte of "); printf("the file.\n"); printf("+ INC is set to default whenever the offset is beyond %ld.\n", LONG_MAX); printf("+ To prevent skewing of column labels when reading some files "); printf("(e.g. a growing\n file) pass the program "); printf("a maximum file size in the argument to the -r option.\n"); printf("+ Overwriting, command @ (edit mode only), will "); printf("accept input according to the\n current numeric base and "); printf("will accept character strings (byte values in the\n range "); printf("[32..126]) when no numeric display is present.\n"); printf("+ Enter \"<>\" to toggle between two file positions.\n"); printf("+ Files open for writing are also open for reading (see "); printf("exception below).\n"); printf("+ Translate method: %s t[ ]b|d|h|o File1 [File2]\n",p); printf(" - All characters from \"|\" to end of line are ignored for "); printf("input lines.\n"); printf(" - If File1 and File2 are not the same file, File2 is open "); printf("for writing only.\n"); printf(" - Numbers in input may be delimited by any non-digit "); printf("for base 2|8|10|16 with\n"); printf(" the exception of the \"|\" character. If not delimited, "); printf("8|3|3|2 digits will\n"); printf(" be converted at a time.\n"); printf(" - Example: %s -als File | %s th File.out\n",p,p); printf(" results in File and File.out having identical "); printf("contents.\n"); exit(0); } else if( argv[2][0]=='v' ) { #ifdef MSDOS printf("FB"); #else printf("fb"); #endif printf(" - File Browser, version 1.5, 2 May 1999\n"); printf(" Copyright (C) 1998, 1999 John Howard Swaby\n"); printf(" Report bugs to polymath@uwyo.edu\n"); #ifdef MSDOS if( strcmp(p,"FB") ) #else if( strcmp(p,"fb") ) #endif printf("Current alias: %s\n",p); exit(0); } else if( argv[2][0]=='c' ) { listCmds1(1); listCmds2(); exit(0); } } void help(char* p) { printf("Base options:\n"); printf(" -b,-B Binary numbers (8 or 16 columns).\n"); printf(" -d,-D Decimal numbers (16 or 32 columns).\n"); printf(" -h,-H Hexadecimal numbers (16 or 32 columns).\n"); printf(" -o,-O Octal numbers (16 or 32 columns).\n"); printf("Display options:\n"); printf(" -a,-A Suppress or display offset addresses.\n"); printf(" (Option -a is ignored if effective mode is "); printf("interactive.)\n"); printf(" -c,-C Characters only (64 or 128 columns).\n"); printf(" -k,-K Compressed or uncompressed numeric display.\n"); printf(" -l,-L Suppress or display column labels.\n"); printf(" -n,-N Exclude or include supplemental character display.\n"); printf("Mode options:\n"); printf(" -e Edit mode. (Ignored if either -s or -t options "); printf("in effect.)\n"); printf(" -E Read-only mode.\n"); printf(" -s Stream output (non-interactive mode).\n"); printf(" -S Interactive mode. (Will nullify previous -s or -t "); printf("options.)\n"); printf(" -t Read from standard input and stream output "); printf("(non-interactive mode).\n"); printf(" (Will nullify previous -S or -T options.) "); printf("File name MUST be \"-\".\n"); printf(" -T Read from File.\n"); printf("Options with arguments:\n"); printf(" -i INC Increment page INC bytes [0..%ld].\n",LONG_MAX); printf(" 0 sets increment to default, (number of rows)*"); printf("(number of columns).\n"); printf(" -r RNG Portion of File to browse. RNG is Start | "); printf("[Start].[Stop];\n"); printf(" where Start [0..%ld] (default: 0) and Stop ",LONG_MAX); printf("(default:\n"); printf(" end of file) are the starting and stopping offsets "); printf("of File.\n"); printf(" -p PS Page size. PS is Rw | [Rw].[Cl]. Rw [0..64] is "); printf("number of rows\n"); printf(" (default: 16). Cl [0..128] is number of columns "); printf("(default: specified\n"); printf(" by either the base option or "); printf("-c,-C options). 0 for either Rw or Cl\n"); printf(" will also invoke their defaults.\n"); printf("Note: Options are evaluated left-to-right. When options\n"); printf(" are mutually exclusive, only last one is effective.\n"); printf(" \"%s File\" performs the same as\n",p); printf(" \"%s -hAEKLNST -p . -r . -i 0 File\".",p); printf("\n"); printf("Replace method: %s r RNG BYTE File\n",p); printf(" Replace bytes in range RNG of File with value BYTE "); printf("[0..255]. RNG is\n Start | [Start].[Stop]; where Start "); printf("(default: 0) is offset in File where\n replacement should "); printf("start and Stop (default: end of file) is offset where\n"); printf(" replacement should stop.\n"); printf("Append/Copy method: %s a|c RNG File1 [File2]\n",p); printf(" Copy bytes in range RNG from File1 and append|copy to "); printf("File1 or optional\n"); printf(" File2. RNG is Start | [Start].[Stop]; where Start (default: 0)"); printf(" is offset\n in File1 where copying should start and Stop "); printf("(default: end of file) is\n offset where copying should "); printf("stop.\n"); printf("Translate method: %s t[ ]b|d|h|o File1 [File2]\n",p); printf(" Convert binary|decimal|hexadecimal|octal numbers in File1 "); printf("(or standard input\n if space is absent between \"t\" and base "); printf("indicator) into bytes and copy bytes\n to File1 (or optional "); printf("File2 if input is NOT from standard input). See under\n"); printf(" notes (%s - n) for more information.\n",p); printf("Compare method: %s b|d|h|o|-|. File1 File2\n",p); printf(" Report offsets and byte values (in binary|decimal|hexadecimal|"); printf("octal) where\n File1 and File2 differ till end of shortest file."); printf(" If file lengths differ,\n report end of file (EOF) for both "); printf("files. \"-\" - report only if files differ\n and how. \".\" - "); printf("return exit status only: 0 - files the same, 1 - error,\n "); printf("2 - bytes differ, 3 - sizes differ, 4 - bytes and sizes differ.\n"); } /* end of file: fb.c */ fb.doc100644 0 0 32545 6713165757 10265 0ustar rootroot FB(1) FB(1) NAME fb - binary file viewer, editor, and manipulator SYNOPSIS fb [[-AaBbCcDdEeHhKkLlNnOoSsTt] [-i INC] [-r RNG] [-p PS] File] | [r RNG BYTE File] | [a|c RNG File1 [File2]] | [t[ ]b|d|h|o File1 [File2]] | [b|d|h|o|-|. File1 File2] | [- c|h|n|v] DESCRIPTION fb provides interactive browsing of a file or the contents of a file can be streamed (without interaction) to stan- dard output. The file can be viewed in binary, octal, decimal, hexadecimal, or characters. Optionally, fb will read standard input if option -t is in effect and "-" is given as the file name. Output consists of "pages" of one or more lines. Each line of a page consists of the offset from the beginning of the file in decimal (optional if non-interactive), followed first by one or more columns of an optional numeric display in either binary, octal, deci- mal, or hexadecimal; and this, in turn, followed by an optional character display; however, at least one of the two displays must be present. Unprintable characters will show as a period. By default, fb has a hexadecimal numeric display along with a character display. fb also has a limited editing capability if invoked with the -e option and the file is writable. In edit mode, the user can specify which bytes in the file to overwrite. These bytes can be overwritten in either binary, octal, decimal, hexadecimal, or character formats. The format in effect is in agreement with the current display. fb also has five helper methods: append, copy, translate, replace, and compare. The append method allows for copy- ing a selection of the contents of one file to the end of another or the same file. If the second file does not exist, it is created. The copy method allows for copying a selection of the contents of one file to another or the same file. Be aware that the second file is overwritten; in particular, copying a file to itself will reduce the file to the size of the portion that was copied. The translate method will convert either binary, octal, decimal, or hexadecimal numbers in one file into bytes and copy these bytes to another or the same file. Or the translate will convert numbers from standard input into bytes and copy these to a file. The numbers can option- ally be delimited with any character that is not a digit for the given base and is not the character "|". The "|" character is used to indicate the start of a comment. The "|" character and all characters after it to the end of line will be ignored. At any place in the file where the numbers are not delimited, 8 digits (for binary), 3 digits 2 May 1999 1 FB(1) FB(1) (for octal and decimal), and 2 digits (for hexadecimal) will be converted at a time. The replace method will replace all of the bytes in a specified portion of a file with a particular value. The compare method will report the offsets where two files differ and the value of the bytes (in binary, decimal, hexadecimal, or octal) at these offsets till the end of the shortest file. If the lengths of the files are dif- ferent, it will also report the end of file (EOF) for both files. The exit status of the compare method is one of five values: 0 - files the same, 1 - an error has occur- red, 2 - bytes differ, 3 - sizes differ, and 4 - bytes and sizes differ. Optionally the compare method can report only if the files differ and how or it can run silent: returning only the exit status. OPTIONS Base options: -b Binary numbers (8 columns). -B Binary numbers (16 columns). -d Decimal numbers (16 columns). -D Decimal numbers (32 columns). -h Hexadecimal numbers (16 columns). -H Hexadecimal numbers (32 columns). -o Octal numbers (16 columns). -O Octal numbers (32 columns). Display options: -a Suppress offset addresses. (Ignored if effective mode is interactive.) -A Display offset addresses. -c Characters only (64 columns). -C Characters only (128 columns). -k Numeric display is compressed (no spaces between numbers). -K Numeric display is not compressed (spaces between numbers). 2 May 1999 2 FB(1) FB(1) -l Suppress column labels. -L Display column labels. -n Exclude supplemental character display. -N Include supplemental character display. Mode options: -e Edit mode. (Ignored if effective mode is non- interactive.) -E Read-only mode. -s Stream output (non-interactive mode). -S Interactive mode. (Will nullify previous -s or -t options.) -t Read from standard input and stream output (non- interactive mode). (Will nullify previous -S or -T options.) Note: File name MUST be "-". -T Read from File. Options with arguments: -i INC Increment page INC bytes. INC is a nonnegative integer. 0 sets increment to default, (number of rows)*(number of columns). -r RNG Portion of File to browse. RNG is Start | [Start].[Stop]; where Start (default: 0) and Stop (default: end of file) are the starting and stop- ping offsets of File. -p PS Page size. PS is Rw | [Rw].[Cl]. Rw is number of rows, range [0..64] (default: 16). Cl is number of columns, range [0..128] (default: specified by either the base option or -c,-C options). Note: 0 for either Rw or Cl will also invoke their defaults. Note: Options are evaluated left-to-right. When options are mutually exclusive, only last one is effective. fb File is the same as fb -hAEKLNST -p . -r . -i 0 File 2 May 1999 3 FB(1) FB(1) Append and Copy methods: fb a RNG File1 [File2] fb c RNG File1 [File2] Copy bytes in range RNG from File1 and append/copy to File1 or optional File2. RNG is Start | [Start].[Stop]; where Start (default: 0) is the offset in File1 where copying should start and Stop (default: end of file) is offset where copying should stop. Translate method: fb t[ ]b|d|h|o File1 [File2] Convert binary|decimal|hexadecimal|octal numbers in File1 (or standard input if no space is present between "t" and base indicator) into bytes and copy bytes to File1 (or to optional File2 if input is NOT from standard input). See under notes (below) for more information. Replace method: fb r RNG BYTE File Replace bytes in range RNG of File with value BYTE [0..255]. RNG is Start | [Start].[Stop]; where Start (default: 0) is the offset in File where replacement should start and Stop (default: end of file) is the offset where replacement should stop. Compare method: fb b|d|h|o|-|. File1 File2 Report offsets and byte values (in binary|deci- mal|hexadecimal|octal) where File1 and File2 differ till end of shortest file. If file lengths differ, report end of file (EOF) for both files. With option "-" report only if files differ and how. With option "." return exit status only: 0 - files the same, 1 - error, 2 - bytes differ, 3 - sizes differ, 4 - bytes and sizes differ. Switches: - c List interactive commands. - h Display help page. - n Display notes concerning fb. - v Show current version information. Note: A space MUST be present between "-" and either c, h, n, or v. 2 May 1999 4 FB(1) FB(1) COMMANDS + Set increment size INC to and increment. - Set increment size INC to - and increment. * Increment * INC bytes. Increment INC bytes. - Set INC to -INC and increment. + Set INC to default (rows * columns) and increment. # Display current value of INC. Go to file offset position . @ Overwrite bytes starting at position . (Edit mode only.) b Binary display (default 8 columns). B Binary display (default 16 columns). d Decimal display (default 16 columns). D Decimal display (default 32 columns). h Hexadecimal display (default 16 columns). H Hexadecimal display (default 32 columns). o Octal display (default 16 columns). O Octal display (default 32 columns). c Character display only (default 64 columns). C Character display only (default 128 columns). [r].[c] If r is nonzero, set number of rows to r (range: [1..64]). If c is nonzero, override column defaults of above alphabetic commands and set num- ber of columns to c (range [1..128]). 2 May 1999 5 FB(1) FB(1) A.[c] Display according to A (=b|B|d|D|h|H|o|O|c|C) and restore default column settings if c not present or zero; otherwise, override column defaults and set number of columns to c. | Toggle between supplemental character display pre- sent or absent. / Toggle between column labels or no column labels. ! Toggle between compressed or uncompressed numeric display. Go to previous marked position. (Initial marked position is 0.) ? Display list of commands. Q Terminate program. (Not case sensitive.) NOTES + Program terminates if it reads past the last byte of the file. + To prevent skewing of column labels when reading some files (e.g. a growing file) pass the program a maximum file size in the argument to the -r option. + Overwriting, command @ (edit mode only), will accept input according to the current numeric base and will accept character strings (byte values in the range [32..126]) when no numeric display is present. + Enter "<>" to toggle between two file positions. + Files open for writing are also open for reading (see exception below). + The command "." is null. + Translate method: fb t[ ]b|d|h|o File1 [File2] - All characters from "|" to end of line are ignored for input lines. - If File1 and File2 are not the same file, File2 is open for writing only. 2 May 1999 6 FB(1) FB(1) - Numbers in input may be delimited by any non-digit for base 2|8|10|16 with the exception of the "|" character. If not delimited, 8|3|3|2 digits will be converted at a time. - Example: "fb -als File | fb th File.out" results in File and File.out having identical contents. EXIT STATUS fb returns 1 if an error occurred. 0 if there were no errors with the exception of the compare method. In this case fb returns, if there were no errors, either 0 files the same, 2 bytes differ, 3 sizes differ, or 4 bytes and sizes differ. AUTHOR John Howard Swaby polymath@uwyo.edu VERSION fb 1.5 (2 May 1999) SEE ALSO dd(1), od(1) 2 May 1999 7