diff -Naur orig/xmotd-1.17.2/atom.c xmotd-1.17.2-arr1/atom.c --- orig/xmotd-1.17.2/atom.c Tue Nov 23 00:48:33 1999 +++ xmotd-1.17.2-arr1/atom.c Fri Apr 25 17:39:00 2003 @@ -58,6 +58,10 @@ static char buffer[256]; pw = getpwuid(getuid()); + /* Special atom name 'none' makes us not use atoms */ + if(!strncmp("none",atomname,4)) + return False; + /* create an unique atom */ sprintf(buffer, "xmotd-%s.%s", atomname, pw->pw_name); diff -Naur orig/xmotd-1.17.2/main.h xmotd-1.17.2-arr1/main.h --- orig/xmotd-1.17.2/main.h Tue Nov 23 22:59:33 1999 +++ xmotd-1.17.2-arr1/main.h Fri Apr 25 17:39:00 2003 @@ -1,33 +1,37 @@ /* $Id: main.h,v 1.5 1999/11/23 23:01:14 elf Exp $ */ typedef struct _resources { - int always; /* flag; if set, ignore .xmotd timestamp */ - int pto; /* popdown time-out value in seconds*/ - int usedomains; /* do timestamping with .xmotd.domain-name */ - int showfilename; /* display the name of the file being - viewed next to the date & time */ - int paranoid; /* used with -warnfile; always display - the warning message */ - - float periodic; /* if set, xmotd will periodically - check the motd files to see if they - have changed, and display them - accordingly. The value indicates - the sleep period in hours (decimals - represent minutes)*/ - - int tail; /* flag; if scroll text widget to end */ - - String warnfile; /* path to a filename containing a - standard warning message that is - displayed whenever a motd is displayed*/ - - String logo; /* path to logo (xbm) */ - - String stampfile; /* name of the timestamp filename */ - - String atomname; /* we can force multiple xmotds to run - by giving them unique names */ - + int always; /* flag; if set, ignore .xmotd timestamp */ + int pto; /* popdown time-out value in seconds*/ + int usedomains; /* do timestamping with .xmotd.domain-name */ + int showfilename; /* display the name of the file being + viewed next to the date & time */ + int paranoid; /* used with -warnfile; always display + the warning message */ + + float periodic; /* if set, xmotd will periodically + check the motd files to see if they + have changed, and display them + accordingly. The value indicates + the sleep period in hours (decimals + represent minutes)*/ + + int tail; /* flag; if scroll text widget to end */ + + String warnfile; /* path to a filename containing a + standard warning message that is + displayed whenever a motd is displayed*/ + + int fork; /* fork policy */ + + String logo; /* path to logo (xbm) */ + + String stampfile; /* name of the timestamp filename */ + + String atomname; /* we can force multiple xmotds to run + by giving them unique names */ + + String locfile; /* File to check for readability to + determine if the user has logged-off */ #ifdef HAVE_HTML String browser; /* path to web-browser */ #endif diff -Naur orig/xmotd-1.17.2/maindefs.h xmotd-1.17.2-arr1/maindefs.h --- orig/xmotd-1.17.2/maindefs.h Fri Feb 14 00:35:24 2003 +++ xmotd-1.17.2-arr1/maindefs.h Fri Apr 25 17:39:00 2003 @@ -13,5 +13,5 @@ #define BROWSER "/usr/local/bin/netscape" #define ATOM "xmotd" - +#define LOCFILE "/dev/console" diff -Naur orig/xmotd-1.17.2/usage.c xmotd-1.17.2-arr1/usage.c --- orig/xmotd-1.17.2/usage.c Fri Feb 14 00:34:16 2003 +++ xmotd-1.17.2-arr1/usage.c Fri Apr 25 17:39:00 2003 @@ -64,6 +64,8 @@ fprintf(stderr, " -usedomains append domain-names to timestamp\n"); fprintf(stderr, " -wakeup #.# every # hours, check motd(s) for changes\n"); + fprintf(stderr, " -locfile file \"logout\" file to check for readability instead of /dev/console\n"); + fprintf(stderr, " -fork Fork policy: 0=no fork, 1=fork only after running once and in \"wakeup\" mode, 2=fork immediately if in \"wakeup\" mode (default), 3=fork immediately.\n"); fprintf(stderr, " -warnfile file show the warning message in \"file\" before motd(s)\n"); fprintf(stderr, " -atom name register xmotd with \"name\"\n"); fprintf(stderr, " -tail scroll & display end of motd file(s)\n"); diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/GNU xmotd-1.17.2-arr1/xmotd-1.17.2/GNU --- orig/xmotd-1.17.2/xmotd-1.17.2/GNU Sun Jun 1 23:09:11 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/GNU Thu Jan 1 00:00:00 1970 @@ -1,339 +0,0 @@ - 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 - - 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. diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/Imakefile xmotd-1.17.2-arr1/xmotd-1.17.2/Imakefile --- orig/xmotd-1.17.2/xmotd-1.17.2/Imakefile Tue Apr 15 22:27:01 2003 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/Imakefile Thu Jan 1 00:00:00 1970 @@ -1,138 +0,0 @@ -XCOMM BUILD INSTRUCTIONS (ALSO SEE NOTES): -XCOMM ------------------- -XCOMM Step 1. xmkmf -a -XCOMM Step 2. make all - -XCOMM ----- -XCOMM NOTES -XCOMM ----- -XCOMM If using /usr/openwin/bin/xmkmf, replace step 1 with: -XCOMM 1. xmkmf; make makefiles; make includes; make depend -XCOMM -XCOMM If building with Motif and HTML replace step 2 with: -XCOMM 2. make all EXTRA_DEFINES="-DMOTIF -DHAVE_HTML" -XCOMM - -XCOMM CUSTOMIZING INSTRUCTIONS: To customize xmotd, uncomment -XCOMM the "#define" statments appropriately. - -XCOMM If you wish to use an HTML widget instead of an ASCII text widget, -XCOMM then uncomment the following line: -XCOMM #define HAVE_HTML - -XCOMM If you wish to use colour xpm pixmaps for the icon and have the -XCOMM Xpm library installed, then uncomment the following line: -XCOMM #define HAVE_XPM - -XCOMM If you wish to build with Motif, then uncomment the following line: -XCOMM #define MOTIF - -XCOMM If compiling MOTIF under SOLARIS 2.x (or CDE on other platforms -XCOMM (untested)), uncomment the following line: -XCOMM #define SOLARIS2 - -#ifdef MOTIF -#ifdef SOLARIS2 - -XCOMM These are set if you are building on Solaris 2.x/CDE. You may -XCOMM have to set LD_LIBRARY_PATH when you run it (use a shell -XCOMM wrapper around xmotd). - - MOTIF_SOLARIS_LD_FLAG = -R/usr/dt/lib - MOTIF_LIB_DIR = -L/usr/dt/lib - MOTIF_INCLUDE = -I/usr/dt/include -#else - -XCOMM On other systems, if the Motif libs & includes are NOT installed -XCOMM in /usr/lib and /usr/include then uncomment and fill-in the following -XCOMM paths appropriately. - -XCOMM MOTIF_LIB_DIR = -L -XCOMM MOTIF_INCLUDE = -I - -#endif -#endif - -XCOMM Don't touch anything past this point unless you know what you're doing. -XCOMM --x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x-- - -XCOMM CC = purify gcc - - SRCS = main.c xmotd.c changed.c textmode.c usage.c browser.c logo.c atom.c - OBJS = main.o xmotd.o changed.o textmode.o usage.o browser.o logo.o atom.o - INCLS = maindefs.h appdefs.h main.h - - CDEBUGFLAGS = -g - MANSUFFIX = 8 - - MANIFEST = README GNU ACKNOWLEDGEMENTS Imakefile browser\ - Makefile XMotd XMotd_motif xmotd.8 xlogo.bm xlogo.xpm\ - $(SRCS) $(INCLS) - -XCOMM No space after the equals-sign - VER =1.17.2 - LITE =1.17.2 - -.PRECIOUS: distrib - -#ifdef HPArchitecture - CCOPTIONS = -Aa -D_HPUX_SOURCE -#endif - -#ifdef HAVE_XPM - XPM_LIB = -lXpm - XPM_DEFINE = -DHAVE_XPM -#endif - -#ifdef HAVE_HTML - HTML_DEFINE = -DHAVE_HTML - HTML_SUB_DIR = ./libhtmlw - HTML_DEP_LIB = htmlw - HTML_LIB_DIR = -L$(HTML_SUB_DIR) - HTML_INCLUDE = -I$(HTML_SUB_DIR) - HTML_LIB = -lhtmlw - - MAKELIST = $(HTML_SUB_DIR) - -#endif - -#ifdef MOTIF - MOTIF_DEFINE = -DMOTIF - MOTIF_LIB = -lXm - LD_LIBRARY_PATH = $(MOTIF_SOLARIS_LD_FLAG) -#endif - - EXTRA_DEFINES = $(XPM_DEFINE) $(HTML_DEFINE) $(MOTIF_DEFINE) - MOTD_LIBRARIES = $(XPM_LIB) $(HTML_LIB_DIR) $(HTML_LIB) $(MOTIF_LIB_DIR) $(MOTIF_LIB) - EXTRA_INCLUDES = $(HTML_INCLUDE) $(MOTIF_INCLUDE) - -XCOMM This is what the final link looks like: -XCOMM LOCAL_LIBRARIES = -lXm -lXmu -lXt -lXext -lX11 -lsocket -lgen -lucb -L/usr/ucblib -R/usr/ucblib -R/usr/X11R6/lib - - LOCAL_LIBRARIES = $(MOTD_LIBRARIES) XawClientLibs - DEPLIBS = $(HTML_DEP_LIB) - -ComplexProgramTarget(xmotd) -InstallAppDefaults(XMotd) - -#ifdef HAVE_HTML -MakefileSubdirs($(HTML_SUB_DIR)) - -NormalLibraryObjectRule() - NamedTargetSubdirs(htmlw, $(HTML_SUB_DIR), , , ) -#endif - -distrib: $(MANIFEST) - ./distrib - -lite: $(MANIFEST) - ./distrib lite - -XCOMM Generate man-page -man: xmotd.8 - rm -f xmotd-man.ps; - troff -mansun xmotd.8 |dpost >xmotd-mansun.ps - -XCOMM This target builds the java distribution, Wed Sep 26 19:24:51 2001 -java-distrib: - tar zcvf jmotd-0.55.tar.gz jmotd/README jmotd/logo.gif jmotd/xmotd* jmotd/HistoryItem* diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/Makefile xmotd-1.17.2-arr1/xmotd-1.17.2/Makefile --- orig/xmotd-1.17.2/xmotd-1.17.2/Makefile Tue Apr 15 22:27:14 2003 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/Makefile Thu Jan 1 00:00:00 1970 @@ -1,619 +0,0 @@ -# Makefile generated by imake - do not edit! -# $XConsortium: imake.c /main/90 1996/11/13 14:43:23 lehors $ - -# ---------------------------------------------------------------------- -# Makefile generated from "Imake.tmpl" and -# $XConsortium: Imake.tmpl /main/243 1996/11/13 14:42:56 lehors $ -# - -all:: - -.SUFFIXES: .i - -# $XConsortium: Imake.cf /main/26 1996/09/28 16:05:09 rws $ - -# ----------------------------------------------------------------------- -# site-specific configuration parameters that need to come before -# the platform-specific parameters - edit site.def to change - -# site: $XConsortium: site.def /main/revisionist/4 1996/12/31 08:02:07 kaleb $ - -# ---------------------------------------------------------------------- -# platform-specific configuration parameters - edit sun.cf to change - -# platform: $XConsortium: sun.cf /main/160 1996/12/26 08:52:18 kaleb $ - -# operating system: SunOS (5.5.0) - -# $XConsortium: svr4.cf /main/16 1996/09/28 16:13:41 rws $ - -# $XConsortium: sv4Lib.rules /main/18 1996/09/28 16:13:29 rws $ - -# ---------------------------------------------------------------------- -# site-specific configuration parameters that go after -# the platform-specific parameters - edit site.def to change - -# site: $XConsortium: site.def /main/revisionist/4 1996/12/31 08:02:07 kaleb $ - -# --------------------------------------------------------------------- -# Imake rules for building libraries, programs, scripts, and data files -# rules: $XConsortium: Imake.rules /main/217 1996/12/05 09:48:26 kaleb $ - - PATHSEP = / - SHELL = /bin/sh - - TOP = . - CURRENT_DIR = . - - IMAKE = imake - DEPEND = makedepend - MKDIRHIER = mkdirhier - EXPORTLISTGEN = exportlistgen - CONFIGSRC = $(TOP)/config - IMAKESRC = $(CONFIGSRC)/imake - DEPENDSRC = $(CONFIGSRC)/makedepend - - INCROOT = /usr/X11/include - USRLIBDIR = /usr/X11/lib - SHLIBDIR = /usr/X11/lib - LINTLIBDIR = $(USRLIBDIR)/lint - MANPATH = /usr/X11/man - MANSOURCEPATH = $(MANPATH)/man - MANDIR = $(MANSOURCEPATH)1 - LIBMANDIR = $(MANSOURCEPATH)3 - FILEMANDIR = $(MANSOURCEPATH)$(FILEMANSUFFIX) - - AR = /usr/ccs/bin/ar cq - BOOTSTRAPCFLAGS = - CC = gcc -fpcc-struct-return - AS = /usr/ccs/bin/as - - COMPRESS = compress - GZIP = gzip - CPP = /usr/ccs/lib/cpp $(STD_CPP_DEFINES) - PREPROCESSCMD = gcc -fpcc-struct-return -E $(STD_CPP_DEFINES) - INSTALL = /usr/ucb/install - INSTALLFLAGS = -c - LD = /usr/ccs/bin/ld - LEX = /usr/ccs/bin/lex - LEXLIB = -ll - YACC = /usr/ccs/bin/yacc - CCYACC = /usr/ccs/bin/yacc - LINT = lint - LINTLIBFLAG = -o - LINTOPTS = -bh - LN = ln -s - MAKE = /usr/ccs/bin/make - MV = mv - CP = cp - - RM = rm -f - MANSUFFIX = 1x - LIBMANSUFFIX = 3x - FILEMANSUFFIX = 4 - TROFF = psroff - NROFF = nroff - MSMACROS = -ms - MANMACROS = -man - TBL = tbl - EQN = eqn - NEQN = neqn - COL = col - - DVIPS = dvips - LATEX = latex - - STD_INCLUDES = - STD_CPP_DEFINES = -Dsun -DSVR4 $(PROJECT_DEFINES) - STD_DEFINES = -Dsun -DSVR4 $(PROJECT_DEFINES) - EXTRA_LOAD_FLAGS = - EXTRA_LDOPTIONS = - EXTRA_LIBRARIES = -lsocket -lnsl - TAGS = ctags - - SHAREDCODEDEF = - SHLIBDEF = - - SHLIBLDFLAGS = -G -z text - - PICFLAGS = -fpic - - CXXPICFLAGS = -K PIC - - PROTO_DEFINES = - - INSTPGMFLAGS = - - INSTBINFLAGS = -m 0755 - INSTUIDFLAGS = -m 4711 - INSTLIBFLAGS = -m 0644 - INSTINCFLAGS = -m 0444 - INSTMANFLAGS = -m 0444 - INSTDATFLAGS = -m 0444 - INSTKMEMFLAGS = -g sys -m 2711 - - PROJECTROOT = /usr/X11 - - CDEBUGFLAGS = -O2 - CCOPTIONS = - - ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES) - ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES) - CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(ALLDEFINES) - LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES) - LDPRELIB = -L$(USRLIBDIR) - LDPOSTLIB = - LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS) - CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS) - - LDLIBS = $(LDPOSTLIBS) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) - - CCENVSETUP = LD_RUN_PATH=$(USRLIBDIRPATH) - CCLINK = $(CCENVSETUP) $(CC) - - CXXENVSETUP = LD_RUN_PATH=$(USRLIBDIRPATH) - CXXLINK = $(CXXENVSETUP) $(CXX) - - LDSTRIPFLAGS = -x - LDCOMBINEFLAGS = -r - DEPENDFLAGS = - - MACROFILE = sun.cf - RM_CMD = $(RM) - - IMAKE_DEFINES = - - IRULESRC = $(CONFIGDIR) - IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) - - ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/X11.tmpl \ - $(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) \ - $(EXTRA_ICONFIGFILES) - -# $XConsortium: X11.rules /main/2 1996/12/04 10:13:00 swick $ - -# ---------------------------------------------------------------------- -# X Window System Build Parameters and Rules -# $XConsortium: X11.tmpl /main/290 1996/12/27 16:14:21 kaleb $ - -# ----------------------------------------------------------------------- -# X Window System make variables; these need to be coordinated with rules - - XTOP = $(TOP) - BINDIR = /usr/X11/bin - BUILDINCROOT = $(TOP)/exports - BUILDINCDIR = $(BUILDINCROOT)/include - BUILDINCTOP = ../.. - BUILDLIBDIR = $(TOP)/exports/lib - BUILDLIBTOP = ../.. - BUILDBINDIR = $(TOP)/exports/bin - BUILDBINTOP = ../.. - XBUILDINCROOT = $(XTOP)/exports - XBUILDINCDIR = $(XBUILDINCROOT)/include/X11 - XBUILDINCTOP = ../../.. - XBUILDBINDIR = $(XBUILDINCROOT)/bin - INCDIR = $(INCROOT) - ADMDIR = /usr/adm - LIBDIR = $(USRLIBDIR)/X11 - TOP_X_INCLUDES = - - FONTDIR = $(LIBDIR)/fonts - XINITDIR = $(LIBDIR)/xinit - XDMDIR = $(LIBDIR)/xdm - TWMDIR = $(LIBDIR)/twm - XSMDIR = $(LIBDIR)/xsm - NLSDIR = $(LIBDIR)/nls - XLOCALEDIR = $(LIBDIR)/locale - PEXAPIDIR = $(LIBDIR)/PEX - LBXPROXYDIR = $(LIBDIR)/lbxproxy - PROXYMANAGERDIR = $(LIBDIR)/proxymngr - XPRINTDIR = $(LIBDIR) - XAPPLOADDIR = $(LIBDIR)/app-defaults - FONTCFLAGS = -t - - INSTAPPFLAGS = $(INSTDATFLAGS) - - RGB = rgb - FONTC = bdftopcf - MKFONTDIR = mkfontdir - - DOCUTILSRC = $(XTOP)/doc/util - XDOCMACROS = $(DOCUTILSRC)/macros.t - XIDXMACROS = $(DOCUTILSRC)/indexmacros.t - PROGRAMSRC = $(TOP)/programs - LIBSRC = $(XTOP)/lib - FONTSRC = $(XTOP)/fonts - INCLUDESRC = $(BUILDINCROOT)/include - XINCLUDESRC = $(INCLUDESRC)/X11 - SERVERSRC = $(XTOP)/programs/Xserver - CONTRIBSRC = $(XTOP)/../contrib - UNSUPPORTEDSRC = $(XTOP)/unsupported - DOCSRC = $(XTOP)/doc - RGBSRC = $(XTOP)/programs/rgb - BDFTOPCFSRC = $(PROGRAMSRC)/bdftopcf - MKFONTDIRSRC = $(PROGRAMSRC)/mkfontdir - FONTSERVERSRC = $(PROGRAMSRC)/xfs - FONTINCSRC = $(XTOP)/include/fonts - EXTINCSRC = $(XTOP)/include/extensions - TRANSCOMMSRC = $(LIBSRC)/xtrans - TRANS_INCLUDES = -I$(TRANSCOMMSRC) - - XENVLIBDIR = $(USRLIBDIR) - CLIENTENVSETUP = LD_LIBRARY_PATH=$(XENVLIBDIR) - -# $XConsortium: sunLib.tmpl /main/44 1996/12/09 16:34:30 kaleb $ - -ICONV_INBUF_DEFINE = -DICONV_INBUF_CONST=const - -# $XConsortium: sv4Lib.tmpl /main/23 1996/12/04 10:11:01 swick $ - -XMULIBONLY = -lXmu - -REGEXSYSLIB = -lgen -DYNLIBSYSLIB = -ldl - -IAFSYSLIB = - - XLIBSRC = $(LIBSRC)/X11 - -SOXLIBREV = 6.1 -DEPXONLYLIB = -XONLYLIB = -lX11 - -LINTXONLY = $(LINTLIBDIR)/llib-lX11.ln - - XLIBONLY = $(XONLYLIB) - - XEXTLIBSRC = $(LIBSRC)/Xext - -SOXEXTREV = 6.3 -DEPEXTENSIONLIB = -EXTENSIONLIB = -lXext - -LINTEXTENSION = $(LINTLIBDIR)/llib-lXext.ln - -LINTEXTENSIONLIB = $(LINTEXTENSION) - DEPXLIB = $(DEPEXTENSIONLIB) $(DEPXONLYLIB) - XLIB = $(EXTENSIONLIB) $(XONLYLIB) - LINTXLIB = $(LINTXONLYLIB) - - XAUTHSRC = $(LIBSRC)/Xau - -DEPXAUTHLIB = $(USRLIBDIR)/libXau.a -XAUTHLIB = -lXau - -LINTXAUTH = $(LINTLIBDIR)/llib-lXau.ln - - XDMCPLIBSRC = $(LIBSRC)/Xdmcp - -DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a -XDMCPLIB = -lXdmcp - -LINTXDMCP = $(LINTLIBDIR)/llib-lXdmcp.ln - - XMUSRC = $(LIBSRC)/Xmu - -SOXMUREV = 6.0 -DEPXMULIB = -XMULIB = -lXmu - -LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln - - OLDXLIBSRC = $(LIBSRC)/oldX - -SOOLDXREV = 6.0 -DEPOLDXLIB = -OLDXLIB = -loldX - -LINTOLDX = $(LINTLIBDIR)/llib-loldX.ln - - XPLIBSRC = $(LIBSRC)/Xp - -SOXPREV = 6.2 -DEPXPLIB = -XPLIB = -lXp - -LINTXP = $(LINTLIBDIR)/llib-lXp.ln - - TOOLKITSRC = $(LIBSRC)/Xt - -SOXTREV = 6.0 -DEPXTOOLONLYLIB = -XTOOLONLYLIB = -lXt - -LINTXTOOLONLY = $(LINTLIBDIR)/llib-lXt.ln - - DEPXTOOLLIB = $(DEPXTOOLONLYLIB) $(DEPSMLIB) $(DEPICELIB) - XTOOLLIB = $(XTOOLONLYLIB) $(SMLIB) $(ICELIB) - LINTXTOOLLIB = $(LINTXTOOLONLYLIB) - - XALIBSRC = $(LIBSRC)/Xa - -DEPvarLIB = $(USRLIBDIR)/libXa.a -varLIB = -lXa - -LINTvar = $(LINTLIBDIR)/llib-lXa.ln - - AWIDGETSRC = $(LIBSRC)/Xaw - -SOXAWREV = 6.1 -DEPXAWLIB = -XAWLIB = -lXaw - -LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln - - XILIBSRC = $(LIBSRC)/Xi - -SOXINPUTREV = 6.0 -DEPXILIB = -XILIB = -lXi - -LINTXI = $(LINTLIBDIR)/llib-lXi.ln - - XTESTLIBSRC = $(LIBSRC)/Xtst - -SOXTESTREV = 6.1 -DEPXTESTLIB = -XTESTLIB = -lXtst - -LINTXTEST = $(LINTLIBDIR)/llib-lXtst.ln - - PEXLIBSRC = $(LIBSRC)/PEX5 - -SOPEXREV = 6.0 -DEPPEXLIB = -PEXLIB = -lPEX5 - -LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln - - XIELIBSRC = $(LIBSRC)/XIE - -SOXIEREV = 6.0 -DEPXIELIB = -XIELIB = -lXIE - -LINTXIE = $(LINTLIBDIR)/llib-lXIE.ln - - PHIGSLIBSRC = $(LIBSRC)/PHIGS - -DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a -PHIGSLIB = -lphigs - -LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln - -DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a -XBSDLIB = -lXbsd - -LINTXBSD = $(LINTLIBDIR)/llib-lXbsd.ln - - ICESRC = $(LIBSRC)/ICE - -SOICEREV = 6.3 -DEPICELIB = -ICELIB = -lICE - -LINTICE = $(LINTLIBDIR)/llib-lICE.ln - - SMSRC = $(LIBSRC)/SM - -SOSMREV = 6.0 -DEPSMLIB = -SMLIB = -lSM - -LINTSM = $(LINTLIBDIR)/llib-lSM.ln - - XKEYSRC = $(LIBSRC)/Xkey - -SOXKEYREV = 6.0 -DEPXKEYLIB = -XKEYLIB = -lXkey - -LINTXKEY = $(LINTLIBDIR)/llib-lXkey.ln - - FSLIBSRC = $(LIBSRC)/FS - -DEPFSLIB = $(USRLIBDIR)/libFS.a -FSLIB = -lFS - -LINTFS = $(LINTLIBDIR)/llib-lFS.ln - - FONTLIBSRC = $(LIBSRC)/font - -DEPFONTLIB = $(USRLIBDIR)/libfont.a -FONTLIB = -lfont - -LINTFONT = $(LINTLIBDIR)/llib-lfont.ln - - XKBFILELIBSRC = $(LIBSRC)/xkbfile - -DEPXKBFILELIB = $(USRLIBDIR)/libxkbfile.a -XKBFILELIB = -lxkbfile - -LINTXKBFILE = $(LINTLIBDIR)/llib-lxkbfile.ln - - XKBCOMPCMD = xkbcomp - - DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) - - DEPLIBS1 = $(DEPLIBS) - DEPLIBS2 = $(DEPLIBS) - DEPLIBS3 = $(DEPLIBS) - DEPLIBS4 = $(DEPLIBS) - DEPLIBS5 = $(DEPLIBS) - DEPLIBS6 = $(DEPLIBS) - DEPLIBS7 = $(DEPLIBS) - DEPLIBS8 = $(DEPLIBS) - DEPLIBS9 = $(DEPLIBS) - DEPLIBS10 = $(DEPLIBS) - - CONFIGDIR = $(LIBDIR)/config - - USRLIBDIRPATH = $(USRLIBDIR) - LDPRELIBS = -L$(USRLIBDIR) - LDPOSTLIBS = - TOP_INCLUDES = -I$(INCROOT) $(TOP_X_INCLUDES) - PROJECT_DEFINES = - -# ---------------------------------------------------------------------- -# start of Imakefile - -# BUILD INSTRUCTIONS (ALSO SEE NOTES): -# ------------------- -# Step 1. xmkmf -a -# Step 2. make all - -# ----- -# NOTES -# ----- -# If using /usr/openwin/bin/xmkmf, replace step 1 with: -# 1. xmkmf; make makefiles; make includes; make depend -# -# If building with Motif and HTML replace step 2 with: -# 2. make all EXTRA_DEFINES="-DMOTIF -DHAVE_HTML" -# - -# CUSTOMIZING INSTRUCTIONS: To customize xmotd, uncomment -# the "#define" statments appropriately. - -# If you wish to use an HTML widget instead of an ASCII text widget, -# then uncomment the following line: -# #define HAVE_HTML - -# If you wish to use colour xpm pixmaps for the icon and have the -# Xpm library installed, then uncomment the following line: -# #define HAVE_XPM - -# If you wish to build with Motif, then uncomment the following line: -# #define MOTIF - -# If compiling MOTIF under SOLARIS 2.x (or CDE on other platforms -# (untested)), uncomment the following line: -# #define SOLARIS2 - -# Don't touch anything past this point unless you know what you're doing. -# --x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x--x-- - -# CC = purify gcc - - SRCS = main.c xmotd.c changed.c textmode.c usage.c browser.c logo.c atom.c - OBJS = main.o xmotd.o changed.o textmode.o usage.o browser.o logo.o atom.o - INCLS = maindefs.h appdefs.h main.h - - CDEBUGFLAGS = -g - MANSUFFIX = 8 - - MANIFEST = README GNU ACKNOWLEDGEMENTS Imakefile browser\ - Makefile XMotd XMotd_motif xmotd.8 xlogo.bm xlogo.xpm\ - $(SRCS) $(INCLS) - -# No space after the equals-sign - VER =1.17.2 - LITE =1.17.2 - -.PRECIOUS: distrib - - EXTRA_DEFINES = $(XPM_DEFINE) $(HTML_DEFINE) $(MOTIF_DEFINE) - MOTD_LIBRARIES = $(XPM_LIB) $(HTML_LIB_DIR) $(HTML_LIB) $(MOTIF_LIB_DIR) $(MOTIF_LIB) - EXTRA_INCLUDES = $(HTML_INCLUDE) $(MOTIF_INCLUDE) - -# This is what the final link looks like: -# LOCAL_LIBRARIES = -lXm -lXmu -lXt -lXext -lX11 -lsocket -lgen -lucb -L/usr/ucblib -R/usr/ucblib -R/usr/X11R6/lib - - LOCAL_LIBRARIES = $(MOTD_LIBRARIES) $(XAWLIB) $(XMULIBONLY) $(XTOOLLIB) $(XLIB) - DEPLIBS = $(HTML_DEP_LIB) - - PROGRAM = xmotd - -all:: xmotd - -xmotd: $(OBJS) $(DEPLIBS) - $(RM) $@ - $(CCLINK) -o $@ $(LDOPTIONS) $(OBJS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) - -install:: xmotd - @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \ - else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi - $(INSTALL) $(INSTALLFLAGS) $(INSTPGMFLAGS) xmotd $(DESTDIR)$(BINDIR)/xmotd - -install.man:: xmotd.man - @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \ - else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi - $(INSTALL) $(INSTALLFLAGS) $(INSTMANFLAGS) xmotd.man $(DESTDIR)$(MANDIR)/xmotd.$(MANSUFFIX) - -depend:: - $(DEPEND) $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- $(SRCS) - -lint: - $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS) -lint1: - $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS) - -clean:: - $(RM) xmotd - -install:: XMotd.ad - @if [ -d $(DESTDIR)$(XAPPLOADDIR) ]; then set +x; \ - else (set -x; $(MKDIRHIER) $(DESTDIR)$(XAPPLOADDIR)); fi - $(INSTALL) $(INSTALLFLAGS) $(INSTAPPFLAGS) XMotd.ad $(DESTDIR)$(XAPPLOADDIR)/XMotd - -distrib: $(MANIFEST) - ./distrib - -lite: $(MANIFEST) - ./distrib lite - -# Generate man-page -man: xmotd.8 - rm -f xmotd-man.ps; - troff -mansun xmotd.8 |dpost >xmotd-mansun.ps - -# This target builds the java distribution, Wed Sep 26 19:24:51 2001 -java-distrib: - tar zcvf jmotd-0.55.tar.gz jmotd/README jmotd/logo.gif jmotd/xmotd* jmotd/HistoryItem* - -# ---------------------------------------------------------------------- -# common rules for all Makefiles - do not edit - -.c.i: - $(RM) $@ - $(CC) -E $(CFLAGS) $(_NOOP_) $*.c > $@ - -emptyrule:: - -clean:: - $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut "#"* - -Makefile:: - -@if [ -f Makefile ]; then set -x; \ - $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ - else exit 0; fi - $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) - -tags:: - $(TAGS) -w *.[ch] - $(TAGS) -xw *.[ch] > TAGS - -man_keywords:: - catman -M $(DESTDIR)$(MANPATH) -w - -# ---------------------------------------------------------------------- -# empty rules for directories that do not have SUBDIRS - do not edit - -install:: - @echo "install in $(CURRENT_DIR) done" - -install.man:: - @echo "install.man in $(CURRENT_DIR) done" - -install.linkkit:: - @echo "install.linkkit in $(CURRENT_DIR) done" - -Makefiles:: - -includes:: - -depend:: - -# ---------------------------------------------------------------------- -# dependencies generated by makedepend - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/README xmotd-1.17.2-arr1/xmotd-1.17.2/README --- orig/xmotd-1.17.2/xmotd-1.17.2/README Fri Feb 14 18:45:45 2003 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/README Thu Jan 1 00:00:00 1970 @@ -1,159 +0,0 @@ -XMOTD 1.17.1 README http://www.ee.ryerson.ca/~elf/xmotd/ - -February 2003 -Luis Fernandes, -Ryerson University, -Toronto, Canada - -xmotd is a message-of-the-day browser for X11 and -dumb-terminals. - -WHAT'S NEW - -1.17.1 fixes a race-condition that the previous bug-fix introduced. - -In previous versions, if a message was modified while xmotd was -popped-up, the modified message would never be seen by the user. This -release fixes that bug. - -REQUIREMENTS - -xmotd requires, a C compiler and at minimum, X11R5 including Xt (the X -Toolkit) for the resource and command-line parsing functions, and the -Athena widget (Xaw) libraries. Optionally, Xm (the Motif toolkit) -should be installed if you wish to compile the Motif version; the Xpm -library should be installed if you wish to compile-in support for -colour logos. - -The HTML library is not included with the 'lite' distribution. - -BUILDING - -First, unpack the distribution with: - - zcat xmotd-1.17.1.tar.gz | tar xvf - - -A directory called xmotd-1.17.1 will be created; cd into that -directory and to build the default flavour type: - - xmkmf -a; make all - -Note: If your xmkmf does not support the -a option -(e.g. /usr/openwin/bin/xmkmf), type: - - xmkmf; make makefiles; make all - -xmotd can be built in different flavours: - - with the Athena widget library (default), or; - - with Athena & HTML widget, or; - - with the Motif widget library, or; - - with Motif and HTML widget. - -Refer to the commentary in the Imakefile for details on customizing -the build for HTML, Motif and XPM support. - -INSTALLATION - -After the compilation is complete (ignore compilation warnings when -the HTML widget is being compiled) and if you wish to install xmotd -automatically, type: - - make install - -NOTE: that "make install" will replace your app-defaults file (if you -have previously installed xmotd ) with the app-defaults in the -distribution. If you have modified your app-defaults, make a copy -before invoking the install. - -Alternatively, you can manually copy the xmotd binary to the install -directory and the manual-page to the man8 directory. - -PLATFORMS - -It has been sucessfully compiled here at Ryerson under SunOS 4.1.4, -Solaris 2.5.1, 2.6 and 2.8 and GNU/Linux 2.4.18. - -xmotd has also been successfully compiled on the following platforms: - - HP 9000/735 running HP-UX 9.03 (X11R5). - IBM RS/6000 model C10 (PowerPC) running AIX v3.2.5. - Silicon Graphics INDY running Irix 5.3 (X11R5) - Mips/CDC (running EPIX) and PCS/M68030 (running MUNIX/SysV). - -MANIFEST - -This distribution contains the following files: - - README (this file) - ACKNOWLEDGEMENTS (contributors to xmotd) - GNU (Terms of GPL) - Imakefile (X Consortium's gift to humanity) - Makefile (...3 guesses) - XMotd (app-defaults) - XMotd_motif (Motif app-defaults) - xmotd.8 ([nt]roff man-page) - xlogo.bm (default bitmap, the "X"-logo) - xlogo.xpm (default pixmap used w/ xpm support) - *.c, *.h (source) - browser (shell script) - libhtmlw/ (NCSA HTML widget; not in 'lite' version) - - -xmotd has many options. Refer to the man-page for further details on -customizing and more examples showing xmotd in use. You can read the -man-page, without installing it, with the following command: - - nroff -man xmotd.8 | less - -APP-DEFAULTS - -xmotd can be customized via editres. - -Reasonably adequate application defaults are compiled into xmotd so it -is NOT necessary to install the supplied app-defaults file. - -You can also customize the resources with the supplied app-defaults -file, XMotd. The Motif version is called XMotd_motif; rename it XMotd -before installing and comment-out appropriate resources if building -with HTML support. The app-defaults file installs in: - - $ProjectRoot/lib/X11/app-defaults/XMotd - -All resources are available as command-line option equivalents so -xmotd may be customized completely via the command-line. - -COPYRIGHT (xmotd) - -xmotd Copyright 1993 (released as xbanner, no public release) -xmotd Copyright 1994-97, 1999, 2001, 2003 Luis Fernandes - -Permission to use, copy, hack, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and -that both that copyright notice and this permission notice appear in -supporting documentation. - -xmotd IS PRESENTED AS IS, WITHOUT ANY IMPLIED OR WRITTEN WARRANTY. - -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. - -COPYRIGHT (HTML widget) - -libhtmlw is copyright (C) 1993, Board of Trustees of the University of -Illinois. See the file libhtmlw/HTML.c for the complete text of the -NCSA copyright. - -NOTE: THE HTML WIDGET IS NOT DISTRIBUTED IN THE "LITE" VERSION OF THE -xmotd DISTRIBUTION, WHICH IS THEREFORE FULLY COMPLIANT WITH THE GPL. diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/XMotd xmotd-1.17.2-arr1/xmotd-1.17.2/XMotd --- orig/xmotd-1.17.2/xmotd-1.17.2/XMotd Sun Jun 8 20:22:22 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/XMotd Thu Jan 1 00:00:00 1970 @@ -1,60 +0,0 @@ -!XMotd: app-defaults for xmotd 1.15 - -!TITLE -!use a backslash to quote leading spaces in the title -*title.label: \ This is the\nMessage of the Day\n\n - -!BITMAP -!If you have a custom bitmap you wish to display, uncomment the next -!resource and correct the path- and file-name to point to the location -!of your X-bitmap file. N.B.: the bitmap can also be specified with the -!"-bitmaplogo" command-line option. -!*BitmapLogo: /usr/local/site.bm - -!overall-colour -*form.background: lightsteelblue3 - -!Shape the buttons; this is better than the default, crappy, Dr. Seuss -!flat-background buttons. ShapeStyle is ignored, however, if Kaleb's -!3D Athena widgets are installed. -*shapeStyle: oval - -!the text-box that displays the motd -*Text.height: 500 -*Text.width: 680 -*Text*font: -*-times-medium-r-*-*-*-140-* -*Text*scrollVertical: whenNeeded -*Text*scrollHorizontal: whenNeeded -*Text*autoFill: off -*Text*input: False -*Text*background: lightsteelblue1 - -!Additional resource for the title -*title.font: -*-times-bold-i-*-*-*-240-* -*title.width: 500 -*title.borderWidth: 0 -*title.background: lightsteelblue3 - -!Additional resource for the bitmap -*logo.background: lightsteelblue3 -*logo.borderWidth: 0 - -!the horizontal-line -*hline.borderWidth: 0 -*hline.height: 2 -*hline.width: 744 -*hline.background: black -*hline.foreground: black - -!The label that displays the date & filename (below the dismiss button) -*info.font: -*-times-bold-i-*-*-*-140-* -*info.borderWidth: 0 -*info.background: lightsteelblue3 - -!Quit Button -*quit.font: -*-times-bold-r-*-*-*-240-* -*quit.label: Dismiss -*quit*foreground: dodgerblue4 -*quit*background: lightsteelblue3 - - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/XMotd_motif xmotd-1.17.2-arr1/xmotd-1.17.2/XMotd_motif --- orig/xmotd-1.17.2/xmotd-1.17.2/XMotd_motif Sun Jun 8 20:22:36 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/XMotd_motif Thu Jan 1 00:00:00 1970 @@ -1,59 +0,0 @@ -!XMotd: Motif app-defaults for xmotd 1.15 - -!TITLE -!Use a backslash to quote leading spaces in the title -*title*labelString: \ This is the\nMessage of the Day\n\n - -!BITMAP -!If you have a custom bitmap you wish to display, uncomment the next -!resource and correct the path- and file-name to point to the location -!of your X-bitmap file. N.B.: the bitmap can also be specified with the -!"-bitmaplogo" command-line option. -!*BitmapLogo: /usr/local/site.bm - -!overall-colour -*form.background: lightsteelblue3 - -!The text-box that displays the motd -*text.rows: 25 -*text.columns: 80 -*text*fontList: -*-times-medium-r-*-*-*-140-* -*text*wordWrap: False -*text*background: white -*text*borderWidth: 0 -*text*background: lightsteelblue1 - -!Used for the HTML widget -!Uncomment these, and comment-out the corresponding ones above -!*text.width: 680 -!*text.height: 500 -!*text*borderWidth: 1 - -!Additional resource for the title -*title*fontList: -*-times-bold-i-*-*-*-240-* -*title*width: 500 -*title*borderWidth: 0 -*title*background: lightsteelblue3 - -!Resources for the bitmap -*logo*background: lightsteelblue3 -*logo*borderColor: lightsteelblue3 -!The logo has a damned border which the following resource is -!supposed to eliminate. But it doesn't work! -*logo*borderWidth: 0 - -!The horizontal line -*hline.width: 680 -*hline.background: black -*hline.foreground: black - -!The label that displays the date & filename (below the dismiss button) -*info*fontList: -*-times-*-r-*-*-*-140-* -*info*background: lightsteelblue3 - -!Quit Button -*quit.fontList: -*-times-bold-i-*-*-*-240-* -!(unfortunately the "Next Message" string is hard-coded) -*quit.labelString: Dismiss -*quit*foreground: dodgerblue4 -*quit*background: lightsteelblue3 diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/appdefs.h xmotd-1.17.2-arr1/xmotd-1.17.2/appdefs.h --- orig/xmotd-1.17.2/xmotd-1.17.2/appdefs.h Fri Aug 20 23:44:58 1999 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/appdefs.h Thu Jan 1 00:00:00 1970 @@ -1,93 +0,0 @@ -/* $Id: appdefs.h,v 1.3 1999/08/20 23:45:22 elf Exp $ */ - -#ifdef MOTIF - -String fallback_resources[] = { - "*form.foreground: black", - "*form.background: lightsteelblue3", - "*text*fontList: -*-times-bold-r-*-*-*-140-*", - "*text*background: lightsteelblue1", - -#ifdef HAVE_HTML - "*text.width: 680", - "*text.height: 500", - "*text*borderWidth: 1", -#else - "*text.rows: 25", - "*text.columns: 80", - "*text*borderWidth: 0", - "*text*wordWrap: False", -#endif - - "*title*fontList: -*-times-bold-i-*-*-*-240-*", - "*title*width: 500", - "*title*borderWidth: 0", - "*title*background: lightsteelblue3", - "*title*labelString: Message Of The Day\n\n" - - "*logo*background: lightsteelblue3", - "*logo*borderColor: lightsteelblue3", - "*logo*borderWidth: 0", - - "*info*fontList: -*-times-*-r-*-*-*-140-*", - "*info*background: lightsteelblue1", - - "*hline.width: 680", - "*hline.background: black", - - "*quit.fontList: -*-times-bold-i-*-*-*-240-*", - "*quit.labelString: Dismiss", - "*quit*foreground: dodgerblue4", - "*quit*background: lightsteelblue1", - NULL, -}; - -#else - -String fallback_resources[] = { -/* "*shell.geometry: +20+20",*/ - "*form.foreground: black", - "*form.background: lightsteelblue3", - "*shapeStyle: oval", - "*Text*font: -*-times-bold-r-*-*-*-140-*", - "*text*background: lightsteelblue1", - -#ifdef HAVE_HTML - "*Text.width: 680", - "*Text.height: 500", - "*text*borderWidth: 1", -#else - "*Text.height: 500", - "*Text.width: 680", - - "*Text*scrollVertical: whenNeeded", - "*Text*scrollHorizontal: whenNeeded", - "*Text*autoFill: off", - "*Text*input: False", -#endif - - "*title.font: -*-times-bold-i-*-*-*-240-*", - "*title.width: 500", - "*title.borderWidth: 0", - "*title.background: lightsteelblue3", - "*title.label: Message Of The Day\n\n\n", - "*logo.background: lightsteelblue3", - "*logo.borderWidth: 0", - - "*hline.borderWidth: 0", - "*hline.height: 2", - "*hline.width: 700", - "*hline.background: black", - "*hline.foreground: black", - - "*info.font: -*-times-bold-i-*-*-*-120-*", - "*info.borderWidth: 0", - "*info.background: lightsteelblue3", - - "*quit.font: -*-times-bold-r-*-*-*-240-*", - "*quit.label: Dismiss", - "*quit*foreground: dodgerblue4", - "*quit*background: lightsteelblue1", - NULL, -}; -#endif diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/atom.c xmotd-1.17.2-arr1/xmotd-1.17.2/atom.c --- orig/xmotd-1.17.2/xmotd-1.17.2/atom.c Tue Nov 23 00:48:33 1999 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/atom.c Thu Jan 1 00:00:00 1970 @@ -1,81 +0,0 @@ -/*$Id: atom.c,v 1.2 1999/11/23 00:50:14 elf Exp $*/ - -/* - * Copyright 1999 Luis Fernandes - * - * Permission to use, copy, hack, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. This application is presented as is - * without any implied or written warranty. - * - */ -/* - * 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. - * - */ -#include - -#include -#include -#include - -#include -#include - -extern XtAppContext app_con; -extern Widget topLevel; /* the application widget*/ - - -/* To prevent multiple copies of xmotd from running (when run with - -wakeup) for the same user (this usually happens when a user logs - in and out multiple times within the timeout period), we create an - Atom in the server so other copies of xmotd can check it - - returns: True if the atom already exists - False if the atom didn't exist (and was created) -*/ - -Boolean -atomExists(String atomname) -{ - Atom xmotd; - struct passwd *pw; - - static char buffer[256]; - pw = getpwuid(getuid()); - - /* create an unique atom */ - sprintf(buffer, "xmotd-%s.%s", atomname, pw->pw_name); - - /*check if the atom exists*/ - xmotd=XInternAtom(XtDisplay(topLevel), buffer, (Boolean)True); - - /*if the atom doesn't exist*/ - if(xmotd==None){ - /*create it*/ - xmotd=XInternAtom(XtDisplay(topLevel), buffer, (Boolean)False); -/* fprintf(stderr,"Created atom: %s\n", buffer); */ - - return(False); - } - else{ - fprintf(stderr,"xmotd (atomized as %s) is already running-- aborting.\n", - atomname); - return(True); - } - -} /* atomExists */ diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/browser xmotd-1.17.2-arr1/xmotd-1.17.2/browser --- orig/xmotd-1.17.2/xmotd-1.17.2/browser Thu Sep 4 20:09:21 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/browser Thu Jan 1 00:00:00 1970 @@ -1,35 +0,0 @@ -#!/bin/sh -#============================================================================ -# SYNOPSIS -# browser URL -# -# DESCRIPTION -# browser opens a specified URL in an already open browser or launches -# a new browser if none is currently running. -# -# xmotd call browser to open URL then waits for the browser to exit. -# Hence browser MUST return after opening the specified URL. -# -# AUTHOR -# Stuart A. Harvey -#============================================================================ - -URL=$1 -TOOLWAIT=xtoolwait -BROWSER=${BROWSER:-/usr/local/bin/netscape} -REMOTE=-remote - -#---------------------------------------------------------------------------- -# Direct an open browser to the specified URL -# - -${BROWSER} ${REMOTE} "OpenURL(${URL})" -status=$? - -if [ ${status} -ne 0 ]; then - xtoolwait ${BROWSER} ${URL} - status=$? - [ ${status} -ne 0 ] && sleep 3 -fi - -exit ${status} diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/browser.c xmotd-1.17.2-arr1/xmotd-1.17.2/browser.c --- orig/xmotd-1.17.2/xmotd-1.17.2/browser.c Thu Aug 28 20:09:27 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/browser.c Thu Jan 1 00:00:00 1970 @@ -1,75 +0,0 @@ -/* Copyright 1996-97 Stuart A. HarveyStuart A. Harvey - * - * Permission to use, copy, hack, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. This application is presented as is - * without any implied or written warranty. - */ - -/* - * 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. - * - */ -/* browser.c: - * callback procedure to launch a browser (tm) when a hypertext - * anchor is activated. - * $Id: browser.c,v 1.3 1997/08/28 20:09:27 elf Exp $ - */ - -#ifdef HAVE_HTML - -#include -#include "maindefs.h" -#include "libhtmlw/HTML.h" -#include "main.h" - -extern app_res_t app_res; - -void __ExecWebBrowser ( char* href ); - -XtCallbackProc -AnchorCallbackProc( Widget w, caddr_t call_data, caddr_t client_data) -{ - WbAnchorCallbackData *anchor_data = ( WbAnchorCallbackData *) client_data; - __ExecWebBrowser ( anchor_data->href ); - -} - -void -__ExecWebBrowser ( char* href ) -{ - static int browser_pid=0; - char *default_browser=BROWSER; - char *local_browser=BROWSER; - - if ( ! app_res.browser ) { - local_browser=default_browser; - } else { - local_browser=app_res.browser; - } - - browser_pid = fork(); - - if ( browser_pid == 0 ) { /* child process */ - execlp(local_browser,local_browser,href,NULL); - fprintf(stderr,"xmotd: Couldn't exec %s\n", local_browser); - } else { - int status; - (void) wait(&status); - } -} -#endif diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/changed.c xmotd-1.17.2-arr1/xmotd-1.17.2/changed.c --- orig/xmotd-1.17.2/xmotd-1.17.2/changed.c Mon Jun 2 11:28:58 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/changed.c Thu Jan 1 00:00:00 1970 @@ -1,68 +0,0 @@ -/* Copyright 1993-97 Luis Fernandes - * - * Permission to use, copy, hack, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. This application is presented as is - * without any implied or written warranty. - */ - -/* - * 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. - * - */ -/* changed.c: utility function for checking the times of 2 files - * $Id: changed.c,v 1.4 1997/06/02 11:28:58 elf Exp $ - */ -#include -#include -#include -#include -#include - -#include "main.h" - -extern app_res_t app_res; - -/* motdChanged() returns time_t of the motd file: if modification time - * of motd is greater than the modification time of time-stamp file; - * else it returns 0. - * */ - -time_t -motdChanged(char *motd, char *stamp) -{ - struct stat motdstat, tsstat; - - stat(motd, &motdstat); - - if(stat(stamp, &tsstat)) - { - extern int errno; - - if(errno==ENOENT) /* file does not exist if 1st time */ - return(motdstat.st_mtime); - } - - if(motdstat.st_mtime <= tsstat.st_mtime) /*Butch Deal*/ - return((time_t) 0); - - if(!motdstat.st_size && !app_res.always) - return((time_t) 0); - - return(motdstat.st_mtime); -} - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/AnchoredImage.xbm xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/AnchoredImage.xbm --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/AnchoredImage.xbm Sun Jun 1 17:22:02 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/AnchoredImage.xbm Thu Jan 1 00:00:00 1970 @@ -1,8 +0,0 @@ -#define AnchoredImage_width 40 -#define AnchoredImage_height 10 -static char AnchoredImage_bits[] = { - 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, - 0x00, 0x80, 0x07, 0xfc, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xff, 0xff, 0xff, - 0x1f, 0xfc, 0xff, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0xff, 0x0f, 0x00, - 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, - 0x80, 0x01}; diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/DelayedImage.xbm xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/DelayedImage.xbm --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/DelayedImage.xbm Sun Jun 1 17:22:02 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/DelayedImage.xbm Thu Jan 1 00:00:00 1970 @@ -1,16 +0,0 @@ -#define DelayedImage_width 40 -#define DelayedImage_height 30 -static char DelayedImage_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xfc, - 0x01, 0xfe, 0x3f, 0x00, 0xfe, 0x03, 0xfe, 0x3f, 0x00, 0xff, 0x07, 0xfe, - 0x3f, 0x80, 0xff, 0x0f, 0xfe, 0x3f, 0xc0, 0xff, 0x1f, 0xfe, 0x3f, 0xe0, - 0xff, 0x3f, 0xfe, 0x3f, 0xf0, 0xff, 0x7f, 0xfe, 0x3f, 0x00, 0x00, 0x00, - 0xfe, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0xfe, 0x3f, - 0xc0, 0x07, 0x00, 0xfe, 0x3f, 0xf0, 0x1f, 0x00, 0xfe, 0x3f, 0xf8, 0x3f, - 0x00, 0xfe, 0x3f, 0xfc, 0x7f, 0x00, 0xfe, 0x3f, 0xfc, 0x7f, 0x00, 0x00, - 0x00, 0xfe, 0xff, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x00, 0xfe, - 0xff, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x00, - 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, - 0xf8, 0x3f, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/DrawingArea.c xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/DrawingArea.c --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/DrawingArea.c Sun Jun 1 17:22:02 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/DrawingArea.c Thu Jan 1 00:00:00 1970 @@ -1,193 +0,0 @@ -/* - * A minimalistic constraint widget - * - * Sun Sep 12 20:03:49 GMT 1993 Gustaf Neumann - */ - -#ifndef MOTIF - -#include -#include - -/* -#include -#include -#include -*/ - -#include "DrawingAreaP.h" - -/* Private Definitions */ - -static void ClassInitialize(), ClassPartInitialize(), Initialize(), Resize(); -static void ConstraintInitialize(); -static Boolean SetValues(), ConstraintSetValues(); -static XtGeometryResult GeometryManager(), PreferredGeometry(); -static void ChangeManaged(); - -DrawingAreaClassRec drawingAreaClassRec = { - { /* core_class fields */ - /* superclass */ (WidgetClass) &constraintClassRec, - /* class_name */ "DrawingArea", - /* widget_size */ sizeof(DrawingAreaRec), - /* class_initialize */ ClassInitialize, - /* class_part_init */ ClassPartInitialize, - /* class_inited */ FALSE, - /* initialize */ Initialize, - /* initialize_hook */ NULL, - /* realize */ XtInheritRealize, - /* actions */ NULL, - /* num_actions */ 0, - /* resources */ NULL, - /* num_resources */ 0, - /* xrm_class */ NULLQUARK, - /* compress_motion */ TRUE, - /* compress_exposure */ TRUE, - /* compress_enterleave*/ TRUE, - /* visible_interest */ FALSE, - /* destroy */ NULL, - /* resize */ Resize, - /* expose */ XtInheritExpose, - /* set_values */ SetValues, - /* set_values_hook */ NULL, - /* set_values_almost */ XtInheritSetValuesAlmost, - /* get_values_hook */ NULL, - /* accept_focus */ NULL, - /* version */ XtVersion, - /* callback_private */ NULL, - /* tm_table */ NULL, - /* query_geometry */ PreferredGeometry, - /* display_accelerator*/ XtInheritDisplayAccelerator, - /* extension */ NULL - }, - { /* composite_class fields */ - /* geometry_manager */ GeometryManager, - /* change_managed */ NULL, /*ChangeManaged,*/ - /* insert_child */ XtInheritInsertChild, - /* delete_child */ XtInheritDeleteChild, - /* extension */ NULL - }, - { /* constraint_class fields */ - /* subresourses */ NULL, - /* subresource_count */ 0, - /* constraint_size */ 0, - /* initialize */ NULL, /*ConstraintInitialize,*/ - /* destroy */ NULL, - /* set_values */ NULL, /*ConstraintSetValues,*/ - /* extension */ NULL - }, - { /* DrawingArea_class fields */ - /* dummy */ 0 - } -}; - -WidgetClass drawingAreaWidgetClass = (WidgetClass)&drawingAreaClassRec; - -/**************************************************************** - * - * Private Procedures - * - ****************************************************************/ - -static void ClassInitialize() -{ -} - -static void ClassPartInitialize(class) - WidgetClass class; -{ -} - -/* ARGSUSED */ -static void Initialize(request, new, args, num_args) - Widget request, new; - ArgList args; - Cardinal *num_args; -{ -/* - DrawingAreaWidget daw = (DrawingAreaWidget)new; -*/ -} - -static void Resize(w) - Widget w; -{ -/* - DrawingAreaWidget daw = (DrawingAreaWidget)w; - WidgetList children = daw->composite.children; - int num_children = daw->composite.num_children; - Widget *childP; - Position x, y; - Dimension width, height; -*/ -} - - -/* ARGSUSED */ -static XtGeometryResult GeometryManager(w, request, reply) - Widget w; - XtWidgetGeometry *request; - XtWidgetGeometry *reply; /* RETURN */ -{ -/* - Dimension old_width, old_height; - DrawingAreaWidget daw = (DrawingAreaWidget) XtParent(w); - DrawingAreaConstraints DrawingArea = (DrawingAreaConstraints) w->core.constraints; - XtWidgetGeometry allowed; - XtGeometryResult ret_val; -*/ - return(XtGeometryNo); -} - - -/* ARGSUSED */ -static Boolean SetValues(current, request, new, args, num_args) - Widget current, request, new; - ArgList args; - Cardinal *num_args; -{ - return( FALSE ); -} - - -/*ARGSUSED*/ -static Boolean ConstraintSetValues(current, request, new, args, num_args) - Widget current, request, new; - ArgList args; - Cardinal *num_args; -{ -/* - register DrawingAreaConstraints cfc = - (DrawingAreaConstraints) current->core.constraints; - register DrawingAreaConstraints nfc = - (DrawingAreaConstraints) new->core.constraints; - */ - return( FALSE ); -} - -static void ChangeManaged(w) - Widget w; -{ -/* - DrawingAreaWidget daw = (DrawingAreaWidget)w; - DrawingAreaConstraints DrawingArea; - WidgetList children, childP; - int num_children = daw->composite.num_children; - Widget child; -*/ -} - - -static XtGeometryResult PreferredGeometry( widget, request, reply ) - Widget widget; - XtWidgetGeometry *request, *reply; -{ -/* - DrawingAreaWidget w = (DrawingAreaWidget)widget; - */ - return XtGeometryNo; -} - - - -#endif diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/DrawingArea.h xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/DrawingArea.h --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/DrawingArea.h Sun Jun 1 17:22:02 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/DrawingArea.h Thu Jan 1 00:00:00 1970 @@ -1,35 +0,0 @@ -#ifndef _XawDrawingArea_h -#define _XawDrawingArea_h - -/* #include */ -/*********************************************************************** - * - * DrawingArea Widget - * - ***********************************************************************/ - -/* Parameters: - - Name Class RepType Default Value - ---- ----- ------- ------------- - background Background Pixel XtDefaultBackground - border BorderColor Pixel XtDefaultForeground - borderWidth BorderWidth Dimension 1 - defaultDistance Thickness int 4 - destroyCallback Callback Pointer NULL - height Height Dimension computed at realize - mappedWhenManaged MappedWhenManaged Boolean True - sensitive Sensitive Boolean True - width Width Dimension computed at realize - x Position Position 0 - y Position Position 0 - -*/ - - -typedef struct _DrawingAreaClassRec *DrawingAreaWidgetClass; -typedef struct _DrawingAreaRec *DrawingAreaWidget; - -extern WidgetClass drawingAreaWidgetClass; - -#endif /* _XawDrawingArea_h */ diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/DrawingAreaP.h xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/DrawingAreaP.h --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/DrawingAreaP.h Sun Jun 1 17:22:02 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/DrawingAreaP.h Thu Jan 1 00:00:00 1970 @@ -1,45 +0,0 @@ - -/* DrawingArea widget private definitions */ - -#ifndef _XawDrawingAreaP_h -#define _XawDrawingAreaP_h - -#include "DrawingArea.h" -#include - -#define XtInheritLayout ((Boolean (*)())_XtInherit) - -typedef struct { - int dummy; -} DrawingAreaClassPart; - - -typedef struct _DrawingAreaClassRec { - CoreClassPart core_class; - CompositeClassPart composite_class; - ConstraintClassPart constraint_class; - DrawingAreaClassPart drawingArea_class; -} DrawingAreaClassRec; - -extern DrawingAreaClassRec drawingAreaClassRec; - -typedef struct _DrawingAreaPart { - int dummy; -} DrawingAreaPart; - -typedef struct _DrawingAreaRec { - CorePart core; - CompositePart composite; - ConstraintPart constraint; - DrawingAreaPart drawingArea; -} DrawingAreaRec; - -typedef struct _DrawingAreaConstraintsPart { - int dummy; -} DrawingAreaConstraintsPart; - -typedef struct _DrawingAreaConstraintsRec { - int dummy; -} DrawingAreaConstraintsRec, *DrawingAreaConstraints; - -#endif /* _XawDrawingAreaP_h */ diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTML-PSformat.c xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTML-PSformat.c --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTML-PSformat.c Sun Jun 1 17:22:02 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTML-PSformat.c Thu Jan 1 00:00:00 1970 @@ -1,1510 +0,0 @@ -/* HTML-PSformat.c - Module for NCSA's Mosaic software - * - * Purpose: to parse Hypertext widget contents into appropriate PostScript - * - * Author: Ameet A. Raval & Frans van Hoesel - * (aar@gfdl.gov & hoesel@chem.rug.nl). - * send bugreports to hoesel@chem.rug.nl - * - * Institution: for Ameet A. Raval: - * Geophysical Fluid Dynamics Laboratory, - * National Oceanic and Atmospheric Administration, - * U.S. Department of Commerce - * P.O. Box 308 - * Princeton, NJ 08542 - * for Frans van Hoesel: - * Xtreme graphics software - * Herepoortenmolendrift 36 - * 9711 DH Groningen - * The Netherlands - * - * Date: 1 aug 1993 - * Modification: 8 nov 1993 - * o added support for bold/italics courier - * o removed unused or no longer needed stuff - * o fixed the font alignment problem - * 23 nov 1993 - * o added support for horizontal ruler - * o on request of Ameet, added a specific - * line about whome to send bugreports to - * - * Copyright: This work is the product of the United States Government, - * and is precluded from copyright protection. It is hereby - * released into the public domain. - * - * WE MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR - * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED - * WARRANTY. WE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE - * USERS OF THIS SOFTWARE. - * - * pieces of code are taken from xvps by kind - * permission of John Bradley. - */ - -#include - -#include -#include -#include -#include -#include -#include "HTMLP.h" - -/* Fix thanks to robm. */ -#ifdef __alpha -#include -#endif - -#define CR '\015' -#define LF '\012' - -extern int SwapElements(); - -/* the next page sizes are a compromise between letter sized paper - * (215.9 x 279.4 mm) and european standard A4 sized paper (210.0 x 297.0 mm). - * Note that PAGE_WIDTH is not the actual width of the paper - */ -#define TOP_MARGIN (10*72) -#define BOT_MARGIN (0.7*72) -#define LEFT_MARGIN (0.6*72) -#define PAGE_HEIGHT (TOP_MARGIN - BOT_MARGIN) -#define PAGE_WIDTH (8*72) - -#define F_FULLCOLOR 0 -#define F_GREYSCALE 1 -#define F_BWDITHER 2 -#define F_REDUCED 3 - -#define L_PAREN '(' -#define R_PAREN ')' -#define B_SLASH '\\' -#define MAX_ASCII '\177' - -#ifdef _NO_PROTO -# define ARG0(v0) () -# define ARG1(t1,v1) (v1) t1 v1; -# define ARG2(t1,v1,t2,v2) (v1,v2) t1 v1;t2 v2; -# define ARG3(t1,v1,t2,v2,t3,v3) (v1,v2,v3) t1 v1;t2 v2;t3 v3; -# define ARG4(t1,v1,t2,v2,t3,v3,t4,v4) (v1,v2,v3,v4) t1 v1;t2 v2;t3 v3;t4 v4; -# define ARG5(t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) (v1,v2,v3,v4,v5) t1 v1;t2 v2;t3 v3;t4 v4; t5 v5; -# define ARG1V(t1,v1,e2) (v1) t1 v1; -#else -# define ARG0(v0) (v0) -# define ARG1(t1,v1) (t1 v1) -# define ARG2(t1,v1,t2,v2) (t1 v1, t2 v2) -# define ARG3(t1,v1,t2,v2,t3,v3) (t1 v1, t2 v2, t3 v3) -# define ARG4(t1,v1,t2,v2,t3,v3,t4,v4) (t1 v1, t2 v2, t3 v3, t4 v4) -# define ARG5(t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) (t1 v1, t2 v2, t3 v3, t4 v4, t5 v5) -# define ARG1V(t1,v1,e2) (t1 v1, e2) -#endif /* _NO_PROTO */ - -/* MONO returns total intensity of r,g,b components .33R+ .5G+ .17B */ -#define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 13) - -/* PSconst_out outputs to the postscript buffer an array of constant - * strings - */ -#define PSconst_out(txt) {\ - int n=(sizeof txt)/(sizeof txt[0]); \ - int i; \ - for (i=0; i10000.0) - dpi = 72.0; - return dpi; -} - - -/*__________________________________________________________________________ - | - | PSprintf - dynamic string concatenation function. - | - | In successive calls, the formatted string will be appended to the global - | output string Sp. - | It assumes that on each call, the length of the text appended to Sp - | is less than 1024. - | The format string is used as in printf, so you can use additional - | arguments. - | - | When successful, PSprintf returns the number of characters printed - | in this call, otherwise it returns EOF (just as printf does) - | -*/ - -#ifdef BROKEN_SOLARIS_COMPILER_STDARG -/* "Looks like there's a bug in Sun's C compiler and the stdarg.h use - of va_start() in HTML-PSformat.c. Until the SunPro folks can take a - look at the problem, the following pre-ANSI code should workaround - the problem." */ -static int PSprintf ARG1V(char *,format, ...) { - va_dcl - va_list args; - int len; - char *s; - - if (PS_size - PS_len < 1024) { - PS_size += 1024; - if ((s = (char *) realloc(PS_string, PS_size)) == NULL) { - fprintf(stderr, "PSprintf malloc failed\n"); - return(EOF); - } - PS_string = s; - } - va_start(args); - len = vsprintf(PS_string+PS_len, format, args); - /* this is a hack to make it work on systems were vsprintf(s,.) - * returns s, instead of the len. - */ - if (len != EOF && len != NULL) - PS_len += strlen(PS_string+PS_len); - va_end(args); - return(len); -} -#else /* not BROKEN_SOLARIS_COMPILER_STDARG */ -static int -PSprintf (format, va_alist) -char* format; -va_dcl -{ - int len; - char *s; - va_list args; - - if (PS_size - PS_len < 1024) { - PS_size += 1024; - if ((s = (char *) realloc(PS_string, PS_size)) == NULL) { - fprintf(stderr, "PSprintf malloc failed\n"); - return(EOF); - } - PS_string = s; - } - va_start(args); - len = vsprintf(PS_string+PS_len, format, args); - /* this is a hack to make it work on systems were vsprintf(s,...) - * returns s, instead of the len. - */ - if (len != EOF && len != 0) - PS_len += strlen(PS_string+PS_len); - va_end(args); - return(len); -} -#endif /* not BROKEN_SOLARIS_COMPILER_STDARG */ - -/*__________________________________________________________________________ - | - | PShex - output hex byte - | - | Append the byte "val" to an internal string buffer in hexadecimal - | format. If the argument "flush" is True, or if the buffer has filled - | up, flush the buffer to the larger postscript output buffer (using - | PSprintf). - | -*/ - -static int PShex ARG2(unsigned char,val, int,flush) { - - static unsigned char hexline[80]; - static char digit[] = "0123456789abcdef"; - - if (!flush) { - hexline[PS_hexi++] = (char) digit[((unsigned) val >> - (unsigned) 4) & (unsigned) 0x0f]; - hexline[PS_hexi++] = (char) digit[(unsigned) val & - (unsigned) 0x0f]; - } - - /* Changed from ">78" to ">77" on advice of - debra@info.win.tue.nl (Paul De Bra). */ - if ((flush && PS_hexi) || (PS_hexi>77)) { - hexline[PS_hexi] = '\0'; - PS_hexi=0; - return (PSprintf("%s\n", hexline)); - } - return (0); -} - - -/*__________________________________________________________________________ - | PSfont - change font - | - | change local font in buf to "font" - | fontfamily indicates if the overall style is times, helvetica, century - | schoolbook or lucida. - | -*/ - -static void PSfont ARG3( HTMLWidget,hw, XFontStruct *,font, int,fontfamily) { - - PS_fontstyle fn; - int style, size; - int fs; - - static PS_fontstyle fontstyle[17] = { - RF, IF, BF, FF, BF, BF, BF, BF, BF, - BF, IF, FF, FF, FB, FI, FB, FI - }; - - static char fnchar[6][3] = {"RF", "BF", "IF", "FF", "FB", "FI"}; - - /* fontsizes as set in gui.c and in HTML.c (listing font is only - * defined in HTML.c) - */ - static int fontsizes[4][3][17] = { - /* times font sizes */ - 14, 14, 14, 14, 18, 17, 14, 12, 10, 8, 14, 12, 12, 14, 14, 12, 12, - 17, 17, 17, 17, 24, 18, 17, 14, 12, 10, 17, 14, 12, 17, 17, 14, 14, - 20, 20, 20, 20, 25, 24, 20, 18, 17, 14, 20, 18, 12, 20, 20, 18, 18, - /* helvetica sizes */ - 14, 14, 14, 14, 18, 17, 14, 12, 10, 8, - 14, 12, 12, 14, 14, 12, 12, - 17, 17, 17, 17, 24, 18, 17, 14, 12, 10, - 17, 14, 12, 17, 17, 14, 14, - 20, 20, 20, 20, 25, 24, 20, 18, 17, 14, - 20, 18, 12, 20, 20, 18, 18, - /* new century schoolbook sizes */ - 14, 14, 14, 14, 18, 17, 14, 12, 10, 8, - 14, 12, 12, 14, 14, 12, 12, - 18, 18, 18, 18, 24, 18, 17, 14, 12, 10, - 18, 14, 12, 18, 18, 14, 14, - 20, 20, 20, 20, 25, 24, 20, 18, 17, 14, - 20, 18, 12, 20, 20, 18, 18, - /* lucida sizes */ - 14, 14, 14, 14, 18, 17, 14, 12, 11, 10, - 14, 12, 12, 14, 14, 12, 12, - 17, 17, 17, 17, 24, 18, 17, 14, 12, 10, - 17, 14, 12, 17, 17, 14, 14, - 20, 20, 20, 20, 25, 24, 20, 18, 17, 14, - 20, 18, 12, 20, 20, 18, 18 - }; - - /* next is for each fontfamily the ascent value as given by the - * medium sized bold x-font (the regular font has the same - * ascent value for both the medium and the large size Century - * font). - * it is use in the check for the fontsize (small, medium, large) - */ - static int medium_fontascent[4] = { - 14, 14, 16, 15 - }; - - /* for each fontfamily, for each fontsize, and for each font style - * give the ascent value, so the output from Postscript is correct. - * If the value is given between parenthesis, then it is different - * from the value as stored in the x-font. - * Note that this is a fix, and need to be changed, if the browser - * is fixed (in the current version 1.2 the baseline of various fonts - * is not aligned very well). - */ - static int fontascent[4][3][17] = { - /*rg, itl, bld, fix, h1, h2, h3, h4, h5, h6, - add, pla, lis, fixbold, fixital, plabold, plaital, */ - /* times */ - 12 ,(11), 12 ,(10),(15),(14), 12 ,(10), (8), (6), - 11 , (9), 10, 10 , 10 , (9), (9), - (13),(13),(14),(12),(20),(15),(14), 12 ,(10), (8), - 13 ,(10), 10 ,(12),(12),(10),(10), - (16),(15),(15),(13),(21),(20),(15),(15),(14), 12 , - 15 ,(13), 10,(13),(13),(13),(13), - /* helvetica */ - (12),(12),(12),(10),(15),(14),(12),(10), (9), (7), - (12), (9), 10 ,(10),(10), (9), (9), - (14),(14),(14),(12),(22),(15),(14),(12),(10), (9), - (14),(10), 10 ,(12),(12),(10),(10), - (16),(16),(16),(13),(22),(22),(16),(15),(14),(12), - (16),(13), 10 ,(13),(13),(13),(13), - /* new century schoolbook */ - (12),(12), 13 ,(10),(16), 14 , 13 ,(10), (9), (7), - (12), (9), 10 ,(10),(10), (9), (9), - (16),(14),(16),(13),(22),(16), 14 , 13 ,(10), (9), - (14),(10), 10 ,(13),(13),(10),(10), - (17),(16),(17),(13),(22),(22),(17),(16), 14 , 13 , - (16),(13), 10 ,(13),(13),(13),(13), - /* lucida bright */ - 11 ,(11), 11 ,(11),(15),(14), 11 ,(10), (9), (7), - 11 , (9), 10, 11 , 10 , (9), (9), - (14),(15),(14),(13),(20),(15),(14), 11 ,(10), (7), - 15 ,(11), 10 ,(13),(13),(11),(10), - (17),(17),(17),(16),(21),(20),(17),(15),(14), 11 , - 17 ,(14), 10,(16),(13),(14),(13) - }; - - /* NULL case - reflush old font or the builtin default: */ - if (hw==NULL || font==NULL) { - if (PS_oldfs != 0) - PSprintf( "%2s %d SF\n", fnchar[PS_oldfn], PS_oldfs); - return; - } - /* added the next line in case xmosaic version 199.4 has more fonts */ - style = 3; - - if (font == hw->html.font) { - style = 0; - } else if (font == hw->html.italic_font) { - style = 1; - } else if (font == hw->html.bold_font) { - style = 2; - } else if (font == hw->html.fixed_font) { - style = 3; - } else if (font == hw->html.header1_font) { - style = 4; - } else if (font == hw->html.header2_font) { - style = 5; - } else if (font == hw->html.header3_font) { - style = 6; - } else if (font == hw->html.header4_font) { - style = 7; - } else if (font == hw->html.header5_font) { - style = 8; - } else if (font == hw->html.header6_font) { - style = 9; - } else if (font == hw->html.address_font) { - style = 10; - } else if (font == hw->html.plain_font) { - style = 11; - } else if (font == hw->html.listing_font) { - style = 12; - } else if (font == hw->html.fixedbold_font) { - style = 13; - } else if (font == hw->html.fixeditalic_font) { - style = 14; - } else if (font == hw->html.plainbold_font) { - style = 15; - } else if (font == hw->html.plainitalic_font) { - style = 16; - } - - /* check size, by looking at the size of the regular font */ - size = 1; - if (hw->html.bold_font->ascent > medium_fontascent[fontfamily]) { - /* large font */ - size = 2; - } else if (hw->html.bold_font->ascent < medium_fontascent[fontfamily]) { - /* small font */ - size = 0; - } - fn = fontstyle[style]; - fs = fontsizes[fontfamily][size][style]; - PS_fontascent = fontascent[fontfamily][size][style]; - - if (fn != PS_oldfn || fs != PS_oldfs) { - PSprintf( "%2s %d SF\n", fnchar[fn], fs); - PS_oldfn=fn, PS_oldfs=fs; - } -} - - -/*__________________________________________________________________________ - | - | PSshowpage - end of page function - | - | show the current page and restore any changes to the printer state - | -*/ - -static void PSshowpage ARG0(void) { - - PSprintf("showpage restore\n"); -} - - -/*__________________________________________________________________________ - | - | PSnewpage - begin a fresh page - | - | increment the page count and handle the structured comment - | conventions - | -*/ - -static void PSnewpage ARG0(void) { - - PS_curr_page++; - - /* the PostScript reference Manual states that the Page: Tag - should have a label and a ordinal; otherwise programs like - psutils fail -gustaf */ - PSprintf("%%%%Page: %d %d\n", PS_curr_page, PS_curr_page); - PSprintf("save\nNP\n"); - PSfont( NULL, NULL, 0); /* force re-flush of last font used */ -} - - -/*__________________________________________________________________________ - | - | PSinit_latin1 - handle ISO encoding - | - | print out initializing PostScript text for ISO Latin1 font encoding - | This code is copied from the Idraw program (from Stanford's InterViews - | package), courtesy of Steinar Kjaernsr|d, steinar@ifi.uio.no - | -*/ - -static void PSinit_latin1 ARG0(void) { - - static char *txt[] = { - - "/reencodeISO {", - "dup dup findfont dup length dict begin", - "{ 1 index /FID ne { def }{ pop pop } ifelse } forall", - "/Encoding ISOLatin1Encoding D", - "currentdict end definefont", - "} D", - "/ISOLatin1Encoding [", - "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef", - "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef", - "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef", - "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef", - "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright", - "/parenleft/parenright/asterisk/plus/comma/minus/period/slash", - "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon", - "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N", - "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright", - "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m", - "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde", - "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef", - "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef", - "/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve", - "/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut", - "/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar", - "/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot", - "/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior", - "/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine", - "/guillemotright/onequarter/onehalf/threequarters/questiondown", - "/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla", - "/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex", - "/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis", - "/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute", - "/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis", - "/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave", - "/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex", - "/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis", - "/yacute/thorn/ydieresis", - "] D", - "[RF BF IF FF FB FI] {reencodeISO D} forall" - }; - - PSconst_out(txt); -} - - -/*__________________________________________________________________________ - | - | PSinit - initialize Postscript output - | - | does the initialization per html document - | -*/ - -static void PSinit ARG0(void) { - PS_size = PS_len = PS_offset = PS_hexi = PS_page_offset = 0; - PS_start_y = 0; - PS_string = (char *) malloc(1); - PS_oldfs = 0; - PS_oldfn = RF; - PS_curr_page = 0 ; -} - - -/*__________________________________________________________________________ - | - | PSheader - initialize Postscript output - | - | prints out the prolog - | -*/ - -static void PSheader ARG2(char *,title, int,font) { - - static char *fontname[] = { - /* in order: regular, bold, italic */ - "Times-Roman", "Times-Bold", "Times-Italic", - "Helvetica", "Helvetica-Bold", "Helvetica-Oblique", - "NewCenturySchlbk-Roman", "NewCenturySchlbk-Bold", - "NewCenturySchlbk-Italic", - /* this is a nasty trick, I have put Times in place of - * Lucida, becaus emost printers don't have Lucida font - */ - "Times-Roman", "Times-Bold", "Times-Italic" - /* "Lucida", "Lucida-Bold", "Lucida-Italic" */ - }; - - static char *txt[] = { - - "%%Creator: NCSA Mosaic, Postscript by Ameet Raval & Frans van Hoesel", - "%%Pages: (atend)", - "%%EndComments", - "save", - "/D {def} def /E {exch} D", - "/M {moveto} D", - "/S {show} D", - "/R {rmoveto} D", - "/L {lineto} D", - "/RL {rlineto} D", - "/SQ {newpath 0 0 M 0 1 L 1 1 L 1 0 L closepath} D", - "/U {gsave currentpoint currentfont /FontInfo get /UnderlinePosition get", - " 0 E currentfont /FontMatrix get dtransform E pop add newpath moveto", - " dup stringwidth rlineto stroke grestore S } D", - "/B {/r E D gsave -13 0 R currentpoint ", - " newpath r 0 360 arc closepath fill grestore } D", - "/OB {/r E D gsave -13 0 R currentpoint ", - " newpath r 0 360 arc closepath stroke grestore } D", - "/NP {xmargin topmargin translate scalfac dup scale } D", - "/HR {/l E D gsave l 0 RL stroke grestore } D", - "/SF {E findfont E scalefont setfont } D", - "/FF {/Courier } D", - "/FB {/Courier-Bold } D", - "/FI {/Courier-Oblique } D" - }; - - - PSprintf("%%!PS-Adobe-1.0\n"); - if (title) - { - char *tmp; - for (tmp = title; *tmp; tmp++) - if (*tmp == CR || *tmp == LF) - *tmp = ' '; - PSprintf("%%%%Title: %s\n", title); - } - PSprintf("%%%%DocumentFonts: %s %s %s Courier Courier-Bold Courier-Oblique\n", - fontname[font*3], fontname[font*3+1], fontname[font*3+2]); - PSconst_out(txt); - PSprintf("/RF {/%s} D\n", fontname[font*3]); - PSprintf("/BF {/%s} D\n", fontname[font*3+1]); - PSprintf("/IF {/%s} D\n", fontname[font*3+2]); - - PSinit_latin1(); - - PSprintf("/xmargin %d D\n", (int) LEFT_MARGIN); - PSprintf("/topmargin %d D\n", (int) TOP_MARGIN); - PSprintf("/scalfac %.5f D\n", Points_Pixel); - PSprintf("%%%%EndProlog\n"); - -} - - -/*__________________________________________________________________________ - | - | PStrailer - write postscript trailer - | -*/ - -static void PStrailer ARG0(void) { - - PSprintf("%%%%Trailer\n"); - PSprintf("restore\n"); - PSprintf("%%%%Pages: %d\n", PS_curr_page); -} - - -/*__________________________________________________________________________ - | - | PStext - output text - | - | show text "t", and protect special characters if needed - | if Underline is non-zero, the text is underlined. - | -*/ - -static void PStext ARG2(String,t, int,underline) { - String tp, t2; - int nspecial=0, nisochar=0; - - tp=t; - /* count # of special char's in text */ - while (*tp != '\0') { - if (*tp == L_PAREN || *tp == R_PAREN || *tp == B_SLASH) - nspecial++; - else if (*(unsigned char *)tp > (unsigned char )MAX_ASCII) - nisochar++; - tp++; - } - - if (nspecial == 0 && nisochar == 0) { - /* no special char's, send out original string */ - PSprintf("(%s)%c\n", t, (underline)?'U':'S'); - return; - } - /* create t2 to hold original text + "\"'s */ - t2 = (String) malloc((tp-t) + nspecial + 3*nisochar + 1); - - if (t2==NULL) { - fprintf(stderr, "PStext malloc failed\n"); - return; - } - - /* for each char in t, if it is a special char, insert "\" - * into the new string t2, then insert the actual char - */ - tp = t2; - while (*t != '\0') { - if (*t == L_PAREN || *t == R_PAREN || *t == B_SLASH) { - *(tp++) = B_SLASH; - *(tp++) = *t; - } else if (*(unsigned char *)t > (unsigned char) MAX_ASCII) { - /* convert to octal */ - *(tp++) = B_SLASH; - *(tp++) = ((int)(*(unsigned char *)t)>>6 & 007) + '0'; - *(tp++) = ((int)(*(unsigned char *)t)>>3 & 007) + '0'; - *(tp++) = ((int)(*(unsigned char *)t) & 007) + '0'; - } else { - *(tp++) = *t; - } - t++; - } - *(tp) = '\0'; - PSprintf("(%s)%c\n", t2, (underline)?'U':'S'); - - free(t2); -} - - -/*__________________________________________________________________________ - | - | PSbullet - output a bullet - | - | the bullet is normally filled, except for a bullet with an indent level - | of two. The size of the higher level bullets is just somewhat smaller - | -*/ - -static void PSbullet ARG2( int, level, int, size) { - - if (size < 6) size = 6; - - if (level <2 ) - PSprintf( " %f B\n", size/5.5); - else if (level == 2) - PSprintf( " %f OB\n", size/5.5); - else - PSprintf(" %f B\n", size/7.5); -} - -/*__________________________________________________________________________ - | - | PShrule - draw a horizontal line with the given width - | - | nothing special, just draw a line, from the current position to - | the right side of the paper. - | -*/ - -static void PShrule ARG1(int, length) { - - PSprintf("%d HR\n", length); -} - - -/*__________________________________________________________________________ - | - | PSmoveto - move to new x,y location - | - | if the Y value does not fit on the current page, begin a new page - | (I think in the current implementation, this never happens) - | -*/ - -static void PSmoveto ARG2( int,x, int,y) { - - if (y > PS_start_y + Pixels_Page) { - PS_start_y = y; - PSshowpage(); - PSnewpage(); - } - PS_offset = 0; - PSprintf( "%d %d M\n", x, -(y - PS_start_y)); -} - - -/*__________________________________________________________________________ - | - | PSmove_offset - set Y-offset - | - | do a relative vertical move, whenever the offset changes - | -*/ - -static void PSmove_offset ARG1( int, offset) { - - if (offset != PS_offset) { - PSprintf("0 %d R\n", PS_offset - offset ); - PS_offset = offset; - } -} - - -/*__________________________________________________________________________ - | - | PSrle_encode - perform run length encoding - | - | does the run-length encoding. This is done to reduce the file size and - | therefore the time to send the file to the printer. You get longer - | processing time instead. - | - | rle is encoded as such: - | # 'run' of count+1 equal pixels - | # count+1 non-equal pixels - | count can range between 0 and 127 - | - | returns length of the rleline vector - | -*/ - -static int PSrle_encode ARG3(unsigned char *, scanline, - unsigned char *,rleline, - int,wide) -{ - int i, j, blocklen, isrun, rlen; - unsigned char block[256], pix; - - blocklen = isrun = rlen = 0; - - for (i=0; i1) { - /* we have a run block to flush */ - rleline[rlen++] = blocklen-1; - rleline[rlen++] = block[0]; - /* start new run block with pix */ - block[0] = pix; - blocklen = 1; - } else { - isrun = 0; - /* blocklen<=1, turn into non-run */ - block[blocklen++] = pix; - } - } - } else { - /* not a run */ - if (pix == block[blocklen-1]) { - /* case 3: non-run, prev==cur */ - if (blocklen>1) { - /* have a non-run block to flush */ - rleline[rlen++] = (blocklen-1) | 0x80; - for (j=0; jI function", - " /rgbdata exch store % call input 'rgbdata'", - " rgbdata length 3 idiv", - " /npixls exch store", - " /rgbindx 0 store", - " /grays npixls string store % str to hold the result", - " 0 1 npixls 1 sub {", - " grays exch", - " rgbdata rgbindx get 20 mul % Red", - " rgbdata rgbindx 1 add get 32 mul % Green", - " rgbdata rgbindx 2 add get 12 mul % Blue", - " add add 64 idiv % I = .5G + .31R + .18B", - " put", - " /rgbindx rgbindx 3 add store", - " } for", - " grays", - " } bind def\n", - /* Utility procedure for colorimage operator. - * This procedure takes two procedures off the - * stack and merges them into a single procedure - */ - " /mergeprocs { % def", - " dup length", - " 3 -1 roll dup length dup 5 1 roll", - " 3 -1 roll add array cvx dup", - " 3 -1 roll 0 exch putinterval", - " dup 4 2 roll putinterval", - " } bind def\n", - " /colorimage { % def", - /* remove 'false 3' operands */ - " pop pop", - " {colortogray} mergeprocs", - " image", - " } bind def", - /* end of 'false' case */ - " } ifelse" - }; - - PSconst_out(txt); -} - -/*__________________________________________________________________________ - | - | PScolormap - write colormap - | - | spits out code for the colormap of the following image - | if !color, it spits out a mono-ized graymap - | -*/ - -static void PScolormap ARG5(int,color, - int,nc, - int *,rmap, - int *,gmap, - int *,bmap) { - - int i; - - /* define the colormap */ - PSprintf("/cmap %d string def\n\n\n", nc * ((color) ? 3 : 1)); - - /* load up the colormap */ - PSprintf("currentfile cmap readhexstring\n"); - - for (i=0; i>8, - gmap[i]>>8, bmap[i]>>8); - else - PSprintf("%02x ", MONO(rmap[i], gmap[i], bmap[i])); - if ((i%10) == 9) - PSprintf("\n"); - } - PSprintf("\n"); - PSprintf("pop pop\n"); /* lose return values from readhexstring */ -} - - -/*__________________________________________________________________________ - | - | PSrle_cmapimage - define rlecmapimage operator - | -*/ - -static void PSrle_cmapimage ARG1(int,color) { - - static char *txt[] = { - - /* rlecmapimage expects to have 'w h bits matrix' on stack */ - "/rlecmapimage {", - " /buffer 1 string def", - " /rgbval 3 string def", - " /block 384 string def", - " { currentfile buffer readhexstring pop", - " /bcount exch 0 get store", - " bcount 128 ge", - " { ", - " 0 1 bcount 128 sub", - " { currentfile buffer readhexstring pop pop" - }; - - static char *txt_color[] = { - " /rgbval cmap buffer 0 get 3 mul 3 getinterval store", - " block exch 3 mul rgbval putinterval", - " } for", - " block 0 bcount 127 sub 3 mul getinterval", - " }", - " { ", - " currentfile buffer readhexstring pop pop", - " /rgbval cmap buffer 0 get 3 mul 3 getinterval store", - " 0 1 bcount { block exch 3 mul rgbval putinterval } for", - " block 0 bcount 1 add 3 mul getinterval", - " } ifelse", - " }", - " false 3 colorimage", - "} bind def" - }; - - static char *txt_gray[] = { - " /rgbval cmap buffer 0 get 1 getinterval store", - " block exch rgbval putinterval", - " } for", - " block 0 bcount 127 sub getinterval", - " }", - " { ", - " currentfile buffer readhexstring pop pop", - " /rgbval cmap buffer 0 get 1 getinterval store", - " 0 1 bcount { block exch rgbval putinterval } for", - " block 0 bcount 1 add getinterval", - " } ifelse", - " }", - " image", - "} bind def" - }; - - PSconst_out(txt); - if (color) { - PSconst_out(txt_color); - } else { - PSconst_out(txt_gray); - } -} - - -/*__________________________________________________________________________ - | - | PSwrite_bw - write B&W image - | - | Write the given image array 'pic' (B/W stippled, 1 byte per pixel, - | 0=blk,1=wht) out as hexadecimal, max of 72 hex chars per line. If - | 'flipbw', then 0=white, 1=black. Returns '0' if everythings fine, - | 'EOF' if writing failed. - | -*/ - -static int PSwrite_bw ARG4(unsigned char *,pic, int,w, int,h, int,flipbw) { - - int i, j; - int err=0; - unsigned char outbyte, bitnum, bit; - - outbyte = bitnum = 0; - for (i=0; inum_colors; - int i, j; - int w = img->width; - int h = img->height; - unsigned char *imgp; - int slen, colorps, colortype, bits; - int err=0; - int extra = 0; - - imgp = img->image_data; - - /* Isgray returns true if the nth color index is a gray value */ -# define Isgray(i,n) (i->reds[n]==i->greens[n] && i->reds[n]==i->blues[n]) - /* Is_bg returns true if the nth color index is the screen background */ -# define Is_bg(i,n) (i->reds[n]==bg_color.red && \ - i->greens[n]==bg_color.green && i->blues[n]==bg_color.blue) - /* Is_fg returns true if the nth color index is the screen foreground */ -# define Is_fg(i,n) (i->reds[n]==fg_color.red && \ - i->greens[n]==fg_color.green && i->blues[n]==fg_color.blue) - - - if (anchor) { - /* draw an outline by drawing a slightly larger black square - * below the actual image - */ - PSprintf("gsave currentpoint %d sub translate ", h); - PSprintf("0 -2 translate %d %d scale\n", w+4, h+4); - PSprintf("SQ fill\n"); - PSprintf("grestore\n"); - extra = 4; - } - - if (imgp == NULL) { - /* image was not available... do something instead - * draw an empty square for example - */ - PSprintf("gsave currentpoint %d sub translate", h); - if (anchor) - PSprintf(" 2 0 translate"); - else - PSprintf(" 0 2 translate"); - PSprintf(" %d %d scale\n", w, h); - PSprintf("0.9 setgray SQ fill\n"); - PSprintf("grestore\n"); - /* move currentpoint just right of image */ - PSprintf("%d 0 R\n", w+extra); - return; - } - - /* this is a hack to see if the image is Black & White, - * Greyscale or 8 bit color - * assume it's bw if it has only one or two colors, both some grey's - * assume it's greyscale if all the colors (>2) are grey - * Images with only one color do occur too. - */ - - if ((ncolors == 2 && ( (Isgray(img,0) && Isgray(img,1)) || - (Is_bg(img,0) && Is_fg(img,1)) || - (Is_fg(img,0) && Is_bg(img,1)) )) || - ncolors == 1 && (Isgray(img,0) || Is_bg(img,0) || - Is_fg(img,0))) { - colortype = F_BWDITHER; - slen = (w+7)/8; - bits = 1; - colorps = 0; - } else { - colortype = F_GREYSCALE; - slen = w; - bits = 8; - colorps = 0; - for (i=0; ireds[0], img->greens[0],img->blues[0]) > - MONO(img->reds[1], img->greens[1], img->blues[1])) || - (ncolors == 1 && - MONO(img->reds[0], img->greens[0],img->blues[0]) > - MONO(127, 127, 127) )) { - flipbw=1; - } - - /* dimensions of data */ - PSprintf("%d %d %d\n", w, h, bits); - - /* mapping matrix */ - PSprintf("[%d 0 0 %d 0 %d]\n\n", w, -h, h); - - PSprintf("{currentfile pix readhexstring pop}\n"); - PSprintf("image\n"); - - /* write the actual image data */ - err = PSwrite_bw(imgp, w, h, flipbw); - } else { - /* all other formats */ - unsigned char *rleline = (unsigned char *) NULL; - int rlen; - - /* if we're using color, make sure 'colorimage' is defined */ - if (colorps) - PScolor_image(); - - PScolormap(colorps, ncolors, img->reds, img->greens, img->blues); - PSrle_cmapimage(colorps); - - /* dimensions of data */ - PSprintf("%d %d %d\n", w, h, bits); - /* mapping matrix */ - PSprintf("[%d 0 0 %d 0 %d]\n", w, -h, h); - PSprintf("rlecmapimage\n"); - - rleline = (unsigned char *) malloc(w * 2); - if (!rleline) { - fprintf(stderr,"failed to malloc space for rleline\n"); - return; - } - - for (i=0; ihtml.view, -#ifdef MOTIF - XtNforeground, &fg_pixel, -#endif - XtNbackground, &bg_pixel, - NULL); -#ifndef MOTIF - XtVaGetValues ((Widget)hw, - XtNforeground, &fg_pixel, - NULL); -#endif - fg_color.pixel = fg_pixel; - bg_color.pixel = bg_pixel; - XQueryColor (XtDisplay (hw->html.view), - DefaultColormap (XtDisplay (hw->html.view), - DefaultScreen (XtDisplay (hw->html.view))), - &fg_color); - XQueryColor (XtDisplay (hw->html.view), - DefaultColormap (XtDisplay (hw->html.view), - DefaultScreen (XtDisplay (hw->html.view))), - &bg_color); - } - - /* this piece of code is needed if the user selects a portion - * of the document with the mouse. - * I think it will never be used, but I left it in anyway. F. - */ - if (SwapElements(startp, endp, start_pos, end_pos)) { - start = endp; - end = startp; - epos = start_pos; - start_pos = end_pos; - end_pos = epos; - } else { - start = startp; - end = endp; - } - - /* Calculate the number of Postscript points per pixel of current - * screen, and the height of the page in pixels (used in figuring - * when we've hit the bottom of the page). - */ - Points_Pixel = 72.0 / GetDpi(hw); -#ifdef OLD - pagewidth = hw->html.doc_width; -#else /* gustaf fix */ - pagewidth = hw->html.view_width; /* seems more reasonable */ -#endif /* gustaf fix */ - - /* reduce the scaling if the width used for formatting is greater - * than 8 * 72 pixels (8 inch) - * In theory, this is not what you want for A4 paper (only 8.27 inch - * wide), but I guess that the hw->html.doc_width includes some - * left and right margins, so it seems to work in practice. - */ - if (pagewidth > PAGE_WIDTH) - Points_Pixel = Points_Pixel * (float) PAGE_WIDTH / pagewidth; - Pixels_Page = (int) (PAGE_HEIGHT / Points_Pixel); - - - PSinit(); - PSheader(hw->html.title, fontfamily); - PSnewpage(); - - last = start; - eptr = start; - - while ((eptr != NULL) && (eptr != end)) { - /* Skip the special internal text added for multi-page - * documents. - */ - if (eptr->internal == True) { - if (eptr->type == E_LINEFEED) { - PS_page_offset += eptr->line_height; - } - eptr = eptr->next; - continue; - } - /* check if this is a newline */ - if (line != eptr->line_number) { - /* calculate max height */ - height = 0; - line = eptr->line_number; - tmpptr = eptr; - while (tmpptr != NULL && tmpptr->line_number == line) { - if (tmpptr->line_height > height) - height = tmpptr->line_height; - tmpptr = tmpptr->next; - } - ypos = eptr->y - PS_page_offset ; - xpos = eptr->x - lmargin; - if (xpos < 0) - xpos = 0; - - /* check if line fits completly on page */ - if (ypos + height > PS_start_y + Pixels_Page) { - PS_start_y = ypos; - PSshowpage(); - PSnewpage(); - } - PSmoveto( xpos, ypos); - } - - switch(eptr->type) { - - case E_TEXT: { - String tptr; - int ascent; - - if (eptr == start) - tptr = (String)(eptr->edata + start_pos); - else - tptr = (String)eptr->edata; - - PSfont(hw, eptr->font, fontfamily); /* set font */ - if (PS_fontascent == 0) - ascent = eptr->font->ascent; - else - ascent = PS_fontascent; - PSmove_offset(eptr->y_offset + ascent); - PStext(tptr, eptr->underline_number); /* insert text */ - break; - } - - case E_BULLET: { - int width; - int offset; - - PSfont(hw, eptr->font, fontfamily); - width = eptr->font->max_bounds.lbearing + - eptr->font->max_bounds.rbearing; - /* the next line is a hack to get a good position of the - * bullet in most practical cases, otherwise the - * bullet may appear just a bit too low (for large fonts) - * What is does is to compare the lineheight with - * the lineheight of the next element, to correct - * for the possibly too large y_offset - */ - if (eptr->next != NULL && (eptr->next->type == E_TEXT - || eptr->next->type == E_IMAGE)) - offset = eptr->line_height - - eptr->next->line_height + - eptr->y_offset + - eptr->next->font->ascent; - else - offset = eptr->y_offset + eptr->font->ascent; - - PSmove_offset(offset - width/4); - PSbullet(eptr->indent_level, eptr->line_height); - break; - } - - case E_IMAGE: { - - PSmove_offset(eptr->y_offset); - PSimage(eptr->pic_data ,(eptr->anchorHRef != NULL)); - break; - } - - case E_LINEFEED: { - break; - } - case E_HRULE: { - PSmove_offset(eptr->y_offset); - PShrule(hw->html.doc_width); - break; - } - } - last = eptr; - eptr = eptr->next; - } - - PSshowpage(); - PStrailer(); - - return( PS_string); -} - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTML.c xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTML.c --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTML.c Sun Jun 1 17:22:03 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTML.c Thu Jan 1 00:00:00 1970 @@ -1,6142 +0,0 @@ -/**************************************************************************** - * NCSA Mosaic for the X Window System * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * mosaic@ncsa.uiuc.edu * - * * - * Copyright (C) 1993, Board of Trustees of the University of Illinois * - * * - * NCSA Mosaic software, both binary and source (hereafter, Software) is * - * copyrighted by The Board of Trustees of the University of Illinois * - * (UI), and ownership remains with the UI. * - * * - * The UI grants you (hereafter, Licensee) a license to use the Software * - * for academic, research and internal business purposes only, without a * - * fee. Licensee may distribute the binary and source code (if released) * - * to third parties provided that the copyright notice and this statement * - * appears on all copies and that no charge is associated with such * - * copies. * - * * - * Licensee may make derivative works. However, if Licensee distributes * - * any derivative work based on or derived from the Software, then * - * Licensee will (1) notify NCSA regarding its distribution of the * - * derivative work, and (2) clearly notify users that such derivative * - * work is a modified version and not the original NCSA Mosaic * - * distributed by the UI. * - * * - * Any Licensee wishing to make commercial use of the Software should * - * contact the UI, c/o NCSA, to negotiate an appropriate license for such * - * commercial use. Commercial use includes (1) integration of all or * - * part of the source code into a product for sale or license by or on * - * behalf of Licensee to third parties, or (2) distribution of the binary * - * code or source code to third parties that need it to utilize a * - * commercial product sold or licensed by or on behalf of Licensee. * - * * - * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR * - * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED * - * WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE * - * USERS OF THIS SOFTWARE. * - * * - * By using or copying this Software, Licensee agrees to abide by the * - * copyright law and all other applicable laws of the U.S. including, but * - * not limited to, export control laws, and the terms of this license. * - * UI shall have the right to terminate this license immediately by * - * written notice upon Licensee's breach of, or non-compliance with, any * - * of its terms. Licensee may be held legally responsible for any * - * copyright infringement that is caused or encouraged by Licensee's * - * failure to abide by the terms of this license. * - * * - * Comments and questions are welcome and can be sent to * - * mosaic-x@ncsa.uiuc.edu. * - ****************************************************************************/ - -#include -#include "HTMLP.h" -#ifdef MOTIF -#include -#include -#else -#include "DrawingArea.h" -#include -#endif -#include - - -#define MARGIN_DEFAULT 20 -#define CLICK_TIME 500 -#define SELECT_THRESHOLD 3 -#define MAX_UNDERLINES 3 -#define DEFAULT_INCREMENT 18 - -#ifndef ABS -#define ABS(x) (((x) > 0) ? (x) : ((x) * -1)) -#endif - -#define W_TEXTFIELD 0 -#define W_CHECKBOX 1 -#define W_RADIOBOX 2 -#define W_PUSHBUTTON 3 -#define W_PASSWORD 4 -#define W_OPTIONMENU 5 - - -extern int FormatAll(); -extern int DocumentWidth(); -extern void PlaceLine(); -extern void TextRefresh(); -extern void ImageRefresh(); -extern void LinefeedRefresh(); -extern void RefreshTextRange(); -extern void FreeColors(); -extern void FreeImages(); -extern void HideWidgets(); -extern void MapWidgets(); -extern int SwapElements(); -extern int ElementLessThan(); -extern int IsDelayedHRef(); -extern int IsIsMapForm(); -extern int AnchoredHeight(); -extern char *ParseMarkTag(); -extern char *ParseTextToString(); -extern char *ParseTextToPrettyString(); -extern char *ParseTextToPSString(); -extern struct mark_up *HTMLParse(); -extern struct ele_rec *LocateElement(); -extern struct ele_rec **MakeLineList(); -extern void FreeHRefs(); -extern struct ref_rec *AddHRef(); -extern void FreeDelayedImages(); -extern struct delay_rec *AddDelayedImage(); -extern ImageInfo *NoImageData(); -extern void ImageSubmitForm(); - - -static void SelectStart(); -static void ExtendStart(); -static void ExtendAdjust(); -static void ExtendEnd(); -static void TrackMotion(); -static Boolean ConvertSelection(); -static void LoseSelection(); -static void SelectionDone(); - - -#ifdef _NO_PROTO - -static void _HTMLInput() ; -#ifndef MOTIF -static void _HTMLpwdInput() ; -#endif -static void Initialize() ; -static void Redisplay() ; -static void Resize() ; -static Boolean SetValues() ; -static XtGeometryResult GeometryManager() ; -static void RecolorInternalHRefs() ; -static Dimension VbarWidth(); -static Dimension HbarHeight(); -static void ViewRedisplay(); -static void ViewClearAndRefresh(); -static void CallLinkCallbacks(); - -#else /* _NO_PROTO */ - -static void _HTMLInput(Widget w, XEvent *event, - String *params, Cardinal *num_params); -#ifndef MOTIF -static void _HTMLpwdInput(Widget w, XEvent *event, - String *params, Cardinal *num_params); -#endif -static void Initialize(HTMLWidget request, HTMLWidget new); -static void Redisplay(HTMLWidget hw, XEvent *event, Region region); -static void Resize(HTMLWidget hw); -static Boolean SetValues(HTMLWidget current, HTMLWidget request, - HTMLWidget new); -static XtGeometryResult GeometryManager(Widget w, XtWidgetGeometry *request, - XtWidgetGeometry *reply); -static void RecolorInternalHRefs(HTMLWidget hw, char *href); -static Dimension VbarWidth(HTMLWidget hw); -static Dimension HbarHeight(HTMLWidget hw); -static void ViewRedisplay(HTMLWidget hw, int x, int y, - int width, int height); -static void ViewClearAndRefresh(HTMLWidget hw); -static void CallLinkCallbacks(HTMLWidget hw); -#endif /* _NO_PROTO */ - - -/* - * Default translations - * Selection of text, and activate anchors. - * If motif, add manager translations. - */ -#ifdef MOTIF -static char defaultTranslations[] = -" \ -: select-start() ManagerGadgetArm()\n\ -: extend-adjust() ManagerGadgetButtonMotion()\n\ -: extend-end(PRIMARY, CUT_BUFFER0) ManagerGadgetActivate()\n\ -: select-start()\n\ -: extend-adjust()\n\ -: extend-end(PRIMARY, CUT_BUFFER0)\n\ -: extend-start()\n\ -: extend-adjust()\n\ -: extend-end(PRIMARY, CUT_BUFFER0) \n\ -: track-motion()\n\ -: track-motion()\n\ -: track-motion()\n\ -: track-motion()\ -"; -#else -static char defaultTranslations[] = -" \ -: select-start() \n\ -: extend-adjust() \n\ -: extend-end(PRIMARY, CUT_BUFFER0) \n\ -: select-start() \n\ -: extend-adjust() \n\ -: extend-end(PRIMARY, CUT_BUFFER0) \n\ -: extend-start()\n\ -: extend-adjust()\n\ -: extend-end(PRIMARY, CUT_BUFFER0) \n\ -: track-motion()\n\ -: track-motion()\n\ -: track-motion()\n\ -: track-motion()\ -"; -#endif /* MOTIF */ - - -static XtActionsRec actionsList[] = -{ - { "select-start", (XtActionProc) SelectStart }, - { "extend-start", (XtActionProc) ExtendStart }, - { "extend-adjust", (XtActionProc) ExtendAdjust }, - { "extend-end", (XtActionProc) ExtendEnd }, - { "track-motion", (XtActionProc) TrackMotion }, - { "HTMLInput", (XtActionProc) _HTMLInput }, -#ifndef MOTIF - { "HTMLpwdInput", (XtActionProc) _HTMLpwdInput }, -#endif - -#ifdef MOTIF -#ifndef MOTIF1_2 - { "Arm", (XtActionProc) _XmGadgetArm }, /* Motif 1.0 */ - { "Activate", (XtActionProc) _XmGadgetActivate }, /* Motif 1.0 */ - { "Enter", (XtActionProc) _XmManagerEnter }, /* Motif 1.0 */ - { "FocusIn", (XtActionProc) _XmManagerFocusIn }, /* Motif 1.0 */ - { "Help", (XtActionProc) _XmManagerHelp }, /* Motif 1.0 */ -#endif /* not MOTIF1_2 */ -#endif /* MOTIF */ -}; - -/* - * For some reason, in Motif1.2/X11R5 the actionsList above gets corrupted - * When the parent HTML widget is created. This means we can't use - * it later with XtAppAddActions to add to the viewing area. - * So, we make a spare copy here to use with XtAppAddActions. - */ -static XtActionsRec SpareActionsList[] = -{ - { "select-start", (XtActionProc) SelectStart }, - { "extend-start", (XtActionProc) ExtendStart }, - { "extend-adjust", (XtActionProc) ExtendAdjust }, - { "extend-end", (XtActionProc) ExtendEnd }, - { "track-motion", (XtActionProc) TrackMotion }, - { "HTMLInput", (XtActionProc) _HTMLInput }, -#ifndef MOTIF - { "HTMLpwdInput", (XtActionProc) _HTMLpwdInput }, -#endif -}; - - - -/* - * Resource definitions for HTML widget - */ - -static XtResource resources[] = -{ - /* Without Motif we need to override the borderWidth to 0 (from 1). */ -#ifndef MOTIF - { XtNborderWidth, - XtCBorderWidth, XtRDimension, sizeof (Dimension), - XtOffset (HTMLWidget, core.border_width), - XtRImmediate, (XtPointer) 0 - }, -#endif - - { WbNmarginWidth, - WbCMarginWidth, XtRDimension, sizeof (Dimension), - XtOffset (HTMLWidget, html.margin_width), - XtRImmediate, (caddr_t) MARGIN_DEFAULT - }, - - { WbNmarginHeight, - WbCMarginHeight, XtRDimension, sizeof (Dimension), - XtOffset (HTMLWidget, html.margin_height), - XtRImmediate, (caddr_t) MARGIN_DEFAULT - }, - - { WbNanchorCallback, - XtCCallback, XtRCallback, sizeof (XtCallbackList), - XtOffset (HTMLWidget, html.anchor_callback), - XtRImmediate, (caddr_t) NULL - }, - - { WbNlinkCallback, - XtCCallback, XtRCallback, sizeof (XtCallbackList), - XtOffset (HTMLWidget, html.link_callback), - XtRImmediate, (caddr_t) NULL - }, - - { WbNsubmitFormCallback, - XtCCallback, XtRCallback, sizeof (XtCallbackList), - XtOffset (HTMLWidget, html.form_callback), - XtRImmediate, (caddr_t) NULL - }, - - { WbNtext, - WbCText, XtRString, sizeof (char *), - XtOffset (HTMLWidget, html.raw_text), - XtRString, (char *) NULL - }, - - { WbNheaderText, - WbCHeaderText, XtRString, sizeof (char *), - XtOffset (HTMLWidget, html.header_text), - XtRString, (char *) NULL - }, - - { WbNfooterText, - WbCFooterText, XtRString, sizeof (char *), - XtOffset (HTMLWidget, html.footer_text), - XtRString, (char *) NULL - }, - - { WbNtitleText, - WbCTitleText, XtRString, sizeof (char *), - XtOffset (HTMLWidget, html.title), - XtRString, (char *) NULL - }, - -/* - * Without motif we need our own foreground resource instead of - * using the manager's - */ -#ifndef MOTIF - { XtNforeground, - XtCForeground, XtRPixel, sizeof (Pixel), - XtOffset (HTMLWidget, html.foreground), - XtRString, "Black" - }, -#endif - - { WbNanchorUnderlines, - WbCAnchorUnderlines, XtRInt, sizeof (int), - XtOffset (HTMLWidget, html.num_anchor_underlines), - XtRString, "0" - }, - - { WbNvisitedAnchorUnderlines, - WbCVisitedAnchorUnderlines, XtRInt, sizeof (int), - XtOffset (HTMLWidget, html.num_visitedAnchor_underlines), - XtRString, "0" - }, - - { WbNdashedAnchorUnderlines, - WbCDashedAnchorUnderlines, XtRBoolean, sizeof (Boolean), - XtOffset (HTMLWidget, html.dashed_anchor_lines), - XtRString, "False" - }, - - { WbNdashedVisitedAnchorUnderlines, - WbCDashedVisitedAnchorUnderlines, XtRBoolean, sizeof (Boolean), - XtOffset (HTMLWidget, html.dashed_visitedAnchor_lines), - XtRString, "False" - }, - - { WbNanchorColor, - XtCForeground, XtRPixel, sizeof (Pixel), - XtOffset (HTMLWidget, html.anchor_fg), - XtRString, "blue2" - }, - - { WbNvisitedAnchorColor, - XtCForeground, XtRPixel, sizeof (Pixel), - XtOffset (HTMLWidget, html.visitedAnchor_fg), - XtRString, "purple4" - }, - - { WbNactiveAnchorFG, - XtCBackground, XtRPixel, sizeof (Pixel), - XtOffset (HTMLWidget, html.activeAnchor_fg), - XtRString, "Red" - }, - - { WbNactiveAnchorBG, - XtCForeground, XtRPixel, sizeof (Pixel), - XtOffset (HTMLWidget, html.activeAnchor_bg), - XtRString, "White" - }, - - { WbNpercentVerticalSpace, - WbCPercentVerticalSpace, XtRInt, sizeof (int), - XtOffset (HTMLWidget, html.percent_vert_space), - XtRString, "90" - }, - - { WbNimageBorders, - WbCImageBorders, XtRBoolean, sizeof (Boolean), - XtOffset (HTMLWidget, html.border_images), - XtRString, "False" - }, - - { WbNdelayImageLoads, - WbCDelayImageLoads, XtRBoolean, sizeof (Boolean), - XtOffset (HTMLWidget, html.delay_images), - XtRString, "False" - }, - - { WbNfancySelections, - WbCFancySelections, XtRBoolean, sizeof (Boolean), - XtOffset (HTMLWidget, html.fancy_selections), - XtRString, "False" - }, - - { WbNisIndex, - WbCIsIndex, XtRBoolean, sizeof (Boolean), - XtOffset (HTMLWidget, html.is_index), - XtRString, "False" - }, - - { WbNview, - WbCView, XtRWidget, sizeof (Widget), - XtOffset (HTMLWidget, html.view), - XtRImmediate, NULL - }, - - { WbNverticalScrollBar, - WbCVerticalScrollBar, XtRWidget, sizeof (Widget), - XtOffset (HTMLWidget, html.vbar), - XtRImmediate, NULL - }, - - { WbNhorizontalScrollBar, - WbCHorizontalScrollBar, XtRWidget, sizeof (Widget), - XtOffset (HTMLWidget, html.hbar), - XtRImmediate, NULL - }, - - { WbNverticalScrollOnRight, - WbCVerticalScrollOnRight, XtRBoolean, sizeof (Boolean), - XtOffset (HTMLWidget, html.vbar_right), - XtRString, "True" - }, - - { WbNhorizontalScrollOnTop, - WbCHorizontalScrollOnTop, XtRBoolean, sizeof (Boolean), - XtOffset (HTMLWidget, html.hbar_top), - XtRString, "False" - }, - - { XtNfont, - XtCFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.font), - XtRString, "-adobe-times-medium-r-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNitalicFont, - WbCItalicFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.italic_font), - XtRString, "-adobe-times-medium-i-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNboldFont, - WbCBoldFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.bold_font), - XtRString, "-adobe-times-bold-r-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNfixedFont, - WbCFixedFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.fixed_font), - XtRString, "-adobe-courier-medium-r-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNfixedboldFont, - WbCFixedboldFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.fixedbold_font), - XtRString, "-adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNfixeditalicFont, - WbCFixeditalicFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.fixeditalic_font), - XtRString, "-adobe-courier-medium-o-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNheader1Font, - WbCHeader1Font, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.header1_font), - XtRString, "-adobe-times-bold-r-normal-*-24-*-*-*-*-*-*-*" - }, - - { WbNheader2Font, - WbCHeader2Font, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.header2_font), - XtRString, "-adobe-times-bold-r-normal-*-18-*-*-*-*-*-*-*" - }, - - { WbNheader3Font, - WbCHeader3Font, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.header3_font), - XtRString, "-adobe-times-bold-r-normal-*-17-*-*-*-*-*-*-*" - }, - - { WbNheader4Font, - WbCHeader4Font, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.header4_font), - XtRString, "-adobe-times-bold-r-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNheader5Font, - WbCHeader5Font, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.header5_font), - XtRString, "-adobe-times-bold-r-normal-*-12-*-*-*-*-*-*-*" - }, - - { WbNheader6Font, - WbCHeader6Font, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.header6_font), - XtRString, "-adobe-times-bold-r-normal-*-10-*-*-*-*-*-*-*" - }, - - { WbNaddressFont, - WbCAddressFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.address_font), - XtRString, "-adobe-times-medium-i-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNplainFont, - WbCPlainFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.plain_font), - XtRString, "-adobe-courier-medium-r-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNplainboldFont, - WbCPlainboldFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.plainbold_font), - XtRString, "-adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNplainitalicFont, - WbCPlainitalicFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.plainitalic_font), - XtRString, "-adobe-courier-medium-o-normal-*-14-*-*-*-*-*-*-*" - }, - - { WbNlistingFont, - WbCListingFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.listing_font), - XtRString, "-adobe-courier-medium-r-normal-*-12-*-*-*-*-*-*-*" - }, -/* amb */ - { WbNsupSubFont, - WbCSupSubFont, XtRFontStruct, sizeof (XFontStruct *), - XtOffset (HTMLWidget, html.supsub_font), - XtRString, "-adobe-courier-medium-r-normal-*-10-*-*-*-*-*-*-*" - }, -/* end amb */ - { WbNpreviouslyVisitedTestFunction, - WbCPreviouslyVisitedTestFunction, XtRPointer, - sizeof (XtPointer), - XtOffset (HTMLWidget, html.previously_visited_test), - XtRImmediate, (caddr_t) NULL - }, - - { WbNresolveImageFunction, - WbCResolveImageFunction, XtRPointer, - sizeof (XtPointer), - XtOffset (HTMLWidget, html.resolveImage), - XtRImmediate, (caddr_t) NULL - }, - - { WbNresolveDelayedImage, - WbCResolveDelayedImage, XtRPointer, - sizeof (XtPointer), - XtOffset (HTMLWidget, html.resolveDelayedImage), - XtRImmediate, (caddr_t) NULL - }, - - { - WbNpointerMotionCallback, - WbCPointerMotionCallback, XtRPointer, - sizeof (XtPointer), - XtOffset (HTMLWidget, html.pointer_motion_callback), - XtRImmediate, (caddr_t) NULL - }, - -}; - - - -HTMLClassRec htmlClassRec = { - { /* core class fields */ -#ifdef MOTIF - (WidgetClass) &xmManagerClassRec, /* superclass */ -#else - (WidgetClass) &constraintClassRec, /* superclass */ -#endif /* MOTIF */ - "HTML", /* class_name */ - sizeof(HTMLRec), /* widget_size */ - NULL, /* class_initialize */ - NULL, /* class_part_init */ - FALSE, /* class_inited */ - (XtInitProc) Initialize, /* initialize */ - NULL, /* initialize_hook */ - XtInheritRealize, /* realize */ - actionsList, /* actions */ - XtNumber(actionsList), /* num_actions */ - resources, /* resources */ - XtNumber(resources), /* num_resources */ - NULLQUARK, /* xrm_class */ - TRUE, /* compress_motion */ - FALSE, /* compress_exposure */ - TRUE, /* compress_enterlv */ - FALSE, /* visible_interest */ - NULL, /* destroy */ - (XtWidgetProc) Resize, /* resize */ - (XtExposeProc) Redisplay, /* expose */ - (XtSetValuesFunc) SetValues, /* set_values */ - NULL, /* set_values_hook */ - XtInheritSetValuesAlmost, /* set_values_almost */ - NULL, /* get_values_hook */ - NULL, /* accept_focus */ - XtVersion, /* version */ - NULL, /* callback_private */ - defaultTranslations, /* tm_table */ - XtInheritQueryGeometry, /* query_geometry */ - XtInheritDisplayAccelerator, /* display_accelerator*/ - NULL, /* extension */ - }, - - { /* composite_class fields */ - (XtGeometryHandler) GeometryManager, /* geometry_manager */ - NULL, /* change_managed */ - XtInheritInsertChild, /* insert_child */ - XtInheritDeleteChild, /* delete_child */ - NULL, /* extension */ - }, - - { /* constraint_class fields */ - NULL, /* resource list */ - 0, /* num resources */ - 0, /* constraint size */ - NULL, /* init proc */ - NULL, /* destroy proc */ - NULL, /* set values proc */ - NULL, /* extension */ - }, - -#ifdef MOTIF - { /* manager_class fields */ - XtInheritTranslations, /* translations */ - NULL, /* syn_resources */ - 0, /* num_syn_resources */ - NULL, /* syn_cont_resources */ - 0, /* num_syn_cont_resources */ - XmInheritParentProcess, /* parent_process */ - NULL, /* extension */ - }, -#endif /* MOTIF */ - - { /* html_class fields */ - 0 /* none */ - } -}; - -WidgetClass htmlWidgetClass = (WidgetClass)&htmlClassRec; - -static Cursor in_anchor_cursor = (Cursor)NULL; - - -/* - * Process an expose event in the View (or drawing area). This - * Can be a regular expose event, or perhaps a GraphicsExpose Event. - */ -static void -DrawExpose(w, data, event) - Widget w; - caddr_t data; - XEvent *event; -{ - XExposeEvent *ExEvent = (XExposeEvent *)event; - HTMLWidget hw = (HTMLWidget)data; - int x, y; - int width, height; - - if ((event->xany.type != Expose)&&(event->xany.type != GraphicsExpose)) - { - return; - } - - /* - * Make sure we have a valid GC to draw with. - */ - if (hw->html.drawGC == NULL) - { - unsigned long valuemask; - XGCValues values; - - values.function = GXcopy; - values.plane_mask = AllPlanes; -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ -#ifdef MOTIF - values.foreground = hw->manager.foreground; -#else - values.foreground = hw->html.foreground; -#endif /* MOTIF */ - values.background = hw->core.background_pixel; - - valuemask = GCFunction|GCPlaneMask|GCForeground|GCBackground; - - hw->html.drawGC = XCreateGC(XtDisplay(hw), XtWindow(hw), - valuemask, &values); - } - - x = ExEvent->x; - y = ExEvent->y; - width = (int)ExEvent->width; - height = (int)ExEvent->height; - -#ifdef DEBUG -DebugHook(x, y, width, height); -#endif - - ViewRedisplay(hw, x, y, width, height); -} - - -void -ScrollWidgets(hw) - HTMLWidget hw; -{ - WidgetInfo *wptr; - int xval, yval; - - xval = hw->html.scroll_x; - yval = hw->html.scroll_y; - wptr = hw->html.widget_list; - while (wptr != NULL) - { - if (wptr->w != NULL) - { - Widget w; - int x, y; - - w = wptr->w; - x = wptr->x; - y = wptr->y; - XtMoveWidget(w, (x - xval), (y - yval)); - } - wptr = wptr->next; - } -} - - -#ifndef MOTIF -/* - * Set the Athena Scrollbar's thumb position properly. - */ -static void -setScrollBar(sb, topPosition, totalLength, currentLength) - Widget sb; - Position topPosition; - Dimension totalLength, currentLength; -{ - float top = (float)topPosition /(float)(totalLength); - float shown = (float)currentLength/(float)(totalLength); - - XawScrollbarSetThumb(sb, top, shown); -} -#endif - - -/* - * Either the vertical or hortizontal scrollbar has been moved - */ -void -ScrollToPos(w, hw, value) - Widget w; - HTMLWidget hw; - int value; -{ - /* - * Special code incase the scrollbar is "moved" before we have a window - * (if we have a GC we have a window) - */ - if (hw->html.drawGC == NULL) - { - if (w == hw->html.vbar) - { - hw->html.scroll_y = value; - } - else if (w == hw->html.hbar) - { - hw->html.scroll_x = value; - } - return; - } - - /* - * get our widgets out of the way (No Expose events) - HideWidgets(hw); - */ - - /* - * If we've moved the vertical scrollbar - */ - if (w == hw->html.vbar) - { - /* - * We've scrolled down. Copy up the untouched part of the - * window. Then Clear and redraw the new area - * exposed. - */ - if (value > hw->html.scroll_y) - { - int dy; - - dy = value - hw->html.scroll_y; - if (dy > hw->html.view_height) - { - hw->html.scroll_y = value; - XClearArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - 0, 0, - hw->html.view_width, - hw->html.view_height, False); - ViewRedisplay(hw, - 0, 0, - hw->html.view_width, - hw->html.view_height); - } - else - { - XCopyArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - XtWindow(hw->html.view), - hw->html.drawGC, 0, dy, - hw->html.view_width, - hw->html.view_height - dy, - 0, 0); - hw->html.scroll_y = value; - XClearArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - 0, (int)hw->html.view_height - dy, - hw->html.view_width, dy, False); - ViewRedisplay(hw, - 0, (int)hw->html.view_height - dy, - hw->html.view_width, dy); - } - } - /* - * We've scrolled up. Copy down the untouched part of the - * window. Then Clear and redraw the new area - * exposed. - */ - else if (value < hw->html.scroll_y) - { - int dy; - - dy = hw->html.scroll_y - value; - if (dy > hw->html.view_height) - { - hw->html.scroll_y = value; - XClearArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - 0, 0, - hw->html.view_width, - hw->html.view_height, False); - ViewRedisplay(hw, - 0, 0, - hw->html.view_width, - hw->html.view_height); - } - else - { - XCopyArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - XtWindow(hw->html.view), - hw->html.drawGC, 0, 0, - hw->html.view_width, - hw->html.view_height - dy, - 0, dy); - hw->html.scroll_y = value; - XClearArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - 0, 0, - hw->html.view_width, dy, False); - ViewRedisplay(hw, - 0, 0, - hw->html.view_width, dy); - } - } - } - /* - * Else we've moved the horizontal scrollbar - */ - else if (w == hw->html.hbar) - { - /* - * We've scrolled right. Copy left the untouched part of the - * window. Then Clear and redraw the new area - * exposed. - */ - if (value > hw->html.scroll_x) - { - int dx; - - dx = value - hw->html.scroll_x; - if (dx > hw->html.view_width) - { - hw->html.scroll_x = value; - XClearArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - 0, 0, - hw->html.view_width, - hw->html.view_height, False); - ViewRedisplay(hw, - 0, 0, - hw->html.view_width, - hw->html.view_height); - } - else - { - XCopyArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - XtWindow(hw->html.view), - hw->html.drawGC, dx, 0, - hw->html.view_width - dx, - hw->html.view_height, - 0, 0); - hw->html.scroll_x = value; - XClearArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - (int)hw->html.view_width - dx, 0, - dx, hw->html.view_height, False); - ViewRedisplay(hw, - (int)hw->html.view_width - dx, 0, - dx, hw->html.view_height); - } - } - /* - * We've scrolled left. Copy right the untouched part of the - * window. Then Clear and redraw the new area - * exposed. - */ - else if (value < hw->html.scroll_x) - { - int dx; - - dx = hw->html.scroll_x - value; - if (dx > hw->html.view_width) - { - hw->html.scroll_x = value; - XClearArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - 0, 0, - hw->html.view_width, - hw->html.view_height, False); - ViewRedisplay(hw, - 0, 0, - hw->html.view_width, - hw->html.view_height); - } - else - { - XCopyArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - XtWindow(hw->html.view), - hw->html.drawGC, 0, 0, - hw->html.view_width - dx, - hw->html.view_height, - dx, 0); - hw->html.scroll_x = value; - XClearArea(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - 0, 0, - dx, hw->html.view_height, False); - ViewRedisplay(hw, - 0, 0, - dx, hw->html.view_height); - } - } - } - - /* - * Move the now hidden widgets - * Flush any Copyed or Cleared text first. - XFlush(XtDisplay(hw)); - */ - ScrollWidgets(hw); - - /* - * Remap the widgets to their new location - MapWidgets(hw); - */ -} - - -/* - * Either the vertical or hortizontal scrollbar has been moved - */ -void -ScrollMove(w, client_data, call_data) - Widget w; - caddr_t client_data; - caddr_t call_data; -{ -#ifdef MOTIF - XmScrollBarCallbackStruct *sc = (XmScrollBarCallbackStruct *)call_data; - - ScrollToPos(w, (HTMLWidget)client_data, sc->value); -#else - float scrollDir = (int)call_data < 0 ? -0.3 : 0.3; - HTMLWidget hw = (HTMLWidget)client_data; - int value; - Dimension totalLength, currentLength; - - if (w == hw->html.vbar) - { - totalLength = hw->html.doc_height; - currentLength = hw->html.view_height; - value = hw->html.scroll_y + scrollDir * currentLength; - } - else - { - totalLength = hw->html.doc_width; - currentLength = hw->html.view_width; - value = hw->html.scroll_x + scrollDir * currentLength; - } - - if (value > (int)totalLength) value = totalLength; - if (value < 0) value = 0; - - setScrollBar(w, value, totalLength, currentLength); - ScrollToPos(w, hw, value); -#endif -} - - -#ifndef MOTIF -void -JumpMove(w, client_data, call_data) - Widget w; - caddr_t client_data; - caddr_t call_data; -{ - HTMLWidget hw = (HTMLWidget)client_data; - int value = (int)(*(float *)call_data * - (w == hw->html.vbar ? - hw->html.doc_height : - hw->html.doc_width)); - ScrollToPos(w, hw, value); -} -#endif - - -/* - * Create the horizontal and vertical scroll bars. - * Size them later. - */ -static void -#ifdef _NO_PROTO -CreateScrollbars (hw) - HTMLWidget hw ; -#else -CreateScrollbars( - HTMLWidget hw) -#endif -{ - Arg arg[20]; - Cardinal argcnt; - XtTranslations trans; - - /* - * If the user hasn't provided a viewing area Widget (which they - * should not most of the time) make a drawing are to use. - */ - if (hw->html.view == NULL) - { - argcnt = 0; - XtSetArg(arg[argcnt], XxNwidth, 10); argcnt++; - XtSetArg(arg[argcnt], XxNheight, 10); argcnt++; - hw->html.view = XtCreateWidget("View", -#ifdef MOTIF - xmDrawingAreaWidgetClass, -#else - drawingAreaWidgetClass, -#endif - (Widget)hw, arg, argcnt); - XtManageChild(hw->html.view); - } - - /* - * For the view widget catch all Expose and GraphicsExpose - * events. Replace its translations with ours, and make - * sure all the actions are in order. - */ - XtAddEventHandler((Widget)hw->html.view, ExposureMask, True, - (XtEventHandler)DrawExpose, (caddr_t)hw); - /* - * As described previoisly, for some reason with Motif1.2/X11R5 - * the list actionsList is corrupted when we get here, - * so we have to use the special copy SpareActionsList - */ - XtAppAddActions(XtWidgetToApplicationContext(hw->html.view), - SpareActionsList, XtNumber(SpareActionsList)); - trans = XtParseTranslationTable(defaultTranslations); - argcnt = 0; - XtSetArg(arg[argcnt], XtNtranslations, trans); argcnt++; - XtSetValues(hw->html.view, arg, argcnt); - - /* - * If the user hasn't provided a vertical scrollbar (which they - * should not most of the time) make one. - */ - if (hw->html.vbar == NULL) - { - argcnt = 0; -#ifdef MOTIF - XtSetArg(arg[argcnt], XmNorientation, XmVERTICAL); argcnt++; - hw->html.vbar = XtCreateWidget("Vbar", xmScrollBarWidgetClass, - (Widget)hw, arg, argcnt); -#else - XtSetArg(arg[argcnt],XtNorientation,XtorientVertical); argcnt++; - hw->html.vbar = XtCreateWidget("Vbar", scrollbarWidgetClass, - (Widget)hw, arg, argcnt); -#endif - XtManageChild(hw->html.vbar); - } - - /* - * Add callbacks to catch scrollbar changes - */ -#ifdef MOTIF - XtAddCallback(hw->html.vbar, XmNvalueChangedCallback, - (XtCallbackProc)ScrollMove, (caddr_t)hw); - XtAddCallback(hw->html.vbar, XmNdragCallback, - (XtCallbackProc)ScrollMove, (caddr_t)hw); -#else - XtAddCallback(hw->html.vbar, XtNjumpProc, - (XtCallbackProc)JumpMove, (caddr_t)hw); - XtAddCallback(hw->html.vbar, XtNscrollProc, - (XtCallbackProc)ScrollMove, (caddr_t)hw); -#endif - - /* - * If the user hasn't provided a horizontal scrollbar (which they - * should not most of the time) make one. - */ - if (hw->html.hbar == NULL) - { - argcnt = 0; -#ifdef MOTIF - XtSetArg(arg[argcnt], XmNorientation, XmHORIZONTAL); argcnt++; - hw->html.hbar = XtCreateWidget("Hbar", xmScrollBarWidgetClass, - (Widget)hw, arg, argcnt); -#else - XtSetArg(arg[argcnt], XtNorientation, XtorientHorizontal); - argcnt++; - hw->html.hbar = XtCreateWidget("Hbar", scrollbarWidgetClass, - (Widget)hw, arg, argcnt); -#endif - XtManageChild(hw->html.hbar); - } - - /* - * Add callbacks to catch scrollbar changes - */ -#ifdef MOTIF - XtAddCallback(hw->html.hbar, XmNvalueChangedCallback, - (XtCallbackProc)ScrollMove, (caddr_t)hw); - XtAddCallback(hw->html.hbar, XmNdragCallback, - (XtCallbackProc)ScrollMove, (caddr_t)hw); -#else - XtAddCallback(hw->html.hbar, XtNjumpProc, - (XtCallbackProc)JumpMove, (caddr_t)hw); - XtAddCallback(hw->html.hbar, XtNscrollProc, - (XtCallbackProc)ScrollMove, (caddr_t)hw); -#endif -} - - -/* - * Return the width of the vertical scrollbar - */ -static Dimension -#ifdef _NO_PROTO -VbarWidth (hw) - HTMLWidget hw ; -#else -VbarWidth( - HTMLWidget hw) -#endif -{ - Arg arg[4]; - Cardinal argcnt; - Dimension width; - - width = 0; - if (hw->html.vbar != NULL) - { - argcnt = 0; - XtSetArg(arg[argcnt], XxNwidth, &width); argcnt++; - XtGetValues(hw->html.vbar, arg, argcnt); - } - - return(width); -} - - -/* - * Return the height of the horizontal scrollbar - */ -static Dimension -#ifdef _NO_PROTO -HbarHeight (hw) - HTMLWidget hw ; -#else -HbarHeight( - HTMLWidget hw) -#endif -{ - Arg arg[4]; - Cardinal argcnt; - Dimension height; - - height = 0; - if (hw->html.hbar != NULL) - { - argcnt = 0; - XtSetArg(arg[argcnt], XxNheight, &height); argcnt++; - XtGetValues(hw->html.hbar, arg, argcnt); - } - - return(height); -} - - -/* - * Resize and set the min and max values of the scrollbars. Position viewing - * area based on scrollbar locations. - */ -static void -#ifdef _NO_PROTO -ConfigScrollBars (hw) - HTMLWidget hw ; -#else -ConfigScrollBars( - HTMLWidget hw) -#endif -{ -#ifdef MOTIF - Arg arg[20]; - Cardinal argcnt; -#endif - int vx, vy; - - /* - * Move and size the viewing area - */ -#ifdef MOTIF - vx = hw->manager.shadow_thickness; - vy = hw->manager.shadow_thickness; -#else - vx = vy = 0; -#endif - if ((hw->html.use_vbar == True)&&(hw->html.vbar_right == False)) - { - vx += VbarWidth(hw); - } - if ((hw->html.use_hbar == True)&&(hw->html.hbar_top == True)) - { - vy += HbarHeight(hw); - } - XtMoveWidget(hw->html.view, vx, vy); - XtResizeWidget(hw->html.view, hw->html.view_width, hw->html.view_height, - hw->html.view->core.border_width); - - /* - * Set up vertical scrollbar - */ - if (hw->html.use_vbar == True) - { - int maxv; - int ss; - - /* - * Size the vertical scrollbar to the height of - * the viewing area - */ - XtResizeWidget(hw->html.vbar, hw->html.vbar->core.width, - hw->html.view_height + (2 * -#ifdef MOTIF - hw->manager.shadow_thickness -#else - 0 -#endif - ), - hw->html.vbar->core.border_width); - - /* - * Set the slider size to be the percentage of the - * viewing area that the viewing area is of the - * document area. Or set it to 1 if that isn't possible. - */ - if (hw->html.doc_height == 0) - { - ss = 1; - } - else - { -#ifdef DEBUG -fprintf (stderr, "view_height %d, doc_height %d\n", -hw->html.view_height, hw->html.doc_height); -#endif -#ifdef NOT_RIGHT - /* Eric -- your previous equation wasn't doing it. - This isn't either... */ - ss = - (int)((float)hw->html.view_height * - ((float)hw->html.view_height / - (float)(hw->html.doc_height - (int)hw->html.view_height))); - if (ss > hw->html.view_height) - { - ss = hw->html.view_height; - } -#endif - /* Added by marca: this produces results *very* close (~1 pixel) - to the original scrolled window behavior. */ - ss = hw->html.view_height; - } - if (ss < 1) - { - ss = 1; - } -#ifdef DEBUG -fprintf (stderr, "computed ss to be %d\n", ss); -#endif - - /* - * If resizing of the document has made scroll_y - * greater than the max, we want to hold it at the max. - */ - maxv = hw->html.doc_height - (int)hw->html.view_height; - if (maxv < 0) - { - maxv = 0; - } - if (hw->html.scroll_y > maxv) - { - hw->html.scroll_y = maxv; - } - - /* - * Prevent the Motif max value and slider size - * from going to zero, which is illegal - */ - maxv = maxv + ss; - if (maxv < 1) - { - maxv = 1; - } - - /* - * Motif will not allow the actual value to be equal to - * its max value. Adjust accordingly. - * Since we might decrease scroll_y, cap it at zero. - */ - if (hw->html.scroll_y >= maxv) - { - hw->html.scroll_y = maxv - 1; - } - if (hw->html.scroll_y < 0) - { - hw->html.scroll_y = 0; - } - -#ifdef MOTIF - argcnt = 0; - XtSetArg(arg[argcnt], XmNminimum, 0); argcnt++; - XtSetArg(arg[argcnt], XmNmaximum, maxv); argcnt++; - XtSetArg(arg[argcnt], XmNvalue, hw->html.scroll_y); argcnt++; - XtSetArg(arg[argcnt], XmNsliderSize, ss); argcnt++; - XtSetArg(arg[argcnt], XmNincrement, DEFAULT_INCREMENT); argcnt++; - XtSetArg(arg[argcnt], XmNpageIncrement, - hw->html.view_height > DEFAULT_INCREMENT ? - hw->html.view_height - DEFAULT_INCREMENT : 1); argcnt++; - XtSetValues(hw->html.vbar, arg, argcnt); -#else - setScrollBar(hw->html.vbar, - hw->html.scroll_y, - hw->html.doc_height, - hw->html.view_height); -#endif /* MOTIF */ - -#ifdef DEBUG -XtVaGetValues(hw->html.vbar, XmNsliderSize, &ss, NULL); -fprintf (stderr, "real slider size %d\n", ss); -#endif - } - - /* - * Set up horizontal scrollbar - */ - if (hw->html.use_hbar == True) - { - int maxv; - int ss; - - /* - * Size the horizontal scrollbar to the width of - * the viewing area - */ - XtResizeWidget(hw->html.hbar, - hw->html.view_width + (2 * -#ifdef MOTIF - hw->manager.shadow_thickness -#else - 0 -#endif /* MOTIF */ - ), - hw->html.hbar->core.height, - hw->html.hbar->core.border_width); - - /* - * Set the slider size to be the percentage of the - * viewing area that the viewing area is of the - * document area. Or set it to 1 if that isn't possible. - */ - if (hw->html.doc_width == 0) - { - ss = 1; - } - else - { -#ifdef NOT_RIGHT - ss = hw->html.view_width * - hw->html.view_width / hw->html.doc_width; - if (ss > hw->html.view_width) - { - ss = hw->html.view_width; - } -#endif - /* Added by marca: this produces results *very* close (~1 pixel) - to the original scrolled window behavior. */ - ss = hw->html.view_width; - } - if (ss < 1) - { - ss = 1; - } - - /* - * If resizing of the document has made scroll_x - * greater than the max, we want to hold it at the max. - */ - maxv = hw->html.doc_width - (int)hw->html.view_width; - if (maxv < 0) - { - maxv = 0; - } - if (hw->html.scroll_x > maxv) - { - hw->html.scroll_x = maxv; - } - - /* - * Prevent the Motif max value and slider size - * from going to zero, which is illegal - */ - maxv = maxv + ss; - if (maxv < 1) - { - maxv = 1; - } - - /* - * Motif will not allow the actual value to be equal to - * its max value. Adjust accordingly. - * Since we might decrease scroll_x, cap it at zero. - */ - if (hw->html.scroll_x >= maxv) - { - hw->html.scroll_x = maxv - 1; - } - if (hw->html.scroll_x < 0) - { - hw->html.scroll_x = 0; - } - -#ifdef MOTIF - argcnt = 0; - XtSetArg(arg[argcnt], XmNminimum, 0); argcnt++; - XtSetArg(arg[argcnt], XmNmaximum, maxv); argcnt++; - XtSetArg(arg[argcnt], XmNvalue, hw->html.scroll_x); argcnt++; - XtSetArg(arg[argcnt], XmNsliderSize, ss); argcnt++; - XtSetArg(arg[argcnt], XmNincrement, DEFAULT_INCREMENT); argcnt++; - XtSetArg(arg[argcnt], XmNpageIncrement, - hw->html.view_width > DEFAULT_INCREMENT ? - hw->html.view_width - DEFAULT_INCREMENT : 1); argcnt++; - XtSetValues(hw->html.hbar, arg, argcnt); -#else - setScrollBar(hw->html.hbar, - hw->html.scroll_x, - hw->html.doc_width, - hw->html.view_width); -#endif /* MOTIF */ - } - -#ifdef DEBUG - { - int ss; -XtVaGetValues(hw->html.vbar, XmNsliderSize, &ss, NULL); -fprintf (stderr, "real slider size %d\n", ss); - } -#endif -} - - -/* - * Reformat the window and scrollbars. - * May be called because of a changed document, or because of a changed - * window size. - */ -static void -#ifdef _NO_PROTO -ReformatWindow (hw) - HTMLWidget hw ; -#else -ReformatWindow( - HTMLWidget hw) -#endif -{ - int temp; - int new_width; - Dimension swidth, sheight; - Dimension st; - - /* - * Find the current scrollbar sizes, and shadow thickness and format - * the document to the current window width - * (assume a vertical scrollbar) - */ - swidth = VbarWidth(hw); - sheight = HbarHeight(hw); -#ifdef MOTIF - st = hw->manager.shadow_thickness; -#else - st = 0; -#endif /* MOTIF */ - if (hw->core.width <= swidth) - { - hw->core.width = swidth + 10; - } - new_width = hw->core.width - swidth - (2 * st); - temp = FormatAll(hw, &new_width); - - /* - * If we need the vertical scrollbar, place and manage it, - * and store the current viewing area width. - */ - if (temp > hw->core.height - sheight) - { - hw->html.use_vbar = True; - if (hw->html.vbar_right == True) - { - XtMoveWidget(hw->html.vbar, - (hw->core.width - swidth), 0); - } - else - { - XtMoveWidget(hw->html.vbar, 0, 0); - } - XtManageChild(hw->html.vbar); - hw->html.view_width = hw->core.width - swidth - (2 * st); - } - /* - * Else we were wrong to assume a vertical scrollbar. - * Remove it, and reformat the document to the wider width. - * Save the as the current viewing are width. - */ - else - { - hw->html.use_vbar = False; - XtUnmanageChild(hw->html.vbar); - hw->html.scroll_y = 0; - new_width = hw->core.width - (2 * st); - temp = FormatAll(hw, &new_width); - hw->html.view_width = hw->core.width - (2 * st); - /* fake out later horizontal scrollbars */ - swidth = 0; - } - - /* - * Calculate the actual max width and height of the complete - * formatted document. - * The max width may exceed the preformatted width due to special - * factors in the formatting of the widget. - * Use the max of the 2 here, but leave max_pre_width unchanged - * for future formatting calls. - */ - /* - * new_width includes the margins, and hw->html.max_pre_width - * does not, fix that here. - */ - new_width = new_width - (2 * hw->html.margin_width); - if (hw->html.max_pre_width > new_width) - { - new_width = hw->html.max_pre_width; - } - /* - * If the maximum width derives from a formatted, as opposed to - * unformatted piece of text, allow a 20% of margin width slop - * over into the margin to cover up a minor glick with terminaing - * punctuation after anchors at the end of the line. - */ - else - { - new_width = new_width - (20 * hw->html.margin_width / 100); - } - - hw->html.doc_height = temp; - hw->html.doc_width = new_width + (2 * hw->html.margin_width); - if (hw->html.view_width > hw->html.doc_width) - { - hw->html.doc_width = hw->html.view_width; - } - - /* - * If we need a horizontal scrollbar - * Place it and manage it. Save the height of the current - * viewing area. - */ - if (hw->html.doc_width > hw->html.view_width) - { - hw->html.use_hbar = True; - if (hw->html.hbar_top == True) - { - if (hw->html.use_vbar == True) - { - XtMoveWidget(hw->html.vbar, - hw->html.vbar->core.x, sheight); - } - - if (hw->html.vbar_right == True) - { - XtMoveWidget(hw->html.hbar, 0, 0); - } - else - { - XtMoveWidget(hw->html.hbar, swidth, 0); - } - } - else - { - if (hw->html.vbar_right == True) - { - XtMoveWidget(hw->html.hbar, 0, - (hw->core.height - sheight)); - } - else - { - XtMoveWidget(hw->html.hbar, swidth, - (hw->core.height - sheight)); - } - } - XtManageChild(hw->html.hbar); - hw->html.view_height = hw->core.height - sheight - (2 * st); - } - /* - * Else we don't need a horizontal scrollbar. - * Remove it and save the current viewing area height. - */ - else - { - hw->html.use_hbar = False; - XtUnmanageChild(hw->html.hbar); - hw->html.scroll_x = 0; - hw->html.view_height = hw->core.height - (2 * st); - } - - /* - * Configure the scrollbar min, max, and slider sizes - */ -#ifdef DEBUG -fprintf (stderr, "calling in ReformatWindow\n"); -#endif - ConfigScrollBars(hw); -} - - -/* - * We're a happy widget. We let any child move or resize themselves - * however they want, we don't care. - */ -static XtGeometryResult -#ifdef _NO_PROTO -GeometryManager (w, request, reply) - Widget w; - XtWidgetGeometry * request; - XtWidgetGeometry * reply; -#else -GeometryManager ( - Widget w, - XtWidgetGeometry * request, - XtWidgetGeometry * reply) -#endif -{ - reply->x = request->x; - reply->y = request->y; - reply->width = request->width; - reply->height = request->height; - reply->border_width = request->border_width; - reply->request_mode = request->request_mode; - return (XtGeometryYes); -} - - -/* - * Initialize is called when the widget is first initialized. - * Check to see that all the starting resources are valid. - */ -static void -#ifdef _NO_PROTO -Initialize (request, new) - HTMLWidget request ; - HTMLWidget new ; -#else -Initialize( - HTMLWidget request, - HTMLWidget new) -#endif -{ - /* - * Make sure height and width are not zero. - */ - if (new->core.width == 0) - { - new->core.width = new->html.margin_width << 1 ; - } - if (new->core.width == 0) - { - new->core.width = 10 ; - } - if (new->core.height == 0) - { - new->core.height = new->html.margin_height << 1 ; - } - if (new->core.height == 0) - { - new->core.height = 10 ; - } - - /* - * Make sure the underline numbers are within bounds. - */ - if (new->html.num_anchor_underlines < 0) - { - new->html.num_anchor_underlines = 0; - } - if (new->html.num_anchor_underlines > MAX_UNDERLINES) - { - new->html.num_anchor_underlines = MAX_UNDERLINES; - } - if (new->html.num_visitedAnchor_underlines < 0) - { - new->html.num_visitedAnchor_underlines = 0; - } - if (new->html.num_visitedAnchor_underlines > MAX_UNDERLINES) - { - new->html.num_visitedAnchor_underlines = MAX_UNDERLINES; - } - - /* - * Parse the raw text with the HTML parser. And set the formatted - * element list to NULL. - */ - new->html.html_objects = HTMLParse(NULL, request->html.raw_text); - CallLinkCallbacks(new); - new->html.html_header_objects = - HTMLParse(NULL, request->html.header_text); - new->html.html_footer_objects = - HTMLParse(NULL, request->html.footer_text); - new->html.formatted_elements = NULL; - new->html.my_visited_hrefs = NULL; - new->html.my_delayed_images = NULL; - new->html.widget_list = NULL; - new->html.form_list = NULL; - - /* - * Blank document - */ - new->html.line_array = NULL; - new->html.line_count = 0; - - /* - * Find the max width of a preformatted - * line in this document. - */ - new->html.max_pre_width = DocumentWidth(new, new->html.html_objects); - - /* - * Create the scrollbars. - * Find their dimensions and then decide which scrollbars you - * will need, and what the dimensions of the viewing area are. - * Start assuming a vertical scrollbar and a horizontal one. - * The remove vertical if short enough, and remove horizontal - * if narrow enough. - */ - CreateScrollbars(new); - new->html.scroll_x = 0; - new->html.scroll_y = 0; - ReformatWindow(new); - - /* - * Initialize private widget resources - */ - new->html.drawGC = NULL; - new->html.select_start = NULL; - new->html.select_end = NULL; - new->html.sel_start_pos = 0; - new->html.sel_end_pos = 0; - new->html.new_start = NULL; - new->html.new_end = NULL; - new->html.new_start_pos = 0; - new->html.new_end_pos = 0; - new->html.active_anchor = NULL; - new->html.press_x = 0; - new->html.press_y = 0; - - new->html.cached_tracked_ele = NULL; - - /* Initialize cursor used when pointer is inside anchor. */ - if (in_anchor_cursor == (Cursor)NULL) - in_anchor_cursor = XCreateFontCursor (XtDisplay (new), XC_hand2); - - return; -} - - -#ifdef DEBUG -void -DebugHook(x, y, width, height) - int x, y, width, height; -{ -/* -fprintf(stderr, "Redrawing (%d,%d) %dx%d\n", x, y, width, height); -*/ -} -#endif - - -/* - * This is called by redisplay. It is passed a rectangle - * in the viewing area, and it redisplays that portion of the - * underlying document area. - */ -static void -#ifdef _NO_PROTO -ViewRedisplay (hw, x, y, width, height) - HTMLWidget hw; - int x, y; - int width, height; -#else -ViewRedisplay( - HTMLWidget hw, - int x, - int y, - int width, - int height) -#endif -{ - int sx, sy; - int doc_x, doc_y; - int i, start, end, guess; - - /* - * Use scrollbar values to map from view space to document space. - */ - sx = sy = 0; - if (hw->html.use_vbar == True) - { - sy += hw->html.scroll_y; - } - if (hw->html.use_hbar == True) - { - sx += hw->html.scroll_x; - } - - doc_x = x + sx; - doc_y = y + sy; - - /* - * Find the lines that overlap the exposed area. - */ - start = 0; - end = hw->html.line_count - 1; - - /* - * Heuristic to speed up redraws by guessing at the starting line. - */ - guess = doc_y / (hw->html.font->max_bounds.ascent + - hw->html.font->max_bounds.descent); - if (guess > end) - { - guess = end; - } - while (guess > 0) - { - if ((hw->html.line_array[guess] != NULL)&& - (hw->html.line_array[guess]->y < doc_y)) - { - break; - } - guess--; - } - if (guess < start) - { - guess = start; - } - - for (i=guess; ihtml.line_count; i++) - { - if (hw->html.line_array[i] == NULL) - { - continue; - } - - if (hw->html.line_array[i]->y < doc_y) - { - start = i; - } - if (hw->html.line_array[i]->y > (doc_y + height)) - { - end = i; - break; - } - } - - /* - * If we have a GC draw the lines that overlap the exposed area. - */ - if (hw->html.drawGC != NULL) - { - for (i=start; i<=end; i++) - { - PlaceLine(hw, i); - } -#ifdef EXTRA_FLUSH - XFlush(XtDisplay(hw)); -#endif - } -} - - -static void -#ifdef _NO_PROTO -ViewClearAndRefresh (hw) - HTMLWidget hw; -#else -ViewClearAndRefresh( - HTMLWidget hw) -#endif -{ - /* - * Only refresh if we have a window already. - * (if we have a GC we have a window) - */ - if (hw->html.drawGC != NULL) - { - XClearArea(XtDisplay(hw->html.view), XtWindow(hw->html.view), - 0, 0, 0, 0, False); - ViewRedisplay(hw, 0, 0, - hw->html.view_width, hw->html.view_height); - /* - * This is a fake deal to make an Expose event tocall Redisplay - * to redraw the shadow around the view area - */ - XClearArea(XtDisplay(hw), XtWindow(hw), - 0, 0, 1, 1, True); - } -} - - -/* - * The Redisplay function is what you do with an expose event. - * Right now we call user callbacks, and then call the CompositeWidget's - * Redisplay routine. - */ -static void -#ifdef _NO_PROTO -Redisplay (hw, event, region) - HTMLWidget hw; - XEvent * event; - Region region; -#else -Redisplay( - HTMLWidget hw, - XEvent * event, - Region region) -#endif -{ - XExposeEvent *ExEvent = (XExposeEvent *)event; - int dx, dy; - -#ifdef MOTIF - /* - * find out where the shadow is based on scrollbars - */ - - Dimension st = hw->manager.shadow_thickness; -#endif /* MOTIF */ - - dx = dy = 0; - if ((hw->html.use_vbar == True)&&(hw->html.vbar_right == False)) - { - dx += VbarWidth(hw); - } - if ((hw->html.use_hbar == True)&&(hw->html.hbar_top == True)) - { - dy += HbarHeight(hw); - } - -#ifdef MOTIF - /* - * Redraw the shadow around the scrolling area which may have been - * messed up. - */ - _XmDrawShadow(XtDisplay(hw), XtWindow(hw), - hw->manager.bottom_shadow_GC, hw->manager.top_shadow_GC, - hw->manager.shadow_thickness, dx, dy, - hw->html.view_width + (2 * st),hw->html.view_height + (2 * st)); -#endif /* MOTIF */ - -#ifdef MOTIF -#ifdef MOTIF1_2 - _XmRedisplayGadgets ((Widget)hw, (XEvent*)event, region); -#else - _XmRedisplayGadgets ((CompositeWidget)hw, (XExposeEvent*)event, region); -#endif /* MOTIF1_2 */ -#endif /* MOTIF */ - - return; -} - - -/* - * Resize is called when the widget changes size. - * Mostly any resize causes a reformat, except for the special case - * where the width doesn't change, and the height doesn't change - * enought to affect the vertical scrollbar. - * It is too complex to guess exactly what needs to be redrawn, so refresh the - * whole window on any resize. - */ -static void -#ifdef _NO_PROTO -Resize (hw) - HTMLWidget hw; -#else -Resize( - HTMLWidget hw) -#endif -{ - int tempw; - Dimension swidth, sheight; - Dimension st; - - /* - * Find the new widht of the viewing area. - */ - swidth = VbarWidth(hw); - sheight = HbarHeight(hw); -#ifdef MOTIF - st = hw->manager.shadow_thickness; -#else - st = 0; -#endif /* MOTIF */ - if (hw->core.width <= swidth) - { - hw->core.width = swidth + 10 ; - } - - if (hw->html.use_vbar == True) - { - tempw = hw->core.width - swidth - (2 * st); - } - else - { - tempw = hw->core.width - (2 * st); - /* fool positioning of horz scrollbar later */ - swidth = 0; - } - - /* - * Special case where we don't have to reformat to a new width. - * The width has not changed, and the height has not changed - * significantly to change the state of the vertical scrollbar. - */ - if ((tempw == hw->html.view_width)&& - (((hw->html.use_vbar == True)&& - ((hw->core.height - sheight - (2 * st)) < hw->html.doc_height))|| - ((hw->html.use_vbar == False)&& - ((hw->core.height - sheight - (2 * st)) >= hw->html.doc_height)))) - { - /* - * Super special case where the size of the window hasn't - * changed at ALL! - */ - if (((hw->html.use_hbar == True)&&(hw->html.view_height == - (hw->core.height - sheight - (2 * st))))|| - ((hw->html.use_hbar == False)&&(hw->html.view_height == - (hw->core.height - (2 * st))))) - { - return; - } - - if (hw->html.use_hbar == True) - { - if (hw->html.hbar_top == True) - { - if (hw->html.vbar_right == True) - { - XtMoveWidget(hw->html.hbar, 0, 0); - } - else - { - XtMoveWidget(hw->html.hbar, swidth, 0); - } - } - else - { - if (hw->html.vbar_right == True) - { - XtMoveWidget(hw->html.hbar, 0, - (hw->core.height - sheight)); - } - else - { - XtMoveWidget(hw->html.hbar, swidth, - (hw->core.height - sheight)); - } - } - hw->html.view_height = hw->core.height - sheight - - (2 * st); - } - else - { - hw->html.view_height = hw->core.height - (2 * st); - } -#ifdef DEBUG -fprintf (stderr, "calling in Resize\n"); -#endif - ConfigScrollBars(hw); - ScrollWidgets(hw); - ViewClearAndRefresh(hw); - } - /* - * Otherwise we have to do a full reformat on every resize. - */ - else - { - ReformatWindow(hw); - ScrollWidgets(hw); - ViewClearAndRefresh(hw); - } - -#ifdef DEBUG - { - int ss; -XtVaGetValues(hw->html.vbar, XmNsliderSize, &ss, NULL); -fprintf (stderr, "leaving; slider size %d\n", ss); - } -#endif - - return; -} - - -/* - * Find the complete text for this the anchor that aptr is a part of - * and set it into the selection. - */ -static void -FindSelectAnchor(hw, aptr) - HTMLWidget hw; - struct ele_rec *aptr; -{ - struct ele_rec *eptr; - - eptr = aptr; - while ((eptr->prev != NULL)&& - (eptr->prev->anchorHRef != NULL)&& - (strcmp(eptr->prev->anchorHRef, eptr->anchorHRef) == 0)) - { - eptr = eptr->prev; - } - hw->html.select_start = eptr; - hw->html.sel_start_pos = 0; - - eptr = aptr; - while ((eptr->next != NULL)&& - (eptr->next->anchorHRef != NULL)&& - (strcmp(eptr->next->anchorHRef, eptr->anchorHRef) == 0)) - { - eptr = eptr->next; - } - hw->html.select_end = eptr; - hw->html.sel_end_pos = eptr->edata_len - 2; -} - - -/* - * Set as active all elements in the widget that are part of the anchor - * in the widget's start ptr. - */ -static void -SetAnchor(hw) - HTMLWidget hw; -{ - struct ele_rec *eptr; - struct ele_rec *start; - struct ele_rec *end; - unsigned long fg, bg; - unsigned long old_fg, old_bg; - - eptr = hw->html.active_anchor; - if ((eptr == NULL)||(eptr->anchorHRef == NULL)) - { - return; - } - fg = hw->html.activeAnchor_fg; - bg = hw->html.activeAnchor_bg; - - FindSelectAnchor(hw, eptr); - - start = hw->html.select_start; - end = hw->html.select_end; - - eptr = start; - while ((eptr != NULL)&&(eptr != end)) - { - if (eptr->type == E_TEXT) - { - old_fg = eptr->fg; - old_bg = eptr->bg; - eptr->fg = fg; - eptr->bg = bg; - TextRefresh(hw, eptr, - 0, (eptr->edata_len - 2)); - eptr->fg = old_fg; - eptr->bg = old_bg; - } - else if (eptr->type == E_IMAGE) - { - old_fg = eptr->fg; - old_bg = eptr->bg; - eptr->fg = fg; - eptr->bg = bg; - ImageRefresh(hw, eptr); - eptr->fg = old_fg; - eptr->bg = old_bg; - } - /* - * Linefeeds in anchor spanning multiple lines should NOT - * be highlighted! - else if (eptr->type == E_LINEFEED) - { - old_fg = eptr->fg; - old_bg = eptr->bg; - eptr->fg = fg; - eptr->bg = bg; - LinefeedRefresh(hw, eptr); - eptr->fg = old_fg; - eptr->bg = old_bg; - } - */ - eptr = eptr->next; - } - if (eptr != NULL) - { - if (eptr->type == E_TEXT) - { - old_fg = eptr->fg; - old_bg = eptr->bg; - eptr->fg = fg; - eptr->bg = bg; - TextRefresh(hw, eptr, - 0, (eptr->edata_len - 2)); - eptr->fg = old_fg; - eptr->bg = old_bg; - } - else if (eptr->type == E_IMAGE) - { - old_fg = eptr->fg; - old_bg = eptr->bg; - eptr->fg = fg; - eptr->bg = bg; - ImageRefresh(hw, eptr); - eptr->fg = old_fg; - eptr->bg = old_bg; - } - /* - * Linefeeds in anchor spanning multiple lines should NOT - * be highlighted! - else if (eptr->type == E_LINEFEED) - { - old_fg = eptr->fg; - old_bg = eptr->bg; - eptr->fg = fg; - eptr->bg = bg; - LinefeedRefresh(hw, eptr); - eptr->fg = old_fg; - eptr->bg = old_bg; - } - */ - } -} - - -/* - * Draw selection for all elements in the widget - * from start to end. - */ -static void -DrawSelection(hw, start, end, start_pos, end_pos) - HTMLWidget hw; - struct ele_rec *start; - struct ele_rec *end; - int start_pos, end_pos; -{ - struct ele_rec *eptr; - int epos; - - if ((start == NULL)||(end == NULL)) - { - return; - } - - /* - * Keep positions within bounds (allows us to be sloppy elsewhere) - */ - if (start_pos < 0) - { - start_pos = 0; - } - if (start_pos >= start->edata_len - 1) - { - start_pos = start->edata_len - 2; - } - if (end_pos < 0) - { - end_pos = 0; - } - if (end_pos >= end->edata_len - 1) - { - end_pos = end->edata_len - 2; - } - - if (SwapElements(start, end, start_pos, end_pos)) - { - eptr = start; - start = end; - end = eptr; - epos = start_pos; - start_pos = end_pos; - end_pos = epos; - } - - eptr = start; - while ((eptr != NULL)&&(eptr != end)) - { - int p1, p2; - - if (eptr == start) - { - p1 = start_pos; - } - else - { - p1 = 0; - } - p2 = eptr->edata_len - 2; - - if (eptr->type == E_TEXT) - { - eptr->selected = True; - eptr->start_pos = p1; - eptr->end_pos = p2; - TextRefresh(hw, eptr, p1, p2); - } - else if (eptr->type == E_LINEFEED) - { - eptr->selected = True; - LinefeedRefresh(hw, eptr); - } - eptr = eptr->next; - } - if (eptr != NULL) - { - int p1, p2; - - if (eptr == start) - { - p1 = start_pos; - } - else - { - p1 = 0; - } - - if (eptr == end) - { - p2 = end_pos; - } - else - { - p2 = eptr->edata_len - 2; - } - - if (eptr->type == E_TEXT) - { - eptr->selected = True; - eptr->start_pos = p1; - eptr->end_pos = p2; - TextRefresh(hw, eptr, p1, p2); - } - else if (eptr->type == E_LINEFEED) - { - eptr->selected = True; - LinefeedRefresh(hw, eptr); - } - } -} - - -/* - * Set selection for all elements in the widget's - * start to end list. - */ -static void -SetSelection(hw) - HTMLWidget hw; -{ - struct ele_rec *start; - struct ele_rec *end; - int start_pos, end_pos; - - start = hw->html.select_start; - end = hw->html.select_end; - start_pos = hw->html.sel_start_pos; - end_pos = hw->html.sel_end_pos; - DrawSelection(hw, start, end, start_pos, end_pos); -} - - -/* - * Erase the selection from start to end - */ -static void -EraseSelection(hw, start, end, start_pos, end_pos) - HTMLWidget hw; - struct ele_rec *start; - struct ele_rec *end; - int start_pos, end_pos; -{ - struct ele_rec *eptr; - int epos; - - if ((start == NULL)||(end == NULL)) - { - return; - } - - /* - * Keep positoins within bounds (allows us to be sloppy elsewhere) - */ - if (start_pos < 0) - { - start_pos = 0; - } - if (start_pos >= start->edata_len - 1) - { - start_pos = start->edata_len - 2; - } - if (end_pos < 0) - { - end_pos = 0; - } - if (end_pos >= end->edata_len - 1) - { - end_pos = end->edata_len - 2; - } - - if (SwapElements(start, end, start_pos, end_pos)) - { - eptr = start; - start = end; - end = eptr; - epos = start_pos; - start_pos = end_pos; - end_pos = epos; - } - - eptr = start; - while ((eptr != NULL)&&(eptr != end)) - { - int p1, p2; - - if (eptr == start) - { - p1 = start_pos; - } - else - { - p1 = 0; - } - p2 = eptr->edata_len - 2; - - if (eptr->type == E_TEXT) - { - eptr->selected = False; - TextRefresh(hw, eptr, p1, p2); - } - else if (eptr->type == E_LINEFEED) - { - eptr->selected = False; - LinefeedRefresh(hw, eptr); - } - eptr = eptr->next; - } - if (eptr != NULL) - { - int p1, p2; - - if (eptr == start) - { - p1 = start_pos; - } - else - { - p1 = 0; - } - - if (eptr == end) - { - p2 = end_pos; - } - else - { - p2 = eptr->edata_len - 2; - } - - if (eptr->type == E_TEXT) - { - eptr->selected = False; - TextRefresh(hw, eptr, p1, p2); - } - else if (eptr->type == E_LINEFEED) - { - eptr->selected = False; - LinefeedRefresh(hw, eptr); - } - } -} - - -/* - * Clear the current selection (if there is one) - */ -static void -ClearSelection(hw) - HTMLWidget hw; -{ - struct ele_rec *start; - struct ele_rec *end; - int start_pos, end_pos; - - start = hw->html.select_start; - end = hw->html.select_end; - start_pos = hw->html.sel_start_pos; - end_pos = hw->html.sel_end_pos; - EraseSelection(hw, start, end, start_pos, end_pos); - - if ((start == NULL)||(end == NULL)) - { - hw->html.select_start = NULL; - hw->html.select_end = NULL; - hw->html.sel_start_pos = 0; - hw->html.sel_end_pos = 0; - hw->html.active_anchor = NULL; - return; - } - - hw->html.select_start = NULL; - hw->html.select_end = NULL; - hw->html.sel_start_pos = 0; - hw->html.sel_end_pos = 0; - hw->html.active_anchor = NULL; -} - - -/* - * clear from active all elements in the widget that are part of the anchor. - * (These have already been previously set into the start and end of the - * selection. - */ -static void -UnsetAnchor(hw) - HTMLWidget hw; -{ - struct ele_rec *eptr; - - /* - * Clear any activated images - */ - eptr = hw->html.select_start; - while ((eptr != NULL)&&(eptr != hw->html.select_end)) - { - if (eptr->type == E_IMAGE) - { - ImageRefresh(hw, eptr); - } - eptr = eptr->next; - } - if ((eptr != NULL)&&(eptr->type == E_IMAGE)) - { - ImageRefresh(hw, eptr); - } - - /* - * Clear the activated anchor - */ - ClearSelection(hw); -} - - -/* - * Erase the old selection, and draw the new one in such a way - * that advantage is taken of overlap, and there is no obnoxious - * flashing. - */ -static void -ChangeSelection(hw, start, end, start_pos, end_pos) - HTMLWidget hw; - struct ele_rec *start; - struct ele_rec *end; - int start_pos, end_pos; -{ - struct ele_rec *old_start; - struct ele_rec *old_end; - struct ele_rec *new_start; - struct ele_rec *new_end; - struct ele_rec *eptr; - int epos; - int new_start_pos, new_end_pos; - int old_start_pos, old_end_pos; - - old_start = hw->html.new_start; - old_end = hw->html.new_end; - old_start_pos = hw->html.new_start_pos; - old_end_pos = hw->html.new_end_pos; - new_start = start; - new_end = end; - new_start_pos = start_pos; - new_end_pos = end_pos; - - if ((new_start == NULL)||(new_end == NULL)) - { - return; - } - - if ((old_start == NULL)||(old_end == NULL)) - { - DrawSelection(hw, new_start, new_end, - new_start_pos, new_end_pos); - return; - } - - if (SwapElements(old_start, old_end, old_start_pos, old_end_pos)) - { - eptr = old_start; - old_start = old_end; - old_end = eptr; - epos = old_start_pos; - old_start_pos = old_end_pos; - old_end_pos = epos; - } - - if (SwapElements(new_start, new_end, new_start_pos, new_end_pos)) - { - eptr = new_start; - new_start = new_end; - new_end = eptr; - epos = new_start_pos; - new_start_pos = new_end_pos; - new_end_pos = epos; - } - - /* - * Deal with all possible intersections of the 2 selection sets. - * - ******************************************************** - * * * - * |-- * |-- * - * old--| * new--| * - * |-- * |-- * - * * * - * |-- * |-- * - * new--| * old--| * - * |-- * |-- * - * * * - ******************************************************** - * * * - * |---- * |-- * - * old--| * new--| * - * | |-- * | * - * |-+-- * |-+-- * - * | * | |-- * - * new--| * old--| * - * |-- * |---- * - * * * - ******************************************************** - * * * - * |--------- * |--------- * - * | * | * - * | |-- * | |-- * - * new--| old--| * old--| new--| * - * | |-- * | |-- * - * | * | * - * |--------- * |--------- * - * * * - ******************************************************** - * - */ - if ((ElementLessThan(old_end, new_start, old_end_pos, new_start_pos))|| - (ElementLessThan(new_end, old_start, new_end_pos, old_start_pos))) - { - EraseSelection(hw, old_start, old_end, - old_start_pos, old_end_pos); - DrawSelection(hw, new_start, new_end, - new_start_pos, new_end_pos); - } - else if ((ElementLessThan(old_start, new_start, - old_start_pos, new_start_pos))&& - (ElementLessThan(old_end, new_end, old_end_pos, new_end_pos))) - { - if (new_start_pos != 0) - { - EraseSelection(hw, old_start, new_start, - old_start_pos, new_start_pos - 1); - } - else - { - EraseSelection(hw, old_start, new_start->prev, - old_start_pos, new_start->prev->edata_len - 2); - } - if (old_end_pos < (old_end->edata_len - 2)) - { - DrawSelection(hw, old_end, new_end, - old_end_pos + 1, new_end_pos); - } - else - { - DrawSelection(hw, old_end->next, new_end, - 0, new_end_pos); - } - } - else if ((ElementLessThan(new_start, old_start, - new_start_pos, old_start_pos))&& - (ElementLessThan(new_end, old_end, new_end_pos, old_end_pos))) - { - if (old_start_pos != 0) - { - DrawSelection(hw, new_start, old_start, - new_start_pos, old_start_pos - 1); - } - else - { - DrawSelection(hw, new_start, old_start->prev, - new_start_pos, old_start->prev->edata_len - 2); - } - if (new_end_pos < (new_end->edata_len - 2)) - { - EraseSelection(hw, new_end, old_end, - new_end_pos + 1, old_end_pos); - } - else - { - EraseSelection(hw, new_end->next, old_end, - 0, old_end_pos); - } - } - else if ((ElementLessThan(new_start, old_start, - new_start_pos, old_start_pos))|| - (ElementLessThan(old_end, new_end, old_end_pos, new_end_pos))) - { - if ((new_start != old_start)||(new_start_pos != old_start_pos)) - { - if (old_start_pos != 0) - { - DrawSelection(hw, new_start, old_start, - new_start_pos, old_start_pos - 1); - } - else - { - DrawSelection(hw, new_start, old_start->prev, - new_start_pos, - old_start->prev->edata_len - 2); - } - } - if ((old_end != new_end)||(old_end_pos != new_end_pos)) - { - if (old_end_pos < (old_end->edata_len - 2)) - { - DrawSelection(hw, old_end, new_end, - old_end_pos + 1, new_end_pos); - } - else - { - DrawSelection(hw, old_end->next, new_end, - 0, new_end_pos); - } - } - } - else - { - if ((old_start != new_start)||(old_start_pos != new_start_pos)) - { - if (new_start_pos != 0) - { - EraseSelection(hw, old_start, new_start, - old_start_pos, new_start_pos - 1); - } - else - { - EraseSelection(hw, old_start, new_start->prev, - old_start_pos, - new_start->prev->edata_len - 2); - } - } - if ((new_end != old_end)||(new_end_pos != old_end_pos)) - { - if (new_end_pos < (new_end->edata_len - 2)) - { - EraseSelection(hw, new_end, old_end, - new_end_pos + 1, old_end_pos); - } - else - { - EraseSelection(hw, new_end->next, old_end, - 0, old_end_pos); - } - } - } -} - - -static void -SelectStart(w, event, params, num_params) - Widget w; - XEvent *event; - String *params; /* unused */ - Cardinal *num_params; /* unused */ -{ - HTMLWidget hw = (HTMLWidget)XtParent(w); - XButtonPressedEvent *BuEvent = (XButtonPressedEvent *)event; - struct ele_rec *eptr; - int epos; - - if (XtClass(XtParent(w)) != htmlWidgetClass) - { - return; - } - -#ifdef NOT_RIGHT - XUndefineCursor(XtDisplay(hw->html.view), XtWindow(hw->html.view)); -#endif - XUndefineCursor(XtDisplay(hw), XtWindow(hw)); - - /* - * Because X sucks, we can get the button pressed in the window, but - * released out of the window. This will highlight some text, but - * never complete the selection. Now on the next button press we - * have to clean up this mess. - */ - EraseSelection(hw, hw->html.new_start, hw->html.new_end, - hw->html.new_start_pos, hw->html.new_end_pos); - - /* - * We want to erase the currently selected text, but still save the - * selection internally in case we don't create a new one. - */ - EraseSelection(hw, hw->html.select_start, hw->html.select_end, - hw->html.sel_start_pos, hw->html.sel_end_pos); - hw->html.new_start = hw->html.select_start; - hw->html.new_end = NULL; - hw->html.new_start_pos = hw->html.sel_start_pos; - hw->html.new_end_pos = 0; - - eptr = LocateElement(hw, BuEvent->x, BuEvent->y, &epos); - if (eptr != NULL) - { - /* - * If this is an anchor assume for now we are activating it - * and not selecting it. - */ - if (eptr->anchorHRef != NULL) - { - hw->html.active_anchor = eptr; - hw->html.press_x = BuEvent->x; - hw->html.press_y = BuEvent->y; - SetAnchor(hw); - } - /* - * Else if we are on an image we can't select text so - * pretend we got eptr==NULL, and exit here. - */ - else if (eptr->type == E_IMAGE) - { - hw->html.new_start = NULL; - hw->html.new_end = NULL; - hw->html.new_start_pos = 0; - hw->html.new_end_pos = 0; - hw->html.press_x = BuEvent->x; - hw->html.press_y = BuEvent->y; - hw->html.but_press_time = BuEvent->time; - return; - } - /* - * Else if we used button2, we can't select text, so exit - * here. - */ - else if (BuEvent->button == Button2) - { - hw->html.press_x = BuEvent->x; - hw->html.press_y = BuEvent->y; - hw->html.but_press_time = BuEvent->time; - return; - } - /* - * Else a single click will not select a new object - * but it will prime that selection on the next mouse - * move. - * Ignore special internal text - */ - else if (eptr->internal == False) - { - hw->html.new_start = eptr; - hw->html.new_start_pos = epos; - hw->html.new_end = NULL; - hw->html.new_end_pos = 0; - hw->html.press_x = BuEvent->x; - hw->html.press_y = BuEvent->y; - } - else - { - hw->html.new_start = NULL; - hw->html.new_end = NULL; - hw->html.new_start_pos = 0; - hw->html.new_end_pos = 0; - hw->html.press_x = BuEvent->x; - hw->html.press_y = BuEvent->y; - } - } - else - { - hw->html.new_start = NULL; - hw->html.new_end = NULL; - hw->html.new_start_pos = 0; - hw->html.new_end_pos = 0; - hw->html.press_x = BuEvent->x; - hw->html.press_y = BuEvent->y; - } - hw->html.but_press_time = BuEvent->time; -} - - -static void -ExtendStart(w, event, params, num_params) - Widget w; - XEvent *event; - String *params; /* unused */ - Cardinal *num_params; /* unused */ -{ - HTMLWidget hw = (HTMLWidget)XtParent(w); - XButtonPressedEvent *BuEvent = (XButtonPressedEvent *)event; - struct ele_rec *eptr; - struct ele_rec *start, *end; - struct ele_rec *old_start, *old_end; - int old_start_pos, old_end_pos; - int start_pos, end_pos; - int epos; - - if (XtClass(XtParent(w)) != htmlWidgetClass) - { - return; - } - - eptr = LocateElement(hw, BuEvent->x, BuEvent->y, &epos); - - /* - * Ignore IMAGE elements. - */ - if ((eptr != NULL)&&(eptr->type == E_IMAGE)) - { - eptr = NULL; - } - - /* - * Ignore NULL elements. - * Ignore special internal text - * documents. - */ - if ((eptr != NULL)&&(eptr->internal == False)) - { - old_start = hw->html.new_start; - old_start_pos = hw->html.new_start_pos; - old_end = hw->html.new_end; - old_end_pos = hw->html.new_end_pos; - if (hw->html.new_start == NULL) - { - hw->html.new_start = hw->html.select_start; - hw->html.new_start_pos = hw->html.sel_start_pos; - hw->html.new_end = hw->html.select_end; - hw->html.new_end_pos = hw->html.sel_end_pos; - } - else - { - hw->html.new_end = eptr; - hw->html.new_end_pos = epos; - } - - if (SwapElements(hw->html.new_start, hw->html.new_end, - hw->html.new_start_pos, hw->html.new_end_pos)) - { - if (SwapElements(eptr, hw->html.new_end, - epos, hw->html.new_end_pos)) - { - start = hw->html.new_end; - start_pos = hw->html.new_end_pos; - end = eptr; - end_pos = epos; - } - else - { - start = hw->html.new_start; - start_pos = hw->html.new_start_pos; - end = eptr; - end_pos = epos; - } - } - else - { - if (SwapElements(eptr, hw->html.new_start, - epos, hw->html.new_start_pos)) - { - start = hw->html.new_start; - start_pos = hw->html.new_start_pos; - end = eptr; - end_pos = epos; - } - else - { - start = hw->html.new_end; - start_pos = hw->html.new_end_pos; - end = eptr; - end_pos = epos; - } - } - - if (start == NULL) - { - start = eptr; - start_pos = epos; - } - - if (old_start == NULL) - { - hw->html.new_start = hw->html.select_start; - hw->html.new_end = hw->html.select_end; - hw->html.new_start_pos = hw->html.sel_start_pos; - hw->html.new_end_pos = hw->html.sel_end_pos; - } - else - { - hw->html.new_start = old_start; - hw->html.new_end = old_end; - hw->html.new_start_pos = old_start_pos; - hw->html.new_end_pos = old_end_pos; - } - ChangeSelection(hw, start, end, start_pos, end_pos); - hw->html.new_start = start; - hw->html.new_end = end; - hw->html.new_start_pos = start_pos; - hw->html.new_end_pos = end_pos; - } - else - { - if (hw->html.new_start == NULL) - { - hw->html.new_start = hw->html.select_start; - hw->html.new_start_pos = hw->html.sel_start_pos; - hw->html.new_end = hw->html.select_end; - hw->html.new_end_pos = hw->html.sel_end_pos; - } - } - hw->html.press_x = BuEvent->x; - hw->html.press_y = BuEvent->y; -} - - -static void -ExtendAdjust(w, event, params, num_params) - Widget w; - XEvent *event; - String *params; /* unused */ - Cardinal *num_params; /* unused */ -{ - HTMLWidget hw = (HTMLWidget)XtParent(w); - XPointerMovedEvent *MoEvent = (XPointerMovedEvent *)event; - struct ele_rec *eptr; - struct ele_rec *start, *end; - int start_pos, end_pos; - int epos; - - if (XtClass(XtParent(w)) != htmlWidgetClass) - { - return; - } - - /* - * Very small mouse motion immediately after button press - * is ignored. - */ - if ((ABS((hw->html.press_x - MoEvent->x)) <= SELECT_THRESHOLD)&& - (ABS((hw->html.press_y - MoEvent->y)) <= SELECT_THRESHOLD)) - { - return; - } - - /* - * If we have an active anchor and we got here, we have moved the - * mouse too far. Deactivate anchor, and prime a selection. - * If the anchor is internal text, don't - * prime a selection. - */ - if (hw->html.active_anchor != NULL) - { - eptr = hw->html.active_anchor; - UnsetAnchor(hw); - if (eptr->internal == False) - { - hw->html.new_start = NULL; - hw->html.new_start_pos = 0; - hw->html.new_end = NULL; - hw->html.new_end_pos = 0; - } - } - - /* - * If we used button2, we can't select text, so - * clear selection and exit here. - */ - if ((MoEvent->state & Button2Mask) != 0) - { - hw->html.select_start = NULL; - hw->html.select_end = NULL; - hw->html.sel_start_pos = 0; - hw->html.sel_end_pos = 0; - hw->html.new_start = NULL; - hw->html.new_end = NULL; - hw->html.new_start_pos = 0; - hw->html.new_end_pos = 0; - return; - } - - eptr = LocateElement(hw, MoEvent->x, MoEvent->y, &epos); - - /* - * If we are on an image pretend we are nowhere - * and just return; - */ - if ((eptr != NULL)&&(eptr->type == E_IMAGE)) - { - return; - } - - /* - * Ignore NULL items. - * Ignore if the same as last selected item and position. - * Ignore special internal text - */ - if ((eptr != NULL)&& - ((eptr != hw->html.new_end)||(epos != hw->html.new_end_pos))&& - (eptr->internal == False)) - { - start = hw->html.new_start; - start_pos = hw->html.new_start_pos; - end = eptr; - end_pos = epos; - if (start == NULL) - { - start = eptr; - start_pos = epos; - } - - ChangeSelection(hw, start, end, start_pos, end_pos); - hw->html.new_start = start; - hw->html.new_end = end; - hw->html.new_start_pos = start_pos; - hw->html.new_end_pos = end_pos; - } -} - - -static void -ExtendEnd(w, event, params, num_params) - Widget w; - XEvent *event; - String *params; - Cardinal *num_params; -{ - HTMLWidget hw = (HTMLWidget)XtParent(w); - XButtonReleasedEvent *BuEvent = (XButtonReleasedEvent *)event; - struct ele_rec *eptr; - struct ele_rec *start, *end; - Atom *atoms; - int i, buffer; - int start_pos, end_pos; - int epos; - char *text; - - if (XtClass(XtParent(w)) != htmlWidgetClass) - { - return; - } - - eptr = LocateElement(hw, BuEvent->x, BuEvent->y, &epos); - - /* - * If we just released button one or two, and we are on an object, - * and we have an active anchor, and we are on the active anchor, - * and if we havn't waited too long. Activate that anchor. - */ - if (((BuEvent->button == Button1)||(BuEvent->button == Button2))&& - (eptr != NULL)&& - (hw->html.active_anchor != NULL)&& - (eptr == hw->html.active_anchor)&& - ((BuEvent->time - hw->html.but_press_time) < CLICK_TIME)) - { - _HTMLInput(w, event, params, num_params); - return; - } - else if (hw->html.active_anchor != NULL) - { - start = hw->html.active_anchor; - UnsetAnchor(hw); - if (start->internal == False) - { - hw->html.new_start = eptr; - hw->html.new_start_pos = epos; - hw->html.new_end = NULL; - hw->html.new_end_pos = 0; - } - } - - /* - * If we used button2, we can't select text, so clear - * selection and exit here. - */ - if (BuEvent->button == Button2) - { - hw->html.new_start = hw->html.select_start; - hw->html.new_end = NULL; - hw->html.new_start_pos = hw->html.sel_start_pos; - hw->html.new_end_pos = 0; - return; - } - - /* - * If we are on an image, pretend we are nowhere - * and NULL out the eptr - */ - if ((eptr != NULL)&&(eptr->type == E_IMAGE)) - { - eptr = NULL; - } - - /* - * If button released on a NULL item, take the last non-NULL - * item that we highlighted. - */ - if ((eptr == NULL)&&(hw->html.new_end != NULL)) - { - eptr = hw->html.new_end; - epos = hw->html.new_end_pos; - } - - if ((eptr != NULL)&&(eptr->internal == False)&& - (hw->html.new_end != NULL)) - { - start = hw->html.new_start; - start_pos = hw->html.new_start_pos; - end = eptr; - end_pos = epos; - if (start == NULL) - { - start = eptr; - start_pos = epos; - } - ChangeSelection(hw, start, end, start_pos, end_pos); - hw->html.select_start = start; - hw->html.sel_start_pos = start_pos; - hw->html.select_end = end; - hw->html.sel_end_pos = end_pos; - SetSelection(hw); - hw->html.new_start = NULL; - hw->html.new_end = NULL; - hw->html.new_start_pos = 0; - hw->html.new_end_pos = 0; - - atoms = (Atom *)malloc(*num_params * sizeof(Atom)); - if (atoms == NULL) - { - fprintf(stderr, "cannot allocate atom list\n"); - return; - } - XmuInternStrings(XtDisplay((Widget)hw), params, *num_params, atoms); - hw->html.selection_time = BuEvent->time; - for (i=0; i< *num_params; i++) - { - switch (atoms[i]) - { - case XA_CUT_BUFFER0: buffer = 0; break; - case XA_CUT_BUFFER1: buffer = 1; break; - case XA_CUT_BUFFER2: buffer = 2; break; - case XA_CUT_BUFFER3: buffer = 3; break; - case XA_CUT_BUFFER4: buffer = 4; break; - case XA_CUT_BUFFER5: buffer = 5; break; - case XA_CUT_BUFFER6: buffer = 6; break; - case XA_CUT_BUFFER7: buffer = 7; break; - default: buffer = -1; break; - } - if (buffer >= 0) - { - if (hw->html.fancy_selections == True) - { - text = ParseTextToPrettyString(hw, - hw->html.formatted_elements, - hw->html.select_start, - hw->html.select_end, - hw->html.sel_start_pos, - hw->html.sel_end_pos, - hw->html.font->max_bounds.width, - hw->html.margin_width); - } - else - { - text = ParseTextToString( - hw->html.formatted_elements, - hw->html.select_start, - hw->html.select_end, - hw->html.sel_start_pos, - hw->html.sel_end_pos, - hw->html.font->max_bounds.width, - hw->html.margin_width); - } - XStoreBuffer(XtDisplay((Widget)hw), - text, strlen(text), buffer); - if (text != NULL) - { - free(text); - } - } - else - { - XtOwnSelection((Widget)hw, atoms[i], - BuEvent->time, - (XtConvertSelectionProc )ConvertSelection, - (XtLoseSelectionProc )LoseSelection, - (XtSelectionDoneProc )SelectionDone); - } - } - free((char *)atoms); - } - else if (eptr == NULL) - { - hw->html.select_start = NULL; - hw->html.sel_start_pos = 0; - hw->html.select_end = NULL; - hw->html.sel_end_pos = 0; - hw->html.new_start = NULL; - hw->html.new_start_pos = 0; - hw->html.new_end = NULL; - hw->html.new_end_pos = 0; - } -} - - -#define LEAVING_ANCHOR(hw) \ - hw->html.cached_tracked_ele = NULL; \ - (*(pointerTrackProc) \ - (hw->html.pointer_motion_callback))(hw, ""); \ - XUndefineCursor (XtDisplay (hw), XtWindow (hw)); - -/* KNOWN PROBLEM: We never get LeaveNotify or FocusOut events, - despite the fact we've requested them. Bummer. */ -static void -TrackMotion(w, event, params, num_params) - Widget w; - XEvent *event; - String *params; /* unused */ - Cardinal *num_params; /* unused */ -{ - HTMLWidget hw = (HTMLWidget)XtParent(w); - struct ele_rec *eptr; - int epos, x, y; - - if (XtClass(XtParent(w)) != htmlWidgetClass) - { - return; - } - - if (!hw->html.pointer_motion_callback) - return; - - if (event->type == MotionNotify) - { - x = ((XMotionEvent *)event)->x; - y = ((XMotionEvent *)event)->y; - } - else if (event->type == LeaveNotify || event->type == FocusOut || - event->type == Expose) - { - /* Wipe out. */ - if (hw->html.cached_tracked_ele) - { - LEAVING_ANCHOR (hw); - } - return; - } - else - { - return; - } - - eptr = LocateElement(hw, x, y, &epos); - - /* We're hitting a new anchor if eptr exists and - eptr != cached tracked element and anchorHRef != NULL. */ - if (eptr != NULL && eptr != hw->html.cached_tracked_ele && - eptr->anchorHRef != NULL) - { - hw->html.cached_tracked_ele = eptr; - (*(pointerTrackProc) - (hw->html.pointer_motion_callback))(hw, eptr->anchorHRef); - XDefineCursor (XtDisplay (hw), XtWindow (hw), in_anchor_cursor); - } - /* We're leaving an anchor if eptr exists and - a cached ele exists and we're not entering a new anchor. */ - else if (eptr != NULL && hw->html.cached_tracked_ele != NULL && - eptr->anchorHRef == NULL) - { - LEAVING_ANCHOR (hw); - } - - return; -} - - -/* - * Process mouse input to the HTML widget - * Currently only processes an anchor-activate when Button1 - * is pressed - */ -static void -#ifdef _NO_PROTO -_HTMLInput( w, event, params, num_params) - Widget w ; - XEvent *event ; - String *params; /* unused */ - Cardinal *num_params; /* unused */ -#else -_HTMLInput( - Widget w, - XEvent *event, - String *params, /* unused */ - Cardinal *num_params) /* unused */ -#endif -{ - HTMLWidget hw = (HTMLWidget)XtParent(w); - struct ele_rec *eptr; - WbAnchorCallbackData cbdata; - int epos; -#ifdef MOTIF - Boolean on_gadget; -#endif /* MOTIF */ - - if (XtClass(XtParent(w)) != htmlWidgetClass) - { - return; - } - -#ifdef MOTIF - /* - * If motif is defined, we don't want to process this button press - * if it is on a gadget - */ -#ifdef MOTIF1_2 - on_gadget = (_XmInputForGadget((Widget)hw, -#else - on_gadget = (_XmInputForGadget((CompositeWidget)hw, -#endif /* MOTIF1_2 */ - event->xbutton.x, event->xbutton.y) != NULL); - - if (on_gadget) - { - return; - } -#endif /* MOTIF */ - - if (event->type == ButtonRelease) - { - eptr = LocateElement(hw, event->xbutton.x, event->xbutton.y, - &epos); - if (eptr != NULL) - { - if (eptr->anchorHRef != NULL) - { - char *tptr, *ptr; - - /* - * Save the anchor text, replace newlines with - * spaces. - */ - tptr = ParseTextToString(hw->html.select_start, - hw->html.select_start, hw->html.select_end, - hw->html.sel_start_pos, hw->html.sel_end_pos, - hw->html.font->max_bounds.width, - hw->html.margin_width); - ptr = tptr; - while ((ptr != NULL)&&(*ptr != '\0')) - { - if (*ptr == '\n') - { - *ptr = ' '; - } - ptr++; - } - - /* - * Clear the activated anchor - */ - UnsetAnchor(hw); -#ifdef EXTRA_FLUSH - XFlush(XtDisplay(hw)); -#endif - - if ((IsDelayedHRef(hw, eptr->anchorHRef))&& - (hw->html.resolveDelayedImage != NULL)) - { - eptr->pic_data = (*(resolveImageProc) - (hw->html.resolveDelayedImage))(hw, eptr->edata); - - if (eptr->pic_data == NULL) - { - eptr->pic_data = NoImageData(hw); - eptr->pic_data->delayed = 0; - eptr->pic_data->internal = 0; - } - else - { - eptr->pic_data->delayed = 0; - /* - * Mark images we have sucessfully - * loaded at least once - */ - if (eptr->pic_data->image_data != NULL) - { - eptr->pic_data->fetched = 1; - } - /* - * See if this is a special - * internal image - */ - if ((eptr->edata != NULL)&& - (strncmp(eptr->edata, - INTERNAL_IMAGE, - strlen(INTERNAL_IMAGE)) == 0)) - { - eptr->pic_data->internal = 1; - } - else - { - eptr->pic_data->internal = 0; - } - } - - ReformatWindow(hw); - ScrollWidgets(hw); - ViewClearAndRefresh(hw); - } - else if ((eptr->pic_data != NULL)&& - (eptr->pic_data->delayed)&& - (eptr->anchorHRef != NULL)&& - (IsIsMapForm(hw, eptr->anchorHRef))) - { - eptr->pic_data = (*(resolveImageProc) - (hw->html.resolveDelayedImage))(hw, eptr->edata); - - if (eptr->pic_data == NULL) - { - eptr->pic_data = NoImageData(hw); - eptr->pic_data->delayed = 0; - eptr->pic_data->internal = 0; - } - else - { - eptr->pic_data->delayed = 0; - /* - * Mark images we have sucessfully - * loaded at least once - */ - if (eptr->pic_data->image_data != NULL) - { - eptr->pic_data->fetched = 1; - } - /* - * See if this is a special - * internal image - */ - if ((eptr->edata != NULL)&& - (strncmp(eptr->edata, - INTERNAL_IMAGE, - strlen(INTERNAL_IMAGE)) == 0)) - { - eptr->pic_data->internal = 1; - } - else - { - eptr->pic_data->internal = 0; - } - } - - ReformatWindow(hw); - ScrollWidgets(hw); - ViewClearAndRefresh(hw); - } - else if ((eptr->pic_data != NULL)&& - (eptr->pic_data->delayed)&& - (eptr->anchorHRef != NULL)&& - (!IsDelayedHRef(hw, eptr->anchorHRef))&& - (!IsIsMapForm(hw, eptr->anchorHRef))&& - (((event->xbutton.y + hw->html.scroll_y) - - (eptr->y + eptr->y_offset)) > - AnchoredHeight(hw))) - { - eptr->pic_data = (*(resolveImageProc) - (hw->html.resolveDelayedImage))(hw, eptr->edata); - - if (eptr->pic_data == NULL) - { - eptr->pic_data = NoImageData(hw); - eptr->pic_data->delayed = 0; - eptr->pic_data->internal = 0; - } - else - { - /* - * Mark images we have sucessfully - * loaded at least once - */ - if (eptr->pic_data->image_data != NULL) - { - eptr->pic_data->fetched = 1; - } - /* - * See if this is a special - * internal image - */ - if ((eptr->edata != NULL)&& - (strncmp(eptr->edata, - INTERNAL_IMAGE, - strlen(INTERNAL_IMAGE)) == 0)) - { - eptr->pic_data->internal = 1; - } - else - { - eptr->pic_data->internal = 0; - } - } - eptr->pic_data->delayed = 0; - - ReformatWindow(hw); - ScrollWidgets(hw); - ViewClearAndRefresh(hw); - } - else if ((eptr->pic_data != NULL)&& - (eptr->pic_data->ismap)&& - (eptr->anchorHRef != NULL)&& - (IsIsMapForm(hw, eptr->anchorHRef))) - { - int form_x, form_y; - - form_x = event->xbutton.x + hw->html.scroll_x - - eptr->x; - form_y = event->xbutton.y + hw->html.scroll_y - - eptr->y; - ImageSubmitForm(eptr->pic_data->fptr, event, - eptr->pic_data->text, form_x, form_y); - } - else - { - /* The following is a hack to send the - * selection location along with the HRef - * for images. This allows you to - * point at a location on a map and have - * the server send you the related document. - * Tony Sanders, April 1993 - */ - int alloced = 0; - char *buf = eptr->anchorHRef; - if (eptr->type == E_IMAGE && eptr->pic_data - && eptr->pic_data->ismap) { - buf = (char *) - malloc(strlen(eptr->anchorHRef) + 256); - alloced = 1; - sprintf(buf, "%s?%d,%d", - eptr->anchorHRef, - event->xbutton.x + hw->html.scroll_x - eptr->x, - event->xbutton.y + hw->html.scroll_y - eptr->y); - } - /* - * XXX: should call a media dependent - * function that decides how to munge the - * HRef. For example mpeg data will want - * to know on what frame the event occured. - * - * cddata.href = *(eptr->eventf)(eptr, event); - */ - cbdata.event = event; - cbdata.element_id = eptr->ele_id; - cbdata.href = buf; - /* cbdata.href = eptr->anchorHRef; */ - cbdata.text = tptr; - XtCallCallbackList ((Widget)hw, - hw->html.anchor_callback, - (XtPointer)&cbdata); - if (alloced) free(buf); - if (tptr != NULL) free(tptr); - } - } - } - } - - return; -} - - -#ifndef MOTIF -#include -/* - * Process key input passwd widgets - */ -static void -#ifdef _NO_PROTO -_HTMLpwdInput( w, event, params, num_params) - Widget w ; - XEvent *event ; - String *params; /* unused */ - Cardinal *num_params; /* unused */ -#else -_HTMLpwdInput( - Widget w, - XEvent *event, - String *params, /* unused */ - Cardinal *num_params) /* unused */ -#endif - { - char buffer[50]; - KeySym ks; - char *keySymString; - char *star = "*"; - int length, passwdLength, i, insertPos, maxLength; - Boolean stringInPlace; - - if (event->type == KeyPress) - { - HTMLWidget hw = (HTMLWidget)XtParent(XtParent(w)); - WidgetInfo *wptr; - - if (XtClass((Widget)hw) != htmlWidgetClass) - return; /* it was not for us */ - - /* - * find the structure for this widget - */ - wptr = hw->html.widget_list; - while (wptr != NULL) - { - if (wptr->w == w) - break; - wptr = wptr->next; - } - if (wptr == NULL) - return; - - passwdLength = wptr->password ? strlen(wptr->password) : 0; - - length = XLookupString((XKeyEvent *)event, - buffer, 50, &ks, NULL); - keySymString = XKeysymToString(ks); - XtVaGetValues(w, - XtNinsertPosition,&insertPos, - XtNuseStringInPlace, &stringInPlace, - XtNlength, &maxLength, - NULL); - - if (maxLength<1) maxLength = 1000000; - - if (!strcmp("Left",keySymString)) - { - if (insertPos > 0) - XtVaSetValues(w,XtNinsertPosition,--insertPos,NULL); - return; - } - else if (!strcmp("Right",keySymString)) - { - if (insertPos < passwdLength) - XtVaSetValues(w,XtNinsertPosition,++insertPos,NULL); - return; - } - - if ((!strcmp("BackSpace",keySymString)) - || (!strcmp("Backspace",keySymString)) - || (!strcmp("Delete",keySymString)) ) - { - insertPos --; - - if (passwdLength>0) - { - char *pwd = &(wptr->password[insertPos]); - - for (i = passwdLength - insertPos; i>0; i--,pwd++) - *pwd = *(pwd+1); - -/* fprintf(stderr,"modified passwd <%s>\n", wptr->password);*/ - XtCallActionProc(w, - insertPos>-1 ? "delete-previous-character" : - "delete-next-character", - event, NULL,0); - } - /* else nothing to erase */ - return; - } - - if (length == 1) - { - buffer[1] = '\0'; - - if (passwdLength>0) - { - - if (passwdLength < maxLength) - { - char *pwd = wptr->password = - (char *)realloc(wptr->password, - sizeof(char)*(passwdLength+2)); - for (i=passwdLength+1; i>insertPos; i--) - pwd[i] = pwd[i-1]; - - pwd[insertPos] = buffer[0]; - } - } - else - { - if (wptr->password == NULL) - wptr->password = (char *)malloc(sizeof(char)*2); - - wptr->password[0] = buffer[0]; - wptr->password[1] = '\0'; - } - - if (stringInPlace && passwdLength\n", wptr->password); */ - } - } - } -#endif /* not MOTIF */ - - -/* - * SetValues is called when XtSetValues is used to change resources in this - * widget. - */ -static Boolean -#ifdef _NO_PROTO -SetValues (current, request, new) - HTMLWidget current ; - HTMLWidget request ; - HTMLWidget new ; -#else -SetValues( - HTMLWidget current, - HTMLWidget request, - HTMLWidget new) -#endif -{ - int reformatted; - - /* - * Make sure the underline numbers are within bounds. - */ - if (request->html.num_anchor_underlines < 0) - { - new->html.num_anchor_underlines = 0; - } - if (request->html.num_anchor_underlines > MAX_UNDERLINES) - { - new->html.num_anchor_underlines = MAX_UNDERLINES; - } - if (request->html.num_visitedAnchor_underlines < 0) - { - new->html.num_visitedAnchor_underlines = 0; - } - if (request->html.num_visitedAnchor_underlines > MAX_UNDERLINES) - { - new->html.num_visitedAnchor_underlines = MAX_UNDERLINES; - } - - reformatted = 0; - if ((request->html.raw_text != current->html.raw_text)|| - (request->html.header_text != current->html.header_text)|| - (request->html.footer_text != current->html.footer_text)) - { - /* - * Free up the old visited href list. - */ - FreeHRefs(current->html.my_visited_hrefs); - new->html.my_visited_hrefs = NULL; - - /* - * Free up the old visited delayed images list. - */ - FreeDelayedImages(current->html.my_delayed_images); - new->html.my_delayed_images = NULL; - - /* - * Free any old colors and pixmaps - */ - FreeColors(XtDisplay(current), DefaultColormapOfScreen(XtScreen(current))); - FreeImages(current); - - /* - * Hide any old widgets - */ - HideWidgets(current); - new->html.widget_list = NULL; - new->html.form_list = NULL; - - /* - * Parse the raw text with the HTML parser - */ - new->html.html_objects = HTMLParse(current->html.html_objects, - request->html.raw_text); - CallLinkCallbacks(new); - new->html.html_header_objects = - HTMLParse(current->html.html_header_objects, - request->html.header_text); - new->html.html_footer_objects = - HTMLParse(current->html.html_footer_objects, - request->html.footer_text); - - /* - * Redisplay for the changed data. - */ - { - new->html.scroll_x = 0; - new->html.scroll_y = 0; - new->html.max_pre_width = DocumentWidth(new, - new->html.html_objects); - ReformatWindow(new); - ViewClearAndRefresh(new); - reformatted = 1; - } - - /* - * Clear any previous selection - */ - new->html.select_start = NULL; - new->html.select_end = NULL; - new->html.sel_start_pos = 0; - new->html.sel_end_pos = 0; - new->html.new_start = NULL; - new->html.new_end = NULL; - new->html.new_start_pos = 0; - new->html.new_end_pos = 0; - new->html.active_anchor = NULL; - } - else if ((request->html.font != current->html.font)|| - (request->html.italic_font != current->html.italic_font)|| - (request->html.bold_font != current->html.bold_font)|| - (request->html.fixed_font != current->html.fixed_font)|| - (request->html.fixedbold_font != current->html.fixedbold_font)|| - (request->html.fixeditalic_font != current->html.fixeditalic_font)|| - (request->html.header1_font != current->html.header1_font)|| - (request->html.header2_font != current->html.header2_font)|| - (request->html.header3_font != current->html.header3_font)|| - (request->html.header4_font != current->html.header4_font)|| - (request->html.header5_font != current->html.header5_font)|| - (request->html.header6_font != current->html.header6_font)|| - (request->html.address_font != current->html.address_font)|| - (request->html.plain_font != current->html.plain_font)|| - (request->html.plainbold_font != current->html.plainbold_font)|| - (request->html.plainitalic_font != current->html.plainitalic_font)|| - (request->html.listing_font != current->html.listing_font)|| - (request->html.activeAnchor_fg != current->html.activeAnchor_fg)|| - (request->html.activeAnchor_bg != current->html.activeAnchor_bg)|| - (request->html.anchor_fg != current->html.anchor_fg)|| - (request->html.visitedAnchor_fg != current->html.visitedAnchor_fg)|| - (request->html.dashed_anchor_lines != current->html.dashed_anchor_lines)|| - (request->html.dashed_visitedAnchor_lines != current->html.dashed_visitedAnchor_lines)|| - (request->html.num_anchor_underlines != current->html.num_anchor_underlines)|| - (request->html.num_visitedAnchor_underlines != current->html.num_visitedAnchor_underlines)) - { - if ((request->html.plain_font != current->html.plain_font)|| - (request->html.listing_font != current->html.listing_font)) - { - new->html.max_pre_width = DocumentWidth(new, - new->html.html_objects); - } - - ReformatWindow(new); - ScrollWidgets(new); - ViewClearAndRefresh(new); - reformatted = 1; - } - - /* - * image borders have been changed - */ - if (request->html.border_images != current->html.border_images) - { - ReformatWindow(new); - ScrollWidgets(new); - ViewClearAndRefresh(new); - reformatted = 1; - } - - /* - * vertical space has been changed - */ - if(request->html.percent_vert_space != current->html.percent_vert_space) - { - ReformatWindow(new); - ScrollWidgets(new); - ViewClearAndRefresh(new); - reformatted = 1; - } - - return(False); -} - - -/* - * Go through the parsed marks and for all the tags in the document - * call the LinkCallback. - */ -static void -#ifdef _NO_PROTO -CallLinkCallbacks(hw) - HTMLWidget hw; -#else -CallLinkCallbacks(HTMLWidget hw) -#endif -{ - struct mark_up *mptr; - LinkInfo l_info; - - mptr = hw->html.html_objects; - while (mptr != NULL) - { - if (mptr->type == M_BASE) - { - l_info.href = ParseMarkTag(mptr->start, MT_BASE, - "HREF"); - l_info.role = ParseMarkTag(mptr->start, MT_BASE, - "ROLE"); - XtCallCallbackList ((Widget)hw, hw->html.link_callback, - (XtPointer)&l_info); - if (l_info.href != NULL) - { - free(l_info.href); - } - if (l_info.role != NULL) - { - free(l_info.role); - } - } - mptr = mptr->next; - } -} - - -/* - * Search through the whole document, and recolor the internal elements with - * the passed HREF. - */ -static void -#ifdef _NO_PROTO -RecolorInternalHRefs(hw, href) - HTMLWidget hw; - char *href; -#else -RecolorInternalHRefs(HTMLWidget hw, char *href) -#endif -{ - struct ele_rec *start; - unsigned long fg; - - fg = hw->html.visitedAnchor_fg; - start = hw->html.formatted_elements; - while (start != NULL) - { - /* - * This one is internal - * This one has an href - * This is the href we want - */ - if ((start->internal == True)&& - (start->anchorHRef != NULL)&& - (strcmp(start->anchorHRef, href) == 0)) - { - start->fg = fg; - start->underline_number = - hw->html.num_visitedAnchor_underlines; - start->dashed_underline = - hw->html.dashed_visitedAnchor_lines; - } - start = start->next; - } -} - - -static Boolean -ConvertSelection(w, selection, target, type, value, length, format) - Widget w; - Atom *selection, *target, *type; - caddr_t *value; - unsigned long *length; - int *format; -{ - Display *d = XtDisplay(w); - HTMLWidget hw = (HTMLWidget)w; - char *text; - - if (hw->html.select_start == NULL) - { - return False; - } - - if (*target == XA_TARGETS(d)) - { - Atom *targetP; - Atom *std_targets; - unsigned long std_length; - XmuConvertStandardSelection( w, hw->html.selection_time, - selection, target, type, (caddr_t*)&std_targets, - &std_length, format); - - *length = std_length + 5; - *value = (caddr_t)XtMalloc(sizeof(Atom)*(*length)); - targetP = *(Atom**)value; - *targetP++ = XA_STRING; - *targetP++ = XA_TEXT(d); - *targetP++ = XA_COMPOUND_TEXT(d); - *targetP++ = XA_LENGTH(d); - *targetP++ = XA_LIST_LENGTH(d); - - bcopy((char*)std_targets, (char*)targetP, - sizeof(Atom)*std_length); - XtFree((char*)std_targets); - *type = XA_ATOM; - *format = 32; - return True; - } - - if (*target == XA_STRING || *target == XA_TEXT(d) || - *target == XA_COMPOUND_TEXT(d)) - { - if (*target == XA_COMPOUND_TEXT(d)) - { - *type = *target; - } - else - { - *type = XA_STRING; - } - if (hw->html.fancy_selections == True) - { - text = ParseTextToPrettyString(hw, - hw->html.formatted_elements, - hw->html.select_start, hw->html.select_end, - hw->html.sel_start_pos, hw->html.sel_end_pos, - hw->html.font->max_bounds.width, - hw->html.margin_width); - } - else - { - text = ParseTextToString(hw->html.formatted_elements, - hw->html.select_start, hw->html.select_end, - hw->html.sel_start_pos, hw->html.sel_end_pos, - hw->html.font->max_bounds.width, - hw->html.margin_width); - } - *value = text; - *length = strlen(*value); - *format = 8; - return True; - } - - if (*target == XA_LIST_LENGTH(d)) - { - *value = XtMalloc(4); - if (sizeof(long) == 4) - { - *(long*)*value = 1; - } - else - { - long temp = 1; - bcopy( ((char*)&temp)+sizeof(long)-4, (char*)*value, 4); - } - *type = XA_INTEGER; - *length = 1; - *format = 32; - return True; - } - - if (*target == XA_LENGTH(d)) - { - if (hw->html.fancy_selections == True) - { - text = ParseTextToPrettyString(hw, - hw->html.formatted_elements, - hw->html.select_start, hw->html.select_end, - hw->html.sel_start_pos, hw->html.sel_end_pos, - hw->html.font->max_bounds.width, - hw->html.margin_width); - } - else - { - text = ParseTextToString(hw->html.formatted_elements, - hw->html.select_start, hw->html.select_end, - hw->html.sel_start_pos, hw->html.sel_end_pos, - hw->html.font->max_bounds.width, - hw->html.margin_width); - } - *value = XtMalloc(4); - if (sizeof(long) == 4) - { - *(long*)*value = strlen(text); - } - else - { - long temp = strlen(text); - bcopy( ((char*)&temp)+sizeof(long)-4, (char*)*value, 4); - } - free(text); - *type = XA_INTEGER; - *length = 1; - *format = 32; - return True; - } - - if (XmuConvertStandardSelection(w, hw->html.selection_time, selection, - target, type, value, length, format)) - { - return True; - } - - return False; -} - - -static void -LoseSelection(w, selection) - Widget w; - Atom *selection; -{ - HTMLWidget hw = (HTMLWidget)w; - - ClearSelection(hw); -} - - -static void -SelectionDone(w, selection, target) - Widget w; - Atom *selection, *target; -{ - /* empty proc so Intrinsics know we want to keep storage */ -} - - -/* - ************************************************************************* - ******************************* PUBLIC FUNCTIONS ************************ - ************************************************************************* - */ - - -/* - * Convenience function to return the text of the HTML document as a plain - * ascii text string. - * This function allocates memory for the returned string, that it is up - * to the user to free. - * Extra option flags "pretty" text to be returned. - * when pretty is two or larger, Postscript is returned. The font used is - * encoded in the pretty parameter: - * pretty = 2: Times - * pretty = 3: Helvetica - * pretty = 4: New century schoolbook - * pretty = 5: Lucida Bright - */ -char * -#ifdef _NO_PROTO -HTMLGetText (w, pretty) - Widget w; - int pretty; -#else -HTMLGetText(Widget w, int pretty) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - char *text; - char *tptr, *buf; - struct ele_rec *start; - struct ele_rec *end; - - text = NULL; - start = hw->html.formatted_elements; - end = start; - while (end != NULL) - { - end = end->next; - } - - if (pretty >= 2) - { - tptr = ParseTextToPSString(hw, start, start, end, - 0, 0, - hw->html.font->max_bounds.width, - hw->html.margin_width , pretty-2); - } - else if (pretty) - { - tptr = ParseTextToPrettyString(hw, start, start, end, - 0, 0, - hw->html.font->max_bounds.width, - hw->html.margin_width); - } - else - { - tptr = ParseTextToString(start, start, end, - 0, 0, - hw->html.font->max_bounds.width, - hw->html.margin_width); - } - if (tptr != NULL) - { - if (text == NULL) - { - text = tptr; - } - else - { - buf = (char *)malloc(strlen(text) + - strlen(tptr) + 1); - strcpy(buf, text); - strcat(buf, tptr); - free(text); - free(tptr); - text = buf; - } - } - return(text); -} - - -/* - * Convenience function to return the element id of the element - * nearest to the x,y coordinates passed in. - * If there is no element there, return the first element in the - * line we are on. If there we are on no line, either return the - * beginning, or the end of the document. - */ -int -#ifdef _NO_PROTO -HTMLPositionToId(w, x, y) - Widget w; - int x, y; -#else -HTMLPositionToId(Widget w, int x, int y) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - int i; - int epos; - struct ele_rec *eptr; - - eptr = LocateElement(hw, x, y, &epos); - if (eptr == NULL) - { - x = x + hw->html.scroll_x; - y = y + hw->html.scroll_y; - eptr = hw->html.line_array[0]; - for (i=0; ihtml.line_count; i++) - { - if (hw->html.line_array[i] == NULL) - { - continue; - } - else if (hw->html.line_array[i]->y <= y) - { - eptr = hw->html.line_array[i]; - continue; - } - else - { - break; - } - } - } - - /* - * 0 means the very top of the document. We put you there for - * unfound elements. - * We also special case for when the scrollbar is at the - * absolute top. - */ - if ((eptr == NULL)||(hw->html.scroll_y == 0)) - { - return(0); - } - else - { - return(eptr->ele_id); - } -} - - -/* - * Convenience function to return the position of the element - * based on the element id passed in. - * Function returns 1 on success and fills in x,y pixel values. - * If there is no such element, x=0, y=0 and -1 is returned. - */ -int -#ifdef _NO_PROTO -HTMLIdToPosition(w, element_id, x, y) - Widget w; - int element_id; - int *x, *y; -#else -HTMLIdToPosition(Widget w, int element_id, int *x, int *y) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - struct ele_rec *start; - struct ele_rec *eptr; - - eptr = NULL; - start = hw->html.formatted_elements; - while (start != NULL) - { - if (start->ele_id == element_id) - { - eptr = start; - break; - } - start = start->next; - } - - if (eptr == NULL) - { - *x = 0; - *y = 0; - return(-1); - } - else - { - *x = eptr->x; - *y = eptr->y; - return(1); - } -} - - -/* - * Convenience function to position the element - * based on the element id passed at the top of the viewing area. - * A passed in id of 0 means goto the top. - */ -void -#ifdef _NO_PROTO -HTMLGotoId(w, element_id) - Widget w; - int element_id; -#else -HTMLGotoId(Widget w, int element_id) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - struct ele_rec *start; - struct ele_rec *eptr; - int newy; -#ifdef MOTIF - int val, size, inc, pageinc; -#endif - - /* - * If we have no scrollbar, just return. - */ - if (hw->html.use_vbar == False) - { - return; - } - - /* - * Find the element corrsponding to the id passed in. - */ - eptr = NULL; - start = hw->html.formatted_elements; - while (start != NULL) - { - if (start->ele_id == element_id) - { - eptr = start; - break; - } - start = start->next; - } - - /* - * No such element, do nothing. - */ - if ((element_id != 0)&&(eptr == NULL)) - { - return; - } - - if (element_id == 0) - { - newy = 0; - } - else - { - newy = eptr->y - 2; - } - if (newy < 0) - { - newy = 0; - } - if (newy > (hw->html.doc_height - (int)hw->html.view_height)) - { - newy = hw->html.doc_height - (int)hw->html.view_height; - } - if (newy < 0) - { - newy = 0; - } -#ifdef MOTIF - XmScrollBarGetValues(hw->html.vbar, &val, &size, &inc, &pageinc); - XmScrollBarSetValues(hw->html.vbar, newy, size, inc, pageinc, True); - XmScrollBarGetValues(hw->html.hbar, &val, &size, &inc, &pageinc); - XmScrollBarSetValues(hw->html.hbar, 0, size, inc, pageinc, True); -#else - ScrollToPos(hw->html.vbar, hw, newy); - ScrollToPos(hw->html.hbar, hw, 0); - setScrollBar(hw->html.vbar, newy, - hw->html.doc_height, - hw->html.view_height); -#endif -} - - -/* - * Convenience function to return the position of the anchor - * based on the anchor NAME passed. - * Function returns 1 on success and fills in x,y pixel values. - * If there is no such element, x=0, y=0 and -1 is returned. - */ -int -#ifdef _NO_PROTO -HTMLAnchorToPosition(w, name, x, y) - Widget w; - char *name; - int *x, *y; -#else -HTMLAnchorToPosition(Widget w, char *name, int *x, int *y) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - struct ele_rec *start; - struct ele_rec *eptr; - - eptr = NULL; - start = hw->html.formatted_elements; - while (start != NULL) - { - if ((start->anchorName)&& - (strcmp(start->anchorName, name) == 0)) - { - eptr = start; - break; - } - start = start->next; - } - - if (eptr == NULL) - { - *x = 0; - *y = 0; - return(-1); - } - else - { - *x = eptr->x; - *y = eptr->y; - return(1); - } -} - - -/* - * Convenience function to return the element id of the anchor - * based on the anchor NAME passed. - * Function returns id on success. - * If there is no such element, 0 is returned. - */ -int -#ifdef _NO_PROTO -HTMLAnchorToId(w, name) - Widget w; - char *name; -#else -HTMLAnchorToId(Widget w, char *name) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - struct ele_rec *start; - struct ele_rec *eptr; - - /* - * Find the passed anchor name - */ - eptr = NULL; - start = hw->html.formatted_elements; - while (start != NULL) - { - if ((start->anchorName)&& - (strcmp(start->anchorName, name) == 0)) - { - eptr = start; - break; - } - start = start->next; - } - - if (eptr == NULL) - { - return(0); - } - else - { - return(eptr->ele_id); - } -} - - -/* - * Convenience function to return the HREFs of all active anchors in the - * document. - * Function returns an array of strings and fills num_hrefs passed. - * If there are no HREFs NULL returned. - */ -char ** -#ifdef _NO_PROTO -HTMLGetHRefs(w, num_hrefs) - Widget w; - int *num_hrefs; -#else -HTMLGetHRefs(Widget w, int *num_hrefs) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - int cnt; - struct ele_rec *start; - struct ele_rec *list; - struct ele_rec *eptr; - char **harray; - - list = NULL; - cnt = 0; - /* - * Construct a linked list of all the diffeent hrefs, counting - * then as we go. - */ - start = hw->html.formatted_elements; - while (start != NULL) - { - /* - * This one has an HREF - */ - if (start->anchorHRef != NULL) - { - /* - * Check to see if we already have - * this HREF in our list. - */ - eptr = list; - while (eptr != NULL) - { - if (strcmp(eptr->anchorHRef, - start->anchorHRef) == 0) - { - break; - } - eptr = eptr->next; - } - /* - * This HREF is not, in our list. Add it. - * That is, if it's not an internal reference. - */ - if ((eptr == NULL)&&(start->internal == False)) - { - eptr = (struct ele_rec *) - malloc(sizeof(struct ele_rec)); - eptr->anchorHRef = start->anchorHRef; - eptr->next = list; - list = eptr; - cnt++; - } - } - start = start->next; - } - - if (cnt == 0) - { - *num_hrefs = 0; - return(NULL); - } - else - { - *num_hrefs = cnt; - harray = (char **)malloc(sizeof(char *) * cnt); - eptr = list; - cnt--; - while (eptr != NULL) - { - harray[cnt] = (char *) - malloc(strlen(eptr->anchorHRef) + 1); - strcpy(harray[cnt], eptr->anchorHRef); - start = eptr; - eptr = eptr->next; - free((char *)start); - cnt--; - } - return(harray); - } -} - - -/* - * Convenience function to return the SRCs of all images in the - * document. - * Function returns an array of strings and fills num_srcs passed. - * If there are no SRCs NULL returned. - */ -char ** -#ifdef _NO_PROTO -HTMLGetImageSrcs(w, num_srcs) - Widget w; - int *num_srcs; -#else -HTMLGetImageSrcs(Widget w, int *num_srcs) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - struct mark_up *mptr; - int cnt; - char *tptr; - char **harray; - - cnt = 0; - mptr = hw->html.html_objects; - while (mptr != NULL) - { - if (mptr->type == M_IMAGE) - { - tptr = ParseMarkTag(mptr->start, MT_IMAGE, "SRC"); - if ((tptr != NULL)&&(*tptr != '\0')) - { - cnt++; - free(tptr); - } - } - else /****** temporary until figure support */ - if (mptr->type == M_FIGURE) - { - tptr = ParseMarkTag(mptr->start, MT_FIGURE, "SRC"); - if ((tptr != NULL)&&(*tptr != '\0')) - { - cnt++; - free(tptr); - } - } - /*********************************************/ - mptr = mptr->next; - } - - if (cnt == 0) - { - *num_srcs = 0; - return(NULL); - } - else - { - *num_srcs = cnt; - harray = (char **)malloc(sizeof(char *) * cnt); - mptr = hw->html.html_objects; - cnt = 0; - while (mptr != NULL) - { - if (mptr->type == M_IMAGE) - { - tptr = ParseMarkTag(mptr->start,MT_IMAGE,"SRC"); - if ((tptr != NULL)&&(*tptr != '\0')) - { - harray[cnt] = tptr; - cnt++; - } - } - else /****** temporary until figure support */ - if (mptr->type == M_FIGURE) - { - tptr =ParseMarkTag(mptr->start,MT_FIGURE,"SRC"); - if ((tptr != NULL)&&(*tptr != '\0')) - { - harray[cnt] = tptr; - cnt++; - } - } - /*********************************************/ - mptr = mptr->next; - } - return(harray); - } -} - - -/* - * Convenience function to return the link information - * for all the tags in the document. - * Function returns an array of LinkInfo structures and fills - * num_links passed. - * If there are no LINKs NULL returned. - */ -LinkInfo * -#ifdef _NO_PROTO -HTMLGetLinks(w, num_links) - Widget w; - int *num_links; -#else -HTMLGetLinks(Widget w, int *num_links) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - struct mark_up *mptr; - int cnt; - char *tptr; - LinkInfo *larray; - - cnt = 0; - mptr = hw->html.html_objects; - while (mptr != NULL) - { - if (mptr->type == M_BASE) - { - cnt++; - } - mptr = mptr->next; - } - - if (cnt == 0) - { - *num_links = 0; - return(NULL); - } - else - { - *num_links = cnt; - larray = (LinkInfo *)malloc(sizeof(LinkInfo) * cnt); - mptr = hw->html.html_objects; - cnt = 0; - while (mptr != NULL) - { - if (mptr->type == M_BASE) - { - tptr = ParseMarkTag(mptr->start, - MT_BASE, "HREF"); - larray[cnt].href = tptr; - tptr = ParseMarkTag(mptr->start, - MT_BASE, "ROLE"); - larray[cnt].role = tptr; - cnt++; - } - mptr = mptr->next; - } - return(larray); - } -} - - - -void * -#ifdef _NO_PROTO -HTMLGetWidgetInfo(w) - Widget w; -#else -HTMLGetWidgetInfo(Widget w) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - - return((void *)hw->html.widget_list); -} - - -void -#ifdef _NO_PROTO -HTMLFreeImageInfo(w) - Widget w; -#else -HTMLFreeImageInfo(Widget w) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - - FreeColors(XtDisplay(w), DefaultColormapOfScreen(XtScreen(w))); - FreeImages(hw); -} - - -void -#ifdef _NO_PROTO -HTMLFreeWidgetInfo(ptr) - void *ptr; -#else -HTMLFreeWidgetInfo(void *ptr) -#endif -{ - WidgetInfo *wptr = (WidgetInfo *)ptr; - WidgetInfo *tptr; - - while (wptr != NULL) - { - tptr = wptr; - wptr = wptr->next; - if (tptr->w != NULL) - { - /* - * This is REALLY DUMB, but X generates an expose event - * for the destruction of the Widgte, even if it isn't - * mapped at the time it is destroyed. - * So I move the invisible widget to -1000,-1000 - * before destroying it, to avoid a visible flash. - */ - XtMoveWidget(tptr->w, -1000, -1000); - XtDestroyWidget(tptr->w); - } - if (tptr->name != NULL) - { - free(tptr->name); - } - if ((tptr->value != NULL)&&(tptr->type != W_OPTIONMENU)) - { - free(tptr->value); - } - free((char *)tptr); - } -} - - -/* - * Convenience function to redraw all active anchors in the - * document. - * Can also pass a new predicate function to check visited - * anchors. If NULL passed for function, uses default predicate - * function. - */ -void -#ifdef _NO_PROTO -HTMLRetestAnchors(w, testFunc) - Widget w; - visitTestProc testFunc; -#else -HTMLRetestAnchors(Widget w, visitTestProc testFunc) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - struct ele_rec *start; - - if (testFunc == NULL) - { - testFunc = (visitTestProc)hw->html.previously_visited_test; - } - - /* - * Search all elements - */ - start = hw->html.formatted_elements; - while (start != NULL) - { - if ((start->internal == True)|| - (start->anchorHRef == NULL)) - { - start = start->next; - continue; - } - - if (testFunc != NULL) - { - if ((*testFunc)(hw, start->anchorHRef)) - { - start->fg = hw->html.visitedAnchor_fg; - start->underline_number = - hw->html.num_visitedAnchor_underlines; - start->dashed_underline = - hw->html.dashed_visitedAnchor_lines; - } - else - { - start->fg = hw->html.anchor_fg; - start->underline_number = - hw->html.num_anchor_underlines; - start->dashed_underline = - hw->html.dashed_anchor_lines; - } - } - else - { - start->fg = hw->html.anchor_fg; - start->underline_number = - hw->html.num_anchor_underlines; - start->dashed_underline = - hw->html.dashed_anchor_lines; - } - - /* - * Since the element may have changed, redraw it - */ - switch(start->type) - { - case E_TEXT: - TextRefresh(hw, start, - 0, (start->edata_len - 2)); - break; - case E_IMAGE: - ImageRefresh(hw, start); - break; - case E_BULLET: - BulletRefresh(hw, start); - break; - case E_LINEFEED: - LinefeedRefresh(hw, start); - break; - } - - start = start->next; - } -} - - -void -#ifdef _NO_PROTO -HTMLClearSelection (w) - Widget w; -#else -HTMLClearSelection(Widget w) -#endif -{ - LoseSelection (w, NULL); -} - - -/* - * Set the current selection based on the ElementRefs passed in. - * Both refs must be valid. - */ -void -#ifdef _NO_PROTO -HTMLSetSelection (w, start, end) - Widget w; - ElementRef *start; - ElementRef *end; -#else -HTMLSetSelection(Widget w, ElementRef *start, ElementRef *end) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - int found; - struct ele_rec *eptr; - struct ele_rec *e_start; - struct ele_rec *e_end; - int start_pos, end_pos; - Atom *atoms; - int i, buffer; - char *text; - char *params[2]; - - /* - * If the starting position is not valid, fail the selection - */ - if ((start->id > 0)&&(start->pos >= 0)) - { - found = 0; - eptr = hw->html.formatted_elements; - - while (eptr != NULL) - { - if (eptr->ele_id == start->id) - { - e_start = eptr; - start_pos = start->pos; - found = 1; - break; - } - eptr = eptr->next; - } - if (!found) - { - return; - } - } - - /* - * If the ending position is not valid, fail the selection - */ - if ((end->id > 0)&&(end->pos >= 0)) - { - found = 0; - eptr = hw->html.formatted_elements; - - while (eptr != NULL) - { - if (eptr->ele_id == end->id) - { - e_end = eptr; - end_pos = end->pos; - found = 1; - break; - } - eptr = eptr->next; - } - if (!found) - { - return; - } - } - - LoseSelection (w, NULL); - - /* - * We expect the ElementRefs came from HTMLSearchText, so we know - * that the end_pos is one past what we want to select. - */ - end_pos = end_pos - 1; - - /* - * Sanify the position data - */ - if ((start_pos > 0)&&(start_pos >= e_start->edata_len - 1)) - { - start_pos = e_start->edata_len - 2; - } - if ((end_pos > 0)&&(end_pos >= e_end->edata_len - 1)) - { - end_pos = e_end->edata_len - 2; - } - - hw->html.select_start = e_start; - hw->html.sel_start_pos = start_pos; - hw->html.select_end = e_end; - hw->html.sel_end_pos = end_pos; - SetSelection(hw); - hw->html.new_start = NULL; - hw->html.new_end = NULL; - hw->html.new_start_pos = 0; - hw->html.new_end_pos = 0; - - /* - * Do all the gunk from the end of the ExtendEnd function - */ - params[0] = "PRIMARY"; - params[1] = "CUT_BUFFER0"; - atoms = (Atom *)malloc(2 * sizeof(Atom)); - if (atoms == NULL) - { - fprintf(stderr, "cannot allocate atom list\n"); - return; - } - XmuInternStrings(XtDisplay((Widget)hw), params, 2, atoms); - hw->html.selection_time = CurrentTime; - for (i=0; i< 2; i++) - { - switch (atoms[i]) - { - case XA_CUT_BUFFER0: buffer = 0; break; - case XA_CUT_BUFFER1: buffer = 1; break; - case XA_CUT_BUFFER2: buffer = 2; break; - case XA_CUT_BUFFER3: buffer = 3; break; - case XA_CUT_BUFFER4: buffer = 4; break; - case XA_CUT_BUFFER5: buffer = 5; break; - case XA_CUT_BUFFER6: buffer = 6; break; - case XA_CUT_BUFFER7: buffer = 7; break; - default: buffer = -1; break; - } - if (buffer >= 0) - { - if (hw->html.fancy_selections == True) - { - text = ParseTextToPrettyString(hw, - hw->html.formatted_elements, - hw->html.select_start, - hw->html.select_end, - hw->html.sel_start_pos, - hw->html.sel_end_pos, - hw->html.font->max_bounds.width, - hw->html.margin_width); - } - else - { - text = ParseTextToString( - hw->html.formatted_elements, - hw->html.select_start, - hw->html.select_end, - hw->html.sel_start_pos, - hw->html.sel_end_pos, - hw->html.font->max_bounds.width, - hw->html.margin_width); - } - XStoreBuffer(XtDisplay((Widget)hw), - text, strlen(text), buffer); - free(text); - } - else - { - XtOwnSelection((Widget)hw, atoms[i], CurrentTime, - (XtConvertSelectionProc )ConvertSelection, - (XtLoseSelectionProc )LoseSelection, - (XtSelectionDoneProc )SelectionDone); - } - } - free((char *)atoms); -} - - -/* - * Convenience function to return the text of the HTML document as a single - * white space separated string, with pointers to the various start and - * end points of selections. - * This function allocates memory for the returned string, that it is up - * to the user to free. - */ -char * -#ifdef _NO_PROTO -HTMLGetTextAndSelection (w, startp, endp, insertp) - Widget w; - char **startp; - char **endp; - char **insertp; -#else -HTMLGetTextAndSelection(Widget w, char **startp, char **endp, char **insertp) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - int length; - char *text; - char *tptr; - struct ele_rec *eptr; - struct ele_rec *sel_start; - struct ele_rec *sel_end; - struct ele_rec *insert_start; - int start_pos, end_pos, insert_pos; - - if (SwapElements(hw->html.select_start, hw->html.select_end, - hw->html.sel_start_pos, hw->html.sel_end_pos)) - { - sel_end = hw->html.select_start; - end_pos = hw->html.sel_start_pos; - sel_start = hw->html.select_end; - start_pos = hw->html.sel_end_pos; - } - else - { - sel_start = hw->html.select_start; - start_pos = hw->html.sel_start_pos; - sel_end = hw->html.select_end; - end_pos = hw->html.sel_end_pos; - } - - insert_start = hw->html.new_start; - insert_pos = hw->html.new_start_pos; - *startp = NULL; - *endp = NULL; - *insertp = NULL; - - length = 0; - - eptr = hw->html.formatted_elements; - while (eptr != NULL) - { - /* - * Skip the special internal text - */ - if (eptr->internal == True) - { - eptr = eptr->next; - continue; - } - - if (eptr->type == E_TEXT) - { - length = length + eptr->edata_len - 1; - } - else if (eptr->type == E_LINEFEED) - { - length = length + 1; - } - eptr = eptr->next; - } - - text = (char *)malloc(length + 1); - if (text == NULL) - { - fprintf(stderr, "No space for return string\n"); - return(NULL); - } - strcpy(text, ""); - - tptr = text; - - eptr = hw->html.formatted_elements; - while (eptr != NULL) - { - /* - * Skip the special internal text - */ - if (eptr->internal == True) - { - eptr = eptr->next; - continue; - } - - if (eptr->type == E_TEXT) - { - if (eptr == sel_start) - { - *startp = (char *)(tptr + start_pos); - } - - if (eptr == sel_end) - { - *endp = (char *)(tptr + end_pos); - } - - if (eptr == insert_start) - { - *insertp = (char *)(tptr + insert_pos); - } - - strcat(text, (char *)eptr->edata); - tptr = tptr + eptr->edata_len - 1; - } - else if (eptr->type == E_LINEFEED) - { - if (eptr == sel_start) - { - *startp = tptr; - } - - if (eptr == sel_end) - { - *endp = tptr; - } - - if (eptr == insert_start) - { - *insertp = tptr; - } - - strcat(text, " "); - tptr = tptr + 1; - } - eptr = eptr->next; - } - return(text); -} - - -/* - * Convenience function to set the raw text into the widget. - * Forces a reparse and a reformat. - * If any pointer is passed in as NULL that text is unchanged, - * if a pointer points to an empty string, that text is set to NULL; - * Also pass an element ID to set the view area to that section of the new - * text. Finally pass an anchor NAME to set position of the new text - * to that anchor. - */ -void -#ifdef _NO_PROTO -HTMLSetText (w, text, header_text, footer_text, element_id, target_anchor, ptr) - Widget w; - char *text; - char *header_text; - char *footer_text; - int element_id; - char *target_anchor; - void *ptr; -#else -HTMLSetText(Widget w, char *text, char *header_text, char *footer_text, int element_id, char *target_anchor, void *ptr) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - WidgetInfo *wptr = (WidgetInfo *)ptr; - struct ele_rec *start; - struct ele_rec *eptr; - int newy; - - if ((text == NULL)&&(header_text == NULL)&&(footer_text == NULL)) - { - return; - } - - /* - * Free up the old visited href list. - */ - FreeHRefs(hw->html.my_visited_hrefs); - hw->html.my_visited_hrefs = NULL; - - /* - * Free up the old visited delayed images list. - */ - FreeDelayedImages(hw->html.my_delayed_images); - hw->html.my_delayed_images = NULL; - - /* - * Hide any old widgets - */ - HideWidgets(hw); - hw->html.widget_list = wptr; - hw->html.form_list = NULL; - - if (text != NULL) - { - if (*text == '\0') - { - text = NULL; - } - hw->html.raw_text = text; - - /* - * Free any old colors and pixmaps - */ - FreeColors(XtDisplay(hw),DefaultColormapOfScreen(XtScreen(hw))); - FreeImages(hw); - - /* - * Parse the raw text with the HTML parser - */ - hw->html.html_objects = HTMLParse(hw->html.html_objects, - hw->html.raw_text); - CallLinkCallbacks(hw); - } - if (header_text != NULL) - { - if (*header_text == '\0') - { - header_text = NULL; - } - hw->html.header_text = header_text; - - /* - * Parse the header text with the HTML parser - */ - hw->html.html_header_objects = - HTMLParse(hw->html.html_header_objects, - hw->html.header_text); - } - if (footer_text != NULL) - { - if (*footer_text == '\0') - { - footer_text = NULL; - } - hw->html.footer_text = footer_text; - - /* - * Parse the footer text with the HTML parser - */ - hw->html.html_footer_objects = - HTMLParse(hw->html.html_footer_objects, - hw->html.footer_text); - } - - /* - * Reformat the new text - */ - hw->html.max_pre_width = DocumentWidth(hw, hw->html.html_objects); - ReformatWindow(hw); - - /* - * If a target anchor is passed, override the element id - * with the id of that anchor. - */ - if (target_anchor != NULL) - { - int id; - - id = HTMLAnchorToId(w, target_anchor); - if (id != 0) - { - element_id = id; - } - } - - /* - * Position text at id specified, or at top if no position - * specified. - * Find the element corrsponding to the id passed in. - */ - eptr = NULL; - if (element_id != 0) - { - start = hw->html.formatted_elements; - while (start != NULL) - { - if (start->ele_id == element_id) - { - eptr = start; - break; - } - start = start->next; - } - } - if (eptr == NULL) - { - newy = 0; - } - else - { - newy = eptr->y - 2; - } - if (newy < 0) - { - newy = 0; - } - if (newy > (hw->html.doc_height - (int)hw->html.view_height)) - { - newy = hw->html.doc_height - (int)hw->html.view_height; - } - if (newy < 0) - { - newy = 0; - } - hw->html.scroll_x = 0; - hw->html.scroll_y = newy; -#ifdef DEBUG -fprintf (stderr, "calling in HTMLSetText\n"); -#endif - ConfigScrollBars(hw); - ScrollWidgets(hw); - - /* - * Display the new text - */ - ViewClearAndRefresh(hw); - - /* - * Clear any previous selection - */ - hw->html.select_start = NULL; - hw->html.select_end = NULL; - hw->html.sel_start_pos = 0; - hw->html.sel_end_pos = 0; - hw->html.new_start = NULL; - hw->html.new_end = NULL; - hw->html.new_start_pos = 0; - hw->html.new_end_pos = 0; - hw->html.active_anchor = NULL; - - hw->html.cached_tracked_ele = NULL; -} - - -/* - * To use faster TOLOWER as set up in HTMLparse.c - */ -#ifdef NOT_ASCII -#define TOLOWER(x) (tolower(x)) -#else -extern char map_table[]; -#define TOLOWER(x) (map_table[x]) -#endif /* NOT_ASCII */ - - -/* - * Convenience function to search the text of the HTML document as a single - * white space separated string. Linefeeds are converted into spaces. - * - * Takes a pattern, pointers to the start and end blocks to store the - * start and end of the match into. Start is also used as the location to - * start the search from for incremental searching. If start is an invalid - * position (id = 0). Default start is the beginning of the document for - * forward searching, and the end of the document for backwards searching. - * The backward and caseless parameters I hope are self-explanatory. - * - * returns 1 on success - * (and the start and end positions of the match). - * returns -1 otherwise (and start and end are unchanged). - */ -int -#ifdef _NO_PROTO -HTMLSearchText (w, pattern, m_start, m_end, backward, caseless) - Widget w; - char *pattern; - ElementRef *m_start; - ElementRef *m_end; - int backward; - int caseless; -#else -HTMLSearchText (Widget w, char *pattern, ElementRef *m_start, ElementRef *m_end, - int backward, int caseless) -#endif -{ - HTMLWidget hw = (HTMLWidget)w; - int found, equal; - char *match; - char *tptr; - char *mptr; - char cval; - struct ele_rec *eptr; - int s_pos; - struct ele_rec *s_eptr; - ElementRef s_ref, e_ref; - ElementRef *start, *end; - - /* - * If bad parameters are passed, just fail the search - */ - if ((pattern == NULL)||(*pattern == '\0')|| - (m_start == NULL)||(m_end == NULL)) - { - return(-1); - } - - /* - * If we are caseless, make a lower case copy of the pattern to - * match to use in compares. - * - * remember to free this before returning - */ - if (caseless) - { - match = (char *)malloc(strlen(pattern) + 1); - tptr = pattern; - mptr = match; - while (*tptr != '\0') - { - *mptr = (char)TOLOWER((int)*tptr); - mptr++; - tptr++; - } - *mptr = '\0'; - } - else - { - match = pattern; - } - - /* - * Slimy coding. I later decided I didn't want to change start and - * end if the search failed. Rather than changing all the code, - * I just copy it into locals here, and copy it out again if a match - * is found. - */ - start = &s_ref; - end = &e_ref; - start->id = m_start->id; - start->pos = m_start->pos; - end->id = m_end->id; - end->pos = m_end->pos; - - /* - * Find the user specified start position. - */ - if (start->id > 0) - { - found = 0; - eptr = hw->html.formatted_elements; - - while (eptr != NULL) - { - if (eptr->ele_id == start->id) - { - s_eptr = eptr; - found = 1; - break; - } - eptr = eptr->next; - } - /* - * Bad start position, fail them out. - */ - if (!found) - { - if (caseless) - { - free(match); - } - return(-1); - } - /* - * Sanify the start position - */ - s_pos = start->pos; - if (s_pos >= s_eptr->edata_len - 1) - { - s_pos = s_eptr->edata_len - 2; - } - if (s_pos < 0) - { - s_pos = 0; - } - } - else - { - /* - * Default search starts at end for backward, and - * beginning for forwards. - */ - if (backward) - { - s_eptr = hw->html.formatted_elements; - while (s_eptr->next != NULL) - { - s_eptr = s_eptr->next; - } - s_pos = s_eptr->edata_len - 2; - } - else - { - s_eptr = hw->html.formatted_elements; - s_pos = 0; - } - } - - if (backward) - { - char *mend; - - /* - * Save the end of match here for easy end to start searching - */ - mend = match; - while (*mend != '\0') - { - mend++; - } - if (mend > match) - { - mend--; - } - found = 0; - equal = 0; - mptr = mend; - - if (s_eptr != NULL) - { - eptr = s_eptr; - } - else - { - eptr = hw->html.formatted_elements; - while (eptr->next != NULL) - { - eptr = eptr->next; - } - } - - while (eptr != NULL) - { - /* - * Skip the special internal text - */ - if (eptr->internal == True) - { - eptr = eptr->prev; - continue; - } - - if (eptr->type == E_TEXT) - { - tptr = (char *)(eptr->edata + eptr->edata_len - 2); - if (eptr == s_eptr) - { - tptr = (char *)(eptr->edata + s_pos); - } - while (tptr >= eptr->edata) - { - if (equal) - { - if (caseless) - { - cval =(char)TOLOWER((int)*tptr); - } - else - { - cval = *tptr; - } - while ((mptr >= match)&& - (tptr >= eptr->edata)&& - (cval == *mptr)) - { - tptr--; - mptr--; - if (tptr >= eptr->edata) - { - if (caseless) - { - cval =(char)TOLOWER((int)*tptr); - } - else - { - cval = *tptr; - } - } - } - if (mptr < match) - { - found = 1; - start->id = eptr->ele_id; - start->pos = (int) - (tptr - eptr->edata + 1); - break; - } - else if (tptr < eptr->edata) - { - break; - } - else - { - equal = 0; - } - } - else - { - mptr = mend; - if (caseless) - { - cval =(char)TOLOWER((int)*tptr); - } - else - { - cval = *tptr; - } - while ((tptr >= eptr->edata)&& - (cval != *mptr)) - { - tptr--; - if (tptr >= eptr->edata) - { - if (caseless) - { - cval =(char)TOLOWER((int)*tptr); - } - else - { - cval = *tptr; - } - } - } - if ((tptr >= eptr->edata)&& - (cval == *mptr)) - { - equal = 1; - end->id = eptr->ele_id; - end->pos = (int) - (tptr - eptr->edata + 1); - } - } - } - } - /* - * Linefeeds match to single space characters. - */ - else if (eptr->type == E_LINEFEED) - { - if (equal) - { - if (*mptr == ' ') - { - mptr--; - if (mptr < match) - { - found = 1; - start->id =eptr->ele_id; - start->pos = 0; - } - } - else - { - equal = 0; - } - } - else - { - mptr = mend; - if (*mptr == ' ') - { - equal = 1; - end->id = eptr->ele_id; - end->pos = 0; - mptr--; - if (mptr < match) - { - found = 1; - start->id =eptr->ele_id; - start->pos = 0; - } - } - } - } - if (found) - { - break; - } - eptr = eptr->prev; - } - } - else /* forward */ - { - found = 0; - equal = 0; - mptr = match; - - if (s_eptr != NULL) - { - eptr = s_eptr; - } - else - { - eptr = hw->html.formatted_elements; - } - - while (eptr != NULL) - { - /* - * Skip the special internal text - */ - if (eptr->internal == True) - { - eptr = eptr->next; - continue; - } - - if (eptr->type == E_TEXT) - { - tptr = eptr->edata; - if (eptr == s_eptr) - { - tptr = (char *)(tptr + s_pos); - } - while (*tptr != '\0') - { - if (equal) - { - if (caseless) - { - cval =(char)TOLOWER((int)*tptr); - } - else - { - cval = *tptr; - } - while ((*mptr != '\0')&& - (cval == *mptr)) - { - tptr++; - mptr++; - if (caseless) - { - cval =(char)TOLOWER((int)*tptr); - } - else - { - cval = *tptr; - } - } - if (*mptr == '\0') - { - found = 1; - end->id = eptr->ele_id; - end->pos = (int) - (tptr - eptr->edata); - break; - } - else if (*tptr == '\0') - { - break; - } - else - { - equal = 0; - } - } - else - { - mptr = match; - if (caseless) - { - cval =(char)TOLOWER((int)*tptr); - } - else - { - cval = *tptr; - } - while ((*tptr != '\0')&& - (cval != *mptr)) - { - tptr++; - if (caseless) - { - cval =(char)TOLOWER((int)*tptr); - } - else - { - cval = *tptr; - } - } - if (cval == *mptr) - { - equal = 1; - start->id = eptr->ele_id; - start->pos = (int) - (tptr - eptr->edata); - } - } - } - } - else if (eptr->type == E_LINEFEED) - { - if (equal) - { - if (*mptr == ' ') - { - mptr++; - if (*mptr == '\0') - { - found = 1; - end->id = eptr->ele_id; - end->pos = 0; - } - } - else - { - equal = 0; - } - } - else - { - mptr = match; - if (*mptr == ' ') - { - equal = 1; - start->id = eptr->ele_id; - start->pos = 0; - mptr++; - if (*mptr == '\0') - { - found = 1; - end->id = eptr->ele_id; - end->pos = 0; - } - } - } - } - if (found) - { - break; - } - eptr = eptr->next; - } - } - - if (found) - { - m_start->id = start->id; - m_start->pos = start->pos; - m_end->id = end->id; - m_end->pos = end->pos; - } - - if (caseless) - { - free(match); - } - - if (found) - { - return(1); - } - else - { - return(-1); - } -} - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTML.h xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTML.h --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTML.h Sun Jun 1 17:22:03 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTML.h Thu Jan 1 00:00:00 1970 @@ -1,571 +0,0 @@ -/**************************************************************************** - * NCSA Mosaic for the X Window System * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * mosaic@ncsa.uiuc.edu * - * * - * Copyright (C) 1993, Board of Trustees of the University of Illinois * - * * - * NCSA Mosaic software, both binary and source (hereafter, Software) is * - * copyrighted by The Board of Trustees of the University of Illinois * - * (UI), and ownership remains with the UI. * - * * - * The UI grants you (hereafter, Licensee) a license to use the Software * - * for academic, research and internal business purposes only, without a * - * fee. Licensee may distribute the binary and source code (if released) * - * to third parties provided that the copyright notice and this statement * - * appears on all copies and that no charge is associated with such * - * copies. * - * * - * Licensee may make derivative works. However, if Licensee distributes * - * any derivative work based on or derived from the Software, then * - * Licensee will (1) notify NCSA regarding its distribution of the * - * derivative work, and (2) clearly notify users that such derivative * - * work is a modified version and not the original NCSA Mosaic * - * distributed by the UI. * - * * - * Any Licensee wishing to make commercial use of the Software should * - * contact the UI, c/o NCSA, to negotiate an appropriate license for such * - * commercial use. Commercial use includes (1) integration of all or * - * part of the source code into a product for sale or license by or on * - * behalf of Licensee to third parties, or (2) distribution of the binary * - * code or source code to third parties that need it to utilize a * - * commercial product sold or licensed by or on behalf of Licensee. * - * * - * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR * - * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED * - * WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE * - * USERS OF THIS SOFTWARE. * - * * - * By using or copying this Software, Licensee agrees to abide by the * - * copyright law and all other applicable laws of the U.S. including, but * - * not limited to, export control laws, and the terms of this license. * - * UI shall have the right to terminate this license immediately by * - * written notice upon Licensee's breach of, or non-compliance with, any * - * of its terms. Licensee may be held legally responsible for any * - * copyright infringement that is caused or encouraged by Licensee's * - * failure to abide by the terms of this license. * - * * - * Comments and questions are welcome and can be sent to * - * mosaic-x@ncsa.uiuc.edu. * - ****************************************************************************/ - -#ifndef HTML_H -#define HTML_H - -#if 0 -/* define via the Imakefile -elf*/ -#ifndef MOTIF -#define MOTIF -#endif -#endif - -#ifdef MOTIF -#include -#if (XmVERSION == 1)&&(XmREVISION >= 2) -#undef MOTIF1_2 -#define MOTIF1_2 -#endif -#else -#include -#include -#endif /* MOTIF */ -#include - - - -typedef int (*visitTestProc)(); -typedef void (*pointerTrackProc)(); - -typedef struct ele_ref_rec { - int id, pos; -} ElementRef; - -typedef struct link_rec { - char *href; - char *role; -} LinkInfo; - -/* - * Public functions - */ -#ifdef _NO_PROTO -extern char *HTMLGetText (); -extern char *HTMLGetTextAndSelection (); -extern char **HTMLGetHRefs (); -extern char **HTMLGetImageSrcs (); -extern void *HTMLGetWidgetInfo (); -extern void HTMLFreeWidgetInfo (); -extern void HTMLFreeImageInfo (); -extern LinkInfo *HTMLGetLinks (); -extern int HTMLPositionToId (); -extern int HTMLIdToPosition (); -extern int HTMLAnchorToPosition (); -extern int HTMLAnchorToId (); -extern void HTMLGotoId (); -extern void HTMLRetestAnchors (); -extern void HTMLClearSelection (); -extern void HTMLSetSelection (); -extern void HTMLSetText (); -extern int HTMLSearchText (); -#else -extern char *HTMLGetText (Widget w, int pretty); -extern char *HTMLGetTextAndSelection (Widget w, char **startp, char **endp, - char **insertp); -extern char **HTMLGetHRefs (Widget w, int *num_hrefs); -extern char **HTMLGetImageSrcs (Widget w, int *num_srcs); -extern void *HTMLGetWidgetInfo (Widget w); -extern void HTMLFreeWidgetInfo (void *ptr); -extern void HTMLFreeImageInfo (Widget w); -extern LinkInfo *HTMLGetLinks (Widget w, int *num_links); -extern int HTMLPositionToId(Widget w, int x, int y); -extern int HTMLIdToPosition(Widget w, int element_id, int *x, int *y); -extern int HTMLAnchorToPosition(Widget w, char *name, int *x, int *y); -extern int HTMLAnchorToId(Widget w, char *name); -extern void HTMLGotoId(Widget w, int element_id); -extern void HTMLRetestAnchors(Widget w, visitTestProc testFunc); -extern void HTMLClearSelection (Widget w); -extern void HTMLSetSelection (Widget w, ElementRef *start, ElementRef *end); -extern void HTMLSetText (Widget w, char *text, char *header_text, - char *footer_text, int element_id, - char *target_anchor, void *ptr); -extern int HTMLSearchText (Widget w, char *pattern, - ElementRef *m_start, ElementRef *m_end, int backward, int caseless); -#endif /* _NO_PROTO */ - - -/* - * Public Structures - */ -typedef struct acall_rec { - XEvent *event; - int element_id; - char *text; - char *href; -} WbAnchorCallbackData; - - -typedef struct fcall_rec { - XEvent *event; - char *href; - char *method; - char *enctype; - char *enc_entity; - int attribute_count; - char **attribute_names; - char **attribute_values; -} WbFormCallbackData; - - -typedef struct form_rec { - Widget hw; - char *action; - char *method; - char *enctype; - char *enc_entity; - int start, end; - Widget button_pressed; /* match button pressed to one of submits */ - struct form_rec *next; -} FormInfo; - - -typedef struct image_rec { - int ismap; - FormInfo *fptr; - int internal; - int delayed; - int fetched; - int width, height; - int num_colors; - int *reds; - int *greens; - int *blues; - unsigned char *image_data; - Pixmap image; - char *text; -} ImageInfo; - - -typedef struct wid_rec { - Widget w; - int type; - int id; - int x, y; - int width, height; - char *name; - char *value; - char *password; - char **mapping; - Boolean checked; - Boolean mapped; - struct wid_rec *next; -} WidgetInfo; - - -typedef enum { F_NONE, F_TEXT, F_IMAGE, F_WIDGET} FieldType; - -typedef struct table_field { - int colSpan; /* number of cells this spans vertically */ - int rowSpan; /* number of cells this spans horizontally */ - Boolean contVert; /* does this cell continue from previous */ - Boolean contHoriz; /* does this cell continue from previous */ - int alignment; /* contents alignment */ - int maxWidth; - int minWidth; - int maxHeight; - int minHeight; - int colWidth; /* uniform width for all element in this col*/ - int rowHeight; /* uniform hieght for all element in the row*/ - Boolean header; /* is this field created with or */ - - /* contents */ - FieldType type; - char *text; - XFontStruct *font; - char **formattedText; - int numLines; /* for formatted text */ - - ImageInfo *image; - WidgetInfo *winfo; -} TableField; - -typedef struct table_rec { - Boolean borders; - char *caption; - int captionAlignment; - struct mark_up *mptr; - int width,height; - int numColumns; - int numRows; - TableField *table; -} TableInfo; - -typedef struct sel_rec { - Widget hw; - struct mark_up *mptr; - int is_value; - char *retval_buf; - char *option_buf; - char **returns; - char **options; - int option_cnt; - char **value; - int value_cnt; -} SelectInfo; - - -typedef ImageInfo *(*resolveImageProc)(); - - -/* - * defines and structures used for the formatted element list - */ - -#define E_TEXT 1 -#define E_BULLET 2 -#define E_LINEFEED 3 -#define E_IMAGE 4 -#define E_WIDGET 5 -#define E_HRULE 6 -#define E_TABLE 7 - -/* define alignment values */ -#define ALIGN_BOTTOM 0 -#define ALIGN_MIDDLE 1 -#define ALIGN_TOP 2 - -#define ALIGN_LEFT 3 -#define ALIGN_CENTER 4 -#define ALIGN_RIGHT 5 - - -struct ele_rec { - int type; - ImageInfo *pic_data; - WidgetInfo *widget_data; - TableInfo *table_data; - XFontStruct *font; - int alignment; - Boolean internal; - Boolean selected; - int indent_level; - int start_pos, end_pos; - int x, y; - int y_offset; - int width; - int line_number; - int line_height; - int ele_id; - int underline_number; - Boolean dashed_underline; - Boolean strikeout; - unsigned long fg; - unsigned long bg; - char *anchorName; - char *anchorHRef; - char *edata; - int edata_len; - struct ele_rec *next; - struct ele_rec *prev; -}; - -struct ref_rec { - char *anchorHRef; - struct ref_rec *next; -}; - -struct delay_rec { - char *src; - struct delay_rec *next; -}; - - -/* - * defines and structures used for the HTML parser, and the - * parsed object list. - */ - -/* Mark types */ -#define M_UNKNOWN -1 -#define M_NONE 0 -#define M_TITLE 1 -#define M_HEADER_1 2 -#define M_HEADER_2 3 -#define M_HEADER_3 4 -#define M_HEADER_4 5 -#define M_HEADER_5 6 -#define M_HEADER_6 7 -#define M_ANCHOR 8 -#define M_PARAGRAPH 9 -#define M_ADDRESS 10 -#define M_PLAIN_TEXT 11 -#define M_UNUM_LIST 12 -#define M_NUM_LIST 13 -#define M_LIST_ITEM 14 -#define M_DESC_LIST 15 -#define M_DESC_TITLE 16 -#define M_DESC_TEXT 17 -#define M_PREFORMAT 18 -#define M_PLAIN_FILE 19 -#define M_LISTING_TEXT 20 -#define M_INDEX 21 -#define M_MENU 22 -#define M_DIRECTORY 23 -#define M_IMAGE 24 -#define M_FIXED 25 -#define M_BOLD 26 -#define M_ITALIC 27 -#define M_EMPHASIZED 28 -#define M_STRONG 29 -#define M_CODE 30 -#define M_SAMPLE 31 -#define M_KEYBOARD 32 -#define M_VARIABLE 33 -#define M_CITATION 34 -#define M_BLOCKQUOTE 35 -#define M_STRIKEOUT 36 -#define M_INPUT 37 -#define M_FORM 38 -#define M_HRULE 39 -#define M_LINEBREAK 40 -#define M_BASE 41 -#define M_SELECT 42 -#define M_OPTION 43 -#define M_TEXTAREA 44 -#define M_TABLE 45 -#define M_CAPTION 46 -#define M_TABLE_HEADER 47 -#define M_TABLE_ROW 48 -#define M_TABLE_DATA 49 -#define M_SUP 50 -#define M_SUB 51 -#define M_FIGURE 52 -#define M_COMMENT 53 -#define M_DOC_HEAD 54 /* amb 2 */ -#define M_UNDERLINED 55 /* amb 2 */ -#define M_DOC_BODY 56 /* amb 2 */ - -/* syntax of Mark types */ -#define MT_TITLE "title" -#define MT_HEADER_1 "h1" -#define MT_HEADER_2 "h2" -#define MT_HEADER_3 "h3" -#define MT_HEADER_4 "h4" -#define MT_HEADER_5 "h5" -#define MT_HEADER_6 "h6" -#define MT_ANCHOR "a" -#define MT_PARAGRAPH "p" -#define MT_ADDRESS "address" -#define MT_PLAIN_TEXT "xmp" -#define MT_UNUM_LIST "ul" -#define MT_NUM_LIST "ol" -#define MT_LIST_ITEM "li" -#define MT_DESC_LIST "dl" -#define MT_DESC_TITLE "dt" -#define MT_DESC_TEXT "dd" -#define MT_PREFORMAT "pre" -#define MT_PLAIN_FILE "plaintext" -#define MT_LISTING_TEXT "listing" -#define MT_INDEX "isindex" -#define MT_MENU "menu" -#define MT_DIRECTORY "dir" -#define MT_IMAGE "img" -#define MT_FIGURE "fig" -#define MT_FIXED "tt" -#define MT_BOLD "b" -#define MT_ITALIC "i" -#define MT_EMPHASIZED "em" -#define MT_STRONG "strong" -#define MT_CODE "code" -#define MT_SAMPLE "samp" -#define MT_KEYBOARD "kbd" -#define MT_VARIABLE "var" -#define MT_CITATION "cite" -#define MT_BLOCKQUOTE "blockquote" -#define MT_STRIKEOUT "strike" -#define MT_INPUT "input" -#define MT_FORM "form" -#define MT_HRULE "hr" -#define MT_LINEBREAK "br" -#define MT_BASE "base" -#define MT_SELECT "select" -#define MT_OPTION "option" -#define MT_TEXTAREA "textarea" -#define MT_TABLE "table" -#define MT_CAPTION "caption" -#define MT_TABLE_ROW "tr" -#define MT_TABLE_HEADER "th" -#define MT_TABLE_DATA "td" -#define MT_SUP "sup" -#define MT_SUB "sub" -#define MT_DOC_HEAD "head" /* amb 2 */ -#define MT_UNDERLINED "u" /* amb 2 */ -#define MT_DOC_BODY "body" - -/* anchor tags */ -#define AT_NAME "name" -#define AT_HREF "href" - - -struct mark_up { - int type; - int is_end; - char *start; - char *text; - char *end; - struct mark_up *next; -}; - - -/* - * New resource names - */ -#define WbNmarginWidth "marginWidth" -#define WbNmarginHeight "marginHeight" -#define WbNtext "text" -#define WbNheaderText "headerText" -#define WbNfooterText "footerText" -#define WbNtitleText "titleText" -#define WbNanchorUnderlines "anchorUnderlines" -#define WbNvisitedAnchorUnderlines "visitedAnchorUnderlines" -#define WbNdashedAnchorUnderlines "dashedAnchorUnderlines" -#define WbNdashedVisitedAnchorUnderlines "dashedVisitedAnchorUnderlines" -#define WbNanchorColor "anchorColor" -#define WbNvisitedAnchorColor "visitedAnchorColor" -#define WbNactiveAnchorFG "activeAnchorFG" -#define WbNactiveAnchorBG "activeAnchorBG" -#define WbNfancySelections "fancySelections" -#define WbNimageBorders "imageBorders" -#define WbNdelayImageLoads "delayImageLoads" -#define WbNisIndex "isIndex" -#define WbNitalicFont "italicFont" -#define WbNboldFont "boldFont" -#define WbNfixedFont "fixedFont" -#define WbNfixedboldFont "fixedboldFont" -#define WbNfixeditalicFont "fixeditalicFont" -#define WbNheader1Font "header1Font" -#define WbNheader2Font "header2Font" -#define WbNheader3Font "header3Font" -#define WbNheader4Font "header4Font" -#define WbNheader5Font "header5Font" -#define WbNheader6Font "header6Font" -#define WbNaddressFont "addressFont" -#define WbNplainFont "plainFont" -#define WbNplainboldFont "plainboldFont" -#define WbNplainitalicFont "plainitalicFont" -#define WbNlistingFont "listingFont" -#define WbNanchorCallback "anchorCallback" -#define WbNlinkCallback "linkCallback" -#define WbNsubmitFormCallback "submitFormCallback" -#define WbNpreviouslyVisitedTestFunction "previouslyVisitedTestFunction" -#define WbNresolveImageFunction "resolveImageFunction" -#define WbNresolveDelayedImage "resolveDelayedImage" -#define WbNpercentVerticalSpace "percentVerticalSpace" -#define WbNpointerMotionCallback "pointerMotionCallback" -#define WbNverticalScrollOnRight "verticalScrollOnRight" -#define WbNhorizontalScrollOnTop "horizontalScrollOnTop" -#define WbNview "view" -#define WbNverticalScrollBar "verticalScrollBar" -#define WbNhorizontalScrollBar "horizontalScrollBar" -#define WbNsupSubFont "supSubFont" /* amb */ - -/* - * New resource classes - */ -#define WbCMarginWidth "MarginWidth" -#define WbCMarginHeight "MarginHeight" -#define WbCText "Text" -#define WbCHeaderText "HeaderText" -#define WbCFooterText "FooterText" -#define WbCTitleText "TitleText" -#define WbCAnchorUnderlines "AnchorUnderlines" -#define WbCVisitedAnchorUnderlines "VisitedAnchorUnderlines" -#define WbCDashedAnchorUnderlines "DashedAnchorUnderlines" -#define WbCDashedVisitedAnchorUnderlines "DashedVisitedAnchorUnderlines" -#define WbCAnchorColor "AnchorColor" -#define WbCVisitedAnchorColor "VisitedAnchorColor" -#define WbCActiveAnchorFG "ActiveAnchorFG" -#define WbCActiveAnchorBG "ActiveAnchorBG" -#define WbCFancySelections "FancySelections" -#define WbCImageBorders "ImageBorders" -#define WbCDelayImageLoads "DelayImageLoads" -#define WbCIsIndex "IsIndex" -#define WbCItalicFont "ItalicFont" -#define WbCBoldFont "BoldFont" -#define WbCFixedFont "FixedFont" -#define WbCFixedboldFont "FixedboldFont" -#define WbCFixeditalicFont "FixeditalicFont" -#define WbCHeader1Font "Header1Font" -#define WbCHeader2Font "Header2Font" -#define WbCHeader3Font "Header3Font" -#define WbCHeader4Font "Header4Font" -#define WbCHeader5Font "Header5Font" -#define WbCHeader6Font "Header6Font" -#define WbCAddressFont "AddressFont" -#define WbCPlainFont "PlainFont" -#define WbCPlainboldFont "PlainboldFont" -#define WbCPlainitalicFont "PlainitalicFont" -#define WbCListingFont "ListingFont" -#define WbCPreviouslyVisitedTestFunction "PreviouslyVisitedTestFunction" -#define WbCResolveImageFunction "ResolveImageFunction" -#define WbCResolveDelayedImage "ResolveDelayedImage" -#define WbCPercentVerticalSpace "PercentVerticalSpace" -#define WbCPointerMotionCallback "PointerMotionCallback" -#define WbCVerticalScrollOnRight "VerticalScrollOnRight" -#define WbCHorizontalScrollOnTop "HorizontalScrollOnTop" -#define WbCView "View" -#define WbCVerticalScrollBar "VerticalScrollBar" -#define WbCHorizontalScrollBar "HorizontalScrollBar" -#define WbCSupSubFont "SupSubFont" /* amb */ - - -typedef struct _HTMLClassRec *HTMLWidgetClass; -typedef struct _HTMLRec *HTMLWidget; - -extern WidgetClass htmlWidgetClass; - - -#endif /* HTML_H */ - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLP.h xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLP.h --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLP.h Sun Jun 1 17:22:03 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLP.h Thu Jan 1 00:00:00 1970 @@ -1,247 +0,0 @@ -/**************************************************************************** - * NCSA Mosaic for the X Window System * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * mosaic@ncsa.uiuc.edu * - * * - * Copyright (C) 1993, Board of Trustees of the University of Illinois * - * * - * NCSA Mosaic software, both binary and source (hereafter, Software) is * - * copyrighted by The Board of Trustees of the University of Illinois * - * (UI), and ownership remains with the UI. * - * * - * The UI grants you (hereafter, Licensee) a license to use the Software * - * for academic, research and internal business purposes only, without a * - * fee. Licensee may distribute the binary and source code (if released) * - * to third parties provided that the copyright notice and this statement * - * appears on all copies and that no charge is associated with such * - * copies. * - * * - * Licensee may make derivative works. However, if Licensee distributes * - * any derivative work based on or derived from the Software, then * - * Licensee will (1) notify NCSA regarding its distribution of the * - * derivative work, and (2) clearly notify users that such derivative * - * work is a modified version and not the original NCSA Mosaic * - * distributed by the UI. * - * * - * Any Licensee wishing to make commercial use of the Software should * - * contact the UI, c/o NCSA, to negotiate an appropriate license for such * - * commercial use. Commercial use includes (1) integration of all or * - * part of the source code into a product for sale or license by or on * - * behalf of Licensee to third parties, or (2) distribution of the binary * - * code or source code to third parties that need it to utilize a * - * commercial product sold or licensed by or on behalf of Licensee. * - * * - * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR * - * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED * - * WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE * - * USERS OF THIS SOFTWARE. * - * * - * By using or copying this Software, Licensee agrees to abide by the * - * copyright law and all other applicable laws of the U.S. including, but * - * not limited to, export control laws, and the terms of this license. * - * UI shall have the right to terminate this license immediately by * - * written notice upon Licensee's breach of, or non-compliance with, any * - * of its terms. Licensee may be held legally responsible for any * - * copyright infringement that is caused or encouraged by Licensee's * - * failure to abide by the terms of this license. * - * * - * Comments and questions are welcome and can be sent to * - * mosaic-x@ncsa.uiuc.edu. * - ****************************************************************************/ - -#ifndef HTMLP_H -#define HTMLP_H - -#include "HTML.h" - -#ifdef MOTIF -#include -# ifdef MOTIF1_2 -# include -# endif /* MOTIF1_2 */ -#else -#include -#include -#endif /* MOTIF */ - -#include -#include - -#if defined(SYSV) || defined(SVR4) || defined(__svr4__) || defined(VMS) -#define bcopy(source, dest, count) memcpy(dest, source, count) -#define bzero(b, len) memset(b, 0, len) -#endif - - -/* - * Used for special images - */ -#define INTERNAL_IMAGE "internal-" - - -/* New fields for the HTML widget class */ -typedef struct _HTMLClassPart -{ - int none; /* no extra HTML class stuff */ -} HTMLClassPart; - - -typedef struct _HTMLClassRec -{ - CoreClassPart core_class; - CompositeClassPart composite_class; - ConstraintClassPart constraint_class; -#ifdef MOTIF - XmManagerClassPart manager_class; -#endif /* MOTIF */ - HTMLClassPart html_class; -} HTMLClassRec; - - -extern HTMLClassRec htmlClassRec; - - -/* New fields for the HTML widget */ -typedef struct _HTMLPart -{ - /* Resources */ - Dimension margin_width; - Dimension margin_height; - - Widget view; - Widget hbar; - Widget vbar; - Boolean hbar_top; - Boolean vbar_right; - - XtCallbackList anchor_callback; - XtCallbackList link_callback; - XtCallbackList form_callback; - - char *title; - char *raw_text; - char *header_text; - char *footer_text; -/* - * Without motif we have to define our own forground resource - * instead of using the manager's - */ -#ifndef MOTIF - Pixel foreground; -#endif - Pixel anchor_fg; - Pixel visitedAnchor_fg; - Pixel activeAnchor_fg; - Pixel activeAnchor_bg; - int num_anchor_underlines; - int num_visitedAnchor_underlines; - Boolean dashed_anchor_lines; - Boolean dashed_visitedAnchor_lines; - Boolean fancy_selections; - Boolean border_images; - Boolean delay_images; - Boolean is_index; - int percent_vert_space; - - XFontStruct *font; - XFontStruct *italic_font; - XFontStruct *bold_font; - XFontStruct *fixed_font; - XFontStruct *fixedbold_font; - XFontStruct *fixeditalic_font; - XFontStruct *header1_font; - XFontStruct *header2_font; - XFontStruct *header3_font; - XFontStruct *header4_font; - XFontStruct *header5_font; - XFontStruct *header6_font; - XFontStruct *address_font; - XFontStruct *plain_font; - XFontStruct *plainbold_font; - XFontStruct *plainitalic_font; - XFontStruct *listing_font; -/* amb */ - XFontStruct *supsub_font; -/* end amb */ - - XtPointer previously_visited_test; - XtPointer resolveImage; - XtPointer resolveDelayedImage; - - XtPointer pointer_motion_callback; - - /* PRIVATE */ - Dimension max_pre_width; - Dimension view_width; - Dimension view_height; - int doc_width; - int doc_height; - int scroll_x; - int scroll_y; - Boolean use_hbar; - Boolean use_vbar; - struct ele_rec *formatted_elements; - int line_count; - struct ele_rec **line_array; - struct ele_rec *select_start; - struct ele_rec *select_end; - int sel_start_pos; - int sel_end_pos; - struct ele_rec *new_start; - struct ele_rec *new_end; - int new_start_pos; - int new_end_pos; - struct ele_rec *active_anchor; - GC drawGC; - int press_x; - int press_y; - Time but_press_time; - Time selection_time; - struct mark_up *html_objects; - struct mark_up *html_header_objects; - struct mark_up *html_footer_objects; - struct ref_rec *my_visited_hrefs; - struct delay_rec *my_delayed_images; - WidgetInfo *widget_list; - FormInfo *form_list; - - struct ele_rec *cached_tracked_ele; -} HTMLPart; - - -typedef struct _HTMLRec -{ - CorePart core; - CompositePart composite; - ConstraintPart constraint; -#ifdef MOTIF - XmManagerPart manager; -#endif /* MOTIF */ - HTMLPart html; -} HTMLRec; - -/* - * to reduce the number of MOTIF/ATHENA ifdefs around the code - * we use some generalized constants - */ -#ifdef MOTIF -# define XxNx XmNx -# define XxNy XmNy -# define XxNwidth XmNwidth -# define XxNheight XmNheight -# define XxNset XmNset -# define XxNvalue XmNvalue -#else -# define XxNx XtNx -# define XxNy XtNy -# define XxNwidth XtNwidth -# define XxNheight XtNheight -# define XxNset XtNstate -# define XxNvalue XtNstring -#endif /* MOTIF */ - - -#endif /* HTMLP_H */ diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLamp.h xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLamp.h --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLamp.h Sun Jun 1 17:22:03 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLamp.h Thu Jan 1 00:00:00 1970 @@ -1,141 +0,0 @@ -/**************************************************************************** - * NCSA Mosaic for the X Window System * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * mosaic@ncsa.uiuc.edu * - * * - * Copyright (C) 1993, Board of Trustees of the University of Illinois * - * * - * NCSA Mosaic software, both binary and source (hereafter, Software) is * - * copyrighted by The Board of Trustees of the University of Illinois * - * (UI), and ownership remains with the UI. * - * * - * The UI grants you (hereafter, Licensee) a license to use the Software * - * for academic, research and internal business purposes only, without a * - * fee. Licensee may distribute the binary and source code (if released) * - * to third parties provided that the copyright notice and this statement * - * appears on all copies and that no charge is associated with such * - * copies. * - * * - * Licensee may make derivative works. However, if Licensee distributes * - * any derivative work based on or derived from the Software, then * - * Licensee will (1) notify NCSA regarding its distribution of the * - * derivative work, and (2) clearly notify users that such derivative * - * work is a modified version and not the original NCSA Mosaic * - * distributed by the UI. * - * * - * Any Licensee wishing to make commercial use of the Software should * - * contact the UI, c/o NCSA, to negotiate an appropriate license for such * - * commercial use. Commercial use includes (1) integration of all or * - * part of the source code into a product for sale or license by or on * - * behalf of Licensee to third parties, or (2) distribution of the binary * - * code or source code to third parties that need it to utilize a * - * commercial product sold or licensed by or on behalf of Licensee. * - * * - * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR * - * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED * - * WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE * - * USERS OF THIS SOFTWARE. * - * * - * By using or copying this Software, Licensee agrees to abide by the * - * copyright law and all other applicable laws of the U.S. including, but * - * not limited to, export control laws, and the terms of this license. * - * UI shall have the right to terminate this license immediately by * - * written notice upon Licensee's breach of, or non-compliance with, any * - * of its terms. Licensee may be held legally responsible for any * - * copyright infringement that is caused or encouraged by Licensee's * - * failure to abide by the terms of this license. * - * * - * Comments and questions are welcome and can be sent to * - * mosaic-x@ncsa.uiuc.edu. * - ****************************************************************************/ - - -typedef struct amp_esc_rec { - char *tag; - char value; -} AmpEsc; - -static AmpEsc AmpEscapes[] = { - {"lt", '<'}, - {"LT", '<'}, - {"gt", '>'}, - {"GT", '>'}, - {"amp", '&'}, - {"AMP", '&'}, - {"quot", '\"'}, - {"QUOT", '\"'}, - {"Agrave", '\300'}, - {"Aacute", '\301'}, - {"Acirc", '\302'}, - {"Atilde", '\303'}, - {"Auml", '\304'}, - {"Aring", '\305'}, - {"AElig", '\306'}, - {"Ccedil", '\307'}, - {"Egrave", '\310'}, - {"Eacute", '\311'}, - {"Ecirc", '\312'}, - {"Euml", '\313'}, - {"Igrave", '\314'}, - {"Iacute", '\315'}, - {"Icirc", '\316'}, - {"Iuml", '\317'}, - {"ETH", '\320'}, - {"Ntilde", '\321'}, - {"Ograve", '\322'}, - {"Oacute", '\323'}, - {"Ocirc", '\324'}, - {"Otilde", '\325'}, - {"Ouml", '\326'}, - - {"?", '\327'}, /* ? */ - - {"Oslash", '\330'}, - {"Ugrave", '\331'}, - {"Uacute", '\332'}, - {"Ucirc", '\333'}, - {"Uuml", '\334'}, - {"Yacute", '\335'}, - {"THORN", '\336'}, - {"szlig", '\337'}, - {"agrave", '\340'}, - {"aacute", '\341'}, - {"acirc", '\342'}, - {"atilde", '\343'}, - {"auml", '\344'}, - {"aring", '\345'}, - {"aelig", '\346'}, - {"ccedil", '\347'}, - {"egrave", '\350'}, - {"eacute", '\351'}, - {"ecirc", '\352'}, - {"euml", '\353'}, - {"igrave", '\354'}, - {"iacute", '\355'}, - {"icirc", '\356'}, - {"iuml", '\357'}, - {"eth", '\360'}, - {"ntilde", '\361'}, - {"ograve", '\362'}, - {"oacute", '\363'}, - {"ocirc", '\364'}, - {"otilde", '\365'}, - {"ouml", '\366'}, - - {"?", '\367'}, /* ? */ - - {"oslash", '\370'}, - {"ugrave", '\371'}, - {"uacute", '\372'}, - {"ucirc", '\373'}, - {"uuml", '\374'}, - {"yacute", '\375'}, - {"thorn", '\376'}, - {"yuml", '\377'}, - - {NULL, '\0'}, -}; - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLformat.c xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLformat.c --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLformat.c Sun Jun 1 17:22:03 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLformat.c Thu Jan 1 00:00:00 1970 @@ -1,6551 +0,0 @@ -/**************************************************************************** - * NCSA Mosaic for the X Window System * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * mosaic@ncsa.uiuc.edu * - * * - * Copyright (C) 1993, Board of Trustees of the University of Illinois * - * * - * NCSA Mosaic software, both binary and source (hereafter, Software) is * - * copyrighted by The Board of Trustees of the University of Illinois * - * (UI), and ownership remains with the UI. * - * * - * The UI grants you (hereafter, Licensee) a license to use the Software * - * for academic, research and internal business purposes only, without a * - * fee. Licensee may distribute the binary and source code (if released) * - * to third parties provided that the copyright notice and this statement * - * appears on all copies and that no charge is associated with such * - * copies. * - * * - * Licensee may make derivative works. However, if Licensee distributes * - * any derivative work based on or derived from the Software, then * - * Licensee will (1) notify NCSA regarding its distribution of the * - * derivative work, and (2) clearly notify users that such derivative * - * work is a modified version and not the original NCSA Mosaic * - * distributed by the UI. * - * * - * Any Licensee wishing to make commercial use of the Software should * - * contact the UI, c/o NCSA, to negotiate an appropriate license for such * - * commercial use. Commercial use includes (1) integration of all or * - * part of the source code into a product for sale or license by or on * - * behalf of Licensee to third parties, or (2) distribution of the binary * - * code or source code to third parties that need it to utilize a * - * commercial product sold or licensed by or on behalf of Licensee. * - * * - * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR * - * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED * - * WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE * - * USERS OF THIS SOFTWARE. * - * * - * By using or copying this Software, Licensee agrees to abide by the * - * copyright law and all other applicable laws of the U.S. including, but * - * not limited to, export control laws, and the terms of this license. * - * UI shall have the right to terminate this license immediately by * - * written notice upon Licensee's breach of, or non-compliance with, any * - * of its terms. Licensee may be held legally responsible for any * - * copyright infringement that is caused or encouraged by Licensee's * - * failure to abide by the terms of this license. * - * * - * Comments and questions are welcome and can be sent to * - * mosaic-x@ncsa.uiuc.edu. * - ****************************************************************************/ - -#ifdef TIMING -#include -struct timeval Tv; -struct timezone Tz; -#endif - -#include -#include -#include "HTMLP.h" - - -/* - * I need my own is ispunct function because I need a closing paren - * immediately after a word to act like punctuation. - */ -#define MY_ISPUNCT(val) (ispunct((int)(val)) || ((val) == ')')) - -#define INDENT_SPACES 2 -#define IMAGE_BORDER 2 - -#define D_NONE 0 -#define D_TITLE 1 -#define D_TEXT 2 -#define D_OLIST 3 -#define D_ULIST 4 - -extern struct ele_rec *AddEle(); -extern void FreeLineList(); -extern void FreeObjList(); -extern int SwapElements(); -extern struct ele_rec **MakeLineList(); -extern char *ParseMarkTag(); -extern char *MaxTextWidth(); -extern char *IsMapForm(); -extern char *DelayedHRef(); -extern int IsDelayedHRef(); -extern int AnchoredHeight(); -extern struct mark_up *HTMLParse(); -extern struct ref_rec *FindHRef(); -extern struct delay_rec *FindDelayedImage(); -extern ImageInfo *NoImageData(); -extern ImageInfo *DelayedImageData(); -extern Pixmap NoImage(); -extern Pixmap DelayedImage(); -extern Pixmap InfoToImage(); -extern int caseless_equal(); -extern void clean_white_space(); -extern void WidgetRefresh(); -extern WidgetInfo *MakeWidget(); -extern XFontStruct *GetWidgetFont(); -extern void AddNewForm(); -extern void PrepareFormEnd(); -extern char *ComposeCommaList(); -extern void FreeCommaList(); -extern TableInfo *MakeTable(); -extern void TableRefresh(); - - -/* - * To allow arbitrary nesting of lists - */ -typedef struct dtype_rec { - int type; /* D_NONE, D_TITLE, D_TEXT, D_OLIST, D_ULIST */ - int count; - int compact; - struct dtype_rec *next; -} DescRec; - - -/* - * To allow arbitrary nesting of font changes - */ -typedef struct font_rec { - XFontStruct *font; - struct font_rec *next; -} FontRec; - -static DescRec BaseDesc; -static DescRec *DescType; -static DescRec *ListData; -static FontRec FontBase; -static FontRec *FontStack; -static XFontStruct *currentFont; -static XFontStruct *saveFont; -static unsigned long Fg; -static unsigned long Bg; -static int Width; -static int MaxWidth; -static int ElementId; -static int WidgetId; -static int LineNumber; -static int LineHeight; -static int LineBottom; -static int BaseLine; -static int TextIndent; -static int MarginW; -static int Ignore; -static int Preformat; -static int PF_LF_State; /* Pre-formatted linefeed state. Hack for bad HTMLs */ -static int NeedSpace; -static Boolean Internal; -static Boolean DashedUnderlines; -static Boolean Strikeout; -static int Underlines; -static int CharsInLine; -static int IndentLevel; -static struct ele_rec *Current; -static char *AnchorText; -static char *TitleText; -static char *TextAreaBuf; -static struct mark_up *Last; -static FormInfo *CurrentForm; -static SelectInfo *CurrentSelect; -static int Superscript; /* amb */ -static int Subscript; -static XFontStruct *nonScriptFont; -static int InDocHead; -static int InUnderlined; - -/* - * Turned out we were taking WAY too much time mallocing and freeing - * memory when composing the lines into elements. So this ineligent - * method minimizes all that. - */ -#define COMP_LINE_BUF_LEN 1024 -static char *CompLine = NULL; -static int CompLineLen = 0; -static char *CompWord = NULL; -static int CompWordLen = 0; - - - -/* - * Create a formatted element - */ -struct ele_rec * -CreateElement(hw, type, fp, x, y, edata) - HTMLWidget hw; - int type; - XFontStruct *fp; - int x, y; - char *edata; -{ - struct ele_rec *eptr; - int baseline; - - if (fp != NULL) - { - baseline = fp->max_bounds.ascent; - } - else - { - baseline = LineHeight; - } - - eptr = (struct ele_rec *)malloc(sizeof(struct ele_rec)); - if (eptr == NULL) - { - fprintf(stderr, "Cannot allocate space for element buffer\n"); - exit(1); - } - - eptr->type = type; - eptr->pic_data = NULL; - eptr->widget_data = NULL; - eptr->table_data = NULL; - eptr->font = fp; - eptr->alignment = ALIGN_BOTTOM; - eptr->selected = False; - eptr->internal = Internal; - eptr->strikeout = Strikeout; - eptr->x = x; - eptr->y = y; - eptr->y_offset = 0; - eptr->width = 0; - eptr->line_number = LineNumber; - eptr->line_height = LineHeight; - eptr->fg = Fg; - eptr->bg = Bg; - eptr->underline_number = Underlines; - eptr->dashed_underline = DashedUnderlines; - eptr->indent_level = IndentLevel; - - switch(type) - { - case E_TEXT: - /* - * get a unique element id - */ - ElementId++; - eptr->ele_id = ElementId; - - eptr->y_offset = 0; - - eptr->edata_len = strlen(edata) + 1; - eptr->edata = (char *)malloc(eptr->edata_len); - if (eptr->edata == NULL) - { - eptr->edata_len = 0; - fprintf(stderr, "Cannot allocate space for copy of text element data\n"); - exit(1); - } - strcpy(eptr->edata, edata); - - /* - * if this is an anchor, puts its href value into - * the element. - */ - if (AnchorText != NULL) - { - eptr->anchorHRef = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_HREF); - eptr->anchorName = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_NAME); - } - else - { - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - } - break; - case E_BULLET: - eptr->ele_id = ElementId; - - if (BaseLine == -100) - { - BaseLine = baseline; - if (LineBottom == 0) - { - LineBottom = LineHeight - baseline; - } - else - { - /* - * It is possible (with the first item - * in a line being a top aligned image) - * for LineBottom to have already been - * set. It now needs to be - * corrected as we set a real - * BaseLine - */ - if ((LineHeight - baseline) > - (LineBottom - baseline)) - { - LineBottom = LineHeight - - baseline; - } - else - { - LineBottom = LineBottom - - baseline; - } - } - } - else if (baseline < BaseLine) - { - eptr->y_offset = BaseLine - baseline; - } - - /* - * Bullets can't be underlined! - */ - eptr->underline_number = 0; - - eptr->edata = NULL; - eptr->edata_len = 0; - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - break; - case E_HRULE: - /* - * get a unique element id - */ - ElementId++; - eptr->ele_id = ElementId; - - if (BaseLine == -100) - { - BaseLine = baseline; - if (LineBottom == 0) - { - LineBottom = LineHeight - baseline; - } - else - { - /* - * It is possible (with the first item - * in a line being a top aligned image) - * for LineBottom to have already been - * set. It now needs to be - * corrected as we set a real - * BaseLine - */ - if ((LineHeight - baseline) > - (LineBottom - baseline)) - { - LineBottom = LineHeight - - baseline; - } - else - { - LineBottom = LineBottom - - baseline; - } - } - } - else if (baseline < BaseLine) - { - eptr->y_offset = BaseLine - baseline; - } - - /* - * Rules can't be underlined! - */ - eptr->underline_number = 0; - - eptr->edata = NULL; - eptr->edata_len = 0; - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - break; - case E_LINEFEED: - eptr->ele_id = ElementId; - - eptr->y_offset = 0; - - if (BaseLine == -100) - { - BaseLine = baseline; - if (LineBottom == 0) - { - LineBottom = LineHeight - baseline; - } - else - { - /* - * It is possible (with the first item - * in a line being a top aligned image) - * for LineBottom to have already been - * set. It now needs to be - * corrected as we set a real - * BaseLine - */ - if ((LineHeight - baseline) > - (LineBottom - baseline)) - { - LineBottom = LineHeight - - baseline; - } - else - { - LineBottom = LineBottom - - baseline; - } - } - } - - /* - * Linefeeds have to use the maximum line height. - * Deal with bad Lucidia descents. - */ -#ifdef NO_EXTRA_FILLS - eptr->line_height = eptr->font->ascent + - eptr->font->descent; -#else - eptr->line_height = LineHeight; -#endif /* NO_EXTRA_FILLS */ - if ((BaseLine + LineBottom) > eptr->line_height) - { - eptr->line_height = BaseLine + LineBottom; - } - - /* - * Linefeeds can't be underlined! - */ - eptr->underline_number = 0; - - eptr->edata = NULL; - eptr->edata_len = 0; - /* - * if this linefeed is part of a broken anchor put - * its href value into the element so we can reconnect - * it when activated. - * If it at the beginning of an anchor, don't put - * the href in, and change the color back. - */ - if (AnchorText != NULL) - { - char *tptr; - - tptr = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_HREF); - if ((Current != NULL)&& - ((Current->anchorHRef == NULL)|| - (tptr == NULL)|| - (strcmp(Current->anchorHRef, tptr) != 0))) - { - if (tptr) - free(tptr); - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ -#ifdef MOTIF - eptr->fg = hw->manager.foreground; -#else - eptr->fg = hw->html.foreground; -#endif /* MOTIF */ - } - else - { - eptr->anchorHRef = tptr; - eptr->anchorName = - ParseMarkTag(AnchorText, - MT_ANCHOR, AT_NAME); - } - } - else - { - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - } - break; - case E_IMAGE: - /* - * get a unique element id - */ - ElementId++; - eptr->ele_id = ElementId; - - /* - * Images can't be underlined! - */ - eptr->underline_number = 0; - - if (edata != NULL) - { - eptr->edata_len = strlen(edata) + 1; - eptr->edata = (char *)malloc(eptr->edata_len); - if (eptr->edata == NULL) - { - eptr->edata_len = 0; - fprintf(stderr, "Cannot allocate space for copy of image element data\n"); - exit(1); - } - strcpy(eptr->edata, edata); - } - else - { - eptr->edata_len = 0; - eptr->edata = NULL; - } - - /* - * if this image is part of an anchor put - * its href and name values into the element - * so we can reconnect it when activated. - */ - if (AnchorText != NULL) - { - eptr->anchorHRef = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_HREF); - eptr->anchorName = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_NAME); - } - else - { - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - } - - /* - * Picture stuff - */ - /* - * if we have an image resolver, use it. - */ - if (hw->html.resolveImage != NULL) - { - int internal; - - /* - * See if this is a special internal image - */ - if ((edata != NULL)&& - (strncmp(edata, INTERNAL_IMAGE, - strlen(INTERNAL_IMAGE)) == 0)) - { - internal = 1; - } - else - { - internal = 0; - } - - /* - * if we delay image fetching - * internal images are not delayed. - */ - if ((hw->html.delay_images == True)&& - (!internal)) - { - /* - * see if already cached. - */ - eptr->pic_data = (*(resolveImageProc) - (hw->html.resolveImage))(hw, edata, 1); - if (eptr->pic_data != NULL) - { - eptr->pic_data->delayed = 0; - /* - * Mark images we have sucessfully - * loaded at least once - */ - if (eptr->pic_data->image_data != NULL) - { - eptr->pic_data->fetched = 1; - } - } - /* - * else, not cached. - */ - else - { - /* - * just image - */ - if (eptr->anchorHRef == NULL) - { - eptr->pic_data = DelayedImageData(hw, - False); - eptr->pic_data->delayed = 1; - eptr->anchorHRef = DelayedHRef(hw); - eptr->fg = hw->html.anchor_fg; - } - /* - * else anchor and image - */ - else - { - eptr->pic_data = DelayedImageData(hw, - True); - eptr->pic_data->delayed = 1; - } - } - } - else - { - eptr->pic_data = (*(resolveImageProc) - (hw->html.resolveImage))(hw, edata, 0); - if (eptr->pic_data != NULL) - { - eptr->pic_data->delayed = 0; - /* - * Mark images we have sucessfully - * loaded at least once - */ - if (eptr->pic_data->image_data != NULL) - { - eptr->pic_data->fetched = 1; - } - } - } - if (eptr->pic_data != NULL) - { - eptr->pic_data->internal = internal; - } - } - if (eptr->pic_data == NULL) - { - eptr->pic_data = NoImageData(hw); - eptr->pic_data->delayed = 0; - eptr->pic_data->internal = 0; - } - - break; - case E_TABLE: - ElementId++; - eptr->ele_id = ElementId; - /* - * Table's can't be underlined - */ - eptr->underline_number = 0; - - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - eptr->edata = NULL; - eptr->edata_len = 0; - - /* - * if this table is part of an anchor put - * its href and name values into the element - * so we can reconnect it when activated. - */ - if (eptr->anchorHRef != NULL) - { - free((char *)eptr->anchorHRef); - } - if (eptr->anchorName != NULL) - { - free((char *)eptr->anchorName); - } - if (AnchorText != NULL) - { - eptr->anchorHRef = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_HREF); - eptr->anchorName = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_NAME); - } - else - { - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - } - eptr->table_data = MakeTable (hw, edata, - (x + IMAGE_BORDER), (y + IMAGE_BORDER)); - - break; - case E_WIDGET: - /* - * get a unique element id - */ - WidgetId++; - ElementId++; - eptr->ele_id = ElementId; - - /* - * Widgets can't be underlined! - */ - eptr->underline_number = 0; - - eptr->edata = NULL; - eptr->edata_len = 0; - - /* - * if this widget is part of an anchor put - * its href and name values into the element - * so we can reconnect it when activated. - */ - if (AnchorText != NULL) - { - eptr->anchorHRef = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_HREF); - eptr->anchorName = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_NAME); - } - else - { - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - } - - /* - * Widget stuff - */ - eptr->widget_data = MakeWidget(hw, edata, - (x + IMAGE_BORDER), (y + IMAGE_BORDER), - WidgetId, CurrentForm); - - /* - * I have no idea what to do if we can't create the - * widget. It probably means we are so messed up we - * will soon be crashing. - */ - if (eptr->widget_data == NULL) - { - } - - break; - default: - fprintf(stderr, "CreateElement: Unknown type %d\n", type); - eptr->ele_id = ElementId; - - eptr->edata = NULL; - eptr->edata_len = 0; - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - break; - } - return(eptr); -} /* CreateElement() */ - - -/* - * Set the formatted element into the format list. Use a pre-allocated - * list position if possible, otherwise allocate a new list position. - */ -void -SetElement(hw, type, fp, x, y, edata) - HTMLWidget hw; - int type; - XFontStruct *fp; - int x, y; - char *edata; -{ - struct ele_rec *eptr; - int len; - int baseline; - - if (fp != NULL) - { - baseline = fp->max_bounds.ascent; - } - else - { - baseline = LineHeight; - } - - /* - * There is not pre-allocated format list, or we have reached - * the end of the pre-allocated list. Create a new element, and - * add it. - */ - if ((hw->html.formatted_elements == NULL)|| - ((Current != NULL)&&(Current->next == NULL))) - { - eptr = CreateElement(hw, type, fp, x, y, edata); - Current = AddEle(&(hw->html.formatted_elements), Current, eptr); - return; - } - - /* - * If current is null, but we have a pre-allocated format list, then - * this is the first SetElement() call for this formated text, and - * we must set current to the head of the formatted list. Otherwise - * we move current to the next pre-allocated list position. - */ - if (Current == NULL) - { - Current = hw->html.formatted_elements; - } - else - { - Current = Current->next; - } - - eptr = Current; - if (eptr == NULL) - { - fprintf(stderr, "SetElement: Error, setting a null element\n"); - exit(1); - } - - eptr->type = type; - eptr->pic_data = NULL; - eptr->widget_data = NULL; - eptr->table_data = NULL; - eptr->font = fp; - eptr->alignment = ALIGN_BOTTOM; - eptr->selected = False; - eptr->internal = Internal; - eptr->strikeout = Strikeout; - eptr->x = x; - eptr->y = y; - eptr->y_offset = 0; - eptr->width = 0; - eptr->line_number = LineNumber; - eptr->line_height = LineHeight; - eptr->fg = Fg; - eptr->bg = Bg; - eptr->underline_number = Underlines; - eptr->dashed_underline = DashedUnderlines; - eptr->indent_level = IndentLevel; - - switch(type) - { - case E_TEXT: - /* - * get a unique element id - */ - ElementId++; - eptr->ele_id = ElementId; - - eptr->y_offset = 0; - - len = strlen(edata) + 1; - if (len > eptr->edata_len) - { - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - eptr->edata = (char *)malloc(len); - if (eptr->edata == NULL) - { - eptr->edata_len = 0; - fprintf(stderr, "Cannot allocate space for copy of text element data\n"); - exit(1); - } - } - eptr->edata_len = len; - strcpy(eptr->edata, edata); - - /* - * if this is an anchor, puts its href and name - * values into the element. - */ - if (eptr->anchorHRef != NULL) - { - free((char *)eptr->anchorHRef); - } - if (eptr->anchorName != NULL) - { - free((char *)eptr->anchorName); - } - if (AnchorText != NULL) - { - eptr->anchorHRef = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_HREF); - eptr->anchorName = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_NAME); - } - else - { - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - } - break; - case E_BULLET: - eptr->ele_id = ElementId; - - if (BaseLine == -100) - { - BaseLine = baseline; - if (LineBottom == 0) - { - LineBottom = LineHeight - baseline; - } - else - { - /* - * It is possible (with the first item - * in a line being a top aligned image) - * for LineBottom to have already been - * set. It now needs to be - * corrected as we set a real - * BaseLine - */ - if ((LineHeight - baseline) > - (LineBottom - baseline)) - { - LineBottom = LineHeight - - baseline; - } - else - { - LineBottom = LineBottom - - baseline; - } - } - } - else if (baseline < BaseLine) - { - eptr->y_offset = BaseLine - baseline; - } - - /* - * Bullets can't be underlined! - */ - eptr->underline_number = 0; - - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - eptr->edata = NULL; - eptr->edata_len = 0; - if (eptr->anchorHRef != NULL) - { - free((char *)eptr->anchorHRef); - } - if (eptr->anchorName != NULL) - { - free((char *)eptr->anchorName); - } - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - break; - case E_HRULE: - /* - * get a unique element id - */ - ElementId++; - eptr->ele_id = ElementId; - - if (BaseLine == -100) - { - BaseLine = baseline; - if (LineBottom == 0) - { - LineBottom = LineHeight - baseline; - } - else - { - /* - * It is possible (with the first item - * in a line being a top aligned image) - * for LineBottom to have already been - * set. It now needs to be - * corrected as we set a real - * BaseLine - */ - if ((LineHeight - baseline) > - (LineBottom - baseline)) - { - LineBottom = LineHeight - - baseline; - } - else - { - LineBottom = LineBottom - - baseline; - } - } - } - else if (baseline < BaseLine) - { - eptr->y_offset = BaseLine - baseline; - } - - /* - * Rules can't be underlined! - */ - eptr->underline_number = 0; - - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - eptr->edata = NULL; - eptr->edata_len = 0; - if (eptr->anchorHRef != NULL) - { - free((char *)eptr->anchorHRef); - } - if (eptr->anchorName != NULL) - { - free((char *)eptr->anchorName); - } - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - break; - case E_LINEFEED: - eptr->ele_id = ElementId; - - eptr->y_offset = 0; - - if (BaseLine == -100) - { - BaseLine = baseline; - if (LineBottom == 0) - { - LineBottom = LineHeight - baseline; - } - else - { - /* - * It is possible (with the first item - * in a line being a top aligned image) - * for LineBottom to have already been - * set. It now needs to be - * corrected as we set a real - * BaseLine - */ - if ((LineHeight - baseline) > - (LineBottom - baseline)) - { - LineBottom = LineHeight - - baseline; - } - else - { - LineBottom = LineBottom - - baseline; - } - } - } - - /* - * Linefeeds have to use the maximum line height. - * Deal with bad Lucidia descents. - */ -#ifdef NO_EXTRA_FILLS - eptr->line_height = eptr->font->ascent + - eptr->font->descent; -#else - eptr->line_height = LineHeight; -#endif /* NO_EXTRA_FILLS */ - if ((BaseLine + LineBottom) > eptr->line_height) - { - eptr->line_height = (BaseLine + LineBottom); - } - - /* - * Linefeeds can't be underlined! - */ - eptr->underline_number = 0; - - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - eptr->edata = NULL; - eptr->edata_len = 0; - /* - * if this linefeed is part of a broken anchor put - * its href and name values into the element - * so we can reconnect it when activated. - * If it at the beginning of an anchor, don't put - * the href in and change the color back. - */ - if (eptr->anchorHRef != NULL) - { - free((char *)eptr->anchorHRef); - } - if (eptr->anchorName != NULL) - { - free((char *)eptr->anchorName); - } - if (AnchorText != NULL) - { - char *tptr; - - tptr = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_HREF); - if ((eptr->prev != NULL)&& - ((eptr->prev->anchorHRef == NULL)|| - (tptr == NULL)|| - (strcmp(eptr->prev->anchorHRef, tptr) != 0))) - { - if (tptr) - free(tptr); - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ -#ifdef MOTIF - eptr->fg = hw->manager.foreground; -#else - eptr->fg = hw->html.foreground; -#endif /* MOTIF */ - } - else - { - eptr->anchorHRef = tptr; - eptr->anchorName = - ParseMarkTag(AnchorText, - MT_ANCHOR, AT_NAME); - } - } - else - { - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - } - break; - case E_IMAGE: - /* - * get a unique element id - */ - ElementId++; - eptr->ele_id = ElementId; - - /* - * Images can't be underlined! - */ - eptr->underline_number = 0; - - if (edata != NULL) - { - len = strlen(edata) + 1; - if (len > eptr->edata_len) - { - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - eptr->edata = (char *)malloc(len); - if (eptr->edata == NULL) - { - eptr->edata_len = 0; - fprintf(stderr, "Cannot allocate space for copy of text element data\n"); - exit(1); - } - } - eptr->edata_len = len; - strcpy(eptr->edata, edata); - } - else - { - eptr->edata_len = 0; - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - eptr->edata = NULL; - } - - /* - * if this image is part of an anchor put - * its href and name values into the element - * so we can reconnect it when activated. - */ - if (eptr->anchorHRef != NULL) - { - free((char *)eptr->anchorHRef); - } - if (eptr->anchorName != NULL) - { - free((char *)eptr->anchorName); - } - if (AnchorText != NULL) - { - eptr->anchorHRef = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_HREF); - eptr->anchorName = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_NAME); - } - else - { - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - } - - /* - * Picture stuff - */ - /* - * if we have an image resolver, use it. - */ - if (hw->html.resolveImage != NULL) - { - int internal; - - /* - * See if this is a special internal image - */ - if ((edata != NULL)&& - (strncmp(edata, INTERNAL_IMAGE, - strlen(INTERNAL_IMAGE)) == 0)) - { - internal = 1; - } - else - { - internal = 0; - } - - /* - * if we delay image fetching - * internal images are not delayed. - */ - if ((hw->html.delay_images == True)&& - (!internal)) - { - /* - * see if already cached. - */ - eptr->pic_data = (*(resolveImageProc) - (hw->html.resolveImage))(hw, edata, 1); - if (eptr->pic_data != NULL) - { - eptr->pic_data->delayed = 0; - /* - * Mark images we have sucessfully - * loaded at least once - */ - if (eptr->pic_data->image_data != NULL) - { - eptr->pic_data->fetched = 1; - } - } - /* - * else, not cached. - */ - else - { - /* - * just image - */ - if (eptr->anchorHRef == NULL) - { - eptr->pic_data = DelayedImageData(hw, - False); - eptr->pic_data->delayed = 1; - eptr->anchorHRef = DelayedHRef(hw); - eptr->fg = hw->html.anchor_fg; - } - /* - * else anchor and image - */ - else - { - eptr->pic_data = DelayedImageData(hw, - True); - eptr->pic_data->delayed = 1; - } - } - } - else - { - eptr->pic_data = (*(resolveImageProc) - (hw->html.resolveImage))(hw, edata, 0); - if (eptr->pic_data != NULL) - { - eptr->pic_data->delayed = 0; - /* - * Mark images we have sucessfully - * loaded at least once - */ - if (eptr->pic_data->image_data != NULL) - { - eptr->pic_data->fetched = 1; - } - } - } - if (eptr->pic_data != NULL) - { - eptr->pic_data->internal = internal; - } - } - if (eptr->pic_data == NULL) - { - eptr->pic_data = NoImageData(hw); - eptr->pic_data->delayed = 0; - eptr->pic_data->internal = 0; - } - - break; - case E_TABLE: - ElementId++; - eptr->ele_id = ElementId; - /* - * Table's can't be underlined - */ - eptr->underline_number = 0; - - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - eptr->edata = NULL; - eptr->edata_len = 0; - - /* - * if this table is part of an anchor put - * its href and name values into the element - * so we can reconnect it when activated. - */ - if (eptr->anchorHRef != NULL) - { - free((char *)eptr->anchorHRef); - } - if (eptr->anchorName != NULL) - { - free((char *)eptr->anchorName); - } - if (AnchorText != NULL) - { - eptr->anchorHRef = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_HREF); - eptr->anchorName = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_NAME); - } - else - { - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - } - eptr->table_data = MakeTable (hw, edata, - (x + IMAGE_BORDER), (y + IMAGE_BORDER)); - - break; - case E_WIDGET: - /* - * get a unique element id - */ - WidgetId++; - ElementId++; - eptr->ele_id = ElementId; - - /* - * Widgets can't be underlined! - */ - eptr->underline_number = 0; - - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - eptr->edata = NULL; - eptr->edata_len = 0; - - /* - * if this widget is part of an anchor put - * its href and name values into the element - * so we can reconnect it when activated. - */ - if (eptr->anchorHRef != NULL) - { - free((char *)eptr->anchorHRef); - } - if (eptr->anchorName != NULL) - { - free((char *)eptr->anchorName); - } - if (AnchorText != NULL) - { - eptr->anchorHRef = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_HREF); - eptr->anchorName = ParseMarkTag(AnchorText, - MT_ANCHOR, AT_NAME); - } - else - { - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - } - - /* - * Widget stuff - */ - eptr->widget_data = MakeWidget(hw, edata, - (x + IMAGE_BORDER), (y + IMAGE_BORDER), - WidgetId, CurrentForm); - - /* - * I have no idea what to do if we can't create the - * widget. It probably means we are so messed up we - * will soon be crashing. - */ - if (eptr->widget_data == NULL) - { - } - - break; - default: - fprintf(stderr, "SetElement: Unknown type %d\n", type); - eptr->ele_id = ElementId; - - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - eptr->edata = NULL; - eptr->edata_len = 0; - if (eptr->anchorHRef != NULL) - { - free((char *)eptr->anchorHRef); - } - if (eptr->anchorName != NULL) - { - free((char *)eptr->anchorName); - } - eptr->anchorHRef = NULL; - eptr->anchorName = NULL; - break; - } -} /* SetElement() */ - - -/* - * Change our drawing font - */ -void -NewFont(fp) - XFontStruct *fp; -{ - /* - * Deal with bad Lucidia descents. - */ - if (fp->descent > fp->max_bounds.descent) - { - LineHeight = fp->max_bounds.ascent + fp->descent; - } - else - { - LineHeight = fp->max_bounds.ascent + fp->max_bounds.descent; - } -} - - -/* - * Place a linefeed at the end of a line. - * Create and add the element record for it. - */ -void -LinefeedPlace(hw, x, y) - HTMLWidget hw; - int *x, *y; -{ - /* - * At the end of every line check if we have a new MaxWidth - */ - if ((*x + hw->html.margin_width) > MaxWidth) - { - MaxWidth = *x + hw->html.margin_width; - } - - SetElement(hw, E_LINEFEED, currentFont, *x, *y, (char *)NULL); -} - - -/* - * We have encountered a line break. Incrment the line counter, - * and move down some space. - */ -void -LineFeed(hw, x, y) - HTMLWidget hw; - int *x, *y; -{ - /* - * Manipulate linefeed state for special pre-formatted linefeed - * hack for broken HTMLs - */ - if (Preformat) - { - switch(PF_LF_State) - { - /* - * First soft linefeed - */ - case 0: - PF_LF_State = 1; - break; - /* - * Collapse multiple soft linefeeds within a pre - */ - case 1: - return; - break; - /* - * Ignore soft linefeeds after hard linefeeds - * within a pre - */ - case 2: - return; - break; - default: - PF_LF_State = 1; - break; - } - } - /* - * No blank lines allowed at the start of a document. - */ - else if (ElementId == 0) - { - return; - } - /* - * For formatted documents there are 3 linefeed states. - * 0 = in the middle of a line. - * 1 = at left margin - * 2 = at left margin with blank line above - */ - else - { - PF_LF_State++; - if (PF_LF_State > 2) - { - PF_LF_State = 2; - } - } - - /* - * sanity check to set some line height if none was specified. - */ - if (BaseLine <= 0) - { - BaseLine = LineHeight; - } - - LinefeedPlace(hw, x, y); - - CharsInLine = 0; - *x = TextIndent; - *y = *y + BaseLine + LineBottom; - - LineBottom = 0; - BaseLine = -100; - - NeedSpace = 0; - LineNumber++; -} - - -/* - * We want to make sure that future text starts at the left margin. - * But if we are already there, don't put in a new line. - */ -void -ConditionalLineFeed(hw, x, y, state) - HTMLWidget hw; - int *x, *y; - int state; -{ - if (PF_LF_State < state) - { - /* - * If this funtion is being used to insert a blank line, - * we need to look at the percentVerticalSpace resource - * to see how high to make the line. - */ - if ((state == 2)&&(hw->html.percent_vert_space > 0)) - { - int l_height; - - l_height = LineHeight; - LineHeight = LineHeight * - hw->html.percent_vert_space / 100; - LineFeed(hw, x, y); - LineHeight = l_height; - } - else - { - LineFeed(hw, x, y); - } - } -} - - -/* - * hack to make broken HTMLs within pre-formatted text have nice - * looking linefeeds. - */ -void -HardLineFeed(hw, x, y) - HTMLWidget hw; - int *x, *y; -{ - /* - * Manipulate linefeed state for special pre-formatted linefeed - * hack for broken HTMLs - */ - if (Preformat) - { - switch(PF_LF_State) - { - /* - * First hard linefeed - */ - case 0: - PF_LF_State = 2; - break; - /* - * Previous soft linefeed should have been ignored, so - * ignore this hard linefeed, but set state like it - * was not ignored. - */ - case 1: - PF_LF_State = 2; - return; - break; - /* - * Honor multiple hard linefeeds. - */ - case 2: - break; - default: - PF_LF_State = 2; - break; - } - } - - /* - * sanity check to set some line height if none was specified. - */ - if (BaseLine <= 0) - { - BaseLine = LineHeight; - } - - LinefeedPlace(hw, x, y); - - CharsInLine = 0; - *x = TextIndent; - *y = *y + BaseLine + LineBottom; - - LineBottom = 0; - BaseLine = -100; - - NeedSpace = 0; - LineNumber++; -} - - -static void -AdjustBaseLine() -{ - int baseline; - int supsubBaseline; - - baseline = Current->font->max_bounds.ascent; - - if ((Superscript>0) || (Subscript>0)) - { - supsubBaseline = nonScriptFont->max_bounds.ascent; - baseline += ((supsubBaseline * .4) * Superscript); - baseline -= ((supsubBaseline * .4) * Subscript); - baseline += 2; - } - - if (BaseLine == -100) - { - BaseLine = baseline; - Current->y_offset = 0; - if (LineBottom == 0) - { - LineBottom = LineHeight - baseline; - } - else - { - /* - * It is possible (with the first item - * in a line being a top aligned image) - * for LineBottom to have already been - * set. It now needs to be - * corrected as we set a real - * BaseLine - */ - if ((LineHeight - baseline) > - (LineBottom - baseline)) - { - LineBottom = LineHeight - - baseline; - } - else - { - LineBottom = LineBottom - - baseline; - } - } - } - else if (baseline <= BaseLine) - { - if (baseline < BaseLine) - { - Current->y_offset = BaseLine - baseline; - } - else - { - Current->y_offset = 0; - } - - if ((LineHeight - baseline) > LineBottom) - { - LineBottom = LineHeight - baseline; - } - } - else - { - struct ele_rec *eptr; - int line, incy; - - incy = baseline - BaseLine; - BaseLine = baseline; - - /* - * Go back over this line - * and move everything down - * a little. - */ - eptr = Current; - line = eptr->line_number; - while ((eptr->prev != NULL)&& - (eptr->prev->line_number == line)) - { - eptr = eptr->prev; - eptr->y_offset = eptr->y_offset + incy; - } - - if ((LineHeight - baseline) > LineBottom) - { - LineBottom = LineHeight - baseline; - } - } -} - - -/* - * Place the bullet at the beginning of an unnumbered - * list item. Create and add the element record for it. - */ -void -BulletPlace(hw, x, y) - HTMLWidget hw; - int *x, *y; -{ - int width, l_height; - - /* - * Save the font's line height, and set your own for this - * element. Restore the fonts height when done. - * Deal with bad Lucidia descents. - */ - l_height = LineHeight; - if (hw->html.font->descent > hw->html.font->max_bounds.descent) - { - LineHeight = hw->html.font->max_bounds.ascent + - hw->html.font->descent; - } - else - { - LineHeight = hw->html.font->max_bounds.ascent + - hw->html.font->max_bounds.descent; - } - - NeedSpace = 0; - width = hw->html.font->max_bounds.width; - SetElement(hw, E_BULLET, hw->html.font, *x, *y, (char *)NULL); - LineHeight = l_height; -/* - * This should reall be here, but it is a hack for headers on list - * elements to work if we leave it out - PF_LF_State = 0; - */ -} - - -/* - * Place a horizontal rule across the page. - * Create and add the element record for it. - */ -void -HRulePlace(hw, x, y, width) - HTMLWidget hw; - int *x, *y; - unsigned int width; -{ - NeedSpace = 0; - *x = hw->html.margin_width; - SetElement(hw, E_HRULE, currentFont, *x, *y, (char *)NULL); - *x = *x + width - (2 * hw->html.margin_width); - NeedSpace = 1; - PF_LF_State = 0; -} - - -/* - * Place the number at the beginning of an numbered - * list item. Create and add the element record for it. - */ -void -ListNumberPlace(hw, x, y, val) - HTMLWidget hw; - int *x, *y; - int val; -{ - int width, my_x; - int dir, ascent, descent; - XCharStruct all; - char buf[20]; - - sprintf(buf, "%d.", val); - - width = hw->html.font->max_bounds.lbearing + - hw->html.font->max_bounds.rbearing; - XTextExtents(currentFont, buf, strlen(buf), &dir, - &ascent, &descent, &all); - my_x = *x - (width / 2) - all.width; - /* - * Add a space after thenumber here so it will look right when - * cut and pasted from a selection. - */ - width = strlen(buf); - buf[width] = ' '; - buf[width + 1] = '\0'; - - SetElement(hw, E_TEXT, currentFont, my_x, *y, buf); - AdjustBaseLine(); - CharsInLine = CharsInLine + strlen(buf); - - NeedSpace = 0; -/* - * This should reall be here, but it is a hack for headers on list - * elements to work if we leave it out - PF_LF_State = 0; - */ -} - - -/* - * Place a piece of pre-formatted text. Add an element record for it. - */ -void -PreformatPlace(hw, mptr, x, y, width) - HTMLWidget hw; - struct mark_up *mptr; - int *x, *y; - unsigned int width; -{ - char *text; - char *start; - char *end; - char *ptr; - char tchar; - int tab_count, char_cnt; - int dir, ascent, descent; - XCharStruct all; - char *line; - int line_x; - - text = mptr->text; - - line_x = *x; - line = CompLine; - if (line != NULL) - { - line[0] = '\0'; - } - end = text; - while (*end != '\0') - { - tab_count = 0; - char_cnt = CharsInLine; - /* - * make start and end point to one word. A word is either - * a lone linefeed, or all whitespace before a word, plus - * the text of the word itself. - */ - start = end; - /* - * Throw out carriage returns and form-feeds - */ - if ((*end == '\r')||(*end == '\f')) - { - start++; - end++; - } - else if (*end == '\n') - { - end++; - char_cnt++; - } - else - { - /* - * Should be only spaces and tabs here, so if it - * is not a tab, make it a space. - * Break on linefeeds, they must be done separately - */ - while (((int)((unsigned char)*end) < 128)&& - (isspace(*end))) - { - if (*end == '\n') - { - break; - } - else if (*end == '\t') - { - tab_count++; - char_cnt = ((char_cnt / 8) + 1) * 8; - } - else - { - *end = ' '; - char_cnt++; - } - end++; - } - while (((int)((unsigned char)*end) > 127)|| - ((!isspace(*end))&&(*end != '\0'))) - { - end++; - char_cnt++; - } - } - - /* - * Add the word to the end of this line, or insert - * a linefeed if the word is a lone linefeed. - * tabs expand to 8 spaces. - */ - if (start != end) - { - int tlen; - - tchar = *end; - *end = '\0'; - - tlen = char_cnt + 1; - if (tlen > CompWordLen) - { - CompWordLen += COMP_LINE_BUF_LEN; - if (tlen > CompWordLen) - { - CompWordLen = tlen; - } - if (CompWord != NULL) - { - free(CompWord); - } - CompWord = (char *)malloc(CompWordLen); - } - ptr = CompWord; - - /* - * If we have any tabs, expand them into spaces. - */ - if (tab_count) - { - char *p1, *p2; - int i, new; - - char_cnt = CharsInLine; - p1 = ptr; - p2 = start; - while (*p2 != '\0') - { - if (*p2 == '\t') - { - new = ((char_cnt / 8) + 1) * 8; - for (i=0; i<(new-char_cnt); i++) - { - *p1++ = ' '; - } - p2++; - char_cnt = new; - } - else - { - *p1++ = *p2++; - char_cnt++; - } - } - *p1 = '\0'; - } - else - { - strcpy(ptr, start); - } - -#ifdef ASSUME_FIXED_WIDTH_PRE - all.width = currentFont->max_bounds.width * strlen(ptr); -#else - XTextExtents(currentFont, ptr, strlen(ptr), &dir, - &ascent, &descent, &all); -#endif /* ASSUME_FIXED_WIDTH_PRE */ - - if (*start == '\n') - { - if ((line != NULL)&&(line[0] != '\0')) - { - SetElement(hw, E_TEXT, currentFont, - line_x, *y, line); - /* - * Save width here to avoid an - * XTextExtents call later. - */ - Current->width = *x - line_x + 1; - - AdjustBaseLine(); - PF_LF_State = 0; - - line[0] = '\0'; - } - - HardLineFeed(hw, x, y); - line_x = *x; - NeedSpace = 0; - } - else - { - char *tptr; - int tlen; - - if (line == NULL) - { - tlen = strlen(ptr) + 1; - } - else - { - tlen = strlen(line) + - strlen(ptr) + 1; - } - if (tlen > CompLineLen) - { - CompLineLen += COMP_LINE_BUF_LEN; - if (tlen > CompLineLen) - { - CompLineLen = tlen; - } - tptr = (char *)malloc(CompLineLen); - if (CompLine != NULL) - { - strcpy(tptr, CompLine); - free(CompLine); - } - else - { - tptr[0] = '\0'; - } - CompLine = tptr; - } - line = CompLine; - - strcat(line, ptr); - - *x = *x + all.width; - CharsInLine = CharsInLine + strlen(ptr); - NeedSpace = 1; - } - *end = tchar; - } - } - if ((line != NULL)&&(line[0] != '\0')) - { - SetElement(hw, E_TEXT, currentFont, - line_x, *y, line); - /* - * Save width here to avoid an - * XTextExtents call later. - */ - Current->width = *x - line_x + 1; - - AdjustBaseLine(); - PF_LF_State = 0; - line[0] = '\0'; - } -} - - -/* - * Format and place a piece of text. Add an element record for it. - */ -void -FormatPlace(hw, mptr, x, y, width) - HTMLWidget hw; - struct mark_up *mptr; - int *x, *y; - unsigned int width; -{ - char *text; - char *start; - char *end; - char *ptr; - char tchar; -#ifdef DOUBLE_SPACE_AFTER_PUNCT - char tchar2; -#endif /* DOUBLE_SPACE_AFTER_PUNCT */ - int stripped_space; - int added_space; - int double_space; - int dir, ascent, descent; - XCharStruct all; - char *line; - int line_x; - - text = mptr->text; - - line_x = *x; - line = CompLine; - if (line != NULL) - { - line[0] = '\0'; - } - end = text; - while (*end != '\0') - { - /* - * make start and end point to one word. - * set flag if we removed any leading white space. - * set flag if we add any leading white space. - */ - stripped_space = 0; - added_space = 0; - start = end; - while (((int)((unsigned char)*start) < 128)&&(isspace(*start))) - { - stripped_space = 1; - start++; - } - - end = start; - while (((int)((unsigned char)*end) > 127)|| - ((!isspace(*end))&&(*end != '\0'))) - { - end++; - } - - /* - * Add the word to the end of this line, or insert - * a linefeed an put the word at the start of the next line. - */ - if (start != end) - { - int nobreak; - int tlen; - - /* - * nobreak is a horrible hack that specifies special - * conditions where line breaks are just not allowed - */ - nobreak = 0; - - tchar = *end; - *end = '\0'; - - /* - * Malloc temp space if needed, leave room for - * 2 spaces and a end of string char - */ - tlen = strlen(start) + 3; - if (tlen > CompWordLen) - { - CompWordLen += COMP_LINE_BUF_LEN; - if (tlen > CompWordLen) - { - CompWordLen = tlen; - } - if (CompWord != NULL) - { - free(CompWord); - } - CompWord = (char *)malloc(CompWordLen); - } - ptr = CompWord; - - if ((NeedSpace > 0)&&(stripped_space)) - { - if (NeedSpace == 2) - { - strcpy(ptr, " "); - added_space = 2; - } - else - { - strcpy(ptr, " "); - added_space = 1; - } - } - else - { - strcpy(ptr, ""); - } - strcat(ptr, start); - -#ifdef DOUBLE_SPACE_AFTER_PUNCT - /* - * If this text ends in '.', '!', or '?' we need - * to set up the addition of two spaces after it. - */ - tchar2 = ptr[strlen(ptr) - 1]; - if ((tchar2 == '.')||(tchar2 == '!')||(tchar2 == '?')) - { - double_space = 1; - } - else - { - double_space = 0; - } -#else - double_space = 0; -#endif /* DOUBLE_SPACE_AFTER_PUNCT */ - - XTextExtents(currentFont, ptr, strlen(ptr), &dir, - &ascent, &descent, &all); - - /* - * Horrible hack for punctuation following - * font changes to not go on the next line. - */ - if ((MY_ISPUNCT(*ptr))&&(added_space == 0)) - { - char *tptr; - - /* - * Take into account whole streams of - * punctuation. - */ - nobreak = 1; - tptr = ptr; - while ((*tptr != '\0')&&(MY_ISPUNCT(*tptr))) - { - tptr++; - } - if (*tptr != '\0') - { - nobreak = 0; - } - } - - /* - * No linebreaks if this whole line is just too - * long. - */ - if (*x == TextIndent) - { - nobreak = 1; - } - - if (((*x + all.width + MarginW) <= width)||(nobreak)) - { - char *tptr; - int tlen; - - if (line == NULL) - { - tlen = strlen(ptr) + 1; - } - else - { - tlen = strlen(line) + - strlen(ptr) + 1; - } - if (tlen > CompLineLen) - { - CompLineLen += COMP_LINE_BUF_LEN; - if (tlen > CompLineLen) - { - CompLineLen = tlen; - } - tptr = (char *)malloc(CompLineLen); - if (CompLine != NULL) - { - strcpy(tptr, CompLine); - free(CompLine); - } - else - { - tptr[0] = '\0'; - } - CompLine = tptr; - } - line = CompLine; - - strcat(line, ptr); - } - else - { - char *tptr, *tptr2; - int tlen; - - if ((line != NULL)&&(line[0] != '\0')) - { - SetElement(hw, E_TEXT, currentFont, - line_x, *y, line); - /* - * Save width here to avoid an - * XTextExtents call later. - */ - Current->width = *x - line_x + 1; - - AdjustBaseLine(); - PF_LF_State = 0; - - line[0] = '\0'; - } - - LineFeed(hw, x, y); - line_x = *x; - - /* - * If we added a space before, remove it now - * since we are at the beginning of a new line - */ - if (added_space) - { - tptr2 = (char *)(ptr + added_space); - } - else - { - tptr2 = ptr; - } - XTextExtents(currentFont, tptr2, - strlen(tptr2), &dir, - &ascent, &descent, &all); - - if (line == NULL) - { - tlen = strlen(tptr2) + 1; - } - else - { - tlen = strlen(line) + - strlen(tptr2) + 1; - } - if (tlen > CompLineLen) - { - CompLineLen += COMP_LINE_BUF_LEN; - if (tlen > CompLineLen) - { - CompLineLen = tlen; - } - tptr = (char *)malloc(CompLineLen); - if (CompLine != NULL) - { - strcpy(tptr, CompLine); - free(CompLine); - } - else - { - tptr[0] = '\0'; - } - CompLine = tptr; - } - line = CompLine; - - strcat(line, tptr2); - } - - /* - * Set NeedSpace for one or 2 spaces based on - * whether we are after a '.', '!', or '?' - * or not. - */ - if (double_space) - { - NeedSpace = 2; - } - else - { - NeedSpace = 1; - } - - *x = *x + all.width; - *end = tchar; - } - /* - * Else if there is trailing whitespace, add it now - */ - else if ((NeedSpace > 0)&&(stripped_space)) - { - char *tptr; - char *spc; - int tlen; - - if (NeedSpace == 2) - { - spc = (char *)malloc(strlen(" ") + 1); - strcpy(spc, " "); - } - else - { - spc = (char *)malloc(strlen(" ") + 1); - strcpy(spc, " "); - } - - XTextExtents(currentFont, spc, strlen(spc), &dir, - &ascent, &descent, &all); - - /* - * Sigh, adding this one little space might force a - * line break. - */ - if ((*x + all.width + MarginW) <= width) - { - if (line == NULL) - { - tlen = strlen(spc) + 1; - } - else - { - tlen = strlen(line) + - strlen(spc) + 1; - } - if (tlen > CompLineLen) - { - CompLineLen += COMP_LINE_BUF_LEN; - if (tlen > CompLineLen) - { - CompLineLen = tlen; - } - tptr = (char *)malloc(CompLineLen); - if (CompLine != NULL) - { - strcpy(tptr, CompLine); - free(CompLine); - } - else - { - tptr[0] = '\0'; - } - CompLine = tptr; - } - line = CompLine; - - strcat(line, spc); - } - /* - * Ok, the space forced a linefeed, but now we must - * also drop the space since we don't want it if we - * have a linefeed here. - */ - else - { - if ((line != NULL)&&(line[0] != '\0')) - { - SetElement(hw, E_TEXT, currentFont, - line_x, *y, line); - /* - * Save width here to avoid an - * XTextExtents call later. - */ - Current->width = *x - line_x + 1; - - AdjustBaseLine(); - PF_LF_State = 0; - - line[0] = '\0'; - } - - LineFeed(hw, x, y); - line_x = *x; - - all.width = 0; - } - - *x = *x + all.width; - if (spc) - free(spc); - NeedSpace = 0; - } - } - if ((line != NULL)&&(line[0] != '\0')) - { - SetElement(hw, E_TEXT, currentFont, - line_x, *y, line); - /* - * Save width here to avoid an - * XTextExtents call later. - */ - Current->width = *x - line_x + 1; - - AdjustBaseLine(); - PF_LF_State = 0; - line[0] = '\0'; - } -} - -TablePlace(hw,mptr,x,y,width) -HTMLWidget hw; -struct mark_up **mptr; -int *x, *y; -unsigned int width; -{ -int extra; - -#ifdef DEBUG - printf("TablePlace(hw,mptr,*x=%d,*y=%d,width = %d)\n", *x,*y,width); -#endif - - if ((*mptr)->is_end) { - /* end of table */ - return; - } - - extra = 10; - - LineFeed(hw, x, y); - SetElement(hw, E_TABLE, currentFont, *x, *y, mptr); - if (!Current->table_data) { - /* no table */ - return; - } - Current->alignment = ALIGN_MIDDLE; - Current->width = Current->table_data->width; - Current->y_offset = Current->table_data->height-extra; - Current->line_height = Current->table_data->height + extra; - BaseLine = Current->table_data->height; - - *x += Current->width + 1; - LineFeed(hw, x, y); -} - -/* - * Place an image. Add an element record for it. - */ -void -ImagePlace(hw, mptr, x, y, width) - HTMLWidget hw; - struct mark_up *mptr; - int *x, *y; - unsigned int width; -{ - char *tptr; - -#ifdef SPACE_HACK - /* - * If we are starting an image in formatted - * text, and it needs a preceeding space, add - * that space now. - */ - if ((!Preformat)&&(NeedSpace > 0)) - { - int dir, ascent, descent; - XCharStruct all; - - if (NeedSpace == 2) - { - tptr = (char *)malloc(strlen(" ") + 1); - strcpy(tptr, " "); - } - else - { - tptr = (char *)malloc(strlen(" ") + 1); - strcpy(tptr, " "); - } - - XTextExtents(currentFont, tptr, - strlen(tptr), &dir, &ascent, - &descent, &all); - SetElement(hw, E_TEXT, currentFont, - *x, *y, tptr); - /* - * Save width here to avoid an - * XTextExtents call later. - */ - Current->width = all.width; - - AdjustBaseLine(); - *x = *x + all.width; - CharsInLine = CharsInLine + strlen(tptr); - if (tptr) - free(tptr); - PF_LF_State = 0; - NeedSpace = 0; - } -#endif /* SPACE_HACK */ - - tptr = ParseMarkTag(mptr->start, MT_IMAGE, "SRC"); - /**temp******/ - if (!tptr) { - tptr = ParseMarkTag(mptr->start, MT_FIGURE, "SRC"); - } - /***********/ - SetElement(hw, E_IMAGE, currentFont, *x, *y, tptr); - - /* - * Only after we have placed the image do we know its dimensions. - * So now look and see if the image is too wide, and if so go - * back and insert a linebreak. - */ - if ((Current->pic_data != NULL)&&(!Preformat)) - { - int extra; - - if ((hw->html.border_images == True)|| - ((Current->anchorHRef != NULL)&& - (!Current->pic_data->internal))) - { - extra = 2 * IMAGE_BORDER; - } - else - { - extra = 0; - } - - if (((*x + Current->pic_data->width + extra + MarginW) >width)&& - (Current->prev != NULL)&& - (Current->prev->line_number == LineNumber)) - { - Current = Current->prev; - LineFeed(hw, x, y); - SetElement(hw, E_IMAGE, currentFont, *x, *y, tptr); - } - } - /* - * Clean up parsed SRC string - */ - if (tptr != NULL) - { - free(tptr); - } - - /* - * Yank out the name field, and stick it in text. - * We may use this for ALT to at some later date. - */ - if (Current->pic_data != NULL) - { - tptr = ParseMarkTag(mptr->start, MT_IMAGE, "NAME"); - /*temp******/ - if (!tptr) { - tptr = ParseMarkTag(mptr->start, MT_FIGURE, "NAME"); - } - /*temp******/ - Current->pic_data->text = tptr; - } - - /* - * Check if this image has the ISMAP attribute, so we know the - * x,y coordinates of the image click are important. - * Due to a special case (see below), this code can acutally - * change the size, or anchor status of the image, thus we MUST - * doit before we muck with the Baseline and stuff. - */ - if (Current->pic_data != NULL) - { - Current->pic_data->fptr = NULL; - tptr = ParseMarkTag(mptr->start, MT_IMAGE, "ISMAP"); - if (tptr != NULL) - { - free(tptr); - Current->pic_data->ismap = 1; - /* - * SUPER SPECIAL CASE! (Thanks Marc) - * If you have an ISMAP image inside a form, - * And that form doesn't already have an HREF - * by being inside an anchor, - * (Being a DelayedHRef is considered no href) - * clicking in that image will submit the form, - * adding the x,y coordinates of the click as part - * of the list of name/value pairs. - */ - if ((CurrentForm != NULL)&& - ((Current->anchorHRef == NULL)|| - (IsDelayedHRef(hw, Current->anchorHRef)))) - { - Current->pic_data->fptr = CurrentForm; - Current->anchorHRef = IsMapForm(hw); - Current->fg = hw->html.anchor_fg; - } - } - else - { - Current->pic_data->ismap = 0; - } - } - - /* - * Check if this image will be top aligned - */ - tptr = ParseMarkTag(mptr->start, MT_IMAGE, "ALIGN"); - /*temp******/ - if (!tptr) - { - tptr = ParseMarkTag(mptr->start, MT_FIGURE, "ALIGN"); - } - /*temp******/ - if (caseless_equal(tptr, "TOP")) - { - Current->alignment = ALIGN_TOP; - } - else if (caseless_equal(tptr, "MIDDLE")) - { - Current->alignment = ALIGN_MIDDLE; - } - else - { - Current->alignment = ALIGN_BOTTOM; - } - /* - * Clean up parsed ALIGN string - */ - if (tptr != NULL) - { - free(tptr); - } - - /* - * Advance x position, and check the max - * line height. We need to follow this - * image with a space. - */ - if (Current->pic_data != NULL) - { - int extra; - - if ((hw->html.border_images == True)|| - ((Current->anchorHRef != NULL)&& - (!Current->pic_data->internal))) - { - extra = 2 * IMAGE_BORDER; - } - else - { - extra = 0; - } - - if (BaseLine == -100) - { - BaseLine = 0; - } - - *x = *x + Current->pic_data->width + extra; - - if (Current->alignment == ALIGN_TOP) - { - Current->y_offset = 0; - - if ((Current->pic_data->height + extra - BaseLine) > - LineBottom) - { - LineBottom = Current->pic_data->height + extra - - BaseLine; - } - } - else if (Current->alignment == ALIGN_MIDDLE) - { - int baseline; - - baseline = (Current->pic_data->height + extra) / 2; - - if (baseline <= BaseLine) - { - Current->y_offset = BaseLine - baseline; - } - else - { - struct ele_rec *eptr; - int line, incy; - - Current->y_offset = 0; - - incy = baseline - BaseLine; - BaseLine = baseline; - - /* - * Go back over this line - * and move everything down - * a little. - */ - eptr = Current; - line = eptr->line_number; - while ((eptr->prev != NULL)&& - (eptr->prev->line_number == line)) - { - eptr = eptr->prev; - eptr->y_offset = eptr->y_offset + incy; - } - } - - if ((Current->pic_data->height + extra - BaseLine) > - LineBottom) - { - LineBottom = Current->pic_data->height + extra - - BaseLine; - } - } - else if ((Current->pic_data->height + extra) <= BaseLine) - { - Current->y_offset = BaseLine - - (Current->pic_data->height + extra); - } - else if ((Current->pic_data->height + extra) > BaseLine) - { - struct ele_rec *eptr; - int line, incy; - - incy = Current->pic_data->height + extra - BaseLine; - BaseLine = Current->pic_data->height + extra; - - /* - * Go back over this line - * and move everything down - * a little. - */ - eptr = Current; - line = eptr->line_number; - while ((eptr->prev != NULL)&& - (eptr->prev->line_number == line)) - { - eptr = eptr->prev; - eptr->y_offset = eptr->y_offset + incy; - } - } - - if (BaseLine == 0) - { - BaseLine = -100; - } - } - PF_LF_State = 0; - NeedSpace = 1; -} - - -/* - * Place a Widget. Add an element record for it. - */ -void -WidgetPlace(hw, mptr, x, y, width) - HTMLWidget hw; - struct mark_up *mptr; - int *x, *y; - unsigned int width; -{ - SetElement(hw, E_WIDGET, currentFont, *x, *y, mptr->start); - - /* - * Only after we have placed the widget do we know its dimensions. - * So now look and see if the widget is too wide, and if so go - * back and insert a linebreak. - */ - if ((Current->widget_data != NULL)&&(!Preformat)) - { - int extra; - - extra = 2 * IMAGE_BORDER; - - if (((*x + Current->widget_data->width + extra + MarginW) > - width)&& - (Current->prev != NULL)&& - (Current->prev->line_number == LineNumber)) - { - WidgetId--; - Current = Current->prev; - LineFeed(hw, x, y); - SetElement(hw, E_WIDGET, currentFont, *x, *y, - mptr->start); - } - } - - /* - * Advance x position, and check BaseLine and LineBottom. - * We need to follow this widget with a space. - */ - if (Current->widget_data != NULL) - { - int extra; - int baseline; - XFontStruct *fp; - - extra = 2 * IMAGE_BORDER; - - /* - * Find the font used in this widget. Then find its baseline - */ - fp = GetWidgetFont(hw, Current->widget_data); - if (fp == NULL) - { - baseline = Current->widget_data->height + extra; - } - /* - * If no font, the baseline is the bottum of the widget - */ - else - { - int border; - - border = ((Current->widget_data->height + extra) - - (fp->max_bounds.ascent + fp->max_bounds.descent)); - baseline = (border / 2) + fp->max_bounds.ascent; - } - - /* - * Baseline == -100 is the special unset baseline value. - */ - if (BaseLine == -100) - { - BaseLine = baseline; - Current->y_offset = 0; - /* - * If linebottom isn't set, set it to - * whatever of the height is below the baseline. - */ - if (LineBottom == 0) - { - LineBottom = Current->widget_data->height + - extra - baseline; - } - /* - * Else, it is possible that a linebottom has been - * set even when we have no baseline yet (like if - * the first item in the line was a top aligned image) - * It now needs to be corrected as we set a real - * BaseLine. - */ - else - { - if ((Current->widget_data->height + - extra - baseline) > - (LineBottom - baseline)) - { - LineBottom = - Current->widget_data->height + - extra - baseline; - } - else - { - LineBottom = LineBottom - baseline; - } - } - } - /* - * Else we already have a baseline, and it is greater that - * the baseline for this widget. - * Set y_offset, and check linebottom. - */ - else if (baseline <= BaseLine) - { - if (baseline < BaseLine) - { - Current->y_offset = BaseLine - baseline; - } - else - { - Current->y_offset = 0; - } - - /* - * Our line bottom may be greater than the - * old one. - */ - if ((Current->widget_data->height + extra - baseline) > - LineBottom) - { - LineBottom = Current->widget_data->height + - extra - baseline; - } - } - else - /* - * Else we have a new baseline greater than the old baseline. - */ - { - struct ele_rec *eptr; - int line, incy; - - /* - * Figure out how much to move all the old stuff - */ - incy = baseline - BaseLine; - BaseLine = baseline; - - /* - * Go back over this line - * and move everything down - * a little. - */ - eptr = Current; - line = eptr->line_number; - while ((eptr->prev != NULL)&& - (eptr->prev->line_number == line)) - { - eptr = eptr->prev; - eptr->y_offset = eptr->y_offset + incy; - } - - /* - * Our line bottom may be greater than the - * old one. - */ - if ((Current->widget_data->height + extra - baseline) > - LineBottom) - { - LineBottom = Current->widget_data->height + - extra - baseline; - } - } - - /* - * Advance the X position. - */ - *x = *x + Current->widget_data->width + extra; - } - PF_LF_State = 0; - NeedSpace = 1; -} - - -static void -PushFont(font) - XFontStruct *font; -{ - FontRec *fptr; - - fptr = (FontRec *)malloc(sizeof(FontRec)); - if (fptr == NULL) - { - fprintf(stderr, "No memory to expand font stack!\n"); - return; - } - - fptr->font = font; - fptr->next = FontStack; - FontStack = fptr; -} - - -static XFontStruct * -PopFont() -{ - XFontStruct *font; - FontRec *fptr; - - if (FontStack->next != NULL) - { - fptr = FontStack; - FontStack = FontStack->next; - font = fptr->font; - free((char *)fptr); - } - else - { -#ifdef VERBOSE - fprintf(stderr, "Warning, popping empty font stack!\n"); -#endif - font = FontStack->font; - } - - return(font); -} - - -/* - * We've just terminated the current OPTION. - * Put it in the proper place in the SelectInfo structure. - * Move option_buf into options, and maybe copy into - * value if is_value is set. - */ -static void -ProcessOption(sptr) - SelectInfo *sptr; -{ - int i, cnt; - char **tarray; - - clean_white_space(sptr->option_buf); - tarray = sptr->options; - cnt = sptr->option_cnt + 1; - sptr->options = (char **)malloc(sizeof(char *) * cnt); - for (i=0; i<(cnt - 1); i++) - { - sptr->options[i] = tarray[i]; - } - if (tarray != NULL) - { - free((char *)tarray); - } - sptr->options[cnt - 1] = sptr->option_buf; - sptr->option_cnt = cnt; - - tarray = sptr->returns; - cnt = sptr->option_cnt; - sptr->returns = (char **)malloc(sizeof(char *) * cnt); - for (i=0; i<(cnt - 1); i++) - { - sptr->returns[i] = tarray[i]; - } - if (tarray != NULL) - { - free((char *)tarray); - } - sptr->returns[cnt - 1] = sptr->retval_buf; - - if (sptr->is_value) - { - tarray = sptr->value; - cnt = sptr->value_cnt + 1; - sptr->value = (char **)malloc(sizeof(char *) * cnt); - for (i=0; i<(cnt - 1); i++) - { - sptr->value[i] = tarray[i]; - } - if (tarray != NULL) - { - free((char *)tarray); - } - sptr->value[cnt - 1] = (char *)malloc( - strlen(sptr->option_buf) + 1); - strcpy(sptr->value[cnt - 1], sptr->option_buf); - sptr->value_cnt = cnt; - } -} - - -/* - * Horrible code for the TEXTAREA element. Escape '\' and ''' by - * putting a '\' in front of them, then replace all '"' with '''. - * This lets us safely put the resultant value between double quotes. - */ -char * -TextAreaAddValue(value, text) - char *value; - char *text; -{ - int extra; - char *buf; - char *bptr; - char *tptr; - - if ((text == NULL)||(text[0] == '\0')) - { - return(value); - } - - extra = 0; - tptr = text; - while (*tptr != '\0') - { - if (*tptr == '\\') - { - extra++; - } - else if (*tptr == '\'') - { - extra++; - } - tptr++; - } - - buf = (char *)malloc(strlen(value) + strlen(text) + extra + 1); - if (buf == NULL) - { - return(value); - } - strcpy(buf, value); - - tptr = text; - bptr = (char *)(buf + strlen(value)); - while (*tptr != '\0') - { - if ((*tptr == '\\')||(*tptr == '\'')) - { - *bptr++ = '\\'; - *bptr++ = *tptr++; - } - else if (*tptr == '\"') - { - *bptr++ = '\''; - tptr++; - } - else - { - *bptr++ = *tptr++; - } - } - *bptr = '\0'; - - free(value); - return(buf); -} - - -/* - * Make necessary changes to formatting, based on the type of the - * parsed HTML text we are formatting. - * Some calls create elements that are added to the formatted element list. - */ -static -void -TriggerMarkChanges(hw, mptr, x, y) - HTMLWidget hw; - struct mark_up **mptr; - int *x, *y; -{ - struct mark_up *mark; - XFontStruct *font; - int type, width; - - mark = *mptr; - type = mark->type; - font = NULL; - - /* If we are not in a tag that belongs in the HEAD, end the HEAD - section - amb */ - if (InDocHead) - if ((type != M_TITLE)&&(type != M_NONE)&&(type != M_BASE)&& - (type != M_INDEX)&&(type != M_COMMENT)) - { - Ignore = 0; - InDocHead = 0; - } - - /* - * If Ignore is set, we ignore all further elements until we get to the - * end of the Ignore - * Let text through so we can grab the title text. - * Let title through so we can hit the end title. - * Now also used for SELECT parseing - * Let SELECT through so we can hit the end SELECT. - * Let OPTION through so we can hit the OPTIONs. - * Let TEXTAREA through so we can hit the TEXTAREAs. - */ - if ((Ignore)&&(!InDocHead)&&(type != M_TITLE)&&(type != M_NONE)&& - (type != M_SELECT)&&(type != M_OPTION)&& - (type != M_TEXTAREA)&&(type != M_DOC_HEAD)) - { - return; - } - - switch(type) - { - /* - * Place the text. Different functions based on whether it - * is pre-formatted or not. - */ - case M_NONE: - if ((Ignore)&&(CurrentSelect == NULL)&& - (TextAreaBuf == NULL)) - { - if (TitleText == NULL) - { - TitleText = (char *) - malloc(strlen((*mptr)->text) + 1); - strcpy(TitleText, (*mptr)->text); - } - else - { - char *tptr; - - tptr = (char *) - malloc(strlen(TitleText) + - strlen((*mptr)->text) + 1); - strcpy(tptr, TitleText); - strcat(tptr, (*mptr)->text); - free(TitleText); - TitleText = tptr; - } - } - else if ((Ignore)&&(CurrentSelect != NULL)) - { - if (CurrentSelect->option_buf != NULL) - { - char *tptr; - - tptr = (char *)malloc(strlen( - CurrentSelect->option_buf) + - strlen((*mptr)->text) + 1); - strcpy(tptr, CurrentSelect->option_buf); - strcat(tptr, (*mptr)->text); - free(CurrentSelect->option_buf); - CurrentSelect->option_buf = tptr; - } - } - else if ((Ignore)&&(TextAreaBuf != NULL)) - { - TextAreaBuf = TextAreaAddValue(TextAreaBuf, - (*mptr)->text); - } - else if (Preformat) - { - PreformatPlace(hw, *mptr, x, y, Width); - } - else - { - FormatPlace(hw, *mptr, x, y, Width); - } - break; - /* - * Titles are just set into the widget for retrieval by - * XtGetValues(). - */ - case M_TITLE: - if (mark->is_end) - { - if (!InDocHead) - Ignore = 0; - hw->html.title = TitleText; - TitleText = NULL; - } - else - { - Ignore = 1; - TitleText = NULL; - } - break; - /* - * Formatting commands just change the current font. - */ - case M_CODE: - case M_SAMPLE: - case M_KEYBOARD: - case M_FIXED: - if (mark->is_end) - { - font = PopFont(); - } - else - { - PushFont(currentFont); - font = hw->html.fixed_font; - } - break; - case M_STRONG: - case M_BOLD: - if (mark->is_end) - { - font = PopFont(); - } - else - { - PushFont(currentFont); - if (currentFont == hw->html.fixed_font || - currentFont == hw->html.fixeditalic_font) - font = hw->html.fixedbold_font; - else if (currentFont == hw->html.plain_font || - currentFont == hw->html.plainitalic_font) - font = hw->html.plainbold_font; - else - font = hw->html.bold_font; - } - break; - case M_EMPHASIZED: - case M_VARIABLE: - case M_CITATION: - case M_ITALIC: - if (mark->is_end) - { - font = PopFont(); - } - else - { - PushFont(currentFont); - if (currentFont == hw->html.fixed_font || - currentFont == hw->html.fixedbold_font) - font = hw->html.fixeditalic_font; - else if (currentFont == hw->html.plain_font || - currentFont == hw->html.plainbold_font) - font = hw->html.plainitalic_font; - else - font = hw->html.italic_font; - } - break; - /* - * Strikeout means draw a line through the text. - * Right now we just set a boolean flag which gets shoved - * in the element record for all elements in the - * strikeout zone. - */ - case M_STRIKEOUT: - if (mark->is_end) - { - Strikeout = False; - } - else - { - Strikeout = True; - } - break; - case M_SUP: - if (mark->is_end) - { - Superscript--; - if ((Superscript==0) && (Subscript==0)) - font = PopFont(); - } - else - { - Superscript++; - if ((Superscript==1) && (Subscript==0)) - { - nonScriptFont=currentFont; - PushFont(currentFont); - font = hw->html.supsub_font; - } - } - break; - case M_SUB: - if (mark->is_end) - { - Subscript--; - if ((Subscript==0) && (Superscript==0)) - font = PopFont(); - } - else - { - Subscript++; - if ((Subscript==1) && (Superscript==0)) - { - nonScriptFont=currentFont; - PushFont(currentFont); - font = hw->html.supsub_font; - } - } - break; -/* amb - ignore text inside a HEAD element */ - case M_DOC_HEAD: - if (mark->is_end) - { - InDocHead = 0; - Ignore = 0; - } - else - { - InDocHead = 1; - Ignore = 1; - } - break; - case M_DOC_BODY: - if (mark->is_end) - { - /* do nothing */ - } - else - { - InDocHead = 0; /* end section */ - Ignore = 0; - } - break; - case M_UNDERLINED: - if (mark->is_end) - { - Underlines = 0; - InUnderlined = 0; - } - else - { - Underlines = 1; - InUnderlined = 1; - } - break; - /* - * Headers are preceeded and followed by a linefeed, - * and the change the font. - */ - case M_HEADER_1: - ConditionalLineFeed(hw, x, y, 1); - if (mark->is_end) - { - font = PopFont(); - NewFont(font); - currentFont = font; - ConditionalLineFeed(hw, x, y, 2); - } - else - { - ConditionalLineFeed(hw, x, y, 2); - PushFont(currentFont); - font = hw->html.header1_font; - } - break; - case M_HEADER_2: - ConditionalLineFeed(hw, x, y, 1); - if (mark->is_end) - { - font = PopFont(); - NewFont(font); - currentFont = font; - ConditionalLineFeed(hw, x, y, 2); - } - else - { - ConditionalLineFeed(hw, x, y, 2); - PushFont(currentFont); - font = hw->html.header2_font; - } - break; - case M_HEADER_3: - ConditionalLineFeed(hw, x, y, 1); - if (mark->is_end) - { - font = PopFont(); - NewFont(font); - currentFont = font; - ConditionalLineFeed(hw, x, y, 2); - } - else - { - ConditionalLineFeed(hw, x, y, 2); - PushFont(currentFont); - font = hw->html.header3_font; - } - break; - case M_HEADER_4: - ConditionalLineFeed(hw, x, y, 1); - if (mark->is_end) - { - font = PopFont(); - NewFont(font); - currentFont = font; - ConditionalLineFeed(hw, x, y, 2); - } - else - { - ConditionalLineFeed(hw, x, y, 2); - PushFont(currentFont); - font = hw->html.header4_font; - } - break; - case M_HEADER_5: - ConditionalLineFeed(hw, x, y, 1); - if (mark->is_end) - { - font = PopFont(); - NewFont(font); - currentFont = font; - ConditionalLineFeed(hw, x, y, 2); - } - else - { - ConditionalLineFeed(hw, x, y, 2); - PushFont(currentFont); - font = hw->html.header5_font; - } - break; - case M_HEADER_6: - ConditionalLineFeed(hw, x, y, 1); - if (mark->is_end) - { - font = PopFont(); - NewFont(font); - currentFont = font; - ConditionalLineFeed(hw, x, y, 2); - } - else - { - ConditionalLineFeed(hw, x, y, 2); - PushFont(currentFont); - font = hw->html.header6_font; - } - break; - /* - * Anchors change the text color, and may set - * underlineing attributes. - * No linefeeds, so they can be imbedded anywhere. - */ - case M_ANCHOR: - if (mark->is_end) - { -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ -#ifdef MOTIF - Fg = hw->manager.foreground; -#else - Fg = hw->html.foreground; -#endif /* MOTIF */ - if (!InUnderlined) /* amb 2 */ - Underlines = 0; - else - Underlines = 1; - DashedUnderlines = False; - AnchorText = NULL; - } - else - { - char *tptr; - - /* - * Only change the color of anchors with - * HREF tags, because other anchors are - * not active. - */ - - tptr = ParseMarkTag(mark->start, - MT_ANCHOR, AT_HREF); - if (tptr != NULL) - { - /* - * If internal check our internal list - * to change color if visited before. - */ - if (Internal == True) - { - struct ref_rec *hptr; - - hptr = FindHRef( - hw->html.my_visited_hrefs, - tptr); - if (hptr != NULL) - { - Fg = hw->html.visitedAnchor_fg; - Underlines = hw->html.num_visitedAnchor_underlines; - DashedUnderlines = hw->html.dashed_visitedAnchor_lines; - } - else - { - Fg = hw->html.anchor_fg; - Underlines = hw->html.num_anchor_underlines; - DashedUnderlines = hw->html.dashed_anchor_lines; - } - } - /* - * Else we may want to send - * the href back somewhere else and - * find out if we've visited it before - */ - else if (hw->html.previously_visited_test != - NULL) - { - if ((*(visitTestProc) - (hw->html.previously_visited_test)) - (hw, tptr)) - { - Fg = hw->html.visitedAnchor_fg; - Underlines = hw->html.num_visitedAnchor_underlines; - DashedUnderlines = hw->html.dashed_visitedAnchor_lines; - } - else - { - Fg = hw->html.anchor_fg; - Underlines = hw->html.num_anchor_underlines; - DashedUnderlines = hw->html.dashed_anchor_lines; - } - } - else - { - Fg = hw->html.anchor_fg; - Underlines = hw->html.num_anchor_underlines; - DashedUnderlines = hw->html.dashed_anchor_lines; - } - if (tptr) - free(tptr); - } - AnchorText = mark->start; - /* amb 2 */ - if (InUnderlined) - { - DashedUnderlines = False; - if (!Underlines) - Underlines = 1; - } - } - break; - /* - * Just insert a linefeed, or ignore if this is prefomatted - * text because the

will be followed be a linefeed. - */ - case M_PARAGRAPH: - ConditionalLineFeed(hw, x, y, 1); - ConditionalLineFeed(hw, x, y, 2); - break; - /* - * Just insert the image for now - */ - case M_FIGURE: - case M_IMAGE: - ImagePlace(hw, *mptr, x, y, Width); - break; - /* - * Can only be inside a SELECT tag. - */ - case M_OPTION: - if (CurrentSelect != NULL) - { - char *tptr; - - if (CurrentSelect->option_buf != NULL) - { - ProcessOption(CurrentSelect); - } - CurrentSelect->option_buf = (char *)malloc(1); - strcpy(CurrentSelect->option_buf, ""); - - /* - * Check if this option starts selected - */ - tptr = ParseMarkTag(mark->start, - MT_OPTION, "SELECTED"); - if (tptr != NULL) - { - CurrentSelect->is_value = 1; - free(tptr); - } - else - { - CurrentSelect->is_value = 0; - } - - /* - * Check if this option has an different - * return value field. - */ - tptr = ParseMarkTag(mark->start, - MT_OPTION, "VALUE"); - if (tptr != NULL) - { - if (*tptr != '\0') - { - CurrentSelect->retval_buf = tptr; - } - else - { - CurrentSelect->retval_buf = NULL; - free(tptr); - } - } - else - { - CurrentSelect->retval_buf = NULL; - } - } - break; - /* - * Special INPUT tag. Allows an option menu or - * a scrolled list. - * Due to a restriction in SGML, this can't just be a - * subset of the INPUT markup. However, I can treat it - * that way to avoid duplicating code. - * As a result I combine SELECT and OPTION into a faked - * up INPUT mark. - */ - case M_SELECT: - if (CurrentForm != NULL) - { - if ((mark->is_end)&&(CurrentSelect != NULL)) - { - int len; - char *buf; - char *start; - char *options, *returns, *value; - - if (CurrentSelect->option_buf != NULL) - { - ProcessOption(CurrentSelect); - } - - options = ComposeCommaList( - CurrentSelect->options, - CurrentSelect->option_cnt); - returns = ComposeCommaList( - CurrentSelect->returns, - CurrentSelect->option_cnt); - value = ComposeCommaList( - CurrentSelect->value, - CurrentSelect->value_cnt); - FreeCommaList( - CurrentSelect->options, - CurrentSelect->option_cnt); - FreeCommaList( - CurrentSelect->returns, - CurrentSelect->option_cnt); - FreeCommaList( - CurrentSelect->value, - CurrentSelect->value_cnt); - - /* - * Construct a fake INPUT tag. - */ - len = strlen(MT_INPUT) + - strlen(options) + - strlen(returns) + - strlen(value) + strlen( - " type=select options=\"\" returns=\"\" value=\"\""); - buf = (char *)malloc(len + - strlen(CurrentSelect->mptr->start) - + 1); - strcpy(buf, MT_INPUT); - strcat(buf, " type=select"); - strcat(buf, " options=\""); - strcat(buf, options); - strcat(buf, "\" returns=\""); - strcat(buf, returns); - strcat(buf, "\" value=\""); - strcat(buf, value); - strcat(buf, "\""); - strcat(buf, (char *) - (CurrentSelect->mptr->start + - strlen(MT_SELECT))); - /* - * stick the fake in, saving the - * real one. - */ - start = CurrentSelect->mptr->start; - CurrentSelect->mptr->start = buf; - WidgetPlace(hw, CurrentSelect->mptr, - x, y, Width); - /* - * free the fake, put the original back - */ - free(buf); - free(options); - free(returns); - free(value); - CurrentSelect->mptr->start = start; - - free((char *)CurrentSelect); - CurrentSelect = NULL; - Ignore = 0; - } - else if ((!mark->is_end)&&(CurrentSelect == NULL)) - { - CurrentSelect = (SelectInfo *)malloc( - sizeof(SelectInfo)); - CurrentSelect->hw = (Widget)hw; - CurrentSelect->mptr = *mptr; - CurrentSelect->option_cnt = 0; - CurrentSelect->returns = NULL; - CurrentSelect->retval_buf = NULL; - CurrentSelect->options = NULL; - CurrentSelect->option_buf = NULL; - CurrentSelect->value_cnt = 0; - CurrentSelect->value = NULL; - CurrentSelect->is_value = -1; - Ignore = 1; - } - } - break; - /* - * TEXTAREA is a replacement for INPUT type=text size=rows,cols - * because SGML will not allow an arbitrary length value - * field. - */ - case M_TEXTAREA: - if (CurrentForm != NULL) - { - if ((mark->is_end)&&(TextAreaBuf != NULL)) - { - char *start; - char *buf; - - /* - * Finish a fake INPUT tag. - */ - buf = (char *)malloc( - strlen(TextAreaBuf) + 2); - strcpy(buf, TextAreaBuf); - strcat(buf, "\""); - - /* - * stick the fake in, saving the - * real one. - */ - start = mark->start; - mark->start = buf; - mark->is_end = 0; - WidgetPlace(hw, mark, x, y, Width); - - /* - * free the fake, put the original back - */ - free(buf); - free(TextAreaBuf); - mark->start = start; - mark->is_end = 1; - TextAreaBuf = NULL; - Ignore = 0; - } - else if ((!mark->is_end)&&(TextAreaBuf == NULL)) - { - char *buf; - int len; - - /* - * Construct the start of - * a fake INPUT tag. - */ - len = strlen(MT_INPUT) + - strlen( - " type=textarea value=\"\""); - buf = (char *)malloc(len + - strlen(mark->start) - + 1); - strcpy(buf, MT_INPUT); - strcat(buf, (char *) - (mark->start + - strlen(MT_TEXTAREA))); - strcat(buf, " type=textarea"); - strcat(buf, " value=\""); - - TextAreaBuf = buf; - Ignore = 1; - } - } - break; - /* - * Just insert the widget. - * Can only inside a FORM tag. - * Special case the type=image stuff to become a special - * IMG tag. - */ - case M_INPUT: - if (CurrentForm != NULL) - { - char *tptr; - char *tptr2; - - tptr = ParseMarkTag((*mptr)->start, - MT_INPUT, "TYPE"); - if ((tptr != NULL)&& - (strcmp(tptr, "image") == 0)) - { - free(tptr); - tptr = (char *)malloc( - strlen((*mptr)->start) + - strlen(" ISMAP") + - strlen(MT_IMAGE) - - strlen(MT_INPUT) + 1); - strcpy(tptr, MT_IMAGE); - strcat(tptr, (char *) - ((*mptr)->start + strlen(MT_INPUT)) - ); - strcat(tptr, " ISMAP"); - tptr2 = (*mptr)->start; - (*mptr)->start = tptr; - ImagePlace(hw, *mptr, x, y, Width); - (*mptr)->start = tptr2; - free(tptr); - } - /* - * hidden inputs have no element associated - * with them, just a widget record. - */ - else if ((tptr != NULL)&& - (strcmp(tptr, "hidden") == 0)) - { - free(tptr); - WidgetId++; - (void)MakeWidget(hw, (*mptr)->start, x, y, - WidgetId, CurrentForm); - } - else - { - if (tptr != NULL) - { - free(tptr); - } - WidgetPlace(hw, *mptr, x, y, Width); - } - } - break; - /* - * Fillout forms. Cannot be nested. - */ - case M_FORM: - ConditionalLineFeed(hw, x, y, 1); - if ((mark->is_end)&&(CurrentForm != NULL)) - { - CurrentForm->end = WidgetId; - ConditionalLineFeed(hw, x, y, 2); - AddNewForm(hw, CurrentForm); - CurrentForm = NULL; - } - else if ((!mark->is_end)&&(CurrentForm == NULL)) - { - ConditionalLineFeed(hw, x, y, 2); - CurrentForm = (FormInfo *)malloc( - sizeof(FormInfo)); - CurrentForm->next = NULL; - CurrentForm->hw = (Widget)hw; - CurrentForm->action = ParseMarkTag(mark->start, - MT_FORM, "ACTION"); - CurrentForm->method = ParseMarkTag(mark->start, - MT_FORM, "METHOD"); - CurrentForm->enctype = ParseMarkTag(mark->start, - MT_FORM, "ENCTYPE"); - CurrentForm->enc_entity = ParseMarkTag( - mark->start, MT_FORM, "ENCENTITY"); - CurrentForm->start = WidgetId; - CurrentForm->end = -1; - CurrentForm->button_pressed=0; - } - break; - /* - * Addresses are just like headers. A linefeed before and - * after, and change the font. - */ - case M_ADDRESS: - ConditionalLineFeed(hw, x, y, 1); - if (mark->is_end) - { - font = PopFont(); - } - else - { - PushFont(currentFont); - font = hw->html.address_font; - } - break; - /* - * Blockquotes increase the margin width. - * They cannot be nested. - */ - case M_BLOCKQUOTE: - ConditionalLineFeed(hw, x, y, 1); - if (mark->is_end) - { - MarginW = hw->html.margin_width; - /* - * Only unindent if we think we indented - * when we started the blockquote - */ - if (TextIndent <= (2 * MarginW)) - { - TextIndent = MarginW; - } - ConditionalLineFeed(hw, x, y, 2); - /* - * The linefeed should have set x to TextIndent - * but since it is conditional, it might not - * have, so check it here. - */ - if (*x > TextIndent) - { - *x = TextIndent; - } - } - else - { - MarginW = 2 * hw->html.margin_width; - /* - * Only indent if the current indent - * is less than what we want. - */ - if (TextIndent < MarginW) - { - TextIndent = MarginW; - } - ConditionalLineFeed(hw, x, y, 2); - /* - * The linefeed should have set x to TextIndent - * but since it is conditional, it might not - * have, so check it here. - */ - if (*x < TextIndent) - { - *x = TextIndent; - } - } - break; - /* - * Plain text. A single pre-formatted chunk of text - * in its own font. - */ - case M_PLAIN_TEXT: - if (mark->is_end) - { - Preformat = 0; - /* - * Properly convert the Linefeed state - * variable from preformat to formatted - * state. - */ - if (PF_LF_State == 2) - { - PF_LF_State = 1; - } - else - { - PF_LF_State = 0; - } - ConditionalLineFeed(hw, x, y, 1); - font = PopFont(); - NewFont(font); - currentFont = font; - ConditionalLineFeed(hw, x, y, 2); - } - else - { - ConditionalLineFeed(hw, x, y, 1); - ConditionalLineFeed(hw, x, y, 2); - Preformat = 1; - PF_LF_State = 0; - PushFont(currentFont); - font = hw->html.plain_font; - } - break; - /* - * Listing text. A different pre-formatted chunk of text - * in its own font. - */ - case M_LISTING_TEXT: - if (mark->is_end) - { - Preformat = 0; - /* - * Properly convert the Linefeed state - * variable from preformat to formatted - * state. - */ - if (PF_LF_State == 2) - { - PF_LF_State = 1; - } - else - { - PF_LF_State = 0; - } - ConditionalLineFeed(hw, x, y, 1); - font = PopFont(); - NewFont(font); - currentFont = font; - ConditionalLineFeed(hw, x, y, 2); - } - else - { - ConditionalLineFeed(hw, x, y, 1); - ConditionalLineFeed(hw, x, y, 2); - Preformat = 1; - PF_LF_State = 0; - PushFont(currentFont); - font = hw->html.listing_font; - } - break; - /* - * Plain text. The rest of the text is pre-formatted. - * There is not end for this mark. - */ - case M_PLAIN_FILE: - ConditionalLineFeed(hw, x, y, 1); - ConditionalLineFeed(hw, x, y, 2); - Preformat = 1; - PF_LF_State = 0; - PushFont(currentFont); - font = hw->html.plain_font; - break; - /* - * Numbered lists, Unnumbered lists, Menus. - * Currently also lump directory listings into this. - * Save state for each indent level. - * Change the value of the TxtIndent (can be nested) - * Linefeed at the end of the list. - */ - case M_NUM_LIST: - case M_UNUM_LIST: - case M_MENU: - case M_DIRECTORY: - ConditionalLineFeed(hw, x, y, 1); - width = hw->html.font->max_bounds.width; - /* - * If this is the outermost level of indentation, - * add another linefeed for more white space. - */ - if ((TextIndent <= MarginW)||((mark->is_end)&& - ((TextIndent - ((INDENT_SPACES + 1) * width)) <= - MarginW))) - { - ConditionalLineFeed(hw, x, y, 2); - } - if (mark->is_end) - { - TextIndent = TextIndent - - ((INDENT_SPACES + 1) * width); - if (TextIndent < MarginW) - { - TextIndent = MarginW; - } - IndentLevel--; - if (IndentLevel < 0) - { - IndentLevel = 0; - } - - /* - * restore the old state if there is one - */ - if (ListData->next != NULL) - { - DescRec *dptr; - - dptr = ListData; - ListData = ListData->next; - free((char *)dptr); - } - } - else - { - DescRec *dptr; - - dptr = (DescRec *)malloc(sizeof(DescRec)); - /* - * Save the old state, and start a new - */ - if (type == M_NUM_LIST) - { - dptr->type = D_OLIST; - dptr->count = 1; - } - else - { - dptr->type = D_ULIST; - dptr->count = 0; - } - dptr->next = ListData; - ListData = dptr; - - TextIndent = TextIndent + - ((INDENT_SPACES + 1) * width); - IndentLevel++; - } - *x = TextIndent; - break; - /* - * Place the bullet element at the beginning of this item. - */ - case M_LIST_ITEM: - if (!mark->is_end) - { - ConditionalLineFeed(hw, x, y, 1); - /* - * for ordered/numbered lists - * put numbers in place of bullets. - */ - if (ListData->type == D_OLIST) - { - ListNumberPlace(hw, x, y, - ListData->count); - ListData->count++; - } - else - { - BulletPlace(hw, x, y); - } - } - break; - /* - * Description lists - */ - case M_DESC_LIST: - ConditionalLineFeed(hw, x, y, 1); - ConditionalLineFeed(hw, x, y, 2); - width = hw->html.font->max_bounds.width; - if (mark->is_end) - { - if (DescType->type == D_TEXT) - { - TextIndent = TextIndent - - ((INDENT_SPACES + 1) * width); - if (TextIndent < MarginW) - { - TextIndent = MarginW; - } - } - /* - * restore the old state if there is one - */ - if (DescType->next != NULL) - { - DescRec *dptr; - - dptr = DescType; - DescType = DescType->next; - free((char *)dptr); - /* - * If the old state had forced an - * indent, outdent it now. - */ - if (DescType->type == D_TITLE) - { - TextIndent = TextIndent - - ((INDENT_SPACES + 1) * width); - if (TextIndent < MarginW) - { - TextIndent = MarginW; - } - } - } - } - else - { - DescRec *dptr; - char *tptr; - - dptr = (DescRec *)malloc(sizeof(DescRec)); - /* - * Check is this is a compact list - */ - tptr = ParseMarkTag(mark->start, - MT_DESC_LIST, "COMPACT"); - if (tptr != NULL) - { - free(tptr); - dptr->compact = 1; - } - else - { - dptr->compact = 0; - } - /* - * Description list stared after a title needs - * a forced indentation here - */ - if (DescType->type == D_TITLE) - { - TextIndent = TextIndent + - ((INDENT_SPACES + 1) * width); - } - /* - * Save the old state, and start a new - */ - dptr->type = D_TITLE; - dptr->next = DescType; - DescType = dptr; - } - *x = TextIndent; - break; - case M_DESC_TITLE: - ConditionalLineFeed(hw, x, y, 1); - width = hw->html.font->max_bounds.width; - /* - * Special hack. Don't indent again for - * multiple

's in a row. - */ - if (DescType->type == D_TEXT) - { - TextIndent = TextIndent - - ((INDENT_SPACES + 1) * width); - if (TextIndent < MarginW) - { - TextIndent = MarginW; - } - } - DescType->type = D_TITLE; - *x = TextIndent; - break; - case M_DESC_TEXT: - width = hw->html.font->max_bounds.width; - - /* - * For a compact list we want to stay on the same - * line if there is room and we are the first line - * after a title. - */ - if ((DescType->compact)&&(DescType->type == D_TITLE)&& - (*x < (TextIndent + (INDENT_SPACES * width)))) - { - NeedSpace = 0; - } - else - { - ConditionalLineFeed(hw, x, y, 1); - } - - /* - * Special hack. Don't indent again for - * multiple
's in a row. - */ - if (DescType->type == D_TITLE) - { - TextIndent = TextIndent + - ((INDENT_SPACES + 1) * width); - } - DescType->type = D_TEXT; - *x = TextIndent; - break; - case M_PREFORMAT: - if (mark->is_end) - { - Preformat = 0; - /* - * Properly convert the Linefeed state - * variable from preformat to formatted - * state. - */ - if (PF_LF_State == 2) - { - PF_LF_State = 1; - } - else - { - PF_LF_State = 0; - } - ConditionalLineFeed(hw, x, y, 1); - if (saveFont != NULL) - { - hw->html.font = saveFont; - saveFont = NULL; - } - font = PopFont(); - NewFont(font); - currentFont = font; - ConditionalLineFeed(hw, x, y, 2); - } - else - { - ConditionalLineFeed(hw, x, y, 1); - ConditionalLineFeed(hw, x, y, 2); - Preformat = 1; - PF_LF_State = 2; - if (saveFont == NULL) - { - saveFont = hw->html.font; - hw->html.font = hw->html.plain_font; - } - PushFont(currentFont); - font = hw->html.font; - } - break; - /* - * Now with forms, is the same as: - *
- *
- * This is a searchable index. Enter search keywords: - * - *
- *
- * Also, will take an ACTION tag to specify a - * different URL to submit the query to. - */ - case M_INDEX: - hw->html.is_index = True; - /* - * No index inside a form - */ - if (CurrentForm == NULL) - { - struct mark_up mark_tmp; - - /* - * Start the form - */ - ConditionalLineFeed(hw, x, y, 1); - ConditionalLineFeed(hw, x, y, 2); - CurrentForm = (FormInfo *)malloc( - sizeof(FormInfo)); - CurrentForm->next = NULL; - CurrentForm->hw = (Widget)hw; - CurrentForm->action = NULL; - CurrentForm->action = ParseMarkTag(mark->start, - MT_INDEX, "ACTION"); - CurrentForm->method = ParseMarkTag(mark->start, - MT_INDEX, "METHOD"); - CurrentForm->enctype = ParseMarkTag(mark->start, - MT_INDEX, "ENCTYPE"); - CurrentForm->enc_entity = ParseMarkTag( - mark->start, MT_INDEX, "ENCENTITY"); - CurrentForm->start = WidgetId; - CurrentForm->end = -1; - - /* - * Horizontal rule - */ - ConditionalLineFeed(hw, x, y, 1); - HRulePlace(hw, x, y, Width); - ConditionalLineFeed(hw, x, y, 1); - - /* - * Text: "This is a searchable index. - * Enter search keywords: " - */ - mark_tmp.text = (char *)malloc( - strlen("This is a searchable index. Enter search keywords: ") + 1); - strcpy(mark_tmp.text,"This is a searchable index. Enter search keywords: "); - FormatPlace(hw, &mark_tmp, x, y, Width); - - /* - * Fake up the text INPUT tag. - */ - mark_tmp.start = (char *)malloc( - strlen("input SIZE=25 NAME=\"isindex\"") + 1); - strcpy(mark_tmp.start,"input SIZE=25 NAME=\"isindex\""); - WidgetPlace(hw, &mark_tmp, x, y, Width); - -#ifdef ISINDEX_SUBMIT - /* - * Text: "; press this button to submit - * the query: " - */ - mark_tmp.text = (char *)malloc( - strlen(";\n press this button to submit the query: ") + 1); - strcpy(mark_tmp.text,";\n press this button to submit the query: "); - FormatPlace(hw, &mark_tmp, x, y, Width); - - /* - * Fake up the submit INPUT tag. - */ - mark_tmp.start = (char *)malloc( - strlen("input TYPE=\"submit\"") + 1); - strcpy(mark_tmp.start, "input TYPE=\"submit\""); - WidgetPlace(hw, &mark_tmp, x, y, Width); - - /* - * Text: "." - */ - mark_tmp.text = (char *)malloc( - strlen(".\n") + 1); - strcpy(mark_tmp.text, ".\n"); - FormatPlace(hw, &mark_tmp, x, y, Width); -#endif /* ISINDEX_SUBMIT */ - - /* - * Horizontal rule - */ - ConditionalLineFeed(hw, x, y, 1); - HRulePlace(hw, x, y, Width); - ConditionalLineFeed(hw, x, y, 1); - - /* - * Close the form - */ - ConditionalLineFeed(hw, x, y, 1); - CurrentForm->end = WidgetId; - ConditionalLineFeed(hw, x, y, 2); - AddNewForm(hw, CurrentForm); - CurrentForm = NULL; - } - break; - case M_HRULE: - ConditionalLineFeed(hw, x, y, 1); - HRulePlace(hw, x, y, Width); - ConditionalLineFeed(hw, x, y, 1); - break; - case M_LINEBREAK: - LineFeed(hw, x, y); - break; - case M_TABLE: - TablePlace(hw, mptr, x, y, Width); - break; - default: - break; - } - if ((font != NULL)&&(font != currentFont)) - { - NewFont(font); - currentFont = font; - } - -} /* TriggerMarkChanges() */ - - -/* - * Format all the objects in the passed Widget's - * parsed object list to fit the locally global Width. - * Passes in the x,y coords of where to start placing the - * formatted text. - * Returns the ending x,y in same variables. - * Title objects are ignored, and not formatted. - * - * The locally global variables are assumed to have been initialized - * before this function was called. - */ -void -FormatChunk(hw, x, y) - HTMLWidget hw; - int *x, *y; -{ - struct mark_up *mptr; - - /* - * Format all objects - */ - mptr = hw->html.html_objects; - Last = NULL; - while (mptr != NULL) - { - TriggerMarkChanges(hw, &mptr, x, y); - - /* - * Save last non-text mark - */ - /* DDT: why is this here? it's not used anywhere? */ - if (mptr->type != M_NONE) - { - Last = mptr; - } - /*****/ - - - if (mptr) { - mptr = mptr->next; - } - } -} - - -/* - * Called by the widget to format all the objects in the - * parsed object list to fit its current window size. - * Returns the max_height of the entire document. - * Title objects are ignored, and not formatted. - */ -int -FormatAll(hw, Fwidth) - HTMLWidget hw; - int *Fwidth; -{ - int x, y; - int width; - struct mark_up *msave; -#ifdef TIMING -gettimeofday(&Tv, &Tz); -fprintf(stderr, "FormatAll enter (%d.%d)\n", Tv.tv_sec, Tv.tv_usec); -#endif - - width = *Fwidth; - MaxWidth = width; - - /* - * Clear the is_index flag - */ - hw->html.is_index = False; - - /* - * Initialize local variables, some from the widget - */ - MarginW = hw->html.margin_width; -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ -#ifdef MOTIF - Fg = hw->manager.foreground; -#else - Fg = hw->html.foreground; -#endif /* MOTIF */ - Bg = hw->core.background_pixel; - Underlines = 0; - DashedUnderlines = False; - Width = width; - TextIndent = MarginW; - ElementId = 0; - WidgetId = 0; - LineNumber = 1; - LineBottom = 0; - BaseLine = -100; - CharsInLine = 0; - IndentLevel = 0; - Ignore = 0; - Preformat = 0; - PF_LF_State = 0; - NeedSpace = 0; - Internal = False; - Strikeout = False; - AnchorText = NULL; - DescType = &BaseDesc; - ListData = &BaseDesc; - DescType->type = D_NONE; - DescType->count = 0; - DescType->compact = 0; - DescType->next = NULL; - CurrentForm = NULL; - CurrentSelect = NULL; - TextAreaBuf = NULL; - Superscript = 0; /* amb */ - Subscript = 0; - InDocHead = 0; - InUnderlined = 0; - - /* - * Free the old title, if there is one. - */ - if (hw->html.title != NULL) - { - free(hw->html.title); - hw->html.title = NULL; - } - TitleText = NULL; - -#ifdef THROW_AWAY_OLD_LIST - /* - * Free up previously formatted elements - */ - FreeLineList(hw->html.formatted_elements); - hw->html.formatted_elements = NULL; -#endif - - /* - * Clear any previous selections - */ - hw->html.select_start = NULL; - hw->html.select_end = NULL; - hw->html.new_start = NULL; - hw->html.new_end = NULL; - - /* - * Set up a starting font, and starting x, y, position - */ - NewFont(hw->html.font); - currentFont = hw->html.font; - saveFont = NULL; - FontStack = &FontBase; - FontStack->font = hw->html.font; - - x = TextIndent; - y = hw->html.margin_height; - - /* - * Start a null element list, to be filled in as we go. - */ - Current = NULL; - - /* - * If we have parsed special header text, fill it in now. - */ - if (hw->html.html_header_objects != NULL) - { - msave = hw->html.html_objects; - hw->html.html_objects = hw->html.html_header_objects; - FormatChunk(hw, &x, &y); - - if (saveFont != NULL) - { - hw->html.font = saveFont; - saveFont = NULL; - } - NewFont(hw->html.font); - currentFont = hw->html.font; - - ConditionalLineFeed(hw, &x, &y, 1); - - hw->html.html_objects = msave; - } - - /* - * Format all objects for width - */ - FormatChunk(hw, &x, &y); - - /* - * If we have parsed special footer text, fill it in now. - */ - if (hw->html.html_footer_objects != NULL) - { - if (saveFont != NULL) - { - hw->html.font = saveFont; - saveFont = NULL; - } - NewFont(hw->html.font); - currentFont = hw->html.font; - - Preformat = 0; - PF_LF_State = 0; - NeedSpace = 0; - - ConditionalLineFeed(hw, &x, &y, 1); - - msave = hw->html.html_objects; - hw->html.html_objects = hw->html.html_footer_objects; - FormatChunk(hw, &x, &y); - - hw->html.html_objects = msave; - } - - /* - * Ensure a linefeed after the final element. - */ - ConditionalLineFeed(hw, &x, &y, 1); - - /* - * Restore the proper font from unterminated preformatted text - * sequences. - */ - if (saveFont != NULL) - { - hw->html.font = saveFont; - saveFont = NULL; - } - - /* - * Free any extra of the pre-allocated list. - * Terminate the element list. - */ - if ((Current != NULL)&&(Current->next != NULL)) - { - FreeLineList(Current->next); - Current->next = NULL; - } - else if ((Current == NULL)&&(hw->html.formatted_elements != NULL)) - { - FreeLineList(hw->html.formatted_elements); - hw->html.formatted_elements = NULL; - } - - /* - * Add the bottom margin to the max height. - */ - y = y + hw->html.margin_height; - - /* - * Make the line array indexed into the element list - * and store it into the widget - */ - hw->html.line_count = LineNumber; - if (hw->html.line_array != NULL) - { - free((char *)hw->html.line_array); - } - hw->html.line_array = MakeLineList(hw->html.formatted_elements, - LineNumber); - - /* - * If the passed in MaxWidth was wrong, correct it. - */ - if (MaxWidth != width) - { - *Fwidth = MaxWidth; - } - -#ifdef TIMING -gettimeofday(&Tv, &Tz); -fprintf(stderr, "FormatAll exit (%d.%d)\n", Tv.tv_sec, Tv.tv_usec); -#endif - return(y); -} - - -/* - * Redraw a linefeed. - * Basically a filled rectangle at the end of a line. - */ -void -LinefeedRefresh(hw, eptr) - HTMLWidget hw; - struct ele_rec *eptr; -{ - int x1, y1; - unsigned int width, height; - -#ifdef NO_EXTRA_FILLS - /* - * The actualt height of the rectangle to fill is strange, based - * an a differente between eptr->font->(ascent/descent) and - * eptr->font->max_bounds.(ascent/descent) which I don't quite - * understand. But it works. - * Deal with bad Lucidia descents. - */ - x1 = eptr->x; - if (x1 > (int)hw->core.width) - { - width = 0; - } - else - { - width = hw->core.width - x1; - } -#ifdef SHORT_LINEFEEDS - y1 = eptr->y + eptr->y_offset + eptr->font->max_bounds.ascent - - eptr->font->ascent; - height = eptr->font->ascent + eptr->font->descent; -#else - y1 = eptr->y + eptr->font->max_bounds.ascent - eptr->font->ascent; - height = eptr->line_height; -#endif /* SHORT_LINEFEEDS */ -#else - x1 = eptr->x; - if (x1 > (int)hw->core.width) - { - width = 0; - } - else - { - width = hw->core.width - x1; - } -#ifdef SHORT_LINEFEEDS - y1 = eptr->y + eptr->y_offset; - if (eptr->font->descent > eptr->font->max_bounds.descent) - { - height = eptr->font->max_bounds.ascent + - eptr->font->descent; - } - else - { - height = eptr->font->max_bounds.ascent + - eptr->font->max_bounds.descent; - } -#else - y1 = eptr->y; - height = eptr->line_height; -#endif /* SHORT_LINEFEEDS */ -#endif /* NO_EXTRA_FILLS */ - - x1 = x1 - hw->html.scroll_x; - y1 = y1 - hw->html.scroll_y; - - if (eptr->selected == True) - { - XSetForeground(XtDisplay(hw), hw->html.drawGC, eptr->fg); - } - else - { - XSetForeground(XtDisplay(hw), hw->html.drawGC, eptr->bg); - } - XFillRectangle(XtDisplay(hw->html.view), XtWindow(hw->html.view), - hw->html.drawGC, - x1, y1, width, height); -} - - -/* - * Redraw part of a formatted text element, in the passed fg and bg - */ -void -PartialRefresh(hw, eptr, start_pos, end_pos, fg, bg) - HTMLWidget hw; - struct ele_rec *eptr; - int start_pos, end_pos; - unsigned long fg, bg; -{ - int ascent; - char *tdata; - int tlen; - int x, y, width; - int partial; - - XSetFont(XtDisplay(hw), hw->html.drawGC, eptr->font->fid); - ascent = eptr->font->max_bounds.ascent; - width = -1; - partial = 0; - - if (start_pos != 0) - { - int dir, nascent, descent; - XCharStruct all; - -#ifdef ASSUME_FIXED_WIDTH_PRE - if (eptr->font == hw->html.plain_font) - { - all.width = eptr->font->max_bounds.width * start_pos; - } - else - { - XTextExtents(eptr->font, (char *)eptr->edata, - start_pos, &dir, &nascent, &descent, &all); - } -#else - XTextExtents(eptr->font, (char *)eptr->edata, - start_pos, &dir, &nascent, &descent, &all); -#endif /* ASSUME_FIXED_WIDTH_PRE */ - x = eptr->x + all.width; - tdata = (char *)(eptr->edata + start_pos); - partial = 1; - } - else - { - x = eptr->x; - tdata = (char *)eptr->edata; - } - - if (end_pos != (eptr->edata_len - 2)) - { - tlen = end_pos - start_pos + 1; - partial = 1; - } - else - { - tlen = eptr->edata_len - start_pos - 1; - } - - y = eptr->y + eptr->y_offset; - - x = x - hw->html.scroll_x; - y = y - hw->html.scroll_y; - -#ifndef NO_EXTRA_FILLS - { - int dir, nascent, descent; - XCharStruct all; - int height; - - /* - * May be safe to used the cached full width of this - * string, and thus avoid a call to XTextExtents - */ - if ((!partial)&&(eptr->width != 0)) - { - all.width = eptr->width; - } - else - { -#ifdef ASSUME_FIXED_WIDTH_PRE - if (eptr->font == hw->html.plain_font) - { - all.width = eptr->font->max_bounds.width * tlen; - } - else - { - XTextExtents(eptr->font, (char *)tdata, - tlen, &dir, &nascent, &descent, &all); - } -#else - XTextExtents(eptr->font, (char *)tdata, - tlen, &dir, &nascent, &descent, &all); -#endif /* ASSUME_FIXED_WIDTH_PRE */ - } - - XSetForeground(XtDisplay(hw), hw->html.drawGC, bg); - - height = (eptr->font->max_bounds.ascent - eptr->font->ascent); - if (height > 0) - { - XFillRectangle(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - hw->html.drawGC, x, y, - (unsigned int)all.width, (unsigned int)height); - } - height = (eptr->font->max_bounds.descent - eptr->font->descent); - if (height > 0) - { - XFillRectangle(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - hw->html.drawGC, x, - (int)(y + eptr->font->max_bounds.ascent + - eptr->font->descent), - (unsigned int)all.width, (unsigned int)height); - } - width = all.width; - } -#endif /* NO_EXTRA_FILLS */ - - XSetForeground(XtDisplay(hw), hw->html.drawGC, fg); - XSetBackground(XtDisplay(hw), hw->html.drawGC, bg); - - XDrawImageString(XtDisplay(hw->html.view), XtWindow(hw->html.view), - hw->html.drawGC, - x, y + ascent, - (char *)tdata, tlen); - - if (eptr->underline_number) - { - int i, ly; - - if (eptr->dashed_underline) - { - XSetLineAttributes(XtDisplay(hw), hw->html.drawGC, 1, - LineDoubleDash, CapButt, JoinBevel); - } - else - { - XSetLineAttributes(XtDisplay(hw), hw->html.drawGC, 1, - LineSolid, CapButt, JoinBevel); - } - - if (width == -1) - { - int dir, nascent, descent; - XCharStruct all; - -#ifdef ASSUME_FIXED_WIDTH_PRE - if (eptr->font == hw->html.plain_font) - { - all.width = eptr->font->max_bounds.width * tlen; - } - else - { - XTextExtents(eptr->font, (char *)tdata, - tlen, &dir, &nascent, &descent,&all); - } -#else - XTextExtents(eptr->font, (char *)tdata, - tlen, &dir, &nascent, &descent,&all); -#endif /* ASSUME_FIXED_WIDTH_PRE */ - width = all.width; - } - - ly = (int)(y + eptr->font->max_bounds.ascent + - eptr->font->descent - 1); - - for (i=0; iunderline_number; i++) - { - XDrawLine(XtDisplay(hw->html.view), - XtWindow(hw->html.view), hw->html.drawGC, - x, ly, (int)(x + width), ly); - ly -= 2; - } - } - - if (eptr->strikeout == True) - { - int ly; - - XSetLineAttributes(XtDisplay(hw), hw->html.drawGC, 1, - LineSolid, CapButt, JoinBevel); - - if (width == -1) - { - int dir, nascent, descent; - XCharStruct all; - -#ifdef ASSUME_FIXED_WIDTH_PRE - if (eptr->font == hw->html.plain_font) - { - all.width = eptr->font->max_bounds.width * tlen; - } - else - { - XTextExtents(eptr->font, (char *)tdata, - tlen, &dir, &nascent, &descent,&all); - } -#else - XTextExtents(eptr->font, (char *)tdata, - tlen, &dir, &nascent, &descent,&all); -#endif /* ASSUME_FIXED_WIDTH_PRE */ - width = all.width; - } - - ly = (int)(y + eptr->font->max_bounds.ascent + - eptr->font->descent - 1); - ly = ly - ((hw->html.font->max_bounds.ascent + - hw->html.font->descent) / 2); - - XDrawLine(XtDisplay(hw->html.view), XtWindow(hw->html.view), - hw->html.drawGC, - x, ly, (int)(x + width), ly); - } -} - - -/* - * Redraw a formatted text element - */ -void -TextRefresh(hw, eptr, start_pos, end_pos) - HTMLWidget hw; - struct ele_rec *eptr; - int start_pos, end_pos; -{ - if (eptr->selected == False) - { - PartialRefresh(hw, eptr, start_pos, end_pos, - eptr->fg, eptr->bg); - } - else if ((start_pos >= eptr->start_pos)&&(end_pos <= eptr->end_pos)) - { - PartialRefresh(hw, eptr, start_pos, end_pos, - eptr->bg, eptr->fg); - } - else - { - if (start_pos < eptr->start_pos) - { - PartialRefresh(hw, eptr, start_pos, eptr->start_pos - 1, - eptr->fg, eptr->bg); - start_pos = eptr->start_pos; - } - if (end_pos > eptr->end_pos) - { - PartialRefresh(hw, eptr, eptr->end_pos + 1, end_pos, - eptr->fg, eptr->bg); - end_pos = eptr->end_pos; - } - PartialRefresh(hw, eptr, start_pos, end_pos, - eptr->bg, eptr->fg); - } -} - - -/* - * Redraw a formatted bullet element - */ -void -BulletRefresh(hw, eptr) - HTMLWidget hw; - struct ele_rec *eptr; -{ - int width, line_height; - int x1, y1; - -/* - width = eptr->font->max_bounds.width; -*/ - width = eptr->font->max_bounds.lbearing + - eptr->font->max_bounds.rbearing; - /* - * Deal with bad Lucidia descents. - */ - if (eptr->font->descent > eptr->font->max_bounds.descent) - { - line_height = eptr->font->max_bounds.ascent + - eptr->font->descent; - } - else - { - line_height = eptr->font->max_bounds.ascent + - eptr->font->max_bounds.descent; - } - x1 = eptr->x; - y1 = eptr->y + eptr->y_offset + (line_height / 2) - (width / 4); - x1 = x1 - hw->html.scroll_x; - y1 = y1 - hw->html.scroll_y; - XSetFont(XtDisplay(hw), hw->html.drawGC, eptr->font->fid); - XSetForeground(XtDisplay(hw), hw->html.drawGC, eptr->fg); - XSetBackground(XtDisplay(hw), hw->html.drawGC, eptr->bg); - if (eptr->indent_level < 2) - { - XFillArc(XtDisplay(hw->html.view), XtWindow(hw->html.view), - hw->html.drawGC, - (x1 - width), y1, - (width / 2), (width / 2), 0, 23040); - } - else if (eptr->indent_level == 2) - { - XSetLineAttributes(XtDisplay(hw), hw->html.drawGC, 1, - LineSolid, CapButt, JoinBevel); - XDrawRectangle(XtDisplay(hw->html.view), - XtWindow(hw->html.view), hw->html.drawGC, - (x1 - width), y1, - (width / 2), (width / 2)); - } - else if (eptr->indent_level > 2) - { - XSetLineAttributes(XtDisplay(hw), hw->html.drawGC, 1, - LineSolid, CapButt, JoinBevel); - XDrawArc(XtDisplay(hw->html.view), XtWindow(hw->html.view), - hw->html.drawGC, - (x1 - width), y1, - (width / 2), (width / 2), 0, 23040); - } -} - - -/* - * Redraw a formatted horizontal rule element - */ -void -HRuleRefresh(hw, eptr) - HTMLWidget hw; - struct ele_rec *eptr; -{ - int width, height; - int x1, y1; - - width = (int)hw->html.view_width - (int)(2 * hw->html.margin_width); - if (width < 0) - { - width = 0; - } - - x1 = eptr->x; - y1 = eptr->y; - x1 = x1 - hw->html.scroll_x; - y1 = y1 - hw->html.scroll_y; - height = eptr->line_height; - - /* blank out area */ - XSetForeground(XtDisplay(hw), hw->html.drawGC, eptr->bg); - XFillRectangle(XtDisplay(hw->html.view), XtWindow(hw->html.view), - hw->html.drawGC, x1, y1, width, height); - y1 = y1 + (height / 2) - 1; - - XSetLineAttributes(XtDisplay(hw), hw->html.drawGC, 1, - LineSolid, CapButt, JoinBevel); -#ifdef MOTIF - XDrawLine(XtDisplay(hw->html.view), XtWindow(hw->html.view), - hw->manager.bottom_shadow_GC, - x1, y1, (int)(x1 + width), y1); - XDrawLine(XtDisplay(hw->html.view), XtWindow(hw->html.view), - hw->manager.top_shadow_GC, - x1, y1 + 1, (int)(x1 + width), y1 + 1); -#else - /* changing the GC back and forth is not the most efficient way.... */ - XSetForeground(XtDisplay(hw), hw->html.drawGC, eptr->fg); - XDrawLine(XtDisplay(hw->html.view), XtWindow(hw->html.view), - hw->html.drawGC, - x1, y1, (int)(x1 + width), y1); - XDrawLine(XtDisplay(hw->html.view), XtWindow(hw->html.view), - hw->html.drawGC, - x1, y1 + 1, (int)(x1 + width), y1 + 1); -#endif -} - - -/* - * Redraw a formatted image element. - * The color of the image border reflects whether it is an active anchor - * or not. - * Actual Pixmap creation was put off until now to make sure we - * had a window. If it hasn't been already created, make the Pixmap - * now. - */ -void -ImageRefresh(hw, eptr) - HTMLWidget hw; - struct ele_rec *eptr; -{ - if (eptr->pic_data != NULL) - { - int x, y, extra; - - x = eptr->x; - y = eptr->y + eptr->y_offset; - - if ((hw->html.border_images == True)|| - ((eptr->anchorHRef != NULL)&& - (!eptr->pic_data->internal))) - { - extra = IMAGE_BORDER; - } - else - { - extra = 0; - } - - x = x - hw->html.scroll_x; - y = y - hw->html.scroll_y; - - XSetForeground(XtDisplay(hw), hw->html.drawGC, eptr->fg); - XSetBackground(XtDisplay(hw), hw->html.drawGC, eptr->bg); - XFillRectangle(XtDisplay(hw->html.view), - XtWindow(hw->html.view), hw->html.drawGC, - x, y, - (eptr->pic_data->width + (2 * extra)), - extra); - XFillRectangle(XtDisplay(hw->html.view), - XtWindow(hw->html.view), hw->html.drawGC, - x, - (y + eptr->pic_data->height + extra), - (eptr->pic_data->width + (2 * extra)), - extra); - XFillRectangle(XtDisplay(hw->html.view), - XtWindow(hw->html.view), hw->html.drawGC, - x, y, - extra, - (eptr->pic_data->height + (2 * extra))); - XFillRectangle(XtDisplay(hw->html.view), - XtWindow(hw->html.view), hw->html.drawGC, - (x + eptr->pic_data->width + extra), - y, - extra, - (eptr->pic_data->height + (2 * extra))); - - if (eptr->pic_data->image == (Pixmap)NULL) - { - if (eptr->pic_data->image_data != NULL) - { - eptr->pic_data->image = InfoToImage(hw, - eptr->pic_data); - } - else - { - if (eptr->pic_data->delayed) - { - if ((eptr->anchorHRef != NULL)&& - (!IsDelayedHRef(hw, eptr->anchorHRef))&& - (!IsIsMapForm(hw, eptr->anchorHRef))) - { - eptr->pic_data->image = DelayedImage( - hw, True); - } - else - { - eptr->pic_data->image = DelayedImage( - hw, False); - } - } - else - { - /* - * Could be that the user opened another - * window, and the Pixmap was freed, and - * then they overflowed the cache, - * and the XImage data was freed. - * If this image was ever successfully - * fetched, try again before giving up. - */ - if ((eptr->pic_data->fetched)&& - (hw->html.resolveDelayedImage != NULL)) - { - ImageInfo *pdata; - - pdata = eptr->pic_data; - eptr->pic_data = (*(resolveImageProc) - (hw->html.resolveDelayedImage))(hw, - eptr->edata); - if (eptr->pic_data != NULL) - { - eptr->pic_data->delayed = 0; - /* - * Mark images we have sucessfully - * loaded at least once - */ - if (eptr->pic_data->image_data != NULL) - { - eptr->pic_data->fetched = 1; - } - /* - * Copy over state information from - * the last time we had this image - */ - eptr->pic_data->ismap = - pdata->ismap; - eptr->pic_data->fptr = - pdata->fptr; - eptr->pic_data->internal = - pdata->internal; - eptr->pic_data->text = - pdata->text; - } - else - { - eptr->pic_data = NoImageData(hw); - eptr->pic_data->delayed = 0; - eptr->pic_data->internal = 0; - } - } - else - { - eptr->pic_data->image = NoImage(hw); - } - } - } - } - - if (eptr->pic_data->image != (Pixmap)NULL) - { - XCopyArea(XtDisplay(hw->html.view), - eptr->pic_data->image, - XtWindow(hw->html.view), hw->html.drawGC, 0, 0, - eptr->pic_data->width, eptr->pic_data->height, - (x + extra), - (y + extra)); - - } - if ((eptr->pic_data->delayed)&&(eptr->anchorHRef != NULL)&& - (!IsDelayedHRef(hw, eptr->anchorHRef))&& - (!IsIsMapForm(hw, eptr->anchorHRef))) - { - XSetForeground(XtDisplay(hw), hw->html.drawGC, - eptr->fg); - XFillRectangle(XtDisplay(hw->html.view), - XtWindow(hw->html.view), hw->html.drawGC, - x, (y + AnchoredHeight(hw)), - (eptr->pic_data->width + (2 * extra)), - extra); - } - } -} - - -void -RefreshTextRange(hw, start, end) - HTMLWidget hw; - struct ele_rec *start; - struct ele_rec *end; -{ - struct ele_rec *eptr; - - eptr = start; - while ((eptr != NULL)&&(eptr != end)) - { - if (eptr->type == E_TEXT) - { - TextRefresh(hw, eptr, - 0, (eptr->edata_len - 2)); - } - eptr = eptr->next; - } - if (eptr != NULL) - { - if (eptr->type == E_TEXT) - { - TextRefresh(hw, eptr, - 0, (eptr->edata_len - 2)); - } - } -} - - -/* - * Refresh all elements on a single line into the widget's window - */ -void -PlaceLine(hw, line) - HTMLWidget hw; - int line; -{ - struct ele_rec *eptr; - - /* - * Item list for this line - */ - eptr = hw->html.line_array[line]; - - while ((eptr != NULL)&&(eptr->line_number == (line + 1))) - { - switch(eptr->type) - { - case E_TEXT: - TextRefresh(hw, eptr, - 0, (eptr->edata_len - 2)); - break; - case E_BULLET: - BulletRefresh(hw, eptr); - break; - case E_HRULE: - HRuleRefresh(hw, eptr); - break; - case E_LINEFEED: - LinefeedRefresh(hw, eptr); - break; - case E_IMAGE: - ImageRefresh(hw, eptr); - break; - case E_WIDGET: - WidgetRefresh(hw, eptr); - break; - case E_TABLE: - TableRefresh(hw, eptr); - break; - } - eptr = eptr->next; - } -} - - -/* - * Locate the element (if any) that is at the passed location - * in the widget. If there is no corresponding element, return - * NULL. If an element is found return the position of the character - * you are at in the pos pointer passed. - */ -struct ele_rec * -LocateElement(hw, x, y, pos) - HTMLWidget hw; - int x, y; - int *pos; -{ - struct ele_rec *eptr; - struct ele_rec *rptr; - int i, start, end, line, guess; - int tx1, tx2, ty1, ty2; - - x = x + hw->html.scroll_x; - y = y + hw->html.scroll_y; - - /* - * Narrow the search down to a 2 line range - * before beginning to search element by element - */ - start = -1; - end = -1; - - /* - * Heuristic to speed up redraws by guessing at the starting line. - */ - guess = y / (hw->html.font->max_bounds.ascent + - hw->html.font->max_bounds.descent); - if (guess > (hw->html.line_count - 1)) - { - guess = hw->html.line_count - 1; - } - while (guess > 0) - { - if ((hw->html.line_array[guess] != NULL)&& - (hw->html.line_array[guess]->y <= y)) - { - break; - } - guess--; - } - if (guess < 0) - { - guess = 0; - } - - for (i=guess; ihtml.line_count; i++) - { - if (hw->html.line_array[i] == NULL) - { - continue; - } - else if (hw->html.line_array[i]->y <= y) - { - start = i; - continue; - } - else - { - end = i; - break; - } - } - - /* - * Search may have already failed, or it may be a one line - * range. - */ - if ((start == -1)&&(end == -1)) - { - return(NULL); - } - else if (start == -1) - { - start = end; - } - else if (end == -1) - { - end = start; - } - - /* - * Search element by element, for now we only search - * text elements, images, and linefeeds. - */ - eptr = hw->html.line_array[start]; - ty1 = eptr->y; - /* - * Deal with bad Lucidia descents. - */ - if (eptr->font->descent > eptr->font->max_bounds.descent) - { - ty2 = eptr->y + eptr->font->max_bounds.ascent + - eptr->font->descent; - } - else - { - ty2 = eptr->y + eptr->font->max_bounds.ascent + - eptr->font->max_bounds.descent; - } - line = eptr->line_number; - /* - * Searches on this line should extend to the top of the - * next line, if possible. Which might be far away if there - * is an image on this line. - */ - if (((line + 1) < hw->html.line_count)&& - (hw->html.line_array[line + 1] != NULL)) - { - ty2 = hw->html.line_array[line + 1]->y - 1; - } - /* - * Else we are at the last line, and need to find its height. - * The linefeed at the end should know the max height of the line. - */ - else - { - struct ele_rec *teptr; - - teptr = eptr; - while (teptr != NULL) - { - if (teptr->type == E_LINEFEED) - { - break; - } - teptr = teptr->next; - } - if (teptr != NULL) - { - ty2 = teptr->y + teptr->line_height - 1; - } - } - - rptr = NULL; - while ((eptr != NULL)&&(eptr->line_number <= (end + 1))) - { - if (eptr->line_number != line) - { - ty1 = ty2; - /* - * Deal with bad Lucidia descents. - */ - if(eptr->font->descent > eptr->font->max_bounds.descent) - { - ty2 = eptr->y + eptr->font->max_bounds.ascent + - eptr->font->descent; - } - else - { - ty2 = eptr->y + eptr->font->max_bounds.ascent + - eptr->font->max_bounds.descent; - } - line = eptr->line_number; - /* - * Searches on this line should extend to the top of - * the next line, if possible. Which might be far - * away if there is an image on this line. - */ - if (((line + 1) < hw->html.line_count)&& - (hw->html.line_array[line + 1] != NULL)) - { - ty2 = hw->html.line_array[line + 1]->y - 1; - } - /* - * Else we are at the last line, and need to find its - * height. The linefeed at the end should know the - * max height of the line. - */ - else - { - struct ele_rec *teptr; - - teptr = eptr; - while (teptr != NULL) - { - if (teptr->type == E_LINEFEED) - { - break; - } - teptr = teptr->next; - } - if (teptr != NULL) - { - ty2 = teptr->y + teptr->line_height - 1; - } - } - } - - if (eptr->type == E_TEXT) - { - int dir, ascent, descent; - XCharStruct all; - - tx1 = eptr->x; - XTextExtents(eptr->font, (char *)eptr->edata, - eptr->edata_len - 1, &dir, - &ascent, &descent, &all); - tx2 = eptr->x + all.width; - if ((x >= tx1)&&(x <= tx2)&&(y >= ty1)&&(y <= ty2)) - { - rptr = eptr; - break; - } - } - else if ((eptr->type == E_IMAGE)&&(eptr->pic_data != NULL)) - { - tx1 = eptr->x; - tx2 = eptr->x + eptr->pic_data->width; - if ((x >= tx1)&&(x <= tx2)&&(y >= ty1)&&(y <= ty2)) - { - rptr = eptr; - break; - } - } - else if (eptr->type == E_LINEFEED) - { - tx1 = eptr->x; - if ((x >= tx1)&&(y >= ty1)&&(y <= ty2)) - { - rptr = eptr; - break; - } - else if (eptr->next == NULL) - { - rptr = eptr; - break; - } - else if (eptr->next != NULL) - { - int tmpy; - - tmpy = eptr->next->y + eptr->next->line_height; - tx2 = eptr->next->x; - if ((x < tx2)&&(y >= ty2)&&(y <= tmpy)) - { - rptr = eptr; - break; - } - } - } - eptr = eptr->next; - } - - /* - * If we found an element, locate the exact character position within - * that element. - */ - if (rptr != NULL) - { - int dir, ascent, descent; - XCharStruct all; - int epos; - - /* - * Start assuming fixed width font. The real position should - * always be <= to this, but just in case, start at the end - * of the string if it is not. - */ - epos = ((x - rptr->x) / rptr->font->max_bounds.width) + 1; - if (epos >= rptr->edata_len - 1) - { - epos = rptr->edata_len - 2; - } - XTextExtents(rptr->font, (char *)rptr->edata, - (epos + 1), &dir, &ascent, &descent, &all); - if (x > (int)(rptr->x + all.width)) - { - epos = rptr->edata_len - 3; - } - else - { - epos--; - } - - while (epos >= 0) - { - XTextExtents(rptr->font, (char *)rptr->edata, - (epos + 1), &dir, &ascent, &descent, &all); - if ((int)(rptr->x + all.width) <= x) - { - break; - } - epos--; - } - epos++; - *pos = epos; - } - return(rptr); -} - - -/* - * Used by ParseTextToPrettyString to let it be sloppy about its - * string creation, and never overflow the buffer. - * It concatonates the passed string to the current string, managing - * both the current string length, and the total buffer length. - */ -void -strcpy_or_grow(str, slen, blen, add) - char **str; - int *slen; - int *blen; - char *add; -{ - int newlen; - int addlen; - char *buf; - - /* - * If necessary, initialize this string buffer - */ - if (*str == NULL) - { - *str = (char *)malloc(1024 * sizeof(char)); - if (*str == NULL) - { - return; - } - *blen = 1024; - strcpy(*str, ""); - *slen = 0; - } - - buf = *str; - if ((buf == NULL)||(add == NULL)) - { - return; - } - - addlen = strlen(add); - - newlen = *slen + addlen; - if (newlen >= *blen) - { - newlen = ((newlen / 1024) + 1) * 1024; - buf = (char *)malloc(newlen * sizeof(char)); - if (buf == NULL) - { - return; - } - bcopy(*str, buf, *blen); - free((char *)*str); - *str = buf; - *blen = newlen; - } - - bcopy(add, (char *)(buf + *slen), addlen + 1); - - *slen = *slen + addlen; -} - - -/* - * Parse all the formatted text elements from start to end - * into an ascii text string, and return it. - * space_width and lmargin tell us how many spaces - * to indent lines. - */ -char * -ParseTextToString(elist, startp, endp, start_pos, end_pos, space_width, lmargin) - struct ele_rec *elist; - struct ele_rec *startp; - struct ele_rec *endp; - int start_pos, end_pos; - int space_width; - int lmargin; -{ - int newline; - int epos; - char *text; - int t_slen, t_blen; - struct ele_rec *eptr; - struct ele_rec *start; - struct ele_rec *end; - - if (startp == NULL) - { - return(NULL); - } - - if (SwapElements(startp, endp, start_pos, end_pos)) - { - start = endp; - end = startp; - epos = start_pos; - start_pos = end_pos; - end_pos = epos; - } - else - { - start = startp; - end = endp; - } - - text = NULL; - newline = 0; - eptr = start; - while ((eptr != NULL)&&(eptr != end)) - { - /* - * Skip the special internal text - */ - if (eptr->internal == True) - { - eptr = eptr->next; - continue; - } - - if (eptr->type == E_TEXT) - { - int i, spaces; - char *tptr; - - if (eptr == start) - { - tptr = (char *)(eptr->edata + start_pos); - } - else - { - tptr = (char *)eptr->edata; - } - - if (newline) - { - spaces = (eptr->x - lmargin) / space_width; - if (spaces < 0) - { - spaces = 0; - } - for (i=0; itype == E_LINEFEED) - { - strcpy_or_grow(&text, &t_slen, &t_blen, "\n"); - newline = 1; - } - eptr = eptr->next; - } - if ((eptr != NULL)&&(eptr->internal == False)) - { - if (eptr->type == E_TEXT) - { - int i, spaces; - char *tptr; - char *tend, tchar; - - if (eptr == start) - { - tptr = (char *)(eptr->edata + start_pos); - } - else - { - tptr = (char *)eptr->edata; - } - - if (eptr == end) - { - tend = (char *)(eptr->edata + end_pos + 1); - tchar = *tend; - *tend = '\0'; - } - - if (newline) - { - spaces = (eptr->x - lmargin) / space_width; - if (spaces < 0) - { - spaces = 0; - } - for (i=0; itype == E_LINEFEED) - { - strcpy_or_grow(&text, &t_slen, &t_blen, "\n"); - newline = 1; - } - } - return(text); -} - - -/* - * Parse all the formatted text elements from start to end - * into an ascii text string, and return it. - * Very like ParseTextToString() except the text is prettied up - * to show headers and the like. - * space_width and lmargin tell us how many spaces - * to indent lines. - */ -char * -ParseTextToPrettyString(hw, elist, startp, endp, start_pos, end_pos, - space_width, lmargin) - HTMLWidget hw; - struct ele_rec *elist; - struct ele_rec *startp; - struct ele_rec *endp; - int start_pos, end_pos; - int space_width; - int lmargin; -{ - int line; - int newline; - int lead_spaces; - int epos; - char *text; - int t_slen, t_blen; - char *line_buf; - int l_slen, l_blen; - char lchar; - struct ele_rec *eptr; - struct ele_rec *start; - struct ele_rec *end; - struct ele_rec *last; - - if (startp == NULL) - { - return(NULL); - } - - if (SwapElements(startp, endp, start_pos, end_pos)) - { - start = endp; - end = startp; - epos = start_pos; - start_pos = end_pos; - end_pos = epos; - } - else - { - start = startp; - end = endp; - } - - text = NULL; - line_buf = NULL; - - /* - * We need to know if we should consider the indentation or bullet - * that might be just before the first selected element to also be - * selected. This current hack looks to see if they selected the - * Whole line, and assumes if they did, they also wanted the beginning. - * - * If we are at the beginning of the list, or the beginning of - * a line, or just behind a bullett, assume this is the start of - * a line that we may want to include the indent for. - */ - if ((start_pos == 0)&& - ((start->prev == NULL)||(start->prev->type == E_BULLET)|| - (start->prev->line_number != start->line_number))) - { - eptr = start; - while ((eptr != NULL)&&(eptr != end)&& - (eptr->type != E_LINEFEED)) - { - eptr = eptr->next; - } - if ((eptr != NULL)&&(eptr->type == E_LINEFEED)) - { - newline = 1; - if ((start->prev != NULL)&& - (start->prev->type == E_BULLET)) - { - start = start->prev; - } - } - else - { - newline = 0; - } - } - else - { - newline = 0; - } - - lead_spaces = 0; - last = start; - eptr = start; - line = eptr->line_number; - while ((eptr != NULL)&&(eptr != end)) - { - /* - * Skip the special internal text - */ - if (eptr->internal == True) - { - eptr = eptr->next; - continue; - } - - if (eptr->type == E_BULLET) - { - int i, spaces; - - if (newline) - { - spaces = (eptr->x - lmargin) / space_width; - spaces -= 2; - if (spaces < 0) - { - spaces = 0; - } - lead_spaces = spaces; - for (i=0; itype == E_TEXT) - { - int i, spaces; - char *tptr; - - if (eptr == start) - { - tptr = (char *)(eptr->edata + start_pos); - } - else - { - tptr = (char *)eptr->edata; - } - - if (newline) - { - spaces = (eptr->x - lmargin) / space_width; - if (spaces < 0) - { - spaces = 0; - } - lead_spaces = spaces; - for (i=0; itype == E_LINEFEED) - { - strcpy_or_grow(&text, &t_slen, &t_blen, line_buf); - strcpy_or_grow(&text, &t_slen, &t_blen, "\n"); - newline = 1; - lchar = '\0'; - if (eptr->font == hw->html.header1_font) - { - lchar = '*'; - } - else if (eptr->font == hw->html.header2_font) - { - lchar = '='; - } - else if (eptr->font == hw->html.header3_font) - { - lchar = '+'; - } - else if (eptr->font == hw->html.header4_font) - { - lchar = '-'; - } - else if (eptr->font == hw->html.header5_font) - { - lchar = '~'; - } - else if (eptr->font == hw->html.header6_font) - { - lchar = '.'; - } - if (lchar != '\0') - { - char *ptr; - int cnt; - - cnt = 0; - ptr = line_buf; - while ((ptr != NULL)&&(*ptr != '\0')) - { - cnt++; - if (cnt > lead_spaces) - { - *ptr = lchar; - } - ptr++; - } - strcpy_or_grow(&text,&t_slen,&t_blen, line_buf); - strcpy_or_grow(&text, &t_slen, &t_blen, "\n"); - } - if (line_buf != NULL) - { - free(line_buf); - line_buf = NULL; - } - } - last = eptr; - eptr = eptr->next; - } - if ((eptr != NULL)&&(eptr->internal == False)) - { - if (eptr->type == E_BULLET) - { - int i, spaces; - - if (newline) - { - spaces = (eptr->x - lmargin) / space_width; - spaces -= 2; - if (spaces < 0) - { - spaces = 0; - } - lead_spaces = spaces; - for (i=0; itype == E_TEXT) - { - int i, spaces; - char *tptr; - char *tend, tchar; - - if (eptr == start) - { - tptr = (char *)(eptr->edata + start_pos); - } - else - { - tptr = (char *)eptr->edata; - } - - if (eptr == end) - { - tend = (char *)(eptr->edata + end_pos + 1); - tchar = *tend; - *tend = '\0'; - } - - if (newline) - { - spaces = (eptr->x - lmargin) / space_width; - if (spaces < 0) - { - spaces = 0; - } - lead_spaces = spaces; - for (i=0; itype == E_LINEFEED) - { - strcpy_or_grow(&text, &t_slen, &t_blen, line_buf); - strcpy_or_grow(&text, &t_slen, &t_blen, "\n"); - newline = 1; - lchar = '\0'; - if (eptr->font == hw->html.header1_font) - { - lchar = '*'; - } - else if (eptr->font == hw->html.header2_font) - { - lchar = '='; - } - else if (eptr->font == hw->html.header3_font) - { - lchar = '+'; - } - else if (eptr->font == hw->html.header4_font) - { - lchar = '-'; - } - else if (eptr->font == hw->html.header5_font) - { - lchar = '~'; - } - else if (eptr->font == hw->html.header6_font) - { - lchar = '.'; - } - if (lchar != '\0') - { - char *ptr; - int cnt; - - cnt = 0; - ptr = line_buf; - while ((ptr != NULL)&&(*ptr != '\0')) - { - cnt++; - if (cnt > lead_spaces) - { - *ptr = lchar; - } - ptr++; - } - strcpy_or_grow(&text,&t_slen,&t_blen, line_buf); - strcpy_or_grow(&text, &t_slen, &t_blen, "\n"); - } - if (line_buf != NULL) - { - free(line_buf); - line_buf = NULL; - } - } - last = eptr; - } - if (line_buf != NULL) - { - strcpy_or_grow(&text, &t_slen, &t_blen, line_buf); - lchar = '\0'; - if (last->font == hw->html.header1_font) - { - lchar = '*'; - } - else if (last->font == hw->html.header2_font) - { - lchar = '='; - } - else if (last->font == hw->html.header3_font) - { - lchar = '+'; - } - else if (last->font == hw->html.header4_font) - { - lchar = '-'; - } - else if (last->font == hw->html.header5_font) - { - lchar = '~'; - } - else if (last->font == hw->html.header6_font) - { - lchar = '.'; - } - if (lchar != '\0') - { - char *ptr; - int cnt; - - cnt = 0; - ptr = line_buf; - while ((ptr != NULL)&&(*ptr != '\0')) - { - cnt++; - if (cnt > lead_spaces) - { - *ptr = lchar; - } - ptr++; - } - strcpy_or_grow(&text, &t_slen, &t_blen, "\n"); - strcpy_or_grow(&text, &t_slen, &t_blen, line_buf); - } - } - if (line_buf != NULL) - { - free(line_buf); - line_buf = NULL; - } - return(text); -} - - -/* - * Find the preferred width of a parsed HTML document - * Currently unformatted plain text, unformatted listing text, plain files - * and preformatted text require special width. - * Preferred width = (width of longest plain text line in document) * - * (width of that text's font) - */ -int -DocumentWidth(hw, list) - HTMLWidget hw; - struct mark_up *list; -{ - struct mark_up *mptr; - int plain_text; - int listing_text; - int pcnt, lcnt, pwidth, lwidth; - int width; - char *ptr; - - /* - * Loop through object list looking at the plain, preformatted, - * and listing text - */ - width = 0; - pwidth = 0; - lwidth = 0; - plain_text = 0; - listing_text = 0; - mptr = list; - while (mptr != NULL) - { - /* - * All text blocks between the starting and ending - * plain and pre text markers are plain text blocks. - * Manipulate flags so we recognize these blocks. - */ - if ((mptr->type == M_PLAIN_TEXT)|| - (mptr->type == M_PLAIN_FILE)|| - (mptr->type == M_PREFORMAT)) - { - if (mptr->is_end) - { - plain_text--; - if (plain_text < 0) - { - plain_text = 0; - } - } - else - { - plain_text++; - } - pcnt = 0; - lcnt = 0; - } - /* - * All text blocks between the starting and ending - * listing markers are listing text blocks. - */ - else if (mptr->type == M_LISTING_TEXT) - { - if (mptr->is_end) - { - listing_text--; - if (listing_text < 0) - { - listing_text = 0; - } - } - else - { - listing_text++; - } - lcnt = 0; - pcnt = 0; - } - /* - * If this is a plain text block, add to line length. - * Find the Max of all line lengths. - */ - else if ((plain_text)&&(mptr->type == M_NONE)) - { - ptr = mptr->text; - while ((ptr != NULL)&&(*ptr != '\0')) - { - ptr = MaxTextWidth(ptr, &pcnt); - if (pcnt > pwidth) - { - pwidth = pcnt; - } - } - } - /* - * If this is a listing text block, add to line length. - * Find the Max of all line lengths. - */ - else if ((listing_text)&&(mptr->type == M_NONE)) - { - ptr = mptr->text; - while ((ptr != NULL)&&(*ptr != '\0')) - { - ptr = MaxTextWidth(ptr, &lcnt); - if (lcnt > lwidth) - { - lwidth = lcnt; - } - } - } - mptr = mptr->next; - } - width = pwidth * hw->html.plain_font->max_bounds.width; - lwidth = lwidth * hw->html.listing_font->max_bounds.width; - if (lwidth > width) - { - width = lwidth; - } - return(width); -} - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLimages.c xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLimages.c --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLimages.c Sun Jun 1 17:22:04 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLimages.c Thu Jan 1 00:00:00 1970 @@ -1,891 +0,0 @@ -/**************************************************************************** - * NCSA Mosaic for the X Window System * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * mosaic@ncsa.uiuc.edu * - * * - * Copyright (C) 1993, Board of Trustees of the University of Illinois * - * * - * NCSA Mosaic software, both binary and source (hereafter, Software) is * - * copyrighted by The Board of Trustees of the University of Illinois * - * (UI), and ownership remains with the UI. * - * * - * The UI grants you (hereafter, Licensee) a license to use the Software * - * for academic, research and internal business purposes only, without a * - * fee. Licensee may distribute the binary and source code (if released) * - * to third parties provided that the copyright notice and this statement * - * appears on all copies and that no charge is associated with such * - * copies. * - * * - * Licensee may make derivative works. However, if Licensee distributes * - * any derivative work based on or derived from the Software, then * - * Licensee will (1) notify NCSA regarding its distribution of the * - * derivative work, and (2) clearly notify users that such derivative * - * work is a modified version and not the original NCSA Mosaic * - * distributed by the UI. * - * * - * Any Licensee wishing to make commercial use of the Software should * - * contact the UI, c/o NCSA, to negotiate an appropriate license for such * - * commercial use. Commercial use includes (1) integration of all or * - * part of the source code into a product for sale or license by or on * - * behalf of Licensee to third parties, or (2) distribution of the binary * - * code or source code to third parties that need it to utilize a * - * commercial product sold or licensed by or on behalf of Licensee. * - * * - * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR * - * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED * - * WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE * - * USERS OF THIS SOFTWARE. * - * * - * By using or copying this Software, Licensee agrees to abide by the * - * copyright law and all other applicable laws of the U.S. including, but * - * not limited to, export control laws, and the terms of this license. * - * UI shall have the right to terminate this license immediately by * - * written notice upon Licensee's breach of, or non-compliance with, any * - * of its terms. Licensee may be held legally responsible for any * - * copyright infringement that is caused or encouraged by Licensee's * - * failure to abide by the terms of this license. * - * * - * Comments and questions are welcome and can be sent to * - * mosaic-x@ncsa.uiuc.edu. * - ****************************************************************************/ - -#include -#include -#include "HTMLP.h" -#include "NoImage.xbm" -#include "DelayedImage.xbm" -#include "AnchoredImage.xbm" - - -#define IMAGE_BORDER 2 - - -ImageInfo no_image; -ImageInfo delayed_image; -ImageInfo anchored_image; - -static int allocation_index[256]; - - -/* - * Free all the colors in the default colormap that we have allocated so far. - */ -void -FreeColors(dsp, colormap) - Display *dsp; - Colormap colormap; -{ - int i, j; - unsigned long pix; - - for (i=0; i<256; i++) - { - if (allocation_index[i]) - { - pix = (unsigned long)i; - /* - * Because X is stupid, we have to Free the color - * once for each time we've allocated it. - */ - for (j=0; jhtml.formatted_elements; - while (eptr != NULL) - { - if ((eptr->type == E_IMAGE)&&(eptr->pic_data != NULL)) - { - /* - * Don't free the no_image default image - */ - if ((eptr->pic_data->image != (Pixmap)NULL)&& - (eptr->pic_data->image != delayed_image.image)&& - (eptr->pic_data->image != anchored_image.image)&& - (eptr->pic_data->image != no_image.image)) - { - /* - * Don't free internal images - */ - if ((eptr->edata != NULL)&& - (strncmp(eptr->edata, INTERNAL_IMAGE, - strlen(INTERNAL_IMAGE)) == 0)) - { - } - else - { - XFreePixmap(XtDisplay(hw), - eptr->pic_data->image); - eptr->pic_data->image = (Pixmap)NULL; - } - } - } - eptr = eptr->next; - } -} - - -/* - * Find the closest color by allocating it, or picking an already allocated - * color - */ -void -FindColor(dsp, colormap, colr) - Display *dsp; - Colormap colormap; - XColor *colr; -{ - int i, match; -#ifdef MORE_ACCURATE - double rd, gd, bd, dist, mindist; -#else - int rd, gd, bd, dist, mindist; -#endif /* MORE_ACCURATE */ - int cindx; -static XColor def_colrs[256]; -static int have_colors = 0; - int NumCells; - - match = XAllocColor(dsp, colormap, colr); - if (match == 0) - { - NumCells = DisplayCells(dsp, DefaultScreen(dsp)); - if (!have_colors) - { - for (i=0; ipixel; - for (i=0; ired) / 256.0; - gd = (def_colrs[i].green - colr->green) / 256.0; - bd = (def_colrs[i].blue - colr->blue) / 256.0; - dist = (rd * rd) + - (gd * gd) + - (bd * bd); - if (dist < mindist) - { - mindist = dist; - cindx = def_colrs[i].pixel; - if (dist == 0.0) - { - break; - } - } - } -#else - mindist = 196608; /* 256 * 256 * 3 */ - cindx = colr->pixel; - for (i=0; i> 8) - - (int)(colr->red >> 8)); - gd = ((int)(def_colrs[i].green >> 8) - - (int)(colr->green >> 8)); - bd = ((int)(def_colrs[i].blue >> 8) - - (int)(colr->blue >> 8)); - dist = (rd * rd) + - (gd * gd) + - (bd * bd); - if (dist < mindist) - { - mindist = dist; - cindx = def_colrs[i].pixel; - if (dist == 0) - { - break; - } - } - } -#endif /* MORE_ACCURATE */ - colr->pixel = cindx; - colr->red = def_colrs[cindx].red; - colr->green = def_colrs[cindx].green; - colr->blue = def_colrs[cindx].blue; - } - else - { - /* - * Keep a count of how many times we have allocated the - * same color, so we can properly free them later. - */ - allocation_index[colr->pixel]++; - - /* - * If this is a new color, we've actually changed the default - * colormap, and may have to re-query it later. - */ - if (allocation_index[colr->pixel] == 1) - { - have_colors = 0; - } - } -} - - -static int -highbit(ul) -unsigned long ul; -{ - /* - * returns position of highest set bit in 'ul' as an integer (0-31), - * or -1 if none. - */ - - int i; - for (i=31; ((ul&0x80000000) == 0) && i>=0; i--, ul<<=1); - return i; -} - - -/* - * Make am image of appropriate depth for display from image data. - */ -XImage * -MakeImage(dsp, data, width, height, depth, img_info) - Display *dsp; - unsigned char *data; - int width, height; - int depth; - ImageInfo *img_info; -{ - int linepad, shiftnum; - int shiftstart, shiftstop, shiftinc; - int bytesperline; - int temp; - int w, h; - XImage *newimage; - unsigned char *bit_data, *bitp, *datap; - Visual *theVisual; - int bmap_order; - unsigned long c; - int rshift, gshift, bshift; - - switch(depth) - { - case 6: - case 8: - bit_data = (unsigned char *)malloc(width * height); - bcopy(data, bit_data, (width * height)); - bytesperline = width; - newimage = XCreateImage(dsp, - DefaultVisual(dsp, DefaultScreen(dsp)), - depth, ZPixmap, 0, (char *)bit_data, - width, height, 8, bytesperline); - break; - case 1: - case 2: - case 4: - if (BitmapBitOrder(dsp) == LSBFirst) - { - shiftstart = 0; - shiftstop = 8; - shiftinc = depth; - } - else - { - shiftstart = 8 - depth; - shiftstop = -depth; - shiftinc = -depth; - } - linepad = 8 - (width % 8); - bit_data = (unsigned char *)malloc(((width + linepad) * height) - + 1); - bitp = bit_data; - datap = data; - *bitp = 0; - shiftnum = shiftstart; - for (h=0; h 0; w--) - { - temp = (((img_info->reds[(int)*datap] >> 1)& 0x7c00) | - ((img_info->greens[(int)*datap] >> 6)& 0x03e0) | - ((img_info->blues[(int)*datap] >> 11)& 0x001f)); - - if (BitmapBitOrder(dsp) == MSBFirst) - { - *bitp++ = (temp >> 8) & 0xff; - *bitp++ = temp & 0xff; - } - else - { - *bitp++ = temp & 0xff; - *bitp++ = (temp >> 8) & 0xff; - } - - datap++; - } - - newimage = XCreateImage(dsp, - DefaultVisual(dsp, DefaultScreen(dsp)), - depth, ZPixmap, 0, (char *)bit_data, - width, height, 16, 0); - break; - case 24: - bit_data = (unsigned char *)malloc(width * height * 4); - - theVisual = DefaultVisual(dsp, DefaultScreen(dsp)); - rshift = highbit(theVisual->red_mask) - 7; - gshift = highbit(theVisual->green_mask) - 7; - bshift = highbit(theVisual->blue_mask) - 7; - bmap_order = BitmapBitOrder(dsp); - - bitp = bit_data; - datap = data; - for (w = (width * height); w > 0; w--) - { - c = - (((img_info->reds[(int)*datap] >> 8) & 0xff) << rshift) | - (((img_info->greens[(int)*datap] >> 8) & 0xff) << gshift) | - (((img_info->blues[(int)*datap] >> 8) & 0xff) << bshift); - - datap++; - - if (bmap_order == MSBFirst) - { - *bitp++ = (unsigned char)((c >> 24) & 0xff); - *bitp++ = (unsigned char)((c >> 16) & 0xff); - *bitp++ = (unsigned char)((c >> 8) & 0xff); - *bitp++ = (unsigned char)(c & 0xff); - } - else - { - *bitp++ = (unsigned char)(c & 0xff); - *bitp++ = (unsigned char)((c >> 8) & 0xff); - *bitp++ = (unsigned char)((c >> 16) & 0xff); - *bitp++ = (unsigned char)((c >> 24) & 0xff); - } - } - - newimage = XCreateImage(dsp, - DefaultVisual(dsp, DefaultScreen(dsp)), - depth, ZPixmap, 0, (char *)bit_data, - width, height, 32, 0); - break; - default: - fprintf(stderr, "Don't know how to format image for display of depth %d\n", depth); - return(NULL); - } - - return(newimage); -} - - -int -AnchoredHeight(hw) - HTMLWidget hw; -{ - return((int)(AnchoredImage_height + IMAGE_BORDER)); -} - - -char * -IsMapForm(hw) - HTMLWidget hw; -{ - char *str; - - str = (char *)malloc(strlen("ISMAP Form") + 1); - if (str != NULL) - { - strcpy(str, "ISMAP Form"); - } - return(str); -} - - -int -IsIsMapForm(hw, href) - HTMLWidget hw; - char *href; -{ - if ((href != NULL)&&(strcmp(href, "ISMAP Form") == 0)) - { - return(1); - } - else - { - return(0); - } -} - - -char * -DelayedHRef(hw) - HTMLWidget hw; -{ - char *str; - - str = (char *)malloc(strlen("Delayed Image") + 1); - if (str != NULL) - { - strcpy(str, "Delayed Image"); - } - return(str); -} - - -int -IsDelayedHRef(hw, href) - HTMLWidget hw; - char *href; -{ - if ((href != NULL)&&(strcmp(href, "Delayed Image") == 0)) - { - return(1); - } - else - { - return(0); - } -} - - -Pixmap -DelayedImage(hw, anchored) - HTMLWidget hw; - Boolean anchored; -{ - if (delayed_image.image == (Pixmap)NULL) - { - delayed_image.image = XCreatePixmapFromBitmapData( - XtDisplay(hw->html.view), - XtWindow(hw->html.view), DelayedImage_bits, - DelayedImage_width, DelayedImage_height, -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ -#ifdef MOTIF - hw->manager.foreground, -#else - hw->html.foreground, -#endif /* MOTIF */ - hw->core.background_pixel, - DefaultDepthOfScreen(XtScreen(hw))); - } - - if ((anchored == True)&&(anchored_image.image == (Pixmap)NULL)) - { - Pixmap pix; - - anchored_image.image = XCreatePixmapFromBitmapData( - XtDisplay(hw->html.view), - XtWindow(hw->html.view), AnchoredImage_bits, - AnchoredImage_width, AnchoredImage_height, -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ -#ifdef MOTIF - hw->manager.foreground, -#else - hw->html.foreground, -#endif /* MOTIF */ - hw->core.background_pixel, - DefaultDepthOfScreen(XtScreen(hw))); - pix = XCreatePixmap( - XtDisplay(hw->html.view), - XtWindow(hw->html.view), - DelayedImage_width, - (DelayedImage_height + AnchoredImage_height + - IMAGE_BORDER), - DefaultDepthOfScreen(XtScreen(hw))); - XSetForeground(XtDisplay(hw), hw->html.drawGC, - hw->core.background_pixel); - XFillRectangle(XtDisplay(hw->html.view), pix, - hw->html.drawGC, 0, 0, - DelayedImage_width, - (DelayedImage_height + AnchoredImage_height + - IMAGE_BORDER)); - XCopyArea(XtDisplay(hw->html.view), - anchored_image.image, pix, hw->html.drawGC, - 0, 0, AnchoredImage_width, AnchoredImage_height, - 0, 0); - XCopyArea(XtDisplay(hw->html.view), - delayed_image.image, pix, hw->html.drawGC, - 0, 0, DelayedImage_width, DelayedImage_height, - 0, (AnchoredImage_height + IMAGE_BORDER)); - XFreePixmap(XtDisplay(hw->html.view), anchored_image.image); - anchored_image.image = pix; - - return(anchored_image.image); - } - - return(delayed_image.image); -} - - -ImageInfo * -DelayedImageData(hw, anchored) - HTMLWidget hw; - Boolean anchored; -{ - delayed_image.delayed = 1; - delayed_image.internal = 0; - delayed_image.fetched = 0; - delayed_image.width = DelayedImage_width; - delayed_image.height = DelayedImage_height; - delayed_image.num_colors = 0; - delayed_image.reds = NULL; - delayed_image.greens = NULL; - delayed_image.blues = NULL; - delayed_image.image_data = NULL; - delayed_image.image = (Pixmap)NULL; - - if (anchored == True) - { - anchored_image.delayed = 0; - anchored_image.internal = 0; - anchored_image.fetched = 0; - anchored_image.width = DelayedImage_width; - anchored_image.height = DelayedImage_height + - AnchoredImage_height + IMAGE_BORDER; - anchored_image.num_colors = 0; - anchored_image.reds = NULL; - anchored_image.greens = NULL; - anchored_image.blues = NULL; - anchored_image.image_data = NULL; - anchored_image.image = (Pixmap)NULL; - - return(&anchored_image); - } - - return(&delayed_image); -} - - -Pixmap -NoImage(hw) - HTMLWidget hw; -{ - if (no_image.image == (Pixmap)NULL) - { - no_image.image = XCreatePixmapFromBitmapData( - XtDisplay(hw->html.view), - XtWindow(hw->html.view), NoImage_bits, - NoImage_width, NoImage_height, -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ -#ifdef MOTIF - hw->manager.foreground, -#else - hw->html.foreground, -#endif /* MOTIF */ - hw->core.background_pixel, - DefaultDepthOfScreen(XtScreen(hw))); - } - return(no_image.image); -} - - -ImageInfo * -NoImageData(hw) - HTMLWidget hw; -{ - no_image.delayed = 0; - no_image.internal = 0; - no_image.fetched = 0; - no_image.width = NoImage_width; - no_image.height = NoImage_height; - no_image.num_colors = 0; - no_image.reds = NULL; - no_image.greens = NULL; - no_image.blues = NULL; - no_image.image_data = NULL; - no_image.image = (Pixmap)NULL; - - return(&no_image); -} - - -Pixmap -InfoToImage(hw, img_info) - HTMLWidget hw; - ImageInfo *img_info; -{ - int i, size; - int delta, not_right_col, not_last_row; - Pixmap Img; - XImage *tmpimage; - XColor tmpcolr; - int *Mapping; - unsigned char *tmpdata; - unsigned char *ptr; - unsigned char *ptr2; - int Vclass; - XVisualInfo vinfo, *vptr; - Boolean need_to_dither; - unsigned long black_pixel; - unsigned long white_pixel; - - /* find the visual class. */ - vinfo.visualid = XVisualIDFromVisual(DefaultVisual(XtDisplay(hw), - DefaultScreen(XtDisplay(hw)))); - vptr = XGetVisualInfo(XtDisplay(hw), VisualIDMask, &vinfo, &i); - Vclass = vptr->class; - if (vptr->depth == 1) - { - need_to_dither = True; - black_pixel = BlackPixel(XtDisplay(hw), - DefaultScreen(XtDisplay(hw))); - white_pixel = WhitePixel(XtDisplay(hw), - DefaultScreen(XtDisplay(hw))); - } - else - { - need_to_dither = False; - } - XFree((char *)vptr); - - Mapping = (int *)malloc(img_info->num_colors * sizeof(int)); - - for (i=0; i < img_info->num_colors; i++) - { - tmpcolr.red = img_info->reds[i]; - tmpcolr.green = img_info->greens[i]; - tmpcolr.blue = img_info->blues[i]; - tmpcolr.flags = DoRed|DoGreen|DoBlue; - if ((Vclass == TrueColor) || (Vclass == DirectColor)) - { - Mapping[i] = i; - } - else if (need_to_dither == True) - { - Mapping[i] = ((tmpcolr.red>>5)*11 + - (tmpcolr.green>>5)*16 + - (tmpcolr.blue>>5)*5) / (65504/64); - } - else - { - FindColor(XtDisplay(hw), - DefaultColormapOfScreen(XtScreen(hw)), - &tmpcolr); - Mapping[i] = tmpcolr.pixel; - } - } - - /* - * Special case: For 2 color non-black&white images, instead - * of 2 dither patterns, we will always drop them to be - * black on white. - */ - if ((need_to_dither == True)&&(img_info->num_colors == 2)) - { - if (Mapping[0] < Mapping[1]) - { - Mapping[0] = 0; - Mapping[1] = 64; - } - else - { - Mapping[0] = 64; - Mapping[1] = 0; - } - } - - size = img_info->width * img_info->height; - if (size == 0) - { - tmpdata = NULL; - } - else - { - tmpdata = (unsigned char *)malloc(size); - } - if (tmpdata == NULL) - { - tmpimage = NULL; - Img = (Pixmap)NULL; - } - else - { - ptr = img_info->image_data; - ptr2 = tmpdata; - - if (need_to_dither == True) - { - int cx, cy; - - for (ptr2 = tmpdata, ptr = img_info->image_data; - ptr2 < tmpdata+(size-1); ptr2++, ptr++) - { - *ptr2 = Mapping[(int)*ptr]; - } - - ptr2 = tmpdata; - for (cy=0; cy < img_info->height; cy++) - { - for (cx=0; cx < img_info->width; cx++) - { - /* - * Assume high numbers are - * really negative. - */ - if (*ptr2 > 128) - { - *ptr2 = 0; - } - if (*ptr2 > 64) - { - *ptr2 = 64; - } - - /* - * Traditional Floyd-Steinberg - */ - if (*ptr2 < 32) - { - delta = *ptr2; - *ptr2 = black_pixel; - } - else - { - delta = *ptr2 - 64; - *ptr2 = white_pixel; - } - if (not_right_col = - (cx < (img_info->width-1))) - { - *(ptr2+1) += delta*7 >> 4; - } - - if (not_last_row = - (cy < (img_info->height-1))) - { - (*(ptr2+img_info->width)) += - delta*5 >> 4; - } - - if (not_right_col && not_last_row) - { - (*(ptr2+img_info->width+1)) += - delta >> 4; - } - - if (cx && not_last_row) - { - (*(ptr2+img_info->width-1)) += - delta*3 >> 4; - } - ptr2++; - } - } - } /* end if (need_to_dither==True) */ - else - { - - for (i=0; i < size; i++) - { - *ptr2++ = (unsigned char)Mapping[(int)*ptr]; - ptr++; - } - } - - tmpimage = MakeImage(XtDisplay(hw), tmpdata, - img_info->width, img_info->height, - DefaultDepthOfScreen(XtScreen(hw)), img_info); - - /* Caught by Purify; should be OK. */ - free (tmpdata); - - Img = XCreatePixmap(XtDisplay(hw->html.view), - XtWindow(hw->html.view), - img_info->width, img_info->height, - DefaultDepthOfScreen(XtScreen(hw))); - } - - if ((tmpimage == NULL)||(Img == (Pixmap)NULL)) - { - if (tmpimage != NULL) - { - XDestroyImage(tmpimage); - } - if (Img != (Pixmap)NULL) - { - XFreePixmap(XtDisplay(hw), Img); - } - img_info->width = NoImage_width; - img_info->height = NoImage_height; - Img = NoImage(hw); - } - else - { - XPutImage(XtDisplay(hw), Img, hw->html.drawGC, tmpimage, 0, 0, - 0, 0, img_info->width, img_info->height); - XDestroyImage(tmpimage); - } - - /* Caught by Purify; should be OK. */ - free((char *)Mapping); - - return(Img); -} - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLjot.c xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLjot.c --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLjot.c Sun Jun 1 17:22:04 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLjot.c Thu Jan 1 00:00:00 1970 @@ -1,648 +0,0 @@ -/**************************************************************************** - * NCSA Mosaic for the X Window System * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * mosaic@ncsa.uiuc.edu * - * * - * Copyright (C) 1993, Board of Trustees of the University of Illinois * - * * - * NCSA Mosaic software, both binary and source (hereafter, Software) is * - * copyrighted by The Board of Trustees of the University of Illinois * - * (UI), and ownership remains with the UI. * - * * - * The UI grants you (hereafter, Licensee) a license to use the Software * - * for academic, research and internal business purposes only, without a * - * fee. Licensee may distribute the binary and source code (if released) * - * to third parties provided that the copyright notice and this statement * - * appears on all copies and that no charge is associated with such * - * copies. * - * * - * Licensee may make derivative works. However, if Licensee distributes * - * any derivative work based on or derived from the Software, then * - * Licensee will (1) notify NCSA regarding its distribution of the * - * derivative work, and (2) clearly notify users that such derivative * - * work is a modified version and not the original NCSA Mosaic * - * distributed by the UI. * - * * - * Any Licensee wishing to make commercial use of the Software should * - * contact the UI, c/o NCSA, to negotiate an appropriate license for such * - * commercial use. Commercial use includes (1) integration of all or * - * part of the source code into a product for sale or license by or on * - * behalf of Licensee to third parties, or (2) distribution of the binary * - * code or source code to third parties that need it to utilize a * - * commercial product sold or licensed by or on behalf of Licensee. * - * * - * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR * - * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED * - * WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE * - * USERS OF THIS SOFTWARE. * - * * - * By using or copying this Software, Licensee agrees to abide by the * - * copyright law and all other applicable laws of the U.S. including, but * - * not limited to, export control laws, and the terms of this license. * - * UI shall have the right to terminate this license immediately by * - * written notice upon Licensee's breach of, or non-compliance with, any * - * of its terms. Licensee may be held legally responsible for any * - * copyright infringement that is caused or encouraged by Licensee's * - * failure to abide by the terms of this license. * - * * - * Comments and questions are welcome and can be sent to * - * mosaic-x@ncsa.uiuc.edu. * - ****************************************************************************/ -#if 0 -#ifndef MOTIF -#define MOTIF -#endif -#endif - -#ifdef MOTIF - -#include -#include "inkstore.h" -#include "HTMLP.h" - -#include -#include - -typedef struct stroke_rec { - Boolean draw; - int x, y; - struct stroke_rec *next; -} Stroke; - -typedef struct jot_rec { - Widget w; - int width, height; - Pixmap pix; - Boolean drawing; - int last_x, last_y; - int min_x, min_y; - int max_x, max_y; - int stroke_cnt; - Stroke *strokes; - Stroke *last_stroke; - struct jot_rec *next; -} JotInfo; - - -static JotInfo *JotList = NULL; -static JotInfo *JotCurrent = NULL; - - - -void -NewJot(w, width, height) - Widget w; - int width, height; -{ - if (JotCurrent == NULL) - { - JotList = (JotInfo *)malloc(sizeof(JotInfo)); - JotCurrent = JotList; - JotCurrent->w = w; - JotCurrent->width = width; - JotCurrent->height = height; - JotCurrent->pix = NULL; - JotCurrent->drawing = False; - JotCurrent->strokes = NULL; - JotCurrent->last_stroke = NULL; - JotCurrent->stroke_cnt = 0; - JotCurrent->min_x = width; - JotCurrent->max_x = 0; - JotCurrent->min_y = height; - JotCurrent->max_y = 0; - JotCurrent->next = NULL; - } - else - { - JotCurrent->next = (JotInfo *)malloc(sizeof(JotInfo)); - JotCurrent = JotCurrent->next; - JotCurrent->w = w; - JotCurrent->width = width; - JotCurrent->height = height; - JotCurrent->pix = NULL; - JotCurrent->drawing = False; - JotCurrent->strokes = NULL; - JotCurrent->last_stroke = NULL; - JotCurrent->stroke_cnt = 0; - JotCurrent->min_x = width; - JotCurrent->max_x = 0; - JotCurrent->min_y = height; - JotCurrent->max_y = 0; - JotCurrent->next = NULL; - } -} - - -JotInfo * -GetJot(w) - Widget w; -{ - JotInfo *jptr; - - jptr = JotList; - while (jptr != NULL) - { - if (jptr->w == w) - { - break; - } - jptr = jptr->next; - } - return(jptr); -} - - -void -FreeStrokes(sptr) - Stroke *sptr; -{ - Stroke *tptr; - - while (sptr != NULL) - { - tptr = sptr; - sptr = sptr->next; - tptr->next = NULL; - free((char *)tptr); - } -} - - -void -ClearJot(hw, w, width, height) - HTMLWidget hw; - Widget w; - int width, height; -{ - JotInfo *jptr; - - XClearArea(XtDisplay(w), XtWindow(w), - 0, 0, width, height, False); - - jptr = GetJot(w); - if (jptr == NULL) - { - return; - } - - if (jptr->pix != NULL) - { - XSetForeground(XtDisplay(w), hw->html.drawGC, - hw->core.background_pixel); - XFillRectangle(XtDisplay(w), jptr->pix, - hw->html.drawGC, - 0, 0, jptr->width, jptr->height); - } - - FreeStrokes(jptr->strokes); - jptr->strokes = NULL; - jptr->last_stroke = NULL; - jptr->stroke_cnt = 0; - jptr->drawing = False; - jptr->min_x = width; - jptr->max_x = 0; - jptr->min_y = height; - jptr->max_y = 0; -} - - -void -AddStroke(jptr, sptr, drawing) - JotInfo *jptr; - Stroke *sptr; - Boolean drawing; -{ - if (jptr->strokes == NULL) - { - jptr->strokes = sptr; - jptr->last_stroke = jptr->strokes; - jptr->last_stroke->next = NULL; - } - else - { - jptr->last_stroke->next = sptr; - jptr->last_stroke = jptr->last_stroke->next; - jptr->last_stroke->next = NULL; - } - jptr->last_x = sptr->x; - jptr->last_y = sptr->y; - jptr->drawing = drawing; - if (sptr->x < jptr->min_x) - { - jptr->min_x = sptr->x; - } - if (sptr->x > jptr->max_x) - { - jptr->max_x = sptr->x; - } - if (sptr->y < jptr->min_y) - { - jptr->min_y = sptr->y; - } - if (sptr->y > jptr->max_y) - { - jptr->max_y = sptr->y; - } - jptr->stroke_cnt++; -} - - -void -EVJotExpose(w, data, event) - Widget w; - XtPointer data; - XEvent *event; -{ - XExposeEvent *ExEvent = (XExposeEvent *)event; - HTMLWidget hw = (HTMLWidget)data; - JotInfo *jptr; - - jptr = GetJot(w); - if (jptr == NULL) - { - return; - } - - if (jptr->pix == NULL) - { - jptr->pix = XCreatePixmap(XtDisplay(w), XtWindow(w), - jptr->width, jptr->height, - XDefaultDepth(XtDisplay(w), XDefaultScreen(XtDisplay(w)))); - if (jptr->pix == NULL) - { - return; - } - XSetForeground(XtDisplay(w), hw->html.drawGC, - hw->core.background_pixel); - XFillRectangle(XtDisplay(w), jptr->pix, - hw->html.drawGC, - 0, 0, jptr->width, jptr->height); - } - - XCopyArea(XtDisplay(w), jptr->pix, XtWindow(w), - hw->html.drawGC, - ExEvent->x, ExEvent->y, - ExEvent->width, ExEvent->height, - ExEvent->x, ExEvent->y); -} - - -void -EVJotPress(w, data, event) - Widget w; - XtPointer data; - XEvent *event; -{ - XButtonPressedEvent *BuEvent = (XButtonPressedEvent *)event; - HTMLWidget hw = (HTMLWidget)data; - JotInfo *jptr; - Stroke *sptr; - - jptr = GetJot(w); - if (jptr == NULL) - { - return; - } - - sptr = (Stroke *)malloc(sizeof(Stroke)); - if (sptr == NULL) - { - return; - } - sptr->x = BuEvent->x; - sptr->y = BuEvent->y; - sptr->draw = False; - sptr->next = NULL; - -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ - XSetForeground(XtDisplay(w), hw->html.drawGC, -#ifdef MOTIF - hw->manager.foreground); -#else - hw->html.foreground); -#endif /* MOTIF */ - XDrawPoint(XtDisplay(w), XtWindow(w), - hw->html.drawGC, sptr->x, sptr->y); - if (jptr->pix != NULL) - { - XDrawPoint(XtDisplay(w), jptr->pix, - hw->html.drawGC, sptr->x, sptr->y); - } - - AddStroke(jptr, sptr, True); -} - - -void -EVJotMove(w, data, event) - Widget w; - XtPointer data; - XEvent *event; -{ - XPointerMovedEvent *MoEvent = (XPointerMovedEvent *)event; - HTMLWidget hw = (HTMLWidget)data; - JotInfo *jptr; - Stroke *sptr; - - jptr = GetJot(w); - if (jptr == NULL) - { - return; - } - - if (jptr->drawing == False) - { - return; - } - - sptr = (Stroke *)malloc(sizeof(Stroke)); - if (sptr == NULL) - { - return; - } - sptr->x = MoEvent->x; - sptr->y = MoEvent->y; - sptr->draw = True; - sptr->next = NULL; - -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ - XSetForeground(XtDisplay(w), hw->html.drawGC, -#ifdef MOTIF - hw->manager.foreground); -#else - hw->html.foreground); -#endif /* MOTIF */ - XDrawLine(XtDisplay(w), XtWindow(w), hw->html.drawGC, - jptr->last_x, jptr->last_y, sptr->x, sptr->y); - if (jptr->pix != NULL) - { - XDrawLine(XtDisplay(w), jptr->pix, hw->html.drawGC, - jptr->last_x, jptr->last_y, sptr->x, sptr->y); - } - - AddStroke(jptr, sptr, True); -} - - -void -EVJotRelease(w, data, event) - Widget w; - XtPointer data; - XEvent *event; -{ - XButtonReleasedEvent *BuEvent = (XButtonReleasedEvent *)event; - HTMLWidget hw = (HTMLWidget)data; - JotInfo *jptr; - Stroke *sptr; - - jptr = GetJot(w); - if (jptr == NULL) - { - return; - } - - if (jptr->drawing == False) - { - return; - } - - sptr = (Stroke *)malloc(sizeof(Stroke)); - if (sptr == NULL) - { - return; - } - sptr->x = BuEvent->x; - sptr->y = BuEvent->y; - sptr->draw = True; - sptr->next = NULL; - -/* - * Without motif we use our own foreground resource instead of - * using the manager's - */ - XSetForeground(XtDisplay(w), hw->html.drawGC, -#ifdef MOTIF - hw->manager.foreground); -#else - hw->html.foreground); -#endif /* MOTIF */ - XDrawLine(XtDisplay(w), XtWindow(w), hw->html.drawGC, - jptr->last_x, jptr->last_y, sptr->x, sptr->y); - if (jptr->pix != NULL) - { - XDrawLine(XtDisplay(w), jptr->pix, hw->html.drawGC, - jptr->last_x, jptr->last_y, sptr->x, sptr->y); - } - - AddStroke(jptr, sptr, True); -} - - -char * -EJB_JOTfromJot(w) - Widget w; -{ - int i, cnt; - int dlen, total; - u_long val; - unsigned char uchar; - JotInfo *jptr; - Stroke *sptr; - unsigned char *data; - unsigned char *dptr; - unsigned char *buffer; - unsigned char *bptr; - - jptr = GetJot(w); - if (jptr == NULL) - { - return(NULL); - } - - dlen = (2 * sizeof(u_long) + sizeof(char)) * jptr->stroke_cnt; - data = (unsigned char *)malloc(dlen); - - cnt = 0; - sptr = jptr->strokes; - dptr = data; - while ((sptr != NULL)&&(cnt < jptr->stroke_cnt)) - { - val = htonl((u_long)sptr->x); - bcopy((char *)&val, (char *)dptr, sizeof(u_long)); - dptr = dptr + sizeof(u_long); - - val = htonl((u_long)sptr->y); - bcopy((char *)&val, (char *)dptr, sizeof(u_long)); - dptr = dptr + sizeof(u_long); - - if (sptr->draw == False) - { - uchar = 0; - } - else - { - uchar = 1; - } - *dptr++ = uchar; - - cnt++; - sptr = sptr->next; - } - for (i=cnt; istroke_cnt; i++) - { - val = 0; - bcopy((char *)&val, (char *)dptr, sizeof(u_long)); - dptr = dptr + sizeof(u_long); - val = 0; - bcopy((char *)&val, (char *)dptr, sizeof(u_long)); - dptr = dptr + sizeof(u_long); - uchar = 0; - *dptr++ = uchar; - } -fprintf(stderr, "Packaging up %d points\n", jptr->stroke_cnt); - - cnt = 0; - dptr = data; - for (i=0; istroke_cnt; - - dataArray = (MY_INK_POINT *)malloc(dlen); - cnt = 0; - sptr = jptr->strokes; - while ((sptr != NULL)&&(cnt < jptr->stroke_cnt)); - { - dataArray[cnt].position.x = sptr->x; - dataArray[cnt].position.y = sptr->y; - dataArray[cnt].buttons = inkPointDefaultButtons; - dataArray[cnt].buttons |= flag0; - if ((sptr->next != NULL)&&(sptr->next->draw == False)) - { - } - else - { - dataArray[cnt].buttons |= flag1; - } - cnt++; - sptr = sptr->next; - } - for (i=cnt; istroke_cnt; i++) - { - dataArray[i].position.x = 0; - dataArray[i].position.y = 0; - dataArray[i].buttons = inkPointDefaultButtons; - } - - iptr = (INK_BUNDLE_RECORD *)malloc(inkRecordBundleSize); - iptr->header.recordType = inkRecordBundle; - iptr->header.recordLength = inkRecordBundleSize; - iptr->version = inkPointDefaultVersion; - iptr->compactionType = inkNoCompression; - iptr->flags = (inkPointDefaultBundleFlags | inkButtonDataPresent); - iptr->penUnitsPerX = inkPointDefaultPenUnitsPerX; - iptr->penUnitsPerY = inkPointDefaultPenUnitsPerY; - - pptr = (INK_PENDATA_RECORD *)malloc(inkRecordPenDataSize(dlen)); - pptr->header.recordType = inkRecordPenData; - pptr->header.recordLength = inkRecordPenDataSize(dlen); - pptr->bounds.origin.x = jptr->min_x; - pptr->bounds.origin.y = jptr->min_y; - pptr->bounds.size.w = jptr->max_x - jptr->min_x + 1; - pptr->bounds.size.h = jptr->max_y - jptr->min_y + 1; - bcopy((char *)dataArray, (char *)pptr->inkData, dlen); - free((char *)dataArray); -/* - pptr->inkData = dataArray; -*/ - - eptr = (INK_END_RECORD *)malloc(inkRecordEndSize); - eptr->header.recordType = inkRecordEnd; - - total = inkRecordBundleSize + inkRecordPenDataSize(dlen) + - inkRecordEndSize; - buffer = (unsigned char *)malloc(total); - bcopy((char *)iptr, buffer, inkRecordBundleSize); - bcopy((char *)pptr, (char *)(buffer + inkRecordBundleSize), - inkRecordPenDataSize(dlen)); - bcopy((char *)eptr, (char *)(buffer + inkRecordBundleSize + - inkRecordPenDataSize(dlen)), inkRecordEndSize); - free((char *)iptr); - free((char *)pptr); - free((char *)eptr); - *buffer_len = total; - return(buffer); -} -#endif /* MOTIF */ diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLlists.c xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLlists.c --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLlists.c Sun Jun 1 17:22:04 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLlists.c Thu Jan 1 00:00:00 1970 @@ -1,897 +0,0 @@ -/**************************************************************************** - * NCSA Mosaic for the X Window System * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * mosaic@ncsa.uiuc.edu * - * * - * Copyright (C) 1993, Board of Trustees of the University of Illinois * - * * - * NCSA Mosaic software, both binary and source (hereafter, Software) is * - * copyrighted by The Board of Trustees of the University of Illinois * - * (UI), and ownership remains with the UI. * - * * - * The UI grants you (hereafter, Licensee) a license to use the Software * - * for academic, research and internal business purposes only, without a * - * fee. Licensee may distribute the binary and source code (if released) * - * to third parties provided that the copyright notice and this statement * - * appears on all copies and that no charge is associated with such * - * copies. * - * * - * Licensee may make derivative works. However, if Licensee distributes * - * any derivative work based on or derived from the Software, then * - * Licensee will (1) notify NCSA regarding its distribution of the * - * derivative work, and (2) clearly notify users that such derivative * - * work is a modified version and not the original NCSA Mosaic * - * distributed by the UI. * - * * - * Any Licensee wishing to make commercial use of the Software should * - * contact the UI, c/o NCSA, to negotiate an appropriate license for such * - * commercial use. Commercial use includes (1) integration of all or * - * part of the source code into a product for sale or license by or on * - * behalf of Licensee to third parties, or (2) distribution of the binary * - * code or source code to third parties that need it to utilize a * - * commercial product sold or licensed by or on behalf of Licensee. * - * * - * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR * - * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED * - * WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE * - * USERS OF THIS SOFTWARE. * - * * - * By using or copying this Software, Licensee agrees to abide by the * - * copyright law and all other applicable laws of the U.S. including, but * - * not limited to, export control laws, and the terms of this license. * - * UI shall have the right to terminate this license immediately by * - * written notice upon Licensee's breach of, or non-compliance with, any * - * of its terms. Licensee may be held legally responsible for any * - * copyright infringement that is caused or encouraged by Licensee's * - * failure to abide by the terms of this license. * - * * - * Comments and questions are welcome and can be sent to * - * mosaic-x@ncsa.uiuc.edu. * - ****************************************************************************/ - -#include -#include "HTML.h" - -/* - * Code to manage a linked list of parsed HTML objects generated - * from a raw text file. - * Also code to manage a linked list of formatted elements that - * make up a page of a formatted document. - */ - - -/* - * Free up the passed linked list of parsed elements, freeing - * all memory associates with each element. - */ -void -FreeObjList(List) - struct mark_up *List; -{ - struct mark_up *current; - struct mark_up *mptr; - - current = List; - while (current != NULL) - { - mptr = current; - current = current->next; - mptr->next = NULL; - if (mptr->start != NULL) - { - free((char *)mptr->start); - } - if (mptr->text != NULL) - { - free((char *)mptr->text); - } - if (mptr->end != NULL) - { - free((char *)mptr->end); - } - free((char *)mptr); - } -} - - -/* - * Add an object to the parsed object list. - * return a pointer to the current (end) position in the list. - * If the object is a normal text object containing nothing but - * white space, throw it out, unless we have been told to keep - * white space. - */ -struct mark_up * -AddObj(listp, current, mark, keep_wsp) - struct mark_up **listp; - struct mark_up *current; - struct mark_up *mark; - int keep_wsp; -{ - if (mark == NULL) - { - return(current); - } - - /* - * Throw out normal text blocks that are only white space, - * unless keep_wsp is set. - */ - if ((mark->type == M_NONE)&&(!keep_wsp)) - { - char *ptr; - - ptr = mark->text; - if (ptr == NULL) - { - free((char *)mark); - return(current); - } - -/* - * No longer throw out whitespace, it is important to keep - * white space between tags. - while ((*ptr == ' ')||(*ptr == '\t')||(*ptr == '\n')) - { - ptr++; - } - * - */ - - if (*ptr == '\0') - { - free(mark->text); - free((char *)mark); - return(current); - } - } - - /* - * Add object to either the head of the list for a new list, - * or at the end after the current pointer. - */ - if (*listp == NULL) - { - *listp = mark; - current = *listp; - } - else - { - current->next = mark; - current = current->next; - } - - current->next = NULL; - - return(current); -} - - -#ifdef DEBUG - -/* - * Convert type number to a printed string for debug - */ -void -PrintType(type) - int type; -{ - switch(type) - { - case M_NONE: - printf("M_NONE"); - break; - case M_TITLE: - printf("M_TITLE"); - break; - case M_FIXED: - printf("M_FIXED"); - break; - case M_BOLD: - printf("M_BOLD"); - break; - case M_ITALIC: - printf("M_ITALIC"); - break; - case M_EMPHASIZED: - printf("M_EMPHASIZED"); - break; - case M_STRONG: - printf("M_STRONG"); - break; - case M_CODE: - printf("M_CODE"); - break; - case M_SAMPLE: - printf("M_SAMPLE"); - break; - case M_KEYBOARD: - printf("M_KEYBOARD"); - break; - case M_VARIABLE: - printf("M_VARIABLE"); - break; - case M_CITATION: - printf("M_CITATION"); - break; - case M_STRIKEOUT: - printf("M_STRIKEOUT"); - break; - case M_HEADER_1: - printf("M_HEADER_1"); - break; - case M_HEADER_2: - printf("M_HEADER_2"); - break; - case M_HEADER_3: - printf("M_HEADER_3"); - break; - case M_HEADER_4: - printf("M_HEADER_4"); - break; - case M_HEADER_5: - printf("M_HEADER_5"); - break; - case M_HEADER_6: - printf("M_HEADER_6"); - break; - case M_ANCHOR: - printf("M_ANCHOR"); - break; - case M_PARAGRAPH: - printf("M_PARAGRAPH"); - break; - case M_ADDRESS: - printf("M_ADDRESS"); - break; - case M_PLAIN_TEXT: - printf("M_PLAIN_TEXT"); - break; - case M_LISTING_TEXT: - printf("M_LISTING_TEXT"); - break; - case M_UNUM_LIST: - printf("M_UNUM_LIST"); - break; - case M_NUM_LIST: - printf("M_NUM_LIST"); - break; - case M_MENU: - printf("M_MENU"); - break; - case M_DIRECTORY: - printf("M_DIRECTORY"); - break; - case M_LIST_ITEM: - printf("M_LIST_ITEM"); - break; - case M_DESC_LIST: - printf("M_DESC_LIST"); - break; - case M_DESC_TITLE: - printf("M_DESC_TITLE"); - break; - case M_DESC_TEXT: - printf("M_DESC_TEXT"); - break; - case M_IMAGE: - printf("M_IMAGE"); - break; - case M_SELECT: - printf("M_SELECT"); - break; - case M_OPTION: - printf("M_OPTION"); - break; - case M_INPUT: - printf("M_INPUT"); - break; - case M_TEXTAREA: - printf("M_TEXTAREA"); - break; - case M_FORM: - printf("M_FORM"); - break; - case M_INDEX: - printf("M_INDEX"); - break; - case M_HRULE: - printf("M_HRULE"); - break; - case M_BASE: - printf("M_BASE"); - break; - case M_LINEBREAK: - printf("M_LINEBREAK"); - break; - case M_BLOCKQUOTE: - printf("M_BLOCKQUOTE"); - break; - default: - printf("UNKNOWN %d", type); - break; - } -} - - -/* - * Print the contents of a parsed object list, for debug - */ -void -PrintList(list) - struct mark_up *list; -{ - struct mark_up *mptr; - - mptr = list; - while (mptr != NULL) - { - PrintType(mptr->type); - if (mptr->is_end) - { - printf(" END"); - } - else - { - printf(" START"); - } - if (mptr->text != NULL) - { - printf("\n{\n\t"); - printf("%s", mptr->text); - printf("}\n"); - } - else - { - printf("\n"); - } - mptr = mptr->next; - } -} - -#endif /* DEBUG */ - - -/* - * Used to find the longest line (in characters) in a collection - * of text blocks. cnt is the running count of characters, and - * txt is the pointer to the current text block. Since we are - * finding line widths, a newline resets the width count. - */ -char * -MaxTextWidth(txt, cnt) - char *txt; - int *cnt; -{ - char *start; - char *end; - int width; - - if (txt == NULL) - { - return(NULL); - } - - width = *cnt; - start = txt; - - /* - * If this blocks starts with a newline, reset the width - * count, and skip the newline. - */ - if (*start == '\n') - { - width = 0; - start++; - } - - end = start; - - /* - * count characters, stoping either at a newline, or at the - * end of this text block. Expand tabs. - */ - while ((*end != '\0')&&(*end != '\n')) - { - if (*end == '\t') - { - width = ((width / 8) + 1) * 8; - } - else - { - width++; - } - end++; - } - - *cnt = width; - return(end); -} - - -/* - * Free up the passed linked list of formatted elements, freeing - * all memory associates with each element. - */ -void -FreeLineList(list) - struct ele_rec *list; -{ - struct ele_rec *current; - struct ele_rec *eptr; - - current = list; - while (current != NULL) - { - eptr = current; - current = current->next; - eptr->next = NULL; - if (eptr->edata != NULL) - { - free((char *)eptr->edata); - } - if (eptr->anchorHRef != NULL) - { - free((char *)eptr->anchorHRef); - } - if (eptr->anchorName != NULL) - { - free((char *)eptr->anchorName); - } - free((char *)eptr); - } -} - - -/* - * Add an element to the linked list of formatted elements. - * return a pointer to the current (end) position in the list. - */ -struct ele_rec * -AddEle(elistp, current, eptr) - struct ele_rec **elistp; - struct ele_rec *current; - struct ele_rec *eptr; -{ - if (eptr == NULL) - { - return(current); - } - - /* - * Add object to either the head of the list for a new list, - * or at the end after the current pointer. - */ - if (*elistp == NULL) - { - *elistp = eptr; - (*elistp)->next = NULL; - (*elistp)->prev = NULL; - current = *elistp; - } - else - { - current->next = eptr; - eptr->prev = current; - current = current->next; - current->next = NULL; - } - return(current); -} - - -/* - * Contruct and return an array of pointers into the element list that - * indexes the elements by line number. - * Note, lines containing only while space will have NULL pointers - * into the element list. - */ -struct ele_rec ** -MakeLineList(elist, max_line) - struct ele_rec *elist; - int max_line; -{ - int i; - struct ele_rec *eptr; - struct ele_rec **ll; - - /* - * malloc index array - */ - ll = (struct ele_rec **)malloc(sizeof(struct ele_rec *) * max_line); - if (ll == NULL) - { - fprintf(stderr, "cannot allocate space for line list\n"); - exit(1); - } - - /* - * zero the index array - */ - for (i=0; iline_number > max_line) - { - break; - } - - if (ll[eptr->line_number - 1] == NULL) - { - ll[eptr->line_number - 1] = eptr; - } - - eptr = eptr->next; - } - return(ll); -} - - -/* - * Passed in 2 element pointers, and element positions. - * Function should return 1 if if start occurs before end. - * Otherwise return 0. - */ -int -ElementLessThan(start, end, start_pos, end_pos) - struct ele_rec *start; - struct ele_rec *end; - int start_pos, end_pos; -{ - struct ele_rec *current; - - /* - * Deal with start or end being NULL - */ - if ((start == NULL)&&(end == NULL)) - { - return(0); - } - else if ((start == NULL)&&(end != NULL)) - { - return(1); - } - else if ((start != NULL)&&(end == NULL)) - { - return(0); - } - - /* - * Deal with easy identical case - */ - if (start == end) - { - if (start_pos < end_pos) - { - return(1); - } - else - { - return(0); - } - } - - /* - * We know element Ids are always equal or increasing within a - * list. - */ - if (start->ele_id < end->ele_id) - { - return(1); - } - else if (start->ele_id == end->ele_id) - { - current = start; - while (current != NULL) - { - if (current->ele_id != start->ele_id) - { - break; - } - else if (current == end) - { - break; - } - current = current->next; - } - if (current == end) - { - return(1); - } - else - { - return(0); - } - } - else - { - return(0); - } -} - - -/* - * Passed in 2 element pointers, and element positions. - * Function should return 1 if they need to be swapped in order for then - * to proceed left to right and top to bottom in the text. - * Otherwise return 0. - */ -int -SwapElements(start, end, start_pos, end_pos) - struct ele_rec *start; - struct ele_rec *end; - int start_pos, end_pos; -{ - struct ele_rec *current; - - /* - * Deal with start or end being NULL - */ - if ((start == NULL)&&(end == NULL)) - { - return(0); - } - else if ((start == NULL)&&(end != NULL)) - { - return(1); - } - else if ((start != NULL)&&(end == NULL)) - { - return(0); - } - - /* - * Deal with easy identical case - */ - if (start == end) - { - if (start_pos > end_pos) - { - return(1); - } - else - { - return(0); - } - } - - /* - * We know element Ids are always equal or increasing within a - * list. - */ - if (start->ele_id < end->ele_id) - { - return(0); - } - else if (start->ele_id == end->ele_id) - { - current = start; - while (current != NULL) - { - if (current->ele_id != start->ele_id) - { - break; - } - else if (current == end) - { - break; - } - current = current->next; - } - if (current == end) - { - return(0); - } - else - { - return(1); - } - } - else - { - return(1); - } -} - - -/* - * Free up the allocated list of internal hrefs. - */ -void -FreeHRefs(list) - struct ref_rec *list; -{ - struct ref_rec *hptr; - struct ref_rec *tptr; - - hptr = list; - while (hptr != NULL) - { - tptr = hptr; - hptr = hptr->next; - if (tptr->anchorHRef != NULL) - { - free((char *)tptr->anchorHRef); - } - free((char *)tptr); - } -} - - -/* - * Find an element in the linked list of Internal HREFS. - * return a pointer to the element, or NULL if not found. - */ -struct ref_rec * -FindHRef(list, href) - struct ref_rec *list; - char *href; -{ - struct ref_rec *hptr; - - if (href == NULL) - { - return(NULL); - } - - hptr = list; - while (hptr != NULL) - { - if (strcmp(hptr->anchorHRef, href) == 0) - { - break; - } - hptr = hptr->next; - } - return(hptr); -} - - -/* - * Add an element to the linked list of Internal HREFS we - * have visited before. - * return a pointer to the head of the new list. - */ -struct ref_rec * -AddHRef(list, href) - struct ref_rec *list; - char *href; -{ - struct ref_rec *hptr; - - if (href == NULL) - { - return(list); - } - - hptr = FindHRef(list, href); - - if (hptr == NULL) - { - hptr = (struct ref_rec *)malloc(sizeof(struct ref_rec)); - if (hptr == NULL) - { - fprintf(stderr, "cannot extend internal href list\n"); - return(list); - } - hptr->anchorHRef = (char *)malloc(strlen(href) + 1); - if (hptr->anchorHRef == NULL) - { - free((char *)hptr); - fprintf(stderr, "cannot extend internal href list\n"); - return(list); - } - strcpy(hptr->anchorHRef, href); - hptr->next = list; - list = hptr; - } - - return(list); -} - - -/* - * Free up the allocated list of visited delayed images - */ -void -FreeDelayedImages(list) - struct delay_rec *list; -{ - struct delay_rec *iptr; - struct delay_rec *tptr; - - iptr = list; - while (iptr != NULL) - { - tptr = iptr; - iptr = iptr->next; - if (tptr->src != NULL) - { - free((char *)tptr->src); - } - free((char *)tptr); - } -} - - -/* - * Find an element in the linked list of visited delayed images. - * return a pointer to the element, or NULL if not found. - */ -struct delay_rec * -FindDelayedImage(list, src) - struct delay_rec *list; - char *src; -{ - struct delay_rec *iptr; - - if (src == NULL) - { - return(NULL); - } - - iptr = list; - while (iptr != NULL) - { - if (strcmp(iptr->src, src) == 0) - { - break; - } - iptr = iptr->next; - } - return(iptr); -} - - -/* - * Add an element to the linked list of visited delayed images. - * return a pointer to the head of the new list. - */ -struct delay_rec * -AddDelayedImage(list, src) - struct delay_rec *list; - char *src; -{ - struct delay_rec *iptr; - - if (src == NULL) - { - return(list); - } - - iptr = FindDelayedImage(list, src); - - if (iptr == NULL) - { - iptr = (struct delay_rec *)malloc(sizeof(struct delay_rec)); - if (iptr == NULL) - { - fprintf(stderr, "cannot extend visited delayed images list\n"); - return(list); - } - iptr->src = (char *)malloc(strlen(src) + 1); - if (iptr->src == NULL) - { - free((char *)iptr); - fprintf(stderr, "cannot extend visited delayed images list\n"); - return(list); - } - strcpy(iptr->src, src); - iptr->next = list; - list = iptr; - } - - return(list); -} - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLparse.c xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLparse.c --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/HTMLparse.c Sun Jun 1 17:22:04 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/HTMLparse.c Thu Jan 1 00:00:00 1970 @@ -1,1465 +0,0 @@ -/**************************************************************************** - * NCSA Mosaic for the X Window System * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * mosaic@ncsa.uiuc.edu * - * * - * Copyright (C) 1993, Board of Trustees of the University of Illinois * - * * - * NCSA Mosaic software, both binary and source (hereafter, Software) is * - * copyrighted by The Board of Trustees of the University of Illinois * - * (UI), and ownership remains with the UI. * - * * - * The UI grants you (hereafter, Licensee) a license to use the Software * - * for academic, research and internal business purposes only, without a * - * fee. Licensee may distribute the binary and source code (if released) * - * to third parties provided that the copyright notice and this statement * - * appears on all copies and that no charge is associated with such * - * copies. * - * * - * Licensee may make derivative works. However, if Licensee distributes * - * any derivative work based on or derived from the Software, then * - * Licensee will (1) notify NCSA regarding its distribution of the * - * derivative work, and (2) clearly notify users that such derivative * - * work is a modified version and not the original NCSA Mosaic * - * distributed by the UI. * - * * - * Any Licensee wishing to make commercial use of the Software should * - * contact the UI, c/o NCSA, to negotiate an appropriate license for such * - * commercial use. Commercial use includes (1) integration of all or * - * part of the source code into a product for sale or license by or on * - * behalf of Licensee to third parties, or (2) distribution of the binary * - * code or source code to third parties that need it to utilize a * - * commercial product sold or licensed by or on behalf of Licensee. * - * * - * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR * - * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED * - * WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE * - * USERS OF THIS SOFTWARE. * - * * - * By using or copying this Software, Licensee agrees to abide by the * - * copyright law and all other applicable laws of the U.S. including, but * - * not limited to, export control laws, and the terms of this license. * - * UI shall have the right to terminate this license immediately by * - * written notice upon Licensee's breach of, or non-compliance with, any * - * of its terms. Licensee may be held legally responsible for any * - * copyright infringement that is caused or encouraged by Licensee's * - * failure to abide by the terms of this license. * - * * - * Comments and questions are welcome and can be sent to * - * mosaic-x@ncsa.uiuc.edu. * - ****************************************************************************/ - -#ifdef TIMING -#include -struct timeval Tv; -struct timezone Tz; -#endif - -#include -#include -#ifndef sun -/* To get atoi. */ -#include -#endif -#include "HTML.h" -#include "HTMLamp.h" - - -extern void FreeObjList(); -extern struct mark_up *AddObj(); - - -#ifdef NOT_ASCII -#define TOLOWER(x) (tolower(x)) -#else - -/* - * A hack to speed up caseless_equal. Thanks to Quincey Koziol for - * developing it for me - */ -unsigned char map_table[256]={ - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23, - 24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44, - 45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,97,98, - 99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115, - 116,117,118,119,120,121,122,91,92,93,94,95,96,97,98,99,100,101,102, - 103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119, - 120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136, - 137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153, - 154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170, - 171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187, - 188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204, - 205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221, - 222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238, - 239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255}; - -#define TOLOWER(x) (map_table[x]) -#endif /* NOT_ASCII */ - - -/* - * Check if two strings are equal, ignoring case. - * The strings must be of the same length to be equal. - * return 1 if equal, 0 otherwise. - */ -int -caseless_equal(str1, str2) - char *str1; - char *str2; -{ - if ((str1 == NULL)||(str2 == NULL)) - { - return(0); - } - - while ((*str1 != '\0')&&(*str2 != '\0')) - { - if (TOLOWER(*str1) != TOLOWER(*str2)) - { - return(0); - } - str1++; - str2++; - } - - if ((*str1 == '\0')&&(*str2 == '\0')) - { - return(1); - } - else - { - return(0); - } -} - - -/* - * Check if two strings are equal in the first count characters, ignoring case. - * The strings must both be at least of length count to be equal. - * return 1 if equal, 0 otherwise. - */ -int -caseless_equal_prefix(str1, str2, cnt) - char *str1; - char *str2; - int cnt; -{ - int i; - - if ((str1 == NULL)||(str2 == NULL)) - { - return(0); - } - - if (cnt < 1) - { - return(1); - } - - for (i=0; i < cnt; i++) - { - if (TOLOWER(*str1) != TOLOWER(*str2)) - { - return(0); - } - str1++; - str2++; - } - - return(1); -} - - -/* - * Clean up the white space in a string. - * Remove all leading and trailing whitespace, and turn all - * internal whitespace into single spaces separating words. - * The cleaning is done by rearranging the chars in the passed - * txt buffer. The resultant string will probably be shorter, - * it can never get longer. - */ -void -clean_white_space(txt) - char *txt; -{ - char *ptr; - char *start; - - start = txt; - ptr = txt; - - /* - * Remove leading white space - */ - while (isspace((int)*ptr)) - { - ptr++; - } - - /* - * find a word, copying if we removed some space already - */ - if (start == ptr) - { - while ((!isspace((int)*ptr))&&(*ptr != '\0')) - { - ptr++; - } - start = ptr; - } - else - { - while ((!isspace((int)*ptr))&&(*ptr != '\0')) - { - *start++ = *ptr++; - } - } - - while (*ptr != '\0') - { - /* - * Remove trailing whitespace. - */ - while (isspace((int)*ptr)) - { - ptr++; - } - if (*ptr == '\0') - { - break; - } - - /* - * If there are more words, insert a space and if space was - * removed move up remaining text. - */ - *start++ = ' '; - if (start == ptr) - { - while ((!isspace((int)*ptr))&&(*ptr != '\0')) - { - ptr++; - } - start = ptr; - } - else - { - while ((!isspace((int)*ptr))&&(*ptr != '\0')) - { - *start++ = *ptr++; - } - } - } - - *start = '\0'; -} - - -/* - * parse an amperstand escape, and return the appropriate character, or - * '\0' on error. - * we should really only use caseless_equal_prefix for unterminated, and use - * caseless_equal otherwise, but since there are so many escapes, and I - * don't want to type everything twice, I always use caseless_equal_prefix - * Turns out the escapes are case sensitive, use strncmp. - * termination states: - * 0: terminated with a ';' - * 1: unterminated - * 2: terminated with whitespace - */ -char -ExpandEscapes(esc, endp, termination) - char *esc; - char **endp; - int termination; -{ - int cnt; - char val; - int unterminated; - - unterminated = (termination & 0x01); - - esc++; - if (*esc == '#') - { - if (unterminated) - { - char *tptr; - char tchar; - - tptr = (char *)(esc + 1); - while (isdigit((int)*tptr)) - { - tptr++; - } - tchar = *tptr; - *tptr = '\0'; - val = (char)atoi((esc + 1)); - *tptr = tchar; - *endp = tptr; - } - else - { - val = (char)atoi((esc + 1)); - *endp = (char *)(esc + strlen(esc)); - } - } - else - { - cnt = 0; - while (AmpEscapes[cnt].tag != NULL) - { - if (strncmp(esc, AmpEscapes[cnt].tag, - strlen(AmpEscapes[cnt].tag)) == 0) - { - val = AmpEscapes[cnt].value; - *endp = (char *)(esc + - strlen(AmpEscapes[cnt].tag)); - break; - } - cnt++; - } - if (AmpEscapes[cnt].tag == NULL) - { -#ifdef VERBOSE - fprintf(stderr, "Error bad & string\n"); -#endif - val = '\0'; - *endp = (char *)NULL; - } - } - - return(val); -} - - -/* - * Clean the special HTML character escapes out of the text and replace - * them with the appropriate characters "<" = "<", ">" = ">", - * "&" = "&" - * GAG: apperantly < etc. can be left unterminated, what a nightmare. - * Ok, better, they have to be terminated with white-space or ';'. - * the '&' character must be immediately followed by a letter to be - * a valid escape sequence. Other &'s are left alone. - * The cleaning is done by rearranging chars in the passed txt buffer. - * if any escapes are replaced, the string becomes shorter. - */ -void -clean_text(txt) - char *txt; -{ - int unterminated; - int space_terminated; - char *ptr; - char *ptr2; - char *start; - char *text; - char *tend; - char tchar; - char val; - - if (txt == NULL) - { - return; - } - - /* - * Quick scan to find escape sequences. - * Escape is '&' followed by a letter (or a hash mark). - * return if there are none. - */ - ptr = txt; - while (*ptr != '\0') - { - if ((*ptr == '&')&& - ((isalpha((int)*(ptr + 1)))||(*(ptr + 1) == '#'))) - { - break; - } - ptr++; - } - if (*ptr == '\0') - { - return; - } - - /* - * Loop, replaceing escape sequences, and moving up remaining - * text. - */ - ptr2 = ptr; - while (*ptr != '\0') - { - - unterminated = 0; - space_terminated = 0; - /* - * Extract the escape sequence from start to ptr - */ - start = ptr; - while ((*ptr != ';')&&(!isspace((int)*ptr))&&(*ptr != '\0')) - { - ptr++; - } - if (*ptr == '\0') - { -#ifdef VERBOSE - fprintf(stderr, "warning: unterminated & (%s)\n", - start); -#endif - unterminated = 1; - } - else if (isspace((int)*ptr)) - { - space_terminated = 1; - } - - /* - * Copy the escape sequence into a separate buffer. - * Then clean spaces so the "& lt ;" = "<" etc. - * The cleaning should be unnecessary. - */ - tchar = *ptr; - *ptr = '\0'; - text = (char *)malloc(strlen(start) + 1); - if (text == NULL) - { - fprintf(stderr, "Cannot malloc space for & text\n"); - *ptr = tchar; - return; - } - strcpy(text, start); - *ptr = tchar; - clean_white_space(text); - - /* - * Replace escape sequence with appropriate character - */ - val = ExpandEscapes(text, &tend, - ((space_terminated << 1) + unterminated)); - if (val != '\0') - { - if (unterminated) - { - tchar = *tend; - *tend = '\0'; - ptr = (char *)(start + strlen(text) - 1); - *tend = tchar; - } - else if (space_terminated) - { - ptr--; - } - *ptr2 = val; - unterminated = 0; - space_terminated = 0; - } - /* - * invalid escape sequence. skip it. - */ - else - { -#ifdef VERBOSE - fprintf(stderr, "Error bad & string\n"); -#endif - ptr = start; - *ptr2 = *ptr; - } - free(text); - - /* - * Copy forward remaining text until you find the next - * escape sequence - */ - ptr2++; - ptr++; - while (*ptr != '\0') - { - if ((*ptr == '&')&& - ((isalpha((int)*(ptr + 1)))||(*(ptr + 1) == '#'))) - { - break; - } - *ptr2++ = *ptr++; - } - } - *ptr2 = '\0'; -} - - -/* - * Get a block of text from a HTML document. - * All text from start to the end, or the first mark - * (a mark is '<' or ''. From the text, determine - * its type, and fill in a mark_up structure to return. Also returns - * endp pointing to the ttrailing '>' in the original string. - */ -struct mark_up * -get_mark(start, endp) - char *start; - char **endp; -{ - char *ptr; - char *text; - char tchar; - struct mark_up *mark; - int comment=0; /* amb - comment==1 if we are in a comment */ - char *first_gt=NULL; /* keep track of ">" for old broken comments */ - - if (start == NULL) - { - return(NULL); - } - - if (*start != '<') - { - return(NULL); - } - - /* amb - check if we are in a comment, start tag is in proximity, 0 --> out of prox -** next delta-Y bit: 1 --> touching tablet, 0 --> not touching -** high-order (sign) delta-Y bit: 1 --> first button closed, 0 --> open -** -** -** The lowest order bit of the delta-X bits is used to indicate that -** additional bytes follow: "1" indicates that the next byte is used for the -** next 7 barrel buttons with state. The high order bit of each sequential -** byte in the series is "1" if an additional byte must be fetched, "0" -** otherwise. In these additional bytes, the additional buttons are -** associated in order starting with the low-order bit. -** -**------------------------------------------------------------------------*/ - - - -/**************************/ -/* REFERENCE SECTION 27.0 */ -/**************************/ - -/*------------------------------------------------------------------------- -** Skipped-point records: -** --------------------- -** -** (Taken from 8-bit byte delta X/Y: two bytes total) -** -** -** |1|0| 0|0|0|0|1|0| 0|X|.|.|.|.|X|X| -** ------------------------------------- -** (delta-X) (delta-Y) -** -** An eight-bit delta with delta-X == 2, and delta-Y in the range -** (-4..3) indicates a count of elided points. The delta-Y values in the -** range (-4..-1) are used to represent skip counts of (4..7). If the -** delta-Y value is zero "0", the next two bytes are fetched to get a U16 -** skip count value. -** -** The elided points are points removed between the point immediately prior -** to the skipped-point record and the point immediately afterward. This -** implies that at least one point must follow every skip record (though -** the point may not appear next in the stream if there are intervening -** button state transitions). Reading applications that are interested in -** recovering elided points will typically interpolate. Skip counts of zero -** are meaningless and not permitted. -** -** Reserved: -** -------- -** -** The remaining encodings from the 8-bit byte delta X/Y are reserved: -** -** delta-X of -4, -3, -2, -1, 3 AND ((delta-Y >= -4) & ((delta-Y <= 3)) -** -**------------------------------------------------------------------------*/ - -#endif /* end of INKSTORE_INCLUDED */ diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/list.c xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/list.c --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/list.c Sun Jun 1 17:22:06 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/list.c Thu Jan 1 00:00:00 1970 @@ -1,322 +0,0 @@ -/* - * Copyright (C) 1992, Board of Trustees of the University of Illinois. - * - * Permission is granted to copy and distribute source with out fee. - * Commercialization of this product requires prior licensing - * from the National Center for Supercomputing Applications of the - * University of Illinois. Commercialization includes the integration of this - * code in part or whole into a product for resale. Free distribution of - * unmodified source and use of NCSA software is not considered - * commercialization. - * - */ - - -/* - * list.c: This module contains list manipulation routines that cunstruct - * and maintain a linked list of data items. The record at the head of each - * list contains pointers to the head, tail, and current list position. - * the list itsself is doubly linked with both next and previous pointers. - * - * ddt - */ -#include -#include "listP.h" - -#ifndef MALLOC -#define MALLOC malloc -#define FREE free -#endif - -#define NIL 0 - -static void ListPrintErr(s) -char *s; -{ - fprintf(stderr,"%s",s); -} - -/* - * This function returns the data located at the head of the linked list, - * or NIL if the list is empty. As a side effect current is also set to - * the head of the list. - */ -char *ListHead(theList) -List theList; -{ - if (!theList) - return(NIL); - theList->current = theList->head; - if (theList->head) - return(theList->head->value); - else - return(NIL); -} - -/* - * This function returns the data located at the tail of the linked list, - * or NIL if the list is empty. As a side effect current is also set to - * the tail of the list. - */ -char *ListTail(theList) -List theList; -{ - if (!theList) - return(NIL); - theList->current = theList->tail; - if (theList->tail) - return(theList->tail->value); - else - return(NIL); -} - -/* - * This function returns the data located at the current position in the - * linked list, or NIL if the list is empty. - */ -char *ListCurrent(theList) -List theList; -{ - if (!theList) - return(NIL); - if (theList->current) - return(theList->current->value); - else - return(NIL); -} - -/* - * This function returns the data located at the next element of the linked - * list after the current position, or NIL if the list is empty, or you - * are at its end. - * As a side effect current is also set to the next entry in the list. - */ -char *ListNext(theList) -List theList; -{ - if (!theList) - return(NIL); - if (theList->current) { - theList->current = theList->current->next; - return(ListCurrent(theList)); - } - else - return(NIL); -} - -/* - * This function returns the data located at the previous element of the linked - * list before the current position, or NIL if the list is empty. - * As a side effect current is also set to the previous entry in the list. - */ -char *ListPrev(theList) -List theList; -{ - if (!theList) - return(NIL); - if (theList->current) { - theList->current = theList->current->prev; - return(ListCurrent(theList)); - } - else - return(NIL); -} - -/* - * Create a list head and initialize it to NIL. - */ -List ListCreate() -{ -List retVal; - - if (!(retVal = (List) MALLOC(sizeof(struct LISTSTRUCT)))) { - ListPrintErr("Out of Memory\n"); - return((List) 0); - } - retVal->head = NIL; - retVal->tail = NIL; - retVal->current = NIL; - retVal->listCount = 0; - return(retVal); -} - -/* - * Destroy a list head, and free all associated memory. - */ -void ListDestroy(theList) -List theList; -{ -struct LISTINSTANCE *l; -struct LISTINSTANCE *m; - - if (!theList) - return; - l = theList->head; - while(l) { - m = l; - l = l->next; - FREE(m); - } - FREE(theList); - -} - - -/* - * Add an entry to the end of the linked list. Current is changed to point to - * the added element. - */ -int ListAddEntry(theList,v) -/* return 0 on failure */ -List theList; -char *v; /* data to be added */ -{ -struct LISTINSTANCE *l; - - if (!(l =(struct LISTINSTANCE *) MALLOC(sizeof(struct LISTINSTANCE)))){ - ListPrintErr("Out of Memory\n"); - return(0); - } - - l->value = v; - - l->next = NIL; - l->prev = NIL; - - if (theList->head == NIL) - theList->tail = theList->head = l; - else { - theList->tail->next = l; - l->prev = theList->tail; - theList->tail = l; - } - - theList->current = l; - - theList->listCount++; - - return(1); -} - -/* - * Search the list for an entry with a matching value field, and return - * a pointer to that list element. Current is changed to point to the - * element returned. - */ -static struct LISTINSTANCE *SearchListByValue(theList,v) -List theList; -char *v; -{ -struct LISTINSTANCE *l; - - l = theList->head; - while (l != NIL) { - if (l->value == v) { - theList->current = l; - return(l); - } - else { - l = l->next; - } - } - theList->current = l; - - return(NIL); - -} - -/* - * Find the list entry with a matching value field, and delete it - * from the list. Set current to point to the element after the deleted - * element in the list. - */ -int ListDeleteEntry(theList,v) -/* removes the first occurance of v from the list */ -/* return 0 if value not in list else 1 */ -List theList; -char *v; -{ -struct LISTINSTANCE *l; -char *retV; - - if (!(l = SearchListByValue(theList,v))) - return(0); - - if (l->prev) - l->prev->next = l->next; - else - theList->head = l->next; - - if (l->next) - l->next->prev = l->prev; - else - theList->tail = l->prev; - - theList->current = l->next; - - retV = l->value; - FREE(l); - - theList->listCount--; - - return(1); -} - - -int ListMakeEntryCurrent(theList,entry) -/* return 0 on failure */ -List theList; -char *entry; -{ -struct LISTINSTANCE *l; - - if (theList) { - if (!(l = SearchListByValue(theList,entry))) - return(0); - theList->current = l; - return(1); - } - return(0); - -} - -int ListCount(theList) -/* return the number of elements in the list */ -/* current position pointer is not affected */ -List theList; -{ -char *entry; -int count; -struct LISTINSTANCE *saveCurrent; - - if (theList) { - return(theList->listCount); - } - else { - return(0); - } -} - - -/* return indexed entry. Index starts at 0 */ -/* the current list pointer will be set to this entry */ -/* return 0 on failure */ -char *ListGetIndexedEntry(theList,number) -List theList; -int number; -{ -char *entry; -register int x; - - if (!theList) { - return(0); - } - entry = ListHead(theList); - for (x = 0; x < number; x++) { - if (!entry) { - return(0); - } - entry = ListNext(theList); - } - return(entry); -} diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/list.h xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/list.h --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/list.h Sun Jun 1 17:22:06 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/list.h Thu Jan 1 00:00:00 1970 @@ -1,29 +0,0 @@ -/* - * Copyright (C) 1992, Board of Trustees of the University of Illinois. - * - * Permission is granted to copy and distribute source with out fee. - * Commercialization of this product requires prior licensing - * from the National Center for Supercomputing Applications of the - * University of Illinois. Commercialization includes the integration of this - * code in part or whole into a product for resale. Free distribution of - * unmodified source and use of NCSA software is not considered - * commercialization. - * - */ - - -typedef struct LISTSTRUCT *List; - -extern List ListCreate(); -extern void ListDestroy(); -extern int ListAddEntry(); -extern int ListDeleteEntry(); -extern int ListMakeEntryCurrent(); -extern int ListCount(); - -extern char *ListHead(); -extern char *ListTail(); -extern char *ListCurrent(); -extern char *ListNext(); -extern char *ListPrev(); -extern char *ListGetIndexedEntry(); diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/listP.h xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/listP.h --- orig/xmotd-1.17.2/xmotd-1.17.2/libhtmlw/listP.h Sun Jun 1 17:22:06 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/libhtmlw/listP.h Thu Jan 1 00:00:00 1970 @@ -1,34 +0,0 @@ -/* - * Copyright (C) 1992, Board of Trustees of the University of Illinois. - * - * Permission is granted to copy and distribute source with out fee. - * Commercialization of this product requires prior licensing - * from the National Center for Supercomputing Applications of the - * University of Illinois. Commercialization includes the integration of this - * code in part or whole into a product for resale. Free distribution of - * unmodified source and use of NCSA software is not considered - * commercialization. - * - */ - - -#ifndef ___HAS_LIST_STUFF_BEEN_INCLUDED_BEFORE___ -#define ___HAS_LIST_STUFF_BEEN_INCLUDED_BEFORE___ - -#include -#include "list.h" - -struct LISTINSTANCE { - char *value; - struct LISTINSTANCE *next; - struct LISTINSTANCE *prev; - }; - -struct LISTSTRUCT { - struct LISTINSTANCE *head; - struct LISTINSTANCE *tail; - struct LISTINSTANCE *current; - int listCount; - }; - -#endif diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/logo.c xmotd-1.17.2-arr1/xmotd-1.17.2/logo.c --- orig/xmotd-1.17.2/xmotd-1.17.2/logo.c Fri Jul 18 01:23:55 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/logo.c Thu Jan 1 00:00:00 1970 @@ -1,139 +0,0 @@ -/* - * Copyright 1993-97 Luis Fernandes - * - * Permission to use, copy, hack, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. This application is presented as is - * without any implied or written warranty. - * - * 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. - * - * libhtmlw is copyright (C) 1993, Board of Trustees of the University - * of Illinois. See the file libhtmlw/HTML.c for the complete text of - * the NCSA copyright. - */ - -/* $Id: logo.c,v 1.2 1997/07/18 01:23:55 elf Exp $ */ -#include -#include -#include - -#ifdef HAVE_XPM -#include - -/* default pixmap that goes in the corner*/ -#include "xlogo.xpm" -#endif - -#include "maindefs.h" - -/* default bitmap that goes in the corner*/ -#include "xlogo.bm" - - -/* Creates an icon pixmap and returns it in icon_pixmap. If xpm is - supported, use it.*/ -void -loadLogo(char *logo, Pixmap *icon_pixmap, Pixel fg, Pixel bg) -{ - extern Widget topLevel; -#ifdef HAVE_XPM - Pixmap shape_mask_return; -#endif - - if(logo) - { -#ifdef MOTIF - -#ifdef HAVE_XPM - int rv=XpmReadFileToPixmap(XtDisplay(topLevel) - ,RootWindowOfScreen(XtScreen(topLevel)) - ,logo, icon_pixmap - ,&shape_mask_return, NULL); - if(rv!=BitmapSuccess) - { - fprintf(stderr,BAD_BITMAP_MESSAGE, logo); - exit(-1); - } -#else - - *icon_pixmap=XmGetPixmap(XtScreen(topLevel), - logo, fg, bg); -#endif /* HAVE_XPM*/ - -#else - unsigned int width, height; - - /* read-in user-specified bitmap*/ - int rv=XReadBitmapFile(XtDisplay(topLevel), - RootWindowOfScreen(XtScreen(topLevel)), - logo, &width, &height, icon_pixmap, - (int *)NULL, (int*)NULL); - - if(rv!=BitmapSuccess) - { - /* if xpm support is compiled in...*/ -#ifdef HAVE_XPM - - /*... attempt to load it as an xpm file*/ - rv=XpmReadFileToPixmap(XtDisplay(topLevel) - ,RootWindowOfScreen(XtScreen(topLevel)) - ,logo, icon_pixmap - ,&shape_mask_return, NULL); -#endif - if(rv!=BitmapSuccess) - { - fprintf(stderr,BAD_BITMAP_MESSAGE, logo); - exit(-1); - } - } -#endif /*MOTIF*/ - } - else - { - -#ifdef HAVE_XPM - /* display default X pixmap compiled-in*/ - XpmCreatePixmapFromData(XtDisplay(topLevel), - RootWindowOfScreen(XtScreen(topLevel)), - xlogo_xpm, icon_pixmap, - &shape_mask_return, NULL); -#else - - /* display default X bitmap compiled-in*/ - /* Note: XCreateBitmapFromData doesn't seem to work under Motif - for some reason, but XCreatePixmapFromBitmapData works for - both, so we use it.*/ - *icon_pixmap= - XCreatePixmapFromBitmapData(XtDisplay(topLevel), - RootWindowOfScreen(XtScreen(topLevel)), - xlogo_bits,xlogo_width,xlogo_height, - fg, bg, - DefaultDepthOfScreen(XtScreen(topLevel))); -#if 0 - - *icon_pixmap= - XCreateBitmapFromData(XtDisplay(topLevel), - RootWindowOfScreen(XtScreen(topLevel)), - xlogo_bits,xlogo_width,xlogo_height); -#endif -#endif /*HAVE_XPM*/ - - } -}/*loadLogo*/ - - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/main.c xmotd-1.17.2-arr1/xmotd-1.17.2/main.c --- orig/xmotd-1.17.2/xmotd-1.17.2/main.c Fri Feb 14 00:35:05 2003 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/main.c Thu Jan 1 00:00:00 1970 @@ -1,805 +0,0 @@ -/* xmotd is a message of the day displayer for X11 and dumb-terminals - * - * It displays a logo in the top-left corner, a 3-line title to its - * right and a text-widget (optionally a HTML widget) for displaying - * the message, just below. The motd filename(s) are supplied on the - * command-line. A single button is used to sequentailly access the - * motd(s) and to dismiss the browser when all the messages have been - * viewed. A label displays the time of the file being viewed and - * (optionally) the filename. It has options for automatically popping - * down w/o user intervention and other features which I can't be - * bothered to type-in here and would rather have you look at the - * man-page or http://www.ee.ryerson.ca:8080/~elf/xmotd.html - * */ - -/* $Id: main.c,v 1.19 2003/02/14 00:35:03 elf Exp $ */ - -/* - * Copyright 1993-97, 1999, 2003 Luis Fernandes - * - * Permission to use, copy, hack, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. This application is presented as is - * without any implied or written warranty. - * - * 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. - * - * libhtmlw is copyright (C) 1993, Board of Trustees of the University - * of Illinois. See the file libhtmlw/HTML.c for the complete text of - * the NCSA copyright. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#if defined(HPUX) - -#include -#define dirent direct - -#else - -#include - -#endif - -#include -#include -#include - -#ifdef HAVE_XPM -#include -#endif - -#ifdef MOTIF - -#include -#include -#include -#include -#include - -#else - -#include -#include -#include -#include -#include - -#endif - -#ifdef HAVE_HTML -#include -#endif - -#define MIN_SLEEP_PERIOD 60 /* in seconds */ -#define HOURS_TO_SECS 3600.0 - -#include "maindefs.h" -#include "appdefs.h" -#include "main.h" - -extern time_t motdChanged(); -extern void nextMessage(Widget w, caddr_t call_data, caddr_t client_data); -extern void AnchorCallbackProc(Widget w, caddr_t call_data, caddr_t client_data); /* browser.c */ - -extern void loadLogo(char *logo, Pixmap *icon_pixmap, Pixel fg, Pixel bg); /* in logo.c */ - -/* fwd decls*/ -XtActionProc reallyQuit(Widget w, XButtonEvent *ev); -void Quit(Widget w, caddr_t call_data, caddr_t client_data); -void printUsage(char *str); /* usage.c */ -int runSilentRunDeep(unsigned slumber); -unsigned getAlarmTime(float period); -messageptr freeMessage(messageptr msglist); -messageptr newMessage(char *file); - -XtAppContext app_con; -Widget topLevel; /* the application widget*/ - -Widget text, quit; -Widget info; - -XtIntervalId timer; /* pop-down time-out ID */ - -Pixmap icon_pixmap; - -app_res_t app_res; /* application resources, in main.h */ - -/* list of pointers to the messages that will actually be displayed */ -messageptr msgslist; - -int gargc; /* globally accessible argc */ -char **gargv; /* globally accessible argv*/ - -char timeStamp[256]; - -static int alreadyForked; /* flag to remember if we are already - running in the background */ - -#define offset(field) XtOffset (struct _resources *, field) - -static XtResource resources[] = { - { "always","Always",XtRInt, sizeof(int), - offset(always),XtRString, "0"}, - - { "popdown","Popdown",XtRInt, sizeof(int), - offset(pto),XtRString, "0"}, - { "usedomains","UseDomains",XtRInt, sizeof(int), - offset(usedomains),XtRString, "0"}, - { "showfilename","ShowFilename",XtRInt, sizeof(int), - offset(showfilename),XtRString, "0"}, - { "paranoid","Paranoid",XtRInt, sizeof(int), - offset(paranoid),XtRString, "0"}, - { "tail","Tail",XtRInt, sizeof(int), - offset(tail),XtRString, "0"}, - { "bitmaplogo","BitmapLogo",XtRString, sizeof(String), - offset(logo),XtRString, NULL}, - { "warnfile","Warnfile",XtRString, sizeof(String), - offset(warnfile),XtRString, NULL}, - { "wakeup","Wakeup",XtRFloat, sizeof(float), - offset(periodic),XtRString, "0"}, - { "stampfile","Stampfile",XtRString, sizeof(String), - offset(stampfile),XtRString, TIMESTAMP}, - { "atom","Atom",XtRString, sizeof(String), - offset(atomname),XtRString, ATOM}, -#ifdef HAVE_HTML - { "browser","Browser",XtRString, sizeof(String), - offset(browser),XtRString, BROWSER}, -#endif -}; - -static XrmOptionDescRec options[] = { - { "-always", "always", XrmoptionNoArg, "1"}, - { "-showfilename", "showfilename", XrmoptionNoArg, "1"}, - { "-usedomains", "usedomains", XrmoptionNoArg, "1"}, - { "-paranoid", "paranoid", XrmoptionNoArg, "1"}, - { "-tail", "tail", XrmoptionNoArg, "1"}, - { "-popdown", "popdown", XrmoptionSepArg, (caddr_t) NULL}, - { "-bitmaplogo", "bitmaplogo", XrmoptionSepArg, (caddr_t) NULL}, - { "-warnfile", "warnfile", XrmoptionSepArg, (caddr_t) NULL}, - { "-wakeup", "wakeup", XrmoptionSepArg, (caddr_t) NULL}, - { "-stampfile", "stampfile", XrmoptionSepArg, (caddr_t) NULL}, - { "-atom", "atom", XrmoptionSepArg, (caddr_t) NULL}, -#ifdef HAVE_HTML - { "-browser", "browser", XrmoptionSepArg, (caddr_t) NULL}, -#endif -}; - -/* You can use shift + btn1 to quit xmotd (when run with -wakeup)*/ -static char shift1Trans[]="#override\n\ - Shift,Shift: reallyquit()"; - -static XtActionsRec xlations[]={ - {"reallyquit", (XtActionProc) reallyQuit}, -}; - -/* when the text widget is mapped and we are in "tail" mode, scroll to - the end of the file*/ -static char tailTrans[]="#override\n\ - : end-of-file()"; - -char * -getTimeStampName() -{ - static char buf[256]; - - sprintf(buf, "%s/%s", getenv("HOME"), app_res.stampfile); - - if(app_res.usedomains) - { - char domainame[256]; - - getdomainname(domainame, 256); - - strcat(buf, "."); - strcat(buf, domainame); - } - - return(buf); - -} - -/* convert user-specified wakeup time to seconds (argument to sleep)*/ -unsigned -getAlarmTime(float period) -{ - unsigned slumber=(period*HOURS_TO_SECS); - - /* fprintf(stderr,"slumber=%ld\n", slumber);*/ - - /* limit sleep to 60sec*/ - return((slumbernext; - - free(oldmsg->file); - free(oldmsg); - return(msglist); - -} /*freeMessage*/ - -messageptr -newMessage(char *file) -{ - messageptr newmsg; - - if (!(newmsg = (messageptr)malloc(sizeof(struct messagenode)))) - { - perror("xmotd"); - exit (2); /*problems, probably no ram HA */ - } /*if*/ - - newmsg->file=(char *)calloc(1,(strlen(file)+1)*sizeof(char)); - - if(!newmsg->file) - { - perror("xmotd"); - exit(2); - } - - strcpy(newmsg->file, file); - newmsg->next = NULL; - return(newmsg); - -} /*newMessage*/ - - -int -numFilesToDisplay(int argc, char **argv) -{ - register int numsg=0, i; - struct stat motdstat; - messageptr newmsg, currentmsg = msgslist; - - /* i starts at 1 since argv[0] is the program name*/ - for(i=1; id_ino == 0) - continue; - if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) - continue; - strcpy(name, argv[i]); - - if (name[strlen(name) - 1] != '/') - strcat(name, "/"); - strcat(name, dp->d_name); - - if (access(name, 0) < 0) - continue; - - if(motdChanged(name, timeStamp) || app_res.always) - { - newmsg = newMessage(name); - - if (!currentmsg) /* first in list */ - msgslist = newmsg; - else - currentmsg->next = newmsg; - - currentmsg = newmsg; - numsg++; - } /*if motdchanged*/ - - } /*while*/ - - closedir(dir); - } /*if opendir*/ - } - else - if(motdChanged(argv[i], timeStamp) || app_res.always) - { - newmsg = newMessage(argv[i]); - - if (!currentmsg) /* first in list */ - msgslist = newmsg; - else - currentmsg->next = newmsg; - - currentmsg = newmsg; - numsg++; - } - } - - if((numsg || app_res.paranoid || app_res.always) && app_res.warnfile) - { - newmsg = newMessage(app_res.warnfile); - newmsg->next = msgslist; - msgslist = newmsg; - numsg++; - } /*if*/ - - return numsg; - -}/* numFilesToDisplay*/ - -int -runSilentRunDeep(unsigned slumber) -{ - int numsg=0; - - while(1) - { - int fd; - - /* fprintf(stderr, "Going to sleep! (Zzzzzzzz...)\n");*/ - sleep(slumber); - /* fprintf(stderr, "Waking-up! (Yawn...)\n");*/ - - /* first thing we do after waking up is to see if the user is - still logged-in*/ - if((fd=open("/dev/console", O_RDONLY, O_RDONLY)<0)) - { - /* since xmotd can't read from the console we assume user - has logged-out, so we exit*/ - exit(0); - } - - close(fd); - - /* next check if any messages need to be displayed, if there - aren't any, go back to sleep; otherwise return to display - messages*/ - if(numsg=numFilesToDisplay(gargc, gargv)) return(numsg); - } - -} - - -main(argc, argv) -int argc; -char **argv; -{ - extern Boolean atomExists(String); - Display *display; - register int i, start=0; - int numsg; - - - if ((argc > 1) && !(strcmp(argv[1],"-help"))) - { - printUsage(argv[0]); /* and exit */ - } - - /* Test to see whether we are connected to an X display. If we - aren't, we proceed in text-only mode: bare-bones functionality; - output to stdout. Why bare-bones, I hear you asking? Well, X - does all the command-line options parsing for me and I don't feel - like duplicating all that code. So there.*/ - - if((display=XOpenDisplay((char *)NULL))==NULL) - { - - if(argc<2) - { - fprintf(stderr, "xmotd: ERROR, missing file.\n"); - printUsage(argv[0]); /* and exit */ - } - else - { - extern void runInTextMode(); - runInTextMode(argc, argv); /* ...and exit... */ - } - - fprintf(stderr,"Never gets here!\n"); - exit(0); /* just in case */ - - } - else - { - XCloseDisplay(display); - } - - /* we have to init the toolkit *before* we check the command-line so - we can use X's parsing routines, since -geom options, etc. may be - specified, in which case, the motd-filename is *not* the 2nd - argument*/ - topLevel = XtVaAppInitialize(&app_con, "XMotd", options, - XtNumber(options), - &argc, argv, fallback_resources, - NULL); - - XtGetApplicationResources(topLevel, (caddr_t) &app_res, - resources, XtNumber(resources), - (ArgList) NULL, (Cardinal) 0); - - if(argc<2) - { - fprintf(stderr,"xmotd: ERROR, missing file\n"); - printUsage(argv[0]); /* and exit */ - } - - if(app_res.paranoid && !app_res.warnfile) - { - fprintf(stderr,"xmotd: ERROR, specified \"-paranoid\" without \"-warnfile\"\n"); - printUsage(argv[0]); /* and exit */ - } - - strcpy(timeStamp, getTimeStampName()); - - gargc=argc; - gargv=argv; - - /* first figure out how many of the files supplied on the - command-line we will be actually displaying; i.e. we only show - the new ones (unless -always has been specified, in which case we - show all of them)*/ - numsg=numFilesToDisplay(argc, argv); - - if(!app_res.periodic && !numsg) - { - /* if none of the messages need to be displayed and -wakeup not - specified */ - - XtDestroyApplicationContext(app_con); - exit(0); - } - - if(app_res.periodic) /*-wakeup or -timeout specified*/ - { - - /*ensure no other copies of xmotd are running*/ - if(atomExists(app_res.atomname)){ - XtDestroyApplicationContext(app_con); - exit(0); - } - - if(fork()) exit(0); /*we have to daemonize ourselves*/ - alreadyForked=1; /* make a note of it */ - - if(!numsg) - { - /* if no messages to be displayed, we sleep */ - numsg=runSilentRunDeep(getAlarmTime(app_res.periodic)); - } - - } - - createWidgets(numsg); - nextMessage((Widget)NULL, (caddr_t)NULL, (caddr_t)NULL); - - XtAddEventHandler(topLevel, (EventMask)0, True, - (XtEventHandler)_XEditResCheckMessages, 0); - - XtRealizeWidget(topLevel); - XtAppMainLoop(app_con); -} - - -createWidgets(int anymsg) -{ - Widget form, paned, logo, mlabel, hline; - XtTranslations shift1TransTable, tailTransTable; - Pixel fg, bg; - Arg args[8]; - int n; - -#ifdef MOTIF - XmString xmstr; - - form=XtVaCreateManagedWidget("form", xmFormWidgetClass,topLevel, - NULL); -#else - - form=XtVaCreateManagedWidget("form", formWidgetClass,topLevel, - XtNresizable, True, - NULL); -#endif /* ifdef MOTIF */ - - XtVaGetValues(form, - XtNbackground, &bg, - XtNforeground, &fg, - NULL); - - loadLogo(app_res.logo, &icon_pixmap, fg, bg); - -#ifdef MOTIF - logo=XtVaCreateManagedWidget("logo", xmLabelWidgetClass, form, - XmNleftAttachment, XmATTACH_FORM, - XmNtopAttachment, XmATTACH_FORM, - XmNlabelType, XmPIXMAP, - XmNlabelPixmap, icon_pixmap, - XmNborderWidth, 0, - NULL); - - mlabel=XtVaCreateManagedWidget("title", xmLabelWidgetClass, form, - XmNleftAttachment, XmATTACH_WIDGET, - XmNleftWidget, logo, - XmNrightAttachment, XmATTACH_FORM, - NULL); - - hline=XtVaCreateManagedWidget("hline", xmSeparatorWidgetClass, form, - XmNtopAttachment, XmATTACH_WIDGET, - XmNtopWidget, logo, - NULL); - - quit = XtVaCreateManagedWidget("quit", xmPushButtonWidgetClass, form, - XmNtopAttachment, XmATTACH_WIDGET, - XmNtopWidget, logo, - XmNlabelType, XmSTRING, - - XmNtraversalOn, False, /* remove - Dismiss button from the Tab group; - comment this line out if YOU WANT - "Space-bar" to activate the dismiss - button*/ - NULL); - - info=XtVaCreateManagedWidget("info", xmLabelWidgetClass, form, - XmNleftAttachment, XmATTACH_FORM, - XmNtopAttachment, XmATTACH_WIDGET, - XmNtopWidget, quit, - XmNlabelType, XmSTRING, - NULL); - -#ifdef HAVE_HTML - - n = 0; - XtSetArg(args[n],XmNtopAttachment, XmATTACH_WIDGET); n++; - XtSetArg(args[n],XmNtopWidget, info); n++; - XtSetArg(args[n],XmNbottomAttachment, XmATTACH_FORM); n++; - - text = XtVaCreateManagedWidget("text", htmlWidgetClass, form,NULL); - - XtSetValues(text,args,n); - - XtManageChild(text); - -#else - - n=0; - XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; - XtSetArg(args[n], XmNeditable, False); n++; - XtSetArg(args[n], XmNscrollHorizontal, False); n++; - XtSetArg(args[n], XmNscrollLeftSide, True); n++; - XtSetArg(args[n], XmNcursorPositionVisible, False); n++; - - text=XmCreateScrolledText(form, "text", args, n); - n=0; - - XtVaSetValues(XtParent(text), - XmNtopAttachment, XmATTACH_WIDGET, - XmNtopWidget, info, - XmNbottomAttachment, XmATTACH_FORM, - NULL); - - XtManageChild(text); -#endif /* ifdef HAVE_HTML & ifdef MOTIF */ - -#else - - logo=XtVaCreateManagedWidget("logo", labelWidgetClass, form, - XtNleft, XtChainLeft, - XtNright, XtChainLeft, - XtNbitmap, icon_pixmap, - NULL); - - mlabel=XtVaCreateManagedWidget("title", labelWidgetClass, form, - XtNfromHoriz, logo, - NULL); - - hline=XtVaCreateManagedWidget("hline", labelWidgetClass, form, - XtNfromVert, logo, - XtNfromVert, mlabel, - XtNlabel, (char *)NULL, - NULL); - - quit = XtVaCreateManagedWidget("quit", commandWidgetClass, form, - XtNleft, XtChainLeft, - XtNright, XtChainLeft, - XtNfromVert, logo, - NULL); - - info=XtVaCreateManagedWidget("info", labelWidgetClass, form, - XtNright, XtChainLeft, - XtNfromVert, quit, - XtNresizable, True, - NULL); - -#ifdef HAVE_HTML - text = XtVaCreateManagedWidget("text", - htmlWidgetClass, form, - XtNfromVert, info, - XtNwidth, 680, - XtNheight, 500, - NULL); - -#else - text = XtVaCreateManagedWidget("text", - asciiTextWidgetClass, form, - XtNfromVert, info, - NULL); - -#endif /* ifdef HAVE_HTML */ - - if(app_res.tail) - { - tailTransTable=XtParseTranslationTable(tailTrans); - XtOverrideTranslations(text, tailTransTable); - } - -#endif /* ifdef MOTIF */ - - if((anymsg>1)) - { -#ifdef MOTIF - xmstr=XmStringCreateLocalized(NEXT_MESSAGE_LABEL); - XtVaSetValues(quit, XmNlabelString, xmstr, NULL); - XmStringFree(xmstr); - - XtAddCallback(quit, XmNactivateCallback, (XtCallbackProc)nextMessage, 0); -#else - XtAddCallback(quit, XtNcallback, (XtCallbackProc)nextMessage,(caddr_t)0); - XtVaSetValues(quit, XtNlabel, NEXT_MESSAGE_LABEL, NULL); -#endif - if(app_res.pto) - timer=XtAppAddTimeOut(app_con, (unsigned long)(app_res.pto*1000), - (XtTimerCallbackProc)nextMessage, (caddr_t) NULL); - } - else - { -#ifdef MOTIF - xmstr=XmStringCreateLocalized(LAST_MESSAGE_LABEL); - XtVaSetValues(quit, XmNlabelString, xmstr, NULL); - XmStringFree(xmstr); - - XtAddCallback(quit, XmNactivateCallback, (XtCallbackProc)Quit, 0); -#else - XtAddCallback(quit, XtNcallback, (XtCallbackProc)Quit, 0); - XtVaSetValues(quit, XtNlabel, LAST_MESSAGE_LABEL, NULL); -#endif - if(app_res.pto) - timer=XtAppAddTimeOut(app_con, (unsigned long)(app_res.pto*1000), - (XtTimerCallbackProc)Quit, (caddr_t) NULL); - } - -#ifdef HAVE_HTML - XtAddCallback(text, WbNanchorCallback, - (XtCallbackProc)AnchorCallbackProc,(caddr_t)0); -#endif - - XtAppAddActions(app_con, xlations, XtNumber(xlations)); - shift1TransTable=XtParseTranslationTable(shift1Trans); - XtOverrideTranslations(quit, shift1TransTable); - -}/* createWidgets*/ - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/main.h xmotd-1.17.2-arr1/xmotd-1.17.2/main.h --- orig/xmotd-1.17.2/xmotd-1.17.2/main.h Tue Nov 23 22:59:33 1999 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/main.h Thu Jan 1 00:00:00 1970 @@ -1,40 +0,0 @@ -/* $Id: main.h,v 1.5 1999/11/23 23:01:14 elf Exp $ */ -typedef struct _resources { - int always; /* flag; if set, ignore .xmotd timestamp */ - int pto; /* popdown time-out value in seconds*/ - int usedomains; /* do timestamping with .xmotd.domain-name */ - int showfilename; /* display the name of the file being - viewed next to the date & time */ - int paranoid; /* used with -warnfile; always display - the warning message */ - - float periodic; /* if set, xmotd will periodically - check the motd files to see if they - have changed, and display them - accordingly. The value indicates - the sleep period in hours (decimals - represent minutes)*/ - - int tail; /* flag; if scroll text widget to end */ - - String warnfile; /* path to a filename containing a - standard warning message that is - displayed whenever a motd is displayed*/ - - String logo; /* path to logo (xbm) */ - - String stampfile; /* name of the timestamp filename */ - - String atomname; /* we can force multiple xmotds to run - by giving them unique names */ - -#ifdef HAVE_HTML - String browser; /* path to web-browser */ -#endif - -} app_res_t; - -typedef struct messagenode { /* linked list of messages to display */ - char *file; - struct messagenode *next; -} *messageptr; diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/maindefs.h xmotd-1.17.2-arr1/xmotd-1.17.2/maindefs.h --- orig/xmotd-1.17.2/xmotd-1.17.2/maindefs.h Fri Feb 14 00:35:24 2003 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/maindefs.h Thu Jan 1 00:00:00 1970 @@ -1,17 +0,0 @@ -/* $Id: maindefs.h,v 1.3 2003/02/14 00:35:22 elf Exp $ */ -#define TIMESTAMP ".xmotd" /* the date of this file, in user's - * home-directory, is used to - * determine whether the motd has - * changed and should be displayed*/ - -#define USAGESTRING "Usage:\n%s [X-toolkit-options] [options] {{file [file2 ...]} {dir/}}\n" - -#define BAD_BITMAP_MESSAGE "Error reading bitmap file: %s.\nPossible causes:\n the file does not exist (perhaps you mis-typed the name),\n or it is not a valid X bitmap,\n or there is insufficient memory to allocate the bitmap.\n" - -#define NEXT_MESSAGE_LABEL "Next Message" -#define LAST_MESSAGE_LABEL "Dismiss" - -#define BROWSER "/usr/local/bin/netscape" -#define ATOM "xmotd" - - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/patchlevel.h xmotd-1.17.2-arr1/xmotd-1.17.2/patchlevel.h --- orig/xmotd-1.17.2/xmotd-1.17.2/patchlevel.h Thu Feb 13 23:31:36 2003 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/patchlevel.h Thu Jan 1 00:00:00 1970 @@ -1,4 +0,0 @@ -#define RELEASE 1 -#define PATCH 17 -#define STATUS "FCS" - diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/textmode.c xmotd-1.17.2-arr1/xmotd-1.17.2/textmode.c --- orig/xmotd-1.17.2/xmotd-1.17.2/textmode.c Tue Nov 3 22:24:03 1998 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/textmode.c Thu Jan 1 00:00:00 1970 @@ -1,168 +0,0 @@ -/* $Id: textmode.c,v 1.7 1998/11/03 22:24:31 elf Exp $ */ - -/* - * Copyright 1993-97 Luis Fernandes - * - * Permission to use, copy, hack, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. This application is presented as is - * without any implied or written warranty. - * - */ - -/* - * 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. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "maindefs.h" - -void -runInTextMode(argc, argv) -int argc; -char **argv; -{ - - register int i, displayed=0; - float sleepPeriod=0.0; - - static int onceAlready; - - static char buf[256], stampfile[256]; - memset(buf, 0, 256); - memset(stampfile, 0, 256); - - strcpy(stampfile, TIMESTAMP); /* default stampfile name */ - - while(1) - { - sprintf(buf, "%s/%s", getenv("HOME"), stampfile); - - for(i=1; i convert to - seconds*/ - sleepPeriod=(atof(argv[i+1])*3600.0); - i++; - } - else - { - fprintf(stdout, "%s: WARNING, ignoring %s\n", argv[0], argv[i]); - } - - } - - } - - if(displayed) - { -/* fprintf(stderr, "Displayed file(s)\n");*/ - updateTimeStamp(buf); /* reset the timestamp after all files - have been read*/ - } - - if(sleepPeriod) - { - int fd; - - if(fork()) exit(0); - sleep((unsigned)sleepPeriod); - - /* Check if user is still logged-in by trying to open - "/dev/tty". If we can't open the controlling terminal - then the user has logged-out (W. Richard Stevens - _Advanced Programming in the Unix Environment_) and xmotd - can exit. */ - - if((fd=open("/dev/tty", O_RDONLY, O_RDONLY)<0)) - { - exit(0); - } - - close(fd); - displayed=0; /* reset the flag */ - } - else - { - exit(0); - } - - } /* while forever */ - -} diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/usage.c xmotd-1.17.2-arr1/xmotd-1.17.2/usage.c --- orig/xmotd-1.17.2/xmotd-1.17.2/usage.c Fri Feb 14 00:34:16 2003 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/usage.c Thu Jan 1 00:00:00 1970 @@ -1,75 +0,0 @@ -/* $Id: usage.c,v 1.8 2003/02/14 00:34:14 elf Exp $ */ -/* - * Copyright 1994-97, 1999, 2003 Luis Fernandes - * - * Permission to use, copy, hack, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. This application is presented as is - * without any implied or written warranty. - * - * - * 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. - * - */ - -#include - -#include "maindefs.h" -#include "patchlevel.h" - -void -printUsage(str) -char *str; -{ - - fprintf(stderr, "This is xmotd %d.%d %s\n", RELEASE, PATCH, STATUS); - - fprintf(stderr, USAGESTRING, str); - - fprintf(stderr, "\nValid options are:\n"); - - fprintf(stderr, " -help display this message\n"); - fprintf(stderr, " -always ignore time-stamp and always display motd(s)\n"); - - fprintf(stderr, " -bitmaplogo file show the bitmap"); -#ifdef HAVE_XPM - fprintf(stderr, "/pixmap"); -#endif - fprintf(stderr," in \"file\" instead of X logo\n"); - -#ifdef HAVE_HTML - fprintf(stderr, " -browser program invoke \"program\" when URL is clicked\n"); -#endif - - fprintf(stderr, " -paranoid (used with -warnfile) always show the warning message\n"); - - - fprintf(stderr, " -popdown # automatically pop-down xmotd after waiting # seconds\n"); - fprintf(stderr, " -stampfile file use \"file\" as timestamp, instead of \"%s\"\n", TIMESTAMP); - fprintf(stderr, " -showfilename show name of the file currently being viewed\n"); - - fprintf(stderr, " -usedomains append domain-names to timestamp\n"); - fprintf(stderr, " -wakeup #.# every # hours, check motd(s) for changes\n"); - fprintf(stderr, " -warnfile file show the warning message in \"file\" before motd(s)\n"); - fprintf(stderr, " -atom name register xmotd with \"name\"\n"); - fprintf(stderr, " -tail scroll & display end of motd file(s)\n"); - - fprintf(stderr, "\n"); - exit(1); - - -} diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/xlogo.bm xmotd-1.17.2-arr1/xmotd-1.17.2/xlogo.bm --- orig/xmotd-1.17.2/xmotd-1.17.2/xlogo.bm Thu May 29 16:56:01 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/xlogo.bm Thu Jan 1 00:00:00 1970 @@ -1,90 +0,0 @@ -#define xlogo_width 100 -#define xlogo_height 100 -static char xlogo_bits[] = { - 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xfe,0xff, - 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xfc,0xff,0xff,0x07, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xf7,0xf8,0xff,0xff,0x0f,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0xfe,0xf3,0xf8,0xff,0xff,0x0f,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0xff,0xf1,0xf0,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0xff,0xf1,0xe0,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff, - 0xf0,0xc0,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x7f,0xf0,0xc0, - 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f,0xf0,0x80,0xff,0xff, - 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x1f,0xf0,0x00,0xff,0xff,0xff,0x01, - 0x00,0x00,0x00,0x00,0x00,0xf0,0x1f,0xf0,0x00,0xfe,0xff,0xff,0x03,0x00,0x00, - 0x00,0x00,0x00,0xf8,0x0f,0xf0,0x00,0xfe,0xff,0xff,0x03,0x00,0x00,0x00,0x00, - 0x00,0xfc,0x07,0xf0,0x00,0xfc,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0xfe, - 0x03,0xf0,0x00,0xf8,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0xf0, - 0x00,0xf0,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0xf0,0x00,0xf0, - 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x80,0xff,0x00,0xf0,0x00,0xe0,0xff,0xff, - 0x3f,0x00,0x00,0x00,0x00,0xc0,0x7f,0x00,0xf0,0x00,0xc0,0xff,0xff,0x7f,0x00, - 0x00,0x00,0x00,0xe0,0x3f,0x00,0xf0,0x00,0x80,0xff,0xff,0xff,0x00,0x00,0x00, - 0x00,0xf0,0x1f,0x00,0xf0,0x00,0x80,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xf0, - 0x1f,0x00,0xf0,0x00,0x00,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xf8,0x0f,0x00, - 0xf0,0x00,0x00,0xfe,0xff,0xff,0x03,0x00,0x00,0x00,0xfc,0x07,0x00,0xf0,0x00, - 0x00,0xfc,0xff,0xff,0x07,0x00,0x00,0x00,0xfe,0x03,0x00,0xf0,0x00,0x00,0xfc, - 0xff,0xff,0x07,0x00,0x00,0x00,0xfe,0x03,0x00,0xf0,0x00,0x00,0xf8,0xff,0xff, - 0x0f,0x00,0x00,0x00,0xff,0x01,0x00,0xf0,0x00,0x00,0xf0,0xff,0xff,0x1f,0x00, - 0x00,0x80,0xff,0x00,0x00,0xf0,0x00,0x00,0xe0,0xff,0xff,0x3f,0x00,0x00,0xc0, - 0x7f,0x00,0x00,0xf0,0x00,0x00,0xe0,0xff,0xff,0x3f,0x00,0x00,0xe0,0x3f,0x00, - 0x00,0xf0,0x00,0x00,0xc0,0xff,0xff,0x7f,0x00,0x00,0xe0,0x3f,0x00,0x00,0xf0, - 0x00,0x00,0x80,0xff,0xff,0xff,0x00,0x00,0xf0,0x1f,0x00,0x00,0xf0,0x00,0x00, - 0x00,0xff,0xff,0xff,0x01,0x00,0xf8,0x0f,0x00,0x00,0xf0,0x00,0x00,0x00,0xff, - 0xff,0xff,0x01,0x00,0xfc,0x07,0x00,0x00,0xf0,0x00,0x00,0x00,0xfe,0xff,0xff, - 0x03,0x00,0xfe,0x03,0x00,0x00,0xf0,0x00,0x00,0x00,0xfc,0xff,0xff,0x07,0x00, - 0xfe,0x03,0x00,0x00,0xf0,0x00,0x00,0x00,0xf8,0xff,0xff,0x0f,0x00,0xff,0x01, - 0x00,0x00,0xf0,0x00,0x00,0x00,0xf8,0xff,0xff,0x0f,0x80,0xff,0x00,0x00,0x00, - 0xf0,0x00,0x00,0x00,0xf0,0xff,0xff,0x1f,0xc0,0x7f,0x00,0x00,0x00,0xf0,0x00, - 0x00,0x00,0xe0,0xff,0xff,0x3f,0xe0,0x3f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00, - 0xc0,0xff,0xff,0x7f,0xe0,0x3f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0xc0,0xff, - 0xff,0x7f,0xf0,0x1f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x80,0xff,0xff,0xff, - 0xf8,0x0f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xff,0xff,0x7f,0xfc,0x07, - 0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xfe,0xff,0x7f,0xfc,0x07,0x00,0x00, - 0x00,0xf0,0x00,0x00,0x00,0x00,0xfe,0xff,0x3f,0xfe,0x03,0x00,0x00,0x00,0xf0, - 0x00,0x00,0x00,0x00,0xfc,0xff,0x1f,0xff,0x01,0x00,0x00,0x00,0xf0,0x00,0x00, - 0x00,0x00,0xf8,0xff,0x8f,0xff,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00, - 0xf0,0xff,0xc7,0x7f,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf0,0xff, - 0xc7,0x7f,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xe0,0xff,0xe3,0x3f, - 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xc0,0xff,0xf1,0x7f,0x00,0x00, - 0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x80,0xff,0xf8,0xff,0x00,0x00,0x00,0x00, - 0xf0,0x00,0x00,0x00,0x00,0xc0,0x7f,0xfc,0xff,0x00,0x00,0x00,0x00,0xf0,0x00, - 0x00,0x00,0x00,0xc0,0x7f,0xfc,0xff,0x01,0x00,0x00,0x00,0xf0,0x00,0x00,0x00, - 0x00,0xe0,0x3f,0xfe,0xff,0x03,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf0, - 0x1f,0xff,0xff,0x07,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xf8,0x8f,0xff, - 0xff,0x07,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xfc,0xc7,0xff,0xff,0x0f, - 0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0xfc,0xc7,0xff,0xff,0x1f,0x00,0x00, - 0x00,0xf0,0x00,0x00,0x00,0x00,0xfe,0xe3,0xff,0xff,0x3f,0x00,0x00,0x00,0xf0, - 0x00,0x00,0x00,0x00,0xff,0xe1,0xff,0xff,0x3f,0x00,0x00,0x00,0xf0,0x00,0x00, - 0x00,0x80,0xff,0xc0,0xff,0xff,0x7f,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x80, - 0xff,0x80,0xff,0xff,0xff,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0xc0,0x7f,0x00, - 0xff,0xff,0xff,0x01,0x00,0x00,0xf0,0x00,0x00,0x00,0xe0,0x3f,0x00,0xff,0xff, - 0xff,0x01,0x00,0x00,0xf0,0x00,0x00,0x00,0xf0,0x1f,0x00,0xfe,0xff,0xff,0x03, - 0x00,0x00,0xf0,0x00,0x00,0x00,0xf8,0x0f,0x00,0xfc,0xff,0xff,0x07,0x00,0x00, - 0xf0,0x00,0x00,0x00,0xf8,0x0f,0x00,0xf8,0xff,0xff,0x0f,0x00,0x00,0xf0,0x00, - 0x00,0x00,0xfc,0x07,0x00,0xf8,0xff,0xff,0x0f,0x00,0x00,0xf0,0x00,0x00,0x00, - 0xfe,0x03,0x00,0xf0,0xff,0xff,0x1f,0x00,0x00,0xf0,0x00,0x00,0x00,0xff,0x01, - 0x00,0xe0,0xff,0xff,0x3f,0x00,0x00,0xf0,0x00,0x00,0x80,0xff,0x00,0x00,0xc0, - 0xff,0xff,0x7f,0x00,0x00,0xf0,0x00,0x00,0x80,0xff,0x00,0x00,0xc0,0xff,0xff, - 0x7f,0x00,0x00,0xf0,0x00,0x00,0xc0,0x7f,0x00,0x00,0x80,0xff,0xff,0xff,0x00, - 0x00,0xf0,0x00,0x00,0xe0,0x3f,0x00,0x00,0x00,0xff,0xff,0xff,0x01,0x00,0xf0, - 0x00,0x00,0xf0,0x1f,0x00,0x00,0x00,0xfe,0xff,0xff,0x03,0x00,0xf0,0x00,0x00, - 0xf8,0x0f,0x00,0x00,0x00,0xfe,0xff,0xff,0x03,0x00,0xf0,0x00,0x00,0xf8,0x0f, - 0x00,0x00,0x00,0xfc,0xff,0xff,0x07,0x00,0xf0,0x00,0x00,0xfc,0x07,0x00,0x00, - 0x00,0xf8,0xff,0xff,0x0f,0x00,0xf0,0x00,0x00,0xfe,0x03,0x00,0x00,0x00,0xf0, - 0xff,0xff,0x1f,0x00,0xf0,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xf0,0xff,0xff, - 0x1f,0x00,0xf0,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xe0,0xff,0xff,0x3f,0x00, - 0xf0,0x00,0x80,0xff,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0x7f,0x00,0xf0,0x00, - 0xc0,0x7f,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x00,0xf0,0x00,0xe0,0x3f, - 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x00,0xf0,0x00,0xf0,0x1f,0x00,0x00, - 0x00,0x00,0x00,0xff,0xff,0xff,0x01,0xf0,0x00,0xf0,0x1f,0x00,0x00,0x00,0x00, - 0x00,0xfe,0xff,0xff,0x03,0xf0,0x00,0xf8,0x0f,0x00,0x00,0x00,0x00,0x00,0xfc, - 0xff,0xff,0x07,0xf0,0x00,0xfc,0x07,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff, - 0x07,0xf0,0x00,0xfe,0x03,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0x0f,0xf0, - 0x00,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0x1f,0xf0,0x00,0xff, - 0x01,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0x3f,0xf0,0x80,0xff,0x00,0x00, - 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0x3f,0xf0,0xc0,0x7f,0x00,0x00,0x00,0x00, - 0x00,0x00,0xc0,0xff,0xff,0x7f,0xf0,0xe0,0x3f,0x00,0x00,0x00,0x00,0x00,0x00, - 0x80,0xff,0xff,0xff,0xf0,0xf0,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff, - 0xff,0xff,0xf1,0xf0,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff, - 0xf1,0xf8,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xf3,0xfc, - 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xf7,0xfe,0x03,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff}; diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/xlogo.xpm xmotd-1.17.2-arr1/xmotd-1.17.2/xlogo.xpm --- orig/xmotd-1.17.2/xmotd-1.17.2/xlogo.xpm Tue Jun 17 20:47:34 1997 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/xlogo.xpm Thu Jan 1 00:00:00 1970 @@ -1,107 +0,0 @@ -/* XPM */ -static char * xlogo_xpm[] = { -"100 100 4 1", -" c #333373733E3E", -". c #B6B6E2E20D0D", -"X c #9F9FB6B6CDCD", -"o c #000047470000", -" .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ", -"X .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX o", -"XX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oo", -"XXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooo", -"XXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooo", -"XXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo", -"XXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooo", -"XXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooooo", -"XXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooo", -"XXXXXXX ......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooX", -"XXXXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooooooX", -"XXXXXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooooooXX", -"XXXXXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooooooXXX", -"XXXXXXXXXX ......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooXXXX", -"XXXXXXXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooXXXXX", -"XXXXXXXXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooooooXXXXX", -"XXXXXXXXXXXX ......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooooooXXXXXX", -"XXXXXXXXXXXXX ......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooooooXXXXXXX", -"XXXXXXXXXXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooXXXXXXXX", -"XXXXXXXXXXXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooXXXXXXXXX", -"XXXXXXXXXXXXXXX ......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooooooXXXXXXXXX", -"XXXXXXXXXXXXXXXX ......XXXXXXXXXXXXXXXXXXXXXXXXXXXX oooooooXXXXXXXXXX", -"XXXXXXXXXXXXXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXXXX oooooooXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXX .......XXXXXXXXXXXXXXXXXXXXXXXX ooooooXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXX ......XXXXXXXXXXXXXXXXXXXXXXXX ooooooXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXX .......XXXXXXXXXXXXXXXXXXXXXX oooooooXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXX .......XXXXXXXXXXXXXXXXXXXX oooooooXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXX ......XXXXXXXXXXXXXXXXXXX oooooooXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXX ......XXXXXXXXXXXXXXXXX ooooooXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXX .......XXXXXXXXXXXXXXXX ooooooXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXX .......XXXXXXXXXXXXXX oooooooXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXX ......XXXXXXXXXXXXX oooooooXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXX ......XXXXXXXXXXX oooooooXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXX .......XXXXXXXXX ooooooXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXX ......XXXXXXXXX ooooooXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXX ......XXXXXXX oooooooXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXX ......XXXXX oooooooXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXX .......XXX ooooooXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......XX ooooooXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......X ooooooXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ...... oooooooXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX .... oooooooXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooo ooooooXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo ooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooo ooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooo oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooo oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooo ooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo oooo...XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooo o.......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooo ........XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo .......XXXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo .......XXXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo .......XXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo .......XXXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo .......XXXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo .......XXXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo .......XXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooo .......XXXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX oooooo .......XXXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooo .......XXXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooooo .......XXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooooX .......XXXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooooXX .......XXXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXXX ooooooooXXXX .......XXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXX oooooooooXXXXX ......XXXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXXX oooooooooXXXXXXX .......XXXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXXX ooooooooXXXXXXXX .......XXXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXXX ooooooooXXXXXXXXXX .......XXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXX ......XXXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXX .......XXXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXXX oooooooooXXXXXXXXXXXXXX .......XXXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXX .......XXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXX ......XXXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXX ......XXXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXX .......XXXXXXXXXXX", -"XXXXXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXX .......XXXXXXXXXX", -"XXXXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXX ......XXXXXXXXXX", -"XXXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXXXX ......XXXXXXXXX", -"XXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXXXXX .......XXXXXXXX", -"XXXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......XXXXXXXX", -"XXXXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......XXXXXXX", -"XXXXXXXXXXXXXX oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......XXXXXX", -"XXXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX .......XXXXX", -"XXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......XXXXX", -"XXXXXXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......XXXX", -"XXXXXXXXXXX oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......XXX", -"XXXXXXXXXX oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX .......XX", -"XXXXXXXXX oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......XX", -"XXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......X", -"XXXXXXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......", -"XXXXXXX oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ......", -"XXXXXX oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX .....", -"XXXXX oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ....", -"XXXX oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ...", -"XXXX ooooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ...", -"XXX oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ..", -"XX oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX .", -"X oooooooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ."}; diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/xmotd.8 xmotd-1.17.2-arr1/xmotd-1.17.2/xmotd.8 --- orig/xmotd-1.17.2/xmotd-1.17.2/xmotd.8 Fri Feb 14 00:31:04 2003 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/xmotd.8 Thu Jan 1 00:00:00 1970 @@ -1,560 +0,0 @@ -.\" $Id: xmotd.8,v 1.11 2003/02/14 00:31:02 elf Exp $" -.TH XMOTD 8 "Nov 24 1999" "X11 Release 6.4" -.SH NAME -xmotd \- message-of-the-day browser for X (and dumb terminals, -VT100, etc.) - -.SH SYNOPSIS -.B /usr/local/bin/xmotd -[\fBX-toolkit options\fP] [\fBxmotd-options\fP] \fIfile\fP -[\fIfile2\fP ... ] - -.B /usr/local/bin/xmotd -[\fBX-toolkit options\fP] [\fBxmotd-options\fP] \fIdirectory\fP - -.PP -or (in text-mode) - -.B /usr/local/bin/xmotd -[\fB-stampfile\fP \fIstamp-file\fP] [\fB-wakeup\fP \fIsleep-period\fP] -\fIfile\fP [\fIfile2\fP ...] - -.SH DESCRIPTION -.LP -\fBxmotd\fP is a utility program (for X11 and dumb terminals) that -can be executed during the login process to display pertinent -messages (i.e. the message of the day) or to periodically check, -while the user is logged in, whether one or more message files have -been modified and display them if they have. Under X11, it displays a -customizable bitmap in the top-left corner. It provides for up to 3 -lines of title-text (the length of the text depends on the size of -the font chosen). It has a \fI"Dismiss"\fP button below the bitmap -and a read-only text-widget that displays the message (or messages) -of the day. The date of the message (and optionally, the filename) is -displayed just above the text. - -.LP -.B xmotd -can be configured to run in various modes: to always pop-up after -login or to pop-up only when the motd changes; to pop-down -automatically (without user-intervention) after a specified delay; to -run in the background and periodically check if the motd has changed -and display it. By default, -.B xmotd -displays a message only if the file(s) was updated since the last -time the user read it. - -.LP -If -.B xmotd -has to display more than one file, the user is obliged to press the -\fI"Next Message"\fP button to view subsequent messages; the text of -the button changes to \fI"Dismiss"\fP when the last message is -displayed. - -.LP -.B xmotd -defaults to text-only mode (output to -.B stdout -when it cannot connect to an X display. This mode is useful for -running -.B xmotd -from user's -.I ~/.login -file in cases where they can also login via dialup. - -.LP -.B xmotd -can display messages marked-up with HTML and xpm colour pixmap -logos. Support for these must be configured at compile-time. - -.SH OPERATION -.LP -.B xmotd -is usually run from the system \fIXsession\fP file via xdm(1), CDE -login and/or from the user's -.I ~/.login -file. At sites where xdm is not used, \fBxmotd\fP may be run from the -user's -.I ~/.xinitrc -where a (possibly) malicious user may intentionally or accidently -remove the \fBxmotd\fP invocation from the file. - -.LP -When -.B xmotd -first runs, it creates a timestamp file (by default called -.I .xmotd -) in the user's home-directory. On subsequent invocations, -.B xmotd -uses the date of this file to decide whether or not the -message-of-the-day (motd) files have been updated. If the date of the -motd file is later than the date on the \fI~/.xmotd\fP file, then -.B xmotd -will display the motd file; otherwise it will silently exit (if there -are no more files to be displayed and if \fB-wakeup\fP was not -used). When invoked with \fB-wakeup\fP, xmotd daemonizes itself and -goes to sleep for the specified sleep-period, periodically waking-up -to see if the motds have changed and then displaying them. - -.LP -By default, -.B xmotd -pops-down only when the \fI"Dismiss"\fP button is clicked; the rest -of the login-procedure then continues. This interactive behaviour can -be overriden so -.B xmotd -will pop-down without user intervention, after a specified timeout -period. - -.SH OPTIONS -All the standard -.B X -options are valid. In addition, the following options, which may also -be set as resources in the app-defaults file (See RESOURCES), are -available: - -.TP 8 -.BI \-always - -overrides -.B xmotd -default behavior; the \fI~/.xmotd\fP time-stamp is ignored and the -message (or messages) is always displayed. Zero-length (empty) files -are displayed when this option is specified. - -.TP 8 -.BI \-atom " atom-name" - -register -.B xmotd -with name \fIatom-name\fP. By default, only one -.B xmotd -is allowed to run (per user). You can permit multiple instances of -.B xmotd -to run by giving each instance an unique name. -.B xmotd -will intern an atom with the X server, that combines the atom-name and -the user's login-id (e.g. \fI"xmotd.elf"\fP ; the default atom name -is \fI"xmotd"\fP); subsequent invocations of -.B xmotd -will check if this atom exists and exit if it does. - - -.TP 8 -.BI \-bitmaplogo " bitmap-filename" - -specifies that the bitmap \fIbitmap-filename\fP is to be displayed in -place of the default bitmap, the "X" logo. Ideally, the specified -bitmap should have a width and height of 100 pixels. If xpm support -is compiled-in, xpm colour pixmaps may be substituted instead. See -NOTES for additional details. - -.TP 8 -.BI \-browser " web-browser" - -specifies the path and filename of a web-browser to be used when an -URL is clicked (HTML version only). By default, \fIweb-browser\fP is -\fI"/usr/local/bin/netscape"\fP. See NOTES for additional details. - -.TP 8 -.BI \-help - -displays command-line options usage. - -.TP 8 -.BI \-paranoid - -(used with \fB-warnfile\fP) displays the warning message -unconditionally at every login (even when there are no messages to be -displayed). - -.TP 8 -.BI \-popdown " timeout" - -exit or pop-down without user intervention, \fItimeout\fP seconds -after being invoked. The user can dismiss \fBxmotd\fP at any time -before the timeout, by clicking on the \fI"Dismiss"\fP button. This -option is only valid at the initial login; it is ignored on -subsequent pop-ups when \fBxmotd\fP is invoked with \fB-wakeup\fP. - -.TP 8 -.BI \-showfilename - -displays the filename of the file currently being viewed (as it -appears on the command-line), alongside the date. - -.TP 8 -.BI \-stampfile " stamp-filename" - -overrides the default timestamp filename, \fI~/.xmotd\fP, and uses -\fIstamp-filename\fP instead. - -.TP 8 -.BI \-tail - -display the end of a file; the text is automatically scrolled so the -end of the file is visible. - -.TP 8 -.BI \-usedomains - -uses local domain-name based time-stamping in cases where user's -home-directories are shared (NFS mounted) across various domains. -Time-stamps are created (and checked) with appropriate domain-names -appended. - -.TP 8 -.BI \-warnfile " warning-filename" - -specifies a file containing a standard message used to warn users of -the consequences of deviance and sundry unlawful things they should -not even \fIthink\fP of doing on your network; your network's rules of -use, information about disk quotas, modem charges and printer -accounting fees (used with \fB-paranoid\fP). - -.TP 8 -.BI \-wakeup " sleep-period" - -causes \fBxmotd\fP to run in the background and wakeup periodically -every \fIsleep-period\fP hours to check whether the files have been -modified and therefore need to be (re-)displayed. The sleep period is -specified as a floating point number where the fractional portion -indicates the number of minutes. For example, a sleep-period of 0.25 -indicates 15 minutes (one quarter of an hour) and a sleep-period of -1.5 indicates one and one-half hours; the minimum (enforced) -sleep-period is 1 minute. The \fB-wakeup\fP option is useful at sites -where users with personal workstations never log-out. See NOTES for -additional details. - -.TP 8 -.I file [file2 ... ] - -one or more files to be displayed may be specified. The file(s) -contain the text of the message(s) of the day. If HTML support is -compiled-in the motd files should be marked-up with HTML. - -.TP 8 -.I directory - -Instead of supplying one or more files on the command-line, -\fBxmotd\fP may be supplied a \fIdirectory\fP containing file(s) to -be displayed. \fBxmotd\fP will scan the directory and display all the -files contained therein, that need to be displayed. This feature is -useful when used with the \fB-wakeup\fP option; upon waking-up, -\fBxmotd\fP will re-scan the directory for any files (including new -files that have been subsequently added) that need to be displayed. - -.SH EXAMPLES -.LP -Give \fBxmotd\fP a geometry option to tell it to pop-up at a location -other than 0,0 and read-in the message-of-the-day from the file -\fI/usr/local/motd\fP: -.nf - - xmotd -geometry +20+20 /usr/local/motd -.fi -.LP -Use a bigger window (900x600) and automatically position it (at -top-left corner at 20,20), always pop-up \fBxmotd\fP displaying the -contents of \fI/usr/local/motd\fP, ignoring the user's \fI~/.xmotd\fP -timestamp-file and pop-down after 20 seconds: -.nf - - xmotd -geom 900x600+20+20 -always -popdown 20 /usr/local/motd -.fi - -.LP -Use a custom bitmap in the file \fI/usr/local/xmotd.bm\fP: -.nf - - xmotd -geom +5+5 -bitmaplogo /usr/local/xmotd.bm /usr/local/motd -.fi - -.LP -In the following example, all the files in \fI/usr/local/messages/\fP will -be checked for modification times greater than the time-stamp and -only those files will be displayed and every eight and a half hours, -\fBxmotd\fP will check if any files have changed (or new ones added) -and display them if necessary: -.nf - - xmotd -geom +5+5 -wakeup 8.5 /usr/local/messages/ -.fi - -To display a warning-message every time the user logs-in (even when -no messages need to be displayed), and to display the filenames of -the files being viewed, use: -.nf - - xmotd -geom +5+5 -warnfile /usr/local/WARNING -paranoid \\ - -showfilename /usr/local/motds/ -.fi - -X resources may be changed from the command-line using the \fB-xrm\fP -option. This example (typed as a single line) illustrates how -\fBxmotd\fP can be customized exclusively from the command-line: - -.nf - - /usr/local/bin/xmotd -always \\ - -xrm "*title.label: Top 10 Disk Hogs\\n As of midnight\\n " \\ - -xrm "*title.foreground: yellow" \\ - -xrm "*form.background: red" \\ - -xrm "*title.background: red" \\ - -xrm "*logo.background: pink" \\ - -xrm "*text*font: -adobe-times-bold-*-normal-*-*-180-*" \\ - -geometry 500x650-1-1 \\ - -bitmaplogo /usr/common/choke.xbm - -popdown 10 \\ - /usr/common/accounting/top & - -.fi - -.SH RESOURCES - -editres(1) may be used to edit resources. The application class-name -is \fIXMotd\fP. - -.LP -The resource: \fIXMotd*Always\fP (set to either \fBTrue\fP or -\fBFalse\fP) is equivalent to the \fB-always\fP command-line option. - -.LP -The resource: \fIXMotd*Atom\fP (set to the name of the atom -\fBxmotd\fP is registered with) is equivalent to the \fB-atom\fP -command-line option. - -.LP -The resource: \fIXMotd*BitmapLogo\fP (set to the path and filename of -the bitmap/pixmap-file) is equivalent to the \fB-bitmaplogo\fP -command-line option. - -.LP -The resource: \fIXMotd*Browser\fP (set to the path and filename of -the browser to be used when users click on an URL (HTML version -only)) is equivalent to the \fB-browser\fP command-line option. - -.LP -The resource: \fIXMotd*Paranoid\fP (set to \fBTrue/False\fP) is -equivalent to the \fB-paranoid\fP command-line option. - -.LP -The resource: \fIXMotd*Popdown\fP (set to the number of seconds) is -equivalent to the \fB-popdown\fP command-line option. - -.LP -The resource: \fIXMotd*UseDomains\fP (set to \fBTrue/False\fP) is -equivalent to the \fB-usedomains\fP command-line option. - -.LP -The resource: \fIXMotd*ShowFilename\fP (set to \fBTrue/False\fP) is -equivalent to the \fB-showfilename\fP command-line option. - -.LP -The resource: \fIXMotd*Warnfile\fP (set to the path and filename of -the warning-file) is equivalent to the \fB-warnfile\fP command-line -option. - -.LP -The resource: \fIXMotd*Tail\fP (set to \fBTrue/False\fP) is -equivalent to the \fB-tail\fP command-line option. - -.LP -The resource: \fIXMotd*Wakeup\fP (set to an floating-point number -representing hours) is equivalent to the \fB-wakeup\fP command-line -option. - -.LP -The resource: \fIXMotd*title.label\fP (set to a possibly multi-line -string) may be used to customize the title. - -By default, the title is the single line:\fI"Message Of The -Day\\n\\n\\n"\fP (the 2-character sequence, \fI"\\n"\fP, indicates a -carriage-return). - -For example, if you want a 2 line title that reads: -.nf - - This is the - Message of the Day -.fi - -the resource can be specified as: -.nf - - *title.label: \\ This is the\\nMessage of the Day\\n\\n -.fi - -Note that the first backslash quotes the leading spaces that indent -the words, \fB"This is the"\fP. - - -.SH WIDGET HIERARCHY - -The widget hierarchy is as follows (Class-name & object-name): -.nf -.ta .5i 1.0i 1.5i 2.0i -XMotd xmotd - Form form - Label logo - Label title - Label hline - Label info - Command quit - Text text \fBOR\fP Html text -.fi - -.SH FILES -\fI$ProjectRoot/lib/X11/xdm/Xsession\fP - -(where \fI$ProjectRoot\fP is \fB/usr/X11R6\fP or, perhaps \fB/usr/X11\fP). - -For systems running CDE put a script that invokes \fBxmotd\fP in -\fI/etc/dt/config/Xsession.d/\fP - -\fI$HOME/.xmotd\fP (default timestamp filename) - -\fI$HOME/.login\fP - -.TE -.SH SEE ALSO -.BR X(1), -.BR xdm(1), -.BR editres(1), -.BR login(1), -.BR xv(l), -.BR gimp(l), -.BR xpaint(l), -.BR cat(1), -.BR less(l) - -.SH NOTES - -The \fB-always\fP option is considered fascist; it is provided merely -for completeness and for testing purposes. - -If xpm support is compiled-in, \fBxmotd -help\fP will print the words -\fI"bitmap/pixmap"\fP for the \fB-bitmaplogo\fP description instead -of just \fI"bitmap"\fP. - -Under dumb-terminal mode, all command-line options are ignored with -the exception of \fB-stampfile\fP and \fB-wakeup\fP; the -\fB-always\fP option is equivalent to cat'ing the motd from the -\fI~/.login\fP file; and \fB-popdown\fP is not really relevant. Both -\fB-warnfile\fP and \fB-paranoid\fP may be simulated with appropriate -cat(1) and more(1) commands. - -\fBxmotd\fP processes invoked with \fB-wakeup\fP will continue -sleeping, "S" in the ps(1) status field, after the user has -logged-out until the sleep timeout expires. Only when \fBxmotd\fP -wakes-up, will it detect that the user has logged-out and -exit. \fBxmotd\fP's logout-detection routine relies on the xdm(1) -support scripts \fBGiveConsole\fP (which chown's \fB/dev/console\fP -to the user) and \fBTakeConsole\fP (which chown's \fB/dev/console\fP -back to root) setting the correct permissions and ownership on -\fB/dev/console\fP. When \fBxmotd\fP wakes-up, it attempts to open(2) -\fB/dev/console\fP for reading; if this open fails, it is an -indication that the user has logged out because \fBTakeConsole\fP has -changed ownership of the console. - -The \fB-browser\fP option was originally called \fB-netscape\fP; it -was renamed to be more generic. When initially run, the browser is -invoked as: - -.nf - /usr/local/bin/netscape %s - -.fi - -where \fB%s\fP is replaced by the selected URL. Subsequent URLs will -be displayed in the already running browser using the syntax: - -.nf - /usr/local/bin/netscape -remote openURL(%s) - -.fi - -You may substitute a browser of your choice for \fBnetscape\fP, if it -supports this syntax. - -.SH BUGS - -There are no provisions for displaying embedded images in the HTML -version of \fBxmotd\fP (until a stable XmHTML widget is available, or -perhaps when \fBxmotd\fP is ported to the GTK). - -At least one other. - -.SH QUOTES -.nf - - \fI...and our lives are forever changed - we will never be the same - the more you change the less you feel\fP - - --\fBTonight, tonight\fP, - "Mellon Collie And The Infinite Sadness" - Billy Corgan, The Smashing Pumpkins - - - \fIOmnia mutantur, nos et mutamur in illis. - (All things change, and we change with them).\fP - - --Matthias Borbonius: - \fBDeliciae Poetarum Germanorum\fP, i. 685 - - - \fITo everything there is a season, - And a time to every purpose under heaven.\fP - - --Ecclesiastes 3:1-4 -.fi - - -.SH AUTHORS -Luis Fernandes is the primary author and maintainer. - -Richard Deal contributed the directory-scanning code. - -Stuart A. Harvey contributed the URL support -code for the HTML version. - -David M. Ronis contributed code to support -xpm logos. - -.SH COPYRIGHT - -Copyright 1993 (as xbanner, no public release) - -Copyright 1994-97, 1999, 2001, 2003 Luis A. Fernandes - -Permission to use, copy, hack, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and -that both that copyright notice and this permission notice appear in -supporting documentation. - -This application is presented as is without any implied or written -warranty. - -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. - -The HTML widget Copyright 1993, Board of Trustees of the -University of Illinois. See the file libhtmlw/HTML.c for the complete -text of the NCSA copyright. - -NOTE: THE HTML WIDGET IS NOT DISTRIBUTED IN THE "LITE" VERSION OF THE -xmotd DISTRIBUTION, WHICH IS THEREFORE FULLY COMPLIANT WITH THE GPL. diff -Naur orig/xmotd-1.17.2/xmotd-1.17.2/xmotd.c xmotd-1.17.2-arr1/xmotd-1.17.2/xmotd.c --- orig/xmotd-1.17.2/xmotd-1.17.2/xmotd.c Fri Feb 14 18:09:45 2003 +++ xmotd-1.17.2-arr1/xmotd-1.17.2/xmotd.c Thu Jan 1 00:00:00 1970 @@ -1,270 +0,0 @@ -/*$Id: xmotd.c,v 1.20 2003/02/14 00:37:38 elf Exp $*/ - -/* - * Copyright 1994-97, 2003 Luis Fernandes - * - * Permission to use, copy, hack, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. This application is presented as is - * without any implied or written warranty. - * - */ -/* - * 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. - * - */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#ifdef MOTIF - -#include -#include -#include -#include -#include - -#ifdef HAVE_HTML -#include -#endif - -#else - -#include -#include -#include -#include -#include - -#ifdef HAVE_HTML -#include -#endif - -#endif - -#include "maindefs.h" -#include "main.h" - -extern time_t motdChanged(); -extern messageptr freeMessage(); -extern Pixmap icon_pixmap; -extern char timeStamp[256]; - -extern messageptr msgslist;/* list of pointers to the motds requested - to be displayed */ -extern app_res_t app_res; -extern XtAppContext app_con; -extern XtIntervalId timer; - -char *txtbuf; /* file is loaded into this malloc'd pointer */ - - -void -/*ARGSUSED*/ -nextMessage(Widget w, caddr_t call_data, caddr_t client_data) -{ - - char buffer[256]; - time_t ftime= time((time_t *)NULL); - extern Widget info, quit; - -#ifdef MOTIF - XmString xmstr; -#endif - -/* fprintf(stderr,"nextMessage()\n"); */ - - if (!msgslist) - return; - - memset(buffer, 0, 256); - displayMessage(msgslist->file); - - if(app_res.showfilename) /*show the filename */ - { - sprintf(buffer, "%s (%s)", ctime(&ftime), msgslist->file); - } - else - { - sprintf(buffer, "%s", ctime(&ftime)); - } - - *strchr(buffer, '\n')=' '; /* junk the \n at the end*/ - -#ifdef MOTIF - xmstr=XmStringCreateLocalized(buffer); - XtVaSetValues(info, XmNlabelString, xmstr, NULL); - XmStringFree(xmstr); -#else - XtVaSetValues(info, XtNlabel, buffer, NULL); -#endif - - /* next time through the loop, we continue at the next message*/ - msgslist = freeMessage(msgslist); - - /*figure out if we are displaying the last message; - if we are, then change the button-label to - "Dismiss" and re-direct the callback to Quit()*/ - if(!msgslist) - { - extern void Quit(Widget w, caddr_t call_data, caddr_t client_data) ; - -/* fprintf(stderr, "msgindex=%d, displayed %s (LAST MESSAGE)\n", msgindex, buffer);*/ - -#ifdef MOTIF - xmstr=XmStringCreateLocalized(LAST_MESSAGE_LABEL); - XtVaSetValues(quit, XmNlabelString, xmstr, NULL); - XmStringFree(xmstr); - - XtRemoveAllCallbacks(quit, XmNactivateCallback); - - XtAddCallback(quit, XmNactivateCallback, - (XtCallbackProc)Quit, 0); -#else - XtVaSetValues(quit, XtNlabel, LAST_MESSAGE_LABEL, NULL); - XtRemoveAllCallbacks(quit, XtNcallback); - - XtAddCallback(quit, XtNcallback, - (XtCallbackProc)Quit, 0); -#endif - if(app_res.pto) - timer=XtAppAddTimeOut(app_con, (unsigned long)(app_res.pto*1000), - (XtTimerCallbackProc)Quit, (caddr_t) NULL); - return; - } - if(app_res.pto) - timer=XtAppAddTimeOut(app_con, (unsigned long)(app_res.pto*1000), - (XtTimerCallbackProc)nextMessage, (caddr_t) NULL); -} - -void -revisitMessagesAndDisplay(int numsg) -{ - extern int gargc; - extern char **gargv; - extern Widget topLevel, quit; - extern void Quit(Widget w, caddr_t call_data, caddr_t client_data); - - /* fprintf(stderr,"revisitMessagesAndDisplay()\n");*/ - - updateTimeStamp(getTimeStampName()); -/* fprintf(stderr, "Updating timestamp now.\n"); */ - - if(numsg>1) - { -#ifdef MOTIF - XmString xmstr; - xmstr=XmStringCreateLocalized(NEXT_MESSAGE_LABEL); - XtVaSetValues(quit, XmNlabelString, xmstr, NULL); - XmStringFree(xmstr); - - XtRemoveAllCallbacks(quit,XmNactivateCallback); - - XtAddCallback(quit, XmNactivateCallback, - (XtCallbackProc)nextMessage, 0); -#else - XtVaSetValues(quit, XtNlabel, NEXT_MESSAGE_LABEL, NULL); - XtRemoveAllCallbacks(quit,XtNcallback); - XtAddCallback(quit, XtNcallback, - (XtCallbackProc)nextMessage, 0); - -#endif - } - /* find and display 1st msg*/ - nextMessage((Widget)NULL, (caddr_t)NULL, (caddr_t)NULL); - XMapRaised(XtDisplay(topLevel), XtWindow(topLevel)); - XFlush(XtDisplay(topLevel)); - -} - - -int -displayMessage(char *filename) -{ - FILE *fp; - struct stat motdstat; - extern Widget text; - -/* fprintf(stderr,"displayMessage()\n"); */ - -#ifdef MOTIF - XmString xmstr; -#endif - -/* memset((char *)(&motdstat), 0, sizeof(struct stat));*/ - - if((fp=fopen(filename,"r"))==NULL) /* Read it in...*/ - { - perror(filename); - return(0); /* no file by this name*/ - } - - stat(filename,&motdstat); - if(txtbuf) free(txtbuf); - - txtbuf=(char *)calloc(1, (motdstat.st_size+1)*sizeof(char)); - - if(!txtbuf) - { - extern XtAppContext app_con; - - perror("xmotd"); - XtDestroyApplicationContext(app_con); - exit(2); - } - - fread(txtbuf,(int)motdstat.st_size,1,fp); - - fclose(fp); - -#ifdef MOTIF - -#ifdef HAVE_HTML - - HTMLSetText(text,txtbuf,NULL,NULL,0,NULL,NULL); - -#else - XtVaSetValues(text, XmNvalue, txtbuf, NULL); -#endif - -#else - -#ifdef HAVE_HTML - - HTMLSetText(text,txtbuf,NULL,NULL,0,NULL,NULL); - -#else - XtVaSetValues(text, XtNstring, txtbuf, NULL); -#endif - -#endif - - return(1); - -}/* displayMessage*/ - diff -Naur orig/xmotd-1.17.2/xmotd.8 xmotd-1.17.2-arr1/xmotd.8 --- orig/xmotd-1.17.2/xmotd.8 Fri Feb 14 00:31:04 2003 +++ xmotd-1.17.2-arr1/xmotd.8 Fri Apr 25 18:54:09 2003 @@ -138,7 +138,8 @@ the user's login-id (e.g. \fI"xmotd.elf"\fP ; the default atom name is \fI"xmotd"\fP); subsequent invocations of .B xmotd -will check if this atom exists and exit if it does. +will check if this atom exists and exit if it does. If \fIatom-name\fP +is given the special value "none", then no atom checking will be performed. .TP 8 @@ -228,6 +229,23 @@ additional details. .TP 8 +.BI \-fork " fork-policy" + +selects from one of four possible forking policies. If +\fIfork-policy\fP is 0, \fBxmotd\fP will never fork itself into the +background. If 1, it will fork only after going into "sleep mode" +(after blocking while displaying any current messages). If 2, it will +fork immediately if \fB-wakeup\fP is set (the default behavior). If 3, +\fBxmotd\fP will unconditionally fork into the background. + +.TP 8 +.BI \-locfile " file" + +the file used to determine if the user has logged out. If the file +is removed or becomes owned by someone other than the invoking user, +\fBxmotd\fP will exit on next waking. The default is \fB/dev/console\fP. + +.TP 8 .I file [file2 ... ] one or more files to be displayed may be specified. The file(s) @@ -446,17 +464,17 @@ cat(1) and more(1) commands. \fBxmotd\fP processes invoked with \fB-wakeup\fP will continue -sleeping, "S" in the ps(1) status field, after the user has -logged-out until the sleep timeout expires. Only when \fBxmotd\fP -wakes-up, will it detect that the user has logged-out and -exit. \fBxmotd\fP's logout-detection routine relies on the xdm(1) -support scripts \fBGiveConsole\fP (which chown's \fB/dev/console\fP -to the user) and \fBTakeConsole\fP (which chown's \fB/dev/console\fP -back to root) setting the correct permissions and ownership on -\fB/dev/console\fP. When \fBxmotd\fP wakes-up, it attempts to open(2) -\fB/dev/console\fP for reading; if this open fails, it is an -indication that the user has logged out because \fBTakeConsole\fP has -changed ownership of the console. +sleeping, "S" in the ps(1) status field, after the user has logged-out +until the sleep timeout expires. Only when \fBxmotd\fP wakes-up, will +it detect that the user has logged-out and exit. \fBxmotd\fP's default +logout-detection routine relies on the xdm(1) support scripts +\fBGiveConsole\fP (which chown's \fB/dev/console\fP to the user) and +\fBTakeConsole\fP (which chown's \fB/dev/console\fP back to root) +setting the correct permissions and ownership on \fB/dev/console\fP +(see, however, the \fB-locfile\fP option). When \fBxmotd\fP wakes-up, +it attempts to stat(2) \fB/dev/console\fP; if this fails or the owner +has changed, it is an indication that the user has logged out because +\fBTakeConsole\fP has changed ownership of the console. The \fB-browser\fP option was originally called \fB-netscape\fP; it was renamed to be more generic. When initially run, the browser is