ncurses-hexedit-0.9.7.orig/0040777000175000017500000000000006753210663014246 5ustar apocapocncurses-hexedit-0.9.7.orig/Makefile.in0100644000175000017500000002501106753210661016301 0ustar apocapoc# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : CC = @CC@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ SUBDIRS = docs src gnu EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL NEWS README install-sh missing mkinstalldirs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ Makefile.am Makefile.in NEWS acconfig.h aclocal.m4 config.in configure \ configure.in install-sh missing mkinstalldirs DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status $(ACLOCAL_M4): configure.in cd $(srcdir) && $(ACLOCAL) config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) config.h: stamp-h @if test ! -f $@; then \ rm -f stamp-h; \ $(MAKE) stamp-h; \ else :; fi stamp-h: $(srcdir)/config.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES= CONFIG_HEADERS=config.h:config.in \ $(SHELL) ./config.status @echo timestamp > stamp-h 2> /dev/null $(srcdir)/config.in: $(srcdir)/stamp-h.in @if test ! -f $@; then \ rm -f $(srcdir)/stamp-h.in; \ $(MAKE) $(srcdir)/stamp-h.in; \ else :; fi $(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h cd $(top_srcdir) && $(AUTOHEADER) @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null mostlyclean-hdr: clean-hdr: distclean-hdr: -rm -f config.h maintainer-clean-hdr: # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. @SET_MAKE@ all-recursive install-data-recursive install-exec-recursive \ installdirs-recursive install-recursive uninstall-recursive \ check-recursive installcheck-recursive info-recursive dvi-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ dot_seen=no; \ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ rev="$$subdir $$rev"; \ test "$$subdir" = "." && dot_seen=yes; \ done; \ test "$$dot_seen" = "no" && rev=". $$rev"; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: tags-recursive $(HEADERS) $(SOURCES) config.in $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)config.in$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.in $$unique $(LISP) -o $$here/TAGS) mostlyclean-tags: clean-tags: distclean-tags: -rm -f TAGS ID maintainer-clean-tags: distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist -rm -rf $(distdir) GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz mkdir $(distdir)/=build mkdir $(distdir)/=inst dc_install_base=`cd $(distdir)/=inst && pwd`; \ cd $(distdir)/=build \ && ../configure --srcdir=.. --prefix=$$dc_install_base \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) dist -rm -rf $(distdir) @banner="$(distdir).tar.gz is ready for distribution"; \ dashes=`echo "$$banner" | sed s/./=/g`; \ echo "$$dashes"; \ echo "$$banner"; \ echo "$$dashes" dist: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) dist-all: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) distdir: $(DISTFILES) -rm -rf $(distdir) mkdir $(distdir) -chmod 777 $(distdir) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done for subdir in $(SUBDIRS); do \ if test "$$subdir" = .; then :; else \ test -d $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \ || exit 1; \ chmod 777 $(distdir)/$$subdir; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ || exit 1; \ fi; \ done info-am: info: info-recursive dvi-am: dvi: dvi-recursive check-am: all-am check: check-recursive installcheck-am: installcheck: installcheck-recursive all-recursive-am: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive install-exec-am: install-exec: install-exec-recursive install-data-am: install-data: install-data-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-recursive uninstall-am: uninstall: uninstall-recursive all-am: Makefile config.h all-redirect: all-recursive-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: installdirs-recursive installdirs-am: mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic mostlyclean: mostlyclean-recursive clean-am: clean-hdr clean-tags clean-generic mostlyclean-am clean: clean-recursive distclean-am: distclean-hdr distclean-tags distclean-generic clean-am distclean: distclean-recursive -rm -f config.status maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-recursive -rm -f config.status .PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ install-data-recursive uninstall-data-recursive install-exec-recursive \ uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ all-recursive check-recursive installcheck-recursive info-recursive \ dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ install-exec-am install-exec install-data-am install-data install-am \ install uninstall-am uninstall all-redirect all-am all installdirs-am \ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ncurses-hexedit-0.9.7.orig/README0100644000175000017500000001426606735465435015141 0ustar apocapoc Hexedit version 0.9.3 by Adam Rogoyski Temperanc on EFNet Copyright (C) 1998, 1999 Adam Rogoyski --- GNU General Public License Disclamer --- 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. ** THIS IS NOT THE OFFICIAL DOCUMENTATION ** I forget to update this file. The Texinfo or LaTeX documentation is what is really worth reading. Look in docs/ direcotry. Hexedit Version 0.9.3 is a full screen text mode Hex editor using the curses library. Hexedit needs to be run in a screen with at least 80 columns or it will not look very good. At least an 80x10 screen minimum. It will look fine at any larger modes. It should resize fine in an xterm. I've built and tested this on the following systems: Linux 2.0.36 i386 ncurses 4.2 (gcc) Linux 2.2.3 i386 ncurses 4.2 (gcc) OpenBSD 2.4 i386 ncurses (gcc) SunOS 5.6 Sparc curses (gcc) AIX 4.3.2 rs6000 curses (gcc and cc) AIX 4.3.2 ppc curses (gcc and cc) DOS 6.22 i386 pdcurses (djgpp gcc) IRIX 6.3 mips curses (gcc) HP-UX B.10.20 curses (gcc) SunOS 5.5.1 sparc curses (gcc) OSF V4.0 alpha curses (gcc) COLOR: SunOS/Solaris: For color, try TERM=AT386, else vt100. AIX Users: You can use TERM=aixterm for color, but when not in X it seems to get the colors mixed up. LINUX USERS: If the editor is not using the last line of the screen, you probably didn't set your TERM environment to linux. in bash: export TERM=linux in tcsh: setenv TERM linux Also try vt100 if linux doesn't work. Color seems to work with TERM=linux. Controls: Maneuver Arrow Keys (or h,j,k.l), Home, End Page Up Control-y, Control-b, Alt-v, Page Up, u, y Page Down Control-v, Control-f, Page Down, v, space Bytes <=> Text Tab, Control-i Insert/Add Byte Control-a, Insert Delete byte control-d, Delete goTo Offset Control-t, t Offset + Jump +, -, n (jump again) Help Control-g Redraw Screen Control-l Save Control-o Save and Quit Control-x Quit (no save) Control-c viEw as text Control-e Search Control-w, w find Next Control-n Undo Control-u ASCII <=> EBCDIC Control-R Switch Spacing Control-P Binary Calculator Control-/ NOTE: - For some commands, Control-x, Control-g and Escape are cancel. Escape may take a second to work. This is normal, it is how curses works and deals with input I believe. - Viewing as text may seem messed up when looking at big binary chunks (why do you want to view this as text anyways?), but it's fine. When looking at binary in text, I had to decide how to display files with little or no newlines so that text portions look ok and the same each time. So it looks back to the last new line and starts from there. So the part you may want to look at may not even be on the screen. To me, this isn't a problem - It's a binary file, look at it in hex! Also, all non printable characters, even newlines, are represented as "." even in the full screen text mode. NOTE: This only takes a snapshot of the current section, you cannot use this feature as a fileviewer of text. It just lets you see a quick snapshot of what it would like like in text. - Goto Offset command takes input as either Hex (i.e. 0xFF), Octal (i.e. 0377) or Base 10 (i.e. 255). I know what you're thinking, but no, strtol () does this for you. - I put a few different ways to page up and down because most people are used to vi or emacs. I personally like how pico is set up. Any other resemblances to pico are purely my doing. - Year 2000 compliant. =) - Searching uses the Boyer-Moore search algorith, and the whole file is in memory, so it's fast. Real fast. - Changes are highlighted in bold. If you insert or delete a byte, all bold is removed until you change something else. This seems like the best thing to do here. Or else I'd be highlighting all the rest of the file. - Undo: for undo, if the modified byte is on the screen, it is reverted to it's previous state. If it is not on the screen, you are brought to the byte's location so it is viewable on the screen. The next Undo command will revert the byte back to it's previous state. - Environment variable HEXEDIT can be used to save your command line options. Example, export HEXEDIT=-8r would put hexedit into readonly mode with 8-bit printing on by default. BUGS - DRAWBACKS - You currently can only edit files and disks up to 4.2 gigs. - On SunOS if you use control-v for page down you have to do it twice. This has to do with the terminal driver interpreting Control-v for it's purposes. If there is a portable way to changes this let me know. *** I've been informed that this is a normal terminal driver thingy. Still, how do I get around it? - I've had different results with older versions of ncurses. Tell me if anything breaks. It should work though. If there are any problems and bugs please send me mail so I can fix them. If you have any extra computer stuff, money, guitar stuff, or anything Stevie Ray Vaughan that you don't want please contact me. Shameless plugs: Video Game Expresss! http://www.vgeonline.com Lisa Loeb Web Shrine http://www.lisaloeb.org Author: Adam Rogoyski As of January 1999, I am a sophomore of Computer Science at the Univeristy of Texas at Austin. ncurses-hexedit-0.9.7.orig/stamp-h.in0100644000175000017500000000001206753161350016127 0ustar apocapoctimestamp ncurses-hexedit-0.9.7.orig/AUTHORS0100644000175000017500000000025606647654715015326 0ustar apocapoc* Adam Rogoyski apoc@laker.net ifqa242@spice.cc.utexas.edu Author of [N]curses Hexedit. * Matt Noel mgn00@eng.amdahl.com EBCDIC and spacing (mostly his ideas). ncurses-hexedit-0.9.7.orig/COPYING0100644000175000017500000004431106647612501015274 0ustar apocapocGNU 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. 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. one line to give the program's name and an idea of what it does. Copyright (C) 19yy name of author 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. signature of Ty Coon, 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. ncurses-hexedit-0.9.7.orig/ChangeLog0100644000175000017500000001154706753210655016022 0ustar apocapoc0.9.7: August 8th, 1999 + Changed date format to use ISO 8601 format. + Fixed file selection to use Control-X for exit. + Changed initialization and File selection errors to work right. + Changed Quit to allow Loading a new file (Quit : Yes, No, New File). + Fixed as many memory leaks as I could find, since with the ability to edit more than one file, a user never needs to even ever exit hexedit. + COLOR!!! Terminals that support color can use color. + -nocolor option for the people who like the default gray scale. + Added Function Keys, F1 for help, F2 for Save, F3 for exit. + F5 Function key toggles color + Fixed typo with saving a file. + Fixed Control-C so that it works correctly, or at least reasonably. + Fixed arrow keys so that they should work everywhere on vt100 terminals. + Added help.c + Fixed Help. Help now works how I wanted it to, will let you scroll up and down if it doesn't all fit on the screen. 0.9.6: April 23rd, 1999 + Fixed view text mode so that it doesn't wrongfully skip lines. + Fixed some occurences of "ascii" to "text" to be clearer. + Added J/K keys for down/up arrows in search selection and calculator. + Fixed some help messages and menus. 0.9.5: April 8th, 1999 + Fixed bug with delete, now we truncate the file to the corect size. Thanks to tenthumbs for this obvious one that got past me. 0.9.4: Marth 20th, 1999 + Added OpenBSD disk support. + Fixed man page errors. + Fixed a few unclear messages about insert and delete. 0.9.3: March 17th, 1999 + Added support for reading file in chunks. Major addition. + Command line flags -b (buffer), -d,-f (linux disk), -q (quiet, no beeping) + Added support for editing fixed disks in Linux. - Removed Bold Table thingy (table_ functions) to be replaced by hash + Added hash table to lookup changes and boldify things. (hash.c) + Control-U to delete whole line in stringBox widget + Jumping relative to current offset fowards or backwards. + Lots of fixes and small changes to make things work right. + Lots and lots of small changes everywhere! + Documentation updates for new features. 0.9.2: February 23rd, 1999 AD + added command line options for printing 8-bit and all text characters. + added HEXEDIT environment variable for saving command line arguments + fixed pre-processor directives (stupid compile fix). + fixed some online messages relating to being in read-only mode. + added vi (h,j,k,l) movement keys + fixed a few dumb typos and small bugs. + changed email address to match rfc style. + Suggestions from Sotiris Vassilopoulos 0.9.1: January 31st, 1999 AD + New read-only mode, prevents you from modifying the file. + Added command line arguments (gnu/getopt* files) + Added autoconf check for TIOCGWINSZ (*termio*.h) and getopt_long + fix a few compile bugs. + fixed file widget status window to display correctly. + Updated documentation. 0.9.0: January 16th, 1999 AD + Added 4 byte work spacing mode (Matt Noel). + Added EBCDIC support (Matt Noel). + Switching between ASCII and EBCDIC, and spacings. + fixed editing, undo, for EBCDIC and spacings. + Updated Texinfo docs and man page. - Removed LaTeX doc, use Texinfo instead. + Fixed memory bug in Search. 0.8.9: January 12th, 1999 AD + Added Automake/Autoconf GNU build system. + Fixed some compatibility issues. + Updated LaTeX documentation. + Added Texinfo documentation. + Added default INSTALL file. + Close to GNU coding standards now. + changed identifier tab to tabb (AIX doesn't like tab). + Fixed some bugs in calculator. 0.8.8: January 4th, 1999 AD + Added file.c + File Selection widget for when no command line file is given, does the ls thing graphically. + Merge sort for linked lists (to sort files in current directory for use with the file selection). + Added filekeys.c +- Split file.c into file.c and filekeys.c + Finished File Selection widget. + Not specifying a file brings up the brand new File Selection Widget. Full screen Directory listings allow you to find the file you want to edit easily. + Handles SIGWINCH in File Select mode. + Updated Documentation. + Cleaned up Makefile 0.8.7: December 20th, 1998 AD + Added Real Documentation in LaTeX format (docs/hexedit.tex) with included DVI (docs/hexedit.dvi) and Postscript (docs/hexedit.ps) translations. + Fixed Undo so it beeps correctly when there's nothing to undo. 0.8.6: December 20th, 1998 AD + Added CHANGES file + added undo.c + added struct Change + added struct ChangeLog + Added Undo command ^U + Added Undo into help menus + Merged hexedit.h and main.h - Removed main.h + Merged Makefiles - Removed Makefile.* 0.8.5: August 16th, 1998 AD o First real public release ncurses-hexedit-0.9.7.orig/INSTALL0100644000175000017500000001753606655101237015301 0ustar apocapocFor the impatient, basically do this to install ./configure make make install If you want further instructions or flexibility, read the following generic GNU installation instructions. Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. ncurses-hexedit-0.9.7.orig/Makefile.am0100644000175000017500000000017006655116760016275 0ustar apocapocSUBDIRS = docs src gnu EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL NEWS README \ install-sh missing mkinstalldirs ncurses-hexedit-0.9.7.orig/NEWS0100644000175000017500000000177506753171220014743 0ustar apocapoc I'm making a list of things I need to do here so I don't forget. - Redo input processing. In multiple places I get input and do basically the same thing each time. Make one generic routine to process input. - Redo Search popup window. It's ugly, and I don't feel I can add seach/replace without changing it enough that re-writing it would be easier. - Use the new generic popupError window for errors, since I use this all over the place, and it all is basically cut and paste. - Fix Help screen so that resizing window works. ------------------------------------------------------------------------- As of version 0.9.3, Viewing and editing fixed disks under Linux works! Currently, this is only for disks up to 4.2 gigs, but this is being worked on. It works on OpenBSD as well. I'm still looking for more stories on how hexedit saved the day, especially situations where hexedit was just a small part of a larger solution. I want to include these in the manual. ncurses-hexedit-0.9.7.orig/acconfig.h0100644000175000017500000000107606661073202016157 0ustar apocapoc /* Name of package */ #undef PACKAGE /* Version of package */ #undef VERSION /* Enable GNU extensions */ #undef _GNU_SOURCE /* Curses library */ #undef HAVE_CURSES_H /* NCurses library */ #undef HAVE_NCURSES_H /* termio */ #undef HAVE_TERMIO_H /* termios */ #undef HAVE_TERMIOS_H /* sys/termio */ #undef HAVE_SYS_TERMIO_H /* sys/termios */ #undef HAVE_SYS_TERMIOS_H /* getopt.h */ #undef HAVE_GETOPT_H /* getopt_long () */ #undef HAVE_GETOPT_LONG /* snprintf () */ #undef HAVE_SNPRINTF /* isprint () */ #undef HAVE_ISPRINT ncurses-hexedit-0.9.7.orig/aclocal.m40100644000175000017500000001045406753161332016101 0ustar apocapocdnl aclocal.m4 generated automatically by aclocal 1.4 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A dnl PARTICULAR PURPOSE. # Do all the work for Automake. This macro actually does too much -- # some checks are only needed if your package does certain things. # But this isn't really a big deal. # serial 1 dnl Usage: dnl AM_INIT_AUTOMAKE(package,version, [no-define]) AC_DEFUN(AM_INIT_AUTOMAKE, [AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) VERSION=[$2] AC_SUBST(VERSION) dnl test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi ifelse([$3],, AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) AC_REQUIRE([AM_SANITY_CHECK]) AC_REQUIRE([AC_ARG_PROGRAM]) dnl FIXME This is truly gross. missing_dir=`cd $ac_aux_dir && pwd` AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_REQUIRE([AC_PROG_MAKE_SET])]) # # Check to make sure that the build environment is sane. # AC_DEFUN(AM_SANITY_CHECK, [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "[$]*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "[$]*" != "X $srcdir/configure conftestfile" \ && test "[$]*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "[$]2" = conftestfile ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi rm -f conftest* AC_MSG_RESULT(yes)]) dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl The program must properly implement --version. AC_DEFUN(AM_MISSING_PROG, [AC_MSG_CHECKING(for working $2) # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if ($2 --version) < /dev/null > /dev/null 2>&1; then $1=$2 AC_MSG_RESULT(found) else $1="$3/missing $2" AC_MSG_RESULT(missing) fi AC_SUBST($1)]) # Like AC_CONFIG_HEADER, but automatically create stamp file. AC_DEFUN(AM_CONFIG_HEADER, [AC_PREREQ([2.12]) AC_CONFIG_HEADER([$1]) dnl When config.status generates a header, we must update the stamp-h file. dnl This file resides in the same directory as the config header dnl that is generated. We must strip everything past the first ":", dnl and everything past the last "/". AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, <>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, <>; do case " <<$>>CONFIG_HEADERS " in *" <<$>>am_file "*<<)>> echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx ;; esac am_indx=`expr "<<$>>am_indx" + 1` done<<>>dnl>>) changequote([,]))]) ncurses-hexedit-0.9.7.orig/config.in0100644000175000017500000000340406710214066016027 0ustar apocapoc/* config.in. Generated automatically from configure.in by autoheader. */ /* Define to empty if the keyword does not work. */ #undef const /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define if your declares struct tm. */ #undef TM_IN_SYS_TIME /* Enable GNU extensions */ #undef _GNU_SOURCE /* termio */ #undef HAVE_TERMIO_H /* termios */ #undef HAVE_TERMIOS_H /* sys/termio */ #undef HAVE_SYS_TERMIO_H /* sys/termios */ #undef HAVE_SYS_TERMIOS_H /* getopt_long () */ #undef HAVE_GETOPT_LONG /* Define if you have the getopt_long function. */ #undef HAVE_GETOPT_LONG /* Define if you have the isprint function. */ #undef HAVE_ISPRINT /* Define if you have the snprintf function. */ #undef HAVE_SNPRINTF /* Define if you have the header file. */ #undef HAVE_CURSES_H /* Define if you have the header file. */ #undef HAVE_DIRENT_H /* Define if you have the header file. */ #undef HAVE_FCNTL_H /* Define if you have the header file. */ #undef HAVE_GETOPT_H /* Define if you have the header file. */ #undef HAVE_LIMITS_H /* Define if you have the header file. */ #undef HAVE_NCURSES_H /* Define if you have the header file. */ #undef HAVE_NDIR_H /* Define if you have the header file. */ #undef HAVE_SYS_DIR_H /* Define if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define if you have the header file. */ #undef HAVE_SYS_NDIR_H /* Define if you have the header file. */ #undef HAVE_UNISTD_H /* Define if you have the ncurses library (-lncurses). */ #undef HAVE_LIBNCURSES /* Name of package */ #undef PACKAGE /* Version number of package */ #undef VERSION ncurses-hexedit-0.9.7.orig/configure0100755000175000017500000021463006753161333016153 0ustar apocapoc#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir="$ac_optarg" ;; -build | --build | --buil | --bui | --bu) ac_prev=build ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$ac_optarg" ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file="$ac_optarg" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix="$ac_optarg" ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$ac_optarg" ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir="$ac_optarg" ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir="$ac_optarg" ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir="$ac_optarg" ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir="$ac_optarg" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir="$ac_optarg" ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir="$ac_optarg" ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir="$ac_optarg" ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix="$ac_optarg" ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix="$ac_optarg" ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix="$ac_optarg" ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name="$ac_optarg" ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir="$ac_optarg" ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir="$ac_optarg" ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site="$ac_optarg" ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir="$ac_optarg" ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir="$ac_optarg" ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes="$ac_optarg" ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries="$ac_optarg" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=src/main.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break fi done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:557: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 echo "configure:610: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "$*" != "X $srcdir/configure conftestfile" \ && test "$*" != "X conftestfile $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". { echo "configure: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" 1>&2; exit 1; } fi test "$2" = conftestfile ) then # Ok. : else { echo "configure: error: newly created file is older than distributed files! Check your system clock" 1>&2; exit 1; } fi rm -f conftest* echo "$ac_t""yes" 1>&6 if test "$program_transform_name" = s,x,x,; then program_transform_name= else # Double any \ or $. echo might interpret backslashes. cat <<\EOF_SED > conftestsed s,\\,\\\\,g; s,\$,$$,g EOF_SED program_transform_name="`echo $program_transform_name|sed -f conftestsed`" rm -f conftestsed fi test "$program_prefix" != NONE && program_transform_name="s,^,${program_prefix},; $program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" # sed with no file args requires a program. test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 echo "configure:667: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftestmake <<\EOF all: @echo 'ac_maketemp="${MAKE}"' EOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftestmake fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$ac_t""yes" 1>&6 SET_MAKE= else echo "$ac_t""no" 1>&6 SET_MAKE="MAKE=${MAKE-make}" fi PACKAGE=hexedit VERSION=0.9.7 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } fi cat >> confdefs.h <> confdefs.h <&6 echo "configure:713: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (aclocal --version) < /dev/null > /dev/null 2>&1; then ACLOCAL=aclocal echo "$ac_t""found" 1>&6 else ACLOCAL="$missing_dir/missing aclocal" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 echo "configure:726: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoconf --version) < /dev/null > /dev/null 2>&1; then AUTOCONF=autoconf echo "$ac_t""found" 1>&6 else AUTOCONF="$missing_dir/missing autoconf" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 echo "configure:739: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (automake --version) < /dev/null > /dev/null 2>&1; then AUTOMAKE=automake echo "$ac_t""found" 1>&6 else AUTOMAKE="$missing_dir/missing automake" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 echo "configure:752: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoheader --version) < /dev/null > /dev/null 2>&1; then AUTOHEADER=autoheader echo "$ac_t""found" 1>&6 else AUTOHEADER="$missing_dir/missing autoheader" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 echo "configure:765: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (makeinfo --version) < /dev/null > /dev/null 2>&1; then MAKEINFO=makeinfo echo "$ac_t""found" 1>&6 else MAKEINFO="$missing_dir/missing makeinfo" echo "$ac_t""missing" 1>&6 fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:785: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:815: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_save_ifs" if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# -gt 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:866: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:898: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 909 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:914: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:940: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:945: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:973: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -Wall" fi # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:1020: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' cat >> confdefs.h <<\EOF #define _GNU_SOURCE 1 EOF echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:1079: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1100: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1117: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1134: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 echo "configure:1159: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1172: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "memchr" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "free" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF if { (eval echo configure:1239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_header_stdc=no fi rm -fr conftest* fi fi fi echo "$ac_t""$ac_cv_header_stdc" 1>&6 if test $ac_cv_header_stdc = yes; then cat >> confdefs.h <<\EOF #define STDC_HEADERS 1 EOF fi if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 echo "configure:1264: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext < Autoconf TIOCGETP EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "$ac_pattern" >/dev/null 2>&1; then rm -rf conftest* ac_cv_prog_gcc_traditional=yes else rm -rf conftest* ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < Autoconf TCGETA EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "$ac_pattern" >/dev/null 2>&1; then rm -rf conftest* ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi for ac_hdr in ncurses.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1314: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1324: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done if test "$ac_cv_header_ncurses_h" = "no"; then for ac_hdr in curses.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1355: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1365: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done if test "$ac_cv_header_curses_h" = "no"; then echo "*** Cannot find Curses headers, probably not installed" echo "*** Hexedit will not run without the curses library" fi fi for ac_hdr in fcntl.h getopt.h limits.h sys/ioctl.h unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1401: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1411: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 echo "configure:1442: checking for $ac_hdr that defines DIR" >&5 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> int main() { DIR *dirp = 0; ; return 0; } EOF if { (eval echo configure:1455: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 echo "configure:1480: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -ldir" else echo "$ac_t""no" 1>&6 fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 echo "configure:1521: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -lx" else echo "$ac_t""no" 1>&6 fi fi echo $ac_n "checking for working const""... $ac_c" 1>&6 echo "configure:1563: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; } ; return 0; } EOF if { (eval echo configure:1617: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_c_const=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_c_const" 1>&6 if test $ac_cv_c_const = no; then cat >> confdefs.h <<\EOF #define const EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 echo "configure:1638: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF if { (eval echo configure:1651: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_struct_tm=sys/time.h fi rm -f conftest* fi echo "$ac_t""$ac_cv_struct_tm" 1>&6 if test $ac_cv_struct_tm = sys/time.h; then cat >> confdefs.h <<\EOF #define TM_IN_SYS_TIME 1 EOF fi for ac_func in snprintf isprint do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1674: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done for ac_func in getopt_long do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1729: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1757: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <> confdefs.h <<\EOF #define HAVE_GETOPT_LONG 1 EOF else echo "$ac_t""no" 1>&6 fi done echo $ac_n "checking for TIOCGWINSZ""... $ac_c" 1>&6 echo "configure:1788: checking for TIOCGWINSZ" >&5 cat > conftest.$ac_ext < #ifdef TIOCGWINSZ rogoyski_hexedit_termio #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "rogoyski_hexedit_termio" >/dev/null 2>&1; then rm -rf conftest* hex_termio_h=yes fi rm -f conftest* if test "$hex_termio_h" = "yes"; then cat >> confdefs.h <<\EOF #define HAVE_TERMIO_H 1 EOF echo "$ac_t""yes, found in termio.h" 1>&6 else cat > conftest.$ac_ext < #ifdef TIOCGWINSZ rogoyski_hexedit_termios #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "rogoyski_hexedit_termios" >/dev/null 2>&1; then rm -rf conftest* hex_termios_h=yes fi rm -f conftest* if test "$hex_termios_h" = "yes"; then cat >> confdefs.h <<\EOF #define HAVE_TERMIOS_H 1 EOF echo "$ac_t""yes, found in termios.h" 1>&6 else cat > conftest.$ac_ext < #ifdef TIOCGWINSZ rogoyski_hexedit_sys_termio #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "rogoyski_hexedit_sys_termio" >/dev/null 2>&1; then rm -rf conftest* hex_sys_termio_h=yes fi rm -f conftest* if test "$hex_sys_termio_h" = "yes"; then cat >> confdefs.h <<\EOF #define HAVE_SYS_TERMIO_H 1 EOF echo "$ac_t""yes, found in sys/termio.h" 1>&6 else cat > conftest.$ac_ext < #ifdef TIOCGWINSZ rogoyski_hexedit_sys_termios #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "rogoyski_hexedit_sys_termios" >/dev/null 2>&1; then rm -rf conftest* hex_sys_termios_h=yes fi rm -f conftest* if test "$hex_sys_termios_h" = "yes"; then cat >> confdefs.h <<\EOF #define HAVE_SYS_TERMIOS_H 1 EOF echo "$ac_t""yes, found in sys/termios.h" 1>&6 else echo "$ac_t""no" 1>&6 fi fi fi fi echo $ac_n "checking for newwin in -lncurses""... $ac_c" 1>&6 echo "configure:1899: checking for newwin in -lncurses" >&5 ac_lib_var=`echo ncurses'_'newwin | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lncurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo ncurses | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 echo $ac_n "checking for newwin in -lcurses""... $ac_c" 1>&6 echo "configure:1944: checking for newwin in -lcurses" >&5 ac_lib_var=`echo curses'_'newwin | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lcurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo curses | sed -e 's/^a-zA-Z0-9_/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi fi trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "Makefile docs/Makefile gnu/Makefile src/Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@PACKAGE@%$PACKAGE%g s%@VERSION@%$VERSION%g s%@ACLOCAL@%$ACLOCAL%g s%@AUTOCONF@%$AUTOCONF%g s%@AUTOMAKE@%$AUTOMAKE%g s%@AUTOHEADER@%$AUTOHEADER%g s%@MAKEINFO@%$MAKEINFO%g s%@SET_MAKE@%$SET_MAKE%g s%@CC@%$CC%g s%@CPP@%$CPP%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' ac_dC='\3' ac_dD='%g' # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='\([ ]\)%\1#\2define\3' ac_uC=' ' ac_uD='\4%g' # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_eB='$%\1#\2define\3' ac_eC=' ' ac_eD='%g' if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF fi for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac echo creating $ac_file rm -f conftest.frag conftest.in conftest.out ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` cat $ac_file_inputs > conftest.in EOF # Transform confdefs.h into a sed script conftest.vals that substitutes # the proper values into config.h.in to produce config.h. And first: # Protect against being on the right side of a sed subst in config.status. # Protect against being in an unquoted here document in config.status. rm -f conftest.vals cat > conftest.hdr <<\EOF s/[\\&%]/\\&/g s%[\\$`]%\\&%g s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp s%ac_d%ac_u%gp s%ac_u%ac_e%gp EOF sed -n -f conftest.hdr confdefs.h > conftest.vals rm -f conftest.hdr # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >> conftest.vals <<\EOF s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% EOF # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. rm -f conftest.tail while : do ac_lines=`grep -c . conftest.vals` # grep -c gives empty output for an empty file on some AIX systems. if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi # Write a limited-size here document to conftest.frag. echo ' cat > conftest.frag <> $CONFIG_STATUS sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS echo 'CEOF sed -f conftest.frag conftest.in > conftest.out rm -f conftest.in mv conftest.out conftest.in ' >> $CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail rm -f conftest.vals mv conftest.tail conftest.vals done rm -f conftest.vals cat >> $CONFIG_STATUS <<\EOF rm -f conftest.frag conftest.h echo "/* $ac_file. Generated automatically by configure. */" > conftest.h cat conftest.in >> conftest.h rm -f conftest.in if cmp -s $ac_file conftest.h 2>/dev/null; then echo "$ac_file is unchanged" rm -f conftest.h else # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" fi rm -f $ac_file mv conftest.h $ac_file fi fi; done EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 ncurses-hexedit-0.9.7.orig/configure.in0100644000175000017500000000461606735276134016564 0ustar apocapocdnl configure.in for hexedit dnl April 23rd, 1999 Adam Rogoyski dnl see COPYING for terms of copying under the GNU General Public License AC_INIT(src/main.c) AM_INIT_AUTOMAKE(hexedit, 0.9.7) AM_CONFIG_HEADER(config.h:config.in) AC_PROG_CC if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -Wall" fi AC_PROG_INSTALL AC_DEFINE(_GNU_SOURCE) AC_HEADER_STDC AC_PROG_GCC_TRADITIONAL AC_CHECK_HEADERS(ncurses.h) if test "$ac_cv_header_ncurses_h" = "no"; then AC_CHECK_HEADERS(curses.h) if test "$ac_cv_header_curses_h" = "no"; then echo "*** Cannot find Curses headers, probably not installed" echo "*** Hexedit will not run without the curses library" fi fi AC_CHECK_HEADERS(fcntl.h getopt.h limits.h sys/ioctl.h unistd.h) AC_HEADER_DIRENT AC_C_CONST AC_STRUCT_TM AC_CHECK_FUNCS(snprintf isprint) AC_CHECK_FUNCS(getopt_long,AC_DEFINE(HAVE_GETOPT_LONG)) dnl find TIOCGWINSZ if possible AC_MSG_CHECKING([for TIOCGWINSZ]) AC_EGREP_CPP(rogoyski_hexedit_termio, [ #include #ifdef TIOCGWINSZ rogoyski_hexedit_termio #endif ], hex_termio_h=yes) if test "$hex_termio_h" = "yes"; then AC_DEFINE(HAVE_TERMIO_H) AC_MSG_RESULT([yes, found in termio.h]) else AC_EGREP_CPP(rogoyski_hexedit_termios, [ #include #ifdef TIOCGWINSZ rogoyski_hexedit_termios #endif ], hex_termios_h=yes) if test "$hex_termios_h" = "yes"; then AC_DEFINE(HAVE_TERMIOS_H) AC_MSG_RESULT([yes, found in termios.h]) else AC_EGREP_CPP(rogoyski_hexedit_sys_termio, [ #include #ifdef TIOCGWINSZ rogoyski_hexedit_sys_termio #endif ], hex_sys_termio_h=yes) if test "$hex_sys_termio_h" = "yes"; then AC_DEFINE(HAVE_SYS_TERMIO_H) AC_MSG_RESULT([yes, found in sys/termio.h]) else AC_EGREP_CPP(rogoyski_hexedit_sys_termios, [ #include #ifdef TIOCGWINSZ rogoyski_hexedit_sys_termios #endif ], hex_sys_termios_h=yes) if test "$hex_sys_termios_h" = "yes"; then AC_DEFINE(HAVE_SYS_TERMIOS_H) AC_MSG_RESULT([yes, found in sys/termios.h]) else AC_MSG_RESULT([no]) fi fi fi fi AC_CHECK_LIB(ncurses, newwin, , AC_CHECK_LIB(curses, newwin), , echo "Hexedit requires the curses library" echo "Ncurses is freely available: ftp://ftp.gnu.org/pub/gnu/" exit 1) AC_OUTPUT(Makefile docs/Makefile gnu/Makefile src/Makefile) ncurses-hexedit-0.9.7.orig/install-sh0100744000175000017500000001272006647612501016242 0ustar apocapoc#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 ncurses-hexedit-0.9.7.orig/missing0100744000175000017500000001420206647612501015632 0ustar apocapoc#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997 Free Software Foundation, Inc. # Franc,ois Pinard , 1996. # 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, 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 test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing - GNU libit 0.0" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER([^):]*:\([^)]*\)).*/\1/p' configure.in` if test -z "$files"; then files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^):]*\)).*/\1/p' configure.in` test -z "$files" || files="$files.in" else files=`echo "$files" | sed -e 's/:/ /g'` fi test -z "$files" && files="config.h.in" touch $files ;; automake) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print \ | sed 's/^\(.*\).am$/touch \1.in/' \ | sh ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; makeinfo) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequirements for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 ncurses-hexedit-0.9.7.orig/mkinstalldirs0100744000175000017500000000133406647612501017043 0ustar apocapoc#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.10 1996/05/03 07:37:52 friedman Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" 1>&2 mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here ncurses-hexedit-0.9.7.orig/docs/0040777000175000017500000000000006753210662015175 5ustar apocapocncurses-hexedit-0.9.7.orig/docs/Makefile.in0100644000175000017500000002204006753210662017231 0ustar apocapoc# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : CC = @CC@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ info_TEXINFOS = hexedit.texinfo man_MANS = hexedit.1 EXTRA_DIST = hexedit.1 texinfo.tex mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = TEXI2DVI = texi2dvi INFO_DEPS = hexedit.info DVIS = hexedit.dvi TEXINFOS = hexedit.texinfo man1dir = $(mandir)/man1 MANS = $(man_MANS) NROFF = nroff DIST_COMMON = Makefile.am Makefile.in texinfo.tex DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: .SUFFIXES: .dvi .info .ps .texi .texinfo .txi $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps docs/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status hexedit.info: hexedit.texinfo hexedit.dvi: hexedit.texinfo DVIPS = dvips .texi.info: @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9] cd $(srcdir) \ && $(MAKEINFO) `echo $< | sed 's,.*/,,'` .texi.dvi: TEXINPUTS=.:$$TEXINPUTS \ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $< .texi: @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9] cd $(srcdir) \ && $(MAKEINFO) `echo $< | sed 's,.*/,,'` .texinfo.info: @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9] cd $(srcdir) \ && $(MAKEINFO) `echo $< | sed 's,.*/,,'` .texinfo: @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9] cd $(srcdir) \ && $(MAKEINFO) `echo $< | sed 's,.*/,,'` .texinfo.dvi: TEXINPUTS=.:$$TEXINPUTS \ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $< .txi.info: @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9] cd $(srcdir) \ && $(MAKEINFO) `echo $< | sed 's,.*/,,'` .txi.dvi: TEXINPUTS=.:$$TEXINPUTS \ MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $< .txi: @cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9] cd $(srcdir) \ && $(MAKEINFO) `echo $< | sed 's,.*/,,'` .dvi.ps: $(DVIPS) $< -o $@ install-info-am: $(INFO_DEPS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(infodir) @list='$(INFO_DEPS)'; \ for file in $$list; do \ d=$(srcdir); \ for ifile in `cd $$d && echo $$file $$file-[0-9] $$file-[0-9][0-9]`; do \ if test -f $$d/$$ifile; then \ echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile"; \ $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile; \ else : ; fi; \ done; \ done @$(POST_INSTALL) @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \ list='$(INFO_DEPS)'; \ for file in $$list; do \ echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\ install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;\ done; \ else : ; fi uninstall-info: $(PRE_UNINSTALL) @if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \ ii=yes; \ else ii=; fi; \ list='$(INFO_DEPS)'; \ for file in $$list; do \ test -z "$ii" \ || install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \ done @$(NORMAL_UNINSTALL) list='$(INFO_DEPS)'; \ for file in $$list; do \ (cd $(DESTDIR)$(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \ done dist-info: $(INFO_DEPS) list='$(INFO_DEPS)'; \ for base in $$list; do \ d=$(srcdir); \ for file in `cd $$d && eval echo $$base*`; do \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file; \ done; \ done mostlyclean-aminfo: -rm -f hexedit.aux hexedit.cp hexedit.cps hexedit.dvi hexedit.fn \ hexedit.fns hexedit.ky hexedit.kys hexedit.ps hexedit.log \ hexedit.pg hexedit.toc hexedit.tp hexedit.tps hexedit.vr \ hexedit.vrs hexedit.op hexedit.tr hexedit.cv hexedit.cn clean-aminfo: distclean-aminfo: maintainer-clean-aminfo: cd $(srcdir) && for i in $(INFO_DEPS); do \ rm -f $$i; \ if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \ rm -f $$i-[0-9]*; \ fi; \ done install-man1: $(mkinstalldirs) $(DESTDIR)$(man1dir) @list='$(man1_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.1*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ else file=$$i; fi; \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ done uninstall-man1: @list='$(man1_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.1*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ rm -f $(DESTDIR)$(man1dir)/$$inst; \ done install-man: $(MANS) @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-man1 uninstall-man: @$(NORMAL_UNINSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-man1 tags: TAGS TAGS: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = docs distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info info-am: $(INFO_DEPS) info: info-am dvi-am: $(DVIS) dvi: dvi-am check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am install-exec-am: install-exec: install-exec-am install-data-am: install-info-am install-man install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am uninstall-am: uninstall-info uninstall-man uninstall: uninstall-am all-am: Makefile $(INFO_DEPS) $(MANS) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(infodir) $(DESTDIR)$(mandir)/man1 mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-aminfo mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-aminfo clean-generic mostlyclean-am clean: clean-am distclean-am: distclean-aminfo distclean-generic clean-am distclean: distclean-am maintainer-clean-am: maintainer-clean-aminfo maintainer-clean-generic \ distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am .PHONY: install-info-am uninstall-info mostlyclean-aminfo \ distclean-aminfo clean-aminfo maintainer-clean-aminfo install-man1 \ uninstall-man1 install-man uninstall-man tags distdir info-am info \ dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ install-exec install-data-am install-data install-am install \ uninstall-am uninstall all-redirect all-am all installdirs \ mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ncurses-hexedit-0.9.7.orig/docs/Makefile.am0100644000175000017500000000013106672453371017223 0ustar apocapocinfo_TEXINFOS = hexedit.texinfo man_MANS = hexedit.1 EXTRA_DIST = hexedit.1 texinfo.tex ncurses-hexedit-0.9.7.orig/docs/texinfo.tex0100644000175000017500000054550706672453134017407 0ustar apocapoc% texinfo.tex -- TeX macros to handle Texinfo files. % % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % \def\texinfoversion{1999-01-05}% % % Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98 % Free Software Foundation, Inc. % % This texinfo.tex file 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, or (at % your option) any later version. % % This texinfo.tex file 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 texinfo.tex file; see the file COPYING. If not, write % to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, % Boston, MA 02111-1307, USA. % % In other words, you are welcome to use, share and improve this program. % You are forbidden to forbid anyone else to use, share and improve % what you give them. Help stamp out software-hoarding! % % Please try the latest version of texinfo.tex before submitting bug % reports; you can get the latest version from: % ftp://ftp.gnu.org/pub/gnu/texinfo.tex % /home/gd/gnu/doc/texinfo.tex on the GNU machines. % (and all GNU mirrors, see http://www.gnu.org/order/ftp.html) % ftp://tug.org/tex/texinfo.tex % ftp://ctan.org/macros/texinfo/texinfo.tex % (and all CTAN mirrors, finger ctan@ctan.org for a list). % The texinfo.tex in the texinfo distribution itself could well be out % of date, so if that's what you're using, please check. % % Send bug reports to bug-texinfo@gnu.org. % Please include a precise test case in each bug report, % including a complete document with which we can reproduce the problem. % % To process a Texinfo manual with TeX, it's most reliable to use the % texi2dvi shell script that comes with the distribution. For simple % manuals, however, you can get away with: % tex foo.texi % texindex foo.?? % tex foo.texi % tex foo.texi % dvips foo.dvi -o # or whatever, to process the dvi file. % The extra runs of TeX get the cross-reference information correct. % Sometimes one run after texindex suffices, and sometimes you need more % than two; texi2dvi does it as many times as necessary. \message{Loading texinfo [version \texinfoversion]:} % If in a .fmt file, print the version number % and turn on active characters that we couldn't do earlier because % they might have appeared in the input file name. \everyjob{\message{[Texinfo version \texinfoversion]}% \catcode`+=\active \catcode`\_=\active} % Save some parts of plain tex whose names we will redefine. \let\ptexb=\b \let\ptexbullet=\bullet \let\ptexc=\c \let\ptexcomma=\, \let\ptexdot=\. \let\ptexdots=\dots \let\ptexend=\end \let\ptexequiv=\equiv \let\ptexexclam=\! \let\ptexi=\i \let\ptexlbrace=\{ \let\ptexrbrace=\} \let\ptexstar=\* \let\ptext=\t % We never want plain's outer \+ definition in Texinfo. % For @tex, we can use \tabalign. \let\+ = \relax \message{Basics,} \chardef\other=12 % If this character appears in an error message or help string, it % starts a new line in the output. \newlinechar = `^^J % Set up fixed words for English if not already set. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi \ifx\putwordon\undefined \gdef\putwordon{on}\fi \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi \ifx\putwordShortContents\undefined \gdef\putwordShortContents{Short Contents}\fi \ifx\putwordTableofContents\undefined\gdef\putwordTableofContents{Table of Contents}\fi % Ignore a token. % \def\gobble#1{} \hyphenation{ap-pen-dix} \hyphenation{mini-buf-fer mini-buf-fers} \hyphenation{eshell} \hyphenation{white-space} % Margin to add to right of even pages, to left of odd pages. \newdimen \bindingoffset \newdimen \normaloffset \newdimen\pagewidth \newdimen\pageheight % Sometimes it is convenient to have everything in the transcript file % and nothing on the terminal. We don't just call \tracingall here, % since that produces some useless output on the terminal. % \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% \ifx\eTeXversion\undefined \def\loggingall{\tracingcommands2 \tracingstats2 \tracingpages1 \tracingoutput1 \tracinglostchars1 \tracingmacros2 \tracingparagraphs1 \tracingrestores1 \showboxbreadth\maxdimen\showboxdepth\maxdimen }% \else \def\loggingall{\tracingcommands3 \tracingstats2 \tracingpages1 \tracingoutput1 \tracinglostchars1 \tracingmacros2 \tracingparagraphs1 \tracingrestores1 \tracingscantokens1 \tracingassigns1 \tracingifs1 \tracinggroups1 \tracingnesting2 \showboxbreadth\maxdimen\showboxdepth\maxdimen }% \fi % For @cropmarks command. % Do @cropmarks to get crop marks. % \newif\ifcropmarks \let\cropmarks = \cropmarkstrue % % Dimensions to add cropmarks at corners. % Added by P. A. MacKay, 12 Nov. 1986 % \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines \newdimen\cornerlong \cornerlong=1pc \newdimen\cornerthick \cornerthick=.3pt \newdimen\topandbottommargin \topandbottommargin=.75in % Main output routine. \chardef\PAGE = 255 \output = {\onepageout{\pagecontents\PAGE}} \newbox\headlinebox \newbox\footlinebox % \onepageout takes a vbox as an argument. Note that \pagecontents % does insertions, but you have to call it yourself. \def\onepageout#1{% \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi % \ifodd\pageno \advance\hoffset by \bindingoffset \else \advance\hoffset by -\bindingoffset\fi % % Do this outside of the \shipout so @code etc. will be expanded in % the headline as they should be, not taken literally (outputting ''code). \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% % {% % Have to do this stuff outside the \shipout because we want it to % take effect in \write's, yet the group defined by the \vbox ends % before the \shipout runs. % \escapechar = `\\ % use backslash in output files. \indexdummies % don't expand commands in the output. \normalturnoffactive % \ in index entries must not stay \, e.g., if % the page break happens to be in the middle of an example. \shipout\vbox{% \ifcropmarks \vbox to \outervsize\bgroup \hsize = \outerhsize \vskip-\topandbottommargin \vtop to0pt{% \line{\ewtop\hfil\ewtop}% \nointerlineskip \line{% \vbox{\moveleft\cornerthick\nstop}% \hfill \vbox{\moveright\cornerthick\nstop}% }% \vss}% \vskip\topandbottommargin \line\bgroup \hfil % center the page within the outer (page) hsize. \ifodd\pageno\hskip\bindingoffset\fi \vbox\bgroup \fi % \unvbox\headlinebox \pagebody{#1}% \ifdim\ht\footlinebox > 0pt % Only leave this space if the footline is nonempty. % (We lessened \vsize for it in \oddfootingxxx.) % The \baselineskip=24pt in plain's \makefootline has no effect. \vskip 2\baselineskip \unvbox\footlinebox \fi % \ifcropmarks \egroup % end of \vbox\bgroup \hfil\egroup % end of (centering) \line\bgroup \vskip\topandbottommargin plus1fill minus1fill \boxmaxdepth = \cornerthick \vbox to0pt{\vss \line{% \vbox{\moveleft\cornerthick\nsbot}% \hfill \vbox{\moveright\cornerthick\nsbot}% }% \nointerlineskip \line{\ewbot\hfil\ewbot}% }% \egroup % \vbox from first cropmarks clause \fi }% end of \shipout\vbox }% end of group with \turnoffactive \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi } \newinsert\margin \dimen\margin=\maxdimen \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} {\catcode`\@ =11 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi % marginal hacks, juha@viisa.uucp (Juha Takala) \ifvoid\margin\else % marginal info is present \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi \dimen@=\dp#1 \unvbox#1 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi \ifr@ggedbottom \kern-\dimen@ \vfil \fi} } % Here are the rules for the cropmarks. Note that they are % offset so that the space between them is truly \outerhsize or \outervsize % (P. A. MacKay, 12 November, 1986) % \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} \def\nstop{\vbox {\hrule height\cornerthick depth\cornerlong width\cornerthick}} \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} \def\nsbot{\vbox {\hrule height\cornerlong depth\cornerthick width\cornerthick}} % Parse an argument, then pass it to #1. The argument is the rest of % the input line (except we remove a trailing comment). #1 should be a % macro which expects an ordinary undelimited TeX argument. % \def\parsearg#1{% \let\next = #1% \begingroup \obeylines \futurelet\temp\parseargx } % If the next token is an obeyed space (from an @example environment or % the like), remove it and recurse. Otherwise, we're done. \def\parseargx{% % \obeyedspace is defined far below, after the definition of \sepspaces. \ifx\obeyedspace\temp \expandafter\parseargdiscardspace \else \expandafter\parseargline \fi } % Remove a single space (as the delimiter token to the macro call). {\obeyspaces % \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} {\obeylines % \gdef\parseargline#1^^M{% \endgroup % End of the group started in \parsearg. % % First remove any @c comment, then any @comment. % Result of each macro is put in \toks0. \argremovec #1\c\relax % \expandafter\argremovecomment \the\toks0 \comment\relax % % % Call the caller's macro, saved as \next in \parsearg. \expandafter\next\expandafter{\the\toks0}% }% } % Since all \c{,omment} does is throw away the argument, we can let TeX % do that for us. The \relax here is matched by the \relax in the call % in \parseargline; it could be more or less anything, its purpose is % just to delimit the argument to the \c. \def\argremovec#1\c#2\relax{\toks0 = {#1}} \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} % \argremovec{,omment} might leave us with trailing spaces, though; e.g., % @end itemize @c foo % will have two active spaces as part of the argument with the % `itemize'. Here we remove all active spaces from #1, and assign the % result to \toks0. % % This loses if there are any *other* active characters besides spaces % in the argument -- _ ^ +, for example -- since they get expanded. % Fortunately, Texinfo does not define any such commands. (If it ever % does, the catcode of the characters in questionwill have to be changed % here.) But this means we cannot call \removeactivespaces as part of % \argremovec{,omment}, since @c uses \parsearg, and thus the argument % that \parsearg gets might well have any character at all in it. % \def\removeactivespaces#1{% \begingroup \ignoreactivespaces \edef\temp{#1}% \global\toks0 = \expandafter{\temp}% \endgroup } % Change the active space to expand to nothing. % \begingroup \obeyspaces \gdef\ignoreactivespaces{\obeyspaces\let =\empty} \endgroup \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} %% These are used to keep @begin/@end levels from running away %% Call \inENV within environments (after a \begingroup) \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} \def\ENVcheck{% \ifENV\errmessage{Still within an environment; press RETURN to continue} \endgroup\fi} % This is not perfect, but it should reduce lossage % @begin foo is the same as @foo, for now. \newhelp\EMsimple{Press RETURN to continue.} \outer\def\begin{\parsearg\beginxxx} \def\beginxxx #1{% \expandafter\ifx\csname #1\endcsname\relax {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else \csname #1\endcsname\fi} % @end foo executes the definition of \Efoo. % \def\end{\parsearg\endxxx} \def\endxxx #1{% \removeactivespaces{#1}% \edef\endthing{\the\toks0}% % \expandafter\ifx\csname E\endthing\endcsname\relax \expandafter\ifx\csname \endthing\endcsname\relax % There's no \foo, i.e., no ``environment'' foo. \errhelp = \EMsimple \errmessage{Undefined command `@end \endthing'}% \else \unmatchedenderror\endthing \fi \else % Everything's ok; the right environment has been started. \csname E\endthing\endcsname \fi } % There is an environment #1, but it hasn't been started. Give an error. % \def\unmatchedenderror#1{% \errhelp = \EMsimple \errmessage{This `@end #1' doesn't have a matching `@#1'}% } % Define the control sequence \E#1 to give an unmatched @end error. % \def\defineunmatchedend#1{% \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% } % Single-spacing is done by various environments (specifically, in % \nonfillstart and \quotations). \newskip\singlespaceskip \singlespaceskip = 12.5pt \def\singlespace{% % Why was this kern here? It messes up equalizing space above and below % environments. --karl, 6may93 %{\advance \baselineskip by -\singlespaceskip %\kern \baselineskip}% \setleading \singlespaceskip } %% Simple single-character @ commands % @@ prints an @ % Kludge this until the fonts are right (grr). \def\@{{\tt\char64}} % This is turned off because it was never documented % and you can use @w{...} around a quote to suppress ligatures. %% Define @` and @' to be the same as ` and ' %% but suppressing ligatures. %\def\`{{`}} %\def\'{{'}} % Used to generate quoted braces. \def\mylbrace {{\tt\char123}} \def\myrbrace {{\tt\char125}} \let\{=\mylbrace \let\}=\myrbrace \begingroup % Definitions to produce actual \{ & \} command in an index. \catcode`\{ = 12 \catcode`\} = 12 \catcode`\[ = 1 \catcode`\] = 2 \catcode`\@ = 0 \catcode`\\ = 12 @gdef@lbracecmd[\{]% @gdef@rbracecmd[\}]% @endgroup % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent % Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H. \let\, = \c \let\dotaccent = \. \def\ringaccent#1{{\accent23 #1}} \let\tieaccent = \t \let\ubaraccent = \b \let\udotaccent = \d % Other special characters: @questiondown @exclamdown % Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss. \def\questiondown{?`} \def\exclamdown{!`} % Dotless i and dotless j, used for accents. \def\imacro{i} \def\jmacro{j} \def\dotless#1{% \def\temp{#1}% \ifx\temp\imacro \ptexi \else\ifx\temp\jmacro \j \else \errmessage{@dotless can be used only with i or j}% \fi\fi } % Be sure we're in horizontal mode when doing a tie, since we make space % equivalent to this in @example-like environments. Otherwise, a space % at the beginning of a line will start with \penalty -- and % since \penalty is valid in vertical mode, we'd end up putting the % penalty on the vertical list instead of in the new paragraph. {\catcode`@ = 11 % Avoid using \@M directly, because that causes trouble % if the definition is written into an index file. \global\let\tiepenalty = \@M \gdef\tie{\leavevmode\penalty\tiepenalty\ } } % @: forces normal size whitespace following. \def\:{\spacefactor=1000 } % @* forces a line break. \def\*{\hfil\break\hbox{}\ignorespaces} % @. is an end-of-sentence period. \def\.{.\spacefactor=3000 } % @! is an end-of-sentence bang. \def\!{!\spacefactor=3000 } % @? is an end-of-sentence query. \def\?{?\spacefactor=3000 } % @w prevents a word break. Without the \leavevmode, @w at the % beginning of a paragraph, when TeX is still in vertical mode, would % produce a whole line of output instead of starting the paragraph. \def\w#1{\leavevmode\hbox{#1}} % @group ... @end group forces ... to be all on one page, by enclosing % it in a TeX vbox. We use \vtop instead of \vbox to construct the box % to keep its height that of a normal line. According to the rules for % \topskip (p.114 of the TeXbook), the glue inserted is % max (\topskip - \ht (first item), 0). If that height is large, % therefore, no glue is inserted, and the space between the headline and % the text is small, which looks bad. % \def\group{\begingroup \ifnum\catcode13=\active \else \errhelp = \groupinvalidhelp \errmessage{@group invalid in context where filling is enabled}% \fi % % The \vtop we start below produces a box with normal height and large % depth; thus, TeX puts \baselineskip glue before it, and (when the % next line of text is done) \lineskip glue after it. (See p.82 of % the TeXbook.) Thus, space below is not quite equal to space % above. But it's pretty close. \def\Egroup{% \egroup % End the \vtop. \endgroup % End the \group. }% % \vtop\bgroup % We have to put a strut on the last line in case the @group is in % the midst of an example, rather than completely enclosing it. % Otherwise, the interline space between the last line of the group % and the first line afterwards is too small. But we can't put the % strut in \Egroup, since there it would be on a line by itself. % Hence this just inserts a strut at the beginning of each line. \everypar = {\strut}% % % Since we have a strut on every line, we don't need any of TeX's % normal interline spacing. \offinterlineskip % % OK, but now we have to do something about blank % lines in the input in @example-like environments, which normally % just turn into \lisppar, which will insert no space now that we've % turned off the interline space. Simplest is to make them be an % empty paragraph. \ifx\par\lisppar \edef\par{\leavevmode \par}% % % Reset ^^M's definition to new definition of \par. \obeylines \fi % % Do @comment since we are called inside an environment such as % @example, where each end-of-line in the input causes an % end-of-line in the output. We don't want the end-of-line after % the `@group' to put extra space in the output. Since @group % should appear on a line by itself (according to the Texinfo % manual), we don't worry about eating any user text. \comment } % % TeX puts in an \escapechar (i.e., `@') at the beginning of the help % message, so this ends up printing `@group can only ...'. % \newhelp\groupinvalidhelp{% group can only be used in environments such as @example,^^J% where each line of input produces a line of output.} % @need space-in-mils % forces a page break if there is not space-in-mils remaining. \newdimen\mil \mil=0.001in \def\need{\parsearg\needx} % Old definition--didn't work. %\def\needx #1{\par % %% This method tries to make TeX break the page naturally %% if the depth of the box does not fit. %{\baselineskip=0pt% %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak %\prevdepth=-1000pt %}} \def\needx#1{% % Go into vertical mode, so we don't make a big box in the middle of a % paragraph. \par % % Don't add any leading before our big empty box, but allow a page % break, since the best break might be right here. \allowbreak \nointerlineskip \vtop to #1\mil{\vfil}% % % TeX does not even consider page breaks if a penalty added to the % main vertical list is 10000 or more. But in order to see if the % empty box we just added fits on the page, we must make it consider % page breaks. On the other hand, we don't want to actually break the % page after the empty box. So we use a penalty of 9999. % % There is an extremely small chance that TeX will actually break the % page at this \penalty, if there are no other feasible breakpoints in % sight. (If the user is using lots of big @group commands, which % almost-but-not-quite fill up a page, TeX will have a hard time doing % good page breaking, for example.) However, I could not construct an % example where a page broke at this \penalty; if it happens in a real % document, then we can reconsider our strategy. \penalty9999 % % Back up by the size of the box, whether we did a page break or not. \kern -#1\mil % % Do not allow a page break right after this kern. \nobreak } % @br forces paragraph break \let\br = \par % @dots{} output an ellipsis using the current font. % We do .5em per period so that it has the same spacing in a typewriter % font as three actual period characters. % \def\dots{% \leavevmode \hbox to 1.5em{% \hskip 0pt plus 0.25fil minus 0.25fil .\hss.\hss.% \hskip 0pt plus 0.5fil minus 0.5fil }% } % @enddots{} is an end-of-sentence ellipsis. % \def\enddots{% \leavevmode \hbox to 2em{% \hskip 0pt plus 0.25fil minus 0.25fil .\hss.\hss.\hss.% \hskip 0pt plus 0.5fil minus 0.5fil }% \spacefactor=3000 } % @page forces the start of a new page % \def\page{\par\vfill\supereject} % @exdent text.... % outputs text on separate line in roman font, starting at standard page margin % This records the amount of indent in the innermost environment. % That's how much \exdent should take out. \newskip\exdentamount % This defn is used inside fill environments such as @defun. \def\exdent{\parsearg\exdentyyy} \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} % This defn is used inside nofill environments such as @example. \def\nofillexdent{\parsearg\nofillexdentyyy} \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount \leftline{\hskip\leftskip{\rm#1}}}} % @inmargin{TEXT} puts TEXT in the margin next to the current paragraph. \def\inmargin#1{% \strut\vadjust{\nobreak\kern-\strutdepth \vtop to \strutdepth{\baselineskip\strutdepth\vss \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}} \newskip\inmarginspacing \inmarginspacing=1cm \def\strutdepth{\dp\strutbox} %\hbox{{\rm#1}}\hfil\break}} % @include file insert text of that file as input. % Allow normal characters that we make active in the argument (a file name). \def\include{\begingroup \catcode`\\=12 \catcode`~=12 \catcode`^=12 \catcode`_=12 \catcode`|=12 \catcode`<=12 \catcode`>=12 \catcode`+=12 \parsearg\includezzz} % Restore active chars for included file. \def\includezzz#1{\endgroup\begingroup % Read the included file in a group so nested @include's work. \def\thisfile{#1}% \input\thisfile \endgroup} \def\thisfile{} % @center line outputs that line, centered \def\center{\parsearg\centerzzz} \def\centerzzz #1{{\advance\hsize by -\leftskip \advance\hsize by -\rightskip \centerline{#1}}} % @sp n outputs n lines of vertical space \def\sp{\parsearg\spxxx} \def\spxxx #1{\vskip #1\baselineskip} % @comment ...line which is ignored... % @c is the same as @comment % @ignore ... @end ignore is another way to write a comment \def\comment{\begingroup \catcode`\^^M=\other% \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% \commentxxx} {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} \let\c=\comment % @paragraphindent is defined for the Info formatting commands only. \let\paragraphindent=\comment % Prevent errors for section commands. % Used in @ignore and in failing conditionals. \def\ignoresections{% \let\chapter=\relax \let\unnumbered=\relax \let\top=\relax \let\unnumberedsec=\relax \let\unnumberedsection=\relax \let\unnumberedsubsec=\relax \let\unnumberedsubsection=\relax \let\unnumberedsubsubsec=\relax \let\unnumberedsubsubsection=\relax \let\section=\relax \let\subsec=\relax \let\subsubsec=\relax \let\subsection=\relax \let\subsubsection=\relax \let\appendix=\relax \let\appendixsec=\relax \let\appendixsection=\relax \let\appendixsubsec=\relax \let\appendixsubsection=\relax \let\appendixsubsubsec=\relax \let\appendixsubsubsection=\relax \let\contents=\relax \let\smallbook=\relax \let\titlepage=\relax } % Used in nested conditionals, where we have to parse the Texinfo source % and so want to turn off most commands, in case they are used % incorrectly. % \def\ignoremorecommands{% \let\defcodeindex = \relax \let\defcv = \relax \let\deffn = \relax \let\deffnx = \relax \let\defindex = \relax \let\defivar = \relax \let\defmac = \relax \let\defmethod = \relax \let\defop = \relax \let\defopt = \relax \let\defspec = \relax \let\deftp = \relax \let\deftypefn = \relax \let\deftypefun = \relax \let\deftypevar = \relax \let\deftypevr = \relax \let\defun = \relax \let\defvar = \relax \let\defvr = \relax \let\ref = \relax \let\xref = \relax \let\printindex = \relax \let\pxref = \relax \let\settitle = \relax \let\setchapternewpage = \relax \let\setchapterstyle = \relax \let\everyheading = \relax \let\evenheading = \relax \let\oddheading = \relax \let\everyfooting = \relax \let\evenfooting = \relax \let\oddfooting = \relax \let\headings = \relax \let\include = \relax \let\lowersections = \relax \let\down = \relax \let\raisesections = \relax \let\up = \relax \let\set = \relax \let\clear = \relax \let\item = \relax } % Ignore @ignore ... @end ignore. % \def\ignore{\doignore{ignore}} % Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text. % \def\ifinfo{\doignore{ifinfo}} \def\ifhtml{\doignore{ifhtml}} \def\ifnottex{\doignore{ifnottex}} \def\html{\doignore{html}} \def\menu{\doignore{menu}} \def\direntry{\doignore{direntry}} % @dircategory CATEGORY -- specify a category of the dir file % which this file should belong to. Ignore this in TeX. \let\dircategory = \comment % Ignore text until a line `@end #1'. % \def\doignore#1{\begingroup % Don't complain about control sequences we have declared \outer. \ignoresections % % Define a command to swallow text until we reach `@end #1'. % This @ is a catcode 12 token (that is the normal catcode of @ in % this texinfo.tex file). We change the catcode of @ below to match. \long\def\doignoretext##1@end #1{\enddoignore}% % % Make sure that spaces turn into tokens that match what \doignoretext wants. \catcode32 = 10 % % Ignore braces, too, so mismatched braces don't cause trouble. \catcode`\{ = 9 \catcode`\} = 9 % % We must not have @c interpreted as a control sequence. \catcode`\@ = 12 % % Make the letter c a comment character so that the rest of the line % will be ignored. This way, the document can have (for example) % @c @end ifinfo % and the @end ifinfo will be properly ignored. % (We've just changed @ to catcode 12.) \catcode`\c = 14 % % And now expand that command. \doignoretext } % What we do to finish off ignored text. % \def\enddoignore{\endgroup\ignorespaces}% \newif\ifwarnedobs\warnedobsfalse \def\obstexwarn{% \ifwarnedobs\relax\else % We need to warn folks that they may have trouble with TeX 3.0. % This uses \immediate\write16 rather than \message to get newlines. \immediate\write16{} \immediate\write16{***WARNING*** for users of Unix TeX 3.0!} \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} \immediate\write16{If you are running another version of TeX, relax.} \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} \immediate\write16{ Then upgrade your TeX installation if you can.} \immediate\write16{ (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)} \immediate\write16{If you are stuck with version 3.0, run the} \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} \immediate\write16{ to use a workaround.} \immediate\write16{} \global\warnedobstrue \fi } % **In TeX 3.0, setting text in \nullfont hangs tex. For a % workaround (which requires the file ``dummy.tfm'' to be installed), % uncomment the following line: %%%%%\font\nullfont=dummy\let\obstexwarn=\relax % Ignore text, except that we keep track of conditional commands for % purposes of nesting, up to an `@end #1' command. % \def\nestedignore#1{% \obstexwarn % We must actually expand the ignored text to look for the @end % command, so that nested ignore constructs work. Thus, we put the % text into a \vbox and then do nothing with the result. To minimize % the change of memory overflow, we follow the approach outlined on % page 401 of the TeXbook: make the current font be a dummy font. % \setbox0 = \vbox\bgroup % Don't complain about control sequences we have declared \outer. \ignoresections % % Define `@end #1' to end the box, which will in turn undefine the % @end command again. \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% % % We are going to be parsing Texinfo commands. Most cause no % trouble when they are used incorrectly, but some commands do % complicated argument parsing or otherwise get confused, so we % undefine them. % % We can't do anything about stray @-signs, unfortunately; % they'll produce `undefined control sequence' errors. \ignoremorecommands % % Set the current font to be \nullfont, a TeX primitive, and define % all the font commands to also use \nullfont. We don't use % dummy.tfm, as suggested in the TeXbook, because not all sites % might have that installed. Therefore, math mode will still % produce output, but that should be an extremely small amount of % stuff compared to the main input. % \nullfont \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont \let\tensf = \nullfont % Similarly for index fonts (mostly for their use in % smallexample) \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont \let\indsf = \nullfont % % Don't complain when characters are missing from the fonts. \tracinglostchars = 0 % % Don't bother to do space factor calculations. \frenchspacing % % Don't report underfull hboxes. \hbadness = 10000 % % Do minimal line-breaking. \pretolerance = 10000 % % Do not execute instructions in @tex \def\tex{\doignore{tex}}% % Do not execute macro definitions. % `c' is a comment character, so the word `macro' will get cut off. \def\macro{\doignore{ma}}% } % @set VAR sets the variable VAR to an empty value. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. % % Since we want to separate VAR from REST-OF-LINE (which might be % empty), we can't just use \parsearg; we have to insert a space of our % own to delimit the rest of the line, and then take it out again if we % didn't need it. Make sure the catcode of space is correct to avoid % losing inside @example, for instance. % \def\set{\begingroup\catcode` =10 \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR. \parsearg\setxxx} \def\setxxx#1{\setyyy#1 \endsetyyy} \def\setyyy#1 #2\endsetyyy{% \def\temp{#2}% \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. \fi \endgroup } % Can't use \xdef to pre-expand #2 and save some time, since \temp or % \next or other control sequences that we've defined might get us into % an infinite loop. Consider `@set foo @cite{bar}'. \def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}} % @clear VAR clears (i.e., unsets) the variable VAR. % \def\clear{\parsearg\clearxxx} \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} % @value{foo} gets the text saved in variable foo. % { \catcode`\_ = \active % % We might end up with active _ or - characters in the argument if % we're called from @code, as @code{@value{foo-bar_}}. So \let any % such active characters to their normal equivalents. \gdef\value{\begingroup \catcode`\-=12 \catcode`\_=12 \indexbreaks \let_\normalunderscore \valuexxx} } \def\valuexxx#1{\expandablevalue{#1}\endgroup} % We have this subroutine so that we can handle at least some @value's % properly in indexes (we \let\value to this in \indexdummies). Ones % whose names contain - or _ still won't work, but we can't do anything % about that. The command has to be fully expandable, since the result % winds up in the index file. This means that if the variable's value % contains other Texinfo commands, it's almost certain it will fail % (although perhaps we could fix that with sufficient work to do a % one-level expansion on the result, instead of complete). % \def\expandablevalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax {[No value for ``#1'']}% \else \csname SET#1\endcsname \fi } % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined % with @set. % \def\ifset{\parsearg\ifsetxxx} \def\ifsetxxx #1{% \expandafter\ifx\csname SET#1\endcsname\relax \expandafter\ifsetfail \else \expandafter\ifsetsucceed \fi } \def\ifsetsucceed{\conditionalsucceed{ifset}} \def\ifsetfail{\nestedignore{ifset}} \defineunmatchedend{ifset} % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been % defined with @set, or has been undefined with @clear. % \def\ifclear{\parsearg\ifclearxxx} \def\ifclearxxx #1{% \expandafter\ifx\csname SET#1\endcsname\relax \expandafter\ifclearsucceed \else \expandafter\ifclearfail \fi } \def\ifclearsucceed{\conditionalsucceed{ifclear}} \def\ifclearfail{\nestedignore{ifclear}} \defineunmatchedend{ifclear} % @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text % following, through the first @end iftex (etc.). Make `@end iftex' % (etc.) valid only after an @iftex. % \def\iftex{\conditionalsucceed{iftex}} \def\ifnothtml{\conditionalsucceed{ifnothtml}} \def\ifnotinfo{\conditionalsucceed{ifnotinfo}} \defineunmatchedend{iftex} \defineunmatchedend{ifnothtml} \defineunmatchedend{ifnotinfo} % We can't just want to start a group at @iftex (for example) and end it % at @end iftex, since then @set commands inside the conditional have no % effect (they'd get reverted at the end of the group). So we must % define \Eiftex to redefine itself to be its previous value. (We can't % just define it to fail again with an ``unmatched end'' error, since % the @ifset might be nested.) % \def\conditionalsucceed#1{% \edef\temp{% % Remember the current value of \E#1. \let\nece{prevE#1} = \nece{E#1}% % % At the `@end #1', redefine \E#1 to be its previous value. \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% }% \temp } % We need to expand lots of \csname's, but we don't want to expand the % control sequences after we've constructed them. % \def\nece#1{\expandafter\noexpand\csname#1\endcsname} % @asis just yields its argument. Used with @table, for example. % \def\asis#1{#1} % @math means output in math mode. % We don't use $'s directly in the definition of \math because control % sequences like \math are expanded when the toc file is written. Then, % we read the toc file back, the $'s will be normal characters (as they % should be, according to the definition of Texinfo). So we must use a % control sequence to switch into and out of math mode. % % This isn't quite enough for @math to work properly in indices, but it % seems unlikely it will ever be needed there. % \let\implicitmath = $ \def\math#1{\implicitmath #1\implicitmath} % @bullet and @minus need the same treatment as @math, just above. \def\bullet{\implicitmath\ptexbullet\implicitmath} \def\minus{\implicitmath-\implicitmath} % @refill is a no-op. \let\refill=\relax % If working on a large document in chapters, it is convenient to % be able to disable indexing, cross-referencing, and contents, for test runs. % This is done with @novalidate (before @setfilename). % \newif\iflinks \linkstrue % by default we want the aux files. \let\novalidate = \linksfalse % @setfilename is done at the beginning of every texinfo file. % So open here the files we need to have open while reading the input. % This makes it possible to make a .fmt file for texinfo. \def\setfilename{% \iflinks \readauxfile \fi % \openindices needs to do some work in any case. \openindices \fixbackslash % Turn off hack to swallow `\input texinfo'. \global\let\setfilename=\comment % Ignore extra @setfilename cmds. % % If texinfo.cnf is present on the system, read it. % Useful for site-wide @afourpaper, etc. % Just to be on the safe side, close the input stream before the \input. \openin 1 texinfo.cnf \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi \closein1 \temp % \comment % Ignore the actual filename. } % Called from \setfilename. % \def\openindices{% \newindex{cp}% \newcodeindex{fn}% \newcodeindex{vr}% \newcodeindex{tp}% \newcodeindex{ky}% \newcodeindex{pg}% } % @bye. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} \message{fonts,} % Font-change commands. % Texinfo sort of supports the sans serif font style, which plain TeX does not. % So we set up a \sf analogous to plain's \rm, etc. \newfam\sffam \def\sf{\fam=\sffam \tensf} \let\li = \sf % Sometimes we call it \li, not \sf. % We don't need math for this one. \def\ttsl{\tenttsl} % Use Computer Modern fonts at \magstephalf (11pt). \newcount\mainmagstep \mainmagstep=\magstephalf % Set the font macro #1 to the font named #2, adding on the % specified font prefix (normally `cm'). % #3 is the font's design size, #4 is a scale factor \def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4} % Use cm as the default font prefix. % To specify the font prefix, you must define \fontprefix % before you read in texinfo.tex. \ifx\fontprefix\undefined \def\fontprefix{cm} \fi % Support font families that don't use the same naming scheme as CM. \def\rmshape{r} \def\rmbshape{bx} %where the normal face is bold \def\bfshape{b} \def\bxshape{bx} \def\ttshape{tt} \def\ttbshape{tt} \def\ttslshape{sltt} \def\itshape{ti} \def\itbshape{bxti} \def\slshape{sl} \def\slbshape{bxsl} \def\sfshape{ss} \def\sfbshape{ss} \def\scshape{csc} \def\scbshape{csc} \ifx\bigger\relax \let\mainmagstep=\magstep1 \setfont\textrm\rmshape{12}{1000} \setfont\texttt\ttshape{12}{1000} \else \setfont\textrm\rmshape{10}{\mainmagstep} \setfont\texttt\ttshape{10}{\mainmagstep} \fi % Instead of cmb10, you many want to use cmbx10. % cmbx10 is a prettier font on its own, but cmb10 % looks better when embedded in a line with cmr10. \setfont\textbf\bfshape{10}{\mainmagstep} \setfont\textit\itshape{10}{\mainmagstep} \setfont\textsl\slshape{10}{\mainmagstep} \setfont\textsf\sfshape{10}{\mainmagstep} \setfont\textsc\scshape{10}{\mainmagstep} \setfont\textttsl\ttslshape{10}{\mainmagstep} \font\texti=cmmi10 scaled \mainmagstep \font\textsy=cmsy10 scaled \mainmagstep % A few fonts for @defun, etc. \setfont\defbf\bxshape{10}{\magstep1} %was 1314 \setfont\deftt\ttshape{10}{\magstep1} \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} % Fonts for indices and small examples (9pt). % We actually use the slanted font rather than the italic, % because texinfo normally uses the slanted fonts for that. % Do not make many font distinctions in general in the index, since they % aren't very useful. \setfont\ninett\ttshape{9}{1000} \setfont\ninettsl\ttslshape{10}{900} \setfont\indrm\rmshape{9}{1000} \setfont\indit\itshape{9}{1000} \setfont\indsl\slshape{9}{1000} \let\indtt=\ninett \let\indttsl=\ninettsl \let\indsf=\indrm \let\indbf=\indrm \setfont\indsc\scshape{10}{900} \font\indi=cmmi9 \font\indsy=cmsy9 % Fonts for title page: \setfont\titlerm\rmbshape{12}{\magstep3} \setfont\titleit\itbshape{10}{\magstep4} \setfont\titlesl\slbshape{10}{\magstep4} \setfont\titlett\ttbshape{12}{\magstep3} \setfont\titlettsl\ttslshape{10}{\magstep4} \setfont\titlesf\sfbshape{17}{\magstep1} \let\titlebf=\titlerm \setfont\titlesc\scbshape{10}{\magstep4} \font\titlei=cmmi12 scaled \magstep3 \font\titlesy=cmsy10 scaled \magstep4 \def\authorrm{\secrm} % Chapter (and unnumbered) fonts (17.28pt). \setfont\chaprm\rmbshape{12}{\magstep2} \setfont\chapit\itbshape{10}{\magstep3} \setfont\chapsl\slbshape{10}{\magstep3} \setfont\chaptt\ttbshape{12}{\magstep2} \setfont\chapttsl\ttslshape{10}{\magstep3} \setfont\chapsf\sfbshape{17}{1000} \let\chapbf=\chaprm \setfont\chapsc\scbshape{10}{\magstep3} \font\chapi=cmmi12 scaled \magstep2 \font\chapsy=cmsy10 scaled \magstep3 % Section fonts (14.4pt). \setfont\secrm\rmbshape{12}{\magstep1} \setfont\secit\itbshape{10}{\magstep2} \setfont\secsl\slbshape{10}{\magstep2} \setfont\sectt\ttbshape{12}{\magstep1} \setfont\secttsl\ttslshape{10}{\magstep2} \setfont\secsf\sfbshape{12}{\magstep1} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep2} \font\seci=cmmi12 scaled \magstep1 \font\secsy=cmsy10 scaled \magstep2 % \setfont\ssecrm\bxshape{10}{\magstep1} % This size an font looked bad. % \setfont\ssecit\itshape{10}{\magstep1} % The letters were too crowded. % \setfont\ssecsl\slshape{10}{\magstep1} % \setfont\ssectt\ttshape{10}{\magstep1} % \setfont\ssecsf\sfshape{10}{\magstep1} %\setfont\ssecrm\bfshape{10}{1315} % Note the use of cmb rather than cmbx. %\setfont\ssecit\itshape{10}{1315} % Also, the size is a little larger than %\setfont\ssecsl\slshape{10}{1315} % being scaled magstep1. %\setfont\ssectt\ttshape{10}{1315} %\setfont\ssecsf\sfshape{10}{1315} %\let\ssecbf=\ssecrm % Subsection fonts (13.15pt). \setfont\ssecrm\rmbshape{12}{\magstephalf} \setfont\ssecit\itbshape{10}{1315} \setfont\ssecsl\slbshape{10}{1315} \setfont\ssectt\ttbshape{12}{\magstephalf} \setfont\ssecttsl\ttslshape{10}{1315} \setfont\ssecsf\sfbshape{12}{\magstephalf} \let\ssecbf\ssecrm \setfont\ssecsc\scbshape{10}{\magstep1} \font\sseci=cmmi12 scaled \magstephalf \font\ssecsy=cmsy10 scaled 1315 % The smallcaps and symbol fonts should actually be scaled \magstep1.5, % but that is not a standard magnification. % In order for the font changes to affect most math symbols and letters, % we have to define the \textfont of the standard families. Since % texinfo doesn't allow for producing subscripts and superscripts, we % don't bother to reset \scriptfont and \scriptscriptfont (which would % also require loading a lot more fonts). % \def\resetmathfonts{% \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf \textfont\ttfam = \tentt \textfont\sffam = \tensf } % The font-changing commands redefine the meanings of \tenSTYLE, instead % of just \STYLE. We do this so that font changes will continue to work % in math mode, where it is the current \fam that is relevant in most % cases, not the current font. Plain TeX does \def\bf{\fam=\bffam % \tenbf}, for example. By redefining \tenbf, we obviate the need to % redefine \bf itself. \def\textfonts{% \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl \resetmathfonts} \def\titlefonts{% \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy \let\tenttsl=\titlettsl \resetmathfonts \setleading{25pt}} \def\titlefont#1{{\titlefonts\rm #1}} \def\chapfonts{% \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl \resetmathfonts \setleading{19pt}} \def\secfonts{% \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl \resetmathfonts \setleading{16pt}} \def\subsecfonts{% \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl \resetmathfonts \setleading{15pt}} \let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf? \def\indexfonts{% \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \let\tenttsl=\indttsl \resetmathfonts \setleading{12pt}} % Set up the default fonts, so we can use them for creating boxes. % \textfonts % Define these so they can be easily changed for other fonts. \def\angleleft{$\langle$} \def\angleright{$\rangle$} % Count depth in font-changes, for error checks \newcount\fontdepth \fontdepth=0 % Fonts for short table of contents. \setfont\shortcontrm\rmshape{12}{1000} \setfont\shortcontbf\bxshape{12}{1000} \setfont\shortcontsl\slshape{12}{1000} %% Add scribe-like font environments, plus @l for inline lisp (usually sans %% serif) and @ii for TeX italic % \smartitalic{ARG} outputs arg in italics, followed by an italic correction % unless the following character is such as not to need one. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} \def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx} \def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx} \let\i=\smartitalic \let\var=\smartslanted \let\dfn=\smartslanted \let\emph=\smartitalic \let\cite=\smartslanted \def\b#1{{\bf #1}} \let\strong=\b % We can't just use \exhyphenpenalty, because that only has effect at % the end of a paragraph. Restore normal hyphenation at the end of the % group within which \nohyphenation is presumably called. % \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} \def\restorehyphenation{\hyphenchar\font = `- } \def\t#1{% {\tt \rawbackslash \frenchspacing #1}% \null } \let\ttfont=\t \def\samp#1{`\tclose{#1}'\null} \setfont\smallrm\rmshape{8}{1000} \font\smallsy=cmsy9 \def\key#1{{\smallrm\textfont2=\smallsy \leavevmode\hbox{% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% \vbox{\hrule\kern-0.4pt \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% \kern-0.4pt\hrule}% \kern-.06em\raise0.4pt\hbox{\angleright}}}} % The old definition, with no lozenge: %\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null} \def\ctrl #1{{\tt \rawbackslash \hat}#1} % @file, @option are the same as @samp. \let\file=\samp \let\option=\samp % @code is a modification of @t, % which makes spaces the same size as normal in the surrounding text. \def\tclose#1{% {% % Change normal interword space to be same as for the current font. \spaceskip = \fontdimen2\font % % Switch to typewriter. \tt % % But `\ ' produces the large typewriter interword space. \def\ {{\spaceskip = 0pt{} }}% % % Turn off hyphenation. \nohyphenation % \rawbackslash \frenchspacing #1% }% \null } % We *must* turn on hyphenation at `-' and `_' in \code. % Otherwise, it is too hard to avoid overfull hboxes % in the Emacs manual, the Library manual, etc. % Unfortunately, TeX uses one parameter (\hyphenchar) to control % both hyphenation at - and hyphenation within words. % We must therefore turn them both off (\tclose does that) % and arrange explicitly to hyphenate at a dash. % -- rms. { \catcode`\-=\active \catcode`\_=\active % \global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex } % % If we end up with any active - characters when handling the index, % just treat them as a normal -. \global\def\indexbreaks{\catcode`\-=\active \let-\realdash} } \def\realdash{-} \def\codedash{-\discretionary{}{}{}} \def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}} \def\codex #1{\tclose{#1}\endgroup} %\let\exp=\tclose %Was temporary % @kbd is like @code, except that if the argument is just one @key command, % then @kbd has no effect. % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), % `example' (@kbd uses ttsl only inside of @example and friends), % or `code' (@kbd uses normal tty font always). \def\kbdinputstyle{\parsearg\kbdinputstylexxx} \def\kbdinputstylexxx#1{% \def\arg{#1}% \ifx\arg\worddistinct \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% \else\ifx\arg\wordexample \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% \else\ifx\arg\wordcode \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% \fi\fi\fi } \def\worddistinct{distinct} \def\wordexample{example} \def\wordcode{code} % Default is kbdinputdistinct. (Too much of a hassle to call the macro, % the catcodes are wrong for parsearg to work.) \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl} \def\xkey{\key} \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% \ifx\one\xkey\ifx\threex\three \key{#2}% \else{\tclose{\kbdfont\look}}\fi \else{\tclose{\kbdfont\look}}\fi} % For @url, @env, @command quotes seem unnecessary, so use \code. \let\url=\code \let\env=\code \let\command=\code % @uref (abbreviation for `urlref') takes an optional second argument % specifying the text to display. First (mandatory) arg is the url. % Perhaps eventually put in a hypertex \special here. % \def\uref#1{\urefxxx #1,,\finish} \def\urefxxx#1,#2,#3\finish{% \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0 > 0pt \unhbox0\ (\code{#1})% \else \code{#1}% \fi } % rms does not like the angle brackets --karl, 17may97. % So now @email is just like @uref. %\def\email#1{\angleleft{\tt #1}\angleright} \let\email=\uref % Check if we are currently using a typewriter font. Since all the % Computer Modern typewriter fonts have zero interword stretch (and % shrink), and it is reasonable to expect all typewriter fonts to have % this property, we can check that font parameter. % \def\ifmonospace{\ifdim\fontdimen3\font=0pt } % Typeset a dimension, e.g., `in' or `pt'. The only reason for the % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. % \def\dmn#1{\thinspace #1} \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} % @l was never documented to mean ``switch to the Lisp font'', % and it is not used as such in any manual I can find. We need it for % Polish suppressed-l. --karl, 22sep96. %\def\l#1{{\li #1}\null} % Explicit font changes: @r, @sc, undocumented @ii. \def\r#1{{\rm #1}} % roman font \def\sc#1{{\smallcaps#1}} % smallcaps font \def\ii#1{{\it #1}} % italic font % @acronym downcases the argument and prints in smallcaps. \def\acronym#1{{\smallcaps \lowercase{#1}}} % @pounds{} is a sterling sign. \def\pounds{{\it\$}} \message{page headings,} \newskip\titlepagetopglue \titlepagetopglue = 1.5in \newskip\titlepagebottomglue \titlepagebottomglue = 2pc % First the title page. Must do @settitle before @titlepage. \newif\ifseenauthor \newif\iffinishedtitlepage % Do an implicit @contents or @shortcontents after @end titlepage if the % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. % \newif\ifsetcontentsaftertitlepage \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue \newif\ifsetshortcontentsaftertitlepage \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue \def\shorttitlepage{\parsearg\shorttitlepagezzz} \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% \endgroup\page\hbox{}\page} \def\titlepage{\begingroup \parindent=0pt \textfonts \let\subtitlerm=\tenrm \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% % \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% % % Leave some space at the very top of the page. \vglue\titlepagetopglue % % Now you can print the title using @title. \def\title{\parsearg\titlezzz}% \def\titlezzz##1{\leftline{\titlefonts\rm ##1} % print a rule at the page bottom also. \finishedtitlepagefalse \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% % No rule at page bottom unless we print one at the top with @title. \finishedtitlepagetrue % % Now you can put text using @subtitle. \def\subtitle{\parsearg\subtitlezzz}% \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% % % @author should come last, but may come many times. \def\author{\parsearg\authorzzz}% \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi {\authorfont \leftline{##1}}}% % % Most title ``pages'' are actually two pages long, with space % at the top of the second. We don't want the ragged left on the second. \let\oldpage = \page \def\page{% \iffinishedtitlepage\else \finishtitlepage \fi \oldpage \let\page = \oldpage \hbox{}}% % \def\page{\oldpage \hbox{}} } \def\Etitlepage{% \iffinishedtitlepage\else \finishtitlepage \fi % It is important to do the page break before ending the group, % because the headline and footline are only empty inside the group. % If we use the new definition of \page, we always get a blank page % after the title page, which we certainly don't want. \oldpage \endgroup % % If they want short, they certainly want long too. \ifsetshortcontentsaftertitlepage \shortcontents \contents \global\let\shortcontents = \relax \global\let\contents = \relax \fi % \ifsetcontentsaftertitlepage \contents \global\let\contents = \relax \global\let\shortcontents = \relax \fi % \HEADINGSon } \def\finishtitlepage{% \vskip4pt \hrule height 2pt width \hsize \vskip\titlepagebottomglue \finishedtitlepagetrue } %%% Set up page headings and footings. \let\thispage=\folio \newtoks\evenheadline % headline on even pages \newtoks\oddheadline % headline on odd pages \newtoks\evenfootline % footline on even pages \newtoks\oddfootline % footline on odd pages % Now make Tex use those variables \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}} \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}\HEADINGShook} \let\HEADINGShook=\relax % Commands to set those variables. % For example, this is what @headings on does % @evenheading @thistitle|@thispage|@thischapter % @oddheading @thischapter|@thispage|@thistitle % @evenfooting @thisfile|| % @oddfooting ||@thisfile \def\evenheading{\parsearg\evenheadingxxx} \def\oddheading{\parsearg\oddheadingxxx} \def\everyheading{\parsearg\everyheadingxxx} \def\evenfooting{\parsearg\evenfootingxxx} \def\oddfooting{\parsearg\oddfootingxxx} \def\everyfooting{\parsearg\everyfootingxxx} {\catcode`\@=0 % \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}% \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% % % Leave some space for the footline. Hopefully ok to assume % @evenfooting will not be used by itself. \global\advance\pageheight by -\baselineskip \global\advance\vsize by -\baselineskip } \gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}} % }% unbind the catcode of @. % @headings double turns headings on for double-sided printing. % @headings single turns headings on for single-sided printing. % @headings off turns them off. % @headings on same as @headings double, retained for compatibility. % @headings after turns on double-sided headings after this page. % @headings doubleafter turns on double-sided headings after this page. % @headings singleafter turns on single-sided headings after this page. % By default, they are off at the start of a document, % and turned `on' after @end titlepage. \def\headings #1 {\csname HEADINGS#1\endcsname} \def\HEADINGSoff{ \global\evenheadline={\hfil} \global\evenfootline={\hfil} \global\oddheadline={\hfil} \global\oddfootline={\hfil}} \HEADINGSoff % When we turn headings on, set the page number to 1. % For double-sided printing, put current file name in lower left corner, % chapter name on inside top of right hand pages, document % title on inside top of left hand pages, and page numbers on outside top % edge of all pages. \def\HEADINGSdouble{ \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } \let\contentsalignmacro = \chappager % For single-sided printing, chapter title goes across top left of page, % page number on top right. \def\HEADINGSsingle{ \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } \def\HEADINGSon{\HEADINGSdouble} \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} \let\HEADINGSdoubleafter=\HEADINGSafter \def\HEADINGSdoublex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} \def\HEADINGSsinglex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } % Subroutines used in generating headings % Produces Day Month Year style of output. \def\today{\number\day\space \ifcase\month\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi \space\number\year} % Use this if you want the Month Day, Year style of output. %\def\today{\ifcase\month\or %January\or February\or March\or April\or May\or June\or %July\or August\or September\or October\or November\or December\fi %\space\number\day, \number\year} % @settitle line... specifies the title of the document, for headings % It generates no output of its own \def\thistitle{No Title} \def\settitle{\parsearg\settitlezzz} \def\settitlezzz #1{\gdef\thistitle{#1}} \message{tables,} % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). % default indentation of table text \newdimen\tableindent \tableindent=.8in % default indentation of @itemize and @enumerate text \newdimen\itemindent \itemindent=.3in % margin between end of table item and start of table text. \newdimen\itemmargin \itemmargin=.1in % used internally for \itemindent minus \itemmargin \newdimen\itemmax % Note @table, @vtable, and @vtable define @item, @itemx, etc., with % these defs. % They also define \itemindex % to index the item name in whatever manner is desired (perhaps none). \newif\ifitemxneedsnegativevskip \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} \def\internalBitem{\smallbreak \parsearg\itemzzz} \def\internalBitemx{\itemxpar \parsearg\itemzzz} \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} \def\internalBkitem{\smallbreak \parsearg\kitemzzz} \def\internalBkitemx{\itemxpar \parsearg\kitemzzz} \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% \itemzzz {#1}} \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% \itemzzz {#1}} \def\itemzzz #1{\begingroup % \advance\hsize by -\rightskip \advance\hsize by -\tableindent \setbox0=\hbox{\itemfont{#1}}% \itemindex{#1}% \nobreak % This prevents a break before @itemx. % % If the item text does not fit in the space we have, put it on a line % by itself, and do not allow a page break either before or after that % line. We do not start a paragraph here because then if the next % command is, e.g., @kindex, the whatsit would get put into the % horizontal list on a line by itself, resulting in extra blank space. \ifdim \wd0>\itemmax % % Make this a paragraph so we get the \parskip glue and wrapping, % but leave it ragged-right. \begingroup \advance\leftskip by-\tableindent \advance\hsize by\tableindent \advance\rightskip by0pt plus1fil \leavevmode\unhbox0\par \endgroup % % We're going to be starting a paragraph, but we don't want the % \parskip glue -- logically it's part of the @item we just started. \nobreak \vskip-\parskip % % Stop a page break at the \parskip glue coming up. Unfortunately % we can't prevent a possible page break at the following % \baselineskip glue. \nobreak \endgroup \itemxneedsnegativevskipfalse \else % The item text fits into the space. Start a paragraph, so that the % following text (if any) will end up on the same line. \noindent % Do this with kerns and \unhbox so that if there is a footnote in % the item text, it can migrate to the main vertical list and % eventually be printed. \nobreak\kern-\tableindent \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 \unhbox0 \nobreak\kern\dimen0 \endgroup \itemxneedsnegativevskiptrue \fi } \def\item{\errmessage{@item while not in a table}} \def\itemx{\errmessage{@itemx while not in a table}} \def\kitem{\errmessage{@kitem while not in a table}} \def\kitemx{\errmessage{@kitemx while not in a table}} \def\xitem{\errmessage{@xitem while not in a table}} \def\xitemx{\errmessage{@xitemx while not in a table}} % Contains a kludge to get @end[description] to work. \def\description{\tablez{\dontindex}{1}{}{}{}{}} % @table, @ftable, @vtable. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} {\obeylines\obeyspaces% \gdef\tablex #1^^M{% \tabley\dontindex#1 \endtabley}} \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} {\obeylines\obeyspaces% \gdef\ftablex #1^^M{% \tabley\fnitemindex#1 \endtabley \def\Eftable{\endgraf\afterenvbreak\endgroup}% \let\Etable=\relax}} \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} {\obeylines\obeyspaces% \gdef\vtablex #1^^M{% \tabley\vritemindex#1 \endtabley \def\Evtable{\endgraf\afterenvbreak\endgroup}% \let\Etable=\relax}} \def\dontindex #1{} \def\fnitemindex #1{\doind {fn}{\code{#1}}}% \def\vritemindex #1{\doind {vr}{\code{#1}}}% {\obeyspaces % \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% \tablez{#1}{#2}{#3}{#4}{#5}{#6}}} \def\tablez #1#2#3#4#5#6{% \aboveenvbreak % \begingroup % \def\Edescription{\Etable}% Necessary kludge. \let\itemindex=#1% \ifnum 0#3>0 \advance \leftskip by #3\mil \fi % \ifnum 0#4>0 \tableindent=#4\mil \fi % \ifnum 0#5>0 \advance \rightskip by #5\mil \fi % \def\itemfont{#2}% \itemmax=\tableindent % \advance \itemmax by -\itemmargin % \advance \leftskip by \tableindent % \exdentamount=\tableindent \parindent = 0pt \parskip = \smallskipamount \ifdim \parskip=0pt \parskip=2pt \fi% \def\Etable{\endgraf\afterenvbreak\endgroup}% \let\item = \internalBitem % \let\itemx = \internalBitemx % \let\kitem = \internalBkitem % \let\kitemx = \internalBkitemx % \let\xitem = \internalBxitem % \let\xitemx = \internalBxitemx % } % This is the counter used by @enumerate, which is really @itemize \newcount \itemno \def\itemize{\parsearg\itemizezzz} \def\itemizezzz #1{% \begingroup % ended by the @end itemize \itemizey {#1}{\Eitemize} } \def\itemizey #1#2{% \aboveenvbreak % \itemmax=\itemindent % \advance \itemmax by -\itemmargin % \advance \leftskip by \itemindent % \exdentamount=\itemindent \parindent = 0pt % \parskip = \smallskipamount % \ifdim \parskip=0pt \parskip=2pt \fi% \def#2{\endgraf\afterenvbreak\endgroup}% \def\itemcontents{#1}% \let\item=\itemizeitem} % Set sfcode to normal for the chars that usually have another value. % These are `.?!:;,' \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } % \splitoff TOKENS\endmark defines \first to be the first token in % TOKENS, and \rest to be the remainder. % \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% % Allow an optional argument of an uppercase letter, lowercase letter, % or number, to specify the first label in the enumerated list. No % argument is the same as `1'. % \def\enumerate{\parsearg\enumeratezzz} \def\enumeratezzz #1{\enumeratey #1 \endenumeratey} \def\enumeratey #1 #2\endenumeratey{% \begingroup % ended by the @end enumerate % % If we were given no argument, pretend we were given `1'. \def\thearg{#1}% \ifx\thearg\empty \def\thearg{1}\fi % % Detect if the argument is a single token. If so, it might be a % letter. Otherwise, the only valid thing it can be is a number. % (We will always have one token, because of the test we just made. % This is a good thing, since \splitoff doesn't work given nothing at % all -- the first parameter is undelimited.) \expandafter\splitoff\thearg\endmark \ifx\rest\empty % Only one token in the argument. It could still be anything. % A ``lowercase letter'' is one whose \lccode is nonzero. % An ``uppercase letter'' is one whose \lccode is both nonzero, and % not equal to itself. % Otherwise, we assume it's a number. % % We need the \relax at the end of the \ifnum lines to stop TeX from % continuing to look for a . % \ifnum\lccode\expandafter`\thearg=0\relax \numericenumerate % a number (we hope) \else % It's a letter. \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax \lowercaseenumerate % lowercase letter \else \uppercaseenumerate % uppercase letter \fi \fi \else % Multiple tokens in the argument. We hope it's a number. \numericenumerate \fi } % An @enumerate whose labels are integers. The starting integer is % given in \thearg. % \def\numericenumerate{% \itemno = \thearg \startenumeration{\the\itemno}% } % The starting (lowercase) letter is in \thearg. \def\lowercaseenumerate{% \itemno = \expandafter`\thearg \startenumeration{% % Be sure we're not beyond the end of the alphabet. \ifnum\itemno=0 \errmessage{No more lowercase letters in @enumerate; get a bigger alphabet}% \fi \char\lccode\itemno }% } % The starting (uppercase) letter is in \thearg. \def\uppercaseenumerate{% \itemno = \expandafter`\thearg \startenumeration{% % Be sure we're not beyond the end of the alphabet. \ifnum\itemno=0 \errmessage{No more uppercase letters in @enumerate; get a bigger alphabet} \fi \char\uccode\itemno }% } % Call itemizey, adding a period to the first argument and supplying the % common last two arguments. Also subtract one from the initial value in % \itemno, since @item increments \itemno. % \def\startenumeration#1{% \advance\itemno by -1 \itemizey{#1.}\Eenumerate\flushcr } % @alphaenumerate and @capsenumerate are abbreviations for giving an arg % to @enumerate. % \def\alphaenumerate{\enumerate{a}} \def\capsenumerate{\enumerate{A}} \def\Ealphaenumerate{\Eenumerate} \def\Ecapsenumerate{\Eenumerate} % Definition of @item while inside @itemize. \def\itemizeitem{% \advance\itemno by 1 {\let\par=\endgraf \smallbreak}% \ifhmode \errmessage{In hmode at itemizeitem}\fi {\parskip=0in \hskip 0pt \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% \vadjust{\penalty 1200}}% \flushcr} % @multitable macros % Amy Hendrickson, 8/18/94, 3/6/96 % % @multitable ... @end multitable will make as many columns as desired. % Contents of each column will wrap at width given in preamble. Width % can be specified either with sample text given in a template line, % or in percent of \hsize, the current width of text on page. % Table can continue over pages but will only break between lines. % To make preamble: % % Either define widths of columns in terms of percent of \hsize: % @multitable @columnfractions .25 .3 .45 % @item ... % % Numbers following @columnfractions are the percent of the total % current hsize to be used for each column. You may use as many % columns as desired. % Or use a template: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item ... % using the widest term desired in each column. % % For those who want to use more than one line's worth of words in % the preamble, break the line within one argument and it % will parse correctly, i.e., % % @multitable {Column 1 template} {Column 2 template} {Column 3 % template} % Not: % @multitable {Column 1 template} {Column 2 template} % {Column 3 template} % Each new table line starts with @item, each subsequent new column % starts with @tab. Empty columns may be produced by supplying @tab's % with nothing between them for as many times as empty columns are needed, % ie, @tab@tab@tab will produce two empty columns. % @item, @tab, @multitable or @end multitable do not need to be on their % own lines, but it will not hurt if they are. % Sample multitable: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item first col stuff @tab second col stuff @tab third col % @item % first col stuff % @tab % second col stuff % @tab % third col % @item first col stuff @tab second col stuff % @tab Many paragraphs of text may be used in any column. % % They will wrap at the width determined by the template. % @item@tab@tab This will be in third column. % @end multitable % Default dimensions may be reset by user. % @multitableparskip is vertical space between paragraphs in table. % @multitableparindent is paragraph indent in table. % @multitablecolmargin is horizontal space to be left between columns. % @multitablelinespace is space to leave between table items, baseline % to baseline. % 0pt means it depends on current normal line spacing. % \newskip\multitableparskip \newskip\multitableparindent \newdimen\multitablecolspace \newskip\multitablelinespace \multitableparskip=0pt \multitableparindent=6pt \multitablecolspace=12pt \multitablelinespace=0pt % Macros used to set up halign preamble: % \let\endsetuptable\relax \def\xendsetuptable{\endsetuptable} \let\columnfractions\relax \def\xcolumnfractions{\columnfractions} \newif\ifsetpercent % #1 is the part of the @columnfraction before the decimal point, which % is presumably either 0 or the empty string (but we don't check, we % just throw it away). #2 is the decimal part, which we use as the % percent of \hsize for this column. \def\pickupwholefraction#1.#2 {% \global\advance\colcount by 1 \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}% \setuptable } \newcount\colcount \def\setuptable#1{% \def\firstarg{#1}% \ifx\firstarg\xendsetuptable \let\go = \relax \else \ifx\firstarg\xcolumnfractions \global\setpercenttrue \else \ifsetpercent \let\go\pickupwholefraction \else \global\advance\colcount by 1 \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator; % typically that is always in the input, anyway. \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% \fi \fi \ifx\go\pickupwholefraction % Put the argument back for the \pickupwholefraction call, so % we'll always have a period there to be parsed. \def\go{\pickupwholefraction#1}% \else \let\go = \setuptable \fi% \fi \go } % multitable syntax \def\tab{&\hskip1sp\relax} % 2/2/96 % tiny skip here makes sure this column space is % maintained, even if it is never used. % @multitable ... @end multitable definitions: % \def\multitable{\parsearg\dotable} \def\dotable#1{\bgroup \vskip\parskip \let\item\crcr \tolerance=9500 \hbadness=9500 \setmultitablespacing \parskip=\multitableparskip \parindent=\multitableparindent \overfullrule=0pt \global\colcount=0 \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}% % % To parse everything between @multitable and @item: \setuptable#1 \endsetuptable % % \everycr will reset column counter, \colcount, at the end of % each line. Every column entry will cause \colcount to advance by one. % The table preamble % looks at the current \colcount to find the correct column width. \everycr{\noalign{% % % \filbreak%% keeps underfull box messages off when table breaks over pages. % Maybe so, but it also creates really weird page breaks when the table % breaks over pages. Wouldn't \vfil be better? Wait until the problem % manifests itself, so it can be fixed for real --karl. \global\colcount=0\relax}}% % % This preamble sets up a generic column definition, which will % be used as many times as user calls for columns. % \vtop will set a single line and will also let text wrap and % continue for many paragraphs if desired. \halign\bgroup&\global\advance\colcount by 1\relax \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname % % In order to keep entries from bumping into each other % we will add a \leftskip of \multitablecolspace to all columns after % the first one. % % If a template has been used, we will add \multitablecolspace % to the width of each template entry. % % If the user has set preamble in terms of percent of \hsize we will % use that dimension as the width of the column, and the \leftskip % will keep entries from bumping into each other. Table will start at % left margin and final column will justify at right margin. % % Make sure we don't inherit \rightskip from the outer environment. \rightskip=0pt \ifnum\colcount=1 % The first column will be indented with the surrounding text. \advance\hsize by\leftskip \else \ifsetpercent \else % If user has not set preamble in terms of percent of \hsize % we will advance \hsize by \multitablecolspace. \advance\hsize by \multitablecolspace \fi % In either case we will make \leftskip=\multitablecolspace: \leftskip=\multitablecolspace \fi % Ignoring space at the beginning and end avoids an occasional spurious % blank line, when TeX decides to break the line at the space before the % box from the multistrut, so the strut ends up on a line by itself. % For example: % @multitable @columnfractions .11 .89 % @item @code{#} % @tab Legal holiday which is valid in major parts of the whole country. % Is automatically provided with highlighting sequences respectively marking % characters. \noindent\ignorespaces##\unskip\multistrut}\cr } \def\setmultitablespacing{% test to see if user has set \multitablelinespace. % If so, do nothing. If not, give it an appropriate dimension based on % current baselineskip. \ifdim\multitablelinespace=0pt %% strut to put in table in case some entry doesn't have descenders, %% to keep lines equally spaced \let\multistrut = \strut %% Test to see if parskip is larger than space between lines of %% table. If not, do nothing. %% If so, set to same dimension as multitablelinespace. \else \gdef\multistrut{\vrule height\multitablelinespace depth\dp0 width0pt\relax} \fi \ifdim\multitableparskip>\multitablelinespace \global\multitableparskip=\multitablelinespace \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller %% than skip between lines in the table. \fi% \ifdim\multitableparskip=0pt \global\multitableparskip=\multitablelinespace \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller %% than skip between lines in the table. \fi} \message{indexing,} % Index generation facilities % Define \newwrite to be identical to plain tex's \newwrite % except not \outer, so it can be used within \newindex. {\catcode`\@=11 \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} % \newindex {foo} defines an index named foo. % It automatically defines \fooindex such that % \fooindex ...rest of line... puts an entry in the index foo. % It also defines \fooindfile to be the number of the output channel for % the file that accumulates this index. The file's extension is foo. % The name of an index should be no more than 2 characters long % for the sake of vms. % \def\newindex#1{% \iflinks \expandafter\newwrite \csname#1indfile\endcsname \openout \csname#1indfile\endcsname \jobname.#1 % Open the file \fi \expandafter\xdef\csname#1index\endcsname{% % Define @#1index \noexpand\doindex{#1}} } % @defindex foo == \newindex{foo} \def\defindex{\parsearg\newindex} % Define @defcodeindex, like @defindex except put all entries in @code. \def\newcodeindex#1{% \iflinks \expandafter\newwrite \csname#1indfile\endcsname \openout \csname#1indfile\endcsname \jobname.#1 \fi \expandafter\xdef\csname#1index\endcsname{% \noexpand\docodeindex{#1}} } \def\defcodeindex{\parsearg\newcodeindex} % @synindex foo bar makes index foo feed into index bar. % Do this instead of @defindex foo if you don't want it as a separate index. % The \closeout helps reduce unnecessary open files; the limit on the % Acorn RISC OS is a mere 16 files. \def\synindex#1 #2 {% \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname \expandafter\closeout\csname#1indfile\endcsname \expandafter\let\csname#1indfile\endcsname=\synindexfoo \expandafter\xdef\csname#1index\endcsname{% define \xxxindex \noexpand\doindex{#2}}% } % @syncodeindex foo bar similar, but put all entries made for index foo % inside @code. \def\syncodeindex#1 #2 {% \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname \expandafter\closeout\csname#1indfile\endcsname \expandafter\let\csname#1indfile\endcsname=\synindexfoo \expandafter\xdef\csname#1index\endcsname{% define \xxxindex \noexpand\docodeindex{#2}}% } % Define \doindex, the driver for all \fooindex macros. % Argument #1 is generated by the calling \fooindex macro, % and it is "foo", the name of the index. % \doindex just uses \parsearg; it calls \doind for the actual work. % This is because \doind is more useful to call from other macros. % There is also \dosubind {index}{topic}{subtopic} % which makes an entry in a two-level index such as the operation index. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} \def\singleindexer #1{\doind{\indexname}{#1}} % like the previous two, but they put @code around the argument. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} \def\indexdummies{% \def\ { }% % Take care of the plain tex accent commands. \def\"{\realbackslash "}% \def\`{\realbackslash `}% \def\'{\realbackslash '}% \def\^{\realbackslash ^}% \def\~{\realbackslash ~}% \def\={\realbackslash =}% \def\b{\realbackslash b}% \def\c{\realbackslash c}% \def\d{\realbackslash d}% \def\u{\realbackslash u}% \def\v{\realbackslash v}% \def\H{\realbackslash H}% % Take care of the plain tex special European modified letters. \def\oe{\realbackslash oe}% \def\ae{\realbackslash ae}% \def\aa{\realbackslash aa}% \def\OE{\realbackslash OE}% \def\AE{\realbackslash AE}% \def\AA{\realbackslash AA}% \def\o{\realbackslash o}% \def\O{\realbackslash O}% \def\l{\realbackslash l}% \def\L{\realbackslash L}% \def\ss{\realbackslash ss}% % Take care of texinfo commands likely to appear in an index entry. % (Must be a way to avoid doing expansion at all, and thus not have to % laboriously list every single command here.) \def\@{@}% will be @@ when we switch to @ as escape char. % Need these in case \tex is in effect and \{ is a \delimiter again. % But can't use \lbracecmd and \rbracecmd because texindex assumes % braces and backslashes are used only as delimiters. \let\{ = \mylbrace \let\} = \myrbrace \def\_{{\realbackslash _}}% \def\w{\realbackslash w }% \def\bf{\realbackslash bf }% %\def\rm{\realbackslash rm }% \def\sl{\realbackslash sl }% \def\sf{\realbackslash sf}% \def\tt{\realbackslash tt}% \def\gtr{\realbackslash gtr}% \def\less{\realbackslash less}% \def\hat{\realbackslash hat}% \def\TeX{\realbackslash TeX}% \def\dots{\realbackslash dots }% \def\result{\realbackslash result}% \def\equiv{\realbackslash equiv}% \def\expansion{\realbackslash expansion}% \def\print{\realbackslash print}% \def\error{\realbackslash error}% \def\point{\realbackslash point}% \def\copyright{\realbackslash copyright}% \def\tclose##1{\realbackslash tclose {##1}}% \def\code##1{\realbackslash code {##1}}% \def\uref##1{\realbackslash uref {##1}}% \def\url##1{\realbackslash url {##1}}% \def\env##1{\realbackslash env {##1}}% \def\command##1{\realbackslash command {##1}}% \def\option##1{\realbackslash option {##1}}% \def\dotless##1{\realbackslash dotless {##1}}% \def\samp##1{\realbackslash samp {##1}}% \def\,##1{\realbackslash ,{##1}}% \def\t##1{\realbackslash t {##1}}% \def\r##1{\realbackslash r {##1}}% \def\i##1{\realbackslash i {##1}}% \def\b##1{\realbackslash b {##1}}% \def\sc##1{\realbackslash sc {##1}}% \def\cite##1{\realbackslash cite {##1}}% \def\key##1{\realbackslash key {##1}}% \def\file##1{\realbackslash file {##1}}% \def\var##1{\realbackslash var {##1}}% \def\kbd##1{\realbackslash kbd {##1}}% \def\dfn##1{\realbackslash dfn {##1}}% \def\emph##1{\realbackslash emph {##1}}% \def\acronym##1{\realbackslash acronym {##1}}% % % Handle some cases of @value -- where the variable name does not % contain - or _, and the value does not contain any % (non-fully-expandable) commands. \let\value = \expandablevalue % \unsepspaces } % If an index command is used in an @example environment, any spaces % therein should become regular spaces in the raw index file, not the % expansion of \tie (\\leavevmode \penalty \@M \ ). {\obeyspaces \gdef\unsepspaces{\obeyspaces\let =\space}} % \indexnofonts no-ops all font-change commands. % This is used when outputting the strings to sort the index by. \def\indexdummyfont#1{#1} \def\indexdummytex{TeX} \def\indexdummydots{...} \def\indexnofonts{% % Just ignore accents. \let\,=\indexdummyfont \let\"=\indexdummyfont \let\`=\indexdummyfont \let\'=\indexdummyfont \let\^=\indexdummyfont \let\~=\indexdummyfont \let\==\indexdummyfont \let\b=\indexdummyfont \let\c=\indexdummyfont \let\d=\indexdummyfont \let\u=\indexdummyfont \let\v=\indexdummyfont \let\H=\indexdummyfont \let\dotless=\indexdummyfont % Take care of the plain tex special European modified letters. \def\oe{oe}% \def\ae{ae}% \def\aa{aa}% \def\OE{OE}% \def\AE{AE}% \def\AA{AA}% \def\o{o}% \def\O{O}% \def\l{l}% \def\L{L}% \def\ss{ss}% \let\w=\indexdummyfont \let\t=\indexdummyfont \let\r=\indexdummyfont \let\i=\indexdummyfont \let\b=\indexdummyfont \let\emph=\indexdummyfont \let\strong=\indexdummyfont \let\cite=\indexdummyfont \let\sc=\indexdummyfont %Don't no-op \tt, since it isn't a user-level command % and is used in the definitions of the active chars like <, >, |... %\let\tt=\indexdummyfont \let\tclose=\indexdummyfont \let\code=\indexdummyfont \let\url=\indexdummyfont \let\uref=\indexdummyfont \let\env=\indexdummyfont \let\command=\indexdummyfont \let\option=\indexdummyfont \let\file=\indexdummyfont \let\samp=\indexdummyfont \let\kbd=\indexdummyfont \let\key=\indexdummyfont \let\var=\indexdummyfont \let\TeX=\indexdummytex \let\dots=\indexdummydots \def\@{@}% } % To define \realbackslash, we must make \ not be an escape. % We must first make another character (@) an escape % so we do not become unable to do a definition. {\catcode`\@=0 \catcode`\\=\other @gdef@realbackslash{\}} \let\indexbackslash=0 %overridden during \printindex. \let\SETmarginindex=\relax % put index entries in margin (undocumented)? % For \ifx comparisons. \def\emptymacro{\empty} % Most index entries go through here, but \dosubind is the general case. % \def\doind#1#2{\dosubind{#1}{#2}\empty} % Workhorse for all \fooindexes. % #1 is name of index, #2 is stuff to put there, #3 is subentry -- % \empty if called from \doind, as we usually are. The main exception % is with defuns, which call us directly. % \def\dosubind#1#2#3{% % Put the index entry in the margin if desired. \ifx\SETmarginindex\relax\else \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% \fi {% \count255=\lastpenalty {% \indexdummies % Must do this here, since \bf, etc expand at this stage \escapechar=`\\ {% \let\folio = 0% We will expand all macros now EXCEPT \folio. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now % so it will be output as is; and it will print as backslash. % \def\thirdarg{#3}% % % If third arg is present, precede it with space in sort key. \ifx\thirdarg\emptymacro \let\subentry = \empty \else \def\subentry{ #3}% \fi % % First process the index-string with all font commands turned off % to get the string to sort by. {\indexnofonts \xdef\indexsorttmp{#2\subentry}}% % % Now produce the complete index entry, with both the sort key and the % original text, including any font commands. \toks0 = {#2}% \edef\temp{% \write\csname#1indfile\endcsname{% \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}% }% % % If third (subentry) arg is present, add it to the index string. \ifx\thirdarg\emptymacro \else \toks0 = {#3}% \edef\temp{\temp{\the\toks0}}% \fi % % If a skip is the last thing on the list now, preserve it % by backing up by \lastskip, doing the \write, then inserting % the skip again. Otherwise, the whatsit generated by the % \write will make \lastskip zero. The result is that sequences % like this: % @end defun % @tindex whatever % @defun ... % will have extra space inserted, because the \medbreak in the % start of the @defun won't see the skip inserted by the @end of % the previous defun. % % But don't do any of this if we're not in vertical mode. We % don't want to do a \vskip and prematurely end a paragraph. % % Avoid page breaks due to these extra skips, too. % \iflinks \ifvmode \skip0 = \lastskip \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi \fi % \temp % do the write % % \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi \fi }% }% \penalty\count255 }% } % The index entry written in the file actually looks like % \entry {sortstring}{page}{topic} % or % \entry {sortstring}{page}{topic}{subtopic} % The texindex program reads in these files and writes files % containing these kinds of lines: % \initial {c} % before the first topic whose initial is c % \entry {topic}{pagelist} % for a topic that is used without subtopics % \primary {topic} % for the beginning of a topic that is used with subtopics % \secondary {subtopic}{pagelist} % for each subtopic. % Define the user-accessible indexing commands % @findex, @vindex, @kindex, @cindex. \def\findex {\fnindex} \def\kindex {\kyindex} \def\cindex {\cpindex} \def\vindex {\vrindex} \def\tindex {\tpindex} \def\pindex {\pgindex} \def\cindexsub {\begingroup\obeylines\cindexsub} {\obeylines % \gdef\cindexsub "#1" #2^^M{\endgroup % \dosubind{cp}{#2}{#1}}} % Define the macros used in formatting output of the sorted index material. % @printindex causes a particular index (the ??s file) to get printed. % It does not print any chapter heading (usually an @unnumbered). % \def\printindex{\parsearg\doprintindex} \def\doprintindex#1{\begingroup \dobreak \chapheadingskip{10000}% % \indexfonts \rm \tolerance = 9500 \indexbreaks % % See if the index file exists and is nonempty. % Change catcode of @ here so that if the index file contains % \initial {@} % as its first line, TeX doesn't complain about mismatched braces % (because it thinks @} is a control sequence). \catcode`\@ = 11 \openin 1 \jobname.#1s \ifeof 1 % \enddoublecolumns gets confused if there is no text in the index, % and it loses the chapter title and the aux file entries for the % index. The easiest way to prevent this problem is to make sure % there is some text. (Index is nonexistent) \else % % If the index file exists but is empty, then \openin leaves \ifeof % false. We have to make TeX try to read something from the file, so % it can discover if there is anything in it. \read 1 to \temp \ifeof 1 (Index is empty) \else % Index files are almost Texinfo source, but we use \ as the escape % character. It would be better to use @, but that's too big a change % to make right now. \def\indexbackslash{\rawbackslashxx}% \catcode`\\ = 0 \escapechar = `\\ \begindoublecolumns \input \jobname.#1s \enddoublecolumns \fi \fi \closein 1 \endgroup} % These macros are used by the sorted index file itself. % Change them to control the appearance of the index. \def\initial#1{{% % Some minor font changes for the special characters. \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt % % Remove any glue we may have, we'll be inserting our own. \removelastskip % % We like breaks before the index initials, so insert a bonus. \penalty -300 % % Typeset the initial. Making this add up to a whole number of % baselineskips increases the chance of the dots lining up from column % to column. It still won't often be perfect, because of the stretch % we need before each entry, but it's better. % % No shrink because it confuses \balancecolumns. \vskip 1.67\baselineskip plus .5\baselineskip \leftline{\secbf #1}% \vskip .33\baselineskip plus .1\baselineskip % % Do our best not to break after the initial. \nobreak }} % This typesets a paragraph consisting of #1, dot leaders, and then #2 % flush to the right margin. It is used for index and table of contents % entries. The paragraph is indented by \leftskip. % \def\entry#1#2{\begingroup % % Start a new paragraph if necessary, so our assignments below can't % affect previous text. \par % % Do not fill out the last line with white space. \parfillskip = 0in % % No extra space above this paragraph. \parskip = 0in % % Do not prefer a separate line ending with a hyphen to fewer lines. \finalhyphendemerits = 0 % % \hangindent is only relevant when the entry text and page number % don't both fit on one line. In that case, bob suggests starting the % dots pretty far over on the line. Unfortunately, a large % indentation looks wrong when the entry text itself is broken across % lines. So we use a small indentation and put up with long leaders. % % \hangafter is reset to 1 (which is the value we want) at the start % of each paragraph, so we need not do anything with that. \hangindent = 2em % % When the entry text needs to be broken, just fill out the first line % with blank space. \rightskip = 0pt plus1fil % % A bit of stretch before each entry for the benefit of balancing columns. \vskip 0pt plus1pt % % Start a ``paragraph'' for the index entry so the line breaking % parameters we've set above will have an effect. \noindent % % Insert the text of the index entry. TeX will do line-breaking on it. #1% % The following is kludged to not output a line of dots in the index if % there are no page numbers. The next person who breaks this will be % cursed by a Unix daemon. \def\tempa{{\rm }}% \def\tempb{#2}% \edef\tempc{\tempa}% \edef\tempd{\tempb}% \ifx\tempc\tempd\ \else% % % If we must, put the page number on a line of its own, and fill out % this line with blank space. (The \hfil is overwhelmed with the % fill leaders glue in \indexdotfill if the page number does fit.) \hfil\penalty50 \null\nobreak\indexdotfill % Have leaders before the page number. % % The `\ ' here is removed by the implicit \unskip that TeX does as % part of (the primitive) \par. Without it, a spurious underfull % \hbox ensues. \ #2% The page number ends the paragraph. \fi% \par \endgroup} % Like \dotfill except takes at least 1 em. \def\indexdotfill{\cleaders \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} \def\primary #1{\line{#1\hfil}} \newskip\secondaryindent \secondaryindent=0.5cm \def\secondary #1#2{ {\parfillskip=0in \parskip=0in \hangindent =1in \hangafter=1 \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par }} % Define two-column mode, which we use to typeset indexes. % Adapted from the TeXbook, page 416, which is to say, % the manmac.tex format used to print the TeXbook itself. \catcode`\@=11 \newbox\partialpage \newdimen\doublecolumnhsize \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns % Grab any single-column material above us. \output = {\global\setbox\partialpage = \vbox{% % % Here is a possibility not foreseen in manmac: if we accumulate a % whole lot of material, we might end up calling this \output % routine twice in a row (see the doublecol-lose test, which is % essentially a couple of indexes with @setchapternewpage off). In % that case, we must prevent the second \partialpage from % simply overwriting the first, causing us to lose the page. % This will preserve it until a real output routine can ship it % out. Generally, \partialpage will be empty when this runs and % this will be a no-op. \unvbox\partialpage % % Unvbox the main output page. \unvbox255 \kern-\topskip \kern\baselineskip }}% \eject % run that output routine to set \partialpage % % Use the double-column output routine for subsequent pages. \output = {\doublecolumnout}% % % Change the page size parameters. We could do this once outside this % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 % format, but then we repeat the same computation. Repeating a couple % of assignments once per index is clearly meaningless for the % execution time, so we may as well do it in one place. % % First we halve the line length, less a little for the gutter between % the columns. We compute the gutter based on the line length, so it % changes automatically with the paper format. The magic constant % below is chosen so that the gutter has the same value (well, +-<1pt) % as it did when we hard-coded it. % % We put the result in a separate register, \doublecolumhsize, so we % can restore it in \pagesofar, after \hsize itself has (potentially) % been clobbered. % \doublecolumnhsize = \hsize \advance\doublecolumnhsize by -.04154\hsize \divide\doublecolumnhsize by 2 \hsize = \doublecolumnhsize % % Double the \vsize as well. (We don't need a separate register here, % since nobody clobbers \vsize.) \advance\vsize by -\ht\partialpage \vsize = 2\vsize } % The double-column output routine for all double-column pages except % the last. % \def\doublecolumnout{% \splittopskip=\topskip \splitmaxdepth=\maxdepth % Get the available space for the double columns -- the normal % (undoubled) page height minus any material left over from the % previous page. \dimen@ = \vsize \divide\dimen@ by 2 % % box0 will be the left-hand column, box2 the right. \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ \onepageout\pagesofar \unvbox255 \penalty\outputpenalty } \def\pagesofar{% % Re-output the contents of the output page -- any previous material, % followed by the two boxes we just split, in box0 and box2. \advance\vsize by \ht\partialpage \unvbox\partialpage % \hsize = \doublecolumnhsize \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}% } \def\enddoublecolumns{% \output = {% % Split the last of the double-column material. Leave it on the % current page, no automatic page break. \balancecolumns % % If we end up splitting too much material for the current page, % though, there will be another page break right after this \output % invocation ends. Having called \balancecolumns once, we do not % want to call it again. Therefore, reset \output to its normal % definition right away. (We hope \balancecolumns will never be % called on to balance too much material, but if it is, this makes % the output somewhat more palatable.) \global\output = {\onepageout{\pagecontents\PAGE}}% }% \eject \endgroup % started in \begindoublecolumns % % \pagegoal was set to the doubled \vsize above, since we restarted % the current page. We're now back to normal single-column % typesetting, so reset \pagegoal to the normal \vsize (after the % \endgroup where \vsize got restored). \pagegoal = \vsize } \def\balancecolumns{% % Called at the end of the double column material. \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. \dimen@ = \ht0 \advance\dimen@ by \topskip \advance\dimen@ by-\baselineskip \divide\dimen@ by 2 % target to split to %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% \splittopskip = \topskip % Loop until we get a decent breakpoint. {% \vbadness = 10000 \loop \global\setbox3 = \copy0 \global\setbox1 = \vsplit3 to \dimen@ \ifdim\ht3>\dimen@ \global\advance\dimen@ by 1pt \repeat }% %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% \setbox0=\vbox to\dimen@{\unvbox1}% \setbox2=\vbox to\dimen@{\unvbox3}% % \pagesofar } \catcode`\@ = \other \message{sectioning,} % Define chapters, sections, etc. \newcount\chapno \newcount\secno \secno=0 \newcount\subsecno \subsecno=0 \newcount\subsubsecno \subsubsecno=0 % This counter is funny since it counts through charcodes of letters A, B, ... \newcount\appendixno \appendixno = `\@ \def\appendixletter{\char\the\appendixno} % Each @chapter defines this as the name of the chapter. % page headings and footings can use it. @section does likewise. \def\thischapter{} \def\thissection{} \newcount\absseclevel % used to calculate proper heading level \newcount\secbase\secbase=0 % @raise/lowersections modify this count % @raisesections: treat @section as chapter, @subsection as section, etc. \def\raisesections{\global\advance\secbase by -1} \let\up=\raisesections % original BFox name % @lowersections: treat @chapter as section, @section as subsection, etc. \def\lowersections{\global\advance\secbase by 1} \let\down=\lowersections % original BFox name % Choose a numbered-heading macro % #1 is heading level if unmodified by @raisesections or @lowersections % #2 is text for heading \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 \ifcase\absseclevel \chapterzzz{#2} \or \seczzz{#2} \or \numberedsubseczzz{#2} \or \numberedsubsubseczzz{#2} \else \ifnum \absseclevel<0 \chapterzzz{#2} \else \numberedsubsubseczzz{#2} \fi \fi } % like \numhead, but chooses appendix heading levels \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 \ifcase\absseclevel \appendixzzz{#2} \or \appendixsectionzzz{#2} \or \appendixsubseczzz{#2} \or \appendixsubsubseczzz{#2} \else \ifnum \absseclevel<0 \appendixzzz{#2} \else \appendixsubsubseczzz{#2} \fi \fi } % like \numhead, but chooses numberless heading levels \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 \ifcase\absseclevel \unnumberedzzz{#2} \or \unnumberedseczzz{#2} \or \unnumberedsubseczzz{#2} \or \unnumberedsubsubseczzz{#2} \else \ifnum \absseclevel<0 \unnumberedzzz{#2} \else \unnumberedsubsubseczzz{#2} \fi \fi } % @chapter, @appendix, @unnumbered. \def\thischaptername{No Chapter Title} \outer\def\chapter{\parsearg\chapteryyy} \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz \def\chapterzzz #1{% \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}% \chapmacro {#1}{\the\chapno}% \gdef\thissection{#1}% \gdef\thischaptername{#1}% % We don't substitute the actual chapter name into \thischapter % because we don't want its macros evaluated now. \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}% {\the\chapno}}}% \temp \donoderef \global\let\section = \numberedsec \global\let\subsection = \numberedsubsec \global\let\subsubsection = \numberedsubsubsec } \outer\def\appendix{\parsearg\appendixyyy} \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz \def\appendixzzz #1{% \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{\putwordAppendix\space \appendixletter}% \chapmacro {#1}{\putwordAppendix{} \appendixletter}% \gdef\thissection{#1}% \gdef\thischaptername{#1}% \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}% {\putwordAppendix{} \appendixletter}}}% \temp \appendixnoderef \global\let\section = \appendixsec \global\let\subsection = \appendixsubsec \global\let\subsubsection = \appendixsubsubsec } % @centerchap is like @unnumbered, but the heading is centered. \outer\def\centerchap{\parsearg\centerchapyyy} \def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}} % @top is like @unnumbered. \outer\def\top{\parsearg\unnumberedyyy} \outer\def\unnumbered{\parsearg\unnumberedyyy} \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz \def\unnumberedzzz #1{% \secno=0 \subsecno=0 \subsubsecno=0 % % This used to be simply \message{#1}, but TeX fully expands the % argument to \message. Therefore, if #1 contained @-commands, TeX % expanded them. For example, in `@unnumbered The @cite{Book}', TeX % expanded @cite (which turns out to cause errors because \cite is meant % to be executed, not expanded). % % Anyway, we don't want the fully-expanded definition of @cite to appear % as a result of the \message, we just want `@cite' itself. We use % \the to achieve this: TeX expands \the only once, % simply yielding the contents of . (We also do this for % the toc entries.) \toks0 = {#1}\message{(\the\toks0)}% % \unnumbchapmacro {#1}% \gdef\thischapter{#1}\gdef\thissection{#1}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}% \temp \unnumbnoderef \global\let\section = \unnumberedsec \global\let\subsection = \unnumberedsubsec \global\let\subsubsection = \unnumberedsubsubsec } % Sections. \outer\def\numberedsec{\parsearg\secyyy} \def\secyyy #1{\numhead1{#1}} % normally calls seczzz \def\seczzz #1{% \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% {\the\chapno}{\the\secno}}}% \temp \donoderef \nobreak } \outer\def\appendixsection{\parsearg\appendixsecyyy} \outer\def\appendixsec{\parsearg\appendixsecyyy} \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz \def\appendixsectionzzz #1{% \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% {\appendixletter}{\the\secno}}}% \temp \appendixnoderef \nobreak } \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz \def\unnumberedseczzz #1{% \plainsecheading {#1}\gdef\thissection{#1}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}% \temp \unnumbnoderef \nobreak } % Subsections. \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz \def\numberedsubseczzz #1{% \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% {\the\chapno}{\the\secno}{\the\subsecno}}}% \temp \donoderef \nobreak } \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz \def\appendixsubseczzz #1{% \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% {\appendixletter}{\the\secno}{\the\subsecno}}}% \temp \appendixnoderef \nobreak } \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz \def\unnumberedsubseczzz #1{% \plainsubsecheading {#1}\gdef\thissection{#1}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry% {\the\toks0}}}% \temp \unnumbnoderef \nobreak } % Subsubsections. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz \def\numberedsubsubseczzz #1{% \gdef\thissection{#1}\global\advance \subsubsecno by 1 % \subsubsecheading {#1} {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% \temp \donoderef \nobreak } \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz \def\appendixsubsubseczzz #1{% \gdef\thissection{#1}\global\advance \subsubsecno by 1 % \subsubsecheading {#1} {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% \temp \appendixnoderef \nobreak } \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz \def\unnumberedsubsubseczzz #1{% \plainsubsubsecheading {#1}\gdef\thissection{#1}% \toks0 = {#1}% \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry% {\the\toks0}}}% \temp \unnumbnoderef \nobreak } % These are variants which are not "outer", so they can appear in @ifinfo. % Actually, they should now be obsolete; ordinary section commands should work. \def\infotop{\parsearg\unnumberedzzz} \def\infounnumbered{\parsearg\unnumberedzzz} \def\infounnumberedsec{\parsearg\unnumberedseczzz} \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} \def\infoappendix{\parsearg\appendixzzz} \def\infoappendixsec{\parsearg\appendixseczzz} \def\infoappendixsubsec{\parsearg\appendixsubseczzz} \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} \def\infochapter{\parsearg\chapterzzz} \def\infosection{\parsearg\sectionzzz} \def\infosubsection{\parsearg\subsectionzzz} \def\infosubsubsection{\parsearg\subsubsectionzzz} % These macros control what the section commands do, according % to what kind of chapter we are in (ordinary, appendix, or unnumbered). % Define them by default for a numbered chapter. \global\let\section = \numberedsec \global\let\subsection = \numberedsubsec \global\let\subsubsection = \numberedsubsubsec % Define @majorheading, @heading and @subheading % NOTE on use of \vbox for chapter headings, section headings, and such: % 1) We use \vbox rather than the earlier \line to permit % overlong headings to fold. % 2) \hyphenpenalty is set to 10000 because hyphenation in a % heading is obnoxious; this forbids it. % 3) Likewise, headings look best if no \parindent is used, and % if justification is not attempted. Hence \raggedright. \def\majorheading{\parsearg\majorheadingzzz} \def\majorheadingzzz #1{% {\advance\chapheadingskip by 10pt \chapbreak }% {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\penalty 200} \def\chapheading{\parsearg\chapheadingzzz} \def\chapheadingzzz #1{\chapbreak % {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\penalty 200} % @heading, @subheading, @subsubheading. \def\heading{\parsearg\plainsecheading} \def\subheading{\parsearg\plainsubsecheading} \def\subsubheading{\parsearg\plainsubsubsecheading} % These macros generate a chapter, section, etc. heading only % (including whitespace, linebreaking, etc. around it), % given all the information in convenient, parsed form. %%% Args are the skip and penalty (usually negative) \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} \def\setchapterstyle #1 {\csname CHAPF#1\endcsname} %%% Define plain chapter starts, and page on/off switching for it % Parameter controlling skip before chapter headings (if needed) \newskip\chapheadingskip \def\chapbreak{\dobreak \chapheadingskip {-4000}} \def\chappager{\par\vfill\supereject} \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} \def\CHAPPAGoff{% \global\let\contentsalignmacro = \chappager \global\let\pchapsepmacro=\chapbreak \global\let\pagealignmacro=\chappager} \def\CHAPPAGon{% \global\let\contentsalignmacro = \chappager \global\let\pchapsepmacro=\chappager \global\let\pagealignmacro=\chappager \global\def\HEADINGSon{\HEADINGSsingle}} \def\CHAPPAGodd{ \global\let\contentsalignmacro = \chapoddpage \global\let\pchapsepmacro=\chapoddpage \global\let\pagealignmacro=\chapoddpage \global\def\HEADINGSon{\HEADINGSdouble}} \CHAPPAGon \def\CHAPFplain{ \global\let\chapmacro=\chfplain \global\let\unnumbchapmacro=\unnchfplain \global\let\centerchapmacro=\centerchfplain} % Plain chapter opening. % #1 is the text, #2 the chapter number or empty if unnumbered. \def\chfplain#1#2{% \pchapsepmacro {% \chapfonts \rm \def\chapnum{#2}% \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}% \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright \hangindent = \wd0 \centerparametersmaybe \unhbox0 #1\par}% }% \nobreak\bigskip % no page break after a chapter title \nobreak } % Plain opening for unnumbered. \def\unnchfplain#1{\chfplain{#1}{}} % @centerchap -- centered and unnumbered. \let\centerparametersmaybe = \relax \def\centerchfplain#1{{% \def\centerparametersmaybe{% \advance\rightskip by 3\rightskip \leftskip = \rightskip \parfillskip = 0pt }% \chfplain{#1}{}% }} \CHAPFplain % The default \def\unnchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\nobreak } \def\chfopen #1#2{\chapoddpage {\chapfonts \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% \par\penalty 5000 % } \def\centerchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt \hfill {\rm #1}\hfill}}\bigskip \par\nobreak } \def\CHAPFopen{ \global\let\chapmacro=\chfopen \global\let\unnumbchapmacro=\unnchfopen \global\let\centerchapmacro=\centerchfopen} % Section titles. \newskip\secheadingskip \def\secheadingbreak{\dobreak \secheadingskip {-1000}} \def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}} \def\plainsecheading#1{\sectionheading{sec}{}{#1}} % Subsection titles. \newskip \subsecheadingskip \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} \def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}} \def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}} % Subsubsection titles. \let\subsubsecheadingskip = \subsecheadingskip \let\subsubsecheadingbreak = \subsecheadingbreak \def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}} \def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}} % Print any size section title. % % #1 is the section type (sec/subsec/subsubsec), #2 is the section % number (maybe empty), #3 the text. \def\sectionheading#1#2#3{% {% \expandafter\advance\csname #1headingskip\endcsname by \parskip \csname #1headingbreak\endcsname }% {% % Switch to the right set of fonts. \csname #1fonts\endcsname \rm % % Only insert the separating space if we have a section number. \def\secnum{#2}% \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}% % \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright \hangindent = \wd0 % zero if no section number \unhbox0 #3}% }% \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak } \message{toc,} \newwrite\tocfile % Write an entry to the toc file, opening it if necessary. % Called from @chapter, etc. We supply {\folio} at the end of the % argument, which will end up as the last argument to the \...entry macro. % % We open the .toc file here instead of at @setfilename or any other % given time so that @contents can be put in the document anywhere. % \newif\iftocfileopened \def\writetocentry#1{% \iftocfileopened\else \immediate\openout\tocfile = \jobname.toc \global\tocfileopenedtrue \fi \iflinks \write\tocfile{#1{\folio}}\fi } \newskip\contentsrightmargin \contentsrightmargin=1in \newcount\savepageno \newcount\lastnegativepageno \lastnegativepageno = -1 % Finish up the main text and prepare to read what we've written % to \tocfile. % \def\startcontents#1{% % If @setchapternewpage on, and @headings double, the contents should % start on an odd page, unlike chapters. Thus, we maintain % \contentsalignmacro in parallel with \pagealignmacro. % From: Torbjorn Granlund \contentsalignmacro \immediate\closeout\tocfile % % Don't need to put `Contents' or `Short Contents' in the headline. % It is abundantly clear what they are. \unnumbchapmacro{#1}\def\thischapter{}% \savepageno = \pageno \begingroup % Set up to handle contents files properly. \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 % We can't do this, because then an actual ^ in a section % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97. %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi \raggedbottom % Worry more about breakpoints than the bottom. \advance\hsize by -\contentsrightmargin % Don't use the full line length. % % Roman numerals for page numbers. \ifnum \pageno>0 \pageno = \lastnegativepageno \fi } % Normal (long) toc. \def\contents{% \startcontents{\putwordTableofContents}% \openin 1 \jobname.toc \ifeof 1 \else \closein 1 \input \jobname.toc \fi \vfill \eject \endgroup \lastnegativepageno = \pageno \pageno = \savepageno } % And just the chapters. \def\summarycontents{% \startcontents{\putwordShortContents}% % \let\chapentry = \shortchapentry \let\unnumbchapentry = \shortunnumberedentry % We want a true roman here for the page numbers. \secfonts \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl \rm \hyphenpenalty = 10000 \advance\baselineskip by 1pt % Open it up a little. \def\secentry ##1##2##3##4{} \def\unnumbsecentry ##1##2{} \def\subsecentry ##1##2##3##4##5{} \def\unnumbsubsecentry ##1##2{} \def\subsubsecentry ##1##2##3##4##5##6{} \def\unnumbsubsubsecentry ##1##2{} \openin 1 \jobname.toc \ifeof 1 \else \closein 1 \input \jobname.toc \fi \vfill \eject \endgroup \lastnegativepageno = \pageno \pageno = \savepageno } \let\shortcontents = \summarycontents % These macros generate individual entries in the table of contents. % The first argument is the chapter or section name. % The last argument is the page number. % The arguments in between are the chapter number, section number, ... % Chapter-level things, for both the long and short contents. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} % See comments in \dochapentry re vbox and related settings \def\shortchapentry#1#2#3{% \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% } % Typeset the label for a chapter or appendix for the short contents. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. % We could simplify the code here by writing out an \appendixentry % command in the toc file for appendices, instead of using \chapentry % for both, but it doesn't seem worth it. \setbox0 = \hbox{\shortcontrm \putwordAppendix } \newdimen\shortappendixwidth \shortappendixwidth = \wd0 \def\shortchaplabel#1{% % We typeset #1 in a box of constant width, regardless of the text of % #1, so the chapter titles will come out aligned. \setbox0 = \hbox{#1}% \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi % % This space should be plenty, since a single number is .5em, and the % widest letter (M) is 1em, at least in the Computer Modern fonts. % (This space doesn't include the extra space that gets added after % the label; that gets put in by \shortchapentry above.) \advance\dimen0 by 1.1em \hbox to \dimen0{#1\hfil}% } \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} % Sections. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} % Subsections. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} % And subsubsections. \def\subsubsecentry#1#2#3#4#5#6{% \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} % This parameter controls the indentation of the various levels. \newdimen\tocindent \tocindent = 3pc % Now for the actual typesetting. In all these, #1 is the text and #2 is the % page number. % % If the toc has to be broken over pages, we want it to be at chapters % if at all possible; hence the \penalty. \def\dochapentry#1#2{% \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip \begingroup \chapentryfonts \tocentry{#1}{\dopageno{#2}}% \endgroup \nobreak\vskip .25\baselineskip plus.1\baselineskip } \def\dosecentry#1#2{\begingroup \secentryfonts \leftskip=\tocindent \tocentry{#1}{\dopageno{#2}}% \endgroup} \def\dosubsecentry#1#2{\begingroup \subsecentryfonts \leftskip=2\tocindent \tocentry{#1}{\dopageno{#2}}% \endgroup} \def\dosubsubsecentry#1#2{\begingroup \subsubsecentryfonts \leftskip=3\tocindent \tocentry{#1}{\dopageno{#2}}% \endgroup} % Final typesetting of a toc entry; we use the same \entry macro as for % the index entries, but we want to suppress hyphenation here. (We % can't do that in the \entry macro, since index entries might consist % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) \def\tocentry#1#2{\begingroup \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks % Do not use \turnoffactive in these arguments. Since the toc is % typeset in cmr, so characters such as _ would come out wrong; we % have to do the usual translation tricks. \entry{#1}{#2}% \endgroup} % Space between chapter (or whatever) number and the title. \def\labelspace{\hskip1em \relax} \def\dopageno#1{{\rm #1}} \def\doshortpageno#1{{\rm #1}} \def\chapentryfonts{\secfonts \rm} \def\secentryfonts{\textfonts} \let\subsecentryfonts = \textfonts \let\subsubsecentryfonts = \textfonts \message{environments,} % Since these characters are used in examples, it should be an even number of % \tt widths. Each \tt character is 1en, so two makes it 1em. % Furthermore, these definitions must come after we define our fonts. \newbox\dblarrowbox \newbox\longdblarrowbox \newbox\pushcharbox \newbox\bullbox \newbox\equivbox \newbox\errorbox %{\tentt %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} % Adapted from the manmac format (p.420 of TeXbook) %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex % depth .1ex\hfil} %} % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. \def\point{$\star$} \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} % Adapted from the TeXbook's \boxit. {\tentt \global\dimen0 = 3em}% Width of the box. \dimen2 = .55pt % Thickness of rules % The text. (`r' is open on the right, `e' somewhat less so on the left.) \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} \global\setbox\errorbox=\hbox to \dimen0{\hfil \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. \advance\hsize by -2\dimen2 % Rules. \vbox{ \hrule height\dimen2 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. \kern3pt\vrule width\dimen2}% Space to right. \hrule height\dimen2} \hfil} % The @error{} command. \def\error{\leavevmode\lower.7ex\copy\errorbox} % @tex ... @end tex escapes into raw Tex temporarily. % One exception: @ is still an escape character, so that @end tex works. % But \@ or @@ will get a plain tex @ character. \def\tex{\begingroup \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie \catcode `\%=14 \catcode 43=12 % plus \catcode`\"=12 \catcode`\==12 \catcode`\|=12 \catcode`\<=12 \catcode`\>=12 \escapechar=`\\ % \let\b=\ptexb \let\bullet=\ptexbullet \let\c=\ptexc \let\,=\ptexcomma \let\.=\ptexdot \let\dots=\ptexdots \let\equiv=\ptexequiv \let\!=\ptexexclam \let\i=\ptexi \let\{=\ptexlbrace \let\+=\tabalign \let\}=\ptexrbrace \let\*=\ptexstar \let\t=\ptext % \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% \def\@{@}% \let\Etex=\endgroup} % Define @lisp ... @endlisp. % @lisp does a \begingroup so it can rebind things, % including the definition of @endlisp (which normally is erroneous). % Amount to narrow the margins by for @lisp. \newskip\lispnarrowing \lispnarrowing=0.4in % This is the definition that ^^M gets inside @lisp, @example, and other % such environments. \null is better than a space, since it doesn't % have any width. \def\lisppar{\null\endgraf} % Make each space character in the input produce a normal interword % space in the output. Don't allow a line break at this space, as this % is used only in environments like @example, where each line of input % should produce a line of output anyway. % {\obeyspaces % \gdef\sepspaces{\obeyspaces\let =\tie}} % Define \obeyedspace to be our active space, whatever it is. This is % for use in \parsearg. {\sepspaces% \global\let\obeyedspace= } % This space is always present above and below environments. \newskip\envskipamount \envskipamount = 0pt % Make spacing and below environment symmetrical. We use \parskip here % to help in doing that, since in @example-like environments \parskip % is reset to zero; thus the \afterenvbreak inserts no space -- but the % start of the next paragraph will insert \parskip % \def\aboveenvbreak{{\advance\envskipamount by \parskip \endgraf \ifdim\lastskip<\envskipamount \removelastskip \penalty-50 \vskip\envskipamount \fi}} \let\afterenvbreak = \aboveenvbreak % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. \let\nonarrowing=\relax % @cartouche ... @end cartouche: draw rectangle w/rounded corners around % environment contents. \font\circle=lcircle10 \newdimen\circthick \newdimen\cartouter\newdimen\cartinner \newskip\normbskip\newskip\normpskip\newskip\normlskip \circthick=\fontdimen8\circle % \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth \def\ctr{{\hskip 6pt\circle\char'010}} \def\cbl{{\circle\char'012\hskip -6pt}} \def\cbr{{\hskip 6pt\circle\char'011}} \def\carttop{\hbox to \cartouter{\hskip\lskip \ctl\leaders\hrule height\circthick\hfil\ctr \hskip\rskip}} \def\cartbot{\hbox to \cartouter{\hskip\lskip \cbl\leaders\hrule height\circthick\hfil\cbr \hskip\rskip}} % \newskip\lskip\newskip\rskip \long\def\cartouche{% \begingroup \lskip=\leftskip \rskip=\rightskip \leftskip=0pt\rightskip=0pt %we want these *outside*. \cartinner=\hsize \advance\cartinner by-\lskip \advance\cartinner by-\rskip \cartouter=\hsize \advance\cartouter by 18.4pt % allow for 3pt kerns on either % side, and for 6pt waste from % each corner char, and rule thickness \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip % Flag to tell @lisp, etc., not to narrow margin. \let\nonarrowing=\comment \vbox\bgroup \baselineskip=0pt\parskip=0pt\lineskip=0pt \carttop \hbox\bgroup \hskip\lskip \vrule\kern3pt \vbox\bgroup \hsize=\cartinner \kern3pt \begingroup \baselineskip=\normbskip \lineskip=\normlskip \parskip=\normpskip \vskip -\parskip \def\Ecartouche{% \endgroup \kern3pt \egroup \kern3pt\vrule \hskip\rskip \egroup \cartbot \egroup \endgroup }} % This macro is called at the beginning of all the @example variants, % inside a group. \def\nonfillstart{% \aboveenvbreak \inENV % This group ends at the end of the body \hfuzz = 12pt % Don't be fussy \sepspaces % Make spaces be word-separators rather than space tokens. \singlespace \let\par = \lisppar % don't ignore blank lines \obeylines % each line of input is a line of output \parskip = 0pt \parindent = 0pt \emergencystretch = 0pt % don't try to avoid overfull boxes % @cartouche defines \nonarrowing to inhibit narrowing % at next level down. \ifx\nonarrowing\relax \advance \leftskip by \lispnarrowing \exdentamount=\lispnarrowing \let\exdent=\nofillexdent \let\nonarrowing=\relax \fi } % Define the \E... control sequence only if we are inside the particular % environment, so the error checking in \end will work. % % To end an @example-like environment, we first end the paragraph (via % \afterenvbreak's vertical glue), and then the group. That way we keep % the zero \parskip that the environments set -- \parskip glue will be % inserted at the beginning of the next paragraph in the document, after % the environment. % \def\nonfillfinish{\afterenvbreak\endgroup} % @lisp: indented, narrowed, typewriter font. \def\lisp{\begingroup \nonfillstart \let\Elisp = \nonfillfinish \tt \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. \gobble % eat return } % @example: Same as @lisp. \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} % @small... is usually equivalent to the non-small (@smallbook % redefines). We must call \example (or whatever) last in the % definition, since it reads the return following the @example (or % whatever) command. % % This actually allows (for example) @end display inside an % @smalldisplay. Too bad, but makeinfo will catch the error anyway. % \def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display} \def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp} \def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format} \def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp} % Real @smallexample and @smalllisp (when @smallbook): use smaller fonts. % Originally contributed by Pavel@xerox. \def\smalllispx{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}% \def\Esmallexample{\nonfillfinish\endgroup}% \indexfonts \lisp } % @display: same as @lisp except keep current font. % \def\display{\begingroup \nonfillstart \let\Edisplay = \nonfillfinish \gobble } % @smalldisplay (when @smallbook): @display plus smaller fonts. % \def\smalldisplayx{\begingroup \def\Esmalldisplay{\nonfillfinish\endgroup}% \indexfonts \rm \display } % @format: same as @display except don't narrow margins. % \def\format{\begingroup \let\nonarrowing = t \nonfillstart \let\Eformat = \nonfillfinish \gobble } % @smallformat (when @smallbook): @format plus smaller fonts. % \def\smallformatx{\begingroup \def\Esmallformat{\nonfillfinish\endgroup}% \indexfonts \rm \format } % @flushleft (same as @format). % \def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format} % @flushright. % \def\flushright{\begingroup \let\nonarrowing = t \nonfillstart \let\Eflushright = \nonfillfinish \advance\leftskip by 0pt plus 1fill \gobble } % @quotation does normal linebreaking (hence we can't use \nonfillstart) % and narrows the margins. % \def\quotation{% \begingroup\inENV %This group ends at the end of the @quotation body {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip \singlespace \parindent=0pt % We have retained a nonzero parskip for the environment, since we're % doing normal filling. So to avoid extra space below the environment... \def\Equotation{\parskip = 0pt \nonfillfinish}% % % @cartouche defines \nonarrowing to inhibit narrowing at next level down. \ifx\nonarrowing\relax \advance\leftskip by \lispnarrowing \advance\rightskip by \lispnarrowing \exdentamount = \lispnarrowing \let\nonarrowing = \relax \fi } \message{defuns,} % Define formatter for defuns % First, allow user to change definition object font (\df) internally \def\setdeffont #1 {\csname DEF#1\endcsname} \newskip\defbodyindent \defbodyindent=.4in \newskip\defargsindent \defargsindent=50pt \newskip\deftypemargin \deftypemargin=12pt \newskip\deflastargmargin \deflastargmargin=18pt \newcount\parencount % define \functionparens, which makes ( and ) and & do special things. % \functionparens affects the group it is contained in. \def\activeparens{% \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active \catcode`\[=\active \catcode`\]=\active} % Make control sequences which act like normal parenthesis chars. \let\lparen = ( \let\rparen = ) {\activeparens % Now, smart parens don't turn on until &foo (see \amprm) % Be sure that we always have a definition for `(', etc. For example, % if the fn name has parens in it, \boldbrax will not be in effect yet, % so TeX would otherwise complain about undefined control sequence. \global\let(=\lparen \global\let)=\rparen \global\let[=\lbrack \global\let]=\rbrack \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} % This is used to turn on special parens % but make & act ordinary (given that it's active). \gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr} % Definitions of (, ) and & used in args for functions. % This is the definition of ( outside of all parentheses. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested \global\advance\parencount by 1 } % % This is the definition of ( when already inside a level of parens. \gdef\opnested{\char`\(\global\advance\parencount by 1 } % \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. % also in that case restore the outer-level definition of (. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi \global\advance \parencount by -1 } % If we encounter &foo, then turn on ()-hacking afterwards \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } % \gdef\normalparens{\boldbrax\let&=\ampnr} } % End of definition inside \activeparens %% These parens (in \boldbrax) actually are a little bolder than the %% contained text. This is especially needed for [ and ] \def\opnr{{\sf\char`\(}\global\advance\parencount by 1 } \def\clnr{{\sf\char`\)}\global\advance\parencount by -1 } \def\ampnr{\&} \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} % First, defname, which formats the header line itself. % #1 should be the function name. % #2 should be the type of definition, such as "Function". \def\defname #1#2{% % Get the values of \leftskip and \rightskip as they were % outside the @def... \dimen2=\leftskip \advance\dimen2 by -\defbodyindent \noindent \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations \parshape 2 0in \dimen0 \defargsindent \dimen1 % Now output arg 2 ("Function" or some such) % ending at \deftypemargin from the right margin, % but stuck inside a box of width 0 so it does not interfere with linebreaking {% Adjust \hsize to exclude the ambient margins, % so that \rightline will obey them. \advance \hsize by -\dimen2 \rlap{\rightline{{\rm #2}\hskip -1.25pc }}}% % Make all lines underfull and no complaints: \tolerance=10000 \hbadness=10000 \advance\leftskip by -\defbodyindent \exdentamount=\defbodyindent {\df #1}\enskip % Generate function name } % Actually process the body of a definition % #1 should be the terminating control sequence, such as \Edefun. % #2 should be the "another name" control sequence, such as \defunx. % #3 should be the control sequence that actually processes the header, % such as \defunheader. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2{\begingroup\obeylines\activeparens\spacesplit#3}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup % \catcode 61=\active % 61 is `=' \obeylines\activeparens\spacesplit#3} % #1 is the \E... control sequence to end the definition (which we define). % #2 is the \...x control sequence for consecutive fns (which we define). % #3 is the control sequence to call to resume processing. % #4, delimited by the space, is the class name. % \def\defmethparsebody#1#2#3#4 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#4}}} % @deftypemethod has an extra argument that nothing else does. Sigh. % #1 is the \E... control sequence to end the definition (which we define). % #2 is the \...x control sequence for consecutive fns (which we define). % #3 is the control sequence to call to resume processing. % #4, delimited by the space, is the class name. % #5 is the method's return type. % \def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}} \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 ##2 {\def#4{##1}% \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#5}}} % These parsing functions are similar to the preceding ones % except that they do not make parens into active characters. % These are used for "variables" since they have no arguments. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2{\begingroup\obeylines\spacesplit#3}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup % \catcode 61=\active % \obeylines\spacesplit#3} % This is used for \def{tp,vr}parsebody. It could probably be used for % some of the others, too, with some judicious conditionals. % \def\parsebodycommon#1#2#3{% \begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines } \def\defvrparsebody#1#2#3#4 {% \parsebodycommon{#1}{#2}{#3}% \spacesplit{#3{#4}}% } % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the % type is just `struct', because we lose the braces in `{struct % termios}' when \spacesplit reads its undelimited argument. Sigh. % \let\deftpparsebody=\defvrparsebody % % So, to get around this, we put \empty in with the type name. That % way, TeX won't find exactly `{...}' as an undelimited argument, and % won't strip off the braces. % \def\deftpparsebody #1#2#3#4 {% \parsebodycommon{#1}{#2}{#3}% \spacesplit{\parsetpheaderline{#3{#4}}}\empty } % Fine, but then we have to eventually remove the \empty *and* the % braces (if any). That's what this does. % \def\removeemptybraces\empty#1\relax{#1} % After \spacesplit has done its work, this is called -- #1 is the final % thing to call, #2 the type name (which starts with \empty), and #3 % (which might be empty) the arguments. % \def\parsetpheaderline#1#2#3{% #1{\removeemptybraces#2\relax}{#3}% }% \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 ##2 {\def#4{##1}% \begingroup\obeylines\spacesplit{#3{##2}}}% \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\spacesplit{#3{#5}}} % Split up #2 at the first space token. % call #1 with two arguments: % the first is all of #2 before the space token, % the second is all of #2 after that space token. % If #2 contains no space token, all of it is passed as the first arg % and the second is passed as empty. {\obeylines \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% \ifx\relax #3% #1{#2}{}\else #1{#2}{#3#4}\fi}} % So much for the things common to all kinds of definitions. % Define @defun. % First, define the processing that is wanted for arguments of \defun % Use this to expand the args and terminate the paragraph they make up \def\defunargs #1{\functionparens \sl % Expand, preventing hyphenation at `-' chars. % Note that groups don't affect changes in \hyphenchar. \hyphenchar\tensl=0 #1% \hyphenchar\tensl=45 \ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi% \interlinepenalty=10000 \advance\rightskip by 0pt plus 1fil \endgraf\nobreak\vskip -\parskip\nobreak } \def\deftypefunargs #1{% % Expand, preventing hyphenation at `-' chars. % Note that groups don't affect changes in \hyphenchar. % Use \boldbraxnoamp, not \functionparens, so that & is not special. \boldbraxnoamp \tclose{#1}% avoid \code because of side effects on active chars \interlinepenalty=10000 \advance\rightskip by 0pt plus 1fil \endgraf\nobreak\vskip -\parskip\nobreak } % Do complete processing of one @defun or @defunx line already parsed. % @deffn Command forward-char nchars \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @defun == @deffn Function \def\defun{\defparsebody\Edefun\defunx\defunheader} \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index \begingroup\defname {#1}{Function}% \defunargs {#2}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @deftypefun int foobar (int @var{foo}, float @var{bar}) \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} % #1 is the data type. #2 is the name and args. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} % #1 is the data type, #2 the name, #3 the args. \def\deftypefunheaderx #1#2 #3\relax{% \doind {fn}{\code{#2}}% Make entry in function index \begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}% \deftypefunargs {#3}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} % \defheaderxcond#1\relax$$$ % puts #1 in @code, followed by a space, but does nothing if #1 is null. \def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi} % #1 is the classification. #2 is the data type. #3 is the name and args. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} % #1 is the classification, #2 the data type, #3 the name, #4 the args. \def\deftypefnheaderx #1#2#3 #4\relax{% \doind {fn}{\code{#3}}% Make entry in function index \begingroup \normalparens % notably, turn off `&' magic, which prevents % at least some C++ text from working \defname {\defheaderxcond#2\relax$$$#3}{#1}% \deftypefunargs {#4}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @defmac == @deffn Macro \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index \begingroup\defname {#1}{Macro}% \defunargs {#2}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @defspec == @deffn Special Form \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index \begingroup\defname {#1}{Special Form}% \defunargs {#2}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % This definition is run if you use @defunx % anywhere other than immediately after a @defun or @defunx. \def\deffnx #1 {\errmessage{@deffnx in invalid context}} \def\defunx #1 {\errmessage{@defunx in invalid context}} \def\defmacx #1 {\errmessage{@defmacx in invalid context}} \def\defspecx #1 {\errmessage{@defspecx in invalid context}} \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} \def\deftypemethodx #1 {\errmessage{@deftypemethodx in invalid context}} \def\deftypefunx #1 {\errmessage{@deftypefunx in invalid context}} % @defmethod, and so on % @defop CATEGORY CLASS OPERATION ARG... \def\defop #1 {\def\defoptype{#1}% \defopparsebody\Edefop\defopx\defopheader\defoptype} \def\defopheader #1#2#3{% \dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index \begingroup\defname {#2}{\defoptype{} on #1}% \defunargs {#3}\endgroup % } % @deftypemethod CLASS RETURN-TYPE METHOD ARG... % \def\deftypemethod{% \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader} % % #1 is the class name, #2 the data type, #3 the method name, #4 the args. \def\deftypemethodheader#1#2#3#4{% \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index \begingroup \defname{\defheaderxcond#2\relax$$$#3}{\putwordMethodon\ \code{#1}}% \deftypefunargs{#4}% \endgroup } % @defmethod == @defop Method % \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} % % #1 is the class name, #2 the method name, #3 the args. \def\defmethodheader#1#2#3{% \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index \begingroup \defname{#2}{\putwordMethodon\ \code{#1}}% \defunargs{#3}% \endgroup } % @defcv {Class Option} foo-class foo-flag \def\defcv #1 {\def\defcvtype{#1}% \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} \def\defcvarheader #1#2#3{% \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index \begingroup\defname {#2}{\defcvtype{} of #1}% \defvarargs {#3}\endgroup % } % @defivar == @defcv {Instance Variable} \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} \def\defivarheader #1#2#3{% \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index \begingroup\defname {#2}{Instance Variable of #1}% \defvarargs {#3}\endgroup % } % These definitions are run if you use @defmethodx, etc., % anywhere other than immediately after a @defmethod, etc. \def\defopx #1 {\errmessage{@defopx in invalid context}} \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} \def\defcvx #1 {\errmessage{@defcvx in invalid context}} \def\defivarx #1 {\errmessage{@defivarx in invalid context}} % Now @defvar % First, define the processing that is wanted for arguments of @defvar. % This is actually simple: just print them in roman. % This must expand the args and terminate the paragraph they make up \def\defvarargs #1{\normalparens #1% \interlinepenalty=10000 \endgraf\nobreak\vskip -\parskip\nobreak} % @defvr Counter foo-count \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} % @defvar == @defvr Variable \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index \begingroup\defname {#1}{Variable}% \defvarargs {#2}\endgroup % } % @defopt == @defvr {User Option} \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index \begingroup\defname {#1}{User Option}% \defvarargs {#2}\endgroup % } % @deftypevar int foobar \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} % #1 is the data type. #2 is the name, perhaps followed by text that % is actually part of the data type, which should not be put into the index. \def\deftypevarheader #1#2{% \dovarind#2 \relax% Make entry in variables index \begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}% \interlinepenalty=10000 \endgraf\nobreak\vskip -\parskip\nobreak \endgroup} \def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}} % @deftypevr {Global Flag} int enable \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} \def\deftypevrheader #1#2#3{\dovarind#3 \relax% \begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1} \interlinepenalty=10000 \endgraf\nobreak\vskip -\parskip\nobreak \endgroup} % This definition is run if you use @defvarx % anywhere other than immediately after a @defvar or @defvarx. \def\defvrx #1 {\errmessage{@defvrx in invalid context}} \def\defvarx #1 {\errmessage{@defvarx in invalid context}} \def\defoptx #1 {\errmessage{@defoptx in invalid context}} \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} % Now define @deftp % Args are printed in bold, a slight difference from @defvar. \def\deftpargs #1{\bf \defvarargs{#1}} % @deftp Class window height width ... \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} % This definition is run if you use @deftpx, etc % anywhere other than immediately after a @deftp, etc. \def\deftpx #1 {\errmessage{@deftpx in invalid context}} \message{macros,} % @macro. % To do this right we need a feature of e-TeX, \scantokens, % which we arrange to emulate with a temporary file in ordinary TeX. \ifx\eTeXversion\undefined \newwrite\macscribble \def\scanmacro#1{% \begingroup \newlinechar`\^^M \immediate\openout\macscribble=\jobname.tmp \immediate\write\macscribble{#1}% \immediate\closeout\macscribble \let\xeatspaces\eatspaces \input \jobname.tmp \endgroup } \else \def\scanmacro#1{% \begingroup \newlinechar`\^^M \let\xeatspaces\eatspaces\scantokens{#1}\endgroup} \fi \newcount\paramno % Count of parameters \newtoks\macname % Macro name \newif\ifrecursive % Is it recursive? % Utility routines. % Thisdoes \let #1 = #2, except with \csnames. \def\cslet#1#2{% \expandafter\expandafter \expandafter\let \expandafter\expandafter \csname#1\endcsname \csname#2\endcsname} % Trim leading and trailing spaces off a string. % Concepts from aro-bend problem 15 (see CTAN). {\catcode`\@=11 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} \def\unbrace#1{#1} \unbrace{\gdef\trim@@@ #1 } #2@{#1} } % Trim a single trailing ^^M off a string. {\catcode`\^^M=12\catcode`\Q=3% \gdef\eatcr #1{\eatcra #1Q^^MQ}% \gdef\eatcra#1^^MQ{\eatcrb#1Q}% \gdef\eatcrb#1Q#2Q{#1}% } % Macro bodies are absorbed as an argument in a context where % all characters are catcode 10, 11 or 12, except \ which is active % (as in normal texinfo). It is necessary to change the definition of \. % It's necessary to have hard CRs when the macro is executed. This is % done by making ^^M (\endlinechar) catcode 12 when reading the macro % body, and then making it the \newlinechar in \scanmacro. \def\macrobodyctxt{% \catcode`\~=12 \catcode`\^=12 \catcode`\_=12 \catcode`\|=12 \catcode`\<=12 \catcode`\>=12 \catcode`\+=12 \catcode`\{=12 \catcode`\}=12 \catcode`\@=12 \catcode`\^^M=12 \usembodybackslash} \def\macroargctxt{% \catcode`\~=12 \catcode`\^=12 \catcode`\_=12 \catcode`\|=12 \catcode`\<=12 \catcode`\>=12 \catcode`\+=12 \catcode`\@=12 \catcode`\\=12} % \mbodybackslash is the definition of \ in @macro bodies. % It maps \foo\ => \csname macarg.foo\endcsname => #N % where N is the macro parameter number. % We define \csname macarg.\endcsname to be \realbackslash, so % \\ in macro replacement text gets you a backslash. {\catcode`@=0 @catcode`@\=@active @gdef@usembodybackslash{@let\=@mbodybackslash} @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} } \expandafter\def\csname macarg.\endcsname{\realbackslash} \def\macro{\recursivefalse\parsearg\macroxxx} \def\rmacro{\recursivetrue\parsearg\macroxxx} \def\macroxxx#1{% \getargs{#1}% now \macname is the macname and \argl the arglist \ifx\argl\empty % no arguments \paramno=0% \else \expandafter\parsemargdef \argl;% \fi \expandafter\ifx \csname macsave.\the\macname\endcsname \relax \cslet{macsave.\the\macname}{\the\macname}% \else \message{Warning: redefining \the\macname}% \fi \begingroup \macrobodyctxt \ifrecursive \expandafter\parsermacbody \else \expandafter\parsemacbody \fi} \def\unmacro{\parsearg\unmacroxxx} \def\unmacroxxx#1{% \expandafter\ifx \csname macsave.\the\macname\endcsname \relax \errmessage{Macro \the\macname\ not defined.}% \else \cslet{#1}{macsave.#1}% \expandafter\let \csname macsave.\the\macname\endcsname \undefined \fi } % This makes use of the obscure feature that if the last token of a % is #, then the preceding argument is delimited by % an opening brace, and that opening brace is not consumed. \def\getargs#1{\getargsxxx#1{}} \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} \def\getmacname #1 #2\relax{\macname={#1}} \def\getmacargs#1{\def\argl{#1}} % Parse the optional {params} list. Set up \paramno and \paramlist % so \defmacro knows what to do. Define \macarg.blah for each blah % in the params list, to be ##N where N is the position in that list. % That gets used by \mbodybackslash (above). % We need to get `macro parameter char #' into several definitions. % The technique used is stolen from LaTeX: let \hash be something % unexpandable, insert that wherever you need a #, and then redefine % it to # just before using the token list produced. % % The same technique is used to protect \eatspaces till just before % the macro is used. \def\parsemargdef#1;{\paramno=0\def\paramlist{}% \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} \def\parsemargdefxxx#1,{% \if#1;\let\next=\relax \else \let\next=\parsemargdefxxx \advance\paramno by 1% \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname {\xeatspaces{\hash\the\paramno}}% \edef\paramlist{\paramlist\hash\the\paramno,}% \fi\next} % These two commands read recursive and nonrecursive macro bodies. % (They're different since rec and nonrec macros end differently.) \long\def\parsemacbody#1@end macro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% \long\def\parsermacbody#1@end rmacro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% % This defines the macro itself. There are six cases: recursive and % nonrecursive macros of zero, one, and many arguments. % Much magic with \expandafter here. % \xdef is used so that macro definitions will survive the file % they're defined in; @include reads the file inside a group. \def\defmacro{% \let\hash=##% convert placeholders to macro parameter chars \ifrecursive \ifcase\paramno % 0 \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\scanmacro{\temp}}% \or % 1 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\braceorline\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup\noexpand\scanmacro{\temp}}% \else % many \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\csname\the\macname xx\endcsname} \expandafter\xdef\csname\the\macname xx\endcsname##1{% \csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter \csname\the\macname xxx\endcsname \paramlist{\egroup\noexpand\scanmacro{\temp}}% \fi \else \ifcase\paramno % 0 \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \or % 1 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\braceorline\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \else % many \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\csname\the\macname xx\endcsname} \expandafter\xdef\csname\the\macname xx\endcsname##1{% \csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter \csname\the\macname xxx\endcsname \paramlist{% \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \fi \fi} \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} % \braceorline decides whether the next nonwhitespace character is a % {. If so it reads up to the closing }, if not, it reads the whole % line. Whatever was read is then fed to the next control sequence % as an argument (by \parsebrace or \parsearg) \def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx} \def\braceorlinexxx{% \ifx\nchar\bgroup\else \expandafter\parsearg \fi \next} \message{cross references,} \newwrite\auxfile \newif\ifhavexrefs % True if xref values are known. \newif\ifwarnedxrefs % True if we warned once that they aren't known. % @inforef is relatively simple. \def\inforef #1{\inforefzzz #1,,,,**} \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, node \samp{\ignorespaces#1{}}} % @node's job is to define \lastnode. \def\node{\ENVcheck\parsearg\nodezzz} \def\nodezzz#1{\nodexxx [#1,]} \def\nodexxx[#1,#2]{\gdef\lastnode{#1}} \let\nwnode=\node \let\lastnode=\relax % The sectioning commands (@chapter, etc.) call these. \def\donoderef{% \ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}% {Ysectionnumberandtype}% \global\let\lastnode=\relax \fi } \def\unnumbnoderef{% \ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}% \global\let\lastnode=\relax \fi } \def\appendixnoderef{% \ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}% {Yappendixletterandtype}% \global\let\lastnode=\relax \fi } % @anchor{NAME} -- define xref target at arbitrary point. % \def\anchor#1{\setref{#1}{Ynothing}} % \setref{NAME}{SNT} defines a cross-reference point NAME, namely % NAME-title, NAME-pg, and NAME-SNT. Called from \foonoderef. We have % to set \indexdummies so commands such as @code in a section title % aren't expanded. It would be nicer not to expand the titles in the % first place, but there's so many layers that that is hard to do. % \def\setref#1#2{{% \indexdummies \dosetq{#1-title}{Ytitle}% \dosetq{#1-pg}{Ypagenumber}% \dosetq{#1-snt}{#2} }} % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is % the node name, #2 the name of the Info cross-reference, #3 the printed % node name, #4 the name of the Info file, #5 the name of the printed % manual. All but the node name can be omitted. % \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} \def\ref#1{\xrefX[#1,,,,,,,]} \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup \def\printedmanual{\ignorespaces #5}% \def\printednodename{\ignorespaces #3}% \setbox1=\hbox{\printedmanual}% \setbox0=\hbox{\printednodename}% \ifdim \wd0 = 0pt % No printed node name was explicitly given. \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax % Use the node name inside the square brackets. \def\printednodename{\ignorespaces #1}% \else % Use the actual chapter/section title appear inside % the square brackets. Use the real section title if we have it. \ifdim \wd1 > 0pt % It is in another manual, so we don't have it. \def\printednodename{\ignorespaces #1}% \else \ifhavexrefs % We know the real title if we have the xref values. \def\printednodename{\refx{#1-title}{}}% \else % Otherwise just copy the Info node name. \def\printednodename{\ignorespaces #1}% \fi% \fi \fi \fi % % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not % insert empty discretionaries after hyphens, which means that it will % not find a line break at a hyphen in a node names. Since some manuals % are best written with fairly long node names, containing hyphens, this % is a loss. Therefore, we give the text of the node name again, so it % is as if TeX is seeing it for the first time. \ifdim \wd1 > 0pt \putwordsection{} ``\printednodename'' in \cite{\printedmanual}% \else % _ (for example) has to be the character _ for the purposes of the % control sequence corresponding to the node, but it has to expand % into the usual \leavevmode...\vrule stuff for purposes of % printing. So we \turnoffactive for the \refx-snt, back on for the % printing, back off for the \refx-pg. {\normalturnoffactive % Only output a following space if the -snt ref is nonempty; for % @unnumbered and @anchor, it won't be. \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi }% % [mynode], [\printednodename],\space % page 3 \turnoffactive \putwordpage\tie\refx{#1-pg}{}% \fi \endgroup} % \dosetq is the interface for calls from other macros % Use \normalturnoffactive so that punctuation chars such as underscore % and backslash work in node names. (\turnoffactive doesn't do \.) \def\dosetq#1#2{% {\let\folio=0 \normalturnoffactive \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}% \iflinks \next \fi }% } % \internalsetq {foo}{page} expands into % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} % When the aux file is read, ' is the escape character \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} % Things to be expanded by \internalsetq \def\Ypagenumber{\folio} \def\Ytitle{\thissection} \def\Ynothing{} \def\Ysectionnumberandtype{% \ifnum\secno=0 \putwordChapter\xreftie\the\chapno % \else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno % \else \ifnum \subsubsecno=0 % \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno % \else % \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % \fi \fi \fi } \def\Yappendixletterandtype{% \ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}% \else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno % \else \ifnum \subsubsecno=0 % \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno % \else % \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % \fi \fi \fi } \gdef\xreftie{'tie} % Use TeX 3.0's \inputlineno to get the line number, for better error % messages, but if we're using an old version of TeX, don't do anything. % \ifx\inputlineno\thisisundefined \let\linenumber = \empty % Non-3.0. \else \def\linenumber{\the\inputlineno:\space} \fi % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. % If its value is nonempty, SUFFIX is output afterward. \def\refx#1#2{% \expandafter\ifx\csname X#1\endcsname\relax % If not defined, say something at least. \angleleft un\-de\-fined\angleright \iflinks \ifhavexrefs \message{\linenumber Undefined cross reference `#1'.}% \else \ifwarnedxrefs\else \global\warnedxrefstrue \message{Cross reference values unknown; you must run TeX again.}% \fi \fi \fi \else % It's defined, so just use it. \csname X#1\endcsname \fi #2% Output the suffix in any case. } % This is the macro invoked by entries in the aux file. % \def\xrdef#1{\begingroup % Reenable \ as an escape while reading the second argument. \catcode`\\ = 0 \afterassignment\endgroup \expandafter\gdef\csname X#1\endcsname } % Read the last existing aux file, if any. No error if none exists. \def\readauxfile{\begingroup \catcode`\^^@=\other \catcode`\^^A=\other \catcode`\^^B=\other \catcode`\^^C=\other \catcode`\^^D=\other \catcode`\^^E=\other \catcode`\^^F=\other \catcode`\^^G=\other \catcode`\^^H=\other \catcode`\^^K=\other \catcode`\^^L=\other \catcode`\^^N=\other \catcode`\^^P=\other \catcode`\^^Q=\other \catcode`\^^R=\other \catcode`\^^S=\other \catcode`\^^T=\other \catcode`\^^U=\other \catcode`\^^V=\other \catcode`\^^W=\other \catcode`\^^X=\other \catcode`\^^Z=\other \catcode`\^^[=\other \catcode`\^^\=\other \catcode`\^^]=\other \catcode`\^^^=\other \catcode`\^^_=\other \catcode`\@=\other \catcode`\^=\other % It was suggested to define this as 7, which would allow ^^e4 etc. % in xref tags, i.e., node names. But since ^^e4 notation isn't % supported in the main text, it doesn't seem desirable. Furthermore, % that is not enough: for node names that actually contain a ^ % character, we would end up writing a line like this: 'xrdef {'hat % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first % argument, and \hat is not an expandable control sequence. It could % all be worked out, but why? Either we support ^^ or we don't. % % The other change necessary for this was to define \auxhat: % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter % and then to call \auxhat in \setq. % \catcode`\~=\other \catcode`\[=\other \catcode`\]=\other \catcode`\"=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode`\$=\other \catcode`\#=\other \catcode`\&=\other \catcode`+=\other % avoid \+ for paranoia even though we've turned it off % Make the characters 128-255 be printing characters {% \count 1=128 \def\loop{% \catcode\count 1=\other \advance\count 1 by 1 \ifnum \count 1<256 \loop \fi }% }% % The aux file uses ' as the escape (for now). % Turn off \ as an escape so we do not lose on % entries which were dumped with control sequences in their names. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ % Reference to such entries still does not work the way one would wish, % but at least they do not bomb out when the aux file is read in. \catcode`\{=1 \catcode`\}=2 \catcode`\%=\other \catcode`\'=0 \catcode`\\=\other % \openin 1 \jobname.aux \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue \global\warnedobstrue \fi % Open the new aux file. TeX will close it automatically at exit. \openout\auxfile=\jobname.aux \endgroup} % Footnotes. \newcount \footnoteno % The trailing space in the following definition for supereject is % vital for proper filling; pages come out unaligned when you do a % pagealignmacro call if that space before the closing brace is % removed. (Generally, numeric constants should always be followed by a % space to prevent strange expansion errors.) \def\supereject{\par\penalty -20000\footnoteno =0 } % @footnotestyle is meaningful for info output only. \let\footnotestyle=\comment \let\ptexfootnote=\footnote {\catcode `\@=11 % % Auto-number footnotes. Otherwise like plain. \gdef\footnote{% \global\advance\footnoteno by \@ne \edef\thisfootno{$^{\the\footnoteno}$}% % % In case the footnote comes at the end of a sentence, preserve the % extra spacing after we do the footnote number. \let\@sf\empty \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi % % Remove inadvertent blank space before typesetting the footnote number. \unskip \thisfootno\@sf \footnotezzz }% % Don't bother with the trickery in plain.tex to not require the % footnote text as a parameter. Our footnotes don't need to be so general. % % Oh yes, they do; otherwise, @ifset and anything else that uses % \parseargline fail inside footnotes because the tokens are fixed when % the footnote is read. --karl, 16nov96. % \long\gdef\footnotezzz{\insert\footins\bgroup % We want to typeset this text as a normal paragraph, even if the % footnote reference occurs in (for example) a display environment. % So reset some parameters. \interlinepenalty\interfootnotelinepenalty \splittopskip\ht\strutbox % top baseline for broken footnotes \splitmaxdepth\dp\strutbox \floatingpenalty\@MM \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip \parindent\defaultparindent % % Hang the footnote text off the number. \hang \textindent{\thisfootno}% % % Don't crash into the line above the footnote text. Since this % expands into a box, it must come within the paragraph, lest it % provide a place where TeX can split the footnote. \footstrut \futurelet\next\fo@t } \def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t \else\let\next\f@t\fi \next} \def\f@@t{\bgroup\aftergroup\@foot\let\next} \def\f@t#1{#1\@foot} \def\@foot{\strut\egroup} }%end \catcode `\@=11 % Set the baselineskip to #1, and the lineskip and strut size % correspondingly. There is no deep meaning behind these magic numbers % used as factors; they just match (closely enough) what Knuth defined. % \def\lineskipfactor{.08333} \def\strutheightpercent{.70833} \def\strutdepthpercent {.29167} % \def\setleading#1{% \normalbaselineskip = #1\relax \normallineskip = \lineskipfactor\normalbaselineskip \normalbaselines \setbox\strutbox =\hbox{% \vrule width0pt height\strutheightpercent\baselineskip depth \strutdepthpercent \baselineskip }% } % @| inserts a changebar to the left of the current line. It should % surround any changed text. This approach does *not* work if the % change spans more than two lines of output. To handle that, we would % have adopt a much more difficult approach (putting marks into the main % vertical list for the beginning and end of each change). % \def\|{% % \vadjust can only be used in horizontal mode. \leavevmode % % Append this vertical mode material after the current line in the output. \vadjust{% % We want to insert a rule with the height and depth of the current % leading; that is exactly what \strutbox is supposed to record. \vskip-\baselineskip % % \vadjust-items are inserted at the left edge of the type. So % the \llap here moves out into the left-hand margin. \llap{% % % For a thicker or thinner bar, change the `1pt'. \vrule height\baselineskip width1pt % % This is the space between the bar and the text. \hskip 12pt }% }% } % For a final copy, take out the rectangles % that mark overfull boxes (in case you have decided % that the text looks ok even though it passes the margin). % \def\finalout{\overfullrule=0pt} % @image. We use the macros from epsf.tex to support this. % If epsf.tex is not installed and @image is used, we complain. % % Check for and read epsf.tex up front. If we read it only at @image % time, we might be inside a group, and then its definitions would get % undone and the next image would fail. \openin 1 = epsf.tex \ifeof 1 \else \closein 1 % Do not bother showing banner with post-v2.7 epsf.tex (available in % doc/epsf.tex until it shows up on ctan). \def\epsfannounce{\toks0 = }% \input epsf.tex \fi % \newif\ifwarnednoepsf \newhelp\noepsfhelp{epsf.tex must be installed for images to work. It is also included in the Texinfo distribution, or you can get it from ftp://ftp.tug.org/tex/epsf.tex.} % % Only complain once about lack of epsf.tex. \def\image#1{% \ifx\epsfbox\undefined \ifwarnednoepsf \else \errhelp = \noepsfhelp \errmessage{epsf.tex not found, images will be ignored}% \global\warnednoepsftrue \fi \else \imagexxx #1,,,\finish \fi } % % Arguments to @image: % #1 is (mandatory) image filename; we tack on .eps extension. % #2 is (optional) width, #3 is (optional) height. % #4 is just the usual extra ignored arg for parsing this stuff. \def\imagexxx#1,#2,#3,#4\finish{% % \epsfbox itself resets \epsf?size at each figure. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi % If the image is by itself, center it. \ifvmode \nobreak\medskip \nobreak \centerline{\epsfbox{#1.eps}}% \bigbreak \else \epsfbox{#1.eps}% \fi } \message{paper sizes,} % And other related parameters. \newdimen\defaultparindent \defaultparindent = 15pt \chapheadingskip = 15pt plus 4pt minus 2pt \secheadingskip = 12pt plus 3pt minus 2pt \subsecheadingskip = 9pt plus 2pt minus 2pt % Prevent underfull vbox error messages. \vbadness = 10000 % Don't be so finicky about underfull hboxes, either. \hbadness = 2000 % Following George Bush, just get rid of widows and orphans. \widowpenalty=10000 \clubpenalty=10000 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're % using an old version of TeX, don't do anything. We want the amount of % stretch added to depend on the line length, hence the dependence on % \hsize. This makes it come to about 9pt for the 8.5x11 format. We % call this whenever the paper size is set. % \def\setemergencystretch{% \ifx\emergencystretch\thisisundefined % Allow us to assign to \emergencystretch anyway. \def\emergencystretch{\dimen0}% \else \emergencystretch = \hsize \divide\emergencystretch by 45 \fi } % Parameters in order: 1) textheight; 2) textwidth; 3) voffset; % 4) hoffset; 5) binding offset; 6) topskip. Then whoever calls us can % set \parskip and call \setleading for \baselineskip. % \def\internalpagesizes#1#2#3#4#5#6{% \voffset = #3\relax \topskip = #6\relax \splittopskip = \topskip % \vsize = #1\relax \advance\vsize by \topskip \outervsize = \vsize \advance\outervsize by 2\topandbottommargin \pageheight = \vsize % \hsize = #2\relax \outerhsize = \hsize \advance\outerhsize by 0.5in \pagewidth = \hsize % \normaloffset = #4\relax \bindingoffset = #5\relax % \parindent = \defaultparindent \setemergencystretch } % @letterpaper (the default). \def\letterpaper{{\globaldefs = 1 \parskip = 3pt plus 2pt minus 1pt \setleading{13.2pt}% % % If page is nothing but text, make it come out even. \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}% }} % Use @smallbook to reset parameters for 7x9.5 (or so) format. \def\smallbook{{\globaldefs = 1 \parskip = 2pt plus 1pt \setleading{12pt}% % \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}% % \lispnarrowing = 0.3in \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt \deftypemargin = 0pt \defbodyindent = .5cm % \let\smalldisplay = \smalldisplayx \let\smallexample = \smalllispx \let\smallformat = \smallformatx \let\smalllisp = \smalllispx }} % Use @afourpaper to print on European A4 paper. \def\afourpaper{{\globaldefs = 1 \setleading{12pt}% \parskip = 3pt plus 2pt minus 1pt % \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}% % \tolerance = 700 \hfuzz = 1pt }} % A specific text layout, 24x15cm overall, intended for A4 paper. Top margin % 29mm, hence bottom margin 28mm, nominal side margin 3cm. \def\afourlatex{{\globaldefs = 1 \setleading{13.6pt}% % \afourpaper \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}% % \globaldefs = 0 }} % Use @afourwide to print on European A4 paper in wide format. \def\afourwide{% \afourpaper \internalpagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}% % \globaldefs = 0 } % @pagesizes TEXTHEIGHT[,TEXTWIDTH] % Perhaps we should allow setting the margins, \topskip, \parskip, % and/or leading, also. Or perhaps we should compute them somehow. % \def\pagesizes{\parsearg\pagesizesxxx} \def\pagesizesxxx#1{\pagesizesyyy #1,,\finish} \def\pagesizesyyy#1,#2,#3\finish{{% \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi \globaldefs = 1 % \parskip = 3pt plus 2pt minus 1pt \setleading{13.2pt}% % \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}% }} % Set default to letter. % \letterpaper \message{and turning on texinfo input format.} % Define macros to output various characters with catcode for normal text. \catcode`\"=\other \catcode`\~=\other \catcode`\^=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode`\+=\other \def\normaldoublequote{"} \def\normaltilde{~} \def\normalcaret{^} \def\normalunderscore{_} \def\normalverticalbar{|} \def\normalless{<} \def\normalgreater{>} \def\normalplus{+} % This macro is used to make a character print one way in ttfont % where it can probably just be output, and another way in other fonts, % where something hairier probably needs to be done. % % #1 is what to print if we are indeed using \tt; #2 is what to print % otherwise. Since all the Computer Modern typewriter fonts have zero % interword stretch (and shrink), and it is reasonable to expect all % typewriter fonts to have this, we can check that font parameter. % \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} % Turn off all special characters except @ % (and those which the user can use as if they were ordinary). % Most of these we simply print from the \tt font, but for some, we can % use math or other variants that look better in normal text. \catcode`\"=\active \def\activedoublequote{{\tt\char34}} \let"=\activedoublequote \catcode`\~=\active \def~{{\tt\char126}} \chardef\hat=`\^ \catcode`\^=\active \def^{{\tt \hat}} \catcode`\_=\active \def_{\ifusingtt\normalunderscore\_} % Subroutine for the previous macro. \def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}} \catcode`\|=\active \def|{{\tt\char124}} \chardef \less=`\< \catcode`\<=\active \def<{{\tt \less}} \chardef \gtr=`\> \catcode`\>=\active \def>{{\tt \gtr}} \catcode`\+=\active \def+{{\tt \char 43}} %\catcode 27=\active %\def^^[{$\diamondsuit$} % Set up an active definition for =, but don't enable it most of the time. {\catcode`\==\active \global\def={{\tt \char 61}}} \catcode`+=\active \catcode`\_=\active % If a .fmt file is being used, characters that might appear in a file % name cannot be active until we have parsed the command line. % So turn them off again, and have \everyjob (or @setfilename) turn them on. % \otherifyactive is called near the end of this file. \def\otherifyactive{\catcode`+=\other \catcode`\_=\other} \catcode`\@=0 % \rawbackslashxx output one backslash character in current font \global\chardef\rawbackslashxx=`\\ %{\catcode`\\=\other %@gdef@rawbackslashxx{\}} % \rawbackslash redefines \ as input to do \rawbackslashxx. {\catcode`\\=\active @gdef@rawbackslash{@let\=@rawbackslashxx }} % \normalbackslash outputs one backslash in fixed width font. \def\normalbackslash{{\tt\rawbackslashxx}} % Say @foo, not \foo, in error messages. \escapechar=`\@ % \catcode 17=0 % Define control-q \catcode`\\=\active % Used sometimes to turn off (effectively) the active characters % even after parsing them. @def@turnoffactive{@let"=@normaldoublequote @let\=@realbackslash @let~=@normaltilde @let^=@normalcaret @let_=@normalunderscore @let|=@normalverticalbar @let<=@normalless @let>=@normalgreater @let+=@normalplus} @def@normalturnoffactive{@let"=@normaldoublequote @let\=@normalbackslash @let~=@normaltilde @let^=@normalcaret @let_=@normalunderscore @let|=@normalverticalbar @let<=@normalless @let>=@normalgreater @let+=@normalplus} % Make _ and + \other characters, temporarily. % This is canceled by @fixbackslash. @otherifyactive % If a .fmt file is being used, we don't want the `\input texinfo' to show up. % That is what \eatinput is for; after that, the `\' should revert to printing % a backslash. % @gdef@eatinput input texinfo{@fixbackslash} @global@let\ = @eatinput % On the other hand, perhaps the file did not have a `\input texinfo'. Then % the first `\{ in the file would cause an error. This macro tries to fix % that, assuming it is called before the first `\' could plausibly occur. % Also back turn on active characters that might appear in the input % file name, in case not using a pre-dumped format. % @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi @catcode`+=@active @catcode`@_=@active} % These look ok in all fonts, so just make them not special. The @rm below % makes sure that the current font starts out as the newly loaded cmr10 @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other @textfonts @rm @c Local variables: @c eval: (add-hook 'write-file-hooks 'time-stamp) @c page-delimiter: "^\\\\message" @c time-stamp-start: "def\\\\texinfoversion{" @c time-stamp-format: "%:y-%02m-%02d" @c time-stamp-end: "}" @c End: ncurses-hexedit-0.9.7.orig/docs/hexedit.texinfo0100644000175000017500000006304506710145342020221 0ustar apocapoc\input texinfo @c -*-texinfo-*- @c %**start of header @setfilename hexedit.info @settitle Ncurses Hexedit @c %**end of header @ifinfo [N]Curses Hexedit Manual Copyright (C) 1999 Adam Rogoyski @end ifinfo @titlepage @title [N]Curses Hexedit @subtitle The hexedit manual @author Adam Rogoyski @page @vskip 0pt plus 1filll Copyright @copyright{} 1999 Adam Rogoyski Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified version, except that this permission notice may be stated in a translation approved by the Free Software Foundation. @end titlepage @node Top, Introduction, (dir), (dir) @menu * Introduction:: About hexedit, the author, and life in general. * Getting Started:: Getting hexedit, compiling, running. * Program Operations:: Program usage and commands. @end menu @node Introduction, Getting Started, Top, Top @chapter Introduction @menu * What is Hexedit:: Brief intro to the program. * Copyright and License:: Terms of copying. * Author:: Info about me. * Feedback and Bugs:: When to contact me. * Contributions:: Who's helped so far. @end menu @node What is Hexedit, Copyright and License, , Introduction @section What is Hexedit? @strong{hexedit} is a Curses based Hex editor. Unlike a text editor, which is used for editing text documents in the desired language, @strong{hexedit} lets you edit any file as it's byte@footnote{I assume a byte is an 8-bit octet. If this is not the case, I really recommend NOT using this program.} for byte representation. It can even let you view and edit your fixed disks on your Linux system. This is not ideal for writing a letter or writing c code, but there are my times when this is ideal: @itemize @bullet @item Editing binary executables. @item Editing your fixed disks (i.e. /dev/hda) @item Checking the output of a Program's binary data file. @item Any place you might use od(1) but need more power. Compare more vs less. @item Any other time you find this useful (tell me). @end itemize @node Copyright and License, Author, What is Hexedit, Introduction @section Copyright and License @strong{[N]Curses Hexedit} Copyright @copyright{} 1998,1999 Adam Rogoyski @* @ @* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as publish by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.@* @ @* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.@* @ @* You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA @node Author, Feedback and Bugs, Copyright and License, Introduction @section Author @strong{[N]Curses Hexedit} was written by Adam Rogoyski@footnote{Email me at apoc@@laker.net}@footnote{There is a picture of me at http://profiles.yahoo.com/rogoyski/}. At the time of writting (December 1998) I am a Sophomore of Computer Science at the University of Texas at Austin. I use Debian GNU/Linux and OpenBSD, I enjoy playing electric guitar, and I currently reside Pflugerville, Texas USA. My heroes are Richard Stallman, Stevie Ray Vaughan, and Lisa Loeb. @node Feedback and Bugs, Contributions, Author, Introduction @section Feedback and Bugs Astounding as it may be, there quite possibly are bugs in @strong{hexedit}. You can do your share to help Free Software@footnote{http://www.gnu.org/philosophy/free-sw.html} be robust and secure by telling me about any problems you find. Patches are even better. General feedback is appreciated as well, if only to tell me that @strong{hexedit} saved the day again, or that my obscure program wasted half your day when you already knew how to use emacs (M-x hexl-mode) in the first place.@* @ @* I can be reached at @emph{apoc@@laker.net} @node Contributions, , Feedback and Bugs, Introduction @section Contributions The following people contributed valuable feedback and information @itemize @bullet @item John Gatewood Ham: Gave some tips for the documentation. @item Cort (unknown): Idea for Undo. @item Matt Noel: EBCDIC support and spacing. Countless suggestions and ideas. @item Everyone else who mailed me and told me things that broke and gave suggestions. @end itemize @node Getting Started, Program Operations, Introduction, Top @chapter Getting Started @menu * Obtaining Source:: Where to find hexedit. * Obtaining Binaries:: Where to find binaries. * Building from Source:: What to do to build hexedit. * Command Line Invocation:: starting from the shell. @end menu @node Obtaining Source, Obtaining Binaries, , Getting Started @section Obtaining Source The latest source tar'd and gzip'd can be obtained at@* @emph{http://ccwf.cc.utexas.edu/~apoc/programs/c/hexedit/}@* and also from everyone's favorite ftp site@* @emph{ftp://metalab.unc.edu/pub/Linux/apps/editors/terminal/}@* If you do not know what tar and gzip are, and are using a DOS derived OS, @xref{Obtaining Binaries}. @node Obtaining Binaries, Building from Source, Obtaining Source, Getting Started @section Obtaining Binaries Pre-compiled statically linked binaries can be obtained for the following operating systems: i386 Linux, i386 OpenBSD, and DOS. The location for these is:@* @emph{http://ccwf.cc.utexas.edu/~apoc/programs/c/hexedit/} I've Built and tested hexedit on the following platforms: @itemize @bullet @item Linux 2.0.36 i386 ncurses 4.2 (gcc) @item Linux 2.2.6 i386 ncurses 4.2 (gcc) @item OpenBSD 2.4 i386 ncurses (gcc) @item SunOS 5.6 Sparc curses (gcc) @item AIX 4.3.2 rs6000 curses (gcc and cc) @item AIX 4.3.2 ppc curses (gcc and cc) @item DOS 6.22 i386 pdcurses (djgpp gcc) @item IRIX 6.3 mips curses (gcc) @item HP-UX B.10.20 curses (gcc) @item SunOS 5.5.1 sparc curses (gcc) @item OSF V4.0 alpha curses (gcc) @end itemize @node Building from Source, Command Line Invocation, Obtaining Binaries, Getting Started @section Building from Source Building from source should be very strait forward. I used the GNU configure system (autoconf and automake) so, like any GNU compliant program, the sequence @example ./configure make make install @end example should be all that's needed to install the package. Additional options may need to be given to configure, check INSTALL for such options. @subsection i386 Linux I extremely recommend you upgrade to ncurses 4.2 for hexedit to work. It should work with all versions, but resizing in an xterm seems to work better with the newest release. The latest ncurses can be obtained at the nearest GNU ftp archive (or ftp://ftp.gnu.org/pub/gnu/). @subsection i386 OpenBSD OpenBSD 2.4 I believe comes with ncurses, and it worked fine at my end. @subsection rs/6000 AIX 4.3 I belive I've fixed the previous AIX problems I was having. Let me know if anything else turns up. @node Command Line Invocation, , Building from Source, Getting Started @section Command Line Invocation Basic program usage is as follows:@* @example @strong{hexedit} [@emph{flags}] [@emph{filename}]@* @end example Where filename is the file which you wish to edit. Additionally, starting the program with no file@* @example @strong{hexedit} [@emph{flags}]@* @end example will bring up the file selection widget which will allow you to browse for the file. The command line arguments which are supported are@* -h, --help Prints help.@* -8, --highbit Allows displaying of high order bit text.@* -a, --alltext Allows displaying of all text (probably bad idea).@* -b, --buffer Buffer the entire file into memory.@* -d, --disk View a fixed disk (Linux only).@* -f, --force Allow editing of disk (Linux only).@* -q, --quiet No Beeping!@* -r, --readonly Prevents modifying the file.@* -v, --version Prints version number.@* @* Defaults may be specified in the HEXEDIT environment variable, i.e.@* sh: @emph{export HEXEDIT=-8r}@* csh: @emph{setenv HEXEDIT=-8r}@* @node Program Operations, , Getting Started, Top @chapter Program Operations @menu * Choosing a file:: How to select a file to edit. * Choosing a fixed disk:: How to select a fixed disk to view/edit. * Windows:: Descriptions of the various windows. * Moving About:: How to traverse the file. * Editing:: Editing procedures. * Undo:: Fixing mistakes. * Searching:: Locating specific strings. * Quit:: Exiting the editor. * Save:: Commiting changes to disk. * Save and Quit:: Commiting changes with exit. * Redraw:: Refreshing the screen. * View as Text:: Take an text snapshot of offset. * Ascii <=> EBCDIC:: Switch between text representations * Switch Spacings:: Change the way the bytes are grouped * Binary Calculator:: Base conversions. * Help:: Accessing online help. @end menu @node Choosing a file, Choosing a fixed disk, , Program Operations @section Choosing a file Before editing can begin, you much select a file to edit. This can be done on the command line: @example hexedit filename @end example Quite possibly, you may not remember the location of the file you wish to edit, or you may wish to browse over many possible files availible to find the file you are looking for. Hexedit comes equipted with a full screen file/directory browser which enables you to specify the file you wish to edit. Not specifying any file on the command line: @example hexedit @end example will bring up the file selection browser. Choosing (pressing enter) a directory will open that directory for viewing. Choosing a file will open that file in the editor. @node Choosing a fixed disk, Windows, Choosing a file, Program Operations @section Choosing a fixed disk. Hexedit, when run in Linux, permits access to read and edit fixed disks (i.e /dev/hda). Using the @emph{-d} option will allow you to edit a disk. Currently, the disk can be only up to 4.2 gigs, but this will probably change in a future release.@* By default, editing a disk will put you in read-only mode. This is for your own protection. If you really think you know what you are doing, issue the @emph{-f} flag and it will force edit mode for the disk and allow you to make changes to your disk. Use this with @strong{EXTREME CAUTION!} If you make a mistake to your boot sector, erase a few important inodes, or hit the wrong keystroke, you could be seriously out of luck. It is really easy to put your disk in an unusable state. Also, remember that the disk could very well be changing as you look at it. So the next time you view a chunk, it may be different, or even the chunk you are currently viewing may have changed on disk since you read it into the editor's buffer. So be careful if you want to edit a mounted disk.@* To put this in another way, if you don't know exactly why you would want to use this option, @emph{Never Use It!} @strong{IMPORTANT}: Never use this in conjunction with the @emph{-b} option to buffer the entier file into memory. I will leave it to you to think why this would be bad. @node Windows, Moving About, Choosing a fixed disk, Program Operations @section Windows The screen is made up of three windows, the @strong{Status} window, the @strong{Main} window, and the @strong{Help} window. A typical view would look something like this. @example File: data.dat ASCII Offset: 0x00004250 / 0x000096BB (%44) 00004200 55 89 E5 53 8b 5D 08 A1 A8 0D 05 08 39 05 AC 0D U..S.]......9... 00004210 05 08 0F 8C 8C 00 00 00 05 00 04 00 00 A3 A8 0D ................ 00004220 05 08 C1 E0 02 50 A1 B0 0D 05 08 50 E8 4B CB FF .....P.....P.K.. . . etc . . ^G Help ^C Exit (No Save) ^T goTo Offset ^X Exit and Save ^W Search @end example And so on. @subsection Status Window The Status Window is the first line of the screen. At all times, it conveys the following information @itemize @bullet @item @strong{Filename} which you are working on @item @strong{Character Set} which you are using, ASCII or EBCDIC @item @strong{Current Offset} which you are at @item @strong{Size} of file @item @strong{Percent}age way through the file @item @strong{Modified Flag}: A M in the upper right corner signals that the file has been modified since last save, or that the file is read-only @end itemize It typically looks like this @example File: data.dat ASCII Offset: 0x00004250 / 0x000096BB (%44) @end example @subsection Main Window The Main Window is the bulk of your view. It is where all viewing and editing of the file takes place. All cursor operations and movements take place within this window. Operations within the Main Window are described in detail in section @ref{Moving About} The Main Window is broken up vertically into three columns of information. The first column from the left is the base offset@footnote{All offsets are in Hexadecimal (base16)} which represents the offset of the first byte of that row in the Data column. The second column is the Data column, where the Hexadecimal representation of each byte of the file is listed. Each row consists of 16 bytes, seperated into 2 columns of 8 bytes, each seperated into columns of 4 bytes. A typical row looks like: (third column not shown) @example 00004280 50 E8 A6 CA@ @ FF FF E8 41@ @ @ CA FF FF 68@ @ 90 F5 04 08 @end example The third column of the main window is the text representation on that row's bytes. Non printable characters are represented as a "." dot. @subsection Help Window The Help Window is the friendly reminder of basic commands within the editor. It cannot be removed. @subsection Popup Windows Various commands may bring up a Popup Window. This is a smaller window centered in the Main Window. Various operations, such as Searching, Jumping to another offset, saving, etc. require their own window, and will "Pop" one up. @emph{Escape}, @emph{Control-X}, and @emph{Control-G} can be used to cancel most Popup Windows. @node Moving About, Editing, Windows, Program Operations @section Moving About Moving about the file is done through the full screen terminal interface. Operations were meant to be easy to learn and comfortable to use. @subsection Hex <=> Text (Tab) The Main Window is composed of the hex and text representation of the file. The cursor may be moved from one to the other by use of @strong{Tab} or @strong{Control-I}@footnote{Control-X signifies holding down the control key and hitting X}. Being on the Hex representation will be called Hex Mode, with being on the text representation Text Mode. @subsection Arrow Keys The arrow keys are the basic way to move about the file. In Hex Mode, left and right shift you four bits in the file. Going right, you could move to the lower 4 bits of the current byte (b & 0x0F), or move to the higher 4 bits of the next byte (b & 0xF0). Left can bring you either to the higher 4 bits of the current byte, or to the lower bits of the previous byte. Up and Down move you 16 bytes (offset +- 0x10) through the file@footnote{This isn't always true if you are near the end of the file}. In Text Mode, left and right always move you one byte, with Up and Down moving you 16 bytes. @subsection Jumping From your current offset, you can jump to an offset relative to where you are. With the cursor in the hex data area, Pressing @emph{+} or @emph{-} will bring up a entry box in the help window, in which you can type in the amount to jump. Depending on whether you did a plus or minus, you will traverse to @strong{current offset} @emph{+|-} @strong{value}. After the first jump, you can use the @emph{n} key to continue to jump by that offset a multitude of times. @subsection Misc The following keys function as you'd expect them to @itemize @bullet @item @emph{Page Up} (also @emph{Control-Y}, @emph{Control-B}, @emph{Alt-V}, @emph{u}, @emph{y}) @item @emph{Page Down} (also @emph{Control-F}, @emph{Control-V}, @emph{space}, @emph{v}) @item @emph{Home} @item @emph{End} @end itemize @subsection GoTo Offset At any time, you may jump to a specific offset of the file with @emph{Control-T} or @emph{t}. This will bring up a Popup Window which will prompt you to enter the new file offset. The new offset may be given in decimal@footnote{Decimal numbers are base10, ex: 255}, octal@footnote{Octal numbers are base8, prefixed by a 0, ex: 0377}, or hex@footnote{Hex numbers are base16, prefixed by 0x, ex: 0xFF}. Note, the default value will be 0, permitting a fast way to jump to the begining of the file. @node Editing, Undo, Moving About, Program Operations @section Editing Editing is the primary@footnote{This would make viewing the secondary function, perhaps.} function of the editor. @subsection Modifying Bytes @subsubsection Hex Mode In this mode, Characters 0-9 and A-F may be used to change the current byte. All other characters are ignored. @subsubsection Text Mode In this mode, any printable character may be used to change the current byte. @subsection Insert Insert allows you to, inplace, insert a new byte of data into the file, thus increasing the size of the file by one byte. The new byte is always equal to zero until you modify it. Insert is done through the @emph{Insert} key or @emph{Control-A}. Insert is only enabled if you use the @emph{-b} option to buffer the entire file into memory. This is not something I will consider changing. If you want to modify your copy to allow this, best of luck to you. Insert cannot work on disks either. To simulate appending a byte to the end of the file, Jump to the end of the file, and insert a byte. This will have pushed the last byte over one. Copy the value of that byte to the new zero'd byte. Now zero the last byte. @subsection Delete Delete allows you to delete the current byte, shifting the remainder of the file back one, thus decreasing the size of the file by one byte. Delete is done through the @emph{Delete} key or @emph{Control-D}. Delete will only work if you use the @emph{-b} option to buffer the entire file into memory. Same as with Insert, this is not going to change in a future release. Usually, you can use dd(1) to get the part of the file/disk you want, insert and delete on that to your heart's content, and then dd that back to the file/disk. If there is only one byte in the file, Delete will zero the byte, but you cannot reduce the file to zero bytes@footnote{I recommend rm(1) for this} @node Undo, Searching, Editing, Program Operations @section Undo While editing a file, it is quite likely that you may make a mistake@footnote{Or a typo, if you prefer}. To facilitate this, an extensive Undo command has been implemented on your behalf. @emph{Control-U} Undoes the previous change to the file. The editor keeps track of all modifications, insertions, and deletions. What this means is that at any time you can, if you wish, revert the file back to it's original state by a series of Undo's. If you do @emph{Control-U} and the last changed byte is currently viewable in the Main Window, then the cursor will relocate to that byte and revert it to it's previous state. If the last changed byte is not currently viewable, the currently viewable area will shift so that the changed byte is viewable. In other words, you will be relocated to that part of the file, with the cursor on that byte at that offset. The Byte WILL NOT be Un-done. Another @emph{Control-U} will now undo the change@footnote{This is probably worded poorly, but it's easy to see what I mean when you try it}. @node Searching, Quit, Undo, Program Operations @section Searching Searching allows you to quickly@footnote{The fast Boyer-Moore algorithm is used} locate a specific sequence of characters or bytes in the file. @emph{Control-W} or @emph{w} brings up a Popup Window giving you the options of Find Next (@emph{N}), Search for text string (@emph{A}), and Search for Hex bytes (@emph{H}). @subsection Search for Text String This options allows you to search for specific character strings of text. Spaces are allowed. @subsection Search for Hex Bytes This options allows you to search for a specific string of bytes in the file. The Popup Window has an entry box, which accepts a sequence of bytes in Hex (0-9, A-F), while it shows the text representation of those bytes above. Non printable characters are shown as "." dot. @subsection Find Next This options allows you to find the next occurence of the previous search (text or Hex). This option is not availible until after your first search is completed. This options is bound to @emph{Control-N} to allow quickly locating the next match. @node Quit, Save, Searching, Program Operations @section Quit Quiting without prompting to save is done by @emph{Control-C}. It will bring up a Popup Window to make sure of your decision to quit the program. @node Save, Save and Quit, Quit, Program Operations @section Save To save the file at any time with the currently made changes is done with @emph{Control-O}@footnote{On OpenBSD and a few other OS's, This keystroke does not seem to work. It has something to do with the terminal using it}. The file may be saved over the current file@footnote{This isn't always possible. One place is in DOS if you try to save over the executable currently being ran}, or you may save the file as a new or different file. In the event of an error or inability to save, you will be given the standard@footnote{perror (filename)} error message in the Popup Window. @node Save and Quit, Redraw, Save, Program Operations @section Save and Quit To exit the program, saving the file as you go, use @emph{Control-X}. If the file has not been modified since the last save, the program will exit without saving. If the file has been modified, you will be prompted for the filename to save to, which may be different than the current filename. In the event of an error or inability to save, you will be given the standard error message in the Popup Window, and the program will resume operations without terminating. @node Redraw, View as Text, Save and Quit, Program Operations @section Redraw In the event that the terminal becomes unreadable, or for any other reason, the screen may be redrawn with @emph{Control-L}. This will only erase and redraw the screen. If the terminal needs to be reset@footnote{By '/bin/echo "\033c"' perhaps}, the terminal will still need to be reset. @node View as Text, Ascii <=> EBCDIC, Redraw, Program Operations @section View as Text If at any time, you would like to see what the current file looks like as an text dump, @emph{Control-E} will let you. Note: This feature was intended for files which are mostly made up of text. I implemented this by traveling back to the previous new line so that the text would be aligned how it would be in a text editor. Because of this, in a file without any new lines for a long time, you may not be able to view certain parts of the file in this mode. I do not see this as a problem, and I can recommend some really nice text editors for you if you disagree. Just don't use this function@footnote{Don't use this function. Never use it. I don't.}. This feature was meant to just show you a snapshot of the current section as text. That's all it does, that's all it will do. @node Ascii <=> EBCDIC, Switch Spacings, View as Text, Program Operations @section Ascii <=> EBCDIC Some old IBM mainframes use EBCDIC instead of the ASCII character set. To switch between which way the text is represented, @emph{Control-R} will switch it. If you don't know what this is, you probably should not use it. @node Switch Spacings, Binary Calculator, Ascii <=> EBCDIC, Program Operations @section Switch Spacings Some people like having spaces between each byte, and between each 8 bytes: @example 04 30 40 23 23 43 23 54 23 48 83 29 23 12 00 45 @end example Some people like having the bytes grouped into four byte words: @example 04304023 23432354 23488329 23120045 @end example To select which way you'd like to view the file as, use @emph{Control-P} to switch the spacings around to the way you like it. @node Binary Calculator, Help, Switch Spacings, Program Operations @section Binary Calculator A binary calculator is included which will let you convert between base2, base8, base10, and base16 easily. This can be brought up with @emph{Control-+}. Currently, this doesn't have all the features I'd like to spend the time to put into it, but it still is quite useful. Currently, all numbers in the calculator are represented in the machines default signed Integer size, a size which will be displayed in the status window. This means that most likely setting the highest bit will lead to a negative number. If I get time, unsigned ints as well as indefinite precision, and arithmetic functions will be added. @node Help, , Binary Calculator, Program Operations @section Help At any time, @emph{Control-G} may be used to get a list of commands for the editor. The Help Window will also list some commonly used commands. @contents @bye ncurses-hexedit-0.9.7.orig/docs/hexedit.10100644000175000017500000000445306710143432016701 0ustar apocapoc.\" Copyright (C) 1998,1999 Adam Rogoyski .TH HEXEDIT 1 .SH NAME hexedit \- Full screen curses Hex editor .SH SYNOPSIS .nr a \n(.j .ad l .nr i \n(.i .in +\w'\fBhexedit 'u .ti \niu .B hexedit .de OP .ie \\n(.$-1 .RI "[\ \fB\\$1fP" "\\$2" "\ ]" .el .RB "[\ " "\\$1" "\ ]" .. .OP \-8abdfgqrv .RI "[\ " filename "\ ]" .br .ad \na .SH DESCRIPTION .I Hexedit is an editor to edit binary (or any) files or disks. The Display consists of the current offset from 0 (the first byte), the next sixteen bytes (aligned by bytes or 32-bit words), and it's ASCII or EBCDIC text representation. .SH OPTIONS .TP .B \fI-h, --help\fR Display help .TP .B \fI-8, --highbit\fR Display 8-bit text .TP .B \fI-a, --alltext\fR Display all text regardless that you know better .TP .B \fI-b, --buffer\fR Buffer the entire file into memory. Faster, and enables insert and delete. .TP .B \fI-d, --disk\fR File editing is a disk. OpenBSD and Linux only. .TP .B \fI-f, --force\fR Force editing of a disk. Need this option to enable writing to disks. .TP .B \fI-q, --quiet\fR Quiet Mode; Turn off all beeping. .TP .B \fI-r, --readonly\fR Do not allow modifying the file .TP .B \fI-v, --version\fR Display version number .SH Commands and keys .TP .B \fI^A\fR Insert byte .TP .B \fIInsert\fR Insert byte .TP .B \fI^D\fR Delete byte .TP .B \fIDelete\fR Delete byte .TP .B \fI^E\fR viEw as text dump .TP .B \fI^F\fR Page down .TP .B \fI^V\fR Page down .TP .B \fIPage Down\fR Page down .TP .B \fI^B\fR Page Up .TP .B \fI^Y\fR Page Up .TP .B \fIAlt-V\fR Page Up .TP .B \fIPage Up\fR Page Up .TP .B \fITab\fR Switch from hex to text representation .TP .B \fI^I\fR Switch from hex to text representation .TP .B \fI^T\fR goTo offset .TP .B \fI^G\fR Get help .TP .B \fI^L\fR Redraw screen .TP .B \fI^C\fR Quit without saving .TP .B \fI^O\fR Save .TP .B \fI^X\fR Save and Quit .TP .B \fI^W\fR Search (text/hex) .TP .B \fI^N\fR find Next .TP .B \fI^U\fR Undo .TP .B \fI^R\fR ASCII <=> EBCDIC .TP .B \fI^P\fR Switch Spacings .TP .B \fI^+\fR Binary Calculator .SH Author Adam Rogoyski .SH "See Also" od (1) .SH BUGS Editing disks is only supported in Linux and OpenBSD. Please email Adam Rogoyski with any bugs you might find. This man page is intentionally brief. Please Read the included documentation in Texinfo format for additional information ncurses-hexedit-0.9.7.orig/docs/hexedit.info0100644000175000017500000006464206710145346017510 0ustar apocapocThis is Info file hexedit.info, produced by Makeinfo version 1.67 from the input file hexedit.texinfo. [N]Curses Hexedit Manual Copyright (C) 1999 Adam Rogoyski  File: hexedit.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) * Menu: * Introduction:: About hexedit, the author, and life in general. * Getting Started:: Getting hexedit, compiling, running. * Program Operations:: Program usage and commands.  File: hexedit.info, Node: Introduction, Next: Getting Started, Prev: Top, Up: Top Introduction ************ * Menu: * What is Hexedit:: Brief intro to the program. * Copyright and License:: Terms of copying. * Author:: Info about me. * Feedback and Bugs:: When to contact me. * Contributions:: Who's helped so far.  File: hexedit.info, Node: What is Hexedit, Next: Copyright and License, Up: Introduction What is Hexedit? ================ *hexedit* is a Curses based Hex editor. Unlike a text editor, which is used for editing text documents in the desired language, *hexedit* lets you edit any file as it's byte(1) for byte representation. It can even let you view and edit your fixed disks on your Linux system. This is not ideal for writing a letter or writing c code, but there are my times when this is ideal: * Editing binary executables. * Editing your fixed disks (i.e. /dev/hda) * Checking the output of a Program's binary data file. * Any place you might use od(1) but need more power. Compare more vs less. * Any other time you find this useful (tell me). ---------- Footnotes ---------- (1) I assume a byte is an 8-bit octet. If this is not the case, I really recommend NOT using this program.  File: hexedit.info, Node: Copyright and License, Next: Author, Prev: What is Hexedit, Up: Introduction Copyright and License ===================== *[N]Curses Hexedit* Copyright (C) 1998,1999 Adam Rogoyski This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as publish by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA  File: hexedit.info, Node: Author, Next: Feedback and Bugs, Prev: Copyright and License, Up: Introduction Author ====== *[N]Curses Hexedit* was written by Adam Rogoyski(1)(2). At the time of writting (December 1998) I am a Sophomore of Computer Science at the University of Texas at Austin. I use Debian GNU/Linux and OpenBSD, I enjoy playing electric guitar, and I currently reside Pflugerville, Texas USA. My heroes are Richard Stallman, Stevie Ray Vaughan, and Lisa Loeb. ---------- Footnotes ---------- (1) Email me at apoc@laker.net (2) There is a picture of me at http://profiles.yahoo.com/rogoyski/  File: hexedit.info, Node: Feedback and Bugs, Next: Contributions, Prev: Author, Up: Introduction Feedback and Bugs ================= Astounding as it may be, there quite possibly are bugs in *hexedit*. You can do your share to help Free Software(1) be robust and secure by telling me about any problems you find. Patches are even better. General feedback is appreciated as well, if only to tell me that *hexedit* saved the day again, or that my obscure program wasted half your day when you already knew how to use emacs (M-x hexl-mode) in the first place. I can be reached at *apoc@laker.net* ---------- Footnotes ---------- (1) http://www.gnu.org/philosophy/free-sw.html  File: hexedit.info, Node: Contributions, Prev: Feedback and Bugs, Up: Introduction Contributions ============= The following people contributed valuable feedback and information * John Gatewood Ham: Gave some tips for the documentation. * Cort (unknown): Idea for Undo. * Matt Noel: EBCDIC support and spacing. Countless suggestions and ideas. * Everyone else who mailed me and told me things that broke and gave suggestions.  File: hexedit.info, Node: Getting Started, Next: Program Operations, Prev: Introduction, Up: Top Getting Started *************** * Menu: * Obtaining Source:: Where to find hexedit. * Obtaining Binaries:: Where to find binaries. * Building from Source:: What to do to build hexedit. * Command Line Invocation:: starting from the shell.  File: hexedit.info, Node: Obtaining Source, Next: Obtaining Binaries, Up: Getting Started Obtaining Source ================ The latest source tar'd and gzip'd can be obtained at *http://ccwf.cc.utexas.edu/~apoc/programs/c/hexedit/* and also from everyone's favorite ftp site *ftp://metalab.unc.edu/pub/Linux/apps/editors/terminal/* If you do not know what tar and gzip are, and are using a DOS derived OS, *Note Obtaining Binaries::.  File: hexedit.info, Node: Obtaining Binaries, Next: Building from Source, Prev: Obtaining Source, Up: Getting Started Obtaining Binaries ================== Pre-compiled statically linked binaries can be obtained for the following operating systems: i386 Linux, i386 OpenBSD, and DOS. The location for these is: *http://ccwf.cc.utexas.edu/~apoc/programs/c/hexedit/* I've Built and tested hexedit on the following platforms: * Linux 2.0.36 i386 ncurses 4.2 (gcc) * Linux 2.2.6 i386 ncurses 4.2 (gcc) * OpenBSD 2.4 i386 ncurses (gcc) * SunOS 5.6 Sparc curses (gcc) * AIX 4.3.2 rs6000 curses (gcc and cc) * AIX 4.3.2 ppc curses (gcc and cc) * DOS 6.22 i386 pdcurses (djgpp gcc) * IRIX 6.3 mips curses (gcc) * HP-UX B.10.20 curses (gcc) * SunOS 5.5.1 sparc curses (gcc) * OSF V4.0 alpha curses (gcc)  File: hexedit.info, Node: Building from Source, Next: Command Line Invocation, Prev: Obtaining Binaries, Up: Getting Started Building from Source ==================== Building from source should be very strait forward. I used the GNU configure system (autoconf and automake) so, like any GNU compliant program, the sequence ./configure make make install should be all that's needed to install the package. Additional options may need to be given to configure, check INSTALL for such options. i386 Linux ---------- I extremely recommend you upgrade to ncurses 4.2 for hexedit to work. It should work with all versions, but resizing in an xterm seems to work better with the newest release. The latest ncurses can be obtained at the nearest GNU ftp archive (or ftp://ftp.gnu.org/pub/gnu/). i386 OpenBSD ------------ OpenBSD 2.4 I believe comes with ncurses, and it worked fine at my end. rs/6000 AIX 4.3 --------------- I belive I've fixed the previous AIX problems I was having. Let me know if anything else turns up.  File: hexedit.info, Node: Command Line Invocation, Prev: Building from Source, Up: Getting Started Command Line Invocation ======================= Basic program usage is as follows: *hexedit* [*flags*] [*filename*] Where filename is the file which you wish to edit. Additionally, starting the program with no file *hexedit* [*flags*] will bring up the file selection widget which will allow you to browse for the file. The command line arguments which are supported are -h, -help Prints help. -8, -highbit Allows displaying of high order bit text. -a, -alltext Allows displaying of all text (probably bad idea). -b, -buffer Buffer the entire file into memory. -d, -disk View a fixed disk (Linux only). -f, -force Allow editing of disk (Linux only). -q, -quiet No Beeping! -r, -readonly Prevents modifying the file. -v, -version Prints version number. Defaults may be specified in the HEXEDIT environment variable, i.e. sh: *export HEXEDIT=-8r* csh: *setenv HEXEDIT=-8r*  File: hexedit.info, Node: Program Operations, Prev: Getting Started, Up: Top Program Operations ****************** * Menu: * Choosing a file:: How to select a file to edit. * Choosing a fixed disk:: How to select a fixed disk to view/edit. * Windows:: Descriptions of the various windows. * Moving About:: How to traverse the file. * Editing:: Editing procedures. * Undo:: Fixing mistakes. * Searching:: Locating specific strings. * Quit:: Exiting the editor. * Save:: Commiting changes to disk. * Save and Quit:: Commiting changes with exit. * Redraw:: Refreshing the screen. * View as Text:: Take an text snapshot of offset. * Ascii <=> EBCDIC:: Switch between text representations * Switch Spacings:: Change the way the bytes are grouped * Binary Calculator:: Base conversions. * Help:: Accessing online help.  File: hexedit.info, Node: Choosing a file, Next: Choosing a fixed disk, Up: Program Operations Choosing a file =============== Before editing can begin, you much select a file to edit. This can be done on the command line: hexedit filename Quite possibly, you may not remember the location of the file you wish to edit, or you may wish to browse over many possible files availible to find the file you are looking for. Hexedit comes equipted with a full screen file/directory browser which enables you to specify the file you wish to edit. Not specifying any file on the command line: hexedit will bring up the file selection browser. Choosing (pressing enter) a directory will open that directory for viewing. Choosing a file will open that file in the editor.  File: hexedit.info, Node: Choosing a fixed disk, Next: Windows, Prev: Choosing a file, Up: Program Operations Choosing a fixed disk. ====================== Hexedit, when run in Linux, permits access to read and edit fixed disks (i.e /dev/hda). Using the *-d* option will allow you to edit a disk. Currently, the disk can be only up to 4.2 gigs, but this will probably change in a future release. By default, editing a disk will put you in read-only mode. This is for your own protection. If you really think you know what you are doing, issue the *-f* flag and it will force edit mode for the disk and allow you to make changes to your disk. Use this with *EXTREME CAUTION!* If you make a mistake to your boot sector, erase a few important inodes, or hit the wrong keystroke, you could be seriously out of luck. It is really easy to put your disk in an unusable state. Also, remember that the disk could very well be changing as you look at it. So the next time you view a chunk, it may be different, or even the chunk you are currently viewing may have changed on disk since you read it into the editor's buffer. So be careful if you want to edit a mounted disk. To put this in another way, if you don't know exactly why you would want to use this option, *Never Use It!* *IMPORTANT*: Never use this in conjunction with the *-b* option to buffer the entier file into memory. I will leave it to you to think why this would be bad.  File: hexedit.info, Node: Windows, Next: Moving About, Prev: Choosing a fixed disk, Up: Program Operations Windows ======= The screen is made up of three windows, the *Status* window, the *Main* window, and the *Help* window. A typical view would look something like this. File: data.dat ASCII Offset: 0x00004250 / 0x000096BB (%44) 00004200 55 89 E5 53 8b 5D 08 A1 A8 0D 05 08 39 05 AC 0D U..S.]......9... 00004210 05 08 0F 8C 8C 00 00 00 05 00 04 00 00 A3 A8 0D ................ 00004220 05 08 C1 E0 02 50 A1 B0 0D 05 08 50 E8 4B CB FF .....P.....P.K.. . . etc . . ^G Help ^C Exit (No Save) ^T goTo Offset ^X Exit and Save ^W Search And so on. Status Window ------------- The Status Window is the first line of the screen. At all times, it conveys the following information * *Filename* which you are working on * *Character Set* which you are using, ASCII or EBCDIC * *Current Offset* which you are at * *Size* of file * *Percent*age way through the file * *Modified Flag*: A M in the upper right corner signals that the file has been modified since last save, or that the file is read-only It typically looks like this File: data.dat ASCII Offset: 0x00004250 / 0x000096BB (%44) Main Window ----------- The Main Window is the bulk of your view. It is where all viewing and editing of the file takes place. All cursor operations and movements take place within this window. Operations within the Main Window are described in detail in section *Note Moving About:: The Main Window is broken up vertically into three columns of information. The first column from the left is the base offset(1) which represents the offset of the first byte of that row in the Data column. The second column is the Data column, where the Hexadecimal representation of each byte of the file is listed. Each row consists of 16 bytes, seperated into 2 columns of 8 bytes, each seperated into columns of 4 bytes. A typical row looks like: (third column not shown) 00004280 50 E8 A6 CA FF FF E8 41 CA FF FF 68 90 F5 04 08 The third column of the main window is the text representation on that row's bytes. Non printable characters are represented as a "." dot. Help Window ----------- The Help Window is the friendly reminder of basic commands within the editor. It cannot be removed. Popup Windows ------------- Various commands may bring up a Popup Window. This is a smaller window centered in the Main Window. Various operations, such as Searching, Jumping to another offset, saving, etc. require their own window, and will "Pop" one up. *Escape*, *Control-X*, and *Control-G* can be used to cancel most Popup Windows. ---------- Footnotes ---------- (1) All offsets are in Hexadecimal (base16)  File: hexedit.info, Node: Moving About, Next: Editing, Prev: Windows, Up: Program Operations Moving About ============ Moving about the file is done through the full screen terminal interface. Operations were meant to be easy to learn and comfortable to use. Hex <=> Text (Tab) ------------------ The Main Window is composed of the hex and text representation of the file. The cursor may be moved from one to the other by use of *Tab* or *Control-I*(1). Being on the Hex representation will be called Hex Mode, with being on the text representation Text Mode. Arrow Keys ---------- The arrow keys are the basic way to move about the file. In Hex Mode, left and right shift you four bits in the file. Going right, you could move to the lower 4 bits of the current byte (b & 0x0F), or move to the higher 4 bits of the next byte (b & 0xF0). Left can bring you either to the higher 4 bits of the current byte, or to the lower bits of the previous byte. Up and Down move you 16 bytes (offset +- 0x10) through the file(2). In Text Mode, left and right always move you one byte, with Up and Down moving you 16 bytes. Jumping ------- From your current offset, you can jump to an offset relative to where you are. With the cursor in the hex data area, Pressing *+* or *-* will bring up a entry box in the help window, in which you can type in the amount to jump. Depending on whether you did a plus or minus, you will traverse to *current offset* *+|-* *value*. After the first jump, you can use the *n* key to continue to jump by that offset a multitude of times. Misc ---- The following keys function as you'd expect them to * *Page Up* (also *Control-Y*, *Control-B*, *Alt-V*, *u*, *y*) * *Page Down* (also *Control-F*, *Control-V*, *space*, *v*) * *Home* * *End* GoTo Offset ----------- At any time, you may jump to a specific offset of the file with *Control-T* or *t*. This will bring up a Popup Window which will prompt you to enter the new file offset. The new offset may be given in decimal(3), octal(4), or hex(5). Note, the default value will be 0, permitting a fast way to jump to the begining of the file. ---------- Footnotes ---------- (1) Control-X signifies holding down the control key and hitting X (2) This isn't always true if you are near the end of the file (3) Decimal numbers are base10, ex: 255 (4) Octal numbers are base8, prefixed by a 0, ex: 0377 (5) Hex numbers are base16, prefixed by 0x, ex: 0xFF  File: hexedit.info, Node: Editing, Next: Undo, Prev: Moving About, Up: Program Operations Editing ======= Editing is the primary(1) function of the editor. Modifying Bytes --------------- Hex Mode ........ In this mode, Characters 0-9 and A-F may be used to change the current byte. All other characters are ignored. Text Mode ......... In this mode, any printable character may be used to change the current byte. Insert ------ Insert allows you to, inplace, insert a new byte of data into the file, thus increasing the size of the file by one byte. The new byte is always equal to zero until you modify it. Insert is done through the *Insert* key or *Control-A*. Insert is only enabled if you use the *-b* option to buffer the entire file into memory. This is not something I will consider changing. If you want to modify your copy to allow this, best of luck to you. Insert cannot work on disks either. To simulate appending a byte to the end of the file, Jump to the end of the file, and insert a byte. This will have pushed the last byte over one. Copy the value of that byte to the new zero'd byte. Now zero the last byte. Delete ------ Delete allows you to delete the current byte, shifting the remainder of the file back one, thus decreasing the size of the file by one byte. Delete is done through the *Delete* key or *Control-D*. Delete will only work if you use the *-b* option to buffer the entire file into memory. Same as with Insert, this is not going to change in a future release. Usually, you can use dd(1) to get the part of the file/disk you want, insert and delete on that to your heart's content, and then dd that back to the file/disk. If there is only one byte in the file, Delete will zero the byte, but you cannot reduce the file to zero bytes(2) ---------- Footnotes ---------- (1) This would make viewing the secondary function, perhaps. (2) I recommend rm(1) for this  File: hexedit.info, Node: Undo, Next: Searching, Prev: Editing, Up: Program Operations Undo ==== While editing a file, it is quite likely that you may make a mistake(1). To facilitate this, an extensive Undo command has been implemented on your behalf. *Control-U* Undoes the previous change to the file. The editor keeps track of all modifications, insertions, and deletions. What this means is that at any time you can, if you wish, revert the file back to it's original state by a series of Undo's. If you do *Control-U* and the last changed byte is currently viewable in the Main Window, then the cursor will relocate to that byte and revert it to it's previous state. If the last changed byte is not currently viewable, the currently viewable area will shift so that the changed byte is viewable. In other words, you will be relocated to that part of the file, with the cursor on that byte at that offset. The Byte WILL NOT be Un-done. Another *Control-U* will now undo the change(2). ---------- Footnotes ---------- (1) Or a typo, if you prefer (2) This is probably worded poorly, but it's easy to see what I mean when you try it  File: hexedit.info, Node: Searching, Next: Quit, Prev: Undo, Up: Program Operations Searching ========= Searching allows you to quickly(1) locate a specific sequence of characters or bytes in the file. *Control-W* or *w* brings up a Popup Window giving you the options of Find Next (*N*), Search for text string (*A*), and Search for Hex bytes (*H*). Search for Text String ---------------------- This options allows you to search for specific character strings of text. Spaces are allowed. Search for Hex Bytes -------------------- This options allows you to search for a specific string of bytes in the file. The Popup Window has an entry box, which accepts a sequence of bytes in Hex (0-9, A-F), while it shows the text representation of those bytes above. Non printable characters are shown as "." dot. Find Next --------- This options allows you to find the next occurence of the previous search (text or Hex). This option is not availible until after your first search is completed. This options is bound to *Control-N* to allow quickly locating the next match. ---------- Footnotes ---------- (1) The fast Boyer-Moore algorithm is used  File: hexedit.info, Node: Quit, Next: Save, Prev: Searching, Up: Program Operations Quit ==== Quiting without prompting to save is done by *Control-C*. It will bring up a Popup Window to make sure of your decision to quit the program.  File: hexedit.info, Node: Save, Next: Save and Quit, Prev: Quit, Up: Program Operations Save ==== To save the file at any time with the currently made changes is done with *Control-O*(1). The file may be saved over the current file(2), or you may save the file as a new or different file. In the event of an error or inability to save, you will be given the standard(3) error message in the Popup Window. ---------- Footnotes ---------- (1) On OpenBSD and a few other OS's, This keystroke does not seem to work. It has something to do with the terminal using it (2) This isn't always possible. One place is in DOS if you try to save over the executable currently being ran (3) perror (filename)  File: hexedit.info, Node: Save and Quit, Next: Redraw, Prev: Save, Up: Program Operations Save and Quit ============= To exit the program, saving the file as you go, use *Control-X*. If the file has not been modified since the last save, the program will exit without saving. If the file has been modified, you will be prompted for the filename to save to, which may be different than the current filename. In the event of an error or inability to save, you will be given the standard error message in the Popup Window, and the program will resume operations without terminating.  File: hexedit.info, Node: Redraw, Next: View as Text, Prev: Save and Quit, Up: Program Operations Redraw ====== In the event that the terminal becomes unreadable, or for any other reason, the screen may be redrawn with *Control-L*. This will only erase and redraw the screen. If the terminal needs to be reset(1), the terminal will still need to be reset. ---------- Footnotes ---------- (1) By '/bin/echo "\033c"' perhaps  File: hexedit.info, Node: View as Text, Next: Ascii <=> EBCDIC, Prev: Redraw, Up: Program Operations View as Text ============ If at any time, you would like to see what the current file looks like as an text dump, *Control-E* will let you. Note: This feature was intended for files which are mostly made up of text. I implemented this by traveling back to the previous new line so that the text would be aligned how it would be in a text editor. Because of this, in a file without any new lines for a long time, you may not be able to view certain parts of the file in this mode. I do not see this as a problem, and I can recommend some really nice text editors for you if you disagree. Just don't use this function(1). This feature was meant to just show you a snapshot of the current section as text. That's all it does, that's all it will do. ---------- Footnotes ---------- (1) Don't use this function. Never use it. I don't.  File: hexedit.info, Node: Ascii <=> EBCDIC, Next: Switch Spacings, Prev: View as Text, Up: Program Operations Ascii <=> EBCDIC ================ Some old IBM mainframes use EBCDIC instead of the ASCII character set. To switch between which way the text is represented, *Control-R* will switch it. If you don't know what this is, you probably should not use it.  File: hexedit.info, Node: Switch Spacings, Next: Binary Calculator, Prev: Ascii <=> EBCDIC, Up: Program Operations Switch Spacings =============== Some people like having spaces between each byte, and between each 8 bytes: 04 30 40 23 23 43 23 54 23 48 83 29 23 12 00 45 Some people like having the bytes grouped into four byte words: 04304023 23432354 23488329 23120045 To select which way you'd like to view the file as, use *Control-P* to switch the spacings around to the way you like it.  File: hexedit.info, Node: Binary Calculator, Next: Help, Prev: Switch Spacings, Up: Program Operations Binary Calculator ================= A binary calculator is included which will let you convert between base2, base8, base10, and base16 easily. This can be brought up with *Control-+*. Currently, this doesn't have all the features I'd like to spend the time to put into it, but it still is quite useful. Currently, all numbers in the calculator are represented in the machines default signed Integer size, a size which will be displayed in the status window. This means that most likely setting the highest bit will lead to a negative number. If I get time, unsigned ints as well as indefinite precision, and arithmetic functions will be added.  File: hexedit.info, Node: Help, Prev: Binary Calculator, Up: Program Operations Help ==== At any time, *Control-G* may be used to get a list of commands for the editor. The Help Window will also list some commonly used commands.  Tag Table: Node: Top170 Node: Introduction434 Node: What is Hexedit812 Node: Copyright and License1752 Node: Author2625 Node: Feedback and Bugs3259 Node: Contributions3954 Node: Getting Started4417 Node: Obtaining Source4764 Node: Obtaining Binaries5209 Node: Building from Source6164 Node: Command Line Invocation7239 Node: Program Operations8279 Node: Choosing a file9124 Node: Choosing a fixed disk9923 Node: Windows11379 Node: Moving About14510 Node: Editing17073 Node: Undo19038 Node: Searching20211 Node: Quit21399 Node: Save21647 Node: Save and Quit22377 Node: Redraw22972 Node: View as Text23418 Node: Ascii <=> EBCDIC24382 Node: Switch Spacings24756 Node: Binary Calculator25281 Node: Help26049  End Tag Table ncurses-hexedit-0.9.7.orig/src/0040777000175000017500000000000006753210663015035 5ustar apocapocncurses-hexedit-0.9.7.orig/src/Makefile.in0100644000175000017500000001707006753210663017100 0ustar apocapoc# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : CC = @CC@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ bin_PROGRAMS = hexedit hexedit_SOURCES = asciikey.c calc.c calckeys.c edit.c file.c filebuf.c filekeys.c hash.c help.c hexkeys.c init.c main.c misc.c print.c search.c undo.c widgets.c windows.c hexedit.h mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = PROGRAMS = $(bin_PROGRAMS) DEFS = @DEFS@ -I. -I$(srcdir) -I.. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ hexedit_OBJECTS = asciikey.o calc.o calckeys.o edit.o file.o filebuf.o \ filekeys.o hash.o help.o hexkeys.o init.o main.o misc.o print.o \ search.o undo.o widgets.o windows.o hexedit_LDADD = $(LDADD) hexedit_DEPENDENCIES = hexedit_LDFLAGS = CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best SOURCES = $(hexedit_SOURCES) OBJECTS = $(hexedit_OBJECTS) all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .o .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status mostlyclean-binPROGRAMS: clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) distclean-binPROGRAMS: maintainer-clean-binPROGRAMS: install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) list='$(bin_PROGRAMS)'; for p in $$list; do \ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ done .c.o: $(COMPILE) -c $< .s.o: $(COMPILE) -c $< .S.o: $(COMPILE) -c $< mostlyclean-compile: -rm -f *.o core *.core clean-compile: distclean-compile: -rm -f *.tab.c maintainer-clean-compile: hexedit: $(hexedit_OBJECTS) $(hexedit_DEPENDENCIES) @rm -f hexedit $(LINK) $(hexedit_LDFLAGS) $(hexedit_OBJECTS) $(hexedit_LDADD) $(LIBS) tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) mostlyclean-tags: clean-tags: distclean-tags: -rm -f TAGS ID maintainer-clean-tags: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = src distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done info-am: info: info-am dvi-am: dvi: dvi-am check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am install-exec-am: install-binPROGRAMS install-exec: install-exec-am install-data-am: install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am uninstall-am: uninstall-binPROGRAMS uninstall: uninstall-am all-am: Makefile $(PROGRAMS) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ mostlyclean-tags mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-binPROGRAMS clean-compile clean-tags clean-generic \ mostlyclean-am clean: clean-am distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ distclean-generic clean-am distclean: distclean-am maintainer-clean-am: maintainer-clean-binPROGRAMS \ maintainer-clean-compile maintainer-clean-tags \ maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am .PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile tags mostlyclean-tags distclean-tags \ clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ check-am installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ all-redirect all-am all installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ncurses-hexedit-0.9.7.orig/src/Makefile.am0100644000175000017500000000076606753161327017075 0ustar apocapocbin_PROGRAMS = hexedit hexedit_SOURCES = asciikey.c \ calc.c \ calckeys.c \ edit.c \ file.c \ filebuf.c \ filekeys.c \ hash.c \ help.c \ hexkeys.c \ init.c \ main.c \ misc.c \ print.c \ search.c \ undo.c \ widgets.c \ windows.c \ hexedit.h ncurses-hexedit-0.9.7.orig/src/asciikey.c0100644000175000017500000000551406665617400017002 0ustar apocapoc/* asciikeys.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" void asciiMode (wchar_t in) { switch (in) { case KEY_UP: case KEY_DOWN: case KEY_LEFT: case KEY_RIGHT: break; case CONTROL_L: redraw (); break; case CONTROL_F: case CONTROL_V: case KEY_NPAGE: case KEY_C3: break; case CONTROL_B: case CONTROL_Y: case KEY_PPAGE: case KEY_A3: #ifdef __PDCURSES__ case ALT_V: #endif break; case CONTROL_T: popupGotoOffset (Globals.filesize); redraw (); break; case CONTROL_G: popupHelp (); redraw (); break; case CONTROL_O: popupFileSave (); redraw (); break; case CONTROL_R: Globals.charset ^= 1; redraw (); break; case CONTROL_X: if (Globals.modified == MODIFIED) exitSave (popupFileSave ()); else exitProgram (); break; case CONTROL_A: case KEY_IC: break; case CONTROL_D: case KEY_DC: break; case KEY_END: break; case KEY_HOME: break; case TAB: break; case CONTROL_E: switchModes (); break; case CONTROL_W: search (0); redraw (); break; case CONTROL_N: search (1); redraw (); break; case ESCAPE_CHARACTER: in = getch (); switch (in) { case ALT_V: break; case 91: in = getch (); switch (in) { case 49: /* home */ break; case 50: /* insert */ break; case 51: /* delete */ break; case 52: /* end */ break; case 53: /* page up */ break; case 54: /* page down */ break; } /* getch (); */ /* returns 126 */ break; } break; default: break; } } ncurses-hexedit-0.9.7.orig/src/calc.c0100644000175000017500000001655206710214566016104 0ustar apocapoc/* calc.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" /* Used only for redraw function after Control-C */ struct calcEntryBox *bbox; struct calcEntryBox *obox; struct calcEntryBox *dbox; struct calcEntryBox *hbox; int calc_mode = DEC_BOX; void binary_calculator () { wchar_t in = 0; struct calcEntryBox binbox = { "01", { '\0' }, 0, 3, 1, { (int) 0 } }; struct calcEntryBox octbox = { "01234567", { '\0' }, 0, 5, 1, { 0L } }; struct calcEntryBox decbox = { "0123456789", { '\0' }, 0, 7, 1, { (unsigned int) 0 } }; struct calcEntryBox hexbox = { "0123456789AaBbCcDdEeFf", { '\0' }, 0, 9, 1, { 0UL } }; calc_mode = DEC_BOX; bbox = &binbox; obox = &octbox; dbox = &decbox; hbox = &hexbox; werase (Globals.wmain); werase (Globals.wstatus); werase (Globals.whelp); wmove (Globals.wmain, 1, (COLS / 2) - (strlen ("Binary Calculator") / 2)); wprintw (Globals.wmain, "Binary Calculator"); calcStatWindow (); wmove (Globals.whelp, 0, 0); wprintw (Globals.whelp, "^X/^G Return ^C Exit J Down K Up"); calcDrawBoxes (&binbox, &octbox, &decbox, &hexbox, calc_mode); wrefresh (Globals.wstatus); wrefresh (Globals.whelp); wrefresh (Globals.wmain); refresh (); while (1) { in = getch (); switch (in) { case CONTROL_G: case CONTROL_X: case ESCAPE_CHARACTER: return; case CONTROL_L: break; case KEY_DOWN: case KEY_UP: case 'j': case 'J': case 'k': case 'K': calcArrowKey (&binbox, &octbox, &decbox, &hexbox, in, &calc_mode); break; default: calcNumberKey (&binbox, &octbox, &decbox, &hexbox, in, calc_mode); break; } calcStatWindow (); werase (Globals.whelp); wmove (Globals.whelp, 0, 0); wprintw (Globals.whelp, "^X/^G Return ^C Exit J Down K Up"); calcDrawBoxes (&binbox, &octbox, &decbox, &hexbox, calc_mode); wrefresh (Globals.wstatus); wrefresh (Globals.whelp); wrefresh (Globals.wmain); refresh (); } } void calcDrawBoxes (struct calcEntryBox *binbox, struct calcEntryBox *octbox, struct calcEntryBox *decbox, struct calcEntryBox *hexbox, int mode) { wmove (Globals.wmain, binbox->pos_y, binbox->pos_x); wprintw (Globals.wmain, "Base 2"); wmove (Globals.wmain, octbox->pos_y, octbox->pos_x); wprintw (Globals.wmain, "Base 8"); wmove (Globals.wmain, decbox->pos_y, decbox->pos_x); wprintw (Globals.wmain, "Base 10"); wmove (Globals.wmain, hexbox->pos_y, decbox->pos_x); wprintw (Globals.wmain, "Base 16"); calcBinaryString (binbox); drawEntryBox (Globals.wmain, binbox, binbox->pos_y, 10, BOX_LEN); if (mode == BIN_BOX) { wattrset (Globals.wmain, A_BOLD); wprintw (Globals.wmain, " <=="); wattroff (Globals.wmain, A_BOLD); } else wprintw (Globals.wmain, " "); calcOctalString (octbox); drawEntryBox (Globals.wmain, octbox, octbox->pos_y, 10, BOX_LEN); if (mode == OCT_BOX) { wattrset (Globals.wmain, A_BOLD); wprintw (Globals.wmain, " <=="); wattroff (Globals.wmain, A_BOLD); } else wprintw (Globals.wmain, " "); calcDecimalString (decbox); drawEntryBox (Globals.wmain, decbox, decbox->pos_y, 10, BOX_LEN); if (mode == DEC_BOX) { wattrset (Globals.wmain, A_BOLD); wprintw (Globals.wmain, " <=="); wattroff (Globals.wmain, A_BOLD); } else wprintw (Globals.wmain, " "); calcHexString (hexbox); drawEntryBox (Globals.wmain, hexbox, hexbox->pos_y, 10, BOX_LEN); if (mode == HEX_BOX) { wattrset (Globals.wmain, A_BOLD); wprintw (Globals.wmain, " <=="); wattroff (Globals.wmain, A_BOLD); } else wprintw (Globals.wmain, " "); } void drawEntryBox (WINDOW *win, struct calcEntryBox *box, int y, int x, int len) { int i = 0; wmove (win, y, x); wattrset (win, A_REVERSE); for (i = 0; i < len; i++) if (box->s[BOX_LEN - 1 - i]) wprintw (win, "%c", box->s[BOX_LEN - 1 - i]); else wprintw (win, " "); wattroff (win, A_REVERSE); } void calcStatWindow () { int i = 0; werase (Globals.wstatus); wmove (Globals.wstatus, 0, 0); wprintw (Globals.wstatus, "Integer: %d bits Long: %d bits", sizeof (int) * 8, sizeof (long) * 8); for (i = 0; i < (COLS - 34); i++) wprintw (Globals.wstatus, " "); } void calcBinaryString (struct calcEntryBox *binbox) { int i = 0; int v = binbox->value.i; memset (binbox->s, 0x00, BOX_LEN + 1); for (i = 0; i < sizeof (int) * 8; i++) { binbox->s[i] = getAsciiValue (v & 0x01); v = (unsigned int) v >> 1; } } void calcOctalString (struct calcEntryBox *octbox) { char s[BOX_LEN + 1]; int i = 0; int v = octbox->value.i; memset (octbox->s, 0x00, BOX_LEN + 1); memset (s, 0x00, BOX_LEN + 1); for (i = 0; i < sizeof (int) * 8; i++) { #ifdef HAVE_SNPRINTF snprintf (s, BOX_LEN, "%o", octbox->value.i); #else sprintf (s, "%o", octbox->value.i); #endif v = v >> 1; } v = 0; for (i = BOX_LEN - 1; i >= 0; i--) /* swap order of the characters so it prints out right */ { if (!s[i]) continue; octbox->s[v++] = s[i]; } } void calcDecimalString (struct calcEntryBox *decbox) { char s[BOX_LEN + 1]; int i = 0; int v = decbox->value.i; memset (decbox->s, 0x00, BOX_LEN + 1); memset (s, 0x00, BOX_LEN + 1); for (i = 0; i < sizeof (int) * 8; i++) { #ifdef HAVE_SNPRINTF snprintf (s, BOX_LEN, "%d", decbox->value.i); #else sprintf (s, "%d", decbox->value.i); #endif v = v >> 1; } v = 0; for (i = BOX_LEN - 1; i >= 0; i--) /* swap order of the characters so it prints out right */ { if (!s[i]) continue; decbox->s[v++] = s[i]; } } void calcHexString (struct calcEntryBox *hexbox) { char s[BOX_LEN + 1]; int i = 0; int v = hexbox->value.i; memset (hexbox->s, 0x00, BOX_LEN + 1); memset (s, 0x00, BOX_LEN + 1); for (i = 0; i < sizeof (int) * 8; i++) { #ifdef HAVE_SNPRINTF snprintf (s, BOX_LEN, "%X", hexbox->value.i); #else sprintf (s, "%X", hexbox->value.i); #endif v = v >> 1; } v = 0; for (i = BOX_LEN - 1; i >= 0; i--) /* swap order of the characters so it prints out right */ { if (!s[i]) continue; hexbox->s[v++] = s[i]; } } ncurses-hexedit-0.9.7.orig/src/calckeys.c0100644000175000017500000001437406710214027016770 0ustar apocapoc/* calckeys.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" void calcNumberKey (struct calcEntryBox *binbox, struct calcEntryBox *octbox, struct calcEntryBox *decbox, struct calcEntryBox *hexbox, wchar_t in, int mode) { unsigned char *p = NULL; int bitoff = 0; memset (&bitoff, 0xFF, sizeof (int)); p = (unsigned char *) &bitoff + (sizeof (int) - 1); switch (mode) { case BIN_BOX: switch (in) { case CONTROL_D: case BACKSPACE: case CONTROL_H: case KEY_BACKSPACE: case KEY_DC: #ifdef __PDCURSES__ case CTL_BKSP: #endif binbox->value.i = binbox->value.i >> 1; *p &= 0x7F; binbox->value.i &= bitoff; octbox->value.i = decbox->value.i = hexbox->value.i = binbox->value.i; break; default: { char *p = binbox->tokens; while (*p) { if (*p == in) break; p++; } if (!*p) return; binbox->value.i = (binbox->value.i << 1) + getHexValue (in); octbox->value.i = decbox->value.i = hexbox->value.i = binbox->value.i; } } break; case OCT_BOX: switch (in) { case CONTROL_D: case BACKSPACE: case CONTROL_H: case KEY_BACKSPACE: case KEY_DC: #ifdef __PDCURSES__ case CTL_BKSP: #endif octbox->value.i = octbox->value.i >> 3; *p = 0x1F; octbox->value.i &= bitoff; binbox->value.i = decbox->value.i = hexbox->value.i = octbox->value.i; break; default: { char *p = octbox->tokens; while (*p) { if (*p == in) break; p++; } if (!*p) return; octbox->value.i = (octbox->value.i << 3) + getHexValue (in); binbox->value.i = decbox->value.i = hexbox->value.i = octbox->value.i; } } break; case DEC_BOX: switch (in) { case CONTROL_D: case BACKSPACE: case CONTROL_H: case KEY_BACKSPACE: case KEY_DC: #ifdef __PDCURSES__ case CTL_BKSP: #endif decbox->value.i /= 10; binbox->value.i = octbox->value.i = hexbox->value.i = decbox->value.i; break; default: { char *p = hexbox->tokens; while (*p) { if (*p == in) break; p++; } if (!*p) return; /* this doesn't really do what we want it to do */ decbox->value.i *= 10; decbox->value.i += getHexValue (in); binbox->value.i = octbox->value.i = hexbox->value.i = decbox->value.i; break; } } break; case HEX_BOX: switch (in) { case CONTROL_D: case BACKSPACE: case CONTROL_H: case KEY_BACKSPACE: case KEY_DC: #ifdef __PDCURSES__ case CTL_BKSP: #endif hexbox->value.i = hexbox->value.i >> 4; *p &= 0x0F; hexbox->value.i &= bitoff; binbox->value.i = octbox->value.i = decbox->value.i = hexbox->value.i; break; default: { char *p = hexbox->tokens; while (*p) { if (*p == in) break; p++; } if (!*p) return; hexbox->value.i = (hexbox->value.i << 4) + getHexValue (in); binbox->value.i = octbox->value.i = decbox->value.i = hexbox->value.i; } } break; } } void calcArrowKey (struct calcEntryBox *binbox, struct calcEntryBox *octbox, struct calcEntryBox *decbox, struct calcEntryBox *hexbox, wchar_t in, int *mode) { switch (*mode) { case BIN_BOX: if ((in == KEY_UP) || (toupper (in) == 'K')) *mode = HEX_BOX; else if ((in == KEY_DOWN) || (toupper (in) == 'J')) *mode = OCT_BOX; break; case OCT_BOX: if ((in == KEY_UP) || (toupper (in) == 'K')) *mode = BIN_BOX; else if ((in == KEY_DOWN) || (toupper (in) == 'J')) *mode = DEC_BOX; break; case DEC_BOX: if ((in == KEY_UP) || (toupper (in) == 'K')) *mode = OCT_BOX; else if ((in == KEY_DOWN) || (toupper (in) == 'J')) *mode = HEX_BOX; break; case HEX_BOX: if ((in == KEY_UP) || (toupper (in) == 'K')) *mode = DEC_BOX; else if ((in == KEY_DOWN) || (toupper (in) == 'J')) *mode = BIN_BOX; break; } } ncurses-hexedit-0.9.7.orig/src/edit.c0100644000175000017500000003565606673023153016133 0ustar apocapoc/* edit.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include #include "hexedit.h" /* The routines in this file are very messy and ugly and not much thought * went into thinking how to minimize the amount of code, I only did it * real fast, making every case I could think of a seperate code block, * so this may be someplace someone may want to improve, especially since * all the hard coded screen positions make it hard to add new viewing * modes. */ /* Table for translating an ASCII character into an EBCDIC char. Index into * the array with an ASCII char value, at that index is the EBCDIC char value * of that character. */ const unsigned char ASCII_to_EBCDIC[] = { 0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e, 0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e, 0x40,0x5a,0x7f,0x7b,0x5b,0x6c,0x50,0x7d,0x4d,0x5d,0x5c,0x4e,0x6b,0x60,0x00,0x61, 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0x7a,0x5e,0x4c,0x7e,0x6e,0x6f, 0x7c,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6, 0xd7,0xd8,0xd9,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xad,0xe0,0xbd,0x5f,0x6d, 0x79,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x91,0x92,0x93,0x94,0x95,0x96, 0x97,0x98,0x99,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0x8b,0x4f,0x9b,0xa1,0x2e }; void insertByte (unsigned char c, int in_undo) { unsigned long off = 0; if (extrabuf <= 0) /* allocate extra chunks to use for inserting when full */ { extrabuf = EXTRA_BUF; filebuf = realloc (filebuf, Globals.filesize + 1 + extrabuf); if (!filebuf) die_horribly ("\nNot enough Memory! file not saved", NULL); memset (filebuf + Globals.filesize, 0, extrabuf); } memmove (filebuf + offset + 1, filebuf + offset, Globals.filesize - offset + 1); if (!in_undo) pushUndo (INSERT, offset, filebuffer (offset), c); *(filebuf + offset) = c; clear_hash (); off = offset & M_0xFFFFFFF0; off -= (cursor_y - MAIN_TOP_LINE) * 0x10; Globals.filesize++; Globals.buffsize++; Globals.buf_end++; extrabuf--; Globals.modified = MODIFIED; printStatusWindow (); drawdump (off); wmove (Globals.wmain, cursor_y, cursor_x); wrefresh (Globals.wmain); refresh (); } void deleteByte (int in_undo) { unsigned long off = 0; if (Globals.filesize <= 0x00) { off = 0; if (*filebuf) pushUndo (CHANGE, 0x00, filebuffer (0x00), filebuffer (0x00)); *filebuf = 0; cursor_x = 10; Globals.filesize = 0x00; Globals.buf_front = 0; Globals.buf_end = 0; do_beep (); printStatusWindow (); drawdump (off); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (Globals.wmain); refresh (); return; } if (offset < Globals.filesize) { if (!in_undo) pushUndo (DELETE, offset, filebuffer (offset), filebuffer (offset)); memmove (filebuf + offset, filebuf + offset + 1, Globals.filesize - offset); } else if (offset == Globals.filesize) { if (!in_undo) pushUndo (DELETE, offset, filebuffer (offset), filebuffer (offset)); *(filebuf + offset) = 0; if (!mapcur (cursor_x)) { if (Globals.spacing) cursor_x = 59; else cursor_x = 43; if (cursor_y > MAIN_TOP_LINE) cursor_y--; } else cursor_x = mappos (mapcur (cursor_x) - 1); offset--; } else /* this had better not ever happen */ { offset = Globals.filesize; cursor_x = mappos (offset & M_0x0F); do_beep (); die_horribly ("Died a horrible, horrible death. Mail maintainer", NULL); return; } *(filebuf + Globals.filesize) = 0; clear_hash (); Globals.filesize--; Globals.buffsize--; Globals.buf_end--; off = offset & M_0xFFFFFFF0; off -= (cursor_y - MAIN_TOP_LINE) * 0x10; if (off < 0x00) off = 0; extrabuf++; Globals.modified = MODIFIED; printStatusWindow (); drawdump (off); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (Globals.wmain); refresh (); } void over_write (wchar_t in) { unsigned long off = 0; if (!isprintable (in)) return; if (Globals.tabb) { if ((cursor_y == BOTTOM_LINE) && (mapcur (cursor_x) == 15)) /* Bottom right corner */ { pushUndo (CHANGE, offset, filebuffer (offset), in); if (Globals.charset == ASCII_CHAR_SET) filebuff_modify (offset, in); else /* EBCDIC */ filebuff_modify (offset, findEBCDIC (in)); if (offset < Globals.filesize) /* data below, scroll screen */ { offset++; cursor_x = mappos (0); } else /* just overwrite character */ { do_beep (); } } else if (offset == Globals.filesize) { pushUndo (CHANGE, offset, filebuffer (offset), in); if (Globals.charset == ASCII_CHAR_SET) filebuff_modify (offset, in); else /* EBCDIC */ filebuff_modify (offset, findEBCDIC (in)); do_beep (); } else if (mapcur (cursor_x) == 15) /* right edge of screen, not bottom corner */ { pushUndo (CHANGE, offset, filebuffer (offset), in); if (Globals.charset == ASCII_CHAR_SET) filebuff_modify (offset, in); else /* EBCDIC */ filebuff_modify (offset, findEBCDIC (in)); offset++; cursor_x = mappos (0); cursor_y++; } else { pushUndo (CHANGE, offset, filebuffer (offset), in); if (Globals.charset == ASCII_CHAR_SET) filebuff_modify (offset, in); else /* EBCDIC */ filebuff_modify (offset, findEBCDIC (in)); offset++; cursor_x = mappos (mapcur (cursor_x) + 1); } off = offset & M_0xFFFFFFF0; off -= (cursor_y - 1) * M_0x10; Globals.modified = MODIFIED; drawdump (off); printStatusWindow (); wrefresh (Globals.wmain); wrefresh (Globals.wstatus); move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); refresh (); } else if (isHexChar (in) && Globals.spacing) { if ((cursor_y == BOTTOM_LINE) && (cursor_x == 60)) /* Bottom right corner */ { unsigned char old_value = filebuffer (offset); unsigned char nc = (filebuffer (offset) & M_0xF0) | getHexValue (in); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); if (offset < Globals.filesize) { offset++; cursor_x = mappos (0); } else { do_beep (); } } else if (offset == Globals.filesize) { if ( cursor_x == 10 || cursor_x == 13 || cursor_x == 16 || cursor_x == 19 || cursor_x == 23 || cursor_x == 26 || cursor_x == 29 || cursor_x == 32 || cursor_x == 37 || cursor_x == 40 || cursor_x == 43 || cursor_x == 46 || cursor_x == 50 || cursor_x == 53 || cursor_x == 56 || cursor_x == 59) { unsigned char old_value = filebuffer (offset); unsigned char nc = (getHexValue (in) << 4) | (filebuffer (offset) & M_0x0F); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); cursor_x++; } else { unsigned char old_value = filebuffer (offset); unsigned char nc = (filebuffer (offset) & M_0xF0) | getHexValue (in); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); do_beep (); } } else if (cursor_x == 60) { unsigned char old_value = filebuffer (offset); unsigned char nc = (filebuffer (offset) & M_0xF0) | getHexValue (in); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); offset++; cursor_x = mappos (0); cursor_y++; } else if ( cursor_x == 10 || cursor_x == 13 || cursor_x == 16 || cursor_x == 19 || cursor_x == 23 || cursor_x == 26 || cursor_x == 29 || cursor_x == 32 || cursor_x == 37 || cursor_x == 40 || cursor_x == 43 || cursor_x == 46 || cursor_x == 50 || cursor_x == 53 || cursor_x == 56 || cursor_x == 59) { unsigned char old_value = filebuffer (offset); unsigned char nc = (getHexValue (in) << 4) | (filebuffer (offset) & M_0x0F); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); cursor_x++; } else { unsigned char old_value = filebuffer (offset); unsigned char nc = (filebuffer (offset) & M_0xF0) | getHexValue (in); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); offset++; cursor_x = mappos (mapcur (cursor_x) + 1); } off = offset & M_0xFFFFFFF0; off -= (cursor_y - 1) * M_0x10; Globals.modified = MODIFIED; drawdump (off); printStatusWindow (); wrefresh (Globals.wmain); wrefresh (Globals.wstatus); move (cursor_y, cursor_x); refresh (); } else if (isHexChar (in) && !Globals.spacing) { if ((cursor_y == BOTTOM_LINE) && (cursor_x == 44)) /* Bottom right corner */ { unsigned char old_value = filebuffer (offset); unsigned char nc = (filebuffer (offset) & M_0xF0) | getHexValue (in); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); if (offset < Globals.filesize) { offset++; cursor_x = mappos (0); } else { do_beep (); } } else if (offset == Globals.filesize) { if ( cursor_x == 10 || cursor_x == 12 || cursor_x == 14 || cursor_x == 16 || cursor_x == 19 || cursor_x == 21 || cursor_x == 23 || cursor_x == 25 || cursor_x == 28 || cursor_x == 30 || cursor_x == 32 || cursor_x == 34 || cursor_x == 37 || cursor_x == 39 || cursor_x == 41 || cursor_x == 43) { unsigned char old_value = filebuffer (offset); unsigned char nc = (getHexValue (in) << 4) | (filebuffer (offset) & M_0x0F); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); cursor_x++; } else { unsigned char old_value = filebuffer (offset); unsigned char nc = (filebuffer (offset) & M_0xF0) | getHexValue (in); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); do_beep (); } } else if (cursor_x == 44) { unsigned char old_value = filebuffer (offset); unsigned char nc = (filebuffer (offset) & M_0xF0) | getHexValue (in); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); offset++; cursor_x = mappos (0); cursor_y++; } else if ( cursor_x == 10 || cursor_x == 12 || cursor_x == 14 || cursor_x == 16 || cursor_x == 19 || cursor_x == 21 || cursor_x == 23 || cursor_x == 25 || cursor_x == 28 || cursor_x == 30 || cursor_x == 32 || cursor_x == 34 || cursor_x == 37 || cursor_x == 39 || cursor_x == 41 || cursor_x == 43) { unsigned char old_value = filebuffer (offset); unsigned char nc = (getHexValue (in) << 4) | (filebuffer (offset) & M_0x0F); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); cursor_x++; } else { unsigned char old_value = filebuffer (offset); unsigned char nc = (filebuffer (offset) & M_0xF0) | getHexValue (in); filebuff_modify (offset, nc); pushUndo (CHANGE, offset, old_value, filebuffer (offset)); offset++; cursor_x = mappos (mapcur (cursor_x) + 1); } off = offset & M_0xFFFFFFF0; off -= (cursor_y - 1) * M_0x10; Globals.modified = MODIFIED; drawdump (off); printStatusWindow (); wrefresh (Globals.wmain); wrefresh (Globals.wstatus); move (cursor_y, cursor_x); refresh (); } } wchar_t findEBCDIC (wchar_t in) { /* wchar_t i = 0; for (i = 0; i < 256; i++) { if (in == EBCDIC[i]) return i; } do_beep (); assert (0); return 0; */ return ASCII_to_EBCDIC[in]; } void filebuff_modify (unsigned long offs, unsigned char c) { /* If the whole buffer isn't in memory, we need to adjust where * our offset is actually in filebuf, and also hash the change. * The actual offset in filebuf will be (offset - buf_front), * Assuming of course that the place being modified is always * in the current buffer. This should always be true. So * should (offset >= buf_front); */ if (!Globals.fullsize) { assert (offset >= Globals.buf_front); *(filebuf + offset - Globals.buf_front) = c; insert_hash_entry (offset, c); } /* If the whole buffer Is in memory, we just change at that offset * in filebuf. */ else { *(filebuf + offset) = c; insert_hash_entry (offset, c); } } ncurses-hexedit-0.9.7.orig/src/file.c0100644000175000017500000003715306736240473016125 0ustar apocapoc/* file.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "../config.h" #include #ifdef HAVE_DIRENT_H #include #endif #include #include #ifdef TM_IN_SYS_TIME #include #endif #include #include "hexedit.h" struct FileNames *fp = NULL; /* used to traverse the list of files */ struct FileNames **pages = NULL; /* node that starts a new page */ int current_page = 0; int num_pages = 0; static void exit_p (int); static void exit_p (int i) { endwin (); exit (EXIT_SUCCESS); } char * fileSelect () { char *p = NULL; char *ret = NULL; char dir[PATH_MAX + 1]; char previous_dir[PATH_MAX + 1]; char trunc_file[PATH_MAX + 1]; wchar_t in = 0; int i = 0; int result = 0; struct FileNames *front = NULL; struct stat filestats; DIR *d = NULL; struct sigaction sig_a, sig_old; sig_a.sa_handler = exit_p; memset (&sig_a.sa_mask, 0x00, sizeof (sigset_t)); sig_a.sa_flags = 0; sigaction (SIGINT, &sig_a, &sig_old); Globals.mode = FILE_MODE; memset (dir, 0x00, PATH_MAX + 1); memset (previous_dir, 0x00, PATH_MAX + 1); getcwd (previous_dir, PATH_MAX); while (1) { int num = 0; int rerr = 0; int derr = 0; if (*dir) strcpy (previous_dir, dir); memset (dir, 0x00, PATH_MAX + 1); p = getcwd (dir, PATH_MAX); if (!p) die_horribly (NULL, "getcwd"); front = fp = getDirectory (dir); if (!fp) { result = errno; front = fp = getDirectory (previous_dir); if (!fp) { errno = result; die_horribly (NULL, previous_dir); } strcpy (dir, previous_dir); } while (fp) { fp = fp->p; num++; } num_pages = ((num - 1) / (LINES - 2)) + 1; pages = malloc (sizeof (struct FileNames *) * num_pages); memset (pages, 0x00, num_pages * sizeof (struct FileNames *)); *pages = front; fp = front; for (i = 1; i < num_pages; i++) { int j = 0; for (j = 0; (j < (LINES - 2)) && fp; j++) fp = fp->p; *(pages + i) = fp; } fp = front; current_page = 0; cursor_y = MAIN_TOP_LINE; werase (Globals.wstatus); werase (Globals.wmain); werase (Globals.whelp); printPage (*pages); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, 0, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); statWindow (fp->filename); helpWindow ("^C ^X Exit ^M Select File k Up j Down"); wrefresh (Globals.wstatus); wrefresh (Globals.wmain); wrefresh (Globals.whelp); move (cursor_y, NAME_POS); refresh (); while ((in = getch ()) != '\n') { memset (trunc_file, 0x00, PATH_MAX + 1); switch (in) { case CONTROL_C: case CONTROL_X: exit_p (0); case KEY_UP: case 'k': file_key_up (¤t_page); break; case KEY_DOWN: case 'j': file_key_down (¤t_page, num_pages); break; case CONTROL_L: file_redraw (¤t_page); break; case KEY_F(5): if (color_term != -1) color_term ^= 1; file_redraw (¤t_page); break; case CONTROL_V: case CONTROL_F: case KEY_NPAGE: case KEY_C3: case ' ': file_pagedown (¤t_page, num_pages); break; case CONTROL_Y: case CONTROL_B: case KEY_PPAGE: case KEY_A3: case '-': #ifdef __PDCURSES__ case ALT_V: #endif /* Page up */ file_pageup (¤t_page); break; case KEY_HOME: file_home (¤t_page); break; case KEY_END: file_end (¤t_page, num_pages); break; case ESCAPE_CHARACTER: in = getch (); switch (in) { case 79: in = getch (); switch (in) { case 'A': file_key_up (¤t_page); break; case 'B': file_key_down (¤t_page, num_pages); break; } break; case 91: in = getch (); switch (in) { case 49: /* home */ file_home (¤t_page); break; case 52: /* end */ file_end (¤t_page, num_pages); break; case 53: /* page up */ file_pageup (¤t_page); break; case 54: /* page down */ file_pagedown (¤t_page, num_pages); break; } getch (); /* returns 126 */ } break; default: break; } } stat (fp->filename, &filestats); if (!S_ISDIR (filestats.st_mode)) break; errno = 0; d = opendir (fp->filename); derr = errno; closedir (d); errno = 0; result = chdir (fp->filename); rerr = errno; if (result || !d) { #define FILE_BOX_WIDTH 50 #define FILE_BOX_HEIGHT 6 WINDOW *wpopup = popupWindow (FILE_BOX_WIDTH, FILE_BOX_HEIGHT); char pdir[PATH_MAX + 1]; errno = derr ? derr : rerr; werase (wpopup); box (wpopup, 0, 0); wmove (wpopup, 1, (FILE_BOX_WIDTH / 2) - (strlen ("Cannot Change Directory") / 2)); wprintw (wpopup, "Cannot Change Direcotry"); wmove (wpopup, FILE_BOX_HEIGHT - 3, (FILE_BOX_WIDTH / 2) - (strlen (strerror (errno)) + strlen ("Reason: ")) / 2); wprintw (wpopup, "Reason: %s", strerror (errno)); wrefresh (wpopup); getch (); memset (pdir, 0x00, PATH_MAX + 1); if (*previous_dir != '/' && *previous_dir != '.') strcpy (pdir, "../"); strcat (pdir, previous_dir); result = chdir (pdir); if (result) die_horribly ("Cannot change back to previous directory", pdir); } else { memset (dir, 0x00, PATH_MAX + 1); strcpy (dir, fp->filename); } free (pages); while (front) { fp = front->p; free (front->filename); free (front); front = fp; } } /* This needs to be freed when editing a new file. */ ret = malloc (strlen (fp->filename) + 1); if (!ret) die_horribly (NOT_ENOUGH_MEMORY, NULL); strcpy (ret, fp->filename); while (front) { fp = front->p; free (front->filename); free (front); front = fp; } if (pages) free (pages); /* signal (SIGINT, sigp); */ sigaction (SIGINT, &sig_old, NULL); return ret; } void statWindow (const char * const filename) { int i = 0; int l = 0; wattrset (Globals.wstatus, color_term ? COLOR_PAIR(4) | A_BOLD : A_REVERSE); wmove (Globals.wstatus, 0, 0); wprintw (Globals.wstatus, "File: %s\n", filename); l = strlen (filename); wmove (Globals.wstatus, 0, l + 6); for (i = 0; i < (COLS - l - 6); i++) wprintw (Globals.wstatus, " "); } void helpWindow (const char * const filename) { wattrset (Globals.whelp, color_term ? COLOR_PAIR(3) | A_BOLD : A_NORMAL); wmove (Globals.whelp, 0, 0); wprintw (Globals.whelp, "%s", filename); } struct FileNames * getDirectory (const char * const dir) { DIR *d = NULL; int i = 0; int num = 0; struct dirent *dp = NULL; struct FileNames *fnp = NULL; struct FileNames *front = NULL; d = opendir (dir); if (!d) { return NULL; } while ((dp = readdir (d))) { if (!fnp) { front = fnp = malloc (sizeof (struct FileNames)); if (!fnp) die_horribly (NOT_ENOUGH_MEMORY, NULL); } else { fnp->p = malloc (sizeof (struct FileNames)); if (!fnp->p) die_horribly (NOT_ENOUGH_MEMORY, NULL); fnp = fnp->p; } fnp->filename = malloc (strlen (dp->d_name) + 1); if (!fnp->filename) die_horribly (NOT_ENOUGH_MEMORY, NULL); strcpy (fnp->filename, dp->d_name); fnp->p = NULL; num++; } if (num > 1) /* Split the list up in half for merge sort. */ { fnp = front; for (i = 0; i < (num / 2); i++) { assert (fnp && fnp->p); if (i == ((num / 2) - 1)) { struct FileNames *p = fnp; fnp = fnp->p; p->p = NULL; } else fnp = fnp->p; } front = merge (msort (front), msort (fnp)); } closedir (d); return front; } struct FileNames * merge (struct FileNames *p1, struct FileNames *p2) /* Merge for merge sort of linked list of filenames. */ { struct FileNames *files = NULL; struct FileNames *front = NULL; while (p1 && p2) { if (!files) { if (strcmp (p1->filename, p2->filename) < 0) { files = p1; p1 = p1->p; } else { files = p2; p2 = p2->p; } front = files; } else { if (strcmp (p1->filename, p2->filename) < 0) { files->p = p1; p1 = p1->p; } else { files->p = p2; p2 = p2->p; } files = files->p; } files->p = NULL; } while (p1) { files->p = p1; files = files->p; p1 = p1->p; } while (p2) { files->p = p2; files = files->p; p2 = p2->p; } files->p = NULL; return front; } struct FileNames * msort (struct FileNames *p) /* The sort part of the merge sort. */ { int i = 0; int num = 0; struct FileNames *fnp = p; if (!p) return NULL; if (!p->p) return p; while (fnp) { fnp = fnp->p; num++; } fnp = p; for (i = 0; i < (num / 2); i++) { assert (fnp && fnp->p); if (i == ((num / 2) - 1)) { struct FileNames *tp = fnp; fnp = fnp->p; tp->p = NULL; } else fnp = fnp->p; } return merge (msort (p), msort (fnp)); } void printPage (const struct FileNames *fp) { int i = 0; int result = 0; char *bits[] = { "---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx" }; char trunc_file[PATH_MAX + 1]; struct stat filestat; if (color_term) wattrset (Globals.wmain, COLOR_PAIR(1)); for (i = 0; (i < (LINES - 2)) && fp; i++) { char modebits[11]; char s1[11]; char s2[11]; struct passwd *pw = NULL; struct group *gw = NULL; struct tm *tp = NULL; memset (s1, 0x00, 11); memset (s2, 0x00, 11); result = stat (fp->filename, &filestat); wmove (Globals.wmain, i, 0); if (!result) /* do the ls thingy with the file mode */ { memset (modebits, 0x00, 11); if (S_ISDIR (filestat.st_mode)) modebits[0] = 'd'; else if (S_ISCHR (filestat.st_mode)) modebits[0] = 'c'; else if (S_ISBLK (filestat.st_mode)) modebits[0] = 'b'; else if (S_ISFIFO (filestat.st_mode)) modebits[0] = 'p'; #ifndef __PDCURSES__ else if (S_ISSOCK (filestat.st_mode)) modebits[0] = 's'; else if (S_ISLNK (filestat.st_mode)) modebits[0] = 'l'; #endif else modebits[0] = '-'; strcat (modebits, bits[(filestat.st_mode & 0700) >> 6]); strcat (modebits, bits[(filestat.st_mode & 0070) >> 3]); strcat (modebits, bits[filestat.st_mode & 0007]); if (filestat.st_mode & 01000) { if (filestat.st_mode & 0001) modebits[9] = 't'; else modebits[9] = 'T'; } if (filestat.st_mode & 02000) { if (filestat.st_mode & 0010) modebits[6] = 's'; else modebits[6] = 'S'; } if (filestat.st_mode & 01000) { if (filestat.st_mode & 0100) modebits[3] = 's'; else modebits[3] = 'S'; } tp = localtime (&filestat.st_mtime); pw = getpwuid (filestat.st_uid); gw = getgrgid (filestat.st_gid); #ifdef HAVE_SNPRINTF if (!pw) snprintf (s1, 11, "%d", (int) filestat.st_uid); else snprintf (s1, 11, "%s", pw->pw_name); if (!gw) snprintf (s2, 11, "%d", (int) filestat.st_gid); else snprintf (s2, 11, "%s", gw->gr_name); #else if (!pw) sprintf (s1, "%d", (int) filestat.st_uid); else sprintf (s1, "%s", pw->pw_name); if (!gw) sprintf (s2, "%d", (int) filestat.st_gid); else sprintf (s2, "%s", gw->gr_name); #endif wprintw (Globals.wmain, /* why does it seem like on OpenBSD this is broken? */ #if defined(__OpenBSD__) || defined(BROKEN) "%s %-8s %-8s %10ld %1d\b2d-%02d-%02d %02d:%02d ", #else "%s %-8s %-8s %10ld %d-%02d-%02d %02d:%02d ", #endif modebits, s1, s2, filestat.st_size, 1900 + tp->tm_year, 1 + tp->tm_mon, tp->tm_mday, tp->tm_hour, tp->tm_min); } /* stat failed, print enough spaces to align file anyways */ else { int j = 0; for (j = 0; j < 57; j++) wprintw (Globals.wmain, " "); } memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wprintw (Globals.wmain, "%s", trunc_file); fp = fp->p; for (result = Globals.wmain->_curx; result < COLS; result++) wprintw (Globals.wmain, " "); } /* Fill in rest of the screen with default color. */ for (; i < (LINES - 2); i++) for (result = 0; result < COLS; result++) wprintw (Globals.wmain, " "); } ncurses-hexedit-0.9.7.orig/src/filebuf.c0100644000175000017500000000712606735274535016624 0ustar apocapoc/* filebuf.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" #include void initbuffer (FILE *filep, unsigned long front, unsigned long end) { Globals.buf_front = front; Globals.buf_end = end; Globals.fp = filep; } unsigned char filebuffer (unsigned long offs) /* This is used for all accesses to the current file being viewed or * edited. All access to filebuf is done indirectly since this way * we can buffer the file in small pieces to save memory if needed. * The buffer very well may be just the size of the entire file. */ { unsigned long temp = 0; /* If the requested section of the file is already in memory, * just return that byte */ if ((offs >= Globals.buf_front) && (offs <= Globals.buf_end)) return *(filebuf + offs - Globals.buf_front); /* Else we load a new section of the file into memory. We will * take the position asked for and buffer before and after it */ temp = offs - (Globals.buffsize / 2); /* check for unsigned underflow: lower bound > upper bound */ if (temp > offs) temp = 0; Globals.buf_front = temp; Globals.buf_end = Globals.buf_front + Globals.buffsize - 1; /* check for unsigned overflow: upper bound < lower bound */ if (Globals.buf_end < Globals.buf_front) Globals.buf_end = Globals.buffsize; memset (filebuf, 0x00, Globals.buffsize); filebuffer_new_buf (); return *(filebuf + offs - Globals.buf_front); } unsigned long filebuffer_new_buf () { int i = 0; unsigned long filled = 0; int next_read = 0; int result = 0; unsigned char strbuf[DEFAULT_READ_BUFFER]; unsigned char c = '\0'; result = fseek (Globals.fp, Globals.buf_front, SEEK_SET); filled = 0; next_read = ((filled + DEFAULT_READ_BUFFER) > Globals.buffsize) ? DEFAULT_READ_BUFFER - filled : DEFAULT_READ_BUFFER; memset (strbuf, 0, DEFAULT_READ_BUFFER); while ((result = fread (strbuf, 1, next_read, Globals.fp)) > 0) { if (ferror (Globals.fp)) die_horribly (NULL, Globals.filename); memcpy (filebuf + i, strbuf, result); i += result; if (i > Globals.filesize + 1) die_horribly ("file has changed, restart", NULL); filled += result; if (filled < Globals.buffsize) { next_read = ((filled + DEFAULT_READ_BUFFER) > Globals.buffsize) ? DEFAULT_READ_BUFFER - filled : DEFAULT_READ_BUFFER; } if ((next_read <= 0) || (filled >= Globals.buffsize)) break; memset (strbuf, 0, 2048); } /* Since we may be reading a portion of the file from disk that * may have been edited, we need to add those changes back into * the current filebuf. */ if (Globals.modified != READ_ONLY && !Globals.fullsize) { for (i = 0; i < filled; i++) { if (!hash_lookup (Globals.buf_front + i, &c)) *(filebuf + i) = c; } } return filled; } ncurses-hexedit-0.9.7.orig/src/filekeys.c0100644000175000017500000003117006735455361017015 0ustar apocapoc/* filekeys.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" #define NAME_POS 57 /* Magic number of where filename always starts */ extern struct FileNames *fp; extern struct FileNames **pages; /* node that starts a new page */ void file_key_up (int *current_page) { char trunc_file[PATH_MAX + 1]; if (cursor_y <= MAIN_TOP_LINE) { if (*current_page <= 0) /* do_beep (); */ ; else { cursor_y = BOTTOM_LINE; memset (trunc_file, 0x00, PATH_MAX + 1); fp = *(pages + --*current_page); while (fp->p != *(pages + *current_page + 1)) fp = fp->p; werase (Globals.wstatus); werase (Globals.wmain); printPage (*(pages + *current_page)); statWindow (fp->filename); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wrefresh (Globals.wstatus); wrefresh (Globals.wmain); move (cursor_y, NAME_POS); } } else { struct FileNames *tp = *(pages + *current_page); while (tp->p != fp) tp = tp->p; wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(1) : A_NORMAL); wprintw (Globals.wmain, "%s", trunc_file); cursor_y--; fp = tp; memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); statWindow (fp->filename); wrefresh (Globals.wstatus); wrefresh (Globals.wmain); move (cursor_y, NAME_POS); } refresh (); } void file_key_down (int *current_page, int n) { char trunc_file[PATH_MAX + 1]; if (cursor_y >= BOTTOM_LINE) { if ((*current_page < (n - 1)) && (n > 1)) { werase (Globals.wstatus); werase (Globals.wmain); printPage (*(pages + ++*current_page)); fp = *(pages + *current_page); wmove (Globals.wmain, 0, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); statWindow (fp->filename); cursor_y = MAIN_TOP_LINE; move (cursor_y, NAME_POS); wrefresh (Globals.wstatus); wrefresh (Globals.wmain); } else /* do_beep (); */ ; } else { if (!fp->p) /* do_beep (); */ ; else { wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(1) : A_NORMAL); wprintw (Globals.wmain, "%s", trunc_file); cursor_y++; fp = fp->p; memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); statWindow (fp->filename); wrefresh (Globals.wstatus); wrefresh (Globals.wmain); move (cursor_y, NAME_POS); } } refresh (); } void file_redraw (int *current_page) { char trunc_file[PATH_MAX + 1]; werase (Globals.wstatus); wrefresh (Globals.wstatus); werase (Globals.wmain); wrefresh (Globals.wmain); werase (Globals.whelp); wrefresh (Globals.whelp); printPage (*(pages + *current_page)); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); statWindow (fp->filename); helpWindow ("^C ^X Exit ^M Select File"); wrefresh (Globals.wstatus); wrefresh (Globals.wmain); wrefresh (Globals.whelp); wmove (Globals.wmain, 0, NAME_POS); move (cursor_y, NAME_POS); refresh (); } void file_pagedown (int *current_page, int n) { char trunc_file[PATH_MAX + 1]; if ((*current_page < (n - 1)) && (n > 1)) { int i = MAIN_TOP_LINE; fp = *(pages + ++*current_page); for (i = MAIN_TOP_LINE; (i < cursor_y) && fp->p; i++) { fp = fp->p; } cursor_y = i; /* bottom may not exist */ werase (Globals.wmain); printPage (*(pages + *current_page)); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); } else { memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(1) : A_NORMAL); wprintw (Globals.wmain, "%s", trunc_file); cursor_y = MAIN_TOP_LINE; fp = *(pages + *current_page); while (fp->p) { cursor_y++; fp = fp->p; } memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); } statWindow (fp->filename); move (cursor_y, NAME_POS); wrefresh (Globals.wstatus); wrefresh (Globals.wmain); refresh (); } void file_pageup (int *current_page) { char trunc_file[PATH_MAX + 1]; if (*current_page > 0) { int i = MAIN_TOP_LINE; fp = *(pages + --*current_page); for (i = MAIN_TOP_LINE; i < cursor_y; i++) { fp = fp->p; } werase (Globals.wmain); printPage (*(pages + *current_page)); statWindow (fp->filename); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); } else { memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(1) : A_NORMAL); wprintw (Globals.wmain, "%s", trunc_file); cursor_y = MAIN_TOP_LINE; fp = *pages; memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); statWindow (fp->filename); } move (cursor_y, NAME_POS); wrefresh (Globals.wstatus); wrefresh (Globals.wmain); refresh (); } void file_home (int *current_page) { char trunc_file[PATH_MAX + 1]; if (*current_page) { *current_page = 0; cursor_y = MAIN_TOP_LINE; werase (Globals.wmain); werase (Globals.wstatus); fp = *pages; statWindow (fp->filename); printPage (*pages); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); move (cursor_y, NAME_POS); } else /* already on first page */ { strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(1) : A_NORMAL); wprintw (Globals.wmain, "%s", trunc_file); fp = *pages; strncpy (trunc_file, fp->filename, COLS - NAME_POS); cursor_y = MAIN_TOP_LINE; wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); werase (Globals.wstatus); statWindow (fp->filename); move (cursor_y, NAME_POS); } wrefresh (Globals.wstatus); wrefresh (Globals.wmain); refresh (); } void file_end (int *current_page, int n) { char trunc_file[PATH_MAX + 1]; if (*current_page < (n - 1)) { cursor_y = MAIN_TOP_LINE; werase (Globals.wmain); *current_page = n - 1; fp = *(pages + *current_page); while (fp->p) { cursor_y++; fp = fp->p; } printPage (*(pages + *current_page)); memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); } else { memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, color_term ? COLOR_PAIR(1) : A_NORMAL); wprintw (Globals.wmain, "%s", trunc_file); fp = *(pages + *current_page); cursor_y = MAIN_TOP_LINE; while (fp->p) { cursor_y++; fp = fp->p; } wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); } statWindow (fp->filename); move (cursor_y, NAME_POS); wrefresh (Globals.wmain); wrefresh (Globals.wstatus); refresh (); } ncurses-hexedit-0.9.7.orig/src/hash.c0100644000175000017500000001435606735424377016137 0ustar apocapoc/* hash.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ /* This file contains a simple hash for looking up changes we may have * made to specific offsets in the file. When we are editing a large * file that cannot fit in memory, when we reread a portion of the file * from disk, it will be the original, and not the changed, so we need * to lookup changes and add them to the current buffer in memory. * The Hash function is just a mod 1009 into the hash table of 0-1008 * entries. Collisions are handled with just a list of entries for * that index in the hash. The key/pair is offset/byte-value. */ #include "hexedit.h" /* All the books say this should usually be a prime number */ #define HASH_TABLE_SIZE 1009 /* The really complex and thought out hash function. */ #define HASH(x) (x % HASH_TABLE_SIZE) /* list of chained collisions */ struct hash_list { unsigned long offset; unsigned char value; struct hash_list *next; }; struct hash_table { struct hash_list *chain; }; /* hash table */ static struct hash_table *table = NULL; void init_hash () /* set each location empty by setting *next chain to -1 */ { int i = 0; if (table) { struct hash_list *p = NULL; for (i = 0; i < HASH_TABLE_SIZE; i++) { while (table[i].chain) { p = table[i].chain->next; free (table[i].chain); table[i].chain = p; } } free (table); } table = malloc (HASH_TABLE_SIZE * sizeof (struct hash_table)); if (!table) die_horribly ("Not enough memory to create hash table\n", NULL); for (i = 0; i < HASH_TABLE_SIZE; i++) { table[i].chain = NULL; } } void clear_hash () { int i = 0; struct hash_list *p = NULL; for (i = 0; i < HASH_TABLE_SIZE; i++) { while (table[i].chain) { p = table[i].chain; table[i].chain = table[i].chain->next; free (p); } } } void insert_hash_entry (unsigned long offset, unsigned char value) { int i = HASH(offset); if (!table[i].chain) /* empty location in table */ { table[i].chain = malloc (sizeof (struct hash_list)); if (!table[i].chain) die_horribly (NOT_ENOUGH_MEMORY, NULL); table[i].chain->offset = offset; table[i].chain->value = value; table[i].chain->next = NULL; } else /* Has at least one element in table. Insert the new collision * into the front of the chain. */ { struct hash_list *p = table[i].chain; /* First, make sure entry isn't already here, if it is, we * change it to the new value. */ while (p) { if (p->offset == offset) { p->value = value; break; } p = p->next; } if (p) return; /* already in hash */ p = malloc (sizeof (struct hash_list)); if (!p) die_horribly (NOT_ENOUGH_MEMORY, NULL); /* build the new entry */ p->offset = offset; p->value = value; p->next = table[i].chain; /* now put entry in the front of the list */ table[i].chain = p; } } void delete_hash_entry (unsigned long offset) { int i = HASH(offset); struct hash_list *p = table[i].chain; /* hash entry not here */ if (!p) return; /* one or more at this index */ else { struct hash_list *last = NULL; while (p) { if (p->offset == offset) break; last = p; p = p->next; } /* if we found it delete it */ if (p) { /* if item isn't first element */ if (last) { last->next = p->next; /* skip over p */ free (p); /* then delete it */ } else { table[i].chain = p->next; /* skip over p */ free (p); /* then delete it */ } } } } int hash_lookup (unsigned long offset, unsigned char *c) /* return -1 on lookup failure. Store value in *c if successful */ { int i = HASH(offset); struct hash_list *p = table[i].chain; while (p) { if (p->offset == offset) break; p = p->next; } if (p) { if (c) *c = p->value; return 0; } return -1; } #ifdef DEBUG_HASH void print_hash_table () { int i = 0; for (i = 0; i < HASH_TABLE_SIZE; i++) { fprintf (stderr, "%d: ", i); /* empty entry */ if (!table[i].chain) fprintf (stderr, "empty\n"); else { struct hash_list *p = table[i].chain; while (p) { fprintf (stderr, "(%ld,%d) ", p->offset, p->value); p = p->next; } fprintf (stderr, "\n"); } } } #endif void commit_changes_in_hash (FILE *fp) /* cycle through the hash and write back all the entries, and clear * the hash while we're at it. */ { int i = 0; int result = 0; struct hash_list *p = NULL; for (i = 0; i < HASH_TABLE_SIZE; i++) { p = table[i].chain; while (table[i].chain) { result = fseek (fp, table[i].chain->offset, SEEK_SET); if (result) die_horribly ("Cannot write new file correctly", "fseek"); result = fwrite (&table[i].chain->value, 1, 1, fp); if (!result && ferror (fp)) die_horribly ("File writing error", "ferror"); else if (!result && feof (fp)) die_horribly ("End of File Reached?", "feof"); p = table[i].chain->next; free (table[i].chain); table[i].chain = p; } } } ncurses-hexedit-0.9.7.orig/src/help.c0100644000175000017500000000620506753171610016123 0ustar apocapoc/* help.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" /* we need to modify these two strings to display the correct message, * how to insert/delete if enabled, or how to enable it. */ #define INSERT_MSG_INDEX 4 #define DELETE_MSG_INDEX 5 #define HELP_MSG_COUNT 21 /* The help messages used with the online help screen. */ const char *help_msgs[] = { "Maneuver Arror Keys (or h,j,k,l), Home, End", "Page Up Control-y, Control-b, Alt-v, Page Up (^Y) (^B) u y", "Page Down Control-v, Control-f, Page Down (^V) (^F) v space", "Bytes <=> text Tab, Control-i (^I)", "Insert/Add Byte ", "Delete Byte ", "goTo Offset Control-t (^T), t", "Offset + Jump +, -, n (jump again)", "Help Control-g (^G), F1", "Redraw Screen Control-l (^L)", "Save Control-o (^O), F2", "Save and Quit Control-x (^X), F3", "Quit/New File Control-c (^C)", "viEw as text Control-e (^E)", "Search Control-w (^W), w", "find Next Control-n (^N)", "Undo Control-U (^U)", "ASCII <=> EBCDIC Control-R (^R)", "Switch spacings Control-P (^P)", "Binary Calculator Control-/, Control-_ (^/) (^_)", "Toggle Color F5 (requires color capable terminal)", NULL }; void help_initialize () { char *temp = NULL; /* Take care of Insert message. */ temp = malloc (1 + strlen (help_msgs[INSERT_MSG_INDEX]) + strlen ( Globals.fullsize ? "Control-a, Insert (^A)" : "Disabled. Use -b, --buffer option to enable")); strcpy (temp, help_msgs[INSERT_MSG_INDEX]); strcat (temp, Globals.fullsize ? "Control-a, Insert (^A)" : "Disabled. Use -b, --buffer option to enable"); help_msgs[INSERT_MSG_INDEX] = temp; /* Take care of Delete message. */ temp = malloc (1 + strlen (help_msgs[DELETE_MSG_INDEX]) + strlen ( Globals.fullsize ? "Control-d, Delete (^D)" : "Disabled. Use -b, --buffer option to enable")); strcpy (temp, help_msgs[DELETE_MSG_INDEX]); strcat (temp, Globals.fullsize ? "Control-d, Delete (^D)" : "Disabled. Use -b, --buffer option to enable"); help_msgs[DELETE_MSG_INDEX] = temp; Globals.help_msg_count = HELP_MSG_COUNT; } void help_print (WINDOW *win, int y, int lines) { int i = 1; while ((i < lines) && help_msgs[y]) { wmove (win, i, 3); wprintw (win, "%s", help_msgs[y]); i++; y++; } } ncurses-hexedit-0.9.7.orig/src/hexkeys.c0100644000175000017500000007754206735766674016713 0ustar apocapoc/* hexkeys.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" void hexMode (wchar_t in) { switch (in) { case KEY_UP: case KEY_DOWN: case KEY_LEFT: case KEY_RIGHT: handleArrowKeys (in); wrefresh (Globals.wmain); refresh (); break; case CONTROL_L: redraw (); break; case CONTROL_F: case CONTROL_V: case KEY_NPAGE: case KEY_C3: pagedown (); wrefresh (Globals.wmain); refresh (); break; case CONTROL_B: case CONTROL_Y: case KEY_PPAGE: case KEY_A3: #ifdef __PDCURSES__ case ALT_V: #endif pageup (); wrefresh (Globals.wmain); refresh (); break; case CONTROL_T: popupGotoOffset (Globals.filesize); redraw (); break; case CONTROL_G: case KEY_F(1): popupHelp (); redraw (); break; case CONTROL_O: case KEY_F(2): popupFileSave (); redraw (); break; case CONTROL_P: Globals.spacing ^= 1; cursor_x = cursor_ascii_to_ebcdic (cursor_x); redraw (); break; case CONTROL_R: Globals.charset ^= 1; redraw (); break; case CONTROL_U: if (Globals.modified != READ_ONLY) undoLastChange (); break; case CONTROL_X: case KEY_F(3): if (Globals.modified == MODIFIED) exitSave (popupFileSave ()); else exitProgram (); break; case CONTROL_A: case KEY_IC: if (Globals.modified != READ_ONLY && Globals.fullsize) insertByte (0x00, 0); break; case CONTROL_D: case KEY_DC: if (Globals.modified != READ_ONLY && Globals.fullsize) deleteByte (0); break; case KEY_END: endKey (); break; case KEY_HOME: homeKey (); break; case TAB: tabcursor (&Globals.tabb); break; case CONTROL_E: switchModes (); break; case CONTROL_W: search (0); redraw (); break; case CONTROL_N: search (1); redraw (); break; case CONTROL_SLASH: { int mode = Globals.mode; Globals.mode = CALCULATOR_MODE; binary_calculator (); Globals.mode = mode; redraw (); break; } case KEY_F(5): if (color_term != -1) color_term ^= 1; redraw (); break; case ESCAPE_CHARACTER: in = getch (); switch (in) { case ALT_V: pageup (); wrefresh (Globals.wmain); refresh (); break; case 79: in = getch (); switch (in) { case 'A': in = KEY_UP; break; case 'B': in = KEY_DOWN; break; case 'D': in = KEY_LEFT; break; case 'C': in = KEY_RIGHT; break; } handleArrowKeys (in); wrefresh (Globals.wmain); refresh (); break; case 91: in = getch (); switch (in) { case 49: /* home */ homeKey (); break; case 50: /* insert */ if (Globals.modified != READ_ONLY && Globals.fullsize) insertByte (0x00, 0); break; case 51: /* delete */ if (Globals.modified != READ_ONLY && Globals.fullsize) deleteByte (0); break; case 52: /* end */ endKey (); break; case 53: /* page up */ pageup (); wrefresh (Globals.wmain); refresh (); break; case 54: /* page down */ pagedown (); wrefresh (Globals.wmain); refresh (); break; } getch (); /* returns 126 */ break; } break; default: /* Lots of extra keys can be used only in hex data mode. */ if (!Globals.tabb || (Globals.modified == READ_ONLY)) { int break_out = 0; /* check vi movement keys (h,j,k,l) */ switch (in) { case 'h': /* left */ case 'H': in = KEY_LEFT; break_out = 1; break; case 'j': /* down */ case 'J': in = KEY_DOWN; break_out = 1; break; case 'k': /* up */ case 'K': in = KEY_UP; break_out = 1; break; case 'l': /* right */ case 'L': in = KEY_RIGHT; break_out = 1; break; case 'v': /* page down */ case 'V': case ' ': pagedown (); wrefresh (Globals.wmain); refresh (); break_out = 1; break; case 'u': /* page up */ case 'U': case 'y': case 'Y': pageup (); wrefresh (Globals.wmain); refresh (); break_out = 1; break; case 't': /* goTo offset */ case 'T': popupGotoOffset (Globals.filesize); redraw (); break_out = 1; break; case 'w': /* Search */ case 'W': search (0); redraw (); break_out = 1; break; case 'n': case 'N': jump_relative_offset (0); break_out = 1; break; case '+': case '-': jump_relative_offset (in); break_out = 1; break; } if (break_out) { handleArrowKeys (in); wrefresh (Globals.wmain); refresh (); break; } } if (Globals.modified != READ_ONLY) over_write (in); break; } refresh (); } void handleArrowKeys (wchar_t key) { unsigned long off = 0; switch (key) { case KEY_DOWN: if (cursor_y < BOTTOM_LINE) /* cursor not at bottom */ { offset += M_0x10; if (offset > Globals.filesize) { if ((offset & M_0x0F) > (Globals.filesize & M_0x0F)) { offset -= mapcur (cursor_x) - (Globals.filesize & M_0x0F); cursor_x = mappos (position - 1); } else { offset -= M_0x10; break; } } printStatusWindow (); if (Globals.tabb) move (++cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (++cursor_y, cursor_x); wrefresh (stdscr); } else if (offset + M_0x10 < Globals.filesize + 1) /* cursor at bottom of screen, but data is ready below */ { offset += M_0x10; off = offset & M_0xFFFFFFF0; off -= M_0x10 * (MAIN_BOTTOM_LINE); printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } else if ((offset & M_0xFFFFFFF0) < (Globals.filesize & M_0xFFFFFFF0)) /* cursor at bottom, and no data directly below */ { offset = Globals.filesize; off = offset & M_0xFFFFFFF0; off -= M_0x10 * (MAIN_BOTTOM_LINE); printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); cursor_x = mappos (position - 1); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } break; case KEY_UP: if ((cursor_y <= MAIN_TOP_LINE) && (offset > M_0x0F)) { wmove (Globals.wmain, 0, 0); offset -= M_0x10; off = offset; if (off > Globals.filesize) off = 0; if (offset >= 0x00) { printStatusWindow (); } else offset = 0x00; drawdump (off); wrefresh (Globals.wmain); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } else if (cursor_y > MAIN_TOP_LINE) { offset -= M_0x10; printStatusWindow (); if (Globals.tabb) move (--cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (--cursor_y, cursor_x); wrefresh (stdscr); } break; case KEY_RIGHT: if (Globals.spacing) { if ( cursor_x == 10 || cursor_x == 13 || cursor_x == 16 || cursor_x == 19 || cursor_x == 23 || cursor_x == 26 || cursor_x == 29 || cursor_x == 32 || cursor_x == 37 || cursor_x == 40 || cursor_x == 43 || cursor_x == 46 || cursor_x == 50 || cursor_x == 53 || cursor_x == 56 || cursor_x == 59) { if (Globals.tabb) { cursor_x++; if ((offset < Globals.filesize) && (cursor_x == 11 || cursor_x == 14 || cursor_x == 17 || cursor_x == 20 || cursor_x == 24 || cursor_x == 27 || cursor_x == 30 || cursor_x == 33 || cursor_x == 38 || cursor_x == 41 || cursor_x == 44 || cursor_x == 47 || cursor_x == 51 || cursor_x == 54 || cursor_x == 57)) { offset++; printStatusWindow (); if (cursor_x == 33) cursor_x += 4; else if (cursor_x == 20 || cursor_x == 47) cursor_x += 3; else cursor_x += 2; move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } else if (cursor_x == 60) { if (cursor_y < BOTTOM_LINE) { if (offset >= Globals.filesize) break; offset++; printStatusWindow (); cursor_x = 10; move (++cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } else if (offset < Globals.filesize) { offset++; printStatusWindow (); off = offset; off -= M_0x10 * (MAIN_BOTTOM_LINE); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); cursor_x = 10; move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } } } else move (cursor_y, ++cursor_x); wrefresh (stdscr); } else if ((offset < Globals.filesize) && (cursor_x == 11 || cursor_x == 14 || cursor_x == 17 || cursor_x == 20 || cursor_x == 24 || cursor_x == 27 || cursor_x == 30 || cursor_x == 33 || cursor_x == 38 || cursor_x == 41 || cursor_x == 44 || cursor_x == 47 || cursor_x == 51 || cursor_x == 54 || cursor_x == 57)) { offset++; printStatusWindow (); cursor_x = mappos (offset & M_0x0F); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } else if (cursor_x == 60) { if (cursor_y < BOTTOM_LINE) { if (offset >= Globals.filesize) break; offset++; printStatusWindow (); cursor_x = 10; if (Globals.tabb) move (++cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (++cursor_y, cursor_x); wrefresh (stdscr); } else if (offset < Globals.filesize) { offset++; printStatusWindow (); off = offset; off -= M_0x10 * (MAIN_BOTTOM_LINE); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); cursor_x = 10; if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } } break; } else { if ( cursor_x == 10 || cursor_x == 12 || cursor_x == 14 || cursor_x == 16 || cursor_x == 19 || cursor_x == 21 || cursor_x == 23 || cursor_x == 25 || cursor_x == 28 || cursor_x == 30 || cursor_x == 32 || cursor_x == 34 || cursor_x == 37 || cursor_x == 39 || cursor_x == 41 || cursor_x == 43) { if (Globals.tabb) { cursor_x++; if ((offset < Globals.filesize) && (cursor_x == 11 || cursor_x == 13 || cursor_x == 15 || cursor_x == 17 || cursor_x == 20 || cursor_x == 22 || cursor_x == 24 || cursor_x == 26 || cursor_x == 29 || cursor_x == 31 || cursor_x == 33 || cursor_x == 35 || cursor_x == 38 || cursor_x == 40 || cursor_x == 42)) { offset++; printStatusWindow (); if (cursor_x == 26) cursor_x += 3; else if (cursor_x == 17 || cursor_x == 35) cursor_x += 3; else cursor_x += 2; move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } else if (cursor_x == 33) { if (cursor_y < BOTTOM_LINE) { if (offset >= Globals.filesize) break; offset++; printStatusWindow (); cursor_x = 10; move (++cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } else if (offset < Globals.filesize) { offset++; printStatusWindow (); off = offset; off -= M_0x10 * (MAIN_BOTTOM_LINE); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); cursor_x = 10; move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } } } else move (cursor_y, ++cursor_x); wrefresh (stdscr); } else if ((offset < Globals.filesize) && (cursor_x == 11 || cursor_x == 13 || cursor_x == 15 || cursor_x == 17 || cursor_x == 20 || cursor_x == 22 || cursor_x == 24 || cursor_x == 26 || cursor_x == 29 || cursor_x == 31 || cursor_x == 33 || cursor_x == 35 || cursor_x == 38 || cursor_x == 40 || cursor_x == 42)) { offset++; printStatusWindow (); cursor_x = mappos (offset & M_0x0F); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } else if (cursor_x == 44) { if (cursor_y < BOTTOM_LINE) { if (offset >= Globals.filesize) break; offset++; printStatusWindow (); cursor_x = 10; if (Globals.tabb) move (++cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (++cursor_y, cursor_x); wrefresh (stdscr); } else if (offset < Globals.filesize) { offset++; printStatusWindow (); off = offset; off -= M_0x10 * (MAIN_BOTTOM_LINE); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); cursor_x = 10; if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } } break; } case KEY_LEFT: if (Globals.spacing) { if (cursor_x == 11 || cursor_x == 14 || cursor_x == 17 || cursor_x == 20 || cursor_x == 24 || cursor_x == 27 || cursor_x == 30 || cursor_x == 33 || cursor_x == 38 || cursor_x == 41 || cursor_x == 44 || cursor_x == 47 || cursor_x == 51 || cursor_x == 54 || cursor_x == 57 || cursor_x == 60) { if (Globals.tabb) { cursor_x--; if (cursor_x == 13 || cursor_x == 16 || cursor_x == 19 || cursor_x == 23 || cursor_x == 26 || cursor_x == 29 || cursor_x == 32 || cursor_x == 37 || cursor_x == 40 || cursor_x == 43 || cursor_x == 46 || cursor_x == 50 || cursor_x == 53 || cursor_x == 56 || cursor_x == 59) { offset--; printStatusWindow (); if (cursor_x == 37) cursor_x -= 4; else if (cursor_x == 23 || cursor_x == 50) cursor_x -= 3; else cursor_x -= 2; move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } else if (cursor_x == 10) { if (cursor_y > MAIN_TOP_LINE) { offset--; printStatusWindow (); cursor_x = 60; move (--cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } else if ((cursor_y <= MAIN_TOP_LINE) && (offset != 0x00)) { offset--; off = offset & M_0xFFFFFFF0; printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); cursor_x = 60; move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } } } else move (cursor_y, --cursor_x); wrefresh (stdscr); } else if (cursor_x == 13 || cursor_x == 16 || cursor_x == 19 || cursor_x == 23 || cursor_x == 26 || cursor_x == 29 || cursor_x == 32 || cursor_x == 37 || cursor_x == 40 || cursor_x == 43 || cursor_x == 46 || cursor_x == 50 || cursor_x == 53 || cursor_x == 56 || cursor_x == 59) { offset--; printStatusWindow (); if (cursor_x == 37) cursor_x -= 4; else if (cursor_x == 23 || cursor_x == 50) cursor_x -= 3; else cursor_x -= 2; if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } else if (cursor_x == 10) { if (cursor_y > MAIN_TOP_LINE) { offset--; printStatusWindow (); cursor_x = 60; if (Globals.tabb) move (--cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (--cursor_y, cursor_x); wrefresh (stdscr); } else if ((cursor_y <= MAIN_TOP_LINE) && (offset != 0x00)) { offset--; off = offset & M_0xFFFFFFF0; printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); cursor_x = 60; if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } } } else { if (cursor_x == 11 || cursor_x == 13 || cursor_x == 15 || cursor_x == 17 || cursor_x == 20 || cursor_x == 22 || cursor_x == 24 || cursor_x == 26 || cursor_x == 29 || cursor_x == 31 || cursor_x == 33 || cursor_x == 35 || cursor_x == 38 || cursor_x == 40 || cursor_x == 42 || cursor_x == 44) { if (Globals.tabb) { cursor_x--; if (cursor_x == 12 || cursor_x == 14 || cursor_x == 16 || cursor_x == 19 || cursor_x == 21 || cursor_x == 23 || cursor_x == 25 || cursor_x == 28 || cursor_x == 30 || cursor_x == 32 || cursor_x == 34 || cursor_x == 37 || cursor_x == 39 || cursor_x == 41 || cursor_x == 43) { offset--; printStatusWindow (); if (cursor_x == 28) cursor_x -= 2; else if (cursor_x == 19 || cursor_x == 37) cursor_x -= 2; else cursor_x -= 1; move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } else if (cursor_x == 10) { if (cursor_y > MAIN_TOP_LINE) { offset--; printStatusWindow (); cursor_x = 44; move (--cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } else if ((cursor_y <= MAIN_TOP_LINE) && (offset != 0x00)) { offset--; off = offset & M_0xFFFFFFF0; printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); cursor_x = 44; move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); } } } else move (cursor_y, --cursor_x); wrefresh (stdscr); } else if (cursor_x == 12 || cursor_x == 14 || cursor_x == 16 || cursor_x == 19 || cursor_x == 21 || cursor_x == 23 || cursor_x == 25 || cursor_x == 28 || cursor_x == 30 || cursor_x == 32 || cursor_x == 34 || cursor_x == 37 || cursor_x == 39 || cursor_x == 41 || cursor_x == 43) { offset--; printStatusWindow (); if (cursor_x == 28) cursor_x -= 2; else if (cursor_x == 19 || cursor_x == 37) cursor_x -= 2; else cursor_x -= 1; if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } else if (cursor_x == 10) { if (cursor_y > MAIN_TOP_LINE) { offset--; printStatusWindow (); cursor_x = 44; if (Globals.tabb) move (--cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (--cursor_y, cursor_x); wrefresh (stdscr); } else if ((cursor_y <= MAIN_TOP_LINE) && (offset != 0x00)) { offset--; off = offset & M_0xFFFFFFF0; printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); cursor_x = 44; if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); wrefresh (stdscr); } } } break; default: break; } } void pagedown (void) { unsigned long off = 0; if ((Globals.filesize & M_0xFFFFFFF0) < (MAIN_BOTTOM_LINE * M_0x10)) { off = 0; offset &= M_0x0F; offset += Globals.filesize & M_0xFFFFFFF0; if (offset > Globals.filesize) offset = Globals.filesize; cursor_y = ((Globals.filesize & M_0xFFFFFFF0) >> 4) + 1; if (mapcur (cursor_x) > (offset & M_0x0F)) cursor_x = mappos (offset & M_0x0F); printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); refresh (); return; } if (((offset & M_0xFFFFFFF0) == (Globals.filesize & M_0xFFFFFFF0)) && (Globals.filesize > ((MAIN_BOTTOM_LINE) * M_0x10))) { off = (offset & M_0xFFFFFFF0) - ((MAIN_BOTTOM_LINE) * M_0x10); if (off > Globals.filesize) off = 0; printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); cursor_y = BOTTOM_LINE; if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); refresh (); return; } else if ((offset + ((MAIN_BOTTOM_LINE) * M_0x10) > (Globals.filesize & M_0xFFFFFFF0))) { if (Globals.filesize >= ((MAIN_BOTTOM_LINE) * M_0x10)) cursor_y = BOTTOM_LINE; else cursor_y = ((Globals.filesize & M_0xF0) >> 4) + MAIN_BOTTOM_LINE; offset = Globals.filesize; if (mapcur (cursor_x) < (offset & M_0x0F)) offset = (offset & M_0xFFFFFFF0) + mapcur (cursor_x); else if (mapcur (cursor_x) > (offset & M_0x0F)) cursor_x = mappos (offset & M_0x0F); } offset += (MAIN_BOTTOM_LINE) * M_0x10; if (offset > Globals.filesize) { offset = Globals.filesize; if (mapcur (cursor_x) < (offset & M_0x0F)) offset = (offset & M_0xFFFFFFF0) + mapcur (cursor_x); else if (mapcur (cursor_x) > (offset & M_0x0F)) cursor_x = mappos (offset & M_0x0F); off = offset & M_0xFFFFFFF0; off -= ((MAIN_BOTTOM_LINE) * M_0x10); if (off > Globals.filesize) off = 0; printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); refresh (); return; } if ((offset - ((MAIN_BOTTOM_LINE) * M_0x10)) < 0) { off = 0; cursor_y = ((offset & M_0xF0) >> 4) + MAIN_BOTTOM_LINE; } else off = offset; off &= M_0xFFFFFFF0; off -= (cursor_y - MAIN_TOP_LINE) * M_0x10; printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); refresh (); } void pageup (void) { unsigned long off = 0; if ((offset & M_0xFFFFFFF0) <= ((MAIN_BOTTOM_LINE) * M_0x10)) /* paged up with offset 0x00 on the screen (begining of file) */ { offset = 0x00 + mapcur (cursor_x); off = 0; cursor_y = MAIN_TOP_LINE; } else /* not at begining of file */ { offset -= M_0x10 * (MAIN_BOTTOM_LINE); off = offset; off -= M_0x10 * (cursor_y - MAIN_TOP_LINE); if (off > Globals.filesize) off = 0; if (offset > Globals.filesize) offset = 0; if ((offset & M_0xFFFFFFF0) < ((MAIN_BOTTOM_LINE) * M_0x10)) { cursor_y = ((offset & M_0xFFFFFFF0) >> 4) + MAIN_TOP_LINE; } } printStatusWindow (); wmove (Globals.wmain, 0, 0); drawdump (off); wrefresh (Globals.wmain); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); refresh (); } void homeKey (void) { if (cursor_x != 10) { offset &= M_0xFFFFFFF0; cursor_x = mappos (0); printStatusWindow (); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); refresh (); } } void endKey (void) { if ((offset & M_0xFFFFFFF0) == (Globals.filesize & M_0xFFFFFFF0)) { cursor_x = mappos (Globals.filesize & M_0x0F) + 1; offset = Globals.filesize; } else if (cursor_x != 60) { if (Globals.spacing) cursor_x = 60; else cursor_x = 44; offset |= M_0x0F; } printStatusWindow (); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); refresh (); } void tabcursor (int *tabb) /* switch from hex side to ascii side of screen */ { *tabb ^= 1; if (*tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); refresh (); } ncurses-hexedit-0.9.7.orig/src/init.c0100644000175000017500000003440106753161673016145 0ustar apocapoc/* init.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" #include #if defined(HAVE_GETOPT_H) && defined(HAVE_GETOPT_LONG) #include #else #include "../gnu/getopt.h" #include "../gnu/getopt.c" #include "../gnu/getopt1.c" #endif #ifdef __linux__ #include #endif #ifdef __OpenBSD__ #include #include #include #endif extern char **environ; /* This is called once at the start of the program. Handles HEXEDIT * Environment variable, command line arguments, sets up signal * handlers, Global Variables, setup windows, possibly use file widget, * and load the file. */ void init (int argc, char **argv) { int i = 0; FILE *fp = NULL; void *p; int option_index = 0; struct option long_options[] = { { "help", 0, 0, 0 }, { "highbit", 0, 0, 0 }, { "alltext", 0, 0, 0 }, { "readonly", 0, 0, 0 }, { "version", 0, 0, 0 }, { "disk", 0, 0, 0 }, { "buffer", 0, 0, 0 }, { "quiet", 0, 0, 0 }, { "force", 0, 0, 0 }, { "nocolor", 0, 0, 0 }, { NULL, 0, 0, 0 } }; Globals.modified = 0; Globals.filesize = 0; Globals.print_mode = REGULAR_PRINT; Globals.buffsize = DEFAULT_BUFFER_SIZE; Globals.fixed_disk = 0; Globals.fullsize = 0; Globals.buf_front = 0; Globals.buf_end = 0; Globals.beeping = 1; Globals.charset = ASCII_CHAR_SET; Globals.spacing = 1; Globals.tabb = 0; newlines = NULL; filebuf = NULL; /* process environemnt variable first, then command line options */ i = 0; while (*environ) { if (!strncasecmp (*environ, "HEXEDIT", 7)) { while (**environ) { switch (**environ) { case '8': Globals.print_mode = HIGH_ASCII_PRINT; break; case 'a': case 'A': Globals.print_mode = ALL_PRINT; break; case 'b': case 'B': Globals.buffsize = 0; Globals.fullsize = 1; break; case 'f': case 'F': Globals.modified = 0; break; case 'r': case 'R': Globals.modified = READ_ONLY; break; case 'd': case 'D': Globals.fixed_disk = 1; Globals.modified = READ_ONLY; /* need force as well */ break; case 'q': case 'Q': Globals.beeping = 0; break; case 'n': case 'N': color_term = -1; /* don't use color terminal if availible */ break; } ++*environ; } break; } environ++; i++; } environ -= i; while ((i = getopt_long (argc, argv, "8abdfhnqrv", long_options, &option_index)) != EOF) { switch (i) { case 0: switch (option_index) { case 0: usage (*argv); exit (EXIT_SUCCESS); case 1: Globals.print_mode = HIGH_ASCII_PRINT; break; case 2: Globals.print_mode = ALL_PRINT; break; case 3: Globals.modified = READ_ONLY; break; case 4: printf ("%s\n", VERSION); exit (EXIT_SUCCESS); case 5: Globals.fixed_disk = 1; Globals.modified = READ_ONLY; /* need force as well */ break; case 6: Globals.buffsize = 0; Globals.fullsize = 1; break; case 7: Globals.beeping = 0; break; case 8: Globals.modified = 0; break; case 9: color_term = -1; break; } break; case '8': Globals.print_mode = HIGH_ASCII_PRINT; break; case 'a': Globals.print_mode = ALL_PRINT; break; case 'b': Globals.buffsize = 0; Globals.fullsize = 1; break; case 'd': Globals.fixed_disk = 1; Globals.modified = READ_ONLY; /* need force as well*/ break; case 'f': Globals.modified = 0; break; case 'h': usage (*argv); exit (EXIT_SUCCESS); case 'n': color_term = -1; break; case 'q': Globals.beeping = 0; break; case 'r': Globals.modified = READ_ONLY; break; case 'v': printf ("%s\n", VERSION); exit (EXIT_SUCCESS); } } help_initialize (); i = 0; p = initscr (); if (p == NULL) { fprintf (stderr, "Cannot initialize screen - curses!\n"); exit (EXIT_FAILURE); } if (color_term != -1) { start_color (); if ((color_term = has_colors ())) { color_term = 1; init_pair (1, COLOR_WHITE, COLOR_BLUE); init_pair (2, COLOR_GREEN, COLOR_BLUE); init_pair (3, COLOR_BLUE, COLOR_BLACK); init_pair (4, COLOR_YELLOW, COLOR_CYAN); } } else color_term = 0; keypad (stdscr, TRUE); scrollok (stdscr, FALSE); cbreak (); noecho (); refresh (); Globals.wstatus = newwin (1, COLS, 0, 0); if (Globals.wstatus == NULL) die_horribly ("Cannot open status window - curses!", NULL); wattrset (Globals.wstatus, color_term ? COLOR_PAIR(4) | A_BOLD : A_REVERSE); scrollok (Globals.wstatus, FALSE); Globals.wmain = newwin (MAIN_HEIGHT, COLS, MAIN_TOP_LINE, 0); if (Globals.wmain == NULL) die_horribly ("Cannot open main window - curses!", NULL); scrollok (Globals.wmain, FALSE); Globals.whelp = newwin (1, COLS, LINES - 1, 0); if (Globals.whelp == NULL) die_horribly ("Cannot open help window - curses!", NULL); wattrset (Globals.whelp, color_term ? COLOR_PAIR(3) | A_BOLD : A_NORMAL); scrollok (Globals.whelp, FALSE); #ifdef __PDCURSES__ leaveok(Globals.wmain, FALSE); /* Stupid macro */ #else leaveok (Globals.wmain, FALSE); #endif #ifndef __PDCURSES__ /* signal (SIGWINCH, handleSigwinch); */ { struct sigaction sig_a; sig_a.sa_handler = handleSigwinch; memset (&sig_a.sa_mask, 0x00, sizeof (sigset_t)); sig_a.sa_flags = 0; sigaction (SIGWINCH, &sig_a, NULL); } #endif if (optind < argc) { int l = 0; fp = fopen (*(argv + optind), "rb"); if (!fp) popup_Error (*(argv + optind), 1); else { l = strlen (*(argv + optind)) + 1; Globals.filename = malloc (l); if (!Globals.filename) die_horribly (NOT_ENOUGH_MEMORY, NULL); strncpy ((char *) Globals.filename, *(argv + optind), l); } } load_new_file (&fp); for (i = 0; i < COLS; i++) waddch (Globals.wstatus, ' '); printStatusWindow (); printHelpWindow (); drawdump (offset); wrefresh (Globals.wmain); cursor_y = MAIN_TOP_LINE; cursor_x = 10; move (cursor_y, cursor_x); refresh (); } /* Used to go to the file selection widget continously until a new file * is choses or the user exits. Returns the name of the new file and * sets fp to the new file opened file pointer. Need to eventually free * this returned value. This is called outside init.c. */ char * select_new_file (FILE **fp) #define FILE_ERR_WIDTH 50 #define FILE_ERR_HEIGHT 6 { char *p = NULL; while (!*fp) { /* need to eventually free () returned valued */ p = fileSelect (); *fp = fopen (p, "rb"); if (!*fp) { popup_Error ("Cannot Open File", 1); free (p); } else break; } return p; } /* Generic popup error box. XXX I should use this in places where it * looks like I cut and pasted this. XXX */ void popup_Error (const char * const msg, int i) { WINDOW *wpopup = popupWindow (FILE_ERR_WIDTH, FILE_ERR_HEIGHT); werase (wpopup); box (wpopup, 0, 0); wmove (wpopup, 1, (FILE_ERR_WIDTH / 2) - (strlen (msg) / 2)); wprintw (wpopup, (char *) msg); wmove (wpopup, FILE_ERR_HEIGHT - 3, (FILE_ERR_WIDTH / 2) - (strlen (strerror (errno)) + strlen ("Reason: ")) / 2); wprintw (wpopup, "Reason: %s", i ? strerror (errno) : "Not applicable"); wrefresh (wpopup); getch (); } /* This is called outside init.c. Deals with loading the file. */ void load_new_file (FILE **fp) { int i = 0; int result = 0; unsigned long filled = 0; int next_read = 0; struct stat filestat; unsigned char strbuf[DEFAULT_READ_BUFFER]; Globals.filesize = 0; while (1) { if (!*fp) { if (Globals.filename) free ((char *) Globals.filename); Globals.filename = select_new_file (fp); } /* hmm how would this happen? Better to just keep going. */ if (!*fp) /* die_horribly (NULL, Globals.filename); */ continue; result = stat (Globals.filename, &filestat); if (result == -1) { /* die_horribly (NULL, Globals.filename); */ popup_Error ("Cannot Read File", 1); fclose (*fp); *fp = NULL; continue; } if ((filestat.st_size == 0) && !Globals.fixed_disk) { /* die_horribly ("File is Zero Bytes - Nothing to Edit!", NULL); */ popup_Error ("File is Zero Bytes, Perhaps Used -d disk mode", 0); fclose (*fp); *fp = NULL; continue; } #ifdef __linux__ else if (Globals.fixed_disk) { struct hd_geometry fixed_disk; result = ioctl (fileno (*fp), HDIO_GETGEO, &fixed_disk); if (result == -1) { /* die_horribly (NULL, Globals.filename); */ popup_Error ("Cannot get disk info", 1); fclose (*fp); *fp = NULL; continue; } Globals.filesize = fixed_disk.heads * fixed_disk.sectors * fixed_disk.cylinders * 512; filestat.st_size = DEFAULT_BUFFER_SIZE; } #elif defined (__OpenBSD__) else if (Globals.fixed_disk) { struct disklabel dl; result = ioctl (fileno (*fp), DIOCGDINFO, &dl); if (result == -1) { /* die_horribly (NULL, Globals.filename); */ popup_Error ("Cannot get disk info", 1); fclose (*fp); *fp = NULL; continue; } Globals.filesize = dl.d_ntracks * dl.d_nsectors * dl.d_ncylinders * 512; filestat.st_size = DEFAULT_BUFFER_SIZE; } #endif break; } /* it would be zero if the -b, --buffer flag was given */ if (!Globals.buffsize) Globals.buffsize = filestat.st_size; else extrabuf = 0; /* no extrabuf since delete and insert not allowed */ if (filebuf) free (filebuf); filebuf = malloc (Globals.buffsize + 1 + extrabuf); if (!filebuf) die_horribly (NOT_ENOUGH_MEMORY, NULL); /* don't think this is needed any more. */ memset (filebuf, 0x00, Globals.buffsize + 1 + extrabuf); i = 0; filled = 0; next_read = (DEFAULT_READ_BUFFER > Globals.buffsize) ? Globals.buffsize : DEFAULT_READ_BUFFER; memset (strbuf, 0, DEFAULT_READ_BUFFER); while ((result = fread (strbuf, 1, next_read, *fp)) > 0) { if (ferror (*fp)) die_horribly (NULL, Globals.filename); memcpy (filebuf + i, strbuf, result); i += result; if (i > filestat.st_size) die_horribly ("file has changed, restart", NULL); filled += result; if (filled < Globals.buffsize) { next_read = ((filled + DEFAULT_READ_BUFFER) > Globals.buffsize) ? Globals.buffsize - filled : DEFAULT_READ_BUFFER; } if ((next_read <= 0) || (filled >= Globals.buffsize)) break; memset (strbuf, 0, DEFAULT_READ_BUFFER); } if (!Globals.filesize) Globals.filesize = filestat.st_size - 1; initbuffer (*fp, 0, filled - 1); if (Globals.modified != READ_ONLY) Globals.modified = 0; { /* signal (SIGINT, handleInterrupt); */ struct sigaction sig_a; sig_a.sa_handler = handleInterrupt; memset (&sig_a.sa_mask, 0x00, sizeof (sigset_t)); /* sig_a.sa_flags = SA_NOMASK; */ sig_a.sa_flags = SA_NODEFER; sigaction (SIGINT, &sig_a, NULL); } if (newlines) free (newlines); newlines = malloc (BOTTOM_LINE * sizeof (int)); if (!newlines) die_horribly (NOT_ENOUGH_MEMORY, NULL); /* if the whole buffer is not read into memory, we need to * do hashing of all modifications to keep track of changes. * Also, for when not in fullsize mode, to keep bold changes. */ init_hash (); if (UndoStack.base) { struct Change *cp = NULL; while (UndoStack.base) { cp = UndoStack.base->p; free (UndoStack.base); UndoStack.base = cp; } } UndoStack.s = 0; UndoStack.base = NULL; UndoStack.top = NULL; /* May be comming out of file mode from selection widget. */ Globals.mode = HEX_MODE; } ncurses-hexedit-0.9.7.orig/src/main.c0100644000175000017500000000223006736250744016120 0ustar apocapoc#define MAIN_C /* main.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" #include int main (int argc, char **argv) { wchar_t in = 0; init (argc, argv); while (1) { in = getch (); switch (Globals.mode) { case HEX_MODE: hexMode (in); break; case ASCII_MODE: asciiMode (in); break; assert (1); /* This would be a programming error. */ } } /* Control never reaches here. */ exitProgram (); return EXIT_SUCCESS; } ncurses-hexedit-0.9.7.orig/src/misc.c0100644000175000017500000004741706736241017016140 0ustar apocapoc/* misc.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" #ifdef HAVE_TERMIO_H #include #else #ifdef HAVE_TERMIOS_H #include #else #ifdef HAVE_SYS_TERMIOS_H #include #endif #endif #endif int mappos (int pos) /* This is used for cursor_x. It has a value of 0-F, depending on what * byte you are on in the line, and this returns the corresponding screen * cursor position */ { if (Globals.spacing) { switch (pos) { case 0: return 10; case 1: return 13; case 2: return 16; case 3: return 19; case 4: return 23; case 5: return 26; case 6: return 29; case 7: return 32; case 8: return 37; case 9: return 40; case 10: return 43; case 11: return 46; case 12: return 50; case 13: return 53; case 14: return 56; case 15: return 59; } } else { switch (pos) { case 0: return 10; case 1: return 12; case 2: return 14; case 3: return 16; case 4: return 19; case 5: return 21; case 6: return 23; case 7: return 25; case 8: return 28; case 9: return 30; case 10: return 32; case 11: return 34; case 12: return 37; case 13: return 39; case 14: return 41; case 15: return 43; } } return 0; } int mapcur (int cur) /* This takes the cursor position and returns what byte it is on that line */ { if (Globals.spacing) { switch (cur) { case 10: case 11: return 0; case 13: case 14: return 1; case 16: case 17: return 2; case 19: case 20: return 3; case 23: case 24: return 4; case 26: case 27: return 5; case 29: case 30: return 6; case 32: case 33: return 7; case 37: case 38: return 8; case 40: case 41: return 9; case 43: case 44: return 10; case 46: case 47: return 11; case 50: case 51: return 12; case 53: case 54: return 13; case 56: case 57: return 14; case 59: case 60: return 15; } } else { switch (cur) { case 10: case 11: return 0; case 12: case 13: return 1; case 14: case 15: return 2; case 16: case 17: return 3; case 19: case 20: return 4; case 21: case 22: return 5; case 23: case 24: return 6; case 25: case 26: return 7; case 28: case 29: return 8; case 30: case 31: return 9; case 32: case 33: return 10; case 34: case 35: return 11; case 37: case 38: return 12; case 39: case 40: return 13; case 41: case 42: return 14; case 43: case 44: return 15; } } return 0; } int cursor_ascii_to_ebcdic (int cur) { if (!Globals.spacing) { switch (cur) { case 10: return 10; case 11: return 11; case 13: return 12; case 14: return 13; case 16: return 14; case 17: return 15; case 19: return 16; case 20: return 17; case 23: return 19; case 24: return 20; case 26: return 21; case 27: return 22; case 29: return 23; case 30: return 24; case 32: return 25; case 33: return 26; case 37: return 28; case 38: return 29; case 40: return 30; case 41: return 31; case 43: return 32; case 44: return 33; case 46: return 34; case 47: return 35; case 50: return 37; case 51: return 38; case 53: return 39; case 54: return 40; case 56: return 41; case 57: return 42; case 59: return 43; case 60: return 44; } } else { switch (cur) { case 10: return 10; case 11: return 11; case 12: return 13; case 13: return 14; case 14: return 16; case 15: return 17; case 16: return 19; case 17: return 20; case 19: return 23; case 20: return 24; case 21: return 26; case 22: return 27; case 23: return 29; case 24: return 30; case 25: return 32; case 26: return 33; case 28: return 37; case 29: return 38; case 30: return 40; case 31: return 41; case 32: return 43; case 33: return 44; case 34: return 46; case 35: return 47; case 37: return 50; case 38: return 51; case 39: return 53; case 40: return 54; case 41: return 56; case 42: return 57; case 43: return 59; case 44: return 60; } } return 0; } void usage (char *prog) { printf ("[N]Curses Hexedit %s by Adam Rogoyski \n" \ "Copyright (C) 1998, 1999 Adam Rogoyski\n" \ "This is free software; see the source for copying conditions.\n" \ "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n" \ "PARTICULAR PURPOSE.\n\n" \ "Usage: %s [options] [file]\n" \ "Options:\n" \ " -h, --help Print this message and exit.\n" " -8, --highbit Print high order 8-bit text.\n" " -a, --alltext Print all text characters.\n" " -b, --buffer Buffer the entire file in memory.\n" " Much faster and enables insert/delete.\n" #if defined (__linux__) || defined (__OpenBSD__) " -d, --disk Edit a fixed disk, i.e. /dev/hda (Read-only)\n" " -f, --force Force editing of disk.\n" " Needed to write to disks.\n" #endif " -n, --nocolor Force Gray scale, no colors.\n" " -q, --quiet Quiet Mode, No annoying beeping\n" " -r, --readonly Do not modifying of the file.\n" " -v, --version Print the version number and exit.\n", VERSION, prog); } void die_horribly (const char * const message, const char * const pmsg) /* clear the screen reset the screen, and optionally print a message * why hexedit terminated to standard error. Possibly print perror (). */ { erase (); refresh (); endwin (); if (message) fprintf (stderr, "%s\n", message); if (pmsg) perror (pmsg); exit (EXIT_FAILURE); } void handleInterrupt (int i) #define QUIT_BOX_WIDTH 60 #define QUIT_BOX_HEIGHT 6 #define YES_VALUE 1 #define NO_VALUE 2 #define NEW_FILE_VALUE 3 #define FIRST_VALUE YES_VALUE #define LAST_VALUE NEW_FILE_VALUE { int done = 0; int j = 0; int value = YES_VALUE; wchar_t in = 0; static int semph = 0; WINDOW *win = popupWindow (QUIT_BOX_WIDTH, QUIT_BOX_HEIGHT); /* signal (SIGINT, SIG_IGN); */ if (semph) return; semph = 1; box (win, 0, 0); if (Globals.modified == READ_ONLY) { wmove (win, 2, QUIT_BOX_WIDTH / 2 - strlen (" Really Quit? ") / 2); wprintw (win, " Really Quit? "); } else { wmove (win, 2, QUIT_BOX_WIDTH / 2 - strlen ("Quit without Saving?") / 2); wprintw (win, "Quit without Saving?"); } wmove (win, 4, QUIT_BOX_WIDTH / 2 - (strlen (" Yes No New File ") / 2)); wattrset (win, A_REVERSE); wprintw (win, " Yes "); wattroff (win, A_REVERSE); wprintw (win, " No"); wprintw (win, " New File"); wrefresh (win); wmove (Globals.whelp, 0, 0); wprintw (Globals.whelp, "^G/^X/Escape Cancel Y Yes N No F New File"); for (j = strlen ("^G/^X/Escape Cancel Y Yes N No F New File"); j < COLS; j++) wprintw (Globals.whelp, " "); wrefresh (Globals.whelp); value = YES_VALUE; while (!done && (in = getch ()) != '\n') { switch (in) { case TAB: case KEY_RIGHT: (value == LAST_VALUE) ? value = FIRST_VALUE : value++; break; case KEY_LEFT: (value == FIRST_VALUE) ? value = LAST_VALUE : value--; break; case 'n': case 'N': case CONTROL_G: case CONTROL_X: case ESCAPE_CHARACTER: value = NO_VALUE; done = 1; break; case 'y': case 'Y': value = YES_VALUE; done = 1; break; case 'f': case 'F': value = NEW_FILE_VALUE; done = 1; break; } if (value == YES_VALUE) { wmove (win, 4, QUIT_BOX_WIDTH / 2 - (strlen (" Yes No New File ") / 2)); wattrset (win, A_REVERSE); wprintw (win, " Yes "); wattroff (win, A_REVERSE); wprintw (win, " No New File "); } else if (value == NO_VALUE) { wmove (win, 4, QUIT_BOX_WIDTH / 2 - (strlen (" Yes No New File ") / 2)); wattroff (win, A_REVERSE); wprintw (win, " Yes "); wattrset (win, A_REVERSE); wprintw (win, " No "); wattroff (win, A_REVERSE); wprintw (win, " New File "); } else if (value == NEW_FILE_VALUE) { wmove (win, 4, QUIT_BOX_WIDTH / 2 - (strlen (" Yes No New File ") / 2)); wattroff (win, A_REVERSE); wprintw (win, " Yes No "); wattrset (win, A_REVERSE); wprintw (win, " New File "); } wrefresh (win); } if (value == YES_VALUE) exitProgram (); else if (value == NEW_FILE_VALUE) { FILE *fp = NULL; load_new_file (&fp); cursor_y = MAIN_TOP_LINE; cursor_x = 10; offset = 0x00; Globals.modified = 0; Globals.tabb = 0; } redraw (); semph = 0; /* signal (SIGINT, handleInterrupt); */ } #ifndef __PDCURSES__ void handleSigwinch (int i) { char *tty = NULL; int fd = 0; int result = 0; struct winsize win; tty = ttyname (0); if (!tty) return; fd = open (tty, O_RDWR); if (fd == -1) { perror (tty); return; } result = ioctl (fd, TIOCGWINSZ, &win); if (result == -1) { perror ("ioctl TIOCGWINSZ"); return; } delwin (Globals.wmain); delwin (Globals.wstatus); delwin (Globals.whelp); endwin (); COLS = win.ws_col; LINES = win.ws_row; initscr (); if (stdscr == NULL) die_horribly ("Cannot initialize screen - curses!\n", NULL); keypad (stdscr, TRUE); scrollok (stdscr, FALSE); cbreak (); noecho (); refresh (); Globals.wmain = newwin (MAIN_HEIGHT, COLS, MAIN_TOP_LINE, 0); if (Globals.wmain == NULL) die_horribly ("Cannot open larger main window - curses!\n", NULL); scrollok (Globals.wmain, FALSE); #ifdef __PDCURSES__ leaveok(Globals.wmain, FALSE); /* Stupid macro */ #else leaveok (Globals.wmain, FALSE); #endif Globals.wstatus = newwin (1, COLS, 0, 0); if (Globals.wstatus == NULL) { fprintf (stderr, "Cannot open status window - curses!\n"); exit (EXIT_FAILURE); } scrollok (Globals.wstatus, FALSE); wattrset (Globals.wstatus, color_term ? COLOR_PAIR(3) | A_BOLD : A_REVERSE); Globals.whelp = newwin (1, COLS, LINES - 1, 0); if (Globals.whelp == NULL) die_horribly ("Cannot open help window - curses!\n", NULL); scrollok (Globals.whelp, FALSE); if (newlines) free (newlines); newlines = malloc (BOTTOM_LINE * sizeof (int)); if (!newlines) die_horribly (NOT_ENOUGH_MEMORY, NULL); Globals.wmain->_cury = cursor_y - 1; Globals.wmain->_curx = cursor_x; stdscr->_cury = cursor_y; stdscr->_curx = cursor_x; if (cursor_y >= BOTTOM_LINE) cursor_y = BOTTOM_LINE; if (Globals.mode == FILE_MODE) { extern struct FileNames *fp; extern struct FileNames **pages; extern int current_page; extern int num_pages; char trunc_file[PATH_MAX + 1]; struct FileNames *p = *pages; struct FileNames *pfront = *pages; int i = 0; int j = 0; int n = 0; if (p) { while (p->p) { p = p->p; n++; } } if (pages) free (pages); num_pages = ((n - 1) / (LINES - 2)) + 1; pages = malloc (sizeof (struct FileNames *) * num_pages); if (!pages) die_horribly (NOT_ENOUGH_MEMORY, NULL); memset (pages, 0x00, num_pages * sizeof (struct FileNames *)); *pages = pfront; p = pfront; for (i = 1; i < num_pages; i++) { for (j = 0; (j < (LINES - 2)) && p; j++) p = p->p; *(pages + i) = p; } i = 0; p = pfront; while (p != fp) { if (p == *(pages + i + 1)) i++; p = p->p; } if (p == *(pages + i + 1)) i++; current_page = i; cursor_y = MAIN_TOP_LINE; p = *(pages + current_page); while (p != fp) { p = p->p; cursor_y++; } refresh (); wrefresh (Globals.wmain); wrefresh (Globals.wstatus); wrefresh (Globals.whelp); printPage (*(pages + current_page)); memset (trunc_file, 0x00, PATH_MAX + 1); strncpy (trunc_file, fp->filename, COLS - NAME_POS); wmove (Globals.wmain, cursor_y - MAIN_TOP_LINE, NAME_POS); wattrset (Globals.wmain, A_BOLD); wprintw (Globals.wmain, "%s", trunc_file); wattroff (Globals.wmain, A_BOLD); statWindow (fp->filename); helpWindow ("^C ^X Exit Program ^M Select File"); move (cursor_y, NAME_POS); wrefresh (Globals.wmain); wrefresh (Globals.wstatus); wrefresh (Globals.whelp); } else { redraw (); redraw (); } refresh (); /* signal (SIGWINCH, handleSigwinch); */ } #endif void exitProgram (void) { int i = 0; struct Change *cp = NULL; move (LINES - 1, 0); wattroff (Globals.wmain, A_REVERSE); for (i = 0; i < COLS; i++) wprintw (stdscr, " "); wrefresh (stdscr); werase (Globals.whelp); wrefresh (Globals.whelp); delwin (Globals.wstatus); delwin (Globals.wmain); delwin (Globals.whelp); delwin (stdscr); free (filebuf); free (newlines); while (UndoStack.base) { cp = UndoStack.base->p; free (UndoStack.base); UndoStack.base = cp; } endwin (); exit (EXIT_SUCCESS); } void exitSave (int saved) { if (saved) exitProgram (); redraw (); } char * chompWhiteSpace (char *str) { int i = 0; i = 0; while (*(str + i)) { if ((*(str + i) == ' ') || (*(str + i) == '\r') || (*(str + i) == '\t') || (*(str + i) == '\n')) { *(str + i) = 0; break; } else i++; } return str; } int isHexChar (wchar_t c) { switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': return 1; default: return 0; } return 0; } int getHexValue (wchar_t c) { switch (c) { case '0': return 0x00; case '1': return 0x01; case '2': return 0x02; case '3': return 0x03; case '4': return 0x04; case '5': return 0x05; case '6': return 0x06; case '7': return 0x07; case '8': return 0x08; case '9': return 0x09; case 'a': case 'A': return 0x0A; case 'b': case 'B': return 0x0B; case 'c': case 'C': return 0x0C; case 'd': case 'D': return 0x0D; case 'e': case 'E': return 0x0E; case 'f': case 'F': return 0x0F; } return 0; } char getAsciiValue (wchar_t c) { switch (c) { case 0: return '0'; case 1: return '1'; case 2: return '2'; case 3: return '3'; case 4: return '4'; case 5: return '5'; case 6: return '6'; case 7: return '7'; case 8: return '8'; case 9: return '9'; case 10: return 'A'; case 11: return 'B'; case 12: return 'C'; case 13: return 'D'; case 14: return 'E'; case 15: return 'F'; } return '\0'; } void switchModes (void) { if (Globals.mode == HEX_MODE) Globals.mode = ASCII_MODE; else Globals.mode = HEX_MODE; redraw (); } int isprintable (int c) { if (Globals.charset == EBCDIC_CHAR_SET) return 1; switch (Globals.print_mode) { case REGULAR_PRINT: #ifdef HAVE_ISPRINT return isprint (c); #else return ((c > 32) && (c < 127)); #endif case HIGH_ASCII_PRINT: #ifdef HAVE_ISPRINT return (isprint (c) || ((c > 127))); #else return ((c > 32) && (c <= 255) && (c != 127)); #endif case ALL_PRINT: return (c > 0); } return 0; } void do_beep () { if (Globals.beeping) beep (); } ncurses-hexedit-0.9.7.orig/src/print.c0100644000175000017500000003537706753170743016351 0ustar apocapoc/* print.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" static long findNewline (unsigned long); static void drawAscii (unsigned long off); static void drawAsciiDump (unsigned long, unsigned long *); const unsigned char EBCDIC[] = { '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', ' ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '<', '(', '+', '|', '&', '.', '.', '.', '.', '.', '.', '.', '.', '.', '!', '$', '*', ')', ';', '^', '-', '/', '.', '.', '.', '.', '.', '.', '.', '.', '|', ',', '%', '_', '>', '?', '.', '.', '.', '.', '.', '.', '.', '.', '.', '`', ':', '#', '@', '\'', '=','"', '.', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '.', '{', '.', '.', '.', '.', '.', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', '.', '}', '.', '.', '.', '.', '.', '~', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', '.', '.', '[', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', ']', '.', '.', '{', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', '.', '.', '.', '.', '.', '.', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', '.', '.', '.', '.', '.', '.', '\\', '.', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '.', '.', '.', '.', '.','.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '.', '.', '.', '.', '.', }; void drawdump (unsigned long off) { int i = 0; int pos = 0; int space = 0; int cur_y = 0; int bold = 0; long upto = (off & M_0xFFFFFFF0) + ((MAIN_HEIGHT) * M_0x10); if (color_term) wattron (Globals.wmain, COLOR_PAIR(1)); werase (Globals.wmain); off &= M_0xFFFFFFF0; while ((off < upto) && (off < Globals.filesize + 1)) { wattrset (Globals.wmain, color_term ? COLOR_PAIR(1) : A_NORMAL); if (pos == 0) wprintw (Globals.wmain, "%08X ", off); if (pos == 4 || pos == 12) { space++; } else if (pos == 8) { if (Globals.spacing) space = 3; else space = 2; } bold = hash_lookup (off, NULL); if (!bold) wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); if (Globals.spacing) { wmove (Globals.wmain, cur_y, (pos * 3) + 10 + space); wprintw (Globals.wmain, "%02lX ", filebuffer (off)); if ((pos == 3) || (pos == 11)) wprintw (Globals.wmain, " "); else if (pos == 7) wprintw (Globals.wmain, " "); } else { wmove (Globals.wmain, cur_y, (pos * 2) + 10 + space); wprintw (Globals.wmain, "%02lX", filebuffer (off)); if ((pos == 3) || (pos == 7) || (pos == 11)) wprintw (Globals.wmain, " "); } wmove (Globals.wmain, cur_y, COLS - M_0x10 + pos); if (Globals.charset == ASCII_CHAR_SET) { if (isprintable (filebuffer (off))) wprintw (Globals.wmain, "%c", filebuffer (off)); else wprintw (Globals.wmain, "."); } else /* EBCDIC */ { wprintw (Globals.wmain, "%c", EBCDIC[filebuffer (off)]); } if (!bold) wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); if (pos == 15) { if (cur_y == BOTTOM_LINE) break; if (Globals.spacing) i = (pos * 3) + 10 + space + 2; else i = (pos * 2) + 10 + space + 2; wmove (Globals.wmain, cur_y, i); for (; i < (COLS - 16); i++) wprintw (Globals.wmain, " "); cur_y++; pos = 0; space = 0; wmove (Globals.wmain, cur_y, 0); } else pos++; off++; } position = pos; wattrset (Globals.wmain, color_term ? COLOR_PAIR(1) : A_NORMAL); if (color_term) { /* If we finished the file and there's screen real estate not * written to, we fill it in with the default color. */ /* First fill in the rest of the line. */ if ((off == (Globals.filesize + 1)) && (((off - 1) & M_0x0F) < M_0x0F)) { i = mappos (pos); wmove (Globals.wmain, cur_y, i); for (; i < (COLS - 16); i++) /* left side of screen. */ wprintw (Globals.wmain, " "); i = COLS - M_0x10 + pos; wmove (Globals.wmain, cur_y, i); for (; i < COLS; i++) /* right side of screen. */ wprintw (Globals.wmain, " "); } /* All empty lines below get the default color */ if (!(off & M_0x0F)) cur_y--; while (++cur_y < BOTTOM_LINE) { wmove (Globals.wmain, cur_y, 0); for (i = 0; i < COLS; i++) wprintw (Globals.wmain, " "); } } } long findNewline (unsigned long off) /* finds the first newline before the current offset. This is used for * drawing the control-e ascii/text screen */ { while (off > 0x00) { if (filebuffer (off) == '\n') { off++; break; } off--; } return off; } void drawAsciiDump (unsigned long off, unsigned long *offs) { int move = 0; int i = 0; int bold = 0; while (1) { if (*offs > Globals.filesize) break; #ifdef __NCURSES_H /* i don't know why this works */ if (Globals.wmain->_cury == MAIN_BOTTOM_LINE) #else if (Globals.wmain->_cury == MAIN_HEIGHT) #endif break; if (Globals.wmain->_curx == COLS - 2) { move = 1; } if (Globals.wmain->_curx == 0) *(newlines + i++) = *offs; bold = hash_lookup (*offs, NULL); if (!bold) wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); if (Globals.charset == ASCII_CHAR_SET) { if (filebuffer (*offs) == '\n') { int cury = Globals.wmain->_cury; int i = Globals.wmain->_curx; for (; i < COLS - 2; i++) wprintw (Globals.wmain, " "); wprintw (Globals.wmain, "."); wmove (Globals.wmain, cury + 1, 0); } else if (filebuffer (*offs) == ' ') { wprintw (Globals.wmain, " "); } else if (isprintable (filebuffer (*offs))) wprintw (Globals.wmain, "%c", filebuffer (*offs)); else wprintw (Globals.wmain, "."); } else /* EBCDIC */ { if (filebuffer (*offs) == EBCDIC['\n']) { int cury = Globals.wmain->_cury; wprintw (Globals.wmain, "."); wmove (Globals.wmain, cury + 1, 0); } else if (filebuffer (*offs) == EBCDIC[' ']) { wprintw (Globals.wmain, " "); } else wprintw (Globals.wmain, "%c", EBCDIC[filebuffer (*offs)]); } if (!bold) { wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); if (color_term) wattrset (Globals.wmain, COLOR_PAIR(1)); } (*offs)++; if (move) { wmove (Globals.wmain, Globals.wmain->_cury + 1, 0); move = 0; continue; } if (*offs > Globals.filesize) break; } *(newlines + i) = *offs + 1; } void drawAscii (unsigned long off) { int i = 0; unsigned long offs = 0; unsigned long os = 0; wmove (Globals.wmain, 0, 0); os = offs = findNewline (off); memset (newlines, 0, BOTTOM_LINE * sizeof (int)); drawAsciiDump (off, &offs); while (offset >= offs) { memset (newlines, 0, BOTTOM_LINE * sizeof (int)); werase (Globals.wmain); wmove (Globals.wmain, 0, 0); drawAsciiDump (offs, &offs); if (offset >= Globals.filesize) break; } acursor_y = 1; acursor_x = 0; for (i = 0; i < BOTTOM_LINE; i++) { if (offset < *(newlines + i)) { acursor_y = i; if (i > 0) acursor_x = offset - *(newlines + i - 1); else acursor_x = offset - os; if (acursor_x >= COLS) { acursor_y += (int) (acursor_x / COLS); acursor_x %= COLS; } break; } } } void printStatusWindow (void) { static char *buf = NULL; static int first = 0; static int length = 0; double percent = 0.0; if (!first) { length = COLS - 54; /* 54 is rest of status bar needed for other info */ buf = malloc (PATH_MAX + 1); /* never gets freed. */ if (!buf) die_horribly (NOT_ENOUGH_MEMORY, NULL); memset (buf, 0, PATH_MAX + 1); first = 1; } memset (buf, ' ', PATH_MAX); length = COLS - 54; if (strlen (Globals.filename) < length) strncpy (buf, Globals.filename, strlen (Globals.filename)); else strncpy (buf, Globals.filename, length - 1); *(buf + length - 1) = '\0'; if (Globals.filesize <= 0) percent = 0.0; else percent = ((double) offset / (double) Globals.filesize) * 100; wmove (Globals.wstatus, 0, 0); wprintw (Globals.wstatus, "File: %-s %7s Offset: 0x%08lX / 0x%08lX (%%%02.0f) ", buf, Globals.charset == ASCII_CHAR_SET ? "ASCII" : "EBCDIC", offset, Globals.filesize, percent); wmove (Globals.wstatus, 0, COLS - 1); if (Globals.modified == MODIFIED) wprintw (Globals.wstatus, "M"); else if (Globals.modified == READ_ONLY) wprintw (Globals.wstatus, "R"); else wprintw (Globals.wstatus, " "); wrefresh (Globals.wstatus); } void printHelpWindow (void) { int len = COLS; /* Only what can fit on the screen will be displayed */ wmove (Globals.whelp, 0, 0); if (len > strlen ("^G Help")) { wprintw (Globals.whelp, "^G"); wprintw (Globals.whelp, " Help"); len -= strlen ("^G Help"); } if (len > strlen (" ^C Exit (No Save)")) { wprintw (Globals.whelp, " ^C"); if (Globals.modified == READ_ONLY) { wprintw (Globals.whelp, " Exit"); len -= strlen (" ^C Exit"); } else { wprintw (Globals.whelp, " Exit (No Save)"); len -= strlen (" ^C Exit (No Save)"); } } if (len > strlen (" ^T goTo Offset")) { wprintw (Globals.whelp, " ^T"); wprintw (Globals.whelp, " goTo Offset"); len -= strlen (" ^T goTo Offset"); } if (len > strlen (" ^X Exit and Save")) { wprintw (Globals.whelp, " ^X"); if (Globals.modified == READ_ONLY) { wprintw (Globals.whelp, " Exit"); len -= strlen (" ^X Exit"); } else { wprintw (Globals.whelp, " Exit and Save"); len -= strlen (" ^X Exit and Save"); } } if (len > strlen (" ^W Search")) { wprintw (Globals.whelp, " ^W"); wprintw (Globals.whelp, " Search"); len -= strlen (" ^W Search"); } if ((Globals.modified != READ_ONLY) && (len > strlen (" ^U Undo"))) { wprintw (Globals.whelp, " ^U"); wprintw (Globals.whelp, " Undo"); len -= strlen (" ^U Undo"); } if (len > strlen (" ^L Redraw")) { wprintw (Globals.whelp, " ^L"); wprintw (Globals.whelp, " Redraw"); len -= strlen (" ^L Redraw"); } if (len > strlen (" ^E Text Mode")) { wprintw (Globals.whelp, " ^E"); wprintw (Globals.whelp, " Text Mode"); len -= strlen (" ^E Text Mode"); } if (len > strlen (" ^R CharSet")) { wprintw (Globals.whelp, " ^R"); wprintw (Globals.whelp, " CharSet"); len -= strlen (" ^R CharSet"); } if (len > strlen (" ^P Spacing")) { wprintw (Globals.whelp, " ^P"); wprintw (Globals.whelp, " Spacing"); len -= strlen (" ^P Spacing"); } if (len > strlen (" ^N Find Next")) { wprintw (Globals.whelp, " ^N"); wprintw (Globals.whelp, " Find Next"); len -= strlen (" ^N Find Next"); } if (len > strlen (" F5 Color")) { wprintw (Globals.whelp, " F5"); wprintw (Globals.whelp, " Color"); len -= strlen (" ^F5 Color"); } wrefresh (Globals.whelp); } void redraw () { int i = 0; unsigned long off = offset; off -= M_0x10 * (cursor_y - MAIN_TOP_LINE); if (off > Globals.filesize) off = 0; werase (Globals.wstatus); werase (Globals.wmain); werase (Globals.whelp); wrefresh (Globals.wstatus); wrefresh (Globals.wmain); wrefresh (Globals.whelp); wattrset (Globals.whelp, color_term ? COLOR_PAIR(3) | A_BOLD : A_NORMAL); wattrset (Globals.wstatus, color_term ? COLOR_PAIR(4) | A_BOLD : A_REVERSE); move (0, 0); wmove (Globals.wstatus, 0, 0); for (i = 0; i < COLS; i++) wprintw (Globals.wstatus, " "); if (Globals.mode == CALCULATOR_MODE) { extern struct calcEntryBox *bbox; extern struct calcEntryBox *obox; extern struct calcEntryBox *dbox; extern struct calcEntryBox *hbox; extern int calc_mode; wmove (Globals.wmain, 1, (COLS / 2) - (strlen ("Binary Calculator") / 2)); wprintw (Globals.wmain, "Binary Calculator"); calcStatWindow (); wmove (Globals.whelp, 0, 0); wprintw (Globals.whelp, "^X/^G Return ^C Exit J Down K Up"); calcDrawBoxes (bbox, obox, dbox, hbox, calc_mode); wrefresh (Globals.wstatus); wrefresh (Globals.whelp); wrefresh (Globals.wmain); refresh (); } else { printStatusWindow (); printHelpWindow (); wmove (Globals.wmain, 0, 0); if (Globals.mode == HEX_MODE) { drawdump (off); wrefresh (Globals.wmain); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); } else { drawAscii (off); wrefresh (Globals.wmain); move (acursor_y, acursor_x); } } refresh (); } ncurses-hexedit-0.9.7.orig/src/search.c0100644000175000017500000000513406735425371016446 0ustar apocapoc/* search.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" static unsigned char curr; struct foundit * boyer_moore_search (unsigned char *substr, unsigned long offs, unsigned long len, unsigned long buflen) /* Uses the Boyer Moore Search algorithm by building up a table */ { int j = 0; unsigned char *s = NULL; unsigned char *buf = NULL; unsigned char c = '\0'; unsigned long i = 0; unsigned long l_table[256]; static struct foundit found; found.offset = 0x00; found.flag = 0; if ((len <= 0) || (buflen <= 0)) return &found; buf = malloc (len); if (!buf) return &found; memset (l_table, 0, 256 * sizeof (int)); i = 0; s = substr + len - 1; while (i < len) { if (!l_table[(int) *s]) { if (i != 0) l_table[(int) *s] = i; else l_table[(int) *s] = -1; } else if (l_table[(int) *s] == -1) l_table[(int) *s] = i; s--; i++; } for (i = 0; i < 256; i++) { if (l_table[i] == -1) l_table[i] = len; else if (!l_table[i]) l_table[i] = len; } s = substr; i = 0; curr = '\0'; while (i < buflen - len + 1) { for (j = 0; j < len; j++) *(buf + j) = filebuffer (offs + i + j); if ((c = bytecmp (s, buf, len)) != 0) { if (i == buflen - len + 1) { free (buf); return &found; } i += l_table[(unsigned int) curr]; } else { found.offset = i; found.flag = 1; free (buf); return &found; } } free (buf); return &found; } unsigned char bytecmp (const unsigned char *s1, const unsigned char *s2, long n) /* searched string backwards for Boyer-Moore search */ { s1 += n - 1; s2 += n - 1; curr = *s2; while (n-- > 0) { if (*s1 != *s2) { return 1; } s1--; s2--; } if (n < 0) return 0; return 1; } ncurses-hexedit-0.9.7.orig/src/undo.c0100644000175000017500000001466706735452343016160 0ustar apocapoc/* undo.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include #include "hexedit.h" void pushUndo (int type, unsigned long offset, unsigned char old, unsigned char new) /* Push the latest change on the undo stack */ { if (!UndoStack.s) { assert (!UndoStack.base); UndoStack.base = malloc (sizeof (struct Change)); if (!UndoStack.base) /* quietly make undo disabled */ return; UndoStack.base->type = type; UndoStack.base->offset = offset; UndoStack.base->new = new; UndoStack.base->old = old; UndoStack.base->p = NULL; UndoStack.top = UndoStack.base; } else { assert (UndoStack.base && UndoStack.top); UndoStack.top->p = malloc (sizeof (struct Change)); if (!UndoStack.top->p) /* quietly make undo disabled */ return; UndoStack.top = UndoStack.top->p; UndoStack.top->type = type; UndoStack.top->offset = offset; UndoStack.top->new = new; UndoStack.top->old = old; UndoStack.top->p = NULL; } UndoStack.s++; } void undoLastChange () /* This is not reentrant. If you somehow hit Control-U and resize the * screen extremely quickly, It may try to undo a portion of the screen * that is no longer viewable. Ignoring SIGWINCH would fix this. */ { int bold = 0; if (!UndoStack.s) { do_beep (); refresh (); return; } else { unsigned long top = 0; unsigned long bottom = 0; assert (UndoStack.base && UndoStack.top); top = cursor_y - MAIN_TOP_LINE; top = (offset - (top * M_0x10)) & M_0xFFFFFFF0; bottom = BOTTOM_LINE - cursor_y + 1; bottom = (offset + (bottom * M_0x10)) & M_0xFFFFFFF0; if ((UndoStack.top->offset >= top) && (UndoStack.top->offset < bottom)) /* Last changed position is currently viewable on the screen */ { int t = 0; cursor_x = mappos (UndoStack.top->offset & M_0x0F); t = ((UndoStack.top->offset & M_0xFFFFFFF0) - (offset & M_0xFFFFFFF0)); if (t > 0) cursor_y += t >> 4; else if (t < 0) cursor_y -= (-t) >> 4; offset = UndoStack.top->offset; switch (UndoStack.top->type) { case INSERT: deleteByte (1); break; case DELETE: insertByte (UndoStack.top->old, 1); break; case CHANGE: { struct Change *p = UndoStack.base; struct Change *q = NULL; /* We need to see if there are other changes * at this offset, so we can add that older value * as the new current one in the hash. */ while (p != UndoStack.top) { if (p->offset == offset) q = p; p = p->p; } filebuff_modify (offset, UndoStack.top->old); /* If the older change to this offset exists, add * it as the current one in the cache. */ if (q && (q != UndoStack.top)) insert_hash_entry (offset, q->new); else delete_hash_entry (offset); break; } } bold = hash_lookup (offset, NULL); if (!bold) wattrset (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); wmove (Globals.wmain, cursor_y - 1, cursor_x); wprintw (Globals.wmain, "%02lX", filebuffer (offset)); wmove (Globals.wmain, cursor_y - 1, COLS - M_0x10 + mapcur (cursor_x)); if (Globals.charset == ASCII_CHAR_SET) { if (isprintable (filebuffer (offset))) wprintw (Globals.wmain, "%c", filebuffer (offset)); else wprintw (Globals.wmain, "."); } else /* EBCDIC */ { wprintw (Globals.wmain, "%c", EBCDIC[filebuffer (offset)]); } if (!bold) { wattroff (Globals.wmain, color_term ? COLOR_PAIR(2) | A_BOLD : A_BOLD); if (color_term) wattrset (Globals.wmain, COLOR_PAIR(1)); } if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); printStatusWindow (); wrefresh (Globals.wmain); refresh (); } else /* must move the screen so the last changed position is viewable */ { offset = UndoStack.top->offset; cursor_y = MAIN_TOP_LINE; cursor_x = mappos (offset & M_0x0F); if (Globals.tabb) move (cursor_y, COLS - M_0x10 + mapcur (cursor_x)); else move (cursor_y, cursor_x); /* we need to move the whole screen to see the change, unlike * above where the change is on the current viewable screen. * We don't undo though, we let the user see that position of * the file, and the next ^U will do that actual undo using * the previous section of code. */ redraw (); return; } } if (UndoStack.s == 1) { assert (UndoStack.base == UndoStack.top); free (UndoStack.base); UndoStack.base = UndoStack.top = NULL; UndoStack.s = 0; } else { struct Change *p = UndoStack.top; assert (UndoStack.base != UndoStack.top); UndoStack.top = UndoStack.base; while (UndoStack.top->p != p) UndoStack.top = UndoStack.top->p; free (UndoStack.top->p); UndoStack.top->p = NULL; UndoStack.s--; } } ncurses-hexedit-0.9.7.orig/src/widgets.c0100644000175000017500000003525706735760065016662 0ustar apocapoc/* widgets.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" #define S_BOX_COLOR (COLOR_PAIR(4) | A_BOLD) WINDOW * popupWindow (int width, int height) /* Generic blank popup window with a border. Comes out centered. */ { int winy = 0, winx = 0; WINDOW *wpopup = NULL; if (LINES < height) height = LINES; if (COLS < width) width = COLS; winy = (LINES / 2) - (height / 2); winx = (COLS / 2) - (width / 2); wpopup = newwin (height, width, winy, winx); if (wpopup == NULL) { fprintf (stderr, "Cannot open up popup window\n"); return NULL; } scrollok (wpopup, FALSE); box (wpopup, 0, 0); return wpopup; } char * stringBox (WINDOW *win, int y, int x, int len, int max, char *sample) /* Creates a entry box to type in a string and returns it. * You are responsible for freeing the returned pointer. */ { char *str = NULL; int done = 0; int i = 0; int n = 0; int oldx = 0; int left = 0; int right = max - 1; int samplelen = strlen (sample ? sample : ""); wchar_t in = 0; wmove (win, y, x); wattrset (win, color_term ? S_BOX_COLOR : A_REVERSE); str = malloc (len + 2); if (!str) { /* fprintf (stderr, "%s - StringBox\n", NOT_ENOUGH_MEMORY); */ popup_Error (NOT_ENOUGH_MEMORY, 0); return NULL; } *(str + len + 1) = '\0'; memset (str, ' ', len + 1); strncpy (str, sample ? sample : "", samplelen); for (i = 0; i < max; i++) { if (*(str + i) && (i < max)) { wprintw (win, "%c", *(str + i)); } else wprintw (win, " "); } i = samplelen; if (i >= max) i = max - 1; wmove (win, y, x + i); wrefresh (win); while (!done && ((in = getch ()) != '\n')) { switch (in) { case CONTROL_C: case CONTROL_G: case CONTROL_X: case ESCAPE_CHARACTER: *str = '\0'; done = 1; break; case KEY_LEFT: if (i > 0) { if (win->_curx > x) /* not at left hand side */ { i--; wmove (win, y, win->_curx - 1); } else if (i > 0) /* left hand side */ { i--; if (left > 0) { left--; right--; } wmove (win, y, x); for (n = left; n <= right; n++) { if ((n < len) && *(str + n)) wprintw (win, "%c", *(str + n)); else wprintw (win, " "); } wmove (win, y, x); } } break; case KEY_RIGHT: if (win->_curx < (x + max - 1)) /* not at right hand side */ { i++; wmove (win, y, win->_curx + 1); } else if (i < len - 1) /* right hand side */ { i++; if (right < len - 1) { left++; right++; } wmove (win, y, x); for (n = left; n <= right; n++) { if (*(str + n)) wprintw (win, "%c", *(str + n)); else wprintw (win, " "); } wmove (win, y, x + max - 1); } break; case BACKSPACE: case CONTROL_H: case KEY_BACKSPACE: case KEY_DC: #ifdef __PDCURSES__ case CTL_BKSP: #endif if (i > 0) { if (win->_curx > x) /* not at left hand side */ { i--; for (n = strlen (str); n < len; n++) *(str + n) = ' '; for (n = i; n < len; n++) *(str + n) = *(str + n + 1); *(str + n) = ' '; oldx = win->_curx; wmove (win, y, x); for (n = left; n <= right; n++) { if (*(str + n)) wprintw (win, "%c", *(str + n)); else wprintw (win, " "); } wmove (win, y, oldx - 1); } else /* at left hand side, not begining of buffer */ { i--; for (n = i; n < len - 1; n++) *(str + n) = *(str + n + 1); if (left > 0) { left--; right--; } wmove (win, y, x); for (n = left; n <= right; n++) { if (*(str + n)) wprintw (win, "%c", *(str + n)); else wprintw (win, " "); } wmove (win, y, x); } } else do_beep (); break; case SPACEBAR: oldx = win->_curx; if ((win->_curx < x + max - 1) && (i < len - 1) && (*(str + len - 1) <= ' ')) { for (n = len - 1; n > i; n--) { *(str + n) = *(str + n - 1); } *(str + i) = ' '; *(str + len) = ' '; i++; wmove (win, y, x); for (n = left; n <= right; n++) { if (*(str + n)) wprintw (win, "%c", *(str + n)); else wprintw (win, " "); } wmove (win, y, oldx + 1); } else if ((win->_curx == x + max - 1) && (i < len - 1) && (*(str + len - 1) <= ' ')) { for (n = len - 1; n > i; n--) { *(str + n) = *(str + n - 1); } *(str + i) = ' '; *(str + len) = ' '; i++; if (right < len - 1) { left++; right++; } wmove (win, y, x); for (n = left; n <= right; n++) { if (*(str + n)) wprintw (win, "%c", *(str + n)); else wprintw (win, " "); } wmove (win, y, x + max - 1); } else if ((win->_curx == x + max - 1) && (i == len - 1)) { *(str + len - 1) = ' '; wmove (win, y, x + max - 1); wprintw (win, " "); wmove (win, y, x + max - 1); do_beep (); } else do_beep (); break; /* erase whole line and bring cursor back to begining */ case CONTROL_U: memset (str, 0x00, len); wmove (win, y, x); for (i = 0; i < max; i++) wprintw (win, " "); i = 0; left = 0; right = max - 1; wmove (win, y, x); wrefresh (win); break; default: /* normal input */ if (isprintable (in)) { if (win->_curx != (x + max - 1)) /* not at right hand side */ { *(str + i) = in; i++; oldx = win->_curx; wmove (win, y, x); for (n = left; n <= right; n++) { if (*(str + n)) wprintw (win, "%c", *(str + n)); else wprintw (win, " "); } wmove (win, y, oldx + 1); } else if (i < len - 1) /* right hand side, not end of buffer */ { *(str + i) = in; i++; if (right < len - 1) { left++; right++; } wmove (win, y, x); for (n = left; n <= right; n++) { if (*(str + n)) wprintw (win, "%c", *(str + n)); else wprintw (win, " "); } wmove (win, y, x + max - 1); } else if (i == len - 1) /* right hand side, end of buffer */ { *(str + i) = in; do_beep (); wmove (win, y, x); for (n = left; n <= right; n++) { if (*(str + n)) wprintw (win, "%c", *(str + n)); else wprintw (win, " "); } wmove (win, y, x + max - 1); } } } wrefresh (win); } return str; } struct ret_string * hex_string_box (WINDOW *win, int searchlen, int boxwidth) { wchar_t in = 0; int newbyte = 1; int i = 0; int move = 0; int width = (searchlen * 3) - 1; int boxleft = (boxwidth / 2) - (width / 2); static struct ret_string rstr = { 0, NULL }; rstr.len = 0; if (rstr.str) { rstr.len = 0; free (rstr.str); rstr.str = NULL; } rstr.str = malloc (searchlen); if (!rstr.str) { wmove (win, 4, boxleft); wprintw (win, (char *) NOT_ENOUGH_MEMORY); getch (); return NULL; } memset (rstr.str, 0, searchlen); wmove (win, 3, boxleft); wprintw (win, "text: "); wattrset (win, color_term ? S_BOX_COLOR : A_REVERSE); wmove (win, 6, boxleft); for (i = 0; i < width + 3; i++) wprintw (win, " "); wattroff (win, color_term ? S_BOX_COLOR : A_REVERSE); wmove (win, 6, boxleft); wrefresh (win); while ((in = getch ()) != '\n') { if (isHexChar (in)) { if (rstr.len >= 16) { do_beep (); wrefresh (win); continue; } *(rstr.str + rstr.len) |= newbyte ? getHexValue (in) << 4: getHexValue (in); move = 0; if (rstr.len > 0) move = rstr.len + (2 * rstr.len); if (!newbyte) move += 1; wmove (win, 3, boxleft + strlen ("text: ") + rstr.len); if (Globals.charset == ASCII_CHAR_SET) { if (isprintable (*(rstr.str + rstr.len))) wprintw (win, "%c", *(rstr.str + rstr.len)); else wprintw (win, "."); } else wprintw (win, "%c", EBCDIC[*(rstr.str + rstr.len)]); wmove (win, 6, boxleft + move); wattrset (win, color_term ? S_BOX_COLOR : A_REVERSE); wprintw (win, "%c", isupper (in) ? in : (toupper (in))); /* isupper (in) ? in : toupper (in)); */ if (newbyte) wprintw (win, "0"); wattroff (win, color_term ? S_BOX_COLOR : A_REVERSE); if (newbyte) { wmove (win, 6, boxleft + move + 1); newbyte = 0; } else { wmove (win, 6, boxleft + move + 2); newbyte = 1; rstr.len++; } wrefresh (win); } else switch (in) { case BACKSPACE: case CONTROL_H: case KEY_BACKSPACE: case KEY_DC: #ifdef __PDCURSES__ case CTL_BKSP: #endif if (newbyte) { if (rstr.len <= 0) { do_beep (); wrefresh (win); continue; } newbyte = 0; rstr.len--; *(rstr.str + rstr.len) &= M_0xF0; move = rstr.len + (2 * rstr.len) + 1; wmove (win, 3, boxleft + strlen ("text: ") + rstr.len + 1); wprintw (win, " "); wmove (win, 6, boxleft + move + 2); wattrset (win, color_term ? S_BOX_COLOR : A_REVERSE); wprintw (win, " "); wmove (win, 6, boxleft + move); wprintw (win, "0"); wattroff (win, color_term ? S_BOX_COLOR : A_REVERSE); wmove (win, 6, boxleft + move); wmove (win, 3, boxleft + strlen ("text: ") + rstr.len); if (isprintable (*(rstr.str + rstr.len))) wprintw (win, "%c", *(rstr.str + rstr.len)); else wprintw (win, "."); wmove (win, 6, boxleft + move); wrefresh (win); } else { newbyte = 1; *(rstr.str + rstr.len) = 0x00; if (rstr.len > 0) move = rstr.len + (2 * rstr.len); else move = 0; wmove (win, 3, boxleft + strlen ("text: ") + rstr.len); if (isprintable (*(rstr.str + rstr.len))) wprintw (win, "%c", *(rstr.str + rstr.len)); else wprintw (win, "."); wmove (win, 6, boxleft + move); wattrset (win, color_term ? S_BOX_COLOR : A_REVERSE); wprintw (win, "0"); wattroff (win, color_term ? S_BOX_COLOR : A_REVERSE); wmove (win, 6, boxleft + move); wrefresh (win); } break; case CONTROL_C: case CONTROL_G: case CONTROL_X: case ESCAPE_CHARACTER: return NULL; } } return &rstr; } ncurses-hexedit-0.9.7.orig/src/windows.c0100644000175000017500000006145306753170237016677 0ustar apocapoc/* windows.c by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #include "hexedit.h" /* Brings up Jump to offset window, to relocate to a different part * of the file. Uses one string box and takes input in octal, decimal, * and hex. */ void popupGotoOffset (long filesize) #define OFFSET_BOX_STRING_BOX 12 #define OFFSET_BOX_HEIGHT 8 #define OFFSET_BOX_WIDTH 50 #define OFFSET_STRING_BUF 11 { char *offstr = NULL; char offsetstr[OFFSET_STRING_BUF]; unsigned long off = 0x00; WINDOW *wpopup = popupWindow (OFFSET_BOX_WIDTH, OFFSET_BOX_HEIGHT); struct sigaction sig_new, sig_old; /* signal (SIGINT, SIG_IGN); */ sig_new.sa_handler = SIG_IGN; memset (&sig_new.sa_mask, 0x00, sizeof (sigset_t)); sig_new.sa_flags = 0; sigaction (SIGINT, &sig_new, &sig_old); wmove (wpopup, 1, (OFFSET_BOX_WIDTH / 2) - (strlen ("Goto Offset") / 2)); wprintw (wpopup, "Goto Offset"); wmove (wpopup, 5, 2); wprintw (wpopup, " Hint: Decimal 255 = Hex 0xFF = Octal 0377"); wmove (wpopup, 3, (OFFSET_BOX_WIDTH / 2) - (OFFSET_BOX_STRING_BOX / 2) - (strlen ("Offset:") / 2)); wprintw (wpopup, "Offset: "); memset (offsetstr, 0, OFFSET_STRING_BUF); sprintf (offsetstr, "0x"); /* uncomment to have eof offset autofilled in string box sprintf (offsetstr, "0x%08lX", filesize); */ werase (Globals.whelp); wmove (Globals.whelp, 0, 0); wprintw (Globals.whelp, "^G/^X/Escape Cancel ^U Clear input"); wrefresh (Globals.whelp); offstr = stringBox (wpopup, 3, (OFFSET_BOX_WIDTH / 2), OFFSET_BOX_STRING_BOX, OFFSET_BOX_STRING_BOX, offsetstr); if (!*offstr) off = offset; else { errno = 0; off = strtoul (offstr, NULL, 0); if (errno) /* Possible ERANGE return */ offset = 0; else if (off > filesize) offset = filesize; else offset = off; cursor_x = mappos (offset & M_0x0F); cursor_y = MAIN_TOP_LINE; } free (offstr); delwin (wpopup); /* signal (SIGINT, handleInterrupt); */ sigaction (SIGINT, &sig_old, NULL); } /* Print the whole line between the box border. */ static void print_line (WINDOW *win, int cols, int y, char c) { int i = 0; wmove (win, y, 1); for (i = 0; i < (cols - 2); i++) wprintw (win, "%c", c); } void do_outer_help_box (WINDOW *win, int y, int lines) { box (win, 0, 0); wmove (win, 0, (COLS / 2) - (strlen ("Help Menu") / 2) - 2); wprintw (win, "Help Menu"); if (y > 0) { wmove (win, 0, COLS - strlen ("(more)") - 1); wprintw (win, "(more)"); } if ((y + lines) < (Globals.help_msg_count + 1)) { wmove (win, MAIN_BOTTOM_LINE, COLS - strlen ("(more)") - 1); wprintw (win, "(more)"); } } /* initialize the help at the start of the program so that it's dynamic so we can have the right help when you start up, then it will be easy. */ void popupHelp (void) #define HELP_BOX_HEIGHT MAIN_HEIGHT #define HELP_BOX_WIDTH COLS #define STRING_BUF 80 { /* Unless you change what you shouldn't, this is fine */ char s[STRING_BUF]; int i = 0; int y = 0; WINDOW *wpopup = popupWindow (HELP_BOX_WIDTH, HELP_BOX_HEIGHT); struct sigaction sig_new, sig_old; wchar_t in = 0; /* signal (SIGINT, SIG_IGN); */ sig_new.sa_handler = SIG_IGN; memset (&sig_new.sa_mask, 0x00, sizeof (sigset_t)); sig_new.sa_flags = 0; sigaction (SIGINT, &sig_new, &sig_old); wattrset (wpopup, color_term ? COLOR_PAIR(1) : A_NORMAL); mvwin (wpopup, MAIN_TOP_LINE, 0); do_outer_help_box (wpopup, 0, LINES - 3); for (y = 1; y < MAIN_BOTTOM_LINE; y++) print_line (wpopup, HELP_BOX_WIDTH, y, ' '); memset (s, 0x00, STRING_BUF); #ifdef HAVE_SNPRINTF snprintf (s, STRING_BUF, "[N]Curses Hexedit %s Adam Rogoyski ", VERSION); #else sprintf (s, "[N]Curses Hexedit %s Adam Rogoyski ", VERSION); #endif werase (Globals.whelp); wmove (Globals.whelp, 0, (COLS / 2) - (strlen (s) / 2)); wprintw (Globals.whelp, "%s", s); wrefresh (Globals.whelp); y = 0; help_print (wpopup, y, LINES - 3); wrefresh (wpopup); while ((in = getch ())) { switch (in) { case '\n': case ESCAPE_CHARACTER: case CONTROL_C: case CONTROL_G: case CONTROL_X: case 'q': case 'Q': delwin (wpopup); sigaction (SIGINT, &sig_old, NULL); return; case KEY_DOWN: case 'j': case 'J': if ((y + LINES - 5) < (Globals.help_msg_count - 1)) y++; break; case KEY_UP: case 'k': case 'K': if (y > 0) y--; break; default: continue; } for (i = 1; i < MAIN_BOTTOM_LINE; i++) print_line (wpopup, HELP_BOX_WIDTH, i, ' '); help_print (wpopup, y, LINES - 3); do_outer_help_box (wpopup, y, LINES - 3); wrefresh (wpopup); } delwin (wpopup); /* signal (SIGINT, handleInterrupt); */ sigaction (SIGINT, &sig_old, NULL); } /* Brings up a popup window and prompts with a stringbox for the * filename to save as. */ int popupFileSave (void) #define FILE_SAVE_STRING_BOX 50 #define FILE_SAVE_STRING_BOX_MAX PATH_MAX #define FILE_SAVE_HEIGHT 6 #define FILE_SAVE_WIDTH 70 { int result = 0; int saved = 0; char *filename = NULL; FILE *fp = NULL; WINDOW *wpopup = popupWindow (FILE_SAVE_WIDTH, FILE_SAVE_HEIGHT); struct sigaction sig_new, sig_old; /* signal (SIGINT, SIG_IGN); */ sig_new.sa_handler = SIG_IGN; memset (&sig_new.sa_mask, 0x00, sizeof (sigset_t)); sig_new.sa_flags = 0; sigaction (SIGINT, &sig_new, &sig_old); wmove (wpopup, 1, (FILE_SAVE_WIDTH / 2) - (strlen ("Save File") / 2)); wprintw (wpopup, "Save File"); wmove (wpopup, 3, 2); wprintw (wpopup, "Filename: "); werase (Globals.whelp); wmove (Globals.whelp, 0, 0); wprintw (Globals.whelp, "^G/^X/Escape Cancel"); wrefresh (Globals.whelp); filename = stringBox (wpopup, 3, 2 + strlen ("Filename: "), FILE_SAVE_STRING_BOX_MAX, FILE_SAVE_STRING_BOX, (char *) Globals.filename); chompWhiteSpace (filename); if (!filename); else if (!*filename) { free (filename); filename = NULL; } else { if (!strcmp (Globals.filename, filename)) { fclose (Globals.fp); fp = fopen (filename, "r+b"); Globals.fp = fp; } else fp = fopen (filename, "wb"); if (!fp) { wattroff (wpopup, A_REVERSE); werase (wpopup); box (wpopup, 0, 0); wmove (wpopup, 1, (FILE_SAVE_WIDTH / 2) - (strlen ("Cannot Save File") / 2)); wprintw (wpopup, "Cannot Save File"); wmove (wpopup, FILE_SAVE_HEIGHT - 3, (FILE_SAVE_WIDTH / 2) - (strlen (strerror (errno)) + strlen ("Reason: ")) / 2); wprintw (wpopup, "Reason: %s", strerror (errno)); wrefresh (wpopup); getch (); if (!strcmp (Globals.filename, filename)) { Globals.fp = fopen (Globals.filename, "rb"); if (!Globals.fp) die_horribly ("Cannot save to original file, nor reopen it", NULL); } if (filename) free (filename); filename = NULL; } else { int buf = 0; unsigned long i = 0; int len = Globals.filesize + 1; /* If it's all in memory just write it out to the file */ if (Globals.fullsize) { while (len > 0) { if (len > DEFAULT_READ_BUFFER) buf = DEFAULT_READ_BUFFER; else buf = len; result = fwrite (filebuf + i, 1, buf, fp); if (result > 0) len -= result; else len = 0; i += result; } ftruncate (fileno (fp), Globals.filesize); } /* If not, we read it from the old file, make the neccessary * changes, and then write it to the new file (possibly the * same file. */ else { /* Two situations: * 1. If we are writing to the same file, we just add the * changes (fast). * 2. If we are writing to a new file, we need to re-read * the entire old file and make the changes as we go (slow). */ if (!strcmp (Globals.filename, filename) || Globals.fixed_disk) /* same file, just add the changes */ { /* cycle through the hash and write all the changes */ commit_changes_in_hash (fp); } else /* different file, re-read whole old one and add changes */ { unsigned char buffer[DEFAULT_READ_BUFFER]; unsigned char c = '\0'; int pos = 0; int result2 = 0; int tst = 0; memset (buffer, 0x00, DEFAULT_READ_BUFFER); while (len > 0) { if (len > DEFAULT_READ_BUFFER) buf = DEFAULT_READ_BUFFER; else buf = len; result = fseek (Globals.fp, pos, SEEK_SET); if (result < 0) die_horribly ("Cannot re-read original file", Globals.filename); result = fread (buffer, 1, buf, Globals.fp); if (ferror (Globals.fp)) die_horribly ("Cannot re-read original file", Globals.filename); /* Make edited changes to file */ for (i = pos; i < (pos + result); i++) { if (!hash_lookup (i, &c)) buffer[i - pos] = c; } tst = fseek (fp, pos, SEEK_SET); if (tst < 0) die_horribly ("Cannot read file", filename); result2 = fwrite (buffer, 1, result, fp); if (result2 != result) die_horribly ("Cannot write new file correctly", "fwrite"); if (result > 0) len -= result; else len = 0; pos += result; } free ((char *) Globals.filename); Globals.filename = filename; filename = NULL; } } fflush (fp); result = 0; if (fp != Globals.fp) result = fclose (fp); else result = fflush (fp); if (result == -1) { wattroff (wpopup, A_REVERSE); werase (wpopup); box (wpopup, 0, 0); wmove (wpopup, 1, (FILE_SAVE_WIDTH / 2) - (strlen ("Cannot Save File") / 2)); wprintw (wpopup, "bCannot Save File"); wmove (wpopup, FILE_SAVE_HEIGHT - 3, (FILE_SAVE_WIDTH / 2) - (strlen (strerror (errno)) + strlen ("Reason: ")) / 2); wprintw (wpopup, "Reason: %s", strerror (errno)); wrefresh (wpopup); if (filename) free (filename); filename = NULL; getch (); } else { saved = 1; Globals.modified = 0; } } if (filename) { free ((char *) Globals.filename); Globals.filename = filename; filename = NULL; } } if (filename) free (filename); delwin (wpopup); /* signal (SIGINT, handleInterrupt); */ sigaction (SIGINT, &sig_old, NULL); return saved; } /* XXX This is really ugly, this needs to be redone eventually. I * want to add search/replace type things, but it's too ugly, needs * to be totaly redone, I don't feel like figuring out how it works. * I must have been up really late. */ void search (int findnext) #define SEARCH_BOX_WIDTH 60 #define SEARCH_BOX_HEIGHT 10 #define SEARCH_STRING_BOX 50 #define SEARCH_STRING_BOX_MAX 50 { char *options[] = { "Find Next", "search for text string", "search for Hex bytes" }; static unsigned char *laststr = NULL; static int first = 1; static int last_str_len = 0; static unsigned char *s = NULL; int done = 0; int selection = 0; wchar_t in = 0; WINDOW *wpopup = popupWindow (SEARCH_BOX_WIDTH, SEARCH_BOX_HEIGHT); struct sigaction sig_new, sig_old; if (findnext && !laststr) return; /* signal (SIGINT, SIG_IGN); */ sig_new.sa_handler = SIG_IGN; memset (&sig_new.sa_mask, 0x00, sizeof (sigset_t)); sig_new.sa_flags = 0; sigaction (SIGINT, &sig_new, &sig_old); werase (Globals.whelp); wmove (Globals.whelp, 0, 0); wprintw (Globals.whelp, "^G/^X/Escape Cancel F/N Find Next A Text Search H Hex Search"); wrefresh (Globals.whelp); wmove (wpopup, 1, (SEARCH_BOX_WIDTH / 2) - (strlen ("Search") / 2)); wprintw (wpopup, "Search"); if (first) selection = 1; if (!first) wattrset (wpopup, A_REVERSE); wmove (wpopup, 3, (SEARCH_BOX_WIDTH / 2) - (strlen (options[0]) / 2)); wprintw (wpopup, "%s", options[0]); if (!first) wattroff (wpopup, A_REVERSE); if (first) wattrset (wpopup, A_REVERSE); wmove (wpopup, 5, (SEARCH_BOX_WIDTH / 2) - (strlen (options[1]) / 2)); wprintw (wpopup, "%s", options[1]); if (first) wattroff (wpopup, A_REVERSE); wmove (wpopup, 7, (SEARCH_BOX_WIDTH / 2) - (strlen (options[2]) / 2)); wprintw (wpopup, "%s", options[2]); if (findnext) { selection = 0; done = 1; } else wrefresh (wpopup); while (!done && ((in = getch()) != '\n')) { switch (in) { case 'f': case 'F': case 'n': case 'N': first = 0; done = 1; selection = 0; break; case 'a': case 'A': first = 0; done = 1; selection = 1; break; case 'h': case 'H': first = 0; done = 1; selection = 2; break; case CONTROL_C: case CONTROL_G: case CONTROL_X: case ESCAPE_CHARACTER: done = -1; break; case KEY_UP: case KEY_DOWN: case 'j': case 'J': case 'k': case 'K': if (toupper (in) == 'J') in = KEY_DOWN; else if (toupper (in) == 'K') in = KEY_UP; if ((in == KEY_UP) && (selection == 0)) selection = 2; else if (in == KEY_UP) selection--; if ((in == KEY_DOWN) && (selection == 2)) selection = 0; else if (in == KEY_DOWN) selection++; if (first && (selection == 0) && (in == KEY_UP)) selection = 2; else if (first && (selection == 0) && (in == KEY_DOWN)) selection = 1; if (selection == 0) wattrset (wpopup, A_REVERSE); wmove (wpopup, 3, (SEARCH_BOX_WIDTH / 2) - (strlen (options[0]) / 2)); wprintw (wpopup, "%s", options[0]); if (selection == 0) wattroff (wpopup, A_REVERSE); if (selection == 1) wattrset (wpopup, A_REVERSE); wmove (wpopup, 5, (SEARCH_BOX_WIDTH / 2) - (strlen (options[1]) / 2)); wprintw (wpopup, "%s", options[1]); if (selection == 1) wattroff (wpopup, A_REVERSE); if (selection == 2) wattrset (wpopup, A_REVERSE); wmove (wpopup, 7, (SEARCH_BOX_WIDTH / 2) - (strlen (options[2]) / 2)); wprintw (wpopup, "%s", options[2]); if (selection == 2) wattroff (wpopup, A_REVERSE); wrefresh (wpopup); break; } } if (done == -1) { /* signal (SIGINT, handleInterrupt); */ sigaction (SIGINT, &sig_old, NULL); return; } done = 0; wmove (wpopup, 3, (SEARCH_BOX_WIDTH / 2) - (strlen (options[0]) / 2)); wprintw (wpopup, "%*c", strlen (options[0]), ' '); wmove (wpopup, 5, (SEARCH_BOX_WIDTH / 2) - (strlen (options[1]) / 2)); wprintw (wpopup, "%*c", strlen (options[1]), ' '); wmove (wpopup, 7, (SEARCH_BOX_WIDTH / 2) - (strlen (options[2]) / 2)); wprintw (wpopup, "%*c", strlen (options[2]), ' '); if (selection == 0) { struct foundit *spot = NULL; if (offset < Globals.filesize - 1) spot = boyer_moore_search (laststr, offset + 1, last_str_len, Globals.filesize - offset); if (spot && spot->flag) { offset += spot->offset + 1; /* started search one character ahead of offset */ cursor_y = 1; cursor_x = mappos (offset & M_0x0F); } else { int i = 0; wattroff (wpopup, A_REVERSE); wmove (wpopup, (SEARCH_BOX_HEIGHT / 2) + 1, 1); for (i = 2; i < SEARCH_BOX_WIDTH; i++) wprintw (wpopup, " "); wmove (wpopup, (SEARCH_BOX_HEIGHT / 2) + 1, (SEARCH_BOX_WIDTH / 2) - (strlen ("** String not found **") / 2)); wprintw (wpopup, "** String not found **"); wrefresh (wpopup); getch (); } } else if (selection == 1) { unsigned char *str = NULL; unsigned char *strb = NULL; if (laststr) { free (laststr); laststr = NULL; } wmove (wpopup, 1, (SEARCH_BOX_WIDTH / 2) - (strlen ("Text String") / 2)); wprintw (wpopup, "Text String"); str = strb = (unsigned char *) stringBox (wpopup, (SEARCH_BOX_HEIGHT / 2) + 1, (SEARCH_BOX_WIDTH - SEARCH_STRING_BOX) / 2, SEARCH_STRING_BOX_MAX, SEARCH_STRING_BOX, NULL); s = (unsigned char *) str; laststr = s; for (str = s + SEARCH_STRING_BOX_MAX - 1; str != (s - 1); str--) { if (*str != ' ') { *(str + 1) = '\0'; done = 1; break; } } if (Globals.charset == EBCDIC_CHAR_SET) { unsigned char *p = s; while (*p) { *p = findEBCDIC (*p); p++; } } if (done) { struct foundit *spot = NULL; if (offset < Globals.filesize - 1) spot = boyer_moore_search (s, offset + 1, last_str_len = strlen ((char *) s), Globals.filesize - offset); if (spot && spot->flag) { offset += spot->offset + 1; /* started search one character ahead of offset */ cursor_y = 1; cursor_x = mappos (offset & M_0x0F); } else { int i = 0; wattroff (wpopup, A_REVERSE); wmove (wpopup, (SEARCH_BOX_HEIGHT / 2) + 1, 1); for (i = 2; i < SEARCH_BOX_WIDTH; i++) wprintw (wpopup, " "); wmove (wpopup, (SEARCH_BOX_HEIGHT / 2) + 1, (SEARCH_BOX_WIDTH / 2) - (strlen ("** String not found **") / 2)); wprintw (wpopup, "** String not found **"); wrefresh (wpopup); getch (); } } } else if (selection == 2) { #define BYTE_SEARCH_LENGTH 16 struct ret_string *retr; wmove (wpopup, 1, (SEARCH_BOX_WIDTH / 2) - (strlen ("Byte Search") / 2)); wprintw (wpopup, "Byte Search"); retr = hex_string_box (wpopup, BYTE_SEARCH_LENGTH, SEARCH_BOX_WIDTH); if (retr) { struct foundit *spot = NULL; if (offset < Globals.filesize - 1) spot = boyer_moore_search (retr->str, offset + 1, last_str_len = retr->len, Globals.filesize - offset); if (spot && spot->flag) { offset += spot->offset + 1; /* started search one character ahead of offset */ cursor_y = 1; cursor_x = mappos (offset & M_0x0F); if (laststr) free (laststr); laststr = malloc (retr->len + 1); memset (laststr, 0x00, retr->len + 1); memcpy (laststr, retr->str, retr->len); free (retr->str); retr->str = NULL; retr->len = 0; } else { int i = 0; wattroff (wpopup, A_REVERSE); wmove (wpopup, (SEARCH_BOX_HEIGHT / 2) + 1, 1); for (i = 2; i < SEARCH_BOX_WIDTH; i++) wprintw (wpopup, " "); wmove (wpopup, (SEARCH_BOX_HEIGHT / 2) + 1, (SEARCH_BOX_WIDTH / 2) - (strlen ("** String not found **") / 2)); wprintw (wpopup, "** String not found **"); wrefresh (wpopup); getch (); } } } first = 0; /* signal (SIGINT, handleInterrupt); */ sigaction (SIGINT, &sig_old, NULL); delwin (wpopup); } /* Brings up a prompt in the help window and prompts for the relative * offset to jump by. */ void jump_relative_offset (wchar_t sign) /* pass sign as '+' or '-' to prompt for an offset to jump to relative * to current offset. * pass sign as 0 to jump relative to current offset the amount prompted * last time we called this routine. */ { static wchar_t in = '\0'; static unsigned long offs = 0x00; unsigned long offst = offset; if (sign) { offs = 0x00; werase (Globals.whelp); wmove (Globals.whelp, 0, 0); wprintw (Globals.whelp, "Offset: 0x%08lX %c 0x", offset, sign); wrefresh (Globals.whelp); while ((in = getch ()) != '\n') { if (!isHexChar (in)) { switch (in) { case BACKSPACE: case CONTROL_H: case KEY_BACKSPACE: case KEY_DC: #ifdef __PDCURSES__ case CTL_BKSP: #endif offs >>= 4; break; case CONTROL_U: offs = 0x00; break; case CONTROL_G: case CONTROL_X: printHelpWindow (); wrefresh (Globals.whelp); move (cursor_y, cursor_x); refresh (); return; default: continue; } } else { /* shift left to make room for new hex digit and or it in least * significant place */ offs <<= 4; offs |= getHexValue (in); } werase (Globals.whelp); wmove (Globals.whelp, 0, 0); wprintw (Globals.whelp, "Offset: 0x%08lX %c 0x%lX", offset, sign, offs); wrefresh (Globals.whelp); } } if (sign) in = sign; if (offs) { if (in == '+') { offst += offs; /* Check for overflow */ if (offst > Globals.filesize) { offst = Globals.filesize; do_beep (); } } else { offst -= offs; /* Check for unsigned underflow */ if (offst > Globals.filesize) { offst = 0x00; do_beep (); } } } cursor_x = mappos (offst & M_0x0F); cursor_y = 1; offset = offst; printStatusWindow (); printHelpWindow (); drawdump (offset); wrefresh (Globals.wmain); wrefresh (Globals.wstatus); wrefresh (Globals.whelp); move (cursor_y, cursor_x); refresh (); } ncurses-hexedit-0.9.7.orig/src/hexedit.h0100644000175000017500000003133606753164566016651 0ustar apocapoc#ifndef HEXEDIT_H #define HEXEDIT_H /* hexedit.h by Adam Rogoyski Temperanc on EFNet irc * Copyright (C) 1998, 1999 Adam Rogoyski * --- GNU General Public License Disclamer --- * 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. */ #ifdef HAVE_CONFIG_H #include "../config.h" #endif #include #ifdef HAVE_NCURSES_H #include #else #ifdef HAVE_CURSES_H #include #endif #endif #include #ifdef HAVE_LIMITS_H #include #endif #ifdef STDC_HEADERS #include #include #endif #include #include #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SYS_IOCTL_H #include #endif #include #include #ifdef HAVE_FCNTL_H #include #endif /* When we push a change on the Undo Stack, this is what type of change * it was. */ #define INSERT 1 #define DELETE 2 #define CHANGE 3 /* Globals.modified takes on 0 if the file is the original (doesn't need * to be saved), 1 if it's modified (needs to be saved), and 2 for * read-only. */ #define MODIFIED 1 #define READ_ONLY 2 /* Globals.print_mode decides what in the text mode part of the screen * is printed. Regular is 7-bit ascii. High ascii is 8-bit ascii. * All print is all characters. */ #define REGULAR_PRINT 1 #define HIGH_ASCII_PRINT 2 #define ALL_PRINT 3 /* These I think are defined in curses as macros but I still use them */ #ifndef __PDCURSES__ #define ALT_V 118 #endif #define BACKSPACE 127 #define CONTROL_A 1 #define CONTROL_B 2 #define CONTROL_C 3 #define CONTROL_D 4 #define CONTROL_E 5 #define CONTROL_F 6 #define CONTROL_G 7 #define CONTROL_H 8 #define CONTROL_I 9 #define CONTROL_L 12 #define CONTROL_N 14 #define CONTROL_O 15 #define CONTROL_P 16 #define CONTROL_R 18 #define CONTROL_T 20 #define CONTROL_U 21 #define CONTROL_V 22 #define CONTROL_W 23 #define CONTROL_X 24 #define CONTROL_Y 25 #define CONTROL_SLASH 31 #define ESCAPE_CHARACTER 27 #define SPACEBAR 32 #define TAB 9 /* Prevent me from typing these in wrong */ #define M_0xFFFFFFF0 0xfffffff0 #define M_0xF0 0xf0 #define M_0x10 0x10 #define M_0x0F 0x0f /* Top and bottom lines of the main window are different depending if * curses is broken or not. */ #define MAIN_HEIGHT (LINES - 2) #define MAIN_TOP_LINE 1 #define MAIN_BOTTOM_LINE (LINES - 3) #define BOTTOM_LINE (LINES - 2) /* Malloc extra bytes so we can do a lot of inserts without realloc */ #define EXTRA_BUF 1024 /* In file selection widget, the filename starts at column 57. */ #define NAME_POS 57 /* Globals.mode, which mode of the editor we are in. They are File * selection widget, normal hex mode, ascii mode (snapshot), and the * calculator. */ #define FILE_MODE 0 #define HEX_MODE 1 #define ASCII_MODE 2 #define CALCULATOR_MODE 3 /* Globals.charset, if we are using ASCII or EBCDIC character set to * display text. */ #define ASCII_CHAR_SET 0 #define EBCDIC_CHAR_SET 1 /* Buffer size is how much we read of the file at a time from disk and * keep in memory (in filebuf). Read buffer is how much we read from * disk with each fread () call. * Buffer size must be greater than read buffer, both must be even. */ #define DEFAULT_BUFFER_SIZE 0x4000 /* 16384 */ #define DEFAULT_READ_BUFFER 0x800 /* 2048 */ /* Functions prototypes for functions used througout */ /* Functions in misc.c */ char * chompWhiteSpace (char *); int cursor_ascii_to_ebcdic (int); void die_horribly (const char * const, const char * const); void do_beep (); void exitProgram (void); void exitSave (int); int getHexValue (wchar_t); char getAsciiValue (wchar_t); void handleInterrupt (int); #ifndef __PDCURSES__ void handleSigwinch (int); #endif int isHexChar (wchar_t); int isprintable (int); int mappos (int); int mapcur (int); void switchModes (void); void usage (char *); /* Functions in init.c */ void init (int, char **); void load_new_file (FILE **); void popup_Error (const char * const, int); char * select_new_file (FILE **); /* Functions in hexkeys.c */ void endKey (void); void handleArrowKeys (wchar_t); void hexMode (wchar_t); void homeKey (void); void pagedown (void); void pageup (void); void tabcursor (int *); /* Functions in edit.c */ void deleteByte (int); void filebuff_modify (unsigned long, unsigned char); wchar_t findEBCDIC (wchar_t); void insertByte (unsigned char, int); void over_write (wchar_t); /* Functions in filebuf.c */ void initbuffer (FILE *, unsigned long, unsigned long); unsigned char filebuffer (unsigned long); unsigned long filebuffer_new_buf (); /* Functions in asciikey.c */ void asciiMode (wchar_t); /* Functions in windows.c and widgets.c */ struct ret_string * hex_string_box (WINDOW *, int, int); void jump_relative_offset (wchar_t); int popupFileSave (void); void popupGotoOffset (long); void popupHelp (void); WINDOW * popupWindow (int, int); void search (int); char * stringBox (WINDOW *, int, int, int, int, char *); /* Functions in print.c */ void drawdump (unsigned long); void printHelpWindow (void); void printStatusWindow (void); void redraw (void); /* Functions in search.c */ struct foundit * boyer_moore_search (unsigned char *, unsigned long, unsigned long, unsigned long); unsigned char bytecmp (const unsigned char *, const unsigned char *, long); /* Functions in undo.c */ void pushUndo (int, unsigned long, unsigned char, unsigned char); void undoLastChange (void); /* Functions in help.c */ void help_initialize (void); void help_print (WINDOW *, int, int); /* Functions in file.c and filekeys.c */ char * fileSelect (void); void statWindow (const char * const); void helpWindow (const char * const); struct FileNames * getDirectory (const char * const); struct FileNames * merge (struct FileNames *, struct FileNames *); struct FileNames * msort (struct FileNames *); void printPage (const struct FileNames *); void file_key_up (int *); void file_key_down (int *, int); void file_redraw (int *); void file_pagedown (int *, int); void file_pageup (int *); void file_home (int *); void file_end (int *, int); /* functions in calc.c */ #define BIN_BOX 1 #define OCT_BOX 2 #define DEC_BOX 3 #define HEX_BOX 4 #define BOX_LEN 64 struct calcEntryBox; void binary_calculator (void); void calcStatWindow (void); void drawEntryBox (WINDOW *, struct calcEntryBox *, int, int, int); void calcDrawBoxes (struct calcEntryBox *, struct calcEntryBox *, struct calcEntryBox *, struct calcEntryBox *, int); void calcNumberKey (struct calcEntryBox *, struct calcEntryBox *, struct calcEntryBox *, struct calcEntryBox *, wchar_t, int); void calcArrowKey (struct calcEntryBox *, struct calcEntryBox *, struct calcEntryBox *, struct calcEntryBox *, wchar_t, int *); void calcBinaryString (struct calcEntryBox *); void calcOctalString (struct calcEntryBox *); void calcDecimalString (struct calcEntryBox *); void calcHexString (struct calcEntryBox *); /* Functions in hash.c */ void clear_hash (); void commit_changes_in_hash (FILE *); void delete_hash_entry (unsigned long); void init_hash (void); void insert_hash_entry (unsigned long, unsigned char); int hash_lookup (unsigned long, unsigned char *); #ifdef MAIN_C unsigned long offset = 0x00; /* where in the file you are */ int position = 0; /* where on the line you are */ int cursor_x = 10; /* cursor tracking in hex mode */ int cursor_y = MAIN_TOP_LINE; int acursor_x = 0; /* cursor tracking in ascii mode */ int acursor_y = 0; int color_term = 0; /* is a color terminal */ unsigned char *filebuf = NULL; /* the file in memory */ int extrabuf = EXTRA_BUF; /* always malloc extra bytes for inserting text */ int *newlines = NULL; /* used in ascii mode, where to start lines */ /* constant strings for printing */ const char * const NOT_ENOUGH_MEMORY = "Not enough memory"; #else extern unsigned long offset; extern int position; extern int cursor_x; extern int cursor_y; extern int acursor_x; extern int acursor_y; extern int color_term; extern unsigned char *filebuf; extern int extrabuf; extern int *newlines; extern const unsigned char EBCDIC[]; extern const unsigned char ASCII_to_EBCDIC[]; extern const char * const NOT_ENOUGH_MEMORY; #endif /* Global structure, keep most global variables here. */ struct { WINDOW *wmain, *wstatus, *whelp; /* three windows used throughout. */ unsigned long filesize; /* size of the file buffer. */ FILE *fp; /* File we are editing. */ const char *filename; /* Name of file we are editing. */ int mode; /* what mode the program is in, such as * file widget, hex, ascii, calculator. */ int modified; /* if the buffer is modified/read-only. */ int tabb; /* are we editing hex or text side. */ int charset; /* ascii or ebcdic character set. */ int spacing; /* byte or word like spacing layout. */ int print_mode; /* print 7-bit text, 8-bit text, or * all text. */ unsigned int buffsize; /* size of buffer read into memory. */ int fullsize; /* is buffsize holding the full buffer. */ int fixed_disk; /* file is a fixed disk. */ unsigned long buf_front; /* current *filebuf in memory is the. */ unsigned long buf_end; /* chunk from offset buf_front through. */ /* buf end. */ int beeping; /* Allow beeping or not. */ int help_msg_count; /* Number of messages in help menu. */ } Globals; struct foundit /* used for returning from searching */ { int flag; unsigned long offset; }; struct ret_string /* used for returning from hexstring box */ { int len; unsigned char *str; }; struct Change /* A node in the ChangeLog stack */ { int type; /* type of change (insert, delete, modify) */ unsigned long offset; /* location of the change */ unsigned char old; /* the previous overwritten value */ unsigned char new; /* the new value */ struct Change *p; /* next change in the list */ }; struct ChangeLog /* Stack of changes to use with undo */ { int s; struct Change *base; struct Change *top; } UndoStack; struct FileNames /* node for linked list of filenames */ { char *filename; struct FileNames *p; }; struct calcEntryBox { char *tokens; char s[BOX_LEN + 1]; int x; int pos_y; int pos_x; union { int i; unsigned int ui; long l; unsigned long ul; } value; }; #endif ncurses-hexedit-0.9.7.orig/gnu/0040777000175000017500000000000006753210663015037 5ustar apocapocncurses-hexedit-0.9.7.orig/gnu/Makefile.in0100644000175000017500000001012006753210663017067 0ustar apocapoc# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : CC = @CC@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ EXTRA_DIST = getopt.h getopt.c getopt1.c mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps gnu/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status tags: TAGS TAGS: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = gnu distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done info-am: info: info-am dvi-am: dvi: dvi-am check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am install-exec-am: install-exec: install-exec-am install-data-am: install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am uninstall-am: uninstall: uninstall-am all-am: Makefile all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-generic mostlyclean-am clean: clean-am distclean-am: distclean-generic clean-am distclean: distclean-am maintainer-clean-am: maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am .PHONY: tags distdir info-am info dvi-am dvi check check-am \ installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ all-redirect all-am all installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ncurses-hexedit-0.9.7.orig/gnu/Makefile.am0100644000175000017500000000005106655117010017051 0ustar apocapocEXTRA_DIST = getopt.h getopt.c getopt1.c ncurses-hexedit-0.9.7.orig/gnu/getopt.h0100644000175000017500000001122106655070362016501 0ustar apocapoc/* 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. 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__ */ #ifndef __cplusplus /* C++ is more pedantic, and demands a full prototype, not this. Hope that stdlib.h has a prototype for `getopt'. */ extern int getopt (); #endif /* __cplusplus */ #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 */ ncurses-hexedit-0.9.7.orig/gnu/getopt.c0100644000175000017500000007254506663334226016515 0ustar apocapoc/* 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. 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. */ /* I added in two braces to remove a compiler warning. * Adam Rogoyski . */ /* 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 #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. */ /* Defined in getopt_init.c */ extern char *__getopt_nonoption_flags; static int nonoption_flags_max_len; 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 __attribute__ ((unused)) store_args_and_env (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; } # ifdef text_set_element text_set_element (__libc_subinit, store_args_and_env); # endif /* text_set_element */ # define SWAP_FLAGS(ch1, ch2) \ if (nonoption_flags_len > 0) \ { \ char __tmp = __getopt_nonoption_flags[ch1]; \ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ __getopt_nonoption_flags[ch2] = __tmp; \ } #else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) #endif /* _LIBC */ /* 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. */ #ifdef _LIBC /* First make sure the handling of the `__getopt_nonoption_flags' string can work normally. Our top argument must be in the range of the string. */ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { /* We must extend the array. The user plays games with us and presents new arguments. */ char *new_str = malloc (top + 1); if (new_str == NULL) nonoption_flags_len = nonoption_flags_max_len = 0; else { memset (__mempcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len), '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } } #endif 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; SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); } /* 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; SWAP_FLAGS (bottom + i, middle + i); } /* 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; 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) { if (nonoption_flags_max_len == 0) { if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0') nonoption_flags_max_len = -1; else { const char *orig_str = __getopt_nonoption_flags; int len = nonoption_flags_max_len = strlen (orig_str); if (nonoption_flags_max_len < argc) nonoption_flags_max_len = argc; __getopt_nonoption_flags = (char *) malloc (nonoption_flags_max_len); if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), '\0', nonoption_flags_max_len - len); } } nonoption_flags_len = nonoption_flags_max_len; } 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 (optind == 0 || !__getopt_initialized) { if (optind == 0) optind = 1; /* Don't scan ARGV[0], the program name. */ optstring = _getopt_initialize (argc, argv, optstring); __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 \ && __getopt_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 */ ncurses-hexedit-0.9.7.orig/gnu/getopt1.c0100644000175000017500000001070406655070362016562 0ustar apocapoc/* 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. 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 */