diff options
-rw-r--r-- | AUTHORS | 0 | ||||
-rw-r--r-- | COPYING | 348 | ||||
-rw-r--r-- | ChangeLog.old | 746 | ||||
-rw-r--r-- | Config.demo | 401 | ||||
-rw-r--r-- | Hacking | 67 | ||||
-rw-r--r-- | INSTALL | 229 | ||||
-rw-r--r-- | Makefile.am | 20 | ||||
-rw-r--r-- | Makefile.in | 658 | ||||
-rw-r--r-- | NEWS | 0 | ||||
-rw-r--r-- | README | 140 | ||||
-rw-r--r-- | README.follow | 18 | ||||
-rw-r--r-- | README.term | 26 | ||||
-rw-r--r-- | TODO | 46 | ||||
-rw-r--r-- | aclocal.m4 | 1020 | ||||
-rw-r--r-- | beam.c | 438 | ||||
-rw-r--r-- | beam.h | 17 | ||||
-rw-r--r-- | catrw.c | 39 | ||||
-rw-r--r-- | cmd.c | 2464 | ||||
-rw-r--r-- | cmd.h | 21 | ||||
-rw-r--r-- | cmd2.c | 1665 | ||||
-rw-r--r-- | cmd2.h | 32 | ||||
-rwxr-xr-x | configure | 5415 | ||||
-rw-r--r-- | configure.in | 49 | ||||
-rw-r--r-- | debian/changelog | 9 | ||||
-rw-r--r-- | debian/control | 12 | ||||
-rwxr-xr-x | debian/rules | 78 | ||||
-rw-r--r-- | defines.h | 367 | ||||
-rwxr-xr-x | depcomp | 464 | ||||
-rw-r--r-- | edit.c | 886 | ||||
-rw-r--r-- | edit.h | 75 | ||||
-rw-r--r-- | eval.c | 1450 | ||||
-rw-r--r-- | eval.h | 58 | ||||
-rw-r--r-- | follow.c | 166 | ||||
-rwxr-xr-x | install-sh | 294 | ||||
-rw-r--r-- | list.c | 679 | ||||
-rw-r--r-- | list.h | 47 | ||||
-rw-r--r-- | log.c | 322 | ||||
-rw-r--r-- | log.h | 22 | ||||
-rw-r--r-- | main.c | 1995 | ||||
-rw-r--r-- | main.h | 117 | ||||
-rw-r--r-- | map.c | 193 | ||||
-rw-r--r-- | map.h | 15 | ||||
-rwxr-xr-x | missing | 336 | ||||
-rwxr-xr-x | mkinstalldirs | 111 | ||||
-rw-r--r-- | movie.c | 93 | ||||
-rw-r--r-- | muc.c | 298 | ||||
-rw-r--r-- | plugtest.c | 18 | ||||
-rw-r--r-- | powwow.6 | 115 | ||||
-rw-r--r-- | powwow.doc | 2152 | ||||
-rw-r--r-- | powwow.help | 553 | ||||
-rw-r--r-- | ptr.c | 578 | ||||
-rw-r--r-- | ptr.h | 68 | ||||
-rw-r--r-- | tcp.c | 1022 | ||||
-rw-r--r-- | tcp.h | 78 | ||||
-rw-r--r-- | tty.c | 774 | ||||
-rw-r--r-- | tty.h | 52 | ||||
-rw-r--r-- | utils.c | 1279 | ||||
-rw-r--r-- | utils.h | 48 |
58 files changed, 28683 insertions, 0 deletions
@@ -0,0 +1,348 @@ + + The GNU General Public License (GPL) below is copyrighted by the + Free Software Foundation, but the instance of code that it refers to + (the program powwow) is copyrighted by me and others who actually wrote it. + + Massimiliano Ghilardi + +------------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief 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., 675 Mass Ave, Cambridge, MA 02139, 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. diff --git a/ChangeLog.old b/ChangeLog.old new file mode 100644 index 0000000..d8a83e0 --- /dev/null +++ b/ChangeLog.old @@ -0,0 +1,746 @@ +2004-07-01 12:05 bpk + + * main.c: Bug/enhancement fix, # followed by nothing is now + ignored, would be nice to kill to end of line though + +2004-07-01 10:54 bpk + + * Makefile, configure.in, utils.c: Added multiline support for + reading from files, using \ at end of line + +2004-07-01 10:52 bpk + + * Makefile, Makefile.am, cmd.c, cmd.h, main.c, plugtest.c: Added + #module support and a test plugin + +2004-07-01 10:46 bpk + + * Makefile.am, aclocal.m4, configure.in, muc.c: Addec muc movie + player and autoconf support + +2004-07-01 10:42 bpk + + * Initial import of stock powwow 1.2.5 + +Changes from 1.2.4 to 1.2.5 (Massimiliano Ghilardi, ...) 21 Jan 2002 + * Added append-mode to #capture: use #capture >file-name + * Cleaned #spawned commands interface: text they print on + standard output *MUST* terminate with a newline ('\n') + in order for powwow to execute it. + * Fixed missing #include <time.h> in main.h. + * Fixed broken matching of #mark patterns starting with $ + * Added the following user-contributed patches: + * Put also 1-char lines into history; + * Do not capture/movie data coming from spawned commands; + * Fixed a bug in command parser. + +Changes from 1.2.3 to 1.2.4 (Massimiliano Ghilardi) 24 May 2000 + * Added support for IAC GA as end-of-prompt marker. + * Added #request [prompt][editor][all] + * Fixed missing/slow prompt redrawing under some circumstances + if #isprompt <number> was used. + +Changes from 1.2.2 to 1.2.3 (Massimiliano Ghilardi) 18 Jan 2000 + * Fixed `#spawn' command that was completely screwed up. + Also fixed CTRL-C not to kill spawned commands. + * Sending/receiving data to/from spawned commands erased the prompt + instead of reprinting it. Fixed. + (If you don't like powwow to show the prompt before executing + lines from spawned commands, set #option +compact) + +Changes from 1.2.1 to 1.2.2 (Massimiliano Ghilardi) 10 May 1999 + * Fixed `#delim custom' to accept whatever character as delimiters. + Previously stopped before the first word-delimiting char (argh!) + * Fixed screen corruption when doing some editing functions + (&del-word-right, &del-word-left, &complete-word, &complete-line, + parentheses flashing) while data comes from the MUD. + * Fixed a line redrawing bug when inserting chars on terminals + with VT100-like wrapglitch. + * Fixed SEGFAULT on #send, #emulate, #exe of a numeric expression. + * Fixed stupid SEGFAULT when cancelling an editing session. + * Fixed sending/receiving latin-1 '\377' (ASCII char 255) as IAC IAC + to conform telnet protocol, both directly and inside MPI messages. + * Fixed matching #actions, #prompts and #marks on MUD data splitted + into multiple fragments. + * Fixed line length calculation when receiving '\r' in the middle + of a line. + * Fixed extra prompt redrawing in #option +compact mode. + * Added #option sendsize and #option autoclear. + Changed default not to send window size upon connecting. + (if the MUD asks it, the window size is sent anyway) + Use #option +sendsize to automatically send it when you connect. + * Added command #rawsend. + * Removed bits of ANSI code giving problems + with really picky non-ANSI compilers + +Changes from 1.2.0 to 1.2.1 (Massimiliano Ghilardi) 20 Nov 1998 + * Fixed a typo in Makefile. + * Reversed order of saved #history lines. + * Fixed out-of-bound array accesses in tcp_find() and tcp_show() + which could give SEGFAULT on #connect, #snoop and #zap. + * Fixed buggy loop in saving #history in definition file that could + create a huge temporary file, filling the filesystem. + * Fixed sporadic SEGFAULT when hitting backspace and some other + editing keys. + * Math operator `?' could freeze due to buggy code. + Systems providing GNU memmem() didn't experience the problem + as it was used instead of my replacement code. + * Enhanced support for terminals with VT100-like wrapglitch: + on them, the rightmost character of every line is used too. + * Fixed wrapping in #printing strings containing ASCII chars > 127 + when #option wrap is on. + * Fixed incorrect drawing of prompt and command line under some + circumstances. + * Fixed wrong wrapping of lines immediately after the prompt + in #option +wrap mode. + * Removed extra newlines sent after each line in `#send <filename' + and `send !command'. + * Fixed a few off-by-one errors causing corruption in #movie/#capture + and (reprint) buffers. + * Powwow now discards all \r received immediately before or after \n, + to avoid troubles when strange data comes just before the prompt. + * Changed MPI key to `unsigned int' because MUME uses a 32 bit + unsigned value for it. + * Cleaned up remote file editing not to leave stale files in /tmp. + * Cleaned up multiple connections support: + Fixed spurious `#too many open connections' errors. + Fixed prompt drawing glitches when getting data from subsidiary + connections. + +Changes from 1.1.7 to 1.2.0 (Massimiliano Ghilardi) 05 Oct 1998 + * Copyright change. Powwow is now GPL-ed. + * Version number bump. I hope there aren't many bugs left. + If you are coming from 1.0.x versions, read this file and powwow.doc + carefully, many things have changed! + * Fixed double-newline printing after each line if #option +wrap + was set. + * Suppressed useless reprinting of files sent back to MUD + using MUME remote editing protocol. + * Updated a few details in docs. + * Some old compilers choked on bits of ANSI code. Fixed. + * Fixed extra newline after prompt in #movie and #capture + when #setvar buffer is not zero. + * Fixed extra \r at beginning of a line under rare circumstances. + * #delim now unescapes the custom delimeters. + * Added missing close() when remote host closes connection. + * Rewrote the code to merge lines received in two (or more) fragments. + * Added `#help warranty' and `#help copyright' to conform GPL :-/ + +Changes from 1.1.6 to 1.1.7 (Massimiliano Ghilardi) 15 Sep 1998 + * Changed meaning and effect of #prompt and #isprompt. + If you used them, re-read their docs in powwow.doc! + * Alias names containing spaces are now rejected too. + Relaxed rules a little, unbalanced () {} or "" + now just print a warning instead of causing an error. + * Added #option reprint. + * Old #prompts were not removed on #load. fixed. + * Fixed SEGFAULT when chaining very long strings: + #("foo..." + "bar...") + * Fixed small compiling problems on some platforms. + * Fixed an off-by-one error in math operator >: + * Fixed math operator `=' bug on copying empty strings. + * Fixed a crashy bug in #reset var. + * Fixed some quirks in unescaping strings: + ending backslashes caused SEGFAULT, + sequences like \\\``` were unescaped incorrectly. + * Fixed incorrect code in #mark and #action that + mismatched patterns containing two or more wildcards. + +Changes from 1.1.5 to 1.1.6 (Massimiliano Ghilardi) 03 Sep 1998 + * Added circular backbuffer for #capture and #movie. + Can be enabled/disabled/resized with #setvar buffer. + * Sanitized aliases: powwow now rejects alias names containing + unbalanced special chars ""(){} . Example: + #alias (=#print is illegal, while + #alias "("=#print is ok. + #alias {}=#print is ok, + #alias \\{=#print is ok too as it matches \{ and _not_ { + * Removed a redundant alias unescaping. If #alias foo=\\bar + then `foo' now sends `\bar' instead of `bar'. + * Fixed a compatibility problem when reading #binds of new savefiles + using old versions of powwow. + * Fixed some problems with #var on numbered variables. + * Fixed #internal error, selflookup_sortednode() failed! + that affected 1.1.5 + * Fixed SEGFAULT upon #exe \; (introduced in 1.1.5). + * When getting data from the MUD after a prompt which set #isprompt + the data is now printed as a separate line even if it doesn't start + with a newline. Helps turning things like + * HP:Fine>You hit the wolf's head hard. + into + * HP:Fine> + You hit the wolf's head hard. + Anyway, such data has _always_ been considered separate + from the prompt if it set #isprompt, i.e. #action patterns like + "^You hit the wolf" already worked in the above case. + +Changes from 1.1.4 to 1.1.5 (Massimiliano Ghilardi) 30 Aug 1998 + * Massive code cleanup. + * Finished removing size limits on strings, text lines and variables. + * Renamed `#settimer' as `#setvar timer' and `#lines' as `#setvar lines' + Added `#setvar mem' to set/edit/remove length limit on text/strings. + * Powwow now stops command execution after any error. + * #key now works also with editing keys. + * Added #keyedit command. "#keyedit &prev-line" runs + the editing function `&prev-line' and so on. + * Added "&insert-string <string>" editing function. + * Added #mark ^pattern, which matches only at line start. + * Decreased CPU usage when/after a lot of variables, aliases or marks + are created. + * Added `*' and `*=' math operator for strings. + * Fixed math operators ^^=, ||= and &&= to always return 0 or 1. + * Fixed SEGFAULT when creating more than 100 variables. + (bug introduced in 1.1.0) + * Fixed SEGFAULT when realloc()ing very big strings. + * Fixed memory leaks when running out of memory. + * Fixed escaping/printing of nasty strings like + backslash + control char. + * Fixed some redrawing glitches on very long input lines. + Input lines bigger than the whole window are still not drawn + correctly. Same problem on prompts longer than a line. + * Fixed #prompts to fully work also on prompts received inside + a set of newline-terminated lines. + * Documented #prompt, #capture and #movie to work only for + the main MUD connection + +Changes from 1.1.3 to 1.1.4 (Massimiliano Ghilardi) 23 Jul 1998 + * Renamed `movie_play' to `movie'. Will do the replay if invoked as + `movie_play' and will convert to ASCII if invoked as `movie2ascii' + * Fixed a 1.1.1 bug that could cause a lot of missed binds. + * Finished adding ANSI prototypes. Renamed some files and remixed + some code in the process. + * Removed -DUSE_TERMIO. If you used it, no problem. + If you didn't use it, you must now add -DUSE_SGTTY. + * Fixed a few compiling problems on OSF1 and other systems + with really annoying compilers. + * Fixed missing sig_oneshot on systems without SA_ONESHOT + * Fixed input of chars with high bit set (again). + +Changes from 1.1.2 to 1.1.3 (Massimiliano Ghilardi) 21 Jul 1998 + * Variable names are now expressions too. This means that + @("foo"+"bar") is the variable @foobar. + * Added `just in time' substitution: ${varname} @{varname} and #{expr} + Not yet implemented for regexp patterns, sorry. + This introduces a subtle incompatibility with older versions, + as now also text coming from $n substitution gets unescaped. + Sorry again. (see powwow.doc for details). + * #action and #prompt did not work when using an expression + as pattern. Now fixed. + * Fixed small bug in anonymous actions. Someone still using them? + * powwow_help renamed powwow.help + * Fixed a bug in #alias: $1..$9 all contained the first word ($1) + * Fixed math operators . : .? :? .< .> <. >. :< :> <: >: which + segfaulted on empty strings (bug introduced in 1.1.0) + * Made SIGINT signal handler non-permanent to allow interrupting + system calls like connect(). Partially reverses the change in 0.9.3 + * Undone a change Gustav made in 0.9.3: now #connect with no args + always lists the open connections. To open a new connection you must + give at least one argument, for example #connect main. + * Changed edit function &redraw-line not to clear prompt. + Use &redraw-line-noprompt to get the old behaviour. + * Added #movie command to record all output from the MUD + and local commands to a file, adding timestamps to allow replay + at correct speed. Also added `movie_play' standalone program + to actually do the replay. + +Changes from 1.1.1 to 1.1.2 (Massimiliano Ghilardi) 16 Jun 1998 + * The wildcard `$' now correctly matches single words only + both in #actions and in #marks. + It was (again!) matching also multiple words like `&' + * Fixed up attr and noattr math operators, which broke in 1.1.0 + * Added workaround for buggy terminals which create empty lines with + coloured background when using #hilite <whatever> on <colour>. + Must compile with -DBUG_ANSI to enable it. + +Changes from 1.1.0 to 1.1.1 (Massimiliano Ghilardi) 11 Jun 1998 + * Added some changes from 1.0.1 that didn't go in 1.1.0. + The 1.0.x and the 1.1.x trees are indipendent... + * Wrote a memmem() replacement for systems that don't have it. + * Decreased CPU usage when receiving lots of text from the terminal + (for example using cut-n-paste) + * Continued adding ANSI prototypes. + +Changes from 1.0.0 to 1.1.0 (Massimiliano Ghilardi) 20 May 1998 + * Splitted 1.0.x and 1.1.x source trees. + * Started adding ANSI function prototypes. + Old K&R compilers still work. + * Removed all size limits in all strings, text lines and variables. + Also allowed '\0' (ASCII zero) in strings. + It was a _huge_ task! Probably messed up all and everything. + * Side effect of the above: lines of arbitrary length received from + the MUD should now work perfectly (at least as long as you have + enough memory) + +Changes from 1.0.0 to 1.0.1 (Massimiliano Ghilardi) 18 May 1998 + * Changed name of some files (Changelog, Hacking, Compile.how, + Config.demo) + * Fixed #capture and #record to save text from main connection only. + * Fixed a buffer overrun in $last_line when receiving lines longer + than 1024 chars. Hopefully lines up to 4095 chars will now work. + * Fixed message "Creating %s" when creating a new definition file. + * Added `catrw' standalone mini-program for splitting powwow output + in multiple windows (quick tutorial in powwow.doc, section #write) + * Added #rebindall and #rebindALL + +Changes from 0.9.9 to 1.0.0 (Massimiliano Ghilardi) 13 May 1998 + * Disabled NAGLE for tcp connections (set TCP_NODELAY option) + which should hopefully increase performance during lossy conditions + (idea and code contributed by Finne Arne Gangstad) + * Cleaned up error handling. Powwow tries really hard to report + any system call error, quitting only when there is really no hope. + Anyway, if you get a '#system call error' message, you should + seriously consider quitting as soon as possible since either + the connection is messed up or your system is running + out of resources. + * Removed extra newline after prompt bug when in #option -compact mode, + introduced in 0.9.7 + * Fixed $last_line to contain last non-empty line from the MUD. + * Updated config.demo with definitions for time-inside-prompt + and other things. + +Changes from 0.9.8 to 0.9.9 (Massimiliano Ghilardi) 12 May 1998 + * Changed rx.h to regex.h in includes + * Fixed behaviour on prompts and lines received in multiple packets: + 0.9.7 and 0.9.8 sometimes print garbage. + * Added some flush()es in the code to cope with the new + terminal I/O buffering. + +Changes from 0.9.7 to 0.9.8 (Massimiliano Ghilardi) 11 May 1998 + * Fixed compile problems on AIX (got out of sync). + * Fixed a stupid bug that caused all actions to be regexp + (introduced in 0.9.7) + * Introduced a more efficient terminal I/O buffering. + +Changes from 0.9.6 to 0.9.7 (Massimiliano Ghilardi) 11 May 1998 + * Increased stability when receiving extremely long lines (>1024 bytes) + The fix is only partial, powwow can still crash on lines slightly + shorter than 4096 bytes when a lot of #marks are used. + * Cleaned up the names of various #defines + In particular, USETERMIO is now USE_TERMIO and + TELNETBUG is now BUG_TELNET + * Added #option autoprint, to automatically print lines matched + by #actions. + * Added #spawn command. + * Added #prompt command. Just like #action, but matches both on + prompts and on normal text. + * #actions now work differently on prompts: + prompts are not matched immediately against #actions, + but only after a \n arrives from the MUD, just in case they are + actually normal lines received in multiple packets and not prompts. + + Thanks to the this change, powwow behaves better on lines received + in two (or more) packets. + See the file powwow.doc, section `#prompt' for the gory details. + +Changes from 0.9.5 to 0.9.6 + (Gustav Hållberg, Massimiliano Ghilardi) 16 Oct 1997 + * Fixed a nasty security hole in MPI messages + * Fixed handling of \; at the end of a command + * Fixed some other problems: + short messages from MUD could interfere with remote editing, + #bind escape sequences containing \0 were incorrectly printed/saved + +Changes from 0.9.4 to 0.9.5 + (Gustav Hållberg, Massimiliano Ghilardi) 18 Sep 1997 + * Continued code cleanup + * Allowed aliases starting with `#' + * Removed #speedwalk, #info, #echo, #keyecho, #compact and #debug + and turned them into #options: `#option echo' and so on. + For compatibility, `#echo' is aliased to `#option echo' and so on. + * Fixed a dangerous bug making cursor jump to start of typed text + when receiving a line that wraps. The bug appeared in 0.9.4, + so blame Gustav ;) + * Fixed an old bug making powwow sometimes miss a bind + * Made the command from a bound key appear with `#hilite' setting + * Made a DEFAULT_HELP_DIR define in powwow.c + * Changed to from ' ' to ` ' in some messages + +Changes from 0.9.3 to 0.9.4 (Massimiliano Ghilardi) 04 Sep 1997 + * Included all the huge changes made by Gustav Hållberg: + I really have no time to double-check them all. + If something works in 0.9.2 but is broken in 0.9.4, + you know who to bother :) + * Small esthetic changes in the source, no effects on executable + * Changed identifier for regexp #actions from ']' to '%' + +Changes from 0.9.2 to 0.9.3 (Gustav Hållberg) 11 Aug 1997 + * Fixed so packets ending with \r*\n\r* set promptstr to "" + * Made all signal handlers permanent (sig_permanent) + * Debugged and reinstalled #option (it was commented out for some + obscure reason (Massimiliano: I never finished it...)), + allowing storage of command history and word + completions in the savefile. Added the 'exit' option to allow + powwow to autoexit when the last connection closes + * #echo, #info, #wrap and #debug now get saved in the savefile + * Made repetitive use of &complete-word and &complete-line cycle + through possible completions + * Made a memory-safe strdup (called str_dup) + * When starting a child viewer/editor, that process' TITLE + environment variable is set to something appropriate (?) + * Regular expressions (Extended POSIX regexp) + available for actions; uses GNU rx. + * Actions with label "" forbidden + * Added the #delim command to change word delimeter mode + * Whenever main_conn changes permanently, linemode is set to 0 and + promptstr to "" + * Fixed a crashy bug in the >: operator + * Fixed the notorious extra-space-on-insert bug (both 'ic' and 'im' + shall NOT be sent if you want to insert something) and a VT100 + mode bug while I was feeling creative + * Made the local editing protocol respect prompts (i.e. they get + rewritten after protocol messages are shown). After texts are sent + back to the mud, the output buffer is flushed (no more pressing + ENTER after you've stopped editing!) + * Fixed a few bugs in #mark; pattern "&" doesn't crash anymore. + Patterns with consecutive wildcards never worked, so I forbade them. + It could be implemented, but I hardly think it's worth it + * Added the ANSIBUG compiler directive to fix the bug in some terms + that show new lines in the current output attrib (screws #mark e.g.) + * Made '#connect' without parameters try to open a connection + titled 'main' to 'hostname' (if specified) if no conns are open. + The initstr from #init will be used in this case + * Added &transpose-words, &upcase-word and &downcase-word (defaults + to M-t, M-u and M-l). Repetition of the latter two changes case + of the whole line + * Changed default key names to be more emacs-like (C-b, Ret etc) + * Made #host get written to the savefile iff *hostname != 0, and + if powwow is started as 'powwow filename', without any #host in + the file, #init is ran immediately + * Fixed a bug in cmd_print() that didn't cope with $0 not being set + * Allowed \0 to be part of a bound key's escape sequence. New format + for #bind allows octal \012 be part of the string representation + of the esc seq (chars with high bit set get saved in octal now) + * Made permanent variables $last_line and $prompt + * Made "#var" without arguments list all defined named variables + +Changes from 0.9.1 to 0.9.2 (Massimiliano Ghilardi) 04 Jun 1997 + * Added #keyecho command toggle echo of bound keys. + Previously, this was controlled by the generic #echo command. + * CTRL-C can now safely interrupt blocking commands like + #connect and #bind. + * POWWOWDIR is now used correctly in all cases: + not only when starting powwow with a filename but also when using + #load, #save or #file + * Changed #file syntax. Now you need = before the save-file. + Putting = alone undefines the save-file and disables autosave + when you quit. + * Cleaned up naming conventions: 'session' means editing session + while 'connection' means remote host connection. + * Fixed handling of 8 bit chars typed from keyboard + * Fixed '#reset bind' which was not reloading cursor binds + * Fixed remote host name spelling in files generated by #save. + * Fixed a bug that caused powwow to crash when failing to + connect to a mud. + +Changes from 0.9.0 to 0.9.1 (Massimiliano Ghilardi) 31 Apr 1997 + * New connections opened with #connect are set as main connection. + You will have to switch back manually if you need it. + * Cleaned up multiple connection support. Better error handling. + * Cleaned up TELNETBUG support. I did not use it recently, + and was out of sync. + * Enhanced #bind syntax: now you can specify control codes + sent by your keyboard directly from the command line. + As a side effect, #exe <file now works also on files created + with #save + * Added #rebind command. Changes the control codes associated + to a key binding without changing its name or its effect. + * Added #quit command. + +Changes from 0.8.6 to 0.9.0 (Massimiliano Ghilardi) 29 Apr 1997 + * Added FreeBSD support in make_it (thanks to Jaako Knuutila) + * Cleaned up terminal interface. + * #save and #load now accept a filename as argument + * Handle SIGQUIT as SIGINT: use to stop long or infinite loops + * Now can switch main connection on the fly with ##<connection-name> + * Allow powwow #commands also on subsidiary connections + +Changes from 0.8.5 to 0.8.6 (Paolo Gatti, Massimiliano Ghilardi) 28 Apr 1997 + * Finally and definitively changed the name to powwow. + Previously, sometimes the program was referred to as pow-wow + and sometimes as powwow, generating confusion. + * Partial port of powwow to AmigaDOS. Incomplete, will NOT compile. + Paolo abandoned the project, so maybe it will just never compile. + * Fixed a bug causing extra new-lines on screen when powwow received + strange data sequences like ASCII codes 10 13 + (on DOS, new-line is 13 10, while on UN*X is 10 only) + * Fixed a bug in #mark not matching correctly the wildcard $ + * Powwow crashed #loading files containing empty lines. Fixed + +Changes from 0.8.4 to 0.8.5 (Massimiliano Ghilardi) + * Fixed a bug introduced by updating files from cancan 2.6.0b sources + (happened in version 0.8.3): powwow was sendind TWO new-line chars + instead of one immediately after every password. + +Changes from 0.8.3 to 0.8.4 (Massimiliano Ghilardi) + * Fixed (I hope definitively) an ancient bug: + some lines were sometimes printed twice or not printed at all. + It is still the bug that appeared in version 0.4... + The bug was almost fixed in version 0.8b but reintroduced in 0.8.3 + +Changes from 0.8b to 0.8.3 (Massimiliano Ghilardi) + * Slightly changed version numbering (0.8.3 instead of 0.8c) + * #save and #load are now safe even in case of errors + (example: `disk full') + * hitting a #bind-ed key now echoes the corresponding command + only if #echo is on + * updated term.c (terminal handling code) and tel.c (telnet code) + with files from cancan 2.6.0b (yes, I shamelessly copied them) + No external changes anyway (unless I introduced some bugs) + note: beam.c NOT updated/copied + * 'follow' standalone mini-program added (see README.follow) + * #key is now explicitly stated not to support editing keys. + They cannot be added cleanly without rewriting the line-editing code + from scratch ('#key up' and '#key return' give the biggest problems) + and I don't have the time for that right now + * blink attribute added + * Now can use multiple attributes in #mark, #hilite, #color + example: #mark *An Orc*=inverse bold blue on red + Note: bold, blink, underline and inverse must appear BEFORE colors + * fixed some bugs: + * changed "VERSION" to "POWWOW_VERSION" in powwow.c. + It seems some compilers use VERSION for internal purposes... + * #wrap mode was discarding lines containing only escape sequences + (example: color codes coming from the MUD) + * #hilite was restoring hilight attributes after EVERY line + coming from the MUD + * self-recursive aliases were causing crash after 100 loops instead + of trapping error and reporting '#error: stack overflow' + (not always, and not on all OS). Now they are completely safe. + Note: they still eat 1MB of memory (10K per loop - released + immediately after) + +Changes from 0.8a to 0.8b (Massimiliano Ghilardi) + * hexadecimal numbers added (and in any other base) + can be used only from calculator, prefix is # + * '#write' command added + * fixed a bug with #nice affecting #load + now #load places actions/marks in memory in the same order as + config file, indipendently from #nice value. + Also, default #nice changes from 1 (top) to 0 (bottom) + * fixed a bug in #save that sometimes caused crashes and destroyed + config file + * now word completion (issued with TAB key) checks + word completion list _before_ built-in commands + +Changes from 0.8 to 0.8a (Massimiliano Ghilardi) + * remind me NEVER to work on Sunday, because I filled version 0.8 with + these bugs (now fixed): + - some debugging stuff was not deleted from official version + - deleting a named variable could cause a crash + - creating a named variable was giving a message even while reading + a definition file + - #settimer was not working due to a change in version 0.8 + - forgot to say that #map variable was added + * #rand, #map and #timer variables renamed rand, map and timer + (removed the #) - sorry for the change but it was necessary. + * removed limit of 50 named variables of each kind (numeric and string) + now the only limit is the memory available + +Changes from 0.7b to 0.8 (Massimiliano Ghilardi) + * #mark now accepts wildcards ($ for a single word, & for a string) + * named variables are now supported + * #assign renamed #var (I never liked the name 'assign' ...) + also, #var can be used to delete variables from memory + * #nice command added. It sets/shows priority of new actions/marks + +Changes from 0.7a to 0.7b (Finn Arne Gangstad) + * make_it now also works for sunos 5.x, irix 5.x and hpux 9.x + +Changes from 0.7 to 0.7a (Massimiliano Ghilardi) + * fixed a _HUGE_ hole in security: $n in actions was matching also ; + (but not spaces) so robotic actions gave a chance to other players + to force you (*AAARGH*) + * startup changed: now powwow does not clear screen when executed, + but jumps to the end of screen (this avoids mess in the first lines + you get from the mud) + +Changes from 0.6d to 0.7 (Massimiliano Ghilardi) + * finally fixed the unpleasant bug of auto-wrap making confusion when + receiving lines that contain escape sequences + (the fix in 0.6d was far from satisfactory) + * high-intensity colours added (for the terminals that support them) + * #assign can be used to put the contents of a variable on input line + * number of global variables raised to 50, max lenght of string + variables raised to 512 bytes + * #settimer command added, '#time' variable changed into '#timer' + * fixed a bug: math operator >= was wrong, worked as <= + +Changes from 0.6c to 0.6d (Massimiliano Ghilardi) + * break key now is also used to stop command-parsing. Useful to stop + long or infinite loops without exiting from powwow. + * #stop command added. It disables all active delayed commands. + * #mark now works also with prompts (was not implemented before) + * fixed an ancient bug with #action not working on lines splitted into + multiple data packets by telnet. + * fixed two other ancient bugs: + #mark not working on auto-wrapped words + and auto-wrap making confusion when receiving lines that contain + escape sequences (only partially fixed to be honest) + * Now the unescaping is performed ALSO on quoted strings, when powwow + evaluates them. Thus there might be to update your definition file + if it contains escapes placed in strings. + +Changes from 0.6b to 0.6c (Massimiliano Ghilardi) + * If you have problems with #rand, random() and srandom() (typically + your compiler is unable to find the functions) you can define + NO_RANDOM at compile time. (temporary solution) + * Now also editing keys can be redefined + * #assign command added (same syntax of #print, #send and #exe) + * Now you can specify start and end line of a file or output of Bourne + shell command when using #print, #send, #exe, #emulate or #assign + * #debug command added (try it in test mode...) + * Now #echo, #info, #speedwalk and #debug also accept 'on' or 'off' + +Changes from 0.6 to 0.6b (Massimiliano Ghilardi) + * #emulate command added (same syntax of #print, #send and #exe) + * now also prompts can be intercepted by #actions + (but cannot be 'gagged') + * powwow can run in test-mode without being connected to a MUD + +Changes from 0.5 to 0.6 (Massimiliano Ghilardi) + * more debug work + * #exe, #send and #print extended to use shell commands and files + Also, #send replaces #read + * #time variable added + * #rand function added + * #connect now supports a different remote host for each connection + (i.e. you can now play on different MUDs with the same invocation + of powwow) + + Ideas coming from Cancan 2.5.1c and implemented on powwow 0.6: + + * output to the remote host is buffered up and sent all at once in the + main loop, to reduce the number of network packets. Long aliases + might benefit from this, as would repeated commands (#10 buy bread). + * #help now works on commands. A help file is needed and provided. + * new command: #record, records lines you type in a file + * source changed so path for helpfile is taken from environment + variable POWWOWHELP (if this variable is not defined, powwow looks + in current directory) + * to print the message of the day, must define MOTDFILE in compiling + with the name (and complete path) of the file containing the message + * Now compiles on BSD/386 as well, automatically detected by make_it + +Changes from 0.4 to 0.5 (Massimiliano Ghilardi) + * Heavy debug work, since 0.4 was an alpha version + (it is not a good idea to place here the huge list of bugs fixed...) + * added #history to list/execute commands in history + Note: #history commands are not placed in history... + * now internal commands can be abbreviated, for example #al can be used + istead of #alias. However, internal commands are still completed + using TAB + +Changes from Cancan 2.5.0b to powwow 0.4 (Massimiliano Ghilardi) + * Inline calculator, with both global and local variables, and C-like + syntax + * added commands #(), #print, #send, #exe to use inline calculator + * added commands #if-#else, #for and #while. + * added #key, #save, #load, #save, #lines, #info, #echo, #compact, + #net, #clock, #time + * added #in and #at to define/edit delayed commands + * #mark and all attrib-related commands now accept also the attribute + 'none' + * #marks and #actions now are not automatically sorted (to sort them, + define SORT in compiling). #aliases and #binds instead are always + sorted. + * #aliases can be self-recursive now (it is potentially dangerous, + powwow will not enter a very long - but not infinite - loop) + * Must not escape ';' anymore to place multiple commands in #alias, + #action or #bind. Instead, multiple commands must be surrounded by + braces, { and } + * #action changed syntax (not need double quotes anymore, but need one + of > < + - = before label) See powwow.doc for details + Lines matched with #action are not printed on screen automatically, + must use a #print to echo them + * #gag is suppressed (not needed anymore), and #add is now a command + * Escaping technique changed. Now unescaping '\\\#' gives '\\#' (i.e. + remove one \ each time), and you can also escape \, in this way: + \` gives \ alone, \`` gives \` and so on. So for example, if you + want to place a \ at the end of an #action pattern, you must write + \` , to avoid escaping the = after the pattern + * Some bugs of Cancan fixed (small things, expecially wrapping) + +Changes from 2.5.0a to 2.5.0b (Finn Arne Gangstad) + * Fixed bug with client aborting when window was resized. + +Changes from 2.5.0 to 2.5.0a (Finn Arne Gangstad) + * Various tweaks to make it compile on most systems. + +Changes from 2.4.4 to 2.5.0 (Mattias Engdegard) + * the length of the prompt is now correctly calculated + even if it contains escape sequences (for muds with coloured prompt). + * built-in commands are always completed with tab and aren't stored in + the word list + * #hilite and #mark now accept general attributes: ansi colours and + bold, underline, inverse. + * the #action command has changed syntax; now double quotes are + required around the pattern, but they can be named. Actions can be + turned on and off. + * the keydefs list contains all keyboard bindings. The #bind command + can define new keys. + * the #alias, #action, #bind and #mark commands can now put a + definition line in the input buffer for easy editing. + The keys M-p and M-n are no longer used. + * some new files, new source module discipline with external + declarations only in header files. + * added the file `Hacking' with some advice. + * mapping functions cleaned up. #map now displays ssss as 4s. + * the definition file is tagged with a file version, to make it easier + to recognize older save formats. + * cancan now displays a motd file whose location is set at compile + time (see Makefile). + * define TELNETBUG to work around an NCSA telnet 2.2 colour bug. + #stdcolour can be used to set the background colour if TELNETBUG is + defined. + +Changes from 2.4.3 to 2.4.4 (David Gay) + * telnet window size option supported + +Changes from 2.4.2 to 2.4.3 + * added term support + * added #hilite to hilite user entered text + * added #mark and #unmark to mark special keywords... + * changed #identify to allow it to send alias' or commands to the + mud when beginning/ending an editing session. + * changes the Makefile a bit to support termcancan + +Changes from 2.4.1 to 2.4.2 + * Added multiple-session support with following # commands: + '#connect', '#zap', '#snoop', '##' + * Added numeric keypad movement, keypad sends commands + n,e,s,w,u,d and exits.. (not on all systems) + * Easier editing of actions with meta-p and meta-n (not on all systems) + * Changed the 'make_it' script a bit, so that it echoes the make + command it executes. + +Changes from 2.4.1 to 2.4.1b + * Improved modularity of source, new files cmd.c, cmd.h + +Changes from 2.4.0 to 2.4.1 + * Changed & in actions to match a single word for backward + compatibility. &0..&9 still match multi-worded text. + * Now compiles on HP-UX (at least HP-UX 9.01A ) + * Included a 'make_it' script that automatically compiles cancan for + Linux, IRIX, AIX, ULTRIX, DolphinOS, SunOS and HP-UX sytems. + +Changes from 2.3.6 to 2.4.0 + * Extended param substitution for & to &0..&9. + * Added '&&' syntax for delayed param substitution. + * Added '#init' command to send initialization string on connect. + * Added '#speedwalk' to toggle speedwalk on and off. + * Added '#map' with automapping. + * Added '#retrace' to retrace steps. + * Added sorting for alias and action lists, which is disabled if + compiled with -DNOSORT. + * Added compile option -DNOSHELL to remove '#!' shell escape function. + +Changes from Cancan 2.3.5 to 2.3.6 + * Fixed a bug with MUME's spinning delay bars and word wrap. + * & can now be escaped. This allows for aliases that create aliases, + and other things. + * Added this change log (not too early) + * Checks the window size after being suspended, in case it was + changed. + * Lines longer than screen width because of invisible spaces and/or + trailing CR:s are not unnecessarily wrapped. + diff --git a/Config.demo b/Config.demo new file mode 100644 index 0000000..7eb537e --- /dev/null +++ b/Config.demo @@ -0,0 +1,401 @@ +#savefile-version 1 +#("We use an old version number to force creation of sane default #binds") + +#init ={#(@oldxp=0);mapend;#option +compact -info -echo} + +#("Connect to MUME") +#host mume.pvv.org 4242 + +#("Some aliases to use labeled #actions") +#alias ac=#action $0 +#alias <=#action <$0 +#alias \==#action =$0 +#alias >=#action >$0 +#alias +=#action +$0 +#alias -=#action -$0 + +#("Some variables") +#(@emergency = 1, @xp = -0) +#($E_col = "bold") +#($Elbereth = "Grima Slinket Crug Camaro") +#($S_col = "inverse") +#($Sauron = "Homie Aridhol Quigley Mournblade ") + +#("Some useful binds -- they all are on numeric keypad") +#alias ?=#history 1 +#alias ??=#history $0 +#bind * ^[Oj=stat +#bind + ^[Ol=open honeycomb +#bind - ^[Om=close honeycomb +#bind . ^[On=sneak +#bind / ^[Oo=! +#bind 0 ^[Op=? +#bind 1 ^[Oq=hide +#bind 2 ^[Or=s +#bind 3 ^[Os=d +#bind 4 ^[Ot=w +#bind 5 ^[Ou=exits +#bind 6 ^[Ov=e +#bind 7 ^[Ow=look +#bind 8 ^[Ox=n +#bind 9 ^[Oy=u + +#alias plusminus={#bind +=open $1;#bind -=close $1} +#action >+close The $1 is open={#print;plusminus $1} +#action >+open2 The $1 seems to be closed={#print;plusminus $1} +#action >+open1 The $1 is closed={#print;plusminus $1} + +#("Bindings for function keys") +#alias HELP=#alias HELP={remove ring;narrate HELP! EMERGENCY TRANSFER! rings off!} +#bind F01 ^[OP=HELP +#alias wi=change wimpy $0 +#alias wq=wi 100 +#alias ww=wi 1000 +#bind F02 ^[OQ=ww +#bind F03 ^[OR=wq +#bind F04 ^[OS=examine +#bind F05 ^[m=now +#bind F06 ^[[17~=#option compact +#bind F07 ^[[18~=listen all +#bind F08 ^[[19~=listen none +#alias ck=change mood berserk +#alias ca=change mood aggressive +#alias cb=change mood brave +#alias cn=change mood normal +#alias cp=chan mood prudent +#alias cw=change mood wimpy +#bind F09 ^[[20~=cw +#bind F10 ^[[21~=ca +#alias pi={remove sword;draw} +#alias sla={sheath;wield sword} +#bind F11 ^[[23~=pi +#bind F12 ^[[24~=sla + +#("Two nice aliases") +#alias ,e=emote leaves east +#alias emsay=emote says '$0' + +#("Teleporting") +#alias ll=cast 'locate life' $0 +#alias tp=cast 'teleport' $0 +#alias portal=cast 'portal' $0 +#alias go={#if (!*\$0:>2) #(\$0+="tp"); #else #if (\$0:>2=="portal") #(\$0+=" u"); #exe (\$0:>2+" "+\$0:1)} + +#alias loc={#var $talias=$1; #action +tkey; ll $2} +#action >tkey Key: '$1'={#print; #action -tkey; #alias ${talias}=go $1 \$0} + +#alias zharlond=go whicewhile $0 +#alias zmichdelv=go sillelega $0 +#alias zbree=go dorwhimile $0 +#alias 1=zHarlond +#alias 2=zMichDelv +#alias 3=zBree + +#("An emote for enchanting weapons") +#alias ench=cast 'enchant weapon' $0 +#alias enchant={, makes a swift gesture and the $0 starts floating in mid air...;EnchSet +;ench $0} +#alias EnchSet={#action $1EnchSucc;#action $1EnchFail;#action $1BackFire} +#action >-BackFire Your spell backfired!={#print;, starts swearing loudly;EnchSet -} +#action >-EnchFail You lost your concentration!={#print;, frowns and exclaims, 'This cannot be! I failed!';EnchSet -} +#action >-EnchSucc $1 glows blue.={#print;, gestures again, and arcane runes flare on the $1!;EnchSet -} + +#("Keep count of game time and also put it in the prompt") + #mark Game time =underline +#("length of a game tick in milliseconds :") + #(@tick = 61500) +#("this is to synchronize") + #action >+clock ^The current time is $1:$2 $3.={#print;#if (\@0=$1*@tick+$2*@tick/60, \$3=="pm" ^^ $1==12) #(\@0+=12*@tick); #settimer (\@0);settick} +#("print time") + #alias time={#if ((\@1=timer%@tick*60/@tick) < 10) #(\$1=":0"); #else #(\$1=":");#print ("Game time "+%(timer/@tick%24)+\$1+%\@1)} +#("manually set time") + #alias now={#if (*\$1) #(\@0=$1*@tick+0$2*@tick/60); #else #if ((\@0=timer-(\@1=timer%@tick)), \@1 >= @tick/2) #(\@0+=@tick); #settimer (\@0)} +#("put time into the prompt. works for MUME.") +#("change to use appropriate patterns for other MUDs") + #prompt %+empty ^[o\\*]>={#isprompt -1; timeprompt} + #prompt %+full ^[o\\*] [^>]*>={#isprompt -1; timeprompt} + #alias timeprompt={#if ((\@1=timer%@tick*60/@tick) < 10) #(\$1=":0"); #else #(\$1=":");#($prompt=$prompt.1+" "+%(timer/@tick%24)+\$1+%\@1+$prompt.>2)} +#("automatically print time at every tick. type `settick' to activate") +#("or change #alias `now' and #action `clock' to run it") + #alias settick=set tick 0 time + #alias set=#exe ("#in $1 ("+%((-timer-1)%@tick+2)+") {"+\$0:>3+";#in $1 ((-timer-1)%@tick+2)}") + +#("Code to help mapping mazes -- keeps track of room number") +#("using binary numbers -- 1 copper == 1, 2 coppers == 0") +#("doesn't work anymore as you now get `six pile of coins' etc. tough luck.") +#alias d1=drop 1 copper +#alias d2=drop 2 copper +#alias m=#for (\@1=$1; \@1; \@1/=2) #if (\@1&1) d1; #else d2 +#alias mapend={- copper-penny;- pile-of-coins;#(@map=0)} +#alias mapstart={+ copper-penny;+ pile-of-coins;#(@map=0);#in map-timeout (-1) {#print ("Room: "+%@map);#(@map=0)}} +#alias mapcount={#(@map*=2, @map+=$1);#in map-timeout (100)} +#action >-pile-of-coins ^A pile of coins=mapcount 0 +#action >-copper-penny ^One miserable copper penny=mapcount 1 + +#("Spells and fight") +#($self = "Cosmos") +#alias self=#($self=$(0)) +#alias k=kill $0 +#alias f=flee +#alias ff=order followers assist ${self} +#alias fw=order followers assist waran +#alias of=order followers $0 +#alias ol=of k lord +#alias on=of k noble +#alias he={#if (!*$(0)) #($(0)=$self);#send ("cast 'heal' "+$(0))} +#alias in={#if (!*$(0)) #($(0)=$self);#send ("cast 'invisibility' "+$(0))} +#alias rp={#if (!*$(0)) #($(0)=$self);#send ("cast 'remove poison' "+$(0))} +#alias sct={#if (!*$(0)) #($(0)=$self);#send ("cast 'sanctuary' "+$(0))} +#alias str={#if (!*$(0)) #($(0)=$self);#send ("cast 'strength' "+$(0))} +#alias ar={#if (!*$(0)) #($(0)=$self);#send ("cast 'armour' "+$(0))} +#alias sspell=#exe ("#alias $1={#if (!*$(0)) #($(0)=$self);#send (\\"cast '"+\$0:>2+"' \\"+$(0))}") +#alias sto=cast 'store' $0 +#alias stb=sto fireball +#alias stl=sto call lightning +#alias stp=sto teleport +#alias stq=sto earthquake +#alias sty=sto colour spray +#alias bd=cast 'block door' $0 +#alias bl=cast 'blindness' $0 +#alias bob=cast 'breath of briskness' +#alias ch=cast 'charm' $0 +#alias cwt=cast 'control weather' $0 +#alias b=cast 'fireball' $0 +#alias j=cast 'lightning bolt' $0 +#alias li=cast 'call lightning' $0 +#alias sl=cast 'sleep' $0 +#alias sle=sl $0 + +#($target = "assassin") +#alias .=$0 ${target} +#alias bl.=bl ${target} +#alias b.=b ${target} +#alias j.=j ${target} +#alias k.=k ${target} +#alias li.=li ${target} +#alias sl.=sl ${target} +#alias blo=bl orc +#alias blt=bl troll +#alias jo=j orc +#alias jt=j troll +#alias ka=k assassin +#alias kw=k wolf + +#alias tr=track $0 +#alias to=tr orc +#alias tt=tr troll +#alias tr.=tr ${target} + +#alias bs=backstab $0 +#alias bs.=bs ${target} +#alias nn=$0 Necromancer + +#("Misc stuff") +#($water = "skin") +#alias dw=drink water +#alias dk=drink ${water} +#alias lk=look in ${water} +#alias po=pour water ${water} +#alias sk=sip ${water} +#alias cv=cast 'create water' $0 +#alias cvk=cv ${water} + +#($pack = "backpack") +#alias gp=get $0 ${pack} +#alias pp=put $0 ${pack} +#alias lp=look in ${pack} + +#($light = "lantern") +#alias hl=wear ${light} +#alias rl=remove ${light} +#alias vl=cover ${light} +#alias ul=uncover ${light} +#alias cl=cast 'create light' $0 +#alias cll=cl ${light} + +#alias lg=look in moneybag +#alias gg=get $1 gold moneybag +#alias pg=put $1 gold moneybag +#alias ggj=get ruby moneybag +#alias pgj=put ruby moneybag + +#alias cf=cast 'create food' +#alias gf=get food +#alias ef=eat food +#alias food={cf;gf;ef} + +#alias bc=#if (*$(1)) butcher $1.corpse; #else butcher corpse +#alias lc=#if (*$(1)) look in $1.corpse; #else look in corpse +#alias ga=#if (*$(1)) get all $1.corpse; #else get all corpse +#alias gc=#if (*$(1)) get coins $1.corpse; #else get coins corpse +#alias gx=#if (*$(2)) get $1 $2.corpse; #else get $1 corpse +#alias xc={hl;gc $0;rl} +#alias gl=get all +#alias glc={get all.coins;get all.copper} +#action >-greed is dead! R.I.P.={#print;gc} + +#alias ldh=#if (*($1)) lead $1.horse; #else lead horse +#alias rdh=#if (*$(1)) ride $0.horse; #else ride horse +#alias ldp=#if (*($1)) lead $1.pony; #else lead pony +#alias rdp=#if (*$(1)) ride $1.pony; #else ride pony +#alias ds=dismount +#action >-Ct ^Clip-clop...the riding horse= +#action >-Cp ^Clip-clop...a pony= +#action >-Cb ^The Horse= +#action >-At ^A riding horse= +#action >-Ap ^A cute and docile pony= +#action >-Ab ^A beautiful horse= + +#alias re=t Alsbreth $0 +#action >+reply ^$1 tells you '={#print;#alias re=t $1 \$0} +#action >-xeval ^$1 tells you 'calc &2'={#print;#alias re=t $1 \$0;if (\$2?";" || \$2?"$" || \$2?"@") {tell $1 *grin*;#()}; #else #send ("t $1 "+%($2))} + +#alias rep={+ report;score} +#action >-report $1 hit, $2 mana and $3 moves.={#print;, has $1 hit, $2 mana and $3 moves.;- report} +#alias rd={#opt +speedwalk;4ensenwdnenne;#opt -speedwalk} +#alias fd={#opt +speedwalk;wsswsuwwdww;#opt -speedwalk} + +#alias lr={look n;look s;look e;look w;look u;look d} +#alias x=#alias $0 +#alias kk=#bind $0 +#alias l=examine $0 +#alias gr=group $0 +#alias le=group ${self} +#alias mm=#mark $0 +#alias sa=#save +#alias se=search $0 +#alias mo=help month +#alias ng=, nods gravely. +#alias nh=, nods happily. +#alias ns=, nods sadly. +#alias p=' open +#alias rf=rem staff +#alias rn=read next +#alias rs=rem stone +#alias rt=rem ticket +#alias sms=, smiles sadly. +#alias ss=spam +#alias fade=emote quickly wraps in his cloak and vanishes. +#alias matz=emote unwraps his cloak and materializes. +#alias fun={fade;$0;matz} +#alias tele={fade;tp $0;matz} +#alias title=chan title the Hungry +#alias tm=t Meryaten $0 +#alias wavall=, waves good-bye to you. +#alias wf=weather fog +#alias wg=weather global +#alias wh=where human +#alias wk={wake;st} +#alias wl=weather local +#alias wr={wake;rest} +#alias grz=na --- === *** C O N G R A T U L A T I O N S !! *** === --- +#alias lin={#lines $0;chan height $0} +#alias lv=na --- === *** L E V E L !! *** === --- +#alias macintosh={#bind ~home ^[OH=eq;#bind ~~home ^[O@=eq;#bind ~F01 ^[OP=#key F01;#bind ~F02 ^[OQ=ww;#bind ~F03 ^[OR=wq;#bind ~F04 ^[OS=examine;#bind ~F05 ^[m=now;#bind ~+ ^[Ok=open patch;#bind ~~F05 ^[[16~=now} + + +#alias listadd=#for (\@0=1; *$$1:\@0 && $$1:\@0!=*13; \@0++) #exe ("#mark "+$$1:\\@0+"="+$$2)} +#alias listclear={#for (\@0=1; *$$1:\@0 && $$1:\@0!=*13; \@0++) #exe ("#mark "+$$1:\\@0+"=");#($$1="")} +#alias elb={listclear Elbereth;#ac +elbereth;t elbereth list} +#alias elblist=#print ("Elf Enemies: "+$Elbereth) +#alias sauronclean={#for (\@0=1; *\$-1:\@0; \@0++) #($-1=$-1:<\\@0<.2+" "+$-1:>(\\@0+1))} +#alias pk={listclear Sauron;#ac +sauron0;#ac +sauron1;t sauron list} +#alias pklist=#print ("PKillers: "+$Sauron) +#action >-elbereth ^Elbereth Gilthoniel tells you 'Elf Enemies: &1'={#($Elbereth=\$1);listadd -5 -6;#ac -elbereth;#print} +#action >-sauron2 ^ &1more to come.'={#($Sauron+=$-1=\$1<.3+",");sauronclean;#ac -sauron2;listadd -3 -4;#($Sauron+=$-1, $-1="");#print} +#action >-sauron1 ^Sauron tells you 'My Envoys: &1={#($Sauron=$-1=\$1<.2+",");sauronclean;#ac -sauron0;#ac -sauron1;#ac +sauron2;listadd -3 -4;#($Sauron=$-1);#print} +#action >-sauron0 ^Sauron tells you 'My Envoys: &1more to come.'={#($-1=\$1<.3+",");sauronclean;#ac -sauron0;#ac -sauron1;listadd -3 -4;#($Sauron=$-1);#print} + +#action >+disappear disappears into nothing.= +#action >+exp ^Needed: $1 xp={#print;#if (\@1=-$1, !@oldxp) #(@oldxp=@xp=\@1);#print ("Exp: "+%(\@1-@xp)+" from last score, "+%(\@1-@oldxp)+" from start of session");#(@xp=\@1)} +#action >+hunt *&1* leaves $2={#mark $2=bold;#print;#mark $2=} +#action >+save Saving=#print ("---> "+\$0+" <---") +#action >-someone ^Your blood freezes as you hear $1 =#if (\$1!="The" && \$1!="the" && \$1!="A" && \$1!="a" && \$1!="An" && \$1!="an") #print +#action >+Willow A sudden drowsiness overcomes you, you yawn and...={#print;wk} + +#mark sitting=bold +#mark resting=bold +#mark sleeping=bold +#mark Room: =bold +#mark tells you=underline +#mark YOU=bold red +#mark is dead! R.I.P.=bold +#mark glows with a bright light!=bold +#mark victim shocked=bold +#mark You feel a watchful eye=bold + +#mark The corpse of *&*=bold +#mark *an Orc*=bold yellow on red +#mark *$ the Orc*=bold yellow on red +#mark *a Troll*=bold cyan on yellow +#mark *$ the Troll*=bold cyan on yellow +#mark *a Human*=blue on cyan +#mark *$ the Human*=blue on cyan +#mark *$ the Numenorean*=blue on cyan +#mark *$ the Black Numenorean*=blue on cyan +#mark *a Dwarf*=bold cyan on magenta +#mark *$ the Dwarf*=bold cyan on magenta +#mark *an Elf*=blue on green +#mark *$ the Elf*=blue on green +#mark *a Hobbit*=bold yellow on blue +#mark *$ the Hobbit*=bold yellow on blue +#alias mumecolor={change col all default;change col shout bold yellow;change col damage bold red;change col hit bold blue} +#alias nocolors={#mark *an Orc*=inverse;#mark *$ the Orc*=inverse;#mark *a Troll*=inverse;#mark *$ the Troll*=inverse;#mark *a Human*=inverse;#mark *$ the Human*=inverse;#mark *$ the Numenorean*=inverse;#mark *$ the Black Numenorean*=inverse;#mark *a Dwarf*=inverse;#mark *$ the Dwarf*=inverse;#mark *an Elf*=inverse;#mark *$ the Elf*=inverse;#mark *a Hobbit*=inverse;#mark *$ the Hobbit*=inverse} +#alias colors={#mark *an Orc*=bold yellow on red;#mark *$ the Orc*=bold yellow on red;#mark *a Troll*=bold cyan on yellow;#mark *$ the Troll*=bold cyan on yellow;#mark *a Human*=blue on cyan;#mark *$ the Human*=blue on cyan;#mark *$ the Numenorean*=blue on cyan;#mark *$ the Black Numenorean*=blue on cyan;#mark *a Dwarf*=bold cyan on magenta;#mark *$ the Dwarf*=bold cyan on magenta;#mark *an Elf*=blue on green;#mark *$ the Elf*=blue on green;#mark *a Hobbit*=bold yellow on blue;#mark *$ the Hobbit*=bold yellow on blue} + +#bind >del ^[[P=&del-char-right +#bind A-bs ^[[071q=&clear-line +#bind A-del ^[[M=&kill-to-eol +#bind A-left ^[[160q=&begin-of-line +#bind A-return ^[[100q=&to-history +#bind A-right ^[[169q=&end-of-line +#bind M-B ^[b=&prev-word +#bind M-D ^[d=&del-word-right +#bind M-F ^[f=&next-word +#bind M-backsp ^[=&del-word-left +#bind M-bs ^[^H=&del-word-left +#bind M-tab ^[^I=&complete-line +#bind ^2 ^[[186q={s;hide} +#bind ^3 ^[[194q={d;hide} +#bind ^4 ^[[174q={w;hide} +#bind ^6 ^[[192q={e;hide} +#bind ^8 ^[[182q={n;hide} +#bind ^9 ^[[190q={u;hide} +#bind ^A ^A=&begin-of-line +#bind ^B ^B=&prev-char +#bind ^D ^D=&del-char-right +#bind ^E ^E=&end-of-line +#bind ^F ^F=&next-char +#bind ^K ^K=&kill-to-eol +#bind ^L ^L=&redraw-line +#bind ^N ^N=&next-line +#bind ^P ^P=&prev-line +#bind ^Q ^Q=&clear-line +#bind ^S ^S=#capture +#bind ^T ^T=&transpose +#bind ^V ^V=#stop +#bind ^W ^W=&to-history +#bind ^X ^X=#exe ("#capture emergency"+%@emergency++) +#bind ^Z ^Z=&suspend +#bind ^bs ^[[085q=&del-word-left +#bind ^del ^[[142q=&del-word-right +#bind ^left ^[[159q=&prev-word +#bind ^right ^[[168q=&next-word +#bind ^tab ^[[072q=&complete-line +#bind backsp =&del-char-left +#bind bs ^H=&del-char-left +#bind del ^[[3~=jo +#bind down ^[OB=&next-line +#bind end ^[[4~=jt +#bind enter ^[OM=flee +#bind home ^[[1~=stat +#bind ins ^[[2~=time +#bind left ^[OD=&prev-char +#bind lf ^J=&enter-line +#bind pgdwn ^[[6~=jh +#bind pgup ^[[5~=score +#bind return ^M=&enter-line +#bind right ^[OC=&next-char +#bind tab ^I=&complete-word +#bind up ^[OA=&prev-line +#bind ~^Q ^[~q=&clear-line +#bind ~^S ^[~s=#capture @@ -0,0 +1,67 @@ +Some notices for you who would like to hack the source in order to +improve powwow, fix bugs or just have fun: + +* Try not to run large chunks of existing code through your C + beautifier if the indentation style doesn't please you. This will + only greatly confuse the original author (if he can't recognize and + maintain his own code, who can?). If you write any new functions, + ok, use your own style as long as it's clear and consistent. + +* For portability, powwow is written using a few #defines that can + generate either K&R and ANSI function prototypes depending on the compiler, + so that it (should) compile fine in both cases. + If people convince me that non-ANSI compilers are rare enough these days, + we could switch to ANSI-only prototypes. Even then, please, do NOT + use any gcc-specific features (I've seen the char constant '\e' in some + places) even if gcc is very common. Our goal should be to let the + maximum number of people use powwow. (Most non-ANSI compilers grok + void and unsigned, so these are safe to use.) + +* For the same reason, do NOT use C++ style comments // + +* To sum it up, assume that the user has: + - a non-ANSI C compiler (use the __P, __P0, __P1, ... defines!) + - an exotic non-VT100 terminal (use TERMCAP!), possibly on a slow line + - a slow workstation, or a larger computer shared by 100 users and + aggressive sysadmins who think that mudding doesn't justify 10% or + even 5% CPU load. + +* Document your changes! A brief report of changes in the Changelog file is + absolutely necessary. So is updating the doc files (powwow.doc, powwow_help + and README) Also, sending an e-mail to the code author/mantainer documenting + your changes will be appreciated. + +Report from cancan's `Hacking': + +******************************************************************************* + Remember, that although I (Yorick) am the original author, I don't dictate + the code; it is explicitly in the public domain. I am merely trying to keep + some kind of order; if versions are permitted to diverge, they are very + painful to merge later. Also, different version branches are very confusing, + and makes it hard to define the "latest and best" version. Please try to + synchronize your hacks into one - the latest - version! +******************************************************************************* + +Well, Yorick refused to merge Powwow and Cancan, so now they both exist +indipendently... Now I (Cosmos) say exactly the same thing Yorick said +('do not let version diverge'), but I fear this will happen again :( +Only difference is that powwow is now GPL-ed and not Public Domain. +I hope this will help a little. + +* Rather than you just distributing your hacked version, I _really_ prefer you + to send back to me your changes, so that I can put them into the following + release. You lose nothing doing so, since even in case I refuse to include + your changes you can still distribute your version if you absolutely want :) + + Even if you decide to distribute such a modified version, please + make it clear that it is not the original version, use a version number + which can't be confused with an original version, and put your name + in Changelog and in POWWOW_VERSION. + +* I've tried to make the code obey the following rules for modularity: + - All exported things from one .c file is declared in its .h file. + - Conversely, symbols are imported by #including .h files, + not by local extern declarations. + - Everything that can be static should be (this is not quite true yet) + + Please obey these rules (or improve them). @@ -0,0 +1,229 @@ +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software +Foundation, Inc. + + This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +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, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + 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 you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' 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. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +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 support 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' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + 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 machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +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. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +will cause the specified gcc to be used as the C compiler (unless it is +overridden in the site shell script). + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--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. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..6e5be04 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,20 @@ +bin_PROGRAMS = powwow muc catrw follow movie +powwow_SOURCES = beam.c cmd.c log.c edit.c cmd2.c eval.c \ + utils.c main.c tcp.c list.c map.c tty.c \ + ptr.c +powwow_LDFLAGS = -rdynamic -ldl +powwowdir = $(pkgincludedir) +powwow_HEADERS = beam.h cmd.h log.h edit.h cmd2.h eval.h \ + utils.h main.h tcp.h list.h map.h tty.h \ + ptr.h defines.h +muc_SOURCES = muc.c +movie_SOURCES = movie.c +follow_SOURCES = follow.c +catrw_SOURCES = catrw.c + +man_MANS = powwow.6 +EXTRA_DIST = README README.follow README.term TODO Hacking Config.demo \ + powwow.doc powwow.help powwow.6 plugtest.c + +plugtest.so: plugtest.c + gcc -shared -o plugtest.so plugtest.c diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..33a722f --- /dev/null +++ b/Makefile.in @@ -0,0 +1,658 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 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. + +@SET_MAKE@ + + +SOURCES = $(catrw_SOURCES) $(follow_SOURCES) $(movie_SOURCES) $(muc_SOURCES) $(powwow_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +bin_PROGRAMS = powwow$(EXEEXT) muc$(EXEEXT) catrw$(EXEEXT) \ + follow$(EXEEXT) movie$(EXEEXT) +subdir = . +DIST_COMMON = README $(am__configure_deps) $(powwow_HEADERS) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ + TODO depcomp install-sh missing mkinstalldirs +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)" \ + "$(DESTDIR)$(powwowdir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_catrw_OBJECTS = catrw.$(OBJEXT) +catrw_OBJECTS = $(am_catrw_OBJECTS) +catrw_LDADD = $(LDADD) +am_follow_OBJECTS = follow.$(OBJEXT) +follow_OBJECTS = $(am_follow_OBJECTS) +follow_LDADD = $(LDADD) +am_movie_OBJECTS = movie.$(OBJEXT) +movie_OBJECTS = $(am_movie_OBJECTS) +movie_LDADD = $(LDADD) +am_muc_OBJECTS = muc.$(OBJEXT) +muc_OBJECTS = $(am_muc_OBJECTS) +muc_LDADD = $(LDADD) +am_powwow_OBJECTS = beam.$(OBJEXT) cmd.$(OBJEXT) log.$(OBJEXT) \ + edit.$(OBJEXT) cmd2.$(OBJEXT) eval.$(OBJEXT) utils.$(OBJEXT) \ + main.$(OBJEXT) tcp.$(OBJEXT) list.$(OBJEXT) map.$(OBJEXT) \ + tty.$(OBJEXT) ptr.$(OBJEXT) +powwow_OBJECTS = $(am_powwow_OBJECTS) +powwow_LDADD = $(LDADD) +DEFAULT_INCLUDES = -I. -I$(srcdir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(catrw_SOURCES) $(follow_SOURCES) $(movie_SOURCES) \ + $(muc_SOURCES) $(powwow_SOURCES) +DIST_SOURCES = $(catrw_SOURCES) $(follow_SOURCES) $(movie_SOURCES) \ + $(muc_SOURCES) $(powwow_SOURCES) +man6dir = $(mandir)/man6 +NROFF = nroff +MANS = $(man_MANS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +powwowHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(powwow_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +powwow_SOURCES = beam.c cmd.c log.c edit.c cmd2.c eval.c \ + utils.c main.c tcp.c list.c map.c tty.c \ + ptr.c + +powwow_LDFLAGS = -rdynamic -ldl +powwowdir = $(pkgincludedir) +powwow_HEADERS = beam.h cmd.h log.h edit.h cmd2.h eval.h \ + utils.h main.h tcp.h list.h map.h tty.h \ + ptr.h defines.h + +muc_SOURCES = muc.c +movie_SOURCES = movie.c +follow_SOURCES = follow.c +catrw_SOURCES = catrw.c +man_MANS = powwow.6 +EXTRA_DIST = README README.follow README.term TODO Hacking Config.demo \ + powwow.doc powwow.help powwow.6 plugtest.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ + cd $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +catrw$(EXEEXT): $(catrw_OBJECTS) $(catrw_DEPENDENCIES) + @rm -f catrw$(EXEEXT) + $(LINK) $(catrw_LDFLAGS) $(catrw_OBJECTS) $(catrw_LDADD) $(LIBS) +follow$(EXEEXT): $(follow_OBJECTS) $(follow_DEPENDENCIES) + @rm -f follow$(EXEEXT) + $(LINK) $(follow_LDFLAGS) $(follow_OBJECTS) $(follow_LDADD) $(LIBS) +movie$(EXEEXT): $(movie_OBJECTS) $(movie_DEPENDENCIES) + @rm -f movie$(EXEEXT) + $(LINK) $(movie_LDFLAGS) $(movie_OBJECTS) $(movie_LDADD) $(LIBS) +muc$(EXEEXT): $(muc_OBJECTS) $(muc_DEPENDENCIES) + @rm -f muc$(EXEEXT) + $(LINK) $(muc_LDFLAGS) $(muc_OBJECTS) $(muc_LDADD) $(LIBS) +powwow$(EXEEXT): $(powwow_OBJECTS) $(powwow_DEPENDENCIES) + @rm -f powwow$(EXEEXT) + $(LINK) $(powwow_LDFLAGS) $(powwow_OBJECTS) $(powwow_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/beam.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/catrw.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmd2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edit.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/follow.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/movie.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ptr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tty.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: +install-man6: $(man6_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man6dir)" || $(mkdir_p) "$(DESTDIR)$(man6dir)" + @list='$(man6_MANS) $(dist_man6_MANS) $(nodist_man6_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.6*) 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/^.*\\.//'`; \ + case "$$ext" in \ + 6*) ;; \ + *) ext='6' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man6dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man6dir)/$$inst"; \ + done +uninstall-man6: + @$(NORMAL_UNINSTALL) + @list='$(man6_MANS) $(dist_man6_MANS) $(nodist_man6_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.6*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 6*) ;; \ + *) ext='6' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(man6dir)/$$inst'"; \ + rm -f "$(DESTDIR)$(man6dir)/$$inst"; \ + done +install-powwowHEADERS: $(powwow_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(powwowdir)" || $(mkdir_p) "$(DESTDIR)$(powwowdir)" + @list='$(powwow_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(powwowHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(powwowdir)/$$f'"; \ + $(powwowHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(powwowdir)/$$f"; \ + done + +uninstall-powwowHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(powwow_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(powwowdir)/$$f'"; \ + rm -f "$(DESTDIR)$(powwowdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_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 + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(MANS) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)" "$(DESTDIR)$(powwowdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-man install-powwowHEADERS + +install-exec-am: install-binPROGRAMS + +install-info: install-info-am + +install-man: install-man6 + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man \ + uninstall-powwowHEADERS + +uninstall-man: uninstall-man6 + +.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ + clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \ + dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ + distclean-compile distclean-generic distclean-tags \ + distcleancheck distdir distuninstallcheck dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-man6 \ + install-powwowHEADERS install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-info-am \ + uninstall-man uninstall-man6 uninstall-powwowHEADERS + + +plugtest.so: plugtest.c + gcc -shared -o plugtest.so plugtest.c +# 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: @@ -0,0 +1,140 @@ + + powwow 1.2.4 README + +Powwow is a client program intended mainly for playing MUD. +It implements (a subset of) the telnet protocol. + +Files you should have received: + + README This text. + Changelog What has changed since the last release. + powwow.doc Complete documentation. READ this! + make_it A shell script that automatically compiles powwow on + many systems. + Compile.how A hopefully detailed text file showing how to compile + powwow on different systems. + Makefile Makefile: tailor it for your system if make_it fails. + *.[ch] Sources. + tools/* Additional standalone utilities. + powwow.help Online help file (in plain ASCII). + powwow.6 Man page. + Config.demo A demonstrative definition file for powwow + Hacking Read this if you want to improve/destroy powwow + yourself. + README.follow Documentation for the 'follow' mini-program. + README.term How to make termpowwow + +COMPILING + + Try the shell-script 'make_it', ie type './make_it'. + If that doesn't work, read the file 'Compile.how', try to edit + the 'Makefile' manually and either run './make_it' or 'make'. + If you have to edit the Makefile, or edit the source + code, to get it to work, pleae e-mail any changes you did to: + <max@Linuz.sns.it>. Also include info on what system you have + (type 'uname -a' to get the necessary info). + + You may also want to edit the Makefile in order to fine-tune powwow + to your system (change optimizations, include regexp library, etc.) + +INSTALLING + + If you want powwow's definition files to go in a specific directory, + set the environment variable POWWOWDIR to that directory. It will be + searched first for definition files at startup. + + Put the file powwow.6 in a suitable directory if you want users on + your system to be able to read the long and comprehensive man page ;) + + Powwow supports the MUME editing protocol. It enables you to edit + texts locally with your favourite editor. So far, only MUME supports + this protocol, but this might change in the future. + + Powwow looks for the editor in the POWWOWEDITOR enviroment variable, + and if it doesn't exist, in EDITOR, and uses "emacs" as default. For + text viewing, powwow looks for POWWOWPAGER, then PAGER, then uses + "more" as default. + + If you are on a multi-window terminal (such as an X terminal or NCSA + telnet from a Mac or PC), powwow will let you start the editor in + another window and remain active. You will then also be able to edit + several texts at the same time. To achieve this, let the first + character of your editor/pager be '&' (which is then skipped). + + Example: (Bourne shell syntax) + + POWWOWEDITOR=vi Use vi as normal editor (same window as + powwow) + POWWOWEDITOR='&emacs' Use emacs as editor in a separate window (if + you are on an X terminal) + POWWOWEDITOR='&xterm -e vi' Use vi in another X window + POWWOWPAGER='&xterm -e less' Use less as your file viewer in another + X window + + If you use a multi-window terminal and have emacsclient installed, it + is a good choice, since you only need one emacs window for all your + editing sessions and you don't have to start and exit emacs all the + time. Set POWWOWEDITOR='&emacsclient' in that case, and make sure your + emacs has a running server (put (server-start) in your .emacs file or + type M-x server-start). + + If you want to use the editing functions, you must execute the + `#identify' command to notify the server that the client supports the + protocol. This can also be done with an action; see the documentation + for details. + + For editing Mudlle programs with emacs, there is a special mode that + helps you with indenting. To use it, put mudlle.el in a suitable + place, and add the two following lines to your .emacs file: + + (setq load-path (append load-path '("mydirectory"))) + (autoload 'mudlle-mode "mudlle.el" "Turns on mudlle editing mode" t) + + where you replace mydirectory with the directory where mudlle.el can + be found. If you put the string -*-mudlle-*- in the first line of + a mudlle program (i.e. in a comment), then emacs will automatically + turn on mudlle mode for that file when you edit it. + The mudlle mode can be customized to some extent. See the source for + details. + +BUGS + + If you have any problems with powwow, try to fix them yourself + (you have the source, right?) or at least isolate the bugs so + the maintainer has a fair change of fixing them. Don't expect + a bug to be fixed, unless you explain it in detail (expecially + how to reproduce it) and supply the powwow and OS version, + as well as the compilation options. + Suggestions for improvements are also very welcome. + +AUTHORS OF CANCAN + + Since powwow is based on cancan, we report also this. + + Mattias Engdegard <f91-men@nada.kth.se> was the original author. + Many other people have contributed at least as much, including + Finn Arne Gangstad <finnag@pvv.unit.no>, David Gay <dgay@di.epfl.ch>, + Gary Dezern <gdezern@satelnet.org> + and Lai-Chang Woo <vivriel@scs.com.sg>. + It is unclear who the current maintainer is, but it seems to be + Finn Arne Gangstad. Ask around at MUME to find out more about cancan. + +AUTHORS OF POWWOW + + Massimiliano Ghilardi <max@Linuz.sns.it>, alias Cosmos, + is the original author, and Gustav Hållberg <f92-gha@nada.kth.se> + contributed a lot of new features. + The powwow WWW page is: http://Linuz.sns.it/~max/powwow.html + + If you forgot where you downloaded powwow from, you can get it from + the above address, or from + ftp://Linuz.sns.it/pub/Linux/ext-pack/powwow/ + + To learn more about MUME, have a look at http://fire.pvv.org/mume/ + which also explains how to connect. + +COPYRIGHT + + Powwow is placed under the terms of GPL (GNU General Public License) + The GPL License can be found in the file COPYING. + diff --git a/README.follow b/README.follow new file mode 100644 index 0000000..8b4e185 --- /dev/null +++ b/README.follow @@ -0,0 +1,18 @@ + + follow 0.1 README + +This mini-program is mainly intended for debugging powwow. +It is completely standalone, and needs to be called with a file-name +(example: `follow mycapture'). +Hitting ESC or ^C quits `follow', hitting RETURN prints the next line +of the file, any other key prints the next character (only one) of the file + +I know it is a _stupid_ program, but it is useful if you find screen-related +bugs in powwow, i.e. powwow does not print some lines or prints something +wrong. +In that case, if you redirect powwow output to a file and reproduce the bug, +you can use `follow your-filename' to examine the file and see what is wrong + +How to send a copy of powwow output to a file: +powwow your-arguments | tee your-filename + diff --git a/README.term b/README.term new file mode 100644 index 0000000..46d9a73 --- /dev/null +++ b/README.term @@ -0,0 +1,26 @@ + +'term' was written by Michael O'Reilly. + +If you don't know what term is, then you can ignore this file. :) + +Otherwise, if you want term support, read on... + +You need to edit the Makefile and edit the TERMDIR variable to the +directory of your term source and client.a. + +If you don't want 'term' compression on for powwow, take out the +-DTERM_COMPRESS in the CFLAGS variable in the Makefile. + +Edit any of the other variables you find neccessary. + +Read the original README for information you might need to know. + +Then do `make termpowwow' + +Note: Unfortunately one of the setbacks of termpowwow is that it won't +detect unknown hosts, nor will it detect if the host refused the connection. +If you don't get any output from a host after a few moments, then you'll +have to ^C. I don't think there's any way around this. + +(note - term support does not allow multiple sessions...) + @@ -0,0 +1,46 @@ +-*-indented-text-*- + +From the authors of cancan: + + THINGS TO DO + Cancan should know the codes of at least some keys + by looking in the TERMCAP. (especially control keys are trivial!) + + - Run (a)lint! + + - There seems to be problems with running cancan on exotic terminals. + This defeats the very purpose of all the carefully terminal- + independent code with TERMCAP, and is generally embarrassing. + + - more system calls should be checked for EINTR for sysV unices + + - negotiate the telnet BINARY option + + - support the telnet IAC GA command to identify prompts + (But what for? Prompts have to be identified as such in the absence + of GA anyway, and there doesn't seem to be a need for it right + now.) + + - implement reverse-incremental-search (like ^R in GNU Readline) + + KNOWN BUGS + - Deleting more than one character with deletechar() might leave + ugly traces on lines that are entirely deleted. + + - using #hilite with coloured background might have effects beyond the + input line, depending on the terminal (don't do that, then :-) + + FUTURE POSSIBLE IMPROVEMENTS + Do some more for portability (clean up the terminal mess) + The source should be more modular + Filtering output through shell command (grep etc) + + +THINGS TO DO/PLANNED IMPROVEMENTS on powwow: + - make a better #help + - add termcap `end of bold', `end of blink' etc. + + If you have ideas, suggestions or whatever, e-mail them to me + (max@Linuz.sns.it) and if I find them interesting, I will add them. + Also, I am trying to keep powwow updated with further releases + of cancan. diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..7b25188 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,1020 @@ +# generated automatically by aclocal 1.9.4 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +# Free Software Foundation, Inc. +# This file 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. + +# -*- Autoconf -*- +# Copyright (C) 2002, 2003 Free Software Foundation, Inc. +# Generated from amversion.in; do not edit by hand. + +# 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 + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.9.4])]) + +# AM_AUX_DIR_EXPAND + +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. + +# 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. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. + +# 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. + +# serial 6 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# serial 7 -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 +# Free Software Foundation, Inc. + +# 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. + + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH]) +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 +# Free Software Foundation, Inc. + +# 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. + +#serial 2 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# 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. + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +# Free Software Foundation, Inc. + +# 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. + +# serial 11 + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.58])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])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 + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $1 | $1:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. + +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. + +# 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. + +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# -*- Autoconf -*- +# Copyright (C) 2003 Free Software Foundation, Inc. + +# 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. + +# serial 1 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + +# 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. + +# serial 2 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# -*- Autoconf -*- + + +# Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. + +# 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. + +# serial 3 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# AM_PROG_MKDIR_P +# --------------- +# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. + +# Copyright (C) 2003, 2004 Free Software Foundation, Inc. + +# 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. + +# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories +# created by `make install' are always world readable, even if the +# installer happens to have an overly restrictive umask (e.g. 077). +# This was a mistake. There are at least two reasons why we must not +# use `-m 0755': +# - it causes special bits like SGID to be ignored, +# - it may be too restrictive (some setups expect 775 directories). +# +# Do not use -m 0755 and let people choose whatever they expect by +# setting umask. +# +# We cannot accept any implementation of `mkdir' that recognizes `-p'. +# Some implementations (such as Solaris 8's) are not thread-safe: if a +# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' +# concurrently, both version can detect that a/ is missing, but only +# one can create it and the other will error out. Consequently we +# restrict ourselves to GNU make (using the --version option ensures +# this.) +AC_DEFUN([AM_PROG_MKDIR_P], +[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi +AC_SUBST([mkdir_p])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + +# 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. + +# serial 2 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# +# Check to make sure that the build environment is sane. +# + +# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc. + +# 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. + +# serial 3 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# 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 conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $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]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# AM_PROG_INSTALL_STRIP + +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. + +# 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. + +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004 Free Software Foundation, Inc. + +# 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. + +# serial 1 + + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar <conftest.tar]) + grep GrepMe conftest.dir/file >/dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + @@ -0,0 +1,438 @@ +/* + * beam.c -- code to beam texts across the TCP connection following a + * special protocol + * + * Copyright (C) 1998 by Massimiliano Ghilardi + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <errno.h> +#include <fcntl.h> +#include <signal.h> +#include <time.h> +#include <unistd.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/wait.h> + +#include "defines.h" +#include "main.h" +#include "utils.h" +#include "beam.h" +#include "map.h" +#include "tcp.h" +#include "tty.h" +#include "edit.h" +#include "eval.h" + +editsess *edit_sess; /* head of session list */ + +char edit_start[BUFSIZE]; /* messages to send to host when starting */ +char edit_end[BUFSIZE]; /* or leaving editing sessions */ + +static void write_message __P1 (char *,s) +{ + clear_input_line(opt_compact); + if (!opt_compact) { + tty_putc('\n'); + status(1); + } + tty_puts(s); +} + +/* + * Process editing protocol message from buf with len remaining chars. + * Return number of characters used in the message. + */ +int process_message __P2 (char *,buf, int,len) +{ + int msglen, i, l, used; + char *text; + char msg[BUFSIZE]; + + status(1); + + msglen = atoi(buf + 1); + for (i = 1; i < len && isdigit(buf[i]); i++) + ; + + if (i < len && buf[i] == '\r') i++; + if (i >= len || buf[i] != '\n') { + write_message ("#warning: MPI protocol error\n"); + return 0; + } + + l = len - ++i; + if (msglen < l) { + l = msglen; + used = msglen + i; + } else + used = len; + + text = (char *)malloc(msglen); + if (!text) { + errmsg("malloc"); + return used > len ? len : used; + } + + memmove(text, buf + i, l); + i = l; + while(i < msglen) { + /* + * read() might block here, but it should't be long. I should also + * process any telnet protocol commands, but I don't care right now. + */ + while ((l = read(tcp_fd, text + i, msglen - i)) == -1 && errno == EINTR) + ; + if (l == -1) { + errmsg("read message from socket"); + return used > len ? len : used; + } + tty_printf("\rgot %d chars out of %d", i, msglen); + tty_flush(); + i += l; + } + tty_printf("\rread all %d chars.%s\n", msglen, tty_clreoln); + + if ((msglen = tcp_unIAC(text, msglen))) + switch(*buf) { + case 'E': + message_edit(text, msglen, 0, 0); + break; + case 'V': + message_edit(text, msglen, 1, 0); + break; + default: + sprintf(msg, "#warning: received a funny message (0x%x)\n", *buf); + write_message(msg); + free(text); + break; + } + + return used; +} + +/* + * abort an editing session when + * the MUD socket it comes from gets closed + */ +void abort_edit_fd __P1 (int,fd) +{ + editsess **sp, *p; + + if (fd < 0) + return; + + for (sp = &edit_sess; *sp; sp = &(*sp)->next) { + p = *sp; + if (p->fd != fd) + continue; + + if (kill(p->pid, SIGKILL) < 0) { /* Editicide */ + errmsg("kill editor child"); + continue; + } + + PRINTF("#aborted `%s' (%u)\n", p->descr, p->key); + p->cancel = 1; + } +} + +/* + * cancel an editing session; does not free anything + * (the child death signal handler will remove the session from the list) + */ +void cancel_edit __P1 (editsess *,sp) +{ + char buf[BUFSIZE]; + char keystr[16]; + + if (kill(sp->pid, SIGKILL) < 0) { /* Editicide */ + errmsg("kill editor child"); + return; + } + PRINTF("#killed `%s' (%u)\n", sp->descr, sp->key); + sprintf(keystr, "C%u\n", sp->key); + sprintf(buf, "%sE%d\n%s", MPI, (int)strlen(keystr), keystr); + tcp_write(sp->fd, buf); + sp->cancel = 1; +} + +/* + * send back edited text to server, or cancel the editing session if the + * file was not changed. + */ +static void finish_edit __P1 (editsess *,sp) +{ + char *realtext = NULL, *text; + int fd, txtlen, hdrlen; + struct stat sbuf; + char keystr[16], buf[256], hdr[65]; + + if (sp->fd == -1) + goto cleanup_file; + + fd = open(sp->file, O_RDONLY); + if (fd == -1) { + errmsg("open edit file"); + goto cleanup_file; + } + if (fstat(fd, &sbuf) == -1) { + errmsg("fstat edit file"); + goto cleanup_fd; + } + + txtlen = sbuf.st_size; + + if (!sp->cancel && (sbuf.st_mtime > sp->ctime || txtlen != sp->oldsize)) { + /* file was changed by editor: send back result to server */ + + realtext = (char *)malloc(2*txtlen + 65); + /* *2 to protect IACs, +1 is for possible LF, +64 for header */ + if (!realtext) { + errmsg("malloc"); + goto cleanup_fd; + } + + text = realtext + 64; + if ((txtlen = tcp_read_addIAC(fd, text, txtlen)) == -1) + goto cleanup_text; + + if (txtlen && text[txtlen - 1] != '\n') { + /* If the last line isn't LF-terminated, add an LF; + * however, empty files must remain empty */ + text[txtlen] = '\n'; + txtlen++; + } + + sprintf(keystr, "E%u\n", sp->key); + + sprintf(hdr, "%sE%d\n%s", MPI, (int)(txtlen + strlen(keystr)), keystr); + + text -= (hdrlen = strlen(hdr)); + memcpy(text, hdr, hdrlen); + + /* text[hdrlen + txtlen] = '\0'; */ + tcp_raw_write(sp->fd, text, hdrlen + txtlen); + + sprintf(buf, "#completed session %s (%u)\n", sp->descr, sp->key); + write_message(buf); + } else { + /* file wasn't changed, cancel editing session */ + sprintf(keystr, "C%u\n", sp->key); + sprintf(hdr, "%sE%d\n%s", MPI, (int) strlen(keystr), keystr); + + tcp_raw_write(sp->fd, hdr, strlen(hdr)); + + sprintf(buf, "#cancelled session %s (%u)\n", sp->descr, sp->key); + write_message(buf); + } + +cleanup_text: if (realtext) free(realtext); +cleanup_fd: close(fd); +cleanup_file: if (unlink(sp->file) < 0) + errmsg("unlink edit file"); +} + +/* + * start an editing session: process the EDIT/VIEW message + * if view == 1, text will be viewed, else edited + */ +void message_edit __P4 (char *,text, int,msglen, char,view, char,builtin) +{ + char tmpname[BUFSIZE], command_str[BUFSIZE], buf[BUFSIZE]; + char *errdesc = "#warning: protocol error (message_edit, no %s)\n"; + int tmpfd, i, childpid; + unsigned int key; + editsess *s; + char *editor, *descr; + char *args[4]; + int waitforeditor; + + status(1); + + args[0] = "/bin/sh"; args[1] = "-c"; + args[2] = command_str; args[3] = 0; + + if (view) { + key = (unsigned int)-1; + i = 0; + } else { + if (text[0] != 'M') { + tty_printf(errdesc, "M"); + free(text); + return; + } + for (i = 1; i < msglen && isdigit(text[i]); i++) + ; + if (text[i++] != '\n' || i >= msglen) { + tty_printf(errdesc, "\\n"); + free(text); + return; + } + key = strtoul(text + 1, NULL, 10); + } + descr = text + i; + while (i < msglen && text[i] != '\n') i++; + if (i >= msglen) { + tty_printf(errdesc, "desc"); + free(text); + return; + } + text[i++] = '\0'; + + sprintf(tmpname, "/tmp/powwow.%u.%d%d", key, getpid(), abs(rand()) >> 8); + if ((tmpfd = open(tmpname, O_WRONLY | O_CREAT, 0600)) < 0) { + errmsg("create temp edit file"); + free(text); + return; + } + if (write(tmpfd, text + i, msglen - i) < msglen - i) { + errmsg("write to temp edit file"); + free(text); + close(tmpfd); + return; + } + close(tmpfd); + + s = (editsess*)malloc(sizeof(editsess)); + if (!s) { + errmsg("malloc"); + return; + } + s->ctime = time((time_t*)NULL); + s->oldsize = msglen - i; + s->key = key; + s->fd = (view || builtin) ? -1 : tcp_fd; /* MUME doesn't expect a reply. */ + s->cancel = 0; + s->descr = my_strdup(descr); + s->file = my_strdup(tmpname); + free(text); + + /* send a edit_start message (if wanted) */ + if ((!edit_sess) && (*edit_start)) { + error = 0; + parse_instruction(edit_start, 0, 0, 1); + history_done = 0; + } + + if (view) { + if (!(editor = getenv("POWWOWPAGER")) && !(editor = getenv("PAGER"))) + editor = "more"; + } else { + if (!(editor = getenv("POWWOWEDITOR")) && !(editor = getenv("EDITOR"))) + editor = "emacs"; + } + + if (editor[0] == '&') { + waitforeditor = 0; + editor++; + } else + waitforeditor = 1; + + if (waitforeditor) { + tty_quit(); + /* ignore SIGINT since interrupting the child would interrupt us too, + if we are in the same tty group */ + sig_permanent(SIGINT, SIG_IGN); + sig_permanent(SIGCHLD, SIG_DFL); + } + + switch(childpid = fork()) { /* let's get schizophrenic */ + case 0: + sprintf(command_str, "%s %s", editor, s->file); + sprintf(buf, "TITLE=%s", s->descr); + putenv(buf); + /* setenv("TITLE", s->descr, 1);*/ + execvp((char *)args[0], (char **)args); + syserr("execve"); + break; + case -1: + errmsg("fork"); + free(s->descr); + free(s->file); + free(s); + return; + } + s->pid = childpid; + if (waitforeditor) { + while ((i = waitpid(childpid, (int*)NULL, 0)) == -1 && errno == EINTR) + ; + + signal_start(); /* reset SIGINT and SIGCHLD handlers */ + tty_start(); + + if (s->fd != -1) { + tty_gotoxy(0, lines - 1); + tty_putc('\n'); + } + + if (i == -1) + errmsg("waitpid"); + else + finish_edit(s); + + free(s->descr); + free(s->file); + if (i != -1 && !edit_sess && *edit_end) { + error = 0; + parse_instruction(edit_end, 0, 0, 1); + history_done = 0; + } + + free(s); + + } else { + s->next = edit_sess; + edit_sess = s; + } +} + +/* + * Our child has snuffed it. check if it was an editor, and update the + * session list if that is the case. + */ +void sig_chld_bottomhalf __P0 (void) +{ + int fd, pid, ret; + editsess **sp, *p; + + /* GH: while() instead of just one check */ + while ((pid = waitpid(-1, &ret, WNOHANG)) > 0) { + + /* GH: check for WIFSTOPPED unnecessary since no */ + /* WUNTRACED to waitpid() */ + for (sp = &edit_sess; *sp && (*sp)->pid != pid; sp = &(*sp)->next) + ; + if (*sp) { + finish_edit(*sp); + p = *sp; *sp = p->next; + fd = p->fd; + free(p->descr); + free(p->file); + free(p); + + /* GH: only send message if found matching session */ + + /* send the edit_end message if this is the last editor... */ + if ((!edit_sess) && (*edit_end)) { + int otcp_fd = tcp_fd; /* backup current socket fd */ + tcp_fd = fd; + error = 0; + parse_instruction(edit_end, 0, 0, 1); + history_done = 0; + tcp_fd = otcp_fd; + } + } + } +} + @@ -0,0 +1,17 @@ +/* public things from beam.c */ + +#ifndef _BEAM_H_ +#define _BEAM_H_ + +int process_message __P ((char *buf, int len)); +void cancel_edit __P ((editsess *sp)); +void abort_edit_fd __P ((int fd)); +void message_edit __P ((char *text, int msglen, char view, char builtin)); +void sig_chld_bottomhalf __P ((void)); + +extern char edit_start[]; +extern char edit_end[]; +extern editsess *edit_sess; + +#endif /* _BEAM_H_ */ + @@ -0,0 +1,39 @@ +/* + * catrw.c -- open a file with O_RDWR and print it. + * + * This file is placed in the public domain. + */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> + +#define BUFSIZE 4096 +char buf[BUFSIZE]; + +void catrw(int fd) { + int i; + for (;;) { + while ( (i = read(fd, buf, BUFSIZE)) < 0 && errno == EINTR) + ; + if (i <= 0) + break; + write(1, buf, i); + } +} + +int main(int argc, char *argv[]) { + int fd; + if (argc == 1) + catrw(0); + else { + while (--argc && (fd = open(*++argv, O_RDWR))) { + catrw(fd); + close(fd); + } + } + return 0; +} + @@ -0,0 +1,2464 @@ +/* + * cmd.c -- functions for powwow's built-in #commands + * + * (created: Finn Arne Gangstad (Ilie), Dec 25th, 1993) + * + * Copyright (C) 1998 by Massimiliano Ghilardi + * + * 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. + * + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <signal.h> +#include <ctype.h> +#include <time.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> +#include <dlfcn.h> + +#include "defines.h" +#include "main.h" +#include "utils.h" +#include "beam.h" +#include "cmd.h" +#include "cmd2.h" +#include "edit.h" +#include "list.h" +#include "map.h" +#include "tcp.h" +#include "tty.h" +#include "eval.h" +#include "log.h" + +/* local function declarations */ +#define _ __P ((char *arg)) + +static void cmd_help _, cmd_shell _, + cmd_action _, cmd_add _, cmd_alias _, cmd_at _, cmd_beep _, cmd_bind _, + cmd_cancel _, cmd_capture _, cmd_clear _, cmd_connect _, cmd_cpu _, + cmd_do _, cmd_delim _, cmd_edit _, cmd_emulate _, cmd_exe _, + cmd_file _, cmd_for _, cmd_hilite _, cmd_history _, cmd_host _, + cmd_identify _, cmd_if _, cmd_in _, cmd_init _, cmd_isprompt _, + cmd_key _, cmd_keyedit _, + cmd_load _, cmd_map _, cmd_mark _, cmd_movie _, + cmd_net _, cmd_nice _, cmd_option _, + cmd_prefix _, cmd_print _, cmd_prompt _, cmd_put _, + cmd_qui _, cmd_quit _, cmd_quote _, + cmd_rawsend _, cmd_rawprint _, cmd_rebind _, cmd_rebindall _, cmd_rebindALL _, + cmd_record _, cmd_request _, cmd_reset _, cmd_retrace _, + cmd_save _, cmd_send _, cmd_setvar _, cmd_snoop _, cmd_spawn _, cmd_stop _, + cmd_time _, cmd_var _, cmd_ver _, cmd_while _, cmd_write _, + cmd_eval _, cmd_zap _, cmd_module _, cmd_group _; + +#ifdef BUG_TELNET +static void cmd_color _; +#endif + +#undef _ + +/* This must be init'd now at runtime */ +cmdstruct *commands = NULL; + +/* The builtin commands */ +cmdstruct default_commands[] = +{ + {NULL,"help", "[keys|math|command]\tthis text, or help on specified topic", cmd_help,NULL}, + {NULL,"17", "command\t\t\trepeat `command' 17 times", (function_str)0,NULL}, +#ifndef NO_SHELL + {NULL,"!", "shell-command\t\texecute a shell command using /bin/sh", cmd_shell,NULL}, +#endif + {NULL,"action", "[[<|=|>|%][+|-]name] [{pattern|(expression)} [=[command]]]\n\t\t\t\tdelete/list/define actions", cmd_action,NULL}, + {NULL,"add", "{string|(expr)}\t\tadd the string to word completion list", cmd_add,NULL}, + {NULL,"alias", "[name[=[text]]]\t\tdelete/list/define aliases", cmd_alias,NULL}, + {NULL,"at", "[name [(time-string) [command]]\tset time of delayed label", cmd_at,NULL}, + {NULL,"beep", "\t\t\t\tmake your terminal beep (like #print (*7))", cmd_beep,NULL}, + {NULL,"bind", "[edit|name [seq][=[command]]]\tdelete/list/define key bindings", cmd_bind,NULL}, + {NULL,"cancel", "[number]\t\tcancel editing session", cmd_cancel,NULL}, + {NULL,"capture", "[filename]\t\tbegin/end of capture to file", cmd_capture,NULL}, + {NULL,"clear", "\t\t\tclear input line (use from spawned programs)", cmd_clear,NULL}, +#ifdef BUG_TELNET + {NULL,"color", "attr\t\t\tset default colors/attributes", cmd_color,NULL}, +#endif + {NULL,"connect", "[connect-id [initstr] [address port]\topen a new connection", cmd_connect,NULL}, + {NULL,"cpu", "\t\t\t\tshow CPU time used by powwow", cmd_cpu,NULL}, + {NULL,"delim", "[normal|program|{custom [chars]}]\n\t\t\t\tset word completion delimeters", cmd_delim,NULL}, + {NULL,"do", "(expr) command\t\trepeat `command' (expr) times", cmd_do,NULL}, + {NULL,"edit", "\t\t\t\tlist editing sessions", cmd_edit,NULL}, + {NULL,"emulate", "[<|!]{text|(expr)}\tprocess result as if received from host", cmd_emulate,NULL}, + {NULL,"exe", "[<|!]{text|(string-expr)}\texecute result as if typed from keyboard", cmd_exe,NULL}, + {NULL,"file", "[=[filename]]\t\tset/show powwow definition file", cmd_file,NULL}, + {NULL,"for", "([init];check;[loop]) command\twhile `check' is true exec `command'", cmd_for,NULL}, + {NULL,"group", "[name] [on|off|list]\tgroup alias/action manipulation'", cmd_group,NULL}, + {NULL,"hilite", "[attr]\t\t\thighlight your input line", cmd_hilite,NULL}, + {NULL,"history", "[{number|(expr)}]\tlist/execute commands in history", cmd_history,NULL}, + {NULL,"host", "[hostname port]]\tset/show address of default host", cmd_host,NULL}, + {NULL,"identify", "[startact [endact]]\tsend MUME client identification", cmd_identify,NULL}, + {NULL,"if", "(expr) instr1 [; #else instr2]\tif `expr' is true execute `instr1'\n\t\t\t\totherwise execute `instr2'", cmd_if,NULL}, + {NULL,"in", "[label [(delay) [command]]]\tdelete/list/define delayed labels", cmd_in,NULL}, + {NULL,"init", "[=[command]]\t\tdefine command to execute on connect to host", cmd_init,NULL}, + {NULL,"isprompt", "\t\t\trecognize a prompt as such", cmd_isprompt,NULL}, + {NULL,"key", "name\t\t\texecute the `name' key binding", cmd_key,NULL}, + {NULL,"keyedit", "editing-name\t\trun a line-editing function", cmd_keyedit,NULL}, + {NULL,"load", "[filename]\t\tload powwow settings from file", cmd_load,NULL}, + {NULL,"module","[filename]\t\tload shared library extension", cmd_module,NULL}, + {NULL,"map", "[-[number]|walksequence]\tshow/clear/edit (auto)map", cmd_map,NULL}, + {NULL,"mark", "[string[=[attr]]]\t\tdelete/list/define markers", cmd_mark,NULL}, + {NULL,"movie", "[filename]\t\tbegin/end of movie record to file", cmd_movie,NULL}, + {NULL,"net", "\t\t\t\tprint amount of data received from/sent to host", cmd_net,NULL}, + {NULL,"nice", "[{number|(expr)}[command]]\tset/show priority of new actions/marks", cmd_nice,NULL}, + {NULL,"option", "[[+|-|=]name]\t\tturn various options", cmd_option,NULL}, + {NULL,"prefix", "string\t\t\tprefix all lines with string", cmd_prefix,NULL}, + {NULL,"", "(expr)\t\t\tevaluate expression, trashing result", cmd_eval,NULL}, + {NULL,"print", "[<|!][text|(expr)]\tprint text/result on screen, appending a \\n\n\t\t\t\tif no argument, prints value of variable $0", cmd_print,NULL}, + {NULL,"prompt", "[[<|=|>|%][+|-]name] [{pattern|(expression)} [=[prompt-command]]]\n\t\t\t\tdelete/list/define actions on prompts", cmd_prompt,NULL}, + {NULL,"put", "{text|(expr)}\t\tput text/result of expression in history", cmd_put,NULL}, + {NULL,"qui", "\t\t\t\tdo nothing", cmd_qui,NULL}, + {NULL,"quit", "\t\t\t\tquit powwow", cmd_quit,NULL}, + {NULL,"quote", "[on|off]\t\t\ttoggle verbatim-flag on/off", cmd_quote,NULL}, + {NULL,"rawsend", "{string|(expr)}\t\tsend raw data to the MUD", cmd_rawsend,NULL}, + {NULL,"rawprint", "{string|(expr)}\t\tsend raw data to the screen", cmd_rawprint,NULL}, + {NULL,"rebind", "name [seq]\t\tchange sequence of a key binding", cmd_rebind,NULL}, + {NULL,"rebindall", "\t\t\trebind all key bindings", cmd_rebindall,NULL}, + {NULL,"rebindALL", "\t\t\trebind ALL key bindings, even trivial ones", cmd_rebindALL,NULL}, + {NULL,"record", "[filename]\t\tbegin/end of record to file", cmd_record,NULL}, + {NULL,"request", "[editor][prompt][all]\tsend various identification strings", cmd_request,NULL}, + {NULL,"reset", "<list-name>\t\tclear the whole defined list and reload default", cmd_reset,NULL}, + {NULL,"retrace", "[number]\t\tretrace the last number steps", cmd_retrace,NULL}, + {NULL,"save", "[filename]\t\tsave powwow settings to file", cmd_save,NULL}, + {NULL,"send", "[<|!]{text|(expr)}\teval expression, sending result to the MUD", cmd_send,NULL}, + {NULL,"setvar", "name[=text|(expr)]\tset/show internal limits and variables", cmd_setvar,NULL}, + {NULL,"snoop", "connect-id\t\ttoggle output display for connections", cmd_snoop,NULL}, + {NULL,"spawn", "connect-id command\ttalk with a shell command", cmd_spawn,NULL}, + {NULL,"stop", "\t\t\t\tremove all delayed commands from active list", cmd_stop,NULL}, + {NULL,"time", "\t\t\t\tprint current time and date", cmd_time,NULL}, + {NULL,"var", "variable [= [<|!]{string|(expr)} ]\twrite result into the variable", cmd_var,NULL}, + {NULL,"ver", "\t\t\t\tshow powwow version", cmd_ver,NULL}, + {NULL,"while", "(expr) instr\t\twhile `expr' is true execute `instr'", cmd_while,NULL}, + {NULL,"write", "[>|!](expr;name)\t\twrite result of expr to `name' file", cmd_write,NULL}, + {NULL,"zap", "connect-id\t\t\tclose a connection", cmd_zap,NULL}, + {NULL,(char *)0, (char *)0, (function_str)0,NULL} +}; + +char *_cmd_sort_name( cmdstruct *cmd ) { + if( cmd -> sortname == NULL ) + return( cmd -> name ); + else + return( cmd -> sortname ); +} + +/* Adds a cmd to commands (inserts the ptr in the list, DO NOT FREE IT) */ +void cmd_add_command( cmdstruct *cmd ) { + /* do insert/sort */ + cmdstruct *c = commands; + + /* + * make sure it doesn't override another commmand + * this is important not just because it'd be irritating, + * but if a module defined the command in the global static + * space, it would create an infinite loop because the -> next + * ptr would point at itself + * + * doing it up front because based on the sortname, we may never see + * the dup item if we do it at sort time + */ + for( c = commands; c != NULL; c = c -> next ) { + if( strcmp( cmd -> name, c -> name ) == 0 ) { + PRINTF( "#error %s is already defined\n", c -> name ); + return; + } + } + + + /* catch insertion to head of list */ + if( commands == NULL ) { + /* no commands yet */ + commands = cmd; + cmd -> next = NULL; + return; + } + + if( strcmp( _cmd_sort_name( commands ), _cmd_sort_name( cmd ) ) > 0 ) { + /* this is lower in sort than every item, so + * make it the head of the list */ + cmd -> next = commands; + commands = cmd; + return; + } + + for( c = commands; c != NULL; c = c -> next ) { + if( strcmp( _cmd_sort_name( cmd ), _cmd_sort_name( c ) ) >= 0 ) { + /* Need second check to handle empty string case */ + if( c -> next == NULL || strcmp( _cmd_sort_name( cmd ), _cmd_sort_name( c -> next ) ) <= 0 ) { + /*PRINTF( "Inserting %s after %s\n", cmd -> name, c -> name ); */ + + /* insert after this one, it is greater than this + * entry but less than the next */ + cmd -> next = c -> next; + c -> next = cmd; + return; + } + } + } + + PRINTF( "ERROR INSERTING COMMAND\n" ); +} + +/* Init the command listing, called from main */ +void _cmd_init() { + int i; + + /* Now add the default command list */ + for( i = 0; default_commands[ i ].name; i++ ) + cmd_add_command( &default_commands[ i ] ); +} + +static void cmd_module __P1 (char *,arg) { + char libname[1024]; + void *lib; + void (*func)(); + + arg = skipspace(arg); + + bzero( libname, 1024 ); + if( *arg == '.' || *arg == '/' ) { + /* No path mungling */ + strncpy( libname, arg, 1024 ); + }else{ + snprintf( libname, 1024, "/usr/local/lib/powwow/%s", arg ); + } + + /* open lib */ + lib = dlopen( libname, RTLD_LAZY ); + if( ! lib ) { + PRINTF( "#lib error: %s\n", dlerror() ); + return; + } + + func = dlsym( lib, "powwow_init" ); + if( func ) { + (*func)(); + }else{ + PRINTF( "#lib error: %s\n", dlerror() ); + } +} + +static void cmd_group __P1 (char *,arg) { + char *group; + int active; + aliasnode *p; + actionnode *a; + + arg = skipspace(arg); + + if( *arg ) { + arg = first_regular( group = arg, ' '); + *arg = '\0'; + arg = skipspace( arg + 1 ); + + if( strcmp( arg, "on" ) == 0 ) { + active = 1; + }else if( strcmp( arg, "off" ) == 0 ) { + active = 0; + }else if( strcmp( arg, "list" ) == 0 ) { + PRINTF( "#not implemented\n" ); + return; + }else{ + PRINTF( "#unknown group command, use off/on/list\n" ); + return; + } + + /* Now loop over all aliases/actions by groupname and toggle */ + for( p = sortedaliases; p; p = p -> snext ) { + if( p -> group && strcmp( p -> group, group ) == 0 ) { + p -> active = active; + } + } + + /* Same for actions */ + for( a = actions; a; a = a -> next ) { + if( a -> group && strcmp( a -> group, group ) == 0 ) { + a -> active = active; + } + } + }else{ + PRINTF( "#group name required\n" ); + } +} + +static void cmd_help __P1 (char *,arg) +{ + int i, size; + char *text, *tmp; + FILE *f; + char line[BUFSIZE]; + int len; + cmdstruct *c; + + arg = skipspace(arg); + if (*arg == '#') arg++; + if (!*arg) { + size = 25; + for( c = commands; c != NULL; c = c -> next ) + size += strlen(c -> name) + strlen(c -> help) + 5; + + text = tmp = (char *)malloc(size); + if (!text) { + errmsg("malloc"); + return; + } + + /* do not use sprintf() return value, almost every OS returns a different thing. */ + sprintf(tmp, "#help\n#commands available:\n"); + tmp += strlen(tmp); + + for( c = commands; c != NULL; c = c -> next ) { + sprintf(tmp, "#%s %s\n", c -> name, c -> help); + tmp += strlen(tmp); + } + + message_edit(text, strlen(text), 1, 1); + return; + } + + if (!strncmp(arg, "copyright", strlen(arg))) { + int fd, left, got = 0; + struct stat stbuf; + + if (stat(copyfile, &stbuf) < 0) { + errmsg("stat(copyright file)"); + return; + } + + if (!(text = (char *)malloc(left = stbuf.st_size))) { + errmsg("malloc"); + return; + } + if ((fd = open(copyfile, O_RDONLY)) < 0) { + errmsg("open(copyright file)"); + free(text); + return; + } + while (left > 0) { + while ((i = read(fd, text + got, left)) < 0 && errno == EINTR) + ; + if (i < 0 && errno == EINTR) { + errmsg("read (copyright file)"); + free(text); + close(fd); + return; + } + if (i == 0) + break; + left -= i, got += i; + } + close(fd); + message_edit(text, strlen(text), 1, 1); + return; + } + + /* !copyright */ + + f = fopen(helpfile, "r"); + if (!f) { + PRINTF("#cannot open help file `%s': %s\n", + helpfile, strerror(errno)); + return; + } + + while ((tmp = fgets(line, BUFSIZE, f)) && + (line[0] != '@' || strncmp(line + 1, arg, strlen(arg)))) + ; + + if (!tmp) { + PRINTF("#no entry for `%s' in the help file.\n", arg); + fclose(f); + return; + } + + if (!(text = (char *)malloc(size = BUFSIZE))) { + errmsg("malloc"); + fclose(f); + return; + } + + memcpy(text, line, i = strlen(line)); + + while (fgets(line, BUFSIZE, f) && line[0] == '@') + ; /* allow multiple commands to share the same help */ + + do { + if ((len = strlen(line)) >= size - i) { + /* Not enough space in current buffer */ + + if (!(tmp = (char *)malloc(size += BUFSIZE))) { + errmsg("malloc"); + free(text); + fclose(f); + return; + } else { + memcpy(tmp, text, i); + free(text); + text = tmp; + } + } + memcpy(text + i, line, len); + i += len; + } while (fgets(line, BUFSIZE, f) && line[0] != '@'); + + fclose(f); + text[i] = '\0'; /* safe, there is space */ + message_edit(text, strlen(text), 1, 1); +} + +static void cmd_clear __P1 (char *,arg) +{ + if (line_status == 0) { + clear_input_line(opt_compact); + if (!opt_compact) { + tty_putc('\n'); + col0 = 0; + } + status(1); + } +} + +#ifndef NO_SHELL +static void cmd_shell __P1 (char *,arg) +{ + if (!*arg) { + if (echo_int) { + PRINTF("#that's easy.\n"); + } + } else { + tty_quit(); + + system(arg); + + tty_start(); + tty_gotoxy(col0 = 0, line0 = lines -1); + tty_puts(tty_clreoln); + } +} +#endif + +static void cmd_alias __P1 (char *,arg) +{ + arg = skipspace(arg); + if (!*arg) + show_aliases(); + else + parse_alias(arg); +} + +static void cmd_action __P1 (char *,arg) +{ + arg = skipspace(arg); + if (!*arg) + show_actions(); + else + parse_action(arg, 0); +} + +static void cmd_prompt __P1 (char *,arg) +{ + arg = skipspace(arg); + if (!*arg) + show_prompts(); + else + parse_action(arg, 1); +} + +static void cmd_beep __P1 (char *,arg) +{ + tty_putc('\007'); +} + +/* + * create/list/edit/delete bindings + */ +static void cmd_bind __P1 (char *,arg) +{ + arg = skipspace(arg); + if (!*arg) + show_binds(0); + else if (!strcmp(arg, "edit")) + show_binds(1); + else + parse_bind(arg); +} + +static void cmd_delim __P1 (char *,arg) +{ + char buf[BUFSIZE]; + int n; + + arg = skipspace(arg); + if (!*arg) { + PRINTF("#delim: `%s' (%s)\n", delim_name[delim_mode], DELIM); + return; + } + + arg = split_first_word(buf, BUFSIZE, arg); + n = 0; + while (n < DELIM_MODES && strncmp(delim_name[n], buf, strlen(buf)) != 0) + n++; + + if (n >= DELIM_MODES) { + PRINTF("#delim [normal|program|{custom <chars>}\n"); + return; + } + + if (n == DELIM_CUSTOM) { + if (!strchr(arg, ' ')) { + my_strncpy(buf+1, arg, BUFSIZE-2); + *buf = ' '; /* force ' ' in the delims */ + arg = buf; + } + unescape(arg); + set_custom_delimeters(arg); + } else + delim_mode = n; +} + +static void cmd_do __P1 (char *,arg) +{ + int type; + long result; + + arg = skipspace(arg); + if (*arg != '(') { + PRINTF("#do: "); + print_error(error=MISMATCH_PAREN_ERROR); + return; + } + arg++; + + type = evall(&result, &arg); + if (REAL_ERROR) return; + + if (type != TYPE_NUM) { + PRINTF("#do: "); + print_error(error=NO_NUM_VALUE_ERROR); + return; + } + + if (*arg == ')') { /* skip the ')' */ + if (*++arg == ' ') + arg++; + } + else { + PRINTF("#do: "); + print_error(error=MISSING_PAREN_ERROR); + return; + } + + if (result >= 0) + while (!error && result--) + (void)parse_instruction(arg, 1, 0, 1); + else { + PRINTF("#do: bogus repeat count `%ld'\n", result); + } +} + +static void cmd_hilite __P1 (char *,arg) +{ + int attr; + + arg = skipspace(arg); + attr = parse_attributes(arg); + if (attr == -1) { + PRINTF("#attribute syntax error.\n"); + if (echo_int) + show_attr_syntax(); + } else { + attr_string(attr, edattrbeg, edattrend); + + edattrbg = ATTR(attr) & ATTR_INVERSE ? 1 + : BACKGROUND(attr) != NO_COLOR || ATTR(attr) & ATTR_BLINK; + + if (echo_int) { + PRINTF("#input highlighting is now %so%s%s.\n", + edattrbeg, (attr == NOATTRCODE) ? "ff" : "n", + edattrend); + } + } +} + +static void cmd_history __P1 (char *,arg) +{ + int num = 0; + long buf; + + arg = skipspace(arg); + + if (history_done >= MAX_HIST) { + print_error(error=HISTORY_RECURSION_ERROR); + return; + } + history_done++; + + if (*arg == '(') { + arg++; + num = evall(&buf, &arg); + if (!REAL_ERROR && num != TYPE_NUM) + error=NO_NUM_VALUE_ERROR; + if (REAL_ERROR) { + PRINTF("#history: "); + print_error(error=NO_NUM_VALUE_ERROR); + return; + } + num = (int)buf; + } else + num = atoi(arg); + + if (num > 0) + exe_history(num); + else + show_history(-num); +} + +static void cmd_host __P1 (char *,arg) +{ + char newhost[BUFSIZE]; + + arg = skipspace(arg); + if (*arg) { + arg = split_first_word(newhost, BUFSIZE, arg); + if (*arg) { + my_strncpy(hostname, newhost, BUFSIZE-1); + portnumber = atoi(arg); + if (echo_int) { + PRINTF("#host set to: %s %d\n", hostname, portnumber); + } + } else { + PRINTF("#host: missing portnumber.\n"); + } + } else if (*hostname) + sprintf(inserted_next, "#host %.*s %d", BUFSIZE-INTLEN-8, + hostname, portnumber); + else { + PRINTF("#syntax: #host hostname port\n"); + } +} + +static void cmd_request __P1 (char *,arg) +{ + char *idprompt = "~$#EP2\nG\n"; + char *ideditor = "~$#EI\n"; + char buf[256]; + int all, len; + + if (tcp_fd == -1) { + PRINTF("#not connected to a MUD!\n"); + return; + } + while (*(arg = skipspace(arg))) { + arg = split_first_word(buf, 256, arg); + if (*buf) { + all = !strcmp(buf, "all"); + len = strlen(buf); + if ((all || !strncmp(buf, "editor", len))) { + tcp_raw_write(tcp_fd, ideditor, strlen(ideditor)); + CONN_LIST(tcp_fd).flags |= IDEDITOR; + if (echo_int) { + PRINTF("#request editor: %s done!\n", ideditor); + } + } + if ((all || !strncmp(buf, "prompt", len))) { + tcp_raw_write(tcp_fd, idprompt, strlen(idprompt)); + CONN_LIST(tcp_fd).flags |= IDPROMPT; + if (echo_int) { + PRINTF("#request prompt: %s done!\n", idprompt); + } + } + } + } + +} + +static void cmd_identify __P1 (char *,arg) +{ + edit_start[0] = edit_end[0] = '\0'; + if (*arg) { + char *p = strchr(arg, ' '); + if (p) { + *(p++) = '\0'; + my_strncpy(edit_end, p, BUFSIZE-1); + } + my_strncpy(edit_start, arg, BUFSIZE-1); + } + cmd_request("editor"); +} + +static void cmd_in __P1 (char *,arg) +{ + char *name; + long millisec, buf; + int type; + delaynode **p; + + arg = skipspace(arg); + if (!*arg) { + show_delays(); + return; + } + + arg = first_regular(name = arg, ' '); + if (*arg) + *arg++ = 0; + + unescape(name); + + p = lookup_delay(name, 0); + if (!*p) p = lookup_delay(name, 1); + + if (!*arg && !*p) { + PRINTF("#unknown delay label, cannot show: `%s'\n", name); + return; + } + if (!*arg) { + show_delaynode(*p, 1); + return; + } + if (*arg != '(') { + PRINTF("#in: "); + print_error(error=MISMATCH_PAREN_ERROR); + return; + } + arg++; /* skip the '(' */ + + type = evall(&buf, &arg); + if (!REAL_ERROR) { + if (type!=TYPE_NUM) + error=NO_NUM_VALUE_ERROR; + else if (*arg != ')') + error=MISSING_PAREN_ERROR; + } + if (REAL_ERROR) { + PRINTF("#in: "); + print_error(error); + return; + } + + arg = skipspace(arg+1); + millisec = buf; + if (*p && millisec) + change_delaynode(p, arg, millisec); + else if (!*p && millisec) { + if (*arg) + new_delaynode(name, arg, millisec); + else { + PRINTF("#cannot create delay label without a command.\n"); + } + } else if (*p && !millisec) { + if (echo_int) { + PRINTF("#deleting delay label: %s %s\n", name, (*p)->command); + } + delete_delaynode(p); + } else { + PRINTF("#unknown delay label, cannot delete: `%s'\n", name); + } +} + +static void cmd_at __P1 (char *,arg) +{ + char *name, *buf = NULL; + char dayflag=0; + struct tm *twhen; + int num, hour = -1, minute = -1, second = -1; + delaynode **p; + long millisec; + ptr pbuf = (ptr)0; + + arg = skipspace(arg); + if (!*arg) { + show_delays(); + return; + } + + arg = first_regular(name = arg, ' '); + if (*arg) + *arg++ = 0; + + unescape(name); + + p = lookup_delay(name, 0); + if (!*p) p = lookup_delay(name, 1); + + if (!*arg && !*p) { + PRINTF("#unknown delay label, cannot show: `%s'\n", name); + return; + } + if (!*arg) { + show_delaynode(*p, 2); + return; + } + if (*arg != '(') { + PRINTF("#in: "); + print_error(error=MISMATCH_PAREN_ERROR); + return; + } + arg++; /* skip the '(' */ + + (void)evalp(&pbuf, &arg); + if (REAL_ERROR) { + print_error(error); + ptrdel(pbuf); + return; + } + if (pbuf) { + /* convert time-string into hour, minute, second */ + buf = skipspace(ptrdata(pbuf)); + if (!*buf || !isdigit(*buf)) { + PRINTF("#at: "); + print_error(error=NO_NUM_VALUE_ERROR); + ptrdel(pbuf); + return; + } + num = atoi(buf); + second = num % 100; + minute = (num /= 100) % 100; + hour = num / 100; + } + if (hour < 0 || hour>23 || minute < 0 || minute>59 + || second < 0 || second>59) { + + PRINTF("#at: #error: invalid time `%s'\n", + pbuf && buf ? buf : (char *)""); + error=OUT_RANGE_ERROR; + ptrdel(pbuf); + return; + } + ptrdel(pbuf); + + if (*arg == ')') { /* skip the ')' */ + if (*++arg == ' ') + arg++; + } + else { + PRINTF("#at: "); + print_error(error=MISSING_PAREN_ERROR); + return; + } + + arg = skipspace(arg); + update_now(); + twhen = localtime((time_t *)&now.tv_sec); + /* put current year, month, day in calendar struct */ + + if (hour < twhen->tm_hour || + (hour == twhen->tm_hour && + (minute < twhen->tm_min || + (minute == twhen->tm_min && + second <= twhen->tm_sec)))) { + dayflag = 1; + /* it is NOT possible to define an #at refering to the past */ + } + + /* if you use a time smaller than the current, it refers to tomorrow */ + + millisec = (hour - twhen->tm_hour) * 3600 + (minute - twhen->tm_min) * 60 + + second - twhen->tm_sec + (dayflag ? 24*60*60 : 0); + millisec *= mSEC_PER_SEC; /* Comparing time with current calendar, + we finally got the delay */ + millisec -= now.tv_usec / uSEC_PER_mSEC; + + if (*p) + change_delaynode(p, arg, millisec); + else + if (*arg) + new_delaynode(name, arg, millisec); + else { + PRINTF("#cannot create delay label without a command.\n"); + } +} + +static void cmd_init __P1 (char *,arg) +{ + arg = skipspace(arg); + + if (*arg == '=') { + if (*++arg) { + my_strncpy(initstr, arg, BUFSIZE-1); + if (echo_int) { + PRINTF("#init: %s\n", initstr); + } + } else { + *initstr = '\0'; + if (echo_int) { + PRINTF("#init cleared.\n"); + } + } + } else + sprintf(inserted_next, "#init =%.*s", BUFSIZE-8, initstr); +} + +static void cmd_isprompt __P1 (char *,arg) +{ + if (tcp_fd == tcp_main_fd) { + int i; + long l; + arg = skipspace(arg); + if (*arg == '(') { + arg++; + i = evall(&l, &arg); + if (!REAL_ERROR) { + if (i!=TYPE_NUM) + error=NO_NUM_VALUE_ERROR; + else if (*arg != ')') + error=MISSING_PAREN_ERROR; + } + if (REAL_ERROR) { + PRINTF("#isprompt: "); + print_error(error); + return; + } + i = (int)l; + } else + i = atoi(arg); + + if (i == 0) + surely_isprompt = -1; + else if (i < 0) { + if (i > -NUMPARAM && *VAR[-i].str) + ptrtrunc(prompt->str, surely_isprompt = ptrlen(*VAR[-i].str)); + } else + ptrtrunc(prompt->str, surely_isprompt = i); + } +} + +static void cmd_key __P1 (char *,arg) +{ + keynode *q=NULL; + + arg = skipspace(arg); + if (!*arg) + return; + + if ((q = *lookup_key(arg))) + q->funct(q->call_data); + else { + PRINTF("#no such key: `%s'\n", arg); + } +} + +static void cmd_keyedit __P1 (char *,arg) +{ + int function; + char *param; + + arg = skipspace(arg); + if (!*arg) + return; + + if ((function = lookup_edit_name(arg, ¶m))) + internal_functions[function].funct(param); + else { + PRINTF("#no such editing function: `%s'\n", arg); + } +} + +static void cmd_map __P1 (char *,arg) +{ + arg = skipspace(arg); + if (!*arg) /* show map */ + map_show(); + else if (*arg == '-') /* retrace steps without walking */ + map_retrace(atoi(arg + 1), 0); + else + map_walk(arg, 1, 1); +} + +static void cmd_retrace __P1 (char *,arg) +{ + map_retrace(atoi(arg), 1); +} + +static void cmd_mark __P1 (char *,arg) +{ + if (!*arg) + show_marks(); + else + parse_mark(arg); +} + +static void cmd_nice __P1 (char *,arg) +{ + int nnice = a_nice; + arg = skipspace(arg); + if (!*arg) { + PRINTF("#nice: %d\n", a_nice); + return; + } + if (isdigit(*arg)) { + a_nice = 0; + while (isdigit(*arg)) { + a_nice *= 10; + a_nice += *arg++ - '0'; + } + } + else if (*arg++=='(') { + long buf; + int type; + + type = evall(&buf, &arg); + if (!REAL_ERROR && type!=TYPE_NUM) + error=NO_NUM_VALUE_ERROR; + else if (!REAL_ERROR && *arg++ != ')') + error=MISSING_PAREN_ERROR; + if (REAL_ERROR) { + PRINTF("#nice: "); + print_error(error); + return; + } + a_nice = (int)buf; + if (a_nice<0) + a_nice = 0; + } + arg = skipspace(arg); + if (*arg) { + parse_instruction(arg, 0, 0, 1); + a_nice = nnice; + } +} + +static void cmd_prefix __P1 (char *,arg) +{ + strcpy(prefixstr, arg); + if (echo_int) { + PRINTF("#prefix %s.\n", *arg ? "set" : "cleared"); + } +} + +static void cmd_quote __P1 (char *,arg) +{ + arg = skipspace(arg); + if (!*arg) + verbatim ^= 1; + else if (!strcmp(arg, "on")) + verbatim = 1; + else if (!strcmp(arg, "off")) + verbatim = 0; + if (echo_int) { + PRINTF("#%s mode.\n", verbatim ? "verbatim" : "normal"); + } +} + +/* + * change the escape sequence of an existing binding + */ +static void cmd_rebind __P1 (char *,arg) +{ + parse_rebind(arg); +} + +static void cmd_rebindall __P1 (char *,arg) +{ + keynode *kp; + char *seq; + + for (kp = keydefs; kp; kp = kp->next) { + seq = kp->sequence; + if (kp->seqlen == 1 && seq[0] < ' ') + ; + else if (kp->seqlen == 2 && seq[0] == '\033' && isalnum(seq[1])) + ; + else { + parse_rebind(kp->name); + if (error) + break; + } + } +} + +static void cmd_rebindALL __P1 (char *,arg) +{ + keynode *kp; + + for (kp = keydefs; kp; kp = kp->next) { + parse_rebind(kp->name); + if (error) + break; + } +} + +static void cmd_reset __P1 (char *,arg) +{ + char all = 0; + arg = skipspace(arg); + if (!*arg) { + PRINTF("#reset: must specify one of:\n"); + tty_puts(" alias, action, bind, in (or at), mark, prompt, var, all.\n"); + return; + } + all = !strcmp(arg, "all"); + if (all || !strcmp(arg, "alias")) { + int n; + for (n = 0; n < MAX_HASH; n++) { + while (aliases[n]) + delete_aliasnode(&aliases[n]); + } + if (!all) + return; + } + if (all || !strcmp(arg, "action")) { + while (actions) + delete_actionnode(&actions); + if (!all) + return; + } + if (all || !strcmp(arg, "bind")) { + while (keydefs) + delete_keynode(&keydefs); + tty_add_initial_binds(); + tty_add_walk_binds(); + if (!all) + return; + } + if (all || !strcmp(arg, "in") || !strcmp(arg, "at")) { + while (delays) + delete_delaynode(&delays); + while (dead_delays) + delete_delaynode(&dead_delays); + if (!all) + return; + } + if (all || !strcmp(arg, "mark")) { + while (markers) + delete_marknode(&markers); + if (!all) + return; + } + if (all || !strcmp(arg, "prompt")) { + while (prompts) + delete_promptnode(&prompts); + if (!all) + return; + } + if (all || !strcmp(arg, "var")) { + int n; + varnode **first; + + for (n = 0; n < MAX_HASH; n++) { + while (named_vars[0][n]) + delete_varnode(&named_vars[0][n], 0); + first = &named_vars[1][n]; + while (*first) { + if (is_permanent_variable(*first)) + first = &(*first)->next; + else + delete_varnode(first, 1); + } + } + + for (n = 0; n < NUMVAR; n++) { + *var[n].num = 0; + ptrdel(*var[n].str); + *var[n].str = NULL; + } + if (!all) + return; + } +} + +static void cmd_snoop __P1 (char *,arg) +{ + if (!*arg) { + PRINTF("#snoop: which connection?\n"); + } else + tcp_togglesnoop(arg); +} + +static void cmd_stop __P1 (char *,arg) +{ + delaynode *dying; + + if (delays) + update_now(); + + while (delays) { + dying = delays; + delays = dying->next; + dying->when.tv_sec = now.tv_sec; + dying->when.tv_usec = now.tv_usec; + dying->next = dead_delays; + dead_delays = dying; + } + if (echo_int) { + PRINTF("#all delayed labels are now disabled.\n"); + } +} + +static void cmd_time __P1 (char *,arg) +{ + struct tm *s; + char buf[BUFSIZE]; + + update_now(); + s = localtime((time_t *)&now.tv_sec); + (void)strftime(buf, BUFSIZE - 1, "%a, %d %b %Y %H:%M:%S", s); + PRINTF("#current time is %s\n", buf); +} + +static void cmd_ver __P1 (char *,arg) +{ + printver(); +} + +static void cmd_emulate __P1 (char *,arg) +{ + char kind; + FILE *fp; + long start, end, i = 1; + int len; + ptr pbuf = (ptr)0; + + arg = redirect(arg, &pbuf, &kind, "emulate", 0, &start, &end); + if (REAL_ERROR || !arg) + return; + + if (kind) { + char buf[BUFSIZE]; + + fp = (kind == '!') ? popen(arg, "r") : fopen(arg, "r"); + if (!fp) { + PRINTF("#emulate: #error opening `%s'\n", arg); + print_error(error=SYNTAX_ERROR); + ptrdel(pbuf); + return; + } + status(-1); /* we're pretending we got something from the MUD */ + while (!error && (!start || i<=end) && fgets(buf, BUFSIZE, fp)) + if (!start || i++>=start) + process_remote_input(buf, strlen(buf)); + + if (kind == '!') pclose(fp); else fclose(fp); + } else { + status(-1); /* idem */ + /* WARNING: no guarantee there is space! */ + arg[len = strlen(arg)] = '\n'; + arg[++len] = '\0'; + process_remote_input(arg, len); + } + ptrdel(pbuf); +} + +static void cmd_eval __P1 (char *,arg) +{ + arg = skipspace(arg); + if (*arg=='(') { + arg++; + (void)evaln(&arg); + if (*arg != ')') { + PRINTF("#(): "); + print_error(error=MISSING_PAREN_ERROR); + } + } + else { + PRINTF("#(): "); + print_error(error=MISMATCH_PAREN_ERROR); + } +} + +static void cmd_exe __P1 (char *,arg) +{ + char kind; + long start, end, i = 1; + FILE *fp; + ptr pbuf = (ptr)0; + + arg = redirect(arg, &pbuf, &kind, "exe", 0, &start, &end); + if (REAL_ERROR || !arg) + return; + + if (kind) { + char buf[BUFSIZE]; + + fp = (kind == '!') ? popen(arg, "r") : fopen(arg, "r"); + if (!fp) { + PRINTF("#exe: #error opening `%s'\n", arg); + error = SYNTAX_ERROR; + ptrdel(pbuf); + return; + } + while (!error && (!start || i<=end) && fgets(buf, BUFSIZE, fp)) + if (!start || i++>=start) { + buf[strlen(buf)-1] = '\0'; + parse_user_input(buf, 0); + } + + if (kind == '!') pclose(fp); else fclose(fp); + } else + parse_user_input(arg, 0); + ptrdel(pbuf); +} + +static void cmd_print __P1 (char *,arg) +{ + char kind; + long start, end, i = 1; + FILE *fp; + ptr pbuf = (ptr)0; + + clear_input_line(opt_compact); + + if (!*arg) { + smart_print(*VAR[0].str ? ptrdata(*VAR[0].str) : (char *)"", 1); + return; + } + + arg = redirect(arg, &pbuf, &kind, "print", 1, &start, &end); + if (REAL_ERROR || !arg) + return; + + if (kind) { + char buf[BUFSIZE]; + fp = (kind == '!') ? popen(arg, "r") : fopen(arg, "r"); + if (!fp) { + PRINTF("#print: #error opening `%s'\n", arg); + error=SYNTAX_ERROR; + ptrdel(pbuf); + return; + } + while (!error && (!start || i <= end) && fgets(buf, BUFSIZE, fp)) + if (!start || i++>=start) + tty_puts(buf); + tty_putc('\n'); + + if (kind == '!') pclose(fp); else fclose(fp); + } else + smart_print(arg, 1); + ptrdel(pbuf); +} + +static void cmd_send __P1 (char *,arg) +{ + char *newline, kind; + long start, end, i = 1; + FILE *fp; + ptr pbuf = (ptr)0; + + arg = redirect(arg, &pbuf, &kind, "send", 0, &start, &end); + if (REAL_ERROR ||!arg) + return; + + if (kind) { + char buf[BUFSIZE]; + fp = (kind == '!') ? popen(arg, "r") : fopen(arg, "r"); + if (!fp) { + PRINTF("#send: #error opening `%s'\n", arg); + error = SYNTAX_ERROR; + ptrdel(pbuf); + return; + } + while (!error && (!start || i<=end) && fgets(buf, BUFSIZE, fp)) { + if ((newline = strchr(buf, '\n'))) + *newline = '\0'; + + if (!start || i++>=start) { + if (echo_ext) { + PRINTF("[%s]\n", buf); + } + tcp_write(tcp_fd, buf); + } + } + if (kind == '!') pclose(fp); else fclose(fp); + } else { + if (echo_ext) { + PRINTF("[%s]\n", arg); + } + tcp_write(tcp_fd, arg); + } + ptrdel(pbuf); +} + +static void cmd_rawsend __P1 (char *,arg) +{ + char *tmp = skipspace(arg); + + if (*tmp=='(') { + ptr pbuf = (ptr)0; + arg = tmp + 1; + (void)evalp(&pbuf, &arg); + if (REAL_ERROR) { + print_error(error); + ptrdel(pbuf); + } else if (pbuf) + tcp_raw_write(tcp_fd, ptrdata(pbuf), ptrlen(pbuf)); + } else { + int len; + if ((len = memunescape(arg, strlen(arg)))) + tcp_raw_write(tcp_fd, arg, len); + } +} + +static void cmd_rawprint __P1 (char *,arg) +{ + char *tmp = skipspace(arg); + + if (*tmp=='(') { + ptr pbuf = (ptr)0; + arg = tmp + 1; + (void)evalp(&pbuf, &arg); + if (REAL_ERROR) { + print_error(error); + ptrdel(pbuf); + } else if (pbuf) + tty_raw_write(ptrdata(pbuf), ptrlen(pbuf)); + } else { + int len; + if ((len = memunescape(arg, strlen(arg)))) + tty_raw_write(arg, len); + } +} + + +static void cmd_write __P1 (char *,arg) +{ + ptr p1 = (ptr)0, p2 = (ptr)0; + char *tmp = skipspace(arg), kind; + FILE *fp; + + kind = *tmp; + if (kind == '!' || kind == '>') + arg = ++tmp; + else + kind = 0; + + if (*tmp=='(') { + arg = tmp + 1; + (void)evalp(&p1, &arg); + if (REAL_ERROR) + goto write_cleanup; + + if (*arg == CMDSEP) { + arg++; + (void)evalp(&p2, &arg); + if (!REAL_ERROR && !p2) + error = NO_STRING_ERROR; + if (REAL_ERROR) + goto write_cleanup; + } else { + PRINTF("#write: "); + error=SYNTAX_ERROR; + goto write_cleanup; + } + if (*arg != ')') { + PRINTF("#write: "); + error=MISSING_PAREN_ERROR; + goto write_cleanup; + } + arg = ptrdata(p2); + + fp = (kind == '!') ? popen(arg, "w") : fopen(arg, kind ? "w" : "a"); + if (!fp) { + PRINTF("#write: #error opening `%s'\n", arg); + error=SYNTAX_ERROR; + goto write_cleanup2; + } + fprintf(fp, "%s\n", p1 ? ptrdata(p1) : (char *)""); + fflush(fp); + if (kind == '!') pclose(fp); else fclose(fp); + } else { + PRINTF("#write: "); + error=MISMATCH_PAREN_ERROR; + } + +write_cleanup: + if (REAL_ERROR) + print_error(error); +write_cleanup2: + ptrdel(p1); + ptrdel(p2); +} + +static void cmd_var __P1 (char *,arg) +{ + char *buf, *expr, *tmp, kind, type, right = 0, deleting = 0; + varnode **p_named_var = NULL, *named_var = NULL; + FILE *fp; + long start, end, i = 1; + int len, idx; + ptr pbuf = (ptr)0; + + arg = skipspace(arg); + expr = first_regular(arg, '='); + + if (*expr) { + *expr++ = '\0'; /* skip the = */ + if (!*expr) + deleting = 1; + else { + right = 1; + if (*expr == ' ') + expr++; + } + } + + if (*arg == '$') + type = TYPE_TXT_VAR; + else if (*arg == '@') + type = TYPE_NUM_VAR; + else if (*arg) { + print_error(error=INVALID_NAME_ERROR); + return; + } else { + show_vars(); + return; + } + + kind = *++arg; + if (isalpha(kind) || kind == '_') { + /* found a named variable */ + tmp = arg; + while (*tmp && (isalnum(*tmp) || *tmp == '_')) + tmp++; + if (*tmp) { + print_error(error=INVALID_NAME_ERROR); + return; + } + kind = type==TYPE_TXT_VAR ? 1 : 0; + p_named_var = lookup_varnode(arg, kind); + if (!*p_named_var) { + /* it doesn't (yet) exist */ + if (!deleting) { + /* so create it */ + named_var = add_varnode(arg, kind); + if (REAL_ERROR) + return; + if (echo_int) { + PRINTF("#new variable: `%s'\n", arg - 1); + } + } else { + print_error(error=UNDEFINED_VARIABLE_ERROR); + return; + } + } else + /* it exists, hold on */ + named_var = *p_named_var; + + idx = named_var->index; + } else { + /* not a named variable, may be + * an unnamed variable or an expression */ + kind = type==TYPE_TXT_VAR ? 1 : 0; + tmp = skipspace(arg); + if (*tmp == '(') { + /* an expression */ + arg = tmp+1; + idx = evalp(&pbuf, &arg); + if (!REAL_ERROR && idx != TYPE_TXT) + error=NO_STRING_ERROR; + if (REAL_ERROR) { + PRINTF("#var: "); + print_error(error); + ptrdel(pbuf); + return; + } + if (pbuf) + buf = ptrdata(pbuf); + else + buf = ""; + if (isdigit(*buf)) { + idx = atoi(buf); + if (idx < -NUMVAR || idx >= NUMPARAM) { + print_error(error=OUT_RANGE_ERROR); + ptrdel(pbuf); + return; + } + } else { + if (!(named_var = *lookup_varnode(buf, kind))) { + if (!deleting) { + named_var = add_varnode(buf, kind); + if (REAL_ERROR) { + print_error(error); + ptrdel(pbuf); + return; + } + if (echo_int) { + PRINTF("#new variable: %c%s\n", kind + ? '$' : '@', buf); + } + } else { + print_error(error=UNDEFINED_VARIABLE_ERROR); + ptrdel(pbuf); + return; + } + } + idx = named_var->index; + } + } else { + /* an unnamed var */ + long buf2; + + idx = evall(&buf2, &arg); + if (!REAL_ERROR && idx != TYPE_NUM) + error=NO_STRING_ERROR; + if (REAL_ERROR) { + PRINTF("#var: "); + print_error(error); + return; + } + idx = (int)buf2; + if (idx < -NUMVAR || idx >= NUMPARAM) { + print_error(error=OUT_RANGE_ERROR); + return; + } + /* ok, it's an unnamed var */ + } + } + + + if (type == TYPE_TXT_VAR && right && !*VAR[idx].str) { + /* create it */ + *VAR[idx].str = ptrnew(PARAMLEN); + if (MEM_ERROR) { + print_error(error); + ptrdel(pbuf); + return; + } + } + + if (deleting) { + /* R.I.P. named variables */ + if (named_var) { + if (is_permanent_variable(named_var)) { + PRINTF("#cannot delete variable: `%s'\n", arg - 1); + } else { + delete_varnode(p_named_var, kind); + if (echo_int) { + PRINTF("#deleted variable: `%s'\n", arg - 1); + } + } + } else if ((type = TYPE_TXT_VAR)) { + /* R.I.P. unnamed variables */ + if (*VAR[idx].str) { + if (idx < 0) { + ptrdel(*VAR[idx].str); + *VAR[idx].str = 0; + } else + ptrzero(*VAR[idx].str); + } + } else + *VAR[idx].num = 0; + ptrdel(pbuf); + return; + } else if (!right) { + /* no right-hand expression, just show */ + if (named_var) { + if (type == TYPE_TXT_VAR) { + pbuf = ptrescape(pbuf, *VAR[idx].str, 0); + if (REAL_ERROR) { + print_error(error); + ptrdel(pbuf); + return; + } + sprintf(inserted_next, "#($%.*s = \"%.*s\")", + BUFSIZE - 10, named_var->name, + BUFSIZE - (int)strlen(named_var->name) - 10, + pbuf ? ptrdata(pbuf) : (char *)""); + } else { + sprintf(inserted_next, "#(@%.*s = %ld)", + BUFSIZE - 8, named_var->name, + *VAR[idx].num); + } + } else { + if (type == TYPE_TXT_VAR) { + pbuf = ptrescape(pbuf, *VAR[idx].str, 0); + sprintf(inserted_next, "#($%d = \"%.*s\")", idx, + BUFSIZE - INTLEN - 10, + pbuf ? ptrdata(pbuf) : (char *)""); + } else { + sprintf(inserted_next, "#(@%d = %ld)", idx, + *VAR[idx].num); + } + } + ptrdel(pbuf); + return; + } + + /* only case left: assign a value to a variable */ + arg = redirect(expr, &pbuf, &kind, "var", 1, &start, &end); + if (REAL_ERROR || !arg) + return; + + if (kind) { + char buf2[BUFSIZE]; + fp = (kind == '!') ? popen(arg, "r") : fopen(arg, "r"); + if (!fp) { + PRINTF("#var: #error opening `%s'\n", arg); + error=SYNTAX_ERROR; + ptrdel(pbuf); + return; + } + len = 0; + i = 1; + while (!error && (!start || i<=end) && fgets(buf2+len, BUFSIZE-len, fp)) + if (!start || i++>=start) + len += strlen(buf2 + len); + + if (kind == '!') pclose(fp); else fclose(fp); + if (len>PARAMLEN) + len = PARAMLEN; + buf2[len] = '\0'; + arg = buf2; + } + + if (type == TYPE_NUM_VAR) { + arg = skipspace(arg); + type = 1; + len = 0; + + if (*arg == '-') + arg++, type = -1; + else if (*arg == '+') + arg++; + + if (isdigit(kind=*arg)) while (isdigit(kind)) { + len*=10; + len+=(kind-'0'); + kind=*++arg; + } + else { + PRINTF("#var: "); + print_error(error=NO_NUM_VALUE_ERROR); + } + *VAR[idx].num = len * type; + } + else { + *VAR[idx].str = ptrmcpy(*VAR[idx].str, arg, strlen(arg)); + if (MEM_ERROR) + print_error(error); + } + ptrdel(pbuf); +} + +static void cmd_setvar __P1 (char *,arg) +{ + char *name; + int i, func = 0; /* show */ + long buf; + + name = arg = skipspace(arg); + arg = first_regular(arg, '='); + if (*arg) { + *arg++ = '\0'; + if (*arg) { + func = 1; /* set */ + if (*arg == '(') { + arg++; + i = evall(&buf, &arg); + if (!REAL_ERROR && i != TYPE_NUM) + error=NO_NUM_VALUE_ERROR; + else if (!REAL_ERROR && *arg != ')') + error=MISSING_PAREN_ERROR; + } else + buf = strtol(arg, NULL, 0); + } else + buf = 0; + + if (REAL_ERROR) { + PRINTF("#setvar: "); + print_error(error); + return; + } + } + + i = strlen(name); + if (i && !strncmp(name, "timer", i)) { + vtime t; + update_now(); + if (func == 0) + sprintf(inserted_next, "#setvar timer=%ld", + diff_vtime(&now, &ref_time)); + else { + t.tv_usec = ((-buf) % mSEC_PER_SEC) * uSEC_PER_mSEC; + t.tv_sec = (-buf) / mSEC_PER_SEC; + ref_time.tv_usec = now.tv_usec; + ref_time.tv_sec = now.tv_sec; + add_vtime(&ref_time, &t); + } + } + else if (i && !strncmp(name, "lines", i)) { + if (func == 0) + sprintf(inserted_next, "#setvar lines=%d", lines); + else { + if (buf > 0) + lines = (int)buf; + if (echo_int) { + PRINTF("#setvar: lines=%d\n", lines); + } + } + } + else if (i && !strncmp(name, "mem", i)) { + if (func == 0) + sprintf(inserted_next, "#setvar mem=%d", limit_mem); + else { + if (buf == 0 || buf >= PARAMLEN) + limit_mem = buf <= INT_MAX ? (int)buf : INT_MAX; + if (echo_int) { + PRINTF("#setvar: mem=%d%s\n", limit_mem, + limit_mem ? "" : " (unlimited)"); + } + } + } + else if (i && !strncmp(name, "buffer", i)) { + if (func == 0) + sprintf(inserted_next, "#setvar buffer=%d", log_getsize()); + else + log_resize(buf); + } else { + update_now(); + PRINTF("#setvar buffer=%d\n#setvar lines=%d\n#setvar mem=%d\n#setvar timer=%ld\n", + log_getsize(), lines, limit_mem, diff_vtime(&now, &ref_time)); + } +} + +static void cmd_if __P1 (char *,arg) +{ + long buf; + int type; + + arg = skipspace(arg); + if (*arg!='(') { + PRINTF("#if: "); + print_error(error=MISMATCH_PAREN_ERROR); + return; + } + arg++; /* skip the '(' */ + + type = evall(&buf, &arg); + if (!REAL_ERROR) { + if (type!=TYPE_NUM) + error=NO_NUM_VALUE_ERROR; + if (*arg != ')') + error=MISSING_PAREN_ERROR; + else { /* skip the ')' */ + if (*++arg == ' ') + arg++; + } + } + if (REAL_ERROR) { + PRINTF("#if: "); + print_error(error); + return; + } + + if (buf) + (void)parse_instruction(arg, 0, 0, 1); + else { + arg = get_next_instr(arg); + if (!strncmp(arg = skipspace(arg), "#else ", 6)) + (void)parse_instruction(arg + 6, 0, 0, 1); + } +} + +static void cmd_for __P1 (char *,arg) +{ + int type = TYPE_NUM, loop=MAX_LOOP; + long buf; + char *check, *tmp, *increm = 0; + + arg = skipspace(arg); + if (*arg != '(') { + PRINTF("#for: "); + print_error(error=MISMATCH_PAREN_ERROR); + return; + } + push_params(); + if (REAL_ERROR) + return; + + arg = skipspace(arg + 1); /* skip the '(' */ + if (*arg != CMDSEP) + (void)evaln(&arg); /* execute <init> */ + + check = arg + 1; + + if (REAL_ERROR) + ; + else if (*arg != CMDSEP) { + PRINTF("#for: "); + print_error(error=MISSING_SEPARATOR_ERROR); + } + else while (!error && loop + && (increm=check, (type = evall(&buf, &increm)) == TYPE_NUM + && !error && *increm == CMDSEP && buf)) { + + tmp = first_regular(increm + 1, ')'); + if (*tmp) + (void)parse_instruction(tmp + 1, 1, 1, 1); + else { + PRINTF("#for: "); + print_error(error=MISSING_PAREN_ERROR); + } + + if (!error) { + tmp = increm + 1; + if (*tmp != ')') + (void)evaln(&tmp); + } + + loop--; + } + if (REAL_ERROR) + ; + else if (increm && *increm != CMDSEP) + error=MISSING_SEPARATOR_ERROR; + else if (!loop) + error=MAX_LOOP_ERROR; + else if (type != TYPE_NUM) + error=NO_NUM_VALUE_ERROR; + if (REAL_ERROR) { + PRINTF("#for: "); + print_error(error); + } + if (error!=DYN_STACK_UND_ERROR && error!=DYN_STACK_OV_ERROR) + pop_params(); +} + +static void cmd_while __P1 (char *,arg) +{ + int type = TYPE_NUM, loop=MAX_LOOP; + long buf; + char *check, *tmp; + + arg = skipspace(arg); + if (!*arg) { + PRINTF("#while: "); + print_error(error=MISMATCH_PAREN_ERROR); + return; + } + push_params(); + + check = ++arg; /* skip the '(' */ + while (!error && loop + && (arg=check, (type = evall(&buf, &arg)) == TYPE_NUM && + !error && *arg == ')' && buf)) { + + if (*(tmp = arg + 1) == ' ') /* skip the ')' */ + tmp++; + if (*tmp) + (void)parse_instruction(tmp, 1, 1, 1); + loop--; + } + if (REAL_ERROR) + ; + else if (*arg != ')') + error=MISSING_PAREN_ERROR; + else if (!loop) + error=MAX_LOOP_ERROR; + else if (type != TYPE_NUM) + error=NO_NUM_VALUE_ERROR; + if (REAL_ERROR) { + PRINTF("#while: "); + print_error(error); + } + if (error!=DYN_STACK_UND_ERROR && error!=DYN_STACK_OV_ERROR) + pop_params(); +} + +static void cmd_capture __P1 (char *,arg) +{ + arg = skipspace(arg); + + if (!*arg) { + if (capturefile) { + log_flush(); + fclose(capturefile); + capturefile = NULL; + if (echo_int) { + PRINTF("#end of capture to file.\n"); + } + } else { + PRINTF("#capture to what file?\n"); + } + } else { + if (capturefile) { + PRINTF("#capture already active.\n"); + } else { + short append = 0; + /* Append to log file, if the name starts with '>' */ + if (*arg == '>') { + arg++; + append = 1; + } + if ((capturefile = fopen(arg, (append) ? "a" : "w")) == NULL) { + PRINTF("#error writing file `%s'\n", arg); + } else if (echo_int) { + PRINTF("#capture to `%s' active, `#capture' ends.\n", arg); + } + } + } +} + +static void cmd_movie __P1 (char *,arg) +{ + arg = skipspace(arg); + + if (!*arg) { + if (moviefile) { + log_flush(); + fclose(moviefile); + moviefile = NULL; + if (echo_int) { + PRINTF("#end of movie to file.\n"); + } + } else { + PRINTF("#movie to what file?\n"); + } + } else { + if (moviefile) { + PRINTF("#movie already active.\n"); + } else { + if ((moviefile = fopen(arg, "w")) == NULL) { + PRINTF("#error writing file `%s'\n", arg); + } else { + if (echo_int) { + PRINTF("#movie to `%s' active, `#movie' ends.\n", arg); + } + update_now(); + movie_last = now; + log_clearsleep(); + } + } + } +} + +static void cmd_record __P1 (char *,arg) +{ + arg = skipspace(arg); + + if (!*arg) { + if (recordfile) { + fclose(recordfile); + recordfile = NULL; + if (echo_int) { + PRINTF("#end of record to file.\n"); + } + } else { + PRINTF("#record to what file?\n"); + } + } else { + if (recordfile) { + PRINTF("#record already active.\n"); + } else { + if ((recordfile = fopen(arg, "w")) == NULL) { + PRINTF("#error writing file `%s'\n", arg); + } else if (echo_int) { + PRINTF("#record to `%s' active, `#record' ends.\n", arg); + } + } + } +} + +static void cmd_edit __P1 (char *,arg) +{ + editsess *sp; + + if (edit_sess) { + for (sp = edit_sess; sp; sp = sp->next) { + PRINTF("# %s (%u)\n", sp->descr, sp->key); + } + } else { + PRINTF("#no active editors.\n"); + } +} + +static void cmd_cancel __P1 (char *,arg) +{ + editsess *sp; + + if (!edit_sess) { + PRINTF("#no editing sessions to cancel.\n"); + } else { + if (*arg) { + for (sp = edit_sess; sp; sp = sp->next) + if (strtoul(arg, NULL, 10) == sp->key) { + cancel_edit(sp); + break; + } + if (!sp) { + PRINTF("#unknown editing session %d\n", atoi(arg)); + } + } else { + if (edit_sess->next) { + PRINTF("#several editing sessions active, use #cancel <number>\n"); + } else + cancel_edit(edit_sess); + } + } +} + +static void cmd_net __P1 (char *,arg) +{ + PRINTF("#received from host: %ld chars, sent to host: %ld chars.\n", + received, sent); +} + + +#ifndef CLOCKS_PER_SEC +# define CLOCKS_PER_SEC uSEC_PER_SEC +#endif +/* hope it works.... */ + +static void cmd_cpu __P1 (char *,arg) +{ + float f, l; + update_now(); + f = (float)((cpu_clock = clock()) - start_clock) / (float)CLOCKS_PER_SEC; + l = (float)(diff_vtime(&now, &start_time)) / (float)mSEC_PER_SEC; + PRINTF("#CPU time used: %.3f sec. (%.2f%%)\n", f, + (l > 0 && l > f) ? f * 100.0 / l : 100.0); +} + +void show_stat __P0 (void) +{ + cmd_net(NULL); + cmd_cpu(NULL); +} + +#ifdef BUG_TELNET +static void cmd_color __P1 (char *,arg) +{ + int attrcode; + + arg = skipspace(arg); + if (!*arg) { + strcpy(tty_modenorm, tty_modenormbackup); + tty_puts(tty_modenorm); + if (echo_int) { + PRINTF("#standard color cleared.\n"); + } + return; + } + + attrcode = parse_attributes(arg); + if (attrcode == -1) { + PRINTF("#invalid attribute syntax.\n"); + if (echo_int) + show_attr_syntax(); + } else { + int bg = BACKGROUND(attrcode), fg = FOREGROUND(attrcode); + if (fg >= COLORS || bg >= COLORS) { + PRINTF("#please specify foreground and background colors.\n"); + } else { + sprintf(tty_modenorm, "\033[;%c%d;%s%dm", + fg<LOWCOLORS ? '3' : '9', fg % LOWCOLORS, + bg<LOWCOLORS ? "4" :"10", bg % LOWCOLORS); + tty_puts(tty_modenorm); + if (echo_int) { + PRINTF("#standard colour set.\n"); + } + } + } +} +#endif + +static void cmd_connect __P1 (char *,arg) +{ +#ifdef TERM + PRINTF("#connect: multiple connections not supported in term version.\n"); +#else + char *s1, *s2, *s3 = NULL, *s4 = NULL; + int argc = 1; + + if (!*skipspace(arg)) { + tcp_show(); + return; + } + else { + s1 = strtok(arg, " "); + s2 = strtok(NULL, " "); + if (s2 && *s2) { + argc++; + s3 = strtok(NULL, " "); + if (s3 && *s3) { + argc++; + s4 = strtok(NULL, " "); + if (s4 && *s4) + argc++; + } + } + } + + if (argc <= 2) { + if (*hostname) + tcp_open(s1, s2, hostname, portnumber); + else { + PRINTF("#connect: no host defined!\n#syntax: #connect session-id [[init-str] [hostname] [port]]\n"); + } + } else if (argc == 3) { + if (!*hostname) { + my_strncpy(hostname, s2, BUFSIZE-1); + portnumber = atoi(s3); + } + tcp_open(s1, NULL, s2, atoi(s3)); + } else { + if (!*hostname) { + my_strncpy(hostname, s3, BUFSIZE-1); + portnumber = atoi(s4); + } + tcp_open(s1, s2, s3, atoi(s4)); + } +#endif /* TERM */ +} + + +static void cmd_spawn __P1 (char *,arg) +{ + char s[BUFSIZE]; + if (*(arg = skipspace(arg))) { + arg = split_first_word(s, BUFSIZE, arg); + if (*arg && *s) { + tcp_spawn(s, arg); + return; + } + } + PRINTF("#syntax: #spawn connect-id command\n"); +} + +static void cmd_zap __P1 (char *,arg) +{ + if (!*arg) { + PRINTF("#zap: no connection name.\n"); + } else + tcp_close(arg); +} + +static void cmd_qui __P1 (char *,arg) +{ + PRINTF("#you have to write '#quit' - no less, to quit!\n"); +} + +static void cmd_quit __P1 (char *,arg) +{ + if (*arg) { /* no skipspace() here! */ + PRINTF("#quit: spurious argument?\n"); + } else + exit_powwow(); +} + +char *full_options_string = "#option %cexit %chistory %cwords %ccompact %cdebug %cecho %cinfo %ckeyecho %cspeedwalk\n#option %cwrap %cautoprint %creprint %csendsize %cautoclear%s"; + +static void cmd_option __P1 (char *,arg) +{ + if (*(arg = skipspace(arg))) { + int len, i, count = 0; + static char *str[] = { "exit", "history", "words", + "compact", "debug", "echo", "info", "keyecho", + "speedwalk", "wrap", "autoprint", "reprint", + "sendsize", "autoclear", 0 }; + static char *varptr[] = { &opt_exit, &opt_history, &opt_words, + &opt_compact, &opt_debug, &echo_ext, &echo_int, &echo_key, + &opt_speedwalk, &opt_wrap, &opt_autoprint, &opt_reprint, + &opt_sendsize, &opt_autoclear, 0 }; + enum { MODE_ON, MODE_OFF, MODE_TOGGLE, MODE_REP } mode; + char buf[BUFSIZE], *p, *varp, c; + while ((arg = skipspace(split_first_word(buf, BUFSIZE, arg))), *buf) { + c = *(p = buf); + switch (c) { + case '=': mode = MODE_REP; p++; break; + case '+': mode = MODE_ON; p++; break; + case '-': mode = MODE_OFF; p++; break; + default: mode = MODE_TOGGLE; break; + } + len = strlen(p); + varp = 0; + count++; + for (i=0; str[i]; i++) { + if (strncmp(str[i], p, len) == 0) { + varp = varptr[i]; + break; + } + } + if (!str[i]) { + if (strncmp("none", p, len) == 0) + continue; + else { + PRINTF("#syntax: #option [[+|-|=]<name>]\t\twhere <name> is one of:\n\ +exit history words compact debug echo info\n\ +keyecho speedwalk wrap autoprint reprint sendsize autoclear\n"); + return; + } + } + if (varp) { + switch (mode) { + case MODE_REP: + sprintf(inserted_next, "#option %c", *varp ? '+' : '-'); + strcat(inserted_next, p); + break; + case MODE_ON: *varp = 1; break; + case MODE_OFF: *varp = 0; break; + default: *varp ^= 1; break; + } + /* + * reset the reprint buffer if changing its status + */ + if (varp == &opt_reprint) + reprint_clear(); + + /* as above, but always print status if + * `#option info' alone was typed */ + if (mode != MODE_REP && !*arg && count==1 && + (echo_int || (mode == MODE_TOGGLE && varp==&echo_int))) { + PRINTF("#option %s is now o%s.\n", str[i], + *varp ? "n" : "ff"); + } + } + } + } else { + PRINTF(full_options_string, + opt_exit ? '+' : '-', + opt_history ? '+' : '-', + opt_words ? '+' : '-', + opt_compact ? '+' : '-', + opt_debug ? '+' : '-', + echo_ext ? '+' : '-', + echo_int ? '+' : '-', + echo_key ? '+' : '-', + opt_speedwalk ? '+' : '-', + opt_wrap ? '+' : '-', + opt_autoprint ? '+' : '-', + opt_reprint ? '+' : '-', + opt_sendsize ? '+' : '-', + opt_autoclear ? '+' : '-', + "\n"); + } +} + +static void cmd_file __P1 (char *,arg) +{ + arg = skipspace(arg); + if (*arg == '=') { + set_deffile(++arg); + if (echo_int) { + if (*arg) { + PRINTF("#save-file set to `%s'\n", deffile); + } else { + PRINTF("#save-file is now undefined.\n"); + } + } + } else if (*deffile) { + sprintf(inserted_next, "#file =%.*s", BUFSIZE-8, deffile); + } else { + PRINTF("#save-file not defined.\n"); + } +} + +static void cmd_save __P1 (char *,arg) +{ + arg = skipspace(arg); + if (*arg) { + set_deffile(arg); + if (echo_int) { + PRINTF("#save-file set to `%s'\n", deffile); + } + } else if (!*deffile) { + PRINTF("#save-file not defined.\n"); + return; + } + + if (*deffile && save_settings() > 0 && echo_int) { + PRINTF("#settings saved to file.\n"); + } +} + +static void cmd_load __P1 (char *,arg) +{ + int res; + + arg = skipspace(arg); + if (*arg) { + set_deffile(arg); + if (echo_int) { + PRINTF("#save-file set to `%s'\n", deffile); + } + } + else if (!*deffile) { + PRINTF("#save-file not defined.\n"); + return; + } + + res = read_settings(); + + if (res > 0) { + /* success */ + if (echo_int) { + PRINTF("#settings loaded from file.\n"); + } + } else if (res < 0) { + /* critical error */ + while (keydefs) + delete_keynode(&keydefs); + tty_add_initial_binds(); + tty_add_walk_binds(); + limit_mem = 1048576; + PRINTF("#emergency loaded default settings.\n"); + } +} + +static char *trivial_eval __P3 (ptr *,pbuf, char *,arg, char *,name) +{ + char *tmp = skipspace(arg); + + if (!pbuf) + return NULL; + + if (*tmp=='(') { + arg = tmp + 1; + (void)evalp(pbuf, &arg); + if (!REAL_ERROR && *arg != ')') + error=MISSING_PAREN_ERROR; + if (REAL_ERROR) { + PRINTF("#%s: ", name); + print_error(error); + return NULL; + } + if (*pbuf) + arg = ptrdata(*pbuf); + else + arg = ""; + } + else + unescape(arg); + + return arg; +} + +static void cmd_add __P1 (char *,arg) +{ + ptr pbuf = (ptr)0; + char buf[BUFSIZE]; + + arg = trivial_eval(&pbuf, arg, "add"); + if (!REAL_ERROR) + while (*arg) { + arg = split_first_word(buf, BUFSIZE, arg); + if (strlen(buf) >= MIN_WORDLEN) + put_word(buf); + } + ptrdel(pbuf); +} + +static void cmd_put __P1 (char *,arg) +{ + ptr pbuf = (ptr)0; + arg = trivial_eval(&pbuf, arg, "put"); + if (!REAL_ERROR && *arg) + put_history(arg); + ptrdel(pbuf); +} + + @@ -0,0 +1,21 @@ +/* public things from cmd.c */ + +#ifndef _CMD_H_ +#define _CMD_H_ + +typedef struct cmdstruct { + char *sortname; /* set to NULL if you want to sort by command name */ + char *name; /* command name */ + char *help; /* short help */ + function_str funct; /* function to call */ + struct cmdstruct *next; +} cmdstruct; + +extern cmdstruct *commands; + +void show_stat __P ((void)); + +void cmd_add_command( cmdstruct *cmd ); + +#endif /* _CMD_H_ */ + @@ -0,0 +1,1665 @@ +/* + * cmd2.c -- back-end for the various #commands + * + * (created: Massimiliano Ghilardi (Cosmos), Aug 14th, 1998) + * + * Copyright (C) 1998 by Massimiliano Ghilardi + * + * 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. + * + */ + + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <signal.h> +#include <ctype.h> +#include <time.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <unistd.h> +#include <errno.h> + +#ifdef USE_REGEXP +# include "malloc.h" +# include <regex.h> +#endif + +int strcasecmp(); +int select(); + +#include "defines.h" +#include "main.h" +#include "utils.h" +#include "beam.h" +#include "edit.h" +#include "list.h" +#include "map.h" +#include "tcp.h" +#include "tty.h" +#include "eval.h" + +/* anyone knows if ANSI 6429 talks about more than 8 colors? */ +static char *colornames[] = { + "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", + "BLACK", "RED", "GREEN", "YELLOW", "BLUE", "MAGENTA", "CYAN", "WHITE", "none" +}; + +/* + * show defined aliases + */ +void show_aliases __P0 (void) +{ + aliasnode *p; + char buf[BUFSIZE]; + + PRINTF("#%s alias%s defined%c\n", sortedaliases ? "the following" : "no", + (sortedaliases && !sortedaliases->snext) ? " is" : "es are", + sortedaliases ? ':' : '.'); + reverse_sortedlist((sortednode **)&sortedaliases); + for (p = sortedaliases; p; p = p->snext) { + escape_specials(buf, p->name); + tty_printf("#alias %s%s@%s=%s\n", + p->active ? "" : "(disabled) ", + buf,p->group == NULL ? "*" : p->group, p->subst); + } + reverse_sortedlist((sortednode **)&sortedaliases); +} + +/* + * check if an alias name contains dangerous things. + * return 1 if illegal name (and print reason). + * if valid, print a warning for unbalanced () {} and "" + */ +static int check_alias __P1 (char *,name) +{ + char *p = name, c; + enum { NORM, ESCAPE } state = NORM; + int quotes=0, paren=0, braces=0, ok = 1; + + if (!*p) { + PRINTF("#illegal alias name: is empty!\n"); + error = INVALID_NAME_ERROR; + return 1; + } + if (*p == '{') { + PRINTF("#illegal beginning '{' in alias name: `%s'\n", name); + error = INVALID_NAME_ERROR; + return 1; + } + if (strchr(name, ' ')) { + PRINTF("#illegal spaces in alias name: `%s'\n", name); + error = INVALID_NAME_ERROR; + return 1; + } + + for (; ok && (c = *p); p++) switch (state) { + case NORM: + if (c == ESC) + state = ESCAPE; + else if (quotes) { + if (c == '\"') + quotes = 0; + } + else if (c == '\"') + quotes = 1; + else if (c == ')') + paren--; + else if (c == '(') + paren++; + else if (c == '}') + braces--; + else if (c == '{') + braces++; + else if (c == CMDSEP && !paren && !braces) + ok = 0; + break; + case ESCAPE: + if (c == ESC) + state = ESCAPE; + else /* if (c == ESC2 || c != ESC2) */ + state = NORM; + default: + break; + } + + if (!ok) { + PRINTF("#illegal non-escaped `;' in alias name: `%s'\n", name); + error = INVALID_NAME_ERROR; + return 1; + } + + if (quotes || paren || braces) { + PRINTF("#warning: unbalanced%s%s%s in alias name `%s' may cause problems\n", + quotes ? " \"\"" : "", paren ? " ()" : "", braces ? " {}" : "", name); + } + + return 0; +} + + +/* + * parse the #alias command + */ +void parse_alias __P1 (char *,str) +{ + char *left, *right, *group; + aliasnode **np, *p; + + left = str = skipspace(str); + + str = first_valid(str, '='); + + if (*str == '=') { + *str = '\0'; + right = ++str; + unescape(left); + + /* break out group name (if present) */ + group = strchr( left, '@' ); + if( group ) { + *group = 0; + group++; + } + + if (check_alias(left)) + return; + p = *(np = lookup_alias(left)); + if (!*str) { + /* delete alias */ + if (p) { + if (echo_int) { + PRINTF("#deleting alias: %s=%s\n", left, p->subst); + } + delete_aliasnode(np); + } else { + PRINTF("#unknown alias, cannot delete: `%s'\n", left); + } + } else { + /* add/redefine alias */ + + /* direct recursion is supported (alias CAN be defined by itself) */ + if (p) { + free(p->subst); + p->subst = my_strdup(right); + } else + add_aliasnode(left, right); + + /* get alias again to add group (if needed) + * don't take the lookup penalty though if not changing groups */ + if( group != NULL && *group != '\0' ) { + np = lookup_alias(left); + if( (*np)->group != NULL ) + free((*np)->group); + + (*np)->group = my_strdup(group); + } + + if (echo_int) { + PRINTF("#%s alias in group '%s': %s=%s\n", p ? "changed" : "new", + group == NULL ? "*" : group, left, right); + } + } + } else { + /* show alias */ + + *str = '\0'; + unescape(left); + if (check_alias(left)) + return; + np = lookup_alias(left); + if (*np) { + char buf[BUFSIZE]; + escape_specials(buf, left); + sprintf(inserted_next, "#alias %s%.*s@%s=%.*s", + BUFSIZE-9, buf, + (*np)->group == NULL ? "*" : (*np)->group, + BUFSIZE-(int)strlen(buf)-9, (*np)->subst); + } else { + PRINTF("#unknown alias, cannot show: `%s'\n", left); + } + } +} + +/* + * delete an action node + */ +static void delete_action __P1 (actionnode **,nodep) +{ + if (echo_int) { + PRINTF("#deleting action: >%c%s %s\n", (*nodep)->active ? + '+' : '-', (*nodep)->label, (*nodep)->pattern); + } + delete_actionnode(nodep); +} + +/* + * delete a prompt node + */ +static void delete_prompt __P1 (actionnode **,nodep) +{ + if (echo_int) { + PRINTF("#deleting prompt: >%c%s %s\n", (*nodep)->active ? + '+' : '-', (*nodep)->label, (*nodep)->pattern); + } + delete_promptnode(nodep); +} + +/* + * create new action + */ +static void add_new_action __P6 (char *,label, char *,pattern, char *,command, int,active, int,type, void *,q) +{ + add_actionnode(pattern, command, label, active, type, q); + if (echo_int) { + PRINTF("#new action: %c%c%s %s=%s\n", + action_chars[type], + active ? '+' : '-', label, + pattern, command); + } +} + +/* + * create new prompt + */ +static void add_new_prompt __P6 (char *,label, char *,pattern, char *,command, int,active, int,type, void *,q) +{ + add_promptnode(pattern, command, label, active, type, q); + if (echo_int) { + PRINTF("#new prompt: %c%c%s %s=%s\n", + action_chars[type], + active ? '+' : '-', label, + pattern, command); + } +} + +/* + * add an action with numbered label + */ +static void add_anonymous_action __P4 (char *,pattern, char *,command, int,type, void *,q) +{ + static int last = 0; + char label[16]; + do { + sprintf(label, "%d", ++last); + } while (*lookup_action(label)); + add_new_action(label, pattern, command, 1, type, q); +} + +#define ONPROMPT (onprompt ? "prompt" : "action") + +/* + * change fields of an existing action node + * pattern or commands can be NULL if no change + */ +static void change_actionorprompt __P6 (actionnode *,node, char *,pattern, char *,command, int,type, void *,q, int,onprompt) +{ +#ifdef USE_REGEXP + if (node->type == ACTION_REGEXP && node->regexp) { + regfree((regex_t *)(node->regexp)); + free(node->regexp); + } + node->regexp = q; +#endif + if (pattern) { + free(node->pattern); + node->pattern = my_strdup(pattern); + node->type = type; + } + if (command) { + free(node->command); + node->command = my_strdup(command); + } + + if (echo_int) { + PRINTF("#changed %s %c%c%s %s=%s\n", ONPROMPT, + action_chars[node->type], + node->active ? '+' : '-', + node->label, node->pattern, node->command); + } +} + +/* + * show defined actions + */ +void show_actions __P0 (void) +{ + actionnode *p; + + PRINTF("#%s action%s defined%c\n", actions ? "the following" : "no", + (actions && !actions->next) ? " is" : "s are", actions ? ':' : '.'); + for (p = actions; p; p = p->next) + tty_printf("#action %c%c%s@%s %s=%s\n", + action_chars[p->type], + p->active ? '+' : '-', p->label, + p->group == NULL ? "*" : p->group, + p->pattern, + p->command); +} + +/* + * show defined prompts + */ +void show_prompts __P0 (void) +{ + promptnode *p; + + PRINTF("#%s prompt%s defined%c\n", prompts ? "the following" : "no", + (prompts && !prompts->next) ? " is" : "s are", prompts ? ':' : '.'); + for (p = prompts; p; p = p->next) + tty_printf("#prompt %c%c%s %s=%s\n", + action_chars[p->type], + p->active ? '+' : '-', p->label, + p->pattern, p->command); +} + +/* + * parse the #action and #prompt commands + * this function is too damn complex because of the hairy syntax. it should be + * split up or rewritten as an fsm instead. + */ +void parse_action __P2 (char *,str, int,onprompt) +{ + char *p, label[BUFSIZE], pattern[BUFSIZE], *command, *group; + actionnode **np = NULL; + char sign, assign, hastail; + char active, type = ACTION_WEAK, kind; + void *regexp = 0; + + sign = *(p = skipspace(str)); + if (!sign) { + PRINTF("%s: no arguments given\n", ONPROMPT); + return; + } + + str = p + 1; + + switch (sign) { + case '+': + case '-': /* edit */ + case '<': /* delete */ + case '=': /* list */ + assign = sign; + break; + case '%': /* action_chars[ACTION_REGEXP] */ + type = ACTION_REGEXP; + /* falltrough */ + case '>': /* action_chars[ACTION_WEAK] */ + + /* define/edit */ + assign = '>'; + sign = *(p + 1); + if (!sign) { + PRINTF("#%s: label expected\n", ONPROMPT); + return; + } else if (sign == '+' || sign == '-') + str++; + else + sign = '+'; + break; + default: + assign = 0; /* anonymous action */ + str = p; + break; + } + + /* labelled action: */ + if (assign != 0) { + p = first_regular(str, ' '); + if ((hastail = *p)) + *p = '\0'; + + /* break out group name (if present) */ + group = strchr( str, '@' ); + if( group ) { + *group = 0; + group++; + } + + my_strncpy(label, str, BUFSIZE-1); + if (hastail) + *p++ = ' '; /* p points to start of pattern, or to \0 */ + + if (!*label) { + PRINTF("#%s: label expected\n", ONPROMPT); + return; + } + + + if (onprompt) + np = lookup_prompt(label); + else + np = lookup_action(label); + + /* '<' : remove action */ + if (assign == '<') { + if (!np || !*np) { + PRINTF("#no %s, cannot delete label: `%s'\n", + ONPROMPT, label); + } + else { + if (onprompt) + delete_prompt(np); + else + delete_action(np); + } + + /* '>' : define action */ + } else if (assign == '>') { +#ifndef USE_REGEXP + if (type == ACTION_REGEXP) { + PRINTF("#error: regexp not allowed\n"); + return; + } +#endif + + if (sign == '+') + active = 1; + else + active = 0; + + if (!*label) { + PRINTF("#%s: label expected\n", ONPROMPT); + return; + } + + p = skipspace(p); + if (*p == '(') { + ptr pbuf = (ptr)0; + p++; + kind = evalp(&pbuf, &p); + if (!REAL_ERROR && kind != TYPE_TXT) + error=NO_STRING_ERROR; + if (REAL_ERROR) { + PRINTF("#%s: ", ONPROMPT); + print_error(error=NO_STRING_ERROR); + ptrdel(pbuf); + return; + } + if (pbuf) { + my_strncpy(pattern, ptrdata(pbuf), BUFSIZE-1); + ptrdel(pbuf); + } else + pattern[0] = '\0'; + if (*p) + p = skipspace(++p); + if ((hastail = *p == '=')) + p++; + } + else { + p = first_regular(command = p, '='); + if ((hastail = *p)) + *p = '\0'; + my_strncpy(pattern, command, BUFSIZE-1); + + if (hastail) + *p++ = '='; + } + + if (!*pattern) { + PRINTF("#error: pattern of #%ss must be non-empty.\n", ONPROMPT); + return; + } + +#ifdef USE_REGEXP + if (type == ACTION_REGEXP && hastail) { + int errcode; + char unesc_pat[BUFSIZE]; + + /* + * HACK WARNING: + * we unescape regexp patterns now, instead of doing + * jit+unescape at runtime, as for weak actions. + */ + strcpy(unesc_pat, pattern); + unescape(unesc_pat); + + regexp = malloc(sizeof(regex_t)); + if (!regexp) { + errmsg("malloc"); + return; + } + + if ((errcode = regcomp((regex_t *)regexp, unesc_pat, REG_EXTENDED))) { + int n; + char *tmp; + n = regerror(errcode, (regex_t *)regexp, NULL, 0); + tmp = (char *)malloc(n); + if (tmp) { + if (!regerror(errcode, (regex_t *)regexp, tmp, n)) + errmsg("regerror"); + else { + PRINTF("#regexp error: %s\n", tmp); + } + free(tmp); + } else { + error = NO_MEM_ERROR; + errmsg("malloc"); + } + regfree((regex_t *)regexp); + free(regexp); + return; + } + } +#endif + command = p; + + if (hastail) { + if (np && *np) { + change_actionorprompt(*np, pattern, command, type, regexp, onprompt); + (*np)->active = active; + } else { + if (onprompt) + add_new_prompt(label, pattern, command, active, + type, regexp); + else + add_new_action(label, pattern, command, active, + type, regexp); + } + + if( group != NULL && *group != '\0' ) { + /* I don't know why but we need to clip this because somehow + * the original string is restored to *p at some point instead + * of the null-clipped one we used waaaay at the top. */ + p = first_regular(group, ' '); + *p = '\0'; + np = lookup_action(label); + if( (*np)->group != NULL ) + free( (*np)->group ); + (*np) -> group = my_strdup( group ); + } + } + + /* '=': list action */ + } else if (assign == '='){ + if (np && *np) { + int len = (int)strlen((*np)->label); + sprintf(inserted_next, "#%s %c%c%.*s %.*s=%.*s", ONPROMPT, + action_chars[(*np)->type], (*np)->active ? '+' : '-', + BUFSIZE - 6 /*strlen(ONPROMPT)*/ - 7, (*np)->label, + BUFSIZE - 6 /*strlen(ONPROMPT)*/ - 7 - len, (*np)->pattern, + BUFSIZE - 6 /*strlen(ONPROMPT)*/ - 7 - len - (int)strlen((*np)->pattern), + (*np)->command); + } else { + PRINTF("#no %s, cannot list label: `%s'\n", ONPROMPT, label); + } + + /* '+', '-': turn action on/off */ + } else { + if (np && *np) { + (*np)->active = (sign == '+'); + if (echo_int) { + PRINTF("#%s %c%s %s is now o%s.\n", ONPROMPT, + action_chars[(*np)->type], + label, + (*np)->pattern, (sign == '+') ? "n" : "ff"); + } + } else { + PRINTF("#no %s, cannot turn o%s label: `%s'\n", ONPROMPT, + (sign == '+') ? "n" : "ff", label); + } + } + + /* anonymous action, cannot be regexp */ + } else { + + if (onprompt) { + PRINTF("#anonymous prompts not supported.\n#please use labelled prompts.\n"); + return; + } + + command = first_regular(str, '='); + + if (*command == '=') { + *command = '\0'; + + my_strncpy(pattern, str, BUFSIZE-1); + *command++ = '='; + np = lookup_action_pattern(pattern); + if (*command) + if (np && *np) + change_actionorprompt(*np, NULL, command, ACTION_WEAK, NULL, 0); + else + add_anonymous_action(pattern, command, ACTION_WEAK, NULL); + else if (np && *np) + delete_action(np); + else { + PRINTF("#no action, cannot delete pattern: `%s'\n", + pattern); + return; + } + } else { + np = lookup_action_pattern(str); + if (np && *np) { + sprintf(inserted_next, "#action %.*s=%.*s", + BUFSIZE - 10, (*np)->pattern, + BUFSIZE - (int)strlen((*np)->pattern) - 10, + (*np)->command); + } else { + PRINTF("#no action, cannot show pattern: `%s'\n", pattern); + } + } + } +} + +#undef ONPROMPT + +/* + * display attribute syntax + */ +void show_attr_syntax __P0 (void) +{ + int i; + PRINTF("#attribute syntax:\n\tOne or more of:\tbold, blink, underline, inverse\n\tand/or\t[foreground] [ON background]\n\tColors: "); + for (i = 0; i < COLORS; i++) + tty_printf("%s%s", colornames[i], + (i == LOWCOLORS - 1 || i == COLORS - 1) ? "\n\t\t" : ","); + tty_printf("%s\n", colornames[i]); +} + +/* + * put escape sequences to turn on/off an attribute in given buffers + */ +void attr_string __P3 (int,attrcode, char *,begin, char *,end) +{ + int fg = FOREGROUND(attrcode), bg = BACKGROUND(attrcode), + tok = ATTR(attrcode); + char need_end = 0; + *begin = *end = '\0'; + + if (tok > (ATTR_BOLD | ATTR_BLINK | ATTR_UNDERLINE | ATTR_INVERSE) + || fg > COLORS || bg > COLORS || attrcode == NOATTRCODE) + return; /* do nothing */ + + if (fg < COLORS) { + if (bg < COLORS) { + sprintf(begin, "\033[%c%d;%s%dm", + fg<LOWCOLORS ? '3' : '9', fg % LOWCOLORS, + bg<LOWCOLORS ? "4" :"10", bg % LOWCOLORS); +#ifdef TERM_LINUX + strcpy(end, "\033[39;49m"); +#endif + } else { + sprintf(begin, "\033[%c%dm", + fg<LOWCOLORS ? '3' : '9', fg % LOWCOLORS); +#ifdef TERM_LINUX + strcpy(end, "\033[39m"); +#endif + } + } else if (bg < COLORS) { + sprintf(begin, "\033[%s%dm", + bg<LOWCOLORS ? "4" : "10", bg % LOWCOLORS); +#ifdef TERM_LINUX + strcpy(end, "\033[49m"); +#endif + } + +#ifndef TERM_LINUX + if (fg < COLORS || bg < COLORS) + need_end = 1; +#endif + + if (tok & ATTR_BOLD) { + if (tty_modebold[0]) { + strcat(begin, tty_modebold); +#ifdef TERM_LINUX + strcat(end, "\033[21m"); +#else + need_end = 1; +#endif + } else { + strcat(begin, tty_modestandon); + strcpy(end, tty_modestandoff); + } + } + + if (tok & ATTR_BLINK) { + if (tty_modeblink[0]) { + strcat(begin, tty_modeblink); +#ifdef TERM_LINUX + strcat(end, "\033[25m"); +#else + need_end = 1; +#endif + } else { + strcat(begin, tty_modestandon); + strcpy(end, tty_modestandoff); + } + } + + if (tok & ATTR_UNDERLINE) { + if (tty_modeuline[0]) { + strcat(begin, tty_modeuline); +#ifdef TERM_LINUX + strcat(end, "\033[24m"); +#else + need_end = 1; +#endif + } else { + strcat(begin, tty_modestandon); + strcpy(end, tty_modestandoff); + } + } + + if (tok & ATTR_INVERSE) { + if (tty_modeinv[0]) { + strcat(begin, tty_modeinv); +#ifdef TERM_LINUX + strcat(end, "\033[27m"); +#else + need_end = 1; +#endif + } else { + strcat(begin, tty_modestandon); + strcpy(end, tty_modestandoff); + } + } + +#ifndef TERM_LINUX + if (need_end) + strcpy(end, tty_modenorm); +#endif +} + +/* + * parse attribute description in line. + * Return attribute if successful, -1 otherwise. + */ +int parse_attributes __P1 (char *,line) +{ + char *p; + int tok = 0, fg, bg, t = -1; + + if (!(p = strtok(line, " "))) + return NOATTRCODE; + + fg = bg = NO_COLOR; + + while (t && p) { + if (!strcasecmp(p, "bold")) + t = ATTR_BOLD; + else if (!strcasecmp(p, "blink")) + t = ATTR_BLINK; + else if (!strcasecmp(p, "underline")) + t = ATTR_UNDERLINE; + else if (!strcasecmp(p, "inverse") || !strcasecmp(p, "reverse")) + t = ATTR_INVERSE; + else + t = 0; + + if (t) { + tok |= t; + p = strtok(NULL, " "); + } + } + + if (!p) + return ATTRCODE(tok, fg, bg); + + for (t = 0; t <= COLORS && strcmp(p, colornames[t]); t++) + ; + if (t <= COLORS) { + fg = t; + p = strtok(NULL, " "); + } + + if (!p) + return ATTRCODE(tok, fg, bg); + + if (strcasecmp(p, "on")) + return -1; /* invalid attribute */ + + if (!(p = strtok(NULL, " "))) + return -1; + + for (t = 0; t <= COLORS && strcmp(p, colornames[t]); t++) + ; + if (t <= COLORS) + bg = t; + else + return -1; + + return ATTRCODE(tok, fg, bg); +} + + +/* + * return a static pointer to name of given attribute code + */ +char *attr_name __P1 (int,attrcode) +{ + static char name[BUFSIZE]; + int fg = FOREGROUND(attrcode), bg = BACKGROUND(attrcode), tok = ATTR(attrcode); + + name[0] = 0; + if (tok > (ATTR_BOLD | ATTR_BLINK | ATTR_UNDERLINE | ATTR_INVERSE) || fg > COLORS || bg > COLORS) + return name; /* error! */ + + if (tok & ATTR_BOLD) + strcat(name, "bold "); + if (tok & ATTR_BLINK) + strcat(name, "blink "); + if (tok & ATTR_UNDERLINE) + strcat(name, "underline "); + if (tok & ATTR_INVERSE) + strcat(name, "inverse "); + + if (fg < COLORS || (fg == bg && fg == COLORS && !tok)) + strcat(name, colornames[fg]); + + if (bg < COLORS) { + strcat(name, " on "); + strcat(name, colornames[bg]); + } + + if (!*name) + strcpy(name, "none"); + + return name; +} + +/* + * show defined marks + */ +void show_marks __P0 (void) +{ + marknode *p; + PRINTF("#%s marker%s defined%c\n", markers ? "the following" : "no", + (markers && !markers->next) ? " is" : "s are", + markers ? ':' : '.'); + for (p = markers; p; p = p->next) + tty_printf("#mark %s%s=%s\n", p->mbeg ? "^" : "", + p->pattern, attr_name(p->attrcode)); +} + + +/* + * parse arguments to the #mark command + */ +void parse_mark __P1 (char *,str) +{ + char *p; + marknode **np, *n; + char mbeg = 0; + + if (*str == '=') { + PRINTF("#marker must be non-null.\n"); + return; + } + p = first_regular(str, '='); + if (!*p) { + if (*str == '^') + mbeg = 1, str++; + unescape(str); + np = lookup_marker(str, mbeg); + if ((n = *np)) { + ptr pbuf = (ptr)0; + char *name; + pbuf = ptrmescape(pbuf, n->pattern, strlen(n->pattern), 0); + if (MEM_ERROR) { ptrdel(pbuf); return; } + name = attr_name(n->attrcode); + sprintf(inserted_next, "#mark %s%.*s=%.*s", n->mbeg ? "^" : "", + BUFSIZE-(int)strlen(name)-9, pbuf ? ptrdata(pbuf) : "", + BUFSIZE-9, name); + ptrdel(pbuf); + } else { + PRINTF("#unknown marker, cannot show: `%s'\n", str); + } + + } else { + int attrcode, wild = 0; + char pattern[BUFSIZE], *p2; + + *(p++) = '\0'; + p = skipspace(p); + if (*str == '^') + mbeg = 1, str++; + my_strncpy(pattern, str, BUFSIZE-1); + unescape(pattern); + p2 = pattern; + while (*p2) { + if (ISMARKWILDCARD(*p2)) { + wild = 1; + if (ISMARKWILDCARD(*(p2 + 1))) { + error=SYNTAX_ERROR; + PRINTF("#error: two wildcards (& or $) may not be next to eachother\n"); + return; + } + } + p2++; + } + + np = lookup_marker(pattern, mbeg); + attrcode = parse_attributes(p); + if (attrcode == -1) { + PRINTF("#invalid attribute syntax.\n"); + error=SYNTAX_ERROR; + if (echo_int) show_attr_syntax(); + } else if (!*p) + if ((n = *np)) { + if (echo_int) { + PRINTF("#deleting mark: %s%s=%s\n", n->mbeg ? "^" : "", + n->pattern, attr_name(n->attrcode)); + } + delete_marknode(np); + } else { + PRINTF("#unknown marker, cannot delete: `%s%s'\n", + mbeg ? "^" : "", pattern); + } + else { + if (*np) { + (*np)->attrcode = attrcode; + if (echo_int) { + PRINTF("#changed"); + } + } else { + add_marknode(pattern, attrcode, mbeg, wild); + if (echo_int) { + PRINTF("#new"); + } + } + if (echo_int) + tty_printf(" mark: %s%s=%s\n", mbeg ? "^" : "", + pattern, attr_name(attrcode)); + } + } +} + +/* + * turn ASCII description of a sequence + * into raw escape sequence + * return pointer to end of ASCII description + */ +static char *unescape_seq __P3 (char *,buf, char *,seq, int *,seqlen) +{ + char c, *start = buf; + enum { NORM, ESCSINGLE, ESCAPE, CARET, DONE } state = NORM; + + for (; (c = *seq); seq++) { + switch (state) { + case NORM: + if (c == '^') + state = CARET; + else if (c == ESC) + state = ESCSINGLE; + else if (c == '=') + state = DONE; + else + *(buf++) = c; + break; + case CARET: + /* + * handle ^@ ^A ... ^_ as expected: + * ^@ == 0x00, ^A == 0x01, ... , ^_ == 0x1f + */ + if (c > 0x40 && c < 0x60) + *(buf++) = c & 0x1f; + /* special case: ^? == 0x7f */ + else if (c == '?') + *(buf++) = 0x7f; + state = NORM; + break; + case ESCSINGLE: + case ESCAPE: + /* + * GH: \012 ==> octal number + */ + if (state == ESCSINGLE && + ISODIGIT(seq[0]) && ISODIGIT(seq[1]) && ISODIGIT(seq[2])) { + *(buf++) =(((seq[0] - '0') << 6) | + ((seq[1] - '0') << 3) | + (seq[2] - '0')); + seq += 2; + } else { + *(buf++) = c; + if (c == ESC) + state = ESCAPE; + else + state = NORM; + } + break; + default: + break; + } + if (state == DONE) + break; + } + *buf = '\0'; + *seqlen = buf - start; + return seq; +} + +/* + * read a single character from tty, with timeout in milliseconds. + * timeout == 0 means wait indefinitely (no timeout). + * return char or -1 if timeout was reached. + */ +static int get_one_char __P1 (int,timeout) +{ + extern int errno; + int err; + fd_set fds; + char c; + struct timeval timeoutbuf; + + FD_ZERO(&fds); + FD_SET(tty_read_fd, &fds); + timeoutbuf.tv_sec = 0; + timeoutbuf.tv_usec = timeout * uSEC_PER_mSEC; + err = select(tty_read_fd+1, &fds, NULL, NULL, + timeout ? &timeoutbuf : NULL); + if (err == 0 || (err == -1 && errno == EINTR)) + return -1; + if (err == -1) { + errmsg("select"); + return -1; + } + while ((err = tty_read(tty_read_fd, &c, 1)) < 0 && errno == EINTR) + ; + if (err != 1) { + errmsg("read from tty"); + return -1; + } + return (int)c; +} + +/* + * print an escape sequence in human-readably form. + */ +void print_seq __P2 (char *,seq, int,len) +{ + char ch; + + while (len--) { + ch = *(seq++); + if (ch == '\033') { + tty_puts("esc "); + continue; + } + if (ch < ' ') { + tty_putc('^'); + ch |= '@'; + } + if (ch == ' ') + tty_puts("space "); + else if (ch == 0x7f) + tty_puts("del "); + else if (ch & 0x80) + tty_printf("\\%03o ", ch); + else + tty_printf("%c ", ch); + } +} + +/* + * return a static pointer to escape sequence made printable, for use in + * definition-files + */ +char *seq_name __P2 (char *,seq, int,len) +{ + static char buf[CAPLEN*4]; + char *p = buf; + char c; + /* + * rules: control chars are written as ^X, where + * X is char | 64 + * + * GH: codes > 0x80 ==> octal \012 + * + * special case: 0x7f is written ^? + */ + while (len--) { + c = *seq++; + if (c == '^' || (c && strchr(SPECIAL_CHARS, c))) + *(p++) = ESC; + + if (c < ' ') { + *(p++) = '^'; + *(p++) = c | '@'; + } else if (c == 0x7f) { + *(p++) = '^'; + *(p++) = '?'; + } else if (c & 0x80) { + /* GH: save chars with high bit set in octal */ + sprintf(p, "\\%03o", (int)c); + p += strlen(p); + } else + *(p++) = c; + } + *p = '\0'; + return buf; +} + +/* + * read a single escape sequence from the keyboard + * prompting user for it; return static pointer + */ +char *read_seq __P2 (char *,name, int *,len) +{ + static char seq[CAPLEN]; + int i = 1, tmp; + + PRINTF("#please press the key `%s' : ", name); + tty_flush(); + + if ((tmp = get_one_char(0)) >= 0) + seq[0] = tmp; + else { + tty_puts("#unable to get key. Giving up.\n"); + return NULL; + } + + while (i < CAPLEN - 1 && + (tmp = get_one_char(KBD_TIMEOUT)) >= 0) + seq[i++] = tmp; + *len = i; + print_seq(seq, i); + + tty_putc('\n'); + if (seq[0] >= ' ' && seq[0] <= '~') { + PRINTF("#that is not a redefinable key.\n"); + return NULL; + } + return seq; +} + +/* + * show full definition of one binding, + * with custom message + */ +static void show_single_bind __P2 (char *,msg, keynode *,p) +{ + if (p->funct == key_run_command) { + PRINTF("#%s %s %s=%s\n", msg, p->name, + seq_name(p->sequence, p->seqlen), p->call_data); + } else { + PRINTF("#%s %s %s=%s%s%s\n", msg, p->name, + seq_name(p->sequence, p->seqlen), + internal_functions[lookup_edit_function(p->funct)].name, + p->call_data ? " " : "", + p->call_data ? p->call_data : ""); + } +} + +/* + * list keyboard bindings + */ +void show_binds __P1 (char,edit) +{ + keynode *p; + int count = 0; + for (p = keydefs; p; p = p->next) { + if (edit != (p->funct == key_run_command)) { + if (!count) { + if (edit) { + PRINTF("#line-editing keys:\n"); + } else { + PRINTF("#user-defined keys:\n"); + } + } + show_single_bind("bind", p); + ++count; + } + } + if (!count) { + PRINTF("#no key bindings defined right now.\n"); + } +} + + +/* + * interactively create a new keybinding + */ +static void define_new_key __P2 (char *,name, char *,command) +{ + char *seq, *arg; + keynode *p; + int seqlen, function; + + seq = read_seq(name, &seqlen); + if (!seq) return; + + for (p = keydefs; p; p = p->next) + /* GH: don't allow binding of supersets of another bind */ + if (!memcmp(p->sequence, seq, MIN2(p->seqlen, seqlen))) { + show_single_bind("key already bound as:", p); + return; + } + + function = lookup_edit_name(command, &arg); + if (function) + add_keynode(name, seq, seqlen, + internal_functions[function].funct, arg); + else + add_keynode(name, seq, seqlen, key_run_command, command); + + if (echo_int) { + PRINTF("#new key binding: %s %s=%s\n", + name, seq_name(seq, seqlen), command); + } +} + +/* + * parse the #bind command non-interactively. + */ +static void parse_bind_noninteractive __P1 (char *,arg) +{ + char rawseq[CAPLEN], *p, *seq, *params; + int function, seqlen; + keynode **kp; + + p = strchr(arg, ' '); + if (!p) { + PRINTF("#syntax error: `#bind %s'\n", arg); + return; + } + *(p++) = '\0'; + seq = p = skipspace(p); + + p = unescape_seq(rawseq, p, &seqlen); + if (!p[0] || !p[1]) { + PRINTF("#syntax error: `#bind %s %s'\n", arg, seq); + return; + } + *p++ = '\0'; + + kp = lookup_key(arg); + if (kp && *kp) + delete_keynode(kp); + + if ((function = lookup_edit_name(p, ¶ms))) + add_keynode(arg, rawseq, seqlen, + internal_functions[function].funct, params); + else + add_keynode(arg, rawseq, seqlen, key_run_command, p); + + if (echo_int) { + PRINTF("#%s: %s %s=%s\n", (kp && *kp) ? + "redefined key" : "new key binding", arg, seq, p); + } +} + +/* + * parse the argument of the #bind command (interactive) + */ +void parse_bind __P1 (char *,arg) +{ + char *p, *q, *command, *params; + char *name = arg; + keynode **npp, *np; + int function; + + p = first_valid(arg, '='); + q = first_valid(arg, ' '); + q = skipspace(q); + + if (*p && *q && p > q) { + parse_bind_noninteractive(arg); + return; + } + + if (*p) { + *(p++) = '\0'; + np = *(npp = lookup_key(name)); + if (*p) { + command = p; + if (np) { + if (np->funct == key_run_command) + free(np->call_data); + if ((function = lookup_edit_name(command, ¶ms))) { + np->call_data = my_strdup(params); + np->funct = internal_functions[function].funct; + } else { + np->call_data = my_strdup(command); + np->funct = key_run_command; + } + if (echo_int) { + PRINTF("#redefined key: %s %s=%s\n", name, + seq_name(np->sequence, np->seqlen), + command); + } + } else + define_new_key(name, command); + } else { + if (np) { + if (echo_int) + show_single_bind("deleting key binding:", np); + delete_keynode(npp); + } else { + PRINTF("#no such key: `%s'\n", name); + } + } + } else { + np = *(npp = lookup_key(name)); + if (np) { + char *seqname; + int seqlen; + seqname = seq_name(np->sequence, np->seqlen); + seqlen = strlen(seqname); + + if (np->funct == key_run_command) + sprintf(inserted_next, "#bind %.*s %s=%.*s", + BUFSIZE-seqlen-9, name, seqname, + BUFSIZE-seqlen-(int)strlen(name)-9, + np->call_data); + else { + p = internal_functions[lookup_edit_function(np->funct)].name; + sprintf(inserted_next, "#bind %.*s %s=%s%s%.*s", + BUFSIZE-seqlen-10, name, seqname, p, + np->call_data ? " " : "", + BUFSIZE-seqlen-(int)strlen(name)-(int)strlen(p)-10, + np->call_data ? np->call_data : ""); + } + } else { + PRINTF("#no such key: `%s'\n", name); + } + } +} + +void parse_rebind __P1 (char *,arg) +{ + char rawseq[CAPLEN], *seq, **old; + keynode **kp, *p; + int seqlen; + + arg = skipspace(arg); + if (!*arg) { + PRINTF("#rebind: missing key.\n"); + return; + } + + seq = first_valid(arg, ' '); + if (*seq) { + *seq++ = '\0'; + seq = skipspace(seq); + } + + kp = lookup_key(arg); + if (!kp || !*kp) { + PRINTF("#no such key: `%s'\n", arg); + return; + } + + if (!*seq) { + seq = read_seq(arg, &seqlen); + if (!seq) + return; + } else { + (void)unescape_seq(rawseq, seq, &seqlen); + seq = rawseq; + } + + for (p = keydefs; p; p = p->next) { + if (p == *kp) + continue; + if (seqlen == p->seqlen && !memcmp(p->sequence, seq, seqlen)) { + show_single_bind("key already bound as:", p); + return; + } + } + + old = &((*kp)->sequence); + if (*old) + free(*old); + *old = (char *)malloc((*kp)->seqlen = seqlen); + memmove(*old, seq, seqlen); + + if (echo_int) + show_single_bind("redefined key:", *kp); +} + +/* + * evaluate an expression, or unescape a text. + * set value of start and end line if <(expression...) or !(expression...) + * if needed, use/malloc `pbuf' as buffer (on error, also free pbuf) + * return resulting char * + */ +char *redirect __P7 (char *,arg, ptr *,pbuf, char *,kind, char *,name, int,also_num, long *,start, long *,end) +{ + char *tmp = skipspace(arg), k; + int type, i; + + if (!pbuf) { + print_error(error=INTERNAL_ERROR); + return NULL; + } + + k = *tmp; + if (k == '!' || k == '<') + arg = ++tmp; + else + k = 0; + + *start = *end = 0; + + if (*tmp=='(') { + + arg = tmp + 1; + type = evalp(pbuf, &arg); + if (!REAL_ERROR && type!=TYPE_TXT && !also_num) + error=NO_STRING_ERROR; + if (REAL_ERROR) { + PRINTF("#%s: ", name); + print_error(error); + ptrdel(*pbuf); + return NULL; + } + for (i=0; i<2; i++) if (*arg == CMDSEP) { + long buf; + + arg++; + if (!i && *arg == CMDSEP) { + *start = 1; + continue; + } + else if (i && *arg == ')') { + *end = LONG_MAX; + continue; + } + + type = evall(&buf, &arg); + if (!REAL_ERROR && type != TYPE_NUM) + error=NO_NUM_VALUE_ERROR; + if (REAL_ERROR) { + PRINTF("#%s: ", name); + print_error(error); + ptrdel(*pbuf); + return NULL; + } + if (i) + *end = buf; + else + *start = buf; + } + if (*arg != ')') { + PRINTF("#%s: ", name); + print_error(error=MISSING_PAREN_ERROR); + ptrdel(*pbuf); + return NULL; + } + if (!*pbuf) { + /* make space to add a final \n */ + *pbuf = ptrsetlen(*pbuf, 1); + ptrzero(*pbuf); + if (REAL_ERROR) { + print_error(error); + ptrdel(*pbuf); + return NULL; + } + } + arg = ptrdata(*pbuf); + if (!*start && *end) + *start = 1; + } else + unescape(arg); + + *kind = k; + return arg; +} + +void show_vars __P0 (void) +{ + varnode *v; + int i, type; + ptr p = (ptr)0; + + PRINTF("#the following variables are defined:\n"); + + for (type = 0; !REAL_ERROR && type < 2; type++) { + reverse_sortedlist((sortednode **)&sortednamed_vars[type]); + v = sortednamed_vars[type]; + while (v) { + if (type == 0) { + tty_printf("#(@%s = %ld)\n", v->name, v->num); + } else { + p = ptrescape(p, v->str, 0); + if (REAL_ERROR) { + print_error(error); + break; + } + tty_printf("#($%s = \"%s\")\n", v->name, + p ? ptrdata(p) : ""); + } + v = v->snext; + } + reverse_sortedlist((sortednode **)&sortednamed_vars[type]); + } + for (i = -NUMVAR; !REAL_ERROR && i < NUMPARAM; i++) { + if (*VAR[i].num) + tty_printf("#(@%d = %ld)\n", i, *VAR[i].num); + } + for (i = -NUMVAR; !REAL_ERROR && i < NUMPARAM; i++) { + if (*VAR[i].str && ptrlen(*VAR[i].str)) { + p = ptrescape(p, *VAR[i].str, 0); + if (p && ptrlen(p)) + tty_printf("#($%d = \"%s\")\n", i, ptrdata(p)); + } + } + ptrdel(p); +} + +void show_delaynode __P2 (delaynode *,p, int,in_or_at) +{ + long d; + struct tm *s; + char buf[BUFSIZE]; + + update_now(); + d = diff_vtime(&p->when, &now); + s = localtime((time_t *)&p->when.tv_sec); + /* s now points to a calendar struct */ + if (in_or_at) { + + if (in_or_at == 2) { + /* write time in buf */ + (void)strftime(buf, BUFSIZE - 1, "%H%M%S", s); + sprintf(inserted_next, "#at %.*s (%s) %.*s", + BUFSIZE - 15, p->name, buf, + BUFSIZE - 15 - (int)strlen(p->name), p->command); + } + else + sprintf(inserted_next, "#in %.*s (%ld) %.*s", + BUFSIZE - LONGLEN - 9, p->name, d, + BUFSIZE - LONGLEN - 9 - (int)strlen(p->name), p->command); + } else { + (void)strftime(buf, BUFSIZE - 1, "%H:%M:%S", s); + PRINTF("#at (%s) #in (%ld) `%s' %s\n", buf, d, p->name, p->command); + } +} + +void show_delays __P0 (void) +{ + delaynode *p; + int n = (delays ? delays->next ? 2 : 1 : 0) + + (dead_delays ? dead_delays->next ? 2 : 1 : 0); + + PRINTF("#%s delay label%s defined%c\n", n ? "the following" : "no", + n == 1 ? " is" : "s are", n ? ':' : '.'); + for (p = delays; p; p = p->next) + show_delaynode(p, 0); + for (p = dead_delays; p; p = p->next) + show_delaynode(p, 0); +} + +void change_delaynode __P3 (delaynode **,p, char *,command, long,millisec) +{ + delaynode *m=*p; + + *p = m->next; + m->when.tv_usec = (millisec % mSEC_PER_SEC) * uSEC_PER_mSEC; + m->when.tv_sec = millisec / mSEC_PER_SEC; + update_now(); + add_vtime(&m->when, &now); + if (*command) { + if (strlen(command) > strlen(m->command)) { + free((void*)m->command); + m->command = my_strdup(command); + } + else + strcpy(m->command, command); + } + if (millisec < 0) + add_node((defnode*)m, (defnode**)&dead_delays, rev_time_sort); + else + add_node((defnode*)m, (defnode**)&delays, time_sort); + if (echo_int) { + PRINTF("#changed "); + show_delaynode(m, 0); + } +} + +void new_delaynode __P3 (char *,name, char *,command, long,millisec) +{ + vtime t; + delaynode *node; + + t.tv_usec = (millisec % mSEC_PER_SEC) * uSEC_PER_mSEC; + t.tv_sec = millisec / mSEC_PER_SEC; + update_now(); + add_vtime(&t, &now); + node = add_delaynode(name, command, &t, millisec < 0); + if (echo_int && node) { + PRINTF("#new "); + show_delaynode(node, 0); + } +} + +void show_history __P1 (int,count) +{ + int i = curline; + + if (!count) count = lines - 1; + if (count >= MAX_HIST) count = MAX_HIST - 1; + i -= count; + if (i < 0) i += MAX_HIST; + + while (count) { + if (hist[i]) { + PRINTF("#%2d: %s\n", count, hist[i]); + } + count--; + if (++i == MAX_HIST) i = 0; + } +} + +void exe_history __P1 (int,count) +{ + int i = curline; + char buf[BUFSIZE]; + + if (count >= MAX_HIST) + count = MAX_HIST - 1; + i -= count; + if (i < 0) + i += MAX_HIST; + if (hist[i]) { + strcpy(buf, hist[i]); + parse_user_input(buf, 0); + } +} + @@ -0,0 +1,32 @@ +/* public things from cmd2.c */ + +void show_aliases __P ((void)); +void parse_alias __P ((char *str)); + +void show_actions __P ((void)); +void show_prompts __P ((void)); +void parse_action __P ((char *str, int onprompt)); + +void show_attr_syntax __P ((void)); +void attr_string __P ((int attrcode, char *begin, char *end)); +int parse_attributes __P ((char *line)); +char *attr_name __P ((int attrcode)); +void show_marks __P ((void)); +void parse_mark __P ((char *str)); + +char *seq_name __P ((char *seq, int len)); +void show_binds __P ((char edit)); +void parse_bind __P ((char *arg)); +void parse_rebind __P ((char *arg)); + +char *redirect __P ((char *arg, ptr *pbuf, char *kind, char *name, int also_num, long *start, long *end)); + +void show_vars __P ((void)); +void show_delaynode __P ((delaynode *p, int in_or_at)); +void show_delays __P ((void)); +void change_delaynode __P ((delaynode **p, char *command, long millisec)); +void new_delaynode __P ((char *name, char *command, long millisec)); + +void show_history __P ((int count)); +void exe_history __P ((int count)); + diff --git a/configure b/configure new file mode 100755 index 0000000..664cccf --- /dev/null +++ b/configure @@ -0,0 +1,5415 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.59. +# +# Copyright (C) 2003 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +# Factoring default headers for most tests. +ac_includes_default="\ +#include <stdio.h> +#if HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#if HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif +#if STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# if HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include <memory.h> +# endif +# include <string.h> +#endif +#if HAVE_STRINGS_H +# include <strings.h> +#endif +#if HAVE_INTTYPES_H +# include <inttypes.h> +#else +# if HAVE_STDINT_H +# include <stdint.h> +# endif +#endif +#if HAVE_UNISTD_H +# include <unistd.h> +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +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' + +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 + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # 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_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$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 ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) 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 | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$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 | -n) + 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_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + 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 "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# 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_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + 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 "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # 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 <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +Program names: + --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 +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-vt100 Hard code vt100 escape sequences, use if you have no + termcap + --enable-sort Sort aliases and actions + --enable-noshell Disables the "#!" command + --enable-ansibug enables fixes for "#mark" ansi bugs on some + terminals + --enable-bsd Needed for BSD systems, in powwow this was USE_SGTTY + and BSD_LIKE + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have + headers in a nonstandard directory <include dir> + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd "$ac_popdir" + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright (C) 2003 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# 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 + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# 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 "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + +am__api_version="1.9" +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 + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $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 +# AmigaOS /C/install, which installs bootblocks on floppy discs +# 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" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /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 + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +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 "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&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}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 +# Just in case +sleep 1 +echo timestamp > conftest.file +# 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 conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $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 "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +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" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 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 conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE=powwow + VERSION=1.2.7 + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + STRIP=$ac_ct_STRIP +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + +# Check whether --enable-vt100 or --disable-vt100 was given. +if test "${enable_vt100+set}" = set; then + enableval="$enable_vt100" + cat >>confdefs.h <<\_ACEOF +#define VT100 1 +_ACEOF + +fi; + +# Check whether --enable-sort or --disable-sort was given. +if test "${enable_sort+set}" = set; then + enableval="$enable_sort" + cat >>confdefs.h <<\_ACEOF +#define DO_SORT 1 +_ACEOF + +fi; + +# Check whether --enable-noshell or --disable-noshell was given. +if test "${enable_noshell+set}" = set; then + enableval="$enable_noshell" + cat >>confdefs.h <<\_ACEOF +#define NO_SHELL 1 +_ACEOF + +fi; + +# Check whether --enable-ansibug or --disable-ansibug was given. +if test "${enable_ansibug+set}" = set; then + enableval="$enable_ansibug" + cat >>confdefs.h <<\_ACEOF +#define BUG_ANSI 1 +_ACEOF + +fi; + +# Check whether --enable-bsd or --disable-bsd was given. +if test "${enable_bsd+set}" = set; then + enableval="$enable_bsd" + cat >>confdefs.h <<\_ACEOF +#define USE_SGTTY 1 +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define BSD_LIKE 1 +_ACEOF + +fi; + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +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 "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +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 $# != 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 + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 + (eval $ac_compiler --version </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5 + (eval $ac_compiler -v </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5 + (eval $ac_compiler -V </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&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 +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include <stdlib.h> +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + + ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6 +rm -f confinc confmf + +# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval="$enable_dependency_tracking" + +fi; +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + + +depcc="$CC" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + + +# Checks for libraries. + + +echo "$as_me:$LINENO: checking for initscr in -lcurses" >&5 +echo $ECHO_N "checking for initscr in -lcurses... $ECHO_C" >&6 +if test "${ac_cv_lib_curses_initscr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcurses $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char initscr (); +int +main () +{ +initscr (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_curses_initscr=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_curses_initscr=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_curses_initscr" >&5 +echo "${ECHO_T}$ac_cv_lib_curses_initscr" >&6 +if test $ac_cv_lib_curses_initscr = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCURSES 1 +_ACEOF + + LIBS="-lcurses $LIBS" + +fi + +echo "$as_me:$LINENO: checking for regcomp" >&5 +echo $ECHO_N "checking for regcomp... $ECHO_C" >&6 +if test "${ac_cv_func_regcomp+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define regcomp to an innocuous variant, in case <limits.h> declares regcomp. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define regcomp innocuous_regcomp + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char regcomp (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef regcomp + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char regcomp (); +/* 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_regcomp) || defined (__stub___regcomp) +choke me +#else +char (*f) () = regcomp; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != regcomp; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_regcomp=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_regcomp=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_regcomp" >&5 +echo "${ECHO_T}$ac_cv_func_regcomp" >&6 +if test $ac_cv_func_regcomp = yes; then + cat >>confdefs.h <<\_ACEOF +#define USE_REGEXP 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for lrand48" >&5 +echo $ECHO_N "checking for lrand48... $ECHO_C" >&6 +if test "${ac_cv_func_lrand48+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define lrand48 to an innocuous variant, in case <limits.h> declares lrand48. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define lrand48 innocuous_lrand48 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char lrand48 (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef lrand48 + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char lrand48 (); +/* 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_lrand48) || defined (__stub___lrand48) +choke me +#else +char (*f) () = lrand48; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != lrand48; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_lrand48=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_lrand48=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_lrand48" >&5 +echo "${ECHO_T}$ac_cv_func_lrand48" >&6 +if test $ac_cv_func_lrand48 = yes; then + : +else + cat >>confdefs.h <<\_ACEOF +#define USE_RANDOM 1 +_ACEOF + +fi + + +# Checks for header files. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <string.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + 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 <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <stdlib.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + 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 <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ctype.h> +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#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); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + +for ac_header in stdlib.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Checks for typedefs, structures, and compiler characteristics. +echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset x; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *ccp; + char **p; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + ccp = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++ccp; + p = (char**) ccp; + ccp = (char const *const *) p; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + } +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_const=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6 +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + + +# Checks for library functions. + +for ac_header in stdlib.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 +echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6 +if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_malloc_0_nonnull=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#if STDC_HEADERS || HAVE_STDLIB_H +# include <stdlib.h> +#else +char *malloc (); +#endif + +int +main () +{ +exit (malloc (0) ? 0 : 1); + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_malloc_0_nonnull=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_malloc_0_nonnull=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 +echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6 +if test $ac_cv_func_malloc_0_nonnull = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MALLOC 1 +_ACEOF + +else + cat >>confdefs.h <<\_ACEOF +#define HAVE_MALLOC 0 +_ACEOF + + case $LIBOBJS in + "malloc.$ac_objext" | \ + *" malloc.$ac_objext" | \ + "malloc.$ac_objext "* | \ + *" malloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; +esac + + +cat >>confdefs.h <<\_ACEOF +#define malloc rpl_malloc +_ACEOF + +fi + + + + +for ac_func in bzero +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* 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 (); +/* 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 +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + ac_config_files="$ac_config_files Makefile" +cat >confcache <<\_ACEOF +# 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, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# 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 \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then we branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +cat >confdef2opt.sed <<\_ACEOF +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +t quote +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +t quote +d +: quote +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,\[,\\&,g +s,\],\\&,g +s,\$,$$,g +p +_ACEOF +# We use echo to avoid assuming a particular line-breaking character. +# The extra dot is to prevent the shell from consuming trailing +# line-breaks from the sub-command output. A line-break within +# single-quotes doesn't work because, if this script is created in a +# platform that uses two characters for line-breaks (e.g., DOS), tr +# would break. +ac_LF_and_DOT=`echo; echo .` +DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` +rm -f confdef2opt.sed + + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Configuration commands: +$config_commands + +Report bugs to <bug-autoconf@gnu.org>." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS section. +# + +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@CYGPATH_W@,$CYGPATH_W,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@install_sh@,$install_sh,;t t +s,@STRIP@,$STRIP,;t t +s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@mkdir_p@,$mkdir_p,;t t +s,@AWK@,$AWK,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@am__leading_dot@,$am__leading_dot,;t t +s,@AMTAR@,$AMTAR,;t t +s,@am__tar@,$am__tar,;t t +s,@am__untar@,$am__untar,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@DEPDIR@,$DEPDIR,;t t +s,@am__include@,$am__include,;t t +s,@am__quote@,$am__quote,;t t +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t +s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t +s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t +s,@CPP@,$CPP,;t t +s,@EGREP@,$EGREP,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # 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_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # 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" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_dir=`(dirname "$ac_dest") 2>/dev/null || +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_dest" : 'X\(//\)[^/]' \| \ + X"$ac_dest" : 'X\(//\)$' \| \ + X"$ac_dest" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_dest" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 +echo "$as_me: executing $ac_dest commands" >&6;} + case $ac_dest in + depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`(dirname "$mf") 2>/dev/null || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`(dirname "$file") 2>/dev/null || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p $dirpart/$fdir + else + as_dir=$dirpart/$fdir + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5 +echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;} + { (exit 1); exit 1; }; }; } + + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + esac +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..3fb7cda --- /dev/null +++ b/configure.in @@ -0,0 +1,49 @@ +# Process this file with autoconf to produce a configure script. +AC_INIT +AM_INIT_AUTOMAKE(powwow, 1.2.7) + +AC_ARG_ENABLE(vt100, + AC_HELP_STRING([--enable-vt100], + [Hard code vt100 escape sequences, use if you have no termcap ]), + AC_DEFINE(VT100)) + +AC_ARG_ENABLE(sort, + AC_HELP_STRING([--enable-sort], + [Sort aliases and actions]), + AC_DEFINE(DO_SORT)) + +AC_ARG_ENABLE(noshell, + AC_HELP_STRING([--enable-noshell], + [Disables the "#!" command]), + AC_DEFINE(NO_SHELL)) + +AC_ARG_ENABLE(ansibug, + AC_HELP_STRING([--enable-ansibug], + [enables fixes for "#mark" ansi bugs on some terminals]), + AC_DEFINE(BUG_ANSI)) + +AC_ARG_ENABLE(bsd, + AC_HELP_STRING([--enable-bsd], + [Needed for BSD systems, in powwow this was USE_SGTTY and BSD_LIKE]), + AC_DEFINE(USE_SGTTY) + AC_DEFINE(BSD_LIKE)) + +# Checks for programs. +AC_PROG_CC + +# Checks for libraries. +AC_CHECK_LIB(curses, initscr) +AC_CHECK_FUNC(regcomp,AC_DEFINE(USE_REGEXP)) +AC_CHECK_FUNC(lrand48,,AC_DEFINE(USE_RANDOM)) + +# Checks for header files. +AC_CHECK_HEADERS([stdlib.h unistd.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST + +# Checks for library functions. +AC_FUNC_MALLOC +AC_CHECK_FUNCS([bzero]) + +AC_OUTPUT(Makefile) diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..fee7716 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,9 @@ +powwow (1.2.7) unstable; urgency=low + + * First release. + + -- Your Name <your@email.address> Mon, 20 Mar 2000 17:58:49 +0000 + +Local variables: +mode: debian-changelog +End: diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..e685d2a --- /dev/null +++ b/debian/control @@ -0,0 +1,12 @@ +Source: powwow +Section: misc +Priority: optional +Standards-Version: 3.0.1 + +Package: powwow +Version: 1.2.7 +Description: a powerful and extensible curses based mud client + powwow is a powerful mud client that supports triggers, aliases, + multiple connections, and more. It is extensible through a plugin + interface. Currently there are plugins to add javascript and perl + language support. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..68ec697 --- /dev/null +++ b/debian/rules @@ -0,0 +1,78 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. +# This file is public domain software, originally written by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This is the debhelper compatability version to use. +export DH_COMPAT=1 + +build: build-stamp +build-stamp: + dh_testdir + + # Add here commands to compile the package. + ./configure --prefix=/usr + $(MAKE) + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + # Add here commands to clean up after the build process. + #$(MAKE) clean + #$(MAKE) distclean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/tmp. + $(MAKE) prefix=`pwd`/debian/tmp/usr install + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install +# dh_testversion + dh_testdir + dh_testroot +# dh_installdebconf + dh_installdocs + dh_installexamples + dh_installmenu +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit + dh_installcron + dh_installmanpages + dh_installinfo +# dh_undocumented + dh_installchangelogs + dh_link + dh_strip + dh_compress + dh_fixperms + # You may want to make some executables suid here. + dh_suidregister +# dh_makeshlibs + dh_installdeb +# dh_perl + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/defines.h b/defines.h new file mode 100644 index 0000000..493d8a1 --- /dev/null +++ b/defines.h @@ -0,0 +1,367 @@ +/* + * common definition and typedefs + */ + +#ifndef _DEFINES_H_ +#define _DEFINES_H_ + +#include "malloc.h" + +#if !defined(SYS_TIME_H) && !defined(_H_SYS_TIME) +# include <sys/time.h> +#endif + +#ifdef AIX +# include <sys/select.h> +#endif + +#define memzero(a,b) memset((a), 0, (b)) + +#ifdef USE_RANDOM +# define get_random random +# define init_random srandom +#else +# define get_random lrand48 +# define init_random srand48 +#endif + +#ifdef __STDC__ + +# define VOLATILE volatile +# ifndef __P +# define __P(args) args +# endif +# define __P0(dummy) (void) +# define __P1(t1,a1) (t1 a1) +# define __P2(t1,a1,t2,a2) (t1 a1, t2 a2) +# define __P3(t1,a1,t2,a2,t3,a3) (t1 a1, t2 a2, t3 a3) +# define __P4(t1,a1,t2,a2,t3,a3,t4,a4) (t1 a1, t2 a2, t3 a3, t4 a4) +# define __P5(t1,a1,t2,a2,t3,a3,t4,a4,t5,a5) (t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) +# define __P6(t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6) (t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) +# define __P7(t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6,t7,a7) (t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) + +#else /* ! __STDC__ */ + +# define VOLATILE +# ifndef __P +# define __P(args) () +# endif +# define __P0(dummy) () +# define __P1(t1,a1) (a1) t1 a1; +# define __P2(t1,a1,t2,a2) (a1, a2) t1 a1; t2 a2; +# define __P3(t1,a1,t2,a2,t3,a3) (a1, a2, a3) t1 a1; t2 a2; t3 a3; +# define __P4(t1,a1,t2,a2,t3,a3,t4,a4) (a1, a2, a3, a4) t1 a1; t2 a2; t3 a3; t4 a4; +# define __P5(t1,a1,t2,a2,t3,a3,t4,a4,t5,a5) (a1, a2, a3, a4, a5) t1 a1; t2 a2; t3 a3; t4 a4; t5 a5; +# define __P6(t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6) (a1, a2, a3, a4, a5, a6) t1 a1; t2 a2; t3 a3; t4 a4; t5 a5; t6 a6; +# define __P7(t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6,t7,a7) (a1, a2, a3, a4, a5, a6, a7) t1 a1; t2 a2; t3 a3; t4 a4; t5 a5; t6 a6; t7 a7; + +#endif /* __STDC__ */ + +#ifdef __GNUC__ +# define INLINE static inline +#else +# define INLINE static +#endif + +#ifndef NULL +# define NULL ((void *)0) +#endif + +#ifndef LONG_MAX +# define LONG_MAX ( (long) ((~(unsigned long)0) >> 1) ) +#endif + +#ifndef LONG_MIN +# define LONG_MIN ( (long) (((~(unsigned long)0) >> 1) + 1) ) +#endif + +#ifndef INT_MAX +# define INT_MAX ( (int) ((~(unsigned int)0) >> 1) ) +#endif + +#ifndef INT_MIN +# define INT_MIN ( (int) (((~(unsigned int)0) >> 1) + 1) ) +#endif + +#define uSEC_PER_SEC ((long)1000000) /* microseconds in a second */ +#define mSEC_PER_SEC ((long)1000) /* milliseconds in a second */ +#define uSEC_PER_mSEC ((long)1000) /* microseconds in a millisecond */ + +#undef MIN2 +#undef MAX2 +#undef ABS +#undef SIGN +#undef SWAP2 +#define MIN2(a,b) ((a)<(b) ? (a) : (b)) +#define MAX2(a,b) ((a)>(b) ? (a) : (b)) +#define ABS(a) ((a)> 0 ? (a) :(-a)) +#define SIGN(a) ((a)> 0 ? 1 : (a) ? -1 : 0) +#define SWAP2(a,b,c) ((c)=(b), (b)=(a), (a)=(c)) + +/* macros to match parentheses */ +#define ISRPAREN(c) ((c) == ')' || (c) == ']' || (c) == '}') +#define ISLPAREN(c) ((c) == '(' || (c) == '[' || (c) == '{') +#define LPAREN(c) ((c) == ')' ? '(' : ((c) == ']' ? '[' : '{')) + +#define ISODIGIT(c) ((c) >= '0' && (c) <= '7') + +#define PRINTF status(1), tty_printf + +#define INTLEN (3*(1+(int)sizeof(int))) + /* max length of a string representation + * of an int */ +#define LONGLEN (3*(1+(int)sizeof(long))) + /* max length of a string representation + * of a long */ +#define ESC '\\' /* special escape char */ +#define STRESC "\\" +#define ESC2 '`' /* other special escape char */ +#define STRESC2 "`" +#define CMDSEP ';' /* command separator character */ +#define SPECIAL_CHARS "{}();\"=" /* specials chars needing escape */ +#define MPI "~$#E" /* MUME protocol introducer */ +#define MPILEN 4 /* strlen(MPI) */ + +#ifdef NR_OPEN +# define MAX_FDSCAN NR_OPEN +#else +# define MAX_FDSCAN 256 /* max number of fds */ +#endif + +#define MAX_CONNECTS 32 /* max number of open connections. must fit in a byte */ + +#define CAPLEN 20 /* max length of a terminal capability */ +#define BUFSIZE 4096 /* general buffer size */ +#define SOCKBUFSIZE BUFSIZE /* socket buffer size for read */ +#define PARAMLEN 99 /* initial length of text strings */ +#define MAX_MAPLEN 1000 /* maximum length of automapped path */ +#define MIN_WORDLEN 3 /* the minimum length for history words */ +#define MAX_WORDS 512 /* number of words kept for TAB-completion */ +#define MAX_HIST 128 /* number of history lines kept */ +#define LOG_MAX_HASH 7 +#define MAX_HASH (1<<LOG_MAX_HASH) /* max hash value, must be a power of 2 */ +#define NUMPARAM 10 /* number of local unnamed params allowed + * (hardcoded, don't change) */ +#define NUMVAR 50 /* number of global unnamed variables */ +#define NUMTOT (NUMVAR+NUMPARAM) +#define MAX_SUBOPT 256 /* max length of suboption string */ +#define MAX_ARGS 16 /* max number of arguments to editor */ +#define FLASHDELAY 500 /* time of parentheses flash in millisecs */ +#define KBD_TIMEOUT 100 /* timeout for keyboard read in millisecs; + * hope it's enough also for very slow lines */ + +#define MAX_STACK 100 /* maximum number of nested + * action, alias, #for or #while */ +#define MAX_LOOP 10000 /* maximum number of iterations in + * #for or #while */ + +#define ACTION_WEAK 0 /* GH: normal junk */ +#define ACTION_REGEXP 1 /* oh-so-mighty regexp */ +#define ACTION_TYPES (ACTION_REGEXP + 1) + +/* GH: the redefinable delimeters */ +#define DELIM (delim_list[delim_mode]) +#define DELIM_LEN (delim_len[delim_mode]) +#define IS_DELIM(c) (strchr(DELIM, (c))) + +#define DELIM_NORMAL 0 /* GH: normal word delimeters */ +#define DELIM_PROGRAM 1 /* ()[]{}.,;"'+/-*% */ +#define DELIM_CUSTOM 2 /* user-defined */ +#define DELIM_MODES (DELIM_CUSTOM + 1) + + +/* macros to find cursor position from input buffer position */ +#define CURLINE(pos) (((pos) + col0) / cols_1 + line0) +#define CURCOL(pos) (((pos) + col0) % cols_1) + +#define CLIP(a, min, max) ((a)=(a)<(min) ? (min) : (a)>(max) ? (max) : (a)) + +#define ISMARKWILDCARD(c) ((c) == '&' || (c) == '$') + +/* + * Attribute codes: bit 0-4 for foreground color, 5-9 for + * background color, 10-13 for effects. + * Color #16 is "none", so 0x0210 is "no attribute". + */ +#define COLORS 16 /* number of colors on HFT terminal */ +#define LOWCOLORS 8 /* number of ANSI colors */ +#define NO_COLOR COLORS /* no color change, use default */ +#define BITS_COLOR 5 /* bits used for a color entry + (16==none is a valid color) */ +#define BITS_2COLOR 10 /* bits used for 2 color entries */ +#define COLOR_MASK 0x1F /* 5 (BITS_COLOR) bits set to 1, others 0 */ + +#define ATTR_BOLD 0x01 +#define ATTR_BLINK 0x02 +#define ATTR_UNDERLINE 0x04 +#define ATTR_INVERSE 0x08 + +/* + * WARNING: colors and attributes are currently using 14 bits: + * 4 for attributes, 5 for foreground color and 5 for background. + * type used is int and -1 is used as 'invalid attribute' + * so in case ints are 16 bits, there is only 1 bit left unused. + * In case ints are 32 bits, no problem. + */ + +/* constructors / accessors for attribute codes */ +#define ATTRCODE(attr, fg, bg) \ + (((attr) << BITS_2COLOR) | ((bg) << BITS_COLOR) | (fg)) +#define FOREGROUND(attrcode) ((attrcode) & COLOR_MASK) +#define BACKGROUND(attrcode) (((attrcode) >> BITS_COLOR) & COLOR_MASK) +#define ATTR(attrcode) ((attrcode) >> BITS_2COLOR) + +#define NOATTRCODE ATTRCODE(0, NO_COLOR, NO_COLOR) + +/* + * NCSA telnet 2.2 doesn't reset the color when it receives "esc [ m", + * so we must know what the normal colors are in order to reset it. + * These colors can be changed with the #color command. + */ +#ifdef BUG_TELNET +# define DEFAULTFG 7 /* make default white text */ +# define DEFAULTBG 4 /* on blue background */ +#endif + +#define LM_NOECHO 1 /* no local echo */ +#define LM_CHAR 2 /* char-by-char mode (no line editing) */ + + + + + +typedef unsigned char byte; + +typedef void (*function_any) (); /* generic function pointer */ + +typedef void (*function_int) __P ((int i)); + +typedef function_int function_signal; + +typedef void (*function_str) __P ((char *arg)); + +typedef struct timeval vtime; /* needs #include <sys/tyme.h> */ + +#include "ptr.h" + + + + +/* generic linked list node (never actually created) */ +typedef struct defnode { + struct defnode *next; + char *sortfield; +} defnode; + +/* + * twin linked list node: used to build pair of parallel lists, + * one sorted and one not, with the same nodes + */ +typedef struct sortednode { + struct sortednode *next; + char *sortfield; + struct sortednode *snext; +} sortednode; + +/* + * linked list nodes: keep `next' first, then string to sort by, + * then (eventually) `snext' + */ +typedef struct aliasnode { + struct aliasnode *next; + char *name; + struct aliasnode *snext; + char *subst; + char *group; + int active; +} aliasnode; + +typedef struct marknode { + struct marknode *next; + char *pattern; + int attrcode; + char *start, *end; + char mbeg; + char wild; +} marknode; + +typedef struct triggernode { + struct triggernode *next; + char *command, *label; + int active; + int type; /* GH: allow regexp */ + char *pattern; +#ifdef USE_REGEXP + void *regexp; /* 0 if type == ACTION_WEAK */ +#endif + char *group; +} triggernode; + +/* + * HACK WARNING : + * actionnode and promptnode must be the same type + * or search_action_or_prompt() in main.c won't work. + */ +typedef triggernode actionnode; +typedef triggernode promptnode; + +typedef int (*function_sort) __P ((defnode *node1, defnode *node2)); + +typedef struct keynode { + struct keynode *next; + char *name; /* key name */ + char *sequence; /* escape sequence sent by terminal */ + int seqlen; /* GH: length of esc seq to allow \0 in seq */ + function_str funct; /* function called when key pressed */ + char *call_data; /* data passed to function */ +} keynode; + +typedef struct delaynode { + struct delaynode *next; + char *name; + char *command; + vtime when; /* structure containing time when */ + /* command must be executed */ +} delaynode; + +/* Variable struct definitions */ + +typedef struct varnode { /* for named variables */ + struct varnode *next; + char *name; + struct varnode *snext; + int index; + long num; + ptr str; +} varnode; + +typedef struct { /* for unnamed vars */ + long num; + ptr str; +} unnamedvar; + +typedef struct { /* stack of local vars */ + unnamedvar p[MAX_STACK][NUMPARAM]; + int curr; +} param_stack; + +typedef struct { /* pointers to all variables */ + long *num; + ptr *str; +} vars; + +/* editing session control */ +typedef struct editsess { + struct editsess *next; + unsigned int key; /* session identifier */ + int pid; /* pid of child */ + int fd; /* MUD socket to talk with (-1 if non-MUD text) */ + char *descr; /* short description of what we are editing */ + char *file; /* name of temporary file */ + time_t ctime; /* time when temp file was created (upper bound) */ + long oldsize; /* original file size */ + char cancel; /* 1 if cancelled */ +} editsess; + +#endif /* _DEFINES_H_ */ + @@ -0,0 +1,464 @@ +#! /bin/sh + +# depcomp - compile a program generating dependencies as side-effects +# Copyright 1999, 2000 Free Software Foundation, Inc. + +# 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. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi +# `libtool' can also be set to `yes' or `no'. + +if test -z "$depfile"; then + base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` + dir=`echo "$object" | sed 's,/.*$,/,'` + if test "$dir" = "$object"; then + dir= + fi + # FIXME: should be _deps on DOS. + depfile="$dir.deps/$base" +fi + +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. This file always lives in the current directory. + # Also, the AIX compiler puts `$object:' at the start of each line; + # $object doesn't have directory information. + stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + outname="$stripped.o" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Must come before tru64. + + # Intel's C compiler understands `-MD -MF file'. However + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + tmpdepfile1="$dir.libs/$base.lo.d" + tmpdepfile2="$dir.libs/$base.d" + "$@" -Wc,-MD + else + tmpdepfile1="$dir$base.o.d" + tmpdepfile2="$dir$base.d" + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + if test -f "$tmpdepfile1"; then + tmpdepfile="$tmpdepfile1" + else + tmpdepfile="$tmpdepfile2" + fi + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a space and a tab in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 @@ -0,0 +1,886 @@ +/* + * edit.c -- line editing functions for powwow + * + * Copyright (C) 1998 by Massimiliano Ghilardi + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <ctype.h> +#include <time.h> +#include <sys/types.h> +#include <sys/time.h> + +#include "defines.h" +#include "main.h" +#include "utils.h" +#include "cmd.h" +#include "edit.h" +#include "tcp.h" +#include "tty.h" +#include "eval.h" +#include "log.h" + +static void insert_string __P ((char *arg)); + +/* history buffer */ +char *hist[MAX_HIST]; /* saved history lines */ +int curline = 0; /* current history line */ +int pickline = 0; /* line to pick history from */ + +/* word completion list */ +wordnode words[MAX_WORDS]; +int wordindex = 0; + +edit_function internal_functions[] = { + {(char *)0, (function_str)0, }, + {"&enter-line", enter_line, }, + {"&complete-word", complete_word, }, + {"&complete-line", complete_line, }, + {"&del-char-left", del_char_left, }, + {"&del-char-right", del_char_right, }, + {"&prev-char", prev_char, }, + {"&prev-line", prev_line, }, + {"&next-char", next_char, }, + {"&next-line", next_line, }, + {"&to-history", to_history, }, + {"&clear-line", clear_line, }, + {"&redraw-line", redraw_line, }, + {"&redraw-line-noprompt", redraw_line_noprompt, }, + {"&begin-of-line", begin_of_line, }, + {"&end-of-line", end_of_line, }, + {"&kill-to-eol", kill_to_eol, }, + {"&transpose", transpose_chars, }, + {"&transpose-words", transpose_words, }, + {"&suspend", (function_str)suspend_powwow, }, /* yep, it's an hack */ + {"&del-word-left", del_word_left, }, + {"&del-word-right", del_word_right, }, + {"&prev-word", prev_word, }, + {"&upcase-word", upcase_word, }, + {"&downcase-word", downcase_word, }, + {"&next-word", next_word, }, + {"&insert-string", insert_string, }, + {(char *)0, (function_str)0 } +}; + +int lookup_edit_name __P2 (char *,name, char **,arg) +{ + int i, len, flen; + char *fname, *extra = NULL; + + if ((fname = strchr(name, ' '))) + len = fname - name; + else + len = strlen(name); + + for (i=1; (fname = internal_functions[i].name); i++) { + flen = strlen(fname); + if (flen == len && !strncmp(name, fname, flen)) { + extra = name + flen; + if (*extra == ' ') extra++; + if (!*extra) extra = NULL; + *arg = extra; + return i; + } + } + *arg = extra; + return 0; +} + +int lookup_edit_function __P1 (function_str,funct) +{ + int i; + function_str ffunct; + + for (i = 1; (ffunct = internal_functions[i].funct); i++) + if (funct == ffunct) + return i; + + return 0; +} + +/* + * redisplay the prompt + * assume cursor is at beginning of line + */ +void draw_prompt __P0 (void) +{ + if (promptlen && prompt_status == 1) { + int e = error; + error = 0; + marked_prompt = ptraddmarks(marked_prompt, prompt->str); + if (MEM_ERROR) { promptzero(); errmsg("malloc(prompt)"); return; } + tty_puts(ptrdata(marked_prompt)); + col0 = printstrlen(promptstr); /* same as printstrlen(marked_prompt) */ + error = e; + } + prompt_status = 0; +} + +/* + * clear current input line (deleteprompt == 1 if to clear also prompt) + * cursor is left right after the prompt. + * + * since we do not expect data from the user at this point, + * do not print edattrbeg now. + */ +void clear_input_line __P1 (int,deleteprompt) +{ + /* + * be careful: if prompt and/or input line have been erased from screen, + * pos will be different from the actual cursor position + */ + if ((edlen && line_status == 0) || (promptlen && prompt_status == 0 && deleteprompt)) { + int newcol = deleteprompt ? 0 : col0; + int realpos = line_status == 0 ? pos : (prompt_status == 0 ? 0 : -col0); + + tty_gotoxy_opt(CURCOL(realpos), CURLINE(realpos), newcol, line0); + tty_puts(edattrend); + if (line0 < lines - 1) + tty_puts(tty_clreoscr); + else + tty_puts(tty_clreoln); + col0 = newcol; + } else { + tty_puts(edattrend); + } + if (deleteprompt) + status(1); + else + line_status = 1; +} + +/* + * clear input line, but do nothing else + */ +void clear_line __P1 (char *,dummy) +{ + if (!edlen) + return; + clear_input_line(0); + pickline = curline; + *edbuf = '\0'; + pos = edlen = 0; +} + +/* + * Redraw the input line and put the cursor at the current position. + * The cursor is assumed to be directly after the prompt. + */ +void draw_input_line __P0 (void) +{ + int i, oldline0; + + if (line_status == 0 || linemode & LM_NOECHO) + return; + + tty_puts(edattrbeg); + + if (edlen) { + oldline0 = line0; + if (edlen < cols_1 - col0) { + tty_puts(edbuf); + } else { + tty_printf("%.*s", cols_1 - col0, edbuf); + for (i = cols_1 - col0; i <= edlen; i += cols_1) { +#ifdef BUG_ANSI + if (edattrbg) + tty_printf("%s\n%s%.*s", edattrend, edattrbeg, cols_1, edbuf + i); + else +#endif + tty_printf("\n%.*s", cols_1, edbuf + i); + } + } + line0 = lines - (edlen + col0) / cols_1 - 1; + if (line0 > oldline0) + line0 = oldline0; + if ((i = CURLINE(pos)) < 0) + line0 -= i; + else if (i > lines - 1) + line0 -= i - lines + 1; + tty_gotoxy_opt(CURCOL(edlen), CURLINE(edlen), CURCOL(pos), CURLINE(pos)); + } + line_status = 0; +} + +/* + * redraw the input line + */ +void redraw_line __P1 (char *,dummy) +{ + clear_input_line(1); +} + +/* + * redraw the input line, clearing the prompt + */ +void redraw_line_noprompt __P1 (char *,dummy) +{ + clear_input_line(0); + tty_putc('\n'); + if (line0 < lines - 1) + line0++; + status(-1); +} + +/* + * GH: transpose two words to the left + */ +void transpose_words __P1 (char *,dummy) +{ + /* other refers to the word to the left, this is the one we are at */ + + int this_so, other_so, this_eo, other_eo; + char buf[BUFSIZE]; + int n; + + if (pos > 2) { + + this_eo = this_so = pos; + /* optionally traceback to find a word */ + while (this_so && strchr(DELIM, edbuf[this_so])) + this_so--; + + /* now find where the current word ends */ + while (this_eo < edlen && !strchr(DELIM, edbuf[this_eo])) + this_eo++; + + /* found a word; now find its start */ + while (this_so > 0 && !strchr(DELIM, edbuf[this_so - 1])) + this_so--; + + if (this_so < 2) + return; /* impossible that there's another word */ + + other_so = this_so - 1; + while (other_so >= 0 && strchr(DELIM, edbuf[other_so])) + other_so--; + if (other_so < 0) + return; + other_eo = other_so + 1; + while (other_so > 0 && !strchr(DELIM, edbuf[other_so - 1])) + other_so--; + + sprintf(buf, "%.*s%.*s%.*s", + this_eo - this_so, edbuf + this_so, + this_so - other_eo, edbuf + other_eo, + other_eo - other_so, edbuf + other_so); + + input_moveto(other_so); + for (n = 0; buf[n]; input_overtype_follow(buf[n++])) + ; + } +} + +/* + * transpose two characters to the left + */ +void transpose_chars __P1 (char *,dummy) +{ + int i, j; + char c; + if (pos > 1 || (pos > 0 && pos < edlen)) { + if (pos < edlen) { + j = pos; + i = pos - 1; + } else { + j = pos - 1; + i = pos - 2; + } + c = edbuf[j]; edbuf[j] = edbuf[i]; edbuf[i] = c; + + if (line_status == 0) { + tty_gotoxy_opt(CURCOL(pos), CURLINE(pos), CURCOL(i), CURLINE(i)); + tty_putc(edbuf[i]); + tty_gotoxy_opt(CURCOL(i+1), CURLINE(i+1), CURCOL(j), CURLINE(j)); + tty_putc(edbuf[j]); + if (pos < edlen) { + pos++; + tty_gotoxy_opt(CURCOL(j+1), CURLINE(j+1), CURCOL(pos), CURLINE(pos)); + } + } else + pos++; + } +} + +/* + * erase everything to the end of line + */ +void kill_to_eol __P1 (char *,dummy) +{ + if (line_status == 0) { + if (edattrbg) + tty_printf("%s%s", edattrend, tty_clreoln); + else + tty_puts(tty_clreoln); + if (CURLINE(edlen) > CURLINE(pos)) { + tty_printf("\n%s", tty_clreoscr); + tty_gotoxy_opt(0, CURLINE(pos) + 1, CURCOL(pos), CURLINE(pos)); + } + if (edattrbg) + tty_puts(edattrbeg); + } + edbuf[edlen = pos] = '\0'; +} + +/* + * move cursor to end of line + */ +void end_of_line __P1 (char *,dummy) +{ + input_moveto(edlen); +} + +/* + * move cursor to beginning of line + */ +void begin_of_line __P1 (char *,dummy) +{ + input_moveto(0); +} + +/* + * delete a character to the right + */ +void del_char_right __P1 (char *,dummy) +{ + input_delete_nofollow_chars(1); +} + +/* + * delete a character to the left + */ +void del_char_left __P1 (char *,dummy) +{ + if (pos) { + input_moveto(pos-1); + input_delete_nofollow_chars(1); + } +} + +/* + * move a line into history, but don't do anything else + */ +void to_history __P1 (char *,dummy) +{ + if (!edlen) + return; + clear_input_line(0); + put_history(edbuf); + pickline = curline; + *edbuf = '\0'; + pos = edlen = 0; +} + +/* + * put string in history at current position + * (string is assumed to be trashable) + */ +void put_history __P1 (char *,str) +{ + char *p; + if (hist[curline]) free(hist[curline]); + if (!(hist[curline] = my_strdup(str))) { + errmsg("malloc"); + return; + } + + if (++curline == MAX_HIST) + curline = 0; + + /* split into words and put into completion list */ + for (p = strtok(str, DELIM); p; + p = strtok(NULL, DELIM)) { + if (strlen(p) >= MIN_WORDLEN && + p[0] != '#') /* no commands/short words */ + put_word(p); + } +} + +/* + * move a node before wordindex, i.e. make it the last word + */ +static void demote_word __P1 (int,i) +{ + words[words[i].prev].next = words[i].next; + words[words[i].next].prev = words[i].prev; + words[i].prev = words[words[i].next = wordindex].prev; + words[wordindex].prev = words[words[wordindex].prev].next = i; +} + +/* + * match and complete a word referring to the word list + */ +void complete_word __P1 (char *,dummy) +{ + /* + * GH: rewritten to allow circulating through history with repetitive command + * code stolen from cancan 2.6.3a + * curr_word: index into words[] + * comp_len length of current completition + * root_len length of the root word (before the completition) + * root start of the root word + */ + + static int curr_word, comp_len = 0, root_len = 0; + char *root, *p; + int k, n; + + /* find word start */ + if (last_edit_cmd == (function_any)complete_word && comp_len) { + k = comp_len; + input_moveto(pos - k); + n = pos - root_len; + } else { + for (n = pos; n > 0 && !IS_DELIM(edbuf[n - 1]); n--) + ; + k = 0; + curr_word = wordindex; + root_len = pos - n; + } + root = edbuf + n; comp_len = 0; + + /* k = chars to delete, n = position of starting word */ + + /* scan word list for next match */ + while ((p = words[curr_word = words[curr_word].next].word)) { + if (!strncasecmp(p, root, root_len) && + *(p += root_len) && + (n = strlen(p)) + edlen < BUFSIZE) { + comp_len = n; + for (; k && n; k--, n--) + input_overtype_follow(*p++); + if (n > 0) + input_insert_follow_chars(p, n); + break; + } + } + if (k > 0) + input_delete_nofollow_chars(k); + + /* delete duplicate instances of the word */ + if (p && !(words[k = curr_word].flags & WORD_UNIQUE)) { + words[k].flags |= WORD_UNIQUE; + p = words[k].word; + n = words[k].next; + while (words[k = n].word) { + n = words[k].next; + if (!strcmp(p, words[k].word)) { + demote_word(k); + free(words[k].word); + words[k].word = 0; + words[curr_word].flags |= words[k].flags; /* move retain flag */ + if ((words[k].flags &= WORD_UNIQUE)) + break; + } + } + } +} + +/* + * match and complete entire lines backwards in history + * GH: made repeated complete_line cycle through history + */ +void complete_line __P1 (char *,dummy) +{ + static int curr_line = MAX_HIST-1, root_len = 0, first_line = 0; + int i; + + if (last_edit_cmd != (function_any)complete_line) { + root_len = edlen; + first_line = curr_line = curline; + } + + for (i = curr_line - 1; i != curr_line; i--) { + if (i < 0) i = MAX_HIST - 1; + if (i == first_line) + break; + if (hist[i] && !strncmp(edbuf, hist[i], root_len)) + break; + } + if (i != curr_line) { + clear_input_line(0); + if (i == first_line) { + edbuf[root_len] = 0; + edlen = root_len; + } else { + strcpy(edbuf, hist[i]); + edlen = strlen(edbuf); + } + pos = edlen; + curr_line = i; + } +} + +/* + * GH: word history handling stolen from cancan 2.6.3a + */ + +static void default_completions __P0 (void) +{ + char buf[BUFSIZE]; + cmdstruct *p; + int i; + for (i = 0, buf[0] = '#', p = commands; p->name; p++) + if (p->funct /*&& strlen(p->name) >= 3*/ ) { + if (++i >= MAX_WORDS) break; + strcpy(buf + 1, p->name); + if (!(words[i].word = my_strdup(buf))) + syserr("malloc"); + words[i].flags = WORD_UNIQUE | WORD_RETAIN; + } + for (i = MAX_WORDS; i--; words[i].prev = i - 1, words[i].next = i + 1) + ; + words[0].prev = MAX_WORDS - 1; + words[MAX_WORDS - 1].next = 0; +} + +/* + * put word in word completion ring + */ +void put_word __P1 (char *,s) +{ + int r = wordindex; + if (!(words[r].word = my_strdup(s))) { + errmsg("malloc"); + return; + } + words[r].flags = 0; + while (words[r = words[r].prev].flags & WORD_RETAIN) + ; + demote_word(r); + wordindex = r; + if (words[r].word) { + free(words[r].word); + words[r].word = 0; + } +} + +/* + * GH: set delimeters[DELIM_CUSTOM] + */ +void set_custom_delimeters __P1 (char *,s) +{ + char *old = delim_list[DELIM_CUSTOM]; + if (!(delim_list[DELIM_CUSTOM] = my_strdup(s))) + errmsg("malloc"); + else { + if (old) + free(old); + delim_len[DELIM_CUSTOM] = strlen(s); + delim_mode = DELIM_CUSTOM; + } +} + +/* + * enter a line + */ +void enter_line __P1 (char *,dummy) +{ + char *p; + + if (line_status == 0) + input_moveto(edlen); + else { + if (prompt_status != 0) + col0 = 0; + draw_input_line(); + } + PRINTF("%s\n", edattrend); + + line0 = CURLINE(edlen); + if (line0 < lines - 1) line0++; + + if (recordfile) + fprintf(recordfile, "%s\n", edbuf); + + col0 = error = pos = line_status = 0; + + if (!*edbuf || (verbatim && *edbuf != '#')) + tcp_write(tcp_fd, edbuf); + else + parse_user_input(edbuf, 1); + history_done = 0; + + /* don't put identical lines in history, nor empty ones */ + p = hist[curline ? curline - 1 : MAX_HIST - 1]; + if (!p || (edlen > 0 && strcmp(edbuf, p))) + put_history(edbuf); + pickline = curline; + if (*inserted_next) { + strcpy(edbuf, inserted_next); + inserted_next[0] = '\0'; + line_status = 1; + } else if (*prefixstr) { + strcpy(edbuf, prefixstr); + line_status = 1; + } else + edbuf[0] = '\0'; + pos = edlen = strlen(edbuf); +} + +/* + * move one word forward + */ +void next_word __P1 (char *,dummy) +{ + int i; + for (i = pos; edbuf[i] && !isalnum(edbuf[i]); i++) + ; + while (isalnum(edbuf[i])) + i++; + input_moveto(i); +} + +/* + * move one word backward + */ +void prev_word __P1 (char *,dummy) +{ + int i; + for (i = pos; i && !isalnum(edbuf[i - 1]); i--) + ; + while (i && isalnum(edbuf[i - 1])) + i--; + input_moveto(i); +} + +/* + * delete word to the right + */ +void del_word_right __P1 (char *,dummy) +{ + int i; + for (i = pos; edbuf[i] && !isalnum(edbuf[i]); i++) + ; + while (isalnum(edbuf[i])) + i++; + input_delete_nofollow_chars(i - pos); +} + +/* + * delete word to the left + */ +void del_word_left __P1 (char *,dummy) +{ + int i; + for (i = pos; i && !isalnum(edbuf[i - 1]); i--) + ; + while (i && isalnum(edbuf[i - 1])) + i--; + i = pos - i; + input_moveto(pos - i); + input_delete_nofollow_chars(i); +} + +/* + * GH: make word upcase + */ +void upcase_word __P1 (char *,dummy) +{ + int opos = pos; + + if (last_edit_cmd == (function_any)upcase_word) + pos = 0; + else { + while (pos > 0 && IS_DELIM(edbuf[pos])) pos--; + while (pos > 0 && !IS_DELIM(edbuf[pos - 1])) pos--; + } + input_moveto(pos); + while (!IS_DELIM(edbuf[pos]) || + (last_edit_cmd == (function_any)upcase_word && edbuf[pos])) + input_overtype_follow(toupper(edbuf[pos])); + input_moveto(opos); +} + +/* + * GH: make word downcase + */ +void downcase_word __P1 (char *,dummy) +{ + int opos = pos; + + if (last_edit_cmd == (function_any)downcase_word) + pos = 0; + else { + while (pos > 0 && IS_DELIM(edbuf[pos])) pos--; + while (pos > 0 && !IS_DELIM(edbuf[pos - 1])) pos--; + } + input_moveto(pos); + while (!IS_DELIM(edbuf[pos]) || + (last_edit_cmd == (function_any)downcase_word && edbuf[pos])) { + input_overtype_follow(tolower(edbuf[pos])); + } + input_moveto(opos); +} + +/* + * get previous line from history list + */ +void prev_line __P1 (char *,dummy) +{ + int i = pickline - 1; + if (i < 0) i = MAX_HIST - 1; + if (hist[i]) { + if (hist[pickline] && strcmp(hist[pickline], edbuf)) { + free(hist[pickline]); + hist[pickline] = NULL; + } + if (!hist[pickline]) { + if (!(hist[pickline] = my_strdup(edbuf))) { + errmsg("malloc"); + return; + } + } + pickline = i; + clear_input_line(0); + strcpy(edbuf, hist[pickline]); + pos = edlen = strlen(edbuf); + } +} + +/* + * get next line from history list + */ +void next_line __P1 (char *,dummy) +{ + int i = pickline + 1; + if (i == MAX_HIST) i = 0; + if (hist[i]) { + if (hist[pickline] && strcmp(hist[pickline], edbuf)) { + free(hist[pickline]); + hist[pickline] = NULL; + } + if (!hist[pickline]) { + if (!(hist[pickline] = my_strdup(edbuf))) { + errmsg("malloc"); + return; + } + } + pickline = i; + clear_input_line(0); + strcpy(edbuf, hist[pickline]); + edlen = pos = strlen(edbuf); + } +} + +/* + * move one char backward + */ +void prev_char __P1 (char *,dummy) +{ + input_moveto(pos-1); +} + +/* + * move one char forward + */ +void next_char __P1 (char *,dummy) +{ + input_moveto(pos+1); +} + +/* + * Flash cursor at parentheses that matches c inserted before current pos + */ +static void flashparen __P1 (char,c) +{ + int lev, i; + if (line_status != 0) + return; + for (i = pos - 1, lev = 0; i >= 0; i--) { + if (ISRPAREN(edbuf[i])) { + lev++; + } else if (ISLPAREN(edbuf[i])) { + lev--; + if (!lev) { + if (LPAREN(c) == edbuf[i]) + break; + else + i = -1; + } + } + } + if (i >= 0) { + tty_gotoxy_opt(CURCOL(pos), CURLINE(pos), CURCOL(i), CURLINE(i)); + flashback = 1; + excursion = i; + } +} + +/* + * put cursor back where it belongs + */ +void putbackcursor __P0 (void) +{ + if (line_status == 0) + tty_gotoxy_opt(CURCOL(excursion), CURLINE(excursion), CURCOL(pos), CURLINE(pos)); + flashback = 0; +} + +/* + * insert a typed character on screen (if it is printable) + */ +void insert_char __P1 (char,c) +{ + if (((c & 0x80) || (c >= ' ' && c <= '~')) && edlen < BUFSIZE - 2) { + if (flashback) putbackcursor(); + input_insert_follow_chars(&c, 1); + if (ISRPAREN(c)) + flashparen(c); + } +} + +static void insert_string __P1 (char *,arg) +{ + char buf[BUFSIZE]; + int len; + + if (!arg || !*arg) + return; + + my_strncpy(buf, arg, BUFSIZE-1); + unescape(buf); + len = strlen(buf); + + if (len > 1) { + if (flashback) putbackcursor(); + input_insert_follow_chars(buf, len); + } else if (len == 1) + insert_char(buf[0]); /* also flash matching parentheses */ +} + +/* + * execute string as if typed + */ +void key_run_command __P1 (char *,cmd) +{ + clear_input_line(opt_compact && !echo_key); + if (echo_key) { + tty_printf("%s%s%s\n", edattrbeg, cmd, edattrend); + } else if (!opt_compact) + tty_putc('\n'); + + status(1); + error = 0; + + if (recordfile) + fprintf(recordfile, "%s\n", edbuf); + + parse_instruction(cmd, 1, 0, 1); + history_done = 0; +} + +void edit_bootstrap __P0 (void) +{ + default_completions(); +} + @@ -0,0 +1,75 @@ +/* public things from edit.c */ + +#ifndef _EDIT_H_ +#define _EDIT_H_ + +typedef struct { + char *name; + function_str funct; +} edit_function; + +extern edit_function internal_functions[]; + +/* + * GH: completion list, stolen from cancan 2.6.3a + * + * words[wordindex] is where the next word will go (always empty) + * words[wordindex].prev is last (least interesting) + * words[wordindex].next is 2nd (first to search for completion) + */ +#define WORD_UNIQUE 1 /* word is unique in list */ +#define WORD_RETAIN 2 /* permanent (#command) */ +typedef struct { + char *word; + int next, prev; + char flags; +} wordnode; + +extern char *hist[MAX_HIST]; +extern int curline; +extern int pickline; + +extern wordnode words[MAX_WORDS]; +extern int wordindex; + +/* public function declarations */ +void edit_bootstrap __P ((void)); + +int lookup_edit_name __P ((char *name, char **arg)); +int lookup_edit_function __P ((function_str funct)); +void draw_prompt __P ((void)); +void clear_input_line __P ((int deleteprompt)); +void draw_input_line __P ((void)); +void redraw_line __P ((char *dummy)); +void redraw_line_noprompt __P ((char *dummy)); +void transpose_words __P ((char *dummy)); +void transpose_chars __P ((char *dummy)); +void kill_to_eol __P ((char *dummy)); +void end_of_line __P ((char *dummy)); +void begin_of_line __P ((char *dummy)); +void del_char_right __P ((char *dummy)); +void del_char_left __P ((char *dummy)); +void to_history __P ((char *dummy)); +void put_history __P ((char *str)); +void complete_word __P ((char *dummy)); +void complete_line __P ((char *dummy)); +void put_word __P ((char *s)); +void set_custom_delimeters __P ((char *s)); +void to_input_line __P ((char *str)); +void clear_line __P ((char *dummy)); +void enter_line __P ((char *dummy)); +void putbackcursor __P ((void)); +void insert_char __P ((char c)); +void next_word __P ((char *dummy)); +void prev_word __P ((char *dummy)); +void del_word_right __P ((char *dummy)); +void del_word_left __P ((char *dummy)); +void upcase_word __P ((char *dummy)); +void downcase_word __P ((char *dummy)); +void prev_line __P ((char *dummy)); +void next_line __P ((char *dummy)); +void prev_char __P ((char *dummy)); +void next_char __P ((char *dummy)); +void key_run_command __P ((char *cmd)); + +#endif /* _EDIT_H_ */ @@ -0,0 +1,1450 @@ +/* + * eval.c -- functions for builtin calculator + * + * (created: Massimiliano Ghilardi (Cosmos), Jan 15th, 1995) + * + * Copyright (C) 1998 by Massimiliano Ghilardi + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <errno.h> +#include <unistd.h> +#include <time.h> +#include <sys/types.h> +#include <sys/time.h> +#include <limits.h> + +#include "defines.h" +#include "main.h" +#include "utils.h" +#include "cmd2.h" +#include "list.h" +#include "map.h" +#include "tty.h" +#include "edit.h" +#include "eval.h" + +#ifdef USE_RANDOM +# define get_random random +# define init_random srandom +#else +# define get_random lrand48 +# define init_random srand48 +#endif + +typedef struct { + int type; + long num; /* used for numeric types or as index for all variables */ + ptr txt; /* used for text types */ +} object; + +#define LEFT 1 +#define RIGHT 2 + +#define BINARY 0 +#define PRE_UNARY LEFT +#define POST_UNARY RIGHT + +#define LOWEST_UNARY_CODE 49 +/* + * it would be 47, but operators 47 '(' and 48 ')' + * are treated separately + */ + +enum op_codes { + null=0, comma, eq, or_or_eq, xor_xor_eq, and_and_eq, or_eq, xor_eq, and_eq, + lshift_eq, rshift_eq, plus_eq, minus_eq, times_eq, div_eq, ampersand_eq, + or_or, xor_xor, and_and, or, xor, and, + less, less_eq, greater, greater_eq, eq_eq, not_eq, + lshift, rshift, plus, minus, times, division, ampersand, + + colon_less, colon_greater, less_colon, greater_colon, + point_less, point_greater, less_point, greater_point, + colon, point, question, another_null, + + left_paren, right_paren, not, tilde, + pre_plus_plus, post_plus_plus, pre_minus_minus, post_minus_minus, + star, print, _random_, _attr_, colon_question, point_question, + pre_plus, pre_minus, a_circle, dollar, pre_null, post_null +}; + +typedef enum op_codes operator; + +typedef struct { + char priority, assoc, syntax, *name; + operator code; +} operator_list; + +typedef struct { + object obj[MAX_STACK]; + int curr_obj; + operator op[MAX_STACK]; + int curr_op; +} stack; + +char *error_msg[] = { + "unknown error", + "math stack overflow", + "math stack underflow", + "stack overflow", + "stack underflow", + "expression syntax", + "operator expected", + "value expected", + "division by zero", + "operand or index out of range", + "missing right parenthesis", + "missing left parenthesis", + "internal error!", + "operator not supported", + "operation not completed (internal error)", + "out of memory", + "text/string longer than limit, discarded", + "infinite loop", + "numeric value expected", + "string expected", + "missing label", + "missing separator `;'", + "#history recursion too deep", + "user break", + "too many defined variables", + "undefined variable", + "invalid digit in numeric value", + "bad attribute syntax", + "invalid variable name", +}; + +operator_list op_list[] = { + { 0, 0, 0, "", null }, + + { 1, LEFT, BINARY, ",", comma }, + + { 2, RIGHT, BINARY, "=", eq }, + { 2, RIGHT, BINARY, "||=", or_or_eq }, + { 2, RIGHT, BINARY, "^^=", xor_xor_eq }, + { 2, RIGHT, BINARY, "&&=", and_and_eq }, + { 2, RIGHT, BINARY, "|=", or_eq }, + { 2, RIGHT, BINARY, "^=", xor_eq }, + { 2, RIGHT, BINARY, "&=", and_eq }, + { 2, RIGHT, BINARY, "<<=", lshift_eq }, + { 2, RIGHT, BINARY, ">>=", rshift_eq }, + { 2, RIGHT, BINARY, "+=", plus_eq }, + { 2, RIGHT, BINARY, "-=", minus_eq }, + { 2, RIGHT, BINARY, "*=", times_eq }, + { 2, RIGHT, BINARY, "/=", div_eq }, + { 2, RIGHT, BINARY, "%=", ampersand_eq }, + + { 3, LEFT, BINARY, "||", or_or }, + + { 4, LEFT, BINARY, "^^", xor_xor }, + + { 5, LEFT, BINARY, "&&", and_and }, + + { 6, LEFT, BINARY, "|", or }, + + { 7, LEFT, BINARY, "^", xor }, + + { 8, LEFT, BINARY, "&", and }, + + { 9, LEFT, BINARY, "<", less }, + { 9, LEFT, BINARY, "<=", less_eq }, + { 9, LEFT, BINARY, ">", greater }, + { 9, LEFT, BINARY, ">=", greater_eq }, + { 9, LEFT, BINARY, "==", eq_eq }, + { 9, LEFT, BINARY, "!=", not_eq }, + + {10, LEFT, BINARY, "<<", lshift }, + {10, LEFT, BINARY, ">>", rshift }, + + {11, LEFT, BINARY, "+", plus }, + {11, LEFT, BINARY, "-", minus }, + + {12, LEFT, BINARY, "*", times }, + {12, LEFT, BINARY, "/", division }, + {12, LEFT, BINARY, "%", ampersand }, + + {14, LEFT, BINARY, ":<", colon_less }, + {14, LEFT, BINARY, ":>", colon_greater }, + {14, LEFT, BINARY, "<:", less_colon }, + {14, LEFT, BINARY, ">:", greater_colon }, + {14, LEFT, BINARY, ".<", point_less }, + {14, LEFT, BINARY, ".>", point_greater }, + {14, LEFT, BINARY, "<.", less_point }, + {14, LEFT, BINARY, ">.", greater_point }, + {14, LEFT, BINARY, ":", colon }, + {14, LEFT, BINARY, ".", point }, + {14, LEFT, BINARY, "?", question }, + + { 0, 0, 0, "", another_null }, + + { 0, RIGHT, PRE_UNARY, "(", left_paren }, + { 0, RIGHT, POST_UNARY, ")", right_paren }, + + {13, RIGHT, PRE_UNARY, "!", not }, + {13, RIGHT, PRE_UNARY, "~", tilde }, + {13, RIGHT, PRE_UNARY, "++", pre_plus_plus }, + {13, RIGHT, POST_UNARY, "++", post_plus_plus }, + {13, RIGHT, PRE_UNARY, "--", pre_minus_minus }, + {13, RIGHT, POST_UNARY, "--", post_minus_minus }, + {13, RIGHT, PRE_UNARY, "*", star }, + {13, RIGHT, PRE_UNARY, "%", print }, + {13, RIGHT, PRE_UNARY, "rand", _random_ }, + {13, RIGHT, PRE_UNARY, "attr", _attr_ }, + + {14, LEFT, PRE_UNARY, ":?", colon_question }, + {14, LEFT, PRE_UNARY, ".?", point_question }, + + {15, RIGHT, PRE_UNARY, "+", pre_plus }, + {15, RIGHT, PRE_UNARY, "-", pre_minus }, + {15, RIGHT, PRE_UNARY, "@", a_circle }, + {15, RIGHT, PRE_UNARY, "$", dollar }, + + { 0, 0, PRE_UNARY, "", pre_null }, + { 0, 0, POST_UNARY, "", post_null } +}; + +static stack stk; +static char *line; +static int depth; +int error; + +void print_error __P1 (int,err_num) +{ + clear_input_line(1); + if (error == NO_MEM_ERROR) { + tty_printf("#system call error: %s (%d", "malloc", ENOMEM); + tty_printf(": %s)\n", strerror(ENOMEM)); + } else + tty_printf("#error: %s.\n", error_msg[err_num]); +} + +static int push_op __P1 (operator *,op) +{ + if (stk.curr_op<MAX_STACK) { + stk.op[++stk.curr_op]=*op; + return 1; + } + else { + error=STACK_OV_ERROR; + return 0; + } +} + +static int pop_op __P1 (operator *,op) +{ + if (stk.curr_op>=0) { + *op=stk.op[stk.curr_op--]; + return 1; + } + else { + error=STACK_UND_ERROR; + return 0; + } +} + +static int push_obj __P1 (object *,obj) +{ + object *tmp; + + int curr=stk.curr_obj; + + if (curr<MAX_STACK) { + tmp = stk.obj + (stk.curr_obj = ++curr); + memmove(tmp, obj, sizeof(object)); + return 1; + } + else { + error=STACK_OV_ERROR; + return 0; + } +} + +static int pop_obj __P1 (object *,obj) +{ + object *tmp; + + int curr=stk.curr_obj; + + if (curr>=0) { + tmp = stk.obj + curr; + stk.curr_obj--; + memmove(obj, tmp, sizeof(object)); + return 1; + } + else { + error=STACK_UND_ERROR; + return 0; + } +} + +static int check_operator __P3 (char,side, operator *,op, int,mindepth) +{ + int i, max, len; + operator match; + char *name, c, d; + + if (!(c=*line) || c == CMDSEP) { + *op = side==BINARY ? null : side==LEFT ? pre_null : post_null; + return 1; + } + else if ((c=='$' || c=='@') && (d=line[1]) && (isalpha(d) || d=='_')) + return 0; /* Danger! found named variable */ + + else if (side==LEFT && c=='(') { + line++; + depth++; + *op=left_paren; + return 1; + } + else if (side==RIGHT && c==')') { + if (--depth >= mindepth) { + line++; + *op=right_paren; + } + else /* exit without touching the parenthesis */ + *op=post_null; + return 1; + } + else if (side==RIGHT && (c=='}' || c==']') && depth == mindepth) { + /* allow also exiting with a '}' or a ']' */ + --depth; + *op=post_null; + return 1; + } + + for (max=match=0, i=(side==BINARY ? 1 : LOWEST_UNARY_CODE); + *(name = op_list[i].name); i++) + if ((len=strlen(name)) > max && + (side==BINARY || side==op_list[i].syntax) && + !strncmp(line, name, (size_t)len)) { + match=op_list[i].code; + max=len; + } + + if (match) { + *op=match; + line+=max; + return 1; + } + else { + *op= side==BINARY ? null : side==PRE_UNARY ? pre_null : post_null; + if (side==BINARY) + error=NO_OPERATOR_ERROR; + } + return 0; +} + +static int check_object __P1 (object *,obj) +{ + long i=0, base = 10; + char c, *end, digit; + + if (c=*line, c == '#' || isdigit(c)) { + while (c == '#' || isalnum(c)) { + digit = !!isdigit(c); + if (c == '#') { + base = i; + i = 0; + if (!base) + base = 16; + } else { + i *= base; + if (digit) + i += (c - '0'); + else { + if (c >= 'a' && c <= 'z') + c = (c - 'a') + 'A'; + if (c - 'A' + 10 >= base) { + error=OUT_BASE_ERROR; + return 0; + } + i += (c - 'A' + 10); + } + } + c=*++line; + } + obj->type=TYPE_NUM; + obj->num=i; + i=1; + } + else if(c=='\"') { + end=first_valid(++line, '\"'); + if (*end) { + obj->type=TYPE_TXT; + obj->txt=ptrmcpy(obj->txt, line, end-line); + if (!REAL_ERROR) { + ptrunescape(obj->txt); + i=1; + line=end+1; + } + } + } + else if ((c=='$' || c=='@') && (c=line[1]) && (isalpha(c) || c=='_')) { + varnode *named_var; /* Found named variable */ + + if (*(line++) == '@') { + i = 0; + obj->type = TYPE_NUM_VAR; + } + else { + i = 1; + obj->type = TYPE_TXT_VAR; + } + end = line + 1; + while ((c=*end) && (isalpha(c) || c=='_' || isdigit(c))) + end++; + c = *end; *end = '\0'; + if (!(named_var = *lookup_varnode(line, i))) { + named_var = add_varnode(line, i); + if (REAL_ERROR) + return 0; + if (echo_int) { + PRINTF("#new variable: %s\n", line - 1); + } + } + *end = c; + line = end; + obj->num = named_var->index; + i = 1; + } + else if (!strncmp(line, "timer", 5)) { + obj->type = TYPE_NUM; + update_now(); + obj->num = diff_vtime(&now, &ref_time); + line += 5; + i = 1; + } + else if (!strncmp(line, "map", 3)) { + char buf[MAX_MAPLEN + 1]; + map_sprintf(buf); + obj->type = TYPE_TXT; + obj->txt = ptrmcpy(obj->txt, buf, strlen(buf)); + if (!REAL_ERROR) { + line += 3; + i = 1; + } + } + else if (!strncmp(line, "noattr", 6)) { + obj->type = TYPE_TXT; + obj->txt = ptrmcpy(obj->txt, tty_modestandoff, strlen(tty_modestandoff)); + obj->txt = ptrmcat(obj->txt, tty_modenorm, strlen(tty_modenorm)); + if (!REAL_ERROR) { + line += 6; + i = 1; + } + } + else + error=NO_VALUE_ERROR; + + return (int)i; +} + +static void check_delete __P1 (object *,obj) +{ + if (obj->type==TYPE_TXT && obj->txt) { + ptrdel(obj->txt); + obj->txt = NULL; + } +} + +static int exe_op __P1 (operator *,op) +{ + object o1, o2, *p=NULL; + long *l, rnd, delta; + ptr src = NULL, dst = NULL, start = NULL; + int srclen; + char *ssrc, *tmp; + int ret=0, i=0, j=0, danger=0; + + o1.txt = o2.txt = NULL; + + switch ((int)*op) { + case (int)comma: + if (pop_obj(&o2) && pop_obj(&o1)); + else if (REAL_ERROR) break; + check_delete(&o1); + p=&o2; + ret=1; + break; + case (int)eq: + if (pop_obj(&o2) && pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (o2.type==TYPE_NUM_VAR) { + o2.num = *VAR[o2.num].num; + o2.type = TYPE_NUM; + } + + if (o1.type==TYPE_NUM_VAR && o2.type==TYPE_NUM) { + *VAR[o1.num].num = o2.num; + p=&o2; + ret=1; + } + else if (o1.type==TYPE_TXT_VAR && + (o2.type==TYPE_TXT || o2.type==TYPE_TXT_VAR)) { + + if (o2.type==TYPE_TXT_VAR) { + o2.txt = ptrdup(*VAR[o2.num].str); + if (REAL_ERROR) break; + o2.type=TYPE_TXT; + } + + *VAR[o1.num].str = ptrcpy(*VAR[o1.num].str, o2.txt); + if (REAL_ERROR) break; + p=&o2; + ret=1; + } + else + error=SYNTAX_ERROR; + break; + case (int)or_or_eq: + case (int)xor_xor_eq: + case (int)and_and_eq: + case (int)or_eq: + case (int)xor_eq: + case (int)and_eq: + case (int)lshift_eq: + case (int)rshift_eq: + case (int)plus_eq: + case (int)minus_eq: + case (int)times_eq: + case (int)div_eq: + case (int)ampersand_eq: + if (pop_obj(&o2) && pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (o2.type==TYPE_NUM_VAR) { + o2.num = *VAR[o2.num].num; + o2.type = TYPE_NUM; + } + + if (o1.type==TYPE_NUM_VAR && o2.type==TYPE_NUM) { + l=VAR[o1.num].num; + + switch ((int)*op) { + case (int)or_or_eq: if ( o2.num) *l = 1; else *l = !!*l; break; + case (int)xor_xor_eq:if ( o2.num) *l = !*l; else *l = !!*l; break; + case (int)and_and_eq:if (!o2.num) *l = 0; else *l = !!*l; break; + case (int)or_eq: *l |= o2.num; break; + case (int)xor_eq: *l ^= o2.num; break; + case (int)and_eq: *l &= o2.num; break; + case (int)lshift_eq: *l <<= o2.num; break; + case (int)rshift_eq: *l >>= o2.num; break; + case (int)plus_eq: *l += o2.num; break; + case (int)minus_eq: *l -= o2.num; break; + case (int)times_eq: *l *= o2.num; break; + case (int)div_eq: *l /= o2.num; break; + case (int)ampersand_eq: + if ((*l %= o2.num) < 0) *l += o2.num; break; + } + o2.num=*l; + p=&o2; + ret=1; + } + else if (*op==plus_eq && o1.type==TYPE_TXT_VAR && + (o2.type==TYPE_TXT || o2.type==TYPE_TXT_VAR)) { + + if (o2.type==TYPE_TXT) + src=o2.txt; + else + src=*VAR[o2.num].str; + + *VAR[o1.num].str = ptrcat(*VAR[o1.num].str, src); + check_delete(&o2); + + dst = ptrdup(*VAR[o1.num].str); + if (REAL_ERROR) break; + + o1.type=TYPE_TXT; + o1.txt=dst; + p=&o1; + ret=1; + } + else if (*op==times_eq && o1.type==TYPE_TXT_VAR && + (o2.type==TYPE_NUM || o2.type==TYPE_NUM_VAR)) { + + if (o2.type==TYPE_NUM_VAR) { + o2.num = *VAR[o2.num].num; + o2.type = TYPE_NUM; + } + + if (o2.num < 0) + error = OUT_RANGE_ERROR; + else if (o2.num == 0) + ptrzero(*VAR[o1.num].str); + else if (o2.num == 1) + ; + else if (*VAR[o1.num].str && (delta = ptrlen(*VAR[o1.num].str))) { + long n; + *VAR[o1.num].str = ptrsetlen(*VAR[o1.num].str, delta*o2.num); + tmp = ptrdata(*VAR[o1.num].str); + for (n = 1; !error && n<o2.num; n++) + memcpy(tmp+n*delta, tmp, delta); + } + + check_delete(&o2); + dst = ptrdup(*VAR[o1.num].str); + if (REAL_ERROR) break; + + o1.type=TYPE_TXT; + o1.txt=dst; + p=&o1; + ret=1; + } + else + error=SYNTAX_ERROR; + break; + case (int)or_or: + case (int)xor_xor: + case (int)and_and: + case (int)or: + case (int)xor: + case (int)and: + case (int)less: + case (int)less_eq: + case (int)greater: + case (int)greater_eq: + case (int)eq_eq: + case (int)not_eq: + case (int)lshift: + case (int)rshift: + case (int)minus: + case (int)plus: + case (int)times: + case (int)division: + case (int)ampersand: + if (pop_obj(&o2) && pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (o1.type==TYPE_NUM_VAR) { + o1.num = *VAR[o1.num].num; + o1.type = TYPE_NUM; + } + if (o2.type==TYPE_NUM_VAR) { + o2.num = *VAR[o2.num].num; + o2.type = TYPE_NUM; + } + + if (o1.type==TYPE_NUM && o2.type==TYPE_NUM) { + if (!o2.num && + (*op==division || *op==ampersand)) { + error=DIV_BY_ZERO_ERROR; + break; + } + + switch ((int)*op) { + case (int)less: o1.num = o1.num < o2.num ? 1 : 0; break; + case (int)less_eq: o1.num = o1.num <= o2.num ? 1 : 0; break; + case (int)greater: o1.num = o1.num > o2.num ? 1 : 0; break; + case (int)greater_eq:o1.num = o1.num >= o2.num ? 1 : 0; break; + case (int)eq_eq: o1.num = o1.num == o2.num ? 1 : 0; break; + case (int)not_eq: o1.num = o1.num != o2.num ? 1 : 0; break; + case (int)or_or: o1.num = o1.num || o2.num; break; + case (int)xor_xor:if (o2.num) o1.num = !o1.num; break; + case (int)and_and: o1.num = o1.num && o2.num; break; + case (int)or: o1.num |= o2.num; break; + case (int)xor: o1.num ^= o2.num; break; + case (int)and: o1.num &= o2.num; break; + case (int)lshift: o1.num <<= o2.num; break; + case (int)rshift: o1.num >>= o2.num; break; + case (int)minus: o1.num -= o2.num; break; + case (int)plus: o1.num += o2.num; break; + case (int)times: o1.num *= o2.num; break; + case (int)division:o1.num /= o2.num; break; + case (int)ampersand: + if ((o1.num %= o2.num) < 0) o1.num += o2.num; break; + } + + p=&o1; + ret=1; + } + else if ((o1.type==TYPE_TXT || o1.type==TYPE_TXT_VAR) && + (o2.type==TYPE_TXT || o2.type==TYPE_TXT_VAR)) { + + if (o1.type==TYPE_TXT_VAR) { + o1.txt = ptrdup(*VAR[o1.num].str); + if (REAL_ERROR) break; + } + dst = o1.txt; + if (o2.type==TYPE_TXT) + src=o2.txt; + else + src=*VAR[o2.num].str; + + if (*op == plus) { + dst = ptrcat(dst, src); + o1.type = TYPE_TXT; + } else { + o1.type = TYPE_NUM; + o1.num = ptrcmp(dst, src); + switch ((int)*op) { + case (int)minus: break; + case (int)less: o1.num = o1.num < 0; break; + case (int)less_eq: o1.num = o1.num <= 0; break; + case (int)greater: o1.num = o1.num > 0; break; + case (int)greater_eq: o1.num = o1.num >= 0; break; + case (int)eq_eq: o1.num = o1.num == 0; break; + case (int)not_eq: o1.num = o1.num != 0; break; + default: + error=SYNTAX_ERROR; + p=NULL; ret=0; break; + } + check_delete(&o1); + } + check_delete(&o2); + if (!REAL_ERROR) { + o1.txt = dst; + p=&o1; + ret=1; + } + } + else if (*op==times + && (o1.type==TYPE_TXT_VAR || o1.type==TYPE_TXT) + && o2.type==TYPE_NUM) { + + if (o2.num > 0 && o1.type==TYPE_TXT_VAR) { + o1.txt = ptrdup(*VAR[o1.num].str); + if (REAL_ERROR) break; + } + dst = o1.txt; + + if (o2.num < 0) + error = OUT_RANGE_ERROR; + else if (o2.num == 0) + ptrzero(dst); + else if (o2.num == 1) + ; + else if (dst && (delta = ptrlen(dst))) { + long n; + dst = ptrsetlen(dst, delta*o2.num); + tmp = ptrdata(dst); + for (n = 1; !error && n<o2.num; n++) + memcpy(tmp+n*delta, tmp, delta); + } + check_delete(&o2); + if (REAL_ERROR) break; + + o1.type=TYPE_TXT; + o1.txt=dst; + p=&o1; + ret=1; + } + else + error=SYNTAX_ERROR; + break; + case (int)colon_less: + case (int)colon_greater: + case (int)less_colon: + case (int)greater_colon: + case (int)colon: + case (int)point_less: + case (int)point_greater: + case (int)less_point: + case (int)greater_point: + case (int)point: + if (pop_obj(&o2) && pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (o2.type==TYPE_NUM_VAR) { + o2.num = *VAR[o2.num].num; + o2.type = TYPE_NUM; + } + + if ((o1.type!=TYPE_TXT_VAR && o1.type!=TYPE_TXT) || o2.type!=TYPE_NUM) { + error=SYNTAX_ERROR; + break; + } + + if (o2.num<=0) { + error=OUT_RANGE_ERROR; + break; + } + + if (o1.type==TYPE_TXT_VAR) { + o1.type=TYPE_TXT; + o1.txt=dst=NULL; + src=start=*VAR[o1.num].str; + } + else { + /* Potentially dangerous: src and dst are overlapping */ + src=dst=start=o1.txt; + danger=1; + } + + if (!src) { + /* src == empty string. just return it */ + check_delete(&o2); + o1.txt = src; + if (!REAL_ERROR) + p=&o1; ret=1; + break; + } + + srclen = ptrlen(src); + ssrc = ptrdata(src); + + switch ((int)*op) { + case (int)colon_less: + while (o2.num && srclen) { + /* skip span of multiple word delimeters */ + while (srclen && memchr(DELIM, *ssrc, DELIM_LEN)) + srclen--, ssrc++, j++; + /* skip whole words */ + if (srclen && (tmp = memchrs(ssrc, srclen, DELIM, DELIM_LEN))) + i=tmp-ssrc, o2.num--, ssrc+=i, j+=i, srclen-=i; + else break; + } + + if (o2.num) { /* end of valid string before the n-th word */ + if (danger) + ; + else + dst = ptrcpy(dst, start); + } else { + if (danger) + ptrtrunc(dst, j); + else + dst = ptrmcpy(dst, ptrdata(start), j); + } + break; + case (int)colon: + case (int)colon_greater: + o2.num--; + /* skip span of multiple word delimeters */ + while (srclen && memchr(DELIM, *ssrc, DELIM_LEN)) + srclen--, ssrc++; + while (o2.num && srclen) { + /* skip whole words */ + if (srclen && (tmp = memchrs(ssrc, srclen, DELIM, DELIM_LEN))) { + i=tmp-ssrc, o2.num--, ssrc+=i, srclen-=i; + /* skip span of multiple word delimeters */ + while (srclen && memchr(DELIM, *ssrc, DELIM_LEN)) + srclen--, ssrc++; + } else break; + } + + if (o2.num) /* end of valid string before the n-th word */ + ptrzero(dst); + else { + if (*op==colon && + (tmp = memchrs(ssrc, srclen, DELIM, DELIM_LEN))) { + dst = ptrmcpy(dst, ssrc, tmp-ssrc); + } + else + dst = ptrmcpy(dst, ssrc, srclen); + } + break; + case (int)less_colon: + o2.num--; + while (o2.num && srclen) { + /* skip span of multiple word delimeters */ + while (srclen && memchr(DELIM, ssrc[srclen], DELIM_LEN)) + srclen--; + /* skip whole words */ + if (srclen && (tmp=memrchrs(ssrc, srclen, DELIM, DELIM_LEN))) + o2.num--, srclen=tmp-ssrc; + else break; + } + + if (o2.num) /* end of valid string before the n-th word */ + ptrzero(dst); + else + dst = ptrmcpy(dst, ssrc, srclen); + break; + case (int)greater_colon: + while (o2.num && srclen) { + /* skip span of multiple word delimeters */ + while (srclen && memchr(DELIM, ssrc[srclen], DELIM_LEN)) + srclen--; + /* skip whole words */ + if (srclen && (tmp=memrchrs(ssrc, srclen, DELIM, DELIM_LEN))) + o2.num--, srclen=tmp-ssrc; + else break; + } + + if (o2.num) /* end of valid string before the n-th word */ + dst = ptrcpy(dst, start); + else + dst = ptrmcpy(dst, ssrc+srclen+1, + ptrlen(start) - (ssrc+srclen+1 - ptrdata(start))); + break; + case (int)point: + dst = ptrmcpy(dst, ssrc+o2.num-1, 1); + break; + case (int)point_less: + j = o2.num < srclen ? o2.num : srclen; + if (danger) + ptrtrunc(dst, j); + else + dst = ptrmcpy(dst, ssrc, j); + break; + case (int)less_point: + j = srclen-o2.num+1; + if (j < 0) + j = 0; + if (danger) + ptrtrunc(dst, j); + else + dst = ptrmcpy(dst, ssrc, j); + break; + case (int)point_greater: + j = o2.num-1 < srclen ? o2.num-1 : srclen; + dst = ptrmcpy(dst, ssrc+j, srclen-j); + break; + case (int)greater_point: + j = srclen-o2.num; + if (j < 0) + j = 0; + dst = ptrmcpy(dst, ssrc+j, srclen-j); + break; + } + check_delete(&o2); + o1.txt = dst; + if (!REAL_ERROR) + p=&o1; ret=1; + break; + case (int)colon_question: + case (int)point_question: + if (pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (o1.type==TYPE_TXT) + src=o1.txt; + else if (o1.type==TYPE_TXT_VAR) + src=*VAR[o1.num].str; + else { + error=SYNTAX_ERROR; + break; + } + if (!src) { + /* empty string. return 0 */ + check_delete(&o1); + o1.type=TYPE_NUM; + o1.num =0; + p=&o1; + ret=1; + break; + } + + ssrc = ptrdata(src); + srclen = ptrlen(src); + + if (*op==colon_question) { + o1.num = 0; + /* skip span of multiple word delimeters */ + while (srclen && memchr(DELIM, *ssrc, DELIM_LEN)) + ssrc++, srclen--; + while (srclen) { + /* skip whole words */ + if (srclen && (tmp=memchrs(ssrc, srclen, DELIM, DELIM_LEN))) { + i=tmp-ssrc, o1.num++, ssrc+=i, srclen-=i; + /* skip span of multiple word delimeters */ + while (srclen && memchr(DELIM, *ssrc, DELIM_LEN)) + srclen--, ssrc++; + } else { + srclen=0; + o1.num++; + } + } + } + else + o1.num=srclen; + + check_delete(&o1); + o1.type=TYPE_NUM; + p=&o1; + ret=1; + break; + case (int)question: + if (pop_obj(&o2) && pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (o1.type==TYPE_TXT) + src = o1.txt; + else if (o1.type==TYPE_TXT_VAR) + src = *VAR[o1.num].str; + else + error = SYNTAX_ERROR; + + if (o2.type==TYPE_TXT) + dst = o2.txt; + else if (o2.type==TYPE_TXT_VAR) + dst = *VAR[o2.num].str; + else + error = SYNTAX_ERROR; + + if (!error) { + if ((ssrc = ptrfind(src, dst))) + i = (int)(ssrc - ptrdata(src)) + 1; + else + i = 0; + o1.type = TYPE_NUM; + o1.num = i; + p=&o1; ret=1; + } + check_delete(&o1); + check_delete(&o2); + break; + case (int)null: + case (int)another_null: + if (pop_obj(&o2) && pop_obj(&o1)); + else if (REAL_ERROR) break; + + check_delete(&o1); + check_delete(&o2); + + o1.type=0, o1.num=0, o1.txt=NULL; + + p=&o1; + ret=1; + break; + case (int)left_paren: + error=MISSING_PAREN_ERROR; + break; + case (int)right_paren: + if (pop_op(op)); + else if (REAL_ERROR) break; + + if (*op!=left_paren) + error=MISMATCH_PAREN_ERROR; + else + ret=1; + + break; + case (int)_random_: +#ifdef NO_RANDOM + error = NOT_SUPPORTED_ERROR; + break; +#endif + case (int)pre_plus: + case (int)pre_minus: + case (int)not: + case (int)tilde: + + if (pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (o1.type==TYPE_NUM_VAR) { + o1.num = *VAR[o1.num].num; + o1.type = TYPE_NUM; + } + if (o1.type==TYPE_NUM) { + if (*op==pre_minus) + o1.num=-o1.num; + else if (*op==not) + o1.num=!o1.num; + else if (*op==tilde) + o1.num=~o1.num; +#ifndef NO_RANDOM + else if (*op==_random_) { + if (o1.num <= 0) { + error=OUT_RANGE_ERROR; + break; + } else { + delta = LONG_MAX - LONG_MAX % o1.num; + while (rnd = get_random(), rnd > delta); + /* skip numbers that would alterate distribution */ + o1.num = rnd / (delta / o1.num); + } + } +#endif + p=&o1; + ret=1; + } + else + error=SYNTAX_ERROR; + break; + case (int)_attr_: + if (pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (o1.type==TYPE_TXT_VAR) { + o1.txt = ptrdup(*VAR[o1.num].str); + if (REAL_ERROR) break; + o1.type = TYPE_TXT; + } + + if (o1.type==TYPE_TXT) { + char dummy[CAPLEN]; /* just because attr_string must write somewhere */ + + if (o1.txt) + i = parse_attributes(ptrdata(o1.txt)); + else + i = NOATTRCODE; + if (i == -1) + error=BAD_ATTR_ERROR; + else { + o1.txt = ptrsetlen(o1.txt, CAPLEN); + if (REAL_ERROR) break; + attr_string(i, ptrdata(o1.txt), dummy); + ptrtrunc(o1.txt, strlen(ptrdata(o1.txt))); + p=&o1; + ret = 1; + } + } else + error=NO_STRING_ERROR; + break; + + case (int)star: + case (int)print: + if (pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (o1.type==TYPE_NUM_VAR) + o1.num = *VAR[o1.num].num; + else if (o1.type==TYPE_TXT_VAR) + o1.txt = *VAR[o1.num].str; + + if (o1.type==TYPE_NUM || o1.type==TYPE_NUM_VAR) { + o1.txt = NULL; + if (*op==print) { + char buf[LONGLEN]; + sprintf(buf, "%ld", o1.num); + o1.txt = ptrmcpy(o1.txt, buf, strlen(buf)); + } else { + char buf = (char)o1.num; + o1.txt = ptrmcpy(o1.txt, &buf, 1); + } + if (REAL_ERROR) break; + o1.type = TYPE_TXT; + p=&o1; ret=1; + } + else if (o1.type==TYPE_TXT || o1.type==TYPE_TXT_VAR) { + if (*op==print) { + if (o1.txt && ptrlen(o1.txt)) + o1.num = atol(ptrdata(o1.txt)); + else + o1.num = 0; + } else { + if (o1.txt && ptrlen(o1.txt)) + o1.num = (long)(byte)*ptrdata(o1.txt); + else + o1.num = 0; + } + check_delete(&o1); + o1.type = TYPE_NUM; + p=&o1; ret=1; + } + else + error=SYNTAX_ERROR; + break; + case (int)pre_plus_plus: + case (int)post_plus_plus: + case (int)pre_minus_minus: + case (int)post_minus_minus: + if (pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (o1.type==TYPE_NUM_VAR) { + l=VAR[o1.num].num; + o1.type=TYPE_NUM; + + if (*op==pre_plus_plus) + o1.num=++*l; + else if (*op==post_plus_plus) + o1.num=(*l)++; + else if (*op==pre_minus_minus) + o1.num=--*l; + else + o1.num=(*l)--; + + p=&o1; + ret=1; + } + else + error=SYNTAX_ERROR; + break; + case (int)a_circle: + case (int)dollar: + if (pop_obj(&o1)); + else if (REAL_ERROR) break; + + if (*op == dollar) + delta = 1; + else + delta = 0; + + if (o1.type==TYPE_NUM_VAR) { + o1.type=TYPE_NUM; + o1.num=*VAR[o1.num].num; + } + + if (o1.type==TYPE_NUM) { + if (o1.num<-NUMVAR || o1.num>=NUMPARAM) { + error=OUT_RANGE_ERROR; + break; + } + o1.type= delta ? TYPE_TXT_VAR : TYPE_NUM_VAR; + p=&o1; + ret=1; + } else { + varnode *named_var; + char c; + + if (o1.type==TYPE_TXT_VAR) + o1.txt = *VAR[o1.num].str; + else if (o1.type!=TYPE_TXT) { + error=SYNTAX_ERROR; + break; + } + + if (o1.txt && (tmp=ptrdata(o1.txt)) && + ((c=*tmp) == '_' || isalpha(c))) { + tmp++; + while ((c=*tmp) == '_' || isalnum(c)) + tmp++; + } + if (!o1.txt || *tmp) { + error=INVALID_NAME_ERROR; + break; + } + + if (!(named_var = *lookup_varnode(ptrdata(o1.txt), delta))) { + named_var = add_varnode(ptrdata(o1.txt), delta); + if (REAL_ERROR) + break; + if (echo_int) { + PRINTF("#new variable: %c%s\n", delta + ? '$' : '@', ptrdata(o1.txt)); + } + } + o1.type= delta ? TYPE_TXT_VAR : TYPE_NUM_VAR; + p=&o1; + ret=1; + } + break; + case (int)pre_null: + case (int)post_null: + ret=1; + break; + default: + break; + } + + if (REAL_ERROR) { + check_delete(&o2); + check_delete(&o1); + } + + if (!REAL_ERROR) { + if (!ret) + error=NOT_DONE_ERROR; + else if (p) { + if (push_obj(p)) + ; + else + check_delete(p); + } + } + + if (REAL_ERROR) + return 0; + + return ret; +} + +static int whichfirst __P2 (operator *,op1, operator *,op2) +{ + int p1, p2; + + p1=op_list[*op1].priority; + p2=op_list[*op2].priority; + if (p1!=p2) + return p1>p2 ? -1 : 1; + + p1 = op_list[*op1].assoc == LEFT; + return p1 ? -1 : 1; +} + +static int compare_and_unload __P1 (operator *,op) +{ + int first=0; + operator new; + + if (REAL_ERROR || stk.curr_op<0) + return 1; + + while (stk.curr_op>=0 && pop_op(&new) && !REAL_ERROR && + (first = whichfirst(&new, op)) == -1 && + (first = 0, exe_op(&new)) + ); + + if (!REAL_ERROR) { + if (!first) + return 1; + else + return push_op(&new); + } else + return 0; +} + +static int _eval __P1 (int,mindepth) +{ + operator op; + object obj; + char endreached = 0; + + for (;;) { + memzero(&obj, sizeof(obj)); + + while (*line==' ') line++; + if (!*line || *line == CMDSEP) + endreached = 1; + + while (check_operator(LEFT, &op, mindepth) && push_op(&op) && + !endreached) { + + if (error) return 0; + while (*line==' ') line++; + if (!*line || *line == CMDSEP) + endreached = 1; + } + + if (!endreached && check_object(&obj) && push_obj(&obj)); + else if (error) return 0; + + while (*line==' ') line++; + if (!*line || *line == CMDSEP) + endreached = 1; + + while (check_operator(RIGHT, &op, mindepth) && compare_and_unload(&op) && + exe_op(&op) && depth>=mindepth && !endreached) { + + if (error) return 0; + while (*line==' ') + line++; + if (!*line || *line == CMDSEP) + endreached = 1; + } + if (error) return 0; + + if (endreached || depth < mindepth) + break; + + if (check_operator(BINARY, &op, mindepth) && + compare_and_unload(&op) && push_op(&op)); + else if (error) return 0; + } + return 1; +} + +int eval_any __P3 (long *,lres, ptr *,pres, char **,what) +{ + int printmode; + long val; + ptr txt; + object res; + + if (pres) + printmode = PRINT_AS_PTR; + else if (lres) + printmode = PRINT_AS_LONG; + else + printmode = PRINT_NOTHING; + + error=0; + stk.curr_obj=stk.curr_op=-1; + line = *what; + + depth = 0; + (void)_eval(0); + + if (!error) + (void)pop_obj(&res); + if (error) { + if (opt_debug) { + PRINTF("#result not available\n"); + } + } else if (printmode!=PRINT_NOTHING || opt_debug) { + if (res.type==TYPE_NUM || res.type==TYPE_NUM_VAR) { + + val = res.type==TYPE_NUM ? res.num : *VAR[res.num].num; + + if (printmode==PRINT_AS_PTR) { + *pres = ptrsetlen(*pres, LONGLEN); + if (!MEM_ERROR) { + sprintf(ptrdata(*pres), "%ld", val); + (*pres)->len = strlen(ptrdata(*pres)); + } + } else if (printmode==PRINT_AS_LONG) + *lres=val; + + if (opt_debug) { + if (error) { + PRINTF("#result not available\n"); + } else { + PRINTF("#result: %ld\n", val); + } + } + } else { + txt = res.type==TYPE_TXT ? res.txt : *VAR[res.num].str; + if (printmode==PRINT_AS_PTR) { + if (txt && *ptrdata(txt)) { + if (res.type == TYPE_TXT) + /* shortcut! */ + *pres = txt; + else + *pres = ptrcpy(*pres, txt); + } else + ptrzero(*pres); + } + if (opt_debug) { + if (error) { + PRINTF("#result not available\n"); + } else if (txt && *ptrdata(txt)) { + PRINTF("#result: %s\n", ptrdata(txt)); + } else { + PRINTF("#result empty\n"); + } + } + } + } + *what=line; + + if (!error) { + if (printmode==PRINT_AS_PTR && res.type == TYPE_TXT + && res.txt && ptrdata(res.txt)) + /* shortcut! */ + ; + else + check_delete(&res); + } else { + while (stk.curr_obj>=0) { + pop_obj(&res); + check_delete(&res); + } + res.type = 0; + } + + if (res.type==TYPE_TXT_VAR) + res.type = TYPE_TXT; + else if (res.type==TYPE_NUM_VAR) + res.type = TYPE_NUM; + + return res.type; +} + +int evalp __P2 (ptr *,res, char **,what) +{ + return eval_any((long *)0, res, what); +} + +int evall __P2 (long *,res, char **,what) +{ + return eval_any(res, (ptr *)0, what); +} + +int evaln __P1 (char **,what) +{ + return eval_any((long *)0, (ptr *)0, what); +} + @@ -0,0 +1,58 @@ +/* public things from eval.c */ + +#ifndef _EVAL_H_ +#define _EVAL_H_ + +#define STACK_OV_ERROR 1 +#define STACK_UND_ERROR 2 +#define DYN_STACK_OV_ERROR 3 +#define DYN_STACK_UND_ERROR 4 +#define SYNTAX_ERROR 5 +#define NO_OPERATOR_ERROR 6 +#define NO_VALUE_ERROR 7 +#define DIV_BY_ZERO_ERROR 8 +#define OUT_RANGE_ERROR 9 +#define MISSING_PAREN_ERROR 10 +#define MISMATCH_PAREN_ERROR 11 +#define INTERNAL_ERROR 12 +#define NOT_SUPPORTED_ERROR 13 +#define NOT_DONE_ERROR 14 +#define NO_MEM_ERROR 15 +#define MEM_LIMIT_ERROR 16 +#define MAX_LOOP_ERROR 17 +#define NO_NUM_VALUE_ERROR 18 +#define NO_STRING_ERROR 19 +#define NO_LABEL_ERROR 20 +#define MISSING_SEPARATOR_ERROR 21 +#define HISTORY_RECURSION_ERROR 22 +#define USER_BREAK 23 +#define OUT_OF_VAR_SPACE_ERROR 24 +#define UNDEFINED_VARIABLE_ERROR 25 +#define OUT_BASE_ERROR 26 +#define BAD_ATTR_ERROR 27 +#define INVALID_NAME_ERROR 28 + +#define TYPE_NUM 1 +#define TYPE_TXT 2 +#define TYPE_NUM_VAR 3 +#define TYPE_TXT_VAR 4 + +#define PRINT_NOTHING 0 +#define PRINT_AS_PTR 1 +#define PRINT_AS_LONG 2 + +int eval_any __P ((long *lres, ptr *pres, char **what)); +int evalp __P (( ptr *pres, char **what)); +int evall __P ((long *lres, char **what)); +int evaln __P (( char **what)); + +void print_error __P ((int err_num)); + +extern char *error_msg[]; +extern int error; + +#define REAL_ERROR (error && error != USER_BREAK) +#define MEM_ERROR (error == NO_MEM_ERROR || error == MEM_LIMIT_ERROR) + +#endif /* _EVAL_H_ */ + diff --git a/follow.c b/follow.c new file mode 100644 index 0000000..fe75558 --- /dev/null +++ b/follow.c @@ -0,0 +1,166 @@ +/* + * follow.c -- interactively print an ASCII file. + * + * This file is placed in the public domain. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> +#include <time.h> +#include <unistd.h> +#include <sys/time.h> +#include <sys/types.h> + +#ifndef USE_SGTTY +# ifdef APOLLO +# include "/sys5.3/usr/include/sys/termio.h" +# else +/* + * including both termio.h and termios.h might be an overkill, and gives + * many warnings, but seems to be necessary at times. works anyway. + */ +# include <termios.h> +# include <termio.h> +# endif +/* #else USE_SGTTY */ +#endif + +/* + * SunOS 4 doesn't have function headers and has the defs needed from + * ioctl.h in termios.h. Does it compile with USE_SGTTY? + */ +#if (defined(sun) && defined(sparc) && ! defined(__SVR4)) +extern int printf(); +#else +# include <sys/ioctl.h> +#endif + +#ifdef BSD_LIKE +# include <sys/ioctl_compat.h> +# define O_RAW RAW +# define O_ECHO ECHO +# define O_CBREAK CBREAK +#endif + +#if defined(TCSETS) || defined(TCSETATTR) +# ifndef TCSETS /* cc for HP-UX SHOULD define this... */ +# define TCSETS TCSETATTR +# define TCGETS TCGETATTR +# endif +typedef struct termios termiostruct; +#else +# define TCSETS TCSETA +# define TCGETS TCGETA +typedef struct termio termiostruct; +#endif + +#ifdef VSUSP +# define O_SUSP VSUSP +#else +# ifdef SWTCH +# define O_SUSP SWTCH +# else +# define O_SUSP SUSP +# endif +#endif + +/*int ioctl();*/ + +#ifdef USE_SGTTY +static struct sgttyb ttybsave; +static struct tchars tcsave; +static struct ltchars ltcsave; +#else /* not USE_SGTTY */ +static termiostruct ttybsave; +#endif /* USE_SGTTY */ + +/* + * Terminal handling routines: + * These are one big mess of left-justified chicken scratches. + * It should be handled more cleanly...but unix portability is what it is. + */ + +/* + * Set the terminal to character-at-a-time-without-echo mode, and save the + * original state in ttybsave + */ +void set_terminal() +{ +#ifdef USE_SGTTY + struct sgttyb ttyb; + struct ltchars ltc; + ioctl(0, TIOCGETP, &ttybsave); + ioctl(0, TIOCGETC, &tcsave); + ioctl(0, TIOCGLTC, <csave); + ttyb = ttybsave; + ttyb.sg_flags = (ttyb.sg_flags|O_CBREAK) & ~O_ECHO; + ioctl(tty_read_fd, TIOCSETP, &ttyb); + ltc = ltcsave; + ltc.t_suspc = -1; + ioctl(0, TIOCSLTC, <c); +#else /* not USE_SGTTY */ + termiostruct ttyb; + ioctl(0, TCGETS, &ttyb); + ttybsave = ttyb; + ttyb.c_lflag &= ~(ECHO|ICANON); + ttyb.c_cc[VTIME] = 0; + ttyb.c_cc[VMIN] = 1; + /* disable the special handling of the suspend key (handle it ourselves) */ + ttyb.c_cc[O_SUSP] = 0; + ioctl(0, TCSETS, &ttyb); +#endif /* USE_SGTTY */ +} + +/* + * Reset the terminal to its original state + */ +void reset_terminal() +{ +#ifdef USE_SGTTY + ioctl(0, TIOCSETP, &ttybsave); + ioctl(0, TIOCSETC, &tcsave); + ioctl(0, TIOCSLTC, <csave); +#else /* not USE_SGTTY */ + ioctl(0, TCSETS, &ttybsave); +#endif /* USE_SGTTY */ +} + +int main(int argc, char *argv[]) { + FILE *f; + char c = 0, buf[512]; + int d; + + if (argc < 2) { + fprintf(stderr, "needed a file name\n"); + exit(0); + } + f = fopen(argv[1], "r"); + if (!f) { + fprintf(stderr, "unable to open %s\n", argv[1]); + exit(0); + } + + set_terminal(); + while(c!=0x1b) { + read(0, &c, 1); + if (c == 0x0a || c == 0x0d) { + if (fgets(buf, 512, f)) + fputs(buf, stdout); + else + break; + } + else { + if ((d = fgetc(f)) != EOF) + putchar(d); + else + break; + } + fflush(stdout); + } + reset_terminal(); + fputs("\033[0m\n", stdout); + return 0; +} + diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..0ec27bc --- /dev/null +++ b/install-sh @@ -0,0 +1,294 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# 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 "$0: no input file specified" >&2 + exit 1 +else + : +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d "$dst" ]; then + instcmd=: + chmodcmd="" + else + instcmd=$mkdirprog + 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" ] || [ -d "$src" ] + then + : + else + echo "$0: $src does not exist" >&2 + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "$0: no destination specified" >&2 + exit 1 + else + : + 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 + : + 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 + : + fi + + pathcomp=$pathcomp/ +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd "$dst" && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; 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 + : + fi + +# Make a couple of temp file names in the proper directory. + + dsttmp=$dstdir/#inst.$$# + rmtmp=$dstdir/#rm.$$# + +# Trap to clean up temp files at exit. + + trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 + trap '(exit $?); exit' 1 2 13 15 + +# Move or copy the file name to the temp name + + $doit $instcmd "$src" "$dsttmp" && + +# 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 :;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && + +# Now remove or move aside any old file at destination location. We try this +# two ways since rm can't unlink itself on some systems and the destination +# file might be busy for other reasons. In this case, the final cleanup +# might fail but the new file should still install successfully. + +{ + if [ -f "$dstdir/$dstfile" ] + then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || + $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || + { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit + } + else + : + fi +} && + +# Now rename the file to the real destination. + + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + +fi && + +# The final little trick to "correctly" pass the exit status to the exit trap. + +{ + (exit 0); exit +} @@ -0,0 +1,679 @@ +/* + * list.c -- list utility functions. + * + * Copyright (C) 1998 by Massimiliano Ghilardi + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <time.h> +#include <sys/types.h> +#include <sys/time.h> + +#ifdef USE_REGEXP +# include "malloc.h" +# include <regex.h> +#endif + +#include "defines.h" +#include "main.h" +#include "utils.h" +#include "cmd2.h" +#include "tty.h" +#include "eval.h" + +/* + * compare two times, return -1 if t1 < t2, 1 if t1 > t2, 0 if t1 == t2 + */ +int cmp_vtime __P2 (vtime *,t1, vtime *,t2) +{ + int i; + i = t1->tv_sec < t2->tv_sec ? -1 : t1->tv_sec > t2->tv_sec ? 1 : 0; + if (!i) + i = t1->tv_usec < t2->tv_usec ? -1 : t1->tv_usec > t2->tv_usec ? 1 : 0; + return i; +} + +/* + * add t2 to t1 (i.e. t1 += t2) + */ +void add_vtime __P2 (vtime *,t1, vtime *,t2) +{ + t1->tv_sec += t2->tv_sec; + if ((t1->tv_usec += t2->tv_usec) >= uSEC_PER_SEC) { + t1->tv_sec += t1->tv_usec / uSEC_PER_SEC; + t1->tv_usec %= uSEC_PER_SEC; + } +} + +/* + * Return t1 - t2, in milliseconds + */ +long diff_vtime __P2 (vtime *,t1, vtime *,t2) +{ + return (t1->tv_sec - t2->tv_sec) * mSEC_PER_SEC + + (t1->tv_usec - t2->tv_usec) / uSEC_PER_mSEC; +} + +int rev_sort __P2 (defnode *,node1, defnode *,node2) +{ + return -1; +} + +/* + * standard ASCII comparison between nodes + */ +int ascii_sort __P2 (defnode *,node1, defnode *,node2) +{ + return strcmp(node1->sortfield, node2->sortfield); +} + +int rev_ascii_sort __P2 (defnode *,node1, defnode *,node2) +{ + return strcmp(node2->sortfield, node1->sortfield); +} + + +/* + * comparison between times of execution of nodes + * (return -1 if node1->when < node2->when) + */ +int time_sort __P2 (defnode *,node1, defnode *,node2) +{ + return cmp_vtime(&((delaynode *)node1)->when, &((delaynode *)node2)->when); +} + +/* + * reverse comparison between times of execution of nodes + * (return -1 if node1->when > node2->when) + */ +int rev_time_sort __P2 (defnode *,node1, defnode *,node2) +{ + return cmp_vtime(&((delaynode *)node2)->when, &((delaynode *)node1)->when); +} + +/* + * compute the hash value of a name + */ +int hash __P2 (char *,name, int,optlen) +{ + int h = 0, i = 0; + if (optlen < 0) + optlen = strlen(name); + while (optlen-- > 0) { + h += ((*name++) ^ i) << i; + if (++i == LOG_MAX_HASH) + i = 0; + } + return (h + (h >> LOG_MAX_HASH) + (h >> (2*LOG_MAX_HASH))) & (MAX_HASH-1); +} + +/* + * generic list node adding routine + */ +void add_node __P3 (defnode *,newnode, defnode **,base, function_sort,sort) +{ + while((*base) && (!sort || (*sort)(newnode, *base) > 0)) + base = &(*base)->next; + newnode->next = *base; + *base = newnode; +} + +static void add_sortednode __P3 (sortednode *,newnode, sortednode **,base, function_sort,sort) +{ + while((*base) && (!sort || (*sort)((defnode *)newnode, (defnode *)*base) > 0)) + base = &(*base)->snext; + newnode->snext = *base; + *base = newnode; +} + +void reverse_list __P1 (defnode **,base) +{ + defnode *node = *base, *list = NULL, *tmp; + while (node) { + tmp = node->next; + node->next = list; + list = node; + node = tmp; + } + *base = list; +} + +void reverse_sortedlist __P1 (sortednode **,base) +{ + sortednode *node = *base, *list = NULL, *tmp; + while (node) { + tmp = node->snext; + node->snext = list; + list = node; + node = tmp; + } + *base = list; +} + +static sortednode **selflookup_sortednode __P2 (sortednode *,self, sortednode **,base) +{ + sortednode **p = base; + while (*p && *p != self) + p = &(*p)->snext; + if (!*p) { + PRINTF("#internal error, selflookup_sortednode(`%s') failed!\n", self->sortfield); + error = INTERNAL_ERROR; + } + return p; +} + +/* + * add a node to the alias list + */ +void add_aliasnode __P2 (char *,name, char *,subst) +{ + aliasnode *new = (aliasnode*)malloc(sizeof(aliasnode)); + if (!new) { + errmsg("malloc"); + return; + } + + new->group = NULL; + new->active = 1; + new->name = my_strdup(name); + new->subst = my_strdup(subst); + if ((name && !new->name) || (subst && !new->subst)) { + errmsg("malloc"); + if (new->name) + free(new->name); + if (new->subst) + free(new->subst); + free(new); + return; + } + add_node((defnode*)new, (defnode**)&aliases[hash(name,-1)], rev_sort); + add_sortednode((sortednode*)new, (sortednode**)&sortedaliases, rev_ascii_sort); +} + +/* + * add a node to the marker list + */ +void add_marknode __P4 (char *,pattern, int,attrcode, char,mbeg, char,wild) +{ + marknode **p, *new = (marknode*)malloc(sizeof(marknode)); + int i; + if (!new) { + errmsg("malloc"); + return; + } + new->pattern = my_strdup(pattern); + new->attrcode = attrcode; + new->start = new->end = NULL; + new->mbeg = mbeg; + new->wild = wild; + if (!new->pattern) { + errmsg("malloc"); + free(new); + return; + } +#ifdef DO_SORT + add_node((defnode*)new, (defnode**)&markers, ascii_sort); +#else + for (p=&markers, i=1; *p && (a_nice==0 || i<a_nice); p = &(*p)->next, i++) + ; + new->next = *p; + *p = new; +#endif +} + +/* + * add a node to the action list + */ +void add_actionnode __P6 (char *,pattern, char *,command, char *,label, int,active, int,type, void *,vregexp) +{ + actionnode **p, *new = (actionnode*)malloc(sizeof(actionnode)); + int i; + if (!new) { + errmsg("malloc"); + return; + } + + new->group = NULL; + new->pattern = my_strdup(pattern); + new->command = my_strdup(command); + new->label = my_strdup(label); + new->active = active; + new->type = type; +#ifdef USE_REGEXP + new->regexp = vregexp; +#endif + if (!new->pattern || (command && !new->command) || (label && !new->label)) { + errmsg("malloc"); + if (new->pattern) + free(new->pattern); + if (new->command) + free(new->command); + if (new->label) + free(new->label); + free(new); + return; + } +#ifdef DO_SORT + add_node((defnode*)new, (defnode**)&actions, ascii_sort); +#else + for (p=&actions, i=1; *p && (a_nice==0 || i<a_nice); p = &(*p)->next, i++) + ; + new->next = *p; + *p = new; +#endif +} + +/* + * add a node to the prompt list + */ +void add_promptnode __P6 (char *,pattern, char *,command, char *,label, int,active, int,type, void *,vregexp) +{ + promptnode **p, *new = (promptnode*)malloc(sizeof(promptnode)); + int i; + if (!new) { + errmsg("malloc"); + return; + } + + new->pattern = my_strdup(pattern); + new->command = my_strdup(command); + new->label = my_strdup(label); + new->active = active; + new->type = type; +#ifdef USE_REGEXP + new->regexp = vregexp; +#endif + if (!new->pattern || (command && !new->command) || (label && !new->label)) { + errmsg("malloc"); + if (new->pattern) + free(new->pattern); + if (new->command) + free(new->command); + if (new->label) + free(new->label); + free(new); + return; + } +#ifdef DO_SORT + add_node((defnode*)new, (defnode**)&prompts, ascii_sort); +#else + for (p=&prompts, i=1; *p && (a_nice==0 || i<a_nice); p = &(*p)->next, i++) + ; + new->next = *p; + *p = new; +#endif +} + +/* + * add a node to the keydef list + */ +void add_keynode __P5 (char *,name, char *,sequence, int,seqlen, function_str,funct, char *,call_data) +{ + keynode *new = (keynode*)malloc(sizeof(keynode)); + if (!new) { + errmsg("malloc"); + return; + } + new->name = my_strdup(name); + if (!seqlen) seqlen = strlen(sequence); + new->sequence = (char *)malloc(seqlen + 1); + memmove(new->sequence, sequence, seqlen); + new->seqlen = seqlen; + new->funct = funct; + new->call_data = my_strdup(call_data); + if (!new->name || !new->sequence || (call_data && !new->call_data)) { + errmsg("malloc"); + if (new->name) + free(new->name); + if (new->sequence) + free(new->sequence); + if (new->call_data) + free(new->call_data); + free(new); + return; + } + add_node((defnode*)new, (defnode**)&keydefs, ascii_sort); +} + +/* + * add a node to the delayed command list + * is_dead == 1 means when < now (and so cannot be executed anymore) + */ +delaynode *add_delaynode __P4 (char *,name, char *,command, vtime *,when, int,is_dead) +{ + delaynode *new = (delaynode*)malloc(sizeof(delaynode)); + if (!new) { + errmsg("malloc"); + return NULL; + } + new->name = my_strdup(name); + new->command = my_strdup(command); + if (!new->name || (command && !new->command)) { + errmsg("malloc"); + if (new->name) + free(new->name); + if (new->command) + free(new->command); + free(new); + return NULL; + } + + new->when.tv_sec = when->tv_sec; + new->when.tv_usec = when->tv_usec; + if (is_dead) + add_node((defnode*)new, (defnode**)&dead_delays, rev_time_sort); + else + add_node((defnode*)new, (defnode**)&delays, time_sort); + + return new; +} + +/* + * add a node to named variables list + * + * do NOT allocate a ptr! + */ +varnode *add_varnode __P2 (char *,name, int,type) +{ + varnode *new; + int m, n; + + if (type) + type = 1; + + if (num_named_vars[type] >= max_named_vars) { + /* we are running low on var pointers. try to enlarge */ + m = NUMTOT + max_named_vars; + n = NUMTOT + max_named_vars * 2; + if (n < 0) { + /* overflow */ + print_error(error=OUT_OF_VAR_SPACE_ERROR); + return NULL; + } + else { + vars *newvar; + if ((newvar = (vars *)realloc(var, n*sizeof(vars) ))) + ; + else if ((newvar = (vars *)malloc( n*sizeof(vars) ))) { + memmove(newvar, var, m * sizeof(vars)); + free((void *)var); + } else { + errmsg("malloc"); + return NULL; + } + var = newvar; + max_named_vars += n-m; + memzero(var + m, (n-m)*sizeof(vars)); + } + } + + new = (varnode*)malloc(sizeof(varnode)); + if (!new) { + errmsg("malloc"); + return NULL; + } + new->name = my_strdup(name); + if (name && !new->name) { + errmsg("malloc"); + free(new); + return NULL; + } + new->num = 0; + new->str = (ptr)0; + new->index = m = NUMPARAM + num_named_vars[type]; + + if (type) + VAR[m].str = &new->str; + else + VAR[m].num = &new->num; + num_named_vars[type]++; + + add_node((defnode*)new, (defnode**)&named_vars[type][hash(name,-1)], rev_sort); + add_sortednode((sortednode*)new, (sortednode**)&sortednamed_vars[type], rev_ascii_sort); + return new; +} + +/* + * look up an alias node by name: + * return pointer to pointer to node or a pointer to NULL if nothing found + */ +aliasnode **lookup_alias __P1 (char *,name) +{ + aliasnode **p = &aliases[hash(name,-1)]; + while (*p && strcmp(name, (*p)->name)) + p = &(*p)->next; + return p; +} + +/* + * look up an action node by label: + * return pointer to pointer to node or a pointer to NULL if nothing found + */ +actionnode **lookup_action __P1 (char *,label) +{ + actionnode **p = &actions; + while (*p && strcmp(label, (*p)->label)) + p = &(*p)->next; + return p; +} + +/* + * look up an action node by pattern: + * return pointer to pointer to node or a pointer to NULL if nothing found + */ +actionnode **lookup_action_pattern __P1 (char *,pattern) +{ + actionnode **p = &actions; + while (*p && strcmp(pattern, (*p)->pattern)) + p = &(*p)->next; + return p; +} + +/* + * look up a prompt node by label: + * return pointer to pointer to node or a pointer to NULL if nothing found + */ +actionnode **lookup_prompt __P1 (char *,label) +{ + promptnode **p = &prompts; + while (*p && strcmp(label, (*p)->label)) + p = &(*p)->next; + return p; +} + +/* + * look up an marker node by pattern: + * return pointer to pointer to node or a pointer to NULL if nothing found + */ +marknode **lookup_marker __P2 (char *,pattern, char,mbeg) +{ + marknode **p = &markers; + while (*p && (mbeg != (*p)->mbeg || strcmp(pattern, (*p)->pattern))) + p = &(*p)->next; + return p; +} + +/* + * look up a key node by name: + * return pointer to pointer to node or a pointer to NULL if nothing found + */ +keynode **lookup_key __P1 (char *,name) +{ + keynode **p = &keydefs; + + while (*p && strcmp(name, (*p)->name)) + p = &(*p)->next; + return p; +} + +/* + * look up a delayed command node by label: + * return pointer to pointer to node or a pointer to NULL if nothing found + */ +delaynode **lookup_delay __P2 (char *,name, int,is_dead) +{ + delaynode **p = (is_dead ? &dead_delays : &delays); + while (*p && strcmp(name, (*p)->name)) + p = &(*p)->next; + return p; +} + +/* + * look up a named variable node by name: + * return pointer to pointer to node or a pointer to NULL if nothing found + */ +varnode **lookup_varnode __P2 (char *,name, int,type) +{ + varnode **p = &named_vars[type][hash(name,-1)]; + while (*p && strcmp(name, (*p)->name)) + p = &(*p)->next; + return p; +} + +/* + * delete an alias node, given a pointer to its precessor's pointer + */ +void delete_aliasnode __P1 (aliasnode **,base) +{ + aliasnode *p = *base; + *base = p->next; + if (*(base = (aliasnode**)selflookup_sortednode + ((sortednode*)p, (sortednode**)&sortedaliases))) + *base = p->snext; + else + return; + if (p->name) free(p->name); + if (p->subst) free(p->subst); + free((void*)p); +} + +/* + * delete an action node, given a pointer to its precessor's pointer + */ +void delete_actionnode __P1 (actionnode **,base) +{ + actionnode *p = *base; + if (p->pattern) free(p->pattern); + if (p->command) free(p->command); + if (p->label) free(p->label); +#ifdef USE_REGEXP + if (p->type == ACTION_REGEXP && p->regexp) { + regfree((regex_t *)p->regexp); + free(p->regexp); + } +#endif + *base = p->next; + free((void*)p); +} + +/* + * delete an prompt node, given a pointer to its precessor's pointer + */ +void delete_promptnode __P1 (promptnode **,base) +{ + promptnode *p = *base; + if (p->pattern) free(p->pattern); + if (p->command) free(p->command); + if (p->label) free(p->label); +#ifdef USE_REGEXP + if (p->type == ACTION_REGEXP && p->regexp) { + regfree((regex_t *)p->regexp); + free(p->regexp); + } +#endif + *base = p->next; + free((void*)p); +} + +/* + * delete an marker node, given a pointer to its precessor's pointer + */ +void delete_marknode __P1 (marknode **,base) +{ + marknode *p = *base; + if (p->pattern) free(p->pattern); + *base = p->next; + free((void*)p); +} + +/* + * delete a keydef node, given a pointer to its precessor's pointer + */ +void delete_keynode __P1 (keynode **,base) +{ + keynode *p = *base; + if (p->name) free(p->name); + if (p->sequence) free(p->sequence); + if (p->call_data) free(p->call_data); + *base = p->next; + free((void*)p); +} + +/* + * delete a delayed command node, given a pointer to its precessor's pointer + */ +void delete_delaynode __P1 (delaynode **,base) +{ + delaynode *p = *base; + if (p->name) free(p->name); + if (p->command) free(p->command); + *base = p->next; + free((void*)p); +} + +/* + * delete a named variable node, given a pointer to its precessor's pointer + */ +void delete_varnode __P2 (varnode **,base, int,type) +{ + varnode *p = *base; + int idx = p->index, i, n; + + *base = p->next; + if (*(base = (varnode**)selflookup_sortednode + ((sortednode*)p, (sortednode**)&sortednamed_vars[type]))) + *base = p->snext; + else + return; + if (p->name) free(p->name); + if (type && p->str) ptrdel(p->str); + free((void*)p); + + i = NUMPARAM + --num_named_vars[type]; + + if (idx == i) + return; + + /* now I must fill the hole in var[idx].*** */ + + for (n = 0; n < MAX_HASH; n++) + for (p = named_vars[type][n]; p; p = p->next) + if (p->index == i) { + n = MAX_HASH; + break; + } + + if (!p) { /* should NEVER happen */ + print_error(error=UNDEFINED_VARIABLE_ERROR); + return; + } + + p->index = idx; + + if (type) { + VAR[idx].str = &p->str; + VAR[ i ].str = NULL; + } else { + VAR[idx].num = &p->num; + VAR[ i ].num = NULL; + } +} @@ -0,0 +1,47 @@ +/* public definitions from list.c */ + +#ifndef _LIST_H_ +#define _LIST_H_ + +int cmp_vtime __P ((vtime *t1, vtime *t2)); +void add_vtime __P ((vtime *t1, vtime *t2)); +long diff_vtime __P ((vtime *t1, vtime *t2)); + +int rev_sort __P ((defnode *node1, defnode *node2)); +int ascii_sort __P ((defnode *node1, defnode *node2)); +int rev_ascii_sort __P ((defnode *node1, defnode *node2)); +int time_sort __P ((defnode *node1, defnode *node2)); +int rev_time_sort __P ((defnode *node1, defnode *node2)); + +int hash __P ((char *name)); + +void add_node __P ((defnode *newnode, defnode **base, function_sort sort)); +void reverse_sortedlist __P ((sortednode **base)); + +void add_aliasnode __P ((char *name, char *subst)); +void add_actionnode __P ((char *pattern, char *command, char *label, int active, int type, void *qregexp)); +void add_promptnode __P ((char *pattern, char *command, char *label, int active, int type, void *qregexp)); +void add_marknode __P ((char *pattern, int attrcode, char mbeg, char wild)); +void add_keynode __P ((char *name, char *sequence, int seqlen, function_str funct, char *call_data)); +delaynode *add_delaynode __P ((char *name, char *command, vtime *when, int is_dead)); +varnode *add_varnode __P ((char *name, int type)); + +aliasnode **lookup_alias __P ((char *name)); +actionnode **lookup_action __P ((char *label)); +actionnode **lookup_prompt __P ((char *label)); +actionnode **lookup_action_pattern __P ((char *pattern)); +marknode **lookup_marker __P ((char *pattern, char mbeg)); +keynode **lookup_key __P ((char *name)); +delaynode **lookup_delay __P ((char *name, int is_dead)); +varnode **lookup_varnode __P ((char *name, int type)); + +void delete_aliasnode __P ((aliasnode **base)); +void delete_actionnode __P ((actionnode **base)); +void delete_promptnode __P ((promptnode **base)); +void delete_marknode __P ((marknode **base)); +void delete_keynode __P ((keynode **base)); +void delete_delaynode __P ((delaynode **base)); +void delete_varnode __P ((varnode **base, int type)); + +#endif /* _LIST_H_ */ + @@ -0,0 +1,322 @@ +/* + * log.c -- code for #movie / #capture backbuffering + * and code for reprint-on-prompt + * + * Copyright (C) 1998 by Massimiliano Ghilardi + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <time.h> + +#include "defines.h" +#include "main.h" +#include "log.h" +#include "tty.h" +#include "list.h" +#include "utils.h" + +vtime movie_last; /* time movie_file was last written */ +FILE *capturefile = (FILE *)NULL; /* capture file or NULL */ +FILE *moviefile = (FILE *)NULL; /* movie file or NULL */ +FILE *recordfile = (FILE *)NULL; /* record file or NULL */ + + +static char *datalist; /* circular string list */ +static int datastart = 0; /* index to first string start */ +static int dataend = 0; /* index one past last string end */ +static int datasize = 0; /* size of circular string list */ + +#define DATALEFT (datastart > dataend ? datastart - dataend - 2 : datastart ? \ + MAX2(datastart - 1, datasize - dataend - 1) : datasize - dataend - 1) + +typedef struct logentry { + enum linetype kind; + long msecs; /* millisecs to sleep if kind == SLEEP */ + char *line; /* pointer to string in `datalist' circular buffer */ +} logentry; + +logentry *loglist; /* circular (pointer to string) list */ + +static int logstart = 0; /* index to first loglist used */ +static int logend = 0; /* index one past last loglist used */ +static int logsize = 0; /* size of circular (pointer to string) list */ + +#define LOGFULL (logend == (logstart ? logstart - 1 : logsize - 1)) + +static char *names[] = { NULL, "line", "prompt", "sleep" }; + +/* + * flush a single buffer line + */ +static void log_flushline __P1 (int,i) +{ + if (capturefile) + fprintf(capturefile, "%s%s", + loglist[i].line, loglist[i].kind == LINE ? "\n" : ""); + if (moviefile) { + if (loglist[i].msecs) + fprintf(moviefile, "%s %ld\n", + names[SLEEP], loglist[i].msecs); + fprintf(moviefile, "%s %s\n", + names[loglist[i].kind], loglist[i].line); + } +} + +/* + * remove the oldest (first) line from the buffer + */ +static void log_clearline __P0 (void) +{ + int next; + + if (logstart == logend) + return; + log_flushline(logstart); + + next = (logstart + 1) % logsize; + if (next == logend) + datastart = dataend = logstart = logend = 0; + else + datastart = loglist[next].line - datalist, logstart = next; +} + +/* + * remove an initial SLEEP from the buffer + */ +void log_clearsleep __P0 (void) +{ + if (logstart != logend) + loglist[logstart].msecs = 0; +} + +/* + * flush the buffer + */ +void log_flush __P0 (void) +{ + int i = logstart; + while (i != logend) { + log_flushline(i); + if (++i == logsize) + i = 0; + } + datastart = dataend = logstart = logend = 0; +} + +int log_getsize __P0 (void) +{ + return datasize; +} + +static void log_reset __P0 (void) +{ + if (datasize) { + if (datalist) free(datalist); + if (loglist) free(loglist); + loglist = NULL; + datalist = NULL; + logsize = datasize = 0; + } +} + + +void log_resize __P1 (int,newsize) +{ + if (newsize && newsize < 1000) { + PRINTF("#buffer size must be 0 (zero) or >= 1000\n"); + return; + } + + if (newsize == datasize) + return; + + log_flush(); + log_reset(); + if (newsize) { + datalist = (char *)malloc(newsize); + if (!datalist) { log_reset(); errmsg("malloc"); return; } + + loglist = (logentry *)malloc(newsize/16*sizeof(logentry)); + if (!loglist) { log_reset(); errmsg("malloc"); return; } + + datasize = newsize; + logsize = newsize / 16; + } + if (echo_int) { + PRINTF("#buffer resized to %d bytes%s\n", newsize, newsize ? "" : " (disabled)"); + } +} + +/* + * add a single line to the buffer + */ +static void log_writeline __P4 (char *,line, int,len, int,kind, long,msecs) +{ + int dst; + + if (++len >= datasize) { + PRINTF("#line too long, discarded from movie/capture buffer\n"); + return; + } + while (LOGFULL || DATALEFT < len) + log_clearline(); + /* ok, now we know there IS enough space */ + + if (datastart >= dataend /* is == iff loglist is empty */ + || datasize - dataend > len) + dst = dataend; + else + dst = 0; + + memcpy(loglist[logend].line = datalist + dst, line, len - 1); + datalist[dst + len - 1] = '\0'; + + loglist[logend].kind = kind; + loglist[logend].msecs = msecs; + + if ((dataend = dst + len) == datasize) + dataend = 0; + + if (++logend == logsize) + logend = 0; +} + +/* + * write to #capture / #movie buffer + */ +void log_write __P3 (char *,str, int,len, int,newline) +{ + char *next; + long diff; + int i, last = 0; + + if (!datasize && !moviefile && !capturefile) + return; + + update_now(); + diff = diff_vtime(&now, &movie_last); + movie_last = now; + + do { + if ((next = memchr(str, '\n', len))) + i = next - str; + else + i = len, last = 1; + + if (datasize) + log_writeline(str, i, last && !newline ? PROMPT : LINE, diff); + else { + if (moviefile) { + if (diff) + fprintf(moviefile, "%s %ld\n", + names[SLEEP], diff); + fprintf(moviefile, "%s %.*s\n", + names[last && !newline ? PROMPT : LINE], i, str); + } + if (capturefile) + fprintf(capturefile, "%.*s%s", + i, str, last && !newline ? "" : "\n"); + } + diff = 0; + if (next) { + len -= next + 1 - str; + str = next + 1; + } + } while (next && len > 0); +} + +static char reprintlist[BUFSIZE]; /* circular string list */ +static int reprintstart = 0; /* index to first string start */ +static int reprintend = 0; /* index one past last string end */ +static int reprintsize = BUFSIZE; /* size of circular string list */ + +#define REPRINTLEFT (reprintstart > reprintend ? reprintstart - reprintend - 1 : reprintstart ? \ + MAX2(reprintstart - 1, reprintsize - reprintend - 1) : reprintsize - reprintend - 1) + +static char *replist[BUFSIZE/8]; /* circular (pointer to string) list */ + +static int repstart = 0; /* index to first replist used */ +static int repend = 0; /* index one past last replist used */ +static int repsize = BUFSIZE/8; /* size of circular (pointer to string) list */ + +#define REPFULL (repend == (repstart ? repstart - 1 : repsize - 1)) + +/* + * remove the oldest (first) line from reprintlist + */ +static void reprint_clearline __P0 (void) +{ + int next; + + if (repstart == repend) + return; + + next = (repstart + 1) % repsize; + if (next == repend) + reprintstart = reprintend = repstart = repend = 0; + else + reprintstart = replist[next] - reprintlist, repstart = next; +} + +void reprint_clear __P0 (void) +{ + reprintstart = reprintend = repstart = repend = 0; +} + +/* + * add a single line to the buffer + */ +void reprint_writeline __P1 (char *,line) +{ + int len = strlen(line) + 1; + int dst; + + if (!opt_reprint || (promptlen && prompt_status != -1)) + /* + * if prompt is valid, we'll never have to reprint, as we + * _already_ printed the command at the right moment + */ + return; + + if (len >= reprintsize) { + PRINTF("#line too long, discarded from prompt reprint buffer\n"); + return; + } + while (REPFULL || REPRINTLEFT < len) + reprint_clearline(); + /* ok, now we know there IS enough space */ + + if (reprintstart >= reprintend /* is == iff replist is empty */ + || reprintsize - reprintend > len) + dst = reprintend; + else + dst = 0; + + memcpy(replist[repend] = reprintlist + dst, line, len - 1); + reprintlist[dst + len - 1] = '\0'; + + if ((reprintend = dst + len) == reprintsize) + reprintend = 0; + + if (++repend == repsize) + repend = 0; +} + +char *reprint_getline __P0 (void) +{ + char *line = NULL; + if (opt_reprint && repend != repstart) + line = replist[repstart]; + reprint_clearline(); + return line; +} + @@ -0,0 +1,22 @@ +/* public things from log.c */ + +#ifndef _LOG_H_ +#define _LOG_H_ + +enum linetype { EMPTY = 0, LINE = 1, PROMPT = 2, SLEEP = 3 }; + +extern FILE *capturefile, *recordfile, *moviefile; +extern vtime movie_last; + +void log_clearsleep __P ((void)); +void log_flush __P ((void)); +int log_getsize __P ((void)); +void log_resize __P ((int newsize)); +void log_write __P ((char *str, int len, int newline)); + +void reprint_writeline __P ((char *line)); +char *reprint_getline __P ((void)); +void reprint_clear __P ((void)); + +#endif /* _LOG_H_ */ + @@ -0,0 +1,1995 @@ +/* + * powwow -- mud client with telnet protocol + * + * Copyright (C) 1998,2000,2002 by Massimiliano Ghilardi + * + * 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. + * + * + * History: + * + * Initially inspired to the Tintin client by Peter Unold, + * Powwow contains no Tintin code. + * The original program Cancan, written by Mattias Engdegård (Yorick) + * (f91-men@nada.kth.se) 1992-94, + * was greatly improved upon by Vivriel, Thuzzle and Ilie and then + * transformed from Cancan into Powwow by Cosmos who worked + * to make it yet more powerful. + * AmigaDOS porting attempt by Fror. + * Many new features added by Dain. + * As usual, all the developers are in debt to countless users + * for suggestions and debugging. + */ + +/* + * Set this to whatever you like + * + * #define POWWOW_DIR "/home/gustav/powwow" + */ + +#define POWWOW_VERSION VERSION ", Copyright 2000-2005 by Cosmos\n" \ + "(contributions by Yorick, Vivriel, Thuzzle, Ilie, Fror, Dain)\n" +#define HELPNAME "powwow.help" +#define COPYNAME "COPYING" + +#ifndef POWWOW_DIR +# define POWWOW_DIR "./" +#endif + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <fcntl.h> +#include <ctype.h> +#include <errno.h> +#include <time.h> + +#include <sys/param.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/wait.h> +#include <memory.h> +#include <unistd.h> + +/* are these really needed? */ +extern int errno; +extern int select(); + +#ifdef USE_REGEXP +# include "malloc.h" +# include <regex.h> +#endif + +#include "defines.h" +#include "main.h" +#include "utils.h" +#include "beam.h" +#include "cmd.h" +#include "cmd2.h" +#include "edit.h" +#include "map.h" +#include "list.h" +#include "tcp.h" +#include "tty.h" +#include "eval.h" +#include "log.h" + +/* local function declarations */ +#ifdef MOTDFILE +static void printmotd __P ((void)); +#endif +static void mainloop __P ((void)); +static void exec_delays __P ((void)); +static void prompt_reset_iac __P ((void)); +static void get_remote_input __P ((void)); +static void get_user_input __P ((void)); + +static int search_action_or_prompt __P ((char *line, char clearline, char copyprompt)); +#define search_action(line, clearline) search_action_or_prompt((line), (clearline), 0) +#define search_prompt(line, copyprompt) search_action_or_prompt((line), 0, (copyprompt)+1) + +static void set_params __P ((char *line, int *match_s, int *match_e)); +static void parse_commands __P ((char *command, char *arg)); +static int subst_param __P ((ptr *buf, char *src)); +static int jit_subst_vars __P ((ptr *buf, char *src)); + + +/* GLOBALS */ +static char *helpname = HELPNAME; +static char *copyname = COPYNAME; + +long received = 0; /* amount of data received from remote host */ +long sent = 0; /* amount of data sent to remote host */ + +char identified = 0; /* 1 after #identify */ +VOLATILE char confirm = 0; /* 1 if just tried to quit */ +int history_done = 0; /* number of recursive #history commands */ +int prompt_status = 0; /* prompt status: 0 = ready -> nothing to do; + * 1 if internal echo -> must redraw; + * -1 if something sent to MUD -> waiting for it. + */ +int line_status = 0; /* input line status: 0 = ready -> nothing to do; + * 1 if printed something -> must redraw. + */ + +int limit_mem = 0; /* if !=0, max len of a string or text */ + +char echo_ext = 1; /* 1 if text sent to MUD must be echoed */ +char echo_key = 1; /* 1 if binds must be echoed */ +char echo_int = 1; /* 0 if internal messages are suppressed */ +char opt_exit = 0; /* 1 to autoquit when closing last conn. */ +char opt_history; /* 1 if to save also history */ +char opt_words = 0; /* 1 if to save also word completion list */ +char opt_compact = 0; /* 1 if to clear prompt between remote messages */ +char opt_debug = 0; /* 1 if to echo every line before executing it */ +char opt_speedwalk = 0; /* 1 = speedwalk on */ +char opt_wrap = 0; /* 1 = word wrap active */ +char opt_autoprint = 0; /* 1 = automatically #print lines matched by actions */ +char opt_reprint = 0; /* 1 = reprint sent commands when we get a prompt */ +char opt_sendsize = 0; /* 1 = send term size upon connect */ +char opt_autoclear = 1; /* 1 = clear input line before executing commands + * from spawned programs. + * if 0, spawned progs must #clear before printing + */ + +char hostname[BUFSIZE]; +int portnumber; +static char powwow_dir[BUFSIZE]; /* default path to definition files */ +char deffile[BUFSIZE]; /* name and path of definition file */ +char helpfile[BUFSIZE]; /* name and path of help file */ +char copyfile[BUFSIZE]; /* name and path of copyright file */ +aliasnode *aliases[MAX_HASH]; /* head of alias hash list */ +aliasnode *sortedaliases; /* head of (ASCII) sorted alias list */ +actionnode *actions; /* head of action list */ +promptnode *prompts; /* head of prompt list */ +marknode *markers; /* head of mark list */ +int a_nice = 0; /* default priority of new actions/marks */ +keynode *keydefs; /* head of key binding list */ +delaynode *delays; /* head of delayed commands list */ +delaynode *dead_delays; /* head of dead-delayed commands list */ + +varnode *named_vars[2][MAX_HASH]; /* head of named variables hash list */ +varnode *sortednamed_vars[2]; /* head of (ASCII) sorted named variables list */ +int max_named_vars = 100; /* max number of named vars (grows as needed) */ +int num_named_vars[2]; /* number of named variables actually used */ + +static param_stack paramstk; /* stack of local unnamed vars */ +static unnamedvar global_var[NUMTOT]; /* global unnamed vars */ + +vars *var; /* vector of all vars */ + +ptr globptr[2]; /* global ptr buffer */ +char globptrok = 1|2; /* x&i = 0 if globptr[i] is in use */ + +varnode *prompt; /* $prompt is always set */ +ptr marked_prompt; /* $prompt with marks added */ +static varnode *last_line; /* $line is always set to + * the last line processed */ + +vtime now; /* current time */ +int now_updated; /* current time is up to date */ +vtime start_time; /* time of powwow timer startup */ +vtime ref_time; /* time corresponding to timer == 0 */ + +function_any last_edit_cmd; /* GH: keep track of for repeated cmds */ + +clock_t start_clock, cpu_clock; + +char initstr[BUFSIZE]; /* initial string to send on connect */ + +int linemode = 0; /* line mode flags (LM_* in main.h) */ + +/* for line editing */ +int cols=80, lines=24; /* screen size */ +int cols_1=79; /* == cols if tty_wrapglitch, == cols-1 otherwise */ +int olines; /* previous screen size */ +int col0; /* input line offset (= printstrlen of prompt) */ +int line0; /* screen line where the input line starts */ +char edbuf[BUFSIZE]; /* line editing buffer */ +int edlen; /* length of current input line */ +int pos = 0; /* cursor position in line */ +char surely_isprompt = 0; /* !=0 if last #prompt set #isprompt */ +char verbatim = 0; /* 1 = don't expand aliases or process semicolons */ +char prefixstr[BUFSIZE]; /* inserted in the editing buffer each time */ +char inserted_next[BUFSIZE];/* inserted in buffer just once */ +char flashback = 0; /* cursor is on excursion and should be put back */ +int excursion; /* where the excursion is */ +char edattrbeg[CAPLEN]; /* starting input line attributes */ +char edattrend[CAPLEN]; /* ending input line attributes */ +int edattrbg; /* input line attributes do change bg color */ + +/* signals handling */ +VOLATILE int sig_pending, sig_winch_got, sig_chld_got; + + +/* GH: different ID characters for different action types */ +/* + * Cosmos: they are hardcoded in cmd2.c, function parse_action() + * so don't change them. + */ +char action_chars[ACTION_TYPES] = { '>', '%' }; + +/* GH: different delimeter modes */ +char *delim_list[] = { " ;", " <>!=(),;\"'{}[]+-/*%", 0 }; +int delim_len [] = { 2 , 21 , 0 }; +char *delim_name[] = { "normal", "program", "custom" }; +int delim_mode = DELIM_NORMAL; + + +int main __P2 (int,argc, char **,argv) +{ + char *p; + int i; + int read_file = 0; /* GH: if true, powwow was started with + * a file argument, and initstr shall be ran */ + + /* initializations */ + initstr[0] = 0; + memzero(conn_list, sizeof(conn_list)); + + update_now(); + ref_time = start_time = movie_last = now; + + start_clock = cpu_clock = clock(); +#ifndef NO_RANDOM + init_random((int)now.tv_sec); +#endif + + _cmd_init(); + + if ((p = getenv("POWWOWDIR"))) { + strcpy(powwow_dir, p); + if (powwow_dir[strlen(powwow_dir) - 1] != '/') + strcat(powwow_dir, "/"); + } else + powwow_dir[0] = '\0'; + + if ((p = getenv("POWWOWHELP"))) + strcpy(helpfile, p); + else if (powwow_dir[0]) + strcpy(helpfile, powwow_dir); + else + strcpy(helpfile, POWWOW_DIR); + + if (helpfile[strlen(helpfile) - 1] != '/') + strcat(helpfile, "/"); + strcat(helpfile, helpname); + if (access(helpfile, R_OK) == -1 && !access(helpname, R_OK)) + strcpy(helpfile, helpname); + + if (powwow_dir[0]) + strcpy(copyfile, powwow_dir); + else + strcpy(copyfile, POWWOW_DIR); + if (helpfile[strlen(helpfile) - 1] != '/') + strcat(copyfile, "/"); + strcat(copyfile, copyname); + if (access(copyfile, R_OK) == -1 && !access(copyname, R_OK)) + strcpy(copyfile, copyname); + + /* initialize va |