cgoban-1.9.14/0000777000671000067100000000000007606355253006621 5cgoban-1.9.14/README0000664000671000067100000001651107502155606007416 README for cgoban 1.9.13 ------------------------ Cgoban (Complete Goban) is for Unix systems with X11. It has the ability to be a computerized go board, view and edit smart-go files, and connect to go servers on the Internet. I'm keeping a mailing list of people interested in cgoban. I will keep the traffic very low. All I send out are announcements when new versions are ready, along with a description of what is new/fixed in the new version. If you want these announcements, then please send me mail at "wms@igoweb.org". HOW TO BUILD ------------ Cgoban uses the Gnu autoconf utility. To build and run it, follow these steps: 1) Unpack it. You must have done this already to read this file. Make sure that you "cd" into the cgoban directory (the directory that has this README in it). 2) Type "./configure". 3) Type "make". 4) Type "./cgoban". If all went well you should be running cgoban. Directions on using cgoban are all available through the "help" buttons. For a list of command line switches available, try "./cgoban -help". 5) You can copy the cgoban executable to a directory on your PATH after you have built it. Then you can delete all the rest of the files - once you have built the binary, you don't need anything else. INSTALLING ---------- cgoban's build directories (that is, the directory that has this README in it and all the subdirectories) take up a lot of disk space. After you build it, you need nothing but the binary. You can install it by running "make install" in the build directory; if you want to put it somewhere besides "/usr/games/bin", then you should edit the Makefile, set "PREFIX" to the place to put cgoban, then run "make install". After you've installed the binary, feel free to delete everything but the binary. IF YOU HAVE TROUBLE ------------------- The section below this lists some systems that are known to have trouble building. Check there to see if your system is on the list. The most common problem is systems that need special switches to run "cc". Your C compiler MUST be an ansi-compatible c compiler. If you have trouble with "./configure" or if you have trouble compiling, try setting your environment variable "CC" to be how to run your C compiler. For example, on some HP/UX systems "make" will break unless you set "CC" to be "cc -Aa -D_HPUX_SOURCE". On a csh-based system, you set this with: $ setenv CC "cc -Aa -D_HPUX_SOURCE" and on an sh-based system you need to type two lines: $ CC="cc -Aa -D_HPUX_SOURCE" $ export CC After setting CC, run "./configure" again and then "make" again to see if it works better. Another problem is finding the X11 includes and/or libraries. If they aren't founds when you are compiling, try running configure again, but this time try "./configure --x-includes= --x-libraries=" to tell configure where your X includes and X libraries are. KNOWN PROBLEM SYSTEMS --------------------- HP/UX Needs CC set as above, and sometimes needs the X directory set by hand (also as shown above). Linux Elf Old Linux Elf libcs have a bug in sscanf that prevents cgoban from working correctly. If you can see the "games" window in client mode, then everything is fine. If you get an error window when you press the "games" button on the client main window, then you need to get a newer version of libc and recompile. I've heard that libc 5.3.12 works, so if you get that version or later you should be OK. VAX/Ultrix Some systems have broken long longs. If you get an error referring to "__ll_lshift" when you try to build, then edit obj-*/configure.h to change "SIZEOF_LONG_LONG" to 0, then do a "make clean" then a "make". AIX There seems to be some broken AIX compilers out there (or it may be a bug in Cgoban that only shows up on AIX). If your AIX system doesn't work correctly try editing the Makefile and changing the CFLAGS line to have no "-O" switch. Then do a "make clean" then "make" and see if it works better. SPARC There are some Sparc X systems that have a bug. When you start up cgoban, your whole X server crashes. If this happens to you, get an upgrade from Sun (they do have a bug fix out that will fix this). FIREWALLS --------- See the help for the "setup" window. NOTE ---- Everybody complains that you can't resize the boards. Well, I'm working on it. In the meantime, PLEASE see the man page about the "cgoban -fontHeight" switch. With this you _can_ change the size of the board, but just not "on the fly". For example, "cgoban -fontHeight 14" will make the boards a little bit bigger (12 is the default); "cgoban -fontHeight 10" will make the boards a little bit smaller. ARENA MODE ---------- This is just for testing out go modem protocol programs. Run it like: $ cgoban -arena.games 4 -arena.size 9 -arena.komi 5.5 -arena.prog1 "myprog-new" -arena.prog2 "myprog-old" This will play myprog-new against myprog-old for four games, alternating who plays white and who plays black. The output will look like: 0 12.5 1 0.5 0 30.5 0 3.5 Which means that myprog-new won the first, third, and fourth games by 12.5, 30.5, and 3.5 points, while myprog-old won the second game by 0.5 points. Note that myprog-new and myprog-old *MUST* play until all dead stones are removed from the game, since the scoring function does *NOT* remove dead stones in arena mode. Scoring is done with Chinese rules so playing until all the dead stones are gone won't count against your score. Arena mode is kind of hacked in mostly for my benefit, so sorry but it isn't real user-friendly. THE grab_cgoban SHELL SCRIPT ---------------------------- If you use cgoban with a 12 point font, then the grab_cgoban shell script will nicely take a snapshot of a cgoban board and save it as a .gif file. For this script to work, you must have either the "imagemagick" or "pbmplus" packages installed. REVISION HISTORY ---------------- If the patchlevel changes, then it's just bug fixes. So for example 1.4.2 is just like 1.4.0 but some things that were broken are fixed. 0.0.0 Alpha version. Not all features are present. 0.1.0 First beta version. All features for the 1.0.0 release are present, but there are still some blatant bugs. 1.0.0 First full release. 1.1.0 Lots-O-bug fixes! Tons of them! Added support for "look" client command. Added a prompt for the client. Added ability to shift-click on a client game to move easily to a specific move number. Added "Say/Both/Kibitz" radio button. Improved games list window to show flags, be more resizable, and not crush columns together. 1.2.0 Spiffed up the configure window and added connect-with-telnet support for the firewalled folks out there. 1.3.0 Added the ability to try out variations on server games that you are observing or playing in. 1.4.0 Added file selector window, game info window, "Edit Game" buttons, and keeping server game info around after the game ends. 1.5.2 Added support for more than two servers, arena mode, and the anti-slip option. Also made it automatically run with no color if it can't get enough instead of just whining about it. 1.6.3 Added server "match" GUI. 1.9.12 Added patches submitted by Jeremy Cooper to record window size and fix an IGS bug. 1.9.13 Moved to Sourceforge. Various patches submitted by other people. $Source: /cvsroot/cgoban1/cgoban1/README,v $ $Revision: 1.7 $ $Date: 2002/06/13 17:51:02 $ cgoban-1.9.14/AUTHORS0000664000671000067100000000005707556057554007620 William M. Schubert Kevin E Sonney Teun Burgerscgoban-1.9.14/COPYING0000664000671000067100000004307607043224462007574 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. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 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. , 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. cgoban-1.9.14/ChangeLog0000664000671000067100000000212307556057554010316 Changes for cgoban-1.9.14-0.1 - New maintainer - add spec for RPMs - add icon file for desktop entry Changes for cgoban-1.9.13 - add grab_cgoban.in to repository, remove grab_cgoban - remove files from repository made by the autotools: configure.h.in, Makefile.in - reverted upgrade to autoconf 2.5x/automake 1.6x now use autoconf 2.13/automake 1.5 - use automake for Makefiles - add Makefile.am in the different directories - remove makerule generation from configure.in - install grab_cgoban using bin_SCRIPTS macro - substitute shell in grab_cgoban from configure - make gnugo default gmp client instead of GoDummy - remove acconfig.h. Use AH_TOP and AH_TEMPLATE macros instead in configure.in - use AC_EXEEXT macro to get .exe extension for cygwin executables - use AC_SEARCH_LIB(cos, m) instead of AC_CHECKLIB(m, main). On some platforms -lm is not needed. - use AC_PATH_XTRA instead of AC_FIND_X - remove INCDIR, LIBDIR from configure.in. This functionality is provided by automake - move AC_AIX AC_ISC_POSIX AC_MINIX to right after AC_PROG_CC. autoconf 2.53 complained about this. cgoban-1.9.14/INSTALL0000664000671000067100000001722707466536414007605 Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. cgoban-1.9.14/Makefile.am0000664000671000067100000000062507606354624010577 AUTOMAKE_OPTIONS = 1.4 SUBDIRS = man6 wmslib src EXTRA_DIST = seigen-minoru.sgf bootstrap cgoban1.spec cgoban_icon.png bin_SCRIPTS = grab_cgoban # use noinst_SCRIPTS to create a symbolic link to the cgoban # executable noinst_SCRIPTS = cgoban$(EXEEXT) MOSTLYCLEANFILES = cgoban$(EXEEXT) cgoban$(EXEEXT): $(top_builddir)/src/cgoban$(EXEEXT) ln -s $(top_builddir)/src/cgoban$(EXEEXT) cgoban$(EXEEXT) cgoban-1.9.14/Makefile.in0000664000671000067100000003511107606355024010601 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPP = @CPP@ DATE = @DATE@ DEPDIR = @DEPDIR@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBS = @LIBS@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ AUTOMAKE_OPTIONS = 1.4 SUBDIRS = man6 wmslib src EXTRA_DIST = seigen-minoru.sgf bootstrap cgoban1.spec cgoban_icon.png bin_SCRIPTS = grab_cgoban # use noinst_SCRIPTS to create a symbolic link to the cgoban # executable noinst_SCRIPTS = cgoban$(EXEEXT) MOSTLYCLEANFILES = cgoban$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = configure.h CONFIG_CLEAN_FILES = grab_cgoban cgoban1.spec SCRIPTS = $(bin_SCRIPTS) $(noinst_SCRIPTS) DIST_SOURCES = RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ uninstall-info-recursive all-recursive install-data-recursive \ install-exec-recursive installdirs-recursive install-recursive \ uninstall-recursive check-recursive installcheck-recursive DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \ Makefile.in NEWS TODO acconfig.h aclocal.m4 cgoban1.spec.in \ configure configure.h.in configure.in depcomp grab_cgoban.in \ install-sh missing mkinstalldirs DIST_SUBDIRS = $(SUBDIRS) all: configure.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe) $(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): configure.in cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) configure.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/configure.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status configure.h $(srcdir)/configure.h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/acconfig.h cd $(top_srcdir) && $(AUTOHEADER) touch $(srcdir)/configure.h.in distclean-hdr: -rm -f configure.h stamp-h1 grab_cgoban: $(top_builddir)/config.status grab_cgoban.in cd $(top_builddir) && $(SHELL) ./config.status $@ cgoban1.spec: $(top_builddir)/config.status cgoban1.spec.in cd $(top_builddir) && $(SHELL) ./config.status $@ binSCRIPT_INSTALL = $(INSTALL_SCRIPT) install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_SCRIPTS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ if test -f $$d$$p; then \ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ echo " $(binSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(bindir)/$$f"; \ $(binSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(bindir)/$$f; \ else :; fi; \ done uninstall-binSCRIPTS: @$(NORMAL_UNINSTALL) @list='$(bin_SCRIPTS)'; for p in $$list; do \ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ rm -f $(DESTDIR)$(bindir)/$$f; \ done uninstall-info-am: # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ETAGS = etags ETAGSFLAGS = tags: TAGS 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-recursive $(HEADERS) $(SOURCES) configure.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) configure.h.in $(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 "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = . distdir = $(PACKAGE)-$(VERSION) am__remove_distdir = \ { test ! -d $(distdir) \ || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr $(distdir); }; } GZIP_ENV = --best distcleancheck_listfiles = find . -type f -print distdir: $(DISTFILES) $(am__remove_distdir) mkdir $(distdir) $(mkinstalldirs) $(distdir)/. @list='$(DISTFILES)'; for file in $$list; do \ 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"; \ $(mkinstalldirs) "$(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 list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \ || exit 1; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" \ distdir=../$(distdir)/$$subdir \ distdir) \ || 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 $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist dist-all: distdir $(AMTAR) chof - $(distdir) | 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 $(am__remove_distdir) GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - 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` \ && 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 \ && (test `find $$dc_install_base -type f -print | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ find $$dc_install_base -type f -print ; \ exit 1; } >&2 ) \ && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \ && rm -f $(distdir).tar.gz \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck $(am__remove_distdir) @echo "$(distdir).tar.gz is ready for distribution" | \ sed 'h;s/./=/g;p;x;p;x' 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 after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(SCRIPTS) configure.h installdirs: installdirs-recursive installdirs-am: $(mkinstalldirs) $(DESTDIR)$(bindir) install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) clean-generic: distclean-generic: -rm -f Makefile $(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-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) distclean-am: clean-am distclean-generic distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: info: info-recursive info-am: install-data-am: install-exec-am: install-binSCRIPTS install-info: install-info-recursive install-man: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf autom4te.cache maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic uninstall-am: uninstall-binSCRIPTS uninstall-info-am uninstall-info: uninstall-info-recursive .PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ clean-generic clean-recursive dist dist-all dist-gzip distcheck \ distclean distclean-generic distclean-hdr distclean-recursive \ distclean-tags distcleancheck distdir dvi dvi-am dvi-recursive \ info info-am info-recursive install install-am \ install-binSCRIPTS install-data install-data-am \ install-data-recursive install-exec install-exec-am \ install-exec-recursive install-info install-info-am \ install-info-recursive install-man install-recursive \ install-strip installcheck installcheck-am installdirs \ installdirs-am installdirs-recursive maintainer-clean \ maintainer-clean-generic maintainer-clean-recursive mostlyclean \ mostlyclean-generic mostlyclean-recursive tags tags-recursive \ uninstall uninstall-am uninstall-binSCRIPTS uninstall-info-am \ uninstall-info-recursive uninstall-recursive cgoban$(EXEEXT): $(top_builddir)/src/cgoban$(EXEEXT) ln -s $(top_builddir)/src/cgoban$(EXEEXT) cgoban$(EXEEXT) # 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: cgoban-1.9.14/NEWS0000664000671000067100000000012107556057555007240 New in cgoban-1.9.14 - default .spec file for RPM based systems - new maintainer cgoban-1.9.14/TODO0000664000671000067100000000436607502155606007233 TODO list for Cgoban 1.9.13 Right now I've got way too many things to plan on when I'll be doing which of them; my head hurts just thinking about all of them. But I am slowly making progress. Update on Feb. 27 2002: Not working on this any more. I'm now working on cgoban 2 and KGS. If anybody wants to take this over, please let me know. Bugs to fix: GMP can't play handicap games on a server. When continuing a game, the number of moves left in your byo-yomi period is wrong at first. Laurent Demailly has this weird bug where it crashes during gettimeofday(). Scrolling rapidly will sometimes mess up the text windows. Running "cgoban -edit buggy.sgf" doesn't pop up an error dialogue. Features to add: Print games you are editing. Make little logos for open, closed, looking. Make game list window keep up with moves in games your are observing or playing in. Watch for the output of "who " and update game list. Add sound effects. Score boxes should reflect final score when a server game ends. Make it automatically resume adjourned games in the same window when they resume. Add windows for each conversation that you are in. Add a way to add/see the "FG" and "DI" SGF codes. Add "-view", like "-edit" but read-only. Allow users to sort the games list. Support the chatter command. Add the equivalent of "Notify". Make it not scroll the text when you're looking at something older. Add tabs to pretty up results output Grey out users so "who 5k-1d o" works well Beep when time running low Warn when your kibitzes are lost because game ended Let users type as you are logging in Let GMP use more than the first two servers Let player change rules of an SGF file Make arrow act same in edit window and edit tool window Add edit tool stuff for inserting nodes When you start a game on one server, automatically become closed to games on the others. Allow people to save and edit "Look" files. Automatically reconnect when you are logged out. Easier saving games from server windows. Configuration options to add: Better beep control. Number of lines to keep in the log Allow users to set up function keys to bind to common commands $Source: /cvsroot/cgoban1/cgoban1/TODO,v $ $Revision: 1.5 $ $Date: 2002/06/13 17:51:02 $ cgoban-1.9.14/acconfig.h0000664000671000067100000000237607556057556010502 /* * configure.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * Copyright (C) 2002 Kevin Sonney * * 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. * * Original code written by William M. Shubert * AutoMake code written by Teun Burgers * The maintainer can be reached at or * Kevin Sonney * 1801 Varsity Drive * Raleigh, NC 27606 * (919) 754-3700 x44112 */ @TOP@ #undef DATE #undef DATE_FRENCH #undef HAVE_H_ERRNO #undef HAVE_SOCKETS #undef LINUX_SOUND #undef SUN_SOUND #undef VERSION #undef X11_DISP cgoban-1.9.14/aclocal.m40000664000671000067100000007634307606355020010404 # aclocal.m4 generated automatically by aclocal 1.6.3 -*- Autoconf -*- # Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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. # 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 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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 8 # 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... AC_PREREQ([2.52]) # Autoconf 2.50 wants to disallow AM_ names. We explicitly allow # the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl # 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_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 # 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_MISSING_PROG(AMTAR, tar) AM_PROG_INSTALL_SH AM_PROG_INSTALL_STRIP # 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 _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 ]) ]) # Copyright 2002 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 # 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.6"]) # 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.6.3])]) # Helper functions for option handling. -*- Autoconf -*- # Copyright 2001, 2002 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 1996, 1997, 2000, 2001 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)]) # -*- Autoconf -*- # Copyright 1997, 1999, 2000, 2001 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_AUX_DIR_EXPAND # Copyright 2001 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. # Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50]) AC_DEFUN([AM_AUX_DIR_EXPAND], [ # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. # Copyright 2001 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)]) # AM_PROG_INSTALL_STRIP # Copyright 2001 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])]) # serial 4 -*- Autoconf -*- # Copyright 1999, 2000, 2001 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 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 # 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. echo '#include "conftest.h"' > conftest.c echo 'int i;' > conftest.h echo "${am__include} ${am__quote}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=conftest.c object=conftest.o \ depfile=conftest.Po tmpdepfile=conftest.TPo \ $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && grep conftest.h conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then am_cv_$1_dependencies_compiler_type=$depmode break 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_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [rm -f .deps 2>/dev/null mkdir .deps 2>/dev/null if test -d .deps; then DEPDIR=.deps else # MS-DOS does not allow filenames that begin with a dot. DEPDIR=_deps fi rmdir .deps 2>/dev/null AC_SUBST([DEPDIR]) ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking Speeds up one-time builds --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 1999, 2000, 2001, 2002 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 grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue # Extract the definition of DEP_FILES from the Makefile without # running `make'. DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` test -z "$DEPDIR" && continue # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n -e '/^U = / s///p' < "$mf"` test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" # 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 -e ' /^DEP_FILES = .*\\\\$/ { s/^DEP_FILES = // :loop s/\\\\$// p n /\\\\$/ b loop p } /^DEP_FILES = / s/^DEP_FILES = //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"]) ]) # Copyright 2001 Free Software Foundation, Inc. -*- Autoconf -*- # 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' doit: @echo done 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 | fgrep -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 ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright 1997, 2000, 2001 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 5 AC_PREREQ(2.52) # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [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])]) # isc-posix.m4 serial 2 (gettext-0.11.2) dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. # This file is not needed with autoconf-2.53 and newer. Remove it in 2005. # This test replaces the one in autoconf. # Currently this macro should have the same name as the autoconf macro # because gettext's gettext.m4 (distributed in the automake package) # still uses it. Otherwise, the use in gettext.m4 makes autoheader # give these diagnostics: # configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX # configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX undefine([AC_ISC_POSIX]) AC_DEFUN([AC_ISC_POSIX], [ dnl This test replaces the obsolescent AC_ISC_POSIX kludge. AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) ] ) # Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*- # Copyright 1996, 1997, 2000, 2001 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_PREREQ([2.52]) # serial 6 # 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. We must strip everything past the first ":", # and everything past the last "/". # _AM_DIRNAME(PATH) # ----------------- # Like AS_DIRNAME, only do it during macro expansion AC_DEFUN([_AM_DIRNAME], [m4_if(regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1, m4_if(regexp([$1], [^//\([^/]\|$\)]), -1, m4_if(regexp([$1], [^/.*]), -1, [.], patsubst([$1], [^\(/\).*], [\1])), patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])), patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl ])# _AM_DIRNAME # The stamp files are numbered to have different names. # We could number them on a directory basis, but that's additional # complications, let's have a unique counter. m4_define([_AM_STAMP_Count], [0]) # _AM_STAMP(HEADER) # ----------------- # The name of the stamp file for HEADER. AC_DEFUN([_AM_STAMP], [m4_define([_AM_STAMP_Count], m4_incr(_AM_STAMP_Count))dnl AS_ESCAPE(_AM_DIRNAME(patsubst([$1], [:.*])))/stamp-h[]_AM_STAMP_Count]) # _AM_CONFIG_HEADER(HEADER[:SOURCES], COMMANDS, INIT-COMMANDS) # ------------------------------------------------------------ # We used to try to get a real timestamp in stamp-h. But the fear is that # that will cause unnecessary cvs conflicts. AC_DEFUN([_AM_CONFIG_HEADER], [# Add the stamp file to the list of files AC keeps track of, # along with our hook. AC_CONFIG_HEADERS([$1], [# update the timestamp echo 'timestamp for $1' >"_AM_STAMP([$1])" $2], [$3]) ])# _AM_CONFIG_HEADER # AM_CONFIG_HEADER(HEADER[:SOURCES]..., COMMANDS, INIT-COMMANDS) # -------------------------------------------------------------- AC_DEFUN([AM_CONFIG_HEADER], [AC_FOREACH([_AM_File], [$1], [_AM_CONFIG_HEADER(_AM_File, [$2], [$3])]) ])# AM_CONFIG_HEADER cgoban-1.9.14/cgoban1.spec.in0000775000671000067100000000567507577676322011364 %define name cgoban %define version @VERSION@ %define release 0.3 %define realname cgoban1 # This is for debug-flavor. Do not remove. Package is stripped conditionally. # %define __os_install_post %{nil} # %{expand:%%define optflags %{optflags} %([ $DEBUG ] && echo '-g3')} Summary: cgoban is an X board for playing go Name: %{name} Version: %{version} Release: %{release} Group: Graphical desktop/Other License: GPL URL: http://cgoban1.sourceforge.net/ Obsoletes: %{name}-1.9.13 BuildRequires: XFree86-devel BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} Source: http://prdownloads.sourceforge.net/cgoban1/%{name}-%{version}.tar.gz %description Cgoban (Complete Goban) is for Unix systems with X11. It has the ability to be a computerized go board, view and edit smart-go files, and connect to go servers on the Internet. %prep rm -rf $RPM_BUILD_ROOT %setup -q %configure %build make %install rm -rf $RPM_BUILD_ROOT mkdir $RPM_BUILD_ROOT chmod 777 $RPM_BUILD_ROOT make install prefix=$RPM_BUILD_ROOT/usr mandir=$RPM_BUILD_ROOT/usr/share/man bindir=$RPM_BUILD_ROOT/usr/bin mv $RPM_BUILD_ROOT/usr/bin/%{name} $RPM_BUILD_ROOT/usr/bin/%{realname} # mkdir $RPM_BUILD_ROOT/usr/share mkdir $RPM_BUILD_ROOT/usr/share/pixmaps cp cgoban_icon.png $RPM_BUILD_ROOT/usr/share/pixmaps mkdir $RPM_BUILD_ROOT/etc mkdir $RPM_BUILD_ROOT/etc/X11 mkdir $RPM_BUILD_ROOT/etc/X11/applnk mkdir $RPM_BUILD_ROOT/etc/X11/applnk/Games cat >$RPM_BUILD_ROOT/etc/X11/applnk/Games/%{realname}.desktop < 1.9.14-0.2 - latest dev build - tested rpm spec on RHL 7.x * Thu Oct 25 2002 Kevin Sonney 1.9.14-0.1 - version jump - remove patches - modify .spec to be included in mainline cgoban1 distribution * Mon Oct 22 2002 Kevin Sonney 1.9.12-0.4 - change desktop/menu entry description * Mon Oct 21 2002 Kevin Sonney 1.9.12-0.3 - rename binary to cgoban1 - added desktop entry for gnome * Thu Aug 22 2002 Kevin Sonney 1.9.12-0.2 - Better patch to Makefile.in - still needs porting to the new autoconf - can now use %configure macro - clean out fluxbox comments form my template .spec file - bad hacks for man pages & doc lcoations * Thu Aug 22 2002 Kevin Sonney 1.9.12-0.1 - Initial Spec File - lots of fixes to the spec to get it to build right as an RPM - patched the Makefile.in to correct autoconf error - needs porting to the new autoconf # end of file cgoban-1.9.14/configure0000775000671000067100000103407307606355027010455 #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57. # # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 # 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 # Support unset when possible. if (FOO=FOO; unset FOO) >/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 -n "`(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 as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="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="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= ac_unique_file="src/cgoban.c" ac_default_prefix=/usr/games # Factoring default headers for most tests. ac_includes_default="\ #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #else # if HAVE_STDINT_H # include # endif #endif #if HAVE_UNISTD_H # include #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 PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE CPP EGREP DATE RANLIB ac_ct_RANLIB X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS 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 X features: --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR _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] --disable-dependency-tracking Speeds up one-time builds --enable-dependency-tracking Do not reject slow dependency extractors Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-x use the X Window System Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory 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 # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` 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 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 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.57. 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.* *.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.6" 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" # ./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/* | \ /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 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 # 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 # Define the identity of the package. PACKAGE=cgoban VERSION=1.9.14 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"} AMTAR=${AMTAR-"${am_missing_run}tar"} 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. #for autoconf 2.5x start configure script with next four lines # AC_PREREQ(2.50) # AC_INIT(cgoban, 1.9.13) # AC_CONFIG_SRCDIR(src/cgoban.c) # AM_INIT_AUTOMAKE # # $Source: /cvsroot/cgoban1/cgoban1/configure.in,v $ # $Revision: 1.11 $ # $Date: 2002/11/19 16:46:01 $ # # Remember to change these in "README", "TODO", and "cgoban.6" too. # DATE must be in DAY MONTH YEAR format. date="10 23 2002" VERSION="1.9.14" # If we want to upgrade to 2.5x, AH_TOP and AH_TEMPLATE # macros can be used # AH_TOP text is inserted by autoheader in configure.h.in # AH_TOP([ #/* # * configure.h, part of Complete Goban (game program) # * Copyright (C) 1995 William Shubert # * Copyright (C) 2002 Kevin Sonney # * # * 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. # * # * Original code written by William M. Shubert # * AutoMake code written by Teun Burgers # * The maintainer can be reached at or # * Kevin Sonney # * 1801 Varsity Drive # * Raleigh, NC 27606 # * (919) 754-3700 x44112 # */] # ) # AH_TEMPLATE([DATE],[]) # AH_TEMPLATE([DATE_FRENCH],[]) # AH_TEMPLATE([HAVE_H_ERRNO],[]) # AH_TEMPLATE([HAVE_SOCKETS],[]) # AH_TEMPLATE([LINUX_SOUND],[ # LINUX_SOUND should be set to 1 if you have linux-style sound. Mostly # this means that you have "linux/soundcard.h" # ]) # AH_TEMPLATE([SUN_SOUND],[ # SUN_SOUND should be set to 1 if you have sun sparc-style sound. Mostly # this means that you have "sun/audioio.h". # ]) # AH_TEMPLATE([VERSION],[]) # AH_TEMPLATE([X11_DISP],[Define X11_DISP to be 1 if you have X11.]) ###################################################################### # My own, personal functions. # ###################################################################### # I don't really know what will clearly tell whether you have sockets or not, # so I just took a bunch of socket-related functions and stuck them in # a routine. If it builds and links, I assume I can build sockets code; # otherwise I assume I can't. ###################################################################### # Done with my own functions. On to the real configure file. # ###################################################################### export VERSION cat >>confdefs.h <<_ACEOF #define VERSION $VERSION _ACEOF dayNum=`echo $date | awk '{ print $1 }'` monthNum=`echo $date | awk '{ print $2 }'` yearNum=`echo $date | awk '{ print $3 }'` monthEnglish=`echo January February March April May June July August September October November December | awk '{ print $'$monthNum' }'` monthFrench=`echo Janvier Fevrier Mars Avril Mai Juin Juillet Août Septembre Octobre Novembre Décembre | awk '{ print $'$monthNum' }'` DATE="\"$dayNum $monthEnglish $yearNum\"" DATE_FRENCH="\"$dayNum $monthFrench $yearNum\"" export DATE export DATE_FRENCH cat >>confdefs.h <<_ACEOF #define DATE $DATE _ACEOF cat >>confdefs.h <<_ACEOF #define DATE_FRENCH $DATE_FRENCH _ACEOF 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 # 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" # ./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/* | \ /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' 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 &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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" >&5 echo $ECHO_N "checking for C compiler default output... $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 #line $LINENO "configure" /* 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 #line $LINENO "configure" /* 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>&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.$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 #line $LINENO "configure" /* 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>&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.$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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* 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; } 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>&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.$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>&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 \ ''\ '#include ' \ '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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include $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>&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.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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>&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.$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.$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 rm -f .deps 2>/dev/null mkdir .deps 2>/dev/null if test -d .deps; then DEPDIR=.deps else # MS-DOS does not allow filenames that begin with a dot. DEPDIR=_deps fi rmdir .deps 2>/dev/null ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' doit: @echo done 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 | fgrep -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 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 # 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. echo '#include "conftest.h"' > conftest.c echo 'int i;' > conftest.h echo "${am__include} ${am__quote}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=conftest.c object=conftest.o \ depfile=conftest.Po tmpdepfile=conftest.TPo \ $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && grep conftest.h conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then am_cv_CC_dependencies_compiler_type=$depmode break 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 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 to if __STDC__ is defined, since # 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #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 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 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 to if __STDC__ is defined, since # 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #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 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 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 AIX" >&5 echo $ECHO_N "checking for AIX... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef _AIX yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 cat >>confdefs.h <<\_ACEOF #define _ALL_SOURCE 1 _ACEOF else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest* echo "$as_me:$LINENO: checking for strerror in -lcposix" >&5 echo $ECHO_N "checking for strerror in -lcposix... $ECHO_C" >&6 if test "${ac_cv_lib_cposix_strerror+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcposix $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 strerror (); int main () { strerror (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_cposix_strerror=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_cposix_strerror=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_cposix_strerror" >&5 echo "${ECHO_T}$ac_cv_lib_cposix_strerror" >&6 if test $ac_cv_lib_cposix_strerror = yes; then LIBS="$LIBS -lcposix" fi 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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.$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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #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.* *.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 #line $LINENO "configure" /* 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>&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.$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 if test "${ac_cv_header_minix_config_h+set}" = set; then echo "$as_me:$LINENO: checking for minix/config.h" >&5 echo $ECHO_N "checking for minix/config.h... $ECHO_C" >&6 if test "${ac_cv_header_minix_config_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 echo "${ECHO_T}$ac_cv_header_minix_config_h" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking minix/config.h usability" >&5 echo $ECHO_N "checking minix/config.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext 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); } && { 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.$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 minix/config.h presence" >&5 echo $ECHO_N "checking minix/config.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 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 in yes:no ) { echo "$as_me:$LINENO: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: minix/config.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: minix/config.h: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; no:yes ) { echo "$as_me:$LINENO: WARNING: minix/config.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: minix/config.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: minix/config.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: minix/config.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: minix/config.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: minix/config.h: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for minix/config.h" >&5 echo $ECHO_N "checking for minix/config.h... $ECHO_C" >&6 if test "${ac_cv_header_minix_config_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_minix_config_h=$ac_header_preproc fi echo "$as_me:$LINENO: result: $ac_cv_header_minix_config_h" >&5 echo "${ECHO_T}$ac_cv_header_minix_config_h" >&6 fi if test $ac_cv_header_minix_config_h = yes; then MINIX=yes else MINIX= fi if test "$MINIX" = yes; then cat >>confdefs.h <<\_ACEOF #define _POSIX_SOURCE 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define _POSIX_1_SOURCE 2 _ACEOF cat >>confdefs.h <<\_ACEOF #define _MINIX 1 _ACEOF 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 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 to if __STDC__ is defined, since # 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #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 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 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 to if __STDC__ is defined, since # 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #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 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 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 best CFLAGS argument" >&5 echo $ECHO_N "checking for best CFLAGS argument... $ECHO_C" >&6 if test $ac_cv_c_compiler_gnu = yes ; then CFLAGS='-O2 -fomit-frame-pointer' else CFLAGS='-O' fi echo "$as_me:$LINENO: result: $CFLAGS" >&5 echo "${ECHO_T}$CFLAGS" >&6 # Add the stamp file to the list of files AC keeps track of, # along with our hook. ac_config_headers="$ac_config_headers configure.h" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; 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_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # 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_RANLIB="${ac_tool_prefix}ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then echo "$as_me:$LINENO: result: $RANLIB" >&5 echo "${ECHO_T}$RANLIB" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; 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_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # 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_RANLIB="ranlib" 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_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 echo "${ECHO_T}$ac_ct_RANLIB" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi RANLIB=$ac_ct_RANLIB else RANLIB="$ac_cv_prog_RANLIB" fi echo "$as_me:$LINENO: checking for library containing cos" >&5 echo $ECHO_N "checking for library containing cos... $ECHO_C" >&6 if test "${ac_cv_search_cos+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS ac_cv_search_cos=no cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 cos (); int main () { cos (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_search_cos="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_cos" = no; then for ac_lib in m; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 cos (); int main () { cos (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_search_cos="-l$ac_lib" break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_search_cos" >&5 echo "${ECHO_T}$ac_cv_search_cos" >&6 if test "$ac_cv_search_cos" != no; then test "$ac_cv_search_cos" = "none required" || LIBS="$ac_cv_search_cos $LIBS" fi echo "$as_me:$LINENO: checking for main in -lseq" >&5 echo $ECHO_N "checking for main in -lseq... $ECHO_C" >&6 if test "${ac_cv_lib_seq_main+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lseq $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { main (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_seq_main=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_seq_main=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_seq_main" >&5 echo "${ECHO_T}$ac_cv_lib_seq_main" >&6 if test $ac_cv_lib_seq_main = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBSEQ 1 _ACEOF LIBS="-lseq $LIBS" fi echo "$as_me:$LINENO: checking for main in -lnsl" >&5 echo $ECHO_N "checking for main in -lnsl... $ECHO_C" >&6 if test "${ac_cv_lib_nsl_main+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { main (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_nsl_main=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_nsl_main=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_main" >&5 echo "${ECHO_T}$ac_cv_lib_nsl_main" >&6 if test $ac_cv_lib_nsl_main = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL 1 _ACEOF LIBS="-lnsl $LIBS" fi echo "$as_me:$LINENO: checking for main in -lsocket" >&5 echo $ECHO_N "checking for main in -lsocket... $ECHO_C" >&6 if test "${ac_cv_lib_socket_main+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { main (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_socket_main=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_socket_main=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_socket_main" >&5 echo "${ECHO_T}$ac_cv_lib_socket_main" >&6 if test $ac_cv_lib_socket_main = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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.$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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #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.* *.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 for ac_header in memory.h sys/select.h unistd.h assert.h stdlib.h string.h netinet/in.h sys/in.h sys/inet.h arpa/nameser.h resolv.h sys/time.h sys/utsname.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 #line $LINENO "configure" /* 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>&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.$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 #line $LINENO "configure" /* 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 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 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 preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; 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: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _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 ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 echo $ECHO_N "checking for $ac_hdr that defines DIR... $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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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.$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_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo "$as_me:$LINENO: checking for library containing opendir" >&5 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS ac_cv_search_opendir=no cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_search_opendir="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_opendir" = no; then for ac_lib in dir; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_search_opendir="-l$ac_lib" break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 echo "${ECHO_T}$ac_cv_search_opendir" >&6 if test "$ac_cv_search_opendir" != no; then test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" fi else echo "$as_me:$LINENO: checking for library containing opendir" >&5 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS ac_cv_search_opendir=no cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_search_opendir="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_opendir" = no; then for ac_lib in x; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_search_opendir="-l$ac_lib" break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 echo "${ECHO_T}$ac_cv_search_opendir" >&6 if test "$ac_cv_search_opendir" != no; then test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" fi fi echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_time=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_time=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6 if test $ac_cv_header_time = yes; then cat >>confdefs.h <<\_ACEOF #define TIME_WITH_SYS_TIME 1 _ACEOF fi if test "${ac_cv_header_sun_audioio_h+set}" = set; then echo "$as_me:$LINENO: checking for sun/audioio.h" >&5 echo $ECHO_N "checking for sun/audioio.h... $ECHO_C" >&6 if test "${ac_cv_header_sun_audioio_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: $ac_cv_header_sun_audioio_h" >&5 echo "${ECHO_T}$ac_cv_header_sun_audioio_h" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking sun/audioio.h usability" >&5 echo $ECHO_N "checking sun/audioio.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext 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); } && { 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.$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 sun/audioio.h presence" >&5 echo $ECHO_N "checking sun/audioio.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 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 in yes:no ) { echo "$as_me:$LINENO: WARNING: sun/audioio.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: sun/audioio.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: sun/audioio.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: sun/audioio.h: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; no:yes ) { echo "$as_me:$LINENO: WARNING: sun/audioio.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: sun/audioio.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: sun/audioio.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: sun/audioio.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: sun/audioio.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: sun/audioio.h: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for sun/audioio.h" >&5 echo $ECHO_N "checking for sun/audioio.h... $ECHO_C" >&6 if test "${ac_cv_header_sun_audioio_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_sun_audioio_h=$ac_header_preproc fi echo "$as_me:$LINENO: result: $ac_cv_header_sun_audioio_h" >&5 echo "${ECHO_T}$ac_cv_header_sun_audioio_h" >&6 fi if test $ac_cv_header_sun_audioio_h = yes; then cat >>confdefs.h <<\_ACEOF #define SUN_SOUND 1 _ACEOF fi if test $ac_cv_header_sun_audioio_h = no; then if test "${ac_cv_header_linux_soundcard_h+set}" = set; then echo "$as_me:$LINENO: checking for linux/soundcard.h" >&5 echo $ECHO_N "checking for linux/soundcard.h... $ECHO_C" >&6 if test "${ac_cv_header_linux_soundcard_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: $ac_cv_header_linux_soundcard_h" >&5 echo "${ECHO_T}$ac_cv_header_linux_soundcard_h" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking linux/soundcard.h usability" >&5 echo $ECHO_N "checking linux/soundcard.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext 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); } && { 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.$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 linux/soundcard.h presence" >&5 echo $ECHO_N "checking linux/soundcard.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 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 in yes:no ) { echo "$as_me:$LINENO: WARNING: linux/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: linux/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: linux/soundcard.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: linux/soundcard.h: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; no:yes ) { echo "$as_me:$LINENO: WARNING: linux/soundcard.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: linux/soundcard.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: linux/soundcard.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: linux/soundcard.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: linux/soundcard.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: linux/soundcard.h: proceeding with the preprocessor's result" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to bug-autoconf@gnu.org. ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for linux/soundcard.h" >&5 echo $ECHO_N "checking for linux/soundcard.h... $ECHO_C" >&6 if test "${ac_cv_header_linux_soundcard_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_linux_soundcard_h=$ac_header_preproc fi echo "$as_me:$LINENO: result: $ac_cv_header_linux_soundcard_h" >&5 echo "${ECHO_T}$ac_cv_header_linux_soundcard_h" >&6 fi if test $ac_cv_header_linux_soundcard_h = yes; then cat >>confdefs.h <<\_ACEOF #define LINUX_SOUND 1 _ACEOF fi fi echo "$as_me:$LINENO: checking for h_errno" >&5 echo $ECHO_N "checking for h_errno... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if HAVE_NETINET_IN_H #include #endif #if HAVE_SYS_IN_H #include #endif #if HAVE_SYS_INET_H #include #endif #include #if HAVE_ARPA_NAMESER_H #include #endif #if HAVE_RESOLV_H #include #endif int main () { h_errno = 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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 echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_H_ERRNO 1 _ACEOF else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext echo "$as_me:$LINENO: checking for sockets" >&5 echo $ECHO_N "checking for sockets... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if HAVE_NETINET_IN_H #include #endif #if HAVE_SYS_IN_H #include #endif #if HAVE_SYS_INET_H #include #endif #include #if HAVE_ARPA_NAMESER_H #include #endif #if HAVE_RESOLV_H #include #endif #include #include #include int main () { struct sockaddr_in sa; bind(0,(struct sockaddr *)&sa, sizeof(sa)); listen(0,2); socket(AF_INET,SOCK_STREAM,0); gethostbyname("foo"); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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 echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF #define HAVE_SOCKETS 1 _ACEOF else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext if test "$cross_compiling" = "yes" ; then echo "********* IMPORTANT *************************************************" echo "*** It looks like either you are cross compiling, or configure cannot" echo "*** figure out how to run your C compiler." echo "*** If you are cross compiling, then configure cannot detect the " echo "*** size of various types and the endian style of your machine. " echo "*** You will have to edit the file obj-${SYSTEM_TYPE}/configure.h " echo "*** by hand." echo "*** If you are NOT cross compiling, then please see the README file" echo "*** for instructions on how to tell ./configure how to run your" echo "*** C compiler." echo "*********************************************************************" else echo "$as_me:$LINENO: checking for short" >&5 echo $ECHO_N "checking for short... $ECHO_C" >&6 if test "${ac_cv_type_short+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if ((short *) 0) return 0; if (sizeof (short)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_type_short=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_short=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5 echo "${ECHO_T}$ac_cv_type_short" >&6 echo "$as_me:$LINENO: checking size of short" >&5 echo $ECHO_N "checking size of short... $ECHO_C" >&6 if test "${ac_cv_sizeof_short+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$ac_cv_type_short" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (short))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (short))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (short))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_short=$ac_lo;; '') { { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77 See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (short), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac else if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default long longval () { return (long) (sizeof (short)); } unsigned long ulongval () { return (long) (sizeof (short)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); if (((long) (sizeof (short))) < 0) { long i = longval (); if (i != ((long) (sizeof (short)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); if (i != ((long) (sizeof (short)))) exit (1); fprintf (f, "%lu\n", i); } exit (ferror (f) || fclose (f) != 0); ; 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_sizeof_short=`cat conftest.val` 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 ) { { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77 See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (short), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi rm -f conftest.val else ac_cv_sizeof_short=0 fi fi echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5 echo "${ECHO_T}$ac_cv_sizeof_short" >&6 cat >>confdefs.h <<_ACEOF #define SIZEOF_SHORT $ac_cv_sizeof_short _ACEOF if test "x$ac_cv_sizeof_short" '=' x0 ; then echo "********* IMPORTANT *************************************************" echo "*** configure cannot figure out how to run your C compiler." echo "*** If you are cross compiling, then configure cannot detect the " echo "*** size of various types and the endian style of your machine. " echo "*** You will have to edit the file obj-${SYSTEM_TYPE}/configure.h " echo "*** by hand." echo "*** If you are NOT cross compiling, then please see the README file" echo "*** for instructions on how to tell ./configure how to run your" echo "*** C compiler." echo "*********************************************************************" exit 1 fi echo "$as_me:$LINENO: checking for int" >&5 echo $ECHO_N "checking for int... $ECHO_C" >&6 if test "${ac_cv_type_int+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if ((int *) 0) return 0; if (sizeof (int)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_type_int=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_int=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 echo "${ECHO_T}$ac_cv_type_int" >&6 echo "$as_me:$LINENO: checking size of int" >&5 echo $ECHO_N "checking size of int... $ECHO_C" >&6 if test "${ac_cv_sizeof_int+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$ac_cv_type_int" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_int=$ac_lo;; '') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (int), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac else if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default long longval () { return (long) (sizeof (int)); } unsigned long ulongval () { return (long) (sizeof (int)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); if (((long) (sizeof (int))) < 0) { long i = longval (); if (i != ((long) (sizeof (int)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); if (i != ((long) (sizeof (int)))) exit (1); fprintf (f, "%lu\n", i); } exit (ferror (f) || fclose (f) != 0); ; 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_sizeof_int=`cat conftest.val` 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 ) { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77 See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (int), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi rm -f conftest.val else ac_cv_sizeof_int=0 fi fi echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 echo "${ECHO_T}$ac_cv_sizeof_int" >&6 cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int _ACEOF echo "$as_me:$LINENO: checking for long" >&5 echo $ECHO_N "checking for long... $ECHO_C" >&6 if test "${ac_cv_type_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if ((long *) 0) return 0; if (sizeof (long)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_type_long=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_long=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 echo "${ECHO_T}$ac_cv_type_long" >&6 echo "$as_me:$LINENO: checking size of long" >&5 echo $ECHO_N "checking size of long... $ECHO_C" >&6 if test "${ac_cv_sizeof_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$ac_cv_type_long" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_long=$ac_lo;; '') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac else if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default long longval () { return (long) (sizeof (long)); } unsigned long ulongval () { return (long) (sizeof (long)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); if (((long) (sizeof (long))) < 0) { long i = longval (); if (i != ((long) (sizeof (long)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); if (i != ((long) (sizeof (long)))) exit (1); fprintf (f, "%lu\n", i); } exit (ferror (f) || fclose (f) != 0); ; 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_sizeof_long=`cat conftest.val` 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 ) { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77 See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi rm -f conftest.val else ac_cv_sizeof_long=0 fi fi echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_long" >&6 cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF echo "$as_me:$LINENO: checking for long long" >&5 echo $ECHO_N "checking for long long... $ECHO_C" >&6 if test "${ac_cv_type_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if ((long long *) 0) return 0; if (sizeof (long long)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_type_long_long=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_long_long=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 echo "${ECHO_T}$ac_cv_type_long_long" >&6 echo "$as_me:$LINENO: checking size of long long" >&5 echo $ECHO_N "checking size of long long... $ECHO_C" >&6 if test "${ac_cv_sizeof_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$ac_cv_type_long_long" = yes; then # The cast to unsigned long works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (long long))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_long_long=$ac_lo;; '') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long long), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } ;; esac else if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default long longval () { return (long) (sizeof (long long)); } unsigned long ulongval () { return (long) (sizeof (long long)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) exit (1); if (((long) (sizeof (long long))) < 0) { long i = longval (); if (i != ((long) (sizeof (long long)))) exit (1); fprintf (f, "%ld\n", i); } else { unsigned long i = ulongval (); if (i != ((long) (sizeof (long long)))) exit (1); fprintf (f, "%lu\n", i); } exit (ferror (f) || fclose (f) != 0); ; 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_sizeof_long_long=`cat conftest.val` 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 ) { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77 See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long long), 77 See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi rm -f conftest.val else ac_cv_sizeof_long_long=0 fi fi echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6 cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long _ACEOF echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 if test "${ac_cv_c_bigendian+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # See if sys/param.h defines the BYTE_ORDER macro. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN bogus endian macros #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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 # It does; now see whether it defined to BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_bigendian=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_bigendian=no fi rm -f conftest.$ac_objext conftest.$ac_ext else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # It does not; compile a test program. if test "$cross_compiling" = yes; then # try to guess the endianness by grepping values into an object file ac_cv_c_bigendian=unknown cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } int main () { _ascii (); _ebcdic (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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 if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long l; char c[sizeof (long)]; } u; u.l = 1; exit (u.c[sizeof (long) - 1] == 1); } _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_c_bigendian=no 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_c_bigendian=yes fi rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 echo "${ECHO_T}$ac_cv_c_bigendian" >&6 case $ac_cv_c_bigendian in yes) cat >>confdefs.h <<\_ACEOF #define WORDS_BIGENDIAN 1 _ACEOF ;; no) ;; *) { { echo "$as_me:$LINENO: error: unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" >&5 echo "$as_me: error: unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} { (exit 1); exit 1; }; } ;; esac fi for ac_func in strerror getdtablesize memmove strcasecmp 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 #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif /* 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>&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.$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 echo "$as_me:$LINENO: checking return type of signal handlers" >&5 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #ifdef signal # undef signal #endif #ifdef __cplusplus extern "C" void (*signal (int, void (*)(int)))(int); #else void (*signal ()) (); #endif int main () { int i; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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); } && { 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_type_signal=void else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_signal=int fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 echo "${ECHO_T}$ac_cv_type_signal" >&6 cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF echo "$as_me:$LINENO: checking for X" >&5 echo $ECHO_N "checking for X... $ECHO_C" >&6 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then withval="$with_x" fi; # $have_x is `yes', `no', `disabled', or empty when we do not yet know. if test "x$with_x" = xno; then # The user explicitly disabled X. have_x=disabled else if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then # Both variables are already set. have_x=yes else if test "${ac_cv_have_x+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # One or both of the vars are not set, and there is no cached value. ac_x_includes=no ac_x_libraries=no rm -fr conftest.dir if mkdir conftest.dir; then cd conftest.dir # Make sure to not put "make" in the Imakefile rules, since we grep it out. cat >Imakefile <<'_ACEOF' acfindx: @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' _ACEOF if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. for ac_extension in a so sl; do if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && test -f $ac_im_libdir/libX11.$ac_extension; then ac_im_usrlibdir=$ac_im_libdir; break fi done # Screen out bogus values from the imake configuration. They are # bogus both because they are the default anyway, and because # using them would break gcc on systems where it needs fixed includes. case $ac_im_incroot in /usr/include) ;; *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;; esac case $ac_im_usrlibdir in /usr/lib | /lib) ;; *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;; esac fi cd .. rm -fr conftest.dir fi # Standard set of common directories for X headers. # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include /usr/X11R6/include /usr/X11R5/include /usr/X11R4/include /usr/include/X11 /usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 /usr/local/X11/include /usr/local/X11R6/include /usr/local/X11R5/include /usr/local/X11R4/include /usr/local/include/X11 /usr/local/include/X11R6 /usr/local/include/X11R5 /usr/local/include/X11R4 /usr/X386/include /usr/x386/include /usr/XFree86/include/X11 /usr/include /usr/local/include /usr/unsupported/include /usr/athena/include /usr/local/x11r5/include /usr/lpp/Xamples/include /usr/openwin/include /usr/openwin/share/include' if test "$ac_x_includes" = no; then # Guess where to find include files, by looking for Intrinsic.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _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 else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # We can compile using X headers with no special include directory. ac_x_includes= else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do if test -r "$ac_dir/X11/Intrinsic.h"; then ac_x_includes=$ac_dir break fi done fi rm -f conftest.err conftest.$ac_ext fi # $ac_x_includes = no if test "$ac_x_libraries" = no; then # Check for the libraries. # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS LIBS="-lXt $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { XtMalloc (0) ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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 LIBS=$ac_save_LIBS # We can link X programs with no special library path. ac_x_libraries= else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 LIBS=$ac_save_LIBS for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` do # Don't even attempt the hair of trying to link an X program! for ac_extension in a so sl; do if test -r $ac_dir/libXt.$ac_extension; then ac_x_libraries=$ac_dir break 2 fi done done fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then # Didn't find X anywhere. Cache the known absence of X. ac_cv_have_x="have_x=no" else # Record where we found X for the cache. ac_cv_have_x="have_x=yes \ ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" fi fi fi eval "$ac_cv_have_x" fi # $with_x != no if test "$have_x" != yes; then echo "$as_me:$LINENO: result: $have_x" >&5 echo "${ECHO_T}$have_x" >&6 no_x=yes else # If each of the values was on the command line, it overrides each guess. test "x$x_includes" = xNONE && x_includes=$ac_x_includes test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries # Update the cache value to reflect the command line values. ac_cv_have_x="have_x=yes \ ac_x_includes=$x_includes ac_x_libraries=$x_libraries" echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5 echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6 fi if test "$no_x" = yes; then # Not all programs may use this symbol, but it does not hurt to define it. cat >>confdefs.h <<\_ACEOF #define X_DISPLAY_MISSING 1 _ACEOF X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= else if test -n "$x_includes"; then X_CFLAGS="$X_CFLAGS -I$x_includes" fi # It would also be nice to do this for all -L options, not just this one. if test -n "$x_libraries"; then X_LIBS="$X_LIBS -L$x_libraries" # For Solaris; some versions of Sun CC require a space after -R and # others require no space. Words are not sufficient . . . . case `(uname -sr) 2>/dev/null` in "SunOS 5"*) echo "$as_me:$LINENO: checking whether -R must be followed by a space" >&5 echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6 ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 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='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_R_nospace=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_R_nospace=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext if test $ac_R_nospace = yes; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 X_LIBS="$X_LIBS -R$x_libraries" else LIBS="$ac_xsave_LIBS -R $x_libraries" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 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='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_R_space=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_R_space=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext if test $ac_R_space = yes; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 X_LIBS="$X_LIBS -R $x_libraries" else echo "$as_me:$LINENO: result: neither works" >&5 echo "${ECHO_T}neither works" >&6 fi fi LIBS=$ac_xsave_LIBS esac fi # Check for system-dependent libraries X programs must link with. # Do this before checking for the system-independent R6 libraries # (-lICE), since we may need -lsocket or whatever for X linking. if test "$ISC" = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" else # Martyn Johnson says this is needed for Ultrix, if the X # libraries were built with DECnet support. And Karl Berry says # the Alpha needs dnet_stub (dnet does not exist). ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 XOpenDisplay (); int main () { XOpenDisplay (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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 : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5 echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6 if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 dnet_ntoa (); int main () { dnet_ntoa (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_dnet_dnet_ntoa=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dnet_dnet_ntoa=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6 if test $ac_cv_lib_dnet_dnet_ntoa = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5 echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6 if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet_stub $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 dnet_ntoa (); int main () { dnet_ntoa (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_dnet_stub_dnet_ntoa=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dnet_stub_dnet_ntoa=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6 if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi fi fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS="$ac_xsave_LIBS" # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, # to get the SysV transport functions. # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4) # needs -lnsl. # The nsl library prevents programs from opening the X display # on Irix 5.2, according to T.E. Dickey. # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. echo "$as_me:$LINENO: checking for gethostbyname" >&5 echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6 if test "${ac_cv_func_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, which can conflict with char gethostbyname (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif /* 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 gethostbyname (); /* 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_gethostbyname) || defined (__stub___gethostbyname) choke me #else char (*f) () = gethostbyname; #endif #ifdef __cplusplus } #endif int main () { return f != gethostbyname; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_gethostbyname=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6 if test $ac_cv_func_gethostbyname = no; then echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5 echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6 if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 gethostbyname (); int main () { gethostbyname (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_nsl_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_nsl_gethostbyname=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6 if test $ac_cv_lib_nsl_gethostbyname = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5 echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6 if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbsd $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 gethostbyname (); int main () { gethostbyname (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_bsd_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_bsd_gethostbyname=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6 if test $ac_cv_lib_bsd_gethostbyname = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi fi fi # lieder@skyler.mavd.honeywell.com says without -lsocket, # socket/setsockopt and other routines are undefined under SCO ODT # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary # on later versions), says Simon Leinen: it contains gethostby* # variants that don't use the name server (or something). -lsocket # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. echo "$as_me:$LINENO: checking for connect" >&5 echo $ECHO_N "checking for connect... $ECHO_C" >&6 if test "${ac_cv_func_connect+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, which can conflict with char connect (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif /* 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 connect (); /* 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_connect) || defined (__stub___connect) choke me #else char (*f) () = connect; #endif #ifdef __cplusplus } #endif int main () { return f != connect; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_connect=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_connect=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5 echo "${ECHO_T}$ac_cv_func_connect" >&6 if test $ac_cv_func_connect = no; then echo "$as_me:$LINENO: checking for connect in -lsocket" >&5 echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6 if test "${ac_cv_lib_socket_connect+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 connect (); int main () { connect (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_socket_connect=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_socket_connect=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5 echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6 if test $ac_cv_lib_socket_connect = yes; then X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi fi # Guillermo Gomez says -lposix is necessary on A/UX. echo "$as_me:$LINENO: checking for remove" >&5 echo $ECHO_N "checking for remove... $ECHO_C" >&6 if test "${ac_cv_func_remove+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, which can conflict with char remove (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif /* 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 remove (); /* 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_remove) || defined (__stub___remove) choke me #else char (*f) () = remove; #endif #ifdef __cplusplus } #endif int main () { return f != remove; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_remove=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_remove=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5 echo "${ECHO_T}$ac_cv_func_remove" >&6 if test $ac_cv_func_remove = no; then echo "$as_me:$LINENO: checking for remove in -lposix" >&5 echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6 if test "${ac_cv_lib_posix_remove+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lposix $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 remove (); int main () { remove (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_posix_remove=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_posix_remove=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5 echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6 if test $ac_cv_lib_posix_remove = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. echo "$as_me:$LINENO: checking for shmat" >&5 echo $ECHO_N "checking for shmat... $ECHO_C" >&6 if test "${ac_cv_func_shmat+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shmat (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif /* 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 shmat (); /* 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_shmat) || defined (__stub___shmat) choke me #else char (*f) () = shmat; #endif #ifdef __cplusplus } #endif int main () { return f != shmat; ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_shmat=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_shmat=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5 echo "${ECHO_T}$ac_cv_func_shmat" >&6 if test $ac_cv_func_shmat = no; then echo "$as_me:$LINENO: checking for shmat in -lipc" >&5 echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6 if test "${ac_cv_lib_ipc_shmat+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lipc $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 shmat (); int main () { shmat (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_ipc_shmat=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ipc_shmat=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5 echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6 if test $ac_cv_lib_ipc_shmat = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi fi fi # Check for libraries that X11R6 Xt/Xaw programs need. ac_save_LDFLAGS=$LDFLAGS test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to # check for ICE first), but we must link in the order -lSM -lICE or # we get undefined symbols. So assume we have SM if we have ICE. # These have to be linked with before -lX11, unlike the other # libraries we check for below, so use a different variable. # John Interrante, Karl Berry echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5 echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6 if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" /* 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 IceConnectionNumber (); int main () { IceConnectionNumber (); ; return 0; } _ACEOF rm -f conftest.$ac_objext 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='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_ICE_IceConnectionNumber=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ICE_IceConnectionNumber=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6 if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi LDFLAGS=$ac_save_LDFLAGS fi if test '!' "$no_x" ; then cat >>confdefs.h <<\_ACEOF #define X11_DISP 1 _ACEOF CFLAGS="$CFLAGS $X_CFLAGS" LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS" else echo "***" echo "*** Sorry, configure cannot find your X includes and libraries." echo "*** Compiling cannot continue until this is fixed." echo "*** If you know where your X11 is installed, try" echo "*** ./configure --x-includes= --x-libraries=" echo "***" exit 1 fi ac_config_files="$ac_config_files Makefile man6/Makefile src/gmp/Makefile src/client/Makefile src/Makefile wmslib/src/wms/Makefile wmslib/src/but/Makefile wmslib/src/abut/Makefile wmslib/src/Makefile wmslib/Makefile grab_cgoban cgoban1.spec" 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 DEFS=-DHAVE_CONFIG_H 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 : ${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 # Support unset when possible. if (FOO=FOO; unset FOO) >/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 -n "`(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 as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="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="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.57. 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 --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.57, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 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" ;; "man6/Makefile" ) CONFIG_FILES="$CONFIG_FILES man6/Makefile" ;; "src/gmp/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/gmp/Makefile" ;; "src/client/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/client/Makefile" ;; "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "wmslib/src/wms/Makefile" ) CONFIG_FILES="$CONFIG_FILES wmslib/src/wms/Makefile" ;; "wmslib/src/but/Makefile" ) CONFIG_FILES="$CONFIG_FILES wmslib/src/but/Makefile" ;; "wmslib/src/abut/Makefile" ) CONFIG_FILES="$CONFIG_FILES wmslib/src/abut/Makefile" ;; "wmslib/src/Makefile" ) CONFIG_FILES="$CONFIG_FILES wmslib/src/Makefile" ;; "wmslib/Makefile" ) CONFIG_FILES="$CONFIG_FILES wmslib/Makefile" ;; "grab_cgoban" ) CONFIG_FILES="$CONFIG_FILES grab_cgoban" ;; "cgoban1.spec" ) CONFIG_FILES="$CONFIG_FILES cgoban1.spec" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "configure.h" ) CONFIG_HEADERS="$CONFIG_HEADERS configure.h" ;; *) { { 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_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers 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,@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,@AMTAR@,$AMTAR,;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,@AWK@,$AWK,;t t s,@SET_MAKE@,$SET_MAKE,;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,@CPP@,$CPP,;t t s,@EGREP@,$EGREP,;t t s,@DATE@,$DATE,;t t s,@RANLIB@,$RANLIB,;t t s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t s,@X_CFLAGS@,$X_CFLAGS,;t t s,@X_PRE_LIBS@,$X_PRE_LIBS,;t t s,@X_LIBS@,$X_LIBS,;t t s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;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 # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac 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 # 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; } _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_HEADER section. # # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='[ ].*$,\1#\2' ac_dC=' ' ac_dD=',;t' # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='$,\1#\2define\3' ac_uC=' ' ac_uD=',;t' for ac_file in : $CONFIG_HEADERS; 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 test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # 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; } # Remove the trailing spaces. sed 's/[ ]*$//' $ac_file_inputs >$tmp/in _ACEOF # Transform confdefs.h into two sed scripts, `conftest.defines' and # `conftest.undefs', that substitutes the proper values into # config.h.in to produce config.h. The first handles `#define' # templates, and the second `#undef' templates. # And first: Protect against being on the right side of a sed subst in # config.status. Protect against being in an unquoted here document # in config.status. rm -f conftest.defines conftest.undefs # Using a here document instead of a string reduces the quoting nightmare. # Putting comments in sed scripts is not portable. # # `end' is used to avoid that the second main sed command (meant for # 0-ary CPP macros) applies to n-ary macro definitions. # See the Autoconf documentation for `clear'. cat >confdef2sed.sed <<\_ACEOF s/[\\&,]/\\&/g s,[\\$`],\\&,g t clear : clear s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp t end s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp : end _ACEOF # If some macros were called several times there might be several times # the same #defines, which is useless. Nevertheless, we may not want to # sort them, since we want the *last* AC-DEFINE to be honored. uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >>conftest.undefs <<\_ACEOF s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, _ACEOF # Break up conftest.defines because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS echo ' :' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.defines >/dev/null do # Write a limited-size here document to $tmp/defines.sed. echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#define' lines. echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/defines.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines echo ' fi # grep' >>$CONFIG_STATUS echo >>$CONFIG_STATUS # Break up conftest.undefs because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.undefs >/dev/null do # Write a limited-size here document to $tmp/undefs.sed. echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#undef' echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/undefs.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail rm -f conftest.undefs mv conftest.tail conftest.undefs done rm -f conftest.undefs cat >>$CONFIG_STATUS <<\_ACEOF # 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 echo "/* Generated by configure. */" >$tmp/config.h else echo "/* $ac_file. Generated by configure. */" >$tmp/config.h fi cat $tmp/in >>$tmp/config.h rm -f $tmp/in if test x"$ac_file" != x-; then if diff $ac_file $tmp/config.h >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else 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; }; }; } rm -f $ac_file mv $tmp/config.h $ac_file fi else cat $tmp/config.h rm -f $tmp/config.h fi # Run the commands associated with the file. case $ac_file in configure.h ) # update the timestamp echo 'timestamp for configure.h' >"./stamp-h1" ;; esac 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'` 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 # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` { 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 grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue # Extract the definition of DEP_FILES from the Makefile without # running `make'. DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` test -z "$DEPDIR" && continue # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n -e '/^U = / s///p' < "$mf"` test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" # 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 -e ' /^DEP_FILES = .*\\\\$/ { s/^DEP_FILES = // :loop s/\\\\$// p n /\\\\$/ b loop p } /^DEP_FILES = / s/^DEP_FILES = //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 cgoban-1.9.14/configure.h.in0000664000671000067100000001271007606355056011300 /* configure.h.in. Generated from configure.in by autoheader. */ /* * configure.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * Copyright (C) 2002 Kevin Sonney * * 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. * * Original code written by William M. Shubert * AutoMake code written by Teun Burgers * The maintainer can be reached at or * Kevin Sonney * 1801 Varsity Drive * Raleigh, NC 27606 * (919) 754-3700 x44112 */ #undef DATE #undef DATE_FRENCH #undef HAVE_H_ERRNO #undef HAVE_SOCKETS #undef LINUX_SOUND #undef SUN_SOUND #undef VERSION #undef X11_DISP /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_NAMESER_H /* Define to 1 if you have the header file. */ #undef HAVE_ASSERT_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the `getdtablesize' function. */ #undef HAVE_GETDTABLESIZE /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL /* Define to 1 if you have the `seq' library (-lseq). */ #undef HAVE_LIBSEQ /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMMOVE /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_RESOLV_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_INET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IN_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_UTSNAME_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* The size of a `int', as computed by sizeof. */ #undef SIZEOF_INT /* The size of a `long', as computed by sizeof. */ #undef SIZEOF_LONG /* The size of a `long long', as computed by sizeof. */ #undef SIZEOF_LONG_LONG /* The size of a `short', as computed by sizeof. */ #undef SIZEOF_SHORT /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN /* Define to 1 if the X Window System is missing or not being used. */ #undef X_DISPLAY_MISSING /* Define to 1 if on AIX 3. System headers sometimes define this. We just want to avoid a redefinition error message. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE cgoban-1.9.14/configure.in0000664000671000067100000002001607606354625011051 #for autoconf 2.1x start configure script with next three lines AC_PREREQ(2.13) AC_INIT(src/cgoban.c) AM_INIT_AUTOMAKE(cgoban, 1.9.14) #for autoconf 2.5x start configure script with next four lines # AC_PREREQ(2.50) # AC_INIT(cgoban, 1.9.13) # AC_CONFIG_SRCDIR(src/cgoban.c) # AM_INIT_AUTOMAKE # # $Source: /cvsroot/cgoban1/cgoban1/configure.in,v $ # $Revision: 1.11 $ # $Date: 2002/11/19 16:46:01 $ # # Remember to change these in "README", "TODO", and "cgoban.6" too. # DATE must be in DAY MONTH YEAR format. date="10 23 2002" VERSION="1.9.14" # If we want to upgrade to 2.5x, AH_TOP and AH_TEMPLATE # macros can be used # AH_TOP text is inserted by autoheader in configure.h.in # AH_TOP([ #/* # * configure.h, part of Complete Goban (game program) # * Copyright (C) 1995 William Shubert # * Copyright (C) 2002 Kevin Sonney # * # * 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. # * # * Original code written by William M. Shubert # * AutoMake code written by Teun Burgers # * The maintainer can be reached at or # * Kevin Sonney # * 1801 Varsity Drive # * Raleigh, NC 27606 # * (919) 754-3700 x44112 # */] # ) # AH_TEMPLATE([DATE],[]) # AH_TEMPLATE([DATE_FRENCH],[]) # AH_TEMPLATE([HAVE_H_ERRNO],[]) # AH_TEMPLATE([HAVE_SOCKETS],[]) # AH_TEMPLATE([LINUX_SOUND],[ # LINUX_SOUND should be set to 1 if you have linux-style sound. Mostly # this means that you have "linux/soundcard.h" # ]) # AH_TEMPLATE([SUN_SOUND],[ # SUN_SOUND should be set to 1 if you have sun sparc-style sound. Mostly # this means that you have "sun/audioio.h". # ]) # AH_TEMPLATE([VERSION],[]) # AH_TEMPLATE([X11_DISP],[Define X11_DISP to be 1 if you have X11.]) ###################################################################### # My own, personal functions. # ###################################################################### AC_DEFUN(WMS_GET_CFLAGS, [AC_MSG_CHECKING([for best CFLAGS argument]) if test $ac_cv_prog_gcc = yes ; then CFLAGS='-O2 -fomit-frame-pointer' else CFLAGS='-O' fi AC_MSG_RESULT($CFLAGS) AC_SUBST(CFLAGS)]) AC_DEFUN(WMS_CHECK_H_ERRNO, [AC_MSG_CHECKING([for h_errno]) AC_TRY_LINK([#include #include #if HAVE_NETINET_IN_H #include #endif #if HAVE_SYS_IN_H #include #endif #if HAVE_SYS_INET_H #include #endif #include #if HAVE_ARPA_NAMESER_H #include #endif #if HAVE_RESOLV_H #include #endif], [h_errno = 0;], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_H_ERRNO)], [AC_MSG_RESULT(no)])]) # I don't really know what will clearly tell whether you have sockets or not, # so I just took a bunch of socket-related functions and stuck them in # a routine. If it builds and links, I assume I can build sockets code; # otherwise I assume I can't. AC_DEFUN(WMS_CHECK_SOCKETS, [AC_MSG_CHECKING([for sockets]) AC_TRY_LINK([#include #include #if HAVE_NETINET_IN_H #include #endif #if HAVE_SYS_IN_H #include #endif #if HAVE_SYS_INET_H #include #endif #include #if HAVE_ARPA_NAMESER_H #include #endif #if HAVE_RESOLV_H #include #endif #include #include #include ], [ struct sockaddr_in sa; bind(0,(struct sockaddr *)&sa, sizeof(sa)); listen(0,2); socket(AF_INET,SOCK_STREAM,0); gethostbyname("foo");], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOCKETS)], [AC_MSG_RESULT(no)])]) ###################################################################### # Done with my own functions. On to the real configure file. # ###################################################################### export VERSION AC_DEFINE_UNQUOTED(VERSION,$VERSION) AC_PREFIX_DEFAULT(/usr/games) dayNum=`echo $date | awk '{ print $1 }'` monthNum=`echo $date | awk '{ print $2 }'` yearNum=`echo $date | awk '{ print $3 }'` monthEnglish=`echo January February March April May June July August September October November December | awk '{ print $'$monthNum' }'` monthFrench=`echo Janvier Fevrier Mars Avril Mai Juin Juillet Août Septembre Octobre Novembre Décembre | awk '{ print $'$monthNum' }'` DATE="\"$dayNum $monthEnglish $yearNum\"" DATE_FRENCH="\"$dayNum $monthFrench $yearNum\"" export DATE export DATE_FRENCH AC_DEFINE_UNQUOTED(DATE,$DATE) AC_DEFINE_UNQUOTED(DATE_FRENCH,$DATE_FRENCH) AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PROG_CC AC_AIX AC_ISC_POSIX AC_MINIX AC_PROG_CPP AC_EXEEXT WMS_GET_CFLAGS AM_CONFIG_HEADER(configure.h) AC_SUBST(LIBS)dnl AC_SUBST(VERSION)dnl AC_SUBST(DATE)dnl AC_PROG_RANLIB AC_SEARCH_LIBS(cos, m) AC_CHECK_LIB(seq,main) AC_CHECK_LIB(nsl,main) AC_CHECK_LIB(socket,main) AC_STDC_HEADERS AC_CHECK_HEADERS(memory.h sys/select.h unistd.h assert.h stdlib.h string.h netinet/in.h sys/in.h sys/inet.h arpa/nameser.h resolv.h sys/time.h sys/utsname.h) AC_HEADER_DIRENT AC_TIME_WITH_SYS_TIME AC_CHECK_HEADER(sun/audioio.h, AC_DEFINE(SUN_SOUND)) if test $ac_cv_header_sun_audioio_h = no; then AC_CHECK_HEADER(linux/soundcard.h, AC_DEFINE(LINUX_SOUND)) fi WMS_CHECK_H_ERRNO WMS_CHECK_SOCKETS if test "$cross_compiling" = "yes" ; then echo "********* IMPORTANT *************************************************" echo "*** It looks like either you are cross compiling, or configure cannot" echo "*** figure out how to run your C compiler." echo "*** If you are cross compiling, then configure cannot detect the " echo "*** size of various types and the endian style of your machine. " echo "*** You will have to edit the file obj-${SYSTEM_TYPE}/configure.h " echo "*** by hand." echo "*** If you are NOT cross compiling, then please see the README file" echo "*** for instructions on how to tell ./configure how to run your" echo "*** C compiler." echo "*********************************************************************" else AC_CHECK_SIZEOF(short) if test "x$ac_cv_sizeof_short" '=' x0 ; then echo "********* IMPORTANT *************************************************" echo "*** configure cannot figure out how to run your C compiler." echo "*** If you are cross compiling, then configure cannot detect the " echo "*** size of various types and the endian style of your machine. " echo "*** You will have to edit the file obj-${SYSTEM_TYPE}/configure.h " echo "*** by hand." echo "*** If you are NOT cross compiling, then please see the README file" echo "*** for instructions on how to tell ./configure how to run your" echo "*** C compiler." echo "*********************************************************************" exit 1 fi AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) AC_C_BIGENDIAN fi AC_CHECK_FUNCS(strerror getdtablesize memmove strcasecmp) AC_RETSIGTYPE AC_PATH_XTRA if test '!' "$no_x" ; then AC_DEFINE(X11_DISP) CFLAGS="$CFLAGS $X_CFLAGS" LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS" else echo "***" echo "*** Sorry, configure cannot find your X includes and libraries." echo "*** Compiling cannot continue until this is fixed." echo "*** If you know where your X11 is installed, try" echo "*** ./configure --x-includes= --x-libraries=" echo "***" exit 1 fi AC_OUTPUT(Makefile man6/Makefile src/gmp/Makefile src/client/Makefile src/Makefile wmslib/src/wms/Makefile wmslib/src/but/Makefile wmslib/src/abut/Makefile wmslib/src/Makefile wmslib/Makefile grab_cgoban cgoban1.spec) cgoban-1.9.14/depcomp0000775000671000067100000003034507466272672010130 #! /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 . 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" ;; tru64) # The Tru64 AIX 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. base=`echo "$object" | sed -e 's/\.o$/.d/' -e 's/\.lo$/.d/'` tmpdepfile1="$base.o.d" tmpdepfile2="$base.d" if test "$libtool" = yes; then "$@" -Wc,-MD else "$@" -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, # because we must use -o when running libtool. test -z "$dashmflag" && dashmflag=-M ( IFS=" " case " $* " in *" --mode=compile "*) # this is libtool, let us make it quiet for arg do # cycle over the arguments case "$arg" in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi 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) # 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;; -*) ;; *) set fnord "$@" "$arg"; shift;; esac done obj_suffix="`echo $object | sed 's/^.*\././'`" touch "$tmpdepfile" ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi 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, regardless of -o, # because we must use -o when running libtool. ( IFS=" " case " $* " in *" --mode=compile "*) for arg do # cycle over the arguments case $arg in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" -E | sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi 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. ( IFS=" " case " $* " in *" --mode=compile "*) for arg do # cycle over the arguments case $arg in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac 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" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi 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 cgoban-1.9.14/grab_cgoban.in0000775000671000067100000000363607466272672011335 #! @SHELL@ # # grab_cgoban save.gif # # Look for a cgoban window, grab the displayed GO board and save it # as a gif file. # # Anthony Thyssen 24 October 1995 # # The location of board in CGoban Window # X=15 Y=78 S=393 # perfect fit -- wood only # X=14 Y=77 S=395 # one pixel more (testing) X=8 Y=70 S=410 # green background frame TMP=/tmp/grab_cgoban.$$ trap "rm -f $TMP; exit 0" 0 if [ $# -ne 1 ]; then echo >&2 "Usage: grab_cgoban save.gif" exit; fi # get the windows ID - ignore the Control or tools window if present window=`xwininfo -tree -root | sed -n '/Basicwin/!d; /C[Gg]oban/d; s/^ *\(0x[^ ]*\).*/\1/p'` # How many boards did we find num=`echo $window | wc -w` if [ $num -lt 1 ]; then echo >&2 "No CGoban Board found! - aborting" exit 10 fi if [ $num -gt 1 ]; then echo >&2 "Multiple CGoban Boards found! - aborting" exit 10 fi # Figure out image filters to use! case "`type convert`" in *'not found'*) case "`type ppmtogif`" in *'not found'*) case "`type pnmtogif`" in *'not found'*) FILTER=XWD ;; *) FILTER=PBMPLUS_OLD ;; esac ;; *) FILTER=PBMPLUS ;; esac ;; *) FILTER=IMAGEMAGICK ;; esac # for debugging #echo "filtering image with $FILTER" # grab the image and filter appropriately case "$FILTER" in IMAGEMAGICK) # note ImageMagick can output to given files suffix # in fact it relies on a suffix to the file type xwd -id $window | convert -crop ${S}x${S}+${X}+${Y} - $1 ;; PBMPLUS) xwd -id $window | xwdtopnm 2>/dev/null | pnmcut $X $Y $S $S | ppmtogif 2>/dev/null > $1 ;; PBMPLUS_OLD) xwd -id $window | xwdtopnm 2>/dev/null | pnmcut $X $Y $S $S | pnmtogif 2>/dev/null > $1 ;; XWD) echo >&2 "WARNING: unable to find a image filter package" echo >&2 "Dumping a XWD image to \"$1.xwd\" instead of GIF format" xwd -id $window > $1.xwd ;; esac # for Debugging #xv $1 & cgoban-1.9.14/install-sh0000775000671000067100000001273607466536414010560 #!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 cgoban-1.9.14/missing0000775000671000067100000001451007466536414010143 #! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc. # Franc,ois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.in; then configure_ac=configure.ac else configure_ac=configure.in fi case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing - GNU libit 0.0" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`$configure_ac'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`$configure_ac'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`$configure_ac'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' $configure_ac` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`$configure_ac'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; makeinfo) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequirements for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 cgoban-1.9.14/mkinstalldirs0000775000671000067100000000132707466536414011354 #! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.2 2002/05/09 18:16:44 arburgers Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here cgoban-1.9.14/seigen-minoru.sgf0000664000671000067100000011570007043224462012015 (;GM[1]FF[3] VieW[]SZ[19] PB[Kitani Minoru] BR[9 dan] PW[Go Seigen] WR[9 dan] GN[1st Japan's Strongest Deciding Matches] EV[Go Seigen vs Kitani Minoru] DT[April 14-15, 1957] PC[Tokyo, Japan]TM[10 hours each] RE[W+Resign] SO["Detailed Analysis of Wu's Famous Games. Vol.3" pp. 95-188. People's Sports \[China\], 1986] KM[0] C[Go Seigen (Wu) vs. Kitani (The 1st Japan's Strongest Deciding Matches) Black: Kitani Minoru, 9d White: Go Seigen (Wu), 9d Date: April 14-15, 1957 Place: Tokyo Thanks to Jim Z. Yu for translating this commentary into English.] ;B[qd] C[(* Before WWII, in Japan, the most popular stars in sports were led by Futabayama of sumo \[Japanese wrestling\], Kawakami of baseball, Boriguchi of boxing, and Kimura Meijin of shogi. While in Go, the most honorable, at the top of the world, were none other than the discoverers of "new opennings", Kitani Minoru and Go Seigen \[Wu\]. (* \[Now it's post-war time.\] Those famous stars \[excluding Wu and Kitani\], at one time or another, have either retired or faded, and only the home run king of baseball, Kawakami, is still able to live up with his fame; he is a rarity. (* But Wu, since traveling to Japan in 1928 at the age of 14, has held the highest honor in Go, never faded in 30 years. He is truely a genius that would appear only once a few hundred years in Go history. *)] ;W[dc] C[(* Comparing with competitions in which outcome may be decided in a short burst or a split of second, a Go game takes much longer battles to yield a winner and a loser. This may have told us why Go players' professional careers are longer than that of other sports. *)] ;B[pq] C[(* After WWII, Kitani Minoru's records were down for a while, but since he was promoted to 9 dan last year \[1956\], his once unbeatable form appeared again. Recently he posted an astonishing record of 14 wins and 5 losses. In major tournaments like the Highest Rank Deciding Matches, Honinbo Matches, and Tokyo Newspaper sponsored Championship Matches, he all recorded triumphs. *)] ;W[oc] C[(* Is the once overwhelming "Wu-Kitani Era" re-emerging? Gradually recovered, rising giant Kitani Minoru, challenges Go Seigen for the first time in 13 years. This balanced struggle is indeed the most remarkable post-war battle since the Wu-Fujisawa 10-game series. *)] ;B[cp] C[This is the first game between Kitani 9 dan and me \[me = Wu\] after the War. Before the War, we had a 10-game series when we were 7 dans; later, we also played 4 games. I remember these 4 games were three games in the Grant Meet (Nihon Kiin's \[Japanese Go Association\] ranked players tournament) and one game sponsored by Yomiuri Newspaper. Finally in 1944 \[during the War, that is\], we met again in the ranked players tournament when we were 8 dans. This game now is my first against Mr. Kitani in 13 years.] ;W[po] C[This game is played in Tokyo Chiyoda District Kioi Street's Fukudake Inn on April 14-15, 1957. At the same time, the game between Sakata Eio 9 dan and Takagawa Honinbo 8 dan \[another of Strongest Deciding Matches\] is also held here. That game of theirs will end with Sakata 9 dan, playing Black, winning by 4 points.] ;B[pp] C[B #7 \[Q4\] is Kitani 9 dan's unique move; other players rarely play it, but Kitani 9 dan has used it a few times in openings like the 1-3-5 \[R16-Q3-C4\] of this game. B doesn't want to play B\[a\] so that W would play \[Q4\] to form the "avalanche shape", so \[Q4\] move applies the proverb "opponent's key point is also my key point."] LB[qo:A]; C[If W #8 extends downwards \[R5\] --- \[Press "shift+down arrow" to switch to this variation, then press "right arrow" to proceed down it.\] W #8 extending upwards is solid. ] W[oo]TR[qo] (;C[B #9 hane is big.]B[qo]; C[W #10 certainly. \[Switch to the variation to see a reference diagram.\] ] W[qn] (; C[B #11 --- \[The variation shows the result of playing at the marked point instead of s5.\] ] B[ro]TR[rp] (;LB[eq:A][iq:B] C[W #12 normally plays W\[a\]. Kitani 9 dan said in his post-game review that, if W\[a\], B had prepared to play B\[b\]. In the situation shown in this game, W #12 does have various ways to play.] W[qg];B[pe]C[B #13 of course.];W[qj]C[W #14 is also normal.];B[ep] C[B #15 is a big point on the board. Had #15 been played B\[a\], W would certainly ignore it \[tenuki\] and play W\[b\].] LB[rn:A][eq:B];W[cf] C[W #16 is also a big point that cannot miss. This point and B #15 \[E4\] are miai \[counterbalance moves of same weight\].] ;B[kc] C[B #17 is an extremely good point. Next move, W #18, is a difficult one. \[difficult to find a good spot, that is.\] \[The variation shows what Wu had in mind for a possible W #18.\] ] (; C[\[Instead,\] W adopted \[P15\] to attach. Next move --- \[Tha main line of play continues with black playing at "A". Switch to the variation to see what would have happened if black had played at "B".\] ] W[oe]LB[pg:A][of:B] (; C[So B simply presses at \[Q13\] is tesuji. \[The first variation explains more why B #19 shouldn't play at the marked point.\] How should W play next move #20? --- \[The main line continues with W playing at "A". Variations 2 and 3 show continuaitons where W plays at "B" instead.\] ] B[pg]LB[pd:A][pf:B]TR[of] (;C[\[Instead,\] W #20 to squeeze here is a good move.]W[pd]; C[B #21 certainly.]B[qe]; C[\[See variation 1 for what would have happened if W had played hane at the marked point instead of playing at P14.\] \[The main line of play continues with B playing at "A". Variation 2 shows what would have happened if B had played at "B" instead.\] So W #22 extends at \[P14\] is good. ] W[of]LB[pf:A][qh:B]TR[qc] (;C[Therefore, B #23 has no choice but \[Q14\].]B[pf];W[qc] C[W, as a result, gets #24 and ...];B[rc];W[qb] C[... #26 to settle down the corner. This local fight thus comes to a pause.] ;B[hc]LB[qh:A][ic:B] C[If B\[a\] for #27, that would be a good point too, but then W would certainly play W\[b\], and \[b\] is a point that cannot be missed. B #27 as played \[H17\] is an extremely big point.] ;W[qh] C[But then W gets #28 \[R12\] key point, and W is in a form to attack B.] ;B[og] C[If B #29 tenuki \[plays elsewhere\], W\[a\] and B big chunk is captured.] LB[nh:A];W[rn] C[W thus finally gets #30 \[S16\]. During this period of conflicts, B never got a chance to play \[S16\].] ;B[np]LB[nq:A][rq:B] C[B #31 is absolutely the only move. If B tenuki \[plays elsewhere\], when Wa\[O3\], B has to defend with Bb\[S3\]; letting W to seal B with sente is unbearable.] ;W[iq] C[W #32 --- \[The variation shows what would have happened if w had played at the marked point instead of J3.\] ] TR[oi] (;B[pi]LB[oi:A][qi:B] C[B #33 \[Q11\] on one hand prevents W\[a\] that was described previously \[see variation at move #32\], on the other hand aims at B\[b\] cut.] ;W[lq] C[If W #34 plays at the right side \[around R11\], it would be slow. \[The variation shows how W would handle it if B plays at the marked point now.\] ] TR[qi] (;B[mq] C[B #35's purpose --- \[The variation is a reference diagram that shows one of B #35's goals.\] Also... ] (;W[lp];B[no] C[...\[Also\] B now has #37 to get out, aiming at the marked cut at the same time. At this critical point, W made a mistake in the next move. W #38 \[W's next move\] --- \[Here w played at A. The variations show results of w playing at B -- that would have been correct.\] ] LB[nn:A][so:B]TR[pn] (;LB[mn:A]W[nn] C[In any case, #38 plays in a wrong direction \[summary of variations: here W should \[T5\] first\]. If W\[a\] next, it would *not* be a sente move, thus B wouldn't answer it. \[The variation shows why W "A" next will not be sente.\] ] (;B[qi] C[Because of W's mistake at #38 \[O6\], B finally gets sente, and with that, B cleverly turns to play \[R11\].] ;W[ri] C[If W can get sente here, W would have W\[a\]-B\[b\]-W\[c\] sequence to extend W's territory at the right side.] LB[ph:A][oh:B][oi:C];B[rj];W[rk] C[Had B #41 \[S10\] played \[a\] cut, W would have atari with \[b\]. With this kind of shape, "capture the cut stone" is common sense.] LB[rh:A][rg:B]; C[It would be awkward for B #43 to atari at \[a\], forcing W\[b\], then B\[c\] to get two W stones. \[Imagine, for example, after B\[c\], W plays \[Q10\].\]] LB[rh:A][sj:B][rg:C]B[pj]; C[W #44 however --- \[The variation shows the result of w moving at the marked point.\] ] W[sj]TR[qk] (;B[qk];W[rj]; C[To here, W is pressed to a low position. This is the fault of W #38 \[O6\]. Next --- \[The variation shows a reference diagram.\] Therefore, it has become an opening favoring B. ] B[pk]TR[mn] (;W[mc] C[If W #48 tenuki here --- \[The variation shows the result of a tenuki.\] ] (;B[fc] C[B #49 \[F17\] is very good. On first look \[a\] seems to be the real big point for #49. But if B\[a\], W will certainly presses at \[F17\]. Then the B teams at upper and right sides would yet have enough eyes, and with two "floating" teams, B would be difficult. Moreover, now with #49, B creates an opportunity for B\[b\] to attack W.] LB[ck:A][ce:B];W[ck] C[Since B gets \[F17\], \[C9\] big point is left for W.];B[gq] C[And then B #51 \[G3\] becomes clearly the next biggest point. B #51 could also consider to play at \[N6\] \[see an earlier reference at move #47\], but that would make it complicated, so B #51 "cashes in" with some territory first. \[I guess Wu is saying, since B is leading, no need for him to make it complex.\]] ;LB[mn:A][pm:B][pn:C][cm:D] C[W\[a\] for #52 is a correct \[text\] move, but if W does play \[a\], it would be no threat to B's corner \[see reference at move #38\]. Also, if W\[a\], B\[b\] to force W\[c\], and B\[d\] would give B a clear lead. Therefore, even though \[N5\] for W #52 is not solid, W doesn't have many choices. This is again the fault of #38 \[O6\]. W #52's purpose is to force B repond here, so W can get sente. If B ignores here --- \[Switch to the variation to see a reference.\] ] W[mo] (;C[Therefore, B #53 \[M2\] and ...]B[lr];W[kr]; C[...\[and\] #55 \[N2\] are necessary. In short, in order to get sente, W has to make a move like #52 \[N5\], although it would leave some weak point.] B[mr]; C[W #56 is the key point to attack. No matter what, if W doesn't stick with this B group, W will have no way to win. #56's purpose is to gain opportunities to protect the marked cut by attacking B team. Conversely, B can adopt two difference attitudes, either harder or softer, when he chooses his next plays. In short, this is the first crisis of the game. If B chooses the hardest way to play, that is --- \[Variation 1 shows the result of B playing at "B".\] Therefore, if B chooses the rough tactic shown above \[in variation 1\], it won't be satisfactory. I think if B plays at "C" \[variations 2 and 3\] would give W a headache. ] W[nj]TR[mn]LB[nk:A][pm:B][nl:C] (;B[nk]C[\[Instead,\] W adopted #57 and ...];W[mk];B[nl] C[...\[and\] #59. This is of course the most solid way to play, but ...] ;W[mj] C[...\[but\] after W #60 connects, W has somewhat achieved his goal of attacking B.] ;B[oj] C[B #61 --- \[The variation shown the result of black moving at the marked point.\] ] TR[on] (;W[so] C[W #62 is to gain with sente before sacrificing the marked stones. ] TR[oo][po];B[rq];W[ml];B[nm]; C[If W #66 connects at \[N6\] --- \[The variation shown the result of white moving at the marked point instead of N7.\] (* The big spot at the left side is the key point concerning the trend of both sides' growth. Here we can see how both sides deliberate intensively over this situation. *) ] W[mm]TR[mn] (;B[on];W[mn];LB[qm:A] C[To here, although W loses two stones, but he gets a spectacular outside thickness in *sente*. W has managed to gain back what he lost on #38 \[O6\]. After B #69, *if* W can gain with \[a\], seemingly a sente, then turn to left side, that would be even better for W \[than to turn to left directly\]. That is to say --- \[Variation 1 shows the result of white moving at A; it looks promising.\] \[Variation 2 shows that black has a way to be safe.\] ] B[pn] (;W[cn] C[\[So Wu said that \[R7\] wouldn't be a sente move for W now. I thought, "Hey, why bother? \[C6\] is big, get it first anyway." But the fact is, in this level of games, *every* point is important. If one passes by a sente move, it could be not sente later.\] Anyway, W finally gets the chance to occupy the big spot at \[C6\], and thus escapes from the previously disadvantageous situation. At the right side, if B\[a\], W\[b\] cut would take care of it.] LB[rl:A][ql:B];B[qm] C[Since W got the big spot at the left edge, letting B to gain here with #71...] ;W[rm];B[ql]C[...and #73 is unavoidable.];W[rl];B[co] C[B #75 is the way to solidify the corner. Of course, even if B doesn't play this move, the corner has no problem for now. But later, when the outside situation changes, then there is a possibility that W will cast in W\[a\]. So B #75 now to prevent it.] LB[er:A];LB[dn:A][bq:B][bp:C][er:D] C[White #76 extending downwards decides the growth of both sides' territory. White extending upwards would be yielding and passive. Also, White #76 aims at white B, black C, white D. \[The variation shows what happens if black tenukis and white plays B.\] ] W[bn] (;C[B #77 is long-waited severe tesuji.]B[ce]; C[W #78 absolutely *cannot* play at the marked point to give in. ] W[de]TR[cd];B[cd]; C[W #80 to connect is a strong move. This move --- \[The variation shows the result of white playing at the marked point instead of at D14.\] ] W[df]TR[dd] (; C[B #81 --- \[The variation shows the result of black playing at the marked point instead of D16.\] ] B[dd]TR[cc] (;W[ed]; C[Since white #82 blocked, B #83 of course has no choice but to cut, looking forward to a deciding fight. ] B[ec]TR[ed];C[W #84, too, is the only move.]W[cc];B[bc];W[bb]; C[B #87 --- \[The variation shows the result of black connecting at the marked point instead of playing at B14.\] ] B[bf]TR[bd] (;W[bg] C[White #88 --- \[The variation shows the result of white peeping at the marked point instead of playing B13.\] ] TR[ad] (;B[bd] C[B #89 only move. Next if W\[a\] hane --- \[The variation shows why white playing hane at "A" would not work.\] ] LB[ac:A] (;W[af] C[W #90 no other choice. If --- \[A variation was shown in the comments of move #89.\] \[The variation shows the result of white playing at the marked point instead of A14.\] ] TR[ab] (;B[ab]; C[If W\[a\] connect for #92 --- \[The variation shows the result of white moving at "A" instead of B19. This leads to a ko, like the move that white made in the game, but the ko in the game is easier for white.\] ] LB[cb:A]W[ba] (; C[B #93, and the huge ko that would determine the result of this game has started.] B[ae];W[be];B[ee];W[fd]; C[After B #97, W can't find an appropriate ko threat anywhere on the board, how to save such a dangerous situation?] B[bf]; C[Under the current circumstances, W #98 is the choice when there's no choice.] W[ag];B[eb];W[cb]; C[B #101 cuts directly. Good. This move --- \[*** 'B' to see a variation.\]] B[cg] (;W[gd] C[W #102. This point absolutely cannot be passed by. If W\[a\] for #102, B would follow with \[G16\], and that's a ko threat for B.] LB[be:A];B[bh] C[B #103 to pull these few stones \[W \[A13\] etc.\] into the ko is rather unexpected. This this the second crisis of the game. \[The first was back at move #56.\] (* Later there will be detailed analysis for B #103. (* As for this ko, what are the best moves? Please study it by yourself, then compare your conclusion with B #103. *)] ;W[be];B[rf] C[B #105 threatens a W team that is worth about 50 points. (* W to answer a move here seems to be unquestionable, since it's hard to imagine that W would sacrifice such a big group. But Go Seigen 9 dan's strategies are often unexpected --- *)] ;W[ad] C[W #106 unhesitatingly finishes the ko. \[He did! I couldn't believe it. :)\]] ;B[sh] C[B #107, and the right W team is dead. However, I think with the moyo at the middle, W has more than enough to compete with B. Therefore, B #103 \[B12\] was a questionable move. In this picture, W G16 \[marked\], extending out, gave W's central moyo a big boost in thickness. So B's best policy at this point was to shift the emphasis to the middle, damaging W's attempt to control the center. Consequently, B #103 should play as the following. \[*** 'B' to see reference 1.\] \[*** 'C' to see reference 2.\]] MA[gd] (;LB[ie:A][ic:B][jf:C][ig:D] C[W #108 wrong order. Before this, W should play W\[a\], forcing B\[b\], *then* jump at \[a\]. Afterwards if B\[c\] to do a shallow invasion, W\[d\] to fence. This way, from the global point of view, it's a better trade for W. Also, when W\[a\], if B doesn't play B\[b\] but jumps at \[a\] --- \[*** 'B' to see a reference.\]] W[en] (; C[Although B #109 is a correct move \[under normal circumstances\], under the current situation, W is better to adopt the following play. \[*** 'B' to see this variation.\]] B[hd] (;W[he];B[ge] C[If B\[a\] for #111, it would just help W to get \[b\]. B #111 cuts is to apply here some techniques directly, looking for some chances to turn it around.] LB[ie:A][if:B];W[ie];B[fe];W[ac] C[Next \[B #115\] --- \[*** 'B' to see a variation.\]] (;C[B #115 too deep. Since B has gone so deep into W's zone...]B[ej]; C[...W #116 has no choice but to surround B and try to kill.]W[gj]; C[B is better to play \[a\] for #117. Then if W\[b\], B\[c\] to seek a living path in another direction.] LB[gh:A][fi:B][ig:C]B[el]; C[This B #117 and W #118 exchange \[E8-F7\] is worth a reconsideration \[by B\]. Since inside the influence of W thickness, B #117 could easily lead himself to a trap that he cannot escape. Besides, after W plays #118, when B later tries to invade from the bottom, it will be different. \[It's harder for B to invade from the bottom now, clearly.\]] W[fm]; C[(* Since it has developed to this situation, the only way for B to win is to desperately find a way to save this team. (* On the other hand, if W fails to capture B, W would lose. Therefore W has no choice but to fight his hardest. It's make-or-break. As shown, an inspiring and heartbreaking fight has begun. *)] B[gh]; C[Kitani 9 dan's given time has completely consumed \[each player is given 10 hours; Kitani's clock should show 9 hours 59 minutes, saving the last minute for byo-yomi\], and he doesn't have sufficient time to deliberate.] W[fi];B[eg];W[fh];B[fg];W[hg];B[gg];W[hh];B[fl] C[If B #127 plays at \[a\], W would counter with \[b\]. Even if W let B run away towards center, W's right side has a metal-solid wall, and B eventually cannot escape.] LB[gk:A][gi:B];W[di];B[cj];W[dh] C[When W #130, if B\[a\] --- \[*** 'B' to see this variation.\]] LB[gm:A] (;B[cl];W[dk];B[dl];W[do];B[dj];MA[dk][do] C[(* W #132-#134-#136 \[D9-D5-B9\] are related tesuji. After #134 \[D5\], B's \[lower left\] corner becomes shaky. *)] W[bk];B[gi];W[fj];B[ek];W[bl];LB[dp:A] C[(* The middle-game fight has come to a most critical point. It's such a close and intense melee at the center, B has no chance to defend the weakness at \[a\]. *)] B[hi];W[dg];B[ji];W[jd] C[If B ignores W #144, W\[a\] would be unbearable. No matter how urgent the situation at the center is, B has to answer here a move.] LB[jc:A];B[jc];W[kh];B[jh] C[(* Now every move by Kitani 9 dan is under the sound of byo-yomi. *)] ;W[kf];B[hj];W[hl];B[il];W[im] C[(* Starting from B #115 \[E10, the move that Wu commented as "too deep"\], it has been Kitani 9-dan's unqiue "invading strategy." Often this strategy \[to let opponent form a big frame, then to live a group in this frame\] would terrify the opponent... *)] ;B[hk] C[(* ...However in this game, W's zone is as solid as a flawless castle, and it's really hard for B to achieve what he has looked for. Besides, Kitani 9-dan is now short of time, which puts him at a more disadvantageous position. *)] ;W[hm];B[lh];W[ki];B[kg];W[lg];B[jg]; C[When W #160, if B tries B\[a\]-W\[b\]-B\[c\] to make an eye, then W would adopt the techniques shown in the following reference diagram to destory B's \[other\] eye at the bottom \["bottom" here is meant to be around \[K10\]\]. \[*** 'B' to see this reference.\]] W[le]LB[gf:A][hf:B][ef:C] (;B[kj];W[li];B[jk];W[hf] C[W #164 connects to destory the eye at \[a\] is the safest way. Thus, no matter how B struggles, B cannot live now. (* If W #164 carelessly atari at \[b\] --- *) \[*** 'B' to see this variation.\]] LB[ff:A][jl:B] (; C[Total of 164 moves. W wins by resignation. Time given: 10 hours apiece Time consumed: Black: 9 hours 59 minutes White: 6 hours 26 minutes \[*** END OF THE GAME ***\]]) (;W[jl]AE[hf]Name[variation]C[(* If W hastily atari at \[K8\]...*)]; B[ih]C[(* B \[J12\] (sente)... *)];W[hf];B[ij] C[(* ...and B \[J10\] makes a ko. *) \[*** end of variation.\] \[*** '\[' to continue.\]]) ) (; Name[reference]C[\[Suppose after W \[M15\]...\]];B[gf] C[\[B \[G14\]...\]];W[hf];B[ef]C[\[...and \[E14\] to make an eye...\]] ;W[jl]C[...when W \[K8\] hane...];B[ik]C[...B \[J9\] connects...]; W[jj] C[...W \[K10\] to deprive an eye from B is a severe tesuji. With this move, the chances for B to live become slim. ... ...] ;B[kj]C[...then if B \[L10\]...];W[li];B[jk]C[...and \[K9\]...];W[kk] C[...W \[L10\] is another fatal blow...];B[ij];W[ih] C[...W \[J12\] denies another eye for B...];B[kl] C[...even if B \[L8\]...];W[lk];B[jm] C[...and \[K7\] to capture a W stone...];W[io] C[...W \[J5\] jumps, and B is still not alive. \[Blood!\] \[*** end of reference.\] \[*** '\[' to continue.\]]) ) (; Name[variation \(B #131\)]C[\[After W \[D12\]...\]];B[gm] C[\[If B \[G7\] hane...\]];W[gn];B[em];W[fn] C[After W \[G6\] and \[F6\]...];B[dn]C[...even if B cuts at \[D6\]...] ;W[dm];B[do];W[dl];B[dj];W[bj] C[W has \[D7\], \[D8\], and \[B10\] to live at the bottom. Then...]; B[hn]C[...if B \[H6\] hane...];W[ho] C[...W \[H5\] also hane, and it works. The result: B is unsuccessful. \[*** end of variation.\] \[*** 'g131' to continue.\]]) ) (; Name[variation \(B #115\)] C[\[After W \[A17\] capturing B stones...\]];B[hh] C[If B \[H12\] and...];W[jh];B[fg] C[...\[and\] \[F13\], this would become a large-scale death-life problem. To live inside W's surronding stones is probably quite difficult, and in fact, under this situation, even if B doesn't try to struggle to live here, he could instead invade from the lower side to somewhat damage W's territory -- and that could be enough. But to give up the upper portion is a difficult decision to make, since it's difficult to be sure that B would gain enough from below. \[*** end of variation\] \[*** 'g115' to continue.\]]) ) (;B[ie]AE[hd]Name[variation]C[B \[J15\]...];W[jd];B[jc]; C[...W probably would play \[H14\]...]W[hf];B[he];W[gf]; C[...B has \[K13\]...]B[jg];W[ih];B[fn];W[fm]; C[Then \[F6\] and \[G6\] to reduce W territory...]B[gn];W[eo]; C[...to here, B should be quite content with this picture. Besides, the B territory at upper side is also increased. Hence, \[J15\] was the key point that neither side should miss. \[*** end of variation.\] \[*** '\[' to continue.\]] B[fp]) ) (;C[\[Say when W \[J15\], B responds with \[E6\]...\]]AB[en]AW[ie] Name[reference];C[W has \[J18\] tesuji...]W[ib];B[ic];W[jb];B[kb]; W[jc];B[jd];W[hb];B[gc]; C[...to here, it's difficult for this B team to live. \[*** end of reference.\] \[*** '\[' to continue.\]] W[kd]) ) (; Name[reference 1 \(B #103\)]AE[sh][rf][be][bh][ad]AB[bf][ae] C[Back to the situation after W #102 \[G16\].];B[hd]LB[bh:A] C[That \[Wu's opinion on B #103\] is, B doesn't play \[a\], but instead to rise at \[H16\]. ] ;W[be]C[When W \[B15\] captures...];B[sh] C[...B \[T12\] threats. (If W\[b\] now to finish the ko, B would play \[S14\] to kill W's team. But this \[situation\] is different from the actual game. The B\[a\] move in actual game is now at \[H16\] key point, and B is clearly better \[if W continues with the way he played in actual game -- \[A16\] finishes the ko and sacrifices team at right\].) ...] LB[bh:A][ad:B];W[rf] C[...so W \[S14\] has to answer the threat of \[T12\]...];B[bf] C[...B captures...];W[dg] C[...when W \[D13\]... \[There is a variation for this move shown in reference 2.\]] ;B[re]C[...B forces another W move here...];W[sg];B[ge] C[...then from \[G15\] to...];W[fe];B[ff];W[ef];B[gf] C[...\[to\] \[G14\]...];W[be];B[gc];W[ee];B[bf];W[ch] C[...after W \[C12\] captures one B stone...];B[dn] C[...B \[D6\] hane...];W[dm];B[en] C[...and \[E6\] extends. Later W needs two moves to clean up the \[upper left\] corner. This way, W's moyo is greatly shrunken. \[*** end of reference 1.\] \[*** '\[' to get back to see reference 2.\]]) (; Name[reference 2 \(B #103\)]AE[sh][rf][bh][be][ad]AB[ae][bf] C[\[Again, after W \[G16\]...\]];B[hd] C[\[The first few moves are the same as reference 1.\]];W[be];B[sh]; W[rf];B[bf];W[ad] C[Here, if W throws in at \[A16\] \[in reference 1, it's played at \[D13\].\]...] ;B[ac];W[be];B[re];W[sg];B[bf];W[om];B[op];W[be];B[pc];W[ad];B[od]; W[aa];B[nd] C[...to here, it becomes a big exchange. B is still better. \[*** end of reference 2.\] \[*** '\[' to continue.\]]) ) (;B[gd]AE[cg]Name[variation]C[If W \[G16\] atari instead...]; C[...after W \[F15\]...]W[fe];C[...*then* cuts at \[C13\]...]B[cg]; W[be];B[rf];W[rg];B[bf];W[dg];B[ch];W[be];B[ff];W[ge];B[bf];W[hd]; B[gc];W[be];B[he];W[gf];B[bf];W[hf];B[bh];W[be]; C[When B \[T13\] to threat...]B[sg]; C[...W would decide to finish the ko!...]W[ad]; C[...when B \[T12\] to kill the big W team at the left...]B[sh]; C[...W \[F6\] big jump and with the huge moyo at left, although W sacrificed a big team at left, he has enough to counter B. \[The key that W *could* sacrifice a huge team at rigth is that W's upper left is now very thick, thus his huge moyo looks very promising.\] \[*** end of variation.\] \[*** '\[' to continue.\]] W[fn]) ) (;W[cb]AE[ba]Name[variation];B[ba];W[ca]; C[...it's a ko. \[*** end of variation.\] ]B[da]) ) (;W[ab]AE[af]Name[variation]C[If W \[A18\] sagari...];B[cg] C[...after B cuts here \[C13\]...];W[bh];B[ee];W[fd];B[ef];W[dg];B[ge] C[...two marked white stones are captured. \[*** end of variation.\] ] TR[ed][fd]) ) (; Name[variation \(W #90\)]C[\[After B \[B16\]...\]];W[ac] C[If W \[A17\] hane...];B[ab];W[aa];B[ae];W[ch];B[db];W[cb];B[eb]; W[ag];B[af];W[ca] C[...to here, W makes it seki in *gote*. W loses big. \[*** end of variation.\] ]) ) (;W[ad]AE[bg]Name[variation]C[If W \[A16\] peeps...];B[be];W[bg];B[ab] ;W[bd];B[db]C[... ...];W[cb];B[ca];W[ac];B[ba] C[...to here it's a ko...];W[aa] C[...when W A19, B has a big ko threat in "A" at the right side. W thus fails. \[*** end of variation.\] ] LB[rf:A]) ) (;B[bd]AE[bf]Name[variation]C[If B connects...];C[W \[A17\] hane...] W[ac];B[bf];W[ad];B[be]; C[...to here, B is killed. \[*** end of variation.\] ]W[bg]) ) (;B[cc]AE[dd]Name[variation] C[If B choose to live the corner with \[C17\] and \[B14\]...];W[ec]; B[bf];W[bg];B[be]; C[...after W \[F16\] hane, W is thick, and it's no good for B. Also, when time comes, W would have W\[a\]-B\[b\]-W\[c\] to force a ko. \[*** end of variation.\] ] LB[cb:A][bb:B][ba:C]W[fd]) ) (;W[dd]AE[df]Name[variation]C[If W connects here...]; C[...B would use \[B14\] to...]B[bf];W[bg];B[cg];W[df];B[bh];W[be]; C[To \[A13\]. After sacrificing the marked stones... ]B[ag]TR[ce][cd] ;W[bd];C[...W's center moyo is gone. \[*** end of variation.\] ]B[dj]) ) (;C[\[W \[B6\] aims at \[B3\]...\]]Name[reference]; C[\[When W \[B3\]...\]]W[bq]; C[If black blocks at \[C3\] \[instead of \[B4\] shown in the main branch\] ... ] B[cq];C[...W \[B4\] up to...]W[bp];B[bo];W[ao];B[br]; C[...\[up to\] \[A2\] are extremely big ending moves. \[*** end of reference.\] ] W[ar]) ) (;C[\[When B \[Q6\]...\]]Name[reference 1]; C[Suppose W plays \[R7\] to force B to respond...]W[qm]; C[...but B ignores (tenuki) and plays \[C7\], the big point at left side...] B[cm];C[...say W would then \[P7\]...]W[om];B[op]; C[...and \[Q7\], seemingly to capture the big B team at upper-right. However --- \[Back up to the start of the variation and try variation 2 to see how black would save his group.\] ] W[pm]) (;AB[cm][op][pn][on]AW[qm][om][pm] C[\[This is the continuation of reference 1 --- \[Suppose W just played \[Q7\]. The upper-right B team seems to be in great danger...\]] Name[reference 2]AE[oo][po]CR[pm];C[B has \[S14\]...]B[rf];W[rg];B[rb] ;W[ra];C[...and \[Q12\]...]B[ph];W[nh];B[ng]; C[Although W has \[O12\] and \[M14\] to deprive B's eyeshapes while attacking...] W[lf];C[...but B has \[T14\], and \[you must see this :-)\]...]B[sf]; W[sb];B[sd]C[\[Here is one eye...\]];W[re];B[sh];W[sg]; C[...\[S8\]!!...]B[rl];W[ql];C[...and \[T8\]!!...]B[sl];W[sm];B[qf]; W[rh]; C[...and \[P8\] makes a second eye! \[first eye at \[S15\]\] This way, not only B lives here completely, also he already gets the big point \[C7\] at the left. Therefore, W's hope to gain with sente at \[R7\] \[consult main branch\] is invalid. \[Here are some explanantions of \[S8\]\[T8\].\] (* The beauty of \[S8\]\[T8\] is that they prevent W to place a stone at \[Q8\]. If W does play \[Q8\] \[trying to deprive the eye at \[P9\]\], W's whole team is demolished. *) \[I almost missed it! :-) Indeed, if W \[Q8\] and B \[P9\], then W will be unable to atari \[S8\]\[T8\] stones -- either \[T9\] or \[S7\] would be "suicide." \[S8\]\[T8\] are "standing roosters."\] \[*** end of reference.\] ] B[ol]) ) (;W[mn]AE[mm]C[If W \[N6\] connects...];C[...after B \[Q7\] peep...] B[pm];C[...W \[Q6\] connects...]W[pn]; C[...B gets the big point at the left. Besides, W leaves a leak at \[N7\]. Thus this W shape is thin. \[*** end of variation.\] ] B[cm]) ) (;B[on]AE[oj]Name[variation] C[A cut at \[P6\] by black would start a large-scale battle... ];W[om] ;B[mn];W[nm];B[ml];W[mm];B[ll];W[ph];B[oh];W[oi];B[li];W[nh];B[ng]; W[mh] C[...to here, the situation is quite complicated; the outcome is hard to predict for B. \[So black chose to play \[P10\] instead of a fierce cut at A.\] \[*** end of variation.\] ] LB[on:A]) ) (;C[\[Assume B is to adopt the hardest tactic against W \[O10\]...\]] Name[variation 1 \(B #57\)]CR[nj];C[B \[Q7\] peeks...]B[pm];W[pn]; C[...\[O9\] touches...]B[nk];W[mk];C[...\[N8\] hane...]B[ml];W[nl]; B[nm];W[ok];C[...however, after B \[P8\] atari...]B[ol]; C[...W can struggle with \[N7\] to force a ko...]W[mm]; C[...after B \[O9\] to take the ko...]B[nk]; C[...W has a ko threat at \[P4\] \[assumably more to come\]...]W[op]; C[...so B has to atari first, then...]B[lm];W[mn]; C[...connect to finish the ko...]B[nl]; C[...then W gets \[P3\] up to...]W[oq];B[or];W[nr];B[pr]; C[...\[up to\] \[O3\]. Thus both sides made an exchange. Since W can next get either \[a\] or \[b\], this result is good for W. For example, if B plays S3 next to protect the corner, W can play W\[b\]-B\[c\]-W\[d\] "double hane", and B's thickness formed by \[O8\] \[the move that connected the ko\] is gone. Or, say B ignores the corner and play at the top \[around O13\], what would be the result? --- \[Continue to see reference\] \[Conclusion, W is better\] \[*** end of variation 1.\] ] LB[rq:A][ng:B][nh:C][mh:D]W[nq]; C[\[Say B ignores the corner and plays around \[O13\]...\]] Name[reference];C[W tosses in a stone at \[S3\]...]W[rq];B[rr];W[rp]; B[qq];W[qp];B[sq];W[so]; C[...to here, although B is not really killed, but letting W to eat two stones \[previously at R5-S5\] in *sente* is a big loss. \[*** end of reference.\] ] B[qs]) (;C[\[After W \[O10\]...\]]Name[variation 2 \(B #57\)]CR[nj]; C[B \[O8\] \[= headache :-)\]...]B[nl];C[...if W \[Q12\] and...]W[ph]; B[oh];C[...\[and\] \[P11\] to cut...]W[oi];C[...B \[O11\] to...]B[ni]; W[oj];B[mi];W[mj];B[lj];W[mk];C[...\[to\] \[N7\] peek and...]B[mm]; W[lk];MA[ph][oi] C[...\[and\] \[N6\] cut, W would be farily thin. So W can't hastily cut with \[Q12\] and \[P11\] \[marked stones\]. (After this shape, if W\[a\], B would of course give up the five stones. \[Q9 five stones\]) ] LB[ok:A]B[mn]) (;C[\[Again, after W \[O10\]...\]]Name[variation 3 \(B #57\)]CR[nj]; C[When B \[O8\]...]B[nl];C[...if W \[P8\] to separate...]W[ol]; C[...B starts with \[P7\] up to...]B[om];W[pl];B[nm];W[ql];B[ni];W[mi] ;B[nh];W[mn];B[nk];W[ok];B[mj];W[oj];B[li];W[mk];B[lj];W[lk]; C[...\[up to\] here, B sacrifices four stones \[O8 team\], but...] B[kk];W[ll]; C[...\[but\] B gets the big point at \[C7\], and it's an easy situation for B. \[Conclusion: like in variation 2, B comes out better with \[O8\] -- after W \[O10\].\] \[*** end of variation 3.\] ] B[cm]) ) (;C[\[Assume B ignores W \[N5\]...\]]Name[reference]; C[W has \[S3\] peek...]W[rq];C[...when B connects...]B[qp]; C[...W \[O2\] another peek. \[Wu didn't explain further. The way I see it, W now has either \[N2\] or \[P4\], plus the "bomb" at \[S3\], it *is* a headache to B.\] \[*** end of reference.\] ] W[nr]) ) (; Name[reference]AE[mc]C[\[Suppose W doesn't play N17...\]];B[nd] C[B immediately peeks at O16...];W[od];B[nc] C[...and blocks with O17. These two moves \[O16-O17\] concern the base of both sides; extremely big. \[*** end of reference.\] ]) ) (;C[\[B can start an attack...\]]Name[reference];C[\[...with N6...\]] B[mn];W[nm];B[pm];W[pn]; C[To here, although B doesn't quite separate W groups, B is now able to attack this big W team when time comes. \[*** end of reference.\] ] B[rl]) ) (;Name[variation]C[If W connects directly at \[R9\]...]W[qk]AE[sj] AW[qk]AB[rj];C[...B *would* get the two W stones...]B[rh];W[sj]; MA[pj][qk] C[(* In other words, it's a big difference between with or without B \[Q10\] forcing W \[R9\]. *) \[So W \[R9\] should \[T10\] capture directly, which W did for his #44.\] \[*** end of variation.\] ] B[rg]) ) (; Name[reference]AW[mn] C[\[Suppose W has played \[N6\] and B ignores it (tenuki)...\]]CR[mn]; W[rq]C[If W \[S3\] and ...];B[qp];W[qr]C[...\[and\] \[R2\]...];B[pr] C[...B plays \[Q2\] and there is no play at the corner. \[Therefore, \[N6\] is not sente.\] \[*** end of reference.\] ]) ) (; Name[variation 1 \(W #38\)]C[\[After B \[O5\] ...\]]CR[no];W[so] C[W hane sente to gain (this play's purpose is to sacrifice \[P5\]\[Q5\] \[marked\] two stones when B cuts at \[Q6\])...] MA[oo][po];B[rq];W[qk]C[...then extend at \[R9\], and W is settled.]; B[pn]C[If B cuts now...];W[pm];B[on];W[om] C[...W \[Q7\] and \[P7\] to sacrifice two stones...];B[nn];W[fq] C[...then turn to \[F3\], an extremely good point...];B[eq];W[er]; B[dr];W[fr] C[...this way, W gains a good deal. W is advantageous, needless to say. In order for B to avoid this... \[see variation 2 (get back to main branch first)\] \[*** end of variation 1.\] ]) (; Name[variation 2 \(W #38\)]C[\[Now look at another variation ...\]] CR[no];W[so]C[\[W still \[T5\]...\]];B[rq];W[qk] C[\[...to here is the same as variation 1...\]];B[gq] C[B, instead of cut \[Q6\], plays \[G3\] here...];W[nn] C[...then W \[O6\] and...];B[mn];LB[ng:A]W[nm] C[...\[and\] \[O7\] are appropraite moves. Now, W\[a\] becomes a severe attack. \[This is the end of the variation; continuing will show why W "A" is a good attack\] \[*** end of variation 2.\] ] ; Name[reference]C[\[Let's see what if W gets chance to play O13...\]] ;W[ng];B[nh];W[mh];B[mg];W[nf];B[ni];W[oj]C[\[*** end of reference\] ]) ) (; Name[reference]AE[mq]C[\[Imagine B is without \[N3\] ...\]];W[op]; B[oq];W[nq] C[W can \[P4\] and \[O3\] to cut. \[This shows the importance of #35 \[N3\] that B played.\] \[*** end of reference.\] ]) ) (; Name[variation \(B #35\)]C[\[After W \[M3\]...\]]CR[lq];B[qi] C[If B pushes and cuts...];W[ri];B[rj];W[rk] C[W would atari from this side \[S9\], sacrificing the two stones \[R12 and R13\] above. \[*** end of variation.\] ]) ) (;AW[oi]AE[iq]Name[variation] C[If W plays \[P11\] to exchange with B \[N13\]...]CR[oi];B[mg];W[iq] C[*Then* W plays \[J3\]...];B[nd];W[od];B[nf] C[B would have \[O16\] peep and \[O14\]. Now B's both sides are settled, and B becomes thicker. \[*** end of variation.\] ]) ) (;AW[qc]AE[of]Name[variation]C[\[If W chooses \[R17\]...\]]CR[qc]; B[of];W[ne];B[rc];W[qb]; C[When B \[R12\] captures one W stone, B gets a good shape. \[*** end of variation.\] ] B[qh]) (;C[After W \[P14\]...]Name[variation \(B #23\)]CR[of]; C[If B still wants to capture one W stone with \[R12\]...]B[qh];W[qc]; B[rc];C[...W would have \[R17\] and \[S18\] double hane...]W[rb];B[qb] ;W[pc];B[rd];W[ic];B[ke]; C[...W first gains with \[J17\] and \[J15\]...]W[ie];B[kg]; LB[rg:A][rh:B][ph:C] C[...then settles the corner with \[T18\]. This way, W is better. Besides, after this shape, W also has aji of W\[a\]-B\[b\]-W\[c\], aiming to reduce B's liberties from outside, thus sealing B inside. \[*** end of variation.\] ] W[sb]) ) (;AB[pg]Name[reference] C[\[Here is more reason why \[P14\] instead of \[Q13\] for B #19 would be wrong.\]] ;W[qf];LB[of:A][ne:B] C[Think of this W \[R14\] and B \[Q14\] exchange. If B played #19 at \[P14\] as shown in the previous variation diagram \[at move #18\], it would be like B now does an exchage of B\[a\] and W\[b\] \[which is clearly bad\]. That's why \[Q14\] for B #19 would be wrong. \[*** end of variation.\] ] B[pf]MA[qf]) (; Name[variation 1 \(W #20\)]C[\[After B \[Q13\]...\]]CR[pg]; C[W \[Q14\] to wedge in seems to be severe, but will it have a satisfactoy result?] W[pf];B[of];W[qf];C[\[P16\] atari to get out is a mediocre move.]B[od] ;W[ne];B[nd];W[me];B[md]; C[It's certain to get here. This way, not only W enlarged his moyo to the biggest extend, but also W left some aji at \[a\]. If so, W is of course better. However --- \[*** variation 3 shows why W \[Q14\] wouldn't work this nicely.\] \[*** end of variation 1.\] ] LB[pc:A]W[le]) (; Name[variation 2 \(W #20\)]C[\[Again, after B \[Q13\]...\]]CR[pg]; C[When W \[Q14\]...]W[pf]; C[B simply \[P16\] to wedge in is tesuji. Then if W\[a\], B\[b\]. This exchange would be in favor of B. So W \[Q14\] \[for #20\] is not good. \[*** end of variation.\] ] LB[of:A][nd:B]B[od]) ) (; Name[variation \(B #19\)]C[\[After W \[P15\]...\]]; C[If B \[P14\] hane...]B[of];C[W would happily extend at \[O15\]...] W[ne];B[pg];W[qf]; C[It ends up with this shape; clearly, \[P14\] for B \[#19\] would be a mistake. \[There is another explanation why \[P14\] would be wrong; see the reference at move #19.\] \[*** end of variation.\] ] B[pf]) ) (; Name[variation \(W #18\)]C[\[Wu says...\]];W[mc] C[W had considered to play \[N17\] jump...];B[pc] C[Then B would certainly play \[Q17\]...];W[ic] C[After that, if W \[J17\] to press...];B[ke];W[me];B[ie];W[gd];B[lg] C[We can then imagine a picture up to here. W would look thin, so I didn't adpot this way to play. \[*** end of variation.\] \[*** 'g18' to continue.\]]) ) (;AB[rp]AE[ro]Name[variation]C[If B plays \[S4\]...]CR[rp];W[ro]; C[The leak of W to the right is almost covered, so B \[S4\] is not as good as \[S5\], the way actually played. \[*** end of variation.\] \[*** '\[' to continue.\]] B[qp]) ) (;AE[qn][qo][po][oo][pp]Name[reference] C[\[Japanese editor, Mr. Katsumoto, gives us another angle to look at the way two players have played the corner so far.\]] ;C[\[This is a joseki.\]]W[po];B[qo];W[pn];B[pp];W[qn]; C[(* The way two players have played so far is similar to this joseki. *) \[*** end of reference.\] ] B[ro]) ) (; Name[variation]AW[qo]AE[oo] C[\[If W extends with \[R5\] instead...\]]CR[qo];B[oo];W[on];B[no]; W[nn]; C[The sequence to here would be certain. Not only B will have a peek at B\[a\] (followed by W\[b\] connecting and B\[c\] extending), W's \[P6\] and \[O6\] playing on line 6 is also unsatisfactory. \[*** end of variation.\] \[Press "shift+left arrow" until you are at the start of the variation, then press "shift+up arrow" to return to the main line of play.\] ] LB[pm:A][pn:B][qm:C]B[mo]) ) cgoban-1.9.14/bootstrap0000775000671000067100000000062307502174653010501 #! /bin/sh echo "calling aclocal..." # aclocal creates aclocal.m4 aclocal echo "calling autoheader..." # autoheaders creates config.h.in autoheader echo "calling automake..." # automake creates a Makefile.in for every Makefile.am automake echo "calling autoconf..." # autoconf creates the configure script autoconf echo "cleaning config.cache and config.status..." rm -f config.cache config.status cgoban-1.9.14/cgoban1.spec0000664000671000067100000000567207606355053010735 %define name cgoban %define version 1.9.14 %define release 0.3 %define realname cgoban1 # This is for debug-flavor. Do not remove. Package is stripped conditionally. # %define __os_install_post %{nil} # %{expand:%%define optflags %{optflags} %([ $DEBUG ] && echo '-g3')} Summary: cgoban is an X board for playing go Name: %{name} Version: %{version} Release: %{release} Group: Graphical desktop/Other License: GPL URL: http://cgoban1.sourceforge.net/ Obsoletes: %{name}-1.9.13 BuildRequires: XFree86-devel BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} Source: http://prdownloads.sourceforge.net/cgoban1/%{name}-%{version}.tar.gz %description Cgoban (Complete Goban) is for Unix systems with X11. It has the ability to be a computerized go board, view and edit smart-go files, and connect to go servers on the Internet. %prep rm -rf $RPM_BUILD_ROOT %setup -q %configure %build make %install rm -rf $RPM_BUILD_ROOT mkdir $RPM_BUILD_ROOT chmod 777 $RPM_BUILD_ROOT make install prefix=$RPM_BUILD_ROOT/usr mandir=$RPM_BUILD_ROOT/usr/share/man bindir=$RPM_BUILD_ROOT/usr/bin mv $RPM_BUILD_ROOT/usr/bin/%{name} $RPM_BUILD_ROOT/usr/bin/%{realname} # mkdir $RPM_BUILD_ROOT/usr/share mkdir $RPM_BUILD_ROOT/usr/share/pixmaps cp cgoban_icon.png $RPM_BUILD_ROOT/usr/share/pixmaps mkdir $RPM_BUILD_ROOT/etc mkdir $RPM_BUILD_ROOT/etc/X11 mkdir $RPM_BUILD_ROOT/etc/X11/applnk mkdir $RPM_BUILD_ROOT/etc/X11/applnk/Games cat >$RPM_BUILD_ROOT/etc/X11/applnk/Games/%{realname}.desktop < 1.9.14-0.2 - latest dev build - tested rpm spec on RHL 7.x * Thu Oct 25 2002 Kevin Sonney 1.9.14-0.1 - version jump - remove patches - modify .spec to be included in mainline cgoban1 distribution * Mon Oct 22 2002 Kevin Sonney 1.9.12-0.4 - change desktop/menu entry description * Mon Oct 21 2002 Kevin Sonney 1.9.12-0.3 - rename binary to cgoban1 - added desktop entry for gnome * Thu Aug 22 2002 Kevin Sonney 1.9.12-0.2 - Better patch to Makefile.in - still needs porting to the new autoconf - can now use %configure macro - clean out fluxbox comments form my template .spec file - bad hacks for man pages & doc lcoations * Thu Aug 22 2002 Kevin Sonney 1.9.12-0.1 - Initial Spec File - lots of fixes to the spec to get it to build right as an RPM - patched the Makefile.in to correct autoconf error - needs porting to the new autoconf # end of file cgoban-1.9.14/cgoban_icon.png0000664000671000067100000000352607556057526011522 ‰PNG  IHDR00Ø`nÐ pHYs  ÒÝ~ütIMEÒ  (×JjõIDATxœí˜iTSgÇŸl’ö%MYŽK¨Y‚kUªíXªÅ½ŽGªèÑ鈠€Ô™92spafzœ*¶´ÚS¤‡ºLi\X‚C [d,` $Ääf%ˉ—ĆoÓùÊýßÿûÜßûÜ7ï½çâP…_“ðÿo{¹\É äJn Wr¹’È•~Å@•Ôl6Î}¤F­?¶3''ú.~zö§ÿ6¨Õ Ì4^ïêxˆ /0§[X×Õñ@ñâ¹cYö´?øÑ–t~jââȹР(ZÿcÓÍ[÷ÿò׳Ñ1 ˜ßÚô¯•k¶m~oUñ©?‡„ÅZ̨טLæñ£»7lúØâìÌæõ *òo|÷ƒ?ÚU&ÎÔz$èê™HOOÇ“É ?W*Õ1Ñ,‘b7òÞ½ ÷>Ú'ˆŒŒÆ¬giT²¯/5{ëŒÆBŸÂ‹[›¹sÆ'©ËfþæwŽSòfPxiü¢¢"ÌùùY_aa\>u(·€¯˜z*G°ã<=éPRRÒÐаzívŒ<=IV³Öd2ëuc³üpö=6›zE‚ïïv®]ÉåâñD{ Lß}{¥Mø Äcƒõõ?†„F”Ÿ«"{ÔŽˆz{{JJŠùËßÅÂŽòâjÕßµZdxhQižJ4Ú®ÒOΈTK`phR‰Û; î?ìnkåŸ)+ Ox%PæÆ]™Näïå-Ypöܹ0× —ü!wrñöfèµSdO_Û!½¢»ååçÃC¢ž¹\]têœ~šÈ(=•Ÿ¼,³§‡Ï9Q˜G"ûYòM÷¿‰_xúO˜ƒi^‡ô‰þc„Ði$µµ·Ö­[-W ˆHd˜–ËdÊi#¾¥¥­ú›ª¤7WjµJl`‹{ðði2Ù&,¦Ñ<åîIJ^O"‚‚-œÃ-stœMëU½Ýwu°Œõ–­9ÁA½}À¢¦ÅÜUQ ÒçIñb#*ý´~f Pègxh`J®Óhôjµ2:*‚4†›íoYB¼SžÙ#øvViVV–L:rùŸgB‚¼q S#ãjd\£š¤Q‰_õ·Ñá–Çönßñ!ácWk°_ðt¨ßlF/\ølõŠÄ‘áÇ(j²  /åœÅ±C8œµ䇆'ùóíÒí]£ËWP‰$ªmØ"“QÓÑÞ©VO{{Sö~¸áÛ›-Ê N–Ѱliœíj~P=' ;e¬Ìvð¶2|‚É^Ža¹\ÖÞÑÉ[Âîè[”ÆþòÚm•JCg8öäU]räëCMå-,..¶>j©cø°ÂÃY ‹¢Ø,ûÿ…EÍë$Éow­ÿøøE"‰ºyÛÞÍÛŽcg¿ÿ¡Y©ÜM Xw©&Á`Bü¢¹)r<úbçŽMKS³,ÎÕ//r¹o­I7ÆDÝ?=énZÀáÍš®Yûï;ß-å¥DÇ$8zFÚEŧIdë²¶§¼ªGN€ÄãU×nùÏ“IG,Nÿ 84ħ¥±Æ —ª‘qÉs¡Д¤søgiÎ|ª‡ÚéeHóÈT/&¶†hT2 8¨«­ Jx#‡÷|%LÒéATåì+X³~‡Å9Vx)-#ëø‰b5ŠG»e2…Ù¤ÁòÓzùÚºÜý{8q‰Ã÷q’ñ¡šë—•J+œÑdW}q {ÈXœóåùÿ¨™ïK+--Ážt³€ŒÝ#Aý;õ8´¶6‰'f¶¾vaë•Ëf“¾CØØ×?Rz*ÏlÖ[K½6½€N÷²Ì P¨ÁL•ÊÃ:Ÿ£G¤2©7ÃB75:­² ÿ÷–ðåK|"ÏŽœYO³€ðx‚?s~ŸŸÁçÛµA§D„ùÀk¬÷ ( ÖQ¢o m˜F÷OJ~;lzPw©²zyÆÒ}r”ò§×¾ú”4ÙðN¶Ÿ”ãý™j>ã.Ñû1ƒý˜Á¶‰iíH/25%éÍäå¶¾Á s,§Ólw'µJÚÜx÷hÞ±ØØXÿ@ û°wíÎ=t¤ð|ŪõkWÈ=ÂÁág0¬¿P³V6¥>\©¬p¼Ì2^’trÄî”ð±À1©DtèË‚íÂÖÚÕ"Qç‘Ã9o­{ßß?Ü’!SÃËÊÊjª++?¿::vìäÉO^æ:™4Àb/䝸Àñ2N%ê•G„‰ìL“ÅÈ$ý•Ÿ¹Q{+.Žs4¯(‘›lûÎtF@ööܘXnîþ=·oÝØÏŽÅ¿|™y…UÉšHž¡dJøœJ<úäzÍM~J´NgXœ¸„Hýå¼J1„¢àåýæàÜ_Ð\È äJn Wr¹’È•Ü@®är¥ÿh³ìÉš…VFIEND®B`‚cgoban-1.9.14/man6/0000777000671000067100000000000007606355251007460 5cgoban-1.9.14/man6/Makefile.am0000664000671000067100000000010707466272674011443 man_MANS = cgoban.6 grab_cgoban.6 EXTRA_DIST = cgoban.6 grab_cgoban.6 cgoban-1.9.14/man6/Makefile.in0000664000671000067100000001547607606355024011456 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPP = @CPP@ DATE = @DATE@ DEPDIR = @DEPDIR@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBS = @LIBS@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ man_MANS = cgoban.6 grab_cgoban.6 EXTRA_DIST = cgoban.6 grab_cgoban.6 subdir = man6 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/configure.h CONFIG_CLEAN_FILES = DIST_SOURCES = NROFF = nroff MANS = $(man_MANS) DIST_COMMON = Makefile.am Makefile.in all: all-am .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu man6/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) uninstall-info-am: man6dir = $(mandir)/man6 install-man6: $(man6_MANS) $(man_MANS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(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/^.*\\.//'`; \ 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 tags: TAGS TAGS: DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = .. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ 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"; \ $(mkinstalldirs) "$(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 check-am: all-am check: check-am all-am: Makefile $(MANS) installdirs: $(mkinstalldirs) $(DESTDIR)$(man6dir) 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-generic mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-man install-exec-am: install-info: install-info-am install-man: install-man6 installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic uninstall-am: uninstall-info-am uninstall-man uninstall-man: uninstall-man6 .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am info info-am install \ install-am install-data install-data-am install-exec \ install-exec-am install-info install-info-am install-man \ install-man6 install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic uninstall uninstall-am \ uninstall-info-am uninstall-man uninstall-man6 # 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: cgoban-1.9.14/man6/cgoban.60000664000671000067100000000244707577705143010733 .\" I really don't like to write man pages. .ds ]W Complete Goban 1.9.14 .TH Cgoban 6 "24 October 2002" .SH NAME cgoban \- X11 Go Toolset .SH SYNOPSIS .LP .B cgoban -help .LP .B cgoban [ .I ] .SH DESCRIPTION Information on the switches is available with .B cgoban .BR \-help . .LP One switch that you may want to use is the .B cgoban .B \-fontHeight .I size switch. This switch changes the size of everything that cgoban draws. The default is 12; running .B cgoban \-fontHeight 14 will make the board, etc. larger, while .B cgoban \-fontHeight 10 will make it all smaller. .LP Any of the command line switches can be set instead with an X default. For example, if you want to set black and white to be the default mode, you can run complete goban with .B cgoban .BR -nocolor , or you can add .B cgoban*color: 0 to your X defaults. .LP Cgoban will store a new .B .cgobanrc file every time you run it. In this file it will save the current state of cgoban. This is handy; you don't normally have to set command line switches since cgoban will remember them in the .B .cgobanrc file. However, it is possible that the .B .cgobanrc file gets some bad data in it. Just delete the file and then you can start from scratch again. .SH AUTHOR Kevin Sonney ksonney@redhat.com .LP http://cgoban1.sourceforge.net/ cgoban-1.9.14/man6/grab_cgoban.60000664000671000067100000000112607211312446011700 .TH grab_cgoban 6 "6 December 1997" .SH NAME grab_cgoban \- take a snapshot of a cgoban board .SH SYNOPSIS .LP .B grab_cgoban [ .IB filename .gif ] .SH DESCRIPTION This shell script looks for a cgoban window, grabs the displayed Go board and saves it as a GIF file. It can use imagemagick or pbmplus to convert the image to GIF. If it can't find either, it will save it as an XWD image instead. In that case it will add the extension .B .xwd to the filename supplied. .SH AUTHOR Anthony Thyssen . .LP This manual page was provided by Richard Braakman . cgoban-1.9.14/wmslib/0000777000671000067100000000000007606355251010114 5cgoban-1.9.14/wmslib/Makefile.am0000664000671000067100000000001607466272676012100 SUBDIRS = src cgoban-1.9.14/wmslib/Makefile.in0000664000671000067100000002275407606355025012110 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPP = @CPP@ DATE = @DATE@ DEPDIR = @DEPDIR@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBS = @LIBS@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ SUBDIRS = src subdir = wmslib mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/configure.h CONFIG_CLEAN_FILES = DIST_SOURCES = RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ uninstall-info-recursive all-recursive install-data-recursive \ install-exec-recursive installdirs-recursive install-recursive \ uninstall-recursive check-recursive installcheck-recursive DIST_COMMON = Makefile.am Makefile.in DIST_SUBDIRS = $(SUBDIRS) all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu wmslib/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) uninstall-info-am: # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ETAGS = etags ETAGSFLAGS = tags: TAGS 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-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(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 "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = .. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ 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"; \ $(mkinstalldirs) "$(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 list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \ || exit 1; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" \ distdir=../$(distdir)/$$subdir \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: info: info-recursive info-am: install-data-am: install-exec-am: install-info: install-info-recursive install-man: installcheck-am: maintainer-clean: maintainer-clean-recursive maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic uninstall-am: uninstall-info-am uninstall-info: uninstall-info-recursive .PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ clean-generic clean-recursive distclean distclean-generic \ distclean-recursive distclean-tags distdir dvi dvi-am \ dvi-recursive info info-am info-recursive install install-am \ install-data install-data-am install-data-recursive \ install-exec install-exec-am install-exec-recursive \ install-info install-info-am install-info-recursive install-man \ install-recursive install-strip installcheck installcheck-am \ installdirs installdirs-am installdirs-recursive \ maintainer-clean maintainer-clean-generic \ maintainer-clean-recursive mostlyclean mostlyclean-generic \ mostlyclean-recursive tags tags-recursive uninstall \ uninstall-am uninstall-info-am uninstall-info-recursive \ uninstall-recursive # 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: cgoban-1.9.14/wmslib/src/0000777000671000067100000000000007606355253010705 5cgoban-1.9.14/wmslib/src/Makefile.am0000664000671000067100000000013607466272677012673 SUBDIRS = abut but wms noinst_LIBRARIES = libwmsutils.a libwmsutils_a_SOURCES = wms.c wms.h cgoban-1.9.14/wmslib/src/Makefile.in0000664000671000067100000002664007606355025012675 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../.. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPP = @CPP@ DATE = @DATE@ DEPDIR = @DEPDIR@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBS = @LIBS@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ SUBDIRS = abut but wms noinst_LIBRARIES = libwmsutils.a libwmsutils_a_SOURCES = wms.c wms.h subdir = wmslib/src mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/configure.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) libwmsutils_a_AR = $(AR) cru libwmsutils_a_LIBADD = am_libwmsutils_a_OBJECTS = wms.$(OBJEXT) libwmsutils_a_OBJECTS = $(am_libwmsutils_a_OBJECTS) DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/wms.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ DIST_SOURCES = $(libwmsutils_a_SOURCES) RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ uninstall-info-recursive all-recursive install-data-recursive \ install-exec-recursive installdirs-recursive install-recursive \ uninstall-recursive check-recursive installcheck-recursive DIST_COMMON = Makefile.am Makefile.in DIST_SUBDIRS = $(SUBDIRS) SOURCES = $(libwmsutils_a_SOURCES) all: all-recursive .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu wmslib/src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) AR = ar clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libwmsutils.a: $(libwmsutils_a_OBJECTS) $(libwmsutils_a_DEPENDENCIES) -rm -f libwmsutils.a $(libwmsutils_a_AR) libwmsutils.a $(libwmsutils_a_OBJECTS) $(libwmsutils_a_LIBADD) $(RANLIB) libwmsutils.a mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wms.Po@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` CCDEPMODE = @CCDEPMODE@ uninstall-info-am: # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ETAGS = etags ETAGSFLAGS = tags: TAGS 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-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(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 "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../.. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ 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"; \ $(mkinstalldirs) "$(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 list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \ || exit 1; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" \ distdir=../$(distdir)/$$subdir \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LIBRARIES) installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-recursive clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-recursive distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-tags dvi: dvi-recursive dvi-am: info: info-recursive info-am: install-data-am: install-exec-am: install-info: install-info-recursive install-man: installcheck-am: maintainer-clean: maintainer-clean-recursive maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic uninstall-am: uninstall-info-am uninstall-info: uninstall-info-recursive .PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ clean-generic clean-noinstLIBRARIES clean-recursive distclean \ distclean-compile distclean-depend distclean-generic \ distclean-recursive distclean-tags distdir dvi dvi-am \ dvi-recursive info info-am info-recursive install install-am \ install-data install-data-am install-data-recursive \ install-exec install-exec-am install-exec-recursive \ install-info install-info-am install-info-recursive install-man \ install-recursive install-strip installcheck installcheck-am \ installdirs installdirs-am installdirs-recursive \ maintainer-clean maintainer-clean-generic \ maintainer-clean-recursive mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-recursive tags tags-recursive \ uninstall uninstall-am uninstall-info-am \ uninstall-info-recursive uninstall-recursive # 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: cgoban-1.9.14/wmslib/src/wms.c0000664000671000067100000001321607043224471011570 /* * wmslib/src/wms.c, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #include #if !HAVE_GETDTABLESIZE #include #endif #if DEBUG typedef struct alloc_struct { int magic; int size; const char *file; int line; struct alloc_struct *next, *prev; } alloc_t; static int alloc_count=0, total_bytes=0, check=FALSE; static alloc_t *ring_head = NULL; void *wms_malloc_debug(uint bufsize, const char *file, int line) { void *ret; alloc_t *alloc; if (bufsize == 0) return(NULL); ++alloc_count; total_bytes += bufsize; bufsize += sizeof(alloc_t); alloc = malloc(bufsize); assert(alloc != NULL); if (alloc == NULL) { fprintf(stderr, "%s: FATAL ERROR: Failed to allocate %d bytes.\n", wms_progname, bufsize); exit(1); } ret = (void *)((int)alloc + sizeof(alloc_t)); alloc->magic = 0x91325832; alloc->size = bufsize - sizeof(alloc_t); alloc->file = file; alloc->line = line; if (ring_head == NULL) { ring_head = alloc; alloc->next = alloc->prev = alloc; } else { alloc->next = ring_head; alloc->prev = ring_head->prev; alloc->next->prev = alloc; alloc->prev->next = alloc; } return(ret); } void wms_free(void *deadbuf) { alloc_t *alloc; assert(deadbuf != NULL); alloc = (alloc_t *)((int)deadbuf - sizeof(alloc_t)); --alloc_count; assert(alloc->magic == 0x91325832); total_bytes -= alloc->size; alloc->magic = 0; if (ring_head == alloc) { if (alloc->next == alloc) ring_head = NULL; else { ring_head = alloc->next; alloc->next->prev = alloc->prev; alloc->prev->next = alloc->next; } } else if (alloc->next != alloc) { alloc->next->prev = alloc->prev; alloc->prev->next = alloc->next; } free(alloc); } void wms_alloc_ring_reset(void) { ring_head = NULL; } void wms_alloc_ring_show(void) { alloc_t *alloc; if (ring_head == NULL) { printf("*** wms_alloc: Empty ring\n"); } else { alloc = ring_head; do { printf("*** wms_alloc: %4d bytes; file \"%s\", line %d.\n", alloc->size, alloc->file, alloc->line); alloc = alloc->next; } while (alloc != ring_head); printf("\n"); } } void wms_alloc_stat(void) { fprintf(stderr, "Count of allocated buffers: %d\n", alloc_count); fprintf(stderr, " Total bytes allocated: %d\n", total_bytes); check = TRUE; } #else /* !DEBUG */ void *wms_malloc(uint bufsize) { void *ret; if (bufsize == 0) return(NULL); ret = malloc(bufsize); assert(ret != NULL); if (ret == NULL) { fprintf(stderr, "%s: FATAL ERROR: Failed to allocate %d bytes.\n", wms_progname, bufsize); exit(1); } return(ret); } #endif /* DEBUG */ #if !HAVE_STRERROR /* * Do a fake, really bad strerror() function. */ const char *strerror(int error) { static char out[20]; sprintf(out, "System error %d", error); return(out); } #endif /* !HAVE_STRERROR */ #if !HAVE_GETDTABLESIZE int getdtablesize(void) { struct rlimit tmp_rlim; getrlimit(RLIMIT_NOFILE, &tmp_rlim); return(tmp_rlim.rlim_cur); } #endif /* !HAVE_GETDTABLESIZE */ int wms_atoi(const char *str, bool *err) { bool dummy; bool negative = FALSE, inNum = FALSE, gotNum = FALSE, doneNum = FALSE; int i, v = 0, newV; if (err == NULL) err = &dummy; *err = FALSE; for (i = 0; str[i]; ++i) { if (isspace(str[i])) { if (inNum) doneNum = TRUE; } else if (str[i] == '-') { if (inNum) { *err = TRUE; return(0); } else { inNum = TRUE; negative = TRUE; } } else if (isdigit(str[i])) { if (doneNum) { *err = TRUE; return(0); } else { inNum = TRUE; gotNum = TRUE; newV = v*10 + (int)(str[i] - '0'); if (newV / 10 != v) { *err = TRUE; return(0); } v = newV; } } else { *err = TRUE; return(0); } } if (!gotNum) { *err = TRUE; return(0); } if (negative) return(-v); else return(v); } double wms_atof(const char *str, bool *err) { int i; bool decimal = FALSE; i = 0; if (str[0] == '-') ++i; while (str[i]) { if (str[i] == '.') { if (decimal) { if (err) *err = TRUE; return(0.0); } decimal = TRUE; } else if (!isdigit(str[i])) { if (err) *err = TRUE; return(0.0); } ++i; } if (err) *err = FALSE; return(atof(str)); } #if WORDS_BIGENDIAN int stdInt32_int(StdInt32 i) { return(((i >> 24) & 0x000000ff) | ((i >> 8) & 0x0000ff00) | ((i << 8) & 0x00ff0000) | ((i << 24) & 0xff000000)); } StdInt32 int_stdInt32(int i) { return(((i >> 24) & 0x000000ff) | ((i >> 8) & 0x0000ff00) | ((i << 8) & 0x00ff0000) | ((i << 24) & 0xff000000)); } #endif /* WORDS_BIGENDIAN */ #if !HAVE_MEMMOVE void *memmove(void *dest, const void *src, size_t n) { char *dc; const char *sc; int i; dc = dest; sc = src; if ((dc + n < sc) || (sc + n < dc)) return(memcpy(dest, src, n)); else { if (dc < sc) { for (i = 0; i < n; ++i) { dc[i] = sc[i]; } } else if (sc < dc) { for (i = n - 1; i >= 0; --i) { dc[i] = sc[i]; } } } return(dest); } #endif /* !HAVE_MEMMOVE */ #if !HAVE_STRCASECMP int strcasecmp(const char *s1, const char *s2) { int i; char c1, c2; for (i = 0; s1[i]; ++i) { c1 = s1[i]; c2 = s2[i]; if ((c1 >= 'a') && (c1 <= 'z')) c1 += 'A' - 'a'; if ((c2 >= 'a') && (c2 <= 'z')) c2 += 'A' - 'a'; if (c1 != c2) return((int)c1 - (int)c2); } if (s2[i]) return(-1); return(0); } #endif /* !HAVE_STRCASECMP */ cgoban-1.9.14/wmslib/src/wms.h0000664000671000067100000001436407043224471011602 /* * wmslib/include/wms.h, part of wmslib (Library functions) * Copyright (C) 1994 William Shubert. * See "configure.h.in" for more copyright information. * * This contains a bunch of definitions I always like to have. * This should ALWAYS be AFTER the last system include, BEFORE the first * local include. */ #ifndef _WMS_H_ #define _WMS_H_ 1 #include #ifdef STDC_HEADERS # include # include #endif /* STDC_HEADERS */ #include #include #include #include #if TIME_WITH_SYS_TIME # include # include #else /* !AC_TIME_WITH_SYS_TIME */ # if HAVE_SYS_TIME_H # include # else /* !HAVE_SYS_TIME_H */ # include # endif /* HAVE_SYS_TIME_H */ #endif /* AC_TIME_WITH_SYS_TIME */ #if X11_DISP # include # include # include #endif /* X11_DISP */ #if SUN_SOUND # include # include # include #endif /* SUN_SOUND */ /* Get all these headers out of the way here. */ #include #include #if HAVE_STDLIB_H # include #endif #if HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ #if HAVE_ASSERT_H && DEBUG #include #else #define assert(ignore) #endif /* HAVE_ASSERT_H && DEBUG */ #if STDC_HEADERS || HAVE_STRING_H #include /* An ANSI string.h and pre-ANSI memory.h might conflict. */ #if !STDC_HEADERS && HAVE_MEMORY_H #include #endif /* not STDC_HEADERS and HAVE_MEMORY_H */ #else /* not STDC_HEADERS and not HAVE_STRING_H */ #include #define memcpy(d,s,n) bcopy((s),(d),(n)) #define strchr index #define strrchr rindex #endif /* Not STDC_HEADERS and not HAVE_STRING_H */ #ifdef bool #undef bool #endif /* bool */ #define bool int #ifndef TRUE #define FALSE 0 #define TRUE 1 #endif /* int32 must be AT LEAT 32 bits. More is OK. */ #ifdef int32 #undef int32 #endif /* int32 */ #if (SIZEOF_INT >= 4) #define int32 int #else /* SIZEOF_INT < 4 */ #define int32 long #endif #ifdef uint32 #undef uint32 #endif /* uint32 */ #define uint32 unsigned int32 #ifdef uchar #undef uchar #endif /* uchar */ #define uchar unsigned char #ifdef ushort #undef ushort #endif /* ushort */ #define ushort unsigned short #ifdef uint #undef uint #endif /* uint */ #define uint unsigned int #ifdef ulong #undef ulong #endif #define ulong unsigned long #define int32_max 0x7fffffff #define int32_min (-int32_max-1) #define int_max ((int)((((1 << (8*(sizeof(int)-2)))-1)<<1)+1)) #define int_min (-int_max-1) #define uint_max ((((1U << (8*(sizeof(uint)-1)))-1)<<1)+1) #define long_max ((long)((((1L << (8*(sizeof(long)-2)))-1)<<1)+1)) #define long_min (-long_max-1) #define ulong_max ((((1UL << (8*(sizeof(ulong)-1)))-1)<<1)+1) /* * This atoi sets err to TRUE if there's an overflow or a non-digit * character around. If err is NULL it is just like regular atoi(). */ extern int wms_atoi(const char *str, bool *err); extern double wms_atof(const char *str, bool *err); /* * Debugging aide 1 - The MAGIC macros. * * In every dynamically allocated structure, add this: * #if DEBUG * int magic; * #endif / * DEBUG * / * Then, every time you alloc a structure, _immediately_ do a MAGIC_SET(foo) * on the newly freed buffer. Last thing before you free a structure, do * a MAGIC_UNSET(foo). Then, before you access a structure, always first * say "assert(MAGIC(foo))". This way, if you touch a structure after you * free it, an assertion will trip! And if debug is set to zero, the * checks all disappear and leave you with an efficient program. */ #if DEBUG #define MAGIC_NUM 31415927 /* Any random number will do. */ #define MAGIC_SET(x) ((x)->magic = MAGIC_NUM) #define MAGIC_UNSET(x) ((x)->magic = 0) #define MAGIC(x) ((x)->magic == MAGIC_NUM) #define MAGICNULL(x) (((x) == NULL) || ((x)->magic == MAGIC_NUM)) #define MAGIC_STRUCT int magic; #else #define MAGIC_SET(x) #define MAGIC_UNSET(x) #define MAGIC(x) 1 #define MAGIC_STRUCT #endif /* magic */ /* * Debugging aide 2 - The wms_malloc routines * * This makes it much easier to spot memory leaks and objects freed multiple * times. Basically, every time you call wms_alloc_stat(), you will see * how much memory is allocated. If this grows indefinitely, you know * that you have a memory leak. Doing wms_alloc_ring_show() will list * EVERY wms_malloc that hasn't yet been freed. Ugh. Probably way * more than you need to see. So when you call wms_alloc_ring_reset(), * the list gets cleared, so call wms_alloc_ring_reset(), do the stuff * that shouldn't leave buffers allocated but does, then call * wms_alloc_ring_show() and voila! The files and lines where your * memory leak is coming from! * As in the MAGIC macros, when DEBUG is set to zero this stuff all * disappears. Good thing, too, because it consumes bunches of memory and * a significant amount of CPU cycles. */ #if DEBUG extern void wms_free(void *deadbuf); extern void wms_alloc_stat(void); #define wms_malloc(x) wms_malloc_debug(x, __FILE__, __LINE__) extern void *wms_malloc_debug(uint bufsize, const char *file, int line); void wms_alloc_ring_reset(void); void wms_alloc_ring_show(void); #else #define wms_free free extern void *wms_malloc(uint bufsize); #endif extern const char *wms_progname; /* * A StdInt32 is an int that is exactly 4 bytes long and in little endian * format. */ #if SIZEOF_INT == 4 typedef int StdInt32; #elif SIZEOF_SHORT == 4 typedef short StdInt32; #elif SIZEOF_LONG == 4 typedef long StdInt32; #else #error You must have a 4 byte data type to compile this program! #endif #if !WORDS_BIGENDIAN #define stdInt32_int(i) (i) #define int_stdInt32(i) (i) #else /* Big endian machine. */ extern int stdInt32_int(StdInt32 i); extern StdInt32 int_stdInt32(int i); #endif #if !HAVE_STRERROR extern const char *strerror(int error); #endif #if !HAVE_STRCASECMP extern int strcasecmp(const char *s1, const char *s2); #endif #if !HAVE_MEMMOVE extern void *memmove(void *dest, const void *src, size_t n); #endif #if !HAVE_GETDTABLESIZE extern int getdtablesize(void); #endif #endif /* _WMS_H_ */ cgoban-1.9.14/wmslib/src/abut/0000777000671000067100000000000007606355252011637 5cgoban-1.9.14/wmslib/src/abut/abut.h0000664000671000067100000000226207043224471012654 /* * src/abut.h, part of wmslib library * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _ABUT_ABUT_H_ #ifndef _WMS_CLP_H_ #include #endif #ifdef _ABUT_ABUT_H_ Levelization Error. #endif #define _ABUT_ABUT_H_ 1 /********************************************************************** * Types **********************************************************************/ /* Private. */ typedef struct Abut_struct { ButEnv *env; const char *ok, *cancel; int butH; int ulColor, lrColor, bgColor; Pixmap ulPixmap, lrPixmap, bgPixmap; Clp *clp; MAGIC_STRUCT } Abut; /********************************************************************** * Functions available **********************************************************************/ extern Abut *abut_create(ButEnv *env, const char *ok, const char *cancel); extern void abut_destroy(Abut *a); extern void abut_setColors(Abut *a, int ul, int lr, int bg); extern void abut_setPixmaps(Abut *a, Pixmap ul, Pixmap lr, Pixmap bg); #define abut_setClp(a, c) ((a)->clp = (c)) #define abut_setButH(a, h) ((a)->butH = (h)) #endif /* _ABUT_ABUT_H_ */ cgoban-1.9.14/wmslib/src/abut/fsel.h0000664000671000067100000000464607043224471012662 /* * src/fsel.h, part of wmslib library * Copyright (C) 1995-1997 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _ABUT_FSEL_H_ #ifndef _ABUT_ABUT_H_ #include #endif #ifndef _ABUT_SWIN_H_ #include #endif #ifndef _WMS_STR_H_ #include #endif #ifndef _ABUT_MSG_H_ #include #endif #ifdef _ABUT_FSEL_H_ #error Levelization Error. #endif #define _ABUT_FSEL_H_ 1 /********************************************************************** * Data types **********************************************************************/ typedef struct AbutFsel_struct { Abut *abut; bool propagate; void (*callback)(struct AbutFsel_struct *fsel, void *packet, const char *fname); void *packet; ButWin *win; But *title; But *box; But *path, *pathIn; But *file, *in; But *mask, *maskIn; But *dirs, *files; AbutSwin *dSwin, *fSwin; But *dList, *dlBg, *fList, *flBg; But *ok; But *cancel; Str pathVal; AbutMsg *msg; MAGIC_STRUCT } AbutFsel; /********************************************************************** * Globals **********************************************************************/ extern const char *abutFsel_pathMessage; extern const char *abutFsel_fileMessage; extern const char *abutFsel_maskMessage; extern const char *abutFsel_dirsMessage; extern const char *abutFsel_filesMessage; extern const char *abutFsel_dirErrMessage; /********************************************************************** * Functions **********************************************************************/ extern AbutFsel *abutFsel_create(Abut *a, void (*callback)(AbutFsel *fsel, void *packet, const char *fname), void *packet, const char *app, const char *title, const char *startName); extern AbutFsel *abutFsel_createDir(Abut *a, void (*callback)(AbutFsel *fsel, void *packet, const char *fname), void *packet, const char *app, const char *title, const char *startDir, const char *startName); extern void abutFsel_destroy(AbutFsel *fsel, bool propagate); #define abutFsel_setColors(f, ul, lr, c) \ butBoxFilled_setColors((f)->box, (ul), (lr), (c)) #define abutFsel_setPixmaps(f, ul, lr, c) \ butBoxFilled_setPixmaps((f)->box, (ul), (lr), (c)) #endif /* _ABUT_FSEL_H_ */ cgoban-1.9.14/wmslib/src/abut/help.h0000664000671000067100000000371007043224471012650 /* * src/help.h, part of wmslib library * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _ABUT_HELP_H_ #define _ABUT_HELP_H_ 1 #ifndef _WMS_H_ #include #endif #ifndef _BUT_BUT_H_ #include #endif #ifndef _BUT_TEXT_H_ #include #endif #ifndef _ABUT_ABUT_H_ #include #endif #ifndef _ABUT_SWIN_H_ #include #endif /********************************************************************** * Types **********************************************************************/ typedef struct AbutHelpText_struct { ButTextAlign align; int fontNum; const char *text; } AbutHelpText; typedef struct AbutHelpPage_struct { const char *pageName; const AbutHelpText *text; } AbutHelpPage; typedef struct AbutHelp_struct { Abut *abut; const AbutHelpPage *pages; int maxMenuOpts, curPage; const char **menuOpts; int numPages; ButWin *win; AbutSwin *swin; int swinW, swinH; But *bg, *menu, *ok; int numTextButs, maxTextButs; But *subBg, **textButs; ButOut (*destroyCallback)(struct AbutHelp_struct *help, void *packet); void *packet; MAGIC_STRUCT } AbutHelp; /********************************************************************** * Functions **********************************************************************/ extern AbutHelp *abutHelp_create(Abut *a, const char *title, const char *menuTitle, const AbutHelpPage *pages, int numPages, int x, int y, int w, int h, int minW, int minH); extern void abutHelp_destroy(AbutHelp *help); extern void abutHelp_newPages(AbutHelp *help, const char *menuTitle, const AbutHelpPage *pages, int numPages); extern void abutHelp_setDestroyCallback(AbutHelp *help, ButOut (*callback)(AbutHelp *help, void *packet), void *packet); extern void abutHelp_newPage(AbutHelp *help, int pageNum); #endif /* _ABUT_HELP_H_ */ cgoban-1.9.14/wmslib/src/abut/msg.h0000664000671000067100000000557107043224471012515 /* * src/help.h, part of wmslib library * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _ABUT_MSG_H_ #define _ABUT_MSG_H_ 1 #ifndef _WMS_H_ #include #endif #ifndef _BUT_BUT_H_ #include #endif #ifndef _BUT_BOX_H_ #include #endif #ifndef _ABUT_ABUT_H_ #include #endif /********************************************************************** * Types **********************************************************************/ /* Public. */ typedef struct AbutMsgOpt_struct { const char *name; ButOut (*callback)(But *but); void *packet; const ButKey *keyEq; } AbutMsgOpt; typedef struct AbutMsgTin_struct { const char *name; const char *def; ButOut (*callback)(But *but, const char *value); uint flags; } AbutMsgTin; #define abutMsgTinFlags_secret 0x1 /* Private. */ typedef struct AbutMsg_struct { Abut *abut; ButWin *win; int numButs, numTins; But **buts, **tins, **tinTitles; const AbutMsgOpt *butDesc; ButOut (*destroy)(void *packet); void *packet; int layer; int w, h, textH; But *box, *text; MAGIC_STRUCT } AbutMsg; /********************************************************************** * Functions available **********************************************************************/ extern AbutMsg *abutMsg_inCreate(Abut *a, ButWin *win, int layer, const char *text, void *packet, int numTins, const AbutMsgTin *tinList); extern AbutMsg *abutMsg_optInCreate(Abut *a, ButWin *win, int layer, const char *text, ButOut (*destroy)(void *packet), void *packet, int numButs, const AbutMsgOpt *optList, int numTins, const AbutMsgTin *tinList); extern AbutMsg *abutMsg_winInCreate(Abut *a, const char *title, const char *text, void *packet, int numTins, const AbutMsgTin *tinList); extern AbutMsg *abutMsg_winOptInCreate(Abut *a, const char *title, const char *text, ButOut (*destroy)(void *packet), void *packet, int numButs, const AbutMsgOpt *optList, int numTins, const AbutMsgTin *tinList); #define abutMsg_create(a, w, l, t) abutMsg_inCreate(a, w, l, t, NULL,0,NULL) #define abutMsg_optCreate(a, w, l, t, d, p, nb, b) \ abutMsg_optInCreate(a, w, l, t, d, p, nb, b, 0,NULL) #define abutMsg_winCreate(a, ti, t) \ abutMsg_winInCreate(a, ti, t, NULL,0,NULL) #define abutMsg_winOptCreate(a, ti, t, d, p, nb, b) \ abutMsg_winOptInCreate(a, ti, t, d, p, nb, b, 0,NULL) extern void abutMsg_destroy(AbutMsg *msg, bool propagate); #define abutMsg_setColors(m, ul, lr, f) \ butBoxFilled_setColors((m)->box, (ul), (lr), (f)) #define abutMsg_setPixmaps(m, ul, lr, f) \ butBoxFilled_setPixmaps((m)->box, (ul), (lr), (f)) #define abutMsg_tin(m, t) ((m)->tins[t]) #endif /* _ABUT_MSG_H_ */ cgoban-1.9.14/wmslib/src/abut/swin.h0000664000671000067100000000331107043224471012675 /* * wmslib/src/abut/swin.h, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for auxiliary button code. */ #ifndef _ABUT_SWIN_H_ #define _ABUT_SWIN_H_ 1 #ifndef _WMS_H_ #include #endif #ifndef _BUT_BUT_H_ #include #endif /********************************************************************** * Constants **********************************************************************/ #define ABUT_UPPIC "\2\1" #define ABUT_DOWNPIC "\2\2" #define ABUT_LEFTPIC "\2\3" #define ABUT_RIGHTPIC "\2\4" /********************************************************************** * Data types **********************************************************************/ typedef struct AbutSwin_struct { ButWin *win; void *packet; But *up, *down, *left, *right, *hSlide, *vSlide, *box; float xCenter, yCenter; uint flags; ButTimer *timer; int x, y, w, h, slideW, lineH; /* Backups for resizing. */ int canButW, canButH; MAGIC_STRUCT } AbutSwin; #define ABUTSWIN_LSLIDE 0x1 #define ABUTSWIN_RSLIDE 0x2 #define ABUTSWIN_TSLIDE 0x4 #define ABUTSWIN_BSLIDE 0x8 /********************************************************************** * Functions **********************************************************************/ extern AbutSwin *abutSwin_create(void *packet, ButWin *parent, int layer, uint flags, ButWinFunc resize); extern void abutSwin_resize(AbutSwin *swin, int x, int y, int w, int h, int slidew, int lineh); extern void abutSwin_destroy(AbutSwin *swin); extern void abutSwin_vMove(AbutSwin *swin, int newLoc); #endif /* _ABUT_SWIN_H_ */ cgoban-1.9.14/wmslib/src/abut/term.h0000664000671000067100000000271307043224471012671 /* * wmslib/src/abut/term.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert * See "configure.h.in" for more copyright information. * * Includes for "term" scrolling terminal-like widgety thing. */ #ifndef _ABUT_TERM_H_ #define _ABUT_TERM_H_ 1 #ifndef _ABUT_ABUT_H_ #include #endif #ifndef _ABUT_SWIN_H_ #include #endif #ifndef _BUT_TBIN_H_ #include #endif /********************************************************************** * Data types **********************************************************************/ typedef enum { abutTermState_fastUp, abutTermState_slowUp, abutTermState_steady, abutTermState_slowDown, abutTermState_fastDown } AbutTermState; typedef struct AbutTerm_struct { Abut *abut; AbutSwin *swin; But *bg; But *tbin; AbutTermState state; MAGIC_STRUCT } AbutTerm; /********************************************************************** * Functions **********************************************************************/ extern AbutTerm *abutTerm_create(Abut *abut, ButWin *parent, int layer, bool editable); extern void abutTerm_destroy(AbutTerm *term); extern void abutTerm_resize(AbutTerm *term, int x, int y, int w, int h); extern void abutTerm_set(AbutTerm *term, const char *text); #define abutTerm_get(term) butTbin_get((term)->tbin) extern void abutTerm_append(AbutTerm *term, const char *appText); #endif /* _ABUT_TERM_H_ */ cgoban-1.9.14/wmslib/src/abut/Makefile.am0000664000671000067100000000032607466273126013615 noinst_LIBRARIES = libabut.a INCLUDES = -I $(srcdir)/.. libabut_a_SOURCES = \ abut.c \ fsel.c \ help.c \ msg.c \ swin.c \ term.c noinst_HEADERS = \ abut.h \ fsel.h \ help.h \ msg.h \ swin.h \ term.h cgoban-1.9.14/wmslib/src/abut/Makefile.in0000664000671000067100000002150107606355025013617 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../../.. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPP = @CPP@ DATE = @DATE@ DEPDIR = @DEPDIR@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBS = @LIBS@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ noinst_LIBRARIES = libabut.a INCLUDES = -I $(srcdir)/.. libabut_a_SOURCES = \ abut.c \ fsel.c \ help.c \ msg.c \ swin.c \ term.c noinst_HEADERS = \ abut.h \ fsel.h \ help.h \ msg.h \ swin.h \ term.h subdir = wmslib/src/abut mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/configure.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) libabut_a_AR = $(AR) cru libabut_a_LIBADD = am_libabut_a_OBJECTS = abut.$(OBJEXT) fsel.$(OBJEXT) help.$(OBJEXT) \ msg.$(OBJEXT) swin.$(OBJEXT) term.$(OBJEXT) libabut_a_OBJECTS = $(am_libabut_a_OBJECTS) DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/abut.Po ./$(DEPDIR)/fsel.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/help.Po ./$(DEPDIR)/msg.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/swin.Po ./$(DEPDIR)/term.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ DIST_SOURCES = $(libabut_a_SOURCES) HEADERS = $(noinst_HEADERS) DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in SOURCES = $(libabut_a_SOURCES) all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu wmslib/src/abut/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) AR = ar clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libabut.a: $(libabut_a_OBJECTS) $(libabut_a_DEPENDENCIES) -rm -f libabut.a $(libabut_a_AR) libabut.a $(libabut_a_OBJECTS) $(libabut_a_LIBADD) $(RANLIB) libabut.a mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abut.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/help.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/term.Po@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` CCDEPMODE = @CCDEPMODE@ uninstall-info-am: ETAGS = etags ETAGSFLAGS = tags: TAGS 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: $(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 "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../../.. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ 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"; \ $(mkinstalldirs) "$(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 check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) $(HEADERS) installdirs: 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-tags dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-exec-am: install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic uninstall-am: uninstall-info-am .PHONY: GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES distclean distclean-compile \ distclean-depend distclean-generic distclean-tags distdir dvi \ dvi-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic tags uninstall uninstall-am \ uninstall-info-am # 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: cgoban-1.9.14/wmslib/src/abut/abut.c0000664000671000067100000000263107043224471012647 /* * src/abut.c, part of wmslib library * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #ifdef _ABUT_ABUT_H_ Levelization Error. #endif #include /********************************************************************** * Functions **********************************************************************/ Abut *abut_create(ButEnv *env, const char *ok, const char *cancel) { Abut *a; a = wms_malloc(sizeof(Abut)); MAGIC_SET(a); a->env = env; a->ok = ok; a->cancel = cancel; a->butH = 0; a->ulColor = BUT_LIT; a->lrColor = BUT_SHAD; a->bgColor = BUT_BG; a->ulPixmap = None; a->lrPixmap = None; a->bgPixmap = None; a->clp = NULL; return(a); } void abut_destroy(Abut *a) { assert(MAGIC(a)); MAGIC_UNSET(a); wms_free(a); } void abut_setColors(Abut *a, int ul, int lr, int bg) { assert(MAGIC(a)); if (ul >= 0) { a->ulColor = ul; a->ulPixmap = None; } if (lr >= 0) { a->lrColor = lr; a->lrPixmap = None; } if (bg >= 0) { a->bgColor = bg; a->bgPixmap = None; } } void abut_setPixmaps(Abut *a, Pixmap ul, Pixmap lr, Pixmap bg) { if (ul != None) { a->ulColor = -1; a->ulPixmap = ul; } if (lr != None) { a->lrColor = -1; a->lrPixmap = lr; } if (bg != None) { a->bgColor = -1; a->bgPixmap = bg; } } cgoban-1.9.14/wmslib/src/abut/fsel.c0000664000671000067100000004306307043224471012651 /* * src/fsel.c, part of wmslib library * Copyright (C) 1995-1997 William Shubert * See "configure.h.in" for more copyright information. */ #include /* * Here goes the dirent kludge. Ugh. The things I go through for portability. */ #if HAVE_DIRENT_H # include # define NAMLEN(dirent) strlen((dirent)->d_name) #else # define dirent direct # define NAMLEN(dirent) (dirent)->d_namlen # if HAVE_SYS_NDIR_H # include # endif # if HAVE_SYS_DIR_H # include # endif # if HAVE_NDIR_H # include # endif #endif #include #include #include #include #include #include #include #include #ifdef _ABUT_FSEL_H_ #error Levelization Error. #endif #include /********************************************************************** * Globals **********************************************************************/ const char *abutFsel_pathMessage = NULL; const char *abutFsel_fileMessage = NULL; const char *abutFsel_maskMessage = NULL; const char *abutFsel_dirsMessage = NULL; const char *abutFsel_filesMessage = NULL; const char *abutFsel_dirErrMessage = NULL; /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut resize(ButWin *win); static ButOut dswinResize(ButWin *win), fswinResize(ButWin *win); static ButOut unmap(ButWin *win); static ButOut wDestroy(ButWin *win); static ButOut okPressed(But *but); static ButOut cancelPressed(But *but); static ButOut newName(But *but, const char *text); static ButOut newPath(But *but, const char *text); static ButOut newMask(But *but, const char *text); static bool dirScan(AbutFsel *f, const char *path); static ButOut dirPressed(But *but, int line); static ButOut filePressed(But *but, int line); static void fixPath(Str *pathOut, const char *pathIn); static void addCwd(Str *pathOut); static bool maskMatch(const char *mask, const char *fName, int fLen); static void dirError(AbutFsel *f, int errnov, const char *badDir); static ButOut msgDead(void *packet); static ButOut msgOkBut(But *but); /********************************************************************** * Functions **********************************************************************/ AbutFsel *abutFsel_createDir(Abut *a, void (*callback)(AbutFsel *fsel, void *packet, const char *fname), void *packet, const char *app, const char *title, const char *startDir, const char *startName) { Str fullName; AbutFsel *result; if (strchr(startName, '/') == NULL) { str_initChars(&fullName, startDir); str_catChar(&fullName, '/'); str_catChars(&fullName, startName); result = abutFsel_create(a, callback, packet, app, title, str_chars(&fullName)); str_deinit(&fullName); return(result); } else { return(abutFsel_create(a, callback, packet, app, title, startName)); } } AbutFsel *abutFsel_create(Abut *a, void (*callback)(AbutFsel *fsel, void *packet, const char *fname), void *packet, const char *app, const char *title, const char *startName) { ButEnv *env; AbutFsel *f; int butH, bw; int i, minW, minH, w, h; Str titleString, pathString; bool err; assert(MAGIC(a)); assert(abutFsel_pathMessage != NULL); assert(abutFsel_fileMessage != NULL); assert(abutFsel_maskMessage != NULL); assert(abutFsel_dirsMessage != NULL); assert(abutFsel_filesMessage != NULL); assert(abutFsel_dirErrMessage != NULL); env = a->env; f = wms_malloc(sizeof(AbutFsel)); MAGIC_SET(f); f->abut = a; f->propagate = TRUE; f->callback = callback; f->packet = packet; str_init(&f->pathVal); f->msg = NULL; butH = a->butH; bw = butEnv_stdBw(env); minH = butH*10 + bw*10; minW = minH; if (a->clp) { w = (int)(minW * clp_getDouble(a->clp, "abut.fsel.w") + 0.5); h = (int)(minH * clp_getDouble(a->clp, "abut.fsel.h") + 0.5); if (w < minW) w = minW; if (h < minH) h = minH; } else { w = minW * 1.2; h = minH * 1.2; } str_initChars(&titleString, app); str_catChars(&titleString, " File Selector"); f->win = butWin_create(f, env, str_chars(&titleString), w, h, unmap, NULL, resize, wDestroy); i = clp_iGetInt(a->clp, "abut.fsel.x", &err); if (!err) butWin_setX(f->win, i); i = clp_iGetInt(a->clp, "abut.fsel.y", &err); if (!err) butWin_setY(f->win, i); butWin_setMinW(f->win, minW); butWin_setMinH(f->win, minH); butWin_setMaxW(f->win, 0); butWin_setMaxH(f->win, 0); butWin_activate(f->win); str_initChars(&pathString, startName); for (i = str_len(&pathString); (i > 0) && (str_chars(&pathString)[i - 1] != '/'); --i); str_copyChars(&titleString, str_chars(&pathString) + i); if (i > 0) str_clip(&pathString, i); else str_copyChars(&pathString, "./"); fixPath(&f->pathVal, str_chars(&pathString)); f->box = butBoxFilled_create(f->win, 0, BUT_DRAWABLE); butBoxFilled_setColors(f->box, a->ulColor, a->lrColor, a->bgColor); butBoxFilled_setPixmaps(f->box, a->ulPixmap, a->lrPixmap, a->bgPixmap); f->title = butText_create(f->win, 1, BUT_DRAWABLE, title, butText_left); f->path = butText_create(f->win, 1, BUT_DRAWABLE, abutFsel_pathMessage, butText_left); f->pathIn = butTextin_create(newPath, f, f->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, str_chars(&f->pathVal), 100); f->file = butText_create(f->win, 1, BUT_DRAWABLE, abutFsel_fileMessage, butText_left); f->in = butTextin_create(newName, f, f->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, str_chars(&titleString), 100); f->mask = butText_create(f->win, 1, BUT_DRAWABLE, abutFsel_maskMessage, butText_left); f->maskIn = butTextin_create(newMask, f, f->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, "*.sgf", 100); f->dirs = butText_create(f->win, 1, BUT_DRAWABLE, abutFsel_dirsMessage, butText_left); f->dSwin = abutSwin_create(f, f->win, 1, ABUTSWIN_LSLIDE, dswinResize); f->dlBg = butPlain_create(f->dSwin->win, 0, BUT_DRAWABLE, BUT_BG); f->dList = butList_create(dirPressed, f, f->dSwin->win, 1, BUT_DRAWABLE|BUT_PRESSABLE); f->files = butText_create(f->win, 1, BUT_DRAWABLE, abutFsel_filesMessage, butText_left); f->fSwin = abutSwin_create(f, f->win, 1, ABUTSWIN_LSLIDE, fswinResize); f->flBg = butPlain_create(f->fSwin->win, 0, BUT_DRAWABLE, BUT_BG); f->fList = butList_create(filePressed, f, f->fSwin->win, 1, BUT_DRAWABLE|BUT_PRESSABLE); f->ok = butCt_create(okPressed, f, f->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, a->ok); f->cancel = butCt_create(cancelPressed, f, f->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, a->cancel); str_deinit(&pathString); str_deinit(&titleString); dirScan(f, butTextin_get(f->pathIn)); return(f); } void abutFsel_destroy(AbutFsel *f, bool propagate) { assert(MAGIC(f)); f->propagate = propagate; butWin_destroy(f->win); } static ButOut resize(ButWin *win) { AbutFsel *f = butWin_packet(win); ButEnv *env = butWin_env(win); int butH, bw; int w, h; int textMaxW, textW; int dirsW, filesW; assert(MAGIC(f)); w = butWin_w(win); h = butWin_h(win); butH = f->abut->butH; bw = butEnv_stdBw(env); but_resize(f->box, 0,0, w,h); but_resize(f->title, bw*2,bw*2, w-bw*4,butH); textMaxW = butText_resize(f->path, bw*2, butH+bw*3, butH); textW = butText_resize(f->file, bw*2, butH*2+bw*4, butH); if (textW > textMaxW) textMaxW = textW; textW = butText_resize(f->mask, bw*2, butH*3+bw*5, butH); if (textW > textMaxW) textMaxW = textW; but_resize(f->pathIn, bw*3 + textMaxW, butH+bw*3, w - (bw*5 + textMaxW), butH); but_resize(f->in, bw*3 + textMaxW, butH*2+bw*4, w - (bw*5 + textMaxW), butH); but_resize(f->maskIn, bw*3 + textMaxW, butH*3+bw*5, w - (bw*5 + textMaxW), butH); dirsW = (w - bw*5) / 2; filesW = w - (bw*5 + dirsW); but_resize(f->dirs, bw*2, butH*4 + bw*6, dirsW, butH); abutSwin_resize(f->dSwin, bw*2, butH*5 + bw*7, dirsW, h - butH*6 - bw*10, 3 * butEnv_fontH(env, 0) / 2, butEnv_fontH(env, 0)); but_resize(f->files, bw*3 + dirsW, butH*4 + bw*6, filesW, butH); abutSwin_resize(f->fSwin, bw*3 + dirsW, butH*5 + bw*7, filesW, h - butH*6 - bw*10, 3 * butEnv_fontH(env, 0) / 2, butEnv_fontH(env, 0)); but_resize(f->cancel, bw*2, h-butH-bw*2, (w-bw*5)/2, butH); but_resize(f->ok, (w-bw*5)/2+bw*3, h-butH-bw*2, (w-bw*5+1)/2, butH); butCan_resizeWin(f->dSwin->win, 0, butList_len(f->dList) * butEnv_fontH(env, 0) + butEnv_stdBw(env) * 2, TRUE); butCan_resizeWin(f->fSwin->win, 0, butList_len(f->fList) * butEnv_fontH(env, 0) + butEnv_stdBw(env) * 2, TRUE); return(0); } static ButOut okPressed(But *but) { AbutFsel *f = but_packet(but); Str result; assert(MAGIC(f)); str_initChars(&result, butTextin_get(f->pathIn)); str_catChars(&result, butTextin_get(f->in)); if (f->callback) { f->callback(f, f->packet, str_chars(&result)); f->callback = NULL; } str_deinit(&result); butWin_destroy(f->win); return(0); } static ButOut cancelPressed(But *but) { AbutFsel *f = but_packet(but); assert(MAGIC(f)); if (f->callback) { f->callback(f, f->packet, NULL); f->callback = NULL; } butWin_destroy(f->win); return(0); } static ButOut unmap(ButWin *win) { butWin_destroy(win); return(0); } static ButOut wDestroy(ButWin *win) { AbutFsel *f = butWin_packet(win); assert(MAGIC(f)); if (f->abut->clp) { clp_setInt(f->abut->clp, "abut.fsel.x", butWin_x(win)); clp_setInt(f->abut->clp, "abut.fsel.y", butWin_y(win)); clp_setDouble(f->abut->clp, "abut.fsel.w", (double)butWin_w(win) / (double)butWin_getMinW(win)); clp_setDouble(f->abut->clp, "abut.fsel.h", (double)butWin_h(win) / (double)butWin_getMinH(win)); } if (f->callback && f->propagate) { f->callback(f, f->packet, NULL); f->callback = NULL; } abutSwin_destroy(f->dSwin); abutSwin_destroy(f->fSwin); str_deinit(&f->pathVal); if (f->msg) { abutMsg_destroy(f->msg, FALSE); f->msg = NULL; } MAGIC_UNSET(f); wms_free(f); return(0); } static ButOut newName(But *but, const char *text) { AbutFsel *f = but_packet(but); assert(MAGIC(f)); if (f->callback) { f->callback(f, f->packet, text); f->callback = NULL; } butWin_destroy(f->win); return(0); } static ButOut newPath(But *but, const char *text) { AbutFsel *f = but_packet(but); Str newDir; bool ok; uint result = 0; assert(MAGIC(f)); str_init(&newDir); fixPath(&newDir, butTextin_get(but)); ok = dirScan(f, str_chars(&newDir)); if (ok) { but_setFlags(but, BUT_NOKEY); butTextin_set(but, str_chars(&newDir), FALSE); str_copy(&f->pathVal, &newDir); } else { result = BUTOUT_ERR; } str_deinit(&newDir); return(result); } static ButOut newMask(But *but, const char *text) { AbutFsel *f = but_packet(but); assert(MAGIC(f)); but_setFlags(but, BUT_NOKEY); dirScan(f, str_chars(&f->pathVal)); return(0); } static ButOut dswinResize(ButWin *win) { AbutSwin *swin = butWin_packet(win); AbutFsel *f; int bw = butEnv_stdBw(butWin_env(win)); assert(MAGIC(swin)); f = swin->packet; assert(MAGIC(f)); but_resize(f->dlBg, 0, 0, butWin_w(win), butWin_h(win)); butList_resize(f->dList, bw, bw, butWin_w(win) - bw); return(0); } static ButOut fswinResize(ButWin *win) { AbutSwin *swin = butWin_packet(win); AbutFsel *f; int bw = butEnv_stdBw(butWin_env(win)); assert(MAGIC(swin)); f = swin->packet; assert(MAGIC(f)); but_resize(f->flBg, 0, 0, butWin_w(win), butWin_h(win)); butList_resize(f->fList, bw, bw, butWin_w(win) - bw); return(0); } static bool dirScan(AbutFsel *f, const char *path) { DIR *d; struct dirent *ent; struct stat fStat; Str fName; int pathLen, i; int numDirs = 0, maxDirs = 10, numFiles = 0, maxFiles = 10; Str *dirs, *files, *newList; d = opendir(path); if (d == NULL) { dirError(f, errno, path); return(FALSE); } dirs = wms_malloc(maxDirs * sizeof(Str)); files = wms_malloc(maxFiles * sizeof(Str)); str_init(&fName); pathLen = strlen(path); for (ent = readdir(d); ent != NULL; ent = readdir(d)) { str_copyCharsLen(&fName, path, pathLen); str_catCharsLen(&fName, ent->d_name, NAMLEN(ent)); if (stat(str_chars(&fName), &fStat) == 0) { if (S_ISDIR(fStat.st_mode)) { if ((NAMLEN(ent) != 1) || (ent->d_name[0] != '.')) { if (numDirs == maxDirs) { newList = wms_malloc(maxDirs * 2 * sizeof(Str)); memcpy(newList, dirs, maxDirs * sizeof(Str)); wms_free(dirs); dirs = newList; maxDirs *= 2; } assert(numDirs < maxDirs); str_initCharsLen(&dirs[numDirs++], ent->d_name, NAMLEN(ent)); } } else { if (maskMatch(butTextin_get(f->maskIn), ent->d_name, NAMLEN(ent))) { if (numFiles == maxFiles) { newList = wms_malloc(maxFiles * 2 * sizeof(Str)); memcpy(newList, files, maxFiles * sizeof(Str)); wms_free(files); files = newList; maxFiles *= 2; } assert(numFiles < maxFiles); str_initCharsLen(&files[numFiles++], ent->d_name, NAMLEN(ent)); } } } } closedir(d); if (numDirs > 1) { qsort(dirs, numDirs, sizeof(Str), str_alphaCmp); } if (numFiles > 1) { qsort(files, numFiles, sizeof(Str), str_alphaCmp); } butCan_resizeWin(f->dSwin->win, 0, numDirs * butEnv_fontH(f->abut->env, 0) + butEnv_stdBw(f->abut->env) * 2, TRUE); butList_setLen(f->dList, numDirs); for (i = 0; i < numDirs; ++i) { butList_changeLine(f->dList, i, str_chars(&dirs[i])); str_deinit(&dirs[i]); } wms_free(dirs); butCan_resizeWin(f->fSwin->win, 0, numFiles * butEnv_fontH(f->abut->env, 0) + butEnv_stdBw(f->abut->env) * 2, TRUE); butList_setLen(f->fList, numFiles); for (i = 0; i < numFiles; ++i) { butList_changeLine(f->fList, i, str_chars(&files[i])); str_deinit(&files[i]); } wms_free(files); return(TRUE); } static ButOut dirPressed(But *but, int line) { AbutFsel *f = but_packet(but); Str newDir; assert(MAGIC(f)); but_setFlags(f->pathIn, BUT_NOKEY); str_initChars(&newDir, str_chars(&f->pathVal)); str_catChars(&newDir, butList_get(but, line)); fixPath(&f->pathVal, str_chars(&newDir)); butTextin_set(f->pathIn, str_chars(&f->pathVal), FALSE); dirScan(f, str_chars(&f->pathVal)); str_deinit(&newDir); return(0); } static ButOut filePressed(But *but, int line) { AbutFsel *f = but_packet(but); assert(MAGIC(f)); if (strcmp(butTextin_get(f->in), butList_get(but, line))) { /* Change the default file name. */ butTextin_set(f->in, butList_get(but, line), FALSE); } else { /* Accept this file. */ okPressed(f->ok); } return(0); } static void fixPath(Str *pathOut, const char *pathIn) { int i; str_clip(pathOut, 0); if (pathIn[0] != '/') { addCwd(pathOut); } else ++pathIn; str_catChar(pathOut, '/'); assert(str_len(pathOut) > 0); while (*pathIn) { if ((pathIn[0] == '.') && (pathIn[1] == '.') && ((pathIn[2] == '/') || (pathIn[2] == '\0'))) { for (i = str_len(pathOut) - 1; (i >= 1) && (str_chars(pathOut)[i - 1] != '/'); --i); if (i >= 1) str_clip(pathOut, i); pathIn += 2; if (*pathIn) ++pathIn; } else if ((pathIn[0] == '.') && ((pathIn[1] == '/') || (pathIn[1] == '\0'))) { ++pathIn; if (*pathIn) ++pathIn; } else if (pathIn[0] == '/') { ++pathIn; } else { while ((*pathIn != '/') && (*pathIn != '\0')) { str_catChar(pathOut, *(pathIn++)); } str_catChar(pathOut, '/'); if (*pathIn) ++pathIn; } } assert(str_len(pathOut) > 0); assert(str_chars(pathOut)[0] == '/'); } static void addCwd(Str *pathOut) { char dirBuf[1024], *result, *tmpBuf; int len = sizeof(dirBuf); result = getcwd(dirBuf, sizeof(dirBuf)); if (result == NULL) { while (errno == ERANGE) { len *= 2; tmpBuf = wms_malloc(len); result = getcwd(tmpBuf, len); if (result != NULL) { str_catChars(pathOut, tmpBuf); wms_free(tmpBuf); return; } wms_free(tmpBuf); } /* Another error. We can't get the cwd. */ str_catChars(pathOut, "/"); return; } str_catChars(pathOut, dirBuf); } static bool maskMatch(const char *mask, const char *fName, int fLen) { assert(fLen >= 0); while (fLen > 0) { switch(*mask) { case '\0': return(FALSE); case '*': while (mask[1] == '*') ++mask; if (fLen == 1) { return(mask[1] == '\0'); } if (fName[1] == mask[1]) { if (maskMatch(mask + 1, fName + 1, fLen - 1)) return(TRUE); } break; default: if (*mask != *fName) return(FALSE); ++mask; break; } ++fName; --fLen; } return(*mask == '\0'); } static void dirError(AbutFsel *f, int errnov, const char *badDir) { Str fullError; AbutMsgOpt okBut; if (f->msg) { abutMsg_destroy(f->msg, FALSE); f->msg = NULL; } okBut.name = f->abut->ok; okBut.callback = msgOkBut; okBut.packet = f; okBut.keyEq = NULL; str_init(&fullError); str_print(&fullError, abutFsel_dirErrMessage, strerror(errnov), badDir); f->msg = abutMsg_optCreate(f->abut, f->win, 2, str_chars(&fullError), msgDead, f, 1, &okBut); } static ButOut msgDead(void *packet) { AbutFsel *f = packet; assert(MAGIC(f)); f->msg = NULL; return(0); } static ButOut msgOkBut(But *but) { AbutFsel *f = but_packet(but); assert(MAGIC(f)); abutMsg_destroy(f->msg, FALSE); f->msg = NULL; return(0); } cgoban-1.9.14/wmslib/src/abut/help.c0000664000671000067100000001515307043224471012647 /* * wmslib/src/abut/help.c, part of wmslib library * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include #ifdef _ABUT_HELP_H_ Levelization Error. #endif #include "help.h" /********************************************************************** * Forward declarations **********************************************************************/ static ButOut unmap(ButWin *win); static ButOut map(ButWin *win); static ButOut resize(ButWin *win); static ButOut subWinResize(ButWin *win); static ButOut destroy(ButWin *win); static ButOut ok(But *but); static ButOut newMenuOpt(But *but, int value); /********************************************************************** * Functions **********************************************************************/ AbutHelp *abutHelp_create(Abut *a, const char *title, const char *menuTitle, const AbutHelpPage *pages, int numPages, int x, int y, int w, int h, int minW, int minH) { AbutHelp *help; help = wms_malloc(sizeof(AbutHelp)); MAGIC_SET(help); help->abut = a; help->pages = pages; help->maxMenuOpts = 0; help->menuOpts = NULL; help->curPage = 0; help->numPages = 0; help->win = butWin_create(help, a->env, title, w, h, unmap, map, resize, destroy); if (x != BUT_NOCHANGE) { butWin_setX(help->win, x); butWin_setY(help->win, y); } if (minW != BUT_NOCHANGE) butWin_setMinW(help->win, minW); if (minH != BUT_NOCHANGE) butWin_setMinH(help->win, minH); butWin_setMaxW(help->win, 0); butWin_setMaxH(help->win, 0); butWin_activate(help->win); help->bg = butBoxFilled_create(help->win, 0, BUT_DRAWABLE); if (a->ulPixmap != None) butBoxFilled_setPixmaps(help->bg, a->ulPixmap, a->lrPixmap, a->bgPixmap); help->menu = NULL; help->swin = abutSwin_create(help, help->win, 1, ABUTSWIN_LSLIDE, subWinResize); help->swinW = 0; help->swinH = 0; help->subBg = butPlain_create(help->swin->win, 0, BUT_DRAWABLE, BUT_BG); help->ok = butCt_create(ok, NULL, help->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, a->ok); help->numTextButs = 0; help->maxTextButs = 0; help->textButs = NULL; help->destroyCallback = NULL; help->packet = NULL; abutHelp_newPages(help, menuTitle, pages, numPages); return(help); } void abutHelp_destroy(AbutHelp *help) { assert(MAGIC(help)); butWin_destroy(help->win); } void abutHelp_setDestroyCallback(AbutHelp *help, ButOut (*callback)(AbutHelp *help, void *packet), void *packet) { assert(MAGIC(help)); help->destroyCallback = callback; help->packet = packet; } void abutHelp_newPages(AbutHelp *help, const char *menuTitle, const AbutHelpPage *pages, int numPages) { int i, bw; assert(MAGIC(help)); if (help->menu != NULL) { but_destroy(help->menu); help->menu = NULL; } help->pages = pages; if (help->maxMenuOpts < numPages + 1) { if (help->menuOpts != NULL) wms_free(help->menuOpts); help->maxMenuOpts = numPages + 1; help->menuOpts = wms_malloc(help->maxMenuOpts * sizeof(const char *)); } for (i = 0; i < numPages; ++i) { if (pages[i].pageName == NULL) help->menuOpts[i] = BUTMENU_OLBREAK; else help->menuOpts[i] = pages[i].pageName; } help->menuOpts[i] = BUTMENU_OLEND; help->menu = butMenu_downCreate(newMenuOpt, help, help->win, 1, 2, BUT_DRAWABLE|BUT_PRESSABLE, menuTitle, help->menuOpts, 0); bw = butEnv_stdBw(butWin_env(help->win)); but_resize(help->menu, bw*2, bw*2, butWin_w(help->win) - bw*4, help->abut->butH * 2); abutHelp_newPage(help, 0); } void abutHelp_newPage(AbutHelp *help, int pageNum) { int i; int numTbs; assert(MAGIC(help)); abutSwin_vMove(help->swin, 0); help->curPage = pageNum; for (i = 0; i < help->numTextButs; ++i) but_destroy(help->textButs[i]); for (numTbs = 0; help->pages[pageNum].text[numTbs].text; ++numTbs); if (numTbs > help->maxTextButs) { if (help->textButs) wms_free(help->textButs); help->textButs = wms_malloc(numTbs * sizeof(But *)); help->maxTextButs = numTbs; } help->numTextButs = numTbs; for (i = 0; i < numTbs; ++i) { help->textButs[i] = butTblock_create(help->swin->win, 1, BUT_DRAWABLE, help->pages[pageNum].text[i].text, help->pages[pageNum].text[i].align); butTblock_setFont(help->textButs[i], help->pages[pageNum].text[i].fontNum); } help->swinW = 0; subWinResize(help->swin->win); } static ButOut unmap(ButWin *win) { return(0); } static ButOut map(ButWin *win) { return(0); } static ButOut resize(ButWin *win) { AbutHelp *help = butWin_packet(win); int w, h; int bw = butEnv_stdBw(butWin_env(win)); int physFontH = butEnv_fontH(butWin_env(win), 0); assert(MAGIC(help)); w = butWin_w(win); h = butWin_h(win); but_resize(help->bg, 0, 0, w, h); but_resize(help->menu, bw*2, bw*2, w - bw*4, help->abut->butH * 2); abutSwin_resize(help->swin, bw*2, bw*3 + help->abut->butH * 2, w - bw*4, h - help->abut->butH * 3 - bw*6, (physFontH * 3) / 2, physFontH); butCan_resizeWin(help->swin->win, 0, butWin_w(help->swin->win), TRUE); but_resize(help->ok, bw*2, h - help->abut->butH - bw*2, w - bw*4, help->abut->butH); return(0); } static ButOut destroy(ButWin *win) { AbutHelp *help = butWin_packet(win); ButOut result = 0; assert(MAGIC(help)); if (help->destroyCallback) result = help->destroyCallback(help, help->packet); abutSwin_destroy(help->swin); MAGIC_UNSET(help); wms_free(help); return(result); } static ButOut subWinResize(ButWin *win) { AbutSwin *swin; AbutHelp *help; int i, bw, w, h, y; swin = butWin_packet(win); assert(MAGIC(swin)); help = swin->packet; assert(MAGIC(help)); w = butWin_w(win); h = butWin_h(win); but_resize(help->subBg, 0, 0, w, h); help->swinW = w; bw = butEnv_stdBw(butWin_env(win)); y = bw; for (i = 0; i < help->numTextButs; ++i) y += butTblock_resize(help->textButs[i], bw, y, w - bw*2); if ((help->swinH != y + bw) || (help->swinH != h)) { help->swinH = y + bw; butCan_resizeWin(help->swin->win, help->swinW, help->swinH, TRUE); } return(0); } static ButOut ok(But *but) { butWin_destroy(but_win(but)); return(0); } static ButOut newMenuOpt(But *but, int value) { AbutHelp *help = but_packet(but); assert(MAGIC(help)); if (value != help->curPage) { abutHelp_newPage(help, value); } return(0); } cgoban-1.9.14/wmslib/src/abut/msg.c0000664000671000067100000002611207043224471012502 /* * src/msg.c, part of wmslib library * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include static ButOut unmap(ButWin *win); static ButOut wDestroy(ButWin *win); static ButOut resize(ButWin *win); static ButOut ok_pressed(But *but); static void checkNewSize(AbutMsg *mwin, ButWin *win); static void calcDims(Abut *abut, int fontNum, const char *text, int *w, int *h, int *textH, int numTins); static ButOut msg_resize(ButWin *win, AbutMsg *mwin); static void fillboxDead(But *but); /* * UseMsg is never accessed. We just need a void * guaranteed to be * different from any the user could pass us. */ static int useMsg = 0; AbutMsg *abutMsg_inCreate(Abut *a, ButWin *win, int layer, const char *text, void *packet, int numTins, const AbutMsgTin *tinList) { static AbutMsgOpt ok[1]; static ButKey ka_ok[] = {{XK_Return, 0, ShiftMask}, {XK_KP_Enter, 0, ShiftMask}, {0,0,0}}; ok[0].name = a->ok; ok[0].callback = ok_pressed; ok[0].keyEq = ka_ok; ok[0].packet = &useMsg; return(abutMsg_optInCreate(a, win, layer, text, NULL, NULL, 1, ok, numTins, tinList)); } AbutMsg *abutMsg_optInCreate(Abut *a, ButWin *win, int layer, const char *text, ButOut (*destroy)(void *packet), void *packet, int numButs, const AbutMsgOpt *optList, int numTins, const AbutMsgTin *tinList) { ButEnv *env; AbutMsg *mwin; int winW, winH; int i; void *butPacket; assert(MAGIC(a)); assert(a->env == butWin_env(win)); env = a->env; mwin = wms_malloc(sizeof(AbutMsg)); MAGIC_SET(mwin); mwin->abut = a; mwin->win = win; mwin->numButs = numButs; mwin->buts = wms_malloc(numButs * sizeof(But *)); mwin->numTins = numTins; mwin->tins = wms_malloc(numTins * sizeof(But *)); mwin->tinTitles = wms_malloc(numTins * sizeof(But *)); mwin->butDesc = optList; mwin->destroy = destroy; mwin->packet = packet; mwin->layer = layer; calcDims(a, 0, text, &winW, &winH, &mwin->textH, numTins); mwin->w = winW; mwin->h = winH; mwin->box = butBoxFilled_create(win, layer, BUT_DRAWABLE); but_setPacket(mwin->box, mwin); but_setDestroyCallback(mwin->box, fillboxDead); butBoxFilled_setColors(mwin->box, a->ulColor, a->lrColor, a->bgColor); butBoxFilled_setPixmaps(mwin->box, a->ulPixmap, a->lrPixmap, a->bgPixmap); mwin->text = butTblock_create(win, layer+1, BUT_DRAWABLE, text, butText_just); for (i = 0; i < numButs; ++i) { butPacket = optList[i].packet; if (butPacket == &useMsg) butPacket = mwin; mwin->buts[i] = butCt_create(optList[i].callback, butPacket, win, layer+1, BUT_DRAWABLE|BUT_PRESSABLE, optList[i].name); if (optList[i].keyEq) but_setKeys(mwin->buts[i], optList[i].keyEq); } for (i = 0; i < numTins; ++i) { if (tinList[i].name) mwin->tinTitles[i] = butText_create(win, layer+1, BUT_DRAWABLE, tinList[i].name, butText_left); else mwin->tinTitles[i] = NULL; mwin->tins[i] = butTextin_create(tinList[i].callback, packet, win, layer+1, BUT_DRAWABLE|BUT_PRESSABLE, tinList[i].def, 500); } if (butWin_w(win)) msg_resize(win, mwin); return(mwin); } AbutMsg *abutMsg_winInCreate(Abut *a, const char *title, const char *text, void *packet, int numTins, const AbutMsgTin *tinList) { static AbutMsgOpt ok[1]; static ButKey ka_ok[] = {{XK_Return, 0, ShiftMask|ControlMask}, {XK_KP_Enter, 0, ShiftMask|ControlMask}, {0, 0, 0}}; ok[0].name = a->ok; ok[0].callback = ok_pressed; ok[0].keyEq = ka_ok; ok[0].packet = &useMsg; return(abutMsg_winOptInCreate(a, title, text, NULL, NULL, 1, ok, numTins, tinList)); } AbutMsg *abutMsg_winOptInCreate(Abut *a, const char *title, const char *text, ButOut (*destroy)(void *packet), void *packet, int numButs, const AbutMsgOpt *optList, int numTins, const AbutMsgTin *tinList) { ButEnv *env; AbutMsg *mwin; ButWin *win; int winW, winH; int i; void *butPacket; assert(MAGIC(a)); env = a->env; mwin = wms_malloc(sizeof(AbutMsg)); MAGIC_SET(mwin); mwin->abut = a; mwin->numButs = numButs; mwin->buts = wms_malloc(numButs * sizeof(But *)); mwin->numTins = numTins; mwin->tins = wms_malloc(numTins * sizeof(But *)); mwin->tinTitles = wms_malloc(numTins * sizeof(But *)); mwin->butDesc = optList; mwin->destroy = destroy; mwin->packet = packet; mwin->layer = 0; calcDims(a, 0, text, &winW, &winH, &mwin->textH, numTins); mwin->w = winW; mwin->h = winH; mwin->win = win = butWin_create(mwin, env, title, winW, winH, unmap, NULL, resize, wDestroy); butWin_activate(win); mwin->box = butBoxFilled_create(win, 0, BUT_DRAWABLE); butBoxFilled_setColors(mwin->box, a->ulColor, a->lrColor, a->bgColor); butBoxFilled_setPixmaps(mwin->box, a->ulPixmap, a->lrPixmap, a->bgPixmap); mwin->text = butTblock_create(win, 1, BUT_DRAWABLE, text, butText_just); for (i = 0; i < numButs; ++i) { butPacket = optList[i].packet; if (butPacket == &useMsg) butPacket = mwin; mwin->buts[i] = butCt_create(optList[i].callback, butPacket, win, 1, BUT_DRAWABLE|BUT_PRESSABLE, optList[i].name); if (optList[i].keyEq) but_setKeys(mwin->buts[i], optList[i].keyEq); } for (i = 0; i < numTins; ++i) { mwin->tinTitles[i] = butText_create(win, 1, BUT_DRAWABLE, tinList[i].name, butText_left); mwin->tins[i] = butTextin_create(tinList[i].callback, packet, win, 1, BUT_DRAWABLE|BUT_PRESSABLE, tinList[i].def, 150); if (tinList[i].flags & abutMsgTinFlags_secret) { butTextin_setHidden(mwin->tins[i], TRUE); } } if (butWin_w(win)) msg_resize(win, mwin); return(mwin); } static ButOut unmap(ButWin *win) { butWin_destroy(win); return(0); } static ButOut wDestroy(ButWin *win) { AbutMsg *mwin = butWin_packet(win); ButOut result = 0; assert(MAGIC(mwin)); mwin->win = NULL; if (mwin->buts) { wms_free(mwin->buts); mwin->buts = NULL; } if (mwin->tins) { wms_free(mwin->tins); wms_free(mwin->tinTitles); mwin->tins = NULL; mwin->tinTitles = NULL; } if (mwin->destroy) result = mwin->destroy(mwin->packet); MAGIC_UNSET(mwin); wms_free(mwin); return(result); } static ButOut resize(ButWin *win) { return(msg_resize(win, butWin_packet(win))); } static ButOut msg_resize(ButWin *win, AbutMsg *mwin) { int x, y, w, h, buth; ButEnv *env = butWin_env(win); int bw = butEnv_stdBw(env); int butX, butW, i; int maxTinNameLen = 0, newLen; assert(MAGIC(mwin)); checkNewSize(mwin, win); x = (butWin_w(win) - mwin->w) / 2; y = (butWin_h(win) - mwin->h) / 2; w = mwin->w; h = mwin->h; buth = mwin->abut->butH; but_resize(mwin->box, x,y, w,h); butTblock_resize(mwin->text, x+bw*2, y+bw*2, w - bw*4); for (butX = bw*2, i = 0; i < mwin->numButs; ++i) { butW = (w-bw-butX + (mwin->numButs - i) / 2) / (mwin->numButs - i) - bw; but_resize(mwin->buts[i], x+butX, y+h-bw*2-buth, butW, buth); butX += butW + bw; } for (i = 0; i < mwin->numTins; ++i) { if (mwin->tinTitles[i]) { newLen = butText_resize(mwin->tinTitles[i], x + bw*2, y + h - (buth + bw)*(mwin->numTins - i + 1) - bw*2, buth) + bw; if (newLen > maxTinNameLen) maxTinNameLen = newLen; } } for (i = 0; i < mwin->numTins; ++i) { but_resize(mwin->tins[i], x + bw*2 + maxTinNameLen, y + h - (buth + bw)*(mwin->numTins - i + 1) - bw*2, w - bw*4 - maxTinNameLen, buth); } return(0); } static void checkNewSize(AbutMsg *mwin, ButWin *win) { ButEnv *env = butWin_env(win); int textH, butH; textH = butEnv_fontH(env, 0); butH = mwin->abut->butH; if (textH != mwin->textH) { calcDims(mwin->abut, 0, butTblock_getText(mwin->text), &mwin->w, &mwin->h, &mwin->textH, mwin->numTins); if (mwin->layer == 0) butWin_resize(win, mwin->w, mwin->h); } } static ButOut ok_pressed(But *but) { AbutMsg *msg; msg = but_packet(but); assert(MAGIC(msg)); if (msg->layer == 0) butWin_destroy(msg->win); else abutMsg_destroy(but_packet(but), TRUE); return(0); } void abutMsg_destroy(AbutMsg *msg, bool propagate) { int i; int x = 0, y = 0, w = 0, h = 0; assert(MAGIC(msg)); if (propagate == FALSE) { msg->destroy = NULL; } if (msg->box) { x = but_x(msg->box); y = but_y(msg->box); w = but_w(msg->box); h = but_h(msg->box); } if (msg->buts) { but_setPacket(msg->box, NULL); but_destroy(msg->box); but_destroy(msg->text); for (i = 0; i < msg->numButs; ++i) but_destroy(msg->buts[i]); for (i = 0; i < msg->numTins; ++i) { but_destroy(msg->tins[i]); but_destroy(msg->tinTitles[i]); } } if ((msg->layer == 0) && msg->win) butWin_destroy(msg->win); else { butWin_redraw(msg->win, x, y, w, h); MAGIC_UNSET(msg); wms_free(msg); } } static void calcDims(Abut *abut, int fontNum, const char *text, int *w, int *h, int *textHOut, int numTins) { ButEnv *env = abut->env; int textW, textH, butH, butSpc; int winW, winH, actualH, bw; double b, c; textW = butEnv_textWidth(env, text, fontNum); *textHOut = textH = butEnv_fontH(env, fontNum); butH = abut->butH; bw = butEnv_stdBw(env); butSpc = butH + bw; /* * This is based on the calculations: * winW = 2*winH * (winW - 4*bw) * (winH - (4*bw + butSpc*(numTins + 1))) = textW*textH * Solve for winW... * (winW - 4*bw) * (0.5*winW - 4*bw - butSpc*numTins - butSpc) = * textW*textH * 0.5*winW^2 - winW*(-4*bw-butSpc*numTins-butSpc-2*bw) + * 16*bw*bw+4*bw*butSpc*numTins+4*bw*butSpc - textW*textH = 0 * winW^2 - winW*(-12*bw-2*butSpc*numTins-2*butSpc) + * 32*bw*bw+8*bw*butSpc*numTins+8*bw*butSpc - 2*textW*textH = 0 * Using the quadratic equation, notice a is 1.0, and solve * winW = (-b+sqrt(b*b-4*a*c))/2*a */ b = (double)(-12 * bw - 2 * butSpc * numTins - 2 * butSpc); c = (double)(32*bw*bw + 8*bw*butSpc*numTins + 8*bw*butSpc - 2 * textW*textH); winW = (int)((-b + sqrt(b*b-4*c)) * 0.5 + 0.5); winH = winW / 2; if (winH < 2*textH + butSpc*(numTins + 1) + 4*butEnv_stdBw(env)) winH = 2*textH + butSpc*(numTins + 1) + 4*butEnv_stdBw(env); winW = winH * 2; actualH = butTblock_guessH(env, text, winW - 4*butEnv_stdBw(env), fontNum) + butSpc*(numTins + 1) + 4*butEnv_stdBw(env); if (actualH > winH) { winH = actualH; winW = 2*winH; } *w = winW; *h = winH; } static void fillboxDead(But *but) { AbutMsg *mwin; assert(MAGIC(but)); mwin = but_packet(but); if (mwin) { assert(MAGIC(mwin)); if (mwin->buts) { wms_free(mwin->buts); mwin->buts = NULL; } if (mwin->tins) { wms_free(mwin->tins); wms_free(mwin->tinTitles); mwin->tins = NULL; mwin->tinTitles = NULL; } mwin->box = mwin->text = NULL; mwin->win = NULL; } } cgoban-1.9.14/wmslib/src/abut/swin.c0000664000671000067100000002752207043224471012702 /* * wmslib/src/abut/swin.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #if X11_DISP #include #include #include #include #include #include #ifdef _ABUT_SWIN_H_ Levelization Error. #endif #include "swin.h" /********************************************************************** * Forward Declarations **********************************************************************/ static void draw_uparrow(void *packet, ButWin *win, int x, int y, int w, int h); static void draw_downarrow(void *packet, ButWin *win, int x, int y, int w, int h); static void draw_leftarrow(void *packet, ButWin *win, int x, int y, int w, int h); static void draw_rightarrow(void *packet, ButWin *win, int x, int y, int w, int h); static ButOut pressUp(But *but), pressDown(But *but); static ButOut pressLeft(But *but), pressRight(But *but); static ButOut releaseVArrow(But *but), releaseHArrow(But *but); static ButOut v_moved(But *but, int new_yoff, bool newPress); static ButOut hMoved(But *but, int new_xOff, bool newPress); static void redo_slider(void *packet, int xoff, int yoff, int w, int h, int viewW, int viewH); /********************************************************************** * Functions **********************************************************************/ AbutSwin *abutSwin_create(void *packet, ButWin *parent, int layer, uint flags, ButWinFunc resize) { AbutSwin *swin; ButEnv *env = butWin_env(parent); static ButKey upKeys[] = {{XK_Prior, 0, ShiftMask}, {0,0,0}}; static ButKey downKeys[] = {{XK_Next, 0, ShiftMask}, {0,0,0}}; static ButKey leftKeys[] = {{XK_Left, 0, ShiftMask}, {0,0,0}}; static ButKey rightKeys[] = {{XK_Right, 0, ShiftMask}, {0,0,0}}; butEnv_setChar(env, 1.0, ABUT_UPPIC, draw_uparrow, NULL); butEnv_setChar(env, 1.0, ABUT_DOWNPIC, draw_downarrow, NULL); butEnv_setChar(env, 1.0, ABUT_LEFTPIC, draw_leftarrow, NULL); butEnv_setChar(env, 1.0, ABUT_RIGHTPIC, draw_rightarrow, NULL); swin = wms_malloc(sizeof(AbutSwin)); MAGIC_SET(swin); if (flags & (ABUTSWIN_LSLIDE | ABUTSWIN_RSLIDE)) { swin->up = butAct_vCreate(pressUp, releaseVArrow, swin, parent, layer, BUT_DRAWABLE|BUT_PRESSABLE, ABUT_UPPIC, BUT_SRIGHT|BUT_SLEFT); but_setKeys(swin->up, upKeys); swin->down = butAct_vCreate(pressDown, releaseVArrow, swin, parent, layer, BUT_DRAWABLE|BUT_PRESSABLE, ABUT_DOWNPIC, BUT_SRIGHT|BUT_SLEFT); but_setKeys(swin->down, downKeys); swin->vSlide = butSlide_vCreate(v_moved, swin, parent, layer, BUT_DRAWABLE|BUT_PRESSABLE, 100,10,10); } if (flags & (ABUTSWIN_TSLIDE | ABUTSWIN_BSLIDE)) { swin->left = butAct_vCreate(pressLeft, releaseHArrow, swin, parent, layer, BUT_DRAWABLE|BUT_PRESSABLE, ABUT_LEFTPIC, BUT_SRIGHT|BUT_SLEFT); but_setKeys(swin->left, leftKeys); swin->right = butAct_vCreate(pressRight, releaseHArrow, swin, parent, layer, BUT_DRAWABLE|BUT_PRESSABLE, ABUT_RIGHTPIC, BUT_SRIGHT|BUT_SLEFT); but_setKeys(swin->right, rightKeys); swin->hSlide = butSlide_hCreate(hMoved, swin, parent, layer, BUT_DRAWABLE|BUT_PRESSABLE, 100,10,10); } swin->box = butBox_create(parent, layer, BUT_DRAWABLE); butBox_setColors(swin->box, BUT_SHAD, BUT_LIT); swin->win = butCan_create(swin, parent, layer, resize, NULL, redo_slider); swin->flags = flags; swin->timer = NULL; swin->xCenter = swin->yCenter = 0.0; swin->packet = packet; return(swin); } void abutSwin_resize(AbutSwin *swin, int x, int y, int w, int h, int slideW, int lineH) { int bx, by, bw, bh; int canWinW, canWinH, canViewW, canViewH; int butbw = butEnv_stdBw(butWin_env(swin->win)); int new_yoff = 0, new_xoff = 0; float yratio = swin->yCenter, xratio = swin->xCenter; assert(MAGIC(swin)); if (x == BUT_NOCHANGE) x = swin->x; if (y == BUT_NOCHANGE) y = swin->y; if (w == BUT_NOCHANGE) w = swin->w; if (h == BUT_NOCHANGE) h = swin->h; if (slideW == BUT_NOCHANGE) slideW = swin->slideW; if (lineH == BUT_NOCHANGE) lineH = swin->lineH; swin->x = x; swin->y = y; swin->w = w; swin->h = h; swin->slideW = slideW; swin->lineH = lineH; bx = x; by = y; bw = w; bh = h; if (swin->flags & ABUTSWIN_LSLIDE) { bx += slideW; bw -= slideW; } else if (swin->flags & ABUTSWIN_RSLIDE) { bw -= slideW; } if (swin->flags & ABUTSWIN_TSLIDE) { by += slideW; bh -= slideW; } else if (swin->flags & ABUTSWIN_BSLIDE) { bh -= slideW; } butCan_resizeView(swin->win, bx+butbw,by+butbw, bw-2*butbw,bh-2*butbw, FALSE); canViewW = bw - butbw*2; canViewH = bh - butbw*2; canWinW = butWin_w(swin->win); canWinH = butWin_h(swin->win); if (swin->flags & (ABUTSWIN_TSLIDE|ABUTSWIN_BSLIDE)) { new_xoff = xratio * (canWinW - canViewW) + 0.5; } if (swin->flags & (ABUTSWIN_LSLIDE|ABUTSWIN_RSLIDE)) { new_yoff = yratio * (canWinH - canViewH) + 0.5; } if (new_xoff > canWinW - canViewW) new_xoff = canWinW - canViewW; if (new_yoff > canWinH - canViewH) new_yoff = canWinH - canViewH; if (new_xoff < 0) new_xoff = 0; if (new_yoff < 0) new_yoff = 0; if (swin->flags & ABUTSWIN_LSLIDE) { if (bh - 2*slideW < butbw * 5) { but_resize(swin->up, x, by, slideW, bh/2); but_resize(swin->down, x, by + bh/2, slideW, (bh + 1) / 2); but_resize(swin->vSlide, 0, 0, 0, 0); butSlide_set(swin->vSlide, canWinH - canViewH, new_yoff, canViewH); v_moved(swin->vSlide, new_yoff, FALSE); } else { but_resize(swin->up, x,by,slideW,slideW); but_resize(swin->down, x,by+bh-slideW,slideW,slideW); but_resize(swin->vSlide, x,by+slideW,slideW,bh-2*slideW); butSlide_set(swin->vSlide, canWinH - canViewH, new_yoff, canViewH); v_moved(swin->vSlide, new_yoff, FALSE); } } else if (swin->flags & ABUTSWIN_RSLIDE) { but_resize(swin->up, x+w-slideW,by,slideW,slideW); but_resize(swin->down, x+w-slideW,by+h-slideW,slideW,slideW); but_resize(swin->vSlide, x+w-slideW,by+slideW,slideW,bh-2*slideW); butSlide_set(swin->vSlide, canWinH - canViewH, new_yoff, canViewH); v_moved(swin->vSlide, new_yoff, FALSE); } if (swin->flags & ABUTSWIN_TSLIDE) { but_resize(swin->left, bx, y, slideW, slideW); but_resize(swin->right, bx + bw - slideW, y, slideW, slideW); but_resize(swin->hSlide, bx + slideW, y, bw - 2 * slideW, slideW); butSlide_set(swin->hSlide, canWinW - canViewW, new_xoff, canViewW); v_moved(swin->hSlide, new_xoff, FALSE); } else if (swin->flags & ABUTSWIN_BSLIDE) { but_resize(swin->left, bx, y + h - slideW, slideW, slideW); but_resize(swin->right, bx + bw - slideW, y + h - slideW, slideW, slideW); but_resize(swin->hSlide, bx + slideW, y + h - slideW, bw - 2 * slideW, slideW); butSlide_set(swin->hSlide, canWinW - canViewW, new_xoff, canViewW); v_moved(swin->hSlide, new_xoff, FALSE); } but_resize(swin->box, bx,by,bw,bh); swin->canButW = bw - butbw*2; swin->canButH = bh - butbw*2; } static void draw_uparrow(void *packet, ButWin *win, int x, int y, int w, int h) { XPoint points[3]; Display *dpy = butEnv_dpy(butWin_env(win)); Window xwin = butWin_xwin(win); GC gc = butEnv_gc(butWin_env(win)); h &= ~1; w &= ~1; points[0].x = x; points[0].y = y+h/2; points[1].x = x+w/2; points[1].y = y; points[2].x = x+w; points[2].y = y+h/2; XFillPolygon(dpy, xwin, gc, points, 3, Nonconvex, CoordModeOrigin); } static void draw_downarrow(void *packet, ButWin *win, int x, int y, int w, int h) { XPoint points[3]; Display *dpy = butEnv_dpy(butWin_env(win)); Window xwin = butWin_xwin(win); GC gc = butEnv_gc(butWin_env(win)); h &= ~1; w &= ~1; points[0].x = x; points[0].y = y+h/2; points[1].x = x+w/2; points[1].y = y+h; points[2].x = x+w; points[2].y = y+h/2; XFillPolygon(dpy, xwin, gc, points, 3, Nonconvex, CoordModeOrigin); } static void draw_leftarrow(void *packet, ButWin *win, int x, int y, int w, int h) { XPoint points[3]; Display *dpy = butEnv_dpy(butWin_env(win)); Window xwin = butWin_xwin(win); GC gc = butEnv_gc(butWin_env(win)); h &= ~1; w &= ~1; points[0].x = x; points[0].y = y+h/2; points[1].x = x+w/2; points[1].y = y; points[2].x = x+w/2; points[2].y = y+h; XFillPolygon(dpy, xwin, gc, points, 3, Nonconvex, CoordModeOrigin); } static void draw_rightarrow(void *packet, ButWin *win, int x, int y, int w, int h) { XPoint points[3]; Display *dpy = butEnv_dpy(butWin_env(win)); Window xwin = butWin_xwin(win); GC gc = butEnv_gc(butWin_env(win)); h &= ~1; w &= ~1; points[0].x = x+w; points[0].y = y+h/2; points[1].x = x+w/2; points[1].y = y; points[2].x = x+w/2; points[2].y = y+h; XFillPolygon(dpy, xwin, gc, points, 3, Nonconvex, CoordModeOrigin); } static ButOut pressUp(But *but) { AbutSwin *swin; swin = but_packet(but); assert(MAGIC(swin)); butSlide_startSlide(swin->vSlide, TRUE, -2*swin->lineH, TRUE); return(0); } static ButOut pressDown(But *but) { AbutSwin *swin; swin = but_packet(but); assert(MAGIC(swin)); butSlide_startSlide(swin->vSlide, TRUE, 2*swin->lineH, TRUE); return(0); } static ButOut pressLeft(But *but) { AbutSwin *swin; swin = but_packet(but); assert(MAGIC(swin)); butSlide_startSlide(swin->hSlide, TRUE, -2*swin->lineH, TRUE); return(0); } static ButOut pressRight(But *but) { AbutSwin *swin; swin = but_packet(but); assert(MAGIC(swin)); butSlide_startSlide(swin->hSlide, TRUE, 2*swin->lineH, TRUE); return(0); } static ButOut releaseVArrow(But *but) { AbutSwin *swin = but_packet(but); assert(MAGIC(swin)); butSlide_stopSlide(swin->vSlide); return(0); } static ButOut releaseHArrow(But *but) { AbutSwin *swin = but_packet(but); assert(MAGIC(swin)); butSlide_stopSlide(swin->hSlide); return(0); } void abutSwin_vMove(AbutSwin *swin, int newLoc) { butSlide_set(swin->vSlide, BUT_NOCHANGE, newLoc, BUT_NOCHANGE); v_moved(swin->vSlide, newLoc, FALSE); } static ButOut v_moved(But *but, int new_yoff, bool newPress) { AbutSwin *swin = but_packet(but); assert(MAGIC(swin)); if (butWin_viewH(swin->win) == butWin_h(swin->win)) swin->yCenter = 0.0; else swin->yCenter = (float)new_yoff / (float)(butWin_h(swin->win) - butWin_viewH(swin->win)); if (swin->yCenter > 1.0) swin->yCenter = 1.0; if (swin->yCenter < 0.0) swin->yCenter = 0.0; butCan_slide(swin->win, BUT_NOCHANGE, new_yoff, FALSE); return(0); } static ButOut hMoved(But *but, int newXOff, bool newPress) { AbutSwin *swin = but_packet(but); assert(MAGIC(swin)); if (butWin_viewW(swin->win) == butWin_w(swin->win)) swin->xCenter = 0.0; else swin->xCenter = (float)newXOff / (float)(butWin_w(swin->win) - butWin_viewW(swin->win)); if (swin->xCenter > 1.0) swin->xCenter = 1.0; if (swin->xCenter < 0.0) swin->xCenter = 0.0; butCan_slide(swin->win, newXOff, BUT_NOCHANGE, FALSE); return(0); } void abutSwin_destroy(AbutSwin *swin) { assert(MAGIC(swin)); MAGIC_UNSET(swin); wms_free(swin); } static void redo_slider(void *packet, int xoff, int yoff, int w, int h, int viewW, int viewH) { AbutSwin *swin = packet; assert(MAGIC(swin)); if (swin->flags & (ABUTSWIN_TSLIDE|ABUTSWIN_BSLIDE)) { butSlide_set(swin->hSlide, w-viewW, xoff, viewW); if (viewW == w) swin->xCenter = 0.0; else swin->xCenter = (float)xoff / (float)(w - viewW); } if (swin->flags & (ABUTSWIN_LSLIDE|ABUTSWIN_RSLIDE)) { butSlide_set(swin->vSlide, h-viewH, yoff, viewH); if (viewH == h) swin->yCenter = 0.0; else swin->yCenter = (float)yoff / (float)(h - viewH); } } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/abut/term.c0000664000671000067100000001236407043224471012667 /* * wmslib/src/abut/term.c, part of wmslib (Library functions) * Copyright (C) 1995-1996 William Shubert * See "configure.h.in" for more copyright information. * * Source code for "term" scrolling terminal-like widgety thing. */ #include #include #include #include #include #include #ifdef _ABUT_TERM_H_ Levelization Error. #endif #include "term.h" /********************************************************************** * Forward declarations **********************************************************************/ static ButWinFunc resize; static void curOffWin(But *but, int activeLine, int passiveLine, int mouseY); /********************************************************************** * Functions **********************************************************************/ AbutTerm *abutTerm_create(Abut *abut, ButWin *parent, int layer, bool editable) { AbutTerm *term; assert(MAGIC(abut)); term = wms_malloc(sizeof(AbutTerm)); MAGIC_SET(term); term->abut = abut; term->swin = abutSwin_create(term, parent, layer, BUT_DRAWABLE|BUT_PRESSABLE, resize); if (editable) term->bg = butPlain_create(term->swin->win, 0, BUT_DRAWABLE, BUT_HIBG); else term->bg = butPlain_create(term->swin->win, 0, BUT_DRAWABLE, BUT_BG); term->tbin = butTbin_create(term->swin->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, ""); if (!editable) butTbin_setReadOnly(term->tbin, TRUE); butTbin_setOffWinCallback(term->tbin, curOffWin); term->state = abutTermState_steady; return(term); } void abutTerm_destroy(AbutTerm *term) { assert(MAGIC(term)); MAGIC_UNSET(term); } void abutTerm_set(AbutTerm *term, const char *text) { ButEnv *env; assert(MAGIC(term)); env = term->abut->env; butTbin_set(term->tbin, text); butCan_resizeWin(term->swin->win, 0, butTbin_numLines(term->tbin) * butEnv_fontH(env, 0) + butEnv_stdBw(env) * 2, TRUE); } void abutTerm_resize(AbutTerm *term, int x, int y, int w, int h) { int fontH = butEnv_fontH(term->abut->env, 0); int bw = butEnv_stdBw(term->abut->env); assert(MAGIC(term)); abutSwin_resize(term->swin, x, y, w, h, (fontH * 3) / 2, fontH); butCan_resizeWin(term->swin->win, 0, butTbin_numLines(term->tbin) * fontH + bw * 2, TRUE); } static ButOut resize(ButWin *win) { AbutSwin *swin = butWin_packet(win); AbutTerm *term = swin->packet; char *temp; int w, h, len; int bw; assert(MAGIC(swin)); assert(MAGIC(term)); w = butWin_w(win); h = butWin_h(win); but_resize(term->bg, 0,0, w,h); bw = butEnv_stdBw(term->abut->env); if (but_w(term->tbin) == w) { but_resize(term->tbin, 0,bw, w,h - bw); } else { /* * This is a mega-cheesy kludge to work around the non-resizability of * a tbin widget. Basically I cut the whole terminal script, clear it, * resize the tbin, then paste it all back in. Ugh. */ len = butTbin_len(term->tbin); temp = wms_malloc(len + 1); memcpy(temp, butTbin_get(term->tbin), len); temp[len] = '\0'; butTbin_set(term->tbin, ""); but_resize(term->tbin, 0,bw, w,h - bw); butTbin_set(term->tbin, temp); wms_free(temp); } return(0); } static void curOffWin(But *but, int activeLine, int passiveLine, int mouseY) { ButWin *win = but_win(but); ButEnv *env = butWin_env(win); AbutSwin *swin = butWin_packet(win); AbutTerm *term; int y, h, bw = butEnv_stdBw(env); int lines; AbutTermState newState; assert(MAGIC(swin)); term = swin->packet; assert(MAGIC(term)); newState = abutTermState_steady; h = butEnv_fontH(env, 0); y = activeLine * h + bw; if (passiveLine != activeLine) { if (y <= butCan_yOff(win) + bw) { if (mouseY < butCan_yOff(win) - h) newState = abutTermState_fastUp; else if (mouseY < butCan_yOff(win)) newState = abutTermState_slowUp; } else if (y + h + bw >= butCan_yOff(win) + butWin_viewH(win)) { if (mouseY > butCan_yOff(win) + butWin_viewH(win) + h) newState = abutTermState_fastDown; else if (mouseY > butCan_yOff(win) + butWin_viewH(win)) newState = abutTermState_slowDown; } } if (newState != term->state) { term->state = newState; switch(newState) { case abutTermState_fastUp: butSlide_startSlide(swin->vSlide, FALSE, -h*10, FALSE); break; case abutTermState_slowUp: butSlide_startSlide(swin->vSlide, FALSE, -h, FALSE); break; case abutTermState_steady: butSlide_stopSlide(swin->vSlide); break; case abutTermState_slowDown: butSlide_startSlide(swin->vSlide, FALSE, h, FALSE); break; case abutTermState_fastDown: butSlide_startSlide(swin->vSlide, FALSE, h*10, FALSE); break; } } if (passiveLine == activeLine) { lines = butTbin_numLines(but); if (activeLine >= lines) lines = activeLine + 1; if (lines * h + bw * 2 > butWin_h(win)) { butCan_resizeWin(swin->win, 0, lines * h + bw * 2, TRUE); } if (y < butCan_yOff(win)) { y -= bw; butCan_slide(win, BUT_NOCHANGE, y, TRUE); } else if (y + h > butCan_yOff(win) + butWin_viewH(win)) { y = y + h + bw - butWin_viewH(win); butCan_slide(win, BUT_NOCHANGE, y, TRUE); } } } cgoban-1.9.14/wmslib/src/but/0000777000671000067100000000000007606355253011477 5cgoban-1.9.14/wmslib/src/but/box.h0000664000671000067100000000350607043224471012352 /* * wmslib/src/but/box.h, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for but.c */ #ifndef _BUT_BOX_H_ #ifndef _BUT_BUT_H_ #include #endif #define _BUT_BOX_H_ 1 /********************************************************************** * Constants **********************************************************************/ #define BUT_ALEFT 0x01 /* Arrows on left/right. */ #define BUT_ARIGHT 0x02 #define BUT_RLEFT 0x04 /* Rounded edges on left/right. */ #define BUT_RRIGHT 0x08 #define BUT_SLEFT 0x10 /* Square edges on left/right. */ #define BUT_SRIGHT 0x20 /********************************************************************** * Functions **********************************************************************/ /* Public. */ extern But *butBox_create(ButWin *win, int layer, int flags); extern void butBox_setColors(But *but, int ul, int lr); extern void butBox_setPixmaps(But *but, Pixmap ul, Pixmap lr); extern But *butBoxFilled_create(ButWin *win, int layer, int flags); extern void butBoxFilled_setColors(But *but, int ul, int lr, int c); extern void butBoxFilled_setPixmaps(But *but, Pixmap ul, Pixmap lr, Pixmap c); /* Private. */ extern void but_drawCtb(ButWin *win, int flags, int fgpic, int bgpic, int pbgpic, int x, int y, int w, int h, int bw, int angles); extern void but_drawCt(ButWin *win, int flags, int fgpic, int bgpic, int pbgpic, int x, int y, int w, int h, int bw, const char *text, int angles, int fontnum); /* If bstate is nonzero, invert the ul and lr colors. */ extern void but_drawBox(ButWin *win, int x, int y, int w, int h, int bstate, int bw, int angles, int ulcolor, int lrcolor, Pixmap ulmap, Pixmap lrmap); #endif /* _BUT_BOX_H_ */ cgoban-1.9.14/wmslib/src/but/but.h0000664000671000067100000004163507043224471012361 /* * wmslib/include/but/but.h, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for auxiliary button code. */ #ifndef _BUT_BUT_H_ #define _BUT_BUT_H_ 1 #include #include #if HAVE_SYS_SELECT_H #include #endif /********************************************************************** * Forward declarations **********************************************************************/ typedef struct ButTimer_struct ButTimer; typedef struct ButWin_struct ButWin; typedef struct ButLnet_struct ButLnet; typedef struct ButRnet_struct ButRnet; typedef struct ButEnv_struct ButEnv; typedef struct But_struct But; #include /********************************************************************** * Constants **********************************************************************/ #define BUT_DCLICK 350 /* Time between double clicks; should probably */ /* be settable by the user. */ /********************************************************************** * Types **********************************************************************/ #define BUTOUT_STOPWAIT 0x01 #define BUTOUT_ERR 0x02 #define BUTOUT_CAUGHT 0x04 #define BUTOUT_STILLBUTS 0x08 #define BUTOUT_IGNORE 0x10 /* Used by canvases. */ typedef uint ButOut; typedef ButOut ButWinFunc(struct ButWin_struct *win); typedef struct ButAction_struct { ButOut (*mMove)(But *but, int x, int y); ButOut (*mLeave)(But *but); ButOut (*mPress)(But *but, int butnum, int x, int y); ButOut (*mRelease)(But *but, int butnum, int x, int y); ButOut (*kPress)(But *but, const char *str, KeySym sym); ButOut (*kRelease)(But *but, const char *str, KeySym sym); void (*draw)(But *but, int x, int y, int w, int h); ButOut (*destroy)(But *but); void (*newFlags)(But *but, uint nfl); ButOut (*netMessage)(But *but, void *msg, int msgLen); /* resize returns TRUE if redraws are needed for old & new position. */ bool (*resize)(But *but, int oldX, int oldY, int oldW, int oldH); } ButAction; typedef struct ButColor_struct { int red, green, blue, greyLevel; } ButColor; typedef struct ButSet_struct { int numButs; bool dynamic; /* If TRUE, then buts should be freed when you're done. */ But **buts; int maxButs; MAGIC_STRUCT } ButSet; typedef struct ButWinArea_struct { int x, y, w, h; } ButWinArea; struct ButWin_struct { struct ButWin_struct *parent; /* NULL unless you're a canvas. */ struct But_struct *parentBut; /* NULL unless you're a canvas. */ void *packet, *iPacket; Window win, physWin; struct ButWin_struct *iconWin; const char *name; bool iconic, isIcon; int x,y,w,h, xOff, yOff, minWRatio, minHRatio, maxWRatio, maxHRatio; int minW, minH, maxW, maxH, wStep, hStep; int logicalW, logicalH; /* Same as w&h except for canvases. */ bool resized, resizeNeeded, redrawReady; ButWinArea *redraws; int numRedraws, maxRedraws; int id; bool mapped; ButWinFunc *unmap, *map, *resize, *destroy, *quit; ButEnv *env; int minLayer, maxLayer; struct ButSet_struct butsNoDraw; But *lock, *butIn; But *keyBut; int numCols, maxCols; struct ButCol_struct *cols; MAGIC_STRUCT }; typedef struct ButWrite_struct { double width; void *packet; void (*draw)(void *packet, ButWin *win, int x, int y, int w, int h); } ButWrite; #define BUTWRITE_MINPRINT '\t' #define BUTWRITE_MAXCHARS (BUTWRITE_MINPRINT*256-256) typedef struct ButFdCallback_struct { ButOut (*callback)(void *packet, int fd); void *packet; } ButFdCallback; struct ButEnv_struct { char *protocol; void *packet; Display *dpy; int (*shutdown)(Display *dpy); GC gc, gc2; Pixmap stipDisable; bool colorp; /* TRUE if color, FALSE if b/w. */ int numColors; ulong *colors; Pixmap greyMaps[17]; Pixmap *colorPmaps; int numFonts; XFontStruct **fonts; int font0h, depth, rootW, rootH; int stdButBw; Atom prop; bool (*sReq)(ButEnv *env, XSelectionRequestEvent *xsre); int (*sClear)(ButEnv *env); int (*sNotify)(ButEnv *env, XSelectionEvent *xsnot); struct ButWin_struct **winlist; int minWindows, wllen, wlmax; But *butIn, *lockBut; struct ButWin_struct *last_mwin; int last_mx, last_my; ButEnv *next; struct ButWrite_struct write[BUTWRITE_MAXCHARS]; uint keyModifiers; Time eventTime; /* But & kbd PRESS or RELEASE or MOVE events. */ int eventNum; /* But & kbd PRESS events ONLY. */ int maxFd, maxGFds[3]; fd_set fMasks[3]; ButFdCallback *fCallbacks[3]; /* These are set up in the rc (remote cusor) file. */ int cur_mnum, new_mnum; Cursor cursors[BUTCUR_NUM]; Pixmap cpic[BUTCUR_NUM], cmask[BUTCUR_NUM], *cstore; struct ButRnet_struct **partners; int partner, numPartners; int maxButIds, maxWinIds; But **id2But; struct ButWin_struct **id2Win; ButCur curnum, curlast; Window curwin; But *curhold; MAGIC_STRUCT }; typedef struct ButKey_struct { KeySym key; uint modifiers; uint modMask; } ButKey; struct But_struct { void *uPacket; /* Packet of user information. */ void *iPacket; /* Packet unique to this button type. */ struct ButWin_struct *win; int layer; int x, y, w, h, id; unsigned flags; const ButKey *keys; /* A list of keys that map to this button. */ const ButAction *action; void (*destroyCallback)(struct But_struct *but); MAGIC_STRUCT }; typedef struct ButRow_struct { int startY, numButs, maxButs; But **buts; MAGIC_STRUCT } ButRow; typedef struct ButCol_struct { int startX; int numRows, maxRows; struct ButRow_struct *rows; MAGIC_STRUCT } ButCol; #define butEnv_setXFg(env, colornum) \ do { \ if (env->colorp) \ XSetForeground(env->dpy, env->gc, env->colors[colornum]); \ else \ XSetTile(env->dpy, env->gc, env->colorPmaps[colornum]); \ } while (0) #define butEnv_stdFill(env) \ do { \ if (env->colorp) \ XSetFillStyle(env->dpy, env->gc, FillSolid); \ else \ XSetFillStyle(env->dpy, env->gc, FillTiled); \ } while (0) #define butEnv_setXFg2(env, colornum) \ do { \ if (env->colorp) \ XSetForeground(env->dpy, env->gc2, env->colors[colornum]); \ else \ XSetTile(env->dpy, env->gc2, env->colorPmaps[colornum]); \ } while (0) #define butEnv_stdFill2(env) \ do { \ if (env->colorp) \ XSetFillStyle(env->dpy, env->gc2, FillSolid); \ else \ XSetFillStyle(env->dpy, env->gc2, FillTiled); \ } while (0) extern Atom but_myProp, but_wmDeleteWindow, but_wmProtocols; extern struct ButTimer_struct *but_timerList; extern bool but_inEvent; extern void butWin_turnOnTimers(ButWin *win); extern void butWin_turnOffTimers(ButWin *win); extern ButOut butWin_delete(ButWin *win); extern ButOut but_dList(But *but); extern ButOut butWin_dList(ButWin *win); /* From "write.c" */ extern void butWin_write(ButWin *win, int x, int y, const char *text, int font); /* Functions available to the buttons. */ extern void butEnv_deinit(ButEnv *env); extern But *but_create(ButWin *win, void *iPacket, const ButAction *action); extern void but_init(But *but); extern ButOut but_delete(But *but); #define but_getFlags(b) ((b)->flags) extern void but_newFlags(But *but, uint newflags); extern void but_flags(But *but, uint newflags); /* Private. */ extern void but_draw(But *but); extern void butWin_redraw(ButWin *win, int x, int y, int w, int h); extern void butWin_performDraws(ButWin *win); extern void but_resize(But *but, int x, int y, int w, int h); extern ButOut butWin_mMove(ButWin *win, int x, int y); extern ButOut butWin_mPress(ButWin *win, int x, int y, int butnum); extern ButOut butWin_mRelease(ButWin *win, int x, int y, int butnum); extern ButOut butWin_kPress(ButWin *win, const char *kstring, KeySym sym); extern ButOut butWin_kRelease(ButWin *env, const char *kstring, KeySym sym); /* Functions for internal use only. */ /* In but_finder.c */ void butSet_destroy(ButSet *butset); extern ButWin *butEnv_findWin(ButEnv *env, Window win); extern void butWin_addToTable(ButWin *win); extern void butWin_rmFromTable(ButWin *win); extern void but_addToTable(But *but); extern void but_delFromTable(But *but); extern void butWin_findButSet(ButWin *win, int x, int y, ButSet *butset); extern void butWin_findButSetInRegion(ButWin *win, int x,int y, int w,int h, ButSet *butset); extern But *butWin_findButsInRegion(ButWin *win, int x,int y, int w,int h, bool (*action)(But *but, void *packet), void *packet); void butSet_addBut(ButSet *butset, But *but); void butSet_delBut(ButSet *butset, But *but); /* From "ctext.c" */ extern Snd but_downSnd, but_upSnd; /********************************************************************** * Forward declarations **********************************************************************/ /* These are all bits for the flags arguments to button functions. */ #define BUT_DRAWABLE 0x0001 /* Can be drawn. */ #define BUT_PRESSABLE 0x0002 /* Can be pressed. */ #define BUT_TWITCHABLE 0x0004 /* Changes when mouse goes over it. */ #define BUT_KEYED 0x0008 /* Keys pressed land in this button. */ #define BUT_PRESSTHRU 0x0010 #define BUT_PRESSED 0x0020 #define BUT_TWITCHED 0x0040 #define BUT_KEYPRESSED 0x0080 #define BUT_KEYACTIVE 0x0100 /* Read only; set if recvs keypresses. */ #define BUT_TABLED 0x0200 /* Private. Don't touch. */ #define BUT_LOCKED 0x0400 #define BUT_OPAQUE 0x0800 /* Solidly fills rectangle. */ #define BUT_DEAD 0x1000 /* Marked for death! */ #define BUT_NETPRESS 0x2000 #define BUT_NETTWITCH 0x4000 #define BUT_NETKEY 0x8000 #define BUT_MAXBITS 16 #define BUT_NODRAW (BUT_DRAWABLE<packet) #define butEnv_dpy(env) ((env)->dpy) #define butEnv_gc(env) ((env)->gc) #define butEnv_color(env, cnum) ((env)->colors[cnum]) #define butEnv_isColor(env) ((env)->colorp) #define butEnv_pixmap(env, cnum) ((env)->colorPmaps[cnum]) #define butEnv_fontStr(env, fnum) ((env)->fonts[fnum]) #define butEnv_stdBw(env) ((env)->stdButBw) #define butEnv_keyModifiers(env) ((env)->keyModifiers) #define butWin_packet(win) ((win)->packet) #define butWin_env(win) ((win)->env) #define butWin_xwin(bwin) ((bwin)->win) #define butWin_w(win) ((win)->logicalW) #define butWin_h(win) ((win)->logicalH) #define butWin_viewW(win) ((win)->w) #define butWin_viewH(win) ((win)->h) #define butWin_x(win) ((win)->x) #define butWin_y(win) ((win)->y) #define butWin_xoff(win) ((win)->xOff) #define butWin_yoff(win) ((win)->yOff) #define butWin_setPacket(win, p) ((win)->packet = (p)) #define butWin_setQuit(win, q) ((win)->quit = (q)) #define butWin_setDestroy(win, d) ((win)->destroy = (d)) #define but_win(but) ((but)->win) #define but_packet(but) ((but)->uPacket) #define but_setPacket(but, val) ((but)->uPacket = (val)) #define but_x(but) ((but)->x) #define but_y(but) ((but)->y) #define but_w(but) ((but)->w) #define but_h(but) ((but)->h) #define but_setDestroyCallback(but, v) ((but)->destroyCallback = (v)) /* * but_events keeps servicing events until one returns BUT_OUT_STOPWAIT. */ extern void butEnv_events(ButEnv *env); extern ButEnv *butEnv_create(const char *protocol, const char *dpyname, int shutdown(Display *dpy)); extern ButEnv *butEnv_createNoDpy(const char *protocol); /* * but_env_init() returns: * 0 - Black and white display or color=FALSE. * 1 - Couldn't allocate standard colors. Failed. * 2 - Color successful. * 3 - Truecolor display. Color will always be successful. */ extern int butEnv_init(ButEnv *env, void *packet, const char *atomname, bool color); extern void butEnv_destroy(ButEnv *env); extern bool butEnv_setFont(ButEnv *env, int fontnum, const char *fontname, int fparam); #define butEnv_fontH(env, fnum) \ ((env)->fonts[fnum]->ascent + (env)->fonts[fnum]->descent) /* drawall is typically used after changing fonts, etc. */ extern void butEnv_drawAll(ButEnv *env); extern void butEnv_resizeAll(ButEnv *env); extern void but_draw(But *but); extern void but_destroy(But *but); extern void but_resize(But *but, int x, int y, int w, int h); #define butEnv_localContext(env) ((env)->localContext) #define butEnv_context(env) ((env)->context) extern void but_setId(But *but, int id); extern void butWin_setId(ButWin *win, int id); #define BUT_READFILE 0 #define BUT_WRITEFILE 1 #define BUT_XFILE 2 extern void butEnv_addFile(ButEnv *env, int group, int fd, void *packet, ButOut (*callback)(void *packet, int fd)); extern void butEnv_rmFile(ButEnv *env, int group, int fd); extern ButWin *butWin_iCreate(void *packet, ButEnv *env, const char *name, int w, int h, ButWin **iWin, bool iconic, int iW, int iH, ButWinFunc *unmap, ButWinFunc *map, ButWinFunc *resize, ButWinFunc *iResize, ButWinFunc *destroy); #define butWin_create(p,e,n,w,h,un,ma,re,de) \ butWin_iCreate(p,e,n,w,h,NULL,FALSE,0,0,un,ma,re,NULL,de) extern void butWin_setGeom(ButWin *win, const char *geometry); extern void butWin_setX(ButWin *win, int x); extern void butWin_setY(ButWin *win, int y); extern void butWin_setMinW(ButWin *win, int minW); extern void butWin_setMinH(ButWin *win, int minH); extern void butWin_setMaxW(ButWin *win, int maxW); extern void butWin_setMaxH(ButWin *win, int maxH); extern void butWin_setWHRatio(ButWin *win, int w, int h); extern void butWin_setWHRatios(ButWin *win, int minW, int minH, int maxW, int maxH); extern void butWin_setWStep(ButWin *win, int wStep); extern void butWin_setHStep(ButWin *win, int hStep); #define butWin_getMinW(w) ((w)->minW) #define butWin_getMinH(w) ((w)->minH) #define butWin_getMaxW(w) ((w)->maxW) #define butWin_getMaxH(w) ((w)->maxH) #define butWin_getWStep(w) ((w)->wStep) #define butWin_getHStep(w) ((w)->hStep) extern void butWin_activate(ButWin *win); extern void butWin_checkDims(ButWin *win); /* Private. */ extern void butWin_resize(ButWin *win, int newW, int newH); extern void butWin_destroy(ButWin *xw); /* grey is 0..16 */ extern ButColor butColor_create(int r, int g, int b, int grey); /* The output color will have bw_greyscale same as c1's. */ extern ButColor butColor_mix(ButColor c1, int r1, ButColor c2, int r2); extern bool butEnv_setColor(ButEnv *env, int colornum, ButColor color); XImage *butEnv_imageCreate(ButEnv *env, int w, int h); void butEnv_imageDestroy(XImage *image); /* From "i_general.c" */ extern void but_setFlags(But *but, uint fch); extern void but_setKeys(But *but, const ButKey *keys); /* From "but_write.c" */ extern void butEnv_setChar(ButEnv *env, double wratio, const char *id, void (*draw)(void *packet, ButWin *win, int x, int y, int w, int h), void *packet); extern int butEnv_textWidth(ButEnv *env, const char *text, int fnum); extern int butEnv_charWidth(ButEnv *env, const char *text, int fnum); /* From "but_textin.c" */ #define BUT_NOCHANGE (1 << (sizeof(int)*8-2)) #endif /* _BUT_BUT_H_ */ cgoban-1.9.14/wmslib/src/but/canvas.h0000664000671000067100000000242007043224471013027 /* * wmslib/include/but/canvas.h, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for canvas.c */ #ifndef _BUT_CANVAS_H_ #define _BUT_CANVAS_H_ 1 /********************************************************************** * Functions. **********************************************************************/ extern ButWin *butCan_create(void *packet, ButWin *parent, int layer, ButWinFunc *resize, ButWinFunc *destroy, void (*change)(void *packet, int xOff, int yOff, int w, int h, int viewW, int viewH)); /* Any values of BUT_NOCHANGE in this function will be left unchanged. */ extern void butCan_resizeView(ButWin *win, int x, int y, int w, int h, bool propagate); extern void butCan_slide(ButWin *win, int xOff, int yOff, bool propagate); extern void butCan_resizeWin(ButWin *win, int w, int h, bool propagate); #define butCan_xOff(win) ((win)->xOff) #define butCan_yOff(win) ((win)->yOff) extern void butCan_destroy(ButWin *can); /* Private. */ extern Window butCan_xWin(ButWin *win); extern void butCan_redrawn(ButWin *win, int x,int y, int w,int h); extern void butCan_winDead(ButWin *win); #endif /* _BUT_CANVAS_H_ */ cgoban-1.9.14/wmslib/src/but/checkbox.h0000664000671000067100000000124607043224471013347 /* * wmslib/src/but/checkbox.h, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for checkbox.c */ #ifndef _BUT_CHECKBOX_H_ #define _BUT_CHECKBOX_H_ 1 /********************************************************************** * Functions **********************************************************************/ extern But *butCb_create(ButOut (*func)(But *but, bool value), void *packet, ButWin *win, int layer, int flags, bool on); extern bool butCb_get(But *but); extern void butCb_set(But *but, bool on, bool makeCallback); #endif /* _BUT_CHECKBOX_H_ */ cgoban-1.9.14/wmslib/src/but/ctext.h0000664000671000067100000000224607043224471012711 /* * wmslib/src/but/ctext.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for ctext.c */ #ifndef _BUT_CTEXT_H_ #define _BUT_CTEXT_H_ 1 #include /********************************************************************** * Functions **********************************************************************/ extern But *butCt_create(ButOut (*func)(But *but), void *packet, ButWin *win, int layer, int flags, const char *text); extern void butCt_setText(But *info, const char *text); extern But *butAct_create(ButOut (*func)(But *but), void *packet, ButWin *win, int layer, int flags, const char *text, int angleflags); extern But *butAct_vCreate(ButOut (*pfunc)(But *but), ButOut (*rfunc)(But *but), void *packet, ButWin *win, int layer, int flags, const char *text, int angleflags); #define butAct_setText butCt_setText extern void butCt_setNetAction(But *but, bool netAction); #define butAct_setNetAction butCt_setNetAction extern void butCt_setTextLoc(But *but, int x, int y, int w, int h); #endif /* _BUT_CTEXT_H_ */ cgoban-1.9.14/wmslib/src/but/i_finder.h0000664000671000067100000000043607043224471013340 /* * wmslib/src/but/i_finder.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for i_finder.c */ #ifndef _BUT_I_FINDER_H_ #define _BUT_I_FINDER_H_ 1 #endif /* _BUT_I_FINDER_H_ */ cgoban-1.9.14/wmslib/src/but/i_general.h0000664000671000067100000000045607043224471013510 /* * wmslib/src/but/i_general.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for auxiliary button code. */ #ifndef _BUT_I_GENERAL_H_ #define _BUT_I_GENERAL_H_ 1 #endif /* _BUT_I_GENERAL_H_ */ cgoban-1.9.14/wmslib/src/but/i_snd.h0000664000671000067100000000041707043224471012654 /* * wmslib/src/but/i_snd.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for i_snd.c */ #ifndef _BUT_I_SND_H_ #define _BUT_I_SND_H_ 1 #endif /* _BUT_I_SND_H_ */ cgoban-1.9.14/wmslib/src/but/i_win.h0000664000671000067100000000041707043224471012665 /* * wmslib/src/but/i_win.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for i_win.c */ #ifndef _BUT_I_WIN_H_ #define _BUT_I_WIN_H_ 1 #endif /* _BUT_I_WIN_H_ */ cgoban-1.9.14/wmslib/src/but/list.h0000664000671000067100000000227507043224471012537 /* * wmslib/src/but/list.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for list.c */ #ifndef _BUT_LIST_H_ #define _BUT_LIST_H_ 1 #ifndef _BUT_TEXT_H_ #include #endif /********************************************************************** * Functions **********************************************************************/ extern But *butList_create(ButOut (*func)(But *but, int line), void *packet, ButWin *win, int layer, int flags); extern void butList_setTabs(But *but, const int *tabs, const ButTextAlign *tabAligns, int numTabs); extern void butList_changeLine(But *but, int line, const char *text); extern void butList_resize(But *list, int x, int y, int w); extern const char *butList_get(But *but, int line); /* * setPress is automatically set to TRUE when a changeLine to a nonempty * string is done, and set to FALSE when changeLine to an empty string * is done. */ extern void butList_setPress(But *but, int line, bool pressable); extern void butList_setLen(But *but, int newLen); extern int butList_len(But *but); #endif /* _BUT_LIST_H_ */ cgoban-1.9.14/wmslib/src/but/menu.h0000664000671000067100000000361207043224471012524 /* * wmslib/src/but/menu.h, part of wmslib (Library functions) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for menu.c */ #ifndef _BUT_MENU_H_ #define _BUT_MENU_H_ 1 /********************************************************************** * Constants **********************************************************************/ #define BUTMENU_OLEND NULL #define BUTMENU_OLBREAK (&butMenu_dummy) #define BUTMENU_DISABLED 1 /* Flags. */ #define BUTMENU_END 2 /* Private. */ #define BUTMENU_BREAK 4 /* Private. */ /********************************************************************** * Global variables **********************************************************************/ /* Private. */ extern char butMenu_dummy; /********************************************************************** * Functions **********************************************************************/ extern But *butMenu_upCreate(ButOut (*func)(But *but, int value), void *packet, ButWin *win, int layer, int toplayer, int flags, const char *title, const char *optlist[], int cur_opt); extern But *butMenu_downCreate(ButOut (*func)(But *but, int value), void *packet, ButWin *win, int layer, int toplayer, int flags, const char *title, const char *optlist[], int cur_opt); extern void butMenu_set(But *but, int new_opt); extern int butMenu_get(But *but); extern void butMenu_setColor(But *but, int fg, int bg); /* If newcval is -1, then it will be left unchanged. */ extern void butMenu_setText(But *but, const char *title, const char *optlist[], int newcval); extern void butMenu_setOptionName(But *but, const char *new, int entryNum); /* * flags should be from the BUTMENU_DISABLED list above. */ extern void butMenu_setFlags(But *but, int optnum, uint flags); #endif /* _BUT_MENU_H_ */ cgoban-1.9.14/wmslib/src/but/menu_snd.h0000664000671000067100000000076307043224471013374 /* * wmslib/src/but/menu_snd.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for menu_snd.c */ #ifndef _BUT_MENU_SND_H_ #define _BUT_MENU_SND_H_ 1 /********************************************************************** * Global variables **********************************************************************/ extern Snd butMenu_openSnd, butMenu_closeSnd; #endif /* _BUT_MENU_SND_H_ */ cgoban-1.9.14/wmslib/src/but/net.h0000664000671000067100000001142507043224471012347 /* * wmslib/include/but/net.h, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for button networking. */ #ifndef _BUTNET_H_ #define _BUTNET_H_ 1 #include /********************************************************************** * Constants **********************************************************************/ /* Public. */ #define BUTNET_MAXCMD (16*1024) /* Max length of 1 net command. */ /* Private. */ /* * These really should be an enum, but then I'd be treating the enum like an * int when I do int_stdInt32() to it, so I may as well just leave it as * an int. */ #define BUTNET_PROTOWHO 0 #define BUTNET_CLOSE 1 #define BUTNET_USERDATA 2 #define BUTNET_MOUSE 3 #define BUTNET_MOUSEACK 4 #define BUTNET_NEWFLAGS 5 #define BUTNET_BUTSPEC 6 /********************************************************************** * Types **********************************************************************/ /* Private. */ struct ButLnet_struct { struct ButEnv_struct *env; void *packet; bool valid, error; int errNum; char *protocol; ButOut (*ocallback)(struct ButRnet_struct *net); ButOut (*callback)(struct ButRnet_struct *net, void *cmd, int cmdLen); ButOut (*ccallback)(struct ButRnet_struct *net, const char *reason); int fd; MAGIC_STRUCT }; /* ButLnet typedef in but.h */ typedef enum { butRnetState_pwWait, butRnetState_pwAccWait, butRnetState_accWait, butRnetState_open, butRnetState_closing, butRnetState_closed } ButRnetState; typedef struct ButNetMsg_struct { StdInt32 length; StdInt32 type; union { struct { StdInt32 context; /* This is the client's new context. */ char proto[100]; char who[100]; } protoWho; char close[BUTNET_MAXCMD]; char userData[BUTNET_MAXCMD]; struct { StdInt32 context, win, type, x,y, w,h; } mouse; /* mouseAck needs no data. */ struct { StdInt32 butId; StdInt32 newFlags; } newFlags; struct { StdInt32 butId; char butData[BUTNET_MAXCMD - sizeof(StdInt32)]; } butSpec; } perType; } ButNetMsg; struct ButRnet_struct { struct ButEnv_struct *env; int partner, rmtPartner; void *packet; ButRnetState state; bool error, lookupError, butNetError; int errNum; const char *who, *protocol; ButOut (*ocallback)(struct ButRnet_struct *net); ButOut (*callback)(struct ButRnet_struct *net, void *cmd, int cmdLen); ButOut (*ccallback)(struct ButRnet_struct *net, const char *reason); int wBufSize, wBufStart, wBufLen; char *wBuffer; int rBufAmt; /* How much stuff in the rBuffer? */ int rBufLen; int rBufMsgLen; struct ButNetMsg_struct rBuffer; int fd; int lWinId, lx,ly, lw,lh, lType; int lPress, lTwitch; ButRcur rc; bool ackNeeded, mouseMove; MAGIC_STRUCT }; /* ButLnet typedef in but.h */ /********************************************************************** * Functions **********************************************************************/ /* Public. */ #define butRnet_valid(net) ((net)->state == butRnetState_open) #define butRnet_error(net) ((net)->error) #define butRnet_lookupError(net) ((net)->lookupError) #define butRnet_specialError(net) ((net)->specialError) #define butRnet_errNum(net) ((net)->errNum) #define butRnet_packet(net) ((net)->packet) #define butRnet_who(net) ((net)->who) #define butRnet_protocol(net) ((net)->protocol) #define butLnet_valid(net) ((net)->valid) #define butLnet_error(net) ((net)->error) #define butLnet_errNum(net) ((net)->errNum) #define butLnet_packet(net) ((net)->packet) /* * butLnet_create and butRnet_create will return NULL if the system was * compiled without sockets available. */ extern ButLnet *butLnet_create(ButEnv *env, int port, void *packet, ButOut ocallback(ButRnet *net), ButOut callback(ButRnet *net, void *cmd, int cmdLen), ButOut ccallback(ButRnet *net, const char *reason)); extern void butLnet_destroy(ButLnet *net); extern ButRnet *butRnet_create(ButEnv *env, const char *address, int port, void *packet, ButOut ocallback(ButRnet *net), ButOut callback(ButRnet *net, void *cmd, int cmdLen), ButOut ccallback(ButRnet *net, const char *reason)); extern void butRnet_accept(ButRnet *net); extern void butRnet_send(ButRnet *net, void *buffer, int len); extern void butRnet_destroy(ButRnet *net, const char *reason); /* Private. */ extern void butRnet_mMove(ButEnv *env, int winId, int lx, int ly, int lw, int lh, ButCur type); extern void butRnet_butSpecSend(But *but, void *buffer, int len); extern void butRnet_newFlags(ButEnv *env, int butId, uint newFlags); #endif /* _BUTNET_H_ */ cgoban-1.9.14/wmslib/src/but/plain.h0000664000671000067100000000240307043224471012660 /* * wmslib/src/but/plain.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for plain.c */ #ifndef _BUT_PLAIN_H_ #define _BUT_PLAIN_H_ 1 /********************************************************************** * Functions. **********************************************************************/ extern But *butPlain_create(ButWin *win, int layer, int flags, int cnum); extern void butPlain_setColor(But *but, int cnum); extern But *butPixmap_create(ButWin *win, int layer, int flags, Pixmap pic); extern void butPixmap_setPic(But *but, Pixmap pic, int x,int y); /* * dummy is a button that isn't drawn, but is opaque. It is sometimes * useful to create one of these to prevent the button library from * doing tons of extra redraws, then erase the dummy to force one * final redraw. */ extern But *butDummy_create(ButWin *win, int layer, int flags); /* * A keytrap does nothing but call your func when the key you specify * is pressed or released. */ extern But *butKeytrap_create(ButOut (*func)(But *but, bool press), void *packet, ButWin *win, int flags); extern void butKeytrap_setHold(But *but, bool hold); #endif /* _BUT_PLAIN_H_ */ cgoban-1.9.14/wmslib/src/but/radio.h0000664000671000067100000000126307043224472012657 /* * wmslib/src/but/radio.h, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for radio.c */ #ifndef _BUT_RADIO_H_ #define _BUT_RADIO_H_ 1 /********************************************************************** * Functions **********************************************************************/ extern But *butRadio_create(ButOut (*func)(But *but, int value), void *packet, ButWin *win, int layer, int flags, int val, int maxVal); extern int butRadio_get(But *but); extern void butRadio_set(But *but, int newVal, bool propagate); #endif /* _BUT_CHECKBOX_H_ */ cgoban-1.9.14/wmslib/src/but/rcur.h0000664000671000067100000000335007043224472012533 /* * wmslib/include/but/rcur.h, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for remote cursors. */ #ifndef _BUTRCUR_H_ #define _BUTRCUR_H_ 1 /********************************************************************** * Constants **********************************************************************/ #define BUTCUR_NUM 10 /********************************************************************** * Types **********************************************************************/ /* * Do not use butCur_bogus. It is a bogus cursor, _NOT_ a bogus-looking * cursor. */ typedef enum { butCur_idle, butCur_text, butCur_twitch, butCur_right, butCur_left, butCur_up, butCur_down, butCur_lr, butCur_ud, butCur_grab, butCur_bogus} ButCur; typedef struct ButRcur_struct { ButEnv *env; int winId, rx,ry, rw,rh; int lx,ly; ButCur type; bool drawn; Pixmap under; MAGIC_STRUCT } ButRcur; /********************************************************************** * Functions **********************************************************************/ /* Public. */ extern void butEnv_rcInit(ButEnv *env); extern void butRcur_create(ButRcur *rc, ButEnv *env); #define butRcur_destroy(rc) butRcur_move(-2, 0,0, 0,0); extern void butRcur_move(ButRcur *rc, int winId, int rx,int ry, int rw,int rh, ButCur type); extern void butRcur_redraw(ButEnv *env, int winId, int x,int y, int w,int h); /* The type of cursor has changed. */ extern void butEnv_setCursor(ButEnv *env, But *but, ButCur newCursor); /* Set up any cursor changes that may have occurred. */ extern void butEnv_rcActivate(ButEnv *env); #endif /* _BUTRCUR_H_ */ cgoban-1.9.14/wmslib/src/but/slide.h0000664000671000067100000000205207043224472012656 /* * wmslib/src/but/slide.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for slide.c */ #ifndef _BUT_SLIDE_H_ #define _BUT_SLIDE_H_ 1 /********************************************************************** * Functions **********************************************************************/ extern But *butSlide_hCreate(ButOut (*func)(But *but, int setting, bool newPress), void *packet, ButWin *win, int layer, int flags, int maxval, int cval, int size); extern But *butSlide_vCreate(ButOut (*func)(But *but, int setting, bool newPress), void *packet, ButWin *win, int layer, int flags, int maxval, int cval, int size); extern int butSlide_get(But *but); extern void butSlide_set(But *but, int maxval, int cval, int size); extern void butSlide_startSlide(But *but, bool pauseStart, int valsPerSecond, bool propagate); extern void butSlide_stopSlide(But *but); #endif /* _BUT_SLIDE_H_ */ cgoban-1.9.14/wmslib/src/but/tbin.h0000664000671000067100000000234307043224472012515 /* * wmslib/src/but/textin.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for textin.c */ #ifndef _BUT_TBIN_H_ #define _BUT_TBIN_H_ 1 /********************************************************************** * Functions **********************************************************************/ extern But *butTbin_create(ButWin *win, int layer, int flags, const char *text); extern void butTbin_set(But *but, const char *str); extern void butTbin_setMaxLines(But *but, int maxLines); extern const char *butTbin_get(But *but); extern int butTbin_numLines(But *but); extern void butTbin_insert(But *but, const char *appText); extern void butTbin_delete(But *but, int delStart, int delLen); extern int butTbin_len(But *but); /* * The offWinCallback function will be called whenever your cursor leaves * the window. Useful if you're on a canvas and want the cursor to * stay on the canvas. */ extern void butTbin_setOffWinCallback(But *but, void (*func)(But *but, int activeLine, int passiveLine, int mouseY)); extern void butTbin_setReadOnly(But *but, bool ro); #endif /* _BUT_TBIN_H_ */ cgoban-1.9.14/wmslib/src/but/tblock.h0000664000671000067100000000174207043224472013041 /* * wmslib/src/but/tblock.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for tblock.c */ #ifndef _BUT_TBLOCK_H_ #define _BUT_TBLOCK_H_ 1 #include /********************************************************************** * Functions **********************************************************************/ extern But *butTblock_create(ButWin *win, int layer, int flags, const char *text, ButTextAlign align); /* resize returns the height of the text block after being resized. */ extern int butTblock_resize(But *but, int x, int y, int w); extern void butTblock_setText(But *but, const char *text); extern const char *butTblock_getText(But *but); extern void butTblock_setFont(But *but, int fontnum); extern int butTblock_getH(But *but); extern int butTblock_guessH(ButEnv *env, const char *text, int w, int fontNum); #endif /* _BUT_TBLOCK_H_ */ cgoban-1.9.14/wmslib/src/but/text.h0000664000671000067100000000204407043224472012543 /* * wmslib/src/but/text.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for text.c */ #ifndef _BUT_TEXT_H_ #define _BUT_TEXT_H_ 1 /********************************************************************** * Data types **********************************************************************/ typedef enum { butText_left, butText_right, butText_center, butText_just } ButTextAlign; /********************************************************************** * Functions **********************************************************************/ extern But *butText_create(ButWin *win, int layer, int flags, const char *text, ButTextAlign align); extern int butText_resize(But *but, int x, int y, int h); extern const char *butText_get(But *but); extern void butText_set(But *but, const char *text); extern void butText_setFont(But *but, int fontnum); extern void butText_setColor(But *but, int color, bool stipple); #endif /* _BUT_TEXT_H_ */ cgoban-1.9.14/wmslib/src/but/textin.h0000664000671000067100000000240207043224472013070 /* * wmslib/src/but/textin.h, part of wmslib (Library functions) * Copyright (C) 1995-1997 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for textin.c */ #ifndef _BUT_TEXTIN_H_ #define _BUT_TEXTIN_H_ 1 /********************************************************************** * Functions **********************************************************************/ extern But *butTextin_create(ButOut (*func)(But *but, const char *value), void *packet, ButWin *win, int layer, int flags, const char *text, int maxlen); extern void butTextin_setCallback(But *but, ButOut (*func)(But *but, const char *value), void *packet); extern void butTextin_set(But *but, const char *str, bool propagate); extern const char *butTextin_get(But *but); /* * If you set hidden to TRUE, then all characters appear as only "*"s. This * is nice if you are asking for a password. */ extern void butTextin_setHidden(But *but, bool hidden); extern void butTextin_setSpecialKey(But *but, KeySym keysym, uint keyModifiers, uint modMask, ButOut callback(But *but, KeySym keysym, uint keyModifiers, void *context), void *context); #endif /* _BUT_TEXTIN_H_ */ cgoban-1.9.14/wmslib/src/but/timer.h0000664000671000067100000000457507043224472012712 /* * wmslib/src/but/timer.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for timer.c */ #ifndef _BUT_TIMER_H_ #define _BUT_TIMER_H_ 1 /********************************************************************** * Constants **********************************************************************/ #define BUTTIMER_HIST 4 #define BUTTIMER_MAXFREQ 400 /* Hz...the most we'll ever allow. */ #define BUTTIMER_STDFREQ 100 /* Hz...the "standard" value. */ /********************************************************************** * Data types **********************************************************************/ typedef enum { butTimer_on, butTimer_off, butTimer_dead } ButTimerState; /* Private. */ struct ButTimer_struct { void *packet; int eventNum; struct timeval nextFiring, period; bool winOnly; /* False=shut off when iconified. */ ButTimerState state; struct ButWin_struct *win; But *but; ButOut (*timerFunc)(struct ButTimer_struct *timer); struct ButTimer_struct *next; int ticksPerPeriod; bool freqCounter; int lastRes[BUTTIMER_HIST]; int resnum, ticksLeft; MAGIC_STRUCT }; /********************************************************************** * Functions **********************************************************************/ /* Public. */ extern ButTimer *butTimer_create(void *packet, But *but, struct timeval delay, struct timeval period, bool win_only, ButOut (*timerfunc)(struct ButTimer_struct *timer)); extern ButTimer *butTimer_fCreate(void *packet, But *but, struct timeval delay, int frequency, bool win_only, ButOut (*timerfunc)(struct ButTimer_struct *timer)); extern void butTimer_destroy(ButTimer *timer); extern void butTimer_reset(ButTimer *timer); #define butTimer_ticks(bt) ((bt)->eventNum) #define butTimer_setTicks(bt, v) ((bt)->eventNum = (v)) #define butTimer_packet(bt) ((bt)->packet) /* Private. */ extern struct timeval but_timerAdd(struct timeval t1, struct timeval t2); extern struct timeval but_timerSub(struct timeval t1, struct timeval t2); extern int but_timerDiv(struct timeval t1, struct timeval t2, struct timeval *remainder); extern int butEnv_checkTimers(ButEnv *env, struct timeval *timeout); #endif /* _BUT_TIMER_H_ */ cgoban-1.9.14/wmslib/src/but/write.h0000664000671000067100000000120007043224472012702 /* * wmslib/src/but/write.h, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. * * Includes for write.c */ #ifndef _BUT_WRITE_H_ #define _BUT_WRITE_H_ 1 #ifndef _BUT_TEXT_H_ #include #endif /********************************************************************** * Functions **********************************************************************/ extern void butWin_writeTabs(ButWin *win, int startX, int y, const char *text, int font, const int *tabList, const ButTextAlign *aligns); #endif /* _BUT_WRITE_H_ */ cgoban-1.9.14/wmslib/src/but/Makefile.am0000664000671000067100000000114207466273126013451 noinst_LIBRARIES = libbut.a libbut_a_SOURCES = \ box.c \ but.c \ canvas.c \ checkbox.c \ ctext.c \ i_finder.c \ i_general.c \ i_snd.c \ i_win.c \ list.c \ menu.c \ menu_snd.c \ net.c \ plain.c \ radio.c \ rcur.c \ slide.c \ tbin.c \ tblock.c \ text.c \ textin.c \ timer.c \ write.c INCLUDES = -I $(srcdir)/.. noinst_HEADERS = \ box.h \ but.h \ canvas.h \ checkbox.h \ ctext.h \ i_finder.h \ i_general.h \ i_snd.h \ i_win.h \ list.h \ menu.h \ menu_snd.h \ net.h \ plain.h \ radio.h \ rcur.h \ slide.h \ tbin.h \ tblock.h \ text.h \ textin.h \ timer.h \ write.h cgoban-1.9.14/wmslib/src/but/Makefile.in0000664000671000067100000002617707606355025013474 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../../.. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPP = @CPP@ DATE = @DATE@ DEPDIR = @DEPDIR@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBS = @LIBS@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ noinst_LIBRARIES = libbut.a libbut_a_SOURCES = \ box.c \ but.c \ canvas.c \ checkbox.c \ ctext.c \ i_finder.c \ i_general.c \ i_snd.c \ i_win.c \ list.c \ menu.c \ menu_snd.c \ net.c \ plain.c \ radio.c \ rcur.c \ slide.c \ tbin.c \ tblock.c \ text.c \ textin.c \ timer.c \ write.c INCLUDES = -I $(srcdir)/.. noinst_HEADERS = \ box.h \ but.h \ canvas.h \ checkbox.h \ ctext.h \ i_finder.h \ i_general.h \ i_snd.h \ i_win.h \ list.h \ menu.h \ menu_snd.h \ net.h \ plain.h \ radio.h \ rcur.h \ slide.h \ tbin.h \ tblock.h \ text.h \ textin.h \ timer.h \ write.h subdir = wmslib/src/but mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/configure.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) libbut_a_AR = $(AR) cru libbut_a_LIBADD = am_libbut_a_OBJECTS = box.$(OBJEXT) but.$(OBJEXT) canvas.$(OBJEXT) \ checkbox.$(OBJEXT) ctext.$(OBJEXT) i_finder.$(OBJEXT) \ i_general.$(OBJEXT) i_snd.$(OBJEXT) i_win.$(OBJEXT) \ list.$(OBJEXT) menu.$(OBJEXT) menu_snd.$(OBJEXT) net.$(OBJEXT) \ plain.$(OBJEXT) radio.$(OBJEXT) rcur.$(OBJEXT) slide.$(OBJEXT) \ tbin.$(OBJEXT) tblock.$(OBJEXT) text.$(OBJEXT) textin.$(OBJEXT) \ timer.$(OBJEXT) write.$(OBJEXT) libbut_a_OBJECTS = $(am_libbut_a_OBJECTS) DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/box.Po ./$(DEPDIR)/but.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/canvas.Po ./$(DEPDIR)/checkbox.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/ctext.Po ./$(DEPDIR)/i_finder.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/i_general.Po ./$(DEPDIR)/i_snd.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/i_win.Po ./$(DEPDIR)/list.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/menu.Po ./$(DEPDIR)/menu_snd.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/net.Po ./$(DEPDIR)/plain.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/radio.Po ./$(DEPDIR)/rcur.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/slide.Po ./$(DEPDIR)/tbin.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/tblock.Po ./$(DEPDIR)/text.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/textin.Po ./$(DEPDIR)/timer.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/write.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ DIST_SOURCES = $(libbut_a_SOURCES) HEADERS = $(noinst_HEADERS) DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in SOURCES = $(libbut_a_SOURCES) all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu wmslib/src/but/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) AR = ar clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libbut.a: $(libbut_a_OBJECTS) $(libbut_a_DEPENDENCIES) -rm -f libbut.a $(libbut_a_AR) libbut.a $(libbut_a_OBJECTS) $(libbut_a_LIBADD) $(RANLIB) libbut.a mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/box.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/but.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/canvas.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checkbox.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctext.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i_finder.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i_general.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i_snd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i_win.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/menu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/menu_snd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plain.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rcur.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slide.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tbin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tblock.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/textin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/write.Po@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` CCDEPMODE = @CCDEPMODE@ uninstall-info-am: ETAGS = etags ETAGSFLAGS = tags: TAGS 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: $(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 "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../../.. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ 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"; \ $(mkinstalldirs) "$(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 check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) $(HEADERS) installdirs: 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-tags dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-exec-am: install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic uninstall-am: uninstall-info-am .PHONY: GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES distclean distclean-compile \ distclean-depend distclean-generic distclean-tags distdir dvi \ dvi-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic tags uninstall uninstall-am \ uninstall-info-am # 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: cgoban-1.9.14/wmslib/src/but/box.c0000664000671000067100000004266207043224471012353 /* * wmslib/src/but/box.c, part of wmslib (Library functions) * Copyright (C) 1994-1997 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include /********************************************************************** * Data Types **********************************************************************/ typedef struct Box_struct { Pixmap ulmap, lrmap; int ulcolor, lrcolor; } Box; typedef struct BoxFilled_struct { Pixmap ulmap, lrmap, cmap; int ulcolor, lrcolor, ccolor; } BoxFilled; /********************************************************************** * Foward Declarations **********************************************************************/ static void box_draw(But *but, int x, int y, int w, int h); static void boxFilled_draw(But *but, int x, int y, int w, int h); static ButOut curve(int x, int y, int radius, int start, int sweep, XPoint *pts); static ButOut box_destroy(But *but); static ButOut boxFilled_destroy(But *but); static bool boxFilled_resize(But *but, int oldX, int oldY, int oldW, int oldH); static ButOut box_mmove(But *but, int x, int y); #define CIRCLE 64 /* Points to make a full circle. */ /********************************************************************** * Globals **********************************************************************/ static ButAction box_action = { box_mmove, NULL, NULL, NULL, NULL, NULL, box_draw, box_destroy, but_flags, NULL, NULL}; static ButAction boxFilled_action = { NULL, NULL, NULL, NULL, NULL, NULL, boxFilled_draw, boxFilled_destroy, but_flags, NULL, boxFilled_resize}; /********************************************************************** * Functions **********************************************************************/ But *butBox_create(ButWin *win, int layer, int flags) { But *but; Box *box; box = (Box *)wms_malloc(sizeof(Box)); but = but_create(win, box, &box_action); but->layer = layer; but->flags = flags; box->ulcolor = BUT_LIT; box->lrcolor = BUT_SHAD; box->ulmap = None; box->lrmap = None; but_init(but); return(but); } void butBox_setColors(But *but, int ul, int lr) { Box *box = but->iPacket; assert(but->action == &box_action); if (ul >= 0) { box->ulcolor = ul; box->ulmap = None; } if (lr >= 0) { box->lrcolor = lr; box->lrmap = None; } but_draw(but); } void butBox_setPixmaps(But *but, Pixmap ul, Pixmap lr) { Box *box = but->iPacket; assert(but->action == &box_action); if (ul != None) box->ulmap = ul; if (lr != None) box->lrmap = lr; but_draw(but); } static void box_draw(But *but, int x, int y, int w, int h) { ButEnv *env = but->win->env; int butbw = env->stdButBw; Box *box = but->iPacket; if ((x < but->x + butbw) || (x+w > but->x + but->w - butbw) || (y < but->y + butbw) || (y+h > but->y + but->h - butbw)) { but_drawBox(but->win, but->x, but->y, but->w, but->h,0, butbw, 0, box->ulcolor, box->lrcolor, box->ulmap, box->lrmap); } } static ButOut box_destroy(But *but) { wms_free(but->iPacket); return(0); } void but_drawBox(ButWin *win, int x, int y, int w, int h, int bstate, int bw, int angles, int ulcolor, int lrcolor, Pixmap ulmap, Pixmap lrmap) { ButEnv *env = win->env; Display *dpy = env->dpy; XPoint points[(CIRCLE/8+1)*4 + (CIRCLE/4+1)*2 + 1]; int abw = (bw * 1448 + 511) / 1024, h2 = h/2; int rounding = env->font0h / 2; int pnum = 0; int xOff = win->xOff, yOff = win->yOff; bool forceTiled; /* For arrows: * a----- h2 = c.y - a.y * / b____ abw = d.x - c.x * / / * c_d * \ \ */ if (angles & BUT_ALEFT) { points[pnum ].x = x + abw + h2 - bw - xOff; points[pnum++].y = y + bw - yOff; points[pnum ].x = x + abw - xOff; points[pnum++].y = y + h2 - yOff; points[pnum ].x = x - xOff; points[pnum++].y = y + h2 - yOff; points[pnum ].x = x + h2 - xOff; points[pnum++].y = y - yOff; } else if (angles & BUT_RLEFT) { pnum += curve(x+rounding-xOff, y+ rounding-yOff, rounding-bw, 90,90, points+pnum); pnum += curve(x+rounding-xOff, y+h-rounding-yOff, rounding-bw, 180,45, points+pnum); pnum += curve(x+rounding-xOff, y+h-rounding-yOff, rounding, 225,-45, points+pnum); pnum += curve(x+rounding-xOff, y+ rounding-yOff, rounding, 180,-90, points+pnum); } else { /* Square left edge. */ points[pnum ].x = x + bw - xOff; points[pnum++].y = y + bw - yOff; points[pnum ].x = x + bw - xOff; points[pnum++].y = y + h - bw - yOff; points[pnum ].x = x - xOff; points[pnum++].y = y + h - yOff; points[pnum ].x = x - xOff; points[pnum++].y = y - yOff; } if (angles & BUT_ARIGHT) { points[pnum ].x = x + w - h2 - xOff; points[pnum++].y = y - yOff; points[pnum ].x = x + w - xOff; points[pnum++].y = y + h2 - yOff; points[pnum ].x = x + w - abw - xOff; points[pnum++].y = y + h2 - yOff; points[pnum ].x = x + w - (abw + h2) + (abw-bw) - xOff; points[pnum++].y = y + bw - yOff; } else if (angles & BUT_RRIGHT) { pnum += curve(x+w-rounding-xOff, y+rounding-yOff, rounding, 90,-45, points+pnum); pnum += curve(x+w-rounding-xOff, y+rounding-yOff, rounding-bw, 0,45, points+pnum); } else { /* Square right edge. */ points[pnum ].x = x + w - xOff; points[pnum++].y = y - yOff; points[pnum ].x = x + w - bw - xOff; points[pnum++].y = y + bw - yOff; } points[pnum] = points[0]; assert(pnum < sizeof(points) / sizeof(points[0])); forceTiled = FALSE; if (bstate == 0) { if (ulmap == None) { butEnv_setXFg(env, ulcolor); } else { forceTiled = TRUE; XSetFillStyle(env->dpy, env->gc, FillTiled); XSetTile(env->dpy, env->gc, ulmap); } } else { if (lrmap == None) { butEnv_setXFg(env, lrcolor); } else { forceTiled = TRUE; XSetFillStyle(env->dpy, env->gc, FillTiled); XSetTile(env->dpy, env->gc, lrmap); } } XFillPolygon(dpy, win->win, env->gc, points, pnum, Nonconvex, CoordModeOrigin); h2 = (h + 1) / 2; pnum = 0; if (angles & BUT_ALEFT) { points[pnum ].x = x + abw + h2 - bw - xOff; points[pnum++].y = y + h - bw - yOff; points[pnum ].x = x + abw - xOff; points[pnum++].y = y + h - h2 - yOff; points[pnum ].x = x - xOff; points[pnum++].y = y + h - h2 - yOff; points[pnum ].x = x + h2 - xOff; points[pnum++].y = y + h - yOff; } else if (angles & BUT_RLEFT) { pnum += curve(x+rounding-xOff, y+h-rounding-yOff, rounding-bw, 270,-45, points+pnum); pnum += curve(x+rounding-xOff, y+h-rounding-yOff, rounding, 225,45, points+pnum); } else { /* Square left edge. */ points[pnum ].x = x + bw - xOff; points[pnum++].y = y + h - bw - yOff; points[pnum ].x = x - xOff; points[pnum++].y = y + h - yOff; } if (angles & BUT_ARIGHT) { points[pnum ].x = x + w - h2 - xOff; points[pnum++].y = y + h - yOff; points[pnum ].x = x + w - xOff; points[pnum++].y = y + h - h2 - yOff; points[pnum ].x = x + w - abw - xOff; points[pnum++].y = y + h - h2 - yOff; points[pnum ].x = x + w - (abw + h2) + (abw-bw) - xOff; points[pnum++].y = y + h - bw - yOff; } else if (angles & BUT_RRIGHT) { pnum += curve(x+w-rounding-xOff, y+h-rounding-yOff, rounding, 270,90, points+pnum); pnum += curve(x+w-rounding-xOff, y+rounding-yOff, rounding, 0,45, points+pnum); pnum += curve(x+w-rounding-xOff, y+rounding-yOff, rounding-bw, 45,-45, points+pnum); pnum += curve(x+w-rounding-xOff, y+h-rounding-yOff, rounding-bw, 0,-90, points+pnum); } else { /* Square right edge. */ points[pnum ].x = x + w - xOff; points[pnum++].y = y + h - yOff; points[pnum ].x = x + w - xOff; points[pnum++].y = y - yOff; points[pnum ].x = x + w - bw - xOff; points[pnum++].y = y + bw - yOff; points[pnum ].x = x + w - bw - xOff; points[pnum++].y = y + h - bw - yOff; } points[pnum] = points[0]; assert(pnum < sizeof(points) / sizeof(points[0])); if (bstate == 0) { if (lrmap == None) { if (forceTiled) { XSetFillStyle(env->dpy, env->gc, FillSolid); forceTiled = FALSE; } butEnv_setXFg(env, lrcolor); } else { forceTiled = TRUE; XSetFillStyle(env->dpy, env->gc, FillTiled); XSetTile(env->dpy, env->gc, lrmap); } } else { if (ulmap == None) { if (forceTiled) { XSetFillStyle(env->dpy, env->gc, FillSolid); forceTiled = FALSE; } butEnv_setXFg(env, ulcolor); } else { if (!forceTiled) { XSetFillStyle(env->dpy, env->gc, FillTiled); forceTiled = TRUE; } XSetTile(env->dpy, env->gc, ulmap); } } XFillPolygon(dpy, win->win, env->gc, points, pnum, Nonconvex, CoordModeOrigin); if (forceTiled) butEnv_stdFill(env); } static ButOut curve(int x, int y, int radius, int start, int sweep, XPoint *pts) { const int circRadius = 2048; static const int cosine[CIRCLE] = { 2048, 2038, 2009, 1960, 1892, 1806, 1703, 1583, 1448, 1299, 1138, 965, 784, 595, 400, 201, 0, -201, -400, -595, -784, -965,-1138,-1299, -1448,-1583,-1703,-1806, -1892,-1960,-2009,-2038, -2048,-2038,-2009,-1960, -1892,-1806,-1703,-1583, -1448,-1299,-1138, -965, -784, -595, -400, -201, 0, 201, 400, 595, 784, 965, 1138, 1299, 1448, 1583, 1703, 1806, 1892, 1960, 2009, 2038}; int i, step, count = 0, limit, round, cv; start = (start * CIRCLE) / 360; sweep = (sweep * CIRCLE) / 360; if (sweep > 0) step = 1; else step = -1; limit = step*sweep; for (i = start, count = 0; count <= limit; i += step, ++count) { cv = cosine[i & (CIRCLE-1)]; if (cv < 0) round = -circRadius/2; else round = circRadius/2; pts[count].x = x + (cv * radius + round) / circRadius; cv = cosine[(CIRCLE/4 + i) & (CIRCLE-1)]; if (cv < 0) round = -circRadius/2; else round = circRadius/2; pts[count].y = y + (cv * radius + round) / circRadius; } return(count); } void but_drawCt(ButWin *win, int flags, int fgpic, int bgpic, int pbgpic, int x, int y, int w, int h, int bw, const char *text, int angles, int fontnum) { ButEnv *env = win->env; but_drawCtb(win, flags, fgpic, bgpic, pbgpic, x, y, w, h, bw, angles); if (!(flags & BUT_PRESSABLE)) { XSetFillStyle(env->dpy, env->gc, FillStippled); XSetForeground(env->dpy, env->gc, env->colors[fgpic]); } else butEnv_setXFg(env, fgpic); if ((flags & BUT_PRESSED) && (flags & BUT_TWITCHED)) { x += bw/2; y += bw/2; } butWin_write(win, x + (w - butEnv_textWidth(env, text, fontnum))/2, y + (h - butEnv_fontH(env, fontnum)) / 2, text, fontnum); if (!(flags & BUT_PRESSABLE)) { butEnv_stdFill(env); } } void but_drawCtb(ButWin *win, int flags, int fgpic, int bgpic, int pbgpic, int x, int y, int w, int h, int bw, int angles) { ButEnv *env = win->env; but_drawBox(win, x, y, w, h, flags & (BUT_PRESSED|BUT_NETPRESS), bw, angles, BUT_LIT, BUT_SHAD, None, None); if ((flags & (BUT_PRESSED|BUT_NETPRESS)) && (flags & (BUT_TWITCHED|BUT_NETTWITCH|BUT_KEYPRESSED|BUT_NETKEY))) bgpic = pbgpic; butEnv_setXFg(env, bgpic); x -= win->xOff; y -= win->yOff; if (angles) { XPoint points[CIRCLE + 5]; int npoints = 0, abw = (bw * 1448 + 511) / 1024, rnd = env->font0h / 2; if (angles & BUT_ALEFT) { points[npoints ].x = x + abw + h/2 - bw; points[npoints++].y = y + bw; points[npoints ].x = x + abw; points[npoints++].y = y + h/2; points[npoints ].x = x + abw + (h+1)/2 - bw; points[npoints++].y = y + h - bw; } else if (angles & BUT_RLEFT) { npoints += curve(x+rnd,y+rnd, rnd-bw, 90,90, points+npoints); npoints += curve(x+rnd,y+h-rnd, rnd-bw, 180,90, points+npoints); } else { points[npoints ].x = x + bw; points[npoints++].y = y + bw; points[npoints ].x = x + bw; points[npoints++].y = y + h - bw; } if (angles & BUT_ARIGHT) { points[npoints ].x = x + w - abw - (h+1)/2 + bw; points[npoints++].y = y + h - bw; points[npoints ].x = x + w - abw; points[npoints++].y = y + h/2; points[npoints ].x = x + w - abw - h/2 + bw; points[npoints++].y = y + bw; } else if (angles & BUT_RRIGHT) { npoints += curve(x+w-rnd,y+h-rnd, rnd-bw, 270,90, points+npoints); npoints += curve(x+w-rnd,y+rnd, rnd-bw, 0,90, points+npoints); } else { points[npoints ].x = x + w - bw; points[npoints++].y = y + h - bw; points[npoints ].x = x + w - bw; points[npoints++].y = y + bw; } points[npoints] = points[0]; assert(npoints < CIRCLE+5); XFillPolygon(env->dpy, win->win, env->gc, points, npoints, Convex, CoordModeOrigin); } else XFillRectangle(env->dpy, win->win, env->gc, x+bw, y+bw, w-2*bw, h-2*bw); } But *butBoxFilled_create(ButWin *win, int layer, int flags) { But *but; BoxFilled *box; box = (BoxFilled *)wms_malloc(sizeof(BoxFilled)); but = but_create(win, box, &boxFilled_action); but->layer = layer; but->flags = flags | BUT_OPAQUE; box->ulcolor = BUT_LIT; box->lrcolor = BUT_SHAD; box->ccolor = BUT_BG; box->ulmap = None; box->lrmap = None; box->cmap = None; but_init(but); return(but); } void butBoxFilled_setColors(But *but, int ul, int lr, int c) { BoxFilled *box = but->iPacket; assert(but->action == &boxFilled_action); if (ul >= 0) { box->ulcolor = ul; box->ulmap = None; } if (lr >= 0) { box->lrcolor = lr; box->lrmap = None; } if (c >= 0) { box->ccolor = c; box->cmap = None; } but_draw(but); } void butBoxFilled_setPixmaps(But *but, Pixmap ul, Pixmap lr, Pixmap c) { BoxFilled *box = but->iPacket; assert(but->action == &boxFilled_action); if (ul != None) box->ulmap = ul; if (lr != None) box->lrmap = lr; if (c != None) box->cmap = c; but_draw(but); } static void boxFilled_draw(But *but, int x, int y, int w, int h) { ButWin *win = but->win; ButEnv *env = win->env; int butbw = env->stdButBw; BoxFilled *box = but->iPacket; if ((x < but->x + butbw) || (x+w > but->x + but->w - butbw) || (y < but->y + butbw) || (y+h > but->y + but->h - butbw)) { but_drawBox(but->win, but->x, but->y, but->w, but->h,0, butbw, 0, box->ulcolor, box->lrcolor, box->ulmap, box->lrmap); } if ((x >= but->x + but->w - butbw) || (y >= but->y + but->h - butbw) || (x + w <= but->x + butbw) || (y+h <= but->y + butbw)) return; if (x < but->x + butbw) { w -= but->x + butbw - x; x = but->x + butbw; } if (y < but->y + butbw) { h -= but->y + butbw - y; y = but->y + butbw; } if (x+w > but->x + but->w - butbw) w = but->x + but->w - butbw - x; if (y+h > but->y + but->h - butbw) h = but->y + but->h - butbw - y; if (box->cmap == None) { butEnv_setXFg(env, box->ccolor); XFillRectangle(env->dpy, win->win, env->gc, x-win->xOff, y-win->yOff, w,h); } else { if (env->colorp) XSetFillStyle(env->dpy, env->gc, FillTiled); XSetTile(env->dpy, env->gc, box->cmap); XFillRectangle(env->dpy, but->win->win, env->gc, x-win->xOff, y-win->yOff, w,h); if (env->colorp) XSetFillStyle(env->dpy, env->gc, FillSolid); } } static ButOut boxFilled_destroy(But *but) { wms_free(but->iPacket); return(0); } /* * This resize redraws only the needed parts of the screen. */ static bool boxFilled_resize(But *but, int oldX, int oldY, int oldW, int oldH) { int x, y, w, h, bw; bw = but->win->env->stdButBw; x = but->x; y = but->y; w = but->w; h = but->h; if ((oldW < 1) || (oldH < 1)) { butWin_redraw(but->win, x, y, w, h); } else if ((x + w < oldX) || (y + h < oldY) || (oldX + oldW < x) || (oldY + oldH < y)) { butWin_redraw(but->win, oldX, oldY, oldW, oldH); butWin_redraw(but->win, x, y, w, h); } else { if (x < oldX) butWin_redraw(but->win, x, y, oldX + bw - x, h); else if (oldX < x) butWin_redraw(but->win, oldX, oldY, x + bw - oldX, oldH); if (y < oldY) butWin_redraw(but->win, x, y, w, oldY + bw - y); else if (oldY < y) butWin_redraw(but->win, oldX, oldY, oldW, y + bw - oldY); if (x + w < oldX + oldW) butWin_redraw(but->win, x + w - bw, oldY, oldX + oldW + bw - x - w, oldH); else if (oldX + oldW < x + w) butWin_redraw(but->win, oldX + oldW - bw, y, x + w + bw - oldX - oldW, h); if (y + h < oldY + oldH) butWin_redraw(but->win, oldX, y + h - bw, oldW, oldY + oldH + bw - y - h); else if (oldY + oldH < y + h) butWin_redraw(but->win, x, oldY + oldH - bw, w, y + h + bw - oldY - oldH); } return(FALSE); } static ButOut box_mmove(But *but, int x, int y) { int bw = butEnv_stdBw(but->win->env); if (((x >= but->x) && (x < but->x + bw)) || ((y >= but->y) && (y < but->y + bw)) || ((x >= but->x + but->w - bw) && (x < but->x + but->w)) || ((y >= but->y + but->h - bw) && (y < but->y + but->h))) return(BUTOUT_CAUGHT); else return(0); } #endif cgoban-1.9.14/wmslib/src/but/but.c0000664000671000067100000007045507043224471012356 /* * wmslib/src/but/but.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #include #include #include #include #include /********************************************************************** * Types **********************************************************************/ typedef struct MouseEventFinder_struct { bool found; Window win; } MouseEventFinder; #if XlibSpecificationRelease < 5 /* * Older (X11R4 and earlier) releases of X11 used a char * where now an * XPointer is used. */ typedef char *XPointer; #endif /********************************************************************** * Forward declarations **********************************************************************/ static ButOut keyPress(ButEnv *env, XKeyPressedEvent *evt); static ButOut keyRelease(ButEnv *env, XKeyReleasedEvent *evt); static ButOut handleEvent(ButEnv *env); static int activateEvent(ButEnv *env); static bool butEnv_stdColors(ButEnv *env); static void getWinXY(Display *dpy, ButWin *win); static ButOut serviceXData(void *packet, int fd); static bool performQueuedWinStuff(ButEnv *env); static Bool anotherMouseEvent(Display *dpy, XEvent *ev, XPointer arg); #if DEBUG static int butErrors(Display *dpy, XErrorEvent *err); #endif /********************************************************************** * Globals **********************************************************************/ ButTimer *but_timerList; Atom but_wmDeleteWindow, but_wmProtocols; static fd_set emptyfds; static struct timeval long_timeout; static void makeStripes(ButEnv *env, int ssize); /* * This array really should be const, but an error in my Xlib.h forces me * to leave it non-const. :-( */ static char greymaps[17][4] = { {0x00, 0x00, 0x00, 0x00}, {0x01, 0x00, 0x00, 0x00}, {0x01, 0x00, 0x04, 0x00}, {0x05, 0x00, 0x04, 0x00}, {0x05, 0x00, 0x05, 0x00}, {0x05, 0x02, 0x05, 0x00}, {0x05, 0x02, 0x05, 0x08}, {0x05, 0x0a, 0x05, 0x08}, {0x05, 0x0a, 0x05, 0x0a}, {0x07, 0x0a, 0x05, 0x0a}, {0x07, 0x0a, 0x0d, 0x0a}, {0x0f, 0x0a, 0x0d, 0x0a}, {0x0f, 0x0a, 0x0f, 0x0a}, {0x0f, 0x0b, 0x0f, 0x0a}, {0x0f, 0x0b, 0x0f, 0x0e}, {0x0f, 0x0f, 0x0f, 0x0e}, {0x0f, 0x0f, 0x0f, 0x0f}}; /********************************************************************** * Functions **********************************************************************/ /* Returns false if the display can't be opened. */ ButEnv *butEnv_create(const char *protocol, const char *dpyname, int shutdown(Display *dpy)) { Display *dpy; ButEnv *env; env = (ButEnv *)wms_malloc(sizeof(ButEnv)); MAGIC_SET(env); if ((dpy = env->dpy = XOpenDisplay(dpyname)) == NULL) { MAGIC_UNSET(env); wms_free(env); return(NULL); } #if DEBUG XSynchronize(dpy, True); XSetErrorHandler(butErrors); #endif env->protocol = (char *)wms_malloc(strlen(protocol)+1); /* Probably not a good idea to silently truncate the protocol like this. */ if (strlen(protocol) > BUTNET_MAXCMD) env->protocol[BUTNET_MAXCMD] = '\0'; strcpy(env->protocol, protocol); if (shutdown != NULL) XSetIOErrorHandler(shutdown); env->shutdown = shutdown; env->last_mwin = 0; env->last_mx = 0; env->last_my = 0; return(env); } ButEnv *butEnv_createNoDpy(const char *protocol) { ButEnv *env; env = (ButEnv *)wms_malloc(sizeof(ButEnv)); MAGIC_SET(env); env->dpy = NULL; return(env); } /* * Returns: * 0 - Black and white display or color=FALSE. * 1 - Couldn't allocate standard colors. Failed. * 2 - Color successful. * 3 - Truecolor display. Color will always be successful. */ int butEnv_init(ButEnv *env, void *packet, const char *atomname, bool color) { Display *dpy; static int firstInit = TRUE; int i; XGCValues defGc; unsigned long gcVals; int retval; XVisualInfo xvi, *vlr; int depth; Window dummyRoot; unsigned int tempW, tempH, dummyBWRet, dummyDepth; int dummyX, dummyY; dpy = env->dpy; env->fonts = NULL; env->colors = NULL; env->colorPmaps = NULL; env->winlist = NULL; if (dpy) { but_wmDeleteWindow = XInternAtom(dpy, "WM_DELETE_WINDOW", 0); but_wmProtocols = XInternAtom(dpy, "WM_PROTOCOLS", 0); depth = DefaultDepth(dpy, DefaultScreen(dpy)); env->depth = depth; } if (firstInit) { firstInit = FALSE; but_timerList = NULL; FD_ZERO(&emptyfds); long_timeout.tv_sec = 60 * 60 * 24 * 365; /* 1 year. */ long_timeout.tv_usec = 0; } if (dpy && color) { xvi.visual = DefaultVisual(dpy, DefaultScreen(dpy)); xvi.visualid = XVisualIDFromVisual(xvi.visual); vlr = XGetVisualInfo(dpy, VisualIDMask, &xvi, &i); if (vlr[0].class == TrueColor) retval = 3; else if (vlr[0].class >= 2) { /* A color class */ retval = 2; } else { /* B&W */ retval = 0; color = FALSE; } XFree(vlr); } else retval = 0; env->packet = packet; if (dpy) { env->prop = XInternAtom(dpy, atomname, False); XGetGeometry(dpy, DefaultRootWindow(dpy), &dummyRoot, &dummyX, &dummyY, &tempW, &tempH, &dummyBWRet, &dummyDepth); env->rootW = tempW; env->rootH = tempH; } env->sReq = NULL; env->sClear = NULL; env->sNotify = NULL; env->winlist = NULL; env->wllen = env->wlmax = 0; env->minWindows = 1; env->butIn = NULL; env->lockBut = NULL; env->last_mwin = NULL; env->stipDisable = None; for (i = 0; i < BUTWRITE_MAXCHARS; ++i) env->write[i].draw = NULL; env->keyModifiers = 0; env->eventNum = 0; env->maxFd = 0; for (i = 0; i < 3; ++i) { env->maxGFds[i] = 0; FD_ZERO(&env->fMasks[i]); env->fCallbacks[i] = NULL; } if (dpy) butEnv_addFile(env, BUT_READFILE, ConnectionNumber(dpy), env, serviceXData); else return(retval); defGc.function = GXcopy; defGc.plane_mask = AllPlanes; defGc.line_style = LineSolid; defGc.cap_style = CapButt; defGc.join_style = JoinMiter; if (color) defGc.fill_style = FillSolid; else defGc.fill_style = FillTiled; defGc.fill_rule = EvenOddRule; defGc.graphics_exposures = False; gcVals = GCFunction | GCPlaneMask | GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle | GCFillRule | GCGraphicsExposures; env->gc = XCreateGC(dpy, RootWindow(dpy, DefaultScreen(dpy)), gcVals, &defGc); env->gc2 = XCreateGC(dpy, RootWindow(dpy, DefaultScreen(dpy)), gcVals, &defGc); env->numFonts = 1; env->fonts = (XFontStruct **)wms_malloc(env->numFonts * sizeof(XFontStruct *)); for (i = 0; i < env->numFonts; ++i) { env->fonts[i] = NULL; butEnv_setFont(env, 0, "fixed", 0); } env->colorp = color; env->numColors = BUT_DCOLORS; env->colors = (ulong *)wms_malloc(env->numColors * sizeof(ulong)); env->colorPmaps = (Pixmap *)wms_malloc(env->numColors * sizeof(Pixmap)); if (!butEnv_stdColors(env)) { retval = 1; env->colorp = FALSE; XSetFillStyle(dpy, env->gc, FillTiled); XSetFillStyle(dpy, env->gc2, FillTiled); butEnv_stdColors(env); } env->partner = 0; env->numPartners = 0; env->partners = NULL; env->maxButIds = env->maxWinIds = 0; env->id2But = NULL; env->id2Win = NULL; butEnv_rcInit(env); return(retval); } void butEnv_destroy(ButEnv *env) { int i; assert(MAGIC(env)); while (env->wllen != 0) { but_inEvent = TRUE; for (i = 0; i < env->wllen; ++i) butWin_destroy(env->winlist[i]); but_inEvent = FALSE; while (but_dList(NULL) || butWin_dList(NULL)); } for (i = 0; i < env->numPartners; ++i) { if (env->partners[i] != NULL) { butRnet_destroy(env->partners[i], "Remote user has quit the program."); } } if (env->fonts != NULL) wms_free(env->fonts); if (env->colors != NULL) wms_free(env->colors); if (env->colorPmaps != NULL) wms_free(env->colorPmaps); if (env->winlist != NULL) wms_free(env->winlist); if (env->protocol != NULL) wms_free(env->protocol); MAGIC_UNSET(env); XCloseDisplay(env->dpy); wms_free(env); } void butEnv_events(ButEnv *env) { int i, selected_fds, fdGroup; fd_set fdSets[3]; struct timeval next_timer; ButOut result, temp; if (env->dpy) butEnv_rcActivate(env); for (;;) { result = 0; if (env->dpy) { do { XFlush(env->dpy); while (XPending(env->dpy)) { result |= handleEvent(env); if (result & BUTOUT_STOPWAIT) return; } result |= butEnv_checkTimers(env, &next_timer); if (result & BUTOUT_STOPWAIT) { return; } } while(performQueuedWinStuff(env)); if (result & BUTOUT_ERR) { XBell(env->dpy, 0); result = 0; } } for (fdGroup = 0; fdGroup < 3; ++fdGroup) { fdSets[fdGroup] = env->fMasks[fdGroup]; } if (env->dpy && (env->wllen <= env->minWindows)) return; selected_fds = select(env->maxFd, &fdSets[BUT_READFILE], &fdSets[BUT_WRITEFILE], &fdSets[BUT_XFILE], &next_timer); assert(selected_fds >= 0); if (selected_fds > 0) { for (fdGroup = 0; fdGroup < 3; ++fdGroup) { for (i = 0; i < env->maxGFds[fdGroup]; ++i) { if (FD_ISSET(i, &fdSets[fdGroup])) { assert(env->fCallbacks[fdGroup][i].callback != NULL); but_inEvent = TRUE; result |= env->fCallbacks[fdGroup][i]. callback(env->fCallbacks[fdGroup][i].packet, i); but_inEvent = FALSE; do { temp = but_dList(NULL) | butWin_dList(NULL); result |= temp; } while (temp != 0); if (env->dpy) { butEnv_rcActivate(env); if (result & BUTOUT_ERR) XBell(env->dpy, 0); } if (result & BUTOUT_STOPWAIT) { return; } } } } } } } /* * Do all the resizes and redraws that have been queued up now. * TRUE is returned if there was anything to do. */ static bool performQueuedWinStuff(ButEnv *env) { bool anythingDone = FALSE; ButWin *win, *winToDo, *ancestor; int i; for (i = 0; i < env->wllen; ++i) { win = env->winlist[i]; if (win->resizeNeeded) { anythingDone = TRUE; win->resize(win); win->resizeNeeded = FALSE; win->resized = TRUE; } } do { winToDo = NULL; for (i = 0; i < env->wllen; ++i) { win = env->winlist[i]; if (win->redrawReady && win->numRedraws && win->resized) { if (winToDo == NULL) { winToDo = win; } else { for (ancestor = win->parent; ancestor; ancestor = ancestor->parent) { if (ancestor == winToDo) winToDo = win; } } } } if (winToDo) { anythingDone = TRUE; butWin_performDraws(winToDo); } } while (winToDo); return(anythingDone); } static ButOut handleEvent(ButEnv *env) { ButOut result, temp; but_inEvent = TRUE; result = activateEvent(env); but_inEvent = FALSE; do { temp = but_dList(NULL) | butWin_dList(NULL); result |= temp; } while (temp != 0); butEnv_rcActivate(env); return(result); } static int activateEvent(ButEnv *env) { Display *dpy; XEvent event, ev2; ButWin *win = NULL; int old_w, old_h; ButOut result = 0; MouseEventFinder mef; dpy = env->dpy; XNextEvent(dpy, &event); switch(event.type) { case Expose: win = butEnv_findWin(env, event.xexpose.window); if (win != NULL) { assert(win->mapped); butWin_redraw(win, event.xexpose.x, event.xexpose.y, event.xexpose.width, event.xexpose.height); /* Don't do any of the redraws until the expose count hits zero. */ win->redrawReady = (event.xexpose.count == 0); } break; case MapNotify: win = butEnv_findWin(env, event.xmap.window); assert(MAGICNULL(win)); if (win == NULL) return(result); butWin_turnOnTimers(win); win->mapped = TRUE; if (win->map != NULL) win->map(win); if (!win->resized) { /* * If you have no window manager, you won't get your ConfigureNotify * when you start up, so we have to fake that first resize when * we get mapped. Yeah, it's ugly, but deal with it. */ win->resizeNeeded = TRUE; } break; case UnmapNotify: win = butEnv_findWin(env, event.xunmap.window); if (win == NULL) return(result); butWin_turnOffTimers(win); win->mapped = FALSE; if (win->unmap != NULL) { result |= win->unmap(win); } if (!win->isIcon && (win->iconWin == NULL)) { butWin_dList(win); } break; case ConfigureNotify: win = butEnv_findWin(env, event.xunmap.window); if (win == NULL) return(result); old_w = win->w; old_h = win->h; win->w = win->logicalW = event.xconfigure.width; win->h = win->logicalH = event.xconfigure.height; butWin_checkDims(win); if ((win->w != old_w) || (win->h != old_h) || !win->resized) win->resizeNeeded = TRUE; getWinXY(dpy, win); break; case MappingNotify: case ReparentNotify: case DestroyNotify: /* I should handle this correctly. */ break; case ClientMessage: if ((event.xclient.message_type == but_wmProtocols) && (event.xclient.data.l[0] == but_wmDeleteWindow)) { /* The WM asked this window to go away. Bye! */ win = butEnv_findWin(env, event.xclient.window); if (win == NULL) return(result); if (win->quit) win->quit(win); else butWin_dList(win); } break; case ButtonPress: env->eventTime = event.xbutton.time; env->keyModifiers = event.xbutton.state; ++env->eventNum; win = butEnv_findWin(env, event.xbutton.window); if (win) result |= butWin_mPress(win, event.xbutton.x, event.xbutton.y, event.xbutton.button); return(result); break; case KeyRelease: env->eventTime = event.xbutton.time; env->keyModifiers = event.xbutton.state; return(result | keyRelease(env, &(event.xkey))); break; case ButtonRelease: env->eventTime = event.xbutton.time; env->keyModifiers = event.xbutton.state; win = butEnv_findWin(env, event.xbutton.window); if (win) result |= butWin_mRelease(win, event.xbutton.x, event.xbutton.y, event.xbutton.button); return(result); break; case KeyPress: env->eventTime = event.xbutton.time; env->keyModifiers = event.xbutton.state; ++env->eventNum; return(result | keyPress(env, &(event.xkey))); break; case MotionNotify: mef.found = FALSE; mef.win = event.xmotion.window; XCheckIfEvent(dpy, &ev2, anotherMouseEvent, (XPointer)&mef); if (!mef.found) { win = butEnv_findWin(env, event.xmotion.window); if (win) { env->eventTime = event.xmotion.time; butWin_mMove(win, event.xmotion.x, event.xmotion.y); butRnet_mMove(env, win->id, event.xmotion.x,event.xmotion.y, win->w,win->h, -1); } } break; case LeaveNotify: win = butEnv_findWin(env, event.xcrossing.window); if (win) { butWin_mMove(win, BUT_NOCHANGE,BUT_NOCHANGE); butRnet_mMove(env, -2, -1,-1,-1,-1,-1); } break; case FocusIn: break; case FocusOut: if (env->lockBut) { if (env->lockBut->flags & BUT_KEYPRESSED) { return(result | env->lockBut->action->kRelease(env->lockBut, "", 0)); } } break; case SelectionRequest: ev2.type = SelectionNotify; ev2.xselection.type = SelectionNotify; ev2.xselection.send_event = True; ev2.xselection.display = event.xselectionrequest.display; ev2.xselection.requestor = event.xselectionrequest.requestor; ev2.xselection.selection = event.xselectionrequest.selection; ev2.xselection.target = event.xselectionrequest.target; if ((env->sReq == NULL) || !env->sReq(env, &(event.xselectionrequest))) ev2.xselection.property = None; else ev2.xselection.property = event.xselectionrequest.property; ev2.xselection.time = event.xselectionrequest.time; XSendEvent(env->dpy, event.xselectionrequest.requestor, False, 0, &ev2); break; case SelectionNotify: if (env->sNotify != NULL) env->sNotify(env, &(event.xselection)); break; case SelectionClear: if (env->sClear != NULL) env->sClear(env); break; default: #if DEBUG printf("UNKNOWN EVENT! #%d\n", event.type); #endif break; } return(result); } static Bool anotherMouseEvent(Display *dpy, XEvent *ev, XPointer arg) { MouseEventFinder *mef = (MouseEventFinder *)arg; if (ev->type == MotionNotify) { if (ev->xmotion.window == mef->win) mef->found = TRUE; } else if ((ev->type == ButtonPress) || (ev->type == ButtonRelease)) { if (ev->xbutton.window == mef->win) mef->found = TRUE; } return(False); } #ifndef STR_MAXLEN #define STR_MAXLEN 100 #endif static ButOut keyPress(ButEnv *env, XKeyPressedEvent *evt) { int slen; char kbuf[STR_MAXLEN]; KeySym keysym; ButWin *win = butEnv_findWin(env, evt->window); if (!win) return(0); assert(MAGIC(win)); slen = XLookupString(evt, kbuf, STR_MAXLEN-1, &keysym, NULL); kbuf[slen] = '\0'; if (kbuf[0] == '\r') kbuf[0] = '\n'; return(butWin_kPress(win, kbuf, keysym)); } static ButOut keyRelease(ButEnv *env, XKeyReleasedEvent *evt) { int slen; char kbuf[STR_MAXLEN]; KeySym keysym; ButWin *win = butEnv_findWin(env, evt->window); if (win == NULL) return(0); slen = XLookupString(evt, kbuf, STR_MAXLEN-1, &keysym, NULL); kbuf[slen] = '\0'; if (kbuf[0] == '\r') kbuf[0] = '\n'; if (XPending(env->dpy)) { XEvent nextev; XPeekEvent(env->dpy, &nextev); if (nextev.type == KeyPress) { if ((nextev.xkey.keycode == evt->keycode) && (evt->time == nextev.xkey.time)) { XNextEvent(env->dpy, &nextev); return(butWin_kPress(win, kbuf, keysym)); } } } return(butWin_kRelease(win, kbuf, keysym)); } /* Disable all timers used in a particular window. Useful mostly so that * when you iconify a window, the timers shut off. Even though the timers * don't take much CPU time, shutting them off makes it possible to * swap the entire application out of memory and this COULD have a * noticeable effect on system performance if other applicaitons need * lots of memory. * The timers will stay in the timer queue, but they will not go off. */ void butWin_turnOffTimers(ButWin *win) { ButTimer *timer; for (timer = but_timerList; timer != NULL; timer = timer->next) { if ((timer->win == win) && (timer->state == butTimer_on) && timer->winOnly) timer->state = butTimer_off; } } /* Re-enable all timers for a particular window. This will undo the work * of but_turnoff_timers. */ void butWin_turnOnTimers(ButWin *win) { ButTimer *timer; for (timer = but_timerList; timer != NULL; timer = timer->next) { if ((timer->win == win) && (timer->state == butTimer_off) && timer->winOnly) timer->state = butTimer_on; } } static bool butEnv_stdColors(ButEnv *env) { ButColor colorset[BUT_DCOLORS]; int i, xblack, xwhite; ButColor black, white; Display *dpy = env->dpy; Window rootwin = DefaultRootWindow(dpy); xblack = BlackPixel(dpy, DefaultScreen(dpy)); xwhite = WhitePixel(dpy, DefaultScreen(dpy)); for (i = 0; i < 17; ++i) { env->greyMaps[i] = XCreatePixmapFromBitmapData(dpy, rootwin, greymaps[i], 4,4, xwhite, xblack, env->depth); } black = butColor_create(0,0,0,0); white = butColor_create(255,255,255,16); colorset[BUT_FG] = black; colorset[BUT_BG] = butColor_mix(white,3, black,1); colorset[BUT_PBG] = butColor_mix(colorset[BUT_BG],7, black,1); colorset[BUT_PBG].greyLevel = 14; colorset[BUT_HIBG] = butColor_mix(colorset[BUT_BG],1, white,1); colorset[BUT_LIT] = butColor_create(255,255,255, 8); colorset[BUT_SHAD] = butColor_create(128,128,128, 0); colorset[BUT_ENTERBG] = colorset[BUT_HIBG]; colorset[BUT_SELBG] = butColor_create(255,255,0,12); /* Yellow. */ colorset[BUT_CHOICE] = butColor_create(0,255,0, 16); colorset[BUT_WHITE] = white; colorset[BUT_BLACK] = black; for (i = 0; i < BUT_DCOLORS; ++i) { env->colorPmaps[i] = None; if (butEnv_setColor(env, i, colorset[i]) == 0) return(FALSE); } return(TRUE); } bool butEnv_setColor(ButEnv *env, int colornum, ButColor color) { int i; Display *dpy = env->dpy; Colormap cmap; XColor temp; static uchar bm1616[] = {1}; Window rootwin = DefaultRootWindow(dpy); if (colornum >= env->numColors) { ulong *newcolors; Pixmap *newpixmaps; newcolors = (ulong *)wms_malloc((colornum+1)*sizeof(ulong)); newpixmaps = (Pixmap *)wms_malloc((colornum+1)*sizeof(Pixmap)); for (i = 0; i < env->numColors; ++i) { newcolors[i] = env->colors[i]; newpixmaps[i] = env->colorPmaps[i]; } if (env->colors) wms_free(env->colors); env->colors = newcolors; if (env->colorPmaps) wms_free(env->colorPmaps); env->colorPmaps = newpixmaps; env->numColors = colornum + 1; for (; i < env->numColors; ++i) env->colorPmaps[i] = None; } cmap = DefaultColormap(dpy, DefaultScreen(dpy)); if (env->colorPmaps[colornum] != None) { if (env->colorp) { XFreePixmap(env->dpy, env->colorPmaps[colornum]); XFreeColors(env->dpy, cmap, &env->colors[colornum], 1, 0); } } if (env->colorp) { temp.red = color.red; temp.green = color.green; temp.blue = color.blue; temp.flags = DoRed | DoGreen | DoBlue; if (XAllocColor(dpy, cmap, &temp) == 0) return(FALSE); env->colors[colornum] = temp.pixel; env->colorPmaps[colornum] = XCreatePixmapFromBitmapData(dpy, rootwin, bm1616, 1,1, temp.pixel,temp.pixel, env->depth); } else { env->colorPmaps[colornum] = env->greyMaps[color.greyLevel]; if (color.greyLevel < 16) env->colors[colornum] = BlackPixel(dpy, DefaultScreen(dpy)); else env->colors[colornum] = WhitePixel(dpy, DefaultScreen(dpy)); } return(TRUE); } int butEnv_setFont(ButEnv *env, int fontnum, const char *fontname, int fparam) { XFontStruct *flist; char **fnames; int i, f_avail, minChar; Str fname, temp; int cstart, fontloaded = 0; str_init(&fname); str_init(&temp); if (fontnum >= env->numFonts) { XFontStruct **newflist; newflist = (XFontStruct **)wms_malloc((fontnum+1) * sizeof(XFontStruct *)); for (i = 0; i < env->numFonts; ++i) newflist[i] = env->fonts[i]; wms_free(env->fonts); env->fonts = newflist; env->numFonts = fontnum + 1; for (; i < env->numFonts; ++i) env->fonts[i] = NULL; } if (env->fonts[fontnum] != NULL) { XFreeFont(env->dpy, env->fonts[fontnum]); env->fonts[fontnum] = NULL; } for (;;) { ++fontloaded; if (*fontname == '/') ++fontname; if (*fontname == '\0') { fontloaded = 0; fontname = "fixed"; } for (cstart = 0; (fontname[cstart] != '\0') && (fontname[cstart] != '/'); ++cstart); str_copyCharsLen(&temp, fontname, cstart); str_print(&fname, str_chars(&temp), fparam); fontname += cstart; fnames = XListFontsWithInfo(env->dpy, str_chars(&fname), 1, &f_avail, &flist); if (f_avail > 0) { env->fonts[fontnum] = XLoadQueryFont(env->dpy, fnames[0]); minChar = env->fonts[fontnum]->min_char_or_byte2; if ((minChar > ' ') || (env->fonts[fontnum]->max_char_or_byte2 < 'z')) { printf("Char range: %d..%d, should be %d..%d\n", env->fonts[fontnum]->min_char_or_byte2, env->fonts[fontnum]->max_char_or_byte2, ' ', 'z'); XFreeFontInfo(fnames, flist, f_avail); continue; } if (env->fonts[fontnum]->per_char == NULL) { if (env->fonts[fontnum]->min_bounds.width < 1) { XFreeFontInfo(fnames, flist, f_avail); continue; } } else { if (env->fonts[fontnum]->per_char['a' - minChar].width < 1) { printf("Width of a is %d\n", env->fonts[fontnum]->per_char['a'].width); XFreeFontInfo(fnames, flist, f_avail); continue; } } if (fontnum == 0) { env->font0h = env->fonts[0]->ascent + env->fonts[0]->descent; env->stdButBw = (env->font0h + 3) / 6; makeStripes(env, (env->font0h / 15) * 2); } XFreeFontInfo(fnames, flist, f_avail); str_deinit(&temp); str_deinit(&fname); return(fontloaded); } } } void butEnv_drawAll(ButEnv *env) { int i; ButWin *win; for (i = 0; i < env->wllen; ++i) { win = env->winlist[i]; butWin_redraw(win, 0,0, win->w,win->h); } } void butEnv_resizeAll(ButEnv *env) { int i; ButWin *win; for (i = 0; i < env->wllen; ++i) { win = env->winlist[i]; win->resize(win); } } static void makeStripes(ButEnv *env, int ssize) { uint j; int x, y; uchar *stripes; if (ssize == 0) ssize = 2; /* "ssize" is the width of a stripe pattern used to grey out text. */ j = (ssize + 7) / 8; stripes = (uchar *)wms_malloc(ssize * j); for (x = 0; x < ssize*j; ++x) stripes[x] = 0; for (y = 0; y < ssize; ++y) { for (x = 0; x < ssize; ++x) { if ((((ssize-x-1) >= y) && ((ssize-x-1) < y+(ssize/2))) || ((ssize-x-1) < y-(ssize/2))) stripes[(x>>3) + (y*j)] |= 1<<(x&7); } } if (env->stipDisable != None) XFreePixmap(env->dpy, env->stipDisable); env->stipDisable = XCreateBitmapFromData(env->dpy, RootWindow(env->dpy, DefaultScreen(env->dpy)), stripes, ssize,ssize); wms_free(stripes); XSetStipple(env->dpy, env->gc, env->stipDisable); XSetStipple(env->dpy, env->gc2, env->stipDisable); } #if DEBUG static int butErrors(Display *dpy, XErrorEvent *err) { char ebuf[1024]; XGetErrorText(dpy, err->error_code, ebuf, sizeof(ebuf)); fprintf(stderr, "Error: %s\n", ebuf); assert(0); } #endif /* DEBUG */ /* * You know, it's really unbelievable to me that this is the only way in * X to find the location on the display of a window. *sigh*. * This code was blatantly stolen from "xwininfo.c". */ static void getWinXY(Display *dpy, ButWin *win) { static bool errorPrinted = FALSE; Status status; Window wmframe = win->win; XWindowAttributes frame_attr; while (True) { Window root, parent; Window *childlist; unsigned int ujunk; status = XQueryTree(dpy, wmframe, &root, &parent, &childlist, &ujunk); if (parent == root || !parent || !status) break; wmframe = parent; if (status && childlist) XFree((void *)childlist); } /* WM may be reparented, so find edges of the frame. */ /* Only works for ICCCM-compliant WMs, and then only if the window has corner gravity. We would need to know the original width of the window to correctly handle the other gravities. */ if (!XGetWindowAttributes(dpy, wmframe, &frame_attr) && !errorPrinted) { fprintf(stderr, "wmslib: Can't get frame attributes."); errorPrinted = TRUE; } win->x = frame_attr.x; win->y = frame_attr.y; } void butEnv_addFile(ButEnv *env, int group, int fd, void *packet, ButOut (*callback)(void *packet, int fd)) { int i; assert((group >= 0) && (group < 3)); if (fd >= env->maxFd) env->maxFd = fd + 1; if (fd >= env->maxGFds[group]) { ButFdCallback *newFc = wms_malloc((fd+1)*sizeof(ButFdCallback)); for (i = 0; i < env->maxGFds[group]; ++i) newFc[i] = env->fCallbacks[group][i]; for (; i < fd; ++i) newFc[i].callback = NULL; if (env->fCallbacks[group] != NULL) wms_free(env->fCallbacks[group]); env->maxGFds[group] = fd + 1; env->fCallbacks[group] = newFc; } env->fCallbacks[group][fd].callback = callback; env->fCallbacks[group][fd].packet = packet; FD_SET(fd, &env->fMasks[group]); } void butEnv_rmFile(ButEnv *env, int group, int fd) { assert((group >= 0) && (group < 3)); assert(MAGIC(env)); assert(fd < env->maxGFds[group]); env->fCallbacks[group][fd].callback = NULL; FD_CLR(fd, &env->fMasks[group]); } static ButOut serviceXData(void *packet, int fd) { ButEnv *env = packet; if (XPending(env->dpy)) return(handleEvent(env)); else return(0); } XImage *butEnv_imageCreate(ButEnv *env, int w, int h) { Display *dpy = env->dpy; XImage *image; image = XCreateImage(dpy, DefaultVisual(dpy, DefaultScreen(dpy)), DefaultDepth(dpy, DefaultScreen(dpy)), ZPixmap, 0, NULL, w, h, 32, 0); image->data = wms_malloc(image->bytes_per_line * h); return(image); } void butEnv_imageDestroy(XImage *img) { wms_free(img->data); img->data = NULL; XDestroyImage(img); } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/canvas.c0000664000671000067100000003274407043224471013036 /* * wmslib/src/but/canvas.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #ifdef _BUT_CANVAS_H_ Levelization Error. #endif #include "canvas.h" /********************************************************************** * Data Types **********************************************************************/ typedef struct Can_struct { bool grabbed; int grab_mx,grab_my, grab_ox,grab_oy; ButWin *parent, *win; But *but; Pixmap pmap; void (*change)(void *packet, int xOff, int yOff, int w, int h, int viewW, int viewH); MAGIC_STRUCT } Can; /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut mmove(But *but, int x, int y); static ButOut mleave(But *but); static ButOut mpress(But *but, int butnum, int x, int y); static ButOut mrelease(But *but, int butnum, int x, int y); static ButOut kpress(But *but, const char *keystr, KeySym sym); static ButOut krelease(But *but, const char *keystr, KeySym sym); static void draw(But *but, int x, int y, int w, int h); static ButOut destroy(But *but); static bool reviseDims(Can *can); /********************************************************************** * Globals **********************************************************************/ static const ButAction action = { mmove, mleave, mpress, mrelease, kpress, krelease, draw, destroy, but_flags, NULL}; /********************************************************************** * Functions **********************************************************************/ ButWin *butCan_create(void *packet, ButWin *parent, int layer, ButWinFunc *resize, ButWinFunc *destroy, void (*change)(void *packet, int xOff, int yOff, int w, int h, int viewW, int viewH)) { ButEnv *env; ButWin *win; But *but; Can *can; assert(MAGIC(parent)); env = parent->env; assert(MAGIC(env)); win = wms_malloc(sizeof(ButWin)); can = wms_malloc(sizeof(Can)); but = but_create(parent, can, &action); MAGIC_SET(win); MAGIC_SET(can); MAGIC_SET(&win->butsNoDraw); win->parent = parent; win->parentBut = but; win->packet = packet; win->iPacket = can; win->win = None; win->physWin = butCan_xWin(parent); win->iconWin = NULL; win->name = NULL; win->iconic = FALSE; win->isIcon = FALSE; win->x = 0; win->y = 0; win->w = win->minW = win->maxW = win->logicalW = 0; win->h = win->minH = win->maxH = win->logicalH = 0; win->wStep = 1; win->hStep = 1; win->xOff = 0; win->yOff = 0; win->minWRatio = win->minHRatio = win->maxWRatio = win->maxHRatio = 0; win->resized = FALSE; win->resizeNeeded = FALSE; win->redrawReady = TRUE; win->redraws = NULL; win->numRedraws = win->maxRedraws = 0; win->id = 0; win->mapped = TRUE; win->unmap = NULL; win->map = NULL; win->resize = resize; win->destroy = destroy; win->quit = NULL; win->env = env; win->minLayer = 1; win->maxLayer = 0; win->butsNoDraw.buts = NULL; win->butsNoDraw.numButs = 0; win->butsNoDraw.maxButs = 0; win->butsNoDraw.dynamic = TRUE; win->lock = NULL; win->butIn = NULL; win->keyBut = NULL; win->numCols = 0; win->maxCols = 0; win->cols = NULL; butWin_addToTable(win); but->uPacket = packet; but->layer = layer; but->flags = BUT_DRAWABLE|BUT_PRESSABLE|BUT_OPAQUE; can->grabbed = FALSE; can->parent = parent; can->win = win; can->but = but; can->pmap = None; can->change = change; but_init(but); return(win); } void butCan_resizeView(ButWin *win, int x, int y, int w, int h, bool propagate) { int oldh, oldw, oldx, oldy; Can *can = win->iPacket; But *but = can->but; assert(MAGIC(win)); assert(MAGIC(can)); win->resized = TRUE; oldx = but->x; oldy = but->y; oldw = but->w; oldh = but->h; if (x == BUT_NOCHANGE) x = oldx; if (y == BUT_NOCHANGE) y = oldy; if (w == BUT_NOCHANGE) w = oldw; if (h == BUT_NOCHANGE) h = oldh; /* * Check to see if the porthole size has changed. If it has, hit it * with a redraw. Not real necessary for these, but what the heck. */ if ((w != oldw) || (h != oldh)) { win->w = w; win->h = h; reviseDims(can); if (win->resize != NULL) { win->resize(win); } if (can->pmap != None) { butWin_rmFromTable(win); XFreePixmap(win->env->dpy, can->pmap); } can->pmap = XCreatePixmap(win->env->dpy, win->physWin, w, h, win->env->depth); win->win = can->pmap; butWin_addToTable(win); but_resize(but, x,y, w,h); butWin_redraw(win, win->xOff,win->yOff, w,h); if (propagate && can->change) { can->change(can->but->uPacket, win->xOff, win->yOff, win->logicalW, win->logicalH, win->w, win->h); } } else if ((x != oldx) || (y != oldy)) { /* Check if the porthole geometry has changed, necessitating a redraw. */ but_resize(but, x,y, w,h); } } void butCan_slide(ButWin *win, int xOff, int yOff, bool propagate) { int oldox, oldoy; Can *can = win->iPacket; int csx, csy, cdx, cdy, cw, ch; int rdx, rdw; assert(MAGIC(win)); assert(MAGIC(can)); oldox = win->xOff; oldoy = win->yOff; if (xOff != BUT_NOCHANGE) win->xOff = xOff; if (yOff != BUT_NOCHANGE) win->yOff = yOff; reviseDims(can); if (((oldox == win->xOff) && (oldoy == win->yOff)) || (win->win == None)) return; if (win->xOff > oldox) { csx = win->xOff - oldox; cdx = 0; cw = win->w - csx; } else if (win->xOff == oldox) { csx = 0; cdx = 0; cw = win->w; } else { /* win->xOff < oldox */ csx = 0; cdx = oldox - win->xOff; cw = win->w - csx; } if (win->yOff > oldoy) { csy = win->yOff - oldoy; cdy = 0; ch = win->h - csy; } else if (win->yOff == oldoy) { csy = 0; cdy = 0; ch = win->h; } else { /* win->yOff < oldoy */ csy = 0; cdy = oldoy - win->yOff; ch = win->h - csy; } if ((cw < 0) || (ch < 0)) { /* Must redraw entire pixmap. */ butWin_redraw(win, win->xOff, win->yOff, win->w, win->h); } else { XCopyArea(win->env->dpy, can->pmap, can->pmap, win->env->gc, csx,csy, cw,ch, cdx,cdy); if (cdx > csx) { butWin_redraw(win, win->xOff, win->yOff, cdx-csx, win->h); rdx = win->xOff+cdx-csx; rdw = win->w - (cdx-csx); if (rdw < 0) rdw = 0; } else if (cdx == csx) { rdx = win->xOff; rdw = win->w; } else { /* cdx < csx */ butWin_redraw(win, win->xOff+win->w-(csx-cdx), win->yOff, csx-cdx, win->h); rdx = win->xOff; rdw = win->w - (csx - cdx); if (rdw < 0) rdw = 0; } if (cdy > csy) { butWin_redraw(win, rdx, win->yOff, rdw, cdy-csy); } else if (cdy < csy) { butWin_redraw(win, rdx, win->yOff+win->h-(csy-cdy), rdw, csy-cdy); } } but_draw(can->but); if (propagate) { can->change(can->but->uPacket, win->xOff, win->yOff, win->logicalW, win->logicalH, win->w, win->h); } if (can->parent->butIn == can->but) { butWin_mMove(win->env->last_mwin, win->env->last_mx, win->env->last_my); } } void butCan_destroy(ButWin *win) { } static ButOut mmove(But *but, int x, int y) { Can *can = but->iPacket; ButWin *win = can->win; ButEnv *env = but->win->env; ButOut result; int new_ox, new_oy; assert(MAGIC(but)); assert(MAGIC(can)); if (can->grabbed) { if (env->last_mwin != but->win) { return(0); } new_ox = can->grab_ox + 10*(can->grab_mx - x); new_oy = can->grab_oy + 10*(can->grab_my - y); if ((new_ox != win->xOff) || (new_oy != win->yOff)) { butCan_slide(can->win, new_ox, new_oy, TRUE); } env->last_mwin = but->win; env->last_mx = x - but->x + win->xOff; env->last_my = y - but->y + win->yOff; return(BUTOUT_CAUGHT); } else { result = butWin_mMove(can->win, x-but->x+win->xOff, y-but->y+win->yOff); return(result | BUTOUT_CAUGHT | BUTOUT_IGNORE); } } static ButOut mleave(But *but) { /* * This isn't quite right...not sure how to handle this. * I don't want to get a "leave" when I propogate a mouse move down * to the area below, but I get one anyway! * can_t *can = but->iPacket; * int result; * * assert(MAGIC(can)); * result = but_mmove(but->win->env, can->win, 1,-1); * return(result); */ return(0); } static ButOut mpress(But *but, int butnum, int x, int y) { Can *can = but->iPacket; ButWin *win = can->win; int result; assert(MAGIC(can)); if (butnum == 3) { can->grabbed = TRUE; can->grab_mx = x; can->grab_my = y; can->grab_ox = win->xOff; can->grab_oy = win->yOff; butEnv_setCursor(but->win->env, but, butCur_grab); but_newFlags(but, but->flags | BUT_LOCKED); return(BUTOUT_CAUGHT); } else { result = butWin_mPress(can->win, x - but->x + win->xOff, y - but->y + win->yOff, butnum); return(result); } } static ButOut mrelease(But *but, int butnum, int x, int y) { Can *can = but->iPacket; ButWin *win = can->win; ButOut result; assert(MAGIC(can)); if (butnum == 3) { can->grabbed = FALSE; but_newFlags(but, but->flags & ~BUT_LOCKED); butEnv_setCursor(but->win->env, but, butCur_idle); return(BUTOUT_CAUGHT); } else { result = butWin_mRelease(can->win, x - but->x + win->xOff, y - but->y + win->yOff, butnum); return(result); } } static ButOut kpress(But *but, const char *keystr, KeySym sym) { Can *can = but->iPacket; ButOut result; assert(MAGIC(can)); result = butWin_kPress(can->win, keystr, sym); return(result); } static ButOut krelease(But *but, const char *keystr, KeySym sym) { Can *can = but->iPacket; ButOut result; assert(MAGIC(can)); result = butWin_kRelease(can->win, keystr, sym); return(result); } static void draw(But *but, int x, int y, int w, int h) { Can *can = but->iPacket; ButWin *win = but->win; ButEnv *env = win->env; int csx,csy, cdx,cdy, cw,ch; assert(MAGIC(can)); assert(MAGIC(win)); csx = 0; csy = 0; cdx = but->x; cdy = but->y; cw = but->w; ch = but->h; if (x > cdx) { csx += x - cdx; cw -= x - cdx; cdx = x; } if (y > cdy) { csy += y - cdy; ch -= y - cdy; cdy = y; } if (x+w < cdx+cw) cw = x+w-cdx; if (y+h < cdy+ch) ch = y+h-cdy; if ((cw > 0) && (ch > 0)) XCopyArea(env->dpy, can->pmap, win->win, env->gc, csx,csy, cw,ch, cdx,cdy); } void butCan_redrawn(ButWin *win, int x,int y, int w,int h) { Can *can = win->iPacket; assert(MAGIC(win)); if (can == NULL) return; assert(MAGIC(can)); if (can->but == NULL) return; assert(MAGIC(can->but)); assert(MAGIC(can->parent)); if (x < win->xOff) { w -= win->xOff - x; x = win->xOff; } if (y < win->yOff) { h -= win->yOff - y; y = win->yOff; } if (x + w > win->xOff + win->w) w = win->xOff + win->w - x; if (y + h > win->yOff + win->h) h = win->yOff + win->h - y; butWin_redraw(can->parent, can->but->x + x - win->xOff, can->but->y + y - win->yOff, w, h); } static ButOut destroy(But *but) { Can *can = but->iPacket; assert(MAGIC(but)); assert(MAGIC(can)); assert((can->win == NULL) || MAGIC(can->win)); can->but = NULL; but->iPacket = NULL; if (can->win == NULL) { MAGIC_UNSET(can); wms_free(can); } else butWin_destroy(can->win); return(0); } void butCan_winDead(ButWin *win) { Can *can = win->iPacket; assert(MAGIC(win)); assert(MAGIC(can)); assert((can->but == NULL) || MAGIC(can->but)); can->win = NULL; win->iPacket = NULL; if (can->but == NULL) { MAGIC_UNSET(can); wms_free(can); } else but_destroy(can->but); } void butCan_resizeWin(ButWin *win, int w, int h, bool propagate) { Can *can = win->iPacket; int oldW, oldH; assert(MAGIC(win)); assert(MAGIC(can)); oldW = win->logicalW; oldH = win->logicalH; if (w < win->w) w = win->w; if (h < win->h) h = win->h; win->logicalW = w; win->logicalH = h; reviseDims(can); if ((win->logicalW <= 0) || (win->logicalH <= 0)) return; if ((win->logicalW != oldW) || (win->logicalH != oldH)) { win->resize(win); if (propagate && can->change) { can->change(can->but->uPacket, win->xOff, win->yOff, win->logicalW, win->logicalH, win->w, win->h); } } } Window butCan_xWin(ButWin *win) { assert(MAGIC(win)); while (win->parent) { win = win->parent; assert(MAGIC(win)); } return(win->win); } static bool reviseDims(Can *can) { ButWin *win = can->win; bool change = FALSE; if (win->logicalW < win->w) { change = TRUE; win->logicalW = win->w; } if (win->logicalH < win->h) { change = TRUE; win->logicalH = win->h; } if (win->xOff < 0) { change = TRUE; win->xOff = 0; } else if (win->xOff + win->w > win->logicalW) { change = TRUE; win->xOff = win->logicalW - win->w; } if (win->yOff < 0) { change = TRUE; win->yOff = 0; } else if (win->yOff + win->h > win->logicalH) { change = TRUE; win->yOff = win->logicalH - win->h; } return(change); } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/checkbox.c0000664000671000067100000001636207043224471013347 /* * wmslib/src/but/checkbox.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #include typedef struct Cb_struct { bool on; ButOut (*press)(But *but, bool value); } Cb; static ButOut mmove(But *but, int x, int y); static ButOut mleave(But *but); static ButOut mpress(But *but, int butnum, int x, int y); static ButOut mrelease(But *but, int butnum, int x, int y); static ButOut kpress(But *but, const char *keystr, KeySym sym); static ButOut krelease(But *but, const char *keystr, KeySym sym); static void draw(But *but, int x, int y, int w, int h); static ButOut destroy(But *but); static void flags(But *but, uint flags); static const ButAction action = { mmove, mleave, mpress, mrelease, kpress, krelease, draw, destroy, flags, NULL}; /********************************************************************** * Functions **********************************************************************/ But *butCb_create(ButOut (*func)(But *but, bool value), void *packet, ButWin *win, int layer, int flags, bool on) { But *but; Cb *cb; cb = wms_malloc(sizeof(Cb)); but = but_create(win, cb, &action); MAGIC_SET(but); but->uPacket = packet; but->layer = layer; but->flags = flags | BUT_OPAQUE; cb->on = on; cb->press = func; but_init(but); return(but); } bool butCb_get(But *but) { Cb *cb = but->iPacket; assert(but->action == &action); assert(MAGIC(but)); return(cb->on); } void butCb_set(But *but, bool on, bool makeCallback) { Cb *cb = but->iPacket; assert(but->action == &action); assert(MAGIC(but)); if (cb->on != on) { cb->on = on; but_draw(but); if (makeCallback && (cb->press != NULL)) cb->press(but, on); } } static ButOut destroy(But *but) { Cb *cb = but->iPacket; assert(but->action == &action); assert(MAGIC(but)); wms_free(cb); return(0); } static void draw(But *but, int x, int y, int w, int h) { ButWin *win = but->win; Cb *cb = but->iPacket; uint flags = but->flags; ButEnv *env = win->env; XPoint check[6]; int i, ix, iy, iw, ih, delta; assert(but->action == &action); assert(MAGIC(but)); ix = but->x + env->stdButBw - win->xOff; iy = but->y + env->stdButBw - win->yOff; iw = but->w - 2*env->stdButBw; ih = but->h - 2*env->stdButBw; but_drawBox(win, but->x,but->y, but->w,but->h, flags & BUT_PRESSED, env->stdButBw, BUT_SLEFT|BUT_SRIGHT, BUT_LIT, BUT_SHAD, None, None); if (flags & BUT_PRESSED) butEnv_setXFg(env, BUT_PBG); else { if (cb->on && (but->flags & BUT_PRESSABLE)) { butEnv_setXFg(env, BUT_CHOICE); } else butEnv_setXFg(env, BUT_BG); } XFillRectangle(env->dpy, win->win, env->gc, ix,iy, iw,ih); if (((flags & BUT_PRESSED) && !cb->on) || (!(flags & BUT_PRESSED) && cb->on)) { check[0].x = ix + (iw + 1) / 3; check[0].y = iy + ih; check[1].x = ix; check[1].y = iy + (2*ih + 1) / 3; check[2].x = ix + (iw + 3) / 6; check[2].y = iy + (3*ih + 3) / 6; check[3].x = check[0].x; check[3].y = check[1].y; check[4].x = ix + iw; check[4].y = iy + (ih + 1) / 3; check[5] = check[0]; if (flags & BUT_PRESSED) { delta = (env->stdButBw + 1) / 2; for (i = 1; i < 5; ++i) check[i].y += delta; check[0].x -= delta; check[5].x += delta; } butEnv_setXFg(env, BUT_FG); XFillPolygon(env->dpy, win->win, env->gc, check, 6, Nonconvex, CoordModeOrigin); } } static void flags(But *but, uint flags) { uint ofl = but->flags; but->flags = flags; if (((flags & (BUT_PRESSABLE|BUT_DRAWABLE|BUT_PRESSED)) != (ofl & (BUT_PRESSABLE|BUT_DRAWABLE|BUT_PRESSED))) || (((flags & BUT_TWITCHED) != (ofl & BUT_TWITCHED)) && (flags & BUT_PRESSED))) but_draw(but); } static ButOut mmove(But *but, int x, int y) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; ButEnv *env = but->win->env; if (!(but->flags & BUT_PRESSABLE)) return(BUTOUT_CAUGHT); if ((x >= but->x + env->stdButBw) && (y >= but->y + env->stdButBw) && (x < but->x + but->w - env->stdButBw) && (y < but->y + but->h - env->stdButBw)) newflags |= BUT_TWITCHED; else { newflags &= ~BUT_TWITCHED; if (!(newflags & BUT_LOCKED)) retval &= ~BUTOUT_CAUGHT; } if (!(but->flags & BUT_TWITCHED) && (newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_twitch); else if ((but->flags & BUT_TWITCHED) && !(newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) { but_newFlags(but, newflags); } return(retval); } static ButOut mleave(But *but) { int newflags = but->flags; newflags &= ~BUT_TWITCHED; if ((but->flags & BUT_TWITCHED) && !(newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) { but_newFlags(but, newflags); } return(BUTOUT_CAUGHT); } static ButOut mpress(But *but, int butnum, int x, int y) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; if (!newflags & BUT_TWITCHED) retval &= ~BUTOUT_CAUGHT; else { if (butnum == 1) newflags |= BUT_PRESSED | BUT_LOCKED; else return(BUTOUT_CAUGHT | BUTOUT_ERR); } if (!(but->flags & BUT_PRESSED) && (newflags & BUT_PRESSED)) snd_play(&but_downSnd); if (newflags != but->flags) but_newFlags(but, newflags); return(retval); } static ButOut mrelease(But *but, int butnum, int x, int y) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; Cb *cb; if (butnum != 1) { if (but->flags & BUT_TWITCHED) return(BUTOUT_CAUGHT); else return(0); } if (!(but->flags & BUT_PRESSED)) return(0); if (but->flags & BUT_TWITCHED) { cb = but->iPacket; cb->on = !cb->on; if (cb->press != NULL) retval |= cb->press(but, cb->on); } else retval |= BUTOUT_ERR; newflags &= ~(BUT_PRESSED|BUT_LOCKED); if ((but->flags & BUT_PRESSED) && !(newflags & BUT_PRESSED) && !(retval & BUTOUT_ERR)) snd_play(&but_upSnd); if (newflags != but->flags) but_newFlags(but, newflags); return(retval); } static ButOut kpress(But *but, const char *keystr, KeySym sym) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; newflags |= BUT_KEYPRESSED; if (!(but->flags & BUT_KEYPRESSED)) { snd_play(&but_downSnd); but_newFlags(but, newflags); } return(retval); } static ButOut krelease(But *but, const char *keystr, KeySym sym) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; Cb *cb = but->iPacket; newflags &= ~(BUT_KEYPRESSED); cb->on = !cb->on; if (cb->press != NULL) retval |= cb->press(but, cb->on); snd_play(&but_upSnd); if (newflags != but->flags) but_newFlags(but, newflags); return(retval); } #endif cgoban-1.9.14/wmslib/src/but/ctext.c0000664000671000067100000002622607043224471012710 /* * wmslib/src/but/ctext.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #include #include /********************************************************************** * Data Types **********************************************************************/ typedef struct Ct_struct { char *str; int maxlen; int angles; ButOut (*pfunc)(But *but), (*rfunc)(But *but); bool netAction; int textX, textY, textW, textH; } Ct; /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut mmove(But *but, int x, int y); static ButOut mleave(But *but); static ButOut mpress(But *but, int butnum, int x, int y); static ButOut mrelease(But *but, int butnum, int x, int y); static ButOut kpress(But *but, const char *keystr, KeySym sym); static ButOut krelease(But *but, const char *keystr, KeySym sym); static void draw(But *but, int x, int y, int w, int h); static ButOut destroy(But *but); static bool mouse_over_but(But *but, int x, int y); static void flags(But *but, uint flags); static ButOut remPress(But *but, void *msg, int msgLen); /********************************************************************** * Globals **********************************************************************/ static ButAction action = { mmove, mleave, mpress, mrelease, kpress, krelease, draw, destroy, flags, remPress}; /********************************************************************** * Functions **********************************************************************/ But *butCt_create(ButOut (*func)(But *but), void *packet, ButWin *win, int layer, int flags, const char *text) { return(butAct_vCreate(NULL, func, packet, win, layer, flags, text, BUT_RLEFT|BUT_RRIGHT)); } But *butAct_create(ButOut (*func)(But *but), void *packet, ButWin *win, int layer, int flags, const char *text, int angleflags) { return(butAct_vCreate(NULL, func, packet, win, layer, flags, text, angleflags)); } But *butAct_vCreate(ButOut (*pfunc)(But *but), ButOut (*rfunc)(But *but), void *packet, ButWin *win, int layer, int flags, const char *text, int angleflags) { Ct *ct; But *but; ct = wms_malloc(sizeof(Ct)); but = but_create(win, ct, &action); but->uPacket = packet; but->layer = layer; but->flags = flags; if (text == NULL) text = ""; ct->rfunc = rfunc; ct->maxlen = strlen(text); ct->str = (char *)wms_malloc(sizeof(char) * (ct->maxlen + 1)); strcpy(ct->str, text); ct->angles = angleflags; ct->pfunc = pfunc; ct->netAction = TRUE; ct->textW = ct->textH = 0; but_init(but); return(but); } void butCt_setText(But *but, const char *text) { Ct *ct = but->iPacket; int newlen; assert(but->action == &action); newlen = strlen(text); if (newlen > ct->maxlen) { wms_free(ct->str); ct->maxlen = newlen; ct->str = (char *)wms_malloc((newlen + 1) * sizeof(char)); } strcpy(ct->str, text); but_draw(but); } static ButOut destroy(But *but) { Ct *ct = but->iPacket; wms_free(ct->str); wms_free(ct); return(0); } void butCt_setTextLoc(But *but, int x, int y, int w, int h) { Ct *ct = but->iPacket; ct->textX = x; ct->textY = y; ct->textW = w; ct->textH = h; } static void draw(But *but, int x, int y, int w, int h) { ButWin *win = but->win; ButEnv *env = win->env; Ct *ct = but->iPacket; uint flags = but->flags; int tx, ty, tw, th; int textWidth; but_drawCtb(win, flags, BUT_FG, BUT_BG, BUT_PBG, but->x, but->y, but->w, but->h, env->stdButBw, ct->angles); tx = but->x; ty = but->y; if (ct->textW != 0) { tx += ct->textX; ty += ct->textY; tw = ct->textW; th = ct->textH; } else { tw = but->w; th = but->h; } if (!(but->flags & BUT_PRESSABLE)) { XSetFillStyle(env->dpy, env->gc, FillStippled); XSetForeground(env->dpy, env->gc, env->colors[BUT_FG]); } else butEnv_setXFg(env, BUT_FG); if ((but->flags & BUT_PRESSED) && (but->flags & BUT_TWITCHED)) { tx += env->stdButBw/2; ty += env->stdButBw/2; } textWidth = butEnv_textWidth(win->env, ct->str, 0); butWin_write(win, tx + (tw - textWidth) / 2, ty + (th - butEnv_fontH(win->env, 0))/2, ct->str, 0); if (!(but->flags & BUT_PRESSABLE)) { butEnv_stdFill(env); } } static void flags(But *but, uint flags) { uint ofl = but->flags; but->flags = flags; if ((flags & BUT_NETPRESS) && !(ofl & BUT_NETPRESS)) { snd_play(&but_downSnd); } if (((flags & (BUT_PRESSABLE|BUT_DRAWABLE|BUT_PRESSED|BUT_NETPRESS)) != (ofl & (BUT_PRESSABLE|BUT_DRAWABLE|BUT_PRESSED|BUT_NETPRESS))) || (((flags & (BUT_TWITCHED|BUT_NETTWITCH)) != (ofl & (BUT_TWITCHED|BUT_NETTWITCH))) && (flags & (BUT_PRESSED|BUT_NETPRESS)))) but_draw(but); } static ButOut mmove(But *but, int x, int y) { ButOut retval = BUTOUT_CAUGHT; uint newflags = but->flags; if (mouse_over_but(but, x,y)) { if (!(but->flags & BUT_PRESSABLE)) return(BUTOUT_CAUGHT); newflags |= BUT_TWITCHED; } else { if (!(but->flags & BUT_PRESSABLE)) return(0); newflags &= ~BUT_TWITCHED; if (!(newflags & BUT_LOCKED)) retval &= ~BUTOUT_CAUGHT; } if (!(but->flags & BUT_TWITCHED) && (newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_twitch); else if ((but->flags & BUT_TWITCHED) && !(newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) { but_newFlags(but, newflags); } return(retval); } static ButOut mleave(But *but) { int newflags = but->flags; newflags &= ~BUT_TWITCHED; if ((but->flags & BUT_TWITCHED) && !(newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) { but_newFlags(but, newflags); } return(BUTOUT_CAUGHT); } static ButOut mpress(But *but, int butnum, int x, int y) { ButOut retval = BUTOUT_CAUGHT; uint newflags = but->flags; Ct *ct = but->iPacket; bool pressPf = FALSE; if (!(newflags & BUT_TWITCHED)) retval &= ~BUTOUT_CAUGHT; else { if (butnum == 1) { newflags |= BUT_PRESSED | BUT_LOCKED; pressPf = TRUE; } else return(BUTOUT_CAUGHT | BUTOUT_ERR); } if (!(but->flags & BUT_PRESSED) && (newflags & BUT_PRESSED)) snd_play(&but_downSnd); if (newflags != but->flags) but_newFlags(but, newflags); if (pressPf && ct->pfunc) retval |= ct->pfunc(but); return(retval); } static ButOut mrelease(But *but, int butnum, int x, int y) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; Ct *ct = but->iPacket; bool pressRf = FALSE; if (butnum != 1) { if (but->flags & BUT_TWITCHED) return(BUTOUT_CAUGHT); else return(0); } if (!(but->flags & BUT_PRESSED)) return(0); if (but->flags & BUT_TWITCHED) { pressRf = TRUE; } else { if (ct->pfunc != NULL) pressRf = TRUE; retval |= BUTOUT_ERR; } newflags &= ~(BUT_PRESSED|BUT_LOCKED); if ((but->flags & BUT_PRESSED) && !(newflags & BUT_PRESSED) && !(retval & BUTOUT_ERR)) snd_play(&but_upSnd); if (newflags != but->flags) but_newFlags(but, newflags); if (but->id >= 0) butRnet_butSpecSend(but, NULL, 0); if (pressRf && ct->rfunc) retval |= ct->rfunc(but); return(retval); } static ButOut kpress(But *but, const char *keystr, KeySym sym) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; Ct *ct = but->iPacket; newflags |= BUT_KEYPRESSED|BUT_PRESSED|BUT_LOCKED; if (!(but->flags & BUT_KEYPRESSED)) { snd_play(&but_downSnd); but_newFlags(but, newflags); if (ct->pfunc != NULL) retval |= ct->pfunc(but); } return(retval); } static ButOut krelease(But *but, const char *keystr, KeySym sym) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; Ct *ct = but->iPacket; bool pressRf = FALSE; if (!(newflags & BUT_KEYPRESSED)) return(0); newflags &= ~(BUT_KEYPRESSED|BUT_PRESSED|BUT_LOCKED); if (keystr != NULL) { /* If keystr is NULL, the key wasn't released - we lost focus instead. */ pressRf = TRUE; } snd_play(&but_upSnd); if (newflags != but->flags) but_newFlags(but, newflags); if (but->id >= 0) butRnet_butSpecSend(but, NULL, 0); if (pressRf && ct->rfunc) retval |= ct->rfunc(but); return(retval); } static bool mouse_over_but(But *but, int x, int y) { int angleflags = ((Ct *)(but->iPacket))->angles; int radlimit, radius, dx, dy; if (x < but->x + but->w/2) { if (angleflags & BUT_ALEFT) { if ((y < but->y) || (y >= but->y + but->h)) return(0); if (y < but->y + but->h/2) { if (x <= but->x + (but->y + but->h/2 - y)) { return(0); } } else { return(x > but->x + (y - (but->y + but->h/2))); } } else if (angleflags & BUT_SLEFT) { return((x >= but->x) && (y >= but->y) && (y < but->y + but->h)); } } else { if (angleflags & BUT_ARIGHT) { if ((y < but->y) || (y >= but->y + but->h)) { return(0); } if (y < but->y + but->h/2) { return(x < but->x + but->w - (but->y + but->h/2 - y)); } else { return(x < but->x + but->w - (y - (but->y + but->h/2))); } } else if (angleflags & BUT_SRIGHT) { return((x < but->x + but->w) && (y >= but->y) && (y < but->y + but->h)); } } /* We're dealing with the tough case...rounded edges! */ radius = but->h / 4; radlimit = (radius + 1); radlimit *= radlimit; if (y < but->y + radius) { if (x < but->x + radius) { dx = but->x + radius - x; dy = but->y + radius - y; return(dx*dx + dy*dy < radlimit); } else if (x < but->x + but->w - radius) return(y >= but->y); else { dx = x - (but->x + but->w - radius - 1); dy = but->y + radius - y; return(dx*dx + dy*dy < radlimit); } } else if (y < but->y + but->h - radius) return((x >= but->x) && (x < but->x + but->w)); else { if (x < but->x + radius) { dx = but->x + radius - x; dy = y - (but->y + but->h - radius - 1); return(dx*dx + dy*dy < radlimit); } else if (x < but->x + but->w - radius) return(y < but->y + but->h); else { dx = x - (but->x + but->w - radius - 1); dy = y - (but->y + but->h - radius - 1); return(dx*dx + dy*dy < radlimit); } } } static ButOut remPress(But *but, void *msg, int msgLen) { Ct *ct = but->iPacket; ButOut res = 0; assert(msgLen == 0); snd_play(&but_upSnd); if ((ct->rfunc != NULL) && ct->netAction) res = ct->rfunc(but); return(res); } void butCt_setNetAction(But *but, bool netAction) { Ct *ct = but->iPacket; ct->netAction = netAction; } #endif cgoban-1.9.14/wmslib/src/but/i_finder.c0000664000671000067100000004055007043224471013334 /* * wmslib/src/but/i_finder.c, part of wmslib (Library functions) * Copyright (C) 1994 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include static void addButToCol(ButCol *col, But *but, int y1, int y2); static void addButToRow(ButRow *row, But *but); static void copyCol(ButCol *dest, ButCol *src); static void copyRow(ButRow *dest, ButRow *src); static void findButSetInCol(ButCol *col, int x, int y, ButSet *butset); static void butDelFromCol(ButCol *col, But *but); static void butDelFromRow(ButRow *row, But *but); static bool colEq(ButCol *c1, ButCol *c2); static bool rowEq(ButRow *r1, ButRow *r2); static void colDel(ButWin *win, int col_num); static void rowDel(ButCol *col, int row_num); static int markForTable(But *but, void *packet); static int addToTable(But *but, void *packet); static int butcomp(const void *a, const void *b); #if 0 /* Useful sometimes for debugging. */ void printf_table(but_win_t *win); void printf_env(but_env_t *win); #endif void butWin_addToTable(ButWin *win) { ButEnv *env = win->env; ButWin **new_winlist; int i, j, new_pos; assert(MAGIC(win)); if (win->win != None) { /* * If win->win is None, then it is a canvas, which does not have to * be entered into the window table yet. */ if (env->wlmax == env->wllen) { new_winlist = wms_malloc(sizeof(ButWin *) * (env->wllen + 1) * 2); for (i = 0; i < env->wllen; ++i) new_winlist[i] = env->winlist[i]; if (env->winlist != NULL) wms_free(env->winlist); env->winlist = new_winlist; env->wlmax = (env->wllen + 1) * 2; } for (i = 0; (i < env->wllen) && (win->win > env->winlist[i]->win); ++i); new_pos = i; for (i = env->wllen; i > new_pos; --i) env->winlist[i] = env->winlist[i-1]; env->winlist[new_pos] = win; ++env->wllen; } if (win->numCols == 0) { /* * A canvas may call this function every time the pixmap changes, so * we have to make sure that we don't re-allocate all this stuff! */ win->numCols = 2; win->maxCols = 2; win->cols = wms_malloc(2 * sizeof(ButCol)); win->cols[0].startX = int_min; win->cols[1].startX = int_max; for (i = 0; i < 2; ++i) { MAGIC_SET(&win->cols[i]); win->cols[i].numRows = 2; win->cols[i].maxRows = 2; win->cols[i].rows = wms_malloc(2 * sizeof(ButRow)); win->cols[i].rows[0].startY = int_min; win->cols[i].rows[1].startY = int_max; for (j = 0; j < 2; ++j) { MAGIC_SET(&win->cols[i].rows[j]); win->cols[i].rows[j].numButs = 0; win->cols[i].rows[j].maxButs = 0; win->cols[i].rows[j].buts = NULL; } } } #if DEBUG for (i = 1; i < env->wllen; ++i) { assert(env->winlist[i]->win > env->winlist[i - 1]->win); } #endif /* DEBUG */ } void butWin_rmFromTable(ButWin *win) { ButEnv *env = win->env; int i; assert(MAGIC(win)); assert(MAGIC(env)); for (i = 0; (env->winlist[i] != win) && (i < env->wllen); ++i); if (i < env->wllen) { --env->wllen; while (i < env->wllen) { env->winlist[i] = env->winlist[i+1]; ++i; } } #if DEBUG for (i = 1; i < env->wllen; ++i) { assert(env->winlist[i]->win > env->winlist[i - 1]->win); } #endif /* DEBUG */ } void but_addToTable(But *but) { ButWin *win = but->win; int x1 = but->x, y1 = but->y, x2 = but->x + but->w, y2 = but->y + but->h; int i, src, dest; ButCol *new_cl = win->cols; int new_cll = win->numCols, new_clmax = win->maxCols; int x1done = 0, x2done = 0; assert(MAGIC(but)); assert(but->flags & BUT_DRAWABLE); butSet_delBut(&win->butsNoDraw, but); for (i = 0; i < new_cll; ++i) { assert(MAGIC(&new_cl[i])); if (new_cl[i].startX == x1) x1done = 1; else if (new_cl[i].startX == x2) x2done = 1; } new_cll += 2 - (x1done + x2done); if (new_cll > win->maxCols) { new_cl = wms_malloc(sizeof(ButCol) * (new_clmax = new_cll * 2)); for (i = 0; i < new_clmax; ++i) { MAGIC_SET(&new_cl[i]); new_cl[i].rows = NULL; } } for (src = win->numCols, dest = new_cll; src > 0;) { --src; --dest; assert(MAGIC(&win->cols[src])); if (!x2done && (win->cols[src].startX < x2)) { assert(MAGIC(&new_cl[dest])); copyCol(&new_cl[dest], &win->cols[src]); new_cl[dest--].startX = x2; x2done = 1; } if (!x1done && (win->cols[src].startX < x1)) { assert(MAGIC(&new_cl[dest])); copyCol(&new_cl[dest], &win->cols[src]); new_cl[dest].startX = x1; addButToCol(&new_cl[dest--], but, y1, y2); x1done = 1; } assert(MAGIC(&new_cl[dest])); new_cl[dest] = win->cols[src]; if ((new_cl[dest].startX < x2) && (new_cl[dest].startX >= x1)) addButToCol(&new_cl[dest], but, y1, y2); } if (win->cols != new_cl) { for (i = 0; i < win->maxCols; ++i) MAGIC_UNSET(&win->cols[i]); wms_free(win->cols); win->cols = new_cl; } win->maxCols = new_clmax; win->numCols = new_cll; } static void addButToCol(ButCol *col, But *but, int y1, int y2) { ButRow *new_rl = col->rows; int i, src, dest, new_rll = col->numRows, new_rlmax = col->maxRows; int y1done=0, y2done=0; assert(MAGIC(col)); assert(MAGIC(but)); for (i = 0; i < col->numRows; ++i) { assert(MAGIC(&col->rows[i])); if (col->rows[i].startY == y1) y1done = 1; if (col->rows[i].startY == y2) y2done = 1; } new_rll += 2 - (y1done + y2done); if (new_rll > col->maxRows) { new_rl = wms_malloc(sizeof(ButRow) * (new_rlmax = new_rll * 2)); for (i = 0; i < new_rlmax; ++i) { MAGIC_SET(&new_rl[i]); new_rl[i].buts = NULL; } } for (src = col->numRows, dest = new_rll; src > 0;) { --src; --dest; assert(MAGIC(&col->rows[src])); if (!y2done && (col->rows[src].startY < y2)) { assert(MAGIC(&new_rl[dest])); copyRow(&new_rl[dest], &col->rows[src]); new_rl[dest--].startY = y2; y2done = 1; } if (!y1done && (col->rows[src].startY < y1)) { assert(MAGIC(&new_rl[dest])); copyRow(&new_rl[dest], &col->rows[src]); new_rl[dest].startY = y1; addButToRow(&new_rl[dest--], but); y1done = 1; } assert(MAGIC(&new_rl[dest])); new_rl[dest] = col->rows[src]; if ((new_rl[dest].startY < y2) && (new_rl[dest].startY >= y1)) addButToRow(&new_rl[dest], but); } if (col->rows != new_rl) { if (col->rows != NULL) { wms_free(col->rows); for (i = 0; i < col->maxRows; ++i) MAGIC_UNSET(&col->rows[i]); } col->rows = new_rl; } col->maxRows = new_rlmax; col->numRows = new_rll; } static void addButToRow(ButRow *row, But *but) { int i, new_maxButs = row->maxButs, new_numButs = row->numButs + 1; But **new_bl = row->buts; assert(MAGIC(row)); assert(MAGIC(but)); if (new_numButs >= row->maxButs) { new_bl = wms_malloc(sizeof(But *) * (new_maxButs = new_numButs * 2)); for (i = 0; i < row->numButs; ++i) new_bl[i] = row->buts[i]; } for (i = row->numButs - 1; (i >= 0) && (but->layer < row->buts[i]->layer); --i) { assert(MAGIC(new_bl[i])); assert(new_bl[i] != but); new_bl[i+1] = new_bl[i]; } new_bl[i+1] = but; #if DEBUG for (; i >= 0; --i) assert(new_bl[i] != but); #endif if ((row->buts != NULL) && (row->buts != new_bl)) wms_free(row->buts); row->buts = new_bl; row->numButs = new_numButs; row->maxButs = new_maxButs; } static void copyCol(ButCol *dest, ButCol *src) { int i; assert(MAGIC(dest)); assert(MAGIC(src)); *dest = *src; dest->rows = wms_malloc(dest->maxRows * sizeof(ButRow)); for (i = 0; i < dest->maxRows; ++i) MAGIC_SET(&dest->rows[i]); for (i = 0; i < dest->numRows; ++i) copyRow(&dest->rows[i], &src->rows[i]); } static void copyRow(ButRow *dest, ButRow *src) { int i; assert(MAGIC(dest)); assert(MAGIC(src)); *dest = *src; dest->buts = wms_malloc(dest->maxButs * sizeof(But *)); for (i = 0; i < dest->numButs; ++i) dest->buts[i] = src->buts[i]; } void butWin_findButSet(ButWin *win, int x, int y, ButSet *butset) { unsigned hlen, result = 0, cllen = win->numCols; assert(MAGIC(win)); butset->dynamic = FALSE; while ((hlen = (cllen >> 1))) { assert(MAGIC(&win->cols[result+hlen])); if (win->cols[result+hlen].startX > x) { cllen = hlen; } else { cllen -= hlen; result += hlen; } } findButSetInCol(&win->cols[result], x, y, butset); } static void findButSetInCol(ButCol *col, int x, int y, ButSet *butset) { unsigned hlen, result = 0, rllen = col->numRows; assert(MAGIC(col)); while ((hlen = (rllen >> 1))) { assert(MAGIC(&col->rows[result+hlen])); if (col->rows[result+hlen].startY > y) { rllen = hlen; } else { rllen -= hlen; result += hlen; } } butset->numButs = col->rows[result].numButs; butset->buts = col->rows[result].buts; butset->dynamic = FALSE; } void but_delFromTable(But *but) { ButWin *win = but->win; int i; ButCol *cl = win->cols; assert(MAGIC(but)); assert(MAGIC(win)); for (i = 1; i < win->numCols - 1; ++i) { assert(MAGIC(&cl[i])); if ((cl[i].startX >= but->x) && (cl[i].startX < but->x + but->w)) { butDelFromCol(&cl[i], but); if (colEq(&cl[i-1], &cl[i])) { colDel(win, i); --i; } if ((i+1 < win->numCols - 1) && colEq(&cl[i], &cl[i+1])) colDel(win, i+1); } } } static bool colEq(ButCol *c1, ButCol *c2) { int i; assert(MAGIC(c1)); assert(MAGIC(c2)); if (c1->numRows != c2->numRows) return(FALSE); for (i = 0; i < c1->numRows; ++i) { if (!rowEq(&c1->rows[i], &c2->rows[i])) return(FALSE); } return(TRUE); } static bool rowEq(ButRow *r1, ButRow *r2) { int i; assert(MAGIC(r1)); assert(MAGIC(r2)); if (r1->numButs != r2->numButs) return(FALSE); for (i = 0; i < r1->numButs; ++i) { if (r1->buts[i] != r2->buts[i]) return(FALSE); } return(TRUE); } static void butDelFromCol(ButCol *col, But *but) { int i; ButRow *rl = col->rows; assert(MAGIC(col)); for (i = 1; i < col->numRows - 1; ++i) { assert(MAGIC(&rl[i])); if ((rl[i].startY >= but->y) && (rl[i].startY < but->y + but->h)) { butDelFromRow(&rl[i], but); if (rowEq(&rl[i-1], &rl[i])) { rowDel(col, i); --i; } if ((i+1 < col->numRows - 1) && rowEq(&rl[i], &rl[i+1])) rowDel(col, i+1); } } } static void butDelFromRow(ButRow *row, But *but) { int dest, src; assert(MAGIC(row)); for (dest = 0, src = 0; src < row->numButs; ++src) { assert(MAGIC(row->buts[src])); row->buts[dest] = row->buts[src]; if (row->buts[dest] != but) { ++dest; } else { assert(src == dest); } } assert(src == dest + 1); --row->numButs; assert(dest == row->numButs); } static void colDel(ButWin *win, int col_num) { int i; assert(MAGIC(win)); assert(MAGIC(&win->cols[col_num])); for (i = 0; i < win->cols[col_num].numRows; ++i) { assert(MAGIC(&win->cols[col_num].rows[i])); if (win->cols[col_num].rows[i].buts != NULL) wms_free(win->cols[col_num].rows[i].buts); } wms_free(win->cols[col_num].rows); --win->numCols; for (i = col_num; i < win->numCols; ++i) win->cols[i] = win->cols[i+1]; } static void rowDel(ButCol *col, int row_num) { int i; assert(MAGIC(col)); assert(MAGIC(&col->rows[row_num])); if (col->rows[row_num].buts != NULL) wms_free(col->rows[row_num].buts); --col->numRows; for (i = row_num; i < col->numRows; ++i) col->rows[i] = col->rows[i+1]; } void butWin_findButSetInRegion(ButWin *win, int x, int y, int w, int h, ButSet *butset) { assert(MAGIC(win)); butset->numButs = 0; butset->dynamic = TRUE; butWin_findButsInRegion(win, x,y, w,h, markForTable, butset); if (butset->numButs > 0) { butset->buts = wms_malloc(butset->numButs * sizeof(But *)); butset->maxButs = butset->numButs; butset->numButs = 0; butWin_findButsInRegion(win, x,y, w,h, addToTable, butset); qsort(butset->buts, butset->numButs, sizeof(But *), butcomp); } else { butset->dynamic = FALSE; butset->buts = NULL; } } static int markForTable(But *but, void *packet) { ButSet *butset = packet; if (but == NULL) { return(0); } assert(MAGIC(but)); if ((but->flags & (BUT_TABLED|BUT_DEAD|BUT_DRAWABLE)) == BUT_DRAWABLE) { ++butset->numButs; but->flags |= BUT_TABLED; } return(0); } static int addToTable(But *but, void *packet) { ButSet *butset = packet; assert(MAGIC(but)); if (but->flags & BUT_TABLED) { butset->buts[butset->numButs++] = but; assert(butset->numButs <= butset->maxButs); but->flags &= ~BUT_TABLED; } return(0); } static int butcomp(const void *a, const void *b) { const But *but_a = *(But **)a; const But *but_b = *(But **)b; assert(MAGIC(but_a)); assert(MAGIC(but_b)); if (but_a->layer != but_b->layer) return(but_a->layer - but_b->layer); else if (but_a > but_b) return(-1); else return(1); } ButWin *butEnv_findWin(ButEnv *env, Window win) { int wmin = 0, wmax = env->wllen, wnum; #if DEBUG for (wnum = 1; wnum < env->wllen; ++wnum) { assert(env->winlist[wnum]->win > env->winlist[wnum - 1]->win); } #endif /* DEBUG */ while (wmin < wmax) { wnum = (wmax + wmin) >> 1; assert(MAGIC(env->winlist[wnum])); if (env->winlist[wnum]->win == win) { return(env->winlist[wnum]); } if (env->winlist[wnum]->win > win) { wmax = wnum; } else { wmin = wnum + 1; } } return(NULL); } But *butWin_findButsInRegion(ButWin *win, int x,int y, int w,int h, bool (*action)(But *but, void *packet), void *packet) { int r, c, b; ButCol *col; ButRow *row; But *but; assert(MAGIC(win)); for (c = 1; c < win->numCols - 1; ++c) { col = &win->cols[c]; assert(MAGIC(col)); if ((col->startX < x+w) && (win->cols[c+1].startX > x)) { for (r = 1; r < col->numRows - 1; ++r) { row = &col->rows[r]; assert(MAGIC(row)); if ((row->startY < y+h) && (col->rows[r+1].startY > y)) { for (b = 0; b < row->numButs; ++b) { but = row->buts[b]; assert(MAGIC(but)); if (action(but, packet)) return(but); } } } } } return(NULL); } #if 0 /* Sometimes useful for debugging. */ void printf_env(but_env_t *env) { int i; printf("Env has %d (max %d) windows:\n", env->wllen, env->wlmax); for (i = 0; i < env->wllen; ++i) printf(" 0x%x (x win %d)\n", (int)env->winlist[i], (int)(env->winlist[i]->win)); } void printf_table(but_win_t *win) { int i, j, k; for (i = 0; i < win->numCols - 1; ++i) { printf("Col %d of %d: %d..%d\n", i+1, win->numCols - 1, win->cols[i].startX, win->cols[i+1].startX - 1); for (j = 0; j < win->cols[i].numRows - 1; ++j) { printf(" Row %d of %d: %d..%d\n", j+1, win->cols[i].numRows - 1, win->cols[i].rows[j].startY, win->cols[i].rows[j+1].startY - 1); if (win->cols[i].rows[j].numButs == 0) printf(" No buttons.\n"); else { for (k = 0; k < win->cols[i].rows[j].numButs; ++k) printf(" But 0x%x\n", (int)win->cols[i].rows[j].buts[k]); } } } printf("---\n"); } #endif void butSet_addBut(ButSet *butset, But *but) { int i, new_maxButs; But **newbuts; assert(MAGIC(butset)); assert(butset->dynamic); for (i = 0; i < butset->numButs; ++i) { if (butset->buts[i] == but) return; } if (butset->numButs == butset->maxButs) { new_maxButs = (butset->maxButs + 1) * 2; newbuts = wms_malloc(new_maxButs * sizeof(But *)); if (butset->buts != NULL) { memcpy(newbuts, butset->buts, butset->maxButs * sizeof(But *)); wms_free(butset->buts); } butset->buts = newbuts; butset->maxButs = new_maxButs; } butset->buts[butset->numButs++] = but; } void butSet_delBut(ButSet *butset, But *but) { int i; assert(MAGIC(butset)); for (i = 0; i < butset->numButs; ++i) { if (butset->buts[i] == but) { butset->buts[i] = butset->buts[--butset->numButs]; return; } } } #endif cgoban-1.9.14/wmslib/src/but/i_general.c0000664000671000067100000004606007043224471013504 /* * wmslib/src/but/i_general.c, part of wmslib (Library functions) * Copyright (C) 1994,1997 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #include #include /********************************************************************** * Forward Declarations **********************************************************************/ static void mousein(ButWin *win, int x, int y, ButSet *butset); /********************************************************************** * Globals **********************************************************************/ bool but_inEvent = FALSE; /********************************************************************** * Functions **********************************************************************/ void but_init(But *but) { ButWin *win = but->win; ButEnv *env = win->env; int nfl; assert(MAGIC(win)); MAGIC_SET(but); if (!(but->flags & BUT_DRAWABLE)) return; if (win->maxLayer < win->minLayer) win->maxLayer = win->minLayer = but->layer; else { if (but->layer < win->minLayer) win->minLayer = but->layer; if (but->layer > win->maxLayer) win->maxLayer = but->layer; } butSet_addBut(&win->butsNoDraw, but); if (but->w > 0) but_addToTable(but); if (but->flags & BUT_KEYED) { if (win->keyBut != NULL) { nfl = win->keyBut->flags & ~BUT_KEYED; if (env->last_mwin == win) nfl &= ~BUT_KEYACTIVE; but_newFlags(win->keyBut, nfl); } win->keyBut = but; if (env->last_mwin == win) but->flags |= BUT_KEYACTIVE; } nfl = but->flags; but->flags = BUT_DRAWABLE; /* Force a new flags type redraw. */ but_newFlags(but, nfl); butWin_mMove(env->last_mwin, env->last_mx, env->last_my); } void but_resize(But *but, int x, int y, int w, int h) { int oldx = but->x, oldy = but->y, oldw = but->w, oldh = but->h; assert(MAGIC(but)); if ((oldx == x) && (oldy == y) && (oldw == w) && (oldh == h)) return; if ((w <= 0) || (h <= 0)) w = h = 0; if ((oldw > 0) && (but->flags & BUT_DRAWABLE)) but_delFromTable(but); but->x = x; but->y = y; but->w = w; but->h = h; if ((w > 0) && (but->flags & BUT_DRAWABLE)) but_addToTable(but); if (but->action->resize) { if (but->action->resize(but, oldx, oldy, oldw, oldh) && (but->flags & BUT_DRAWABLE)) { butWin_redraw(but->win, oldx,oldy, oldw,oldh); butWin_redraw(but->win, x,y, w,h); } } else if (but->flags & BUT_DRAWABLE) { if ((oldw > 0) && (oldh > 0)) butWin_redraw(but->win, oldx,oldy, oldw,oldh); butWin_redraw(but->win, x,y, w,h); } if (but->flags & BUT_DRAWABLE) butWin_mMove(but->win->env->last_mwin, but->win->env->last_mx, but->win->env->last_my); } void but_destroy(But *but) { ButTimer *timer; if (but != NULL) { assert(MAGIC(but)); but_newFlags(but, 0); for (timer = but_timerList; timer != NULL; timer = timer->next) { if (timer->but == but) { butTimer_destroy(timer); break; } } } if (but_inEvent) but_dList(but); else but_delete(but); } But *but_create(ButWin *win, void *iPacket, const ButAction *action) { But *but; but = (But *)wms_malloc(sizeof(But)); MAGIC_SET(but); assert(win->parent || (win->win != None)); but->uPacket = NULL; but->iPacket = iPacket; but->win = win; but->layer = 0; but->x = 0; but->y = 0; but->w = 0; but->h = 0; but->id = -2; but->flags = 0; but->keys = NULL; but->action = action; but->destroyCallback = NULL; return(but); } ButOut but_delete(But *but) { ButOut result = 0; ButWin *win = but->win; int x = but->x, y = but->y, w = but->w, h = but->h; assert(but != NULL); assert(MAGIC(win)); assert(MAGIC(but)); if (but->flags) but_newFlags(but, 0); if (but->destroyCallback) but->destroyCallback(but); if (but->action->destroy != NULL) result = but->action->destroy(but); MAGIC_UNSET(but); wms_free(but); butWin_redraw(win, x,y,w,h); return(result); } void but_setFlags(But *but, uint fch) { uint fl; assert(MAGIC(but)); fl = but->flags | fch; fl &= ~(fch >> BUT_MAXBITS); but_newFlags(but, fl); } void but_setKeys(But *but, const ButKey *keys) { assert(MAGIC(but)); assert((but->action->kPress) || (but->action->kRelease)); but->keys = keys; } void but_newFlags(But *but, uint nfl) { static bool inNewFlags = FALSE; ButWin *win = but->win, *tmpWin, *ancestor; ButEnv *env = win->env; uint oldflags = but->flags; assert(MAGIC(win)); assert(MAGIC(but)); for (ancestor = win; ancestor->parent; ancestor = ancestor->parent) assert(MAGIC(ancestor)); if (!(nfl & BUT_PRESSABLE)) { nfl &= ~(BUT_PRESSED|BUT_TWITCHED|BUT_LOCKED); if (env->curhold == but) butEnv_setCursor(env, but, butCur_idle); } if (!(oldflags & BUT_DRAWABLE) && (nfl & BUT_DRAWABLE)) { but->flags = nfl; but_init(but); return; } if (!(nfl & BUT_DRAWABLE) && (env->butIn == but)) { env->butIn = NULL; for (tmpWin = win; tmpWin; tmpWin = tmpWin->parent) { assert(MAGIC(tmpWin)); tmpWin->butIn = NULL; } } if ((oldflags & BUT_KEYED) && !(nfl & BUT_KEYED)) { nfl &= ~BUT_KEYACTIVE; ancestor->keyBut = NULL; } if (!(oldflags & BUT_KEYED) && (nfl & BUT_KEYED)) { if (ancestor->keyBut != NULL) { but_newFlags(ancestor->keyBut, ancestor->keyBut->flags & ~BUT_KEYED); } ancestor->keyBut = but; if (env->last_mwin == but->win) { nfl |= BUT_KEYACTIVE; } } if ((but->id != -2) && !inNewFlags && ((nfl & BUT_NETMASK) != (but->flags & BUT_NETMASK))) { inNewFlags = TRUE; butRnet_newFlags(env, but->id, nfl); inNewFlags = FALSE; } if (!(oldflags & BUT_LOCKED) && (nfl & BUT_LOCKED)) { if (env->lockBut != NULL) but_newFlags(env->lockBut, env->lockBut->flags & ~BUT_LOCKED); env->lockBut = but; win->lock = but; for (tmpWin = env->lockBut->win; tmpWin->parent; tmpWin = tmpWin->parent) { assert(MAGIC(tmpWin)); tmpWin->parent->lock = tmpWin->parentBut; } } else if ((oldflags & BUT_LOCKED) && !(nfl & BUT_LOCKED)) { for (tmpWin = but->win; tmpWin; tmpWin = tmpWin->parent) { assert(MAGIC(tmpWin)); tmpWin->lock = NULL; } env->lockBut = NULL; } if (nfl != oldflags) { assert(but->action->newFlags); but->action->newFlags(but, nfl); } if ((oldflags & BUT_DRAWABLE) && !(nfl & BUT_DRAWABLE)) { if (but->w > 0) { but_delFromTable(but); } } butWin_mMove(env->last_mwin, env->last_mx, env->last_my); } void but_draw(But *but) { assert(MAGIC(but)); if ((but->flags & (BUT_DRAWABLE|BUT_DEAD)) == BUT_DRAWABLE) butWin_redraw(but->win, but->x,but->y, but->w,but->h); } ButOut butWin_mMove(ButWin *win, int x, int y) { ButEnv *env; ButOut result = 0; int i; But *but, *oldbut; ButSet butset; ButWin *tmpWin; assert(MAGICNULL(win)); if (win == NULL) return(0); env = win->env; if ((env->last_mwin != win) && (!env->last_mwin || (env->last_mwin->physWin != win->physWin))) { env->curwin = win->physWin; env->curlast = butCur_bogus; } if (win->parent == NULL) { /* Only do this if you're on a real window, that is, not in a canvas. */ env->last_mwin = win; env->last_mx = x; env->last_my = y; } mousein(win, x, y, &butset); for (i = butset.numButs - 1; i >= 0; --i) { but = butset.buts[i]; assert(MAGIC(but)); if ((but->flags & BUT_DRAWABLE) && !(but->flags & BUT_PRESSTHRU)) { if (but->action->mMove == NULL) result |= BUTOUT_CAUGHT; else result |= but->action->mMove(but, x,y); if (result & BUTOUT_CAUGHT) { if (result & BUTOUT_IGNORE) return(result); if (env->butIn != but) { if (env->butIn != NULL) { for (tmpWin = env->butIn->win; tmpWin; tmpWin = tmpWin->parent) { tmpWin->butIn = NULL; } if ((env->butIn->flags & BUT_PRESSABLE) && (env->butIn->action->mLeave != NULL)) result |= env->butIn->action->mLeave(env->butIn); } env->butIn = but; but->win->butIn = but; for (tmpWin = but->win; tmpWin->parent; tmpWin = tmpWin->parent) { tmpWin->parent->butIn = tmpWin->parentBut; } } return(result); } } } if (env->butIn != NULL) { oldbut = env->butIn; for (tmpWin = env->butIn->win; tmpWin; tmpWin = tmpWin->parent) { tmpWin->butIn = NULL; } env->butIn = NULL; if ((oldbut->flags & BUT_PRESSABLE) && (oldbut->action->mLeave != NULL)) result |= oldbut->action->mLeave(oldbut); } return(result); } ButOut butWin_mPress(ButWin *win, int x, int y, int butnum) { ButOut result; But *but; assert(MAGIC(win)); result = butWin_mMove(win, x, y); but = win->butIn; if (but != NULL) { assert(MAGIC(but)); if ((but->flags & BUT_PRESSABLE) && (but->action->mPress != NULL)) { return(result | but->action->mPress(but, butnum, x, y)); } } return(result | BUTOUT_ERR); } ButOut butWin_mRelease(ButWin *win, int x, int y, int butnum) { ButOut result; But *but; assert(MAGIC(win)); result = butWin_mMove(win, x, y); but = win->butIn; if (but != NULL) { assert(MAGIC(but)); if ((but->flags & BUT_PRESSABLE) && (but->action->mRelease != NULL)) return(result | but->action->mRelease(but, butnum, x, y)); } return(result); } static int keycheck(But *but, void *packet) { int keycount; KeySym sym = *(KeySym *)packet; assert(MAGIC(but)); if (but->keys != NULL) { for (keycount = 0; but->keys[keycount].key != 0; ++keycount) { if ((but->keys[keycount].key == sym) && ((but->win->env->keyModifiers & but->keys[keycount].modMask) == but->keys[keycount].modifiers)) return(1); } } return(0); } ButOut butWin_kPress(ButWin *win, const char *keystr, KeySym sym) { ButOut retVal = 0; But *but; assert(MAGIC(win)); /* * The keybut _always_ get a shot at the key when it is pressed. */ if (win->keyBut) { assert(win->keyBut->flags & BUT_PRESSABLE); retVal |= win->keyBut->action->kPress(win->keyBut, keystr, sym); } if (!(retVal & BUTOUT_CAUGHT)) { but = butWin_findButsInRegion(win, 0,0, win->w,win->h, keycheck, &sym); if ((but != NULL) && (but->flags & BUT_PRESSABLE) && (but->action->kPress != NULL)) { assert(MAGIC(but)); retVal |= but->action->kPress(but, keystr, sym); } else { /* * A key was pressed that nobody wanted. * But only signal an error if it was a "real" key...don't beep when * some poor guy presses shift! */ if (!IsModifierKey(sym)) retVal |= BUTOUT_ERR; } } return(retVal); } ButOut butWin_kRelease(ButWin *win, const char *keystr, KeySym sym) { ButOut retval = 0; But *but; assert(MAGIC(win)); but = butWin_findButsInRegion(win, 0,0, win->w,win->h, keycheck, &sym); if (but != NULL) { assert(MAGIC(but)); if ((but->flags & BUT_PRESSABLE) && (but->action->kRelease != NULL)) retval |= but->action->kRelease(but, keystr, sym); } return(retval); } /* mousein(win, x, y, reason) will return the button number that the mouse is * presently inside of. If the mouse is not in any button NULL will * be returned. * The checkfunc will be called only if the mouse is already inside the * (x,y,w,h) boundaries of the button. "reason" is one of BUT_RE_PRESS, * BUT_RE_RELEASE, or BUT_RE_MOVE, depending on the reason for the button * to be checked. * Non-pressable buttons will never be returned. * * NOTE: This does a linear search through the buttons. YUCK! SLOW! I'd * like to recode this to do a three-dimensional binary search (the * dimensions being window, x, and y) but that would take some seriously * heavy-duty coding and I have a million other things to do first. * * NOTE to note: I finally did the 3d binary search. Works great! */ static void mousein(ButWin *win, int x, int y, ButSet *butset) { static But *but; assert(MAGIC(win)); if (win->lock) { butset->dynamic = FALSE; butset->numButs = 1; butset->buts = &but; but = win->lock; } else butWin_findButSet(win, x, y, butset); } static int but_compare(const void *a, const void *b) { But **but_a = (But **)a, **but_b = (But **)b; assert(MAGIC(*but_a)); assert(MAGIC(*but_b)); return((*but_a)->layer - (*but_b)->layer); } void butWin_redraw(ButWin *win, int x, int y, int w, int h) { ButWinArea *newAreas; int newMaxRedraws, i; bool change; assert((x > -1000) && (y > -1000)); if (!w || !h) return; assert(w > 0); assert(h > 0); if (win->numRedraws + 1 >= win->maxRedraws) { newMaxRedraws = (win->maxRedraws + 1) * 2; newAreas = wms_malloc(newMaxRedraws * sizeof(ButWinArea)); for (i = 0; i < win->numRedraws; ++i) { newAreas[i] = win->redraws[i]; } if (win->redraws) wms_free(win->redraws); win->redraws = newAreas; win->maxRedraws = newMaxRedraws; } assert(win->numRedraws < win->maxRedraws); do { assert(w > 0); assert(h > 0); change = FALSE; for (i = 0; i < win->numRedraws; ++i) { if ((x <= win->redraws[i].x + win->redraws[i].w) && (y <= win->redraws[i].y + win->redraws[i].h) && (x + w >= win->redraws[i].x) && (y + h >= win->redraws[i].y)) { change = TRUE; if (win->redraws[i].x < x) { w += x - win->redraws[i].x; x = win->redraws[i].x; } if (win->redraws[i].y < y) { h += y - win->redraws[i].y; y = win->redraws[i].y; } if (x + w < win->redraws[i].x + win->redraws[i].w) w = win->redraws[i].x + win->redraws[i].w - x; if (y + h < win->redraws[i].y + win->redraws[i].h) h = win->redraws[i].y + win->redraws[i].h - y; win->redraws[i] = win->redraws[--win->numRedraws]; } } } while (change); win->redraws[win->numRedraws].x = x; win->redraws[win->numRedraws].y = y; win->redraws[win->numRedraws].w = w; win->redraws[win->numRedraws].h = h; assert(w > 0); assert(h > 0); ++win->numRedraws; assert(win->numRedraws < win->maxRedraws); } void butWin_performDraws(ButWin *win) { int drawNum; int i, drx,dry, drw,drh, x, y, w, h; ButEnv *env = win->env; XRectangle cliprect; ButSet butset; But *but; assert(MAGIC(win)); if (!win->mapped) { win->numRedraws = 0; return; } for (drawNum = 0; drawNum < win->numRedraws; ++drawNum) { x = win->redraws[drawNum].x; y = win->redraws[drawNum].y; w = win->redraws[drawNum].w; h = win->redraws[drawNum].h; assert(w > 0); assert(h > 0); if (x < win->xOff) { w -= win->xOff - x; x = win->xOff; } if (x + w > win->xOff + win->w) w = win->xOff + win->w - x; if (y < win->yOff) { h -= win->yOff - y; y = win->yOff; } if (y + h > win->yOff + win->h) h = win->yOff + win->h - y; if ((w <= 0) || (h <= 0)) continue; if (win->id != -2) butRcur_redraw(env, win->id, x,y,w,h); butWin_findButSetInRegion(win, x,y, w,h, &butset); if (butset.numButs > 0) { cliprect.x = x - win->xOff; cliprect.y = y - win->yOff; cliprect.width = w; cliprect.height = h; XSetClipRectangles(env->dpy, env->gc, 0,0, &cliprect, 1, YXSorted); qsort(butset.buts, butset.numButs, sizeof(But *), but_compare); assert(MAGIC(win)); for (i = butset.numButs - 1; i > 0; --i) { but = butset.buts[i]; assert(MAGIC(but)); if ((but->flags & BUT_OPAQUE) && (but->x <= x) && (but->y <= y) && (but->x + but->w >= x + w) && (but->y + but->h >= y + h)) break; } for (; i < butset.numButs; ++i) { but = butset.buts[i]; assert(MAGIC(but)); if (!(but->flags & BUT_DEAD)) { if (but->x < x) drx = x; else drx = but->x; if (but->y < y) dry = y; else dry = but->y; if (but->x + but->w < x+w) drw = but->x + but->w - drx; else drw = x + w - drx; if (but->y + but->h < y+h) drh = but->y + but->h - dry; else drh = y+h - dry; but->action->draw(but, x,y, w,h); } } XSetClipMask(env->dpy, env->gc, None); butSet_destroy(&butset); if (win->parent) { /* * It's a canvas. Fire off a redraw request so that the changes to * the canvas pixmap will be seen on the screen. */ butCan_redrawn(win, x, y, w, h); } } } win->numRedraws = 0; } void butSet_destroy(ButSet *butset) { if (butset->dynamic && (butset->buts != NULL)) wms_free(butset->buts); } /* If win is NULL it will execute all destroy commands built up. */ ButOut butWin_dList(ButWin *win) { static ButWin **dlist = NULL; static int dlist_len = 0, max_dlist_len = 0; ButWin **new_dlist; int i; ButOut result = 0; assert(MAGICNULL(win)); if (win == NULL) { /* * It is really important that we start at the end here. Since our * child windows are added to the _end_ of the dlist, and they _must_ * be destroyed first, we have to go backwards. */ while (dlist_len) { i = dlist_len - 1; if (dlist[i] != NULL) { assert(MAGIC(dlist[i])); result |= butWin_delete(dlist[i]) | BUTOUT_CAUGHT; if (result & BUTOUT_STILLBUTS) { /* Window still has buttons...can't kill it yet! */ return(result & ~BUTOUT_STILLBUTS); } dlist[i] = NULL; } --dlist_len; } } else { if (win->iconWin != NULL) { butWin_dList(win->iconWin); win->iconWin = NULL; } if (dlist_len+1 > max_dlist_len) { new_dlist = wms_malloc(sizeof(ButWin *) * (dlist_len * 2 + 2)); for (i = 0; i < dlist_len; ++i) new_dlist[i] = dlist[i]; if (dlist != NULL) wms_free(dlist); dlist = new_dlist; max_dlist_len = (dlist_len * 2 + 2); } for (i = 0; i < dlist_len; ++i) if (dlist[i] == win) return(result); dlist[dlist_len++] = win; } return(result); } /* If but is NULL it will execute all destroy commands built up. */ ButOut but_dList(But *but) { static But **dlist = NULL; static int dlist_len = 0, max_dlist_len = 0; But **new_dlist; int i; ButOut result = 0; if (but == NULL) { if (dlist_len == 0) return(0); for (i = 0; i < dlist_len; ++i) { result |= but_delete(dlist[i]) | BUTOUT_CAUGHT; } dlist_len = 0; } else { if (dlist_len+1 > max_dlist_len) { new_dlist = wms_malloc(sizeof(But *) * (dlist_len * 2 + 2)); for (i = 0; i < dlist_len; ++i) new_dlist[i] = dlist[i]; if (dlist != NULL) wms_free(dlist); dlist = new_dlist; max_dlist_len = (dlist_len * 2 + 2); } for (i = 0; i < dlist_len; ++i) if (dlist[i] == but) return(result); but_newFlags(but, 0); dlist[dlist_len++] = but; but->flags |= BUT_DEAD; } return(result); } void but_flags(But *but, uint flags) { but->flags = flags; but_draw(but); } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/i_snd.c0000664000671000067100000000235407043224471012651 /* * wmslib/src/but/i_snd.c, part of wmslib (Library functions) * Copyright (C) 1994 William Shubert. * See "configure.h.in" for more copyright information. */ #include #if X11_DISP #include #include static uchar butdown[] = { /* * Actual noise: The final click as you slam a pair of scissors * shut. */ 88,93,188,250,62,199,229,69,77,197,111,68,206,217,77,59,198,62, 79,203,216,95,207,188,167,199,35,78,89,159,163,45,155,177,106,47, 159,169,31,170,58,90,45,73,45,216,42,75,58,186,55,120,175,61,69, 191,121,44,181,122,86,64,189,93,74,187,189,100,185,183,239,196}; static uchar butup[] = { /* * Actual noise: The final click as you slam a pair of scissors * shut. * This is a slightly different sample than butdown; more echoish. */ 171,71,87,89,55,224,211,203,66,91,90,53,175,188,70,72,76,76,230, 190,174,56,55,213,79,91,193,216,77,87,202,199,220,95,79,70,58, 187,175,61,172,86,48,189,198,92,96,205,67,78,198,179,56,55,191, 44,207,180,54,186,206,69,180,185,43,187,184,67,195,93,164,208,71, 156,229,163,44,24,156,168,71,23,235,166,144,173,207,149,221,237, 30,49,26}; Snd but_downSnd = snd_define(butdown); Snd but_upSnd = snd_define(butup); #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/i_win.c0000664000671000067100000003230707056055725012673 /* * $Source: /cvsroot/cgoban1/cgoban1/wmslib/src/but/i_win.c,v $ * $Revision: 1.2 $ * $Date: 2000/02/26 23:03:49 $ * * wmslib/src/but/i_win.c, part of wmslib (Library functions) * Copyright © 1994-2000 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include /********************************************************************** * Forward declarations **********************************************************************/ static ButWin *create(void *packet, ButEnv *env, const char *name, int w, int h, ButWinFunc *resize); /********************************************************************** * Functions **********************************************************************/ ButWin *butWin_iCreate(void *packet, ButEnv *env, const char *name, int w, int h, ButWin **iWin, bool iconic, int iW, int iH, ButWinFunc *unmap, ButWinFunc *map, ButWinFunc *resize, ButWinFunc *iResize, ButWinFunc *destroy) { ButWin *result; result = create(packet, env, name, w, h, resize); result->unmap = unmap; result->map = map; result->destroy = destroy; result->quit = NULL; if (iWin) { *iWin = create(packet, env, name, iW, iH, iResize); (*iWin)->isIcon = TRUE; result->iconWin = *iWin; result->iconic = iconic; butWin_activate(*iWin); } return(result); } static ButWin *create(void *packet, ButEnv *env, const char *name, int w, int h, ButWinFunc *resize) { ButWin *win; win = wms_malloc(sizeof(ButWin)); MAGIC_SET(win); MAGIC_SET(&win->butsNoDraw); win->parent = NULL; win->parentBut = NULL; win->packet = packet; win->iPacket = NULL; win->win = None; win->physWin = None; win->iconWin = NULL; win->name = name; win->iconic = FALSE; win->isIcon = FALSE; win->x = int_max; win->y = int_max; win->w = win->minW = win->maxW = win->logicalW = w; win->h = win->minH = win->maxH = win->logicalH = h; win->wStep = 1; win->hStep = 1; win->xOff = 0; win->yOff = 0; win->minWRatio = win->minHRatio = win->maxWRatio = win->maxHRatio = 0; win->resized = FALSE; win->resizeNeeded = FALSE; win->redrawReady = TRUE; win->redraws = NULL; win->numRedraws = win->maxRedraws = 0; win->id = 0; win->mapped = FALSE; win->unmap = NULL; win->map = NULL; win->resize = resize; win->destroy = NULL; win->quit = NULL; win->env = env; win->minLayer = 1; win->maxLayer = 0; win->butsNoDraw.buts = NULL; win->butsNoDraw.numButs = 0; win->butsNoDraw.maxButs = 0; win->butsNoDraw.dynamic = TRUE; win->lock = NULL; win->butIn = NULL; win->keyBut = NULL; win->numCols = 0; win->maxCols = 0; win->cols = NULL; return(win); } void butWin_setGeom(ButWin *win, const char *geometry) { char xdir = '+', ydir = '+'; int pcount; int defscr = DefaultScreen(win->env->dpy); assert(MAGIC(win)); if (geometry[0] == '=') ++geometry; if ((geometry[0] == '+') || (geometry[0] == '-')) { pcount = sscanf(geometry, "%c%d%c%d", &xdir, &win->x, &ydir, &win->y); if ((pcount != 4) || ((xdir != '-') && (xdir != '+')) || ((ydir != '-') && (ydir != '+'))) { fprintf(stderr, "Error: Cannot understand geometry \"%s\".\n", geometry); abort(); } } else { pcount = sscanf(geometry, "%dx%d%c%d%c%d", &win->w, &win->h, &xdir, &win->x, &ydir, &win->y); if (((pcount != 2) && (pcount != 6)) || ((xdir != '-') && (xdir != '+')) || ((ydir != '-') && (ydir != '+'))) { fprintf(stderr, "Error: Cannot understand geometry \"%s\".\n", geometry); abort(); } } if (xdir == '-') win->x = DisplayWidth(win->env->dpy, defscr) - win->x - win->w; if (ydir == '-') win->y = DisplayHeight(win->env->dpy, defscr) - win->y - win->h; butWin_checkDims(win); } void butWin_setX(ButWin *win, int x) { assert(MAGIC(win)); win->x = x; butWin_checkDims(win); } void butWin_setY(ButWin *win, int y) { assert(MAGIC(win)); win->y = y; butWin_checkDims(win); } void butWin_setMinW(ButWin *win, int minW) { assert(MAGIC(win)); win->minW = minW; butWin_checkDims(win); } void butWin_setMinH(ButWin *win, int minH) { assert(MAGIC(win)); win->minH = minH; butWin_checkDims(win); } void butWin_setMaxW(ButWin *win, int maxW) { assert(MAGIC(win)); if (maxW == 0) maxW = int_max / 2; win->maxW = maxW; butWin_checkDims(win); } void butWin_setMaxH(ButWin *win, int maxH) { assert(MAGIC(win)); if (maxH == 0) maxH = int_max / 2; win->maxH = maxH; butWin_checkDims(win); } void butWin_setWHRatio(ButWin *win, int w, int h) { assert(MAGIC(win)); win->minWRatio = w; win->maxWRatio = w; win->minHRatio = h; win->maxHRatio = h; butWin_checkDims(win); } void butWin_setWHRatios(ButWin *win, int minW, int minH, int maxW, int maxH) { assert(MAGIC(win)); assert(minW / minH <= maxW / maxH); assert(minH / minW >= maxH / maxW); win->minWRatio = minW; win->minHRatio = minH; win->maxWRatio = maxW; win->maxHRatio = maxH; butWin_checkDims(win); } void butWin_setWStep(ButWin *win, int wStep) { assert(MAGIC(win)); win->wStep = wStep; butWin_checkDims(win); } void butWin_setHStep(ButWin *win, int hStep) { assert(MAGIC(win)); win->hStep = hStep; butWin_checkDims(win); } void butWin_activate(ButWin *win) { ButEnv *env = win->env; Display *dpy = env->dpy; uint hintmask = USSize; int defscr = DefaultScreen(dpy); XSizeHints *sizeHints; XSetWindowAttributes winattr; XWMHints wm_hints; XClassHint class_hints; XTextProperty windowName, iconName; static char *dumb_argv[] = {NULL}; static Atom protocols[1]; /* Stupid X doesn't call their strings const always. */ char *annoyance; char annoy2[] = "Basicwin"; sizeHints = XAllocSizeHints(); if (win->x != int_max) { hintmask |= USPosition; if (win->x + win->w / 2 < 0) win->x = -win->w / 2; if (win->x + win->w / 2 > env->rootW) win->x = env->rootW - win->w/2; if (win->y + win->h / 2 < 0) win->y = -win->h/2; if (win->y + win->h / 2 > env->rootH) win->y = env->rootH - win->h / 2; } winattr.background_pixel = env->colors[BUT_BG]; winattr.event_mask = ExposureMask | StructureNotifyMask; winattr.bit_gravity = NorthWestGravity; if (win->isIcon) { win->win = XCreateWindow(dpy, DefaultRootWindow(dpy), win->x,win->y, win->w, win->h, 0, env->depth, InputOutput, CopyFromParent, CWBackPixel|CWEventMask|CWBitGravity, &winattr); win->physWin = win->win; XSelectInput(dpy, win->win, ExposureMask|StructureNotifyMask); } else { winattr.event_mask |= PointerMotionMask | ButtonPressMask | KeyPressMask | ButtonReleaseMask | KeyReleaseMask | LeaveWindowMask | FocusChangeMask; win->win = XCreateWindow(dpy, RootWindow(dpy, defscr), win->x,win->y, win->w,win->h, 0, env->depth, InputOutput, CopyFromParent, CWBackPixel|CWEventMask|CWBitGravity, &winattr); win->physWin = win->win; sizeHints->flags = PSize | PMinSize | PMaxSize | hintmask; sizeHints->max_width = win->maxW; sizeHints->max_height = win->maxH; sizeHints->min_width = win->minW; sizeHints->min_height = win->minH; if (win->minWRatio != 0) { sizeHints->flags |= (PAspect | PBaseSize); sizeHints->min_aspect.x = win->minWRatio; sizeHints->min_aspect.y = win->minHRatio; sizeHints->max_aspect.x = win->maxWRatio; sizeHints->max_aspect.y = win->maxHRatio; sizeHints->base_width = 0; sizeHints->base_height = 0; } if ((win->wStep != 1) || (win->hStep != 1)) { sizeHints->flags |= PResizeInc; sizeHints->width_inc = win->wStep; sizeHints->height_inc = win->hStep; } wm_hints.flags = StateHint | InputHint; if (win->iconWin != None) { wm_hints.flags |= IconWindowHint; wm_hints.icon_window = win->iconWin->win; } annoyance = wms_malloc(strlen(win->name) + 1); strcpy(annoyance, win->name); if (XStringListToTextProperty(&annoyance, 1, &iconName) == 0) { fprintf(stderr, "Cannot allocate icon name.\n"); abort(); } if (XStringListToTextProperty(&annoyance, 1, &windowName) == 0) { fprintf(stderr, "Cannot allocate window name.\n"); abort(); } if (win->iconic) wm_hints.initial_state = IconicState; else wm_hints.initial_state = NormalState; wm_hints.input = True; class_hints.res_name = annoyance; class_hints.res_class = annoy2; XSetWMProperties(dpy, win->win, &windowName, &iconName, dumb_argv, 0, sizeHints, &wm_hints, &class_hints); protocols[0] = but_wmDeleteWindow; XSetWMProtocols(dpy, win->win, protocols, 1); XMapWindow(dpy, win->win); wms_free(annoyance); } XFree(sizeHints); butWin_addToTable(win); } void butWin_destroy(ButWin *win) { if (but_inEvent) { butWin_dList(win); } else { while (butWin_delete(win) == BUTOUT_STILLBUTS); } } ButOut butWin_delete(ButWin *win) { ButEnv *env = win->env; ButOut result = 0; int i, j; ButSet bset; assert(MAGIC(win)); if (win->destroy != NULL) { /* * This must be done before killing the buttons in case the user wants * to read some buttons before they go away. */ result |= win->destroy(win); win->destroy = NULL; } butWin_findButSetInRegion(win, int_min/2,int_min/2, int_max,int_max, &bset); but_inEvent = TRUE; if ((bset.numButs != 0) || (win->butsNoDraw.numButs != 0)) { for (i = 0; i < bset.numButs; ++i) { but_destroy(bset.buts[i]); } for (i = 0; i < win->butsNoDraw.numButs; ++i) { but_destroy(win->butsNoDraw.buts[i]); } butSet_destroy(&bset); win->butsNoDraw.numButs = 0; return(BUTOUT_STILLBUTS); } if (win->parent) butCan_winDead(win); but_inEvent = FALSE; butSet_destroy(&bset); butSet_destroy(&win->butsNoDraw); /* Remove all timers from the timer list. */ /* Clear out the table. */ /* Since there can be no buttons left, you can easily wms_free the table. */ for (i = 0; i < win->numCols; ++i) { assert(MAGIC(&win->cols[i])); MAGIC_UNSET(&win->cols[i]); for (j = 0; j < win->cols[i].numRows; ++j) { assert(MAGIC(&win->cols[i].rows[j])); MAGIC_UNSET(&win->cols[i].rows[j]); if (win->cols[i].rows[j].buts != NULL) wms_free(win->cols[i].rows[j].buts); } wms_free(win->cols[i].rows); } wms_free(win->cols); if (env->curwin == win->win) env->curwin = None; if (win->parent) XFreePixmap(env->dpy, win->win); else XDestroyWindow(env->dpy, win->win); if (env->last_mwin == win) env->last_mwin = NULL; butWin_rmFromTable(win); MAGIC_UNSET(&win->butsNoDraw); MAGIC_UNSET(win); wms_free(win); return(result); } /* * Should only be called by a fixed size window. */ void butWin_resize(ButWin *win, int newW, int newH) { XSizeHints *sizeHints; win->minW = win->maxW = newW; win->minH = win->maxH = newH; sizeHints = XAllocSizeHints(); sizeHints->flags = PMaxSize | PMinSize | PSize; sizeHints->max_width = sizeHints->min_width = sizeHints->width = newW; sizeHints->max_height = sizeHints->min_height = sizeHints->height = newH; XSetWMNormalHints(win->env->dpy, win->win, sizeHints); XFree(sizeHints); XResizeWindow(win->env->dpy, win->win, newW, newH); } /* * Some window managers (like eXceed/NT) ignore the ratio parts of * a window. This could break some programs, so here we just ignore * parts of a window if that's the case. It's ugly, but hey, get * a real window manager. */ void butWin_checkDims(ButWin *win) { if (win->w > win->env->rootW) win->w = win->env->rootW; if (win->h > win->env->rootH) win->h = win->env->rootH; if (win->w < win->minW) win->w = win->minW; if (win->w > win->maxW) win->w = win->maxW; if (win->h < win->minH) win->h = win->minH; if (win->h > win->maxH) win->h = win->maxH; win->w -= ((win->w - win->minW) % win->wStep); win->h -= ((win->h - win->minH) % win->hStep); if (win->minWRatio) { if ((win->w + 1) * win->minHRatio - 1 < win->h * win->minWRatio) win->w = (win->h * win->minWRatio) / win->minHRatio; if ((win->h + 1) * win->maxWRatio - 1 < win->w * win->maxHRatio) win->h = (win->w * win->maxHRatio) / win->maxWRatio; } } ButColor butColor_create(int r, int g, int b, int grey) { ButColor result; result.red = (65535L * r + 127) / 255; result.green = (65535L * g + 127) / 255; result.blue = (65535L * b + 127) / 255; result.greyLevel = grey; return(result); } ButColor butColor_mix(ButColor c1, int r1, ButColor c2, int r2) { ButColor res; res.red = ((c1.red * r1) + (c2.red * r2) + (r1 + r2) / 2) / (r1 + r2); res.green = ((c1.green * r1) + (c2.green * r2) + (r1 + r2) / 2) / (r1 + r2); res.blue = ((c1.blue * r1) + (c2.blue * r2) + (r1 + r2) / 2) / (r1 + r2); res.greyLevel = c1.greyLevel; return(res); } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/list.c0000664000671000067100000002577707043224471012546 /* * wmslib/src/but/list.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #include #ifdef _BUT_LIST_H_ Levelization Error. #endif #include /********************************************************************** * Data types **********************************************************************/ typedef struct ListEl_struct { Str str; bool pressable; } ListEl; typedef struct List_struct { ButOut (*func)(But *but, int line); int numLines, maxLines, selectLine, pressLine; ListEl *lines; int numTabs, *tabs; ButTextAlign *aligns; MAGIC_STRUCT } List; /********************************************************************** * Forward declarations **********************************************************************/ static ButOut mmove(But *but, int x, int y); static ButOut mleave(But *but); static ButOut mpress(But *but, int butnum, int x, int y); static ButOut mrelease(But *but, int butnum, int x, int y); static void draw(But *but, int x, int y, int w, int h); static ButOut destroy(But *but); static void newFlags(But *but, uint flags); static void drawLine(But *but, int lineNum); /********************************************************************** * Functions **********************************************************************/ But *butList_create(ButOut (*func)(But *but, int line), void *packet, ButWin *win, int layer, int flags) { static const ButAction action = { mmove, mleave, mpress, mrelease, NULL, NULL, draw, destroy, newFlags, NULL, NULL}; List *l; But *but; int i; const int len = 1; l = wms_malloc(sizeof(List)); MAGIC_SET(l); but = but_create(win, l, &action); but->uPacket = packet; but->layer = layer; but->flags = flags; l->func = func; l->numLines = l->maxLines = len; l->selectLine = -1; l->pressLine = -1; l->lines = wms_malloc(len * sizeof(ListEl)); l->numTabs = 0; l->tabs = NULL; l->aligns = NULL; for (i = 0; i < len; ++i) { l->lines[i].pressable = FALSE; str_init(&l->lines[i].str); } but_init(but); return(but); } void butList_setTabs(But *but, const int *tabs, const ButTextAlign *tabAligns, int numTabs) { List *l = but->iPacket; int i; assert(MAGIC(l)); if (l->numTabs < numTabs) { if (l->tabs) { wms_free(l->tabs); wms_free(l->aligns); } l->tabs = wms_malloc(numTabs * sizeof(int)); l->aligns = wms_malloc(numTabs * sizeof(ButTextAlign)); l->numTabs = numTabs; } for (i = 0; i < numTabs; ++i) { l->tabs[i] = tabs[i]; if (tabAligns) l->aligns[i] = tabAligns[i]; else l->aligns[i] = butText_left; } } void butList_resize(But *but, int x, int y, int w) { List *list = but->iPacket; int listLen; assert(MAGIC(list)); listLen = list->numLines; if (listLen == 0) { listLen = 1; str_copyCharsLen(&list->lines[0].str, "", 0); } but_resize(but, x, y, w, listLen * butEnv_fontH(but->win->env, 0)); } void butList_changeLine(But *but, int line, const char *text) { List *l = but->iPacket; assert(MAGIC(l)); if (line >= l->numLines) { butList_setLen(but, line + 1); butList_resize(but, but->x, but->y, but->w); } str_copyChars(&l->lines[line].str, text); if (str_len(&l->lines[line].str) == 0) { l->lines[line].pressable = FALSE; if (l->selectLine == line) l->selectLine = -1; if (l->pressLine == line) l->pressLine = -1; } else { l->lines[line].pressable = TRUE; } drawLine(but, line); } void butList_setLen(But *but, int newLen) { List *list = but->iPacket; int i; ListEl *newLines; assert(MAGIC(list)); if (newLen > list->maxLines) { newLines = wms_malloc(newLen * sizeof(ListEl)); for (i = 0; i < list->maxLines; ++i) { newLines[i] = list->lines[i]; } for (; i < newLen; ++i) { newLines[i].pressable = FALSE; str_init(&newLines[i].str); } wms_free(list->lines); list->maxLines = newLen; list->lines = newLines; } if (newLen > list->numLines) { for (i = list->numLines; i < newLen; ++i) { str_copyCharsLen(&list->lines[i].str, "", 0); list->lines[i].pressable = FALSE; } } list->numLines = newLen; butList_resize(but, but->x, but->y, but->w); } static ButOut destroy(But *but) { List *l = but->iPacket; int i; for (i = 0; i < l->maxLines; ++i) { str_deinit(&l->lines[i].str); } wms_free(l->lines); if (l->tabs) { wms_free(l->tabs); wms_free(l->aligns); } MAGIC_UNSET(l); wms_free(l); return(0); } static void draw(But *but, int x, int y, int w, int h) { ButWin *win = but->win; ButEnv *env = win->env; List *l = but->iPacket; int i, fontH; int txtY; int startLine; butEnv_setXFg(env, BUT_FG); fontH = butEnv_fontH(env, 0); startLine = (y - but->y) / fontH; if (startLine < 0) startLine = 0; txtY = but->y + startLine * fontH; for (i = startLine; i < l->numLines; ++i) { if (i == l->selectLine) { if (i == l->pressLine) { butEnv_setXFg(env, BUT_FG); XFillRectangle(env->dpy, win->win, env->gc, but->x - win->xOff, txtY - win->yOff, but->w, fontH); butEnv_setXFg(env, BUT_BG); } else if (l->pressLine == -1) { if (env->colorp) butEnv_setXFg(env, BUT_HIBG); else butEnv_setXFg(env, BUT_PBG); XFillRectangle(env->dpy, win->win, env->gc, but->x - win->xOff, txtY - win->yOff, but->w, fontH); butEnv_setXFg(env, BUT_FG); } } butWin_writeTabs(win, but->x, txtY, str_chars(&l->lines[i].str), 0, l->tabs, l->aligns); if ((i == l->selectLine) && (i == l->pressLine)) butEnv_setXFg(env, BUT_FG); txtY += fontH; if (txtY >= y + h) break; } } static void newFlags(But *but, uint flags) { uint ofl = but->flags; but->flags = flags; if ((flags & BUT_NETPRESS) && !(ofl & BUT_NETPRESS)) { snd_play(&but_downSnd); } if (((flags & (BUT_PRESSABLE|BUT_DRAWABLE|BUT_PRESSED|BUT_NETPRESS)) != (ofl & (BUT_PRESSABLE|BUT_DRAWABLE|BUT_PRESSED|BUT_NETPRESS))) || (((flags & (BUT_TWITCHED|BUT_NETTWITCH)) != (ofl & (BUT_TWITCHED|BUT_NETTWITCH))) && (flags & (BUT_PRESSED|BUT_NETPRESS)))) but_draw(but); } static ButOut mmove(But *but, int x, int y) { ButOut retval = BUTOUT_CAUGHT; uint newflags = but->flags; bool overBut; List *list = but->iPacket; int oldSelect; overBut = ((x >= but->x) && (x < but->x + but->w) && (y >= but->y) && (y < but->y + list->numLines * butEnv_fontH(but->win->env, 0))); if (but->flags & BUT_PRESSABLE) { oldSelect = list->selectLine; list->selectLine = (y - but->y) / butEnv_fontH(but->win->env, 0); if ((list->selectLine < 0) || (list->selectLine >= list->numLines)) list->selectLine = -1; else if (!list->lines[list->selectLine].pressable) list->selectLine = -1; if (oldSelect != list->selectLine) { drawLine(but, oldSelect); drawLine(but, list->selectLine); } } if (overBut) { if (!(but->flags & BUT_PRESSABLE)) return(BUTOUT_CAUGHT); if (list->selectLine >= 0) newflags |= BUT_TWITCHED; else newflags &= ~BUT_TWITCHED; } else { if (!(but->flags & BUT_PRESSABLE)) return(0); newflags &= ~BUT_TWITCHED; if (!(newflags & BUT_LOCKED)) retval &= ~BUTOUT_CAUGHT; } if (!(but->flags & BUT_TWITCHED) && (newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_twitch); else if ((but->flags & BUT_TWITCHED) && !(newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) { but_newFlags(but, newflags); } return(retval); } static ButOut mleave(But *but) { List *list = but->iPacket; int newflags = but->flags; newflags &= ~BUT_TWITCHED; if (but->flags & BUT_TWITCHED) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) { but_newFlags(but, newflags); } if (list->selectLine != -1) { drawLine(but, list->selectLine); list->selectLine = -1; } return(BUTOUT_CAUGHT); } static ButOut mpress(But *but, int butnum, int x, int y) { ButOut retval = BUTOUT_CAUGHT; uint newflags = but->flags; List *list = but->iPacket; int oldPressLine; assert(MAGIC(list)); if (!(newflags & BUT_TWITCHED)) { retval = BUTOUT_ERR; } else { if (butnum == 1) { newflags |= BUT_PRESSED | BUT_LOCKED; oldPressLine = list->pressLine; list->pressLine = list->selectLine; if (oldPressLine != list->pressLine) { drawLine(but, oldPressLine); drawLine(but, list->pressLine); } if (list->pressLine < 0) { return(BUTOUT_CAUGHT | BUTOUT_ERR); } } else return(BUTOUT_CAUGHT | BUTOUT_ERR); } if (!(but->flags & BUT_PRESSED) && (newflags & BUT_PRESSED)) snd_play(&but_downSnd); if (newflags != but->flags) but_newFlags(but, newflags); return(retval); } static ButOut mrelease(But *but, int butnum, int x, int y) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; List *list = but->iPacket; int pressLine = -1; assert(MAGIC(list)); if (butnum != 1) { if (but->flags & BUT_TWITCHED) return(BUTOUT_CAUGHT); else return(0); } if (!(but->flags & BUT_PRESSED)) return(0); if (but->flags & BUT_TWITCHED) { pressLine = (y - but->y) / butEnv_fontH(but->win->env, 0); } else { retval |= BUTOUT_ERR; } newflags &= ~(BUT_PRESSED|BUT_LOCKED); if ((but->flags & BUT_PRESSED) && !(newflags & BUT_PRESSED) && !(retval & BUTOUT_ERR)) snd_play(&but_upSnd); if (newflags != but->flags) but_newFlags(but, newflags); if ((pressLine >= 0) && (pressLine == list->pressLine)) { list->pressLine = -1; retval |= list->func(but, pressLine); } else list->pressLine = -1; return(retval); } int butList_len(But *but) { List *list = but->iPacket; assert(MAGIC(list)); return(list->numLines); } static void drawLine(But *but, int lineNum) { if (lineNum >= 0) { butWin_redraw(but->win, but->x, but->y + lineNum * butEnv_fontH(but->win->env, 0), but->w, butEnv_fontH(but->win->env, 0)); } } void butList_setPress(But *but, int line, bool pressable) { List *list; assert(MAGIC(but)); list = but->iPacket; assert(MAGIC(list)); assert(line < list->numLines); list->lines[line].pressable = pressable; } const char *butList_get(But *but, int line) { List *list; assert(MAGIC(but)); list = but->iPacket; assert(MAGIC(list)); assert(line < list->numLines); return(str_chars(&list->lines[line].str)); } #endif cgoban-1.9.14/wmslib/src/but/menu.c0000664000671000067100000004612507043224471012525 /* * wmslib/src/but/menu.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. * * Known problems: * The first and last options MUST be text, not a divider. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #include #include #include #include /********************************************************************** * Data structures **********************************************************************/ typedef struct Ol_struct { /* Option List */ Str text; int x,y,w,h; uint flags; } Ol; typedef struct menu_struct { int fgpic, bgpic; int cval, nvals, nbreaks, tval, xoff; int last_w, llayer; bool active, up, skip_clicks; bool menu_was_twitched; bool clickOpen; /* TRUE if it's open because of a click. */ Time pressTime; const char *title; Ol *options; But *child, *parent; ButOut (*callback)(But *but, int value); } Menu; /********************************************************************** * Forward Declarations **********************************************************************/ static int menu_width(But *but); static ButOut smmove(But *but, int x, int y); static ButOut smleave(But *but); static ButOut smpress(But *but, int butnum, int x, int y); static void sdraw(But *but, int x,int y, int w,int h); static ButOut sdestroy(But *but); static void snewflags(But *but, uint flags); static But *lcreate(But *smenu, bool local); static ButOut lmmove(But *but, int x, int y); static ButOut lmleave(But *but); static ButOut lmpress(But *but, int butnum, int x, int y); static ButOut lmrelease(But *but, int butnum, int x, int y); static void ldraw(But *but, int x,int y, int w,int h); static ButOut ldestroy(But *but); static void lnewflags(But *but, uint flags); static ButOut netMsg(But *but, void *msg, int msgLen); static But *create(ButOut (*func)(But *but, int value), void *packet, ButWin *win, int layer, int toplayer, int flags, const char *title, const char *optlist[], int cur_opt, bool up); /********************************************************************** * Globals **********************************************************************/ static const ButAction saction = { smmove, smleave, smpress, NULL, NULL, NULL, sdraw, sdestroy, snewflags, netMsg}; static const ButAction laction = { lmmove, lmleave, lmpress, lmrelease, NULL, NULL, ldraw, ldestroy, lnewflags, NULL}; char butMenu_dummy = '\0'; /********************************************************************** * Functions **********************************************************************/ But *butMenu_upCreate(ButOut (*func)(But *but, int value), void *packet, ButWin *win, int layer, int toplayer, int flags, const char *title, const char *optlist[], int cur_opt) { return(create(func, packet, win, layer, toplayer, flags, title, optlist, cur_opt, TRUE)); } But *butMenu_downCreate(ButOut (*func)(But *but, int value), void *packet, ButWin *win, int layer, int toplayer, int flags, const char *title, const char *optlist[], int cur_opt) { return(create(func, packet, win, layer, toplayer, flags, title, optlist, cur_opt, FALSE)); } static But *create(ButOut (*callback)(But *but, int value), void *packet, ButWin *win, int layer, int toplayer, int flags, const char *title, const char *optlist[], int cur_opt, bool up) { Menu *m; But *but; int i; m = wms_malloc(sizeof(Menu)); but = but_create(win, m, &saction); but->uPacket = packet; but->layer = layer; but->flags = flags | BUT_OPAQUE; m->callback = callback; m->fgpic = BUT_FG; m->bgpic = BUT_BG; m->cval = cur_opt; m->nbreaks = 0; for (i = 0; optlist[i] != BUTMENU_OLEND; ++i) if (optlist[i] == BUTMENU_OLBREAK) ++m->nbreaks; m->nvals = i; m->options = wms_malloc((i+1) * sizeof(Ol)); i = 0; do { if (optlist[i] == BUTMENU_OLBREAK) { str_init(&m->options[i].text); m->options[i].flags = BUTMENU_BREAK; } else if (optlist[i] == BUTMENU_OLEND) { str_init(&m->options[i].text); m->options[i].flags = BUTMENU_END; } else { str_initChars(&m->options[i].text, optlist[i]); m->options[i].flags = 0; } } while (optlist[i++] != BUTMENU_OLEND); m->llayer = toplayer; m->tval = 0; m->active = FALSE; m->up = up; m->menu_was_twitched = FALSE; m->title = title; m->last_w = 0; m->child = NULL; m->parent = but; but_init(but); return(but); } void butMenu_setText(But *but, const char *title, const char *optlist[], int newopt) { Menu *m = but->iPacket; int i; if (title == NULL) title = m->title; m->title = title; m->nbreaks = 0; for (i = 0; optlist[i] != BUTMENU_OLEND; ++i) if (optlist[i] == BUTMENU_OLBREAK) ++m->nbreaks; m->nvals = i; wms_free(m->options); m->options = wms_malloc((i+1) * sizeof(Ol)); i = 0; do { if (optlist[i] == BUTMENU_OLBREAK) { str_init(&m->options[i].text); m->options[i].flags = BUTMENU_BREAK; } else if (optlist[i] == BUTMENU_OLEND) { str_init(&m->options[i].text); m->options[i].flags = BUTMENU_END; } else { str_copyChars(&m->options[i].text, optlist[i]); m->options[i].flags = 0; } } while (optlist[i++] != BUTMENU_OLEND); if (newopt != BUT_NOCHANGE) m->cval = newopt; but_draw(but); } void butMenu_setFlags(But *but, int optnum, uint flags) { Menu *m = but->iPacket; m->options[optnum].flags = flags; but_draw(but); } /* Cannot be called when the menu is open. */ void butMenu_set(But *but, int new_opt) { Menu *m = but->iPacket; assert(but->action == &saction); m->cval = new_opt; but_draw(but); } int butMenu_get(But *but) { Menu *m = but->iPacket; return(m->cval); } void butMenu_setColor(But *but, int fg, int bg) { Menu *m = but->iPacket; assert(but->action == &saction); m->fgpic = fg; m->bgpic = bg; but_draw(but); } static ButOut smmove(But *but, int x, int y) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; int butbw = but->win->env->stdButBw; if ((x >= but->x + butbw) && (x < but->x + but->w - butbw) && (y >= but->y + butbw) && (y < but->y + but->h - butbw)) { newflags |= BUT_TWITCHED; } else { newflags &= ~BUT_TWITCHED; if (!newflags & BUT_LOCKED) retval &= ~BUTOUT_CAUGHT; } if (!(but->flags & BUT_TWITCHED) && (newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_twitch); else if ((but->flags & BUT_TWITCHED) && !(newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) but_newFlags(but, newflags); return(retval); } static ButOut smleave(But *but) { int newflags = but->flags; newflags &= ~BUT_TWITCHED; if ((but->flags & BUT_TWITCHED) && !(newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) but_newFlags(but, newflags); return(BUTOUT_CAUGHT); } static ButOut smpress(But *but, int butnum, int x, int y) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; Menu *m = but->iPacket; if (!(newflags & BUT_TWITCHED)) retval &= ~BUTOUT_CAUGHT; else { if (butnum == 1) { newflags |= BUT_PRESSED; m->pressTime = but->win->env->eventTime; } else retval |= BUTOUT_ERR; } if (newflags != but->flags) but_newFlags(but, newflags); return(retval); } static void sdraw(But *but, int x,int y, int w,int h) { ButWin *win = but->win; Menu *m = but->iPacket; uint flags = but->flags; int bwdiff, sbw, bbw; if (m->child == NULL) { bbw = win->env->stdButBw; if (bbw == 0) bbw = 1; sbw = (bbw + 1) / 2; bwdiff = bbw - sbw; but_drawBox(win, but->x, but->y, but->w, but->h, 0, bwdiff, BUT_SLEFT|BUT_SRIGHT, BUT_LIT, BUT_SHAD, None, None); but_drawCt(win, flags, m->fgpic, m->bgpic, BUT_PBG, but->x+bwdiff, but->y+bwdiff, but->w-2*bwdiff, but->h/2 - bwdiff, sbw, m->title, BUT_SLEFT|BUT_SRIGHT, 0); but_drawCt(win, flags, BUT_FG,BUT_BG,BUT_PBG, but->x+bwdiff, but->y + but->h/2, but->w-2*bwdiff, but->h - but->h/2 - bwdiff, sbw, str_chars(&m->options[m->cval].text), BUT_SLEFT|BUT_SRIGHT, 0); } } static ButOut sdestroy(But *but) { Menu *m = but->iPacket; int i; if (m->child != NULL) but_destroy(m->child); for (i = 0; i <= m->nvals; ++i) { str_deinit(&m->options[i].text); } wms_free(m->options); wms_free(but->iPacket); return(0); } static void snewflags(But *but, uint flags) { Menu *m = but->iPacket; bool local; if (flags & (BUT_PRESSED|BUT_NETPRESS)) { if (m->child == NULL) { local = flags & BUT_PRESSED; but->flags = flags & ~(BUT_PRESSED|BUT_NETPRESS); m->child = lcreate(but, local); } } else { but->flags = flags; } } /* * If local is TRUE, then make the popup unpressable. */ static But *lcreate(But *smenu, bool local) { But *but; Menu *m = smenu->iPacket; int sh, i, x,y, w,h; ButWin *win = smenu->win; ButEnv *env = win->env; int butbw = env->stdButBw; h = (m->nvals - m->nbreaks) * (sh = (env->font0h + butbw * 2)) + butbw * 3 + smenu->h / 2 + m->nbreaks * ((butbw & ~1) + butbw); but = but_create(win, m, &laction); but->uPacket = smenu->uPacket; but->layer = m->llayer; but->x = smenu->x; but->y = smenu->y; if (m->up) but->y += smenu->h - h; but->w = smenu->w; but->h = h; but->flags = BUT_DRAWABLE | BUT_OPAQUE; if (local) but->flags |= BUT_PRESSABLE | BUT_PRESSED | BUT_LOCKED | BUT_TWITCHED; but->keys = NULL; x = but->x + env->stdButBw; y = but->y + m->parent->h/2 + 2*butbw; w = but->w - 2*env->stdButBw; h = env->font0h + env->stdButBw; for (i = 0; i < m->nvals; ++i) { if (m->options[i].flags & BUTMENU_BREAK) { y += (env->stdButBw & ~1) + env->stdButBw; } else { m->options[i].x = x; m->options[i].y = y; m->options[i].w = w; m->options[i].h = h; y += env->font0h + env->stdButBw * 2; } } m->tval = m->cval; m->last_w = 0; m->clickOpen = FALSE; if (local) { x = but->x + but->w/2; y = m->options[m->cval].y - butbw + sh/2; while (win->parent != NULL) { x += win->xOff; y += win->yOff; win = win->parent; } XWarpPointer(env->dpy, None, win->win, 0,0,0,0, x, y); } m->skip_clicks = TRUE; but_init(but); snd_play(&butMenu_openSnd); return(but); } static ButOut lmmove(But *but, int x, int y) { ButOut result = 0; int msel, m_y, newflags = but->flags, otval; Menu *m = but->iPacket; ButEnv *env = but->win->env; int butbw = env->stdButBw; bool click = TRUE; StdInt32 netNewVal; if (m->skip_clicks) { click = FALSE; } if (but->flags & BUT_PRESSED) result |= BUTOUT_CAUGHT; for (msel = 0; msel < m->nvals; ++msel) { if (!(m->options[msel].flags & BUTMENU_BREAK)) { m_y = m->options[msel].y - butbw; if ((y > m_y + butbw / 2) && (y <= m_y + butbw / 2 + 2*butbw + env->font0h)) break; } } if (msel < m->nvals) { if (msel == m->cval) m->skip_clicks = FALSE; if (m->options[msel].flags & BUTMENU_DISABLED) msel = m->nvals; } if (msel == m->nvals) newflags &= ~BUT_TWITCHED; else newflags |= BUT_TWITCHED; if (msel != m->tval) { if (m->parent->id >= 0) { netNewVal = int_stdInt32(msel); butRnet_butSpecSend(m->parent, &netNewVal, sizeof(netNewVal)); } otval = m->tval; m->tval = msel; if (((newflags ^ but->flags) & ~BUT_TWITCHED) == 0) { /* Otherwise, it will be drawn by the setflags call. */ if (otval != m->nvals) { butWin_redraw(but->win, m->options[otval].x,m->options[otval].y-butbw, m->options[otval].w,m->options[otval].h+butbw*2); } if (msel != m->nvals) { butWin_redraw(but->win, m->options[msel].x,m->options[msel].y-butbw, m->options[msel].w,m->options[msel].h+butbw*2); } } if (click) snd_play(&but_downSnd); } if (newflags != but->flags) but_newFlags(but, newflags); return(result); } static ButOut lmleave(But *but) { Menu *m = but->iPacket; StdInt32 msg; if (m->parent->id >= 0) { msg = int_stdInt32(-1); butRnet_butSpecSend(m->parent, &msg, sizeof(msg)); } but_destroy(but); snd_play(&butMenu_closeSnd); return(BUTOUT_CAUGHT); } static ButOut lmpress(But *but, int butnum, int x, int y) { Menu *m = but->iPacket; if (m->clickOpen) { m->clickOpen = FALSE; snd_play(&but_upSnd); return(BUTOUT_CAUGHT); } else return(BUTOUT_CAUGHT | BUTOUT_ERR); } static ButOut lmrelease(But *but, int butnum, int x, int y) { int result = BUTOUT_CAUGHT; Menu *m = but->iPacket; StdInt32 msg; if (but->flags & BUT_PRESSABLE) { if (m->pressTime + BUT_DCLICK > but->win->env->eventTime) { /* Open this with a click. */ m->clickOpen = TRUE; return(BUTOUT_CAUGHT); } if (m->parent->id >= 0) { msg = int_stdInt32(-1); butRnet_butSpecSend(m->parent, &msg, sizeof(msg)); } } but_destroy(but); if (m->tval == m->nvals) { result |= BUTOUT_ERR; } else { m->cval = m->tval; if (m->callback != NULL) result |= m->callback(m->parent, m->cval); } snd_play(&butMenu_closeSnd); return(result); } static void ldraw(But *but, int x,int y, int w,int h) { Menu *m = but->iPacket; ButWin *win = but->win; ButEnv *env = win->env; But *sbut = m->parent; int tx, ty, tw, th, i; uint butbw = env->stdButBw; int new_y, old_y; if (butbw == 0) butbw = 1; /* If it resizes, you must recalculate how far into the button you should * start drawing the options. Start with last_w set to 0 to force * this to happen on the first redraw. */ if (m->last_w != but->w) { m->last_w = but->w; m->xoff = (but->w - menu_width(but)) / 2; } /* Draw the title. */ tw = sbut->w; th = sbut->h / 2; /* Don't forget: sbut is two boxes high! */ if (y < m->options[0].y) { but_drawCt(but->win, BUT_PRESSABLE, m->fgpic, m->bgpic, 0, but->x, but->y, tw, th, butbw, m->title, BUT_SLEFT|BUT_SRIGHT, 0); } /* The box around the options. */ if ((y < m->options[0].y-butbw) || (y+h > m->options[m->nvals-1].y + m->options[m->nvals-1].h+butbw) || (x < m->options[0].x-butbw) || (x > m->options[0].x + m->options[0].w+butbw)) { but_drawBox(win, but->x, but->y + th, but->w, but->h - th, 0, (butbw+1)/2, BUT_SLEFT|BUT_SRIGHT, BUT_LIT, BUT_SHAD, None, None); } new_y = but->y + th + butbw; /* Top of the current selection. */ old_y = but->y + th + (butbw+1) / 2; /* Fill in the background for the options. */ butEnv_setXFg(env, BUT_BG); XFillRectangle(env->dpy, win->win, env->gc, but->x + butbw - win->xOff, new_y - win->yOff, but->w - butbw * 2, but->y + but->h - new_y - butbw); for (i = 0; i <= m->nvals; ++i) { if (m->options[i].flags & (BUTMENU_BREAK | BUTMENU_END)) { /* Draw the inner box around a group of options. */ tx = but->x + (butbw+1)/2; ty = old_y; tw = but->w - ((butbw+1) & ~1); th = new_y - old_y + butbw + (butbw / 2); if ((ty < y+h) && (ty+th >= y) && ((ty+butbw/2 > y) || (ty+th-butbw/2 < y+h) || (tx+butbw/2 > x) || (tx+tw-butbw/2 < x+w))) but_drawBox(win, tx,ty, tw,th, 0, butbw / 2, BUT_SLEFT|BUT_SRIGHT, BUT_LIT, BUT_SHAD, None, None); old_y = new_y + butbw + butbw/2; new_y += (butbw & ~1) + butbw; } else { /* Draw the text for this option. */ /* If it's selected, highlight behind it. */ if (i == m->tval) { if ((m->options[i].y-butbw <= y+h) && (m->options[i].y+m->options[i].h+butbw > y)) { but_drawBox(win, but->x + butbw, new_y, but->w - 2*butbw, env->font0h + 3*butbw, 0, butbw, BUT_SLEFT|BUT_SRIGHT, BUT_LIT, BUT_SHAD, None, None); butEnv_setXFg(env, BUT_HIBG); XFillRectangle(env->dpy, win->win, env->gc, but->x + 2*butbw - win->xOff, new_y + butbw - win->yOff, but->w - 4*butbw, env->font0h + butbw); } } if ((m->options[i].y <= y+h) && (m->options[i].y+m->options[i].h > y)) { if (m->options[i].flags & BUTMENU_DISABLED) { XSetFillStyle(env->dpy, env->gc, FillStippled); XSetForeground(env->dpy, env->gc, env->colors[BUT_FG]); } else butEnv_setXFg(env, BUT_FG); butWin_write(win, but->x + m->xoff, m->options[i].y + butbw/2, str_chars(&m->options[i].text), 0); if (m->options[i].flags & BUTMENU_DISABLED) { butEnv_stdFill(env); } } new_y += env->font0h + butbw*2; } } } static ButOut ldestroy(But *but) { ButWin *win = but->win; ButEnv *env = win->env; Menu *m = but->iPacket; But *sbut = m->parent; int x, y; int minX, minY; minX = but->x; minY = but->y; x = sbut->x + sbut->w/2; y = sbut->y + sbut->h/2; while (win->parent != NULL) { minX += win->xOff; x += win->xOff; minY += win->yOff; y += win->yOff; win = win->parent; } XWarpPointer(env->dpy, win->win, win->win, minX, minY, but->w, but->h, x, y); m->child = NULL; return(0); } static void lnewflags(But *but, uint flags) { uint ofl = but->flags; but->flags = flags; if (((flags ^ ofl) & ~BUT_TWITCHED) != 0) but_draw(but); } static int menu_width(But *but) { Menu *m = but->iPacket; ButEnv *env = but->win->env; int i, maxw, tw; maxw = butEnv_textWidth(env, m->title, 0); for (i = 0; !(m->options[i].flags & BUTMENU_END); ++i) { if (!(m->options[i].flags & BUTMENU_BREAK)) { tw = butEnv_textWidth(env, str_chars(&m->options[i].text), 0); if (tw > maxw) maxw = tw; } } return(maxw); } static ButOut netMsg(But *but, void *msg, int msgLen) { StdInt32 *i = msg; int msgVal = stdInt32_int(*i); int ctval, butbw = butEnv_stdBw(but->win->env); Menu *m = but->iPacket; ButOut result = 0; assert(msgLen == sizeof(StdInt32)); if (msgVal < 0) result |= lmrelease(m->child, 0,0,0); else { snd_play(&but_downSnd); ctval = m->tval; m->tval = msgVal; if (ctval != m->nvals) { butWin_redraw(but->win, m->options[ctval].x, m->options[ctval].y-butbw, m->options[ctval].w,m->options[ctval].h+butbw*2); } if (msgVal != m->nvals) { butWin_redraw(but->win, m->options[msgVal].x, m->options[msgVal].y-butbw, m->options[msgVal].w, m->options[msgVal].h+butbw*2); } } return(result); } void butMenu_setOptionName(But *but, const char *new, int entryNum) { Menu *m; assert(but->action == &saction); m = but->iPacket; assert(entryNum < m->nvals); str_copyChars(&m->options[entryNum].text, new); if (entryNum == m->cval) but_draw(but); } #endif cgoban-1.9.14/wmslib/src/but/menu_snd.c0000664000671000067100000002126107043224471013363 /* * wmslib/src/but/menu_snd.c, part of wmslib (Library functions) * Copyright (C) 1994 William Shubert. * See "configure.h.in" for more copyright information. */ #include #if X11_DISP #include #include #include static uchar openmenu[] = { /* * Actual noise: "Twanging" a rubber band stretched across my * hole puncher. */ 101,97,104,92,79,70,53,55,89,32,21,35,32,44,47,57,72,83,229,196, 146,136,150,140,139,145,150,158,164,175,190,235,74,59,51,47,45, 44,43,43,43,44,45,47,49,53,56,36,31,180,101,222,193,211,210,45, 29,14,19,12,22,31,35,109,191,200,220,175,176,169,169,167,166,166, 166,167,168,167,142,128,133,139,142,151,156,167,177,206,80,58,47, 43,40,31,12,3,5,6,10,14,21,25,30,41,50,73,238,195,185,178,174, 163,137,128,133,137,141,146,152,159,168,180,197,102,68,57,50,42, 34,47,46,43,47,44,48,48,52,55,59,47,24,16,18,15,14,17,25,32,44, 62,125,191,180,173,169,166,160,140,129,137,159,178,159,147,140, 142,151,161,34,21,44,168,162,184,185,223,95,70,60,56,52,51,49,50, 50,51,53,52,31,17,15,13,15,25,60,161,146,143,149,150,154,156,159, 163,167,171,174,179,184,189,195,201,207,214,221,227,233,235,235, 233,229,227,45,12,7,11,15,24,30,41,54,84,203,185,167,143,137,146, 175,67,225,207,166,144,141,139,139,142,158,43,17,13,17,20,32,169, 149,143,151,156,161,172,178,197,219,82,68,60,56,45,24,16,16,15, 21,29,58,176,158,154,158,159,163,167,170,174,184,202,223,79,81, 240,185,176,186,186,189,191,194,202,33,7,8,14,18,27,32,45,204, 149,141,142,167,36,59,64,79,220,213,193,175,156,157,165,176,88, 68,69,74,75,77,78,105,165,147,142,138,142,150,155,166,175,198,97, 57,24,10,10,10,13,22,39,174,157,159,165,169,173,178,185,190,198, 206,217,232,93,51,45,49,46,52,55,62,82,193,172,169,172,173,175, 194,21,6,13,17,24,31,40,56,231,155,143,149,172,53,222,215,203, 189,183,157,153,157,162,188,75,53,56,59,60,64,213,173,172,161, 154,151,148,147,150,158,167,179,202,91,53,26,14,12,11,15,20,28, 48,190,162,158,167,172,176,188,208,91,78,67,57,49,51,59,76,234, 204,194,187,175,168,163,161,166,179,73,27,10,12,17,22,29,36,47, 206,157,156,157,179,69,78,96,208,174,155,155,156,160,175,218,50, 43,45,49,86,172,166,159,156,157,158,165,168,170,170,171,175,187, 236,60,45,34,27,23,21,22,24,28,36,55,207,185,179,177,179,180,186, 196,205,218,237,110,107,222,196,186,185,179,174,173,173,174,179, 189,210,56,34,22,12,13,20,25,31,46,176,163,165,164,183,201,187, 179,174,170,167,166,168,173,185,209,89,76,77,110,200,182,175,172, 170,170,170,171,174,174,177,183,186,191,207,91,58,45,40,36,32,29, 29,33,41,47,55,66,95,208,201,204,206,207,205,202,200,196,194,191, 189,187,182,178,176,180,187,206,94,71,53,40,30,24,21,22,30,44,87, 184,173,170,171,172,175,181,181,180,183,181,178,179,184,191,208, 244,107,121,225,203,193,187,184,185,184,183,182,181,182,184,189, 196,205,231,77,56,45,41,38,37,38,41,47,58,69,78,90,239,216,211, 208,207,206,206,203,202,203,199,195,193,191,188,188,192,205,124, 78,67,53,39,33,30,30,34,41,56,101,189,177,173,173,174,176,179, 184,189,191,196,199,198,195,192,193,197,203,210,222,234,232,230, 220,214,211,203,196,191,188,187,188,191,199,214,106,73,58,49,45, 43,44,46,52,61,74,94,237,218,212,206,204,205,206,206,206,208,210, 209,206,204,201,196,192,191,191,198,218,88,61,50,39,30,30,32,40, 51,79,201,183,176,176,179,184,189,196,203,206,207,207,207,202, 194,191,190,193,198,201,203,206,208,212,214,218,221,221,218,208, 205,200,193,192,197,207,124,76,61,53,47,46,47,54,61,73,91,242, 218,209,206,206,205,205,208,211,214,214,215,218,217,219,216,212, 207,203,204,205,219,96,72,57,44,35,30,31,38,48,72,206,185,178, 176,178,184,189,197,205,208,211,207,205,199,192,191,191,193,196, 200,204,209,212,217,222,222,231,228,220,214,205,200,195,191,191, 198,213,99,72,60,55,53,53,57,64,75,83,90,97,102,109,254,254,249, 242,234,229,223,219,215,212,208,206,204,203,203,205,213,223,114, 79,65,56,45,37,34,38,45,59,101,197,184,179,179,182,186,191,199, 205,207,206,205,202,198,197,195,196,197,199,202,205,215,230,111, 93,86,85,90,105,235,211,199,191,186,186,190,203,250,76,62,57,56, 59,64,75,83,89,95,95,90,85,85,87,91,99,120,237,228,226,225,221, 215,209,208,206,205,209,220,110,78,65,58,49,42,40,42,46,59,79, 207,189,182,179,180,183,188,194,202,206,209,212,211,206,204,201, 199,198,198,200,203,210,224,254,97,91,87,83,83,87,101,236,213, 202,195,194,201,217,109,77,65,61,61,64,73,84,96,105,103,103,96, 95,97,105,120,244,231,223,222,220,219,216,213,212,208,211,220, 235,92,73,62,56,50,44,44,46,53,65,91,213,194,187,184,183,185,188, 191,199,204,207,213,215,215,214,211,207,206,207,210,216,223,236, 121,101,91,86,87,94,125,220,205,195,190,188,189,192,204,242,85, 72,64,62,63,67,72,78,88,95,104,117,109,106,114,123,117,123,255, 120,109,106,108,110,119,237,227,233,246,97,77,66,59,54,48,49,55, 62,78,245,206,194,187,185,186,188,191,195,200,204,206,215,231, 242,236,225,218,213,212,214,218,222,231,252,104,92,87,90,95,114, 225,206,198,191,190,190,195,206,247,84,72,66,66,69,74,79,89,95, 101,100,95,94,96,101,108,113,109,105,99,94,92,92,95,103,116,122, 116,101,86,75,67,61,58,56,58,63,75,95,223,207,199,193,190,189, 189,190,193,197,200,203,207,217,226,237,251,247,243,236,232,230, 227,230,245,110,95,92,94,109,234,214,204,200,198,197,201,210,235, 94,78,71,68,69,72,76,83,90,103,122,242,238,237,236,238,239,238, 238,237,247,115,104,96,94,99,103,104,100,90,82,75,69,63,61,62,66, 74,89,252,223,215,208,203,199,196,196,198,200,201,204,211,219, 224,229,234,235,231,233,234,231,227,223,224,229,245,102,94,94, 102,248}; static uchar closemenu[] = { /* * Actual sound: Me clicking my tongue. I don't really like this * noise but I can't find a better one within my wage slave * cubicle and if I leave to record a good noise my boss might * see me. */ 214,102,73,59,51,47,44,42,42,43,44,47,52,61,81,218,191,182,176, 175,174,175,177,181,187,194,202,215,224,231,223,209,200,193,190, 188,188,186,181,180,181,185,195,219,90,65,55,47,45,44,43,43,43, 46,52,68,243,192,177,172,170,169,172,182,205,77,52,41,34,30,29, 30,34,41,54,103,188,173,167,164,162,162,162,164,166,170,172,175, 175,179,189,217,76,59,52,49,49,47,44,38,32,30,30,32,40,49,67,110, 199,185,176,171,167,166,168,173,184,205,94,72,66,62,60,57,54,54, 58,70,117,201,188,186,188,192,195,193,189,185,184,184,185,187, 190,188,187,184,180,177,175,175,174,175,176,183,204,72,44,31,25, 21,18,18,19,21,25,29,36,47,76,197,178,172,169,167,168,168,168, 168,169,170,171,174,175,178,177,175,175,175,177,183,188,198,211, 225,122,99,87,73,63,60,58,60,62,62,61,60,57,55,55,57,61,68,78,79, 76,71,70,77,105,206,191,186,183,183,184,186,190,199,204,215,249, 94,90,120,212,199,190,189,191,196,203,208,208,206,207,218,118,86, 73,66,59,55,52,47,45,43,41,40,40,39,39,40,41,44,49,60,91,203,184, 174,167,160,157,156,159,168,179,192,197,189,177,174,179,221,56, 44,44,55,73,62,43,31,41,175,144,144,144,152,144,153,18,18,18,145, 144,144,151,31,18,18,18,72,153,193,32,144,144,174,18,18,39,151, 195,172,144,144,160,18,18,163,158,34,150,144,144,178,18,18,41,37, 18,36,144,144,144,18,18,18,18,21,235,144,144,144,18,18,22,18,22, 168,144,144,144,95,25,18,18,18,42,144,144,163,152,59,18,18,18,25, 147,153,144,144,167,18,18,19,23,29,148,144,144,186,27,26,18,18, 18,152,144,158,145,155,22,18,18,35,41,175,144,144,159,47,43,18, 18,25,158,151,153,144,148,42,20,29,34,45,157,144,146,163,195,26, 18,18,20,32,182,144,144,145,153,172,48,43,74,201,170,157,168,62, 29,18,18,18,18,26,126,167,172,164,189,62,76,237,166,150,144,144, 144,149,172,73,43,34,47,68,214,189,102,46,28,22,17,21,30,43,217, 188,192,220,49,41,38,43,79,181,162,158,160,170,189,84,60,78,194, 172,164,162,168,188,62,31,18,192,154,29,144,22,144,31,41,175,18, 156,18,144,29,145,197,177,174,41,162,31,151,52,147,194,157,206, 67,57,36,104,34,187,35,186,26,32,47,60,68,29,203,105,189,87,88, 78,38,47,43,97,73,169,171,161,173,171,193,239,103,80,195,203,177, 189,189,76,63,45,47,46,58,87,217,191,206,222,63,58,48,57,69,209, 187,178,180,189,216,77,66,59,68,86,210,196,186,185,185,188,189, 184,176,172,169,167,169,175,194,106,63,56,55,62,78,119,116,75,56, 44,36,31,30,31,36,42,51,60,79,107,223,200,187,176,172,166,162, 159,160,163,167,173,177,186,191,204,242,78,59,47,40,33,30,30,31, 35,41,47,57,69,90,221,202,191,184,178,175,174,175,178,183,191, 206,243,107,255,222,213,205,202,202,205,212,213,217,213,205,198, 194,192,193,198,207,220,232,225,211,203,198,200,209,121,78,63,57, 54,52,51,52,56,60,65,74,76,78,81,88,116,219,205,202,201,202,207, 219,239,105,87,78,78,82,84,88,88,80,77,76,76,79,93,234,209,201, 194,189,186,184,185,188,190,190,190,190,191,191,193,197,204,219, 229,241,123,95,79,72,68,64,60,56}; Snd butMenu_openSnd = snd_define(openmenu); Snd butMenu_closeSnd = snd_define(closemenu); #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/net.c0000664000671000067100000005206407043224471012346 /* * wmslib/src/but/net.c, part of wmslib (Library functions) * Copyright (C) 1995-1997 William Shubert. * See "configure.h.in" for more copyright information. */ #include #if X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #if HAVE_SOCKETS #include #if HAVE_NETINET_IN_H #include #endif #if HAVE_SYS_IN_H #include #endif #if HAVE_SYS_INET_H #include #endif #include #if HAVE_ARPA_NAMESER_H #include #endif #if HAVE_RESOLV_H #include #endif #if HAVE_SYS_UTSNAME_H #include #endif #include #endif /* HAVE_SOCKETS */ #include #include #include #include #if HAVE_SOCKETS /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut newConn(void *packet, int fd); static ButRnet *newRnet(ButEnv *env); static ButOut getNetData(void *packet, int fd); static ButOut finishWrite(void *packet, int fd); static void putProtoWho(ButRnet *net); static void butRnet_close(ButRnet *net, const char *reason, bool forced); static bool butRnet_write(ButRnet *net, ButNetMsg *msg); static void butRnet_sendMMove(ButRnet *net, int winId, int lx, int ly, int lw, int lh, ButCur type); static void newFlags(ButRnet *net, int id, uint newFlags); static ButOut butSpec(ButEnv *env, int butId, void *buf, int bufLen); /********************************************************************** * Functions **********************************************************************/ ButLnet *butLnet_create(ButEnv *env, int port, void *packet, ButOut ocallback(ButRnet *net), ButOut callback(ButRnet *net, void *cmd, int cmdLen), ButOut ccallback(ButRnet *net, const char *reason)) { ButLnet *net = wms_malloc(sizeof(ButLnet)); struct sockaddr_in sa; MAGIC_SET(net); net->env = env; net->packet = packet; net->valid = net->error = FALSE; net->fd = socket(AF_INET, SOCK_STREAM, 0); net->ocallback = ocallback; net->callback = callback; net->ccallback = ccallback; if (net->fd == -1) { net->error = TRUE; net->errNum = errno; return(net); } sa.sin_family = AF_INET; sa.sin_addr.s_addr = INADDR_ANY; sa.sin_port = htons(port); if (bind(net->fd, (struct sockaddr *)&sa, sizeof(sa)) != 0) { net->error = TRUE; net->errNum = errno; close(net->fd); return(net); } if (listen(net->fd, 2) != 0) { net->error = TRUE; net->errNum = errno; close(net->fd); return(net); } butEnv_addFile(env, BUT_READFILE, net->fd, net, newConn); net->valid = TRUE; return(net); } ButRnet *butRnet_create(ButEnv *env, const char *address, int port, void *packet, ButOut ocallback(ButRnet *net), ButOut callback(ButRnet *net, void *cmd, int cmdLen), ButOut ccallback(ButRnet *net, const char *reason)) { ButRnet *net; struct sockaddr_in sa; struct hostent *hp; net = newRnet(env); net->packet = packet; net->state = butRnetState_closed; net->error = net->lookupError = net->butNetError = FALSE; net->ocallback = ocallback; net->callback = callback; net->ccallback = ccallback; if ((net->fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { net->error = TRUE; net->errNum = errno; return(net); } sa.sin_family = AF_INET; if ((hp = gethostbyname(address)) == NULL) { net->lookupError = TRUE; #if HAVE_H_ERRNO net->errNum = h_errno; #else net->errNum = HOST_NOT_FOUND; #endif return(net); } memcpy(&sa.sin_addr, hp->h_addr, hp->h_length); sa.sin_port = htons(port); if (connect(net->fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) { net->error = TRUE; net->errNum = errno; return(net); } net->state = butRnetState_pwWait; fcntl(net->fd, F_SETFL, O_NONBLOCK); putProtoWho(net); butEnv_addFile(net->env, BUT_READFILE, net->fd, net, getNetData); return(net); } void butRnet_accept(ButRnet *net) { assert(net->state == butRnetState_accWait); net->state = butRnetState_open; net->lType = net->env->curlast; net->env->curlast = butCur_bogus; /* Force the cursor type to be sent. */ putProtoWho(net); } void butLnet_destroy(ButLnet *net) { assert(MAGIC(net)); if (net->valid) { close(net->fd); butEnv_rmFile(net->env, BUT_READFILE, net->fd); } MAGIC_UNSET(net); wms_free(net); } void butRnet_destroy(ButRnet *net, const char *reason) { ButNetMsg msgOut; assert(MAGIC(net)); if (net->state < butRnetState_closing) { msgOut.type = int_stdInt32(BUTNET_CLOSE); msgOut.length = int_stdInt32(2*4+strlen(reason)+1); strcpy(msgOut.perType.close, reason); butRnet_write(net, &msgOut); butRnet_close(net, NULL, FALSE); } } static ButOut newConn(void *packet, int fd) { ButLnet *lnet = packet; ButRnet *rnet; struct sockaddr_in addr; int addrlen = sizeof(addr); assert(MAGIC(lnet)); rnet = newRnet(lnet->env); rnet->fd = accept(lnet->fd, (struct sockaddr *)&addr, &addrlen); if (rnet->fd < 0) { rnet->env->partners[rnet->partner] = NULL; MAGIC_UNSET(rnet); wms_free(rnet); return(0); } rnet->packet = lnet->packet; rnet->ocallback = lnet->ocallback; rnet->callback = lnet->callback; rnet->ccallback = lnet->ccallback; fcntl(rnet->fd, F_SETFL, O_NONBLOCK); rnet->state = butRnetState_pwAccWait; butEnv_addFile(rnet->env, BUT_READFILE, rnet->fd, rnet, getNetData); return(0); } static ButRnet *newRnet(ButEnv *env) { ButRnet *net = wms_malloc(sizeof(ButRnet)); int newNumPartners, i, partner; ButRnet **newPartners; MAGIC_SET(net); for (partner = 0; partner < env->numPartners; ++partner) { if (!env->partners[partner]) break; } if (partner == env->numPartners) { newNumPartners = (env->numPartners + 1) * 2; newPartners = wms_malloc(newNumPartners * sizeof(ButRnet *)); for (i = 0; i < env->numPartners; ++i) { newPartners[i] = env->partners[i]; } for (; i < newNumPartners; ++i) newPartners[i] = NULL; if (env->partners) wms_free(env->partners); env->numPartners = newNumPartners; env->partners = newPartners; } env->partners[partner] = net; net->partner = partner; net->env = env; net->error = FALSE; net->wBufSize = net->wBufStart = net->wBufLen = 0; net->wBuffer = NULL; net->rBufAmt = 0; net->rBufLen = BUTNET_MAXCMD * 2 + 2; net->fd = -1; net->ackNeeded = net->mouseMove = FALSE; net->who = "Unknown"; net->protocol = "Unknown"; if ((env->last_mwin) && (env->last_mx >= 0)) { assert(MAGIC(env->last_mwin)); net->lWinId = env->last_mwin->id; net->lx = env->last_mx; net->ly = env->last_my; net->lw = env->last_mwin->w; net->lh = env->last_mwin->h; net->lType = env->curnum; } else net->lWinId = -2; net->lPress = net->lTwitch = -1; butRcur_create(&net->rc, net->env); return(net); } /* Returns TRUE if success. */ static bool butRnet_write(ButRnet *net, ButNetMsg *msg) { int len = stdInt32_int(msg->length) + 8; int amtWritten; char *remainder = (char *)msg; assert(MAGIC(net)); if (net->wBufLen == 0) { /* Nothing queued up. Try to write directly! */ amtWritten = write(net->fd, msg, len); if (amtWritten == len) return(TRUE); if (amtWritten < 0) { butRnet_close(net, strerror(errno), TRUE); return(FALSE); } remainder += amtWritten; len -= amtWritten; } /* Not all got written. Put some into the wBuffer. */ if (len + net->wBufStart + net->wBufLen > net->wBufSize) { char *newBuf; newBuf = wms_malloc(net->wBufSize = len + net->wBufStart + net->wBufLen); if (net->wBufLen) memcpy(newBuf, net->wBuffer+net->wBufStart, net->wBufLen); net->wBufStart = 0; if (net->wBuffer) wms_free(net->wBuffer); net->wBuffer = newBuf; } memcpy(remainder, net->wBuffer + net->wBufStart + net->wBufLen, len); net->wBufLen += len; butEnv_addFile(net->env, BUT_WRITEFILE, net->fd, net, finishWrite); return(TRUE); } static ButOut finishWrite(void *packet, int fd) { ButRnet *net = packet; int amtWritten; assert(MAGIC(net)); amtWritten = write(net->fd, net->wBuffer + net->wBufStart, net->wBufLen); if (amtWritten == net->wBufLen) { butEnv_rmFile(net->env, BUT_WRITEFILE, net->fd); net->wBufLen = 0; net->wBufStart = 0; if (net->state == butRnetState_closing) { close(net->fd); net->fd = -1; MAGIC_UNSET(net); wms_free(net); } } else if (amtWritten < 0) { butRnet_close(net, strerror(errno), TRUE); return(0); } else { net->wBufStart += amtWritten; net->wBufLen -= amtWritten; } return(0); } static ButOut getNetData(void *packet, int fd) { ButRnet *net = packet; int readLen, i, msgType; ButOut res = 0; char *temp; assert(MAGIC(net)); if (net->rBufAmt < 4) { /* Waiting for the length count. */ readLen = read(fd, (char *)&net->rBuffer + net->rBufAmt, 4 - net->rBufAmt); if (readLen <= 0) { if (readLen == 0) butRnet_close(net, "Connection closed", TRUE); else if ((readLen < 0) && (errno != EAGAIN)) butRnet_close(net, strerror(errno), TRUE); return(res); } if ((net->rBufAmt += readLen) < 4) return(0); net->rBufMsgLen = stdInt32_int(net->rBuffer.length); if (net->rBufMsgLen > BUTNET_MAXCMD) { fprintf(stderr, "Bogus command\n"); for (;;); } net->rBufMsgLen += 8; return(0); } if ((net->rBufMsgLen > BUTNET_MAXCMD+8) || (net->rBufMsgLen < 8)) { butRnet_close(net, "Invalid data on connection", TRUE); return(res); } readLen = read(fd, (char *)&net->rBuffer + net->rBufAmt, net->rBufMsgLen - net->rBufAmt); if (readLen <= 0) { if (readLen == 0) butRnet_close(net, "Connection closed", TRUE); else if ((readLen < 0) && (errno != EAGAIN)) butRnet_close(net, strerror(errno), TRUE); return(res); } net->rBufAmt += readLen; if (net->rBufAmt == net->rBufMsgLen) { msgType = stdInt32_int(net->rBuffer.type); net->rBufAmt = 0; switch(msgType) { case BUTNET_PROTOWHO: if (net->state == butRnetState_pwWait) { net->state = butRnetState_open; /* Force the cursor type to be sent. */ net->lType = net->env->curlast; net->env->curlast = butCur_bogus; } else if (net->state == butRnetState_pwAccWait) { net->state = butRnetState_accWait; } else { butRnet_close(net, "Invalid data on connection", TRUE); break; } if (net->rBufMsgLen != sizeof(net->rBuffer.perType.protoWho) + 8) { butRnet_close(net, "Invalid data on connection", TRUE); break; } net->rmtPartner = stdInt32_int(net->rBuffer.perType.protoWho.context); temp = wms_malloc(i = (strlen(net->rBuffer.perType.protoWho.proto) + 1)); strcpy(temp, net->rBuffer.perType.protoWho.proto); net->protocol = temp; temp = wms_malloc(strlen(net->rBuffer.perType.protoWho.who) + 1); strcpy(temp, net->rBuffer.perType.protoWho.who); net->who = temp; return(net->ocallback(net)); break; case BUTNET_CLOSE: butRnet_close(net, net->rBuffer.perType.close, FALSE); break; case BUTNET_USERDATA: if (net->callback) return(net->callback(net, net->rBuffer.perType.userData, stdInt32_int(net->rBuffer.length))); break; case BUTNET_MOUSE: if (net->rBufMsgLen != sizeof(net->rBuffer.perType.mouse) + 8) { butRnet_close(net, "Invalid data on connection", TRUE); break; } butRcur_move(&net->rc, stdInt32_int(net->rBuffer.perType.mouse.win), stdInt32_int(net->rBuffer.perType.mouse.x), stdInt32_int(net->rBuffer.perType.mouse.y), stdInt32_int(net->rBuffer.perType.mouse.w), stdInt32_int(net->rBuffer.perType.mouse.h), stdInt32_int(net->rBuffer.perType.mouse.type)); net->rBuffer.length = int_stdInt32(0); net->rBuffer.type = int_stdInt32(BUTNET_MOUSEACK); butRnet_write(net, &net->rBuffer); break; case BUTNET_MOUSEACK: if (net->rBufMsgLen != 8) { butRnet_close(net, "Invalid data on connection", TRUE); break; } net->ackNeeded = FALSE; if (net->mouseMove) { net->mouseMove = FALSE; butRnet_sendMMove(net, -1, -1,-1, -1,-1, -1); } break; case BUTNET_NEWFLAGS: if (net->rBufMsgLen != sizeof(net->rBuffer.perType.newFlags) + 8) { butRnet_close(net, "Invalid data on connection", TRUE); break; } newFlags(net, stdInt32_int(net->rBuffer.perType.newFlags.butId), stdInt32_int(net->rBuffer.perType.newFlags.newFlags)); break; case BUTNET_BUTSPEC: res |= butSpec(net->env, stdInt32_int(net->rBuffer.perType.butSpec.butId), net->rBuffer.perType.butSpec.butData, stdInt32_int(net->rBuffer.length) - sizeof(StdInt32)); break; default: butRnet_close(net, "Invalid data on connection", TRUE); break; } } return(res); } static void newFlags(ButRnet *net, int id, uint newFlags) { ButEnv *env = net->env; But *but; if (id < env->maxButIds) { but = env->id2But[id]; if (but) { if (newFlags & BUT_PRESSED) net->lPress = id; else if (net->lPress == id) net->lPress = -1; if (newFlags & BUT_TWITCHED) net->lTwitch = id; else if (net->lTwitch == id) net->lTwitch = -1; but_newFlags(but, (newFlags & (BUT_NETMASK<flags & ~(BUT_NETMASK<env; ButNetMsg protoOut; assert(MAGIC(net)); protoOut.length = int_stdInt32(sizeof(protoOut.perType.protoWho)); protoOut.type = int_stdInt32(BUTNET_PROTOWHO); #if HAVE_SYS_UTSNAME_H uname(&unameOut); #endif if ((loginName = getlogin()) == NULL) { pw = getpwuid(getuid()); loginName = pw->pw_name; } strcpy(protoOut.perType.protoWho.proto, env->protocol); protoOut.perType.protoWho.proto[sizeof(protoOut.perType.protoWho.proto) - 1] = '\0'; sprintf(protoOut.perType.protoWho.who, "%s@%s", loginName, #if HAVE_SYS_UTSNAME_H unameOut.nodename #else "unknown" #endif ); butRnet_write(net, &protoOut); } static void butRnet_close(ButRnet *net, const char *reason, bool force) { ButEnv *env = net->env; assert(MAGIC(net)); if (net->lPress != -1) { if (env->id2But[net->lPress]) { but_newFlags(env->id2But[net->lPress], env->id2But[net->lPress]->flags & ~BUT_NETPRESS); } } if (net->lTwitch != -1) { if (env->id2But[net->lTwitch]) { but_newFlags(env->id2But[net->lTwitch], env->id2But[net->lTwitch]->flags & ~BUT_NETTWITCH); } } if (net->state < butRnetState_closing) { if (reason && net->ccallback) net->ccallback(net, reason); net->state = butRnetState_closing; butEnv_rmFile(net->env, BUT_READFILE, net->fd); if (force || (net->wBufLen == 0)) { close(net->fd); net->fd = -1; if (net->wBufLen != 0) butEnv_rmFile(net->env, BUT_WRITEFILE, net->fd); } } net->env->partners[net->partner] = NULL; MAGIC_UNSET(net); wms_free(net); } void butRnet_send(ButRnet *net, void *buffer, int len) { ButNetMsg msg; assert(len <= BUTNET_MAXCMD); msg.length = int_stdInt32(len); msg.type = int_stdInt32(BUTNET_USERDATA); memcpy(msg.perType.userData, buffer, len); butRnet_write(net, &msg); } void butRnet_mMove(ButEnv *env, int winId, int lx,int ly, int lw,int lh, ButCur curnum) { int i; for (i = 0; i < env->numPartners; ++i) { if (env->partners[i]) { if (butRnet_valid(env->partners[i]) && ((winId != -2) || (env->partners[i]->lWinId != -2))) butRnet_sendMMove(env->partners[i], winId, lx,ly, lw,lh, curnum); } } } static void butRnet_sendMMove(ButRnet *net, int winId, int lx, int ly, int lw, int lh, ButCur curnum) { ButNetMsg msg; if (winId == -1) winId = net->lWinId; if (lx == -1) lx = net->lx; if (ly == -1) ly = net->ly; if (lw == -1) lw = net->lw; if (lh == -1) lh = net->lh; if (curnum == -1) curnum = net->lType; net->lWinId = winId; net->lx = lx; net->ly = ly; net->lw = lw; net->lh = lh; net->lType = curnum; if (net->ackNeeded) net->mouseMove = TRUE; else { msg.length = int_stdInt32(sizeof(msg.perType.mouse)); msg.type = int_stdInt32(BUTNET_MOUSE); msg.perType.mouse.context = int_stdInt32(0); msg.perType.mouse.win = int_stdInt32(winId); msg.perType.mouse.x = int_stdInt32(lx); msg.perType.mouse.y = int_stdInt32(ly); msg.perType.mouse.w = int_stdInt32(lw); msg.perType.mouse.h = int_stdInt32(lh); msg.perType.mouse.type = int_stdInt32(curnum); assert((curnum == -1) || (curnum < butCur_bogus)); butRnet_write(net, &msg); } } void butRnet_newFlags(ButEnv *env, int butId, uint newFlags) { int i; ButNetMsg msg; if ((butId != -2) && (env->numPartners > 0)) { assert(butId >= 0); assert(butId < env->maxButIds); newFlags = (newFlags & ~(BUT_NETTWITCH|BUT_NETPRESS|BUT_NETKEY)) | ((newFlags & BUT_NETMASK) << BUT_NETSHIFT); msg.length = int_stdInt32(sizeof(msg.perType.newFlags)); msg.type = int_stdInt32(BUTNET_NEWFLAGS); msg.perType.newFlags.butId = int_stdInt32(butId); msg.perType.newFlags.newFlags = int_stdInt32(newFlags); for (i = 0; i < env->numPartners; ++i) { if (env->partners[i]) if (butRnet_valid(env->partners[i])) butRnet_write(env->partners[i], &msg); } } } static ButOut butSpec(ButEnv *env, int butId, void *buf, int bufLen) { But *but; but = env->id2But[butId]; assert(but->action->netMessage); return(but->action->netMessage(but, buf, bufLen)); } #else /* !HAVE_SOCKETS */ ButLnet *butLnet_create(ButEnv *env, int port, void *packet, ButOut ocallback(ButRnet *net), ButOut callback(ButRnet *net, void *cmd, int cmdLen), ButOut ccallback(ButRnet *net, const char *reason)) { ButLnet *net = wms_malloc(sizeof(ButLnet)); net->error = TRUE; net->valid = FALSE; net->errNum = EPERM; return(net); } ButRnet *butRnet_create(ButEnv *env, char *address, int port, void *packet, ButOut ocallback(ButRnet *net), ButOut callback(ButRnet *net, void *cmd, int cmdLen), ButOut ccallback(ButRnet *net, const char *reason)) { ButRnet *net = wms_malloc(sizeof(ButRnet)); net->error = TRUE; net->errNum = EPERM; net->state = butRnetState_closed; return(net); } void butLnet_destroy(ButLnet *net) { wms_free(net); } void butRnet_destroy(ButRnet *net, char *reason) { wms_free(net); } bool butRnet_write(ButRnet *net, ButNetMsg *msg) { return(FALSE); } void butRnet_send(ButRnet *net, void *buffer, int len) {} void butRnet_mMove(ButEnv *env, int winId, int lx,int ly, int lw,int lh, ButCur curnum) {} void butRnet_newFlags(ButEnv *env, int butId, uint newFlags) {} void butRnet_accept(ButRnet *net) {} #endif /* HAVE_SOCKETS */ void but_setId(But *but, int id) { ButEnv *env = but->win->env; int i; assert(MAGIC(but)); if (id >= env->maxButIds) { But **newId2But; int newMaxButIds = (id + 1)*2; newId2But = wms_malloc(newMaxButIds * sizeof(But *)); for (i = 0; i < env->maxButIds; ++i) newId2But[i] = env->id2But[i]; for (; i < newMaxButIds; ++i) newId2But[i] = NULL; env->maxButIds = newMaxButIds; if (env->id2But) wms_free(env->id2But); env->id2But = newId2But; } if (but->id != -1) { assert(but->id < env->maxButIds); env->id2But[id] = NULL; } env->id2But[id] = but; but->id = id; } void butWin_setId(ButWin *win, int id) { ButEnv *env = win->env; int i; assert(MAGIC(win)); if (id >= env->maxWinIds) { ButWin **newId2Win; int newMaxWinIds = (id + 1)*2; newId2Win = wms_malloc(newMaxWinIds * sizeof(ButWin *)); for (i = 0; i < env->maxWinIds; ++i) newId2Win[i] = env->id2Win[i]; for (; i < newMaxWinIds; ++i) newId2Win[i] = NULL; env->maxWinIds = newMaxWinIds; if (env->id2Win) wms_free(env->id2Win); env->id2Win = newId2Win; } if (win->id != -1) { assert(win->id < env->maxWinIds); env->id2Win[id] = NULL; } env->id2Win[id] = win; win->id = id; } void butRnet_butSpecSend(But *but, void *buffer, int len) { ButEnv *env; ButNetMsg msg; int i; assert(len < BUTNET_MAXCMD - sizeof(StdInt32)); if (but->id >= 0) { env = but->win->env; if (env->numPartners > 0) { msg.length = int_stdInt32(len + 4); msg.type = int_stdInt32(BUTNET_BUTSPEC); msg.perType.butSpec.butId = int_stdInt32(but->id); if (len > 0) memcpy(msg.perType.butSpec.butData, buffer, len); for (i = 0; i < env->numPartners; ++i) { if (env->partners[i]) { if (butRnet_valid(env->partners[i])) butRnet_write(env->partners[i], &msg); } } } } } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/plain.c0000664000671000067100000001472307043224471012663 /* * wmslib/src/but/plain.c, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. * * File for "plain" buttons...pixmaps, solid colors, etc. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include static void pix_draw(But *but, int x, int y, int w, int h); static void plain_draw(But *but, int x, int y, int w, int h); static void dummy_draw(But *but, int x, int y, int w, int h); static void keytrap_draw(But *but, int x, int y, int w, int h); static ButOut pixmap_destroy(But *but); static ButOut plain_destroy(But *but); static ButOut dummy_destroy(But *but); static ButOut keytrap_destroy(But *but); static ButOut plain_mmove(But *but, int x, int y); static ButOut keytrap_kpress(But *but, const char *keystr, KeySym sym); static ButOut keytrap_krelease(But *but, const char *keystr, KeySym sym); static ButAction pix_action = { NULL, NULL, NULL, NULL, NULL, NULL, pix_draw, pixmap_destroy, but_flags, NULL}; static ButAction plain_action = { plain_mmove, NULL, NULL, NULL, NULL, NULL, plain_draw, plain_destroy, but_flags, NULL}; static ButAction dummy_action = { NULL, NULL, NULL, NULL, NULL, NULL, dummy_draw, dummy_destroy, but_flags, NULL}; static ButAction keytrap_action = { NULL, NULL, NULL, NULL, keytrap_kpress, keytrap_krelease, keytrap_draw, keytrap_destroy, but_flags, NULL}; typedef struct Pix_struct { Pixmap pic; int x,y; } Pix; typedef struct Plain_struct { int color; } Plain; typedef struct Keytrap_struct { ButOut (*callback)(But *but, int press); bool holdKey; } Keytrap; But *butPixmap_create(ButWin *win, int layer, int flags, Pixmap pic) { Pix *pix; But *but; pix = wms_malloc(sizeof(Pix)); but = but_create(win, pix, &pix_action); but->win = win; but->layer = layer; but->flags = flags | BUT_OPAQUE; pix->pic = pic; pix->x = 0; pix->y = 0; but_init(but); return(but); } void butPixmap_setPic(But *but, Pixmap pic, int x,int y) { Pix *pix = but->iPacket; assert(but->action == &pix_action); pix->pic = pic; pix->x = x; pix->y = y; but_draw(but); } static ButOut pixmap_destroy(But *but) { wms_free(but->iPacket); return(0); } static void pix_draw(But *but, int x, int y, int w, int h) { ButWin *win = but->win; ButEnv *env = win->env; Pix *pix = but->iPacket; if (pix->pic == None) { return; } XSetFillStyle(env->dpy, env->gc, FillTiled); XSetTile(env->dpy, env->gc, pix->pic); if ((but->x != pix->x + win->xOff) || (but->y != pix->y + win->yOff)) XSetTSOrigin(env->dpy, env->gc, but->x - pix->x - win->xOff, but->y - pix->y - win->yOff); if (but->x > x) { w -= but->x - x; x = but->x; } if (but->y > y) { h -= but->y - y; y = but->y; } if (but->x + but->w < x + w) w = but->x + but->w - x; if (but->y + but->h < y + h) h = but->y + but->h - y; XFillRectangle(env->dpy, win->win, env->gc, x - win->xOff, y - win->yOff, w, h); butEnv_stdFill(env); if ((but->x != pix->x) || (but->y != pix->y)) XSetTSOrigin(env->dpy, env->gc, 0,0); } But *butPlain_create(ButWin *win, int layer, int flags, int cnum) { Plain *plain; But *but; plain = wms_malloc(sizeof(Plain)); but = but_create(win, plain, &plain_action); but->layer = layer; but->flags = flags | BUT_OPAQUE; plain->color = cnum; but_init(but); return(but); } void butPlain_setColor(But *but, int cnum) { Plain *plain = but->iPacket; plain->color = cnum; but_draw(but); } static ButOut plain_destroy(But *but) { wms_free(but->iPacket); return(0); } static void plain_draw(But *but, int x, int y, int w, int h) { ButWin *win = but->win; ButEnv *env = win->env; Plain *color = but->iPacket; if (but->x > x) { w -= (but->x - x); x = but->x; } if (but->y > y) { h -= (but->y - y); y = but->y; } if (but->x+but->w < x+w) w = but->x+but->w - x; if (but->y+but->h < y+h) h = but->y+but->h - y; butEnv_setXFg(env, color->color); XFillRectangle(env->dpy, win->win, env->gc, x-win->xOff, y-win->yOff, w,h); } static ButOut plain_mmove(But *but, int x, int y) { return(BUTOUT_CAUGHT); } But *butDummy_create(ButWin *win, int layer, int flags) { But *but; but = but_create(win, NULL, &dummy_action); but->layer = layer; but->flags = flags | BUT_OPAQUE; but_init(but); return(but); } static ButOut dummy_destroy(But *but) { return(0); } static void dummy_draw(But *but, int x, int y, int w, int h) { } But *butKeytrap_create(ButOut (*func)(But *but, int press), void *uPacket, ButWin *win, int flags) { Keytrap *ktrap; But *but; but = but_create(win, NULL, &keytrap_action); ktrap = wms_malloc(sizeof(Keytrap)); but->uPacket = uPacket; but->iPacket = ktrap; ktrap->callback = func; ktrap->holdKey = TRUE; but->flags = flags; but->w = 1; but->h = 1; but_init(but); return(but); } static ButOut keytrap_destroy(But *but) { return(0); } void butKeytrap_setHold(But *but, bool hold) { Keytrap *k; assert(but->action == &keytrap_action); k = but->iPacket; k->holdKey = hold; } static ButOut keytrap_kpress(But *but, const char *keystr, KeySym sym) { ButOut retval = BUTOUT_CAUGHT; Keytrap *k = but->iPacket; if (!(but->flags & BUT_KEYPRESSED)) { snd_play(&but_downSnd); if (k->holdKey) but_newFlags(but, but->flags | BUT_KEYPRESSED|BUT_PRESSED|BUT_LOCKED); retval |= k->callback(but, TRUE); } return(retval); } static ButOut keytrap_krelease(But *but, const char *keystr, KeySym sym) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; Keytrap *k = but->iPacket; if (!(newflags & BUT_KEYPRESSED) && k->holdKey) return(0); if (k->holdKey) { newflags &= ~(BUT_KEYPRESSED|BUT_PRESSED|BUT_LOCKED); if (newflags != but->flags) but_newFlags(but, newflags); } snd_play(&but_upSnd); if (keystr != NULL) { /* If keystr is NULL, the key wasn't released - we lost focus instead. */ retval |= k->callback(but, FALSE); } return(retval); } static void keytrap_draw(But *but, int x, int y, int w, int h) { } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/radio.c0000664000671000067100000001552007043224471012652 /* * wmslib/src/but/checkbox.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #ifdef _BUT_RADIO_H_ LEVELIZATION ERROR #endif #include typedef struct Radio_struct { int val, maxVal; int pVal; /* The pressed down value. */ ButOut (*press)(But *but, int value); } Radio; static ButOut mmove(But *but, int x, int y); static ButOut mleave(But *but); static ButOut mpress(But *but, int butnum, int x, int y); static ButOut mrelease(But *but, int butnum, int x, int y); static void draw(But *but, int x, int y, int w, int h); static ButOut destroy(But *but); static void flags(But *but, uint flags); static void redrawOpt(But *but, Radio *radio, int opt); static ButAction action = { mmove, mleave, mpress, mrelease, NULL, NULL, draw, destroy, flags, NULL}; But *butRadio_create(ButOut (*func)(But *but, bool value), void *packet, ButWin *win, int layer, int flags, int val, int maxVal) { But *but; Radio *radio; radio = wms_malloc(sizeof(Radio)); but = but_create(win, radio, &action); MAGIC_SET(but); but->uPacket = packet; but->layer = layer; but->flags = flags | BUT_OPAQUE; radio->val = val; radio->maxVal = maxVal; radio->pVal = -1; radio->press = func; but_init(but); return(but); } int butRadio_get(But *but) { Radio *radio = but->iPacket; assert(but->action == &action); assert(MAGIC(but)); return(radio->val); } void butRadio_set(But *but, int val, bool propagate) { Radio *radio = but->iPacket; assert(but->action == &action); assert(MAGIC(but)); if (radio->val != val) { redrawOpt(but, radio, val); redrawOpt(but, radio, radio->val); radio->val = val; but_draw(but); if (propagate && (radio->press != NULL)) radio->press(but, val); } } static ButOut destroy(But *but) { Radio *radio = but->iPacket; assert(but->action == &action); assert(MAGIC(but)); wms_free(radio); return(0); } static void draw(But *but, int x, int y, int w, int h) { ButWin *win = but->win; Radio *radio = but->iPacket; uint flags = but->flags; ButEnv *env = win->env; int i, ix, ix2, iy, iw, ih; assert(but->action == &action); assert(MAGIC(but)); ix2 = but->x; for (i = 0; i < radio->maxVal; ++i) { ix = ix2; ix2 = but->x + ((i + 1) * but->w + (radio->maxVal>>1)) / radio->maxVal; iy = but->y; iw = ix2 - ix; ih = but->h; but_drawBox(win, ix,iy, iw,ih, (flags & BUT_PRESSED) && (i == radio->pVal), env->stdButBw, BUT_SLEFT|BUT_SRIGHT, BUT_LIT, BUT_SHAD, None, None); if (i == radio->pVal) butEnv_setXFg(env, BUT_PBG); else if (i == radio->val) butEnv_setXFg(env, BUT_CHOICE); else butEnv_setXFg(env, BUT_BG); XFillRectangle(env->dpy, win->win, env->gc, ix + env->stdButBw - win->xOff, iy + env->stdButBw - win->yOff, iw - env->stdButBw * 2, ih - env->stdButBw * 2); } } static void flags(But *but, uint flags) { uint ofl = but->flags; Radio *radio; but->flags = flags; if ((flags & (BUT_PRESSABLE|BUT_DRAWABLE|BUT_PRESSED)) != (ofl & (BUT_PRESSABLE|BUT_DRAWABLE|BUT_PRESSED))) { radio = but->iPacket; if (radio->pVal >= 0) redrawOpt(but, radio, radio->pVal); } } static ButOut mmove(But *but, int x, int y) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; ButEnv *env = but->win->env; if (!(but->flags & BUT_PRESSABLE)) return(BUTOUT_CAUGHT); if ((x >= but->x + env->stdButBw) && (y >= but->y + env->stdButBw) && (x < but->x + but->w - env->stdButBw) && (y < but->y + but->h - env->stdButBw)) newflags |= BUT_TWITCHED; else { newflags &= ~BUT_TWITCHED; if (!(newflags & BUT_LOCKED)) retval &= ~BUTOUT_CAUGHT; } if (!(but->flags & BUT_TWITCHED) && (newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_twitch); else if ((but->flags & BUT_TWITCHED) && !(newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) { but_newFlags(but, newflags); } return(retval); } static ButOut mleave(But *but) { int newflags = but->flags; newflags &= ~BUT_TWITCHED; if ((but->flags & BUT_TWITCHED) && !(newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) { but_newFlags(but, newflags); } return(BUTOUT_CAUGHT); } static ButOut mpress(But *but, int butnum, int x, int y) { Radio *radio = but->iPacket; ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; if (!newflags & BUT_TWITCHED) retval &= ~BUTOUT_CAUGHT; else { if (butnum == 1) { newflags |= BUT_PRESSED | BUT_LOCKED; radio->pVal = ((x - but->x) * radio->maxVal) / but->w; } else return(BUTOUT_CAUGHT | BUTOUT_ERR); } if (!(but->flags & BUT_PRESSED) && (newflags & BUT_PRESSED)) snd_play(&but_downSnd); if (newflags != but->flags) but_newFlags(but, newflags); return(retval); } static ButOut mrelease(But *but, int butnum, int x, int y) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; Radio *radio = but->iPacket; int oldPVal, newPVal; oldPVal = radio->pVal; if (oldPVal >= 0) redrawOpt(but, radio, oldPVal); radio->pVal = -1; if (butnum != 1) { if (but->flags & BUT_TWITCHED) return(BUTOUT_CAUGHT); else return(0); } if (!(but->flags & BUT_PRESSED)) return(0); if (but->flags & BUT_TWITCHED) { newPVal = ((x - but->x) * radio->maxVal) / but->w; if (newPVal != oldPVal) oldPVal = -1; } else { oldPVal = -1; retval |= BUTOUT_ERR; } newflags &= ~(BUT_PRESSED|BUT_LOCKED); if ((but->flags & BUT_PRESSED) && !(newflags & BUT_PRESSED) && !(retval & BUTOUT_ERR)) snd_play(&but_upSnd); if (newflags != but->flags) but_newFlags(but, newflags); if (oldPVal != -1) { redrawOpt(but, radio, oldPVal); redrawOpt(but, radio, radio->val); radio->val = oldPVal; if (radio->press) radio->press(but, oldPVal); } else retval |= BUTOUT_ERR; return(retval); } static void redrawOpt(But *but, Radio *radio, int opt) { int x1, x2; if ((opt >= 0) && (opt < radio->maxVal)) { x1 = (but->w * opt + (radio->maxVal >> 1)) / radio->maxVal; x2 = (but->w * (opt + 1) + (radio->maxVal >> 1)) / radio->maxVal; butWin_redraw(but->win, but->x + x1, but->y, x2 - x1, but->h); } } #endif cgoban-1.9.14/wmslib/src/but/rcur.c0000664000671000067100000002427207043224472012534 /* * wmslib/src/but/rcur.c, part of wmslib (Library functions) * Copyright (C) 1994 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #include typedef struct Curs_struct { int fontcurnum; int hotX, hotY, w, h; char *pic, *mask; } Curs; #define ntm_width 16 #define ntm_height 16 #define ntm_bits ((char *)ntm_ubits) static uchar ntm_ubits[] = { 0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, 0x3f, 0x00, 0x7f, 0x00, 0xff, 0x00, 0xff, 0x01, 0xff, 0x03, 0xff, 0x03, 0x7f, 0x00, 0xf7, 0x00, 0xf3, 0x00, 0xe0, 0x01, 0xe0, 0x01, 0xc0, 0x01}; #define ntp_width 16 #define ntp_height 16 #define ntp_bits ((char *)ntp_ubits) static uchar ntp_ubits[] = { 0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x1e, 0x00, 0x3e, 0x00, 0x7e, 0x00, 0xfe, 0x00, 0xfe, 0x01, 0x3e, 0x00, 0x36, 0x00, 0x62, 0x00, 0x60, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0x00, 0x00}; #define tm_width 16 #define tm_height 16 #define tm_bits ((char *)tm_ubits) static uchar tm_ubits[] = { 0x00, 0xe0, 0x00, 0xf8, 0x00, 0xfe, 0x80, 0x7f, 0xe0, 0x7f, 0xf8, 0x3f, 0xfc, 0x3f, 0xf8, 0x1f, 0xe0, 0x1f, 0xf0, 0x0f, 0xf8, 0x0f, 0x7c, 0x07, 0x3e, 0x07, 0x1f, 0x02, 0x0e, 0x00, 0x04, 0x00}; #define tp_width 16 #define tp_height 16 #define tp_bits ((char *)tp_ubits) static uchar tp_ubits[] = { 0x00, 0x00, 0x00, 0x60, 0x00, 0x78, 0x00, 0x3e, 0x80, 0x3f, 0xe0, 0x1f, 0xf8, 0x1f, 0x80, 0x0f, 0xc0, 0x0f, 0xe0, 0x06, 0x70, 0x06, 0x38, 0x02, 0x1c, 0x02, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00}; #define txtp_width 16 #define txtp_height 16 #define txtp_bits ((char *)txtp_ubits) static uchar txtp_ubits[] = { 0x00, 0x00, 0xee, 0x00, 0x38, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x38, 0x00, 0xee, 0x00, 0x00, 0x00}; #define txtm_width 16 #define txtm_height 16 #define txtm_bits ((char *)txtm_ubits) static uchar txtm_ubits[] = { 0xef, 0x01, 0xff, 0x01, 0xff, 0x01, 0x7c, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xff, 0x01, 0xff, 0x01, 0xef, 0x01}; static Curs cursors[BUTCUR_NUM]; static void draw(ButRcur *rc); static void erase(ButRcur *rc); static void butRcur_hideForRedraw(ButRcur *rc, int winId, int x,int y, int w,int h); void butEnv_rcInit(ButEnv *env) { Drawable d = RootWindow(env->dpy, DefaultScreen(env->dpy)); static bool first_time = TRUE; ButCur i; int dataWidth, j, k; if (first_time) { first_time = FALSE; for (i = butCur_idle; i < butCur_bogus; ++i) cursors[i].pic = NULL; cursors[butCur_idle].fontcurnum = XC_left_ptr; cursors[butCur_idle].hotX = 1; cursors[butCur_idle].hotY = 1; cursors[butCur_idle].w = 16; cursors[butCur_idle].h = 16; cursors[butCur_idle].pic = ntp_bits; cursors[butCur_idle].mask = ntm_bits; cursors[butCur_twitch].fontcurnum = XC_arrow; cursors[butCur_twitch].hotX = 14; cursors[butCur_twitch].hotY = 1; cursors[butCur_twitch].w = 16; cursors[butCur_twitch].h = 16; cursors[butCur_twitch].pic = tp_bits; cursors[butCur_twitch].mask = tm_bits; cursors[butCur_text].fontcurnum = XC_xterm; cursors[butCur_text].hotX = 4; cursors[butCur_text].hotY = 8; cursors[butCur_text].w = 16; cursors[butCur_text].h = 16; cursors[butCur_text].pic = txtp_bits; cursors[butCur_text].mask = txtm_bits; cursors[butCur_up].fontcurnum = XC_sb_up_arrow; cursors[butCur_up].hotX = 14; cursors[butCur_up].hotY = 14; cursors[butCur_up].w = 16; cursors[butCur_up].h = 16; cursors[butCur_up].pic = ntp_bits; cursors[butCur_up].mask = ntm_bits; cursors[butCur_down].fontcurnum = XC_sb_down_arrow; cursors[butCur_down].hotX = 14; cursors[butCur_down].hotY = 14; cursors[butCur_down].w = 16; cursors[butCur_down].h = 16; cursors[butCur_down].pic = ntp_bits; cursors[butCur_down].mask = ntm_bits; cursors[butCur_left].fontcurnum = XC_sb_left_arrow; cursors[butCur_left].hotX = 14; cursors[butCur_left].hotY = 14; cursors[butCur_left].w = 16; cursors[butCur_left].h = 16; cursors[butCur_left].pic = ntp_bits; cursors[butCur_left].mask = ntm_bits; cursors[butCur_right].fontcurnum = XC_sb_right_arrow; cursors[butCur_right].hotX = 14; cursors[butCur_right].hotY = 14; cursors[butCur_right].w = 16; cursors[butCur_right].h = 16; cursors[butCur_right].pic = ntp_bits; cursors[butCur_right].mask = ntm_bits; cursors[butCur_lr].fontcurnum = XC_sb_h_double_arrow; cursors[butCur_lr].hotX = 14; cursors[butCur_lr].hotY = 14; cursors[butCur_lr].w = 16; cursors[butCur_lr].h = 16; cursors[butCur_lr].pic = ntp_bits; cursors[butCur_lr].mask = ntm_bits; cursors[butCur_ud].fontcurnum = XC_sb_v_double_arrow; cursors[butCur_ud].hotX = 14; cursors[butCur_ud].hotY = 14; cursors[butCur_ud].w = 16; cursors[butCur_ud].h = 16; cursors[butCur_ud].pic = ntp_bits; cursors[butCur_ud].mask = ntm_bits; cursors[butCur_grab].fontcurnum = XC_fleur; cursors[butCur_grab].hotX = 14; cursors[butCur_grab].hotY = 14; cursors[butCur_grab].w = 16; cursors[butCur_grab].h = 16; cursors[butCur_grab].pic = ntp_bits; cursors[butCur_grab].mask = ntm_bits; } for (i = butCur_idle; i < butCur_bogus; ++i) { /* "Grey out" the remote cursors. */ dataWidth = (cursors[i].w + 7) / 8; for (j = 0; j < cursors[i].h; j += 2) { for (k = 0; k < dataWidth; ++k) { cursors[i].mask[j*dataWidth + k] &= 0x55; if (j+1 < cursors[i].h) { cursors[i].mask[(j+1)*dataWidth + k] &= 0xaa; } } } env->cursors[i] = XCreateFontCursor(env->dpy, cursors[i].fontcurnum); env->cpic[i] = XCreateBitmapFromData(env->dpy, d, cursors[i].pic, cursors[i].w, cursors[i].h); env->cmask[i] = XCreateBitmapFromData(env->dpy, d, cursors[i].mask, cursors[i].w, cursors[i].h); } env->curnum = butCur_idle; env->curwin = None; env->curhold = NULL; env->curlast = butCur_bogus; } /* Erase the cursor if it is in the area specified. */ void butRcur_create(ButRcur *rc, ButEnv *env) { MAGIC_SET(rc); rc->env = env; rc->winId = -2; rc->drawn = FALSE; rc->under = XCreatePixmap(env->dpy, DefaultRootWindow(env->dpy), 16,16, env->depth); } void butRcur_move(ButRcur *rc, int winId, int rx,int ry, int rw,int rh, ButCur type) { ButEnv *env = rc->env; assert(MAGIC(rc)); if ((winId < 0) || (winId >= env->maxWinIds)) winId = -2; else if (env->id2Win[winId] == NULL) winId = -2; if ((winId == rc->winId) && (rx == rc->rx) && (ry == rc->ry) && (rw == rc->rw) && (rh == rc->rh) && (type == rc->type)) return; if (rc->drawn) erase(rc); rc->winId = winId; rc->rx = rx; rc->ry = ry; rc->rw = rw; rc->rh = rh; rc->type = type; if (winId != -2) { rc->lx = (rx * env->id2Win[winId]->w + rw/2) / rw - cursors[type].hotX; rc->ly = (ry * env->id2Win[winId]->h + rh/2) / rh - cursors[type].hotY; draw(rc); } } void butRcur_redraw(ButEnv *env, int winId, int x,int y, int w,int h) { int i; if (winId == -2) return; for (i = 0; i < env->numPartners; ++i) { if (env->partners[i]) { if (butRnet_valid(env->partners[i]) && (winId == env->partners[i]->rc.winId)) butRcur_hideForRedraw(&env->partners[i]->rc, winId, x,y, w,h); } } } static void butRcur_hideForRedraw(ButRcur *rc, int winId, int x,int y, int w,int h) { assert(MAGIC(rc)); if (rc->drawn && (rc->winId == winId) && (x < rc->lx+16) && (y < rc->ly+16) && (x+w > rc->lx) && (y+h > rc->ly)) { /* We need to erase it. Will the redraw erase it for us? */ if ((x <= rc->lx) && (y <= rc->ly) && (x+w >= rc->lx+16) && (y+h >= rc->ly+16)) { rc->drawn = FALSE; } else erase(rc); } } /* xio is the I/O context that the move got reported in. */ static void draw(ButRcur *rc) { ButEnv *env = rc->env; assert(!rc->drawn); assert(MAGIC(rc)); XCopyArea(env->dpy, env->id2Win[rc->winId]->win, rc->under, env->gc2, rc->lx,rc->ly, 16,16, 0,0); if (!env->colorp) XSetFillStyle(env->dpy, env->gc2, FillSolid); XSetClipMask(env->dpy, env->gc2, env->cmask[rc->type]); XSetClipOrigin(env->dpy, env->gc2, rc->lx,rc->ly); XSetForeground(env->dpy, env->gc2, env->colors[BUT_FG]); XSetBackground(env->dpy, env->gc2, env->colors[BUT_LIT]); XCopyPlane(env->dpy, env->cpic[rc->type],env->id2Win[rc->winId]->win, env->gc2, 0,0, 16,16, rc->lx,rc->ly, 1L); XSetClipMask(env->dpy, env->gc2, None); if (!env->colorp) XSetFillStyle(env->dpy, env->gc2, FillTiled); rc->drawn = TRUE; } static void erase(ButRcur *rc) { ButEnv *env = rc->env; assert(MAGIC(rc)); assert(rc->drawn); XCopyArea(env->dpy, rc->under, env->id2Win[rc->winId]->win, env->gc2, 0,0, 16,16, rc->lx,rc->ly); rc->drawn = FALSE; } /* Change the cursor to make it twitched or not twitched. */ void butEnv_setCursor(ButEnv *env, But *but, ButCur newcursor) { if (newcursor == butCur_idle) { if (but == env->curhold) { env->curnum = newcursor; env->curhold = NULL; } } else { env->curnum = newcursor; env->curhold = but; } env->curwin = but->win->physWin; } /* Set up any cursor changes that may have occurred. */ void butEnv_rcActivate(ButEnv *env) { int i; if ((env->curlast != env->curnum) && (env->curwin != None)) { assert(env->curnum < butCur_bogus); env->curlast = env->curnum; XDefineCursor(env->dpy, env->curwin, env->cursors[env->curlast]); butRnet_mMove(env, -1, -1,-1, -1,-1, env->curnum); } for (i = 0; i < env->numPartners; ++i) { if (env->partners[i]) { if (butRnet_valid(env->partners[i]) && (env->partners[i]->rc.winId >= 0) && !env->partners[i]->rc.drawn) draw(&env->partners[i]->rc); } } } #endif cgoban-1.9.14/wmslib/src/but/slide.c0000664000671000067100000003612607043224472012662 /* * wmslib/src/but/slide.c, part of wmslib (Library functions) * Copyright (C) 1994-1997 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #include #include /********************************************************************** * Data Types **********************************************************************/ typedef struct Slide_struct { int maxval; int cval; int size; bool horiz; bool grip; int start_mloc, start_val, start_loc; ButTimer *timer; int timer_jump; int oldcur; /* * Stuff calculated from dimensions. * w and h are for a horizontal slider. Reverse for vertical! */ int boxW, boxH, boxLoc; int lastW, lastH; ButOut (*callback)(But *but, int setting, bool newPress); } Slide; /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut mmove(But *but, int x, int y); static ButOut mleave(But *but); static ButOut mpress(But *but, int butnum, int x, int y); static ButOut mrelease(But *but, int butnum, int x, int y); static void draw(But *but, int x, int y, int w, int h); static ButOut destroy(But *but); static void flags(But *but, uint flags); static ButOut slide_now(ButTimer *bt); static void specialDraw(But *but, Slide *slide, int x, int y, int w, int h); static void drawNewLoc(But *but); static void calcBoxLoc(But *but); /********************************************************************** * Globals **********************************************************************/ static const ButAction action = { mmove, mleave, mpress, mrelease, NULL, NULL, draw, destroy, flags, NULL}; /********************************************************************** * Functions **********************************************************************/ But *butSlide_hCreate(ButOut (*func)(But *but, int setting, bool newPress), void *packet, ButWin *win, int layer, int flags, int maxval, int cval, int size) { Slide *slide; But *but; slide = wms_malloc(sizeof(Slide)); but = but_create(win, slide, &action); but->uPacket = packet; but->layer = layer; but->flags = flags | BUT_OPAQUE; slide->maxval = maxval; slide->cval = cval; slide->size = size; slide->horiz = TRUE; slide->grip = FALSE; slide->start_mloc = 0; slide->start_val = 0; slide->start_loc = 0; slide->timer = NULL; slide->timer_jump = 0; slide->oldcur = butCur_idle; slide->boxW = slide->boxH = slide->boxLoc = 0; slide->lastW = 0; slide->lastH = 0; slide->callback = func; but_init(but); return(but); } But *butSlide_vCreate(ButOut (*func)(But *but, int setting, bool newPress), void *packet, ButWin *win, int layer, int flags, int maxval, int cval, int size) { Slide *slide; But *but; slide = wms_malloc(sizeof(Slide)); but = but_create(win, slide, &action); but->uPacket = packet; but->layer = layer; but->flags = flags | BUT_OPAQUE; slide->maxval = maxval; slide->cval = cval; slide->size = size; slide->horiz = FALSE; slide->grip = FALSE; slide->start_mloc = 0; slide->start_val = 0; slide->start_loc = 0; slide->timer = NULL; slide->timer_jump = 0; slide->oldcur = butCur_idle; slide->boxW = slide->boxH = slide->boxLoc = 0; slide->lastW = 0; slide->lastH = 0; slide->callback = func; but_init(but); return(but); } void butSlide_set(But *but, int maxval, int cval, int size) { Slide *slide = but->iPacket; assert(but->action == &action); if (maxval == BUT_NOCHANGE) maxval = slide->maxval; if (cval == BUT_NOCHANGE) cval = slide->cval; if (size == BUT_NOCHANGE) size = slide->size; if ((maxval != slide->maxval) || (cval != slide->cval) || (size != slide->size)) { slide->maxval = maxval; slide->cval = cval; slide->size = size; drawNewLoc(but); } } int butSlide_get(But *but) { Slide *slide = but->iPacket; return(slide->cval); } static ButOut destroy(But *but) { Slide *slide = but->iPacket; if (slide->timer != NULL) butTimer_destroy(slide->timer); wms_free(slide); return(0); } static void draw(But *but, int x, int y, int w, int h) { ButWin *win = but->win; ButEnv *env = win->env; Slide *slide = but->iPacket; int bw = env->stdButBw; if ((w != slide->lastW) || (h != slide->lastH)) calcBoxLoc(but); but_drawBox(win, but->x,but->y, but->w,but->h, 1, bw, BUT_SLEFT|BUT_SRIGHT, BUT_LIT, BUT_SHAD, None, None); butEnv_setXFg(env, BUT_PBG); XFillRectangle(env->dpy, win->win, env->gc, but->x+bw,but->y+bw, but->w-2*bw, but->h-2*bw); if (slide->horiz) { but_drawBox(win, but->x+bw+slide->boxLoc, but->y+bw, slide->boxW, slide->boxH, but->flags & BUT_LOCKED, bw, BUT_SLEFT|BUT_SRIGHT, BUT_LIT, BUT_SHAD, None, None); butEnv_setXFg(env, BUT_BG); XFillRectangle(env->dpy, win->win, env->gc, but->x + bw*2 + slide->boxLoc, but->y + bw * 2, slide->boxW - bw * 2, slide->boxH - bw * 2); } else /* !but->horiz */ { but_drawBox(win, but->x+bw, but->y+bw+slide->boxLoc, slide->boxH, slide->boxW, but->flags & BUT_LOCKED, bw, BUT_SLEFT|BUT_SRIGHT, BUT_LIT, BUT_SHAD, None, None); butEnv_setXFg(env, BUT_BG); XFillRectangle(env->dpy, win->win, env->gc, but->x + bw * 2, but->y + bw*2 + slide->boxLoc, slide->boxH - bw * 2, slide->boxW - bw * 2); } } static void calcBoxLoc(But *but) { Slide *slide = but->iPacket; ButEnv *env = but->win->env; int allW, allH; int bw; bw = butEnv_stdBw(env); if (slide->horiz) { allW = but->w - 2*bw; allH = but->h - 2*bw; } else { allW = but->h - 2*bw; allH = but->w - 2*bw; } if (allW <= allH) { slide->boxW = allW; slide->boxH = allH; slide->boxLoc = 0; } else { slide->boxW = (slide->size * allW + (slide->size + slide->maxval) / 2) / (slide->size + slide->maxval); slide->boxH = allH; if (slide->boxW < slide->boxH) slide->boxW = slide->boxH; if (slide->maxval == 0) slide->boxLoc = 0; else slide->boxLoc = ((allW - slide->boxW) * slide->cval + slide->maxval / 2) / slide->maxval; } slide->lastW = but->w; slide->lastH = but->h; } static void drawNewLoc(But *but) { ButEnv *env = but->win->env; Slide *slide = but->iPacket; int bw = env->stdButBw; int boxW, boxH, boxLoc; int oldW, oldLoc; if ((but->w < 1) || (but->h < 1)) return; oldW = slide->boxW; oldLoc = slide->boxLoc; calcBoxLoc(but); boxW = slide->boxW; boxH = slide->boxH; boxLoc = slide->boxLoc; if (boxLoc < oldLoc) { specialDraw(but, slide, boxLoc + bw, bw, oldLoc + bw - boxLoc, boxH); } else if (boxLoc > oldLoc) { specialDraw(but, slide, oldLoc + bw, bw, boxLoc + bw - oldLoc, boxH); } if (boxLoc + boxW < oldLoc + oldW) { specialDraw(but, slide, boxLoc + boxW, bw, oldLoc + oldW + bw - boxLoc - boxW, boxH); } else if (boxLoc + boxW > oldLoc + oldW) { specialDraw(but, slide, oldLoc + oldW, bw, boxLoc + boxW + bw - oldLoc - oldW, boxH); } } static void specialDraw(But *but, Slide *slide, int x, int y, int w, int h) { if (slide->horiz) { butWin_redraw(but->win, but->x + x, but->y + y, w, h); } else { butWin_redraw(but->win, but->x + y, but->y + x, h, w); } } static void flags(But *but, uint flags) { uint ofl = but->flags; but->flags = flags; if ((flags & (BUT_PRESSABLE|BUT_DRAWABLE|BUT_PRESSED|BUT_LOCKED)) != (ofl & (BUT_PRESSABLE|BUT_DRAWABLE|BUT_PRESSED|BUT_LOCKED))) but_draw(but); } static ButOut mmove(But *but, int x, int y) { ButOut retval = BUTOUT_CAUGHT; int newflags = but->flags; ButEnv *env = butWin_env(but_win(but)); Slide *slide = but->iPacket; int newval, newloc, pitmax; int newcur = butCur_idle; if (slide->horiz) { if ((newflags & BUT_LOCKED) && slide->grip) { /* Slide it around! */ if (x == BUT_NOCHANGE) return(retval); newloc = x - slide->start_mloc + slide->start_loc; if (newloc < 0) newloc = 0; pitmax = but->w - slide->boxW - env->stdButBw*2; if (newloc > pitmax) newloc = pitmax; if (pitmax == 0) newval = 0; else newval = (newloc * slide->maxval + pitmax/2) / pitmax; if (newval != slide->cval) { slide->cval = newval; drawNewLoc(but); if (slide->callback != NULL) return(retval | slide->callback(but, slide->cval, FALSE)); } return(retval); } if ((x >= but->x+env->stdButBw) && (x < but->x+but->w-env->stdButBw) && (y >= but->y+env->stdButBw) && (y < but->y+but->h-env->stdButBw)) { newflags |= BUT_TWITCHED; if (x < but->x + env->stdButBw + slide->boxLoc) newcur = butCur_left; else if (x < but->x + env->stdButBw + slide->boxLoc + slide->boxW) newcur = butCur_lr; else newcur = butCur_right; } else { newflags &= ~BUT_TWITCHED; if (!(newflags & BUT_LOCKED)) retval &= ~BUTOUT_CAUGHT; } if (!(newflags & BUT_LOCKED) && (newcur != slide->oldcur)) { butEnv_setCursor(env, but, newcur); slide->oldcur = newcur; } if (newflags != but->flags) { but_newFlags(but, newflags); } return(retval); } else /* !slide->horiz */ { if ((newflags & BUT_LOCKED) && slide->grip) { /* Slide it around! */ if (y == BUT_NOCHANGE) return(retval); newloc = y - slide->start_mloc + slide->start_loc; if (newloc < 0) newloc = 0; pitmax = but->h - slide->boxW - env->stdButBw*2; if (newloc > pitmax) newloc = pitmax; if (pitmax == 0) newval = 0; else newval = (newloc * slide->maxval + pitmax/2) / pitmax; if (newval != slide->cval) { slide->cval = newval; drawNewLoc(but); if (slide->callback != NULL) return(retval | slide->callback(but, slide->cval, FALSE)); } return(retval); } if ((x >= but->x+env->stdButBw) && (x < but->x+but->w-env->stdButBw) && (y >= but->y+env->stdButBw) && (y < but->y+but->h-env->stdButBw)) { newflags |= BUT_TWITCHED; if (y < but->y + env->stdButBw + slide->boxLoc) newcur = butCur_up; else if (y < but->y + env->stdButBw + slide->boxLoc + slide->boxW) newcur = butCur_ud; else newcur = butCur_down; } else { newflags &= ~BUT_TWITCHED; if (!(newflags & BUT_LOCKED)) retval &= ~BUTOUT_CAUGHT; } if (!(newflags & BUT_LOCKED) && (newcur != slide->oldcur)) { butEnv_setCursor(env, but, newcur); slide->oldcur = newcur; } if (newflags != but->flags) { but_newFlags(but, newflags); } return(retval); } } static ButOut mleave(But *but) { int newflags = but->flags; Slide *slide = but->iPacket; newflags &= ~BUT_TWITCHED; butEnv_setCursor(but->win->env, but, butCur_idle); slide->oldcur = butCur_idle; if (newflags != but->flags) { but_newFlags(but, newflags); } return(BUTOUT_CAUGHT); } static ButOut mpress(But *but, int butnum, int x, int y) { int retval = BUTOUT_CAUGHT, newflags = but->flags; Slide *slide = but->iPacket; ButEnv *env = but->win->env; if (!newflags & BUT_TWITCHED) retval &= ~BUTOUT_CAUGHT; else { if (slide->horiz) { if (but->w <= but->h) return(BUTOUT_CAUGHT | BUTOUT_ERR); if (butnum == 1) { newflags |= BUT_LOCKED; if (x < but->x + env->stdButBw + slide->boxLoc) { butSlide_startSlide(but, TRUE, -slide->size*2, FALSE); } else if (x >= but->x + env->stdButBw + slide->boxLoc + slide->boxW) { butSlide_startSlide(but, TRUE, slide->size*2, FALSE); } else { /* The box has been "gripped." */ slide->grip = TRUE; slide->start_mloc = x; slide->start_loc = slide->boxLoc; slide->start_val = slide->cval; } } else return(BUTOUT_CAUGHT | BUTOUT_ERR); } else /* !slide->horiz */ { if (but->h <= but->w) return(BUTOUT_CAUGHT | BUTOUT_ERR); if (butnum == 1) { newflags |= BUT_LOCKED; if (y < but->y + env->stdButBw + slide->boxLoc) { butSlide_startSlide(but, TRUE, -slide->size*2, FALSE); } else if (y >= but->y + env->stdButBw + slide->boxLoc + slide->boxW) { butSlide_startSlide(but, TRUE, slide->size*2, FALSE); } else { /* The box has been "gripped." */ slide->grip = TRUE; slide->start_mloc = y; slide->start_loc = slide->boxLoc; slide->start_val = slide->cval; } } else return(BUTOUT_CAUGHT | BUTOUT_ERR); } snd_play(&but_downSnd); if (newflags != but->flags) but_newFlags(but, newflags); if (slide->callback != NULL) return(retval | slide->callback(but, slide->cval, TRUE)); } return(retval); } void butSlide_startSlide(But *but, bool pause, int ssize, bool propagate) { Slide *slide = but->iPacket; struct timeval delay; int atj; bool skipTimer = FALSE; if (slide->timer != NULL) butTimer_destroy(slide->timer); if (pause) { slide->cval += ssize/2; if (slide->cval <= 0) { slide->cval = 0; skipTimer = TRUE; } else if (slide->cval >= slide->maxval - 1) { slide->cval = slide->maxval - 1; skipTimer = TRUE; } drawNewLoc(but); if (propagate && slide->callback) slide->callback(but, slide->cval, TRUE); } if (!skipTimer) { slide->timer_jump = ssize; if (pause) { delay.tv_sec = 0; delay.tv_usec = 500000; } else { delay.tv_sec = 0; delay.tv_usec = 0; } if (slide->timer_jump > 0) atj = slide->timer_jump; else atj = -slide->timer_jump; slide->timer = butTimer_fCreate(NULL, but, delay, atj*2, FALSE, slide_now); } } static ButOut slide_now(ButTimer *bt) { But *but = bt->but; Slide *slide = but->iPacket; if (slide->timer_jump > 0) { slide->cval += bt->eventNum; if (slide->cval > slide->maxval) { slide->cval = slide->maxval; butTimer_destroy(bt); slide->timer = NULL; } } else { slide->cval -= bt->eventNum; if (slide->cval < 0) { slide->cval = 0; butTimer_destroy(bt); slide->timer = NULL; } } bt->eventNum = 0; drawNewLoc(but); if (slide->callback != NULL) return(slide->callback(but, slide->cval, FALSE)); return(0); } static ButOut mrelease(But *but, int butnum, int x, int y) { ButOut retval = BUTOUT_CAUGHT; uint newflags = but->flags; Slide *slide = but->iPacket; if (!newflags & BUT_TWITCHED) butEnv_setCursor(but->win->env, but, slide->oldcur = butCur_idle); if (slide->timer != NULL) { butTimer_destroy(slide->timer); slide->timer = NULL; } slide->grip = FALSE; newflags &= ~BUT_LOCKED; if (newflags != but->flags) but_newFlags(but, newflags); snd_play(&but_upSnd); return(retval); } void butSlide_stopSlide(But *but) { Slide *slide = but->iPacket; if (slide->timer) { butTimer_destroy(slide->timer); slide->timer = NULL; } } #endif cgoban-1.9.14/wmslib/src/but/tbin.c0000664000671000067100000017015307043224472012515 /* * wmslib/src/but/tbin.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ /* * This is absolutely huge and disgusting. It is no longer a cute little * button. It has grown into a monstrosity. Some day I will break it off, * make it into its own module, that reads configuration files, etc. * Then it will be cool! Then it will be its own work processor, and I * will just have to wrap a few extra buttons around it to have my very * own beautiful wysiwyg word processor/editor! Yay! */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #include #include #include #include #include /********************************************************************** * Constants **********************************************************************/ #define MAX_PASTE (64*1024) /********************************************************************** * Data types **********************************************************************/ typedef enum { insert_none, insert_ok, insert_cr, insert_bad } Insert; typedef enum { break_loCur, break_eoLoCur, break_eol } BreakType; typedef struct Loc_struct { int tin, index; } Loc; typedef struct Tin_struct { int start, len; int width; /* In pixels. */ } Tin; typedef enum { tbin_loCur, tbin_hiCur, tbin_mouse, tbin_press } TbinLoc; #define tbin_numLocs (tbin_press + 1) #define tbinLoc_iter(i) for (i = 0; i < tbin_numLocs; ++i) typedef struct Tbin_struct { ButTimer *cTimer; int mouseX; Loc locs[tbin_numLocs]; bool mouseInBut; int clicks, prevClickNum; bool cursorVisible; bool readOnly; int lMargin, rMargin; int maxLines; /* If you exceed this, chop off the top. */ int numTins, maxTins, loTinBreak, hiTinBreak; Tin *tins; int bufLen, loBreak, hiBreak; char *buf; void (*offWinCallback)(But *but, int activeLine, int passiveLine, int mouseY); MAGIC_STRUCT } Tbin; static But *cut_butnum = NULL; static But *paste_butnum = NULL; /********************************************************************** * Forward declarations **********************************************************************/ static int locateMouse(XFontStruct *fs, const char *text, int textLen, int x, bool *rightSide); static void ti_cursor(But *but); static void ti_redrawCursor(But *but); static ButOut mmove(But *but, int x, int y); static ButOut mleave(But *but); static ButOut mpress(But *but, int butnum, int x, int y); static ButOut mrelease(But *but, int butnum, int x, int y); static ButOut kpress(But *but, const char *keystr, KeySym sym); static void draw(But *but, int x,int y, int w,int h); static ButOut destroy(But *but); static Insert insert(ButEnv *env, const char *src, Tbin *but, int butW, bool *changePrev); static void cut(ButEnv *env, But *but); static void paste(ButEnv *env, But *but); static void enableCTimer(But *but); static void disableCTimer(But *but); static bool sreq(ButEnv *env, XSelectionRequestEvent *xsre); static int sclear(ButEnv *env); static int snotify(ButEnv *env, XSelectionEvent *xsre); static void flags(But *but, uint flags); static void wordsel_adjust(Tbin *tbin); static void tin_draw(But *but, Tbin *tb, int tinNum, int x, int y, int w, int h); static int calcTinNum(But *but, Tbin *tbin, int y); static void setMouseX(But *but, Tbin *tbin, int tin, int loc); static void checkOffWin(But *but, int mouseY, bool force); #define tinNum_next(tn, tb) (((tn)+1 == (tb)->loTinBreak) ? \ (tb)->hiTinBreak:(tn)+1) #define tinNum_prev(tn, tb) (((tn) == (tb)->hiTinBreak) ? \ (tb)->loTinBreak-1:(tn)-1) #define tinNum_line(tn, tb) ((tn) >= (tb)->loTinBreak ? \ (tn) + (tb)->loTinBreak - (tb)->hiTinBreak : \ (tn)) #define tinNum_line2TinNum(l, tb) \ ((l) >= (tb)->loTinBreak ? \ (l) + (tb)->hiTinBreak - (tb)->loTinBreak : \ (l)) #define tinNum_valid(tn, tb) (((tn) >= 0) && ((tn) < (tb)->maxTins) && \ (((tn) < (tb)->loTinBreak) || \ ((tn) >= (tb)->hiTinBreak))) #define loc_valid(l, tb) (tinNum_valid((l).tin, (tb)) && \ ((l).index >= 0) && \ ((l).index <= (tb)->tins[(l).tin].len)) #define loc_eq(a, b) (((a).index == (b).index) && ((a).tin == (b).tin)) static void adjustBreak(Tbin *tb, BreakType bType, int breakTin); static void addMoreBufferSpace(Tbin *tb); static void addMoreTins(Tbin *tb); static void breakLine(Tbin *tb, int tinNum, ButEnv *env, int butW); static int calcTinWidth(Tin *tin, const char *buf, ButEnv *env); static bool tryJoinLines(Tbin *tb, int tinNum, ButEnv *env, int butW); static bool resize(But *but, int oldX, int oldY, int oldW, int oldH); static void killTopLines(Tbin *tb, int lines); static void setLoc(Tbin *tb, TbinLoc locNum, int position); /********************************************************************** * Global variables **********************************************************************/ static ButAction action = { mmove, mleave, mpress, mrelease, kpress, NULL, draw, destroy, flags, NULL, resize}; But *butTbin_create(ButWin *win, int layer, int flags, const char *text) { But *but; Tbin *tb; TbinLoc tbinLoc; tb = wms_malloc(sizeof(Tbin)); MAGIC_SET(tb); but = but_create(win, tb, &action); but->layer = layer; but->flags = flags; if (text == NULL) text = ""; tb->cTimer = NULL; tb->mouseX = -1; tbinLoc_iter(tbinLoc) { tb->locs[tbinLoc].tin = 0; tb->locs[tbinLoc].index = 0; } tb->mouseInBut = FALSE; tb->clicks = tb->prevClickNum = 0; tb->cursorVisible = FALSE; tb->readOnly = FALSE; tb->lMargin = tb->rMargin = butEnv_stdBw(win->env); tb->maxLines = -1; tb->numTins = 1; tb->maxTins = 2; tb->tins = wms_malloc(tb->maxTins * sizeof(Tin)); tb->bufLen = 4 * 1024; tb->loBreak = 0; tb->hiBreak = tb->bufLen; tb->buf = wms_malloc(tb->bufLen); butTbin_set(but, text); tb->offWinCallback = NULL; return(but); } const char *butTbin_get(But *but) { Tbin *tb = but->iPacket; assert(but->action == &action); assert(MAGIC(tb)); adjustBreak(tb, break_eol, tinNum_prev(tb->maxTins, tb)); if (tb->loBreak == tb->hiBreak) addMoreBufferSpace(tb); tb->buf[tb->loBreak] = '\0'; return(tb->buf); } int butTbin_numLines(But *but) { Tbin *tbin = but->iPacket; assert(MAGIC(tbin)); return(tbin->numTins); } void butTbin_setOffWinCallback(But *but, void (*func)(But *but, int activeLine, int passiveLine, int mouseY)) { Tbin *tbin; assert(MAGIC(but)); tbin = but->iPacket; assert(MAGIC(tbin)); tbin->offWinCallback = func; } static ButOut destroy(But *but) { Tbin *tb = but->iPacket; ButEnv *env = but->win->env; assert(but->action == &action); assert(MAGIC(tb)); if (cut_butnum == but) { if (env->sClear == sclear) env->sClear = NULL; if (env->sReq == sreq) env->sReq = NULL; cut_butnum = NULL; } if (paste_butnum == but) { if (env->sNotify == snotify) env->sNotify = NULL; paste_butnum = NULL; } wms_free(tb->tins); wms_free(tb->buf); MAGIC_UNSET(tb); wms_free(tb); return(0); } static void draw(But *but, int x,int y, int w,int h) { Tbin *tb = but->iPacket; ButEnv *env = but->win->env; int fontH, i, startLine; int tinY; assert(but->action == &action); assert(MAGIC(tb)); fontH = butEnv_fontH(env, 0); XSetFont(env->dpy, env->gc, env->fonts[0]->fid); startLine = (y - fontH + 1 - but->y) / fontH; if (startLine < 0) startLine = 0; tinY = but->y + startLine * fontH; for (i = tinNum_line2TinNum(startLine, tb); (i < tb->maxTins) && (tinY < y + h); i = tinNum_next(i, tb)) { tin_draw(but, tb, i, but->x, tinY, but->w, fontH); tinY += fontH; } } static void tin_draw(But *but, Tbin *tb, int tinNum, int x, int y, int w, int h) { ButWin *win = but->win; ButEnv *env = win->env; Tin *ti = &tb->tins[tinNum]; XFontStruct *fs = env->fonts[0]; int loCur, hiCur; int blockL, blockW; butEnv_setXFg(env, BUT_FG); if (tb->locs[tbin_loCur].tin < tinNum) { loCur = -1; } else if (tb->locs[tbin_loCur].tin == tinNum) { loCur = tb->locs[tbin_loCur].index; } else { loCur = ti->len + 1; } if (tb->locs[tbin_hiCur].tin < tinNum) { hiCur = -1; } else if (tb->locs[tbin_hiCur].tin == tinNum) { hiCur = tb->locs[tbin_hiCur].index; } else { hiCur = ti->len + 1; } if (loCur != hiCur) { blockW = 0; assert(hiCur >= 0); if (loCur == -1) { if (hiCur == 0) blockL = x + tb->lMargin; else { blockL = x; blockW += tb->lMargin; } } else { assert((loCur >= 0) && (loCur <= ti->len)); blockL = x + tb->lMargin + XTextWidth(fs, tb->buf + ti->start, loCur); } if (hiCur <= ti->len) { blockW += XTextWidth(fs, tb->buf + ti->start + loCur, hiCur - loCur); } else { assert(hiCur == ti->len + 1); if (loCur == 0) blockL = x; blockW = w - blockL; } butEnv_setXFg(env, BUT_SELBG); XFillRectangle(env->dpy, win->win, env->gc, blockL-win->xOff, y-win->yOff, blockW, h); butEnv_setXFg(env, BUT_FG); } XDrawString(env->dpy, win->win, env->gc, x + tb->lMargin - win->xOff, y + fs->ascent - win->yOff, tb->buf + ti->start, ti->len); if (!(but->flags & BUT_PRESSABLE)) { butEnv_stdFill2(env); } if ((tb->locs[tbin_loCur].tin == tinNum) && (loCur == hiCur) && tb->cursorVisible && (but->flags & BUT_PRESSABLE)) ti_cursor(but); } static ButOut mmove(But *but, int x, int y) { Tbin *tb = but->iPacket; Tin *ti; int tinNum; ButWin *win = but->win; ButEnv *env = win->env; int newMousePress; bool rightSide; int oldLoTin = tb->locs[tbin_loCur].tin, oldLo = tb->locs[tbin_loCur].index; int oldHiTin = tb->locs[tbin_hiCur].tin, oldHi = tb->locs[tbin_hiCur].index; if (!(but->flags & BUT_PRESSABLE)) return(BUTOUT_CAUGHT); if (!tb->mouseInBut) { tb->mouseInBut = TRUE; butEnv_setCursor(env, but, butCur_text); } tinNum = calcTinNum(but, tb, y); if ((tinNum >= 0) && (tinNum < tb->maxTins)) ti = &tb->tins[tinNum]; else ti = NULL; switch(tb->clicks) { case(0): break; case(1): case(2): if (ti) { if (y < but->y) { newMousePress = 0; rightSide = FALSE; } else newMousePress = locateMouse(env->fonts[0], tb->buf + ti->start, ti->len, x - (but->x+tb->lMargin), &rightSide); if (rightSide && (newMousePress == ti->len) && ((tinNum > tb->locs[tbin_press].tin) || ((tinNum == tb->locs[tbin_press].tin) && (tb->locs[tbin_press].index < newMousePress)))) { tinNum = tinNum_next(tinNum, tb); newMousePress = 0; if (tinNum >= tb->maxTins) { tinNum = tinNum_prev(tb->maxTins, tb); ti = NULL; } else { ti = &tb->tins[tinNum]; } } } else { newMousePress = 0; rightSide = FALSE; } if (ti && (tb->clicks == 2)) { if (rightSide && ((tinNum > tb->locs[tbin_press].tin) || ((tinNum == tb->locs[tbin_press].tin) && (newMousePress >= tb->locs[tbin_press].index))) && (newMousePress < ti->len) && (newMousePress > 0)) ++newMousePress; else if (!rightSide && ((tinNum < tb->locs[tbin_press].tin) || ((tinNum == tb->locs[tbin_press].tin) && (newMousePress <= tb->locs[tbin_press].index))) && (newMousePress > 0)) --newMousePress; } if ((newMousePress != tb->locs[tbin_mouse].index) || (tinNum != tb->locs[tbin_mouse].tin)) { tb->locs[tbin_mouse].index = newMousePress; tb->locs[tbin_mouse].tin = tinNum; assert(loc_valid(tb->locs[tbin_mouse], tb)); if ((tb->locs[tbin_mouse].tin < tb->locs[tbin_press].tin) || ((tb->locs[tbin_mouse].tin == tb->locs[tbin_press].tin) && (tb->locs[tbin_mouse].index < tb->locs[tbin_press].index))) { tb->locs[tbin_loCur] = tb->locs[tbin_mouse]; tb->locs[tbin_hiCur] = tb->locs[tbin_press]; } else { tb->locs[tbin_loCur] = tb->locs[tbin_press]; tb->locs[tbin_hiCur] = tb->locs[tbin_mouse]; } if (tb->clicks == 2) { wordsel_adjust(tb); } } break; case(3): /* Triple-click. */ tb->locs[tbin_mouse].tin = tinNum; tb->locs[tbin_mouse].index = 0; tb->locs[tbin_loCur].index = tb->locs[tbin_hiCur].index = 0; if (tb->locs[tbin_mouse].tin < tb->locs[tbin_press].tin) { tb->locs[tbin_loCur].tin = tb->locs[tbin_mouse].tin; tb->locs[tbin_hiCur].tin = tb->locs[tbin_press].tin; } else { tb->locs[tbin_loCur].tin = tb->locs[tbin_press].tin; tb->locs[tbin_hiCur].tin = tb->locs[tbin_mouse].tin; } if (tinNum_next(tb->locs[tbin_hiCur].tin, tb) < tb->maxTins) { tb->locs[tbin_hiCur].tin = tinNum_next(tb->locs[tbin_hiCur].tin, tb); } else tb->locs[tbin_hiCur].index = tb->tins[tb->locs[tbin_hiCur].tin].len; assert(loc_valid(tb->locs[tbin_mouse], tb)); break; default: assert(tb->clicks == 4); tb->locs[tbin_mouse].tin = tinNum; assert(loc_valid(tb->locs[tbin_mouse], tb)); break; } if (tb->clicks) { /* * We cannot call this if no clicks. Why? Because with no clicks, we * _could_ be doing a resize (due to a new line being added). * Resize calls mmove, which would call checkOffWin, which calls * resize, etc...boom! * Even this is a bit hairy. */ checkOffWin(but, y, TRUE); } if ((tb->locs[tbin_loCur].tin != oldLoTin) || (tb->locs[tbin_loCur].index != oldLo) || (tb->locs[tbin_hiCur].tin != oldHiTin) || (tb->locs[tbin_hiCur].index != oldHi)) but_draw(but); return(BUTOUT_CAUGHT); } static ButOut mleave(But *but) { Tbin *tb = but->iPacket; if (tb->mouseInBut) { tb->mouseInBut = FALSE; butEnv_setCursor(but->win->env, but, butCur_idle); } return(BUTOUT_CAUGHT); } static ButOut mpress(But *but, int butnum, int x, int y) { Tbin *tb = but->iPacket; Tin *ti; ButEnv *env = but->win->env; static Time lastPressTime = -1; static int lastPressNum = -2; int rightSide; if (tb->cTimer) { butTimer_reset(tb->cTimer); tb->cursorVisible = TRUE; } tb->locs[tbin_mouse].tin = calcTinNum(but, tb, y); if ((tb->locs[tbin_mouse].tin >= 0) && (tb->locs[tbin_mouse].tin < tb->maxTins)) { ti = &tb->tins[tb->locs[tbin_mouse].tin]; if (y < but->y) { tb->locs[tbin_mouse].index = 0; rightSide = FALSE; } else tb->locs[tbin_mouse].index = locateMouse(env->fonts[0], tb->buf + ti->start, ti->len, x - (but->x+tb->lMargin), &rightSide); } else { ti = NULL; tb->locs[tbin_mouse].index = 0; } switch (butnum) { case 1: /* Button 1 selects, drags, etc. */ assert(loc_valid(tb->locs[tbin_mouse], tb)); tb->locs[tbin_loCur] = tb->locs[tbin_hiCur] = tb->locs[tbin_press] = tb->locs[tbin_mouse]; if (!tb->readOnly && !(but->flags & BUT_KEYED)) but_newFlags(but, but->flags | BUT_KEYED); but_newFlags(but, but->flags | BUT_LOCKED); if ((lastPressTime + BUT_DCLICK > env->eventTime) && (lastPressNum + 1 == env->eventNum)) { tb->clicks = tb->prevClickNum; if (tb->clicks == 1) { /* It's a double click! */ ++tb->clicks; if (rightSide) ++tb->locs[tbin_hiCur].index; else --tb->locs[tbin_loCur].index; wordsel_adjust(tb); } else if (tb->clicks == 2) { /* It's a triple click! */ ++tb->clicks; tb->locs[tbin_loCur].index = 0; tb->locs[tbin_hiCur].index = 0; if (tinNum_next(tb->locs[tbin_mouse].tin, tb) < tb->maxTins) tb->locs[tbin_hiCur].tin = tinNum_next(tb->locs[tbin_hiCur].tin, tb); } else if (tb->clicks == 3) { /* Quadruple click! Mark everything! */ ++tb->clicks; tb->locs[tbin_loCur].tin = 0; tb->locs[tbin_hiCur].tin = tinNum_prev(tb->maxTins, tb); tb->locs[tbin_loCur].index = 0; tb->locs[tbin_hiCur].index = tb->tins[tb->locs[tbin_hiCur].tin].len; } else { /* Pentuple click! Restart! */ tb->clicks = 1; } } else { tb->clicks = 1; } lastPressTime = env->eventTime; lastPressNum = env->eventNum; but_draw(but); break; case 2: /* Paste! */ if (tb->readOnly) return(BUTOUT_ERR); else paste(env, but); break; default: /* * Weird. I don't know what to do with mice with more than 3 buttons * so I guess I might as well beep. I like beeping. */ return(BUTOUT_ERR); break; } checkOffWin(but, y, TRUE); return(BUTOUT_CAUGHT); } static ButOut mrelease(But *but, int butnum, int x, int y) { Tbin *tb = but->iPacket; if (tb->cTimer) { butTimer_reset(tb->cTimer); tb->cursorVisible = TRUE; } if ((butnum == 1) && tb->clicks) { tb->prevClickNum = tb->clicks; tb->clicks = 0; if ((tb->locs[tbin_loCur].tin != tb->locs[tbin_hiCur].tin) || (tb->locs[tbin_loCur].index != tb->locs[tbin_hiCur].index)) { cut(but->win->env, but); } but_newFlags(but, but->flags & ~BUT_LOCKED); } checkOffWin(but, y, TRUE); return(BUTOUT_CAUGHT); } static ButOut kpress(But *but, const char *newtext, KeySym keysym) { Tbin *tb = but->iPacket; ButEnv *env = but->win->env; bool need_draw = FALSE; ButOut result = 0; bool clearMouseX = TRUE; int drawLo = tb->locs[tbin_loCur].tin, drawHi = tb->locs[tbin_hiCur].tin; Insert insertResult = insert_none; bool changePrev = FALSE; assert(but->flags & BUT_KEYED); butTimer_reset(tb->cTimer); tb->cursorVisible = TRUE; if (((keysym >= XK_KP_Space) && (keysym <= XK_KP_9)) || ((keysym >= XK_space) && (keysym <= XK_ydiaeresis))) { need_draw = TRUE; switch(newtext[0]) { case '\001': /* Ctrl-A: Beginning of line. */ tb->locs[tbin_loCur].index = 0; tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; break; case '\020': /* Ctrl-P: Up a line. */ clearMouseX = FALSE; if (tb->locs[tbin_loCur].tin == 0) { if (tb->locs[tbin_loCur].index || tb->locs[tbin_hiCur].index || tb->locs[tbin_hiCur].tin) { tb->locs[tbin_loCur].index = 0; tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; } else { need_draw = FALSE; result |= BUTOUT_ERR; } } else { if (tb->mouseX == -1) setMouseX(but, tb, tb->locs[tbin_loCur].tin, tb->locs[tbin_loCur].index); tb->locs[tbin_loCur].tin = tinNum_prev(tb->locs[tbin_loCur].tin, tb); tb->locs[tbin_loCur].index = locateMouse(env->fonts[0], tb->buf + tb->tins[tb->locs[tbin_loCur].tin].start, tb->tins[tb->locs[tbin_loCur].tin].len, tb->mouseX, NULL); tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; } break; case '\016': /* Ctrl-N: Down a line. */ clearMouseX = FALSE; if (tinNum_next(tb->locs[tbin_hiCur].tin, tb) == tb->maxTins) { if (tb->locs[tbin_loCur].tin != tb->locs[tbin_hiCur].tin) { tb->locs[tbin_loCur] = tb->locs[tbin_hiCur]; } else { need_draw = FALSE; result |= BUTOUT_ERR; } } else { if (tb->mouseX == -1) setMouseX(but, tb, tb->locs[tbin_hiCur].tin, tb->locs[tbin_hiCur].index); tb->locs[tbin_hiCur].tin = tinNum_next(tb->locs[tbin_hiCur].tin, tb); tb->locs[tbin_hiCur].index = locateMouse(env->fonts[0], tb->buf + tb->tins[tb->locs[tbin_hiCur].tin].start, tb->tins[tb->locs[tbin_hiCur].tin].len, tb->mouseX, NULL); tb->locs[tbin_loCur] = tb->locs[tbin_hiCur]; } break; case '\002': /* Ctrl-B: Back a character. */ if ((tb->locs[tbin_loCur].tin != tb->locs[tbin_hiCur].tin) || (tb->locs[tbin_loCur].index != tb->locs[tbin_hiCur].index)) { tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; need_draw = TRUE; } else if (tb->locs[tbin_loCur].index) { tb->locs[tbin_hiCur].index = --tb->locs[tbin_loCur].index; } else if (tb->locs[tbin_loCur].tin) { tb->locs[tbin_loCur].tin = tinNum_prev(tb->locs[tbin_loCur].tin, tb); tb->locs[tbin_loCur].index = tb->tins[tb->locs[tbin_loCur].tin].len; tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; } else { need_draw = FALSE; result |= BUTOUT_ERR; } break; case '\004': /* Ctrl-D: Delete right. */ if ((tb->locs[tbin_loCur].index != tb->locs[tbin_hiCur].index) || (tb->locs[tbin_loCur].tin != tb->locs[tbin_hiCur].tin)) { insertResult = insert(env, "", tb, but->w, &changePrev); need_draw = TRUE; } else if (tinNum_next(tb->locs[tbin_loCur].tin, tb) < tb->maxTins) { if (tb->locs[tbin_loCur].index < tb->tins[tb->locs[tbin_loCur].tin].len) ++tb->locs[tbin_hiCur].index; else if (tb->buf[tb->loBreak - 1] == '\n') { tb->locs[tbin_hiCur].tin = tinNum_next(tb->locs[tbin_hiCur].tin, tb); tb->locs[tbin_hiCur].index = 0; } else { tb->locs[tbin_hiCur].tin = tinNum_next(tb->locs[tbin_hiCur].tin, tb); tb->locs[tbin_hiCur].index = 1; } insertResult = insert(env, "", tb, but->w, &changePrev); need_draw = TRUE; } else result |= BUTOUT_ERR; break; case '\005': /* Ctrl-E: End of line. */ tb->locs[tbin_hiCur].index = tb->tins[tb->locs[tbin_hiCur].tin].len; tb->locs[tbin_loCur] = tb->locs[tbin_hiCur]; break; case '\006': /* Ctrl-F: Forward a character. */ need_draw = TRUE; if ((tb->locs[tbin_loCur].tin != tb->locs[tbin_hiCur].tin) || (tb->locs[tbin_loCur].index != tb->locs[tbin_hiCur].index)) { tb->locs[tbin_loCur] = tb->locs[tbin_hiCur]; } else if (tb->locs[tbin_loCur].index < tb->tins[tb->locs[tbin_loCur].tin].len) { tb->locs[tbin_hiCur].index = ++tb->locs[tbin_loCur].index; } else if (tinNum_next(tb->locs[tbin_loCur].tin, tb) < tb->maxTins) { tb->locs[tbin_loCur].tin = tinNum_next(tb->locs[tbin_loCur].tin, tb); tb->locs[tbin_loCur].index = 0; tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; } else { result |= BUTOUT_ERR; need_draw = FALSE; } break; case '\013': /* Ctrl-K: Kill to end of line. */ need_draw = TRUE; if ((tb->locs[tbin_loCur].index != tb->locs[tbin_hiCur].index) || (tb->locs[tbin_loCur].tin != tb->locs[tbin_hiCur].tin)) insertResult = insert(env, "", tb, but->w, &changePrev); else if (tinNum_next(tb->locs[tbin_loCur].tin, tb) < tb->maxTins) { if (tb->locs[tbin_loCur].index == tb->tins[tb->locs[tbin_loCur].tin].len) { tb->locs[tbin_hiCur].tin = tinNum_next(tb->locs[tbin_loCur].tin, tb); tb->locs[tbin_hiCur].index = 0; } else { tb->locs[tbin_hiCur].tin = tb->locs[tbin_loCur].tin; tb->locs[tbin_hiCur].index = tb->tins[tb->locs[tbin_loCur].tin].len; } insertResult = insert(env, "", tb, but->w, &changePrev); } else { result |= BUTOUT_ERR; need_draw = FALSE; } break; case '\025': /* Ctrl-U: Kill from beginning of line. */ if ((tb->locs[tbin_loCur].index != tb->locs[tbin_hiCur].index) || (tb->locs[tbin_loCur].tin != tb->locs[tbin_hiCur].tin)) insertResult = insert(env, "", tb, but->w, &changePrev); else if (tb->locs[tbin_loCur].index > 0) { tb->locs[tbin_hiCur].index = 0; tb->locs[tbin_hiCur].tin = tb->locs[tbin_loCur].tin; insertResult = insert(env, "", tb, but->w, &changePrev); } else { result |= BUTOUT_ERR; need_draw = FALSE; } break; default: insertResult = insert(env, newtext, tb, but->w, &changePrev); break; } } else if ((keysym >= XK_Shift_L) && (keysym <= XK_Hyper_R)) { } else if ((keysym >= XK_F1) && (keysym <= XK_F35)) { insertResult = insert(env, newtext, tb, but->w, &changePrev); } else if ((keysym == XK_BackSpace) || (keysym == XK_Delete)) { if ((tb->locs[tbin_loCur].index != tb->locs[tbin_hiCur].index) || (tb->locs[tbin_loCur].tin != tb->locs[tbin_hiCur].tin)) { insertResult = insert(env, "", tb, but->w, &changePrev); need_draw = TRUE; } else if (tb->locs[tbin_loCur].index > 0) { --tb->locs[tbin_loCur].index; assert((drawHi < tb->loTinBreak) || (drawHi >= tb->hiTinBreak)); drawHi = tinNum_line(drawHi, tb); insertResult = insert(env, "", tb, but->w, &changePrev); drawHi = tinNum_line2TinNum(drawHi, tb); assert((drawHi < tb->loTinBreak) || (drawHi >= tb->hiTinBreak)); need_draw = TRUE; } else if (tb->locs[tbin_loCur].tin > 0) { if (tb->buf[tb->tins[tb->locs[tbin_loCur].tin].start - 1] == '\n') { tb->locs[tbin_loCur].tin = tinNum_prev(tb->locs[tbin_loCur].tin, tb); tb->locs[tbin_loCur].index = tb->tins[tb->locs[tbin_loCur].tin].len; } else { tb->locs[tbin_loCur].tin = tinNum_prev(tb->locs[tbin_loCur].tin, tb); tb->locs[tbin_loCur].index = tb->tins[tb->locs[tbin_loCur].tin].len - 1; } insertResult = insert(env, "", tb, but->w, &changePrev); need_draw = TRUE; } else { result |= BUTOUT_ERR; } #if 0 /* People don't like my delete. :-( */ } else if (keysym == XK_Delete) { if ((tb->locs[tbin_loCur].index != tb->locs[tbin_hiCur].index) || (tb->locs[tbin_loCur].tin != tb->locs[tbin_hiCur].tin)) { insertResult = insert(env, "", tb, but->w, &changePrev); need_draw = TRUE; } else if (tinNum_next(tb->locs[tbin_loCur].tin, tb) < tb->maxTins) { if (tb->locs[tbin_loCur].index < tb->tins[tb->locs[tbin_loCur].tin].len) ++tb->locs[tbin_hiCur].index; else if (tb->buf[tb->loBreak - 1] == '\n') { tb->locs[tbin_hiCur].tin = tinNum_next(tb->locs[tbin_hiCur].tin, tb); tb->locs[tbin_hiCur].index = 0; } else { tb->locs[tbin_hiCur].tin = tinNum_next(tb->locs[tbin_hiCur].tin, tb); tb->locs[tbin_hiCur].index = 1; } insertResult = insert(env, "", tb, but->w, &changePrev); need_draw = TRUE; } else result |= BUTOUT_ERR; #endif } else if (keysym == XK_Left) { need_draw = TRUE; if (!loc_eq(tb->locs[tbin_loCur], tb->locs[tbin_hiCur])) { tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; } else if (tb->locs[tbin_loCur].index) { tb->locs[tbin_hiCur].index = --tb->locs[tbin_loCur].index; } else if (tb->locs[tbin_loCur].tin) { tb->locs[tbin_loCur].tin = tinNum_prev(tb->locs[tbin_loCur].tin, tb); tb->locs[tbin_loCur].index = tb->tins[tb->locs[tbin_loCur].tin].len; tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; } else result |= BUTOUT_ERR; } else if (keysym == XK_Right) { need_draw = TRUE; if (!loc_eq(tb->locs[tbin_loCur], tb->locs[tbin_hiCur])) { tb->locs[tbin_loCur] = tb->locs[tbin_hiCur]; } else if (tb->locs[tbin_loCur].index < tb->tins[tb->locs[tbin_loCur].tin].len) { tb->locs[tbin_hiCur].index = ++tb->locs[tbin_loCur].index; } else if (tinNum_next(tb->locs[tbin_loCur].tin, tb) < tb->maxTins) { tb->locs[tbin_loCur].tin = tinNum_next(tb->locs[tbin_loCur].tin, tb); tb->locs[tbin_loCur].index = 0; tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; } else result |= BUTOUT_ERR; } else if (keysym == XK_Up) { clearMouseX = FALSE; if (tb->locs[tbin_loCur].tin == 0) { if (!loc_eq(tb->locs[tbin_loCur], tb->locs[tbin_hiCur])) { tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; need_draw = TRUE; } else result |= BUTOUT_ERR; } else { if (tb->mouseX == -1) setMouseX(but, tb, tb->locs[tbin_loCur].tin, tb->locs[tbin_loCur].index); tb->locs[tbin_loCur].tin = tinNum_prev(tb->locs[tbin_loCur].tin, tb); tb->locs[tbin_loCur].index = locateMouse(env->fonts[0], tb->buf + tb->tins[tb->locs[tbin_loCur]. tin].start, tb->tins[tb->locs[tbin_loCur]. tin].len, tb->mouseX, NULL); tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; need_draw = TRUE; } } else if (keysym == XK_Down) { clearMouseX = FALSE; assert(loc_valid(tb->locs[tbin_loCur], tb)); assert(loc_valid(tb->locs[tbin_hiCur], tb)); if (tinNum_next(tb->locs[tbin_hiCur].tin, tb) == tb->maxTins) { if (loc_eq(tb->locs[tbin_loCur], tb->locs[tbin_hiCur])) result |= BUTOUT_ERR; else { tb->locs[tbin_loCur] = tb->locs[tbin_hiCur]; } } else { if (tb->mouseX == -1) setMouseX(but, tb, tb->locs[tbin_hiCur].tin, tb->locs[tbin_hiCur].index); tb->locs[tbin_hiCur].tin = tinNum_next(tb->locs[tbin_hiCur].tin, tb); tb->locs[tbin_hiCur].index = locateMouse(env->fonts[0], tb->buf + tb->tins[tb->locs[tbin_hiCur].tin].start, tb->tins[tb->locs[tbin_hiCur].tin].len, tb->mouseX, NULL); tb->locs[tbin_loCur] = tb->locs[tbin_hiCur]; } need_draw = TRUE; } else if ((keysym == XK_Return) || (keysym == XK_Linefeed) || (keysym == XK_KP_Enter)) { insertResult = insert(env, "\n", tb, but->w, &changePrev); } else { result |= BUTOUT_ERR; } /* Void all mouse movement until it is pressed again. */ if (tb->clicks) { tb->clicks = 0; if (but->flags & BUT_LOCKED) but_newFlags(but, but->flags & ~BUT_LOCKED); } if (need_draw || (insertResult != insert_none)) { result |= BUTOUT_CAUGHT; if (tb->locs[tbin_loCur].tin < drawLo) drawLo = tb->locs[tbin_loCur].tin; if (tb->locs[tbin_hiCur].tin > drawHi) { drawHi = tb->locs[tbin_hiCur].tin; assert((drawHi < tb->loTinBreak) || (drawHi >= tb->hiTinBreak)); } if (changePrev && drawLo) { drawLo = tinNum_prev(drawLo, tb); } assert(drawHi >= drawLo); drawLo = tinNum_line(drawLo, tb) * butEnv_fontH(env, 0); if (insertResult == insert_cr) { drawHi = but->h; } else { assert((drawHi < tb->loTinBreak) || (drawHi >= tb->hiTinBreak)); drawHi = (tinNum_line(drawHi, tb) + 1) * butEnv_fontH(env, 0); } if (drawLo < but->h) { assert(drawHi >= drawLo); if (drawHi > but->h) { drawHi = but->h; assert(drawHi > drawLo); } butWin_redraw(but->win, but->x,but->y+drawLo, but->w,drawHi - drawLo); } } if (clearMouseX) tb->mouseX = -1; if (insertResult == insert_bad) result |= BUTOUT_ERR; checkOffWin(but, 0, FALSE); return(result); } static Insert insert(ButEnv *env, const char *src, Tbin *tb, int butW, bool *drawLo) { int i, len, loTinWidthCheck; Insert result = insert_ok; bool lineBroken, dummy; if (drawLo == NULL) drawLo = &dummy; butW -= tb->lMargin + tb->rMargin; assert(tb->loTinBreak <= tb->hiTinBreak); assert(loc_valid(tb->locs[tbin_loCur], tb)); assert(loc_valid(tb->locs[tbin_hiCur], tb)); assert(tb->maxTins == tb->numTins + tb->hiTinBreak - tb->loTinBreak); adjustBreak(tb, break_loCur, 0); assert(tb->tins[tb->locs[tbin_loCur].tin].start + tb->locs[tbin_loCur].index == tb->loBreak); assert(loc_valid(tb->locs[tbin_loCur], tb)); assert(loc_valid(tb->locs[tbin_hiCur], tb)); assert(tb->maxTins == tb->numTins + tb->hiTinBreak - tb->loTinBreak); if (!loc_eq(tb->locs[tbin_loCur], tb->locs[tbin_hiCur])) { /* * Cut out any deleted text. */ assert(loc_valid(tb->locs[tbin_mouse], tb)); assert(loc_valid(tb->locs[tbin_press], tb)); if (tb->locs[tbin_hiCur].tin != tb->locs[tbin_loCur].tin) { result = insert_cr; i = tb->locs[tbin_hiCur].tin + 1 - tb->hiTinBreak; tb->numTins -= i, tb->hiTinBreak += i; } tb->tins[tb->locs[tbin_loCur].tin].len = tb->locs[tbin_loCur].index + tb->tins[tb->locs[tbin_hiCur].tin].len - tb->locs[tbin_hiCur].index; if (tb->locs[tbin_loCur].tin == tb->locs[tbin_hiCur].tin) { tb->hiBreak += tb->locs[tbin_hiCur].index - tb->locs[tbin_loCur].index; } else tb->hiBreak = tb->tins[tb->locs[tbin_hiCur].tin].start + tb->locs[tbin_hiCur].index; tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; if (!loc_valid(tb->locs[tbin_mouse], tb)) tb->locs[tbin_mouse] = tb->locs[tbin_loCur]; if (!loc_valid(tb->locs[tbin_press], tb)) tb->locs[tbin_press] = tb->locs[tbin_loCur]; } assert(tb->tins[tb->locs[tbin_loCur].tin].start + tb->locs[tbin_loCur].index == tb->loBreak); assert(tb->loTinBreak <= tb->hiTinBreak); assert(tb->maxTins == tb->numTins + tb->hiTinBreak - tb->loTinBreak); if (src == NULL) { adjustBreak(tb, break_eoLoCur, 0); return(insert_bad); } len = strlen(src); /* * We must use <= in this next condition because we may add an extra \n to * the buffer at the end. */ while (tb->hiBreak - tb->loBreak <= len) { addMoreBufferSpace(tb); } assert(tb->tins[tb->locs[tbin_loCur].tin].start >= 0); loTinWidthCheck = tinNum_line(tb->locs[tbin_loCur].tin, tb); for (i = 0; i < len; ++i) { assert(tb->loTinBreak <= tb->hiTinBreak); assert(tb->tins[tb->locs[tbin_loCur].tin].start + tb->locs[tbin_loCur].index == tb->loBreak); tb->buf[tb->loBreak++] = src[i]; if (src[i] == '\n') { /* * If the only line left is the mandatory blank line at the end, then * don't bother inserting the final '\n'. */ if ((i + 1 == len) && (tinNum_next(tb->locs[tbin_loCur].tin, tb) == tinNum_prev(tb->maxTins, tb)) && (tb->locs[tbin_loCur].index == tb->tins[tb->locs[tbin_loCur].tin].len)) { --tb->loBreak; tb->locs[tbin_loCur].tin = tinNum_next(tb->locs[tbin_loCur].tin, tb); tb->locs[tbin_loCur].index = 0; break; } result = insert_cr; if (tb->numTins == tb->maxTins) addMoreTins(tb); tb->tins[tb->locs[tbin_loCur].tin + 1].start = tb->loBreak; tb->tins[tb->locs[tbin_loCur].tin + 1].len = tb->tins[tb->locs[tbin_loCur].tin].len - tb->locs[tbin_loCur].index; tb->tins[tb->locs[tbin_loCur].tin].len = tb->locs[tbin_loCur].index; ++tb->numTins; ++tb->loTinBreak; ++tb->locs[tbin_loCur].tin; tb->locs[tbin_loCur].index = 0; } else { ++tb->locs[tbin_loCur].index; ++tb->tins[tb->locs[tbin_loCur].tin].len; } } assert(tb->tins[tb->locs[tbin_loCur].tin].start >= 0); assert(tb->maxTins == tb->numTins + tb->hiTinBreak - tb->loTinBreak); if ((tb->hiBreak == tb->bufLen) && (tb->tins[tb->loTinBreak - 1].len > 0) && !tb->readOnly) { /* * Add an extra '\n' to make sure that there's always a blank line at * the end of the buffer. */ tb->buf[tb->loBreak++] = '\n'; result = insert_cr; if (tb->numTins == tb->maxTins) addMoreTins(tb); assert(tb->tins[tb->locs[tbin_loCur].tin].start >= 0); tb->tins[tb->locs[tbin_loCur].tin + 1].start = tb->loBreak; tb->tins[tb->locs[tbin_loCur].tin + 1].len = 0; tb->tins[tb->locs[tbin_loCur].tin + 1].width = 0; ++tb->numTins; ++tb->loTinBreak; } tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; adjustBreak(tb, break_eoLoCur, 0); assert(loc_valid(tb->locs[tbin_loCur], tb)); assert(loc_valid(tb->locs[tbin_hiCur], tb)); assert(tb->maxTins == tb->numTins + tb->hiTinBreak - tb->loTinBreak); assert(tb->hiBreak <= tb->bufLen); assert(tb->loBreak <= tb->bufLen); assert(tb->hiBreak >= 0); assert(tb->loBreak >= 0); assert(tb->tins[tb->locs[tbin_loCur].tin].start >= 0); /* * Now that the text is inserted, it is time to adjust the EOLs if we have * to. */ tryJoinLines(tb, tinNum_line2TinNum(loTinWidthCheck, tb), env, butW); lineBroken = TRUE; for (i = tinNum_line2TinNum(loTinWidthCheck, tb); (i < tb->maxTins) && ((i <= tb->locs[tbin_loCur].tin) || lineBroken); i = tinNum_next(i, tb)) { if (calcTinWidth(&tb->tins[i], tb->buf, env) > butW) { lineBroken = TRUE; breakLine(tb, i, env, butW); result = insert_cr; } } if (tryJoinLines(tb, tinNum_next(tb->locs[tbin_loCur].tin, tb), env, butW)) result = insert_cr; if ((tb->maxLines > 0) && (tb->numTins > tb->maxLines)) { killTopLines(tb, tb->numTins - tb->maxLines); } return(result); } /* * This routine attempts to join the line that you specify with the * previous line. * You cannot call this unless the current break is in the middle of neither * of these lines. It is OK to call this if the current break is in between * these lines. * The breakpoint may be changed while in this function. */ static bool tryJoinLines(Tbin *tb, int tinNum, ButEnv *env, int butW) { int prevTinNum, w, curChar; Tin *a, *b; XFontStruct *fs = env->fonts[0]; TbinLoc loc; if ((tinNum == 0) || (tinNum == tb->maxTins)) return(FALSE); prevTinNum = tinNum_prev(tinNum, tb); a = &tb->tins[prevTinNum]; b = &tb->tins[tinNum]; if (tinNum == tb->hiTinBreak) { if (b->start != tb->hiBreak) return(FALSE); } else { if (b->start != a->start + a->len) return(FALSE); } w = a->width; curChar = a->len - 1; while ((curChar >= 0) && (tb->buf[a->start + curChar] == ' ')) { --curChar; if (fs->per_char == NULL) w += fs->min_bounds.width; else w += fs->per_char[(uchar)tb->buf[a->start + curChar] - fs->min_char_or_byte2].width; } curChar = 0; while ((curChar < b->len) && (w <= butW)) { if (fs->per_char == NULL) w += fs->min_bounds.width; else w += fs->per_char[(uchar)tb->buf[b->start + curChar] - fs->min_char_or_byte2].width; ++curChar; } if (w > butW) { if (curChar) { --curChar; while (curChar && (tb->buf[b->start + curChar] != ' ')) --curChar; while ((curChar < b->len) && (tb->buf[b->start + curChar] == ' ')) ++curChar; } } if (!curChar) return(FALSE); if (curChar == b->len) { /* We can suck the whole damn line up. */ adjustBreak(tb, break_eol, tinNum); tinNum = tb->loTinBreak - 1; tbinLoc_iter(loc) { if (tb->locs[loc].tin == tinNum) { tb->locs[loc].index += tb->tins[tinNum - 1].len; --tb->locs[loc].tin; } } tb->tins[tinNum - 1].len += tb->tins[tinNum].len; calcTinWidth(&tb->tins[tinNum - 1], tb->buf, env); --tb->numTins; --tb->loTinBreak; assert((tb->loTinBreak == 0) || (tb->tins[tb->loTinBreak - 1].start < tb->loBreak)); } else { tbinLoc_iter(loc) { if (tb->locs[loc].tin == tinNum) { tb->locs[loc].index -= curChar; if (tb->locs[loc].index <= 0) { tb->locs[loc].tin = prevTinNum; tb->locs[loc].index += a->len + curChar; } } } a->len += curChar; b->len -= curChar; b->start += curChar; if (tb->hiTinBreak == tinNum) { adjustBreak(tb, break_eol, prevTinNum); calcTinWidth(&tb->tins[tb->loTinBreak - 1], tb->buf, env); calcTinWidth(&tb->tins[tb->hiTinBreak], tb->buf, env); } assert((tb->loTinBreak == 0) || (tb->tins[tb->loTinBreak - 1].start < tb->loBreak)); } return(TRUE); } static void breakLine(Tbin *tb, int tinNum, ButEnv *env, int butW) { XFontStruct *fs = env->fonts[0]; int breakPoint, w; TbinLoc loc; assert(tinNum < tb->maxTins); assert((tinNum < tb->loTinBreak) || (tinNum >= tb->hiTinBreak)); if (butW <= 0) { return; } assert(loc_valid(tb->locs[tbin_loCur], tb)); adjustBreak(tb, break_eol, tinNum); /* * I really should make my mark into a loc, but I'll cheese out instead. */ tinNum = tb->loTinBreak - 1; assert(loc_valid(tb->locs[tbin_loCur], tb)); breakPoint = tb->tins[tinNum].len; w = tb->tins[tinNum].width; assert(w > butW); while (tb->buf[tb->tins[tinNum].start + breakPoint - 1] == ' ') { --breakPoint; assert(breakPoint > 0); } while (breakPoint > 0) { if ((tb->buf[tb->tins[tinNum].start + breakPoint] == ' ') && (tb->buf[tb->tins[tinNum].start + breakPoint - 1] != ' ') && (w <= butW)) break; --breakPoint; if (fs->per_char == NULL) w -= fs->min_bounds.width; else w -= fs->per_char[(uchar)tb->buf[tb->tins[tinNum].start + breakPoint] - fs->min_char_or_byte2].width; } if (breakPoint == 0) { adjustBreak(tb, break_eoLoCur, 0); return; } while (tb->buf[tb->tins[tinNum].start + breakPoint] == ' ') ++breakPoint; if (tb->numTins == tb->maxTins) addMoreTins(tb); assert(tb->loTinBreak == tinNum + 1); if ((tb->hiTinBreak < tb->maxTins) && (tb->tins[tb->hiTinBreak].start == tb->hiBreak)) { /* * There is no '\n' here, so we can just shuffle the too-long characters * down to the next line. */ tb->tins[tb->hiTinBreak].len += tb->tins[tinNum].len - breakPoint; tb->tins[tb->hiTinBreak].start = tb->tins[tinNum].start + breakPoint; tb->tins[tb->hiTinBreak].width += XTextWidth(env->fonts[0], tb->buf + tb->tins[tb->hiTinBreak].start, tb->tins[tinNum].len - breakPoint); tb->tins[tb->loTinBreak] = tb->tins[tb->hiTinBreak]; ++tb->loTinBreak; ++tb->hiTinBreak; } else { tb->tins[tinNum + 1].start = tb->tins[tinNum].start + breakPoint; tb->tins[tinNum + 1].len = tb->tins[tinNum].len - breakPoint; ++tb->loTinBreak; ++tb->numTins; } tb->tins[tinNum].len = breakPoint; tb->tins[tinNum].width = w; tbinLoc_iter(loc) { if ((tb->locs[loc].tin == tinNum) && (tb->locs[loc].index > tb->tins[tinNum].len)) { tb->locs[loc].index -= tb->tins[tinNum].len; tb->locs[loc].tin = tinNum_next(tb->locs[loc].tin, tb); } } ++tinNum; calcTinWidth(&tb->tins[tinNum], tb->buf, env); assert(loc_valid(tb->locs[tbin_loCur], tb)); adjustBreak(tb, break_eoLoCur, 0); assert(loc_valid(tb->locs[tbin_loCur], tb)); } static void ti_cursor(But *but) { Tbin *tb = but->iPacket; Tin *ti = &tb->tins[tb->locs[tbin_loCur].tin]; ButWin *win = but->win; ButEnv *env = win->env; XFontStruct *fs = env->fonts[0]; int x, y; int rw, rh; if (!loc_eq(tb->locs[tbin_loCur], tb->locs[tbin_hiCur]) || !tb->cursorVisible) return; x = but->x + XTextWidth(fs, tb->buf + ti->start, tb->locs[tbin_loCur].index) + tb->lMargin; y = but->y + tinNum_line(tb->locs[tbin_loCur].tin, tb) * (fs->ascent + fs->descent); if ((rw = (fs->ascent + fs->descent + 10) / 20) < 1) rw = 1; x -= rw/2; if (x < but->x) { rw -= but->x - x; x = but->x; } else if (x+rw > but->x + but->w) { rw = but->x + but->w - x; } rh = fs->ascent + fs->descent; if (y + rh > but->y + but->h) rh = but->y + but->h - y; if ((rw <= 0) || (rh <= 0)) return; butEnv_setXFg(env, BUT_FG); XFillRectangle(env->dpy, win->win, env->gc, x-win->xOff, y-win->yOff, rw,rh); } static void ti_redrawCursor(But *but) { Tbin *tb = but->iPacket; Tin *ti = &tb->tins[tb->locs[tbin_loCur].tin]; ButWin *win = but->win; ButEnv *env = win->env; XFontStruct *fs = env->fonts[0]; int fontH = fs->ascent + fs->descent; int x, y; int rw; if (!loc_eq(tb->locs[tbin_loCur], tb->locs[tbin_hiCur])) { return; } x = but->x + XTextWidth(fs, tb->buf + ti->start, tb->locs[tbin_loCur].index) + tb->lMargin; y = but->y + tinNum_line(tb->locs[tbin_loCur].tin, tb) * fontH; if ((rw = (fs->ascent + fs->descent + 10) / 20) < 1) rw = 1; x -= rw/2; if (x < but->x) { rw -= (but->x - x); x = but->x; } else if (x+rw > but->x + but->w) { rw = but->x + but->w - x; } if (rw <= 0) return; butWin_redraw(win, x,y, rw,fs->ascent + fs->descent); } static void cut(ButEnv *env, But *but) { Tbin *tbin = but->iPacket; int storeLen; adjustBreak(tbin, break_loCur, 0); if (tbin->locs[tbin_loCur].tin == tbin->locs[tbin_hiCur].tin) storeLen = tbin->locs[tbin_hiCur].index - tbin->locs[tbin_loCur].index; else storeLen = tbin->locs[tbin_hiCur].index + tbin->tins[tbin->locs[tbin_hiCur].tin].start - tbin->hiBreak; XStoreBytes(env->dpy, tbin->buf + tbin->hiBreak, storeLen); adjustBreak(tbin, break_eoLoCur, 0); if ((env->sReq == NULL) || ((env->sReq == sreq) && (cut_butnum == but))) XSetSelectionOwner(env->dpy, XA_PRIMARY, but->win->physWin, 0); else env->sClear(env); if (XGetSelectionOwner(env->dpy, XA_PRIMARY) == but->win->physWin) { env->sReq = sreq; env->sClear = sclear; cut_butnum = but; } } static bool sreq(ButEnv *env, XSelectionRequestEvent *xsre) { Tbin *tbin; int storeLen; if (xsre->target != XA_STRING) return(FALSE); tbin = cut_butnum->iPacket; adjustBreak(tbin, break_loCur, 0); if (tbin->locs[tbin_loCur].tin == tbin->locs[tbin_hiCur].tin) storeLen = tbin->locs[tbin_hiCur].index - tbin->locs[tbin_loCur].index; else storeLen = tbin->locs[tbin_hiCur].index + tbin->tins[tbin->locs[tbin_hiCur].tin].start - tbin->hiBreak; XChangeProperty(env->dpy, xsre->requestor, xsre->property, xsre->target, 8, PropModeReplace, tbin->buf + tbin->hiBreak, storeLen); adjustBreak(tbin, break_eoLoCur, 0); return(TRUE); } static int sclear(ButEnv *env) { Tbin *tbin = cut_butnum->iPacket; tbin->locs[tbin_hiCur] = tbin->locs[tbin_loCur]; but_draw(cut_butnum); env->sReq = NULL; env->sClear = NULL; return(0); } static void paste(ButEnv *env, But *but) { ButWin *topWin; paste_butnum = but; env->sNotify = snotify; topWin = but->win; while (topWin->parent != NULL) topWin = topWin->parent; XConvertSelection(env->dpy, XA_PRIMARY, XA_STRING, env->prop, topWin->physWin, 0); } static int snotify(ButEnv *env, XSelectionEvent *xsnot) { unsigned char *propbuf; unsigned long proplen, propleft; int blen; int pformat; Atom ptype; Tbin *tbin; char *pb2; tbin = paste_butnum->iPacket; if (xsnot->property != None) { XGetWindowProperty(env->dpy, xsnot->requestor, xsnot->property, 0, MAX_PASTE, True, AnyPropertyType, &ptype, &pformat, &proplen, &propleft, &propbuf); tbin->locs[tbin_loCur] = tbin->locs[tbin_hiCur] = tbin->locs[tbin_mouse]; if (insert(env, (char *)propbuf, tbin, paste_butnum->w, NULL) != insert_bad) but_draw(paste_butnum); else XBell(env->dpy, 0); XFree(propbuf); } else { tbin->locs[tbin_loCur] = tbin->locs[tbin_hiCur] = tbin->locs[tbin_mouse]; propbuf = (unsigned char *)XFetchBytes(env->dpy, &blen); if (blen > 0) { pb2 = (char *)wms_malloc(blen + 1); pb2[blen] = '\0'; memcpy(pb2, propbuf, blen); XFree(propbuf); if (insert(env, pb2, tbin, paste_butnum->w, NULL)) but_draw(paste_butnum); else XBell(env->dpy, 0); wms_free(pb2); } else XBell(env->dpy, 0); } env->sNotify = NULL; return(0); } /* * This adjusts your loc and your cutEnd for when you're in word select mode. */ static void wordsel_adjust(Tbin *tbin) { char *atp, *btp; int a, b, at, bt; a = tbin->locs[tbin_loCur].index; at = tbin->locs[tbin_loCur].tin; b = tbin->locs[tbin_hiCur].index; bt = tbin->locs[tbin_hiCur].tin; if ((at >= 0) && (at < tbin->numTins)) atp = tbin->buf + tbin->tins[at].start; else atp = NULL; if ((bt >= 0) && (bt < tbin->numTins)) btp = tbin->buf + tbin->tins[bt].start; else btp = NULL; if (atp) { for (;;) { if (a <= 0) { a = 0; break; } if (((isalnum(atp[a]) || (atp[a] == '_')) && (isalnum(atp[a-1]) || (atp[a-1] == '_'))) || (atp[a] == atp[a-1]) || (isdigit(atp[a]) && (atp[a-1] == '.') && (a >= 2) && isdigit(atp[a-2])) || (isdigit(atp[a+1]) && (atp[a] == '.') && isdigit(atp[a-1]))) --a; else break; } } if (btp && (b > 0)) { for (;;) { if (b >= tbin->tins[bt].len) { b = tbin->tins[bt].len; break; } if (((isalnum(btp[b-1]) || (btp[b-1] == '_')) && (isalnum(btp[b]) || (btp[b] == '_'))) || (btp[b-1] == btp[b]) || (isdigit(btp[b-1]) && (btp[b] == '.') && isdigit(btp[b+1])) || ((b >= 2) && isdigit(btp[b-2]) && (btp[b-1] == '.') && isdigit(btp[b]))) ++b; else break; } } tbin->locs[tbin_loCur].index = a; tbin->locs[tbin_hiCur].index = b; } /* Returns the index of the character just to the right of the cursor. */ static int locateMouse(XFontStruct *fs, const char *text, int textLen, int x, bool *rightSide) { int i; int prev_x = x; int spaceWidth; bool dummy; if (rightSide == NULL) rightSide = &dummy; for (i = 0; (x > 0) && (i < textLen); ++i) { prev_x = x; if (fs->per_char == NULL) /* Monospace font. */ x -= fs->min_bounds.width; else x -= fs->per_char[(uchar)text[i] - fs->min_char_or_byte2].width; } if (fs->per_char == NULL) spaceWidth = fs->min_bounds.width; else spaceWidth = fs->per_char[' ' - fs->min_char_or_byte2].width; if (x >= spaceWidth) *rightSide = TRUE; else if ((*rightSide = ((i > 0) && (x < 0) && (prev_x < -x)))) --i; return(i); } static void flags(But *but, uint flags) { Tbin *tb = but->iPacket; if ((but->flags & BUT_KEYED) != (flags & BUT_KEYED)) { if (flags & BUT_KEYED) { enableCTimer(but); tb->cursorVisible = TRUE; } else { tb->cursorVisible = FALSE; disableCTimer(but); } } assert((but->flags & BUT_PRESSABLE) || !(but->flags & BUT_KEYED)); but->flags = flags; but_draw(but); } static ButOut blinkCursor(ButTimer *timer) { But *but = butTimer_packet(timer); Tbin *tb = but->iPacket; tb->cursorVisible = !(butTimer_ticks(timer) & 1); ti_redrawCursor(but); return(0); } static void enableCTimer(But *but) { Tbin *tb = but->iPacket; struct timeval halfSec; assert(tb->cTimer == NULL); halfSec.tv_sec = 0; halfSec.tv_usec = 500000; tb->cTimer = butTimer_create(but, but, halfSec, halfSec, TRUE, blinkCursor); } static void disableCTimer(But *but) { Tbin *tb = but->iPacket; if (tb->cTimer != NULL) { butTimer_destroy(tb->cTimer); tb->cTimer = NULL; } } void butTbin_set(But *but, const char *newStr) { Tbin *tb = but->iPacket; assert(MAGIC(but)); assert(but->action == &action); if (but->flags & BUT_KEYED) but_setFlags(but, BUT_NOKEY); tb->numTins = 1; tb->loTinBreak = 1; tb->hiTinBreak = tb->maxTins; tb->locs[tbin_loCur].index = 0; tb->locs[tbin_loCur].tin = 0; tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; tb->tins[0].len = 0; tb->tins[0].start = 0; tb->loBreak = 0; tb->hiBreak = tb->bufLen; insert(but->win->env, newStr, tb, but->w, NULL); but_draw(but); } static int calcTinNum(But *but, Tbin *tbin, int y) { int n; if (y < but->y) return(0); n = (y - but->y) / butEnv_fontH(but->win->env, 0); if (n >= tbin->loTinBreak) n += tbin->hiTinBreak - tbin->loTinBreak; if (n >= tbin->maxTins) n = tinNum_prev(tbin->maxTins, tbin); return(n); } static void setMouseX(But *but, Tbin *tbin, int tin, int loc) { assert((tin >= 0) && (tin < tbin->maxTins)); assert((loc >= 0) && (loc <= tbin->tins[tin].len)); tbin->mouseX = XTextWidth(but->win->env->fonts[0], tbin->buf + tbin->tins[tin].start, loc); } static void checkOffWin(But *but, int mouseY, bool force) { ButWin *win = but->win; Tbin *tbin = but->iPacket; int y, h, cy, ch, maxCy, loLineNum, hiLineNum; assert(MAGIC(but)); assert(MAGIC(tbin)); assert(tbin->maxTins == tbin->numTins + tbin->hiTinBreak - tbin->loTinBreak); assert(loc_valid(tbin->locs[tbin_loCur], tbin)); assert(loc_valid(tbin->locs[tbin_hiCur], tbin)); if (!loc_eq(tbin->locs[tbin_loCur], tbin->locs[tbin_hiCur]) && !tbin->clicks) { /* * The text is selected, but no mouse is moving around. Don't scroll * around! * Perhaps we should move around in this case if text is inserted or * something. Tough call, but probably we shouldn't since inserting * text will (of necessity) move around the cutEnd and the loc. */ return; } if (tbin->offWinCallback) { y = win->yOff; h = win->h; ch = butEnv_fontH(win->env, 0); if (tbin->clicks) { assert(loc_valid(tbin->locs[tbin_mouse], tbin)); cy = loLineNum = tinNum_line(tbin->locs[tbin_mouse].tin, tbin); hiLineNum = tinNum_line(tbin->locs[tbin_press].tin, tbin); } else { cy = loLineNum = hiLineNum = tinNum_line(tbin->locs[tbin_loCur].tin, tbin); mouseY = 0; } cy = but->y + cy * ch; maxCy = tbin->numTins * ch; if (force || (cy < y) || (cy + ch > y + h) || (maxCy + ch > but->h)) { tbin->offWinCallback(but, loLineNum, hiLineNum, mouseY); } } } /** * Adjust the breakpoint of the text field. * * Parameters: * tb - The tbin being adjusted. * bType = Ony of: * break_loCur (move break to the lo cursor) * break_eoLoCur (move break to end of the line containing the lo cursor) * break_eol (move break to the end of line breakTin). * breakTin - Used in break_eol. Zero otherwise. */ static void adjustBreak(Tbin *tb, BreakType bType, int breakTin) { int newLoBreak, breakIndex = 0, newHiBreak; int origHiTinBreak, origLoTinBreak; int breakDiff; TbinLoc loc; assert(tb->hiBreak <= tb->bufLen); assert(tb->loBreak <= tb->bufLen); assert(tb->hiBreak >= 0); assert(tb->loBreak >= 0); switch(bType) { case break_loCur: assert(breakTin == 0); breakTin = tb->locs[tbin_loCur].tin; breakIndex = tb->locs[tbin_loCur].index; break; case break_eoLoCur: assert(breakTin == 0); breakTin = tb->locs[tbin_loCur].tin; breakIndex = tb->tins[tb->locs[tbin_loCur].tin].len; break; case break_eol: assert(breakTin < tb->maxTins); assert((breakTin < tb->loTinBreak) || (breakTin >= tb->hiTinBreak)); breakIndex = tb->tins[breakTin].len; break; } newLoBreak = tb->tins[breakTin].start; assert(newLoBreak >= 0); if (newLoBreak > tb->loBreak) { assert(newLoBreak >= tb->hiBreak); newLoBreak -= tb->hiBreak - tb->loBreak; } newLoBreak += breakIndex; assert(newLoBreak >= 0); assert(newLoBreak >= 0); assert(newLoBreak <= tb->loBreak + tb->bufLen - tb->hiBreak); breakDiff = tb->hiBreak - tb->loBreak; newHiBreak = newLoBreak + breakDiff; assert(newHiBreak <= tb->bufLen); if (newLoBreak < tb->loBreak) { memmove(tb->buf + newHiBreak, tb->buf + newLoBreak, tb->loBreak - newLoBreak); origHiTinBreak = tb->hiTinBreak; while (tb->loTinBreak > breakTin + 1) { --tb->loTinBreak; --tb->hiTinBreak; assert(tb->tins[tb->loTinBreak].start <= tb->loBreak); tb->tins[tb->hiTinBreak] = tb->tins[tb->loTinBreak]; tb->tins[tb->hiTinBreak].start += tb->hiBreak - tb->loBreak; if (breakTin == tb->loTinBreak) breakTin = tb->hiTinBreak; assert(tb->tins[tb->loTinBreak].start <= tb->bufLen); } assert(newLoBreak >= 0); tb->loBreak = newLoBreak; tb->hiBreak = newHiBreak; tbinLoc_iter(loc) { if ((tb->locs[loc].tin < origHiTinBreak) && (tb->locs[loc].tin >= tb->loTinBreak)) tb->locs[loc].tin += tb->hiTinBreak - tb->loTinBreak; } assert(tb->tins[tb->locs[tbin_loCur].tin].start >= 0); assert((bType != break_loCur) || (tb->tins[tb->locs[tbin_loCur].tin].start + tb->locs[tbin_loCur].index == tb->loBreak)); } else /* newLoBreak >= tb->loBreak */ { if (newLoBreak != tb->loBreak) memmove(tb->buf + tb->loBreak, tb->buf + tb->hiBreak, newLoBreak - tb->loBreak); origLoTinBreak = tb->loTinBreak; while (tb->hiTinBreak <= breakTin) { assert(tb->tins[tb->hiTinBreak].start >= tb->hiBreak); tb->tins[tb->loTinBreak] = tb->tins[tb->hiTinBreak]; tb->tins[tb->loTinBreak].start -= tb->hiBreak - tb->loBreak; if (breakTin == tb->hiTinBreak) breakTin = tb->loTinBreak; assert(tb->tins[tb->loTinBreak].start >= 0); ++tb->loTinBreak; ++tb->hiTinBreak; } assert(newLoBreak >= 0); tb->loBreak = newLoBreak; tb->hiBreak = newHiBreak; tbinLoc_iter(loc) { if ((tb->locs[loc].tin >= origLoTinBreak) && (tb->locs[loc].tin < tb->hiTinBreak)) tb->locs[loc].tin -= tb->hiTinBreak - tb->loTinBreak; } assert(tb->tins[tb->locs[tbin_loCur].tin].start >= 0); assert((bType != break_loCur) || (tb->tins[tb->locs[tbin_loCur].tin].start + tb->locs[tbin_loCur].index == tb->loBreak)); } assert(tb->hiBreak <= tb->bufLen); assert(tb->loBreak <= tb->bufLen); assert(tb->hiBreak >= 0); assert(tb->loBreak >= 0); } static void addMoreBufferSpace(Tbin *tb) { char *newBuf; int newLen, i; int newHiBreak; newLen = tb->bufLen * 2; newBuf = wms_malloc(newLen); newHiBreak = tb->hiBreak + newLen - tb->bufLen; memcpy(newBuf, tb->buf, tb->loBreak); memcpy(newBuf + newHiBreak, tb->buf + tb->hiBreak, newLen - newHiBreak); for (i = tb->hiTinBreak; i < tb->maxTins; ++i) { tb->tins[i].start += newLen - tb->bufLen; } wms_free(tb->buf); tb->buf = newBuf; tb->hiBreak = newHiBreak; tb->bufLen = newLen; } static void addMoreTins(Tbin *tb) { Tin *newTins; int newMaxTins, i; int newHiBreak, tinDiff; newMaxTins = tb->maxTins * 2; newTins = wms_malloc(newMaxTins * sizeof(Tin)); newHiBreak = tb->hiTinBreak + newMaxTins - tb->maxTins; for (i = 0; i < tb->loTinBreak; ++i) { newTins[i] = tb->tins[i]; } tinDiff = newMaxTins - tb->maxTins; for (i = tb->hiTinBreak; i < tb->maxTins; ++i) { newTins[i + tinDiff] = tb->tins[i]; } if (tb->locs[tbin_mouse].tin >= tb->loTinBreak) tb->locs[tbin_mouse].tin += tinDiff; if (tb->locs[tbin_press].tin >= tb->loTinBreak) tb->locs[tbin_press].tin += tinDiff; if (tb->locs[tbin_loCur].tin >= tb->loTinBreak) tb->locs[tbin_loCur].tin += tinDiff; if (tb->locs[tbin_hiCur].tin >= tb->loTinBreak) tb->locs[tbin_hiCur].tin += tinDiff; wms_free(tb->tins); tb->tins = newTins; tb->hiTinBreak = newHiBreak; tb->maxTins = newMaxTins; } static int calcTinWidth(Tin *tin, const char *buf, ButEnv *env) { int textLen; textLen = tin->len; while ((textLen > 0) && (buf[tin->start + textLen - 1] == ' ')) --textLen; tin->width = XTextWidth(env->fonts[0], buf + tin->start, textLen); return(tin->width); } static bool resize(But *but, int oldX, int oldY, int oldW, int oldH) { Tbin *tb; int newW, i; if (oldW != but->w) { tb = but->iPacket; newW = but->w - (tb->rMargin + tb->lMargin); for (i = 0; i < tb->maxTins; i = tinNum_next(i, tb)) { if (tb->tins[i].width > newW) breakLine(tb, i, but->win->env, newW); } return(TRUE); } else return((but->x != oldX) || (but->y != oldY) || (but->h != oldH)); } static void killTopLines(Tbin *tb, int lines) { int charsDead, i; TbinLoc loc; assert(lines < tb->numTins); adjustBreak(tb, break_eol, tinNum_prev(tb->maxTins, tb)); charsDead = tb->tins[lines].start; memmove(tb->buf, tb->buf + charsDead, tb->loBreak - charsDead); tb->loBreak -= charsDead; tb->numTins -= lines; tb->loTinBreak -= lines; for (i = 0; i < tb->loTinBreak; ++i) { tb->tins[i].start = tb->tins[i + lines].start - charsDead; tb->tins[i].len = tb->tins[i + lines].len; tb->tins[i].width = tb->tins[i + lines].width; } tbinLoc_iter(loc) { tb->locs[loc].tin -= lines; if (tb->locs[loc].tin < 0) { tb->locs[loc].tin = 0; tb->locs[loc].index = 0; } } } void butTbin_insert(But *but, const char *appText) { bool saveOldCurs; Tbin *tb; assert(MAGIC(but)); tb = but->iPacket; assert(MAGIC(tb)); saveOldCurs = (!loc_eq(tb->locs[tbin_loCur], tb->locs[tbin_hiCur]) || (tinNum_next(tb->locs[tbin_loCur].tin, tb) != tb->maxTins)); if (saveOldCurs) { tb->locs[tbin_mouse] = tb->locs[tbin_loCur]; tb->locs[tbin_press] = tb->locs[tbin_hiCur]; tb->locs[tbin_loCur].tin = tinNum_prev(tb->maxTins, tb); tb->locs[tbin_loCur].index = tb->tins[tb->locs[tbin_loCur].tin].len; tb->locs[tbin_hiCur] = tb->locs[tbin_loCur]; } insert(but->win->env, appText, tb, but->w - (tb->lMargin + tb->rMargin), NULL); checkOffWin(but, 0, TRUE); if (saveOldCurs && !loc_eq(tb->locs[tbin_mouse], tb->locs[tbin_press])) { tb->locs[tbin_loCur] = tb->locs[tbin_mouse]; tb->locs[tbin_hiCur] = tb->locs[tbin_press]; } but_draw(but); } int butTbin_len(But *but) { Tbin *tb; assert(MAGIC(but)); tb = but->iPacket; assert(MAGIC(tb)); return(tb->bufLen - (tb->hiBreak - tb->loBreak)); } void butTbin_setMaxLines(But *but, int maxLines) { Tbin *tb = but->iPacket; assert(MAGIC(tb)); tb->maxLines = maxLines; } void butTbin_setReadOnly(But *but, bool ro) { Tbin *tb = but->iPacket; assert(MAGIC(tb)); tb->readOnly = ro; } void butTbin_delete(But *but, int delStart, int delLen) { Tbin *tb = but->iPacket; assert(but->action == &action); assert(MAGIC(tb)); tb->locs[tbin_mouse] = tb->locs[tbin_loCur]; tb->locs[tbin_press] = tb->locs[tbin_hiCur]; setLoc(tb, tbin_loCur, delStart); setLoc(tb, tbin_hiCur, delStart + delLen); insert(but->win->env, "", tb, but->w, NULL); tb->locs[tbin_loCur] = tb->locs[tbin_mouse]; tb->locs[tbin_hiCur] = tb->locs[tbin_press]; } static void setLoc(Tbin *tb, TbinLoc locNum, int position) { Loc *l = &tb->locs[locNum]; int i; if (position > tb->loBreak) position += (tb->hiBreak - tb->loBreak); i = 0; while (tb->tins[i].start + tb->tins[i].len < position) { i = tinNum_next(i, tb); assert(i < tb->maxTins); } l->tin = i; l->index = position - tb->tins[i].start; } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/tblock.c0000664000671000067100000002430607043224472013035 /* * wmslib/src/but/tblock.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #include #include #include /********************************************************************** * Data Types **********************************************************************/ typedef struct Word_struct { int start, len, xoff, yoff, w; } Word; typedef struct { char *str; int nwords; Word *words; ButTextAlign align; int font; int setup_w; } Tb; /********************************************************************** * Forward Declarations **********************************************************************/ static void draw(But *but, int x,int y, int w,int h); static ButOut destroy(But *but); /********************************************************************** * Globals **********************************************************************/ static const ButAction action = { NULL,NULL,NULL,NULL, NULL,NULL, draw, destroy, but_flags, NULL}; /********************************************************************** * Functions **********************************************************************/ But *butTblock_create(ButWin *win, int layer, int flags, const char *text, ButTextAlign align) { But *but; Tb *tb; assert(MAGIC(win)); assert(MAGIC(&win->butsNoDraw)); tb = wms_malloc(sizeof(Tb)); but = but_create(win, tb, &action); but->layer = layer; but->flags = flags; tb->str = NULL; tb->nwords = 0; tb->words = NULL; tb->align = align; tb->font = 0; tb->setup_w = 0; but_init(but); if (text != NULL) butTblock_setText(but, text); return(but); } void butTblock_setFont(But *but, int fontnum) { Tb *tb = but->iPacket; assert(but->action == &action); tb->font = fontnum; but_draw(but); } int butTblock_getH(But *but) { Tb *tb = but->iPacket; int fonth; assert(but->action == &action); fonth = but->win->env->fonts[tb->font]->ascent + but->win->env->fonts[tb->font]->descent; if (tb->nwords == 0) return(fonth); else return(tb->words[tb->nwords - 1].yoff + fonth); } const char *butTblock_getText(But *but) { Tb *tb; assert(but->action == &action); tb = but->iPacket; return(tb->str); } void butTblock_setText(But *but, const char *text) { Tb *tb = but->iPacket; ButEnv *env = but->win->env; int w = tb->setup_w = but->w, txtH; int len, numLines, wordNum, totalWidth, i, j; int lastSpaceSeen, spacesAtLastSpace, spacesThisLine; int widthAtLastSpace, widthNonSpace, widthOfCurrentChar; int widthNonSpaceAtLastSpace; bool nonSpaceSeen, prevCharWasSpace; Word *words; int *widths; int wordWMax, wordWMin; assert(but->action == &action); txtH = env->fonts[tb->font]->ascent + env->fonts[tb->font]->descent; if (text != NULL) { len = strlen(text); if (tb->str != NULL) wms_free(tb->str); tb->str = wms_malloc((len + 1) * sizeof(char)); strcpy(tb->str, text); } if (w == 0) return; text = tb->str; len = strlen(text); if (tb->words != NULL) wms_free(tb->words); if (text == NULL) { tb->words = NULL; return; } tb->nwords = strlen(tb->str); if (tb->nwords == 0) return; tb->words = words = wms_malloc(tb->nwords * sizeof(Word)); widths = wms_malloc(len * sizeof(int)); words[0].start = 0; words[0].xoff = 0; words[0].yoff = 0; words[0].w = 0; wordNum = totalWidth = widthNonSpace = 0; widthAtLastSpace = 0; spacesAtLastSpace = 0; widthNonSpaceAtLastSpace = 0; wordWMax = wordWMin = 0; numLines = 1; spacesThisLine = lastSpaceSeen = 0; nonSpaceSeen = prevCharWasSpace = FALSE; for (i = 0; i < len; ++i) { widthOfCurrentChar = butEnv_charWidth(env, tb->str+i, tb->font); assert(widthOfCurrentChar > 0); widths[i] = widthOfCurrentChar; if (tb->str[i] == ' ') { if (!prevCharWasSpace) { lastSpaceSeen = i; widthAtLastSpace = totalWidth; widthNonSpaceAtLastSpace = widthNonSpace; spacesAtLastSpace = spacesThisLine; } if (nonSpaceSeen) ++spacesThisLine; else widthNonSpace += widthOfCurrentChar; prevCharWasSpace = TRUE; } else { if ((uchar)tb->str[i] < BUTWRITE_MINPRINT) { ++i; widths[i] = 0; } nonSpaceSeen = TRUE; prevCharWasSpace = FALSE; widthNonSpace += widthOfCurrentChar; } totalWidth += widthOfCurrentChar; if (totalWidth > w) { if (lastSpaceSeen != words[wordNum].start) i = lastSpaceSeen; words[wordNum].len = i - words[wordNum].start; switch(tb->align) { case butText_center: words[wordNum].xoff += (w - widthAtLastSpace) / 2; words[wordNum].w = widthAtLastSpace; break; case butText_right: words[wordNum].xoff += (w - widthAtLastSpace); words[wordNum].w = widthAtLastSpace; break; case butText_just: widthNonSpace = widthNonSpaceAtLastSpace; totalWidth = 0; j = words[wordNum].start; nonSpaceSeen = FALSE; while (spacesAtLastSpace > 0) { assert(j <= i); if ((tb->str[j] == ' ') && nonSpaceSeen) { widthOfCurrentChar = (w - widthNonSpace + spacesAtLastSpace/2) / spacesAtLastSpace; --spacesAtLastSpace; widthNonSpace += widthOfCurrentChar; totalWidth += widthOfCurrentChar; if (tb->str[j - 1] != ' ') { words[wordNum].len = j - words[wordNum].start; assert(words[wordNum].w > 0); assert(words[wordNum].w < w); ++wordNum; } if (tb->str[j + 1] != ' ') { assert(totalWidth < w); words[wordNum].start = j + 1; words[wordNum].xoff = totalWidth; words[wordNum].yoff = txtH * (numLines - 1); words[wordNum].w = 0; } } else { if (tb->str[j] != ' ') nonSpaceSeen = TRUE; totalWidth += widths[j]; words[wordNum].w += widths[j]; if ((uchar)tb->str[j] < BUTWRITE_MINPRINT) ++j; } ++j; } words[wordNum].len = i - tb->words[wordNum].start; while ((tb->str[j] != ' ') && (tb->str[j] != '\0')) words[wordNum].w += widths[j++]; break; case butText_left: words[wordNum].w = widthAtLastSpace; break; } ++wordNum; while (tb->str[i] == ' ') { ++i; widths[i] = butEnv_charWidth(env, tb->str+i, tb->font); } lastSpaceSeen = i; widthNonSpace = totalWidth = widths[i]; spacesThisLine = 0; nonSpaceSeen = TRUE; prevCharWasSpace = FALSE; words[wordNum].start = i; words[wordNum].xoff = 0; words[wordNum].yoff = txtH * numLines; words[wordNum].w = 0; ++numLines; /* * If this was a special character then step over it's second byte. */ if ((uchar)tb->str[i] < BUTWRITE_MINPRINT) { ++i; widths[i] = 0; } } } words[wordNum].len = i - words[wordNum].start; if (tb->align == butText_center) words[wordNum].xoff += (w - totalWidth) / 2; else if (tb->align == butText_right) words[wordNum].xoff += (w - totalWidth); words[wordNum].w = totalWidth; tb->nwords = wordNum + 1; /* We probably allocated way too many words, so allocate a new block * of exactly the right size and move to it. */ words = wms_malloc(tb->nwords * sizeof(Word)); memcpy(words, tb->words, tb->nwords * sizeof(Word)); for (i = 0; i < tb->nwords; ++i) { words[i].w = 0; for (j = words[i].start; j < words[i].start+words[i].len; ++j) words[i].w += widths[j]; } wms_free(widths); wms_free(tb->words); tb->words = words; } /* Returns the height of the text block after being resized. */ int butTblock_resize(But *but, int x, int y, int w) { int old_w = but->w, h; assert(MAGIC(but)); assert(but->action == &action); but->w = w; butTblock_setText(but, NULL); but->w = old_w; but_resize(but, x, y, w, h = butTblock_getH(but)); return(h); } static ButOut destroy(But *but) { Tb *tb = but->iPacket; if (tb->str != NULL) wms_free(tb->str); if (tb->words != NULL) wms_free(tb->words); wms_free(tb); return(0); } static void draw(But *but, int dx, int dy, int dw, int dh) { Tb *tb = but->iPacket; ButEnv *env = but->win->env; int i, x, y; char temp; int fonth; if (but->w != tb->setup_w) butTblock_setText(but, NULL); fonth = env->fonts[tb->font]->ascent + env->fonts[tb->font]->descent; butEnv_setXFg(env, BUT_FG); x = but->x; y = but->y; for (i = 0; i < tb->nwords; ++i) { assert((tb->words[i].xoff >= 0) && (tb->words[i].xoff < but->w) && (tb->words[i].yoff >= 0) && (tb->words[i].yoff < but->h)); assert((tb->words[i].w > 0) && (tb->words[i].w <= but->w)); if ((x+tb->words[i].xoff < dx+dw) && (y+tb->words[i].yoff < dy+dh) && (x+tb->words[i].xoff + tb->words[i].w >= dx) && (y+tb->words[i].yoff + fonth >= dy)) { temp = tb->str[tb->words[i].start + tb->words[i].len]; tb->str[tb->words[i].start + tb->words[i].len] = '\0'; butWin_write(but->win, x+tb->words[i].xoff, y+tb->words[i].yoff, tb->str+tb->words[i].start, tb->font); tb->str[tb->words[i].start + tb->words[i].len] = temp; } } } int butTblock_guessH(ButEnv *env, const char *text, int w, int fontNum) { int curW = 0, curH; int wLastSpace = 0; int fontH; int i; fontH = butEnv_fontH(env, fontNum); curH = fontH; for (i = 0; text[i]; ++i) { if (text[i] == ' ') { curW += butEnv_charWidth(env, text+i, fontNum); wLastSpace = curW; if (curW >= w) { while (i+1 == ' ') ++i; curH += fontH; wLastSpace = curW = 0; } } else { curW += butEnv_charWidth(env, text+i, fontNum); if (text[i] <= '\2') ++i; if (curW > w) { curH += fontH; if (wLastSpace) { curW -= wLastSpace; wLastSpace = 0; } else { /* No spaces, break the word in half. */ curW = butEnv_charWidth(env, text+i, fontNum); } } } } return(curH); } #endif cgoban-1.9.14/wmslib/src/but/text.c0000664000671000067100000000771007043224472012543 /* * wmslib/src/but/text.c, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #include /********************************************************************** * Data Structures **********************************************************************/ typedef struct Txt_struct { Str text; ButTextAlign align; int font; int color; bool stipple; } Txt; /********************************************************************** * Forward Declarations **********************************************************************/ static void draw(But *but, int x,int y, int w,int h); static ButOut destroy(But *but); /********************************************************************** * Globals **********************************************************************/ static const ButAction action = { NULL,NULL,NULL,NULL, NULL,NULL, draw, destroy, but_flags, NULL}; /********************************************************************** * Functions **********************************************************************/ But *butText_create(ButWin *win, int layer, int flags, const char *text, ButTextAlign align) { But *but; Txt *t; t = wms_malloc(sizeof(Txt)); but = but_create(win, t, &action); but->layer = layer; but->flags = flags; str_init(&t->text); t->align = align; t->font = 0; t->color = BUT_FG; t->stipple = FALSE; but_init(but); if (text != NULL) butText_set(but, text); return(but); } void butText_set(But *but, const char *text) { Txt *t = but->iPacket; assert(but->action == &action); if (text == NULL) text = ""; str_copyChars(&t->text, text); but_draw(but); } void butText_setFont(But *but, int fontnum) { Txt *t = but->iPacket; assert(but->action == &action); t->font = fontnum; but_draw(but); } void butText_setColor(But *but, int color, bool stipple) { Txt *t = but->iPacket; if (color == BUT_NOCHANGE) color = t->color; if ((color != t->color) || (stipple != t->stipple)) { t->color = color; t->stipple = stipple; but_draw(but); } } static ButOut destroy(But *but) { Txt *t = but->iPacket; str_deinit(&t->text); return(0); } static void draw(But *but, int x,int y, int w,int h) { Txt *t = but->iPacket; ButEnv *env = but->win->env; XFontStruct *fs = env->fonts[t->font]; int th; const char *text = str_chars(&t->text); if (t->stipple) { XSetFillStyle(env->dpy, env->gc, FillStippled); XSetForeground(env->dpy, env->gc, env->colors[t->color]); } else { butEnv_setXFg(env, t->color); } x = but->x; if (t->align == butText_center) x += (but->w - butEnv_textWidth(env, text, t->font)) / 2; else if (t->align == butText_right) x += (but->w - butEnv_textWidth(env, text, t->font)); th = fs->ascent + fs->descent; butWin_write(but->win, x, but->y + (but->h - th) / 2, text, t->font); if (t->stipple) { butEnv_stdFill(env); } } int butText_resize(But *but, int x, int y, int h) { Txt *txt = but->iPacket; int w = butEnv_textWidth(but->win->env, str_chars(&txt->text), txt->font); switch (txt->align) { case butText_left: break; case butText_center: x -= w/2; break; case butText_right: x -= w; break; default: break; } but_resize(but, x, y, w, h); return(w); } const char *butText_get(But *but) { Txt *t; assert(MAGIC(but)); assert(but->action == &action); t = but->iPacket; return(str_chars(&t->text)); } #endif cgoban-1.9.14/wmslib/src/but/textin.c0000664000671000067100000007255507043224472013103 /* * wmslib/src/but/textin.c, part of wmslib (Library functions) * Copyright (C) 1994-1997 William Shubert. * See "configure.h.in" for more copyright information. */ /* * I don't really like this button. * It is slower than it has to be (this may or may not matter). */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include #include #include /********************************************************************** * Data Types **********************************************************************/ typedef struct SpecKey_struct { struct SpecKey_struct *next; KeySym keysym; uint keyModifiers, modMask; ButOut (*callback)(But *but, KeySym keysym, uint keyModifiers, void *context); void *context; MAGIC_STRUCT } SpecKey; typedef struct Txtin_struct { ButOut (*callback)(But *but, const char *value); bool hidden; char *str, *dispStr; /* dispStr is only used if hidden is TRUE. */ int maxlen, len, loc, cutend; int mousePress, origMousePress, clicks; int xoffset; Pixmap pm; int pm_w, pm_h, slideDir, slideFreq; int but3StartMouse, but3StartXoff; bool mouseInBut, cursorVisible; ButTimer *cTimer, *sTimer; SpecKey *specKeys; MAGIC_STRUCT } Txtin; /********************************************************************** * Forward Declarations **********************************************************************/ static int locateMouse(XFontStruct *fs, char *text, int len, int x, bool *rightSide); static void ti_cursor(But *but); static void ti_redrawCursor(But *but); static ButOut mmove(But *but, int x, int y); static ButOut mleave(But *but); static ButOut mpress(But *but, int butnum, int x, int y); static ButOut mrelease(But *but, int butnum, int x, int y); static ButOut kpress(But *but, const char *keystr, KeySym sym); static void draw(But *but, int x,int y, int w,int h); static ButOut destroy(But *but); static bool insert(ButEnv *env, const char *src, Txtin *but); static void cut(ButEnv *env, char *cutstr, int cutlen, But *but); static void paste(ButEnv *env, But *but); static void enableCTimer(But *but); static void disableCTimer(But *but); static void curInView(But *but); static void textInView(But *but, bool maxInView); static bool sreq(ButEnv *env, XSelectionRequestEvent *xsre); static int sclear(ButEnv *env); static int snotify(ButEnv *env, XSelectionEvent *xsre); static void flags(But *but, uint flags); static void wordsel_adjust(Txtin *but); static void startSlide(But *but, int dir, bool fast); static ButOut slide(ButTimer *timer); /********************************************************************** * Globals **********************************************************************/ static int cutstr_maxlen = 0, cutstr_len; static char *cutdata = NULL; static But *cut_butnum = NULL; static But *paste_butnum = NULL; static const ButAction action = { mmove, mleave, mpress, mrelease, kpress, NULL, draw, destroy, flags, NULL}; /********************************************************************** * Functions **********************************************************************/ But *butTextin_create(ButOut (*callback)(But *but, const char *value), void *packet, ButWin *win, int layer, int flags, const char *text, int maxlen) { But *but; Txtin *ti; ti = wms_malloc(sizeof(Txtin)); MAGIC_SET(ti); but = but_create(win, ti, &action); but->uPacket = packet; but->layer = layer; but->flags = flags | BUT_OPAQUE; if (text == NULL) text = ""; ti->callback = callback; ti->hidden = FALSE; ti->maxlen = maxlen; ti->str = (char *)wms_malloc(ti->maxlen + 1); ti->dispStr = ti->str; ti->xoffset = 0; ti->pm_w = ti->pm_h = 0; ti->pm = None; ti->mousePress = -1; ti->mouseInBut = FALSE; strcpy(ti->str, text); ti->len = ti->loc = ti->cutend = strlen(text); ti->cTimer = NULL; if (flags & BUT_KEYED) { ti->cursorVisible = TRUE; } else ti->cursorVisible = FALSE; ti->sTimer = NULL; ti->but3StartXoff = -1; ti->specKeys = NULL; but_init(but); return(but); } const char *butTextin_get(But *but) { Txtin *ti = but->iPacket; assert(but->action == &action); assert(MAGIC(ti)); return(ti->str); } static ButOut destroy(But *but) { Txtin *ti = but->iPacket; ButEnv *env = but->win->env; SpecKey *spec, *nextSpec; assert(but->action == &action); assert(MAGIC(ti)); spec = ti->specKeys; while (spec != NULL) { assert(MAGIC(spec)); nextSpec = spec->next; MAGIC_UNSET(spec); wms_free(spec); spec = nextSpec; } if (cut_butnum == but) { if (env->sClear == sclear) env->sClear = NULL; if (env->sReq == sreq) env->sReq = NULL; cut_butnum = NULL; } if (paste_butnum == but) { if (env->sNotify == snotify) env->sNotify = NULL; paste_butnum = NULL; } if (ti->pm != None) XFreePixmap(but->win->env->dpy, ti->pm); wms_free(ti->str); if (ti->hidden) wms_free(ti->dispStr); else { assert(ti->dispStr == ti->str); } MAGIC_UNSET(ti); wms_free(ti); return(0); } static void draw(But *but, int x,int y, int w,int h) { ButWin *win = but->win; ButEnv *env = win->env; Txtin *ti = but->iPacket; int txtw; int butbw = env->stdButBw; XFontStruct *fs = env->fonts[0]; assert(but->action == &action); assert(MAGIC(ti)); XSetFont(env->dpy, env->gc2, env->fonts[0]->fid); if ((ti->pm_w != but->w - 2*butbw) || (ti->pm_h != but->h - 2*butbw)) { if (ti->pm != None) XFreePixmap(env->dpy, ti->pm); ti->pm = XCreatePixmap(env->dpy, win->win, ti->pm_w = but->w - 2*butbw, ti->pm_h = but->h - 2*butbw, DefaultDepth(env->dpy, DefaultScreen(env->dpy))); } but_drawBox(win, but->x,but->y, but->w,but->h, 1, butbw, BUT_SRIGHT|BUT_SLEFT, BUT_LIT, BUT_SHAD, None, None); txtw = XTextWidth(fs, ti->dispStr, ti->loc); butEnv_setXFg2(env, BUT_HIBG); XFillRectangle(env->dpy, ti->pm, env->gc2, 0,0, ti->pm_w,ti->pm_h); if (but->flags & BUT_PRESSABLE) butEnv_setXFg2(env, BUT_FG); else { XSetFillStyle(env->dpy, env->gc2, FillStippled); XSetForeground(env->dpy, env->gc2, env->colors[BUT_FG]); } if (ti->loc == ti->cutend) { XDrawString(env->dpy, ti->pm, env->gc2, x = butbw - ti->xoffset, y = (fs->ascent + ti->pm_h - fs->descent) / 2, ti->dispStr, ti->len); } else { int tw1, tw2; int cl1, cl2; if (ti->cutend >= ti->loc) { cl1 = ti->loc; cl2 = ti->cutend; } else { cl1 = ti->cutend; cl2 = ti->loc; } XDrawString(env->dpy, ti->pm, env->gc2, x = butbw - ti->xoffset, y = (fs->ascent + ti->pm_h - fs->descent) / 2, ti->dispStr, cl1); tw1 = XTextWidth(fs, ti->dispStr, cl1); tw2 = XTextWidth(fs, ti->dispStr + cl1, cl2 - cl1); x += tw1 + tw2; XDrawString(env->dpy, ti->pm, env->gc2, x,y, ti->dispStr + cl2, ti->len - cl2); x -= tw2; XSetBackground(env->dpy, env->gc2, env->colors[BUT_SELBG]); if (!env->colorp) { XSetTile(env->dpy, env->gc2, env->colorPmaps[BUT_WHITE]); XSetForeground(env->dpy, env->gc2, env->colors[BUT_WHITE]); } XDrawImageString(env->dpy, ti->pm, env->gc2, x,y, ti->dispStr + cl1, cl2 - cl1); } if (!(but->flags & BUT_PRESSABLE)) { butEnv_stdFill2(env); } XCopyArea(env->dpy, ti->pm, win->win, env->gc, 0,0, ti->pm_w,ti->pm_h, but->x + butbw - win->xOff, but->y + butbw - win->yOff); if ((ti->loc == ti->cutend) && ti->cursorVisible && (but->flags & BUT_PRESSABLE)) ti_cursor(but); } static ButOut mmove(But *but, int x, int y) { Txtin *ti = but->iPacket; ButWin *win = but->win; ButEnv *env = win->env; int newMousePress; bool rightSide; if (!(but->flags & BUT_PRESSABLE)) return(BUTOUT_CAUGHT); if (!ti->mouseInBut) { ti->mouseInBut = TRUE; butEnv_setCursor(env, but, butCur_text); } if (ti->mousePress != -1) { if (ti->clicks < 2) { if (x < but->x) { startSlide(but, -1, (x < but->x - but->h + env->stdButBw*2)); newMousePress = 0; } else if (x > but->x + but->w) { startSlide(but, 1, (x > but->x + but->w + but->h - env->stdButBw*2)); newMousePress = ti->len; } else { if (ti->sTimer != NULL) { butTimer_destroy(ti->sTimer); ti->sTimer = NULL; } if (y < but->y + env->stdButBw*2) newMousePress = 0; else if (y > but->y+but->h - env->stdButBw*2) newMousePress = ti->len; else newMousePress = locateMouse(env->fonts[0], ti->dispStr, ti->len, x - (but->x + 2*env->stdButBw - ti->xoffset), &rightSide); } if (ti->clicks == 1) { if (rightSide && (newMousePress >= ti->origMousePress) && (newMousePress < ti->len)) ++newMousePress; else if (!rightSide && (newMousePress <= ti->origMousePress) && (newMousePress > 0)) --newMousePress; } if (newMousePress != ti->mousePress) { ti->mousePress = ti->loc = newMousePress; if (ti->clicks == 1) { ti->cutend = ti->origMousePress; wordsel_adjust(ti); } but_draw(but); } } } if (ti->but3StartXoff != -1) { int oldXoff = ti->xoffset; ti->xoffset = ti->but3StartXoff - 10*(x - ti->but3StartMouse); textInView(but, FALSE); if (oldXoff != ti->xoffset) but_draw(but); } return(BUTOUT_CAUGHT); } static ButOut mleave(But *but) { Txtin *ti = but->iPacket; if (ti->mouseInBut) { ti->mouseInBut = FALSE; butEnv_setCursor(but->win->env, but, butCur_idle); } return(BUTOUT_CAUGHT); } static ButOut mpress(But *but, int butnum, int x, int y) { Txtin *ti = but->iPacket; ButEnv *env = but->win->env; static Time lastPressTime = -1; static int lastPressNum = -2; int rightSide; if (ti->cTimer) { butTimer_reset(ti->cTimer); ti->cursorVisible = TRUE; } switch (butnum) { case 1: /* Button 1 selects, drags, etc. */ if (ti->but3StartXoff != -1) return(BUTOUT_ERR); if (!(but->flags & BUT_KEYED)) but_newFlags(but, but->flags | BUT_KEYED); but_newFlags(but, but->flags | BUT_LOCKED); ti->mousePress = locateMouse(env->fonts[0], ti->dispStr, ti->len, x - (but->x + 2*env->stdButBw - ti->xoffset), &rightSide); ti->loc = ti->cutend = ti->origMousePress = ti->mousePress; if ((lastPressTime + BUT_DCLICK > env->eventTime) && (lastPressNum + 1 == env->eventNum)) { if (ti->clicks == 0) { /* It's a double click! */ ++ti->clicks; if (rightSide) ++ti->loc; else --ti->loc; wordsel_adjust(ti); } else if (ti->clicks == 1) { /* It's a triple click! */ ++ti->clicks; ti->loc = 0; ti->cutend = ti->len; } else { /* Quadruple click! Restart! */ ti->clicks = 0; } } else ti->clicks = 0; lastPressTime = env->eventTime; lastPressNum = env->eventNum; but_draw(but); break; case 2: /* Paste! */ ti->cutend = ti->loc = locateMouse(env->fonts[0], ti->dispStr, ti->len, x - (but->x + 2*env->stdButBw - ti->xoffset), NULL); paste(env, but); break; case 3: /* * Button 3 scrolls as if this input window was a mini-canvas. I'm not * sure how useful this is but I'm doing it anyway just to make my * interface more consistent. */ if (ti->mousePress != -1) return(BUTOUT_ERR); but_newFlags(but, but->flags | BUT_LOCKED); butEnv_setCursor(env, but, butCur_lr); ti->but3StartMouse = x; ti->but3StartXoff = ti->xoffset; break; default: /* * Weird. I don't know what to do with mice with more than 3 buttons * so I guess I might as well beep. I like beeping. */ return(BUTOUT_ERR); break; } return(BUTOUT_CAUGHT); } static ButOut mrelease(But *but, int butnum, int x, int y) { Txtin *ti = but->iPacket; char *cutstr; int cutlen; if (ti->cTimer) { butTimer_reset(ti->cTimer); ti->cursorVisible = TRUE; } if ((butnum == 1) && (ti->mousePress != -1)) { if (ti->sTimer != NULL) { butTimer_destroy(ti->sTimer); ti->sTimer = NULL; } if (ti->loc != ti->cutend) { if (ti->loc < ti->cutend) { cutstr = ti->str + ti->loc; cutlen = ti->cutend - ti->loc; } else { cutstr = ti->str + ti->cutend; cutlen = ti->loc - ti->cutend; } cut(but->win->env, cutstr, cutlen, but); } ti->mousePress = -1; but_newFlags(but, but->flags & ~BUT_LOCKED); } else if ((butnum == 3) && (ti->but3StartXoff != -1)) { butEnv_setCursor(but->win->env, but, butCur_text); ti->but3StartXoff = -1; but_newFlags(but, but->flags & ~BUT_LOCKED); } return(BUTOUT_CAUGHT); } static ButOut kpress(But *but, const char *newtext, KeySym keysym) { Txtin *ti = but->iPacket; ButEnv *env = but->win->env; bool need_draw = FALSE, needCallback = FALSE; int i; ButOut result = 0; SpecKey *spec; butTimer_reset(ti->cTimer); ti->cursorVisible = TRUE; for (spec = ti->specKeys; spec != NULL; spec = spec->next) { if ((keysym == spec->keysym) && ((env->keyModifiers & spec->modMask) == spec->keyModifiers)) { return(spec->callback(but, keysym, env->keyModifiers, spec->context) | BUTOUT_CAUGHT); } } if (((keysym >= XK_KP_Space) && (keysym <= XK_KP_9)) || ((keysym >= XK_space) && (keysym <= XK_ydiaeresis))) { need_draw = TRUE; switch(newtext[0]) { case '\001': /* Ctrl-A: Beginning of line. */ case '\020': /* Ctrl-P: Up a line. */ ti->loc = ti->cutend = 0; break; case '\002': /* Ctrl-B: Back a character. */ if (ti->loc != ti->cutend) { ti->cutend = ti->loc; } else if (ti->loc) { ti->cutend = --ti->loc; } else { need_draw = FALSE; result |= BUTOUT_ERR | BUTOUT_CAUGHT; } break; case '\004': /* Ctrl-D: Delete right. */ if (ti->loc != ti->cutend) need_draw = insert(env, "", ti); else if (ti->loc < ti->len) { for (i = ti->loc; ti->str[i]; ++i) ti->str[i] = ti->str[i+1]; --ti->len; need_draw = TRUE; } else result |= BUTOUT_ERR | BUTOUT_CAUGHT; break; case '\005': /* Ctrl-E: End of line. */ case '\016': /* Ctrl-N: Down a line. */ ti->loc = ti->cutend = ti->len; break; case '\006': /* Ctrl-F: Forward a character. */ if (ti->loc != ti->cutend) { ti->loc = ti->cutend; } else if (ti->loc < ti->len) { ti->cutend = ++ti->loc; } else { result |= BUTOUT_ERR | BUTOUT_CAUGHT; need_draw = FALSE; } break; case '\013': /* Ctrl-K: Kill to end of line. */ ti->str[ti->len = ti->loc = ti->cutend] = '\0'; break; case '\025': /* Ctrl-U: Kill from beginning of line. */ for (i = ti->loc; i < ti->len; ++i) ti->str[i - ti->loc] = ti->str[i]; ti->str[ti->len -= ti->loc] = '\0'; ti->loc = ti->cutend = 0; break; default: if (!(need_draw = insert(env, newtext, ti))) result |= BUTOUT_ERR | BUTOUT_CAUGHT; break; } } else if ((keysym >= XK_Shift_L) && (keysym <= XK_Hyper_R)) { } else if ((keysym >= XK_F1) && (keysym <= XK_F35)) { if (!(need_draw = insert(env, newtext, ti))) result |= BUTOUT_ERR | BUTOUT_CAUGHT; } else if ((keysym == XK_BackSpace) || (keysym == XK_Delete)) { if (ti->loc != ti->cutend) need_draw = insert(env, "", ti); else if (ti->loc > 0) { for (i = ti->cutend = --ti->loc; ti->str[i]; ++i) ti->str[i] = ti->str[i+1]; --ti->len; need_draw = TRUE; } else result |= BUTOUT_ERR | BUTOUT_CAUGHT; #if 0 /* People don't like it when delete works the way I like it. :-( */ } else if (keysym == XK_Delete) { if (ti->loc != ti->cutend) need_draw = insert(env, "", ti); else if (ti->loc < ti->len) { for (i = ti->loc; ti->str[i]; ++i) ti->str[i] = ti->str[i+1]; --ti->len; need_draw = TRUE; } else result |= BUTOUT_ERR | BUTOUT_CAUGHT; #endif } else if (keysym == XK_Left) { if (ti->loc != ti->cutend) { if (ti->loc < ti->cutend) ti->cutend = ti->loc; else ti->loc = ti->cutend; need_draw = TRUE; } else if (ti->loc) { ti->cutend = --ti->loc; need_draw = TRUE; } else result |= BUTOUT_ERR | BUTOUT_CAUGHT; } else if (keysym == XK_Right) { if (ti->loc != ti->cutend) { if (ti->loc > ti->cutend) ti->cutend = ti->loc; else ti->loc = ti->cutend; need_draw = TRUE; } else if (ti->loc < ti->len) { ti->cutend = ++ti->loc; need_draw = TRUE; } else result |= BUTOUT_ERR | BUTOUT_CAUGHT; } else if (keysym == XK_Up) { ti->loc = ti->cutend = 0; need_draw = TRUE; } else if (keysym == XK_Down) { ti->loc = ti->cutend = ti->len; need_draw = TRUE; } else if ((keysym == XK_Return) || (keysym == XK_Linefeed) || (keysym == XK_KP_Enter)) { result |= BUTOUT_CAUGHT; if (ti->callback == NULL) { but_setFlags(but, BUT_NOKEY); } else { needCallback = TRUE; } } /* Void all mouse movement until it is pressed again. */ if (ti->mousePress != -1) { ti->mousePress = -1; if (but->flags & BUT_LOCKED) but_newFlags(but, but->flags & ~BUT_LOCKED); } if (need_draw) { result |= BUTOUT_CAUGHT; curInView(but); but_draw(but); } if (needCallback) result |= ti->callback(but, ti->str); return(result); } static bool insert(ButEnv *env, const char *src, Txtin *ti) { int i, j, ntLen, cl1, cl2; XFontStruct *fs = env->fonts[0]; if (src == NULL) { return(FALSE); } if (ti->loc <= ti->cutend) { cl1 = ti->loc; cl2 = ti->cutend; } else { cl1 = ti->cutend; cl2 = ti->loc; } for (i = 0, ntLen = 0; src[i]; ++i) { if ((((uchar)src[i] >= fs->min_char_or_byte2) && ((uchar)src[i] <= fs->max_char_or_byte2)) || (fs->all_chars_exist && fs->per_char[(uchar)src[i] - fs->min_char_or_byte2].width)) ++ntLen; } if ((ntLen == 0) && src[0]) return(FALSE); if (ntLen + ti->len + cl1 - cl2 > ti->maxlen) { return(FALSE); } if (cl1 != cl2) { for (i = cl1; i < ti->len; ++i) ti->str[i] = ti->str[i + cl2 - cl1]; } for (i = ti->len + ntLen; i >= cl1 + ntLen; --i) ti->str[i] = ti->str[i - ntLen]; for (i = 0, j = cl1; src[i]; ++i) { if ((((uchar)src[i] >= fs->min_char_or_byte2) && ((uchar)src[i] <= fs->max_char_or_byte2)) || (fs->all_chars_exist && fs->per_char[(uchar)src[i] - fs->min_char_or_byte2].width)) { ti->str[j++] = src[i]; } } ti->len += cl1 - cl2 + ntLen; ti->loc = ti->cutend = cl1 + ntLen; return(TRUE); } static void ti_cursor(But *but) { Txtin *ti = but->iPacket; ButWin *win = but->win; ButEnv *env = win->env; XFontStruct *fs = env->fonts[0]; int x, y; int rw; if (ti->loc != ti->cutend) return; x = but->x - ti->xoffset + env->stdButBw*2 + XTextWidth(fs, ti->dispStr, ti->loc); y = but->y + env->stdButBw*2; if ((rw = (fs->ascent + fs->descent + 10) / 20) < 1) rw = 1; x -= rw/2; if (x < but->x + env->stdButBw) { rw -= (but->x + env->stdButBw - x); x = but->x + env->stdButBw; } else if (x+rw > but->x + but->w - env->stdButBw) { rw = but->x + but->w - env->stdButBw - x; } if (rw <= 0) return; if (ti->cursorVisible) butEnv_setXFg2(env, BUT_FG); else butEnv_setXFg2(env, BUT_HIBG); XFillRectangle(env->dpy, win->win, env->gc2, x - win->xOff, y - win->yOff, rw, ti->pm_h - env->stdButBw*2); } static void ti_redrawCursor(But *but) { Txtin *ti = but->iPacket; ButWin *win = but->win; ButEnv *env = win->env; XFontStruct *fs = env->fonts[0]; int x, y; int rw; if (ti->loc != ti->cutend) return; x = but->x - ti->xoffset + env->stdButBw*2 + XTextWidth(fs, ti->dispStr, ti->loc); y = but->y + env->stdButBw*2; if ((rw = (fs->ascent + fs->descent + 10) / 20) < 1) rw = 1; x -= rw/2; if (x < but->x + env->stdButBw) { rw -= (but->x + env->stdButBw - x); x = but->x + env->stdButBw; } else if (x+rw > but->x + but->w - env->stdButBw) { rw = but->x + but->w - env->stdButBw - x; } if (rw <= 0) return; butWin_redraw(win, x, y, rw, ti->pm_h - env->stdButBw*2); } static void cut(ButEnv *env, char *cutstr, int cutlen, But *but) { ButWin *realWin; if (cutstr_maxlen < cutlen) { if (cutdata != NULL) wms_free(cutdata); cutdata = (char *)wms_malloc(cutlen); cutstr_maxlen = cutlen; } XStoreBytes(env->dpy, cutstr, cutlen); memcpy(cutdata, cutstr, cutlen); cutstr_len = cutlen; realWin = but->win; while (realWin->parent != NULL) realWin = realWin->parent; if ((env->sReq == NULL) || ((env->sReq == sreq) && (cut_butnum == but))) XSetSelectionOwner(env->dpy, XA_PRIMARY, realWin->win, 0); else env->sClear(env); if (XGetSelectionOwner(env->dpy, XA_PRIMARY) == realWin->win) { env->sReq = sreq; env->sClear = sclear; cut_butnum = but; } } static bool sreq(ButEnv *env, XSelectionRequestEvent *xsre) { if (xsre->target != XA_STRING) return(FALSE); XChangeProperty(env->dpy, xsre->requestor, xsre->property, xsre->target, 8, PropModeReplace, cutdata, cutstr_len); return(TRUE); } static int sclear(ButEnv *env) { Txtin *ti; assert(MAGIC(cut_butnum)); ti = cut_butnum->iPacket; assert(MAGIC(ti)); ti->loc = ti->cutend; but_draw(cut_butnum); env->sReq = NULL; env->sClear = NULL; return(0); } static void paste(ButEnv *env, But *but) { ButWin *topWin; paste_butnum = but; env->sNotify = snotify; topWin = but->win; while (topWin->parent != NULL) topWin = topWin->parent; XConvertSelection(env->dpy, XA_PRIMARY, XA_STRING, env->prop, topWin->win, 0); } static int snotify(ButEnv *env, XSelectionEvent *xsnot) { unsigned char *propbuf; unsigned long proplen, propleft; int blen; int pformat; Atom ptype; Txtin *ti; char *pb2; ti = paste_butnum->iPacket; if (xsnot->property != None) { XGetWindowProperty(env->dpy, xsnot->requestor, xsnot->property, 0, ti->maxlen, True, AnyPropertyType, &ptype, &pformat, &proplen, &propleft, &propbuf); pb2 = (char *)wms_malloc(proplen * pformat + 1); pb2[proplen * pformat] = '\0'; memcpy(pb2, propbuf, proplen * pformat); XFree(propbuf); if (insert(env, pb2, ti)) { textInView(paste_butnum, FALSE); but_draw(paste_butnum); } else XBell(env->dpy, 0); wms_free(pb2); } else { propbuf = (unsigned char *)XFetchBytes(env->dpy, &blen); if (blen > 0) { pb2 = (char *)wms_malloc(blen + 1); pb2[blen] = '\0'; memcpy(pb2, propbuf, blen); XFree(propbuf); if (insert(env, pb2, ti)) { textInView(paste_butnum, FALSE); but_draw(paste_butnum); } else XBell(env->dpy, 0); wms_free(pb2); } else XBell(env->dpy, 0); } env->sNotify = NULL; return(0); } /* * This adjusts your loc and your cutend for when you're in word select mode. */ static void wordsel_adjust(Txtin *but) { int a, b; if (but->loc < but->cutend) { a = but->loc; b = but->cutend; } else { a = but->cutend; b = but->loc; } for (;;) { if (a <= 0) { a = 0; break; } if (((isalnum(but->str[a]) || (but->str[a] == '_')) && (isalnum(but->str[a-1]) || (but->str[a-1] == '_'))) || (but->str[a] == but->str[a-1]) || (isdigit(but->str[a]) && (but->str[a-1] == '.') && (a >= 2) && isdigit(but->str[a-2])) || (isdigit(but->str[a+1]) && (but->str[a] == '.') && isdigit(but->str[a-1]))) --a; else break; } if (b <= 0) b = 1; for (;;) { if (b >= but->len) { b = but->len; break; } if (((isalnum(but->str[b-1]) || (but->str[b-1] == '_')) && (isalnum(but->str[b]) || (but->str[b] == '_'))) || (but->str[b-1] == but->str[b]) || (isdigit(but->str[b-1]) && (but->str[b] == '.') && isdigit(but->str[b+1])) || ((b >= 2) && isdigit(but->str[b-2]) && (but->str[b-1] == '.') && isdigit(but->str[b]))) ++b; else break; } but->loc = a; but->cutend = b; } /* Returns the index of the character just to the right of the cursor. */ static int locateMouse(XFontStruct *fs, char *text, int len, int x, bool *rightSide) { int i; int prev_x = x; bool dummy; if (rightSide == NULL) rightSide = &dummy; for (i = 0; (x > 0) && (i < len); ++i) { prev_x = x; if (fs->per_char == NULL) /* Monospace font. */ x -= fs->min_bounds.width; else x -= fs->per_char[text[i] - fs->min_char_or_byte2].width; } if ((*rightSide = ((i > 0) && (x < 0) && (prev_x < -x)))) --i; if (i == len) *rightSide = FALSE; return(i); } /* Set up xoffset so that the cursor will be in view. */ static void curInView(But *but) { Txtin *ti = but->iPacket; ButEnv *env = but->win->env; int curIn; curIn = XTextWidth(env->fonts[0], ti->dispStr, ti->loc); if (curIn < ti->xoffset) ti->xoffset = curIn; if (curIn - ti->xoffset > ti->pm_w - env->stdButBw * 2) ti->xoffset = curIn - ti->pm_w + env->stdButBw * 2; } /* * Set up xoffset so that the text will be in view. If maxInView is set, * then make sure that as much text is in the window as possible (that is, * there is no unnecessary empty space to the right of the text). */ static void textInView(But *but, bool maxInView) { Txtin *ti = but->iPacket; ButEnv *env = but->win->env; int curIn; curIn = XTextWidth(env->fonts[0], ti->dispStr, ti->len); if (maxInView) { if (ti->xoffset > curIn - (but->w - env->stdButBw*4)) ti->xoffset = curIn - (but->w - env->stdButBw * 4); } if (ti->xoffset < 0) ti->xoffset = 0; if (ti->xoffset > curIn) ti->xoffset = curIn; } static void flags(But *but, uint flags) { Txtin *ti = but->iPacket; if ((but->flags & BUT_KEYED) != (flags & BUT_KEYED)) { if (flags & BUT_KEYED) { enableCTimer(but); ti->cursorVisible = TRUE; } else { ti->cursorVisible = FALSE; disableCTimer(but); } } but->flags = flags; assert((but->flags & BUT_PRESSABLE) || !(but->flags & BUT_KEYED)); but_draw(but); } static ButOut blinkCursor(ButTimer *timer) { But *but = butTimer_packet(timer); Txtin *ti = but->iPacket; ti->cursorVisible = !(butTimer_ticks(timer) & 1); ti_redrawCursor(but); return(0); } static ButOut slide(ButTimer *timer) { But *but = butTimer_packet(timer); Txtin *ti = but->iPacket; int newXoff, oldXoff; if (ti->slideDir > 0) { oldXoff = ti->xoffset; textInView(but, TRUE); if (oldXoff != ti->xoffset) { ti->xoffset = oldXoff; butTimer_destroy(ti->sTimer); ti->sTimer = NULL; return(0); } } newXoff = ti->xoffset + ti->slideDir * butTimer_ticks(timer); ti->xoffset = newXoff; textInView(but, ti->slideDir > 0); if (ti->xoffset != newXoff) { butTimer_destroy(ti->sTimer); ti->sTimer = NULL; } butTimer_setTicks(timer, 0); but_draw(but); return(0); } static void startSlide(But *but, int dir, bool fast) { struct timeval zero; Txtin *ti = but->iPacket; int freq; zero.tv_sec = 0; zero.tv_usec = 0; freq = but->h; if (fast) freq *= 10; if (ti->sTimer != NULL) { if ((ti->slideFreq == freq) && (ti->slideDir == dir)) return; butTimer_destroy(ti->sTimer); } ti->slideDir = dir; ti->slideFreq = freq; ti->sTimer = butTimer_fCreate(but, but, zero, freq, FALSE, slide); } static void enableCTimer(But *but) { Txtin *ti = but->iPacket; struct timeval halfSec; assert(ti->cTimer == NULL); halfSec.tv_sec = 0; halfSec.tv_usec = 500000; ti->cTimer = butTimer_create(but, but, halfSec, halfSec, TRUE, blinkCursor); } static void disableCTimer(But *but) { Txtin *ti = but->iPacket; if (ti->cTimer != NULL) { butTimer_destroy(ti->cTimer); ti->cTimer = NULL; } } void butTextin_set(But *but, const char *newStr, bool propagate) { Txtin *ti; assert(MAGIC(but)); assert(but->action == &action); ti = but->iPacket; assert(MAGIC(ti)); assert(strlen(newStr) <= ti->maxlen); strcpy(ti->str, newStr); ti->len = ti->loc = ti->cutend = strlen(newStr); textInView(but, TRUE); but_draw(but); if (propagate) ti->callback(but, ti->str); } void butTextin_setHidden(But *but, bool hidden) { Txtin *ti; int i; assert(MAGIC(but)); assert(but->action == &action); ti = but->iPacket; assert(MAGIC(ti)); if (hidden == ti->hidden) return; ti->hidden = hidden; if (hidden) { ti->dispStr = wms_malloc(ti->maxlen); for (i = 0; i < ti->maxlen; ++i) { ti->dispStr[i] = '*'; } } else { wms_free(ti->dispStr); ti->dispStr = ti->str; } } void butTextin_setSpecialKey(But *but, KeySym keysym, uint keyModifiers, uint modMask, ButOut callback(But *but, KeySym keysym, uint keyModifiers, void *context), void *context) { Txtin *ti; SpecKey *newSpec; assert(MAGIC(but)); assert(but->action == &action); ti = but->iPacket; assert(MAGIC(ti)); assert((keyModifiers & modMask) == keyModifiers); newSpec = wms_malloc(sizeof(SpecKey)); MAGIC_SET(newSpec); newSpec->next = ti->specKeys; ti->specKeys = newSpec; newSpec->keysym = keysym; newSpec->keyModifiers = keyModifiers; newSpec->modMask = modMask; newSpec->callback = callback; newSpec->context = context; } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/timer.c0000664000671000067100000001245307043224472012677 /* * wmslib/src/but/timer.c, part of wmslib (Library functions) * Copyright (C) 1994 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #include #include #include #include #include #include #include #include #include ButTimer *butTimer_create(void *packet, But *but, struct timeval delay, struct timeval period, bool winOnly, ButOut (*timerFunc)(ButTimer *timer)) { ButTimer *bt; struct timeval now; struct timezone tzone; bt = wms_malloc(sizeof(ButTimer)); MAGIC_SET(bt); bt->packet = packet; bt->eventNum = 0; bt->period = period; bt->state = butTimer_on; gettimeofday(&now, &tzone); bt->nextFiring = but_timerAdd(now, delay); if (but) bt->win = but->win; else bt->win = NULL; bt->but = but; bt->timerFunc = timerFunc; bt->winOnly = winOnly; bt->next = but_timerList; bt->freqCounter = FALSE; bt->ticksLeft = 0; but_timerList = bt; return(bt); } ButTimer *butTimer_fCreate(void *packet, But *but, struct timeval delay, int frequency, bool winOnly, ButOut (*timerFunc)(ButTimer *timer)) { ButTimer *bt; struct timeval now; struct timezone tzone; int i; bt = wms_malloc(sizeof(ButTimer)); MAGIC_SET(bt); bt->packet = packet; bt->eventNum = 0; bt->period.tv_sec = 0; bt->winOnly = winOnly; if (frequency < BUTTIMER_MAXFREQ) { bt->period.tv_usec = 1000000 / frequency; bt->ticksPerPeriod = 1; } else { bt->period.tv_usec = 1000000 / BUTTIMER_STDFREQ; bt->ticksPerPeriod = (frequency + BUTTIMER_STDFREQ/2) / BUTTIMER_STDFREQ; } bt->state = butTimer_on; gettimeofday(&now, &tzone); bt->nextFiring = but_timerAdd(now, delay); if (but) bt->win = but->win; else bt->win = NULL; bt->but = but; bt->timerFunc = timerFunc; bt->next = but_timerList; bt->freqCounter = TRUE; for (i = 0; i < BUTTIMER_HIST; ++i) bt->lastRes[i] = 1; bt->resnum = 0; bt->ticksLeft = 0; but_timerList = bt; return(bt); } void butTimer_destroy(ButTimer *timer) { assert(MAGIC(timer)); timer->state = butTimer_dead; } void butTimer_reset(ButTimer *timer) { struct timeval now; struct timezone tzone; assert(MAGIC(timer)); timer->eventNum = 0; gettimeofday(&now, &tzone); timer->nextFiring = but_timerAdd(now, timer->period); } struct timeval but_timerAdd(struct timeval t1, struct timeval t2) { struct timeval r; r.tv_sec = t1.tv_sec + t2.tv_sec; if ((r.tv_usec = t1.tv_usec + t2.tv_usec) > 1000000) { r.tv_usec -= 1000000; ++r.tv_sec; } return(r); } struct timeval but_timerSub(struct timeval t1, struct timeval t2) { struct timeval r; r.tv_sec = t1.tv_sec - t2.tv_sec; if ((r.tv_usec = t1.tv_usec - t2.tv_usec) < 0) { r.tv_usec += 1000000; --r.tv_sec; } if (r.tv_sec < 0) r.tv_sec += 60*60*24; return(r); } int but_timerDiv(struct timeval t1, struct timeval t2, struct timeval *remainder) { int result; long it1, it2, irem; it1 = (t1.tv_sec*1000000L) + t1.tv_usec; it2 = (t2.tv_sec*1000000L) + t2.tv_usec; result = it1 / it2; if (remainder != NULL) { irem = it1 % it2; remainder->tv_usec = irem % 1000000; remainder->tv_sec = irem / 1000000; } return(result); } int butEnv_checkTimers(ButEnv *env, struct timeval *timeout) { struct timeval current_time, next_timer, timerem; struct timezone tzone; bool take_timer, timer_set = FALSE; ButTimer *bt, *bt2; int ticks, i, orig_ticks; int result = 0; /* First, kill off all the dead timers. */ for (bt = but_timerList; bt != NULL;) { if (bt->state == butTimer_dead) { if (bt == but_timerList) but_timerList = bt->next; else { for (bt2 = but_timerList; bt2->next != bt; bt2 = bt2->next); bt2->next = bt->next; } bt2 = bt->next; MAGIC_UNSET(bt); wms_free(bt); bt = bt2; } else { bt = bt->next; } } gettimeofday(¤t_time, &tzone); for (bt = but_timerList; bt != NULL; bt = bt->next) { if (bt->state == butTimer_on) { if (timercmp(&bt->nextFiring, ¤t_time, <)) { take_timer = TRUE; ticks = but_timerDiv(but_timerSub(current_time, bt->nextFiring), bt->period, &timerem) + 1 + bt->ticksLeft; take_timer = TRUE; orig_ticks = ticks; if (bt->freqCounter) { for (i = 0; i < BUTTIMER_HIST; ++i) { if (bt->lastRes[i] > ticks) { take_timer = FALSE; } } if (!bt->ticksLeft) { bt->lastRes[bt->resnum] = ticks; bt->resnum = (bt->resnum + 1) & (BUTTIMER_HIST - 1); } ticks *= bt->ticksPerPeriod; } bt->nextFiring = but_timerSub(but_timerAdd(current_time, bt->period), timerem); if (take_timer) { bt->eventNum += ticks; result |= bt->timerFunc(bt); XSync(env->dpy, False); bt->ticksLeft = 0; } else bt->ticksLeft += orig_ticks; } if (!timer_set || timercmp(&bt->nextFiring, &next_timer, <)) { timer_set = TRUE; next_timer = bt->nextFiring; } } } if (timer_set) *timeout = but_timerSub(next_timer, current_time); else { timeout->tv_usec = 0; timeout->tv_sec = 365*24*60*60; /* 1 spurious interrupt per year. */ } return(result); } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/but/write.c0000664000671000067100000001227207043224472012710 /* * wmslib/src/but/write.c, part of wmslib (Library functions) * Copyright (C) 1994 William Shubert. * See "configure.h.in" for more copyright information. */ #include #ifdef X11_DISP #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif #include #include #include void butEnv_setChar(ButEnv *env, double width, const char *id, void (*draw)(void *packet, ButWin *win, int x, int y, int w, int h), void *packet) { int idval; idval = ((int)(uchar)id[0] << 8) + (uchar)id[1] - 256; env->write[idval].width = width; env->write[idval].packet = packet; env->write[idval].draw = draw; } int butEnv_textWidth(ButEnv *env, const char *text, int fnum) { uchar c; int special; int total = 0, min_char, std_width; XCharStruct *charlist; if (env->fonts[fnum]->per_char != NULL) { charlist = env->fonts[fnum]->per_char; min_char = env->fonts[fnum]->min_char_or_byte2; for (;;) { c = text[0]; ++text; switch(c) { case '\0': return(total); break; case '\1': case '\2': special = 256 * (c - 1) + text[0]; ++text; assert(env->write[special].draw != NULL); total += (env->fonts[fnum]->ascent + env->fonts[fnum]->descent) * env->write[special].width + 0.5; break; default: assert((c >= min_char) && (c <= env->fonts[fnum]->max_char_or_byte2)); total += charlist[c - min_char].width; break; } } } else { /* All chars are the same width. */ std_width = env->fonts[fnum]->min_bounds.width; for (;;) { c = text[0]; ++text; switch(c) { case '\0': return(total); break; case '\1': case '\2': special = 256 * (c - 1) + text[0]; ++text; assert(env->write[special].draw != NULL); total += (env->fonts[fnum]->ascent + env->fonts[fnum]->descent) * env->write[special].width + 0.5; break; default: total += std_width; break; } } } } int butEnv_charWidth(ButEnv *env, const char *text, int fnum) { uchar c, special; int width; c = text[0]; assert(c != '\0'); switch(c) { case '\1': case '\2': special = 256 * (c - 1) + text[1]; assert(env->write[special].draw != NULL); width = (env->fonts[fnum]->ascent + env->fonts[fnum]->descent) * env->write[special].width + 0.5; break; default: if (env->fonts[fnum]->per_char != NULL) width = env->fonts[fnum]->per_char[c - env->fonts[fnum]->min_char_or_byte2]. width; else width = env->fonts[fnum]->min_bounds.width; break; } return(width); } void butWin_write(ButWin *win, int x, int y, const char *text, int font) { int wlen; ButEnv *env = win->env; int ascent = env->fonts[font]->ascent, special; int w, h = ascent + env->fonts[font]->descent; uchar c; XSetFont(env->dpy, env->gc, env->fonts[font]->fid); for (;;) { for (wlen = 0; (uchar)(text[wlen]) > BUTWRITE_MINPRINT; ++wlen); if (wlen > 0) { XDrawString(env->dpy, win->win, env->gc, x-win->xOff, y+ascent-win->yOff, text, wlen); x += XTextWidth(env->fonts[font], text, wlen); text += wlen; } switch(c = text[0]) { case '\0': return; break; case '\1': case '\2': special = 256 * (c-1) + text[1]; text += 2; assert(env->write[special].draw != NULL); w = h * env->write[special].width + 0.5; env->write[special].draw(env->write[special].packet, win, x-win->xOff,y-win->yOff, w,h); x += w; break; } } } void butWin_writeTabs(ButWin *win, int startX, int y, const char *text, int font, const int *tabList, const ButTextAlign *aligns) { int wlen; ButEnv *env = win->env; int ascent = env->fonts[font]->ascent, special; int w, h = ascent + env->fonts[font]->descent; int x = startX; uchar c; int tabNum = 0; ButTextAlign align = butText_left; XSetFont(env->dpy, env->gc, env->fonts[font]->fid); for (;;) { for (wlen = 0; (uchar)(text[wlen]) > BUTWRITE_MINPRINT; ++wlen); if (wlen > 0) { w = XTextWidth(env->fonts[font], text, wlen); switch(align) { case butText_left: break; case butText_center: x -= w / 2; break; case butText_right: x -= w; break; case butText_just: assert(0); break; } XDrawString(env->dpy, win->win, env->gc, x - win->xOff, y+ascent-win->yOff, text, wlen); x += w; text += wlen; } switch(c = text[0]) { case '\0': return; break; case '\1': case '\2': special = 256 * (c-1) + text[1]; text += 2; assert(env->write[special].draw != NULL); w = h * env->write[special].width + 0.5; env->write[special].draw(env->write[special].packet, win, x-win->xOff,y-win->yOff, w,h); x += w; break; case '\t': x = startX + tabList[tabNum]; align = aligns[tabNum]; ++tabNum; ++text; break; } } } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/wms/0000777000671000067100000000000007606355253011513 5cgoban-1.9.14/wmslib/src/wms/clp-x.h0000664000671000067100000000105407043224472012616 /* * wmslib/src/wms/clp.h, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. * * Command Line Parse. */ #ifndef _WMS_CLP_X_H_ #define _WMS_CLP_X_H_ 1 #ifndef _WMS_CLP_H_ #include #endif /********************************************************************** * Functions **********************************************************************/ extern void clp_rXDefaults(Clp *cltab, Display *dpy, const char *name); #endif /* _WMS_CLP_X_H_ */ cgoban-1.9.14/wmslib/src/wms/clp.h0000664000671000067100000001113707043224472012354 /* * wmslib/src/wms/clp.h, part of wmslib (Library functions) * Copyright (C) 1994-1996 William Shubert. * See "configure.h.in" for more copyright information. * * Command Line Parse. */ #ifndef _WMS_CLP_H_ #ifndef _WMS_STR_H_ #include #endif #ifdef _WMS_CLP_H_ Levelization Error. #endif #define _WMS_CLP_H_ 1 /********************************************************************** * Data types. These are all visible to the application. **********************************************************************/ struct ClpEntry_struct; /* Public. */ #define CLPSETUP_BOOL 0x01 /* Is it "-[no]" or "- "? */ #define CLPSETUP_SHOWBOOL 0x02 /* Show "[no]" in the help. */ #define CLPSETUP_NOSAVE 0x04 #define CLPSETUP_ENDFLAG 0x08 #define CLPSETUP_HELP 0x10 /* This switch gives you help. */ typedef struct ClpSetup_struct { const char *name; /* NULL for just a label. */ const char *defVal; const char *desc; /* NULL if it doesn't show up in the help. */ uint flags; bool (*test)(struct ClpEntry_struct *entry); } ClpSetup; typedef enum { clpWhere_unset, clpWhere_rcfile, clpWhere_xdefs, clpWhere_cmdline, clpWhere_dup } ClpWhere; /* Private. */ typedef enum { clpDtype_int, clpDtype_double, clpDtype_bool, clpDtype_string, clpDtype_end } ClpDtype; typedef struct ClpEntry_struct { const char *name; const char *desc; uint flags; bool (*test)(struct ClpEntry_struct *entry); ClpWhere where; ClpDtype type; int numStrs, maxStrs; union { int ival; double dval; Str *strList; bool bval; } storage; MAGIC_STRUCT } ClpEntry; typedef struct Clp_struct { ClpEntry *infos; int numInfos; MAGIC_STRUCT } Clp; /********************************************************************** * Routines available **********************************************************************/ extern Clp *clp_create(const ClpSetup vars[]); extern void clp_destroy(Clp *clp); /* * clp_rCmdline returns the number of arguments left on the command * line, or CLP_ARGS_NOGOOD if there was an error. */ extern int clp_rCmdline(Clp *cltab, char *argv[]); /* * clp_rFile returns FALSE if it can't find the file at all. */ extern bool clp_rFile(Clp *cltab, const char *fname); extern void clp_wFile(Clp *cltab, const char *fname, const char *pname); extern ClpEntry *clp_lookup(Clp *clp, const char *varName); #define clp_where(clp, str) (clp_lookup(clp, str)->where) #define clpEntry_where(ce) ((ce)->where) extern int clpEntry_iGetInt(ClpEntry *ce, bool *err); #define clp_iGetInt(clp, str, e) clpEntry_iGetInt(clp_lookup(clp, str), e) #define clpEntry_getInt(ce) clpEntry_iGetInt(ce, NULL) #define clp_getInt(clp, str) clpEntry_getInt(clp_lookup(clp, str)) extern double clpEntry_iGetDouble(ClpEntry *ce, bool *err); #define clpEntry_getDouble(ce) clpEntry_iGetDouble(ce, NULL) #define clp_getDouble(clp, str) clpEntry_getDouble(clp_lookup(clp,str)) #define clpEntry_numStrs(ce) ((ce)->numStrs) extern const char *clpEntry_iGetStrNum(ClpEntry *ce, int num, bool *err); #define clpEntry_getStrNum(ce, n) clpEntry_iGetStrNum(ce, n, NULL) #define clp_getStrNum(clp, s, n) clpEntry_getStrNum(clp_lookup(clp, s), n) #define clpEntry_iGetStr(ce, e) clpEntry_iGetStrNum(ce, 0, e) #define clpEntry_getStr(ce) clpEntry_iGetStr(ce, NULL) #define clp_getStr(clp, str) clpEntry_getStr(clp_lookup(clp, str)) extern bool clpEntry_iGetBool(ClpEntry *ce, bool *err); #define clpEntry_getBool(ce) clpEntry_iGetBool(ce, NULL) #define clp_getBool(clp, str) clpEntry_getBool(clp_lookup(clp, str)) extern bool clpEntry_setInt(ClpEntry *ce, int val); #define clp_setInt(c, s, v) clpEntry_setInt(clp_lookup(c, s), v) extern bool clpEntry_setDouble(ClpEntry *ce, double val); #define clp_setDouble(c, s, v) clpEntry_setDouble(clp_lookup(c, s), v) extern bool clpEntry_setStrNum(ClpEntry *ce, const char *val, int num); #define clp_setStrNum(c, s, v, n) clpEntry_setStrNum(clp_lookup(c, s), v, n) #define clpEntry_setStr(ce, v) clpEntry_setStrNum(ce, v, 0) #define clp_setStr(c, s, v) clpEntry_setStr(clp_lookup(c, s), v) extern bool clpEntry_setBool(ClpEntry *ce, bool val); #define clp_setBool(c, s, v) clpEntry_setBool(clp_lookup(c, s), v) /********************************************************************** * Handy macros and constants. **********************************************************************/ #define CLPSETUP_MSG(message) {NULL, NULL, message, 0, NULL} #define CLPSETUP_END {NULL,NULL,NULL,CLPSETUP_ENDFLAG, NULL} #define CLP_ARGS_NOGOOD -1 #endif /* _WMS_CLP_H_ */ cgoban-1.9.14/wmslib/src/wms/rnd.h0000664000671000067100000000133607043224472012361 /* * wmslib/src/wms/rnd.h, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _WMS_RND_H_ #define _WMS_RND_H_ 1 #ifndef _WMS_H_ #include #endif #define RND_DATASIZE 31 #define RND_INDENT 3 typedef struct Rnd_struct { int indent; uint32 data[RND_DATASIZE]; MAGIC_STRUCT } Rnd; extern int rnd_int(Rnd *state); /* No negative numbers. */ extern uint rnd_uint(Rnd *state); /* Random bit field. */ extern int rnd_int32(Rnd *state); extern uint rnd_uint32(Rnd *state); extern Rnd *rnd_create(uint seed); extern void rnd_destroy(Rnd *state); extern float rnd_float(Rnd *state); #endif /* _WMS_RND_H_ */ cgoban-1.9.14/wmslib/src/wms/snd.h0000664000671000067100000000431007043224472012355 /* * wmslib/include/snd.h, part of wmslib (Library functions) * Copyright (C) 1994 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _WMS_SND_H_ #define _WMS_SND_H_ 1 /********************************************************************** * Data types **********************************************************************/ /* Public. */ typedef enum { sndInit_ok, sndInit_busy, sndInit_broken } SndInit; /* * This is a public type, but the "sndState_i*" values should never be used * by the application - they are for internal use only. */ typedef enum { sndState_iOff, sndState_off, sndState_partOpen, sndState_iWantOpen, sndState_fullOpen, sndState_oldState, sndState_iTempOpen } SndState; /* Opaque. */ typedef struct Snd_struct { int len; uchar *data; bool converted; int cvtlen; union { uchar *dsp; ushort *dsp1; } cvtdata; struct Snd_struct *next; } Snd; /********************************************************************** * Global variables **********************************************************************/ /* * Feel free to set this pointer to point to any old handler. By default * it points to a routine that dumps errStr to stderr for the first * error then ignores the rest. * It gets called ONLY by snd_play; snd_init returns an error code that you * should check for. * errStr is always the same as snd_error. */ extern void (*snd_errHandler)(SndInit errType, char *errStr); extern char snd_error[]; /********************************************************************** * Functions **********************************************************************/ extern SndInit snd_init(SndState newState, int newVolume); extern void snd_play(Snd *sound); extern void snd_deinit(void); /********************************************************************** * Macros, constants, etc. **********************************************************************/ #define snd_define(data) {sizeof(data), data, FALSE,0,{NULL},NULL} #define SND_MAXVOL 10000 /* Just for kicks, you know? */ #if SUN_SOUND || LINUX_SOUND #define SND_AVAILABLE 1 #else #define SND_AVAILABLE 0 #endif #endif /* _WMS_SND_H_ */ cgoban-1.9.14/wmslib/src/wms/str.h0000664000671000067100000000400207043224472012377 /* * wmslib/src/wms/str.h, part of wmslib (Library functions) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _WMS_STR_H_ #define _WMS_STR_H_ 1 #ifndef _WMS_H_ #include #endif /********************************************************************** * Data Types **********************************************************************/ typedef struct Str_struct { char *chars; int len; int maxLen; MAGIC_STRUCT } Str; /********************************************************************** * Functions **********************************************************************/ extern Str *str_create(void); extern Str *str_createStr(const Str *s); extern Str *str_createChars(const char *chars); extern Str *str_createChar(char c); extern void str_destroy(Str *s); extern void str_init(Str *s); extern void str_initStr(Str *s, const Str *src); extern void str_initChars(Str *s, const char *src); extern void str_initCharsLen(Str *s, const char *src, int len); extern void str_deinit(Str *s); #define str_len(s) ((s)->len) #define str_chars(s) ((const char *)((s)->chars)) extern void str_copy(Str *dest, const Str *src); extern void str_copyChars(Str *dest, const char *src); extern void str_copyCharsLen(Str *dest, const char *src, int len); extern void str_copyChar(Str *dest, char src); extern void str_print(Str *dest, const char *fmt, ...); extern void str_cat(Str *dest, const Str *src); extern void str_catChars(Str *dest, const char *src); extern void str_catCharsLen(Str *dest, const char *src, int len); extern void str_catChar(Str *dest, char src); extern void str_catInt(Str *dest, int src); /* str_alphaCmd is useful in qsort and bsearch. */ extern int str_alphaCmp(const void *a, const void *b); #define str_clip(s, l) \ do { \ if ((l) < (s)->len) \ (s)->chars[(s)->len = (l)] = '\0'; \ } while(0) #endif /* _WMS_STR_H_ */ cgoban-1.9.14/wmslib/src/wms/Makefile.am0000664000671000067100000000031007466273126013461 noinst_LIBRARIES = libwms.a INCLUDES = -I $(top_srcdir)/wmslib/src libwms_a_SOURCES = \ clp-x.c \ clp.c \ rnd.c \ snd.c \ str.c noinst_HEADERS = \ clp-x.h \ clp.h \ rnd.h \ snd.h \ str.h cgoban-1.9.14/wmslib/src/wms/Makefile.in0000664000671000067100000002126407606355026013501 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../../.. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPP = @CPP@ DATE = @DATE@ DEPDIR = @DEPDIR@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBS = @LIBS@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ noinst_LIBRARIES = libwms.a INCLUDES = -I $(top_srcdir)/wmslib/src libwms_a_SOURCES = \ clp-x.c \ clp.c \ rnd.c \ snd.c \ str.c noinst_HEADERS = \ clp-x.h \ clp.h \ rnd.h \ snd.h \ str.h subdir = wmslib/src/wms mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/configure.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) libwms_a_AR = $(AR) cru libwms_a_LIBADD = am_libwms_a_OBJECTS = clp-x.$(OBJEXT) clp.$(OBJEXT) rnd.$(OBJEXT) \ snd.$(OBJEXT) str.$(OBJEXT) libwms_a_OBJECTS = $(am_libwms_a_OBJECTS) DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/clp-x.Po ./$(DEPDIR)/clp.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/rnd.Po ./$(DEPDIR)/snd.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/str.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ DIST_SOURCES = $(libwms_a_SOURCES) HEADERS = $(noinst_HEADERS) DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in SOURCES = $(libwms_a_SOURCES) all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu wmslib/src/wms/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) AR = ar clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libwms.a: $(libwms_a_OBJECTS) $(libwms_a_DEPENDENCIES) -rm -f libwms.a $(libwms_a_AR) libwms.a $(libwms_a_OBJECTS) $(libwms_a_LIBADD) $(RANLIB) libwms.a mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clp-x.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rnd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str.Po@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` CCDEPMODE = @CCDEPMODE@ uninstall-info-am: ETAGS = etags ETAGSFLAGS = tags: TAGS 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: $(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 "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../../.. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ 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"; \ $(mkinstalldirs) "$(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 check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) $(HEADERS) installdirs: 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-tags dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-exec-am: install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic uninstall-am: uninstall-info-am .PHONY: GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES distclean distclean-compile \ distclean-depend distclean-generic distclean-tags distdir dvi \ dvi-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic tags uninstall uninstall-am \ uninstall-info-am # 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: cgoban-1.9.14/wmslib/src/wms/clp-x.c0000664000671000067100000000205707043224472012615 /* * wmslib/src/wms/clp-x.c, part of wmslib (Library functions) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. * * Command Line Parser. */ #include #if X11_DISP #include #include #include "clp.h" /********************************************************************** * Functions **********************************************************************/ void clp_rXDefaults(Clp *clp, Display *dpy, char *name) { int i, j; ClpEntry *ci; char *xdef, wname[80]; for (i = 0; i < clp->numInfos; ++i) { ci = &clp->infos[i]; if (!ci->name || (ci->where == clpWhere_cmdline)) continue; strncpy(wname, ci->name, sizeof(wname) - 1); wname[sizeof(wname) - 1] = '\0'; for (j = 0; wname[j]; ++j) if (wname[j] == ',') wname[j] = '\0'; xdef = XGetDefault(dpy, name, wname); if (xdef != NULL) { ci->where = clpWhere_xdefs; ci->type = clpDtype_string; clpEntry_setStr(ci, xdef); } } } #endif /* X11_DISP */ cgoban-1.9.14/wmslib/src/wms/clp.c0000664000671000067100000003533207043224472012352 /* * wmslib/src/wms/clp.c, part of wmslib (Library functions) * Copyright (C) 1995-1997 William Shubert. * See "configure.h.in" for more copyright information. * * Command Line Parse. */ #include #include #include #include /* To get umask()...I hope this is portable! */ #include #if STDC_HEADERS #include #endif /* STDC_HEADERS */ #ifdef _WMS_CLP_H_ #error Levelization Error. #endif #include "clp.h" /********************************************************************** * Globals **********************************************************************/ const char *wms_progname = "UNKNOWN"; static bool showErrs = TRUE; /********************************************************************** * Forward Declarations **********************************************************************/ static ClpEntry *clp_iLookup(Clp *clp, const char *key, bool *bval); static void clpEntry_free(ClpEntry *ci); static void strip(char *argv[]); static void clp_help(Clp *clp); static void setStrList(ClpEntry *entry, const char *vals); static void moreStrs(ClpEntry *ce, int newNumStrs); /********************************************************************** * Functions **********************************************************************/ Clp *clp_create(const ClpSetup vars[]) { int numVars, i; Clp *newClp; newClp = wms_malloc(sizeof(Clp)); MAGIC_SET(newClp); for (numVars = 0; !(vars[numVars].flags & CLPSETUP_ENDFLAG); ++numVars); newClp->numInfos = numVars + 2; newClp->infos = wms_malloc((numVars + 2) * sizeof(ClpEntry)); for (i = 0; i < numVars; ++i) { MAGIC_SET(&newClp->infos[i]); newClp->infos[i].name = vars[i].name; newClp->infos[i].desc = vars[i].desc; newClp->infos[i].flags = vars[i].flags; newClp->infos[i].test = vars[i].test; if (vars[i].name == NULL) newClp->infos[i].flags |= CLPSETUP_NOSAVE; newClp->infos[i].where = clpWhere_unset; newClp->infos[i].type = clpDtype_string; newClp->infos[i].numStrs = 0; newClp->infos[i].maxStrs = 0; newClp->infos[i].storage.strList = NULL; if (vars[i].defVal) { setStrList(&newClp->infos[i], vars[i].defVal); } else { setStrList(&newClp->infos[i], ""); } assert(newClp->infos[i].numStrs > 0); } MAGIC_SET(&newClp->infos[i]); newClp->infos[i].name = NULL; newClp->infos[i].desc = ""; newClp->infos[i].flags = CLPSETUP_BOOL|CLPSETUP_NOSAVE; newClp->infos[i].where = clpWhere_unset; newClp->infos[i].type = clpDtype_bool; newClp->infos[i].test = NULL; ++i; MAGIC_SET(&newClp->infos[i]); newClp->infos[i].name = "help,-help"; newClp->infos[i].desc = "Show this message"; newClp->infos[i].flags = CLPSETUP_BOOL|CLPSETUP_NOSAVE|CLPSETUP_HELP; newClp->infos[i].where = clpWhere_unset; newClp->infos[i].type = clpDtype_bool; newClp->infos[i].test = NULL; return(newClp); } void clp_destroy(Clp *clp) { int i; assert(MAGIC(clp)); for (i = 0; i < clp->numInfos; ++i) clpEntry_free(&clp->infos[i]); wms_free(clp->infos); wms_free(clp); } int clp_rCmdline(Clp *clp, char *argv[]) { int numArgs; ClpEntry *ce; bool bval; assert(MAGIC(clp)); wms_progname = argv[0]; strip(argv); for (numArgs = 0; argv[numArgs];) { if (argv[numArgs][0] == '-') { /* It's a switch. */ ce = clp_iLookup(clp, argv[numArgs]+1, &bval); ce->where = clpWhere_cmdline; if (ce->flags & CLPSETUP_BOOL) { if (bval && (ce->flags & CLPSETUP_HELP)) { clp_help(clp); exit(1); } clpEntry_setBool(ce, bval); } else { if (argv[numArgs+1]) clpEntry_setStr(ce, argv[numArgs+1]); else { fprintf(stderr, "%s: Switch \"%s\" requires an argument.\n", wms_progname, argv[numArgs]); exit(1); } strip(argv + numArgs); } strip(argv + numArgs); } else ++numArgs; } return(numArgs); } /* * clp_rFile returns FALSE if it can't find the file at all. */ bool clp_rFile(Clp *clp, const char *fname) { FILE *ifile; char line_in[1024], *arg; Str full_fn; char *home, *key_start; int i, ch_in; bool retval = FALSE; ClpEntry *ci; assert(MAGIC(clp)); str_initChars(&full_fn, fname); showErrs = FALSE; if (fname[0] == '~') { /* Prepend "$HOME" */ home = getenv("HOME"); if (home == NULL) { fprintf(stderr, "%s: Error: Could not find environment variable \"HOME\".\n", wms_progname); showErrs = TRUE; str_deinit(&full_fn); return(FALSE); } str_print(&full_fn, "%s/%s", home, fname+1); } ifile = fopen(str_chars(&full_fn), "r"); if (ifile != NULL) { retval = TRUE; do { ch_in = getc(ifile); for (i = 0; (i < 1023) && (ch_in != '\n') && (ch_in != EOF); ++i) { line_in[i] = ch_in; ch_in = getc(ifile); } while ((ch_in != '\n') && (ch_in != EOF)) ch_in = getc(ifile); line_in[i] = '\0'; if ((line_in[0] == '#') || (line_in[0] == '\0')) continue; key_start = strchr(line_in, '.') + 1; if (key_start != NULL) { arg = strchr(line_in, ':'); *arg = '\0'; arg += 2; ci = clp_iLookup(clp, key_start, NULL); if (ci != NULL) { if ((ci->where == clpWhere_unset) || (ci->where == clpWhere_xdefs)) { ci->where = clpWhere_rcfile; setStrList(ci, arg); } } } } while (ch_in != EOF); fclose(ifile); } str_deinit(&full_fn); showErrs = TRUE; return(retval); } void clp_wFile(Clp *clp, const char *fname, const char *pname) { FILE *ofile; Str full_fn; char *home; const char *strOut; int i, prevMask, strNum, charNum; ClpEntry *ci; str_initChars(&full_fn, fname); if (fname[0] == '~') { /* Prepend "$HOME" */ home = getenv("HOME"); if (home == NULL) { fprintf(stderr, "%s: Error: Could not find environment variable \"HOME\".\n", wms_progname); str_deinit(&full_fn); return; } str_print(&full_fn, "%s/%s", home, fname+1); } prevMask = umask(0177); ofile = fopen(str_chars(&full_fn), "w"); umask(prevMask); if (ofile == NULL) { fprintf(stderr, "%s: Error: Could not open file \"%s\" for writing.\n", wms_progname, fname); perror(wms_progname); exit(1); } fprintf(ofile, "# NOTICE: Please do not edit this file.\n" "# It was automatically generated by \"%s\". If you want to\n" "# change one of these values, please use command line switches,\n" "# X defaults, or a setup window.\n" "# As a last resort you may simply delete this file.\n\n", wms_progname); for (i = 0; i < clp->numInfos; ++i) { ci = &clp->infos[i]; if (!(ci->flags & CLPSETUP_NOSAVE)) { switch(ci->type) { case clpDtype_int: fprintf(ofile, "%s.%s: %d\n", pname, ci->name, ci->storage.ival); break; case clpDtype_double: fprintf(ofile, "%s.%s: %f\n", pname, ci->name, ci->storage.dval); break; case clpDtype_bool: if (ci->storage.bval) fprintf(ofile, "%s.%s: y\n", pname, ci->name); else fprintf(ofile, "%s.%s: n\n", pname, ci->name); break; case clpDtype_string: fprintf(ofile, "%s.%s: ", pname, ci->name); for (strNum = 0; strNum < ci->numStrs; ++strNum) { if (strNum != 0) putc('|', ofile); strOut = str_chars(&ci->storage.strList[strNum]); for (charNum = 0; strOut[charNum]; ++charNum) { if ((strOut[charNum] == '|') || (strOut[charNum] == '\\')) putc('\\', ofile); putc(strOut[charNum], ofile); } } putc('\n', ofile); break; default: /* Should never reach here. */ assert(0); break; } } } fclose(ofile); str_deinit(&full_fn); } int clpEntry_iGetInt(ClpEntry *ce, bool *err) { switch(ce->type) { case clpDtype_int: if (err) *err = FALSE; return(ce->storage.ival); break; case clpDtype_string: return(wms_atoi(str_chars(&ce->storage.strList[0]), err)); break; default: if (err) *err = TRUE; return(0); } } double clpEntry_iGetDouble(ClpEntry *ce, bool *err) { switch(ce->type) { case clpDtype_double: if (err) *err = FALSE; return(ce->storage.dval); break; case clpDtype_string: return(wms_atof(str_chars(&ce->storage.strList[0]), err)); break; default: if (err) *err = TRUE; return(0.0); } } const char *clpEntry_iGetStrNum(ClpEntry *ce, int num, bool *err) { if (ce->type == clpDtype_string) { if (err) *err = FALSE; assert(num < ce->numStrs); return(str_chars(&ce->storage.strList[num])); } else { if (err) *err = TRUE; return(NULL); } } bool clpEntry_iGetBool(ClpEntry *ce, bool *err) { const char *str; switch(ce->type) { case clpDtype_bool: if (err) *err = FALSE; return(ce->storage.bval); break; case clpDtype_string: str = str_chars(&ce->storage.strList[0]); if ((!strcmp(str, "1")) || (!strcmp(str, "t")) || (!strcmp(str, "T")) || (!strcmp(str, "y")) || (!strcmp(str, "Y")) || (!strcmp(str, "true")) || (!strcmp(str, "True")) || (!strcmp(str, "TRUE")) || (!strcmp(str, "yes")) || (!strcmp(str, "Yes")) || (!strcmp(str, "YES"))) return(TRUE); if ((!strcmp(str, "0")) || (!strcmp(str, "f")) || (!strcmp(str, "F")) || (!strcmp(str, "n")) || (!strcmp(str, "N")) || (!strcmp(str, "false")) || (!strcmp(str, "False")) || (!strcmp(str, "FALSE")) || (!strcmp(str, "no")) || (!strcmp(str, "No")) || (!strcmp(str, "NO"))) return(FALSE); if (err) *err = TRUE; return(FALSE); break; default: if (err) *err = TRUE; return(FALSE); } } bool clpEntry_setInt(ClpEntry *ce, int val) { ClpEntry newCe; MAGIC_SET(&newCe); if (ce->test) { newCe.type = clpDtype_int; newCe.storage.ival = val; if (!ce->test(&newCe)) return(FALSE); } clpEntry_free(ce); ce->type = clpDtype_int; ce->storage.ival = val; MAGIC_UNSET(&newCe); return(TRUE); } bool clpEntry_setDouble(ClpEntry *ce, double val) { ClpEntry newCe; MAGIC_SET(&newCe); if (ce->test) { newCe.type = clpDtype_double; newCe.storage.dval = val; if (!ce->test(&newCe)) return(FALSE); } clpEntry_free(ce); ce->type = clpDtype_double; ce->storage.dval = val; MAGIC_UNSET(&newCe); return(TRUE); } bool clpEntry_setStrNum(ClpEntry *ce, const char *val, int num) { ClpEntry newCe; bool testResult; if (ce->test) { assert(num == 0); MAGIC_SET(&newCe); newCe.type = clpDtype_string; newCe.storage.strList = str_createChars(val); newCe.numStrs = 1; testResult = ce->test(&newCe); str_destroy(newCe.storage.strList); MAGIC_UNSET(&newCe); if (!testResult) return(FALSE); } if (ce->type == clpDtype_string) { if (num >= ce->numStrs) { moreStrs(ce, num+1); } str_copyChars(&ce->storage.strList[num], val); } else { assert(num == 0); clpEntry_free(ce); ce->type = clpDtype_string; ce->numStrs = 1; ce->maxStrs = 1; ce->storage.strList = str_createChars(val); } return(TRUE); } static void moreStrs(ClpEntry *ce, int newNumStrs) { Str *newStrs; int i; assert(newNumStrs > ce->numStrs); newStrs = wms_malloc(newNumStrs * sizeof(Str)); for (i = 0; i < ce->numStrs; ++i) { newStrs[i] = ce->storage.strList[i]; } for (; i < newNumStrs; ++i) { str_init(&newStrs[i]); } wms_free(ce->storage.strList); ce->storage.strList = newStrs; } bool clpEntry_setBool(ClpEntry *ce, bool val) { ClpEntry newCe; MAGIC_SET(&newCe); if (ce->test) { newCe.type = clpDtype_bool; newCe.storage.bval = val; if (!ce->test(&newCe)) return(FALSE); } clpEntry_free(ce); ce->type = clpDtype_bool; ce->storage.bval = val; MAGIC_UNSET(&newCe); return(TRUE); } ClpEntry *clp_lookup(Clp *clp, const char *key) { assert(MAGIC(clp)); return(clp_iLookup(clp, key, NULL)); } static ClpEntry *clp_iLookup(Clp *clp, const char *key, bool *bval) { ClpEntry *ci; int i, j, keyLen; bool reversed; assert(MAGIC(clp)); keyLen = strlen(key); reversed = !strncmp(key, "no", 2); if (bval) *bval = TRUE; for (i = 0; i < clp->numInfos; ++i) { ci = &clp->infos[i]; if (ci->name) { for (j = 0; ci->name[j];) { if (!strncmp(ci->name+j, key, keyLen)) { if ((ci->name[j + keyLen] == '\0') || (ci->name[j + keyLen] == ',')) return(ci); } if (reversed && (ci->flags & CLPSETUP_BOOL) && !strncmp(ci->name, key+2, keyLen - 2)) { if (bval) *bval = FALSE; return(ci); } while (ci->name[j] && (ci->name[j] != ',')) ++j; if (ci->name[j]) ++j; } } } if (showErrs) { fprintf(stderr, "%s: \"-%s\" is not a valid flag.\n" " Use \"%s -help\" for a list of valid flags.\n", wms_progname, key, wms_progname); exit(1); } else return(NULL); } static void strip(char *argv[]) { do { argv[0] = argv[1]; ++argv; } while (argv[0] != NULL); } static void clpEntry_free(ClpEntry *ci) { int i; assert(MAGIC(ci)); if (ci->type == clpDtype_string) { for (i = 0; i < ci->maxStrs; ++i) str_deinit(&ci->storage.strList[i]); wms_free(ci->storage.strList); } } static void clp_help(Clp *clp) { int i, j; char name[40]; const char *prestr; assert(MAGIC(clp)); for (i = 0; i < clp->numInfos; ++i) { if (clp->infos[i].desc) { if (clp->infos[i].name) { name[0] = '\0'; if (clp->infos[i].flags & CLPSETUP_SHOWBOOL) prestr = "-[no]"; else prestr = "-"; strcpy(name, prestr); for (j = 0; clp->infos[i].name[j]; ++j) { strncat(name, clp->infos[i].name+j, 1); if (clp->infos[i].name[j] == ',') strcat(name, prestr); } fprintf(stderr, " %20s %s\n", name, clp->infos[i].desc); } else fprintf(stderr, " %s\n", clp->infos[i].desc); } } } static void setStrList(ClpEntry *entry, const char *vals) { int numVals = 1; int i; Str *newStrs; bool escaped; for (i = 0, escaped = FALSE; vals[i]; ++i) { if (!escaped && (vals[i] == '|')) ++numVals; escaped = (!escaped && (vals[i] == '\\')); } if (numVals > entry->maxStrs) { newStrs = wms_malloc(numVals * sizeof(Str)); for (i = 0; i < numVals; ++i) { str_init(&newStrs[i]); } if (entry->storage.strList != NULL) wms_free(entry->storage.strList); entry->maxStrs = numVals; entry->storage.strList = newStrs; } else newStrs = entry->storage.strList; entry->numStrs = numVals; numVals = 0; str_clip(&newStrs[0], 0); for (i = 0, escaped = FALSE; vals[i]; ++i) { if (escaped) { str_catChar(&newStrs[numVals], vals[i]); escaped = FALSE; } else { if (vals[i] == '\\') escaped = TRUE; else if (vals[i] == '|') { ++numVals; assert(numVals < entry->numStrs); str_clip(&newStrs[numVals], 0); } else { str_catChar(&newStrs[numVals], vals[i]); } } } } cgoban-1.9.14/wmslib/src/wms/rnd.c0000664000671000067100000000440207043224472012351 /* * wmslib/src/wms/rnd.c, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include int rnd_int(Rnd *state) { uint result; int destIndent; assert(MAGIC(state)); destIndent = state->indent + RND_INDENT; if (destIndent >= RND_DATASIZE) destIndent -= RND_DATASIZE; result = (state->data[destIndent] += state->data[state->indent]); if (++state->indent >= RND_DATASIZE) state->indent = 0; return((int)(result >> 1)); } uint rnd_uint(Rnd *state) { uint result; int destIndent; assert(MAGIC(state)); destIndent = state->indent + RND_INDENT; if (destIndent >= RND_DATASIZE) destIndent -= RND_DATASIZE; result = (state->data[destIndent] += state->data[state->indent]); if (++state->indent >= RND_DATASIZE) state->indent = 0; return(result); } int32 rnd_int32(Rnd *state) { uint32 result; int destIndent; assert(MAGIC(state)); destIndent = state->indent + RND_INDENT; if (destIndent >= RND_DATASIZE) destIndent -= RND_DATASIZE; result = (state->data[destIndent] += state->data[state->indent]); if (++state->indent >= RND_DATASIZE) state->indent = 0; return((int32)(result >> 1)); } uint32 rnd_uint32(Rnd *state) { uint32 result; int destIndent; assert(MAGIC(state)); destIndent = state->indent + RND_INDENT; if (destIndent >= RND_DATASIZE) destIndent -= RND_DATASIZE; result = (state->data[destIndent] += state->data[state->indent]); if (++state->indent >= RND_DATASIZE) state->indent = 0; return(result); } Rnd *rnd_create(uint seed) { int i; Rnd *state; state = wms_malloc(sizeof(Rnd)); MAGIC_SET(state); state->indent = 0; for (i = 0; i < RND_DATASIZE; ++i) { state->data[i] = seed; seed = seed * 13 + 3; } for (i = 0; i < 100; ++i) rnd_uint32(state); return(state); } void rnd_destroy(Rnd *state) { assert(MAGIC(state)); MAGIC_UNSET(state); wms_free(state); } float rnd_float(Rnd *state) { int result; float out; #if SIZEOF_INT > 2 result = rnd_int(state) & 0xffffff; out = result / 16777216.0; return(out); #else result = rnd_int(state) & 0x7fff; out = result / 32768.0; return(out); #endif } cgoban-1.9.14/wmslib/src/wms/snd.c0000664000671000067100000001615107043224472012356 /* * wmslib/src/wms/snd.c, part of wmslib (Library functions) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include #include #if SUN_SOUND #include #elif LINUX_SOUND #if !HAVE_GETDTABLESIZE #include #endif #include #include #endif #if SUN_SOUND #define sound_dev_name "/dev/audio" #elif LINUX_SOUND #define sound_dev_name "/dev/dsp" #endif #if SUN_SOUND #define SND_PHYSMAXVOL 255 #elif LINUX_SOUND #define SND_PHYSMAXVOL 261 #endif #ifndef SUN_SOUND #define SUN_SOUND 0 #endif #ifndef LINUX_SOUND #define LINUX_SOUND 0 #endif const bool sndAvail = (SUN_SOUND || LINUX_SOUND); static int sound_dev = -1, volume = 0; static SndState state = sndState_off; #if SUN_SOUND static audio_info_t old_ai; #elif LINUX_SOUND static Snd *cvtlist = NULL; static pid_t child; static int ulaw_to_16bit(uchar ulawbyte); static void audio_child(int in, int out); #endif void (*snd_errHandler)(SndInit errType, char *errStr) = NULL; char snd_error[1000] = "Sound functioning properly."; static void snd_deinitChild(void); #if SUN_SOUND || LINUX_SOUND SndInit snd_init(SndState newState, int newVolume) { #if SUN_SOUND audio_info_t ai; #endif /* SUN_SOUND */ SndInit result = sndInit_ok; assert((newVolume >= -1) && (newVolume <= SND_MAXVOL)); if (newVolume >= 0) newVolume = ((newVolume * SND_PHYSMAXVOL + SND_MAXVOL/2) / SND_MAXVOL); if (state == sndState_iOff) return(sndInit_broken); if (state == sndState_iWantOpen) { if (newState == sndState_oldState) newState = sndState_fullOpen; state = sndState_off; } if (newVolume == -1) newVolume = volume; if (volume != newVolume) { if (volume == 0) { if (newState == sndState_oldState) newState = state; state = sndState_off; } #if LINUX_SOUND /* Free up all old converted sound buffers. */ while (cvtlist != NULL) { cvtlist->converted = FALSE; wms_free(cvtlist->cvtdata.dsp); cvtlist = cvtlist->next; } #endif /* LINUX_SOUND */ volume = newVolume; } if (volume == 0) snd_deinit(); if ((newState != sndState_oldState) && (newState != state)) { snd_deinit(); state = newState; if ((volume == 0) || (state < sndState_fullOpen)) { /* * Try to open it, just to make sure that we can. */ sound_dev = open(sound_dev_name, O_WRONLY|O_NDELAY); if (sound_dev != -1) { close(sound_dev); sound_dev = -1; return(result); } } else sound_dev = open(sound_dev_name, O_WRONLY|O_NDELAY); if (sound_dev == -1) { /* Can't open the sound device. Drag. */ if (errno == EBUSY) { result = sndInit_busy; if (state == sndState_fullOpen) state = sndState_iWantOpen; /* Somebody else has it open! Print an error and try again. */ sprintf(snd_error, "Sound device \"%s\" is busy.", sound_dev_name); } else { /* Some other reason...give up forever. */ result = sndInit_broken; volume = 0; state = sndState_iOff; sprintf(snd_error, "Couldn't open sound device \"%s\". " "Error code: \"%s\".", sound_dev_name, strerror(errno)); } return(result); } if (state == sndState_fullOpen) { #if LINUX_SOUND /* Sound device opened successfully. Spawn the audio child. */ int pipes[2], i; pipe(pipes); child = fork(); if (child == 0) { int maxFiles = getdtablesize(); /* * Close off all file descriptors that the audio child doesn't need. */ for (i = 2; i < maxFiles; ++i) { if ((i != pipes[0]) && (i != sound_dev)) close(i); } audio_child(pipes[0], sound_dev); } else { close(pipes[0]); close(sound_dev); sound_dev = pipes[1]; } #endif /* LINUX_SOUND */ } } #if SUN_SOUND /* Cofigure the device for us. */ ioctl(sound_dev, AUDIO_GETINFO, &ai); old_ai = ai; AUDIO_INITINFO(&ai); ai.play.sample_rate = 8000; ai.play.channels = 1; ai.play.precision = 8; ai.play.encoding = AUDIO_ENCODING_ULAW; if (volume != -1) ai.play.gain = (volume * AUDIO_MAX_GAIN + SND_MAXVOL/2) / SND_MAXVOL; if (ioctl(sound_dev, AUDIO_SETINFO, &ai) == -1) { sprintf(snd_error, "Sound device \"%s\" cannot use desired " "data format.", sound_dev_name); result = sndInit_broken; volume = 0; close(sound_dev); state = sndState_iOff; } #endif /* SUN_SOUND */ return(result); } void snd_play(Snd *sound) { if ((volume == 0) || (state <= sndState_off)) return; #if LINUX_SOUND if (!sound->converted) { int i; sound->cvtdata.dsp = wms_malloc(sound->len); sound->cvtlen = sound->len; for (i = 0; i < sound->len; ++i) sound->cvtdata.dsp[i] = ((ulaw_to_16bit(sound->data[i]) * volume) >> 16) + 128; sound->converted = TRUE; sound->next = cvtlist; cvtlist = sound; } #endif /* LINUX_SOUND */ if (state == sndState_partOpen) snd_init(sndState_iTempOpen, -1); if (sound_dev != -1) write(sound_dev, #if SUN_SOUND sound->data, sound->len #elif LINUX_SOUND sound->cvtdata.dsp, sound->cvtlen #endif ); if (state == sndState_iTempOpen) { #if LINUX_SOUND if (sound_dev != -1) ioctl(sound_dev, SNDCTL_DSP_SYNC, NULL); #endif snd_deinitChild(); state = sndState_partOpen; } } void snd_deinit(void) { #if LINUX_SOUND int status; #endif /* LINUX_SOUND */ if ((sound_dev != -1) && (state == sndState_fullOpen)) { #if SUN_SOUND ioctl(sound_dev, AUDIO_SETINFO, &old_ai); #endif /* SUN_SOUND */ close(sound_dev); #if LINUX_SOUND kill(child, SIGKILL); wait(&status); #endif /* LINUX_SOUND */ } sound_dev = -1; } static void snd_deinitChild(void) { if (sound_dev != -1) { #if SUN_SOUND ioctl(sound_dev, AUDIO_SETINFO, &old_ai); #endif /* SUN_SOUND */ close(sound_dev); } sound_dev = -1; } #if LINUX_SOUND static void audio_child(int in, int out) { size_t size_in; char buf[1024*8]; /* 1 second...should be enough! */ /* Make sure that we don't save OUR state! */ signal(SIGTERM, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGPIPE, SIG_DFL); signal(SIGHUP, SIG_DFL); for (;;) { size_in = read(in, buf, 1024*8); if (size_in == 0) exit(0); if (size_in == -1) { perror("Pente sound demon: Error "); exit(1); } write(out, buf, size_in); ioctl(out, SNDCTL_DSP_SYNC, NULL); } } static int ulaw_to_16bit(uchar ulawbyte) { static int exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 }; int sign, exponent, mantissa, sample; ulawbyte = ~ ulawbyte; sign = ( ulawbyte & 0x80 ); exponent = ( ulawbyte >> 4 ) & 0x07; mantissa = ulawbyte & 0x0F; sample = exp_lut[exponent] + ( mantissa << ( exponent + 3 ) ); if ( sign != 0 ) sample = -sample; return sample; } #endif /* LINUX_SOUND */ #else /* No audio. */ SndInit snd_init(SndState newstate, int vol) { sprintf(snd_error, "%s was compiled with sound turned off.", wms_progname); return(sndInit_broken); } void snd_play(Snd *sound) {} void snd_deinit(void) {} #endif /* SUN_SOUND || LINUX_SOUND */ cgoban-1.9.14/wmslib/src/wms/str.c0000664000671000067100000001721707043224472012406 /* * wmslib/src/wms/str.c, part of wmslib (Library functions) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include /********************************************************************** * Global variables **********************************************************************/ static char empty = '\0'; /********************************************************************** * Functions **********************************************************************/ Str *str_create(void) { Str *ret; ret = wms_malloc(sizeof(Str)); MAGIC_SET(ret); ret->len = ret->maxLen = 0; ret->chars = ∅ return(ret); } Str *str_createStr(const Str *s) { Str *ret; ret = wms_malloc(sizeof(Str)); MAGIC_SET(ret); ret->len = ret->maxLen = s->len; ret->chars = wms_malloc(ret->len + 1); strcpy(ret->chars, s->chars); assert(strlen(ret->chars) == ret->len); return(ret); } Str *str_createChars(const char *chars) { Str *ret; ret = wms_malloc(sizeof(Str)); MAGIC_SET(ret); ret->len = ret->maxLen = strlen(chars); ret->chars = wms_malloc(ret->len + 1); strcpy(ret->chars, chars); assert(strlen(ret->chars) == ret->len); return(ret); } Str *str_createChar(char c) { Str *ret; ret = wms_malloc(sizeof(Str)); MAGIC_SET(ret); ret->len = ret->maxLen = 1; ret->chars = wms_malloc(ret->len + 1); ret->chars[0] = c; ret->chars[1] = '\0'; assert(strlen(ret->chars) == ret->len); return(ret); } void str_destroy(Str *s) { assert(MAGIC(s)); if (s->chars != &empty) wms_free(s->chars); MAGIC_UNSET(s); wms_free(s); } void str_init(Str *s) { MAGIC_SET(s); s->len = s->maxLen = 0; s->chars = ∅ } void str_initStr(Str *s, const Str *src) { MAGIC_SET(s); s->len = s->maxLen = src->len; s->chars = wms_malloc(s->len + 1); strcpy(s->chars, src->chars); assert(strlen(s->chars) == s->len); } void str_initChars(Str *s, const char *src) { MAGIC_SET(s); s->len = s->maxLen = strlen(src); s->chars = wms_malloc(s->len + 1); strcpy(s->chars, src); assert(strlen(s->chars) == s->len); } void str_initCharsLen(Str *s, const char *src, int len) { assert(strlen(src) >= len); MAGIC_SET(s); s->len = s->maxLen = len; s->chars = wms_malloc(s->len + 1); strncpy(s->chars, src, len); s->chars[len] = '\0'; assert(strlen(s->chars) == s->len); } void str_deinit(Str *s) { assert(MAGIC(s)); if (s->chars != &empty) wms_free(s->chars); MAGIC_UNSET(s); } void str_copy(Str *dest, const Str *src) { char *newChars; assert(MAGIC(dest)); assert(MAGIC(src)); assert(strlen(src->chars) == src->len); if (src->len > dest->maxLen) { dest->maxLen = src->len * 2; newChars = wms_malloc(dest->maxLen + 1); if (dest->chars != &empty) wms_free(dest->chars); dest->chars = newChars; } strcpy(dest->chars, src->chars); dest->len = src->len; assert(strlen(dest->chars) == dest->len); } void str_copyChars(Str *dest, const char *src) { int srcLen = strlen(src); char *newChars; assert(MAGIC(dest)); if (srcLen > dest->maxLen) { dest->maxLen = srcLen * 2; newChars = wms_malloc(dest->maxLen + 1); if (dest->chars != &empty) wms_free(dest->chars); dest->chars = newChars; } strcpy(dest->chars, src); dest->len = srcLen; assert(strlen(dest->chars) == dest->len); } void str_copyCharsLen(Str *dest, const char *src, int srcLen) { char *newChars; assert(MAGIC(dest)); assert(strlen(src) >= srcLen); if (srcLen > dest->maxLen) { dest->maxLen = srcLen * 2; newChars = wms_malloc(dest->maxLen + 1); if (dest->chars != &empty) wms_free(dest->chars); dest->chars = newChars; } strncpy(dest->chars, src, srcLen); dest->chars[dest->len = srcLen] = '\0'; assert(strlen(dest->chars) == dest->len); } void str_copyChar(Str *dest, char src) { char *newChars; assert(MAGIC(dest)); if (1 > dest->maxLen) { dest->maxLen = 32; newChars = wms_malloc(dest->maxLen + 1); if (dest->chars != &empty) wms_free(dest->chars); dest->chars = newChars; } dest->chars[0] = src; dest->chars[1] = '\0'; dest->len = 1; assert(src != '\0'); } void str_cat(Str *dest, const Str *src) { char *newChars; assert(MAGIC(dest)); assert(MAGIC(src)); assert(strlen(dest->chars) == dest->len); assert(strlen(src->chars) == src->len); if (dest->len + src->len > dest->maxLen) { dest->maxLen = (dest->len + src->len) * 2; newChars = wms_malloc(dest->maxLen + 1); strcpy(newChars, dest->chars); if (dest->chars != &empty) wms_free(dest->chars); dest->chars = newChars; } strcpy(dest->chars + dest->len, src->chars); dest->len += src->len; assert(strlen(dest->chars) == dest->len); } void str_catChars(Str *dest, const char *src) { int srcLen = strlen(src); char *newChars; assert(MAGIC(dest)); assert(strlen(dest->chars) == dest->len); if (dest->len + srcLen > dest->maxLen) { dest->maxLen = (dest->len + srcLen) * 2; newChars = wms_malloc(dest->maxLen + 1); strcpy(newChars, dest->chars); if (dest->chars != &empty) wms_free(dest->chars); dest->chars = newChars; } strcpy(dest->chars + dest->len, src); dest->len += srcLen; } void str_catCharsLen(Str *dest, const char *src, int srcLen) { char *newChars; assert(MAGIC(dest)); assert(strlen(dest->chars) == dest->len); assert(strlen(src) >= srcLen); if (dest->len + srcLen > dest->maxLen) { dest->maxLen = (dest->len + srcLen) * 2; newChars = wms_malloc(dest->maxLen + 1); strcpy(newChars, dest->chars); if (dest->chars != &empty) wms_free(dest->chars); dest->chars = newChars; } strncpy(dest->chars + dest->len, src, srcLen); dest->len += srcLen; dest->chars[dest->len] = '\0'; } void str_catChar(Str *dest, char src) { char *newChars; assert(MAGIC(dest)); assert(strlen(dest->chars) == dest->len); if (dest->len + 1 > dest->maxLen) { dest->maxLen = (dest->len + 1) * 2; newChars = wms_malloc(dest->maxLen + 1); strcpy(newChars, dest->chars); if (dest->chars != &empty) wms_free(dest->chars); dest->chars = newChars; assert(strlen(dest->chars) == dest->len); } dest->chars[dest->len++] = src; dest->chars[dest->len] = '\0'; assert(strlen(dest->chars) == dest->len); } void str_catInt(Str *dest, int src) { char srcChars[SIZEOF_INT * 3 + 1]; assert(MAGIC(dest)); sprintf(srcChars, "%d", src); str_catChars(dest, srcChars); } void str_print(Str *dest, const char *fmt, ...) { va_list ap; char tmp[40]; static char tmpFmt[] = "%0xd"; double dval; const char *sVal; assert(MAGIC(dest)); str_copyChars(dest, ""); va_start(ap, fmt); while (*fmt) { if (*fmt != '%') str_catChar(dest, *fmt); else { ++fmt; switch(*fmt) { case '0': assert(fmt[2] == 'd'); tmpFmt[2] = fmt[1]; sprintf(tmp, tmpFmt, va_arg(ap, int)); str_catChars(dest, tmp); fmt += 2; break; case 'c': str_catChar(dest, (char)va_arg(ap, int)); break; case 'd': str_catInt(dest, va_arg(ap, int)); break; case 'g': dval = va_arg(ap, double); if ((int)dval == dval) { sprintf(tmp, "%d", (int)dval); } else { sprintf(tmp, "%.1f", dval); } str_catChars(dest, tmp); break; case 's': sVal = va_arg(ap, char *); assert(sVal != NULL); str_catChars(dest, sVal); break; default: str_catChar(dest, *fmt); break; } } ++fmt; } va_end(ap); } int str_alphaCmp(const void *a, const void *b) { const Str *sa = a, *sb = b; assert(MAGIC(sa)); assert(MAGIC(sb)); return(strcmp(sa->chars, sb->chars)); } cgoban-1.9.14/src/0000777000671000067100000000000007606355255007412 5cgoban-1.9.14/src/arena.h0000664000671000067100000000160707043224470010560 /* * src/arena.h, part of Complete Goban (game program) * Copyright (C) 1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _ARENA_H_ #ifndef _GMP_ENGINE_H_ #include "gmp/engine.h" #endif #ifndef _GOGAME_H_ #include "goGame.h" #endif #ifdef _ARENA_H_ Levelization Error. #endif #define _ARENA_H_ 1 /********************************************************************** * Data Types **********************************************************************/ typedef struct Arena_struct { Cgoban *cg; GmpEngine engines[2]; GoGame *game; MAGIC_STRUCT } Arena; /********************************************************************** * Functions **********************************************************************/ extern void arena(Cgoban *cg, const char *prog1, const char *prog2, int size, float komi, int handicap); #endif cgoban-1.9.14/src/cgbuts.h0000664000671000067100000001223007476005006010755 /* * $Source: /cvsroot/cgoban1/cgoban1/src/cgbuts.h,v $ * $Revision: 1.2 $ * $Author: wmshub $ * $Date: 2002/05/31 23:40:54 $ * * src/cgbuts.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CGBUTS_H_ #define _CGBUTS_H_ 1 #ifndef _GOBOARD_H_ #include "goBoard.h" #endif #ifndef _BUT_BUT_H_ #include #endif /********************************************************************** * Constants **********************************************************************/ #define CGBUTS_COLORBG1 (BUT_DCOLORS+0) #define CGBUTS_COLORBG2 (BUT_DCOLORS+1) #define CGBUTS_COLORBGLIT1 (BUT_DCOLORS+2) #define CGBUTS_COLORBGLIT2 (BUT_DCOLORS+3) #define CGBUTS_COLORBGSHAD1 (BUT_DCOLORS+4) #define CGBUTS_COLORBGSHAD2 (BUT_DCOLORS+5) #define CGBUTS_COLORREDLED (BUT_DCOLORS+6) #define CGBUTS_GREY(n) (BUT_DCOLORS+7+(n)) #define CGBUTS_COLORBOARD(n) (BUT_DCOLORS+7+256+(n)) #define CGBUTS_NUMCOLORS (COLOR_BOARD(256)) #define CGBUTS_REWCHAR "\1\1" #define CGBUTS_BACKCHAR "\1\2" #define CGBUTS_FWDCHAR "\1\3" #define CGBUTS_FFCHAR "\1\4" #define CGBUTS_WSTONECHAR "\1\5" #define CGBUTS_BSTONECHAR "\1\6" #define CGBUTS_NUMWHITE 5 #define CGBUTS_YINYANG(x) (CGBUTS_NUMWHITE+(x)) #define CGBUTS_WORLDWEST(x) (CGBUTS_YINYANG(CGBUTS_NUMWHITE)+(x)) #define CGBUTS_WORLDEAST(x) (CGBUTS_WORLDWEST(CGBUTS_NUMWHITE)+(x)) #define CGBUTS_HOLDTIME 500 /* ms */ /********************************************************************** * Data types **********************************************************************/ typedef struct CgbutsPics_struct { Pixmap stonePixmaps; Pixmap maskBitmaps; } CgbutsPic; typedef struct Cgbuts_struct { ButEnv *env; int dpyDepth; Window dpyRootWindow; int numPics; CgbutsPic *pics; Rnd *rnd; int color; /* TrueColor, PseudoColor, or GrayScale. */ bool hiContrast; bool holdEnabled; Time holdStart; int timeWarn; MAGIC_STRUCT } Cgbuts; typedef enum { goMark_none, goMark_lastMove, goMark_ko, goMark_triangle, goMark_x, goMark_square, goMark_circle, goMark_letter, goMark_number, goMark_smWhite, goMark_smBlack } GoMarkType; #define goMark_max (goMark_ko + 1) typedef enum { gridLines_ul, gridLines_top, gridLines_ur, gridLines_left, gridLines_center, gridLines_right, gridLines_ll, gridLines_bottom, gridLines_lr, gridLines_none } GridLines; typedef struct Grid_struct { Cgbuts *b; ButOut (*callback)(But *but); GridLines lineGroup; bool starPoint; int pos; GoStone ptype; /* The piece at this point on the board. */ GoStone pressColor; /* The color to add when this button is pressed. */ int stoneVersion; bool grey, holdRequired; GoMarkType markType; int markAux; MAGIC_STRUCT } Grid; /********************************************************************** * Global Variables **********************************************************************/ extern const char *cgbuts_stoneChar[2]; /********************************************************************** * Functions **********************************************************************/ extern void cgbuts_init(Cgbuts *cgbuts, ButEnv *env, Rnd *rnd, int color, bool hold, bool hiContrast, int timeWarn); extern But *grid_create(Cgbuts *b, ButOut (*func)(But *but), void *packet, ButWin *win, int layer, int flags, int pos); extern void grid_setStone(But *but, GoStone piece, bool grey); extern void grid_setMark(But *but, GoMarkType markType, int markAux); extern void grid_setPress(But *but, GoStone pressColor); #define grid_setHold(b, h) (((Grid *)((b)->iPacket))->holdRequired = (h)) #define grid_pressColor(b) (((Grid *)((b)->iPacket))->pressColor) #define grid_setLineGroup(b, g) (((Grid *)((b)->iPacket))->lineGroup = (g)) #define grid_setStarPoint(b, s) (((Grid *)((b)->iPacket))->starPoint = (s)) #define grid_pos(b) (((Grid *)((b)->iPacket))->pos) #define grid_stone(b) (((Grid *)((b)->iPacket))->ptype) #define grid_grey(b) (((Grid *)((b)->iPacket))->grey) #define grid_markType(b) (((Grid *)((b)->iPacket))->markType) #define grid_markAux(b) (((Grid *)((b)->iPacket))->markAux) #define grid_setVersion(b, v) (((Grid *)((b)->iPacket))->stoneVersion = v) #define goMarkType_stone2sm(s) \ ((GoMarkType)((s - goStone_white) + goMark_smWhite)) extern But *gobanPic_create(Cgbuts *b, ButWin *win, int layer, int flags); extern But *stoneGroup_create(Cgbuts *b, ButWin *win, int layer, int flags); extern But *computerPic_create(Cgbuts *b, ButWin *win, int layer, int flags); extern But *toolPic_create(Cgbuts *b, ButWin *win, int layer, int flags); extern void cgbuts_redraw(Cgbuts *b); /* Functions only for "friend" routines. */ extern void cgbuts_drawp(Cgbuts *b, ButWin *win, GoStone piece, bool grey, int x, int y, int size, int stoneVersion, int dx, int dy, int dw, int dh); extern void cgbuts_markPiece(Cgbuts *b, ButWin *win, GoStone piece, GoMarkType markType, int markAux, int x, int y, int w, int stoneVersion, int dx,int dy, int dw,int dh); #endif /* _CGBUTS_H_ */ cgoban-1.9.14/src/cgoban.h0000664000671000067100000000354607043224470010727 /* * src/cgoban.h, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CGOBAN_H_ #ifndef _WMS_STR_H_ #include #endif #ifndef _CGBUTS_H_ #include "cgbuts.h" #endif #ifndef _WMS_CLP_H_ #include #endif #ifndef _ABUT_H_ #include #endif #ifndef _BUT_BUT_H_ #include #endif #ifndef _ABUT_HELP_H_ #include #endif #ifndef _HELP_H_ #include "help.h" #endif #ifndef _ABUT_MSG_H_ #include #endif #ifdef _CGOBAN_H_ #error Levelization Error. #endif #define _CGOBAN_H_ 1 /********************************************************************** * Data types **********************************************************************/ typedef struct Cgoban_struct { char **envp; /* This is the original envp passed to main(). */ Clp *clp; ButEnv *env; Abut *abut; AbutHelp *help; int rcMajor, rcMinor, rcBugFix; Str lastDirAccessed; int fontH; bool markLastMove, markHotStones; bool showCoords; Pixmap boardPixmap, bgPixmap, bgLitPixmap, bgShadPixmap; Rnd *rnd; Cgbuts cgbuts; MAGIC_STRUCT } Cgoban; /********************************************************************** * Globals **********************************************************************/ extern const ButKey cg_return[]; extern const ButKey cg_help[]; /********************************************************************** * Functions **********************************************************************/ extern Cgoban *cgoban_create(int argc, char *argv[], char *envp[]); extern void cgoban_destroy(Cgoban *cg); #define cgoban_createMsgWindow(cg, title, message) \ abutMsg_winCreate((cg)->abut, (title), (message)) ButOut cgoban_createHelpWindow(But *but); #endif /* _CGOBAN_H_ */ cgoban-1.9.14/src/cm2pm.h0000664000671000067100000000143407043224470010506 /* * src/cm2pm.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CM2PM_H_ #define _CM2PM_H_ 1 /********************************************************************** * Constants **********************************************************************/ /********************************************************************** * Functions **********************************************************************/ extern Pixmap cm2Pm(ButEnv *env, uchar *cmap, uint cmapw,uint cmaph, uint w,uint h, int pic0, int npic, bool flat); extern void cm2OldPm(ButEnv *env, uchar *cmap, uint cmapw,uint cmaph, int pic0, int npic, Pixmap pic, bool flat); #endif /* _CM2PM_H_ */ cgoban-1.9.14/src/control.h0000664000671000067100000000173607043224470011155 /* * src/control.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CONTROL_H_ #define _CONTROL_H_ 1 #ifndef _SETUP_H_ #include "setup.h" #endif /********************************************************************** * Data types **********************************************************************/ typedef struct Control_struct { Cgoban *cg; ButWin *win; But *box; But *sPics[2], *servers[2]; But *lGame, *lGamePic; But *lLoad, *lLoadPic; But *edit, *editPic; But *gmp, *gmpPic; But *sBox; Setup *setupWin; But *help, *setup, *quit; ButWin *iWin; But *iBg, *ig; MAGIC_STRUCT } Control; /********************************************************************** * Functions **********************************************************************/ extern Control *control_create(Cgoban *cg, bool iconic); #endif /* _CONTROL_H_ */ cgoban-1.9.14/src/crwin.h0000664000671000067100000000133407043224470010611 /* * src/crwin.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CRWIN_H_ #define _CRWIN_H_ 1 /********************************************************************** * Data types **********************************************************************/ typedef struct { ButEnv *env; But *box, *title, *byBill, *noWarr, *seeHelp; ButTimer *timer; MAGIC_STRUCT } Crwin; /********************************************************************** * Functions **********************************************************************/ Crwin *crwin_create(Cgoban *cg, ButWin *win, int layer); #endif /* _CRWIN_H_ */ cgoban-1.9.14/src/drawStone.h0000664000671000067100000000176307043224470011443 /* * src/drawStone.h, part of Complete Goban (game program) * Copyright (C) 1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _DRAWSTONE_H_ #ifdef _DRAWSTONE_H_ Levelization Error. #endif #define _DRAWSTONE_H_ 1 /********************************************************************** * Constants **********************************************************************/ #define DRAWSTONE_NUMWHITE 5 #define DRAWSTONE_YINYANG(x) (DRAWSTONE_NUMWHITE+(x)) #define DRAWSTONE_WORLDWEST(x) (DRAWSTONE_YINYANG(DRAWSTONE_NUMWHITE)+(x)) #define DRAWSTONE_WORLDEAST(x) (DRAWSTONE_WORLDWEST(DRAWSTONE_NUMWHITE)+(x)) /********************************************************************** * Functions **********************************************************************/ extern void drawStone_newPics(ButEnv *env, Rnd *rnd, int baseColor, Pixmap *stonePixmap, Pixmap *maskBitmap, int size, bool color); #endif /* _DRAWSTONE_H_ */ cgoban-1.9.14/src/editBoard.h0000664000671000067100000000275007043224470011367 /* * src/editBoard.h, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _EDITBOARD_H_ #ifndef _CGOBAN_H_ #include "cgoban.h" #endif #ifndef _SGF_H_ #include "sgf.h" #endif #ifndef _GOGAME_H_ #include "goGame.h" #endif #ifndef _GOBAN_H_ #include "goban.h" #endif #ifndef _EDITTOOL_H_ #include "editTool.h" #endif #ifndef _ABUT_FSEL_H_ #include #endif #ifndef _EDITINFO_H_ #include "editInfo.h" #endif #ifdef _EDITBOARD_H_ Levelization Error. #endif #define _EDITBOARD_H_ 1 /********************************************************************** * Data types **********************************************************************/ typedef struct EditBoard_struct { Cgoban *cg; Str fName; bool modified; AbutFsel *fsel; AbutMsg *reallyQuit; Sgf *sgf; int currentNodeNum; GoGame *game; Goban *goban; SgfElem *lastComment; EditToolWin tools; EditTool oldTool; But *shiftKeytrap, *prevVar, *nextVar; bool invertShift; /* Kludgey. :-( */ EditInfo *info; MAGIC_STRUCT } EditBoard; /********************************************************************** * Functions **********************************************************************/ EditBoard *editBoard_create(Cgoban *cg, const char *fName); EditBoard *editBoard_createSgf(Cgoban *cg, const Sgf *sgf); void editBoard_destroy(EditBoard *eb); #endif /* _EDITBOARD_H_ */ cgoban-1.9.14/src/editInfo.h0000664000671000067100000000331407043224470011230 /* * src/editInfo.h, part of Complete Goban (game program) * Copyright (C) 1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _EDITINFO_H_ #ifndef _CGOBAN_H_ #include "cgoban.h" #endif #ifndef _ABUT_TERM_H_ #include #endif #ifndef _GOBAN_H_ #include "goban.h" #endif #ifdef _EDITINFO_H_ Levelization Error. #endif #define _EDITINFO_H_ 1 /********************************************************************** * Data Types **********************************************************************/ typedef enum { editInfo_gameTitle, editInfo_copyright, editInfo_wName, editInfo_bName, editInfo_wRank, editInfo_bRank, editInfo_handicap, editInfo_komi, editInfo_time, editInfo_result, editInfo_date, editInfo_place, editInfo_event, editInfo_source, editInfo_count } EditInfoVal; typedef struct EditInfo_struct { Cgoban *cg; Goban *goban; ButWin *win; But *bg; Sgf *sgf; But *winTitle; struct { But *name, *in; } infos[editInfo_count]; AbutTerm *gameComment; void (*destroy)(struct EditInfo_struct *info, void *packet); void *packet; MAGIC_STRUCT } EditInfo; /********************************************************************** * Functions **********************************************************************/ #define editInfoVal_iter(v) \ for ((v) = editInfo_gameTitle; (v) < editInfo_count; ++(v)) extern EditInfo *editInfo_create(Cgoban *cg, Goban *goban, Sgf *sgf, void (*dCallback)(EditInfo *info, void *packet), void *packet); extern void editInfo_destroy(EditInfo *info, bool propagate); extern void editInfo_updateSgf(EditInfo *info); #endif cgoban-1.9.14/src/editTool.h0000664000671000067100000000451207050207032011244 /* * $Source: /cvsroot/cgoban1/cgoban1/src/editTool.h,v $ * $Revision: 1.2 $ * $Date: 2000/02/09 06:50:02 $ * * src/editTool.h, part of Complete Goban (game program) * Copyright © 1995,2000 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _EDITTOOL_H_ #define _EDITTOOL_H_ 1 #ifndef _CGOBAN_H_ #include "cgoban.h" #endif #ifndef _SGF_H_ #include "sgf.h" #endif /********************************************************************** * Data types **********************************************************************/ typedef enum { editTool_play, editTool_changeBoard, editTool_score, editTool_triangle, editTool_square, editTool_circle, editTool_letter, editTool_number } EditTool; #define editTool_min editTool_play #define editTool_max (editTool_number + 1) typedef struct EditToolWin_struct { Cgoban *cg; bool modified; ButWin *toolWin, *toolIWin; AbutSwin *mapWin; But *toolBg, *toolIBg, *toolIPic; But *toolSel, *selDesc[editTool_max]; But *toolBox, *toolName, *toolDesc1, *toolDesc2; But *help, *killNode, *moveNode; But *mapBg, *sgfMap, *prevVar, *nextVar; EditTool tool; GoStone lastColor; /* Color of the editTool_play icon. */ Sgf *sgf; void (*quitRequested)(void *packet); ButOut (*newToolCallback)(void *packet); ButOut (*mapCallback)(void *packet, int nodeNum); void *packet; MAGIC_STRUCT } EditToolWin; /********************************************************************** * Functions **********************************************************************/ extern void editToolWin_init(EditToolWin *etw, Cgoban *cg, Sgf *sgf, void (*quitRequested)(void *packet), ButOut (*newToolCallback)(void *packet), ButOut (*newActiveNode)(void *packet, int nodeNum), void *packet); extern void editToolWin_deinit(EditToolWin *etw); extern void editToolWin_newColor(EditToolWin *etw, GoStone color); extern void editToolWin_newTool(EditToolWin *etw, EditTool tool, bool propagate); extern void editToolWin_newActiveNode(EditToolWin *etw, SgfElem *newNode); extern void editToolWin_nodeAdded(EditToolWin *etw, SgfElem *newNode); extern ButOut editToolWin_shiftUpPressed(But *but, bool press); extern ButOut editToolWin_shiftDownPressed(But *but, bool press); #endif /* _EDITTOOL_H_ */ cgoban-1.9.14/src/gameSetup.h0000664000671000067100000000372707043224470011431 /* * src/lsetup.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GAMESETUP_H_ #define _GAMESETUP_H_ 1 #ifndef _GOGAME_H_ #include "goGame.h" #endif #ifndef _GOTIME_H_ #include "goTime.h" #endif /********************************************************************** * Data types **********************************************************************/ typedef struct GameSetup_struct { Cgoban *cg; void (*callback)(void *packet, struct GameSetup_struct *gs); void *packet; ButWin *win; But *bg; But *title; But *namesBox; But *wStr, *wIn; But *bStr, *bIn; But *rulesBox; But *rulesMenu; But *sizeStr, *sizeIn; But *hcapStr, *hcapIn; But *komiStr, *komiIn; GoRules rules; int size, hcap; float komi; bool sizeSet, hcapSet, komiSet; But *timeBox; But *timeMenu; But *mainStr, *mainIn; But *byStr, *byIn; But *auxStr, *auxIn; GoTimeType timeType; int numTimeArgs, mainTime, byTime, aux; But *help, *ok, *cancel; MAGIC_STRUCT } GameSetup; /********************************************************************** * Functions **********************************************************************/ extern GameSetup *gameSetup_create(Cgoban *cg, void (*callback)(void *packet, GameSetup *gs), void *packet); extern void gameSetup_destroy(GameSetup *ls); #define gameSetup_rules(gs) ((gs)->rules) #define gameSetup_size(gs) ((gs)->size) #define gameSetup_handicap(gs) ((gs)->hcap) #define gameSetup_komi(gs) ((gs)->komi) #define gameSetup_wName(gs) (butTextin_get((gs)->wIn)) #define gameSetup_bName(gs) (butTextin_get((gs)->bIn)) #define gameSetup_timeType(gs) ((gs)->timeType) #define gameSetup_mainTime(gs) ((gs)->mainTime) #define gameSetup_byTime(gs) ((gs)->byTime) #define gameSetup_timeAux(gs) ((gs)->aux) #endif /* _GAMESETUP_H_ */ cgoban-1.9.14/src/goBoard.h0000664000671000067100000000743707043224470011056 /* * src/goboard.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GOBOARD_H_ #define _GOBOARD_H_ 1 #ifndef _GOHASH_H_ #include "goHash.h" #endif /********************************************************************** * Constants **********************************************************************/ #define GOBOARD_MAXSIZE 38 /********************************************************************** * Data types **********************************************************************/ typedef enum { goStone_white, goStone_black, goStone_edge, goStone_empty } GoStone; typedef struct GoBoardPiece_struct { GoStone type; int libs, size; struct GoBoardPiece_struct *head, *tail, *next; GoHash hashStone[goStone_black+1], hashKo[goStone_black+1]; } GoBoardPiece; typedef struct { int area, dirs[4]; GoBoardPiece *pieces; int caps[2]; GoHash hashVal; int koLoc; MAGIC_STRUCT } GoBoard; /********************************************************************** * Iterators **********************************************************************/ #define goStoneIter(s) for ((s) = goStone_white; \ (s) <= goStone_black; \ ++(s)) typedef GoBoardPiece *GoBoardGroupIter; #define goBoardGroupIter(i, b, l) for ((i) = ((b)->pieces[loc].head); \ (i); \ (i) = (i)->next) #define goBoardGroupIter_loc(i, b) ((i) - &(b)->pieces[0]) /********************************************************************** * Functions **********************************************************************/ #define goStone_isStone(t) ((t) <= goStone_black) #define goStone_char(t) ("WB#."[t]) #define goStone_opponent(s) (goStone_white + goStone_black - (s)) extern GoBoard *goBoard_create(int size); extern void goBoard_destroy(GoBoard *board); /* * For goBoard_copy, the sizes of src and dest must be the same. */ extern void goBoard_copy(GoBoard *src, GoBoard *dest); extern bool goBoard_eq(GoBoard *b1, GoBoard *b2); extern void goBoard_print(GoBoard *b); extern void goBoard_fprint(GoBoard *b, FILE *fnum); #define goBoard_xy2Loc(b,x,y) ((x)+(y)*(b)->dirs[0]+(b)->dirs[0]+1) extern void goBoard_loc2Str(GoBoard *board, int loc, char *str); extern int goBoard_str2Loc(GoBoard *board, const char *str); #define goBoard_loc2X(b,l) (((l)%(b)->dirs[0])-1) #define goBoard_loc2Y(b,l) (((l)/(b)->dirs[0])-1) extern const char *goBoard_loc2Sgf(GoBoard *b, int l); extern int goBoard_sgf2Loc(GoBoard *b, const char *l); #define goBoard_size(b) ((b)->dirs[0] - 1) #define goBoard_width(b) ((b)->dirs[0]) #define goBoard_area(b) ((b)->area) #define goBoard_minLoc(b) ((b)->dirs[0]) #define goBoard_maxLoc(b) ((b)->area - (b)->dirs[0]) #define goBoard_dir(b, d) ((b)->dirs[d]) #define goBoard_stone(b, l) ((b)->pieces[l].type) #define goBoard_koLoc(b) ((b)->koLoc) #define goBoard_hash(b) ((b)->hashVal) #define goBoard_hashNoKo(b, s) goHash_xor((b)->hashVal, \ (b)->pieces[(b)->koLoc].hashKo[s]) #define goBoard_caps(b, p) ((b)->caps[p]) #define goBoard_addCaps(b, p, s) (((b)->caps[p]) += s) #define goBoard_liberties(b, l) ((b)->pieces[l].head->libs) #define goBoard_groupSize(b, l) ((b)->pieces[l].head->size) #define goBoard_groupEq(b, l1, l2) ((b)->pieces[l1].head == \ (b)->pieces[l2].head) /* goBoard_addStone(...) returns the number of stones captured. */ extern int goBoard_addStone(GoBoard *board, GoStone stone, int loc, int *suicides); extern void goBoard_rmGroup(GoBoard *board, int loc); /* quickHash() always returns the hashNoKo value. */ extern GoHash goBoard_quickHash(GoBoard *board, GoStone stone, int loc, bool *suicide); #endif /* _GOBOARD_H_ */ cgoban-1.9.14/src/goGame.h0000664000671000067100000001320607043224470010667 /* * src/gogame.h, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GOGAME_H_ #define _GOGAME_H_ 1 #ifndef _GOHASH_H_ #include "goHash.h" #endif #ifndef _GOBOARD_H_ #include "goBoard.h" #endif #ifndef _GOTIME_H_ #include "goTime.h" #endif /********************************************************************** * Constants **********************************************************************/ #define GOGAME_PASS 0 /********************************************************************** * Data types **********************************************************************/ typedef enum { goRules_chinese, goRules_japanese, goRules_ing, goRules_aga, goRules_nz, goRules_tibetan } GoRules; #define goRules_num ((int)goRules_tibetan + 1) typedef enum { goRulesKo_japanese, goRulesKo_super, goRulesKo_tibetan /* * goRulesKo_ing is longer supported since it can't be implemented * accurately by a computer without lots of help from the players. */ } GoRulesKo; typedef enum { goGameState_play, goGameState_dispute, goGameState_selectDead, goGameState_selectDisputed, goGameState_done } GoGameState; #define GOGAMEFLAGS_DISPUTED 0x0001 #define GOGAMEFLAGS_MARKDEAD 0x0002 #define GOGAMEFLAGS_WANTDEAD 0x0004 #define GOGAMEFLAGS_RESOLVEDEAD 0x0008 #define GOGAMEFLAGS_RESOLVEALIVE 0x0010 #define GOGAMEFLAGS_SEEWHITE 0x0020 #define GOGAMEFLAGS_SEEBLACK 0x0040 #define GOGAMEFLAGS_SEKI 0x0080 #define GOGAMEFLAGS_NOSEKI 0x0100 #define GOGAMEFLAGS_SPECIAL 0x0200 /* For seki detection. */ #define GOGAMEFLAGS_EYE 0x0400 /* For seki detection. */ #define GOGAMEFLAGS_FAKETEST 0x0800 /* For seki detection. */ #define GOGAMEFLAGS_NOTFAKE 0x1000 /* For seki detection. */ #define GOGAMEFLAGS_RESOLVED (GOGAMEFLAGS_RESOLVEDEAD| \ GOGAMEFLAGS_RESOLVEALIVE) #define GOGAMEFLAGS_SEEN (GOGAMEFLAGS_SEEBLACK|GOGAMEFLAGS_SEEWHITE) #define goGameFlags_see(s) (GOGAMEFLAGS_SEEWHITE << (s)) typedef struct GoGameMove_struct { int move; GoStone color; GoHash hash; /* Hash value at the beginning of this move. */ GoTimer time; /* Time left at this move. */ } GoGameMove; typedef struct { int size; GoRules rules; /* * Passive and forcePlay are somewhat redundant. I should clean them up. * But basically, passive means it is controlled by the SGF, and * forcePlay means go server. Yuck. */ bool passive; bool forcePlay; float komi; GoTime time; int moveNum, maxMoves, handicap, passCount; GoGameMove *moves; int movesLen; bool noLastMove; GoStone whoseMove; GoBoard *board; GoBoard *tmpBoard; /* Used for superko rule and seki checks. */ uint *flags; bool flagsCleared; int *hotMoves; int cooloff; /* The last move that cleared the kos. */ GoGameState state; bool disputeAlive; int setWhoseMoveNum; GoStone setWhoseMoveColor; int disputedLoc; MAGIC_STRUCT } GoGame; /********************************************************************** * Global variables **********************************************************************/ extern const bool goRules_freeHandicaps[goRules_num]; extern const GoRulesKo goRules_ko[goRules_num]; extern const bool goRules_suicide[goRules_num]; extern const bool goRules_dispute[goRules_num]; extern const bool goRules_scoreKills[goRules_num]; /********************************************************************** * Functions **********************************************************************/ extern GoGame *goGame_create(int size, GoRules rules, int handicap, float komi, const GoTime *time, bool passive); extern void goGame_destroy(GoGame *game); /* * Valid in the play or dispute states. */ /* * goGame_move() returns TRUE if the move caused the game's state to change. * Possible changes: * play --> selectDead * dispute --> selectDead * play, dispute --> done (for time-out losses only, move will not be made) */ extern bool goGame_move(GoGame *game, GoStone color, int move, GoTimer *currentTime); extern void goGame_setBoard(GoGame *game, GoStone color, int loc); #define goGame_pass(g, color, t) goGame_move((g), color, GOGAME_PASS, t) #define goGame_isHot(g, l) ((g)->hotMoves[l] >= (g)->cooloff) #define goGame_whoseMove(g) ((g)->whoseMove) extern GoStone goGame_whoseTurnOnMove(GoGame *game, int moveNum); extern const GoTimer *goGame_getTimer(const GoGame *game, GoStone color); /* * Valid in play, dispute, or done states. Returns TRUE if the game's state * has changed, just like goGame_move. * Possible changes: * play --> done * done --> play */ extern bool goGame_moveTo(GoGame *game, int moveNum); /* * Valid in the selectDead state. */ extern void goGame_markDead(GoGame *game, int loc); /* * resume() will change state from selectDead to play. */ extern void goGame_resume(GoGame *game); /* * done() will change state from selectDead to done. */ extern void goGame_done(GoGame *game); /* * selectDisputed() will change state from selectDead to selectDisputed. */ #define goGame_selectDisputed(g) ((g)->state = goGameState_selectDisputed) /* * dispute() will change state from selectDisputed to dispute. */ extern void goGame_dispute(GoGame *game, int loc); /* * Always valid. */ extern bool goGame_isLegal(GoGame *game, GoStone moveColor, int move); #define goGame_caps(g, s) goBoard_caps((g)->board, (s)) extern int goGame_lastMove(GoGame *g); #define goGame_noLastMove(g) ((g)->noLastMove = TRUE) #endif /* _GOGAME_H_ */ cgoban-1.9.14/src/goHash.h0000664000671000067100000000311607043224470010700 /* * src/gohash.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GOHASH_H_ #define _GOHASH_H_ 1 #ifndef _WMS_RND_H_ #include #endif /********************************************************************** * Data types **********************************************************************/ #if SIZEOF_LONG >= 8 #define GoHash_isScalar 1 typedef ulong GoHash; #elif SIZEOF_LONG_LONG >= 8 #define GoHash_isScalar 1 typedef unsigned long long GoHash; #else #define GoHash_isScalar 0 typedef struct { uint32 lo, hi; } GoHash; #endif /********************************************************************** * Global variables **********************************************************************/ extern const GoHash goHash_zero; extern const GoHash goHash_pass; /********************************************************************** * Functions **********************************************************************/ /* In all of these functions, passing zero as the "loc" means a pass. */ GoHash goHash_init(Rnd *r); #if GoHash_isScalar #define goHash_xor(v1, v2) ((v1) ^ (v2)) #define goHash_eq(v1, v2) ((v1) == (v2)) #define goHash_loBits(v, m) ((v) & (m)) #define goHash_print(v) printf("0x%x%08x",(int)(v>>32),(int)v) #else extern GoHash goHash_xor(GoHash v1, GoHash v2); #define goHash_eq(v1, v2) (((v1).lo == (v2).lo) && ((v1).hi == (v2).hi)) #define goHash_loBits(v, m) ((v).lo & (m)) #endif /* GoHash_isScalar */ #endif /* _GOHASH_H_ */ cgoban-1.9.14/src/goPic.h0000664000671000067100000000321407043224470010527 /* * src/gopic.h, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GOPIC_H_ #ifndef _GOGAME_H_ #include "goGame.h" #endif #ifndef _CGOBAN_H_ #include "cgoban.h" #endif #ifdef _GOPIC_H_ Levelization Error #endif #define _GOPIC_H_ 1 /********************************************************************** * Data types **********************************************************************/ typedef enum GoPicMoves_enum { goPicMove_legal = 0x01, goPicMove_empty = 0x02, goPicMove_stone = 0x04, goPicMove_forceWhite = 0x08, goPicMove_forceBlack = 0x10, goPicMove_noPass = 0x20, goPicMove_noWhite = 0x40, goPicMove_noBlack = 0x80 } GoPicMoves; typedef struct GoPic_struct { Cgoban *cg; GoGame *game; ButOut (*press)(void *packet, int loc); void *packet; int size; /* You must call goPic_update after changing this value. */ GoPicMoves allowedMoves; But *boardBg; But **boardButs; But **letters, **numbers; MAGIC_STRUCT } GoPic; /********************************************************************** * Functions **********************************************************************/ extern GoPic *goPic_create(Cgoban *cg, void *packet, GoGame *game, ButWin *win, int layer, ButOut pressed(void *packet, int loc), int size); extern void goPic_destroy(GoPic *p); extern void goPic_resize(GoPic *p, int x, int y, int w, int h); extern void goPic_setButHold(GoPic *p, bool hold); /* * Returns the color whose move it is. */ extern GoStone goPic_update(GoPic *p); #endif /* _GOPIC_H_ */ cgoban-1.9.14/src/goScore.h0000664000671000067100000000164607043224470011076 /* * src/goScore.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GOSCORE_H_ #define _GOSCORE_H_ 1 #ifndef _GOGAME_H_ #include "goGame.h" #endif /********************************************************************** * Data types **********************************************************************/ typedef struct GoScore_struct { int territories[2], livingStones[2], deadStones[2], dame; float scores[2]; } GoScore; /********************************************************************** * Functions **********************************************************************/ extern void goScore_compute(GoScore *score, GoGame *game); extern void goScore_zero(GoScore *score); extern Str *goScore_str(GoScore *score, GoGame *game, const GoTime *time, const GoTimer *timers); #endif /* _GOSCORE_H_ */ cgoban-1.9.14/src/goTime.h0000664000671000067100000000366307043224470010722 /* * src/gotime.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GOTIME_H_ #define _GOTIME_H_ 1 #ifndef _WMS_STR_H_ #include #endif /********************************************************************** * Data types **********************************************************************/ typedef enum { goTime_none, goTime_absolute, goTime_japanese, goTime_canadian, goTime_ing } GoTimeType; typedef struct { GoTimeType type; int main; int by; int aux; } GoTime; typedef struct { int timeLeft, aux; int usLeft; struct timeval startTime; } GoTimer; /********************************************************************** * Functions **********************************************************************/ void goTime_str(int time, Str *out); int goTime_parseChars(const char *t, bool ignoreExtra, bool *err); void goTime_describeStr(const GoTime *time, Str *out); void goTime_parseDescribeChars(GoTime *time, const char *desc); void goTime_remainStr(const GoTime *time, const GoTimer *timer, Str *out); void goTimer_init(GoTimer *timer, const GoTime *time); void goTime_startTimer(const GoTime *time, GoTimer *timer); /* * goTime_checkTimer() and goTime_endTimer() return FALSE if you are out of * time. */ bool goTime_checkTimer(const GoTime *time, GoTimer *timer); bool goTime_endTimer(const GoTime *time, GoTimer *timer); int goTime_ingPenalty(const GoTime *time, const GoTimer *timer); #define goTime_out(tm, tmr) (((tm)->type != goTime_none) && \ ((tmr)->timeLeft < 0)) #define goTime_low(tm, tmr, limit) \ ((((tm)->type == goTime_absolute) && ((tmr)->timeLeft < limit)) || \ (((tm)->type == goTime_canadian) && ((tmr)->aux > 0) && \ ((tmr)->timeLeft < limit)) || \ (((tm)->type == goTime_japanese) && ((tmr)->timeLeft < limit))) #endif /* _GOTIME_H_ */ cgoban-1.9.14/src/goban.h0000664000671000067100000001062707437322513010566 /* * $Source: /cvsroot/cgoban1/cgoban1/src/goban.h,v $ * $Revision: 1.2 $ * $Date: 2002/02/28 03:34:35 $ * * src/goban.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GOBAN_H_ #define _GOBAN_H_ 1 #ifndef _ABUT_TERM_H_ #include #endif #ifndef _GOGAME_H_ #include "goGame.h" #endif #ifndef _GOPIC_H_ #include "goPic.h" #endif #ifndef _GOSCORE_H_ #include "goScore.h" #endif #ifndef _ABUT_MSG_H_ #include #endif /********************************************************************** * Data types **********************************************************************/ typedef enum { gobanOut_draw, gobanOut_noDraw, gobanOut_err } GobanOut; typedef struct GobanActions_struct { /* * Callbacks when buttons are pressed. Returns TRUE if you have to * update the grid afterwards. */ GobanOut (*gridPressed)(void *packet, int loc); GobanOut (*quitPressed)(void *packet); GobanOut (*passPressed)(void *packet); GobanOut (*rewPressed)(void *packet); GobanOut (*backPressed)(void *packet); GobanOut (*fwdPressed)(void *packet); GobanOut (*ffPressed)(void *packet); GobanOut (*donePressed)(void *packet); GobanOut (*disputePressed)(void *packet); GobanOut (*savePressed)(void *packet); GobanOut (*editPressed)(void *packet); GobanOut (*gameInfoPressed)(void *packet); Help *helpInfo; /* * Called when goban_destroy is called with propagate set to TRUE, or * when the window is suddenly destroyed. */ void (*destroyCallback)(void *packet); /* Returns TRUE if the specified button should be pressable. */ bool (*rewOk)(void *packet); bool (*backOk)(void *packet); bool (*fwdOk)(void *packet); bool (*ffwdOk)(void *packet); } GobanActions; typedef struct GobanPlayerInfo_struct { But *box, *stones[5], *capsLabel, *capsOut, *timeLabel, *timeOut; But *capsBox, *timeBox; } GobanPlayerInfo; typedef struct Goban_struct { Cgoban *cg; const GobanActions *actions; void *packet; bool propagateDestroy; GoGame *game; GoTimer timers[2]; GoStone activeTimer; GoScore score; int ingTimePenalties[2]; int lastMove; float lastScores[2]; ClpEntry *bProp, *bPropW, *clpX, *clpY; ButWin *win; But *bg; But *labelBox, *labelText; But *infoText; But *gameInfo; But *help; AbutTerm *comments; But *kibIn, *kibType, *kibSay, *kibBoth, *kibKib; GobanOut (*newKib)(void *packet, const char *txt); But *pass; But *resume; But *done; GobanPlayerInfo playerInfos[2]; But *save; But *edit; But *quit; But *rew, *back, *fwd, *ff; GoPic *pic; But *boardBox; ButWin *iWin; But *iBg, *iBoard, *iDec1, *iDec2; /* Icon Decorations. */ AbutMsg *msgBox; ButTimer *clock; MAGIC_STRUCT } Goban; /********************************************************************** * Functions **********************************************************************/ extern Goban *goban_create(Cgoban *cg, const GobanActions *actions, void *packet, GoGame *game, const char *bPropName, const char *title); #define goban_setTitle(g, n) butText_set((g)->labelText, (n)) #define goban_getComments(g) abutTerm_get((g)->comments) #define goban_setComments(g, c) abutTerm_set((g)->comments, (c)) #define goban_catComments(g, c) butTbin_insert((g)->comments->tbin, (c)) extern void goban_destroy(Goban *g, bool propagate); extern void goban_message(Goban *g, const char *message); extern void goban_noMessage(Goban *g); extern void goban_update(Goban *g); extern void goban_startTimer(Goban *g, GoStone whose); /* stopTimer returns TRUE if there is still time left. */ extern bool goban_stopTimer(Goban *g); #define goban_setHold(g, h) goPic_setButHold((g)->pic, h) #define goban_score(g, p) ((g)->score.scores[p] - (g)->ingTimePenalties[p]) #define goban_dame(g) ((g)->score.dame) #define goban_territory(g, p) ((g)->score.territories[p]) #define goban_livingStones(g, p) ((g)->score.livingStones[p]) #define goban_caps(g, p) (goGame_caps((g)->game, p) + \ (g)->score.deadStones[p]) extern void goban_setKibitz(Goban *g, GobanOut (*newKib)(void *packet, const char *txt), int kibVal); #define goban_kibType(g) butRadio_get((g)->kibType) extern void goban_updateTimeReadouts(Goban *g); #endif /* _GOBAN_H_ */ cgoban-1.9.14/src/help.h0000664000671000067100000000205307043224470010416 /* * src/msg.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _HELP_H_ #define _HELP_H_ 1 #ifndef _ABUT_HELP_H_ #include #endif /********************************************************************** * Data Types **********************************************************************/ typedef struct { int numPages; const char *menuTitle; const AbutHelpPage *pages; } Help; /********************************************************************** * Global variables **********************************************************************/ extern Help help_control; extern Help help_gameSetup; extern Help help_editTool; extern Help help_cliMain; extern Help help_cliMatch; extern Help help_editBoard; extern Help help_localBoard; extern Help help_cliBoard; extern Help help_cliSetup; extern Help help_gmpBoard; extern Help help_gmpSetup; extern Help help_configure; extern Help help_cliLook; #endif /* _HELP_H_ */ cgoban-1.9.14/src/local.h0000664000671000067100000000323307043224471010562 /* * src/local.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _LOCAL_H_ #define _LOCAL_H_ 1 #ifndef _SGF_H_ #include "sgf.h" #endif #ifndef _GOGAME_H_ #include "goGame.h" #endif #ifndef _GOPIC_H_ #include "goPic.h" #endif #ifndef _GOBAN_H_ #include "goban.h" #endif /********************************************************************** * Forward declarations **********************************************************************/ #ifndef _ABUT_FSEL_H_ #ifndef AbutFsel #define AbutFsel void #endif #endif #ifndef _ABUT_MSG_H_ #ifndef AbutMsg #define AbutMsg void #endif #endif /********************************************************************** * Data types **********************************************************************/ typedef struct Local_struct { Cgoban *cg; GoGame *game; bool modified; Goban *goban; Sgf *moves; SgfElem *endGame; /* Used to backtrack after a dispute. */ SgfElem *lastComment; AbutFsel *fsel; AbutMsg *reallyQuit; MAGIC_STRUCT } Local; /********************************************************************** * Functions **********************************************************************/ extern Local *local_create(Cgoban *cg, GoRules rules, int size, int hcap, float komi, const char *white, const char *black, GoTimeType timeType, int mainTime, int byTime, int auxTime); extern Local *local_createFile(Cgoban *cg, const char *fname); extern Local *local_createSgf(Cgoban *cg, Sgf *mc); extern void local_destroy(Local *l); #endif /* _LOCAL_H_ */ cgoban-1.9.14/src/main.h0000664000671000067100000000066507043224471010422 /* * src/main.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _MAIN_H_ #define _MAIN_H_ 1 /********************************************************************** * Functions **********************************************************************/ extern int main(int argc, char *argv[], char *envp[]); #endif /* _MAIN_H_ */ cgoban-1.9.14/src/msg.h0000664000671000067100000001601507043224471010260 /* * src/msg.h, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _MSG_H_ #define _MSG_H_ 1 /********************************************************************** * Global variables **********************************************************************/ extern const char msg_mFonts[], msg_labelFonts[], msg_bFonts[]; /* From "crwin.c" */ extern const char msg_byBillShubert[]; extern const char msg_noWarranty[]; extern const char msg_seeHelp[]; /* From "cgoban.c" */ extern const char msg_path[], msg_file[], msg_mask[]; extern const char msg_dirs[], msg_files[]; extern const char msg_dirErr[]; extern const char msg_notEnoughColors[]; /* From "control.c" */ extern const char msg_newGame[], msg_loadGame[]; extern const char msg_editSGF[], msg_goModem[]; extern const char msg_quit[], msg_setup[]; extern const char msg_loadGameName[], msg_editGameName[]; /* From "local.c" */ extern const char msg_gSetup[]; extern const char msg_wName[], msg_bName[]; extern const char msg_ruleSet[], *msg_ruleNames[]; extern const char msg_boardSize[]; extern const char msg_handicap[]; extern const char msg_komi[]; extern const char msg_ok[]; extern const char msg_cancel[]; extern const char msg_timeSystem[], *msg_timeSystems[]; extern const char msg_primaryTime[], msg_byoYomi[]; extern const char msg_byoYomiCount[], msg_byoYomiStones[]; extern const char msg_badSize[], msg_badHcap[], msg_badKomi[]; extern const char msg_localTitle[], msg_noTitle[]; extern const char msg_badTime[], msg_badBYStones[], msg_badBYCount[]; /* * From "local.c" */ extern const char msg_notCgobanFile[]; extern const char msg_gameInfo[], msg_help[]; extern const char msg_pass[], msg_done[], msg_resume[], msg_dispute[]; extern const char msg_saveGame[], msg_editGame[]; extern const char msg_score[], msg_time[]; extern const char msg_localChiRemDead[], msg_localJapRemDead[]; extern const char msg_selectDisputed[], msg_selectDisputedMsg[]; extern const char *msg_stoneNames[]; extern const char msg_gameStartDesc[], msg_toPlay[]; extern const char msg_move1Desc[], msg_move1OfDesc[]; extern const char msg_moveNDesc[], msg_moveNOfDesc[]; extern const char msg_selectDead[]; extern const char msg_whiteWon[], msg_blackWon[], msg_jigo[]; extern const char msg_timeLossInfo[]; extern const char msg_disputeAnnounce[], msg_alive[], msg_dead[]; extern const char msg_disputeOverAlive[]; extern const char msg_disputeOverDead[]; extern const char msg_scoreKillsComment[], msg_scoreNoKillsComment[]; extern const char msg_ingPenaltyComment[]; extern const char msg_winnerComment[], msg_jigoComment[]; extern const char msg_gameIsOver[]; extern const char msg_timeLoss[]; extern const char msg_saveGameName[]; extern const char msg_reallyQuitGame[]; /* From "goban.c" */ extern const char msg_say[], msg_both[], msg_kib[]; /* From movechain.c */ extern const char msg_mcReadErr[]; extern const char msg_badSGFFile[]; extern const char msg_sgfBadToken[]; extern const char msg_sgfEarlyEOF[]; extern const char msg_sgfBadLoc[]; extern const char msg_sgfBadArg[]; /* From editBoard.c */ extern const char msg_printGame[], msg_noSuchGame[], msg_reallyQuit[]; extern const char msg_noCancel[], msg_yesQuit[]; extern const char msg_changeNodeWhileScoring[]; /* From editTool.c */ extern const char *msg_toolNames[]; extern const char *msg_toolDesc1[], *msg_toolDesc2[]; extern const char msg_killNode[], msg_moveNode[]; /* From "editInfo.c" */ extern const char msg_editInfoTitle[], msg_copyrightC[]; extern const char msg_gameTitle[], msg_result[]; extern const char msg_wStoneName[], msg_bStoneName[]; extern const char msg_wRank[], msg_bRank[]; extern const char msg_handicapC[], msg_komiC[]; extern const char msg_date[], msg_place[], msg_event[], msg_source[]; /* From gmp/setup.c */ extern const char msg_gmpSetup[]; extern const char *msg_gmpTypes[]; extern const char *msg_gmpPlayers[]; extern const char msg_program[]; extern const char msg_device[]; extern const char msg_machineName[]; extern const char msg_port[]; extern const char msg_username[]; extern const char msg_password[]; extern const char msg_badPortNum[]; extern const char msg_progRunErr[], msg_devOpenErr[]; extern const char msg_gmpTooBig[]; extern const char msg_waitingForGame[]; extern const char msg_noUndoFromGmpToClient[]; /* From gmp/play.c */ extern const char msg_gmpMoveOutsideGame[]; extern const char msg_gmpBadMove[]; extern const char msg_undoRequested[]; extern const char msg_badNewGameReq[]; extern const char msg_gmpCouldntStart[]; extern const char msg_gmpProgDied[], msg_gmpProgKilled[]; extern const char msg_gmpProgWhyDead[]; /* From gmp/engine.c */ extern const char msg_gmpDead[], msg_gmpTimeout[], msg_gmpSendBufFull[]; /* From client/setup.c */ extern const char *msg_loginDesc[]; extern const char msg_usernameColon[], msg_passwordColon[]; /* From client/login.c */ extern const char msg_cliOpenSocket[], msg_cliLookup[], msg_cliConnect[]; extern const char msg_cliHangup[], msg_login[]; extern const char msg_notAGuest[], msg_guest[], msg_loginFailed[]; /* From client/board.c */ extern const char msg_cliGameName[], msg_close[], msg_adjourn[]; extern const char msg_resign[], msg_yesResign[], msg_reallyResign[]; extern const char msg_cliGameBadMove[]; /* From client/conn.c */ extern const char msg_commandError[]; /* From client/look.c */ extern const char msg_cliLookName[]; extern const char msg_cliLookInfo[]; /* From client/main.c */ extern const char msg_players[], msg_games[]; /* From client/game.c */ extern const char msg_gameGoneResign[], msg_gameGoneAdjourn[]; extern const char msg_gameGoneTime[], msg_gameGoneScore[]; extern const char msg_gameResultResign[], msg_gameResultAdjourn[]; extern const char msg_gameResultTime[], msg_gameResultScore[]; extern const char msg_gameListDesc[]; extern const char msg_gameBadElf[]; /* From client/player.c */ extern const char msg_name[], msg_braceRank[], msg_state[]; extern const char msg_playerListDesc[]; /* From setup.c */ extern const char msg_setupTitle[]; extern const char msg_selServer[]; extern const char msg_gsCompName[]; extern const char msg_gsPortNum[]; extern const char msg_clientBadPortNum[]; extern const char msg_srvConfig[]; extern const char msg_directConn[]; extern const char msg_connCmdLabel[]; extern const char msg_miscellaneous[]; extern const char msg_showCoordinates[], msg_numberKibitzes[]; extern const char msg_hiContrast[]; extern const char msg_noTypo[]; extern const char msg_setupSrvName[]; extern const char msg_setupProtocol[]; extern const char msg_warnLimit[]; /* From client/match.c */ extern const char msg_swapColors[]; extern const char msg_cliGameSetup[]; extern const char msg_cliGameSetupSent[]; extern const char msg_cliGameSetupRej[]; extern const char msg_cliGameSetupRecvd[]; extern const char msg_freeGame[]; extern const char msg_youDontExist[]; /* From "sgfPlay.c" */ extern const char msg_badMoveInSgf[]; #endif /* _MSG_H_ */ cgoban-1.9.14/src/plasma.h0000664000671000067100000000113407043224471010743 /* * src/gogame.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _PLASMA_H_ #define _PLASMA_H_ 1 /********************************************************************** * Constants **********************************************************************/ #define PLASMA_SIZE 512 /********************************************************************** * Functions **********************************************************************/ extern uchar *plasma(void); #endif /* _PLASMA_H_ */ cgoban-1.9.14/src/setup.h0000664000671000067100000000373707043224471010641 /* * src/setup.h, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _SETUP_H_ #ifndef _CGOBAN_H_ #include "cgoban.h" #endif #ifdef _SETUP_H_ Levelization Error #endif #define _SETUP_H_ 1 /********************************************************************** * Constants **********************************************************************/ /* * If you change CONTROL_MAXSERVERS, you must also change the number of * entries in a lot of the "client." CLP entries found in * "src/cgoban.c". */ #define SETUP_MAXSERVERS 10 /********************************************************************** * Data types **********************************************************************/ typedef struct Setup_struct { Cgoban *cg; void (*destroyCallback)(struct Setup_struct *setup, void *packet); void (*newServerCallback)(struct Setup_struct *setup, void *packet); void *packet; ButWin *win; But *bg, *title; AbutSwin *swin; int srvNum; But *srvMenu; But *srvBox, *srvTitle, *srvName, *srvNameLabel; But *srvProto, *srvProtoLabel, *srvDirect, *srvDirectLabel; But *igsLabel, *nngsLabel; But *srvComp, *srvCompIn, *srvPort, *srvPortIn; But *srvCmd, *srvCmdLabel; But *miscBox, *miscTitle; But *coordLabel, *coord; But *hiLabel, *hi; But *numKibsLabel, *numKibs; But *noTypoLabel, *noTypo; But *warnLabel, *warnLimit; But *help, *ok; MAGIC_STRUCT } Setup; /********************************************************************** * Functions **********************************************************************/ extern Setup *setup_create(Cgoban *cg, void (*destroyCallback)(Setup *setup, void *packet), void (*newServerCallback)(Setup *setup, void *packet), void *packet); extern void setup_destroy(Setup *setup, bool propagate); #endif /* _SETUP_H_ */ cgoban-1.9.14/src/sgf.h0000664000671000067100000001415007476005006010250 /* * src/sgf.h, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _SGF_H_ /* We need goboard.h for the GoStone type. */ #ifndef _WMS_STR_H_ #include #endif #ifndef _GOBOARD_H_ #include "goBoard.h" #endif #ifdef _SGF_H_ LEVELIZATION ERROR #endif #define _SGF_H_ 1 /********************************************************************** * Data types **********************************************************************/ typedef enum { sgfInsert_main, sgfInsert_variant, sgfInsert_inline } SgfInsert; typedef enum { sgfType_node, sgfType_unknown, sgfType_style, sgfType_size, sgfType_rules, sgfType_handicap, sgfType_komi, sgfType_time, sgfType_copyright, sgfType_playerName, sgfType_date, sgfType_place, sgfType_title, sgfType_playerRank, sgfType_event, sgfType_source, sgfType_gameComment, sgfType_whoseMove, sgfType_move, sgfType_pass, sgfType_timeLeft, sgfType_stonesLeft, sgfType_setBoard, sgfType_territory, sgfType_triangle, sgfType_square, sgfType_mark, sgfType_circle, sgfType_label, sgfType_comment, sgfType_result } SgfType; typedef struct SgfElem_struct { SgfType type; GoStone gVal; int iVal; Str *sVal; char lVal[5]; struct SgfElem_struct *childH, *childT, *activeChild; struct SgfElem_struct *sibling, *parent; int numChildren; int mapX, mapY; /* Accessed in "sgfMap.h" */ MAGIC_STRUCT } SgfElem; typedef struct Sgf_struct { SgfElem top; SgfElem *active; SgfInsert mode; bool longLoc; int moveNum; MAGIC_STRUCT } Sgf; /********************************************************************** * Functions **********************************************************************/ extern Sgf *sgf_create(void); extern void sgf_destroy(Sgf *mc); extern void sgf_addCElem(Sgf *mc, SgfType type, GoStone gVal); extern void sgf_addCIElem(Sgf *mc, SgfType type, GoStone c, int i); extern void sgf_addCSElem(Sgf *mc, SgfType type, GoStone gVal, const char *s); extern void sgf_addCLElem(Sgf *mc, SgfType type, GoStone gVal, const char *l); extern void sgf_addCLSElem(Sgf *mc, SgfType type, GoStone gVal, const char *l, const char *s); #define sgf_addElem(mc, t) sgf_addCElem(mc, t, goStone_empty) #define sgf_addIElem(mc, t, i) sgf_addCIElem(mc, t, goStone_empty, i) #define sgf_addSElem(mc, t, s) sgf_addCSElem(mc, t, goStone_empty, s) #define sgf_addLElem(mc, t, l) sgf_addCLElem(mc, t, goStone_empty, l) #define sgf_addLSElem(mc, t, l, s) sgf_addCLSElem(mc, t, goStone_empty, l, s) #define sgf_addNode(mc) sgf_addElem(mc, sgfType_node) #define sgf_style(mc, s) sgf_addSElem(mc, sgfType_style, s) #define sgf_setSize(mc, size) sgf_addIElem(mc, sgfType_size, size) #define sgf_setRules(mc, rules) sgf_addIElem(mc, sgfType_rules, (int)rules) extern void sgf_setHandicap(Sgf *sgf, int handicap); #define sgf_setKomi(mc, komi) \ sgf_addIElem(mc, sgfType_komi, (int)(komi * 2.0)) #define sgf_setTimeFormat(mc, time) sgf_addSElem(mc, sgfType_time, time) #define sgf_move(mc, color, loc) sgf_addCLElem(mc, sgfType_move, color, loc) #define sgf_pass(mc, color) sgf_addCElem(mc, sgfType_pass, color) #define sgf_timeLeft(mc, c, t) sgf_addCIElem(mc, sgfType_timeLeft, c, t) #define sgf_stonesLeft(mc, c, s) sgf_addCIElem(mc, sgfType_stonesLeft, c, s) #define sgf_addStone(mc, color, loc) \ sgf_addCLElem(mc, sgfType_setBoard, color, loc) #define sgf_addTerritory(mc, color, loc) \ sgf_addCLElem(mc, sgfType_territory, color, loc) #define sgf_addTriangle(mc, loc) sgf_addLElem(mc, sgfType_triangle, loc) #define sgf_addCircle(mc, loc) sgf_addLElem(mc, sgfType_circle, loc) #define sgf_addSquare(mc, loc) sgf_addLElem(mc, sgfType_square, loc) #define sgf_label(mc, loc, label) \ sgf_addLSElem(mc, sgfType_label, loc, label) #define sgf_rmStone(mc, loc) \ sgf_addCLElem(mc, sgfType_setBoard, goStone_empty, loc) #define sgf_copyright(mc, s) sgf_addSElem(mc, sgfType_copyright, s) #define sgf_setPlayerName(mc, color, name) \ sgf_addCSElem(mc, sgfType_playerName, color, name) #define sgf_setTitle(mc, title) sgf_addSElem(mc, sgfType_title, title) #define sgf_playerRank(mc, p, r) sgf_addCSElem(mc, sgfType_playerRank, p, r) #define sgf_event(mc, e) sgf_addSElem(mc, sgfType_event, e) #define sgf_source(mc, e) sgf_addSElem(mc, sgfType_source, e) #define sgf_gameComment(mc, e) sgf_addSElem(mc, sgfType_gameComment, e) #define sgf_setWhoseMove(mc, c) sgf_addCElem(mc, sgfType_whoseMove, c) #define sgf_comment(mc, comment) sgf_addSElem(mc, sgfType_comment, comment) #define sgf_result(mc, r) sgf_addSElem(mc, sgfType_result, r) #define sgf_unknown(mc, u) sgf_addSElem(mc, sgfType_unknown, u) #define sgf_place(mc, p) sgf_addSElem(mc, sgfType_place, p) extern void sgfElem_destroyActiveChild(SgfElem *me); extern void sgf_setDate(Sgf *mc); extern void sgf_setActiveNodeNumber(Sgf *mc, int sgfNum); extern SgfElem *sgf_findType(Sgf *mc, SgfType t); extern SgfElem *sgf_elemFindType(Sgf *mc, SgfElem *me, SgfType t); extern SgfElem *sgfElem_findType(SgfElem *me, SgfType t); extern SgfElem *sgfElem_findTypeInNode(SgfElem *me, SgfType t); extern SgfElem *sgf_findFirstType(Sgf *mc, SgfType t); extern SgfElem *sgf_elemFindFirstType(Sgf *mc, SgfElem *me, SgfType t); extern SgfElem *sgfElem_findFirstType(SgfElem *me, SgfType t); extern void sgf_catComment(Sgf *sgf, const char *comments); /* * sgfElem_snip leaves the children where the snipped node used to be. */ extern void sgfElem_snip(SgfElem *se, Sgf *sgf); /* * findMove returns how many nodes you had to step over to find the move. * dir = 1 means look ahead, dir = -1 means look back. * The return value is always positive, or -1 if it wasn't found. */ extern int sgfElem_findMove(SgfElem *se, const char *move, int dir); extern void sgfElem_newString(SgfElem *me, const char *str); #define sgf_setActiveToEnd(sgf) \ while ((sgf)->active->activeChild) \ (sgf)->active = (sgf)->active->activeChild extern void sgf_addHandicapStones(Sgf *sgf, GoBoard *board); extern Sgf *sgf_copy(const Sgf *src); #endif /* _SGF_H_ */ cgoban-1.9.14/src/sgfIn.h0000664000671000067100000000101507043224471010532 /* * src/sgfIn.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _SGFIN_H_ #define _SGFIN_H_ 1 #ifndef _SGF_H_ #include "sgf.h" #endif /********************************************************************** * Functions **********************************************************************/ extern Sgf *sgf_createFile(Cgoban *cg, const char *fName, const char **err, bool *noFile); #endif /* _SGFIN_H_ */ cgoban-1.9.14/src/sgfMap.h0000664000671000067100000000506207043224471010707 /* * src/sgfMap.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _SGFMAP_H_ #define _SGFMAP_H_ 1 #ifndef _CGBUTS_H_ #include "cgbuts.h" #endif #ifndef _SGF_H_ #include "sgf.h" #endif /********************************************************************** * Constants **********************************************************************/ /********************************************************************** * Data types **********************************************************************/ typedef enum { sgfMap_next, sgfMap_prev } SgfMapDirection; typedef enum { sgfMap_black, sgfMap_white, sgfMap_bPass, sgfMap_wPass, sgfMap_edit, sgfMap_none } SgfMapType; #define SGFMAPFLAGS_MARKED 0x01 #define SGFMAPFLAGS_MAIN 0x02 #define SGFMAPFLAGS_CONNL 0x04 #define SGFMAPFLAGS_CONNR 0x08 #define SGFMAPFLAGS_CONNU 0x10 #define SGFMAPFLAGS_CONND 0x20 #define SGFMAPFLAGS_CONNDR 0x40 #define SGFMAPFLAGS_CONNUL 0x80 #define SGFMAPFLAGS_CONN (SGFMAPFLAGS_CONNL | SGFMAPFLAGS_CONNR | \ SGFMAPFLAGS_CONNU | SGFMAPFLAGS_CONND | \ SGFMAPFLAGS_CONNDR | SGFMAPFLAGS_CONNUL) typedef struct SgfMapElem_struct { SgfElem *node; SgfMapType type; uint flags; int moveNum; } SgfMapElem; typedef struct SgfMap_struct { Cgbuts *cgbuts; ButOut (*callback)(But *but, int newNodeNum); int mapW, mapH, maxW, maxH; int activeX, activeY; /* [0,0] = ul node, [1,0] = next node, etc. */ int pressX, pressY; /* [0,0] = ul node, [1,0] = next node, etc. */ int activeCtrX, activeCtrY; /* In pixels. */ SgfMapElem *els; MAGIC_STRUCT } SgfMap; /********************************************************************** * Functions **********************************************************************/ extern But *sgfMap_create(Cgbuts *b, ButOut (*callback)(But *but, int newNodeNum), void *packet, ButWin *win, int layer, int flags, Sgf *sgf); extern void sgfMap_resize(But *but, int x, int y); extern void sgfMap_newActive(But *but, SgfElem *new); #define sgfMap_activeCtrX(b) (((SgfMap *)(b->iPacket))->activeCtrX) #define sgfMap_activeCtrY(b) (((SgfMap *)(b->iPacket))->activeCtrY) extern bool sgfMap_changeVar(But *but, SgfMapDirection dir); extern void sgfMap_remap(But *but, Sgf *sgf); extern bool sgfMap_newNode(But *but, SgfElem *new); extern void sgfMap_changeNode(But *but, SgfElem *changed); extern void sgfMap_setMapPointer(But *but, SgfElem *activeElem); #endif /* _sgfMap_H_ */ cgoban-1.9.14/src/sgfOut.h0000664000671000067100000000131707043224471010740 /* * src/sgfOut.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _SGFOUT_H_ #define _MOVECHAIN_H_ 1 #ifndef _SGF_H_ #include "sgf.h" #endif /********************************************************************** * Functions **********************************************************************/ /** * Write an sgf file out. * * @param mc The SGF tree. * @param fname The file name to save to. * @param err Where to write the error code when there is an error. * @return TRUE on success, FALSE on failure. */ extern bool sgf_writeFile(Sgf *mc, const char *fname, int *err); #endif /* _SGFOUT_H_ */ cgoban-1.9.14/src/sgfPlay.h0000664000671000067100000000176707043224471011107 /* * src/sgfPlay.h, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _SGFPLAY_H_ #ifndef _SGF_H_ #include "sgf.h" #endif #ifndef _GOGAME_H_ #include "goGame.h" #endif #ifndef _GOPIC_H_ #include "goPic.h" #endif #ifdef _SGFPLAY_H_ Levelization Error. #endif #define _SGFPLAY_H_ 1 /********************************************************************** * Functions **********************************************************************/ /* * sgf_play will play until node terminator is hit or numNodes are passed. * If numNodes is -1, then it is played to the end. * In any case, it returns the node number it played to. This is * probably only useful if "numNodes" was -1. * If GoPic is non-NULL, then it will set the marks on the stones * appropriately. */ extern int sgf_play(Sgf *mc, GoGame *game, GoPic *pic, int numNodes, SgfElem *terminator); #endif /* _SGFPLAY_H_ */ cgoban-1.9.14/src/Makefile.am0000664000671000067100000000173207466272674011376 bin_PROGRAMS = cgoban SUBDIRS = gmp client INCLUDES = -I $(top_srcdir)/wmslib/src cgoban_LDADD = \ gmp/libgmp.a\ client/libclient.a\ ../wmslib/src/abut/libabut.a\ ../wmslib/src/but/libbut.a\ ../wmslib/src/wms/libwms.a\ ../wmslib/src/libwmsutils.a cgoban_SOURCES = \ arena.c \ cgbuts.c \ cgoban.c \ cm2pm.c \ control.c \ crwin.c \ drawStone.c \ editBoard.c \ editInfo.c \ editTool.c \ gameSetup.c \ goBoard.c \ goGame.c \ goHash.c \ goPic.c \ goScore.c \ goTime.c \ goban.c \ help.c \ local.c \ main.c \ msg.c \ plasma.c \ setup.c \ sgf.c \ sgfIn.c \ sgfMap.c \ sgfOut.c \ sgfPlay.c noinst_HEADERS = \ arena.h \ cgbuts.h \ cgoban.h \ cm2pm.h \ control.h \ crwin.h \ drawStone.h \ editBoard.h \ editInfo.h \ editTool.h \ gameSetup.h \ goBoard.h \ goGame.h \ goHash.h \ goPic.h \ goScore.h \ goTime.h \ goban.h \ help.h \ local.h \ main.h \ msg.h \ plasma.h \ setup.h \ sgf.h \ sgfIn.h \ sgfMap.h \ sgfOut.h \ sgfPlay.h cgoban-1.9.14/src/Makefile.in0000664000671000067100000004073507606355024011400 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPP = @CPP@ DATE = @DATE@ DEPDIR = @DEPDIR@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBS = @LIBS@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ bin_PROGRAMS = cgoban SUBDIRS = gmp client INCLUDES = -I $(top_srcdir)/wmslib/src cgoban_LDADD = \ gmp/libgmp.a\ client/libclient.a\ ../wmslib/src/abut/libabut.a\ ../wmslib/src/but/libbut.a\ ../wmslib/src/wms/libwms.a\ ../wmslib/src/libwmsutils.a cgoban_SOURCES = \ arena.c \ cgbuts.c \ cgoban.c \ cm2pm.c \ control.c \ crwin.c \ drawStone.c \ editBoard.c \ editInfo.c \ editTool.c \ gameSetup.c \ goBoard.c \ goGame.c \ goHash.c \ goPic.c \ goScore.c \ goTime.c \ goban.c \ help.c \ local.c \ main.c \ msg.c \ plasma.c \ setup.c \ sgf.c \ sgfIn.c \ sgfMap.c \ sgfOut.c \ sgfPlay.c noinst_HEADERS = \ arena.h \ cgbuts.h \ cgoban.h \ cm2pm.h \ control.h \ crwin.h \ drawStone.h \ editBoard.h \ editInfo.h \ editTool.h \ gameSetup.h \ goBoard.h \ goGame.h \ goHash.h \ goPic.h \ goScore.h \ goTime.h \ goban.h \ help.h \ local.h \ main.h \ msg.h \ plasma.h \ setup.h \ sgf.h \ sgfIn.h \ sgfMap.h \ sgfOut.h \ sgfPlay.h subdir = src mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/configure.h CONFIG_CLEAN_FILES = bin_PROGRAMS = cgoban$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) am_cgoban_OBJECTS = arena.$(OBJEXT) cgbuts.$(OBJEXT) cgoban.$(OBJEXT) \ cm2pm.$(OBJEXT) control.$(OBJEXT) crwin.$(OBJEXT) \ drawStone.$(OBJEXT) editBoard.$(OBJEXT) editInfo.$(OBJEXT) \ editTool.$(OBJEXT) gameSetup.$(OBJEXT) goBoard.$(OBJEXT) \ goGame.$(OBJEXT) goHash.$(OBJEXT) goPic.$(OBJEXT) \ goScore.$(OBJEXT) goTime.$(OBJEXT) goban.$(OBJEXT) \ help.$(OBJEXT) local.$(OBJEXT) main.$(OBJEXT) msg.$(OBJEXT) \ plasma.$(OBJEXT) setup.$(OBJEXT) sgf.$(OBJEXT) sgfIn.$(OBJEXT) \ sgfMap.$(OBJEXT) sgfOut.$(OBJEXT) sgfPlay.$(OBJEXT) cgoban_OBJECTS = $(am_cgoban_OBJECTS) cgoban_DEPENDENCIES = gmp/libgmp.a client/libclient.a \ ../wmslib/src/abut/libabut.a ../wmslib/src/but/libbut.a \ ../wmslib/src/wms/libwms.a ../wmslib/src/libwmsutils.a cgoban_LDFLAGS = DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/arena.Po ./$(DEPDIR)/cgbuts.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/cgoban.Po ./$(DEPDIR)/cm2pm.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/control.Po ./$(DEPDIR)/crwin.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/drawStone.Po ./$(DEPDIR)/editBoard.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/editInfo.Po ./$(DEPDIR)/editTool.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/gameSetup.Po ./$(DEPDIR)/goBoard.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/goGame.Po ./$(DEPDIR)/goHash.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/goPic.Po ./$(DEPDIR)/goScore.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/goTime.Po ./$(DEPDIR)/goban.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/help.Po ./$(DEPDIR)/local.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/main.Po ./$(DEPDIR)/msg.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/plasma.Po ./$(DEPDIR)/setup.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/sgf.Po ./$(DEPDIR)/sgfIn.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/sgfMap.Po ./$(DEPDIR)/sgfOut.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/sgfPlay.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ DIST_SOURCES = $(cgoban_SOURCES) HEADERS = $(noinst_HEADERS) RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ uninstall-info-recursive all-recursive install-data-recursive \ install-exec-recursive installdirs-recursive install-recursive \ uninstall-recursive check-recursive installcheck-recursive DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in DIST_SUBDIRS = $(SUBDIRS) SOURCES = $(cgoban_SOURCES) all: all-recursive .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(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; \ 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) cgoban$(EXEEXT): $(cgoban_OBJECTS) $(cgoban_DEPENDENCIES) @rm -f cgoban$(EXEEXT) $(LINK) $(cgoban_LDFLAGS) $(cgoban_OBJECTS) $(cgoban_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arena.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cgbuts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cgoban.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cm2pm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/control.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crwin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/drawStone.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/editBoard.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/editInfo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/editTool.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gameSetup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/goBoard.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/goGame.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/goHash.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/goPic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/goScore.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/goTime.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/goban.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/help.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/local.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plasma.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sgf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sgfIn.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sgfMap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sgfOut.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sgfPlay.Po@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` CCDEPMODE = @CCDEPMODE@ uninstall-info-am: # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ETAGS = etags ETAGSFLAGS = tags: TAGS 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-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(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 "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = .. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ 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"; \ $(mkinstalldirs) "$(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 list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \ || exit 1; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" \ distdir=../$(distdir)/$$subdir \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(PROGRAMS) $(HEADERS) installdirs: installdirs-recursive installdirs-am: $(mkinstalldirs) $(DESTDIR)$(bindir) install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-recursive clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-recursive distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-tags dvi: dvi-recursive dvi-am: info: info-recursive info-am: install-data-am: install-exec-am: install-binPROGRAMS install-info: install-info-recursive install-man: installcheck-am: maintainer-clean: maintainer-clean-recursive maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-info: uninstall-info-recursive .PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ clean-binPROGRAMS clean-generic clean-recursive distclean \ distclean-compile distclean-depend distclean-generic \ distclean-recursive distclean-tags distdir dvi dvi-am \ dvi-recursive info info-am info-recursive install install-am \ install-binPROGRAMS install-data install-data-am \ install-data-recursive install-exec install-exec-am \ install-exec-recursive install-info install-info-am \ install-info-recursive install-man install-recursive \ install-strip installcheck installcheck-am installdirs \ installdirs-am installdirs-recursive maintainer-clean \ maintainer-clean-generic maintainer-clean-recursive mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-recursive \ tags tags-recursive uninstall uninstall-am \ uninstall-binPROGRAMS uninstall-info-am \ uninstall-info-recursive uninstall-recursive # 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: cgoban-1.9.14/src/arena.c0000664000671000067100000000663307050207032010550 /* * src/arena.c, part of Complete Goban (game program) * Copyright (C) 1996-1997 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include "gmp/engine.h" #include "goScore.h" #ifdef _ARENA_H_ #error Levelization Error. #endif #include "arena.h" /********************************************************************** * Forward Declarations **********************************************************************/ static void match(Arena *arena, int whitePlayer, int size, float komi, int handicap); static ButOut gotMove(GmpEngine *ge, void *packet, GoStone color, int x, int y); static ButOut gotErr(GmpEngine *ge, void *packet, const char *errStr); /********************************************************************** * Functions **********************************************************************/ void arena(Cgoban *cg, const char *prog1, const char *prog2, int size, float komi, int handicap) { Arena arena; int in, out; int i, numGames; static const GmpActions actions = {NULL, gotMove, NULL, gotErr}; MAGIC_SET(&arena); arena.cg = cg; numGames = clp_getInt(cg->clp, "arena.games"); gmp_forkProgram(cg, &in, &out, prog1, 0, 0); gmpEngine_init(cg, &arena.engines[0], in, out, &actions, &arena); gmp_forkProgram(cg, &in, &out, prog1, 0, 0); gmpEngine_init(cg, &arena.engines[1], in, out, &actions, &arena); for (i = 0; i < numGames; ++i) { match(&arena, i & 1, size, komi, handicap); } MAGIC_UNSET(&arena); } static void match(Arena *arena, int whitePlayer, int size, float komi, int handicap) { static const GoTime noTime = {goTime_none, 0, 0, 0}; GoScore score; int winner; arena->game = goGame_create(size, goRules_nz, handicap, komi, &noTime, FALSE); gmpEngine_startGame(&arena->engines[whitePlayer], size, handicap, komi, TRUE, TRUE); gmpEngine_startGame(&arena->engines[whitePlayer ^ 1], size, handicap, komi, TRUE, FALSE); butEnv_events(arena->cg->env); goScore_compute(&score, arena->game); if (score.scores[0] > score.scores[1]) winner = 0; else winner = 1; printf("%d %g\n", winner ^ whitePlayer, score.scores[winner] - score.scores[winner ^ 1]); goGame_destroy(arena->game); } static ButOut gotMove(GmpEngine *ge, void *packet, GoStone color, int x, int y) { Arena *arena = packet; int move, engineNum; assert(MAGIC(arena)); if (ge == &arena->engines[0]) engineNum = 0; else { assert(ge == &arena->engines[1]); engineNum = 1; } assert(color == arena->game->whoseMove); if (color == goStone_white) { assert(!arena->engines[engineNum].iAmWhite); } else { assert(arena->engines[engineNum].iAmWhite); } if (x < 0) { goGame_pass(arena->game, arena->game->whoseMove, NULL); gmpEngine_sendPass(&arena->engines[engineNum ^ 1]); } else { move = goBoard_xy2Loc(arena->game->board, x, y); if (!goGame_isLegal(arena->game, arena->game->whoseMove, move)) { fprintf(stderr, "Got an illegal move.\n"); exit(1); } goGame_move(arena->game, arena->game->whoseMove, move, NULL); gmpEngine_sendMove(&arena->engines[engineNum ^ 1], x, y); } if (arena->game->state == goGameState_play) return(0); else return(BUTOUT_STOPWAIT); } static ButOut gotErr(GmpEngine *ge, void *packet, const char *errStr) { fprintf(stderr, "Error \"%s\" happened.\n", errStr); exit(1); } cgoban-1.9.14/src/cgbuts.c0000664000671000067100000007422407476005006010763 /* * $Source: /cvsroot/cgoban1/cgoban1/src/cgbuts.c,v $ * $Revision: 1.2 $ * $Author: wmshub $ * $Date: 2002/05/31 23:40:54 $ * * src/cgbuts.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. * * This code extends the wmslib/but library to add special buttons needed * for cgoban. * * The globe data was extracted from the CIA World Data Bank II map database. * via XEarth. See the main copyright for information about this. */ #include #include #include #include #include #include #include "goBoard.h" #include "drawStone.h" #ifdef _CGBUTS_H_ Levelization Error. #endif #include "cgbuts.h" /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut grid_mmove(But *but, int x, int y); static ButOut grid_mleave(But *but); static ButOut grid_mpress(But *but, int butnum, int x, int y); static ButOut grid_mrelease(But *but, int butnum, int x, int y); static void grid_draw(But *but, int x,int y,int w,int h); static ButOut grid_destroy(But *but); static void grid_newflags(But *but, uint fl); static ButOut gridNetPress(But *but, void *buf, int bufLen); static void drawRewChar(void *packet, ButWin *win, int x, int y, int w, int h); static void drawBackChar(void *packet, ButWin *win, int x, int y, int w, int h); static void drawFwdChar(void *packet, ButWin *win, int x, int y, int w, int h); static void drawFfChar(void *packet, ButWin *win, int x, int y, int w, int h); static void drawWStoneChar(void *packet, ButWin *win, int x, int y, int w, int h); static void drawBStoneChar(void *packet, ButWin *win, int x, int y, int w, int h); static void grid_morePixmaps(Cgbuts *b, int newNumPixmaps); static void gobanPic_draw(But *but, int x,int y, int w,int h); static ButOut gobanPic_destroy(But *but); static void stoneGroup_draw(But *but, int x,int y, int w,int h); static ButOut stoneGroup_destroy(But *but); static void computerPic_draw(But *but, int x,int y, int w,int h); static ButOut computerPic_destroy(But *but); static void toolPic_draw(But *but, int x,int y, int w,int h); static ButOut toolPic_destroy(But *but); /********************************************************************** * Global Variables **********************************************************************/ const char *cgbuts_stoneChar[2] = {CGBUTS_WSTONECHAR, CGBUTS_BSTONECHAR}; static const ButAction grid_action = { grid_mmove, grid_mleave, grid_mpress, grid_mrelease, NULL, NULL, grid_draw, grid_destroy, grid_newflags, gridNetPress}; static const ButAction gobanPic_action = { NULL, NULL, NULL, NULL, NULL, NULL, gobanPic_draw, gobanPic_destroy, but_flags, NULL}; static const ButAction stoneGroup_action = { NULL, NULL, NULL, NULL, NULL, NULL, stoneGroup_draw, stoneGroup_destroy, but_flags, NULL}; static const ButAction computerPic_action = { NULL, NULL, NULL, NULL, NULL, NULL, computerPic_draw, computerPic_destroy, but_flags, NULL}; static const ButAction toolPic_action = { NULL, NULL, NULL, NULL, NULL, NULL, toolPic_draw, toolPic_destroy, but_flags, NULL}; /********************************************************************** * Functions **********************************************************************/ void cgbuts_init(Cgbuts *cgbuts, ButEnv *env, Rnd *rnd, int color, bool hold, bool hiContrast, int timeWarn) { MAGIC_SET(cgbuts); cgbuts->env = env; cgbuts->dpyDepth = DefaultDepth(butEnv_dpy(env), DefaultScreen(butEnv_dpy(env))); cgbuts->dpyRootWindow = RootWindow(butEnv_dpy(env), DefaultScreen(butEnv_dpy(env))); cgbuts->pics = NULL; cgbuts->numPics = 0; cgbuts->rnd = rnd; cgbuts->color = color; cgbuts->holdStart = 0; cgbuts->hiContrast = hiContrast; cgbuts->holdEnabled = hold; cgbuts->timeWarn = timeWarn; butEnv_setChar(env, 1.0, CGBUTS_REWCHAR, drawRewChar, NULL); butEnv_setChar(env, 0.5, CGBUTS_BACKCHAR, drawBackChar, NULL); butEnv_setChar(env, 0.5, CGBUTS_FWDCHAR, drawFwdChar, NULL); butEnv_setChar(env, 1.0, CGBUTS_FFCHAR, drawFfChar, NULL); butEnv_setChar(env, 1.0, CGBUTS_WSTONECHAR, drawWStoneChar, cgbuts); butEnv_setChar(env, 1.0, CGBUTS_BSTONECHAR, drawBStoneChar, cgbuts); } But *grid_create(Cgbuts *b, ButOut (*func)(But *but), void *packet, ButWin *win, int layer, int flags, int pos) { Grid *grid; But *but; grid = wms_malloc(sizeof(Grid)); MAGIC_SET(grid); but = but_create(win, grid, &grid_action); but->uPacket = packet; but->layer = layer; but->flags = flags; grid->b = b; grid->callback = func; grid->lineGroup = gridLines_center; grid->starPoint = FALSE; grid->pos = pos; grid->pressColor = goStone_black; grid->stoneVersion = rnd_int(b->rnd) % CGBUTS_NUMWHITE; grid->ptype = goStone_empty; grid->grey = FALSE; grid->holdRequired = FALSE; grid->markType = goMark_none; grid->markAux = 0; but_init(but); return(but); } void grid_setStone(But *but, GoStone piece, bool grey) { Grid *grid = but->iPacket; assert(but->action == &grid_action); if ((piece != grid->ptype) || (grey != grid->grey)) { grid->ptype = piece; grid->grey = grey; but_draw(but); } } void grid_setMark(But *but, GoMarkType mark, int aux) { Grid *grid = but->iPacket; assert(but->action == &grid_action); if ((grid->markType != mark) || (grid->markAux != aux)) { grid->markType = mark; grid->markAux = aux; but_draw(but); } } static ButOut grid_destroy(But *but) { Grid *grid = but->iPacket; wms_free(grid); return(0); } static void grid_newflags(But *but, uint fl) { uint ofl = but->flags; but->flags = fl; if ((ofl & (BUT_TWITCHED|BUT_PRESSED|BUT_NETTWITCH|BUT_NETPRESS)) != (fl & (BUT_TWITCHED|BUT_PRESSED|BUT_NETTWITCH|BUT_NETPRESS))) { but_draw(but); } } static ButOut grid_mmove(But *but, int x, int y) { uint newflags = but->flags, retval = BUTOUT_CAUGHT; Grid *grid; if (!(but->flags & BUT_PRESSABLE)) return(BUTOUT_CAUGHT); if ((x < but->x) || (y < but->y) || (x >= but->x + but->w) || (y >= but->y + but->h)) { newflags &= ~BUT_TWITCHED; if (newflags != but->flags) { butEnv_setCursor(but->win->env, but, butCur_idle); but_newFlags(but, newflags); } if (!(newflags & BUT_LOCKED)) retval = 0; } else { newflags |= BUT_TWITCHED; if (newflags != but->flags) { grid = but->iPacket; assert(MAGIC(grid)); grid->b->holdStart = butWin_env(but_win(but))->eventTime; butEnv_setCursor(but->win->env, but, butCur_twitch); but_newFlags(but, newflags); } } return(retval); } static ButOut grid_mleave(But *but) { int newflags = but->flags; newflags &= ~BUT_TWITCHED; if (newflags != but->flags) { butEnv_setCursor(but->win->env, but, butCur_idle); but_newFlags(but, newflags); } return(BUTOUT_CAUGHT); } static ButOut grid_mpress(But *but, int butnum, int x, int y) { int newflags = but->flags, retval = BUTOUT_CAUGHT; Grid *grid; if (butnum == 1) { grid = but->iPacket; assert(MAGIC(grid)); /* * Check to make sure that the user has been holding the mouse there * long enough. * Holding the mouse is only necessare if all of these are true: * - Cgbuts.holdEnabled is TRUE. This lets the user turn on and off * all holds globally. * - This particular button has hold enabled. This lets cgoban turn * off hold when you are in a situation where an undo is no problem. * - No modifiers are pressed. Same reason as the previous. */ if (((but->win->env->keyModifiers & (ShiftMask | ControlMask)) == 0) && grid->holdRequired && grid->b->holdEnabled && (butWin_env(but_win(but))->eventTime - grid->b->holdStart < CGBUTS_HOLDTIME)) retval |= BUTOUT_ERR; else newflags |= BUT_PRESSED|BUT_LOCKED; } else retval |= BUTOUT_ERR; /* * if (!(but->flags & BUT_PRESSED) && (newflags & BUT_PRESSED)) * snd_play(&pe_move_snd); */ if (newflags != but->flags) but_newFlags(but, newflags); return(retval); } static ButOut grid_mrelease(But *but, int butnum, int x, int y) { int newflags = but->flags, retval = BUTOUT_CAUGHT; Grid *grid = but->iPacket; bool makeCallback = FALSE; if (butnum != 1) return(retval); if (but->flags & BUT_TWITCHED) { if (but->flags & BUT_PRESSED) { if (but->id) butRnet_butSpecSend(but, NULL, 0); makeCallback = TRUE; } } else retval |= BUTOUT_ERR; newflags &= ~(BUT_PRESSED|BUT_LOCKED); if (newflags != but->flags) but_newFlags(but, newflags); if (makeCallback) retval |= grid->callback(but); return(retval); } static void grid_draw(But *but, int x,int y,int w,int h) { static const struct { int numPoints, points[5]; } lineFormats[9] = { {3, {4,2,3}}, /* ul */ {4, {1,3,2,4}}, /* top */ {3, {1,2,4}}, /* ur */ {4, {0,4,2,3}}, /* left */ {5, {1,3,2,0,4}}, /* center */ {4, {0,4,2,1}}, /* right */ {3, {0,2,3}}, /* ll */ {4, {1,3,2,0}}, /* bottom */ {3, {0,2,1}}}; /* lr */ Grid *grid = but->iPacket; int i, lineWidth, starSize, flags = but->flags; Display *dpy; XPoint points[5], lines[5]; GC gc = but->win->env->gc; GoStone markColor; Cgbuts *b = grid->b; assert(MAGIC(b)); dpy = but->win->env->dpy; /* Points are: * 0 * | * 1 - 2 - 3 * | * 4 */ if ((grid->markType != goMark_letter) && (grid->markType != goMark_number) && (grid->lineGroup != gridLines_none) && ((grid->ptype == goStone_empty) || grid->grey)) { butEnv_setXFg(but->win->env, BUT_FG); lineWidth = (but->w + 15) / 30; if (lineWidth < 1) lineWidth = 1; XSetLineAttributes(dpy, gc, lineWidth, LineSolid, CapButt, JoinMiter); points[0].x = points[2].x = points[4].x = but->x + but->w/2; points[1].x = but->x; points[3].x = but->x + but->w; points[0].y = but->y; points[1].y = points[2].y = points[3].y = but->y + but->h/2; points[4].y = but->y + but->h; for (i = 0; i < lineFormats[grid->lineGroup].numPoints; ++i) lines[i] = points[lineFormats[grid->lineGroup].points[i]]; XDrawLines(dpy, but->win->win, gc, lines, lineFormats[grid->lineGroup].numPoints, CoordModeOrigin); if (grid->starPoint) { butEnv_setXFg(but->win->env, BUT_FG); starSize = (((but->w + 6 - lineWidth*6) / 12) * 2) + lineWidth+1; if (starSize > 1) { XFillArc(dpy, but->win->win, gc, but->x+(but->w - starSize)/2, but->y + (but->h-starSize)/2, starSize, starSize, 0, 360*64); } } } if ((grid->ptype == goStone_empty) && !(flags & (BUT_TWITCHED|BUT_NETTWITCH)) && (grid->markType == goMark_none)) return; markColor = grid->ptype; if (grid->ptype != goStone_empty) { if (flags & (BUT_PRESSED|BUT_NETPRESS)) { /* Pressed. Invert the greyness. */ cgbuts_drawp(b, but->win, grid->ptype, !grid->grey, but->x, but->y, but->w, grid->stoneVersion, x,y,w,h); } else { cgbuts_drawp(b, but->win, grid->ptype, grid->grey, but->x, but->y, but->w, grid->stoneVersion, x,y,w,h); if (flags & (BUT_TWITCHED|BUT_NETTWITCH)) { /* Twitched. Draw a small stone in the middle of it. */ if (grid->grey) { cgbuts_drawp(b, but->win, grid->ptype, FALSE, but->x+(but->w+1)/4, but->y+(but->w+1)/4, but->w/2, grid->stoneVersion, x,y,w,h); } else { cgbuts_drawp(b, but->win, goStone_opponent(grid->ptype), TRUE, but->x+(but->w+1)/4, but->y+(but->w+1)/4, but->w/2, grid->stoneVersion, x,y,w,h); } } } } else { assert(grid->ptype == goStone_empty); if (flags & (BUT_PRESSED|BUT_NETPRESS|BUT_TWITCHED|BUT_NETTWITCH)) { markColor = grid->pressColor; if (flags & (BUT_PRESSED |BUT_NETPRESS)) { cgbuts_drawp(b, but->win, grid->pressColor, FALSE, but->x, but->y, but->w, grid->stoneVersion, x,y,w,h); } else { /* Grid is twitched only. */ cgbuts_drawp(b, but->win, grid->pressColor, TRUE, but->x, but->y, but->w, grid->stoneVersion, x,y,w,h); } } } if ((grid->markType != goMark_none) && (!(flags & (BUT_PRESSED|BUT_NETPRESS)))) { cgbuts_markPiece(b, but->win, markColor, grid->markType, grid->markAux, but->x, but->y, but->w, grid->stoneVersion, x,y,w,h); } } static ButOut gridNetPress(But *but, void *buf, int bufLen) { Grid *grid = but->iPacket; assert(bufLen == 0); /* snd_play(&pe_move_snd); */ return(grid->callback(but)); } void cgbuts_drawp(Cgbuts *b, ButWin *win, GoStone piece, bool grey, int x, int y, int size, int stoneVersion, int dx,int dy, int dw,int dh) { ButEnv *env = win->env; Display *dpy = env->dpy; GC gc = env->gc2; int copyStart; int worldNum = 0; if (size >= b->numPics) grid_morePixmaps(b, size + 1); if (b->pics[size].stonePixmaps == None) drawStone_newPics(env, b->rnd, CGBUTS_GREY(0), &b->pics[size].stonePixmaps, &b->pics[size].maskBitmaps, size, butEnv_isColor(env) && !b->hiContrast); if (stoneVersion >= CGBUTS_NUMWHITE) { worldNum = 2 + stoneVersion / CGBUTS_NUMWHITE; stoneVersion %= CGBUTS_NUMWHITE; } if ((dx >= x+size) || (dy >= y+size) || (dx+dw <= x) || (dy+dh <= y)) return; if (dx < x) { dw -= x - dx; dx = x; } if (dy < y) { dh -= y - dy; dy = y; } if (dx + dw > x + size) dw = x + size - dx; if (dy + dh > y + size) dh = y + size - dy; XSetClipMask(dpy, gc, b->pics[size].maskBitmaps); if (grey) { if ((x & 1) == (y & 1)) XSetClipOrigin(dpy, gc, x - size - win->xOff, y - win->yOff); else XSetClipOrigin(dpy, gc, x - size * 2 - win->xOff, y - win->yOff); } else { XSetClipOrigin(dpy, gc, x - win->xOff, y - win->yOff); } copyStart = 0; if (piece == goStone_white) copyStart = (stoneVersion + 1) * size; XCopyArea(dpy, b->pics[size].stonePixmaps, win->win, gc, copyStart+dx-x,dy-y, dw,dh, dx - win->xOff, dy - win->yOff); if (worldNum) { copyStart = 0; if (piece == goStone_black) copyStart = (stoneVersion + 1) * size; XSetClipOrigin(dpy, gc, x-size*worldNum - win->xOff, y - win->yOff); XCopyArea(dpy, b->pics[size].stonePixmaps, win->win, gc, copyStart+dx-x,dy-y, dw,dh, dx - win->xOff, dy - win->yOff); } XSetClipMask(dpy, gc, None); } void cgbuts_markPiece(Cgbuts *b, ButWin *win, GoStone piece, GoMarkType markType, int markAux, int x, int y, int w, int stoneVersion, int dx,int dy, int dw,int dh) { ButEnv *env = win->env; Display *dpy = env->dpy; GC gc = env->gc; int lw = 0; XPoint points[4]; int off; char text[4]; if ((markType >= goMark_lastMove) && (markType <= goMark_circle)) { /* Must set up line attributes. */ lw = (w + 7) / 15; if (lw < 1) lw = 1; XSetLineAttributes(dpy, gc, lw, LineSolid, CapButt, JoinMiter); } if (piece == goStone_black) butEnv_setXFg(env, BUT_WHITE); else butEnv_setXFg(env, BUT_BLACK); switch(markType) { case goMark_none: break; case goMark_triangle: points[0].x = x+w/2 - win->xOff; points[0].y = y+lw - win->yOff; points[1].x = x+((w*0.9330127)-(lw*0.8660254)+0.5) - win->xOff; points[1].y = y+((w*0.75)-(lw*0.5)+0.5) - win->yOff; points[2].x = x+((w*0.0669873)+(lw*0.8660254)+0.5) - win->xOff; points[2].y = points[1].y; points[3] = points[0]; XDrawLines(dpy, win->win, gc, points, 4, CoordModeOrigin); break; case goMark_x: off = (int)(w*0.14644661+lw*0.5+1.5); XDrawLine(dpy, win->win, gc, x + off - win->xOff, y + off - win->yOff, x + w - off - win->xOff-(lw&1), y + w - off - win->yOff-(lw&1)); XDrawLine(dpy, win->win, gc, x + off - win->xOff, y + w - off - win->yOff-(lw&1), x + w - off - win->xOff-(lw&1), y + off - win->yOff); break; case goMark_ko: case goMark_square: off = (int)(w*0.14644661+lw*0.5+0.5); XDrawRectangle(dpy, win->win, gc, x + off - win->xOff, y + off - win->yOff, w-off*2-(lw&1),w-off*2-(lw&1)); break; case goMark_lastMove: case goMark_circle: off = (w + 1) / 4; XDrawArc(dpy, win->win, gc, x + off - win->xOff, y + off - win->yOff, w-off*2-1,w-off*2-1, 0,360*64); break; case goMark_smBlack: case goMark_smWhite: if (markType == goMark_smBlack) cgbuts_drawp(b, win, goStone_black, FALSE, x+(w+1)/4,y+(w+1)/4, w/2, stoneVersion, dx,dy,dw,dh); else cgbuts_drawp(b, win, goStone_white, FALSE, x+(w+1)/4,y+(w+1)/4, w/2, stoneVersion, dx,dy,dw,dh); break; case goMark_letter: text[0] = markAux; text[1] = '\0'; butWin_write(win, x + (w - butEnv_textWidth(env, text, 1)) / 2, y + (w - butEnv_fontH(env, 1)) / 2, text, 1); break; case goMark_number: assert(markAux >= 0); if (markAux > 999) markAux = 999; if ((markAux > 99) && (w < butEnv_fontH(env, 0) * 2)) sprintf(text, "%02d", markAux % 100); else sprintf(text, "%d", markAux); butWin_write(win, x + (w - butEnv_textWidth(env, text, 1)) / 2, y + (w - butEnv_fontH(env, 1)) / 2, text, 1); break; } } void grid_setPress(But *but, GoStone pressColor) { Grid *grid; assert(but->action == &grid_action); if (pressColor == goStone_empty) { if (but->flags & BUT_PRESSABLE) but_setFlags(but, BUT_NOPRESS); } else { if (!(but->flags & BUT_PRESSABLE)) but_setFlags(but, BUT_PRESSABLE); grid = but->iPacket; grid->pressColor = pressColor; } if (but->flags & BUT_TWITCHED) but_draw(but); } static void drawRewChar(void *packet, ButWin *win, int x, int y, int w, int h) { XPoint points[8]; Display *dpy = butEnv_dpy(butWin_env(win)); Window xwin = butWin_xwin(win); GC gc = butEnv_gc(butWin_env(win)); h &= ~1; w &= ~1; points[0].x = x; points[0].y = y+h/2; points[1].x = x+w/2; points[1].y = y; points[2].x = x+w/2; points[2].y = y+h/2; points[3].x = x+w; points[3].y = y; points[4].x = x+w; points[4].y = y+h; points[5] = points[2]; points[6].x = x+w/2; points[6].y = y+h; points[7] = points[0]; XFillPolygon(dpy, xwin, gc, points, 8, Nonconvex, CoordModeOrigin); } static void drawBackChar(void *packet, ButWin *win, int x, int y, int w, int h) { XPoint points[4]; Display *dpy = butEnv_dpy(butWin_env(win)); Window xwin = butWin_xwin(win); GC gc = butEnv_gc(butWin_env(win)); h &= ~1; points[0].x = x; points[0].y = y+h/2; points[1].x = x+w; points[1].y = y; points[2].x = x+w; points[2].y = y+h; points[3] = points[0]; XFillPolygon(dpy, xwin, gc, points, 4, Nonconvex, CoordModeOrigin); } static void drawFwdChar(void *packet, ButWin *win, int x, int y, int w, int h) { XPoint points[4]; Display *dpy = butEnv_dpy(butWin_env(win)); Window xwin = butWin_xwin(win); GC gc = butEnv_gc(butWin_env(win)); h &= ~1; points[0].x = x; points[0].y = y; points[1].x = x+w; points[1].y = y+h/2; points[2].x = x; points[2].y = y+h; points[3] = points[0]; XFillPolygon(dpy, xwin, gc, points, 4, Nonconvex, CoordModeOrigin); } static void drawFfChar(void *packet, ButWin *win, int x, int y, int w, int h) { XPoint points[8]; Display *dpy = butEnv_dpy(butWin_env(win)); Window xwin = butWin_xwin(win); GC gc = butEnv_gc(butWin_env(win)); h &= ~1; w &= ~1; points[0].x = x; points[0].y = y; points[1].x = x+w/2; points[1].y = y+h/2; points[2].x = x+w/2; points[2].y = y; points[3].x = x+w; points[3].y = y+h/2; points[4].x = x+w/2; points[4].y = y+h; points[5] = points[1]; points[6].x = x; points[6].y = y+h; points[7] = points[0]; XFillPolygon(dpy, xwin, gc, points, 8, Nonconvex, CoordModeOrigin); } static void drawWStoneChar(void *packet, ButWin *win, int x, int y, int w, int h) { Cgbuts *b = packet; cgbuts_drawp(b, win, goStone_white, FALSE, x,y, w, 1, x,y,w,h); } static void drawBStoneChar(void *packet, ButWin *win, int x, int y, int w, int h) { Cgbuts *b = packet; cgbuts_drawp(b, win, goStone_black, FALSE, x,y, w, 1, x,y,w,h); } static void grid_morePixmaps(Cgbuts *b, int newNumPics) { int i; CgbutsPic *newPics; assert(MAGIC(b)); newPics = wms_malloc(newNumPics * sizeof(CgbutsPic)); for (i = 0; i < b->numPics; ++i) { newPics[i] = b->pics[i]; } for (; i < newNumPics; ++i) { newPics[i].stonePixmaps = None; newPics[i].maskBitmaps = None; } b->numPics = newNumPics; if (b->pics) { wms_free(b->pics); } b->pics = newPics; } But *gobanPic_create(Cgbuts *b, ButWin *win, int layer, int flags) { But *but; but = but_create(win, b, &gobanPic_action); but->uPacket = NULL; but->layer = layer; but->flags = flags; return(but); } static void gobanPic_draw(But *but, int x,int y, int w,int h) { ButWin *win = but->win; ButEnv *env = win->env; int w13 = (but->w+1)/3; int w16 = (but->w + 2) / 6; int stonew = but->w/3; int bw = butEnv_stdBw(env); int cgtop = but->y + (but->w - stonew - bw - (w13 + w16)) / 2; int bdtop = cgtop + stonew + bw; XPoint points[4]; butEnv_setXFg(env, CGBUTS_COLORBOARD(0)); XFillRectangle(env->dpy, win->win, env->gc, but->x,bdtop+w13, but->w,w16); butEnv_setXFg(env, CGBUTS_COLORBOARD(225)); points[0].x = but->x; points[0].y = bdtop+w13; points[1].x = but->x + w16; points[1].y = bdtop; points[2].x = but->x + but->w - w16; points[2].y = points[1].y; points[3].x = but->x + but->w; points[3].y = points[0].y; XFillPolygon(env->dpy, win->win, env->gc, points, 4, Convex, CoordModeOrigin); } static ButOut gobanPic_destroy(But *but) { return(0); } But *stoneGroup_create(Cgbuts *b, ButWin *win, int layer, int flags) { But *but; but = but_create(win, b, &stoneGroup_action); but->uPacket = NULL; but->layer = layer; but->flags = flags; return(but); } static void stoneGroup_draw(But *but, int x,int y, int w,int h) { ButWin *win = but->win; int stoneW; stoneW = but->w >> 1; cgbuts_drawp(but->iPacket, win, goStone_black, FALSE, but->x, but->y, stoneW, 0, x, y, w, h); cgbuts_drawp(but->iPacket, win, goStone_white, FALSE, but->x + stoneW, but->y, stoneW, 1, x, y, w, h); cgbuts_drawp(but->iPacket, win, goStone_white, FALSE, but->x, but->y + stoneW, stoneW, 2, x, y, w, h); cgbuts_drawp(but->iPacket, win, goStone_black, FALSE, but->x + stoneW, but->y + stoneW, stoneW, 3, x, y, w, h); } static ButOut stoneGroup_destroy(But *but) { return(0); } But *computerPic_create(Cgbuts *b, ButWin *win, int layer, int flags) { But *but; but = but_create(win, b, &computerPic_action); but->uPacket = NULL; but->layer = layer; but->flags = flags; return(but); } static void computerPic_draw(But *but, int x,int y, int w,int h) { XPoint points[4]; ButWin *win = but->win; Display *dpy = butEnv_dpy(butWin_env(win)); Window xwin = butWin_xwin(win); GC gc = butEnv_gc(butWin_env(win)); int h2 = but->h / 2, h3 = but->h / 3, h12 = but->h / 12; int w6 = but->w / 6, w9 = but->w / 9; x = but->x; y = but->y; w = but->w; h = but->h; y += (h - (h12 + h2 + h12 + h3)) / 2; points[0].x = x; points[0].y = y + h12 + h2 + h3; points[1].x = x + w6; points[1].y = y + h12 + h2 + h12; points[2].x = x + w - w6; points[2].y = y + h12 + h2 + h12; points[3].x = x + w; points[3].y = y + h12 + h2 + h3; butEnv_setXFg(butWin_env(win), BUT_BLACK); XFillPolygon(dpy, xwin, gc, points, 4, Nonconvex, CoordModeOrigin); XFillRectangle(dpy, xwin, gc, x+w6,y+h12, w-2*w6,h2); butEnv_setXFg(butWin_env(win), BUT_PBG); XFillRectangle(dpy, xwin, gc, x+w6+w9,y+h12*2, w-2*w6-2*w9,h2-h12*2); } static ButOut computerPic_destroy(But *but) { return(0); } But *toolPic_create(Cgbuts *b, ButWin *win, int layer, int flags) { But *but; but = but_create(win, b, &toolPic_action); but->uPacket = NULL; but->layer = layer; but->flags = flags; return(but); } static void toolPic_draw(But *but, int x,int y, int w,int h) { XPoint points[12]; ButWin *win = but->win; Display *dpy = butEnv_dpy(butWin_env(win)); Window xwin = butWin_xwin(win); GC gc = butEnv_gc(butWin_env(win)); /* Size of hammer or screwdriver relative to whole picture. */ const float subBoxSize = 0.75; const float bevel = 0.25; const float hr2 = 0.70710678; /* Half of Root 2 */ /* Hammer constants. */ const float hHandleW = 0.1; const float hJointW = 0.2; const float hJointL = 0.2; const float hClawL = 0.4; const float hNeckW = 0.07; const float hHeadL = 0.1; /* Screwdriver constants. */ const float sHandleW = 0.2; const float sHandleL = 0.5; const float sHEndW = 0.15; const float sBladeW = 0.04; float th; float bx, by; x = but->x; y = but->y; h = but->h; th = h * subBoxSize; bx = x + h * (1.0 - subBoxSize); by = y + h * (1.0 - subBoxSize); /* The hammer's handle. */ points[0].x = x; points[0].y = y + th * (1.0 - hHandleW) + 0.5; points[1].x = x + th * hHandleW + 0.5; points[1].y = points[0].y + (points[1].x - points[0].x); points[2].x = x + th * (1.0 - hJointL * hr2) + 0.5; points[2].y = points[1].y - (points[2].x - points[1].x); points[3].x = points[2].x - (points[1].x - points[0].x); points[3].y = points[2].y - (points[1].x - points[0].x); /* Add beveling to the handle. */ points[4] = points[0]; points[5].x = x + th * hHandleW * bevel + 0.5; points[5].y = points[4].y + (points[5].x - points[4].x); points[6].x = x + th * (1.0 - hJointL * hr2) + 0.5; points[6].y = points[5].y - (points[6].x - points[5].x); points[7] = points[3]; points[9] = points[1]; points[10] = points[2]; points[8].x = points[9].x - th * hHandleW * bevel + 0.5; points[8].y = points[9].y - (points[9].x - points[8].x); points[11].x = points[10].x - (points[9].x - points[8].x); points[11].y = points[10].y - (points[9].x - points[8].x); butEnv_setXFg(butWin_env(win), CGBUTS_COLORBOARD(200)); XFillPolygon(dpy, xwin, gc, points, 4, Nonconvex, CoordModeOrigin); butEnv_setXFg(butWin_env(win), CGBUTS_COLORBOARD(0)); XFillPolygon(dpy, xwin, gc, points+4, 4, Nonconvex, CoordModeOrigin); butEnv_setXFg(butWin_env(win), CGBUTS_COLORBOARD(255)); XFillPolygon(dpy, xwin, gc, points+8, 4, Nonconvex, CoordModeOrigin); /* The hammer's head. */ points[0].x = x + th + 0.5; points[0].y = y + th * (hJointL * hr2) + 0.5; points[1].x = points[0].x - (points[0].y - y); points[1].y = y; points[2].x = x + th * (1.0 - hJointL * hr2 - hClawL) + 0.5; points[2].y = y; points[3].x = x + th * (1.0 - (hJointL + hJointW) * hr2) + 0.5; points[3].y = y + (points[1].x - points[3].x); points[4].x = points[3].x + (points[0].x - points[1].x); points[4].y = points[3].y + (points[4].x - points[3].x); points[5].x = x + th * (1.0 - (hJointW + hNeckW) * hr2 * 0.5) + 0.5; points[5].y = points[4].y - (points[5].x - points[4].x); points[6].x = points[5].x; points[6].y = points[4].y + (points[6].x - points[4].x); points[7].x = x + th * (1.0 + (hHeadL * 2.0 - hJointW) * hr2) + 0.5; points[7].y = points[6].y + (points[7].x - points[6].x); points[8].x = points[7].x + (points[0].x - points[4].x); points[8].y = points[7].y - (points[8].x - points[7].x); points[9].x = points[8].x - (points[7].x - points[6].x); points[9].y = points[8].y - (points[7].x - points[6].x); points[10].x = points[0].x - (points[9].y - points[0].y); points[10].y = points[9].y; butEnv_setXFg(butWin_env(win), BUT_BLACK); XFillPolygon(dpy, xwin, gc, points, 11, Nonconvex, CoordModeOrigin); /* The screwdriver's blade. */ points[0].x = bx + th * (1.0 - sBladeW * hr2) + 0.5; points[0].y = by + 0.5; points[1].x = bx + th * sHandleW + 0.5; points[1].y = points[0].y + (points[0].x - points[1].x); points[3].x = bx + th + 0.5; points[3].y = points[0].y + (points[3].x - points[0].x); points[2].x = points[1].x + (points[3].x - points[0].x); points[2].y = points[1].y + (points[3].x - points[0].x); butEnv_setXFg(butWin_env(win), CGBUTS_GREY(120)); XFillPolygon(dpy, xwin, gc, points, 4, Nonconvex, CoordModeOrigin); /* The screwdriver's handle. */ points[4].x = bx + 0.5; points[4].y = by + th * (1.0 - sHandleW * hr2) + 0.5; points[5].x = points[4].x; points[5].y = by + th * (1.0 - sHEndW * hr2) + 0.5; points[6].y = by + th + 0.5; points[6].x = points[5].x + (points[6].y - points[5].y); points[7].y = points[6].y; points[7].x = points[6].x + (points[5].y - points[4].y); points[8].x = bx + th * (sHandleL + sHandleW) * hr2 + 0.5; points[8].y = points[7].y - (points[8].x - points[7].x); points[3].x = points[4].x + (points[8].x - points[7].x); points[3].y = points[4].y - (points[8].x - points[7].x); points[2].x = points[3].x + th * bevel * sHandleW * hr2 + 0.5; points[2].y = points[3].y + (points[2].x - points[3].x); points[9].x = points[8].x - (points[2].x - points[3].x); points[9].y = points[8].y - (points[2].x - points[3].x); points[1].x = points[4].x + (points[2].x - points[3].x); points[1].y = points[4].y + (points[2].x - points[3].x); points[10].x = points[7].x - (points[2].x - points[3].x); points[10].y = points[7].y - (points[2].x - points[3].x); points[0].x = points[5].x + th * bevel * sHEndW * hr2 + 0.5; points[0].y = points[5].y + (points[0].x - points[5].x); points[11].x = points[6].x - (points[0].x - points[5].x); points[11].y = points[6].y - (points[0].x - points[5].x); butEnv_setXFg(butWin_env(win), CGBUTS_COLORBOARD(200)); XFillPolygon(dpy, xwin, gc, points+3, 6, Nonconvex, CoordModeOrigin); butEnv_setXFg(butWin_env(win), CGBUTS_COLORBOARD(0)); XFillPolygon(dpy, xwin, gc, points, 6, Nonconvex, CoordModeOrigin); butEnv_setXFg(butWin_env(win), CGBUTS_COLORBOARD(255)); XFillPolygon(dpy, xwin, gc, points+6, 6, Nonconvex, CoordModeOrigin); } static ButOut toolPic_destroy(But *but) { return(0); } void cgbuts_redraw(Cgbuts *b) { int i; assert(MAGIC(b)); for (i = 0; i < b->numPics; ++i) { if (b->pics[i].stonePixmaps != None) { XFreePixmap(butEnv_dpy(b->env), b->pics[i].stonePixmaps); XFreePixmap(butEnv_dpy(b->env), b->pics[i].maskBitmaps); } } wms_free(b->pics); b->pics = NULL; b->numPics = 0; butEnv_drawAll(b->env); } cgoban-1.9.14/src/cgoban.c0000644000671000067100000004634007577724540010736 /* * $Source: /cvsroot/cgoban1/cgoban1/src/cgoban.c,v $ * $Revision: 1.4 $ * $Date: 2002/12/17 22:46:56 $ * * src/cgoban.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include "msg.h" #include "cgbuts.h" #include "goGame.h" #include "goTime.h" #include "plasma.h" #include "cm2pm.h" #include #include #ifdef _CGOBAN_H_ LEVELIZATION ERROR #endif #include "cgoban.h" /********************************************************************** * Forward Declarations **********************************************************************/ static bool setupColors(Cgoban *cg, int colorMode); static void setupPixmaps(Cgoban *cg); static bool checkRules(ClpEntry *ce); static bool checkSize(ClpEntry *ce); static bool checkKomi(ClpEntry *ce); static bool checkHandicap(ClpEntry *ce); static bool checkTimeType(ClpEntry *ce); static bool checkTimeValue(ClpEntry *ce); static bool checkBYStones(ClpEntry *ce); static bool checkBProp(ClpEntry *ce); static bool checkGmpOption(ClpEntry *ce); static bool checkPortNum(ClpEntry *ce); static ButOut helpDead(AbutHelp *help, void *packet); /********************************************************************** * Global variables **********************************************************************/ const ButKey cg_return[] = {{XK_Return, 0, ShiftMask}, {XK_KP_Enter, 0, ShiftMask}, {0,0,0}}; const ButKey cg_help[] = {{XK_Help, 0, 0}, {0,0,0}}; /********************************************************************** * Functions **********************************************************************/ Cgoban *cgoban_create(int argc, char *argv[], char *envp[]) { Cgoban *cg; static const ClpSetup commandLine[] = { CLPSETUP_MSG("Complete Goban " VERSION " by William Shubert, Kevin Sonney - " DATE), CLPSETUP_MSG(""), {"VersionNumber", VERSION, NULL, 0, NULL}, {"version,-version", "f", "Print version information", CLPSETUP_BOOL|CLPSETUP_NOSAVE, NULL}, {"stealth", "t", "Stealth mode", CLPSETUP_SHOWBOOL|CLPSETUP_BOOL, NULL}, {"display", NULL, "Display to use", CLPSETUP_NOSAVE, NULL}, {"color", "t", "Use color if possible", CLPSETUP_SHOWBOOL|CLPSETUP_BOOL|CLPSETUP_NOSAVE, NULL}, {"hiContrast", "f", "Use high-contrast graphics instead of rendered", CLPSETUP_SHOWBOOL|CLPSETUP_BOOL, NULL}, {"adfile", "~/.cgobanrc", "Set resource file name", CLPSETUP_NOSAVE, NULL}, {"name", "cgoban", "Name used to look up X resources", 0, NULL}, {"fontHeight", "12", "Size (in pixels) of font (default = 12)", 0, NULL}, CLPSETUP_MSG(""), CLPSETUP_MSG("See the README for info about arena mode"), {"arena.games", "0", "Number of games to play in arena test", CLPSETUP_NOSAVE, NULL}, {"arena.prog1", "", "Program 1 for arena testing", 0, NULL}, {"arena.prog2", "", "Program 2 for arena testing", 0, NULL}, {"arena.size", "19", "Size to use in arena testing", 0, NULL}, {"arena.komi", "5.5", "Komi for arena testing", 0, NULL}, {"arena.handicap", "0", "Handicap for arena testing", 0, NULL}, {"play.markLastMove", "t", NULL, CLPSETUP_SHOWBOOL|CLPSETUP_BOOL, NULL}, {"play.markHotStones", "t", NULL, CLPSETUP_SHOWBOOL|CLPSETUP_BOOL, NULL}, {"board.showCoords", "t", NULL, CLPSETUP_SHOWBOOL|CLPSETUP_BOOL, NULL}, CLPSETUP_MSG(""), {"edit", "", "Edit SGF file", CLPSETUP_NOSAVE, NULL}, {"nngs", "f", "Connect to NNGS", CLPSETUP_BOOL|CLPSETUP_NOSAVE, NULL}, {"igs", "f", "Connect to IGS", CLPSETUP_BOOL|CLPSETUP_NOSAVE, NULL}, {"iconic", "f", NULL, CLPSETUP_BOOL|CLPSETUP_NOSAVE, NULL}, {"control.x", "", NULL, 0, NULL}, {"control.y", "", NULL, 0, NULL}, {"help.x", "", NULL, 0, NULL}, {"help.y", "", NULL, 0, NULL}, {"help.w", "28.284271", NULL, 0, NULL}, {"help.h", "40.0", NULL, 0, NULL}, {"game.rules", "1", NULL, 0, checkRules}, {"game.size", "19", NULL, 0, checkSize}, {"game.komi", "5.5", NULL, 0, checkKomi}, {"game.handicap", "0", NULL, 0, checkHandicap}, {"local.wName", "White", NULL, 0, NULL}, {"local.bName", "Black", NULL, 0, NULL}, {"local.x", "", NULL, 0, NULL}, {"local.y", "", NULL, 0, NULL}, {"local.bProp", "1.0", NULL, 0, checkBProp}, {"local.bPropW", "1.0", NULL, 0, checkBProp}, {"local.sgfName", "game.sgf", NULL, 0, NULL}, {"edit.x", "", NULL, 0, NULL}, {"edit.y", "", NULL, 0, NULL}, {"edit.toolX", "", NULL, 0, NULL}, {"edit.toolY", "", NULL, 0, NULL}, {"edit.toolW", "0.0", NULL, 0, NULL}, {"edit.toolH", "0.0", NULL, 0, NULL}, {"edit.bProp", "1.0", NULL, 0, checkBProp}, {"edit.bPropW", "1.0", NULL, 0, checkBProp}, {"edit.sgfName", "seigen-minoru.sgf", NULL, 0, NULL}, {"edit.infoX", "", NULL, 0, NULL}, {"edit.infoY", "", NULL, 0, NULL}, {"edit.infoW", "1.0", NULL, 0, NULL}, {"edit.infoH", "1.0", NULL, 0, NULL}, {"setup.timeType", "2", NULL, 0, checkTimeType}, {"setup.mainTime", "30:00", NULL, 0, checkTimeValue}, {"setup.igsBYTime", "10:00", NULL, 0, checkTimeValue}, {"setup.igsBYStones", "25", NULL, 0, checkBYStones}, {"setup.ingBYTime", "15:00", NULL, 0, checkTimeValue}, {"setup.ingBYPeriods", "3", NULL, 0, checkBYStones}, {"setup.jBYTime", "1:00", NULL, 0, checkTimeValue}, {"setup.jBYPeriods", "5", NULL, 0, checkBYStones}, {"config.x", "", NULL, 0, NULL}, {"config.y", "", NULL, 0, NULL}, {"config.h", "0.70710678", NULL, 0, NULL}, {"gmp.WOption", "0", NULL, 0, checkGmpOption}, {"gmp.BOption", "0", NULL, 0, checkGmpOption}, {"gmp.WProgram", "/usr/bin/gnugo --mode gmp --quiet", NULL, 0, NULL}, {"gmp.BProgram", "/usr/bin/gnugo --mode gmp --quiet", NULL, 0, NULL}, {"gmp.WDevice", "/dev/cua0", NULL, 0, NULL}, {"gmp.BDevice", "/dev/cua1", NULL, 0, NULL}, {"gmp.machine", "localhost", NULL, 0, NULL}, {"gmp.port", "26276", NULL, 0, checkPortNum}, {"gmp.nngs.username", "", NULL, 0, NULL}, {"gmp.nngs.password", "", NULL, 0, NULL}, {"gmp.igs.username", "", NULL, 0, NULL}, {"gmp.igs.password", "", NULL, 0, NULL}, {"client.def1", "0", NULL, 0, NULL}, {"client.def2", "1", NULL, 0, NULL}, /* * If you change the number of entries in these lists you must also * change the value of SETUP_MAXSERVERS in "src/setup.c". */ {"client.server", "NNGS|IGS|LGS|NCIC|GIGS|||||", NULL, 0, NULL}, {"client.protocol", "n|i|n|n|n|n|n|n|n|n", NULL, 0, NULL}, {"client.direct", "t|t|t|t|t|t|t|t|t|t", NULL, 0, NULL}, {"client.connCmd", "telnet nngs.cosmic.org 9696|" "telnet igs.joyjoy.net 6969|" "telnet|telnet|telnet|telnet|telnet|telnet|telnet|telnet", NULL, 0, NULL}, {"client.username", "|||||||||", NULL, 0, NULL}, {"client.password", "|||||||||", NULL, 0, NULL}, {"client.address", "nngs.cosmic.org|igs.joyjoy.net|micro.ee.nthu.edu.tw|" "jet.ncic.ac.cn|grizu.uni-regensburg.de|||||", NULL, 0, NULL}, {"client.port", "9696|6969|9696|9696|9696|9696|9696|9696|9696|9696", NULL, 0, NULL}, {"client.match.meFirst", "t", NULL, 0, NULL}, {"client.match.size", "19", NULL, 0, checkSize}, {"client.match.free", "f", NULL, 0, NULL}, {"client.match.mainTime", "20:00", NULL, 0, checkTimeValue}, {"client.match.byTime", "10:00", NULL, 0, checkTimeValue}, {"client.match.x", "", NULL, 0, NULL}, {"client.match.y", "", NULL, 0, NULL}, {"client.main.x", "", NULL, 0, NULL}, {"client.main.y", "", NULL, 0, NULL}, {"client.main.w", "40", NULL, 0, NULL}, {"client.main.h", "40", NULL, 0, NULL}, {"client.games.x", "", NULL, 0, NULL}, {"client.games.y", "", NULL, 0, NULL}, {"client.games.w", "6", NULL, 0, NULL}, {"client.games.h2", "0.5", NULL, 0, NULL}, {"client.players.x", "", NULL, 0, NULL}, {"client.players.y", "", NULL, 0, NULL}, {"client.players.h", "30.742", NULL, 0, NULL}, {"client.players.sort", "0", NULL, 0, NULL}, {"client.x", "", NULL, 0, NULL}, {"client.y", "", NULL, 0, NULL}, {"client.bProp", "1.0", NULL, 0, checkBProp}, {"client.bPropW", "1.0", NULL, 0, checkBProp}, {"client.numberKibitz", "f", NULL, CLPSETUP_BOOL, NULL}, {"client.noTypo", "f", NULL, CLPSETUP_BOOL, NULL}, {"client.look.x", "", NULL, 0, NULL}, {"client.look.y", "", NULL, 0, NULL}, {"client.look.bProp", "1.0", NULL, 0, checkBProp}, {"client.look.bPropW", "1.0", NULL, 0, checkBProp}, {"client.saykib", "1", NULL, 0, NULL}, {"client.warnLimit", "30", NULL, 0, NULL}, {"abut.fsel.x", "", NULL, 0, NULL}, {"abut.fsel.y", "", NULL, 0, NULL}, {"abut.fsel.w", "1.2", NULL, 0, NULL}, {"abut.fsel.h", "1.2", NULL, 0, NULL}, CLPSETUP_END}; int envInit, color; int parses; int boardBgSize; bool colorWarning = FALSE; /* Create the cg */ cg = wms_malloc(sizeof(Cgoban)); MAGIC_SET(cg); cg->envp = envp; cg->clp = clp_create(commandLine); clp_rCmdline(cg->clp, argv); if (clp_getBool(cg->clp, "version")) { printf("cgoban version " VERSION " by William Shubert, Kevin Sonney - " DATE "\n"); exit(0); } if (clp_getInt(cg->clp, "arena.games") > 0) { cg->env = butEnv_createNoDpy("Complete Goban " VERSION); return(cg); } cg->env = butEnv_create("Complete Goban " VERSION, clp_getStr(cg->clp, "display"), NULL); if (cg->env == NULL) { clp_destroy(cg->clp); wms_free(cg); MAGIC_UNSET(cg); return(NULL); } clp_rXDefaults(cg->clp, butEnv_dpy(cg->env), clp_getStr(cg->clp, "name")); clp_rFile(cg->clp, clp_getStr(cg->clp, "adfile")); parses = sscanf(clp_getStr(cg->clp, "VersionNumber"), "Complete Goban %d.%d.%d", &cg->rcMajor, &cg->rcMinor, &cg->rcBugFix); if (parses != 3) cg->rcMajor = cg->rcMinor = cg->rcBugFix = 0; clp_setStr(cg->clp, "VersionNumber", VERSION); color = TrueColor; envInit = butEnv_init(cg->env, cg, "Complete Goban", (clp_getBool(cg->clp, "color"))); cg->env->minWindows = 2; if (envInit == 0) color = GrayScale; if (envInit == 2) color = PseudoColor; else if (envInit == 1) { color = GrayScale; colorWarning = TRUE; } if (!setupColors(cg, color)) { colorWarning = TRUE; butEnv_destroy(cg->env); cg->env = butEnv_create("Complete Goban " VERSION, clp_getStr(cg->clp, "display"), NULL); assert(cg->env != NULL); butEnv_init(cg->env, cg, "Complete Goban", FALSE); setupColors(cg, color = GrayScale); } str_initChars(&cg->lastDirAccessed, "./"); cg->abut = abut_create(cg->env, msg_ok, msg_cancel); abut_setClp(cg->abut, cg->clp); abutFsel_pathMessage = msg_path; abutFsel_fileMessage = msg_file; abutFsel_maskMessage = msg_mask; abutFsel_dirsMessage = msg_dirs; abutFsel_filesMessage = msg_files; abutFsel_dirErrMessage = msg_dirErr; cg->help = NULL; cg->fontH = clp_getInt(cg->clp, "fontHeight"); abut_setButH(cg->abut, cg->fontH * 2); cg->markLastMove = clp_getBool(cg->clp, "play.markLastMove"); cg->markHotStones = clp_getBool(cg->clp, "play.markHotStones"); cg->showCoords = clp_getBool(cg->clp, "board.showCoords"); cg->rnd = rnd_create(time(NULL)); /* Set up the X stuff */ butEnv_setFont(cg->env, 0, msg_mFonts, cg->fontH); butEnv_setFont(cg->env, 1, msg_labelFonts, (cg->fontH*5+3)/6); butEnv_setFont(cg->env, 2, msg_bFonts, cg->fontH); cgbuts_init(&cg->cgbuts, cg->env, cg->rnd, color, clp_getBool(cg->clp, "client.noTypo"), clp_getBool(cg->clp, "hiContrast"), clp_getInt(cg->clp, "client.warnLimit")); if (cg->cgbuts.color == GrayScale) { cg->boardPixmap = butEnv_pixmap(cg->env, BUT_LIT); } else { boardBgSize = butEnv_fontH(cg->env, 0) * 28 + butEnv_stdBw(cg->env) * 19; cg->boardPixmap = cm2Pm(cg->env, plasma(), PLASMA_SIZE,PLASMA_SIZE, boardBgSize, boardBgSize, CGBUTS_COLORBOARD(0), 256, clp_getBool(cg->clp, "hiContrast")); } setupPixmaps(cg); abut_setPixmaps(cg->abut, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); if (colorWarning) { cgoban_createMsgWindow(cg, "Cgoban Warning", msg_notEnoughColors); } return(cg); } void cgoban_destroy(Cgoban *cg) { assert(MAGIC(cg)); clp_wFile(cg->clp, clp_getStr(cg->clp, "adfile"), "cgoban"); butEnv_destroy(cg->env); clp_destroy(cg->clp); rnd_destroy(cg->rnd); str_deinit(&cg->lastDirAccessed); MAGIC_UNSET(cg); wms_free(cg); } static bool setupColors(Cgoban *cg, int color) { ButColor bd0, bd255, g0, g255; int i, mix1, mix2; assert(MAGIC(cg)); if (!butEnv_setColor(cg->env, CGBUTS_COLORBG1, butColor_create(46,139,87, 15))) return(FALSE); if (!butEnv_setColor(cg->env, CGBUTS_COLORBG2, butColor_create(55,167,104, 15))) return(FALSE); if (!butEnv_setColor(cg->env, CGBUTS_COLORBGLIT1, butColor_create(61,185,116, 15))) return(FALSE); if (!butEnv_setColor(cg->env, CGBUTS_COLORBGLIT2, butColor_create(74,222,139, 15))) return(FALSE); if (!butEnv_setColor(cg->env, CGBUTS_COLORBGSHAD1, butColor_create(31,93,58, 8))) return(FALSE); if (!butEnv_setColor(cg->env, CGBUTS_COLORBGSHAD2, butColor_create(37,111,70, 8))) return(FALSE); if (!butEnv_setColor(cg->env, CGBUTS_COLORREDLED, butColor_create(255,80,80, 16))) return(FALSE); butEnv_setColor(cg->env, BUT_CHOICE, butColor_create(255,80,80, 8)); g0 = butColor_create(0,0,0, 0); g255 = butColor_create(255,255,255, 16); for (i = 0; i < 256; ++i) { mix1 = 255-i; mix2 = i; if (color != TrueColor) { mix1 = (mix1 * 17) / 256; mix2 = 16 - mix1; } if (!butEnv_setColor(cg->env, CGBUTS_GREY(i), butColor_mix(g0, mix1, g255, mix2))) return(FALSE); } bd0 = butColor_create(242,174,106, 8); bd255 = butColor_create(212,121,78, 8); bd255 = butColor_mix(bd0, 1, bd255, 4); for (i = 0; i < 256; ++i) { mix2 = (i*i*i + 127) / 255; mix1 = 255*255 - mix2; if (color != TrueColor) { mix1 = (mix1 * 8) / (255 * 255 + 1); mix2 = 7 - mix1; } if (!butEnv_setColor(cg->env, CGBUTS_COLORBOARD(i), butColor_mix(bd0, mix1, bd255, mix2))) return(FALSE); } return(TRUE); } static void setupPixmaps(Cgoban *cg) { Display *dpy; GC gc; int picH, i, j, offset, lastOffset = -1, lw, ll; assert(MAGIC(cg)); lw = (cg->fontH + 5) / 10; if (lw < 1) lw = 1; ll = lw * 4; picH = (ll+lw) * 3; picH = (((cg->fontH * 4) / picH) + 1) * picH; dpy = butEnv_dpy(cg->env); gc = butEnv_gc(cg->env); if (cg->cgbuts.color == GrayScale) { cg->bgPixmap = butEnv_pixmap(cg->env, BUT_BG); cg->bgLitPixmap = butEnv_pixmap(cg->env, BUT_LIT); cg->bgShadPixmap = butEnv_pixmap(cg->env, BUT_SHAD); } else { cg->bgPixmap = XCreatePixmap(dpy, cg->cgbuts.dpyRootWindow, picH, picH, cg->cgbuts.dpyDepth); cg->bgLitPixmap = XCreatePixmap(dpy, cg->cgbuts.dpyRootWindow, picH, picH, cg->cgbuts.dpyDepth); cg->bgShadPixmap = XCreatePixmap(dpy, cg->cgbuts.dpyRootWindow, picH, picH, cg->cgbuts.dpyDepth); XSetFillStyle(dpy, gc, FillSolid); XSetForeground(dpy, gc, butEnv_color(cg->env, CGBUTS_COLORBG1)); XFillRectangle(dpy, cg->bgPixmap, gc, 0,0, picH, picH); XSetForeground(dpy, gc, butEnv_color(cg->env, CGBUTS_COLORBGLIT1)); XFillRectangle(dpy, cg->bgLitPixmap, gc, 0,0, picH, picH); XSetForeground(dpy, gc, butEnv_color(cg->env, CGBUTS_COLORBGSHAD1)); XFillRectangle(dpy, cg->bgShadPixmap, gc, 0,0, picH, picH); XSetLineAttributes(dpy, gc, lw, LineSolid, CapButt, JoinMiter); for (i = 0; i < picH; i += 3*lw) { do { offset = (rnd_int(cg->rnd) % (ll+lw)) + lw; } while (offset == lastOffset); lastOffset = offset; for (j = -offset; j < picH; j += (ll+lw)) { XSetForeground(dpy, gc, butEnv_color(cg->env, CGBUTS_COLORBG2)); XDrawLine(dpy, cg->bgPixmap, gc, i-j,j, i-j-ll,j+ll); XDrawLine(dpy, cg->bgPixmap, gc, i-j+picH,j, i-j-ll+picH,j+ll); XSetForeground(dpy, gc, butEnv_color(cg->env, CGBUTS_COLORBGLIT2)); XDrawLine(dpy, cg->bgLitPixmap, gc, i-j,j, i-j-ll,j+ll); XDrawLine(dpy, cg->bgLitPixmap, gc, i-j+picH,j, i-j-ll+picH,j+ll); XSetForeground(dpy, gc, butEnv_color(cg->env, CGBUTS_COLORBGSHAD2)); XDrawLine(dpy, cg->bgShadPixmap, gc, i-j,j, i-j-ll,j+ll); XDrawLine(dpy, cg->bgShadPixmap, gc, i-j+picH,j, i-j-ll+picH,j+ll); } } butEnv_stdFill(cg->env); } } static bool checkRules(ClpEntry *ce) { bool err; int i; i = clpEntry_iGetInt(ce, &err); return(!err && (i >= 0) && (i < goRules_num)); } static bool checkSize(ClpEntry *ce) { bool err; int i; i = clpEntry_iGetInt(ce, &err); return(!err && (i >= 2) && (i <= GOBOARD_MAXSIZE)); } static bool checkKomi(ClpEntry *ce) { bool err; double i; i = clpEntry_iGetDouble(ce, &err); return(!err && (i >= -999.5) && (i <= 999.5) && (i * 2.0 == (double)((int)(i * 2.0)))); } static bool checkHandicap(ClpEntry *ce) { bool err; int i; i = clpEntry_iGetInt(ce, &err); return(!err && (i >= 0) && (i <= 27)); } static bool checkTimeType(ClpEntry *ce) { bool err; GoTimeType t; t = (GoTimeType)clpEntry_iGetInt(ce, &err); return(!err && (t <= goTime_ing)); } static bool checkTimeValue(ClpEntry *ce) { bool err; int time; time = goTime_parseChars(clpEntry_iGetStr(ce, NULL), FALSE, &err); return ((time >= 0) && !err); } static bool checkBYStones(ClpEntry *ce) { bool err; int i; i = clpEntry_iGetInt(ce, &err); return(!err && (i >= 1)); } static bool checkBProp(ClpEntry *ce) { bool err; double d; d = clpEntry_iGetDouble(ce, &err); return(!err && (d >= 1.0)); } static bool checkGmpOption(ClpEntry *ce) { bool err; int i; i = clpEntry_iGetInt(ce, &err); return(!err && (i >= 0) && (i <= 4)); } static bool checkPortNum(ClpEntry *ce) { bool err; int i; i = clpEntry_iGetInt(ce, &err); return(!err && (i <= 65535) && (i > 0)); } ButOut cgoban_createHelpWindow(But *but) { Cgoban *cg; const Help *helpInfo; int x, y, w, h; bool err; cg = butEnv_packet(butWin_env(but_win(but))); assert(MAGIC(cg)); helpInfo = but_packet(but); assert(helpInfo != NULL); if (cg->help) { abutHelp_newPages(cg->help, helpInfo->menuTitle, helpInfo->pages, helpInfo->numPages); } else { x = clpEntry_iGetInt(clp_lookup(cg->clp, "help.x"), &err); if (err) { x = BUT_NOCHANGE; y = BUT_NOCHANGE; } else y = clp_getInt(cg->clp, "help.y"); w = (int)(cg->fontH * clp_getDouble(cg->clp, "help.w") + 0.5); h = (int)(cg->fontH * clp_getDouble(cg->clp, "help.h") + 0.5); cg->help = abutHelp_create(cg->abut, "Cgoban Help", helpInfo->menuTitle, helpInfo->pages, helpInfo->numPages, x, y, w, h, 8 * cg->fontH, 8 * cg->fontH); abutHelp_setDestroyCallback(cg->help, helpDead, cg); } return(0); } static ButOut helpDead(AbutHelp *help, void *packet) { Cgoban *cg = packet; assert(MAGIC(cg)); cg->help = NULL; clp_setInt(cg->clp, "help.x", butWin_x(help->win)); clp_setInt(cg->clp, "help.y", butWin_y(help->win)); clp_setDouble(cg->clp, "help.w", (double)butWin_w(help->win) / (double)cg->fontH); clp_setDouble(cg->clp, "help.h", (double)butWin_h(help->win) / (double)cg->fontH); return(0); } cgoban-1.9.14/src/cm2pm.c0000664000671000067100000000454007043224470010502 /* * src/xio/cm2pm.c, part of Complete Goban (game program) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include "cm2pm.h" Pixmap cm2Pm(ButEnv *env, uchar *cmap, uint cmapw,uint cmaph, uint w,uint h, int pic0, int npic, bool flat) { Pixmap pic; Display *dpy = butEnv_dpy(env); pic = XCreatePixmap(dpy, RootWindow(dpy, DefaultScreen(dpy)), w,h, DefaultDepth(dpy, DefaultScreen(dpy))); cm2OldPm(env, cmap, cmapw, cmaph, pic0, npic, pic, flat); return(pic); } void cm2OldPm(ButEnv *env, uchar *cmap, uint cmapw,uint cmaph, int pic0, int npic, Pixmap pic, bool flat) { Display *dpy; int i, x, y, div, cmx, cmy; int w, h; unsigned long clist[256]; XImage *im; int xaddmin, addstd, subextra, current; bool done = FALSE; int stripeSize = 4, stripeShift = 2; int pixVal, cmap1, cmap2, color1, color2; Window dummyWindow; unsigned int wUns, hUns, dummyBw, dummyDepth; dpy = butEnv_dpy(env); XGetGeometry(dpy, pic, &dummyWindow, &x, &y, &wUns, &hUns, &dummyBw, &dummyDepth); w = wUns; h = hUns; while (stripeSize * 400 < w) { stripeSize += stripeSize; ++stripeShift; } div = (256*1024) / npic; for (i = 0; i < 256; ++i) { clist[i] = butEnv_color(env, pic0 + (i*1024)/div); } if (flat) { XSetForeground(dpy, env->gc, clist[128]); XFillRectangle(dpy, pic, env->gc, 0, 0, w, h); } else { im = butEnv_imageCreate(env, w, h); xaddmin = cmapw / w; addstd = cmapw - (xaddmin * w); subextra = w; current = 0; if (!done) { for (y = 0; y < h; ++y) { cmy = ((y * cmaph) / h) * cmapw; cmx = 0; for (x = 0; x < w; ++x) { cmap1 = cmap[cmx + cmy]; if (x < w) cmap2 = cmap[cmx+1 + cmy]; else cmap2 = cmap[cmx+1-cmapw + cmy]; color1 = (x << 8) + (uint)(cmap1 << (stripeShift + 2)); color2 = (x << 8) + 128 + (uint)((cmap1 << (stripeShift + 1)) + (cmap2 << (stripeShift + 1))); pixVal = (((color1 >> stripeShift) & 255) + ((color2 >> stripeShift) & 255)) >> 1; XPutPixel(im, x, y, clist[pixVal]); cmx += xaddmin; current += addstd; if (current > 0) { ++cmx; current -= subextra; } } } } XPutImage(dpy, pic, env->gc, im, 0,0,0,0,w,h); butEnv_imageDestroy(im); } } cgoban-1.9.14/src/control.c0000664000671000067100000003120507043224470011142 /* * src/control.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include "cgoban.h" #include "msg.h" #include "control.h" #include "gameSetup.h" #include "local.h" #include "cgbuts.h" #include "editBoard.h" #include "gmp/setup.h" #include "client/setup.h" #include "help.h" /********************************************************************** * Forward declarations **********************************************************************/ static ButOut map(ButWin *win); static ButOut resize(ButWin *win); static ButOut iResize(ButWin *win); static ButOut destroy(ButWin *win); static ButOut localGoban(But *but); static ButOut loadLocalGoban(But *but); static void gotLoadName(AbutFsel *fsel, void *packet, const char *fname); static ButOut quit(But *but); static ButOut setup(But *but); static ButOut editPressed(But *but); static ButOut gmpPressed(But *but); static void editFileName(AbutFsel *fsel, void *packet, const char *fName); static void localReady(void *packet, GameSetup *gs); static ButOut serverPressed(But *but); static void setupGone(Setup *setup, void *packet); static void updateServerBut(void *packet, int butNum); static void serverChange(Setup *setup, void *packet); /********************************************************************** * Functions **********************************************************************/ #define WIN_W(h,bw) ((h)*18+(bw)*18) /* I really want this to be square, */ #define WIN_H(h,bw) ((h)*18+(bw)*17) /* but it just won't work out. */ /* * Layout: * * 2*bw * Text * 2 * = Text*6+bw*4 * bw * = Text*6+bw*4 * Text * 2 * bw * 4 * = Text*2 * 2*bw * * Total: Text * 18 + bw * 17 */ Control *control_create(Cgoban *cg, bool iconic) { Control *ctrl; int i, serverNum; bool err; assert(MAGIC(cg)); ctrl = wms_malloc(sizeof(Control)); MAGIC_SET(ctrl); if (!iconic) cg->env->minWindows = 1; ctrl->cg = cg; ctrl->win = butWin_iCreate(ctrl, cg->env, "CGoban Control", WIN_W(cg->fontH, butEnv_stdBw(cg->env)), WIN_H(cg->fontH, butEnv_stdBw(cg->env)), &ctrl->iWin, iconic, 48,48, NULL, map, resize, iResize, destroy); i = clp_iGetInt(cg->clp, "control.x", &err); if (!err) butWin_setX(ctrl->win, i); i = clp_iGetInt(cg->clp, "control.y", &err); if (!err) butWin_setY(ctrl->win, i); butWin_activate(ctrl->win); ctrl->box = butBoxFilled_create(ctrl->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(ctrl->box, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); serverNum = clp_getInt(cg->clp, "client.def1"); ctrl->servers[0] = butCt_create(serverPressed, ctrl, ctrl->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, clp_getStrNum(cg->clp, "client.server", serverNum)); ctrl->sPics[0] = grid_create(&cg->cgbuts, NULL, NULL, ctrl->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(ctrl->sPics[0], goStone_white, FALSE); if (clp_getStrNum(cg->clp, "client.protocol", serverNum)[0] == 'n') grid_setVersion(ctrl->sPics[0], CGBUTS_WORLDWEST(0)); else grid_setVersion(ctrl->sPics[0], CGBUTS_WORLDEAST(0)); grid_setLineGroup(ctrl->sPics[0], gridLines_none); serverNum = clp_getInt(cg->clp, "client.def2"); ctrl->servers[1] = butCt_create(serverPressed, ctrl, ctrl->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, clp_getStrNum(cg->clp, "client.server", serverNum)); ctrl->sPics[1] = grid_create(&cg->cgbuts, NULL, NULL, ctrl->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(ctrl->sPics[1], goStone_white, FALSE); grid_setVersion(ctrl->sPics[1], CGBUTS_WORLDEAST(1)); grid_setLineGroup(ctrl->sPics[1], gridLines_none); ctrl->lGame = butCt_create(localGoban, ctrl, ctrl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_newGame); ctrl->lGamePic = grid_create(&cg->cgbuts, NULL, NULL, ctrl->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(ctrl->lGamePic, goStone_white, FALSE); grid_setVersion(ctrl->lGamePic, 2); grid_setLineGroup(ctrl->lGamePic, gridLines_none); ctrl->lLoad = butCt_create(loadLocalGoban, ctrl, ctrl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_loadGame); ctrl->lLoadPic = grid_create(&cg->cgbuts, NULL, NULL, ctrl->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(ctrl->lLoadPic, goStone_black, FALSE); grid_setLineGroup(ctrl->lLoadPic, gridLines_none); ctrl->edit = butCt_create(editPressed, ctrl, ctrl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_editSGF); ctrl->editPic = toolPic_create(&cg->cgbuts, ctrl->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU); ctrl->gmp = butCt_create(gmpPressed, ctrl, ctrl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_goModem); ctrl->gmpPic = computerPic_create(&cg->cgbuts, ctrl->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU); ctrl->sBox = butBoxFilled_create(ctrl->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(ctrl->sBox, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); ctrl->setupWin = NULL; ctrl->help = butCt_create(cgoban_createHelpWindow, &help_control, ctrl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_help); ctrl->setup = butCt_create(setup, ctrl, ctrl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_setup); ctrl->quit = butCt_create(quit, ctrl, ctrl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_quit); ctrl->iBg = butBoxFilled_create(ctrl->iWin, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(ctrl->iBg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); ctrl->ig = grid_create(&cg->cgbuts, NULL, NULL, ctrl->iWin, 1, BUT_DRAWABLE, 0); grid_setStone(ctrl->ig, goStone_black, FALSE); grid_setLineGroup(ctrl->ig, gridLines_none); grid_setVersion(ctrl->ig, CGBUTS_YINYANG(2)); return(ctrl); } static ButOut map(ButWin *win) { butWin_env(win)->minWindows = 1; return(0); } static ButOut resize(ButWin *win) { Control *ctrl = butWin_packet(win); ButEnv *env; int bw, fontH; int x, y, w, h, tbH, totalH, boxH; assert(MAGIC(ctrl)); env = ctrl->cg->env; bw = butEnv_stdBw(env); fontH = ctrl->cg->fontH; x = bw * 2; y = bw * 2; w = fontH*6 + bw*4; h = fontH*8 + bw*4; tbH = fontH*2; totalH = h + bw; boxH = totalH * 2 + bw*3; but_resize(ctrl->box, 0,0, butWin_w(win), boxH); but_resize(ctrl->sBox, 0,boxH, butWin_w(win), butWin_h(win) - boxH); but_resize(ctrl->servers[0], x, y, w, h); butCt_setTextLoc(ctrl->servers[0], 0, 0, w, tbH); but_resize(ctrl->sPics[0], x+bw*2,y+tbH+bw*2, w-bw*4,w-bw*4); y += totalH; but_resize(ctrl->servers[1], x, y, w, h); but_resize(ctrl->sPics[1], x+bw*2,y+bw*2, w-bw*4,w-bw*4); butCt_setTextLoc(ctrl->servers[1], 0, h-tbH, w, tbH); x += w + bw; y -= totalH; but_resize(ctrl->lGame, x, y, w, h); butCt_setTextLoc(ctrl->lGame, 0, 0, w, tbH); but_resize(ctrl->lGamePic, x+bw*2,y+tbH+bw*2, w-bw*4,w-bw*4); y += totalH; but_resize(ctrl->lLoad, x, y, w, h); butCt_setTextLoc(ctrl->lLoad, 0, h-tbH, w, tbH); but_resize(ctrl->lLoadPic, x+bw*2, y+bw*2, w-bw*4, w-bw*4); x += w + bw; y -= totalH; but_resize(ctrl->edit, x, y, w, h); butCt_setTextLoc(ctrl->edit, 0, 0, w, tbH); but_resize(ctrl->editPic, x+bw*2,y+tbH+bw*2, w-bw*4,w-bw*4); y += totalH; but_resize(ctrl->gmp, x, y, w, h); butCt_setTextLoc(ctrl->gmp, 0, h-tbH, w, tbH); but_resize(ctrl->gmpPic, x+bw*2, y+bw*2, w-bw*4, w-bw*4); y += totalH + bw*3; x = bw*2; but_resize(ctrl->help, x, y, w, tbH); but_resize(ctrl->setup, x + w + bw, y, w, tbH); but_resize(ctrl->quit, x + w*2 + bw*2, y, w, tbH); return(0); } static ButOut iResize(ButWin *win) { Control *ctrl = butWin_packet(win); int w, h, size; int border; assert(MAGIC(ctrl)); w = butWin_w(win); h = butWin_h(win); but_resize(ctrl->iBg, 0,0, w,h); border = 2*butEnv_stdBw(butWin_env(win)); size = w - border * 2; but_resize(ctrl->ig, border, border, size, size); return(0); } static ButOut destroy(ButWin *win) { Control *ctrl = butWin_packet(win); assert(MAGIC(ctrl)); clp_setInt(ctrl->cg->clp, "control.x", butWin_x(win)); clp_setInt(ctrl->cg->clp, "control.y", butWin_y(win)); return(BUTOUT_STOPWAIT); } static ButOut localGoban(But *but) { Control *ctrl = but_packet(but); assert(MAGIC(ctrl)); gameSetup_create(ctrl->cg, localReady, ctrl); return(0); } static void localReady(void *packet, GameSetup *gs) { Control *ctrl = packet; assert(MAGIC(ctrl)); if (gs != NULL) { local_create(ctrl->cg, gameSetup_rules(gs), gameSetup_size(gs), gameSetup_handicap(gs), gameSetup_komi(gs), gameSetup_wName(gs), gameSetup_bName(gs), gameSetup_timeType(gs), gameSetup_mainTime(gs), gameSetup_byTime(gs), gameSetup_timeAux(gs)); } } static ButOut loadLocalGoban(But *but) { Control *c = but_packet(but); assert(MAGIC(c)); abutFsel_createDir(c->cg->abut, gotLoadName, c, "CGoban", msg_loadGameName, str_chars(&c->cg->lastDirAccessed), clp_getStr(c->cg->clp, "local.sgfName")); return(0); } static void gotLoadName(AbutFsel *fsel, void *packet, const char *fname) { Control *c = packet; assert(MAGIC(c)); str_copy(&c->cg->lastDirAccessed, &fsel->pathVal); if (fname != NULL) { clp_setStr(c->cg->clp, "local.sgfName", butTextin_get(fsel->in)); local_createFile(c->cg, fname); } } static ButOut quit(But *but) { Control *ctrl = but_packet(but); Clp *clp; assert(MAGIC(ctrl)); clp = ctrl->cg->clp; clp_setInt(clp, "control.x", butWin_x(ctrl->win)); clp_setInt(clp, "control.y", butWin_y(ctrl->win)); clp_wFile(clp, clp_getStr(clp, "adfile"), clp_getStr(clp, "name")); return(BUTOUT_STOPWAIT); } static ButOut setup(But *but) { Control *ctrl = but_packet(but); assert(MAGIC(ctrl)); if (ctrl->setupWin) { XRaiseWindow(butEnv_dpy(ctrl->cg->env), butWin_xwin(ctrl->setupWin->win)); } else { ctrl->setupWin = setup_create(ctrl->cg, setupGone, serverChange, ctrl); } return(0); } static void setupGone(Setup *setup, void *packet) { Control *ctrl = packet; assert(MAGIC(ctrl)); ctrl->setupWin = NULL; } static ButOut editPressed(But *but) { Control *ctrl = but_packet(but); assert(MAGIC(ctrl)); assert(MAGIC(ctrl->cg)); abutFsel_createDir(ctrl->cg->abut, editFileName, ctrl, "CGoban", msg_editGameName, str_chars(&ctrl->cg->lastDirAccessed), clp_getStr(ctrl->cg->clp, "edit.sgfName")); return(0); } static void editFileName(AbutFsel *fsel, void *packet, const char *fName) { Control *ctrl = packet; assert(MAGIC(ctrl)); str_copy(&ctrl->cg->lastDirAccessed, &fsel->pathVal); if (fName) { clp_setStr(ctrl->cg->clp, "edit.sgfName", butTextin_get(fsel->in)); editBoard_create(ctrl->cg, fName); } } static ButOut gmpPressed(But *but) { Control *ctrl = but_packet(but); gmpSetup_create(ctrl->cg); return(0); } static ButOut serverPressed(But *but) { Control *ctrl = but_packet(but); int butNum, serverNum; ClpEntry *sEntry, *sNames; assert(MAGIC(ctrl)); if (but == ctrl->servers[0]) { butNum = 0; sEntry = clp_lookup(ctrl->cg->clp, "client.def1"); } else { assert(but == ctrl->servers[1]); butNum = 1; sEntry = clp_lookup(ctrl->cg->clp, "client.def2"); } serverNum = clpEntry_getInt(sEntry); if (butEnv_keyModifiers(ctrl->cg->env) & ShiftMask) { /* Change which server this is. */ sNames = clp_lookup(ctrl->cg->clp, "client.server"); do { ++serverNum; if (serverNum == SETUP_MAXSERVERS) { serverNum = 0; } } while ((serverNum > 0) && (clpEntry_getStrNum(sNames, serverNum)[0] == '\0')); clpEntry_setInt(sEntry, serverNum); updateServerBut(ctrl, butNum); } else { /* Start up a connection to the server. */ cliSetup_create(ctrl->cg, serverNum); } return(0); } static void serverChange(Setup *setup, void *packet) { updateServerBut(packet, 0); updateServerBut(packet, 1); } static void updateServerBut(void *packet, int butNum) { Control *ctrl = packet; int sNum; assert(MAGIC(ctrl)); assert((butNum == 0) || (butNum == 1)); if (butNum == 0) { sNum = clp_getInt(ctrl->cg->clp, "client.def1"); } else { sNum = clp_getInt(ctrl->cg->clp, "client.def2"); } assert((sNum >= 0) && (sNum < SETUP_MAXSERVERS)); butCt_setText(ctrl->servers[butNum], clp_getStrNum(ctrl->cg->clp, "client.server", sNum)); if (clp_getStrNum(ctrl->cg->clp, "client.protocol", sNum)[0] == 'n') grid_setVersion(ctrl->sPics[butNum], CGBUTS_WORLDWEST(0)); else grid_setVersion(ctrl->sPics[butNum], CGBUTS_WORLDEAST(0)); } cgoban-1.9.14/src/crwin.c0000664000671000067100000000520607043224470010606 /* * src/crwin.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include "cgoban.h" #include "msg.h" #include "crwin.h" /********************************************************************** * Forward declarations **********************************************************************/ static void destroyed(But *but); static ButOut killCr(ButTimer *timer); /********************************************************************** * Functions **********************************************************************/ Crwin *crwin_create(Cgoban *cg, ButWin *win, int layer) { Crwin *cr; ButEnv *env; int x, y, w, h, textH; struct timeval fiveSeconds; assert(MAGIC(cg)); cr = wms_malloc(sizeof(Crwin)); MAGIC_SET(cr); cr->env = env = cg->env; cr->box = butBoxFilled_create(win, layer, BUT_DRAWABLE); but_setPacket(cr->box, cr); but_setDestroyCallback(cr->box, destroyed); cr->title = butText_create(win, layer+1, BUT_DRAWABLE, "CGoban " VERSION, butText_center); butText_setFont(cr->title, 2); cr->byBill = butTblock_create(win, layer+1, BUT_DRAWABLE, msg_byBillShubert, butText_center); cr->noWarr = butTblock_create(win, layer+1, BUT_DRAWABLE, msg_noWarranty, butText_center); cr->seeHelp = butTblock_create(win, layer+1, BUT_DRAWABLE, msg_seeHelp, butText_center); textH = butEnv_fontH(env, 0); h = textH * 8; w = h * 2; x = (butWin_w(win) - w) / 2; y = (butWin_h(win) - h) / 3; but_resize(cr->box, x,y, w,h); butText_resize(cr->title, x + w/2, y += textH, textH); x += butEnv_stdBw(env) * 2; w -= butEnv_stdBw(env) * 4; y += textH; y += butTblock_resize(cr->byBill, x, y, w); y += butTblock_resize(cr->noWarr, x, y, w); butTblock_resize(cr->seeHelp, x, y, w); fiveSeconds.tv_usec = 0; fiveSeconds.tv_sec = 5; cr->timer = butTimer_create(cr, cr->box, fiveSeconds, fiveSeconds, FALSE, killCr); return(cr); } static void destroyed(But *but) { Crwin *cr = but_packet(but); assert(MAGIC(cr)); MAGIC_UNSET(cr); wms_free(cr); } static ButOut killCr(ButTimer *timer) { Crwin *cr = butTimer_packet(timer); assert(MAGIC(cr)); butTimer_destroy(cr->timer); but_destroy(cr->title); but_destroy(cr->byBill); but_destroy(cr->noWarr); but_destroy(cr->seeHelp); /* * Kill the box last. This is important, because killing the box * triggers the destruction of the Crwin data structure. */ but_destroy(cr->box); return(0); } cgoban-1.9.14/src/drawStone.c0000664000671000067100000005531107043224470011434 /* * src/drawStone.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. * * This code extends the wmslib/but library to add special buttons needed * for cgoban. * * The globe data was extracted from the CIA World Data Bank II map database. * */ #include #include #include #include #include #include #include "goBoard.h" #ifdef _DRAWSTONE_H_ Levelization Error. #endif #include "drawStone.h" /********************************************************************** * Data Types **********************************************************************/ typedef struct WhiteDesc_struct { float cosTheta, sinTheta; float stripeWidth, xAdd; float stripeMul, zMul; } WhiteDesc; /********************************************************************** * Forward Declarations **********************************************************************/ static void decideAppearance(WhiteDesc *desc, int size, Rnd *rnd); static float calcCosAngleReflection2View(int x, int y, int r, float *lambertian, float *z); static void drawNngs(Display *dpy, GC gc, Pixmap pic, int xOff, int size); static void drawIgs(Display *dpy, GC gc, Pixmap pic, int xOff, int size); static void drawWorld(Display *dpy, GC gc, Pixmap pic, int xOff, int size, const XPoint data[]); static int yinYangX(int size, int y); /********************************************************************** * Global Variables **********************************************************************/ void drawStone_newPics(ButEnv *env, Rnd *rnd, int baseColor, Pixmap *stonePixmap, Pixmap *maskBitmap, int size, bool color) { XImage *stones; GC gc1; Display *dpy = env->dpy; uchar *maskData; int maxRadius; int maskW; int x, y, i, wBright, bBright, yyx; XGCValues values; float bright, lambertian, z; float wStripeLoc, wStripeColor; WhiteDesc white[DRAWSTONE_NUMWHITE]; int sizeLimit; stones = butEnv_imageCreate(env, size * (DRAWSTONE_NUMWHITE + 1), size); maskW = (size * 6 + 7) >> 3; maskData = wms_malloc(maskW * size); memset(maskData, 0, maskW * size); for (i = 0; i < DRAWSTONE_NUMWHITE; ++i) { decideAppearance(&white[i], size, rnd); } maxRadius = size * size; sizeLimit = (int)((size - butEnv_fontH(env, 0) * 0.14) * (size - butEnv_fontH(env, 0) * 0.14)); if (sizeLimit > ((size - 1) * (size - 1))) sizeLimit = (size - 1) * (size - 1); for (y = 0; y < size; ++y) { yyx = yinYangX(size, y); for (x = 0; x < size; ++x) { /* * Here we build the masks. We need three basic masks; the solid * circular mask, and two dithered masks used for semitransparent * stones. * Then after that we have the yin yang mask. We have the world masks * too, but we make those in a separate function. */ if (((size - 1) - (x+x)) * ((size - 1) - (x+x)) + ((size - 1) - (y+y)) * ((size - 1) - (y+y)) <= maxRadius) { maskData[(x >> 3) + (y * maskW)] |= (1 << (x & 7)); x += size; if ((x & 1) == (y & 1)) maskData[(x >> 3) + (y * maskW)] |= (1 << (x & 7)); x += size; if ((x & 1) == (y & 1)) maskData[(x >> 3) + (y * maskW)] |= (1 << (x & 7)); x += size; if (x - size*3 < yyx) maskData[(x >> 3) + (y * maskW)] |= (1 << (x & 7)); x -= size*3; /* * Now we do the actual stone. If it's a greyscale/b&w display, it's * easy because there is no rendering going on. */ if (!color) { XPutPixel(stones, x, y, butEnv_color(env, BUT_BLACK)); if (((size - 1) - (x+x)) * ((size - 1) - (x+x)) + ((size - 1) - (y+y)) * ((size - 1) - (y+y)) < sizeLimit) { for (i = 0; i < DRAWSTONE_NUMWHITE; ++i) { XPutPixel(stones, x+size*(i+1), y, butEnv_color(env, BUT_WHITE)); } } else { for (i = 0; i < DRAWSTONE_NUMWHITE; ++i) { XPutPixel(stones, x+size*(i+1), y, butEnv_color(env, BUT_BLACK)); } } } else { /* * All right, time to add some color. First we calculate the * cosine of the angle of reflection to the angle of the viewer. * This is the basic quantity used to calculate the amount of * light seen in phong shading. You raise this value to a * power; the higher the power, the "shinier" the object you are * rendering. For the black stones, which aren't very shiny, * I use bright^4. For the white stones, which are very shiny, * I use bright^32. Then you multiply this value by the * intensity of the object at the point of rendering, add a * little bit of lambertian reflection and a tiny bit of ambient * light, and you're done! */ bright = calcCosAngleReflection2View((size - 1) - (x+x), (size - 1) - (y + y), size+size, &lambertian, &z); bright *= bright; bright *= bright; bBright = bright*165.0 + lambertian*10.0 - 5.0; bright *= bright; bright *= bright; bright *= bright; if (bBright > 255) bBright = 255; if (bBright < 0) bBright = 0; XPutPixel(stones, x, y, butEnv_color(env, baseColor + bBright)); /* * OK, the black stones are done. Now for the white stones. * Here we have to add the stripes. The algorithm for stripe * intensity is just something I made up. I kept tweaking * parameters and screwing around with it until it looked sort * of like my stones. The stripes are too regular, some day I * may go back and change that, but for now it is acceptable * looking IMHO. */ for (i = 0; i < DRAWSTONE_NUMWHITE; ++i) { wStripeLoc = (x*white[i].cosTheta - y*white[i].sinTheta) + white[i].xAdd; wStripeColor = fmod(wStripeLoc + (z * z * z * white[i].zMul) * white[i].stripeWidth, white[i].stripeWidth) / white[i].stripeWidth; wStripeColor = wStripeColor * white[i].stripeMul - 0.5; if (wStripeColor < 0.0) wStripeColor = -2.0 * wStripeColor; if (wStripeColor > 1.0) wStripeColor = 1.0; wStripeColor = wStripeColor * 0.15 + 0.85; wBright = bright*bright*250.0 + wStripeColor * (lambertian*120.0 + 110.0); if (wBright > 255) wBright = 255; if (wBright < 0) wBright = 0; XPutPixel(stones, x+(i+1)*size, y, butEnv_color(env, baseColor + wBright)); } } } } } *stonePixmap = XCreatePixmap(dpy, RootWindow(dpy, DefaultScreen(dpy)), size * (DRAWSTONE_NUMWHITE + 1), size, DefaultDepth(dpy, DefaultScreen(dpy))); XPutImage(dpy, *stonePixmap, env->gc2, stones, 0,0, 0,0, size * (DRAWSTONE_NUMWHITE + 1), size); butEnv_imageDestroy(stones); *maskBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, DefaultScreen(dpy)), (void *)maskData, maskW<<3, size); /* * The "void *" above is because maskData should be a uchar, but the * function prototype specifies a char. */ wms_free(maskData); values.graphics_exposures = False; gc1 = XCreateGC(dpy, *maskBitmap, GCGraphicsExposures, &values); /* Do that whole world thing, you know, the world thing. */ XSetForeground(dpy, gc1, 1); drawNngs(dpy, gc1, *maskBitmap, size*4, size); drawIgs(dpy, gc1, *maskBitmap, size*5, size); XSetFunction(dpy, gc1, GXand); XCopyArea(dpy, *maskBitmap, *maskBitmap, gc1, 0,0, size,size, size*4,0); XCopyArea(dpy, *maskBitmap, *maskBitmap, gc1, 0,0, size,size, size*5,0); } /* * Viewing vector is simply "z". * I model the stones as the top part of the sphere with the viewer looking * straight down on them. lx*i+ly*j+lz*k is the angle of incident light. * If you draw out the vectors and work out the equation, you'll notice that * it very nicely simplifies down to what you get here. The lambertian * intensity (lambertian) and the z magnitude of the surface normal (z) * aren't really related to the cosine being calculated, but they share * many operations with it so it saves CPU time to calculate them at the * same time. */ static float calcCosAngleReflection2View(int x, int y, int r, float *lambertian, float *z) { const float lx = 0.35355339, ly = 0.35355339, lz = 0.8660254; float nx, ny, nz, rz; float nDotL; nz = sqrt((double)(r * r - x * x - y * y)); *z = 1.0 - (nz / r); nx = (float)x; ny = (float)y; nDotL = (nx*lx + ny*ly + nz*lz) / r; rz = (2.0 * nz * nDotL) / r - lz; *lambertian = nDotL; return(rz); } /* * drawNngs and drawIgs are a list of vectors to draw to outline the world. * I took GIFs produced by XGlobe, which got it's data from the * CIA World Data Bank II map database. Then I wrote a program that * traced the outlines of the continents of those gifs, clipped out * unnecessare points, and saved the results as these list of points for * the polygons. Pretty cool, huh? */ static void drawNngs(Display *dpy, GC gc, Pixmap pic, int xOff, int size) { static const XPoint nngsData[] = { {120,0},{145,0},{147,2},{153,2},{155,4},{157,4},{159,6},{161,6},{161,9}, {159,11},{159,17},{158,17},{156,15},{152,15},{148,11},{146,11},{140,5}, {138,5},{136,3},{130,3},{129,2},{128,2},{126,4},{126,5},{127,6},{131,6}, {133,8},{135,8},{137,10},{137,13},{135,15},{134,15},{132,13},{128,13}, {126,11},{124,11},{124,9},{123,8},{122,8},{119,11},{119,13},{116,13}, {116,7},{115,6},{114,6},{113,7},{113,13},{109,13},{105,17},{105,18}, {107,20},{111,20},{113,22},{117,22},{117,26},{118,27},{119,27},{120,26}, {120,22},{122,22},{123,21},{123,20},{122,19},{122,14},{125,14},{127,16}, {131,16},{133,18},{136,18},{138,16},{139,16},{145,22},{147,22},{149,24}, {151,24},{151,28},{153,30},{157,30},{157,33},{150,33},{150,29},{149,28}, {148,28},{147,29},{145,29},{142,32},{142,33},{143,34},{147,34},{147,37}, {145,37},{143,39},{140,39},{138,37},{137,37},{133,41},{133,43},{131,43}, {123,51},{123,53},{119,57},{117,57},{113,61},{113,66},{115,68},{115,71}, {113,73},{112,73},{110,71},{110,67},{106,63},{99,63},{97,65},{87,65}, {85,67},{83,67},{81,69},{81,75},{79,77},{79,82},{84,87},{85,87},{86,86}, {90,86},{92,84},{92,82},{94,80},{99,80},{99,85},{97,87},{97,90},{99,92}, {105,92},{107,94},{107,99},{105,101},{105,102},{110,107},{111,107}, {112,106},{117,106},{119,108},{120,108},{122,106},{122,104},{124,102}, {128,102},{130,100},{133,100},{135,102},{139,102},{141,104},{155,104}, {155,106},{159,110},{161,110},{165,114},{171,114},{173,116},{175,116}, {177,118},{177,122},{179,124},{179,126},{181,128},{185,128},{187,130}, {189,130},{191,132},{193,132},{195,134},{199,134},{203,138},{205,138}, {207,140},{207,147},{205,149},{205,151},{199,157},{199,161},{197,163}, {197,167},{195,169},{195,171},{191,175},{191,177},{187,177},{185,179}, {183,179},{181,181},{179,181},{177,183},{177,185},{175,187},{175,189}, {163,201},{159,201},{157,203},{157,205},{155,207},{153,207},{151,209}, {149,209},{138,220},{138,221},{139,222},{139,223},{135,227},{135,230}, {137,232},{137,233},{132,233},{130,231},{128,231},{128,229},{126,227}, {126,220},{128,218},{128,217},{126,215},{126,212},{128,210},{128,204}, {130,202},{130,198},{132,196},{132,186},{134,184},{134,169},{128,163}, {126,163},{124,161},{122,161},{122,157},{118,153},{118,151},{116,149}, {116,147},{110,141},{110,136},{112,134},{112,126},{114,126},{116,124}, {116,122},{119,119},{119,118},{118,117},{118,111},{115,108},{114,108}, {113,109},{113,111},{110,111},{108,109},{106,109},{102,105},{100,105}, {100,103},{96,99},{94,99},{92,97},{88,97},{83,92},{82,92},{81,93}, {76,93},{74,91},{72,91},{70,89},{68,89},{64,85},{64,77},{60,73},{60,65}, {57,62},{56,62},{55,63},{55,64},{57,66},{57,74},{59,76},{59,77},{56,77}, {56,73},{52,69},{52,68},{54,66},{54,65},{52,63},{52,57},{50,55},{50,48}, {52,46},{52,44},{54,42},{54,40},{60,34},{60,32},{62,30},{62,28},{63,27}, {63,26},{62,25},{62,24},{67,19},{67,18},{66,17},{62,17},{62,16},{64,16}, {66,14},{68,14},{70,12},{72,12},{74,10},{76,10},{78,8},{82,8},{84,6}, {87,6},{88,7},{89,7},{90,6},{91,6},{93,8},{94,8},{98,4},{104,4},{106,2}, {107,2},{107,6},{108,7},{109,7},{110,6},{110,2},{111,2},{111,4},{112,5}, {113,5},{114,4},{114,2},{118,2},{119,1},{-1,-1},{168,10},{173,10}, {175,12},{175,13},{172,13},{170,11},{168,11},{-1,-1},{186,14},{189,14}, {197,22},{199,22},{201,24},{205,24},{213,32},{215,32},{219,36},{219,38}, {221,40},{221,44},{225,48},{225,50},{226,51},{227,51},{228,50},{229,50}, {235,56},{235,58},{239,62},{239,64},{241,66},{241,68},{243,70},{243,72}, {245,74},{245,76},{247,78},{247,82},{249,84},{249,88},{251,90},{251,94}, {253,96},{253,104},{255,106},{255,137},{254,137},{254,119},{251,116}, {250,116},{249,117},{248,117},{247,116},{246,116},{245,117},{242,117}, {242,115},{238,111},{238,107},{232,101},{232,97},{230,95},{230,87}, {228,85},{228,83},{226,81},{226,66},{227,65},{227,64},{226,63},{226,61}, {224,59},{224,53},{222,51},{220,51},{216,47},{216,45},{212,41},{212,38}, {213,37},{213,36},{212,35},{210,35},{202,27},{198,27},{190,19},{190,17}, {188,15},{186,15},{-1,-1},{110,76},{113,76},{115,78},{117,78},{119,80}, {121,80},{123,82},{125,82},{125,83},{123,83},{120,86},{120,87},{121,88}, {121,89},{118,89},{118,86},{119,85},{119,84},{116,81},{114,81},{112,79}, {106,79},{106,78},{108,78},{109,77},{-1,-1},{128,84},{135,84},{137,86}, {139,86},{139,87},{135,87},{133,89},{132,89},{130,87},{126,87},{126,86}, {127,85},{-1,-1},{142,86},{143,86},{143,89},{142,89},{142,87},{-1,-1}, {88,128},{89,128},{89,129},{88,129},{-1,-1},{254,142},{255,142}, {255,143},{254,143},{-1,-1},{250,162},{251,162},{251,165},{250,165}, {250,163},{-1,-1},{146,228},{149,228},{149,229},{146,229},{-1,-1}, {140,242},{143,242},{143,243},{141,243},{139,245},{137,245},{136,246}, {136,247},{137,248},{137,249},{135,251},{133,251},{132,252},{132,253}, {133,254},{136,254},{138,252},{139,252},{141,254},{142,254},{144,252}, {154,252},{156,250},{162,250},{164,248},{167,248},{167,249},{165,251}, {161,251},{159,253},{151,253},{149,255},{106,255},{104,253},{98,253}, {98,250},{107,250},{108,251},{109,251},{110,250},{124,250},{126,248}, {130,248},{134,244},{138,244},{139,243},{-2,-2}}; drawWorld(dpy, gc, pic, xOff, size, nngsData); } static void drawIgs(Display *dpy, GC gc, Pixmap pic, int xOff, int size) { static const XPoint igsData[] = { {106,2},{115,2},{117,4},{121,4},{123,6},{126,6},{128,4},{128,2},{131,2}, {135,6},{143,6},{145,8},{163,8},{164,9},{165,9},{166,8},{166,6},{171,6}, {173,8},{177,8},{179,10},{181,10},{183,12},{185,12},{187,14},{189,14}, {191,16},{191,23},{190,23},{190,21},{186,17},{180,17},{174,11},{167,11}, {165,13},{165,15},{163,15},{161,17},{159,17},{157,19},{157,23},{155,25}, {155,27},{152,27},{150,25},{150,18},{151,17},{151,16},{150,15},{149,15}, {147,17},{133,17},{128,22},{128,23},{129,24},{135,24},{135,28},{137,30}, {137,31},{135,33},{134,33},{134,29},{133,28},{132,28},{131,29},{131,33}, {127,37},{125,37},{121,41},{117,41},{111,47},{111,48},{113,50},{113,53}, {111,55},{106,55},{106,51},{104,49},{104,48},{105,47},{105,46},{104,45}, {103,45},{101,47},{100,47},{98,45},{97,45},{95,47},{95,48},{97,50}, {101,50},{101,51},{97,51},{95,53},{95,56},{97,58},{97,65},{91,71}, {91,72},{92,73},{93,73},{94,72},{95,72},{95,77},{93,79},{92,79},{92,75}, {91,74},{90,74},{89,75},{87,75},{85,77},{83,77},{81,79},{77,79},{73,83}, {73,85},{71,87},{68,87},{68,84},{69,83},{69,82},{68,81},{67,81},{63,85}, {63,88},{67,92},{67,103},{65,103},{59,109},{58,109},{58,105},{53,100}, {52,100},{49,103},{49,108},{55,114},{55,128},{59,132},{61,132},{63,134}, {63,135},{61,135},{59,137},{59,138},{61,140},{63,140},{65,142},{75,142}, {79,146},{93,146},{93,147},{91,147},{89,149},{89,151},{88,151},{88,149}, {86,147},{70,147},{68,145},{62,145},{56,139},{54,139},{52,137},{52,135}, {50,133},{50,131},{49,130},{48,130},{47,131},{46,131},{46,130},{47,129}, {47,128},{44,125},{44,121},{40,117},{40,116},{45,116},{48,119},{49,119}, {50,118},{50,115},{48,113},{48,111},{46,109},{46,106},{48,104},{48,93}, {47,92},{46,92},{45,93},{44,93},{42,91},{42,90},{44,88},{44,87},{42,85}, {42,81},{40,79},{39,79},{23,95},{23,99},{21,101},{21,108},{23,110}, {23,111},{21,113},{21,115},{20,115},{20,109},{19,108},{18,108},{17,109}, {16,109},{16,88},{18,86},{18,83},{16,81},{16,78},{18,76},{18,75},{16,73}, {15,73},{13,75},{13,77},{11,79},{11,81},{9,83},{9,85},{7,87},{7,89}, {5,91},{4,91},{4,90},{6,88},{6,84},{8,82},{8,78},{10,76},{10,74},{14,70}, {14,66},{16,64},{16,62},{20,58},{20,56},{24,52},{24,50},{34,40},{34,38}, {36,36},{38,36},{40,34},{40,32},{42,32},{50,24},{52,24},{56,20},{58,20}, {62,16},{64,16},{66,14},{68,14},{70,12},{72,12},{74,10},{76,10},{78,8}, {84,8},{86,6},{90,6},{92,4},{93,4},{94,5},{95,5},{96,4},{104,4},{105,3}, {-1,-1},{134,36},{135,36},{137,38},{139,38},{139,41},{135,41},{133,43}, {133,44},{135,46},{135,47},{133,49},{133,53},{131,53},{129,55},{127,55}, {125,57},{117,57},{115,59},{115,61},{112,61},{112,58},{118,52},{124,52}, {130,46},{130,44},{131,43},{131,42},{130,41},{130,40},{132,40},{134,38}, {134,37},{-1,-1},{92,86},{93,86},{95,88},{95,91},{93,93},{93,94},{95,96}, {97,96},{97,98},{99,100},{101,100},{101,103},{98,106},{98,107},{99,108}, {103,108},{103,111},{101,113},{101,115},{98,115},{95,112},{94,112}, {93,113},{92,113},{92,110},{94,108},{94,105},{92,103},{92,102},{93,102}, {95,104},{96,104},{97,103},{97,102},{96,101},{96,99},{95,98},{94,98}, {93,99},{90,99},{90,95},{88,93},{88,92},{90,90},{90,88},{91,87},{-1,-1}, {80,112},{83,112},{87,116},{87,117},{85,117},{83,119},{83,122},{85,124}, {85,125},{83,127},{83,129},{81,131},{81,135},{79,137},{76,137},{74,135}, {68,135},{68,131},{66,129},{66,124},{68,124},{76,116},{78,116},{80,114}, {80,113},{-1,-1},{90,124},{93,124},{95,126},{96,126},{98,124},{99,124}, {99,125},{97,127},{91,127},{90,128},{90,129},{91,130},{95,130},{95,131}, {93,131},{92,132},{92,133},{93,134},{93,136},{95,138},{95,139},{92,139}, {91,138},{90,138},{89,139},{89,141},{88,141},{86,139},{86,130},{88,128}, {88,126},{89,125},{-1,-1},{104,124},{107,124},{107,127},{105,129}, {105,131},{104,131},{104,125},{-1,-1},{114,128},{117,128},{119,130}, {119,132},{121,134},{122,134},{123,133},{123,132},{122,131},{122,130}, {123,130},{124,131},{125,131},{126,130},{127,130},{129,132},{133,132}, {135,134},{139,134},{141,136},{143,136},{147,140},{149,140},{149,144}, {155,150},{155,151},{150,151},{144,145},{141,145},{137,149},{134,149}, {131,146},{130,146},{129,147},{128,147},{128,141},{126,139},{124,139}, {122,137},{116,137},{114,135},{114,133},{112,131},{112,130},{113,129}, {-1,-1},{100,132},{101,132},{103,134},{103,137},{102,137},{102,135}, {100,133},{-1,-1},{106,134},{111,134},{111,135},{106,135},{-1,-1}, {158,136},{161,136},{161,137},{157,141},{152,141},{152,140},{154,140}, {157,137},{-1,-1},{98,146},{103,146},{103,147},{101,149},{99,149}, {97,151},{96,151},{96,148},{97,147},{-1,-1},{174,148},{177,148}, {179,150},{179,151},{178,151},{176,149},{174,149},{-1,-1},{110,152}, {113,152},{114,153},{115,153},{116,152},{117,152},{119,154},{125,154}, {125,159},{124,160},{124,161},{127,164},{129,164},{131,166},{132,166}, {134,164},{134,158},{136,156},{136,152},{139,152},{139,156},{143,160}, {143,162},{145,164},{145,168},{147,170},{149,170},{151,172},{151,174}, {157,180},{157,193},{155,195},{155,197},{149,203},{149,205},{147,207}, {132,207},{128,203},{126,203},{126,201},{125,200},{124,200},{123,201}, {122,201},{122,199},{118,195},{109,195},{107,197},{103,197},{101,199}, {95,199},{93,201},{88,201},{86,199},{86,195},{84,193},{84,191},{80,187}, {80,183},{78,181},{78,176},{80,176},{84,172},{88,172},{90,170},{92,170}, {94,168},{94,164},{96,164},{102,158},{105,158},{107,160},{108,160}, {110,158},{110,156},{111,155},{111,154},{110,153},{-1,-1},{208,164}, {209,164},{209,165},{207,167},{204,167},{204,166},{206,166},{207,165}, {-1,-1},{180,172},{183,172},{185,174},{185,177},{184,177},{180,173}, {-1,-1},{188,202},{189,202},{193,206},{193,207},{187,213},{186,213}, {186,208},{188,206},{188,203},{-1,-1},{144,210},{145,210},{145,213}, {143,215},{140,215},{138,213},{138,212},{142,212},{143,211},{-1,-1}, {180,212},{183,212},{183,215},{181,215},{175,221},{170,221},{170,218}, {172,218},{174,216},{176,216},{179,213},{-1,-1},{90,244},{101,244}, {102,245},{103,245},{104,244},{109,244},{111,246},{112,246},{114,244}, {117,244},{118,245},{119,245},{120,244},{129,244},{131,246},{141,246}, {143,248},{149,248},{149,249},{147,251},{143,251},{141,253},{139,253}, {137,255},{106,255},{104,253},{96,253},{94,251},{90,251},{88,249}, {84,249},{82,247},{78,247},{78,246},{88,246},{89,245},{-1,-1},{152,252}, {155,252},{155,253},{152,253},{-2,-2}}; drawWorld(dpy, gc, pic, xOff, size, igsData); } /* * Here we take the world polygon point list and trace it out into a bitmap. */ static void drawWorld(Display *dpy, GC gc, Pixmap pic, int xOff, int size, const XPoint data[]) { XPoint temp[344]; int i, numPoints; numPoints = 0; for (i = 0;; ++i) { if (data[i].x < 0) { if (numPoints > 2) { XFillPolygon(dpy, pic, gc, temp, numPoints, Complex, CoordModeOrigin); } numPoints = 0; if (data[i].x == -2) return; } else { temp[numPoints].x = ((data[i].x * (size + 1)) >> 8) + xOff; temp[numPoints].y = ((data[i].y * (size + 1)) >> 8); if ((numPoints == 0) || (temp[numPoints - 1].x != temp[numPoints].x) || (temp[numPoints - 1].y != temp[numPoints].y)) { ++numPoints; assert(numPoints <= 344); } } } } /* * Returns the answer: * Where is the x coordinate of the "seam" in the yin yang symbol for this * particular y value? */ static int yinYangX(int size, int y) { float center; float fy = y + 0.5; if (y < size / 2) { center = (float)size * 0.25; return((int)((float)size * 0.5 + sqrt(center * center - (fy - center) * (fy - center)) + 0.5)); } else { center = (float)size * 0.75; return((int)((float)size * 0.5 - sqrt((float)(size * size) * 0.0625 - (fy - center) * (fy - center)) + 0.5)); } } static void decideAppearance(WhiteDesc *desc, int size, Rnd *rnd) { double minStripeW, maxStripeW, theta; minStripeW = (float)size / 20.0; if (minStripeW < 2.5) minStripeW = 2.5; maxStripeW = (float)size / 5.0; if (maxStripeW < 4.0) maxStripeW = 4.0; theta = rnd_float(rnd) * 2.0 * M_PI; desc->cosTheta = cos(theta); desc->sinTheta = sin(theta); desc->stripeWidth = minStripeW + (rnd_float(rnd) * (maxStripeW - minStripeW)); desc->xAdd = rnd_float(rnd) * desc->stripeWidth + (float)size * 3; /* Make sure that all x's are positive! */ desc->stripeMul = rnd_float(rnd) * 4.0 + 1.5; desc->zMul = rnd_float(rnd) * 650.0 + 70.0; } cgoban-1.9.14/src/editBoard.c0000664000671000067100000010114507043224470011360 /* * src/editBoard.c, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include #include "cgoban.h" #include "sgf.h" #include "sgfIn.h" #include "sgfPlay.h" #include "sgfOut.h" #include "goban.h" #include "msg.h" #include "sgfMap.h" #ifdef _EDITBOARD_H_ #error Levelization Error. #endif #include "editBoard.h" /********************************************************************** * Data types **********************************************************************/ typedef enum { setMark_toggle, setMark_forceOn, setMark_forceOff } SetMarkAction; /********************************************************************** * Forward declarations **********************************************************************/ static void toolsQuit(void *packet); static GobanOut gridPressed(void *packet, int loc); static GobanOut quitPressed(void *packet); static GobanOut passPressed(void *packet); static GobanOut rewPressed(void *packet); static GobanOut backPressed(void *packet); static GobanOut fwdPressed(void *packet); static GobanOut ffPressed(void *packet); static GobanOut donePressed(void *packet); static GobanOut disputePressed(void *packet); static GobanOut savePressed(void *packet); static GobanOut gameInfoPressed(void *packet); static void writeGobanComments(EditBoard *e), readGobanComments(EditBoard *e); static void clearComments(EditBoard *eb); static bool backOk(void *packet); static bool fwdOk(void *packet); static void saveFile(AbutFsel *fsel, void *packet, const char *fname); static void gobanDestroyed(void *packet); static GobanOut jumpToLoc(EditBoard *eb, int loc); static void addPattern(EditBoard *eb, GoStone color, int loc); static void setMark(EditBoard *eb, SgfType sType, int loc, SetMarkAction action); static void addLetter(EditBoard *eb, int loc); static bool addNumber(EditBoard *eb, int loc, bool moveNum); static bool markGroup(EditBoard *eb, SgfType type, int loc); static ButOut newTool(void *packet); static ButOut shiftPressed(But *but, bool press); static ButOut newActiveSgfNode(void *packet, int nodeNum); static void changeWhoseMove(EditBoard *eb); static ButOut reallyQuit(But *but); static ButOut dontQuit(But *but); static ButOut quitWinDead(void *packet); static EditBoard *createSgf(Cgoban *cg, Sgf *sgf, const char *fName); static void infoDead(EditInfo *info, void *packet); /********************************************************************** * Global variables **********************************************************************/ static const GobanActions editBoard_actions = { gridPressed, quitPressed, passPressed, rewPressed, backPressed, fwdPressed, ffPressed, donePressed, disputePressed, savePressed, NULL, /* editPressed / printPressed */ gameInfoPressed, &help_editBoard, gobanDestroyed, backOk, backOk, fwdOk, fwdOk}; /********************************************************************** * Functions **********************************************************************/ EditBoard *editBoard_create(Cgoban *cg, const char *fName) { Sgf *sgf; const char *err; Str *tmpTitle; bool noFile = FALSE; sgf = sgf_createFile(cg, fName, &err, &noFile); if (sgf == NULL) { if (noFile) { tmpTitle = str_create(); str_print(tmpTitle, msg_noSuchGame, fName); abutMsg_winCreate(cg->abut, "Cgoban Error", str_chars(tmpTitle)); str_destroy(tmpTitle); } else { abutMsg_winCreate(cg->abut, "Cgoban Error", err); } return(FALSE); } return(createSgf(cg, sgf, fName)); } EditBoard *editBoard_createSgf(Cgoban *cg, const Sgf *sgf) { EditBoard *eb; eb = createSgf(cg, sgf_copy(sgf), NULL); if (eb != NULL) { ffPressed(eb); goban_update(eb->goban); } return(eb); } static EditBoard *createSgf(Cgoban *cg, Sgf *sgf, const char *fName) { EditBoard *eb; SgfElem *me; const char *white = NULL, *black = NULL, *title; GoRules rules; int size; int hcap; float komi; GoTime time; static const ButKey shiftKeys[] = {{XK_Shift_L, 0,0}, {XK_Shift_R,0,0}, {0,0,0}}; static const ButKey shiftUpKeys[] = {{XK_Up, ShiftMask, ShiftMask}, {0,0,0}}; static const ButKey shiftDownKeys[] = {{XK_Down, ShiftMask, ShiftMask}, {0,0,0}}; Str *tmpTitle = NULL; sgf->mode = sgfInsert_variant; eb = wms_malloc(sizeof(EditBoard)); MAGIC_SET(eb); eb->cg = cg; eb->fsel = NULL; eb->reallyQuit = NULL; eb->sgf = sgf; me = sgf_findType(sgf, sgfType_rules); if (me) { rules = (GoRules)me->iVal; } else rules = goRules_japanese; me = sgf_findType(sgf, sgfType_size); if (me) { size = me->iVal; } else { size = 19; } me = sgf_findType(sgf, sgfType_handicap); if (me) { hcap = me->iVal; } else { hcap = 0; } me = sgf_findType(sgf, sgfType_komi); if (me) { komi = (float)me->iVal / 2.0; } else { komi = 0.0; } me = sgf_findFirstType(sgf, sgfType_playerName); while (me) { if (me->gVal == goStone_white) white = str_chars(me->sVal); else { assert(me->gVal == goStone_black); black = str_chars(me->sVal); } me = sgfElem_findFirstType(me, sgfType_playerName); } str_init(&eb->fName); if (fName != NULL) { str_copyChars(&eb->fName, fName); } else if (white && black) { str_print(&eb->fName, "%s-%s.sgf", white, black); } else { str_copyChars(&eb->fName, "game.sgf"); } me = sgf_findFirstType(sgf, sgfType_time); if (me) { goTime_parseDescribeChars(&time, str_chars(me->sVal)); } else { time.type = goTime_none; } eb->game = goGame_create(size, rules, hcap, komi, &time, TRUE); sgf_play(sgf, eb->game, NULL, eb->currentNodeNum = 0, NULL); ++eb->game->maxMoves; me = sgf_findFirstType(sgf, sgfType_title); if (me) { title = str_chars(me->sVal); } else { if (white && black) { tmpTitle = str_create(); str_print(tmpTitle, msg_localTitle, white, black); title = str_chars(tmpTitle); } else title = msg_noTitle; } eb->goban = goban_create(cg, &editBoard_actions, eb, eb->game, "edit", title); if (tmpTitle) str_destroy(tmpTitle); eb->goban->iDec1 = stoneGroup_create(&cg->cgbuts, eb->goban->iWin, 2, BUT_DRAWABLE); assert((hcap == 0) || ((hcap >= 2) && (hcap <= 27))); butCt_setText(eb->goban->edit, msg_printGame); eb->lastComment = NULL; editToolWin_init(&eb->tools, cg, eb->sgf, toolsQuit, newTool, newActiveSgfNode, eb); eb->oldTool = editTool_changeBoard; eb->shiftKeytrap = butKeytrap_create(shiftPressed, eb, eb->goban->win, BUT_DRAWABLE|BUT_PRESSABLE); but_setKeys(eb->shiftKeytrap, shiftKeys); eb->prevVar = butKeytrap_create(editToolWin_shiftUpPressed, &eb->tools, eb->goban->win, BUT_DRAWABLE|BUT_PRESSABLE); but_setKeys(eb->prevVar, shiftUpKeys); eb->nextVar = butKeytrap_create(editToolWin_shiftDownPressed, &eb->tools, eb->goban->win, BUT_DRAWABLE|BUT_PRESSABLE); but_setKeys(eb->nextVar, shiftDownKeys); eb->invertShift = FALSE; butKeytrap_setHold(eb->shiftKeytrap, FALSE); writeGobanComments(eb); newTool(eb); eb->info = NULL; return(eb); } void editBoard_destroy(EditBoard *eb) { assert(MAGIC(eb)); str_deinit(&eb->fName); if (eb->reallyQuit) { abutMsg_destroy(eb->reallyQuit, FALSE); eb->reallyQuit = NULL; } if (eb->sgf) sgf_destroy(eb->sgf); if (eb->goban) goban_destroy(eb->goban, FALSE); if (eb->game) goGame_destroy(eb->game); editToolWin_deinit(&eb->tools); if (eb->info) { editInfo_destroy(eb->info, FALSE); eb->info = NULL; } MAGIC_UNSET(eb); wms_free(eb); } static void toolsQuit(void *packet) { quitPressed(packet); } static GobanOut gridPressed(void *packet, int loc) { EditBoard *eb = packet; ButEnv *env; GobanOut result = gobanOut_draw; assert(MAGIC(eb)); assert(eb->sgf->active != NULL); env = eb->cg->env; switch(eb->tools.tool) { case editTool_play: if (butEnv_keyModifiers(env) & ShiftMask) { result = jumpToLoc(eb, loc); } else { if (goBoard_stone(eb->game->board, loc) != goStone_empty) { result = gobanOut_err; } else { eb->tools.modified = TRUE; readGobanComments(eb); sgf_addNode(eb->sgf); assert(eb->sgf->active->mapX < 1000); editToolWin_nodeAdded(&eb->tools, eb->sgf->active); sgf_move(eb->sgf, goGame_whoseMove(eb->game), goBoard_loc2Sgf(eb->game->board, loc)); sgf_play(eb->sgf, eb->game, eb->goban->pic, ++eb->currentNodeNum, NULL); editToolWin_newActiveNode(&eb->tools, eb->sgf->active); writeGobanComments(eb); } } break; case editTool_changeBoard: eb->tools.modified = TRUE; if (goStone_isStone(goBoard_stone(eb->game->board, loc))) addPattern(eb, goStone_empty, loc); else if (butEnv_keyModifiers(env) & ShiftMask) addPattern(eb, goStone_black, loc); else addPattern(eb, goStone_white, loc); break; case editTool_score: if (goStone_isStone(goBoard_stone(eb->game->board, loc))) goGame_markDead(eb->game, loc); else result = gobanOut_err; break; case editTool_triangle: if (butEnv_keyModifiers(env) & ShiftMask) { if (!markGroup(eb, sgfType_triangle, loc)) result = gobanOut_err; else { eb->tools.modified = TRUE; } } else { eb->tools.modified = TRUE; setMark(eb, sgfType_triangle, loc, setMark_toggle); } break; case editTool_square: if (butEnv_keyModifiers(env) & ShiftMask) { if (!markGroup(eb, sgfType_square, loc)) result = gobanOut_err; else { eb->tools.modified = TRUE; } } else { eb->tools.modified = TRUE; setMark(eb, sgfType_square, loc, setMark_toggle); } break; case editTool_circle: if (butEnv_keyModifiers(env) & ShiftMask) { if (!markGroup(eb, sgfType_circle, loc)) result = gobanOut_err; else { eb->tools.modified = TRUE; } } else { eb->tools.modified = TRUE; setMark(eb, sgfType_circle, loc, setMark_toggle); } break; case editTool_letter: eb->tools.modified = TRUE; addLetter(eb, loc); break; case editTool_number: if (addNumber(eb, loc, butEnv_keyModifiers(env) & ShiftMask)) { eb->tools.modified = TRUE; } else result = gobanOut_err; break; } editToolWin_newColor(&eb->tools, goGame_whoseMove(eb->game)); assert(eb->sgf->active != NULL); sgfMap_changeNode(eb->tools.sgfMap, eb->sgf->active); return(result); } static GobanOut jumpToLoc(EditBoard *eb, int loc) { char moveTo[5]; int newNode, i; strcpy(moveTo, goBoard_loc2Sgf(eb->game->board, loc)); newNode = -1; if (goBoard_stone(eb->game->board, loc) == goStone_empty) { i = sgfElem_findMove(eb->sgf->active, moveTo, 1); if (i >= 0) { newNode = eb->currentNodeNum + i; } else { i = sgfElem_findMove(eb->sgf->active, moveTo, -1); if (i >= 0) newNode = eb->currentNodeNum - i; } } else { i = sgfElem_findMove(eb->sgf->active, moveTo, -1); assert(i >= 0); newNode = eb->currentNodeNum - i; } if (newNode > 0) { readGobanComments(eb); sgf_play(eb->sgf, eb->game, eb->goban->pic, eb->currentNodeNum = newNode, NULL); editToolWin_newActiveNode(&eb->tools, eb->sgf->active); writeGobanComments(eb); return(gobanOut_draw); } else return(gobanOut_err); } static GobanOut quitPressed(void *packet) { EditBoard *eb = packet; AbutMsgOpt buttons[2]; Str saveMessage; assert(MAGIC(eb)); readGobanComments(eb); if (eb->tools.modified) { buttons[0].name = msg_noCancel; buttons[0].callback = dontQuit; buttons[0].packet = eb; buttons[0].keyEq = NULL; buttons[1].name = msg_yesQuit; buttons[1].callback = reallyQuit; buttons[1].packet = eb; buttons[1].keyEq = NULL; str_init(&saveMessage); str_print(&saveMessage, msg_reallyQuit, str_chars(&eb->fName)); if (eb->reallyQuit) abutMsg_destroy(eb->reallyQuit, FALSE); eb->reallyQuit = abutMsg_winOptCreate(eb->cg->abut, "Cgoban Warning", str_chars(&saveMessage), quitWinDead, eb, 2, buttons); str_deinit(&saveMessage); } else editBoard_destroy(packet); return(gobanOut_noDraw); } static GobanOut passPressed(void *packet) { EditBoard *eb = packet; assert(MAGIC(eb)); switch(eb->tools.tool) { case editTool_play: readGobanComments(eb); sgf_addNode(eb->sgf); assert(eb->sgf->active->parent->activeChild == eb->sgf->active); editToolWin_nodeAdded(&eb->tools, eb->sgf->active); assert(eb->sgf->active->parent->activeChild == eb->sgf->active); readGobanComments(eb); assert(eb->sgf->active->type == sgfType_node); assert(eb->sgf->active->parent->activeChild == eb->sgf->active); assert((eb->sgf->active->parent->childH != eb->sgf->active->parent->childT) || (eb->sgf->active->parent->activeChild == eb->sgf->active->parent->childH)); sgf_pass(eb->sgf, goGame_whoseMove(eb->game)); assert(eb->sgf->active->type == sgfType_pass); assert(eb->sgf->active->parent->activeChild == eb->sgf->active); assert(eb->sgf->active->parent->activeChild == eb->sgf->active->parent->childH); assert(eb->sgf->active->parent->activeChild == eb->sgf->active->parent->childT); assert((eb->sgf->active->parent->parent->childH != eb->sgf->active->parent->parent->childT) || (eb->sgf->active->parent->parent->activeChild == eb->sgf->active->parent->parent->childH)); sgf_play(eb->sgf, eb->game, eb->goban->pic, ++eb->currentNodeNum, NULL); editToolWin_newActiveNode(&eb->tools, eb->sgf->active); writeGobanComments(eb); break; case editTool_changeBoard: readGobanComments(eb); sgf_addNode(eb->sgf); clearComments(eb); editToolWin_newActiveNode(&eb->tools, eb->sgf->active); writeGobanComments(eb); break; default: break; } editToolWin_newColor(&eb->tools, goGame_whoseMove(eb->game)); sgfMap_changeNode(eb->tools.sgfMap, eb->sgf->active); return(gobanOut_draw); } static GobanOut rewPressed(void *packet) { EditBoard *e = packet; assert(MAGIC(e)); readGobanComments(e); sgf_play(e->sgf, e->game, e->goban->pic, e->currentNodeNum = 0, NULL); editToolWin_newActiveNode(&e->tools, e->sgf->active); writeGobanComments(e); editToolWin_newColor(&e->tools, goGame_whoseMove(e->game)); return(gobanOut_draw); } static GobanOut backPressed(void *packet) { EditBoard *eb = packet; SgfElem *active; int backCount = 1; assert(MAGIC(eb)); readGobanComments(eb); if (butEnv_keyModifiers(eb->cg->env) & ShiftMask) { /* * Jump to next node with comments or a variation. */ backCount = 0; active = eb->sgf->active; while (active) { if (active->type == sgfType_node) { ++backCount; } else if ((active->type >= sgfType_setBoard) && (active->type <= sgfType_comment) && backCount) break; if ((backCount > 0) && (active->childH != active->childT)) break; active = active->parent; } } sgf_play(eb->sgf, eb->game, eb->goban->pic, eb->currentNodeNum -= backCount, NULL); editToolWin_newActiveNode(&eb->tools, eb->sgf->active); writeGobanComments(eb); editToolWin_newColor(&eb->tools, goGame_whoseMove(eb->game)); return(gobanOut_draw); } static GobanOut fwdPressed(void *packet) { EditBoard *eb = packet; SgfElem *active; int fwdCount = 1; assert(MAGIC(eb)); readGobanComments(eb); if (butEnv_keyModifiers(eb->cg->env) & ShiftMask) { /* * Jump to next node with comments or a variation. */ active = eb->sgf->active->activeChild->activeChild; while (active) { if (active->type == sgfType_node) { ++fwdCount; } else if ((active->type >= sgfType_setBoard) && (active->type <= sgfType_comment)) break; if (active->childH != active->childT) break; active = active->activeChild; } } sgf_play(eb->sgf, eb->game, eb->goban->pic, eb->currentNodeNum += fwdCount, NULL); editToolWin_newActiveNode(&eb->tools, eb->sgf->active); writeGobanComments(eb); editToolWin_newColor(&eb->tools, goGame_whoseMove(eb->game)); return(gobanOut_draw); } static GobanOut ffPressed(void *packet) { EditBoard *e = packet; assert(MAGIC(e)); readGobanComments(e); e->currentNodeNum = sgf_play(e->sgf, e->game, e->goban->pic, -1, NULL); editToolWin_newActiveNode(&e->tools, e->sgf->active); writeGobanComments(e); editToolWin_newColor(&e->tools, goGame_whoseMove(e->game)); return(gobanOut_draw); } static GobanOut donePressed(void *packet) { SgfElem *otherTerrMarks; int i; EditBoard *eb = packet; Str *scoreComment; assert(MAGIC(eb)); readGobanComments(eb); while ((otherTerrMarks = sgfElem_findTypeInNode(eb->sgf->active, sgfType_territory))) { sgfElem_snip(otherTerrMarks, eb->sgf); } for (i = 0; i < goBoard_area(eb->game->board); ++i) { if (((eb->game->flags[i] & GOGAMEFLAGS_SEEN) == GOGAMEFLAGS_SEEWHITE) && ((goBoard_stone(eb->game->board, i) == goStone_empty) || (eb->game->flags[i] & GOGAMEFLAGS_MARKDEAD))) sgf_addTerritory(eb->sgf, goStone_white, goBoard_loc2Sgf(eb->game->board, i)); } for (i = 0; i < goBoard_area(eb->game->board); ++i) { if (((eb->game->flags[i] & GOGAMEFLAGS_SEEN) == GOGAMEFLAGS_SEEBLACK) && ((goBoard_stone(eb->game->board, i) == goStone_empty) || (eb->game->flags[i] & GOGAMEFLAGS_MARKDEAD))) sgf_addTerritory(eb->sgf, goStone_black, goBoard_loc2Sgf(eb->game->board, i)); } scoreComment = goScore_str(&eb->goban->score, eb->game, &eb->game->time, eb->goban->timers); sgf_catComment(eb->sgf, str_chars(scoreComment)); sgfMap_changeNode(eb->tools.sgfMap, eb->sgf->active); str_destroy(scoreComment); editToolWin_newTool(&eb->tools, editTool_play, TRUE); writeGobanComments(eb); sgfMap_changeNode(eb->tools.sgfMap, eb->sgf->active); return(gobanOut_noDraw); } static GobanOut disputePressed(void *packet) { return(gobanOut_noDraw); } static GobanOut savePressed(void *packet) { EditBoard *e = packet; assert(MAGIC(e)); if (e->fsel) abutFsel_destroy(e->fsel, FALSE); e->fsel = abutFsel_create(e->cg->abut, saveFile, e, "CGoban", msg_saveGameName, str_chars(&e->fName)); return(gobanOut_noDraw); } static void saveFile(AbutFsel *fsel, void *packet, const char *fname) { EditBoard *e = packet; int error; Str str; assert(MAGIC(e)); str_copy(&e->cg->lastDirAccessed, &fsel->pathVal); if (fname != NULL) { str_copyChars(&e->fName, fname); clp_setStr(e->cg->clp, "edit.sgfName", butTextin_get(fsel->in)); readGobanComments(e); e->tools.modified = FALSE; if (e->info) editInfo_updateSgf(e->info); if (!sgf_writeFile(e->sgf, fname, &error)) { str_init(&str); str_print(&str, "Error saving file \"%s\": %s", fname, strerror(errno)); cgoban_createMsgWindow(e->cg, "Cgoban Error", str_chars(&str)); str_deinit(&str); } } e->fsel = NULL; } static void clearComments(EditBoard *eb) { assert(MAGIC(eb)); goban_setComments(eb->goban, ""); } /* * This transfers comments from the SGF move chain to the goban. */ static void writeGobanComments(EditBoard *e) { SgfElem *comElem; assert(MAGIC(e)); comElem = sgfElem_findTypeInNode(e->sgf->active, sgfType_comment); if (comElem) { if (strcmp(str_chars(comElem->sVal), goban_getComments(e->goban))) goban_setComments(e->goban, str_chars(comElem->sVal)); } else { if (e->lastComment) goban_setComments(e->goban, ""); } e->lastComment = comElem; } /* * This transfers comments from the goban to the SGF move chain. */ static void readGobanComments(EditBoard *eb) { const char *comm; int cmpLen; assert(MAGIC(eb)); assert(eb->sgf->active->parent->activeChild == eb->sgf->active); comm = goban_getComments(eb->goban); if (comm[0]) { if (eb->lastComment) { cmpLen = str_len(eb->lastComment->sVal); if (str_chars(eb->lastComment->sVal)[cmpLen - 1] != '\n') { /* A "\n" was added. */ if ((strlen(comm) == cmpLen + 1) && !strncmp(comm, str_chars(eb->lastComment->sVal), cmpLen)) return; } else { if (!strcmp(comm, str_chars(eb->lastComment->sVal))) return; } } eb->tools.modified = TRUE; eb->sgf->mode = sgfInsert_inline; sgf_comment(eb->sgf, comm); eb->sgf->mode = sgfInsert_variant; eb->lastComment = sgfElem_findTypeInNode(eb->sgf->active, sgfType_comment); assert(eb->lastComment != NULL); assert(eb->sgf->active->parent->activeChild == eb->sgf->active); } else if (eb->lastComment) { eb->tools.modified = TRUE; sgfElem_snip(eb->lastComment, eb->sgf); eb->lastComment = NULL; assert(eb->sgf->active->parent->activeChild == eb->sgf->active); } sgfMap_setMapPointer(eb->tools.sgfMap, eb->sgf->active); } static bool backOk(void *packet) { EditBoard *e = packet; assert(MAGIC(e)); return((e->game->state == goGameState_play) && (e->currentNodeNum > 0)); } static bool fwdOk(void *packet) { EditBoard *e = packet; assert(MAGIC(e)); return((e->game->state == goGameState_play) && (e->sgf->active->activeChild != NULL)); } static void gobanDestroyed(void *packet) { EditBoard *eb = packet; assert(MAGIC(eb)); eb->goban = NULL; editBoard_destroy(eb); } static void addPattern(EditBoard *eb, GoStone color, int loc) { SgfElem *otherEdits, *oldActive; GoBoard *newBoard, *tmp; int i; otherEdits = sgfElem_findTypeInNode(eb->sgf->active, sgfType_setBoard); if (otherEdits == NULL) { /* * We always add a node if there are no other edits, 'cause they * shouldn't be in the same node as moves. */ readGobanComments(eb); sgf_addNode(eb->sgf); editToolWin_nodeAdded(&eb->tools, eb->sgf->active); ++eb->currentNodeNum; editToolWin_newActiveNode(&eb->tools, eb->sgf->active); writeGobanComments(eb); } /* * What we do is add the stone, copy the board, then recreate the game * just before this group of stones. Then we scan through the two boards, * looking for differences, and recording them in the sgf file. This * is very time consuming, but it's the easient way to do things so for * now I'll leave it as is. */ newBoard = goBoard_create(eb->game->size); goGame_setBoard(eb->game, color, loc); goBoard_copy(eb->game->board, newBoard); if (eb->currentNodeNum == 0) { /* We must start from a fresh board! */ goGame_moveTo(eb->game, 0); } else { /* We want to preserve the active node across this call to "play()". */ oldActive = eb->sgf->active; sgf_play(eb->sgf, eb->game, NULL, eb->currentNodeNum - 1, NULL); eb->sgf->active = oldActive; } eb->sgf->mode = sgfInsert_inline; /* * Now we have to snip out all previous edits. */ while ((otherEdits = sgfElem_findTypeInNode(eb->sgf->active, sgfType_setBoard))) { sgfElem_snip(otherEdits, eb->sgf); } /* First add all the empties... */ for (i = 0; i < goBoard_area(newBoard); ++i) { if ((goBoard_stone(newBoard, i) == goStone_empty) && (goBoard_stone(eb->game->board, i) != goStone_empty)) sgf_addStone(eb->sgf, goStone_empty, goBoard_loc2Sgf(newBoard, i)); } /* Now the white stones... */ for (i = 0; i < goBoard_area(newBoard); ++i) { if ((goBoard_stone(newBoard, i) == goStone_white) && (goBoard_stone(eb->game->board, i) != goStone_white)) sgf_addStone(eb->sgf, goStone_white, goBoard_loc2Sgf(newBoard, i)); } /* And finally the black stones. */ for (i = 0; i < goBoard_area(newBoard); ++i) { if ((goBoard_stone(newBoard, i) == goStone_black) && (goBoard_stone(eb->game->board, i) != goStone_black)) sgf_addStone(eb->sgf, goStone_black, goBoard_loc2Sgf(newBoard, i)); } /* Now put the board back the way that it should be. */ tmp = eb->game->board; eb->game->board = newBoard; eb->sgf->mode = sgfInsert_variant; goBoard_destroy(tmp); } static void setMark(EditBoard *eb, SgfType sType, int loc, SetMarkAction action) { SgfElem *search; bool remove; GoMarkType markAdded; for (search = eb->sgf->active; search && (search->type != sgfType_node); search = search->parent) { if (((search->type == sgfType_triangle) || (search->type == sgfType_circle) || (search->type == sgfType_square)) && (goBoard_sgf2Loc(eb->game->board, search->lVal) == loc)) { remove = (((search->type == sType) && (action == setMark_toggle)) || (action == setMark_forceOff)); sgfElem_snip(search, eb->sgf); if (remove) { grid_setMark(eb->goban->pic->boardButs[loc], goMark_none, 0); return; } break; } } search = sgfElem_findTypeInNode(eb->sgf->active, sType); if (search) eb->sgf->active = search; eb->sgf->mode = sgfInsert_inline; sgf_addLElem(eb->sgf, sType, goBoard_loc2Sgf(eb->game->board, loc)); eb->sgf->mode = sgfInsert_variant; if (sType == sgfType_triangle) { markAdded = goMark_triangle; } else if (sType == sgfType_square) { markAdded = goMark_square; } else { assert(sType == sgfType_circle); markAdded = goMark_circle; } grid_setMark(eb->goban->pic->boardButs[loc], markAdded, 0); } static void addLetter(EditBoard *eb, int loc) { SgfElem *search; int i; char letter[2]; for (search = eb->sgf->active; search && (search->type != sgfType_node); search = search->parent) { if ((search->type == sgfType_label) && (goBoard_sgf2Loc(eb->game->board, search->lVal) == loc)) { if (eb->sgf->active == search) eb->sgf->active = search->parent; sgfElem_snip(search, eb->sgf); grid_setMark(eb->goban->pic->boardButs[loc], goMark_none, 0); return; } } letter[0] = 'A'; letter[1] = '\0'; for (i = 0; i < goBoard_area(eb->game->board); ++i) { if (eb->goban->pic->boardButs[i]) { if ((grid_markType(eb->goban->pic->boardButs[i]) == goMark_letter) && (grid_markAux(eb->goban->pic->boardButs[i]) >= letter[0])) letter[0] = grid_markAux(eb->goban->pic->boardButs[i]) + 1; } } if (letter[0] == 'Z' + 1) letter[0] = 'a'; else if (letter[0] > 'z') letter[0] = 'z'; eb->sgf->mode = sgfInsert_inline; sgf_label(eb->sgf, goBoard_loc2Sgf(eb->game->board, loc), letter); eb->sgf->mode = sgfInsert_variant; grid_setMark(eb->goban->pic->boardButs[loc], goMark_letter, letter[0]); } static bool addNumber(EditBoard *eb, int loc, bool moveNum) { SgfElem *search; int i, val; char labelStr[4]; const char *sgfLoc; for (search = eb->sgf->active; search && (search->type != sgfType_node); search = search->parent) { if ((search->type == sgfType_label) && (goBoard_sgf2Loc(eb->game->board, search->lVal) == loc)) { if (eb->sgf->active == search) eb->sgf->active = search->parent; sgfElem_snip(search, eb->sgf); grid_setMark(eb->goban->pic->boardButs[loc], goMark_none, 0); return(TRUE); } } if (moveNum) { for (val = eb->game->moveNum - 1; val >= 0; --val) { if (eb->game->moves[val].move == loc) break; } if (val < 0) return(FALSE); else ++val; } else { val = 1; for (i = 0; i < goBoard_area(eb->game->board); ++i) { if (eb->goban->pic->boardButs[i]) { if ((grid_markType(eb->goban->pic->boardButs[i]) == goMark_number) && (grid_markAux(eb->goban->pic->boardButs[i]) >= val)) val = grid_markAux(eb->goban->pic->boardButs[i]) + 1; } } } if (val > 999) val = 999; sprintf(labelStr, "%d", val); eb->sgf->mode = sgfInsert_inline; sgfLoc = goBoard_loc2Sgf(eb->game->board, loc); sgf_label(eb->sgf, sgfLoc, labelStr); eb->sgf->mode = sgfInsert_variant; grid_setMark(eb->goban->pic->boardButs[loc], goMark_number, val); return(TRUE); } static bool markGroup(EditBoard *eb, SgfType type, int loc) { GoMarkType oldMark; SetMarkAction action; GoBoardGroupIter i; if (!goStone_isStone(goBoard_stone(eb->game->board, loc))) return(FALSE); oldMark = grid_markType(eb->goban->pic->boardButs[loc]); if ((oldMark == goMark_triangle) || (oldMark == goMark_square) || (oldMark == goMark_circle)) action = setMark_forceOff; else action = setMark_forceOn; goBoardGroupIter(i, eb->game->board, loc) { setMark(eb, type, goBoardGroupIter_loc(i, eb->game->board), action); } return(TRUE); } static ButOut shiftPressed(But *but, bool press) { EditBoard *eb = but_packet(but); ButOut result; assert(MAGIC(eb)); /* * Alas, the modifier flags don't change until AFTER the press, so we * have to invert the shift here. */ eb->invertShift = TRUE; /* * Change the oldTool thingy so we don't change color if we're on the * play tool. */ eb->oldTool = editTool_changeBoard; result = newTool(but_packet(but)); eb->invertShift = FALSE; return(result); } static ButOut newTool(void *packet) { EditBoard *eb = packet; bool shiftPressed, updateGoban = FALSE; uint pressAllowed = goPicMove_empty | goPicMove_stone; GoGameState gameState = goGameState_play; assert(MAGIC(eb)); shiftPressed = butEnv_keyModifiers(eb->cg->env) & ShiftMask; if (eb->invertShift) shiftPressed = !shiftPressed; switch(eb->tools.tool) { case editTool_play: if (!shiftPressed) pressAllowed = goPicMove_legal; if (eb->oldTool == editTool_play) { /* * Change whose turn it is. */ changeWhoseMove(eb); updateGoban = TRUE; } break; case editTool_changeBoard: if (!shiftPressed) pressAllowed |= goPicMove_forceWhite; else pressAllowed |= goPicMove_forceBlack; break; case editTool_score: pressAllowed = goPicMove_stone | goPicMove_noPass; gameState = goGameState_selectDead; break; case editTool_triangle: case editTool_square: case editTool_circle: case editTool_number: pressAllowed |= goPicMove_noPass; if (shiftPressed) pressAllowed = goPicMove_stone; break; case editTool_letter: pressAllowed |= goPicMove_noPass; break; } eb->oldTool = eb->tools.tool; if (pressAllowed != eb->goban->pic->allowedMoves) { eb->goban->pic->allowedMoves = pressAllowed; updateGoban = TRUE; } if (gameState != eb->game->state) { eb->game->state = gameState; if (eb->game->state == goGameState_play) { /* * Replay the game to get rid of all those nasty territory markers. */ sgf_play(eb->sgf, eb->game, eb->goban->pic, eb->currentNodeNum, NULL); } updateGoban = TRUE; } if (updateGoban) goban_update(eb->goban); return(0); } static ButOut newActiveSgfNode(void *packet, int nodeNum) { EditBoard *eb = packet; assert(MAGIC(eb)); if (eb->game->state == goGameState_selectDead) { abutMsg_winCreate(eb->cg->abut, "Cgoban Error", msg_changeNodeWhileScoring); return(BUTOUT_ERR); } else { readGobanComments(eb); sgf_play(eb->sgf, eb->game, eb->goban->pic, nodeNum, NULL); eb->currentNodeNum = nodeNum; editToolWin_newActiveNode(&eb->tools, eb->sgf->active); writeGobanComments(eb); editToolWin_newColor(&eb->tools, goGame_whoseMove(eb->game)); goban_update(eb->goban); return(0); } } static void changeWhoseMove(EditBoard *eb) { SgfElem *oldSetTurn; GoStone newColor; newColor = goStone_opponent(eb->game->whoseMove); oldSetTurn = sgfElem_findTypeInNode(eb->sgf->active, sgfType_whoseMove); if (oldSetTurn) { assert(oldSetTurn->gVal != newColor); oldSetTurn->gVal = newColor; } else { eb->sgf->mode = sgfInsert_inline; sgf_setWhoseMove(eb->sgf, newColor); eb->sgf->mode = sgfInsert_variant; } eb->game->setWhoseMoveNum = eb->game->moveNum; eb->game->whoseMove = eb->game->setWhoseMoveColor = newColor; editToolWin_newColor(&eb->tools, newColor); but_draw(eb->tools.selDesc[editTool_play]); } static ButOut reallyQuit(But *but) { editBoard_destroy(but_packet(but)); return(0); } static ButOut dontQuit(But *but) { EditBoard *eb = but_packet(but); assert(MAGIC(eb)); abutMsg_destroy(eb->reallyQuit, FALSE); eb->reallyQuit = NULL; return(0); } static ButOut quitWinDead(void *packet) { EditBoard *eb = packet; assert(MAGIC(eb)); eb->reallyQuit = NULL; return(0); } static GobanOut gameInfoPressed(void *packet) { EditBoard *eb = packet; assert(MAGIC(eb)); if (eb->info) { XRaiseWindow(butEnv_dpy(eb->cg->env), butWin_xwin(eb->info->win)); } else { eb->info = editInfo_create(eb->cg, eb->goban, eb->sgf, infoDead, eb); } return(gobanOut_noDraw); } static void infoDead(EditInfo *info, void *packet) { EditBoard *eb = packet; assert(MAGIC(eb)); assert(eb->info == info); eb->info = NULL; } cgoban-1.9.14/src/editInfo.c0000664000671000067100000002450007043224470011223 /* * src/editInfo.c, part of Complete Goban (game program) * Copyright (C) 1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include "sgf.h" #include "msg.h" #include #include #ifdef _EDITINFO_H_ Levelization Error. #endif #include "editInfo.h" /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut unmap(ButWin *win); static ButOut map(ButWin *win); static ButOut resize(ButWin *win); static ButOut destroy(ButWin *win); static ButOut newTitle(But *but, const char *newStr); /********************************************************************** * Globals **********************************************************************/ static const struct { const char *title; SgfType type; GoStone color; } sgfVals[] = { {msg_gameTitle, sgfType_title, goStone_empty}, {msg_copyrightC, sgfType_copyright, goStone_empty}, {msg_wStoneName, sgfType_playerName, goStone_white}, {msg_bStoneName, sgfType_playerName, goStone_black}, {msg_wRank, sgfType_playerRank, goStone_white}, {msg_bRank, sgfType_playerRank, goStone_black}, {msg_handicapC, sgfType_handicap, goStone_empty}, {msg_komiC, sgfType_komi, goStone_empty}, {msg_time, sgfType_time, goStone_empty}, {msg_result, sgfType_result, goStone_empty}, {msg_date, sgfType_date, goStone_empty}, {msg_place, sgfType_place, goStone_empty}, {msg_event, sgfType_event, goStone_empty}, {msg_source, sgfType_source, goStone_empty}}; /********************************************************************** * Functions **********************************************************************/ EditInfo *editInfo_create(Cgoban *cg, Goban *goban, Sgf *sgf, void (*dCallback)(EditInfo *info, void *packet), void *packet) { int i, minW, minH, w, h, bw, fontH; ButEnv *env; EditInfo *info; bool err; EditInfoVal val; Str defValBuf; const char *defVal; SgfElem *elLookup; ButOut (*callback)(But *but, const char *newStr); info = wms_malloc(sizeof(EditInfo)); MAGIC_SET(info); env = cg->env; info->cg = cg; info->goban = goban; info->sgf = sgf; info->destroy = dCallback; info->packet = packet; fontH = cg->fontH; bw = butEnv_stdBw(env); minW = fontH * 24 + bw * 14; minH = minW; w = (double)minW * clp_getDouble(cg->clp, "edit.infoW") + 0.5; h = (double)minH * clp_getDouble(cg->clp, "edit.infoH") + 0.5; info->win = butWin_create(info, cg->env, "Cgoban Game Info", w, h, unmap, map, resize, destroy); i = clpEntry_iGetInt(clp_lookup(cg->clp, "edit.infoX"), &err); if (!err) butWin_setX(info->win, i); i = clpEntry_iGetInt(clp_lookup(cg->clp, "edit.infoY"), &err); if (!err) butWin_setY(info->win, i); butWin_setMinW(info->win, minW); butWin_setMinH(info->win, minH); butWin_setMaxW(info->win, 0); butWin_setMaxH(info->win, 0); butWin_activate(info->win); info->bg = butBoxFilled_create(info->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(info->bg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); info->winTitle = butText_create(info->win, 1, BUT_DRAWABLE, msg_editInfoTitle, butText_center); butText_setFont(info->winTitle, 2); str_init(&defValBuf); editInfoVal_iter(val) { info->infos[val].name = butText_create(info->win, 1, BUT_DRAWABLE, sgfVals[val].title, butText_left); defVal = ""; for (elLookup = &sgf->top; (elLookup != NULL) && (elLookup->type != sgfType_node); elLookup = elLookup->activeChild) { if ((elLookup->type == sgfVals[val].type) && ((sgfVals[val].color == goStone_empty) || (sgfVals[val].color == elLookup->gVal))) { switch(elLookup->type) { case sgfType_komi: str_print(&defValBuf, "%g", (double)elLookup->iVal / 2.0); defVal = str_chars(&defValBuf); break; case sgfType_handicap: str_print(&defValBuf, "%d", elLookup->iVal); defVal = str_chars(&defValBuf); break; default: defVal = str_chars(elLookup->sVal); break; } break; } } if (val == editInfo_gameTitle) callback = newTitle; else callback = NULL; info->infos[val].in = butTextin_create(callback, info, info->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, defVal, 1000); } str_deinit(&defValBuf); info->gameComment = abutTerm_create(cg->abut, info->win, 1, TRUE); for (elLookup = &sgf->top; (elLookup != NULL) && (elLookup->type != sgfType_node); elLookup = elLookup->activeChild) { if (elLookup->type == sgfType_gameComment) { abutTerm_set(info->gameComment, str_chars(elLookup->sVal)); break; } } return(info); } void editInfo_destroy(EditInfo *info, bool propagate) { Cgoban *cg; assert(MAGIC(info)); if (propagate) { info->destroy(info, info->packet); assert(MAGIC(info)); } if (info->win) { cg = info->cg; assert(MAGIC(cg)); clp_setDouble(cg->clp, "edit.infoW", (double)butWin_w(info->win) / (double)butWin_getMinW(info->win)); clp_setDouble(cg->clp, "edit.infoH", (double)butWin_h(info->win) / (double)butWin_getMinH(info->win)); clp_setInt(cg->clp, "edit.infoX", butWin_x(info->win)); clp_setInt(cg->clp, "edit.infoY", butWin_y(info->win)); butWin_setDestroy(info->win, NULL); butWin_destroy(info->win); } MAGIC_UNSET(info); wms_free(info); } static ButOut unmap(ButWin *win) { return(0); } static ButOut map(ButWin *win) { return(0); } static ButOut resize(ButWin *win) { EditInfo *info = butWin_packet(win); int fontH, bw, w, h; int y; int w2; int lw, rw; EditInfoVal val; int textW, maxTextW; assert(MAGIC(info)); w = butWin_w(info->win); h = butWin_h(info->win); fontH = info->cg->fontH; bw = butEnv_stdBw(butWin_env(win)); but_resize(info->bg, 0, 0, w, h); but_resize(info->winTitle, bw*2, y = bw*2, w - bw*4, fontH*2); maxTextW = 0; editInfoVal_iter(val) { textW = butEnv_textWidth(info->cg->env, sgfVals[val].title, 0); if (textW > maxTextW) maxTextW = textW; } w2 = (w + bw) / 2; lw = w2 - bw * 3; rw = w - bw * 2 - w2; editInfoVal_iter(val) { if (val <= editInfo_copyright) { but_resize(info->infos[val].name, bw*2, y += bw + fontH*2, maxTextW, fontH*2); but_resize(info->infos[val].in, bw*3 + maxTextW, y, w - (bw*5 + maxTextW), fontH*2); } else { but_resize(info->infos[val].name, bw*2, y += bw + fontH*2, maxTextW, fontH*2); but_resize(info->infos[val].in, bw*3 + maxTextW, y, lw - (maxTextW + bw), fontH*2); ++val; but_resize(info->infos[val].name, w2, y, maxTextW, fontH*2); but_resize(info->infos[val].in, w2 + maxTextW + bw, y, rw - (maxTextW + bw), fontH*2); } } y += bw + fontH * 2; abutTerm_resize(info->gameComment, bw*2, y, w - bw*4, h - y - bw*2); return(0); } static ButOut destroy(ButWin *win) { EditInfo *info = butWin_packet(win); Cgoban *cg; assert(MAGIC(info)); editInfo_updateSgf(info); cg = info->cg; assert(MAGIC(cg)); clp_setDouble(cg->clp, "edit.infoW", (double)butWin_w(win) / (double)butWin_getMinW(win)); clp_setDouble(cg->clp, "edit.infoH", (double)butWin_h(win) / (double)butWin_getMinH(win)); clp_setInt(cg->clp, "edit.infoX", butWin_x(win)); clp_setInt(cg->clp, "edit.infoY", butWin_y(win)); info->win = NULL; editInfo_destroy(info, TRUE); return(0); } static ButOut newTitle(But *but, const char *newStr) { EditInfo *info = but_packet(but); assert(MAGIC(info)); assert(but == info->infos[editInfo_gameTitle].in); editInfo_updateSgf(info); butText_set(info->goban->labelText, newStr); return(0); } /* * This function is really badly structured. I should fix it up. */ void editInfo_updateSgf(EditInfo *info) { EditInfoVal val; const char *newVal; SgfElem *elLookup; int newIval; bool found, change, err; SgfInsert oldMode; newIval = 0; /* To shut up the warning from gcc. */ change = FALSE; /* To shut up the warning from gcc. */ assert(MAGIC(info)); editInfoVal_iter(val) { newVal = butTextin_get(info->infos[val].in); found = FALSE; for (elLookup = &info->sgf->top; (elLookup != NULL) && (elLookup->type != sgfType_node); elLookup = elLookup->activeChild) { if ((elLookup->type == sgfVals[val].type) && ((sgfVals[val].color == goStone_empty) || (sgfVals[val].color == elLookup->gVal))) { found = TRUE; break; } } err = FALSE; if (val == editInfo_komi) { newIval = (int)(wms_atof(newVal, &err) * 2.0); } else if (val == editInfo_handicap) { newIval = wms_atoi(newVal, &err); } if (!found) { if (newVal[0] != '\0') change = TRUE; } else { if ((val == editInfo_komi) || (val == editInfo_handicap)) { change = (newIval != elLookup->iVal); } else { change = strcmp(newVal, str_chars(elLookup->sVal)); } } if (change) { if (found) { if ((val == editInfo_komi) || (val == editInfo_handicap)) { if (!err) elLookup->iVal = newIval; } else { str_copyChars(elLookup->sVal, newVal); } } else { elLookup = info->sgf->active; info->sgf->active = info->sgf->top.activeChild; oldMode = info->sgf->mode; info->sgf->mode = sgfInsert_inline; if ((val == editInfo_komi) || (val == editInfo_handicap)) { if (!err) sgf_addCIElem(info->sgf, sgfVals[val].type, sgfVals[val].color, newIval); } else { sgf_addCSElem(info->sgf, sgfVals[val].type, sgfVals[val].color, newVal); } info->sgf->mode = oldMode; info->sgf->active = elLookup; } } } newVal = butTbin_get(info->gameComment->tbin); found = FALSE; for (elLookup = &info->sgf->top; (elLookup != NULL) && (elLookup->type != sgfType_node); elLookup = elLookup->activeChild) { if (elLookup->type == sgfType_gameComment) { found = TRUE; break; } } if (found) { if (strcmp(newVal, str_chars(elLookup->sVal))) { str_copyChars(elLookup->sVal, newVal); } } else { if (newVal[0] != '\0') { elLookup = info->sgf->active; info->sgf->active = info->sgf->top.activeChild; oldMode = info->sgf->mode; info->sgf->mode = sgfInsert_inline; sgf_addCSElem(info->sgf, sgfType_gameComment, goStone_empty, newVal); info->sgf->mode = oldMode; info->sgf->active = elLookup; } } } cgoban-1.9.14/src/editTool.c0000664000671000067100000003720507050207032011244 /* * src/editTool.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cgoban.h" #include "editTool.h" #include "msg.h" #include "sgfMap.h" #include "sgf.h" #include "help.h" /********************************************************************** * Forward declarations **********************************************************************/ static ButOut unmap(ButWin *win); static ButOut map(ButWin *win); static ButOut resize(ButWin *win); static ButOut iResize(ButWin *win); static ButOut mapResize(ButWin *win); static ButOut destroy(ButWin *win); static ButOut newTool(But *but, int val); static ButOut windowQuit(ButWin *win); static ButOut mapCallback(But *but, int newNodeNum); static ButOut cutPressed(But *but); static ButOut movePressed(But *but); static void updateTreeButtons(EditToolWin *etw); /********************************************************************** * Functions **********************************************************************/ #define editW(bw, fontH) ((fontH*2 + bw*4) * editTool_max + bw * 4) void editToolWin_init(EditToolWin *etw, Cgoban *cg, Sgf *sgf, void (*quitRequested)(void *packet), ButOut (*newToolCallback)(void *packet), ButOut (*newActiveNode)(void *packet, int nodeNum), void *packet) { static const ButKey shiftUpKeys[] = {{XK_Up, ShiftMask, ShiftMask}, {0,0,0}}; static const ButKey shiftDownKeys[] = {{XK_Down, ShiftMask, ShiftMask}, {0,0,0}}; int w, h, minW, minH; But *b; int i, fontH; bool err; MAGIC_SET(etw); etw->cg = cg; etw->modified = FALSE; fontH = butEnv_fontH(cg->env, 0); minW = editW(butEnv_stdBw(cg->env), fontH); minH = minW * 0.70710678 + 0.5; w = (fontH * clp_getDouble(cg->clp, "edit.toolW") + 0.5); h = (fontH * clp_getDouble(cg->clp, "edit.toolH") + 0.5); if (w < minW) w = minW; if (h < minH) h = minH; etw->toolWin = butWin_iCreate(etw, cg->env, "Cgoban Tools", w, h, &etw->toolIWin, FALSE, 48, 48, unmap, map, resize, iResize, destroy); i = clp_iGetInt(cg->clp, "edit.toolX", &err); if (!err) butWin_setX(etw->toolWin, i); i = clp_iGetInt(cg->clp, "edit.toolY", &err); if (!err) butWin_setY(etw->toolWin, i); butWin_setMinW(etw->toolWin, minW); butWin_setMinH(etw->toolWin, minH); butWin_setMaxW(etw->toolWin, 0); butWin_setMaxH(etw->toolWin, 0); butWin_setQuit(etw->toolWin, windowQuit); butWin_activate(etw->toolWin); etw->toolBg = butBoxFilled_create(etw->toolWin, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(etw->toolBg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); etw->toolIBg = butBoxFilled_create(etw->toolIWin, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(etw->toolIBg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); etw->toolIPic = toolPic_create(&cg->cgbuts, etw->toolIWin, 1, BUT_DRAWABLE); etw->toolSel = butRadio_create(newTool, etw, etw->toolWin, 1, BUT_PRESSABLE|BUT_DRAWABLE, 0, editTool_max); etw->selDesc[editTool_play] = b = grid_create(&cg->cgbuts, NULL, NULL, etw->toolWin, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(b, etw->lastColor = goStone_black, FALSE); grid_setLineGroup(b, gridLines_none); grid_setVersion(b, 0); etw->selDesc[editTool_changeBoard] = stoneGroup_create(&cg->cgbuts, etw->toolWin, 2, BUT_DRAWABLE|BUT_PRESSTHRU); etw->selDesc[editTool_score] = b = grid_create(&cg->cgbuts, NULL, NULL, etw->toolWin, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(b, goStone_black, FALSE); grid_setLineGroup(b, gridLines_none); grid_setVersion(b, CGBUTS_YINYANG(1)); etw->selDesc[editTool_triangle] = b = grid_create(&cg->cgbuts, NULL, NULL, etw->toolWin, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(b, goStone_black, FALSE); grid_setLineGroup(b, gridLines_none); grid_setMark(b, goMark_triangle, 0); etw->selDesc[editTool_square] = b = grid_create(&cg->cgbuts, NULL, NULL, etw->toolWin, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(b, goStone_black, FALSE); grid_setLineGroup(b, gridLines_none); grid_setMark(b, goMark_square, 0); etw->selDesc[editTool_circle] = b = grid_create(&cg->cgbuts, NULL, NULL, etw->toolWin, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(b, goStone_black, FALSE); grid_setLineGroup(b, gridLines_none); grid_setMark(b, goMark_circle, 0); etw->selDesc[editTool_letter] = b = grid_create(&cg->cgbuts, NULL, NULL, etw->toolWin, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(b, goStone_black, FALSE); grid_setLineGroup(b, gridLines_none); grid_setMark(b, goMark_letter, 'A'); grid_setVersion(b, 1); etw->selDesc[editTool_number] = b = grid_create(&cg->cgbuts, NULL, NULL, etw->toolWin, 2, BUT_DRAWABLE|BUT_PRESSTHRU, 0); grid_setStone(b, goStone_black, FALSE); grid_setLineGroup(b, gridLines_none); grid_setMark(b, goMark_number, 1); grid_setVersion(b, 2); etw->mapWin = abutSwin_create(etw, etw->toolWin, 1, ABUTSWIN_LSLIDE|ABUTSWIN_BSLIDE, mapResize); etw->mapBg = butPixmap_create(etw->mapWin->win, 0, BUT_DRAWABLE, cg->boardPixmap); etw->sgfMap = sgfMap_create(&cg->cgbuts, mapCallback, etw, etw->mapWin->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, sgf); etw->prevVar = butKeytrap_create(editToolWin_shiftUpPressed, etw, etw->toolWin, BUT_DRAWABLE|BUT_PRESSABLE); but_setKeys(etw->prevVar, shiftUpKeys); etw->nextVar = butKeytrap_create(editToolWin_shiftDownPressed, etw, etw->toolWin, BUT_DRAWABLE|BUT_PRESSABLE); but_setKeys(etw->nextVar, shiftDownKeys); etw->sgf = sgf; etw->tool = editTool_play; etw->toolBox = butBoxFilled_create(etw->toolWin, 1, BUT_DRAWABLE); etw->toolName = butText_create(etw->toolWin, 2, BUT_DRAWABLE, msg_toolNames[etw->tool], butText_center); butText_setFont(etw->toolName, 2); etw->toolDesc1 = butText_create(etw->toolWin, 2, BUT_DRAWABLE, msg_toolDesc1[etw->tool], butText_center); etw->toolDesc2 = butText_create(etw->toolWin, 2, BUT_DRAWABLE, msg_toolDesc2[etw->tool], butText_center); etw->help = butCt_create(cgoban_createHelpWindow, &help_editTool, etw->toolWin, 1, BUT_DRAWABLE | BUT_PRESSABLE, msg_help); etw->killNode = butCt_create(cutPressed, etw, etw->toolWin, 1, BUT_DRAWABLE | BUT_PRESSABLE, msg_killNode); etw->moveNode = butCt_create(movePressed, etw, etw->toolWin, 1, BUT_DRAWABLE | BUT_PRESSABLE, msg_moveNode); etw->quitRequested = quitRequested; etw->newToolCallback = newToolCallback; etw->mapCallback = newActiveNode; etw->packet = packet; updateTreeButtons(etw); } void editToolWin_deinit(EditToolWin *etw) { int fontH; assert(MAGIC(etw)); if (etw->toolWin != NULL) { fontH = butEnv_fontH(etw->cg->env, 0); clp_setInt(etw->cg->clp, "edit.toolX", butWin_x(etw->toolWin)); clp_setInt(etw->cg->clp, "edit.toolY", butWin_y(etw->toolWin)); clp_setDouble(etw->cg->clp, "edit.toolW", (double)butWin_w(etw->toolWin) / (double)fontH); clp_setDouble(etw->cg->clp, "edit.toolH", (double)butWin_h(etw->toolWin) / (double)fontH); butWin_setPacket(etw->toolWin, NULL); butWin_destroy(etw->toolWin); } MAGIC_UNSET(etw); } static ButOut unmap(ButWin *win) { return(0); } static ButOut map(ButWin *win) { return(0); } static ButOut resize(ButWin *win) { EditToolWin *etw = butWin_packet(win); ButEnv *env = butWin_env(win); int bw = butEnv_stdBw(env); int fontH = butEnv_fontH(env, 0), font2H = butEnv_fontH(env, 2); int butH; int w = butWin_w(win), h = butWin_h(win); EditTool tool; int x, x2, y, toolW; assert(MAGIC(etw)); butH = etw->cg->fontH * 2; but_resize(etw->toolBg, 0, 0, w, h); but_resize(etw->toolSel, bw * 2, bw * 2, w - bw * 4, fontH * 2 + bw * 4); x2 = bw * 2; toolW = fontH * 2; for (tool = editTool_min; tool < editTool_max; ++tool) { x = x2; x2 = bw * 2 + ((tool + 1) * (w - bw * 4)) / editTool_max; but_resize(etw->selDesc[tool], (x + x2 - toolW) / 2, bw*4, toolW, toolW); } y = fontH * 2 + bw * 6; but_resize(etw->toolBox, bw * 2, y, w - bw * 4, bw * 4 + font2H + fontH * 2); but_resize(etw->toolName, bw * 4, y += bw * 2, w - bw * 8, font2H); but_resize(etw->toolDesc1, bw * 4, y += font2H, w - bw * 8, fontH); but_resize(etw->toolDesc2, bw * 4, y += fontH, w - bw * 8, fontH); but_resize(etw->help, bw*2, y += fontH + bw * 3, (w - bw * 6 + 1) / 3, butH); but_resize(etw->killNode, bw*3 + (w - bw * 6 + 1) / 3, y, w - bw * 6 - 2*(w - bw * 6 + 1) / 3, butH); but_resize(etw->moveNode, w - bw * 2 - (w - bw * 6 + 1) / 3, y, (w - bw * 6 + 1) / 3, butH); y += butH + bw; abutSwin_resize(etw->mapWin, bw * 2, y, w - bw * 4, h - bw * 2 - y, (fontH * 3) / 2, fontH * 3); sgfMap_resize(etw->sgfMap, 0, 0); butCan_resizeWin(etw->mapWin->win, but_w(etw->sgfMap), but_h(etw->sgfMap), TRUE); return(0); } static ButOut iResize(ButWin *win) { EditToolWin *etw = butWin_packet(win); int bw = butEnv_stdBw(win->env); assert(MAGIC(etw)); but_resize(etw->toolIBg, 0, 0, butWin_w(win), butWin_h(win)); but_resize(etw->toolIPic, bw*2, bw*2, butWin_w(win) - bw*4, butWin_h(win) - bw*4); return(0); } static ButOut mapResize(ButWin *win) { AbutSwin *swin = butWin_packet(win); EditToolWin *etw; assert(MAGIC(swin)); etw = swin->packet; assert(MAGIC(etw)); but_resize(etw->mapBg, 0, 0, butWin_w(win), butWin_h(win)); return(0); } static ButOut destroy(ButWin *win) { EditToolWin *etw = butWin_packet(win); if (etw) { assert(MAGIC(etw)); clp_setInt(etw->cg->clp, "edit.toolX", butWin_x(win)); clp_setInt(etw->cg->clp, "edit.toolY", butWin_y(win)); etw->toolWin = NULL; /* editToolWin_deinit(etw); */ } return(0); } static ButOut windowQuit(ButWin *win) { EditToolWin *etw = butWin_packet(win); assert(MAGIC(etw)); etw->quitRequested(etw->packet); return(0); } static ButOut newTool(But *but, int val) { EditToolWin *etw; etw = but_packet(but); assert(MAGIC(etw)); if ((EditTool)val != etw->tool) { etw->tool = (EditTool)val; butText_set(etw->toolName, msg_toolNames[val]); butText_set(etw->toolDesc1, msg_toolDesc1[val]); butText_set(etw->toolDesc2, msg_toolDesc2[val]); } return(etw->newToolCallback(etw->packet)); } void editToolWin_newColor(EditToolWin *etw, GoStone color) { if (color != etw->lastColor) { grid_setStone(etw->selDesc[editTool_play], etw->lastColor = color, FALSE); } } void editToolWin_newTool(EditToolWin *etw, EditTool tool, bool propagate) { butRadio_set(etw->toolSel, tool, propagate); } static ButOut mapCallback(But *but, int newNodeNum) { EditToolWin *etw = but_packet(but); ButOut result; assert(MAGIC(etw)); result = etw->mapCallback(etw->packet, newNodeNum); updateTreeButtons(etw); return(result); } void editToolWin_newActiveNode(EditToolWin *etw, SgfElem *newNode) { int w, h, loX, loY, hiX, hiY; int aX, aY; int slideX, slideY, newX, newY; sgfMap_newActive(etw->sgfMap, newNode); w = butWin_viewW(etw->mapWin->win); h = butWin_viewH(etw->mapWin->win); newX = slideX = butCan_xOff(etw->mapWin->win); newY = slideY = butCan_yOff(etw->mapWin->win); loX = slideX + (w + 1) / 4; loY = slideY + (h + 1) / 4; hiX = slideX + (w * 3 + 1) / 4; hiY = slideY + (h * 3 + 1) / 4; aX = sgfMap_activeCtrX(etw->sgfMap); aY = sgfMap_activeCtrY(etw->sgfMap); if (aX < loX) { newX = aX - (w + 1) / 4; if (newX < 0) newX = 0; } else if (aX > hiX) { newX = aX - (w * 3 + 1) / 4; if (newX + w > butWin_w(etw->mapWin->win)) newX = butWin_w(etw->mapWin->win) - w; } if (aY < loY) { newY = aY - (h + 1) / 4; if (newY < 0) newY = 0; } else if (aY > hiY) { newY = aY - (h * 3 + 1) / 4; if (newY + h > butWin_h(etw->mapWin->win)) newY = butWin_h(etw->mapWin->win) - h; } if ((newX != slideX) || (newY != slideY)) { butCan_slide(etw->mapWin->win, newX, newY, TRUE); } updateTreeButtons(etw); } static ButOut cutPressed(But *but) { EditToolWin *etw = but_packet(but); SgfElem *deadElem, *newActive; ButOut result; assert(MAGIC(etw)); etw->modified = TRUE; deadElem = etw->sgf->active->activeChild; if (deadElem == NULL) return(BUTOUT_ERR); newActive = deadElem->sibling; if (newActive) { sgfMap_changeVar(etw->sgfMap, sgfMap_next); } else { for (newActive = etw->sgf->active->childH; newActive && (newActive->sibling != deadElem); newActive = newActive->sibling); if (newActive) sgfMap_changeVar(etw->sgfMap, sgfMap_prev); } etw->sgf->active->activeChild = deadElem; assert(newActive != etw->sgf->active->activeChild); assert(MAGICNULL(newActive)); sgfElem_destroyActiveChild(etw->sgf->active); assert(MAGICNULL(newActive)); etw->sgf->active->activeChild = newActive; sgfMap_remap(etw->sgfMap, etw->sgf); butCan_resizeWin(etw->mapWin->win, but_w(etw->sgfMap), but_h(etw->sgfMap), TRUE); result = etw->mapCallback(etw->packet, etw->sgf->active->mapX); updateTreeButtons(etw); return(result); } static ButOut movePressed(But *but) { EditToolWin *etw = but_packet(but); SgfElem *active, *loSwap, *hiSwap, *prevChild; assert(MAGIC(etw)); etw->modified = TRUE; active = etw->sgf->active; assert(active->childH != active->childT); assert(active->childH != NULL); hiSwap = active->activeChild; if (active->childH == hiSwap) { loSwap = hiSwap; hiSwap = loSwap->sibling; } else { for (loSwap = active->childH; loSwap->sibling != hiSwap; loSwap = loSwap->sibling) assert(MAGIC(loSwap)); } if (active->childH == loSwap) { active->childH = hiSwap; } else { for (prevChild = active->childH; prevChild->sibling != loSwap; prevChild = prevChild->sibling); prevChild->sibling = hiSwap; } loSwap->sibling = hiSwap->sibling; hiSwap->sibling = loSwap; if (active->childT == hiSwap) active->childT = loSwap; sgfMap_remap(etw->sgfMap, etw->sgf); butCan_resizeWin(etw->mapWin->win, but_w(etw->sgfMap), but_h(etw->sgfMap), TRUE); return(0); } void editToolWin_nodeAdded(EditToolWin *etw, SgfElem *newNode) { bool addSuccessful; addSuccessful = sgfMap_newNode(etw->sgfMap, newNode); if (!addSuccessful) { sgfMap_remap(etw->sgfMap, etw->sgf); butCan_resizeWin(etw->mapWin->win, but_w(etw->sgfMap), but_h(etw->sgfMap), TRUE); } updateTreeButtons(etw); } ButOut editToolWin_shiftUpPressed(But *but, bool press) { EditToolWin *etw = but_packet(but); assert(MAGIC(etw)); if (press) { if (sgfMap_changeVar(etw->sgfMap, sgfMap_prev)) return(0); else return(BUTOUT_ERR); } else return(0); } ButOut editToolWin_shiftDownPressed(But *but, bool press) { EditToolWin *etw = but_packet(but); assert(MAGIC(etw)); if (press) { if (sgfMap_changeVar(etw->sgfMap, sgfMap_next)) return(0); else return(BUTOUT_ERR); } else return(0); } static void updateTreeButtons(EditToolWin *etw) { if (etw->sgf->active->childH) { but_setFlags(etw->killNode, BUT_PRESSABLE); if (etw->sgf->active->childH == etw->sgf->active->childT) { but_setFlags(etw->moveNode, BUT_NOPRESS); } else { but_setFlags(etw->moveNode, BUT_PRESSABLE); } } else { but_setFlags(etw->killNode, BUT_NOPRESS); but_setFlags(etw->moveNode, BUT_NOPRESS); } } cgoban-1.9.14/src/gameSetup.c0000664000671000067100000004366707043224470011433 /* * src/lsetup.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include "cgoban.h" #include "gameSetup.h" #include "msg.h" #include "help.h" /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut resize(ButWin *win); static ButOut destroy(ButWin *win); static ButOut newRules(But *but, int newVal); static ButOut newSize(But *but, const char *value); static ButOut newHcap(But *but, const char *value); static ButOut newKomi(But *but, const char *value); static ButOut newName(But *but, const char *value); static ButOut okPressed(But *but); static ButOut cancelPressed(But *but); static ButOut newTimeType(But *but, int newVal); static ButOut newMainTime(But *but, const char *value); static ButOut newBYTime(But *but, const char *value); static ButOut newAuxTime(But *but, const char *value); /********************************************************************** * Functions **********************************************************************/ GameSetup *gameSetup_create(Cgoban *cg, void (*callback)(void *packet, GameSetup *gs), void *packet) { GameSetup *ls; int w, h; char curText[10]; assert(MAGIC(cg)); ls = wms_malloc(sizeof(GameSetup)); MAGIC_SET(ls); ls->callback = callback; ls->packet = packet; ls->cg = cg; h = cg->fontH * 22 + butEnv_stdBw(cg->env) * 20; w = h * 1.618034 + 0.5; ls->win = butWin_create(ls, cg->env, "Game Setup", w,h, NULL, NULL, resize, destroy); butWin_activate(ls->win); ls->bg = butBoxFilled_create(ls->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(ls->bg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); ls->title = butText_create(ls->win, 1, BUT_DRAWABLE, msg_gSetup, butText_center); butText_setFont(ls->title, 2); ls->namesBox = butBox_create(ls->win, 1, BUT_DRAWABLE); butBox_setPixmaps(ls->namesBox, cg->bgLitPixmap, cg->bgShadPixmap); ls->wStr = butText_create(ls->win, 1, BUT_DRAWABLE, msg_wName, butText_left); ls->wIn = butTextin_create(newName, ls, ls->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, clp_getStr(cg->clp, "local.wName"), 30); ls->bStr = butText_create(ls->win, 1, BUT_DRAWABLE, msg_bName, butText_left); ls->bIn = butTextin_create(newName, ls, ls->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, clp_getStr(cg->clp, "local.bName"), 30); ls->rules = (GoRules)clp_getInt(cg->clp, "game.rules"); ls->size = clp_getInt(cg->clp, "game.size"); ls->hcap = clp_getInt(cg->clp, "game.handicap"); ls->komi = clp_getDouble(cg->clp, "game.komi"); ls->sizeSet = FALSE; ls->hcapSet = FALSE; ls->komiSet = FALSE; ls->rulesBox = butBox_create(ls->win, 1, BUT_DRAWABLE); butBox_setPixmaps(ls->rulesBox, cg->bgLitPixmap, cg->bgShadPixmap); ls->rulesMenu = butMenu_downCreate(newRules, ls, ls->win, 1, 2, BUT_PRESSABLE|BUT_DRAWABLE, msg_ruleSet, msg_ruleNames, ls->rules); butMenu_setFlags(ls->rulesMenu, (int)goRules_tibetan, BUTMENU_DISABLED); ls->sizeStr = butText_create(ls->win, 1, BUT_DRAWABLE, msg_boardSize, butText_center); sprintf(curText, "%d", ls->size); ls->sizeIn = butTextin_create(newSize, ls, ls->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, curText, 10); ls->hcapStr = butText_create(ls->win, 1, BUT_DRAWABLE, msg_handicap, butText_center); sprintf(curText, "%d", ls->hcap); ls->hcapIn = butTextin_create(newHcap, ls, ls->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, curText, 10); ls->komiStr = butText_create(ls->win, 1, BUT_DRAWABLE, msg_komi, butText_center); sprintf(curText, "%g", ls->komi); ls->komiIn = butTextin_create(newKomi, ls, ls->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, curText, 10); ls->timeBox = butBox_create(ls->win, 1, BUT_DRAWABLE); butBox_setPixmaps(ls->timeBox, cg->bgLitPixmap, cg->bgShadPixmap); ls->timeType = 2; ls->numTimeArgs = 3; ls->timeMenu = butMenu_downCreate(newTimeType, ls, ls->win, 1, 2, BUT_PRESSABLE|BUT_DRAWABLE, msg_timeSystem, msg_timeSystems, clp_getInt(cg->clp, "setup.timeType")); ls->mainStr = butText_create(ls->win, 1, BUT_DRAWABLE, msg_primaryTime, butText_center); ls->mainIn = butTextin_create(newMainTime, ls, ls->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, clp_getStr(cg->clp, "setup.mainTime"), 10); ls->byStr = butText_create(ls->win, 1, BUT_DRAWABLE, msg_byoYomi, butText_center); ls->byIn = butTextin_create(newBYTime, ls, ls->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, clp_getStr(cg->clp, "setup.igsBYTime"), 10); ls->auxStr = butText_create(ls->win, 1, BUT_DRAWABLE, msg_byoYomiStones, butText_center); ls->auxIn = butTextin_create(newAuxTime, ls, ls->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, clp_getStr(cg->clp, "setup.igsBYStones"), 10); ls->timeType = goTime_canadian; ls->mainTime = goTime_parseChars(butTextin_get(ls->mainIn), FALSE, NULL); ls->byTime = goTime_parseChars(butTextin_get(ls->byIn), FALSE, NULL); ls->aux = wms_atoi(butTextin_get(ls->auxIn), NULL); newTimeType(ls->timeMenu, butMenu_get(ls->timeMenu)); ls->help = butCt_create(cgoban_createHelpWindow, &help_gameSetup, ls->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_help); ls->ok = butCt_create(okPressed, ls, ls->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_ok); ls->cancel = butCt_create(cancelPressed, ls, ls->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_cancel); return(ls); } void gameSetup_destroy(GameSetup *ls) { assert(MAGIC(ls)); if (ls->callback) { ls->callback(ls->packet, NULL); ls->callback = NULL; } if (ls->win) butWin_destroy(ls->win); MAGIC_UNSET(ls); wms_free(ls); } static ButOut resize(ButWin *win) { GameSetup *ls = butWin_packet(win); Cgoban *cg; int w, butW, h, x, y; int bw, fh; ButEnv *env; int wStrSize, bStrSize; assert(MAGIC(ls)); cg = ls->cg; assert(MAGIC(cg)); env = cg->env; bw = butEnv_stdBw(env); fh = cg->fontH; w = butWin_w(win); h = butWin_h(win); butW = w/2-5*bw; but_resize(ls->bg, 0,0, w,h); butText_resize(ls->title, w/2,bw*2, fh*2); but_resize(ls->namesBox, bw,bw*3+fh*2, w-bw*2,bw*4+fh*2); wStrSize = butText_resize(ls->wStr, bw*3, bw*5+fh*2, fh*2); bStrSize = butText_resize(ls->bStr, w/2+bw*2, bw*5+fh*2, fh*2); if (bStrSize > wStrSize) wStrSize = bStrSize; but_resize(ls->wIn, bw*4+wStrSize, bw*5+fh*2, w/2 - (bw*6+wStrSize), fh*2); but_resize(ls->bIn, w/2+bw*3+wStrSize, bw*5+fh*2, w - (w/2+bw*6+wStrSize), fh*2); y = bw*7+fh*4; but_resize(ls->rulesBox, bw,y, w/2-bw,fh*16+bw*10); but_resize(ls->rulesMenu, bw*3,y+bw*2+fh*0, butW,fh*4); but_resize(ls->sizeStr, bw*3,y+bw*3+fh*4, butW,fh*2); but_resize(ls->sizeIn, bw*3,y+bw*4+fh*6, butW,fh*2); but_resize(ls->hcapStr, bw*3,y+bw*5+fh*8, butW,fh*2); but_resize(ls->hcapIn, bw*3,y+bw*6+fh*10, butW,fh*2); but_resize(ls->komiStr, bw*3,y+bw*7+fh*12, butW,fh*2); but_resize(ls->komiIn, bw*3,y+bw*8+fh*14, butW,fh*2); but_resize(ls->timeBox, w/2,y, w-bw-w/2,fh*16+bw*10); x = w/2 + bw*2; butW = w-x-bw*3; but_resize(ls->timeMenu, x,y+bw*2+fh*0, butW,fh*4); but_resize(ls->mainStr, x,y+bw*3+fh*4, butW,fh*2); but_resize(ls->mainIn, x,y+bw*4+fh*6, butW,fh*2); but_resize(ls->byStr, x,y+bw*5+fh*8, butW,fh*2); but_resize(ls->byIn, x,y+bw*6+fh*10, butW,fh*2); but_resize(ls->auxStr, x,y+bw*7+fh*12, butW,fh*2); but_resize(ls->auxIn, x,y+bw*8+fh*14, butW,fh*2); but_resize(ls->help, bw*2,y+bw*11+fh*16, (w-bw*6+1)/3,fh*2); but_resize(ls->cancel, bw*3+(w-bw*6+1)/3,y+bw*11+fh*16, w-2*(bw*3+(w-bw*6+1)/3),fh*2); but_resize(ls->ok, w-(bw*2+(w-bw*6+1)/3),y+bw*11+fh*16, (w-bw*6+1)/3,fh*2); return(0); } static ButOut destroy(ButWin *win) { GameSetup *ls = butWin_packet(win); assert(MAGIC(ls)); ls->win = NULL; /* It's dead already. */ gameSetup_destroy(ls); return(0); } static ButOut newRules(But *but, int newVal) { GameSetup *ls = but_packet(but); assert(MAGIC(ls)); clp_setInt(ls->cg->clp, "game.rules", newVal); if (!ls->sizeSet) { if (newVal != goRules_tibetan) { if ((ls->size != 9) && (ls->size != 13) && (ls->size != 19)) { butTextin_set(ls->sizeIn, "19", FALSE); clp_setInt(ls->cg->clp, "game.size", 19); ls->size = 19; } } else { butTextin_set(ls->sizeIn, "17", FALSE); clp_setInt(ls->cg->clp, "game.size", 17); ls->size = 17; } } if (!ls->komiSet && (ls->hcap == 0) && (((ls->rules == goRules_ing) && (ls->komi == 8.0)) || ((ls->rules != goRules_ing) && (ls->komi == 5.5)))) { if (newVal != goRules_ing) { butTextin_set(ls->komiIn, "5.5", FALSE); clp_setDouble(ls->cg->clp, "game.komi", 5.5); ls->komi = 5.5; } else { butTextin_set(ls->komiIn, "8", FALSE); clp_setDouble(ls->cg->clp, "game.komi", 8.0); ls->komi = 8.0; } } if (!ls->komiSet && (ls->hcap != 0) && (((ls->rules == goRules_ing) && (ls->komi == 0.0)) || ((ls->rules != goRules_ing) && (ls->komi == 0.5)))) { if (newVal != goRules_ing) { butTextin_set(ls->komiIn, "0.5", FALSE); clp_setDouble(ls->cg->clp, "game.komi", 0.5); ls->komi = 0.5; } else { butTextin_set(ls->komiIn, "0", FALSE); clp_setDouble(ls->cg->clp, "game.komi", 0.0); ls->komi = 0.0; } } ls->rules = newVal; return(0); } static ButOut newSize(But *but, const char *value) { GameSetup *ls = but_packet(but); int newSize; char curValue[200]; assert(MAGIC(ls)); newSize = atoi(value); if (!clp_setStr(ls->cg->clp, "game.size", value)) { sprintf(curValue, msg_badSize, value, GOBOARD_MAXSIZE); cgoban_createMsgWindow(ls->cg, "Cgoban Error", curValue); sprintf(curValue, "%d", ls->size); butTextin_set(but, curValue, FALSE); return(BUTOUT_ERR); } ls->sizeSet = TRUE; ls->size = newSize; but_setFlags(ls->hcapIn, BUT_KEYED); return(0); } static ButOut newHcap(But *but, const char *value) { GameSetup *ls = but_packet(but); int newVal = atoi(value); Str curValue; assert(MAGIC(ls)); if (!clp_setStr(ls->cg->clp, "game.handicap", value)) { str_init(&curValue); str_print(&curValue, msg_badHcap, value, 27); cgoban_createMsgWindow(ls->cg, "Cgoban Error", str_chars(&curValue)); str_print(&curValue, "%d", ls->hcap); butTextin_set(but, str_chars(&curValue), FALSE); str_deinit(&curValue); return(BUTOUT_ERR); } ls->hcapSet = TRUE; if ((newVal == 1) || (!ls->komiSet && (ls->hcap == 0) && (newVal != 0) && (((ls->rules == goRules_ing) && (ls->komi == 8.0)) || ((ls->rules != goRules_ing) && (ls->komi == 5.5))))) { ls->komiSet = FALSE; if (ls->rules == goRules_ing) { butTextin_set(ls->komiIn, "0", FALSE); clp_setDouble(ls->cg->clp, "game.komi", 0.0); ls->komi = 0.0; } else { butTextin_set(ls->komiIn, "0.5", FALSE); clp_setDouble(ls->cg->clp, "game.komi", 0.5); ls->komi = 0.5; } } if (!ls->komiSet && (ls->hcap > 0) && (newVal == 0) && ((ls->komi == 0.0) || (ls->komi == 0.5))) { if (ls->rules == goRules_ing) { butTextin_set(ls->komiIn, "8", FALSE); clp_setDouble(ls->cg->clp, "game.komi", 8.0); ls->komi = 8.0; } else { butTextin_set(ls->komiIn, "5.5", FALSE); clp_setDouble(ls->cg->clp, "game.komi", 5.5); ls->komi = 5.5; } } ls->hcap = newVal; but_setFlags(ls->komiIn, BUT_KEYED); return(0); } static ButOut newKomi(But *but, const char *value) { GameSetup *ls = but_packet(but); char curValue[200]; bool komiErr; double newKomi; assert(MAGIC(ls)); newKomi = wms_atof(value, &komiErr); if (!clp_setStr(ls->cg->clp, "game.komi", value)) { sprintf(curValue, msg_badKomi, value); cgoban_createMsgWindow(ls->cg, "Cgoban Error", curValue); sprintf(curValue, "%g", ls->komi); butTextin_set(but, curValue, FALSE); return(BUTOUT_ERR); } ls->komiSet = TRUE; ls->komi = newKomi; but_setFlags(ls->komiIn, BUT_NOKEY); return(0); } static ButOut okPressed(But *but) { GameSetup *ls = but_packet(but); Clp *clp = ls->cg->clp; assert(MAGIC(ls)); if (newSize(ls->sizeIn, butTextin_get(ls->sizeIn)) & BUTOUT_ERR) return(BUTOUT_ERR); if (newHcap(ls->hcapIn, butTextin_get(ls->hcapIn)) & BUTOUT_ERR) return(BUTOUT_ERR); if (newKomi(ls->komiIn, butTextin_get(ls->komiIn)) & BUTOUT_ERR) return(BUTOUT_ERR); if (ls->numTimeArgs >= 1) if (newMainTime(ls->mainIn, butTextin_get(ls->mainIn)) & BUTOUT_ERR) return(BUTOUT_ERR); if (ls->numTimeArgs >= 2) if (newBYTime(ls->byIn, butTextin_get(ls->byIn)) & BUTOUT_ERR) return(BUTOUT_ERR); if (ls->numTimeArgs >= 3) if (newAuxTime(ls->auxIn, butTextin_get(ls->auxIn)) & BUTOUT_ERR) return(BUTOUT_ERR); clp_setInt(clp, "game.size", ls->size); clp_setInt(clp, "game.handicap", ls->hcap); clp_setDouble(clp, "game.komi", ls->komi); clp_setStr(clp, "local.wName", butTextin_get(ls->wIn)); clp_setStr(clp, "local.bName", butTextin_get(ls->bIn)); if (ls->callback) { ls->callback(ls->packet, ls); ls->callback = NULL; } butWin_destroy(but_win(but)); return(0); } static ButOut cancelPressed(But *but) { GameSetup *gs = but_packet(but); assert(MAGIC(gs)); if (gs->callback) { gs->callback(gs->packet, NULL); gs->callback = NULL; } butWin_destroy(but_win(but)); return(0); } static ButOut newName(But *but, const char *value) { GameSetup *ls = but_packet(but); assert(MAGIC(ls)); if (but == ls->wIn) { clp_setStr(ls->cg->clp, "local.wName", value); but_setFlags(ls->bIn, BUT_KEYED); } else { assert(but == ls->bIn); but_setFlags(but, BUT_NOKEY); clp_setStr(ls->cg->clp, "local.bName", value); } return(0); } static ButOut newTimeType(But *but, int newVal) { GameSetup *ls = but_packet(but); GoTimeType newTime = (GoTimeType)newVal; int nargs = 0; assert(MAGIC(ls)); if (newTime == ls->timeType) return(0); switch(ls->timeType = newTime) { case goTime_none: nargs = ls->numTimeArgs = 0; break; case goTime_absolute: nargs = ls->numTimeArgs = 1; ls->byTime = 0; /* Just to make things clear. */ break; case goTime_canadian: nargs = ls->numTimeArgs = 3; butTextin_set(ls->byIn, clp_getStr(ls->cg->clp, "setup.igsBYTime"), FALSE); butText_set(ls->auxStr, msg_byoYomiStones); butTextin_set(ls->auxIn, clp_getStr(ls->cg->clp, "setup.igsBYStones"), FALSE); break; case goTime_ing: nargs = ls->numTimeArgs = 3; butTextin_set(ls->byIn, clp_getStr(ls->cg->clp, "setup.ingBYTime"), FALSE); butText_set(ls->auxStr, msg_byoYomiCount); butTextin_set(ls->auxIn, clp_getStr(ls->cg->clp, "setup.ingBYPeriods"), FALSE); break; case goTime_japanese: nargs = ls->numTimeArgs = 3; butTextin_set(ls->byIn, clp_getStr(ls->cg->clp, "setup.jBYTime"), FALSE); butText_set(ls->auxStr, msg_byoYomiCount); butTextin_set(ls->auxIn, clp_getStr(ls->cg->clp, "setup.jBYPeriods"), FALSE); } if (nargs >= 1) { butText_setColor(ls->mainStr, BUT_FG, FALSE); but_setFlags(ls->mainIn, BUT_PRESSABLE); if (nargs >= 2) { butText_setColor(ls->byStr, BUT_FG, FALSE); but_setFlags(ls->byIn, BUT_PRESSABLE); if (nargs >= 3) { butText_setColor(ls->auxStr, BUT_FG, FALSE); but_setFlags(ls->auxIn, BUT_PRESSABLE); } } } if (nargs < 3) { butText_setColor(ls->auxStr, BUT_FG, TRUE); but_setFlags(ls->auxIn, BUT_NOPRESS|BUT_NOKEY); if (nargs < 2) { butText_setColor(ls->byStr, BUT_FG, TRUE); but_setFlags(ls->byIn, BUT_NOPRESS|BUT_NOKEY); if (nargs < 1) { butText_setColor(ls->mainStr, BUT_FG, TRUE); but_setFlags(ls->mainIn, BUT_NOPRESS|BUT_NOKEY); } } } clp_setInt(ls->cg->clp, "setup.timeType", newVal); return(0); } static ButOut newMainTime(But *but, const char *value) { GameSetup *ls = but_packet(but); Str errMsg; if (!clp_setStr(ls->cg->clp, "setup.mainTime", value)) { str_init(&errMsg); str_print(&errMsg, msg_badTime, value); cgoban_createMsgWindow(ls->cg, "Cgoban Error", str_chars(&errMsg)); goTime_str(ls->mainTime, &errMsg); butTextin_set(but, str_chars(&errMsg), FALSE); str_deinit(&errMsg); return(BUTOUT_ERR); } ls->mainTime = goTime_parseChars(value, FALSE, NULL); if (but_getFlags(ls->byIn) & BUT_PRESSABLE) but_setFlags(ls->byIn, BUT_KEYED); else but_setFlags(but, BUT_NOKEY); return(0); } static ButOut newBYTime(But *but, const char *value) { GameSetup *ls = but_packet(but); Str errMsg; if (!clp_setStr(ls->cg->clp, "setup.igsBYTime", value)) { str_init(&errMsg); str_print(&errMsg, msg_badTime, value); cgoban_createMsgWindow(ls->cg, "Cgoban Error", str_chars(&errMsg)); goTime_str(ls->byTime, &errMsg); butTextin_set(but, str_chars(&errMsg), FALSE); str_deinit(&errMsg); return(BUTOUT_ERR); } ls->byTime = goTime_parseChars(value, FALSE, NULL); but_setFlags(but, BUT_NOKEY); if (but_getFlags(ls->auxIn) & BUT_PRESSABLE) but_setFlags(ls->auxIn, BUT_KEYED); else but_setFlags(but, BUT_NOKEY); return(0); } static ButOut newAuxTime(But *but, const char *value) { GameSetup *ls = but_packet(but); Str errMsg; if (!clp_setStr(ls->cg->clp, "setup.igsBYStones", value)) { str_init(&errMsg); if (ls->timeType == goTime_ing) str_print(&errMsg, msg_badBYCount, value); else str_print(&errMsg, msg_badBYStones, value); cgoban_createMsgWindow(ls->cg, "Cgoban Error", str_chars(&errMsg)); str_print(&errMsg, "%d", ls->aux); butTextin_set(but, str_chars(&errMsg), FALSE); str_deinit(&errMsg); return(BUTOUT_ERR); } ls->aux = wms_atoi(value, NULL); but_setFlags(but, BUT_NOKEY); return(0); } cgoban-1.9.14/src/goBoard.c0000664000671000067100000003620507043224470011044 /* * src/goboard.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include "goBoard.h" #include "goHash.h" #define DEBUG_SHOWLINKS 0 static bool goBoard_isBorder(GoBoard *board, int pos); static void addEmpty(GoBoard *board, int pos); #if DEBUG_SHOWLINKS static void showLinks(GoBoard *board); #endif GoBoard *goBoard_create(int size) { GoBoard *board; int i; Rnd *r; r = rnd_create(50); board = wms_malloc(sizeof(GoBoard)); MAGIC_SET(board); board->area = ((size + 2) * (size + 1) + 1); board->dirs[0] = size + 1; board->dirs[1] = -(size + 1); board->dirs[2] = 1; board->dirs[3] = -1; board->pieces = wms_malloc(board->area * sizeof(GoBoardPiece)); for (i = 0; i < board->area; ++i) { if (goBoard_isBorder(board, i)) { board->pieces[i].type = goStone_edge; board->pieces[i].head = NULL; board->pieces[i].hashStone[goStone_black] = goHash_zero; board->pieces[i].hashStone[goStone_white] = goHash_zero; board->pieces[i].hashKo[goStone_black] = goHash_zero; board->pieces[i].hashKo[goStone_white] = goHash_zero; } else { board->pieces[i].type = goStone_empty; /* * We must set empties to NULL head or else they may trip up the * liberty counting code (it sounds unlikely, but believe me! * I've seen it happen!) */ board->pieces[i].head = NULL; board->pieces[i].hashStone[goStone_black] = goHash_init(r); board->pieces[i].hashStone[goStone_white] = goHash_init(r); board->pieces[i].hashKo[goStone_black] = goHash_init(r); board->pieces[i].hashKo[goStone_white] = goHash_init(r); } } board->caps[0] = 0; board->caps[1] = 0; board->hashVal = goHash_zero; board->koLoc = 0; rnd_destroy(r); return(board); } static bool goBoard_isBorder(GoBoard *board, int pos) { return((pos < board->dirs[0]) || (pos >= board->area - board->dirs[0]) || (pos % board->dirs[0] == 0)); } void goBoard_destroy(GoBoard *board) { assert(MAGIC(board)); wms_free(board->pieces); MAGIC_UNSET(board); wms_free(board); } void goBoard_copy(GoBoard *src, GoBoard *dest) { int i; GoBoardPiece *sp, *dp; assert(MAGIC(src)); assert(MAGIC(dest)); assert(src->area == dest->area); for (i = 0, sp = src->pieces, dp = dest->pieces; i < src->area; ++i, ++sp, ++dp) { dp->type = sp->type; dp->libs = sp->libs; dp->size = sp->size; if (sp->head) dp->head = dest->pieces + (sp->head - src->pieces); else dp->head = NULL; if (sp->tail) dp->tail = dest->pieces + (sp->tail - src->pieces); else dp->tail = NULL; if (sp->next) dp->next = dest->pieces + (sp->next - src->pieces); else dp->next = NULL; } dest->caps[0] = src->caps[0]; dest->caps[1] = src->caps[1]; dest->hashVal = src->hashVal; dest->koLoc = src->koLoc; } bool goBoard_eq(GoBoard *b1, GoBoard *b2) { int i; assert(MAGIC(b1)); assert(MAGIC(b2)); if (b1->area != b2->area) return(FALSE); for (i = 0; i < b1->area; ++i) { if (b1->pieces[i].type != b2->pieces[i].type) return(FALSE); } return(TRUE); } void goBoard_print(GoBoard *b) { goBoard_fprint(b, stdout); } void goBoard_fprint(GoBoard *b, FILE *fnum) { int x, y; for (y = 0; y < goBoard_size(b); ++y) { for (x = 0; x < goBoard_size(b); ++x) { printf("%c ", goStone_char(b->pieces[goBoard_xy2Loc(b, x,y)].type)); } printf("\n"); } } /* * Returns the number of captures. */ int goBoard_addStone(GoBoard *board, GoStone stone, int loc, int *suicides) { GoStone oppType; GoBoardPiece *oppList[4], *new, *neighbor, *group, *groupNeighbor; GoBoardPiece *oppOppList[4]; GoBoardPiece *oldHead; GoBoardPiece *libs[GOBOARD_MAXSIZE*GOBOARD_MAXSIZE]; int i, j, k, oppListLen, oppOppListLen, numLibs, captures = 0; bool unseen; assert(MAGIC(board)); assert(loc >= 0); assert(loc < board->area); if (stone == goStone_empty) { assert(suicides == NULL); addEmpty(board, loc); return(0); } assert((loc == 0) || (board->pieces[loc].type == goStone_empty)); assert((stone == goStone_black) || (stone == goStone_white)); oppType = goStone_opponent(stone); new = &board->pieces[loc]; board->hashVal = goHash_xor(goHash_xor(board->hashVal, goHash_pass), new->hashStone[stone]); if (board->koLoc) { board->hashVal = goHash_xor(board->hashVal, board->pieces[board->koLoc].hashKo[oppType]); board->koLoc = 0; } if (loc == 0) return(0); /* Start you out as a simple group. */ new->type = stone; new->libs = 0; new->size = 1; new->head = new; new->tail = new; new->next = NULL; for (i = 0, oppListLen = 0; i < 4; ++i) { neighbor = new + board->dirs[i]; if (neighbor->type == oppType) { /* * An enemy group...remove a liberty. * If it now has 0 liberties, kill it! */ unseen = TRUE; /* * First check; if you've already seen this group then you shouldn't * remove another liberty, you've already done it. */ neighbor = neighbor->head; assert(neighbor->libs > 0); for (j = 0; j < oppListLen; ++j) { if (neighbor == oppList[j]) { unseen = FALSE; break; } } if (unseen) { oppList[oppListLen] = neighbor; ++oppListLen; if (--neighbor->libs == 0) { if (new == new->head) ++new->libs; captures += neighbor->size; for (group = neighbor; group; group = group->next) { board->hashVal = goHash_xor(board->hashVal, group->hashStone[oppType]); group->type = goStone_empty; group->head = NULL; oppOppListLen = 0; for (j = 0; j < 4; ++j) { groupNeighbor = group + board->dirs[j]; if (groupNeighbor->type == stone) { if ((groupNeighbor != new) || (groupNeighbor->head != groupNeighbor)) ++groupNeighbor->head->libs; groupNeighbor = groupNeighbor->head; for (k = 0; k < oppOppListLen; ++k) { if (oppOppList[k] == groupNeighbor) { --groupNeighbor->libs; break; } } oppOppList[oppOppListLen++] = groupNeighbor; } } } } } } else if ((neighbor->type == stone) && (neighbor->head != new->head)) { neighbor = neighbor->head; assert(neighbor->libs > 0); oldHead = new->head; /* * Add the group with the new stone to the tail of the neighbor group. */ neighbor->size += oldHead->size; numLibs = 0; /* You're touching a friendly stone. Merge them into a single group. */ for (group = oldHead; group; group = group->next) { group->head = neighbor; for (j = 0; j < 4; ++j) { groupNeighbor = group + board->dirs[j]; if ((groupNeighbor->type == goStone_empty) && (groupNeighbor->head != neighbor)) { groupNeighbor->head = neighbor; libs[numLibs++] = groupNeighbor; } } } for (group = neighbor; group; group = group->next) { for (j = 0; j < 4; ++j) { groupNeighbor = group + board->dirs[j]; if ((groupNeighbor->type == goStone_empty) && (groupNeighbor->head != neighbor)) { groupNeighbor->head = neighbor; libs[numLibs++] = groupNeighbor; } } } neighbor->tail->next = oldHead; neighbor->tail = oldHead->tail; assert(neighbor->libs - 1 <= numLibs); neighbor->libs = numLibs; for (j = 0; j < numLibs; ++j) { libs[j]->head = NULL; } assert(neighbor != new); assert(new->head == neighbor); } else if ((neighbor->type == goStone_empty) && (new->head == new)) ++new->libs; } if (new->head->libs == 0) { if (suicides) *suicides = new->head->size; board->caps[oppType] += new->head->size; for (group = new->head; group; group = group->next) { board->hashVal = goHash_xor(board->hashVal, group->hashStone[stone]); group->type = goStone_empty; group->head = NULL; oppOppListLen = 0; for (j = 0; j < 4; ++j) { groupNeighbor = group + board->dirs[j]; if (groupNeighbor->type == oppType) { groupNeighbor = groupNeighbor->head; ++groupNeighbor->libs; for (k = 0; k < oppOppListLen; ++k) { if (oppOppList[k] == groupNeighbor) { --groupNeighbor->libs; break; } } oppOppList[oppOppListLen++] = groupNeighbor; } } } } else if (suicides) *suicides = 0; board->caps[stone] += captures; if ((captures == 1) && (new->head == new) && (new->libs == 1)) { board->koLoc = loc; board->hashVal = goHash_xor(board->hashVal, new->hashKo[stone]); } #if DEBUG_SHOWLINKS showLinks(board); #endif return(captures); } static void addEmpty(GoBoard *board, int loc) { GoBoardPiece *remove, *group, *neighbor, *oppList[4]; GoStone type; int killedLocs[GOBOARD_MAXSIZE*GOBOARD_MAXSIZE]; int i, dir, numKilled, oppListLen; /* * My database really has no clean way of removing stones, so I take out * the entire group that the empty stone is a part of, then add in * all of the group (except for the stone that I wanted to remove in * first place) one at a time. */ remove = board->pieces + loc; type = remove->type; if (type == goStone_empty) return; assert((type == goStone_white) || (type == goStone_black)); numKilled = 0; for (group = remove->head; group; group = group->next) { if (group != remove) killedLocs[numKilled++] = group - board->pieces; board->hashVal = goHash_xor(board->hashVal, group->hashStone[type]); group->type = goStone_empty; group->head = NULL; oppListLen = 0; for (dir = 0; dir < 4; ++dir) { neighbor = group + board->dirs[dir]; if (neighbor->type == goStone_opponent(type)) { neighbor = neighbor->head; ++neighbor->libs; for (i = 0; i < oppListLen; ++i) { if (oppList[i] == neighbor) { --neighbor->libs; break; } } oppList[oppListLen++] = neighbor; } } } /* Ok, they're all gone now. So add them back! :-) */ for (i = 0; i < numKilled; ++i) { goBoard_addStone(board, type, killedLocs[i], NULL); } } /* * This returns the hash WITHOUT the ko. */ GoHash goBoard_quickHash(GoBoard *board, GoStone stone, int loc, bool *suicide) { GoHash result; int i, j, deadListLen = 0; bool killSelf = TRUE, killNeighbor; GoBoardPiece *new, *neighbor, *deadList[4]; assert(MAGIC(board)); assert(loc >= 0); assert(loc < board->area); assert((loc == 0) || (board->pieces[loc].type == goStone_empty)); assert((stone == goStone_black) || (stone == goStone_white)); result = goHash_xor(goBoard_hashNoKo(board, goStone_opponent(stone)), goHash_xor(goHash_pass, board->pieces[loc].hashStone[stone])); if (loc == 0) return(result); new = &board->pieces[loc]; for (i = 0; i < 4; ++i) { neighbor = new + board->dirs[i]; if (neighbor->type == goStone_empty) killSelf = FALSE; else if (neighbor->type == stone) { if (neighbor->head->libs > 1) killSelf = FALSE; } else if (neighbor->type == goStone_opponent(stone)) { neighbor = neighbor->head; if (neighbor->libs == 1) { killSelf = FALSE; killNeighbor = TRUE; for (j = 0; j < deadListLen; ++j) { if (deadList[j] == neighbor) { killNeighbor = FALSE; break; } } if (killNeighbor) { deadList[deadListLen++] = neighbor; do { result = goHash_xor(result, neighbor->hashStone[goStone_opponent(stone)]); neighbor = neighbor->next; } while (neighbor); } } } } if (suicide) *suicide = killSelf; if (killSelf) { result = goHash_xor(result, new->hashStone[stone]); deadListLen = 0; for (i = 0; i < 4; ++i) { neighbor = new + board->dirs[i]; if (neighbor->type == stone) { neighbor = neighbor->head; killNeighbor = TRUE; for (j = 0; j < deadListLen; ++j) { if (deadList[j] == neighbor) { killNeighbor = FALSE; break; } } if (killNeighbor) { deadList[deadListLen++] = neighbor; do { result = goHash_xor(result, neighbor->hashStone[stone]); neighbor = neighbor->next; } while (neighbor); } } } } return(result); } void goBoard_loc2Str(GoBoard *board, int loc, char *str) { if (loc == 0) strcpy(str, "Pass"); /* BAD! */ else { str[0] = 'A' + (loc % board->dirs[0]) - 1; if (str[0] >= 'I') ++str[0]; sprintf(str+1, "%d", goBoard_size(board) + 1 - (loc / board->dirs[0])); } } int goBoard_str2Loc(GoBoard *board, const char *str) { char xChar; int x, y, yLoc; int args; args = sscanf(str, "%c%d", &xChar, &yLoc); assert(args == 2); if (xChar < 'I') x = xChar - 'A'; else x = xChar - 'B'; y = goBoard_size(board) - yLoc; if ((x < 0) || (y < 0) || (x >= goBoard_size(board)) || (y >= goBoard_size(board))) { return(-1); } return(goBoard_xy2Loc(board, x, y)); } void goBoard_rmGroup(GoBoard *board, int loc) { GoBoardPiece *oppList[4]; GoBoardPiece *dead, *neighbor; GoStone s, o; int i, j, oppListLen; assert(goStone_isStone(board->pieces[loc].type)); dead = board->pieces[loc].head; s = dead->type; assert(goStone_isStone(s)); o = goStone_opponent(s); board->caps[o] += dead->size; do { board->hashVal = goHash_xor(board->hashVal, dead->hashStone[s]); dead->type = goStone_empty; dead->head = NULL; oppListLen = 0; for (i = 0; i < 4; ++i) { neighbor = dead + board->dirs[i]; if (neighbor->type == o) { neighbor = neighbor->head; ++neighbor->libs; for (j = 0; j < oppListLen; ++j) { if (oppList[j] == neighbor) { --neighbor->libs; break; } } oppList[oppListLen++] = neighbor; } } dead = dead->next; } while (dead); } const char *goBoard_loc2Sgf(GoBoard *b, int l) { static char loc[5] = "xxxx"; int x, y; assert(MAGIC(b)); assert((l > 0) && (l < b->area)); x = goBoard_loc2X(b, l); y = goBoard_loc2Y(b, l); loc[0] = 'a' + (x / 26); loc[1] = 'a' + (x % 26); loc[2] = 'a' + (y / 26); loc[3] = 'a' + (y % 26); return(loc); } int goBoard_sgf2Loc(GoBoard *b, const char *l) { int x, y; assert(MAGIC(b)); assert((strlen(l) == 2) || (strlen(l) == 4)); if (l[2] == '\0') { x = l[0] - 'a'; y = l[1] - 'a'; } else { x = (l[0] - 'a') * 26 + (l[1] - 'a'); y = (l[2] - 'a') * 26 + (l[3] - 'a'); } assert((x >= 0) && (x < goBoard_size(b))); assert((y >= 0) && (y < goBoard_size(b))); return(goBoard_xy2Loc(b, x, y)); } #if DEBUG_SHOWLINKS static void showLinks(GoBoard *board) { GoBoardPiece *group; int loc; char locStr[4]; printf("Links:\n"); for (loc = 0; loc < board->area; ++loc) { if (goStone_isStone(board->pieces[loc].type) && board->pieces[loc].head == &board->pieces[loc]) { printf(" Color = %c, libs=%d, size=%d\n", goStone_char(board->pieces[loc].type), board->pieces[loc].libs, board->pieces[loc].size); for (group = &board->pieces[loc]; group; group = group->next) { goBoard_loc2Str(board, group - &board->pieces[0], locStr); printf(" %s\n", locStr); assert(group->head == &board->pieces[loc]); } } } printf("----\n"); } #endif /* DEBUG_SHOWLINKS */ cgoban-1.9.14/src/goGame.c0000664000671000067100000004507307466655374010715 /* * $Source: /cvsroot/cgoban1/cgoban1/src/goGame.c,v $ * $Revision: 1.3 $ * $Date: 2002/05/10 05:30:36 $ * * src/gogame.c, part of Complete Goban (game program) * Copyright © 1995-2000 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include #include "goBoard.h" #ifdef _GOGAME_H_ #error LEVELIZATION ERROR #endif #include "goGame.h" /********************************************************************** * Forward Declarations **********************************************************************/ static bool goGame_forcedHandicapPlacement(GoGame *game); static void goGame_addHandicapStones(GoGame *game, GoBoard *board); static GoBoard *goGame_replay(GoGame *game, int moves, bool separateBoard); static void goGame_updateForMove(GoGame *game, GoStone moveColor, int move); static bool isDisputeAlive(GoGame *game); static void addMoveToMoves(GoGame *game, GoStone moveColor, int move, int moveNum); static bool goGame_canMove(GoGame *game, GoStone s, int move); static bool goGame_canDispute(GoGame *game, int move); /********************************************************************** * Globals **********************************************************************/ const bool goRules_freeHandicaps[goRules_num] = { FALSE, FALSE, TRUE, FALSE, TRUE, TRUE}; const GoRulesKo goRules_ko[goRules_num] = { goRulesKo_super, goRulesKo_japanese, goRulesKo_super, goRulesKo_super, goRulesKo_super, goRulesKo_tibetan}; const bool goRules_suicide[goRules_num] = { TRUE, FALSE, TRUE, TRUE, TRUE, FALSE}; const bool goRules_dispute[goRules_num] = { TRUE, FALSE, FALSE, FALSE, FALSE, TRUE}; const bool goRules_scoreKills[goRules_num] = { FALSE, TRUE, FALSE, TRUE, FALSE, TRUE}; /********************************************************************** * Functions **********************************************************************/ GoGame *goGame_create(int size, GoRules rules, int handicap, float komi, const GoTime *time, bool passive) { GoGame *game; int i; assert((handicap >= 0) && (handicap <= 27)); game = wms_malloc(sizeof(GoGame)); MAGIC_SET(game); game->size = size; game->rules = rules; game->passive = passive; game->forcePlay = FALSE; if (handicap == 1) handicap = 0; game->handicap = handicap; game->komi = komi; if (time) { game->time = *time; } else { game->time.type = goTime_none; } game->moveNum = 0; game->maxMoves = 0; game->passCount = 0; game->movesLen = 5 /* 400 */; game->moves = wms_malloc(game->movesLen * sizeof(game->moves[0])); game->noLastMove = FALSE; game->board = goBoard_create(size); game->tmpBoard = goBoard_create(size); game->flags = wms_malloc(game->board->area * sizeof(uint)); game->hotMoves = wms_malloc(game->board->area * sizeof(int)); for (i = 0; i < goBoard_area(game->board); ++i) { game->hotMoves[i] = -1; game->flags[i] = 0; } game->flagsCleared = TRUE; game->cooloff = 0; game->state = goGameState_play; game->setWhoseMoveNum = -1; game->disputeAlive = FALSE; game->setWhoseMoveColor = 0; game->disputedLoc = 0; if (game->handicap && goGame_forcedHandicapPlacement(game)) goGame_addHandicapStones(game, game->board); game->whoseMove = goGame_whoseTurnOnMove(game, game->moveNum); return(game); } void goGame_destroy(GoGame *game) { assert(MAGIC(game)); goBoard_destroy(game->board); goBoard_destroy(game->tmpBoard); wms_free(game->flags); wms_free(game->hotMoves); wms_free(game->moves); MAGIC_UNSET(game); wms_free(game); } bool goGame_move(GoGame *game, GoStone moveColor, int move, GoTimer *timer) { bool stateChange = FALSE; bool disputeAnswer; int i; assert(MAGIC(game)); assert(game->passive || (moveColor == game->whoseMove)); assert((game->state == goGameState_play) || (game->state == goGameState_dispute)); assert(move >= 0); assert((game->state == goGameState_play) || (game->setWhoseMoveNum >= 0)); assert(game->moveNum >= game->setWhoseMoveNum); assert(goGame_isLegal(game, moveColor, move)); game->noLastMove = FALSE; if ((game->state == goGameState_play) && !game->flagsCleared) { for (i = 0; i < goBoard_area(game->board); ++i) { game->flags[i] = 0; } } addMoveToMoves(game, moveColor, move, game->moveNum); /* * Save this timer so if we rewind, we can reset the clock. */ if (timer != NULL) { game->moves[game->moveNum].time = *timer; if (timer->timeLeft < 0) game->moves[game->moveNum].time.timeLeft = 0; } else { game->moves[game->moveNum].time.timeLeft = 0; } /* * Place the move on the board. */ goGame_updateForMove(game, moveColor, move); game->maxMoves = game->moveNum; if (move == GOGAME_PASS) { /* A pass may change your state. */ if (game->state == goGameState_play) { /* Two passes puts you into selectDead state. */ if ((game->passCount == 2) && !game->passive && !game->forcePlay) { stateChange = TRUE; game->setWhoseMoveNum = game->moveNum; game->state = goGameState_selectDead; } } else { assert(game->state == goGameState_dispute); assert(game->setWhoseMoveNum >= 0); /* * Three passes puts you back into selectDead state. */ if ((game->passCount == 3) && !game->passive && !game->forcePlay) { disputeAnswer = game->disputeAlive; for (i = 0; i < goBoard_area(game->board); ++i) { if (game->flags[i] & GOGAMEFLAGS_DISPUTED) { if (disputeAnswer) { game->flags[i] = (game->flags[i] & ~(GOGAMEFLAGS_DISPUTED | GOGAMEFLAGS_MARKDEAD | GOGAMEFLAGS_WANTDEAD)) | GOGAMEFLAGS_RESOLVEALIVE; } else { game->flags[i] = (game->flags[i] & ~GOGAMEFLAGS_DISPUTED) | GOGAMEFLAGS_MARKDEAD | GOGAMEFLAGS_RESOLVEDEAD; } } } stateChange = TRUE; game->maxMoves = game->setWhoseMoveNum; goGame_moveTo(game, game->setWhoseMoveNum); game->state = goGameState_selectDead; /* * disputeAlive is sometimes changed when we replay back to the * end of the game, so we restore it's value here. */ game->disputeAlive = disputeAnswer; } } } game->whoseMove = goGame_whoseTurnOnMove(game, game->moveNum); return(stateChange); } static void goGame_updateForMove(GoGame *game, GoStone moveColor, int move) { int caps; assert(MAGIC(game)); assert((game->state == goGameState_done) || goGame_isLegal(game, moveColor, move)); caps = goBoard_addStone(game->board, moveColor, move, NULL); ++game->moveNum; assert(game->moveNum <= game->movesLen); /* * Update the list of hashes seen. * The hashes seen is used to quickly determine whether we have seen this * board position before. It is used for the superko rule and also to * detect a game with no result under Japanese and Tibetan rules. */ game->moves[game->moveNum].hash = goBoard_hashNoKo(game->board, moveColor); /* * I use hot stones to decide the Japanese and Tibetan ko rules. * Basically, a hot stone is a stone that cannot be captured. * Now decide whether or not to mark this stone as hot, and also whether or * not this was a "cooling" move; that is, one that made all hot stones * no longer hot. */ /* Check for the tibetan anti-snapback rule activation! */ if ((caps == 1) && (goRules_ko[game->rules] == goRulesKo_tibetan) && (goBoard_liberties(game->board, move) == 1)) { game->hotMoves[move] = game->moveNum; } /* Check for regular Japanese ko. */ if (goBoard_koLoc(game->board)) { game->hotMoves[move] = game->moveNum; } if ((move == 0) || (game->state == goGameState_play)) game->cooloff = game->moveNum; if (move == 0) { if ((game->state == goGameState_dispute) && (game->moveNum == game->setWhoseMoveNum)) game->passCount = 0; else { ++game->passCount; if ((game->state == goGameState_play) && (game->rules == goRules_aga)) goBoard_addCaps(game->board, goStone_opponent(moveColor), 1); } } else { game->passCount = 0; if (game->state == goGameState_dispute) { game->disputeAlive = isDisputeAlive(game); } } } bool goGame_isLegal(GoGame *game, GoStone moveColor, int move) { assert(MAGIC(game)); assert((move >= 0) && (move < game->board->area)); switch(game->state) { case goGameState_play: case goGameState_dispute: if (!game->passive && !game->forcePlay && (game->whoseMove != moveColor)) return(FALSE); return(goGame_canMove(game, moveColor, move)); break; case goGameState_selectDead: case goGameState_selectDisputed: return(goGame_canDispute(game, move)); break; case goGameState_done: return(FALSE); break; default: abort(); break; } } static bool goGame_canMove(GoGame *game, GoStone s, int move) { GoHash newHash; bool suicide, superKoMatch; GoBoard *b; int i, d; if (move == GOGAME_PASS) return(TRUE); if (goBoard_stone(game->board, move) != goStone_empty) return(FALSE); newHash = goBoard_quickHash(game->board, s, move, &suicide); if (suicide) { if (!goRules_suicide[game->rules]) return(FALSE); /* Single stone suicide is _always_ illegal. */ for (d = 0; d < 4; ++d) { if (goBoard_stone(game->board, move+goBoard_dir(game->board, d)) == s) break; } if (d == 4) return(FALSE); } /* Check for a ko. */ switch(goRules_ko[game->rules]) { case goRulesKo_super: assert(game->moveNum <= game->movesLen); for (i = 0; i < game->moveNum; ++i) { if (goHash_eq(game->moves[i].hash, newHash) && (goGame_whoseTurnOnMove(game, i) == goStone_opponent(s))) { /* * We _may_ have a match. Rebuild the board at the move in question * and see if they are equal. */ goBoard_copy(game->board, game->tmpBoard); goBoard_addStone(game->tmpBoard, s, move, NULL); b = goGame_replay(game, i, TRUE); superKoMatch = goBoard_eq(game->tmpBoard, b); goBoard_destroy(b); if (superKoMatch) return(FALSE); } } return(TRUE); break; case goRulesKo_tibetan: case goRulesKo_japanese: /* * Although these three ko rules are _not_ the same, they all restrict * moves with "hot" stones. The only difference in them is how to * decide which stones are hot. */ for (d = 0; d < 4; ++d) { if (goGame_isHot(game, move + goBoard_dir(game->board, d)) && (goBoard_stone(game->board, move + goBoard_dir(game->board, d)) != s)) return(FALSE); } return(TRUE); break; default: abort(); break; } } static bool goGame_canDispute(GoGame *game, int move) { assert(MAGIC(game)); assert((move >= 0) && (move < goBoard_area(game->board))); if (!goStone_isStone(goBoard_stone(game->board, move))) return(FALSE); if (game->flags[move] & GOGAMEFLAGS_RESOLVED) return(FALSE); return(TRUE); } GoStone goGame_whoseTurnOnMove(GoGame *game, int moveNum) { assert(MAGIC(game)); if ((game->setWhoseMoveNum >= 0) && (game->moveNum >= game->setWhoseMoveNum)) { if ((moveNum - game->setWhoseMoveNum) & 1) return(goStone_opponent(game->setWhoseMoveColor)); else return(game->setWhoseMoveColor); } else if (goGame_forcedHandicapPlacement(game)) { if (game->handicap) { if (moveNum & 1) return(goStone_black); else return(goStone_white); } else if (moveNum & 1) return(goStone_white); else return(goStone_black); } else { if (game->handicap) { if (moveNum < game->handicap) return(goStone_black); else { if ((moveNum - game->handicap) & 1) return(goStone_black); else return(goStone_white); } } else { if (moveNum & 1) return(goStone_white); else return(goStone_black); } } } static bool goGame_forcedHandicapPlacement(GoGame *game) { return(!goRules_freeHandicaps[game->rules] && !game->passive && (game->size >= 9) && (game->size & 1) && (game->handicap <= 9)); } static void goGame_addHandicapStones(GoGame *game, GoBoard *board) { int locs[9], numLocs = 0; int lo, mid, hi; assert(goGame_forcedHandicapPlacement(game)); if (game->size >= 13) lo = 3; else lo = 2; hi = game->size - lo - 1; mid = game->size / 2; locs[numLocs++] = goBoard_xy2Loc(board, hi, lo); locs[numLocs++] = goBoard_xy2Loc(board, lo, hi); if (game->handicap >= 3) locs[numLocs++] = goBoard_xy2Loc(board, lo, lo); if (game->handicap >= 4) { locs[numLocs++] = goBoard_xy2Loc(board, hi, hi); if (game->handicap & 1) locs[numLocs++] = goBoard_xy2Loc(board, mid, mid); } if (game->handicap >= 6) { locs[numLocs++] = goBoard_xy2Loc(board, lo, mid); locs[numLocs++] = goBoard_xy2Loc(board, hi, mid); } if (game->handicap >= 8) { locs[numLocs++] = goBoard_xy2Loc(board, mid, lo); locs[numLocs++] = goBoard_xy2Loc(board, mid, hi); } while (numLocs) { --numLocs; goBoard_addStone(board, goStone_black, locs[numLocs], NULL); } } bool goGame_moveTo(GoGame *game, int moveNum) { bool newState = FALSE; int oldSetColorMove; assert(MAGIC(game)); assert(moveNum >= 0); assert(game->passive || game->forcePlay || ((game->state == goGameState_play) || (game->state == goGameState_done) || (game->state == goGameState_dispute))); assert((game->state != goGameState_dispute) || (moveNum >= game->setWhoseMoveNum)); assert(moveNum <= game->maxMoves); game->moveNum = moveNum; oldSetColorMove = game->setWhoseMoveNum; goGame_replay(game, game->moveNum, FALSE); if ((game->state == goGameState_dispute) && (game->moveNum >= oldSetColorMove)) game->setWhoseMoveNum = oldSetColorMove; if ((game->state == goGameState_play) && (game->passCount == 2) && !game->passive && !game->forcePlay) { newState = TRUE; game->state = goGameState_done; } else if ((game->state == goGameState_done) && (game->passCount < 2) && !game->passive && !game->forcePlay) { newState = TRUE; game->state = goGameState_play; } return(newState); } /* * If separateBoard is set, then we assume that you only want the way the * board looked at that point so the game structure will be unchanged. * Otherwise game will be exactly as if a game were played to that point, * except (of course) maxMoves will be different. */ static GoBoard *goGame_replay(GoGame *game, int moves, bool separateBoard) { GoBoard *b; int i; assert(moves <= game->maxMoves); b = goBoard_create(game->size); if (!separateBoard) { goBoard_destroy(game->board); game->setWhoseMoveNum = -1; game->board = b; game->moveNum = 0; game->passCount = 0; for (i = 0; i < goBoard_area(b); ++i) { game->hotMoves[i] = -1; } } if (game->handicap && goGame_forcedHandicapPlacement(game)) goGame_addHandicapStones(game, b); assert(moves <= game->movesLen); for (i = 0; i < moves; ++i) { if (separateBoard) { goBoard_addStone(b, game->moves[i].color, game->moves[i].move, NULL); } else { game->whoseMove = game->moves[i].color; if ((game->time.type == goTime_none) || (game->moves[i].time.timeLeft >= 0)) { /* * If there was a time loss, then the last move isn't valid - the * game ended before the move could be made. */ goGame_updateForMove(game, game->whoseMove, game->moves[i].move); } else { ++game->moveNum; assert(game->moveNum < game->movesLen); } } } if (!separateBoard) { game->whoseMove = goGame_whoseTurnOnMove(game, i); } return(b); } void goGame_markDead(GoGame *game, int loc) { GoBoardGroupIter i; int iterLoc; assert(MAGIC(game)); assert(goStone_isStone(goBoard_stone(game->board, loc))); goBoardGroupIter(i, game->board, loc) { iterLoc = goBoardGroupIter_loc(i, game->board); game->flags[iterLoc] ^= GOGAMEFLAGS_MARKDEAD; } } void goGame_resume(GoGame *game) { assert(MAGIC(game)); assert(game->state == goGameState_selectDead); game->maxMoves -= 2; game->state = goGameState_play; goGame_replay(game, game->maxMoves, FALSE); game->whoseMove = goGame_whoseTurnOnMove(game, game->moveNum); } void goGame_done(GoGame *game) { assert(MAGIC(game)); assert(game->state == goGameState_selectDead); game->state = goGameState_done; game->maxMoves = game->moveNum; } void goGame_dispute(GoGame *game, int loc) { GoBoardGroupIter i; int stoneLoc; assert(MAGIC(game)); assert(game->state == goGameState_selectDisputed); game->state = goGameState_dispute; game->disputeAlive = TRUE; game->disputedLoc = loc; game->setWhoseMoveColor = goStone_opponent(goBoard_stone(game->board, loc)); game->passCount = 0; game->state = goGameState_dispute; assert(goStone_isStone(game->setWhoseMoveColor)); for (stoneLoc = 0; stoneLoc < goBoard_area(game->board); ++stoneLoc); goBoardGroupIter(i, game->board, loc) { stoneLoc = goBoardGroupIter_loc(i, game->board); game->flags[stoneLoc] = GOGAMEFLAGS_DISPUTED; } game->whoseMove = goGame_whoseTurnOnMove(game, game->moveNum); } static bool isDisputeAlive(GoGame *game) { int i; for (i = 0; i < goBoard_area(game->board); ++i) { if ((game->flags[i] & GOGAMEFLAGS_DISPUTED) && (goBoard_stone(game->board, i) == goStone_opponent(game->setWhoseMoveColor))) return(TRUE); } return(FALSE); } static void addMoveToMoves(GoGame *game, GoStone moveColor, int move, int moveNum) { GoGameMove *newMoves; int i; if (moveNum + 1 == game->movesLen) { newMoves = wms_malloc(game->movesLen * 2 * sizeof(game->moves[0])); for (i = 0; i < game->movesLen; ++i) { newMoves[i] = game->moves[i]; } wms_free(game->moves); game->moves = newMoves; game->movesLen *= 2; } assert(moveNum + 1 < game->movesLen); game->moves[moveNum].move = move; game->moves[moveNum].color = moveColor; } int goGame_lastMove(GoGame *g) { assert(MAGIC(g)); if (g->noLastMove || (g->moveNum == 0)) return(0); assert(g->moveNum > 0); assert(g->moveNum <= g->movesLen); return(g->moves[g->moveNum - 1].move); } void goGame_setBoard(GoGame *game, GoStone color, int loc) { assert(MAGIC(game)); if (goStone_isStone(color) && goStone_isStone(goBoard_stone(game->board, loc))) { if (goBoard_stone(game->board, loc) == color) return; goBoard_addStone(game->board, goStone_empty, loc, NULL); } goBoard_addStone(game->board, color, loc, NULL); } const GoTimer *goGame_getTimer(const GoGame *game, GoStone color) { if (color == game->whoseMove) { if (game->moveNum <= 1) { return(NULL); } else { return(&game->moves[game->moveNum - 2].time); } } else { if (game->moveNum <= 0) { return(NULL); } else { return(&game->moves[game->moveNum - 1].time); } } } cgoban-1.9.14/src/goHash.c0000664000671000067100000000154207043224470010674 /* * src/gohash.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include "goHash.h" #if GoHash_isScalar const GoHash goHash_zero = 0; const GoHash goHash_pass = 1; #else const GoHash goHash_zero = {0, 0}; const GoHash goHash_pass = {1, 0}; #endif /* GoHash_isScalar */ GoHash goHash_init(Rnd *r) { GoHash v; int i; #if GoHash_isScalar v = 0; for (i = 0; i < sizeof(GoHash) / sizeof(uint32); ++i) v = (v << 32) | (GoHash)rnd_uint32(r); v &= ~1; #else v.hi = rnd_uint32(r); v.lo = rnd_uint32(r) & ~1; #endif /* GoHash_isScalar */ return(v); } #if !GoHash_isScalar GoHash goHash_xor(GoHash v1, GoHash v2) { v1.lo ^= v2.lo; v1.hi ^= v2.hi; return(v1); } #endif /* !GoHash_isScalar */ cgoban-1.9.14/src/goPic.c0000664000671000067100000002405207043224470010525 /* * src/gopic.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include "cgoban.h" #include "goPic.h" #include "goGame.h" #include "cgbuts.h" #include "plasma.h" #include "cm2pm.h" static ButOut gridPressed(But *but); GoPic *goPic_create(Cgoban *cg, void *packet, GoGame *game, ButWin *win, int layer, ButOut pressed(void *packet, int loc), int size) { GoPic *p; int i, x, y, loc; char label[3]; p = wms_malloc(sizeof(GoPic)); MAGIC_SET(p); p->cg = cg; p->game = game; p->press = pressed; p->packet = packet; p->size = size; /* * if (cg->cgbuts.color == GrayScale && 0) { * p->boardBg = butBoxFilled_create(win, layer, BUT_DRAWABLE); * butBoxFilled_setColors(p->boardBg, BUT_LIT, BUT_SHAD, BUT_LIT); * } */ p->boardBg = butPixmap_create(win, layer, BUT_DRAWABLE, None); butPixmap_setPic(p->boardBg, p->cg->boardPixmap, 0,0); p->size = size; p->allowedMoves = goPicMove_legal; p->boardButs = wms_malloc(goBoard_area(game->board) * sizeof(But *)); for (i = 0; i < goBoard_area(game->board); ++i) p->boardButs[i] = NULL; for (x = 0; x < size; ++x) { for (y = 0; y < size; ++y) { loc = goBoard_xy2Loc(game->board, x, y); p->boardButs[loc] = grid_create(&cg->cgbuts, gridPressed, p, win, layer+1, BUT_DRAWABLE, loc); } } grid_setLineGroup(p->boardButs[goBoard_xy2Loc(game->board, 0, 0)], gridLines_ul); grid_setLineGroup(p->boardButs[goBoard_xy2Loc(game->board, size-1, 0)], gridLines_ur); grid_setLineGroup(p->boardButs[goBoard_xy2Loc(game->board, 0, size-1)], gridLines_ll); grid_setLineGroup(p->boardButs[goBoard_xy2Loc(game->board, size-1, size-1)], gridLines_lr); for (x = 1; x < size-1; ++x) { grid_setLineGroup(p->boardButs[goBoard_xy2Loc(game->board, x,0)], gridLines_top); grid_setLineGroup(p->boardButs[goBoard_xy2Loc(game->board, 0,x)], gridLines_left); grid_setLineGroup(p->boardButs[goBoard_xy2Loc(game->board, size-1,x)], gridLines_right); grid_setLineGroup(p->boardButs[goBoard_xy2Loc(game->board, x,size-1)], gridLines_bottom); } if (size == 19) { for (x = 3; x < 19; x += 6) { for (y = 3; y < 19; y += 6) { grid_setStarPoint(p->boardButs[goBoard_xy2Loc(game->board, x,y)], TRUE); } } } else if (size == 13) { for (x = 3; x < 12; x += 3) { for (y = 3; y < 12; y += 3) { grid_setStarPoint(p->boardButs[goBoard_xy2Loc(game->board, x,y)], TRUE); } } } else if (size == 9) { grid_setStarPoint(p->boardButs[goBoard_xy2Loc(game->board, 4,4)], TRUE); grid_setStarPoint(p->boardButs[goBoard_xy2Loc(game->board, 2,2)], TRUE); grid_setStarPoint(p->boardButs[goBoard_xy2Loc(game->board, 2,6)], TRUE); grid_setStarPoint(p->boardButs[goBoard_xy2Loc(game->board, 6,2)], TRUE); grid_setStarPoint(p->boardButs[goBoard_xy2Loc(game->board, 6,6)], TRUE); } assert(size < 50); p->letters = wms_malloc(size * 2 * sizeof(But *)); p->numbers = wms_malloc(size * 2 * sizeof(But *)); for (i = 0; i < size; ++i) { label[0] = 'A' + (i % 25); label[1] = '\0'; if (label[0] >= 'I') ++label[0]; if (i > 24) { label[1] = label[0]; label[2] = '\0'; } p->letters[i] = butText_create(win, layer+1, 0, label, butText_center); butText_setFont(p->letters[i], 1); p->letters[i+size] = butText_create(win, layer+1, 0, label, butText_center); butText_setFont(p->letters[i+size], 1); sprintf(label, "%d", size-i); p->numbers[i] = butText_create(win, layer+1, 0, label, butText_center); butText_setFont(p->numbers[i], 1); p->numbers[i+size] = butText_create(win, layer+1, 0, label, butText_center); butText_setFont(p->numbers[i+size], 1); } return(p); } void goPic_destroy(GoPic *p) { assert(MAGIC(p)); /* * I don't destroy the buttons. Kill the window to do that. */ wms_free(p->boardButs); wms_free(p->letters); wms_free(p->numbers); MAGIC_UNSET(p); wms_free(p); } void goPic_resize(GoPic *p, int x, int y, int w, int h) { int i, bx, by; int edgeLabelSize, stoneW, stoneH, stoneX0, stoneY0; int loc; assert(w == h); if (p->cg->showCoords) { edgeLabelSize = butEnv_fontH(p->cg->env, 1); i = butEnv_textWidth(p->cg->env, "00", 1); if (i > edgeLabelSize) edgeLabelSize = i; } else edgeLabelSize = 0; stoneW = (w - edgeLabelSize * 2) / p->size; if (stoneW < edgeLabelSize) { edgeLabelSize = 0; stoneW = (w - edgeLabelSize * 2) / p->size; } stoneH = (h - edgeLabelSize * 2) / p->size; stoneX0 = x + (w - stoneW * p->size) / 2; stoneY0 = y + (h - stoneH * p->size) / 2; but_resize(p->boardBg, x,y, w,h); for (bx = 0; bx < p->size; ++bx) { for (by = 0; by < p->size; ++by) { loc = goBoard_xy2Loc(p->game->board, bx, by); but_resize(p->boardButs[loc], bx*stoneW+stoneX0, by*stoneH+stoneY0, stoneW,stoneH); } } but_draw(p->boardBg); if (p->cg->showCoords) { for (i = 0; i < p->size*2; ++i) { but_setFlags(p->letters[i], BUT_DRAWABLE); but_setFlags(p->numbers[i], BUT_DRAWABLE); } } else { for (i = 0; i < p->size*2; ++i) { but_setFlags(p->letters[i], BUT_NODRAW); but_setFlags(p->numbers[i], BUT_NODRAW); } } for (i = 0; i < p->size; ++i) { but_resize(p->letters[i], i*stoneW + stoneX0, stoneY0 - edgeLabelSize, stoneW, edgeLabelSize); but_resize(p->letters[i+p->size], i*stoneW + stoneX0, stoneY0 + p->size*stoneW, stoneW, edgeLabelSize); but_resize(p->numbers[i], stoneX0 - edgeLabelSize, stoneY0 + i*stoneW, edgeLabelSize, stoneW); but_resize(p->numbers[i+p->size], stoneX0 + p->size*stoneW, stoneY0 + i*stoneW, edgeLabelSize, stoneW); } } void goPic_setButHold(GoPic *p, bool hold) { int i; for (i = 0; i < goBoard_area(p->game->board); ++i) { if (p->boardButs[i]) { grid_setHold(p->boardButs[i], hold); } } } GoStone goPic_update(GoPic *p) { int i; GoStone s, toMove; GoGame *game = p->game; GoBoard *board = game->board; bool setMove; GoMarkType mark; bool grey; int markAux; int whiteVersion; uint moveType, allowed; assert(MAGIC(p)); whiteVersion = rnd_int(p->cg->rnd) % CGBUTS_NUMWHITE; setMove = ((game->state == goGameState_play) || (game->state == goGameState_dispute)); allowed = p->allowedMoves; if (allowed & goPicMove_forceWhite) toMove = goStone_white; else if (allowed & goPicMove_forceBlack) toMove = goStone_black; else if (setMove) toMove = goGame_whoseMove(game); else toMove = goStone_empty; if ((toMove == goStone_white) && (allowed & goPicMove_noWhite)) allowed = 0; else if ((toMove == goStone_black) && (allowed & goPicMove_noBlack)) allowed = 0; for (i = 0; i < goBoard_area(board); ++i) { if (p->boardButs[i]) { s = goBoard_stone(board, i); mark = goMark_none; grey = FALSE; markAux = 0; switch(game->state) { case goGameState_dispute: if (game->flags[i] & GOGAMEFLAGS_DISPUTED) mark = goMark_triangle; /* Fall through to goGameState_play */ case goGameState_play: if (goGame_lastMove(game) == i) mark = goMark_lastMove; if (goGame_isHot(game, i)) mark = goMark_ko; break; case goGameState_selectDead: case goGameState_selectDisputed: case goGameState_done: if ((game->flags[i] & GOGAMEFLAGS_WANTDEAD) && (game->state != goGameState_done)) mark = goMark_triangle; if (game->flags[i] & GOGAMEFLAGS_MARKDEAD) grey = TRUE; if ((game->flags[i] & GOGAMEFLAGS_MARKDEAD) || (s == goStone_empty)) { if (((game->flags[i] & GOGAMEFLAGS_SEEN) == GOGAMEFLAGS_SEEBLACK) && ((game->rules != goRules_japanese) || (game->flags[i] & GOGAMEFLAGS_NOSEKI))) mark = goMark_smBlack; if (((game->flags[i] & GOGAMEFLAGS_SEEN) == GOGAMEFLAGS_SEEWHITE) && ((game->rules != goRules_japanese) || (game->flags[i] & GOGAMEFLAGS_NOSEKI))) mark = goMark_smWhite; } break; default: break; } /* * If it's a passive game, then we can't set the marks of the grid * ourselves. the sgfPlay module must do it instead. */ if (game->passive && (game->state != goGameState_selectDead)) { /* * If there's no other mark there and it's a mark for the last * move or a ko, then we draw the mark for the last move. * Otherwise sgfPlay's mark takes precedence. */ if (((mark != goMark_lastMove) && (mark != goMark_ko)) || (grid_markType(p->boardButs[i]) != goMark_none)) { grey = grid_grey(p->boardButs[i]); mark = grid_markType(p->boardButs[i]); markAux = grid_markAux(p->boardButs[i]); } } if (goStone_isStone(goBoard_stone(game->board, i))) moveType = goPicMove_stone; else moveType = goPicMove_empty; if ((s != grid_stone(p->boardButs[i])) || (grey != grid_grey(p->boardButs[i]))) { if (s == goStone_white) grid_setVersion(p->boardButs[i], (rnd_int(p->cg->rnd) % CGBUTS_NUMWHITE)); grid_setStone(p->boardButs[i], goBoard_stone(board, i), grey); } if ((mark != grid_markType(p->boardButs[i])) || (markAux != grid_markAux(p->boardButs[i]))) grid_setMark(p->boardButs[i], mark, markAux); if (allowed & goPicMove_legal) { if (goGame_isLegal(game, toMove, i)) moveType |= goPicMove_legal; } if (moveType & allowed) { if (setMove) { if ((toMove == goStone_white) && (grid_stone(p->boardButs[i]) == goStone_empty)) grid_setVersion(p->boardButs[i], whiteVersion); grid_setPress(p->boardButs[i], toMove); } else but_setFlags(p->boardButs[i], BUT_PRESSABLE); } else { but_setFlags(p->boardButs[i], BUT_NOPRESS); } } } return(toMove); } static ButOut gridPressed(But *but) { GoPic *p; p = but_packet(but); assert(MAGIC(p)); return(p->press(p->packet, grid_pos(but))); } cgoban-1.9.14/src/goScore.c0000664000671000067100000004065207046432415011074 /* * Part of Complete Goban (game program) * * $Source: /cvsroot/cgoban1/cgoban1/src/goScore.c,v $ * $Revision: 1.3 $ * $Date: 2000/02/04 02:10:21 $ * * Copyright (C) 1995-1996,2000 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include #include "goBoard.h" #include "goGame.h" #include "goScore.h" #include "msg.h" /********************************************************************** * Forward Declarations **********************************************************************/ static void checkIfSeki(GoGame *game, int loc); static void markNeighborEmptySpecial(GoGame *game, int loc, GoStone s); static void markSpecialStones(GoGame *game, GoStone s, uint mark); static int findSpecialEyes(GoGame *game, GoStone s); static int countNeighbors(GoGame *g, GoBoard *b, int loc, GoStone s); static void removeFakeEyes(GoGame *g, GoStone s); static void testGroupForFake(GoGame *g, int loc, GoStone s); static void paintRelatedGroupsFaketest(GoGame *g, int loc, GoStone s); /********************************************************************** * Functions **********************************************************************/ Str *goScore_str(GoScore *score, GoGame *game, const GoTime *time, const GoTimer *timers) { Str *result, ingTimes[2], winner; GoRules rules = game->rules; float scores[2]; int timePenalties[2]; GoStone s; result = str_create(); goStoneIter(s) { str_init(&ingTimes[s]); if (time != NULL) timePenalties[s] = goTime_ingPenalty(time, &timers[s]); if (timePenalties[s]) { str_print(&ingTimes[s], msg_ingPenaltyComment, timePenalties[s]); } scores[s] = score->scores[s] - timePenalties[s]; } if (goRules_scoreKills[rules]) { str_print(result, msg_scoreKillsComment, score->territories[goStone_white], goGame_caps(game, goStone_white) + score->deadStones[goStone_white], game->komi, str_chars(&ingTimes[goStone_white]), scores[goStone_white], score->territories[goStone_black], goGame_caps(game, goStone_black) + score->deadStones[goStone_black], str_chars(&ingTimes[goStone_black]), scores[goStone_black]); } else { str_print(result, msg_scoreNoKillsComment, score->territories[goStone_white], score->livingStones[goStone_white], (double)score->dame / 2.0, game->komi, str_chars(&ingTimes[goStone_white]), scores[goStone_white], score->territories[goStone_black], score->livingStones[goStone_black], (double)score->dame / 2.0, str_chars(&ingTimes[goStone_black]), scores[goStone_black]); } str_init(&winner); if (scores[goStone_white] > scores[goStone_black]) { str_print(&winner, msg_winnerComment, msg_stoneNames[goStone_white], scores[goStone_white] - scores[goStone_black]); } else if ((scores[goStone_black] > scores[goStone_white]) || (game->rules == goRules_ing)) { str_print(&winner, msg_winnerComment, msg_stoneNames[goStone_black], scores[goStone_black] - scores[goStone_white]); } else { str_print(&winner, msg_jigoComment); } str_cat(result, &winner); str_catChar(result, '\n'); str_deinit(&winner); str_deinit(&ingTimes[goStone_white]); str_deinit(&ingTimes[goStone_black]); return(result); } void goScore_compute(GoScore *score, GoGame *game) { int sekiArea[2], dame = 0; GoBoard *b = game->board; bool change; int i, j, min, max; uint oldFlags; GoStone s; assert(MAGIC(game)); assert(game->state >= goGameState_selectDead); game->flagsCleared = FALSE; min = goBoard_minLoc(game->board); max = goBoard_maxLoc(game->board); score->livingStones[goStone_black] = score->livingStones[goStone_white] = 0; score->territories[goStone_black] = score->territories[goStone_white] = 0; score->deadStones[goStone_black] = score->deadStones[goStone_white] = 0; score->dame = 0; sekiArea[goStone_black] = sekiArea[goStone_white] = 0; /* Add up the number of living stones. */ for (i = min; i < max; ++i) { game->flags[i] &= ~(GOGAMEFLAGS_SEEN | GOGAMEFLAGS_SEKI | GOGAMEFLAGS_NOSEKI); s = goBoard_stone(b, i); if (goStone_isStone(s)) { if (game->flags[i] & GOGAMEFLAGS_MARKDEAD) { ++score->deadStones[goStone_opponent(s)]; } else { game->flags[i] |= goGameFlags_see(s); ++score->livingStones[s]; } } } /* * Now iterate over the board, figuring out what empty spaces see * different stones. */ do { change = FALSE; for (i = min; i < max; ++i) { if ((goBoard_stone(b, i) == goStone_empty) || (game->flags[i] & GOGAMEFLAGS_MARKDEAD)) { /* It's an empty space. */ oldFlags = game->flags[i]; for (j = 0; j < 4; ++j) { game->flags[i] |= game->flags[i + goBoard_dir(b, j)] & GOGAMEFLAGS_SEEN; } change = (change || (game->flags[i] != oldFlags)); } } } while (change); /* * Go through and find all the sekis. */ if (game->rules == goRules_japanese) { for (i = 0; i < goBoard_area(game->board); ++i) { if (goStone_isStone(goBoard_stone(game->board, i)) && !(game->flags[i] & (GOGAMEFLAGS_SEKI | GOGAMEFLAGS_NOSEKI | GOGAMEFLAGS_MARKDEAD))) checkIfSeki(game, i); } } for (i = min; i < max; ++i) { if ((goBoard_stone(b, i) == goStone_empty) || (game->flags[i] & GOGAMEFLAGS_MARKDEAD)) { if (((game->flags[i] & GOGAMEFLAGS_SEEBLACK) == 0) == ((game->flags[i] & GOGAMEFLAGS_SEEWHITE) == 0)) { ++dame; } else if (game->flags[i] & GOGAMEFLAGS_SEEBLACK) { if (game->flags[i] & GOGAMEFLAGS_SEKI) { ++sekiArea[goStone_black]; } else { ++score->territories[goStone_black]; } } else { assert(game->flags[i] & GOGAMEFLAGS_SEEWHITE); if (game->flags[i] & GOGAMEFLAGS_SEKI) { ++sekiArea[goStone_white]; } else { ++score->territories[goStone_white]; } } } } score->dame = dame; switch(game->rules) { case goRules_chinese: case goRules_ing: case goRules_nz: goStoneIter(s) { score->territories[s] += sekiArea[s]; score->scores[s] = (float)dame / 2.0 + score->territories[s] + score->livingStones[s]; } break; case goRules_aga: case goRules_tibetan: goStoneIter(s) { score->territories[s] += sekiArea[s]; score->scores[s] = score->territories[s] + goGame_caps(game, s) + score->deadStones[s]; } break; case goRules_japanese: goStoneIter(s) { score->scores[s] = score->territories[s] + goGame_caps(game, s) + score->deadStones[s]; } break; } score->scores[goStone_white] += game->komi; } static void checkIfSeki(GoGame *game, int loc) { GoStone s; int i; s = goBoard_stone(game->board, loc); goBoard_copy(game->board, game->tmpBoard); for (i = 0; i < goBoard_area(game->tmpBoard); ++i) { if (goStone_isStone(goBoard_stone(game->tmpBoard, i)) && (game->flags[i] & GOGAMEFLAGS_MARKDEAD)) goBoard_rmGroup(game->tmpBoard, i); } markNeighborEmptySpecial(game, loc, s); removeFakeEyes(game, s); if (findSpecialEyes(game, s) > 1) { markSpecialStones(game, s, GOGAMEFLAGS_NOSEKI); return; } markSpecialStones(game, s, GOGAMEFLAGS_SEKI); } static void markNeighborEmptySpecial(GoGame *game, int loc, GoStone s) { int i, d; bool change; GoStone stoneHere; uint oldFlags, enemySeen; for (i = 0; i < goBoard_area(game->tmpBoard); ++i) game->flags[i] &= ~(GOGAMEFLAGS_SPECIAL | GOGAMEFLAGS_EYE | GOGAMEFLAGS_NOTFAKE | GOGAMEFLAGS_FAKETEST); game->flags[loc] |= GOGAMEFLAGS_SPECIAL; do { change = FALSE; for (i = 0; i < goBoard_area(game->tmpBoard); ++i) { stoneHere = goBoard_stone(game->tmpBoard, i); if (!(game->flags[i] & GOGAMEFLAGS_SPECIAL) && ((stoneHere == goStone_empty) || (stoneHere == s))) { oldFlags = game->flags[i]; for (d = 0; d < 4; ++d) game->flags[i] |= game->flags[i+goBoard_dir(game->tmpBoard, d)] & GOGAMEFLAGS_SPECIAL; change = (change || (oldFlags != game->flags[i])); } } } while (change); enemySeen = goGameFlags_see(goStone_opponent(s)); for (i = 0; i < goBoard_area(game->tmpBoard); ++i) { if (game->flags[i] & enemySeen) game->flags[i] &= ~GOGAMEFLAGS_SPECIAL; } } static void markSpecialStones(GoGame *game, GoStone s, uint mark) { int i; for (i = 0; i < goBoard_area(game->tmpBoard); ++i) { if (game->flags[i] & GOGAMEFLAGS_SPECIAL) game->flags[i] |= mark; } } static int findSpecialEyes(GoGame *game, GoStone s) { uint oldFlags; int i, d, eyeSize, n; int deadEnemyLoc, enemySize = 0, deadEnemyConn[5]; int specialConn[5]; bool change, emptyAwayFromEnemy = FALSE; GoStone opponent = goStone_opponent(s); deadEnemyLoc = 0; for (i = 0; i < 5; ++i) { deadEnemyConn[i] = 0; specialConn[i] = 0; } for (i = 0; i < goBoard_area(game->tmpBoard); ++i) { if ((game->flags[i] & GOGAMEFLAGS_SPECIAL) && (goBoard_stone(game->tmpBoard, i) == goStone_empty)) { game->flags[i] |= GOGAMEFLAGS_EYE; break; } } if (i == goBoard_area(game->tmpBoard)) { return(0); } /* * If this is a dead enemy stone, we want to know! */ if (goBoard_stone(game->board, i) == opponent) { deadEnemyLoc = i; ++deadEnemyConn[countNeighbors(game, game->board, i, opponent)]; ++enemySize; } else { n = countNeighbors(game, game->board, i, goStone_empty); ++specialConn[n]; if (n >= 3) return(2); if (countNeighbors(game, game->board, i, opponent) == 0) emptyAwayFromEnemy = TRUE; } eyeSize = 1; do { change = FALSE; for (i = 0; i < goBoard_area(game->tmpBoard); ++i) { if (((game->flags[i] & (GOGAMEFLAGS_EYE|GOGAMEFLAGS_SPECIAL)) == GOGAMEFLAGS_SPECIAL) && (goBoard_stone(game->tmpBoard, i) == goStone_empty)) { oldFlags = game->flags[i]; for (d = 0; d < 4; ++d) game->flags[i] |= game->flags[i+goBoard_dir(game->tmpBoard, d)] & GOGAMEFLAGS_EYE; if (game->flags[i] != oldFlags) { change = TRUE; ++eyeSize; if (goBoard_stone(game->board, i) == opponent) { if (deadEnemyLoc) { if (!goBoard_groupEq(game->board, deadEnemyLoc, i)) return(2); } else deadEnemyLoc = i; ++deadEnemyConn[countNeighbors(game, game->board, i, opponent)]; ++enemySize; } else { n = countNeighbors(game, game->board, i, goStone_empty); ++specialConn[n]; if (n >= 3) return(2); if (countNeighbors(game, game->board, i, opponent) == 0) emptyAwayFromEnemy = TRUE; } } } } } while (change); /* * Look for a second eye. */ for (i = 0; i < goBoard_area(game->tmpBoard); ++i) { if (((game->flags[i] & (GOGAMEFLAGS_SPECIAL | GOGAMEFLAGS_EYE)) == GOGAMEFLAGS_SPECIAL) && (goBoard_stone(game->tmpBoard, i) == goStone_empty)) { return(2); } } /* * We have one big eye with no dead enemies in in. It can make unless it * is less than 3 in size or it is a 4 space 2x2 eye. */ if (enemySize == 0) { switch(eyeSize) { case(1): case(2): return(1); case(4): if (specialConn[2] == 4) return(1); else return(2); default: return(2); } } /* * If there are enemies and you have a liberty away from them, then you * can get two eyes. */ if (emptyAwayFromEnemy) return(2); /* * We have some dead enemies. See if they're in a dead shape. */ /* * First test: Matches ? * ? # ? * ? */ if (deadEnemyConn[4] + deadEnemyConn[3] + deadEnemyConn[2] < 2) return(1); /* * Second test: Matches # # * ? # # * ? */ if ((deadEnemyConn[4] == (deadEnemyConn[1] == 2)) && (deadEnemyConn[3] == (deadEnemyConn[1] == 1)) && (deadEnemyConn[4] + deadEnemyConn[3] + deadEnemyConn[2] == 4) && (deadEnemyConn[1] < 3)) return(1); /* * Second test: Matches # # * # # # * # # */ if ((deadEnemyConn[4] == 1) && (deadEnemyConn[2] == 6) && (enemySize == 7)) return(1); return(2); } static int countNeighbors(GoGame *g, GoBoard *b, int loc, GoStone s) { int d, newLoc, count; for (d = 0, count = 0; d < 4; ++d) { newLoc = loc + goBoard_dir(b, d); if ((goBoard_stone(b, newLoc) == s) && (g->flags[newLoc] & GOGAMEFLAGS_SPECIAL)) ++count; } return(count); } static void removeFakeEyes(GoGame *g, GoStone s) { int i; bool change; do { change = FALSE; for (i = 0; i < goBoard_area(g->tmpBoard); ++i) { if ((goBoard_stone(g->tmpBoard, i) == s) && ((g->flags[i] & (GOGAMEFLAGS_SPECIAL | GOGAMEFLAGS_NOTFAKE)) == GOGAMEFLAGS_SPECIAL)) { change = TRUE; testGroupForFake(g, i, s); break; } } } while (change); } static void testGroupForFake(GoGame *g, int loc, GoStone s) { int i, d, faketests, conns, newLoc; int emptySeen = 0; paintRelatedGroupsFaketest(g, loc, s); /* * All SPECIAL empties touching FAKETEST stones are fake UNLESS: * - There are more than one SPECIAL empties that touch FAKETEST * stones. * or * - There is at least one SPECIAL empty that is bounded on all four * sides by FAKETEST stones. */ for (i = 0; i < goBoard_area(g->tmpBoard); ++i) { if ((goBoard_stone(g->tmpBoard, i) == goStone_empty) && (g->flags[i] & GOGAMEFLAGS_SPECIAL)) { faketests = 0; conns = 0; for (d = 0; d < 4; ++d) { newLoc = i + goBoard_dir(g->tmpBoard, d); if (g->flags[newLoc] & GOGAMEFLAGS_FAKETEST) { ++faketests; } else if (goBoard_stone(g->tmpBoard, newLoc) == goStone_edge) { ++conns; } } if (faketests) ++emptySeen; if (faketests + conns == 4) { ++emptySeen; } } } if (emptySeen != 1) { /* No fakes associated with this group. */ for (i = 0; i < goBoard_area(g->tmpBoard); ++i) { if ((goBoard_stone(g->tmpBoard, i) == s) && (g->flags[i] & GOGAMEFLAGS_FAKETEST)) { g->flags[i] |= GOGAMEFLAGS_NOTFAKE; } g->flags[i] &= ~GOGAMEFLAGS_FAKETEST; } } else { /* * Fake. Turn off the specialness of all adjacent empties, and * also turn off all NOTFAKE flags. * Turn on the SEEBLACK and the SEEWHITE flags to make sure that * the fake eyes don't count for territory. */ #ifdef PRINT_OUT_BOARD int x, y; printf("--------------------------------------------------------------\n"); for (y = 0; y < 9; ++y) { for (x = 0; x < 9; ++x) { printf("%c%c%c%c ", (g->flags[x+y*10+11] & GOGAMEFLAGS_FAKETEST ? 'F' : '.'), (g->flags[x+y*10+11] & GOGAMEFLAGS_SPECIAL ? 'S' : '.'), (g->flags[x+y*10+11] & GOGAMEFLAGS_SEEBLACK ? 'B' : '.'), (g->flags[x+y*10+11] & GOGAMEFLAGS_SEEWHITE ? 'W' : '.')); } printf("\n"); } printf("--------------------------------------------------------------\n"); #endif for (i = 0; i < goBoard_area(g->tmpBoard); ++i) { if ((goBoard_stone(g->tmpBoard, i) == s) && (g->flags[i] & GOGAMEFLAGS_FAKETEST)) { for (d = 0; d < 4; ++d) { newLoc = i + goBoard_dir(g->tmpBoard, d); if ((g->flags[newLoc] & GOGAMEFLAGS_SPECIAL) && (goBoard_stone(g->tmpBoard, newLoc) == goStone_empty)) { g->flags[newLoc] = (g->flags[newLoc] & ~GOGAMEFLAGS_SPECIAL) | (GOGAMEFLAGS_SEEBLACK|GOGAMEFLAGS_SEEWHITE); } } } g->flags[i] &= ~(GOGAMEFLAGS_FAKETEST | GOGAMEFLAGS_NOTFAKE); } } } /* * All stones that are connected by non-eye spaces are related. Here * we paint all such groups FAKETEST. */ static void paintRelatedGroupsFaketest(GoGame *g, int loc, GoStone s) { bool change; uint oldFlags; int i, d; g->flags[loc] |= GOGAMEFLAGS_FAKETEST; do { change = FALSE; for (i = 0; i < goBoard_area(g->tmpBoard); ++i) { if ((goBoard_stone(g->tmpBoard, i) == s) || ((goBoard_stone(g->tmpBoard, i) == goStone_empty) && !(g->flags[i] & GOGAMEFLAGS_SPECIAL))) { oldFlags = g->flags[i]; for (d = 0; d < 4; ++d) g->flags[i] |= (g->flags[i + goBoard_dir(g->tmpBoard, d)] & GOGAMEFLAGS_FAKETEST); change = (change || (oldFlags != g->flags[i])); } } } while (change); } void goScore_zero(GoScore *score) { GoStone color; score->dame = 0; goStoneIter(color) { score->territories[color] = 0; score->livingStones[color] = 0; score->deadStones[color] = 0; score->scores[color] = 0.0; } } cgoban-1.9.14/src/goTime.c0000664000671000067100000001577607043224470010725 /* * src/gotime.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include "goTime.h" int goTime_parseChars(const char *t, bool ignoreExtra, bool *err) { bool dummy; int numScans; int v1, v2, v3; char c1, c2, c3; if (err == NULL) err = &dummy; numScans = sscanf(t, "%d%c%d%c%d%c", &v1, &c1, &v2, &c2, &v3, &c3); if (ignoreExtra) { if ((numScans > 1) && (c1 != ':')) { numScans = 1; } else if ((numScans > 3) && (c2 != ':')) { numScans = 3; } else if (numScans > 5) numScans = 5; } switch(numScans) { case 1: /* Format "mm" */ if (v1 >= 0) { *err = FALSE; return(v1 * 60); } break; case 3: /* Format "mm:ss" */ if ((c1 == ':') && (v1 >= 0) && (v2 >= 0) && (v2 < 60)) { *err = FALSE; return(v1 * 60 + v2); } break; case 5: /* Format "hh:mm:ss" */ if ((c1 == ':') && (c2 == ':') && (v1 >= 0) && (v2 >= 0) && (v3 >= 0) && (v2 < 60) && (v3 < 60)) { *err = FALSE; return(v1*60*60 + v2*60 + v3); } break; default: break; } *err = TRUE; return(0); } void goTime_str(int time, Str *out) { assert(time >= 0); if (time < 60*60) { str_print(out, "%d:%02d", time/60, time%60); } else { str_print(out, "%d:%02d:%02d", time/(60*60), (time/60)%60, time%60); } } void goTime_describeStr(const GoTime *time, Str *out) { Str tmp; switch(time->type) { case(goTime_none): str_copyChar(out, '-'); break; case(goTime_absolute): goTime_str(time->main, out); break; case(goTime_canadian): str_init(&tmp); goTime_str(time->main, out); goTime_str(time->by, &tmp); str_catChar(out, '+'); str_cat(out, &tmp); str_catChar(out, '/'); str_catInt(out, time->aux); str_deinit(&tmp); break; case(goTime_japanese): str_init(&tmp); goTime_str(time->main, out); goTime_str(time->by, &tmp); str_catChar(out, '('); str_catInt(out, time->aux); str_catChar(out, 'x'); str_cat(out, &tmp); str_catChar(out, ')'); str_deinit(&tmp); break; case(goTime_ing): str_init(&tmp); goTime_str(time->main, out); goTime_str(time->by, &tmp); str_catChar(out, '+'); str_cat(out, &tmp); str_catChar(out, 'x'); str_catInt(out, time->aux); str_deinit(&tmp); break; default: assert(0); break; } } void goTime_parseDescribeChars(GoTime *time, const char *desc) { if (isdigit(desc[0])) { time->main = goTime_parseChars(desc, TRUE, NULL); for (;;) { switch(*(++desc)) { case '\0': time->type = goTime_absolute; return; case '+': ++desc; time->by = goTime_parseChars(desc, TRUE, NULL); while (*desc && (*desc != '/') && (*desc != 'x')) ++desc; switch(*desc) { case '/': time->type = goTime_canadian; ++desc; time->aux = wms_atoi(desc, NULL); break; case 'x': time->type = goTime_ing; ++desc; time->aux = wms_atoi(desc, NULL); break; default: time->type = goTime_none; break; } return; break; case '(': time->type = goTime_japanese; ++desc; /* Can't use wms_atoi here, it will report an error and return 0. */ time->aux = atoi(desc); while (*desc && (*desc != 'x')) ++desc; if (*desc == 'x') { time->by = goTime_parseChars(desc+1, TRUE, NULL); } else { time->type = goTime_none; } return; break; default: break; } } } else time->type = goTime_none; } void goTime_remainStr(const GoTime *time, const GoTimer *timer, Str *out) { int tLeft; tLeft = timer->timeLeft; if (timer->usLeft) ++tLeft; if (tLeft < 0) tLeft = 0; switch(time->type) { case(goTime_none): str_copyChar(out, '-'); break; case(goTime_absolute): goTime_str(tLeft, out); break; case(goTime_canadian): goTime_str(tLeft, out); str_catChar(out, '/'); if (timer->aux == 0) { str_catChar(out, '-'); } else { str_catInt(out, timer->aux); } break; case(goTime_japanese): goTime_str(tLeft, out); if (tLeft <= time->aux * time->by) { str_catChar(out, '('); if (tLeft < 0) str_catChar(out, '0'); else str_catInt(out, (tLeft + time->by - 1) / time->by); str_catChar(out, ')'); } break; case(goTime_ing): goTime_str(tLeft, out); if (timer->aux > 0) { str_catChar(out, '+'); str_catInt(out, timer->aux); } break; default: assert(0); break; } } void goTimer_init(GoTimer *timer, const GoTime *time) { timer->timeLeft = time->main; if (time->type == goTime_ing) timer->aux = time->aux; else timer->aux = 0; timer->usLeft = 0; } void goTime_startTimer(const GoTime *time, GoTimer *timer) { struct timezone tzone; gettimeofday(&timer->startTime, &tzone); } /* * goTime_checkTimer() returns FALSE if you are out of time. * Call it whenever you want the clock to be updated. Every second is nice. */ bool goTime_checkTimer(const GoTime *time, GoTimer *timer) { struct timeval now; struct timezone tzone; gettimeofday(&now, &tzone); timer->usLeft -= (now.tv_usec - timer->startTime.tv_usec); while (timer->usLeft <= 0) { timer->usLeft += 1000000; --timer->timeLeft; } timer->timeLeft -= (now.tv_sec - timer->startTime.tv_sec); timer->startTime = now; if (timer->timeLeft < 0) { switch(time->type) { case goTime_none: timer->timeLeft = 1; break; case goTime_absolute: case goTime_japanese: timer->timeLeft = -1; timer->usLeft = 1000000; break; case goTime_canadian: if (timer->aux == 0) { timer->aux = time->aux; timer->timeLeft += time->by; if (timer->timeLeft < 0) { timer->timeLeft = -1; timer->usLeft = 1000000; } } else { timer->timeLeft = -1; timer->usLeft = 1000000; } break; case goTime_ing: while ((timer->timeLeft < 0) && (timer->aux > 0)) { timer->timeLeft += time->by; --timer->aux; } if ((timer->timeLeft < 0) && (timer->aux == 0)) { timer->timeLeft = -1; timer->usLeft = 1000000; } break; default: assert(0); break; } } return(timer->timeLeft >= 0); } bool goTime_endTimer(const GoTime *time, GoTimer *timer) { bool result; int left; result = goTime_checkTimer(time, timer); if (time->type == goTime_japanese) { left = timer->timeLeft; if (timer->usLeft) ++left; if ((left > 0) && (left <= time->aux * time->by)) { left = (left + time->by - 1); timer->timeLeft = left - (left % time->by); timer->usLeft = 0; } } else if (time->type == goTime_canadian) { if (timer->aux) { --timer->aux; if (timer->aux == 0) { timer->aux = time->aux; timer->timeLeft = time->by; timer->usLeft = 0; } } } return(result); } int goTime_ingPenalty(const GoTime *time, const GoTimer *timer) { if (time->type == goTime_ing) return(2 * (time->aux - timer->aux)); else return(0); } cgoban-1.9.14/src/goban.c0000664000671000067100000006457407437322513010573 /* * $Source: /cvsroot/cgoban1/cgoban1/src/goban.c,v $ * $Revision: 1.2 $ * $Date: 2002/02/28 03:34:35 $ * * src/goban.c, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cgoban.h" #include "msg.h" #include "goGame.h" #include "cgbuts.h" #include "goPic.h" #ifdef _GOBAN_H_ #error Levelization Error. #endif #include "goban.h" /********************************************************************** * Forward references **********************************************************************/ static ButOut resize(ButWin *win); static ButOut iResize(ButWin *win); static ButOut destroy(ButWin *win); static ButOut msgBoxKilled(But *okBut); static void startMoveTimer(Goban *g); static void stopMoveTimer(Goban *g); static ButOut newTime(ButTimer *t); static ButOut dispatchGrid(void *packet, int loc); static ButOut dispatchQuit(But *but); static ButOut dispatchPass(But *but); static ButOut dispatchRew(But *but); static ButOut dispatchBack(But *but); static ButOut dispatchFwd(But *but); static ButOut dispatchFf(But *but); static ButOut dispatchDone(But *but); static ButOut dispatchDispute(But *but); static ButOut dispatchSave(But *but); static ButOut dispatchEdit(But *but); static ButOut dispatchInfo(But *but); static ButOut gotKibitz(But *but, const char *value); static ButOut newKibVal(But *but, int value); /********************************************************************** * Functions **********************************************************************/ /* * This is an ugly kludge. */ #define WIN_W(fontH, bw) \ (fontH*3+bw*2 + fontH*12+bw*5 + \ (fontH*2+bw)*12+fontH*2+bw*6) Goban *goban_create(Cgoban *cg, const GobanActions *actions,void *packet, GoGame *game, const char *clpName, const char *title) { static ButKey rewKeys[] = {{XK_Home, 0,0}, {0,0,0}}; static ButKey backKeys[] = {{XK_Left, 0,0}, {0,0,0}}; static ButKey fwdKeys[] = {{XK_Right, 0,0}, {0,0,0}}; static ButKey ffKeys[] = {{XK_End, 0,0}, {0,0,0}}; Goban *g; int winSize, i; GoStone s; GobanPlayerInfo *pi; Str clpStrs; bool err; uint butFlags; assert(MAGIC(cg)); g = wms_malloc(sizeof(Goban)); MAGIC_SET(g); g->cg = cg; g->actions = actions; g->packet = packet; g->propagateDestroy = TRUE; g->game = game; goTimer_init(&g->timers[goStone_black], &game->time); goTimer_init(&g->timers[goStone_white], &game->time); g->activeTimer = goStone_empty; g->ingTimePenalties[goStone_black] = g->ingTimePenalties[goStone_white] = 0; g->lastMove = 0; g->lastScores[goStone_black] = g->lastScores[goStone_white] = 0.0; str_init(&clpStrs); str_print(&clpStrs, "%s.bProp", clpName); g->bProp = clp_lookup(cg->clp, str_chars(&clpStrs)); str_print(&clpStrs, "%s.bPropW", clpName); g->bPropW = clp_lookup(cg->clp, str_chars(&clpStrs)); str_print(&clpStrs, "%s.x", clpName); g->clpX = clp_lookup(cg->clp, str_chars(&clpStrs)); str_print(&clpStrs, "%s.y", clpName); g->clpY = clp_lookup(cg->clp, str_chars(&clpStrs)); str_deinit(&clpStrs); winSize = WIN_W(cg->fontH, butEnv_stdBw(cg->env)); g->win = butWin_iCreate(g, cg->env, title, (int)(winSize * clpEntry_getDouble(g->bPropW) + 0.5), (int)(winSize * clpEntry_getDouble(g->bProp) + 0.5), &g->iWin, FALSE, 64,64, NULL, NULL, resize, iResize, destroy); i = clpEntry_iGetInt(g->clpX, &err); if (!err) { butWin_setX(g->win, i); } i = clpEntry_iGetInt(g->clpY, &err); if (!err) { butWin_setY(g->win, i); } butWin_setMinH(g->win, winSize); butWin_setMaxH(g->win, 0); butWin_setMinW(g->win, winSize / 2); butWin_setMaxW(g->win, 0); butWin_setWHRatios(g->win, 1, 1000, 1, 1); butWin_activate(g->win); g->bg = butBoxFilled_create(g->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(g->bg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); g->labelBox = butBoxFilled_create(g->win, 1, BUT_DRAWABLE); g->labelText = butText_create(g->win, 2, BUT_DRAWABLE, title, butText_center); butText_setFont(g->labelText, 2); g->infoText = butText_create(g->win, 2, BUT_DRAWABLE, "", butText_center); if (actions->gameInfoPressed) butFlags = BUT_DRAWABLE | BUT_PRESSABLE; else butFlags = BUT_DRAWABLE; g->gameInfo = butCt_create(dispatchInfo, g, g->win, 1, butFlags, msg_gameInfo); g->help = butCt_create(cgoban_createHelpWindow, actions->helpInfo, g->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_help); g->pass = butCt_create(dispatchPass, g, g->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_pass); if ((game->rules == goRules_japanese) || (game->rules == goRules_tibetan)) g->resume = butCt_create(dispatchDispute, g, g->win, 1, BUT_DRAWABLE, msg_dispute); else g->resume = butCt_create(dispatchBack, g, g->win, 1, BUT_DRAWABLE, msg_resume); g->done = butCt_create(dispatchDone, g, g->win, 1, BUT_DRAWABLE, msg_done); g->rew = butAct_create(dispatchRew, g, g->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, CGBUTS_REWCHAR, BUT_RLEFT|BUT_SRIGHT); but_setKeys(g->rew, rewKeys); g->back = butAct_create(dispatchBack, g, g->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, CGBUTS_BACKCHAR, BUT_SLEFT|BUT_SRIGHT); but_setKeys(g->back, backKeys); g->fwd = butAct_create(dispatchFwd, g, g->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, CGBUTS_FWDCHAR, BUT_SLEFT|BUT_SRIGHT); but_setKeys(g->fwd, fwdKeys); g->ff = butAct_create(dispatchFf, g, g->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, CGBUTS_FFCHAR, BUT_SLEFT|BUT_RRIGHT); but_setKeys(g->ff, ffKeys); for (s = goStone_white; s <= goStone_black; ++s) { pi = &g->playerInfos[s]; pi->box = butBoxFilled_create(g->win, 1, BUT_DRAWABLE); for (i = 0; i < 5; ++i) { assert(i < CGBUTS_NUMWHITE); pi->stones[i] = grid_create(&g->cg->cgbuts, NULL, NULL, g->win, 2, BUT_DRAWABLE, 0); grid_setStone(pi->stones[i], s, FALSE); grid_setLineGroup(pi->stones[i], gridLines_none); grid_setVersion(pi->stones[i], i); } pi->capsLabel = butText_create(g->win, 2, BUT_DRAWABLE, msg_score, butText_left); pi->capsOut = butText_create(g->win, 3, BUT_DRAWABLE, "0", butText_right); butText_setColor(pi->capsOut, CGBUTS_COLORREDLED, FALSE); pi->capsBox = butBoxFilled_create(g->win, 2, BUT_DRAWABLE); butBoxFilled_setColors(pi->capsBox, BUT_SHAD,BUT_LIT,BUT_FG); pi->timeLabel = butText_create(g->win, 2, BUT_DRAWABLE, msg_time, butText_left); pi->timeOut = butText_create(g->win, 3, BUT_DRAWABLE, "", butText_right); butText_setColor(pi->timeOut, CGBUTS_COLORREDLED, FALSE); pi->timeBox = butBoxFilled_create(g->win, 2, BUT_DRAWABLE); butBoxFilled_setColors(pi->timeBox, BUT_SHAD,BUT_LIT,BUT_FG); } if (actions->savePressed) butFlags = BUT_DRAWABLE | BUT_PRESSABLE; else butFlags = BUT_DRAWABLE; g->save = butCt_create(dispatchSave, g, g->win, 1, butFlags, msg_saveGame); if (actions->editPressed) butFlags = BUT_DRAWABLE | BUT_PRESSABLE; else butFlags = BUT_DRAWABLE; g->edit = butCt_create(dispatchEdit, g, g->win, 1, butFlags, msg_editGame); g->quit = butCt_create(dispatchQuit, g, g->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_close); g->comments = abutTerm_create(cg->abut, g->win, 1, TRUE); g->kibIn = NULL; g->newKib = NULL; g->boardBox = butPixmap_create(g->win, 1, BUT_DRAWABLE, cg->bgShadPixmap); butPixmap_setPic(g->boardBox, cg->bgShadPixmap, cg->fontH + butEnv_stdBw(cg->env) + cg->fontH / 2, cg->fontH + butEnv_stdBw(cg->env) + cg->fontH / 2); g->pic = goPic_create(cg, g, game, g->win, 2, dispatchGrid, goBoard_size(game->board)); g->iBg = butBoxFilled_create(g->iWin, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(g->iBg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); g->iBoard = gobanPic_create(&cg->cgbuts, g->iWin, 1, BUT_DRAWABLE); g->iDec1 = NULL; g->iDec2 = NULL; g->msgBox = NULL; g->clock = NULL; goban_update(g); return(g); } void goban_destroy(Goban *g, bool propagate) { assert(MAGIC(g)); goPic_destroy(g->pic); g->pic = NULL; g->propagateDestroy = propagate; butWin_destroy(g->win); } static ButOut resize(ButWin *win) { Goban *g = butWin_packet(win); Cgoban *cg; int butX,butY, butW,butH, butSpc, boxH, x, w; int bigStoneW; int winW, winH, boardW; int bw; int i, boardXPic, boardYPic; GoStone s; GobanPlayerInfo *pi; int fontH; assert(MAGIC(g)); cg = g->cg; assert(MAGIC(cg)); bw = butEnv_stdBw(cg->env); winW = butWin_w(win); winH = butWin_h(win); fontH = cg->fontH; butW = fontH * 10 + bw*4; boardW = winW - butW - fontH*3 - bw*2; clpEntry_setDouble(g->bProp, (double)winH / (double)butWin_getMinH(win)); clpEntry_setDouble(g->bPropW, (double)winW / (double)butWin_getMinW(win)/2.0); butH = fontH * 2; butSpc = fontH * 2 + bw; butY = fontH*2 + bw + butH + butSpc; bigStoneW = fontH; boxH = butSpc*3 + bw*3; boardXPic = fontH + bw; boardYPic = butY; butX = boardXPic + boardW + fontH; but_resize(g->bg, 0,0, winW,butWin_h(win)); but_resize(g->labelBox, boardXPic,bw + fontH, boardW,butH+butSpc); but_resize(g->labelText, bw*2 + fontH,bw*2 + fontH, boardW-bw*2,(butH+butSpc-bw*2)/2); but_resize(g->infoText, bw*2 + fontH, bw*2 + fontH+(butH+butSpc-bw*2)/2, boardW-bw*2,(butH+butSpc-bw*2)/2); but_resize(g->gameInfo, butX, fontH + bw, butW,butH); but_resize(g->help, butX, fontH + bw + butSpc, butW,butH); but_resize(g->pass, butX,butY, butW,butH); but_resize(g->resume, butX,butY+butSpc, butW,butH); but_resize(g->done, butX,butY+2*butSpc, butW,butH); x = butX; w = butW/4; but_resize(g->rew, x,butY+3*butSpc, w,butH); x += w; w = butW/2 - w; but_resize(g->back, x,butY+3*butSpc, w,butH); x += w; w = butW - (w + butW/2); but_resize(g->fwd, x,butY+3*butSpc, w,butH); x += w; but_resize(g->ff, x,butY+3*butSpc, butW/4,butH); butY += 4*butSpc + fontH; x = butEnv_textWidth(win->env, msg_time, 0); w = butEnv_textWidth(win->env, msg_score, 0); if (x < w) x = w; w = butW - x - 5*bw; x += butX + bw*3; for (s = goStone_white; s <= goStone_black; ++s) { pi = &g->playerInfos[s]; but_resize(pi->box, butX,butY, butW,boxH); for (i = 0; i < 5; ++i) but_resize(pi->stones[i], butX+bw*2+bigStoneW*2*i + fontH/2, butY+bw*2 + fontH/2, fontH, fontH); butText_resize(pi->capsLabel, butX+bw*2,butY+butSpc+bw*2, butH); but_resize(pi->capsOut, x+bw*2,butY+bw*3+butSpc, w-bw*4,butH-bw*2); but_resize(pi->capsBox, x,butY+bw*2+butSpc, w,butH); butText_resize(pi->timeLabel, butX+bw*2,butY+butSpc*2+bw*2, butH); but_resize(pi->timeOut, x+bw*2,butY+butSpc*2+bw*3, w-bw*4,butH-bw*2); but_resize(pi->timeBox, x,butY+butSpc*2+bw*2, w,butH); butY += boxH+bw; } butY += fontH - bw; but_resize(g->save, butX,butY , butW,butH); but_resize(g->edit, butX,butY+butSpc , butW,butH); but_resize(g->quit, butX,butY+butSpc*2, butW,butH); butY += butSpc*3 + fontH - bw; if (butY < boardYPic + boardW + fontH) butY = boardYPic + boardW + fontH; if (g->kibIn == NULL) { abutTerm_resize(g->comments, fontH+bw,butY, winW - bw*2 - fontH*2, winH - butY - fontH - bw); } else { abutTerm_resize(g->comments, fontH+bw,butY, winW - bw*2 - fontH*2, winH - butY - fontH*3 - bw); but_resize(g->kibIn, fontH+bw, winH - fontH * 3 - bw, winW - bw*2 - fontH*2 - butW, fontH * 2); but_resize(g->kibType, butX, winH - fontH * 3 - bw, butW, fontH * 2); but_resize(g->kibSay, butX, winH - fontH * 3 - bw, (butW + 1) / 3, fontH * 2); but_resize(g->kibBoth, butX + (butW + 1) / 3, winH - fontH * 3 - bw, butW - ((butW + 1) / 3) * 2, fontH * 2); but_resize(g->kibKib, butX + butW - (butW + 1) / 3, winH - fontH * 3 - bw, (butW + 1) / 3, fontH * 2); } but_resize(g->boardBox, boardXPic + fontH/2,boardYPic + fontH/2, boardW,boardW); goPic_resize(g->pic, boardXPic,boardYPic, boardW,boardW); return(0); } static ButOut iResize(ButWin *win) { Goban *g = butWin_packet(win); int bw = butEnv_stdBw(win->env); int w = butWin_w(win), h = butWin_h(win); assert(MAGIC(g)); but_resize(g->iBg, 0,0, butWin_w(win),butWin_h(win)); but_resize(g->iBoard, bw*2,bw*2, butWin_w(win)-bw*4,butWin_h(win)-bw*4); if (g->iDec1 && !g->iDec2) { but_resize(g->iDec1, (w * 1 + 2) / 5, (h + 4) / 10, (w * 3 + 2) / 5, (w * 3 + 2) / 5); } else if (g->iDec1 && g->iDec2) { but_resize(g->iDec1, bw*2, (h + 4) / 10, (w + 1) / 3, (w + 1) / 3); but_resize(g->iDec2, w - bw*2 - (w + 1) / 3, (h + 4) / 10, (w + 1) / 3, (w + 1) / 3); } return(0); } static ButOut destroy(ButWin *win) { Goban *g = butWin_packet(win); const GobanActions *actions; void *packet; bool propagate; assert(MAGIC(g)); propagate = g->propagateDestroy; actions = g->actions; packet = g->packet; g->win = NULL; /* It's dead already. */ clpEntry_setInt(g->clpX, butWin_x(win)); clpEntry_setInt(g->clpY, butWin_y(win)); if (g->pic) goPic_destroy(g->pic); if (g->msgBox) abutMsg_destroy(g->msgBox, FALSE); MAGIC_UNSET(g); wms_free(g); if (propagate) { actions->destroyCallback(packet); } return(0); } void goban_update(Goban *g) { Str newText; char newScore[40], locDesc[5]; const char *statusStr; GoStone color; float score; uint defaultPassFlags; assert(MAGIC(g)); str_init(&newText); if (g->game->state > goGameState_dispute) { goScore_compute(&g->score, g->game); } else { goScore_zero(&g->score); } goPic_update(g->pic); goban_updateTimeReadouts(g); goStoneIter(color) { if (g->game->state <= goGameState_dispute) { score = goGame_caps(g->game, color) - g->ingTimePenalties[color]; if (color == goStone_white) score += g->game->komi; } else { score = g->score.scores[color]; } if (score != g->lastScores[color]) { g->lastScores[color] = score; sprintf(newScore, "%g", score); butText_set(g->playerInfos[color].capsOut, newScore); } } if ((g->pic->allowedMoves & goPicMove_noPass) || ((g->game->whoseMove == goStone_white) && (g->pic->allowedMoves & goPicMove_noWhite)) || ((g->game->whoseMove == goStone_black) && (g->pic->allowedMoves & goPicMove_noBlack))) defaultPassFlags = BUT_NOPRESS; else defaultPassFlags = BUT_PRESSABLE; switch(g->game->state) { case goGameState_play: switch(g->game->moveNum) { case 0: str_copyChars(&newText, msg_gameStartDesc); break; case 1: goBoard_loc2Str(g->game->board, g->game->moves[0].move, locDesc); if (g->game->maxMoves == 1) { str_print(&newText, msg_move1Desc, (int)goStone_char(goGame_whoseTurnOnMove(g->game, 0)), locDesc); } else { str_print(&newText, msg_move1OfDesc, (int)goStone_char(goGame_whoseTurnOnMove(g->game, 0)), locDesc, g->game->maxMoves); } break; default: goBoard_loc2Str(g->game->board, g->game->moves[g->game->moveNum - 1].move, locDesc); if (g->game->maxMoves == g->game->moveNum) { str_print(&newText, msg_moveNDesc, g->game->moveNum, (int)goStone_char(goGame_whoseTurnOnMove(g->game, g->game->moveNum - 1)), locDesc); } else { str_print(&newText, msg_moveNOfDesc, g->game->moveNum, (int)goStone_char(goGame_whoseTurnOnMove(g->game, g->game->moveNum - 1)), locDesc, g->game->maxMoves); } break; } assert(goStone_isStone(goGame_whoseMove(g->game))); str_catChars(&newText, msg_stoneNames[goGame_whoseMove(g->game)]); str_catChars(&newText, msg_toPlay); butText_set(g->infoText, str_chars(&newText)); but_setFlags(g->pass, defaultPassFlags); but_setFlags(g->resume, BUT_NOPRESS); but_setFlags(g->done, BUT_NOPRESS); break; case goGameState_dispute: color = goGame_whoseMove(g->game); if (g->game->disputeAlive) statusStr = msg_alive; else statusStr = msg_dead; str_print(&newText, msg_disputeAnnounce, statusStr, msg_stoneNames[color]); butText_set(g->infoText, str_chars(&newText)); but_setFlags(g->pass, defaultPassFlags); but_setFlags(g->resume, BUT_NOPRESS); but_setFlags(g->done, BUT_NOPRESS); break; case goGameState_selectDead: butText_set(g->infoText, msg_selectDead); but_setFlags(g->pass, BUT_NOPRESS); if (g->actions->disputePressed) but_setFlags(g->resume, BUT_PRESSABLE); else but_setFlags(g->resume, BUT_NOPRESS); but_setFlags(g->done, BUT_PRESSABLE); break; case goGameState_selectDisputed: butText_set(g->infoText, msg_selectDisputed); but_setFlags(g->pass, BUT_NOPRESS); but_setFlags(g->resume, BUT_NOPRESS); but_setFlags(g->done, BUT_NOPRESS); break; case goGameState_done: if (!goTime_checkTimer(&g->game->time, &g->timers[g->game->whoseMove])) { str_print(&newText, msg_timeLossInfo, msg_stoneNames[g->game->whoseMove]); butText_set(g->infoText, str_chars(&newText)); } else if (g->lastScores[goStone_white] > g->lastScores[goStone_black]) butText_set(g->infoText, msg_whiteWon); else if ((g->lastScores[goStone_white] < g->lastScores[goStone_black]) || (g->game->rules == goRules_ing)) butText_set(g->infoText, msg_blackWon); else butText_set(g->infoText, msg_jigo); but_setFlags(g->pass, BUT_NOPRESS); but_setFlags(g->resume, BUT_NOPRESS); but_setFlags(g->done, BUT_NOPRESS); break; } if (g->actions->rewOk(g->packet)) but_setFlags(g->rew, BUT_PRESSABLE); else but_setFlags(g->rew, BUT_NOPRESS); if (g->actions->backOk(g->packet)) but_setFlags(g->back, BUT_PRESSABLE); else but_setFlags(g->back, BUT_NOPRESS); if (g->actions->fwdOk(g->packet)) { but_setFlags(g->fwd, BUT_PRESSABLE); } else { but_setFlags(g->fwd, BUT_NOPRESS); } if (g->actions->ffwdOk(g->packet)) { but_setFlags(g->ff, BUT_PRESSABLE); } else { but_setFlags(g->ff, BUT_NOPRESS); } str_deinit(&newText); } static ButOut msgBoxKilled(But *okBut) { Goban *g = but_packet(okBut); assert(MAGIC(g)); abutMsg_destroy(g->msgBox, FALSE); g->msgBox = NULL; return(0); } void goban_message(Goban *g, const char *str) { AbutMsgOpt ok; assert(MAGIC(g)); ok.name = msg_ok; ok.callback = msgBoxKilled; ok.packet = g; ok.keyEq = cg_return; if (g->msgBox) abutMsg_destroy(g->msgBox, FALSE); g->msgBox = abutMsg_optCreate(g->cg->abut, g->win, 4, str, NULL, NULL, 1, &ok); } void goban_noMessage(Goban *g) { if (g->msgBox) { abutMsg_destroy(g->msgBox, FALSE); g->msgBox = NULL; } } static void startMoveTimer(Goban *g) { struct timeval delay, period; /* * If we are in passive mode, then time does not go down. This is used * when editing SGF files, etc. */ if (!g->game->passive) { stopMoveTimer(g); delay.tv_sec = 0; delay.tv_usec = g->timers[g->activeTimer].usLeft + 100000; while (delay.tv_usec >= 1000000) delay.tv_usec -= 1000000; period.tv_sec = 1; period.tv_usec = 0; g->clock = butTimer_create(g, g->bg, delay, period, FALSE, newTime); } } static void stopMoveTimer(Goban *g) { if (g->clock) { butTimer_destroy(g->clock); g->clock = NULL; } } static ButOut newTime(ButTimer *t) { Goban *g = butTimer_packet(t); int newIngPenalty; assert(MAGIC(g)); goTime_checkTimer(&g->game->time, &g->timers[g->activeTimer]); newIngPenalty = goTime_ingPenalty(&g->game->time, &g->timers[g->activeTimer]); if (newIngPenalty == g->ingTimePenalties[g->activeTimer]) goban_updateTimeReadouts(g); else { g->ingTimePenalties[g->activeTimer] = newIngPenalty; goban_update(g); } return(0); } void goban_updateTimeReadouts(Goban *g) { GoStone color; Str newText; int tLeft; assert(MAGIC(g)); str_init(&newText); goStoneIter(color) { goTime_remainStr(&g->game->time, &g->timers[color], &newText); if (strcmp(str_chars(&newText), butText_get(g->playerInfos[color].timeOut))) { butText_set(g->playerInfos[color].timeOut, str_chars(&newText)); tLeft = g->timers[color].timeLeft; if ((g->cg->cgbuts.timeWarn > 0) && goTime_low(&g->game->time, &g->timers[color], g->cg->cgbuts.timeWarn) && ((tLeft & 1) == 0)) { butText_setColor(g->playerInfos[color].timeOut, BUT_BLACK, FALSE); butBoxFilled_setColors(g->playerInfos[color].timeBox, BUT_SHAD, BUT_LIT, BUT_WHITE); } else { butText_setColor(g->playerInfos[color].timeOut, CGBUTS_COLORREDLED, FALSE); butBoxFilled_setColors(g->playerInfos[color].timeBox, BUT_SHAD, BUT_LIT, BUT_BLACK); } } if (g->game->whoseMove != color) { butText_setColor(g->playerInfos[color].timeOut, CGBUTS_COLORREDLED, FALSE); butBoxFilled_setColors(g->playerInfos[color].timeBox, BUT_SHAD, BUT_LIT, BUT_BLACK); } } str_deinit(&newText); } static ButOut dispatchGrid(void *packet, int loc) { Goban *g = packet; GobanOut out; assert(MAGIC(g)); out = g->actions->gridPressed(g->packet, loc); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchQuit(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->quitPressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchPass(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->passPressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchRew(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->rewPressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchBack(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->backPressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchFwd(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->fwdPressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchFf(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->ffPressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchDone(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->donePressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchDispute(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->disputePressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchSave(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->savePressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchEdit(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->editPressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } static ButOut dispatchInfo(But *but) { Goban *g = but_packet(but); GobanOut out; assert(MAGIC(g)); out = g->actions->gameInfoPressed(g->packet); if (out == gobanOut_draw) goban_update(g); if (out == gobanOut_err) return(BUTOUT_ERR); else return(0); } void goban_setKibitz(Goban *g, GobanOut (*newKib)(void *packet, const char *txt), int kibVal) { uint kibFlags; assert(MAGIC(g)); if (kibVal == -1) { kibFlags = BUT_DRAWABLE; kibVal = 2; } else kibFlags = BUT_PRESSABLE|BUT_DRAWABLE; butTbin_setMaxLines(g->comments->tbin, 100); butTbin_setReadOnly(g->comments->tbin, TRUE); butPlain_setColor(g->comments->bg, BUT_BG); g->kibIn = butTextin_create(gotKibitz, g, g->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, "", 200); g->newKib = newKib; g->kibType = butRadio_create(newKibVal, g, g->win, 1, kibFlags, kibVal, 3); g->kibSay = butText_create(g->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU, msg_say, butText_center); g->kibBoth = butText_create(g->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU, msg_both, butText_center); g->kibKib = butText_create(g->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU, msg_kib, butText_center); if (!(kibFlags & BUT_PRESSABLE)) { butText_setColor(g->kibSay, BUT_FG, TRUE); butText_setColor(g->kibBoth, BUT_FG, TRUE); } } static ButOut gotKibitz(But *but, const char *value) { Goban *g = but_packet(but); assert(MAGIC(g)); if (value[0] == '\0') { but_setFlags(g->kibIn, BUT_NOKEY); } else { g->newKib(g->packet, value); butTextin_set(g->kibIn, "", FALSE); } return(0); } static ButOut newKibVal(But *but, int value) { Goban *g = but_packet(but); assert(MAGIC(g)); clp_setInt(g->cg->clp, "client.saykib", value); return(0); } void goban_startTimer(Goban *g, GoStone whose) { goTime_startTimer(&g->game->time, &g->timers[whose]); g->activeTimer = whose; startMoveTimer(g); } /* stopTimer returns TRUE if there is still time left. */ bool goban_stopTimer(Goban *g) { GoStone color = g->activeTimer; if (color == goStone_empty) { /* Timers were never started! */ return(TRUE); } assert(goStone_isStone(color)); stopMoveTimer(g); g->activeTimer = goStone_empty; return(goTime_endTimer(&g->game->time, &g->timers[color])); } cgoban-1.9.14/src/help.c0000664000671000067100000025363107577707436010447 /* * src/help.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include "cgbuts.h" #ifdef _HELP_H_ LEVELIZATION ERROR #endif #include "help.h" /* * Used by all help pages */ static const AbutHelpText aboutAuthor[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "About the authors"}, {butText_just, 0, " Bill Shubert learned go at a very young age, " "but never had any opponents until late 1993, when he learned of the" "Internet Go Server. He was thrilled by the server, but was " "disappointed by the client programs available. He was also " "disappointed by the quality of the smart go editing tools that " "he could find. Instead of just whining, he decided to create his own " "program to do these tasks! He called it \"Cgoban\", for Complete " "Goban, because it does everything that a computerized goban should."}, {butText_just, 0, " Bill began focusing on the Kiseido Go Server and " "the cgoban v2 client." }, {butText_just, 0, " Kevin Sonney learned Go from a friend in 1995." "Impressed with Bill's work, Kevin thought that there was still a lot " "of potential for cgoban v1. Kevintook over maintainership of cgoban1 " "In October 2002."}, {butText_just, 0, " You can always get the latest version of cgoban from " "it's Sourceforge project at http://cgoban1.sourceforge.net/ " "Comments and Suggestions can be sent through the contact information below"}, {butText_left, 0, " Maintainer Email: ksonney@redhat.com"}, {butText_left, 0, " WWW: http://cgoban1.sourceforge.net/"}, {butText_just, 0, ""}, {butText_just, 0, " Thanks for trying out our program. We hope you like " "it!"}, {butText_just, 0, " Special thanks to all cgoban testers, especially " "to Andries Brouwer, Tomas Boman, Jean-Louis Martineau, " "Eric Anderson, Dan Niles, Per-Eric Martin, Anthony Thyssen, " "Jan van der Steen, " "Eric Hoffman, Allen Tollin, Mel Melchner, Saito Takaaki, and " "Matt Ritchie, who either helped debug, wrote extra features, or " "otherwise hacked on the code to help make cgoban what it is."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText copyright[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert & Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 0, " The globe pictures were extracted from gifs created " "by xearth-1.0, which carries this copyright:"}, {butText_center, 0, "Copyright (C) 1989, 1990, 1993, 1994, 1995 Kirk Lauritz Johnson"}, {butText_center, 0, "Parts of the source code (as marked) are:"}, {butText_center, 0, "Copyright (C) 1989, 1990, 1991 by Jim Frost"}, {butText_center, 0, "Copyright (C) 1992 by Jamie Zawinski "}, {butText_center, 0, "Permission to use, copy, modify and freely distribute " "xearth for non-commercial and not-for-profit purposes is hereby granted " "without fee, provided that both the above copyright notice and " "this permission notice appear in all copies and in supporting " "documentation."}, {butText_just, 0, ""}, {butText_just, 2, "Distribution"}, {butText_just, 0, " All code except for the data described above is " "copyright \251 1995-2002 William Shubert and Kevin Sonney and is " "distributed under the Gnu General Public License, version 2. This " "should have been included with your copy of the source code is a " "file called \"COPYING\". In any case, the license is also included below."}, {butText_just, 0, " Basically, there are three things that most of you " "will care about in this license. One is that you can give away free " "copies to all your friends. Another is that you have to be told where " "you can get the source code from. You can get it from me; see the " "\"About the Author\" help page for how to get in touch. The last is " "that there is no warranty, so if this software ruins your life don't " "come crying to me."}, {butText_just, 0, " If you want to do anything else with this software, " "you should read the license below for details."}, {butText_just, 0, ""}, {butText_center, 0, "GNU GENERAL PUBLIC LICENSE"}, {butText_center, 0, "TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND " "MODIFICATION"}, {butText_just, 0, ""}, {butText_just, 0, " 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\"."}, {butText_just, 0, ""}, {butText_just, 0, "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."}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_just, 0, "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."}, {butText_just, 0, ""}, {butText_just, 0, " 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:"}, {butText_just, 0, ""}, {butText_just, 0, " a) You must cause the modified files to carry " "prominent notices stating that you changed the files and the date of " "any change."}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_just, 0, " 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.)"}, {butText_just, 0, ""}, {butText_just, 0, "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."}, {butText_just, 0, ""}, {butText_just, 0, "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."}, {butText_just, 0, ""}, {butText_just, 0, "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."}, {butText_just, 0, ""}, {butText_just, 0, " 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:"}, {butText_just, 0, ""}, {butText_just, 0, " 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,"}, {butText_just, 0, ""}, {butText_just, 0, " 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,"}, {butText_just, 0, ""}, {butText_just, 0, " 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.)"}, {butText_just, 0, ""}, {butText_just, 0, "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."}, {butText_just, 0, ""}, {butText_just, 0, "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."}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_just, 0, "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."}, {butText_just, 0, ""}, {butText_just, 0, "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."}, {butText_just, 0, ""}, {butText_just, 0, "This section is intended to make thoroughly clear what " "is believed to be a consequence of the rest of this License."}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_just, 0, "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."}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_center, 0, "NO WARRANTY"}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_just, 0, " 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."}, {butText_just, 0, ""}, {butText_center, 0, "END OF TERMS AND CONDITIONS"}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; /* * From control.c */ static const AbutHelpText ctrlHelp[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Control Panel"}, {butText_just, 0, " The control panel of cgoban is used to select one " "of Cgoban's features. The text on this help page will only briefly " "describe what feature each button activates. More detailed help " "on each of these features is available once the feature has been " "started."}, {butText_just, 0, ""}, {butText_just, 2, "Server Buttons"}, {butText_just, 0, " These two buttons are used to log in to the " "internet go servers. Clicking on a button will connect to the server " "named on that button. To access more than two servers, hold down shift " "and click on a server button; this will change the server that the " "button connects to."}, {butText_just, 0, ""}, {butText_just, 2, "\"New Game\" and \"Load Game\" Buttons"}, {butText_just, 0, " To start a new game of Go, click on the \"New Game\" " "button. Here two players can play against each other on a single " "go board."}, {butText_just, 0, " Pressing the \"Load Game\" button will let you " "continue a previously saved game of go. You can only use \"Load Game\" " "for games started with cgoban. If you want to load a smart go file " "that was created with a different program, then use the \"Edit SGF " "File\" button instead."}, {butText_just, 0, ""}, {butText_just, 2, "\"Edit SGF File\" Button"}, {butText_just, 0, " To edit a smart go file, use the \"Edit SGF File\" " "button. Using this button, you can review an sgf file or edit it, " "viewing and adding comments, annotations, and variations. The " "\"Edit SGF File\" button can not be used to create a new SGF file. " "To do that use the \"New Game\" button, then once the game has " "started use the \"Edit Game\" button on the go board to switch to " "SGF editing mode."}, {butText_just, 0, " To edit a file without going through the control " "window, you may start cgoban by typing \"cgoban -edit \"."}, {butText_just, 0, ""}, {butText_just, 2, "\"Go Modem\" Button"}, {butText_just, 0, " The Go Modem protocol is a standard protocol for " "playing go over a modem that was designed by Bruce Wilcox and others. " "It has also become a standard format for playing computer go " "tournaments. The \"Go Modem\" button can be used to connect cgoban to a " "computer program or a device that talks the go modem protocol. The \"Go " "Modem\" button can also be used to connect a go modem protocol program " "to one of the internet go servers."}, {butText_just, 0, ""}, {butText_just, 2, "\"Help\", \"Setup\", and \"Quit\" Buttons"}, {butText_just, 0, " Pressing \"Help\" brings up this window. Most " "Cgoban windows have help buttons. Pressing the help button on any " "window brings up help for that window."}, {butText_just, 0, " The \"Setup\" button will open the cgoban setup " "window. In this window you can configure cgoban, " "changing the address of the go servers, turning on and off certain " "features, etc."}, {butText_just, 0, " Pressing the \"Quit\" button will exit from Cgoban. " "Be careful! If you press \"Quit\", then all games in progress will " "end!"}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage ctrlPage[] = { {"Control Window", ctrlHelp}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_control = {4, "Control Help Pages", ctrlPage}; /* * From gameSetup.c */ static const AbutHelpText gameSetup[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Game Setup Window"}, {butText_just, 0, " This window allows you to set up a new game. At " "the top you may enter the names of the players. You have a choice of " "rule sets in the left pane of the window, and a choice of time controls " "in the right pane."}, {butText_just, 0, " The difference in rule sets and time controls is described in " "other help pages. To see these pages, use the menu at the top of this " "help window."}, {butText_just, 0, " Besides selecting the rule set and the time system, players can " "choose the handicap and the komi. \"Handicap\" is the number of " "stones that Black is given at the start of the game. Depending on " "the rule set, Black may be free to place these stones where they " "choose or may be forced to play them in certain locations. A handicap " "of zero will give Black no stones to begin the game."}, {butText_just, 0, " The komi is the number of points that White is given at the " "beginning of the game to make up for having to move second. Most " "rule sets say that a komi of 5.5 with a handicap of zero lead to a fair " "game (the extra half point prevents tie games). The Ing rules, " "however, say that a komi of 8.0 is fair. Often, a game with no " "handicap and a komi of zero is called a \"handicap 1\" game because " "the Black player gets the advantage of moving first and no penalty."}, {butText_just, 0, " When the game is configured the way you want, press the \"Ok\" " "button to start the game, or press the \"Cancel\" button if you decide " "not to start the game at all."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText ruleSets[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Rule Sets"}, {butText_just, 0, " Depending on where Go is played, the rules of the game can differ " "sligtly. Cgoban allows you to pick the rule set that you are most " "comfortable with. This help page is not a description of the rules of " "go; it is only meant to outline the differences between the rule sets."}, {butText_just, 0, " The biggest differences between the rule sets are typically the ko " "rule used and the way that the game is scored."}, {butText_just, 0, ""}, {butText_just, 2, "Chinese Rules"}, {butText_just, 0, " Chinese rules are played primarily on mainland China. Chinese " "rules use the Superko rule. The superko rule states that it is illegal " "to make a move which returns the board to an earlier position. A game " "played under Chinese rules ends when both players pass; at that point " "score is counted. The score of a player is the number of living stones " "that player has on the board, plus the amount of territory surrounded, " "plus one-half the number of dame points on the board. If there is a " "dispute over which stones are dead at the end of the game, the players " "can simply continue the game where they left off to resolve the " "problem."}, {butText_just, 0, " Chinese rules are considered by some people to be the most " "mathematically elegant version of the rules of go."}, {butText_just, 0, ""}, {butText_just, 2, "Japanese Rules"}, {butText_just, 0, " Japanese rules are played in Japan and also have strong followings " "in many other countries. The Japanese ko rule states that it is " "illegal to recreate the board position of exactly two moves ago. " "There are certain board positions that can lead to cycles of more than " "two moves; if a game ever falls into one of these positions, the " "players repeat until they conclude that the game will never finish. " "At this point the game is regarded as \"no result\" (not as a draw). " "If this is a game in a tournament, it must be replayed."}, {butText_just, 0, " The score in a Japanese game is the total of the number of enemy " "stones captured and the amount of territory surrounded. Territory in " "a seki is not counted towards either player's score. If there is " "a dispute over which stones are dead at the end of the game, the " "fate of the disputed stones is resolved locally. Cgoban handles this " "by letting the players continue the game. When resolving the " "dispute, ko stones can never be retaken until a player passes, and " "after three passes the stones are considered dead only if all of them " "have been removed from the board. At this point the board is returned " "to the original end game position but with the disputed stones marked " "as alive or dead."}, {butText_just, 0, " Japanese rules state that suicide (making a move which kills your " "own stones) is illegal. Under some rare circumstances such a move may " "be useful, so most other rule sets allow it."}, {butText_just, 0, " Under some situations cgoban will not recognize a seki unless the " "dame are filled in. If there is a seki position on the board and " "you see that cgoban is mis-scoring it, continue the game and fill in " "the dame."}, {butText_just, 0, " Some people find the Japanese rules to be the most natural " "to play with. Most of Europe and North America plays with rule sets " "based on the Japanese rules."}, {butText_just, 0, ""}, {butText_just, 2, "Ing Rules"}, {butText_just, 0, " The Ing rules were invented by a wealthy Taiwanese Go player. They " "are encouraged through the Ing Foundation, which sponsors Go " "tournaments around the world. Unfortunately, the Ing Ko rule is very " "difficult (some say impossible) to implement on a computer, so the " "Ing rules of Cgoban are the same as Chinese rules except that the " "standard Komi is 8 and tie games are awarded to Black."}, {butText_just, 0, ""}, {butText_just, 2, "AGA Rules"}, {butText_just, 0, " The American Go Association has a set of rules designed to feel " "like Japanese rules, but use the simpler end of game disputes of " "Chinese rules. AGA rules use Superko like Chinese rules, but count " "score as captures plus territory (although unlike Japanese rules, eyes " "in a seki count for points under AGA rules). In addition, every time " "that you pass under AGA rules you must give your opponent one capture. " "This change makes it reasonable to resolve disputed stones by " "continuing the game, as in Chinese rules."}, {butText_just, 0, ""}, {butText_just, 2, "New Zealand Rules"}, {butText_just, 0, " In New Zealand the go organization has adopted the Chinese rules, " "with the exception that handicap stones may be placed anywhere on the " "board instead of at the preselected star points. In every other way " "it is the same as Chinese rules."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText timeTypes[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Time Formats"}, {butText_just, 0, " Much like the rule sets, as Go has travelled around the world many " "different ways of timing games have been used. Cgoban makes available " "many of the more popular. To select a time control, first choose the " "type of time control with the \"Time System\" menu, then fill in the " "appropriate time values."}, {butText_just, 0, ""}, {butText_just, 2, "None"}, {butText_just, 0, " If you select \"None\" as your time system, then the players may " "take as long as they wish to make their moves."}, {butText_just, 0, ""}, {butText_just, 2, "Absolute Time"}, {butText_just, 0, " With the \"Absolute\" time system, you simply set a main time for " "the players. Each player must finish the game within the time " "specified. If the player runs out of time, then the player loses."}, {butText_just, 0, ""}, {butText_just, 2, "Japanese Time"}, {butText_just, 0, " In Japan one of the common tournament time systems involves a " "main time and what are called \"byo-yomi\" periods. The easiest way " "to explain this is with an example. If you play with 45 minutes main " "time and five one-minute byo-yomi periods, then each player starts with " "45 minutes on the clock. Play goes as with an absolute time limit, but " "when a player's clock drops below the five minute mark the enter the " "first byo-yomi period. As long as they finish before their clock drops " "below the four minute mark, it will be reset to five minutes. From " "then on, they can play as many moves as they want, but if they take " "more than a minute on any move their clock moves to the second byo-yomi " "period, which is from four to three minutes. If they ever use up their " "last byo-yomi period, then they lose the game."}, {butText_just, 0, " This scheme gives players lots of time to think until they have " "used up their main time, then forces them to keep moving with only a " "few opportunities to think for long after that."}, {butText_just, 0, ""}, {butText_just, 2, "Canadian Time"}, {butText_just, 0, " The canadian time system is also used on the internet go servers. " "It also has a main time period and what are called byo-yomi periods, " "but the byo-yomi periods work differently. Again, an example will " "be a good way to show how this works. If you have a 30 minute main " "time period and byo-yomi periods of 25 moves in ten minutes, then each " "player starts with 30 minutes on their clock. After that time is gone, " "their clock is reset to ten minutes. They must make 25 moves in that " "ten minutes or lose. If they make 25 moves, then no matter how much " "time is left on their clock it is reset to ten minutes again and they " "must make another 25 moves in that ten minutes. This can continue " "indefinitely."}, {butText_just, 0, ""}, {butText_just, 2, "Ing Time"}, {butText_just, 0, " Like the Ing rules, the Ing time controls are encouraged by the " "Ing foundation. Under Ing rules, players are given main time and " "extra time periods, but the players are penalized tw, points for " "entering each extra time periods."}, {butText_just, 0, " If players have 45 minutes and three 15 minute periods, a player who " "used 55 minutes to make their moves will lose two points. A player who " "used 80 minutes will lose six points, and a player who used only 40 " "minutes will lose no points."}, {butText_just, 0, ""}, {butText_just, 0, NULL}}; static const AbutHelpPage gameSetupPage[] = { {"Game Setup Window", gameSetup}, {"Rule Sets", ruleSets}, {"Time Controls", timeTypes}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_gameSetup = {6, "Game Setup Help Pages", gameSetupPage}; static const AbutHelpText editToolHelp[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "About Smart Go Files"}, {butText_just, 0, " Smart go files can contain a game complete with many different " "types of annotation. A game may contain marks on the board that " "become visible as the game is viewed, it make contain comments about " "the game as it progresses, and it may also contain variations."}, {butText_just, 0, " The variations of a smart go file make it into what can be called a " "move tree. The starting position (typically an empty board) is at the " "start of the move tree. From each move in the game, you may progress " "to the next move. When there is a variation, there may be several " "different moves to go to. Typically one move will be the move actually " "made during game play, and the other moves show what would have " "happened if the players had made different choices."}, {butText_just, 0, " As you are viewing a game, the \"active move list\" is the set of " "moves that you will see if you step through the game. You may choose " "which moves are active with the game map (see below). The active moves " "are also the moves that will be affected by the cut and reorder " "buttons."}, {butText_just, 0, ""}, {butText_just, 2, "The Edit Tool Window"}, {butText_just, 0, " The edit tool window of cgoban is used to edit a smart go file. " "It contains three parts; the tool selector, the cut/reorder buttons, " "and the game map."}, {butText_just, 0, ""}, {butText_just, 2, "The Tool Selector"}, {butText_just, 0, " The tool selector is the line of buttons on the top of the edit tool " "window. Click on a button to make that the active tool. The effects " "of the current tool are listed just below the tool selector. A " "complete description of each tool is available through the menu at the " "top of this help window."}, {butText_just, 0, ""}, {butText_just, 2, "The Delete Moves Button"}, {butText_just, 0, " Pressing \"Delete Moves\" will remove all of the active moves below " "your current move. Be careful! There is currently no way to undo if " "you accidentally delete some moves"}, {butText_just, 0, ""}, {butText_just, 2, "The Reorder Moves Button"}, {butText_just, 0, " Pressing \"Reorder Moves\" is useful when you have several " "variations to your current move. Pressing this button will change " "the order in which the variations appear."}, {butText_just, 0, ""}, {butText_just, 2, "The Game Map"}, {butText_just, 0, " The game map shows the same game that is being viewed on the " "board, but it shows the game as a list of moves instead of showing " "the current board position. For a game with no variations, this list " "will be a simple line of stones. For a game with many variations, " "however, the game map can be invaluable in finding interesting " "variations and keeping your place within the game."}, {butText_just, 0, " The active move list is shown as a set of moves along a line. " "variation that are not active (that is, variations that you will not " "see by just stepping through the move list) are shown in grey. You " "may skip to a new move by clicking on the mark that corresponds to " "that move. If you click on a non-active move, then the active move " "list will change to the move list that contains the move you clicked " "on. The move that you see on the board is always shown with a box " "around it."}, {butText_just, 0, " On the game map, the starting board position is in the upper-left " "of the map. Each game move is to the right of the previous move. " "When there are several moves that are variations from a single board " "position, these will be seen as a \"fork\" in the game with each " "possible variation as a separate move chain."}, {butText_just, 0, " Different types of moves are represented by different symbols " "on the game map. Simple moves are shown as a black or white stone. " "If there is some sort of comment or annotation to the move, a " "triangle move is placed on the stone; otherwise the stone is labeled " "with its move number."}, {butText_just, 0, " Moves that are not strictly game moves, but instead modifications " "to the board, are represented by groups of four stones on the map. " "An empty spot on a move chain means that there is no move information " "here."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText moveTool[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Move Tool"}, {butText_just, 0, " The \"Move Tool\" is represented on the tool selector as a plain " "stone. The color of the stone shows whose move it is. By clicking on " "the stone you may set whose turn it is to move."}, {butText_just, 0, " When you click on the board with the move tool, you will add moves " "to the game that you are viewing. These moves will be added to the " "game as variations off of the current move if there is already a move " "off of the current move."}, {butText_just, 0, " Holding down the shift key when you use the move tool will not add " "stones to the board. Instead it will make the current move change to " "the point when a specific move was made. For example, to see the " "board when a move was made at location C16, hold down shift and click " "on the board at location C16."}, {butText_just, 0, " Clicking on the move tool when it is already active will change " "whose move it is."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText editToolKey[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Edit Tool Keyboard Shortcuts"}, {butText_just, 0, " Shift-up changes the active move list to the previous variation."}, {butText_just, 0, " Shift-down changes the active move list to the next variation."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText changeTool[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Change Board Tool"}, {butText_just, 0, " The \"Change Board Tool\" is represented on the tool selector as a " "group of four stones. This tool lets you rearrange a lot of stones " "with a single move; it is useful for setting up board positions and " "erasing groups of stones."}, {butText_just, 0, " Clicking on the board with this tool will erase a stone where you " "click, or add a stone if there isn't a stone there. The added stone " "will be white. To add a black stone, hold down the shift key when you " "click."}, {butText_just, 0, " Pressing \"Pass\" when the change board tool is selected will make " "all new board changes become part of a new board. This lets you create " "a sequence of moves, each rearranging the board however you wish."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText scoreTool[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Score Tool"}, {butText_just, 0, " The \"Score Tool\" is represented on the tool selector as a yin-yang " "symbol. This tallies up the current score of the game and adds marks " "to show who own what territory."}, {butText_just, 0, " When you select this tool, all territory completely surrounded by " "one player will be marked as that player's territory. Now clicking " "on stones will mark them as dead. To unmark some dead stones, click " "on them again."}, {butText_just, 0, " When you are satisfied with which stones are dead and alive, press " "the \"Done\" button next to the board. This will add a comment to " "the game record stating the score. To stop scoring and remove all " "marks, select a different tool."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText markTools[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Marking Tools Tool"}, {butText_just, 0, " The marking tools are represented on the tool selector as stones " "marked with a triangle, circle, or square. All three of these tools " "behaves in the same way; only the mark added is different."}, {butText_just, 0, " When one of the three marking tools is selected and you click on " "the board, the appropriate mark will be added. Holding down shift " "when you click will mark a group of stones."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText labelTools[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Label Tools"}, {butText_just, 0, " The label tools are represented on the tool selector as a stones " "with a letter or number on them. The letter label tool and the " "number label tool behave in very similar ways."}, {butText_just, 0, " When you click on the board with a label tool, the appropriate " "type of label (a letter or a number) is added. The labels will start " "at \"A\" or \"1\" and count up for each label that you add. Holding " "down shift when you click with the numbering tool will add the move " "number of that stone instead of starting at one."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage editToolPage[] = { {"Edit Tool Window", editToolHelp}, {"Keyboard Shortcuts", editToolKey}, {"Move Tool", moveTool}, {"Change Board Tool", changeTool}, {"Score Tool", scoreTool}, {"Marking Tools", markTools}, {"Label Tools", labelTools}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_editTool = {10, "Edit Tool Help Pages", editToolPage}; /* * From client/main.c */ static const AbutHelpText cliMain[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Client Main Window"}, {butText_just, 0, " When cgoban is connected to one of the servers, the client main " "window is the central area for information. There is a log in " "the middle of this window which shows the output from the server. " "Above the log are two buttons that open other windows; see the " "\"Client Game List Window\" and \"Client Player List Window\" help " "pages in the menu at the top of this help page. Below the log " "are a text input box, the help button and the \"Quit\" button. The " "\"Quit\" button will disconnect you from the server."}, {butText_just, 0, " Any commands that you want to send to the server should be typed " "in the text input box below the log. If you need help on server " "commands, type the \"Help\" command here. These help pages only give " "help for this client, not for the servers themselves."}, {butText_just, 0, " Some server commands won\'t work with this client if you try to " "enter them directly. For example, the \"who\" command should not be " "used because its output will be caught by the client and not shown; if " "you want a list of players, open the \"Player List\" window. Other " "commands that will not work correctly are the \"games\" and \"observe\" " "commands. Other commands may not be needed because their " "functionality is already present in the client, but they will work " "if you want to use them."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText cliGames[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Client Game List Window"}, {butText_just, 0, " The game list window presents a list of all games in progress on " "the server. The list will be automatically kept up to date as games " "start and end."}, {butText_just, 0, " Each line of the list is one game. From left to right, the columns " "of the list are the game number, the name and rank of the white " "player, the name and rank of the black player, the size of the board " "used, the number of handicap stones given to black, the komi points " "given to white, the game flags, and the number of players observing the " "game."}, {butText_just, 0, " When a game ends, the game number will be replaced " "with a hyphen and the \"Flags\" and \"Observers\" columns will be " "replaced with the result of the game. This will remain until another " "game is started in that game slot or until the \"*\" button is pressed " "(see below)."}, {butText_just, 0, " If you can't see all of the columns, then resize the window to be " "bigger. For a description of exactly what the column means, see " "the server's help file on the \"games\" command."}, {butText_just, 0, " To observe a game in progress, click on the game in the list."}, {butText_just, 0, " Not all of these fields will be kept up to date. To refresh the " "window at any time press the \"*\" button in the upper left corner of " "the list. This will also clear out all old game results for games " "that have ended."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText cliPlayers[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Client Player List Window"}, {butText_just, 0, " The player list window is a list of all players currently logged in " "to the server. As players come and go they will appear and disappear " "on this list."}, {butText_just, 0, " Each line of the list is one player. From left to right, the " "column of the list are the player\'s name, the player\'s rank, the " "player\'s state, how long the player has been idle, and the game number " "that the player is currently observing or playing in."}, {butText_just, 0, " The state is one of four options: \"!\" means that the player is " "actively looking for games, \"O\" means that the player is open to " "playing, \"X\" means that the player is not available for games, and " "\"?\" means that the client does not know what state the player is in"}, {butText_just, 0, " The list is sorted. You have three choices on how to sort the list; " "pick one by clicking on the buttons at the top of the player list. " "Clicking on \"Name\" will sort the list alphabetically by name. " "Clicking on \"Rank\" will sort the list by rank, strongest players " "to weakest players. Clicking on \"State\" will sort the list by " "state, with the players looking for games at the top and players " "not interested in games at the bottom."}, {butText_just, 0, " If you click on a player\'s name, the complete status of that " "player will be fetched from the server and displayed in the log in " "the main window."}, {butText_just, 0, " If the player is available for games, then you can click on the " "player's state to open up a \"Server Game Setup\" window. Use this " "window to set up games against the other players on the server."}, {butText_just, 0, " As new players arrive, they are placed at the bottom of the list. " "To update the list and re-sort it, press the \"*\" button in the upper " "left corner of the list."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage cliMainPage[] = { {"Main Client Window", cliMain}, {"Game List Window", cliGames}, {"Player List Window", cliPlayers}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_cliMain = {6, "Client Help Pages", cliMainPage}; /* From "client/match.c" */ static const AbutHelpText cliMatch[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Server Game Setup Window"}, {butText_just, 0, " The server game setup window is used to set up games against other " "people on the server. To use this, first you set up the game " "parameters as you wish, then when you are ready you click on the " "\"OK\" button. This will send the match request to the other player. " "When they send you a matching request, the game will begin!"}, {butText_just, 0, " At the top are the names of the players (you and your opponent). " "To change who plays black and who white, press the \"Switch\" button."}, {butText_just, 0, " Below this are places where you can choose the rules of the game - " "the size, handicap, etc. Most of these should be self-explanatory if " "you are familiar with playing go on the servers. If you have any " "questions, then you may want to try the online help files from the " "server. Typing \"help match\", \"help komi\", etc. on the server " "command line should give you the help that you need."}, {butText_just, 0, " The \"Free Game\" button will determine whether the game counts " "towards your rank. Usually you want this to happen, but if you want " "to just experiment during a game or play casually, then check this " "box."}, {butText_just, 0, " Click \"Cancel\" if you decide that you don't want to play the game " "at all. This will take away the window."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage cliMatchPage[] = { {"Server Game Setup Window", cliMatch}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_cliMatch = {4, "Client Help Pages", cliMatchPage}; /* From "editBoard.c" */ static const AbutHelpText editBoard[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Edit Board Window"}, {butText_just, 0, " When editing a smart-go file, the current board position is " "displayed in the edit board window. Around the edit board window are " "various buttons and controls."}, {butText_just, 0, ""}, {butText_just, 2, "The Title Box"}, {butText_just, 0, " At the top left of the window is the title box. This shows the " "name of the game in bold, and below that which moves are currently " "visible on the board."}, {butText_just, 0, ""}, {butText_just, 2, "The Board"}, {butText_just, 0, " Just below the title box is the board. Clicking on a point on " "the board will have different effects depending on which edit tool " "you are using; press \"Help\" in the edit tool window for more " "infomation. With the most common tool, the \"Move Tool\", clicking " "on the board will add a variation. Holding down shift when you " "click on the board will change your move number to see when a " "particular move was made."}, {butText_just, 0, ""}, {butText_just, 2, "The \""CGBUTS_REWCHAR"\", \""CGBUTS_BACKCHAR"\", " "\""CGBUTS_FWDCHAR"\", and \""CGBUTS_FFCHAR"\" Buttons"}, {butText_just, 0, " Pressing these buttons will change the current move number that " "you can see on the board. "CGBUTS_BACKCHAR" and "CGBUTS_FWDCHAR" " "will go one move at a time. "CGBUTS_REWCHAR" moves you to the " "beginning of the game, and "CGBUTS_FFCHAR" moves you to the end."}, {butText_just, 0, ""}, {butText_just, 2, "The Score Boxes"}, {butText_just, 0, " To the right of the board are the score boxes. There are two; one " "for white and one for black. In each box are shown the current score " "for that player and the amount of time remaining on that player's " "clock. The score is not the final score for that player, but the sum " "of the number of captures and the komi. To see the final score use " "the \"Score Tool\" in the edit tool window."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Save Game\" Button"}, {butText_just, 0, " Pressing \"Save Game\" will let you save the changes that you have " "made to the smart-go file."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Quit\" Button"}, {butText_just, 0, " Pressing the \"Quit\" button will close the edit board window and " "the edit tool window. If you have made any changes to the smart go " "file that you were viewing then you will be asked whether you want to " "save these changes before you exit."}, {butText_just, 0, ""}, {butText_just, 2, "The Comments Box"}, {butText_just, 0, " At the very bottom of the window is the comments box. Here you " "will see any comments that have been made about the move you are " "viewing. To edit or add the comments, click in the comments box " "and start typing. Some emacs-style control keys are available; " "see the \"Keyboard Shortcuts\" help page for a list of them."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText editBoardInfo[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Game Info Window"}, {butText_just, 0, " You open the game info window by pressing the " "\"Game Info\" button when you are viewing a smart go file."}, {butText_just, 0, " The game info window lets you view and edit the " "smart go game properties, such as player names, etc. To change " "the properties simply type in your new value then save the game. " "You should be warned that changing a property does not change the " "game itself, only the description of the game. For example, if you " "change the handicap then handicap stones will not be automatically " "added to the game; the game will be described as having the new " "handicap but to see this change you must add the stones yourself."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText editBoardKey[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Edit Board Keyboard Shortcuts"}, {butText_just, 0, " Left arrow: Go back one move."}, {butText_just, 0, " Right arrow: Go ahead one move."}, {butText_just, 0, " Shift-left arrow: Go back to the previous " "variation, comment, or annotation."}, {butText_just, 0, " Shift-right arrow: Go ahead to the next " "variation, comment, or annotation."}, {butText_just, 0, " Shift-up arrow: Change the main variation to " "the previous variation."}, {butText_just, 0, " Shift-down arrow: Change the main variation to " "the next variation."}, {butText_just, 0, ""}, {butText_just, 2, "Comment Editing"}, {butText_just, 0, " When you are editing a comment the left and right " "arrows will not change moves. Instead they will move the cursor. " "These other commands are available:"}, {butText_just, 0, " Ctrl-A: Move cursor to the beginning of the line."}, {butText_just, 0, " Ctrl-D: Delete to the right of the cursor"}, {butText_just, 0, " Ctrl-E: Move cursor to the end of the line."}, {butText_just, 0, " Ctrl-K: Delete to the end of the line."}, {butText_just, 0, " Ctrl-U: Delete from the beginning of the line."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage editBoardPage[] = { {"Edit Board Window", editBoard}, {"Game Info Window", editBoardInfo}, {"Keyboard Shortcuts", editBoardKey}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_editBoard = {6, "Edit Board Help Pages", editBoardPage}; /* From "local.c" */ static const AbutHelpText localBoard[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Game Board"}, {butText_just, 0, " When two players are playing go with Cgoban, the " "board is shown in a window with controls used in the game around it. " "To make a move, click on the board where you want your stone to go. " "The last stone played will have a circle marker on it; if the last " "move was a ko move, then the stone will have a square marker on it " "instead."}, {butText_just, 0, ""}, {butText_just, 2, "The Title Box"}, {butText_just, 0, " Just above the board is the title box. Here, the " "title of the game is shown along with the current move number and " "whose move it is."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Pass\" Button"}, {butText_just, 0, " Pressing \"Pass\" will pass your turn. The game will " "enter the scoring stage after both players pass."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Dispute\" Button"}, {butText_just, 0, " When you are playing with Japanese scoring, the " "button just below the pass button is the \"Dispute\" button. If " "the players disagree on whether a group of stones are alive or dead, " "they can resolve the disagreement by pressing \"Dispute\". After " "pressing dispute, the players select which group of stones are " "the problem. Then the game continues, with slightly different rules. " "When you are resolving disputes, kos cannot be retaken until a player " "passes and it takes three consecutive passes to end the dispute. After " "the three passes, the board is put back to the position it had before " "the dispute. If any of the disputed stones are still alive, then " "they are alive for scoring purposes; if they are all dead, then they " "are dead for scoring purposes."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Resume\" button"}, {butText_just, 0, " When you are not using Japanese rules, any dispute " "at the end of the game can be resolved by simply undoing the last two " "passes and continuing the game. Pressing \"Resume\" will let you do " "that."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Done\" button"}, {butText_just, 0, " When both players are done marking dead stones, " "pressing \"Done\" will finish it and record the score."}, {butText_just, 0, ""}, {butText_just, 2, "The \""CGBUTS_REWCHAR"\", \""CGBUTS_BACKCHAR"\", " "\""CGBUTS_FWDCHAR"\", and \""CGBUTS_FFCHAR"\" Buttons"}, {butText_just, 0, " Pressing these buttons will move forward and backward through the " "game, letting you undo and redo moves. "CGBUTS_BACKCHAR" and " CGBUTS_FWDCHAR" will go one move at a time. "CGBUTS_REWCHAR" moves " "you to the beginning of the game, and "CGBUTS_FFCHAR" moves you to the " "end."}, {butText_just, 0, ""}, {butText_just, 2, "The Score Boxes"}, {butText_just, 0, " To the right of the board are the score boxes. There are two; one " "for white and one for black. In each box are shown the current score " "for that player and the amount of time remaining on that player's " "clock. When you are playing the game, the score is not the final " "score for that player, but the sum of the number of captures and the " "komi. When you are selecting dead stones and after pressing the " "\"Done\" button, the score is the actual score for that player."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Save Game\" Button"}, {butText_just, 0, " Pressing \"Save Game\" will save the game as a smart go file. Later " "you can continue the game with the \"Load Game\" button of the control " "window. You can also choose \"Edit Game\" from the control panel to " "edit the game that you have saved. This is currently the only way to " "create a new smart go file since the \"Edit Game\" button doesn't " "work."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Edit Game\" Button"}, {butText_just, 0, " Pressing \"Edit Game\" will pop up a second game board with the " "game on it. This will be an edit game board, not a playing game " "board, and it will come with a edit tool set. This is used if you " "want to stop playing a game and want to use the editing tools to " "annotate your game."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Quit\" Button"}, {butText_just, 0, " Pressing \"Quit\" will end the game. If you want to continue the " "game later, you should choose \"Save Game\" before you quit."}, {butText_just, 0, ""}, {butText_just, 2, "The Comments Box"}, {butText_just, 0, " At the very bottom of the window is the comments box. Here you " "can make comments about the game that will be saved in the smart go " "file if you choose \"Save Game\" later. To edit or add the comments, " "click in the comments box and start typing. Some emacs-style control " "keys are available; see the \"Keyboard Shortcuts\" help page for a " "list of them."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText localKeys[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Playing Go Keyboard Shortcuts"}, {butText_just, 0, " Left arrow: Go back one move."}, {butText_just, 0, " Right arrow: Go ahead one move."}, {butText_just, 0, ""}, {butText_just, 2, "Comment Editing"}, {butText_just, 0, " When you are editing a comment the left and right " "arrows will not change moves. Instead they will move the cursor. " "These other commands are available:"}, {butText_just, 0, " Ctrl-A: Move cursor to the beginning of the line."}, {butText_just, 0, " Ctrl-D: Delete to the right of the cursor"}, {butText_just, 0, " Ctrl-E: Move cursor to the end of the line."}, {butText_just, 0, " Ctrl-K: Delete to the end of the line."}, {butText_just, 0, " Ctrl-U: Delete from the beginning of the line."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage localBoardPage[] = { {"Playing Go", localBoard}, {"Keyboard Shortcuts", localKeys}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_localBoard = {5, "Playing Go Help Pages", localBoardPage}; /* From "client/board.c" */ static const AbutHelpText cliBoardPage[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Game Board"}, {butText_just, 0, " When you play or observe a game on the server, the " "board is shown in a window with controls used in the game around it. " "To make a move, click on the board where you want your stone to go. " "The last stone played will have a circle marker on it; if the last " "move was a ko move, then the stone will have a square marker on it " "instead."}, {butText_just, 0, " You can also skip around in games or try out " "variations by holding down shift or control as you click on the board. " "See the \"Keyboard Shortcuts\" help page for more information on this."}, {butText_just, 0, ""}, {butText_just, 2, "The Title Box"}, {butText_just, 0, " Just above the board is the title box. Here, the " "title of the game is shown along with the current move number and " "whose move it is."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Pass\" Button"}, {butText_just, 0, " Pressing \"Pass\" will pass your turn. The game will " "enter the scoring stage after both players pass."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Done\" button"}, {butText_just, 0, " When you are done marking dead stones, " "pressing \"Done\" will finish it and record the score."}, {butText_just, 0, ""}, {butText_just, 2, "The \""CGBUTS_REWCHAR"\", \""CGBUTS_BACKCHAR"\", " "\""CGBUTS_FWDCHAR"\", and \""CGBUTS_FFCHAR"\" Buttons"}, {butText_just, 0, " Pressing these buttons will move forward and backward through the " "game to see what order the moves occurred in. They do not undo or " "redo moves; they only let you look back at previous moves. " CGBUTS_BACKCHAR" and " CGBUTS_FWDCHAR" will go one move at a time. "CGBUTS_REWCHAR" moves " "you to the beginning of the game, and "CGBUTS_FFCHAR" moves you to the " "end."}, {butText_just, 0, ""}, {butText_just, 2, "The Score Boxes"}, {butText_just, 0, " To the right of the board are the score boxes. There are two; one " "for white and one for black. In each box are shown the current score " "for that player and the amount of time remaining on that player's " "clock. When you are playing the game, the score is not the final " "score for that player, but the sum of the number of captures and the " "komi. When you are selecting dead stones and after pressing the " "\"Done\" button, the score is the actual score for that player."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Adjourn\" Button"}, {butText_just, 0, " Pressing \"Adjourn\" will send a request to adjourn the game when " "you are playing. The other player must choose to adjourn also; then " "the game will be saved on the server and you can safely stop playing."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Resign\" and \"Close\" Buttons"}, {butText_just, 0, " If you are playing a game, there will be a button labeled " "\"Resign\". Pressing this will resign the game. You will be asked " "whether you really want to resign just in case you pressed the button " "by accident!"}, {butText_just, 0, " If you are not playing in the game, then the button will say " "\"close\" instead and pressing it will close the window showing the " "game."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Edit Game\" Button"}, {butText_just, 0, " Pressing \"Edit Game\" will pop up a second game board with the " "game on it. This will be an edit game board, not a server game " "board, and it will come with a edit tool set. This is used if you " "want to the editing tools to annotate the game that your are " "observing or playing in."}, {butText_just, 0, ""}, {butText_just, 2, "The Kibitz Box"}, {butText_just, 0, " At the very bottom of the window is the kibitz box. If you are " "observing the game, then you will see kibitzes here. If you are " "playing, then you will see messages from your opponent here."}, {butText_just, 0, " There is an area below the kibitz box where you can type your " "own kibitzes. Observers can only kibitz here; if you are playing, " "then the radio button to the right of the text entry box controls " "whether your message is seen by the observers (the \"Kib\" setting), " "your opponent (the \"Say\" setting) or everybody (the \"Both\" " "setting)."}, {butText_just, 0, " When you are typing a message, the left and right arrows will not " "move you forwards and backwards in the game. Instead they will move " "the text cursor. To get rid of the text cursor and enable the " "left and right arrows again, just press \"Return\" on an empty " "kibitz."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText cliBoardKeyPage[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Client Play Keyboard Shortcuts"}, {butText_just, 0, " Left arrow: Go back one move."}, {butText_just, 0, " Right arrow: Go ahead one move."}, {butText_just, 0, " Holding down shift when you click on the board will move the " "game forward or back to when that move was played."}, {butText_just, 0, " Holding down control when you click on the board will let you try " "out variations in the game you are observing or playing. Press " "the \"" CGBUTS_FFCHAR "\" button to return to the game."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage cliBoard[] = { {"Server Play", cliBoardPage}, {"Keyboard Shortcuts", cliBoardKeyPage}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_cliBoard = {5, "Server Play Help Pages", cliBoard}; /* From "client/setup.c" */ static const AbutHelpText cliSetup[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Connecting to Go Servers"}, {butText_just, 0, " The internet go servers provide a way for go " "players around the world to meet to talk and play go. If your computer " "can connect to these servers then you too can enjoy this. In some " "parts of the world the go servers is the only way to find games of " "go on a regular basis!"}, {butText_just, 0, " To connect, fill out your username and password " "in the areas provided. You will not see your password as you type it " "for security reasons. Your username and password will be stored in " "your resource file so that you will not have to type them next time " "that you log in. This does mean, however, that you should be careful " "about letting people see your resource file! The default name for " "this file is \".cgobanrc\"; you should protect it if you are worried " "about your password getting out."}, {butText_just, 0, " If you don't have an account on the server you are " "connecting to, just follow the directions in the connect window and " "you will log in as a guest."}, {butText_just, 0, " If you are behind a firewall and need to use a proxy " "agent to connect to a server, then press the \"setup\" button on the " "main window. This will allow you to configure the servers to go " "through a proxy. It will also enable you to add or remove servers."}, {butText_just, 0, " To change the machine name or port numbers used to " "connect to the servers, press the \"Setup\" button in the control " "window."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage cliSetupPage[] = { {"Server Connect", cliSetup}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_cliSetup = {4, "Server Connect Help Pages", cliSetupPage}; /* From "gmp/play.c" */ static const AbutHelpText gmpBoard[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "The Game Board"}, {butText_just, 0, " When using go modem protocol to play a game, the " "board is shown in a window with controls used in the game around it. " "To make a move, click on the board where you want your stone to go. " "The last stone played will have a circle marker on it; if the last " "move was a ko move, then the stone will have a square marker on it " "instead."}, {butText_just, 0, ""}, {butText_just, 2, "The Title Box"}, {butText_just, 0, " Just above the board is the title box. Here, the " "title of the game is shown along with the current move number and " "whose move it is."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Pass\" Button"}, {butText_just, 0, " Pressing \"Pass\" will pass your turn. The game will " "enter the scoring stage after both players pass."}, {butText_just, 0, " Go modem protocol has no way to indicate which stones " "are dead, so that must be done by a person."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Dispute\" Button"}, {butText_just, 0, " When you are playing with Japanese scoring, the " "button just below the pass button is the \"Dispute\" button. If " "the players disagree on whether a group of stones are alive or dead, " "they can resolve the disagreement by pressing \"Dispute\". After " "pressing dispute, the players select which group of stones are " "the problem. Then the game continues, with slightly different rules. " "When you are resolving disputes, kos cannot be retaken until a player " "passes and it takes three consecutive passes to end the dispute. After " "the three passes, the board is put back to the position it had before " "the dispute. If any of the disputed stones are still alive, then " "they are alive for scoring purposes; if they are all dead, then they " "are dead for scoring purposes."}, {butText_just, 0, " It should be noted that go modem protocol has no " "way to resolve disputes, so the disputes must be played out by a " "person."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Resume\" button"}, {butText_just, 0, " When you are not using Japanese rules, any dispute " "at the end of the game can be resolved by simply undoing the last two " "passes and continuing the game. Pressing \"Resume\" will let you do " "that."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Done\" button"}, {butText_just, 0, " When both players are done marking dead stones, " "pressing \"Done\" will finish it and record the score."}, {butText_just, 0, ""}, {butText_just, 2, "The \""CGBUTS_REWCHAR"\", \""CGBUTS_BACKCHAR"\", " "\""CGBUTS_FWDCHAR"\", and \""CGBUTS_FFCHAR"\" Buttons"}, {butText_just, 0, " Pressing these buttons will move forward and backward through the " "game, letting you undo and redo moves. "CGBUTS_BACKCHAR" and " CGBUTS_FWDCHAR" will go one move at a time. "CGBUTS_REWCHAR" moves " "you to the beginning of the game, and "CGBUTS_FFCHAR" moves you to the " "end."}, {butText_just, 0, ""}, {butText_just, 2, "The Score Boxes"}, {butText_just, 0, " To the right of the board are the score boxes. There are two; one " "for white and one for black. In each box are shown the current score " "for that player and the amount of time remaining on that player's " "clock. When you are playing the game, the score is not the final " "score for that player, but the sum of the number of captures and the " "komi. When you are selecting dead stones and after pressing the " "\"Done\" button, the score is the actual score for that player."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Save Game\" Button"}, {butText_just, 0, " Pressing \"Save Game\" will save the game as a smart go file. Later " "you can continue the game with the \"Load Game\" button of the control " "window. You can also choose \"Edit Game\" from the control panel to " "edit the game that you have saved. This is currently the only way to " "create a new smart go file since the \"Edit Game\" button doesn't " "work."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Edit Game\" Button"}, {butText_just, 0, " Pressing \"Edit Game\" will pop up a second game board with the " "game on it. This will be an edit game board, not a go modem game " "board, and it will come with a edit tool set. This is used if you " "want to use the editing tools to annotate the game that is being " "played."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Quit\" Button"}, {butText_just, 0, " Pressing \"Quit\" will end the game. If you want to continue the " "game later, you should choose \"Save Game\" before you quit."}, {butText_just, 0, ""}, {butText_just, 2, "The Comments Box"}, {butText_just, 0, " At the very bottom of the window is the comments box. Here you " "can make comments about the game that will be saved in the smart go " "file if you choose \"Save Game\" later. To edit or add the comments, " "click in the comments box and start typing. Some emacs-style control " "keys are available; see the \"Keyboard Shortcuts\" help page for a " "list of them."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpText gmpBoardKey[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Playing Go Keyboard Shortcuts"}, {butText_just, 0, " Left arrow: Go back one move."}, {butText_just, 0, " Right arrow: Go ahead one move."}, {butText_just, 0, ""}, {butText_just, 2, "Comment Editing"}, {butText_just, 0, " When you are editing a comment the left and right " "arrows will not change moves. Instead they will move the cursor. " "These other commands are available:"}, {butText_just, 0, " Ctrl-A: Move cursor to the beginning of the line."}, {butText_just, 0, " Ctrl-D: Delete to the right of the cursor"}, {butText_just, 0, " Ctrl-E: Move cursor to the end of the line."}, {butText_just, 0, " Ctrl-K: Delete to the end of the line."}, {butText_just, 0, " Ctrl-U: Delete from the beginning of the line."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage gmpBoardPage[] = { {"Go Modem Play", gmpBoard}, {"Keyboard Shortcuts", gmpBoardKey}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_gmpBoard = {5, "Go Modem Help Pages", gmpBoardPage}; /* From "gmp/setup.c" */ static const AbutHelpText gmpSetup[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Go Modem Protocol Setup Window"}, {butText_just, 0, " Using this window you may configure how the go modem " "protocol will be used. The different types of connections allowed " "will be described."}, {butText_just, 0, ""}, {butText_just, 2, "\"Program\" Connections"}, {butText_just, 0, " When you select \"Program\" as either the white " "or the black player, Cgoban will execute a program and communicate " "go modem protocol with that program's stdin/stdout. You must " "specify the program to run in the \"Program\" field. The full " "command line, with the path, must be specified. If you put \"%d\" " "in the command line somewhere, the first \"%d\" will be replaced by " "the main time (in seconds) and the second \"%d\" will be replaced by " "the byo-yomi time (in seconds). For example, the program name " "\"./goDummy -time %d -byoYomi %d\" will run the program \"goDummy\" " "from the current directory with the time and the byo-yomi time " "passed in on the command line."}, {butText_just, 0, " The send game command checkbox controls whether " "commands to start the game will be sent to the program. Go modem " "protocol required the two agents to decide before connecting who will " "initiate the communication; this button lets you choose. Make sure " "that either Cgoban or the program send the game command or else the " "game will never start!"}, {butText_just, 0, ""}, {butText_just, 2, "\"Device\" Connections"}, {butText_just, 0, " This behaves much like a \"Program\" connection " "except that instead of running a program, Cgoban will connect to " "the device specified. For example, in Linux setting device to " "\"/dev/cua0\" will connect up to the computer's COM1 port."}, {butText_just, 0, ""}, {butText_just, 2, "\"Human\" Connections"}, {butText_just, 0, " Setting the connection to \"Human\" will let you " "make moves for this player."}, {butText_just, 0, ""}, {butText_just, 2, "\"NNGS\" and \"IGS\" Connections"}, {butText_just, 0, " Using \"NNGS\" or \"IGS\" will open a connection " "to a go server. The username and the password should be set " "correctly. If one player is \"NNGS\" or \"IGS\", then the other " "player will be started up every time that a game is accepted on " "the server. You will have to type all server commands except for " "the actual moves in the game; these will be made by the program or " "device. The \"Send game command\" switch is always set when you " "are connected to a server."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage gmpSetupPage[] = { {"Go Modem Play Setup", gmpSetup}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_gmpSetup = {4, "Go Modem Setup Help Pages", gmpSetupPage}; /* From "setup.c" */ static const AbutHelpText configure[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Configure Window"}, {butText_just, 0, " The configure window lets you change the behavior " "of Cgoban. There are several control panels in the configure window; " "each controls a different part of cgoban."}, {butText_just, 0, ""}, {butText_just, 2, "The \"Connecting To NNGS\" And \"Connecting To IGS\" " "Control Panels"}, {butText_just, 0, " Here you can set the location of the go servers. " "The default will be set to the current location of the " "servers; this window is here in case they move in the future. " "If the locations are wrong then you should fill in the machine name " "and port number of the server in the appropriate fields."}, {butText_just, 0, " Typically you want to leave \"Connect Directly To " "Server\" set. This is the most efficient way to connect to a go " "server. The only time when you might not want to set this is when " "your computer is behind a firewall or other security system. Then " "direct connections out might not work and you will have to go through " "a proxy. To do this, turn off \"Connect Directly To Server\" and " "enter the name of a program that can get through the firewall in " "the \"Connecting Command\" field. Instead of connecting to the " "server itself, Cgoban will run the command you specify and use it " "to get to the server."}, {butText_just, 0, " Be careful that you do not confuse the NNGS and the " "IGS servers! There are subtle differences in their protocol and " "Cgoban will not operate reliably if it connects to one type of " "server when it thinks it is connecting to another!"}, {butText_just, 0, ""}, {butText_just, 2, "The \"Miscellaneous\" Control Panel"}, {butText_just, 0, " Here are a few different controls."}, {butText_just, 0, " When \"Show Coordinates Around Boards\" checkbox " "controls whether the coordinates are shown around the boards that " "Cgoban draws."}, {butText_just, 0, " When \"Number Kibitzes\" is set, any kibitz " "in a game on a go server will have the move number shown before it."}, {butText_just, 0, " The \"Anti-Slip Moving\" button will not let you " "make a move until you have held the mouse over that point for at least " "a half a second. This is useful because sometimes clicking on the " "mouse makes it slip to the next space over, placing your move in " "the wrong location! With Anti-Slip on, this can't happen."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage configurePage[] = { {"Configuring Cgoban", configure}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_configure = {4, "Configure Help Pages", configurePage}; /* From client/look.c */ static const AbutHelpText cliLook[] = { {butText_center, 2, "Cgoban " VERSION}, {butText_center, 0, "By Bill Shubert, Kevin Sonney"}, {butText_center, 0, DATE}, {butText_just, 0, ""}, {butText_just, 2, "Client Look Window"}, {butText_just, 0, " The \"Look\" and \"Status\" commands on the go " "servers show you the current state of a game. \"Look\" shows you " "a saved game, while \"Status\" shows you a game in progress."}, {butText_just, 0, " These boards cannot be edited or manipulated in " "any way."}, {butText_just, 0, ""}, {butText_left, 0, NULL}}; static const AbutHelpPage cliLookPage[] = { {"Client Look Window", cliLook}, {NULL, NULL}, {"Copyright and Non-Warranty", copyright}, {"About the Author", aboutAuthor}}; Help help_cliLook = {4, "Client Look Help Pages", cliLookPage}; cgoban-1.9.14/src/local.c0000664000671000067100000004725007050207032010554 /* * $Source: /cvsroot/cgoban1/cgoban1/src/local.c,v $ * $Revision: 1.2 $ * $Date: 2000/02/09 06:50:02 $ * * Part of Complete Goban (game program) * Copyright © 1995-1996,2000 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cgoban.h" #include "goban.h" #include "msg.h" #include "goGame.h" #include "goPic.h" #include "cgbuts.h" #include "sgf.h" #include "sgfIn.h" #include "sgfOut.h" #include "sgfPlay.h" #include "editBoard.h" #ifdef _LOCAL_H_ Levelization Error. #endif #include "local.h" /********************************************************************** * Forward references **********************************************************************/ static GobanOut gridPressed(void *packet, int loc); static GobanOut quitPressed(void *packet); static GobanOut passPressed(void *packet); static GobanOut rewPressed(void *packet); static GobanOut backPressed(void *packet); static GobanOut fwdPressed(void *packet); static GobanOut ffPressed(void *packet); static GobanOut donePressed(void *packet); static GobanOut disputePressed(void *packet); static GobanOut savePressed(void *packet); static GobanOut editPressed(void *packet); static void saveFile(AbutFsel *fsel, void *packet, const char *fname); static void writeGobanComments(Local *l), readGobanComments(Local *l); static void addDisputedTriangles(GoGame *game, Sgf *sgf); static void addTimeInfoToSgf(Local *l, GoStone color); static void recordTimeLoss(Local *l); static bool rewOk(void *packet), backOk(void *packet), fwdOk(void *packet); static void gobanDestroyed(void *packet); static ButOut reallyQuit(But *but); static ButOut dontQuit(But *but); static ButOut quitWinDead(void *packet); static void setTimers(Local *l); /********************************************************************** * Global variables **********************************************************************/ static const GobanActions local_actions = { gridPressed, quitPressed, passPressed, rewPressed, backPressed, fwdPressed, ffPressed, donePressed, disputePressed, savePressed, editPressed, NULL /* gameInfo */, &help_localBoard, gobanDestroyed, rewOk, backOk, fwdOk, fwdOk}; /********************************************************************** * Functions **********************************************************************/ Local *local_create(Cgoban *cg, GoRules rules, int size, int hcap, float komi, const char *white, const char *black, GoTimeType timeType, int mainTime, int byTime, int auxTime) { Sgf *mc; Str tmp; GoTime time; mc = sgf_create(); str_init(&tmp); sgf_setRules(mc, rules); sgf_setSize(mc, size); sgf_setHandicap(mc, hcap); sgf_setKomi(mc, komi); sgf_setPlayerName(mc, goStone_white, white); sgf_setPlayerName(mc, goStone_black, black); str_print(&tmp, msg_localTitle, white, black); sgf_setTitle(mc, str_chars(&tmp)); sgf_setDate(mc); sgf_style(mc, "Cgoban " VERSION); time.type = timeType; time.main = mainTime; time.by = byTime; time.aux = auxTime; goTime_describeStr(&time, &tmp); sgf_setTimeFormat(mc, str_chars(&tmp)); str_deinit(&tmp); return(local_createSgf(cg, mc)); } Local *local_createFile(Cgoban *cg, const char *fname) { Str badFile; Sgf *mc; SgfElem *style; const char *err; mc = sgf_createFile(cg, fname, &err, NULL); if (mc == NULL) { abutMsg_winCreate(cg->abut, "Cgoban Error", err); return(NULL); } style = sgf_findType(mc, sgfType_style); if (!style || strncmp(str_chars(style->sVal), "Cgoban", 6)) { str_init(&badFile); str_print(&badFile, msg_notCgobanFile, fname); abutMsg_winCreate(cg->abut, "Cgoban Error", str_chars(&badFile)); str_deinit(&badFile); sgf_destroy(mc); return(NULL); } return(local_createSgf(cg, mc)); } Local *local_createSgf(Cgoban *cg, Sgf *mc) { Local *l; SgfElem *me; GoRules rules; int size, hcap; float komi; GoTime time; const char *title; assert(MAGIC(cg)); l = wms_malloc(sizeof(Local)); MAGIC_SET(l); l->cg = cg; l->moves = mc; l->endGame = NULL; me = sgf_findType(mc, sgfType_rules); if (me) { rules = (GoRules)me->iVal; } else rules = goRules_japanese; me = sgf_findType(mc, sgfType_size); if (me) { size = me->iVal; } else { size = 19; } me = sgf_findType(mc, sgfType_handicap); if (me) { hcap = me->iVal; } else { hcap = 0; } me = sgf_findType(mc, sgfType_komi); if (me) { komi = (float)me->iVal / 2.0; } else { komi = 0.0; } me = sgf_findFirstType(mc, sgfType_playerName); while (me) { me = sgfElem_findFirstType(me, sgfType_playerName); } me = sgf_findFirstType(mc, sgfType_time); if (me) { goTime_parseDescribeChars(&time, str_chars(me->sVal)); } else { time.type = goTime_none; } l->game = goGame_create(size, rules, hcap, komi, &time, FALSE); sgf_play(mc, l->game, NULL, -1, NULL); l->modified = FALSE; me = sgf_findFirstType(mc, sgfType_title); if (me) { title = str_chars(me->sVal); } else { title = msg_noTitle; } l->goban = goban_create(cg, &local_actions, l, l->game, "local", title); l->goban->iDec1 = grid_create(&cg->cgbuts, NULL, NULL, l->goban->iWin, 2, BUT_DRAWABLE, 0); grid_setStone(l->goban->iDec1, goStone_white, FALSE); l->goban->iDec2 = grid_create(&cg->cgbuts, NULL, NULL, l->goban->iWin, 2, BUT_DRAWABLE, 0); grid_setStone(l->goban->iDec2, goStone_black, FALSE); setTimers(l); l->lastComment = NULL; assert((hcap == 0) || ((hcap >= 2) && (hcap <= 27))); l->fsel = NULL; l->reallyQuit = NULL; return(l); } void local_destroy(Local *l) { assert(MAGIC(l)); if (l->goban) goban_destroy(l->goban, FALSE); if (l->game) goGame_destroy(l->game); if (l->fsel) abutFsel_destroy(l->fsel, FALSE); if (l->reallyQuit) abutMsg_destroy(l->reallyQuit, FALSE); MAGIC_UNSET(l); wms_free(l); } static GobanOut gridPressed(void *packet, int loc) { Local *l = packet; GoStone moveColor; bool timeLeft; assert(MAGIC(l)); l->modified = TRUE; moveColor = goGame_whoseMove(l->game); if (l->game->state <= goGameState_dispute) { readGobanComments(l); sgf_addNode(l->moves); if (l->game->state == goGameState_dispute) { addDisputedTriangles(l->game, l->moves); } timeLeft = goban_stopTimer(l->goban); if (!timeLeft) { l->game->state = goGameState_done; recordTimeLoss(l); } else { sgf_move(l->moves, moveColor, goBoard_loc2Sgf(l->game->board, loc)); goGame_move(l->game, moveColor, loc, &l->goban->timers[moveColor]); addTimeInfoToSgf(l, moveColor); goban_startTimer(l->goban, goStone_opponent(moveColor)); } } else if (l->game->state == goGameState_selectDead) { goGame_markDead(l->game, loc); } else if (l->game->state == goGameState_selectDisputed) { l->endGame = l->moves->active; goGame_dispute(l->game, loc); /* * We briefly change to "variant" insert mode so that multiple disputes * will be seen in the order they were made. Then we switch back to * "main" insert mode so that undos and ends of disputes will be * the main variation. */ l->moves->mode = sgfInsert_variant; sgf_addNode(l->moves); addDisputedTriangles(l->game, l->moves); sgf_setWhoseMove(l->moves, l->game->setWhoseMoveColor); l->moves->mode = sgfInsert_main; } writeGobanComments(l); return(gobanOut_draw); } /* * This transfers comments from the SGF move chain to the goban. */ static void writeGobanComments(Local *l) { SgfElem *comElem; assert(MAGIC(l)); comElem = sgfElem_findTypeInNode(l->moves->active, sgfType_comment); if (comElem) { if (strcmp(str_chars(comElem->sVal), goban_getComments(l->goban))) goban_setComments(l->goban, str_chars(comElem->sVal)); } else { if (l->lastComment) goban_setComments(l->goban, ""); } l->lastComment = comElem; } /* * This transfers comments from the goban to the SGF move chain. */ static void readGobanComments(Local *l) { const char *comm; comm = goban_getComments(l->goban); if (comm[0]) { if (l->lastComment) { if (!strcmp(comm, str_chars(l->lastComment->sVal))) return; } l->modified = TRUE; l->moves->mode = sgfInsert_inline; sgf_comment(l->moves, comm); l->moves->mode = sgfInsert_main; l->lastComment = l->moves->active; } else if (l->lastComment) { l->modified = TRUE; sgfElem_snip(l->lastComment, l->moves); l->lastComment = NULL; } } static GobanOut quitPressed(void *packet) { Local *l = packet; AbutMsgOpt buttons[2]; assert(MAGIC(l)); if (l->modified) { buttons[0].name = msg_noCancel; buttons[0].callback = dontQuit; buttons[0].packet = l; buttons[0].keyEq = NULL; buttons[1].name = msg_yesQuit; buttons[1].callback = reallyQuit; buttons[1].packet = l; buttons[1].keyEq = NULL; if (l->reallyQuit) abutMsg_destroy(l->reallyQuit, FALSE); l->reallyQuit = abutMsg_winOptCreate(l->cg->abut, "Cgoban Warning", msg_reallyQuitGame, quitWinDead, l, 2, buttons); } else local_destroy(l); return(gobanOut_noDraw); } static GobanOut passPressed(void *packet) { Local *l = packet; GoGameState oldState = l->game->state; GoStone moveColor; bool timeLeft; assert(MAGIC(l)); readGobanComments(l); moveColor = goGame_whoseMove(l->game); sgf_addNode(l->moves); if (oldState == goGameState_dispute) addDisputedTriangles(l->game, l->moves); sgf_pass(l->moves, moveColor); addTimeInfoToSgf(l, moveColor); timeLeft = goban_stopTimer(l->goban); if (!timeLeft) { l->game->state = goGameState_done; recordTimeLoss(l); } else if (goGame_pass(l->game, moveColor, &l->goban->timers[moveColor])) { /* * The game state has changed. */ if (oldState == goGameState_dispute) { assert(MAGIC(l->endGame)); l->moves->active = l->endGame; l->endGame = NULL; if (l->game->disputeAlive) goban_message(l->goban, msg_disputeOverAlive); else goban_message(l->goban, msg_disputeOverDead); } else { assert(oldState == goGameState_play); if ((l->game->rules == goRules_japanese) || (l->game->rules == goRules_tibetan)) goban_message(l->goban, msg_localJapRemDead); else goban_message(l->goban, msg_localChiRemDead); } } else { goban_startTimer(l->goban, goStone_opponent(moveColor)); } writeGobanComments(l); return(gobanOut_draw); } static GobanOut rewPressed(void *packet) { Local *l = packet; assert(MAGIC(l)); readGobanComments(l); goban_noMessage(l->goban); goban_stopTimer(l->goban); if (l->game->state == goGameState_dispute) goGame_moveTo(l->game, l->game->setWhoseMoveNum); else goGame_moveTo(l->game, 0); sgf_setActiveNodeNumber(l->moves, l->game->moveNum); setTimers(l); writeGobanComments(l); return(gobanOut_draw); } static GobanOut backPressed(void *packet) { Local *l = packet; assert(MAGIC(l)); readGobanComments(l); goban_noMessage(l->goban); goban_stopTimer(l->goban); if (l->game->state != goGameState_selectDead) { goGame_moveTo(l->game, l->game->moveNum - 1); } else { /* We must be in the endgame. Let's continue the game now instead! */ goGame_resume(l->game); } sgf_setActiveNodeNumber(l->moves, l->game->moveNum); setTimers(l); writeGobanComments(l); return(gobanOut_draw); } static GobanOut fwdPressed(void *packet) { Local *l = packet; assert(MAGIC(l)); readGobanComments(l); goban_noMessage(l->goban); goban_stopTimer(l->goban); goGame_moveTo(l->game, l->game->moveNum + 1); sgf_setActiveNodeNumber(l->moves, l->game->moveNum); setTimers(l); writeGobanComments(l); return(gobanOut_draw); } static GobanOut ffPressed(void *packet) { Local *l = packet; assert(MAGIC(l)); readGobanComments(l); goban_noMessage(l->goban); goban_stopTimer(l->goban); goGame_moveTo(l->game, l->game->maxMoves); sgf_setActiveNodeNumber(l->moves, l->game->moveNum); setTimers(l); writeGobanComments(l); return(gobanOut_draw); } static GobanOut donePressed(void *packet) { Local *l = packet; int i; Str *scoreComment, winner, doneMessage, result; float wScore, bScore; SgfElem *resultElem; assert(MAGIC(l)); assert(l->game->state == goGameState_selectDead); readGobanComments(l); goban_stopTimer(l->goban); str_init(&winner); str_init(&doneMessage); str_init(&result); goban_noMessage(l->goban); goGame_done(l->game); sgf_addNode(l->moves); /* * Add a territory list. */ for (i = 0; i < goBoard_area(l->game->board); ++i) { if (((l->game->flags[i] & GOGAMEFLAGS_SEEN) == GOGAMEFLAGS_SEEWHITE) && ((goBoard_stone(l->game->board, i) == goStone_empty) || (l->game->flags[i] & GOGAMEFLAGS_MARKDEAD))) sgf_addTerritory(l->moves, goStone_white, goBoard_loc2Sgf(l->game->board, i)); } for (i = 0; i < goBoard_area(l->game->board); ++i) { if (((l->game->flags[i] & GOGAMEFLAGS_SEEN) == GOGAMEFLAGS_SEEBLACK) && ((goBoard_stone(l->game->board, i) == goStone_empty) || (l->game->flags[i] & GOGAMEFLAGS_MARKDEAD))) sgf_addTerritory(l->moves, goStone_black, goBoard_loc2Sgf(l->game->board, i)); } wScore = goban_score(l->goban, goStone_white); bScore = goban_score(l->goban, goStone_black); if (wScore > bScore) { str_print(&winner, msg_winnerComment, msg_stoneNames[goStone_white], wScore - bScore); str_print(&result, "W+%g", wScore - bScore); } else if ((bScore > wScore) || (l->game->rules == goRules_ing)) { str_print(&winner, msg_winnerComment, msg_stoneNames[goStone_black], bScore - wScore); str_print(&result, "B+%g", bScore - wScore); } else { str_print(&winner, msg_jigoComment); str_copyChar(&result, '0'); } str_print(&doneMessage, msg_gameIsOver, winner); goban_message(l->goban, str_chars(&doneMessage)); scoreComment = goScore_str(&l->goban->score, l->game, &l->game->time, l->goban->timers); sgf_catComment(l->moves, str_chars(scoreComment)); str_destroy(scoreComment); resultElem = sgf_findType(l->moves, sgfType_result); if (resultElem) { sgfElem_newString(resultElem, str_chars(&result)); } else { sgf_setActiveNodeNumber(l->moves, 0); l->moves->mode = sgfInsert_inline; sgf_result(l->moves, str_chars(&result)); l->moves->mode = sgfInsert_main; sgf_setActiveToEnd(l->moves); } str_deinit(&winner); str_deinit(&doneMessage); str_deinit(&result); writeGobanComments(l); return(gobanOut_draw); } static GobanOut disputePressed(void *packet) { Local *l = packet; assert(MAGIC(l)); goGame_selectDisputed(l->game); goban_message(l->goban, msg_selectDisputedMsg); return(gobanOut_draw); } static GobanOut savePressed(void *packet) { Local *l = packet; assert(MAGIC(l)); if (l->fsel) abutFsel_destroy(l->fsel, FALSE); l->fsel = abutFsel_create(l->cg->abut, saveFile, l, "CGoban", msg_saveGameName, clp_getStr(l->cg->clp, "local.sgfName")); return(gobanOut_noDraw); } static GobanOut editPressed(void *packet) { Local *l = packet; assert(MAGIC(l)); editBoard_createSgf(l->cg, l->moves); return(gobanOut_noDraw); } static void saveFile(AbutFsel *fsel, void *packet, const char *fname) { Local *l = packet; int error; Str str; assert(MAGIC(l)); str_copy(&l->cg->lastDirAccessed, &fsel->pathVal); if (fname != NULL) { readGobanComments(l); l->modified = FALSE; clp_setStr(l->cg->clp, "local.sgfName", butTextin_get(fsel->in)); if (!sgf_writeFile(l->moves, fname, &error)) { str_init(&str); str_print(&str, "Error saving file \"%s\": %s", fname, strerror(errno)); cgoban_createMsgWindow(l->cg, "Cgoban Error", str_chars(&str)); str_deinit(&str); } } l->fsel = NULL; } static void addDisputedTriangles(GoGame *game, Sgf *sgf) { int i; for (i = 0; i < goBoard_area(game->board); ++i) { if (game->flags[i] & GOGAMEFLAGS_DISPUTED) sgf_addTriangle(sgf, goBoard_loc2Sgf(game->board, i)); } } static void addTimeInfoToSgf(Local *l, GoStone who) { if (l->game->time.type != goTime_none) { sgf_timeLeft(l->moves, who, l->goban->timers[who].timeLeft + (l->goban->timers[who].usLeft > 0)); if ((l->game->time.type == goTime_ing) || ((l->game->time.type == goTime_canadian) && l->goban->timers[who].aux)) { sgf_stonesLeft(l->moves, who, l->goban->timers[who].aux); } } } static void recordTimeLoss(Local *l) { Str timeMsg; GoStone loser = l->game->whoseMove; /* I don't think that this code is needed any more. * sgf_timeLeft(l->moves, l->game->timeLoss, -1); * if ((l->game->time.type == goTime_ing) || * ((l->game->time.type == goTime_canadian) && * l->goban->timers[loser].aux)) { * sgf_stonesLeft(l->moves, loser, * l->goban->timers[loser].aux + * (l->game->time.type == goTime_canadian)); * } */ str_init(&timeMsg); str_print(&timeMsg, msg_timeLoss, msg_stoneNames[loser], msg_stoneNames[goStone_opponent(loser)]); goban_message(l->goban, str_chars(&timeMsg)); str_catChar(&timeMsg, '\n'); sgf_catComment(l->moves, str_chars(&timeMsg)); str_print(&timeMsg, "%c+T", (int)goStone_char(goStone_opponent(loser))); sgf_setActiveNodeNumber(l->moves, 0); l->moves->mode = sgfInsert_inline; sgf_result(l->moves, str_chars(&timeMsg)); l->moves->mode = sgfInsert_main; sgf_setActiveToEnd(l->moves); str_deinit(&timeMsg); } static bool rewOk(void *packet) { Local *l = packet; GoGame *game; assert(MAGIC(l)); game = l->game; switch(game->state) { case(goGameState_selectDead): case(goGameState_selectDisputed): return(FALSE); break; case(goGameState_dispute): return(game->moveNum > game->setWhoseMoveNum); break; default: return(game->moveNum > 0); break; } } static bool backOk(void *packet) { Local *l = packet; GoGame *game; assert(MAGIC(l)); game = l->game; switch(game->state) { case(goGameState_selectDead): return(TRUE); break; case(goGameState_selectDisputed): return(FALSE); break; case(goGameState_dispute): return(game->moveNum > game->setWhoseMoveNum); break; default: return(game->moveNum > 0); break; } } static bool fwdOk(void *packet) { Local *l = packet; GoGame *game; assert(MAGIC(l)); game = l->game; switch(game->state) { case(goGameState_selectDead): case(goGameState_selectDisputed): return(FALSE); break; default: return(game->moveNum < game->maxMoves); break; } } static void gobanDestroyed(void *packet) { Local *l = packet; assert(MAGIC(l)); l->goban = NULL; local_destroy(l); } static ButOut reallyQuit(But *but) { local_destroy(but_packet(but)); return(0); } static ButOut dontQuit(But *but) { Local *l = but_packet(but); assert(MAGIC(l)); abutMsg_destroy(l->reallyQuit, FALSE); l->reallyQuit = NULL; return(0); } static ButOut quitWinDead(void *packet) { Local *l = packet; assert(MAGIC(l)); l->reallyQuit = NULL; return(0); } static void setTimers(Local *l) { GoStone stone; const GoTimer *timer; assert(MAGIC(l)); goStoneIter(stone) { timer = goGame_getTimer(l->game, stone); if (timer == NULL) goTimer_init(&l->goban->timers[stone], &l->game->time); else l->goban->timers[stone] = *timer; } goban_updateTimeReadouts(l->goban); goban_startTimer(l->goban, goGame_whoseMove(l->game)); } cgoban-1.9.14/src/main.c0000664000671000067100000000645707056055722010427 /* * $Source: /cvsroot/cgoban1/cgoban1/src/main.c,v $ * $Revision: 1.2 $ * $Date: 2000/02/26 23:03:46 $ * * src/main.c, part of Complete Goban (game program) * Copyright © 1995-2000 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include "cgoban.h" #include "control.h" #include "main.h" #include "editBoard.h" #include "crwin.h" #include "client/setup.h" #include "arena.h" /********************************************************************** * Forward Declarations **********************************************************************/ static void stealth(int exitVal); #if !DEBUG static RETSIGTYPE sigHandler(); #endif /* !DEBUG */ int main(int argc, char *argv[], char *envp[]) { Cgoban *cg; int retVal = 0; Control *ctrl; EditBoard *e; CliSetup *client; cg = cgoban_create(argc, argv, envp); if (cg == NULL) { fprintf(stderr, "cgoban: Couldn't open X display.\n"); return(1); } if (clp_getInt(cg->clp, "arena.games") > 0) { arena(cg, clp_getStr(cg->clp, "arena.prog1"), clp_getStr(cg->clp, "arena.prog2"), clp_getInt(cg->clp, "arena.size"), (float)clp_getDouble(cg->clp, "arena.komi"), clp_getInt(cg->clp, "arena.handicap")); exit(0); } #if !DEBUG signal(SIGTERM, sigHandler); /* Catch these signals gracefully. */ signal(SIGINT, sigHandler); signal(SIGHUP, sigHandler); #endif /* * We have to always catch SIGPIPE. Otherwise the GMP will freak out * on us. */ signal(SIGPIPE, SIG_IGN); /* Seems like you can't catch a SIGPIPE. */ #ifdef DEBUG #define STEALTH_VALID (!(DEBUG)) #else #define STEALTH_VALID 1 #endif if (clp_getStr(cg->clp, "edit")[0]) { if ((e = editBoard_create(cg, clp_getStr(cg->clp, "edit"))) == NULL) { cg->env->minWindows = 0; retVal = 1; } else { crwin_create(cg, e->goban->win, 4); control_create(cg, TRUE); } } else if (clp_getBool(cg->clp, "nngs")) { if ((client = cliSetup_create(cg, cliServer_nngs)) == NULL) { cg->env->minWindows = 0; retVal = 1; } else { crwin_create(cg, client->login->win, 3); control_create(cg, TRUE); } } else if (clp_getBool(cg->clp, "igs")) { if ((client = cliSetup_create(cg, cliServer_igs)) == NULL) { cg->env->minWindows = 0; retVal = 1; } else { crwin_create(cg, client->login->win, 3); control_create(cg, TRUE); } } else { ctrl = control_create(cg, clp_getBool(cg->clp, "iconic")); crwin_create(cg, ctrl->win, 3); } if (clp_getBool(cg->clp, "stealth") && STEALTH_VALID) stealth(0); butEnv_events(cg->env); cgoban_destroy(cg); return(retVal); } static void stealth(int exitVal) { int pid; #ifdef TIOCNOTTY int tty; #endif pid = fork(); if (pid < 0) { perror("cgoban: fork() failed"); return; } else if (pid > 0) /* Parent just exits. */ exit(0); /* Go stealth (ditch our controlling tty). */ #ifdef TIOCNOTTY tty = open("/dev/tty", 0); if (tty < 0) return; ioctl(tty, TIOCNOTTY, 0); close(tty); #endif } #if !DEBUG static RETSIGTYPE sigHandler() { fprintf(stderr, "Signal caught.\n"); abort(); } #endif /* !DEBUG */ cgoban-1.9.14/src/msg.c0000664000671000067100000004516707577722564010307 /* * src/msg.c, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include "cgbuts.h" /* Included for CGBUTS_WSTONECHAR and CGBUTS_BSTONECHAR */ #ifdef _MSG_H_ Levelization Error. #endif #include "msg.h" /********************************************************************** * Globals **********************************************************************/ const char msg_mFonts[] = "-adobe-utopia-medium-r-normal--%d-*-*-*-*-*-*-*/" "-adobe-times-medium-r-normal--%d-*-*-*-*-*-*-*/" "-bitstream-charter-medium-r-normal--%d-*-*-*-*-*-*-*"; const char msg_labelFonts[] = "-adobe-helvetica-bold-r-normal--%d-*-*-*-*-*-*-*"; const char msg_bFonts[] = "-adobe-utopia-bold-r-normal--%d-*-*-*-*-*-*-*/" "-adobe-times-bold-r-normal--%d-*-*-*-*-*-*-*/" "-bitstream-charter-black-r-normal--%d-*-*-*-*-*-*-*"; /* * From crwin.c */ const char msg_byBillShubert[] = "Copyright \251 1995-2002 William Shubert and Kevin Sonney"; const char msg_noWarranty[] = "Cgoban comes with ABSOLUTELY NO WARRANTY " "and is free software."; const char msg_seeHelp[] = "Please see the file \"COPYING\" for more " "details."; /* From "cgoban.c" */ const char msg_path[] = "Path:"; const char msg_file[] = "File:"; const char msg_mask[] = "Mask:"; const char msg_dirs[] = "Directories"; const char msg_files[] = "Files"; const char msg_dirErr[] = "Error \"%s\" occurred while trying to read directory \"%s\"."; const char msg_notEnoughColors[] = " Cgoban can't get enough colors. You probably have programs running " "that use a lot of colors, like Netscape or image viewers. Cgoban will " "run in black and white mode; if you want to run cgoban in color, then " "you must exit from the problem applications and run cgoban again."; /* * From control.c */ const char msg_newGame[] = "New Game"; const char msg_loadGame[] = "Load Game"; const char msg_editSGF[] = "Edit SGF File"; const char msg_goModem[] = "Go Modem"; const char msg_quit[] = "Quit"; const char msg_setup[] = "Setup"; const char msg_loadGameName[] = "Select the file to load:"; const char msg_editGameName[] = "Select the file to edit:"; /* * Buttons from gameSetup.c */ const char msg_gSetup[] = "Game Setup"; const char msg_wName[] = CGBUTS_WSTONECHAR " White:"; const char msg_bName[] = CGBUTS_BSTONECHAR " Black:"; const char msg_ruleSet[] = "Rules Set"; const char *msg_ruleNames[] = {"Chinese", "Japanese", "Ing", "AGA", "New Zealand", "Tibetan", BUTMENU_OLEND}; const char msg_boardSize[] = "Board Size"; const char msg_handicap[] = "Handicap"; const char msg_komi[] = "Komi"; const char msg_ok[] = "OK"; const char msg_cancel[] = "Cancel"; const char msg_timeSystem[] = "Time System"; const char *msg_timeSystems[] = {"None", "Absolute", "Japanese", "Canadian", "Ing", BUTMENU_OLEND}; const char msg_primaryTime[] = "Main Time"; const char msg_byoYomi[] = "Byo-Yomi Time"; const char msg_byoYomiStones[] = "Stones per Byo-Yomi"; const char msg_byoYomiCount[] = "Byo-Yomi Periods"; const char msg_badSize[] = "\"%s\" is an invalid size. The size should be " "a number from 2 through %d."; const char msg_badHcap[] = "\"%s\" is an invalid handicap. The handicap " "should be zero or a number from 2 through %d."; const char msg_badKomi[] = "\"%s\" is an invalid komi. The komi should be " "be a number, possibly with 0.5 (one-half) added."; const char msg_localTitle[] = "%s (W) vs. %s (B)"; const char msg_noTitle[] = "No Title"; const char msg_badTime[] = "\"%s\" is not a legal time. Use either " "just minutes, \"mm:ss\", or \"hh:mm:ss\" " "formats."; const char msg_badBYStones[] = "\"%s\" is not a legal byo-yomi stone " "count. Use any positive number."; const char msg_badBYCount[] = "\"%s\" is not a legal value for the " "number of byo-yomi periods. Use a " "positive whole number."; /* * Text from local.c */ const char msg_notCgobanFile[] = "\"%s\" is not a Cgoban save game. You may " "edit this SGF file, but you can not continue the game."; const char msg_gameInfo[] = "Game Info"; const char msg_help[] = "Help"; const char msg_pass[] = "Pass"; const char msg_done[] = "Done"; const char msg_resume[] = "Resume"; const char msg_dispute[] = "Dispute"; const char msg_saveGame[] = "Save Game"; const char msg_editGame[] = "Edit Game"; const char msg_score[] = "Score:"; const char msg_time[] = "Time: "; const char msg_localChiRemDead[] = "Now you must remove all dead stones. " "Click on a group to mark them as dead. " "Press \"Done\" when all dead groups are " "removed. Press \"Resume\" or \"" CGBUTS_BACKCHAR "\" if you want to go " "back to the game."; const char msg_localJapRemDead[] = "Now you must remove all dead stones. " "Click on a group to mark them as dead. " "Press \"Done\" when all dead groups are " "removed. Press \"Dispute\" if the " "players cannot agree which stones are " "dead. Press \"" CGBUTS_BACKCHAR "\" to continue the game."; const char msg_selectDisputedMsg[] = "Click on the stones that are disputed, then play to determine whether " "the stones are alive or dead. Pass when you are satisfied with the fate " "of the stones."; const char *msg_stoneNames[] = {"White", "Black", "Empty"}; const char msg_gameStartDesc[] = "Game Start: "; const char msg_move1Desc[] = "Move 1 (%c %s): "; const char msg_move1OfDesc[] = "Move 1 (%c %s) of %d: "; const char msg_moveNDesc[] = "Moves 1 to %d (%c %s): "; const char msg_moveNOfDesc[] = "Moves 1 to %d (%c %s) of %d: "; const char msg_toPlay[] = " to play"; const char msg_selectDead[] = "Select Dead Stones"; const char msg_selectDisputed[] = "Select Disputed Stones"; const char msg_whiteWon[] = "Game Over: White Won"; const char msg_blackWon[] = "Game Over: Black Won"; const char msg_jigo[] = "Game Over: Jigo (Tie Game)"; const char msg_timeLossInfo[] = "Game Over: %s has run out of time"; const char msg_disputeAnnounce[] = "Dispute (%s): %s to play"; const char msg_alive[] = "Alive"; const char msg_dead[] = "Dead"; const char msg_disputeOverAlive[] = "At least one disputed stone is still alive, so they will all stay on " "the board. You may now select more dead stones, or press \"Done\"."; const char msg_disputeOverDead[] = "All disputed stones are dead, so they will be removed from the board. " "You may now select more dead stones, or press \"Done\"."; const char msg_scoreKillsComment[] = "The game is over. Final score:\n" " White = %d territory + %d captures + %g komi%s = %g\n" " Black = %d territory + %d captures%s = %g\n"; const char msg_scoreNoKillsComment[] = "The game is over. Final score:\n" " White = %d territory + %d living stones + %g dame + %g komi%s = %g\n" " Black = %d territory + %d living stones + %g dame%s = %g\n"; const char msg_ingPenaltyComment[] = " - %d Ing Time Penalty"; const char msg_winnerComment[] = "%s wins by %g."; const char msg_jigoComment[] = "Jigo (Tie game)."; const char msg_gameIsOver[] = "The game is over. %s"; const char msg_saveGameName[] = "Enter the file name for the game:"; const char msg_timeLoss[] = "%s has run out of time. %s wins."; const char msg_reallyQuitGame[] = "You have changed this game since you last saved it. Are you sure that " "you want to quit without saving?"; /* From "goban.c" */ const char msg_say[] = "Say"; const char msg_both[] = "Both"; const char msg_kib[] = "Kib"; /* From movechain.c */ const char msg_mcReadErr[] = "System error \"%s\" occurred while trying to read " " file \"%s\"."; const char msg_badSGFFile[] = "File \"%s\" has %s on line %d. It " "cannot be read in."; const char msg_sgfBadToken[] = "a bad token"; const char msg_sgfEarlyEOF[] = "an unexpected EOF"; const char msg_sgfBadLoc[] = "a bad board position"; const char msg_sgfBadArg[] = "a bad argument"; /* From editBoard.c */ const char msg_printGame[] = "Print Game"; const char msg_noSuchGame[] = "Sorry, file \"%s\" cannot be found. To create a new smart-go file, " "use \"New Game\" from the control panel, then press \"Edit Game\" " "once the game has started."; const char msg_reallyQuit[] = "File \"%s\" has been changed since you last saved it. Are you sure that " "you want to quit and lose your changes?"; const char msg_noCancel[] = "No, Cancel"; const char msg_yesQuit[] = "Yes, Quit"; const char msg_changeNodeWhileScoring[] = "You cannot change nodes while " "you are scoring a game. Please change to a different tool."; /* From editTools.c */ const char *msg_toolNames[] = { "Play Game", "Edit Board", "Compute Score", "Add Triangle", "Add Square", "Add Circle", "Add Letter", "Number Stones"}; const char *msg_toolDesc1[] = { "Click to play a stone", "Click to add/remove white stones", "Click to mark stones as dead", "Click to add/remove triangle marks", "Click to add/remove square marks", "Click to add/remove circle marks", "Click to add/remove letters", "Click to add/remove numbers starting at 1"}; const char *msg_toolDesc2[] = { "Shift-click to go to when a move was made", "Shift-click to add/remove black stones", "Press \"Done\" to record score", "Shift-click to mark groups of stones", "Shift-click to mark groups of stones", "Shift-click to mark groups of stones", "", "Shift-click to add/remove move numbers"}; const char msg_killNode[] = "Delete Moves"; const char msg_moveNode[] = "Reorder Moves"; /* From "editInfo.c" */ const char msg_editInfoTitle[] = "SGF Game Info"; const char msg_copyrightC[] = "Copyright:"; const char msg_gameTitle[] = "Title:"; const char msg_result[] = "Result:"; const char msg_wStoneName[] = CGBUTS_WSTONECHAR " Name:"; const char msg_bStoneName[] = CGBUTS_BSTONECHAR " Name:"; const char msg_wRank[] = CGBUTS_WSTONECHAR " Rank:"; const char msg_bRank[] = CGBUTS_BSTONECHAR " Rank:"; const char msg_handicapC[] = "Handicap:"; const char msg_komiC[] = "Komi:"; const char msg_date[] = "Date:"; const char msg_place[] = "Place:"; const char msg_event[] = "Event:"; const char msg_source[] = "Source:"; /* From gmpSetup.c */ const char msg_gmpSetup[] = "Go Modem Protocol Setup"; const char *msg_gmpPlayers[] = {CGBUTS_WSTONECHAR " White Player", CGBUTS_BSTONECHAR " Black Player"}; const char *msg_gmpTypes[] = {"Program", "Device", "Human", "NNGS", "IGS", "Local Port", "Remote Port", BUTMENU_OLEND}; const char msg_program[] = "Program"; const char msg_device[] = "Device"; const char msg_machineName[] = "Machine Name"; const char msg_port[] = "Port"; const char msg_username[] = "Username"; const char msg_password[] = "Password"; const char msg_waitingForGame[] = "Waiting for go modem handshaking to complete."; const char msg_noUndoFromGmpToClient[] = "A request to undo the last move came from the go modem protocol " "connection. This is not supported when you are playing on a go server. " "The undo request will be ignored."; const char msg_badPortNum[] = "\"%s\" is not a valid port. Your ports should be a value from 1 through " "65535. \"26276\" is the default port."; const char msg_progRunErr[] = "System error \"%s\" occurred while trying to run program \"%s\"."; const char msg_devOpenErr[] = "System error \"%s\" occurred while trying to open device program \"%s\"."; const char msg_gmpTooBig[] = "The go modem protocol does not permit games to be played on a board " "larger than 22x22."; /* From gmpPlay.c */ const char msg_gmpMoveOutsideGame[] = "A move was received from the go modem protocol when the game was not " "in progress!"; const char msg_gmpBadMove[] = "An illegal move at location %s was received from the go modem protocol."; const char msg_undoRequested[] = "Player %s requested to undo %d moves."; const char msg_badNewGameReq[] = "Player %s wants to start a new game. You may restart a new game " "manually if you wish."; const char msg_gmpCouldntStart[] = "Command line \"%s\" could not be executed. Please make sure that you have " "completely specified the programs path."; const char msg_gmpProgDied[] = "Program \"%s\" exitted unexpectedly with status %d."; const char msg_gmpProgKilled[] = "Program \"%s\" was unexpectedly killed by signal %d."; const char msg_gmpProgWhyDead[] = "Program \"%s\" is dead, but I can't figure out why."; /* From gmp.c */ const char msg_gmpDead[] = "System error \"%s\" occurred over the go modem protocol link."; const char msg_gmpTimeout[] = "The go modem protocol connection has timed out."; const char msg_gmpSendBufFull[] = "The go modem protocol is out of send buffer space."; /* From cliLogin.c */ const char *msg_loginDesc[] = { "Please enter your NNGS username and password here. If you do not yet " "have an account, just leave the password blank and you will be logged in " "as an unregistered user.", "Please enter your IGS username and password here. If you do not yet " "have an account, fill in \"guest\" for your username."}; const char msg_usernameColon[] = "Username:"; const char msg_passwordColon[] = "Password:"; const char msg_cliOpenSocket[] = "Error \"%s\" while trying to open a socket to contact %s."; const char msg_cliLookup[] = "The machine \"%s\" couldn't be found in host lookup tables. Either " "this machine does not exist or there is something wrong with your " "name server."; const char msg_cliConnect[] = "Error \"%s\" occurred while trying to connect to %s."; const char msg_cliHangup[] = "Your connection to server %s was lost due to \"%s\"."; const char msg_notAGuest[] = "Sorry, the username \"%s\" seems to be " "taken already! You must either supply a password or choose another name " "to use while you are a guest."; const char msg_guest[] = "You have logged in as a guest. You may use " "the \"register\" command to get a full account."; const char msg_loginFailed[] = "Sorry, your password seems to be wrong " "for the account name you gave. Please try another password or another " "account."; const char msg_login[] = "The connection to %s has been established. " "Login is in progress."; /* From client/board.c */ const char msg_cliGameName[] = "Game %d: %s %s (W) vs. %s %s (B)"; const char msg_close[] = "Close"; const char msg_adjourn[] = "Adjourn"; const char msg_resign[] = "Resign"; const char msg_yesResign[] = "Yes, Resign"; const char msg_reallyResign[] = "You have pressed \"Resign\" which will " "end the game and give your opponent victory. Are you sure that you " "want to do this?"; const char msg_cliGameBadMove[] = "Move \"%s\" in game %d came from the " "server. This does not seem to be a legal move. Sorry, I'm not sure what " "to do now."; /* From client/conn.c */ const char msg_commandError[] = "The command \"%s\" exited with error " "return code %d."; /* From client/look.c */ const char msg_cliLookName[] = "%s %s (W) vs. %s %s (B)"; const char msg_cliLookInfo[] = "Static Game Board"; /* From client/main.c */ const char msg_log[] = "Log"; const char msg_players[] = "Players"; const char msg_games[] = "Games"; /* From client/game.c */ const char msg_gameGoneResign[] = "The game has ended; %s has resigned. Press the \"Close\" button to " "remove this board."; const char msg_gameResultResign[] = "Move %d: %s resigns"; const char msg_gameGoneAdjourn[] = "The game has been adjourned. Press the \"Close\" button to remove this " "board."; const char msg_gameResultAdjourn[] = "Move %d: Game adjourned"; const char msg_gameGoneTime[] = "The game has ended; %s ran out of time and lost. Press the \"Close\" " "button to remove this board."; const char msg_gameResultTime[] = "Move %d: %s runs out of time"; const char msg_gameGoneScore[] = "The game has ended. The final score is White %g points, Black %g " "points. %s wins."; const char msg_gameResultScore[] = "Move %d: %s wins, %g to %g"; const char msg_gameGone[] = "This game has ended on the server. You can " "continue to look at the game, but your kibitzes, etc. will not be seen " "by other players."; const char msg_gameListDesc[] = "\t#\tWhite\t\tBlack\tMv\tSz\tH\tKm\tFl\tOb"; const char msg_gameBadElf[] = " Cgoban is having trouble interpreting data from the server. This " "probably means that this cgoban binary was built on an old Linux Elf " "system. Older Linux Elf systems have a bug in sscanf that prevents " "cgoban from functioning properly. Please see the cgoban README for more " "information."; /* From client/player.c */ const char msg_name[] = "Name"; const char msg_braceRank[] = "[Rank]"; const char msg_state[] = "State"; const char msg_playerListDesc[] = "\tIdle\tGm"; /* From setup.c */ const char msg_selServer[] = "Server to Edit"; const char msg_setupTitle[] = "Cgoban Setup"; const char msg_gsCompName[] = "Machine Name:"; const char msg_gsPortNum[] = "Port Number:"; const char msg_clientBadPortNum[] = "\"%s\" is not a valid port. Your ports should be a value from 1 through " "65535. The default ports are 9696 for NNGS servers and 6969 for " "IGS servers."; const char msg_srvConfig[] = "Connecting To Server"; const char msg_directConn[] = "Connect Directly To Server"; const char msg_connCmdLabel[] = "Connecting Command:"; const char msg_miscellaneous[] = "Miscellaneous"; const char msg_showCoordinates[] = "Show Coordinates Around Boards"; const char msg_numberKibitzes[] = "Number Kibitzes"; const char msg_hiContrast[] = "High Contrast Stones"; const char msg_noTypo[] = "Anti-Slip Moving"; const char msg_setupSrvName[] = "Server Name:"; const char msg_setupProtocol[] = "Server Protocol:"; const char msg_warnLimit[] = "Time Warning Limit (secs):"; /* From client/match.c */ const char msg_swapColors[] = "Swap Colors"; const char msg_cliGameSetup[] = "Server Game Setup"; const char msg_cliGameSetupSent[] = "Server Game Setup - Challenge Sent"; const char msg_cliGameSetupRej[] = "Server Game Setup - Challenge Rejected"; const char msg_cliGameSetupRecvd[] = "Server Game Setup - Challenge Received"; const char msg_freeGame[] = "Free (Unrated) Game"; const char msg_youDontExist[] = "Sorry, an error has happened. Somehow " "you don't seem to be in the player list, so I can't start up the " "challenge! You might want to try pressing " "the \"reload\" button on the player list to see if that helps. This may " "also mean that you are a guest on IGS."; /* From "sgfPlay.c" */ const char msg_badMoveInSgf[] = "The SGF file has \"%s\" as move " "number %d. This is not a legal move, so it will not be placed on the " "board"; cgoban-1.9.14/src/plasma.c0000664000671000067100000000644107043224471010744 /* * src/xio/plasma.c, part of Complete Goban (game program) * Copyright (C) 1994-1995 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include "plasma.h" #define FACTOR 0.7 #define SIZE PLASMA_SIZE #define STRETCH 3 static void vert(int *cloud, int step, int skew, Rnd *rnd); static void diag(int *, int, int, Rnd *), perp(int *, int, int, Rnd *); static int my_random(int limit, Rnd *rnd); uchar *plasma(void) { static bool done = FALSE; int *cloud, x; Rnd *rnd; static unsigned char *cout = NULL; int step, i; float fskew; if (done) return(cout); done = TRUE; rnd = rnd_create(time(NULL)); cout = wms_malloc(SIZE * SIZE * sizeof(char)); fskew = (float)(750 << 8); cloud = wms_malloc(SIZE * (SIZE+1) * sizeof(int)); assert(cloud != NULL); if (cloud == NULL) { fprintf(stderr, "Could not allocate enough memory.\n"); exit(1); } *cloud = my_random(256 << 16, rnd); for (step = SIZE/2; step; step /= 2) { diag(cloud, step, (int)fskew, rnd); fskew *= FACTOR; if (fskew < 1.0) fskew = 1.0; perp(cloud, step, (int)fskew, rnd); fskew *= FACTOR; if (fskew < 1.0) fskew = 1.0; } #if STRETCH for (i = PLASMA_SIZE*PLASMA_SIZE/(1<= 0; i -= PLASMA_SIZE) { memcpy(cloud+(i<>= 1) { fskew = 1.0; vert(cloud, step, (int)fskew, rnd); fskew *= FACTOR*FACTOR; if (fskew < 1.0) fskew = 1.0; } #endif /* STRETCH */ for (i = 0; i < SIZE*SIZE; ++i) { x = (cloud[i] >> 8) & 511; if (x > 255) x = 511 - x; cout[i] = x; } wms_free(cloud); rnd_destroy(rnd); return(cout); } #define CLACC(x, y) cloud[(x) + ((y)*SIZE)] static void diag(int *cloud, int step, int skew, Rnd *rnd) { int i, j; int sum; for (i = 0; i < SIZE; i += step) for (j = 0; j < SIZE; j += step) { if (((i & step) != 0) && ((j & step) != 0)) { sum = (CLACC(i-step, j-step) + CLACC(i-step, (j+step)&(SIZE-1)) + CLACC((i+step)&(SIZE-1), j-step) + CLACC((i+step)&(SIZE-1), (j+step)&(SIZE-1))) / 4; CLACC(i, j) = sum + my_random(skew, rnd); } } } static void perp(int *cloud, int step, int skew, Rnd *rnd) { int i, j; int sum; for (i = 0; i < SIZE; i += step) for (j = 0; j < SIZE; j += step) { if ((i & step) != (j & step)) { sum = (CLACC((i-step)&(SIZE-1), j) + CLACC(i, (j+step)&(SIZE-1)) + CLACC((i+step)&(SIZE-1), j) + CLACC(i, (j-step)&(SIZE-1))) / 4.0; CLACC(i, j) = sum + my_random(skew, rnd); } } } static void vert(int *cloud, int step, int skew, Rnd *rnd) { int i, j; int sum; for (i = 0; i < SIZE; ++i) for (j = step; j < SIZE; j += (step<<1)) { sum = (CLACC((i-1)&(SIZE-1), j-step) + CLACC(i, j-step) + CLACC((i+1)&(SIZE-1), j-step) + CLACC((i-1)&(SIZE-1), j+step) + CLACC(i, j+step) + CLACC((i+1)&(SIZE-1), j+step)) / 6.0; CLACC(i, j) = sum + my_random(skew, rnd); } } static int my_random(int limit, Rnd *rnd) { int i; i = rnd_int(rnd); if (i & 8) return(rnd_int(rnd) % limit); else return(-(rnd_int(rnd) % limit)); } cgoban-1.9.14/src/setup.c0000664000671000067100000004347307043224471010635 /* * src/lsetup.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cm2pm.h" #include "msg.h" #include "plasma.h" #ifdef _SETUP_H_ Levelization ERror #endif #include "setup.h" /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut unmap(ButWin *win); static ButOut map(ButWin *win); static ButOut resize(ButWin *win); static ButOut subwinResize(ButWin *win); static ButOut destroy(ButWin *win); static ButOut newComp(But *but, const char *val); static ButOut newPort(But *but, const char *val); static ButOut newConnCmd(But *but, const char *val); static ButOut newDirect(But *but, bool value); static ButOut newCoord(But *but, bool value); static ButOut newNumKibs(But *but, bool value); static ButOut newNoTypo(But *but, bool value); static ButOut ok(But *but); static ButOut newSrvNum(But *but, int value); static ButOut newName(But *but, const char *newVal); static ButOut newProto(But *but, int newVal); static ButOut newHiContrast(But *but, bool value); static ButOut newWarnLimit(But *but, const char *val); /********************************************************************** * Functions **********************************************************************/ #define boxHeight(lines, fh, bw) ((lines) * (2 * (fh) + (bw)) + 3 * (bw)) #define textOff(line, fh, bw) ((line) * (2 * (fh) + (bw)) + 2 * (bw)) Setup *setup_create(Cgoban *cg, void (*destroyCallback)(Setup *setup, void *packet), void (*newServerCallback)(Setup *setup, void *packet), void *packet) { Setup *setup; bool isDirect; bool err; int i; int h, minH, bw; ButWin *subwin; const char *menuOpts[SETUP_MAXSERVERS + 1]; char tmpWarnLimit[10]; assert(MAGIC(cg)); setup = wms_malloc(sizeof(Setup)); MAGIC_SET(setup); setup->cg = cg; setup->destroyCallback = destroyCallback; setup->newServerCallback = newServerCallback; setup->packet = packet; bw = butEnv_stdBw(cg->env); minH = cg->fontH * 12 + bw * 16; h = (int)(minH * 2 * clp_getDouble(cg->clp, "config.h") + 0.5); setup->win = butWin_create(setup, cg->env, "Cgoban Setup", minH * 2, h, unmap, map, resize, destroy); butWin_setMinH(setup->win, minH); butWin_setMaxH(setup->win, cg->fontH * 4 + bw * 8 + boxHeight(8, cg->fontH, bw) + cg->fontH * 2 + boxHeight(4, cg->fontH, bw)); i = clp_iGetInt(cg->clp, "config.x", &err); if (!err) butWin_setX(setup->win, i); i = clp_iGetInt(cg->clp, "config.y", &err); if (!err) butWin_setY(setup->win, i); butWin_activate(setup->win); setup->bg = butBoxFilled_create(setup->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(setup->bg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); setup->title = butText_create(setup->win, 1, BUT_DRAWABLE, msg_setupTitle, butText_center); butText_setFont(setup->title, 2); setup->swin = abutSwin_create(setup, setup->win, 1, ABUTSWIN_LSLIDE, subwinResize); subwin = setup->swin->win; setup->srvBox = butBoxFilled_create(subwin, 0, BUT_DRAWABLE); setup->srvTitle = butText_create(subwin, 1, BUT_DRAWABLE, msg_srvConfig, butText_center); butText_setFont(setup->srvTitle, 2); setup->srvNum = 0; for (i = 0; i < SETUP_MAXSERVERS; ++i) { menuOpts[i] = clp_getStrNum(cg->clp, "client.server", i); } menuOpts[i] = BUTMENU_OLEND; setup->srvMenu = butMenu_downCreate(newSrvNum, setup, subwin, 2, 3, BUT_DRAWABLE|BUT_PRESSABLE, msg_selServer, menuOpts, 0); setup->srvName = butTextin_create(newName, setup, subwin, 1, BUT_DRAWABLE|BUT_PRESSABLE, clp_getStrNum(cg->clp, "client.server", setup->srvNum), 100); setup->srvNameLabel = butText_create(subwin, 1, BUT_DRAWABLE, msg_setupSrvName, butText_left); setup->srvProto = butRadio_create(newProto, setup, subwin, 1, BUT_DRAWABLE|BUT_PRESSABLE, (clp_getStrNum(cg->clp, "client.protocol", setup->srvNum)[0] == 'n'), 2); setup->srvProtoLabel = butText_create(subwin, 1, BUT_DRAWABLE, msg_setupProtocol, butText_left); setup->igsLabel = butText_create(subwin, 2, BUT_DRAWABLE|BUT_PRESSTHRU, "IGS", butText_center); setup->nngsLabel = butText_create(subwin, 2, BUT_DRAWABLE|BUT_PRESSTHRU, "NNGS", butText_center); isDirect = (clp_getStrNum(cg->clp, "client.direct", setup->srvNum)[0] == 't'); setup->srvDirectLabel = butText_create(subwin, 1, BUT_DRAWABLE, msg_directConn, butText_left); setup->srvDirect = butCb_create(newDirect, setup, subwin, 1, BUT_DRAWABLE|BUT_PRESSABLE, isDirect); setup->srvComp = butText_create(subwin, 1, BUT_DRAWABLE, msg_gsCompName, butText_left); setup->srvCompIn = butTextin_create(newComp, setup, subwin, 1, BUT_DRAWABLE, clp_getStrNum(cg->clp, "client.address", setup->srvNum), 100); setup->srvPort = butText_create(subwin, 1, BUT_DRAWABLE, msg_gsPortNum, butText_left); setup->srvPortIn = butTextin_create(newPort, setup, subwin, 1, BUT_DRAWABLE, clp_getStrNum(cg->clp, "client.port", setup->srvNum), 20); setup->srvCmdLabel = butText_create(subwin, 1, BUT_DRAWABLE, msg_connCmdLabel, butText_left); setup->srvCmd = butTextin_create(newConnCmd, setup, subwin, 1, BUT_DRAWABLE, clp_getStrNum(cg->clp, "client.connCmd", setup->srvNum), 100); newDirect(setup->srvDirect, isDirect); setup->miscBox = butBoxFilled_create(subwin, 0, BUT_DRAWABLE); setup->miscTitle = butText_create(subwin, 1, BUT_DRAWABLE, msg_miscellaneous, butText_center); butText_setFont(setup->miscTitle, 2); setup->coordLabel = butText_create(subwin, 1, BUT_DRAWABLE, msg_showCoordinates, butText_left); setup->coord = butCb_create(newCoord, setup, subwin, 1, BUT_DRAWABLE|BUT_PRESSABLE, clp_getBool(cg->clp, "board.showCoords")); setup->hiLabel = butText_create(subwin, 1, BUT_DRAWABLE, msg_hiContrast, butText_left); setup->hi = butCb_create(newHiContrast, setup, subwin, 1, BUT_DRAWABLE|BUT_PRESSABLE, clp_getBool(cg->clp, "hiContrast")); setup->numKibsLabel = butText_create(subwin, 1, BUT_DRAWABLE, msg_numberKibitzes, butText_left); setup->numKibs = butCb_create(newNumKibs, setup, subwin, 1, BUT_DRAWABLE|BUT_PRESSABLE, clp_getBool(cg->clp, "client.numberKibitz")); setup->noTypoLabel = butText_create(subwin, 1, BUT_DRAWABLE, msg_noTypo, butText_left); setup->noTypo = butCb_create(newNoTypo, setup, subwin, 1, BUT_DRAWABLE|BUT_PRESSABLE, clp_getBool(cg->clp, "client.noTypo")); setup->warnLabel = butText_create(subwin, 1, BUT_DRAWABLE, msg_warnLimit, butText_left); i = clp_getInt(cg->clp, "client.warnLimit"); sprintf(tmpWarnLimit, "%d", i); setup->warnLimit = butTextin_create(newWarnLimit, setup, subwin, 1, BUT_DRAWABLE|BUT_PRESSABLE, tmpWarnLimit, 10); setup->help = butCt_create(cgoban_createHelpWindow, &help_configure, setup->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_help); setup->ok = butCt_create(ok, setup, setup->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_ok); return(setup); } void setup_destroy(Setup *setup, bool propagate) { assert(MAGIC(setup)); if (propagate) setup->destroyCallback(setup, setup->packet); if (setup->win) butWin_destroy(setup->win); MAGIC_UNSET(setup); wms_free(setup); } static ButOut unmap(ButWin *win) { return(0); } static ButOut map(ButWin *win) { return(0); } static ButOut resize(ButWin *win) { ButEnv *env = butWin_env(win); Setup *setup = butWin_packet(win); int y, w, h; int fontH, bw; assert(MAGIC(setup)); w = butWin_w(win); h = butWin_h(win); fontH = setup->cg->fontH; bw = butEnv_stdBw(env); but_resize(setup->bg, 0, y = 0, w, h); but_resize(setup->title, bw*2, y += bw*2, w - bw*4, fontH * 2); abutSwin_resize(setup->swin, bw*2, y += fontH * 2 + bw, w - bw*4, h - fontH * 4 - bw * 6, (butEnv_fontH(env, 0) * 3) / 2, butEnv_fontH(env, 0)); but_resize(setup->help, bw * 2, h - (fontH * 2 + bw * 2), (w - bw * 5) / 2, fontH * 2); but_resize(setup->ok, (w + bw) / 2, h - (fontH * 2 + bw * 2), w - bw*2 - (w + bw) / 2, fontH * 2); return(0); } static ButOut subwinResize(ButWin *win) { AbutSwin *swin; ButEnv *env = butWin_env(win); Setup *setup; int y, w; int fontH, bw; swin = butWin_packet(win); assert(MAGIC(swin)); setup = swin->packet; assert(MAGIC(setup)); w = butWin_w(win); fontH = setup->cg->fontH; bw = butEnv_stdBw(env); y = 0; but_resize(setup->srvBox, 0, y, w, boxHeight(8, fontH, bw) + fontH*2); but_resize(setup->srvTitle, bw*2, y + textOff(0, fontH, bw), w - bw*4, fontH * 2); but_resize(setup->srvMenu, bw * 2, y + textOff(1, fontH, bw), w - bw * 4, fontH * 4); but_resize(setup->srvNameLabel, bw * 2, y + textOff(2, fontH, bw) + fontH * 2, w/2 - bw*2, fontH * 2); but_resize(setup->srvName, w/2, y + textOff(2, fontH, bw) + fontH * 2, w - (w/2 + bw*2), fontH * 2); but_resize(setup->srvProtoLabel, bw * 2, y + textOff(3, fontH, bw) + fontH * 2, w/2 - bw*2, fontH * 2); but_resize(setup->srvProto, w/2, y + textOff(3, fontH, bw) + fontH * 2, w - (w/2 + bw*2), fontH * 2); butText_resize(setup->igsLabel, w/2 + (w - (w/2 + bw*2))/4, y + textOff(3, fontH, bw) + fontH * 2, fontH * 2); butText_resize(setup->nngsLabel, w/2 + (w - (w/2 + bw*2)) - (w - (w/2 + bw*2))/4, y + textOff(3, fontH, bw) + fontH * 2, fontH * 2); but_resize(setup->srvDirectLabel, bw * 2, y + textOff(4, fontH, bw) + fontH*2, w - (bw * 4 + fontH * 2), fontH * 2); but_resize(setup->srvDirect, w - (bw*2 + fontH * 2), y + textOff(4, fontH, bw) + fontH * 2, fontH * 2, fontH * 2); but_resize(setup->srvComp, bw * 2, y + textOff(5, fontH, bw) + fontH * 2, w/2 - bw*2, fontH * 2); but_resize(setup->srvCompIn, w/2, y + textOff(5, fontH, bw) + fontH * 2, w - (w/2 + bw*2), fontH * 2); but_resize(setup->srvPort, bw * 2, y + textOff(6, fontH, bw) + fontH * 2, w/2 - bw*2, fontH * 2); but_resize(setup->srvPortIn, w/2, y + textOff(6, fontH, bw) + fontH * 2, w - (w/2 + bw*2), fontH * 2); but_resize(setup->srvCmdLabel, bw * 2, y + textOff(7, fontH, bw) + fontH * 2, w/2 - bw*2, fontH * 2); but_resize(setup->srvCmd, w/2, y + textOff(7, fontH, bw) + fontH * 2, w - (w/2 + bw*2), fontH * 2); y += boxHeight(8, fontH, bw) + fontH * 2; but_resize(setup->miscBox, 0, y, w, boxHeight(6, fontH, bw)); but_resize(setup->miscTitle, bw*2, y + textOff(0, fontH, bw), w - bw*4, fontH * 2); but_resize(setup->coordLabel, bw * 2, y + textOff(1, fontH, bw), w - (bw * 4 + fontH * 2), fontH * 2); but_resize(setup->coord, w - (bw*2 + fontH * 2), y + textOff(1, fontH, bw), fontH * 2, fontH * 2); but_resize(setup->hiLabel, bw * 2, y + textOff(2, fontH, bw), w - (bw * 4 + fontH * 2), fontH * 2); but_resize(setup->hi, w - (bw*2 + fontH * 2), y + textOff(2, fontH, bw), fontH * 2, fontH * 2); but_resize(setup->numKibsLabel, bw * 2, y + textOff(3, fontH, bw), w - (bw * 4 + fontH * 2), fontH * 2); but_resize(setup->numKibs, w - (bw*2 + fontH * 2), y + textOff(3, fontH, bw), fontH * 2, fontH * 2); but_resize(setup->noTypoLabel, bw * 2, y + textOff(4, fontH, bw), w - (bw * 4 + fontH * 2), fontH * 2); but_resize(setup->noTypo, w - (bw*2 + fontH * 2), y + textOff(4, fontH, bw), fontH * 2, fontH * 2); but_resize(setup->warnLabel, bw * 2, y + textOff(5, fontH, bw), w - (bw * 4 + fontH * 2), fontH * 2); but_resize(setup->warnLimit, w/2, y + textOff(5, fontH, bw), w - (w/2 + bw*2), fontH * 2); y += boxHeight(6, fontH, bw); if (y != butWin_h(win)) { butCan_resizeWin(win, butWin_w(win), y, TRUE); } return(0); } static ButOut destroy(ButWin *win) { Setup *setup = butWin_packet(win); assert(MAGIC(setup)); clp_setInt(setup->cg->clp, "config.x", butWin_x(win)); clp_setInt(setup->cg->clp, "config.y", butWin_y(win)); clp_setDouble(setup->cg->clp, "config.h", (double)butWin_h(win) / (double)butWin_w(win)); setup->win = NULL; /* It's dead already. */ setup_destroy(setup, TRUE); return(0); } static ButOut newComp(But *but, const char *val) { Setup *setup = but_packet(but); assert(MAGIC(setup)); clp_setStrNum(setup->cg->clp, "client.address", val, setup->srvNum); but_setFlags(but, BUT_NOKEY); return(0); } static ButOut newPort(But *but, const char *val) { Setup *setup = but_packet(but); ButOut result = 0; Str errorMsg; int test; bool err; assert(MAGIC(setup)); err = FALSE; test = wms_atoi(val, &err); if ((test < 0) || (test > 65535) || err) { str_init(&errorMsg); str_print(&errorMsg, msg_clientBadPortNum, val); cgoban_createMsgWindow(setup->cg, "Cgoban Error", str_chars(&errorMsg)); str_deinit(&errorMsg); result = BUTOUT_ERR; } else clp_setStrNum(setup->cg->clp, "client.port", val, setup->srvNum); but_setFlags(but, BUT_NOKEY); return(result); } static ButOut ok(But *but) { Setup *setup = but_packet(but); ButOut result = 0; assert(MAGIC(setup)); result |= newComp(setup->srvCompIn, butTextin_get(setup->srvCompIn)); result |= newPort(setup->srvPortIn, butTextin_get(setup->srvPortIn)); result |= newConnCmd(setup->srvCmd, butTextin_get(setup->srvCmd)); result |= newName(setup->srvName, butTextin_get(setup->srvName)); newWarnLimit(setup->warnLimit, butTextin_get(setup->warnLimit)); if (!(result & BUTOUT_ERR)) { butWin_destroy(but_win(but)); } return(result); } static ButOut newConnCmd(But *but, const char *val) { Setup *setup = but_packet(but); assert(MAGIC(setup)); but_setFlags(but, BUT_NOKEY); clp_setStrNum(setup->cg->clp, "client.connCmd", val, setup->srvNum); return(0); } static ButOut newDirect(But *but, bool value) { Setup *setup = but_packet(but); uint directFlags; assert(MAGIC(setup)); if (value) directFlags = BUT_DRAWABLE | BUT_PRESSABLE; else directFlags = BUT_DRAWABLE | BUT_NOPRESS | BUT_NOKEY; clp_setStrNum(setup->cg->clp, "client.direct", (value ? "t" : "f"), setup->srvNum); butText_setColor(setup->srvComp, BUT_FG, !value); but_setFlags(setup->srvCompIn, directFlags); butText_setColor(setup->srvPort, BUT_FG, !value); but_setFlags(setup->srvPortIn, directFlags); butText_setColor(setup->srvCmdLabel, BUT_FG, value); but_setFlags(setup->srvCmd, directFlags ^ (BUT_PRESSABLE|BUT_NOPRESS|BUT_NOKEY)); return(0); } static ButOut newCoord(But *but, bool value) { Setup *setup = but_packet(but); assert(MAGIC(setup)); clp_setBool(setup->cg->clp, "board.showCoords", value); setup->cg->showCoords = value; butEnv_resizeAll(butWin_env(but_win(but))); return(0); } static ButOut newHiContrast(But *but, bool value) { Setup *setup = but_packet(but); assert(MAGIC(setup)); clp_setBool(setup->cg->clp, "hiContrast", value); setup->cg->cgbuts.hiContrast = value; cm2OldPm(setup->cg->env, plasma(), PLASMA_SIZE,PLASMA_SIZE, CGBUTS_COLORBOARD(0), 256, setup->cg->boardPixmap, value); cgbuts_redraw(&setup->cg->cgbuts); return(0); } static ButOut newNumKibs(But *but, bool value) { Setup *setup = but_packet(but); assert(MAGIC(setup)); clp_setBool(setup->cg->clp, "client.numberKibitz", value); return(0); } static ButOut newNoTypo(But *but, bool value) { Setup *setup = but_packet(but); assert(MAGIC(setup)); clp_setBool(setup->cg->clp, "client.noTypo", value); setup->cg->cgbuts.holdEnabled = value; return(0); } static ButOut newProto(But *but, int newVal) { Setup *setup = but_packet(but); static const char *protos[] = {"i", "n"}; assert(MAGIC(setup)); clp_setStrNum(setup->cg->clp, "client.protocol", protos[newVal], setup->srvNum); return(0); } static ButOut newName(But *but, const char *newVal) { Setup *setup = but_packet(but); assert(MAGIC(setup)); but_setFlags(but, BUT_NOKEY); clp_setStrNum(setup->cg->clp, "client.server", newVal, setup->srvNum); butMenu_setOptionName(setup->srvMenu, newVal, setup->srvNum); setup->newServerCallback(setup, setup->packet); return(0); } static ButOut newSrvNum(But *but, int value) { Setup *setup = but_packet(but); ButOut result = 0; Clp *clp = setup->cg->clp; result |= newComp(setup->srvCompIn, butTextin_get(setup->srvCompIn)); result |= newPort(setup->srvPortIn, butTextin_get(setup->srvPortIn)); result |= newConnCmd(setup->srvCmd, butTextin_get(setup->srvCmd)); result |= newName(setup->srvName, butTextin_get(setup->srvName)); setup->srvNum = value; butTextin_set(setup->srvName, clp_getStrNum(clp, "client.server", value), FALSE); butRadio_set(setup->srvProto, (clp_getStrNum(clp, "client.protocol", value)[0] == 'n'), FALSE); butCb_set(setup->srvDirect, (clp_getStrNum(clp, "client.direct", value)[0] == 't'), TRUE); butTextin_set(setup->srvCompIn, clp_getStrNum(clp, "client.address", value), FALSE); butTextin_set(setup->srvPortIn, clp_getStrNum(clp, "client.port", value), FALSE); butTextin_set(setup->srvCmd, clp_getStrNum(clp, "client.connCmd", value), FALSE); return(result); } static ButOut newWarnLimit(But *but, const char *val) { Setup *setup = but_packet(but); int newVal; Clp *clp = setup->cg->clp; newVal = atoi(val); setup->cg->cgbuts.timeWarn = newVal; clp_setInt(clp, "client.warnLimit", newVal); return(0); } cgoban-1.9.14/src/sgf.c0000664000671000067100000003135607043224471010251 /* * src/sgf.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include "cgoban.h" #include "msg.h" #ifdef _SGF_H_ LEVELIZATION ERROR #endif #include "sgf.h" /********************************************************************** * Constants **********************************************************************/ #define POOLSIZE 100 /********************************************************************** * Data Types **********************************************************************/ typedef struct ElemPool_struct { struct ElemPool_struct *next; SgfElem elems[POOLSIZE]; MAGIC_STRUCT } ElemPool; /********************************************************************** * Globals **********************************************************************/ static ElemPool *elemPoolList = NULL; static SgfElem *freeElem = NULL; /********************************************************************** * Forward Declarations **********************************************************************/ static SgfElem *sgfElem_create(Sgf *mc, SgfType type); static void sgfElem_destroy(SgfElem *me); static void sgfElem_copy(Sgf *destSgf, SgfElem *dest, const SgfElem *src); /********************************************************************** * Functions **********************************************************************/ Sgf *sgf_create(void) { Sgf *mc; mc = wms_malloc(sizeof(Sgf)); MAGIC_SET(mc); MAGIC_SET(&(mc->top)); mc->longLoc = FALSE; mc->mode = sgfInsert_main; mc->top.type = sgfType_unknown; mc->top.childH = NULL; mc->top.childT = NULL; mc->top.activeChild = NULL; mc->top.sibling = NULL; mc->top.parent = NULL; mc->top.numChildren = 0; mc->top.mapX = -1; mc->top.mapY = -1; mc->active = &(mc->top); mc->moveNum = 0; return(mc); } void sgf_destroy(Sgf *mc) { SgfElem *me, *nextMe; assert(MAGIC(mc)); me = mc->top.childH; while (me) { assert(MAGIC(me)); nextMe = me->sibling; sgfElem_destroy(me); me = nextMe; } MAGIC_UNSET(mc); wms_free(mc); } void sgf_addCElem(Sgf *mc, SgfType type, GoStone gVal) { SgfElem *me; assert(MAGIC(mc)); me = sgfElem_create(mc, type); assert(MAGIC(me)); me->gVal = gVal; } void sgf_addCIElem(Sgf *mc, SgfType type, GoStone c, int i) { sgf_addCElem(mc, type, c); mc->active->iVal = i; if ((type == sgfType_size) && (i > 19)) mc->longLoc = TRUE; } void sgf_addCSElem(Sgf *mc, SgfType type, GoStone c, const char *s) { SgfElem *se; if (type == sgfType_comment) { se = sgfElem_findTypeInNode(mc->active, sgfType_comment); if (se) { str_copyChars(se->sVal, s); return; } } sgf_addCElem(mc, type, c); mc->active->sVal = str_createChars(s); } void sgf_catComment(Sgf *sgf, const char *s) { SgfElem *se; se = sgfElem_findTypeInNode(sgf->active, sgfType_comment); if (se) { str_catChars(se->sVal, s); } else { sgf_addCElem(sgf, sgfType_comment, goStone_empty); sgf->active->sVal = str_createChars(s); } } void sgf_addCLElem(Sgf *mc, SgfType type, GoStone c, const char *loc) { sgf_addCElem(mc, type, c); assert((strlen(loc) == 4) || (strlen(loc) == 2)); strcpy(mc->active->lVal, loc); } void sgf_addCLSElem(Sgf *mc, SgfType type, GoStone c, const char *loc, const char *str) { sgf_addCElem(mc, type, c); assert((strlen(loc) == 4) || (strlen(loc) == 2)); strcpy(mc->active->lVal, loc); mc->active->sVal = str_createChars(str); } static SgfElem *sgfElem_create(Sgf *mc, SgfType type) { ElemPool *newPool; int i; SgfElem *result, *parent, *childOfResult; if (freeElem == NULL) { newPool = wms_malloc(sizeof(ElemPool)); MAGIC_SET(newPool); newPool->next = elemPoolList; elemPoolList = newPool; for (i = 0; i < POOLSIZE; ++i) { newPool->elems[i].childH = &(newPool->elems[i+1]); newPool->elems[i].sVal = NULL; } newPool->elems[POOLSIZE - 1].childH = NULL; freeElem = &newPool->elems[0]; } result = freeElem; freeElem = freeElem->childH; result->type = type; result->childH = NULL; result->childT = NULL; result->sibling = NULL; result->activeChild = NULL; result->numChildren = 0; MAGIC_SET(result); parent = mc->active; result->mapX = parent->mapX; result->mapY = parent->mapY; result->parent = parent; #if DEBUG if (mc->mode != sgfInsert_inline) { if (type == sgfType_node) { assert((parent->childH == NULL) || (parent->childH->type == sgfType_node)); } else assert(parent->childH == NULL); } #endif /* DEBUG */ switch(mc->mode) { case sgfInsert_main: result->sibling = parent->childH; parent->childH = result; if (result->sibling == NULL) parent->childT = result; break; case sgfInsert_variant: if (parent->childH == NULL) parent->childH = result; else parent->childT->sibling = result; parent->childT = result; break; case sgfInsert_inline: result->childH = parent->childH; result->childT = parent->childT; result->activeChild = parent->activeChild; result->sibling = NULL; parent->childH = parent->childT = result; for (childOfResult = result->childH; childOfResult; childOfResult = childOfResult->sibling) { childOfResult->parent = result; } break; } parent->activeChild = result; assert((parent->childH != parent->childT) || (parent->activeChild == parent->childH)); mc->active = result; return(result); } static void sgfElem_destroy(SgfElem *me) { SgfElem *child, *nextChild; assert(MAGIC(me)); child = me->childH; while (child) { assert(MAGIC(child)); nextChild = child->sibling; sgfElem_destroy(child); child = nextChild; } if (me->sVal) { str_destroy(me->sVal); me->sVal = NULL; } MAGIC_UNSET(me); me->childH = freeElem; freeElem = me; } void sgfElem_destroyActiveChild(SgfElem *parent) { SgfElem *prevChild; SgfElem *deadChild = parent->activeChild; assert(MAGIC(parent)); assert(MAGIC(deadChild)); if (parent->childH == deadChild) { prevChild = NULL; parent->childH = deadChild->sibling; } else { for (prevChild = parent->childH; prevChild->sibling != deadChild; prevChild = prevChild->sibling); prevChild->sibling = deadChild->sibling; } if (parent->childT == deadChild) parent->childT = prevChild; sgfElem_destroy(deadChild); parent->activeChild = parent->childH; } void sgf_setDate(Sgf *mc) { time_t curTime; struct tm *tmTime; char dateStr[20]; time(&curTime); tmTime = localtime(&curTime); sprintf(dateStr, "%04d-%02d-%02d", tmTime->tm_year + 1900, tmTime->tm_mon + 1, tmTime->tm_mday); sgf_addCSElem(mc, sgfType_date, goStone_empty, dateStr); } /* * 0 = Before the first move. * 1 = The first move. * etc. */ void sgf_setActiveNodeNumber(Sgf *mc, int moveNum) { int curMove = 0; SgfElem *me; assert(MAGIC(mc)); me = &mc->top; for (;;) { assert(MAGIC(me)); if (me->activeChild == NULL) { assert(curMove == moveNum); break; } if (me->activeChild->type == sgfType_node) { ++curMove; if (curMove > moveNum) break; } me = me->activeChild; } mc->active = me; } SgfElem *sgf_findType(Sgf *mc, SgfType t) { SgfElem *me; assert(MAGIC(mc)); if (mc->active == &mc->top) return(NULL); for (me = mc->active; me; me = me->parent) { assert(MAGIC(me)); if (me->type == t) return(me); } return(NULL); } SgfElem *sgfElem_findTypeInNode(SgfElem *me, SgfType t) { assert(MAGICNULL(me)); while (me && (me->type != sgfType_node)) { assert(MAGIC(me)); if (me->type == t) return(me); me = me->parent; } return(NULL); } SgfElem *sgf_elemFindType(Sgf *mc, SgfElem *me, SgfType t) { SgfElem *result = NULL; assert(MAGIC(me)); if (me == mc->active) return(NULL); for (me = me->activeChild; (me != NULL) && (me != mc->active); me = me->activeChild) { assert(MAGIC(me)); if (me->type == t) result = me; } if ((me != NULL) && (me->type == t)) result = me; return(result); } SgfElem *sgfElem_findType(SgfElem *me, SgfType t) { SgfElem *result = NULL; assert(MAGIC(me)); for (me = me->activeChild; me != NULL; me = me->activeChild) { assert(MAGIC(me)); if (me->type == t) result = me; } return(result); } SgfElem *sgf_findFirstType(Sgf *mc, SgfType t) { SgfElem *me; assert(MAGIC(mc)); if (mc->active == &mc->top) return(NULL); if (mc->active->type == t) return(mc->active); for (me = mc->top.activeChild; me != mc->active; me = me->activeChild) { assert(MAGIC(me)); if (me->type == t) return(me); } return(NULL); } SgfElem *sgf_elemFindFirstType(Sgf *mc, SgfElem *me, SgfType t) { assert(MAGIC(me)); if (me == mc->active) return(NULL); for (me = me->activeChild; (me != NULL) && (me != mc->active); me = me->activeChild) { assert(MAGIC(me)); if (me->type == t) return(me); } if ((me != NULL) && (me->type == t)) return(me); return(NULL); } SgfElem *sgfElem_findFirstType(SgfElem *me, SgfType t) { assert(MAGIC(me)); for (me = me->activeChild; me != NULL; me = me->activeChild) { assert(MAGIC(me)); if (me->type == t) return(me); } return(NULL); } void sgfElem_newString(SgfElem *me, const char *str) { assert(MAGIC(me)); str_copyChars(me->sVal, str); } void sgfElem_snip(SgfElem *se, Sgf *sgf) { SgfElem *parent, *child, *sibling; if (sgf->active == se) sgf->active = se->parent; parent = se->parent; if (parent->activeChild == se) parent->activeChild = se->activeChild; if (parent->childH == se) { if (se->sibling) { if (se->childH) { se->childT->sibling = se->sibling; se->childT = parent->childT; } else { se->childH = se->sibling; se->childT = parent->childT; } } if (parent->childT == se) { parent->childH = se->childH; parent->childT = se->childT; } } else { for (sibling = parent->childH; sibling->sibling != se; sibling = sibling->sibling); if (se->childH) { sibling->sibling = se->childH; se->childT->sibling = se->sibling; } else { sibling->sibling = se->sibling; } } for (child = se->childH; child; child = child->sibling) { child->parent = parent; } se->childH = se->childT = NULL; sgfElem_destroy(se); } int sgfElem_findMove(SgfElem *se, const char *move, int dir) { int steps; assert(MAGIC(se)); assert((dir == 1) || (dir == -1)); if (dir == 1) steps = 0; else steps = -1; for (;;) { if (dir == 1) { se = se->activeChild; } else { if (steps >= 0) se = se->parent; } if (se == NULL) return(-1); switch(se->type) { case sgfType_node: ++steps; break; case sgfType_setBoard: if (se->gVal == goStone_empty) break; /* Fall through to sgfType_move. */ case sgfType_move: if (!strcmp(move, se->lVal)) { if (steps < 0) steps = 0; return(steps); } break; default: break; } if (steps < 0) steps = 0; } } void sgf_addHandicapStones(Sgf *sgf, GoBoard *board) { int i; for (i = 0; i < goBoard_area(board); ++i) { if (goBoard_stone(board, i) == goStone_black) { sgf_addStone(sgf, goStone_black, goBoard_loc2Sgf(board, i)); } } } void sgf_setHandicap(Sgf *sgf, int handicap) { if (handicap == 1) handicap = 0; sgf_addIElem(sgf, sgfType_handicap, handicap); } Sgf *sgf_copy(const Sgf *src) { Sgf *dest; dest = wms_malloc(sizeof(Sgf)); *dest = *src; dest->mode = sgfInsert_variant; dest->top.childH = dest->top.childT = dest->top.activeChild = NULL; sgfElem_copy(dest, &dest->top, &src->top); dest->active = &dest->top; while (dest->active->activeChild) { dest->active = dest->active->childH; assert(dest->active != NULL); } return(dest); } static void sgfElem_copy(Sgf *destSgf, SgfElem *dest, const SgfElem *src) { SgfElem *srcChild, *destChild; int i; for (srcChild = src->childH; srcChild; srcChild = srcChild->sibling) { destSgf->active = dest; sgfElem_create(destSgf, srcChild->type); destChild = destSgf->active; destChild->gVal = srcChild->gVal; destChild->iVal = srcChild->iVal; assert(destChild->sVal == NULL); if (srcChild->sVal != NULL) { destChild->sVal = str_createStr(srcChild->sVal); } for (i = 0; i < 5; ++i) { destChild->lVal[i] = srcChild->lVal[i]; } sgfElem_copy(destSgf, destChild, srcChild); } dest->activeChild = dest->childH; } cgoban-1.9.14/src/sgfIn.c0000664000671000067100000003733707476005006010546 /* * $Source: /cvsroot/cgoban1/cgoban1/src/sgfIn.c,v $ * $Revision: 1.3 $ * $Author: wmshub $ * $Date: 2002/05/31 23:40:54 $ * * src/sgfInchain.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include #include #include "cgoban.h" #include "sgf.h" #include "sgfIn.h" #include "msg.h" #include "goGame.h" /********************************************************************** * Constants **********************************************************************/ #define POOLSIZE 100 /********************************************************************** * Forward declarations **********************************************************************/ static uint getToken(FILE *f, const char **arg, int *lineCount); static const char *readFile(Sgf *mc, FILE *f, int *lineCount); static const char *arg_getLoc(const char *arg, char *loc); static int arg_getInt(const char *arg, bool *err); static double arg_getDouble(const char *arg, bool *err); static const char *arg_getStr(const char *arg, Str *result); static void arg_getMove(const char *arg, Sgf *mc, GoStone gval, bool *errOut); static void arg_multi(const char *arg, Sgf *mc, SgfType type, GoStone gval, bool *err); static void arg_multiRange(const char *arg, Sgf *mc, SgfType type, GoStone gval, bool *err); static void arg_multiLabel(const char *arg, Sgf *mc, bool *errOut); /********************************************************************** * Functions **********************************************************************/ #define TOKEN1(c) ((int)c & 0xff) #define TOKEN2(c1, c2) (((int)c1 & 0xff) | (((int)c2 << 8) & 0xff00)) Sgf *sgf_createFile(Cgoban *cg, const char *fName, const char **err, bool *noFile) { static Str strErr; static bool firstTime = TRUE; Sgf *mc; SgfElem *me; FILE *f; int c, crCount = 1; const char *problem; bool dummy; if (noFile == NULL) noFile = &dummy; *noFile = FALSE; if (firstTime) { str_init(&strErr); firstTime = FALSE; } mc = sgf_create(); assert(MAGIC(mc)); mc->mode = sgfInsert_variant; f = fopen(fName, "r"); if (f == NULL) { if (err) { if (errno == ENOENT) *noFile = TRUE; str_print(&strErr, msg_mcReadErr, strerror(errno), fName); *err = str_chars(&strErr); } sgf_destroy(mc); return(NULL); } /* * Start reading after the "(;" bit that marks the first node. */ do { do { c = getc(f); if (c == '\n') ++crCount; } while((c != '(') && (c != EOF)); do { c = getc(f); if (c == '\n') ++crCount; } while(isspace(c)); } while ((c != EOF) && (c != ';')); problem = readFile(mc, f, &crCount); if (problem) { if (err) { str_print(&strErr, msg_badSGFFile, fName, problem, crCount); *err = str_chars(&strErr); } fclose(f); sgf_destroy(mc); return(NULL); } fclose(f); mc->mode = sgfInsert_main; for (me = &mc->top; me; me = me->activeChild) { mc->active = me; } return(mc); } /* * Returns FALSE if there was an error. */ static const char *readFile(Sgf *mc, FILE *f, int *crCount) { uint token; const char *arg; SgfElem *me; int i; bool err = FALSE; const char *problem; static Str strOut; static bool firstTime = TRUE; float komi; if (firstTime) { str_init(&strOut); firstTime = FALSE; } for (;;) { token = getToken(f, &arg, crCount); switch(token) { case(0): return(msg_sgfBadToken); break; case(TOKEN1(')')): return(NULL); break; case(TOKEN1(';')): sgf_addNode(mc); break; case(TOKEN1('(')): me = mc->active; problem = readFile(mc, f, crCount); if (problem) return(problem); else { mc->active = me; me->activeChild = me->childH; } break; case(TOKEN2('S','Z')): i = arg_getInt(arg, &err); if ((err) || (i < 2) || (i > GOBOARD_MAXSIZE)) return(msg_sgfBadArg); sgf_setSize(mc, i); break; case(TOKEN2('R','U')): arg_getStr(arg, &strOut); for (i = 0; i < (int)goRules_num; ++i) { if (!strcmp(str_chars(&strOut), msg_ruleNames[i])) { break; } } if (i == goRules_num) { sgf_setRules(mc, goRules_japanese); } else { sgf_setRules(mc, (GoRules)i); } break; case(TOKEN2('H','A')): i = arg_getInt(arg, &err); if (err) { return(msg_sgfBadArg); } sgf_setHandicap(mc, i); break; case(TOKEN2('K','M')): arg_getStr(arg, &strOut); if (str_len(&strOut) == 0) { sgf_setKomi(mc, 0.0); } else { komi = wms_atof(str_chars(&strOut), &err); if (err) { if ((str_chars(&strOut)[0] == '-') || isdigit(str_chars(&strOut)[0])) { komi = atoi(str_chars(&strOut)); if (komi >= 0.0) komi += 0.5; else komi -= 0.5; } else { return(msg_sgfBadArg); } } sgf_setKomi(mc, komi); } break; case(TOKEN2('T','M')): sgf_setTimeFormat(mc, arg_getStr(arg, &strOut)); break; case(TOKEN2('C','P')): sgf_copyright(mc, arg_getStr(arg, &strOut)); break; case(TOKEN2('P','W')): sgf_setPlayerName(mc, goStone_white, arg_getStr(arg, &strOut)); break; case(TOKEN2('P','B')): sgf_setPlayerName(mc, goStone_black, arg_getStr(arg, &strOut)); break; case(TOKEN2('D','T')): sgf_addSElem(mc, sgfType_date, arg_getStr(arg, &strOut)); break; case(TOKEN2('G','N')): arg_getStr(arg, &strOut); if (str_len(&strOut) > 0) sgf_addSElem(mc, sgfType_title, str_chars(&strOut)); break; case(TOKEN2('W','R')): sgf_playerRank(mc, goStone_white, arg_getStr(arg, &strOut)); break; case(TOKEN2('B','R')): sgf_playerRank(mc, goStone_black, arg_getStr(arg, &strOut)); break; case(TOKEN2('E','V')): sgf_event(mc, arg_getStr(arg, &strOut)); break; case(TOKEN2('S','O')): sgf_source(mc, arg_getStr(arg, &strOut)); break; case(TOKEN2('G','C')): sgf_gameComment(mc, arg_getStr(arg, &strOut)); break; case(TOKEN2('P','L')): arg_getStr(arg, &strOut); if (str_len(&strOut) != 1) { return(msg_sgfBadArg); } switch(str_chars(&strOut)[0]) { case 'B': case 'b': case '1': sgf_setWhoseMove(mc, goStone_black); break; case 'W': case 'w': case '2': sgf_setWhoseMove(mc, goStone_white); break; default: return(msg_sgfBadArg); } break; case(TOKEN1('W')): arg_getMove(arg, mc, goStone_white, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN1('B')): arg_getMove(arg, mc, goStone_black, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN2('W','L')): i = (int)arg_getDouble(arg, &err); if (err) { return(msg_sgfBadArg); } sgf_timeLeft(mc, goStone_white, i); break; case(TOKEN2('B','L')): i = (int)arg_getDouble(arg, &err); if (err) { return(msg_sgfBadArg); } sgf_timeLeft(mc, goStone_black, i); break; case(TOKEN2('O','W')): i = arg_getInt(arg, &err); if (err) { return(msg_sgfBadArg); } sgf_stonesLeft(mc, goStone_white, i); break; case(TOKEN2('O','B')): i = arg_getInt(arg, &err); if (err) { return(msg_sgfBadArg); } sgf_stonesLeft(mc, goStone_black, i); break; case(TOKEN2('A','E')): arg_multi(arg, mc, sgfType_setBoard, goStone_empty, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN2('A','W')): arg_multi(arg, mc, sgfType_setBoard, goStone_white, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN2('A','B')): arg_multi(arg, mc, sgfType_setBoard, goStone_black, &err); if (err) { return(msg_sgfBadLoc); } break; case(TOKEN2('T','W')): arg_multiRange(arg, mc, sgfType_territory, goStone_white, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN2('T','B')): arg_multiRange(arg, mc, sgfType_territory, goStone_black, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN2('T','R')): case(TOKEN1('M')): /* Some games have marks as "M[..]". */ arg_multi(arg, mc, sgfType_triangle, goStone_empty, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN2('C','R')): arg_multi(arg, mc, sgfType_circle, goStone_empty, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN2('M','A')): /* I draw "MA" (mark) as a square. */ arg_multi(arg, mc, sgfType_mark, goStone_empty, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN2('S','Q')): arg_multi(arg, mc, sgfType_square, goStone_empty, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN2('L','B')): arg_multiLabel(arg, mc, &err); if (err) return(msg_sgfBadLoc); break; case(TOKEN1('L')): /* Obsolete version of the LB token. */ me = mc->active; arg_multi(arg, mc, sgfType_label, goStone_empty, &err); if (err) return(msg_sgfBadLoc); i = 'A'; while (me != mc->active) { me = me->activeChild; me->sVal = str_createChar(i++); } break; case(TOKEN1('C')): sgf_comment(mc, arg_getStr(arg, &strOut)); break; case(TOKEN2('R','E')): sgf_result(mc, arg_getStr(arg, &strOut)); break; case(TOKEN2('G','M')): /* * if (arg_getInt(arg, &err) != 1) * return(msg_sgfBadArg); */ break; case(TOKEN2('F','F')): break; case(TOKEN2('P','C')): sgf_place(mc, arg_getStr(arg, &strOut)); break; case(TOKEN2('S','Y')): sgf_style(mc, arg_getStr(arg, &strOut)); break; default: sgf_unknown(mc, arg); break; } } } /* * Read a position. * Called with arg pointing past the [ or : * Returns a pointer to : or ] (and NULL on error) * The position is returned via posp (NULL for no position). */ static const char *arg_getLoc(const char *arg, char *posp) { *posp = '\0'; if (*arg == ']') return arg; if ((arg[0] == 't') && (arg[1] == 't') && (arg[2] == ']')) return arg+2; if (!islower(arg[0]) || !islower(arg[1])) return NULL; if ((arg[2] == ']') || (arg[2] == ':')) { posp[0] = posp[2] = 'a'; posp[1] = arg[0]; posp[3] = arg[1]; posp[4] = '\0'; return arg+2; } } /* * Call sgf_move or sgf_pass for a location [xx] or [] */ static void arg_getMove(const char *arg, Sgf *mc, GoStone gval, bool *errOut) { char loc[5]; arg = strchr(arg, '['); if (arg) arg = arg_getLoc(arg+1, loc); if (!arg) { *errOut = TRUE; return; } if (loc[0]) sgf_move(mc, gval, loc); else sgf_pass(mc, gval); } /* * Call sgf_addCLElem() for a series of locations [xx][xx]... */ static void arg_multi(const char *arg, Sgf *mc, SgfType type, GoStone gval, bool *errOut) { char loc[5]; for (;;) { arg = strchr(arg, '['); if (!arg) return; arg = arg_getLoc(arg+1, loc); if (arg == NULL) { *errOut = TRUE; return; } if (loc[0]) sgf_addCLElem(mc, type, gval, loc); ++arg; } } /* * Call sgf_addCLElem() for a series of locations [xx][yy:zz]... */ static void arg_multiRange(const char *arg, Sgf *mc, SgfType type, GoStone gval, bool *errOut) { char loc[5], loc2[5]; char xlo,xhi,ylo,yhi,x,y; for (;;) { arg = strchr(arg, '['); if (!arg) return; arg = arg_getLoc(arg+1, loc); if (arg == NULL) { *errOut = TRUE; return; } if (*arg == ':') { arg = arg_getLoc(arg+1, loc2); if (arg == NULL) { *errOut = TRUE; return; } /* expect auav, axay */ if (!(loc[0] == 'a' && loc[2] == 'a' && loc2[0] == 'a' && loc2[2] == 'a')) { *errOut = TRUE; return; } xlo = loc[1]; xhi = loc2[1]; ylo = loc[3]; yhi = loc2[3]; for(x=xlo; x<=xhi; x++) { for(y=ylo; y<=yhi; y++) { loc[1] = x; loc[3] = y; sgf_addCLElem(mc, type, gval, loc); } } } else if (loc[0]) sgf_addCLElem(mc, type, gval, loc); ++arg; } } static void arg_multiLabel(const char *arg, Sgf *mc, bool *errOut) { char loc[5]; for (;;) { arg = strchr(arg, '['); if (!arg) return; arg = arg_getLoc(arg+1, loc); if (!arg) { *errOut = TRUE; return; } arg = strchr(arg, ':'); if (!arg) { *errOut = TRUE; return; } sgf_label(mc, loc, ""); ++arg; while ((*arg != ']') && (*arg != '\0')) { str_catChar(mc->active->sVal, *arg); ++arg; } if (*arg == '\0') { *errOut = TRUE; return; } } } static int arg_getInt(const char *arg, bool *err) { int len; char tmp[11]; while (*arg != '[') ++arg; if (arg[1] == ']') { /* * Is this an error? I think so. * But apparently some lame ass SGF editor uses [] as zero at times, * so I gotta accept it. */ return(0); } ++arg; for (len = 0; arg[len] != ']'; ++len) { tmp[len] = arg[len]; if (len + 1 >= sizeof(tmp)) { *err = TRUE; return(0); } } tmp[len] = '\0'; return(wms_atoi(tmp, err)); } static double arg_getDouble(const char *arg, bool *err) { int len; char tmp[20]; while (*arg != '[') ++arg; ++arg; for (len = 0; arg[len] != ']'; ++len) { tmp[len] = arg[len]; if (len + 1 >= sizeof(tmp)) { *err = TRUE; return(0); } } tmp[len] = '\0'; return(wms_atof(tmp, err)); } static const char *arg_getStr(const char *arg, Str *result) { str_clip(result, 0); while (*arg != '[') ++arg; ++arg; while (*arg != ']') { assert(*arg); if (*arg == '\\') ++arg; str_catChar(result, *arg); ++arg; } return(str_chars(result)); } static uint getToken(FILE *f, const char **arg, int *lineCount) { static bool firstTime = TRUE; static Str buf; int c; enum { state_token, state_arg, state_nextArg } state; bool escaping = FALSE, escaped; uint token = 0; int shift = 0; int countAdd = 0; int lastCloseBracket = 0; if (firstTime) { str_init(&buf); firstTime = FALSE; } state = state_token; str_copyChars(&buf, ""); for (;;) { c = getc(f); if (c == '\n') ++countAdd; if (c == EOF) { *arg = str_chars(&buf); if (state == state_nextArg) { *lineCount += countAdd; return(token); } else return(0); } if (!escaping) { escaped = FALSE; if (c == '\\') escaping = TRUE; } else { escaped = TRUE; escaping = FALSE; } if ((state == state_token) && !escaped && !token && ((c == ';') || (c == '(') || (c == ')'))) { str_catChar(&buf, c); token = c; *arg = str_chars(&buf); *lineCount += countAdd; return(token); } else if ((state == state_token) && !islower(c) && !isspace(c) && (c != '[')) { str_catChar(&buf, c); token |= ((int)c & 0xff) << shift; shift += 8; if (shift > 16) return(0); } else if (((state == state_token) || (state == state_nextArg)) && !escaped && (c == '[')) { *lineCount += countAdd; countAdd = 0; str_catChar(&buf, c); state = state_arg; } else if ((state == state_arg) && !escaped && (c == ']')) { str_catChar(&buf, c); lastCloseBracket = str_len(&buf); state = state_nextArg; } else if ((state == state_nextArg) && !isspace(c) && (c != '[')) { ungetc(c, f); *arg = str_chars(&buf); *lineCount += countAdd; assert(lastCloseBracket > 0); str_clip(&buf, lastCloseBracket); return(token); } else { str_catChar(&buf, c); } } } cgoban-1.9.14/src/sgfMap.c0000664000671000067100000005367307043224471010715 /* * src/xio/sgfMap.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include "cgbuts.h" #include "sgfMap.h" /********************************************************************** * Forward declarations **********************************************************************/ static ButOut mmove(But *but, int x, int y); static ButOut mleave(But *but); static ButOut mpress(But *but, int butNum, int x, int y); static ButOut mrelease(But *but, int butNum, int x, int y); static void draw(But *but, int x, int y, int w, int h); static ButOut destroy(But *but); static void relocate(But *but, SgfElem *elem, int x, int y, int numDiag, int moveNum, bool mainLine); static void resizeGraph(SgfMap *map, int newX, int newY); static int findSubtreeY(SgfMap *map, SgfElem *tree, int x0, int y0, int *numDiagOut); static void drawConn(But *but, uint flags, int x, int y, int fontH); static void newFlags(But *but, uint flags); static void redrawEl(But *but, int x, int y); static void newMain(But *but, SgfMap *map, int x, int y); /********************************************************************** * Functions **********************************************************************/ But *sgfMap_create(Cgbuts *b, ButOut (*callback)(But *but, int newNodeNum), void *packet, ButWin *win, int layer, int flags, Sgf *sgf) { static const ButAction action = { mmove, mleave, mpress, mrelease, NULL, NULL, draw, destroy, newFlags, NULL}; SgfMap *map; But *but; map = wms_malloc(sizeof(SgfMap)); MAGIC_SET(map); but = but_create(win, map, &action); but->uPacket = packet; but->layer = layer; but->flags = flags; map->cgbuts = b; map->callback = callback; map->mapW = map->mapH = 0; map->maxW = map->maxH = 1; map->activeX = map->activeY = 0; map->activeCtrX = map->activeCtrY = -1; map->els = wms_malloc(sizeof(SgfMapElem)); map->els[0].flags = 0; but_init(but); relocate(but, sgf->top.activeChild, 0, 0, 0, 0, TRUE); map->els[0].flags &= ~SGFMAPFLAGS_CONNL; return(but); } void sgfMap_destroy(But *but) { SgfMap *map = but->iPacket; assert(MAGIC(map)); wms_free(map); } void sgfMap_resize(But *but, int x, int y) { SgfMap *map; int fontH; map = but->iPacket; assert(MAGIC(map)); fontH = butEnv_fontH(but->win->env, 0); but_resize(but, x, y, map->mapW * 3 * fontH + fontH, map->mapH * 3 * fontH + fontH); } static ButOut mmove(But *but, int x, int y) { SgfMap *map = but->iPacket; ButEnv *env = but->win->env; int gx, gy; int gridSpc = butEnv_fontH(env, 0); int gridW = gridSpc * 3; uint newFlags = but->flags; ButOut result = BUTOUT_CAUGHT; bool overBut = TRUE; gx = (x - but->x - gridSpc / 2) / gridW; gy = (y - but->y - gridSpc / 2) / gridW; if ((gx < 0) || (gy < 0) || (gx >= map->mapW) || (gy >= map->mapH)) overBut = FALSE; else if (map->els[gx + gy * map->maxW].node == NULL) overBut = FALSE; else if ((but->flags & BUT_PRESSED) && ((gx != map->pressX) || (gy != map->pressY))) overBut = FALSE; if (overBut) newFlags |= BUT_TWITCHED; else { newFlags &= ~BUT_TWITCHED; if (!(newFlags & BUT_LOCKED)) result &= ~BUTOUT_CAUGHT; } if (!(but->flags & BUT_TWITCHED) && (newFlags & BUT_TWITCHED)) butEnv_setCursor(env, but, butCur_twitch); else if ((but->flags & BUT_TWITCHED) && !(newFlags & BUT_TWITCHED)) butEnv_setCursor(env, but, butCur_idle); if (newFlags != but->flags) { but_newFlags(but, newFlags); } return(result); } static ButOut mleave(But *but) { int newflags = but->flags; newflags &= ~BUT_TWITCHED; if ((but->flags & BUT_TWITCHED) && !(newflags & BUT_TWITCHED)) butEnv_setCursor(but->win->env, but, butCur_idle); if (newflags != but->flags) { but_newFlags(but, newflags); } return(BUTOUT_CAUGHT); } static ButOut mpress(But *but, int butNum, int x, int y) { SgfMap *map = but->iPacket; ButOut result = BUTOUT_CAUGHT; ButEnv *env = but->win->env; int gx, gy; int gridSpc = butEnv_fontH(env, 0); int gridW = gridSpc * 3; uint newFlags = but->flags; gx = (x - but->x - gridSpc / 2) / gridW; gy = (y - but->y - gridSpc / 2) / gridW; if (!(newFlags & BUT_TWITCHED)) result &= ~BUTOUT_CAUGHT; else { assert(gx >= 0); assert(gy >= 0); assert(gx < map->mapW); assert(gy < map->mapH); assert(map->els[gx + gy * map->maxW].node != NULL); if (butNum == 1) { map->pressX = gx; map->pressY = gy; newFlags |= BUT_PRESSED | BUT_LOCKED; } else return(BUTOUT_CAUGHT | BUTOUT_ERR); } if (newFlags != but->flags) but_newFlags(but, newFlags); return(result); } static ButOut mrelease(But *but, int butNum, int x, int y) { ButOut result = BUTOUT_CAUGHT; bool makeCallback = FALSE; uint newFlags = but->flags; SgfMap *map = but->iPacket; if (butNum != 1) { if (but->flags & BUT_TWITCHED) return(BUTOUT_CAUGHT); else return(0); } if (!(but->flags & BUT_PRESSED)) return(0); if (but->flags & BUT_TWITCHED) { makeCallback = TRUE; } else { result |= BUTOUT_ERR; } newFlags &= ~(BUT_PRESSED|BUT_LOCKED); if (newFlags != but->flags) but_newFlags(but, newFlags); if (makeCallback && map->callback) { if (!(map->els[map->pressX + map->pressY * map->maxW].flags & SGFMAPFLAGS_MAIN)) { newMain(but, map, map->pressX, map->pressY); } result |= map->callback(but, map->pressX); } return(0); } static void draw(But *but, int dx, int dy, int dw, int dh) { ButWin *win = but->win; ButEnv *env = win->env; SgfMap *map = but->iPacket; SgfMapElem *el; int gridW, gridSize, gridSep, bw; int startY, endY, startX, endX; int x, y, locX0, stoneX, stoneY; GoStone stone = goStone_empty; bool mark = TRUE, grey; assert(MAGIC(env)); gridSep = butEnv_fontH(env, 0); gridSize = butEnv_fontH(env, 0) * 2; gridW = gridSep + gridSize; bw = butEnv_stdBw(env); startX = (dx - but->x - gridSep) / gridW; if (startX < 0) startX = 0; if (startX >= map->mapW) return; startY = (dy - but->y - gridSep) / gridW; if (startY < 0) startY = 0; if (startY >= map->mapH) return; endX = (dx + dw + gridSize - but->x) / gridW; if (endX < 1) return; if (endX > map->mapW) endX = map->mapW; endY = (dy + dh + gridSize - but->y) / gridW; if (endY < 1) return; if (endY > map->mapH) endY = map->mapH; if ((map->activeX >= startX) && (map->activeX < endX) && (map->activeY >= startY) && (map->activeY < endY)) { stoneX = map->activeX * gridW + gridSep + but->x; stoneY = map->activeY * gridW + gridSep + but->y; butEnv_setXFg(env, BUT_CHOICE); XFillRectangle(env->dpy, win->win, env->gc, stoneX - gridSep/2 + bw - win->xOff, stoneY - gridSep/2 + bw - win->yOff, gridW - bw*2, gridW - bw*2); but_drawBox(win, stoneX - gridSep/2, stoneY - gridSep/2, gridW, gridW, 0, bw, BUT_SRIGHT|BUT_SLEFT, BUT_LIT, BUT_SHAD, None, None); } if ((but->flags & BUT_PRESSED) && (but->flags & BUT_TWITCHED) && (map->pressX >= startX) && (map->pressX < endX) && (map->pressY >= startY) && (map->pressY < endY)) { stoneX = map->pressX * gridW + gridSep + but->x; stoneY = map->pressY * gridW + gridSep + but->y; butEnv_setXFg(env, BUT_PBG); XFillRectangle(env->dpy, win->win, env->gc, stoneX - gridSep/2 + bw - win->xOff, stoneY - gridSep/2 + bw - win->yOff, gridW - bw*2, gridW - bw*2); but_drawBox(win, stoneX - gridSep/2, stoneY - gridSep/2, gridW, gridW, 0, bw, BUT_SRIGHT|BUT_SLEFT, BUT_SHAD, BUT_LIT, None, None); } for (y = startY; y < endY; ++y) { locX0 = y * map->maxW; for (x = startX; x < endX; ++x) { stoneX = x * gridW + gridSep + but->x; stoneY = y * gridW + gridSep + but->y; el = &map->els[locX0 + x]; if (el->flags & SGFMAPFLAGS_CONN) drawConn(but, el->flags, stoneX, stoneY, gridSep); if (el->node == NULL) continue; switch(el->type) { case sgfMap_white: case sgfMap_wPass: mark = TRUE; stone = goStone_white; break; case sgfMap_black: case sgfMap_bPass: mark = TRUE; stone = goStone_black; break; case sgfMap_edit: mark = FALSE; break; case sgfMap_none: mark = TRUE; stone = goStone_empty; break; } grey = !(el->flags & SGFMAPFLAGS_MAIN); if (mark) { if (stone != goStone_empty) { cgbuts_drawp(map->cgbuts, win, stone, grey, stoneX, stoneY, gridSize, x % CGBUTS_NUMWHITE, dx, dy, dw, dh); } if (el->flags & SGFMAPFLAGS_MARKED) cgbuts_markPiece(map->cgbuts, win, stone, goMark_triangle, 0, stoneX, stoneY, gridSize, 1, dx, dy, dw, dh); else if (stone != goStone_empty) cgbuts_markPiece(map->cgbuts, win, stone, goMark_number, el->moveNum, stoneX, stoneY, gridSize, 1, dx, dy, dw, dh); } else { cgbuts_drawp(map->cgbuts, win, goStone_black, grey, stoneX, stoneY, gridSep, 1, dx, dy, dw, dh); cgbuts_drawp(map->cgbuts, win, goStone_white, grey, stoneX + gridSep, stoneY, gridSep, 2, dx, dy, dw, dh); cgbuts_drawp(map->cgbuts, win, goStone_white, grey, stoneX, stoneY + gridSep, gridSep, 3, dx, dy, dw, dh); cgbuts_drawp(map->cgbuts, win, goStone_black, grey, stoneX + gridSep, stoneY + gridSep, gridSep, 4, dx, dy, dw, dh); } } } } static void drawConn(But *but, uint flags, int x, int y, int fontH) { ButWin *win = but->win; ButEnv *env = win->env; int lineStart, lineEnd; int lineW; lineW = (fontH + 3) / 8; if (lineW < 1) lineW = 1; XSetLineAttributes(env->dpy, env->gc, lineW, LineSolid, CapButt, JoinMiter); butEnv_setXFg(but->win->env, BUT_BLACK); lineStart = lineEnd = y + fontH; if (flags & SGFMAPFLAGS_CONNU) lineStart = y; if (flags & SGFMAPFLAGS_CONND) lineEnd += fontH * 2; if (lineStart != lineEnd) XDrawLine(env->dpy, win->win, env->gc, x + fontH - win->xOff, lineStart - win->yOff, x + fontH - win->xOff, lineEnd - win->yOff); lineStart = lineEnd = x + fontH; if (flags & SGFMAPFLAGS_CONNL) lineStart = x; if (flags & SGFMAPFLAGS_CONNR) lineEnd += fontH * 2; if (lineStart != lineEnd) XDrawLine(env->dpy, win->win, env->gc, lineStart - win->xOff, y + fontH - win->yOff, lineEnd - win->xOff, y + fontH - win->yOff); lineStart = lineEnd = fontH; if (flags & SGFMAPFLAGS_CONNUL) lineStart = 0; if (flags & SGFMAPFLAGS_CONNDR) lineEnd += fontH * 2; if (lineStart != lineEnd) XDrawLine(env->dpy, win->win, env->gc, x + lineStart - win->xOff, y + lineStart - win->yOff, x + lineEnd - win->xOff, y + lineEnd - win->yOff); } static ButOut destroy(But *but) { return(0); } static void relocate(But *but, SgfElem *elem, int x, int y, int numDiag, int moveNum, bool mainLine) { SgfMap *map = but->iPacket; SgfMapElem *me; SgfElem *child; int connLoc; assert(MAGIC(map)); if (elem == NULL) return; resizeGraph(map, x, y); me = &map->els[x + y * map->maxW]; if (numDiag) { me->flags |= SGFMAPFLAGS_CONNUL; --numDiag; } else { me->flags |= SGFMAPFLAGS_CONNL; } if (mainLine) me->flags |= SGFMAPFLAGS_MAIN; me->type = sgfMap_none; while (elem->childH && (elem->childH->type != sgfType_node)) { elem->mapX = x; elem->mapY = y; assert(elem->childH == elem->childT); elem = elem->childH; switch(elem->type) { case sgfType_move: if (elem->gVal == goStone_white) me->type = sgfMap_white; else { assert(elem->gVal == goStone_black); me->type = sgfMap_black; } me->moveNum = ++moveNum; break; case sgfType_pass: if (elem->gVal == goStone_white) me->type = sgfMap_wPass; else { assert(elem->gVal == goStone_black); me->type = sgfMap_bPass; } me->moveNum = ++moveNum; break; case sgfType_triangle: case sgfType_comment: case sgfType_square: case sgfType_circle: case sgfType_label: me->flags |= SGFMAPFLAGS_MARKED; break; case sgfType_setBoard: me->type = sgfMap_edit; break; default: break; } } elem->mapX = x; elem->mapY = y; me->node = elem; if (elem->childH) { if (numDiag) { me->flags |= SGFMAPFLAGS_CONNDR; relocate(but, elem->childH, x + 1, y + 1, numDiag, moveNum, mainLine && (elem->childH == elem->activeChild)); } else { me->flags |= SGFMAPFLAGS_CONNR; relocate(but, elem->childH, x + 1, y, 0, moveNum, mainLine && (elem->childH == elem->activeChild)); } for (child = elem->childH->sibling; child; child = child->sibling) { connLoc = y; y = findSubtreeY(map, child, x, y, &numDiag); assert(numDiag > 0); while (connLoc < y) { map->els[x + connLoc * map->maxW].flags |= SGFMAPFLAGS_CONND; map->els[x + ++connLoc * map->maxW].flags |= SGFMAPFLAGS_CONNU; } map->els[x + y * map->maxW].flags |= SGFMAPFLAGS_CONNDR; relocate(but, child, x + 1, y + 1, numDiag, moveNum, mainLine && (child == elem->activeChild)); } } } static void resizeGraph(SgfMap *map, int newX, int newY) { SgfMapElem *newEls; int newMaxW, newMaxH; int x, y, oldX0, newX0; if ((newX >= map->maxW) || (newY >= map->maxH)) { newMaxW = (newX + 1) * 2; if (newMaxW < map->maxW) newMaxW = map->maxW; newMaxH = (newY + 1) * 2; if (newMaxH < map->maxH) newMaxH = map->maxH; newEls = wms_malloc(newMaxW * newMaxH * sizeof(SgfMapElem)); for (y = 0; y < map->maxH; ++y) { oldX0 = y * map->maxW; newX0 = y * newMaxW; for (x = 0; x < map->maxW; ++x) { newEls[newX0 + x] = map->els[oldX0 + x]; } for (x = map->maxW; x < newMaxW; ++x) { newEls[newX0 + x].node = NULL; newEls[newX0 + x].flags = 0; } } for (y = map->maxH; y < newMaxH; ++y) { newX0 = y * newMaxW; for (x = 0; x < newMaxW; ++x) { newEls[newX0 + x].node = NULL; newEls[newX0 + x].flags = 0; } } if (map->els != NULL) wms_free(map->els); map->els = newEls; map->maxW = newMaxW; map->maxH = newMaxH; } if (newX >= map->mapW) map->mapW = newX + 1; if (newY >= map->mapH) map->mapH = newY + 1; } static int findSubtreeY(SgfMap *map, SgfElem *tree, int x0, int y0, int *numDiagOut) { int x, y, numDiag; x = x0; y = y0 + 1; numDiag = 1; while (tree) { ++x; resizeGraph(map, x, y); while (map->els[y * map->maxW + x].node || map->els[y * map->maxW + x].flags) { ++y; ++numDiag; resizeGraph(map, x, y); } if (numDiag > x - x0) { numDiag = x - x0; } do { tree = tree->childH; } while (tree && (tree->type != sgfType_node)); } *numDiagOut = numDiag; return(y - numDiag); } void sgfMap_newActive(But *but, SgfElem *new) { SgfMap *map = but->iPacket; ButWin *win = but->win; int butSpc = butEnv_fontH(win->env, 0); assert(MAGIC(map)); assert(new->mapX >= 0); assert(new->mapY >= 0); assert(new->mapX < map->mapW); assert(new->mapY < map->mapH); if (map->activeX >= 0) { redrawEl(but, map->activeX, map->activeY); } map->activeX = new->mapX; map->activeY = new->mapY; if (map->activeX >= 0) { map->activeCtrX = but->x + butSpc * 3 * map->activeX + butSpc * 2; map->activeCtrY = but->y + butSpc * 3 * map->activeY + butSpc * 2; redrawEl(but, map->activeX, map->activeY); } } static void newFlags(But *but, uint flags) { SgfMap *map = but->iPacket; uint ofl = but->flags; but->flags = flags; if (((flags & BUT_PRESSED) != (ofl & BUT_PRESSED)) || (((flags & BUT_TWITCHED) != (ofl & BUT_TWITCHED)) && (flags & BUT_PRESSED))) { redrawEl(but, map->pressX, map->pressY); } } static void redrawEl(But *but, int x, int y) { int elSpc = butEnv_fontH(but->win->env, 0); butWin_redraw(but->win, but->x + x * elSpc * 3, but->y + y * elSpc * 3, elSpc * 4, elSpc * 4); } static void newMain(But *but, SgfMap *map, int x, int y) { SgfElem *node, *prevNode, *oldMain; int prevX, prevY; SgfMapElem *el; el = &map->els[x + y * map->maxW]; assert(MAGIC(el->node)); /* * First, go _down_ from the current active node, coloring all * links as "main". */ prevX = prevY = -1; for (node = el->node; node; node = node->activeChild) { if ((prevX != node->mapX) || (prevY != node->mapY)) { prevX = node->mapX; prevY = node->mapY; map->els[prevX + prevY * map->maxW].flags |= SGFMAPFLAGS_MAIN; redrawEl(but, prevX, prevY); } } /* * Now, go _up_ from the current active node, coloring all links as * "main". */ prevX = x; prevY = y; prevNode = el->node; for (node = prevNode->parent; ; node = node->parent) { oldMain = node->activeChild; node->activeChild = prevNode; assert(node == prevNode->parent); assert((node->childH != node->childT) || (node->activeChild == node->childH)); prevNode = node; if ((prevX != node->mapX) || (prevY != node->mapY)) { prevX = node->mapX; prevY = node->mapY; if (map->els[prevX + prevY * map->maxW].flags & SGFMAPFLAGS_MAIN) break; else { map->els[prevX + prevY * map->maxW].flags |= SGFMAPFLAGS_MAIN; redrawEl(but, prevX, prevY); } } } assert(oldMain != node->activeChild); /* * Now, make all the stuff that _used_ to be main as "non-main". */ for (; oldMain; oldMain = oldMain->activeChild) { if ((prevX != oldMain->mapX) || (prevY != oldMain->mapY)) { prevX = oldMain->mapX; prevY = oldMain->mapY; map->els[prevX + prevY * map->maxW].flags &= ~SGFMAPFLAGS_MAIN; redrawEl(but, prevX, prevY); } } } bool sgfMap_changeVar(But *but, SgfMapDirection dir) { SgfMap *map = but->iPacket; SgfElem *active, *curChild, *newChild; assert(MAGIC(map)); active = map->els[map->activeX + map->activeY * map->maxW].node; assert(MAGIC(active)); while ((active->childH != NULL) && (active->childH->type != sgfType_node)) { active = active->childH; assert(MAGIC(active)); } if ((active->childH == NULL) || (active->childH == active->childT)) return(FALSE); curChild = active->activeChild; assert(MAGIC(curChild)); if (dir == sgfMap_next) { newChild = curChild->sibling; if (!newChild) newChild = active->childH; } else { assert(dir == sgfMap_prev); if (curChild == active->childH) newChild = active->childT; else { for (newChild = active->childH; newChild->sibling != curChild; newChild = newChild->sibling); } } newMain(but, map, newChild->mapX, newChild->mapY); return(TRUE); } void sgfMap_remap(But *but, Sgf *sgf) { SgfMap *map = but->iPacket; int i, fontH = butEnv_fontH(but->win->env, 0); assert(MAGIC(map)); for (i = 0; i < map->maxW * map->maxH; ++i) { map->els[i].node = NULL; map->els[i].flags = 0; map->els[i].type = sgfMap_none; } map->mapW = map->mapH = 0; relocate(but, sgf->top.activeChild, 0, 0, 0, 0, TRUE); map->els[0].flags &= ~SGFMAPFLAGS_CONNL; but_resize(but, but->x, but->y, map->mapW * 3 * fontH + fontH, map->mapH * 3 * fontH + fontH); but_draw(but); } bool sgfMap_newNode(But *but, SgfElem *new) { SgfMap *map = but->iPacket; int newX, newY; SgfMapElem *el; assert(MAGIC(map)); newX = new->mapX; newY = new->mapY; assert(newX < map->maxW); if (newX + 1 == map->mapW) return(FALSE); if (map->els[newX + newY * map->maxW].flags & (SGFMAPFLAGS_CONND | SGFMAPFLAGS_CONNDR | SGFMAPFLAGS_CONNR)) return(FALSE); if (map->els[newX + 1 + newY * map->maxW].flags) return(FALSE); map->els[newX + newY * map->maxW].flags |= SGFMAPFLAGS_CONNR | SGFMAPFLAGS_MAIN; el = &map->els[newX + 1 + newY * map->maxW]; ++newX; el->flags |= SGFMAPFLAGS_CONNL | SGFMAPFLAGS_MAIN; redrawEl(but, newX, newY); new->mapX = newX; new->mapY = newY; el->node = new; el->type = sgfMap_none; return(TRUE); } void sgfMap_changeNode(But *but, SgfElem *changed) { SgfMap *map = but->iPacket; SgfMapElem *me; int moveAdd = 0; assert(MAGIC(map)); assert(changed != NULL); me = &map->els[changed->mapX + changed->mapY * map->maxW]; me->type = sgfMap_none; while (changed->parent && (changed->type != sgfType_node)) { switch(changed->type) { case sgfType_move: if (changed->gVal == goStone_white) me->type = sgfMap_white; else { assert(changed->gVal == goStone_black); me->type = sgfMap_black; } moveAdd = 1; break; case sgfType_pass: if (changed->gVal == goStone_white) me->type = sgfMap_wPass; else { assert(changed->gVal == goStone_black); me->type = sgfMap_bPass; } moveAdd = 1; break; case sgfType_triangle: case sgfType_comment: case sgfType_square: case sgfType_circle: case sgfType_label: me->flags |= SGFMAPFLAGS_MARKED; break; case sgfType_setBoard: me->type = sgfMap_edit; break; default: break; } changed = changed->parent; assert(changed != NULL); } if (changed->parent) { changed = changed->parent; assert(changed != NULL); me->moveNum = map->els[changed->mapX + changed->mapY * map->maxW].moveNum + moveAdd; } else me->moveNum = moveAdd; assert(changed != NULL); redrawEl(but, changed->mapX, changed->mapY); } /* * Sometimes, in our frenzy of adding and deleting SgfElems, we could kill * the one that the map points to. So every time we change active nodes, * we first reset the map to point to the old active node. */ void sgfMap_setMapPointer(But *but, SgfElem *activeElem) { SgfMap *map = but->iPacket; int x, y; assert(MAGIC(map)); x = activeElem->mapX; y = activeElem->mapY; assert((x >= 0) && (x < map->mapW) && (y >= 0) && (y < map->mapH)); assert(map->els[x + y * map->maxW].node); map->els[x + y * map->maxW].node = activeElem; } cgoban-1.9.14/src/sgfOut.c0000664000671000067100000002124507476005006010736 /* * $Source: /cvsroot/cgoban1/cgoban1/src/sgfOut.c,v $ * $Revision: 1.3 $ * $Author: wmshub $ * $Date: 2002/05/31 23:40:54 $ * * src/sgfOut.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include #include #include "cgoban.h" #include "sgf.h" #include "msg.h" #ifdef _SGFOUT_H_ LEVELIZATION ERROR #endif #include "sgfOut.h" /********************************************************************** * Forward Declarations **********************************************************************/ static void printColor(Str *out, SgfElem *me); static void printPoint(Str *out, Sgf *mc, SgfElem *me); static bool writeNode(FILE *f, Sgf *mc, SgfElem *me, int *err, int col, Str *tmp1, Str *tmp2); static void printString(Str *out, SgfElem *me); static SgfElem *printPoints(Str *out, Sgf *mc, SgfElem *me); static SgfElem *printLabelPoints(Str *out, Sgf *mc, SgfElem *me); /********************************************************************** * Functions **********************************************************************/ bool sgf_writeFile(Sgf *mc, const char *fname, int *err) { FILE *f; SgfElem *me; Str nodeOut, tmp; assert(MAGIC(mc)); f = fopen(fname, "w"); if (f == NULL) { if (err) *err = errno; return(FALSE); } fprintf(f, "(;GM[1]FF[3]\n"); str_init(&nodeOut); str_init(&tmp); if (mc->top.childH == mc->top.childT) { if (!writeNode(f, mc, mc->top.childH, err, 0, &nodeOut, &tmp)) { fclose(f); str_deinit(&nodeOut); str_deinit(&tmp); return(FALSE); } } else { for (me = mc->top.childH; me; me = me->sibling) { fprintf(f, "\n("); if (!writeNode(f, mc, me, err, 0, &nodeOut, &tmp)) { fclose(f); str_deinit(&nodeOut); str_deinit(&tmp); return(FALSE); } fprintf(f, ")"); } } fprintf(f, "\n)\n"); fclose(f); str_deinit(&nodeOut); str_deinit(&tmp); return(TRUE); } static bool writeNode(FILE *f, Sgf *mc, SgfElem *me, int *err, int col, Str *nodeOut, Str *tmp) { bool crNeeded; /* Flag; put this on its own line? */ while (me) { crNeeded = FALSE; switch(me->type) { case sgfType_node: str_copyChar(nodeOut, ';'); break; case sgfType_unknown: str_copyChars(nodeOut, str_chars(me->sVal)); break; case sgfType_size: str_print(nodeOut, "SZ[%d]", me->iVal); break; case sgfType_rules: str_print(nodeOut, "RU[%s]", msg_ruleNames[(int)(me->iVal)]); break; case sgfType_handicap: str_print(nodeOut, "HA[%d]", me->iVal); break; case sgfType_komi: str_print(nodeOut, "KM[%g]", (double)me->iVal / 2.0); break; case sgfType_time: str_print(nodeOut, "TM[%s]", str_chars(me->sVal)); break; case sgfType_copyright: str_copyChars(nodeOut, "CP"); printString(nodeOut, me); break; case sgfType_playerName: crNeeded = TRUE; str_copyChar(nodeOut, 'P'); printColor(nodeOut, me); printString(nodeOut, me); break; case sgfType_title: crNeeded = TRUE; str_copyChars(nodeOut, "GN"); printString(nodeOut, me); break; case sgfType_playerRank: str_clip(nodeOut, 0); printColor(nodeOut, me); str_catChar(nodeOut, 'R'); printString(nodeOut, me); break; case sgfType_event: crNeeded = TRUE; str_copyChars(nodeOut, "EV"); printString(nodeOut, me); break; case sgfType_source: crNeeded = TRUE; str_copyChars(nodeOut, "SO"); printString(nodeOut, me); break; case sgfType_gameComment: str_copyChars(nodeOut, "GC"); printString(nodeOut, me); break; case sgfType_date: crNeeded = TRUE; str_copyChars(nodeOut, "DT"); printString(nodeOut, me); break; case sgfType_whoseMove: assert(goStone_isStone(me->gVal)); str_print(nodeOut, "PL[%c]", (me->gVal == goStone_white) ? 'W' : 'B'); break; case sgfType_move: str_clip(nodeOut, 0); printColor(nodeOut, me); printPoint(nodeOut, mc, me); break; case sgfType_pass: str_clip(nodeOut, 0); printColor(nodeOut, me); if (mc->longLoc) str_catChars(nodeOut, "[]"); else str_catChars(nodeOut, "[tt]"); break; case sgfType_timeLeft: str_clip(tmp, 0); printColor(tmp, me); str_print(nodeOut, "%sL[%d]", str_chars(tmp), me->iVal); break; case sgfType_stonesLeft: str_copyChar(tmp, 'O'); printColor(tmp, me); str_print(nodeOut, "%s[%d]", str_chars(tmp), me->iVal); break; case sgfType_setBoard: str_copyChar(nodeOut, 'A'); printColor(nodeOut, me); me = printPoints(nodeOut, mc, me); break; case sgfType_territory: str_copyChar(nodeOut, 'T'); printColor(nodeOut, me); me = printPoints(nodeOut, mc, me); break; case sgfType_triangle: str_copyChars(nodeOut, "TR"); me = printPoints(nodeOut, mc, me); break; case sgfType_circle: str_copyChars(nodeOut, "CR"); me = printPoints(nodeOut, mc, me); break; case sgfType_square: str_copyChars(nodeOut, "SQ"); me = printPoints(nodeOut, mc, me); break; case sgfType_mark: str_copyChars(nodeOut, "MA"); me = printPoints(nodeOut, mc, me); break; case sgfType_label: str_copyChars(nodeOut, "LB"); me = printLabelPoints(nodeOut, mc, me); break; case sgfType_comment: str_copyChars(nodeOut, "C"); printString(nodeOut, me); break; case sgfType_result: crNeeded = TRUE; str_copyChars(nodeOut, "RE"); printString(nodeOut, me); break; case sgfType_place: str_copyChars(nodeOut, "PC"); printString(nodeOut, me); break; case sgfType_style: str_copyChars(nodeOut, "SY"); printString(nodeOut, me); break; default: fprintf(stderr, "BOGUS PROPERTY TO PRINT!\n"); for (;;); break; } if (col && (crNeeded || (col + str_len(nodeOut) > 70))) { fprintf(f, "\n"); col = 0; } col += str_len(nodeOut); fprintf(f, "%s", str_chars(nodeOut)); if (crNeeded) { fprintf(f, "\n"); col = 0; } if (me->childH == me->childT) { me = me->childH; } else { for (me = me->childH; me; me = me->sibling) { fprintf(f, "\n("); if (!writeNode(f, mc, me, err, 1, nodeOut, tmp)) return(FALSE); fprintf(f, ")\n"); col = 0; } } } return(TRUE); } static void printColor(Str *out, SgfElem *me) { if (me->gVal == goStone_white) str_catChar(out, 'W'); else if (me->gVal == goStone_black) str_catChar(out, 'B'); else { assert(me->gVal == goStone_empty); str_catChar(out, 'E'); } } static void printPoint(Str *out, Sgf *mc, SgfElem *me) { if (mc->longLoc) { str_catChar(out, '['); str_catChar(out, me->lVal[0]); str_catChar(out, me->lVal[1]); str_catChar(out, me->lVal[2]); str_catChar(out, me->lVal[3]); str_catChar(out, ']'); } else { str_catChar(out, '['); str_catChar(out, me->lVal[1]); str_catChar(out, me->lVal[3]); str_catChar(out, ']'); } } static SgfElem *printPoints(Str *out, Sgf *mc, SgfElem *me) { printPoint(out, mc, me); while ((me->childH != NULL) && (me->childH == me->childT) && (me->childH->type == me->type) && (me->childH->gVal == me->gVal)) { me = me->childH; printPoint(out, mc, me); } return(me); } static void printLabelPoint(Str *out, Sgf *mc, SgfElem *me) { if (mc->longLoc) { str_catChar(out, '['); str_catChar(out, me->lVal[0]); str_catChar(out, me->lVal[1]); str_catChar(out, me->lVal[2]); str_catChar(out, me->lVal[3]); str_catChar(out, ':'); str_cat(out, me->sVal); str_catChar(out, ']'); } else { str_catChar(out, '['); str_catChar(out, me->lVal[1]); str_catChar(out, me->lVal[3]); str_catChar(out, ':'); str_cat(out, me->sVal); str_catChar(out, ']'); } } static SgfElem *printLabelPoints(Str *out, Sgf *mc, SgfElem *me) { printLabelPoint(out, mc, me); while (me->childH && (me->childH == me->childT) && (me->childH->type == me->type) && (me->childH->gVal == me->gVal)) { me = me->childH; printLabelPoint(out, mc, me); } return(me); } static void printString(Str *out, SgfElem *me) { const char *str = str_chars(me->sVal); str_catChar(out, '['); while (*str) { if ((*str == ']') || (*str == '[') || (*str == '\\')) str_catChar(out, '\\'); str_catChar(out, *str); ++str; } str_catChar(out, ']'); } cgoban-1.9.14/src/sgfPlay.c0000664000671000067100000002022407476005006011070 /* * $Source: /cvsroot/cgoban1/cgoban1/src/sgfPlay.c,v $ * $Revision: 1.2 $ * $Author: wmshub $ * $Date: 2002/05/31 23:40:54 $ * * src/sgfPlay.c, part of Complete Goban (game program) * Copyright © 1995,2002 William Shubert. * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include "cgoban.h" #include "goPic.h" #include "sgf.h" #include "sgfPlay.h" #include "msg.h" /********************************************************************** * Forward declarations **********************************************************************/ static void processMoves(SgfElem *me, GoGame *game, int *handicap, bool *handicapPlayed, Cgoban *cg); static void processNodeMarks(SgfElem *me, GoGame *game, GoPic *pic, bool *changed); static void eraseObsoleteMarks(GoPic *pic, GoGame *game, bool *changed); /********************************************************************** * Functions **********************************************************************/ int sgf_play(Sgf *mc, GoGame *game, GoPic *pic, int numNodes, SgfElem *terminator) { int handicap = 0, i, currentNode = 0; SgfElem *me; bool handicapPlayed = FALSE; SgfElem *nodeStart = mc->top.activeChild; bool *changed; goGame_moveTo(game, 0); if (numNodes >= 0) ++numNodes; if (terminator != NULL) { terminator = terminator->activeChild; } for (me = mc->top.activeChild; (me != terminator) && numNodes; me = me->activeChild) { assert(MAGIC(me)); mc->active = me; if (me->type == sgfType_node) { assert((me->childH == NULL) || (me->childH != me->childT) || (me->activeChild == me->childH)); --numNodes; ++currentNode; if (numNodes) { nodeStart = me->activeChild; /* * We take out the last move at each node to make sure that * you don't see that silly ring forever. If there's another * move coming then this will get undone when we move. */ goGame_noLastMove(game); } else { mc->active = me->parent; } } else { assert(me->parent->childH == me->parent->childT); assert(me->parent->activeChild == me->parent->childH); if (pic == NULL) processMoves(me, game, &handicap, &handicapPlayed, NULL); else processMoves(me, game, &handicap, &handicapPlayed, pic->cg); } } /* * Now set the clock to match the time that we had left. for (i = game->moveNum - 1; i >= 0; --i) { if (game->moves[i].color == goStone_white) game->timers[goStone_white] = game->moves[i].time; } for (i = game->moveNum - 1; i >= 0; --i) { if (game->moves[i].color == goStone_black) game->timers[goStone_black] = game->moves[i].time; } */ /* * If there are handicap stones that were added automatically and aren't * in the movechain, then add them now. * This is really stupid. There is no way that adding handicap stones * should be in the sgf play code! :-( */ if (!handicapPlayed && handicap && !game->passive) { for (i = 0; i < goBoard_area(game->board); ++i) { if (goBoard_stone(game->board, i) == goStone_black) sgf_addStone(mc, goStone_black, goBoard_loc2Sgf(game->board, i)); } } /* * If we were given a GoPic, then add marks to it now. */ if (pic) { changed = wms_malloc(goBoard_area(game->board) * sizeof(bool)); memset(changed, 0, goBoard_area(game->board) * sizeof(bool)); while (nodeStart) { if (nodeStart->type == sgfType_node) break; processNodeMarks(nodeStart, game, pic, changed); nodeStart = nodeStart->activeChild; } eraseObsoleteMarks(pic, game, changed); wms_free(changed); } if (me) --currentNode; return(currentNode); } static void processMoves(SgfElem *me, GoGame *game, int *handicap, bool *handicapPlayed, Cgoban *cg) { int i; switch(me->type) { case sgfType_node: assert(0); break; case sgfType_handicap: *handicap = me->iVal; break; case sgfType_whoseMove: game->setWhoseMoveNum = game->moveNum; game->setWhoseMoveColor = me->gVal; game->whoseMove = me->gVal; break; case sgfType_move: *handicapPlayed = TRUE; i = goBoard_sgf2Loc(game->board, me->lVal); if (!*handicap || (goBoard_stone(game->board, i) != goStone_black)) { assert(game->passive || (me->gVal == game->whoseMove)); if (!goGame_isLegal(game, me->gVal, i)) { Str errmsg; char moveStr[5]; str_init(&errmsg); goBoard_loc2Str(game->board, i, moveStr), str_print(&errmsg, msg_badMoveInSgf, moveStr, game->moveNum); if (cg != NULL) cgoban_createMsgWindow(cg, "CGoban: Error in SGF file", str_chars(&errmsg)); str_deinit(&errmsg); } else { goGame_move(game, me->gVal, i, NULL); } } if (*handicap) --*handicap; break; case sgfType_pass: if (game->state != goGameState_selectDead) { /* * IGS sends out games with more than two passes at the end of the * game. If you've already gone to non-play state and you get * passes, then ignore them. */ goGame_pass(game, me->gVal, NULL); } break; case sgfType_setBoard: i = goBoard_sgf2Loc(game->board, me->lVal); if ((me->gVal == goStone_empty) && ((game->state == goGameState_selectDead) || game->forcePlay)) { if (!(game->flags[i] & GOGAMEFLAGS_MARKDEAD)) { goGame_markDead(game, i); } } else { if (goBoard_stone(game->board, i) != me->gVal) { goGame_setBoard(game, me->gVal, i); } assert(goBoard_stone(game->board, i) == me->gVal); } break; case sgfType_timeLeft: if (me->iVal < 0) { /* * This is marking a time loss. Fake up the game structure to * make it clear that this is what happened. */ game->maxMoves = ++game->moveNum; } game->moves[game->moveNum - 1].time.timeLeft = me->iVal; break; case sgfType_stonesLeft: game->moves[game->moveNum - 1].time.aux = me->iVal; break; default: break; } } static void processNodeMarks(SgfElem *me, GoGame *game, GoPic *pic, bool *changed) { int loc, i; GoMarkType mark; bool err; assert(MAGIC(me)); switch(me->type) { case sgfType_territory: loc = goBoard_sgf2Loc(game->board, me->lVal); changed[loc] = TRUE; mark = goMarkType_stone2sm(me->gVal); if (goStone_isStone(goBoard_stone(game->board, loc))) { if (!grid_grey(pic->boardButs[loc])) { grid_setStone(pic->boardButs[loc], goBoard_stone(game->board, loc), TRUE); } } if (grid_markType(pic->boardButs[loc]) != mark) { grid_setMark(pic->boardButs[loc], mark, 0); } break; case sgfType_triangle: case sgfType_circle: case sgfType_square: case sgfType_mark: if (me->type == sgfType_triangle) mark = goMark_triangle; else if (me->type == sgfType_circle) mark = goMark_circle; else if (me->type == sgfType_mark) mark = goMark_x; else /* me->type == sgfType_square */ mark = goMark_square; loc = goBoard_sgf2Loc(game->board, me->lVal); changed[loc] = TRUE; if (grid_grey(pic->boardButs[loc])) { grid_setStone(pic->boardButs[loc], goBoard_stone(game->board, loc), FALSE); } if (grid_markType(pic->boardButs[loc]) != mark) { grid_setMark(pic->boardButs[loc], mark, 0); } break; case sgfType_label: loc = goBoard_sgf2Loc(game->board, me->lVal); changed[loc] = TRUE; /* See if it is a numeric label. */ i = wms_atoi(str_chars(me->sVal), &err); if (err) grid_setMark(pic->boardButs[loc], goMark_letter, str_chars(me->sVal)[0]); else grid_setMark(pic->boardButs[loc], goMark_number, i); break; default: break; } } static void eraseObsoleteMarks(GoPic *pic, GoGame *game, bool *changed) { int loc; for (loc = 0; loc < goBoard_area(game->board); ++loc) { if (!changed[loc] && pic->boardButs[loc]) { if (grid_grey(pic->boardButs[loc]) || (grid_markType(pic->boardButs[loc]) != goMark_none)) { grid_setStone(pic->boardButs[loc], goBoard_stone(game->board, loc), FALSE); grid_setMark(pic->boardButs[loc], goMark_none, 0); } } } } cgoban-1.9.14/src/gmp/0000777000671000067100000000000007606355255010175 5cgoban-1.9.14/src/gmp/client.h0000664000671000067100000000204207043224471011526 /* * src/gmp/client.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GMP_CLIENT_H_ #define _GMP_CLIENT_H_ 1 #ifndef _GMP_ENGINE_H_ #include "engine.h" #endif #ifndef _CLIENT_BOARD_H_ #include "../client/board.h" #endif /********************************************************************** * Data types **********************************************************************/ typedef struct GmpClient_struct { Cgoban *cg; bool inGame; int size, pid, inFile, outFile; GmpEngine ge; Str progName; CliBoard *cliBoard; MAGIC_STRUCT } GmpClient; /********************************************************************** * Functions **********************************************************************/ extern GmpClient *gmpClient_create(Cgoban *cg, const char *progName, CliServer server, const char *user, const char *password); extern void gmpClient_destroy(GmpClient *gc); #endif /* _GMP_SETUP_H_ */ cgoban-1.9.14/src/gmp/engine.h0000664000671000067100000000573207043224471011526 /* * src/gmp.h, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GMP_ENGINE_H_ #ifndef _BUT_BUT_H_ #include #endif #ifndef _GOBOARD_H_ #include "../goBoard.h" #endif #ifndef _CGOBAN_H_ #include "../cgoban.h" #endif #ifdef _GMP_ENGINE_H_ #error Levelization Error. #endif #define _GMP_ENGINE_H_ 1 /********************************************************************** * Constants **********************************************************************/ #define GMP_SENDBUFSIZE 16 #define GMP_EXECVEFAILED 127 /********************************************************************** * Data types **********************************************************************/ typedef struct GmpEngine_struct GmpEngine; typedef struct GmpActions_struct { ButOut (*newGame)(GmpEngine *ge, void *packet, int size, int handicap, float komi, bool chineseRules, bool iAmWhite); ButOut (*moveRecvd)(GmpEngine *ge, void *packet, GoStone color, int x, int y); ButOut (*undoMoves)(GmpEngine *ge, void *packet, int numUndos); ButOut (*errorRecvd)(GmpEngine *ge, void *packet, const char *errStr); } GmpActions; struct GmpEngine_struct { bool stopped; /* Prevents you from reading stuff after the game ends. */ int inFile, outFile; ButTimer *heartbeat; int boardSize; int handicap; float komi; bool chineseRules; bool iAmWhite; /* send white's moves out, get black's moves in. */ int queriesAcked, lastQuerySent; bool gameStarted; int recvSoFar, sendsQueued, sendFailures; bool waitingHighAck; time_t lastSendTime; int myLastSeq, hisLastSeq; unsigned char recvData[4]; /* Store up 1024 cmds. Should be enough. */ unsigned char sendData[4]; struct { int cmd, val; } sendsPending[GMP_SENDBUFSIZE]; Cgoban *cg; ButEnv *env; void *packet; const GmpActions *actions; MAGIC_STRUCT }; /********************************************************************** * Fuctions **********************************************************************/ extern GmpEngine *gmpEngine_init(Cgoban *cg, GmpEngine *ge, int inFile, int outFile, const GmpActions *actions, void *packet); #define gmpEngine_create(e, i, o, a, p) \ gmpEngine_init(e, wms_malloc(sizeof(GmpEngine)), i, o, a, p) #define gmpEngine_stop(e) ((e)->stopped = TRUE) extern GmpEngine *gmpEngine_deinit(GmpEngine *ge); #define gmpEngine_destroy(ge) wms_free(gmpEngine_deinit(ge)) extern void gmpEngine_startGame(GmpEngine *ge, int size, int handicap, float komi, bool chineseRules, bool iAmWhite); extern void gmpEngine_sendPass(GmpEngine *ge); extern void gmpEngine_sendMove(GmpEngine *ge, int x, int y); extern void gmpEngine_sendUndo(GmpEngine *ge, int numUndos); extern int gmp_forkProgram(Cgoban *cg, int *inFile, int *outFile, const char *progName, int mainTime, int byTime); #endif /* _GMP_ENGINE_H_ */ cgoban-1.9.14/src/gmp/play.h0000664000671000067100000000341407043224471011221 /* * src/gmp/play.h, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GMP_PLAY_H_ #ifndef _SGF_H_ #include "../sgf.h" #endif #ifndef _GOGAME_H_ #include "../goGame.h" #endif #ifndef _GOPIC_H_ #include "../goPic.h" #endif #ifndef _GOBAN_H_ #include "../goban.h" #endif #ifndef _GMP_ENGINE_H_ #include "engine.h" #endif #define _GMP_PLAY_H_ 1 /********************************************************************** * Forward declarations **********************************************************************/ #ifndef _ABUT_FSEL_H_ #ifndef AbutFsel #define AbutFsel void #endif #endif #ifndef _ABUT_MSG_H_ #ifndef AbutMsg #define AbutMsg void #endif #endif /********************************************************************** * Data types **********************************************************************/ typedef struct GmpPlayInfo_struct { int in, out, pid; bool ready; GmpEngine *engine; } GmpPlayInfo; typedef struct GmpPlay_struct { Cgoban *cg; GmpPlayInfo players[2]; GoGame *game; Goban *goban; Sgf *moves; SgfElem *endGame; /* Used to backtrack after a dispute. */ SgfElem *lastComment; AbutFsel *fsel; MAGIC_STRUCT } GmpPlay; /********************************************************************** * Functions **********************************************************************/ extern GmpPlay *gmpPlay_create(Cgoban *cg, int inFiles[2], int outFiles[2], int pids[2], GoRules rules, int size, int hcap, float komi, const char *white, const char *black, GoTimeType timeType, int mainTime, int byTime, int auxTime); extern void gmpPlay_destroy(GmpPlay *l); #endif /* _GMP_PLAY_H_ */ cgoban-1.9.14/src/gmp/setup.h0000664000671000067100000000264407043224471011420 /* * src/gmp/setup.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _GMP_SETUP_H_ #define _GMP_SETUP_H_ 1 /********************************************************************** * Data types **********************************************************************/ typedef enum { gmpSetup_program, gmpSetup_device, gmpSetup_human, gmpSetup_nngs, gmpSetup_igs, gmpSetup_local, gmpSetup_remote } GmpSetupType; typedef struct GmpSetupPlayer_struct { GmpSetupType type; ClpEntry *optionEntry, *progNameEntry, *devNameEntry; Str progName, devName; But *box; But *typeMenu; But *strDesc1, *strIn1; But *strDesc2, *strIn2; } GmpSetupPlayer; typedef struct GmpSetup_struct { Cgoban *cg; /* TRUE if you are waiting for a callback from gameSetup. */ bool gameWaiting; ButWin *win; But *bg; But *title; But *ok, *help, *cancel; GmpSetupPlayer players[2]; MAGIC_STRUCT } GmpSetup; /********************************************************************** * Functions **********************************************************************/ extern GmpSetup *gmpSetup_create(Cgoban *cg); extern void gmpSetup_destroy(GmpSetup *gs); extern int gmp_forkProgram(Cgoban *cg, int *inFile, int *outFile, const char *progName, int mainTime, int byTime); #endif /* _GMP_SETUP_H_ */ cgoban-1.9.14/src/gmp/Makefile.am0000664000671000067100000000030407466272676012155 noinst_LIBRARIES = libgmp.a INCLUDES = -I $(top_srcdir)/wmslib/src libgmp_a_SOURCES = \ client.c \ engine.c \ play.c \ setup.c noinst_HEADERS = \ client.h \ engine.h \ play.h \ setup.h cgoban-1.9.14/src/gmp/Makefile.in0000664000671000067100000002107607606355025012161 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../.. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPP = @CPP@ DATE = @DATE@ DEPDIR = @DEPDIR@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBS = @LIBS@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ noinst_LIBRARIES = libgmp.a INCLUDES = -I $(top_srcdir)/wmslib/src libgmp_a_SOURCES = \ client.c \ engine.c \ play.c \ setup.c noinst_HEADERS = \ client.h \ engine.h \ play.h \ setup.h subdir = src/gmp mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/configure.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) libgmp_a_AR = $(AR) cru libgmp_a_LIBADD = am_libgmp_a_OBJECTS = client.$(OBJEXT) engine.$(OBJEXT) play.$(OBJEXT) \ setup.$(OBJEXT) libgmp_a_OBJECTS = $(am_libgmp_a_OBJECTS) DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/client.Po ./$(DEPDIR)/engine.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/play.Po ./$(DEPDIR)/setup.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ DIST_SOURCES = $(libgmp_a_SOURCES) HEADERS = $(noinst_HEADERS) DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in SOURCES = $(libgmp_a_SOURCES) all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu src/gmp/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) AR = ar clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libgmp.a: $(libgmp_a_OBJECTS) $(libgmp_a_DEPENDENCIES) -rm -f libgmp.a $(libgmp_a_AR) libgmp.a $(libgmp_a_OBJECTS) $(libgmp_a_LIBADD) $(RANLIB) libgmp.a mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/engine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/play.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setup.Po@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` CCDEPMODE = @CCDEPMODE@ uninstall-info-am: ETAGS = etags ETAGSFLAGS = tags: TAGS 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: $(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 "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../.. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ 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"; \ $(mkinstalldirs) "$(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 check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) $(HEADERS) installdirs: 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-tags dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-exec-am: install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic uninstall-am: uninstall-info-am .PHONY: GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES distclean distclean-compile \ distclean-depend distclean-generic distclean-tags distdir dvi \ dvi-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic tags uninstall uninstall-am \ uninstall-info-am # 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: cgoban-1.9.14/src/gmp/client.c0000664000671000067100000001311707043224471011526 /* * src/gmp/setup.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../cgoban.h" #include "client.h" #include "../gameSetup.h" #include "../msg.h" #include "play.h" #include "../client/setup.h" /********************************************************************** * Forward declarations **********************************************************************/ static void newGame(void *packet, GoStone localColor, int size, int handicap, float komi, int mainTime, int byTime, void *board); static void gotMoveFromServer(void *packet, GoStone color, int loc); static void endGame(void *packet); static void logout(void *packet); static void gotUndoFromServer(void *packet); static ButOut gotMoveFromProg(GmpEngine *ge, void *packet, GoStone color, int x, int y); static ButOut gotErrFromProg(GmpEngine *ge, void *packet, const char *errStr); static ButOut undoMoves(GmpEngine *ge, void *packet, int numUndos); /********************************************************************** * Functions **********************************************************************/ GmpClient *gmpClient_create(Cgoban *cg, const char *progName, CliServer server, const char *user, const char *password) { GmpClient *cli; static const CliActions actions = { newGame, gotMoveFromServer, gotUndoFromServer, endGame, logout}; assert(MAGIC(cg)); cli = wms_malloc(sizeof(GmpClient)); MAGIC_SET(cli); cli->cg = cg; cli->inGame = FALSE; str_initChars(&cli->progName, progName); cliSetup_createGmp(cg, server, user, password, &actions, cli); return(cli); } static void newGame(void *packet, GoStone localColor, int size, int handicap, float komi, int mainTime, int byTime, void *board) { static const GmpActions actions = {NULL, gotMoveFromProg, undoMoves, gotErrFromProg}; GmpClient *cli = packet; Str error; assert(MAGIC(cli)); if (cli->inGame) endGame(cli); cli->size = size; cli->cliBoard = board; cli->pid = gmp_forkProgram(cli->cg, &cli->inFile, &cli->outFile, str_chars(&cli->progName), mainTime, byTime); if (cli->pid < 0) { str_init(&error); str_print(&error, msg_progRunErr, strerror(errno), str_chars(&cli->progName)); cgoban_createMsgWindow(cli->cg, "Cgoban Error", str_chars(&error)); str_deinit(&error); close(cli->inFile); close(cli->outFile); } else { gmpEngine_init(cli->cg, &cli->ge, cli->inFile, cli->outFile, &actions, cli); cli->inGame = TRUE; gmpEngine_startGame(&cli->ge, size, handicap, komi, FALSE, (localColor != goStone_white)); } } static void gotMoveFromServer(void *packet, GoStone color, int loc) { GmpClient *gc = packet; assert(MAGIC(gc)); if (gc->inGame) { if (loc == 0) gmpEngine_sendPass(&gc->ge); else { gmpEngine_sendMove(&gc->ge, goBoard_loc2X(gc->cliBoard->game->board, loc), goBoard_loc2Y(gc->cliBoard->game->board, loc)); } } } static void endGame(void *packet) { GmpClient *gc = packet; int dummy; assert(MAGIC(gc)); if (gc->inGame) { gc->inGame = FALSE; kill(gc->pid, SIGTERM); waitpid(gc->pid, &dummy, 0); close(gc->inFile); close(gc->outFile); gmpEngine_deinit(&gc->ge); } } static void logout(void *packet) { GmpClient *gc = packet; assert(MAGIC(gc)); gmpClient_destroy(gc); } void gmpClient_destroy(GmpClient *gc) { assert(MAGIC(gc)); if (gc->inGame) endGame(gc); str_deinit(&gc->progName); MAGIC_UNSET(gc); wms_free(gc); } static ButOut gotMoveFromProg(GmpEngine *ge, void *packet, GoStone color, int x, int y) { GmpClient *gc = packet; assert(MAGIC(gc)); if (x >= 0) { cliBoard_gridPressed(gc->cliBoard, goBoard_xy2Loc(gc->cliBoard->game->board, x, y), TRUE); } else cliBoard_passPressed(gc->cliBoard); return(0); } static ButOut gotErrFromProg(GmpEngine *ge, void *packet, const char *errStr) { GmpClient *gc = packet; int exitStatus = 0; bool alreadyDead = FALSE; Str exitMsg; assert(MAGIC(gc)); alreadyDead = (waitpid(gc->pid, &exitStatus, WNOHANG) != 0); if (!alreadyDead) { kill(gc->pid, SIGKILL); waitpid(gc->pid, &exitStatus, 0); } close(gc->inFile); close(gc->outFile); gmpEngine_deinit(&gc->ge); gc->inGame = FALSE; if (alreadyDead) { str_init(&exitMsg); if (WIFEXITED(exitStatus) && (WEXITSTATUS(exitStatus) == GMP_EXECVEFAILED)) { str_print(&exitMsg, msg_gmpCouldntStart, str_chars(&gc->progName)); } else if (WIFSIGNALED(exitStatus)) { str_print(&exitMsg, msg_gmpProgKilled, str_chars(&gc->progName), WTERMSIG(exitStatus)); } else { str_print(&exitMsg, msg_gmpProgWhyDead, str_chars(&gc->progName)); } goban_message(gc->cliBoard->goban, str_chars(&exitMsg)); str_deinit(&exitMsg); } else goban_message(gc->cliBoard->goban, errStr); return(BUTOUT_ERR); } static void gotUndoFromServer(void *packet) { GmpClient *gc = packet; assert(MAGIC(gc)); gmpEngine_sendUndo(&gc->ge, 1); } static ButOut undoMoves(GmpEngine *ge, void *packet, int numUndos) { GmpClient *gc = packet; assert(MAGIC(gc)); goban_message(gc->cliBoard->goban, msg_noUndoFromGmpToClient); return(BUTOUT_ERR); } cgoban-1.9.14/src/gmp/engine.c0000664000671000067100000004156407043224471011524 /* * src/gmp/engine.c, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert. * See "configure.h.in" for more copyright information. */ /* * This is based on David Fotland's go modem protocol code. I've pretty much * completely rewritten it though. */ #include #include #include #include #include "../cgoban.h" #include "../goBoard.h" #include "../msg.h" #ifdef _GMP_ENGINE_H_ #error Levelization Error. #endif #include "engine.h" /********************************************************************** * Constants **********************************************************************/ #define GMP_NUMQUERIESTOASK 4 #define GMP_TIMEOUTSECS 60 /********************************************************************** * Data types **********************************************************************/ typedef enum { cmd_ack, cmd_deny, cmd_reset, cmd_query, cmd_respond, cmd_move, cmd_undo } Command; typedef enum { query_game, query_bufSize, query_protocol, query_stones, query_bTime, query_wTime, query_charSet, query_rules, query_handicap, query_boardSize, query_timeLimit, query_color, query_who } Query; /********************************************************************** * Globals **********************************************************************/ #if DEBUG static const char *cmdNames[] = { "ACK", "DENY", "RESET", "QUERY", "RESPOND", "MOVE", "UNDO"}; static bool showTransfers = TRUE; #endif /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut dataReadyForRecv(void *packet, int fd); static ButOut getPacket(GmpEngine *ge); static unsigned char checksum(unsigned char p[4]); static ButOut parsePacket(GmpEngine *ge); static ButOut processCommand(GmpEngine *ge, Command command, int val); static ButOut gotQueryResponse(GmpEngine *ge, int val); static ButOut putCommand(GmpEngine *ge, Command cmd, int val); static ButOut heartbeat(ButTimer *timer); static void respond(GmpEngine *ge, Query query); static void askQuery(GmpEngine *ge); static void processQ(GmpEngine *ge); static char **makeArgv(const char *cmdLine); /********************************************************************** * Functions **********************************************************************/ GmpEngine *gmpEngine_init(Cgoban *cg, GmpEngine *ge, int inFile, int outFile, const GmpActions *actions, void *packet) { struct timeval oneSecond; MAGIC_SET(ge); ge->stopped = FALSE; ge->inFile = inFile; ge->outFile = outFile; ge->boardSize = 0; ge->handicap = 0; ge->komi = 0.0; ge->chineseRules = TRUE; ge->iAmWhite = 0; ge->queriesAcked = 0; ge->lastQuerySent = 0; ge->recvSoFar = 0; ge->sendsQueued = 0; ge->sendFailures = 0; ge->waitingHighAck = FALSE; ge->lastSendTime = 0; ge->myLastSeq = 0; ge->hisLastSeq = 0; ge->cg = cg; ge->env = cg->env; ge->packet = packet; ge->actions = actions; butEnv_addFile(cg->env, BUT_READFILE, inFile, ge, dataReadyForRecv); oneSecond.tv_usec = 0; oneSecond.tv_sec = 1; ge->heartbeat = butTimer_create(ge, NULL, oneSecond, oneSecond, FALSE, heartbeat); return(ge); } GmpEngine *gmpEngine_deinit(GmpEngine *ge) { assert(MAGIC(ge)); butEnv_rmFile(ge->env, BUT_READFILE, ge->inFile); butTimer_destroy(ge->heartbeat); MAGIC_UNSET(ge); return(ge); } static ButOut dataReadyForRecv(void *packet, int fd) { GmpEngine *ge = packet; assert(MAGIC(ge)); assert(fd == ge->inFile); return(getPacket(ge)); } static ButOut getPacket(GmpEngine *ge) { unsigned char charsIn[4], c; int count = 0, cNum; Str errDesc; ButOut result = 0; count = read(ge->inFile, charsIn, 4 - ge->recvSoFar); if (ge->stopped) return(0); if (count < 0) { str_init(&errDesc); str_print(&errDesc, msg_gmpDead, strerror(errno)); ge->actions->errorRecvd(ge, ge->packet, str_chars(&errDesc)); str_deinit(&errDesc); return(BUTOUT_ERR); } else if (count == 0) return(0); for (cNum = 0; cNum < count; ++cNum) { c = charsIn[cNum]; if (!ge->recvSoFar) { /* idle, looking for start of packet */ if ((c & 0xfc) == 0) { /* start of packet */ ge->recvData[0] = c; ge->recvSoFar = 1; } } else { /* We're in the packet. */ if ((c & 0x80) == 0) { /* error */ ge->recvSoFar = 0; if ((c & 0xfc) == 0) { ge->recvData[ge->recvSoFar++] = c; } } else { /* A valid character for in a packet. */ ge->recvData[ge->recvSoFar++] = c; if (ge->recvSoFar == 4) { /* check for extra bytes */ assert(cNum + 1 == count); if (checksum(ge->recvData) == ge->recvData[1]) result = parsePacket(ge); ge->recvSoFar = 0; } } } } return(result); } static unsigned char checksum(unsigned char p[4]) { unsigned char sum; sum = p[0] + p[2] + p[3]; sum |= 0x80; /* set sign bit */ return(sum); } static ButOut parsePacket(GmpEngine *ge) { int seq, ack, val; Command command; ButOut result = 0; seq = ge->recvData[0] & 1; ack = (ge->recvData[0] & 2) >> 1; if (ge->recvData[2] & 0x08) /* Not-understood command. */ return(0); command = (ge->recvData[2] >> 4) & 7; #if DEBUG if (showTransfers) { fprintf(stderr, "GMP: Command %s received from port %d:%d.\n", cmdNames[command], ge->inFile, ge->outFile); } #endif if ((command != cmd_deny) && (command != cmd_reset) && !ge->iAmWhite && !ge->gameStarted) { ge->gameStarted = TRUE; if (ge->actions->newGame != NULL) ge->actions->newGame(ge, ge->packet, ge->boardSize, ge->handicap, ge->komi, ge->chineseRules, ge->iAmWhite); } val = ((ge->recvData[2] & 7) << 7) | (ge->recvData[3] & 0x7f); if (!ge->waitingHighAck) { if ((command == cmd_ack) || /* An ack. We don't need an ack now. */ (ack != ge->myLastSeq)) { /* He missed my last message. */ #if DEBUG if (showTransfers) { fprintf(stderr, "GMP: ACK does not match myLastSeq.\n"); } #endif return(0); } else if (seq == ge->hisLastSeq) { /* Seen this one before. */ #if DEBUG if (showTransfers) { fprintf(stderr, "GMP: Repeated packet.\n"); } #endif putCommand(ge, cmd_ack, ~0); } else { ge->hisLastSeq = seq; ge->sendFailures = 0; result = processCommand(ge, command, val); } } else { /* Waiting for OK. */ if (command == cmd_ack) { if ((ack != ge->myLastSeq) || (seq != ge->hisLastSeq)) { /* Sequence error. */ return(result); } ge->sendFailures = 0; ge->waitingHighAck = FALSE; processQ(ge); } else if (seq == ge->hisLastSeq) { /* His command is old. */ } else if (ack == ge->myLastSeq) { ge->sendFailures = 0; ge->waitingHighAck = FALSE; ge->hisLastSeq = seq; result = processCommand(ge, command, val); processQ(ge); } else { /* Conflict with opponent. */ #if DEBUG if (showTransfers) { fprintf(stderr, "GMP: Received a packet, expected an ACK.\n"); } #endif /* * This code seems wrong. * * ge->myLastSeq = 1 - ge->myLastSeq; * ge->waitingHighAck = FALSE; * processQ(ge); */ } } return(result); } static ButOut processCommand(GmpEngine *ge, Command command, int val) { int s, x, y; ButOut result = 0; switch(command) { case cmd_deny: return(putCommand(ge, cmd_ack, ~0)); break; case cmd_query: respond(ge, val); break; case cmd_reset: /* New game. */ ge->queriesAcked = 0; askQuery(ge); break; case cmd_undo: /* Take back moves. */ result = putCommand(ge, cmd_ack, ~0); assert(ge->actions->undoMoves != NULL); result |= ge->actions->undoMoves(ge, ge->packet, val); return(result); break; case cmd_move: s = val & 0x1ff; if (s == 0) { x = -1; y = 0; } else { --s; x = (s % ge->boardSize); y = ge->boardSize - 1 - (s / ge->boardSize); } result = putCommand(ge, cmd_ack, ~0); if (val & 0x200) result |= ge->actions->moveRecvd(ge, ge->packet, goStone_white, x, y); else result |= ge->actions->moveRecvd(ge, ge->packet, goStone_black, x, y); return(result); break; case cmd_respond: return(gotQueryResponse(ge, val)); break; default: /* Don't understand command. */ return(putCommand(ge, cmd_deny, 0)); break; } return(0); } static ButOut putCommand(GmpEngine *ge, Command cmd, int val) { int writeResult; if (ge->waitingHighAck && (cmd != cmd_ack) && (cmd != cmd_respond) && (cmd != cmd_deny)) { if (ge->sendsQueued < GMP_SENDBUFSIZE) { ge->sendsPending[ge->sendsQueued].cmd = cmd; ge->sendsPending[ge->sendsQueued].val = val; ++ge->sendsQueued; } else { return(ge->actions->errorRecvd(ge, ge->packet, msg_gmpSendBufFull)); } return(0); } if ((cmd == cmd_ack) && (ge->sendsQueued)) { ge->waitingHighAck = FALSE; processQ(ge); return(0); } if (cmd != cmd_ack) ge->myLastSeq ^= 1; ge->sendData[0] = ge->myLastSeq | (ge->hisLastSeq << 1); ge->sendData[2] = 0x80 | (cmd << 4) | ((val >> 7) & 7); ge->sendData[3] = 0x80 | val; ge->sendData[1] = checksum(ge->sendData); ge->lastSendTime = time(NULL); #if DEBUG if (showTransfers) { fprintf(stderr, "GMP: Writing command %s to port %d:%d.\n", cmdNames[cmd], ge->inFile, ge->outFile); } #endif writeResult = write(ge->outFile, ge->sendData, 4); assert(writeResult == 4); ge->waitingHighAck = (cmd != cmd_ack); return(0); } static void respond(GmpEngine *ge, Query query) { int response; if (query & 0x200) { /* * Oops! This really means "do you support this extended command." * I don't support any extended commands, so the response should always * be zero. */ response = 0; /* * * Do you support this query? * * * query &= ~0x200; * if ((query == query_game) || (query == query_rules) || * (query == query_handicap) || (query == query_boardSize) || * (query == query_color)) * response = 15; * Yes. * * else * response = 0; * No. * */ } else { ge->waitingHighAck = TRUE; switch(query) { case query_game: response = 1; /* GO */ break; case query_rules: if (ge->chineseRules) response = 2; else response = 1; break; case query_handicap: response = ge->handicap; if (response == 0) response = 1; break; case query_boardSize: response = ge->boardSize; break; case query_color: if (ge->iAmWhite) response = 1; else response = 2; break; default: response = 0; break; } } putCommand(ge, cmd_respond, response); } static void askQuery(GmpEngine *ge) { static const Query queryList[GMP_NUMQUERIESTOASK] = { query_rules, query_handicap, query_boardSize, query_color}; int query; assert(ge->queriesAcked < GMP_NUMQUERIESTOASK); query = queryList[ge->queriesAcked]; ge->lastQuerySent = query; putCommand(ge, cmd_query, query); } static ButOut gotQueryResponse(GmpEngine *ge, int val) { static const char *ruleNames[] = {"Japanese", "Chinese"}; static const char *colorNames[] = {"Black", "White"}; Str err; ButOut result = 0; switch(ge->lastQuerySent) { case query_handicap: if (val <= 1) --val; if ((val != -1) && (val != ge->handicap)) { str_init(&err); str_print(&err, "Handicaps do not agree; I want %d, he wants %d.", ge->handicap, val); result |= ge->actions->errorRecvd(ge, ge->packet, str_chars(&err)); str_deinit(&err); } break; case query_boardSize: assert(ge->boardSize != 0); if ((val != 0) && (val != ge->boardSize)) { str_init(&err); str_print(&err, "Board sizes do not agree; I want %d, he wants %d.", ge->boardSize, val); result |= ge->actions->errorRecvd(ge, ge->packet, str_chars(&err)); str_deinit(&err); } break; case query_rules: if (val != 0) { if (ge->chineseRules != (val == 2)) { str_init(&err); str_print(&err, "Rule sets do not agree; I want %s, he wants %s.", ruleNames[ge->chineseRules], ruleNames[val == 2]); result |= ge->actions->errorRecvd(ge, ge->packet, str_chars(&err)); str_deinit(&err); } } break; case query_color: if (val != 0) { if (ge->iAmWhite == (val == 1)) { str_init(&err); str_print(&err, "Colors sets do not agree; we both want to be %s.", colorNames[ge->iAmWhite]); result |= ge->actions->errorRecvd(ge, ge->packet, str_chars(&err)); str_deinit(&err); } } } if ((result & BUTOUT_ERR) == 0) { ++ge->queriesAcked; if (ge->queriesAcked < GMP_NUMQUERIESTOASK) askQuery(ge); else { result |= putCommand(ge, cmd_ack, ~0); if (ge->actions->newGame != NULL) ge->actions->newGame(ge, ge->packet, ge->boardSize, ge->handicap, ge->komi, ge->chineseRules, ge->iAmWhite); } } return(result); } static ButOut heartbeat(ButTimer *timer) { GmpEngine *ge = butTimer_packet(timer); int writeResult; assert(MAGIC(ge)); if (ge->waitingHighAck && (time(NULL) != ge->lastSendTime)) { if (++ge->sendFailures > GMP_TIMEOUTSECS) { return(ge->actions->errorRecvd(ge, ge->packet, msg_gmpTimeout)); } else { ge->lastSendTime = time(NULL); #if DEBUG if (showTransfers) { fprintf(stderr, "GMP: Writing command %s to port %d:%d (retry %d).\n", cmdNames[(ge->sendData[2] >> 4) & 7], ge->inFile, ge->outFile, ge->sendFailures); } #endif writeResult = write(ge->outFile, ge->sendData, 4); if (writeResult != 4) { return(BUTOUT_ERR); } } } return(0); } void gmpEngine_startGame(GmpEngine *ge, int size, int handicap, float komi, bool chineseRules, bool iAmWhite) { ge->boardSize = size; ge->handicap = handicap; ge->komi = komi; ge->chineseRules = chineseRules; ge->iAmWhite = iAmWhite; ge->gameStarted = FALSE; if (!iAmWhite) { putCommand(ge, cmd_reset, 0); } } void gmpEngine_sendPass(GmpEngine *ge) { int arg; assert(MAGIC(ge)); if (ge->iAmWhite) arg = 0x200; else arg = 0; putCommand(ge, cmd_move, arg); } void gmpEngine_sendMove(GmpEngine *ge, int x, int y) { int val; assert(MAGIC(ge)); val = x + ge->boardSize * (ge->boardSize - 1 - y) + 1; if (ge->iAmWhite) val |= 0x200; putCommand(ge, cmd_move, val); } void gmpEngine_sendUndo(GmpEngine *ge, int numUndos) { assert(MAGIC(ge)); putCommand(ge, cmd_undo, numUndos); } static void processQ(GmpEngine *ge) { int i; if (!ge->waitingHighAck && ge->sendsQueued) { putCommand(ge, ge->sendsPending[0].cmd, ge->sendsPending[0].val); --ge->sendsQueued; for (i = 0; i < ge->sendsQueued; ++i) { ge->sendsPending[i] = ge->sendsPending[i + 1]; } } } int gmp_forkProgram(Cgoban *cg, int *inFile, int *outFile, const char *progName, int mainTime, int byTime) { int pid, result, fd; int cgToProg[2], progToCg[2]; int i; char **argv; Str cmdLine; result = pipe(cgToProg); if (result) return(-1); result = pipe(progToCg); if (result) { close(cgToProg[0]); close(cgToProg[1]); return(-1); } pid = fork(); if (pid < 0) { close(cgToProg[0]); close(cgToProg[1]); close(progToCg[0]); close(progToCg[1]); return(-1); } if (pid == 0) { /* The child. */ for (fd = 0; fd < 100; ++fd) { if ((fd != 2) && /* Don't close stderr! */ (fd != cgToProg[0]) && (fd != progToCg[1])) close(fd); } if (dup(cgToProg[0]) != 0) { fprintf(stderr, "I couldn't fdup into stdin!\n"); exit(1); } if (dup(progToCg[1]) != 1) { fprintf(stderr, "I couldn't fdup into stdout!\n"); exit(1); } str_init(&cmdLine); str_print(&cmdLine, progName, mainTime, byTime); argv = makeArgv(str_chars(&cmdLine)); i = execve(argv[0], argv, cg->envp); /* * If we got here, then the execve() must have failed. * No need to clean up, free cmdLine, etc...we're dead! */ exit(GMP_EXECVEFAILED); } else { close(cgToProg[0]); close(progToCg[1]); *inFile = progToCg[0]; *outFile = cgToProg[1]; return(pid); } } static char **makeArgv(const char *cmdLine) { char *buf; char **args; int i, numWords, len; len = strlen(cmdLine); buf = wms_malloc(len + 1); strcpy(buf, cmdLine); numWords = 1; for (i = 1; i < len; ++i) { if ((buf[i - 1] == ' ') && (buf[i] != ' ')) ++numWords; } args = wms_malloc((numWords + 1) * sizeof(char *)); args[0] = buf; numWords = 1; for (i = 1; i < len; ++i) { if (buf[i] == ' ') buf[i] = '\0'; if ((buf[i - 1] == '\0') && (buf[i] != '\0')) { args[numWords++] = buf + i; } } args[numWords++] = NULL; return(args); } cgoban-1.9.14/src/gmp/play.c0000664000671000067100000006204607050207035011215 /* * $Source: /cvsroot/cgoban1/cgoban1/src/gmp/play.c,v $ * $Revision: 1.2 $ * $Date: 2000/02/09 06:50:05 $ * * Part of Complete Goban (game program) * Copyright © 1995-1996,2000 William Shubert * See "configure.h.in" for more copyright information. * * Most of this file was mercilessly cut and pasted from local.c. I probably * should have found a way to make the local.c code do double-duty, but hey * I'm lazy and it's late at night and I want to get this done. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../cgoban.h" #include "../goban.h" #include "../msg.h" #include "../goGame.h" #include "../goPic.h" #include "../cgbuts.h" #include "../sgf.h" #include "../sgfIn.h" #include "../sgfOut.h" #include "../sgfPlay.h" #include "engine.h" #include "../editBoard.h" #if _GMP_PLAY_H_ #error LEVELIZATION ERROR #endif #include "play.h" /********************************************************************** * Forward references **********************************************************************/ static GobanOut gridPressed(void *packet, int loc); static GobanOut quitPressed(void *packet); static GobanOut passPressed(void *packet); static GobanOut rewPressed(void *packet); static GobanOut backPressed(void *packet); static GobanOut fwdPressed(void *packet); static GobanOut ffPressed(void *packet); static GobanOut donePressed(void *packet); static GobanOut disputePressed(void *packet); static GobanOut savePressed(void *packet); static GobanOut editPressed(void *packet); static void saveFile(AbutFsel *fsel, void *packet, const char *fname); static void writeGobanComments(GmpPlay *l), readGobanComments(GmpPlay *l); static void addDisputedTriangles(GoGame *game, Sgf *sgf); static void addTimeInfoToSgf(GmpPlay *l, GoStone color); static void recordTimeLoss(GmpPlay *l); static bool rewOk(void *packet), backOk(void *packet), fwdOk(void *packet); static void gobanDestroyed(void *packet); static GmpPlay *gmpPlay_createSgf(Cgoban *cg, Sgf *mc, int inFiles[2], int outFiles[2], int pids[2]); static ButOut recvNewGame(GmpEngine *ge, void *packet, int size, int handicap, float komi, bool chineseRules, bool iAmWhite); static ButOut recvMove(GmpEngine *ge, void *packet, GoStone color, int x, int y); static ButOut recvUndo(GmpEngine *ge, void *packet, int numUndos); static ButOut recvError(GmpEngine *ge, void *packet, const char *errStr); /********************************************************************** * Global variables **********************************************************************/ static const GobanActions gmpPlay_actions = { gridPressed, quitPressed, passPressed, rewPressed, backPressed, fwdPressed, ffPressed, donePressed, disputePressed, savePressed, editPressed, NULL, /* gameInfo */ &help_gmpBoard, gobanDestroyed, rewOk, backOk, fwdOk, fwdOk}; /********************************************************************** * Functions **********************************************************************/ GmpPlay *gmpPlay_create(Cgoban *cg, int inFiles[2], int outFiles[2], int pids[2], GoRules rules, int size, int hcap, float komi, const char *white, const char *black, GoTimeType timeType, int mainTime, int byTime, int auxTime) { Sgf *mc; Str tmp; GoTime time; mc = sgf_create(); str_init(&tmp); if (rules != goRules_japanese) { /* * GMP says that chinese rules let you play handicap stones anywhere. * I call that New Zealand rules instead. */ rules = goRules_nz; } sgf_setRules(mc, rules); sgf_setSize(mc, size); sgf_setHandicap(mc, hcap); sgf_setKomi(mc, komi); sgf_setPlayerName(mc, goStone_white, white); sgf_setPlayerName(mc, goStone_black, black); str_print(&tmp, msg_localTitle, white, black); sgf_setTitle(mc, str_chars(&tmp)); sgf_setDate(mc); sgf_style(mc, "Cgoban " VERSION); time.type = timeType; time.main = mainTime; time.by = byTime; time.aux = auxTime; goTime_describeStr(&time, &tmp); sgf_setTimeFormat(mc, str_chars(&tmp)); str_deinit(&tmp); return(gmpPlay_createSgf(cg, mc, inFiles, outFiles, pids)); } static GmpPlay *gmpPlay_createSgf(Cgoban *cg, Sgf *mc, int inFiles[2], int outFiles[2], int pids[2]) { static const GmpActions gmpCallbacks = { recvNewGame, recvMove, recvUndo, recvError}; GmpPlay *l; SgfElem *me; GoRules rules; int size, hcap; float komi; GoTime time; const char *title; GoStone s; assert(MAGIC(cg)); l = wms_malloc(sizeof(GmpPlay)); MAGIC_SET(l); l->cg = cg; goStoneIter(s) { l->players[s].in = inFiles[s]; l->players[s].out = outFiles[s]; l->players[s].pid = pids[s]; l->players[s].ready = (inFiles[s] < 0); } l->moves = mc; l->endGame = NULL; me = sgf_findType(mc, sgfType_rules); if (me) { rules = (GoRules)me->iVal; } else rules = goRules_japanese; me = sgf_findType(mc, sgfType_size); if (me) { size = me->iVal; } else { size = 19; } me = sgf_findType(mc, sgfType_handicap); if (me) { hcap = me->iVal; } else { hcap = 0; } me = sgf_findType(mc, sgfType_komi); if (me) { komi = (float)me->iVal / 2.0; } else { komi = 0.0; } me = sgf_findFirstType(mc, sgfType_time); if (me) { goTime_parseDescribeChars(&time, str_chars(me->sVal)); } else { time.type = goTime_none; } l->game = goGame_create(size, rules, hcap, komi, &time, FALSE); sgf_play(mc, l->game, NULL, -1, NULL); me = sgf_findFirstType(mc, sgfType_title); if (me) { title = str_chars(me->sVal); } else { title = msg_noTitle; } l->goban = goban_create(cg, &gmpPlay_actions, l, l->game, "local", title); l->goban->pic->allowedMoves |= goPicMove_noWhite | goPicMove_noBlack; goPic_update(l->goban->pic); goban_message(l->goban, msg_waitingForGame); goban_startTimer(l->goban, goGame_whoseMove(l->game)); l->goban->iDec1 = grid_create(&cg->cgbuts, NULL, NULL, l->goban->iWin, 2, BUT_DRAWABLE, 0); grid_setStone(l->goban->iDec1, goStone_white, FALSE); l->goban->iDec2 = grid_create(&cg->cgbuts, NULL, NULL, l->goban->iWin, 2, BUT_DRAWABLE, 0); grid_setStone(l->goban->iDec2, goStone_black, FALSE); l->lastComment = NULL; assert((hcap == 0) || ((hcap >= 2) && (hcap <= 27))); goStoneIter(s) { if (l->players[s].in >= 0) { assert(l->players[s].out >= 0); l->players[s].engine = gmpEngine_create(l->cg, l->players[s].in, l->players[s].out, &gmpCallbacks, l); gmpEngine_startGame(l->players[s].engine, size, hcap, komi, (rules != goRules_japanese), (s != goStone_white)); } } l->fsel = NULL; return(l); } void gmpPlay_destroy(GmpPlay *l) { GoStone s; int dummy; assert(MAGIC(l)); if (l->goban) goban_destroy(l->goban, FALSE); if (l->game) goGame_destroy(l->game); if (l->fsel) abutFsel_destroy(l->fsel, FALSE); goStoneIter(s) { if (l->players[s].in >= 0) { if (l->players[s].pid >= 0) { kill(l->players[s].pid, SIGTERM); waitpid(l->players[s].pid, &dummy, 0); } close(l->players[s].in); if (l->players[s].out != l->players[s].in) { close(l->players[s].out); } l->players[s].in = -1; l->players[s].out = -1; l->players[s].pid = -1; gmpEngine_destroy(l->players[s].engine); } } MAGIC_UNSET(l); wms_free(l); } static GobanOut gridPressed(void *packet, int loc) { GmpPlay *l = packet; SgfElem *startActive; GoStone moveColor; bool timeLeft; assert(MAGIC(l)); moveColor = goGame_whoseMove(l->game); if ((l->game->moveNum < l->game->maxMoves) && (l->players[goStone_opponent(moveColor)].in >= 0)) { gmpEngine_sendUndo(l->players[goStone_opponent(moveColor)].engine, l->game->maxMoves - l->game->moveNum); } if (l->game->state <= goGameState_dispute) { readGobanComments(l); sgf_addNode(l->moves); startActive = l->moves->active; if (l->game->state == goGameState_dispute) { addDisputedTriangles(l->game, l->moves); } timeLeft = goban_stopTimer(l->goban); if (!timeLeft) { recordTimeLoss(l); } else { sgf_move(l->moves, moveColor, goBoard_loc2Sgf(l->game->board, loc)); if (l->players[goStone_opponent(moveColor)].in >= 0) { /* Send the move out the GMP. */ gmpEngine_sendMove(l->players[goStone_opponent(moveColor)].engine, goBoard_loc2X(l->game->board, loc), goBoard_loc2Y(l->game->board, loc)); } goGame_move(l->game, moveColor, loc, &l->goban->timers[moveColor]); addTimeInfoToSgf(l, moveColor); goban_startTimer(l->goban, goGame_whoseMove(l->game)); } } else if (l->game->state == goGameState_selectDead) { goGame_markDead(l->game, loc); } else if (l->game->state == goGameState_selectDisputed) { l->endGame = l->moves->active; goGame_dispute(l->game, loc); /* * We briefly change to "variant" insert mode so that multiple disputes * will be seen in the order they were made. Then we switch back to * "main" insert mode so that undos and ends of disputes will be * the main variation. */ l->moves->mode = sgfInsert_variant; sgf_addNode(l->moves); addDisputedTriangles(l->game, l->moves); sgf_setWhoseMove(l->moves, l->game->setWhoseMoveColor); l->moves->mode = sgfInsert_main; } writeGobanComments(l); return(gobanOut_draw); } /* * This transfers comments from the SGF move chain to the goban. */ static void writeGobanComments(GmpPlay *l) { SgfElem *comElem; assert(MAGIC(l)); comElem = sgfElem_findTypeInNode(l->moves->active, sgfType_comment); if (comElem) { if (strcmp(str_chars(comElem->sVal), goban_getComments(l->goban))) goban_setComments(l->goban, str_chars(comElem->sVal)); } else { if (l->lastComment) goban_setComments(l->goban, ""); } l->lastComment = comElem; } /* * This transfers comments from the goban to the SGF move chain. */ static void readGobanComments(GmpPlay *l) { const char *comm; comm = goban_getComments(l->goban); if (comm[0]) { l->moves->mode = sgfInsert_inline; sgf_comment(l->moves, comm); l->moves->mode = sgfInsert_main; l->lastComment = l->moves->active; } else if (l->lastComment) { sgfElem_snip(l->lastComment, l->moves); l->lastComment = NULL; } } static GobanOut quitPressed(void *packet) { GmpPlay *l = packet; assert(MAGIC(l)); gmpPlay_destroy(l); return(gobanOut_noDraw); } static GobanOut passPressed(void *packet) { GmpPlay *l = packet; GoGameState oldState = l->game->state; SgfElem *startActive; GoStone moveColor; bool timeLeft; assert(MAGIC(l)); readGobanComments(l); moveColor = goGame_whoseMove(l->game); if ((l->game->moveNum < l->game->maxMoves) && (l->players[goStone_opponent(moveColor)].in >= 0)) { gmpEngine_sendUndo(l->players[goStone_opponent(moveColor)].engine, l->game->maxMoves - l->game->moveNum); } sgf_addNode(l->moves); startActive = l->moves->active; if (oldState == goGameState_dispute) addDisputedTriangles(l->game, l->moves); sgf_pass(l->moves, moveColor); if (l->players[goStone_opponent(moveColor)].in >= 0) { /* Send the move out the GMP. */ gmpEngine_sendPass(l->players[goStone_opponent(moveColor)].engine); } addTimeInfoToSgf(l, moveColor); timeLeft = goban_stopTimer(l->goban); if (!timeLeft) recordTimeLoss(l); else { if (goGame_pass(l->game, moveColor, &l->goban->timers[moveColor])) { /* * The game state has changed. */ if (oldState == goGameState_dispute) { assert(MAGIC(l->endGame)); l->moves->active = l->endGame; l->endGame = NULL; if (l->game->disputeAlive) goban_message(l->goban, msg_disputeOverAlive); else goban_message(l->goban, msg_disputeOverDead); } else { assert(oldState == goGameState_play); if ((l->game->rules == goRules_japanese) || (l->game->rules == goRules_tibetan)) goban_message(l->goban, msg_localJapRemDead); else goban_message(l->goban, msg_localChiRemDead); /* Stop the GMP engines! */ if (l->players[goStone_white].in >= 0) gmpEngine_stop(l->players[goStone_white].engine); if (l->players[goStone_black].in >= 0) gmpEngine_stop(l->players[goStone_black].engine); } } } if (l->game->state <= goGameState_dispute) { goban_startTimer(l->goban, goGame_whoseMove(l->game)); } writeGobanComments(l); return(gobanOut_draw); } static GobanOut rewPressed(void *packet) { GmpPlay *l = packet; assert(MAGIC(l)); readGobanComments(l); goban_noMessage(l->goban); if (l->game->state == goGameState_dispute) goGame_moveTo(l->game, l->game->setWhoseMoveNum); else goGame_moveTo(l->game, 0); sgf_setActiveNodeNumber(l->moves, l->game->moveNum); writeGobanComments(l); return(gobanOut_draw); } static GobanOut backPressed(void *packet) { GmpPlay *l = packet; assert(MAGIC(l)); readGobanComments(l); goban_noMessage(l->goban); if (l->game->state != goGameState_selectDead) { goGame_moveTo(l->game, l->game->moveNum - 1); } else { /* We must be in the endgame. Let's continue the game now instead! */ goGame_resume(l->game); } sgf_setActiveNodeNumber(l->moves, l->game->moveNum); writeGobanComments(l); return(gobanOut_draw); } static GobanOut fwdPressed(void *packet) { GmpPlay *l = packet; assert(MAGIC(l)); readGobanComments(l); goban_noMessage(l->goban); goGame_moveTo(l->game, l->game->moveNum + 1); sgf_setActiveNodeNumber(l->moves, l->game->moveNum); writeGobanComments(l); return(gobanOut_draw); } static GobanOut ffPressed(void *packet) { GmpPlay *l = packet; assert(MAGIC(l)); readGobanComments(l); goban_noMessage(l->goban); goGame_moveTo(l->game, l->game->maxMoves); sgf_setActiveNodeNumber(l->moves, l->game->moveNum); writeGobanComments(l); return(gobanOut_draw); } static GobanOut editPressed(void *packet) { GmpPlay *play = packet; assert(MAGIC(play)); editBoard_createSgf(play->cg, play->moves); return(gobanOut_noDraw); } static GobanOut donePressed(void *packet) { GmpPlay *l = packet; int i; Str *scoreComment, winner, doneMessage, result; float wScore, bScore; SgfElem *resultElem; assert(MAGIC(l)); assert(l->game->state == goGameState_selectDead); readGobanComments(l); str_init(&winner); str_init(&doneMessage); str_init(&result); goban_noMessage(l->goban); goGame_done(l->game); sgf_addNode(l->moves); /* * Add a territory list. */ for (i = 0; i < goBoard_area(l->game->board); ++i) { if (((l->game->flags[i] & GOGAMEFLAGS_SEEN) == GOGAMEFLAGS_SEEWHITE) && ((goBoard_stone(l->game->board, i) == goStone_empty) || (l->game->flags[i] & GOGAMEFLAGS_MARKDEAD))) sgf_addTerritory(l->moves, goStone_white, goBoard_loc2Sgf(l->game->board, i)); } for (i = 0; i < goBoard_area(l->game->board); ++i) { if (((l->game->flags[i] & GOGAMEFLAGS_SEEN) == GOGAMEFLAGS_SEEBLACK) && ((goBoard_stone(l->game->board, i) == goStone_empty) || (l->game->flags[i] & GOGAMEFLAGS_MARKDEAD))) sgf_addTerritory(l->moves, goStone_black, goBoard_loc2Sgf(l->game->board, i)); } wScore = goban_score(l->goban, goStone_white); bScore = goban_score(l->goban, goStone_black); if (wScore > bScore) { str_print(&winner, msg_winnerComment, msg_stoneNames[goStone_white], wScore - bScore); str_print(&result, "W+%g", wScore - bScore); } else if ((bScore > wScore) || (l->game->rules == goRules_ing)) { str_print(&winner, msg_winnerComment, msg_stoneNames[goStone_black], bScore - wScore); str_print(&result, "B+%g", bScore - wScore); } else { str_print(&winner, msg_jigoComment); str_copyChar(&result, '0'); } str_print(&doneMessage, msg_gameIsOver, winner); goban_message(l->goban, str_chars(&doneMessage)); scoreComment = goScore_str(&l->goban->score, l->game, &l->game->time, l->goban->timers); sgf_catComment(l->moves, str_chars(scoreComment)); str_destroy(scoreComment); resultElem = sgf_findType(l->moves, sgfType_result); if (resultElem) { sgfElem_newString(resultElem, str_chars(&result)); } else { sgf_setActiveNodeNumber(l->moves, 0); l->moves->mode = sgfInsert_inline; sgf_result(l->moves, str_chars(&result)); l->moves->mode = sgfInsert_main; sgf_setActiveToEnd(l->moves); } str_deinit(&winner); str_deinit(&doneMessage); str_deinit(&result); writeGobanComments(l); return(gobanOut_draw); } static GobanOut disputePressed(void *packet) { GmpPlay *l = packet; assert(MAGIC(l)); goGame_selectDisputed(l->game); goban_message(l->goban, msg_selectDisputedMsg); return(gobanOut_draw); } static GobanOut savePressed(void *packet) { GmpPlay *l = packet; assert(MAGIC(l)); if (l->fsel) abutFsel_destroy(l->fsel, FALSE); l->fsel = abutFsel_create(l->cg->abut, saveFile, l, "CGoban", msg_saveGameName, clp_getStr(l->cg->clp, "local.sgfName")); return(gobanOut_noDraw); } static void saveFile(AbutFsel *fsel, void *packet, const char *fname) { GmpPlay *l = packet; assert(MAGIC(l)); str_copy(&l->cg->lastDirAccessed, &fsel->pathVal); if (fname != NULL) { clp_setStr(l->cg->clp, "local.sgfName", butTextin_get(fsel->in)); sgf_writeFile(l->moves, fname, NULL); } l->fsel = NULL; } static void addDisputedTriangles(GoGame *game, Sgf *sgf) { int i; for (i = 0; i < goBoard_area(game->board); ++i) { if (game->flags[i] & GOGAMEFLAGS_DISPUTED) sgf_addTriangle(sgf, goBoard_loc2Sgf(game->board, i)); } } static void addTimeInfoToSgf(GmpPlay *l, GoStone who) { if (l->game->time.type != goTime_none) { sgf_timeLeft(l->moves, who, l->goban->timers[who].timeLeft + (l->goban->timers[who].usLeft > 0)); if ((l->game->time.type == goTime_ing) || ((l->game->time.type == goTime_canadian) && l->goban->timers[who].aux)) { sgf_stonesLeft(l->moves, who, l->goban->timers[who].aux); } } } static void recordTimeLoss(GmpPlay *l) { Str timeMsg; GoStone loser = l->game->whoseMove; sgf_timeLeft(l->moves, loser, -1); if ((l->game->time.type == goTime_ing) || ((l->game->time.type == goTime_canadian) && l->goban->timers[loser].aux)) { sgf_stonesLeft(l->moves, loser, l->goban->timers[loser].aux + (l->game->time.type == goTime_canadian)); } str_init(&timeMsg); str_print(&timeMsg, msg_timeLoss, msg_stoneNames[loser], msg_stoneNames[goStone_opponent(loser)]); goban_message(l->goban, str_chars(&timeMsg)); str_catChar(&timeMsg, '\n'); sgf_catComment(l->moves, str_chars(&timeMsg)); str_print(&timeMsg, "%c+T", (int)goStone_char(goStone_opponent(loser))); sgf_setActiveNodeNumber(l->moves, 0); l->moves->mode = sgfInsert_inline; sgf_result(l->moves, str_chars(&timeMsg)); l->moves->mode = sgfInsert_main; sgf_setActiveToEnd(l->moves); str_deinit(&timeMsg); } static bool rewOk(void *packet) { GmpPlay *l = packet; GoGame *game; assert(MAGIC(l)); game = l->game; switch(game->state) { case(goGameState_selectDead): case(goGameState_selectDisputed): return(FALSE); break; case(goGameState_dispute): return(game->moveNum > game->setWhoseMoveNum); break; default: if (!goStone_isStone(game->whoseMove)) return(TRUE); return((game->moveNum > 0) && ((l->players[goStone_opponent(game->whoseMove)].in >= 0) || (game->moveNum < game->maxMoves))); break; } } static bool backOk(void *packet) { GmpPlay *l = packet; GoGame *game; assert(MAGIC(l)); game = l->game; switch(game->state) { case(goGameState_selectDead): return(TRUE); break; case(goGameState_selectDisputed): return(FALSE); break; case(goGameState_dispute): return(game->moveNum > game->setWhoseMoveNum); break; default: if (!goStone_isStone(game->whoseMove)) return(TRUE); return((game->moveNum > 0) && ((l->players[goStone_opponent(game->whoseMove)].in >= 0) || (game->moveNum < game->maxMoves))); break; } } static bool fwdOk(void *packet) { GmpPlay *l = packet; GoGame *game; assert(MAGIC(l)); game = l->game; switch(game->state) { case(goGameState_selectDead): case(goGameState_selectDisputed): return(FALSE); break; default: return(game->moveNum < game->maxMoves); break; } } static void gobanDestroyed(void *packet) { GmpPlay *l = packet; assert(MAGIC(l)); l->goban = NULL; gmpPlay_destroy(l); } static ButOut recvNewGame(GmpEngine *ge, void *packet, int size, int handicap, float komi, bool chineseRules, bool iAmWhite) { Str errStr; GoStone s; GmpPlay *gp = packet; assert(MAGIC(gp)); if (ge == gp->players[goStone_white].engine) s = goStone_white; else { assert(ge == gp->players[goStone_black].engine); s = goStone_black; } if ((size != gp->game->size) || (handicap != gp->game->handicap) || (chineseRules != (gp->game->rules == goRules_nz)) || (iAmWhite != (s == goStone_black))) { str_init(&errStr); str_print(&errStr, msg_badNewGameReq, msg_stoneNames[s]); recvError(ge, gp, str_chars(&errStr)); str_deinit(&errStr); } else { gp->players[s].ready = TRUE; if (gp->players[goStone_opponent(s)].ready) { goban_noMessage(gp->goban); if (gp->players[goStone_white].in < 0) { gp->goban->pic->allowedMoves &= ~goPicMove_noWhite; } if (gp->players[goStone_black].in < 0) { gp->goban->pic->allowedMoves &= ~goPicMove_noBlack; } goPic_update(gp->goban->pic); } } return(0); } static ButOut recvMove(GmpEngine *ge, void *packet, GoStone color, int x, int y) { GmpPlay *gp = packet; Str error; char locStr[10]; int loc, oldMoveNum = -1; assert(MAGIC(gp)); assert(color == gp->game->whoseMove); loc = goBoard_xy2Loc(gp->game->board, x, y); if (gp->game->state != goGameState_play) { recvError(ge, gp, msg_gmpMoveOutsideGame); } else { if (gp->game->moveNum < gp->game->maxMoves) { oldMoveNum = gp->game->moveNum; goGame_moveTo(gp->game, gp->game->maxMoves); sgf_setActiveNodeNumber(gp->moves, gp->game->moveNum); } if (x >= 0) { if (goGame_isLegal(gp->game, color, loc)) { gridPressed(gp, goBoard_xy2Loc(gp->game->board, x, y)); } else { goBoard_loc2Str(gp->game->board, loc, locStr); str_init(&error); str_print(&error, msg_gmpBadMove, locStr); recvError(ge, gp, str_chars(&error)); str_deinit(&error); } } else { /* A pass. */ passPressed(gp); } if (oldMoveNum != -1) { goGame_moveTo(gp->game, oldMoveNum); sgf_setActiveNodeNumber(gp->moves, gp->game->moveNum); } } goban_update(gp->goban); return(0); } static ButOut recvUndo(GmpEngine *ge, void *packet, int numUndos) { Str undoMessage; GoStone s; GmpPlay *gp = packet; assert(MAGIC(gp)); if (ge == gp->players[goStone_white].engine) s = goStone_white; else { assert(ge == gp->players[goStone_black].engine); s = goStone_black; } str_init(&undoMessage); str_print(&undoMessage, msg_undoRequested, msg_stoneNames[s], numUndos); goban_message(gp->goban, str_chars(&undoMessage)); str_deinit(&undoMessage); readGobanComments(gp); if (numUndos > gp->game->moveNum) numUndos = gp->game->moveNum; if (gp->game->moveNum > gp->game->maxMoves - numUndos) { goGame_moveTo(gp->game, gp->game->moveNum - numUndos); } gp->game->maxMoves -= numUndos; sgf_setActiveNodeNumber(gp->moves, gp->game->moveNum); writeGobanComments(gp); return(0); } static ButOut recvError(GmpEngine *ge, void *packet, const char *errStr) { GmpPlay *gp = packet; GmpPlayInfo *p; int exitStatus = 0; bool alreadyDead = FALSE; const char *progClp; Str exitMsg; assert(MAGIC(gp)); if (ge == gp->players[goStone_white].engine) { p = &gp->players[goStone_white]; progClp = "gmp.WProgram"; } else { assert(ge == gp->players[goStone_black].engine); p = &gp->players[goStone_black]; progClp = "gmp.BProgram"; } if (p->pid >= 0) { alreadyDead = (waitpid(p->pid, &exitStatus, WNOHANG) != 0); assert(alreadyDead != -1); if (!alreadyDead) { kill(p->pid, SIGKILL); waitpid(p->pid, &exitStatus, 0); } } gmpEngine_destroy(p->engine); close(p->in); if (p->out != p->in) close(p->out); p->in = -1; p->out = -1; p->pid = -1; if (alreadyDead) { str_init(&exitMsg); if (WIFEXITED(exitStatus) && (WEXITSTATUS(exitStatus) == GMP_EXECVEFAILED)) { str_print(&exitMsg, msg_gmpCouldntStart, clp_getStr(gp->cg->clp, progClp)); } else if (WIFSIGNALED(exitStatus)) { str_print(&exitMsg, msg_gmpProgKilled, clp_getStr(gp->cg->clp, progClp), WTERMSIG(exitStatus)); } else { str_print(&exitMsg, msg_gmpProgWhyDead, clp_getStr(gp->cg->clp, progClp)); } goban_message(gp->goban, str_chars(&exitMsg)); str_deinit(&exitMsg); } else goban_message(gp->goban, errStr); return(BUTOUT_ERR); } cgoban-1.9.14/src/gmp/setup.c0000664000671000067100000004062607043224471011415 /* * src/gmp/setup.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../cgoban.h" #include "setup.h" #include "client.h" #include "../gameSetup.h" #include "../msg.h" #include "play.h" #include /********************************************************************** * Global variables **********************************************************************/ /* * If this field is TRUE, then we will really, truly be speaking GMP to * the player in question. */ static const bool isGmpType[] = { TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE}; /********************************************************************** * Forward declarations **********************************************************************/ static ButOut unmap(ButWin *win); static ButOut map(ButWin *win); static ButOut resize(ButWin *win); static ButOut destroy(ButWin *win); static ButOut okPressed(But *but); static ButOut cancelPressed(But *but); static ButOut newType(But *but, int newVal); static ButOut newIn1(But *but, const char *value); static ButOut newIn2(But *but, const char *value); static void gotGameSetup(void *packet, GameSetup *gameSetup); /********************************************************************** * Functions **********************************************************************/ GmpSetup *gmpSetup_create(Cgoban *cg) { GmpSetup *gs; GoStone s; int w, h; GmpSetupPlayer *p; char port[10]; assert(MAGIC(cg)); gs = wms_malloc(sizeof(GmpSetup)); MAGIC_SET(gs); gs->cg = cg; gs->gameWaiting = FALSE; h = cg->fontH * 16 + butEnv_stdBw(cg->env) * 14; w = h * 2; gs->win = butWin_create(gs, cg->env, "Go Modem Protocol Setup", w,h, unmap, map, resize, destroy); butWin_activate(gs->win); gs->bg = butBoxFilled_create(gs->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(gs->bg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); gs->title = butText_create(gs->win, 1, BUT_DRAWABLE, msg_gmpSetup, butText_center); butText_setFont(gs->title, 2); gs->ok = butCt_create(okPressed, gs, gs->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, msg_ok); gs->cancel = butCt_create(cancelPressed, gs, gs->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, msg_cancel); gs->help = butCt_create(cgoban_createHelpWindow, &help_gmpSetup, gs->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_help); gs->players[goStone_white].optionEntry = clp_lookup(cg->clp, "gmp.WOption"); gs->players[goStone_black].optionEntry = clp_lookup(cg->clp, "gmp.BOption"); gs->players[goStone_white].progNameEntry = clp_lookup(cg->clp, "gmp.WProgram"); gs->players[goStone_black].progNameEntry = clp_lookup(cg->clp, "gmp.BProgram"); gs->players[goStone_white].devNameEntry = clp_lookup(cg->clp, "gmp.WDevice"); gs->players[goStone_black].devNameEntry = clp_lookup(cg->clp, "gmp.BDevice"); sprintf(port, "%d", clp_getInt(cg->clp, "gmp.port")); /* * Set up the goStone_black type because when I set up goStone_white, * below, I will check this value and it must be something sane. */ gs->players[goStone_black].type = gmpSetup_program; goStoneIter(s) { p = &gs->players[s]; str_initChars(&p->progName, clpEntry_getStr(p->progNameEntry)); str_initChars(&p->devName, clpEntry_getStr(p->devNameEntry)); p->box = butBox_create(gs->win, 1, BUT_DRAWABLE); butBox_setPixmaps(p->box, cg->bgLitPixmap, cg->bgShadPixmap); p->typeMenu = butMenu_downCreate(newType, gs, gs->win, 1, 2, BUT_DRAWABLE|BUT_PRESSABLE, msg_gmpPlayers[s], msg_gmpTypes, clpEntry_getInt(p->optionEntry)); butMenu_setFlags(p->typeMenu, (int)gmpSetup_local, BUTMENU_DISABLED); butMenu_setFlags(p->typeMenu, (int)gmpSetup_remote, BUTMENU_DISABLED); p->strDesc1 = butText_create(gs->win, 1, BUT_DRAWABLE, msg_program, butText_center); butText_setColor(p->strDesc1, BUT_NOCHANGE, TRUE); p->strIn1 = butTextin_create(newIn1, gs, gs->win, 1, BUT_DRAWABLE, str_chars(&p->progName), 500); p->strDesc2 = butText_create(gs->win, 1, BUT_DRAWABLE, msg_port, butText_center); butText_setColor(p->strDesc2, BUT_NOCHANGE, TRUE); p->strIn2 = butTextin_create(newIn2, gs, gs->win, 1, BUT_DRAWABLE, port, 100); p->type = -1; newType(p->typeMenu, clpEntry_getInt(p->optionEntry)); } return(gs); } void gmpSetup_destroy(GmpSetup *gs) { assert(MAGIC(gs)); if (gs->win) { butWin_setDestroy(gs->win, NULL); butWin_destroy(gs->win); } str_deinit(&gs->players[goStone_white].progName); str_deinit(&gs->players[goStone_black].progName); str_deinit(&gs->players[goStone_white].devName); str_deinit(&gs->players[goStone_black].devName); MAGIC_UNSET(gs); wms_free(gs); } static ButOut unmap(ButWin *win) { return(0); } static ButOut map(ButWin *win) { return(0); } static ButOut resize(ButWin *win) { GmpSetup *gs = butWin_packet(win); Cgoban *cg; int w, h; int bw, fh; ButEnv *env; int boxX, boxY, boxW, boxH, butX, butW, butY; GoStone s; GmpSetupPlayer *p; assert(MAGIC(gs)); cg = gs->cg; assert(MAGIC(cg)); env = cg->env; bw = butEnv_stdBw(env); fh = cg->fontH; w = butWin_w(win); h = butWin_h(win); but_resize(gs->bg, 0,0, w,h); butText_resize(gs->title, w/2,bw*2, fh*2); boxX = bw; boxY = bw * 3 + fh * 2; boxH = h - bw * 6 - fh * 4; goStoneIter(s) { p = &gs->players[s]; boxW = (w - bw * 2 + (int)s) / 2; but_resize(p->box, boxX, boxY, boxW, boxH); butX = boxX + bw * 2; butW = boxW - bw * 4; butY = boxY + bw * 2; boxX += boxW; but_resize(p->typeMenu, butX, butY, butW, fh * 4); butY += fh * 4 + bw; but_resize(p->strDesc1, butX, butY, butW, fh * 2); butY += fh * 2 + bw; but_resize(p->strIn1, butX, butY, butW, fh * 2); butY += fh * 2 + bw; but_resize(p->strDesc2, butX, butY, butW, fh * 2); butY += fh * 2 + bw; but_resize(p->strIn2, butX, butY, butW, fh * 2); } boxX = bw * 2; boxW = (w - bw * 6) / 3; but_resize(gs->help, boxX, boxY + boxH + bw, boxW, fh * 2); boxX += boxW + bw; boxW = (w - bw * 6) / 3 + ((w - bw * 6) % 3); but_resize(gs->cancel, boxX, boxY + boxH + bw, boxW, fh * 2); boxX += boxW + bw; boxW = (w - bw * 6) / 3; but_resize(gs->ok, boxX, boxY + boxH + bw, boxW, fh * 2); return(0); } static ButOut destroy(ButWin *win) { GmpSetup *gs = butWin_packet(win); assert(MAGIC(gs)); gs->win = NULL; /* It's dead already. */ if (!gs->gameWaiting) { gmpSetup_destroy(gs); } return(0); } /* * Callback for when "OK" is pressed in the setup window. * It starts up the game setup dialogue, which asks for handicap, time * controls, etc. */ static ButOut okPressed(But *but) { GmpSetup *gs; GoStone s; GmpSetupPlayer *p; bool needSetup = TRUE; CliServer server = cliServer_nngs; const char *userName = NULL, *password = NULL; gs = but_packet(but); assert(MAGIC(gs)); goStoneIter(s) { p = &gs->players[s]; if (but_getFlags(p->strIn1) & BUT_PRESSABLE) { if (newIn1(p->strIn1, butTextin_get(p->strIn1)) & BUTOUT_ERR) return(BUTOUT_ERR); } if (but_getFlags(p->strIn2) & BUT_PRESSABLE) { if (newIn2(p->strIn2, butTextin_get(p->strIn2)) & BUTOUT_ERR) return(BUTOUT_ERR); } if ((p->type == gmpSetup_nngs) || (p->type == gmpSetup_igs)) { if (p->type == gmpSetup_nngs) server = cliServer_nngs; else server = cliServer_igs; needSetup = FALSE; userName = butTextin_get(p->strIn1); password = butTextin_get(p->strIn2); } } if (needSetup) { gs->gameWaiting = TRUE; butWin_destroy(gs->win); gameSetup_create(gs->cg, gotGameSetup, gs); } else { /* You need to connect to the server! */ if (gs->players[goStone_white].type == gmpSetup_program) gmpClient_create(gs->cg, str_chars(&gs->players[goStone_white].progName), server, userName, password); else gmpClient_create(gs->cg, str_chars(&gs->players[goStone_black].progName), server, userName, password); gmpSetup_destroy(gs); } return(0); } static void gotGameSetup(void *packet, GameSetup *gameSetup) { int inFiles[2], outFiles[2], pids[2]; GmpSetup *gs = packet; GoStone s; GmpSetupPlayer *p; bool valid = TRUE; Str error; struct termios newTty; assert(MAGIC(gs)); if (gameSetup) { if (gameSetup_size(gameSetup) > 22) { cgoban_createMsgWindow(gs->cg, "Cgoban Error", msg_gmpTooBig); valid = FALSE; } else { goStoneIter(s) { p = &gs->players[s]; switch(p->type) { case gmpSetup_program: pids[s] = gmp_forkProgram(gs->cg, &inFiles[s], &outFiles[s], str_chars(&p->progName), gameSetup->mainTime, gameSetup->byTime); if (pids[s] < 0) { str_init(&error); str_print(&error, msg_progRunErr, strerror(errno), str_chars(&p->progName)); cgoban_createMsgWindow(gs->cg, "Cgoban Error", str_chars(&error)); str_deinit(&error); valid = FALSE; } break; case gmpSetup_device: pids[s] = -1; inFiles[s] = outFiles[s] = open(str_chars(&p->devName), O_RDWR | O_NDELAY); if (inFiles[s] < 0) { str_init(&error); str_print(&error, msg_devOpenErr, strerror(errno), str_chars(&p->devName)); cgoban_createMsgWindow(gs->cg, "Cgoban Error", str_chars(&error)); str_deinit(&error); valid = FALSE; } if (isatty(inFiles[s])) { newTty.c_cflag = B2400 | CREAD | CLOCAL | CS8; newTty.c_iflag = 0; newTty.c_oflag = 0; newTty.c_lflag = 0; bzero(newTty.c_cc, NCCS); tcsetattr(inFiles[s], TCSANOW, &newTty); } break; case gmpSetup_human: inFiles[s] = outFiles[s] = -1; pids[s] = -1; break; case gmpSetup_local: case gmpSetup_remote: default: assert(0); break; } } } if (valid) { gmpPlay_create(gs->cg, inFiles, outFiles, pids, gameSetup_rules(gameSetup), gameSetup_size(gameSetup), gameSetup_handicap(gameSetup), gameSetup_komi(gameSetup), gameSetup_wName(gameSetup), gameSetup_bName(gameSetup), gameSetup_timeType(gameSetup), gameSetup_mainTime(gameSetup), gameSetup_byTime(gameSetup), gameSetup_timeAux(gameSetup)); } } gmpSetup_destroy(gs); } static ButOut cancelPressed(But *but) { GmpSetup *gs = but_packet(but); assert(MAGIC(gs)); butWin_destroy(gs->win); return(0); } static ButOut newType(But *but, int newVal) { GmpSetup *gs; GoStone color; GmpSetupPlayer *p; gs = but_packet(but); assert(MAGIC(gs)); if (but == gs->players[goStone_white].typeMenu) { color = goStone_white; } else { assert(but == gs->players[goStone_black].typeMenu); color = goStone_black; } p = &gs->players[color]; if (p->type == (GmpSetupType)newVal) return(0); p->type = (GmpSetupType)newVal; clpEntry_setInt(p->optionEntry, newVal); switch((GmpSetupType)newVal) { case gmpSetup_program: butText_setColor(p->strDesc1, BUT_NOCHANGE, FALSE); butText_set(p->strDesc1, msg_program); butTextin_set(p->strIn1, str_chars(&p->progName), FALSE); but_setFlags(p->strIn1, BUT_PRESSABLE); butText_setColor(p->strDesc2, BUT_NOCHANGE, TRUE); but_setFlags(p->strIn2, BUT_NOPRESS); break; case gmpSetup_device: butText_setColor(p->strDesc1, BUT_NOCHANGE, FALSE); butText_set(p->strDesc1, msg_device); butTextin_set(p->strIn1, str_chars(&p->devName), FALSE); but_setFlags(p->strIn1, BUT_PRESSABLE); butText_setColor(p->strDesc2, BUT_NOCHANGE, TRUE); but_setFlags(p->strIn2, BUT_NOPRESS); break; case gmpSetup_human: butText_setColor(p->strDesc1, BUT_NOCHANGE, TRUE); but_setFlags(p->strIn1, BUT_NOPRESS); butText_setColor(p->strDesc2, BUT_NOCHANGE, TRUE); but_setFlags(p->strIn2, BUT_NOPRESS); break; case gmpSetup_nngs: butText_setColor(p->strDesc1, BUT_NOCHANGE, FALSE); butText_set(p->strDesc1, msg_username); butTextin_set(p->strIn1, clp_getStr(gs->cg->clp, "gmp.nngs.username"), FALSE); but_setFlags(p->strIn1, BUT_PRESSABLE); butText_setColor(p->strDesc2, BUT_NOCHANGE, FALSE); butText_set(p->strDesc2, msg_password); but_setFlags(p->strIn2, BUT_DRAWABLE|BUT_PRESSABLE); butTextin_set(p->strIn2, clp_getStr(gs->cg->clp, "gmp.nngs.password"), FALSE); butTextin_setHidden(p->strIn2, TRUE); break; case gmpSetup_igs: butText_setColor(p->strDesc1, BUT_NOCHANGE, FALSE); butText_set(p->strDesc1, msg_username); butTextin_set(p->strIn1, clp_getStr(gs->cg->clp, "gmp.igs.username"), FALSE); but_setFlags(p->strIn1, BUT_PRESSABLE); butText_setColor(p->strDesc2, BUT_NOCHANGE, FALSE); butText_set(p->strDesc2, msg_password); but_setFlags(p->strIn2, BUT_DRAWABLE|BUT_PRESSABLE); butTextin_set(p->strIn2, clp_getStr(gs->cg->clp, "gmp.igs.password"), FALSE); butTextin_setHidden(p->strIn2, TRUE); break; case gmpSetup_local: butText_setColor(p->strDesc1, BUT_NOCHANGE, FALSE); butText_set(p->strDesc1, msg_port); butTextin_set(p->strIn1, clp_getStr(gs->cg->clp, "gmp.port"), FALSE); but_setFlags(p->strIn1, BUT_PRESSABLE); butText_setColor(p->strDesc2, BUT_NOCHANGE, TRUE); but_setFlags(p->strIn2, BUT_NOPRESS); break; case gmpSetup_remote: butText_setColor(p->strDesc1, BUT_NOCHANGE, FALSE); butText_set(p->strDesc1, msg_machineName); butTextin_set(p->strIn1, clp_getStr(gs->cg->clp, "gmp.machine"), FALSE); but_setFlags(p->strIn1, BUT_PRESSABLE); butText_setColor(p->strDesc2, BUT_NOCHANGE, FALSE); butText_set(p->strDesc2, msg_port); but_setFlags(p->strIn2, BUT_DRAWABLE|BUT_PRESSABLE); butTextin_set(p->strIn2, clp_getStr(gs->cg->clp, "gmp.port"), FALSE); butTextin_setHidden(p->strIn2, FALSE); break; } if (!isGmpType[gs->players[goStone_white].type] && !isGmpType[gs->players[goStone_black].type]) { but_setFlags(gs->ok, BUT_NOPRESS); } else { but_setFlags(gs->ok, BUT_PRESSABLE); } return(0); } static ButOut newIn1(But *but, const char *value) { GmpSetup *gs = but_packet(but); GoStone color; GmpSetupPlayer *p; Str errorMsg; assert(MAGIC(gs)); but_setFlags(but, BUT_NOKEY); if (but == gs->players[goStone_white].strIn1) { color = goStone_white; } else { assert(but == gs->players[goStone_black].strIn1); color = goStone_black; } p = &gs->players[color]; switch(p->type) { case gmpSetup_program: clpEntry_setStr(p->progNameEntry, value); str_copyChars(&p->progName, value); break; case gmpSetup_device: clpEntry_setStr(p->devNameEntry, value); str_copyChars(&p->devName, value); break; case gmpSetup_nngs: clp_setStr(gs->cg->clp, "gmp.nngs.username", value); break; case gmpSetup_igs: clp_setStr(gs->cg->clp, "gmp.igs.username", value); break; case gmpSetup_local: if (!clp_setStr(gs->cg->clp, "gmp.port", value)) { str_init(&errorMsg); str_print(&errorMsg, msg_badPortNum, value); cgoban_createMsgWindow(gs->cg, "Cgoban Error", str_chars(&errorMsg)); str_deinit(&errorMsg); return(BUTOUT_ERR); } break; case gmpSetup_remote: clp_setStr(gs->cg->clp, "gmp.machine", value); break; default: assert(0); break; } return(0); } static ButOut newIn2(But *but, const char *value) { GmpSetup *gs = but_packet(but); GoStone color; GmpSetupPlayer *p; Str errorMsg; assert(MAGIC(gs)); but_setFlags(but, BUT_NOKEY); if (but == gs->players[goStone_white].strIn2) { color = goStone_white; } else { assert(but == gs->players[goStone_black].strIn2); color = goStone_black; } p = &gs->players[color]; switch(p->type) { case gmpSetup_nngs: clp_setStr(gs->cg->clp, "gmp.nngs.password", value); break; case gmpSetup_igs: clp_setStr(gs->cg->clp, "gmp.igs.password", value); break; case gmpSetup_remote: if (!clp_setStr(gs->cg->clp, "gmp.port", value)) { str_init(&errorMsg); str_print(&errorMsg, msg_badPortNum, value); cgoban_createMsgWindow(gs->cg, "Cgoban Error", str_chars(&errorMsg)); str_deinit(&errorMsg); return(BUTOUT_ERR); } break; default: assert(0); break; } return(0); } cgoban-1.9.14/src/client/0000777000671000067100000000000007606355255010670 5cgoban-1.9.14/src/client/board.h0000664000671000067100000000373607043224471012045 /* * src/client/board.h, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_BOARD_H_ #ifndef _GOBOARD_H_ #include "../goBoard.h" #endif #ifndef _CLIENT_DATA_H_ #include "data.h" #endif #ifndef _GOGAME_H_ #include "../goGame.h" #endif #ifndef _GOBAN_H_ #include "../goban.h" #endif #ifndef _SGF_H_ #include "../sgf.h" #endif #ifdef _CLIENT_BOARD_H_ LEVELIZATION ERROR #endif #define _CLIENT_BOARD_H_ 1 /********************************************************************** * Data Types **********************************************************************/ typedef struct CliBoard_struct { CliData *data; Cgoban *cg; Sgf *sgf; SgfElem *gameEnd; int gameNum, lastMoveRead; bool gameEnded, onTrack; GoGame *game; Goban *goban; But *shiftKeytrap, *ctrlKeytrap; void (*destroy)(struct CliBoard_struct *cli, void *packet); void *packet; GoTime timer; Str wName, bName; bool moveWhite, moveBlack; Str result; MAGIC_STRUCT } CliBoard; /********************************************************************** * Functions **********************************************************************/ extern CliBoard *cliBoard_create(CliData *data, int gameNum, const Str *wName, const Str *wRank, const Str *bName, const Str *bRank, int size, int handicap, float komi, int mainTime, int byTime, void (*destroy)(CliBoard *cli, void *packet), void *packet); extern void cliBoard_destroy(CliBoard *board, bool propagate); extern Bool cliBoard_gotMove(CliBoard *board, const char *locStr, GoStone color, int moveNum); #define cliBoard_addKibitz(cli, kib) goban_catComments((cli)->goban, (kib)) GobanOut cliBoard_gridPressed(void *packet, int loc, bool forcePress); GobanOut cliBoard_passPressed(void *packet); extern void cliBoard_update(CliBoard *cli); #endif /* _CLIENT_BOARD_H_ */ cgoban-1.9.14/src/client/conn.h0000664000671000067100000000454007043224471011705 /* * src/client/conn.h, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_CONN_H_ #define _CLIENT_CONN_H_ 1 #ifndef _CLIENT_SERVER_H_ #include "server.h" #endif #ifndef _CGOBAN_H_ #include "../cgoban.h" #endif #ifndef _WMS_STR_H_ #include #endif /********************************************************************** * Data Types **********************************************************************/ typedef enum { cliConnErr_openSocket, cliConnErr_lookup, cliConnErr_connect, cliConnErr_ok } CliConnErr; typedef struct CliConn_struct { Cgoban *cg; int fd; CliConnErr err; int serverNum; CliServer server; bool directConn; bool loginMode; union { int errNum; /* Only valid when err == openSocket or connect */ const char *serverName; /* Only valid when err = lookup */ } errOut; int inLen, inSize, outLen, outSize; int telnetState; /* Should probably be an enum. */ char *inBuf, *outBuf; Str outMsgs; bool promptReady; uchar loChar, hiChar; /* Bounds of chars you let through. */ void (*newData)(void *packet, const char *dataIn, int dataLen); void *packet; MAGIC_STRUCT } CliConn; /********************************************************************** * Functions **********************************************************************/ /* * newdata should return the amount of data that has been read and can * be thrown out of the buffer. 0 is a perfectly legitimate amount to * return, in which case you won't be bothered again until more data * shows up. * If newData is called with NULL as the dataIn value, then dataLen contains * the errno that killed the connection. */ extern CliConn *cliConn_init(CliConn *cc, Cgoban *cg, int serverNum, CliServer protocol, uchar loChar, uchar hiChar, void (*newData)(void *packet, const char *dataIn, int dataLen), void *packet); #define cliConn_create(cg, s, nd, p) \ cliConn_init(wms_malloc(sizeof(CliConn)), (cg), (s), (nd), (p)) extern CliConn *cliConn_deinit(CliConn *cc); #define cliConn_destroy(cc) wms_free(cliConn_deinit(cc)) extern void cliConn_send(CliConn *conn, const char *str); extern void cliConn_prompt(CliConn *conn); #endif /* _CLIENT_CONN_H_ */ cgoban-1.9.14/src/client/data.h0000664000671000067100000000410507043224471011656 /* * src/client/data.h, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_DATA_H_ #ifndef _CLIENT_SERVER_H_ #include "server.h" #endif #ifndef _CGOBAN_H_ #include "../cgoban.h" #endif #ifndef _CLIENT_CONN_H_ #include "conn.h" #endif #ifndef _WMS_STR_H_ #include #endif #ifdef _CLIENT_DATA_H_ #error LEVELIZATION ERROR #endif #define _CLIENT_DATA_H_ 1 /********************************************************************** * Data Types **********************************************************************/ typedef struct CliActions_struct { /* * Passing board as a void is really ugly. What I should do is move * this data type into board.h and keep it in the main data structure, * passing it down as needed. */ void (*newGame)(void *packet, GoStone localColor, int size, int handicap, float komi, int mainTime, int byTime, void *board); void (*gotMove)(void *packet, GoStone color, int loc); void (*gotUndo)(void *packet); void (*endGame)(void *packet); void (*logout)(void *packet); } CliActions; typedef enum { cliData_setup, cliData_login, cliData_main } CliDataState; typedef struct CliData_struct { CliDataState state; Cgoban *cg; int serverNum; CliServer server; const char *serverName; Str userName; Str cmdBuild; ClpEntry *numKibitz; bool connValid; CliConn conn; const CliActions *actions; void *packet; int refCount; /* Not sure I like this. */ ButOut (*observeGame)(void *obPacket, int boardId); void *obPacket; MAGIC_STRUCT } CliData; /********************************************************************** * Functions **********************************************************************/ extern CliData *cliData_create(Cgoban *cg, int serverNum, const CliActions *actions, void *packet); #define cliData_incRef(cd) (++((cd)->refCount)) extern void cliData_closeConns(CliData *cd); extern void cliData_decRef(CliData *cd); #endif /* _CLIENT_DATA_H_ */ cgoban-1.9.14/src/client/game.h0000664000671000067100000000466507043224471011671 /* * src/client/game.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_GAME_H_ #define _CLIENT_GAME_H_ 1 #ifndef _CLIENT_DATA_H_ #include "data.h" #endif #ifndef _CLIENT_BOARD_H_ #include "board.h" #endif #ifndef _CLIENT_PLAYER_H_ #include "player.h" #endif /********************************************************************** * Data Types **********************************************************************/ typedef enum { cliGame_noGame, cliGame_idle, cliGame_observing, cliGame_waitNoOb, cliGame_over } CliGameState; typedef struct CliGame_struct { CliGameState state; bool gamePressed; /* Don't let a double click do "observe " twice! */ Str wName, bName, wRank, bRank, flags; int moveNum, size, handicap; float komi; int byTime, observers; bool free, fromMatch; CliBoard *board; } CliGame; typedef struct CliGameList_struct { CliData *data; CliPlayerList *playerList; int maxGames; CliGame *games; int defaultGame, playGame; int kibGame; char kibPlayer[41]; ButWin *win; AbutSwin *swin; But *bg, *sBg, *list, *num, *titleBox, *title, *reload; bool elfBugReported; MAGIC_STRUCT } CliGameList; /********************************************************************** * Functions **********************************************************************/ extern CliGameList *cliGameList_init(CliGameList *gl, CliData *data, CliPlayerList *playerList); extern CliGameList *cliGameList_deinit(CliGameList *gl); extern void cliGameList_gotMove(CliGameList *gl, const char *move); extern void cliGameList_gotGameInfo(CliGameList *gl, const char *buf); extern void cliGameList_notObserving(CliGameList *gl, const char *buf); extern void cliGameList_kibitz(CliGameList *gl, const char *buf); extern void cliGameList_say(CliGameList *gl, const char *buf); extern void cliGameList_openWin(CliGameList *gl); extern void cliGameList_gameGone(CliGameList *gl, const char *buf, int bufLen); extern void cliGameList_gameStarts(CliGameList *gl, const char *buf); extern void cliGameList_selectDead(CliGameList *gl, const char *buf); extern void cliGameList_deadStone(CliGameList *gl, const char *buf); extern void cliGameList_gotUndo(CliGameList *gl, const char *buf); extern bool cliGame_tellIsSay(CliGameList *list, Str *tell); #endif /* _CLIENT_MAIN_H_ */ cgoban-1.9.14/src/client/login.h0000664000671000067100000000226107043224471012056 /* * src/client/login.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_LOGIN_H_ #define _CLIENT_LOGIN_H_ 1 #ifndef _CGOBAN_H_ #include "../cgoban.h" #endif #ifndef _CLIENT_DATA_H_ #include "data.h" #endif #ifndef _CLIENT_SERVER_H_ #include "server.h" #endif #ifndef _CLIENT_MAIN_H_ #include "main.h" #endif /********************************************************************** * Data Types **********************************************************************/ typedef enum { cliLogin_waitForUser, cliLogin_waitForPassword, cliLogin_waitForPrompt } CliLoginState; typedef struct CliLogin_struct { CliData *cd; CliMain *main; bool keepMainMessage; Str user, pass; CliLoginState state; MAGIC_STRUCT } CliLogin; /********************************************************************** * Functions **********************************************************************/ extern CliLogin *cliLogin_create(CliData *cd, const char *user, const char *pass); extern void cliLogin_destroy(CliLogin *cl, bool propagate); #endif /* _CLIENT_LOGIN_H_ */ cgoban-1.9.14/src/client/look.h0000664000671000067100000000262307043224471011714 /* * src/client/look.h, part of Complete Goban (game program) * Copyright (C) 1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_LOOK_H_ #ifndef _GOGAME_H_ #include "../goGame.h" #endif #ifndef _CGOBAN_H_ #include "../cgoban.h" #endif #ifndef _GOBAN_H_ #include "../goban.h" #endif #ifndef _CLIENT_SERVER_H_ #include "server.h" #endif #ifdef _CLIENT_LOOK_H_ LEVELIZATION ERROR #endif #define _CLIENT_LOOK_H_ 1 /********************************************************************** * Data Types **********************************************************************/ typedef enum { cliLook_ready, cliLook_info, cliLook_body } CliLookStatus; typedef struct CliLook_struct { Cgoban *cg; CliServer server; int handicap, captures[2]; float komi; Str name[2], rank[2], boardData; CliLookStatus state; bool skip; MAGIC_STRUCT } CliLook; typedef struct CliLookChild_struct { Cgoban *cg; GoGame *game; Goban *goban; MAGIC_STRUCT } CliLookChild; /********************************************************************** * Functions **********************************************************************/ extern void cliLook_init(CliLook *look, Cgoban *cg, CliServer server); extern void cliLook_gotData(CliLook *look, const char *buf); extern void cliLook_deinit(CliLook *look); #endif /* _CLIENT_BOARD_H_ */ cgoban-1.9.14/src/client/main.h0000664000671000067100000000424207043224471011673 /* * src/client/main.h, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_MAIN_H_ #ifndef _CGOBAN_H_ #include "../cgoban.h" #endif #ifndef _CLIENT_DATA_H_ #include "data.h" #endif #ifndef _CLIENT_BOARD_H_ #include "board.h" #endif #ifndef _CLIENT_GAME_H_ #include "game.h" #endif #ifndef _CLIENT_PLAYER_H_ #include "player.h" #endif #ifndef _CLIENT_LOOK_H_ #include "look.h" #endif #ifdef _CLIENT_MAIN_H_ #error LEVELIZATION ERROR #endif #define _CLIENT_MAIN_H_ 1 /********************************************************************** * Constants **********************************************************************/ #define MAIN_HISTORYMAXLEN 100 /********************************************************************** * Data Types **********************************************************************/ typedef enum { cliMain_idle, cliMain_inFile, cliMain_gotWho } CliMainState; typedef struct CliMain_struct { CliData *data; ButWin *win; But *bg, *quit, *help, *games, *players, *tin; But *userState, *looking, *open, *closed; AbutTerm *script; AbutMsg *message; CliGameList gameList; CliPlayerList playerList; CliMainState state; bool promptVisible; CliLook look; Str outStr; const char *fileEnd; ButWin *iWin; But *iBg, *iPic; Str history[MAIN_HISTORYMAXLEN]; int historyLen, historyBeingFilled, historyBeingViewed; void (*destroyCallback)(struct CliMain_struct *main, void *packet); void *packet; MAGIC_STRUCT } CliMain; /********************************************************************** * Functions **********************************************************************/ extern CliMain *cliMain_create(CliData *cd, void (*destroyCallback)(CliMain *main, void *packet), void *packet); extern void cliMain_activate(CliMain *main); extern void cliMain_message(CliMain *main, const char *message); extern void cliMain_clearMessage(CliMain *main); extern void cliMain_destroy(CliMain *cm); extern void cliMain_log(CliMain *main, const char *str); #endif /* _CLIENT_MAIN_H_ */ cgoban-1.9.14/src/client/match.h0000664000671000067100000000427507043224471012051 /* * src/client/match.h, part of Complete Goban (player program) * Copyright (C) 1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_MATCH_H_ #ifndef _CLIENT_DATA_H_ #include "data.h" #endif #define _CLIENT_MATCH_H_ 1 /********************************************************************** * Data Types **********************************************************************/ typedef struct CliMatch_struct CliMatch; typedef enum { cliMatch_nil, cliMatch_sent, cliMatch_recvd } CliMatchState; struct CliMatch_struct { CliMatch *next, **prev; CliData *data; CliMatchState state; ButWin *win; But *bg; But *title; But *namesBox; But *wBox, *wTitle; But *bBox, *bTitle; But *swap; But *rulesBox; But *sizeStr, *sizeIn, *sizeDown, *sizeUp; But *hcapStr, *hcapIn, *hcapDown, *hcapUp; But *komiStr, *komiIn, *komiDown, *komiUp; int size, hcap; float komi; But *timeBox; But *mainStr, *mainIn, *mainDown1, *mainDown5, *mainUp1, *mainUp5; But *byStr, *byIn, *byDown1, *byDown5, *byUp1, *byUp5; But *freeGame, *freeTitle; int mainTime, byTime; But *help, *ok, *cancel; Str wName, bName; bool meFirst; MAGIC_STRUCT }; /********************************************************************** * Functions **********************************************************************/ extern CliMatch *cliMatch_create(CliData *data, const char *oppName, CliMatch **next, int rankDiff); extern CliMatch *cliMatch_matchCommand(CliData *data, const char *command, CliMatch **next, int rankDiff); extern void cliMatch_declineCommand(CliMatch *match, const char *buf); extern void cliMatch_destroy(CliMatch *match); /* * If oppName is non-NULL, then destroyChain will fill in hcap etc. with * the game results if it finds the appropriate match form. * It returns TRUE if it does find the right form, FALSE otherwise. */ extern bool cliMatch_destroyChain(CliMatch *match, const char *oppName, int *hcap, float *komi, bool *free); extern void cliMatch_extraInfo(CliMatch *match, const char *oppName, int hcap, float komi, bool free); #endif /* _CLIENT_MATCH_H_ */ cgoban-1.9.14/src/client/player.h0000664000671000067100000000526307043224471012247 /* * src/client/player.h, part of Complete Goban (player program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_PLAYER_H_ #ifndef _CLIENT_DATA_H_ #include "data.h" #endif #ifndef _CLIENT_BOARD_H_ #include "board.h" #endif #ifndef _CLIENT_MATCH_H_ #include "match.h" #endif #ifdef _CLIENT_PLAYER_H_ Levelization Error. #endif #define _CLIENT_PLAYER_H_ 1 /********************************************************************** * Data Types **********************************************************************/ typedef enum { /* * It is important to note that when a player list is sorted by state, they * will be sorted with the lowest valued state on the bottom of the * player list. In addition, there's a character array in the * getListEl() function that depends on the order of this enum type. */ cliPlayer_unknown, cliPlayer_closed, cliPlayer_open, cliPlayer_looking, cliPlayer_noPlayer } CliPlayerState; typedef enum { cliPlayerSort_alphabet, cliPlayerSort_rank, cliPlayerSort_open } CliPlayerSort; typedef struct CliPlayer_struct { CliPlayerState state; CliPlayerSort sort; /* Needed for the qsort. :-( */ Str name, rank, idleTime; But *but; bool matchBut; int gameIn, gameOb; } CliPlayer; typedef struct CliPlayerList_struct { CliData *data; int maxPlayers; CliPlayer *players; CliPlayerSort sort; int sortEnd; CliMatch *match; ButWin *win; AbutSwin *swin; But *sortType, *nameSort, *rankSort, *stateSort; But *bg, *sBg, *list, *num, *titleBox, *title, *reload; bool elfBugReported; MAGIC_STRUCT } CliPlayerList; /********************************************************************** * Functions **********************************************************************/ extern CliPlayerList *cliPlayerList_init(CliPlayerList *gl, CliData *data); extern CliPlayerList *cliPlayerList_deinit(CliPlayerList *gl); extern void cliPlayerList_openWin(CliPlayerList *gl); extern void cliPlayerList_whoOutput(CliPlayerList *gl, const char *buf); extern void cliPlayerList_disconnected(CliPlayerList *pl, const char *buf); extern void cliPlayerList_connected(CliPlayerList *pl, const char *buf); extern void cliPlayerList_sort(CliPlayerList *pl); extern void cliPlayerList_playerInGame(CliPlayerList *pl, const char *player, int gameNum); extern int cliPlayerList_lookupPlayer(CliPlayerList *pl, const char *player); extern void cliPlayerList_setState(CliPlayerList *pl, int playerNum, CliPlayerState state); extern const char *cliPlayerList_getRank(CliPlayerList *pl, const char *name); #endif /* _CLIENT_MAIN_H_ */ cgoban-1.9.14/src/client/server.h0000664000671000067100000000174607043224471012263 /* * src/client/server.h, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_SERVER_H_ #define _CLIENT_SERVER_H_ 1 /********************************************************************** * Data Types **********************************************************************/ typedef enum { cliServer_nngs, cliServer_igs } CliServer; /********************************************************************** * Functions **********************************************************************/ /* * It seems that gcc has an error. If no _functions_ in a library file are * called, then the file is not linked in. Since I want "cliServer_names[]" * to get pulled in, I need to have a function here. :-( * This file no longer has *any* data in it, so I could just scrap it, but * what the hell. */ extern void cliServer_create(void); #endif /* _CLIENT_SERVER_H_ */ cgoban-1.9.14/src/client/setup.h0000664000671000067100000000216407043224471012110 /* * src/client/setup.h, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert. * See "configure.h.in" for more copyright information. */ #ifndef _CLIENT_SETUP_H_ #define _CLIENT_SETUP_H_ 1 #ifndef _CGOBAN_H_ #include "../cgoban.h" #endif #ifndef _CLIENT_DATA_H_ #include "data.h" #endif #ifndef _CLIENT_SERVER_H_ #include "server.h" #endif /********************************************************************** * Data Types **********************************************************************/ typedef struct CliSetup_struct { CliData *cd; AbutMsg *login; int serverNum; ClpEntry *userClp, *passwordClp; MAGIC_STRUCT } CliSetup; /********************************************************************** * Functions **********************************************************************/ extern CliSetup *cliSetup_create(Cgoban *cg, int serverNum); extern void cliSetup_createGmp(Cgoban *cg, int serverNum, const char *username, const char *password, const CliActions *actions, void *packet); extern void cliSetup_destroy(CliSetup *c); #endif /* _CLIENT_SETUP_H_ */ cgoban-1.9.14/src/client/Makefile.am0000664000671000067100000000053407466272676012655 noinst_LIBRARIES = libclient.a INCLUDES = -I $(top_srcdir)/wmslib/src libclient_a_SOURCES = \ board.c \ conn.c \ data.c \ game.c \ login.c \ look.c \ main.c \ match.c \ player.c \ server.c \ setup.c noinst_HEADERS = \ board.h \ conn.h \ data.h \ game.h \ login.h \ look.h \ main.h \ match.h \ player.h \ server.h \ setup.h cgoban-1.9.14/src/client/Makefile.in0000664000671000067100000002305007606355024012645 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../.. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPP = @CPP@ DATE = @DATE@ DEPDIR = @DEPDIR@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBS = @LIBS@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ noinst_LIBRARIES = libclient.a INCLUDES = -I $(top_srcdir)/wmslib/src libclient_a_SOURCES = \ board.c \ conn.c \ data.c \ game.c \ login.c \ look.c \ main.c \ match.c \ player.c \ server.c \ setup.c noinst_HEADERS = \ board.h \ conn.h \ data.h \ game.h \ login.h \ look.h \ main.h \ match.h \ player.h \ server.h \ setup.h subdir = src/client mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/configure.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) libclient_a_AR = $(AR) cru libclient_a_LIBADD = am_libclient_a_OBJECTS = board.$(OBJEXT) conn.$(OBJEXT) data.$(OBJEXT) \ game.$(OBJEXT) login.$(OBJEXT) look.$(OBJEXT) main.$(OBJEXT) \ match.$(OBJEXT) player.$(OBJEXT) server.$(OBJEXT) \ setup.$(OBJEXT) libclient_a_OBJECTS = $(am_libclient_a_OBJECTS) DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/board.Po ./$(DEPDIR)/conn.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/data.Po ./$(DEPDIR)/game.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/login.Po ./$(DEPDIR)/look.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/main.Po ./$(DEPDIR)/match.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/player.Po ./$(DEPDIR)/server.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/setup.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ DIST_SOURCES = $(libclient_a_SOURCES) HEADERS = $(noinst_HEADERS) DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in SOURCES = $(libclient_a_SOURCES) all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu src/client/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) AR = ar clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libclient.a: $(libclient_a_OBJECTS) $(libclient_a_DEPENDENCIES) -rm -f libclient.a $(libclient_a_AR) libclient.a $(libclient_a_OBJECTS) $(libclient_a_LIBADD) $(RANLIB) libclient.a mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/board.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conn.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/look.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/match.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/player.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setup.Po@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` CCDEPMODE = @CCDEPMODE@ uninstall-info-am: ETAGS = etags ETAGSFLAGS = tags: TAGS 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: $(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 "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../.. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ 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"; \ $(mkinstalldirs) "$(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 check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) $(HEADERS) installdirs: 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-tags dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-exec-am: install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic uninstall-am: uninstall-info-am .PHONY: GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES distclean distclean-compile \ distclean-depend distclean-generic distclean-tags distdir dvi \ dvi-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic tags uninstall uninstall-am \ uninstall-info-am # 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: cgoban-1.9.14/src/client/board.c0000664000671000067100000004240407043224471012033 /* * src/client/board.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include "../msg.h" #include "../sgfPlay.h" #include "../editBoard.h" #ifdef _CLIENT_BOARD_H_ LEVELIZATION ERROR #endif #include "board.h" /********************************************************************** * Forward Declarations **********************************************************************/ static bool rewAndBackOk(void *packet), fwdOk(void *packet); static bool ffwdOk(void *packet); static void gobanDestroyed(void *packet); static GobanOut quitClosePressed(void *packet); static GobanOut adjournPressed(void *packet); static GobanOut newKibitz(void *packet, const char *kib); static GobanOut rewPressed(void *packet); static GobanOut backPressed(void *packet); static GobanOut fwdPressed(void *packet); static GobanOut ffPressed(void *packet); static GobanOut donePressed(void *packet); static GobanOut gridPressed(void *packet, int loc); static GobanOut editPressed(void *packet); static ButOut shiftPressed(But *but, bool press); static ButOut ctrlPressed(But *but, bool press); static ButOut dontResign(But *but); static ButOut yesResign(But *but); static void cliBoard_updateWithToggle(CliBoard *cli, uint toggle); /********************************************************************** * Functions **********************************************************************/ CliBoard *cliBoard_create(CliData *data, int gameNum, const Str *wName, const Str *wRank, const Str *bName, const Str *bRank, int size, int handicap, float komi, int mainTime, int byTime, void (*destroy)(CliBoard *cli, void *packet), void *packet) { static const GobanActions actions = { gridPressed, quitClosePressed, cliBoard_passPressed, rewPressed, backPressed, fwdPressed, ffPressed, donePressed, NULL,adjournPressed, /* dispute, save */ editPressed, NULL, /* gameInfo */ &help_cliBoard, /* Help */ gobanDestroyed, rewAndBackOk, rewAndBackOk, fwdOk, ffwdOk}; static const ButKey shiftKeys[] = {{XK_Shift_L, 0,0}, {XK_Shift_R,0,0}, {0,0,0}}; static const ButKey ctrlKeys[] = {{XK_Control_L, 0,0}, {XK_Control_R,0,0}, {0,0,0}}; CliBoard *cli; Str gameName; cli = wms_malloc(sizeof(CliBoard)); MAGIC_SET(cli); cli->data = data; cliData_incRef(cli->data); cli->cg = data->cg; cli->sgf = sgf_create(); sgf_setSize(cli->sgf, size); sgf_setKomi(cli->sgf, komi); sgf_setPlayerName(cli->sgf, goStone_white, str_chars(wName)); sgf_playerRank(cli->sgf, goStone_white, str_chars(wRank)); sgf_setPlayerName(cli->sgf, goStone_black, str_chars(bName)); sgf_playerRank(cli->sgf, goStone_black, str_chars(bRank)); sgf_setDate(cli->sgf); sgf_style(cli->sgf, "Cgoban " VERSION); cli->gameNum = gameNum; cli->lastMoveRead = -1; cli->gameEnded = FALSE; cli->onTrack = TRUE; cli->timer.type = goTime_canadian; cli->timer.main = 360000; cli->timer.by = byTime; cli->timer.aux = 25; cli->game = goGame_create(size, goRules_japanese, handicap, komi, &cli->timer, FALSE); if (handicap) { sgf_setHandicap(cli->sgf, handicap); sgf_addHandicapStones(cli->sgf, cli->game->board); } cli->gameEnd = cli->sgf->active; cli->game->forcePlay = TRUE; cli->sgf->mode = sgfInsert_variant; str_init(&gameName); str_print(&gameName, msg_cliGameName, gameNum, str_chars(wName), str_chars(wRank), str_chars(bName), str_chars(bRank)); cli->goban = goban_create(cli->cg, &actions, cli, cli->game, "client", str_chars(&gameName)); goban_startTimer(cli->goban, goGame_whoseMove(cli->game)); goban_setHold(cli->goban, TRUE); but_setFlags(cli->goban->save, BUT_NOPRESS); str_deinit(&gameName); cli->goban->iDec1 = grid_create(&cli->cg->cgbuts, NULL, NULL, cli->goban->iWin, 2, BUT_DRAWABLE, 0); grid_setStone(cli->goban->iDec1, goStone_white, FALSE); if (data->server == cliServer_nngs) grid_setVersion(cli->goban->iDec1, CGBUTS_WORLDWEST(0)); else grid_setVersion(cli->goban->iDec1, CGBUTS_WORLDEAST(0)); cli->shiftKeytrap = butKeytrap_create(shiftPressed, cli, cli->goban->win, BUT_DRAWABLE|BUT_PRESSABLE); but_setKeys(cli->shiftKeytrap, shiftKeys); butKeytrap_setHold(cli->shiftKeytrap, FALSE); cli->ctrlKeytrap = butKeytrap_create(ctrlPressed, cli, cli->goban->win, BUT_DRAWABLE|BUT_PRESSABLE); but_setKeys(cli->ctrlKeytrap, ctrlKeys); butKeytrap_setHold(cli->ctrlKeytrap, FALSE); cli->destroy = destroy; cli->packet = packet; cli->moveWhite = !strcmp(str_chars(wName), str_chars(&data->userName)); cli->moveBlack = !strcmp(str_chars(bName), str_chars(&data->userName)); str_init(&cli->result); str_initStr(&cli->wName, wName); str_initStr(&cli->bName, bName); if (cli->moveWhite || cli->moveBlack) { goban_setKibitz(cli->goban, newKibitz, clp_getInt(data->cg->clp, "client.saykib")); } else { goban_setKibitz(cli->goban, newKibitz, -1); } if (cli->moveWhite) { if (data->actions) { cli->goban->pic->allowedMoves |= goPicMove_noWhite; data->actions->newGame(data->packet, goStone_white, size, handicap, komi, mainTime, byTime, cli); } } else { cli->goban->pic->allowedMoves |= goPicMove_noWhite; } if (cli->moveBlack) { if (data->actions) { cli->goban->pic->allowedMoves |= goPicMove_noBlack; data->actions->newGame(data->packet, goStone_black, size, handicap, komi, mainTime, byTime, cli); } } else { cli->goban->pic->allowedMoves |= goPicMove_noBlack; } butCt_setText(cli->goban->save, msg_adjourn); if (cli->moveWhite || cli->moveBlack) { but_setFlags(cli->goban->save, BUT_PRESSABLE); butCt_setText(cli->goban->quit, msg_resign); } cliBoard_update(cli); return(cli); } void cliBoard_destroy(CliBoard *cli, bool propagate) { assert(MAGIC(cli)); sgf_destroy(cli->sgf); if (cli->data->actions && (cli->moveWhite || cli->moveBlack)) { cli->data->actions->endGame(cli->data->packet); } if (cli->goban) { goban_destroy(cli->goban, FALSE); cli->goban = NULL; } if (cli->game) { goGame_destroy(cli->game); cli->game = NULL; } if (propagate && cli->destroy) { cli->destroy(cli, cli->packet); } cliData_decRef(cli->data); MAGIC_UNSET(cli); wms_free(cli); } Bool cliBoard_gotMove(CliBoard *cli, const char *locStr, GoStone color, int moveNum) { int loc, oldMoveNum = 0; SgfElem *oldSgf = NULL; Bool result = TRUE; assert(MAGIC(cli)); if (cli->game->handicap != 0) --moveNum; if (moveNum != cli->lastMoveRead + 1) { return(TRUE); } cli->lastMoveRead = moveNum; if (!strcmp(locStr, "Pass")) loc = 0; else { loc = goBoard_str2Loc(cli->game->board, locStr); if (loc == -1) { return(FALSE); } } if (color == goStone_white) { if (cli->moveBlack && cli->data->actions) { cli->data->actions->gotMove(cli->data->packet, goStone_white, loc); } } else { assert(color == goStone_black); if (cli->moveWhite && cli->data->actions) { cli->data->actions->gotMove(cli->data->packet, goStone_black, loc); } } cli->sgf->mode = sgfInsert_main; if (cli->gameEnd != cli->sgf->active) { oldSgf = cli->sgf->active; cli->sgf->active = cli->gameEnd; if (cli->onTrack) { oldMoveNum = cli->game->moveNum; goGame_moveTo(cli->game, cli->game->maxMoves); } } goban_stopTimer(cli->goban); if (cli->onTrack) { if (!goGame_isLegal(cli->game, color, loc)) result = FALSE; else goGame_move(cli->game, color, loc, &cli->goban->timers[color]); } goban_startTimer(cli->goban, goGame_whoseMove(cli->game)); sgf_addNode(cli->sgf); assert(cli->sgf->active == cli->gameEnd->childH); if (loc == 0) sgf_pass(cli->sgf, color); else sgf_move(cli->sgf, color, goBoard_loc2Sgf(cli->game->board, loc)); cli->gameEnd = cli->sgf->active; if (oldSgf) { cli->sgf->active = oldSgf; if (cli->onTrack) goGame_moveTo(cli->game, oldMoveNum); } cli->sgf->mode = sgfInsert_variant; if (cli->onTrack) cliBoard_update(cli); return(result); } static bool rewAndBackOk(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); return(cli->game->moveNum > 0); } static bool fwdOk(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); if (cli->onTrack) { return(cli->sgf->active != cli->gameEnd); } else { return(cli->sgf->active->childH != NULL); } } static bool ffwdOk(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); return((cli->game->moveNum < cli->game->maxMoves) || (cli->gameEnd != cli->sgf->active)); } static void gobanDestroyed(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); cli->goban = NULL; cliBoard_destroy(cli, TRUE); } static GobanOut adjournPressed(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); assert(cli->moveBlack || cli->moveWhite); cliConn_send(&cli->data->conn, "adjourn\n"); return(gobanOut_noDraw); } static GobanOut quitClosePressed(void *packet) { CliBoard *cli = packet; AbutMsgOpt buttons[2]; assert(MAGIC(cli)); if (cli->moveBlack || cli->moveWhite) { buttons[0].name = msg_noCancel; buttons[0].callback = dontResign; buttons[0].packet = cli; buttons[0].keyEq = NULL; buttons[1].name = msg_yesResign; buttons[1].callback = yesResign; buttons[1].packet = cli; buttons[1].keyEq = NULL; if (cli->goban->msgBox) abutMsg_destroy(cli->goban->msgBox, FALSE); cli->goban->msgBox = abutMsg_optCreate(cli->cg->abut, cli->goban->win, 4, msg_reallyResign, NULL, NULL, 2, buttons); } else { cliBoard_destroy(cli, TRUE); } return(gobanOut_noDraw); } static GobanOut newKibitz(void *packet, const char *kib) { CliBoard *cli = packet; const char *opponent; assert(MAGIC(cli)); if (clpEntry_getBool(cli->data->numKibitz)) str_print(&cli->data->cmdBuild, "%d %s: %s\n", cli->game->maxMoves, str_chars(&cli->data->userName), kib); else str_print(&cli->data->cmdBuild, "%s: %s\n", str_chars(&cli->data->userName), kib); goban_catComments(cli->goban, str_chars(&cli->data->cmdBuild)); if (cli->moveWhite || cli->moveBlack) { switch(goban_kibType(cli->goban)) { case 0: str_print(&cli->data->cmdBuild, "say %s\n", kib); break; case 1: assert(MAGIC(&cli->bName)); assert(MAGIC(&cli->wName)); if (cli->moveWhite) opponent = str_chars(&cli->bName); else opponent = str_chars(&cli->wName); str_print(&cli->data->cmdBuild, "tell %s %s\nkibitz %d %s\n", opponent, kib, cli->gameNum, kib); break; case 2: str_print(&cli->data->cmdBuild, "kibitz %d %s\n", cli->gameNum, kib); break; } } else str_print(&cli->data->cmdBuild, "kibitz %d %s\n", cli->gameNum, kib); if (cli->destroy) cliConn_send(&cli->data->conn, str_chars(&cli->data->cmdBuild)); return(gobanOut_noDraw); } static GobanOut rewPressed(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); if (cli->game->state > goGameState_play) { cli->game->state = goGameState_play; } goGame_moveTo(cli->game, 0); sgf_setActiveNodeNumber(cli->sgf, 0); cliBoard_update(cli); return(gobanOut_noDraw); } static GobanOut backPressed(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); if (cli->game->state > goGameState_play) { cli->game->state = goGameState_play; } goGame_moveTo(cli->game, cli->game->moveNum - 1); sgf_setActiveNodeNumber(cli->sgf, cli->game->moveNum); cliBoard_update(cli); return(gobanOut_noDraw); } static GobanOut fwdPressed(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); assert(cli->game->moveNum < cli->game->maxMoves); goGame_moveTo(cli->game, cli->game->moveNum + 1); cli->sgf->active = cli->sgf->active->activeChild; while ((cli->sgf->active->activeChild != NULL) && (cli->sgf->active->activeChild->type != sgfType_node)) { cli->sgf->active = cli->sgf->active->activeChild; } cliBoard_update(cli); return(gobanOut_noDraw); } static GobanOut ffPressed(void *packet) { CliBoard *cli = packet; SgfElem *elem; assert(MAGIC(cli)); for (elem = &cli->sgf->top; elem; elem = elem->childH) { elem->activeChild = elem->childH; } sgf_play(cli->sgf, cli->game, NULL, -1, cli->gameEnd); assert(cli->sgf->active == cli->gameEnd); goGame_moveTo(cli->game, cli->game->maxMoves); cli->onTrack = TRUE; cliBoard_update(cli); return(gobanOut_noDraw); } static GobanOut gridPressed(void *packet, int loc) { return(cliBoard_gridPressed(packet, loc, FALSE)); } GobanOut cliBoard_gridPressed(void *packet, int loc, bool forceMove) { CliBoard *cli = packet; char move[10]; int newNode, i; assert(MAGIC(cli)); if (!forceMove && (butEnv_keyModifiers(cli->cg->env) & ShiftMask)) { strcpy(move, goBoard_loc2Sgf(cli->game->board, loc)); newNode = -1; if (goBoard_stone(cli->game->board, loc) == goStone_empty) { i = sgfElem_findMove(cli->sgf->active, move, 1); if (i >= 0) { newNode = cli->game->moveNum + i; } else { i = sgfElem_findMove(cli->sgf->active, move, -1); if (i >= 0) newNode = cli->game->moveNum - i; } } else { i = sgfElem_findMove(cli->sgf->active, move, -1); assert(i >= 0); newNode = cli->game->moveNum - i; } if (newNode >= 0) { if (cli->game->state > goGameState_play) { cli->game->state = goGameState_play; } goGame_moveTo(cli->game, newNode); sgf_setActiveNodeNumber(cli->sgf, newNode); if (cli->gameEnded && (cli->game->moveNum == cli->game->maxMoves)) { if (cli->goban->activeTimer != goStone_empty) goban_stopTimer(cli->goban); cli->game->state = goGameState_selectDead; } cliBoard_update(cli); return(gobanOut_noDraw); } else { return(gobanOut_err); } } else if (!forceMove && (butEnv_keyModifiers(cli->cg->env) & ControlMask)) { sgf_addNode(cli->sgf); sgf_move(cli->sgf, cli->game->whoseMove, goBoard_loc2Sgf(cli->game->board, loc)); goGame_move(cli->game, cli->game->whoseMove, loc, &cli->goban->timers[cli->game->whoseMove]); cli->onTrack = FALSE; cliBoard_update(cli); return(gobanOut_noDraw); } else { goBoard_loc2Str(cli->game->board, loc, move); strcat(move, "\n"); cliConn_send(&cli->data->conn, move); return(gobanOut_noDraw); } } GobanOut cliBoard_passPressed(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); cliConn_send(&cli->data->conn, "pass\n"); return(gobanOut_noDraw); } static GobanOut donePressed(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); cliConn_send(&cli->data->conn, "done\n"); return(gobanOut_noDraw); } static GobanOut editPressed(void *packet) { CliBoard *cli = packet; assert(MAGIC(cli)); assert(MAGIC(cli->data)); editBoard_createSgf(cli->data->cg, cli->sgf); return(gobanOut_noDraw); } static ButOut shiftPressed(But *but, bool press) { CliBoard *cli = but_packet(but); assert(MAGIC(cli)); /* * Alas, the modifier flags don't change until AFTER the press, so we * have to invert the shift here. */ cliBoard_updateWithToggle(cli, ShiftMask); return(0); } static ButOut ctrlPressed(But *but, bool press) { CliBoard *cli = but_packet(but); assert(MAGIC(cli)); /* * Alas, the modifier flags don't change until AFTER the press, so we * have to invert the shift here. */ cliBoard_updateWithToggle(cli, ControlMask); return(0); } static ButOut dontResign(But *but) { CliBoard *cli = but_packet(but); assert(MAGIC(cli)); goban_noMessage(cli->goban); return(0); } static ButOut yesResign(But *but) { CliBoard *cli = but_packet(but); assert(MAGIC(cli)); cliConn_send(&cli->data->conn, "resign\n"); goban_noMessage(cli->goban); return(0); } void cliBoard_update(CliBoard *cli) { cliBoard_updateWithToggle(cli, 0); } static void cliBoard_updateWithToggle(CliBoard *cli, uint toggle) { uint moves = 0; /* To shut up gcc warning. */ if (cli->gameEnded && (cli->gameEnd == cli->sgf->active)) { if (cli->goban->activeTimer != goStone_empty) goban_stopTimer(cli->goban); cli->game->state = goGameState_selectDead; } else cli->game->state = goGameState_play; switch((butEnv_keyModifiers(cli->cg->env) & (ShiftMask|ControlMask)) ^ toggle) { case 0: moves = goPicMove_legal; if (!cli->moveWhite || cli->data->actions || (cli->sgf->active != cli->gameEnd)) { moves |= goPicMove_noWhite; } if (!cli->moveBlack || cli->data->actions || (cli->sgf->active != cli->gameEnd)) { moves |= goPicMove_noBlack; } break; case ShiftMask: moves = goPicMove_empty | goPicMove_stone; if (!(but_getFlags(cli->goban->pass) & BUT_PRESSABLE)) moves |= goPicMove_noPass; break; case ControlMask: moves = goPicMove_legal; break; case ShiftMask|ControlMask: moves = 0; break; } cli->goban->pic->allowedMoves = moves; goban_update(cli->goban); if (str_len(&cli->result) && (cli->sgf->active == cli->gameEnd)) { butText_set(cli->goban->infoText, str_chars(&cli->result)); } } cgoban-1.9.14/src/client/conn.c0000664000671000067100000003065507043224471011706 /* * src/client/conn.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #ifdef STDC_HEADERS #include #include #endif /* STDC_HEADERS */ #include #include #include #if HAVE_NETINET_IN_H #include #endif #if HAVE_SYS_IN_H #include #endif #if HAVE_SYS_INET_H #include #endif #include #if HAVE_ARPA_NAMESER_H #include #endif #if HAVE_RESOLV_H #include #endif #include #include #include #include #include #include #include #include "../cgoban.h" #include "../msg.h" #include "server.h" #ifdef _CLIENT_CONN_H_ LEVELIZATION ERROR #endif #include "conn.h" /********************************************************************** * Constants **********************************************************************/ #define TRACELOG 0 static const int defaultInLen = (8 * 1024); static const int defaultOutLen = 1024; /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut newNetData(void *packet, int fd); static void expandBuf(char **buf, int *size, int len); static int telnetMunge(CliConn *cc, int amtRead); static ButOut writeData(void *packet, int fd); static void sendNextCommand(CliConn *conn); static void transmitData(CliConn *cc, const char *str, int strLen); static void sockConn(CliConn *conn); static void progConn(CliConn *conn); /********************************************************************** * Functions **********************************************************************/ CliConn *cliConn_init(CliConn *cc, Cgoban *cg, int serverNum, CliServer protocol, uchar loChar, uchar hiChar, void (*newData)(void *packet, const char *dataIn, int dataLen), void *packet) { const char *cliDirect; assert(MAGIC(cg)); MAGIC_SET(cc); cc->cg = cg; cc->fd = -1; cc->inBuf = NULL; cc->outBuf = NULL; cc->err = cliConnErr_ok; cc->serverNum = serverNum; cc->server = protocol; cc->loginMode = TRUE; if (protocol == cliServer_igs) str_init(&cc->outMsgs); cliDirect = clp_getStrNum(cg->clp, "client.direct", serverNum); cc->directConn = (cliDirect[0] == 't'); if (cc->directConn) { sockConn(cc); } else { assert(cliDirect[0] == 'f'); progConn(cc); } if (cc->err != cliConnErr_ok) return(cc); fcntl(cc->fd, F_SETFL, O_NONBLOCK); butEnv_addFile(cg->env, BUT_READFILE, cc->fd, cc, newNetData); cc->inLen = 0; cc->telnetState = 0; cc->inBuf = wms_malloc(cc->inSize = defaultInLen); cc->outLen = 0; cc->outBuf = wms_malloc(cc->outSize = defaultOutLen); cc->promptReady = TRUE; if (loChar <= '\r') /* DON'T pass those damn \r's! */ loChar = '\r' + 1; cc->loChar = loChar; cc->hiChar = hiChar; cc->newData = newData; cc->packet = packet; return(cc); } CliConn *cliConn_deinit(CliConn *cc) { assert(MAGIC(cc)); if (cc->fd >= 0) { butEnv_rmFile(cc->cg->env, BUT_READFILE, cc->fd); close(cc->fd); } if (cc->inBuf) wms_free(cc->inBuf); if (cc->outBuf) wms_free(cc->outBuf); if (cc->server == cliServer_igs) str_deinit(&cc->outMsgs); MAGIC_UNSET(cc); return(cc); } static ButOut newNetData(void *packet, int fd) { CliConn *cc = packet; int amtRead, totalAmtRead, readLen, lineStart, lineEnd; assert(MAGIC(cc)); totalAmtRead = 0; do { if (cc->inLen + totalAmtRead + 1 >= cc->inSize) expandBuf(&cc->inBuf, &cc->inSize, cc->inLen); readLen = cc->inSize - (cc->inLen + totalAmtRead + 1); amtRead = read(cc->fd, cc->inBuf + cc->inLen, readLen); if (amtRead < 0) { if (errno == EAGAIN) amtRead = 0; else { cc->newData(cc->packet, NULL, errno); return(0); } } else if (amtRead == 0) { cc->newData(cc->packet, NULL, errno); return(0); } totalAmtRead += amtRead; } while (amtRead == readLen); totalAmtRead = telnetMunge(cc, totalAmtRead); if (totalAmtRead < 0) { cc->newData(cc->packet, NULL, EPIPE); return(0); } if (totalAmtRead > 0) { cc->inLen += totalAmtRead; assert(cc->inLen < cc->inSize); lineStart = 0; for (;;) { lineEnd = lineStart; while ((lineEnd < cc->inLen) && (cc->inBuf[lineEnd] != '\n')) ++lineEnd; if ((lineEnd < cc->inLen) || (cc->loginMode && (((lineEnd - lineStart == 7) && !strncmp(cc->inBuf + lineStart, "Login: ", 7)) || ((lineEnd - lineStart == 10) && !strncmp(cc->inBuf + lineStart, "Password: ", 10)) || ((lineEnd - lineStart == 3) && !strncmp(cc->inBuf + lineStart, "#> ", 3))))) { cc->inBuf[lineEnd] = '\0'; #if TRACELOG printf("%s\n", cc->inBuf + lineStart); #endif cc->newData(cc->packet, cc->inBuf + lineStart, lineEnd - lineStart); lineStart = lineEnd + 1; } else break; } if (lineStart >= cc->inLen) { cc->inLen = 0; } else if (lineStart > 0) { memmove(cc->inBuf, cc->inBuf + lineStart, cc->inLen - lineStart); cc->inLen -= lineStart; } } return(0); } static void expandBuf(char **buf, int *size, int len) { char *newBuf; int newSize; newSize = *size * 2; newBuf = wms_malloc(newSize); memcpy(newBuf, *buf, len); if (*buf) wms_free(*buf); *buf = newBuf; *size = newSize; } /* * This returns the number of bytes left after stripping out \r's, telnet * escape codes, etc. */ static int telnetMunge(CliConn *cc, int amtRead) { unsigned char c; char *src, *dest; src = dest = cc->inBuf + cc->inLen; while (src < cc->inBuf + cc->inLen + amtRead) { c = (unsigned char)*(src++); switch (cc->telnetState) { case 0: /* Haven't skipped over any control chars or telnet commands */ if (c == IAC) { cc->telnetState = 1; } else if ((c == '\n') || ((c >= cc->loChar) && (c <= cc->hiChar))) { *(dest++) = c; } break; case 1: /* got telnet IAC */ if (c == IP) { return(-1); /* ^C = logout */ } else if (c == DO) { cc->telnetState = 4; } else if ((c == WILL) || (c == DONT) || (c == WONT)) { cc->telnetState = 3; /* this is cheesy, but we aren't using 'em */ } else { cc->telnetState = 0; } break; case 3: /* some telnet junk we're ignoring */ cc->telnetState = 0; break; case 4: /* got IAC DO */ /* * We really should handle this right. But it doesn't seem to matter * when you're connecting to one of the servers. I know that it * doesn't matter if you're using NNGS, because I wrote the NNGS * network code and I don't know what these escapes are supposed * to mean. */ cc->telnetState = 0; break; default: assert(0); } } return(dest - (cc->inBuf + cc->inLen)); } void cliConn_send(CliConn *conn, const char *str) { #if TRACELOG printf("***SEND {\n%s***SEND }\n", str); #endif if ((conn->server == cliServer_nngs) || conn->loginMode) { transmitData(conn, str, strlen(str)); } else { str_catChars(&conn->outMsgs, str); if (conn->promptReady) sendNextCommand(conn); } } void cliConn_prompt(CliConn *conn) { if (conn->server == cliServer_igs) { conn->promptReady = TRUE; sendNextCommand(conn); } } /* * The IGS has a bug where only the first command in a TCP packet is executed; * the rest are ignored. Yes, it really is that stupid. Here I take out * a single command and transmit it. If you're connected to the NNGS, then * this is all unnecessary so cliConn_send() would have jumped straight * to transmitData(). */ static void sendNextCommand(CliConn *conn) { const char *crPos; int sendLen; Str temp; assert(conn->server == cliServer_igs); assert(conn->promptReady); if (str_len(&conn->outMsgs)) { crPos = strchr(str_chars(&conn->outMsgs), '\n'); assert(crPos != NULL); sendLen = (crPos - str_chars(&conn->outMsgs)) + 1; transmitData(conn, str_chars(&conn->outMsgs), sendLen); if (sendLen == str_len(&conn->outMsgs)) { str_clip(&conn->outMsgs, 0); } else { str_initStr(&temp, &conn->outMsgs); str_copyCharsLen(&conn->outMsgs, str_chars(&temp) + sendLen, str_len(&temp) - sendLen); str_deinit(&temp); } conn->promptReady = FALSE; } } static void transmitData(CliConn *cc, const char *str, int strLen) { int amtWritten; assert(MAGIC(cc)); if (cc->outLen == 0) { amtWritten = write(cc->fd, str, strLen); if (amtWritten < 0) amtWritten = 0; } else amtWritten = 0; if (amtWritten < strLen) { while (cc->outLen + amtWritten > cc->outSize) expandBuf(&cc->outBuf, &cc->outSize, cc->outLen); memcpy(cc->outBuf + cc->outLen, str + amtWritten, strLen - amtWritten); if (cc->outLen == 0) { butEnv_addFile(cc->cg->env, BUT_WRITEFILE, cc->fd, cc, writeData); } cc->outLen += strLen - amtWritten; } } static ButOut writeData(void *packet, int fd) { CliConn *cc = packet; int amtWritten; assert(MAGIC(cc)); assert(cc->fd == fd); assert(cc->outLen > 0); amtWritten = write(fd, cc->outBuf, cc->outLen); if (amtWritten < 0) amtWritten = 0; if (amtWritten == cc->outLen) { cc->outLen = 0; butEnv_rmFile(cc->cg->env, BUT_WRITEFILE, cc->fd); } else { memmove(cc->outBuf, cc->outBuf + amtWritten, cc->outLen - amtWritten); cc->outLen -= amtWritten; } return(0); } static void sockConn(CliConn *conn) { Cgoban *cg = conn->cg; const char *address, *portStr; struct hostent *hp; struct sockaddr_in sa; int port; bool lookupNeeded; int matches, addrA, addrB, addrC, addrD; address = clp_getStrNum(cg->clp, "client.address", conn->serverNum); matches = sscanf(address, "%d.%d.%d.%d", &addrA, &addrB, &addrC, &addrD); lookupNeeded = (matches != 4); portStr = clp_getStrNum(cg->clp, "client.port", conn->serverNum); port = atoi(portStr); conn->fd = socket(AF_INET, SOCK_STREAM, 0); if (conn->fd < 0) { conn->err = cliConnErr_openSocket; conn->errOut.errNum = errno; return; } sa.sin_family = AF_INET; if (lookupNeeded) { if ((hp = gethostbyname(address)) == NULL) { close(conn->fd); conn->fd = -1; conn->err = cliConnErr_lookup; conn->errOut.serverName = address; return; } memcpy(&sa.sin_addr, hp->h_addr, hp->h_length); } else { sa.sin_addr.s_addr = htonl((addrA << IN_CLASSA_NSHIFT) | (addrB << IN_CLASSB_NSHIFT) | (addrC << IN_CLASSC_NSHIFT) | addrD); } sa.sin_port = htons(port); if (connect(conn->fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) { close(conn->fd); conn->fd = -1; conn->err = cliConnErr_connect; conn->errOut.errNum = errno; return; } } static void progConn(CliConn *conn) { Cgoban *cg = conn->cg; const char *cmd; int sockets[2]; int result; int pid, fd; cmd = clp_getStrNum(cg->clp, "client.connCmd", conn->serverNum); result = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets); if (result < 0) { conn->err = cliConnErr_connect; conn->errOut.errNum = errno; return; } pid = fork(); if (pid < 0) { close(sockets[0]); close(sockets[1]); conn->err = cliConnErr_connect; conn->errOut.errNum = errno; return; } if (pid == 0) { /* The child. */ for (fd = 0; fd < 100; ++fd) { if ((fd != 2) && /* Don't close stderr! */ (fd != sockets[1])) close(fd); } if (dup(sockets[1]) != 0) { fprintf(stderr, "I couldn't fdup into stdin!\n"); exit(1); } if (dup(sockets[1]) != 1) { fprintf(stderr, "I couldn't fdup into stdout!\n"); exit(1); } result = system(cmd); if (result != 0) { Str msg; str_init(&msg); str_print(&msg, msg_commandError, cmd, result); fprintf(stderr, "%s\n", str_chars(&msg)); /* * createMsgWindow doesn't work here, since I'm in a subprocess. * Oh well. * * cgoban_createMsgWindow(cg, "Cgoban Error", str_chars(&msg)); */ str_deinit(&msg); } exit(result); } else { close(sockets[1]); conn->fd = sockets[0]; } } cgoban-1.9.14/src/client/data.c0000664000671000067100000000370007043224471011651 /* * src/client/data.c, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include "../cgoban.h" #ifdef _CLIENT_DATA_H_ #error LEVELIZATION ERROR #endif #include "data.h" /********************************************************************** * Forward Declarations **********************************************************************/ static void cliData_destroy(CliData *cd); /********************************************************************** * Functions **********************************************************************/ CliData *cliData_create(Cgoban *cg, int serverNum, const CliActions *actions, void *packet) { CliData *cd; const char *serverId; assert(MAGIC(cg)); cd = wms_malloc(sizeof(CliData)); MAGIC_SET(cd); cd->state = cliData_setup; cd->cg = cg; cd->serverNum = serverNum; serverId = clp_getStrNum(cg->clp, "client.protocol", serverNum); if (serverId[0] == 'n') cd->server = cliServer_nngs; else { assert(serverId[0] == 'i'); cd->server = cliServer_igs; } cd->serverName = clp_getStrNum(cg->clp, "client.server", serverNum); str_init(&cd->userName); str_init(&cd->cmdBuild); cd->numKibitz = clp_lookup(cg->clp, "client.numberKibitz"); cd->connValid = FALSE; cd->actions = actions; cd->packet = packet; cd->refCount = 1; return(cd); } void cliData_closeConns(CliData *cd) { assert(MAGIC(cd)); if (cd->connValid) { cliConn_deinit(&cd->conn); cd->connValid = FALSE; } } static void cliData_destroy(CliData *cd) { assert(MAGIC(cd)); if (cd->actions) { cd->actions->logout(cd->packet); } str_deinit(&cd->userName); str_deinit(&cd->cmdBuild); cliData_closeConns(cd); MAGIC_UNSET(cd); wms_free(cd); } void cliData_decRef(CliData *cd) { if (--cd->refCount == 0) cliData_destroy(cd); } cgoban-1.9.14/src/client/game.c0000664000671000067100000007520607577677075011713 /* * src/client/game.c, part of Complete Goban (game program) * Copyright (C) 1995-1997 William Shubert * See "configure.h.in" for more copyright information. */ /* * Removed the bogus BadElf messages that were caused by messages from * the server that weren't being caught. Dan Niles (-DDN-) */ #include #include #include #include #include "../msg.h" #include #include #include #include #ifdef _CLIENT_GAME_H_ #error LEVELIZATION ERROR #endif #include "game.h" /********************************************************************** * Forward Declarations **********************************************************************/ static void expandGames(CliGameList *gl, int gameNum); static void boardDead(CliBoard *board, void *packet); static ButOut unmap(ButWin *win); static ButOut map(ButWin *win); static ButOut resize(ButWin *win); static ButOut destroy(ButWin *win); static void getListEl(CliGameList *gl, int gNum, Str *out); static ButOut sResize(ButWin *win); static ButOut reload(But *but); static ButOut listPressed(But *but, int line); static ButOut observeGame(void *packet, int boardId); /********************************************************************** * Functions **********************************************************************/ CliGameList *cliGameList_init(CliGameList *gl, CliData *data, CliPlayerList *playerList) { MAGIC_SET(gl); gl->data = data; gl->playerList = playerList; gl->maxGames = 0; gl->games = NULL; gl->defaultGame = -1; gl->playGame = -1; gl->kibGame = -1; gl->win = NULL; gl->elfBugReported = FALSE; data->observeGame = observeGame; data->obPacket = gl; return(gl); } CliGameList *cliGameList_deinit(CliGameList *gl) { int i; Cgoban *cg; assert(MAGIC(gl)); cg = gl->data->cg; for (i = 0; i < gl->maxGames; ++i) { if (gl->games[i].board) { cliBoard_destroy(gl->games[i].board, FALSE); gl->games[i].board = NULL; } str_deinit(&gl->games[i].wName); str_deinit(&gl->games[i].bName); str_deinit(&gl->games[i].wRank); str_deinit(&gl->games[i].bRank); str_deinit(&gl->games[i].flags); } if (gl->games) wms_free(gl->games); if (gl->win) { clp_setInt(cg->clp, "client.games.w", (butWin_w(gl->win) - butWin_getMinW(gl->win)) / butWin_getWStep(gl->win)); clp_setDouble(cg->clp, "client.games.h2", ((double)butWin_h(gl->win) / (double)(butWin_getMinW(gl->win) + 6 * butWin_getWStep(gl->win)))); clp_setInt(cg->clp, "client.games.x", butWin_x(gl->win)); clp_setInt(cg->clp, "client.games.y", butWin_y(gl->win)); butWin_setDestroy(gl->win, NULL); butWin_destroy(gl->win); } MAGIC_UNSET(gl); return(gl); } void cliGameList_openWin(CliGameList *gl) { int winW, minWinW, winH; Cgoban *cg; int i; bool err; Str listEl; int physH, bw; double wHRatio; assert(MAGIC(gl)); str_init(&listEl); if (gl->win) { XRaiseWindow(butEnv_dpy(gl->data->cg->env), butWin_xwin(gl->win)); return; } cg = gl->data->cg; physH = butEnv_fontH(gl->data->cg->env, 0); bw = butEnv_stdBw(gl->data->cg->env); minWinW = physH * 18 + bw * 8; winW = minWinW + physH * 2 * clp_getInt(cg->clp, "client.games.w"); wHRatio = clp_getDouble(cg->clp, "client.games.h2"); winH = ((double)(minWinW + physH * 12) * wHRatio + 0.5); str_print(&listEl, "%s Game List", gl->data->serverName); gl->win = butWin_create(gl, cg->env, str_chars(&listEl), winW, winH, unmap, map, resize, destroy); butWin_setMinW(gl->win, minWinW); butWin_setMaxW(gl->win, minWinW + physH * 12); butWin_setWStep(gl->win, physH * 2); i = clpEntry_iGetInt(clp_lookup(cg->clp, "client.games.x"), &err); if (!err) butWin_setX(gl->win, i); i = clpEntry_iGetInt(clp_lookup(cg->clp, "client.games.y"), &err); if (!err) butWin_setY(gl->win, i); butWin_setMaxH(gl->win, 0); butWin_setMinH(gl->win, cg->fontH * 6); butWin_activate(gl->win); gl->bg = butBoxFilled_create(gl->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(gl->bg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); gl->swin = abutSwin_create(gl, gl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, sResize); gl->sBg = butPlain_create(gl->swin->win, 0, BUT_DRAWABLE, BUT_BG); gl->list = butList_create(listPressed, gl, gl->swin->win, 2, BUT_DRAWABLE|BUT_PRESSABLE); gl->titleBox = butBoxFilled_create(gl->win, 1, BUT_DRAWABLE); gl->title = butList_create(NULL, NULL, gl->win, 2, BUT_DRAWABLE); butList_setLen(gl->title, 1); butList_changeLine(gl->title, 0, msg_gameListDesc); gl->reload = butCt_create(reload, gl, gl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, "*"); for (i = 1; i < gl->maxGames; ++i) { if (gl->games[i].state != cliGame_noGame) { getListEl(gl, i, &listEl); butList_setLen(gl->list, i); butList_changeLine(gl->list, i - 1, str_chars(&listEl)); if (gl->games[i].state == cliGame_over) { butList_setPress(gl->list, i - 1, FALSE); } } } butCan_resizeWin(gl->swin->win, 0, butList_len(gl->list) * butEnv_fontH(gl->data->cg->env, 0) + butEnv_stdBw(gl->data->cg->env) * 2, TRUE); str_deinit(&listEl); } void cliGameList_gotMove(CliGameList *gl, const char *buf) { int args; int moveNum, handicap; char color, locStr[6]; const char *oppName; GoStone stone; CliGame *g; int time1, time2, stonesLeft1, stonesLeft2; Bool IGS_DeadWorkAround; assert(MAGIC(gl)); if (buf[0] == 'G') { args = sscanf(buf, "Game %d %*s %*s (%*d %d %d) vs %*s (%*d %d %d)", &gl->defaultGame, &time1, &stonesLeft1, &time2, &stonesLeft2); assert(args == 5); expandGames(gl, gl->defaultGame); g = &gl->games[gl->defaultGame]; switch(g->state) { case cliGame_noGame: case cliGame_over: str_print(&gl->data->cmdBuild, "games %d\nmoves %d\n", gl->defaultGame, gl->defaultGame); cliConn_send(&gl->data->conn, str_chars(&gl->data->cmdBuild)); gl->defaultGame = -1; return; break; case cliGame_waitNoOb: gl->defaultGame = -1; return; break; default: if (g->board) { g->board->goban->timers[goStone_white].timeLeft = time1; g->board->goban->timers[goStone_black].timeLeft = time2; if (stonesLeft1 < 0) stonesLeft1 = 0; if (stonesLeft2 < 0) stonesLeft2 = 0; g->board->goban->timers[goStone_white].aux = stonesLeft1; g->board->goban->timers[goStone_black].aux = stonesLeft2; } else { /* * This code is also in gotGameInfo(). It really belongs here only * but a bug in NNGS forces me to put it in both places. */ g->state = cliGame_observing; g->board = cliBoard_create(gl->data, gl->defaultGame, &g->wName, &g->wRank, &g->bName, &g->bRank, g->size, g->handicap, g->komi, time1, g->byTime * 60, boardDead, gl); g->gamePressed = FALSE; g->fromMatch = FALSE; if (g->board->moveWhite || g->board->moveBlack) { gl->playGame = gl->defaultGame; if (gl->playerList->match) { if (g->board->moveWhite) oppName = str_chars(&g->bName); else oppName = str_chars(&g->wName); g->fromMatch = cliMatch_destroyChain(gl->playerList->match, oppName, &g->handicap, &g->komi, &g->free); } } str_print(&gl->data->cmdBuild, "moves %d\n", gl->defaultGame); cliConn_send(&gl->data->conn, str_chars(&gl->data->cmdBuild)); } break; } } else if (gl->defaultGame >= 0) { g = &gl->games[gl->defaultGame]; args = sscanf(buf, "%d(%c): %5s", &moveNum, &color, locStr); assert(args == 3); if (!strncmp(locStr, "Handi",5)) { sscanf(buf, "%*s %*s %d", &handicap); if (handicap != g->handicap) { g->handicap = handicap; goGame_destroy(g->board->game); g->board->game = goGame_create(g->size, goRules_japanese, g->handicap, g->komi, &g->board->timer, FALSE); g->board->goban->game = g->board->game; g->board->goban->pic->game = g->board->game; while (g->board->sgf->active->childH != NULL) { sgfElem_snip(g->board->sgf->active->childH, g->board->sgf); } sgf_setHandicap(g->board->sgf, handicap); sgf_addHandicapStones(g->board->sgf, g->board->game->board); g->board->gameEnd = g->board->sgf->active; g->board->onTrack = TRUE; goban_stopTimer(g->board->goban); goban_startTimer(g->board->goban, goGame_whoseMove(g->board->game)); goban_update(g->board->goban); } } if (color == 'W') { stone = goStone_white; } else { assert(color == 'B'); stone = goStone_black; } if (gl->games[gl->defaultGame].board->goban->timers[stone].aux > 0) ++gl->games[gl->defaultGame].board->goban->timers[stone].aux; IGS_DeadWorkAround = FALSE; /* * IGS notifies the client that dead stone selection has begun * before it notifies the client of the last move made! This * is a workaround to avoid confusing the client. */ if (gl->games[gl->defaultGame].board->game->state == goGameState_selectDead) { if (strcmp(locStr, "Pass") == 0) { /* * We've received a move _after_ the game has already been ended * by IGS. This must be the last move of the game before it ended. * apply the workaround. */ gl->games[gl->defaultGame].board->game->state = goGameState_play; IGS_DeadWorkAround = TRUE; } } if (!cliBoard_gotMove(gl->games[gl->defaultGame].board, locStr, stone, moveNum)) { Str errStr; str_init(&errStr); str_print(&errStr, msg_cliGameBadMove, locStr, gl->defaultGame); cgoban_createMsgWindow(gl->data->cg, "Client/Server Error Detected", str_chars(&errStr)); str_deinit(&errStr); } if (IGS_DeadWorkAround == TRUE) { /* * We revived a game from dead state to add the final passing * move received by from the server. Return the game to 'select dead' * state. */ gl->games[gl->defaultGame].board->game->state = goGameState_selectDead; } } } void cliGameList_gotGameInfo(CliGameList *gl, const char *buf) { int gameNum, move, size, handicap, byTime, observers; float komi; CliGame *g; char wName[41], bName[41], wRank[10], bRank[10], flags[5], temp[50]; int matches; if (buf[1] != '#') { /* It's not the header. */ matches = sscanf(buf, "[%d] %40s [ %[^] ] ] vs. %40s [ %[^] ] ] " "(%d %d %d %g %d %[^)]) (%d)", &gameNum, wName, wRank, bName, bRank, &move, &size, &handicap, &komi, &byTime, flags, &observers); if (matches != 12) { if (!gl->elfBugReported) { gl->elfBugReported = TRUE; cgoban_createMsgWindow(gl->data->cg, "Cgoban Error", msg_gameBadElf); } return; } assert(matches == 12); expandGames(gl, gameNum); g = &gl->games[gameNum]; if ((g->state == cliGame_noGame) || (g->state == cliGame_over)) g->state = cliGame_idle; str_copyChars(&g->wName, wName); str_copyChars(&g->bName, bName); str_copyChars(&g->wRank, wRank); str_copyChars(&g->bRank, bRank); str_copyChars(&g->flags, flags); cliPlayerList_playerInGame(gl->playerList, wName, gameNum); cliPlayerList_playerInGame(gl->playerList, bName, gameNum); g->moveNum = move; if (g->board && g->fromMatch && (move < 2)) { if (g->komi != komi) str_print(&gl->data->cmdBuild, "komi %g\n", g->komi); if (g->board->moveBlack) { if (g->free && (strchr(str_chars(&g->flags), 'F') == NULL)) str_catChars(&gl->data->cmdBuild, "free\n"); if (g->handicap > 0) { sprintf(temp, "handicap %d\n", g->handicap); str_catChars(&gl->data->cmdBuild, temp); } } cliConn_send(&gl->data->conn, str_chars(&gl->data->cmdBuild)); g->fromMatch = FALSE; } assert((size >= 1) && (size <= 38)); g->size = size; assert((handicap >= 0) && (handicap <= 27)); g->handicap = handicap; g->komi = komi; g->byTime = byTime; g->observers = observers; if (gl->win) { if (gameNum > butList_len(gl->list)) { butList_setLen(gl->list, gameNum); butCan_resizeWin(gl->swin->win, 0, butList_len(gl->list) * butEnv_fontH(gl->data->cg->env, 0) + butEnv_stdBw(gl->data->cg->env) * 2, TRUE); } getListEl(gl, gameNum, &gl->data->cmdBuild); butList_changeLine(gl->list, gameNum - 1, str_chars(&gl->data->cmdBuild)); } } } static void expandGames(CliGameList *gl, int gameNum) { int newMaxGames; CliGame *newGames; int i; if (gameNum >= gl->maxGames) { newMaxGames = (gameNum + 1) * 2; newGames = wms_malloc(newMaxGames * sizeof(CliGame)); for (i = 0; i < gl->maxGames; ++i) newGames[i] = gl->games[i]; for (; i < newMaxGames; ++i) { newGames[i].state = cliGame_noGame; newGames[i].gamePressed = FALSE; str_init(&newGames[i].wName); str_init(&newGames[i].bName); str_init(&newGames[i].wRank); str_init(&newGames[i].bRank); str_init(&newGames[i].flags); newGames[i].moveNum = 0; newGames[i].size = 0; newGames[i].handicap = 0; newGames[i].komi = 0.0; newGames[i].byTime = 0; newGames[i].observers = 0; newGames[i].board = NULL; } if (gl->games) wms_free(gl->games); gl->maxGames = newMaxGames; gl->games = newGames; } } static void boardDead(CliBoard *board, void *packet) { CliGameList *gl = packet; assert(MAGIC(gl)); assert(gl->games[board->gameNum].board == board); str_print(&gl->data->cmdBuild, "observe %d\n", board->gameNum); cliConn_send(&gl->data->conn, str_chars(&gl->data->cmdBuild)); gl->games[board->gameNum].board = NULL; gl->games[board->gameNum].state = cliGame_waitNoOb; if (gl->defaultGame == board->gameNum) gl->defaultGame = -1; } void cliGameList_notObserving(CliGameList *gl, const char *buf) { int args; int gameNum; args = sscanf(buf, "Removing game %d", &gameNum); assert(args == 1); assert(gameNum >= 0); assert(gameNum < gl->maxGames); assert(gl->games[gameNum].state == cliGame_waitNoOb); gl->games[gameNum].state = cliGame_idle; } void cliGameList_kibitz(CliGameList *gl, const char *buf) { int args; const char *kibitz; assert(MAGIC(gl)); if (buf[0] == 'K') { args = sscanf(buf, "Kibitz %40[^:]%*[^[][%d", gl->kibPlayer, &gl->kibGame); if (args != 2) { if (!gl->elfBugReported) { gl->elfBugReported = TRUE; cgoban_createMsgWindow(gl->data->cg, "Cgoban Error", msg_gameBadElf); } return; } assert(args == 2); expandGames(gl, gl->kibGame); } else { if ((gl->kibGame < 0) || (gl->games[gl->kibGame].state != cliGame_observing)) { return; } for (kibitz = buf; *kibitz == ' '; ++kibitz); if (clpEntry_getBool(gl->data->numKibitz)) str_print(&gl->data->cmdBuild, "%d %s: %s\n", gl->games[gl->kibGame].board->game->maxMoves, gl->kibPlayer, kibitz); else str_print(&gl->data->cmdBuild, "%s: %s\n", gl->kibPlayer, kibitz); cliBoard_addKibitz(gl->games[gl->kibGame].board, str_chars(&gl->data->cmdBuild)); } } void cliGameList_say(CliGameList *gl, const char *buf) { assert(MAGIC(gl)); if (gl->playGame >= 0) { if (clpEntry_getBool(gl->data->numKibitz)) str_print(&gl->data->cmdBuild, "%d %s\n", gl->games[gl->playGame].board->game->maxMoves, buf); else str_print(&gl->data->cmdBuild, "%s\n", buf); cliBoard_addKibitz(gl->games[gl->playGame].board, str_chars(&gl->data->cmdBuild)); } } static ButOut unmap(ButWin *win) { return(0); } static ButOut map(ButWin *win) { return(0); } static ButOut resize(ButWin *win) { int w, h; CliGameList *gl = butWin_packet(win); int bw = butEnv_stdBw(butWin_env(win)); int tabs[10]; static const ButTextAlign tabAligns[10] = {butText_right, butText_left, butText_left, butText_left, butText_right, butText_right, butText_right, butText_right, butText_right, butText_right}; int fontH; int physFontH = butEnv_fontH(butWin_env(win), 0); int slideW = (physFontH * 3)/2; int centerAdd; assert(MAGIC(gl)); fontH = gl->data->cg->fontH; w = butWin_w(win); h = butWin_h(win); but_resize(gl->bg, 0, 0, w, h); but_resize(gl->titleBox, bw*2 + slideW, bw*2, w - (bw*4 + slideW), fontH * 2); but_resize(gl->reload, bw*2, bw*2, slideW, fontH * 2); but_resize(gl->title, bw * 4 + slideW, bw * 2 + (fontH * 2 - physFontH) / 2, w - (bw * 8 + slideW), physFontH); abutSwin_resize(gl->swin, bw*2, bw*2 + fontH*2, w - bw*4, h - bw*4 - fontH*2, slideW, physFontH); butCan_resizeWin(gl->swin->win, 0, butList_len(gl->list) * physFontH + bw * 2, TRUE); centerAdd = (physFontH * 3 + 1) / 4; tabs[0] = (physFontH * 2) / 2; tabs[1] = (physFontH * 3) / 2; tabs[2] = (physFontH * 17) / 2; tabs[3] = (physFontH * 20) / 2; tabs[4] = (physFontH * 37) / 2; tabs[5] = (physFontH * 41) / 2; tabs[6] = (physFontH * 45) / 2; tabs[7] = (physFontH * 49) / 2; tabs[8] = (physFontH * 53) / 2; tabs[9] = (physFontH * 57) / 2; if (w < physFontH * 20 + bw * 8) tabs[4] += physFontH * 20; if (w < physFontH * 22 + bw * 8) tabs[5] += physFontH * 20; if (w < physFontH * 24 + bw * 8) tabs[6] += physFontH * 20; if (w < physFontH * 26 + bw * 8) tabs[7] += physFontH * 20; if (w < physFontH * 28 + bw * 8) tabs[8] += physFontH * 20; if (w < physFontH * 30 + bw * 8) tabs[9] += physFontH * 20; butList_setTabs(gl->title, tabs, tabAligns, 10); butList_setTabs(gl->list, tabs, tabAligns, 10); return(0); } static ButOut sResize(ButWin *win) { int w, h; AbutSwin *swin = butWin_packet(win); CliGameList *gl; int bw = butEnv_stdBw(butWin_env(win)); assert(MAGIC(swin)); gl = swin->packet; assert(MAGIC(gl)); w = butWin_w(win); h = butWin_h(win); but_resize(gl->sBg, 0, 0, w, h); butList_resize(gl->list, bw, bw, w - bw*2); return(0); } static ButOut destroy(ButWin *win) { CliGameList *gl = butWin_packet(win); Cgoban *cg = gl->data->cg; assert(MAGIC(gl)); clp_setInt(cg->clp, "client.games.w", (butWin_w(win) - butWin_getMinW(gl->win)) / butWin_getWStep(gl->win)); clp_setDouble(cg->clp, "client.games.h2", ((double)butWin_h(win) / (double)(butWin_getMinW(gl->win) + 6 * butWin_getWStep(gl->win)))); clp_setInt(cg->clp, "client.games.x", butWin_x(win)); clp_setInt(cg->clp, "client.games.y", butWin_y(win)); gl->win = NULL; return(0); } static void getListEl(CliGameList *gl, int gNum, Str *out) { switch(gl->games[gNum].state) { case cliGame_noGame: str_copyCharsLen(out, "", 0); break; case cliGame_over: str_print(out, "\t-\t%s [%s]\tvs.\t%s [%s]\t%d\t%d\t%d\t%g\t\t%s", str_chars(&gl->games[gNum].wName), str_chars(&gl->games[gNum].wRank), str_chars(&gl->games[gNum].bName), str_chars(&gl->games[gNum].bRank), gl->games[gNum].moveNum, gl->games[gNum].size, gl->games[gNum].handicap, gl->games[gNum].komi, str_chars(&gl->games[gNum].flags)); break; default: str_print(out, "\t%d\t%s [%s]\tvs.\t%s [%s]\t%d\t%d\t%d\t%g\t%s\t(%d)", gNum, str_chars(&gl->games[gNum].wName), str_chars(&gl->games[gNum].wRank), str_chars(&gl->games[gNum].bName), str_chars(&gl->games[gNum].bRank), gl->games[gNum].moveNum, gl->games[gNum].size, gl->games[gNum].handicap, gl->games[gNum].komi, str_chars(&gl->games[gNum].flags), gl->games[gNum].observers); break; } } void cliGameList_gameGone(CliGameList *gl, const char *buf, int bufLen) { int args, gameNum; Str gobanMessage, *winMsg; double bScore, wScore; CliBoard *board; GoStone winner = goStone_empty, loser; enum { adjourn, time, resign, score } endType; /* * 21 {Game 7: GoBot vs GoBot : Black resigns.} * 21 {Game 2: drwhat vs white : Black resigns. W 88.5 B 87.0} * 21 {Game 7: hunanren vs fine2 has adjourned.} * 21 {Game 34: waffle vs Benyu : W 55.5 B 72.0} * 21 {Game 36: ToLive vs bevin : Black forfeits on time.} * * Also found these. -DDN- * Note: It seems that IGS sends TWO messages at the end of a * request game. One of the next three, followed by an adjourn. * 21 {Game 37: otari* vs cleaner* : White lost by Resign} * 21 {Game 14: otari* vs ogre* : Black lost by 4.5} * 21 {Game 63: Okada* vs Girl* : Black lost by Time} */ args = sscanf(buf, "{Game %d", &gameNum); assert(args == 1); expandGames(gl, gameNum); cliPlayerList_playerInGame(gl->playerList, str_chars(&gl->games[gameNum].wName), -1); cliPlayerList_playerInGame(gl->playerList, str_chars(&gl->games[gameNum].bName), -1); /* Figure out exactly how the game ended. */ if (!strcmp(buf + bufLen - 10, " resigns.}")) { endType = resign; if (buf[bufLen - 11] == 'k') { winner = goStone_white; } else { assert(buf[bufLen - 11] == 'e'); winner = goStone_black; } /* Added to catch Resign in replayed games. -DDN- */ } else if (!strcmp(buf + bufLen - 16, " lost by Resign}")) { endType = resign; if (buf[bufLen - 17] == 'k') { winner = goStone_white; } else { assert(buf[bufLen - 17] == 'e'); winner = goStone_black; } } else if (!strcmp(buf + bufLen - 12, " adjourned.}")) { endType = adjourn; } else if (!strcmp(buf + bufLen - 19, " forfeits on time.}")) { endType = time; if (buf[bufLen - 20] == 'k') { winner = goStone_white; } else { assert(buf[bufLen - 20] == 'e'); winner = goStone_black; } /* Added to catch Time in replayed games. -DDN- */ } else if (!strcmp(buf + bufLen - 14, " lost by Time}")) { endType = time; if (buf[bufLen - 15] == 'k') { winner = goStone_white; } else { assert(buf[bufLen - 15] == 'e'); winner = goStone_black; } } else { endType = score; args = sscanf(buf, "{Game %*d: %*s vs %*s %*[^0-9]%lf B %lf", &wScore, &bScore); if (args != 2) { /* Check to see if it is the end of a replayed game. -DDN- */ char color[6]; args = sscanf(buf, "{Game %*d: %*s vs %*s : %5s lost by %lf", color, &bScore); if(args != 2) { if (!gl->elfBugReported) { gl->elfBugReported = TRUE; cgoban_createMsgWindow(gl->data->cg, "Cgoban Error", msg_gameBadElf); } return; } /* Set the score for the replayed game. -DDN- */ if (color[4] == 'k') { winner = goStone_white; wScore = bScore; bScore = 0.0; } else { assert(color[4] == 'e'); winner = goStone_black; wScore = 0.0; } } else if (wScore > bScore) { winner = goStone_white; } else { winner = goStone_black; } } /* Set up the flags field to describe the end of the game. */ if (gl->games[gameNum].state != cliGame_noGame) { winMsg = &gl->games[gameNum].flags; switch(endType) { case adjourn: str_copyChars(winMsg, "Adj."); break; case time: str_print(winMsg, "%c+Time", goStone_char(winner)); break; case resign: str_print(winMsg, "%c+Res.", goStone_char(winner)); break; case score: str_print(winMsg, "%c+%g", goStone_char(winner), fabs(wScore - bScore)); break; } gl->games[gameNum].state = cliGame_over; if (gl->win) { getListEl(gl, gameNum, &gl->data->cmdBuild); butList_changeLine(gl->list, gameNum - 1, str_chars(&gl->data->cmdBuild)); butList_setPress(gl->list, gameNum - 1, FALSE); } } if (gl->games[gameNum].board) { board = gl->games[gameNum].board; if (board->moveBlack || board->moveWhite) { board->moveBlack = FALSE; board->moveWhite = FALSE; but_setFlags(board->goban->save, BUT_NOPRESS); butCt_setText(board->goban->quit, msg_close); } str_init(&gobanMessage); loser = goStone_opponent(winner); switch(endType) { case resign: str_print(&gobanMessage, msg_gameGoneResign, msg_stoneNames[loser]); str_print(&board->result, msg_gameResultResign, board->game->maxMoves, msg_stoneNames[loser]); break; case adjourn: str_copyChars(&gobanMessage, msg_gameGoneAdjourn); str_print(&board->result, msg_gameResultAdjourn, board->game->maxMoves); break; case time: str_print(&gobanMessage, msg_gameGoneTime, msg_stoneNames[loser]); str_print(&board->result, msg_gameResultTime, board->game->maxMoves, msg_stoneNames[loser]); break; case score: str_print(&gobanMessage, msg_gameGoneScore, wScore, bScore, msg_stoneNames[winner]); if (wScore < bScore) { float temp; temp = wScore; wScore = bScore; bScore = temp; } str_print(&board->result, msg_gameResultScore, board->game->maxMoves, msg_stoneNames[winner], wScore, bScore); } if (gl->games[gameNum].board->goban->activeTimer != goStone_empty) goban_stopTimer(gl->games[gameNum].board->goban); goban_message(gl->games[gameNum].board->goban, str_chars(&gobanMessage)); cliBoard_update(board); str_deinit(&gobanMessage); gl->games[gameNum].board->destroy = NULL; gl->games[gameNum].board = NULL; } if (gameNum == gl->defaultGame) gl->defaultGame = -1; if (gameNum == gl->playGame) gl->playGame = -1; gl->games[gameNum].gamePressed = FALSE; } void cliGameList_gameStarts(CliGameList *gl, const char *buf) { int args, gameNum; args = sscanf(buf, "%*s %d", &gameNum); assert(args == 1); str_print(&gl->data->cmdBuild, "games %d\n", gameNum); cliConn_send(&gl->data->conn, str_chars(&gl->data->cmdBuild)); } void cliGameList_selectDead(CliGameList *gl, const char *buf) { CliGame *g; assert(MAGIC(gl)); assert(gl->playGame >= 0); g = &gl->games[gl->playGame]; if (g->board->gameEnd == g->board->sgf->active) { if (g->board->goban->activeTimer != goStone_empty) goban_stopTimer(g->board->goban); g->board->game->state = goGameState_selectDead; } g->board->gameEnded = TRUE; goban_update(g->board->goban); } /* This really should be in board.c, IMHO */ void cliGameList_deadStone(CliGameList *gl, const char *buf) { CliGame *g; char deadStone[5]; int args, oldMoveNum, loc; SgfElem *prevActive = NULL; GoBoardGroupIter group; assert(MAGIC(gl)); assert(gl->playGame >= 0); g = &gl->games[gl->playGame]; args = sscanf(buf, "Removing @ %s", deadStone); assert(args == 1); loc = goBoard_str2Loc(g->board->game->board, deadStone); if (g->board->gameEnd != g->board->sgf->active) { prevActive = g->board->sgf->active; g->board->sgf->active = g->board->gameEnd; g->board->sgf->mode = sgfInsert_main; } goBoardGroupIter(group, g->board->game->board, loc) { sgf_addStone(g->board->sgf, goStone_empty, goBoard_loc2Sgf(g->board->game->board, goBoardGroupIter_loc(group, g->board->game->board))); } g->board->gameEnd = g->board->sgf->active; if (prevActive != NULL) g->board->sgf->active = prevActive; if (g->board->onTrack) { if (g->board->game->moveNum < g->board->game->maxMoves) { oldMoveNum = g->board->game->moveNum; goGame_moveTo(g->board->game, g->board->game->maxMoves); if (g->board->goban->activeTimer != goStone_empty) goban_stopTimer(g->board->goban); g->board->game->state = goGameState_selectDead; goGame_markDead(g->board->game, loc); g->board->game->state = goGameState_play; goGame_moveTo(g->board->game, oldMoveNum); } else { goGame_markDead(g->board->game, loc); } } goban_update(g->board->goban); } void cliGameList_gotUndo(CliGameList *gl, const char *buf) { CliGame *g; int args, gameNum = -1; assert(MAGIC(gl)); args = sscanf(buf, "Undo in game %d", &gameNum); if (args == 0) { gameNum = gl->playGame; } else { assert(args == 1); } assert(gameNum >= 0); expandGames(gl, gameNum); g = &gl->games[gameNum]; if (g->board && (g->board->game->moveNum > 0)) { --g->board->lastMoveRead; if ((g->board->moveWhite || g->board->moveBlack) && gl->data->actions) { gl->data->actions->gotUndo(gl->data->packet); } while (g->board->gameEnd->type != sgfType_node) { g->board->gameEnd = g->board->gameEnd->parent; assert(g->board->gameEnd != NULL); } g->board->gameEnd = g->board->gameEnd->parent; assert(g->board->gameEnd != NULL); if (g->board->onTrack) { g->board->gameEnded = FALSE; if (g->board->game->moveNum == g->board->game->maxMoves) { goGame_moveTo(g->board->game, g->board->game->moveNum - 1); g->board->sgf->active = g->board->gameEnd; if (g->board->game->state > goGameState_play) { g->board->game->state = goGameState_play; } } --g->board->game->maxMoves; } goban_update(g->board->goban); } } static ButOut reload(But *but) { CliGameList *gl = but_packet(but); int i, newLen; bool lenChanged; assert(MAGIC(gl)); cliConn_send(&gl->data->conn, "games\n"); for (i = 0; i < gl->maxGames; ++i) { if (gl->games[i].state == cliGame_over) { gl->games[i].state = cliGame_noGame; butList_changeLine(gl->list, i - 1, ""); } } lenChanged = FALSE; for (newLen = butList_len(gl->list); (newLen > 1) && (gl->games[newLen].state == cliGame_noGame); --newLen) { lenChanged = TRUE; } if (lenChanged) { butList_setLen(gl->list, newLen); butCan_resizeWin(gl->swin->win, 0, newLen * butEnv_fontH(gl->data->cg->env, 0) + butEnv_stdBw(gl->data->cg->env) * 2, TRUE); } return(0); } static ButOut listPressed(But *but, int line) { CliGameList *gl; gl = but_packet(but); assert(MAGIC(gl)); return(observeGame(gl, line + 1)); } static ButOut observeGame(void *packet, int boardId) { CliGameList *gl = packet; assert(MAGIC(gl)); assert((boardId > 0) && (boardId < gl->maxGames)); if (gl->games[boardId].state == cliGame_noGame) return(BUTOUT_ERR); if (gl->games[boardId].board) { XRaiseWindow(butEnv_dpy(gl->data->cg->env), butWin_xwin(gl->games[boardId].board->goban->win)); } else if (!gl->games[boardId].gamePressed) { gl->games[boardId].gamePressed = TRUE; str_print(&gl->data->cmdBuild, "observe %d\n", boardId); cliConn_send(&gl->data->conn, str_chars(&gl->data->cmdBuild)); } return(0); } bool cliGame_tellIsSay(CliGameList *list, Str *tell) { char tellerName[41]; int matches; if (list->playGame >= 0) { matches = sscanf(str_chars(tell), "*%40[^*]", tellerName); if (matches != 1) { if (!list->elfBugReported) { list->elfBugReported = TRUE; cgoban_createMsgWindow(list->data->cg, "Cgoban Error", msg_gameBadElf); } return(FALSE); } assert(matches == 1); if (!strcmp(str_chars(&list->games[list->playGame].wName), tellerName) || !strcmp(str_chars(&list->games[list->playGame].bName), tellerName)) { cliBoard_addKibitz(list->games[list->playGame].board, str_chars(tell)); return(TRUE); } } return(FALSE); } cgoban-1.9.14/src/client/login.c0000664000671000067100000001154307043224471012054 /* * src/client/login.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include "../cgoban.h" #include "login.h" #include "../msg.h" #include "conn.h" #include "main.h" /********************************************************************** * Forward Declarations **********************************************************************/ static void cliLogin_dataIn(void *packet, const char *buf, int bufLen); static void mainDied(CliMain *main, void *packet); /********************************************************************** * Functions **********************************************************************/ CliLogin *cliLogin_create(CliData *cd, const char *user, const char *pass) { CliConn *conn; CliLogin *cl; Str errStr; XFontStruct *fs; cl = wms_malloc(sizeof(CliLogin)); MAGIC_SET(cl); cl->cd = cd; fs = butEnv_fontStr(cd->cg->env, 0); conn = cliConn_init(&cd->conn, cd->cg, cd->serverNum, cd->server, fs->min_char_or_byte2, fs->max_char_or_byte2, cliLogin_dataIn, cl); cd->connValid = TRUE; if (conn->err == cliConnErr_ok) { str_print(&cd->cmdBuild, msg_login, cd->serverName); cl->main = cliMain_create(cd, mainDied, cl); cliMain_message(cl->main, str_chars(&cd->cmdBuild)); cl->keepMainMessage = FALSE; cd->state = cliData_login; str_init(&cl->user); str_print(&cl->user, "%s\n", user); str_init(&cl->pass); str_print(&cl->pass, "%s\n", pass); cl->state = cliLogin_waitForUser; return(cl); } else { MAGIC_UNSET(cl); wms_free(cl); str_init(&errStr); switch(conn->err) { case cliConnErr_openSocket: str_print(&errStr, msg_cliOpenSocket, strerror(conn->errOut.errNum), cd->serverName); break; case cliConnErr_lookup: str_print(&errStr, msg_cliLookup, conn->errOut.serverName); break; case cliConnErr_connect: str_print(&errStr, msg_cliConnect, strerror(conn->errOut.errNum), cd->serverName); break; default: assert(0); break; } cgoban_createMsgWindow(cd->cg, "Cgoban Error", str_chars(&errStr)); str_deinit(&errStr); return(NULL); } } void cliLogin_destroy(CliLogin *cl, bool propagate) { assert(MAGIC(cl)); assert(MAGIC(cl->main)); str_deinit(&cl->user); str_deinit(&cl->pass); cl->main->destroyCallback = NULL; if (propagate && cl->cd->conn.loginMode) cliMain_destroy(cl->main); MAGIC_UNSET(cl); wms_free(cl); } static void cliLogin_dataIn(void *packet, const char *buf, int bufLen) { CliLogin *cl = packet; Str errStr; assert(MAGIC(cl)); assert(MAGIC(cl->cd)); assert(MAGIC(cl->cd->cg)); if (buf == NULL) { str_init(&errStr); str_print(&errStr, msg_cliHangup, cl->cd->serverName, strerror(bufLen)); abutMsg_winCreate(cl->cd->cg->abut, "Cgoban Error", str_chars(&errStr)); str_deinit(&errStr); cliLogin_destroy(cl, TRUE); return; } cliMain_log(cl->main, buf); cliMain_log(cl->main, "\n"); switch(cl->state) { case cliLogin_waitForUser: if (!strcmp(buf, "Login: ")) { cl->state = cliLogin_waitForPassword; cliConn_send(&cl->cd->conn, str_chars(&cl->user)); cliMain_log(cl->main, str_chars(&cl->user)); cliMain_log(cl->main, "\n"); } break; case cliLogin_waitForPassword: if (!strcmp(buf, "1 1") || !strcmp(buf, "Password: ")) { cl->state = cliLogin_waitForPrompt; if ((str_len(&cl->pass) == 0) && (cl->cd->server == cliServer_nngs)) { str_init(&errStr); str_print(&errStr, msg_notAGuest, str_chars(&cl->user)); cliMain_message(cl->main, str_chars(&errStr)); str_deinit(&errStr); cliLogin_destroy(cl, TRUE); return; } else { cliConn_send(&cl->cd->conn, str_chars(&cl->pass)); cliMain_log(cl->main, "******\n"); } } else if (!strcmp(buf, "#> ")) { cliConn_send(&cl->cd->conn, "toggle client 1\n"); cliMain_message(cl->main, msg_guest); cl->state = cliLogin_waitForPrompt; cl->keepMainMessage = TRUE; } break; case cliLogin_waitForPrompt: if (!strcmp(buf, "Login: ")) { cliMain_message(cl->main, msg_loginFailed); cliLogin_destroy(cl, TRUE); return; } else if (!strcmp(buf, "#> ")) { cliConn_send(&cl->cd->conn, "toggle client 1\n"); cliMain_log(cl->main, "toggle client 1\n"); } else if (!strcmp(buf, "1 5")) { if (!cl->keepMainMessage) cliMain_clearMessage(cl->main); cliMain_activate(cl->main); cliLogin_destroy(cl, TRUE); } break; } } static void mainDied(CliMain *main, void *packet) { CliLogin *login = packet; assert(MAGIC(login)); cliLogin_destroy(login, FALSE); } cgoban-1.9.14/src/client/look.c0000664000671000067100000001324307043224471011707 /* * src/client/look.c, part of Complete Goban (game program) * Copyright (C) 1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #ifndef _MSG_H_ #include "../msg.h" #endif #ifdef _CLIENT_LOOK_H_ LEVELIZATION ERROR #endif #include "look.h" /********************************************************************** * Forward Declarations **********************************************************************/ static void gameReady(CliLook *look, int size); static GobanOut quit(void *packet); static void gobanDead(void *packet); static bool moveOk(void *packet); static void makeMoves(GoGame *game, const char *board, int size); /********************************************************************** * Functions **********************************************************************/ void cliLook_init(CliLook *look, Cgoban *cg, CliServer server) { GoStone s; MAGIC_SET(look); look->cg = cg; look->server = server; look->state = cliLook_ready; goStoneIter(s) { str_init(&look->name[s]); str_init(&look->rank[s]); } str_init(&look->boardData); } void cliLook_deinit(CliLook *look) { GoStone s; assert(MAGIC(look)); goStoneIter(s) { str_deinit(&look->name[s]); str_deinit(&look->rank[s]); } str_deinit(&look->boardData); MAGIC_UNSET(look); } void cliLook_gotData(CliLook *look, const char *buf) { GoStone s; int lineNum, matches; char data[GOBOARD_MAXSIZE + 1]; char name[40], rank[10]; assert(MAGIC(look)); switch(look->state) { case cliLook_ready: look->skip = FALSE; str_clip(&look->boardData, 0); /* Fall through to cliLook_info1. */ case cliLook_info: s = (look->state - cliLook_ready) + goStone_white; matches = sscanf(buf, "%39s %9s %d %*d %*d %*s %g %d", name, rank, &look->captures[s], &look->komi, &look->handicap); assert(matches == 5); str_copyChars(&look->name[s], name); str_copyChars(&look->rank[s], rank); ++look->state; break; case cliLook_body: matches = sscanf(buf, "%d: %s", &lineNum, data); assert(matches == 2); assert(strlen(data) <= GOBOARD_MAXSIZE); str_catChars(&look->boardData, data); if (lineNum == strlen(data) - 1) { gameReady(look, lineNum + 1); look->state = cliLook_ready; } break; } } static void gameReady(CliLook *look, int size) { static const GobanActions actions = { NULL, quit, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* edit, gameInfo */ &help_cliLook, gobanDead, moveOk, moveOk, moveOk, moveOk}; Goban *goban; GoGame *game; Str title; static const GoTime noTime = {goTime_none, 0, 0, 0}; CliLookChild *child; int i; /* * If it's a game-end board, then don't show it. * You can tell these because they have 3s, 4s, and 5s in them. */ for (i = 0; i < str_len(&look->boardData); ++i) { assert(str_chars(&look->boardData)[i] >= '0'); assert(str_chars(&look->boardData)[i] <= '6'); if ((str_chars(&look->boardData)[i] > '2') && (str_chars(&look->boardData)[i] < '6')) { return; } } child = wms_malloc(sizeof(CliLookChild)); MAGIC_SET(child); str_init(&title); str_print(&title, msg_cliLookName, str_chars(&look->name[goStone_white]), str_chars(&look->rank[goStone_white]), str_chars(&look->name[goStone_black]), str_chars(&look->rank[goStone_black])); /* * I pass in a handicap of 0 even though I know the real handicap. Why? * because otherwise when I parse over the board, if I find a white * stone where there used to be a handicap stone, I'm screwed! I'd have * to erase the black stone somehow and add a white one. Ugh. Easier * just to never add the handicap stones to begin with; they'll be caught * when I scan the board later. */ game = goGame_create(size, goRules_japanese, 0, look->komi, &noTime, TRUE); makeMoves(game, str_chars(&look->boardData), size); goban = goban_create(look->cg, &actions, child, game, "client.look", str_chars(&title)); goban->pic->allowedMoves = goPicMove_noWhite | goPicMove_noBlack; goban->iDec1 = grid_create(&look->cg->cgbuts, NULL, NULL, goban->iWin, 2, BUT_DRAWABLE, 0); grid_setStone(goban->iDec1, goStone_white, FALSE); if (look->server == cliServer_nngs) grid_setVersion(goban->iDec1, CGBUTS_WORLDWEST(0)); else grid_setVersion(goban->iDec1, CGBUTS_WORLDEAST(0)); goban_update(goban); butText_set(goban->infoText, "Static Game Board"); child->game = game; child->goban = goban; str_deinit(&title); } static GobanOut quit(void *packet) { CliLookChild *child = packet; assert(MAGIC(child)); goban_destroy(child->goban, TRUE); return(gobanOut_noDraw); } static void gobanDead(void *packet) { CliLookChild *child = packet; assert(MAGIC(child)); goGame_destroy(child->game); MAGIC_UNSET(child); wms_free(child); } static bool moveOk(void *packet) { return(FALSE); } static void makeMoves(GoGame *game, const char *board, int size) { int x, y; for (x = 0; x < size; ++x) { for (y = 0; y < size; ++y) { switch(*board) { case '0': goGame_move(game, goStone_black, goBoard_xy2Loc(game->board, x, y), NULL); break; case '1': goGame_move(game, goStone_white, goBoard_xy2Loc(game->board, x, y), NULL); break; case '2': case '6': break; default: assert(0); break; } ++board; } } goGame_pass(game, goStone_black, NULL); /* These passes just get rid of */ goGame_pass(game, goStone_white, NULL); /* the "last move here" marker. */ } cgoban-1.9.14/src/client/main.c0000664000671000067100000005067707056054575011715 /* * $Source: /cvsroot/cgoban1/cgoban1/src/client/main.c,v $ * $Revision: 1.2 $ * $Date: 2000/02/26 22:53:49 $ * * src/client/main.c, part of Complete Goban (game program) * Copyright © 1995-2000 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include #include #include #include #include "../cgoban.h" #include "../msg.h" #include "../help.h" #ifdef _CLIENT_MAIN_H_ #error LEVELIZATION ERROR #endif #include "main.h" /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut unmap(ButWin *win); static ButOut map(ButWin *win); static ButOut resize(ButWin *win); static ButOut destroy(ButWin *win); static void dataIn(void *packet, const char *buf, int bufLen); static ButOut userInput(But *but, const char *input); static ButOut quitPressed(But *but); static ButOut gamesPressed(But *but); static ButOut playersPressed(But *but); static ButOut iResize(ButWin *win); static ButOut newState(But *but, int value); static ButOut msgBoxKilled(But *okBut); static void client2client(CliMain *cMain, const char *buf); static ButOut prevHistory(But *but, KeySym keysym, uint keyModifiers, void *context); static ButOut nextHistory(But *but, KeySym keysym, uint keyModifiers, void *context); /********************************************************************** * Functions **********************************************************************/ CliMain *cliMain_create(CliData *data, void (*destroyCallback)(CliMain *cMain, void *packet), void *packet) { Str winTitle; CliMain *cMain; int winW, winH; Cgoban *cg; int i; bool err; assert(MAGIC(data)); cg = data->cg; cMain = wms_malloc(sizeof(CliMain)); MAGIC_SET(cMain); cliData_incRef(data); cMain->data = data; winW = (clp_getDouble(cg->clp, "client.main.w") * cg->fontH + 0.5); winH = (clp_getDouble(cg->clp, "client.main.h") * cg->fontH + 0.5); str_init(&winTitle); str_print(&winTitle, "%s Client", data->serverName); cMain->win = butWin_iCreate(cMain, cg->env, str_chars(&winTitle), winW, winH, &cMain->iWin, FALSE, 48, 48, unmap, map, resize, iResize, destroy); i = clpEntry_iGetInt(clp_lookup(cg->clp, "client.main.x"), &err); if (!err) butWin_setX(cMain->win, i); i = clpEntry_iGetInt(clp_lookup(cg->clp, "client.main.y"), &err); if (!err) butWin_setY(cMain->win, i); butWin_setMinW(cMain->win, cg->fontH * 10); butWin_setMinH(cMain->win, cg->fontH * 10); butWin_setMaxW(cMain->win, 0); butWin_setMaxH(cMain->win, 0); butWin_activate(cMain->win); str_deinit(&winTitle); cMain->bg = butBoxFilled_create(cMain->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(cMain->bg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); cMain->quit = butCt_create(quitPressed, cMain, cMain->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_quit); cMain->games = butCt_create(gamesPressed, cMain, cMain->win, 1, BUT_DRAWABLE, msg_games); cMain->players = butCt_create(playersPressed, cMain, cMain->win, 1, BUT_DRAWABLE, msg_players); cMain->help = butCt_create(cgoban_createHelpWindow, &help_cliMain, cMain->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_help); cMain->script = abutTerm_create(cg->abut, cMain->win, 1, FALSE); cMain->message = NULL; butTbin_setMaxLines(cMain->script->tbin, 250); if (data->conn.directConn) cMain->tin = butTextin_create(userInput, cMain, cMain->win, 1, BUT_DRAWABLE, "", 200); else cMain->tin = butTextin_create(userInput, cMain, cMain->win, 1, BUT_DRAWABLE|BUT_PRESSABLE|BUT_KEYED, "", 200); cMain->userState = butRadio_create(newState, cMain, cMain->win, 1, BUT_DRAWABLE, cliPlayer_unknown - cliPlayer_closed, 3); cMain->looking = butText_create(cMain->win, 2, BUT_DRAWABLE | BUT_PRESSTHRU, "!", butText_center); cMain->open = butText_create(cMain->win, 2, BUT_DRAWABLE | BUT_PRESSTHRU, "O", butText_center); cMain->closed = butText_create(cMain->win, 2, BUT_DRAWABLE | BUT_PRESSTHRU, "X", butText_center); cliPlayerList_init(&cMain->playerList, data); cliGameList_init(&cMain->gameList, data, &cMain->playerList); cMain->state = cliMain_idle; cMain->promptVisible = FALSE; str_init(&cMain->outStr); cMain->iBg = butBoxFilled_create(cMain->iWin, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(cMain->iBg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); cMain->iPic = grid_create(&cg->cgbuts, NULL, NULL, cMain->iWin, 1, BUT_DRAWABLE, 0); grid_setStone(cMain->iPic, goStone_white, FALSE); grid_setLineGroup(cMain->iPic, gridLines_none); if (data->server == cliServer_nngs) grid_setVersion(cMain->iPic, CGBUTS_WORLDWEST(3)); else grid_setVersion(cMain->iPic, CGBUTS_WORLDEAST(4)); cliLook_init(&cMain->look, cg, data->server); cMain->historyLen = 0; cMain->historyBeingFilled = 0; cMain->historyBeingViewed = 0; for (i = 0; i < MAIN_HISTORYMAXLEN; ++i) { str_init(&cMain->history[i]); } butTextin_setSpecialKey(cMain->tin, XK_p, ControlMask, ShiftMask|ControlMask, prevHistory, cMain); butTextin_setSpecialKey(cMain->tin, XK_Up, 0, ShiftMask|ControlMask, prevHistory, cMain); butTextin_setSpecialKey(cMain->tin, XK_n, ControlMask, ShiftMask|ControlMask, nextHistory, cMain); butTextin_setSpecialKey(cMain->tin, XK_Down, 0, ShiftMask|ControlMask, nextHistory, cMain); cMain->destroyCallback = destroyCallback; cMain->packet = packet; return(cMain); } void cliMain_activate(CliMain *cMain) { assert(MAGIC(cMain)); cMain->data->state = cliData_main; cMain->data->conn.newData = dataIn; cMain->data->conn.packet = cMain; cMain->data->conn.loginMode = FALSE; but_setFlags(cMain->games, BUT_PRESSABLE); but_setFlags(cMain->players, BUT_PRESSABLE); but_setFlags(cMain->tin, BUT_PRESSABLE|BUT_KEYED); but_setFlags(cMain->games, BUT_PRESSABLE); but_setFlags(cMain->userState, BUT_PRESSABLE); cliConn_prompt(&cMain->data->conn); cliConn_send(&cMain->data->conn, "toggle quiet 0\ntoggle verbose 0\ngames\nwho\n"); } void cliMain_destroy(CliMain *cMain) { Cgoban *cg; assert(MAGIC(cMain)); if (cMain->destroyCallback) cMain->destroyCallback(cMain, cMain->packet); cliMain_clearMessage(cMain); if (cMain->win) { cg = cMain->data->cg; clp_setDouble(cg->clp, "client.main.w", (double)butWin_w(cMain->win) / (double)cg->fontH); clp_setDouble(cg->clp, "client.main.h", (double)butWin_h(cMain->win) / (double)cg->fontH); clp_setInt(cg->clp, "client.main.x", butWin_x(cMain->win)); clp_setInt(cg->clp, "client.main.y", butWin_y(cMain->win)); butWin_setDestroy(cMain->win, NULL); butWin_destroy(cMain->win); } cliGameList_deinit(&cMain->gameList); cliPlayerList_deinit(&cMain->playerList); cliLook_deinit(&cMain->look); str_deinit(&cMain->outStr); cliData_closeConns(cMain->data); cliData_decRef(cMain->data); MAGIC_UNSET(cMain); wms_free(cMain); } static ButOut unmap(ButWin *win) { return(0); } static ButOut map(ButWin *win) { return(0); } static ButOut resize(ButWin *win) { CliMain *cMain = butWin_packet(win); int w = butWin_w(win), h = butWin_h(win); int bw = butEnv_stdBw(butWin_env(win)); int fontH = cMain->data->cg->fontH; int midY; assert(MAGIC(cMain)); but_resize(cMain->bg, 0, 0, w, h); midY = (w - (bw * 2 + fontH * 6)) / 2; but_resize(cMain->games, bw * 2, bw * 2, midY - bw * 2, fontH * 2); but_resize(cMain->userState, midY + bw, bw * 2, fontH * 6, fontH * 2); but_resize(cMain->closed, midY + bw, bw * 2, fontH * 2, fontH * 2); but_resize(cMain->open, midY + bw + fontH * 2, bw * 2, fontH * 2, fontH * 2); but_resize(cMain->looking, midY + bw + fontH * 4, bw * 2, fontH * 2, fontH * 2); but_resize(cMain->players, midY + bw * 2 + fontH * 6, bw * 2, w - (midY + bw * 4 + fontH * 6), fontH * 2); abutTerm_resize(cMain->script, bw * 2, bw * 3 + fontH * 2, w - bw * 4, h - fontH * 6 - bw * 6); but_resize(cMain->tin, bw * 2, h - fontH * 4 - bw * 3, w - bw * 4, fontH * 2); midY = (w - bw) / 2; but_resize(cMain->help, bw * 2, h - fontH * 2 - bw * 2, midY - bw * 2, fontH * 2); but_resize(cMain->quit, midY + bw, h - fontH * 2 - bw * 2, w - (midY + bw * 3), fontH * 2); return(0); } static ButOut destroy(ButWin *win) { CliMain *cMain = win->packet; Cgoban *cg; assert(MAGIC(cMain)); cg = cMain->data->cg; clp_setDouble(cg->clp, "client.main.w", (double)butWin_w(win) / (double)cg->fontH); clp_setDouble(cg->clp, "client.main.h", (double)butWin_h(win) / (double)cg->fontH); clp_setInt(cg->clp, "client.main.x", butWin_x(win)); clp_setInt(cg->clp, "client.main.y", butWin_y(win)); cMain->win = NULL; cliMain_destroy(cMain); return(0); } static void dataIn(void *packet, const char *buf, int bufLen) { CliMain *cMain = packet; int dataType, args, userNum; CliGameState oldState; const char *temp; assert(MAGIC(cMain)); if (buf == NULL) { str_print(&cMain->outStr, msg_cliHangup, cMain->data->serverName, strerror(bufLen)); abutMsg_winCreate(cMain->data->cg->abut, "Cgoban Error", str_chars(&cMain->outStr)); cliMain_destroy(cMain); } else { oldState = cMain->state; str_copyCharsLen(&cMain->outStr, buf, bufLen); str_catChar(&cMain->outStr, '\n'); if (cMain->state == cliMain_inFile) { if (!strcmp(buf, cMain->fileEnd)) cMain->state = cliMain_idle; else cliMain_log(cMain, str_chars(&cMain->outStr)); } else if (bufLen) { args = sscanf(buf, "%d", &dataType); if (args != 1) { dataType = 0; args = 1; #if DEBUG printf("Did not pass: \"%s\"\n", buf); #endif } else { while (isdigit(*buf)) { ++buf; --bufLen; } ++buf; --bufLen; str_copyCharsLen(&cMain->outStr, buf, bufLen); str_catChar(&cMain->outStr, '\n'); } assert(args == 1); /* * Set promptReady to FALSE. If we got a 1, we'll immediately set it to * TRUE so no harm done. */ cMain->data->conn.promptReady = FALSE; switch(dataType) { case 1: /* Prompt. */ cMain->state = cliMain_idle; if (!cMain->promptVisible) { butTbin_insert(cMain->script->tbin, "#> "); cMain->promptVisible = TRUE; } cliConn_prompt(&cMain->data->conn); break; case 2: /* Beep. */ XBell(butEnv_dpy(cMain->data->cg->env), 0); break; case 5: /* Error. */ XBell(butEnv_dpy(cMain->data->cg->env), 0); cliMain_log(cMain, str_chars(&cMain->outStr)); break; case 7: /* Game info. */ cliGameList_gotGameInfo(&cMain->gameList, buf); break; case 8: /* Help. */ assert(!strcmp(buf, "File")); cMain->state = cliMain_inFile; cMain->fileEnd = "8 File"; break; case 9: /* Misc. */ /* * 9 Use or to respond. * 9 Requesting match in 21 min with wwms as White. * 9 wwms declines your request for a match. * 9 You decline the match offer from wms. */ if (!strcmp(buf, "File")) { cMain->state = cliMain_inFile; cMain->fileEnd = "9 File"; } else if (!strncmp(buf, "Removing game ", 14)) cliGameList_notObserving(&cMain->gameList, buf); else if (!strncmp(buf, "Removing @ ", 11)) cliGameList_deadStone(&cMain->gameList, buf); else if (!strncmp(buf, "You can check ", 14)) cliGameList_selectDead(&cMain->gameList, buf); else if (!strncmp(buf, "Use playerList, oppName); if (oppRank == NULL) rankDiff = 1; else rankDiff = strcmp(oppRank, cliPlayerList_getRank(&cMain->playerList, str_chars(&cMain->data-> userName))); cliMatch_matchCommand(cMain->data, buf, &cMain->playerList.match, rankDiff); } else if (((bufLen > 34) && !strcmp(buf + bufLen - 34, "declines your request for a match.")) || ((bufLen > 26) && !strcmp(buf + bufLen - 26, "withdraws the match offer."))) cliMatch_declineCommand(cMain->playerList.match, buf); else if (strncmp(buf, "Adding game to", 14) && strncmp(buf, "{Game ", 6) && strncmp(buf, "Requesting ", 11) && strncmp(buf, "You decline", 11) && strncmp(buf, "Match [", 7) && strncmp(buf, "Updating ", 9) && strncmp(buf, "Declining offer", 15) && ((bufLen < 26) || strcmp(buf + bufLen - 26, "updates the match request."))) { cliMain_log(cMain, str_chars(&cMain->outStr)); } break; case 11: /* Kibitzes. */ cliGameList_kibitz(&cMain->gameList, buf); break; case 15: /* Game moves. */ cliGameList_gotMove(&cMain->gameList, buf); /* * On NNGS, if you start a game when your state is closed, you * become open. Update the cMain window's radio button here. */ if ((cMain->gameList.playGame >= 0) && (cliPlayer_closed + butRadio_get(cMain->userState) == cliPlayer_closed)) { butRadio_set(cMain->userState, cliPlayer_open - cliPlayer_closed, FALSE); } break; case 19: /* Say. */ cliGameList_say(&cMain->gameList, buf); break; case 21: /* Shouts & game start/stop info & user log in/out. */ if (!strncmp(buf, "{Game ", 6)) { if (strchr(buf, '@') != NULL) { /* A continued game. */ cliGameList_gameStarts(&cMain->gameList, buf); } else { cliGameList_gameGone(&cMain->gameList, buf, bufLen); } } else if (!strncmp(buf, "{Match ", 7)) { /* A new game. */ cliGameList_gameStarts(&cMain->gameList, buf); } else if (!strcmp(buf + bufLen - 17, "has disconnected}")) { cliPlayerList_disconnected(&cMain->playerList, buf); } else if (!strcmp(buf + bufLen - 15, "has connected.}")) { cliPlayerList_connected(&cMain->playerList, buf); } else cliMain_log(cMain, str_chars(&cMain->outStr)); break; case 22: /* A board. */ cliLook_gotData(&cMain->look, str_chars(&cMain->outStr)); break; case 24: /* Tells. */ for (temp = buf; *temp != ':'; ++temp); temp += 2; if (!strncmp(temp, "CLIENT: ", 8)) { client2client(cMain, temp); } else if (!cliGame_tellIsSay(&cMain->gameList, &cMain->outStr)) cliMain_log(cMain, str_chars(&cMain->outStr)); break; case 25: /* Results list. */ assert(!strcmp(buf, "File")); cMain->state = cliMain_inFile; cMain->fileEnd = "25 File"; break; case 27: /* Who output. */ cMain->state = cliMain_gotWho; cliPlayerList_whoOutput(&cMain->playerList, buf); break; case 28: /* Undo. */ cliGameList_gotUndo(&cMain->gameList, buf); break; case 20: /* Game results. */ case 23: /* A list of stored games. */ case 32: /* Channel tell. */ case 39: /* Version number. */ case 40: /* Confirming who you spoke to, or something like that. */ case 42: /* IGS "user" output. */ case 500: /* NNGS emotes. */ case 501: /* NNGS tell you who the emote went to. */ default: cliMain_log(cMain, str_chars(&cMain->outStr)); break; } if ((oldState == cliMain_gotWho) && (cMain->state != cliMain_gotWho)) { cliPlayerList_sort(&cMain->playerList); userNum = cliPlayerList_lookupPlayer(&cMain->playerList, str_chars(&cMain->data->userName)); if ((userNum >= 0) && (butRadio_get(cMain->userState) == cliPlayer_unknown - cliPlayer_closed)) { butRadio_set(cMain->userState, cMain->playerList.players[userNum].state - cliPlayer_closed, FALSE); } } } } } static ButOut userInput(But *but, const char *input) { CliMain *cMain = but_packet(but); assert(MAGIC(cMain)); if (input[0] != '\0') { str_copyChars(&cMain->history[cMain->historyBeingFilled], input); if (++cMain->historyBeingFilled >= MAIN_HISTORYMAXLEN) cMain->historyBeingFilled = 0; cMain->historyBeingViewed = 0; if (++cMain->historyLen >= MAIN_HISTORYMAXLEN) cMain->historyLen = MAIN_HISTORYMAXLEN - 1; } str_print(&cMain->data->cmdBuild, "%s\n", input); cliConn_send(&cMain->data->conn, str_chars(&cMain->data->cmdBuild)); if (!cMain->promptVisible) str_print(&cMain->data->cmdBuild, "#> %s\n", input); butTbin_insert(cMain->script->tbin, str_chars(&cMain->data->cmdBuild)); butTextin_set(but, "", FALSE); cMain->promptVisible = FALSE; return(0); } static ButOut quitPressed(But *but) { cliMain_destroy(but_packet(but)); return(0); } static ButOut iResize(ButWin *win) { CliMain *cMain = butWin_packet(win); int w, h, size; int border; assert(MAGIC(cMain)); w = butWin_w(win); h = butWin_h(win); but_resize(cMain->iBg, 0,0, w,h); border = 2*butEnv_stdBw(butWin_env(win)); size = w - border * 2; but_resize(cMain->iPic, border, border, size, size); return(0); } static ButOut gamesPressed(But *but) { CliMain *cMain = but_packet(but); assert(MAGIC(cMain)); cliGameList_openWin(&cMain->gameList); return(0); } static ButOut playersPressed(But *but) { CliMain *cMain = but_packet(but); assert(MAGIC(cMain)); cliPlayerList_openWin(&cMain->playerList); return(0); } static ButOut newState(But *but, int value) { CliPlayerState newState = value + cliPlayer_closed; CliMain *cMain = but_packet(but); int userNum; assert(MAGIC(but)); switch(newState) { case cliPlayer_looking: cliConn_send(&cMain->data->conn, "toggle open 1\ntoggle looking 1\n"); break; case cliPlayer_open: cliConn_send(&cMain->data->conn, "toggle open 1\ntoggle looking 0\n"); break; case cliPlayer_closed: cliConn_send(&cMain->data->conn, "toggle open 0\ntoggle looking 0\n"); break; default: assert(0); break; } userNum = cliPlayerList_lookupPlayer(&cMain->playerList, str_chars(&cMain->data->userName)); if (userNum >= 0) { cliPlayerList_setState(&cMain->playerList, userNum, newState); } return(0); } void cliMain_message(CliMain *cMain, const char *message) { AbutMsgOpt ok; assert(MAGIC(cMain)); cliMain_clearMessage(cMain); ok.name = msg_ok; ok.callback = msgBoxKilled; ok.packet = cMain; ok.keyEq = cg_return; cMain->message = abutMsg_optCreate(cMain->data->cg->abut, cMain->win, 4, message, NULL, NULL, 1, &ok); } void cliMain_clearMessage(CliMain *cMain) { assert(MAGIC(cMain)); if (cMain->message) abutMsg_destroy(cMain->message, FALSE); cMain->message = NULL; } static ButOut msgBoxKilled(But *okBut) { CliMain *cMain = but_packet(okBut); assert(MAGIC(cMain)); assert(cMain->message != NULL); abutMsg_destroy(cMain->message, FALSE); cMain->message = NULL; return(0); } void cliMain_log(CliMain *cMain, const char *str) { if (cMain->promptVisible) { butTbin_delete(cMain->script->tbin, butTbin_len(cMain->script->tbin) - 3, 3); cMain->promptVisible = FALSE; } butTbin_insert((cMain)->script->tbin, (str)); } static void client2client(CliMain *cMain, const char *buf) { char oppName[31], freeChar = 'x'; int matches, hcap; float komi; if (strncmp(buf, "CLIENT: = 3) { /* Extra match info. */ cliMatch_extraInfo(cMain->playerList.match, oppName, hcap, komi, freeChar == 'f'); } } static ButOut prevHistory(But *but, KeySym keysym, uint keyModifiers, void *context) { CliMain *cMain = context; int i; assert(MAGIC(cMain)); if (cMain->historyBeingViewed == -cMain->historyLen) { return(BUTOUT_ERR); } if (cMain->historyBeingViewed == 0) { str_copyChars(&cMain->history[cMain->historyBeingFilled], butTextin_get(cMain->tin)); } --cMain->historyBeingViewed; i = cMain->historyBeingFilled + cMain->historyBeingViewed; if (i < 0) i += MAIN_HISTORYMAXLEN; butTextin_set(cMain->tin, str_chars(&cMain->history[i]), FALSE); return(0); } static ButOut nextHistory(But *but, KeySym keysym, uint keyModifiers, void *context) { CliMain *cMain = context; int i; assert(MAGIC(cMain)); if (cMain->historyBeingViewed == 0) { return(BUTOUT_ERR); } ++cMain->historyBeingViewed; i = cMain->historyBeingFilled + cMain->historyBeingViewed; if (i < 0) i += MAIN_HISTORYMAXLEN; butTextin_set(cMain->tin, str_chars(&cMain->history[i]), FALSE); return(0); } cgoban-1.9.14/src/client/match.c0000664000671000067100000005772207043224471012051 /* * src/client/match.c, part of Complete Goban (player program) * Copyright (C) 1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include "../msg.h" #include #include #include #include #include #include #include "../goTime.h" #ifdef _CLIENT_MATCH_H_ Levelization Error. #endif #include "match.h" /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut resize(ButWin *win); static ButOut destroy(ButWin *win); static ButOut newSize(But *but, const char *value); static ButOut newHcap(But *but, const char *value); static ButOut newKomi(But *but, const char *value); static ButOut newMainTime(But *but, const char *value); static ButOut newBYTime(But *but, const char *value); static ButOut okPressed(But *but); static ButOut cancelPressed(But *but); static ButOut newFree(But *but, bool newVal); static ButOut swapPressed(But *but); static CliMatch *playerLookup(CliMatch *chain, const char *player); static ButOut changeMain(But *but); static ButOut changeBy(But *but); static ButOut changeSize(But *but); static ButOut changeKomi(But *but); static ButOut changeHcap(But *but); /********************************************************************** * Functions **********************************************************************/ CliMatch *cliMatch_matchCommand(CliData *data, const char *command, CliMatch **next, int rankDiff) { char oppName[21]; char colorChar; int args, size, mainTime, byTime; CliMatch *match; args = sscanf(command, "Use ", oppName, &colorChar, &size, &mainTime, &byTime); assert(args == 5); assert((colorChar == 'W') || (colorChar == 'B')); match = playerLookup(*next, oppName); if (match == NULL) { /* Start up a new match window. */ match = cliMatch_create(data, oppName, next, rankDiff); if ((colorChar == 'B') != match->meFirst) swapPressed(match->swap); } else { /* Modify an old one. */ XRaiseWindow(butEnv_dpy(butWin_env(match->win)), butWin_xwin(match->win)); if ((colorChar == 'B') != match->meFirst) swapPressed(match->swap); } str_print(&data->cmdBuild, "%d", match->size = size); butTextin_set(match->sizeIn, str_chars(&data->cmdBuild), TRUE); goTime_str(match->mainTime = mainTime * 60, &data->cmdBuild); butTextin_set(match->mainIn, str_chars(&data->cmdBuild), TRUE); goTime_str(match->byTime = byTime * 60, &data->cmdBuild); butTextin_set(match->byIn, str_chars(&data->cmdBuild), TRUE); match->state = cliMatch_recvd; butText_set(match->title, msg_cliGameSetupRecvd); return(match); } CliMatch *cliMatch_create(CliData *data, const char *oppName, CliMatch **next, int rankDiff) { CliMatch *m; Cgoban *cg; int i, h, w; char curText[20]; bool err; uint flags; assert(MAGIC(data)); m = playerLookup(*next, oppName); if (m != NULL) { XRaiseWindow(butEnv_dpy(butWin_env(m->win)), butWin_xwin(m->win)); return(m); } cg = data->cg; m = wms_malloc(sizeof(CliMatch)); MAGIC_SET(m); m->next = *next; m->prev = next; *next = m; m->data = data; m->state = cliMatch_nil; if (rankDiff == 0) { m->meFirst = clp_getBool(cg->clp, "client.match.meFirst"); m->komi = 5.5; m->hcap = 0; } else if (rankDiff > 0) { m->meFirst = FALSE; m->komi = 0.5; m->hcap = 0; } else /* rankDiff < 0 */ { m->meFirst = TRUE; m->komi = 0.5; m->hcap = 0; } if (m->meFirst) { str_initChars(&m->wName, oppName); str_initChars(&m->bName, str_chars(&data->userName)); } else { str_initChars(&m->bName, oppName); str_initChars(&m->wName, str_chars(&data->userName)); } h = cg->fontH * 18 + butEnv_stdBw(cg->env) * 19; w = (h * 1.4142136) + 0.5; m->win = butWin_create(m, cg->env, "Server Game Setup", w, h, NULL, NULL, resize, destroy); if (m->next == NULL) { /* * We only want to set the window to the "standard" place if it is the * first one. Otherwise all the windows would stack up on each other, * which is kind of annoying. */ i = clp_iGetInt(cg->clp, "client.match.x", &err); if (!err) butWin_setX(m->win, i); i = clp_iGetInt(cg->clp, "client.match.y", &err); if (!err) butWin_setY(m->win, i); } butWin_activate(m->win); m->bg = butBoxFilled_create(m->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(m->bg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); m->title = butText_create(m->win, 1, BUT_DRAWABLE, msg_cliGameSetup, butText_center); butText_setFont(m->title, 2); m->namesBox = butBox_create(m->win, 1, BUT_DRAWABLE); butBox_setPixmaps(m->namesBox, cg->bgLitPixmap, cg->bgShadPixmap); m->wBox = butBoxFilled_create(m->win, 1, BUT_DRAWABLE); butBoxFilled_setColors(m->wBox, BUT_LIT, BUT_SHAD, BUT_BG); str_print(&data->cmdBuild, CGBUTS_WSTONECHAR " %s", str_chars(&m->wName)); m->wTitle = butText_create(m->win, 2, BUT_DRAWABLE, str_chars(&data->cmdBuild), butText_left); m->bBox = butBoxFilled_create(m->win, 1, BUT_DRAWABLE); butBoxFilled_setColors(m->bBox, BUT_LIT, BUT_SHAD, BUT_BG); str_print(&data->cmdBuild, CGBUTS_BSTONECHAR " %s", str_chars(&m->bName)); m->bTitle = butText_create(m->win, 2, BUT_DRAWABLE, str_chars(&data->cmdBuild), butText_left); m->swap = butAct_create(swapPressed, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_swapColors, BUT_ALEFT|BUT_ARIGHT); m->size = clp_getInt(cg->clp, "client.match.size"); m->mainTime = clp_getInt(cg->clp, "client.match.mainTime"); m->byTime = clp_getInt(cg->clp, "client.match.byTime"); m->rulesBox = butBox_create(m->win, 1, BUT_DRAWABLE); butBox_setPixmaps(m->rulesBox, cg->bgLitPixmap, cg->bgShadPixmap); m->sizeStr = butText_create(m->win, 1, BUT_DRAWABLE, msg_boardSize, butText_center); sprintf(curText, "%d", m->size); m->sizeIn = butTextin_create(newSize, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, curText, 10); flags = BUT_DRAWABLE; if (m->size < 19) flags |= BUT_PRESSABLE; m->sizeUp = butAct_create(changeSize, m, m->win, 1, flags, CGBUTS_FWDCHAR, BUT_RRIGHT|BUT_SLEFT); flags = BUT_DRAWABLE; if (m->size > 9) flags |= BUT_PRESSABLE; m->sizeDown = butAct_create(changeSize, m, m->win, 1, flags, CGBUTS_BACKCHAR, BUT_RLEFT|BUT_SRIGHT); m->hcapStr = butText_create(m->win, 1, BUT_DRAWABLE, msg_handicap, butText_center); sprintf(curText, "%d", m->hcap); m->hcapIn = butTextin_create(newHcap, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, curText, 10); flags = BUT_DRAWABLE; if (m->hcap < 9) flags |= BUT_PRESSABLE; m->hcapUp = butAct_create(changeHcap, m, m->win, 1, flags, CGBUTS_FWDCHAR, BUT_RRIGHT|BUT_SLEFT); flags = BUT_DRAWABLE; if (m->hcap > 0) flags |= BUT_PRESSABLE; m->hcapDown = butAct_create(changeHcap, m, m->win, 1, flags, CGBUTS_BACKCHAR, BUT_RLEFT|BUT_SRIGHT); m->komiStr = butText_create(m->win, 1, BUT_DRAWABLE, msg_komi, butText_center); sprintf(curText, "%g", m->komi); m->komiIn = butTextin_create(newKomi, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, curText, 10); m->komiUp = butAct_create(changeKomi, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, CGBUTS_FWDCHAR, BUT_RRIGHT|BUT_SLEFT); m->komiDown = butAct_create(changeKomi, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, CGBUTS_BACKCHAR, BUT_RLEFT|BUT_SRIGHT); m->timeBox = butBox_create(m->win, 1, BUT_DRAWABLE); butBox_setPixmaps(m->timeBox, cg->bgLitPixmap, cg->bgShadPixmap); m->mainStr = butText_create(m->win, 1, BUT_DRAWABLE, msg_primaryTime, butText_center); m->mainIn = butTextin_create(newMainTime, m, m->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, clp_getStr(cg->clp, "client.match.mainTime"), 10); m->mainUp1 = butAct_create(changeMain, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, CGBUTS_FWDCHAR, BUT_SRIGHT|BUT_SLEFT); flags = BUT_DRAWABLE; m->mainTime = goTime_parseChars(butTextin_get(m->mainIn), FALSE, NULL); if (m->mainTime > 0) flags |= BUT_PRESSABLE; m->mainDown1 = butAct_create(changeMain, m, m->win, 1, flags, CGBUTS_BACKCHAR, BUT_SRIGHT|BUT_SLEFT); m->mainUp5 = butAct_create(changeMain, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, CGBUTS_FFCHAR, BUT_RRIGHT|BUT_SLEFT); m->mainDown5 = butAct_create(changeMain, m, m->win, 1, flags, CGBUTS_REWCHAR, BUT_RLEFT|BUT_SRIGHT); m->byStr = butText_create(m->win, 1, BUT_DRAWABLE, msg_byoYomi, butText_center); m->byIn = butTextin_create(newBYTime, m, m->win, 1, BUT_PRESSABLE|BUT_DRAWABLE, clp_getStr(cg->clp, "client.match.byTime"), 10); m->byTime = goTime_parseChars(butTextin_get(m->byIn), FALSE, NULL); m->byUp1 = butAct_create(changeBy, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, CGBUTS_FWDCHAR, BUT_SRIGHT|BUT_SLEFT); flags = BUT_DRAWABLE; if (m->byTime > 0) flags |= BUT_PRESSABLE; m->byDown1 = butAct_create(changeBy, m, m->win, 1, flags, CGBUTS_BACKCHAR, BUT_SRIGHT|BUT_SLEFT); m->byUp5 = butAct_create(changeBy, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, CGBUTS_FFCHAR, BUT_RRIGHT|BUT_SLEFT); m->byDown5 = butAct_create(changeBy, m, m->win, 1, flags, CGBUTS_REWCHAR, BUT_RLEFT|BUT_SRIGHT); m->freeTitle = butText_create(m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_freeGame, butText_center); m->freeGame = butCb_create(newFree, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, clp_getBool(cg->clp, "client.match.free")); m->help = butCt_create(cgoban_createHelpWindow, &help_cliMatch, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_help); m->ok = butCt_create(okPressed, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_ok); m->cancel = butCt_create(cancelPressed, m, m->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, msg_cancel); return(m); } void cliMatch_destroy(CliMatch *match) { assert(MAGIC(match)); butWin_destroy(match->win); } bool cliMatch_destroyChain(CliMatch *match, const char *oppName, int *hcap, float *komi, bool *free) { bool result = FALSE; /* * This code wouldn't work if things were done right in the but library * and the windows were destroyed as soon as I asked for it. But since * the library is too broken for me to fix right now I'll have to do it * this way. The second assert in the loop will fail when the but library * is rewritten to do things right. */ while (match != NULL) { assert(MAGIC(match)); if (oppName != NULL) { if (!strcmp(oppName, str_chars(&match->wName)) || !strcmp(oppName, str_chars(&match->bName))) { result = TRUE; *hcap = match->hcap; *komi = match->komi; *free = butCb_get(match->freeGame); match->state = cliMatch_nil; } } cliMatch_destroy(match); assert(MAGIC(match)); match = match->next; } return(result); } static ButOut resize(ButWin *win) { CliMatch *m = butWin_packet(win); Cgoban *cg; int w, butW, h, x, y; int bw, fh; ButEnv *env; assert(MAGIC(m)); cg = m->data->cg; assert(MAGIC(cg)); env = cg->env; bw = butEnv_stdBw(env); fh = cg->fontH; w = butWin_w(win); h = butWin_h(win); butW = w/2-5*bw; but_resize(m->bg, 0,0, w,h); but_resize(m->title, 0,bw*2, w, fh*2); but_resize(m->namesBox, bw,bw*3+fh*2, w-bw*2,bw*4+fh*2); but_resize(m->wBox, bw*3, bw*5+fh*2, w/2 - (bw * 4 + fh * 4), fh * 2); but_resize(m->wTitle, bw * 5, bw * 5 + fh * 2, w/2 - (bw * 8 + fh * 4), fh * 2); but_resize(m->bBox, w/2 + bw + fh*4, bw*5+fh*2, w - (w/2+bw*4 + fh * 4), fh*2); but_resize(m->bTitle, w/2 + bw * 3 + fh*4, bw*5+fh*2, w - (w/2+bw*8 + fh * 4), fh*2); but_resize(m->swap, w/2 - fh * 4, bw*5+fh*2, fh * 8, fh * 2); y = bw*7+fh*4; but_resize(m->rulesBox, bw,y, w/2-bw,fh*12+bw*9); but_resize(m->sizeStr, bw*3,y+bw*2+fh*0, butW,fh*2); but_resize(m->sizeIn, bw*3+fh*2,y+bw*3+fh*2, butW-fh*4,fh*2); but_resize(m->sizeDown, bw*3,y+bw*3+fh*2, fh*2,fh*2); but_resize(m->sizeUp, bw*3+butW-fh*2,y+bw*3+fh*2, fh*2,fh*2); but_resize(m->hcapStr, bw*3,y+bw*4+fh*4, butW,fh*2); but_resize(m->hcapIn, bw*3+fh*2,y+bw*5+fh*6, butW-fh*4,fh*2); but_resize(m->hcapDown, bw*3,y+bw*5+fh*6, fh*2,fh*2); but_resize(m->hcapUp, bw*3+butW-fh*2,y+bw*5+fh*6, fh*2,fh*2); but_resize(m->komiStr, bw*3,y+bw*6+fh*8, butW,fh*2); but_resize(m->komiIn, bw*3+fh*2,y+bw*7+fh*10, butW-fh*4,fh*2); but_resize(m->komiDown, bw*3,y+bw*7+fh*10, fh*2,fh*2); but_resize(m->komiUp, bw*3+butW-fh*2,y+bw*7+fh*10, fh*2,fh*2); but_resize(m->timeBox, w/2,y, w-bw-w/2,fh*12+bw*9); x = w/2 + bw*2; butW = w-x-bw*3; but_resize(m->mainStr, x,y+bw*2+fh*0, butW,fh*2); but_resize(m->mainIn, x+fh*4,y+bw*3+fh*2, butW-fh*8,fh*2); but_resize(m->mainDown5, x,y+bw*3+fh*2, fh*2,fh*2); but_resize(m->mainDown1, x+fh*2,y+bw*3+fh*2, fh*2,fh*2); but_resize(m->mainUp1, x+butW-fh*4,y+bw*3+fh*2, fh*2,fh*2); but_resize(m->mainUp5, x+butW-fh*2,y+bw*3+fh*2, fh*2,fh*2); but_resize(m->byStr, x,y+bw*4+fh*4, butW,fh*2); but_resize(m->byIn, x+fh*4,y+bw*5+fh*6, butW-fh*8,fh*2); but_resize(m->byDown5, x,y+bw*5+fh*6, fh*2,fh*2); but_resize(m->byDown1, x+fh*2,y+bw*5+fh*6, fh*2,fh*2); but_resize(m->byUp1, x+butW-fh*4,y+bw*5+fh*6, fh*2,fh*2); but_resize(m->byUp5, x+butW-fh*2,y+bw*5+fh*6, fh*2,fh*2); but_resize(m->freeTitle, x,y+bw*6+fh*8, butW,fh*2); but_resize(m->freeGame, x + butW/2 - fh,y+bw*7+fh*10, fh*2,fh*2); but_resize(m->help, bw*2,y+bw*10+fh*12, (w-bw*6+1)/3,fh*2); but_resize(m->cancel, bw*3+(w-bw*6+1)/3,y+bw*10+fh*12, w-2*(bw*3+(w-bw*6+1)/3),fh*2); but_resize(m->ok, w-(bw*2+(w-bw*6+1)/3),y+bw*10+fh*12, (w-bw*6+1)/3,fh*2); return(0); } static ButOut destroy(ButWin *win) { CliMatch *m; Clp *clp; Str *opp; m = butWin_packet(win); assert(MAGIC(m)); if (m->state != cliMatch_nil) { if (m->meFirst) opp = &m->wName; else opp = &m->bName; str_print(&m->data->cmdBuild, "decline %s\n", str_chars(opp)); cliConn_send(&m->data->conn, str_chars(&m->data->cmdBuild)); } clp = m->data->cg->clp; clp_setInt(clp, "client.match.x", butWin_x(win)); clp_setInt(clp, "client.match.y", butWin_y(win)); clp_setBool(clp, "client.match.meFirst", m->meFirst); str_deinit(&m->wName); str_deinit(&m->bName); *(m->prev) = m->next; MAGIC_UNSET(m); wms_free(m); return(0); } static ButOut newSize(But *but, const char *value) { CliMatch *m = but_packet(but); int newSize; char curValue[3]; assert(MAGIC(m)); newSize = atoi(value); if ((newSize > 19) || !clp_setStr(m->data->cg->clp, "client.match.size", value)) { str_print(&m->data->cmdBuild, msg_badSize, value, 19); cgoban_createMsgWindow(m->data->cg, "Cgoban Error", str_chars(&m->data->cmdBuild)); sprintf(curValue, "%d", m->size); butTextin_set(but, curValue, FALSE); return(BUTOUT_ERR); } m->size = newSize; if (m->size > 9) { but_setFlags(m->sizeDown, BUT_PRESSABLE); } else { but_setFlags(m->sizeDown, BUT_NOPRESS); } if (m->size < 19) but_setFlags(m->sizeUp, BUT_PRESSABLE); else but_setFlags(m->sizeUp, BUT_NOPRESS); return(0); } static ButOut newHcap(But *but, const char *value) { CliMatch *m = but_packet(but); int newHcap; char curValue[2]; bool err; assert(MAGIC(m)); newHcap = wms_atoi(value, &err); if ((newHcap > 9) || (newHcap == 1) || (newHcap < 0) || err) { str_print(&m->data->cmdBuild, msg_badHcap, value, 9); cgoban_createMsgWindow(m->data->cg, "Cgoban Error", str_chars(&m->data->cmdBuild)); sprintf(curValue, "%d", m->hcap); butTextin_set(but, curValue, FALSE); return(BUTOUT_ERR); } m->hcap = newHcap; if (m->hcap > 0) { but_setFlags(m->hcapDown, BUT_PRESSABLE); } else { but_setFlags(m->hcapDown, BUT_NOPRESS); } if (m->hcap < 9) but_setFlags(m->hcapUp, BUT_PRESSABLE); else but_setFlags(m->hcapUp, BUT_NOPRESS); return(0); } static ButOut newKomi(But *but, const char *value) { CliMatch *m = but_packet(but); float newKomi; char curValue[7]; bool err; assert(MAGIC(m)); newKomi = wms_atof(value, &err); if ((newKomi > 999.5) || (newKomi < -999.5) || err || ((int)(newKomi * 2.0) != newKomi * 2.0)) { str_print(&m->data->cmdBuild, msg_badKomi, value); cgoban_createMsgWindow(m->data->cg, "Cgoban Error", str_chars(&m->data->cmdBuild)); sprintf(curValue, "%g", m->komi); butTextin_set(but, curValue, FALSE); return(BUTOUT_ERR); } m->komi = newKomi; if (m->komi > -99.5) { but_setFlags(m->hcapDown, BUT_PRESSABLE); } else { but_setFlags(m->hcapDown, BUT_NOPRESS); } if (m->hcap < 99.5) but_setFlags(m->hcapUp, BUT_PRESSABLE); else but_setFlags(m->hcapUp, BUT_NOPRESS); return(0); } static ButOut newMainTime(But *but, const char *value) { CliMatch *m = but_packet(but); Str errMsg; assert(MAGIC(m)); if (!clp_setStr(m->data->cg->clp, "client.match.mainTime", value)) { str_init(&errMsg); str_print(&errMsg, msg_badTime, value); cgoban_createMsgWindow(m->data->cg, "Cgoban Error", str_chars(&errMsg)); goTime_str(m->mainTime, &errMsg); butTextin_set(but, str_chars(&errMsg), FALSE); str_deinit(&errMsg); return(BUTOUT_ERR); } m->mainTime = goTime_parseChars(value, FALSE, NULL); if (but_getFlags(but) & BUT_KEYED) but_setFlags(m->byIn, BUT_KEYED); if (m->mainTime > 0) { but_setFlags(m->mainDown1, BUT_PRESSABLE); but_setFlags(m->mainDown5, BUT_PRESSABLE); } else { but_setFlags(m->mainDown1, BUT_NOPRESS); but_setFlags(m->mainDown5, BUT_NOPRESS); } return(0); } static ButOut newBYTime(But *but, const char *value) { CliMatch *m = but_packet(but); Str errMsg; assert(MAGIC(m)); if (!clp_setStr(m->data->cg->clp, "client.match.byTime", value)) { str_init(&errMsg); str_print(&errMsg, msg_badTime, value); cgoban_createMsgWindow(m->data->cg, "Cgoban Error", str_chars(&errMsg)); goTime_str(m->byTime, &errMsg); butTextin_set(but, str_chars(&errMsg), FALSE); str_deinit(&errMsg); return(BUTOUT_ERR); } m->byTime = goTime_parseChars(value, FALSE, NULL); but_setFlags(but, BUT_NOKEY); if (m->byTime > 0) { but_setFlags(m->byDown1, BUT_PRESSABLE); but_setFlags(m->byDown5, BUT_PRESSABLE); } else { but_setFlags(m->byDown1, BUT_NOPRESS); but_setFlags(m->byDown5, BUT_NOPRESS); } return(0); } static ButOut okPressed(But *but) { CliMatch *m = but_packet(but); const char *oppName, *myName; ButOut result; assert(MAGIC(m)); if (m->meFirst) { oppName = str_chars(&m->wName); myName = str_chars(&m->bName); } else { myName = str_chars(&m->wName); oppName = str_chars(&m->bName); } result = newSize(m->sizeIn, butTextin_get(m->sizeIn)) | newMainTime(m->mainIn, butTextin_get(m->mainIn)) | newBYTime(m->byIn, butTextin_get(m->byIn)); if (!(result & BUTOUT_ERR)) { str_print(&m->data->cmdBuild, "match %s %c %d %d %d\n" "tell %s CLIENT: match %s wants " "handicap %d, komi %g", oppName, (int)("wb"[m->meFirst]), m->size, (m->mainTime + 59) / 60, (m->byTime + 59) / 60, oppName, myName, m->hcap, m->komi); if (butCb_get(m->freeGame)) str_catChars(&m->data->cmdBuild, ", free\n"); else str_catChar(&m->data->cmdBuild, '\n'); cliConn_send(&m->data->conn, str_chars(&m->data->cmdBuild)); m->state = cliMatch_sent; butText_set(m->title, msg_cliGameSetupSent); } return(result); } static ButOut cancelPressed(But *but) { butWin_destroy(but_win(but)); return(0); } static ButOut newFree(But *but, bool newVal) { CliMatch *m; m = but_packet(but); assert(MAGIC(m)); clp_setBool(m->data->cg->clp, "client.match.free", newVal); return(0); } static ButOut swapPressed(But *but) { CliMatch *m; Str temp, *cmdBuild; m = but_packet(but); assert(MAGIC(m)); temp = m->wName; m->wName = m->bName; m->bName = temp; m->meFirst = !m->meFirst; cmdBuild = &m->data->cmdBuild; str_print(cmdBuild, CGBUTS_WSTONECHAR " %s", str_chars(&m->wName)); butText_set(m->wTitle, str_chars(cmdBuild)); str_print(cmdBuild, CGBUTS_BSTONECHAR " %s", str_chars(&m->bName)); butText_set(m->bTitle, str_chars(cmdBuild)); return(0); } void cliMatch_declineCommand(CliMatch *match, const char *buf) { char name[30]; sscanf(buf, "%s", name); match = playerLookup(match, name); if (match != NULL) { match->state = cliMatch_nil; butText_set(match->title, msg_cliGameSetupRej); } } static CliMatch *playerLookup(CliMatch *chain, const char *player) { while (chain != NULL) { if (!strcmp(player, str_chars(&chain->wName)) || !strcmp(player, str_chars(&chain->bName))) return(chain); chain = chain->next; } return(NULL); } static ButOut changeMain(But *but) { CliMatch *m = but_packet(but); assert(MAGIC(m)); if (newMainTime(m->mainIn, butTextin_get(m->mainIn)) & BUTOUT_ERR) return(BUTOUT_ERR); if (but == m->mainUp1) { m->mainTime += 60; } else if (but == m->mainUp5) { m->mainTime += 60 * 5; } else if (but == m->mainDown1) { m->mainTime -= 60; if (m->mainTime < 0) m->mainTime = 0; } else { assert(but == m->mainDown5); m->mainTime -= 60 * 5; if (m->mainTime < 0) m->mainTime = 0; } goTime_str(m->mainTime, &m->data->cmdBuild); butTextin_set(m->mainIn, str_chars(&m->data->cmdBuild), TRUE); return(0); } static ButOut changeBy(But *but) { CliMatch *m = but_packet(but); assert(MAGIC(m)); if (newBYTime(m->byIn, butTextin_get(m->byIn)) & BUTOUT_ERR) return(BUTOUT_ERR); if (but == m->byUp1) { m->byTime += 60; } else if (but == m->byUp5) { m->byTime += 60 * 5; } else if (but == m->byDown1) { m->byTime -= 60; if (m->byTime < 0) m->byTime = 0; } else { assert(but == m->byDown5); m->byTime -= 60 * 5; if (m->byTime < 0) m->byTime = 0; } goTime_str(m->byTime, &m->data->cmdBuild); butTextin_set(m->byIn, str_chars(&m->data->cmdBuild), TRUE); return(0); } static ButOut changeSize(But *but) { CliMatch *m = but_packet(but); char sizeStr[3]; assert(MAGIC(m)); if (newSize(m->sizeIn, butTextin_get(m->sizeIn)) & BUTOUT_ERR) return(BUTOUT_ERR); if (but == m->sizeUp) { if (m->size < 13) m->size = 13; else m->size = 19; } else { assert(but == m->sizeDown); if (m->size > 13) m->size = 13; else m->size = 9; } sprintf(sizeStr, "%d", m->size); butTextin_set(m->sizeIn, sizeStr, TRUE); return(0); } static ButOut changeKomi(But *but) { CliMatch *m = but_packet(but); char komiStr[10]; assert(MAGIC(m)); if (newKomi(m->komiIn, butTextin_get(m->komiIn)) & BUTOUT_ERR) return(BUTOUT_ERR); if (but == m->komiUp) { m->komi += 1.0; if (m->komi > 99.5) m->komi = 99.5; } else { assert(but == m->komiDown); m->komi -= 1.0; if (m->komi < -99.5) m->komi = -99.5; } sprintf(komiStr, "%g", m->komi); butTextin_set(m->komiIn, komiStr, TRUE); return(0); } static ButOut changeHcap(But *but) { CliMatch *m = but_packet(but); char hcapStr[3]; assert(MAGIC(m)); if (newHcap(m->hcapIn, butTextin_get(m->hcapIn)) & BUTOUT_ERR) return(BUTOUT_ERR); if (but == m->hcapUp) { ++m->hcap; if (m->hcap == 1) m->hcap = 2; if (m->hcap > 9) m->hcap = 9; } else { assert(but == m->hcapDown); --m->hcap; if (m->hcap == 1) m->hcap = 0; if (m->hcap < 0) m->hcap = 0; } sprintf(hcapStr, "%d", m->hcap); butTextin_set(m->hcapIn, hcapStr, TRUE); return(0); } void cliMatch_extraInfo(CliMatch *match, const char *oppName, int hcap, float komi, bool free) { char temp[20]; match = playerLookup(match, oppName); if (match != NULL) { sprintf(temp, "%d", hcap); butTextin_set(match->hcapIn, temp, TRUE); sprintf(temp, "%g", komi); butTextin_set(match->komiIn, temp, TRUE); match->komi = komi; butCb_set(match->freeGame, free, TRUE); } } cgoban-1.9.14/src/client/player.c0000664000671000067100000005211607043224471012241 /* * src/client/player.c, part of Complete Goan (player program) * Copyright (C) 1995-1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include "../msg.h" #include #include #include #include #include #ifdef _CLIENT_PLAYER_H_ Levelization Error. #endif #include "player.h" /********************************************************************** * Forward Declarations **********************************************************************/ static void expandPlayers(CliPlayerList *gl, int playerNum); static ButOut unmap(ButWin *win); static ButOut map(ButWin *win); static ButOut resize(ButWin *win); static ButOut destroy(ButWin *win); static void getListEl(CliPlayerList *gl, int gNum, Str *out); static ButOut sResize(ButWin *win); static void updatePlayer(CliPlayerList *pl, const char *playerInfo); static ButOut reload(But *but); static int cmpPlayers(const void *a, const void *b); static int getRankNum(const Str *rank); static ButOut newSort(But *but, int newSortType); static ButOut listPressed(But *but, int line); static void redrawLine(CliPlayerList *pl, int playerNum); static ButOut matchPressed(But *but); static ButOut observePressed(But *but); /********************************************************************** * Functions **********************************************************************/ CliPlayerList *cliPlayerList_init(CliPlayerList *gl, CliData *data) { MAGIC_SET(gl); gl->data = data; gl->maxPlayers = 0; gl->players = NULL; gl->sort = (CliPlayerSort)clp_getInt(data->cg->clp, "client.players.sort"); gl->sortEnd = 0; gl->win = NULL; gl->elfBugReported = FALSE; gl->match = NULL; return(gl); } CliPlayerList *cliPlayerList_deinit(CliPlayerList *gl) { Cgoban *cg; CliMatch *m; assert(MAGIC(gl)); cg = gl->data->cg; if (gl->players) wms_free(gl->players); if (gl->win) { clp_setDouble(cg->clp, "client.players.h", (double)butWin_h(gl->win) / (double)cg->fontH); clp_setInt(cg->clp, "client.players.x", butWin_x(gl->win)); clp_setInt(cg->clp, "client.players.y", butWin_y(gl->win)); butWin_setDestroy(gl->win, NULL); butWin_destroy(gl->win); } /* * Set all the match states to nil so they won't try to send declines * out a no-longer-valid conn! */ for (m = gl->match; m; m = m->next) m->state = cliMatch_nil; cliMatch_destroyChain(gl->match, NULL,NULL,NULL,NULL); MAGIC_UNSET(gl); return(gl); } void cliPlayerList_openWin(CliPlayerList *gl) { int winW, winH; Cgoban *cg; int i; bool err; Str winName; assert(MAGIC(gl)); if (gl->win) { XRaiseWindow(butEnv_dpy(gl->data->cg->env), butWin_xwin(gl->win)); return; } cliPlayerList_sort(gl); cg = gl->data->cg; winW = (butEnv_fontH(cg->env, 0) * 28) / 2 + 2 * cg->fontH + butEnv_stdBw(cg->env) * 8; winH = (clp_getDouble(cg->clp, "client.players.h") * cg->fontH + 0.5); str_init(&winName); str_print(&winName, "%s Player List", gl->data->serverName); gl->win = butWin_create(gl, cg->env, str_chars(&winName), winW, winH, unmap, map, resize, destroy); i = clpEntry_iGetInt(clp_lookup(cg->clp, "client.players.x"), &err); if (!err) butWin_setX(gl->win, i); i = clpEntry_iGetInt(clp_lookup(cg->clp, "client.players.y"), &err); if (!err) butWin_setY(gl->win, i); butWin_setMaxH(gl->win, 0); butWin_setMinH(gl->win, cg->fontH * 5); butWin_activate(gl->win); str_deinit(&winName); gl->bg = butBoxFilled_create(gl->win, 0, BUT_DRAWABLE); butBoxFilled_setPixmaps(gl->bg, cg->bgLitPixmap, cg->bgShadPixmap, cg->bgPixmap); gl->swin = abutSwin_create(gl, gl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, sResize); gl->sBg = butPlain_create(gl->swin->win, 0, BUT_DRAWABLE, BUT_BG); gl->list = butList_create(listPressed, gl, gl->swin->win, 2, BUT_DRAWABLE|BUT_PRESSABLE); gl->sortType = butRadio_create(newSort, gl, gl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, gl->sort, 3); gl->nameSort = butText_create(gl->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU, msg_name, butText_center); gl->rankSort = butText_create(gl->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU, msg_braceRank, butText_center); gl->stateSort = butText_create(gl->win, 2, BUT_DRAWABLE|BUT_PRESSTHRU, msg_state, butText_center); gl->titleBox = butBoxFilled_create(gl->win, 1, BUT_DRAWABLE); gl->title = butList_create(NULL, NULL, gl->win, 2, BUT_DRAWABLE); butList_setLen(gl->title, 1); butList_changeLine(gl->title, 0, msg_playerListDesc); gl->reload = butCt_create(reload, gl, gl->win, 1, BUT_DRAWABLE|BUT_PRESSABLE, "*"); for (i = 0; i < gl->maxPlayers; ++i) { if (gl->players[i].state != cliPlayer_noPlayer) { redrawLine(gl, i); } } butCan_resizeWin(gl->swin->win, 0, butList_len(gl->list) * butEnv_fontH(gl->data->cg->env, 0) + butEnv_stdBw(gl->data->cg->env) * 2, TRUE); } static void expandPlayers(CliPlayerList *gl, int playerNum) { int newMaxPlayers; CliPlayer *newPlayers; int i; if (playerNum >= gl->maxPlayers) { newMaxPlayers = (playerNum + 1) * 2; newPlayers = wms_malloc(newMaxPlayers * sizeof(CliPlayer)); for (i = 0; i < gl->maxPlayers; ++i) newPlayers[i] = gl->players[i]; for (; i < newMaxPlayers; ++i) { newPlayers[i].state = cliPlayer_noPlayer; newPlayers[i].sort = gl->sort; str_init(&newPlayers[i].name); str_init(&newPlayers[i].rank); str_init(&newPlayers[i].idleTime); newPlayers[i].but = NULL; newPlayers[i].gameIn = -1; } if (gl->players) wms_free(gl->players); gl->maxPlayers = newMaxPlayers; gl->players = newPlayers; } } static ButOut unmap(ButWin *win) { return(0); } static ButOut map(ButWin *win) { return(0); } static ButOut resize(ButWin *win) { int w, h; CliPlayerList *gl = butWin_packet(win); int bw = butEnv_stdBw(butWin_env(win)); int tabs[3]; static const ButTextAlign tabAligns[3] = {butText_center, butText_right, butText_right}; int fontH; int physFontH = butEnv_fontH(butWin_env(win), 0); int slideW = (physFontH * 3)/2; int centerAdd; assert(MAGIC(gl)); fontH = gl->data->cg->fontH; w = butWin_w(win); h = butWin_h(win); but_resize(gl->bg, 0, 0, w, h); but_resize(gl->sortType, bw*2 + slideW, bw*2, physFontH * 9, fontH * 2); but_resize(gl->nameSort, bw*2 + slideW, bw*2, (physFontH * 18 + 2) / 6, fontH * 2); but_resize(gl->rankSort, bw*2 + slideW + (physFontH * 18 + 2) / 6, bw*2, (physFontH * 18) / 2 - 2*(physFontH * 18 + 2) / 6, fontH * 2); but_resize(gl->stateSort, bw*2 + slideW + (physFontH * 18) / 2 - (physFontH * 18 + 2) / 6, bw*2, (physFontH * 18 + 2) / 6, fontH * 2); but_resize(gl->titleBox, bw*2 + slideW + physFontH * 9, bw*2, w - (bw*4 + slideW + physFontH * 9), fontH * 2); but_resize(gl->reload, bw*2, bw*2, slideW, fontH * 2); but_resize(gl->title, bw * 4 + slideW + (physFontH * 18) / 2, bw * 2 + (fontH * 2 - physFontH) / 2, w - (bw*2 + slideW + (physFontH * 18) / 2), physFontH); abutSwin_resize(gl->swin, bw*2, bw*2 + fontH*2, w - bw*4, h - bw*4 - fontH*2, slideW, physFontH); butCan_resizeWin(gl->swin->win, 0, butList_len(gl->list) * physFontH + bw * 2, TRUE); centerAdd = (physFontH * 3 + 1) / 4; tabs[0] = physFontH * 8; tabs[1] = (physFontH * 22) / 2; tabs[2] = (physFontH * 27) / 2; butList_setTabs(gl->list, tabs, tabAligns, 3); tabs[1] -= (physFontH * 18) / 2; tabs[2] -= (physFontH * 18) / 2; butList_setTabs(gl->title, tabs + 1, tabAligns + 1, 2); return(0); } static ButOut sResize(ButWin *win) { int w, h; AbutSwin *swin = butWin_packet(win); CliPlayerList *gl; int bw = butEnv_stdBw(butWin_env(win)); assert(MAGIC(swin)); gl = swin->packet; assert(MAGIC(gl)); w = butWin_w(win); h = butWin_h(win); but_resize(gl->sBg, 0, 0, w, h); butList_resize(gl->list, bw, bw, w - bw*2); return(0); } static ButOut destroy(ButWin *win) { CliPlayerList *gl = butWin_packet(win); Cgoban *cg = gl->data->cg; int i; assert(MAGIC(gl)); clp_setDouble(cg->clp, "client.players.h", (double)butWin_h(win) / (double)cg->fontH); clp_setInt(cg->clp, "client.players.x", butWin_x(win)); clp_setInt(cg->clp, "client.players.y", butWin_y(win)); gl->win = NULL; for (i = 0; i < gl->maxPlayers; ++i) { gl->players[i].but = NULL; } return(0); } static void getListEl(CliPlayerList *pl, int pNum, Str *out) { static const char desc[5] = {'?', 'X', 'O', '!', '-'}; char thisDesc, obPl, idleType; const char *idle = ""; int gameNum; CliPlayer *p = &pl->players[pNum]; if (p->state == cliPlayer_noPlayer) str_copyCharsLen(out, "", 0); thisDesc = desc[p->state]; if (p->gameIn >= 0) { thisDesc = 'X'; obPl = 'P'; gameNum = p->gameIn; } else if (p->gameOb >= 0) { obPl = 'O'; gameNum = p->gameOb; } else { obPl = ' '; gameNum = -1; } idleType = str_chars(&p->idleTime)[str_len(&p->idleTime) - 1]; if ((idleType != 's') || (atoi(str_chars(&p->idleTime)) >= 30)) idle = str_chars(&p->idleTime); if (gameNum >= 0) { str_print(out, "%s [%s]\t%c\t%s\t%c %d", str_chars(&p->name), str_chars(&p->rank), (int)thisDesc, idle, (int)obPl, gameNum); } else { str_print(out, "%s [%s]\t%c\t%s", str_chars(&p->name), str_chars(&p->rank), (int)thisDesc, idle); } } void cliPlayerList_whoOutput(CliPlayerList *pl, const char *buf) { char onePlayer[36]; if (buf[1] != 'I') { strncpy(onePlayer, buf, 35); onePlayer[35] = '\0'; updatePlayer(pl, onePlayer); if (strlen(buf) > 50) { strncpy(onePlayer, buf+37, 35); onePlayer[35] = '\0'; updatePlayer(pl, onePlayer); } } } static void updatePlayer(CliPlayerList *pl, const char *playerInfo) { char f1, f2, f3; char ob[40], play[40], name[40], idle[40], rank[40]; int args, playerNum; CliPlayer *p; args = sscanf(playerInfo, "%c%c%c %s %s %s %s %s", &f1, &f2, &f3, ob, play, name, idle, rank); if (args != 8) return; playerNum = cliPlayerList_lookupPlayer(pl, name); if (playerNum == -1) { for (playerNum = pl->sortEnd; playerNum < pl->maxPlayers; ++playerNum) { if (pl->players[playerNum].state == cliPlayer_noPlayer) break; } expandPlayers(pl, playerNum); } p = &pl->players[playerNum]; switch(f3) { case '!': p->state = cliPlayer_looking; break; case 'X': p->state = cliPlayer_closed; break; default: p->state = cliPlayer_open; break; } str_copyChars(&p->name, name); str_copyChars(&p->rank, rank); str_copyChars(&p->idleTime, idle); if (strcmp(ob, "--")) p->gameOb = atoi(ob); else p->gameOb = -1; if (strcmp(play, "--")) { p->gameIn = atoi(play); p->gameOb = -1; } else p->gameIn = -1; redrawLine(pl, playerNum); } int cliPlayerList_lookupPlayer(CliPlayerList *pl, const char *name) { int i; for (i = 0; i < pl->maxPlayers; ++i) { if (pl->players[i].state != cliPlayer_noPlayer) { if (!strcmp(str_chars(&pl->players[i].name), name)) return(i); } } return(-1); } void cliPlayerList_disconnected(CliPlayerList *pl, const char *buf) { char name[50]; int args, playerNum; args = sscanf(buf, "{%s ", name); assert(args == 1); playerNum = cliPlayerList_lookupPlayer(pl, name); if (playerNum >= 0) { pl->players[playerNum].state = cliPlayer_noPlayer; while ((pl->sortEnd > 0) && (pl->players[pl->sortEnd - 1].state == cliPlayer_noPlayer)) --pl->sortEnd; if (pl->win) { butList_changeLine(pl->list, playerNum, ""); if (pl->players[playerNum].but) { but_destroy(pl->players[playerNum].but); pl->players[playerNum].but = NULL; } } } } void cliPlayerList_connected(CliPlayerList *pl, const char *buf) { char name[50], rank[50]; int args, i, playerNum; CliPlayer *p; args = sscanf(buf, "{%s [ %[^]]", name, rank); if (args != 2) { if (!pl->elfBugReported) { pl->elfBugReported = TRUE; cgoban_createMsgWindow(pl->data->cg, "Cgoban Error", msg_gameBadElf); } return; } assert(args == 2); for (i = strlen(rank); i && (rank[i - 1] == ' '); --i); rank[i] = '\0'; playerNum = cliPlayerList_lookupPlayer(pl, name); if (playerNum == -1) { for (playerNum = pl->sortEnd; playerNum < pl->maxPlayers; ++playerNum) { if (pl->players[playerNum].state == cliPlayer_noPlayer) break; } expandPlayers(pl, playerNum); p = &pl->players[playerNum]; p->state = cliPlayer_unknown; str_copyChars(&p->name, name); str_copyChars(&p->rank, rank); str_copyChars(&p->idleTime, ""); p->gameIn = -1; p->gameOb = -1; redrawLine(pl, playerNum); } } static ButOut reload(But *but) { CliPlayerList *pl = but_packet(but); assert(MAGIC(pl)); cliConn_send(&pl->data->conn, "who\n"); return(0); } void cliPlayerList_sort(CliPlayerList *pl) { Str listEl; int i, physFontH, bw; ButEnv *env; qsort(pl->players, pl->maxPlayers, sizeof(CliPlayer), cmpPlayers); for (pl->sortEnd = 0; ((pl->sortEnd < pl->maxPlayers) && (pl->players[pl->sortEnd].state != cliPlayer_noPlayer)); ++pl->sortEnd); if (pl->win) { str_init(&listEl); env = pl->data->cg->env; physFontH = butEnv_fontH(env, 0); bw = butEnv_stdBw(env); for (i = 0; i < pl->maxPlayers; ++i) { if (pl->players[i].state == cliPlayer_noPlayer) break; getListEl(pl, i, &listEl); butList_changeLine(pl->list, i, str_chars(&listEl)); if (pl->players[i].but != NULL) { but_resize(pl->players[i].but, bw + physFontH * (pl->players[i].matchBut ? 7 : 11), bw + physFontH * i, physFontH * (pl->players[i].matchBut ? 2 : 3), physFontH); } } if (i == 0) i = 1; butList_setLen(pl->list, i); butCan_resizeWin(pl->swin->win, 0, i * butEnv_fontH(pl->data->cg->env, 0) + butEnv_stdBw(pl->data->cg->env) * 2, TRUE); str_deinit(&listEl); } } static int cmpPlayers(const void *a, const void *b) { const CliPlayer *pa = a; const CliPlayer *pb = b; int rankA, rankB; CliPlayerState stateA, stateB; if (pa->state == cliPlayer_noPlayer) return(1); else if (pb->state == cliPlayer_noPlayer) return(-1); if (pa->sort == cliPlayerSort_open) { stateA = pa->state; if (pa->gameIn >= 0) stateA = cliPlayer_closed; stateB = pb->state; if (pb->gameIn >= 0) stateB = cliPlayer_closed; if (stateA != stateB) return(stateB - stateA); } if (pa->sort >= cliPlayerSort_rank) { rankA = getRankNum(&pa->rank); rankB = getRankNum(&pb->rank); if (rankA != rankB) return(rankB - rankA); } return(strcasecmp(str_chars(&pa->name), str_chars(&pb->name))); } static int getRankNum(const Str *rank) { char class; int val; if (!strncmp(str_chars(rank), "NR", 2) || !strncmp(str_chars(rank), "?" "?" "?", 3)) /* Avoid the trigraphs. */ return(-100); class = str_chars(rank)[str_len(rank) - 1]; if (class == '*') { class = str_chars(rank)[str_len(rank) - 2]; } val = atoi(str_chars(rank)); if (class == 'k') return(-val); else if (class == 'd') return(val); else { assert(class == 'p'); return(val + 100); } } static ButOut newSort(But *but, int newSortType) { CliPlayerList *pl; int i; pl = but_packet(but); assert(MAGIC(pl)); clp_setInt(pl->data->cg->clp, "client.players.sort", newSortType); pl->sort = (CliPlayerSort)newSortType; for (i = 0; i < pl->maxPlayers; ++i) { pl->players[i].sort = (CliPlayerSort)newSortType; } cliPlayerList_sort(pl); return(0); } static ButOut listPressed(But *but, int line) { CliPlayerList *pl; pl = but_packet(but); assert(MAGIC(pl)); assert((line >= 0) && (line < pl->maxPlayers)); if (pl->players[line].state == cliPlayer_noPlayer) return(BUTOUT_ERR); str_print(&pl->data->cmdBuild, "stats %s\n", str_chars(&pl->players[line].name)); cliConn_send(&pl->data->conn, str_chars(&pl->data->cmdBuild)); return(0); } void cliPlayerList_playerInGame(CliPlayerList *pl, const char *player, int gameNum) { int playerNum; playerNum = cliPlayerList_lookupPlayer(pl, player); if (playerNum >= 0) { if (pl->players[playerNum].gameIn != gameNum) { pl->players[playerNum].gameIn = gameNum; pl->players[playerNum].gameOb = -1; if (pl->win) { redrawLine(pl, playerNum); } } } } void cliPlayerList_setState(CliPlayerList *pl, int playerNum, CliPlayerState state) { assert(MAGIC(pl)); assert((playerNum >= 0) && (playerNum < pl->maxPlayers)); assert(pl->players[playerNum].state != cliPlayer_noPlayer); pl->players[playerNum].state = state; redrawLine(pl, playerNum); } static void redrawLine(CliPlayerList *pl, int playerNum) { CliPlayer *p; ButEnv *env; int bw, lastPlayer, physFontH; char state[2]; assert(MAGIC(pl)); if (pl->win) { p = &pl->players[playerNum]; getListEl(pl, playerNum, &pl->data->cmdBuild); if (p->state == cliPlayer_noPlayer) { if (p->but) { but_destroy(p->but); p->but = NULL; } if (playerNum == butList_len(pl->list) - 1) { for (lastPlayer = playerNum - 1; ((lastPlayer >= 0) && (pl->players[lastPlayer].state == cliPlayer_noPlayer)); --lastPlayer); butList_setLen(pl->list, lastPlayer + 1); butCan_resizeWin(pl->swin->win, 0, (lastPlayer + 1) * butEnv_fontH(pl->data->cg->env, 0) + butEnv_stdBw(pl->data->cg->env) * 2, TRUE); } } else { if (playerNum >= butList_len(pl->list)) { butList_setLen(pl->list, playerNum + 1); butCan_resizeWin(pl->swin->win, 0, butList_len(pl->list) * butEnv_fontH(pl->data->cg->env, 0) + butEnv_stdBw(pl->data->cg->env) * 2, TRUE); } if (p->but) { if (!((p->matchBut && (p->gameIn == -1) && (p->state != cliPlayer_closed)) || (!p->matchBut && (p->gameIn != -1)))) { but_destroy(p->but); p->but = NULL; } } if (p->but == NULL) { if (p->gameIn != -1) { char label[10]; sprintf(label, "P%d", p->gameIn); p->but = butCt_create(observePressed, pl, pl->swin->win, 3, BUT_DRAWABLE|BUT_PRESSABLE, label); p->matchBut = FALSE; } else if (p->state != cliPlayer_closed) { state[0] = "?XO! "[p->state]; state[1] = '\0'; p->but = butCt_create(matchPressed, pl, pl->swin->win, 3, BUT_DRAWABLE|BUT_PRESSABLE, state); p->matchBut = TRUE; } if (p->but != NULL) { env = pl->data->cg->env; physFontH = butEnv_fontH(env, 0); bw = butEnv_stdBw(env); but_resize(p->but, bw + physFontH * (p->matchBut ? 7 : 11), bw + physFontH * playerNum, physFontH * (p->matchBut ? 2 : 3), physFontH); } } else { if (p->matchBut) { state[0] = "?XO! "[p->state]; state[1] = '\0'; butCt_setText(p->but, state); } } } butList_changeLine(pl->list, playerNum, str_chars(&pl->data->cmdBuild)); } } static ButOut matchPressed(But *but) { CliPlayerList *pl = but_packet(but); int playerNum, oppRank, myRank; CliPlayer *p, *me; const char *rankStr; assert(MAGIC(pl)); /* * If there were lots of buttons, hashing the but *'s or something would * be a good idea. But for now, a linear search is probably OK. */ for (playerNum = 0; pl->players[playerNum].but != but; ++playerNum) { assert(playerNum < pl->maxPlayers); } p = &pl->players[playerNum]; for (playerNum = 0; (pl->players[playerNum].state == cliPlayer_noPlayer) || strcmp(str_chars(&pl->players[playerNum].name), str_chars(&pl->data->userName)); ++playerNum) { if (playerNum + 1 >= pl->maxPlayers) { /* We didn't find ourselves in the list. Ouch. */ cgoban_createMsgWindow(pl->data->cg, "Cgoban Error", msg_youDontExist); return(BUTOUT_ERR); } } me = &pl->players[playerNum]; if (isdigit(str_chars(&p->rank)[0]) && isdigit(str_chars(&me->rank)[0])) { oppRank = atoi(str_chars(&p->rank)); rankStr = str_chars(&p->rank); if ((rankStr[str_len(&p->rank) - 1] == 'k') || (rankStr[str_len(&p->rank) - 2] == 'k')) oppRank = -oppRank; myRank = atoi(str_chars(&me->rank)); rankStr = str_chars(&me->rank); if ((rankStr[str_len(&me->rank) - 1] == 'k') || (rankStr[str_len(&me->rank) - 2] == 'k')) myRank = -myRank; } else oppRank = myRank = 0; cliMatch_create(pl->data, str_chars(&p->name), &pl->match, myRank - oppRank); return(0); } static ButOut observePressed(But *but) { CliPlayerList *pl = but_packet(but); CliPlayer *p; int playerNum; assert(MAGIC(pl)); for (playerNum = 0; pl->players[playerNum].but != but; ++playerNum) { assert(playerNum < pl->maxPlayers); } p = &pl->players[playerNum]; if (p->gameIn != -1) { pl->data->observeGame(pl->data->obPacket, p->gameIn); } return(0); } extern const char *cliPlayerList_getRank(CliPlayerList *pl, const char *name) { int i; for (i = 0; i < pl->maxPlayers; ++i) { if (pl->players[i].state != cliPlayer_noPlayer) { if (!strcmp(name, str_chars(&pl->players[i].name))) return(str_chars(&pl->players[i].rank)); } } return(NULL); } cgoban-1.9.14/src/client/server.c0000664000671000067100000000131307043224471012244 /* * src/cliServer.c, part of Complete Goban (game program) * Copyright (C) 1995-1996 William Shubert * See "configure.h.in" for more copyright information. */ #include #include "server.h" /********************************************************************** * Functions **********************************************************************/ /* * It seems that gcc has an error. If no _functions_ in a library file are * called, then the file is not linked in. Since I want "cliServer_names[]" * to get pulled in, I need to have a function here. :-( * This file no longer has *any* data in it, so I could just scrap this, but * what the hell. */ void cliServer_create(void) { } cgoban-1.9.14/src/client/setup.c0000664000671000067100000000776507043224471012117 /* * src/cliSetup.c, part of Complete Goban (game program) * Copyright (C) 1995 William Shubert * See "configure.h.in" for more copyright information. */ #include #include #include #include #include #include #include "../cgoban.h" #include "setup.h" #include "../msg.h" #include "login.h" /********************************************************************** * Forward Declarations **********************************************************************/ static ButOut loginDestroyed(void *packet); static ButOut cancelPressed(But *but); static ButOut okPressed(But *but); static ButOut newUser(But *but, const char *user); static ButOut newPassword(But *but, const char *pass); /********************************************************************** * Functions **********************************************************************/ CliSetup *cliSetup_create(Cgoban *cg, int serverNum) { CliSetup *c; Str title; AbutMsgTin tins[2]; AbutMsgOpt buttons[3]; /* Necessary reference to server.c. See "server.h" for an explanation. */ cliServer_create(); assert(MAGIC(cg)); str_init(&title); c = wms_malloc(sizeof(CliSetup)); MAGIC_SET(c); c->cd = cliData_create(cg, serverNum, NULL, NULL); c->userClp = clp_lookup(cg->clp, "client.username"); c->passwordClp = clp_lookup(cg->clp, "client.password"); c->serverNum = serverNum; str_print(&title, "%s Setup", c->cd->serverName); tins[0].name = msg_usernameColon; tins[0].def = clpEntry_getStrNum(c->userClp, serverNum); tins[0].callback = newUser; tins[0].flags = 0; tins[1].name = msg_passwordColon; tins[1].def = clpEntry_getStrNum(c->passwordClp, serverNum); tins[1].callback = newPassword; tins[1].flags = abutMsgTinFlags_secret; buttons[0].name = msg_help; buttons[0].callback = cgoban_createHelpWindow; buttons[0].packet = &help_cliSetup; buttons[0].keyEq = cg_help; buttons[1].name = msg_cancel; buttons[1].callback = cancelPressed; buttons[1].packet = c; buttons[1].keyEq = NULL; buttons[2].name = msg_ok; buttons[2].callback = okPressed; buttons[2].packet = c; buttons[2].keyEq = cg_return; c->login = abutMsg_winOptInCreate(cg->abut, str_chars(&title), msg_loginDesc[c->cd->server], loginDestroyed, c, 3, buttons, 2, tins); str_deinit(&title); return(c); } static ButOut newUser(But *but, const char *user) { CliSetup *setup = but_packet(but); assert(MAGIC(setup)); but_setFlags(setup->login->tins[1], BUT_KEYED); return(0); } static ButOut newPassword(But *but, const char *pass) { CliSetup *setup = but_packet(but); assert(MAGIC(setup)); return(okPressed(setup->login->buts[2])); } void cliSetup_destroy(CliSetup *c) { assert(MAGIC(c)); if (c->login) { abutMsg_destroy(c->login, FALSE); c->login = NULL; } cliData_decRef(c->cd); MAGIC_UNSET(c); wms_free(c); } static ButOut loginDestroyed(void *packet) { CliSetup *c = packet; assert(MAGIC(c)); c->login = NULL; cliSetup_destroy(c); return(0); } static ButOut cancelPressed(But *but) { CliSetup *c = but_packet(but); assert(MAGIC(c)); butWin_destroy(c->login->win); return(0); } static ButOut okPressed(But *but) { CliSetup *c = but_packet(but); ButOut result = 0; const char *user, *pass; assert(MAGIC(c)); user = butTextin_get(abutMsg_tin(c->login, 0)); pass = butTextin_get(abutMsg_tin(c->login, 1)); clpEntry_setStrNum(c->userClp, user, c->serverNum); clpEntry_setStrNum(c->passwordClp, pass, c->serverNum); str_copyChars(&c->cd->userName, user); if (!cliLogin_create(c->cd, user, pass)) result = BUTOUT_ERR; cliSetup_destroy(c); return(result); } void cliSetup_createGmp(Cgoban *cg, int serverNum, const char *username, const char *password, const CliActions *actions, void *packet) { CliData *data; data = cliData_create(cg, serverNum, actions, packet); str_copyChars(&data->userName, username); cliLogin_create(data, username, password); }