Comment: These are patches to produce the Andrew component of the X.V11R4 distribution, patch level 6 Andrew-Patch: 6 Date: Fri, 27 Jul 1990 14:45:35 -0400 (EDT) Date-span: 90/4/3 12:12:08 through 90/7/27 12:42:29 Bugs addressed: Count of patched files: 472 SPECIAL PATCH NOTES: You must create the directory ./atk/console/stats/i386_mach by hand before you can patch. You must create the directory ./atk/console/stats/rs_aix31 by hand before you can patch. You must create the directory ./config/i386_mach by hand before you can patch. You must create the directory ./config/ps_aix12 by hand before you can patch. You must create the directory ./config/rs_aix31 by hand before you can patch. You must create the directory ./contrib/time by hand before you can patch. You must create the directory ./overhead/class/machdep/aix_31 by hand before you can patch. You must create the directory ./overhead/class/machdep/i386_mach by hand before you can patch. *** patchlevel.h Wed Apr 11 14:16:57 1990 --- patchlevel.h.NEW Fri Jul 27 13:00:51 1990 *************** *** 1 **** ! This is the Andrew component of the X.V11R4 distribution, patch level 5 --- 1 ---- ! This is the Andrew component of the X.V11R4 distribution, patch level 6 No differences encountered *** config/ImakeMacros.d Wed Nov 22 11:28:26 1989 --- config/ImakeMacros.d.NEW Wed Jun 13 16:43:34 1990 *************** *** 1,4 **** ! \begindata{text,268720820} \textdsversion{12} \template{default} \define{italic --- 1,4 ---- ! \begindata{text,269113888} \textdsversion{12} \template{default} \define{italic *************** *** 103,111 **** window. }\ ! \begindata{bp,268773804} ! \enddata{bp,268773804} ! \view{bpv,268773804,0,0,0} \chapter{1 Notes} --- 103,111 ---- window. }\ ! \begindata{bp,269104832} ! \enddata{bp,269104832} ! \view{bpv,269104832,0,0,0} \chapter{1 Notes} *************** *** 176,184 **** Imakefiles MUST end with a newline} ! \begindata{bp,268773712} ! \enddata{bp,268773712} ! \view{bpv,268773712,1,0,0} \chapter{2 Standard and often used Make rules} --- 176,184 ---- Imakefiles MUST end with a newline} ! \begindata{bp,269104764} ! \enddata{bp,269104764} ! \view{bpv,269104764,1,0,0} \chapter{2 Standard and often used Make rules} *************** *** 255,263 **** \fieldcontent{Use only in conjunction with InstallHelpAlias() rule} ! \begindata{bp,268853496} ! \enddata{bp,268853496} ! \view{bpv,268853496,2,0,0} \section{2.2 Compilation rules} --- 255,263 ---- \fieldcontent{Use only in conjunction with InstallHelpAlias() rule} ! \begindata{bp,269104696} ! \enddata{bp,269104696} ! \view{bpv,269104696,2,0,0} \section{2.2 Compilation rules} *************** *** 311,319 **** ! \begindata{bp,268853368} ! \enddata{bp,268853368} ! \view{bpv,268853368,3,0,0} \subsection{2.2.2 LibraryTarget} --- 311,319 ---- ! \begindata{bp,269104628} ! \enddata{bp,269104628} ! \view{bpv,269104628,3,0,0} \subsection{2.2.2 LibraryTarget} *************** *** 358,366 **** $(AR) $@ objs ! $(RANLIB) $@} ! ! \fieldheader{Use:} \fieldcontent{Use whenever a library archive file (*.a) is to be generated --- 358,364 ---- $(AR) $@ objs ! } \fieldheader{Use:} \fieldcontent{Use whenever a library archive file (*.a) is to be generated *************** *** 368,376 **** ! \begindata{bp,268773380} ! \enddata{bp,268773380} ! \view{bpv,268773380,4,0,0} \subsection{2.2.3 TestProgramTarget} --- 366,374 ---- ! \begindata{bp,269104556} ! \enddata{bp,269104556} ! \view{bpv,269104556,4,0,0} \subsection{2.2.3 TestProgramTarget} *************** *** 420,428 **** \fieldheader{Use:} ! \begindata{bp,268773252} ! \enddata{bp,268773252} ! \view{bpv,268773252,5,0,0} \section{2.3 Cleanup and dependency generating rules} --- 418,426 ---- \fieldheader{Use:} ! \begindata{bp,268677288} ! \enddata{bp,268677288} ! \view{bpv,268677288,5,0,0} \section{2.3 Cleanup and dependency generating rules} *************** *** 498,506 **** things like OS-type differences} ! \begindata{bp,268773124} ! \enddata{bp,268773124} ! \view{bpv,268773124,6,0,0} \subsection{2.3.3 MkdirTarget} --- 496,504 ---- things like OS-type differences} ! \begindata{bp,269183564} ! \enddata{bp,269183564} ! \view{bpv,269183564,6,0,0} \subsection{2.3.3 MkdirTarget} *************** *** 556,564 **** ! \begindata{bp,268772996} ! \enddata{bp,268772996} ! \view{bpv,268772996,7,0,0} \section{2.4 Installation rules} --- 554,562 ---- ! \begindata{bp,269104412} ! \enddata{bp,269104412} ! \view{bpv,269104412,7,0,0} \section{2.4 Installation rules} *************** *** 638,646 **** different name than what it already has.} ! \begindata{bp,268772856} ! \enddata{bp,268772856} ! \view{bpv,268772856,8,0,0} \subsection{2.4.3 InstallDocs} --- 636,644 ---- different name than what it already has.} ! \begindata{bp,268677144} ! \enddata{bp,268677144} ! \view{bpv,268677144,8,0,0} \subsection{2.4.3 InstallDocs} *************** *** 721,729 **** } ! \begindata{bp,268840416} ! \enddata{bp,268840416} ! \view{bpv,268840416,9,0,0} \subsection{2.4.5 InstallMultiple} --- 719,727 ---- } ! \begindata{bp,269104316} ! \enddata{bp,269104316} ! \view{bpv,269104316,9,0,0} \subsection{2.4.5 InstallMultiple} *************** *** 769,777 **** ! \begindata{bp,268840188} ! \enddata{bp,268840188} ! \view{bpv,268840188,10,0,0} \subsection{2.4.6 InstallByPattern} --- 767,775 ---- ! \begindata{bp,268677024} ! \enddata{bp,268677024} ! \view{bpv,268677024,10,0,0} \subsection{2.4.6 InstallByPattern} *************** *** 897,905 **** } ! \begindata{bp,268839960} ! \enddata{bp,268839960} ! \view{bpv,268839960,11,0,0} \subsection{2.4.9 InstallLibrary} --- 895,903 ---- } ! \begindata{bp,268676980} ! \enddata{bp,268676980} ! \view{bpv,268676980,11,0,0} \subsection{2.4.9 InstallLibrary} *************** *** 977,985 **** ! \begindata{bp,268839832} ! \enddata{bp,268839832} ! \view{bpv,268839832,12,0,0} \subsection{2.4.11 InstallHardLink} --- 975,983 ---- ! \begindata{bp,268676936} ! \enddata{bp,268676936} ! \view{bpv,268676936,12,0,0} \subsection{2.4.11 InstallHardLink} *************** *** 1038,1046 **** ! \begindata{bp,268839704} ! \enddata{bp,268839704} ! \view{bpv,268839704,13,0,0} \chapter{3 Less standard, or less often used Make rules} --- 1036,1044 ---- ! \begindata{bp,268676892} ! \enddata{bp,268676892} ! \view{bpv,268676892,13,0,0} \chapter{3 Less standard, or less often used Make rules} *************** *** 1104,1112 **** ! \begindata{bp,268839576} ! \enddata{bp,268839576} ! \view{bpv,268839576,14,0,0} \subsection{3.1.3 NormalAsmPPRule} --- 1102,1110 ---- ! \begindata{bp,268676848} ! \enddata{bp,268676848} ! \view{bpv,268676848,14,0,0} \subsection{3.1.3 NormalAsmPPRule} *************** *** 1171,1179 **** ! \begindata{bp,268839448} ! \enddata{bp,268839448} ! \view{bpv,268839448,15,0,0} \subsection{3.1.5 NormalScribeRule} --- 1169,1177 ---- ! \begindata{bp,268676804} ! \enddata{bp,268676804} ! \view{bpv,268676804,15,0,0} \subsection{3.1.5 NormalScribeRule} *************** *** 1200,1208 **** - useful for printed documentation.} ! \begindata{bp,268839320} ! \enddata{bp,268839320} ! \view{bpv,268839320,16,0,0} \section{3.2 Compilation rules} --- 1198,1206 ---- - useful for printed documentation.} ! \begindata{bp,268676760} ! \enddata{bp,268676760} ! \view{bpv,268676760,16,0,0} \section{3.2 Compilation rules} *************** *** 1250,1258 **** ! \begindata{bp,268839192} ! \enddata{bp,268839192} ! \view{bpv,268839192,17,0,0} \subsection{3.2.2 YaccWithReplacement} --- 1248,1256 ---- ! \begindata{bp,268676716} ! \enddata{bp,268676716} ! \view{bpv,268676716,17,0,0} \subsection{3.2.2 YaccWithReplacement} *************** *** 1340,1348 **** \fieldheader{Use:} ! \begindata{bp,268839064} ! \enddata{bp,268839064} ! \view{bpv,268839064,18,0,0} \subsection{3.2.4 NCYaccWithHeader} --- 1338,1346 ---- \fieldheader{Use:} ! \begindata{bp,268676672} ! \enddata{bp,268676672} ! \view{bpv,268676672,18,0,0} \subsection{3.2.4 NCYaccWithHeader} *************** *** 1401,1409 **** \fieldcontent{For simple lex processing - NC = Not Compiled. } ! \begindata{bp,268838936} ! \enddata{bp,268838936} ! \view{bpv,268838936,19,0,0} \subsection{3.2.6 CppAndFilter} --- 1399,1407 ---- \fieldcontent{For simple lex processing - NC = Not Compiled. } ! \begindata{bp,268676628} ! \enddata{bp,268676628} ! \view{bpv,268676628,19,0,0} \subsection{3.2.6 CppAndFilter} *************** *** 1471,1479 **** filenames. This simply cats them together. } ! \begindata{bp,268838844} ! \enddata{bp,268838844} ! \view{bpv,268838844,20,0,0} \subsection{3.2.8 TagsTarget} --- 1469,1477 ---- filenames. This simply cats them together. } ! \begindata{bp,269228700} ! \enddata{bp,269228700} ! \view{bpv,269228700,20,0,0} \subsection{3.2.8 TagsTarget} *************** *** 1501,1509 **** ! \begindata{bp,268838752} ! \enddata{bp,268838752} ! \view{bpv,268838752,21,0,0} \chapter{4 ATK compilation rules} --- 1499,1507 ---- ! \begindata{bp,269195700} ! \enddata{bp,269195700} ! \view{bpv,269195700,21,0,0} \chapter{4 ATK compilation rules} *************** *** 1558,1566 **** and/or .do files} ! \begindata{bp,268838660} ! \enddata{bp,268838660} ! \view{bpv,268838660,22,0,0} \section{4.2 Compilation rules} --- 1556,1564 ---- and/or .do files} ! \begindata{bp,268676512} ! \enddata{bp,268676512} ! \view{bpv,268676512,22,0,0} \section{4.2 Compilation rules} *************** *** 1610,1618 **** ! \begindata{bp,268862188} ! \enddata{bp,268862188} ! \view{bpv,268862188,23,0,0} \subsection{4.2.2 DynamicMultiObject} --- 1608,1616 ---- ! \begindata{bp,268676468} ! \enddata{bp,268676468} ! \view{bpv,268676468,23,0,0} \subsection{4.2.2 DynamicMultiObject} *************** *** 1661,1669 **** ! \begindata{bp,268862056} ! \enddata{bp,268862056} ! \view{bpv,268862056,24,0,0} \section{4.3 Installation rules} --- 1659,1667 ---- ! \begindata{bp,269220448} ! \enddata{bp,269220448} ! \view{bpv,269220448,24,0,0} \section{4.3 Installation rules} *************** *** 1877,1885 **** the same destination directory (a separate one for each ex* directory) } ! \begindata{bp,268861928} ! \enddata{bp,268861928} ! \view{bpv,268861928,25,0,0} \chapter{5 Font rules } --- 1875,1883 ---- the same destination directory (a separate one for each ex* directory) } ! \begindata{bp,269195600} ! \enddata{bp,269195600} ! \view{bpv,269195600,25,0,0} \chapter{5 Font rules } *************** *** 2009,2017 **** (Installs font as a link if LINKINSTALL_ENV is defined)} ! \begindata{bp,268861800} ! \enddata{bp,268861800} ! \view{bpv,268861800,26,0,0} \section{5.2 Compilation rules} --- 2007,2015 ---- (Installs font as a link if LINKINSTALL_ENV is defined)} ! \begindata{bp,268676352} ! \enddata{bp,268676352} ! \view{bpv,268676352,26,0,0} \section{5.2 Compilation rules} *************** *** 2106,2114 **** (replaces WMFontRule and XFontRule) } ! \begindata{bp,268861708} ! \enddata{bp,268861708} ! \view{bpv,268861708,27,0,0} \chapter{6 Internal (to template) rules} --- 2104,2112 ---- (replaces WMFontRule and XFontRule) } ! \begindata{bp,269216276} ! \enddata{bp,269216276} ! \view{bpv,269216276,27,0,0} \chapter{6 Internal (to template) rules} *************** *** 2170,2178 **** \fieldcontent{Used only when LINKINSTALL_ENV is set} ! \begindata{bp,268861616} ! \enddata{bp,268861616} ! \view{bpv,268861616,28,0,0} \section{6.2 Cleanup rule} --- 2168,2176 ---- \fieldcontent{Used only when LINKINSTALL_ENV is set} ! \begindata{bp,269216232} ! \enddata{bp,269216232} ! \view{bpv,269216232,28,0,0} \section{6.2 Cleanup rule} *************** *** 2255,2263 **** \fieldheader{Use:} ! \begindata{bp,268861524} ! \enddata{bp,268861524} ! \view{bpv,268861524,29,0,0} \section{6.4 Subdir rules} --- 2253,2261 ---- \fieldheader{Use:} ! \begindata{bp,269245100} ! \enddata{bp,269245100} ! \view{bpv,269245100,29,0,0} \section{6.4 Subdir rules} *************** *** 2329,2337 **** ! \begindata{bp,268861432} ! \enddata{bp,268861432} ! \view{bpv,268861432,30,0,0} \subsection{6.4.3 InstallSubdirs} --- 2327,2335 ---- ! \begindata{bp,269195500} ! \enddata{bp,269195500} ! \view{bpv,269195500,30,0,0} \subsection{6.4.3 InstallSubdirs} *************** *** 2404,2412 **** ! \begindata{bp,268861340} ! \enddata{bp,268861340} ! \view{bpv,268861340,31,0,0} \subsection{6.4.5 InstallAliasSubdirs} --- 2402,2410 ---- ! \begindata{bp,269216116} ! \enddata{bp,269216116} ! \view{bpv,269216116,31,0,0} \subsection{6.4.5 InstallAliasSubdirs} *************** *** 2479,2487 **** ! \begindata{bp,268861248} ! \enddata{bp,268861248} ! \view{bpv,268861248,32,0,0} \subsection{6.4.7 WorldInstallSubdirs} --- 2477,2485 ---- ! \begindata{bp,269240928} ! \enddata{bp,269240928} ! \view{bpv,269240928,32,0,0} \subsection{6.4.7 WorldInstallSubdirs} *************** *** 2588,2596 **** the installed ones. } ! \begindata{bp,268861156} ! \enddata{bp,268861156} ! \view{bpv,268861156,33,0,0} \subsection{6.4.10 TagSubdirs} --- 2586,2594 ---- the installed ones. } ! \begindata{bp,269216024} ! \enddata{bp,269216024} ! \view{bpv,269216024,33,0,0} \subsection{6.4.10 TagSubdirs} *************** *** 2661,2669 **** ! \begindata{bp,268861064} ! \enddata{bp,268861064} ! \view{bpv,268861064,34,0,0} \subsection{6.4.12 MakefileSubdirs} --- 2659,2667 ---- ! \begindata{bp,269236804} ! \enddata{bp,269236804} ! \view{bpv,269236804,34,0,0} \subsection{6.4.12 MakefileSubdirs} *************** *** 2698,2701 **** \fieldheader{Use:} ! \enddata{text,268720820} --- 2696,2699 ---- \fieldheader{Use:} ! \enddata{text,269113888} *** config/allsys.h Fri Dec 8 11:14:30 1989 --- config/allsys.h.NEW Fri Jul 20 11:20:50 1990 *************** *** 20,31 **** #define SY_U53 0 /* define for SysVR3 */ /* These are here for AIX support. */ #define SY_AIX11 0 /* define for AIX 1.1 (e.g. on PS/2) */ #define SY_AIX221 0 /* define for AIX 2.2.1 */ /* Generic bsd vs SysV defines */ #define SY_B4x (SY_B42 || SY_B43) #define SY_U5x (SY_U51 || SY_U52 || SY_U53) ! #define SY_AIXx (SY_AIX11 || SY_AIX221) /* If your site has a specific place where you would like to place the */ /* AndrewSetup configuration file, #define LOCAL_ANDREW_SETUP_ENV */ --- 20,34 ---- #define SY_U53 0 /* define for SysVR3 */ /* These are here for AIX support. */ #define SY_AIX11 0 /* define for AIX 1.1 (e.g. on PS/2) */ + #define SY_AIX12 0 /* define for AIX 1.2 (e.g. on PS/2) */ #define SY_AIX221 0 /* define for AIX 2.2.1 */ + #define SY_AIX3 0 /* defined for AIX 3 (e.g. on RS/6000) */ + #define SY_AIX31 0 /* defined for AIX 3.1 (e.g. on RS/6000) */ /* Generic bsd vs SysV defines */ #define SY_B4x (SY_B42 || SY_B43) #define SY_U5x (SY_U51 || SY_U52 || SY_U53) ! #define SY_AIXx (SY_AIX11 || SY_AIX12 || SY_AIX221 || SY_AIX3 || SY_AIX31) /* If your site has a specific place where you would like to place the */ /* AndrewSetup configuration file, #define LOCAL_ANDREW_SETUP_ENV */ *** config/andrew.rls Fri Jul 27 15:42:53 1990 --- config/andrew.rls.NEW Wed Aug 1 13:04:09 1990 *************** *** 35,40 **** --- 35,41 ---- $(BASEDIR)/bin/doindex *.do + #ifndef LINKINSTALL_ENV #define NormalHelpRule() @@\ install.alias:: doc do.alias @@\ @sh -c 'if [ -f ,help.alias ]; then \ @@\ *************** *** 45,53 **** @@\ do.alias:: @@\ @$(RM) ,help.alias - #define NormalYaccRule() @@\ .y.o: @@\ $(YACC) $*.y @@\ --- 46,65 ---- @@\ do.alias:: @@\ @$(RM) ,help.alias + #else /* LINKINSTALL_ENV */ + #define NormalHelpRule() @@\ + install.alias:: doc do.alias @@\ + @sh -c 'if [ -f ,help.alias ]; then \ @@\ + $(ADDALIASES) ,help.alias \ @@\ + $(TOP)/helpindex/help.aliases;\ @@\ + fi; \ @@\ + exit 0' @@\ + @@\ + do.alias:: @@\ + @$(RM) ,help.alias + #endif /* LINKINSTALL_ENV */ #define NormalYaccRule() @@\ .y.o: @@\ $(YACC) $*.y @@\ *************** *** 203,218 **** --- 215,246 ---- clean:: @@\ $(RM) program + #ifdef _IBMR2 + #define ProgramTarget(program, objs, libs, syslibs) @@\ all:: program @@\ @@\ program: objs libs @@\ $(RM) $@ @@\ + $(CC) $(CFLAGS) -o $@ objs libs syslibs -L ${DESTDIR}/lib @@\ + @@\ + clean:: @@\ + $(RM) program + + #else + + #define ProgramTarget(program, objs, libs, syslibs) @@\ + all:: program @@\ + @@\ + program: objs libs @@\ + $(RM) $@ @@\ $(CC) $(CFLAGS) -o $@ objs libs syslibs @@\ @@\ clean:: @@\ $(RM) program + #endif /* _IBMR2 */ + #define CleanTarget(files) @@\ clean:: @@\ $(RM) files *************** *** 681,687 **** install.time:: ihlist @@\ @case '$(MFLAGS)' in *[i]*) set +e;; esac; \ @@\ PWD=`pwd`; echo +; for i in $?; do \ @@\ ! (set -x; $(RM) dest$$i;\ @@\ $(LN) $$PWD/$$i dest;\ @@\ $(RM) dest/`basename $$i .ih`.ch;\ @@\ $(LN) $$PWD/`basename $$i .ih`.ch dest;\ @@\ --- 709,715 ---- install.time:: ihlist @@\ @case '$(MFLAGS)' in *[i]*) set +e;; esac; \ @@\ PWD=`pwd`; echo +; for i in $?; do \ @@\ ! (set -x; $(RM) dest/$$i;\ @@\ $(LN) $$PWD/$$i dest;\ @@\ $(RM) dest/`basename $$i .ih`.ch;\ @@\ $(LN) $$PWD/`basename $$i .ih`.ch dest;\ @@\ *** config/andrewos.h Wed Nov 22 11:28:21 1989 --- config/andrewos.h.NEW Thu May 10 16:18:01 1990 *************** *** 33,294 **** /* Make sure that locally defined system-specific flags are defined */ #include - /* make sure that if a SystemV derivitive is used that SYSV is defined */ - #if SY_U5x - #ifndef SYSV - #define SYSV 1 - #endif SYSV - #endif SY_U5x - - #ifdef hpux - #ifndef SYSV - #define SYSV 1 - #endif SYSV - #endif hpux - - #if SY_AIX11 - /* _BSD must be defined to get right "struct direct" from sys/dir.h */ - #define _BSD - #endif /* SY_AIX11 */ - - /* - * Get major data types (esp. caddr_t) - */ - - #ifdef CRAY - #ifndef __TYPES__ - #define __TYPES__ - #include /* forgot to protect it... */ - #endif /* __TYPES__ */ - #else - #include - #endif /* CRAY */ - - - /* - * Just about everyone needs the strings routines. For uniformity, we use - * the BSD-style index() and rindex() in application code, so any systems that - * don't provide them need to have #defines here. Unfortunately, we can't - * use #if defined() here since makedepend will get confused. - * - * The list of systems that currently needs System V stings includes: - * - * hpux - * macII - * CRAY - */ - - #ifdef SYSV - #define SYSV_STRINGS - #endif /* SYSV */ - - #ifdef macII /* since it doesn't define SYSV */ - #define SYSV_STRINGS - #endif /* macII */ - - #ifdef SYSV_STRINGS - #include - #define index strchr - #define rindex strrchr - #undef SYSV_STRINGS - #else - #include - #endif /* SYSV_STRINGS */ - - - /* - * Get open(2) constants - */ - - #ifdef SYSV - #include - #endif /* SYSV */ - #include - - - /* - * Get struct timeval - */ - - #ifdef macII - #include /* need this as well as sys/time.h */ - #endif /* macII */ - - #ifdef SYSV - #include - # ifdef mips - # include - # endif /* mips */ - #else /* else not SYSV */ - #include - #endif /* SYSV */ - - /* - * More BSDisms - */ - - #ifdef SYSV - #define SIGCHLD SIGCLD - #endif /* SYSV */ - - /* include path for syslog.h BSD vs SYSV */ - #ifdef AIX - #include - #else /* AIX */ - #ifndef hpux - #include - #endif /* hpux */ - #endif /* AIX */ - - /* VMUNIX vs. SY_B4x */ - #if SY_B4x - #ifndef VMUNIX - #define VMUNIX 1 - #endif VMUNIX - #endif SY_B4x - - /* getdtablesize() and an errno which does not seem to be defined for SYSV */ - #ifdef SYSV - #define EDOM 33 - #define getdtablesize() _NFILE - #define setpriority(which,who,prio) (nice((prio)-nice(0))) - #endif SYSV - - - /* - * handle (BSD) flock vs. (SYSV) lockf through defines - * osi == Operating System Independent - * locking with blocking is not enabled in AFS - so not defined below - */ - - /* - * Define this as 1 for systems with a readlink(2) system call, 0 for - * systems without. - */ - - #if (SY_B4x || (defined(AIX))) - #define OSI_HAS_SYMLINKS 1 - #else /* (SY_B4x || (defined(AIX))) */ - #define OSI_HAS_SYMLINKS 0 - #endif /* (SY_B4x || (defined(AIX))) */ - - - #if OSI_HAS_SYMLINKS - #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) - #else - /* If OSI_HAS_SYMLINKS is not defined, osi_readlink is present in libutil. */ - extern int osi_readlink(); - #endif /* OSI_HAS_SYMLINKS */ - - #if (defined(SYSV) || defined(AIX)) - #ifdef hpux - #include - #else - #include - #endif /* hpux */ - #define osi_ExclusiveLockNoBlock(fid) lockf((fid), F_TLOCK, 0) - #define osi_UnLock(fid) lockf((fid), F_ULOCK, 0) - #define osi_O_READLOCK O_RDWR - #define osi_F_READLOCK "r+" - #else /* (defined(SYSV) || defined(AIX)) */ - #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) - #define osi_UnLock(fid) flock((fid), LOCK_UN) - #define osi_O_READLOCK O_RDONLY - #define osi_F_READLOCK "r" - #endif /* (defined(SYSV) || defined(AIX)) */ - - /* handle (BSD) vfork for (AIX) which only knows fork */ - #if SY_AIXx - #define osi_vfork() fork() - #else /* SY_AIXx */ - #define osi_vfork() vfork() - #endif /* SY_AIXx */ - - /* Handle the absence of _setjmp and _longjmp on AIX. */ - #if SY_AIXx - #define osi_setjmp setjmp - #define osi_longjmp longjmp - #else /* SY_AIXx */ - #define osi_setjmp _setjmp - #define osi_longjmp _longjmp - #endif /* SY_AIXx */ - - /* Make a time standard. */ - struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; - /* Set one of the above with a call to osi_GetTimes(&foo) */ - #define osi_GetSecs() time((long int *) 0) - #if (SY_AIXx || SY_U5x) - #define osi_SetZone() tzset() - #define osi_ZoneNames tzname - #define osi_SecondsWest timezone - #define osi_IsEverDaylight daylight - #else /* #if (SY_AIXx || SY_U5x) */ - /* e.g., BSD */ - extern void osi_SetZone(); - extern char *osi_ZoneNames[]; - extern long int osi_SecondsWest; - extern int osi_IsEverDaylight; - #endif /* #if (SY_AIXx || SY_U5x) */ - - /* More BSD-isms */ - #if (defined(SYSV) || defined(AIX)) - #define setreuid(r,e) setuid(r) - #define setlinebuf(file) setvbuf(file, NULL, _IOLBF, BUFSIZ) - #endif - - /* - * Put system-specific definitions here - */ - - #ifdef mips - # ifdef SYSTYPE_SYSV - # include - # include - # endif /* SYSTYPE_SYSV */ - #endif /* mips */ - - #ifndef hpux - #define HAS_SYSEXITS 1 - #endif /* hpux */ - - #ifdef hpux - #undef setreuid - #define setreuid(r,e) setresuid(r,e,-1) - - #define sigvec sigvector - - #define random rand - #define srandom srand - #define initstate(a,b,c) srand(a) - #define bcopy(src, dst, length) memcpy(dst, src, length) - #define bzero(b, length) memset(b, 0, length) - #define bcmp(region1, region2, length) memcmp(region1, region2, length) - #define killpg(pgid, signal) kill(-(pgid), signal) - - #include - #define getwd(pathname) getcwd(pathname, MAXPATHLEN) - #endif /* hpux */ - - #ifndef HAS_SYSEXITS - /* hpux, for example, has no sysexits.h file anywhere. */ - #ifndef EX__BASE - #define EX_OK 0 - #define EX__BASE 64 - #define EX_USAGE 64 - #define EX_DATAERR 65 - #define EX_NOINPUT 66 - #define EX_NOUSER 67 - #define EX_NOHOST 68 - #define EX_UNAVAILABLE 69 - #define EX_SOFTWARE 70 - #define EX_OSERR 71 - #define EX_OSFILE 72 - #define EX_CANTCREAT 73 - #define EX_IOERR 74 - #define EX_TEMPFAIL 75 - #define EX_PROTOCOL 76 - #define EX_NOPERM 77 - #endif /* #ifndef EX__BASE */ - #endif /* #ifndef HAS_SYSEXITS */ - #endif /* _XOS_H_ */ --- 33,36 ---- *** config/imake.tmpl Wed Nov 22 11:28:22 1989 --- config/imake.tmpl.NEW Thu Jul 12 12:54:22 1990 *************** *** 8,13 **** --- 8,23 ---- /**/# The following comes from the macro file /**/# + #if defined(_IBMR2) + #include + #define MacroIncludeFile rs_aix31/system.mcr + #endif /* RS6000 */ + + #if (defined(MACH) && defined(i386)) + #include + #define MacroIncludeFile i386_mach/system.mcr + #endif /* AIX */ + #if defined(AIX) && (!defined(i386)) #include #define MacroIncludeFile rt_aix221/system.mcr *************** *** 14,21 **** #endif /* AIX */ #if defined(AIX) && (defined(i386)) ! #include ! #define MacroIncludeFile ps_aix11/system.mcr #endif /* AIX */ #ifdef ibm032 --- 24,31 ---- #endif /* AIX */ #if defined(AIX) && (defined(i386)) ! #include ! #define MacroIncludeFile ps_aix12/system.mcr #endif /* AIX */ #ifdef ibm032 *************** *** 28,40 **** #include #define MacroIncludeFile vax_43/system.mcr #else /* ultrix */ ! #if (defined(vax2) || (!defined(vax3) && !defined(vax4) && !defined(vax5))) #include #define MacroIncludeFile vax_22/system.mcr ! #else /* #if (defined(vax2) || (!defined(vax3) && !defined(vax4) && !defined(vax5))) */ #include #define MacroIncludeFile vax_3/system.mcr ! #endif /* #if (defined(vax2) || (!defined(vax3) && !defined(vax4) && !defined(vax5))) */ #endif /* ultrix */ #endif /* vax */ --- 38,50 ---- #include #define MacroIncludeFile vax_43/system.mcr #else /* ultrix */ ! #if (defined(vax2) && !defined(vax3) && !defined(vax4) && !defined(vax5)) #include #define MacroIncludeFile vax_22/system.mcr ! #else /* #if (defined(vax2) && !defined(vax3) && !defined(vax4) && !defined(vax5)) */ #include #define MacroIncludeFile vax_3/system.mcr ! #endif /* #if (defined(vax2) && !defined(vax3) && !defined(vax4) && !defined(vax5)) */ #endif /* ultrix */ #endif /* vax */ *************** *** 90,96 **** MACROFILE = MacroIncludeFile ! .SUFFIXES: .PS .do .o .ih .eh .fwm .snf .rtx .c .s .spp .y .l .ch .mss .fdb #ifdef ConstructMFLAGS MFLAGS = -${MAKEFLAGS} --- 100,106 ---- MACROFILE = MacroIncludeFile ! .SUFFIXES: .PS .do .o .ih .eh .fwm .snf .rtx .c .s .spp .y .l .ch .mss .fdb .bdf #ifdef ConstructMFLAGS MFLAGS = -${MAKEFLAGS} *************** *** 193,198 **** --- 203,210 ---- depend:: all:: + dependInstallClean:: depend install clean + GenericCleanTarget() MakefileTarget() TagsTarget() *************** *** 208,213 **** --- 220,233 ---- /**/# Makefiles:: Makefile + + dependInstallClean:: + @case '$(MFLAGS)' in *[ik]*) set +e;; esac; \ + for i in $(SUBDIRS); \ + do \ + (cd $$i; echo "building (dependInstall) (`pwd`)"; \ + $(MAKE) $(MFLAGS) DESTDIR='$(DESTDIR)' dependInstallClean) \ + done #ifdef IHaveSubdirs *** config/apollo68k/system.h Wed Nov 22 11:28:50 1989 --- config/apollo68k/system.h.NEW Tue May 15 10:34:36 1990 *************** *** 13,23 **** #define SYS_NAME "Apollo_Domain/OS" #define SUN_ENV - /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ /* Now follow the site-specific customizations. */ #include --- 13,69 ---- #define SYS_NAME "Apollo_Domain/OS" #define SUN_ENV /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ + #ifndef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include + + #include + + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* In_Imake */ /* Now follow the site-specific customizations. */ #include *** config/apollo68k/system.mcr Wed Nov 22 11:28:49 1989 --- config/apollo68k/system.mcr.NEW Thu May 10 16:18:11 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = apollo68k/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/hp300/system.h Wed Nov 22 11:29:03 1989 --- config/hp300/system.h.NEW Wed Jun 13 16:43:50 1990 *************** *** 12,27 **** #define sys_hpux_300 1 #define SYS_NAME "hp300" #define HP300_ENV - /* Here follow the overrides for this system. */ #undef SY_U52 #define SY_U52 1 /* HP300 is most like SysVR2. */ ! #undef RESOLVER_ENV ! #define BUILDANDREWINSTALL_ENV 1 /* Now follow the site-specific customizations. */ #include --- 12,129 ---- #define sys_hpux_300 1 #define SYS_NAME "hp300" #define HP300_ENV + #define HP_OS 70 /* Here follow the overrides for this system. */ #undef SY_U52 #define SY_U52 1 /* HP300 is most like SysVR2. */ ! #ifndef In_Imake ! #ifndef SYSV ! #define SYSV 1 ! #endif SYSV + /* Get major data types (esp. caddr_t) */ + #include + + #define SYSV_STRINGS + #include + #define index strchr + #define rindex strrchr + + /* Get open(2) constants */ + #include + #include + + /* Get struct timeval */ + #include + + /* More BSDisms */ + + #if HP_OS >= 70 + #include + #else + #define SIGCHLD SIGCLD + #endif + + /* getdtablesize() and an errno which does not seem to be defined for SYSV */ + #define EDOM 33 + #define getdtablesize() _NFILE + #define setpriority(which,who,prio) (nice((prio)-nice(0))) + + #define OSI_HAS_SYMLINKS 0 + /* If OSI_HAS_SYMLINKS is not defined, osi_readlink is present in libutil. */ + extern int osi_readlink(); + + #include + #define osi_ExclusiveLockNoBlock(fid) lockf((fid), F_TLOCK, 0) + #define osi_UnLock(fid) lockf((fid), F_ULOCK, 0) + #define osi_O_READLOCK O_RDWR + #define osi_F_READLOCK "r+" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + #define osi_SetZone() tzset() + #define osi_ZoneNames tzname + #define osi_SecondsWest timezone + #define osi_IsEverDaylight daylight + + /* More BSD-isms */ + #define setreuid(r,e) setuid(r) + #define setlinebuf(file) setvbuf(file, NULL, _IOLBF, BUFSIZ) + + /* + * Put system-specific definitions here + */ + + #undef setreuid + #define setreuid(r,e) setresuid(r,e,-1) + + #define sigvec sigvector + + #define random rand + #define srandom srand + #define initstate(a,b,c) srand(a) + #define bcopy(src, dst, length) memmove(dst, src, length) + #define bzero(b, length) memset(b, 0, length) + #define bcmp(region1, region2, length) memcmp(region1, region2, length) + #define killpg(pgid, signal) kill(-(pgid), signal) + + #include + #define getwd(pathname) getcwd(pathname, MAXPATHLEN) + + /* hpux has no sysexits.h file anywhere. */ + #ifndef EX__BASE + #define EX_OK 0 + #define EX__BASE 64 + #define EX_USAGE 64 + #define EX_DATAERR 65 + #define EX_NOINPUT 66 + #define EX_NOUSER 67 + #define EX_NOHOST 68 + #define EX_UNAVAILABLE 69 + #define EX_SOFTWARE 70 + #define EX_OSERR 71 + #define EX_OSFILE 72 + #define EX_CANTCREAT 73 + #define EX_IOERR 74 + #define EX_TEMPFAIL 75 + #define EX_PROTOCOL 76 + #define EX_NOPERM 77 + #endif /* #ifndef EX__BASE */ + + #endif /* !In_Imake */ + + #define GETDOMAIN_ENV 1 + #define BUILDANDREWINSTALL_ENV 1 /* Now follow the site-specific customizations. */ #include *** config/hp300/system.mcr Wed Nov 22 11:29:01 1989 --- config/hp300/system.mcr.NEW Wed Jun 13 16:43:52 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = hp300/system.h + #undef In_Imake /* These next three lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *************** *** 16,25 **** /* Now for the system-dependent information. */ - XBASEDIR = - XUTILDIR = ${BASEDIR}/bin/X11 CDEBUGFLAGS = +O1 ! STD_DEFINES = +Nd4000 +Ns3000 -W p,-H500000 /* Get site-specific inclusions */ --- 18,25 ---- /* Now for the system-dependent information. */ CDEBUGFLAGS = +O1 ! STD_DEFINES = +Nd4000 +Ns3000 -W p,-H500000 -D_CLASSIC_TYPES /* Get site-specific inclusions */ *** config/i386_mach/system.h Fri Jul 27 13:04:08 1990 --- config/i386_mach/system.h.NEW Tue May 15 10:34:46 1990 *************** *** 0 **** --- 1,73 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + #ifndef SYSTEM_H + #define SYSTEM_H + + /* Get common definitions */ + #include + + #define OPSYSNAME "i386_mach" + #define SYS_NAME "i386_mach" + #define vax2 1 + #define sys_vax_43 1 + #define VAX_ENV 1 + + /* Here follow the overrides for this system. */ + #undef SY_B43 + #define SY_B43 1 /* This system is most like bsd 4.3 */ + + #ifdef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + /* Get open(2) constants */ + #include + + #include + + /* Get struct timeval */ + #include + + /* include path for syslog.h */ + #include + + /* VMUNIX vs. SY_B4x */ + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* Put system-specific definitions here */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ + + /* Now follow the site-specific customizations. */ + #include + + #endif /* SYSTEM_H */ *** config/i386_mach/system.mcr Fri Jul 27 13:04:21 1990 --- config/i386_mach/system.mcr.NEW Thu May 10 16:18:24 1990 *************** *** 0 **** --- 1,25 ---- + /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ + /* For full copyright information see:'andrew/config/COPYRITE' */ + + #define In_Imake 1 + /* The next two lines need to be kept in sync */ + #include + SYSTEM_H_FILE = i386_mach/system.h + #undef In_Imake + + /* These next two lines help configure the embedded machine-dependent + directories overhead/class/machdep, atk/console/stats, and + atk/console/stats/common. */ + SYS_IDENT = i386_mach + SYS_OS_ARCH = i386_mach + + + /* Get parent inclusions */ + #include + + /* Now for the system-dependent information. */ + + CDEBUGFLAGS = -O -fwritable-strings + + /* Get site-specific inclusions */ + #include *** config/mac2_51/system.h Wed Nov 22 11:29:06 1989 --- config/mac2_51/system.h.NEW Tue May 15 10:34:49 1990 *************** *** 13,24 **** #define SYS_NAME "mac2_51" #define MACH_ENV - /* Here follow the overrides for this system. */ /* for MACH systems */ #undef SY_MCH #define SY_MCH 1 /* Now follow the site-specific customizations. */ #include --- 13,73 ---- #define SYS_NAME "mac2_51" #define MACH_ENV /* Here follow the overrides for this system. */ /* for MACH systems */ #undef SY_MCH #define SY_MCH 1 + #ifndef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + #include + #define index strchr + #define rindex strrchr + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include /* need this as well as sys/time.h */ + #include + + /* include path for syslog.h BSD vs SYSV */ + #include + + #define OSI_HAS_SYMLINKS 0 + + /* If OSI_HAS_SYMLINKS is not defined, osi_readlink is present in libutil. */ + extern int osi_readlink(); + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ /* Now follow the site-specific customizations. */ #include *** config/mac2_51/system.mcr Wed Nov 22 11:29:07 1989 --- config/mac2_51/system.mcr.NEW Thu May 10 16:18:29 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = mac2_51/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/pmax_3/system.h Wed Nov 22 11:29:13 1989 --- config/pmax_3/system.h.NEW Tue May 15 10:34:54 1990 *************** *** 13,22 **** #define SYS_NAME "pmax_3" #define PMAX_ENV - /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ /* Now follow the site-specific customizations. */ #include --- 13,86 ---- #define SYS_NAME "pmax_3" #define PMAX_ENV /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ + + #ifndef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #ifdef SYSV + #include + # ifdef mips + # include + # endif /* mips */ + #else /* else not SYSV */ + #include + #endif /* SYSV */ + + /* include path for syslog.h BSD vs SYSV */ + #include + + /* VMUNIX vs. SY_B4x */ + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* + * Put system-specific definitions here + */ + + #ifdef mips + # ifdef SYSTYPE_SYSV + # include + # include + # endif /* SYSTYPE_SYSV */ + #endif /* mips */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ /* Now follow the site-specific customizations. */ #include *** config/pmax_3/system.mcr Wed Nov 22 11:29:12 1989 --- config/pmax_3/system.mcr.NEW Thu May 10 16:18:35 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = pmax_3/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/ps_aix11/system.h Fri Jan 12 13:41:01 1990 --- config/ps_aix11/system.h.NEW Tue May 15 10:34:57 1990 *************** *** 15,24 **** #define i386_ENV #endif /* i386_ENV */ - /* Here follow the overrides for this system. */ #undef SY_AIX11 #define SY_AIX11 1 /* This system is most like AIX 1.1 */ #undef RESOLVER_ENV #undef ANDREW_MALLOC_ENV --- 15,83 ---- #define i386_ENV #endif /* i386_ENV */ /* Here follow the overrides for this system. */ #undef SY_AIX11 #define SY_AIX11 1 /* This system is most like AIX 1.1 */ + + #ifndef In_Imake + + #ifndef _BSD + #define _BSD + #endif /* _BSD */ + + /*Get major data types (esp. caddr_t) */ + #include + + #ifndef BSD + #define BSD + #endif /* BSD */ + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include + + /* include path for syslog.h BSD vs SYSV */ + #include + + #define OSI_HAS_SYMLINKS 1 + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #include + #define osi_ExclusiveLockNoBlock(fid) lockf((fid), F_TLOCK, 0) + #define osi_UnLock(fid) lockf((fid), F_ULOCK, 0) + #define osi_O_READLOCK O_RDWR + #define osi_F_READLOCK "r+" + + /* handle (BSD) vfork for (AIX) which only knows fork */ + #define osi_vfork() fork() + + /* Handle the absence of _setjmp and _longjmp on AIX. */ + #define osi_setjmp setjmp + #define osi_longjmp longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + #define osi_SetZone() tzset() + #define osi_ZoneNames tzname + #define osi_SecondsWest timezone + #define osi_IsEverDaylight daylight + + /* More BSD-isms */ + #define setreuid(r,e) setuid(r) + #define setlinebuf(file) setvbuf(file, NULL, _IOLBF, BUFSIZ) + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ #undef RESOLVER_ENV #undef ANDREW_MALLOC_ENV *** config/ps_aix11/system.mcr Fri Jan 12 13:41:02 1990 --- config/ps_aix11/system.mcr.NEW Wed Jun 20 13:16:24 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = ps_aix11/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *************** *** 23,28 **** --- 25,37 ---- #define ConstructMFLAGS 1 RANLIB = echo ranlib is not needed on this system + #ifdef LINKINSTALL_ENV + RM = rm -fs + #else + RM = rm -f + #endif /* LINKINSTALL_ENV */ + + NM = /bin/nm /* Get site-specific inclusions */ #include *** config/ps_aix12/system.h Fri Jul 27 13:05:25 1990 --- config/ps_aix12/system.h.NEW Wed Jun 20 13:16:30 1990 *************** *** 0 **** --- 1,95 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + #ifndef SYSTEM_H + #define SYSTEM_H + + /* Get common definitions */ + #include + + #define OPSYSNAME "ps2_aix12" + #define sys_ps_aix12 1 + #define SYS_NAME "ps_aix12" + #ifndef i386_ENV + #define i386_ENV + #endif /* i386_ENV */ + + /* Here follow the overrides for this system. */ + #undef SY_AIX12 + #define SY_AIX12 1 /* This system is most like AIX 1.2 */ + + #ifndef In_Imake + + #ifndef _BSD + #define _BSD + #endif /* _BSD */ + + /* Get major data types (esp. caddr_t) */ + #include + + #ifndef BSD + #define BSD + #endif /* BSD */ + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include + + /* include path for syslog.h BSD vs SYSV */ + #include + + #define OSI_HAS_SYMLINKS 1 + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #include + #define osi_ExclusiveLockNoBlock(fid) lockf((fid), F_TLOCK, 0) + #define osi_UnLock(fid) lockf((fid), F_ULOCK, 0) + #define osi_O_READLOCK O_RDWR + #define osi_F_READLOCK "r+" + + /* handle (BSD) vfork for (AIX) which only knows fork */ + #define osi_vfork() fork() + + /* Handle the absence of _setjmp and _longjmp on AIX. */ + #define osi_setjmp setjmp + #define osi_longjmp longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + #define osi_SetZone() tzset() + #define osi_ZoneNames tzname + #define osi_SecondsWest timezone + #define osi_IsEverDaylight daylight + + /* More BSD-isms */ + #define setreuid(r,e) setuid(r) + #define setlinebuf(file) setvbuf(file, NULL, _IOLBF, BUFSIZ) + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ + + #undef RESOLVER_ENV + #undef ANDREW_MALLOC_ENV + #undef DEBUG_MALLOC_ENV + #undef LEVEL_ENV + #define LEVEL_ENV 1 + + #undef MK_BLD_BLKS + #undef DITROFF_ENV + + + /* Now follow the site-specific customizations. */ + #include + + #endif /* SYSTEM_H */ *** config/ps_aix12/system.mcr Fri Jul 27 13:05:38 1990 --- config/ps_aix12/system.mcr.NEW Wed Jun 20 13:16:32 1990 *************** *** 0 **** --- 1,37 ---- + /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ + /* For full copyright information see:'andrew/config/COPYRITE' */ + + #define In_Imake 1 + /* The next two lines need to be kept in sync */ + #include + SYSTEM_H_FILE = ps_aix12/system.h + #undef In_Imake + + /* These next two lines help configure the embedded machine-dependent + directories overhead/class/machdep, atk/console/stats, and + atk/console/stats/common. */ + SYS_IDENT = ps_aix12 + SYS_OS_ARCH = aix_i386 + + /* Get parent inclusions */ + #include + + + /* Now for the system-dependent information. */ + XSRCDIR = / + INCLUDES = -I${BASEDIR}/include/atk -I${BASEDIR}/include -I${XBASEDIR}/usr/include + + CC = cc -DBSD_INCLUDES -DBSD_REMAP_SIGNAL_TO_SIGVEC + #define ConstructMFLAGS 1 + RANLIB = echo ranlib is not needed on this system + + #ifdef LINKINSTALL_ENV + RM = rm -fs + #else + RM = rm -f + #endif /* LINKINSTALL_ENV */ + + NM = /bin/nm + + /* Get site-specific inclusions */ + #include *** config/rs_aix31/system.h Fri Jul 27 13:05:51 1990 --- config/rs_aix31/system.h.NEW Wed Jun 20 13:16:38 1990 *************** *** 0 **** --- 1,93 ---- + #ifndef SYSTEM_H + #define SYSTEM_H + + /* Get common definitions */ + + #include + + #define OPSYSNAME "risc_aix31" + #define sys_rt_aix3 1 + #define SYS_NAME "rs_aix31" + + #ifndef IBM032_ENV + #define IBM032_ENV + #endif /* IBM032_ENV */ + + /* These are here for AIX support. */ + + #undef SY_AIX31 + #define SY_AIX31 1 /* define for AIX 3.1 */ + + #ifndef In_Imake + + #undef _ANSI_C_SOURCE + #include + #define _ANSI_C_SOURCE + + #include + + #undef _ANSI_C_SOURCE + #include + #define _ANSI_C_SOURCE + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include + #include + + /* include path for syslog.h */ + #include + + #define OSI_HAS_SYMLINKS 1 + /* If OSI_HAS_SYMLINKS is not defined, osi_readlink is present in libutil. */ + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + #include + #define osi_ExclusiveLockNoBlock(fid) lockf((fid), F_TLOCK, 0) + #define osi_UnLock(fid) lockf((fid), F_ULOCK, 0) + #define osi_O_READLOCK O_RDWR + #define osi_F_READLOCK "r+" + + /* handle (BSD) vfork for (AIX) which only knows fork */ + #define osi_vfork() fork() + + /* Handle the absence of _setjmp and _longjmp on AIX. */ + #define osi_setjmp setjmp + #define osi_longjmp longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + #define osi_SetZone() tzset() + #define osi_ZoneNames tzname + #define osi_SecondsWest timezone + #define osi_IsEverDaylight daylight + + /* More BSD-isms */ + #define setreuid(r,e) setuid(r) + #define setlinebuf(file) setvbuf(file, NULL, _IOLBF, BUFSIZ) + + /* + * Put system-specific definitions here + */ + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ + + /* This system needs the customized ``install'' program. */ + + #define BUILDANDREWINSTALL_ENV 1 + + /* Things that aren't yet handled */ + + #undef RESOLVER_ENV + #undef LEVEL_ENV + + /* Now follow the site-specific customizations. */ + + #include + + #endif /* SYSTEM_H */ + *** config/rs_aix31/system.mcr Fri Jul 27 13:06:02 1990 --- config/rs_aix31/system.mcr.NEW Wed Jun 13 16:44:07 1990 *************** *** 0 **** --- 1,33 ---- + SHELL=/bin/sh + + /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ + /* For full copyright information see:'andrew/config/COPYRITE' */ + + #define In_Imake 1 + /* The next two lines need to be kept in sync */ + #include + SYSTEM_H_FILE = rs_aix31/system.h + #undef In_Imake + + /* These next two lines help configure the embedded machine-dependent + directories overhead/class/machdep, atk/console/stats, and atk/console/stats/common. */ + SYS_IDENT = rs_aix31 + SYS_OS_ARCH = aix_31 + + /* Get parent inclusions */ + #include + + /* Now for the system-dependent information. */ + CC = cc -DAIX -D_AIX -D_IBMR2 -DAIX_31 -D_BSD -U__STR__ -D_NO_PROTO -D_H_NLCTYPE + STD_DEFINES = -qflag=i:i + + RANLIB = echo ranlib is not needed this system + XFC = /usr/lpp/X11/bin/bdftosnf + XMKFONTDIR = /usr/lpp/X11/bin/mkfontdir + + #define ConstructMFLAGS 1 + + /* Get site-specific inclusions */ + + #include + *** config/rt_aix221/system.h Wed Nov 22 11:29:20 1989 --- config/rt_aix221/system.h.NEW Tue May 15 10:35:09 1990 *************** *** 15,25 **** #define IBM032_ENV #endif /* IBM032_ENV */ - /* Here follow the overrides for this system. */ #undef SY_AIX221 #define SY_AIX221 1 /* This system is most like AIX 2.2.1 */ /* This system needs the customized ``install'' program. */ #define BUILDANDREWINSTALL_ENV 1 --- 15,80 ---- #define IBM032_ENV #endif /* IBM032_ENV */ /* Here follow the overrides for this system. */ #undef SY_AIX221 #define SY_AIX221 1 /* This system is most like AIX 2.2.1 */ + #ifndef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + #ifndef BSD + #define BSD + #endif /* BSD */ + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include + + /* include path for syslog.h */ + #include + + #define OSI_HAS_SYMLINKS 1 + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #include + #define osi_ExclusiveLockNoBlock(fid) lockf((fid), F_TLOCK, 0) + #define osi_UnLock(fid) lockf((fid), F_ULOCK, 0) + #define osi_O_READLOCK O_RDWR + #define osi_F_READLOCK "r+" + + /* handle (BSD) vfork for (AIX) which only knows fork */ + #define osi_vfork() fork() + + /* Handle the absence of _setjmp and _longjmp on AIX. */ + #define osi_setjmp setjmp + #define osi_longjmp longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + #define osi_SetZone() tzset() + #define osi_ZoneNames tzname + #define osi_SecondsWest timezone + #define osi_IsEverDaylight daylight + + /* More BSD-isms */ + #define setreuid(r,e) setuid(r) + #define setlinebuf(file) setvbuf(file, NULL, _IOLBF, BUFSIZ) + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ + /* This system needs the customized ``install'' program. */ #define BUILDANDREWINSTALL_ENV 1 *************** *** 27,36 **** #undef RESOLVER_ENV #undef LEVEL_ENV - /* No ditroff here (yet) */ #undef DITROFF_ENV - /* Now follow the site-specific customizations. */ #include --- 82,89 ---- *** config/rt_aix221/system.mcr Wed Nov 22 11:29:19 1989 --- config/rt_aix221/system.mcr.NEW Thu May 10 16:18:50 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = rt_aix221/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/rt_r3/system.h Wed Nov 22 11:29:23 1989 --- config/rt_r3/system.h.NEW Fri May 11 12:58:27 1990 *************** *** 15,26 **** #define IBM032_ENV #endif /* IBM032_ENV */ - /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ #define NDBM_ENV 1 /* Now follow the site-specific customizations. */ #include --- 15,76 ---- #define IBM032_ENV #endif /* IBM032_ENV */ /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ #define NDBM_ENV 1 + + #ifndef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + /* Get open(2) constants */ + #include + + #include + + /* Get struct timeval */ + #include + + /* include path for syslog.h */ + #include + + /* VMUNIX vs. SY_B4x */ + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + #endif /* In_Imake */ + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 /* Now follow the site-specific customizations. */ #include *** config/rt_r3/system.mcr Wed Nov 22 11:29:22 1989 --- config/rt_r3/system.mcr.NEW Thu May 10 16:18:57 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = rt_r3/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/sun2_35/system.h Wed Nov 22 11:29:28 1989 --- config/sun2_35/system.h.NEW Tue May 15 10:35:15 1990 *************** *** 13,26 **** #define SYS_NAME "sun2_35" #define SUN_ENV - /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ #define NDBM_ENV 1 #define GETDOMAIN_ENV 1 - /* Now follow the site-specific customizations. */ #include --- 13,76 ---- #define SYS_NAME "sun2_35" #define SUN_ENV /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ + #ifndef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include + + /* include path for syslog.h */ + #include + + /* VMUNIX vs. SY_B4x */ + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + /* handle (BSD) vfork for (AIX) which only knows fork */ + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ + #define NDBM_ENV 1 #define GETDOMAIN_ENV 1 /* Now follow the site-specific customizations. */ #include *** config/sun2_35/system.mcr Wed Nov 22 11:29:26 1989 --- config/sun2_35/system.mcr.NEW Thu May 10 16:19:04 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = sun2_35/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/sun3_35/system.h Wed Nov 22 11:29:33 1989 --- config/sun3_35/system.h.NEW Tue May 15 10:35:19 1990 *************** *** 13,26 **** #define SYS_NAME "sun3_35" #define SUN_ENV - /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ #define NDBM_ENV 1 #define GETDOMAIN_ENV 1 - /* Now follow the site-specific customizations. */ #include --- 13,73 ---- #define SYS_NAME "sun3_35" #define SUN_ENV /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ + #ifndef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include + + /* include path for syslog.h */ + #include + + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* + * Put system-specific definitions here + */ + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ + #define NDBM_ENV 1 #define GETDOMAIN_ENV 1 /* Now follow the site-specific customizations. */ #include *** config/sun3_35/system.mcr Wed Nov 22 11:29:32 1989 --- config/sun3_35/system.mcr.NEW Thu May 10 16:19:08 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = sun3_35/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/sun3_4/system.h Wed Nov 22 11:29:36 1989 --- config/sun3_4/system.h.NEW Tue May 15 10:35:23 1990 *************** *** 13,26 **** #define SYS_NAME "sun3_4" #define SUN_ENV - /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ #define NDBM_ENV 1 #define GETDOMAIN_ENV 1 - /* Now follow the site-specific customizations. */ #include --- 13,75 ---- #define SYS_NAME "sun3_4" #define SUN_ENV /* Here follow the overrides for this system. */ #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ + #ifndef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include + + /* include path for syslog.h */ + #include + + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ + #define NDBM_ENV 1 #define GETDOMAIN_ENV 1 /* Now follow the site-specific customizations. */ #include *** config/sun3_4/system.mcr Wed Nov 22 11:29:37 1989 --- config/sun3_4/system.mcr.NEW Thu May 10 16:19:13 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = sun3_4/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/sun4_40/system.h Wed Nov 22 11:29:45 1989 --- config/sun4_40/system.h.NEW Tue May 15 10:35:26 1990 *************** *** 17,25 **** #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ #define NDBM_ENV 1 #define GETDOMAIN_ENV 1 - /* Now follow the site-specific customizations. */ #include --- 17,75 ---- #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ + #ifndef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include + + /* include path for syslog.h */ + #include + + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ + #define NDBM_ENV 1 #define GETDOMAIN_ENV 1 /* Now follow the site-specific customizations. */ #include *** config/sun4_40/system.mcr Wed Nov 29 19:31:22 1989 --- config/sun4_40/system.mcr.NEW Thu May 10 16:19:18 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = sun4_40/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/vax_22/system.h Wed Nov 22 11:29:50 1989 --- config/vax_22/system.h.NEW Tue May 15 10:35:31 1990 *************** *** 17,22 **** --- 17,71 ---- #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ + #ifndef In_Imake + + /* Get major data types (esp. caddr_t) */ + #include + + #include + + /* Get open(2) constants */ + #include + + /*Get struct timeval */ + #include + + #include + + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ /* Now follow the site-specific customizations. */ #include *** config/vax_22/system.mcr Wed Nov 22 11:29:49 1989 --- config/vax_22/system.mcr.NEW Thu May 10 16:19:22 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = vax_22/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/vax_3/system.h Wed Nov 22 11:29:52 1989 --- config/vax_3/system.h.NEW Tue May 15 10:35:36 1990 *************** *** 17,24 **** #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ ! #define GETDOMAIN_ENV 1 /* Now follow the site-specific customizations. */ #include --- 17,68 ---- #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ ! #ifndef In_Imake + /* Get major data types (esp. caddr_t) */ + #include + + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval*/ + #include + + #include + + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ + + #define GETDOMAIN_ENV 1 /* Now follow the site-specific customizations. */ #include *** config/vax_3/system.mcr Wed Nov 22 11:29:53 1989 --- config/vax_3/system.mcr.NEW Thu May 10 16:19:27 1990 *************** *** 1,9 **** --- 1,11 ---- /* Copyright IBM Corporation 1988,1989 - All Rights Reserved */ /* For full copyright information see:'andrew/config/COPYRITE' */ + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = vax_3/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** config/vax_43/system.h Wed Nov 22 11:29:56 1989 --- config/vax_43/system.h.NEW Tue May 15 10:35:40 1990 *************** *** 17,24 **** #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ ! #define GETDOMAIN_ENV 1 /* Now follow the site-specific customizations. */ #include --- 17,73 ---- #undef SY_B43 #define SY_B43 1 /* This system is most like bsd 4.3 */ ! #ifndef In_Imake + /* Get major data types (esp. caddr_t) */ + #include + + #include + + /* Get open(2) constants */ + #include + + /* Get struct timeval */ + #include + + #include + + #ifndef VMUNIX + #define VMUNIX 1 + #endif VMUNIX + + #define OSI_HAS_SYMLINKS 1 + + #define osi_readlink(PATH,BUF,SIZE) readlink((PATH),(BUF),(SIZE)) + + #define osi_ExclusiveLockNoBlock(fid) flock((fid), LOCK_EX | LOCK_NB) + #define osi_UnLock(fid) flock((fid), LOCK_UN) + #define osi_O_READLOCK O_RDONLY + #define osi_F_READLOCK "r" + + #define osi_vfork() vfork() + + #define osi_setjmp _setjmp + #define osi_longjmp _longjmp + + /* Make a time standard. */ + struct osi_Times {unsigned long int Secs; unsigned long int USecs;}; + /* Set one of the above with a call to osi_GetTimes(&foo) */ + #define osi_GetSecs() time((long int *) 0) + extern void osi_SetZone(); + extern char *osi_ZoneNames[]; + extern long int osi_SecondsWest; + extern int osi_IsEverDaylight; + + /* + * Put system-specific definitions here + */ + + #define HAS_SYSEXITS 1 + + #endif /* !In_Imake */ + + #define GETDOMAIN_ENV 1 /* Now follow the site-specific customizations. */ #include *** config/vax_43/system.mcr Wed Nov 22 11:29:57 1989 --- config/vax_43/system.mcr.NEW Thu May 10 16:19:33 1990 *************** *** 5,13 **** --- 5,15 ---- * named vax unless we #undef vax */ #undef vax + #define In_Imake 1 /* The next two lines need to be kept in sync */ #include SYSTEM_H_FILE = vax_43/system.h + #undef In_Imake /* These next two lines help configure the embedded machine-dependent directories overhead/class/machdep, atk/console/stats, and *** ams/Imakefile Wed Nov 22 11:30:11 1989 --- ams/Imakefile.NEW Wed May 16 10:49:46 1990 *************** *** 26,31 **** $(UTILS) \ $(DELIVERY) ! MkdirTarget($(DESTDIR)/include/ams $(COMMON)/$(DESTDIR)/lib/flames) --- 26,31 ---- $(UTILS) \ $(DELIVERY) ! MkdirTarget($(DESTDIR)/include/ams $(DESTDIR)/lib/flames) *** ams/flames/flib.flm Wed Nov 22 11:30:20 1989 --- ams/flames/flib.flm.NEW Fri Jul 20 11:21:20 1990 *************** *** 255,261 **** ; pattern passed to extract-liberally. It matches ; one or more non-terminator characters within a subexpression ; (so we can get at the matched portion with re-strdecompose+) ! (setq &END-OF-EXTRACT-PATTERN "([^] ,@:)}>%;!\"]+)") (setq NEWLINE-TAB "\n\t") --- 255,261 ---- ; pattern passed to extract-liberally. It matches ; one or more non-terminator characters within a subexpression ; (so we can get at the matched portion with re-strdecompose+) ! (setq &END-OF-EXTRACT-PATTERN "([^]\n ,@:)}>%;!\"]+)") (setq NEWLINE-TAB "\n\t") *** ams/libs/cui/andmchs.c Wed Nov 22 11:30:54 1989 --- ams/libs/cui/andmchs.c.NEW Wed Jun 13 16:44:57 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/cui/RCS/andmchs.c,v 2.20 89/08/03 13:22:09 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/cui/RCS/andmchs.c,v $ */ /* Machine dependent module -- Andrew Version */ #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/cui/RCS/andmchs.c,v 2.21 90/06/04 16:26:24 gk5g Exp $ ! $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/cui/RCS/andmchs.c,v $ */ /* Machine dependent module -- Andrew Version */ #include *************** *** 14,23 **** #include #include #include - #include /* sys/file.h */ #include #include - #include #ifdef SNAP_ENV #include #else /* SNAP_ENV */ --- 14,21 ---- *************** *** 48,54 **** extern long CUI_LastCallFinished; extern int CUI_SnapIsRunning; ! extern char *getenv(), *malloc(), *getprofile(); int SNAP_debuglevel=0, SNAP_socket=0, --- 46,56 ---- extern long CUI_LastCallFinished; extern int CUI_SnapIsRunning; ! extern char *getenv(), *getprofile(); ! ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ int SNAP_debuglevel=0, SNAP_socket=0, *** ams/libs/cui/cuilib.c Mon Mar 12 13:15:01 1990 --- ams/libs/cui/cuilib.c.NEW Wed Jun 13 16:45:07 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/cui/RCS/cuilib.c,v 2.43 90/02/15 15:42:34 bobg Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/cui/RCS/cuilib.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/cui/RCS/cuilib.c,v 2.44 90/06/04 16:26:42 gk5g Exp $ ! $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/cui/RCS/cuilib.c,v $ */ #include #include *************** *** 43,49 **** MS_GetHeaderContents(), MS_SubmitMessage(), MS_UnlinkFile(), MS_ReconstructDirectory(), MS_ValidateAndReplaceChunk(), MS_GetPartialFile(), MS_WriteAllMatchesToFile(), MS_InstallWelcomeMessage(), MS_CloneMessage(), MS_GetAssociatedTime(), MS_SetAssociatedTime(), MS_StorePartialFile(), MS_RenameDir(), MS_GetDirInfo(), MS_RemoveDirectory(), MS_CheckMissingFolder(), MS_GetSubscriptionEntry(), MS_PrefetchMessage(), MS_HandlePreference(), MS_SetSubscriptionEntry(), MS_MergeDirectories(), MS_StorePartialFile(), MS_GetDirAttributes(), MS_AddAttribute(),MS_GetVConfig(); ! extern char *malloc (), *realloc (), *NextAddress(), *cvEng(); extern char *SnapVersionString; /* Any CUI functions that return a long should be in this list */ --- 43,53 ---- MS_GetHeaderContents(), MS_SubmitMessage(), MS_UnlinkFile(), MS_ReconstructDirectory(), MS_ValidateAndReplaceChunk(), MS_GetPartialFile(), MS_WriteAllMatchesToFile(), MS_InstallWelcomeMessage(), MS_CloneMessage(), MS_GetAssociatedTime(), MS_SetAssociatedTime(), MS_StorePartialFile(), MS_RenameDir(), MS_GetDirInfo(), MS_RemoveDirectory(), MS_CheckMissingFolder(), MS_GetSubscriptionEntry(), MS_PrefetchMessage(), MS_HandlePreference(), MS_SetSubscriptionEntry(), MS_MergeDirectories(), MS_StorePartialFile(), MS_GetDirAttributes(), MS_AddAttribute(),MS_GetVConfig(); ! #ifndef _IBMR2 ! extern char *malloc (), *realloc (); ! #endif /* _IBMR2 */ ! ! extern char *NextAddress(), *cvEng(); extern char *SnapVersionString; /* Any CUI functions that return a long should be in this list */ *** ams/libs/cui/pcmchs.c Wed Nov 22 11:30:55 1989 --- ams/libs/cui/pcmchs.c.NEW Wed Jun 13 16:45:11 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/cui/RCS/pcmchs.c,v 2.7 89/02/15 11:21:13 ghoti Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/cui/RCS/pcmchs.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/cui/RCS/pcmchs.c,v 2.7 89/02/15 11:21:13 ghoti Exp $ "; #endif /* lint */ /* Machine dependent modules -- PC Version */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/cui/RCS/pcmchs.c,v 2.8 90/06/04 16:27:19 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/cui/RCS/pcmchs.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/cui/RCS/pcmchs.c,v 2.8 90/06/04 16:27:19 gk5g Exp $ "; #endif /* lint */ /* Machine dependent modules -- PC Version */ *************** *** 26,32 **** #include struct passwd *getpwuid(); #define MAXBUFFERSIZE 20000 ! char *mktemp(), *getenv(), *malloc(); int SNAP_debuglevel=0, SNAP_socket=0, --- 26,36 ---- #include struct passwd *getpwuid(); #define MAXBUFFERSIZE 20000 ! char *mktemp(), *getenv(); ! ! #ifndef _IBMR2 ! char *malloc(); ! #endif /* _IBMR2 */ int SNAP_debuglevel=0, SNAP_socket=0, *** ams/libs/ms/Imakefile Mon Mar 12 13:15:08 1990 --- ams/libs/ms/Imakefile.NEW Thu May 10 16:20:07 1990 *************** *** 24,30 **** parseraw.o pfmsg.o prettyn.o purge.o rawdb.o \ rawfil.o rebldmap.o rebldmuf.o recon.o \ redslash.o rmvdir.o renadir.o reply.o rsndhdr.o \ ! restilde.o fixsub.o safeexit.o setasct.o setknell.o \ setsubs.o shrkdate.o shrkname.o stack.o storfile.o strpself.o \ submsg.o subs.o subswalk.o substr.o uattrs.o \ unlnfile.o unscrib.o update.o util.o mtchfold.o scavenge.o --- 24,30 ---- parseraw.o pfmsg.o prettyn.o purge.o rawdb.o \ rawfil.o rebldmap.o rebldmuf.o recon.o \ redslash.o rmvdir.o renadir.o reply.o rsndhdr.o \ ! restilde.o fixsub.o site.o safeexit.o setasct.o setknell.o \ setsubs.o shrkdate.o shrkname.o stack.o storfile.o strpself.o \ submsg.o subs.o subswalk.o substr.o uattrs.o \ unlnfile.o unscrib.o update.o util.o mtchfold.o scavenge.o *** ams/libs/ms/addhdr.c Wed Nov 22 11:31:57 1989 --- ams/libs/ms/addhdr.c.NEW Wed Jun 13 16:46:04 1990 *************** *** 3,16 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/addhdr.c,v 2.7 89/08/03 13:25:50 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/addhdr.c,v $ */ #include #include #include extern char *malloc(); #define ALTER_ADD 0 #define ALTER_DEL 1 --- 3,18 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/addhdr.c,v 2.8 90/06/04 16:47:25 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/addhdr.c,v $ */ #include #include #include + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ #define ALTER_ADD 0 #define ALTER_DEL 1 *** ams/libs/ms/authuid.c Wed Nov 22 11:32:05 1989 --- ams/libs/ms/authuid.c.NEW Fri Jun 15 12:06:15 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/authuid.c,v 2.10 89/11/07 10:48:43 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/authuid.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/authuid.c,v 2.12 90/06/15 12:04:28 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/authuid.c,v $ */ #include #include *************** *** 17,23 **** #include #endif /* AFS_ENV */ ! extern char *index(), *malloc(), *StripWhiteEnds(), *rindex(), *GenAuthField(); extern int postmanvuid, myvuid, homeUsesAMSDelivery; extern char MyMailDomain[]; --- 17,26 ---- #include #endif /* AFS_ENV */ ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! extern char *index(), *StripWhiteEnds(), *rindex(), *GenAuthField(); extern int postmanvuid, myvuid, homeUsesAMSDelivery; extern char MyMailDomain[]; *** ams/libs/ms/bldcapt.c Wed Jan 17 16:35:29 1990 --- ams/libs/ms/bldcapt.c.NEW Wed Jun 13 16:46:09 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/bldcapt.c,v 2.14 89/12/22 15:52:52 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/bldcapt.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/bldcapt.c,v 2.15 90/06/05 14:34:04 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/bldcapt.c,v $ */ #include #include *************** *** 27,33 **** #define BIGCAPTPASTDATE 65 extern int postmanvuid, myvuid; ! extern char *months[], *malloc(), *index(), MyMailDomain[]; BuildCaption(Msg, Template, IsMyMail) struct MS_Message *Msg; --- 27,37 ---- #define BIGCAPTPASTDATE 65 extern int postmanvuid, myvuid; ! extern char *months[], *index(), MyMailDomain[]; ! ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ BuildCaption(Msg, Template, IsMyMail) struct MS_Message *Msg; *** ams/libs/ms/bldreply.c Wed Nov 22 11:32:15 1989 --- ams/libs/ms/bldreply.c.NEW Wed Jun 13 16:46:11 1990 *************** *** 3,15 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/bldreply.c,v 2.6 89/04/23 18:36:46 pgc Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/bldreply.c,v $ */ #include #include extern char *malloc(); BuildReplyField(Msg) struct MS_Message *Msg; --- 3,17 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/bldreply.c,v 2.7 90/06/05 14:34:18 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/bldreply.c,v $ */ #include #include + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ BuildReplyField(Msg) struct MS_Message *Msg; *** ams/libs/ms/bldwide.c Wed Nov 22 11:32:10 1989 --- ams/libs/ms/bldwide.c.NEW Wed Jun 13 16:46:13 1990 *************** *** 3,15 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/bldwide.c,v 2.8 89/10/27 17:11:57 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/bldwide.c,v $ */ #include #include extern char *malloc(), *realloc(); BuildWideReply(Msg, IncludeFrom) struct MS_Message *Msg; --- 3,17 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/bldwide.c,v 2.9 90/06/05 14:34:23 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/bldwide.c,v $ */ #include #include + #ifndef _IBMR2 extern char *malloc(), *realloc(); + #endif /* _IBMR2 */ BuildWideReply(Msg, IncludeFrom) struct MS_Message *Msg; *** ams/libs/ms/chzdirs.c Wed Jan 17 16:35:35 1990 --- ams/libs/ms/chzdirs.c.NEW Wed Jun 13 16:46:22 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/chzdirs.c,v 2.16 89/05/23 18:43:23 bobg Exp $ ! $Source: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/chzdirs.c,v $ */ /* chzdirs.c -- Routines for deciding in which directories to put mail --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/chzdirs.c,v 2.17 90/06/05 14:34:28 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/chzdirs.c,v $ */ /* chzdirs.c -- Routines for deciding in which directories to put mail *************** *** 17,23 **** */ ! char ams_choosedirs_rcsid[] = "$Header: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/chzdirs.c,v 2.16 89/05/23 18:43:23 bobg Exp $"; #include #include --- 17,23 ---- */ ! char ams_choosedirs_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/chzdirs.c,v 2.17 90/06/05 14:34:28 gk5g Exp $"; #include #include *************** *** 38,44 **** * months */ extern char *pop(); ! extern char *index(), *malloc(), *realloc(), *rindex(); extern char *StripWhiteEnds(), *GenAuthField(); extern FILE *qopen(); extern char Me[], *MyPrettyAddress, home[], MyMailDomain[]; --- 38,49 ---- * months */ extern char *pop(); ! extern char *index(), *rindex(); ! ! #ifndef _IBMR2 ! extern char *malloc(), *realloc(); ! #endif /* _IBMR2 */ ! extern char *StripWhiteEnds(), *GenAuthField(); extern FILE *qopen(); extern char Me[], *MyPrettyAddress, home[], MyMailDomain[]; *** ams/libs/ms/cvtold.c Wed Nov 22 11:32:32 1989 --- ams/libs/ms/cvtold.c.NEW Fri Jul 20 11:21:48 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/cvtold.c,v 2.13 89/09/01 16:05:54 cfe Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/cvtold.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/cvtold.c,v 2.13 89/09/01 16:05:54 cfe Exp $ "; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/cvtold.c,v 2.15 90/07/13 11:16:03 tpn Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/cvtold.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/cvtold.c,v 2.15 90/07/13 11:16:03 tpn Exp $ "; #endif /* lint */ #include *************** *** 14,26 **** #include #include #include /* sys/types.h sys/file.h sys/time.h */ - #include #include #include #include #include ! extern char *malloc(), *index(); extern int errno; extern FILE *fopen(); extern char home[]; --- 14,29 ---- #include #include #include /* sys/types.h sys/file.h sys/time.h */ #include #include #include #include ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char *index(); extern int errno; extern FILE *fopen(); extern char home[]; *************** *** 170,176 **** int *FilesReadIn; { FILE *fp; ! int wfd = 0, i, errsave, tfd, AnyWrittenToThisOne, LockFD; short FileOpen, ReadyToStartAgain; struct stat statbuf; char buffer[buffsize], FName[1+MAXPATHLEN], CurLock[1+MAXPATHLEN]; --- 173,179 ---- int *FilesReadIn; { FILE *fp; ! int wfd = 0, i, errsave, tfd, AnyWrittenToThisOne, LockFD,blen; short FileOpen, ReadyToStartAgain; struct stat statbuf; char buffer[buffsize], FName[1+MAXPATHLEN], CurLock[1+MAXPATHLEN]; *************** *** 248,260 **** if ((buffer[0] == AMS_SeparatingCharacter) && (AnyWrittenToThisOne != 0)) { ReadyToStartAgain = 1; } else { ! writeall(wfd, buffer, strlen(buffer)); AnyWrittenToThisOne = 1; ReadyToStartAgain = 0; } } else { ReadyToStartAgain = (buffer[0] == '\n') ? 1 : 0; ! writeall(wfd, buffer, strlen(buffer)); AnyWrittenToThisOne = 1; } } --- 251,277 ---- if ((buffer[0] == AMS_SeparatingCharacter) && (AnyWrittenToThisOne != 0)) { ReadyToStartAgain = 1; } else { ! blen = strlen(buffer); ! if(writeall(wfd, buffer,blen) != blen){ ! errsave = errno; ! fclose(fp); ! close(wfd); ! if (AMS_StrictStandaloneLocking) rmlock(CurLock, LockFD); ! AMS_RETURN_ERRCODE(errsave, EIN_WRITE, EVIA_CONVERTINCOMING); ! } AnyWrittenToThisOne = 1; ReadyToStartAgain = 0; } } else { ReadyToStartAgain = (buffer[0] == '\n') ? 1 : 0; ! blen = strlen(buffer); ! if(writeall(wfd, buffer,blen) != blen){ ! errsave = errno; ! fclose(fp); ! close(wfd); ! if (AMS_StrictStandaloneLocking) rmlock(CurLock, LockFD); ! AMS_RETURN_ERRCODE(errsave, EIN_WRITE, EVIA_CONVERTINCOMING); ! } AnyWrittenToThisOne = 1; } } *** ams/libs/ms/epoch.c Wed Nov 22 11:32:51 1989 --- ams/libs/ms/epoch.c.NEW Wed Jun 13 16:46:27 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/epoch.c,v 2.26 89/07/20 14:11:11 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/epoch.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/epoch.c,v 2.27 90/06/05 14:34:51 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/epoch.c,v $ */ #include #include *************** *** 11,17 **** --- 11,19 ---- #include #include + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ static int dirCmp(s1, s2) char **s1, **s2; *** ams/libs/ms/fixsub.c Wed Nov 22 11:34:58 1989 --- ams/libs/ms/fixsub.c.NEW Wed Jun 13 16:46:28 1990 *************** *** 3,14 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/fixsub.c,v 2.3 89/02/08 15:45:18 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/fixsub.c,v $ */ #include extern char *malloc(); struct { char *left, *right; --- 3,16 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/fixsub.c,v 2.4 90/06/05 14:35:02 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/fixsub.c,v $ */ #include + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ struct { char *left, *right; *** ams/libs/ms/flushdir.c Wed Nov 22 11:32:59 1989 --- ams/libs/ms/flushdir.c.NEW Wed Jun 13 16:46:30 1990 *************** *** 3,14 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/flushdir.c,v 2.4 89/02/08 15:33:16 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/flushdir.c,v $ */ #include extern char *malloc(); #define MAXNUMWAITING 5 struct MS_Directory *MyOpenDir = NULL; --- 3,16 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/flushdir.c,v 2.5 90/06/05 14:35:06 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/flushdir.c,v $ */ #include + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ #define MAXNUMWAITING 5 struct MS_Directory *MyOpenDir = NULL; *** ams/libs/ms/hdlnew.c Mon Mar 12 13:15:14 1990 --- ams/libs/ms/hdlnew.c.NEW Wed Jun 13 16:46:35 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/hdlnew.c,v 2.52 90/02/15 15:41:15 bobg Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/hdlnew.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/hdlnew.c,v 2.52 90/02/15 15:41:15 bobg Exp $ "; #endif /* lint */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/hdlnew.c,v 2.53 90/06/12 15:23:26 bobg Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/hdlnew.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/hdlnew.c,v 2.53 90/06/12 15:23:26 bobg Exp $ "; #endif /* lint */ *************** *** 1236,1241 **** --- 1236,1245 ---- Msg = (struct MS_Message *) argv[0]; start = (int) argv[1]; len = (int) argv[2]; + if (len == 0) { + PrepareReturnString(st, "", 0, resbuf); + return; + } if ((start >= 0) && (len > 0) && ((start + len) <= (Msg->FullSize - Msg->HeadSize))) { bodybuf = malloc(1 + len); if (!bodybuf) { *** ams/libs/ms/hdlpref.c Wed Nov 22 11:31:59 1989 --- ams/libs/ms/hdlpref.c.NEW Wed Jun 13 16:46:38 1990 *************** *** 3,14 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/hdlpref.c,v 2.3 89/02/08 15:31:21 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/hdlpref.c,v $ */ #include ! extern char *malloc(), *getprofile(); MS_HandlePreference(prog, pref, InVal, OutVal, OutLim, opcode, resulti, defaulti) char *prog, *pref, *InVal; /* Passed IN */ --- 3,18 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/hdlpref.c,v 2.4 90/06/05 14:35:12 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/hdlpref.c,v $ */ #include ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char *getprofile(); MS_HandlePreference(prog, pref, InVal, OutVal, OutLim, opcode, resulti, defaulti) char *prog, *pref, *InVal; /* Passed IN */ *** ams/libs/ms/init.c Mon Mar 12 13:15:19 1990 --- ams/libs/ms/init.c.NEW Wed Jun 13 16:46:41 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/init.c,v 2.36 90/02/15 15:41:40 bobg Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/init.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/init.c,v 2.38 90/06/04 16:47:46 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/init.c,v $ */ #include #include *************** *** 26,32 **** #endif /* hpux */ extern char **environ; ! extern char *getprofile(), *index(), *rindex(), *StripWhiteEnds(), *malloc(); extern FILE *fopen(); char *StandardHeaderNames[] = { --- 26,37 ---- #endif /* hpux */ extern char **environ; ! extern char *getprofile(), *index(), *rindex(), *StripWhiteEnds(); ! ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! extern FILE *fopen(); char *StandardHeaderNames[] = { *************** *** 512,567 **** #ifdef SIGXCPU signal(SIGXCPU, DieYouHeathenSwine); #endif /* SIGXCPU */ - } - - /* Find the User name in a gecos field, if posible, returning the malloced result */ - - GetNameFromGecos(fullname, userid, domain, newname) - char *fullname, *userid, *domain; - char **newname; - { - if (AMS_GecosHacks && domain && ThisDomain - && (ULstrcmp(domain, ThisDomain) == 0)) { - char *ampersand, *strt, *othr; - char NameCopy[250]; - int len; - - strncpy(NameCopy, fullname, sizeof(NameCopy)); - NameCopy[sizeof(NameCopy)-1] = '\0'; - strt = NameCopy; - if (*strt == '*') ++strt; - for (othr = strt; *othr != '\0'; ++othr) { /* look for sysV gecos format */ - if (*othr == '-' && othr[1] != '\0') { /* Aha! digits, hyphen: call it sysV. */ - ++othr; - strt = othr; - break; - } - if (!isdigit(*othr)) break; /* nope--not a leading digit string */ - } - othr = index(strt, ','); - if (othr != NULL) *othr = '\0'; - ampersand = index(strt, '&'); - len = strlen(strt) + 1; - if (ampersand != NULL) { - len += strlen(userid); - } - *newname = malloc(len); - if (*newname != NULL) { - if (ampersand != NULL) { - strncpy(*newname, strt, ampersand - strt + 1); - othr = (*newname) + (ampersand - strt); - strcpy(othr, userid); - if (islower(*othr)) *othr = toupper(*othr); - strcat(*newname, ampersand+1); - } else { - strcpy(*newname, strt); - } - } - } else { - *newname = malloc(1+strlen(fullname)); - if (*newname != NULL) strcpy(*newname, fullname); - } - return(0); } MS_GetConfigurationParameters(MailDomain, len, UseAmsDelivery, UseNameSep, DelType) --- 517,522 ---- *** ams/libs/ms/instinfo.c Wed Nov 22 11:33:24 1989 --- ams/libs/ms/instinfo.c.NEW Wed Jun 13 16:46:42 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/instinfo.c,v 2.6 89/02/17 18:58:02 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/instinfo.c,v $ */ #include #include /* sys/file.h */ --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/instinfo.c,v 2.7 90/06/05 14:35:15 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/instinfo.c,v $ */ #include #include /* sys/file.h */ *************** *** 12,18 **** #include #include ! extern char Me[], *MyPrettyAddress, home[], *malloc(); MS_InstallWelcomeMessage(ParentName, InitDir, InitFile, ShortName) char *ParentName, *InitDir, *InitFile, *ShortName; --- 12,22 ---- #include #include ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char Me[], *MyPrettyAddress, home[]; MS_InstallWelcomeMessage(ParentName, InitDir, InitFile, ShortName) char *ParentName, *InitDir, *InitFile, *ShortName; *** ams/libs/ms/msdir.c Wed Nov 22 11:33:54 1989 --- ams/libs/ms/msdir.c.NEW Mon Jun 25 10:07:21 1990 *************** *** 3,16 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/msdir.c,v 2.30 89/10/26 11:03:57 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/msdir.c,v $ */ /* msdir.c -- Routines for manipulating message directory structures */ ! char ams_msdir_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/msdir.c,v 2.30 89/10/26 11:03:57 cfe Exp $"; #include #include --- 3,16 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/msdir.c,v 2.32 90/06/22 19:58:40 bobg Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/msdir.c,v $ */ /* msdir.c -- Routines for manipulating message directory structures */ ! char ams_msdir_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/msdir.c,v 2.32 90/06/22 19:58:40 bobg Exp $"; #include #include *************** *** 20,26 **** #include /* for htonl, etc. */ #include ! extern char *malloc(), *realloc(), *permanentmalloc(), *index(); extern unsigned long KRHash(); struct dcnode { --- 20,30 ---- #include /* for htonl, etc. */ #include ! #ifndef _IBMR2 ! extern char *malloc(), *realloc(); ! #endif /* _IBMR2 */ ! ! extern char *permanentmalloc(), *index(); extern unsigned long KRHash(); struct dcnode { *************** *** 84,90 **** struct MS_Directory *Dir; { char SBuf[AMS_SNAPSHOTSIZE]; ! unsigned long int mTime, timeTemp; char ErrBuf[100 + MAXPATHLEN]; debug(1, ("AppendMessageToMSDir\n")); --- 88,94 ---- struct MS_Directory *Dir; { char SBuf[AMS_SNAPSHOTSIZE]; ! unsigned long int mTime, timeTemp, bumpLastMsgDate = (unsigned long) 0; char ErrBuf[100 + MAXPATHLEN]; debug(1, ("AppendMessageToMSDir\n")); *************** *** 118,135 **** /* But even more important, do not allow the dates to get out of order */ if (Dir->MessageCount > 0) { ! if (GetSnapshotByNumber(Dir, Dir->MessageCount - 1, SBuf)) { ! return (mserrcode); ! } ! timeTemp = conv64tolong(AMS_DATE(SBuf)); ! if (timeTemp >= mTime) { ! mTime = timeTemp + 1; ! if (mTime > (unsigned long) 0xc0000000 || mTime > ((unsigned long) time(0) + 7 * 24 * 60 * 60)) { ! sprintf(ErrBuf, "Dates in folder %s, %d=%s, are bogus; folder needs reconstruction.", ap_Shorten(Dir->UNIXDir), mTime, NiceTime(mTime)); ! NonfatalBizarreError(ErrBuf); ! } ! strncpy(AMS_DATE(Msg->Snapshot), convlongto64(mTime, 0), AMS_DATESIZE); ! } } if (SetChainField(Msg, Dir, TRUE)) --- 122,159 ---- /* But even more important, do not allow the dates to get out of order */ if (Dir->MessageCount > 0) { ! if (Dir->LastMsgDate[0]) { ! char time64[AMS_DATESIZE + 1]; ! ! bcopy(Dir->LastMsgDate, time64, AMS_DATESIZE); ! time64[AMS_DATESIZE] = '\0'; ! timeTemp = conv64tolong(time64); ! if (timeTemp >= mTime) { ! mTime = timeTemp + 1; ! debug(16, ("New message is older than LastMsgDate, bumping both...\n")); ! /* I'm not going to bother with the paramcheck that the other case (below) does --bobg */ ! strncpy(AMS_DATE(Msg->Snapshot), convlongto64(mTime, 0), AMS_DATESIZE); ! } ! bumpLastMsgDate = mTime; ! } ! else { ! if (GetSnapshotByNumber(Dir, ! Dir->MessageCount - 1, ! SBuf)) { ! return (mserrcode); ! } ! timeTemp = conv64tolong(AMS_DATE(SBuf)); ! if (timeTemp >= mTime) { ! mTime = timeTemp + 1; ! debug(16, ("New message is older than LastMsgDate, bumping both...\n")); ! if (mTime > (unsigned long) 0xc0000000 || mTime > ((unsigned long) time(0) + 7 * 24 * 60 * 60)) { ! sprintf(ErrBuf, "Dates in folder %s, %d=%s, are bogus; folder needs reconstruction.", ap_Shorten(Dir->UNIXDir), mTime, NiceTime(mTime)); ! NonfatalBizarreError(ErrBuf); ! } ! strncpy(AMS_DATE(Msg->Snapshot), convlongto64(mTime, 0), AMS_DATESIZE); ! } ! bumpLastMsgDate = mTime; ! } } if (SetChainField(Msg, Dir, TRUE)) *************** *** 142,147 **** --- 166,177 ---- AMS_RETURN_ERRCODE(errno, EIN_WRITE, EVIA_APPENDMESSAGETOMSDIR); } Dir->MessageCount++; + if (bumpLastMsgDate > 0) { + strncpy(Dir->LastMsgDate, convlongto64(bumpLastMsgDate, 0), + AMS_DATESIZE); + debug(16, ("Set LastMsgDate to %s", + ctime(&bumpLastMsgDate))); + } debug(16, ("Almost done appending message; writing out head again\n")); return (DestructivelyWriteDirectoryHead(Dir)); } *** ams/libs/ms/msprint.c Wed Nov 22 11:33:32 1989 --- ams/libs/ms/msprint.c.NEW Wed Jun 13 16:46:55 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/msprint.c,v 2.22 89/09/06 10:24:48 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/msprint.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/msprint.c,v 2.23 90/06/05 14:35:35 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/msprint.c,v $ */ #include #include *************** *** 20,26 **** #define PRINTPREFIX ".MS.ToPrint" extern char home[], MeInFull[]; ! extern char *malloc(), *StripWhiteEnds(), *index(), *rindex(), *getenv(); extern double getla(); extern int DelayPrinting, AlwaysPrintImmediately; --- 20,31 ---- #define PRINTPREFIX ".MS.ToPrint" extern char home[], MeInFull[]; ! ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char *StripWhiteEnds(), *index(), *rindex(), *getenv(); extern double getla(); extern int DelayPrinting, AlwaysPrintImmediately; *** ams/libs/ms/mswp.c Wed Apr 11 14:17:17 1990 --- ams/libs/ms/mswp.c.NEW Wed Jun 13 16:47:01 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/mswp.c,v 2.39 89/11/07 12:49:40 cfe Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/mswp.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/mswp.c,v 2.39 89/11/07 12:49:40 cfe Exp $ "; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/mswp.c,v 2.42 90/06/04 16:50:10 gk5g Exp $ */ /* $ACIS: $ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/mswp.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/mswp.c,v 2.42 90/06/04 16:50:10 gk5g Exp $ "; #endif /* lint */ #include *************** *** 27,33 **** #include #endif /* WHITEPAGES_ENV */ ! extern char *malloc(), *index(), *rindex(), *realloc(), *StripWhiteEnds(); extern int NeedToTimeOut; extern char home[], Me[], MyMailDomain[]; extern ADDRESS_HOST *MakeHost(); --- 27,38 ---- #include #endif /* WHITEPAGES_ENV */ ! extern char *index(), *rindex(), *StripWhiteEnds(); ! ! #ifndef _IBMR2 ! extern char *malloc(), *realloc(); ! #endif /* _IBMR2 */ ! extern int NeedToTimeOut; extern char home[], Me[], MyMailDomain[]; extern ADDRESS_HOST *MakeHost(); *************** *** 67,73 **** *pathName = *outCell = NULL; *SPEix = -1; ! while (*genPos < MS_NumDirsInSearchPath) { *pathName = SearchPathElements[*genPos].Path; if (SearchPathElements[*genPos].Cell == NULL) { code = GetCellFromFileName(SearchPathElements[*genPos].Path, cellBuf, sizeof(cellBuf)); --- 72,78 ---- *pathName = *outCell = NULL; *SPEix = -1; ! if (*genPos < MS_NumDirsInSearchPath) { *pathName = SearchPathElements[*genPos].Path; if (SearchPathElements[*genPos].Cell == NULL) { code = GetCellFromFileName(SearchPathElements[*genPos].Path, cellBuf, sizeof(cellBuf)); *************** *** 485,491 **** static enum WpState {wpopen_NotOpen, wpopen_CannotOpen, wpopen_Open} WpOpen = wpopen_NotOpen; ! static char WpCell[150] = '\0'; static struct wp_cd *wpCD = NULL; static wp_FieldIndex idxN = -1, idxID, idxAf; --- 490,496 ---- static enum WpState {wpopen_NotOpen, wpopen_CannotOpen, wpopen_Open} WpOpen = wpopen_NotOpen; ! static char WpCell[150] = "\0"; static struct wp_cd *wpCD = NULL; static wp_FieldIndex idxN = -1, idxID, idxAf; *************** *** 1026,1037 **** AMS_RETURN_ERRCODE(ConvertWpErrToMSErr(wpErr, EMSWPREAD, FALSE), EIN_HANDLEADDRESS, EVIA_REWRITEADDRESS); } free(PKey); ! if (CanonName != NULL) { ! CommText = NewString(CanonName); ! if (CommText != NULL) { ! if (Addr->RoutePhrase != NULL) free(Addr->RoutePhrase); ! Addr->RoutePhrase = CommText; ! } } } else { free(PKey); /* we already have all we need */ --- 1031,1038 ---- AMS_RETURN_ERRCODE(ConvertWpErrToMSErr(wpErr, EMSWPREAD, FALSE), EIN_HANDLEADDRESS, EVIA_REWRITEADDRESS); } free(PKey); ! if (CanonName != NULL && Addr->RoutePhrase == NULL) { ! Addr->RoutePhrase = NewString(CanonName); /* not to worry on err */ } } else { free(PKey); /* we already have all we need */ *************** *** 1231,1238 **** } else { sprintf(NewName, (UnderAMSDelivery > 0 ? "%s+" : "%s"), p->pw_name); } ! if (RealName) { ! if (Addr->RoutePhrase) free(Addr->RoutePhrase); Addr->RoutePhrase = RealName; RealName = NULL; /* Consume the name */ } --- 1232,1238 ---- } else { sprintf(NewName, (UnderAMSDelivery > 0 ? "%s+" : "%s"), p->pw_name); } ! if (RealName != NULL && Addr->RoutePhrase == NULL) { Addr->RoutePhrase = RealName; RealName = NULL; /* Consume the name */ } *************** *** 1250,1279 **** return(0); } - static int LookupInLocalDatabase(Addr, laType, IDpart, PostID, IsGoodLocalName, Domain, UnderAMSDelivery, NameSep, Answered) - /* This routine, LookupInLocalDatabase, is a site-dependent routine for performing non-standard name validation. */ - /* A trivial change to this would validate all local names as OK. The body would have 3 lines: - - *Answered = 1; - *IsGoodLocalName = 1; - return(0): - - Of course, the AMS_LocalDatabaseValidation variable would also have to be turned on in mailconf.c, also, either statically or via an AndrewSetup or AMS-Server file. - */ - PARSED_ADDRESS *Addr; /* IN-OUT. The address structure, from parseadd.h. Parts should be rewritten if needed, as this will be unparsed to produce the address in the header. */ - int laType; /* IN. latype_ value defined in mail.h, flags type of local address */ - char *IDpart; /* IN. The part preceding the + in nsb+foobar */ - char *PostID; /* IN. The part following the + in nsb+foobar */ - int *IsGoodLocalName; /* OUT. The Boolean answer about if this is a good name */ - char *Domain; /* IN. the address domain (used, e.g. in choosing white pages to open) */ - int UnderAMSDelivery; /* IN. >0 if this address should be treated as an AMS_DeliverySystem one, <0 if not as one, 0 if unknown. */ - int NameSep; /* IN. >0 means it's the character to separate firstname and lastname in the validated name; <0 means use the userid; 0 means unknown. */ - int *Answered; /* OUT. Boolean that says whether or not this routine actually provided an answer. */ - { - *Answered = 0; /* By default, ignore this routine */ - return(0); /* But don't indicate any errors, either */ - } - static void StripExtraComments(addr, ExtraThingToNuke) PARSED_ADDRESS *addr; char *ExtraThingToNuke; --- 1250,1255 ---- *************** *** 1367,1379 **** do { isnext = FALSE; if (curr == LocalDBVal) { ! int IsGoodLocalName = 0; ! if (LookupInLocalDatabase(Addr, laType, IDpart, PostID, &IsGoodLocalName, Domain, UnderAMSDelivery, NameSep, &Answered)) { AMS_RETURN_ERRCODE(errno, EIN_LOCALNAMEDB, EVIA_REWRITEADDRESS); } if (Answered) { ! *WpCode = IsGoodLocalName ? (CheckAMSFmtOK(Domain) <= 0 ? MSWP_GOODNETMAIL : MSWP_GOODUSER) : MSWP_CRAP; return(0); } } else if ((curr < LocalDBVal)) { --- 1343,1355 ---- do { isnext = FALSE; if (curr == LocalDBVal) { ! int OutCode; ! if (LookupInLocalDatabase(Addr, laType, IDpart, PostID, Domain, UnderAMSDelivery, NameSep, MaxNameMatches, &Answered, &OutCode)) { AMS_RETURN_ERRCODE(errno, EIN_LOCALNAMEDB, EVIA_REWRITEADDRESS); } if (Answered) { ! *WpCode = OutCode; return(0); } } else if ((curr < LocalDBVal)) { *************** *** 1733,1740 **** AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_REWRITEADDRESS); } if (AMSNameSep <= 0 || (PostID && *PostID)) { ! if (Addr->RoutePhrase != NULL) free(Addr->RoutePhrase); ! Addr->RoutePhrase = realname; } else { /* Try to write as firstname.lastname. */ char *S; for (S = realname; *S != '\0'; ++S) if (*S == ' ') *S = AMSNameSep; --- 1709,1719 ---- AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_REWRITEADDRESS); } if (AMSNameSep <= 0 || (PostID && *PostID)) { ! if (Addr->RoutePhrase != NULL) { ! free(realname); ! } else { ! Addr->RoutePhrase = realname; ! } } else { /* Try to write as firstname.lastname. */ char *S; for (S = realname; *S != '\0'; ++S) if (*S == ' ') *S = AMSNameSep; *************** *** 1792,1798 **** WasGoodGlobalAlias = -1; if (AMSDel <= 0 && recdepth == 0 && AMS_AliasesValidation > 0) { if (CheckGlobalAlias(Addr->LocalPart, &WasGoodGlobalAlias, Domain)) { ! if (vdown(AMS_ERRNO)) { ++SawTempFail; } else { if (IDpart) free(IDpart); --- 1771,1777 ---- WasGoodGlobalAlias = -1; if (AMSDel <= 0 && recdepth == 0 && AMS_AliasesValidation > 0) { if (CheckGlobalAlias(Addr->LocalPart, &WasGoodGlobalAlias, Domain)) { ! if (tfail(AMS_ERRNO)) { ++SawTempFail; } else { if (IDpart) free(IDpart); *************** *** 2295,2324 **** char *name, *Domain; int *code; { char LineBuf[1000], *s; FILE *fp; ! errno = 0; ! fp = fopen("/usr/lib/aliases", "r"); ! if (!fp) { ! if (errno == 0) errno = ENOMEM; ! if (errno == ENOENT) return(0); /* Not our problem if there ain't no alias file */ ! else AMS_RETURN_ERRCODE(errno, EIN_FOPEN, EVIA_REWRITEADDRESS); } ! name = StripWhiteEnds(name); ! while (fgets(LineBuf, sizeof(LineBuf), fp)) { ! if (LineBuf[0] == '#') continue; ! s = index(LineBuf, ':'); ! if (!s) continue; ! *s = '\0'; ! s = StripWhiteEnds(LineBuf); ! if (!ULstrcmp(s, name)) { ! *code = (CheckAMSFmtOK(Domain) <= 0 ? MSWP_GOODNETMAIL : MSWP_GOODUSER); ! debug(16, ("CheckGlobalAlias: given %s/%s, returning %d\n", name, Domain, *code)); ! break; } } ! fclose(fp); return(0); } --- 2274,2334 ---- char *name, *Domain; int *code; { + /* Define the macro YELLOWPAGES_ENV in site.h to use YP aliases lookup before the default /usr/lib/aliases. */ + /* AMS_AliasesValidation must also be set to 1 (true) for global alias validation. */ char LineBuf[1000], *s; FILE *fp; + int Found; + #ifdef YELLOWPAGES_ENV + static char *ThisYPDomain = NULL; + char *alias; + int Len; + #endif /* YELLOWPAGES_ENV */ ! Found = 0; ! #ifdef YELLOWPAGES_ENV ! if (LocalYPDomain == NULL) { ! errno = 0; ! if (yp_get_default_domain(&LocalYPDomain)) { ! AMS_RETURN_ERRCODE(errno, EIN_GETCELLFROMWS, EVIA_REWRITEADDRESS); ! } } ! if (LocalYPDomain != NULL && *LocalYPDomain != '\0') { ! alias = NULL; ! if (yp_match(LocalYPDomain, "mail.aliases", name, strlen(name)+1, &alias, &Len) == 0) { ! if (Len != 0) { ! free(alias); ! Found = 1; ! } } } ! #endif /* YELLOWPAGES_ENV */ ! if (Found == 0) { ! errno = 0; ! fp = fopen("/usr/lib/aliases", "r"); ! if (!fp) { ! if (errno == 0) errno = ENOMEM; ! if (errno == ENOENT) return(0); /* Not our problem if there ain't no alias file */ ! else AMS_RETURN_ERRCODE(errno, EIN_FOPEN, EVIA_REWRITEADDRESS); ! } ! name = StripWhiteEnds(name); ! while (fgets(LineBuf, sizeof(LineBuf), fp)) { ! if (LineBuf[0] == '#') continue; ! s = index(LineBuf, ':'); ! if (!s) continue; ! *s = '\0'; ! s = StripWhiteEnds(LineBuf); ! if (!ULstrcmp(s, name)) { ! Found = 1; ! break; ! } ! } ! fclose(fp); ! } ! if (Found != 0) { ! *code = (CheckAMSFmtOK(Domain) <= 0 ? MSWP_GOODNETMAIL : MSWP_GOODUSER); ! debug(16, ("CheckGlobalAlias: given %s/%s, returning %d\n", name, Domain, *code)); ! } return(0); } *************** *** 2330,2337 **** char *domainindex; debug(16, ("ExternalForcingCode: given %s, code %d\n", ExtAddress, codein)); ! if (codein != MSWP_GOODNETMAIL && codein != MSWP_GOODEXTMSDIR && codein != ! MSWP_GOODUSER && codein != MSWP_GOODMSDIR) return(codein); if (RefreshAliasFile()) return (mserrcode); fetmp = ForceExtRoot; domainindex = index(ExtAddress, '@'); --- 2340,2346 ---- char *domainindex; debug(16, ("ExternalForcingCode: given %s, code %d\n", ExtAddress, codein)); ! if (codein != MSWP_GOODNETMAIL && codein != MSWP_GOODEXTMSDIR && codein != MSWP_GOODUSER && codein != MSWP_GOODMSDIR) return(codein); if (RefreshAliasFile()) return (mserrcode); fetmp = ForceExtRoot; domainindex = index(ExtAddress, '@'); *** ams/libs/ms/site.c Fri Jul 27 13:13:29 1990 --- ams/libs/ms/site.c.NEW Wed Jun 13 16:47:06 1990 *************** *** 0 **** --- 1,109 ---- + /* ********************************************************************** *\ + * Copyright IBM Corporation 1988,1989 - All Rights Reserved * + * For full copyright information see:'andrew/config/COPYRITE' * + \* ********************************************************************** */ + /* + $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/site.c,v 1.2 90/06/05 14:35:47 gk5g Exp $ + $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/site.c,v $ + */ + #include + #include + /* Some header files that are useful */ + #include + #include + #include + #include /* sys/file.h */ + #include + #include + #include + #include + #include + + /* Some useful functions and buffers */ + #ifndef _IBMR2 + extern char *malloc(), *realloc(); + #endif /* _IBMR2 */ + + extern char *index(), *rindex(), *StripWhiteEnds(); + extern char *strchr(), *strrchr(); + extern int NeedToTimeOut; + extern char home[], Me[], MyMailDomain[]; + extern ADDRESS_HOST *MakeHost(); + extern PARSED_ADDRESS *SingleAddress(); + + int LookupInLocalDatabase(Addr, laType, IDpart, PostID, Domain, UnderAMSDelivery, NameSep, MaxNameMatches, Answered, MswpCodeP) + /* This routine, LookupInLocalDatabase, is a site-dependent routine for performing non-standard name validation. */ + /* A trivial change to this would validate all local names as OK. The body would have 3 lines: + + *Answered = 1; + *MswpCodeP = (CheckAMSFmtOK(Domain) <= 0 ? MSWP_GOODNETMAIL : MSWP_GOODUSER); + return(0): + + (Sigh. MSWP_GOODUSER is a user who is ready to receive ATK-formatted mail; MSWP_GOODNETMAIL is a user who is not necessarily ready for that. To say that a local name is NOT valid, set *Answered to 1 and set *MswpCodeP to MSWP_CRAP.) + + Of course, the AMS_LocalDatabaseValidation variable would also have to be turned on in mailconf.c, also, either statically or via an AndrewSetup or AMS-Server file. + */ + PARSED_ADDRESS *Addr; /* IN-OUT. The address structure, from parseadd.h. Parts should be rewritten if needed, as this will be unparsed to produce the address in the header. */ + int laType; /* IN. latype_ value defined in mail.h, flags type of local address */ + char *IDpart; /* IN. The part preceding the + in nsb+foobar */ + char *PostID; /* IN. The part following the + in nsb+foobar */ + char *Domain; /* IN. the address domain (used, e.g. in choosing white pages to open) */ + int UnderAMSDelivery; /* IN. >0 if this address should be treated as an AMS_DeliverySystem one, <0 if not as one, 0 if unknown. */ + int NameSep; /* IN. >0 means it's the character to separate firstname and lastname in the validated name; <0 means use the userid; 0 means unknown. */ + int MaxNameMatches; /* IN. Maximum number of matches expected */ + int *Answered; /* OUT. Boolean that says whether or not this routine actually provided an answer. */ + int *MswpCodeP; /* OUT. Integer giving the MSWP_xxx code that best describes this Boolean that says whether or not this routine actually provided an answer. */ + { + *Answered = 0; + return(0); + } + + int GetNameFromGecos(GecosField, LoginID, Domain, PersonalNameP) + /* Find the User name in a gecos field, if posible, returning the malloced result */ + char *GecosField; /* IN The gecos field from the password file for userid */ + char *LoginID; /* IN The login id of the user */ + char *Domain; /* IN Name of this domain */ + char **PersonalNameP; /* OUT The users full name, freshly allocated. */ + { + if (AMS_GecosHacks && ULstrcmp(Domain, ThisDomain) == 0) { + char *ampersand, *strt, *othr; + char NameCopy[250]; + int len; + + strncpy(NameCopy, GecosField, sizeof(NameCopy)); + NameCopy[sizeof(NameCopy)-1] = '\0'; + strt = NameCopy; + if (*strt == '*') ++strt; + for (othr = strt; *othr != '\0'; ++othr) { /* look for sysV gecos format */ + if (*othr == '-' && *othr != '\0') { /* Aha! digits, hyphen: call it sysV. */ + ++othr; + strt = othr; + break; + } + if (!isdigit(*othr)) break; /* nope--not a leading digit string */ + } + othr = index(strt, ','); + if (othr != NULL) *othr = '\0'; + ampersand = index(strt, '&'); + len = strlen(strt) + 1; + if (ampersand != NULL) { + len += strlen(LoginID); + } + *PersonalNameP = malloc(len); + if (*PersonalNameP != NULL) { + if (ampersand != NULL) { + strncpy(*PersonalNameP, strt, ampersand - strt + 1); + othr = (*PersonalNameP) + (ampersand - strt); + strcpy(othr, LoginID); + if (islower(*othr)) *othr = toupper(*othr); + strcat(*PersonalNameP, ampersand+1); + } else { + strcpy(*PersonalNameP, strt); + } + } + } else { + *PersonalNameP = malloc(1+strlen(GecosField)); + if (*PersonalNameP != NULL) strcpy(*PersonalNameP, GecosField); + } + return(0); + } *** ams/libs/ms/mungenew.c Wed Nov 22 11:34:01 1989 --- ams/libs/ms/mungenew.c.NEW Wed Jun 13 16:47:08 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/mungenew.c,v 2.22 89/08/08 14:45:08 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/mungenew.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/mungenew.c,v 2.23 90/06/05 14:35:52 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/mungenew.c,v $ */ #include #include *************** *** 20,26 **** #define MAILBOXFILECHUNK 1000 ! extern char *malloc(), *rindex(), home[], Me[], *PersonalMailCollectionCommand, *GetPersonalMailbox(), *getprofile(), *getenv(); extern int CompareFileTimeStructs(), homeUsesAMSDelivery; /* The following two are to allow us to get decent reporting data from the postman daemon even when it gets a quit signal. */ --- 20,30 ---- #define MAILBOXFILECHUNK 1000 ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char *rindex(), home[], Me[], *PersonalMailCollectionCommand, *GetPersonalMailbox(), *getprofile(), *getenv(); extern int CompareFileTimeStructs(), homeUsesAMSDelivery; /* The following two are to allow us to get decent reporting data from the postman daemon even when it gets a quit signal. */ *** ams/libs/ms/newmail.c Wed Jan 17 16:35:48 1990 --- ams/libs/ms/newmail.c.NEW Wed Jun 13 16:47:16 1990 *************** *** 3,16 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/newmail.c,v 2.14 89/12/22 15:10:23 cfe Exp $ ! $Source: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/newmail.c,v $ */ /* newmail.c -- Routines for accessing incoming mail files in the raw. */ ! char ams_newmail_rcsid[] = "$Header: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/newmail.c,v 2.14 89/12/22 15:10:23 cfe Exp $"; #include #include --- 3,16 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/newmail.c,v 2.15 90/06/05 14:35:59 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/newmail.c,v $ */ /* newmail.c -- Routines for accessing incoming mail files in the raw. */ ! char ams_newmail_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/newmail.c,v 2.15 90/06/05 14:35:59 gk5g Exp $"; #include #include *************** *** 17,23 **** #include #include ! extern char *malloc(), *rindex(), home[]; extern struct MS_Directory *MyOpenDir; --- 17,27 ---- #include #include ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char *rindex(), home[]; extern struct MS_Directory *MyOpenDir; *** ams/libs/ms/papanote.c Wed Nov 22 11:33:44 1989 --- ams/libs/ms/papanote.c.NEW Wed Jun 13 16:47:17 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/papanote.c,v 2.6 89/02/17 18:58:37 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/papanote.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/papanote.c,v 2.7 90/06/05 14:36:06 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/papanote.c,v $ */ #include #include *************** *** 11,17 **** #include /* sys/file.h */ #include ! extern char *malloc(), home[], *index(); AddParentalMessage(Msg, PDirName, bbname, bbpath) struct MS_Message *Msg; --- 11,21 ---- #include /* sys/file.h */ #include ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char home[], *index(); AddParentalMessage(Msg, PDirName, bbname, bbpath) struct MS_Message *Msg; *** ams/libs/ms/parseraw.c Wed Nov 22 11:34:37 1989 --- ams/libs/ms/parseraw.c.NEW Wed Jun 13 16:47:19 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/parseraw.c,v 2.10 89/04/23 19:32:30 pgc Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/parseraw.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/parseraw.c,v 2.11 90/06/05 14:36:12 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/parseraw.c,v $ */ #include #include *************** *** 11,17 **** #include #include ! extern char *malloc(), *index(); extern char *StandardHeaderNames[]; #define ALLOCCHUNK (10+HP_END_PREDEFINED) --- 11,21 ---- #include #include ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char *index(); extern char *StandardHeaderNames[]; #define ALLOCCHUNK (10+HP_END_PREDEFINED) *** ams/libs/ms/purge.c Wed Nov 22 11:34:43 1989 --- ams/libs/ms/purge.c.NEW Mon Jun 25 10:07:24 1990 *************** *** 3,15 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/purge.c,v 2.13 89/05/03 17:07:31 aw0g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/purge.c,v $ */ #include #include /* sys/file.h */ extern char *malloc(); MS_PurgeDeletedMessages(dirname) char *dirname; --- 3,17 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/purge.c,v 2.16 90/06/22 20:04:36 bobg Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/purge.c,v $ */ #include #include /* sys/file.h */ + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ MS_PurgeDeletedMessages(dirname) char *dirname; *** ams/libs/ms/rawdb.c Wed Jan 17 16:35:52 1990 --- ams/libs/ms/rawdb.c.NEW Mon Jun 25 10:07:27 1990 *************** *** 3,18 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/rawdb.c,v 2.51 89/12/18 11:50:01 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/rawdb.c,v $ */ /* ! rawdb.c -- Routines for accessing MS database files in the raw. */ ! char ams_rawdb_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/rawdb.c,v 2.51 89/12/18 11:50:01 cfe Exp $"; ! #include /* sys/file.h */ #include #include #include --- 3,18 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/rawdb.c,v 2.53 90/06/22 20:04:43 bobg Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/rawdb.c,v $ */ /* ! rawdb.c -- Routines for accessing MS database files in the raw. */ ! char ams_rawdb_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/rawdb.c,v 2.53 90/06/22 20:04:43 bobg Exp $"; ! #include /* sys/file.h */ #include #include #include *************** *** 24,38 **** #include #ifdef WHITEPAGES_ENV #include ! #endif /* WHITEPAGES_ENV */ #ifdef AFS_ENV #include #include ! #endif /* AFS_ENV */ #include #include ! extern char *malloc(), *index(), *rindex(), *permanentmalloc(); extern long time(); extern char MyMailDomain[]; --- 24,43 ---- #include #ifdef WHITEPAGES_ENV #include ! #endif /* WHITEPAGES_ENV */ #ifdef AFS_ENV #include #include ! #endif /* AFS_ENV */ #include #include ! #ifndef _IBMR2 ! extern char *malloc(); ! ! #endif /* _IBMR2 */ ! ! extern char *index(), *rindex(), *permanentmalloc(); extern long time(); extern char MyMailDomain[]; *************** *** 39,53 **** static char *EFBIGFormat = "Maximum number of files per directory may have been exceeded closing %s"; /* Forward Declarations */ ! static void FreeUpdates(); ! static void AnnounceBadDirFormat(); ! static void BuildAttrNameBuf(); /* Version number for database format. This number gets stored ! in each message directory when it is written. If the ! message server detects an inconsistency between its version ! and the file's version, it must run a conversion program or ! otherwise figure out how to cope. */ /* The next line should change each time the actual file format changes.*/ --- 44,58 ---- static char *EFBIGFormat = "Maximum number of files per directory may have been exceeded closing %s"; /* Forward Declarations */ ! static void FreeUpdates(); ! static void AnnounceBadDirFormat(); ! static void BuildAttrNameBuf(); /* Version number for database format. This number gets stored ! in each message directory when it is written. If the ! message server detects an inconsistency between its version ! and the file's version, it must run a conversion program or ! otherwise figure out how to cope. */ /* The next line should change each time the actual file format changes.*/ *************** *** 58,86 **** int AdjustIDs(Dir, HowMany) struct MS_Directory *Dir; int HowMany; ! { /* Makes sure that HowMany entries are ! * allocated in the IDs array hanging off ! * Dir->IDs. Returns 0 if OK, -1 if not. */ int Ix; if (HowMany <= 0) ! return -1; if (HowMany <= Dir->NumIDs) ! return 0; if (Dir->IDs != NULL) { ! Dir->IDs = (struct MS_IDs *) realloc(Dir->IDs, HowMany * (sizeof(struct MS_IDs))); } else { ! Dir->IDs = (struct MS_IDs *) malloc(HowMany * (sizeof(struct MS_IDs))); } if (Dir->IDs == NULL) { ! Dir->NumIDs = 0; ! return -1; } for (Ix = Dir->NumIDs; Ix < HowMany; ++Ix) { ! Dir->IDs[Ix].Chn = -1; ! Dir->IDs[Ix].midH = noKRHash; ! Dir->IDs[Ix].repH = noKRHash; } Dir->NumIDs = HowMany; return 0; --- 63,92 ---- int AdjustIDs(Dir, HowMany) struct MS_Directory *Dir; int HowMany; ! { /* Makes sure that HowMany entries ! * are allocated in the IDs array ! * hanging off Dir->IDs. Returns 0 ! * if OK, -1 if not. */ int Ix; if (HowMany <= 0) ! return -1; if (HowMany <= Dir->NumIDs) ! return 0; if (Dir->IDs != NULL) { ! Dir->IDs = (struct MS_IDs *) realloc(Dir->IDs, HowMany * (sizeof(struct MS_IDs))); } else { ! Dir->IDs = (struct MS_IDs *) malloc(HowMany * (sizeof(struct MS_IDs))); } if (Dir->IDs == NULL) { ! Dir->NumIDs = 0; ! return -1; } for (Ix = Dir->NumIDs; Ix < HowMany; ++Ix) { ! Dir->IDs[Ix].Chn = -1; ! Dir->IDs[Ix].midH = noKRHash; ! Dir->IDs[Ix].repH = noKRHash; } Dir->NumIDs = HowMany; return 0; *************** *** 88,102 **** void FreeIDs(Dir) struct MS_Directory *Dir; ! { /* Deallocated the IDs. */ if (Dir->NumIDs > 0 && Dir->IDs != NULL) ! free(Dir->IDs); Dir->NumIDs = 0; Dir->IDs = NULL; } /* The following routine creates a new directory, with the appropriate ! zero-record initialization, but with no messages. */ CreateNewMSDirectory(Dirname, NewDir, Overwrite) --- 94,108 ---- void FreeIDs(Dir) struct MS_Directory *Dir; ! { /* Deallocated the IDs. */ if (Dir->NumIDs > 0 && Dir->IDs != NULL) ! free(Dir->IDs); Dir->NumIDs = 0; Dir->IDs = NULL; } /* The following routine creates a new directory, with the appropriate ! zero-record initialization, but with no messages. */ CreateNewMSDirectory(Dirname, NewDir, Overwrite) *************** *** 111,130 **** debug(1, ("CreateNewMSDirectory (%s) %s\n", Overwrite ? "Overwrite" : "Safe", Dirname)); slash = rindex(Dirname, '/'); if (!slash) { ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_CREATENEWMSDIRECTORY); } ++slash; if ((*slash == '+') || index(slash, ' ') || index(slash, '.')) { ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_CREATENEWMSDIRECTORY); } *NewDir = (struct MS_Directory *) permanentmalloc(sizeof(struct MS_Directory)); if (*NewDir == NULL) { ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_CREATENEWMSDIRECTORY); } debug(2, ("Setting up directory parameters\n")); (*NewDir)->UNIXDir = permanentmalloc(strlen(Dirname) + 1); if (!(*NewDir)->UNIXDir) { ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_CREATENEWMSDIRECTORY); } strcpy((*NewDir)->UNIXDir, Dirname); (*NewDir)->MessageCount = 0; --- 117,136 ---- debug(1, ("CreateNewMSDirectory (%s) %s\n", Overwrite ? "Overwrite" : "Safe", Dirname)); slash = rindex(Dirname, '/'); if (!slash) { ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_CREATENEWMSDIRECTORY); } ++slash; if ((*slash == '+') || index(slash, ' ') || index(slash, '.')) { ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_CREATENEWMSDIRECTORY); } *NewDir = (struct MS_Directory *) permanentmalloc(sizeof(struct MS_Directory)); if (*NewDir == NULL) { ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_CREATENEWMSDIRECTORY); } debug(2, ("Setting up directory parameters\n")); (*NewDir)->UNIXDir = permanentmalloc(strlen(Dirname) + 1); if (!(*NewDir)->UNIXDir) { ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_CREATENEWMSDIRECTORY); } strcpy((*NewDir)->UNIXDir, Dirname); (*NewDir)->MessageCount = 0; *************** *** 138,175 **** (*NewDir)->IDs = NULL; (*NewDir)->NumIDs = 0; if (stat(Dirname, &stbuf) || ((stbuf.st_mode & S_IFMT) != S_IFDIR)) { ! if (mkdir(Dirname, 0777) && errno != EEXIST) { ! AMS_RETURN_ERRCODE(errno, EIN_MKDIR, EVIA_CREATENEWMSDIRECTORY); ! } } sprintf(DirPath, "%s/%s", Dirname, MS_DIRNAME); if (!access(DirPath, F_OK)) { ! debug(2, ("Would overwrite\n")); ! if (Overwrite) { ! MarkInProgress(Dirname); /* If we overwrite, wouldn't hurt to ! * check for lost files */ ! } ! else { ! AMS_RETURN_ERRCODE(EMSWOULDOVERWRITE, EIN_PARAMCHECK, EVIA_CREATENEWMSDIRECTORY); ! } } if (OpenMSDirectory(*NewDir, MD_CREATE)) { ! debug(2, ("Cannot lock\n")); ! return (mserrcode); } debug(2, ("Calling destructive write\n")); status = DestructivelyWriteDirectoryHead((*NewDir)); if (CloseMSDir(*NewDir, MD_CREATE)) { ! return (mserrcode); } if (status) ! return (status); if (AddToDirCache(*NewDir, TRUE)) { ! return (mserrcode); } mserrcode = EnsureInSubscriptionMap(Dirname); if (!mserrcode) { ! mserrcode = DropHint(Dirname); } return (mserrcode); } --- 144,181 ---- (*NewDir)->IDs = NULL; (*NewDir)->NumIDs = 0; if (stat(Dirname, &stbuf) || ((stbuf.st_mode & S_IFMT) != S_IFDIR)) { ! if (mkdir(Dirname, 0777) && errno != EEXIST) { ! AMS_RETURN_ERRCODE(errno, EIN_MKDIR, EVIA_CREATENEWMSDIRECTORY); ! } } sprintf(DirPath, "%s/%s", Dirname, MS_DIRNAME); if (!access(DirPath, F_OK)) { ! debug(2, ("Would overwrite\n")); ! if (Overwrite) { ! MarkInProgress(Dirname); /* If we overwrite, wouldn't hurt ! * to check for lost files */ ! } ! else { ! AMS_RETURN_ERRCODE(EMSWOULDOVERWRITE, EIN_PARAMCHECK, EVIA_CREATENEWMSDIRECTORY); ! } } if (OpenMSDirectory(*NewDir, MD_CREATE)) { ! debug(2, ("Cannot lock\n")); ! return (mserrcode); } debug(2, ("Calling destructive write\n")); status = DestructivelyWriteDirectoryHead((*NewDir)); if (CloseMSDir(*NewDir, MD_CREATE)) { ! return (mserrcode); } if (status) ! return (status); if (AddToDirCache(*NewDir, TRUE)) { ! return (mserrcode); } mserrcode = EnsureInSubscriptionMap(Dirname); if (!mserrcode) { ! mserrcode = DropHint(Dirname); } return (mserrcode); } *************** *** 190,215 **** debug(1, ("In destructively write directory head\n")); if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_DESTRUCTIVELYWRITEDIR); } if (Dir->OpenMode < MD_WRITE) { ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_DESTRUCTIVELYWRITEDIR); } if (lseek(Dir->fd, 0, L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_DESTRUCTIVELYWRITEDIR); } ! itops((long) MS_DB_VERSION, majstr, PADSIZE); /* itops is in util.c */ itops((long) Dir->MaxChainVal, minstr, PADSIZE); ! itops(time(0), killstr, PADSIZE); /* Killer mod time, more or less */ BuildAttrNameBuf(Dir, AttrBuf); sprintf(DirectoryHeader, "%s%s%s%s", ! AMS_DIRECTORY_PREFIX_STRING, majstr, minstr, killstr); ! i = strlen(DirectoryHeader) + 1; /* include FIVE trailing nulls */ ! bzero(DirectoryHeader + i, 4); /* zero out the last four */ bcopy(AttrBuf, DirectoryHeader + i + 4, ATTNAMESLEN); ! bzero(DirectoryHeader + i + 4 + ATTNAMESLEN, AMS_DIRHEADSIZE - (i + ATTNAMESLEN + 5)); if (writeall(Dir->fd, DirectoryHeader, AMS_DIRHEADSIZE) != AMS_DIRHEADSIZE) { ! AMS_RETURN_ERRCODE(errno, EIN_FWRITE, EVIA_DESTRUCTIVELYWRITEDIR); } debug(2, ("Wrote raw head out\n")); return (0); --- 196,235 ---- debug(1, ("In destructively write directory head\n")); if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_DESTRUCTIVELYWRITEDIR); } if (Dir->OpenMode < MD_WRITE) { ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_DESTRUCTIVELYWRITEDIR); } if (lseek(Dir->fd, 0, L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_DESTRUCTIVELYWRITEDIR); } ! itops((long) MS_DB_VERSION, majstr, PADSIZE); /* itops is in util.c */ itops((long) Dir->MaxChainVal, minstr, PADSIZE); ! itops(time(0), killstr, PADSIZE); /* Killer mod time, more or less */ BuildAttrNameBuf(Dir, AttrBuf); sprintf(DirectoryHeader, "%s%s%s%s", ! AMS_DIRECTORY_PREFIX_STRING, majstr, minstr, killstr); ! i = strlen(DirectoryHeader) + 1; /* include FIVE trailing nulls */ ! bzero(DirectoryHeader + i, 4); /* zero out the last four */ bcopy(AttrBuf, DirectoryHeader + i + 4, ATTNAMESLEN); ! if (MSDebugging & 2) { ! char time64[1 + AMS_DATESIZE]; ! unsigned long timenum; ! ! strncpy(time64, Dir->LastMsgDate, AMS_DATESIZE); ! time64[AMS_DATESIZE] = '\0'; ! timenum = (unsigned long) conv64tolong(time64); ! debug(2, ("Placed LastMsgDate into raw head; date is %s", ! ctime(&timenum))); ! } ! bcopy(Dir->LastMsgDate, DirectoryHeader + i + 4 + ATTNAMESLEN, ! AMS_DATESIZE); /* Record the oldest date ever to ! * appear in this folder */ ! bzero(DirectoryHeader + i + 4 + ATTNAMESLEN + AMS_DATESIZE, ! AMS_DIRHEADSIZE - (i + ATTNAMESLEN + AMS_DATESIZE + 5)); if (writeall(Dir->fd, DirectoryHeader, AMS_DIRHEADSIZE) != AMS_DIRHEADSIZE) { ! AMS_RETURN_ERRCODE(errno, EIN_FWRITE, EVIA_DESTRUCTIVELYWRITEDIR); } debug(2, ("Wrote raw head out\n")); return (0); *************** *** 216,224 **** } /* The following routine fills the supplied structure with the up-to-date ! contents of the named directory. Any previous contents to the ! structure will be lost -- this is not the right routine to ! use for updating an old representation of a directory */ ReadOldMSDirectoryHead(Dir) --- 236,244 ---- } /* The following routine fills the supplied structure with the up-to-date ! contents of the named directory. Any previous contents to the ! structure will be lost -- this is not the right routine to ! use for updating an old representation of a directory */ ReadOldMSDirectoryHead(Dir) *************** *** 229,265 **** ReadOldMSDirectoryHead_Complain(Dir, DoComplain) struct MS_Directory *Dir; ! int DoComplain; { int numbytes; char DirHead[AMS_DIRHEADSIZE + 1], AttrBuf[ATTNAMESLEN + 1]; ! char ConvBuf[PADSIZE + 1]; /* For conversion of ascii long ints */ struct stat statbuf; if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_READOLDMSDIR); } if (fstat(Dir->fd, &statbuf)) { ! AMS_RETURN_ERRCODE(errno, EIN_FSTAT, EVIA_READOLDMSDIR); } if (statbuf.st_size < AMS_DIRHEADSIZE ! || ((statbuf.st_size - AMS_DIRHEADSIZE) % AMS_SNAPSHOTSIZE)) { ! if (DoComplain) AnnounceBadDirFormat(Dir->UNIXDir); ! AMS_RETURN_ERRCODE(EMSBADDIRFORMAT, EIN_SIZECHECK, EVIA_READOLDMSDIR); } if (lseek(Dir->fd, 0, L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_READOLDMSDIR); } if ((numbytes = read(Dir->fd, DirHead, AMS_DIRHEADSIZE)) != AMS_DIRHEADSIZE) { ! if (numbytes >= 0) { ! if (DoComplain) AnnounceBadDirFormat(Dir->UNIXDir); ! errno = EMSBADDIRFORMAT; ! } ! AMS_RETURN_ERRCODE(errno, EIN_READ, EVIA_READOLDMSDIR); } if (bcmp(DirHead, AMS_DIRECTORY_PREFIX_STRING, sizeof(AMS_DIRECTORY_PREFIX_STRING) - 1)) { ! if (DoComplain) AnnounceBadDirFormat(Dir->UNIXDir); ! AMS_RETURN_ERRCODE(EMSBADDIRFORMAT, EIN_BCMP, EVIA_READOLDMSDIR); } bcopy(DirHead + sizeof(AMS_DIRECTORY_PREFIX_STRING) - 1, ConvBuf, PADSIZE); ConvBuf[PADSIZE] = 0; --- 249,289 ---- ReadOldMSDirectoryHead_Complain(Dir, DoComplain) struct MS_Directory *Dir; ! int DoComplain; { int numbytes; char DirHead[AMS_DIRHEADSIZE + 1], AttrBuf[ATTNAMESLEN + 1]; ! char ConvBuf[PADSIZE + 1]; /* For conversion of ascii ! * long ints */ struct stat statbuf; if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_READOLDMSDIR); } if (fstat(Dir->fd, &statbuf)) { ! AMS_RETURN_ERRCODE(errno, EIN_FSTAT, EVIA_READOLDMSDIR); } if (statbuf.st_size < AMS_DIRHEADSIZE ! || ((statbuf.st_size - AMS_DIRHEADSIZE) % AMS_SNAPSHOTSIZE)) { ! if (DoComplain) ! AnnounceBadDirFormat(Dir->UNIXDir); ! AMS_RETURN_ERRCODE(EMSBADDIRFORMAT, EIN_SIZECHECK, EVIA_READOLDMSDIR); } if (lseek(Dir->fd, 0, L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_READOLDMSDIR); } if ((numbytes = read(Dir->fd, DirHead, AMS_DIRHEADSIZE)) != AMS_DIRHEADSIZE) { ! if (numbytes >= 0) { ! if (DoComplain) ! AnnounceBadDirFormat(Dir->UNIXDir); ! errno = EMSBADDIRFORMAT; ! } ! AMS_RETURN_ERRCODE(errno, EIN_READ, EVIA_READOLDMSDIR); } if (bcmp(DirHead, AMS_DIRECTORY_PREFIX_STRING, sizeof(AMS_DIRECTORY_PREFIX_STRING) - 1)) { ! if (DoComplain) ! AnnounceBadDirFormat(Dir->UNIXDir); ! AMS_RETURN_ERRCODE(EMSBADDIRFORMAT, EIN_BCMP, EVIA_READOLDMSDIR); } bcopy(DirHead + sizeof(AMS_DIRECTORY_PREFIX_STRING) - 1, ConvBuf, PADSIZE); ConvBuf[PADSIZE] = 0; *************** *** 270,341 **** * NOTE THAT THE NEXT chunk of bytes are currently wasted -- these are * PADSIZE bytes that start at DirHead + * sizeof(AMS_DIRECTORY_PREFIX_STRING) + PADSIZE -1 and are being ! * reserved for future use */ bcopy(DirHead + sizeof(AMS_DIRECTORY_PREFIX_STRING) + PADSIZE - 1, ConvBuf, PADSIZE); ConvBuf[PADSIZE] = 0; Dir->MaxChainVal = atoi(ConvBuf); if (Dir->DBMajorVersion < 4) ! Dir->MaxChainVal = 0; ! bcopy(DirHead + sizeof(AMS_DIRECTORY_PREFIX_STRING) + PADSIZE + PADSIZE - 1, ConvBuf, PADSIZE); /* Currently obsolete ? */ ConvBuf[PADSIZE] = 0; Dir->AttrCount = 0; if (Dir->DBMajorVersion >= 4) { ! char ABuf[AMS_ATTRNAMEMAX + 1], *Ptrs[AMS_NUM_UATTRS]; ! int i; ! bcopy(DirHead + sizeof(AMS_DIRECTORY_PREFIX_STRING) + (3 * PADSIZE) + 3, AttrBuf, ATTNAMESLEN); ! while ((Dir->AttrCount < AMS_ATTRNAMEMAX) && (AttrBuf[(Dir->AttrCount * AMS_ATTRNAMEMAX) + 1] != '\0')) { ! strncpy(ABuf, &AttrBuf[(Dir->AttrCount * AMS_ATTRNAMEMAX) + 1], ! AMS_ATTRNAMEMAX); ! ABuf[AMS_ATTRNAMEMAX] = '\0'; ! debug(2, ("Found attribute named %s\n", ABuf)); ! Ptrs[Dir->AttrCount] = malloc(1 + strlen(ABuf)); ! if (!Ptrs[Dir->AttrCount]) { ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_READOLDMSDIR); ! } ! strcpy(Ptrs[Dir->AttrCount], ABuf); ! ++(Dir->AttrCount); ! } ! /* Always leave room for all of the attribute names here */ ! if (!Dir->AttrNames) { ! Dir->AttrNames = (char **) permanentmalloc(AMS_NUM_UATTRS * sizeof(char *)); ! if (!Dir->AttrNames) { ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_READOLDMSDIR); ! } ! bzero(Dir->AttrNames, AMS_NUM_UATTRS * sizeof(char *)); ! } ! if (Dir->AttrCount) { ! for (i = 0; i < Dir->AttrCount; ++i) { ! if (Dir->AttrNames[i]) ! free(Dir->AttrNames[i]); ! Dir->AttrNames[i] = Ptrs[i]; ! } ! } } else { ! Dir->AttrNames = NULL; } debug(2, ("Number of user attribute names: %d\n", Dir->AttrCount)); if ((MSDebugging & 2) && Dir->AttrNames) { ! int i; ! for (i = 0; i < Dir->AttrCount; ++i) { ! debug(2, ("Attribute #%d is named %s\n", i, Dir->AttrNames[i])); ! } } Dir->MessageCount = ((statbuf.st_size - AMS_DIRHEADSIZE) / AMS_SNAPSHOTSIZE); ! if (Dir->MessageCount > 0) { ! char MySnapshot[AMS_SNAPSHOTSIZE]; ! if (GetSnapshotByNumber(Dir, Dir->MessageCount - 1, MySnapshot)) { ! return (mserrcode); ! } ! strncpy(Dir->LastMsgDate, AMS_DATE(MySnapshot), AMS_DATESIZE); } - else { - Dir->LastMsgDate[0] = '\0'; - } Dir->FileDateWhenRead = statbuf.st_mtime; debug(2, ("File mod date is %ld\n", Dir->FileDateWhenRead)); return (0); --- 294,392 ---- * NOTE THAT THE NEXT chunk of bytes are currently wasted -- these are * PADSIZE bytes that start at DirHead + * sizeof(AMS_DIRECTORY_PREFIX_STRING) + PADSIZE -1 and are being ! * reserved for future use */ bcopy(DirHead + sizeof(AMS_DIRECTORY_PREFIX_STRING) + PADSIZE - 1, ConvBuf, PADSIZE); ConvBuf[PADSIZE] = 0; Dir->MaxChainVal = atoi(ConvBuf); if (Dir->DBMajorVersion < 4) ! Dir->MaxChainVal = 0; ! bcopy(DirHead + sizeof(AMS_DIRECTORY_PREFIX_STRING) + PADSIZE + PADSIZE - 1, ConvBuf, PADSIZE); /* Currently obsolete ? */ ConvBuf[PADSIZE] = 0; Dir->AttrCount = 0; if (Dir->DBMajorVersion >= 4) { ! char ABuf[AMS_ATTRNAMEMAX + 1], *Ptrs[AMS_NUM_UATTRS]; ! int i; ! bcopy(DirHead + sizeof(AMS_DIRECTORY_PREFIX_STRING) + (3 * PADSIZE) + 3, AttrBuf, ATTNAMESLEN); ! while ((Dir->AttrCount < AMS_ATTRNAMEMAX) && (AttrBuf[(Dir->AttrCount * AMS_ATTRNAMEMAX) + 1] != '\0')) { ! strncpy(ABuf, &AttrBuf[(Dir->AttrCount * AMS_ATTRNAMEMAX) + 1], ! AMS_ATTRNAMEMAX); ! ABuf[AMS_ATTRNAMEMAX] = '\0'; ! debug(2, ("Found attribute named %s\n", ABuf)); ! Ptrs[Dir->AttrCount] = malloc(1 + strlen(ABuf)); ! if (!Ptrs[Dir->AttrCount]) { ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_READOLDMSDIR); ! } ! strcpy(Ptrs[Dir->AttrCount], ABuf); ! ++(Dir->AttrCount); ! } ! /* Always leave room for all of the attribute names here */ ! if (!Dir->AttrNames) { ! Dir->AttrNames = (char **) permanentmalloc(AMS_NUM_UATTRS * sizeof(char *)); ! if (!Dir->AttrNames) { ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_READOLDMSDIR); ! } ! bzero(Dir->AttrNames, AMS_NUM_UATTRS * sizeof(char *)); ! } ! if (Dir->AttrCount) { ! for (i = 0; i < Dir->AttrCount; ++i) { ! if (Dir->AttrNames[i]) ! free(Dir->AttrNames[i]); ! Dir->AttrNames[i] = Ptrs[i]; ! } ! } ! bcopy(DirHead + sizeof(AMS_DIRECTORY_PREFIX_STRING) ! + (3 * PADSIZE) + 4 + ATTNAMESLEN, ! Dir->LastMsgDate, AMS_DATESIZE); /* It'll either be a valid date, or all zeroes */ ! if (MSDebugging & 2) { ! if (Dir->LastMsgDate[0]) { ! char time64[AMS_DATESIZE + 1]; ! unsigned long timenum; ! ! bcopy(Dir->LastMsgDate, time64, AMS_DATESIZE); ! time64[AMS_DATESIZE] = '\0'; ! timenum = (unsigned long) conv64tolong(time64); ! debug(2, ("LastMsgDate for %s is %s", ! Dir->UNIXDir, ctime(&timenum))); ! } ! else ! debug(2, ("LastMsgDate for %s is not set...\n", ! Dir->UNIXDir)); ! } } else { ! Dir->AttrNames = NULL; } debug(2, ("Number of user attribute names: %d\n", Dir->AttrCount)); if ((MSDebugging & 2) && Dir->AttrNames) { ! int i; ! for (i = 0; i < Dir->AttrCount; ++i) { ! debug(2, ("Attribute #%d is named %s\n", i, Dir->AttrNames[i])); ! } } Dir->MessageCount = ((statbuf.st_size - AMS_DIRHEADSIZE) / AMS_SNAPSHOTSIZE); ! if (!(Dir->LastMsgDate[0])) { ! if (Dir->MessageCount > 0) { ! char MySnapshot[AMS_SNAPSHOTSIZE]; ! if (GetSnapshotByNumber(Dir, Dir->MessageCount - 1, MySnapshot)) { ! return (mserrcode); ! } ! strncpy(Dir->LastMsgDate, AMS_DATE(MySnapshot), AMS_DATESIZE); ! if (MSDebugging & 2) { ! unsigned long timenum; ! ! timenum = (unsigned long) conv64tolong(AMS_DATE(MySnapshot)); ! debug(2, ("Set LastMsgDate for %s to %s", ! Dir->UNIXDir, ctime(&timenum))); ! } ! } ! else { ! debug(2, ("No messages in %s, not setting LastMsgDate.\n", Dir->UNIXDir)); ! } } Dir->FileDateWhenRead = statbuf.st_mtime; debug(2, ("File mod date is %ld\n", Dir->FileDateWhenRead)); return (0); *************** *** 347,378 **** char NameBuf[1000], *aname, *abuf; if (Msg->AuthName) { ! aname = Msg->AuthName; } else { ! GetCellularUserName(Msg->AuthUid, Msg->AuthCell, NameBuf, sizeof(NameBuf)); ! aname = NameBuf; } abuf = malloc(25 + strlen(Msg->AuthCell ? Msg->AuthCell : WorkstationName) + (2 * strlen(aname))); if (!abuf) ! return (NULL); #ifdef AFS_ENV if (Msg->AuthUid == ANONYMOUSID || Msg->AuthUid == ANYUSERID) { ! sprintf(abuf, "%d", ANONYMOUSID); } else ! #endif /* AFS_ENV */ { ! char *newpos; ! sprintf(abuf, "%d;%s;", Msg->AuthUid, Msg->AuthCell ? Msg->AuthCell : WorkstationName); ! newpos = &abuf[strlen(abuf)]; ! while (*aname) { ! if (*aname == ';' || *aname == '\\') ! *newpos++ = '\\'; ! *newpos++ = *aname++; ! } ! *newpos = '\0'; } return (abuf); } --- 398,429 ---- char NameBuf[1000], *aname, *abuf; if (Msg->AuthName) { ! aname = Msg->AuthName; } else { ! GetCellularUserName(Msg->AuthUid, Msg->AuthCell, NameBuf, sizeof(NameBuf)); ! aname = NameBuf; } abuf = malloc(25 + strlen(Msg->AuthCell ? Msg->AuthCell : WorkstationName) + (2 * strlen(aname))); if (!abuf) ! return (NULL); #ifdef AFS_ENV if (Msg->AuthUid == ANONYMOUSID || Msg->AuthUid == ANYUSERID) { ! sprintf(abuf, "%d", ANONYMOUSID); } else ! #endif /* AFS_ENV */ { ! char *newpos; ! sprintf(abuf, "%d;%s;", Msg->AuthUid, Msg->AuthCell ? Msg->AuthCell : WorkstationName); ! newpos = &abuf[strlen(abuf)]; ! while (*aname) { ! if (*aname == ';' || *aname == '\\') ! *newpos++ = '\\'; ! *newpos++ = *aname++; ! } ! *newpos = '\0'; } return (abuf); } *************** *** 388,468 **** debug(1, ("Write pure file %s\n", File)); if (Msg->RawBits == NULL) { ! AMS_RETURN_ERRCODE(EMSBADMSGFORMAT, EIN_PARAMCHECK, EVIA_WRITEPUREFILE); } /* Bogus -- what if not overwrite? */ fd = open(File, ! Overwrite ? O_CREAT | O_TRUNC | O_WRONLY : O_CREAT | O_EXCL | O_WRONLY, ! Mode); if (fd < 0) { #ifdef AFS_ENV ! if (AMS_ViceIsRunning) { ! if (errno == EFBIG) { ! char ErrorText[100 + MAXPATHLEN]; ! sprintf(ErrorText, EFBIGFormat, ap_Shorten(File)); ! CriticalBizarreError(ErrorText); ! } ! } ! #endif /* AFS_ENV */ ! AMS_RETURN_ERRCODE(errno, EIN_OPEN, EVIA_WRITEPUREFILE); } if (!Msg->ParsedStuff->HeadBody[HP_AUTHENTICATED_AS]) { ! char MyAuthHead[800], *authfield; ! authfield = GenAuthField(Msg); ! if (!authfield) { ! close(fd); ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_WRITEPUREFILE); ! } ! sprintf(MyAuthHead, "X-Andrew-Authenticated-As: %s\n", authfield); ! free(authfield); ! writeall(fd, MyAuthHead, strlen(MyAuthHead)); } if (strlen(Msg->RawBits) > Msg->HeadSize) { ! char ErrorText[1000]; ! sprintf(ErrorText, "Warning! Message amt read in is %d but should be at least %d, reading %s.", Msg->HeadSize, strlen(Msg->RawBits), ap_Shorten(File)); ! NonfatalBizarreError(ErrorText); ! Msg->HeadSize = strlen(Msg->RawBits); } if (writeall(fd, Msg->RawBits, Msg->HeadSize) != Msg->HeadSize) { ! myerrno = errno; ! vclose(fd); ! AMS_RETURN_ERRCODE(myerrno, EIN_WRITE, EVIA_WRITEPUREFILE); } if (lseek(Msg->OpenFD, Msg->BodyOffsetInFD, L_SET) < 0) { ! myerrno = errno; ! vclose(fd); ! AMS_RETURN_ERRCODE(myerrno, EIN_LSEEK, EVIA_WRITEPUREFILE); } bytesleft = Msg->FullSize - Msg->HeadSize; while (bytesleft > 0) { ! bytestoread = (bytesleft > (sizeof(BigBuf) - 1)) ? (sizeof(BigBuf) - 1) : bytesleft; ! if (read(Msg->OpenFD, BigBuf, bytestoread) != bytestoread) { ! myerrno = errno; ! vclose(fd); ! AMS_RETURN_ERRCODE(myerrno, EIN_READ, EVIA_WRITEPUREFILE); ! } ! if (writeall(fd, BigBuf, bytestoread) != bytestoread) { ! myerrno = errno; ! vclose(fd); ! AMS_RETURN_ERRCODE(myerrno, EIN_FWRITE, EVIA_WRITEPUREFILE); ! } ! bytesleft -= bytestoread; } if (vclose(fd)) { #ifdef AFS_ENV ! if (AMS_ViceIsRunning) { ! if (errno == EFBIG) { ! char ErrorText[100 + MAXPATHLEN]; ! sprintf(ErrorText, EFBIGFormat, ap_Shorten(File)); ! CriticalBizarreError(ErrorText); ! } ! } ! #endif /* AFS_ENV */ ! AMS_RETURN_ERRCODE(errno, EIN_VCLOSE, EVIA_WRITEPUREFILE); } return (0); } --- 439,519 ---- debug(1, ("Write pure file %s\n", File)); if (Msg->RawBits == NULL) { ! AMS_RETURN_ERRCODE(EMSBADMSGFORMAT, EIN_PARAMCHECK, EVIA_WRITEPUREFILE); } /* Bogus -- what if not overwrite? */ fd = open(File, ! Overwrite ? O_CREAT | O_TRUNC | O_WRONLY : O_CREAT | O_EXCL | O_WRONLY, ! Mode); if (fd < 0) { #ifdef AFS_ENV ! if (AMS_ViceIsRunning) { ! if (errno == EFBIG) { ! char ErrorText[100 + MAXPATHLEN]; ! sprintf(ErrorText, EFBIGFormat, ap_Shorten(File)); ! CriticalBizarreError(ErrorText); ! } ! } ! #endif /* AFS_ENV */ ! AMS_RETURN_ERRCODE(errno, EIN_OPEN, EVIA_WRITEPUREFILE); } if (!Msg->ParsedStuff->HeadBody[HP_AUTHENTICATED_AS]) { ! char MyAuthHead[800], *authfield; ! authfield = GenAuthField(Msg); ! if (!authfield) { ! close(fd); ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_WRITEPUREFILE); ! } ! sprintf(MyAuthHead, "X-Andrew-Authenticated-As: %s\n", authfield); ! free(authfield); ! writeall(fd, MyAuthHead, strlen(MyAuthHead)); } if (strlen(Msg->RawBits) > Msg->HeadSize) { ! char ErrorText[1000]; ! sprintf(ErrorText, "Warning! Message amt read in is %d but should be at least %d, reading %s.", Msg->HeadSize, strlen(Msg->RawBits), ap_Shorten(File)); ! NonfatalBizarreError(ErrorText); ! Msg->HeadSize = strlen(Msg->RawBits); } if (writeall(fd, Msg->RawBits, Msg->HeadSize) != Msg->HeadSize) { ! myerrno = errno; ! vclose(fd); ! AMS_RETURN_ERRCODE(myerrno, EIN_WRITE, EVIA_WRITEPUREFILE); } if (lseek(Msg->OpenFD, Msg->BodyOffsetInFD, L_SET) < 0) { ! myerrno = errno; ! vclose(fd); ! AMS_RETURN_ERRCODE(myerrno, EIN_LSEEK, EVIA_WRITEPUREFILE); } bytesleft = Msg->FullSize - Msg->HeadSize; while (bytesleft > 0) { ! bytestoread = (bytesleft > (sizeof(BigBuf) - 1)) ? (sizeof(BigBuf) - 1) : bytesleft; ! if (read(Msg->OpenFD, BigBuf, bytestoread) != bytestoread) { ! myerrno = errno; ! vclose(fd); ! AMS_RETURN_ERRCODE(myerrno, EIN_READ, EVIA_WRITEPUREFILE); ! } ! if (writeall(fd, BigBuf, bytestoread) != bytestoread) { ! myerrno = errno; ! vclose(fd); ! AMS_RETURN_ERRCODE(myerrno, EIN_FWRITE, EVIA_WRITEPUREFILE); ! } ! bytesleft -= bytestoread; } if (vclose(fd)) { #ifdef AFS_ENV ! if (AMS_ViceIsRunning) { ! if (errno == EFBIG) { ! char ErrorText[100 + MAXPATHLEN]; ! sprintf(ErrorText, EFBIGFormat, ap_Shorten(File)); ! CriticalBizarreError(ErrorText); ! } ! } ! #endif /* AFS_ENV */ ! AMS_RETURN_ERRCODE(errno, EIN_VCLOSE, EVIA_WRITEPUREFILE); } return (0); } *************** *** 475,572 **** char DirPath[1 + MAXPATHLEN]; if (Dir->fd >= 0) { ! AMS_RETURN_ERRCODE(EMSDIRALREADYOPEN, EIN_PARAMCHECK, EVIA_OPENMSDIR); } sprintf(DirPath, "%s/%s", Dir->UNIXDir, MS_DIRNAME); Dir->BadScavenge = 0; if (access(DirPath, W_OK)) { ! Dir->Writable = 0; } else { ! Dir->Writable = 1; } switch (Code) { ! case MD_CREATE: ! openmode = O_RDWR | O_CREAT | O_TRUNC; ! break; ! case MD_OK: ! case MD_READ: ! openmode = O_RDONLY; ! break; ! case MD_WRITE: ! case MD_APPEND: ! openmode = O_RDWR; ! break; ! default: ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_OPENMSDIR); } fd = open(DirPath, openmode, 0644); if (fd < 0) { #ifdef AFS_ENV ! if (AMS_ViceIsRunning) { ! if (errno == EFBIG) { ! char ErrorText[100 + MAXPATHLEN]; ! sprintf(ErrorText, EFBIGFormat, ap_Shorten(DirPath)); ! CriticalBizarreError(ErrorText); ! } ! } ! #endif /* AFS_ENV */ ! AMS_RETURN_ERRCODE(errno, EIN_OPEN, EVIA_OPENMSDIR); } debug(128, ("Opened dir %s\n", DirPath)); if (Code >= MD_WRITE) { ! if (osi_ExclusiveLockNoBlock(fd)) { ! errsave = errno; ! close(fd); ! if (Code >= MD_CREATE) { ! unlink(DirPath); ! } ! debug(128, ("Lock failed -- Closed dir %s\n", DirPath)); ! AMS_RETURN_ERRCODE(errsave, EIN_FLOCK, EVIA_OPENMSDIR); ! } } Quietly = FALSE; if (Code >= MD_APPEND) { ! if (CheckHintDroppingPermission(Dir->UNIXDir)) { ! errsave = mserrcode; ! close(fd); ! if (Code >= MD_CREATE) { ! unlink(DirPath); ! } ! return (mserrcode); ! } ! cleanupmess = CheckMarksInProgress(Dir, &Quietly); ! if (MarkInProgress(Dir->UNIXDir)) { ! errsave = mserrcode; ! close(fd); ! if (Code >= MD_CREATE) { ! unlink(DirPath); ! } ! return (mserrcode); ! } } else { ! cleanupmess = 0; } if (Code == MD_OK) { ! close(fd); ! debug(128, ("Quickly closed dir %s\n", DirPath)); } else { ! Dir->fd = fd; ! Dir->OpenMode = Code; } if (cleanupmess) { ! if (HandleMarksInProgress(Dir, Quietly)) { ! Dir->BadScavenge = 1; ! if (!Quietly) { ! char ErrorText[500]; ! sprintf(ErrorText, "Could not handle 'in progress' mail in directory %s", ap_Shorten(Dir->UNIXDir)); ! NonfatalBizarreError(ErrorText); ! } ! } } Dir->LastOpenTimestamp = time(0); return (0); --- 526,623 ---- char DirPath[1 + MAXPATHLEN]; if (Dir->fd >= 0) { ! AMS_RETURN_ERRCODE(EMSDIRALREADYOPEN, EIN_PARAMCHECK, EVIA_OPENMSDIR); } sprintf(DirPath, "%s/%s", Dir->UNIXDir, MS_DIRNAME); Dir->BadScavenge = 0; if (access(DirPath, W_OK)) { ! Dir->Writable = 0; } else { ! Dir->Writable = 1; } switch (Code) { ! case MD_CREATE: ! openmode = O_RDWR | O_CREAT | O_TRUNC; ! break; ! case MD_OK: ! case MD_READ: ! openmode = O_RDONLY; ! break; ! case MD_WRITE: ! case MD_APPEND: ! openmode = O_RDWR; ! break; ! default: ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_OPENMSDIR); } fd = open(DirPath, openmode, 0644); if (fd < 0) { #ifdef AFS_ENV ! if (AMS_ViceIsRunning) { ! if (errno == EFBIG) { ! char ErrorText[100 + MAXPATHLEN]; ! sprintf(ErrorText, EFBIGFormat, ap_Shorten(DirPath)); ! CriticalBizarreError(ErrorText); ! } ! } ! #endif /* AFS_ENV */ ! AMS_RETURN_ERRCODE(errno, EIN_OPEN, EVIA_OPENMSDIR); } debug(128, ("Opened dir %s\n", DirPath)); if (Code >= MD_WRITE) { ! if (osi_ExclusiveLockNoBlock(fd)) { ! errsave = errno; ! close(fd); ! if (Code >= MD_CREATE) { ! unlink(DirPath); ! } ! debug(128, ("Lock failed -- Closed dir %s\n", DirPath)); ! AMS_RETURN_ERRCODE(errsave, EIN_FLOCK, EVIA_OPENMSDIR); ! } } Quietly = FALSE; if (Code >= MD_APPEND) { ! if (CheckHintDroppingPermission(Dir->UNIXDir)) { ! errsave = mserrcode; ! close(fd); ! if (Code >= MD_CREATE) { ! unlink(DirPath); ! } ! return (mserrcode); ! } ! cleanupmess = CheckMarksInProgress(Dir, &Quietly); ! if (MarkInProgress(Dir->UNIXDir)) { ! errsave = mserrcode; ! close(fd); ! if (Code >= MD_CREATE) { ! unlink(DirPath); ! } ! return (mserrcode); ! } } else { ! cleanupmess = 0; } if (Code == MD_OK) { ! close(fd); ! debug(128, ("Quickly closed dir %s\n", DirPath)); } else { ! Dir->fd = fd; ! Dir->OpenMode = Code; } if (cleanupmess) { ! if (HandleMarksInProgress(Dir, Quietly)) { ! Dir->BadScavenge = 1; ! if (!Quietly) { ! char ErrorText[500]; ! sprintf(ErrorText, "Could not handle 'in progress' mail in directory %s", ap_Shorten(Dir->UNIXDir)); ! NonfatalBizarreError(ErrorText); ! } ! } } Dir->LastOpenTimestamp = time(0); return (0); *************** *** 577,617 **** int CloseMode; { if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_CLOSEMSDIR); } if (CloseMode < Dir->OpenMode) { ! /* It is already open for a higher purpose */ ! debug(128, ("Skipping close of %s due to low open mode (%d, %d)\n", Dir->UNIXDir, CloseMode, Dir->OpenMode)); ! return (0); } FreeIDs(Dir); if (vclose(Dir->fd)) { ! debug(128, ("Close failed on dir %s\n", Dir->UNIXDir)); ! Dir->fd = -1; ! Dir->OpenMode = -1; #ifdef AFS_ENV ! if (AMS_ViceIsRunning) { ! if (errno == EFBIG) { ! char ErrorText[100 + MAXPATHLEN]; ! sprintf(ErrorText, EFBIGFormat, ap_Shorten(Dir->UNIXDir)); ! CriticalBizarreError(ErrorText); ! } ! } ! #endif /* AFS_ENV */ ! AMS_RETURN_ERRCODE(errno, EIN_VCLOSE, EVIA_CLOSEMSDIR); } if ((CloseMode >= MD_APPEND) && Dir->BadScavenge == 0 && UnmarkInProgress(Dir->UNIXDir)) { ! char ErrBuf[100 + MAXPATHLEN]; ! sprintf(ErrBuf, "Unmark in progress failed on dir %s; next append may be needlessly slow.", ap_Shorten(Dir->UNIXDir)); ! NonfatalBizarreError(ErrBuf); } debug(128, ("Closed dir %s\n", Dir->UNIXDir)); Dir->fd = -1; Dir->OpenMode = -1; if (CloseMode >= MD_APPEND) { ! DropHint(Dir->UNIXDir); } return (0); } --- 628,668 ---- int CloseMode; { if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_CLOSEMSDIR); } if (CloseMode < Dir->OpenMode) { ! /* It is already open for a higher purpose */ ! debug(128, ("Skipping close of %s due to low open mode (%d, %d)\n", Dir->UNIXDir, CloseMode, Dir->OpenMode)); ! return (0); } FreeIDs(Dir); if (vclose(Dir->fd)) { ! debug(128, ("Close failed on dir %s\n", Dir->UNIXDir)); ! Dir->fd = -1; ! Dir->OpenMode = -1; #ifdef AFS_ENV ! if (AMS_ViceIsRunning) { ! if (errno == EFBIG) { ! char ErrorText[100 + MAXPATHLEN]; ! sprintf(ErrorText, EFBIGFormat, ap_Shorten(Dir->UNIXDir)); ! CriticalBizarreError(ErrorText); ! } ! } ! #endif /* AFS_ENV */ ! AMS_RETURN_ERRCODE(errno, EIN_VCLOSE, EVIA_CLOSEMSDIR); } if ((CloseMode >= MD_APPEND) && Dir->BadScavenge == 0 && UnmarkInProgress(Dir->UNIXDir)) { ! char ErrBuf[100 + MAXPATHLEN]; ! sprintf(ErrBuf, "Unmark in progress failed on dir %s; next append may be needlessly slow.", ap_Shorten(Dir->UNIXDir)); ! NonfatalBizarreError(ErrBuf); } debug(128, ("Closed dir %s\n", Dir->UNIXDir)); Dir->fd = -1; Dir->OpenMode = -1; if (CloseMode >= MD_APPEND) { ! DropHint(Dir->UNIXDir); } return (0); } *************** *** 618,632 **** char *fixDate(dPtr) char *dPtr; ! {/* Fix up the base-64 value (size AMS_DATESIZE) at dPtr. Return a pointer to it. */ int X; register char *cp; cp = dPtr; for (X = AMS_DATESIZE; X > 0; X--) { ! if (*cp == '_') ! *cp = ':'; ! ++cp; } return dPtr; } --- 669,685 ---- char *fixDate(dPtr) char *dPtr; ! { /* Fix up the base-64 value (size ! * AMS_DATESIZE) at dPtr. Return a ! * pointer to it. */ int X; register char *cp; cp = dPtr; for (X = AMS_DATESIZE; X > 0; X--) { ! if (*cp == '_') ! *cp = ':'; ! ++cp; } return dPtr; } *************** *** 640,723 **** unsigned long int uLong; if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_GETSNAPSHOTBYID); } startpt = Dir->LastIDHit; if (startpt < 0 || startpt >= Dir->MessageCount) ! startpt = Dir->MessageCount - 1; if (startpt < 0) ! startpt = 0; for (i = startpt; i < Dir->MessageCount; ++i) { ! if (lseek(Dir->fd, AMS_DIRHEADSIZE + (i * AMS_SNAPSHOTSIZE), L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_GETSNAPSHOTBYID); ! } ! readct = read(Dir->fd, snapshot, AMS_SNAPSHOTSIZE); ! if (readct != AMS_SNAPSHOTSIZE) { ! if (readct >= 0) { ! AnnounceBadDirFormat(Dir->UNIXDir); ! errno = EMSBADDIRFORMAT; ! } ! AMS_RETURN_ERRCODE(errno, EIN_READ, EVIA_GETSNAPSHOTBYID); ! } ! if (i < Dir->NumIDs) { ! bcopy(AMS_CHAIN(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].Chn = ntohl(uLong); ! bcopy(AMS_MIDHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].midH = ntohl(uLong); ! bcopy(AMS_REPLYHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].repH = ntohl(uLong); ! } ! if (!strcmp(id, AMS_ID(snapshot))) { ! *msgnum = i; ! fixDate(AMS_DATE(snapshot)); ! if (Dir->Writable) { ! AMS_SET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); ! } ! else { ! AMS_UNSET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); ! } ! Dir->LastIDHit = i; ! return (0); ! } } for (i = startpt - 1; i >= 0; --i) { ! if (lseek(Dir->fd, AMS_DIRHEADSIZE + (i * AMS_SNAPSHOTSIZE), L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_GETSNAPSHOTBYID); ! } ! readct = read(Dir->fd, snapshot, AMS_SNAPSHOTSIZE); ! if (readct != AMS_SNAPSHOTSIZE) { ! if (readct >= 0) { ! AnnounceBadDirFormat(Dir->UNIXDir); ! errno = EMSBADDIRFORMAT; ! } ! AMS_RETURN_ERRCODE(errno, EIN_READ, EVIA_GETSNAPSHOTBYID); ! } ! if (i < Dir->NumIDs) { ! bcopy(AMS_CHAIN(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].Chn = ntohl(uLong); ! bcopy(AMS_MIDHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].midH = ntohl(uLong); ! bcopy(AMS_REPLYHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].repH = ntohl(uLong); ! } ! if (!strcmp(id, AMS_ID(snapshot))) { ! *msgnum = i; ! fixDate(AMS_DATE(snapshot)); ! if (Dir->Writable) { ! AMS_SET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); ! } ! else { ! AMS_UNSET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); ! } ! Dir->LastIDHit = i; ! return (0); ! } } AMS_RETURN_ERRCODE(EMSNOSUCHMESSAGE, EIN_PARAMCHECK, EVIA_GETSNAPSHOTBYID); } ! /* Note in the following routine that numbers start a zero ! and go to Dir->MessageCount -1 */ GetSnapshotByNumber(Dir, msgnum, snapshot) struct MS_Directory *Dir; --- 693,776 ---- unsigned long int uLong; if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_GETSNAPSHOTBYID); } startpt = Dir->LastIDHit; if (startpt < 0 || startpt >= Dir->MessageCount) ! startpt = Dir->MessageCount - 1; if (startpt < 0) ! startpt = 0; for (i = startpt; i < Dir->MessageCount; ++i) { ! if (lseek(Dir->fd, AMS_DIRHEADSIZE + (i * AMS_SNAPSHOTSIZE), L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_GETSNAPSHOTBYID); ! } ! readct = read(Dir->fd, snapshot, AMS_SNAPSHOTSIZE); ! if (readct != AMS_SNAPSHOTSIZE) { ! if (readct >= 0) { ! AnnounceBadDirFormat(Dir->UNIXDir); ! errno = EMSBADDIRFORMAT; ! } ! AMS_RETURN_ERRCODE(errno, EIN_READ, EVIA_GETSNAPSHOTBYID); ! } ! if (i < Dir->NumIDs) { ! bcopy(AMS_CHAIN(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].Chn = ntohl(uLong); ! bcopy(AMS_MIDHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].midH = ntohl(uLong); ! bcopy(AMS_REPLYHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].repH = ntohl(uLong); ! } ! if (!strcmp(id, AMS_ID(snapshot))) { ! *msgnum = i; ! fixDate(AMS_DATE(snapshot)); ! if (Dir->Writable) { ! AMS_SET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); ! } ! else { ! AMS_UNSET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); ! } ! Dir->LastIDHit = i; ! return (0); ! } } for (i = startpt - 1; i >= 0; --i) { ! if (lseek(Dir->fd, AMS_DIRHEADSIZE + (i * AMS_SNAPSHOTSIZE), L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_GETSNAPSHOTBYID); ! } ! readct = read(Dir->fd, snapshot, AMS_SNAPSHOTSIZE); ! if (readct != AMS_SNAPSHOTSIZE) { ! if (readct >= 0) { ! AnnounceBadDirFormat(Dir->UNIXDir); ! errno = EMSBADDIRFORMAT; ! } ! AMS_RETURN_ERRCODE(errno, EIN_READ, EVIA_GETSNAPSHOTBYID); ! } ! if (i < Dir->NumIDs) { ! bcopy(AMS_CHAIN(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].Chn = ntohl(uLong); ! bcopy(AMS_MIDHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].midH = ntohl(uLong); ! bcopy(AMS_REPLYHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[i].repH = ntohl(uLong); ! } ! if (!strcmp(id, AMS_ID(snapshot))) { ! *msgnum = i; ! fixDate(AMS_DATE(snapshot)); ! if (Dir->Writable) { ! AMS_SET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); ! } ! else { ! AMS_UNSET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); ! } ! Dir->LastIDHit = i; ! return (0); ! } } AMS_RETURN_ERRCODE(EMSNOSUCHMESSAGE, EIN_PARAMCHECK, EVIA_GETSNAPSHOTBYID); } ! /* Note in the following routine that numbers start a zero ! and go to Dir->MessageCount -1 */ GetSnapshotByNumber(Dir, msgnum, snapshot) struct MS_Directory *Dir; *************** *** 728,763 **** unsigned long int uLong; if (msgnum >= Dir->MessageCount || (msgnum < 0)) { ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_GETSNAPSHOTBYNUMBER); } if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_GETSNAPSHOTBYNUMBER); } if (lseek(Dir->fd, AMS_DIRHEADSIZE + (msgnum * AMS_SNAPSHOTSIZE), L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_GETSNAPSHOTBYNUMBER); } readct = read(Dir->fd, snapshot, AMS_SNAPSHOTSIZE); if (readct != AMS_SNAPSHOTSIZE) { ! if (readct >= 0) { ! AnnounceBadDirFormat(Dir->UNIXDir); ! errno = EMSBADDIRFORMAT; ! } ! AMS_RETURN_ERRCODE(errno, EIN_READ, EVIA_GETSNAPSHOTBYNUMBER); } fixDate(AMS_DATE(snapshot)); if (Dir->Writable) { ! AMS_SET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); } else { ! AMS_UNSET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); } if (msgnum < Dir->NumIDs) { ! bcopy(AMS_CHAIN(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[msgnum].Chn = ntohl(uLong); ! bcopy(AMS_MIDHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[msgnum].midH = ntohl(uLong); ! bcopy(AMS_REPLYHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[msgnum].repH = ntohl(uLong); } return (0); } --- 781,816 ---- unsigned long int uLong; if (msgnum >= Dir->MessageCount || (msgnum < 0)) { ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_GETSNAPSHOTBYNUMBER); } if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_GETSNAPSHOTBYNUMBER); } if (lseek(Dir->fd, AMS_DIRHEADSIZE + (msgnum * AMS_SNAPSHOTSIZE), L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_GETSNAPSHOTBYNUMBER); } readct = read(Dir->fd, snapshot, AMS_SNAPSHOTSIZE); if (readct != AMS_SNAPSHOTSIZE) { ! if (readct >= 0) { ! AnnounceBadDirFormat(Dir->UNIXDir); ! errno = EMSBADDIRFORMAT; ! } ! AMS_RETURN_ERRCODE(errno, EIN_READ, EVIA_GETSNAPSHOTBYNUMBER); } fixDate(AMS_DATE(snapshot)); if (Dir->Writable) { ! AMS_SET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); } else { ! AMS_UNSET_ATTRIBUTE(snapshot, AMS_ATT_MAYMODIFY); } if (msgnum < Dir->NumIDs) { ! bcopy(AMS_CHAIN(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[msgnum].Chn = ntohl(uLong); ! bcopy(AMS_MIDHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[msgnum].midH = ntohl(uLong); ! bcopy(AMS_REPLYHASH(snapshot), &uLong, sizeof(unsigned long)); ! Dir->IDs[msgnum].repH = ntohl(uLong); } return (0); } *************** *** 768,780 **** char *snapshot; { if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_REWRITESNAPSHOTINDIR); } if (lseek(Dir->fd, AMS_DIRHEADSIZE + (num * AMS_SNAPSHOTSIZE), L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_REWRITESNAPSHOTINDIR); } if (writeall(Dir->fd, snapshot, AMS_SNAPSHOTSIZE) != AMS_SNAPSHOTSIZE) { ! AMS_RETURN_ERRCODE(errno, EIN_WRITE, EVIA_REWRITESNAPSHOTINDIR); } return (0); } --- 821,833 ---- char *snapshot; { if (Dir->fd < 0) { ! AMS_RETURN_ERRCODE(EMSDIRNOTOPEN, EIN_PARAMCHECK, EVIA_REWRITESNAPSHOTINDIR); } if (lseek(Dir->fd, AMS_DIRHEADSIZE + (num * AMS_SNAPSHOTSIZE), L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_REWRITESNAPSHOTINDIR); } if (writeall(Dir->fd, snapshot, AMS_SNAPSHOTSIZE) != AMS_SNAPSHOTSIZE) { ! AMS_RETURN_ERRCODE(errno, EIN_WRITE, EVIA_REWRITESNAPSHOTINDIR); } return (0); } *************** *** 786,799 **** debug(2, ("Checking hint dropping permission.\n")); if (FindTreeRoot(Dirname, UpdateFileName, FALSE)) ! return (0); /* no MUF here either */ strcat(UpdateFileName, "/"); strcat(UpdateFileName, MS_MASTERDIR); if (access(UpdateFileName, W_OK)) { ! if (errno == ENOENT) { ! return (0); /* No MUF on this tree */ ! } ! AMS_RETURN_ERRCODE(errno, EIN_ACCESS, EVIA_UPDATEUPDATES); } return (0); } --- 839,852 ---- debug(2, ("Checking hint dropping permission.\n")); if (FindTreeRoot(Dirname, UpdateFileName, FALSE)) ! return (0); /* no MUF here either */ strcat(UpdateFileName, "/"); strcat(UpdateFileName, MS_MASTERDIR); if (access(UpdateFileName, W_OK)) { ! if (errno == ENOENT) { ! return (0); /* No MUF on this tree */ ! } ! AMS_RETURN_ERRCODE(errno, EIN_ACCESS, EVIA_UPDATEUPDATES); } return (0); } *************** *** 803,812 **** static char ThisHost[150] = ""; if (ThisHost[0] == '\0') { ! GetHostDomainName(ThisHost, sizeof(ThisHost)); ! if (ThisHost[0] == '\0') { ! strcpy(ThisHost, "unknown-host"); ! } } return (ThisHost); } --- 856,865 ---- static char ThisHost[150] = ""; if (ThisHost[0] == '\0') { ! GetHostDomainName(ThisHost, sizeof(ThisHost)); ! if (ThisHost[0] == '\0') { ! strcpy(ThisHost, "unknown-host"); ! } } return (ThisHost); } *************** *** 819,830 **** debug(2, ("Dropping hint for %s\n", Dirname)); if (FindTreeRoot(Dirname, UpdateFileName, FALSE)) { ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_UPDATEUPDATES); } strcat(UpdateFileName, "/"); strcat(UpdateFileName, MS_MASTERDIR); if (access(UpdateFileName, F_OK) && errno == ENOENT) { ! return (0); /* No MUF on this tree */ } maybehere = &UpdateFileName[strlen(UpdateFileName)]; strcpy(maybehere, "/"); --- 872,883 ---- debug(2, ("Dropping hint for %s\n", Dirname)); if (FindTreeRoot(Dirname, UpdateFileName, FALSE)) { ! AMS_RETURN_ERRCODE(EINVAL, EIN_PARAMCHECK, EVIA_UPDATEUPDATES); } strcat(UpdateFileName, "/"); strcat(UpdateFileName, MS_MASTERDIR); if (access(UpdateFileName, F_OK) && errno == ENOENT) { ! return (0); /* No MUF on this tree */ } maybehere = &UpdateFileName[strlen(UpdateFileName)]; strcpy(maybehere, "/"); *************** *** 831,837 **** strcat(maybehere, GetMyHost()); debug(2, ("Possible update file name is %s\n", UpdateFileName)); if (access(UpdateFileName, W_OK)) { ! *maybehere = '\0'; } strcat(UpdateFileName, "/"); strcat(UpdateFileName, MS_MASTERHINT); --- 884,890 ---- strcat(maybehere, GetMyHost()); debug(2, ("Possible update file name is %s\n", UpdateFileName)); if (access(UpdateFileName, W_OK)) { ! *maybehere = '\0'; } strcat(UpdateFileName, "/"); strcat(UpdateFileName, MS_MASTERHINT); *************** *** 838,856 **** BuildNickName(Dirname, ScratchBuf); strcat(UpdateFileName, ScratchBuf); fd = open(UpdateFileName, O_CREAT | O_WRONLY, 0666); ! if (fd < 0 && errno == EACCES) { /* tolerate insert-only permission */ ! if (access(ScratchBuf, F_OK) == 0) { ! debug(2, ("OK: Hint file '%s' already exists; things should be fine.\n", UpdateFileName)); ! return (0); ! } } if (fd < 0) { ! sprintf(ScratchBuf, "Cannot open hint file '%s'", ap_Shorten(UpdateFileName)); ! NonfatalBizarreError(ScratchBuf); ! AMS_RETURN_ERRCODE(errno, EIN_OPEN, EVIA_UPDATEUPDATES); } ! close(fd); /* It was already created, it is empty, who ! * cares about a close error? */ debug(2, ("OK: Left hint file '%s', things should be fine.\n", UpdateFileName)); return (0); } --- 891,910 ---- BuildNickName(Dirname, ScratchBuf); strcat(UpdateFileName, ScratchBuf); fd = open(UpdateFileName, O_CREAT | O_WRONLY, 0666); ! if (fd < 0 && errno == EACCES) { /* tolerate insert-only permission */ ! if (access(ScratchBuf, F_OK) == 0) { ! debug(2, ("OK: Hint file '%s' already exists; things should be fine.\n", UpdateFileName)); ! return (0); ! } } if (fd < 0) { ! sprintf(ScratchBuf, "Cannot open hint file '%s'", ap_Shorten(UpdateFileName)); ! NonfatalBizarreError(ScratchBuf); ! AMS_RETURN_ERRCODE(errno, EIN_OPEN, EVIA_UPDATEUPDATES); } ! close(fd); /* It was already created, it is ! * empty, who cares about a close ! * error? */ debug(2, ("OK: Left hint file '%s', things should be fine.\n", UpdateFileName)); return (0); } *************** *** 869,892 **** debug(1, ("Trying to lock master update file %s\n", LockDirName)); sprintf(LockFileName, "%s/%s", LockDirName, MS_UPDATELOCK); while (TRUE) { ! *lockfd = open(LockFileName, osi_O_READLOCK | O_CREAT, 0644); ! if (*lockfd < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_OPEN, EVIA_LOCKMASTERFILE); ! } ! else { ! if (!osi_ExclusiveLockNoBlock(*lockfd)) { ! return (0); ! } ! errsave = errno; ! close(*lockfd); ! *lockfd = -1; ! if ((errsave != EWOULDBLOCK) || (locktriesleft-- <= 0)) { ! AMS_RETURN_ERRCODE(errsave, EIN_FLOCK, EVIA_LOCKMASTERFILE); ! } ! sprintf(ErrorText, "Update file %s is locked (%d); sleeping %d seconds (%d retries remain)...", ap_Shorten(LockFileName), errsave, LOCKSLEEPPERIOD, locktriesleft); ! NonfatalBizarreError(ErrorText); ! sleep(LOCKSLEEPPERIOD); ! } } } --- 923,946 ---- debug(1, ("Trying to lock master update file %s\n", LockDirName)); sprintf(LockFileName, "%s/%s", LockDirName, MS_UPDATELOCK); while (TRUE) { ! *lockfd = open(LockFileName, osi_O_READLOCK | O_CREAT, 0644); ! if (*lockfd < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_OPEN, EVIA_LOCKMASTERFILE); ! } ! else { ! if (!osi_ExclusiveLockNoBlock(*lockfd)) { ! return (0); ! } ! errsave = errno; ! close(*lockfd); ! *lockfd = -1; ! if ((errsave != EWOULDBLOCK) || (locktriesleft-- <= 0)) { ! AMS_RETURN_ERRCODE(errsave, EIN_FLOCK, EVIA_LOCKMASTERFILE); ! } ! sprintf(ErrorText, "Update file %s is locked (%d); sleeping %d seconds (%d retries remain)...", ap_Shorten(LockFileName), errsave, LOCKSLEEPPERIOD, locktriesleft); ! NonfatalBizarreError(ErrorText); ! sleep(LOCKSLEEPPERIOD); ! } } } *************** *** 900,913 **** NonfatalBizarreError(DoAll ? "Taking ALL hints" : "Taking hints"); *ProtFailures = 0; while (MS_GetSearchPathEntry(i++, PathElt, MAXPATHLEN) == 0) { ! if (CheckPathForMUFHints(PathElt, DoAll)) { ! if (AMS_ERRNO == EACCES) { ! ++*ProtFailures; ! } ! else { ! return (mserrcode); ! } ! } } return (0); } --- 954,967 ---- NonfatalBizarreError(DoAll ? "Taking ALL hints" : "Taking hints"); *ProtFailures = 0; while (MS_GetSearchPathEntry(i++, PathElt, MAXPATHLEN) == 0) { ! if (CheckPathForMUFHints(PathElt, DoAll)) { ! if (AMS_ERRNO == EACCES) { ! ++*ProtFailures; ! } ! else { ! return (mserrcode); ! } ! } } return (0); } *************** *** 924,935 **** strcat(MUFDir, "/"); strcat(MUFDir, MS_MASTERDIR); if (access(MUFDir, W_OK)) { ! if (errno == ENOENT) ! return (0); /* No MUF to check */ ! AMS_RETURN_ERRCODE(errno, EIN_ACCESS, EVIA_UPDATEUPDATES); } if (LockMUF(MUFDir, &lockfd)) { ! return (mserrcode); } i = CheckForMUFHints(MUFDir, DoAll, PathElt); mserrcode = ClearUpdates(PathElt); --- 978,989 ---- strcat(MUFDir, "/"); strcat(MUFDir, MS_MASTERDIR); if (access(MUFDir, W_OK)) { ! if (errno == ENOENT) ! return (0); /* No MUF to check */ ! AMS_RETURN_ERRCODE(errno, EIN_ACCESS, EVIA_UPDATEUPDATES); } if (LockMUF(MUFDir, &lockfd)) { ! return (mserrcode); } i = CheckForMUFHints(MUFDir, DoAll, PathElt); mserrcode = ClearUpdates(PathElt); *************** *** 959,1027 **** debug(1, ("PlanHint %s /%s %s /%s\n", PathElt, shortname, MUFDir, MUFHint)); fullhint = malloc(2 + strlen(MUFDir) + strlen(MUFHint)); if (!fullhint) ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_UPDATEUPDATES); fulldir = malloc(2 + strlen(PathElt) + strlen(shortname)); if (!fulldir) { ! free(fullhint); ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_UPDATEUPDATES); } sprintf(fullhint, "%s/%s", MUFDir, MUFHint); sprintf(fulldir, "%s/%s", PathElt, shortname); for (i = 0; i < UpdatesPending; ++i) { ! if (!strcmp(fulldir, TakenUpdates[i].FullDirName)) { ! debug(2, ("Aha! Would have hit a duplicate!\n")); ! /* Skip it and delete the second hint file */ ! unlink(fullhint); /* Can ignore errors, I guess */ ! free(fullhint); ! free(fulldir); ! return (0); ! } } if (ReadOrFindMSDir(fulldir, &Dir, MD_READ)) { ! char ErrBuf[100 + MAXPATHLEN]; ! if (errno != ENOENT) { ! free(fullhint); ! free(fulldir); ! return (mserrcode); ! } ! /* It has been deleted! */ ! sprintf(ErrBuf, "Hint found for non-existent folder %s; ignoring...", ap_Shorten(fulldir)); ! NonfatalBizarreError(ErrBuf); ! TakenUpdates[UpdatesPending].Deleted = 1; } else { ! struct stat stbuf; ! TakenUpdates[UpdatesPending].Deleted = 0; ! if (Dir->MessageCount > 0) { ! char SnapshotDum[1 + AMS_SNAPSHOTSIZE]; ! if (GetSnapshotByNumber(Dir, Dir->MessageCount - 1, SnapshotDum)) { ! saveerr = mserrcode; ! CloseMSDir(Dir, MD_READ); ! free(fullhint); ! free(fulldir); ! return (saveerr); ! } ! strncpy(TakenUpdates[UpdatesPending].date64, AMS_DATE(SnapshotDum), AMS_DATESIZE); ! } ! else { ! strcpy(TakenUpdates[UpdatesPending].date64, "000000"); ! } ! CloseMSDir(Dir, MD_READ); ! if (stat(fulldir, &stbuf)) { ! free(fullhint); ! free(fulldir); ! AMS_RETURN_ERRCODE(errno, EIN_STAT, EVIA_REBUILDMASTERUPS); ! } ! TakenUpdates[UpdatesPending].modtime = stbuf.st_mtime; } TakenUpdates[UpdatesPending].FullDirName = fulldir; TakenUpdates[UpdatesPending].HintFileName = fullhint; if (++UpdatesPending >= MAXUPDATES) ! return (ClearUpdates(PathElt)); return (0); } --- 1013,1081 ---- debug(1, ("PlanHint %s /%s %s /%s\n", PathElt, shortname, MUFDir, MUFHint)); fullhint = malloc(2 + strlen(MUFDir) + strlen(MUFHint)); if (!fullhint) ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_UPDATEUPDATES); fulldir = malloc(2 + strlen(PathElt) + strlen(shortname)); if (!fulldir) { ! free(fullhint); ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_UPDATEUPDATES); } sprintf(fullhint, "%s/%s", MUFDir, MUFHint); sprintf(fulldir, "%s/%s", PathElt, shortname); for (i = 0; i < UpdatesPending; ++i) { ! if (!strcmp(fulldir, TakenUpdates[i].FullDirName)) { ! debug(2, ("Aha! Would have hit a duplicate!\n")); ! /* Skip it and delete the second hint file */ ! unlink(fullhint); /* Can ignore errors, I guess */ ! free(fullhint); ! free(fulldir); ! return (0); ! } } if (ReadOrFindMSDir(fulldir, &Dir, MD_READ)) { ! char ErrBuf[100 + MAXPATHLEN]; ! if (errno != ENOENT) { ! free(fullhint); ! free(fulldir); ! return (mserrcode); ! } ! /* It has been deleted! */ ! sprintf(ErrBuf, "Hint found for non-existent folder %s; ignoring...", ap_Shorten(fulldir)); ! NonfatalBizarreError(ErrBuf); ! TakenUpdates[UpdatesPending].Deleted = 1; } else { ! struct stat stbuf; ! TakenUpdates[UpdatesPending].Deleted = 0; ! if (Dir->MessageCount > 0) { ! char SnapshotDum[1 + AMS_SNAPSHOTSIZE]; ! if (GetSnapshotByNumber(Dir, Dir->MessageCount - 1, SnapshotDum)) { ! saveerr = mserrcode; ! CloseMSDir(Dir, MD_READ); ! free(fullhint); ! free(fulldir); ! return (saveerr); ! } ! strncpy(TakenUpdates[UpdatesPending].date64, AMS_DATE(SnapshotDum), AMS_DATESIZE); ! } ! else { ! strcpy(TakenUpdates[UpdatesPending].date64, "000000"); ! } ! CloseMSDir(Dir, MD_READ); ! if (stat(fulldir, &stbuf)) { ! free(fullhint); ! free(fulldir); ! AMS_RETURN_ERRCODE(errno, EIN_STAT, EVIA_REBUILDMASTERUPS); ! } ! TakenUpdates[UpdatesPending].modtime = stbuf.st_mtime; } TakenUpdates[UpdatesPending].FullDirName = fulldir; TakenUpdates[UpdatesPending].HintFileName = fullhint; if (++UpdatesPending >= MAXUPDATES) ! return (ClearUpdates(PathElt)); return (0); } *************** *** 1037,1067 **** char *elt1start, *elt1end, *elt2start, *elt2end; int result = 0; ! elt1start = index(p1, '/'); /* Assuming slashes, not dots; hope that's OK */ elt2start = index(p2, '/'); while (elt1start && elt2start) { ! elt1end = index(++elt1start, '/'); ! elt2end = index(++elt2start, '/'); ! if (elt1end) ! *elt1end = '\0'; ! if (elt2end) ! *elt2end = '\0'; ! result = strcmp(elt1start, elt2start); ! if (elt1end) ! *elt1end = '/'; ! if (elt2end) ! *elt2end = '/'; ! if (result) ! return (result); ! elt1start = elt1end; ! elt2start = elt2end; } if (elt1start == 0 && elt2start == 0) ! return (0); else ! return (elt1start != 0 ? 1 : -1); /* (can't count on pointers ! * being arithmetically ! * positive) */ } static int CompareTakenUpdates(t1, t2) --- 1091,1123 ---- char *elt1start, *elt1end, *elt2start, *elt2end; int result = 0; ! elt1start = index(p1, '/'); /* Assuming slashes, not dots; hope ! * that's OK */ elt2start = index(p2, '/'); while (elt1start && elt2start) { ! elt1end = index(++elt1start, '/'); ! elt2end = index(++elt2start, '/'); ! if (elt1end) ! *elt1end = '\0'; ! if (elt2end) ! *elt2end = '\0'; ! result = strcmp(elt1start, elt2start); ! if (elt1end) ! *elt1end = '/'; ! if (elt2end) ! *elt2end = '/'; ! if (result) ! return (result); ! elt1start = elt1end; ! elt2start = elt2end; } if (elt1start == 0 && elt2start == 0) ! return (0); else ! return (elt1start != 0 ? 1 : -1); /* (can't count on ! * pointers being ! * arithmetically ! * positive) */ } static int CompareTakenUpdates(t1, t2) *************** *** 1080,1086 **** debug(1, ("ClearUpdates %s\n", PathElt)); if (UpdatesPending <= 0) ! return (0); qsort(TakenUpdates, UpdatesPending, sizeof(struct takenupdate), CompareTakenUpdates); --- 1136,1142 ---- debug(1, ("ClearUpdates %s\n", PathElt)); if (UpdatesPending <= 0) ! return (0); qsort(TakenUpdates, UpdatesPending, sizeof(struct takenupdate), CompareTakenUpdates); *************** *** 1088,1266 **** strcat(UpdateFileName, "/"); strcat(UpdateFileName, MS_MASTERUPDATE); if (access(UpdateFileName, W_OK)) { ! FreeUpdates(FALSE); ! if (errno == ENOENT) { ! return (0); /* No update file means we don't create one */ ! } ! AMS_RETURN_ERRCODE(errno, EIN_ACCESS, EVIA_UPDATEUPDATES); } oldR = fopen(UpdateFileName, "r"); if (!oldR) { ! FreeUpdates(FALSE); ! AMS_RETURN_ERRCODE(errno, EIN_FOPEN, EVIA_UPDATEUPDATES); } strcpy(NewUpdateFileName, UpdateFileName); strcat(NewUpdateFileName, ".NEW"); newW = fopen(NewUpdateFileName, "w"); if (!newW) { ! fclose(oldR); ! FreeUpdates(FALSE); ! AMS_RETURN_ERRCODE(errno, EIN_FOPEN, EVIA_UPDATEUPDATES); } Dirname = TakenUpdates[whichupdate].FullDirName; if (TakenUpdates[whichupdate].Deleted) { ! NewLine[0] = '\0'; } else { ! sprintf(NewLine, "%s %s %d\n", Dirname, TakenUpdates[whichupdate].date64, TakenUpdates[whichupdate].modtime); } PrevLine[0] = '\0'; while (TryAgain || fgets(LineBuf, sizeof(LineBuf), oldR)) { ! if (!TryAgain) { /* Did read a new line */ ! if (u = index(LineBuf, ' ')) { ! *u = '\0'; ! fixDate(u + 1); ! } ! if (v = index(PrevLine, ' ')) { ! *v = '\0'; ! fixDate(v + 1); ! } ! if (ComparePathsByElts(LineBuf, PrevLine) <= 0) { ! if (u) ! *u = ' '; ! if (v) ! *v = ' '; ! s = index(LineBuf, '\n'); ! if (s) ! *s = '\0'; ! t = index(PrevLine, '\n'); ! if (t) ! *t = '\0'; ! sprintf(ErrorText, "Mis-ordered MUF line (discarding & hinting): %s (PrevLine is %s), in %s", LineBuf, PrevLine, ap_Shorten(UpdateFileName)); ! if (t) ! *t = '\n'; ! NonfatalBizarreError(ErrorText); ! s = index(LineBuf, ' '); ! if (s) ! *s = '\0'; ! DropHint(LineBuf); ! continue; ! } ! else { ! if (u) ! *u = ' '; ! if (v) ! *v = ' '; ! } ! strcpy(PrevLine, LineBuf); ! } ! TryAgain = FALSE; ! /* ! * Do not propogate bogus lines. In the past, illegal chars have ! * gotten into MUF files from bad Ethernet interfaces, sigh... ! */ ! mistakes = 0; ! for (s = LineBuf; *s; ++s) { ! if (!isprint(*s) && !isspace(*s)) { ! sprintf(ErrorText, "Illegal character in update file %s: ASCII %d (decimal)", ap_Shorten(UpdateFileName), *s); ! NonfatalBizarreError(ErrorText); ! *s = 'X'; /* The error message should be kind to ! * console */ ! ++mistakes; ! } ! } ! if (LineBuf[0] != '/') { ! ++mistakes; /* Must be a full path name */ ! } ! if (mistakes) { ! sprintf(ErrorText, "Discarding illegal MUF %s entry: %s", ap_Shorten(UpdateFileName), LineBuf); ! NonfatalBizarreError(ErrorText); ! continue; ! } ! if (whichupdate >= UpdatesPending) { /* finished with hint entries */ ! fputs(LineBuf, newW); ! continue; ! } ! s = index(LineBuf, ' '); ! if (s) ! *s = '\0'; ! code = ComparePathsByElts(Dirname, LineBuf); ! if (s) ! *s = ' '; ! if (code <= 0) { ! /* We have just NOW Passed it or this is exactly it. */ ! fputs(NewLine, newW); ! if (code) { ! TryAgain = TRUE; ! /* ! * Used to be fputs(LineBuf, newW) but this screwed up when ! * two new things needed to be inserted consecutively ! */ ! } ! if (++whichupdate < UpdatesPending) { ! Dirname = TakenUpdates[whichupdate].FullDirName; ! if (TakenUpdates[whichupdate].Deleted) { ! NewLine[0] = '\0'; ! } ! else { ! sprintf(NewLine, "%s %s %d\n", Dirname, TakenUpdates[whichupdate].date64, TakenUpdates[whichupdate].modtime); ! } ! } ! } ! else { ! /* We have not yet gotten there */ ! fputs(LineBuf, newW); ! } } while (whichupdate < UpdatesPending) { ! fputs(NewLine, newW); ! if (++whichupdate < UpdatesPending) { ! if (TakenUpdates[whichupdate].Deleted) { ! NewLine[0] = '\0'; ! } ! else { ! sprintf(NewLine, "%s %s %d\n", TakenUpdates[whichupdate].FullDirName, TakenUpdates[whichupdate].date64, TakenUpdates[whichupdate].modtime); ! } ! } } fclose(oldR); ! errno = 0; /* Paranoia regarding ferror */ if (ferror(newW) || feof(newW)) { ! saveerr = errno; ! fclose(newW); ! unlink(NewUpdateFileName); ! FreeUpdates(FALSE); ! AMS_RETURN_ERRCODE(saveerr, EIN_FERROR, EVIA_UPDATEUPDATES); } if (vfclose(newW)) { ! saveerr = errno; ! unlink(NewUpdateFileName); ! FreeUpdates(FALSE); ! AMS_RETURN_ERRCODE(saveerr, EIN_VFCLOSE, EVIA_UPDATEUPDATES); } if (rename(NewUpdateFileName, UpdateFileName)) { ! saveerr = errno; ! unlink(NewUpdateFileName); ! FreeUpdates(FALSE); ! AMS_RETURN_ERRCODE(saveerr, EIN_RENAME, EVIA_UPDATEUPDATES); } FreeUpdates(TRUE); return (0); } ! static void FreeUpdates(UnlinkHints) int UnlinkHints; { while (--UpdatesPending >= 0) { ! if (UnlinkHints) ! unlink(TakenUpdates[UpdatesPending].HintFileName); ! free(TakenUpdates[UpdatesPending].HintFileName); ! free(TakenUpdates[UpdatesPending].FullDirName); } UpdatesPending = 0; } --- 1144,1324 ---- strcat(UpdateFileName, "/"); strcat(UpdateFileName, MS_MASTERUPDATE); if (access(UpdateFileName, W_OK)) { ! FreeUpdates(FALSE); ! if (errno == ENOENT) { ! return (0); /* No update file means we don't ! * create one */ ! } ! AMS_RETURN_ERRCODE(errno, EIN_ACCESS, EVIA_UPDATEUPDATES); } oldR = fopen(UpdateFileName, "r"); if (!oldR) { ! FreeUpdates(FALSE); ! AMS_RETURN_ERRCODE(errno, EIN_FOPEN, EVIA_UPDATEUPDATES); } strcpy(NewUpdateFileName, UpdateFileName); strcat(NewUpdateFileName, ".NEW"); newW = fopen(NewUpdateFileName, "w"); if (!newW) { ! fclose(oldR); ! FreeUpdates(FALSE); ! AMS_RETURN_ERRCODE(errno, EIN_FOPEN, EVIA_UPDATEUPDATES); } Dirname = TakenUpdates[whichupdate].FullDirName; if (TakenUpdates[whichupdate].Deleted) { ! NewLine[0] = '\0'; } else { ! sprintf(NewLine, "%s %s %d\n", Dirname, TakenUpdates[whichupdate].date64, TakenUpdates[whichupdate].modtime); } PrevLine[0] = '\0'; while (TryAgain || fgets(LineBuf, sizeof(LineBuf), oldR)) { ! if (!TryAgain) { /* Did read a new line */ ! if (u = index(LineBuf, ' ')) { ! *u = '\0'; ! fixDate(u + 1); ! } ! if (v = index(PrevLine, ' ')) { ! *v = '\0'; ! fixDate(v + 1); ! } ! if (ComparePathsByElts(LineBuf, PrevLine) <= 0) { ! if (u) ! *u = ' '; ! if (v) ! *v = ' '; ! s = index(LineBuf, '\n'); ! if (s) ! *s = '\0'; ! t = index(PrevLine, '\n'); ! if (t) ! *t = '\0'; ! sprintf(ErrorText, "Mis-ordered MUF line (discarding & hinting): %s (PrevLine is %s), in %s", LineBuf, PrevLine, ap_Shorten(UpdateFileName)); ! if (t) ! *t = '\n'; ! NonfatalBizarreError(ErrorText); ! s = index(LineBuf, ' '); ! if (s) ! *s = '\0'; ! DropHint(LineBuf); ! continue; ! } ! else { ! if (u) ! *u = ' '; ! if (v) ! *v = ' '; ! } ! strcpy(PrevLine, LineBuf); ! } ! TryAgain = FALSE; ! /* ! * Do not propogate bogus lines. In the past, illegal chars have ! * gotten into MUF files from bad Ethernet interfaces, sigh... ! */ ! mistakes = 0; ! for (s = LineBuf; *s; ++s) { ! if (!isprint(*s) && !isspace(*s)) { ! sprintf(ErrorText, "Illegal character in update file %s: ASCII %d (decimal)", ap_Shorten(UpdateFileName), *s); ! NonfatalBizarreError(ErrorText); ! *s = 'X'; /* The error message should be kind ! * to console */ ! ++mistakes; ! } ! } ! if (LineBuf[0] != '/') { ! ++mistakes; /* Must be a full path name */ ! } ! if (mistakes) { ! sprintf(ErrorText, "Discarding illegal MUF %s entry: %s", ap_Shorten(UpdateFileName), LineBuf); ! NonfatalBizarreError(ErrorText); ! continue; ! } ! if (whichupdate >= UpdatesPending) { /* finished with hint ! * entries */ ! fputs(LineBuf, newW); ! continue; ! } ! s = index(LineBuf, ' '); ! if (s) ! *s = '\0'; ! code = ComparePathsByElts(Dirname, LineBuf); ! if (s) ! *s = ' '; ! if (code <= 0) { ! /* We have just NOW Passed it or this is exactly it. */ ! fputs(NewLine, newW); ! if (code) { ! TryAgain = TRUE; ! /* ! * Used to be fputs(LineBuf, newW) but this screwed up ! * when two new things needed to be inserted consecutively ! */ ! } ! if (++whichupdate < UpdatesPending) { ! Dirname = TakenUpdates[whichupdate].FullDirName; ! if (TakenUpdates[whichupdate].Deleted) { ! NewLine[0] = '\0'; ! } ! else { ! sprintf(NewLine, "%s %s %d\n", Dirname, TakenUpdates[whichupdate].date64, TakenUpdates[whichupdate].modtime); ! } ! } ! } ! else { ! /* We have not yet gotten there */ ! fputs(LineBuf, newW); ! } } while (whichupdate < UpdatesPending) { ! fputs(NewLine, newW); ! if (++whichupdate < UpdatesPending) { ! if (TakenUpdates[whichupdate].Deleted) { ! NewLine[0] = '\0'; ! } ! else { ! sprintf(NewLine, "%s %s %d\n", TakenUpdates[whichupdate].FullDirName, TakenUpdates[whichupdate].date64, TakenUpdates[whichupdate].modtime); ! } ! } } fclose(oldR); ! errno = 0; /* Paranoia regarding ferror */ if (ferror(newW) || feof(newW)) { ! saveerr = errno; ! fclose(newW); ! unlink(NewUpdateFileName); ! FreeUpdates(FALSE); ! AMS_RETURN_ERRCODE(saveerr, EIN_FERROR, EVIA_UPDATEUPDATES); } if (vfclose(newW)) { ! saveerr = errno; ! unlink(NewUpdateFileName); ! FreeUpdates(FALSE); ! AMS_RETURN_ERRCODE(saveerr, EIN_VFCLOSE, EVIA_UPDATEUPDATES); } if (rename(NewUpdateFileName, UpdateFileName)) { ! saveerr = errno; ! unlink(NewUpdateFileName); ! FreeUpdates(FALSE); ! AMS_RETURN_ERRCODE(saveerr, EIN_RENAME, EVIA_UPDATEUPDATES); } FreeUpdates(TRUE); return (0); } ! static void FreeUpdates(UnlinkHints) int UnlinkHints; { while (--UpdatesPending >= 0) { ! if (UnlinkHints) ! unlink(TakenUpdates[UpdatesPending].HintFileName); ! free(TakenUpdates[UpdatesPending].HintFileName); ! free(TakenUpdates[UpdatesPending].FullDirName); } UpdatesPending = 0; } *************** *** 1276,1324 **** debug(1, ("Looking for hints in directory %s\n", MUFDir)); dirp = opendir(MUFDir); if (!dirp) { ! AMS_RETURN_ERRCODE(errno, EIN_OPENDIR, EVIA_UPDATEUPDATES); } while (dp = readdir(dirp)) { ! if (strncmp(dp->d_name, MS_MASTERHINT, sizeof(MS_MASTERHINT) - 1)) { ! if ((*dp->d_name != '.') && (DoAll || !strcmp(dp->d_name, GetMyHost()))) { ! struct stat stbuf; ! debug(2, ("Considering recursion into %s\n", dp->d_name)); ! strcpy(namebuf, MUFDir); ! strcat(namebuf, "/"); ! strcat(namebuf, dp->d_name); ! if (stat(namebuf, &stbuf)) { ! char ErrorText[100 + MAXPATHLEN]; ! sprintf(ErrorText, "Cannot stat %s/%s; may be missing some hints", ap_Shorten(MUFDir), dp->d_name); ! NonfatalBizarreError(ErrorText); ! continue; ! } ! if ((stbuf.st_mode & S_IFMT) == S_IFDIR) { ! CheckForMUFHints(namebuf, DoAll, PathElt); ! } ! } ! else { ! debug(2, ("Ignoring %s\n", dp->d_name)); ! } ! continue; ! } ! strcpy(namebuf, dp->d_name + sizeof(MS_MASTERHINT) - 1); ! for (s = namebuf; *s; ++s) { ! if (*s == '.') ! *s = '/'; ! } ! debug(2, ("Handling update hint for %s.\n", namebuf)); ! if (PlanHint(PathElt, namebuf, MUFDir, dp->d_name)) { ! closedir(dirp); ! return (mserrcode); ! } } closedir(dirp); return (0); } ! static void AnnounceBadDirFormat(line) char *line; { char ErrorText[100 + MAXPATHLEN]; --- 1334,1382 ---- debug(1, ("Looking for hints in directory %s\n", MUFDir)); dirp = opendir(MUFDir); if (!dirp) { ! AMS_RETURN_ERRCODE(errno, EIN_OPENDIR, EVIA_UPDATEUPDATES); } while (dp = readdir(dirp)) { ! if (strncmp(dp->d_name, MS_MASTERHINT, sizeof(MS_MASTERHINT) - 1)) { ! if ((*dp->d_name != '.') && (DoAll || !strcmp(dp->d_name, GetMyHost()))) { ! struct stat stbuf; ! debug(2, ("Considering recursion into %s\n", dp->d_name)); ! strcpy(namebuf, MUFDir); ! strcat(namebuf, "/"); ! strcat(namebuf, dp->d_name); ! if (stat(namebuf, &stbuf)) { ! char ErrorText[100 + MAXPATHLEN]; ! sprintf(ErrorText, "Cannot stat %s/%s; may be missing some hints", ap_Shorten(MUFDir), dp->d_name); ! NonfatalBizarreError(ErrorText); ! continue; ! } ! if ((stbuf.st_mode & S_IFMT) == S_IFDIR) { ! CheckForMUFHints(namebuf, DoAll, PathElt); ! } ! } ! else { ! debug(2, ("Ignoring %s\n", dp->d_name)); ! } ! continue; ! } ! strcpy(namebuf, dp->d_name + sizeof(MS_MASTERHINT) - 1); ! for (s = namebuf; *s; ++s) { ! if (*s == '.') ! *s = '/'; ! } ! debug(2, ("Handling update hint for %s.\n", namebuf)); ! if (PlanHint(PathElt, namebuf, MUFDir, dp->d_name)) { ! closedir(dirp); ! return (mserrcode); ! } } closedir(dirp); return (0); } ! static void AnnounceBadDirFormat(line) char *line; { char ErrorText[100 + MAXPATHLEN]; *************** *** 1327,1333 **** CriticalBizarreError(ErrorText); } ! static void BuildAttrNameBuf(Dir, AttrBuf) struct MS_Directory *Dir; char *AttrBuf; { --- 1385,1391 ---- CriticalBizarreError(ErrorText); } ! static void BuildAttrNameBuf(Dir, AttrBuf) struct MS_Directory *Dir; char *AttrBuf; { *************** *** 1336,1346 **** bzero(AttrBuf, ATTNAMESLEN); if (!Dir->AttrNames) ! return; for (i = 0; i < Dir->AttrCount; ++i) { ! strncpy(s, Dir->AttrNames[i], AMS_ATTRNAMEMAX); ! s[AMS_ATTRNAMEMAX - 1] = '\0'; ! s += AMS_ATTRNAMEMAX; } } --- 1394,1404 ---- bzero(AttrBuf, ATTNAMESLEN); if (!Dir->AttrNames) ! return; for (i = 0; i < Dir->AttrCount; ++i) { ! strncpy(s, Dir->AttrNames[i], AMS_ATTRNAMEMAX); ! s[AMS_ATTRNAMEMAX - 1] = '\0'; ! s += AMS_ATTRNAMEMAX; } } *************** *** 1350,1383 **** int *SkippedBytes; { struct LinePromState *lps; ! char Lbuf[2000]; /* actually, 120 *should* suffice */ int oldpos, curpos; *SkippedBytes = 0; if ((oldpos = lseek(fd, 0, L_INCR)) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_EMITBE2PREFIX); } BE2LinePromoteInit(&lps); curpos = 0; while (TRUE) { ! if (read(fd, &Lbuf[curpos], 1) != 1) ! break; ! if (Lbuf[curpos] == '\n') { ! Lbuf[curpos + 1] = '\0'; ! if (BE2LinePromote(Lbuf, lps) != 2) ! break; ! fputs(Lbuf, fp); ! *SkippedBytes += curpos; ! oldpos += curpos; ! curpos = 0; ! } ! else { ! ++curpos; ! } } BE2LinePromoteEnd(lps); if (lseek(fd, oldpos, L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_EMITBE2PREFIX); } return (0); } --- 1408,1441 ---- int *SkippedBytes; { struct LinePromState *lps; ! char Lbuf[2000]; /* actually, 120 *should* suffice */ int oldpos, curpos; *SkippedBytes = 0; if ((oldpos = lseek(fd, 0, L_INCR)) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_EMITBE2PREFIX); } BE2LinePromoteInit(&lps); curpos = 0; while (TRUE) { ! if (read(fd, &Lbuf[curpos], 1) != 1) ! break; ! if (Lbuf[curpos] == '\n') { ! Lbuf[curpos + 1] = '\0'; ! if (BE2LinePromote(Lbuf, lps) != 2) ! break; ! fputs(Lbuf, fp); ! *SkippedBytes += curpos; ! oldpos += curpos; ! curpos = 0; ! } ! else { ! ++curpos; ! } } BE2LinePromoteEnd(lps); if (lseek(fd, oldpos, L_SET) < 0) { ! AMS_RETURN_ERRCODE(errno, EIN_LSEEK, EVIA_EMITBE2PREFIX); } return (0); } *************** *** 1393,1406 **** p = getcpwuid(uid, cell ? cell : MyMailDomain); if (p) { ! newName = NULL; ! GetNameFromGecos(p->pw_gecos, p->pw_name, (cell ? cell : MyMailDomain), &newName); ! strncpy(NameBuf, (newName ? newName : p->pw_gecos), lim); ! if (newName) ! free(newName); } if (!NameBuf[0]) { ! sprintf(NameBuf, "User %d in domain %s", uid, cell ? cell : MyMailDomain); } } --- 1451,1464 ---- p = getcpwuid(uid, cell ? cell : MyMailDomain); if (p) { ! newName = NULL; ! GetNameFromGecos(p->pw_gecos, p->pw_name, (cell ? cell : MyMailDomain), &newName); ! strncpy(NameBuf, (newName ? newName : p->pw_gecos), lim); ! if (newName) ! free(newName); } if (!NameBuf[0]) { ! sprintf(NameBuf, "User %d in domain %s", uid, cell ? cell : MyMailDomain); } } *************** *** 1437,1455 **** strcat(MarkFile, MS_DIRINPROGRESSFILE); debug(1, ("Turning %s in-progress mark file %s\n", TurnOnMark ? "ON" : "OFF", MarkFile)); if (TurnOnMark) { ! fd = open(MarkFile, O_RDWR | O_CREAT, 0666); ! if (fd < 0) ! AMS_RETURN_ERRCODE(errno, EIN_OPEN, EVIA_MARKINPROGRESS); ! if (Quietly) ! (void) write(fd, QuietMark, sizeof(QuietMark) - 1); ! close(fd); } else { ! if (unlink(MarkFile)) { ! if (errno != ENOENT) { ! AMS_RETURN_ERRCODE(errno, EIN_UNLINK, EVIA_MARKINPROGRESS); ! } ! } } return (0); } --- 1495,1513 ---- strcat(MarkFile, MS_DIRINPROGRESSFILE); debug(1, ("Turning %s in-progress mark file %s\n", TurnOnMark ? "ON" : "OFF", MarkFile)); if (TurnOnMark) { ! fd = open(MarkFile, O_RDWR | O_CREAT, 0666); ! if (fd < 0) ! AMS_RETURN_ERRCODE(errno, EIN_OPEN, EVIA_MARKINPROGRESS); ! if (Quietly) ! (void) write(fd, QuietMark, sizeof(QuietMark) - 1); ! close(fd); } else { ! if (unlink(MarkFile)) { ! if (errno != ENOENT) { ! AMS_RETURN_ERRCODE(errno, EIN_UNLINK, EVIA_MARKINPROGRESS); ! } ! } } return (0); } *************** *** 1465,1487 **** strcat(MarkFile, "/"); strcat(MarkFile, MS_DIRINPROGRESSFILE); if (stat(MarkFile, &sbuf) != 0) ! return (0); *pQuietly = (sbuf.st_size >= (sizeof(QuietMark) - 1)); return (1); } ! struct FileInfo {char *Name; unsigned long int FileDate;}; struct CheckList { char *Label; struct FileInfo *ToCheck; int Allocated, Used, UsesDates; ! } FilesToCheck = {"file", 0, 0, 0, 0}, ! SnapsToCheck = {"snapshot", 0, 0, 0, 0}, ! Orphans = {"orphan", 0, 0, 0, 1}, ! Missing = {"missing", 0, 0, 0, 0}; ! int HandleMarksInProgress(Dir, Quiet) struct MS_Directory *Dir; int Quiet; { --- 1523,1560 ---- strcat(MarkFile, "/"); strcat(MarkFile, MS_DIRINPROGRESSFILE); if (stat(MarkFile, &sbuf) != 0) ! return (0); *pQuietly = (sbuf.st_size >= (sizeof(QuietMark) - 1)); return (1); } ! struct FileInfo { ! char *Name; ! unsigned long int FileDate; ! }; struct CheckList { char *Label; struct FileInfo *ToCheck; int Allocated, Used, UsesDates; ! } FilesToCheck = { ! "file", 0, 0, 0, 0 ! }, ! ! SnapsToCheck = { ! "snapshot", 0, 0, 0, 0 ! }, ! ! Orphans = { ! "orphan", 0, 0, 0, 1 ! }, ! ! Missing = { ! "missing", 0, 0, 0, 0 ! }; ! ! int HandleMarksInProgress(Dir, Quiet) struct MS_Directory *Dir; int Quiet; { *************** *** 1492,1502 **** struct stat sbuf; if (!Quiet) { ! sprintf(ErrorText, "Checking for hidden messages in folder %s.", ap_Shorten(Dir->UNIXDir)); ! NonfatalBizarreError(ErrorText); } if (IsDirAlien(Dir, &alien)) { ! return(mserrcode); } FilesToCheck.ToCheck = 0; SnapsToCheck.ToCheck = 0; --- 1565,1575 ---- struct stat sbuf; if (!Quiet) { ! sprintf(ErrorText, "Checking for hidden messages in folder %s.", ap_Shorten(Dir->UNIXDir)); ! NonfatalBizarreError(ErrorText); } if (IsDirAlien(Dir, &alien)) { ! return (mserrcode); } FilesToCheck.ToCheck = 0; SnapsToCheck.ToCheck = 0; *************** *** 1504,1545 **** Missing.ToCheck = 0; FreeCheckLists(); if (ReadOldMSDirectoryHead(Dir)) ! return (mserrcode); dirp = opendir(Dir->UNIXDir); if (!dirp) { ! AMS_RETURN_ERRCODE(errno, EIN_OPENDIR, EVIA_MARKINPROGRESS); } while (dp = readdir(dirp)) { ! if (*dp->d_name == '+') { ! AddToCheckList(dp->d_name + 1, &FilesToCheck); ! } ! else if (*dp->d_name != '.') { ! char ErrText[100 + MAXPATHLEN]; ! sprintf(ErrText, "%s/%s", Dir->UNIXDir, dp->d_name); ! if (stat(ErrText, &sbuf) == 0 && (sbuf.st_mode & S_IFMT) != S_IFDIR) { ! if ((sbuf.st_mode & S_IFMT) == S_IFREG) { ! if (alien) { ! AddToCheckList(dp->d_name, &FilesToCheck); ! } else { ! sprintf(ErrText, "There is a bogus file '%s' in folder %s.", dp->d_name, ap_Shorten(Dir->UNIXDir)); ! NonfatalBizarreError(ErrText); ! } ! } else { ! sprintf(ErrText, "There is a bogus file '%s' (type %#o) in folder %s.", dp->d_name, (sbuf.st_mode & S_IFMT), ap_Shorten(Dir->UNIXDir)); ! NonfatalBizarreError(ErrText); ! } ! } ! } ! } closedir(dirp); for (i = 0; i < Dir->MessageCount; ++i) { ! if (GetSnapshotByNumber(Dir, i, SBuf)) { ! closedir(dirp); ! FreeCheckLists(); ! return (mserrcode); ! } ! AddToCheckList(AMS_ID(SBuf), &SnapsToCheck); } return (CheckCheckLists(Dir, Quiet, alien)); } --- 1577,1621 ---- Missing.ToCheck = 0; FreeCheckLists(); if (ReadOldMSDirectoryHead(Dir)) ! return (mserrcode); dirp = opendir(Dir->UNIXDir); if (!dirp) { ! AMS_RETURN_ERRCODE(errno, EIN_OPENDIR, EVIA_MARKINPROGRESS); } while (dp = readdir(dirp)) { ! if (*dp->d_name == '+') { ! AddToCheckList(dp->d_name + 1, &FilesToCheck); ! } ! else ! if (*dp->d_name != '.') { ! char ErrText[100 + MAXPATHLEN]; ! sprintf(ErrText, "%s/%s", Dir->UNIXDir, dp->d_name); ! if (stat(ErrText, &sbuf) == 0 && (sbuf.st_mode & S_IFMT) != S_IFDIR) { ! if ((sbuf.st_mode & S_IFMT) == S_IFREG) { ! if (alien) { ! AddToCheckList(dp->d_name, &FilesToCheck); ! } ! else { ! sprintf(ErrText, "There is a bogus file '%s' in folder %s.", dp->d_name, ap_Shorten(Dir->UNIXDir)); ! NonfatalBizarreError(ErrText); ! } ! } ! else { ! sprintf(ErrText, "There is a bogus file '%s' (type %#o) in folder %s.", dp->d_name, (sbuf.st_mode & S_IFMT), ap_Shorten(Dir->UNIXDir)); ! NonfatalBizarreError(ErrText); ! } ! } ! } ! } closedir(dirp); for (i = 0; i < Dir->MessageCount; ++i) { ! if (GetSnapshotByNumber(Dir, i, SBuf)) { ! closedir(dirp); ! FreeCheckLists(); ! return (mserrcode); ! } ! AddToCheckList(AMS_ID(SBuf), &SnapsToCheck); } return (CheckCheckLists(Dir, Quiet, alien)); } *************** *** 1549,1570 **** struct CheckList *CheckList; { if (CheckList->Used >= CheckList->Allocated) { ! CheckList->Allocated *= 2; ! CheckList->Allocated += 25; ! if (CheckList->ToCheck) { ! CheckList->ToCheck = (struct FileInfo *) realloc(CheckList->ToCheck, CheckList->Allocated * sizeof(struct FileInfo)); ! } ! else { ! CheckList->ToCheck = (struct FileInfo *) malloc(CheckList->Allocated * sizeof(struct FileInfo)); ! } ! if (!CheckList->ToCheck) ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_MARKINPROGRESS); ! debug(262144, ("The %s checklist now has %d/%d entries.\n", CheckList->Label, CheckList->Used, CheckList->Allocated)); } CheckList->ToCheck[CheckList->Used].FileDate = 0; CheckList->ToCheck[CheckList->Used].Name = (char *) malloc(1 + strlen(name)); if (!CheckList->ToCheck[CheckList->Used].Name) ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_MARKINPROGRESS); strcpy(CheckList->ToCheck[CheckList->Used].Name, name); ++CheckList->Used; return (0); --- 1625,1646 ---- struct CheckList *CheckList; { if (CheckList->Used >= CheckList->Allocated) { ! CheckList->Allocated *= 2; ! CheckList->Allocated += 25; ! if (CheckList->ToCheck) { ! CheckList->ToCheck = (struct FileInfo *) realloc(CheckList->ToCheck, CheckList->Allocated * sizeof(struct FileInfo)); ! } ! else { ! CheckList->ToCheck = (struct FileInfo *) malloc(CheckList->Allocated * sizeof(struct FileInfo)); ! } ! if (!CheckList->ToCheck) ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_MARKINPROGRESS); ! debug(262144, ("The %s checklist now has %d/%d entries.\n", CheckList->Label, CheckList->Used, CheckList->Allocated)); } CheckList->ToCheck[CheckList->Used].FileDate = 0; CheckList->ToCheck[CheckList->Used].Name = (char *) malloc(1 + strlen(name)); if (!CheckList->ToCheck[CheckList->Used].Name) ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_MARKINPROGRESS); strcpy(CheckList->ToCheck[CheckList->Used].Name, name); ++CheckList->Used; return (0); *************** *** 1584,1594 **** int i; if (CheckList->ToCheck) { ! for (i = 0; i < CheckList->Used; ++i) { ! free(CheckList->ToCheck[i].Name); ! } ! free(CheckList->ToCheck); ! CheckList->ToCheck = NULL; } CheckList->Used = 0; CheckList->Allocated = 0; --- 1660,1670 ---- int i; if (CheckList->ToCheck) { ! for (i = 0; i < CheckList->Used; ++i) { ! free(CheckList->ToCheck[i].Name); ! } ! free(CheckList->ToCheck); ! CheckList->ToCheck = NULL; } CheckList->Used = 0; CheckList->Allocated = 0; *************** *** 1623,1702 **** qsort(FilesToCheck.ToCheck, FilesToCheck.Used, sizeof(struct FileInfo), CompareStrings); qsort(SnapsToCheck.ToCheck, SnapsToCheck.Used, sizeof(struct FileInfo), CompareStrings); for (i = 0, j = 0; i < FilesToCheck.Used || j < SnapsToCheck.Used;) { ! if (j >= SnapsToCheck.Used) { ! debug(2, ("Automatically using the file\n")); ! code = -1; ! } ! else if (i >= FilesToCheck.Used) { ! debug(2, ("Automatically using the snapshot\n")); ! code = 1; ! } ! else { ! code = strcmp(FilesToCheck.ToCheck[i].Name, SnapsToCheck.ToCheck[j].Name); ! debug(2, ("Comparing the file and snapshot\n")); ! } ! if (!code) { ! debug(2, ("They are the same\n")); ! ++j; ! ++i; ! continue; ! } ! if (code > 0) { ! debug(2, ("Adding from snapshot: %s\n", SnapsToCheck.ToCheck[j].Name)); ! AddToCheckList(SnapsToCheck.ToCheck[j].Name, &Missing); ! ++j; ! } ! else { ! debug(2, ("Adding from files: %s\n", FilesToCheck.ToCheck[i].Name)); ! AddToCheckList(FilesToCheck.ToCheck[i].Name, &Orphans); ! ++i; ! } } if (Orphans.Used > 0) { ! struct stat SBuf; ! debug(262144, ("The directory %s DOES have hidden mail in it-- %d messages!\n", Dir->UNIXDir, Orphans.Used)); ! for (i = 0; i < Orphans.Used; ++i) { ! strcpy(partstart, Orphans.ToCheck[i].Name); ! Orphans.ToCheck[i].FileDate = (stat(FileName, &SBuf) == 0 ? SBuf.st_ctime : 0); ! } ! qsort(Orphans.ToCheck, Orphans.Used, sizeof(struct FileInfo), CompareTimes); ! for (i = 0; i < Orphans.Used; ++i) { ! ++foundct; ! debug(2, ("The directory %s DOES have hidden mail in it -- %s!\n", Dir->UNIXDir, Orphans.ToCheck[i].Name)); ! strcpy(partstart, Orphans.ToCheck[i].Name); ! strcpy(FileBuf2, FileName); /* make a temp copy of the name of the file to add */ ! if (AppendFileToMSDirInternal(FileBuf2, Dir, TRUE, alien)) ! ++errs; ! if ((i & 077) == 077) ! debug(262144, ("...finished adding %d of %d hidden files\n", i, Orphans.Used)); ! } ! debug(262144, ("Finished adding all %d hidden files.\n", Orphans.Used)); } if (Missing.Used > 0) { ! debug(262144, ("The directory %s has %d orphaned snapshots in it!\n", Dir->UNIXDir, Missing.Used)); ! for (i = 0; i < Missing.Used; ++i) { ! int msgnum; ! char snapshot[AMS_SNAPSHOTSIZE + 1]; ! ++missingct; ! debug(2, ("The directory %s has an orphaned snapshot in it -- %s!\n", Dir->UNIXDir, Missing.ToCheck[i].Name)); ! mserrcode = GetSnapshotByID(Dir, Missing.ToCheck[i].Name, &msgnum, snapshot); ! if (mserrcode) { ! ++errs; ! } else { ! strcpy(AMS_CAPTION(snapshot), "Deleted message: Caption will disappear with next purge."); ! AMS_SET_ATTRIBUTE(snapshot, AMS_ATT_DELETED); ! if (RewriteSnapshotInDirectory(Dir, msgnum, snapshot)) ! ++errs; ! } ! if ((i & 077) == 077) ! debug(262144, ("Finished fixing %d of %d snapshots\n", i, Missing.Used)); ! } ! debug(262144, ("Finished fixing all %d snapshots.\n", Missing.Used)); } if (!Quiet || foundct > 0) { ! sprintf(ErrorText, "Found %d old hidden messages in %s (%d orphaned snapshots, %d processing errors).", foundct, ap_Shorten(Dir->UNIXDir), missingct, errs); ! NonfatalBizarreError(ErrorText); } FreeCheckLists(); return (0); --- 1699,1782 ---- qsort(FilesToCheck.ToCheck, FilesToCheck.Used, sizeof(struct FileInfo), CompareStrings); qsort(SnapsToCheck.ToCheck, SnapsToCheck.Used, sizeof(struct FileInfo), CompareStrings); for (i = 0, j = 0; i < FilesToCheck.Used || j < SnapsToCheck.Used;) { ! if (j >= SnapsToCheck.Used) { ! debug(2, ("Automatically using the file\n")); ! code = -1; ! } ! else ! if (i >= FilesToCheck.Used) { ! debug(2, ("Automatically using the snapshot\n")); ! code = 1; ! } ! else { ! code = strcmp(FilesToCheck.ToCheck[i].Name, SnapsToCheck.ToCheck[j].Name); ! debug(2, ("Comparing the file and snapshot\n")); ! } ! if (!code) { ! debug(2, ("They are the same\n")); ! ++j; ! ++i; ! continue; ! } ! if (code > 0) { ! debug(2, ("Adding from snapshot: %s\n", SnapsToCheck.ToCheck[j].Name)); ! AddToCheckList(SnapsToCheck.ToCheck[j].Name, &Missing); ! ++j; ! } ! else { ! debug(2, ("Adding from files: %s\n", FilesToCheck.ToCheck[i].Name)); ! AddToCheckList(FilesToCheck.ToCheck[i].Name, &Orphans); ! ++i; ! } } if (Orphans.Used > 0) { ! struct stat SBuf; ! ! debug(262144, ("The directory %s DOES have hidden mail in it-- %d messages!\n", Dir->UNIXDir, Orphans.Used)); ! for (i = 0; i < Orphans.Used; ++i) { ! strcpy(partstart, Orphans.ToCheck[i].Name); ! Orphans.ToCheck[i].FileDate = (stat(FileName, &SBuf) == 0 ? SBuf.st_ctime : 0); ! } ! qsort(Orphans.ToCheck, Orphans.Used, sizeof(struct FileInfo), CompareTimes); ! for (i = 0; i < Orphans.Used; ++i) { ! ++foundct; ! debug(2, ("The directory %s DOES have hidden mail in it -- %s!\n", Dir->UNIXDir, Orphans.ToCheck[i].Name)); ! strcpy(partstart, Orphans.ToCheck[i].Name); ! strcpy(FileBuf2, FileName);/* make a temp copy of the name of ! * the file to add */ ! if (AppendFileToMSDirInternal(FileBuf2, Dir, TRUE, alien)) ! ++errs; ! if ((i & 077) == 077) ! debug(262144, ("...finished adding %d of %d hidden files\n", i, Orphans.Used)); ! } ! debug(262144, ("Finished adding all %d hidden files.\n", Orphans.Used)); } if (Missing.Used > 0) { ! debug(262144, ("The directory %s has %d orphaned snapshots in it!\n", Dir->UNIXDir, Missing.Used)); ! for (i = 0; i < Missing.Used; ++i) { ! int msgnum; ! char snapshot[AMS_SNAPSHOTSIZE + 1]; ! ++missingct; ! debug(2, ("The directory %s has an orphaned snapshot in it -- %s!\n", Dir->UNIXDir, Missing.ToCheck[i].Name)); ! mserrcode = GetSnapshotByID(Dir, Missing.ToCheck[i].Name, &msgnum, snapshot); ! if (mserrcode) { ! ++errs; ! } ! else { ! strcpy(AMS_CAPTION(snapshot), "Deleted message: Caption will disappear with next purge."); ! AMS_SET_ATTRIBUTE(snapshot, AMS_ATT_DELETED); ! if (RewriteSnapshotInDirectory(Dir, msgnum, snapshot)) ! ++errs; ! } ! if ((i & 077) == 077) ! debug(262144, ("Finished fixing %d of %d snapshots\n", i, Missing.Used)); ! } ! debug(262144, ("Finished fixing all %d snapshots.\n", Missing.Used)); } if (!Quiet || foundct > 0) { ! sprintf(ErrorText, "Found %d old hidden messages in %s (%d orphaned snapshots, %d processing errors).", foundct, ap_Shorten(Dir->UNIXDir), missingct, errs); ! NonfatalBizarreError(ErrorText); } FreeCheckLists(); return (0); *************** *** 1704,1755 **** IsDirAlien(Dir, alien) struct MS_Directory *Dir; ! int *alien; { ! static int *pathcodes = NULL; ! int i, whichpath; ! char Root[1+MAXPATHLEN]; if (pathcodes == NULL) { ! pathcodes = (int *) malloc((MS_NumDirsInSearchPath + 1) * sizeof(int)); ! if (pathcodes == NULL) { ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_MARKINPROGRESS); ! } ! for (i=0; i<= MS_NumDirsInSearchPath; ++i) { ! pathcodes[i] = -1; ! } } FindTreeRoot(Dir->UNIXDir, Root, FALSE); whichpath = WhichPath(Root); if (whichpath < 0) { ! *alien = 0; ! return(0); } if (pathcodes[whichpath] == -1) { ! char AlienFlagFile[1+MAXPATHLEN]; ! struct stat stbuf; ! sprintf(AlienFlagFile, "%s/.amsalien", SearchPathElements[whichpath].Path); ! if (stat(AlienFlagFile, &stbuf)) { ! if (errno != ENOENT) { ! AMS_RETURN_ERRCODE(errno, EIN_STAT, EVIA_MARKINPROGRESS); ! } ! pathcodes[whichpath] = 0; ! } else { ! pathcodes[whichpath] = 1; ! } } *alien = pathcodes[whichpath]; ! return(0); } GetBodyFileName(DirName, id, FileName) ! char *DirName, *id, *FileName; { sprintf(FileName, "%s/+%s", DirName, id); if (access(FileName, R_OK)) { ! sprintf(FileName, "%s/%s", DirName, id); } } - - --- 1784,1834 ---- IsDirAlien(Dir, alien) struct MS_Directory *Dir; ! int *alien; { ! static int *pathcodes = NULL; ! int i, whichpath; ! char Root[1 + MAXPATHLEN]; if (pathcodes == NULL) { ! pathcodes = (int *) malloc((MS_NumDirsInSearchPath + 1) * sizeof(int)); ! if (pathcodes == NULL) { ! AMS_RETURN_ERRCODE(ENOMEM, EIN_MALLOC, EVIA_MARKINPROGRESS); ! } ! for (i = 0; i <= MS_NumDirsInSearchPath; ++i) { ! pathcodes[i] = -1; ! } } FindTreeRoot(Dir->UNIXDir, Root, FALSE); whichpath = WhichPath(Root); if (whichpath < 0) { ! *alien = 0; ! return (0); } if (pathcodes[whichpath] == -1) { ! char AlienFlagFile[1 + MAXPATHLEN]; ! struct stat stbuf; ! sprintf(AlienFlagFile, "%s/.amsalien", SearchPathElements[whichpath].Path); ! if (stat(AlienFlagFile, &stbuf)) { ! if (errno != ENOENT) { ! AMS_RETURN_ERRCODE(errno, EIN_STAT, EVIA_MARKINPROGRESS); ! } ! pathcodes[whichpath] = 0; ! } ! else { ! pathcodes[whichpath] = 1; ! } } *alien = pathcodes[whichpath]; ! return (0); } GetBodyFileName(DirName, id, FileName) ! char *DirName, *id, *FileName; { sprintf(FileName, "%s/+%s", DirName, id); if (access(FileName, R_OK)) { ! sprintf(FileName, "%s/%s", DirName, id); } } *** ams/libs/ms/rawfil.c Wed Apr 11 14:17:20 1990 --- ams/libs/ms/rawfil.c.NEW Wed Jun 13 16:47:30 1990 *************** *** 3,9 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/rawfil.c,v 1.1 90/03/08 13:09:08 bobg Exp $ $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/rawfil.c,v $ */ #include --- 3,9 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/rawfil.c,v 1.2 90/06/05 14:36:23 gk5g Exp $ $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/rawfil.c,v $ */ #include *************** *** 19,25 **** #define OLDLOCK 1200 /* 20 minutes */ ! extern char *malloc(), *realloc(), *index(); extern char MyMailDomain[]; ReadRawFile(File, NewMessage, DoLocking) --- 19,29 ---- #define OLDLOCK 1200 /* 20 minutes */ ! #ifndef _IBMR2 ! extern char *malloc(), *realloc(); ! #endif /* _IBMR2 */ ! ! extern char *index(); extern char MyMailDomain[]; ReadRawFile(File, NewMessage, DoLocking) *** ams/libs/ms/recon.c Wed Jan 17 16:35:55 1990 --- ams/libs/ms/recon.c.NEW Mon Jun 25 10:07:33 1990 *************** *** 4,11 **** \* ********************************************************************** */ /* ! $Header: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/recon.c,v 2.17 89/10/26 11:02:48 cfe Exp $ ! $Source: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/recon.c,v $ */ #include --- 4,11 ---- \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/recon.c,v 2.19 90/06/22 20:05:05 bobg Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/recon.c,v $ */ #include *************** *** 37,43 **** #define MS_DB_VERSION 4 ! static char ams_reconstruct_rcsid[] = "$Header: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/recon.c,v 2.17 89/10/26 11:02:48 cfe Exp $"; struct hashlist { unsigned long *hashes; --- 37,43 ---- #define MS_DB_VERSION 4 ! static char ams_reconstruct_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/recon.c,v 2.19 90/06/22 20:05:05 bobg Exp $"; struct hashlist { unsigned long *hashes; *************** *** 74,80 **** --- 74,82 ---- int used, size; }; + #ifndef _IBMR2 extern char *malloc(), *realloc(); + #endif /* _IBMR2 */ static int ContainsOnlyBase64Chars(str) char *str; *************** *** 752,758 **** struct MS_CaptionTemplate captiontemplate; struct MS_Directory *oldMSDir; int k, oldDirReadable, newMSDirfd, errsave, notOldID, newMaxChainVal; ! int alienDir; DIR *dirp; struct direct *dirent; struct stat statbuf; --- 754,760 ---- struct MS_CaptionTemplate captiontemplate; struct MS_Directory *oldMSDir; int k, oldDirReadable, newMSDirfd, errsave, notOldID, newMaxChainVal; ! int alienDir, calcLastMsgDate = 1; DIR *dirp; struct direct *dirent; struct stat statbuf; *************** *** 815,820 **** --- 817,824 ---- oldDirReadable = FALSE; CloseMSDir(oldMSDir, MD_APPEND); } + else + calcLastMsgDate = 0; } } } *************** *** 835,844 **** bzero(headBuf + i, 4); bcopy(attributesBuf, headBuf + i + 4, ATTNAMESLEN); bzero(headBuf + i + 4 + ATTNAMESLEN, ! AMS_DIRHEADSIZE - (i + ATTNAMESLEN + 5)); } ! /* Defer writing of new header until we know newMaxChainVal */ if (oldDirReadable) { if (IsDirAlien(oldMSDir, &alienDir)) { --- 839,850 ---- bzero(headBuf + i, 4); bcopy(attributesBuf, headBuf + i + 4, ATTNAMESLEN); bzero(headBuf + i + 4 + ATTNAMESLEN, ! AMS_DATESIZE); /* Space for LastMsgDate. This should be replaced later on with the AMS_DATE of the last snapshot */ ! bzero(headBuf + i + 4 + ATTNAMESLEN + AMS_DATESIZE, ! AMS_DIRHEADSIZE - (i + ATTNAMESLEN + AMS_DATESIZE + 5)); } ! /* Defer writing of new header until we know newMaxChainVal (and LastMsgDate) */ if (oldDirReadable) { if (IsDirAlien(oldMSDir, &alienDir)) { *************** *** 1148,1153 **** --- 1154,1172 ---- itops((long) newMaxChainVal, minstr, PADSIZE); bcopy(minstr, headBuf + strlen(AMS_DIRECTORY_PREFIX_STRING) + PADSIZE, PADSIZE); + /* Put snapshots in chronological order */ + + MsgList_SortByTime(&newMsgList); + + /* Modify the headbuf to reflect the new LastMsgDate (if necessary) */ + + if (calcLastMsgDate) { + bcopy(AMS_DATE(MsgList_GetSnapshot(&newMsgList, + (MsgList_Size(&newMsgList) - 1))), + headBuf + sizeof(AMS_DIRECTORY_PREFIX_STRING) + + (3 * PADSIZE) + 4 + ATTNAMESLEN); + } + /* Write out the header of the new MSDir */ if (writeall(newMSDirfd, headBuf, AMS_DIRHEADSIZE) != *************** *** 1163,1170 **** } /* Append snapshots to new msdir */ - - MsgList_SortByTime(&newMsgList); for (k = 0; k < MsgList_Size(&newMsgList); ++k) { if (lseek(newMSDirfd, --- 1182,1187 ---- *** ams/libs/ms/reply.c Wed Nov 22 11:35:01 1989 --- ams/libs/ms/reply.c.NEW Wed Jun 13 16:47:44 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/reply.c,v 2.7 89/04/16 11:30:53 nsb Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/reply.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/reply.c,v 2.8 90/06/05 14:36:46 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/reply.c,v $ */ #include #include *************** *** 12,18 **** #include /* sys/file.h */ extern FILE *fopen(); ! extern char *malloc(), *RewriteSubject(), *index(), *rindex(), *StripWhiteEnds(); extern char MeInFull[]; static char *ForwardString = "---------- Forwarded message begins here ----------\n\n"; --- 12,21 ---- #include /* sys/file.h */ extern FILE *fopen(); ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! extern char *RewriteSubject(), *index(), *rindex(), *StripWhiteEnds(); extern char MeInFull[]; static char *ForwardString = "---------- Forwarded message begins here ----------\n\n"; *** ams/libs/ms/restilde.c Wed Nov 22 11:35:07 1989 --- ams/libs/ms/restilde.c.NEW Wed Jun 13 16:47:46 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/restilde.c,v 2.6 89/02/15 11:42:19 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/restilde.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/restilde.c,v 2.7 90/06/05 14:36:53 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/restilde.c,v $ */ #include #include *************** *** 11,17 **** #define MAXUSERNAME 100 /* Biggest length of a user name */ ! extern char *malloc(), home[], *StripWhiteEnds(), *FindUserDir(); extern char MyMailDomain[]; /* If you make any changes to this routine, check out TildeResolve in --- 11,21 ---- #define MAXUSERNAME 100 /* Biggest length of a user name */ ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char home[], *StripWhiteEnds(), *FindUserDir(); extern char MyMailDomain[]; /* If you make any changes to this routine, check out TildeResolve in *** ams/libs/ms/scavenge.c Wed Nov 22 11:35:49 1989 --- ams/libs/ms/scavenge.c.NEW Wed Jun 13 16:47:48 1990 *************** *** 13,19 **** --- 13,21 ---- #define EVIA_SCAVENGE EVIA_UNKNOWN /* temp hack until first wash */ #endif + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ long MS_ScavengeDirectory(DirName, Recurse, numgood, numbad, quiet, Purge) char *DirName; *** ams/libs/ms/setasct.c Wed Nov 22 11:34:59 1989 --- ams/libs/ms/setasct.c.NEW Mon Jun 25 10:07:35 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/setasct.c,v 2.6 89/05/04 12:34:03 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/setasct.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/setasct.c,v 2.6 89/05/04 12:34:03 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/setasct.c,v $ */ #include #include *** ams/libs/ms/stack.c Wed Nov 22 11:35:23 1989 --- ams/libs/ms/stack.c.NEW Wed Jun 13 16:47:50 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/stack.c,v 2.3 89/02/08 15:45:58 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/stack.c,v $ */ /* stack.c -- push and pop on an otherwise private stack. You pass in pointers, and the stack routines do appropriate mallocs and frees --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/stack.c,v 2.4 90/06/05 14:37:03 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/stack.c,v $ */ /* stack.c -- push and pop on an otherwise private stack. You pass in pointers, and the stack routines do appropriate mallocs and frees *************** *** 17,23 **** --- 17,25 ---- #define STACKSIZE 1000 #define MAXSTACKS 2 /* MAXSTACKS is the number of stacks -- 2 stacks, stack 0 and 1 */ + #ifndef _IBMR2 extern char *malloc(), *realloc(); + #endif /* _IBMR2 */ static char *Stack[MAXSTACKS][STACKSIZE + 1]; static int StackTop[MAXSTACKS]; *** ams/libs/ms/strpself.c Wed Nov 22 11:35:16 1989 --- ams/libs/ms/strpself.c.NEW Wed Jun 13 16:47:52 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/strpself.c,v 2.9 89/05/16 10:09:24 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/strpself.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/strpself.c,v 2.10 90/06/05 14:37:08 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/strpself.c,v $ */ #include #include *************** *** 11,17 **** #include #include /* */ ! extern char *malloc(), Me[], MeInFull[], MyMailDomain[], *MyShortAddress; static void StripList(AddrList) PARSED_ADDRESS *AddrList; --- 11,21 ---- #include #include /* */ ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char Me[], MeInFull[], MyMailDomain[], *MyShortAddress; static void StripList(AddrList) PARSED_ADDRESS *AddrList; *** ams/libs/ms/submsg.c Wed Jan 17 16:35:59 1990 --- ams/libs/ms/submsg.c.NEW Wed Jun 13 16:47:54 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/submsg.c,v 2.11 89/12/22 15:10:42 cfe Exp $ ! $Source: /afs/.andrew.cmu.edu/itc/src/andrew/ams/libs/ms/RCS/submsg.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/submsg.c,v 2.13 90/06/05 14:37:12 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/submsg.c,v $ */ #include #include *************** *** 20,26 **** extern FILE *fopen(); extern char MAILLOGSTATFILE[], MyMailDomain[]; ! extern char Me[], *MyPrettyAddress, *BCCto, home[], *malloc(), *NextAddress(); extern int BCCFlag, IsLoggingMailStats, myvuid, errno, MS_DeliveryType; static char ThisHost[150] = ""; --- 20,31 ---- extern FILE *fopen(); extern char MAILLOGSTATFILE[], MyMailDomain[]; ! ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char Me[], *MyPrettyAddress, *BCCto, home[], *NextAddress(); extern int BCCFlag, IsLoggingMailStats, myvuid, errno, MS_DeliveryType; static char ThisHost[150] = ""; *************** *** 95,101 **** TempAddr->Comments = NULL; if (TempAddr->RoutePhrase) { free(TempAddr->RoutePhrase); ! TempAddr->RoutePhrase = NULL; } if (UnparseOneAddress(TempAddr, UP_SPACES_TO_DOTS, TempBuf, sizeof(TempBuf), "", " ", 69) != PA_OK) { FreeAddressList(AddrList); --- 100,106 ---- TempAddr->Comments = NULL; if (TempAddr->RoutePhrase) { free(TempAddr->RoutePhrase); ! (TempAddr->RoutePhrase) = NULL; } if (UnparseOneAddress(TempAddr, UP_SPACES_TO_DOTS, TempBuf, sizeof(TempBuf), "", " ", 69) != PA_OK) { FreeAddressList(AddrList); *** ams/libs/ms/subs.c Wed Nov 22 11:33:35 1989 --- ams/libs/ms/subs.c.NEW Wed Jun 13 16:48:00 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/subs.c,v 2.25 89/09/07 16:47:39 cfe Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/subs.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/subs.c,v 2.27 90/06/05 14:37:21 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/subs.c,v $ */ #include #include *************** *** 15,21 **** #include #include ! extern char *malloc(), *index(), *realloc(), *StripWhiteEnds(), *getprofile(), *convlongto64(), *fixDate(); extern char home[], MyMailDomain[]; extern int NeedToTimeOut; --- 15,25 ---- #include #include ! #ifndef _IBMR2 ! extern char *malloc(), *realloc(); ! #endif /* _IBMR2 */ ! ! extern char *index(), *StripWhiteEnds(), *getprofile(), *convlongto64(), *fixDate(); extern char home[], MyMailDomain[]; extern int NeedToTimeOut; *************** *** 605,610 **** --- 609,616 ---- char *s, *t; { register char sc, tc; + if (!s || !t) + return (0); for (;;) { sc = *s; if (sc == '/') sc = '.'; *** ams/libs/ms/subswalk.c Wed Nov 22 11:35:26 1989 --- ams/libs/ms/subswalk.c.NEW Wed Jun 13 16:48:03 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/subswalk.c,v 2.8 89/07/13 13:00:12 bobg Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/subswalk.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/subswalk.c,v 2.9 90/06/05 14:37:33 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/subswalk.c,v $ */ #include #include *************** *** 11,17 **** --- 11,19 ---- #include #include + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ /* This routine walks down a directory subtree corresponding to a message directory, and prints appropriate subscription information on the *** ams/libs/ms/uattrs.c Wed Nov 22 11:35:30 1989 --- ams/libs/ms/uattrs.c.NEW Wed Jun 13 16:48:05 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/uattrs.c,v 2.4 89/02/15 11:42:43 ghoti Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/uattrs.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/uattrs.c,v 2.4 89/02/15 11:42:43 ghoti Exp $ "; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/uattrs.c,v 2.4 89/02/15 11:42:43 ghoti Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/uattrs.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/uattrs.c,v 2.4 89/02/15 11:42:43 ghoti Exp $ "; #endif /* lint */ #include *** ams/libs/ms/unscrib.c Wed Nov 22 11:35:32 1989 --- ams/libs/ms/unscrib.c.NEW Fri Jul 27 12:44:16 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/unscrib.c,v 2.8 89/04/16 11:30:58 nsb Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/unscrib.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/unscrib.c,v 2.10 90/07/26 16:38:13 gk5g Exp $ ! $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/unscrib.c,v $ */ #include #include *************** *** 13,20 **** #include /* sys/file.h */ extern FILE *fopen(); - extern char *index(), *StripWhiteEnds(), *malloc(); MS_WriteUnscribedBodyFile(DirName, id, FileName) char *DirName, /* IN */ *id, /* IN */ --- 13,25 ---- #include /* sys/file.h */ extern FILE *fopen(); + #ifndef _IBMR2 + extern char *malloc(); + #endif /* _IBMR2 */ + + extern char *index(), *StripWhiteEnds(); + MS_WriteUnscribedBodyFile(DirName, id, FileName) char *DirName, /* IN */ *id, /* IN */ *************** *** 60,68 **** AMS_RETURN_ERRCODE(errno, EIN_FOPEN, EVIA_WRITEUNSCRIBED); } GetFormatFromMessage(Msg, ScribeVers, sizeof(ScribeVers), &IsBE2); ! DeleteHeader(Msg, HP_SCRIBEFORMAT); ! DeleteHeader(Msg, HP_CONTENTTYPE); ! DeleteHeader(Msg, HP_UNSUPPORTEDTYPE); if (fwriteallchars(Msg->RawBits, Msg->HeadSize, fp) != Msg->HeadSize) { fclose(fp); unlink(FileName); --- 65,75 ---- AMS_RETURN_ERRCODE(errno, EIN_FOPEN, EVIA_WRITEUNSCRIBED); } GetFormatFromMessage(Msg, ScribeVers, sizeof(ScribeVers), &IsBE2); ! if (ScribeVers[0]) { ! DeleteHeader(Msg, HP_SCRIBEFORMAT); ! DeleteHeader(Msg, HP_CONTENTTYPE); ! DeleteHeader(Msg, HP_UNSUPPORTEDTYPE); ! } if (fwriteallchars(Msg->RawBits, Msg->HeadSize, fp) != Msg->HeadSize) { fclose(fp); unlink(FileName); *** ams/libs/ms/update.c Wed Nov 22 11:35:46 1989 --- ams/libs/ms/update.c.NEW Wed Jun 13 16:48:09 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/update.c,v 2.8 89/08/29 10:39:48 mcinerny Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/update.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/update.c,v 2.8 89/08/29 10:39:48 mcinerny Exp $ "; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/update.c,v 2.9 90/06/06 14:04:40 ajp Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/update.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/update.c,v 2.9 90/06/06 14:04:40 ajp Exp $ "; #endif /* lint */ #include *************** *** 66,83 **** return(retcode); } ! #ifdef hp9000s300 setup_sigAlrm() { } ! #endif /* hp9000s300 */ UpdateState(DoEverything) Boolean DoEverything; { ! #ifndef hp9000s300 union wait status; ! #endif /* hp9000s300 */ int pid, retcode = 0, errct = 0; #ifdef WHITEPAGES_ENV static long time_when_wp_last_closed = 0; --- 66,83 ---- return(retcode); } ! #if defined(hpux) && HP_OS < 70 setup_sigAlrm() { } ! #endif /* hpux */ UpdateState(DoEverything) Boolean DoEverything; { ! #ifndef hpux union wait status; ! #endif /* hpux */ int pid, retcode = 0, errct = 0; #ifdef WHITEPAGES_ENV static long time_when_wp_last_closed = 0; *************** *** 113,119 **** } if (MS_ShouldCleanZombies) { ! #ifdef hp9000s300 int status; struct sigvec vecAlrm; struct itimerval timer; --- 113,119 ---- } if (MS_ShouldCleanZombies) { ! #if defined(hpux) && HP_OS < 70 int status; struct sigvec vecAlrm; struct itimerval timer; *************** *** 135,145 **** timer.it_value.tv_sec = 0; timer.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &timer, 0); ! #else /* hp9000s300 */ do { /* Have you checked the children? */ pid = wait3(&status, WNOHANG, NULL); } while (pid > 0); ! #endif /* hp9000s300 */ } NeedToTimeOut = 0; if (errct > 1) { --- 135,145 ---- timer.it_value.tv_sec = 0; timer.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &timer, 0); ! #else /* hpux */ do { /* Have you checked the children? */ pid = wait3(&status, WNOHANG, NULL); } while (pid > 0); ! #endif /* hpux */ } NeedToTimeOut = 0; if (errct > 1) { *** ams/libs/ms/util.c Wed Nov 22 11:35:47 1989 --- ams/libs/ms/util.c.NEW Wed Jun 13 16:48:13 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/util.c,v 2.12 89/07/21 17:27:05 cfe Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/util.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/ms/RCS/util.c,v 2.12 89/07/21 17:27:05 cfe Exp $ "; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/util.c,v 2.13 90/06/05 14:37:50 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/util.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/libs/ms/RCS/util.c,v 2.13 90/06/05 14:37:50 gk5g Exp $ "; #endif /* lint */ #include *************** *** 14,20 **** #include /* sys/file.h */ #include ! extern char *getprofile(), *malloc(), *index(), *StripWhiteEnds(); extern char home[], MyMailDomain[]; extern Boolean DidInit; --- 14,24 ---- #include /* sys/file.h */ #include ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char *getprofile(), *index(), *StripWhiteEnds(); extern char home[], MyMailDomain[]; extern Boolean DidInit; *** ams/libs/shr/brkdown.c Wed Nov 22 11:36:19 1989 --- ams/libs/shr/brkdown.c.NEW Wed Jun 13 16:48:25 1990 *************** *** 2,18 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/shr/RCS/brkdown.c,v 2.5 89/08/03 13:26:41 ghoti Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/shr/RCS/brkdown.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/shr/RCS/brkdown.c,v 2.5 89/08/03 13:26:41 ghoti Exp $ "; #endif /* lint */ #include ! extern char *Next822LPart(), *malloc(), *index(); static char * Useful_Next822LPart(s, e, thing, size) char *s, *e, *thing; --- 2,22 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/shr/RCS/brkdown.c,v 2.6 90/06/04 16:51:00 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/shr/RCS/brkdown.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/shr/RCS/brkdown.c,v 2.6 90/06/04 16:51:00 gk5g Exp $ "; #endif /* lint */ #include ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char *Next822LPart(), *index(); static char * Useful_Next822LPart(s, e, thing, size) char *s, *e, *thing; *** ams/libs/shr/utils.c Wed Nov 22 11:36:20 1989 --- ams/libs/shr/utils.c.NEW Wed Jun 13 16:48:28 1990 *************** *** 3,10 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/shr/RCS/utils.c,v 2.4 89/02/10 09:16:02 ghoti Exp $ ! $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/libs/shr/RCS/utils.c,v $ */ #include #include --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ /* ! $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/shr/RCS/utils.c,v 2.5 90/06/04 16:51:12 gk5g Exp $ ! $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/libs/shr/RCS/utils.c,v $ */ #include #include *************** *** 11,17 **** #include #include /* Just for debugging, could as easily be ms.h */ ! extern char *index(), *malloc(); /* Random utilities used by BOTH cui and ms */ --- 11,20 ---- #include #include /* Just for debugging, could as easily be ms.h */ ! extern char *index(); ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ /* Random utilities used by BOTH cui and ms */ *** ams/msclients/cui/cui.c Fri Feb 2 12:23:57 1990 --- ams/msclients/cui/cui.c.NEW Wed Jun 13 16:48:48 1990 *************** *** 2,16 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/andrew/ams/msclients/cui/RCS/cui.c,v 2.29 90/01/26 12:27:17 susan Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/andrew/ams/msclients/cui/RCS/cui.c,v $ */ #define CUIP_MAJ_VER 2 #define CUIP_MIN_VER 0 #ifndef NO_DUPLICATE_STATIC_CHARS ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/ams/msclients/cui/RCS/cui.c,v 2.29 90/01/26 12:27:17 susan Exp $ "; #endif /* NO_DUPLICATE_STATIC_CHARS */ --- 2,16 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/msclients/cui/RCS/cui.c,v 2.30 90/06/04 17:22:37 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/msclients/cui/RCS/cui.c,v $ */ #define CUIP_MAJ_VER 2 #define CUIP_MIN_VER 0 #ifndef NO_DUPLICATE_STATIC_CHARS ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/msclients/cui/RCS/cui.c,v 2.30 90/06/04 17:22:37 gk5g Exp $ "; #endif /* NO_DUPLICATE_STATIC_CHARS */ *************** *** 129,136 **** extern struct tm *localtime (); extern FILE * qopen (); ! extern char *convlongto64 (), *StripWhiteEnds (), *index (), *malloc (), *realloc (), ! *getenv (), *copy(), *GetLine(), *rindex(); extern char *sys_errlist[], *ms_errlist[], *ms_errcauselist[], --- 129,140 ---- extern struct tm *localtime (); extern FILE * qopen (); ! ! #ifndef _IBMR2 ! extern char *malloc (), *realloc (); ! #endif /* _IBMR2 */ ! ! extern char *convlongto64 (), *StripWhiteEnds (), *index (), *getenv (), *copy(), *GetLine(), *rindex(); extern char *sys_errlist[], *ms_errlist[], *ms_errcauselist[], *** ams/msclients/vui/cmdargs.c Wed Nov 22 11:38:17 1989 --- ams/msclients/vui/cmdargs.c.NEW Wed Jun 13 16:49:14 1990 *************** *** 27,33 **** * */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/msclients/vui/RCS/cmdargs.c,v 2.3 89/02/15 08:29:18 ghoti Exp $ */ #include --- 27,33 ---- * */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/msclients/vui/RCS/cmdargs.c,v 2.4 90/06/05 14:26:43 gk5g Exp $ */ #include *************** *** 35,41 **** --- 35,44 ---- #include #include #include + + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ char *GetArgument (i, arg, argc, argv) int *i, argc; *** ams/msclients/vui/panelp.c Wed Nov 22 11:38:49 1989 --- ams/msclients/vui/panelp.c.NEW Wed Jun 13 16:49:20 1990 *************** *** 21,27 **** * */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/msclients/vui/RCS/panelp.c,v 1.15 89/07/21 17:45:33 cfe Exp $ */ #include #include --- 21,27 ---- * */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/msclients/vui/RCS/panelp.c,v 1.16 90/06/05 14:27:01 gk5g Exp $ */ #include #include *************** *** 30,36 **** --- 30,39 ---- #include #include + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ + extern int Interactive; unsigned char msg_row = 23; *** ams/msclients/vui/vui.c Wed Nov 22 11:38:44 1989 --- ams/msclients/vui/vui.c.NEW Thu May 10 16:20:46 1990 *************** *** 2,8 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/msclients/vui/RCS/vui.c,v 2.29 89/07/21 17:45:55 cfe Exp $ */ /* * This module contains the mainline VUI code for access --- 2,8 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/msclients/vui/RCS/vui.c,v 2.30 90/05/01 10:33:07 bobg Exp $ */ /* * This module contains the mainline VUI code for access *************** *** 115,120 **** --- 115,121 ---- amsconfig(argc, argv, CUI_SnapIsRunning? "vuis": "vuin"); Interactive=FALSE; SetUp(argc, argv, &opt); + show_motd = CUI_GetProfileSwitch(ProgramName,"motd",FALSE); /* pdb */ while (!quit) { GotoFlag=TRUE; *** ams/msclients/vui/vuibase.c Wed Nov 22 11:38:34 1989 --- ams/msclients/vui/vuibase.c.NEW Wed Jun 13 16:49:24 1990 *************** *** 2,11 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/msclients/vui/RCS/vuibase.c,v 1.29 89/08/18 00:08:09 ghoti Exp $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/msclients/vui/RCS/vuibase.c,v 1.29 89/08/18 00:08:09 ghoti Exp $ "; #endif /* lint */ #include --- 2,11 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/msclients/vui/RCS/vuibase.c,v 1.30 90/06/05 14:27:13 gk5g Exp $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/msclients/vui/RCS/vuibase.c,v 1.30 90/06/05 14:27:13 gk5g Exp $ "; #endif /* lint */ #include *************** *** 31,37 **** --- 31,41 ---- #define WHOIS_ROW 8 extern char *AndrewDir(), *GetSUser(), *getenv(), *index(), *copy(); + + #ifndef _IBMR2 extern char *malloc(), *realloc(); + #endif /* _IBMR2 */ + extern char VUI_editor[], *rindex(), *StripWhiteEnds(), CUI_VersionString[]; extern char ENT_filename[], VUI_printer[]; extern char *VUI_HelpFile, VUI_bccto[], sep_line[]; *** ams/msclients/vui/vuipnl.c Wed Nov 22 11:38:40 1989 --- ams/msclients/vui/vuipnl.c.NEW Wed Jun 13 16:49:35 1990 *************** *** 2,8 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/msclients/vui/RCS/vuipnl.c,v 1.27 89/08/24 10:21:55 ghoti Exp $ */ /* * This module defines, and responds to input from, the --- 2,8 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/msclients/vui/RCS/vuipnl.c,v 1.28 90/06/05 14:31:29 gk5g Exp $ */ /* * This module defines, and responds to input from, the *************** *** 21,27 **** #include #include ! extern char *malloc(), *index(), *GetSUser(); extern long CUI_DisambiguateDir(), CUI_CacheDirName(); extern long MS_GetPartialFile(), MS_GetNthSnapshot(), MS_WriteUnscribedBodyFile(), MS_SetAssociatedTime(), MS_UpdateState(), MS_UnlinkFile(), MS_DisambiguateFile(), MS_ParseDate(); --- 21,31 ---- #include #include ! #ifndef _IBMR2 ! extern char *malloc(); ! #endif /* _IBMR2 */ ! ! extern char *index(), *GetSUser(); extern long CUI_DisambiguateDir(), CUI_CacheDirName(); extern long MS_GetPartialFile(), MS_GetNthSnapshot(), MS_WriteUnscribedBodyFile(), MS_SetAssociatedTime(), MS_UpdateState(), MS_UnlinkFile(), MS_DisambiguateFile(), MS_ParseDate(); *** ams/utils/nntp/cmd/main.c Wed Nov 22 11:39:37 1989 --- ams/utils/nntp/cmd/main.c.NEW Wed Jun 13 16:50:12 1990 *************** *** 27,33 **** #else /* DEBUG */ char *logaddr="bb+andrew.daemons.nntppoll"; #endif /* DEBUG */ ! char AuthString[1000] = '\0'; char dupfile[MAXPATHLEN+1]; --- 27,33 ---- #else /* DEBUG */ char *logaddr="bb+andrew.daemons.nntppoll"; #endif /* DEBUG */ ! char AuthString[1000] = "\0"; char dupfile[MAXPATHLEN+1]; *** ams/utils/nntp/lib/nntppoll.c Wed Nov 22 11:40:03 1989 --- ams/utils/nntp/lib/nntppoll.c.NEW Fri Jul 20 11:22:32 1990 *************** *** 33,40 **** --- 33,43 ---- #include #include + #if !SY_AIX12 && !defined(_IBMR2) extern unsigned long int time(); + #endif /* SY_AIX12 && !defined(_IBMR2)*/ extern int errno; + extern char *arpadate(); char *DSTS = ""; char *GRPS = "comp.*,news.*,sci.*,rec.*,misc.*,soc.*,talk.*"; *** ams/utils/reauth/reauth.c Wed Nov 22 11:40:16 1989 --- ams/utils/reauth/reauth.c.NEW Thu May 10 16:21:19 1990 *************** *** 11,16 **** --- 11,19 ---- #include + #if defined(AIX) && defined(i386) + #include + #endif /* defined(AIX) && defined(i386) */ #include #include #include *** ams/delivery/trymail/strong.c Wed Nov 22 11:41:03 1989 --- ams/delivery/trymail/strong.c.NEW Thu May 10 16:21:35 1990 *************** *** 10,16 **** is permitted to return mail to its sender. \* ************************************************************ */ ! static char rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/delivery/trymail/RCS/strong.c,v 1.37 89/10/09 17:05:17 cfe Exp $"; #include #include --- 10,16 ---- is permitted to return mail to its sender. \* ************************************************************ */ ! static char rcsid[] = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/delivery/trymail/RCS/strong.c,v 1.39 90/05/09 16:23:16 gk5g Exp $"; #include #include *************** *** 1857,1862 **** --- 1857,1880 ---- return 0; } + int RemoteGotDelivered(Addr) + PARSED_ADDRESS *Addr; + {/* The given Addr has been delivered. Don't consider it here. */ + struct DelayedRemote *DR; + + for (DR = RemoteRoot; DR != NULL; DR = DR->Next) { + if (DR->RmtAddr == Addr) { + DR->FailCode1 = 0; + DR->FailCode2 = 3; + DR->Status = Finished; + if (TMDebug) fprintf(stderr, "RemoteGotDelivered: found ``%s''.\n", Addr->LocalPart); + return 0; + } + } + if (TMDebug) fprintf(stderr, "RemoteGotDelivered: didn't find ``%s''. Sigh.\n", Addr->LocalPart); + return 1; + } + static int BackULcmp(p1, p2) char *p1, *p2; {/* Do like ULstrcmp, but look from the ends of the strings to the beginnings. */ *************** *** 1977,1984 **** NumRecip = 0; for (DR = RemoteRoot; DR != NULL; DR = DR->Next) { DR->AddrPrint = AddrUnparse(DR->RmtAddr, &DR->AddrReason); ! DR->Status = UnTried; ! if (DR->AddrPrint != NULL) { NMax = WasThisSent(MsgHdr, DR->AddrPrint, DR->RmtAddr); if (NMax > 0) { DR->Status = Redundant; --- 1995,2001 ---- NumRecip = 0; for (DR = RemoteRoot; DR != NULL; DR = DR->Next) { DR->AddrPrint = AddrUnparse(DR->RmtAddr, &DR->AddrReason); ! if (DR->AddrPrint != NULL && DR->Status == UnTried) { NMax = WasThisSent(MsgHdr, DR->AddrPrint, DR->RmtAddr); if (NMax > 0) { DR->Status = Redundant; *************** *** 1991,2015 **** TimedOut = 0; for (DR = RemoteRoot; DR != NULL; DR = DR->Next) { ! Hst = DR->RmtAddr->Hosts; ! /* Catch problem cases falling through from when we can't reject a cross-cell message. */ ! if (Hst != NULL && Hst != Hst->Prev && DR->RmtAddr->MD == NULL) { ! char *Prime, *Second; int outType, laerr; ! Prime = NULL; ! laerr = la_KindDomain(DR->RmtAddr, &outType, &Prime, &Second, GlobalDom); ! if (Prime != NULL) free(Prime); ! } ! Hst = DR->RmtAddr->Hosts; ! if (Hst != NULL && Hst != Hst->Prev) { ! Hst = Hst->Prev; ! if (Hst->Name != NULL && Hst->Name[0] != '\0') { ! if (DR->RmtAddr->MD == NULL) { ! DR->Status = Finished; ! DR->FailCode1 = 13; ! } else if (DR->RmtAddr->MD->Qual == mailhost_bad || (!IsExpired && DR->RmtAddr->MD->Qual == mailhost_indeterminate)) { ! DR->Status = Finished; ! DR->FailCode1 = ! (DR->RmtAddr->MD->Qual == mailhost_bad ? 12 : 11); } } } --- 2008,2034 ---- TimedOut = 0; for (DR = RemoteRoot; DR != NULL; DR = DR->Next) { ! if (DR->Status == UnTried) { ! Hst = DR->RmtAddr->Hosts; ! /* Catch problem cases falling through from when we can't reject a cross-cell message. */ ! if (Hst != NULL && Hst != Hst->Prev && DR->RmtAddr->MD == NULL) { ! char *Prime, *Second; int outType, laerr; ! Prime = NULL; ! laerr = la_KindDomain(DR->RmtAddr, &outType, &Prime, &Second, GlobalDom); ! if (Prime != NULL) free(Prime); ! } ! Hst = DR->RmtAddr->Hosts; ! if (Hst != NULL && Hst != Hst->Prev) { ! Hst = Hst->Prev; ! if (Hst->Name != NULL && Hst->Name[0] != '\0') { ! if (DR->RmtAddr->MD == NULL) { ! DR->Status = Finished; ! DR->FailCode1 = 13; ! } else if (DR->RmtAddr->MD->Qual == mailhost_bad || (!IsExpired && DR->RmtAddr->MD->Qual == mailhost_indeterminate)) { ! DR->Status = Finished; ! DR->FailCode1 = ! (DR->RmtAddr->MD->Qual == mailhost_bad ? 12 : 11); ! } } } } *************** *** 2317,2322 **** --- 2336,2344 ---- if (DR->FailCode2 == 2) { AddrResult(tmok_RequestedNotToSend, DR->RmtAddr, "Requested to omit"); + } else if (DR->FailCode2 == 3) { + AddrResult(tmok_DroppedOffToCell, DR->RmtAddr, + "Delivered into authenticated cell"); } else if (DR->FailCode2 == 1) { AddrResult(tmok_DroppedOffToCell, DR->RmtAddr, "Dropped into cellular queues"); *************** *** 2333,2339 **** break; case 3: if (DR->FailCode2 > 0) { ! if (tfail(DR->FailCode2) || ULstrcmp(GlobalDom, WorkstationCell) != 0) { AddrResult(tmltf_MailTransputError, DR->RmtAddr, "StripBE: error %s", UnixError(DR->FailCode2)); } else { --- 2355,2361 ---- break; case 3: if (DR->FailCode2 > 0) { ! if (tfail(DR->FailCode2) || DR->FailCode2 == EPIPE || ULstrcmp(GlobalDom, WorkstationCell) != 0) { AddrResult(tmltf_MailTransputError, DR->RmtAddr, "StripBE: error %s", UnixError(DR->FailCode2)); } else { *************** *** 2441,2447 **** FILE *RunningPgm; struct BEStripper *BES = NULL; struct stat sblock; ! static struct {char **Src; char Abbr} Params[] = { {&TextRetPath, 'r'}, {&DestStr, 'd'}, {&CopyForString, '4'}, --- 2463,2469 ---- FILE *RunningPgm; struct BEStripper *BES = NULL; struct stat sblock; ! static struct {char **Src; char Abbr;} Params[] = { {&TextRetPath, 'r'}, {&DestStr, 'd'}, {&CopyForString, '4'}, *** ams/delivery/trymail/trymail.c Wed Apr 11 14:17:32 1990 --- ams/delivery/trymail/trymail.c.NEW Thu May 10 16:21:43 1990 *************** *** 8,14 **** to client workstations for possible short-circuit evaluation. \* ************************************************************ */ ! static char rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/ams/delivery/trymail/RCS/trymail.c,v 1.40 90/03/07 11:10:05 bobg Exp $"; #include /*VARARGS1*/ --- 8,14 ---- to client workstations for possible short-circuit evaluation. \* ************************************************************ */ ! static char rcsid[] = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/delivery/trymail/RCS/trymail.c,v 1.41 90/05/01 10:31:18 bobg Exp $"; #include /*VARARGS1*/ *************** *** 2447,2452 **** --- 2447,2455 ---- case Group: TypeName = "group contents"; break; + default: + TypeName = "unknown address type"; + break; } AddrResult(tmltf_MailFwdBadParse, Addr, "Cannot parse %s; code is %d", TypeName, FwdCode); return; *************** *** 3370,3375 **** --- 3373,3379 ---- if (ULstrcmp(ThisAddr->Hosts->Prev->Name, Domain) == 0) { AddrResult(tmok_DroppedOffToCell, ThisAddr, "Dropped into queues for cell %s", Domain); + RemoteGotDelivered(ThisAddr); AppendAddrTo(ThisAddr, DoneList); } break; *************** *** 3435,3440 **** --- 3439,3449 ---- if (Addrs[Ix] != NULL) ThisWasSent(Hdr, Addrs[Ix], GlobalForString, 1); } MoveMatching(AddrList, ca->CellName, DoneList); + if (TMDebug) { + fprintf(stderr, "AuthCellDelivery to queues for cell %s: delivered %s", ca->CellName, Addrs[0]); + for (Ix = 1; Ix < HowMany; ++Ix) fprintf(stderr, ", %s", Addrs[Ix]); + fprintf(stderr, "\n"); + } } } } *************** *** 3441,3447 **** for (Ix = 0; Ix < HowMany; ++Ix) if (Addrs[Ix] != NULL) free(Addrs[Ix]); free(Addrs); ! FreeAddressList(DoneList); } } if (Hdr != NULL) {free(Hdr); unlink(fnBuff);} --- 3450,3457 ---- for (Ix = 0; Ix < HowMany; ++Ix) if (Addrs[Ix] != NULL) free(Addrs[Ix]); free(Addrs); ! /* Don't reclaim addresses because that causes switchmail's subsequent DealWithRemoteList to crap out in trying to refer to the (now moved) addresses. Since we're exiting soon, we can afford to discard our pointers to this storage. */ ! /* FreeAddressList(DoneList); */ DoneList = NULL; } } if (Hdr != NULL) {free(Hdr); unlink(fnBuff);} *** ams/delivery/trymail/weak.c Wed Nov 22 11:41:07 1989 --- ams/delivery/trymail/weak.c.NEW Thu May 10 16:21:47 1990 *************** *** 11,17 **** determinations for ``switchmail'' running on the postoffice machines. \* ************************************************************ */ ! static char rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/ams/delivery/trymail/RCS/weak.c,v 1.8 89/03/23 12:02:07 cfe Exp $"; #include #include --- 11,17 ---- determinations for ``switchmail'' running on the postoffice machines. \* ************************************************************ */ ! static char rcsid[] = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/ams/delivery/trymail/RCS/weak.c,v 1.9 90/05/01 10:31:54 bobg Exp $"; #include #include *************** *** 94,99 **** --- 94,106 ---- int AppendRemote(Addr, Fwd) PARSED_ADDRESS *Addr; struct FwdLink *Fwd; + { + return 0; + } + + /*ARGSUSED*/ + int RemoteGotDelivered(Addr) + PARSED_ADDRESS *Addr; { return 0; } *** ams/delivery/trymail/wkstr.h Wed Nov 22 11:41:06 1989 --- ams/delivery/trymail/wkstr.h.NEW Thu May 10 16:21:49 1990 *************** *** 63,70 **** extern char *FindErrString(); extern int FindForwarding(); ! /* Handle remote recipients. AppendRemote gets a chance to construct something for each recipient, and DealWithRemoteList must handle each named remote list. If it wants, it can simply use the argument, which is a PARSED_ADDRESS list naming the saved remote addresses. */ extern int AppendRemote(); extern void DealWithRemoteList(); /* ReturnError() sends off an error message to the Return-Path. It returns 0 if there's every expectation that the message will get there, and a non-zero code otherwise. ReturnAmbig() will compose and send an error message about an ambiguous recipient, returning similar error codes. */ --- 63,71 ---- extern char *FindErrString(); extern int FindForwarding(); ! /* Handle remote recipients. AppendRemote gets a chance to construct something for each recipient, and DealWithRemoteList must handle each named remote list. (RemoteGotDelivered can reclaim an AppendRemote entry if something need not be dealt with by DealWithRemoteList.) If it wants, it can simply use the argument, which is a PARSED_ADDRESS list naming the saved remote addresses. */ extern int AppendRemote(); + extern int RemoteGotDelivered(); extern void DealWithRemoteList(); /* ReturnError() sends off an error message to the Return-Path. It returns 0 if there's every expectation that the message will get there, and a non-zero code otherwise. ReturnAmbig() will compose and send an error message about an ambiguous recipient, returning similar error codes. */ *** ams/delivery/queuem/queuem.c Fri Jan 12 13:40:34 1990 --- ams/delivery/queuem/queuem.c.NEW Fri Jul 20 11:22:48 1990 *************** *** 41,48 **** -4 string String will be used as value of FOR subfield in Received header (if it is prepended) - -m Mail errors back to sender (uses -r value - or uid of invoker) -E Examine the queue given via ``-q''; don't process mail in it. That is, print a listing of the contents of the queue. -a All following arguments are addresses, not further --- 41,46 ---- *************** *** 270,275 **** --- 268,275 ---- static char AMSHomeCell[2*MAXCELLCHARS+1] = { '\0' }; static int GotAMSHomeCell = FALSE; static char *homeCell = NULL; + static char TrymailArgBuff[300]; + static char *TrymailArg = NULL; static char AuthorizationRequest[300]; static int AuthNonQueue = 0; *************** *** 449,455 **** ReturnPath[argLen] = '\0'; } else { ReturnPath[0] = '<'; ! strcpy(ReturnPath+1, arg+extraBkts, argLen); strcpy(ReturnPath+argLen+1, ">"); } } else { --- 449,455 ---- ReturnPath[argLen] = '\0'; } else { ReturnPath[0] = '<'; ! strncpy(ReturnPath+1, arg+extraBkts, argLen); strcpy(ReturnPath+argLen+1, ">"); } } else { *************** *** 1670,1676 **** #endif /* DEBUG */ if (Pass == 1 && StartAt != '\0') { SetProcTitle("(queuemail) -O%d p%d scanning to ``%c'' (%s)", cotime, Pass, (StartAt == '\0' ? '0' : StartAt), Times); ! for (pwd=getvpwent(); pwd->pw_name[0] < StartAt; pwd=getvpwent()); } for (pwd=getvpwent(); pwd!=NIL; pwd=getvpwent()) { char dirName[MAXPATHLEN+1]; --- 1670,1676 ---- #endif /* DEBUG */ if (Pass == 1 && StartAt != '\0') { SetProcTitle("(queuemail) -O%d p%d scanning to ``%c'' (%s)", cotime, Pass, (StartAt == '\0' ? '0' : StartAt), Times); ! for (pwd=getvpwent(); pwd != NIL && pwd->pw_name != NIL && pwd->pw_name[0] < StartAt; pwd=getvpwent()); } for (pwd=getvpwent(); pwd!=NIL; pwd=getvpwent()) { char dirName[MAXPATHLEN+1]; *************** *** 2066,2072 **** case 'C': /* Ignore most arguments (for future compatibility). */ if (s[1] == 'h') { /* Set home cell */ ! homeCell = argv[1]; } ++argv; --argc; --- 2066,2079 ---- case 'C': /* Ignore most arguments (for future compatibility). */ if (s[1] == 'h') { /* Set home cell */ ! homeCell = argv[1]; ! } else if (s[1] == 'a') { /* set extra arg to trymail/switchmail */ ! if (strlen(argv[1]) >= sizeof(TrymailArgBuff)) { ! sprintf(ErrorText, "Trymail arg too long: %d chars (%d max)", strlen(argv[1]), sizeof(TrymailArgBuff)-1); ! FatalError(ErrorText, NIL, FALSE, EX_USAGE); ! } ! strncpy(TrymailArgBuff, argv[1], sizeof(TrymailArgBuff)); ! TrymailArg = TrymailArgBuff; } ++argv; --argc; *************** *** 2180,2189 **** Debugging, prbool(IsDaemon)); printf("\tBypassLocalDelivery: %s\n\tUseOldSendmail: %s\n", prbool(BypassLocalDelivery), prbool(UseOldSendmail)); printf("\tSleepPeriod: %d\n\tOldMessageAge: %d (seconds)\n\tToNames: ", SleepPeriod, OldMessageAge); ListAllRecipients(stdout, ", "); ! printf("\n\tMailSourceFile: %s\n\tSourceQueueDir: %s\n\tPrimaryQueueDir: %s\n", MailSourceFile, SourceQueueDir, PrimaryQueueDir); printf("\tBackupQueueDir: %s\n\tLocalQueueDir: %s\n", BackupQueueDir, LocalQueueDir); --- 2187,2199 ---- Debugging, prbool(IsDaemon)); printf("\tBypassLocalDelivery: %s\n\tUseOldSendmail: %s\n", prbool(BypassLocalDelivery), prbool(UseOldSendmail)); + if (TrymailArg != NULL) { + printf("\tExtra trymail/switchmail arg: ``%s''\n", TrymailArg); + } printf("\tSleepPeriod: %d\n\tOldMessageAge: %d (seconds)\n\tToNames: ", SleepPeriod, OldMessageAge); ListAllRecipients(stdout, ", "); ! printf("\n\tMailSourceFile: %s\n\tSourceQueueDir: %s\n\tPrimaryQueueDir: %s\n", MailSourceFile, SourceQueueDir, PrimaryQueueDir); printf("\tBackupQueueDir: %s\n\tLocalQueueDir: %s\n", BackupQueueDir, LocalQueueDir); *************** *** 2311,2317 **** static char LatestGetError[450]; /*VARARGS1*/ static void GetError(fmt, p1, p2, p3, p4, p5) ! char *fmt, *p1, *p2, *p3, *p4, *p5; { /* Record the latest GetMessageFromQueue error and handle reporting. */ sprintf(LatestGetError, fmt, p1, p2, p3, p4, p5); --- 2321,2328 ---- static char LatestGetError[450]; /*VARARGS1*/ static void GetError(fmt, p1, p2, p3, p4, p5) ! char *fmt, *p1; ! int p2, p3, p4, p5; { /* Record the latest GetMessageFromQueue error and handle reporting. */ sprintf(LatestGetError, fmt, p1, p2, p3, p4, p5); *************** *** 2823,2829 **** sprintf(PMMailbox, "-m%s", PostmasterMailbox); argv[1] = PMMailbox; argv[2] = NULL; ! f = qopen(vicemail, argv, "w"); if (f == NULL) { debug(512, ("Horrible bailout: can't run vicemail\n")); sprintf(Text, "Can not run vicemail to give error to postmaster: %s", Msg); --- 2834,2840 ---- sprintf(PMMailbox, "-m%s", PostmasterMailbox); argv[1] = PMMailbox; argv[2] = NULL; ! f = (FILE *) qopen(vicemail, argv, "w"); if (f == NULL) { debug(512, ("Horrible bailout: can't run vicemail\n")); sprintf(Text, "Can not run vicemail to give error to postmaster: %s", Msg); *************** *** 3177,3183 **** static int TryLocalDelivery() { ! static char *argv[16]; static char *program; int WillWait, i, pgrp, status, timedout, result, termcode; FILE *r, *w; --- 3188,3194 ---- static int TryLocalDelivery() { ! static char *argv[17]; static char *program; int WillWait, i, pgrp, status, timedout, result, termcode; FILE *r, *w; *************** *** 3222,3227 **** --- 3233,3239 ---- #if LogsYes if (Logging) argv[++i] = "-t"; #endif /* LogsYes */ + if (TrymailArg != NULL) argv[++i] = TrymailArg; argv[++i] = MailSourceFile; #if Logs *** ams/delivery/sendmail/sendmail.c Wed Jan 17 16:36:15 1990 --- ams/delivery/sendmail/sendmail.c.NEW Thu May 10 16:22:06 1990 *************** *** 101,107 **** qargs[q] = NIL; /* Fork queuemail & send it message */ ! qmail = qopen(queuemail, qargs, "w"); if (qmail == NIL) { fputs("[SENDMAIL] Can't invoke queuemail\n", stderr); exit(EX_UNAVAILABLE); --- 101,107 ---- qargs[q] = NIL; /* Fork queuemail & send it message */ ! qmail = (FILE *) qopen(queuemail, qargs, "w"); if (qmail == NIL) { fputs("[SENDMAIL] Can't invoke queuemail\n", stderr); exit(EX_UNAVAILABLE); *************** *** 171,177 **** register int i; args[2] = PostmasterTitle; ! fout = qopen(queuemail, args, "w"); if (fout == NULL) return fputs("WARNING: can't send mail to postmaster\n", stderr); --- 171,177 ---- register int i; args[2] = PostmasterTitle; ! fout = (FILE *) qopen(queuemail, args, "w"); if (fout == NULL) return fputs("WARNING: can't send mail to postmaster\n", stderr); *** atk/apps/Imakefile Wed Nov 22 11:44:26 1989 --- atk/apps/Imakefile.NEW Fri Jul 27 12:46:05 1990 *************** *** 17,24 **** #endif /* WM_ENV */ #ifdef X11_ENV ! X11LIBS = ${BASEDIR}/lib/libcmenu.a \ ! ${XLIBDIR}/libX11.a #endif /* X11_ENV */ OTHERLIBS = ${WMLIBS} \ --- 17,23 ---- #endif /* WM_ENV */ #ifdef X11_ENV ! X11LIBS = ${BASEDIR}/lib/libcmenu.a #endif /* X11_ENV */ OTHERLIBS = ${WMLIBS} \ *************** *** 28,38 **** $(MALLOCLIB) \ ${X11LIBS} SYSLIBS = -lm NormalObjectRule() ! ProgramTarget(runapp, runapp.o statload.o, ${ATKLIBS} ${OTHERLIBS}, ${SYSLIBS}) InstallProgram(runapp, ${DESTDIR}/bin) --- 27,41 ---- $(MALLOCLIB) \ ${X11LIBS} + #ifdef X11_ENV + SYSLIBS = -lX11 -lm + #else SYSLIBS = -lm + #endif /* X11_ENV */ NormalObjectRule() ! ProgramTarget(runapp, runapp.o statload.o, ${ATKLIBS} ${OTHERLIBS} ${RESOLVLIB}, ${SYSLIBS}) InstallProgram(runapp, ${DESTDIR}/bin) *** atk/apps/statload.c Wed Nov 22 11:44:29 1989 --- atk/apps/statload.c.NEW Thu Jul 12 13:57:23 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/apps/RCS/statload.c,v 2.7 89/06/22 13:25:10 ghoti Exp $ */ /* $ACIS:statload.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/apps/RCS/statload.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/apps/RCS/statload.c,v 2.7 89/06/22 13:25:10 ghoti Exp $"; #endif /* lint */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/apps/RCS/statload.c,v 2.10 90/07/12 13:34:07 ajp Exp $ */ /* $ACIS:statload.c 1.2$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/apps/RCS/statload.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/apps/RCS/statload.c,v 2.10 90/07/12 13:34:07 ajp Exp $"; #endif /* lint */ *************** *** 43,48 **** --- 43,49 ---- #include #include #include + #include #include #include #include *************** *** 113,118 **** --- 114,120 ---- fontdesc_StaticEntry; im_StaticEntry; buffer_StaticEntry; + bufferlist_StaticEntry; mark_StaticEntry; nestedmark_StaticEntry; rectlist_StaticEntry; *** atk/apt/apt/apt.c Wed Jan 17 16:36:28 1990 --- atk/apt/apt/apt.c.NEW Mon Apr 23 13:50:21 1990 *************** *** 11,16 **** --- 11,19 ---- /* $Log: apt.c,v $ + * Revision 1.7 90/04/11 14:10:12 gk5g + * Removed initialization of variable debug from apt.h and put it in apt.c:apt__InitializeClass. Create apt__InitializeClass. + * * Revision 1.6 89/12/12 14:57:47 ghoti * sync with MIT tape * *************** *** 102,107 **** --- 105,120 ---- static char *areas[] = { "Left", "Top", "Right", "Bottom" }; + boolean + apt__InitializeClass( classID ) + register struct classheader *classID; + { + IN(apt_InitializeClass); + debug = 0; + OUT(apt_InitializeClass); + return TRUE; + } + boolean apt__InitializeObject( classID, self ) register struct classheader *classID; *** atk/apt/apt/apt.ch Wed Nov 22 11:44:46 1989 --- atk/apt/apt/apt.ch.NEW Mon Apr 23 13:50:26 1990 *************** *** 3,16 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/apt/apt/RCS/apt.ch,v 1.2 89/05/24 19:44:52 tom Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/apt/apt/RCS/apt.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidapt_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/apt/apt/RCS/apt.ch,v 1.2 89/05/24 19:44:52 tom Exp $"; #endif /* $Log: apt.ch,v $ Revision 1.2 89/05/24 19:44:52 tom Add apt_LeftArea, etc. --- 3,19 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/apt/apt/RCS/apt.ch,v 1.3 90/04/11 14:11:06 gk5g Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/apt/apt/RCS/apt.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidapt_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/apt/apt/RCS/apt.ch,v 1.3 90/04/11 14:11:06 gk5g Exp $"; #endif /* $Log: apt.ch,v $ + Revision 1.3 90/04/11 14:11:06 gk5g + Removed initialization of variable debug from apt.h and put it in apt.c:apt__InitializeClass. Create apt__InitializeClass. + Revision 1.2 89/05/24 19:44:52 tom Add apt_LeftArea, etc. *************** *** 133,138 **** --- 136,142 ---- InitializeObject( struct apt *self ) returns boolean; FinalizeObject( struct apt *self ); + InitializeClass() returns boolean; data: *** atk/apt/apt/apt.h Wed Nov 22 11:44:44 1989 --- atk/apt/apt/apt.h.NEW Mon Apr 23 13:50:28 1990 *************** *** 7,12 **** --- 7,18 ---- /* $Log: apt.h,v $ + * Revision 1.4 90/04/11 14:11:12 gk5g + * Removed initialization of variable debug from apt.h and put it in apt.c:apt__InitializeClass. Create apt__InitializeClass. + * + * Revision 1.3 90/04/11 12:37:56 gk5g + * Initialized variable debug to zero. + * * Revision 1.2 89/08/03 16:01:56 gk5g * Replaced #include with andrewos.h. * *** atk/apt/suite/suiteev.c Wed Apr 11 14:18:03 1990 --- atk/apt/suite/suiteev.c.NEW Thu Jul 12 12:56:36 1990 *************** *** 4,10 **** \* ********************************************************************** */ #ifndef lint ! static char *rcsidsuiteev_c = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/apt/suite/RCS/suiteev.c,v 1.28 90/03/05 12:16:32 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* --- 4,10 ---- \* ********************************************************************** */ #ifndef lint ! static char *rcsidsuiteev_c = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/apt/suite/RCS/suiteev.c,v 1.33 90/06/13 18:59:52 gk5g Exp Locker: gk5g $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* *************** *** 30,92 **** Such curiosities need be resolved prior to Project Completion... - HISTORY - 11/01/88 Created (GW Keim) - 05/04/89 Changed to lower-case naming convention (GW Keim) - 05/23/89 Added hooks to determine the window system; - Made sure that ShadowItem() looked reasonable - on both X and WM; (GW Keim) - 05/26/89 Changed suiteev_ItemNormalize() to either draw a caption or - call view_FullUpdate(item->viewobject,...); - Tuned the arrangement layout in PlaceItems() and - suiteev_Arrange(); - Worked on improving the ReadWrite items behavior with - respect to hits in other items when it has the inputFocus; (GW Keim) - 05/30/89 Cleaned up suiteev_Hit() with respect to calling hit handlers under - the proper conditions. (GW Keim) - 06/05/89 Continued to clean-up suiteev_Hit(); - 06/07/89 Changed suiteev_Hit() to call the client hithandler only on the - up-transition; As well, changed _Hit() to give the InputFocus to - any child inset (CVIF) the hit occurs on; - Prefaced some calls to suiteev_DrawItemBorder() with a test - to determine if the item_BorderStyle is suite_Invisible; (GW Keim) - 06/09/89 Tweaked AttemptSymmetry() to work better. - 07/21/89 Added check for sufficient dimensions upon entering suiteev_Arrange() - if the suite is a List; (GW Keim) - 07/28/89 Moved methods suite_MaxStringSize, MaxSubStringSize, - suite_SetItemToReadWrite from suite.c to suiteev.c; - Made fix in suiteev_Hit() to call view_WantInputFocus in lieu of - view_ReceiveInputFocus. This problem had adverse affects on CECEtalk; - Only set the {X,Y}GutterOffset to a non-zero value if the actual gutterSize - is also non-zero; (GW Keim) - 08/02/89 Changed the setting of CVIF in suiteev_Hit() so that CECEtalk properly - accepted hits. This was a general bug; (GW Keim) - 08/06/89 Changed suiteev_ItemDrawCaption() and suiteev_ItemDrawTitle() - to white-out the background if the item has a passivation-style - of suite_Pale (GW Keim) - 08/24/89 Upgrade to V1.0 interface (GWK) - 08/25/89 Fix for core-dump in AttemptSymmetry() where I divide by - zero when the window is really large. Fix for wrapping bug wherein - breakpoints were being left around and erroneously found in - suiteev_ItemDrawCaption(). - 09/08/89 Added support for caption-alignment; (GW Keim) - 09/14/89 In ItemPlaceCaption() added the statements that set the captionwidth - and captionheight parameters to 0 if either is greater than - dimensions of the passed item; (GW Keim) - 09/29/89 Removed whiteing-out of the background behind a passive caption; - Added code in suiteev_ItemDrawCaption() that results in a suiteev_Update() - when a bolded List caption grows too large for the item dimensions; - In support of this "bolded List caption growing" added - MaxListSubStringWidth(); - Added NPixels{Prior,After}() in support of List scrolling; - Increased the performance of long List scrolling by keeping track of the - summed height of the captions as they are being ShrinkWrap()'ed; - Now draw captions within their CaptionRects using - BETWEENTOPANDBOTTOM not TOPANDBASELINE (This was causing - descenders to be drawn out of the item space; - END-SPECIFICATION ************************************************************/ ! #include #include #include --- 30,37 ---- Such curiosities need be resolved prior to Project Completion... END-SPECIFICATION ************************************************************/ ! #include #include #include #include *************** *** 212,639 **** static void xsetframe(), ygetinfo(), ysetframe(), yendzone(); static long ywhatis(), xwhatis(); static void DrawRect(); ! static struct scrollfns horizInterface = {ygetinfo,xsetframe,yendzone,xwhatis}; ! static struct scrollfns vertInterface = {ygetinfo,ysetframe,yendzone,ywhatis}; static void ReadWriteHandler(); ! static void MaxSubStringSize(), MaxListSubStringWidth(); static struct menulist *menulist = NULL; static void AllocNameSpace( target, source ) ! register char **target, *source; { ! if(target && *target) { ! free(*target); ! *target = NULL; ! } ! if(source && *source) { ! *target = malloc(strlen(source)+1); ! if(*target) strcpy(*target,source); ! } ! else *target = NULL; } static long Within( x, y, left, top, width, height ) ! register long x, y, left, top, width, height; { ! return((x >= left) && (x <= left + width) && (y >= top) && (y <= top + height)); } static long WithinRect( x, y, r ) ! register long x, y; ! register struct rectangle *r; { ! return( Within( x, y, r->left, r->top, r->width, r->height ) ); } static long CopySelected( self, suite, item, datum ) ! register struct suiteev *self; ! register struct suite *suite; ! register struct suite_item *item; ! register long datum; { ! register long int status = 0; ! static char buffer[1025]; ! IN(CopySelected); ! if(suite && item) ! if(Exposed(item) && Active(item) && Highlighted(item)) { ! sprintf(buffer,"%s ",(char*)suite_ItemAttribute(suite,item, ! suite_ItemCaption(0))); ! fputs(buffer,(FILE*)datum); ! } ! OUT(CopySelected); ! return(status); } static void Copy( self ) ! register struct suiteev *self; { ! register FILE *CutFile = NULL; ! register struct im *im = NULL; ! IN(Copy); ! if(im = suiteev_GetIM(self)) { ! CutFile = im_ToCutBuffer(im); ! suite_Apply(Suite,CopySelected,Suite,CutFile); ! im_CloseToCutBuffer(im,CutFile); ! } ! OUT(Copy); } boolean suiteev__InitializeClass( ClassID ) ! register struct classheader *ClassID; { ! struct proctable_Entry *tempProc = NULL; ! IN(suiteev_InitializeClass); ! menulist = menulist_New(); ! tempProc = proctable_DefineProc( "suiteev-copy", Copy, &suiteev_classinfo, NULL, "copy selected region to cut buffer" ); ! menulist_AddToML( menulist, "Copy~10", tempProc, NULL, NULL ); ! OUT(suiteev_InitializeClass); ! return(TRUE); } boolean suiteev__InitializeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct suiteev *self; { ! self->parent = NULL; ! self->cvif = NULL; ! self->firsthit = self->lasthit = NULL; ! self->menulist = menulist_DuplicateML(menulist,self); ! FirstVisibleSubString = 0; ! debug = Debug = 0; ! return(TRUE); } void ! suiteev__FinalizeObject( self ) ! register struct suiteev *self; ! {} void suiteev__PostMenus( self, menulist ) ! struct suiteev *self; ! struct menulist *menulist; { ! IN(suiteev_PostMenus); ! if(List) { ! menulist_ClearChain(self->menulist); ! if(menulist) ! menulist_ChainBeforeML(self->menulist,menulist,NULL); ! super_PostMenus(self,self->menulist); ! } ! else super_PostMenus(self,menulist); ! OUT(suiteev_PostMenus); } static struct suite_item * NthAfter( self, start, numToSkip ) ! register struct suiteev *self; ! register struct suite_item *start; ! register long numToSkip; { ! register int i = 0; ! register struct suite_item *item = start; ! register long count = 0, size = 0; ! IN(NthAfter); ! if(Items && ITEM(0) && (i = vector_Subscript(Items,start)) != -1) { ! size = vector_Count(Items); ! while((count < numToSkip) && (i < size) && (item = ITEM(++i))) ! if(suite_ItemExposed(Suite,item)) count++; ! } ! OUT(NthAfter); ! return(item); } static struct suite_item * NthPrior( self, start, numToSkip ) ! register struct suiteev *self; ! register struct suite_item *start; ! register long numToSkip; { ! register int i = 0; ! register struct suite_item *item = start; ! register long count = 0; ! IN(NthAfter); ! if(Items && ITEM(0) && (i = vector_Subscript(Items,start)) != -1) { ! while((count < numToSkip) && (i > 0) && (item = ITEM(--i))) ! if(suite_ItemExposed(Suite,item)) count++; ! } ! OUT(NthPrior); ! return(item); } static struct suite_item * NPixelsAfter( self, start, pix, numToSkip ) ! register struct suiteev *self; ! register struct suite_item *start; ! register long pix, *numToSkip; { ! register int i = 0; ! register struct suite_item *item = start; ! register long count = 0, size = 0, tmp = 0; ! IN(NthAfter); ! if(Items && ITEM(0) && (i = vector_Subscript(Items,start)) != -1) { ! size = vector_Count(Items); ! if(ColumnMajor) tmp = YGutterSize; ! else tmp = XGutterSize; ! while((tmp < pix) && (i < size) && (item = ITEM(++i))) ! if(suite_ItemExposed(Suite,item)) { ! if(ColumnMajor) tmp += (Height + YGutterSize); ! else tmp += (Width + XGutterSize); ! count++; ! } ! } ! *numToSkip = count; ! OUT(NPixelsAfter); ! return(item); } static struct suite_item * NPixelsPrior( self, start, pix, numToSkip ) ! register struct suiteev *self; ! register struct suite_item *start; ! register long pix, *numToSkip; { ! register int i = 0; ! register struct suite_item *item = start; ! register long count = 0, tmp = 0; ! IN(NthAfter); ! if(Items && ITEM(0) && (i = vector_Subscript(Items,start)) != -1) { ! if(ColumnMajor) tmp = YGutterSize; ! else tmp = XGutterSize; ! while((tmp < pix) && (i > 0) && (item = ITEM(--i))) ! if(suite_ItemExposed(Suite,item)) { ! if(ColumnMajor || List) tmp += (Height + YGutterSize); ! else tmp += (Width + XGutterSize); ! count++; ! } ! } ! *numToSkip = count; ! OUT(NPixelsPrior); ! return(item); } static void DrawGutterLines( self ) ! register struct suiteev *self; { ! register struct suite_item *item = FirstVisible; ! register long i = 0; ! long numToDo = 0, numToSkip = 0; ! long Offset = 0; ! IN(DrawGutterLines); ! if(Items && ITEM(0) && FirstVisible ) { ! if(RowLine) { ! if(RowMajor) numToSkip = VisibleColumns; ! else if(ColumnMajor) numToSkip = 1; ! numToDo = VisibleRows - 1; ! Offset = YGutterSize/2; ! for(i = 0 ;(i < numToDo) && item ; i++) { ! suiteev_MoveTo(self,ContainerLeft,Top + Height + Offset); ! suiteev_DrawLineTo(self,ContainerLeft + ContainerWidth, ! Top + Height + Offset); ! item = NthAfter(self,item,numToSkip); ! } } ! if(ColumnLine) { ! if(RowMajor) numToSkip = 1; ! else if(ColumnMajor) numToSkip = VisibleRows; ! item = FirstVisible; ! numToDo = VisibleColumns - 1; ! Offset = XGutterSize/2; ! for(i = 0 ; (i < numToDo) && item ; i++) { ! suiteev_MoveTo(self,Left + Width + Offset, Top); ! suiteev_DrawLineTo(self,Left + Width + Offset, ! Top + ContainerHeight); ! item = NthAfter(self,item,numToSkip); ! } } } ! OUT(DrawGutterLines); } static long ResetItemBreaks( self, suite, item, datum ) ! register struct suite *self; ! register struct suite *suite; ! register struct suite_item *item; ! register long datum; { ! register int status = 0, i = 0; ! if(item) { ! for(i = 0; i < BreakCount(item); i++) ! vector_Item(Breaks(item),i) = 0; ! BreakCount(item) = 0; ! } ! return(status); } void suiteev__FullUpdate( self, type, left, top, width, height ) ! register struct suiteev *self; ! register enum view_UpdateType type; ! register long left, top, width, height; { ! struct rectangle r; ! ! IN(suiteev_FullUpdate); ! if((type == view_FullRedraw) || (type == view_LastPartialRedraw)) { ! rectangle_SetRectSize(&r,left,top,width,height); ! if(List) suite_Apply(Suite,ResetItemBreaks,Suite,0); ! suiteev_Arrange(self,&r); ! suiteev_DrawItems(self,&r); ! } ! DrawGutterLines(self); ! OUT(suiteev_FullUpdate); } char * suiteev__GetInterface( self, type ) ! register struct suiteev *self; ! register char *type; { ! IN(suiteev_GetInterface); ! if(!strcmp(type,"scroll,vertical")) return((char*)&vertInterface); ! else if(!strcmp(type,"scroll,horizontal")) return((char*)&horizInterface); ! else return(NULL); } static void ygetinfo( self, total, seen, dot ) ! register struct suiteev *self; ! register struct range *total, *seen, *dot; { ! IN(ygetinfo); ! total->beg = 0; ! total->end = suiteev_NumberExposed(self) - 1; ! if(Items && ITEM(0) && FirstVisible) ! seen->beg = vector_Subscript(Items,FirstVisible); ! else seen->beg = 0; ! if(Items && ITEM(0) && LastVisible) ! seen->end = vector_Subscript(Items,LastVisible); ! else seen->end = total->end; ! dot->beg = dot->end = seen->beg; } static void yendzone( self, zone, action ) ! register struct suiteev *self; ! register int zone; ! register enum view_MouseAction action; { ! register int numVisible = 0, EndOffset = 0; ! register struct suite_item *LastItem = NULL; ! IN(yendzone); ! if(zone == /*scroll_BOTTOMENDZONE*/ 3) { ! if(Items && ITEM(0)) { ! numVisible = suiteev_NumberExposed(self); ! LastItem = ITEM(vector_Count(Items) - 1); ! if(Matrix) ! if(numVisible > (VisibleRows * VisibleColumns)) { ! EndOffset = (VisibleRows * VisibleColumns) - 1; ! NewFirstVisible = NthPrior(self,LastItem,EndOffset); ! } ! else NewFirstVisible = ITEM(0); ! else if(SingleRow) ! if(numVisible > VisibleColumns) { ! EndOffset = VisibleColumns - 1; ! NewFirstVisible = NthPrior(self,LastItem,EndOffset); ! } ! else NewFirstVisible = ITEM(0); ! else if(SingleColumn) ! if(numVisible > VisibleRows) { ! EndOffset = VisibleRows - 1; ! NewFirstVisible = NthPrior(self,LastItem,EndOffset); ! } ! else NewFirstVisible = ITEM(0); } } ! else if(zone == scroll_TOPENDZONE) ! if(Items && ITEM(0)) NewFirstVisible = ITEM(0); ! suiteev_WantUpdate(self,self); ! OUT(yendzone); } static long ywhatis( self, num, denom ) ! register struct suiteev *self; ! register long num, denom; { ! return(suiteev_Locate(self,0,(num*suiteev_GetLogicalHeight(self))/denom)); } static void ysetframe( self, posn, coord, outof ) ! register struct suiteev *self; ! register long posn, coord, outof; { ! register long vertOffset = 0, height = ItemHeight; ! long numToSkip = 0; ! IN(ysetframe); ! if(coord) { /* Right Click */ ! if(RowLine) height = ItemHeight+3; ! vertOffset = suiteev_GetLogicalHeight(self)*coord/outof; ! if(List) { ! NPixelsPrior(self,FirstVisible,vertOffset,&numToSkip); ! if(RowMajor) numToSkip *= VisibleColumns; ! } ! else { ! if(ColumnMajor) numToSkip = vertOffset/height; ! else if(RowMajor) numToSkip = ((vertOffset/height)*VisibleColumns); ! } ! NewFirstVisible = NthPrior(self,FirstVisible,numToSkip); ! if(!NewFirstVisible) NewFirstVisible = ITEM(0); } ! else /* Left Click */ ! NewFirstVisible = NthAfter(self,ITEM(0),posn); ! suiteev_WantUpdate(self,self); } static long xwhatis( self, num, denom ) ! register struct suiteev *self; ! register long num, denom; { ! return(suiteev_Locate(self,(num*suiteev_GetLogicalWidth(self))/denom,0)); } static void xsetframe( self, posn, coord, outof ) ! register struct suiteev *self; ! register long posn, coord, outof; { ! register long width = ItemWidth, horizOffset = 0, numToSkip = 0; ! IN(xsetframe); ! if(coord) { /* Right Click */ ! if(ColumnLine) width += 3; ! horizOffset = suiteev_GetLogicalWidth(self)*coord/outof; ! if(ColumnMajor) numToSkip = ((horizOffset/width)*VisibleRows); ! else if(RowMajor) numToSkip = horizOffset/width; ! NewFirstVisible = NthPrior(self,FirstVisible,numToSkip); ! if(!NewFirstVisible) NewFirstVisible = ITEM(0); ! } ! else /* Left Click */ ! NewFirstVisible = NthAfter(self,ITEM(0),posn); ! suiteev_WantUpdate(self,self); } #define TwiceBorderSize (2*ItemBorderSize) --- 157,594 ---- static void xsetframe(), ygetinfo(), ysetframe(), yendzone(); static long ywhatis(), xwhatis(); static void DrawRect(); ! static struct scrollfns horizInterface = { ygetinfo, xsetframe, yendzone, xwhatis }; ! static struct scrollfns vertInterface = { ygetinfo, ysetframe, yendzone, ywhatis }; static void ReadWriteHandler(); ! static void MaxSubStringSize(); ! static long MaxListSubStringWidth(); static struct menulist *menulist = NULL; static void AllocNameSpace( target, source ) ! register char **target, *source; { ! if(target && *target) { ! free(*target); ! *target = NULL; ! } ! if(source && *source) { ! *target = malloc(strlen(source)+1); ! if(*target) strcpy(*target,source); ! } ! else *target = NULL; } static long Within( x, y, left, top, width, height ) ! register long x, y, left, top, width, height; { ! return((x >= left) && (x <= left + width) && (y >= top) && (y <= top + height)); } static long WithinRect( x, y, r ) ! register long x, y; ! register struct rectangle *r; { ! return(Within( x, y, r->left, r->top, r->width, r->height )); } static long CopySelected( self, suite, item, datum ) ! register struct suiteev *self; ! register struct suite *suite; ! register struct suite_item *item; ! register long datum; { ! register long int status = 0; ! static char buffer[1025]; ! IN(CopySelected); ! if(suite && item) ! if(Exposed(item) && Active(item) && Highlighted(item)) { ! sprintf(buffer,"%s ",(char*)suite_ItemAttribute(suite,item, ! suite_ItemCaption(0))); ! fputs(buffer,(FILE*)datum); ! } ! OUT(CopySelected); ! return(status); } static void Copy( self ) ! register struct suiteev *self; { ! register FILE *CutFile = NULL; ! register struct im *im = NULL; ! IN(Copy); ! if(im = suiteev_GetIM(self)) { ! CutFile = im_ToCutBuffer(im); ! suite_Apply(Suite,CopySelected,Suite,CutFile); ! im_CloseToCutBuffer(im,CutFile); ! } ! OUT(Copy); } boolean suiteev__InitializeClass( ClassID ) ! register struct classheader *ClassID; { ! struct proctable_Entry *tempProc = NULL; ! IN(suiteev_InitializeClass); ! menulist = menulist_New(); ! tempProc = proctable_DefineProc( "suiteev-copy", Copy, &suiteev_classinfo, NULL, "copy selected region to cut buffer" ); ! menulist_AddToML( menulist, "Copy~10", tempProc, NULL, NULL ); ! OUT(suiteev_InitializeClass); ! return(TRUE); } boolean suiteev__InitializeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct suiteev *self; { ! self->parent = NULL; ! self->cvif = NULL; ! self->firsthit = self->lasthit = NULL; ! self->menulist = menulist_DuplicateML(menulist,self); ! FirstVisibleSubString = 0; ! debug = Debug = 0; ! return(TRUE); } void ! suiteev__FinalizeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct suiteev *self; ! { ! if(self->menulist) menulist_Destroy(self->menulist); ! } void suiteev__PostMenus( self, menulist ) ! struct suiteev *self; ! struct menulist *menulist; { ! IN(suiteev_PostMenus); ! if(List) { ! menulist_ClearChain(self->menulist); ! if(menulist) ! menulist_ChainBeforeML(self->menulist,menulist,NULL); ! super_PostMenus(self,self->menulist); ! } ! else super_PostMenus(self,menulist); ! OUT(suiteev_PostMenus); } static struct suite_item * NthAfter( self, start, numToSkip ) ! register struct suiteev *self; ! register struct suite_item *start; ! register long numToSkip; { ! register int i = 0; ! register struct suite_item *item = start; ! register long count = 0, size = 0; ! IN(NthAfter); ! if(Items && ITEM(0) && (i = vector_Subscript(Items,start)) != -1) { ! size = vector_Count(Items); ! while((count < numToSkip) && (i < size) && (item = ITEM(++i))) ! if(suite_ItemExposed(Suite,item)) count++; ! } ! OUT(NthAfter); ! return(item); } static struct suite_item * NthPrior( self, start, numToSkip ) ! register struct suiteev *self; ! register struct suite_item *start; ! register long numToSkip; { ! register int i = 0; ! register struct suite_item *item = start; ! register long count = 0; ! IN(NthAfter); ! if(Items && ITEM(0) && (i = vector_Subscript(Items,start)) != -1) ! while((count < numToSkip) && (i > 0) && (item = ITEM(--i))) ! if(suite_ItemExposed(Suite,item)) count++; ! OUT(NthPrior); ! return(item); } static struct suite_item * NPixelsAfter( self, start, pix, numToSkip ) ! register struct suiteev *self; ! register struct suite_item *start; ! register long pix, *numToSkip; { ! register int i = 0; ! register struct suite_item *item = start; ! register long count = 0, size = 0, tmp = 0; ! IN(NthAfter); ! if(Items && ITEM(0) && (i = vector_Subscript(Items,start)) != -1) { ! size = vector_Count(Items); ! if(ColumnMajor) tmp = YGutterSize; ! else tmp = XGutterSize; ! while((tmp < pix) && (i < size) && (item = ITEM(++i))) ! if(suite_ItemExposed(Suite,item)) { ! if(ColumnMajor) tmp += (Height + YGutterSize); ! else tmp += (Width + XGutterSize); ! count++; ! } ! } ! *numToSkip = count; ! OUT(NPixelsAfter); ! return(item); } static struct suite_item * NPixelsPrior( self, start, pix, numToSkip ) ! register struct suiteev *self; ! register struct suite_item *start; ! register long pix, *numToSkip; { ! register int i = 0; ! register struct suite_item *item = start; ! register long count = 0, tmp = 0; ! IN(NthAfter); ! if(Items && ITEM(0) && (i = vector_Subscript(Items,start)) != -1) { ! if(ColumnMajor) tmp = YGutterSize; ! else tmp = XGutterSize; ! while((tmp < pix) && (i > 0) && (item = ITEM(--i))) ! if(suite_ItemExposed(Suite,item)) { ! if(ColumnMajor || List) tmp += (Height + YGutterSize); ! else tmp += (Width + XGutterSize); ! count++; ! } ! } ! *numToSkip = count; ! OUT(NPixelsPrior); ! return(item); } static void DrawGutterLines( self ) ! register struct suiteev *self; { ! register struct suite_item *item = FirstVisible; ! register long i = 0; ! long numToDo = 0, numToSkip = 0; ! long Offset = 0, clearLeft = 0, clearTop = 0; ! IN(DrawGutterLines); ! if(Items && ITEM(0) && FirstVisible ) { ! if(RowLine || ColumnLine) { ! if(RowLine) { ! if(RowMajor) numToSkip = VisibleColumns; ! else if(ColumnMajor) numToSkip = 1; ! numToDo = VisibleRows - 1; ! Offset = YGutterSize/2; ! for(i = 0 ;(i < numToDo) && item ; i++) { ! suiteev_MoveTo(self,ContainerLeft,Top + Height + Offset); ! suiteev_DrawLineTo(self,ContainerLeft + ContainerWidth, ! Top + Height + Offset); ! item = NthAfter(self,item,numToSkip); } ! clearTop = LastVisible->bounds.top + LastVisible->bounds.height; ! } ! if(ColumnLine) { ! if(RowMajor) numToSkip = 1; ! else if(ColumnMajor) numToSkip = VisibleRows; ! item = FirstVisible; ! numToDo = VisibleColumns - 1; ! Offset = XGutterSize/2; ! for(i = 0 ; (i < numToDo) && item ; i++) { ! suiteev_MoveTo(self,Left + Width + Offset, Top); ! suiteev_DrawLineTo(self,Left + Width + Offset, ! Top + ContainerHeight); ! item = NthAfter(self,item,numToSkip); } + clearLeft = LastVisible->bounds.left + LastVisible->bounds.width; + } + SetTransferMode(self,graphic_WHITE); + suiteev_FillRectSize(self, clearLeft, clearTop, ContainerWidth - clearLeft, ContainerHeight - clearTop, suiteev_WhitePattern(self) ); + SetTransferMode(self,graphic_BLACK); } ! } ! OUT(DrawGutterLines); } static long ResetItemBreaks( self, suite, item, datum ) ! register struct suite *self; ! register struct suite *suite; ! register struct suite_item *item; ! register long datum; { ! register int status = 0, i = 0; ! if(item) { ! for(i = 0; i < BreakCount(item); i++) ! vector_Item(Breaks(item),i) = 0; ! BreakCount(item) = 0; ! } ! return(status); } void suiteev__FullUpdate( self, type, left, top, width, height ) ! register struct suiteev *self; ! register enum view_UpdateType type; ! register long left, top, width, height; { ! struct rectangle r; ! ! IN(suiteev_FullUpdate); ! if((type == view_FullRedraw) || (type == view_LastPartialRedraw)) { ! rectangle_SetRectSize(&r,left,top,width,height); ! if(List) suite_Apply(Suite,ResetItemBreaks,Suite,0); ! suiteev_Arrange(self,&r); ! suiteev_DrawItems(self,&r); ! } ! DrawGutterLines(self); ! OUT(suiteev_FullUpdate); } char * suiteev__GetInterface( self, type ) ! register struct suiteev *self; ! register char *type; { ! IN(suiteev_GetInterface); ! if(!strcmp(type,"scroll,vertical")) return((char*)&vertInterface); ! else if(!strcmp(type,"scroll,horizontal")) return((char*)&horizInterface); ! else return(NULL); } static void ygetinfo( self, total, seen, dot ) ! register struct suiteev *self; ! register struct range *total, *seen, *dot; { ! IN(ygetinfo); ! total->beg = 0; ! total->end = suiteev_NumberExposed(self) - 1; ! if(Items && ITEM(0) && FirstVisible) ! seen->beg = vector_Subscript(Items,FirstVisible); ! else seen->beg = 0; ! if(Items && ITEM(0) && LastVisible) ! seen->end = vector_Subscript(Items,LastVisible); ! else seen->end = total->end; ! dot->beg = dot->end = seen->beg; } static void yendzone( self, zone, action ) ! register struct suiteev *self; ! register int zone; ! register enum view_MouseAction action; { ! register int numVisible = 0, EndOffset = 0; ! register struct suite_item *LastItem = NULL; ! IN(yendzone); ! if(zone == /*scroll_BOTTOMENDZONE*/ 3) { ! if(Items && ITEM(0)) { ! numVisible = suiteev_NumberExposed(self); ! LastItem = ITEM(vector_Count(Items) - 1); ! if(Matrix) ! if(numVisible > (VisibleRows * VisibleColumns)) { ! EndOffset = (VisibleRows * VisibleColumns) - 1; ! NewFirstVisible = NthPrior(self,LastItem,EndOffset); } + else NewFirstVisible = ITEM(0); + else if(SingleRow) + if(numVisible > VisibleColumns) { + EndOffset = VisibleColumns - 1; + NewFirstVisible = NthPrior(self,LastItem,EndOffset); + } + else NewFirstVisible = ITEM(0); + else if(SingleColumn) + if(numVisible > VisibleRows) { + EndOffset = VisibleRows - 1; + NewFirstVisible = NthPrior(self,LastItem,EndOffset); + } + else NewFirstVisible = ITEM(0); } ! } ! else if(zone == scroll_TOPENDZONE) ! if(Items && ITEM(0)) NewFirstVisible = ITEM(0); ! suiteev_WantUpdate(self,self); ! OUT(yendzone); } static long ywhatis( self, num, denom ) ! register struct suiteev *self; ! register long num, denom; { ! return(suiteev_Locate(self,0,(num*suiteev_GetLogicalHeight(self))/denom)); } static void ysetframe( self, posn, coord, outof ) ! register struct suiteev *self; ! register long posn, coord, outof; { ! register long vertOffset = 0, height = ItemHeight; ! long numToSkip = 0; ! IN(ysetframe); ! if(coord) { /* Right Click */ ! if(RowLine) height = ItemHeight+3; ! vertOffset = suiteev_GetLogicalHeight(self)*coord/outof; ! if(List) { ! NPixelsPrior(self,FirstVisible,vertOffset,&numToSkip); ! if(RowMajor) numToSkip *= VisibleColumns; } ! else { ! if(ColumnMajor) numToSkip = vertOffset/height; ! else if(RowMajor) numToSkip = ((vertOffset/height)*VisibleColumns); ! } ! NewFirstVisible = NthPrior(self,FirstVisible,numToSkip); ! if(!NewFirstVisible) NewFirstVisible = ITEM(0); ! } ! else /* Left Click */ ! NewFirstVisible = NthAfter(self,ITEM(0),posn); ! suiteev_WantUpdate(self,self); } static long xwhatis( self, num, denom ) ! register struct suiteev *self; ! register long num, denom; { ! return(suiteev_Locate(self,(num*suiteev_GetLogicalWidth(self))/denom,0)); } static void xsetframe( self, posn, coord, outof ) ! register struct suiteev *self; ! register long posn, coord, outof; { ! register long width = ItemWidth, horizOffset = 0, numToSkip = 0; ! IN(xsetframe); ! if(coord) { /* Right Click */ ! if(ColumnLine) width += 3; ! horizOffset = suiteev_GetLogicalWidth(self)*coord/outof; ! if(ColumnMajor) numToSkip = ((horizOffset/width)*VisibleRows); ! else if(RowMajor) numToSkip = horizOffset/width; ! NewFirstVisible = NthPrior(self,FirstVisible,numToSkip); ! if(!NewFirstVisible) NewFirstVisible = ITEM(0); ! } ! else /* Left Click */ ! NewFirstVisible = NthAfter(self,ITEM(0),posn); ! suiteev_WantUpdate(self,self); } #define TwiceBorderSize (2*ItemBorderSize) *************** *** 640,1641 **** static void AttemptSymmetry( self, numItems, rows, columns ) ! register struct suiteev *self; ! register long numItems, *rows, *columns; { ! ! IN(AttemptSymmetry); ! if((VScroll && HScroll) || !Scroll) { ! *rows = numItems / *columns; ! while(*rows > 0 && ((*columns / *rows) > 1)) { ! --(*columns); ! *rows = (numItems / *columns); ! } ! if((*rows < 1) || (numItems % *columns)) (*rows)++; } ! OUT(AttemptSymmetry); } static void SetBreakPoint( self, item, end ) ! register struct suiteev *self; ! register struct suite_item *item; ! register char *end; { ! vector_AddItem(Breaks(item),(long)(end - item_Caption)); } static boolean DoesItFit( self, item, head, tail, width ) ! struct suiteev *self; ! struct suite_item *item; ! char *head; ! char *tail; ! long width; { ! char save; ! long XWidth = 0, YWidth = 0; ! save = *tail; ! *tail = '\0'; ! fontdesc_StringSize(item_CaptionFont,suiteev_GetDrawable(self), ! head,&XWidth,&YWidth); ! *tail = save; /*replace potential break*/ ! if(XWidth < width) return(TRUE); ! else return(FALSE); } static char * WalkBackwardToPunctuation( head, tail ) ! register char *head; ! register char *tail; { ! if(tail && (*tail != ' ') && (*(tail - 1) == ' ')) tail--; ! while((tail > head) && (*tail == ' ')) tail--; ! while(tail > head) { ! if(*tail == '.' || *tail == '-' || *tail == ';' || *tail == ':') ! break; ! else tail--; ! } ! if(*tail == ' ') tail++; ! return(tail); } - static char * WalkBackwardBlackSpace( self, item, head, tail, width ) ! register struct suiteev *self; ! register struct suite_item *item; ! register char *head; ! register char *tail; ! register long width; { ! char *saved_tail = tail; ! if((*tail != ' ') && (*(tail - 1) == ' ')) (tail)--; ! while((tail > head) && (*tail == ' ')) (tail)--; ! while((tail > head) && (*tail != ' ')) (tail)--; ! if(*tail == ' ') (tail)++; ! if(tail == head) { ! tail = saved_tail; ! while((tail > head) && (tail = WalkBackwardToPunctuation(head,tail))) ! if(DoesItFit(self,item,head,tail,width)) break; ! else tail--; } ! if(tail == head) { ! tail = saved_tail-1; ! while(tail > head) { ! if(DoesItFit(self,item,head,tail,width)) break; ! else tail--; ! } ! if(tail == head) tail = head + 1; ! } ! return(tail); } void suiteev__ShrinkWrap( self, width, height ) ! struct suiteev *self; ! long width, height; { ! boolean end = FALSE, ResetWidthForOffset = TRUE; ! register int indx = 0, i = 0, numLines = 0; ! register struct suite_item *item = NULL; ! long saved_width = 0; ! register char *head = NULL, *nl = NULL, *t = NULL; ! long carriedHeight = YGutterSize + ItemBorderSize; ! IN(suiteev_ShrinkWrap); ! saved_width = width; ! if(Items && ITEM(0)) { ! indx = vector_Subscript(Items,FirstVisible); ! while((indx < vector_Count(Items)) && (item = ITEM(indx)) && (carriedHeight < height)) { ! if(width>(3*CaptionMWidth)) ResetWidthForOffset = FALSE; ! else ResetWidthForOffset = TRUE; ! width = saved_width; ! if(Exposed(item) && item_Caption) { ! BreakCount(item) = 0; ! numLines = suiteev_LineCount(self,item_Caption); ! head = item_Caption; ! for(i = 0 ; i < numLines ; i++) { end = FALSE; ! while(!end) { ! if(nl = (char*)index(head,'\n')) ! *nl = '\0'; ! else { ! nl = head + strlen(head); ! end = TRUE; ! } ! for(t = nl;t > head;t = WalkBackwardBlackSpace(self,item,head,t,width)) ! if(DoesItFit(self,item,head,t,width)) break; ! if(!end) *nl = '\n'; ! if(t == head) t = head+2; ! if(t > head && *t != '\0') { ! if(*t == '\n') head = t + 1; ! else { ! SetBreakPoint(self,item,t-1); ! end = FALSE; ! head = t; ! } ! if(!ResetWidthForOffset) { ! width -= (2 * CaptionMWidth); ! ResetWidthForOffset = TRUE; ! } ! } ! } } ! carriedHeight += (((item_CaptionFontSize+1) * (numLines+BreakCount(item))) + item_BorderSize + YGutterSize); ! } ! indx++; } } ! OUT(suiteev_ShrinkWrap); } static void PlaceItems( self, rect, rows, cols, numleftOvers, itemWidth, itemHeight ) ! register struct suiteev *self; ! struct rectangle *rect; ! long rows, cols, numleftOvers; ! long itemWidth, itemHeight; { ! register int i = 0; ! register struct suite_item *item = NULL; ! long itemIndex = 0, itemleft = 0, itemtop = 0; ! long int width = 0, height = 0, top = 0, left = 0; ! long int OrigWidth = 0, OrigHeight = 0, ! OrigTop = 0, OrigLeft = 0; ! long delta = 0; ! register long XIndex = 0, XMax = cols, YIndex = 0, YMax = rows; ! long Ax = 0, Bx = 0, Ay = 0, By = 0; ! IN(PlaceItems); ! rectangle_GetRectSize(rect,&left,&top,&width,&height); ! rectangle_GetRectSize(rect,&OrigLeft,&OrigTop,&OrigWidth,&OrigHeight ); ! if(Items && ITEM(0)) LastVisible = ITEM(vector_Count(Items) - 1); ! else return; ! if(RowMajor && (numleftOvers > 0)) rows++; ! else if(ColumnMajor && (numleftOvers > 0)) cols++; ! width -= (cols * XGutterSize); ! height -= (rows * YGutterSize); ! if(!List) { ! if(ItemFixedWidth && (delta = (width - (cols * itemWidth))) > 0) { ! left += (delta / 2); ! width -= delta; } ! if(ItemFixedHeight && (delta = (height - (rows * itemHeight))) > 0) { ! top += (delta / 2); ! height -= delta; } } ! if(List && VisibleColumns == 1) { Ax = left + XGutterSize; ! Bx = itemWidth + XGutterSize + 1; Ay = top + YGutterSize; ! itemtop = Ay; } ! else { ! Ax = left + XGutterSize; Bx = itemWidth + XGutterSize; ! Ay = top + YGutterSize; By = itemHeight + YGutterSize; ! } ! i = vector_Subscript(Items,FirstVisible); while(item = ITEM(i++)) ! if(Exposed(item)) { ! itemIndex++; ! if(List && VisibleColumns == 1) { ! itemHeight = ((item_RealCaptionFontSize+2) * (suiteev_LineCount(self,item_Caption) + BreakCount(item))) + TwiceBorderSize; ! By = itemHeight + YGutterSize; ! itemleft = Ax + XIndex * Bx; ! item_SetUpperLeft(item,itemleft,itemtop); ! itemtop += By; ! } ! else { ! itemleft = Ax + XIndex * Bx; ! itemtop = Ay + YIndex * By; ! item_SetUpperLeft(item,itemleft,itemtop); ! } ! item_SetDimensions(item,itemWidth,itemHeight); ! rectangle_SetRectSize(&InsetRect,itemleft,itemtop, ! itemWidth,itemHeight); ! if(RowMajor) { ! if(++XIndex == XMax) { ! XIndex = 0; ! YIndex++; ! } ! } ! else { ! if(++YIndex == YMax) { ! YIndex = 0; ! XIndex++; ! } ! } ! if((itemIndex == NumVisible) && (LastVisible = item)) break; ! if( numleftOvers && ! ((RowMajor && (YIndex == (YMax - 1))) || ! (ColumnMajor && (XIndex == (XMax - 1))))) break; ! } ! if(numleftOvers) { ! left = OrigLeft;top = OrigTop; ! width = OrigWidth;height = OrigHeight; ! if(Balanced) { ! if(RowMajor) { ! width -= ((numleftOvers+1) * XGutterSize); ! left += (abs(width-(numleftOvers*itemWidth))/2); ! Ax = left + XGutterSize; ! } ! else if(ColumnMajor) { ! height -= ((numleftOvers+1) * YGutterSize); ! top += (abs(height-(numleftOvers*itemHeight))/2); ! Ay = top + YGutterSize; ! } ! } ! if(RowMajor) XIndex = 0; ! else YIndex = 0; ! while(item = ITEM(i++)) ! if(Exposed(item)) { ! itemIndex++; ! item_SetDimensions(item,itemWidth,List? ((item_RealCaptionFontSize+2)*(suiteev_LineCount(self,item_Caption)+ ! BreakCount(item))):itemHeight); ! itemleft = Ax + XIndex * Bx; ! itemtop = Ay + YIndex * By; ! item_SetUpperLeft(item,itemleft,itemtop); ! rectangle_SetRectSize(&InsetRect,itemleft,itemtop,itemWidth,itemHeight); ! if(RowMajor) XIndex++; ! else YIndex++; ! if((itemIndex == NumVisible) && (LastVisible = item)) break; ! } ! } ! NumVisible = itemIndex; ! OUT(PlaceItems); } static void DetermineVisibleListItems( self, height ) ! struct suiteev *self; ! long height; { ! register int i = 0, count = 0; ! struct suite_item *item = NULL; ! int sum = YGutterSize; ! IN(DetermineVisibleListItems); ! i = vector_Subscript(Items,FirstVisible); ! while(item = ITEM(i++)) { ! count++; ! sum += (TwiceBorderSize + YGutterSize + ((suiteev_LineCount(self,item_Caption) + BreakCount(item)) * (item_RealCaptionFontSize+2))); ! if(sum > height) { ! NumVisible = count; ! return; ! } } ! NumVisible = count; ! OUT(DetermineVisibleListItems); } void suiteev__Arrange( self, rect ) ! register struct suiteev *self; ! register struct rectangle *rect; { ! long itemWidth = 0, itemHeight = 0, ! minHeight = 0, minWidth = 0, ! width = 0, height = 0, top = 0, left = 0; ! long numleftOvers = 0, ! maxCols = 0, maxRows = 0, numItems = 0; ! long XGutterOffset = 0, YGutterOffset = 0; ! IN(suiteev_Arrange); ! if(!Items || ((numItems = suiteev_NumberExposed(self)) <= 0) || ! (List && (rect->width < (3 * CaptionMWidth))) || ! (List && (rect->height < (RealCaptionFontSize + TwiceBorderSize)))) { ! FirstVisible = LastVisible = NULL; ! NumVisible = 0; ! return; } ! else if(!FirstVisible) FirstVisible = ITEM(0); ! suiteev_MaxStringSize(self,&itemWidth,&itemHeight); ! rectangle_GetRectSize(rect,&left,&top,&width,&height); ! XGutterOffset = ((XGutterSize > 0) ? (XGutterSize + 1) : 0); ! YGutterOffset = ((YGutterSize > 0) ? (YGutterSize + 1) : 0); ! if(ItemFixedHeight) minHeight = ItemFixedHeight + YGutterOffset; ! else minHeight = itemHeight + TwiceBorderSize + 2 + YGutterOffset; ! if(ItemFixedWidth) minWidth = ItemFixedWidth + XGutterOffset; ! else minWidth = itemWidth + TwiceBorderSize + (2 * CaptionMWidth) + XGutterOffset; ! if(List && (minWidth > width)) { ! if(width > (TwiceBorderSize+(2*CaptionMWidth)+XGutterOffset)) { ! suiteev_ShrinkWrap(self, width - TwiceBorderSize - ! CaptionMWidth - XGutterOffset, height); ! suiteev_MaxStringSize(self,&itemWidth,&itemHeight); ! minHeight = itemHeight + TwiceBorderSize + 2 + YGutterOffset; ! minWidth = itemWidth + TwiceBorderSize + CaptionMWidth + XGutterOffset; ! } } ! if(!Scroll) { ! NumVisible = numItems; ! FirstVisible = ITEM(0); } ! if(Matrix) { DEBUG(Matrix); ! maxCols = ((width/minWidth > 1) ? (width/minWidth) : 1); ! maxRows = ((height/minHeight > 1) ? (height/minHeight) : 1); ! if(RowMajor && (maxCols > numItems)) { ! maxCols = numItems; ! maxRows = 1; ! } ! else if(ColumnMajor && (maxRows > numItems)) { ! maxRows = numItems; ! maxCols = 1; ! } ! AttemptSymmetry(self,numItems,&maxRows,&maxCols); ! width -= ((maxCols+1) * XGutterSize); ! height -= ((maxRows+1) * YGutterSize); ! if(List) { DEBUG(List); ! ItemWidth = itemWidth = minWidth - XGutterSize; ! ItemHeight = itemHeight = minHeight - YGutterSize; ! } ! else { DEBUG(Not List); ! if(ItemFixedWidth) ItemWidth = itemWidth = ItemFixedWidth; ! else ItemWidth = itemWidth = width/maxCols; ! if(ItemFixedHeight) ItemHeight = itemHeight = ItemFixedHeight; ! else ItemHeight = itemHeight = height/maxRows; ! } ! VisibleColumns = Columns = maxCols; ! VisibleRows = Rows = maxRows; ! if( numItems <= ( VisibleRows * VisibleColumns ) ) ! NumVisible = numItems; ! else NumVisible = VisibleRows * VisibleColumns; ! if(RowMajor) numleftOvers = NumVisible % maxCols; ! else if(ColumnMajor) numleftOvers = NumVisible % maxRows; ! if(List && (maxCols == 1)) { ! DetermineVisibleListItems(self,rect->height); ! VisibleRows = Rows = maxRows = NumVisible; ! numleftOvers = 0; ! } } ! else if(SingleColumn) { DEBUG(SingleColumn); ! if(ItemFixedHeight) { DEBUG(FixedHeight); ! itemHeight = ItemFixedHeight; ! if(Scroll) NumVisible = height/minHeight; ! else NumVisible = numItems; ! } ! else { ! if(Scroll) { ! if((NumVisible = height/minHeight) == 0) ! NumVisible = 1; ! } ! else NumVisible = numItems; ! height -= ((NumVisible+1) * YGutterSize ); ! itemHeight = height/NumVisible; ! } ! if(ItemFixedWidth) ! itemWidth = ItemFixedWidth; ! else ! itemWidth = width - (2 * XGutterSize); ! ItemHeight = itemHeight; ! ItemWidth = itemWidth; ! if(Scroll) { ! if(VScroll) { ! Rows = numItems; ! maxRows = VisibleRows = NumVisible; ! } ! } ! else NumVisible = Rows = VisibleRows = maxRows = numItems; ! Columns = VisibleColumns = maxCols = 1; ! if(List) { ! DetermineVisibleListItems(self,rect->height); ! VisibleRows = Rows = maxRows = NumVisible; ! numleftOvers = 0; ! } } else { ! if(ItemFixedWidth) { ! minWidth = itemWidth = ItemFixedWidth; ! if(Scroll) NumVisible = width/minWidth; ! else NumVisible = numItems; ! } ! else { ! if(Scroll) ! if((NumVisible = width/minWidth) == 0) ! NumVisible = 1; ! else NumVisible = numItems; ! width -= ((NumVisible+1) * XGutterSize); ! itemWidth = width/NumVisible; ! } ! if(ItemFixedHeight) ! itemHeight = ItemFixedHeight; ! else ! itemHeight = height - (2 * YGutterSize); ! ItemHeight = itemHeight; ! ItemWidth = itemWidth; ! if(Scroll) { ! if(HScroll) { ! Columns = numItems; ! maxCols = VisibleColumns = NumVisible; ! } ! } ! else NumVisible = Columns = VisibleColumns = maxCols = numItems; ! Rows = VisibleRows = maxRows = 1; } ! PlaceItems(self,rect,maxRows,maxCols,numleftOvers,itemWidth,itemHeight); ! OUT(suiteev_Arrange); } void suiteev__DrawItems( self, rect ) ! register struct suiteev *self; ! register struct rectangle *rect; { ! register int i = 0; ! register struct suite_item *item = NULL; ! IN(suiteev_DrawItems); ! if(!Items || !ITEM(0)) return; ! if(!FirstVisible) FirstVisible = ITEM(0); ! i = vector_Subscript(Items,FirstVisible); ! while(item = ITEM(i++)) ! if(Exposed(item)) { ! ItemFullUpdate(self,item,view_FullRedraw,0,0,0,0); ! if(item == LastVisible) break; ! } ! OUT(suiteev_DrawItems); } static void EraseItems( self ) ! register struct suiteev *self; { ! register int i = 0; ! register struct suite_item *item = NULL; ! IN(EraseItems); ! if(!Items || !ITEM(0) || !FirstVisible) return; ! i = vector_Subscript(Items,FirstVisible); ! while(item = ITEM(i++)) ! if(Exposed(item)) { ! suiteev_ItemClear(self,item); ! if(item == LastVisible) break; ! } ! SetTransferMode(self,graphic_BLACK); ! OUT(EraseItems); } void suiteev__Update( self ) ! register struct suiteev *self; { ! struct rectangle r; ! IN(suiteev_Update); ! suiteev_GetVisualBounds(self,&r); ! if(RowLine || ColumnLine) EraseItems(self); ! else suiteev_Clear(self); ! if(FirstVisible != NewFirstVisible) ! FirstVisible = NewFirstVisible; ! if(List) suite_Apply(Suite,ResetItemBreaks,Suite,0); ! suiteev_Arrange(self,&r); ! suiteev_DrawItems(self,&r); ! DrawGutterLines(self); ! OUT(suiteev_Update); } long suiteev__NumberItems( self ) ! register struct suiteev *self; { ! if(Items && ITEM(0)) return(vector_Count(Items)); ! else return(-1); } long suiteev__NumberVisible( self ) ! register struct suiteev *self; { ! register long i = 0; ! register struct suite_item *item = FirstVisible; ! while(item && ++i && (item != LastVisible)); ! return(i); } long suiteev__NumberExposed( self ) ! register struct suiteev *self; { ! register long i = 0, index = 0; ! register struct suite_item *item = NULL; ! if(Items && ITEM(0)) ! while(item = ITEM(index++)) ! if(Exposed(item)) i++; ! return(i); } void suiteev__Clear( self ) ! register struct suiteev *self; { ! struct rectangle r; ! suiteev_GetVisualBounds(self,&r); ! SetTransferMode(self,graphic_WHITE); ! suiteev_FillRect(self,&r,suiteev_WhitePattern(self)); ! SetTransferMode(self,graphic_BLACK); } struct suite_item * suiteev__WhichItem( self, x, y ) ! register struct suiteev *self; ! register long x, y; { ! register int i = 0; ! register struct suite_item *item = NULL; ! IN(suiteev_WhichItem); ! if(Items && ITEM(0)) { ! if(!FirstVisible) FirstVisible = ITEM(0); ! i = vector_Subscript(Items,FirstVisible); ! while(item = ITEM(i++)) ! if(Active(item) && Exposed(item) && WithinRect(x,y,&Bounds)) ! return(item); ! else if(item == LastVisible) ! return(NULL); ! } ! return(NULL); } void suiteev_HandleExclusiveHit( self, item, action, x, y, numberOfClicks ) ! register struct suiteev *self; ! register struct suite_item *item; ! enum view_MouseAction action; ! long x, y; ! long numberOfClicks; { ! IN(suiteev_HandleExclusiveHit); ! switch(action) { ! case view_LeftDown: ! if(Highlighted(item)) break; ! else { ! suite_Reset(Suite,suite_Normalize); ! suiteev_ItemHighlight(self,item); ! } ! break; ! case view_LeftUp: ! case view_LeftMovement: ! if(LastHit != item) { ! suite_Reset(Suite,suite_Normalize); ! suiteev_ItemHighlight(self,item); ! } ! break; ! case view_RightUp: break; ! case view_RightMovement: ! if(LastHit != item) { ! if(Highlighted(item)) ! suiteev_ItemNormalize(self,item); ! else { ! suite_Reset(Suite,suite_Normalize); ! suiteev_ItemHighlight(self,item); ! } ! } ! break; ! case view_RightDown: ! if(Highlighted(item)) suiteev_ItemNormalize(self,item); ! else { ! suite_Reset(Suite,suite_Normalize); ! suiteev_ItemHighlight(self,item); ! } ! break; ! } ! OUT(suiteev_HandleExclusiveHit); } void suiteev_HighlightFirstToLast( self, first, last ) ! register struct suiteev *self; ! register struct suite_item *first; ! register struct suite_item *last; { ! register struct suite_item *item = NULL; ! boolean lastFound = FALSE, Stop = FALSE; ! register int i = 0; ! IN(suiteev_HighlightFirstToLast); ! if( !Items || !ITEM(0)) return; ! while(item = ITEM(i++)) { ! if(first == item) break; ! if(Exposed(item) && Active(item) && Highlighted(item)) ! suiteev_ItemNormalize(self,item); ! if((last == item) && (lastFound = TRUE)) break; } ! i = vector_Subscript(Items,first); ! if(lastFound) { ! while((item = ITEM(i--)) && !Stop) { ! if(item == last) Stop = TRUE; ! if(Exposed(item) && Active(item) && Normalized(item)) ! suiteev_ItemHighlight(self,item); ! } ! i = vector_Subscript(Items,first) + 1; } ! else ! while((item = ITEM(i++)) && !Stop) { ! if(item == last) Stop = TRUE; ! if(Active(item) && Exposed(item) && Normalized(item)) ! suiteev_ItemHighlight(self,item); ! } ! while(item = ITEM(i++)) ! if(Active(item) && Highlighted(item) && Exposed(item)) ! suiteev_ItemNormalize(self,item); ! OUT(suiteev_HighlightFirstToLast); } void suiteev_HandleInclusiveHit( self, item, action, x, y, numberOfClicks ) ! register struct suiteev *self; ! register struct suite_item *item; ! register enum view_MouseAction action; ! register long x, y, numberOfClicks; { ! ! IN(suiteev_HandleInclusiveHit); ! switch(action) { ! case view_LeftMovement: ! if(LastHit != item) ! suiteev_HighlightFirstToLast(self,FirstHit,item); ! break; ! case view_LeftDown: ! suite_Reset(Suite,suite_Normalize); ! if(Normalized(item)) ! suiteev_ItemHighlight(self,item); ! FirstHit = item; ! break; ! case view_RightUp: ! case view_LeftUp: ! FirstHit = NULL; ! break; ! case view_RightMovement: ! if(LastHit != item) ! suiteev_ItemToggle(self,item); ! break; ! case view_RightDown: ! FirstHit = item; ! suiteev_ItemToggle(self,item); ! break; ! } ! OUT(suiteev_HandleInclusiveHit); } void suiteev_HandleToggleHit( self, item, action, x, y, numberOfClicks ) ! register struct suiteev *self; ! register struct suite_item *item; ! register enum view_MouseAction action; ! register long x, y, numberOfClicks; { ! ! IN(suiteev_HandleToggleHit); ! if((action == view_LeftDown) || (action == view_RightDown)) ! suiteev_ItemToggle(self,item); ! OUT(suiteev_HandleToggleHit); } struct view * suiteev__Hit( self, action, x, y, numClicks ) ! register struct suiteev *self; ! register enum view_MouseAction action; ! register long x, y, numClicks; { ! register struct suite_item *item = NULL; ! struct rectangle r; ! register struct view *ret = NULL; ! IN(suiteev_Hit); ! suiteev_GetVisualBounds(self,&r); ! if(WithinRect(x,y,&r)) { ! if(item = suiteev_WhichItem(self,x,y)) { ! CurrentItem = item; ! switch(SelectionMode) { ! case suite_Toggle: ! suiteev_HandleToggleHit(self,item,action,x,y,numClicks); ! break; ! case suite_Exclusive: ! suiteev_HandleExclusiveHit(self,item,action,x,y,numClicks); ! break; ! case suite_Inclusive: ! suiteev_HandleInclusiveHit(self,item,action,x,y,numClicks); ! break; ! } ! if(HitHandler && !item->hithandler) ! HitHandler(ClientAnchor,Suite,item,suite_ItemObject, ! action,x,y,numClicks); ! if(LastHit != item) LastHit = item; ! if(action != view_LeftUp && action != view_RightUp) { ! if(CVIF && (CVIF != item->viewobject)) CVIF = NULL; ! if(item->viewobject) CVIF = item->viewobject; ! } ! ret = suiteev_ItemHit(self,item,action,x,y,numClicks); } ! else if(HitHandler) ! HitHandler(ClientAnchor,Suite,item,suite_NoObject, ! action,x,y,numClicks); } ! OUT(suiteev_Hit); ! return(ret); } static ItemFullUpdate( self, item, type, left, top, width, height ) ! register struct suiteev *self; ! register struct suite_item *item; ! register enum view_UpdateType type; ! register long left, top, width, height; { ! struct rectangle *r = NULL; ! IN(ItemFullUpdate); ! if(!ItemCursor && !item->cursor && item->cursorbyte) { ! DEBUG(Cursor); ! item->cursor = cursor_Create(self); ! if(item->cursor && item_CursorFont && item_CursorByte) ! cursor_SetGlyph(item->cursor,item_CursorFont,item_CursorByte); ! else if(item_CursorByte) cursor_SetStandard(item->cursor,item_CursorByte); ! else cursor_SetStandard(item->cursor,Cursor_Octagon); ! } ! if(!item->captionfont) ! item->captionfont = fontdesc_Create(item_CaptionFontName, item_CaptionFontType,item_RealCaptionFontSize); ! if(!item->titlefont) ! item->titlefont = fontdesc_Create(item_TitleFontName, item_TitleFontType,RealItemTitleFontSize); ! if(Active(item)) { DEBUG(Active); ! if(item_AccessType & suite_ReadWrite) { DEBUG(ReadWrite); ! if(!item->dataobject) suiteev_SetItemToReadWrite(self,item); ! if(!(item_BorderStyle & suite_Invisible)) ! suiteev_DrawItemBorder(self,item); ! if( item->title ) suiteev_ItemDrawTitle(self,item,NOFORCEDMODE); ! r = rectangle_Duplicate(&InsetRect); ! DrawRect(self,r); ! DecrementRect(r,1); ! suitecv_InsertView((struct suitecv*) item->viewobject,self,r); ! suitecv_FullUpdate((struct suitecv*) item->viewobject,type,0,0, ! r->width,r->height); } ! else if( item_DataObjectName ) { DEBUGst(DataObjectName,item_DataObjectName); ! if(!item->dataobject) { DEBUG(Build DataObject); ! item->dataobject = ! (struct dataobject*)class_NewObject(item_DataObjectName); ! if(item_DataObjectHandler) { DEBUG(DataHandler); ! item_DataObjectHandler(ClientAnchor,Suite,item); ! } ! } ! if(!item_ViewObjectName) { DEBUG(No ViewObjectName); ! if(!item->viewobjectname) ! AllocNameSpace(&ItemViewObjectName, dataobject_ViewName(item->dataobject)); ! } ! if(!item->viewobject) { DEBUG(Build ViewObject); ! item->viewobject = (struct view*)class_NewObject(item_ViewObjectName); ! if(item_ViewObjectHandler) { DEBUG(ViewHandler); ! item_ViewObjectHandler(ClientAnchor,Suite,item); ! } ! } ! if(!(item_BorderStyle & suite_Invisible)) ! suiteev_DrawItemBorder(self,item); ! view_InsertView(item->viewobject,self,&InsetRect); ! view_FullUpdate(item->viewobject,type,0,0,InsetWidth,InsetHeight); } ! else if(Normalized(item)) suiteev_ItemNormalize(self,item); ! else if(Highlighted(item)) suiteev_ItemHighlight(self,item); } ! else if(ItemPassiveStyle & suite_Pale) suiteev_ItemShade(self,item); ! if(item->cursor || ItemCursorByte) ! suiteev_PostCursor(self,&Bounds,item_Cursor); ! OUT(ItemFullUpdate); } void suiteev__ItemUpdate( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemUpdate); ! if(item->viewobject && item->dataobject) ! view_Update(item->viewobject); ! else { ! suiteev_ItemClear(self,item); ! ItemFullUpdate(self,item,view_FullRedraw,0,0,0,0); ! } ! OUT(suiteev_ItemUpdate); } struct view * suiteev__ItemHit( self, item, action, x, y, numClicks ) ! register struct suiteev *self; ! register struct suite_item *item; ! register enum view_MouseAction action; ! register long x, y, numClicks; { ! struct view *retval = (struct view*)self; ! IN(suiteev_ItemHit); ! if(item && Active(item)) { ! if(!CVIF || (item->viewobject && (item->viewobject == CVIF))) { ! if(item_AccessType & suite_ReadWrite) { ! if(WithinRect(x,y,&InsetRect)) { ! return((struct view*)suitecv_Hit((struct suitecv*)item->viewobject, ! action,x - InsetLeft,y - InsetTop,numClicks)); ! } ! else ! return((struct view*)suitecv_Hit((struct suitecv*)item->viewobject, action,0,0,numClicks)); ! } ! else if(item->viewobject) ! retval = view_Hit(item->viewobject,action,x - InsetLeft, y - InsetTop,numClicks); ! if(item->hithandler) ! item->hithandler(ClientAnchor,Suite,item,suite_ItemObject, ! action,x,y,numClicks); ! } } ! OUT(suiteev_ItemHit); ! return((struct view*)retval); } static void CenterBiggestCircleInRect( self, rect ) ! register struct suiteev *self; ! register struct rectangle *rect; { ! long rad = MIN(rect->width,rect->height)/2; ! long centerX = rect->left + rect->width/2, centerY = rect->top + rect->height/2; ! rectangle_SetRectSize(rect,centerX - rad,centerY - rad,2 * rad,2 * rad); } void suiteev__ItemClear( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! struct rectangle r; ! IN(suiteev_ItemClear); ! rectangle_SetRectSize(&r,Left,Top,Width,Height); ! SetTransferMode(self,graphic_WHITE); ! suiteev_FillRect(self,&r,suiteev_WhitePattern(self)); ! OUT(suiteev_ItemClear); } void suiteev__ItemBlackOut( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! struct rectangle *r; ! IN(suiteev_ItemBlackOut); ! r = rectangle_Duplicate(&Bounds); ! DrawRect(self,r); ! rectangle_SetRectSize(r,Left + 1,Top + 1,Width - 2,Height - 2); ! DecrementRect(r,item_BorderSize); ! SetTransferMode(self,graphic_BLACK); ! suiteev_FillRect(self,r,suiteev_BlackPattern(self)); ! OUT(suiteev_ItemBlackOut); } void suiteev__ItemHighlightReverseVideo( self, item, border ) ! register struct suiteev *self; ! register struct suite_item *item; ! boolean border; { ! struct rectangle *rect = rectangle_Duplicate(&Bounds); ! IN(suiteev_ItemHighlightReverseVideo); ! if(item_BorderStyle & suite_Roundangle) { ! suiteev_ItemClear(self,item); ! SetTransferMode(self,graphic_BLACK); ! suiteev_FillRRectSize(self,Left,Top,Width,Height,10,10, suiteev_BlackPattern(self)); ! } ! else if(item_BorderStyle & suite_Rectangle) ! suiteev_ItemBlackOut(self,item); ! else if(item_BorderStyle & suite_Circle) { ! CenterBiggestCircleInRect(self,rect); ! suiteev_ItemClear(self,item); ! SetTransferMode(self,graphic_BLACK); ! suiteev_FillOvalSize(self,rect->left,rect->top, rect->width,rect->height,suiteev_BlackPattern(self)); ! } ! else if(item_BorderStyle & suite_Oval) { ! suiteev_ItemClear(self,item); ! SetTransferMode(self,graphic_BLACK); ! suiteev_FillOvalSize(self,Left,Top,Width,Height, suiteev_BlackPattern(self)); ! } ! OUT(suiteev_ItemHighlightReverseVideo); } void suiteev__ItemHighlightBorder( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemHighlightBorder); ! suiteev_DrawItemBorder(self,item); ! OUT(suiteev_ItemHighlightBorder); } void suiteev__ItemHighlightCaptionBoldItalic( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemHighlightCaptionBoldItalic); ! item->captionfonttype = fontdesc_Bold | fontdesc_Italic; ! item->captionfont = NULL; ! OUT(suiteev_ItemHighlightCaptionBoldItalic); } void suiteev__ItemHighlightCaptionBold( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemHighlightCaptionBold); ! item->captionfonttype = fontdesc_Bold; ! item->captionfont = NULL; ! OUT(suiteev_ItemHighlightCaptionBold); } void suiteev__ItemHighlightCaptionItalic( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemHighlightCaptionItalic); ! item->captionfonttype = fontdesc_Italic; ! item->captionfont = NULL; ! OUT(suiteev_ItemHighlightCaptionItalic); } void suiteev__ItemNormalize( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemNormalize); ! suiteev_ItemClear(self,item); ! if(!(item_BorderStyle & (suite_Invisible | suite_None))) ! suiteev_DrawItemBorder(self,item); ! item->mode = ((item_Active | item_Normalized) & ~item_Highlighted); ! if(item_HighlightStyle & (suite_Italic | suite_Bold)) { ! item->captionfonttype = fontdesc_Plain; ! item->captionfont = NULL; ! } ! if(item->title) suiteev_ItemDrawTitle(self,item,NOFORCEDMODE); ! if(item->viewobject) ! view_FullUpdate(item->viewobject,view_FullRedraw,0,0,Width,Height); ! else if(item_Caption) suiteev_ItemDrawCaption(self,item,NOFORCEDMODE); ! if(item_AccessType & suite_ReadWrite) DrawRect(self,&InsetRect); ! OUT(suiteev_ItemNormalize); } #define BorderPlusOne (ItemBorderSize+1) --- 595,1604 ---- static void AttemptSymmetry( self, numItems, rows, columns ) ! register struct suiteev *self; ! register long numItems, *rows, *columns; { ! IN(AttemptSymmetry); ! if((VScroll && HScroll) || !Scroll) { ! *rows = numItems / *columns; ! while(*rows > 0 && ((*columns / *rows) > 1)) { ! --(*columns); ! *rows = (numItems / *columns); } ! if((*rows < 1) || (numItems % *columns)) (*rows)++; ! } ! OUT(AttemptSymmetry); } static void SetBreakPoint( self, item, end ) ! register struct suiteev *self; ! register struct suite_item *item; ! register char *end; { ! vector_AddItem(Breaks(item),(long)(end - item_Caption)); } static boolean DoesItFit( self, item, head, tail, width ) ! struct suiteev *self; ! struct suite_item *item; ! char *head; ! char *tail; ! long width; { ! char save = *tail; ! long XWidth = 0, YWidth = 0; ! *tail = '\0'; ! fontdesc_StringBoundingBox(item_CaptionFont,suiteev_GetDrawable(self), ! head,&XWidth,&YWidth); ! *tail = save; /*replace potential break*/ ! return((XWidth < width) ? TRUE : FALSE); } static char * WalkBackwardToPunctuation( head, tail ) ! register char *head; ! register char *tail; { ! if(tail && (*tail != ' ') && (*(tail - 1) == ' ')) tail--; ! while((tail > head) && (*tail == ' ')) tail--; ! while(tail > head) { ! if(*tail == '.' || *tail == '-' || *tail == ';' || *tail == ':') ! break; ! else tail--; ! } ! if(*tail == ' ') tail++; ! return(tail); } static char * WalkBackwardBlackSpace( self, item, head, tail, width ) ! register struct suiteev *self; ! register struct suite_item *item; ! register char *head; ! register char *tail; ! register long width; { ! char *saved_tail = tail; ! if((*tail != ' ') && (*(tail - 1) == ' ')) (tail)--; ! while((tail > head) && (*tail == ' ')) (tail)--; ! while((tail > head) && (*tail != ' ')) (tail)--; ! if(*tail == ' ') (tail)++; ! if(tail == head) { ! tail = saved_tail; ! while((tail > head) && (tail = WalkBackwardToPunctuation(head,tail))) ! if(DoesItFit(self,item,head,tail,width)) break; ! else tail--; ! } ! if(tail == head) { ! tail = saved_tail-1; ! while(tail > head) { ! if(DoesItFit(self,item,head,tail,width)) break; ! else tail--; } ! if(tail == head) tail = head + 1; ! } ! return(tail); } void suiteev__ShrinkWrap( self, width, height ) ! struct suiteev *self; ! long width, height; { ! boolean end = FALSE, ResetWidthForOffset = TRUE; ! register int indx = 0, i = 0, numLines = 0; ! register struct suite_item *item = NULL; ! long saved_width = 0; ! register char *head = NULL, *nl = NULL, *t = NULL; ! long carriedHeight = YGutterSize + ItemBorderSize; ! IN(suiteev_ShrinkWrap); ! saved_width = width; ! if(Items && ITEM(0)) { ! indx = vector_Subscript(Items,FirstVisible); ! while((indx < vector_Count(Items)) && (item = ITEM(indx)) && (carriedHeight < height)) { ! if(width>(3*CaptionMWidth)) ResetWidthForOffset = FALSE; ! else ResetWidthForOffset = TRUE; ! width = saved_width; ! if(Exposed(item) && item_Caption) { ! BreakCount(item) = 0; ! numLines = suiteev_LineCount(self,item_Caption); ! head = item_Caption; ! for(i = 0 ; i < numLines ; i++) { ! end = FALSE; ! while(!end) { ! if(nl = (char*)index(head,'\n')) ! *nl = '\0'; ! else { ! nl = head + strlen(head); ! end = TRUE; ! } ! for(t = nl;t > head;t = WalkBackwardBlackSpace(self,item,head,t,width)) ! if(DoesItFit(self,item,head,t,width)) break; ! if(!end) *nl = '\n'; ! if(t == head) t = head+2; ! if(t > head && *t != '\0') { ! if(*t == '\n') head = t + 1; ! else { ! SetBreakPoint(self,item,t-1); end = FALSE; ! head = t; ! } ! if(!ResetWidthForOffset) { ! width -= (2 * CaptionMWidth); ! ResetWidthForOffset = TRUE; ! } } ! } } + carriedHeight += (((item_CaptionFontSize+1) * (numLines+BreakCount(item))) + item_BorderSize + YGutterSize); + } + indx++; } ! } ! OUT(suiteev_ShrinkWrap); } static void PlaceItems( self, rect, rows, cols, numleftOvers, itemWidth, itemHeight ) ! register struct suiteev *self; ! struct rectangle *rect; ! long rows, cols, numleftOvers; ! long itemWidth, itemHeight; { ! register int i = 0; ! register struct suite_item *item = NULL; ! long itemIndex = 0, itemleft = 0, itemtop = 0; ! long int width = 0, height = 0, top = 0, left = 0; ! long int OrigWidth = 0, OrigHeight = 0, ! OrigTop = 0, OrigLeft = 0; ! long delta = 0; ! register long XIndex = 0, XMax = cols; ! register long YIndex = 0, YMax = rows; ! long Ax = 0, Bx = 0, Ay = 0, By = 0; ! IN(PlaceItems); ! rectangle_GetRectSize(rect,&left,&top,&width,&height); ! rectangle_GetRectSize(rect,&OrigLeft,&OrigTop,&OrigWidth,&OrigHeight ); ! if(Items && ITEM(0)) LastVisible = ITEM(vector_Count(Items) - 1); ! else return; ! if(RowMajor && (numleftOvers > 0)) rows++; ! else if(ColumnMajor && (numleftOvers > 0)) cols++; ! width -= (cols * XGutterSize); ! height -= (rows * YGutterSize); ! if(!List) { ! if(ItemFixedWidth && (delta = (width - (cols * itemWidth))) > 0) { ! left += (delta / 2); ! width -= delta; ! } ! if(ItemFixedHeight && (delta = (height - (rows * itemHeight))) > 0) { ! top += (delta / 2); ! height -= delta; ! } ! } ! if(List && VisibleColumns == 1) { ! Ax = left + XGutterSize; ! Bx = itemWidth + XGutterSize + 1; ! Ay = top + YGutterSize; ! itemtop = Ay; ! } ! else { ! Ax = left + XGutterSize; Bx = itemWidth + XGutterSize; ! Ay = top + YGutterSize; By = itemHeight + YGutterSize; ! } ! i = vector_Subscript(Items,FirstVisible); ! while(item = ITEM(i++)) ! if(Exposed(item)) { ! itemIndex++; ! if(List && VisibleColumns == 1) { ! itemHeight = ((item_RealCaptionFontSize+2) * (suiteev_LineCount(self,item_Caption) + BreakCount(item))) + TwiceBorderSize; ! By = itemHeight + YGutterSize; ! itemleft = Ax + XIndex * Bx; ! item_SetUpperLeft(item,itemleft,itemtop); ! itemtop += By; ! } ! else { ! itemleft = Ax + XIndex * Bx; ! itemtop = Ay + YIndex * By; ! item_SetUpperLeft(item,itemleft,itemtop); ! } ! item_SetDimensions(item,itemWidth,itemHeight); ! rectangle_SetRectSize(&InsetRect,itemleft,itemtop, ! itemWidth,itemHeight); ! if(RowMajor) { ! if(++XIndex == XMax) { ! XIndex = 0; ! YIndex++; } ! } ! else { ! if(++YIndex == YMax) { ! YIndex = 0; ! XIndex++; } + } + if((itemIndex == NumVisible) && (LastVisible = item)) break; + if( numleftOvers && + ((RowMajor && (YIndex == (YMax - 1))) || + (ColumnMajor && (XIndex == (XMax - 1))))) break; } ! if(numleftOvers) { ! left = OrigLeft;top = OrigTop; ! width = OrigWidth;height = OrigHeight; ! if(Balanced) { ! if(RowMajor) { ! width -= ((numleftOvers+1) * XGutterSize); ! left += (abs(width-(numleftOvers*itemWidth))/2); Ax = left + XGutterSize; ! } ! else if(ColumnMajor) { ! height -= ((numleftOvers+1) * YGutterSize); ! top += (abs(height-(numleftOvers*itemHeight))/2); Ay = top + YGutterSize; ! } } ! if(RowMajor) XIndex = 0; ! else YIndex = 0; while(item = ITEM(i++)) ! if(Exposed(item)) { ! itemIndex++; ! item_SetDimensions(item,itemWidth,List ? ((item_RealCaptionFontSize + 2) * (suiteev_LineCount(self,item_Caption) + BreakCount(item))) : itemHeight); ! itemleft = Ax + XIndex * Bx; ! itemtop = Ay + YIndex * By; ! item_SetUpperLeft(item,itemleft,itemtop); ! rectangle_SetRectSize(&InsetRect,itemleft,itemtop,itemWidth,itemHeight); ! if(RowMajor) XIndex++; ! else YIndex++; ! if((itemIndex == NumVisible) && (LastVisible = item)) break; ! } ! } ! NumVisible = itemIndex; ! OUT(PlaceItems); } static void DetermineVisibleListItems( self, height ) ! struct suiteev *self; ! long height; { ! register int i = 0, count = 0; ! struct suite_item *item = NULL; ! int sum = YGutterSize; ! IN(DetermineVisibleListItems); ! i = vector_Subscript(Items,FirstVisible); ! while(item = ITEM(i++)) { ! count++; ! sum += (TwiceBorderSize + YGutterSize + ((suiteev_LineCount(self,item_Caption) + BreakCount(item)) * (item_RealCaptionFontSize + 2))); ! if(sum > height) { ! NumVisible = count; ! return; } ! } ! NumVisible = count; ! OUT(DetermineVisibleListItems); } void suiteev__Arrange( self, rect ) ! register struct suiteev *self; ! register struct rectangle *rect; { ! long itemWidth = 0, itemHeight = 0, ! minHeight = 0, minWidth = 0, ! width = 0, height = 0, top = 0, left = 0; ! long numleftOvers = 0, maxCols = 0; ! long maxRows = 0, numItems = 0; ! long XGutterOffset = 0, YGutterOffset = 0; ! IN(suiteev_Arrange); ! if(!Items || ((numItems = suiteev_NumberExposed(self)) <= 0) || ! (List && (rect->width < (3 * CaptionMWidth))) || ! (List && (rect->height < (RealCaptionFontSize + TwiceBorderSize)))) { ! FirstVisible = LastVisible = NULL; ! NumVisible = 0; ! return; ! } ! else if(!FirstVisible) FirstVisible = ITEM(0); ! suiteev_MaxStringSize(self,&itemWidth,&itemHeight); ! rectangle_GetRectSize(rect,&left,&top,&width,&height); ! XGutterOffset = ((XGutterSize > 0) ? (XGutterSize + 1) : 0); ! YGutterOffset = ((YGutterSize > 0) ? (YGutterSize + 1) : 0); ! if(ItemFixedHeight) minHeight = ItemFixedHeight + YGutterOffset; ! else minHeight = itemHeight + TwiceBorderSize + 2 + YGutterOffset; ! if(ItemFixedWidth) minWidth = ItemFixedWidth + XGutterOffset; ! else minWidth = itemWidth + TwiceBorderSize + (2 * CaptionMWidth) + XGutterOffset; ! if(List && (minWidth > width)) { ! if(width > (TwiceBorderSize+(2*CaptionMWidth)+XGutterOffset)) { ! suiteev_ShrinkWrap(self, width - TwiceBorderSize - ! (2*CaptionMWidth) - (2*XGutterOffset), height); ! suiteev_MaxStringSize(self,&itemWidth,&itemHeight); ! minHeight = itemHeight + TwiceBorderSize + 2; ! minWidth = width - TwiceBorderSize - (2*XGutterOffset); ! } ! } ! if(!Scroll) { ! NumVisible = numItems; ! FirstVisible = ITEM(0); ! } ! if(Matrix) { DEBUG(Matrix); ! maxCols = ((width/minWidth > 1) ? (width/minWidth) : 1); ! maxRows = ((height/minHeight > 1) ? (height/minHeight) : 1); ! if(RowMajor && (maxCols > numItems)) { ! maxCols = numItems; ! maxRows = 1; } ! else if(ColumnMajor && (maxRows > numItems)) { ! maxRows = numItems; ! maxCols = 1; } ! AttemptSymmetry(self,numItems,&maxRows,&maxCols); ! width -= ((maxCols+1) * XGutterSize); ! height -= ((maxRows+1) * YGutterSize); ! if(List) { DEBUG(List); ! ItemWidth = itemWidth = minWidth; ! ItemHeight = itemHeight = minHeight; } ! else { DEBUG(Not List); ! if(ItemFixedWidth) ItemWidth = itemWidth = ItemFixedWidth; ! else ItemWidth = itemWidth = width/maxCols; ! if(ItemFixedHeight) ItemHeight = itemHeight = ItemFixedHeight; ! else ItemHeight = itemHeight = height/maxRows; } ! VisibleColumns = Columns = maxCols; ! VisibleRows = Rows = maxRows; ! if( numItems <= ( VisibleRows * VisibleColumns ) ) ! NumVisible = numItems; ! else NumVisible = VisibleRows * VisibleColumns; ! if(RowMajor) numleftOvers = NumVisible % maxCols; ! else if(ColumnMajor) numleftOvers = NumVisible % maxRows; ! if(List && (maxCols == 1)) { ! DetermineVisibleListItems(self,rect->height); ! VisibleRows = Rows = maxRows = NumVisible; ! numleftOvers = 0; } + } + else if(SingleColumn) { + DEBUG(SingleColumn); + if(ItemFixedHeight) { + DEBUG(FixedHeight); + itemHeight = ItemFixedHeight; + if(Scroll) NumVisible = height/minHeight; + else NumVisible = numItems; + } else { ! if(Scroll) { ! if((NumVisible = height/minHeight) == 0) ! NumVisible = 1; ! } ! else NumVisible = numItems; ! height -= ((NumVisible+1) * YGutterSize ); ! itemHeight = height/NumVisible; } ! if(ItemFixedWidth) ! itemWidth = ItemFixedWidth; ! else ! itemWidth = width - (2 * XGutterSize); ! ItemHeight = itemHeight; ! ItemWidth = itemWidth; ! if(Scroll) { ! if(VScroll) { ! Rows = numItems; ! maxRows = VisibleRows = NumVisible; ! } ! } ! else NumVisible = Rows = VisibleRows = maxRows = numItems; ! Columns = VisibleColumns = maxCols = 1; ! if(List) { ! DetermineVisibleListItems(self,rect->height); ! VisibleRows = Rows = maxRows = NumVisible; ! numleftOvers = 0; ! } ! } ! else { ! if(ItemFixedWidth) { ! minWidth = itemWidth = ItemFixedWidth; ! if(Scroll) NumVisible = width/minWidth; ! else NumVisible = numItems; ! } ! else { ! if(Scroll) ! if((NumVisible = width/minWidth) == 0) ! NumVisible = 1; ! else NumVisible = numItems; ! width -= ((NumVisible+1) * XGutterSize); ! itemWidth = width/NumVisible; ! } ! if(ItemFixedHeight) ! itemHeight = ItemFixedHeight; ! else ! itemHeight = height - (2 * YGutterSize); ! ItemHeight = itemHeight; ! ItemWidth = itemWidth; ! if(Scroll) { ! if(HScroll) { ! Columns = numItems; ! maxCols = VisibleColumns = NumVisible; ! } ! } ! else NumVisible = Columns = VisibleColumns = maxCols = numItems; ! Rows = VisibleRows = maxRows = 1; ! } ! PlaceItems(self,rect,maxRows,maxCols,numleftOvers,itemWidth,itemHeight); ! OUT(suiteev_Arrange); } void suiteev__DrawItems( self, rect ) ! register struct suiteev *self; ! register struct rectangle *rect; { ! register int i = 0; ! register struct suite_item *item = NULL; ! IN(suiteev_DrawItems); ! if(!Items || !ITEM(0)) return; ! if(!FirstVisible) FirstVisible = ITEM(0); ! i = vector_Subscript(Items,FirstVisible); ! while(item = ITEM(i++)) ! if(Exposed(item)) { ! ItemFullUpdate(self,item,view_FullRedraw,0,0,0,0); ! if(item == LastVisible) break; ! } ! OUT(suiteev_DrawItems); } static void EraseItems( self ) ! register struct suiteev *self; { ! register int i = 0; ! register struct suite_item *item = NULL; ! IN(EraseItems); ! if(!Items || !ITEM(0) || !FirstVisible) return; ! i = vector_Subscript(Items,FirstVisible); ! while(item = ITEM(i++)) ! if(Exposed(item)) { ! suiteev_ItemClear(self,item); ! if(item == LastVisible) break; ! } ! SetTransferMode(self,graphic_BLACK); ! OUT(EraseItems); } void suiteev__Update( self ) ! register struct suiteev *self; { ! struct rectangle r; ! IN(suiteev_Update); ! suiteev_GetVisualBounds(self,&r); ! if(RowLine || ColumnLine) EraseItems(self); ! else suiteev_Clear(self); ! if(FirstVisible != NewFirstVisible) ! FirstVisible = NewFirstVisible; ! if(List) suite_Apply(Suite,ResetItemBreaks,Suite,0); ! suiteev_Arrange(self,&r); ! suiteev_DrawItems(self,&r); ! DrawGutterLines(self); ! OUT(suiteev_Update); } long suiteev__NumberItems( self ) ! register struct suiteev *self; { ! if(Items && ITEM(0)) return(vector_Count(Items)); ! else return(-1); } long suiteev__NumberVisible( self ) ! register struct suiteev *self; { ! register long i = 0; ! register struct suite_item *item = FirstVisible; ! while(item && ++i && (item != LastVisible)); ! return(i); } long suiteev__NumberExposed( self ) ! register struct suiteev *self; { ! register long i = 0, index = 0; ! register struct suite_item *item = NULL; ! if(Items && ITEM(0)) ! while(item = ITEM(index++)) ! if(Exposed(item)) i++; ! return(i); } void suiteev__Clear( self ) ! register struct suiteev *self; { ! struct rectangle r; ! suiteev_GetVisualBounds(self,&r); ! SetTransferMode(self,graphic_WHITE); ! suiteev_FillRect(self,&r,suiteev_WhitePattern(self)); ! SetTransferMode(self,graphic_BLACK); } struct suite_item * suiteev__WhichItem( self, x, y ) ! register struct suiteev *self; ! register long x, y; { ! register int i = 0; ! register struct suite_item *item = NULL; ! IN(suiteev_WhichItem); ! if(Items && ITEM(0)) { ! if(!FirstVisible) FirstVisible = ITEM(0); ! i = vector_Subscript(Items,FirstVisible); ! while(item = ITEM(i++)) ! if(Exposed(item) && WithinRect(x,y,&Bounds)) ! return(item); ! else if(item == LastVisible) { ! if(List) return(item); ! else return(NULL); ! } ! if(List && !item && LastVisible) ! return(LastVisible); ! } ! return(NULL); } void suiteev_HandleExclusiveHit( self, item, action, x, y, numberOfClicks ) ! register struct suiteev *self; ! register struct suite_item *item; ! enum view_MouseAction action; ! long x, y; ! long numberOfClicks; { ! IN(suiteev_HandleExclusiveHit); ! switch(action) { ! case view_LeftDown: ! if(Highlighted(item)) break; ! else { ! suite_Reset(Suite,suite_Normalize); ! suiteev_ItemHighlight(self,item); ! } ! break; ! case view_LeftUp: ! case view_LeftMovement: ! if(LastHit != item) { ! suite_Reset(Suite,suite_Normalize); ! suiteev_ItemHighlight(self,item); ! } ! break; ! case view_RightUp: break; ! case view_RightMovement: ! if(LastHit != item) { ! if(Highlighted(item)) ! suiteev_ItemNormalize(self,item); ! else { ! suite_Reset(Suite,suite_Normalize); ! suiteev_ItemHighlight(self,item); ! } ! } ! break; ! case view_RightDown: ! if(Highlighted(item)) suiteev_ItemNormalize(self,item); ! else { ! suite_Reset(Suite,suite_Normalize); ! suiteev_ItemHighlight(self,item); ! } ! break; ! } ! OUT(suiteev_HandleExclusiveHit); } void suiteev_HighlightFirstToLast( self, first, last ) ! register struct suiteev *self; ! register struct suite_item *first; ! register struct suite_item *last; { ! register struct suite_item *item = NULL; ! boolean lastFound = FALSE, Stop = FALSE; ! register int i = 0; ! IN(suiteev_HighlightFirstToLast); ! if( !Items || !ITEM(0)) return; ! while(item = ITEM(i++)) { ! if(first == item) break; ! if(Exposed(item) && Active(item) && Highlighted(item)) ! suiteev_ItemNormalize(self,item); ! if((last == item) && (lastFound = TRUE)) break; ! } ! i = vector_Subscript(Items,first); ! if(lastFound) { ! while((item = ITEM(i--)) && !Stop) { ! if(item == last) Stop = TRUE; ! if(Exposed(item) && Active(item) && Normalized(item)) ! suiteev_ItemHighlight(self,item); } ! i = vector_Subscript(Items,first) + 1; ! } ! else ! while((item = ITEM(i++)) && !Stop) { ! if(item == last) Stop = TRUE; ! if(Active(item) && Exposed(item) && Normalized(item)) ! suiteev_ItemHighlight(self,item); } ! while(item = ITEM(i++)) ! if(Active(item) && Highlighted(item) && Exposed(item)) ! suiteev_ItemNormalize(self,item); ! OUT(suiteev_HighlightFirstToLast); } void suiteev_HandleInclusiveHit( self, item, action, x, y, numberOfClicks ) ! register struct suiteev *self; ! register struct suite_item *item; ! register enum view_MouseAction action; ! register long x, y, numberOfClicks; { ! IN(suiteev_HandleInclusiveHit); ! switch(action) { ! case view_LeftMovement: ! if(LastHit != item) ! suiteev_HighlightFirstToLast(self,FirstHit,item); ! break; ! case view_LeftDown: ! suite_Reset(Suite,suite_Normalize); ! if(Normalized(item)) ! suiteev_ItemHighlight(self,item); ! FirstHit = item; ! break; ! case view_RightUp: ! case view_LeftUp: ! FirstHit = NULL; ! break; ! case view_RightMovement: ! if(LastHit != item) ! suiteev_ItemToggle(self,item); ! break; ! case view_RightDown: ! FirstHit = item; ! suiteev_ItemToggle(self,item); ! break; ! } ! OUT(suiteev_HandleInclusiveHit); } void suiteev_HandleToggleHit( self, item, action, x, y, numberOfClicks ) ! register struct suiteev *self; ! register struct suite_item *item; ! register enum view_MouseAction action; ! register long x, y, numberOfClicks; { ! IN(suiteev_HandleToggleHit); ! if((action == view_LeftDown) || (action == view_RightDown)) ! suiteev_ItemToggle(self,item); ! OUT(suiteev_HandleToggleHit); } struct view * suiteev__Hit( self, action, x, y, numClicks ) ! register struct suiteev *self; ! register enum view_MouseAction action; ! register long x, y, numClicks; { ! register struct suite_item *item = NULL; ! struct rectangle r; ! register struct view *ret = NULL; ! IN(suiteev_Hit); ! suiteev_GetVisualBounds(self,&r); ! if(WithinRect(x,y,&r)) { ! if((item = suiteev_WhichItem(self,x,y)) && Active(item)) { ! CurrentItem = item; ! switch(SelectionMode) { ! case suite_Toggle: ! suiteev_HandleToggleHit(self,item,action,x,y,numClicks); ! break; ! case suite_Exclusive: ! suiteev_HandleExclusiveHit(self,item,action,x,y,numClicks); ! break; ! case suite_Inclusive: ! suiteev_HandleInclusiveHit(self,item,action,x,y,numClicks); ! break; ! } ! if(HitHandler && !item->hithandler) ! HitHandler(ClientAnchor,Suite,item,suite_ItemObject, ! action,x,y,numClicks); ! if(LastHit != item) LastHit = item; ! if(action != view_LeftUp && action != view_RightUp) { ! if(CVIF && (CVIF != item->viewobject)) CVIF = NULL; ! if(item->viewobject) CVIF = item->viewobject; } ! ret = suiteev_ItemHit(self,item,action,x,y,numClicks); } ! else if(HitHandler && (!item || Active(item))) ! HitHandler(ClientAnchor,Suite,item,suite_NoObject, ! action,x,y,numClicks); ! } ! OUT(suiteev_Hit); ! return(ret); } static ItemFullUpdate( self, item, type, left, top, width, height ) ! register struct suiteev *self; ! register struct suite_item *item; ! register enum view_UpdateType type; ! register long left, top, width, height; { ! struct rectangle *r = NULL; ! IN(ItemFullUpdate); ! if(!ItemCursor && !item->cursor && item->cursorbyte) { ! DEBUG(Cursor); ! item->cursor = cursor_Create(self); ! if(item->cursor && item_CursorFont && item_CursorByte) ! cursor_SetGlyph(item->cursor,item_CursorFont,item_CursorByte); ! else if(item_CursorByte) cursor_SetStandard(item->cursor,item_CursorByte); ! else cursor_SetStandard(item->cursor,Cursor_Octagon); ! } ! if(!item->captionfont) ! item->captionfont = fontdesc_Create(item_CaptionFontName, item_CaptionFontType,item_RealCaptionFontSize); ! if(!item->titlefont) ! item->titlefont = fontdesc_Create(item_TitleFontName, item_TitleFontType,RealItemTitleFontSize); ! if(Active(item)) { ! DEBUG(Active); ! if(item_AccessType & suite_ReadWrite) { ! if(!item->dataobject) suiteev_SetItemToReadWrite(self,item); ! if(!(item_BorderStyle & suite_Invisible)) ! suiteev_DrawItemBorder(self,item); ! if( item->title ) suiteev_ItemDrawTitle(self,item,NOFORCEDMODE); ! r = rectangle_Duplicate(&InsetRect); ! DrawRect(self,r); ! DecrementRect(r,1); ! suitecv_InsertView((struct suitecv*) item->viewobject,self,r); ! suitecv_FullUpdate((struct suitecv*) item->viewobject,type,0,0, ! r->width,r->height); ! } ! else if( item->viewobject ) { ! view_InsertView(item->viewobject,self,&InsetRect); ! view_FullUpdate(item->viewobject,type,0,0,InsetWidth,InsetHeight); ! } ! else if( item_DataObjectName ) { DEBUGst(DataObjectName,item_DataObjectName); ! if(!item->dataobject) { ! DEBUG(Build DataObject); ! item->dataobject = (struct dataobject*)class_NewObject(item_DataObjectName); ! if(item_DataObjectHandler) { ! DEBUG(DataHandler); ! item_DataObjectHandler(ClientAnchor,Suite,item); } ! } ! if(!item_ViewObjectName) { DEBUG(No ViewObjectName); ! if(!item->viewobjectname) ! AllocNameSpace(&ItemViewObjectName, dataobject_ViewName(item->dataobject)); ! } ! if(!item->viewobject) { ! DEBUG(Build ViewObject); ! item->viewobject = (struct view*)class_NewObject(item_ViewObjectName); ! if(item_ViewObjectHandler) { ! DEBUG(ViewHandler); ! item_ViewObjectHandler(ClientAnchor,Suite,item); } ! } ! if(!(item_BorderStyle & suite_Invisible)) ! suiteev_DrawItemBorder(self,item); ! view_InsertView(item->viewobject,self,&InsetRect); ! view_FullUpdate(item->viewobject,type,0,0,InsetWidth,InsetHeight); } ! else if(Normalized(item)) suiteev_ItemNormalize(self,item); ! else if(Highlighted(item)) suiteev_ItemHighlight(self,item); ! } ! else if(ItemPassiveStyle & suite_Pale) suiteev_ItemShade(self,item); ! if(item->cursor || ItemCursorByte) ! suiteev_PostCursor(self,&Bounds,item_Cursor); ! OUT(ItemFullUpdate); } void suiteev__ItemUpdate( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemUpdate); ! if(item->viewobject && item->dataobject) ! view_Update(item->viewobject); ! else { ! suiteev_ItemClear(self,item); ! ItemFullUpdate(self,item,view_FullRedraw,0,0,0,0); ! } ! OUT(suiteev_ItemUpdate); } struct view * suiteev__ItemHit( self, item, action, x, y, numClicks ) ! register struct suiteev *self; ! register struct suite_item *item; ! register enum view_MouseAction action; ! register long x, y, numClicks; { ! struct view *retval = (struct view*)self; ! IN(suiteev_ItemHit); ! if(item && Active(item)) { ! if(!CVIF || (item->viewobject && (item->viewobject == CVIF))) { ! if(item_AccessType & suite_ReadWrite) { ! if(WithinRect(x,y,&InsetRect)) { ! return((struct view*)suitecv_Hit((struct suitecv*)item->viewobject, ! action,x - InsetLeft,y - InsetTop,numClicks)); ! } ! else ! return((struct view*)suitecv_Hit((struct suitecv*)item->viewobject, action,0,0,numClicks)); ! } ! else if(item->viewobject) ! retval = view_Hit(item->viewobject,action,x - InsetLeft, y - InsetTop,numClicks); ! if(item->hithandler) ! item->hithandler(ClientAnchor,Suite,item,suite_ItemObject, ! action,x,y,numClicks); } ! } ! OUT(suiteev_ItemHit); ! return((struct view*)retval); } static void CenterBiggestCircleInRect( self, rect ) ! register struct suiteev *self; ! register struct rectangle *rect; { ! long rad = MIN(rect->width,rect->height)/2; ! long centerX = rect->left + rect->width/2, centerY = rect->top + rect->height/2; ! rectangle_SetRectSize(rect,centerX - rad,centerY - rad,2 * rad,2 * rad); } void suiteev__ItemClear( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! struct rectangle r; ! IN(suiteev_ItemClear); ! rectangle_SetRectSize(&r,Left,Top,Width,Height); ! SetTransferMode(self,graphic_WHITE); ! suiteev_FillRect(self,&r,suiteev_WhitePattern(self)); ! OUT(suiteev_ItemClear); } void suiteev__ItemBlackOut( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! struct rectangle *r; ! IN(suiteev_ItemBlackOut); ! r = rectangle_Duplicate(&Bounds); ! DrawRect(self,r); ! rectangle_SetRectSize(r,Left + 1,Top + 1,Width - 2,Height - 2); ! DecrementRect(r,item_BorderSize); ! SetTransferMode(self,graphic_BLACK); ! suiteev_FillRect(self,r,suiteev_BlackPattern(self)); ! OUT(suiteev_ItemBlackOut); } void suiteev__ItemHighlightReverseVideo( self, item, border ) ! register struct suiteev *self; ! register struct suite_item *item; ! boolean border; { ! struct rectangle *rect = rectangle_Duplicate(&Bounds); ! IN(suiteev_ItemHighlightReverseVideo); ! if(item_BorderStyle & suite_Roundangle) { ! suiteev_ItemClear(self,item); ! SetTransferMode(self,graphic_BLACK); ! suiteev_FillRRectSize(self,Left,Top,Width,Height,10,10, suiteev_BlackPattern(self)); ! } ! else if(item_BorderStyle & suite_Rectangle) ! suiteev_ItemBlackOut(self,item); ! else if(item_BorderStyle & suite_Circle) { ! CenterBiggestCircleInRect(self,rect); ! suiteev_ItemClear(self,item); ! SetTransferMode(self,graphic_BLACK); ! suiteev_FillOvalSize(self,rect->left,rect->top, rect->width,rect->height,suiteev_BlackPattern(self)); ! } ! else if(item_BorderStyle & suite_Oval) { ! suiteev_ItemClear(self,item); ! SetTransferMode(self,graphic_BLACK); ! suiteev_FillOvalSize(self,Left,Top,Width,Height, suiteev_BlackPattern(self)); ! } ! OUT(suiteev_ItemHighlightReverseVideo); } void suiteev__ItemHighlightBorder( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemHighlightBorder); ! suiteev_DrawItemBorder(self,item); ! OUT(suiteev_ItemHighlightBorder); } void suiteev__ItemHighlightCaptionBoldItalic( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemHighlightCaptionBoldItalic); ! item->captionfonttype = fontdesc_Bold | fontdesc_Italic; ! item->captionfont = NULL; ! OUT(suiteev_ItemHighlightCaptionBoldItalic); } void suiteev__ItemHighlightCaptionBold( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemHighlightCaptionBold); ! item->captionfonttype = fontdesc_Bold; ! item->captionfont = NULL; ! OUT(suiteev_ItemHighlightCaptionBold); } void suiteev__ItemHighlightCaptionItalic( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemHighlightCaptionItalic); ! item->captionfonttype = fontdesc_Italic; ! item->captionfont = NULL; ! OUT(suiteev_ItemHighlightCaptionItalic); } void suiteev__ItemNormalize( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemNormalize); ! suiteev_ItemClear(self,item); ! if(!(item_BorderStyle & (suite_Invisible | suite_None))) ! suiteev_DrawItemBorder(self,item); ! item->mode = ((item_Active | item_Normalized) & ~item_Highlighted); ! if(item_HighlightStyle & (suite_Italic | suite_Bold)) { ! item->captionfonttype = fontdesc_Plain; ! item->captionfont = NULL; ! } ! if(item->title) suiteev_ItemDrawTitle(self,item,NOFORCEDMODE); ! if(item->viewobject) ! view_FullUpdate(item->viewobject,view_FullRedraw,0,0,Width,Height); ! else if(item_Caption) suiteev_ItemDrawCaption(self,item,NOFORCEDMODE); ! if(item_AccessType & suite_ReadWrite) DrawRect(self,&InsetRect); ! OUT(suiteev_ItemNormalize); } #define BorderPlusOne (ItemBorderSize+1) *************** *** 1643,2328 **** static void ItemPlaceCaption( self, item, captionwidth, captionheight, place ) ! register struct suiteev *self; ! register struct suite_item *item; ! long captionwidth; ! long captionheight; ! unsigned *place; { ! unsigned char alignment = 0; ! long l = Left + ItemBorderSize, t = Top + ItemBorderSize; ! long w = Width - (2*ItemBorderSize); ! long h = Height - (2*ItemBorderSize); ! IN(ItemPlaceCaption); ! if(item) { ! alignment = item_CaptionAlignment; ! if(captionwidth > w) captionwidth = w; ! if(captionheight > h) captionheight = h; ! rectangle_SetRectSize(&CaptionRect, ! l + ((w - captionwidth)/2), ! t + ((h - captionheight)/2), ! captionwidth,captionheight); ! if(alignment & suite_Left) CaptionRect.left = l; ! if(alignment & suite_Right) CaptionRect.left = l + w - captionwidth; ! if(alignment & suite_Top) CaptionRect.top = t; ! if(alignment & suite_Bottom) CaptionRect.top = t + h - captionheight; ! } ! *place = graphic_BETWEENTOPANDBOTTOM; ! if(alignment & suite_Middle) *place |= graphic_BETWEENTOPANDBOTTOM; ! if(alignment & suite_Center) *place |= graphic_BETWEENLEFTANDRIGHT; ! if(alignment & suite_Left) *place |= graphic_ATLEFT; ! if(alignment & suite_Right) *place |= graphic_ATRIGHT; ! OUT(ItemPlaceCaption); } void suiteev__ItemDrawCaption( self, item, forcedTransferMode ) ! register struct suiteev *self; ! register struct suite_item *item; ! short forcedTransferMode; { ! long captionwidth = 0, captionheight = 0, totalWidth = 0; ! long X = 0, Y = 0, SubStringIndex = 0; ! unsigned tMode = graphic_BLACK, placement = 0; ! unsigned alignment = item_CaptionAlignment; ! register long pos = 0, i = 0, j = 0, numLines = 0; ! char *tmp = NULL, *head = NULL, save; ! boolean WasBreakPos = FALSE, WasNewLine = FALSE; ! boolean dontDraw = FALSE; ! IN(suiteev_ItemDrawCaption); ! if(forcedTransferMode != NOFORCEDMODE) tMode = forcedTransferMode; ! item->captionfont = fontdesc_Create(item_CaptionFontName, item_CaptionFontType,item_RealCaptionFontSize); ! SetFont(self,item->captionfont); ! MaxSubStringSize(self,item,item_Caption,item_CaptionFont, &captionwidth,&captionheight,&SubStringIndex); if(List) { ! MaxListSubStringWidth(self,item,item_Caption, ! item_CaptionFont,&totalWidth); ! if(item_Title) totalWidth += TitleRect.width; ! if((totalWidth > Width) && (Width > (4 * CaptionMWidth))) { ! suiteev_Update(self); ! return; } ! } ! numLines = suiteev_LineCount(self,item_Caption) + BreakCount(item); ! captionheight = numLines * (item_RealCaptionFontSize+2); ! ItemPlaceCaption(self,item,captionwidth,captionheight,&placement); ! if(forcedTransferMode == NOFORCEDMODE) ! if((item_HighlightStyle & suite_Invert) && Highlighted(item)) ! tMode = graphic_WHITE; ! else tMode = graphic_BLACK; ! SetTransferMode(self,tMode); ! tmp = head = item_Caption; ! Y = CaptionRect.top + (item_RealCaptionFontSize/2) + 1; ! X = CaptionRect.left + CaptionRect.width/2; ! if(alignment & suite_Left) X = CaptionRect.left; ! if(alignment & suite_Right) X = CaptionRect.left + CaptionRect.width; ! for( j = 0, i = 0 ; i < numLines ; i++ ) { ! WasNewLine = WasBreakPos = FALSE; ! save = '\0'; ! while(tmp && (*tmp != '\0')) { ! if(*tmp == '\n') { ! WasNewLine = TRUE; ! break; ! } ! else if((j < BreakCount(item)) && (pos == BreakPos(item,j))) { ! WasBreakPos = TRUE; ! break; ! } ! else { ! pos++;tmp++; ! } } ! if(WasNewLine) *tmp = '\0'; ! else if(WasBreakPos) { ! save = *(tmp+1); ! *(tmp+1) = '\0'; ! } ! if(List) { ! if(i > 0) { ! if(WrapStyle & suite_LeftIndent) { ! X = Left + CaptionMWidth + (2 * CaptionMWidth); ! placement = graphic_ATLEFT | graphic_BETWEENTOPANDBOTTOM; ! } ! else if(WrapStyle & suite_LeftRight) { ! X = Left + Width - (2 * CaptionMWidth); ! placement = graphic_ATRIGHT | graphic_BETWEENTOPANDBOTTOM; ! } ! } ! else { ! X = Left + CaptionMWidth; ! placement = graphic_ATLEFT | graphic_BETWEENTOPANDBOTTOM; ! } ! if(item == FirstVisible && i < FirstVisibleSubString) ! dontDraw = TRUE; ! else dontDraw = FALSE; ! } ! if(i > 0) Y += (item_RealCaptionFontSize + 2); ! if(!List || ! (Y + (item_RealCaptionFontSize/2) + 1) < suiteev_GetVisualBottom(self)) { ! if(!dontDraw) { ! suiteev_MoveTo(self,X,Y); ! suiteev_DrawString(self,head,placement); ! } ! } ! if(WasNewLine) *tmp = '\n'; ! else if(WasBreakPos) { ! *(tmp+1) = save; ! j++; ! } ! tmp++;pos++; ! head = tmp; } ! SetTransferMode(self,graphic_BLACK); ! OUT(suiteev_ItemDrawCaption); } void ItemPlaceTitle(self,item,titlewidth,titleheight) ! struct suiteev *self; ! struct suite_item *item; ! long titlewidth, titleheight; { ! unsigned char titleplacement = item_TitlePlacement; ! boolean left = FALSE, right = FALSE, top = FALSE, bottom = FALSE; ! IN(suiteev_ItemPlaceTitle); ! if(titleplacement & suite_Left) { ! left = TRUE; ! rectangle_SetRectSize(&TitleRect, ! Left + BorderPlusOne, ! Top + BorderPlusOne, ! titlewidth + 2, ! Height - TwiceBorderPlusOne); ! rectangle_SetRectSize(&InsetRect, ! TitleRect.left + TitleRect.width + 1, ! Top + BorderPlusOne, ! Width - TitleRect.width - TwiceBorderPlusOne - 1, ! Height - TwiceBorderPlusOne); ! } ! else if (titleplacement & suite_Right) { ! right = TRUE; ! rectangle_SetRectSize(&TitleRect, ! Left + Width - (titlewidth + 2), ! Top + BorderPlusOne, ! titlewidth + 2, ! Height - TwiceBorderPlusOne); ! rectangle_SetRectSize(&InsetRect, ! Left + BorderPlusOne, ! Top + BorderPlusOne, ! Width - TitleRect.width - TwiceBorderPlusOne - 1, ! Height - TwiceBorderPlusOne); ! } ! else if(titleplacement & suite_Top) { ! top = TRUE; ! rectangle_SetRectSize(&TitleRect, ! Left + BorderPlusOne, ! Top + BorderPlusOne, ! Width - TwiceBorderPlusOne, ! titleheight + 2); ! rectangle_SetRectSize(&InsetRect, ! Left + BorderPlusOne, ! TitleRect.top + TitleRect.height + 1, ! Width - TwiceBorderPlusOne, ! Height - TitleRect.height - TwiceBorderPlusOne); ! } ! else if(titleplacement & suite_Bottom) { ! bottom = TRUE; ! rectangle_SetRectSize(&TitleRect, ! Left + BorderPlusOne, ! Top + Height - titleheight - BorderPlusOne, ! Width - TwiceBorderPlusOne, ! titleheight + 2); ! rectangle_SetRectSize(&InsetRect, ! Left + BorderPlusOne, ! Top + BorderPlusOne, ! Width - TwiceBorderPlusOne, ! Height - TitleRect.height - BorderPlusOne); ! } ! if(item_AccessType & suite_ReadWrite) { ! InsetHeight = RealItemTitleFontSize > 27 ? ! RealItemTitleFontSize : 27; ! if(Height < InsetHeight) InsetHeight = Height - 4; ! if(left || right) ! InsetTop = TitleRect.top + (TitleRect.height-InsetHeight)/2; ! else if(top) InsetTop = TitleRect.top + TitleRect.height + 2; ! else if(bottom) InsetTop = TitleRect.top + 2 + InsetHeight; ! } ! OUT(suiteev_ItemPlaceTitle); } void suiteev__ItemDrawTitle( self, item, forcedTransferMode ) ! register struct suiteev *self; ! register struct suite_item *item; ! short forcedTransferMode; { ! long x = 0, y = 0, count = 0; ! char *tmp = NULL, *head = NULL; ! unsigned tMode = 0, alignment = 0, ! placement = graphic_BETWEENTOPANDBOTTOM; ! long titlewidth = 0, titleheight = 0; ! long titleLines = 0; ! IN(suiteev_ItemDrawTitle); ! tMode = (forcedTransferMode == NOFORCEDMODE) ? ! graphic_BLACK : forcedTransferMode; ! if(!item->titlefont) item->titlefont = fontdesc_Create(item_TitleFontName, ! item_TitleFontType,RealItemTitleFontSize); ! SetFont(self,item->titlefont); ! if(item_Title) { ! fontdesc_StringSize(item->titlefont, ! suiteev_GetDrawable(self),item_Title, ! &titlewidth,&titleheight); ! titleLines = suiteev_LineCount(self,item_Title); ! titleheight = titleLines *(RealItemTitleFontSize+1); ! alignment = item_TitleCaptionAlignment; ! if(alignment & suite_Left) placement |= graphic_ATLEFT; ! else if(alignment & suite_Right) placement |= graphic_ATRIGHT; ! else placement |= graphic_BETWEENLEFTANDRIGHT; ! } /* else if(item->titleviewobject) { titlewidth = Width/3; titleheight = Height/3; } */ ! ItemPlaceTitle(self,item,titlewidth,titleheight); ! if(forcedTransferMode == NOFORCEDMODE) { ! if((item_HighlightStyle & suite_Invert) && Highlighted(item)) ! tMode = graphic_WHITE; ! else tMode = graphic_BLACK; } ! SetTransferMode(self,tMode); ! if(item_Title) { ! head = item_Title; ! if(alignment & suite_Left) x = TitleRect.left; ! else if(alignment & suite_Right) x = TitleRect.left + TitleRect.width; ! else x = TitleRect.left + TitleRect.width/2; ! if(alignment & suite_Top) y = TitleRect.top + RealItemTitleFontSize/2; ! else if(alignment & suite_Bottom) ! y = TitleRect.top + TitleRect.height - titleheight + RealItemTitleFontSize/2; ! else y = TitleRect.top + (TitleRect.height - titleheight)/2 + RealItemTitleFontSize/2; ! for( count = 0; (count < titleLines) && (head != '\0');count++) { ! if(tmp = (char*)index(head,'\n')) *tmp = '\0'; ! suiteev_MoveTo(self,x,y + ((RealItemTitleFontSize+1)*count)); ! suiteev_DrawString(self,head,placement); ! if(tmp) { ! *tmp = '\n'; ! head = tmp + 1; ! } ! } ! } /* else if(item->titleviewobject) view_FullUpdate(item->titleviewobject,view_FullRedraw,0,0, TitleRect.width,TitleRect.height); */ ! SetTransferMode(self,graphic_BLACK); ! OUT(suiteev_ItemDrawTitle); } void suiteev__ItemHighlight( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemHighlight); ! if(item_HighlightStyle & suite_None) return; ! if(item_HighlightStyle & suite_Invert) ! suiteev_ItemHighlightReverseVideo(self,item, ! item_HighlightStyle & suite_Border); ! else if(!item->viewobject) suiteev_ItemClear(self,item); ! if((item_HighlightStyle & suite_Bold) && (item_HighlightStyle & suite_Italic)) ! suiteev_ItemHighlightCaptionBoldItalic(self,item); ! else { ! if(item_HighlightStyle & suite_Bold) ! suiteev_ItemHighlightCaptionBold( self,item); ! if(item_HighlightStyle & suite_Italic) ! suiteev_ItemHighlightCaptionItalic(self,item); ! } ! item->mode = ((item_Active | item_Highlighted) & ~item_Normalized); ! if(item->title) suiteev_ItemDrawTitle(self,item,NOFORCEDMODE); ! if(item_Caption && !(item_AccessType & suite_ReadWrite)) ! suiteev_ItemDrawCaption(self,item,NOFORCEDMODE); ! if(!(item_BorderStyle & suite_None)) suiteev_DrawItemBorder(self,item); ! OUT(suiteev_ItemHighlight); } void suiteev__ItemClearCaption( self, item ) ! struct suiteev *self; ! struct suite_item *item; { ! IN(suiteev_ItemClearCaption); ! if(item_Caption) suiteev_ItemDrawCaption(self,item,graphic_WHITE); ! OUT(suiteev_ItemClearCaption); } void suiteev__ItemShade( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! short int shade = 0; ! struct rectangle *rect = rectangle_Duplicate(&Bounds); ! IN(suiteev_ItemShade); ! SetTransferMode(self,graphic_COPY); /* gk5g 8/4/89 was AND */ ! shade = 50; ! if(item_BorderStyle & suite_Roundangle) ! suiteev_FillRRectSize(self,Left,Top,Width,Height,10,10, ! suiteev_GrayPattern(self,shade,100)); ! else if(item_BorderStyle & suite_Rectangle) ! suiteev_FillRect(self,&Bounds,suiteev_GrayPattern(self,shade,100)); ! else if(item_BorderStyle & suite_Circle) { ! CenterBiggestCircleInRect(self,rect); ! suiteev_FillOvalSize(self,rect->left,rect->top, ! rect->width,rect->height,suiteev_GrayPattern(self,shade,100)); ! } ! else if(item_BorderStyle & suite_Oval) ! suiteev_FillOvalSize(self,Left,Top,Width,Height, ! suiteev_GrayPattern(self,shade,100)); ! if(item->title) ! suiteev_ItemDrawTitle(self,item,graphic_BLACK); ! if(item_Caption) ! suiteev_ItemDrawCaption(self,item,graphic_BLACK); ! item->mode &= ~item_Active; ! item->mode &= ~item_Normalized; ! if(!(item_BorderStyle & (suite_Invisible | suite_None))) ! suiteev_DrawItemBorder(self,item); ! OUT(suiteev_ItemShade); } long suiteev__Locate( self, x, y ) ! register struct suiteev *self; ! register long x, y; { ! register struct suite_item *item = NULL; ! register long i = 0; ! long realLeft = 0, realTop = 0, ! realWidth = 0, realHeight = 0; ! long YGutterOffset = YGutterSize + 1; ! long XGutterOffset = XGutterSize + 1; ! IN(suiteev_Locate); ! if(Items && ITEM(0) && (i = vector_Subscript(Items,FirstVisible)) != -1) { ! if(!x) ! while(item = ITEM(i)) { ! realTop = Top - (YGutterOffset/2); ! realHeight = Height + YGutterOffset; ! if(suite_ItemExposed(Suite,item) && ! (realTop <= y) && (y <= (realTop + realHeight))) { ! if((item == FirstVisible) && ((i+1) < vector_Count(Items))) ! return(i+1); ! else return(i); ! } ! else i++; ! } ! else if(!y) ! while(item = ITEM(i)) { ! realLeft = Left - (XGutterOffset/2); ! realWidth = Width + XGutterOffset; ! if(suite_ItemExposed(Suite,item) && ! (realLeft <= x) && (x <= (realLeft + realWidth))) return(i); ! else i++; ! } ! } ! else return(0); ! OUT(suiteev_Locate); ! return(vector_Subscript(Items,FirstVisible)); /* === */ } void suiteev__DrawItemBorder( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! register long i = 0; ! struct rectangle *rect = NULL; ! IN(suiteev_DrawItemBorder); ! SetTransferMode(self,graphic_BLACK); ! rect = rectangle_Duplicate(&Bounds); ! if(item_BorderStyle & suite_Roundangle) { ! for( i = 0 ; i < item_BorderSize ; i++ ) { ! suiteev_DrawRRectSize(self,rect->left,rect->top, ! rect->width,rect->height,10,10); ! DecrementRect(rect,1); ! } } ! else if(item_BorderStyle & suite_Rectangle) ! for( i = 0 ; i < item_BorderSize ; i++ ) { ! DrawRect(self,rect); ! DecrementRect(rect,1); ! } ! else if(item_BorderStyle & suite_Circle) ! CenterBiggestCircleInRect(self,rect); ! if((item_BorderStyle & suite_Oval) || (item_BorderStyle & suite_Circle)) ! for( i = 0 ; i < item_BorderSize ; i++ ) { ! suiteev_DrawOval(self,rect); ! DecrementRect(rect,1); ! } ! rectangle_SetRectSize(&InsetRect,rect->left,rect->top, ! rect->width,rect->height); ! OUT(suiteev_DrawItemBorder); } void suiteev__ItemToggle( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemToggle); ! if(Highlighted(item)) suiteev_ItemNormalize(self,item); ! else if(Normalized(item)) suiteev_ItemHighlight(self,item); ! OUT(suiteev_ItemToggle); } void suiteev__AllocItemArray( self, count ) ! register struct suiteev *self; ! long count; { ! IN(suiteev_AllocItemArray); ! if(count>0) ! ItemArray = (struct suite_item**) ! calloc(count+1,sizeof(struct suite_item*)); ! OUT(suiteev_AllocItemArray); } static void ReadWriteHandler( anchor, suite, item ) ! register long anchor; ! register struct suite *suite; ! register struct suite_item *item; { ! register struct text *txt = NULL; ! register struct suitecv *txtv = NULL; ! if((txt = (struct text*) suite_ItemDataObject(suite,item)) && ! (txtv = (struct suitecv*) suite_ItemViewObject(suite,item))) ! suitecv_SetDataObject(txtv,txt); } void suiteev__SetItemToReadWrite( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! AllocNameSpace(&item->dataobjectname,"text"); ! item->dataobject = (struct dataobject*) class_NewObject(item_DataObjectName); ! AllocNameSpace(&item->viewobjectname,"suitecv"); ! item->viewobject = (struct view*) class_NewObject(item_ViewObjectName); ! ((struct suitecv*)item->viewobject)->parent_EV = self; ! ((struct suitecv*)item->viewobject)->parent_item = item; ! item->viewobjecthandler = (long(*)())ReadWriteHandler; ! ReadWriteHandler(ClientAnchor,Suite,item); ! item->highlightstyle = suite_Border; ! if(item_Caption) ! text_AlwaysInsertCharacters((struct text*)item->dataobject, ! 0,item_Caption,strlen(item_Caption)); } static void MaxSubStringSize( self, item, str, font, w, h, index ) ! struct suiteev *self; ! struct suite_item *item; ! char *str; ! struct fontdesc *font; ! long int *w, *h, *index; { ! long int HMax = 0, WMax = 0; ! char *tmp = NULL, *head = NULL, save; ! register int j = 0, pos = 0, i = 0; ! tmp = head = str; ! while(tmp && *tmp != '\0') { ! if(*tmp == '\n') { ! *tmp = '\0'; ! fontdesc_StringSize(font,suiteev_GetDrawable(self),head,w,h); ! if(*w > WMax) { ! WMax = *w; ! *index = i; ! } ! if(*h > HMax) { ! HMax = *h; ! *index = i; ! } ! *tmp++ = '\n'; ! pos++; ! head = tmp; ! i++; ! } ! else if((j < BreakCount(item)) && (pos == BreakPos(item,j))) { ! save = *(item_Caption + pos + 1); ! *(item_Caption + pos + 1) = '\0'; ! fontdesc_StringSize(font,suiteev_GetDrawable(self),head,w,h); ! if(*w > WMax) { ! WMax = *w; ! *index = i; ! } ! if(*h > HMax) { ! HMax = *h; ! *index = i; ! } ! *(item_Caption + pos + 1) = save; ! tmp++;pos++; ! head = tmp; ! j++; ! i++; ! } ! else { ! tmp++; ! pos++; ! } } ! if(*tmp == '\0' && *head != '\0' ) { ! fontdesc_StringSize(font,suiteev_GetDrawable(self),head,w,h); ! if(*w > WMax) { ! WMax = *w; ! *index = i; ! } ! if(*h > HMax) HMax = *h; } ! *w = WMax; ! *h = HMax; } ! static void ! MaxListSubStringWidth( self, item, str, font, w ) ! struct suiteev *self; ! struct suite_item *item; ! char *str; ! struct fontdesc *font; ! long int *w; { ! long int WMax = 0, *h = 0; ! char *tmp = NULL, *head = NULL, save; ! register int j = 0, pos = 0, i = 0; ! tmp = head = str; ! while(tmp && *tmp != '\0') { ! if(*tmp == '\n') { ! *tmp = '\0'; ! fontdesc_StringSize(font,suiteev_GetDrawable(self),head,w,h); ! if(i==0) *w += CaptionMWidth; ! else *w += (3 * CaptionMWidth); ! if(*w > WMax) WMax = *w; ! *tmp++ = '\n'; ! pos++; ! head = tmp; ! i++; ! } ! else if((j < BreakCount(item)) && (pos == BreakPos(item,j))) { ! save = *(item_Caption + pos + 1); ! *(item_Caption + pos + 1) = '\0'; ! fontdesc_StringSize(font,suiteev_GetDrawable(self),head,w,h); ! if(i==0) *w += CaptionMWidth; ! else *w += (3 * CaptionMWidth); ! if(*w > WMax) WMax = *w; ! *(item_Caption + pos + 1) = save; ! tmp++;pos++; ! head = tmp; ! j++; ! i++; ! } ! else { ! tmp++; ! pos++; ! } } ! if(*tmp == '\0' && *head != '\0' ) { ! fontdesc_StringSize(font,suiteev_GetDrawable(self),head,w,h); ! if(i==0) *w += CaptionMWidth; ! else *w += (3 * CaptionMWidth); ! if(*w > WMax) WMax = *w; } ! *w = WMax; } void suiteev__MaxStringSize( self, width, height ) ! struct suiteev *self; ! long *width, *height; { ! register int i = 0; ! register struct suite_item *item = NULL; ! register long maxWidth = 0, maxHeight = 0; ! long XWidth = 0, YWidth = 0, dummyIndex = 0; ! register numLines = 0; ! IN(MaxStringSize); ! while(item = ITEM(i++)) ! if(Exposed(item)) { ! if(item_Caption) { ! numLines = suiteev_LineCount(self,item_Caption) + BreakCount(item); ! MaxSubStringSize(self,item,item_Caption,item_CaptionFont, ! &XWidth,&YWidth,&dummyIndex); ! if(XWidth > maxWidth) maxWidth = XWidth; ! YWidth = item_RealCaptionFontSize * numLines; ! if(YWidth > maxHeight) maxHeight = YWidth; ! } ! if(item->title) { ! numLines = suiteev_LineCount(self,item->title); ! MaxSubStringSize(self,item,item->title,TitleFont, ! &XWidth,&YWidth,&dummyIndex); ! if(XWidth > maxWidth) { ! if(TitlePlacement & (suite_Left|suite_Right)) maxWidth += XWidth; ! else maxWidth = XWidth; ! } ! if(TitlePlacement & (suite_Top|suite_Bottom)) { ! YWidth += (numLines * RealItemTitleFontSize); ! if(YWidth > maxHeight) maxHeight += YWidth; ! } ! } } ! *width = maxWidth; ! *height = maxHeight; ! OUT(MaxStringSize); } long suiteev__LineCount( self, str ) ! register struct suiteev *self; ! register char *str; { ! register long number = 1; ! register char *tmp = str; ! if(tmp) ! while(*tmp != '\0') ! if(*tmp++ == '\n') number++; ! return(number); } static void DrawRectSize(self,x, y,width,height) ! struct suiteev *self; ! long x,y,width,height; { ! long left = x; ! long right = x+width-1; ! long top = y; ! long bottom = y+height-1; ! if (left > right) left = right; ! if(top > bottom) top = bottom; ! ! suiteev_MoveTo(self,left,top); ! suiteev_DrawLineTo(self,right,top); ! suiteev_DrawLineTo(self,right,bottom); ! suiteev_DrawLineTo(self,left,bottom); ! suiteev_DrawLineTo(self,left,top); } static void DrawRect(self, Rect) ! struct suiteev *self; ! struct rectangle *Rect; { ! DrawRectSize(self,rectangle_Left(Rect),rectangle_Top(Rect), rectangle_Width(Rect), rectangle_Height(Rect)); } --- 1606,2299 ---- static void ItemPlaceCaption( self, item, captionwidth, captionheight, place ) ! register struct suiteev *self; ! register struct suite_item *item; ! long captionwidth; ! long captionheight; ! unsigned *place; { ! unsigned char alignment = 0; ! long l = Left + ItemBorderSize, t = Top + ItemBorderSize; ! long w = Width - (2*ItemBorderSize); ! long h = Height - (2*ItemBorderSize); ! IN(ItemPlaceCaption); ! if(item) { ! alignment = item_CaptionAlignment; ! if(captionwidth > w) captionwidth = w; ! if(captionheight > h) captionheight = h; ! rectangle_SetRectSize(&CaptionRect, ! l + ((w - captionwidth)/2), ! t + ((h - captionheight)/2), ! captionwidth,captionheight); ! if(alignment & suite_Left) CaptionRect.left = l; ! if(alignment & suite_Right) CaptionRect.left = l + w - captionwidth; ! if(alignment & suite_Top) CaptionRect.top = t; ! if(alignment & suite_Bottom) CaptionRect.top = t + h - captionheight; ! } ! *place = graphic_BETWEENTOPANDBOTTOM; ! if(alignment & suite_Middle) *place |= graphic_BETWEENTOPANDBOTTOM; ! if(alignment & suite_Center) *place |= graphic_BETWEENLEFTANDRIGHT; ! if(alignment & suite_Left) *place |= graphic_ATLEFT; ! if(alignment & suite_Right) *place |= graphic_ATRIGHT; ! OUT(ItemPlaceCaption); } void suiteev__ItemDrawCaption( self, item, forcedTransferMode ) ! register struct suiteev *self; ! register struct suite_item *item; ! short forcedTransferMode; { ! long captionwidth = 0, captionheight = 0, totalWidth = 0; ! long X = 0, Y = 0, SubStringIndex = 0; ! unsigned tMode = graphic_BLACK, placement = 0; ! unsigned alignment = item_CaptionAlignment; ! register long pos = 0, i = 0, j = 0, numLines = 0; ! char *tmp = NULL, *head = NULL, save; ! boolean WasBreakPos = FALSE, WasNewLine = FALSE; ! boolean dontDraw = FALSE; ! IN(suiteev_ItemDrawCaption); ! if(forcedTransferMode != NOFORCEDMODE) tMode = forcedTransferMode; ! item->captionfont = fontdesc_Create(item_CaptionFontName, item_CaptionFontType,item_RealCaptionFontSize); ! SetFont(self,item->captionfont); ! MaxSubStringSize(self,item,item_Caption,item_CaptionFont, &captionwidth,&captionheight,&SubStringIndex); + if(List) { + totalWidth = MaxListSubStringWidth(self,item,item_Caption,item_CaptionFont); + if(item_Title) totalWidth += TitleRect.width; + if((totalWidth > Width) && (Width > (4 * CaptionMWidth))) { + suiteev_Update(self); + return; + } + } + numLines = suiteev_LineCount(self,item_Caption) + BreakCount(item); + captionheight = numLines * (item_RealCaptionFontSize+2); + ItemPlaceCaption(self,item,captionwidth,captionheight,&placement); + if(forcedTransferMode == NOFORCEDMODE) + if((item_HighlightStyle & suite_Invert) && Highlighted(item)) + tMode = graphic_WHITE; + else tMode = graphic_BLACK; + SetTransferMode(self,tMode); + tmp = head = item_Caption; + Y = CaptionRect.top + (item_RealCaptionFontSize/2) + 1; + X = CaptionRect.left + CaptionRect.width/2; + if(alignment & suite_Left) X = CaptionRect.left; + if(alignment & suite_Right) X = CaptionRect.left + CaptionRect.width; + for( j = 0, i = 0 ; i < numLines ; i++ ) { + WasNewLine = WasBreakPos = FALSE; + save = '\0'; + while(tmp && (*tmp != '\0')) { + if(*tmp == '\n') { + WasNewLine = TRUE; + break; + } + else if((j < BreakCount(item)) && (pos == BreakPos(item,j))) { + WasBreakPos = TRUE; + break; + } + else { + pos++;tmp++; + } + } + if(WasNewLine) *tmp = '\0'; + else if(WasBreakPos) { + save = *(tmp+1); + *(tmp+1) = '\0'; + } if(List) { ! if(i > 0) { ! if(WrapStyle & suite_LeftIndent) { ! X = Left + CaptionMWidth + (2 * CaptionMWidth); ! placement = graphic_ATLEFT | graphic_BETWEENTOPANDBOTTOM; } ! else if(WrapStyle & suite_LeftRight) { ! X = Left + Width - (2 * CaptionMWidth); ! placement = graphic_ATRIGHT | graphic_BETWEENTOPANDBOTTOM; } ! } ! else { ! X = Left + CaptionMWidth; ! placement = graphic_ATLEFT | graphic_BETWEENTOPANDBOTTOM; ! } ! if(item == FirstVisible && i < FirstVisibleSubString) ! dontDraw = TRUE; ! else dontDraw = FALSE; } ! if(i > 0) Y += (item_RealCaptionFontSize + 2); ! if(!List || ! (Y + (item_RealCaptionFontSize/2) + 1) < suiteev_GetVisualBottom(self)) { ! if(!dontDraw) { ! suiteev_MoveTo(self,X,Y); ! suiteev_DrawString(self,head,placement); ! } ! } ! if(WasNewLine) *tmp = '\n'; ! else if(WasBreakPos) { ! *(tmp+1) = save; ! j++; ! } ! tmp++;pos++; ! head = tmp; ! } ! SetTransferMode(self,graphic_BLACK); ! OUT(suiteev_ItemDrawCaption); } void ItemPlaceTitle(self,item,titlewidth,titleheight) ! struct suiteev *self; ! struct suite_item *item; ! long titlewidth, titleheight; { ! unsigned char titleplacement = item_TitlePlacement; ! boolean left = FALSE, right = FALSE, top = FALSE, bottom = FALSE; ! IN(suiteev_ItemPlaceTitle); ! if(titleplacement & suite_Left) { ! left = TRUE; ! rectangle_SetRectSize(&TitleRect, ! Left + BorderPlusOne, ! Top + BorderPlusOne, ! titlewidth + 2, ! Height - TwiceBorderPlusOne); ! rectangle_SetRectSize(&InsetRect, ! TitleRect.left + TitleRect.width + 1, ! Top + BorderPlusOne, ! Width - TitleRect.width - TwiceBorderPlusOne - 1, ! Height - TwiceBorderPlusOne); ! } ! else if(titleplacement & suite_Right) { ! right = TRUE; ! rectangle_SetRectSize(&TitleRect, ! Left + Width - (titlewidth + 2), ! Top + BorderPlusOne, ! titlewidth + 2, ! Height - TwiceBorderPlusOne); ! rectangle_SetRectSize(&InsetRect, ! Left + BorderPlusOne, ! Top + BorderPlusOne, ! Width - TitleRect.width - TwiceBorderPlusOne - 1, ! Height - TwiceBorderPlusOne); ! } ! else if(titleplacement & suite_Top) { ! top = TRUE; ! rectangle_SetRectSize(&TitleRect, ! Left + BorderPlusOne, ! Top + BorderPlusOne, ! Width - TwiceBorderPlusOne, ! titleheight + 2); ! rectangle_SetRectSize(&InsetRect, ! Left + BorderPlusOne, ! TitleRect.top + TitleRect.height + 1, ! Width - TwiceBorderPlusOne, ! Height - TitleRect.height - TwiceBorderPlusOne); ! } ! else if(titleplacement & suite_Bottom) { ! bottom = TRUE; ! rectangle_SetRectSize(&TitleRect, ! Left + BorderPlusOne, ! Top + Height - titleheight - BorderPlusOne, ! Width - TwiceBorderPlusOne, ! titleheight + 2); ! rectangle_SetRectSize(&InsetRect, ! Left + BorderPlusOne, ! Top + BorderPlusOne, ! Width - TwiceBorderPlusOne, ! Height - TitleRect.height - BorderPlusOne); ! } ! if(item_AccessType & suite_ReadWrite) { ! InsetHeight = RealItemTitleFontSize + 12; ! if(Height < InsetHeight) ! InsetHeight = Height - 4; ! if(left || right) ! InsetTop = TitleRect.top + (TitleRect.height-InsetHeight)/2; ! else if(top) ! InsetTop = TitleRect.top + TitleRect.height + 2; ! else if(bottom) ! InsetTop = TitleRect.top + 2 + InsetHeight; ! } ! OUT(suiteev_ItemPlaceTitle); } void suiteev__ItemDrawTitle( self, item, forcedTransferMode ) ! register struct suiteev *self; ! register struct suite_item *item; ! short forcedTransferMode; { ! long x = 0, y = 0, count = 0; ! char *tmp = NULL, *head = NULL; ! unsigned tMode = 0, alignment = 0, ! placement = graphic_BETWEENTOPANDBOTTOM; ! long titlewidth = 0, titleheight = 0; ! long titleLines = 0; ! IN(suiteev_ItemDrawTitle); ! tMode = (forcedTransferMode == NOFORCEDMODE) ? ! graphic_BLACK : forcedTransferMode; ! if(!item->titlefont) ! item->titlefont = fontdesc_Create(item_TitleFontName, ! item_TitleFontType,RealItemTitleFontSize); ! SetFont(self,item->titlefont); ! if(item_Title) { ! fontdesc_StringBoundingBox(item->titlefont, ! suiteev_GetDrawable(self),item_Title, ! &titlewidth,&titleheight); ! titleLines = suiteev_LineCount(self,item_Title); ! titleheight = titleLines * (titleheight+1); ! /* titleheight = titleLines *(RealItemTitleFontSize+1);*/ ! alignment = item_TitleCaptionAlignment; ! if(alignment & suite_Left) placement |= graphic_ATLEFT; ! else if(alignment & suite_Right) placement |= graphic_ATRIGHT; ! else placement |= graphic_BETWEENLEFTANDRIGHT; ! } /* else if(item->titleviewobject) { titlewidth = Width/3; titleheight = Height/3; } */ ! ItemPlaceTitle(self,item,titlewidth,titleheight); ! if(forcedTransferMode == NOFORCEDMODE) { ! if((item_HighlightStyle & suite_Invert) && Highlighted(item)) ! tMode = graphic_WHITE; ! else tMode = graphic_BLACK; ! } ! SetTransferMode(self,tMode); ! if(item_Title) { ! head = item_Title; ! if(alignment & suite_Left) x = TitleRect.left; ! else if(alignment & suite_Right) x = TitleRect.left + TitleRect.width; ! else x = TitleRect.left + TitleRect.width/2; ! if(alignment & suite_Top) y = TitleRect.top + RealItemTitleFontSize/2; ! else if(alignment & suite_Bottom) ! y = TitleRect.top + TitleRect.height - titleheight + RealItemTitleFontSize/2; ! else y = TitleRect.top + (TitleRect.height - titleheight)/2 + RealItemTitleFontSize/2; ! for( count = 0; (count < titleLines) && (head != '\0');count++) { ! if(tmp = (char*)index(head,'\n')) *tmp = '\0'; ! suiteev_MoveTo(self,x,y + ((RealItemTitleFontSize+1)*count)); ! suiteev_DrawString(self,head,placement); ! if(tmp) { ! *tmp = '\n'; ! head = tmp + 1; ! } } ! } /* else if(item->titleviewobject) view_FullUpdate(item->titleviewobject,view_FullRedraw,0,0, TitleRect.width,TitleRect.height); */ ! SetTransferMode(self,graphic_BLACK); ! OUT(suiteev_ItemDrawTitle); } void suiteev__ItemHighlight( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemHighlight); ! if(item_HighlightStyle & suite_None) return; ! if(item_HighlightStyle & suite_Invert) ! suiteev_ItemHighlightReverseVideo(self,item, ! item_HighlightStyle & suite_Border); ! else if(!item->viewobject) suiteev_ItemClear(self,item); ! if((item_HighlightStyle & suite_Bold) && (item_HighlightStyle & suite_Italic)) ! suiteev_ItemHighlightCaptionBoldItalic(self,item); ! else { ! if(item_HighlightStyle & suite_Bold) ! suiteev_ItemHighlightCaptionBold( self,item); ! if(item_HighlightStyle & suite_Italic) ! suiteev_ItemHighlightCaptionItalic(self,item); ! } ! item->mode = ((item_Active | item_Highlighted) & ~item_Normalized); ! if(item->title) suiteev_ItemDrawTitle(self,item,NOFORCEDMODE); ! if(item_Caption && !(item_AccessType & suite_ReadWrite)) ! suiteev_ItemDrawCaption(self,item,NOFORCEDMODE); ! if(!(item_BorderStyle & suite_None)) suiteev_DrawItemBorder(self,item); ! OUT(suiteev_ItemHighlight); } void suiteev__ItemClearCaption( self, item ) ! struct suiteev *self; ! struct suite_item *item; { ! IN(suiteev_ItemClearCaption); ! if(item_Caption) suiteev_ItemDrawCaption(self,item,graphic_WHITE); ! OUT(suiteev_ItemClearCaption); } void suiteev__ItemShade( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! short int shade = 0; ! struct rectangle *rect = rectangle_Duplicate(&Bounds); ! IN(suiteev_ItemShade); ! SetTransferMode(self,graphic_COPY); /* gk5g 8/4/89 was AND */ ! shade = 50; ! if(item_BorderStyle & suite_Roundangle) ! suiteev_FillRRectSize(self,Left,Top,Width,Height,10,10, ! suiteev_GrayPattern(self,shade,100)); ! else if(item_BorderStyle & suite_Rectangle) ! suiteev_FillRect(self,&Bounds,suiteev_GrayPattern(self,shade,100)); ! else if(item_BorderStyle & suite_Circle) { ! CenterBiggestCircleInRect(self,rect); ! suiteev_FillOvalSize(self,rect->left,rect->top, ! rect->width,rect->height,suiteev_GrayPattern(self,shade,100)); ! } ! else if(item_BorderStyle & suite_Oval) ! suiteev_FillOvalSize(self,Left,Top,Width,Height, ! suiteev_GrayPattern(self,shade,100)); ! if(item->title) ! suiteev_ItemDrawTitle(self,item,graphic_BLACK); ! if(item_Caption) ! suiteev_ItemDrawCaption(self,item,graphic_BLACK); ! item->mode &= ~item_Active; ! item->mode &= ~item_Normalized; ! if(!(item_BorderStyle & (suite_Invisible | suite_None))) ! suiteev_DrawItemBorder(self,item); ! OUT(suiteev_ItemShade); } long suiteev__Locate( self, x, y ) ! register struct suiteev *self; ! register long x, y; { ! register struct suite_item *item = NULL; ! register long i = 0; ! long realLeft = 0, realTop = 0, ! realWidth = 0, realHeight = 0; ! long YGutterOffset = YGutterSize + 1; ! long XGutterOffset = XGutterSize + 1; ! IN(suiteev_Locate); ! if(Items && ITEM(0) && (i = vector_Subscript(Items,FirstVisible)) != -1) { ! if(!x) ! while(item = ITEM(i)) { ! realTop = Top - (YGutterOffset/2); ! realHeight = Height + YGutterOffset; ! if(suite_ItemExposed(Suite,item) && ! (realTop <= y) && (y <= (realTop + realHeight))) { ! if((item == FirstVisible) && ((i+1) < vector_Count(Items))) ! return(i+1); ! else return(i); ! } ! else i++; ! } ! else if(!y) ! while(item = ITEM(i)) { ! realLeft = Left - (XGutterOffset/2); ! realWidth = Width + XGutterOffset; ! if(suite_ItemExposed(Suite,item) && ! (realLeft <= x) && (x <= (realLeft + realWidth))) return(i); ! else i++; ! } ! } ! else return(0); ! OUT(suiteev_Locate); ! return(vector_Subscript(Items,FirstVisible)); /* === */ } void suiteev__DrawItemBorder( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! register long i = 0; ! struct rectangle *rect = NULL; ! IN(suiteev_DrawItemBorder); ! SetTransferMode(self,graphic_BLACK); ! rect = rectangle_Duplicate(&Bounds); ! if(item_BorderStyle & suite_Roundangle) { ! for( i = 0 ; i < item_BorderSize ; i++ ) { ! suiteev_DrawRRectSize(self,rect->left,rect->top, ! rect->width,rect->height,10,10); ! DecrementRect(rect,1); } ! } ! else if(item_BorderStyle & suite_Rectangle) ! for( i = 0 ; i < item_BorderSize ; i++ ) { ! DrawRect(self,rect); ! DecrementRect(rect,1); ! } ! else if(item_BorderStyle & suite_Circle) ! CenterBiggestCircleInRect(self,rect); ! if((item_BorderStyle & suite_Oval) || (item_BorderStyle & suite_Circle)) ! for( i = 0 ; i < item_BorderSize ; i++ ) { ! suiteev_DrawOval(self,rect); ! DecrementRect(rect,1); ! } ! rectangle_SetRectSize(&InsetRect,rect->left,rect->top, ! rect->width,rect->height); ! OUT(suiteev_DrawItemBorder); } void suiteev__ItemToggle( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! IN(suiteev_ItemToggle); ! if(Highlighted(item)) suiteev_ItemNormalize(self,item); ! else if(Normalized(item)) suiteev_ItemHighlight(self,item); ! OUT(suiteev_ItemToggle); } void suiteev__AllocItemArray( self, count ) ! register struct suiteev *self; ! long count; { ! IN(suiteev_AllocItemArray); ! if(count > 0) ! ItemArray = (struct suite_item**) ! calloc(count + 1,sizeof(struct suite_item*)); ! OUT(suiteev_AllocItemArray); } static void ReadWriteHandler( anchor, suite, item ) ! register long anchor; ! register struct suite *suite; ! register struct suite_item *item; { ! register struct text *txt = NULL; ! register struct suitecv *txtv = NULL; ! if((txt = (struct text*) suite_ItemDataObject(suite,item)) && ! (txtv = (struct suitecv*) suite_ItemViewObject(suite,item))) { ! suitecv_SetBorder(txtv,1,1); ! suitecv_SetDataObject(txtv,txt); ! } } void suiteev__SetItemToReadWrite( self, item ) ! register struct suiteev *self; ! register struct suite_item *item; { ! AllocNameSpace(&item->dataobjectname,"text"); ! item->dataobject = (struct dataobject*) class_NewObject(item_DataObjectName); ! AllocNameSpace(&item->viewobjectname,"suitecv"); ! item->viewobject = (struct view*) class_NewObject(item_ViewObjectName); ! ((struct suitecv*)item->viewobject)->parent_EV = self; ! ((struct suitecv*)item->viewobject)->parent_item = item; ! item->viewobjecthandler = (long(*)())ReadWriteHandler; ! ReadWriteHandler(ClientAnchor,Suite,item); ! item->highlightstyle = suite_Border; ! if(item_Caption) ! text_AlwaysInsertCharacters((struct text*)item->dataobject, ! 0,item_Caption,strlen(item_Caption)); } static void MaxSubStringSize( self, item, str, font, w, h, index ) ! struct suiteev *self; ! struct suite_item *item; ! char *str; ! struct fontdesc *font; ! long int *w, *h, *index; { ! long int HMax = 0, WMax = 0; ! char *tmp = NULL, *head = NULL, save; ! register int j = 0, pos = 0, i = 0; ! *w = *h = 0; ! tmp = head = str; ! while(tmp && *tmp != '\0') { ! if(*tmp == '\n') { ! *tmp = '\0'; ! fontdesc_StringBoundingBox(font,suiteev_GetDrawable(self),head,w,h); ! if(*w > WMax) { ! WMax = *w; ! *index = i; ! } ! if(*h > HMax) { ! HMax = *h; ! *index = i; ! } ! *tmp++ = '\n'; ! pos++; ! head = tmp; ! i++; } ! else if((j < BreakCount(item)) && (pos == BreakPos(item,j))) { ! save = *(item_Caption + pos + 1); ! *(item_Caption + pos + 1) = '\0'; ! fontdesc_StringBoundingBox(font,suiteev_GetDrawable(self),head,w,h); ! if(*w > WMax) { ! WMax = *w; ! *index = i; ! } ! if(*h > HMax) { ! HMax = *h; ! *index = i; ! } ! *(item_Caption + pos + 1) = save; ! tmp++;pos++; ! head = tmp; ! j++; ! i++; } ! else { ! tmp++; ! pos++; ! } ! } ! if(*tmp == '\0' && *head != '\0' ) { ! fontdesc_StringBoundingBox(font,suiteev_GetDrawable(self),head,w,h); ! if(*w > WMax) { ! WMax = *w; ! *index = i; ! } ! if(*h > HMax) HMax = *h; ! } ! *w = WMax; ! *h = HMax; } ! static long ! MaxListSubStringWidth( self, item, str, font ) ! struct suiteev *self; ! struct suite_item *item; ! char *str; ! struct fontdesc *font; { ! long int WMax = 0, h = 0, w = 0; ! char *tmp = NULL, *head = NULL, save; ! register int j = 0, pos = 0, i = 0; ! w = 0; ! tmp = head = str; ! while(tmp && *tmp != '\0') { ! if(*tmp == '\n') { ! *tmp = '\0'; ! fontdesc_StringBoundingBox(font,suiteev_GetDrawable(self),head,&w,&h); ! if(i > 0) w += (2 * CaptionMWidth); ! if(w > WMax) WMax = w; ! *tmp++ = '\n'; ! pos++; ! head = tmp; ! i++; } ! else if((j < BreakCount(item)) && (pos == BreakPos(item,j))) { ! save = *(item_Caption + pos + 1); ! *(item_Caption + pos + 1) = '\0'; ! fontdesc_StringBoundingBox(font,suiteev_GetDrawable(self),head,&w,&h); ! if(i > 0) w += (2 * CaptionMWidth); ! if(w > WMax) WMax = w; ! *(item_Caption + pos + 1) = save; ! tmp++;pos++; ! head = tmp; ! j++; ! i++; } ! else { ! tmp++; ! pos++; ! } ! } ! if(*tmp == '\0' && *head != '\0' ) { ! fontdesc_StringBoundingBox(font,suiteev_GetDrawable(self),head,&w,&h); ! if(i > 0) w += (2 * CaptionMWidth); ! if(w > WMax) WMax = w; ! } ! return(WMax); } void suiteev__MaxStringSize( self, width, height ) ! struct suiteev *self; ! long *width, *height; { ! register int i = 0; ! register struct suite_item *item = NULL; ! register long maxWidth = 0, maxHeight = 0; ! long XWidth = 0, YWidth = 0, dummyIndex = 0; ! register numLines = 0; ! IN(MaxStringSize); ! while(item = ITEM(i++)) ! if(Exposed(item)) { ! if(item_Caption) { ! numLines = suiteev_LineCount(self,item_Caption) + BreakCount(item); ! MaxSubStringSize(self,item,item_Caption,item_CaptionFont, ! &XWidth,&YWidth,&dummyIndex); ! if(XWidth > maxWidth) maxWidth = XWidth; ! YWidth *= numLines; ! /* YWidth = item_RealCaptionFontSize * numLines;*/ ! if(YWidth > maxHeight) maxHeight = YWidth; ! } ! if(item->title) { ! long titleYWidth = 0, titleXWidth = 0; ! ! numLines = suiteev_LineCount(self,item->title); ! MaxSubStringSize(self,item,item->title,TitleFont, ! &titleXWidth,&titleYWidth,&dummyIndex); ! if(titleXWidth > maxWidth) { ! if(TitlePlacement & (suite_Left|suite_Right)) ! maxWidth += titleXWidth; ! else maxWidth = titleXWidth; } ! if(TitlePlacement & (suite_Top|suite_Bottom)) { ! YWidth += (numLines * titleYWidth); ! /* YWidth += (numLines * RealItemTitleFontSize);*/ ! if(YWidth > maxHeight) maxHeight += YWidth; ! } ! } ! } ! *width = maxWidth; ! *height = maxHeight; ! OUT(MaxStringSize); } long suiteev__LineCount( self, str ) ! register struct suiteev *self; ! register char *str; { ! register long number = 1; ! register char *tmp = str; ! if(tmp) ! while(*tmp != '\0') ! if(*tmp++ == '\n') ! number++; ! return(number); } static void DrawRectSize(self,x, y,width,height) ! struct suiteev *self; ! long x,y,width,height; { ! long left = x; ! long right = x+width-1; ! long top = y; ! long bottom = y+height-1; ! if (left > right) left = right; ! if(top > bottom) top = bottom; ! suiteev_MoveTo(self,left,top); ! suiteev_DrawLineTo(self,right,top); ! suiteev_DrawLineTo(self,right,bottom); ! suiteev_DrawLineTo(self,left,bottom); ! suiteev_DrawLineTo(self,left,top); } static void DrawRect(self, Rect) ! struct suiteev *self; ! struct rectangle *Rect; { ! DrawRectSize(self,rectangle_Left(Rect),rectangle_Top(Rect), rectangle_Width(Rect), rectangle_Height(Rect)); } *** atk/apt/suite/SuitePG.doc Wed Nov 22 11:45:49 1989 --- atk/apt/suite/SuitePG.doc.NEW Thu May 10 16:22:44 1990 *************** *** 1,4 **** ! \begindata{text,268682652} \textdsversion{12} \define{italic menu:[Font,Italic] --- 1,4 ---- ! \begindata{text,269076168} \textdsversion{12} \define{italic menu:[Font,Italic] *************** *** 136,144 **** \italic{styingg} ! \begindata{bp,269259724} ! \enddata{bp,269259724} ! \view{bpv,269259724,7,0,0} \center{ --- 136,144 ---- \italic{styingg} ! \begindata{bp,269075052} ! \enddata{bp,269075052} ! \view{bpv,269075052,0,0,0} \center{ *************** *** 208,216 **** \bold{(c) IBM Corporation 1989}} ! \begindata{bp,269341712} ! \enddata{bp,269341712} ! \view{bpv,269341712,8,0,0} \bold{Preface} --- 208,216 ---- \bold{(c) IBM Corporation 1989}} ! \begindata{bp,269047124} ! \enddata{bp,269047124} ! \view{bpv,269047124,1,0,0} \bold{Preface} *************** *** 231,239 **** interfaces to suites of items. ! \begindata{bp,269339044} ! \enddata{bp,269339044} ! \view{bpv,269339044,9,0,0} \bold{Introduction} --- 231,239 ---- interfaces to suites of items. ! \begindata{bp,269004840} ! \enddata{bp,269004840} ! \view{bpv,269004840,2,0,0} \bold{Introduction} *************** *** 275,283 **** manner in which the user interacts with the Suite. ! \begindata{bp,269338140} ! \enddata{bp,269338140} ! \view{bpv,269338140,10,0,0} \chapter{1 Concepts} --- 275,283 ---- manner in which the user interacts with the Suite. ! \begindata{bp,269036056} ! \enddata{bp,269036056} ! \view{bpv,269036056,3,0,0} \chapter{1 Concepts} *************** *** 337,345 **** } ! \begindata{bp,269333652} ! \enddata{bp,269333652} ! \view{bpv,269333652,11,0,0} You can set various attributes to tailor the manner in which a Suite and its Items are displayed and manipulated. Note, however, that all have defaults that should yield acceptable formatting. You should begin with the defaults, --- 337,345 ---- } ! \begindata{bp,269024732} ! \enddata{bp,269024732} ! \view{bpv,269024732,4,0,0} You can set various attributes to tailor the manner in which a Suite and its Items are displayed and manipulated. Note, however, that all have defaults that should yield acceptable formatting. You should begin with the defaults, *************** *** 350,356 **** Some typical Suite views: \center{ ! \begindata{zip,268819580} %ViewWidth 436 %ViewHeight 388 *G;-675,675 --- 350,356 ---- Some typical Suite views: \center{ ! \begindata{zip,269046964} %ViewWidth 436 %ViewHeight 388 *G;-675,675 *************** *** 631,638 **** G1 >236,350 ! \enddata{zip,268819580} ! \view{zipview,268819580,0,0,0} } --- 631,638 ---- G1 >236,350 ! \enddata{zip,269046964} ! \view{zipview,269046964,5,0,0} } *************** *** 650,658 **** program: all the Suite and Item attributes can be set or queried through attribute-access facilities. ! \begindata{bp,269410308} ! \enddata{bp,269410308} ! \view{bpv,269410308,12,0,0} By way of example, the following is a complete program (\italic{\sans{suitex1a}}) employing the Suite class. Its functionality is rather simple: it prints the name of the flavor clicked. --- 650,658 ---- program: all the Suite and Item attributes can be set or queried through attribute-access facilities. ! \begindata{bp,269173820} ! \enddata{bp,269173820} ! \view{bpv,269173820,6,0,0} By way of example, the following is a complete program (\italic{\sans{suitex1a}}) employing the Suite class. Its functionality is rather simple: it prints the name of the flavor clicked. *************** *** 759,765 **** \center{ ! \begindata{zip,268915276} %ViewWidth 355 %ViewHeight 288 *D;-1000,1400 --- 759,765 ---- \center{ ! \begindata{zip,269349924} %ViewWidth 355 %ViewHeight 288 *D;-1000,1400 *************** *** 908,925 **** TSingleRow MCM ! \enddata{zip,268915276} ! \view{zipview,268915276,1,0,0} } ! \begindata{bp,269398972} ! \enddata{bp,269398972} ! \view{bpv,269398972,13,0,0} Title can be placed within the Suit container in any of four places: \center{ ! \begindata{zip,268897284} %ViewWidth 317 %ViewHeight 197 *D;-1000,1400 --- 908,925 ---- TSingleRow MCM ! \enddata{zip,269349924} ! \view{zipview,269349924,7,0,0} } ! \begindata{bp,269349312} ! \enddata{bp,269349312} ! \view{bpv,269349312,8,0,0} Title can be placed within the Suit container in any of four places: \center{ ! \begindata{zip,269122408} %ViewWidth 317 %ViewHeight 197 *D;-1000,1400 *************** *** 1009,1016 **** TA\nLeft\nSide\nTitle MLM ! \enddata{zip,268897284} ! \view{zipview,268897284,2,319,199} } --- 1009,1016 ---- TA\nLeft\nSide\nTitle MLM ! \enddata{zip,269122408} ! \view{zipview,269122408,9,319,199} } *************** *** 1025,1031 **** width and height sufficient to display only 3 columns and 4 rows). \center{ ! \begindata{zip,268896828} %ViewWidth 277 %ViewHeight 319 *D;-1000,1400 --- 1025,1031 ---- width and height sufficient to display only 3 columns and 4 rows). \center{ ! \begindata{zip,269113056} %ViewWidth 277 %ViewHeight 319 *D;-1000,1400 *************** *** 1198,1205 **** G1 >-808,-639 ! \enddata{zip,268896828} ! \view{zipview,268896828,3,279,321} } --- 1198,1205 ---- G1 >-808,-639 ! \enddata{zip,269113056} ! \view{zipview,269113056,10,279,321} } *************** *** 1209,1215 **** desirable, its scrolling is "snake-wise", from column to column. \center{ ! \begindata{zip,269106592} %ViewWidth 263 %ViewHeight 145 *D;-1000,1400 --- 1209,1215 ---- desirable, its scrolling is "snake-wise", from column to column. \center{ ! \begindata{zip,269121584} %ViewWidth 263 %ViewHeight 145 *D;-1000,1400 *************** *** 1416,1423 **** TP MCM ! \enddata{zip,269106592} ! \view{zipview,269106592,4,265,147} } --- 1416,1423 ---- TP MCM ! \enddata{zip,269121584} ! \view{zipview,269121584,11,265,147} } *************** *** 1600,1606 **** \indent{The cursor for the entire Suite may be specified as an ASCII character literal. If the \sans{CursorFontName} is not specified, the default font is ! \italic{icon12}. Example: \sans{suite_Cursor( 'E' )}} --- 1600,1606 ---- \indent{The cursor for the entire Suite may be specified as an ASCII character literal. If the \sans{CursorFontName} is not specified, the default font is ! \italic{icon12}. The NULL character is reserved. Example: \sans{suite_Cursor( 'E' )}} *************** *** 1806,1812 **** \indent{The cursor for individual Items may be specified as an ASCII character literal. If the \sans{CursorFontName} is not specified, the default font is ! \italic{icon12}. Example: \sans{suite_ItemCursor( 'E' )}} --- 1806,1812 ---- \indent{The cursor for individual Items may be specified as an ASCII character literal. If the \sans{CursorFontName} is not specified, the default font is ! \italic{icon12}. The NULL character is reserved. Example: \sans{suite_ItemCursor( 'E' )}} *************** *** 2667,2675 **** (Presently, Printing of Suites is not supported.) ! \begindata{bp,269435404} ! \enddata{bp,269435404} ! \view{bpv,269435404,14,0,0} \chapter{2 Facilities} --- 2667,2675 ---- (Presently, Printing of Suites is not supported.) ! \begindata{bp,269572496} ! \enddata{bp,269572496} ! \view{bpv,269572496,12,0,0} \chapter{2 Facilities} *************** *** 3980,3988 **** } ! \begindata{bp,269423628} ! \enddata{bp,269423628} ! \view{bpv,269423628,15,0,0} \chapter{3 Sample Programs} --- 3980,3988 ---- } ! \begindata{bp,269572452} ! \enddata{bp,269572452} ! \view{bpv,269572452,13,0,0} \chapter{3 Sample Programs} *************** *** 3993,3999 **** \center{ ! \begindata{zip,268913300} %ViewWidth 485 %ViewHeight 544 *N;-1325,234 --- 3993,3999 ---- \center{ ! \begindata{zip,269111628} %ViewWidth 485 %ViewHeight 544 *N;-1325,234 *************** *** 4253,4260 **** TSerial MCM ! \enddata{zip,268913300} ! \view{zipview,268913300,5,487,546} } --- 4253,4260 ---- TSerial MCM ! \enddata{zip,269111628} ! \view{zipview,269111628,14,487,546} } *************** *** 4262,4270 **** See \italic{Sample Programs}, following. ! \begindata{bp,269428432} ! \enddata{bp,269428432} ! \view{bpv,269428432,16,0,0} \section{3.1 Simple Button Suite} --- 4262,4270 ---- See \italic{Sample Programs}, following. ! \begindata{bp,269110488} ! \enddata{bp,269110488} ! \view{bpv,269110488,15,0,0} \section{3.1 Simple Button Suite} *************** *** 4340,4346 **** \center{ ! \begindata{zip,268974468} %ViewWidth 212 %ViewHeight 191 *D;-1124,1153 --- 4340,4346 ---- \center{ ! \begindata{zip,269541752} %ViewWidth 212 %ViewHeight 191 *D;-1124,1153 *************** *** 4403,4410 **** TOrange MCM ! \enddata{zip,268974468} ! \view{zipview,268974468,6,214,193} } --- 4403,4410 ---- TOrange MCM ! \enddata{zip,269541752} ! \view{zipview,269541752,16,214,193} } *************** *** 4644,4652 **** xxx ! \begindata{bp,269419672} ! \enddata{bp,269419672} ! \view{bpv,269419672,17,0,0} \chapter{4 Problem Determination} --- 4644,4652 ---- xxx ! \begindata{bp,269559232} ! \enddata{bp,269559232} ! \view{bpv,269559232,17,0,0} \chapter{4 Problem Determination} *************** *** 4695,4698 **** xxx ! \enddata{text,268682652} --- 4695,4698 ---- xxx ! \enddata{text,269076168} *** atk/apt/suite/suite.c Wed Apr 11 14:17:49 1990 --- atk/apt/suite/suite.c.NEW Thu Jul 12 12:56:49 1990 *************** *** 1,4 **** ! /* ********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ --- 1,4 ---- ! /*********************************************************************** *\ * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ *************** *** 7,13 **** /* $Source $ */ #ifndef lint ! static char *rcsidsuite_c = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/apt/suite/RCS/suite.c,v 1.29 90/03/05 12:14:49 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* --- 7,13 ---- /* $Source $ */ #ifndef lint ! static char *rcsidsuite_c = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/apt/suite/RCS/suite.c,v 1.35 90/06/13 19:01:45 gk5g Exp Locker: gk5g $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* *************** *** 34,86 **** HISTORY - 11/01/88 Created (GW Keim) - 05/04/89 Changed to lower-case naming convention (GW Keim) - 05/23/89 Removed extra pixel around the suite border; - Added hooks to determine the window system; - Fixed up AssignSetAndTitleSpace() to get rid of the - extra pixels at the right and bottom of the suite;(GW Keim) - 05/26/89 Added text_AlwaysInsertCharacters() to - suite_SetItemToReadWrite() so that the initial RW caption - shows up; - 06/05/89 Fixed 'Detail' core-dump by setting NewFirstVisible to NULL - in suite_ClearItems() (GW Keim) - 06/11/89 Added call to suite_SetOptions(aptv_SuppressControl|aptv_SuppressBorder) - to suite_InitializeObject(). - 07/19/89 Added call to view_UnlinkTree(item->viewobject) in suite_DestroyItem() for - the case of a child-inset being destroyed; (GW Keim) - 07/28/89 Removed methods suite_ChangeTitleCaption, ChangeItemCaption, - and a few others, whose responsiblities are now handled by the - the new methods suite_ChangeSuiteAttribute and - suite_ChangeItemAttribute; (GW Keim) - 07/28/89 Re-added check for List attribute in TitleFits(); (GW Keim) - 07/29/89 Improve Error Msgs (TCP) - 08/02/89 Added method suite_ItemAtPosition(); (GW Keim) - 08/07/89 Fixed suite_ChangeItemAttribute() to call ChangeItemAttribute - instead of SetItemAttribute(); (GW Keim) - 09/01/89 Added SortStub() routine to be called by qsort() when a SortHandler - has been defined; - Added various state values to suite_Reset() and better updating support; (GW Keim) - 09/08/89 Added support for caption-alignment, suite_Line title-borders, - and titleviews; (GW Keim) - 09/13/89 Restore lost semi-colon at line 853 (TCP) - 09/14/89 In suite_FullUpdate() take away one pixel from the Bounds and Container - rectangle's width and height only if the appropriate guttersize is - greater than 0; (GW Keim) - 09/29/89 Made the test in CaptionsFit() a little more realistic by taking into account - the BorderSizes; - Made DrawTitle() smarter about scaling the TitleFont to make the Title fit; - Set the ClippingRect for the title; - Use BETWEENTOPANDBOTTOM instead of TOPANDBASELINE for title; - Fixed a bug with the Font{Low,High} being re-set incorrectly when specified - prior to the FontName; - Added call to suiteev_Clear() prior to FullUpdates in ChangeSuiteAttribute(); - Added assignments CurrentItem = item in suite_{Passivate,Normalize}Item(); - In SetItemAttribute() set the item fonts to NULL when a new fontname - is set for an item; (GW Keim) END-SPECIFICATION ************************************************************/ - #include #include #include --- 34,41 ---- *************** *** 270,619 **** static long Within( x, y, left, top, width, height ) ! register long x, y, left, top, width, height; { ! return((x >= left) && (x <= left + width) && (y >= top) && (y <= top + height)); } static long WithinRect( x, y, r ) ! register long x, y; ! register struct rectangle *r; { ! return(Within(x,y,r->left,r->top,r->width,r->height)); } static char * strip( str ) ! register char *str; { ! register char *tmp = NULL, *head = NULL; ! if(!str) return(str); ! tmp = head = str; ! while(*str == 040) str++; ! while(*tmp++ = *str++); ! tmp = head + strlen(head) - 1; ! while(*tmp == 040) tmp--; ! *(tmp+1) = '\0'; ! return(head); } boolean suite__InitializeClass( ClassID ) ! register struct classheader *ClassID; { ! proctable_DefineProc("suite-set-items", ! SetItems, &suite_classinfo, ! "suite", "Set item list (colon separated list)"); ! proctable_DefineProc("suite-set-attribute", ! SetAttrByName, &suite_classinfo, ! "suite", "Set an attribute for suite"); ! proctable_DefineProc("suite-set-item-attribute", ! SetEltAttrByName, &suite_classinfo, ! "suite", "Set an attribute for one item of a suite"); ! proctable_DefineProc("suite-set-with-value-name", ! SetValByName, &suite_classinfo, ! "suite", "Set an attribute for suite; pass name of value"); ! proctable_DefineProc("suite-set-item-with-value-name", ! SetEltValByName, &suite_classinfo, ! "suite", "Set attr for an item; pass name of value"); ! return(TRUE); } boolean suite__InitializeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct suite *self; { ! IN(suite_InitializeObject); ! if(!(Items = vector_Create(100,3)) || ! !(SetView = suiteev_New()) || ! !(Apt = apt_New())) ! HandleException(self,NULL,suite_InsufficientSpace); ! suite_SetDataObject(self,Apt); ! Datum = 0; ! CurrentItem = NULL; ! SetView->parent = self; ! ContainerLeft = ContainerTop = ContainerWidth = ContainerHeight = 0; ! ItemOrder = suite_RowMajor; ! TitleCaption = NULL; ! rectangle_SetRectSize(&TitleRect,0,0,0,0); ! TitleHighlightStyle = suite_Invert; ! TitleBorderStyle = suite_None; ! TitleBorderSize = 1; ! TitleDataObjectName = NULL; ! TitleDataObject = NULL; ! TitleDataObjectHandler = NULL; ! TitleViewObjectHandler = NULL; ! TitleHighlighted = FALSE; ! Arrangement = suite_Matrix | suite_Balanced; ! SelectionMode = suite_Exclusive; ! TitlePlacement = suite_Top; ! TitleCaptionAlignment = suite_Middle | suite_Center; ! ItemTitlePlacement = TitlePlacement; ! ItemTitleCaptionAlignment = suite_Middle | suite_Center; ! BorderSize = 1; ! BorderStyle = suite_Rectangle; ! Scroll = NULL; ! rectangle_SetRectSize(&ScrollRect,0,0,0,0); ! ScrollType = 0; ! HitHandler = 0; ! TitleHitHandler = 0; ! TitleViewObjectName = NULL; ! TitleViewObject = NULL; ! TitleFontName = NULL; ! AllocNameSpace(&TitleFontName,"andytype"); ! TitleFont = NULL; ! RealTitleFontSize = TitleFontSize = 12; ! TitleFontLow = TitleFontHigh = 0; ! TitleFontType = RealTitleFontType = fontdesc_Plain; ! ItemTitleFontName = NULL; ! AllocNameSpace(&ItemTitleFontName,"andytype"); ! RealItemTitleFontSize = ItemTitleFontSize = 10; ! ItemTitleFontLow = ItemTitleFontHigh = 0; ! ItemTitleFontType = fontdesc_Plain; ! ItemViewObjectName = ItemDataObjectName = 0; ! ItemViewObjectHandler = ItemDataObjectHandler = 0; ! CaptionFontName = NULL; ! AllocNameSpace(&CaptionFontName,"andytype"); ! CaptionFont = NULL; ! RealCaptionFontSize = 0; ! CaptionFontSize = 10; ! CaptionFontLow = CaptionFontHigh = 0; ! CaptionFontType = fontdesc_Plain; ! CaptionAlignment = suite_Middle | suite_Center; ! ItemBorderStyle = suite_Rectangle; ! ItemBorderSize = 1; ! ItemHighlightStyle = suite_Invert; ! ItemPassiveStyle = suite_Pale; ! AccessType = suite_ReadOnly; ! FirstVisible = NewFirstVisible = LastVisible = NULL; ! VisibleRows = Rows = VisibleColumns = Columns = 0; ! ItemHeight = ItemWidth = ItemFixedWidth = ItemFixedHeight = 0; ! debug = Debug = 0; ! ExceptionHandler = 0; ! ExceptionStatus = 0; ! ExceptionItem = NULL; ! Cursor = NULL; ! CursorFontName = NULL; ! CursorFont = NULL; ! CursorByte = 0; ! ItemCursor = NULL; ! ItemCursorFontName = NULL; ! ItemCursorFont = NULL; ! ItemCursorByte = 0; ! SortHandler = 0; ! SortOrder = 0; ! ClientAnchor = 0; ! XGutterSize = YGutterSize = 1; ! ItemArray = NULL; ! HasFocus = FALSE; ! WindowSystem = 0; ! suite_SetOptions(self,aptv_SuppressControl | ! aptv_SuppressBorder | ! aptv_SuppressEnclosures); ! WrapStyle = suite_LeftIndent; ! MaxItemPosGiven = 0; ! OUT(suite_InitializeObject); ! return(TRUE); } void suite__FinalizeObject( ClassID, self ) ! struct classheader *ClassID; ! struct suite *self; { ! IN(suite_FinalizeObject); ! suite_ClearAllItems(self); ! if(Apt) apt_Destroy(Apt); ! if(Scroll) scroll_Destroy(Scroll); ! if(TitleCaption) free(TitleCaption); ! if(TitleDataObjectName) free(TitleDataObjectName); ! if(TitleViewObjectName) free(TitleViewObjectName); ! if(TitleDataObject) dataobject_Destroy(TitleDataObject); ! if(TitleViewObject) view_Destroy(TitleViewObject); ! if(TitleFontName) free(TitleFontName); ! if(CaptionFontName) free(CaptionFontName); ! if(ItemTitleFontName) free(ItemTitleFontName); ! if(ItemViewObjectName) free(ItemViewObjectName); ! if(ItemDataObjectName) free(ItemDataObjectName); ! OUT(suite_FinalizeObject); } void suite__ReceiveInputFocus( self ) ! register struct suite *self; { ! IN(suite_ReceiveInputFocus); ! HasFocus = TRUE; ! super_ReceiveInputFocus(self); ! OUT(suite_ReceiveInputFocus); } void suite__LoseInputFocus( self ) ! register struct suite *self; { ! IN(suite_LoseInputFocus); ! HasFocus = FALSE; ! super_LoseInputFocus(self); ! OUT(suite_LoseInputFocus); } struct suite * suite__Create( ClassID, suite, anchor ) ! struct classheader *ClassID; ! suite_Specification *suite; ! unsigned anchor; { ! register struct suite *self = NULL; ! if(!(self = suite_New())) ! HandleException(self,NULL,suite_InsufficientSpace); ! ClientAnchor = anchor; ! while(suite && suite->attribute) { ! SetSuiteAttribute(self,suite->attribute,suite->value); ! suite++; ! } ! if(SortHandler) ! if(Items) { ! vector_SetSortRoutine(Items,SortStub); ! vector_Sort(Items); ! } ! if(TitleDataObject && TitleDataObjectHandler) ! TitleDataObjectHandler(ClientAnchor,self,NULL,suite_TitleObject); ! if(TitleViewObject && TitleViewObjectHandler) ! TitleViewObjectHandler(ClientAnchor,self,NULL,suite_TitleObject); if(Items) { ! FirstVisible = ITEM(0); ! LastVisible = ITEM(vector_Count(Items) - 1); } ! OUT(suite_Create); ! return(self); } void suite__DestroyItem( self, item ) ! struct suite *self; ! struct suite_item *item; { ! IN(suite_DestroyItem); ! if(Items && item) { ! if(Active(item) && Exposed(item)) { ! item->mode &= ~item_Active; ! if(IsLinked) suite_HideItem(self,item); ! } ! vector_RemoveItem(Items,item); ! FinalizeItem(item); ! item = NULL; } ! OUT(suite_DestroyItem); } struct suite_item * suite__CreateItem( self, name, datum ) ! register struct suite *self; ! register char *name; ! register long datum; { ! register struct suite_item *item = NULL; ! IN(CreateItem); ! item = GenerateItem(self,NULL,name,datum); ! OUT(CreateItem); ! return(item); } static long BreakSorter( item1, item2 ) ! register long *item1, *item2; { ! if(!item1 || !item2) return(0); ! if(*item1 < *item2) return(-1); ! else if(*item1 == *item2) return(0); ! else return(1); } static struct suite_item * GenerateItem( self, spec, name, datum ) ! register struct suite *self; ! register suite_Specification *spec; ! register char *name; ! register long datum; { ! register struct suite_item *item = NULL; ! IN(GenerateItem); ! if(!(item = AllocItem())) ! HandleException(self,NULL,suite_InsufficientSpace); ! if(!Items) { ! if(!(Items = vector_Create(100,3))) { ! HandleException(self,NULL,suite_InsufficientSpace); ! } ! else { ! if(SortHandler) vector_SetSortRoutine(Items,SortStub); ! else if(SortOrder) SetSortRoutine(self); ! } } ! if(spec) /* from static declaration */ ! while(spec && spec->attribute) { ! SetItemAttribute(self,item,spec->attribute,spec->value); ! spec++; ! } ! else { /* from CreateItem() */ ! if(name) AllocNameSpace(&item->name,name); ! item->datum = datum; } ! item->suite = self; ! item->exposed = TRUE; ! item->mode = item_Active | item_Normalized; ! Breaks(item) = vector_Create(5,2); ! vector_SetSortRoutine(Breaks(item),BreakSorter); ! vector_AddItem(Items,item); ! OUT(GenerateItem); ! return(item); } static boolean TitleFits( self, title_rect, title_sub_rect ) ! register struct suite *self; ! register struct rectangle *title_rect, *title_sub_rect; { ! register boolean status = TRUE; ! IN(TitleFits); ! if( (title_sub_rect->left <= title_rect->left) || ! ((title_sub_rect->left + title_sub_rect->width) >= ! (title_rect->left + title_rect->width)) || ! (title_sub_rect->top <= title_rect->top) || ! ((title_sub_rect->top + title_sub_rect->height) >= ! (title_rect->top + title_rect->height)) ) ! status = FALSE; ! OUT(TitleFits); ! return(status); } static boolean ItemsFit( self ) ! register struct suite *self; { ! long width = 0, height = 0; ! register long numItems = suiteev_NumberExposed(SetView); ! register boolean status = TRUE; ! IN(ItemsFit); ! if(numItems == 0 || List) return(TRUE); ! suiteev_MaxStringSize(SetView,&width,&height); ! if(((ItemWidth - (2 * ItemBorderSize)) < width) || ! ((ItemHeight - (2 * ItemBorderSize)) < height) || ! ((width + ( 2 * ItemBorderSize )) > ContainerWidth) || ! ((height +( 2 * ItemBorderSize )) > ContainerHeight)) { ! status = FALSE; ! } ! OUT(ItemsFit); ! return(status); } #define TITLE_ONLY 0 --- 225,574 ---- static long Within( x, y, left, top, width, height ) ! register long x, y, left, top, width, height; { ! return((x >= left) && (x <= left + width) && (y >= top) && (y <= top + height)); } static long WithinRect( x, y, r ) ! register long x, y; ! register struct rectangle *r; { ! return(Within(x,y,r->left,r->top,r->width,r->height)); } static char * strip( str ) ! register char *str; { ! register char *tmp = NULL, *head = NULL; ! if(!str) return(str); ! tmp = head = str; ! while(*str == 040) str++; ! while(*tmp++ = *str++); ! tmp = head + strlen(head) - 1; ! while(*tmp == 040) tmp--; ! *(tmp+1) = '\0'; ! return(head); } boolean suite__InitializeClass( ClassID ) ! register struct classheader *ClassID; { ! proctable_DefineProc("suite-set-items", ! SetItems, &suite_classinfo, ! "suite", "Set item list (colon separated list)"); ! proctable_DefineProc("suite-set-attribute", ! SetAttrByName, &suite_classinfo, ! "suite", "Set an attribute for suite"); ! proctable_DefineProc("suite-set-item-attribute", ! SetEltAttrByName, &suite_classinfo, ! "suite", "Set an attribute for one item of a suite"); ! proctable_DefineProc("suite-set-with-value-name", ! SetValByName, &suite_classinfo, ! "suite", "Set an attribute for suite; pass name of value"); ! proctable_DefineProc("suite-set-item-with-value-name", ! SetEltValByName, &suite_classinfo, ! "suite", "Set attr for an item; pass name of value"); ! return(TRUE); } boolean suite__InitializeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct suite *self; { ! IN(suite_InitializeObject); ! if(!(Items = vector_Create(100,3)) || ! !(SetView = suiteev_New()) || ! !(Apt = apt_New())) ! HandleException(self,NULL,suite_InsufficientSpace); ! suite_SetDataObject(self,Apt); ! Datum = 0; ! CurrentItem = NULL; ! SetView->parent = self; ! ContainerLeft = ContainerTop = ContainerWidth = ContainerHeight = 0; ! ItemOrder = suite_RowMajor; ! TitleCaption = NULL; ! rectangle_SetRectSize(&TitleRect,0,0,0,0); ! TitleHighlightStyle = suite_Invert; ! TitleBorderStyle = suite_None; ! TitleBorderSize = 1; ! TitleDataObjectName = NULL; ! TitleDataObject = NULL; ! TitleDataObjectHandler = NULL; ! TitleViewObjectHandler = NULL; ! TitleHighlighted = FALSE; ! Arrangement = suite_Matrix | suite_Balanced; ! SelectionMode = suite_Exclusive; ! TitlePlacement = suite_Top; ! TitleCaptionAlignment = suite_Middle | suite_Center; ! ItemTitlePlacement = TitlePlacement; ! ItemTitleCaptionAlignment = suite_Middle | suite_Center; ! BorderSize = 1; ! BorderStyle = suite_Rectangle; ! Scroll = NULL; ! rectangle_SetRectSize(&ScrollRect,0,0,0,0); ! ScrollType = 0; ! HitHandler = 0; ! TitleHitHandler = 0; ! TitleViewObjectName = NULL; ! TitleViewObject = NULL; ! TitleFontName = NULL; ! AllocNameSpace(&TitleFontName,"andytype"); ! TitleFont = NULL; ! RealTitleFontSize = TitleFontSize = 12; ! TitleFontLow = TitleFontHigh = 0; ! TitleFontType = RealTitleFontType = fontdesc_Plain; ! ItemTitleFontName = NULL; ! AllocNameSpace(&ItemTitleFontName,"andytype"); ! RealItemTitleFontSize = ItemTitleFontSize = 10; ! ItemTitleFontLow = ItemTitleFontHigh = 0; ! ItemTitleFontType = fontdesc_Plain; ! ItemViewObjectName = ItemDataObjectName = 0; ! ItemViewObjectHandler = ItemDataObjectHandler = 0; ! CaptionFontName = NULL; ! AllocNameSpace(&CaptionFontName,"andytype"); ! CaptionFont = NULL; ! RealCaptionFontSize = 0; ! CaptionFontSize = 10; ! CaptionFontLow = CaptionFontHigh = 0; ! CaptionFontType = fontdesc_Plain; ! CaptionAlignment = suite_Middle | suite_Center; ! ItemBorderStyle = suite_Rectangle; ! ItemBorderSize = 1; ! ItemHighlightStyle = suite_Invert; ! ItemPassiveStyle = suite_Pale; ! AccessType = suite_ReadOnly; ! FirstVisible = NewFirstVisible = LastVisible = NULL; ! VisibleRows = Rows = VisibleColumns = Columns = 0; ! ItemHeight = ItemWidth = ItemFixedWidth = ItemFixedHeight = 0; ! debug = Debug = 0; ! ExceptionHandler = 0; ! ExceptionStatus = 0; ! ExceptionItem = NULL; ! Cursor = NULL; ! CursorFontName = NULL; ! CursorFont = NULL; ! CursorByte = 0; ! ItemCursor = NULL; ! ItemCursorFontName = NULL; ! ItemCursorFont = NULL; ! ItemCursorByte = 0; ! SortHandler = 0; ! SortOrder = 0; ! ClientAnchor = 0; ! XGutterSize = YGutterSize = 1; ! ItemArray = NULL; ! HasFocus = FALSE; ! WindowSystem = 0; ! suite_SetOptions(self,aptv_SuppressControl | ! aptv_SuppressBorder | ! aptv_SuppressEnclosures); ! WrapStyle = suite_LeftIndent; ! MaxItemPosGiven = 0; ! OUT(suite_InitializeObject); ! return(TRUE); } void suite__FinalizeObject( ClassID, self ) ! struct classheader *ClassID; ! struct suite *self; { ! IN(suite_FinalizeObject); ! suite_ClearAllItems(self); ! if(Apt) apt_Destroy(Apt); ! if(Scroll) scroll_Destroy(Scroll); ! if(TitleCaption) free(TitleCaption); ! if(TitleDataObjectName) free(TitleDataObjectName); ! if(TitleViewObjectName) free(TitleViewObjectName); ! if(TitleDataObject) dataobject_Destroy(TitleDataObject); ! if(TitleViewObject) view_Destroy(TitleViewObject); ! if(TitleFontName) free(TitleFontName); ! if(CaptionFontName) free(CaptionFontName); ! if(ItemTitleFontName) free(ItemTitleFontName); ! if(ItemViewObjectName) free(ItemViewObjectName); ! if(ItemDataObjectName) free(ItemDataObjectName); ! OUT(suite_FinalizeObject); } void suite__ReceiveInputFocus( self ) ! register struct suite *self; { ! IN(suite_ReceiveInputFocus); ! HasFocus = TRUE; ! super_ReceiveInputFocus(self); ! OUT(suite_ReceiveInputFocus); } void suite__LoseInputFocus( self ) ! register struct suite *self; { ! IN(suite_LoseInputFocus); ! HasFocus = FALSE; ! super_LoseInputFocus(self); ! OUT(suite_LoseInputFocus); } struct suite * suite__Create( ClassID, suite, anchor ) ! struct classheader *ClassID; ! suite_Specification *suite; ! unsigned anchor; { ! register struct suite *self = NULL; ! if(!(self = suite_New())) ! HandleException(self,NULL,suite_InsufficientSpace); ! ClientAnchor = anchor; ! while(suite && suite->attribute) { ! SetSuiteAttribute(self,suite->attribute,suite->value); ! suite++; ! } ! if(SortHandler) if(Items) { ! vector_SetSortRoutine(Items,SortStub); ! vector_Sort(Items); } ! if(TitleDataObject && TitleDataObjectHandler) ! TitleDataObjectHandler(ClientAnchor,self,NULL,suite_TitleObject); ! if(TitleViewObject && TitleViewObjectHandler) ! TitleViewObjectHandler(ClientAnchor,self,NULL,suite_TitleObject); ! if(Items) { ! FirstVisible = ITEM(0); ! LastVisible = ITEM(vector_Count(Items) - 1); ! } ! OUT(suite_Create); ! return(self); } void suite__DestroyItem( self, item ) ! struct suite *self; ! struct suite_item *item; { ! IN(suite_DestroyItem); ! if(Items && item) { ! if(Active(item) && Exposed(item)) { ! item->mode &= ~item_Active; ! if(IsLinked) suite_HideItem(self,item); } ! vector_RemoveItem(Items,item); ! FinalizeItem(item); ! item = NULL; ! } ! OUT(suite_DestroyItem); } struct suite_item * suite__CreateItem( self, name, datum ) ! register struct suite *self; ! register char *name; ! register long datum; { ! register struct suite_item *item = NULL; ! IN(CreateItem); ! item = GenerateItem(self,NULL,name,datum); ! OUT(CreateItem); ! return(item); } static long BreakSorter( item1, item2 ) ! register long *item1, *item2; { ! if(!item1 || !item2) return(0); ! if(*item1 < *item2) return(-1); ! else if(*item1 == *item2) return(0); ! else return(1); } static struct suite_item * GenerateItem( self, spec, name, datum ) ! register struct suite *self; ! register suite_Specification *spec; ! register char *name; ! register long datum; { ! register struct suite_item *item = NULL; ! IN(GenerateItem); ! if(!(item = AllocItem())) ! HandleException(self,NULL,suite_InsufficientSpace); ! if(!Items) { ! if(!(Items = vector_Create(100,3))) { ! HandleException(self,NULL,suite_InsufficientSpace); } ! else { ! if(SortHandler) vector_SetSortRoutine(Items,SortStub); ! else if(SortOrder) SetSortRoutine(self); } ! } ! if(spec) /* from static declaration */ ! while(spec && spec->attribute) { ! SetItemAttribute(self,item,spec->attribute,spec->value); ! spec++; ! } ! else { /* from CreateItem() */ ! if(name) AllocNameSpace(&item->name,name); ! item->datum = datum; ! } ! item->suite = self; ! item->exposed = TRUE; ! item->mode = item_Active | item_Normalized; ! Breaks(item) = vector_Create(5,2); ! vector_SetSortRoutine(Breaks(item),BreakSorter); ! vector_AddItem(Items,item); ! OUT(GenerateItem); ! return(item); } static boolean TitleFits( self, title_rect, title_sub_rect ) ! register struct suite *self; ! register struct rectangle *title_rect, *title_sub_rect; { ! register boolean status = TRUE; ! IN(TitleFits); ! if((title_sub_rect->left <= title_rect->left) || ! ((title_sub_rect->left + title_sub_rect->width) >= ! (title_rect->left + title_rect->width)) || ! (title_sub_rect->top <= title_rect->top) || ! ((title_sub_rect->top + title_sub_rect->height) >= ! (title_rect->top + title_rect->height)) ) ! status = FALSE; ! OUT(TitleFits); ! return(status); } static boolean ItemsFit( self ) ! register struct suite *self; { ! long width = 0, height = 0; ! register long numItems = suiteev_NumberExposed(SetView); ! register boolean status = TRUE; ! IN(ItemsFit); ! if(numItems == 0 || List) return(TRUE); ! suiteev_MaxStringSize(SetView,&width,&height); ! if(((ItemWidth - (2 * ItemBorderSize)) < width) || ! ((ItemHeight - (2 * ItemBorderSize)) < height) || ! ((width + ( 2 * ItemBorderSize )) > ContainerWidth) || ! ((height +( 2 * ItemBorderSize )) > ContainerHeight)) { ! status = FALSE; ! } ! OUT(ItemsFit); ! return(status); } #define TITLE_ONLY 0 *************** *** 621,1585 **** static void DecrementFontSizes( self, which ) ! struct suite *self; ! boolean which; { ! if((which == TITLE_ONLY) && (RealTitleFontSize > TitleFontLow)) { ! RealTitleFontSize -= 2; ! TitleFont = fontdesc_Create(TitleFontName,RealTitleFontType,RealTitleFontSize); ! } ! if((which == CAPTIONS_ONLY) && (RealCaptionFontSize > CaptionFontLow)) { ! RealCaptionFontSize -= 2; ! CaptionFont = fontdesc_Create(CaptionFontName,CaptionFontType,RealCaptionFontSize); ! } } boolean Arrange( self, rect ) ! register struct suite *self; ! register struct rectangle *rect; { ! struct rectangle suite, title_sect, title; ! register boolean title_fits = FALSE, captions_fit = FALSE; ! register long needs_scroll = FALSE; ! IN(Arrange); ! rectangle_SetRectSize(&suite,rect->left,rect->top,rect->width,rect->height); ! while((RealCaptionFontSize > CaptionFontLow) && ! (RealTitleFontSize > TitleFontLow)) { ! DecrementRect(rect,BorderSize); ! if(TitleCaption) { ! AssignSetAndTitleSpace(self,&title_sect,rect); ! PlaceTitle(self,&title_sect,&title); ! } ! if(ScrollLeft) { ! rect->left += SCROLL_WIDTH; ! rect->width -= SCROLL_WIDTH; ! } ! if(ScrollTop) { ! rect->top += SCROLL_WIDTH; ! rect->height -= SCROLL_WIDTH; ! } ! if(ScrollBottom) rect->height -= SCROLL_WIDTH; ! if(ScrollRight) rect->width -= SCROLL_WIDTH; ! rectangle_SetRectSize(rect,0,0,rect->width,rect->height); ! if(!List) suiteev_Arrange(SetView,rect); ! if(TitleCaption && !(title_fits = TitleFits(self,&title_sect,&title))) ! DecrementFontSizes(self,TITLE_ONLY); ! if(!(captions_fit = ItemsFit(self))) DecrementFontSizes(self,CAPTIONS_ONLY); ! if(TitleCaption) { ! if(title_fits && captions_fit) break; ! } ! else if(captions_fit) break; ! rectangle_SetRectSize(rect,suite.left,suite.top,suite.width,suite.height); } ! if(Scroll) needs_scroll = TRUE; ! OUT(Arrange); ! return(needs_scroll); } static void SetMWidths( self ) ! struct suite *self; { ! struct fontdesc_charInfo M_Info; ! IN(SetMWidths); ! if(CaptionFont) { ! fontdesc_CharSummary(CaptionFont,suite_GetDrawable(self),'m',&M_Info); ! CaptionMWidth = M_Info.width; ! } ! if(TitleFont) { ! fontdesc_CharSummary(TitleFont,suite_GetDrawable(self),'m',&M_Info); ! TitleMWidth = M_Info.width; ! } ! OUT(SetMWidths); } void suite__Update( self ) ! register struct suite *self; { ! IN(suite_Update); ! suiteev_Clear(SetView); ! suiteev_Update(SetView); ! if(Scroll) scroll_Update(Scroll); ! OUT(suite_Update); } void suite__FullUpdate( self, type, left, top, width, height ) ! register struct suite *self; ! register enum view_UpdateType type; ! register long left, top, width, height; { ! struct rectangle *arrange_rect = NULL, *curse_rect = NULL, title; ! register boolean needs_scroll = FALSE; ! IN(suite_FullUpdate); ! if(!strcmp("AndrewWM",suite_GetWindowManagerType(self))) ! WindowSystem = WM; ! if((type != view_FullRedraw) && (type != view_LastPartialRedraw)) return; ! suite_GetVisualBounds(self,&Bounds); ! suite_GetVisualBounds(self,&Container); ! if(!(BorderStyle & suite_None) && (BorderSize > 0)) { ! DecrementRect(&Bounds,1); ! DecrementRect(&Container,1); } ! arrange_rect = rectangle_Duplicate(&Container); ! SetTransferMode(self,graphic_WHITE); ! suite_FillRect(self,&Container,suite_WhitePattern(self)); ! curse_rect = rectangle_Duplicate(&Container); ! if(!Cursor) { ! Cursor = cursor_Create(self); ! if(Cursor && CursorFont && (CursorByte != 0)) ! cursor_SetGlyph(Cursor,CursorFont,CursorByte); ! else if(CursorByte && (CursorByte != suite_NoCursor)) ! cursor_SetStandard(Cursor,CursorByte); ! else if(CursorByte != suite_NoCursor) ! cursor_SetStandard(Cursor,Cursor_Octagon); } ! RealCaptionFontSize = (List?CaptionFontSize:MAX(CaptionFontSize,CaptionFontHigh)); ! CaptionFont = fontdesc_Create(CaptionFontName,CaptionFontType,RealCaptionFontSize); ! RealTitleFontSize = MAX(TitleFontSize,TitleFontHigh); ! TitleFont = fontdesc_Create(TitleFontName,RealTitleFontType,RealTitleFontSize); ! SetMWidths(self); ! if(Scroll) scroll_LinkTree(Scroll,self); ! else suiteev_LinkTree(SetView,self); ! needs_scroll = Arrange(self,arrange_rect); ! SetMWidths(self); ! DrawOutline(self,&Container,BorderSize,BorderStyle); ! if(TitleCaption || TitleViewObjectName || TitleDataObjectName ) { ! AssignSetAndTitleSpace(self,&title,&Container); ! DrawTitle(self,&title); ! if(TitleHighlighted) suite_HighlightTitle(self); } ! if(Scroll && needs_scroll) { DEBUG(Scroll); ! ScrollRect.left = ContainerLeft; ScrollRect.top = ContainerTop; ! ScrollRect.width = ContainerWidth; ScrollRect.height = ContainerHeight; ! if(ScrollLeft) { ! curse_rect->left += SCROLL_WIDTH; curse_rect->width -= SCROLL_WIDTH; ! ContainerLeft += SCROLL_WIDTH; ContainerWidth -= SCROLL_WIDTH; ! } ! if(ScrollRight) { ! curse_rect->width -= SCROLL_WIDTH; ! ContainerWidth -= SCROLL_WIDTH; ! } ! if(ScrollTop) { ! curse_rect->top += SCROLL_WIDTH; curse_rect->height -= SCROLL_WIDTH; ! ContainerTop += SCROLL_WIDTH; ContainerHeight -= SCROLL_WIDTH; ! } ! if(ScrollBottom) { ! curse_rect->width -= SCROLL_WIDTH; ! ContainerWidth -= SCROLL_WIDTH; ! } ! scroll_InsertView(Scroll,self,&ScrollRect); ! scroll_FullUpdate(Scroll,view_FullRedraw,0,0,ScrollRect.width,ScrollRect.height); } ! else { DEBUG(No Scroll); ! suiteev_InsertView(SetView,self,&Container); ! suiteev_FullUpdate(SetView,view_FullRedraw,0,0,ContainerWidth,ContainerHeight); ! } ! if(Cursor && (CursorByte != suite_NoCursor)) ! suite_PostCursor(self,curse_rect,Cursor); ! if(curse_rect) free(curse_rect); ! OUT(suite_FullUpdate); } static void DrawTitle( self, rect ) ! register struct suite *self; ! register struct rectangle *rect; { ! register long title_lines = NumberLines(TitleCaption), ! vert_point = 0, horiz_point = 0, i; ! struct rectangle title; ! char *tmp_title = NULL; ! register char *str = NULL, *next_str = NULL, *newline = NULL; ! long align = 0; ! boolean titleFits = FALSE; ! IN(DrawTitle); ! SetTransferMode(self,graphic_WHITE); ! suite_FillRect(self,rect,suite_WhitePattern(self)); ! SetTransferMode(self,graphic_BLACK); ! if(TitleCaption && (*TitleCaption != '\0')) { ! AllocNameSpace(&tmp_title,TitleCaption); ! str = next_str = tmp_title; ! DecrementRect(rect,1); ! DrawOutline(self,rect,TitleBorderSize,TitleBorderStyle); ! suite_SetClippingRect(self,rect); ! RealTitleFontSize = MAX(TitleFontSize,TitleFontHigh); ! while(!titleFits) { ! PlaceTitle(self,rect,&title); ! TitleFont = fontdesc_Create(TitleFontName,RealTitleFontType,RealTitleFontSize); ! if((titleFits = TitleFits(self,rect,&title)) || ! (RealTitleFontSize <= TitleFontLow)) break; ! else DecrementFontSizes(self,TITLE_ONLY); ! } ! horiz_point = title.left + title.width/2; ! vert_point = title.top + RealTitleFontSize/2; ! align = graphic_BETWEENTOPANDBOTTOM; ! if(TitleCaptionAlignment & suite_Left) { ! horiz_point = title.left + 1; ! align |= graphic_ATLEFT; ! } ! else if(TitleCaptionAlignment & suite_Right) { ! horiz_point = title.left + title.width - 1; ! align |= graphic_ATRIGHT; ! } ! else align |= graphic_BETWEENLEFTANDRIGHT; ! if(TitleFont) SetFont(self,TitleFont); ! for( i = 0 ; i < title_lines ; i++ ) { ! if(newline = (char*)rindex(next_str,'\n')) { ! next_str = newline + 1; ! *newline = NULL; ! } ! suite_MoveTo(self,horiz_point,vert_point); ! suite_DrawString(self,str,align); ! vert_point += RealTitleFontSize; ! str = next_str; ! } ! if(tmp_title) free(tmp_title); ! suite_ClearClippingRect(self); } ! else if(TitleViewObjectName || TitleDataObjectName) { ! if(TitleDataObjectName) { ! if(!TitleDataObject) ! TitleDataObject = ! (struct dataobject*)class_NewObject(TitleDataObjectName); ! if(TitleDataObject && TitleDataObjectHandler) ! TitleDataObjectHandler(ClientAnchor,self,NULL,suite_TitleObject); ! } ! if(!TitleViewObject) { ! if(!TitleViewObjectName) ! AllocNameSpace(&TitleViewObjectName, ! dataobject_ViewName(TitleDataObject)); ! TitleViewObject = (struct view*)class_NewObject(TitleViewObjectName); ! if(TitleViewObject && TitleViewObjectHandler) ! TitleViewObjectHandler(ClientAnchor,self,NULL,suite_TitleObject); ! } ! view_SetDataObject(TitleViewObject,TitleDataObject); ! DrawOutline(self,rect,TitleBorderSize,TitleBorderStyle); ! view_InsertView(TitleViewObject,self,rect); ! view_FullUpdate(TitleViewObject,view_FullRedraw,0,0, ! rect->width,rect->height); } ! else { ! if(Debug) printf("Title gone; calling FullUpdate.\n"); ! suite_FullUpdate(self,view_FullRedraw,0,0,Bounds.width,Bounds.height); } ! OUT(DrawTitle); } static void CenterBiggestCircleInRect( self, rect ) ! register struct suite *self; ! register struct rectangle *rect; { ! register long circum = MIN(rect->width,rect->height), rad = circum/2; ! register long centerX = rect->left + rect->width/2, centerY = rect->top + rect->height/2; ! ! rectangle_SetRectSize(rect,centerX - rad,centerY - rad,circum,circum); } static void DrawOutline( self, rect, width, style ) ! register struct suite *self; ! register struct rectangle *rect; ! register short width; ! register unsigned style; { ! register long i = 0; ! register struct rectangle *inner = NULL; ! register long X1 = 0, Y1 = 0, X2 = 0, Y2 = 0; ! IN(DrawOutline); ! SetTransferMode(self,graphic_BLACK); ! if(style & (suite_Invisible | suite_None)) return; ! else if(style & suite_Line) { ! if(TitlePlacement & suite_Top) { ! X1 = rect->left; Y1 = rect->top + rect->height; ! X2 = X1 + rect->width; Y2 = Y1; ! } ! else if(TitlePlacement & suite_Bottom) { ! X1 = rect->left; Y1 = rect->top; ! X2 = X1 + rect->width; Y2 = Y1; ! } ! else if(TitlePlacement & suite_Left) { ! X1 = rect->left + rect->width; Y1 = rect->top; ! X2 = X1; Y2 = Y1 + rect->height; ! } ! else if(TitlePlacement & suite_Right) { ! X1 = rect->left; Y1 = rect->top; ! X2 = X1; Y2 = Y1 + rect->height; ! } ! suite_MoveTo(self,X1,Y1); ! suite_DrawLineTo(self,X2,Y2); } ! else if(style & suite_Rectangle) { ! for( i = 0 ; i < width ; i++ ) { ! DrawRect(self,rect); ! DecrementRect(rect,1); ! } } ! else if(style & suite_Roundangle) { ! inner = rectangle_Duplicate(rect); ! DecrementRect(inner,5); ! suite_DrawRRect(self,rect,inner); ! DecrementRect(rect,5); } ! else if(style & suite_Circle) ! CenterBiggestCircleInRect(self,rect); ! if((style & suite_Oval) || (style & suite_Circle)) { ! for( i = 0 ; i < width ; i++ ) { ! suite_DrawOval(self,rect); ! DecrementRect(rect,1); ! } } ! SetTransferMode(self,graphic_BLACK); ! OUT(DrawOutline); } struct view * suite__Hit( self, action, x, y, numberOfClicks ) ! register struct suite *self; ! register enum view_MouseAction action; ! register long x, y, numberOfClicks; { ! struct view *retval = (struct view*)self; ! IN(suite_Hit); ! if(Scroll) { ! if(WithinRect(x,y,&ScrollRect)) ! retval = scroll_Hit(Scroll,action,x - ScrollRect.left, ! y - ScrollRect.top,numberOfClicks); ! } ! else { ! if(Within(x - ContainerLeft,y - ContainerTop,0,0, ! ContainerWidth,ContainerHeight)) ! retval = suiteev_Hit(SetView,action,x - ContainerLeft,y - ContainerTop, ! numberOfClicks); ! } ! if(WithinRect(x,y,&TitleRect)) { ! if(TitleHitHandler) ! TitleHitHandler(ClientAnchor,self,NULL,suite_TitleObject, action,x,y,numberOfClicks); ! else if(HitHandler) ! HitHandler(ClientAnchor,self,NULL,suite_TitleObject, ! action,x,y,numberOfClicks); ! else if(TitleViewObject) ! retval = view_Hit(TitleViewObject,action,x,y,numberOfClicks); ! } ! return((struct view*)retval); } long suite__Reset( self, state ) ! register struct suite *self; ! register long state; { ! register long i = 0, status = 0; ! register struct suite_item *item = NULL; ! boolean onScreen = FALSE, doFullRedraw = FALSE; ! boolean doContainerRedraw = FALSE; ! if(!(state & suite_Defer)) state |= suite_Immediate; ! if(state & suite_Clear) { ! suite_ClearAllItems(self); ! suite_SetSuiteAttribute(self,suite_TitleCaption(NULL)); ! doFullRedraw = TRUE; ! } ! if(state & suite_ClearItems) { ! suite_ClearAllItems(self); ! doContainerRedraw = TRUE; ! } ! if(state & suite_ClearTitle) { ! suite_SetSuiteAttribute(self,suite_TitleCaption(NULL)); ! doFullRedraw = TRUE; ! } ! if(state & suite_Activate) { ! if(Items && ITEM(0)) { ! while(item = ITEM(i++)) { ! if(FirstVisible && (FirstVisible == item)) onScreen = TRUE; ! if(Exposed(item) && !Active(item)) { ! suite_ActivateItem(self,item); ! if((state & suite_Immediate) && onScreen) ! suiteev_ItemNormalize(SetView,item); ! } ! else if(Exposed(item) && Highlighted(item)) ! if((state & suite_Immediate) && onScreen) ! suiteev_ItemNormalize(SetView,item); ! else if((state & suite_Expose) && !Exposed(item)) { ! item->exposed = TRUE; ! doContainerRedraw = TRUE; ! } ! item->mode = ((item_Active | item_Normalized) & ~item_Highlighted); ! if(LastVisible && (LastVisible == item)) onScreen = FALSE; ! } } ! else status = -1; } ! if(state & suite_Normalize) { ! if(Items && ITEM(0)) { ! while(item = ITEM(i++)) { ! if(FirstVisible && (FirstVisible == item)) onScreen = TRUE; ! if(Exposed(item) && Active(item) && Highlighted(item)) { ! if((state & suite_Immediate) && onScreen) ! suiteev_ItemNormalize(SetView,item); ! else item->mode = ((item_Active | item_Normalized) & ! ~item_Highlighted); ! } ! else if((state & suite_Expose) && !Exposed(item)) { ! item->exposed = TRUE; ! doContainerRedraw = TRUE; ! } ! if(LastVisible && (LastVisible == item)) onScreen = FALSE; ! } } } ! if(doFullRedraw && IsLinked) { ! suiteev_Clear(SetView); ! suite_FullUpdate(self,view_FullRedraw,0,0,0,0); ! } ! else if(doContainerRedraw && IsLinked) { ! suiteev_Clear(SetView); ! suiteev_FullUpdate(SetView,view_FullRedraw, ! 0,0,ContainerWidth,ContainerHeight); ! if(Scroll) scroll_Update(Scroll); ! } ! return(status); } void suite__ClearAllItems( self ) ! struct suite *self; { ! register int i = 0, count = 0; ! register struct suite_item *item = NULL; ! IN(suite_ClearAllItems); ! if(Items && ITEM(0)) { ! count = vector_Count(Items); ! for( i = 0 ; i < count ; i++ ){ ! item = ITEM(i); ! FinalizeItem(item); ! item = NULL; ! } ! vector_Destroy(Items); ! Items = NULL; } ! NewFirstVisible = FirstVisible = LastVisible = NULL; ! OUT(suite_ClearAllItems); } static long TitleSectionWidth( self ) ! struct suite *self; { ! register char *title = NULL, *newline = NULL, *tmp = NULL; ! long numLines = 0, XWidth = 0, YWidth = 0, maxWidth = 0; ! register long i = 0; ! if(TitleCaption) { ! tmp = title = (char*) malloc(strlen(TitleCaption) + 1); ! strcpy(title,TitleCaption); ! numLines = NumberLines(TitleCaption); ! for ( i = 0 ; i < numLines ; i++ ) { ! if(newline = (char*) rindex(tmp,'\n')) { ! *newline = NULL; ! fontdesc_StringSize(TitleFont,suite_GetDrawable(self),tmp, ! &XWidth,&YWidth); ! tmp = newline + 1; ! } ! else fontdesc_StringSize(TitleFont,suite_GetDrawable(self),tmp, ! &XWidth,&YWidth); ! if(XWidth > maxWidth) maxWidth = XWidth; ! } ! free(title); } ! else if(TitleViewObjectName || TitleDataObjectName) { ! if(TitlePlacement & (suite_Top | suite_Bottom)) ! maxWidth = ContainerWidth; ! else maxWidth = ContainerWidth/3; ! } ! return(maxWidth); } static long TitleSectionHeight( self ) ! struct suite *self; { ! IN(TitleSectionHeight); ! if(TitleCaption) return(NumberLines(TitleCaption) * RealTitleFontSize); ! else if(TitleViewObjectName || TitleDataObjectName) { ! if(TitlePlacement & (suite_Top | suite_Bottom)) ! return(ContainerHeight/3); ! else return(ContainerHeight); ! } ! OUT(TitleSectionHeight); } static void AssignSetAndTitleSpace( self, title, container ) ! register struct suite *self; ! register struct rectangle *title, *container; { ! register long TitleHeight = TitleSectionHeight(self), TitleWidth = TitleSectionWidth(self); ! switch(TitlePlacement) { ! case suite_Top: ! title->left = container->left; ! title->width = container->width; ! title->top = container->top; ! title->height = TitleHeight + TitleMWidth; ! container->top = title->top + title->height; ! container->height -= title->height; ! break; ! case suite_Bottom: ! title->left = container->left; ! title->width = container->width; ! title->height = TitleHeight + TitleMWidth; ! title->top = container->top + container->height - ! title->height; ! container->height -= title->height; ! break; ! case suite_Left: ! title->left = container->left; ! title->top = container->top; ! title->width = TitleWidth + TitleMWidth; ! title->height = container->height; ! container->left = title->left + title->width; ! container->width -= title->width; ! break; ! case suite_Right: ! title->top = container->top; ! title->height = container->height; ! title->width = TitleWidth + TitleMWidth; ! title->left = container->left + container->width - ! title->width; ! container->width -= title->width; ! break; ! } ! rectangle_SetRectSize(&TitleRect,title->left,title->top, title->width,title->height); } static void PlaceTitle( self, title_sect, title ) ! struct suite *self; ! struct rectangle *title_sect, *title; { ! register long Width = TitleSectionWidth(self), Height = TitleSectionHeight(self); ! register unsigned alignment = TitleCaptionAlignment; ! title->left = title_sect->left + (title_sect->width - Width)/2; ! title->top = title_sect->top + (title_sect->height - Height)/2; ! ! title->width = Width; title->height = Height; ! if(alignment & suite_Left) { ! title->left = title_sect->left + 2; ! } ! else if(alignment & suite_Right) { ! title->left = title_sect->left + (title_sect->width - Width) - 2; ! } ! if(alignment & suite_Top) { ! title->top = title_sect->top + 2; ! } ! else if(alignment & suite_Bottom) { ! title->top = title_sect->top + (title_sect->height - Height) - 2; ! } } static void SetCaptionList( self, captions ) ! register struct suite *self; ! register char **captions; { ! register char **ptr = captions; ! suite_ClearAllItems(self); ! if(ptr) { ! if(!(Items = vector_Create(100,3))) ! HandleException(self,NULL,suite_InsufficientSpace); ! else { ! if(SortHandler) ! vector_SetSortRoutine(Items,SortStub); ! else if(SortOrder) ! SetSortRoutine(self); ! } ! while(*ptr) ! if(!(suite_CreateItem(self,*ptr++,0))) ! HandleException(self,NULL,suite_InsufficientSpace); ! if(Items && ITEM(0)) { ! FirstVisible = ITEM(0); ! LastVisible = ITEM(vector_Count(Items) - 1); ! } } } static void ParseFontFullName( self, fullname, familyName, buffSize, size, type ) ! register struct suite *self; ! register char *fullname, *familyName; ! register long buffSize; ! register long *size, *type; { ! if(fullname && *fullname) fontdesc_ExplodeFontName(fullname,familyName, buffSize,(long)type,(long)size); } static void ChangeItemCaption( self, item, caption ) ! register struct suite *self; ! register struct suite_item *item; ! register char *caption; { ! register struct text *txt = NULL; ! register struct suitecv *CV = NULL; ! ValidateItem(self,item); ! AllocNameSpace(&item->caption,caption); ! if(item_AccessType & suite_ReadWrite) { ! text_Clear(txt = (struct text*) item->dataobject); ! text_InsertCharacters(txt,0,item->caption,strlen(item->caption)); ! suitecv_WantUpdate(CV = (struct suitecv*)item->viewobject,CV); ! } ! suiteev_ItemUpdate(SetView,item); } void suite__PassivateItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! register long mode = 0; ! if(item) { ! if(!Active(item)) return; ! if(IsLinked && (ItemPassiveStyle & suite_Removed)) ! suite_HideItem(self,item); ! else { ! mode = (item->mode & ~item_Active & ~item_Highlighted) | ! item_Normalized; ! if(ItemPassiveStyle & suite_Invisible) mode |= suite_Invisible; ! item->mode = mode; ! if(IsLinked) suiteev_ItemUpdate(SetView,item); ! } } } void suite__ActivateItem( self, item ) ! struct suite *self; ! struct suite_item *item; { ! register long mode = 0; ! if(item) { ! if(Active(item)) return; ! if(IsLinked && (ItemPassiveStyle & suite_Removed)) ! suite_ExposeItem(self,item); ! else { ! mode = (item->mode | item_Active | item_Normalized) & ! ~item_Highlighted; ! if(ItemPassiveStyle & suite_Invisible) mode |= ~suite_Invisible; ! item->mode = mode; ! if(IsLinked) suiteev_ItemUpdate(SetView,item); ! } } } static struct suite_item* AllocItem() { ! return((struct suite_item*) calloc(1,sizeof(struct suite_item))); } static void FinalizeItem( item ) ! register struct suite_item *item; { ! IN(FinalizeItem); ! if(Breaks(item)) vector_Destroy(Breaks(item)); ! if(item->caption) free(item->caption); ! if(item->title) free(item->title); ! if(item->titlefontname) free(item->titlefontname); ! if(item->captionfontname) free(item->captionfontname); ! if(item->viewobjectname) free(item->viewobjectname); ! if(item->dataobjectname) free(item->dataobjectname); ! if(item->viewobject) { ! view_UnlinkTree(item->viewobject); ! view_Destroy(item->viewobject); ! item->viewobject = NULL; ! } /*=== if(item->dataobject) dataobject_Destroy(item->dataobject); gk5g 5/1/89 ===*/ ! free(item); ! OUT(FinalizeItem); } static void SetSortRoutine( self ) ! register struct suite *self; { ! if(suite_Ascend & SortOrder) { ! if(suite_Alphabetic & SortOrder) ! vector_SetSortRoutine(Items,AlphasortAscend); ! else if(suite_Numeric & SortOrder) ! vector_SetSortRoutine(Items,NumericAscend); } - else if(suite_Descend & SortOrder) { - if(suite_Alphabetic & SortOrder) - vector_SetSortRoutine(Items,AlphasortDescend); - else if(suite_Numeric & SortOrder) - vector_SetSortRoutine(Items,NumericDescend); - } } static long SortStub( item1, item2 ) ! register struct suite_item **item1; ! register struct suite_item **item2; { ! register struct suite *self = NULL; ! register long status = 0; ! if(item1 && *item1 && item2 && *item2) { ! self = (*item1)->suite; ! if(self) status = SortHandler(ClientAnchor,self,*item1,*item2); ! } ! return status; } void suite__Sort( self, mode, handler ) ! register struct suite *self; ! register unsigned mode; ! register long (*handler)(); { ! IN(suite_Sort); ! suiteev_Clear(SetView); ! if(Items && ITEM(0)) { ! DEBUG(Sort); ! if(mode) SortOrder = mode; ! if(handler) { DEBUG(Handler); ! SortHandler = (long (*)())handler; ! vector_SetSortRoutine(Items,SortStub); ! } ! else SetSortRoutine(self); ! vector_Sort(Items); ! FirstVisible = ITEM(0); ! LastVisible = ITEM(vector_Count(Items) - 1); ! suiteev_FullUpdate(SetView,view_FullRedraw,0,0, ! ContainerWidth,ContainerHeight); ! if(Scroll) scroll_Update(Scroll); } ! OUT(suite_Sort); } void suite__Apply( self, proc, anchor, datum ) ! register struct suite *self; ! register long (*proc)(); ! register unsigned anchor, datum; { ! register int i = 0; ! register struct suite_item *item = NULL; ! register long status = 0; ! if(Items && ITEM(0)) ! while((item = ITEM(i++)) && (status >= 0)) ! status = proc(anchor,self,item,datum); } static long AlphasortAscend( item1, item2 ) ! register struct suite_item **item1, **item2; { ! register char *str1 = NULL, *str2 = NULL; ! if(!item1 || !*item1 || !item2 || !*item2) return(0); ! if((*item1)->caption) str1 = (*item1)->caption; ! else str1 = (*item1)->name; ! if((*item2)->caption) str1 = (*item2)->caption; ! else str2 = (*item2)->name; ! return(strcmp(str1,str2)); } static long NumericAscend( item1, item2 ) ! register struct suite_item **item1, **item2; { ! if(!item1 || !*item1 || !item2 || !*item2) return(0); ! if((*item1)->datum > (*item2)->datum) return(1); ! else if((*item1)->datum < (*item2)->datum) return(-1); ! else return(0); } static long AlphasortDescend( item1, item2 ) ! register struct suite_item **item1, **item2; { ! register char *str1 = NULL, *str2 = NULL; ! if(!item1 || !*item1 || !item2 || !*item2) return(0); ! if((*item1)->caption) str1 = (*item1)->caption; ! else str1 = (*item1)->name; ! if((*item2)->caption) str1 = (*item2)->caption; ! else str2 = (*item2)->name; ! return(-1 * strcmp(str1,str2)); } static long NumericDescend( item1, item2 ) ! register struct suite_item **item1, **item2; { ! if(!item1 || !*item1 || !item2 || !*item2) return(0); ! if((*item1)->datum < (*item2)->datum) return(-1); ! else if((*item1)->datum > (*item2)->datum) return(1); ! else return(0); } static void AllocNameSpace( target, source ) ! register char **target, *source; { ! if(target && *target) { ! free(*target); ! *target = NULL; ! } ! if(source && *source) { ! *target = malloc(strlen(source)+1); ! if(*target) strcpy(*target,source); ! } ! else *target = NULL; } struct suite_item ** suite__SelectedItems( self, number ) ! register struct suite *self; ! register long *number; { ! register struct suite_item *item = NULL; ! register int i = 0; ! register long count = 0, index = 0; ! if(Items && ITEM(0)) { ! while(item = ITEM(i++)) ! if(Exposed(item) && Active(item) && Highlighted(item)) count++; ! suiteev_AllocItemArray(SetView,count); ! if(ItemArray) { ! i = 0; ! while(item = ITEM(i++)) ! if(Exposed(item) && Active(item) && Highlighted(item)) ! ItemArray[index++] = item; ! } ! } ! if(number) *number = count; ! return(ItemArray); } void suite__SetDebug( self, value ) ! register struct suite *self; ! register boolean value; { ! self->debug = SetView->debug = value; } static void SetArrangementAttribute( self, value ) ! register struct suite *self; ! register unsigned long value; { ! if(value & suite_List) ! Arrangement |= suite_List; ! if(value & suite_Matrix) { ! Arrangement &= (~suite_Row & ~suite_Column); ! Arrangement |= suite_Matrix; ! } ! if(value & suite_Row) { ! Arrangement &= (~suite_Matrix & ~suite_Column); ! Arrangement |= suite_Row; ! } ! if(value & suite_Column) { ! Arrangement &= (~suite_Matrix & ~suite_Row); ! Arrangement |= suite_Column; ! } ! if(value & suite_Balanced) { ! Arrangement &= ~suite_Unbalanced; ! Arrangement |= suite_Balanced; ! } ! if(value & suite_Unbalanced) { ! Arrangement &= ~suite_Balanced; ! Arrangement |= suite_Unbalanced; ! } ! if(value & suite_RowLine) Arrangement |= suite_RowLine; ! if(value & suite_ColumnLine) Arrangement |= suite_ColumnLine; } static void SetBorderStyleAttribute( self, border_style, value ) ! register struct suite *self; ! register unsigned int *border_style; ! register long value; { ! if(value & suite_Invisible) { ! *border_style &= ~suite_None; ! *border_style |= suite_Invisible; ! } ! if(value & suite_Rectangle) { ! *border_style &= (~suite_Roundangle & ~suite_Circle & ! ~suite_Oval & ~suite_None); ! *border_style |= suite_Rectangle; ! } ! if(value & suite_Roundangle) { ! *border_style &= (~suite_Rectangle & ~suite_Circle & ! ~suite_Oval & ~suite_None); ! *border_style |= suite_Roundangle; ! } ! if(value & suite_Circle) { ! *border_style &= (~suite_Rectangle & ~suite_Roundangle & ! ~suite_Oval & ~suite_None); ! *border_style |= suite_Circle; ! } ! if(value & suite_Oval) { ! *border_style &= (~suite_Rectangle & ~suite_Roundangle & ! ~suite_Circle & ~suite_None); ! *border_style |= suite_Oval; ! } ! if(value & suite_Line) { ! *border_style &= (~suite_Rectangle & ~suite_Roundangle & ! ~suite_Circle & ~suite_None & ~suite_Oval); ! *border_style |= suite_Line; ! } ! if(value & suite_None) { ! *border_style &= (~suite_Rectangle & ~suite_Roundangle & ! ~suite_Circle & ~suite_Oval); ! *border_style |= suite_None; ! } } static void SetSuiteAttribute( self, attribute, value ) ! register struct suite *self; ! register long attribute, value; { ! char Name[100]; ! long int Size, Type; ! IN(SetSuiteAttribute); ! switch(attribute) { case suite_titlecaption: ! AllocNameSpace(&TitleCaption,strip((char*)value)); break; case suite_titlehighlightstyle: TitleHighlightStyle = value; --- 576,1543 ---- static void DecrementFontSizes( self, which ) ! struct suite *self; ! boolean which; { ! if((which == TITLE_ONLY) && (RealTitleFontSize > TitleFontLow)) { ! RealTitleFontSize -= 2; ! TitleFont = fontdesc_Create(TitleFontName,RealTitleFontType,RealTitleFontSize); ! } ! if((which == CAPTIONS_ONLY) && (RealCaptionFontSize > CaptionFontLow)) { ! RealCaptionFontSize -= 2; ! CaptionFont = fontdesc_Create(CaptionFontName,CaptionFontType,RealCaptionFontSize); ! } } boolean Arrange( self, rect ) ! register struct suite *self; ! register struct rectangle *rect; { ! struct rectangle suite, title_sect, title; ! register boolean title_fits = FALSE, captions_fit = FALSE; ! register long needs_scroll = FALSE; ! IN(Arrange); ! rectangle_SetRectSize(&suite,rect->left,rect->top,rect->width,rect->height); ! while(TRUE) { ! DecrementRect(rect,BorderSize); ! if(TitleCaption) { ! AssignSetAndTitleSpace(self,&title_sect,rect); ! PlaceTitle(self,&title_sect,&title); } ! if(ScrollLeft) { ! rect->left += SCROLL_WIDTH; ! rect->width -= SCROLL_WIDTH; ! } ! if(ScrollTop) { ! rect->top += SCROLL_WIDTH; ! rect->height -= SCROLL_WIDTH; ! } ! if(ScrollBottom) rect->height -= SCROLL_WIDTH; ! if(ScrollRight) rect->width -= SCROLL_WIDTH; ! rectangle_SetRectSize(rect,0,0,rect->width,rect->height); ! if(!List) suiteev_Arrange(SetView,rect); ! if(TitleCaption && !(title_fits = TitleFits(self,&title_sect,&title))) { ! if(RealTitleFontSize > TitleFontLow) ! DecrementFontSizes(self,TITLE_ONLY); ! else title_fits = TRUE; ! } ! if(!(captions_fit = ItemsFit(self))) { ! if(RealCaptionFontSize > CaptionFontLow) ! DecrementFontSizes(self,CAPTIONS_ONLY); ! else captions_fit = TRUE; ! } ! if(TitleCaption) { ! if(title_fits && captions_fit) break; ! } ! else if(captions_fit) break; ! rectangle_SetRectSize(rect,suite.left,suite.top,suite.width,suite.height); ! } ! if(Scroll) needs_scroll = TRUE; ! OUT(Arrange); ! return(needs_scroll); } static void SetMWidths( self ) ! struct suite *self; { ! struct fontdesc_charInfo M_Info; ! IN(SetMWidths); ! if(CaptionFont) { ! fontdesc_CharSummary(CaptionFont,suite_GetDrawable(self),'m',&M_Info); ! CaptionMWidth = M_Info.width; ! } ! if(TitleFont) { ! fontdesc_CharSummary(TitleFont,suite_GetDrawable(self),'m',&M_Info); ! TitleMWidth = M_Info.width; ! } ! OUT(SetMWidths); } void suite__Update( self ) ! register struct suite *self; { ! IN(suite_Update); ! suiteev_Clear(SetView); ! suiteev_Update(SetView); ! if(Scroll) scroll_Update(Scroll); ! OUT(suite_Update); } void suite__FullUpdate( self, type, left, top, width, height ) ! register struct suite *self; ! register enum view_UpdateType type; ! register long left, top, width, height; { ! struct rectangle *arrange_rect = NULL, *curse_rect = NULL, title; ! register boolean needs_scroll = FALSE; ! IN(suite_FullUpdate); ! if(!strcmp("AndrewWM",suite_GetWindowManagerType(self))) ! WindowSystem = WM; ! if((type != view_FullRedraw) && (type != view_LastPartialRedraw)) return; ! suite_GetVisualBounds(self,&Bounds); ! suite_GetVisualBounds(self,&Container); ! if(!(BorderStyle & suite_None) && (BorderSize > 0)) { ! DecrementRect(&Bounds,1); ! DecrementRect(&Container,1); ! } ! arrange_rect = rectangle_Duplicate(&Container); ! SetTransferMode(self,graphic_WHITE); ! suite_FillRect(self,&Container,suite_WhitePattern(self)); ! curse_rect = rectangle_Duplicate(&Container); ! if(!Cursor) { ! Cursor = cursor_Create(self); ! if(Cursor && CursorFont && (CursorByte != suite_NoCursor)) ! cursor_SetGlyph(Cursor,CursorFont,CursorByte); ! else if(CursorByte != suite_NoCursor) ! cursor_SetStandard(Cursor,CursorByte); ! else cursor_SetStandard(Cursor,Cursor_Octagon); ! } ! RealCaptionFontSize = (List?CaptionFontSize:MAX(CaptionFontSize,CaptionFontHigh)); ! CaptionFont = fontdesc_Create(CaptionFontName,CaptionFontType,RealCaptionFontSize); ! RealTitleFontSize = MAX(TitleFontSize,TitleFontHigh); ! TitleFont = fontdesc_Create(TitleFontName,RealTitleFontType,RealTitleFontSize); ! SetMWidths(self); ! if(Scroll) scroll_LinkTree(Scroll,self); ! else suiteev_LinkTree(SetView,self); ! needs_scroll = Arrange(self,arrange_rect); ! SetMWidths(self); ! DrawOutline(self,&Container,BorderSize,BorderStyle); ! if(TitleCaption || TitleViewObjectName || TitleDataObjectName ) { ! AssignSetAndTitleSpace(self,&title,&Container); ! DrawTitle(self,&title); ! if(TitleHighlighted) suite_HighlightTitle(self); ! } ! if(Scroll && needs_scroll) { DEBUG(Scroll); ! ScrollRect.left = ContainerLeft; ScrollRect.top = ContainerTop; ! ScrollRect.width = ContainerWidth; ScrollRect.height = ContainerHeight; ! if(ScrollLeft) { ! curse_rect->left += SCROLL_WIDTH; curse_rect->width -= SCROLL_WIDTH; ! ContainerLeft += SCROLL_WIDTH; ContainerWidth -= SCROLL_WIDTH; } ! if(ScrollRight) { ! curse_rect->width -= SCROLL_WIDTH; ! ContainerWidth -= SCROLL_WIDTH; } ! if(ScrollTop) { ! curse_rect->top += SCROLL_WIDTH; curse_rect->height -= SCROLL_WIDTH; ! ContainerTop += SCROLL_WIDTH; ContainerHeight -= SCROLL_WIDTH; } ! if(ScrollBottom) { ! curse_rect->width -= SCROLL_WIDTH; ! ContainerWidth -= SCROLL_WIDTH; } ! scroll_InsertView(Scroll,self,&ScrollRect); ! scroll_FullUpdate(Scroll, view_FullRedraw, 0, 0, ScrollRect.width, ScrollRect.height); ! } ! else { DEBUG(No Scroll); ! suiteev_InsertView(SetView,self,&Container); ! suiteev_FullUpdate(SetView,view_FullRedraw,0,0, ContainerWidth, ContainerHeight); ! } ! if(Cursor) suite_PostCursor(self,curse_rect,Cursor); ! if(curse_rect) free(curse_rect); ! OUT(suite_FullUpdate); } static void DrawTitle( self, rect ) ! register struct suite *self; ! register struct rectangle *rect; { ! register long title_lines = NumberLines(TitleCaption), ! vert_point = 0, horiz_point = 0, i; ! struct rectangle title; ! char *tmp_title = NULL; ! register char *str = NULL, *next_str = NULL, *newline = NULL; ! long align = 0; ! boolean titleFits = FALSE; ! IN(DrawTitle); ! SetTransferMode(self,graphic_WHITE); ! suite_FillRect(self,rect,suite_WhitePattern(self)); ! SetTransferMode(self,graphic_BLACK); ! if(TitleCaption && (*TitleCaption != '\0')) { ! AllocNameSpace(&tmp_title,TitleCaption); ! str = next_str = tmp_title; ! DecrementRect(rect,1); ! DrawOutline(self,rect,TitleBorderSize,TitleBorderStyle); ! suite_SetClippingRect(self,rect); ! RealTitleFontSize = MAX(TitleFontSize,TitleFontHigh); ! while(!titleFits) { ! PlaceTitle(self,rect,&title); ! TitleFont = fontdesc_Create(TitleFontName,RealTitleFontType,RealTitleFontSize); ! if((titleFits = TitleFits(self,rect,&title)) || ! (RealTitleFontSize <= TitleFontLow)) break; ! else DecrementFontSizes(self,TITLE_ONLY); } ! horiz_point = title.left + title.width/2; ! vert_point = title.top + RealTitleFontSize/2; ! align = graphic_BETWEENTOPANDBOTTOM; ! if(TitleCaptionAlignment & suite_Left) { ! horiz_point = title.left + 1; ! align |= graphic_ATLEFT; } ! else if(TitleCaptionAlignment & suite_Right) { ! horiz_point = title.left + title.width - 1; ! align |= graphic_ATRIGHT; } ! else align |= graphic_BETWEENLEFTANDRIGHT; ! if(TitleFont) SetFont(self,TitleFont); ! for( i = 0 ; i < title_lines ; i++ ) { ! if(newline = (char*)rindex(next_str,'\n')) { ! next_str = newline + 1; ! *newline = NULL; ! } ! suite_MoveTo(self,horiz_point,vert_point); ! suite_DrawString(self,str,align); ! vert_point += RealTitleFontSize; ! str = next_str; ! } ! if(tmp_title) free(tmp_title); ! suite_ClearClippingRect(self); ! } ! else if(TitleViewObjectName || TitleDataObjectName) { ! if(TitleDataObjectName) { ! if(!TitleDataObject) ! TitleDataObject = ! (struct dataobject*)class_NewObject(TitleDataObjectName); ! if(TitleDataObject && TitleDataObjectHandler) ! TitleDataObjectHandler(ClientAnchor,self,NULL,suite_TitleObject); ! } ! if(!TitleViewObject) { ! if(!TitleViewObjectName) ! AllocNameSpace(&TitleViewObjectName, ! dataobject_ViewName(TitleDataObject)); ! TitleViewObject = (struct view*)class_NewObject(TitleViewObjectName); ! if(TitleViewObject && TitleViewObjectHandler) ! TitleViewObjectHandler(ClientAnchor,self,NULL,suite_TitleObject); ! } ! view_SetDataObject(TitleViewObject,TitleDataObject); ! DrawOutline(self,rect,TitleBorderSize,TitleBorderStyle); ! view_InsertView(TitleViewObject,self,rect); ! view_FullUpdate(TitleViewObject,view_FullRedraw,0,0, ! rect->width,rect->height); ! } ! else { ! if(Debug) printf("Title gone; calling FullUpdate.\n"); ! suite_FullUpdate(self,view_FullRedraw,0,0,Bounds.width,Bounds.height); ! } ! OUT(DrawTitle); } static void CenterBiggestCircleInRect( self, rect ) ! register struct suite *self; ! register struct rectangle *rect; { ! register long circum = MIN(rect->width,rect->height), rad = circum/2; ! register long centerX = rect->left + rect->width/2, centerY = rect->top + rect->height/2; ! rectangle_SetRectSize(rect,centerX - rad,centerY - rad,circum,circum); } static void DrawOutline( self, rect, width, style ) ! register struct suite *self; ! register struct rectangle *rect; ! register short width; ! register unsigned style; { ! register long i = 0; ! register struct rectangle *inner = NULL; ! register long X1 = 0, Y1 = 0, X2 = 0, Y2 = 0; ! IN(DrawOutline); ! SetTransferMode(self,graphic_BLACK); ! if(style & (suite_Invisible | suite_None)) return; ! else if(style & suite_Line) { ! if(TitlePlacement & suite_Top) { ! X1 = rect->left; Y1 = rect->top + rect->height; ! X2 = X1 + rect->width; Y2 = Y1; } ! else if(TitlePlacement & suite_Bottom) { ! X1 = rect->left; Y1 = rect->top; ! X2 = X1 + rect->width; Y2 = Y1; } ! else if(TitlePlacement & suite_Left) { ! X1 = rect->left + rect->width; Y1 = rect->top; ! X2 = X1; Y2 = Y1 + rect->height; } ! else if(TitlePlacement & suite_Right) { ! X1 = rect->left; Y1 = rect->top; ! X2 = X1; Y2 = Y1 + rect->height; } ! suite_MoveTo(self,X1,Y1); ! suite_DrawLineTo(self,X2,Y2); ! } ! else if(style & suite_Rectangle) { ! for( i = 0 ; i < width ; i++ ) { ! DrawRect(self,rect); ! DecrementRect(rect,1); ! } ! } ! else if(style & suite_Roundangle) { ! inner = rectangle_Duplicate(rect); ! DecrementRect(inner,5); ! suite_DrawRRect(self,rect,inner); ! DecrementRect(rect,5); ! } ! else if(style & suite_Circle) ! CenterBiggestCircleInRect(self,rect); ! if((style & suite_Oval) || (style & suite_Circle)) { ! for( i = 0 ; i < width ; i++ ) { ! suite_DrawOval(self,rect); ! DecrementRect(rect,1); ! } ! } ! SetTransferMode(self,graphic_BLACK); ! OUT(DrawOutline); } struct view * suite__Hit( self, action, x, y, numberOfClicks ) ! register struct suite *self; ! register enum view_MouseAction action; ! register long x, y, numberOfClicks; { ! struct view *retval = (struct view*)self; ! IN(suite_Hit); ! if(Scroll) { ! if(WithinRect(x,y,&ScrollRect)) ! retval = scroll_Hit(Scroll,action,x - ScrollRect.left, ! y - ScrollRect.top,numberOfClicks); ! } ! else { ! if(Within(x - ContainerLeft,y - ContainerTop,0,0, ! ContainerWidth,ContainerHeight)) ! retval = suiteev_Hit(SetView,action,x - ContainerLeft,y - ContainerTop, ! numberOfClicks); ! } ! if(WithinRect(x,y,&TitleRect)) { ! if(TitleHitHandler) ! TitleHitHandler(ClientAnchor,self,NULL,suite_TitleObject, action,x,y,numberOfClicks); ! else if(HitHandler) ! HitHandler(ClientAnchor,self,NULL,suite_TitleObject, ! action,x,y,numberOfClicks); ! else if(TitleViewObject) ! retval = view_Hit(TitleViewObject,action,x,y,numberOfClicks); ! } ! return((struct view*)retval); } long suite__Reset( self, state ) ! register struct suite *self; ! register long state; { ! register long i = 0, status = 0; ! register struct suite_item *item = NULL; ! boolean onScreen = FALSE, doFullRedraw = FALSE; ! boolean doContainerRedraw = FALSE; ! if(!(state & suite_Defer)) state |= suite_Immediate; ! if(state & suite_Clear) { ! suite_ClearAllItems(self); ! suite_SetSuiteAttribute(self,suite_TitleCaption(NULL)); ! doFullRedraw = TRUE; ! } ! if(state & suite_ClearItems) { ! suite_ClearAllItems(self); ! doContainerRedraw = TRUE; ! } ! if(state & suite_ClearTitle) { ! suite_SetSuiteAttribute(self,suite_TitleCaption(NULL)); ! doFullRedraw = TRUE; ! } ! if(state & suite_Activate) { ! if(Items && ITEM(0)) { ! while(item = ITEM(i++)) { ! if(FirstVisible && (FirstVisible == item)) onScreen = TRUE; ! if(Exposed(item) && !Active(item)) { ! suite_ActivateItem(self,item); ! if((state & suite_Immediate) && onScreen) ! suiteev_ItemNormalize(SetView,item); } ! else if(Exposed(item) && Highlighted(item)) ! if((state & suite_Immediate) && onScreen) ! suiteev_ItemNormalize(SetView,item); ! else if((state & suite_Expose) && !Exposed(item)) { ! item->exposed = TRUE; ! doContainerRedraw = TRUE; ! } ! item->mode = ((item_Active | item_Normalized) & ~item_Highlighted); ! if(LastVisible && (LastVisible == item)) onScreen = FALSE; ! } } ! else status = -1; ! } ! if(state & suite_Normalize) { ! if(Items && ITEM(0)) { ! while(item = ITEM(i++)) { ! if(FirstVisible && (FirstVisible == item)) onScreen = TRUE; ! if(Exposed(item) && Active(item) && Highlighted(item)) { ! if((state & suite_Immediate) && onScreen) ! suiteev_ItemNormalize(SetView,item); ! else item->mode = ((item_Active | item_Normalized) & ! ~item_Highlighted); } + else if((state & suite_Expose) && !Exposed(item)) { + item->exposed = TRUE; + doContainerRedraw = TRUE; + } + if(LastVisible && (LastVisible == item)) onScreen = FALSE; + } } ! } ! if(doFullRedraw && IsLinked) { ! suiteev_Clear(SetView); ! suite_FullUpdate(self,view_FullRedraw,0,0,0,0); ! } ! else if(doContainerRedraw && IsLinked) { ! suiteev_Clear(SetView); ! suiteev_FullUpdate(SetView,view_FullRedraw, ! 0,0,ContainerWidth,ContainerHeight); ! if(Scroll) scroll_Update(Scroll); ! } ! return(status); } void suite__ClearAllItems( self ) ! struct suite *self; { ! register int i = 0, count = 0; ! register struct suite_item *item = NULL; ! IN(suite_ClearAllItems); ! if(Items && ITEM(0)) { ! count = vector_Count(Items); ! for( i = 0 ; i < count ; i++ ){ ! item = ITEM(i); ! FinalizeItem(item); ! item = NULL; } ! vector_Destroy(Items); ! Items = NULL; ! } ! NewFirstVisible = FirstVisible = LastVisible = NULL; ! OUT(suite_ClearAllItems); } static long TitleSectionWidth( self ) ! struct suite *self; { ! register char *title = NULL, *newline = NULL, *tmp = NULL; ! long numLines = 0, XWidth = 0, YWidth = 0, maxWidth = 0; ! register long i = 0; ! if(TitleCaption) { ! tmp = title = (char*) malloc(strlen(TitleCaption) + 1); ! strcpy(title,TitleCaption); ! numLines = NumberLines(TitleCaption); ! for ( i = 0 ; i < numLines ; i++ ) { ! if(newline = (char*) rindex(tmp,'\n')) { ! *newline = NULL; ! fontdesc_StringBoundingBox(TitleFont,suite_GetDrawable(self),tmp, ! &XWidth,&YWidth); ! tmp = newline + 1; ! } ! else ! fontdesc_StringBoundingBox(TitleFont,suite_GetDrawable(self),tmp, ! &XWidth,&YWidth); ! if(XWidth > maxWidth) maxWidth = XWidth; } ! free(title); ! } ! else if(TitleViewObjectName || TitleDataObjectName) { ! if(TitlePlacement & (suite_Top | suite_Bottom)) ! maxWidth = ContainerWidth; ! else maxWidth = ContainerWidth/3; ! } ! return(maxWidth); } static long TitleSectionHeight( self ) ! struct suite *self; { ! IN(TitleSectionHeight); ! if(TitleCaption) return(NumberLines(TitleCaption) * RealTitleFontSize); ! else if(TitleViewObjectName || TitleDataObjectName) { ! if(TitlePlacement & (suite_Top | suite_Bottom)) ! return(ContainerHeight/3); ! else return(ContainerHeight); ! } ! OUT(TitleSectionHeight); } static void AssignSetAndTitleSpace( self, title, container ) ! register struct suite *self; ! register struct rectangle *title, *container; { ! register long TitleHeight = TitleSectionHeight(self), TitleWidth = TitleSectionWidth(self); ! switch(TitlePlacement) { ! case suite_Top: ! title->left = container->left; ! title->width = container->width; ! title->top = container->top; ! title->height = TitleHeight + TitleMWidth; ! container->top = title->top + title->height; ! container->height -= title->height; ! break; ! case suite_Bottom: ! title->left = container->left; ! title->width = container->width; ! title->height = TitleHeight + TitleMWidth; ! title->top = container->top + container->height - title->height; ! container->height -= title->height; ! break; ! case suite_Left: ! title->left = container->left; ! title->top = container->top; ! title->width = TitleWidth + TitleMWidth; ! title->height = container->height; ! container->left = title->left + title->width; ! container->width -= title->width; ! break; ! case suite_Right: ! title->top = container->top; ! title->height = container->height; ! title->width = TitleWidth + TitleMWidth; ! title->left = container->left + container->width - title->width; ! container->width -= title->width; ! break; ! } ! rectangle_SetRectSize(&TitleRect,title->left,title->top, title->width,title->height); } static void PlaceTitle( self, title_sect, title ) ! struct suite *self; ! struct rectangle *title_sect, *title; { ! register long Width = TitleSectionWidth(self), Height = TitleSectionHeight(self); ! register unsigned alignment = TitleCaptionAlignment; ! title->left = title_sect->left + (title_sect->width - Width)/2; ! title->top = title_sect->top + (title_sect->height - Height)/2; ! title->width = Width; title->height = Height; ! if(alignment & suite_Left) { ! title->left = title_sect->left + 2; ! } ! else if(alignment & suite_Right) { ! title->left = title_sect->left + (title_sect->width - Width) - 2; ! } ! if(alignment & suite_Top) { ! title->top = title_sect->top + 2; ! } ! else if(alignment & suite_Bottom) { ! title->top = title_sect->top + (title_sect->height - Height) - 2; ! } } static void SetCaptionList( self, captions ) ! register struct suite *self; ! register char **captions; { ! register char **ptr = captions; ! suite_ClearAllItems(self); ! if(ptr && *ptr && **ptr) { ! if(!(Items = vector_Create(100,3))) ! HandleException(self,NULL,suite_InsufficientSpace); ! else { ! if(SortHandler) ! vector_SetSortRoutine(Items,SortStub); ! else if(SortOrder) ! SetSortRoutine(self); } + while(*ptr) + if(!(suite_CreateItem(self,*ptr++,0))) + HandleException(self,NULL,suite_InsufficientSpace); + if(Items && ITEM(0)) { + FirstVisible = ITEM(0); + LastVisible = ITEM(vector_Count(Items) - 1); + } + } } static void ParseFontFullName( self, fullname, familyName, buffSize, size, type ) ! register struct suite *self; ! register char *fullname, *familyName; ! register long buffSize; ! register long *size, *type; { ! if(fullname && *fullname) fontdesc_ExplodeFontName(fullname,familyName, buffSize,(long)type,(long)size); } static void ChangeItemCaption( self, item, caption ) ! register struct suite *self; ! register struct suite_item *item; ! register char *caption; { ! register struct text *txt = NULL; ! register struct suitecv *CV = NULL; ! ValidateItem(self,item); ! AllocNameSpace(&item->caption,caption); ! if(item_AccessType & suite_ReadWrite) { ! text_Clear(txt = (struct text*) item->dataobject); ! text_InsertCharacters(txt,0,item->caption,strlen(item->caption)); ! suitecv_WantUpdate(CV = (struct suitecv*)item->viewobject,CV); ! } ! suiteev_ItemUpdate(SetView,item); } void suite__PassivateItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! register long mode = 0; ! if(item) { ! if(!Active(item)) return; ! if(IsLinked && (ItemPassiveStyle & suite_Removed)) ! suite_HideItem(self,item); ! else { ! mode = (item->mode & ~item_Active & ~item_Highlighted) | ! item_Normalized; ! if(ItemPassiveStyle & suite_Invisible) mode |= suite_Invisible; ! item->mode = mode; ! if(IsLinked) suiteev_ItemUpdate(SetView,item); } + } } void suite__ActivateItem( self, item ) ! struct suite *self; ! struct suite_item *item; { ! register long mode = 0; ! if(item) { ! if(Active(item)) return; ! if(IsLinked && (ItemPassiveStyle & suite_Removed)) ! suite_ExposeItem(self,item); ! else { ! mode = (item->mode | item_Active | item_Normalized) & ! ~item_Highlighted; ! if(ItemPassiveStyle & suite_Invisible) mode |= ~suite_Invisible; ! item->mode = mode; ! if(IsLinked) suiteev_ItemUpdate(SetView,item); } + } } static struct suite_item* AllocItem() { ! return((struct suite_item*) calloc(1,sizeof(struct suite_item))); } static void FinalizeItem( item ) ! register struct suite_item *item; { ! IN(FinalizeItem); ! if(Breaks(item)) vector_Destroy(Breaks(item)); ! if(item->caption) free(item->caption); ! if(item->title) free(item->title); ! if(item->titlefontname) free(item->titlefontname); ! if(item->captionfontname) free(item->captionfontname); ! if(item->viewobjectname) free(item->viewobjectname); ! if(item->dataobjectname) free(item->dataobjectname); ! if(item->viewobject) { ! view_UnlinkTree(item->viewobject); ! view_Destroy(item->viewobject); ! item->viewobject = NULL; ! } /*=== if(item->dataobject) dataobject_Destroy(item->dataobject); gk5g 5/1/89 ===*/ ! free(item); ! OUT(FinalizeItem); } static void SetSortRoutine( self ) ! register struct suite *self; { ! if(suite_Ascend & SortOrder) { ! if(suite_Alphabetic & SortOrder) ! vector_SetSortRoutine(Items,AlphasortAscend); ! else if(suite_Numeric & SortOrder) ! vector_SetSortRoutine(Items,NumericAscend); ! } ! else if(suite_Descend & SortOrder) { ! if(suite_Alphabetic & SortOrder) ! vector_SetSortRoutine(Items,AlphasortDescend); ! else if(suite_Numeric & SortOrder) ! vector_SetSortRoutine(Items,NumericDescend); } } static long SortStub( item1, item2 ) ! register struct suite_item **item1; ! register struct suite_item **item2; { ! register struct suite *self = NULL; ! register long status = 0; ! if(item1 && *item1 && item2 && *item2) { ! self = (*item1)->suite; ! if(self) status = SortHandler(ClientAnchor,self,*item1,*item2); ! } ! return status; } void suite__Sort( self, mode, handler ) ! register struct suite *self; ! register unsigned mode; ! register long (*handler)(); { ! IN(suite_Sort); ! suiteev_Clear(SetView); ! if(Items && ITEM(0)) { ! DEBUG(Sort); ! if(mode) SortOrder = mode; ! if(handler) { DEBUG(Handler); ! SortHandler = (long (*)())handler; ! vector_SetSortRoutine(Items,SortStub); } ! else SetSortRoutine(self); ! vector_Sort(Items); ! FirstVisible = ITEM(0); ! LastVisible = ITEM(vector_Count(Items) - 1); ! suiteev_FullUpdate(SetView,view_FullRedraw,0,0, ! ContainerWidth,ContainerHeight); ! if(Scroll) scroll_Update(Scroll); ! } ! OUT(suite_Sort); } void suite__Apply( self, proc, anchor, datum ) ! register struct suite *self; ! register long (*proc)(); ! register unsigned anchor, datum; { ! register int i = 0; ! register struct suite_item *item = NULL; ! register long status = 0; ! if(Items && ITEM(0)) ! while((item = ITEM(i++)) && (status >= 0)) ! status = proc(anchor,self,item,datum); } static long AlphasortAscend( item1, item2 ) ! register struct suite_item **item1, **item2; { ! register char *str1 = NULL, *str2 = NULL; ! if(!item1 || !*item1 || !item2 || !*item2) return(0); ! if((*item1)->caption) str1 = (*item1)->caption; ! else str1 = (*item1)->name; ! if((*item2)->caption) str1 = (*item2)->caption; ! else str2 = (*item2)->name; ! return(strcmp(str1,str2)); } static long NumericAscend( item1, item2 ) ! register struct suite_item **item1, **item2; { ! if(!item1 || !*item1 || !item2 || !*item2) return(0); ! if((*item1)->datum > (*item2)->datum) return(1); ! else if((*item1)->datum < (*item2)->datum) return(-1); ! else return(0); } static long AlphasortDescend( item1, item2 ) ! register struct suite_item **item1, **item2; { ! register char *str1 = NULL, *str2 = NULL; ! if(!item1 || !*item1 || !item2 || !*item2) return(0); ! if((*item1)->caption) str1 = (*item1)->caption; ! else str1 = (*item1)->name; ! if((*item2)->caption) str1 = (*item2)->caption; ! else str2 = (*item2)->name; ! return(-1 * strcmp(str1,str2)); } static long NumericDescend( item1, item2 ) ! register struct suite_item **item1, **item2; { ! if(!item1 || !*item1 || !item2 || !*item2) return(0); ! if((*item1)->datum < (*item2)->datum) return(-1); ! else if((*item1)->datum > (*item2)->datum) return(1); ! else return(0); } static void AllocNameSpace( target, source ) ! register char **target, *source; { ! if(target && *target) { ! free(*target); ! *target = NULL; ! } ! if(source && *source) { ! *target = malloc(strlen(source)+1); ! if(*target) strcpy(*target,source); ! } ! else *target = NULL; } struct suite_item ** suite__SelectedItems( self, number ) ! register struct suite *self; ! register long *number; { ! register struct suite_item *item = NULL; ! register int i = 0; ! register long count = 0, index = 0; ! if(Items && ITEM(0)) { ! while(item = ITEM(i++)) ! if(Exposed(item) && Active(item) && Highlighted(item)) count++; ! suiteev_AllocItemArray(SetView,count); ! if(ItemArray) { ! i = 0; ! while(item = ITEM(i++)) ! if(Exposed(item) && Active(item) && Highlighted(item)) ! ItemArray[index++] = item; ! } ! } ! if(number) *number = count; ! return(ItemArray); } void suite__SetDebug( self, value ) ! register struct suite *self; ! register boolean value; { ! self->debug = SetView->debug = value; } static void SetArrangementAttribute( self, value ) ! register struct suite *self; ! register unsigned long value; { ! if(value & suite_List) ! Arrangement |= suite_List; ! if(value & suite_Matrix) { ! Arrangement &= (~suite_Row & ~suite_Column); ! Arrangement |= suite_Matrix; ! } ! if(value & suite_Row) { ! Arrangement &= (~suite_Matrix & ~suite_Column); ! Arrangement |= suite_Row; ! } ! if(value & suite_Column) { ! Arrangement &= (~suite_Matrix & ~suite_Row); ! Arrangement |= suite_Column; ! } ! if(value & suite_Balanced) { ! Arrangement &= ~suite_Unbalanced; ! Arrangement |= suite_Balanced; ! } ! if(value & suite_Unbalanced) { ! Arrangement &= ~suite_Balanced; ! Arrangement |= suite_Unbalanced; ! } ! if(value & suite_RowLine) Arrangement |= suite_RowLine; ! if(value & suite_ColumnLine) Arrangement |= suite_ColumnLine; } static void SetBorderStyleAttribute( self, border_style, value ) ! register struct suite *self; ! register unsigned int *border_style; ! register long value; { ! if(value & suite_Invisible) { ! *border_style &= ~suite_None; ! *border_style |= suite_Invisible; ! } ! if(value & suite_Rectangle) { ! *border_style &= (~suite_Roundangle & ~suite_Circle & ! ~suite_Oval & ~suite_None); ! *border_style |= suite_Rectangle; ! } ! if(value & suite_Roundangle) { ! *border_style &= (~suite_Rectangle & ~suite_Circle & ! ~suite_Oval & ~suite_None); ! *border_style |= suite_Roundangle; ! } ! if(value & suite_Circle) { ! *border_style &= (~suite_Rectangle & ~suite_Roundangle & ! ~suite_Oval & ~suite_None); ! *border_style |= suite_Circle; ! } ! if(value & suite_Oval) { ! *border_style &= (~suite_Rectangle & ~suite_Roundangle & ! ~suite_Circle & ~suite_None); ! *border_style |= suite_Oval; ! } ! if(value & suite_Line) { ! *border_style &= (~suite_Rectangle & ~suite_Roundangle & ! ~suite_Circle & ~suite_None & ~suite_Oval); ! *border_style |= suite_Line; ! } ! if(value & suite_None) { ! *border_style &= (~suite_Rectangle & ~suite_Roundangle & ! ~suite_Circle & ~suite_Oval); ! *border_style |= suite_None; ! } } static void SetSuiteAttribute( self, attribute, value ) ! register struct suite *self; ! register long attribute, value; { ! char Name[100], *tmp = NULL; ! long int Size, Type; ! IN(SetSuiteAttribute); ! switch(attribute) { case suite_titlecaption: ! AllocNameSpace(&tmp,(char*)value); ! AllocNameSpace(&TitleCaption,strip(tmp)); ! if(tmp) free(tmp); break; case suite_titlehighlightstyle: TitleHighlightStyle = value; *************** *** 1591,1597 **** TitleBorderSize = value; break; case suite_titledataobjectname: ! AllocNameSpace(&TitleDataObjectName,strip((char*)value)); break; case suite_itemorder: ItemOrder = value; --- 1549,1557 ---- TitleBorderSize = value; break; case suite_titledataobjectname: ! AllocNameSpace(&tmp,(char*)value); ! AllocNameSpace(&TitleDataObjectName,strip(tmp)); ! if(tmp) free(tmp); break; case suite_itemorder: ItemOrder = value; *************** *** 1634,1649 **** TitleCaptionAlignment = value; break; case suite_titlefontname: ! ParseFontFullName(self,strip((char*)value),Name,100,&Size,&Type); AllocNameSpace(&TitleFontName,Name); TitleFontSize = Size; if(TitleFontLow ==0) TitleFontLow = Size - DEFAULT_FONT_RANGE; if(TitleFontHigh == 0) TitleFontHigh = Size + DEFAULT_FONT_RANGE; RealTitleFontType = TitleFontType = Type; ! TitleFont = suite_BuildFont(self,value,&Size); break; case suite_titleviewobjectname: ! AllocNameSpace(&TitleViewObjectName,strip((char*)value)); break; case suite_titleviewobjecthandler: TitleViewObjectHandler = (long(*)())value; --- 1594,1613 ---- TitleCaptionAlignment = value; break; case suite_titlefontname: ! AllocNameSpace(&tmp,(char*)value); ! ParseFontFullName(self,strip(tmp),Name,100,&Size,&Type); AllocNameSpace(&TitleFontName,Name); TitleFontSize = Size; if(TitleFontLow ==0) TitleFontLow = Size - DEFAULT_FONT_RANGE; if(TitleFontHigh == 0) TitleFontHigh = Size + DEFAULT_FONT_RANGE; RealTitleFontType = TitleFontType = Type; ! TitleFont = suite_BuildFont(self,tmp,&Size); ! if(tmp) free(tmp); break; case suite_titleviewobjectname: ! AllocNameSpace(&tmp,(char*)value); ! AllocNameSpace(&TitleViewObjectName,strip(tmp)); ! if(tmp) free(tmp); break; case suite_titleviewobjecthandler: TitleViewObjectHandler = (long(*)())value; *************** *** 1667,1679 **** TitleHitHandler = (long(*)())value; break; case suite_itemcaptionfontname: ! ParseFontFullName(self,strip((char*)value),Name,100,&Size,&Type); AllocNameSpace(&CaptionFontName,Name); CaptionFontSize = Size; if(CaptionFontLow == 0) CaptionFontLow = Size - DEFAULT_FONT_RANGE; if(CaptionFontHigh == 0) CaptionFontHigh = Size + DEFAULT_FONT_RANGE; CaptionFontType = Type; ! CaptionFont = suite_BuildFont(self,value,&Size); break; case suite_itemcaptionfontlow: CaptionFontLow = value; --- 1631,1645 ---- TitleHitHandler = (long(*)())value; break; case suite_itemcaptionfontname: ! AllocNameSpace(&tmp,(char*)value); ! ParseFontFullName(self,strip(tmp),Name,100,&Size,&Type); AllocNameSpace(&CaptionFontName,Name); CaptionFontSize = Size; if(CaptionFontLow == 0) CaptionFontLow = Size - DEFAULT_FONT_RANGE; if(CaptionFontHigh == 0) CaptionFontHigh = Size + DEFAULT_FONT_RANGE; CaptionFontType = Type; ! CaptionFont = suite_BuildFont(self,tmp,&Size); ! if(tmp) free(tmp); break; case suite_itemcaptionfontlow: CaptionFontLow = value; *************** *** 1682,1688 **** CaptionFontHigh = value; break; case suite_itemtitlefontname: ! ParseFontFullName(self,strip((char*)value),Name,100,&Size,&Type); AllocNameSpace(&ItemTitleFontName,Name); ItemTitleFontSize = Size; if(ItemTitleFontLow == 0) ItemTitleFontLow = Size - DEFAULT_FONT_RANGE; --- 1648,1656 ---- CaptionFontHigh = value; break; case suite_itemtitlefontname: ! AllocNameSpace(&tmp,(char*)value); ! ParseFontFullName(self,strip(tmp),Name,100,&Size,&Type); ! if(tmp) free(tmp); AllocNameSpace(&ItemTitleFontName,Name); ItemTitleFontSize = Size; if(ItemTitleFontLow == 0) ItemTitleFontLow = Size - DEFAULT_FONT_RANGE; *************** *** 1696,1720 **** self->itemtitlefonthigh = value; break; case suite_fontname: ! ParseFontFullName(self,strip((char*)value),Name,100,&Size,&Type); AllocNameSpace(&TitleFontName,Name); TitleFontSize = Size; if(TitleFontLow == 0) TitleFontLow = Size - DEFAULT_FONT_RANGE; if(TitleFontHigh == 0) TitleFontHigh = Size + DEFAULT_FONT_RANGE; RealTitleFontType = TitleFontType = Type; ! TitleFont = suite_BuildFont(self,value,&Size); AllocNameSpace(&ItemTitleFontName,Name); ItemTitleFontSize = Size; if(ItemTitleFontLow == 0) ItemTitleFontLow = Size - DEFAULT_FONT_RANGE; if(ItemTitleFontHigh == 0) ItemTitleFontHigh = Size + DEFAULT_FONT_RANGE; ItemTitleFontType = Type; ! TitleFont = suite_BuildFont(self,value,&Size); AllocNameSpace(&CaptionFontName,Name); CaptionFontSize = Size; if(CaptionFontLow == 0) CaptionFontLow = Size - DEFAULT_FONT_RANGE; if(CaptionFontHigh == 0) CaptionFontHigh = Size + DEFAULT_FONT_RANGE; CaptionFontType = Type; ! CaptionFont = suite_BuildFont(self,value,&Size); break; case suite_itemborderstyle: SetBorderStyleAttribute(self,&ItemBorderStyle,value); --- 1664,1690 ---- self->itemtitlefonthigh = value; break; case suite_fontname: ! AllocNameSpace(&tmp,(char*)value); ! ParseFontFullName(self,strip(tmp),Name,100,&Size,&Type); AllocNameSpace(&TitleFontName,Name); TitleFontSize = Size; if(TitleFontLow == 0) TitleFontLow = Size - DEFAULT_FONT_RANGE; if(TitleFontHigh == 0) TitleFontHigh = Size + DEFAULT_FONT_RANGE; RealTitleFontType = TitleFontType = Type; ! TitleFont = suite_BuildFont(self,tmp,&Size); AllocNameSpace(&ItemTitleFontName,Name); ItemTitleFontSize = Size; if(ItemTitleFontLow == 0) ItemTitleFontLow = Size - DEFAULT_FONT_RANGE; if(ItemTitleFontHigh == 0) ItemTitleFontHigh = Size + DEFAULT_FONT_RANGE; ItemTitleFontType = Type; ! TitleFont = suite_BuildFont(self,tmp,&Size); AllocNameSpace(&CaptionFontName,Name); CaptionFontSize = Size; if(CaptionFontLow == 0) CaptionFontLow = Size - DEFAULT_FONT_RANGE; if(CaptionFontHigh == 0) CaptionFontHigh = Size + DEFAULT_FONT_RANGE; CaptionFontType = Type; ! CaptionFont = suite_BuildFont(self,tmp,&Size); ! if(tmp) free(tmp); break; case suite_itemborderstyle: SetBorderStyleAttribute(self,&ItemBorderStyle,value); *************** *** 1735,1741 **** AccessType = (unsigned)value; break; case suite_itemdataobjectname: ! AllocNameSpace(&ItemDataObjectName,strip((char*)value)); break; case suite_itemdataobjecthandler: ItemDataObjectHandler = (long(*)())value; --- 1705,1713 ---- AccessType = (unsigned)value; break; case suite_itemdataobjectname: ! AllocNameSpace(&tmp,(char*)value); ! AllocNameSpace(&ItemDataObjectName,strip(tmp)); ! if(tmp) free(tmp); break; case suite_itemdataobjecthandler: ItemDataObjectHandler = (long(*)())value; *************** *** 1744,1750 **** ItemViewObjectHandler = (long(*)())value; break; case suite_itemviewobjectname: ! AllocNameSpace(&ItemViewObjectName,strip((char*)value)); break; case suite_guttersize: YGutterSize = XGutterSize = value; --- 1716,1724 ---- ItemViewObjectHandler = (long(*)())value; break; case suite_itemviewobjectname: ! AllocNameSpace(&tmp,(char*)value); ! AllocNameSpace(&ItemViewObjectName,strip(tmp)); ! if(tmp) free(tmp); break; case suite_guttersize: YGutterSize = XGutterSize = value; *************** *** 1764,1772 **** if(Items) vector_SetSortRoutine(Items,SortStub); break; case suite_cursorfontname: ! ParseFontFullName(self,strip((char*)value),Name,100,&Size,&Type); AllocNameSpace(&CursorFontName,Name); ! CursorFont = suite_BuildFont(self,value,&Size); if(Cursor) { cursor_Destroy(Cursor); Cursor = NULL; --- 1738,1748 ---- if(Items) vector_SetSortRoutine(Items,SortStub); break; case suite_cursorfontname: ! AllocNameSpace(&tmp,(char*)value); ! ParseFontFullName(self,strip(tmp),Name,100,&Size,&Type); AllocNameSpace(&CursorFontName,Name); ! CursorFont = suite_BuildFont(self,tmp,&Size); ! if(tmp) free(tmp); if(Cursor) { cursor_Destroy(Cursor); Cursor = NULL; *************** *** 1780,1788 **** } break; case suite_itemcursorfontname: ! ParseFontFullName(self,strip((char*)value),Name,100,&Size,&Type); AllocNameSpace(&ItemCursorFontName,Name); ! ItemCursorFont = suite_BuildFont(self,value,&Size); if(ItemCursor) { cursor_Destroy(ItemCursor); ItemCursor = NULL; --- 1756,1766 ---- } break; case suite_itemcursorfontname: ! AllocNameSpace(&tmp,(char*)value); ! ParseFontFullName(self,strip(tmp),Name,100,&Size,&Type); AllocNameSpace(&ItemCursorFontName,Name); ! ItemCursorFont = suite_BuildFont(self,tmp,&Size); ! if(tmp) free(tmp); if(ItemCursor) { cursor_Destroy(ItemCursor); ItemCursor = NULL; *************** *** 1799,1828 **** WrapStyle = (short) value; break; default: fprintf( stderr, "Suite: Unknown Suite Attribute (%d)\n",attribute); ! } ! OUT(SetSuiteAttribute); } long suite__SetSuiteAttribute( self, attribute, value ) ! register struct suite *self; ! register long attribute, value; { ! register long status = 0; ! SetSuiteAttribute(self,attribute,value); ! return(status); } static void ChangeSuiteAttribute( self, attribute, value ) ! register struct suite *self; ! register long attribute, value; { ! struct rectangle *title_rect = rectangle_Duplicate(&TitleRect); ! SetSuiteAttribute(self,attribute,value); ! switch(attribute) { case suite_titleviewobjectname: if(TitleViewObject) { view_UnlinkTree(TitleViewObject); --- 1777,1806 ---- WrapStyle = (short) value; break; default: fprintf( stderr, "Suite: Unknown Suite Attribute (%d)\n",attribute); ! } ! OUT(SetSuiteAttribute); } long suite__SetSuiteAttribute( self, attribute, value ) ! register struct suite *self; ! register long attribute, value; { ! register long status = 0; ! SetSuiteAttribute(self,attribute,value); ! return(status); } static void ChangeSuiteAttribute( self, attribute, value ) ! register struct suite *self; ! register long attribute, value; { ! struct rectangle *title_rect = rectangle_Duplicate(&TitleRect); ! SetSuiteAttribute(self,attribute,value); ! switch(attribute) { case suite_titleviewobjectname: if(TitleViewObject) { view_UnlinkTree(TitleViewObject); *************** *** 1908,1935 **** case suite_datum: break; default: fprintf(stderr,"Suite: Unknown Suite Attribute (%d)\n",attribute); ! } } long suite__ChangeSuiteAttribute( self, attribute, value ) ! register struct suite *self; ! register long attribute, value; { ! register long status = 0; ! ChangeSuiteAttribute(self,attribute,value); ! return(status); } long suite__SuiteAttribute( self, attribute ) ! register struct suite *self; ! register long attribute; { ! register long value = NULL; ! switch(attribute) { case suite_titlecaption: value = (long)TitleCaption; break; case suite_titlehighlightstyle: value = (long)TitleHighlightStyle; break; case suite_titleborderstyle: value = (long)TitleBorderStyle; break; --- 1886,1913 ---- case suite_datum: break; default: fprintf(stderr,"Suite: Unknown Suite Attribute (%d)\n",attribute); ! } } long suite__ChangeSuiteAttribute( self, attribute, value ) ! register struct suite *self; ! register long attribute, value; { ! register long status = 0; ! ChangeSuiteAttribute(self,attribute,value); ! return(status); } long suite__SuiteAttribute( self, attribute ) ! register struct suite *self; ! register long attribute; { ! register long value = NULL; ! switch(attribute) { case suite_titlecaption: value = (long)TitleCaption; break; case suite_titlehighlightstyle: value = (long)TitleHighlightStyle; break; case suite_titleborderstyle: value = (long)TitleBorderStyle; break; *************** *** 1988,2133 **** default: fprintf(stderr,"Suite: Unknown Suite Attribute (%d)\n",attribute); break; ! } ! return(value); } void suite__ExposeItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! item->exposed = TRUE; ! suiteev_Clear(SetView); ! suiteev_FullUpdate(SetView,view_FullRedraw,0,0,ContainerWidth,ContainerHeight); ! if(Scroll) scroll_Update(Scroll); } void suite__HideItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! item->exposed = FALSE; ! suiteev_Clear(SetView); ! suiteev_FullUpdate(SetView,view_FullRedraw,0,0,ContainerWidth,ContainerHeight); ! if(Scroll) scroll_Update(Scroll); } boolean suite__ItemHighlighted( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! if(!item) return(FALSE); ! return(Highlighted(item)); } long suite__HighlightItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! register long status = 0, i = 0; ! boolean onScreen = FALSE; ! register struct suite_item *this_one = NULL; ! if(!Items || !ITEM(0) || !item) return; ! if(IsLinked) { ! i = vector_Subscript(Items,(long)FirstVisible); ! if(SelectionMode & suite_Exclusive) ! suite_Reset(self,suite_Normalize); ! while(this_one = ITEM(i++)) ! if(item == this_one) { ! onScreen = TRUE; ! break; ! } ! else if(this_one == LastVisible) ! break; ! if(Exposed(item) && !Active(item)) ! suite_ActivateItem(self,item); ! } ! if(onScreen) ! suiteev_ItemHighlight(SetView,item); ! else ! item->mode = ((item_Active | item_Highlighted) & ~item_Normalized); ! CurrentItem = item; ! return(status); } boolean suite__ItemNormalized( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! if(!item) return(FALSE); ! return(Normalized(item)); } long suite__NormalizeItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! register long status = 0, i = 0; ! boolean onScreen = FALSE; ! register struct suite_item *this_one = NULL; ! if(!Items || !ITEM(0) || !item) return; ! if(IsLinked) { ! i = vector_Subscript(Items,(long)FirstVisible); ! if(SelectionMode & suite_Exclusive) ! suite_Reset(self,suite_Normalize); ! while(this_one = ITEM(i++)) ! if(item == this_one) { ! onScreen = TRUE; ! break; ! } ! else if(this_one == LastVisible) ! break; ! if(Exposed(item) && !Active(item)) ! suite_ActivateItem(self,item); ! } ! if(onScreen) ! suiteev_ItemNormalize(SetView,item); ! else ! item->mode = ((item_Active | item_Normalized) & ~item_Highlighted); ! CurrentItem = item; ! return(status); } boolean suite__ItemActivated( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! if(!item) return(FALSE); ! return(Active(item)); } static void SetItemAttribute( self, item, attribute, value ) ! register struct suite *self; ! register struct suite_item *item; ! register long attribute, value; { ! char Name[101]; ! long Size, Type; ! switch(attribute) { case suite_itemname: ! AllocNameSpace(&item->name,strip((char*)value)); ! break; case suite_itemposition: MaxItemPosGiven = MAX(MaxItemPosGiven,value); item->position = value; break; case suite_itemcaption: ! AllocNameSpace(&item->caption,strip((char*)value)); break; case suite_itemcaptionfontname: ! ParseFontFullName(self,strip((char*)value),Name,100,&Size,&Type); AllocNameSpace(&item->captionfontname,Name); item->captionfontsize = Size; item->captionfonttype = Type; --- 1966,2116 ---- default: fprintf(stderr,"Suite: Unknown Suite Attribute (%d)\n",attribute); break; ! } ! return(value); } void suite__ExposeItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! item->exposed = TRUE; ! suiteev_Clear(SetView); ! suiteev_FullUpdate(SetView,view_FullRedraw,0,0, ContainerWidth, ContainerHeight); ! if(Scroll) scroll_Update(Scroll); } void suite__HideItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! item->exposed = FALSE; ! suiteev_Clear(SetView); ! suiteev_FullUpdate(SetView,view_FullRedraw,0,0, ContainerWidth, ContainerHeight); ! if(Scroll) scroll_Update(Scroll); } boolean suite__ItemHighlighted( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! if(!item) return(FALSE); ! return(Highlighted(item)); } long suite__HighlightItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! register long status = 0, i = 0; ! boolean onScreen = FALSE; ! register struct suite_item *this_one = NULL; ! if(!Items || !ITEM(0) || !item) return; ! if(IsLinked) { ! i = vector_Subscript(Items,(long)FirstVisible); ! if(SelectionMode & suite_Exclusive) ! suite_Reset(self,suite_Normalize); ! while(this_one = ITEM(i++)) ! if(item == this_one) { ! onScreen = TRUE; ! break; ! } ! else if(this_one == LastVisible) ! break; ! if(Exposed(item) && !Active(item)) ! suite_ActivateItem(self,item); ! } ! if(onScreen) ! suiteev_ItemHighlight(SetView,item); ! else ! item->mode = ((item_Active | item_Highlighted) & ~item_Normalized); ! CurrentItem = item; ! return(status); } boolean suite__ItemNormalized( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! if(!item) return(FALSE); ! return(Normalized(item)); } long suite__NormalizeItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! register long status = 0, i = 0; ! boolean onScreen = FALSE; ! register struct suite_item *this_one = NULL; ! if(!Items || !ITEM(0) || !item) return; ! if(IsLinked) { ! i = vector_Subscript(Items,(long)FirstVisible); ! if(SelectionMode & suite_Exclusive) ! suite_Reset(self,suite_Normalize); ! while(this_one = ITEM(i++)) ! if(item == this_one) { ! onScreen = TRUE; ! break; ! } ! else if(this_one == LastVisible) ! break; ! if(Exposed(item) && !Active(item)) ! suite_ActivateItem(self,item); ! } ! if(onScreen) ! suiteev_ItemNormalize(SetView,item); ! else item->mode = ((item_Active | item_Normalized) & ~item_Highlighted); ! CurrentItem = item; ! return(status); } boolean suite__ItemActivated( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! if(!item) return(FALSE); ! return(Active(item)); } static void SetItemAttribute( self, item, attribute, value ) ! register struct suite *self; ! register struct suite_item *item; ! register long attribute, value; { ! char Name[101], *tmp = NULL; ! long Size, Type; ! switch(attribute) { case suite_itemname: ! AllocNameSpace(&tmp,(char*)value); ! AllocNameSpace(&item->name,strip(tmp)); ! if(tmp) free(tmp); ! break; case suite_itemposition: MaxItemPosGiven = MAX(MaxItemPosGiven,value); item->position = value; break; case suite_itemcaption: ! AllocNameSpace(&tmp,(char*)value); ! AllocNameSpace(&item->caption,strip(tmp)); ! if(tmp) free(tmp); break; case suite_itemcaptionfontname: ! AllocNameSpace(&tmp,(char*)value); ! ParseFontFullName(self,strip(tmp),Name,100,&Size,&Type); ! if(tmp) free(tmp); AllocNameSpace(&item->captionfontname,Name); item->captionfontsize = Size; item->captionfonttype = Type; *************** *** 2134,2143 **** item->captionfont = NULL; break; case suite_itemtitlecaption: ! AllocNameSpace(&item->title,strip((char*)value)); break; case suite_itemtitlefontname: ! ParseFontFullName(self,strip((char*)value),Name,100,&Size,&Type); AllocNameSpace(&item->titlefontname,Name); item->titlefontsize = Size; item->titlefonttype = Type; --- 2117,2130 ---- item->captionfont = NULL; break; case suite_itemtitlecaption: ! AllocNameSpace(&tmp,(char*)value); ! AllocNameSpace(&item->title,strip(tmp)); ! if(tmp) free(tmp); break; case suite_itemtitlefontname: ! AllocNameSpace(&tmp,(char*)value); ! ParseFontFullName(self,strip(tmp),Name,100,&Size,&Type); ! if(tmp) free(tmp); AllocNameSpace(&item->titlefontname,Name); item->titlefontsize = Size; item->titlefonttype = Type; *************** *** 2157,2163 **** suiteev_SetItemToReadWrite(SetView,item); break; case suite_itemviewobjectname: ! AllocNameSpace(&item->viewobjectname,strip((char*)value)); if(item->viewobject) { view_UnlinkTree(item->viewobject); view_Destroy(item->viewobject); --- 2144,2152 ---- suiteev_SetItemToReadWrite(SetView,item); break; case suite_itemviewobjectname: ! AllocNameSpace(&tmp,(char*)value); ! AllocNameSpace(&item->viewobjectname,strip(tmp)); ! if(tmp) free(tmp); if(item->viewobject) { view_UnlinkTree(item->viewobject); view_Destroy(item->viewobject); *************** *** 2166,2172 **** (struct view*)class_NewObject(item_ViewObjectName); break; case suite_itemdataobjectname: ! AllocNameSpace(&item->dataobjectname,strip((char*)value)); if(item->dataobject) dataobject_Destroy(item->dataobject); item->dataobject = (struct dataobject*)class_NewObject(item_DataObjectName); --- 2155,2163 ---- (struct view*)class_NewObject(item_ViewObjectName); break; case suite_itemdataobjectname: ! AllocNameSpace(&tmp,(char*)value); ! AllocNameSpace(&item->dataobjectname,strip(tmp)); ! if(tmp) free(tmp); if(item->dataobject) dataobject_Destroy(item->dataobject); item->dataobject = (struct dataobject*)class_NewObject(item_DataObjectName); *************** *** 2190,2198 **** item->highlightstyle = value; break; case suite_itemcursorfontname: ! ParseFontFullName(self,strip((char*)value),Name,100,&Size,&Type); AllocNameSpace(&item->cursorfontname,Name); ! item->cursorfont = suite_BuildFont(self,value,&Size); if(item->cursor) { cursor_Destroy(item->cursor); item->cursor = NULL; --- 2181,2191 ---- item->highlightstyle = value; break; case suite_itemcursorfontname: ! AllocNameSpace(&tmp,(char*)value); ! ParseFontFullName(self,strip(tmp),Name,100,&Size,&Type); AllocNameSpace(&item->cursorfontname,Name); ! item->cursorfont = suite_BuildFont(self,tmp,&Size); ! if(tmp) free(tmp); if(item->cursor) { cursor_Destroy(item->cursor); item->cursor = NULL; *************** *** 2215,2246 **** default: fprintf(stderr, "Suite: Unknown Item Attribute (%d)\n", attribute); break; ! } } long suite__SetItemAttribute( self, item, attribute, value ) ! register struct suite *self; ! register struct suite_item *item; ! register long attribute, value; { ! register long status = 0; ! SetItemAttribute(self,item,attribute,value); ! return(status); } static void ChangeItemAttribute( self, item, attribute, value ) ! register struct suite *self; ! register struct suite_item *item; ! register long attribute, value; { ! SetItemAttribute(self,item,attribute,value); ! switch(attribute) { case suite_itemcaption: ! ChangeItemCaption(self,item,strip((char*)value)); break; case suite_itemdataobjectname: if(item->viewobject) { --- 2208,2242 ---- default: fprintf(stderr, "Suite: Unknown Item Attribute (%d)\n", attribute); break; ! } } long suite__SetItemAttribute( self, item, attribute, value ) ! register struct suite *self; ! register struct suite_item *item; ! register long attribute, value; { ! register long status = 0; ! SetItemAttribute(self,item,attribute,value); ! return(status); } static void ChangeItemAttribute( self, item, attribute, value ) ! register struct suite *self; ! register struct suite_item *item; ! register long attribute, value; { + char *tmp = NULL; ! SetItemAttribute(self,item,attribute,value); ! switch(attribute) { case suite_itemcaption: ! AllocNameSpace(&tmp,(char*)value); ! ChangeItemCaption(self,item,strip(tmp)); ! if(tmp) free(tmp); break; case suite_itemdataobjectname: if(item->viewobject) { *************** *** 2247,2261 **** view_UnlinkTree(item->viewobject); view_Destroy(item->viewobject); } ! AllocNameSpace(&item->viewobjectname,dataobject_ViewName(item->dataobject)); item->viewobject = ! (struct view*)class_NewObject(item->viewobjectname); ! view_SetDataObject(item->viewobject,item->dataobject); break; case suite_itemviewobjectname: if(item->dataobject) ! view_SetDataObject(item->viewobject,item->dataobject); ! suiteev_ItemUpdate(SetView,item); break; case suite_itemdataobjecthandler: case suite_itemhithandler: --- 2243,2257 ---- view_UnlinkTree(item->viewobject); view_Destroy(item->viewobject); } ! AllocNameSpace(&item->viewobjectname, dataobject_ViewName(item->dataobject)); item->viewobject = ! (struct view*) class_NewObject(item->viewobjectname); ! view_SetDataObject(item->viewobject, item->dataobject); break; case suite_itemviewobjectname: if(item->dataobject) ! view_SetDataObject(item->viewobject, item->dataobject); ! suiteev_ItemUpdate(SetView, item); break; case suite_itemdataobjecthandler: case suite_itemhithandler: *************** *** 2287,2316 **** default: fprintf(stderr,"Suite: Unknown Item Attribute (%d)\n",attribute); break; ! } } long suite__ChangeItemAttribute( self, item, attribute, value ) ! register struct suite *self; ! register struct suite_item *item; ! register long attribute, value; { ! register long status = 0; ! ChangeItemAttribute(self,item,attribute,value); ! return(status); } long suite__ItemAttribute( self, item, attribute ) ! register struct suite *self; ! register struct suite_item *item; ! register long attribute; { ! register long value = 0; ! switch(attribute) { case suite_itemposition: if(Items) value = vector_Subscript(Items,(long)item); --- 2283,2312 ---- default: fprintf(stderr,"Suite: Unknown Item Attribute (%d)\n",attribute); break; ! } } long suite__ChangeItemAttribute( self, item, attribute, value ) ! register struct suite *self; ! register struct suite_item *item; ! register long attribute, value; { ! register long status = 0; ! ChangeItemAttribute(self,item,attribute,value); ! return(status); } long suite__ItemAttribute( self, item, attribute ) ! register struct suite *self; ! register struct suite_item *item; ! register long attribute; { ! register long value = 0; ! switch(attribute) { case suite_itemposition: if(Items) value = vector_Subscript(Items,(long)item); *************** *** 2317,2322 **** --- 2313,2320 ---- if(value != -1) value += 1; break; case suite_itemcaption: value = (long) item_Caption; break; + case suite_itemname: + value = (long) item_Name; break; case suite_itemcaptionfontname: value = (long) item->captionfontname; break; case suite_itemtitlecaption: *************** *** 2354,2498 **** default: fprintf(stderr,"Suite: Unknown Item Attribute (%d)\n",attribute); break; ! } ! return(value); } ! struct suite_item * suite__ItemOfDatum( self, datum ) ! register struct suite *self; ! register long datum; { ! register struct suite_item *item = NULL; ! register int i = 0; ! if(Items && ITEM(0)) ! while(item = ITEM(i++)) if(datum == (long)item->datum) return(item); ! return(NULL); } struct suite_item ** suite__ItemsOfDatum( self, datum ) ! register struct suite *self; ! register long datum; { ! register int i = 0; ! register struct suite_item *item = NULL; ! register int count = 0; ! if(Items && ITEM(0)) { ! while(item = ITEM(i++)) if(datum == (long)item->datum) count++; ! suiteev_AllocItemArray(SetView,count); ! i = count = 0; ! while(item = ITEM(i++)) ! if(datum == (long)item->datum) ItemArray[count++] = item; ! } ! else return(NULL); ! return(ItemArray); } struct suite_item * suite__ItemOfName( self, name ) ! register struct suite *self; ! register char *name; { ! register struct suite_item *item = NULL; ! register int i = 0; ! if(Items && ITEM(0)) ! while(item = ITEM(i++)) ! if((!name || !(*name)) && ! (suite_ItemAttribute(self,item,suite_ItemName(0)) == (long)name)) ! return(item); ! else if(!strcmp(name,suite_ItemAttribute(self,item,suite_ItemName(0)))) ! return(item); ! return(NULL); } struct suite_item ** suite__ItemsOfName( self, name ) ! register struct suite *self; ! register char *name; { ! register int i = 0, count = 0; ! register struct suite_item *item = NULL; ! if(Items && ITEM(0)) { ! while(item = ITEM(i++)) ! if((!name || !(*name)) && ! (suite_ItemAttribute(self,item,suite_ItemName(0)) == (long)name)) ! count++; ! else if(!strcmp(name,suite_ItemAttribute(self,item,suite_ItemName(0)))) ! count++; ! suiteev_AllocItemArray(SetView,count); ! i = count = 0; ! while(item = ITEM(i++)) ! if((!name || !(*name)) && ! (suite_ItemAttribute(self,item,suite_ItemName(0)) == (long)name)) ! ItemArray[count++] = item; ! else if(!strcmp(name,suite_ItemAttribute(self,item,suite_ItemName(0)))) ! ItemArray[count++] = item; ! } ! else return(NULL); ! return(ItemArray); } struct suite_item * suite__ItemAtPosition( self, position ) ! register struct suite *self; ! register long position; { ! register struct suite_item *item = NULL; ! IN(suite_ItemAtPosition); ! if((position > 0) && (position < (suite_ItemCount(self) + 1))) ! item = ITEM(position-1); ! OUT(suite_ItemAtPosition); ! return(item); } static void DefaultExceptionHandler( self ) ! register struct suite *self; { ! char msg[1000]; ! long result; ! static char *continue_choice[2] = {"continue",0}; ! sprintf(msg, "Suite: DefaultExceptionHandler:: exception code '%d' detected.", suite_ExceptionCode(self) ); message_MultipleChoiceQuestion(self,100,msg,0,&result,continue_choice,NULL); ! if(ExceptionItem) { ! sprintf(msg, "Suite: DefaultExceptionHandler:: exception item caption '%s'.", ! suite_ItemAttribute(self,ExceptionItem,suite_ItemCaption(0))); ! message_MultipleChoiceQuestion(self,100,msg,0,&result,continue_choice,NULL); ! } } static void HandleException( self, item, code ) ! register struct suite *self; ! register struct suite_item *item; ! register long code; { ! DEBUGdt(Code,code); ! ExceptionStatus = code; ! ExceptionItem = item; ! if(ExceptionHandler) ! ExceptionHandler(ClientAnchor,self,item,ExceptionStatus); ! else DefaultExceptionHandler(self); } static void ValidateItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! if(!item || !Items || ! (Items && (vector_Subscript(Items,(unsigned int)item)) == -1)) ! HandleException(self,item,suite_NonExistentItem); } ! /*** Following in support of Ness ***/ struct nametbl { --- 2352,2570 ---- default: fprintf(stderr,"Suite: Unknown Item Attribute (%d)\n",attribute); break; ! } ! return(value); } ! struct suite_item * suite__ItemOfDatum( self, datum ) ! register struct suite *self; ! register long datum; { ! register struct suite_item *item = NULL; ! register int i = 0; ! if(Items && ITEM(0)) ! while(item = ITEM(i++)) if(datum == (long)item->datum) ! return(item); ! return(NULL); } struct suite_item ** suite__ItemsOfDatum( self, datum ) ! register struct suite *self; ! register long datum; { ! register int i = 0; ! register struct suite_item *item = NULL; ! register int count = 0; ! if(Items && ITEM(0)) { ! while(item = ITEM(i++)) if(datum == (long)item->datum) count++; ! suiteev_AllocItemArray(SetView,count); ! i = count = 0; ! while(item = ITEM(i++)) ! if(datum == (long)item->datum) ItemArray[count++] = item; ! } ! else return(NULL); ! return(ItemArray); } struct suite_item * suite__ItemOfName( self, name ) ! register struct suite *self; ! register char *name; { ! register struct suite_item *item = NULL; ! register int i = 0; ! if(Items && ITEM(0)) ! while(item = ITEM(i++)) ! if((!name || !(*name)) && ! (suite_ItemAttribute(self,item,suite_ItemName(0)) == (long)name)) ! return(item); ! else if(!strcmp(name,suite_ItemAttribute(self,item,suite_ItemName(0)))) ! return(item); ! return(NULL); } struct suite_item ** suite__ItemsOfName( self, name ) ! register struct suite *self; ! register char *name; { ! register int i = 0, count = 0; ! register struct suite_item *item = NULL; ! if(Items && ITEM(0)) { ! while(item = ITEM(i++)) ! if((!name || !(*name)) && ! (suite_ItemAttribute(self,item,suite_ItemName(0)) == (long)name)) ! count++; ! else if(!strcmp(name,suite_ItemAttribute(self,item,suite_ItemName(0)))) ! count++; ! suiteev_AllocItemArray(SetView,count); ! i = count = 0; ! while(item = ITEM(i++)) ! if((!name || !(*name)) && ! (suite_ItemAttribute(self,item,suite_ItemName(0)) == (long)name)) ! ItemArray[count++] = item; ! else if(!strcmp(name,suite_ItemAttribute(self,item,suite_ItemName(0)))) ! ItemArray[count++] = item; ! } ! else return(NULL); ! return(ItemArray); } struct suite_item * suite__ItemAtPosition( self, position ) ! register struct suite *self; ! register long position; { ! register struct suite_item *item = NULL; ! IN(suite_ItemAtPosition); ! if((position > 0) && (position < (suite_ItemCount(self) + 1))) ! item = ITEM(position-1); ! OUT(suite_ItemAtPosition); ! return(item); } static void DefaultExceptionHandler( self ) ! register struct suite *self; { ! char msg[1000]; ! long result; ! static char *continue_choice[2] = {"continue",0}; ! sprintf(msg, "Suite: DefaultExceptionHandler:: exception code '%d' detected.", suite_ExceptionCode(self) ); + message_MultipleChoiceQuestion(self,100,msg,0,&result,continue_choice,NULL); + if(ExceptionItem) { + sprintf(msg, "Suite: DefaultExceptionHandler:: exception item caption '%s'.", + suite_ItemAttribute(self,ExceptionItem,suite_ItemCaption(0))); message_MultipleChoiceQuestion(self,100,msg,0,&result,continue_choice,NULL); ! } } static void HandleException( self, item, code ) ! register struct suite *self; ! register struct suite_item *item; ! register long code; { ! DEBUGdt(Code,code); ! ExceptionStatus = code; ! ExceptionItem = item; ! if(ExceptionHandler) ! ExceptionHandler(ClientAnchor,self,item,ExceptionStatus); ! else DefaultExceptionHandler(self); } static void ValidateItem( self, item ) ! register struct suite *self; ! register struct suite_item *item; { ! if(!item || !Items || ! (Items && (vector_Subscript(Items,(unsigned int)item)) == -1)) ! HandleException(self,item,suite_NonExistentItem); } ! ! void ! suite__HighlightTitle( self ) ! struct suite *self; ! { ! unsigned type = 0; ! struct rectangle *rect = rectangle_Duplicate(&TitleRect); ! ! if(TitleHighlightStyle & (suite_Bold | suite_Italic)) { ! if(TitleHighlightStyle & suite_Bold) type = fontdesc_Bold; ! if(TitleHighlightStyle & suite_Italic) type |= fontdesc_Italic; ! TitleFont = fontdesc_Create(TitleFontName,RealTitleFontType = type,TitleFontSize); ! DrawTitle(self,rect); ! } ! else if(TitleHighlightStyle == suite_Invert) { ! SetTransferMode(self,graphic_INVERT); ! suite_FillRect(self,rect,suite_BlackPattern(self)); ! } ! else if(TitleHighlightStyle == suite_Border) { ! DecrementRect(rect,1); ! DrawOutline(self,rect,TitleBorderSize,TitleBorderStyle); ! } ! TitleHighlighted = TRUE; ! } ! ! void ! suite__NormalizeTitle( self ) ! struct suite *self; ! { ! struct rectangle *rect = rectangle_Duplicate(&TitleRect); ! ! RealTitleFontType = TitleFontType; ! if(TitleHighlightStyle & (suite_Bold | suite_Italic)) { ! TitleFont = fontdesc_Create(TitleFontName,RealTitleFontType,TitleFontSize); ! DrawTitle(self,rect); ! } ! else if(TitleHighlightStyle == suite_Invert) { ! SetTransferMode(self,graphic_INVERT); ! suite_FillRect(self,rect,suite_BlackPattern(self)); ! } ! else if(TitleHighlightStyle == suite_Border) { ! DrawTitle(self,rect); ! } ! TitleHighlighted = FALSE; ! } ! ! static void ! DrawRectSize(self,x, y,width,height) ! struct suite *self; ! long x, y, width, height; ! { ! long left = x; ! long right = x+width-1; ! long top = y; ! long bottom = y+height-1; ! ! if(left > right) left = right; ! if(top > bottom) top = bottom; ! ! suite_MoveTo(self,left,top); ! suite_DrawLineTo(self,right,top); ! suite_DrawLineTo(self,right,bottom); ! suite_DrawLineTo(self,left,bottom); ! suite_DrawLineTo(self,left,top); ! } ! ! static void ! DrawRect(self, Rect) ! struct suite *self; ! struct rectangle *Rect; ! { ! DrawRectSize(self,rectangle_Left(Rect),rectangle_Top(Rect), rectangle_Width(Rect), rectangle_Height(Rect)); ! } ! /*** Following in support of Ness ***/ struct nametbl { *************** *** 2634,2704 **** static struct nametbl* FindIndex( tbl, name ) ! register struct nametbl *tbl; ! register unsigned char *name; { ! register struct nametbl *e; ! for(e = tbl; e->name != NULL && strcmp(name, e->name) != 0; e++) {} ! if(e->name == NULL) return(NULL); ! return(e); } static void SetItems(self, elts) ! register struct suite *self; ! register char *elts; { ! register char *tmp = NULL, *ret = NULL, **captions = NULL; ! char *copy = NULL; ! register int count = 1, i = 0; ! IN(SetItems); ! if(elts && *elts) { ! tmp = elts; ! AllocNameSpace(©,elts); ! if(!copy) return; ! while(ret = (char*)index(tmp,':')) { ! count++; ! tmp = ++ret; ! } ! if(count>0) { ! tmp = copy; ! if(!(captions = (char**) calloc(count+1,sizeof(char*)))) { ! free(copy); ! return; ! } ! for(i = 0;iindex,val); } static void SetEltAttrByName(self, item, attr, val) ! register struct suite *self; ! register unsigned char *item; ! register unsigned char *attr; ! register long val; { /* XXX DEFER SetEltAttrByName */ } --- 2706,2776 ---- static struct nametbl* FindIndex( tbl, name ) ! register struct nametbl *tbl; ! register unsigned char *name; { ! register struct nametbl *e; ! for(e = tbl; e->name != NULL && strcmp(name, e->name) != 0; e++) {} ! if(e->name == NULL) return(NULL); ! return(e); } static void SetItems(self, elts) ! register struct suite *self; ! register char *elts; { ! register char *tmp = NULL, *ret = NULL, **captions = NULL; ! char *copy = NULL; ! register int count = 1, i = 0; ! IN(SetItems); ! if(elts && *elts) { ! tmp = elts; ! AllocNameSpace(©,elts); ! if(!copy) return; ! while(ret = (char*)index(tmp,':')) { ! count++; ! tmp = ++ret; } ! if(count>0) { ! tmp = copy; ! if(!(captions = (char**) calloc(count+1,sizeof(char*)))) { ! free(copy); ! return; ! } ! for(i = 0;iindex,val); } static void SetEltAttrByName(self, item, attr, val) ! register struct suite *self; ! register unsigned char *item; ! register unsigned char *attr; ! register long val; { /* XXX DEFER SetEltAttrByName */ } *************** *** 2706,2804 **** static void SetValByName( self, attr, cval ) ! register struct suite *self; ! register unsigned char *attr; ! register unsigned char *cval; { ! register struct nametbl *tblelt, *valindex; ! tblelt = FindIndex(attrTable,attr); ! if(tblelt->name == NULL) return; ! if (tblelt->valtbl == NULL) return; ! valindex = FindIndex(tblelt->valtbl,cval); ! if(valindex == NULL) return; ! SetSuiteAttribute(self,tblelt->index,valindex->index); } static void SetEltValByName( self, item, attr, cval ) ! register struct suite *self; ! register unsigned char *item; ! register unsigned char *attr; ! register unsigned char *cval; { /* XXX DEFER SetEltValByName */ } - void - suite__HighlightTitle( self ) - struct suite *self; - { - unsigned type = 0; - struct rectangle *rect = rectangle_Duplicate(&TitleRect); - - if(TitleHighlightStyle & (suite_Bold | suite_Italic)) { - if(TitleHighlightStyle & suite_Bold) type = fontdesc_Bold; - if(TitleHighlightStyle & suite_Italic) type |= fontdesc_Italic; - TitleFont = fontdesc_Create(TitleFontName,RealTitleFontType = type,TitleFontSize); - DrawTitle(self,rect); - } - else if(TitleHighlightStyle == suite_Invert) { - SetTransferMode(self,graphic_INVERT); - suite_FillRect(self,rect,suite_BlackPattern(self)); - } - else if(TitleHighlightStyle == suite_Border) { - DecrementRect(rect,1); - DrawOutline(self,rect,TitleBorderSize,TitleBorderStyle); - } - TitleHighlighted = TRUE; - } - - void - suite__NormalizeTitle( self ) - struct suite *self; - { - struct rectangle *rect = rectangle_Duplicate(&TitleRect); - - RealTitleFontType = TitleFontType; - if(TitleHighlightStyle & (suite_Bold | suite_Italic)) { - TitleFont = fontdesc_Create(TitleFontName,RealTitleFontType,TitleFontSize); - DrawTitle(self,rect); - } - else if(TitleHighlightStyle == suite_Invert) { - SetTransferMode(self,graphic_INVERT); - suite_FillRect(self,rect,suite_BlackPattern(self)); - } - else if(TitleHighlightStyle == suite_Border) { - DrawTitle(self,rect); - } - TitleHighlighted = FALSE; - } - - static void - DrawRectSize(self,x, y,width,height) - struct suite * self; - long x,y,width,height; - { - long left = x; - long right = x+width-1; - long top = y; - long bottom = y+height-1; - - if (left > right) left = right; - if(top > bottom) top = bottom; - - suite_MoveTo(self,left,top); - suite_DrawLineTo(self,right,top); - suite_DrawLineTo(self,right,bottom); - suite_DrawLineTo(self,left,bottom); - suite_DrawLineTo(self,left,top); - } - - static void - DrawRect(self, Rect) - struct suite * self; - struct rectangle * Rect; - { - DrawRectSize(self,rectangle_Left(Rect),rectangle_Top(Rect), rectangle_Width(Rect), rectangle_Height(Rect)); - } --- 2778,2804 ---- static void SetValByName( self, attr, cval ) ! register struct suite *self; ! register unsigned char *attr; ! register unsigned char *cval; { ! register struct nametbl *tblelt, *valindex; ! tblelt = FindIndex(attrTable,attr); ! if(tblelt->name == NULL) return; ! if (tblelt->valtbl == NULL) return; ! valindex = FindIndex(tblelt->valtbl,cval); ! if(valindex == NULL) return; ! SetSuiteAttribute(self,tblelt->index,valindex->index); } static void SetEltValByName( self, item, attr, cval ) ! register struct suite *self; ! register unsigned char *item; ! register unsigned char *attr; ! register unsigned char *cval; { /* XXX DEFER SetEltValByName */ } *** atk/apt/suite/suite.ch Wed Apr 11 14:17:55 1990 --- atk/apt/suite/suite.ch.NEW Thu May 10 16:22:57 1990 *************** *** 4,10 **** \* ********************************************************************** */ #ifndef lint ! static char *rcsidsuite_ch = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/apt/suite/RCS/suite.ch,v 1.19 90/03/05 12:16:23 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* --- 4,10 ---- \* ********************************************************************** */ #ifndef lint ! static char *rcsidsuite_ch = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/apt/suite/RCS/suite.ch,v 1.20 90/05/10 14:54:50 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* *************** *** 320,326 **** #define suite_Defer (1<<6) #define suite_Expose (1<<7) ! #define suite_NoCursor (200) /*** Exception Codes ***/ #define suite_NonExistentItem (1) --- 320,326 ---- #define suite_Defer (1<<6) #define suite_Expose (1<<7) ! #define suite_NoCursor (0) /*** Exception Codes ***/ #define suite_NonExistentItem (1) *** atk/apt/suite/suite.h Wed Nov 22 11:45:44 1989 --- atk/apt/suite/suite.h.NEW Thu May 10 16:22:59 1990 *************** *** 7,17 **** /* $Source $ */ #ifndef lint ! static char *rcsidsuite_h = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/apt/suite/RCS/suite.h,v 1.5 89/09/29 15:55:06 gk5g Exp $"; #endif /* $Log: suite.h,v $ * Revision 1.5 89/09/29 15:55:06 gk5g * Added macro item_RealCaptionFontSize. * --- 7,20 ---- /* $Source $ */ #ifndef lint ! static char *rcsidsuite_h = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/apt/suite/RCS/suite.h,v 1.6 90/04/27 15:36:59 gk5g Exp $"; #endif /* $Log: suite.h,v $ + * Revision 1.6 90/04/27 15:36:59 gk5g + * Added item_Name macro. + * * Revision 1.5 89/09/29 15:55:06 gk5g * Added macro item_RealCaptionFontSize. * *************** *** 66,71 **** --- 69,75 ---- (item->bounds).width = (WIDTH);(item->bounds).height = (HEIGHT) #define item_Caption (item->caption?item->caption:item->name) + #define item_Name (item->name?item->name:item->caption) #define item_CaptionPlacement \ ((item->captionplacement)?(item->captionplacement):(item->suite->captionplacement)) #define item_CaptionAlignment \ *** atk/apt/suite/suitecv.c Wed Jan 17 16:36:30 1990 --- atk/apt/suite/suitecv.c.NEW Wed Jun 13 20:29:10 1990 *************** *** 7,17 **** /* $Source $ */ #ifndef lint ! static char *rcsidsuitecv_c = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/apt/suite/RCS/suitecv.c,v 1.13 89/12/14 15:14:28 cfe Exp $"; #endif /* $Log: suitecv.c,v $ * Revision 1.13 89/12/14 15:14:28 cfe * Sync with MIT tape (add additional log stuff). * --- 7,21 ---- /* $Source $ */ #ifndef lint ! static char *rcsidsuitecv_c = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/apt/suite/RCS/suitecv.c,v 1.14 90/06/13 19:02:18 gk5g Exp $"; #endif /* $Log: suitecv.c,v $ + * Revision 1.14 90/06/13 19:02:18 gk5g + * Added use of fontdesc_StringBoundingBox method contributed by Bill Janssen. + * Changed the way ItemFullUpdate handles a suite_item that simply has a handle on a child-view. Now just insert it and FullUpdate it. + * * Revision 1.13 89/12/14 15:14:28 cfe * Sync with MIT tape (add additional log stuff). * *************** *** 112,117 **** --- 116,123 ---- #define ParentItem ((self)->parent_item) #define KeyState ((self)->kstate) #define Debug ((self)->debug) + #define Suite ((EV)->parent) + #define ClientAnchor ((Suite)->anchor) void suitecv_InsertNLCmd(); static struct keymap *KeyMap; *************** *** 152,158 **** struct suitecv *self; long key; { ! suiteev_WantInputFocus(EV,EV); } void --- 158,167 ---- struct suitecv *self; long key; { ! if(ClientAnchor) ! suitecv_WantInputFocus(self,ClientAnchor); ! else ! suitecv_WantInputFocus(self,Suite); } void *** atk/apt/suite/suiteev.ch Wed Nov 22 11:45:38 1989 --- atk/apt/suite/suiteev.ch.NEW Thu May 10 16:23:02 1990 *************** *** 7,17 **** /* $Source $ */ #ifndef lint ! static char *rcsidsuiteev_ch = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/apt/suite/RCS/suiteev.ch,v 1.8 89/11/02 18:58:27 gk5g Exp $"; #endif /* $Log: suiteev.ch,v $ Revision 1.8 89/11/02 18:58:27 gk5g Added instance variable firstvisiblesubstring. --- 7,20 ---- /* $Source $ */ #ifndef lint ! static char *rcsidsuiteev_ch = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/apt/suite/RCS/suiteev.ch,v 1.9 90/05/08 15:50:21 gk5g Exp $"; #endif /* $Log: suiteev.ch,v $ + Revision 1.9 90/05/08 15:50:21 gk5g + Just cleaned up a bit. + Revision 1.8 89/11/02 18:58:27 gk5g Added instance variable firstvisiblesubstring. *************** *** 69,83 **** HISTORY 11/01/88 Created (GW Keim) 05/04/89 Changed to lower-case naming convention (GW Keim) ! END-SPECIFICATION ************************************************************/ ! ! class suiteev: view{ classprocedures: ! InitializeClass() returns boolean; ! InitializeObject() returns boolean; ! FinalizeObject(); overrides: ! FullUpdate(enum view_UpdateType type,long left,long top,long width,long height ); GetInterface(char *type) returns char*; Hit(enum view_MouseAction action,long x,long y,long numClicks) returns struct view *; Update(); --- 72,87 ---- HISTORY 11/01/88 Created (GW Keim) 05/04/89 Changed to lower-case naming convention (GW Keim) ! END-SPECIFICATION ! **********************************************************/ ! ! class suiteev : view { classprocedures: ! InitializeClass(struct classheader *ClassID) returns boolean; ! InitializeObject(struct classheader *ClassID, struct suiteev *self) returns boolean; ! FinalizeObject(struct classheader *ClassID, struct suiteev *self); overrides: ! FullUpdate(enum view_UpdateType type,long left,long top,long width,long height); GetInterface(char *type) returns char*; Hit(enum view_MouseAction action,long x,long y,long numClicks) returns struct view *; Update(); *** atk/apt/suite/suiteta.c Wed Apr 11 14:18:08 1990 --- atk/apt/suite/suiteta.c.NEW Wed Jun 13 20:29:12 1990 *************** *** 8,24 **** ** ** \**********************************/ ! #include "frame.ih" ! #include "im.ih" ! #include "filetype.ih" ! #include "lpair.ih" ! #include "text.ih" ! #include "textv.ih" ! #include "cursor.ih" ! #include "suite.ih" ! #include "apt.h" ! #include "apts.ih" ! #include "suiteta.eh" struct view *Name_Choice(), *RW_Hit_Handler(), *First_Test(), *Last_Test(), *Number_Test(), --- 8,24 ---- ** ** \**********************************/ ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include struct view *Name_Choice(), *RW_Hit_Handler(), *First_Test(), *Last_Test(), *Number_Test(), *** atk/apt/suite/vector.c Wed Nov 22 11:45:42 1989 --- atk/apt/suite/vector.c.NEW Thu May 10 16:23:05 1990 *************** *** 7,28 **** /* $Source $ */ #ifndef lint ! static char *rcsidvector_c = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/apt/suite/RCS/vector.c,v 1.3 89/07/28 18:49:20 gk5g Exp $"; #endif - /* - $Log: vector.c,v $ - * Revision 1.3 89/07/28 18:49:20 gk5g - * Reset removed data items to NULL in vector_DestroyItem() - * - * Revision 1.2 89/07/19 12:43:59 gk5g - * In vector_RemoveItem() now index the vector explicitly instead of relying on a terminating NULL data field. It is perfectly OK to have NULL data anywhere in the vector. NOTE: There may be more instances of this NULL-terminator reliance. - * - * Revision 1.1 89/04/28 20:26:48 tom - * Initial revision - * - */ - /** SPECIFICATION -- External Facility Suite ********************************* TITLE The Vector-object --- 7,15 ---- /* $Source $ */ #ifndef lint ! static char *rcsidvector_c = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/apt/suite/RCS/vector.c,v 1.4 90/04/25 17:55:15 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* TITLE The Vector-object *************** *** 55,64 **** 07/28/89 Reset removed data items to NULL in vector_DestroyItem(); (GW Keim); END-SPECIFICATION ************************************************************/ - #include #include ! #include "vector.eh" #define Data (self->data) #define InitialDataSize (self->initial_vector_count) --- 42,50 ---- 07/28/89 Reset removed data items to NULL in vector_DestroyItem(); (GW Keim); END-SPECIFICATION ************************************************************/ #include #include ! #include #define Data (self->data) #define InitialDataSize (self->initial_vector_count) *************** *** 73,238 **** boolean vector__InitializeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct vector *self; { ! Data = NULL; ! Debug = DataSize = DataUsed = InitialDataSize = ReallocFactor = 0; ! ApplyProc = Sorter = Destroyer = NULL; ! return(TRUE); } struct vector * vector__Create( ClassID, init_data_size, reallocfactor ) ! register struct classheader *ClassID; ! register long init_data_size, reallocfactor; { ! register struct vector *self = NULL; ! if( !(self = vector_New()) ) { ! printf("vector: couldn't allocate new object.\n"); ! exit(-1); ! } ! DataSize = InitialDataSize = init_data_size; ! ReallocFactor = reallocfactor; ! if( !(Data = (long*) calloc( InitialDataSize + 1, sizeof(long)) )) { ! printf("vector:couldn't allocate enough memory.\n"); ! exit(-1); ! } ! return(self); } void vector__FinalizeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct vector *self; { ! register long i = 0; ! if(Data) ! if(Destroyer) ! while((i < DataUsed) && Data[i]) ! Destroyer(Data[i++]); ! if(Data) { ! free(Data); ! Data = NULL; ! } } static void ReallocData( self ) ! register struct vector *self; { ! register long i = 0; ! DataSize *= ReallocFactor; ! if( !(Data = (long*) realloc( Data, sizeof(long) * (DataSize + 1))) ) { ! printf("vector: couldn't allocate enough memory.\n"); ! exit(-1); ! } ! i = DataUsed; ! while(i < (DataSize+1)) Data[i++] = 0; } long vector__AddItem( self, item ) ! register struct vector *self; ! long item; { ! register long i = 0, ! insertOffset = 0, ! end = 0; ! if(!DataSpaceAvailable) ! ReallocData(self); ! if(Sorter) { ! while(Data[i] && (Sorter(&Data[i],&item) < 0)) i++; ! insertOffset = i; ! end = DataUsed - 1; ! while(end >= insertOffset) { ! Data[end + 1] = Data[end]; ! end--; ! } } ! else insertOffset = DataUsed; ! Data[insertOffset] = item; ! DataUsed++; ! return(insertOffset); } boolean vector__ItemExists( self, item ) ! register struct vector *self; ! register long item; { ! if(vector_Subscript(self,item) != -1) ! return(TRUE); ! else ! return(FALSE); } long vector__RemoveItem( self, item ) ! register struct vector *self; ! register long item; { ! register long i = 0, removeOffset = 0; ! while(Data[i]) { ! if(Data[i] == item) { ! removeOffset = i; ! while((i+1) < DataUsed) { ! Data[i] = Data[i+1]; ! i++; ! } ! DataUsed--; ! Data[DataUsed] = NULL; ! return(removeOffset); ! } ! else i++; } ! return(-1); } long vector__Sort( self ) ! register struct vector *self; { ! register long status = 0; ! if(!Sorter) ! status = vector_status_no_sort_routine; ! else ! qsort(Data,DataSize,sizeof(long),Sorter); ! return(status); } long vector__Subscript( self, item ) ! register struct vector *self; ! register long item; { ! register long i = 0; ! if(Data) ! while((i < DataUsed) && Data[i]) ! if(Data[i] == item) ! return(i); ! else ! i++; ! return(-1); } void vector__Apply( self, proc ) ! register struct vector *self; ! long (*proc)(); { ! register int i = 0, status = 0; ! if(Data && Data[0]) ! for( i = 0 ; (i < DataUsed) && !status ; i++ ) ! status = proc(Data[i]); } --- 59,223 ---- boolean vector__InitializeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct vector *self; { ! Data = NULL; ! Debug = DataSize = DataUsed = InitialDataSize = ReallocFactor = 0; ! ApplyProc = Sorter = Destroyer = NULL; ! return(TRUE); } struct vector * vector__Create( ClassID, init_data_size, reallocfactor ) ! register struct classheader *ClassID; ! register long init_data_size, reallocfactor; { ! register struct vector *self = NULL; ! if(!(self = vector_New())) { ! printf("vector: couldn't allocate new object.\n"); ! exit(-1); ! } ! DataSize = InitialDataSize = init_data_size; ! ReallocFactor = reallocfactor; ! if(!(Data = (long*) calloc(InitialDataSize + 1, sizeof(long)))) { ! printf("vector:couldn't allocate enough memory.\n"); ! exit(-1); ! } ! return(self); } void vector__FinalizeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct vector *self; { ! register long i = 0; ! if(Data) ! if(Destroyer) ! while((i < DataUsed) && Data[i]) ! Destroyer(Data[i++]); ! if(Data) { ! free(Data); ! Data = NULL; ! } } static void ReallocData( self ) ! register struct vector *self; { ! register long i = 0; ! DataSize *= ReallocFactor; ! if(!(Data = (long*) realloc(Data,sizeof(long) * (DataSize + 1)))) { ! printf("vector: couldn't allocate enough memory.\n"); ! exit(-1); ! } ! i = DataUsed; ! while(i < (DataSize+1)) ! Data[i++] = 0; } long vector__AddItem( self, item ) ! register struct vector *self; ! long item; { ! register long i = 0, insertOffset = 0, end = 0; ! if(!DataSpaceAvailable) ! ReallocData(self); ! if(Sorter) { ! while(Data[i] && (Sorter(&Data[i],&item) < 0)) i++; ! insertOffset = i; ! end = DataUsed - 1; ! while(end >= insertOffset) { ! Data[end + 1] = Data[end]; ! end--; } ! } ! else insertOffset = DataUsed; ! Data[insertOffset] = item; ! DataUsed++; ! return(insertOffset); } boolean vector__ItemExists( self, item ) ! register struct vector *self; ! register long item; { ! if(vector_Subscript(self,item) != -1) ! return(TRUE); ! else ! return(FALSE); } long vector__RemoveItem( self, item ) ! register struct vector *self; ! register long item; { ! register long i = 0, removeOffset = 0; ! while(Data[i]) { ! if(Data[i] == item) { ! removeOffset = i; ! while((i+1) < DataUsed) { ! Data[i] = Data[i+1]; ! i++; ! } ! DataUsed--; ! Data[DataUsed] = NULL; ! return(removeOffset); } ! else i++; ! } ! return(-1); } long vector__Sort( self ) ! register struct vector *self; { ! register long status = 0; ! if(!Sorter) ! status = vector_status_no_sort_routine; ! else ! qsort(Data,DataUsed,sizeof(long),Sorter); ! return(status); } long vector__Subscript( self, item ) ! register struct vector *self; ! register long item; { ! register long i = 0; ! if(Data) ! while((i < DataUsed) && Data[i]) ! if(Data[i] == item) ! return(i); ! else ! i++; ! return(-1); } void vector__Apply( self, proc ) ! register struct vector *self; ! long (*proc)(); { ! register int i = 0, status = 0; ! if(Data && Data[0]) ! for(i = 0 ; (i < DataUsed) && !status ; i++) ! status = proc(Data[i]); } *** atk/atkvers/atkvers.num Wed Apr 11 14:18:21 1990 --- atk/atkvers/atkvers.num.NEW Fri Jul 20 11:23:16 1990 *************** *** 1 **** ! 14.6 --- 1 ---- ! 15.0 *** atk/basics/wm/wgraphic.c Wed Nov 22 11:46:50 1989 --- atk/basics/wm/wgraphic.c.NEW Thu May 10 16:23:18 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/wm/RCS/wgraphic.c,v 1.6 89/08/29 15:58:51 wjh Exp $ */ /* $ACIS:graphic.c 1.6$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/wm/RCS/wgraphic.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/wm/RCS/wgraphic.c,v 1.6 89/08/29 15:58:51 wjh Exp $"; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/wm/RCS/wgraphic.c,v 1.8 90/05/09 14:20:28 ajp Exp $ */ /* $ACIS:graphic.c 1.6$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/wm/RCS/wgraphic.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/wm/RCS/wgraphic.c,v 1.8 90/05/09 14:20:28 ajp Exp $"; #endif /* lint */ #include *************** *** 27,63 **** #include #include #include - #if 0 - #define wmgraphic_GetLogicalWidth(self) \ - (((struct graphic *)self)->localBounds.width) - #define wmgraphic_GetLogicalHeight(self) \ - (((struct graphic *)self)->localBounds.height) - #define wmgraphic_GetLogicalLeft(self) \ - (((struct graphic *)self)->localBounds.left) - #define wmgraphic_GetLogicalTop(self) \ - (((struct graphic *)self)->localBounds.top) - #define wmgraphic_GetVisualWidth(self) \ - (((struct graphic *)self)->visualBounds.width) - #define wmgraphic_GetVisualHeight(self) \ - (((struct graphic *)self)->visualBounds.height) - #define wmgraphic_GetVisualLeft(self) \ - (((struct graphic *)self)->visualBounds.left) - #define wmgraphic_GetVisualTop(self) \ - (((struct graphic *)self)->visualBounds.top) - - #define wmgraphic_GetEnclosedWidth(self) \ - (((struct graphic *)self)->localBounds.width) - #define wmgraphic_GetEnclosedHeight(self) \ - (((struct graphic *)self)->localBounds.height) - #define wmgraphic_GetEnclosedLeft(self) \ - (point_X(&(((struct graphic *)self)->enclosedOrigin))) - #define wmgraphic_GetEnclosedTop(self) \ - (point_Y(&(((struct graphic *)self)->enclosedOrigin))) - - #endif /* 0 */ - struct wm_saved_state_vector { struct wm_saved_state_vector * next_vector; struct wm_window * associatedWindow; --- 27,35 ---- #include #include #include + #include struct wm_saved_state_vector { struct wm_saved_state_vector * next_vector; struct wm_window * associatedWindow; *************** *** 611,618 **** /* clip the rectangle to avoid a bug in WM - 3 July 1989 */ wmgraphic_GetVisualBounds(self, &Temp); ! if (self->header.graphic.clippingRect) ! rectangle_IntersectRect(&Temp, &Temp, self->header.graphic.clippingRect); rectangle_IntersectRect(&Temp, Rect, &Temp); if (rectangle_Width(&Temp) <= 0 || rectangle_Height(&Temp) <= 0) --- 583,596 ---- /* clip the rectangle to avoid a bug in WM - 3 July 1989 */ wmgraphic_GetVisualBounds(self, &Temp); ! if (self->header.graphic.clippingRegion) { ! struct rectangle clipRect; ! ! region_GetBoundingBox(self->header.graphic.clippingRegion, &clipRect); ! ! rectangle_IntersectRect(&Temp, &Temp, &clipRect); ! } ! rectangle_IntersectRect(&Temp, Rect, &Temp); if (rectangle_Width(&Temp) <= 0 || rectangle_Height(&Temp) <= 0) *************** *** 929,937 **** wmgraphic_GetVisualBounds(self,&Temp); ! if (self->header.graphic.clippingRect) ! rectangle_IntersectRect(&Temp,&Temp,self->header.graphic.clippingRect); physical_LogicalToGlobalRect(self,&Temp); wm_SetClipRectangle(rectangle_Left(&Temp), rectangle_Top(&Temp), rectangle_Width(&Temp), rectangle_Height(&Temp)); --- 907,919 ---- wmgraphic_GetVisualBounds(self,&Temp); ! if (self->header.graphic.clippingRegion) { ! struct rectangle clipRect; + region_GetBoundingBox(self->header.graphic.clippingRegion, &clipRect); + rectangle_IntersectRect(&Temp ,&Temp, &clipRect); + } + physical_LogicalToGlobalRect(self,&Temp); wm_SetClipRectangle(rectangle_Left(&Temp), rectangle_Top(&Temp), rectangle_Width(&Temp), rectangle_Height(&Temp)); *************** *** 971,988 **** } - void wmgraphic__InsertGraphicSize(self, EnclosingGraphic, xOriginInParent, - yOriginInParent, width, height) - struct wmgraphic * self; - struct wmgraphic * EnclosingGraphic; - long xOriginInParent, yOriginInParent, width, height; { - struct rectangle r; - - rectangle_SetRectSize(&r,xOriginInParent, yOriginInParent, - width,height); - wmgraphic_InsertGraphic(self,EnclosingGraphic,&r); - } - void wmgraphic__InsertGraphic(self, EnclosingGraphic, EnclosedRectangle) struct wmgraphic * self; struct wmgraphic * EnclosingGraphic; --- 953,958 ---- *************** *** 989,1031 **** struct rectangle * EnclosedRectangle; { - #if 0 - /* Fill in the local bounds for the rectangle (always 0,0 based - upon creation) */ - - rectangle_SetRectSize(&self->header.graphic.localBounds,point_X(&self->header.graphic.savedOrigin), - point_Y(&self->header.graphic.savedOrigin), - rectangle_Width(EnclosedRectangle), - rectangle_Height(EnclosedRectangle)); - - /* Calculate the visual bounds for the newly enclosed rectangle - in terms of the parent. Start with entire requested area, - and then clip (intersect) to enclosing graphic */ - - self->header.graphic.visualBounds = *EnclosedRectangle; - rectangle_IntersectRect(&self->header.graphic.visualBounds,&self->header.graphic.visualBounds, - &EnclosingGraphic->header.graphic.visualBounds); - /* Now reorient the rect to local (savedOrigin based) coordinates. */ - rectangle_OffsetRect(&self->header.graphic.visualBounds, - -rectangle_Left(EnclosedRectangle), - -rectangle_Top(EnclosedRectangle)); - rectangle_OffsetRect(&self->header.graphic.visualBounds,point_X(&self->header.graphic.savedOrigin), - point_Y(&self->header.graphic.savedOrigin)); - - /* Install the origin relative to the enclosing grphic (just - copy over the rectangle that it specified! */ - point_SetPt(&self->header.graphic.enclosedOrigin, - rectangle_Left(EnclosedRectangle), - rectangle_Top(EnclosedRectangle)); - - /* Since the clippingRect is relative to the visual rect, we - define the clipping rectangle as disappearing with an - insertion operation */ - if (self->header.graphic.clippingRect) free(self->header.graphic.clippingRect); - self->header.graphic.clippingRect = NULL; - - - #endif /* 0 */ /* do window manager independent stuff */ super_InsertGraphic(self,EnclosingGraphic,EnclosedRectangle); --- 959,964 ---- *************** *** 1034,1041 **** /* Copy over the machine dependent window capability */ self->window = ((struct wmgraphic * )EnclosingGraphic)->window; - - } --- 967,972 ---- *************** *** 1138,1156 **** } ! struct graphic * wmgraphic__ColorPattern(self, red, blue, green) struct wmgraphic * self; - long red, blue, green; { - if (red==0 && blue == 0 && green == 0) return wmgraphic_BlackPattern(self); - return wmgraphic_WhitePattern(self); - } - - void wmgraphic__SetForegroundColor(self, colorName, red, blue, green) - struct wmgraphic * self; char *colorName; ! long red, blue, green; { ! super_SetForegroundColor(self, colorName, red, blue, green); ValidateState(self); if (colorName != NULL) { --- 1069,1080 ---- } ! void wmgraphic__SetForegroundColor(self, colorName, red, green, blue) struct wmgraphic * self; char *colorName; ! long red, green, blue; { ! super_SetForegroundColor(self, colorName, red, green, blue); ValidateState(self); if (colorName != NULL) { *************** *** 1168,1179 **** wmgraphic_LocalSetTransferFunction(self); } ! void wmgraphic__SetBackgroundColor(self, colorName, red, blue, green) struct wmgraphic * self; char *colorName; ! long red, blue, green; { ! super_SetBackgroundColor(self, colorName, red, blue, green); ValidateState(self); if (colorName != NULL) { --- 1092,1103 ---- wmgraphic_LocalSetTransferFunction(self); } ! void wmgraphic__SetBackgroundColor(self, colorName, red, green, blue) struct wmgraphic * self; char *colorName; ! long red, green, blue; { ! super_SetBackgroundColor(self, colorName, red, green, blue); ValidateState(self); if (colorName != NULL) { *** atk/basics/wm/wgraphic.ch Wed Nov 22 11:46:43 1989 --- atk/basics/wm/wgraphic.ch.NEW Thu May 10 16:23:21 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/wm/RCS/wgraphic.ch,v 1.5 89/03/10 16:16:07 cm26 Exp $ */ /* $ACIS:graphic.ch 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/wm/RCS/wgraphic.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidgraphic_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/wm/RCS/wgraphic.ch,v 1.5 89/03/10 16:16:07 cm26 Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/wm/RCS/wgraphic.ch,v 1.7 90/05/09 14:20:56 ajp Exp $ */ /* $ACIS:graphic.ch 1.4$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/wm/RCS/wgraphic.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidgraphic_H = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/wm/RCS/wgraphic.ch,v 1.7 90/05/09 14:20:56 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #include *************** *** 75,82 **** /* transfers a piece of the graphic to a piece of the pixelimage */ InsertGraphic(struct graphic * EnclosingGraphic, struct rectangle * EnclosedRectangle); - InsertGraphicSize(struct graphic * EnclosingGraphic, - long xOriginInParent, long yOriginInParent, long width, long height); SetClippingRect(struct rectangle * AdditionalRect); ClearClippingRect(); --- 75,80 ---- *************** *** 89,98 **** WhitePattern() returns struct graphic *; BlackPattern() returns struct graphic *; GrayPattern(short IntensityNum, IntensityDenom) returns struct graphic *; - ColorPattern(long red, long blue, long green) returns struct graphic *; ! SetForegroundColor(char *colorName, long red, long blue, long green); ! SetBackgroundColor(char *colorName, long red, long blue, long green); GetHorizontalResolution() returns long; GetVerticalResolution() returns long; --- 87,95 ---- WhitePattern() returns struct graphic *; BlackPattern() returns struct graphic *; GrayPattern(short IntensityNum, IntensityDenom) returns struct graphic *; ! SetForegroundColor(char *colorName, long red, long green, long blue); ! SetBackgroundColor(char *colorName, long red, long green, long blue); GetHorizontalResolution() returns long; GetVerticalResolution() returns long; *** atk/basics/wm/wfontd.c Wed Nov 22 11:46:40 1989 --- atk/basics/wm/wfontd.c.NEW Wed Jun 27 12:46:08 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/wm/RCS/wfontd.c,v 1.10 89/09/27 14:46:37 wjh Exp $ */ /* $ACIS:fontdesc.c 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/wm/RCS/wfontd.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/wm/RCS/wfontd.c,v 1.10 89/09/27 14:46:37 wjh Exp $"; #endif /* lint */ /* --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/wm/RCS/wfontd.c,v 1.11 90/06/26 14:58:21 rr2b Exp $ */ /* $ACIS:fontdesc.c 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/wm/RCS/wfontd.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/wm/RCS/wfontd.c,v 1.11 90/06/26 14:58:21 rr2b Exp $"; #endif /* lint */ /* *************** *** 202,208 **** long wmfontdesc__TextSize(self, graphic, text, TextLength, XWidth, YWidth) struct fontdesc * self; struct wmgraphic *graphic; ! char * text; long TextLength; long * XWidth; long * YWidth; { --- 202,208 ---- long wmfontdesc__TextSize(self, graphic, text, TextLength, XWidth, YWidth) struct fontdesc * self; struct wmgraphic *graphic; ! unsigned char * text; long TextLength; long * XWidth; long * YWidth; { *************** *** 315,321 **** void wmfontdesc__CharSummary(self,gr,LookUpChar,RetValue) struct fontdesc * self; struct wmgraphic * gr; ! char LookUpChar; struct fontdesc_charInfo * RetValue; { register struct font *font = fontdesc_GetRealFontDesc(self, gr); --- 315,321 ---- void wmfontdesc__CharSummary(self,gr,LookUpChar,RetValue) struct fontdesc * self; struct wmgraphic * gr; ! unsigned char LookUpChar; struct fontdesc_charInfo * RetValue; { register struct font *font = fontdesc_GetRealFontDesc(self, gr); *** atk/basics/x/xgraphic.c Wed Apr 11 14:18:25 1990 --- atk/basics/x/xgraphic.c.NEW Wed Jun 13 16:52:29 1990 *************** *** 2,8 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.c,v 1.10 90/03/22 09:27:44 ajp Exp $ */ /* $ACIS:graphic.c 1.11$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.c,v $ */ --- 2,8 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.c,v 1.16 90/06/12 11:29:05 sg08 Exp $ */ /* $ACIS:graphic.c 1.11$ */ /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.c,v $ */ *************** *** 9,15 **** #ifndef LINT ! char xgraphic_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.c,v 1.10 90/03/22 09:27:44 ajp Exp $"; #endif /* LINT */ /* graphic.c --- 9,15 ---- #ifndef LINT ! char xgraphic_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.c,v 1.16 90/06/12 11:29:05 sg08 Exp $"; #endif /* LINT */ /* graphic.c *************** *** 28,37 **** --- 28,40 ---- #include #include #include + #include #include static int regionDebug = 0; + #define XFullBrightness 65535.0 + struct xgraphic_GrayBlock { struct xgraphic_GrayBlock * nextBlock; Display * displayUsed; *************** *** 776,781 **** --- 779,786 ---- struct xgraphic * Tile; { int grayIndex; + struct xgraphic * tile = Tile; + register long fgPixel; /* See if transfer mode will take care of it, i.e., mode is source independent. If so, just make sure that a fillsolid mode is picked in the belief that the server won't be smart enough to realize that only the shape matters and not to waste time aligning any random tile that was left over */ if ( (self->header.graphic.transferMode == graphic_BLACK) || *************** *** 789,798 **** } return; } /* Hm, depends on sources, but source may be white or black, so let's special case those as well */ ! if (self->gray_shades[16] && self->gray_shades[16] == Tile) { /* We're using black, make sure context is OK */ ! long fgPixel = (self->header.graphic.transferMode == graphic_XOR) ? self->foregroundpixel ^ self->backgroundpixel : self->foregroundpixel; if (self->lastFillStyle != FillSolid) { XSetFillStyle(xgraphic_XDisplay(self), xgraphic_XFillGC(self), FillSolid); --- 794,806 ---- } return; } + if ( tile == NULL && ( xgraphic_DisplayClass( self ) & graphic_Color )) + tile = ( struct xgraphic * ) xgraphic_BlackPattern( self ); + else if ( tile == NULL ) tile = self->lastFillTile; /* Hm, depends on sources, but source may be white or black, so let's special case those as well */ ! if (self->gray_shades[16] && self->gray_shades[16] == tile) { /* We're using black, make sure context is OK */ ! fgPixel = (self->header.graphic.transferMode == graphic_XOR) ? self->foregroundpixel ^ self->backgroundpixel : self->foregroundpixel; if (self->lastFillStyle != FillSolid) { XSetFillStyle(xgraphic_XDisplay(self), xgraphic_XFillGC(self), FillSolid); *************** *** 802,809 **** XSetForeground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), fgPixel); self->lastFillPixel = fgPixel; } } ! else if (self->gray_shades[0] && self->gray_shades[0] == Tile) { /* We're using white, make sure content is OK */ if (self->lastFillStyle != FillSolid) { --- 810,818 ---- XSetForeground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), fgPixel); self->lastFillPixel = fgPixel; } + self->lastFillTile = self->gray_shades[16]; } ! else if (self->gray_shades[0] && self->gray_shades[0] == tile) { /* We're using white, make sure content is OK */ if (self->lastFillStyle != FillSolid) { *************** *** 814,819 **** --- 823,829 ---- XSetForeground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), self->backgroundpixel); self->lastFillPixel = self->backgroundpixel; } + self->lastFillTile = self->gray_shades[0]; } /* Not black or white, but maybe predefind gray that is already down loaded, if so just set fill style and don't download pixmap again. Note: we are exceedingly tricky by using the assignment statement to pickup the gray shade that matches, and by picking what we think will be most common ones first. We assume, as per C book, that evaluatio stops with first true test */ else { *************** *** 820,858 **** register int i = 15; static int ind[] = {8, 4, 12, 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15}; ! if (Tile != NULL) { ! for (i = 0; i < 15 && self->gray_shades[ind[i]] != Tile; i++) ; } if (i < 15) { grayIndex = ind[i]; - /* Lucky us, reusing a preloaded gray shade, so just make sure that fill style is set correctly, and see if we have alredy downloaded tile */ ! if (self->lastFillStyle != FillTiled) { ! XSetFillStyle(xgraphic_XDisplay(self), xgraphic_XFillGC(self), FillTiled); ! self->lastFillStyle = FillTiled; } if (self->lastFillTile != self->gray_shades[grayIndex]) { /* oh well, let's download the gray pattern */ ! XSetTile(xgraphic_XDisplay(self), self->localFillGraphicContext, ! Tile->localWindow); self->lastFillTile = self->gray_shades[grayIndex]; } } /* Unknown, or unused tile, so download it and use it */ else { /* Let's see if style is right */ ! if (self->lastFillStyle != FillTiled) { ! XSetFillStyle(xgraphic_XDisplay(self), xgraphic_XFillGC(self), FillTiled); ! self->lastFillStyle = FillTiled; } /* And let's send down the tile */ ! XSetTile(xgraphic_XDisplay(self), self->localFillGraphicContext, ! Tile->localWindow); ! self->lastFillTile = Tile; } } --- 830,879 ---- register int i = 15; static int ind[] = {8, 4, 12, 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15}; ! if (tile != NULL) { ! for (i = 0; i < 15 && self->gray_shades[ind[i]] != tile; i++) ; } if (i < 15) { grayIndex = ind[i]; /* Lucky us, reusing a preloaded gray shade, so just make sure that fill style is set correctly, and see if we have alredy downloaded tile */ ! fgPixel = (self->header.graphic.transferMode == graphic_XOR) ? self->foregroundpixel ^ self->backgroundpixel : self->foregroundpixel; ! ! if (self->lastFillPixel != fgPixel) { ! XSetForeground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), fgPixel); ! self->lastFillPixel = fgPixel; } + if (self->lastFillStyle != FillOpaqueStippled) { + XSetFillStyle(xgraphic_XDisplay(self), xgraphic_XFillGC(self), FillOpaqueStippled ); + self->lastFillStyle = FillOpaqueStippled; + } if (self->lastFillTile != self->gray_shades[grayIndex]) { /* oh well, let's download the gray pattern */ ! XSetStipple(xgraphic_XDisplay(self), self->localFillGraphicContext, ! tile->localWindow); self->lastFillTile = self->gray_shades[grayIndex]; } } /* Unknown, or unused tile, so download it and use it */ else { + fgPixel = (self->header.graphic.transferMode == graphic_XOR) ? self->foregroundpixel ^ self->backgroundpixel : self->foregroundpixel; + + if (self->lastFillPixel != fgPixel) { + XSetForeground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), fgPixel); + self->lastFillPixel = fgPixel; + } /* Let's see if style is right */ ! if (self->lastFillStyle != FillOpaqueStippled) { ! XSetFillStyle(xgraphic_XDisplay(self), xgraphic_XFillGC(self), FillOpaqueStippled); ! self->lastFillStyle = FillOpaqueStippled; } /* And let's send down the tile */ ! XSetStipple(xgraphic_XDisplay(self), self->localFillGraphicContext, ! tile->localWindow); ! self->lastFillTile = tile; } } *************** *** 1037,1043 **** struct xgraphic * Tile;{ struct region * tmpRegion; struct region * visRegion; - struct region * clipRegion; struct xgraphic_UpdateBlock * curBlock; /* VerifyUpdateClipping(self); */ /* unneeded here since we will explicitly pull out the update region for our graphics hack */ --- 1058,1063 ---- *************** *** 1059,1073 **** tmpRegion = region_DuplicateRegion(Rgn); /* Step 2 - clip to visual */ ! visRegion = region_CreateRectRegion(&self->header.graphic.visualBounds); ! region_IntersectRegion(tmpRegion,visRegion,tmpRegion); ! region_Destroy(visRegion); /* Step 3 - clip to graphic clipping */ ! if (self->header.graphic.clippingRect) { ! clipRegion = region_CreateRectRegion(self->header.graphic.clippingRect); ! region_IntersectRegion(tmpRegion,clipRegion,tmpRegion); ! region_Destroy(clipRegion); } /* Step 4 - offset by physical coordinates */ --- 1079,1096 ---- tmpRegion = region_DuplicateRegion(Rgn); /* Step 2 - clip to visual */ ! if (self->header.graphic.visualRegion == NULL) { ! visRegion = region_CreateRectRegion(&self->header.graphic.visualBounds); ! region_IntersectRegion(tmpRegion,visRegion,tmpRegion); ! region_Destroy(visRegion); ! } ! else { ! region_IntersectRegion(tmpRegion, self->header.graphic.visualRegion, tmpRegion); ! } /* Step 3 - clip to graphic clipping */ ! if (self->header.graphic.clippingRegion != NULL) { ! region_IntersectRegion(tmpRegion, self->header.graphic.clippingRegion, tmpRegion); } /* Step 4 - offset by physical coordinates */ *************** *** 1248,1255 **** struct xgraphic_UpdateBlock * updateBlk; { struct rectangle Temp; XRectangle XRect[1]; - XPoint FakeRect[5]; - Region tmpRegion; /* The clipping rectangle for a graphic is the intersection of the visual bounds of the graphic, the updtae clipping rectangle, and any clipping rectangle provided by the client of the graphic */ --- 1271,1276 ---- *************** *** 1257,1339 **** printf("LocalSetClippingRect: entering with updateBlk %X\n",updateBlk); } /* Calculate the limiting rectangle based on visual bounds and any set rectangle (and turn them into physical coorindates) */ - xgraphic_GetVisualBounds(self,&Temp); - /* If we have a clipping rect, factor it in */ - if (self->header.graphic.clippingRect) - rectangle_IntersectRect(&Temp,&Temp,self->header.graphic.clippingRect); - - /* map it to physical space (X coordinates) */ - physical_LogicalToGlobalRect(self,&Temp); ! if (regionDebug) printf("LocalSetClip: finished with clip and visual: x %d, y %d, width %d, height %d\n", rectangle_Left(&Temp), rectangle_Top(&Temp), rectangle_Width(&Temp), rectangle_Bottom(&Temp)); ! /* First check to see if we have any kind of update region to contend with */ ! if (!updateBlk) updateBlk = xgraphic_FindUpdateBlock(xgraphic_XDisplay(self), xgraphic_XWindow(self)); ! if (regionDebug) printf("LocalSetClip: Using block %X\n", updateBlk); ! if (regionDebug) printf("localsetclip: region counter in update block %d, region %X\n", updateBlk->RegionCounter, updateBlk->updateRegionInUse); ! if (updateBlk->updateRegionInUse) { ! /* First make a dummy region for defining the above caluated rectangle */ ! FakeRect[0].x = FakeRect[4].x = FakeRect[3].x = rectangle_Left(&Temp); ! FakeRect[0].y = FakeRect[4].y = FakeRect[1].y = rectangle_Top(&Temp); ! FakeRect[1].x = FakeRect[2].x = rectangle_Right(&Temp); ! FakeRect[2].y = FakeRect[3].y = rectangle_Bottom(&Temp); ! tmpRegion = XPolygonRegion(FakeRect,4,EvenOddRule); ! #ifdef OLDXBUG ! tmpRegion->extents.y2 = FakeRect[2].y; ! #endif /* OLDXBUG */ ! /* Intersect it with the update region */ ! XIntersectRegion(tmpRegion,updateBlk->updateRegionInUse,tmpRegion); ! /* Set clipping rectangles */ ! ! if (regionDebug){ ! XRectangle fakeRect; ! printf("localsetclip: setting clip rect to intersected form\n"); ! printf("xim:about to test for region equality\n"); ! fakeRect.x = fakeRect.y = 0; ! fakeRect.width = fakeRect.height = 32000; ! XClipBox(tmpRegion,&fakeRect); ! printf("xgraphic: clipbox of final clipping region is %d, %d, %d, %d\n", fakeRect.x, fakeRect.y, fakeRect.width, fakeRect.height); } #ifdef XRELEASE2_ENV ! TempXSetRegion(xgraphic_XDisplay(self),xgraphic_XGC(self),tmpRegion); ! TempXSetRegion(xgraphic_XDisplay(self),xgraphic_XFillGC(self),tmpRegion); #else /* XRELEASE2_ENV */ ! XSetRegion(xgraphic_XDisplay(self),xgraphic_XGC(self),tmpRegion); ! XSetRegion(xgraphic_XDisplay(self),xgraphic_XFillGC(self),tmpRegion); #endif /* XRELEASE2_ENV */ /* and toss temporary region */ ! XDestroyRegion(tmpRegion); } - else { /* No update region is pending, so just use ordinary calculations */ - /* make the rectangle for the clip call */ - XRect[0].x = rectangle_Left(&Temp); - XRect[0].y = rectangle_Top(&Temp); - XRect[0].width = rectangle_Width(&Temp); - XRect[0].height = rectangle_Height(&Temp); - - if (regionDebug) printf("localsetclip: no update rgn, ignoring it\n"); - XSetClipRectangles(xgraphic_XDisplay(self), - xgraphic_XGC(self), - /* Clip origin */0,0,XRect,/* Num Rects */1, - YXBanded); - XSetClipRectangles(xgraphic_XDisplay(self), - xgraphic_XFillGC(self), - /* Clip origin */0,0,XRect,/* Num Rects */1, - YXBanded); - } - - /* regardless of how we got called here, let's mark the graphic's clipping information as up to date, since we just in fact updated it */ self->lastUpdateRegionIDUsed = curUpdateRegionID; } void xgraphic__SetClippingRect(self, AdditionalRect) struct xgraphic * self; struct rectangle * AdditionalRect;{ --- 1278,1382 ---- printf("LocalSetClippingRect: entering with updateBlk %X\n",updateBlk); } + /* First check to see if we have any kind of update region to contend with */ + + if (!updateBlk) updateBlk = xgraphic_FindUpdateBlock(xgraphic_XDisplay(self), xgraphic_XWindow(self)); + /* Calculate the limiting rectangle based on visual bounds and any set rectangle (and turn them into physical coorindates) */ ! if (self->header.graphic.visualRegion == NULL && ! self->header.graphic.clippingRegion == NULL && ! ! updateBlk->updateRegionInUse) { ! xgraphic_GetVisualBounds(self,&Temp); ! physical_LogicalToGlobalRect(self,&Temp); ! XRect[0].x = rectangle_Left(&Temp); ! XRect[0].y = rectangle_Top(&Temp); ! XRect[0].width = rectangle_Width(&Temp); ! XRect[0].height = rectangle_Height(&Temp); ! if (regionDebug) printf("localsetclip: no update rgn, ignoring it\n"); ! XSetClipRectangles(xgraphic_XDisplay(self), ! xgraphic_XGC(self), ! /* Clip origin */0,0,XRect,/* Num Rects */1, ! YXBanded); ! XSetClipRectangles(xgraphic_XDisplay(self), ! xgraphic_XFillGC(self), ! /* Clip origin */0,0,XRect,/* Num Rects */1, ! YXBanded); ! } ! else { ! struct region *clipRegion; ! if (self->header.graphic.visualRegion == NULL) { ! clipRegion = region_CreateRectRegion(&self->header.graphic.visualBounds); ! } ! else { ! clipRegion = region_New(); ! region_CopyRegion(clipRegion, self->header.graphic.visualRegion); ! } ! /* If we have a clipping region, factor it in */ ! if (self->header.graphic.clippingRegion != NULL) { ! region_IntersectRegion(clipRegion, self->header.graphic.clippingRegion, clipRegion); ! } ! /* map it to physical space (X coordinates) */ ! ! region_OffsetRegion(clipRegion, physical_LogicalXToGlobalX(self, 0), ! physical_LogicalYToGlobalY(self, 0)); ! ! if (regionDebug) printf("LocalSetClip: finished with clip and visual: x %d, y %d, width %d, height %d\n", rectangle_Left(&Temp), rectangle_Top(&Temp), rectangle_Width(&Temp), rectangle_Bottom(&Temp)); ! ! ! if (regionDebug) printf("LocalSetClip: Using block %X\n", updateBlk); ! ! if (regionDebug) printf("localsetclip: region counter in update block %d, region %X\n", updateBlk->RegionCounter, updateBlk->updateRegionInUse); ! ! if (updateBlk->updateRegionInUse) { ! /* Intersect it with the update region */ ! XIntersectRegion(region_GetRegionData(clipRegion), ! updateBlk->updateRegionInUse, ! region_GetRegionData(clipRegion)); ! /* Set clipping rectangles */ ! ! if (regionDebug){ ! XRectangle fakeRect; ! ! printf("localsetclip: setting clip rect to intersected form\n"); ! printf("xim:about to test for region equality\n"); ! fakeRect.x = fakeRect.y = 0; ! fakeRect.width = fakeRect.height = 32000; ! XClipBox(region_GetRegionData(clipRegion),&fakeRect); ! printf("xgraphic: clipbox of final clipping region is %d, %d, %d, %d\n", fakeRect.x, fakeRect.y, fakeRect.width, fakeRect.height); ! } } #ifdef XRELEASE2_ENV ! TempXSetRegion(xgraphic_XDisplay(self), xgraphic_XGC(self), region_GetRegionData(clipRegion)); ! TempXSetRegion(xgraphic_XDisplay(self), xgraphic_XFillGC(self), region_GetRegionData(clipRegion)); #else /* XRELEASE2_ENV */ ! XSetRegion(xgraphic_XDisplay(self), xgraphic_XGC(self), region_GetRegionData(clipRegion)); ! XSetRegion(xgraphic_XDisplay(self), xgraphic_XFillGC(self), region_GetRegionData(clipRegion)); #endif /* XRELEASE2_ENV */ /* and toss temporary region */ ! region_Destroy(clipRegion); } self->lastUpdateRegionIDUsed = curUpdateRegionID; } + void xgraphic__SetClippingRegion(self, region) + struct xgraphic *self; + struct region *region; + { + /* Machine independent stuff */ + super_SetClippingRegion(self,region); + /* Machine dependent actions */ + xgraphic_LocalSetClippingRect(self,NULL); + } + void xgraphic__SetClippingRect(self, AdditionalRect) struct xgraphic * self; struct rectangle * AdditionalRect;{ *************** *** 1357,1374 **** short NewLineWidth; { XGCValues tempGC; ! self->header.graphic.lineWidth = NewLineWidth; ! tempGC.line_width = NewLineWidth; ! /* special case 1 to use the underlying hardware (width 0); the performance hit is just too great for a real width of 1 */ ! if (NewLineWidth == 1) tempGC.line_width = 0; ! XChangeGC(xgraphic_XDisplay(self), xgraphic_XGC(self), GCLineWidth,&tempGC); } void xgraphic__SetTransferMode(self,NewTransferMode) struct xgraphic * self; short NewTransferMode;{ --- 1400,1498 ---- short NewLineWidth; { XGCValues tempGC; ! if ( xgraphic_GetLineWidth( self ) != NewLineWidth ) ! { ! super_SetLineWidth( self, NewLineWidth ); ! self->header.graphic.lineWidth = NewLineWidth; ! tempGC.line_width = NewLineWidth; ! /* special case 1 to use the underlying hardware (width 0); the performance hit is just too great for a real width of 1 */ ! if (NewLineWidth == 1) tempGC.line_width = 0; ! XChangeGC(xgraphic_XDisplay(self), xgraphic_XGC(self), GCLineWidth,&tempGC); + } } + void xgraphic__SetLineDash( self, dashPattern, dashOffset, dashType ) + struct xgraphic *self; + char *dashPattern; + int dashOffset; + short dashType; + { + XGCValues tempGC; + register int n = 0; + register char *p; + register short type = dashType; + char *oldPattern = NULL; + int oldOffset; + short oldType; + if ( dashPattern == NULL ) type = graphic_LineSolid; + xgraphic_GetLineDash( self, &oldPattern, &oldOffset, &oldType ); + if ( oldPattern && dashPattern && ( strcmp( oldPattern, dashPattern ) == 0 ) && dashOffset == oldOffset && type == oldType ); + else + { + super_SetLineDash( self, dashPattern, dashOffset, type ); + switch( type ) + { + case graphic_LineOnOffDash: tempGC.line_style = LineOnOffDash; break; + case graphic_LineDoubleDash: tempGC.line_style = LineDoubleDash; break; + case graphic_LineSolid: + default: tempGC.line_style = LineSolid; break; + } + XChangeGC( xgraphic_XDisplay(self), xgraphic_XGC(self), GCLineStyle, &tempGC ); + if ( dashPattern ) + { + p = dashPattern; + while ( *p++ != 0 ) n++; + if ( n ) XSetDashes( xgraphic_XDisplay( self ), xgraphic_XGC( self ), dashOffset, dashPattern, n ); + } + } + } + + void xgraphic__SetLineCap( self, newLineCap ) + struct xgraphic *self; + short newLineCap; + { + XGCValues tempGC; + + if ( xgraphic_GetLineCap( self ) != newLineCap ) + { + super_SetLineCap( self, newLineCap ); + switch( newLineCap ) + { + case graphic_CapNotLast: tempGC.cap_style = CapNotLast; break; + case graphic_CapRound: tempGC.cap_style = CapRound; break; + case graphic_CapProjecting: tempGC.cap_style = CapProjecting; break; + case graphic_CapButt: + default: tempGC.cap_style = CapButt; break; + } + XChangeGC( xgraphic_XDisplay(self), xgraphic_XGC(self), GCCapStyle, &tempGC ); + } + } + + void xgraphic__SetLineJoin( self, newLineJoin ) + struct xgraphic *self; + short newLineJoin; + { + XGCValues tempGC; + + if ( xgraphic_GetLineJoin( self ) != newLineJoin ) + { + super_SetLineJoin( self, newLineJoin ); + switch( newLineJoin ) + { + case graphic_JoinRound: tempGC.join_style = JoinRound; break; + case graphic_JoinBevel: tempGC.join_style = JoinBevel; break; + case graphic_JoinMiter: + defualt: tempGC.join_style = JoinMiter; break; + } + XChangeGC( xgraphic_XDisplay(self), xgraphic_XGC(self), GCJoinStyle, &tempGC ); + } + } + void xgraphic__SetTransferMode(self,NewTransferMode) struct xgraphic * self; short NewTransferMode;{ *************** *** 1379,1409 **** xgraphic_LocalSetTransferFunction(self, prevValue); } ! ! void xgraphic__InsertGraphicSize(self, EnclosingGraphic, xOriginInParent, ! yOriginInParent, width, height) ! struct xgraphic * self; ! struct graphic * EnclosingGraphic; ! long xOriginInParent, yOriginInParent, width, height; { ! struct rectangle r; ! ! rectangle_SetRectSize(&r,xOriginInParent, yOriginInParent, ! width,height); ! xgraphic_InsertGraphic(self,EnclosingGraphic,&r); ! } ! ! void xgraphic__InsertGraphic(self, EnclosingGraphic, EnclosedRectangle) ! struct xgraphic * self; ! struct xgraphic * EnclosingGraphic; ! struct rectangle * EnclosedRectangle; { XGCValues tempGCValues; - - /* First do the machine independent stuff */ - - super_InsertGraphic(self,EnclosingGraphic, EnclosedRectangle); - /* First see if we are moving between windows or displays */ /* We actually may be too aggressive here, but it is probably safe for now, e.g., movement within the same display/screen pair --- 1503,1514 ---- xgraphic_LocalSetTransferFunction(self, prevValue); } ! static void HandleInsertion(self, EnclosingGraphic) ! struct xgraphic *self; ! struct xgraphic *EnclosingGraphic; { XGCValues tempGCValues; /* First see if we are moving between windows or displays */ /* We actually may be too aggressive here, but it is probably safe for now, e.g., movement within the same display/screen pair *************** *** 1491,1496 **** --- 1596,1644 ---- } + void xgraphic__InsertGraphicSize(self, EnclosingGraphic, xOriginInParent, + yOriginInParent, width, height) + struct xgraphic * self; + struct graphic * EnclosingGraphic; + long xOriginInParent, yOriginInParent, width, height; { + struct rectangle r; + + rectangle_SetRectSize(&r,xOriginInParent, yOriginInParent, + width,height); + xgraphic_InsertGraphic(self,EnclosingGraphic,&r); + } + + void xgraphic__InsertGraphic(self, EnclosingGraphic, EnclosedRectangle) + struct xgraphic * self; + struct xgraphic * EnclosingGraphic; + struct rectangle * EnclosedRectangle; + { + /* First do the machine independent stuff */ + + super_InsertGraphic(self,EnclosingGraphic, EnclosedRectangle); + + HandleInsertion(self, EnclosingGraphic); + } + + void xgraphic__InsertGraphicRegion(self, EnclosingGraphic, region) + struct xgraphic * self; + struct xgraphic * EnclosingGraphic; + struct region; + { + super_InsertGraphicRegion(self,EnclosingGraphic, region); + + HandleInsertion(self, EnclosingGraphic); + } + + void xgraphic__SetVisualRegion(self, region) + struct xgraphic *self; + struct region *region; + { + super_SetVisualRegion(self, region); + + xgraphic_LocalSetClippingRect(self,NULL); + } + void xgraphic__FlushGraphics(self) struct xgraphic * self; { XFlush(xgraphic_XDisplay(self)); *************** *** 1524,1596 **** fontdesc_CvtCharToGraphic(xgraphic_shadeFont, self, IntensityNum)); } ! struct graphic * xgraphic__ColorPattern(self, red, blue, green) ! struct xgraphic * self; ! long red, blue, green; { ! printf("xgraphic_ColorPattern: method not yet implemented\n"); ! if (red==0 && blue == 0 && green == 0) return xgraphic_BlackPattern(self); ! return xgraphic_WhitePattern(self); ! } ! ! /* SetForegroundColor and SetBackgroundColor do not ever free colormap entries. ! * This is a resource leak, but correct. This has something to do with the fact ! * that somebody may still be using these colors when one of the ground colors ! * changes... -Z- ! */ ! void xgraphic__SetForegroundColor(self, colorName, red, blue, green) struct xgraphic * self; char *colorName; ! long red, blue, green; { long status; XColor desiredColor; ! /* Two step process -- alloc the color (I hope it is reused, but the manual is silent on this) and set the foreground accordingly */ ! if (colorName != NULL) { ! XColor exactColor; /* Not used... */ ! ! status = XAllocNamedColor(xgraphic_XDisplay(self), DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), colorName, &desiredColor, &exactColor); ! } ! else { ! desiredColor.red = red; ! desiredColor.blue = blue; ! desiredColor.green = green; ! desiredColor.flags = DoRed | DoGreen | DoBlue; ! status = XAllocColor(xgraphic_XDisplay(self), DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), &desiredColor); ! } ! if (!status) { ! desiredColor.pixel = BlackPixel(xgraphic_XDisplay(self), xgraphic_XScreen(self)); ! } ! super_SetForegroundColor(self, colorName, desiredColor.red, desiredColor.blue, desiredColor.green); ! ! /* Allocated new color -- use it as foreground */ ! ! self->lastFillPixel = self->foregroundpixel = desiredColor.pixel; ! if (self->header.graphic.transferMode == graphic_WHITE) { ! XSetBackground(xgraphic_XDisplay(self), xgraphic_XGC(self), self->foregroundpixel); ! XSetBackground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), self->foregroundpixel); ! } #ifndef PLANEMASK_ENV ! else if (self->header.graphic.transferMode == graphic_XOR) { ! XSetForeground(xgraphic_XDisplay(self), xgraphic_XGC(self), self->foregroundpixel ^ self->backgroundpixel); ! XSetForeground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), self->foregroundpixel ^ self->backgroundpixel); ! } #endif /* PLANEMASK_ENV */ ! else { ! XSetForeground(xgraphic_XDisplay(self), xgraphic_XGC(self), self->foregroundpixel); ! XSetForeground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), self->foregroundpixel); ! } #ifdef PLANEMASK_ENV ! XSetPlaneMask(xgraphic_XDisplay(self), xgraphic_XGC(self), self->foregroundpixel ^ self->backgroundpixel); ! XSetPlaneMask(xgraphic_XDisplay(self), xgraphic_XFillGC(self), self->foregroundpixel ^ self->backgroundpixel); #endif /* PLANEMASK_ENV */ } ! void xgraphic__SetBackgroundColor(self, colorName, red, blue, green) struct xgraphic * self; char *colorName; ! long red, blue, green; { long status; XColor desiredColor; --- 1672,1732 ---- fontdesc_CvtCharToGraphic(xgraphic_shadeFont, self, IntensityNum)); } ! static void SetFGColor( self, colorName, red, green, blue ) struct xgraphic * self; char *colorName; ! long red, green, blue; { long status; XColor desiredColor; ! /* Two step process -- alloc the color (I hope it is reused, but the manual is silent on this) and set the foreground accordingly */ ! if (colorName != NULL) { ! status = XParseColor(xgraphic_XDisplay(self), ! DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), colorName, &desiredColor); ! if (status) ! status = XAllocColor(xgraphic_XDisplay(self), ! DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), &desiredColor); ! super_SetForegroundColor(self, colorName, desiredColor.red, desiredColor.green, desiredColor.blue); ! } ! else { ! desiredColor.red = red; ! desiredColor.blue = blue; ! desiredColor.green = green; ! desiredColor.flags = DoRed | DoGreen | DoBlue; ! status = XAllocColor(xgraphic_XDisplay(self), DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), &desiredColor); ! super_SetForegroundColor(self, colorName, desiredColor.red, desiredColor.green, desiredColor.blue); ! } ! if (!status) { ! desiredColor.pixel = BlackPixel(xgraphic_XDisplay(self), xgraphic_XScreen(self)); ! } ! /* Allocated new color -- use it as foreground */ ! self->lastFillPixel = self->foregroundpixel = desiredColor.pixel; ! if (self->header.graphic.transferMode == graphic_WHITE) { ! XSetBackground(xgraphic_XDisplay(self), xgraphic_XGC(self), self->foregroundpixel); ! XSetBackground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), self->foregroundpixel); ! } #ifndef PLANEMASK_ENV ! else if (self->header.graphic.transferMode == graphic_XOR) { ! XSetForeground(xgraphic_XDisplay(self), xgraphic_XGC(self), self->foregroundpixel ^ self->backgroundpixel); ! XSetForeground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), self->foregroundpixel ^ self->backgroundpixel); ! } #endif /* PLANEMASK_ENV */ ! else { ! XSetForeground(xgraphic_XDisplay(self), xgraphic_XGC(self), self->foregroundpixel); ! XSetForeground(xgraphic_XDisplay(self), xgraphic_XFillGC(self), self->foregroundpixel); ! } #ifdef PLANEMASK_ENV ! XSetPlaneMask(xgraphic_XDisplay(self), xgraphic_XGC(self), self->foregroundpixel ^ self->backgroundpixel); ! XSetPlaneMask(xgraphic_XDisplay(self), xgraphic_XFillGC(self), self->foregroundpixel ^ self->backgroundpixel); #endif /* PLANEMASK_ENV */ } ! static void SetBGColor(self, colorName, red, green, blue) struct xgraphic * self; char *colorName; ! long red, green, blue; { long status; XColor desiredColor; *************** *** 1597,1606 **** /* Two step process -- alloc the color (I hope it is reused, but the manual is silent on this) and set the background accordingly */ if (colorName != NULL) { ! ! XColor exactColor; /* Not used... */ ! ! status = XAllocNamedColor(xgraphic_XDisplay(self), DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), colorName, &desiredColor, &exactColor); } else { desiredColor.red = red; --- 1733,1744 ---- /* Two step process -- alloc the color (I hope it is reused, but the manual is silent on this) and set the background accordingly */ if (colorName != NULL) { ! status = XParseColor(xgraphic_XDisplay(self), ! DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), colorName, &desiredColor); ! if (status) ! status = XAllocColor(xgraphic_XDisplay(self), ! DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), &desiredColor); ! super_SetBackgroundColor(self, colorName, desiredColor.red, desiredColor.green, desiredColor.blue); } else { desiredColor.red = red; *************** *** 1608,1618 **** desiredColor.green = green; desiredColor.flags = DoRed | DoGreen | DoBlue; status = XAllocColor(xgraphic_XDisplay(self), DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), &desiredColor); } if (!status) { desiredColor.pixel = WhitePixel(xgraphic_XDisplay(self), xgraphic_XScreen(self)); } - super_SetBackgroundColor(self, colorName, desiredColor.red, desiredColor.blue, desiredColor.green); /* Allocated new color -- use it as background */ self->backgroundpixel = desiredColor.pixel; if (self->header.graphic.transferMode == graphic_WHITE) { --- 1746,1757 ---- desiredColor.green = green; desiredColor.flags = DoRed | DoGreen | DoBlue; status = XAllocColor(xgraphic_XDisplay(self), DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), &desiredColor); + super_SetBackgroundColor(self, colorName, desiredColor.red, desiredColor.green, desiredColor.blue); + } if (!status) { desiredColor.pixel = WhitePixel(xgraphic_XDisplay(self), xgraphic_XScreen(self)); } /* Allocated new color -- use it as background */ self->backgroundpixel = desiredColor.pixel; if (self->header.graphic.transferMode == graphic_WHITE) { *************** *** 1636,1641 **** --- 1775,1994 ---- #endif /* PLANEMASK_ENV */ } + static short xgraphic_ApproximateColor( self, colorName, red, green, blue ) + struct xgraphic *self; + char *colorName; + long *red, *green, *blue; + { + short index = 0; + XColor exactRGB, screenRGB; + + if ( colorName ) + { + if ( XLookupColor( xgraphic_XDisplay(self), DefaultColormap(xgraphic_XDisplay(self), xgraphic_XScreen(self)), colorName, &exactRGB, &screenRGB )) + { + *red = exactRGB.red; + *green = exactRGB.green; + *blue = exactRGB.blue; + } + else + fprintf( stderr, "xgraphic: named color not in database (%s)\n", colorName ); + } + if ( xgraphic_DisplayClass( self ) & graphic_Monochrome ) + { + if (( *red == *green ) && ( *green == *blue )) + index = 16 - ( short )( 16.0 * (( double )*red )/XFullBrightness + .5); + else + index = 16 - (short) (16.0 * (((double) *red) * 0.3 + ((double) *green) * 0.59 + ((double) *blue) * 0.11) / XFullBrightness + .5); + } + else if ( xgraphic_DisplayClass( self ) & graphic_GrayScale ) + { + if (( *red == *green ) && ( *green == *blue )); + else + *red = (long)(((double) *red) * 0.3 + ((double) *green) * 0.59 + ((double) *blue) * 0.11 + .5 ); + } + return index; + } + + static void SetStipple(self, index, bgBlack) + struct xgraphic *self; + long index; + boolean bgBlack; + { + struct xgraphic *tile; + + if (bgBlack) { + /* background is black */ + SetFGColor(self, "white", 0, 0, 0); + index = 16 - index; + } + else { + SetFGColor(self, "black", 0, 0, 0); + } + + + tile = ( struct xgraphic * ) xgraphic_GrayPattern( self, index, 16 ); + xgraphic_SetupFillGC( self, tile ); + XSetFillStyle(xgraphic_XDisplay(self), xgraphic_XGC(self), FillOpaqueStippled ); + XSetStipple(xgraphic_XDisplay(self), xgraphic_XGC(self), tile->localWindow); + } + + /* SetForegroundColor and SetBackgroundColor do not ever free colormap entries. + * This is a resource leak, but correct. This has something to do with the fact + * that somebody may still be using these colors when one of the ground colors + * changes... -Z- + */ + void xgraphic__SetForegroundColor(self, colorName, red, green, blue ) + struct xgraphic * self; + char *colorName; + long red, green, blue; + { + short index; + + if ( xgraphic_DisplayClass( self ) & graphic_Color ) + SetFGColor( self, colorName, red, green, blue ); + else + { + index = xgraphic_ApproximateColor( self, colorName, &red, &green, &blue ); + if ( xgraphic_DisplayClass( self ) & graphic_GrayScale ) + SetFGColor( self, NULL, red, red, red ); + else if ( xgraphic_DisplayClass( self ) & graphic_Monochrome ) + { + if (index != 0 && index != 16) { + long backRed; + + xgraphic_GetBackgroundColor(self, NULL, &backRed, NULL, NULL); + + SetStipple(self, index, backRed == 0); + } + else { + SetFGColor( self, colorName, red, green, blue ); + XSetFillStyle(xgraphic_XDisplay(self), xgraphic_XGC(self), FillSolid); + } + } + super_SetForegroundColor( self, colorName, red, green, blue ); + } + } + + void xgraphic__SetBackgroundColor(self, colorName, red, green, blue) + struct xgraphic * self; + char *colorName; + long red, green, blue; + { + if ( xgraphic_DisplayClass( self ) & graphic_Color ) + SetBGColor( self, colorName, red, green, blue ); + else + { + long foreRed, foreGreen, foreBlue; + char *foreName; + long index = xgraphic_ApproximateColor( self, colorName, &red, &green, &blue ); + + if ( xgraphic_DisplayClass( self ) & graphic_GrayScale ) + SetBGColor( self, NULL, red, red, red ); + else { + if (index < 8) { + /* Set background to white */ + colorName = "white"; + red = green = blue = 65535; + } + else { + /* Set background to black */ + colorName = "black"; + red = green = blue = 0; + } + SetBGColor( self, colorName, red, green, blue ); + xgraphic_GetForegroundColor(self, &foreName, &foreRed, &foreGreen, &foreBlue); + index = xgraphic_ApproximateColor(self, foreName, &foreRed, &foreGreen, &foreBlue); + if (index != 0 && index != 16) { + SetStipple(self, index, red == 0); + } + } + super_SetBackgroundColor( self, colorName, red, green, blue ); + } + } + + void xgraphic__SetFGColor( self, red, green, blue ) + struct xgraphic *self; + double red, green, blue; + { + long Red, Green, Blue, oldRed, oldGreen, oldBlue; + short index; + + Red = ( long )( red * XFullBrightness ); + Green = ( long )( green * XFullBrightness ); + Blue = ( long )( blue * XFullBrightness ); + if ( xgraphic_DisplayClass( self ) & graphic_Color ) + { + xgraphic_GetForegroundColor( self, NULL, &oldRed, &oldGreen, &oldBlue ); + if ( oldRed != Red || oldGreen != Green || oldBlue != Blue ) + SetFGColor( self, NULL, Red, Green, Blue ); + } + else + { + index = xgraphic_ApproximateColor( self, NULL, &Red, &Green, &Blue ); + if ( xgraphic_DisplayClass( self ) & graphic_GrayScale ) + SetFGColor( self, NULL, Red, Red, Red ); + else if ( xgraphic_DisplayClass( self ) & graphic_Monochrome ) + { + if (index != 0 || index != 16) { + long backRed; + + xgraphic_GetBackgroundColor(self, NULL, &backRed, NULL, NULL); + + SetStipple(self, index, backRed == 0); + } + else { + SetFGColor(self, NULL, Red, Green, Blue); + XSetFillStyle(xgraphic_XDisplay(self), xgraphic_XGC(self), FillSolid); + } + } + super_SetForegroundColor( self, NULL, Red, Green, Blue ); + } + } + + void xgraphic__SetBGColor( self, red, green, blue ) + struct xgraphic *self; + double red, green, blue; + { + long Red, Green, Blue, oldRed, oldGreen, oldBlue; + + Red = ( long )( red * XFullBrightness ); + Green = ( long )( green * XFullBrightness ); + Blue = ( long )( blue * XFullBrightness ); + if ( xgraphic_DisplayClass( self ) & graphic_Color ) + { + xgraphic_GetBackgroundColor( self, NULL, &oldRed, &oldGreen, &oldBlue ); + if ( oldRed != Red || oldGreen != Green || oldBlue != Blue ) + SetBGColor( self, NULL, Red, Green, Blue ); + } + else + { + long foreRed, foreGreen, foreBlue; + char *foreName; + long index = xgraphic_ApproximateColor( self, NULL, &Red, &Green, &Blue ); + + if ( xgraphic_DisplayClass( self ) & graphic_GrayScale ) + SetBGColor( self, NULL, Red, Red, Red ); + else { + if (index < 8) { + /* Set background to white */ + Red = Green = Blue = 65535; + } + else { + /* Set background to black */ + Red = Green = Blue = 0; + } + SetBGColor( self, NULL, Red, Green, Blue ); + xgraphic_GetForegroundColor(self, &foreName, &foreRed, &foreGreen, &foreBlue); + index = xgraphic_ApproximateColor(self, foreName, &foreRed, &foreGreen, &foreBlue); + if (index != 0 && index != 16) { + SetStipple(self, index, Red == 0); + } + } + super_SetBackgroundColor( self, NULL, Red, Green, Blue ); + } + } + long xgraphic__GetHorizontalResolution(self) struct xgraphic * self; { return (long) ((25.4 * DisplayWidth(xgraphic_XDisplay(self), xgraphic_XScreen(self))) / (DisplayWidthMM(xgraphic_XDisplay(self), xgraphic_XScreen(self)))); *************** *** 1717,1720 **** --- 2070,2112 ---- } } + long xgraphic__DisplayClass( self ) + struct xgraphic *self; + { + long class; + XVisualInfo vTemplate; + static XVisualInfo *vList = NULL; + static int matched = 0; + if ( vList == NULL ) + { + vTemplate.screen = xgraphic_XScreen( self ); + vTemplate.depth = DisplayPlanes( xgraphic_XDisplay( self ), xgraphic_XScreen( self )); + vList = XGetVisualInfo( xgraphic_XDisplay( self ), VisualScreenMask | VisualDepthMask, &vTemplate, &matched ); + } + if ( matched ) + { + switch ( vList[0].class ) + { + case PseudoColor: class = graphic_PseudoColor; + class |= graphic_Color; + break; + case GrayScale: class = graphic_GrayScale; + break; + case DirectColor: class = graphic_DirectColor; + class |= graphic_Color; + break; + case TrueColor: class = graphic_TrueColor; + class |= graphic_Color; + break; + case StaticColor: class = graphic_StaticColor; + class |= graphic_Color; + break; + case StaticGray: if ( DisplayPlanes( xgraphic_XDisplay( self ), xgraphic_XScreen( self )) == 1 ) class = graphic_Monochrome; + class |= graphic_StaticGray; + break; + } + } + else class = graphic_Monochrome | graphic_StaticGray; + return class; + } *** atk/basics/x/xgraphic.ch Wed Apr 11 14:18:27 1990 --- atk/basics/x/xgraphic.ch.NEW Thu May 10 16:23:33 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.ch,v 1.4 90/03/22 09:28:29 ajp Exp $ */ /* $ACIS:graphic.ch 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidxgraphic_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.ch,v 1.4 90/03/22 09:28:29 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.ch,v 1.6 90/05/09 14:17:07 ajp Exp $ */ /* $ACIS:graphic.ch 1.5$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidxgraphic_H = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xgraphic.ch,v 1.6 90/05/09 14:17:07 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 58,71 **** --- 58,77 ---- long width, long height); /* transfers a piece of the graphic to a piece of the pixelimage */ + InsertGraphicRegion(struct graphic *EnclosingGraphic, struct region *regions); InsertGraphic(struct graphic * EnclosingGraphic, struct rectangle * EnclosedRectangle); InsertGraphicSize(struct graphic * EnclosingGraphic, long xOriginInParent, long yOriginInParent, long width, long height); + SetVisualRegion(struct region *region); + SetClippingRegion(struct region *region); SetClippingRect(struct rectangle * AdditionalRect); ClearClippingRect(); SetLineWidth(short NewLineWidth); + SetLineDash( char *dashPattern, int dashOffset, short dashType ); + SetLineCap( short newLineCap ); + SetLineJoin( short newLineJoin ); SetTransferMode(short NewTransferMode); *************** *** 74,89 **** WhitePattern() returns struct graphic *; BlackPattern() returns struct graphic *; GrayPattern(short IntensityNum, IntensityDenom) returns struct graphic *; - ColorPattern(long red, long blue, long green) returns struct graphic *; /* If colorName is NULL, use the RGB. */ ! SetForegroundColor(char *colorName, long red, long blue, long green); ! SetBackgroundColor(char *colorName, long red, long blue, long green); GetHorizontalResolution() returns long; GetVerticalResolution() returns long; GetWindowManagerType() returns char *; GetDevice() returns long; macromethods: Valid() ((self)->valid) XWindow() ((self)->localWindow) --- 80,97 ---- WhitePattern() returns struct graphic *; BlackPattern() returns struct graphic *; GrayPattern(short IntensityNum, IntensityDenom) returns struct graphic *; /* If colorName is NULL, use the RGB. */ ! SetForegroundColor(char *colorName, long red, long green, long blue); ! SetBackgroundColor(char *colorName, long red, long green, long blue); ! SetFGColor( double red, double green, double blue ); ! SetBGColor( double red, double green, double blue ); GetHorizontalResolution() returns long; GetVerticalResolution() returns long; GetWindowManagerType() returns char *; GetDevice() returns long; + DisplayClass() returns long; macromethods: Valid() ((self)->valid) XWindow() ((self)->localWindow) *** atk/basics/x/xfontd.c Wed Nov 22 11:47:20 1989 --- atk/basics/x/xfontd.c.NEW Thu May 10 16:23:37 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/x/RCS/xfontd.c,v 1.9 89/08/27 19:46:11 zs01 Exp $ */ /* $ACIS:fontdesc.c 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/x/RCS/xfontd.c,v $ */ #ifndef lint ! char *xfontd_rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/x/RCS/xfontd.c,v 1.9 89/08/27 19:46:11 zs01 Exp $"; #endif /* lint */ /* fontdesc.c --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xfontd.c,v 1.10 90/05/03 14:43:57 gk5g Exp $ */ /* $ACIS:fontdesc.c 1.4$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xfontd.c,v $ */ #ifndef lint ! char *xfontd_rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xfontd.c,v 1.10 90/05/03 14:43:57 gk5g Exp $"; #endif /* lint */ /* fontdesc.c *************** *** 382,389 **** int depth; ENSUREGRAPHIC(NULL); ! depth = DefaultDepth(xgraphic_XDisplay(graphic), xgraphic_XScreen(graphic)); ! RetValue = xgraphic_New(); if (!RetValue) return NULL; /* This is text code extracted from my test suite, not the real stuff */ --- 382,388 ---- int depth; ENSUREGRAPHIC(NULL); ! depth = 1; /* Force depth of one for Stippling. was: DefaultDepth(xgraphic_XDisplay(graphic), xgraphic_XScreen(graphic)); */ RetValue = xgraphic_New(); if (!RetValue) return NULL; /* This is text code extracted from my test suite, not the real stuff */ *************** *** 420,426 **** 2) consistent semantics with other xgraphic objects */ gcattr.fill_style = FillSolid; ! gcattr.foreground = graphic->backgroundpixel; #ifndef PLANEMASK_ENV gc = XCreateGC(xgraphic_XDisplay(graphic), newPixmap, GCFillStyle | GCForeground, &gcattr); #else /* PLANEMASK_ENV */ --- 419,425 ---- 2) consistent semantics with other xgraphic objects */ gcattr.fill_style = FillSolid; ! gcattr.foreground = 0; #ifndef PLANEMASK_ENV gc = XCreateGC(xgraphic_XDisplay(graphic), newPixmap, GCFillStyle | GCForeground, &gcattr); #else /* PLANEMASK_ENV */ *************** *** 429,435 **** #endif /* PLANEMASK_ENV */ XFillRectangle(xgraphic_XDisplay(graphic), newPixmap, gc, 0, 0, width, height); XSetFont(xgraphic_XDisplay(graphic), gc, info->fid); ! XSetForeground(xgraphic_XDisplay(graphic), gc, graphic->foregroundpixel); XSetFunction(xgraphic_XDisplay(graphic), gc, GXcopy); str[0] = SpecialChar; XDrawString(xgraphic_XDisplay(graphic), newPixmap, gc, x, y, str, 1); --- 428,434 ---- #endif /* PLANEMASK_ENV */ XFillRectangle(xgraphic_XDisplay(graphic), newPixmap, gc, 0, 0, width, height); XSetFont(xgraphic_XDisplay(graphic), gc, info->fid); ! XSetForeground(xgraphic_XDisplay(graphic), gc, 1 ); XSetFunction(xgraphic_XDisplay(graphic), gc, GXcopy); str[0] = SpecialChar; XDrawString(xgraphic_XDisplay(graphic), newPixmap, gc, x, y, str, 1); *** atk/basics/x/xim.c Fri Jul 27 15:56:47 1990 --- atk/basics/x/xim.c.NEW Mon Jul 30 15:13:50 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/x/RCS/xim.c,v 1.26 90/01/26 13:00:48 susan Exp $ */ /* $ACIS:im.c 1.6$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/x/RCS/xim.c,v $ */ #ifndef lint ! char *xim_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/x/RCS/xim.c,v 1.26 90/01/26 13:00:48 susan Exp $"; #endif /* lint */ /* Put in error messages for handling of keystrokes. --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xim.c,v 1.34 90/07/30 14:36:03 gk5g Exp $ */ /* $ACIS:im.c 1.6$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xim.c,v $ */ #ifndef lint ! char *xim_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/x/RCS/xim.c,v 1.34 90/07/30 14:36:03 gk5g Exp $"; #endif /* lint */ /* Put in error messages for handling of keystrokes. *************** *** 29,34 **** --- 29,38 ---- #include #include #include + #ifdef _IBMR2 + typedef int (*XErrorHandler) (); + #endif + #include #include *************** *** 326,332 **** WMName[100] = '\0'; XSetIconName(display, window, WMName); ! wmhints.flags = StateHint; /* try to make expose work -wjh */ wmhints.initial_state = NormalState; XSetWMHints(display, window, &wmhints); --- 330,337 ---- WMName[100] = '\0'; XSetIconName(display, window, WMName); ! wmhints.flags = StateHint | InputHint; /* try to make expose work -wjh */ ! wmhints.input = TRUE; wmhints.initial_state = NormalState; XSetWMHints(display, window, &wmhints); *************** *** 458,464 **** FirstTimeThrough = FALSE; /* Setup error handler */ ! XSetErrorHandler(XErrorsToConsole); } /* ensure that 'host' points to a host name */ --- 463,469 ---- FirstTimeThrough = FALSE; /* Setup error handler */ ! XSetErrorHandler((XErrorHandler)XErrorsToConsole); } /* ensure that 'host' points to a host name */ *************** *** 780,786 **** &RetAtom, &RetFormat, &RetNumItems, &RetBytesAfter, &RetData); if (RetAtom == None) XStoreBuffer(xDisplay, (char *)&RetNumItems, 0, i); ! if (RetData) free(RetData); } /* set up the mouseStatus structure for the new display */ --- 785,791 ---- &RetAtom, &RetFormat, &RetNumItems, &RetBytesAfter, &RetData); if (RetAtom == None) XStoreBuffer(xDisplay, (char *)&RetNumItems, 0, i); ! if (RetData) XFree(RetData); } /* set up the mouseStatus structure for the new display */ *************** *** 3382,3387 **** --- 3387,3395 ---- XWarpPointer(xim2display(self), NULL, xim2window(self), 0,0,0,0,0,0); /* be sure it gets the input focus */ XSetInputFocus(xim2display(self), xim2window(self), RevertToPointerRoot, lastEventTime); + + /* Be sure to admit we don't need the input focus anymore */ + XSetInputFocus(xim2display(self), RootWindow(xim2display(self),xim2screen(self)),RevertToPointerRoot, lastEventTime); /* do it now! */ XFlush(xim2display(self)); } *** atk/basics/common/atomlist.c Wed Nov 22 11:48:03 1989 --- atk/basics/common/atomlist.c.NEW Wed Jun 13 16:53:05 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/atomlist.c,v 2.5 89/06/20 13:03:14 mcinerny Exp $ */ /* $ACIS:atomlist.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/atomlist.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/atomlist.c,v 2.5 89/06/20 13:03:14 mcinerny Exp $"; #endif /* lint */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/atomlist.c,v 2.6 90/06/04 13:39:13 gk5g Exp $ */ /* $ACIS:atomlist.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/atomlist.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/atomlist.c,v 2.6 90/06/04 13:39:13 gk5g Exp $"; #endif /* lint */ *************** *** 16,22 **** --- 16,24 ---- #include #include + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ /* * Class Procedures *** atk/basics/common/environ.c Fri Feb 2 12:24:31 1990 --- atk/basics/common/environ.c.NEW Fri Jun 29 12:58:37 1990 *************** *** 4,15 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/common/RCS/environ.c,v 2.5 90/01/26 12:40:39 susan Exp $ */ /* $ACIS:environ.c 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/common/RCS/environ.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/common/RCS/environ.c,v 2.5 90/01/26 12:40:39 susan Exp $"; #endif /* lint */ /* environ.c --- 4,15 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/environ.c,v 2.6 90/06/29 12:53:22 rr2b Exp $ */ /* $ACIS:environ.c 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/environ.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/environ.c,v 2.6 90/06/29 12:53:22 rr2b Exp $"; #endif /* lint */ /* environ.c *************** *** 22,31 **** --- 22,36 ---- extern ProgramName[]; /* blechhh */ + /* used to avoid problems with null pointers expected to be + treated as null strings */ + static char *nullstring=""; + void environ__SetProgramName(classID,s) struct classheader *classID; char *s; { + if(s==NULL) s=nullstring; strcpy(ProgramName,s); } *************** *** 61,66 **** --- 66,73 ---- static int lastEnvironLength = 0; /* The maximum number of entries in lastEnviron. */ register char **p; + /* check for a NULL value so we can make it the expected null string */ + if(value==NULL) value=nullstring; for (p = environ; *p != NULL && !varcmp(variable, *p); p++) ; *** atk/basics/common/fontdesc.c Wed Nov 22 11:48:30 1989 --- atk/basics/common/fontdesc.c.NEW Wed Jun 13 16:53:08 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/fontdesc.c,v 2.6 89/08/27 19:43:08 zs01 Exp $ */ /* $ACIS:fontdesc.c 1.3$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/fontdesc.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/fontdesc.c,v 2.6 89/08/27 19:43:08 zs01 Exp $"; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/fontdesc.c,v 2.7 90/06/06 14:23:55 gk5g Exp $ */ /* $ACIS:fontdesc.c 1.3$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/fontdesc.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/fontdesc.c,v 2.7 90/06/06 14:23:55 gk5g Exp $"; #endif /* lint */ #include *************** *** 325,327 **** --- 325,359 ---- return TRUE; } + + long fontdesc__StringBoundingBox(font, graphic, string, width, height) + struct fontdesc *font; + struct graphic *graphic; + char *string; + int *width; + int *height; + { + int w, a, d, ascent, descent, junk; + register short *fwt, *fht; + register char *p; + static struct fontdesc_charInfo ci; + + #define MAX(a,b) (((a)>(b))?(a):(b)) + + fwt = fontdesc_WidthTable (font, graphic); + fht = fontdesc_HeightTable (font, graphic); + if (fwt == NULL || fht == NULL) + return 0; + fontdesc_StringSize (font, graphic, string, &w, &junk); + for (p = string, a = 0, d = 0; *p != (char) 0; p += 1) + { + fontdesc_CharSummary (font, graphic, *p, &ci); + ascent = ci.yOriginOffset; + descent = ci.height - ascent; + a = MAX(a,ascent); + d = MAX(d,descent); + } + *width = w; + *height = a + d; + return (w); + } *** atk/basics/common/fontdesc.ch Wed Nov 22 11:49:47 1989 --- atk/basics/common/fontdesc.ch.NEW Wed Jun 13 16:53:10 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/fontdesc.ch,v 2.6 89/08/27 19:44:21 zs01 Exp $ */ /* $ACIS:fontdesc.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/fontdesc.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidfontdesc_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/fontdesc.ch,v 2.6 89/08/27 19:44:21 zs01 Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/fontdesc.ch,v 2.7 90/06/06 14:25:04 gk5g Exp $ */ /* $ACIS:fontdesc.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/fontdesc.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidfontdesc_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/fontdesc.ch,v 2.7 90/06/06 14:25:04 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 70,75 **** --- 70,76 ---- GetRealFontDesc(struct graphic *gr) returns struct font *; StringSize(struct graphic *gr, char * string, long * XWidth, long * YWidth) returns long; + StringBoundingBox(struct graphic *graphic, char *string, int *width, int *height) returns long; TextSize(struct graphic *gr, char * text, long TextLength, long *XWidth, long *YWidth) returns long; WidthTable(struct graphic *gr) returns short*; /* actually an array of short's */ *** atk/basics/common/graphic.c Wed Nov 22 11:48:32 1989 --- atk/basics/common/graphic.c.NEW Fri Jun 1 15:41:40 1990 *************** *** 6,12 **** */ #ifndef LINT ! char graphic_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/graphic.c,v 2.5 89/03/10 16:09:52 cm26 Exp $"; #endif /* LINT */ #include --- 6,12 ---- */ #ifndef LINT ! char graphic_rcsid[] = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/graphic.c,v 2.10 90/06/01 15:38:56 ajp Exp $"; #endif /* LINT */ #include *************** *** 567,573 **** } } - void graphic__SetBitAtLoc(self,XPos,YPos, NewValue) struct graphic * self; long YPos; --- 567,572 ---- *************** *** 575,581 **** boolean NewValue; { struct point * tempPt; ! short tempLineWidth, tempTMode; /* Slow, but correct -- instead of filling a rectangle, we should probably draw a one pixel long, one pixel wide line. */ --- 574,582 ---- boolean NewValue; { struct point * tempPt; ! short tempLineWidth, tempTMode, dashStyle, tempLineCap, tempLineJoin; ! int dashOffset; ! char *dashPattern; /* Slow, but correct -- instead of filling a rectangle, we should probably draw a one pixel long, one pixel wide line. */ *************** *** 582,587 **** --- 583,591 ---- graphic_GetCurrentPt(self,&tempPt); tempLineWidth = graphic_GetLineWidth(self); tempTMode = graphic_GetTransferMode(self); + graphic_GetLineDash( self, &dashPattern, &dashOffset, &dashStyle ); + tempLineCap = graphic_GetLineCap( self ); + tempLineJoin = graphic_GetLineJoin( self ); if (NewValue==TRUE) graphic_SetTransferMode(self,graphic_BLACK); *************** *** 591,600 **** --- 595,610 ---- graphic_MoveTo(self,XPos,YPos); graphic_SetLineWidth(self,1); + graphic_SetLineDash( self, NULL, 0, graphic_LineSolid ); + graphic_SetLineCap( self, 1 ); + graphic_SetLineJoin( self, 0); graphic_DrawLineTo(self,XPos,YPos); /* yep, this draws one dot in wm */ graphic_MoveToPt(self,&tempPt); graphic_SetLineWidth(self,tempLineWidth); + graphic_SetLineDash( self, dashPattern, dashOffset, dashStyle ); + graphic_SetLineCap( self, tempLineCap ); + graphic_SetLineJoin( self, tempLineJoin ); graphic_SetTransferMode(self,tempTMode); } *************** *** 607,613 **** point_OffsetPoint(&self->savedOrigin,DeltaX,DeltaY); rectangle_OffsetRect(&self->localBounds,DeltaX,DeltaY); rectangle_OffsetRect(&self->visualBounds,DeltaX,DeltaY); ! /* *********BUG ************* */ /* Must change clipping rectangle */ /* specification uncertainity: should currentpoint be mnoved? */ /* view bug : all children should have enclosed origins reset */ --- 617,636 ---- point_OffsetPoint(&self->savedOrigin,DeltaX,DeltaY); rectangle_OffsetRect(&self->localBounds,DeltaX,DeltaY); rectangle_OffsetRect(&self->visualBounds,DeltaX,DeltaY); ! if (self->localRegion) { ! region_OffsetRegion(self->localRegion, DeltaX, DeltaY); ! } ! if (self->visualRegion) { ! region_OffsetRegion(self->visualRegion, DeltaX, DeltaY); ! } ! if (self->clippingRegion) { ! region_OffsetRegion(self->clippingRegion, DeltaX, DeltaY); ! } ! point_OffsetPoint(&self->currentPoint, DeltaX, DeltaY); ! ! /* *********Previous BUG statement ************* */ ! /* Added code for doing offsets to clipping and currnet point */ ! /* Still might be wrong */ /* Must change clipping rectangle */ /* specification uncertainity: should currentpoint be mnoved? */ /* view bug : all children should have enclosed origins reset */ *************** *** 674,679 **** --- 697,727 ---- } + void graphic__SetClippingRegion(self, region) + struct graphic *self; + struct region *region; + { + if (self->clippingRegion == NULL) { + self->clippingRegion = region_New(); + } + region_CopyRegion(self->clippingRegion, region); + } + + struct region *graphic__GetClippingRegion(self, retRegion) + struct graphic *self; + struct region *retRegion; + { + if (retRegion != NULL) { + if (self->clippingRegion != NULL) { + region_CopyRegion(retRegion, self->clippingRegion); + } + else { + return NULL; + } + } + return retRegion; + } + void graphic__SetClippingRect(self, AdditionalRect) struct graphic * self; struct rectangle * AdditionalRect; *************** *** 681,689 **** /* Note: we need some way to remove the clipping rectangle so that resizing does the "right" thing */ ! if (self->clippingRect) ! *self->clippingRect = *AdditionalRect; ! else self->clippingRect = rectangle_Duplicate(AdditionalRect); } void graphic__SetClippingRectSize(self, x, y, w, h) --- 729,740 ---- /* Note: we need some way to remove the clipping rectangle so that resizing does the "right" thing */ ! if (self->clippingRegion == NULL) { ! self->clippingRegion = region_CreateRectRegion(AdditionalRect); ! } ! else { ! region_RectRegion(self->clippingRegion, AdditionalRect); ! } } void graphic__SetClippingRectSize(self, x, y, w, h) *************** *** 699,706 **** struct graphic * self; { ! if (self->clippingRect) free(self->clippingRect); ! self->clippingRect = NULL; } void graphic__GetClippingRect(self,Rect) --- 750,758 ---- struct graphic * self; { ! if (self->clippingRegion) ! region_Destroy(self->clippingRegion); ! self->clippingRegion = NULL; } void graphic__GetClippingRect(self,Rect) *************** *** 707,713 **** struct graphic * self; struct rectangle * Rect; { ! if (self->clippingRect) *Rect = *self->clippingRect; else graphic_GetVisualBounds(self,Rect); } --- 759,765 ---- struct graphic * self; struct rectangle * Rect; { ! if (self->clippingRegion) region_GetBoundingBox(self->clippingRegion, Rect); else graphic_GetVisualBounds(self,Rect); } *************** *** 726,731 **** --- 778,846 ---- return self->lineWidth; } + void graphic__SetLineDash( self, dashPattern, dashOffset, dashType ) + struct graphic *self; + char *dashPattern; + int dashOffset; + short dashType; + { + char *oldDash = self->lineDashPattern; + + self->lineDashType = dashType; + self->lineDashOffset = dashOffset; + if ( dashPattern && ( self->lineDashPattern = malloc( strlen( dashPattern ) + 1 ))) + { + strcpy( self->lineDashPattern, dashPattern ); + if ( oldDash ) free( oldDash ); + } + else self->lineDashPattern = oldDash; + } + + void graphic__GetLineDash( self, dashPattern, dashOffset, dashType ) + struct graphic *self; + char **dashPattern; + int *dashOffset; + short *dashType; + { + if ( dashOffset ) *dashOffset = self->lineDashOffset; + if ( dashType ) *dashType = self->lineDashType; + if ( dashPattern ) + { + if ( self->lineDashPattern ) + { + *dashPattern = malloc( strlen( self->lineDashPattern ) + 1 ); + strcpy( *dashPattern, self->lineDashPattern ); + } + else *dashPattern = NULL; + } + } + + void graphic__SetLineCap( self, newLineCap ) + struct graphic *self; + short newLineCap; + { + self->lineCap = newLineCap; + } + + short graphic__GetLineCap( self ) + struct graphic *self; + { + return self->lineCap; + } + + void graphic__SetLineJoin( self, newLineJoin ) + struct graphic *self; + short newLineJoin; + { + self->lineJoin = newLineJoin; + } + + short graphic__GetLineJoin( self ) + struct graphic *self; + { + return self->lineJoin; + } + void graphic__SetTransferMode(self,NewTransferMode) struct graphic * self; short NewTransferMode; *************** *** 760,765 **** --- 875,959 ---- } + void graphic__InsertGraphicRegion(self, EnclosingGraphic, region) + struct graphic * self; + struct graphic * EnclosingGraphic; + struct region *region; + { + /* Fill in the local bounds for the rectangle (always 0,0 based + upon creation) */ + + if (region_IsRegionEmpty(region)) { + graphic_InsertGraphicSize(self, EnclosingGraphic, 0,0, 0, 0); + return; + } + + if (self->localRegion == NULL) { + self->localRegion = region_New(); + } + region_CopyRegion(self->localRegion, region); + region_GetBoundingBox(self->localRegion, &self->localBounds); + + point_X(&self->enclosedOrigin) = rectangle_Left(&self->localBounds); + point_Y(&self->enclosedOrigin) = rectangle_Top(&self->localBounds); + + rectangle_Left(&self->localBounds) = point_X(&self->savedOrigin); + rectangle_Top(&self->localBounds) = point_Y(&self->savedOrigin); + + region_OffsetRegion(self->localRegion, + point_X(&self->savedOrigin) - point_X(&self->enclosedOrigin), + point_Y(&self->savedOrigin) - point_Y(&self->enclosedOrigin)); + + + /* Calculate the visual bounds for the newly enclosed rectangle + in terms of the parent. Start with entire requested area, + and then clip (intersect) to enclosing graphic */ + + if (self->visualRegion == NULL) { + self->visualRegion = region_New(); + } + region_CopyRegion(self->visualRegion, region); + if (EnclosingGraphic->visualRegion != NULL) { + region_IntersectRegion(self->visualRegion, EnclosingGraphic->visualRegion, + self->visualRegion); + } + else { + struct region *tmpRegion; + + tmpRegion = region_CreateRectRegion(&EnclosingGraphic->visualBounds); + region_IntersectRegion(self->visualRegion, tmpRegion, + self->visualRegion); + region_Destroy(tmpRegion); + } + + region_OffsetRegion(self->visualRegion, + point_X(&self->savedOrigin) - point_X(&self->enclosedOrigin), + point_Y(&self->savedOrigin) - point_Y(&self->enclosedOrigin)); + + region_GetBoundingBox(self->visualRegion, &self->visualBounds); + + /* Since the clippingRegion is relative to the visual rect, we + define the clipping region as disappearing with an + insertion operation */ + if (self->clippingRegion) + region_Destroy(self->clippingRegion); + self->clippingRegion = NULL; + + + /* Now figure out how the local window manager offsets should be + reset. Note: the origin that we are calculating should be the + upper left hand corner of the local bounds (0,0 point) of the + newly created graphic. This way we know that any references to + a point in the local graphic are exactly offset by the + the origin we are about to calculate. */ + + self->physicalOrigin = + EnclosingGraphic->physicalOrigin; + point_OffsetPoint(&self->physicalOrigin, + point_X(&self->enclosedOrigin), + point_Y(&self->enclosedOrigin)); + } + void graphic__InsertGraphicSize(self, EnclosingGraphic, xOriginInParent, yOriginInParent, width, height) struct graphic * self; *************** *** 796,806 **** &EnclosingGraphic->visualBounds); /* Now reorient the rect to local (savedOrigin based) coordinates. */ rectangle_OffsetRect(&self->visualBounds, ! -rectangle_Left(EnclosedRectangle), ! -rectangle_Top(EnclosedRectangle)); ! rectangle_OffsetRect(&self->visualBounds,point_X(&self->savedOrigin), ! point_Y(&self->savedOrigin)); /* Install the origin relative to the enclosing grphic (just copy over the rectangle that it specified! */ point_SetPt(&self->enclosedOrigin, --- 990,1011 ---- &EnclosingGraphic->visualBounds); /* Now reorient the rect to local (savedOrigin based) coordinates. */ rectangle_OffsetRect(&self->visualBounds, ! point_X(&self->savedOrigin)-rectangle_Left(EnclosedRectangle), ! point_Y(&self->savedOrigin)-rectangle_Top(EnclosedRectangle)); + if (self->visualRegion != NULL) { + region_Destroy(self->visualRegion); + self->visualRegion = NULL; + } + if (EnclosingGraphic->visualRegion != NULL) { + self->visualRegion = region_CreateRectRegion(EnclosedRectangle); + region_IntersectRegion(self->visualRegion, EnclosingGraphic->visualRegion, + self->visualRegion); + region_OffsetRegion(self->visualRegion, + point_X(&self->savedOrigin)-rectangle_Left(EnclosedRectangle), + point_Y(&self->savedOrigin)-rectangle_Top(EnclosedRectangle)); + } + /* Install the origin relative to the enclosing grphic (just copy over the rectangle that it specified! */ point_SetPt(&self->enclosedOrigin, *************** *** 807,817 **** rectangle_Left(EnclosedRectangle), rectangle_Top(EnclosedRectangle)); ! /* Since the clippingRect is relative to the visual rect, we ! define the clipping rectangle as disappearing with an insertion operation */ ! if (self->clippingRect) free(self->clippingRect); ! self->clippingRect = NULL; /* Now figure out how the local window manager offsets should be --- 1012,1023 ---- rectangle_Left(EnclosedRectangle), rectangle_Top(EnclosedRectangle)); ! /* Since the clippingRegion is relative to the visual rect, we ! define the clipping region as disappearing with an insertion operation */ ! if (self->clippingRegion) ! region_Destroy(self->clippingRegion); ! self->clippingRegion = NULL; /* Now figure out how the local window manager offsets should be *************** *** 829,835 **** --- 1035,1079 ---- } + void graphic__SetVisualRegion(self, region) + struct graphic *self; + struct region *region; + { + if (region_IsRegionEmpty(region)) { + rectangle_SetWidth(&self->visualBounds, 0); + rectangle_SetHeight(&self->visualBounds, 0); + } + else { + if (self->visualRegion == NULL) { + self->visualRegion = region_New(); + } + region_CopyRegion(self->visualRegion, region); + region_OffsetRegion(self->visualRegion, + point_X(&self->savedOrigin), + point_Y(&self->savedOrigin)); + region_GetBoundingBox(self->visualRegion, &self->visualBounds); + } + } + struct region *graphic__GetVisualRegion(self, retRegion) + struct graphic *self; + struct region *retRegion; + { + if (retRegion != NULL) { + if (self->visualRegion != NULL) { + region_CopyRegion(retRegion, self->visualRegion); + } + else { + struct region *tmpRegion; + + tmpRegion = region_CreateRectRegion(&self->visualBounds); + region_CopyRegion(retRegion, tmpRegion); + region_Destroy(tmpRegion); + } + } + return retRegion; + } + void graphic__RestoreGraphicsState(self) struct graphic * self; { *************** *** 865,883 **** return (struct graphic *) 0; } - struct graphic * graphic__ColorPattern(self, red, blue, green) - struct graphic * self; - long red, blue, green; - { - /* Just a place holder */ - static boolean printed = FALSE; - if (! printed) { - printed = TRUE; - fprintf(stderr, "graphic: ColorPattern not implemented for this wm \n"); - } - return NULL; - } - void graphic__SetDefaultColors(classID, foreground, background) struct classinfo *classID; char *foreground; --- 1109,1114 ---- *************** *** 923,966 **** * name and the rgb values should correspond to what is really on the screen... * -Z- */ ! void graphic__SetForegroundColor(self, colorName, red, blue, green) struct graphic * self; char *colorName; long red, blue, green; { self->foreRed = red; self->foreGreen = green; self->foreBlue = blue; } ! void graphic__GetForegroundColor(self, red, blue, green) struct graphic * self; long *red, *blue, *green; { if (red) *red = self->foreRed; - if (blue) *blue = self->foreBlue; if (green) *green = self->foreGreen; } ! void graphic__SetBackgroundColor(self, colorName, red, blue, green) struct graphic * self; char *colorName; long red, blue, green; { self->backRed = red; self->backGreen = green; self->backBlue = blue; } ! void graphic__GetBackgroundColor(self, red, blue, green) struct graphic * self; long *red, *blue, *green; { if (red) *red = self->backRed; - if (blue) *blue = self->backBlue; if (green) *green = self->backGreen; } long graphic__GetHorizontalResolution(self) struct graphic * self; { --- 1154,1265 ---- * name and the rgb values should correspond to what is really on the screen... * -Z- */ ! /* 5/1/90: the color names can now be gotten. The RGB values are guarenteed to match ! the screen only when using an ASCII name. Otherwise they are as specified. -SG */ ! ! void graphic__SetForegroundColor(self, colorName, red, green, blue) struct graphic * self; char *colorName; long red, blue, green; { + if ( colorName ) + { + if ( self->foreName ) free( self->foreName ); + if ( self->foreName = malloc( strlen( colorName ) + 1 )) + strcpy( self->foreName, colorName ); + } + else if ( self->foreName ) + { + free( self->foreName ); + self->foreName = NULL; + } self->foreRed = red; self->foreGreen = green; self->foreBlue = blue; } ! void graphic__GetForegroundColor(self, colorName, red, green, blue) struct graphic * self; + char **colorName; long *red, *blue, *green; { + + if ( colorName ) + *colorName = self->foreName; if (red) *red = self->foreRed; if (green) *green = self->foreGreen; + if (blue) *blue = self->foreBlue; } ! void graphic__SetBackgroundColor(self, colorName, red, green, blue) struct graphic * self; char *colorName; long red, blue, green; { + if ( colorName ) + { + if ( self->backName ) free( self->backName ); + if ( self->backName = malloc( strlen( colorName ) + 1 )) + strcpy( self->backName, colorName ); + } + else if ( self->backName ) + { + free( self->backName ); + self->backName = NULL; + } self->backRed = red; self->backGreen = green; self->backBlue = blue; } ! void graphic__GetBackgroundColor(self, colorName, red, green, blue) struct graphic * self; + char **colorName; long *red, *blue, *green; { + if ( colorName ) + *colorName = self->backName; if (red) *red = self->backRed; if (green) *green = self->backGreen; + if (blue) *blue = self->backBlue; } + void graphic__SetFGColor( self, red, green, blue ) + struct graphic *self; + double red, green, blue; + { + self->foreRed = ( long ) ( red * 65535.0 ); + self->foreGreen = ( long ) ( green * 65535.0 ); + self->foreBlue = ( long ) ( blue * 65535.0 ); + } + + void graphic__GetFGColor( self, red, green, blue ) + struct graphic *self; + double *red, *green, *blue; + { + if (red) *red = ( double ) self->foreRed / 65535.0; + if (green) *green = ( double ) self->foreGreen / 65535.0; + if (blue) *blue = ( double ) self->foreBlue / 65535.0; + } + + void graphic__SetBGColor( self, red, green, blue ) + struct graphic *self; + double red, green, blue; + { + self->backRed = ( long ) ( red * 65535.0 ); + self->backGreen = ( long ) ( green * 65535.0 ); + self->backBlue = ( long ) ( blue * 65535.0 ); + } + + void graphic__GetBGColor( self, red, green, blue ) + struct graphic *self; + double *red, *green, *blue; + { + if (red) *red = ( double ) self->backRed / 65535.0; + if (green) *green = ( double ) self->backGreen / 65535.0; + if (blue) *blue = ( double ) self->backBlue / 65535.0; + } + long graphic__GetHorizontalResolution(self) struct graphic * self; { *************** *** 985,990 **** --- 1284,1295 ---- return 0; } + long graphic__DisplayClass( self ) + struct graphic *self; + { + return graphic_Monochrome | graphic_StaticGray; + } + /* -------------------------------------------------- */ /* Predefined procedures */ /* -------------------------------------------------- */ *************** *** 997,1002 **** --- 1302,1309 ---- rectangle_SetRectSize(&self->localBounds,0,0,0,0); rectangle_SetRectSize(&self->visualBounds,0,0,0,0); + self->localRegion = NULL; + self->visualRegion = NULL; point_SetPt(&self->savedOrigin,0,0); point_SetPt(&self->enclosedOrigin,0,0); if (defaultFont == NULL) *************** *** 1006,1012 **** self->spaceShim = 0; self->transferMode = graphic_COPY; self->lineWidth = 1; ! self->clippingRect = (struct rectangle * ) NULL; point_SetPt(&self->currentPoint,0,0); point_SetPt(&self->physicalOrigin,0,0); --- 1313,1324 ---- self->spaceShim = 0; self->transferMode = graphic_COPY; self->lineWidth = 1; ! self->lineDashType = 0; ! self->lineDashOffset = 0; ! self->lineDashPattern = NULL; ! self->lineCap = 1; ! self->lineJoin = 0; ! self->clippingRegion = (struct region * ) NULL; point_SetPt(&self->currentPoint,0,0); point_SetPt(&self->physicalOrigin,0,0); *************** *** 1013,1018 **** --- 1325,1331 ---- self->backRed = self->backBlue = self->backGreen = 65535; /* white */ self->foreRed = self->foreBlue = self->foreGreen = 0; /* black */ + self->foreName = self->backName = NULL; return TRUE; } *************** *** 1031,1036 **** struct graphic *self; { if (self->internalFont) fontdesc_Destroy(self->currentFont); ! if (self->clippingRect) free(self->clippingRect); } --- 1344,1357 ---- struct graphic *self; { if (self->internalFont) fontdesc_Destroy(self->currentFont); ! if (self->clippingRegion) { ! region_Destroy(self->clippingRegion); ! } ! if (self->localRegion) { ! region_Destroy(self->localRegion); ! } ! if (self->visualRegion) { ! region_Destroy(self->visualRegion); ! } } *** atk/basics/common/graphic.ch Wed Nov 22 11:49:49 1989 --- atk/basics/common/graphic.ch.NEW Thu May 10 16:24:07 1990 *************** *** 3,14 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/graphic.ch,v 2.10 89/09/08 10:01:07 ghoti Exp $ */ /* $ACIS:graphic.ch 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/graphic.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidgraphic_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/graphic.ch,v 2.10 89/09/08 10:01:07 ghoti Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #include --- 3,14 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/graphic.ch,v 2.12 90/05/09 14:05:25 ajp Exp $ */ /* $ACIS:graphic.ch 1.5$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/graphic.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidgraphic_H = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/graphic.ch,v 2.12 90/05/09 14:05:25 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ #include *************** *** 30,36 **** --- 30,61 ---- #define graphic_BETWEENTOPANDBOTTOM 0100 #define graphic_BETWEENTOPANDBASELINE 0200 + /* LineDash */ + #define graphic_LineSolid 0 + #define graphic_LineDoubleDash 1 + #define graphic_LineOnOffDash 2 + /* LineCap */ + #define graphic_CapNotLast 0 + #define graphic_CapButt 1 + #define graphic_CapRound 2 + #define graphic_CapProjecting 3 + + /* LineJoin */ + #define graphic_JoinMiter 0 + #define graphic_JoinRound 1 + #define graphic_JoinBevel 2 + + /* Display Classes */ + #define graphic_Monochrome (1<<1) + #define graphic_Color (1<<2) + #define graphic_PseudoColor (1<<3) + #define graphic_GrayScale (1<<4) + #define graphic_DirectColor (1<<5) + #define graphic_TrueColor (1<<6) + #define graphic_StaticColor (1<<7) + #define graphic_StaticGray (1<<8) + class graphic : observable[observe] { methods: MoveToPt(struct point * Pt); *************** *** 101,106 **** --- 126,136 ---- InsertGraphic(struct graphic * EnclosingGraphic, struct rectangle * EnclosedRectangle); InsertGraphicSize(struct graphic * EnclosingGraphic, long xOriginInParent, long yOriginInParent, long width, long height); + InsertGraphicRegion(struct graphic *EnclosingGraphic, struct region *regions); + + SetVisualRegion(struct region *region); + GetVisualRegion(struct region *retRegion) returns struct region *; + MoveLogicalOrigin(long DeltaX, long DeltaY); SetLogicalOrigin(long NewX, long NewY); SetLogicalOriginPt(struct point * Pt); *************** *** 116,121 **** --- 146,154 ---- GetVisualRight() returns long; GetVisualBottom() returns long; + SetClippingRegion(struct region *region); + GetClippingRegion(struct region *retRegion) returns struct region *; + SetClippingRect(struct rectangle * AdditionalRect); SetClippingRectSize(long x, y, w, h); ClearClippingRect(); *************** *** 124,129 **** --- 157,171 ---- SetLineWidth(short NewLineWidth); GetLineWidth() returns short; + SetLineDash( char *dashPattern, int dashOffset, short dashType ); + GetLineDash( char **dashPattern, int *dashOffset, short *dashType ); + + SetLineCap( short NewLineCap ); + GetLineCap() returns short; + + SetLineJoin( short NewLineJoin ); + GetLineJoin() returns short; + SetTransferMode(short NewTransferMode); GetTransferMode() returns short; *************** *** 133,150 **** WhitePattern() returns struct graphic *; BlackPattern() returns struct graphic *; GrayPattern(short IntensityNum, IntensityDenom) returns struct graphic *; - ColorPattern(long red, long blue, long green) returns struct graphic *; /* If colorName is NULL, use the RGB. */ ! SetForegroundColor(char *colorName, long red, long blue, long green); ! GetForegroundColor(long *red, long *blue, long *green); ! SetBackgroundColor(char *colorName, long red, long blue, long green); ! GetBackgroundColor(long *red, long *blue, long *green); GetHorizontalResolution() returns long; GetVerticalResolution() returns long; GetWindowManagerType() returns char *; GetDevice() returns long; macromethods: --- 175,197 ---- WhitePattern() returns struct graphic *; BlackPattern() returns struct graphic *; GrayPattern(short IntensityNum, IntensityDenom) returns struct graphic *; /* If colorName is NULL, use the RGB. */ ! SetForegroundColor(char *colorName, long red, long green, long blue); ! GetForegroundColor(char **colorName, long *red, long *green, long *blue); ! SetBackgroundColor(char *colorName, long red, long green, long blue); ! GetBackgroundColor(char **colorName, long *red, long *green, long *blue); + SetFGColor( double red, double green, double blue ); + GetFGColor( double *red, double *green, double *blue ); + SetBGColor( double red, double green, double blue ); + GetBGColor( double *red, double *green, double *blue ); + GetHorizontalResolution() returns long; GetVerticalResolution() returns long; GetWindowManagerType() returns char *; GetDevice() returns long; + DisplayClass() returns long; macromethods: *************** *** 173,178 **** --- 220,227 ---- data: struct rectangle localBounds; /* What is size of rectangle */ struct rectangle visualBounds; /* How much of rect is seen */ + struct region *localRegion; + struct region *visualRegion; struct point savedOrigin; /* Logical offsets of origin */ /* Saved across insertions */ struct point enclosedOrigin; /* local rect in parent's coord*/ *************** *** 180,190 **** short spaceShim; short transferMode; /* ALU function for bitblit */ short lineWidth; /* How thick to make outlines */ ! struct rectangle * clippingRect; /* Rects for clipping */ struct point currentPoint; /* Start of drawing operations */ boolean internalFont; /* internal fontdescriptor */ long foreRed, foreGreen, foreBlue; /* Foreground colors */ long backRed, backGreen, backBlue; /* Backgrond colors */ /* private data */ struct point physicalOrigin; --- 229,245 ---- short spaceShim; short transferMode; /* ALU function for bitblit */ short lineWidth; /* How thick to make outlines */ ! short lineDashType; /* Dash style for lines */ ! int lineDashOffset; /* Dash offset (phase) for lines */ ! char *lineDashPattern; /* Dash pattern for lines */ ! short lineCap; /* Cap style for lines */ ! short lineJoin; /* Join style for lines */ ! struct region * clippingRegion; /* Rects for clipping */ struct point currentPoint; /* Start of drawing operations */ boolean internalFont; /* internal fontdescriptor */ long foreRed, foreGreen, foreBlue; /* Foreground colors */ long backRed, backGreen, backBlue; /* Backgrond colors */ + char *foreName, *backName; /* background and foregound names */ /* private data */ struct point physicalOrigin; *** atk/basics/common/graphic.doc Wed Nov 22 11:50:51 1989 --- atk/basics/common/graphic.doc.NEW Thu May 10 16:24:12 1990 *************** *** 1,4 **** ! \begindata{text,270048644} \textdsversion{12} \template{be2guide} \define{bold --- 1,4 ---- ! \begindata{text,268637772} \textdsversion{12} \template{be2guide} \define{bold *************** *** 95,104 **** \fixedtext{void \bold{graphic_}ClearClippingRect }\fixedindent{(struct graphic *\paramname{graphic});} - \fixedtext{struct graphic *\bold{graphic_}ColorPattern }\fixedindent{(struct - graphic *\paramname{graphic}, long \paramname{red}, long \paramname{blue}, - long \paramname{green});} - \fixedtext{struct graphic *\bold{graphic_}CreateGraphic }\fixedindent{();} \fixedtext{void \bold{graphic_}DrawArcSize }\fixedindent{(struct graphic --- 95,100 ---- *************** *** 190,197 **** \paramname{width}, long \paramname{height}, struct graphic *\paramname{Tile});} - - \fixedtext{void \bold{graphic_}FillOval }\fixedindent{(struct graphic *\paramname{graphic}, struct rectangle *\paramname{Rect}, struct graphic *\paramname{Tile});} --- 186,191 ---- *************** *** 205,211 **** \paramname{width}, long \paramname{height}, struct graphic *\paramname{Tile});} - \fixedtext{void \bold{graphic_}FillRect }\fixedindent{(struct graphic *\paramname{graphic}, struct rectangle *\paramname{Rect}, struct graphic *\paramname{Tile});} --- 199,204 ---- *************** *** 235,242 **** *\paramname{graphic});} \fixedtext{void \bold{graphic_}GetBackgroundColor }\fixedindent{(struct ! graphic *\paramname{graphic}, long *\paramname{red}, long *\paramname{blue}, ! long *\paramname{green});} \fixedtext{void \bold{graphic_}GetClippingRect }\fixedindent{(struct graphic *\paramname{graphic}, struct rectangle *\paramname{Rect});} --- 228,235 ---- *\paramname{graphic});} \fixedtext{void \bold{graphic_}GetBackgroundColor }\fixedindent{(struct ! graphic *\paramname{graphic}, char **\paramname{colorName}, long ! *\paramname{red}, long *\paramname{green}, long *\paramname{blue});} \fixedtext{void \bold{graphic_}GetClippingRect }\fixedindent{(struct graphic *\paramname{graphic}, struct rectangle *\paramname{Rect});} *************** *** 275,282 **** graphic *\paramname{graphic});} \fixedtext{void \bold{graphic_}GetForegroundColor }\fixedindent{(struct ! graphic *\paramname{graphic}, long *\paramname{red}, long *\paramname{blue}, ! long *\paramname{green});} \fixedtext{long \bold{graphic_}GetHorizontalResolution }\fixedindent{(struct graphic *\paramname{graphic});} \fixedtext{short \bold{graphic_}GetLineWidth --- 268,275 ---- graphic *\paramname{graphic});} \fixedtext{void \bold{graphic_}GetForegroundColor }\fixedindent{(struct ! graphic *\paramname{graphic}, char **\paramname{colorName}, long ! *\paramname{red}, long *\paramname{green}, long *\paramname{blue});} \fixedtext{long \bold{graphic_}GetHorizontalResolution }\fixedindent{(struct graphic *\paramname{graphic});} \fixedtext{short \bold{graphic_}GetLineWidth *************** *** 374,380 **** \fixedtext{void \bold{graphic_}SetBackgroundColor }\fixedindent{(struct graphic *\paramname{graphic}, char *\paramname{colorName}, long ! \paramname{red}, long \paramname{blue}, long \paramname{green});} \fixedtext{void \bold{graphic_}SetBitAtLoc }\fixedindent{(struct graphic *\paramname{graphic}, long \paramname{XPos}, long \paramname{YPos}, boolean --- 367,373 ---- \fixedtext{void \bold{graphic_}SetBackgroundColor }\fixedindent{(struct graphic *\paramname{graphic}, char *\paramname{colorName}, long ! \paramname{red}, long \paramname{green}, long \paramname{blue});} \fixedtext{void \bold{graphic_}SetBitAtLoc }\fixedindent{(struct graphic *\paramname{graphic}, long \paramname{XPos}, long \paramname{YPos}, boolean *************** *** 395,401 **** \fixedtext{void \bold{graphic_}SetForegroundColor }\fixedindent{(struct graphic *\paramname{graphic}, char *\paramname{colorName}, long ! \paramname{red}, long \paramname{blue}, long \paramname{green});} \fixedtext{void \bold{graphic_}SetLineWidth }\fixedindent{(struct graphic *\paramname{graphic}, short \paramname{NewLineWidth});} --- 388,394 ---- \fixedtext{void \bold{graphic_}SetForegroundColor }\fixedindent{(struct graphic *\paramname{graphic}, char *\paramname{colorName}, long ! \paramname{red}, long \paramname{green}, long \paramname{blue});} \fixedtext{void \bold{graphic_}SetLineWidth }\fixedindent{(struct graphic *\paramname{graphic}, short \paramname{NewLineWidth});} *************** *** 419,426 **** --- 412,450 ---- \paramname{SrcX}, long \paramname{SrcY}, long \paramname{width}, long \paramname{height});} + \fixedtext{void \bold{graphic_}SetFGColor( struct graphic *\paramname{graphic, + }double \paramname{red}, double \paramname{green}, double \paramname{blue} ); + void \bold{graphic_}GetFGColor( struct graphic *\paramname{graphic, }double + *\paramname{red}, double *\paramname{green}, double *\paramname{blue} ); + void \bold{graphic_}SetBGColor( struct graphic *\paramname{graphic, }double + \paramname{red}, double \paramname{green}, double \paramname{blue} ); + + void \bold{graphic_}GetBGColor( struct graphic *\paramname{graphic, }double + *\paramname{red}, double *\paramname{green}, double *\paramname{blue} ); + + void \bold{graphic_}SetLineDash( struct graphic *\paramname{graphic, }char + *\paramname{dashPattern}, int \paramname{dashOffset}, short + \paramname{dashType} ); + + void \bold{graphic_}GetLineDash( struct graphic *\paramname{graphic, }char + **\paramname{dashPattern}, int *\paramname{dashOffset}, short + *\paramname{dashType} ); + + void \bold{graphic_}SetLineCap( struct graphic *\paramname{graphic, }short + \paramname{NewLineCap} ); + + short \bold{graphic_}GetLineCap( struct graphic *\paramname{graphic }); + + void \bold{graphic_}SetLineJoin( struct graphic *\paramname{graphic, }short + \paramname{NewLineJoin} ); + + short \bold{graphic_}GetLineJoin( struct graphic *\paramname{graphic }); + + long \bold{graphic_}DisplayClass( struct graphic *\paramname{graphic });} + + \section{Overview of Graphic} *************** *** 453,461 **** or class procedures in pixmap. ! \begindata{bp,270045832} ! \enddata{bp,270045832} ! \view{bpv,270045832,150,0,0} \subsection{The logical rectangle} \indexi{Logical rectangle} \indexi{Rectangle++Logical} --- 477,485 ---- or class procedures in pixmap. ! \begindata{bp,268697612} ! \enddata{bp,268697612} ! \view{bpv,268697612,0,0,0} \subsection{The logical rectangle} \indexi{Logical rectangle} \indexi{Rectangle++Logical} *************** *** 598,606 **** should initialize the graphic state in the \italic{InitializeObject} procedure. ! \begindata{bp,269987448} ! \enddata{bp,269987448} ! \view{bpv,269987448,151,0,0} \paragraph{Before drawing} \indexi{Graphic++Drawing} --- 622,630 ---- should initialize the graphic state in the \italic{InitializeObject} procedure. ! \begindata{bp,268792956} ! \enddata{bp,268792956} ! \view{bpv,268792956,1,0,0} \paragraph{Before drawing} \indexi{Graphic++Drawing} *************** *** 650,658 **** requests (see section \bold{View}). ! \begindata{bp,269771680} ! \enddata{bp,269771680} ! \view{bpv,269771680,152,0,0} \subsection{Creating and initializing graphics} \paragraph{Creating an instance of a graphic} \indexi{Graphic++Creating} --- 674,682 ---- requests (see section \bold{View}). ! \begindata{bp,268799344} ! \enddata{bp,268799344} ! \view{bpv,268799344,2,0,0} \subsection{Creating and initializing graphics} \paragraph{Creating an instance of a graphic} \indexi{Graphic++Creating} *************** *** 718,726 **** local graphic state. } ! \begindata{bp,269759300} ! \enddata{bp,269759300} ! \view{bpv,269759300,153,0,0} \subsection{The current point} \indexi{Graphic++Current point} --- 742,750 ---- local graphic state. } ! \begindata{bp,268792912} ! \enddata{bp,268792912} ! \view{bpv,268792912,3,0,0} \subsection{The current point} \indexi{Graphic++Current point} *************** *** 784,792 **** current point to \italic{pt}. }\ ! \begindata{bp,270325268} ! \enddata{bp,270325268} ! \view{bpv,270325268,154,0,0} \paragraph{Moving the current point to a new (x,y) coordinate} \indexi{Graphic++Moving} --- 808,816 ---- current point to \italic{pt}. }\ ! \begindata{bp,268842812} ! \enddata{bp,268842812} ! \view{bpv,268842812,4,0,0} \paragraph{Moving the current point to a new (x,y) coordinate} \indexi{Graphic++Moving} *************** *** 893,906 **** } ! \begindata{bp,270000728} ! \enddata{bp,270000728} ! \view{bpv,270000728,155,0,0} \subsection{Drawing Lines} ! Lines are drawn with black "points" using the current transfer mode and line ! width. \paragraph{Drawing a line from the current point to another point} --- 917,930 ---- } ! \begindata{bp,268792844} ! \enddata{bp,268792844} ! \view{bpv,268792844,5,0,0} \subsection{Drawing Lines} ! Lines are drawn with black (foreground color) "points" using the current ! transfer mode and line width. \paragraph{Drawing a line from the current point to another point} *************** *** 975,983 **** CurrentY+\italic{DeltaY}). } ! \begindata{bp,268762084} ! \enddata{bp,268762084} ! \view{bpv,268762084,156,0,0} \subsection{The current line width} --- 999,1007 ---- CurrentY+\italic{DeltaY}). } ! \begindata{bp,268842768} ! \enddata{bp,268842768} ! \view{bpv,268842768,6,0,0} \subsection{The current line width} *************** *** 996,1001 **** --- 1020,1026 ---- short NewLineWidth;} \indexi{ } + \leftindent{\bold{Method description.} \italic{graphic_SetLineWidth} sets the line width to NewLineWidth. The unit is pixels and the value can range from 0 pixels to 2\formatnote{@+}[8}-1. Other values are undefined. *************** *** 1039,1047 **** (CLineWidth+CLineWidth)} doubles the current line width. } ! \begindata{bp,270145588} ! \enddata{bp,270145588} ! \view{bpv,270145588,157,0,0} \subsection{The current font} \indexi{Graphic++Fonts} --- 1064,1222 ---- (CLineWidth+CLineWidth)} doubles the current line width. } ! \bold{\bigger{Line Styles ! ! ! }}\bold{Setting the line dash ! ! } ! \example{void graphic\bold{_}SetLineDash( graphic, dashPattern, dashOffset, ! dashType ); ! ! struct graphic *\paramname{graphic; ! ! }char *\paramname{dashPattern; ! ! }int \paramname{dashOffset; ! ! }short \paramname{dashType; ! ! }} ! \indent{\bold{Method description. } \italic{graphic_SetLineDash }sets the ! current line dash style for line drawing (under X11). The \italic{dashPattern} ! argument is an array of characters whose integer values specify the pattern of ! on-off dashes desired. This array must be terminated with a 0 (zero) value. ! The offset argument defines the phase of the pattern, specifying how many ! pixels into the dashPattern the pattern should actually begin on any single ! line drawing operation. The \italic{dashType} argument can be any of the ! following symbolics: ! ! ! \typewriter{graphic_LineSolid} -- solid, non-dashed lines. ! ! \typewriter{graphic_LineDoubleDash} -- even and odd elements of the ! dashPattern are drawn in the foreground and background colors, respectively. ! ! \typewriter{graphic_LineOnOffDash }-- only the even elements of the ! dashPattern are drawn. ! ! ! A NULL \paramname{dashPattern} argument will set the graphic state to draw ! solid lines. Solid lines are drawn be default until a dash pattern and dash ! type are set.} ! ! ! \bold{Getting the line dash} ! ! \bold{ ! }\example{void graphic_GetLineDash( graphic, dashPattern, dashOffset, ! dashType ); ! ! struct graphic *graphic; ! ! char **dashPattern; ! ! int *dashOffset; ! ! short *dashType;} ! ! ! \indent{\bold{Method description}. \italic{graphic_GetLineDash} returns the ! current values of the line dash style attributes of the given graphic via the ! pointer arguments passed in.} ! ! ! \bold{Setting the line cap ! ! } ! \example{void graphic\bold{_}SetLineCap( graphic, NewLineCap ); ! ! struct graphic *\paramname{graphic; ! ! }short \paramname{NewLineCap;}} ! ! ! \indent{\bold{Method description}. \italic{graphic_SetLineCap} sets the line ! cap style for the given graphic, which defines how the endpoints of a path are ! drawn (under X11). The \paramname{NewLineCap} argument can be any of the ! following symbolics: ! ! ! \typewriter{\typewriter{graphic_CapBut}t} -- the line is square at the ! endpoint (perpenedicular to the slope of the line) with no projection beyond. ! ! \typewriter{graphic_CapNotLast} -- same as graphic_CapButt, except for a line ! width of zero, the final endpoint is not drawn. ! ! \typewriter{graphic_CapRound} -- The line has a circular arc with the diameter ! equal to the line width, centered on the endpoint. ! ! \typewriter{graphic_CapProjecting} -- The line is square at the end, but the ! path continues beyond the endpoint for a distance equal to half the line ! width. ! ! ! The default line cap is \typewriter{graphic_CapButt}. } ! ! ! \bold{Getting the line cap ! ! } ! \example{short graphic\bold{_}GetLineCap( graphic\paramname{ }); ! ! struct graphic *\paramname{graphic;}} ! ! ! \indent{\bold{Method Description}. \italic{graphic_GetLineCap} returns the ! currently set line cap style.} ! ! ! \bold{Setting the line join ! ! } ! \example{void graphic\bold{_}SetLineJoin(graphic, NewLineJoin); ! ! struct graphic *\paramname{graphic; ! ! }short \paramname{NewLineJoin;}}\paramname{ ! ! } ! \indent{\bold{Method description}. \italic{graphic_SetLineJoin} sets the line ! join style for the given graphic, which defines how corners are drawn for wide ! lines (under X11). The NewLineJoin argument can be any of the following ! symbolics: ! ! ! \typewriter{graphic_JoinMiter} -- the outer edges of two lines extend to meet ! at an angle. If the angle is less than 11 degrees, then a graphic_JoinBevel ! style join is used instead. ! ! \typewriter{graphic_JoinRound} -- The corner is a circular arc with the ! diameter equal to the line width, centered on the joinpoint. ! ! \typewriter{graphic_JoinBevel} -- The corner has \typewriter{graphic_CapButt} ! style endpoints, with the triangular notch filled. ! ! ! The default line join is \typewriter{graphic_JoinMiter}. } ! ! ! \bold{Getting the line join ! ! } ! \example{short \bold{graphic_}GetLineJoin( graphic ); ! ! struct graphic *\paramname{graphic; }} ! ! ! \indent{\bold{Method description}: \italic{graphic_GetLineJoin }returns the ! currently set line join style.} ! ! \ ! \begindata{bp,268779584} ! \enddata{bp,268779584} ! \view{bpv,268779584,7,0,0} ! \subsection{The current font} \indexi{Graphic++Fonts} *************** *** 1124,1132 **** } ! \begindata{bp,269945448} ! \enddata{bp,269945448} ! \view{bpv,269945448,158,0,0} \subsection{Drawing Text} \indexi{Graphic++Text} --- 1299,1307 ---- } ! \begindata{bp,268779540} ! \enddata{bp,268779540} ! \view{bpv,268779540,8,0,0} \subsection{Drawing Text} \indexi{Graphic++Text} *************** *** 1212,1220 **** will be used as defaults. } ! \begindata{bp,269855964} ! \enddata{bp,269855964} ! \view{bpv,269855964,159,0,0} \paragraph{Drawing text} \indexi{Graphic++Draw text} \indexi{ \italic{graphic_DrawText}} --- 1387,1395 ---- will be used as defaults. } ! \begindata{bp,268779496} ! \enddata{bp,268779496} ! \view{bpv,268779496,9,0,0} \paragraph{Drawing text} \indexi{Graphic++Draw text} \indexi{ \italic{graphic_DrawText}} *************** *** 1272,1280 **** space shim value. }\ ! \begindata{bp,270079408} ! \enddata{bp,270079408} ! \view{bpv,270079408,160,0,0} \subsection{Drawing regions} \paragraph{Drawing a rectangle} \indexi{Graphic++Draw rectangle} --- 1447,1455 ---- space shim value. }\ ! \begindata{bp,268694964} ! \enddata{bp,268694964} ! \view{bpv,268694964,10,0,0} \subsection{Drawing regions} \paragraph{Drawing a rectangle} \indexi{Graphic++Draw rectangle} *************** *** 1334,1342 **** \leftindent{\bold{Method description.} \italic{graphic_DrawOval} is the same as \italic{graphic_DrawPolygon }except it is used for drawing oval figures.} ! \begindata{bp,270383836} ! \enddata{bp,270383836} ! \view{bpv,270383836,161,0,0} \paragraph{Drawing arcs} \indexi{Graphic++Draw arc} \indexi{ \italic{graphic_DrawArc}} --- 1509,1517 ---- \leftindent{\bold{Method description.} \italic{graphic_DrawOval} is the same as \italic{graphic_DrawPolygon }except it is used for drawing oval figures.} ! \begindata{bp,268779428} ! \enddata{bp,268779428} ! \view{bpv,268779428,11,0,0} \paragraph{Drawing arcs} \indexi{Graphic++Draw arc} \indexi{ \italic{graphic_DrawArc}} *************** *** 1397,1405 **** } ! \subsection{Filling regions} \paragraph{Filling a rectangle} ! \indexi{Graphic++Fill rectangle} \indexi{ \italic{graphic_FillRect}} \example{void graphic_FillRect(grphc, Rect, Tile) --- 1572,1589 ---- } ! \subsection{Filling regions} + The fill methods take a Tile argument, which is used to stipple (mask with a + pattern) the fill operations. Under X11, if the Tile argument is NULL, the + result is a solid fill of the current foreground color. On monochrome + displays, attempts to use color will set an approximation stipple tile that + will be used on fills when the Tile argument is NULL (if it is not NULL, the + Tile argument overrides this approximation tile). + + + \paragraph{Filling a rectangle} \indexi{Graphic++Fill rectangle} + \indexi{ \italic{graphic_FillRect}} \example{void graphic_FillRect(grphc, Rect, Tile) *************** *** 1408,1418 **** struct rectangle *Rect; ! struct pixmap *Tile;} \leftindent{\bold{Method description.} \italic{graphic_FillRect} fills a ! rectangle in grphc with the specified pixmap, \italic{Tile}. \bold{Usage.} If Tile is 1, then black; if 0, then white.} --- 1592,1602 ---- struct rectangle *Rect; ! struct graphic *Tile;} \leftindent{\bold{Method description.} \italic{graphic_FillRect} fills a ! rectangle in grphc with the specified graphic, \italic{Tile}. \bold{Usage.} If Tile is 1, then black; if 0, then white.} *************** *** 1432,1438 **** short PointCount; ! struct pixmap *Tile;} \leftindent{\bold{Method description.} \italic{graphic_FillPolygon} is used --- 1616,1622 ---- short PointCount; ! struct graphic *Tile;} \leftindent{\bold{Method description.} \italic{graphic_FillPolygon} is used *************** *** 1450,1456 **** struct rectangle *Rect; ! struct pixmap *Tile;} \leftindent{\bold{Method description.} \italic{graphic_FillOval} is used to --- 1634,1640 ---- struct rectangle *Rect; ! struct graphic *Tile;} \leftindent{\bold{Method description.} \italic{graphic_FillOval} is used to *************** *** 1470,1476 **** short StartAngle; short OffsetAngle; ! struct pixmap *Tile;} \leftindent{\bold{Method description.} \italic{graphic_FillArc} fills arc --- 1654,1660 ---- short StartAngle; short OffsetAngle; ! struct graphic *Tile;} \leftindent{\bold{Method description.} \italic{graphic_FillArc} fills arc *************** *** 1493,1507 **** struct rectangle *InnerBox; ! struct pixmap *Tile;} \leftindent{\bold{Method description.} \italic{graphic_FillRRect} fills rectangles regions created by \italic{DrawRRect}. } ! \begindata{bp,270325224} ! \enddata{bp,270325224} ! \view{bpv,270325224,162,0,0} \subsection{Bit block transfers} --- 1677,1691 ---- struct rectangle *InnerBox; ! struct graphic *Tile;} \leftindent{\bold{Method description.} \italic{graphic_FillRRect} fills rectangles regions created by \italic{DrawRRect}. } ! \begindata{bp,268779384} ! \enddata{bp,268779384} ! \view{bpv,268779384,12,0,0} \subsection{Bit block transfers} *************** *** 1556,1564 **** \italic{Value}. Value should be 1 (black) or 0 (white). } ! \begindata{bp,269952820} ! \enddata{bp,269952820} ! \view{bpv,269952820,163,0,0} \subsection{The logical rectangle} --- 1740,1748 ---- \italic{Value}. Value should be 1 (black) or 0 (white). } ! \begindata{bp,268779340} ! \enddata{bp,268779340} ! \view{bpv,268779340,13,0,0} \subsection{The logical rectangle} *************** *** 1626,1634 **** logical rectangle.} ! \begindata{bp,270128164} ! \enddata{bp,270128164} ! \view{bpv,270128164,164,0,0} \paragraph{Getting the enclosed bounds} \indexi{Graphic++Get enclosed bounds} \indexi{ \italic{graphic_GetEnclosedBounds}} --- 1810,1818 ---- logical rectangle.} ! \begindata{bp,268779296} ! \enddata{bp,268779296} ! \view{bpv,268779296,14,0,0} \paragraph{Getting the enclosed bounds} \indexi{Graphic++Get enclosed bounds} \indexi{ \italic{graphic_GetEnclosedBounds}} *************** *** 1724,1732 **** ! \begindata{bp,269855908} ! \enddata{bp,269855908} ! \view{bpv,269855908,165,0,0} \subsection{The clipping rectangle} \paragraph{Setting the clipping rectangle} \indexi{Graphic++Set clipping rectangle} --- 1908,1916 ---- ! \begindata{bp,268779252} ! \enddata{bp,268779252} ! \view{bpv,268779252,15,0,0} \subsection{The clipping rectangle} \paragraph{Setting the clipping rectangle} \indexi{Graphic++Set clipping rectangle} *************** *** 1777,1785 **** ! \begindata{bp,270191736} ! \enddata{bp,270191736} ! \view{bpv,270191736,166,0,0} \subsection{The transfer mode} --- 1961,1969 ---- ! \begindata{bp,268694920} ! \enddata{bp,268694920} ! \view{bpv,268694920,16,0,0} \subsection{The transfer mode} *************** *** 1866,1874 **** } } ! \begindata{bp,270045740} ! \enddata{bp,270045740} ! \view{bpv,270045740,167,0,0} \paragraph{Getting the transfer mode} \indexi{Graphic++Get transfer mode} \indexi{ \italic{graphic_GetTransferMode}} --- 2050,2058 ---- } } ! \begindata{bp,268779180} ! \enddata{bp,268779180} ! \view{bpv,268779180,17,0,0} \paragraph{Getting the transfer mode} \indexi{Graphic++Get transfer mode} \indexi{ \italic{graphic_GetTransferMode}} *************** *** 1903,1915 **** \indexi{ \italic{graphic_WhitePattern}} ! \example{struct pixmap *graphic_WhitePattern(grphc) struct graphic *grphc;} \leftindent{\bold{Method description.} \italic{graphic_WhitePattern }returns ! a white pixmap. } --- 2087,2099 ---- \indexi{ \italic{graphic_WhitePattern}} ! \example{struct graphic *graphic_WhitePattern(grphc) struct graphic *grphc;} \leftindent{\bold{Method description.} \italic{graphic_WhitePattern }returns ! a graphic that can be used to supply a white pixmap for fill operations. } *************** *** 1917,1929 **** \indexi{ \italic{graphic_BlackPattern}} ! \example{struct pixmap *graphic_BlackPattern(grphc) struct graphic *grphc;} \leftindent{\bold{Method description.} \italic{graphic_BlackPattern} returns ! a black pixmap. } --- 2101,2113 ---- \indexi{ \italic{graphic_BlackPattern}} ! \example{struct graphic *graphic_BlackPattern(grphc) struct graphic *grphc;} \leftindent{\bold{Method description.} \italic{graphic_BlackPattern} returns ! a graphic that can be used to supply a black pixmap for fill operations. } *************** *** 1931,1937 **** \indexi{ \italic{graphic_GrayPattern}} ! \example{struct pixmap *graphic_GrayPattern(grphc,IntensityNum, IntensityDenom) struct graphic *grphc; --- 2115,2121 ---- \indexi{ \italic{graphic_GrayPattern}} ! \example{struct graphic *graphic_GrayPattern(grphc,IntensityNum, IntensityDenom) struct graphic *grphc; *************** *** 1940,1950 **** \leftindent{\bold{Method description.} \italic{graphic_GrayPattern} returns ! a grey pixmap.} ! \begindata{bp,269937948} ! \enddata{bp,269937948} ! \view{bpv,269937948,168,0,0} \subsection{Redirecting graphic output} \paragraph{Redirecting a graphic} \indexi{Graphic++Redirect} --- 2124,2367 ---- \leftindent{\bold{Method description.} \italic{graphic_GrayPattern} returns ! a graphic that can be used to supply a grey pixmap for fill operations.} ! \begindata{bp,269145492} ! \enddata{bp,269145492} ! \view{bpv,269145492,19,0,0} ! ! \bold{\bigger{Color}} ! ! ! Under X11, the foreground and background colors can be set to achieve color ! output. Colors can be specified either by an ASCII string name, to be looked ! up in the X11 color database, or by specifying RGB values. These RGB values ! can be expressed as integers between 0 and 65535, where 0 is off and 65535 is ! full intensity, or as real numbers between 0.0 and 1.0, where 0.0 is off and ! 1.0 is full intensity. Integers and reals can be used interchangably to set ! and get the foreground and background colors. ! ! ! On monochrome displays, attempts to use color will set an approximation ! stipple tile that will be used on fills when the Tile argument to the graphic ! fill methods is NULL (if it is not NULL, the Tile argument overrides this ! approximation tile). If they choose to, programmers can use the ! \typewriter{DisplayClass} method to determine the nature of the display, and ! can special case monochrome and color as they see fit, effectively bypassing ! the built-in approximation on monochrome. ! ! ! \bold{Determining the display class ! ! } ! \example{long graphic_DisplayClass( graphic ); ! ! struct graphic *graphic} ! ! ! \indent{\bold{Method description}. \italic{graphic_DisplayClass} returns a bit ! mask long integer that describes the display of the server that the ! application is using. The return value consists of the appropriate symbolics ! bitwise-or'ed together. The set of possible values includes symbolics for the ! six display classes defined by X11, plus additional symbolics defined by the ! graphic class: ! ! ! \typewriter{graphic_Monochrome ! ! graphic_Color ! ! graphic_PseudoColor ! ! graphic_GrayScale ! ! graphic_DirectColor ! ! graphic_TrueColor ! ! graphic_StaticColor ! ! graphic_StaticGray} ! ! ! All color displays will have \typewriter{graphic_Color} or'ed in with the ! appropriate display class symbolic. StaticGray displays with a colormap of ! size 2 will have \typewriter{graphic_Monochrome} or'ed in. ! ! ! \bold{Example} ! ! } ! \example{if ( graphic_DisplayClass( graphic ) & graphic_Color ) ! ! ...color handling code... ! ! else if ( graphic_DisplayClass( graphic ) & graphic_Monochrome ) ! ! ... monochrome handling code} ! ! ! \bold{Setting the foreground color ! ! } ! \example{void graphic\bold{_}SetForegroundColor (graphic, colorName, red, ! green, blue); ! ! }\example{struct graphic *graphic; ! ! char *colorName; ! ! long red; ! ! long green; ! ! long blue;} ! ! ! \indent{\bold{Method description}. \italic{graphic_SetForegroundColor} ! optionally takes a colorName argument or RGB values (expressed as integers ! between 0 and 65535) to set the foregound color. If the colorName argument is ! supplied, it is used to look up RGB values and set the foreground color ! accordingly. If colorName is NULL, the red, green, and blue values are used.} ! ! ! \example{void graphic_SetFGColor(graphic, red, green, blue ); ! ! struct graphic *graphic; ! ! double red; ! ! double green; ! ! double blue;} ! ! ! \indent{\bold{Method description}.\italic{\italic{ graphic_SetFGColo}r} ! accepts red, green, and blue real number values between 0.0 and 1.0 to specify ! the foreground color. } ! ! ! \bold{G}\bold{etting the foreground color ! ! } ! \example{void graphic\bold{_}GetForegroundColor (graphic, colorName, red, ! green, blue); ! ! }\example{struct graphic *graphic; ! ! char **colorName; ! ! long *red; ! ! long *green; ! ! long *blue; ! ! } ! \indent{\bold{Method description}. \italic{graphic_GetForegroundColor} returns ! the currently set foreground color. If a colorName was originally used to ! specify the color, both it and the resultant RGB values are returned. ! Otherwise only the RGB values are returned.} ! ! ! \example{void graphic_GetFGColor(graphic, red, green, blue ); ! ! struct graphic *graphic; ! ! double *red; ! ! double *green; ! ! double *blue;} ! ! ! \indent{\bold{Method description}.\italic{\italic{ graphic_GetFGColo}r} ! returns the red, green, and blue real number values between 0.0 and 1.0 that ! describe the currently set foreground color. ! ! ! }\bold{Setting the background color ! ! } ! \example{void graphic\bold{_}SetBackgroundColor (graphic, colorName, red, ! green, blue); ! ! }\example{struct graphic *graphic; ! ! char *colorName; ! ! long red; ! ! long green; ! ! long blue;} ! ! ! \indent{\bold{Method description}. \italic{graphic_SetBackgroundColor} ! optionally takes a colorName argument or RGB values (expressed as integers ! between 0 and 65535) to set the backgound color. If the colorName argument is ! supplied, it is used to look up RGB values and set the background color ! accordingly. If colorName is NULL, the red, green, and blue values are used.} ! ! ! \example{void graphic_SetFGColor(graphic, red, green, blue ); ! ! struct graphic *graphic; ! ! double red; ! ! double green; ! ! double blue;} ! ! ! \indent{\bold{Method description}.\italic{\italic{ graphic_SetFGColo}r} ! accepts red, green, and blue real number values between 0.0 and 1.0 to specify ! the background color. } ! ! ! \bold{G}\bold{etting the background color ! ! } ! \example{void graphic\bold{_}GetBackgroundColor (graphic, colorName, red, ! green, blue); ! ! }\example{struct graphic *graphic; ! ! char **colorName; ! ! long *red; ! ! long *green; ! ! long *blue; ! ! } ! \indent{\bold{Method description}. \italic{graphic_GetBackgroundColor} returns ! the currently set background color. If a colorName was originally used to ! specify the color, both it and the resultant RGB values are returned. ! Otherwise only the RGB values are returned.} ! ! ! \example{void graphic_GetBGColor(graphic, red, green, blue ); ! ! struct graphic *graphic; ! ! double *red; ! ! double *green; ! ! double *blue;} ! ! ! \indent{\bold{Method description}.\italic{\italic{ graphic_GetBGColo}r} ! returns the red, green, and blue real number values between 0.0 and 1.0 that ! describe the currently set background color. ! ! } ! \begindata{bp,268779136} ! \enddata{bp,268779136} ! \view{bpv,268779136,18,0,0} \subsection{Redirecting graphic output} \paragraph{Redirecting a graphic} \indexi{Graphic++Redirect} *************** *** 1967,1970 **** } ! \enddata{text,270048644} --- 2384,2387 ---- } ! \enddata{text,268637772} *** atk/basics/common/im.c Wed Jan 17 16:37:02 1990 --- atk/basics/common/im.c.NEW Fri Jul 27 12:47:02 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/common/RCS/im.c,v 2.27 89/12/12 14:58:34 ghoti Exp $ */ /* $ACIS:im.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/common/RCS/im.c,v $ */ #ifndef lint ! char *im_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/common/RCS/im.c,v 2.27 89/12/12 14:58:34 ghoti Exp $"; #endif /* lint */ /* Put in error messages for handling of keystrokes. --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/im.c,v 2.30 90/07/23 15:00:47 rr2b Exp $ */ /* $ACIS:im.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/im.c,v $ */ #ifndef lint ! char *im_rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/im.c,v 2.30 90/07/23 15:00:47 rr2b Exp $"; #endif /* lint */ /* Put in error messages for handling of keystrokes. *************** *** 206,213 **** fprintf(self->LogFile, "%s", ctime(&now)); } if (self->LogFile == NULL) return; ! if (str[1] == '\0') str = charToPrintable(*str); fprintf(self->LogFile, "%d%c%s\n", now - LogStart, code, str); } --- 206,216 ---- fprintf(self->LogFile, "%s", ctime(&now)); } if (self->LogFile == NULL) return; ! if(str == NULL) str="NULL host"; ! else { ! if (str[1] == '\0') str = charToPrintable(*str); + } fprintf(self->LogFile, "%d%c%s\n", now - LogStart, code, str); } *************** *** 358,364 **** else p->next = n; freeQelt(a); } ! p = a; } } --- 361,369 ---- else p->next = n; freeQelt(a); } ! else { ! p = a; ! } } } *************** *** 1689,1695 **** } ! #ifdef hp9000s300 xim_sigAlrm() { } #endif /* hp9000s300 */ --- 1694,1700 ---- } ! #if defined(hp9000s300) && HP_OS < 70 xim_sigAlrm() { } #endif /* hp9000s300 */ *************** *** 1730,1736 **** else if (childDied) { childDied = FALSE; if (cleanUpZombies) { ! #ifdef hp9000s300 struct sigvec vecAlrm; struct itimerval timer; int pid, status; --- 1735,1741 ---- else if (childDied) { childDied = FALSE; if (cleanUpZombies) { ! #if defined(hp9000s300) && HP_OS < 70 struct sigvec vecAlrm; struct itimerval timer; int pid, status; *** atk/basics/common/im.ch Wed Nov 22 11:49:51 1989 --- atk/basics/common/im.ch.NEW Thu May 10 16:24:16 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/im.ch,v 2.12 89/09/08 13:29:31 tpn Exp $ */ /* $ACIS:im.ch 1.4$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/im.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidim_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/im.ch,v 2.12 89/09/08 13:29:31 tpn Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/im.ch,v 2.13 90/05/03 12:31:39 gk5g Exp $ */ /* $ACIS:im.ch 1.4$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/im.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidim_H = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/im.ch,v 2.13 90/05/03 12:31:39 gk5g Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 173,179 **** RedrawChangedWindows(); SetDefaultServerHost(char *name); ! SetGeometrySpec(char value); data: struct atom * programNameAtom; struct im *next; /* Next im allocated object */ --- 173,179 ---- RedrawChangedWindows(); SetDefaultServerHost(char *name); ! SetGeometrySpec(char *value); data: struct atom * programNameAtom; struct im *next; /* Next im allocated object */ *** atk/basics/common/initfls.help Mon Mar 12 13:15:45 1990 --- atk/basics/common/initfls.help.NEW Thu May 10 16:24:18 1990 *************** *** 1,4 **** ! \begindata{text,269223540} \textdsversion{12} \template{help} \chapter{Setting up and using initialization files}\chapter{ --- 1,4 ---- ! \begindata{text,269728084} \textdsversion{12} \template{help} \chapter{Setting up and using initialization files}\chapter{ *************** *** 162,168 **** }\leftindent{Addmenu commands let you create new menu items bound to the procedures already available in an inset. You can put new items on the cards the inset provides by default, or put them on entirely new cards you create. ! See the help on \italic{listprocs} for information on how to find out what procedures are available. --- 162,168 ---- }\leftindent{Addmenu commands let you create new menu items bound to the procedures already available in an inset. You can put new items on the cards the inset provides by default, or put them on entirely new cards you create. ! See the help on \italic{deskey} for information on how to find out what procedures are available. *************** *** 270,276 **** \leftindent{ Addkey commands let you bind procedures to particular key sequences, so that when the keys are pressed the procedure is invoked. The same procedures are ! available for keybinding as for menu items; see the help on \italic{listprocs} for information on how to find out what procedures are available. --- 270,276 ---- \leftindent{ Addkey commands let you bind procedures to particular key sequences, so that when the keys are pressed the procedure is invoked. The same procedures are ! available for keybinding as for menu items; see the help on \italic{deskey} for information on how to find out what procedures are available. *************** *** 367,370 **** \italic{typescript-keys }} ! \enddata{text,269223540} --- 367,370 ---- \italic{typescript-keys }} ! \enddata{text,269728084} *** atk/basics/common/keymap.c Wed Nov 22 11:48:43 1989 --- atk/basics/common/keymap.c.NEW Fri Jul 13 11:34:19 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/keymap.c,v 2.5 89/08/15 21:42:04 zs01 Exp $ */ /* $ACIS:keymap.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/keymap.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/keymap.c,v 2.5 89/08/15 21:42:04 zs01 Exp $"; #endif /* lint */ /* keymap.c -- A class that provides mappings of keys to procedures. --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/keymap.c,v 2.7 90/07/12 14:37:31 tpn Exp $ */ /* $ACIS:keymap.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/keymap.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/keymap.c,v 2.7 90/07/12 14:37:31 tpn Exp $"; #endif /* lint */ /* keymap.c -- A class that provides mappings of keys to procedures. *************** *** 59,76 **** static boolean bindKey(self,keys,obj,rock,type) struct keymap *self; ! char *keys; struct basicobject *obj; long rock; enum keymap_Types type; { enum keymap_Types e; ! register char *p; struct keymap *km1, *km2; ! register char c; for (p = keys, km1 = self; p[1] != 0; ++p) { ! c = (*p) & 0x7f; /* high order bit on allows nulls in string */ e = keymap_Lookup(km1, c, &km2,NULL ); if (e == keymap_Empty) { e = keymap_Keymap; --- 59,76 ---- static boolean bindKey(self,keys,obj,rock,type) struct keymap *self; ! unsigned char *keys; struct basicobject *obj; long rock; enum keymap_Types type; { enum keymap_Types e; ! register unsigned char *p; struct keymap *km1, *km2; ! register unsigned char c; for (p = keys, km1 = self; p[1] != 0; ++p) { ! c = (*p == 128)? 0 : *p; /* allows nulls in string to be represented by 128 */ e = keymap_Lookup(km1, c, &km2,NULL ); if (e == keymap_Empty) { e = keymap_Keymap; *************** *** 81,88 **** return FALSE; km1 = km2; } ! c = (*p) & 0x7f; /* to allow nulls in binding strings */ ! keymap_InsertObject(km1,c,obj,rock,type); return TRUE; --- 81,88 ---- return FALSE; km1 = km2; } ! c = (*p == 128)? 0 : *p; /* allows nulls in string to be represented by 128 */ ! keymap_InsertObject(km1,c,obj,rock,type); return TRUE; *** atk/basics/common/keymap.ch Wed Nov 22 11:49:54 1989 --- atk/basics/common/keymap.ch.NEW Fri Jul 13 11:34:22 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/keymap.ch,v 2.5 89/02/17 18:37:43 ghoti Exp $ */ /* $ACIS:keymap.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/keymap.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidkeymap_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/keymap.ch,v 2.5 89/02/17 18:37:43 ghoti Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* keymap.ch -- A class that provides mappings of keys to procedures. --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/keymap.ch,v 2.6 90/07/12 14:18:30 tpn Exp $ */ /* $ACIS:keymap.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/keymap.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidkeymap_H = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/keymap.ch,v 2.6 90/07/12 14:18:30 tpn Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ /* keymap.ch -- A class that provides mappings of keys to procedures. *************** *** 14,20 **** December, 1986 */ /* Number of entries in a keymap. Should be power of two. */ ! #define keymap_MAXKEYS 128 /* Number of entries in a sparse map. Should be a multiple of 4 for good * structure packing. */ #define keymap_SPARSESIZE 16 --- 14,20 ---- December, 1986 */ /* Number of entries in a keymap. Should be power of two. */ ! #define keymap_MAXKEYS 256 /* Number of entries in a sparse map. Should be a multiple of 4 for good * structure packing. */ #define keymap_SPARSESIZE 16 *** atk/basics/common/profile.c Wed Nov 22 11:49:09 1989 --- atk/basics/common/profile.c.NEW Wed Jun 13 16:53:18 1990 *************** *** 18,26 **** #endif /* #ifndef SYSV */ #endif /* #ifdef AIX */ ! #ifndef SYSV #include ! #endif /* SYSV */ #include #define SCALE_1_TO_1 0x10000L --- 18,27 ---- #endif /* #ifndef SYSV */ #endif /* #ifdef AIX */ ! #if (!defined(AIX) && !defined(_IBMR2)) #include ! #endif /* (!defined(AIX) && !defined(_IBMR2)) */ ! #include #define SCALE_1_TO_1 0x10000L *** atk/basics/common/region.c Fri Feb 2 12:24:33 1990 --- atk/basics/common/region.c.NEW Thu May 10 16:24:23 1990 *************** *** 4,15 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/common/RCS/region.c,v 2.5 90/01/26 12:51:13 susan Exp $ */ /* $ACIS:region.c 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/common/RCS/region.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/basics/common/RCS/region.c,v 2.5 90/01/26 12:51:13 susan Exp $"; #endif /* lint */ #include --- 4,15 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/region.c,v 2.6 90/05/09 14:05:07 ajp Exp $ */ /* $ACIS:region.c 1.2$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/region.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/region.c,v 2.6 90/05/09 14:05:07 ajp Exp $"; #endif /* lint */ #include *************** *** 120,125 **** --- 120,140 ---- struct region * self; struct region * TestRegion;{ return XEqualRegion(self->regionData, TestRegion->regionData); + } + + struct rectangle *region__GetBoundingBox(self, retRect) + struct region *self; + struct rectangle *retRect; + { + XRectangle rect; + + if (retRect != NULL) { + XClipBox(self->regionData, &rect); + + rectangle_SetRectSize(retRect, rect.x, rect.y, + rect.width, rect.height); + } + return retRect; } *** atk/basics/common/region.ch Wed Nov 22 11:50:18 1989 --- atk/basics/common/region.ch.NEW Thu May 10 16:24:24 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/region.ch,v 2.6 89/09/08 10:01:20 ghoti Exp $ */ /* $ACIS:region.ch 1.2$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/region.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidregion_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/region.ch,v 2.6 89/09/08 10:01:20 ghoti Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/region.ch,v 2.7 90/05/09 14:05:36 ajp Exp $ */ /* $ACIS:region.ch 1.2$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/region.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidregion_H = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/region.ch,v 2.7 90/05/09 14:05:36 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 32,37 **** --- 32,41 ---- IsRectInRegion(struct rectangle * TestRect) returns boolean; AreRegionsEqual(struct region * TestRegion) returns boolean; + GetBoundingBox(struct rectangle *rect) returns struct rectangle *; + + macromethods: + GetRegionData() ((self)->regionData) /* Only used in the X code. probably should subclass region to do this */ classprocedures: CreateEmptyRegion() returns struct region *; *** atk/basics/common/rm.c Wed Nov 22 11:49:18 1989 --- atk/basics/common/rm.c.NEW Wed Jun 13 16:53:22 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/rm.c,v 2.5 89/02/23 14:05:59 ghoti Exp $ */ /* $ACIS:rm.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/rm.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/rm.c,v 2.5 89/02/23 14:05:59 ghoti Exp $"; #endif /* lint */ #include --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/rm.c,v 2.6 90/06/04 13:38:55 gk5g Exp $ */ /* $ACIS:rm.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/rm.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/rm.c,v 2.6 90/06/04 13:38:55 gk5g Exp $"; #endif /* lint */ #include *************** *** 14,21 **** #include #include #include - extern char * malloc(); #define DEBUG_RM 1 static int debug_rm = 0; --- 14,23 ---- #include #include #include + #ifndef _IBMR2 + extern char *malloc(); + #endif /* _IBMR2 */ #define DEBUG_RM 1 static int debug_rm = 0; *** atk/basics/common/view.c Wed Apr 11 14:18:36 1990 --- atk/basics/common/view.c.NEW Thu May 10 16:24:26 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/view.c,v 2.8 90/03/22 09:26:31 ajp Exp $ */ /* $ACIS:view.c 1.5$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/view.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/view.c,v 2.8 90/03/22 09:26:31 ajp Exp $"; #endif /* lint */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/view.c,v 2.9 90/05/09 14:05:15 ajp Exp $ */ /* $ACIS:view.c 1.5$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/view.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/view.c,v 2.9 90/05/09 14:05:15 ajp Exp $"; #endif /* lint */ *************** *** 373,378 **** --- 373,388 ---- { if (self->parent != NULL) view_PostDefaultHandler(self->parent, handlerName, handler); + } + + void view__InsertViewRegion(self, parent, region) + struct view *self; + struct view *parent; + struct region *region; + { + graphic_InsertGraphicRegion(self->drawable, parent->drawable, region); + self->imPtr = parent->imPtr; + self->parent = parent; } void view__InsertView(self, parent, enclosingRectangle) *** atk/basics/common/view.ch Wed Nov 22 11:50:21 1989 --- atk/basics/common/view.ch.NEW Thu May 10 16:24:29 1990 *************** *** 2,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/view.ch,v 2.8 89/09/08 10:01:26 ghoti Exp $ */ /* $ACIS:view.ch 1.3$ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/view.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidview_H = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/basics/common/RCS/view.ch,v 2.8 89/09/08 10:01:26 ghoti Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ --- 2,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/view.ch,v 2.10 90/05/09 14:06:07 ajp Exp $ */ /* $ACIS:view.ch 1.3$ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/view.ch,v $ */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) ! static char *rcsidview_H = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/basics/common/RCS/view.ch,v 2.10 90/05/09 14:06:07 ajp Exp $"; #endif /* !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) */ *************** *** 85,90 **** --- 85,91 ---- struct atomlist * class ); PostResource( struct atomlist * path, struct atom * type, long data ); + InsertViewRegion(struct view *parent, struct region *region); InsertView(struct view * parent, struct rectangle * enclosingRect); InsertViewSize(struct view * EnclosingView, long xOriginInParent, long yOriginInParent, long width, long height); SetDataObject(struct dataobject *dataobject); *************** *** 136,141 **** --- 137,144 ---- GetLogicalWidth() (graphic_GetLogicalWidth(((self)->drawable))) GetLogicalTop() (graphic_GetLogicalTop(((self)->drawable))) + SetVisualRegion(region) (graphic_SetVisualRegion((self)->drawable, (region))) + GetVisualRegion(region) (graphic_GetVisualRegion((self)->drawable, (region))) GetVisualBounds(Rect) (graphic_GetVisualBounds((self)->drawable,(Rect))) GetVisualBoundsSize(x, y, width, height) (graphic_GetVisualBoundsSize((self)->drawable,(x),(y),(width),(height))) GetVisualRight() (graphic_GetVisualRight((self)->drawable)) *************** *** 207,212 **** --- 210,217 ---- SetLogicalOriginPt(Pt) (graphic_SetLogicalOriginPt((self)->drawable,(Pt))) + SetClippingRegion(region) (graphic_SetClippingRegion((self)->drawable, (region))) + GetClippingRegion(region) (graphic_SetClippingRegion((self)->drawable, (region))) SetClippingRect(ClipRect) (graphic_SetClippingRect((self)->drawable,(ClipRect))) SetClippingRectSize(x, y, width, height) (graphic_SetClippingRectSize((self)->drawable,(x),(y),(width),(height))) ClearClippingRect() (graphic_ClearClippingRect((self)->drawable)) *************** *** 216,221 **** --- 221,235 ---- SetLineWidth(NewLineWidth) (graphic_SetLineWidth((self)->drawable, (NewLineWidth))) GetLineWidth() (graphic_GetLineWidth((self)->drawable)) + SetLineDash( dashPattern, dashOffset, dashType ) (graphic_SetLineDash((self)->drawable, (dashPattern), (dashOffset), (dashType))) + GetLineDash() (graphic_GetLineDash((self)->drawable, (dashPattern), (dashOffset), (dashType))) + + SetLineCap(NewLineCap) (graphic_SetLineCap((self)->drawable, (NewLineCap))) + GetLineCap() (graphic_GetLineCap((self)->drawable)) + + SetLineJoin(NewLineJoin) (graphic_SetLineJoin((self)->drawable, (NewLineJoin))) + GetLineJoin() (graphic_GetLineJoin((self)->drawable)) + SetTransferMode(NewTransferMode) (graphic_SetTransferMode((self)->drawable,(NewTransferMode))) GetTransferMode() (graphic_GetTransferMode((self)->drawable)) *************** *** 224,236 **** WhitePattern() (graphic_WhitePattern((self)->drawable)) BlackPattern() (graphic_BlackPattern((self)->drawable)) GrayPattern(IntensityNum, IntensityDenom) (graphic_GrayPattern((self)->drawable,(IntensityNum),(IntensityDenom))) - ColorPattern(red, blue, green) (graphic_ColorPattern((self)->drawable, (red), (blue), (green))) ! SetForegroundColor(char *colorName, red, blue, green) (graphic_SetForegroundColor((self)->drawable, (colorName), (red), (blue), (green))) ! GetForegroundColor(retred, retblue, retgreen) (graphic_GetForegroundColor((self)->drawable,(retred), (retblue), (retgreen))) ! SetBackgroundColor(char *colorName, red, blue, green) (graphic_SetBackgroundColor((self)->drawable, (colorName), (red),(blue),(green))) ! GetBackgroundColor(retred, retblue, retgreen) (graphic_GetBackgroundColor((self)->drawable,(retred), (retblue),(retgreen))) GetHorizontalResolution() (graphic_GetHorizontalResolution((self)->drawable)) GetVerticalResolution() (graphic_GetVerticalResolution((self)->drawable)) --- 238,254 ---- WhitePattern() (graphic_WhitePattern((self)->drawable)) BlackPattern() (graphic_BlackPattern((self)->drawable)) GrayPattern(IntensityNum, IntensityDenom) (graphic_GrayPattern((self)->drawable,(IntensityNum),(IntensityDenom))) ! SetForegroundColor(char *colorName, red, green, blue) (graphic_SetForegroundColor((self)->drawable, (colorName), (red), (green), (blue))) ! GetForegroundColor(retred, retblue, retgreen) (graphic_GetForegroundColor((self)->drawable,(retred), (retgreen), (retblue))) ! SetBackgroundColor(char *colorName, red, green, blue ) (graphic_SetBackgroundColor((self)->drawable, (colorName), (red),(green),(blue))) ! GetBackgroundColor(retred, retgreen, retblue) (graphic_GetBackgroundColor((self)->drawable,(retred), (retgreen),(retblue))) + SetFGColor(red, green, blue) (graphic_SetFGColor((self)->drawable,(red),(green),(blue))) + GetFGColor(red, green, blue) (graphic_GetFGColor((self)->drawable,(red),(green),(blue))) + SetBGColor(red, green, blue) (graphic_SetBGColor((self)->drawable,(red),(green),(blue))) + GetBGColor(red, green, blue) (graphic_GetBGColor((self)->drawable,(red),(green),(blue))) + GetHorizontalResolution() (graphic_GetHorizontalResolution((self)->drawable)) GetVerticalResolution() (graphic_GetVerticalResolution((self)->drawable)) *************** *** 240,246 **** EnclosedYToLocalY(yvalue) ((yvalue)-graphic_GetEnclosedTop((self)->drawable)+graphic_GetLogicalTop((self)->drawable)) GetDataObject() ((self)->dataobject) ! classprocedures: InitializeClass() returns boolean; FinalizeObject(struct view *self); --- 258,264 ---- EnclosedYToLocalY(yvalue) ((yvalue)-graphic_GetEnclosedTop((self)->drawable)+graphic_GetLogicalTop((self)->drawable)) GetDataObject() ((self)->dataobject) ! DisplayClass() (graphic_DisplayClass((self)->drawable )) classprocedures: InitializeClass() returns boolean; FinalizeObject(struct view *self); *** atk/bush/bushv.c Wed Apr 11 14:18:47 1990 --- atk/bush/bushv.c.NEW Sat May 12 17:31:19 1990 *************** *** 3,13 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ - /* $Header $ */ - /* $Source $ */ - #ifndef lint ! static char *rcsidbushv_c = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bushv.c,v 1.45 90/03/27 14:08:09 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* --- 3,10 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ #ifndef lint ! static char *rcsidbushv_c = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bushv.c,v 1.52 90/05/12 17:29:41 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* *************** *** 36,134 **** HISTORY 08/21/85 Created (TCP) 01/15/89 Convert to ATK (GW Keim) - 05/01/89 Change aptcursors20 to aptcsr20 (TCP) - 05/19/89 Changed call to suite_WantUpdate() in PerformDetail() to - suite_Update() (GW Keim) - 05/23/89 Changed back the suite_Update() call to a WantUpdate(); - Found a NULL pointer indirection bug in - FormatEntriesItem() that manifested itself through - PerformDetail(); (GW Keim) - 05/26/89 Changed the individual ControlView item suite_Specification - delcarations to static so that Bush will compile on a VAX - for wdc@athena; (GW Keim) - 06/06/89 Added chdir() calls to set the current-working-directory - to be the current root node; - Reformated bushv_FullUdpate(); - Changed the ControlView (suite) size to be larger vertically - in order to make the button labels more visible. - As well, changed the ControlView Arrangement to Matrix - from Row; - Added check for auto-rescan possibility in - PushToEntries(). (GW Keim) - 06/11/89 Added static void HandleChangeDir() to replace calls to chdir(). - HandleChangeDir() makes a call to im_ChangeDirectory(); (GW Keim) - Tweaked the ControlView size so that no extra whitespace shows at the right - or bottom of the suite container; (GW Keim) - 06/21/89 Added code to Push() that Pop's the user back to the nodes_level if - they select a directory in the entries_level; - Added code to EntriesHitHandler() that checks to make sure that we - are still in the entries_level when we count and print the number of - selected entries; (GW Keim) - 06/21/89 Added a TitleHitHandler attribute to the ControlView that sets the - current-working-directory for the process to be the path shown in the title; - Added a static void ControlTitleHitHandler() function to be called upon hits - in the ControlView title area; (GW Keim) - 07/10/89 Set CurrEntry = NULL in PopToNodes(); this was causing the ControlView - title to erroneously be set to a filename when at the nodes_level. (GW Keim) - 07/11/89 Changed Push() to behave properly when a entries_level directory entry - is selected. - 07/14/89 Added support for mv'ing directories from the nodes_level. Added routines - StartDirMove() and FinishDirMove(). - Added instance var, MoveNode; (GW Keim) - 07/19/89 Fix for core-dump generated by the last fix (7/14) that occurred when - the user mouse clicked in the treev background; - Added PostCursor() to obviate PostWaitCursor(); - Fixed failure of second-level display to properly set the current sort-mode - during the overlay prompt for the new sort-mode; (GW Keim) - 07/28/89 Changed PushToEntries() to implement the new and better way of associating a - view/ApplicationLayer pair with a particular dataobject (entry); - Also change each occurance of AptTree to just Tree; (GW Keim) - 07/31/89 Added call to view_WantInputFocus(EntryView,EntryView) to - PushToEntry(); (GW Keim) - 08/01/89 Udpated the ControlView Title in PushToEntry(); (GW Keim) - 08/02/89 Added check for a rescan to PopToEntries(); (GW Keim) - 08/21/89 Made changes to PerformSystemAction() in an attempt to fix the bug that - causes the bush process to hang around until all its children are dead; (GW Keim) - 08/22/89 Changed PerformExit() to destroy the bushv and, if the bushv is TopLevel, - the im view. The call the exit does kill the process; (GW Keim) - 08/25/89 Fixed problem with selected state in TreeHitHandler; (GW Keim) - 09/01/89 Added support for new suite_Sort() interface to - SortBy{Name,Date,Size,Suffix,Type}; (GW Keim) - 09/08/89 Added EntryFilep instance variable to handle closing of a visited file properly - in PopToEntries(); - Changed instances of suite_ItemCaptionPlacement to - suite_ItemCaptionAlignment; - Changed DoPrint() to use ezprint; (GW Keim) - 09/29/89 Changed the EntriesView caption font to andytype12; - Gave the ControlView suite 6 more vertical pixels; - Fixed bug in PerformDestroy() that bogusly attempted to passivate destroyed - items after the PopToEntries() call already did an auto-rescan, removing those - items. This caused an occasional core dump; - Replaced a call to PopToEntries() in PushToEntry() with an assignment - Object = entries_object upon failure to open the entry; - Added assignment CurrEntry = NULL in PopToNodes; (GW Keim) - 10/24/89 Now create directories with mode 0777; - Fix for bug wherein moving a directory to a point "lower" in the filestructure - caused bogus visuals (this was a combination of a tree & bush bug; (GW Keim) - Set CurrNode to NULL when its ancestor is moved because it's destroyed - in the process; - 10/25/89 Added checks in PerformEdit, PerformExec, and PerformPrint to make sure - that in the entries_level these actions are only performed on files and - not directories; (GW Keim) ! END-SPECIFICATION ************************************************************/ ! ! #include #include #include #include - #include - #include #include - #include #include ! #include #include #include #include #include --- 33,49 ---- HISTORY 08/21/85 Created (TCP) 01/15/89 Convert to ATK (GW Keim) ! END-SPECIFICATION ******************************************************/ #include #include #include #include #include ! #include ! #include #include + #include #include #include #include *************** *** 135,171 **** #include #include #include #include #include #include #include #include - #include #include - #include #include ! #include ! #include ! #include #include #include #include ! #define by_name 0 ! #define by_size 1 ! #define by_date 2 ! #define by_suffix 3 ! #define by_type 4 ! #define nodes_object 1 ! #define entries_object 2 ! #define entry_object 4 ! static char *sorts[] = { "Name", ! "Size", ! "Date", ! "Suffix", ! "Type", NULL }; --- 50,92 ---- #include #include #include + #include #include #include #include #include #include #include #include ! #include ! #include /* tree.ih is included in bush.ih */ ! #include #include #include #include ! #define by_name 0 ! #define by_size 1 ! #define by_date 2 ! #define by_suffix 3 ! #define by_type 4 ! #define nodes_object 1 ! #define entries_object 2 ! #define entry_object 4 ! #define bushv_DefaultMenus (1<<6) ! #define bushv_EntryMenus (1<<7) ! #define bushv_RWEntryMenus (1<<8) ! ! #define DEFAULTCKPINTERVAL 120 ! int CkpInterval; ! ! static char *sorts[] = { "name", ! "size", ! "date", ! "suffix", ! "type", NULL }; *************** *** 199,206 **** PerformRename(), PerformRescan(), PerformEdit(), - PopToNodes(), - PopToEntries(), PushToEntries(), PushToEntry(), SetEditor(), --- 120,125 ---- *************** *** 209,221 **** PassivateControls(), IssueError(), ToggleDebug(), ! HandleChangeDir(); static long ControlHitHandler(), TreeHitHandler(), EntriesHitHandler(); int SortByName(), SortBySize(), SortBySuffix(), --- 128,148 ---- PassivateControls(), IssueError(), ToggleDebug(), ! HandleChangeDir(), ! Checkpoint(), ! UpdateDetailCaption(); + static int PopToNodes(), + PopToEntries(); static long ControlHitHandler(), TreeHitHandler(), EntriesHitHandler(); + static int bushv_WriteFile(), + bushv_SaveFile(), + bushv_SetPrinter(); + int SortByName(), SortBySize(), SortBySuffix(), *************** *** 229,234 **** --- 156,163 ---- #define EntryView (self->entry_view) #define EntryViewAppLayer (self->entry_view_application_layer) #define EntryObject (self->entry) + #define EntryObjectModified (self->entry_object_modified) + #define EntryObjectLastCKP (self->entry_object_last_checkpoint) #define EntryFilep (self->entry_filep) #define NumPrevSelected (self->num_prev_selected) #define LP (self->lp) *************** *** 244,250 **** #define Cursor (self->cursor) #define Detail (self->detail) #define TopLevelInset (self->top_level_inset) - #define IgnoreFullUpdate (self->ignore_fullupdate) #define Debug (self->debug) #define EditorProgram (self->editor_program) #define EditorChoices (self->editor_choices) --- 173,178 ---- *************** *** 293,331 **** #define SetTreeNotificationNode(self,node) \ tree_SetNotificationNode(Tree,node) #define SetTreeNotificationData(self,node,code) \ ! SetTreeNotificationNode(self,node);SetTreeNotificationCode(self,code) #define NotifyTreeObservers(self) \ tree_NotifyObservers(Tree,NULL) #define AllocNameSpace(s,t) apts_CaptureString(s,t) ! #define ClearFrameBuffer(self) bushv_Announce(self,"") ! static suite_Specification edit[] = { suite_ItemCaption("Edit"), ! suite_ItemDatum(6), 0 }; ! static suite_Specification exec[] = { suite_ItemCaption("Exec"), ! suite_ItemDatum(6), 0 }; ! static suite_Specification print[] = { suite_ItemCaption("Print"), ! suite_ItemDatum(7), 0 }; ! static suite_Specification editor[] = { suite_ItemCaption("Editor"), ! suite_ItemDatum(7), 0 }; ! static suite_Specification sort[] = { suite_ItemCaption("Sort"), ! suite_ItemDatum(3), 0 }; ! static suite_Specification pop[] = { suite_ItemCaption("Pop"), ! suite_ItemDatum(6), 0 }; ! static suite_Specification detail[] = { suite_ItemCaption("Detail"), ! suite_ItemDatum(3), 0 }; ! static suite_Specification destroy[] = { suite_ItemCaption("Destroy"), ! suite_ItemDatum(7), 0 }; ! static suite_Specification Switch[] = { suite_ItemCaption("Switch"), ! suite_ItemDatum(7), 0 }; ! static suite_Specification rescan[] = { suite_ItemCaption("ReScan"), ! suite_ItemDatum(7), 0 }; ! static suite_Specification create[] = { suite_ItemCaption("Create"), ! suite_ItemDatum(3), 0 }; ! static suite_Specification rename_it[] = { suite_ItemCaption("ReName"), ! suite_ItemDatum(7), 0 }; suite_Specification control_spec[] = { suite_TitleCaption( "Bush: A FileSystem Browser" ), suite_TitlePlacement( suite_Top ), --- 221,316 ---- #define SetTreeNotificationNode(self,node) \ tree_SetNotificationNode(Tree,node) #define SetTreeNotificationData(self,node,code) \ ! SetTreeNotificationNode(self,node);\ ! SetTreeNotificationCode(self,code) #define NotifyTreeObservers(self) \ tree_NotifyObservers(Tree,NULL) #define AllocNameSpace(s,t) apts_CaptureString(s,t) + #define Announce(msg_string) bushv_Announce(self,msg_string) + #define ClearMessageLine() if(!message_Asking(self)) Announce("") ! #define edit_code 1 ! #define exec_code 2 ! #define print_code 3 ! #define editor_code 4 ! #define sort_code 5 ! #define pop_code 6 ! #define detail_code 7 ! #define destroy_code 8 ! #define switch_code 9 ! #define rescan_code 10 ! #define create_code 11 ! #define rename_code 12 ! struct item_data { /* item data for the ControlView buttons */ ! long code; /* item index */ ! long activate; /* mask that determines under what state the item is active */ ! }; + static struct item_data + edit_data = {edit_code, entries_object | entry_object}, + exec_data = {exec_code, entries_object | entry_object}, + print_data = {print_code, nodes_object | entries_object | entry_object}, + editor_data = {editor_code, nodes_object | entries_object | entry_object}, + sort_data = {sort_code, nodes_object | entries_object}, + pop_data = {pop_code, entries_object | entry_object}, + detail_data = {detail_code, nodes_object | entries_object}, + destroy_data = {destroy_code, nodes_object | entries_object | entry_object}, + switch_data = {switch_code, nodes_object | entries_object | entry_object}, + rescan_data = {rescan_code, nodes_object | entries_object | entry_object}, + create_data = {create_code, nodes_object | entries_object}, + rename_data = {rename_code, nodes_object | entries_object | entry_object}; + + static suite_Specification edit[] = { + suite_ItemCaption("Edit"), + suite_ItemDatum(&edit_data), + NULL }; + static suite_Specification exec[] = { + suite_ItemCaption("Exec"), + suite_ItemDatum(&exec_data), + NULL }; + static suite_Specification print[] = { + suite_ItemCaption("Print"), + suite_ItemDatum(&print_data), + NULL }; + static suite_Specification editor[] = { + suite_ItemCaption("Editor"), + suite_ItemDatum(&editor_data), + NULL }; + static suite_Specification sort[] = { + suite_ItemCaption("Sort: name"), + suite_ItemDatum(&sort_data), + NULL }; + static suite_Specification pop[] = { + suite_ItemCaption("Pop"), + suite_ItemDatum(&pop_data), + NULL }; + static suite_Specification detail[] = { + suite_ItemCaption("Detail: off"), + suite_ItemDatum(&detail_data), + NULL }; + static suite_Specification destroy[] = { + suite_ItemCaption("Destroy"), + suite_ItemDatum(&destroy_data), + NULL }; + static suite_Specification Switch[] = { + suite_ItemCaption("Switch"), + suite_ItemDatum(&switch_data), + NULL }; + static suite_Specification rescan[] = { + suite_ItemCaption("ReScan"), + suite_ItemDatum(&rescan_data), + NULL }; + static suite_Specification create[] = { + suite_ItemCaption("Create"), + suite_ItemDatum(&create_data), + NULL }; + static suite_Specification rename_it[] = { + suite_ItemCaption("ReName"), + suite_ItemDatum(&rename_data), + NULL }; + suite_Specification control_spec[] = { suite_TitleCaption( "Bush: A FileSystem Browser" ), suite_TitlePlacement( suite_Top ), *************** *** 386,411 **** treev_Cursor( 'z' ), treev_CursorFontName( "aptcsr20" ), treev_HitHandler( TreeHitHandler ), ! NULL }; static void PostCursor( self, type ) ! struct bushv *self; ! int type; { ! struct rectangle r; ! bushv_GetVisualBounds(self,&r); ! cursor_SetStandard(Cursor,type); ! bushv_PostCursor(self,&r,Cursor); } static long ResetSelectedState( self, suite, item, datum ) ! struct bushv *self; ! struct suite *suite; ! struct suite_item *item; ! unsigned datum; /* Called by static void EntriesHitHandler(). Resets the Dir_Entry mode flag, associated with each suite_item, to correspond with the items that are currently highlighted in the suite --- 371,397 ---- treev_Cursor( 'z' ), treev_CursorFontName( "aptcsr20" ), treev_HitHandler( TreeHitHandler ), ! NULL ! }; static void PostCursor( self, type ) ! register struct bushv *self; ! register int type; { ! struct rectangle r; ! bushv_GetVisualBounds(self,&r); ! cursor_SetStandard(Cursor,type); ! bushv_PostCursor(self,&r,Cursor); } static long ResetSelectedState( self, suite, item, datum ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *item; ! register unsigned datum; /* Called by static void EntriesHitHandler(). Resets the Dir_Entry mode flag, associated with each suite_item, to correspond with the items that are currently highlighted in the suite *************** *** 412,1502 **** (entries_object). We do this after the check for Pop conditions because we need to determine the number of items previously highlighted for that check. */ { ! register struct Dir_Entry *dirEntry = NULL; ! register long int status = 0; ! if(!suite || !item) return(status); ! dirEntry = (struct Dir_Entry*)suite_ItemAttribute(suite,item,suite_ItemDatum(0)); ! if(!suite_ItemExposed(suite,item) || !suite_ItemHighlighted(suite,item) || ! !suite_ItemActivated(suite,item)) EntrySelected(dirEntry) = FALSE; ! else EntrySelected(dirEntry) = TRUE; ! return(status); } static long EntriesHitHandler( self, suite, item, object, action, x, y, numClicks ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *item; ! register long object; ! register enum view_MouseAction action; ! register long x, y, numClicks; { ! register struct Dir_Entry *dirEntry = NULL; ! register int numSelected = 0, count = 0, i = 0; ! IN(EntriesHitHandler); ! ClearFrameBuffer(self); ! if((object == suite_ItemObject) && item && ((action == view_LeftUp) || (action == view_RightUp))) { ! if(action == view_LeftUp) { ! CurrEntry = dirEntry = (struct Dir_Entry*) ! suite_ItemAttribute(EntriesView,item,suite_ItemDatum(0)); ! if(EntrySelected(dirEntry) && (NumPrevSelected == 1)) { ! PostCursor(self,Cursor_Wait); ! Push(self); ! bushv_RetractCursor(self,Cursor); ! } } - suite_Apply(suite,ResetSelectedState,self,NULL); - if(DirEntries(CurrNode)) { - count = DirEntriesCount(CurrNode); - for(i = 0 ; i < count ; i++) - if(DirEntryMode(CurrNode,i).selected) numSelected++; - } - NumPrevSelected = numSelected; - if(Object == entries_object) { /* may have Pop'ed back to nodes */ - if((numSelected > 1) || (numSelected == 0)) - sprintf(msg,"%d entries currently selected",numSelected); - else sprintf(msg,"1 entry selected"); - bushv_Announce(self,msg); - } } ! OUT(EntriesHitHandler); ! return(0); } static void StartDirMove( self, tn ) ! struct bushv *self; ! tree_type_node tn; { ! IN(StartDirMove); ! if(tn) { ! PostCursor(self,Cursor_Gunsight); ! sprintf(msg,"Moving directory '%s'...",DirName(tn)); ! bushv_Announce(self,msg); ! } ! else bushv_Announce(self,"No selected directory to move."); ! OUT(StartDirMove); } static int FinishDirMove( self, tn ) ! register struct bushv *self; ! register tree_type_node tn; { ! register int status = 0; ! char finalLocation[MAXPATHLEN]; ! IN(FinishDirMove); ! PostCursor(self,Cursor_Wait); ! if(!MoveNode) status = -1; ! else if(!tn) { ! sprintf(msg,"No target selected. Move operation cancelled."); ! bushv_Announce(self,msg); ! status = -1; } - else if(tn == MoveNode) { - sprintf(msg,"Cancelled."); - bushv_Announce(self,msg); - status = -1; - } - else if(tree_NodeAncestor(Tree,MoveNode,tn)) { - sprintf(msg,"You cannot move a directory to one of its children."); - bushv_Announce(self,msg); - status = -1; - } - else if(tn == Parent(MoveNode)) { - sprintf(msg,"'%s' already lives under '%s'", - DirName(MoveNode),DirName(tn)); - bushv_Announce(self,msg); - status = -1; - } else { ! sprintf(msg,"Moving '%s' under '%s'",DirName(MoveNode), ! DirName(tn)); ! bushv_Announce(self,msg); ! sprintf(finalLocation,"%s/%s",DirPath(tn), ! DirName(MoveNode)); ! if(status = rename(DirPath(MoveNode),finalLocation)) { ! IssueError(self,"Moving",DirName(MoveNode),TRUE); ! sprintf(msg,"Move failed."); ! bushv_Announce(self,msg); ! } ! else { ! if(tree_NodeLevel(Tree,CurrNode) >= ! tree_NodeLevel(Tree,MoveNode)) CurrNode = NULL; ! SetTreeNotificationData(self,MoveNode,tree_NodeDestroyed); ! NotifyTreeObservers(self); ! tree_DestroyNode(Tree,MoveNode); ! sprintf(msg,"Move succeeded."); ! bushv_Announce(self,msg); ! } } ! bushv_RetractCursor(self,Cursor); ! OUT(FinishDirMove); ! return(status); } static long TreeHitHandler( self, tree_view, node, object, action, x, y, numClicks ) ! register struct bushv *self; ! register struct treev *tree_view; ! register tree_type_node node; ! register long object; ! register enum view_MouseAction action; ! register long x, y, numClicks; { ! register tree_type_node old_CurrNode = NULL; ! register tree_type_node peer = NULL; ! struct stat stats; ! IN(TreeHitHandler); ! if(object == treev_NodeObject) { ! if(node) treev_HighlightNode(tree_view,node); ! if(action == view_RightDown) { ! MoveNode = node; ! StartDirMove(self,node); ! return 0; } ! else if(action == view_RightUp) { ! if(FinishDirMove(self,node)) { ! treev_HighlightNode(tree_view,CurrNode); ! MoveNode = NULL; ! return 0; ! } ! MoveNode = NULL; ! DirMode(node).do_rescan = TRUE; ! } ! else if(action != view_LeftUp || !node) return 0; ! ClearFrameBuffer(self); ! PostCursor(self,Cursor_Wait); ! if(stat(DirPath(node),&stats)) { ! DirMode(node).stat_failed = TRUE; ! IssueError(self,"Scanning",DirName(node),TRUE); ! bushv_RetractCursor(self,Cursor); ! return 0; ! } ! old_CurrNode = CurrNode; ! CurrNode = node; ! if(Parent(CurrNode)) peer = Child(Parent(CurrNode)); ! else peer = CurrNode; ! if(!DirMode(CurrNode).selected || (action == view_RightUp)) { ! if(old_CurrNode) { ! DirMode(old_CurrNode).selected = FALSE; ! old_CurrNode = NULL; ! } ! while(peer) { ! if(Child(peer)) { ! SetTreeNotificationData(self,peer, ! tree_NodeChildrenDestroyed); ! NotifyTreeObservers(self); ! bush_DestroySubDirs(Bush,peer); ! break; ! } ! peer = Right(peer); ! } ! DirMode(CurrNode).selected = TRUE; ! if(ScanRequired(CurrNode)) { ! sprintf(msg,"Scanning '%s' ...",DirName(CurrNode)); ! bushv_Announce(self,msg); ! im_WantUpdate(bushv_GetIM(self),self); ! bush_ScanDir(Bush,CurrNode); ! ClearFrameBuffer(self); ! } ! bush_BuildSubDirs(Bush,CurrNode); ! SetTreeNotificationData(self,CurrNode,tree_NodeChildrenCreated); ! NotifyTreeObservers(self); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! } ! else Push(self); ! bushv_RetractCursor(self,Cursor); } ! OUT(TreeHitHandler); ! return(0); } static long ControlHitHandler( self, suite, item, object, action, x, y, numClicks ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *item; ! register long object; ! register enum view_MouseAction action; ! register long x, y, numClicks; { - IN(ControlHitHandler); ! ClearFrameBuffer(self); ! if((action == view_LeftUp) || (action == view_RightUp)) { ! if(object == suite_ItemObject){ ! register char *caption = (char*) ! suite_ItemAttribute(suite,item,suite_ItemCaption(0)); ! if(!strcmp(caption,"Edit")) PerformEdit(self); ! else if(!strcmp(caption,"Exec")) PerformExec(self); ! else if(!strcmp(caption,"Print")) PerformPrint(self); ! else if(!strcmp(caption,"Sort")) PerformSort(self); ! else if(!strcmp(caption,"Destroy")) PerformDestroy(self); ! else if(!strcmp(caption,"ReScan")) PerformRescan(self); ! else if(!strcmp(caption,"Create")) PerformCreate(self); ! else if(!strcmp(caption,"Exit")) PerformExit(self); ! else if(!strcmp(caption,"Pop")) PerformPop(self); ! else if(!strcmp(caption,"Detail")) PerformDetail(self); ! else if(!strcmp(caption,"ReName")) PerformRename(self); ! else if(!strcmp(caption,"Editor")) SetEditor(self); ! else if(!strcmp(caption,"Switch")) SwitchDirectory(self); ! PassivateControls(self); } ! else if(object == suite_TitleObject) { ! suite_HighlightTitle(suite); ! PostCursor(self,Cursor_Wait); ! HandleChangeDir(self,DirPath(CurrNode)); ! sleep(1); ! bushv_RetractCursor(self,Cursor); ! sprintf(msg,"Working directory changed to '%s'", ! DirPath(CurrNode)); ! bushv_Announce(self,msg); ! suite_NormalizeTitle(suite); ! } ! else if(object == suite_NoObject) { ! PassivateControls(self); ! if(suite_CurrentItem(suite)) ! suite_PassivateItem(suite,suite_CurrentItem(suite)); ! } } ! OUT(ControlHitHandler); ! return(0); } static char * FileSuffix( file_name ) ! register char *file_name; { ! register char *suffix; ! if(suffix = (char*)rindex(file_name,'.')) suffix++; ! else suffix = file_name + strlen(file_name); ! return(suffix); } static char * FileType( file_name ) ! register char *file_name; { ! static char *suffixes[] = {"BAK","CKP",0}; ! register char *suffix, **suffix_ptr; ! suffix = (char*)rindex(file_name,'.'); ! if(!suffix) return(file_name + strlen(file_name)); ! suffix++; ! suffix_ptr = suffixes; ! while(*suffix_ptr) { ! if(!strcmp(suffix,*suffix_ptr)) { ! *(suffix-1) = '\0'; ! return(FileSuffix(file_name)); ! } ! suffix_ptr++; } ! return(suffix); } int SortByName( self, suite, e1, e2 ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *e1,*e2; { ! register struct Dir_Entry *a = NULL, *b = NULL; ! register long status = 0; ! if(!e1 || !e2) return(0); ! a = (struct Dir_Entry*)suite_ItemAttribute(suite,e1,suite_ItemDatum(0)); ! b = (struct Dir_Entry*)suite_ItemAttribute(suite,e2,suite_ItemDatum(0)); ! if(a && b) { ! status = strcmp(a->name,b->name); ! if(status < 0) return(-1); ! else if(status > 0) return(1); ! } ! return(0); } int SortBySuffix( self, suite, e1, e2 ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *e1,*e2; { ! register struct Dir_Entry *a = NULL, *b = NULL; ! register long rc; ! ! if(!e1|| !e2) return(0); ! a = (struct Dir_Entry*)suite_ItemAttribute(suite,e1,suite_ItemDatum(0)); ! b = (struct Dir_Entry*)suite_ItemAttribute(suite,e2,suite_ItemDatum(0)); ! if(a && b) ! if(!(rc = strcmp(FileSuffix(a->name),FileSuffix(b->name)))) { ! rc = strcmp(a->name,b->name); ! if(rc > 0) return(1); ! else if(rc < 0) return(-1); ! } ! else { ! if(rc > 0) return(1); ! else if(rc < 0) return(-1); ! } ! return(0); } int SortBySize( self, suite, e1, e2 ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *e1,*e2; { ! register struct Dir_Entry *a = NULL, *b = NULL; ! if(!e1 || !e2) return(0); ! a = (struct Dir_Entry*)suite_ItemAttribute(suite,e1,suite_ItemDatum(0)); ! b = (struct Dir_Entry*)suite_ItemAttribute(suite,e2,suite_ItemDatum(0)); ! if(a && b) { ! if(a->size < b->size) return(1); ! else if(a->size > b->size) return(-1); ! } ! return(0); } int SortByDate( self, suite, e1, e2 ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *e1,*e2; { ! register struct Dir_Entry *a = NULL, *b = NULL; ! if(!e1 || !e2) return(0); ! a = (struct Dir_Entry*)suite_ItemAttribute(suite,e1,suite_ItemDatum(0)); ! b = (struct Dir_Entry*)suite_ItemAttribute(suite,e2,suite_ItemDatum(0)); ! if(a && b) { ! if(a->time_stamp < b->time_stamp) return(1); ! if(a->time_stamp > b->time_stamp) return(-1); ! } ! return(0); } int SortByType( self, suite, e1, e2 ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *e1,*e2; { ! register struct Dir_Entry *a = NULL, *b = NULL; ! char n1[MAXPATHLEN+1], n2[MAXPATHLEN+1]; ! register long rc; ! if(!e1 || !e2) return(0); ! a = (struct Dir_Entry*)suite_ItemAttribute(suite,e1,suite_ItemDatum(0)); ! b = (struct Dir_Entry*)suite_ItemAttribute(suite,e2,suite_ItemDatum(0)); ! if(a && b) { ! strcpy(n1,a->name); ! strcpy(n2,b->name); ! if(!(rc = strcmp(FileType(n1),FileType(n2)))) { ! rc = strcmp(a->name,b->name); ! if(rc < 0) return(-1); ! else if(rc > 0) return(1); ! } ! else { ! if(rc < 0) return(-1); ! else if(rc > 0) return(1); ! } } ! return(0); } boolean bushv__InitializeClass( ClassID ) ! struct classheader *ClassID; { ! struct proctable_Entry *tempProc = NULL; ! kmap = keymap_New(); ! menulist = menulist_New(); ! tempProc = proctable_DefineProc("bushv-exit",PerformExit, ! &bushv_classinfo,NULL,"Exit Bush."); ! menulist_AddToML(menulist,"Quit~70",tempProc,NULL,NULL); ! proctable_DefineProc("bushv-DEBUG",ToggleDebug, ! &bushv_classinfo,NULL,"Toggle Bush debug flag."); ! proctable_DefineProc("bushv-pop",PerformPop, ! &bushv_classinfo,NULL,"Pop up a level."); ! proctable_DefineProc("bushv-switch",SwitchDirectory, ! &bushv_classinfo,NULL,"Switch to a new directory."); ! proctable_DefineProc("bushv-rescan",PerformRescan, ! &bushv_classinfo,NULL,"Rescan the current directory."); ! proctable_DefineProc("bushv-destroy",PerformDestroy, ! &bushv_classinfo,NULL,"Destroy the current directory/files."); ! return(TRUE); } static void GetPreferredEditors( self ) ! struct bushv *self; { ! register char *tmp = NULL, *colon = NULL; ! char *myCopy = NULL; ! register int i = 0; ! IN(GetPreferredEditors); ! environ_SetProgramName("bush"); ! if(((tmp = environ_GetProfile("editors")) || ! (tmp = environ_GetProfile("editor"))) && *tmp) { ! AllocNameSpace(tmp,&myCopy); ! if(colon = (char*)index(tmp = myCopy,':')) { ! while((colon = (char*)index(tmp,':')) && (i < MAXEDITORS)) { ! *colon = '\0'; ! if(tmp && (*tmp != '\0')) { ! EditorChoices[i] = NULL; ! AllocNameSpace(tmp,&EditorChoices[i++]); ! } ! tmp = colon + 1; ! } ! if(tmp && (*tmp != '\0') && (i < MAXEDITORS)) { ! EditorChoices[i] = NULL; ! AllocNameSpace(tmp,&EditorChoices[i]); ! EditorChoices[i+1] = NULL; ! } ! else if(i >= MAXEDITORS) ! fprintf(stderr,"bush: too many editors in preference.\n"); ! } ! else if(tmp && (*tmp != '\0')) { ! EditorChoices[i] = NULL; ! AllocNameSpace(myCopy,&EditorChoices[i]); ! EditorChoices[i+1] = NULL; ! } ! i++; ! AllocNameSpace("other",&EditorChoices[i]); ! EditorChoices[i+1] = NULL; ! NumEditorChoices = i+1; ! if(myCopy) free(myCopy); ! } ! else if(!tmp || (i == 0)) { ! for( i = 0 ; default_editor_choices[i] && (i < MAXEDITORS); i++ ) { ! EditorChoices[i] = NULL; ! AllocNameSpace(default_editor_choices[i],&EditorChoices[i]); } ! EditorChoices[i] = NULL; ! NumEditorChoices = i; } ! EditorIndex = 0; ! strcpy(EditorProgram,EditorChoices[0]); ! OUT(GetPreferredEditors); } static void GetPreferredFont( self ) ! struct bushv *self; { ! register char *tmp = NULL; ! IN(GetPreferredFont); ! if((tmp = environ_GetProfile("bodyfont")) && *tmp) { ! suite_SetSuiteAttribute(ControlView, ! suite_TitleFontName( tmp )); ! suite_SetSuiteAttribute(ControlView,suite_TitleCaptionFontHigh(0)); ! suite_SetSuiteAttribute(ControlView, ! suite_ItemCaptionFontName( tmp )); ! suite_SetSuiteAttribute(ControlView,suite_ItemCaptionFontHigh(0)); ! suite_SetSuiteAttribute(EntriesView,suite_TitleFontName( tmp )); ! suite_SetSuiteAttribute(EntriesView,suite_TitleCaptionFontHigh(0)); ! suite_SetSuiteAttribute(EntriesView,suite_ItemCaptionFontName( tmp )); ! suite_SetSuiteAttribute(EntriesView,suite_ItemCaptionFontHigh(0)); ! } ! OUT(GetPreferredFont); } static void GetPreferences( self ) ! struct bushv *self; { ! IN(GetPreferences); ! GetPreferredEditors(self); ! GetPreferredFont(self); ! OUT(GetPreferences); } boolean bushv__InitializeObject( ClassID, self ) ! struct classheader *ClassID; ! struct bushv *self; { ! Kmap = kmap; ! if(!(Kstate = keystate_Create(self,Kmap))) { ! fprintf(stderr,"bushv: could not create keystate.\n"); ! exit(1); ! } ! Cursor = cursor_Create(self); ! cursor_SetStandard(Cursor,Cursor_Wait); ! Bush = NULL; ! CurrNode = InitNode = MoveNode = NULL; ! CurrEntry = NULL; ! EntryView = EntryViewAppLayer = NULL; ! EntryObject = NULL; ! EntryFilep = NULL; ! ControlView = suite_Create(control_spec,self); ! EntriesView = suite_Create(entries_spec,self); ! DirTreeView = treev_Create(tree_spec,self); ! LP = lpair_New(); ! lpair_VTFixed(LP,(struct view*)ControlView,(struct view*)DirTreeView,95,TRUE); ! lpair_LinkTree(LP,(struct view*)self); ! Object = nodes_object; ! SortMode = 0; ! Detail = 0; ! NumPrevSelected = 0; ! Debug = 1; ! Menulist = menulist_DuplicateML(menulist,self); ! GetPreferences(self); ! bushv_SetOptions(self,aptv_SuppressControl | aptv_SuppressBorder); ! TopLevelInset = TRUE; ! IgnoreFullUpdate = FALSE; ! OUT(bushv_InitializeObject); ! return(TRUE); ! } void bushv__FinalizeObject( ClassID, self ) ! struct classheader *ClassID; ! struct bushv *self; { ! IN(bushv_FinalizeObject); ! if(LP) lpair_Destroy(LP); ! if(ControlView) suite_Destroy(ControlView); ! if(EntriesView) suite_Destroy(EntriesView); ! if(DirTreeView) treev_Destroy(DirTreeView); ! if(EntryView) view_Destroy(EntryView); ! if(EntryObject) dataobject_Destroy(EntryObject); ! OUT(bushv_FinalizeObject); } struct bushv * bushv__Create( ClassID, object ) ! struct classheader *ClassID; ! char object; { ! struct bushv *self = NULL; ! if(self = bushv_New()) Object = object; ! OUT(bushv_Create); ! return(self); } void bushv__PostMenus( self, menulist ) ! struct bushv *self; ! struct menulist *menulist; { ! IN(bushv_PostMenus); ! menulist_ClearChain(Menulist); ! if(menulist) menulist_ChainBeforeML(Menulist,menulist,NULL); ! super_PostMenus(self,Menulist); ! OUT(bushv_PostMenus); } struct view * bushv__Hit( self, action, x, y, numberOfClicks ) ! struct bushv *self; ! enum view_MouseAction action; ! long x, y, numberOfClicks; { ! IN(bushv_Hit); ! return(lpair_Hit(LP,action,x,y,numberOfClicks)); } void bushv__FullUpdate( self, Type, left, top, width, height ) ! struct bushv *self; ! enum view_UpdateType Type; ! long left, top, width, height; { ! struct rectangle r; ! char RootPathIfInset[MAXPATHLEN]; ! char NewTitle[MAXPATHLEN]; ! IN(bushv_FullUpdate); ! if(!IgnoreFullUpdate && ! (Type == view_LastPartialRedraw || Type == view_FullRedraw)) { ! super_FullUpdate(self,Type,left,top,width,height); ! if(!RootPathName) { ! im_GetDirectory(RootPathIfInset); ! bush_InitTree(Bush,RootPathIfInset); ! CurrNode = InitNode = TreeRoot; ! bush_BuildSubDirs(Bush,TreeRoot); ! HandleChangeDir(self,RootPathName); ! } ! bushv_GetVisualBounds(self,&r); ! bushv_SetTransferMode(self,graphic_WHITE); ! bushv_FillRect(self,&r,bushv_WhitePattern(self)); ! lpair_InsertView(LP,(struct view*)self,&r); ! bushv_SetTransferMode(self,graphic_BLACK); ! lpair_FullUpdate(LP,Type,0,0,r.width,r.height); ! if(CurrNode || (CurrNode = treev_CurrentNode(DirTreeView))) { ! sprintf(NewTitle,"%s%s%s",DirPath(CurrNode), ! CurrEntry ? "/" : "", CurrEntry ? CurrEntry->name : ""); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(NewTitle)); ! } ! else ! suite_ChangeSuiteAttribute(ControlView,"No Current Directory"); ! PassivateControls(self); ! ClearFrameBuffer(self); } ! IgnoreFullUpdate = false; ! if(Object == nodes_object) ! treev_WantInputFocus(DirTreeView,DirTreeView); ! OUT(bushv_FullUpdate); } static void DoEdit( self, path, name ) ! struct bushv *self; ! char *path, *name; { ! char full_path[MAXPATHLEN * 2]; ! IN(DoEdit); ! sprintf(full_path,"%s/%s",path,name); ! sprintf(msg,"%s '%s/%s'",EditorProgram,path,name); ! argv[0] = EditorProgram; ! argv[1] = full_path; ! argv[2] = NULL; ! PerformSystemAction(self,EditorProgram,argv,msg); ! OUT(DoEdit); } static void PerformEdit( self ) ! struct bushv *self; { ! register int i = 0; ! IN(PerformEdit); ! if(!CurrEntry) return; ! PostCursor(self,Cursor_Wait); ! switch(Object) { ! case nodes_object: ! break; ! case entries_object: ! if(CurrNode && DirEntries(CurrNode) && ! (DirEntriesCount(CurrNode) >= 0)) ! for(i=0;iname); ! break; ! } ! bushv_RetractCursor(self,Cursor); ! OUT(PerformEdit); } static void PerformPrint( self ) ! struct bushv *self; { ! register int i = 0; ! register FILE *file = NULL; ! IN(PerformPrint); ! PostCursor(self,Cursor_Wait); ! switch(Object) { ! case nodes_object: ! if(file = fopen("/tmp/bush_print.PS","w")) { ! treev_Print(DirTreeView,file,"postscript","postscript",1); ! fclose(file); ! system("print -Tnative /tmp/bush_print.PS"); ! sprintf(msg,"Printed '%s'",RootPathName); ! bushv_Announce(self,msg); ! } ! else bushv_Announce(self,"Error Printing"); ! break; ! case entries_object: ! for(i=0;i < DirEntriesCount(CurrNode);i++) ! if(DirEntryMode(CurrNode,i).selected && ! !DirEntryType(CurrNode,i).dir) ! DoPrint(self,DirPath(CurrNode), ! DirEntryName(CurrNode,i)); ! break; ! case entry_object: ! DoPrint(self,DirPath(CurrNode),CurrEntry->name); ! break; ! } ! bushv_RetractCursor(self,Cursor); ! OUT(PerformPrint); } static DoPrint( self, path, name ) ! struct bushv *self; ! char *path, *name; { ! char full_path[MAXPATHLEN * 2], *ext = NULL; ! int i = 0; ! IN(DoPrint); ! sprintf(full_path,"%s/%s",path,name); ! sprintf(msg,"Printing '%s'",full_path); ! if((ext = rindex(name,'.')) != NULL) { ! ext++; ! argv[i++] = "print"; ! argv[i++] = "-T"; ! if(!strcmp(ext,"ps")) argv[i++] = "native"; ! else if(!strcmp(ext,"ras")) argv[i++] = "raster"; ! else if(!strcmp(ext,"dvi")) argv[i++] = "dvi"; ! else { ! i = 0; ! argv[i++] = "ezprint"; ! } } ! else argv[i++] = "ezprint"; ! argv[i++] = full_path; ! argv[i] = NULL; ! PerformSystemAction(self,argv[0],argv,msg); ! OUT(DoPrint); } static void PerformCreate( self ) ! struct bushv *self; { ! register int f = 0; ! char *response = NULL; ! IN(PerformCreate); ! if(!CurrNode) return; ! switch(Object) { ! case nodes_object: ! if(bushv_Query(self,"Directory Name: ","",&response)) return; ! sprintf(cmd,"%s/%s",DirPath(CurrNode),response); ! if(mkdir(cmd,0777)) { ! IssueError(self,"Creating",response,TRUE); ! return; ! } ! else PerformRescan(self); ! break; ! case entries_object: ! if(bushv_Query(self,"File Name: ","",&response)) return; ! sprintf(cmd,"%s/%s",DirPath(CurrNode),response); ! if((f = open(cmd,O_CREAT | O_EXCL, 0100 | 0200 | 0400)) < 0) { ! IssueError(self,"Creating",response,TRUE); ! return; ! } ! else { ! close(f); ! PerformRescan(self); ! } ! break; ! case entry_object: ! break; ! } ! OUT(PerformCreate); } static void IssueError( self, what, where, overlay ) ! register struct bushv *self; ! register char *what, *where; ! boolean overlay; { ! int result = 0; ! static char *question[] = {"Continue",NULL}; ! IN(IssueError); ! if(errno <= sys_nerr) sprintf(msg,"ERROR %s '%s': %s",what,where,sys_errlist[errno]); ! else sprintf(msg,"ERROR %s '%s': (Invalid System Error-code '%d')",what,where,errno); ! if(overlay) message_MultipleChoiceQuestion(self,100,msg,0,&result,question,NULL); ! else bushv_Announce(self,msg); ! OUT(IssueError); } static int DoDestroy( self, tn, Entry, overlay ) ! register struct bushv *self; ! register tree_type_node tn; ! register struct Dir_Entry *Entry; ! boolean overlay; { ! register int status = 0; ! IN(DoDestroy); ! if(self && tn && Entry) { ! if(status = bush_DestroyEntry(Bush,tn,Entry)) ! IssueError(self,"Destroying",Entry->name,overlay); ! } ! OUT(DoDestroy); ! return(status); } static void PerformDestroy( self ) ! struct bushv *self; { ! static char *question[] = {"Confirm","Cancel",0}; ! register int i = 0; ! long result = 0; ! int count = 0; ! register struct Dir_Entry *Dir_Entry = NULL, *current_entry = CurrEntry; ! register tree_type_node current_node = CurrNode, tn = NULL; ! register struct suite_item **selected = NULL; ! IN(PerformDestroy); ! if(!current_node) return; ! switch(self->object) { ! case nodes_object: ! if(tn = Parent(current_node)) { ! for(i=0;i 0)){ ! sprintf(msg,"'%s' has contents. Destroy Anyway?", ! DirName(current_node)); ! if(message_MultipleChoiceQuestion(self,100,msg, ! 1,&result,question,NULL) == -1) return; ! if(result != 0) { ! bushv_Announce(self,"Cancelled"); ! return; ! } ! } ! if(result == 0) { ! PostCursor(self,Cursor_Wait); ! if(DoDestroy(self,Parent(current_node), ! Dir_Entry,TRUE)) { ! bushv_RetractCursor(self,Cursor); ! return; ! } ! CurrNode = Parent(current_node); ! treev_HighlightNode(DirTreeView,CurrNode); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! bushv_RetractCursor(self,Cursor); ! PerformRescan(self); ! sprintf(msg,"Destroyed Node '%s'",Dir_Entry->name); ! bushv_Announce(self,msg); ! } ! } ! else bushv_Announce(self,"Node Not Found in Parent"); } ! else bushv_Announce(self,"May Not Destroy Root Directory"); ! break; ! case entries_object: ! selected = suite_SelectedItems(EntriesView,&count); ! if(count == 0) break; ! if(count > 1) ! if(count == 2) sprintf(msg,"Destroy Both Items ?"); ! else sprintf(msg,"Destroy All %d Items ?",count); ! else { ! Dir_Entry = (struct Dir_Entry*) ! suite_ItemAttribute(EntriesView,selected[0],suite_ItemDatum(0)); ! sprintf(msg,"Destroy %s '%s' ?",EntryDirType(Dir_Entry) ! ? "Node" : "",Dir_Entry->name); } ! if(message_MultipleChoiceQuestion(self,100,msg,1, ! &result,question,NULL) == -1) return; ! if(result == 0) { ! PostCursor(self,Cursor_Wait); ! for( i = 0 ; i < count ; i++ ) { ! Dir_Entry = (struct Dir_Entry*) ! suite_ItemAttribute(EntriesView,selected[i],suite_ItemDatum(0)); ! if(!DoDestroy(self,current_node,Dir_Entry,TRUE)) { ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! suite_PassivateItem(EntriesView,selected[i]); ! EntrySelected(Dir_Entry) = FALSE; ! } ! } ! bushv_RetractCursor(self,Cursor); } ! else bushv_Announce(self,"Canceled"); ! break; ! case entry_object: ! if(current_entry) { ! selected = suite_SelectedItems(EntriesView,&count); ! if(EntryDirType(current_entry)) ! sprintf(msg,"Destroy Directory '%s'?",current_entry->name); ! else sprintf(msg,"Destroy '%s'?",current_entry->name); ! if(message_MultipleChoiceQuestion(self,100,msg,1, &result,question,NULL) == -1) return; ! if(result==0) { ! PostCursor(self,Cursor_Wait); ! if(!DoDestroy(self,current_node,current_entry,TRUE)) { ! CurrEntry = NULL; ! PerformPop(self); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! } ! bushv_RetractCursor(self,Cursor); ! } } ! else bushv_Announce(self,"Canceled"); ! break; ! } ! OUT(PerformDestroy); } static void PerformExec( self ) ! struct bushv *self; { ! register int i = 0; ! IN(PerformExec); ! if(!CurrEntry) return; ! PostCursor(self,Cursor_Wait); ! switch(Object) { ! case nodes_object: break; ! case entries_object: ! if(CurrNode && DirEntries(CurrNode) && ! (DirEntriesCount(CurrNode) >= 0)) ! for(i = 0;i < DirEntriesCount(CurrNode);i++) ! if(DirEntryMode(CurrNode,i).selected && ! !DirEntryType(CurrNode,i).dir) ! DoExecute(self,CurrNode,DirEntry(CurrNode,i)); ! break; ! case entry_object: ! DoExecute(self,CurrNode,CurrEntry); ! break; ! } ! bushv_RetractCursor(self,Cursor); ! OUT(PerformExec); } static DoExecute( self, tn, Entry ) ! struct bushv *self; ! tree_type_node tn; ! struct Dir_Entry *Entry; { ! char full_path[MAXPATHLEN * 2]; ! IN(DoExecute); ! sprintf(full_path,"%s/%s",DirPath(tn),Entry->name); ! sprintf(msg,"Executing '%s'",full_path); ! argv[0] = full_path; ! argv[1] = NULL; ! PerformSystemAction(self,full_path,argv,msg); ! OUT(DoExecute); } static int PerformSystemAction( self, name, argv, msg ) ! struct bushv *self; ! char *name; ! char *argv[]; ! char *msg; { ! bushv_Announce(self,msg); ! return(bush_PerformSystemAction(Bush,name,argv)); } static char* Format_Tags( tag ) ! u_short tag; { ! static char tags[11]; ! strcpy(tags,"----------"); ! if((tag & S_IFMT) == S_IFREG) tags[0] = '-'; ! else if((tag & S_IFMT) == S_IFDIR) tags[0] = 'd'; ! else if((tag & S_IFMT) == S_IFCHR) tags[0] = 'c'; ! else if((tag & S_IFMT) == S_IFBLK) tags[0] = 'b'; ! else if((tag & S_IFMT) == S_IFLNK) tags[0] = 'l'; #ifdef S_IFIFO ! else if((tag & S_IFMT) == S_IFIFO) tags[0] = '?'; #endif /* #ifdef S_IFIFO */ #ifdef S_IFSOCK ! else if((tag & S_IFMT) == S_IFSOCK) tags[0] = '?'; #endif /* #ifdef S_IFSOCK */ ! if(tag & S_IREAD) tags[1] = 'r'; ! if(tag & S_IWRITE) tags[2] = 'w'; ! if(tag & S_IEXEC) tags[3] = 'x'; ! if(tag & (S_IREAD >>3)) tags[4] = 'r'; ! if(tag & (S_IWRITE>>3)) tags[5] = 'w'; ! if(tag & (S_IEXEC >>3)) tags[6] = 'x'; ! if(tag & (S_IREAD >>6)) tags[7] = 'r'; ! if(tag & (S_IWRITE>>6)) tags[8] = 'w'; ! if(tag & (S_IEXEC >>6)) tags[9] = 'x'; ! tags[10] = '\0'; ! return(tags); } static char* FormatEntriesItem( self, tn, i, dirEntry ) ! register struct bushv *self; ! tree_type_node tn; ! int i; ! struct Dir_Entry *dirEntry; { ! static char entries_item[257], trailer[5]; ! register char *entries_ptr = NULL, *time_ptr = NULL; ! IN(FormatEntriesItem); ! if(tn) { ! if(!DirEntryType(tn,i).soft_link && DirEntryType(tn,i).dir) ! strcpy(trailer,"/"); ! else if(DirEntryType(tn,i).soft_link && ! ((DirDetail(CurrNode) == 1) || ! ((DirDetail(CurrNode) == -1) && Detail))) ! strcpy(trailer," -> "); ! else if(DirEntryPerms(tn,i) & S_IEXEC) strcpy(trailer,"*"); ! else trailer[0] = '\0'; ! if((DirDetail(tn) == 1) || ((DirDetail(tn) == -1) && Detail)) { ! time_ptr = (char*) ctime(&DirEntryTimeStamp(tn,i)); ! time_ptr[24] = '\0'; ! sprintf(entries_item,"%s %2d %8s %8d %s %s%s%s", ! Format_Tags(DirEntryPerms(tn,i)), ! DirEntryNLinks(tn,i),DirEntryOwner(tn,i), ! DirEntrySize(tn,i),time_ptr,DirEntryName(tn,i), ! trailer, DirEntryType(tn,i).soft_link ? DirEntryLinkName(tn,i) : ""); ! } ! else sprintf(entries_item,"%s%s",DirEntryName(tn,i),trailer); ! entries_ptr = entries_item; } ! else if(dirEntry) { ! if(!EntryLinkType(dirEntry) && EntryDirType(dirEntry)) strcpy(trailer,"/"); ! else if(EntryLinkType(dirEntry) && ! ((DirDetail(CurrNode) == 1) || ! ((DirDetail(CurrNode) == -1) && Detail))) ! strcpy(trailer," -> "); ! else if(EntryPerms(dirEntry) & S_IEXEC) strcpy(trailer,"*"); ! else trailer[0] = '\0'; ! if((DirDetail(CurrNode) == 1) || ! ((DirDetail(CurrNode) == -1) && Detail)) { ! time_ptr = (char*) ctime(&dirEntry->time_stamp); ! time_ptr[24] = '\0'; ! sprintf(entries_item,"%s %2d %8s %8d %s %s%s%s", ! Format_Tags(dirEntry->permissions), ! dirEntry->nlinks,dirEntry->owner, ! dirEntry->size,time_ptr,dirEntry->name, ! trailer, EntryLinkType(dirEntry) ? EntryLinkName(dirEntry) : ""); ! } ! else sprintf(entries_item,"%s%s",dirEntry->name,trailer); ! entries_ptr = entries_item; } ! OUT(FormatEntriesItem); ! return(entries_ptr); } static void --- 398,1526 ---- (entries_object). We do this after the check for Pop conditions because we need to determine the number of items previously highlighted for that check. */ { ! register struct Dir_Entry *dirEntry = NULL; ! register long int status = 0; ! if(!suite || !item) return(status); ! dirEntry = (struct Dir_Entry*) ! suite_ItemAttribute(suite,item,suite_ItemDatum(0)); ! if(!suite_ItemExposed(suite,item) || ! !suite_ItemHighlighted(suite,item) || ! !suite_ItemActivated(suite,item)) EntrySelected(dirEntry) = FALSE; ! else EntrySelected(dirEntry) = TRUE; ! return(status); } static long EntriesHitHandler( self, suite, item, object, action, x, y, numClicks ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *item; ! register long object; ! register enum view_MouseAction action; ! register long x, y, numClicks; { ! register struct Dir_Entry *dirEntry = NULL; ! register int numSelected = 0, count = 0, i = 0; ! IN(EntriesHitHandler); ! ClearMessageLine(); ! if((object == suite_ItemObject) && item && ((action == view_LeftUp) || (action == view_RightUp))) { ! if(action == view_LeftUp) { ! CurrEntry = dirEntry = (struct Dir_Entry*) ! suite_ItemAttribute(EntriesView,item,suite_ItemDatum(0)); ! if(EntrySelected(dirEntry) && (NumPrevSelected == 1)) { ! PostCursor(self,Cursor_Wait); ! Push(self); ! bushv_RetractCursor(self,Cursor); } } ! suite_Apply(suite,ResetSelectedState,self,NULL); ! if(DirEntries(CurrNode)) { ! count = DirEntriesCount(CurrNode); ! for(i = 0 ; i < count ; i++) ! if(DirEntryMode(CurrNode,i).selected) ! numSelected++; ! } ! NumPrevSelected = numSelected; ! if(Object == entries_object) { /* may have Pop'ed back to nodes */ ! if((numSelected > 1) || (numSelected == 0)) ! sprintf(msg,"%d entries currently selected",numSelected); ! else sprintf(msg,"1 entry selected"); ! Announce(msg); ! } ! } ! OUT(EntriesHitHandler); ! return(0); } static void StartDirMove( self, tn ) ! register struct bushv *self; ! register tree_type_node tn; { ! IN(StartDirMove); ! if(tn) { ! PostCursor(self,Cursor_Gunsight); ! sprintf(msg,"Moving directory '%s'...",DirName(tn)); ! Announce(msg); ! } ! else Announce("No selected directory to move."); ! OUT(StartDirMove); } static int FinishDirMove( self, tn ) ! register struct bushv *self; ! register tree_type_node tn; { ! register int status = 0; ! char finalLocation[MAXPATHLEN]; ! IN(FinishDirMove); ! PostCursor(self,Cursor_Wait); ! if(!MoveNode) status = -1; ! else if(!tn) { ! sprintf(msg,"No target selected. Move operation cancelled."); ! Announce(msg); ! status = -1; ! } ! else if(tn == MoveNode) { ! sprintf(msg,"Cancelled."); ! Announce(msg); ! status = -1; ! } ! else if(tree_NodeAncestor(Tree,MoveNode,tn)) { ! sprintf(msg,"You cannot move a directory to one of its children."); ! Announce(msg); ! status = -1; ! } ! else if(tn == Parent(MoveNode)) { ! sprintf(msg,"'%s' already lives under '%s'", ! DirName(MoveNode),DirName(tn)); ! Announce(msg); ! status = -1; ! } ! else { ! sprintf(msg,"Moving '%s' under '%s'",DirName(MoveNode), ! DirName(tn)); ! Announce(msg); ! sprintf(finalLocation,"%s/%s",DirPath(tn), ! DirName(MoveNode)); ! if(status = rename(DirPath(MoveNode),finalLocation)) { ! IssueError(self,"Moving",DirName(MoveNode),TRUE); ! sprintf(msg,"Move failed."); ! Announce(msg); } else { ! if(tree_NodeLevel(Tree,CurrNode) >= tree_NodeLevel(Tree,MoveNode)) ! CurrNode = NULL; ! SetTreeNotificationData(self,MoveNode,tree_NodeDestroyed); ! NotifyTreeObservers(self); ! tree_DestroyNode(Tree,MoveNode); ! sprintf(msg,"Move succeeded."); ! Announce(msg); } ! } ! bushv_RetractCursor(self,Cursor); ! OUT(FinishDirMove); ! return(status); } static long TreeHitHandler( self, tree_view, node, object, action, x, y, numClicks ) ! register struct bushv *self; ! register struct treev *tree_view; ! register tree_type_node node; ! register long object; ! register enum view_MouseAction action; ! register long x, y, numClicks; { ! register tree_type_node old_CurrNode = NULL; ! register tree_type_node peer = NULL; ! struct stat stats; ! IN(TreeHitHandler); ! if(object == treev_NodeObject) { ! if(node) treev_HighlightNode(tree_view,node); ! if(action == view_RightDown) { ! MoveNode = node; ! StartDirMove(self,node); ! return 0; ! } ! else if(action == view_RightUp) { ! if(FinishDirMove(self,node)) { ! treev_HighlightNode(tree_view,CurrNode); ! MoveNode = NULL; ! return 0; ! } ! MoveNode = NULL; ! DirMode(node).do_rescan = TRUE; ! } ! else if(action != view_LeftUp || !node) return 0; ! ClearMessageLine(); ! PostCursor(self,Cursor_Wait); ! if(stat(DirPath(node),&stats)) { ! DirMode(node).stat_failed = TRUE; ! IssueError(self,"Scanning",DirName(node),TRUE); ! bushv_RetractCursor(self,Cursor); ! return 0; ! } ! old_CurrNode = CurrNode; ! CurrNode = node; ! if(Parent(CurrNode)) peer = Child(Parent(CurrNode)); ! else peer = CurrNode; ! if(!DirMode(CurrNode).selected || (action == view_RightUp)) { ! if(old_CurrNode) { ! DirMode(old_CurrNode).selected = FALSE; ! old_CurrNode = NULL; ! } ! while(peer) { ! if(Child(peer)) { ! SetTreeNotificationData(self,peer, ! tree_NodeChildrenDestroyed); ! NotifyTreeObservers(self); ! bush_DestroySubDirs(Bush,peer); ! break; } ! peer = Right(peer); ! } ! DirMode(CurrNode).selected = TRUE; ! if(ScanRequired(CurrNode)) { ! sprintf(msg,"Scanning '%s' ...",DirName(CurrNode)); ! Announce(msg); ! im_ForceUpdate(); ! bush_ScanDir(Bush,CurrNode); ! ClearMessageLine(); ! } ! bush_BuildSubDirs(Bush,CurrNode); ! SetTreeNotificationData(self,CurrNode, ! tree_NodeChildrenCreated); ! NotifyTreeObservers(self); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); } ! else Push(self); ! bushv_RetractCursor(self,Cursor); ! } ! OUT(TreeHitHandler); ! return(0); } static long ControlHitHandler( self, suite, item, object, action, x, y, numClicks ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *item; ! register long object; ! register enum view_MouseAction action; ! register long x, y, numClicks; { ! IN(ControlHitHandler); ! ClearMessageLine(); ! if((action == view_LeftUp) || (action == view_RightUp)) { ! if(item && (object == suite_ItemObject)) { ! struct item_data *itemData = NULL; ! if(itemData = (struct item_data*) suite_ItemAttribute(suite, item, suite_ItemData(0))) ! switch(itemData->code) { ! case(edit_code): PerformEdit(self); break; ! case(exec_code): PerformExec(self); break; ! case(print_code): PerformPrint(self); break; ! case(sort_code): PerformSort(self); break; ! case(destroy_code): PerformDestroy(self); break; ! case(rescan_code): PerformRescan(self); break; ! case(create_code): PerformCreate(self); break; ! case(pop_code): PerformPop(self); break; ! case(detail_code): PerformDetail(self); break; ! case(rename_code): PerformRename(self); break; ! case(editor_code): SetEditor(self); break; ! case(switch_code): SwitchDirectory(self); break; } ! PassivateControls(self); } ! else if(object == suite_TitleObject) { ! suite_HighlightTitle(suite); ! PostCursor(self,Cursor_Wait); ! HandleChangeDir(self,DirPath(CurrNode)); ! sleep(1); ! bushv_RetractCursor(self,Cursor); ! sprintf(msg,"Working directory changed to '%s'", ! DirPath(CurrNode)); ! Announce(msg); ! suite_NormalizeTitle(suite); ! } ! else if(object == suite_NoObject) { ! PassivateControls(self); ! if(suite_CurrentItem(suite)) ! suite_PassivateItem(suite,suite_CurrentItem(suite)); ! } ! } ! OUT(ControlHitHandler); ! return(0); } static char * FileSuffix( file_name ) ! register char *file_name; { ! register char *suffix; ! if(suffix = (char*)rindex(file_name,'.')) suffix++; ! else suffix = file_name + strlen(file_name); ! return(suffix); } static char * FileType( file_name ) ! register char *file_name; { ! static char *suffixes[] = {"BAK","CKP",0}; ! register char *suffix, **suffix_ptr; ! suffix = (char*)rindex(file_name,'.'); ! if(!suffix) return(file_name + strlen(file_name)); ! suffix++; ! suffix_ptr = suffixes; ! while(*suffix_ptr) { ! if(!strcmp(suffix,*suffix_ptr)) { ! *(suffix-1) = '\0'; ! return(FileSuffix(file_name)); } ! suffix_ptr++; ! } ! return(suffix); } int SortByName( self, suite, e1, e2 ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *e1,*e2; { ! register struct Dir_Entry *a = NULL, *b = NULL; ! register long status = 0; ! if(!e1 || !e2) return(0); ! a = (struct Dir_Entry*)suite_ItemAttribute(suite,e1,suite_ItemDatum(0)); ! b = (struct Dir_Entry*)suite_ItemAttribute(suite,e2,suite_ItemDatum(0)); ! if(a && b) { ! status = strcmp(a->name,b->name); ! if(status < 0) return(-1); ! else if(status > 0) return(1); ! } ! return(0); } int SortBySuffix( self, suite, e1, e2 ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *e1,*e2; { ! register struct Dir_Entry *a = NULL, *b = NULL; ! register long rc; ! if(!e1|| !e2) return(0); ! a = (struct Dir_Entry*)suite_ItemAttribute(suite,e1,suite_ItemDatum(0)); ! b = (struct Dir_Entry*)suite_ItemAttribute(suite,e2,suite_ItemDatum(0)); ! if(a && b) ! if(!(rc = strcmp(FileSuffix(a->name),FileSuffix(b->name)))) { ! rc = strcmp(a->name,b->name); ! if(rc > 0) return(1); ! else if(rc < 0) return(-1); ! } ! else { ! if(rc > 0) return(1); ! else if(rc < 0) return(-1); ! } ! return(0); } int SortBySize( self, suite, e1, e2 ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *e1,*e2; { ! register struct Dir_Entry *a = NULL, *b = NULL; ! if(!e1 || !e2) return(0); ! a = (struct Dir_Entry*)suite_ItemAttribute(suite,e1,suite_ItemDatum(0)); ! b = (struct Dir_Entry*)suite_ItemAttribute(suite,e2,suite_ItemDatum(0)); ! if(a && b) { ! if(a->size < b->size) return(1); ! else if(a->size > b->size) return(-1); ! } ! return(0); } int SortByDate( self, suite, e1, e2 ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *e1,*e2; { ! register struct Dir_Entry *a = NULL, *b = NULL; ! if(!e1 || !e2) return(0); ! a = (struct Dir_Entry*)suite_ItemAttribute(suite,e1,suite_ItemDatum(0)); ! b = (struct Dir_Entry*)suite_ItemAttribute(suite,e2,suite_ItemDatum(0)); ! if(a && b) { ! if(a->time_stamp < b->time_stamp) return(1); ! if(a->time_stamp > b->time_stamp) return(-1); ! } ! return(0); } int SortByType( self, suite, e1, e2 ) ! register struct bushv *self; ! register struct suite *suite; ! register struct suite_item *e1,*e2; { ! register struct Dir_Entry *a = NULL, *b = NULL; ! char n1[MAXPATHLEN+1], n2[MAXPATHLEN+1]; ! register long rc; ! if(!e1 || !e2) return(0); ! a = (struct Dir_Entry*)suite_ItemAttribute(suite,e1,suite_ItemDatum(0)); ! b = (struct Dir_Entry*)suite_ItemAttribute(suite,e2,suite_ItemDatum(0)); ! if(a && b) { ! strcpy(n1,a->name); ! strcpy(n2,b->name); ! if(!(rc = strcmp(FileType(n1),FileType(n2)))) { ! rc = strcmp(a->name,b->name); ! if(rc < 0) return(-1); ! else if(rc > 0) return(1); } ! else { ! if(rc < 0) return(-1); ! else if(rc > 0) return(1); ! } ! } ! return(0); } + static struct bind_Description bushvBindings[] = { + {"bushv-exit","\030\003",0,"Quit~99",0,bushv_DefaultMenus, PerformExit, + "Exit. If any file is modified ask for confirmation."}, + {"bushv-save-file","\030\023",0,"Save~20",0,bushv_RWEntryMenus, + (void(*)())bushv_SaveFile,"Saves buffer into its current file."}, + {"bushv-write-file","\030\027",0,"File~10,Save As~1",0, + bushv_EntryMenus,(void(*)())bushv_WriteFile,"Prompt for a file to save."}, + {"bushv-set-printer",NULL,0,"File~10,Set Printer~20",0, + bushv_EntryMenus, (void(*)())bushv_SetPrinter, "Set the default printer."}, + NULL + }; + boolean bushv__InitializeClass( ClassID ) ! struct classheader *ClassID; { ! struct classinfo *classInfo = NULL; ! kmap = keymap_New(); ! menulist = menulist_New(); ! classInfo = class_Load("bushv"); ! bind_BindList(bushvBindings, kmap, menulist, classInfo); ! proctable_DefineProc("bushv-DEBUG",ToggleDebug, ! &bushv_classinfo,NULL,"Toggle Bush debug flag."); ! proctable_DefineProc("bushv-pop",PerformPop, ! &bushv_classinfo,NULL,"Pop up a level."); ! proctable_DefineProc("bushv-switch",SwitchDirectory, ! &bushv_classinfo,NULL,"Switch to a new directory."); ! proctable_DefineProc("bushv-rescan",PerformRescan, ! &bushv_classinfo,NULL,"Rescan the current directory."); ! proctable_DefineProc("bushv-destroy",PerformDestroy, ! &bushv_classinfo,NULL,"Destroy the current directory/files."); ! return(TRUE); } static void GetPreferredEditors( self ) ! register struct bushv *self; { ! register char *tmp = NULL, *colon = NULL; ! char *myCopy = NULL; ! register int i = 0; ! IN(GetPreferredEditors); ! environ_SetProgramName("bush"); ! if(((tmp = environ_GetProfile("editors")) || ! (tmp = environ_GetProfile("editor"))) && *tmp) { ! AllocNameSpace(tmp,&myCopy); ! if(colon = (char*)index(tmp = myCopy,':')) { ! while((colon = (char*)index(tmp,':')) && (i < MAXEDITORS)) { ! *colon = '\0'; ! if(tmp && (*tmp != '\0')) { ! EditorChoices[i] = NULL; ! AllocNameSpace(tmp,&EditorChoices[i++]); } ! tmp = colon + 1; ! } ! if(tmp && (*tmp != '\0') && (i < MAXEDITORS)) { ! EditorChoices[i] = NULL; ! AllocNameSpace(tmp,&EditorChoices[i]); ! EditorChoices[i+1] = NULL; ! } ! else if(i >= MAXEDITORS) ! fprintf(stderr,"bush: too many editors in preference.\n"); } ! else if(tmp && (*tmp != '\0')) { ! EditorChoices[i] = NULL; ! AllocNameSpace(myCopy,&EditorChoices[i]); ! EditorChoices[i+1] = NULL; ! } ! i++; ! AllocNameSpace("other",&EditorChoices[i]); ! EditorChoices[i+1] = NULL; ! NumEditorChoices = i+1; ! if(myCopy) free(myCopy); ! } ! else if(!tmp || (i == 0)) { ! for( i = 0 ; default_editor_choices[i] && (i < MAXEDITORS); i++ ) { ! EditorChoices[i] = NULL; ! AllocNameSpace(default_editor_choices[i],&EditorChoices[i]); ! } ! EditorChoices[i] = NULL; ! NumEditorChoices = i; ! } ! EditorIndex = 0; ! strcpy(EditorProgram,EditorChoices[0]); ! if(EditorProgram && *EditorProgram != '\0') { ! struct suite_item *editorItem = NULL; ! char editorCaption[64]; ! ! if(editorItem = suite_ItemOfDatum(ControlView,&editor_data)) { ! sprintf(editorCaption,"Editor: %s",EditorProgram); ! suite_SetItemAttribute(ControlView, editorItem, suite_ItemCaption(editorCaption)); ! } ! } ! OUT(GetPreferredEditors); } static void GetPreferredFont( self ) ! register struct bushv *self; { ! register char *tmp = NULL; ! IN(GetPreferredFont); ! if((tmp = environ_GetProfile("bodyfont")) && *tmp) { ! suite_SetSuiteAttribute(ControlView, ! suite_TitleFontName(tmp)); ! suite_SetSuiteAttribute(ControlView,suite_TitleCaptionFontHigh(0)); ! suite_SetSuiteAttribute(ControlView, ! suite_ItemCaptionFontName(tmp)); ! suite_SetSuiteAttribute(ControlView,suite_ItemCaptionFontHigh(0)); ! suite_SetSuiteAttribute(EntriesView,suite_TitleFontName(tmp)); ! suite_SetSuiteAttribute(EntriesView,suite_TitleCaptionFontHigh(0)); ! suite_SetSuiteAttribute(EntriesView,suite_ItemCaptionFontName(tmp)); ! suite_SetSuiteAttribute(EntriesView,suite_ItemCaptionFontHigh(0)); ! } ! OUT(GetPreferredFont); } static void GetPreferences( self ) ! register struct bushv *self; { ! IN(GetPreferences); ! GetPreferredEditors(self); ! GetPreferredFont(self); ! CkpInterval = environ_GetProfileInt("CheckpointInterval",DEFAULTCKPINTERVAL); ! OUT(GetPreferences); } boolean bushv__InitializeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct bushv *self; { ! Kmap = kmap; ! if(!(Kstate = keystate_Create(self,Kmap))) { ! fprintf(stderr,"bushv: could not create keystate.\n"); ! exit(1); ! } ! Cursor = cursor_Create(self); ! cursor_SetStandard(Cursor,Cursor_Wait); ! Bush = NULL; ! CurrNode = InitNode = MoveNode = NULL; ! CurrEntry = NULL; ! EntryView = EntryViewAppLayer = NULL; ! EntryObject = NULL; ! EntryObjectModified = EntryObjectLastCKP = 0; ! EntryFilep = NULL; ! ControlView = suite_Create(control_spec,self); ! EntriesView = suite_Create(entries_spec,self); ! DirTreeView = treev_Create(tree_spec,self); ! LP = lpair_New(); ! lpair_VTFixed(LP,(struct view*)ControlView,(struct view*)DirTreeView,95,TRUE); ! lpair_LinkTree(LP,(struct view*)self); ! Object = nodes_object; ! SortMode = 0; ! Detail = 0; ! NumPrevSelected = 0; ! Debug = 1; ! Menulist = menulist_DuplicateML(menulist,self); ! GetPreferences(self); ! bushv_SetOptions(self,aptv_SuppressControl | aptv_SuppressBorder); ! TopLevelInset = TRUE; ! OUT(bushv_InitializeObject); ! return(TRUE); ! } void bushv__FinalizeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct bushv *self; { ! IN(bushv_FinalizeObject); ! if(LP) lpair_Destroy(LP); ! if(ControlView) suite_Destroy(ControlView); ! if(EntriesView) suite_Destroy(EntriesView); ! if(DirTreeView) treev_Destroy(DirTreeView); ! if(EntryView) view_Destroy(EntryView); ! if(EntryObject) dataobject_Destroy(EntryObject); ! if(Menulist) menulist_Destroy(Menulist); ! OUT(bushv_FinalizeObject); } struct bushv * bushv__Create( ClassID, object ) ! register struct classheader *ClassID; ! register char object; { ! struct bushv *self = NULL; ! if(self = bushv_New()) Object = object; ! OUT(bushv_Create); ! return(self); } void bushv__PostMenus( self, menulist ) ! struct bushv *self; ! struct menulist *menulist; { ! int mask = 0; ! ! IN(bushv_PostMenus); ! menulist_ClearChain(Menulist); ! mask = menulist_GetMask(Menulist) | bushv_DefaultMenus; ! if(Object == entry_object) ! mask |= bushv_EntryMenus; ! else ! mask &= (~bushv_EntryMenus & ~bushv_RWEntryMenus); ! menulist_SetMask(Menulist,mask); ! if(menulist) ! menulist_ChainBeforeML(Menulist,menulist,NULL); ! super_PostMenus(self,Menulist); ! OUT(bushv_PostMenus); } struct view * bushv__Hit( self, action, x, y, numberOfClicks ) ! struct bushv *self; ! enum view_MouseAction action; ! long x, y, numberOfClicks; { ! IN(bushv_Hit); ! return(lpair_Hit(LP,action,x,y,numberOfClicks)); } void bushv__FullUpdate( self, Type, left, top, width, height ) ! struct bushv *self; ! enum view_UpdateType Type; ! long left, top, width, height; { ! struct rectangle r; ! char RootPathIfInset[MAXPATHLEN]; ! char NewTitle[MAXPATHLEN]; ! IN(bushv_FullUpdate); ! if(Type == view_LastPartialRedraw || Type == view_FullRedraw) { ! super_FullUpdate(self,Type,left,top,width,height); ! if(!RootPathName) { ! im_GetDirectory(RootPathIfInset); ! bush_InitTree(Bush,RootPathIfInset); ! CurrNode = InitNode = TreeRoot; ! bush_BuildSubDirs(Bush,TreeRoot); ! HandleChangeDir(self,RootPathName); } ! bushv_GetVisualBounds(self,&r); ! lpair_InsertView(LP,(struct view*)self,&r); ! bushv_SetTransferMode(self,graphic_WHITE); ! bushv_FillRect(self,&r,bushv_WhitePattern(self)); ! bushv_SetTransferMode(self,graphic_BLACK); ! lpair_FullUpdate(LP,Type,0,0,r.width,r.height); ! if(CurrNode || (CurrNode = treev_CurrentNode(DirTreeView))) { ! sprintf(NewTitle,"%s%s%s",DirPath(CurrNode), ! CurrEntry ? "/" : "", CurrEntry ? CurrEntry->name : ""); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(NewTitle)); ! } ! else ! suite_ChangeSuiteAttribute(ControlView,"No Current Directory"); ! PassivateControls(self); ! ClearMessageLine(); ! } ! if(Object == nodes_object) ! bushv_WantInputFocus(self,DirTreeView); ! OUT(bushv_FullUpdate); } static void DoEdit( self, path, name ) ! struct bushv *self; ! char *path, *name; { ! char full_path[MAXPATHLEN * 2]; ! IN(DoEdit); ! sprintf(full_path,"%s/%s",path,name); ! sprintf(msg,"%s '%s/%s'",EditorProgram,path,name); ! argv[0] = EditorProgram; ! argv[1] = full_path; ! argv[2] = NULL; ! PerformSystemAction(self,EditorProgram,argv,msg); ! OUT(DoEdit); } static void PerformEdit( self ) ! struct bushv *self; { ! register int i = 0; ! IN(PerformEdit); ! if(!CurrEntry) return; ! PostCursor(self,Cursor_Wait); ! switch(Object) { ! case nodes_object: ! break; ! case entries_object: ! if(CurrNode && DirEntries(CurrNode) && ! (DirEntriesCount(CurrNode) >= 0)) ! for(i=0;iname); ! break; ! } ! bushv_RetractCursor(self,Cursor); ! OUT(PerformEdit); } static void PerformPrint( self ) ! struct bushv *self; { ! register int i = 0; ! register FILE *file = NULL; ! IN(PerformPrint); ! PostCursor(self,Cursor_Wait); ! switch(Object) { ! case nodes_object: ! if(file = fopen("/tmp/bush_print.PS","w")) { ! treev_Print(DirTreeView,file,"postscript","postscript",1); ! fclose(file); ! system("print -Tnative /tmp/bush_print.PS"); ! sprintf(msg,"Printed '%s'",RootPathName); ! Announce(msg); ! } ! else Announce("Error Printing"); ! break; ! case entries_object: ! for(i=0;i < DirEntriesCount(CurrNode);i++) ! if(DirEntryMode(CurrNode,i).selected && ! !DirEntryType(CurrNode,i).dir) ! DoPrint(self,DirPath(CurrNode), ! DirEntryName(CurrNode,i)); ! break; ! case entry_object: ! DoPrint(self,DirPath(CurrNode),CurrEntry->name); ! break; ! } ! bushv_RetractCursor(self,Cursor); ! OUT(PerformPrint); } static DoPrint( self, path, name ) ! struct bushv *self; ! char *path, *name; { ! char full_path[MAXPATHLEN * 2], *ext = NULL; ! int i = 0; ! IN(DoPrint); ! sprintf(full_path,"%s/%s",path,name); ! sprintf(msg,"Printing '%s'",full_path); ! if((ext = rindex(name,'.')) != NULL) { ! ext++; ! argv[i++] = "print"; ! argv[i++] = "-T"; ! if(!strcmp(ext,"ps")) argv[i++] = "native"; ! else if(!strcmp(ext,"ras")) argv[i++] = "raster"; ! else if(!strcmp(ext,"dvi")) argv[i++] = "dvi"; ! else { ! i = 0; ! argv[i++] = "ezprint"; } ! } ! else argv[i++] = "ezprint"; ! argv[i++] = full_path; ! argv[i] = NULL; ! PerformSystemAction(self,argv[0],argv,msg); ! OUT(DoPrint); } static void PerformCreate( self ) ! struct bushv *self; { ! register int f = 0; ! char *response = NULL; ! IN(PerformCreate); ! if(!CurrNode) return; ! switch(Object) { ! case nodes_object: ! if(bushv_Query(self,"Directory Name: ","",&response)) return; ! sprintf(cmd,"%s/%s",DirPath(CurrNode),response); ! if(mkdir(cmd,0777)) { ! IssueError(self,"Creating",response,TRUE); ! return; ! } ! else PerformRescan(self); ! break; ! case entries_object: ! if(bushv_Query(self,"File Name: ","",&response)) return; ! sprintf(cmd,"%s/%s",DirPath(CurrNode),response); ! if((f = open(cmd,O_CREAT | O_EXCL, 0100 | 0200 | 0400)) < 0) { ! IssueError(self,"Creating",response,TRUE); ! return; ! } ! else { ! close(f); ! PerformRescan(self); ! } ! break; ! case entry_object: ! break; ! } ! OUT(PerformCreate); } static void IssueError( self, what, where, overlay ) ! register struct bushv *self; ! register char *what, *where; ! boolean overlay; { ! int result = 0; ! static char *question[] = {"Continue",NULL}; ! IN(IssueError); ! if(errno > 0 && errno <= sys_nerr) ! sprintf(msg,"ERROR %s '%s': %s", what, where, sys_errlist[errno] ); ! else if(errno != 0) ! sprintf(msg,"ERROR %s '%s': (Invalid System Error-code '%d')", what, where, errno ); ! else ! sprintf(msg,"ERROR %s '%s'", what, where); ! if(overlay) message_MultipleChoiceQuestion(self,100,msg,0,&result,question,NULL); ! else Announce(msg); ! errno = 0; ! OUT(IssueError); } static int DoDestroy( self, tn, Entry, overlay ) ! register struct bushv *self; ! register tree_type_node tn; ! register struct Dir_Entry *Entry; ! boolean overlay; { ! register int status = 0; ! IN(DoDestroy); ! if(self && tn && Entry) { ! if(status = bush_DestroyEntry(Bush,tn,Entry)) ! IssueError(self,"Destroying",Entry->name,overlay); ! } ! OUT(DoDestroy); ! return(status); } static void PerformDestroy( self ) ! struct bushv *self; { ! static char *question[] = {"Confirm","Cancel",0}; ! register int i = 0; ! long result = 0; ! int count = 0; ! register struct Dir_Entry *Dir_Entry = NULL, *current_entry = CurrEntry; ! register tree_type_node current_node = CurrNode, tn = NULL; ! register struct suite_item **selected = NULL; ! IN(PerformDestroy); ! if(!current_node) return; ! switch(self->object) { ! case nodes_object: ! if(tn = Parent(current_node)) { ! for(i=0;i 0)){ ! sprintf(msg,"'%s' has contents. Destroy Anyway?", ! DirName(current_node)); ! if(message_MultipleChoiceQuestion(self,100,msg, ! 1,&result,question,NULL) == -1) return; ! if(result != 0) { ! Announce("Cancelled"); ! return; } ! } ! if(result == 0) { ! PostCursor(self,Cursor_Wait); ! if(DoDestroy(self,Parent(current_node), ! Dir_Entry,TRUE)) { ! bushv_RetractCursor(self,Cursor); ! return; } ! CurrNode = Parent(current_node); ! treev_HighlightNode(DirTreeView,CurrNode); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! bushv_RetractCursor(self,Cursor); ! PerformRescan(self); ! sprintf(msg,"Destroyed Node '%s'",Dir_Entry->name); ! Announce(msg); ! } ! } ! else Announce("Node Not Found in Parent"); ! } ! else Announce("May Not Destroy Root Directory"); ! break; ! case entries_object: ! selected = suite_SelectedItems(EntriesView,&count); ! if(count == 0) break; ! if(count > 1) ! if(count == 2) sprintf(msg,"Destroy Both Items ?"); ! else sprintf(msg,"Destroy All %d Items ?",count); ! else { ! Dir_Entry = (struct Dir_Entry*) ! suite_ItemAttribute(EntriesView,selected[0],suite_ItemDatum(0)); ! sprintf(msg,"Destroy %s '%s' ?",EntryDirType(Dir_Entry) ! ? "Node" : "",Dir_Entry->name); ! } ! if(message_MultipleChoiceQuestion(self,100,msg,1, ! &result,question,NULL) == -1) return; ! if(result == 0) { ! PostCursor(self,Cursor_Wait); ! for( i = 0 ; i < count ; i++ ) { ! Dir_Entry = (struct Dir_Entry*) ! suite_ItemAttribute(EntriesView,selected[i],suite_ItemDatum(0)); ! if(!DoDestroy(self,current_node,Dir_Entry,TRUE)) { ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! suite_PassivateItem(EntriesView,selected[i]); ! EntrySelected(Dir_Entry) = FALSE; } ! } ! bushv_RetractCursor(self,Cursor); ! } ! else Announce("Canceled"); ! break; ! case entry_object: ! if(current_entry) { ! selected = suite_SelectedItems(EntriesView,&count); ! if(EntryDirType(current_entry)) ! sprintf(msg,"Destroy Directory '%s'?",current_entry->name); ! else sprintf(msg,"Destroy '%s'?",current_entry->name); ! if(message_MultipleChoiceQuestion(self,100,msg,1, &result,question,NULL) == -1) return; ! if(result==0) { ! PostCursor(self,Cursor_Wait); ! if(!DoDestroy(self,current_node,current_entry,TRUE)) { ! CurrEntry = NULL; ! PerformPop(self); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); } ! bushv_RetractCursor(self,Cursor); ! } ! } ! else Announce("Canceled"); ! break; ! } ! OUT(PerformDestroy); } static void PerformExec( self ) ! struct bushv *self; { ! register int i = 0; ! IN(PerformExec); ! if(!CurrEntry) return; ! PostCursor(self,Cursor_Wait); ! switch(Object) { ! case nodes_object: break; ! case entries_object: ! if(CurrNode && DirEntries(CurrNode) && ! (DirEntriesCount(CurrNode) >= 0)) ! for(i = 0;i < DirEntriesCount(CurrNode);i++) ! if(DirEntryMode(CurrNode,i).selected && ! !DirEntryType(CurrNode,i).dir) ! DoExecute(self,CurrNode,DirEntry(CurrNode,i)); ! break; ! case entry_object: ! DoExecute(self,CurrNode,CurrEntry); ! break; ! } ! bushv_RetractCursor(self,Cursor); ! OUT(PerformExec); } static DoExecute( self, tn, Entry ) ! struct bushv *self; ! tree_type_node tn; ! struct Dir_Entry *Entry; { ! char full_path[MAXPATHLEN * 2]; ! IN(DoExecute); ! sprintf(full_path,"%s/%s",DirPath(tn),Entry->name); ! sprintf(msg,"Executing '%s'",full_path); ! argv[0] = full_path; ! argv[1] = NULL; ! PerformSystemAction(self,full_path,argv,msg); ! OUT(DoExecute); } static int PerformSystemAction( self, name, argv, msg ) ! struct bushv *self; ! char *name; ! char *argv[]; ! char *msg; { ! Announce(msg); ! return(bush_PerformSystemAction(Bush,name,argv)); } static char* Format_Tags( tag ) ! u_short tag; { ! static char tags[11]; ! strcpy(tags,"----------"); ! if((tag & S_IFMT) == S_IFREG) tags[0] = '-'; ! else if((tag & S_IFMT) == S_IFDIR) tags[0] = 'd'; ! else if((tag & S_IFMT) == S_IFCHR) tags[0] = 'c'; ! else if((tag & S_IFMT) == S_IFBLK) tags[0] = 'b'; ! else if((tag & S_IFMT) == S_IFLNK) tags[0] = 'l'; #ifdef S_IFIFO ! else if((tag & S_IFMT) == S_IFIFO) tags[0] = '?'; #endif /* #ifdef S_IFIFO */ #ifdef S_IFSOCK ! else if((tag & S_IFMT) == S_IFSOCK) tags[0] = '?'; #endif /* #ifdef S_IFSOCK */ ! if(tag & S_IREAD) tags[1] = 'r'; ! if(tag & S_IWRITE) tags[2] = 'w'; ! if(tag & S_IEXEC) tags[3] = 'x'; ! if(tag & (S_IREAD >>3)) tags[4] = 'r'; ! if(tag & (S_IWRITE>>3)) tags[5] = 'w'; ! if(tag & (S_IEXEC >>3)) tags[6] = 'x'; ! if(tag & (S_IREAD >>6)) tags[7] = 'r'; ! if(tag & (S_IWRITE>>6)) tags[8] = 'w'; ! if(tag & (S_IEXEC >>6)) tags[9] = 'x'; ! tags[10] = '\0'; ! return(tags); } static char* FormatEntriesItem( self, tn, i, dirEntry ) ! register struct bushv *self; ! tree_type_node tn; ! int i; ! struct Dir_Entry *dirEntry; { ! static char entries_item[257], trailer[5]; ! register char *entries_ptr = NULL, *time_ptr = NULL; ! IN(FormatEntriesItem); ! if(tn) { ! if(!DirEntryType(tn,i).soft_link && DirEntryType(tn,i).dir) ! strcpy(trailer,"/"); ! else if(DirEntryType(tn,i).soft_link && ! ((DirDetail(CurrNode) == 1) || ! ((DirDetail(CurrNode) == -1) && Detail))) ! strcpy(trailer," -> "); ! else if(DirEntryPerms(tn,i) & S_IEXEC) strcpy(trailer,"*"); ! else trailer[0] = '\0'; ! if((DirDetail(tn) == 1) || ((DirDetail(tn) == -1) && Detail)) { ! time_ptr = (char*) ctime(&DirEntryTimeStamp(tn,i)); ! time_ptr[24] = '\0'; ! sprintf(entries_item,"%s %2d %8s %8d %s %s%s%s", ! Format_Tags(DirEntryPerms(tn,i)), ! DirEntryNLinks(tn,i),DirEntryOwner(tn,i), ! DirEntrySize(tn,i),time_ptr,DirEntryName(tn,i), ! trailer, DirEntryType(tn,i).soft_link ? DirEntryLinkName(tn,i) : ""); } ! else sprintf(entries_item,"%s%s",DirEntryName(tn,i),trailer); ! entries_ptr = entries_item; ! } ! else if(dirEntry) { ! if(!EntryLinkType(dirEntry) && EntryDirType(dirEntry)) strcpy(trailer,"/"); ! else if(EntryLinkType(dirEntry) && ! ((DirDetail(CurrNode) == 1) || ! ((DirDetail(CurrNode) == -1) && Detail))) ! strcpy(trailer," -> "); ! else if(EntryPerms(dirEntry) & S_IEXEC) strcpy(trailer,"*"); ! else trailer[0] = '\0'; ! if((DirDetail(CurrNode) == 1) || ! ((DirDetail(CurrNode) == -1) && Detail)) { ! time_ptr = (char*) ctime(&dirEntry->time_stamp); ! time_ptr[24] = '\0'; ! sprintf(entries_item,"%s %2d %8s %8d %s %s%s%s", ! Format_Tags(dirEntry->permissions), ! dirEntry->nlinks,dirEntry->owner, ! dirEntry->size,time_ptr,dirEntry->name, ! trailer, EntryLinkType(dirEntry) ? EntryLinkName(dirEntry) : ""); } ! else sprintf(entries_item,"%s%s",dirEntry->name,trailer); ! entries_ptr = entries_item; ! } ! OUT(FormatEntriesItem); ! return(entries_ptr); } static void *************** *** 1501,2221 **** static void ResetEntriesCaptions( self ) ! struct bushv *self; { ! register int i = 0, count = 0; ! struct suite_item *item = NULL; ! IN(ResetEntriesCaptions); ! suite_Reset(EntriesView,suite_ClearItems); ! if(DirEntries(CurrNode) && ! (count = DirEntriesCount(CurrNode)) >= 0) ! for( i = 0 ; i < count ; i++ ) ! if(item = suite_CreateItem(EntriesView, ! DirEntryName(CurrNode,i),DirEntry(CurrNode,i))) ! suite_SetItemAttribute(EntriesView,item, ! suite_ItemCaption(FormatEntriesItem(self,CurrNode,i,NULL))); ! OUT(ResetEntriesCaptions); } static void PerformExit( self ) ! struct bushv *self; { ! IN(PerformExit); ! if(TopLevelInset) im_Destroy(bushv_GetIM(self)); ! bushv_Destroy(self); ! _exit(0); ! OUT(PerformExit); /*HA!*/ } static void SwitchDirectory( self ) ! struct bushv *self; { ! static char *question[] = {"Continue",NULL}; ! int msg_status = 0; ! long result = 0; ! char *response = NULL; ! struct stat stats; ! IN(SwitchDirectory); ! msg_status = bushv_QueryDirectoryName(self,"Switch To Directory: ",&response); ! if(msg_status) { ! return; ! } PostCursor(self,Cursor_Wait); ! if(stat(response,&stats)) { ! IssueError(self,"ReScanning",response,TRUE); ! bushv_RetractCursor(self,Cursor); ! return; ! } ! if((stats.st_mode & S_IFMT) != S_IFDIR) { ! sprintf(msg,"Must Change to a Directory"); ! message_MultipleChoiceQuestion(self,100,msg,0,&result,question,NULL); ! sprintf(msg,"Failed to change to '%s'",response); ! bushv_Announce(self,msg); ! bushv_RetractCursor(self,Cursor); ! return; ! } ! if(Object != nodes_object) { ! PopToNodes(self); ! PostCursor(self,Cursor_Wait); ! } ! SetTreeNotificationData(self,TreeRoot,tree_NodeDestroyed); ! NotifyTreeObservers(self); ! tree_DestroyNode(Tree,TreeRoot); ! bush_InitTree(Bush,response); ! CurrNode = InitNode = TreeRoot; ! bush_BuildSubDirs(Bush,CurrNode); ! SetTreeNotificationData(self,CurrNode,tree_NodeCreated); ! NotifyTreeObservers(self); ! suite_ChangeSuiteAttribute(ControlView, suite_TitleCaption(DirPath(CurrNode))); ! if(TopLevelInset) im_SetTitle(bushv_GetIM(self),DirName(CurrNode)); ! bushv_RetractCursor(self,Cursor); ! HandleChangeDir(self,RootPathName); ! OUT(SwitchDirectory); } static void SetEditor( self ) ! struct bushv *self; { ! long result = 0; ! char *response = NULL; ! IN(SetEditor); ! sprintf(msg,"Set editor to: "); ! if(message_MultipleChoiceQuestion(self,100,msg,EditorIndex, &result,EditorChoices,NULL) == -1) return; ! if(!strcmp(EditorChoices[result],"other")) { ! if(bushv_Query(self,"Set editor to: ","",&response)) { ! return; ! } ! AllocNameSpace(EditorChoices[NumEditorChoices-1], ! &EditorChoices[NumEditorChoices]); ! AllocNameSpace(response,&EditorChoices[NumEditorChoices-1]); ! EditorChoices[++NumEditorChoices] = NULL; } ! EditorIndex = result; ! strcpy(EditorProgram,EditorChoices[result]); ! sprintf(msg,"Editor set to: '%s'",EditorProgram); ! bushv_Announce(self,msg); ! OUT(SetEditor); } void bushv__PostKeyState( self, kstate ) ! struct bushv *self; ! struct keystate *kstate; { ! IN(bushv_KeyState); ! keystate_AddBefore(Kstate,kstate); ! super_PostKeyState(self,Kstate); ! OUT(bushv_KeyState); } char * FormatEntriesInfo( self, tn ) ! struct bushv *self; ! tree_type_node tn; { ! static char entries_info[257]; ! register long i = 0, total_bytes = 0, count = 0; ! IN(FormatEntriesInfo); ! if(tn) { ! if(DirEntries(tn)) count = DirEntriesCount(tn); ! for( i = 0; i < count; i++ ) total_bytes += DirEntrySize(tn,i); ! sprintf(entries_info,"%d %s %d %s %s %s",count, ! "Entries",total_bytes,"Bytes","Sorted by", ! (DirSortMode(tn) != -1) ? sorts[DirSortMode(tn)] : ! sorts[SortMode]); ! } ! OUT(FormatEntriesInfo); ! return(entries_info); } static int (*DetermineSortHandler( self, tn ))() ! struct bushv *self; ! tree_type_node tn; { ! int (*sorter)(), sMode = 0; ! IN(DetermineSortHandler); ! if((sMode = DirSortMode(tn)) == -1) sMode = SortMode; ! switch(sMode) { ! case by_name: sorter = SortByName; break; ! case by_size: sorter = SortBySize; break; ! case by_date: sorter = SortByDate; break; ! case by_suffix: sorter = SortBySuffix; break; ! case by_type: sorter = SortByType; break; } ! OUT(DetermineSortHandler); ! return(sorter); } static void PushToEntries( self ) ! struct bushv *self; { ! register int (*sorter)(); ! IN(PushToEntries); ! if(EntriesView) { ! sorter = DetermineSortHandler(self,CurrNode); ! suite_SetSuiteAttribute(EntriesView,suite_SortHandler(sorter)); ! Object = entries_object; ! ResetEntriesCaptions(self); ! suite_SetSuiteAttribute(EntriesView, suite_TitleCaption(FormatEntriesInfo(self,CurrNode))); ! lpair_SetNth(LP,1,(struct view*)EntriesView); ! if(ScanRequired(CurrNode)) PerformRescan(self); ! bushv_WantInputFocus(self,EntriesView); ! } ! OUT(PushToEntries); } static void PushToEntry( self ) ! struct bushv *self; { ! char file_name[MAXPATHLEN]; ! char *objectName = NULL; ! long objectID = 0; ! IN(PushToEntry); ! PostCursor(self,Cursor_Wait); ! Object = entry_object; ! sprintf(file_name,"%s/%s",DirPath(CurrNode),CurrEntry->name); ! sprintf(msg,"reading '%s'",file_name); ! bushv_Announce(self,msg); ! if(EntryFilep = fopen(file_name,"r")) { ! objectName = filetype_Lookup(EntryFilep,file_name,&objectID,NULL); ! if(!objectName) objectName = "text"; ! if(EntryView) { ! if(view_IsAncestor(EntryViewAppLayer,self)) ! lpair_SetNth(LP,1,NULL); ! view_DeleteApplicationLayer(EntryView,EntryViewAppLayer); ! view_Destroy(EntryView); ! EntryView = EntryViewAppLayer = NULL; ! dataobject_Destroy(EntryObject); ! EntryObject = NULL; ! } ! if(!(EntryObject = (struct dataobject*)class_NewObject(objectName)) || ! !(EntryView = (struct view*)class_NewObject(dataobject_ViewName(EntryObject)))) { ! IssueError(self,"Allocating Object",objectName,TRUE); ! Object = entries_object; ! } ! else { /*success*/ ! dataobject_Read(EntryObject,EntryFilep,objectID); ! view_SetDataObject(EntryView,EntryObject); ! if(!strcmp(objectName,"text") || !strcmp(objectName,"ctext")) ! text_SetReadOnly((struct text*)EntryObject,TRUE); ! lpair_SetNth(LP,1, ! EntryViewAppLayer = view_GetApplicationLayer(EntryView)); ! view_WantInputFocus(EntryView,EntryView); ! suite_ChangeSuiteAttribute(ControlView,suite_TitleCaption(file_name)); ! } } ! else { ! IssueError(self,"Opening Entry",CurrEntry->name,TRUE); ! Object = entries_object; } ! ClearFrameBuffer(self); ! bushv_RetractCursor(self,Cursor); ! OUT(PushToEntry); } ! static void PopToNodes( self ) ! struct bushv *self; { ! IN(PopToNodes); ! if(DirTreeView) { ! Object = nodes_object; ! CurrEntry = NULL; ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! lpair_SetNth(LP,1,(struct view*)DirTreeView); ! if(ScanRequired(CurrNode)) PerformRescan(self); ! treev_WantInputFocus(DirTreeView,DirTreeView); ! } ! OUT(PopToNodes); } ! static void PopToEntries( self ) ! struct bushv *self; { ! IN(PopToEntries); ! if(EntryFilep) { ! fclose(EntryFilep); ! EntryFilep = NULL; ! } ! if(EntriesView) { ! Object = entries_object; ! lpair_SetNth(LP,1,(struct view*)EntriesView); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! if(ScanRequired(CurrNode)) PerformRescan(self); ! bushv_WantInputFocus(self,EntriesView); ! } ! OUT(PopToEntries); } static long Passivator( self, suite, item, datum ) ! /* ! ============================================================ ! I set the data attribute of the ControlView items to be the OR'ed sum of ! the Object codes for which the particular item is active. If a button is ! active during both the nodes_object(1) and entries_object(2) then it's data field ! is set to (nodes_object + entries_Object) = 1 + 2 = 3. This is how I implemented ! automatic button "Passivation" in bush. It has been proposed that this feature ! be incorporated into suite (3/29/89). ! ============================================================= ! */ ! struct bushv *self; ! struct suite *suite; ! struct suite_item *item; ! unsigned datum; { ! long int result = 0; ! if(suite && item) ! if(suite_ItemAttribute(suite,item,suite_ItemDatum(0)) & Object) ! suite_ActivateItem(suite,item); ! else suite_PassivateItem(suite,item); ! return(result); } static void PassivateControls( self ) ! struct bushv *self; { ! IN(PassivateControls); ! suite_Apply(ControlView,Passivator,self,NULL); ! suite_Reset(ControlView,suite_Normalize); ! OUT(PassivateControls); } static void Push( self ) ! register struct bushv *self; { ! register tree_type_node tn = NULL; ! char *name = NULL; ! IN(Push); ! switch(Object) { ! case nodes_object: ! PushToEntries(self); break; ! case entries_object: ! if(EntryDirType(CurrEntry)) { ! AllocNameSpace(CurrEntry->name,&name); ! PostCursor(self,Cursor_Wait); ! Pop(self); ! tn = Child(CurrNode); ! while(tn) ! if(!strcmp(DirName(tn),name)) break; ! else tn = Right(tn); ! if(tn) { ! TreeHitHandler(self,DirTreeView,tn, ! treev_NodeObject,view_LeftUp,0,0,0); ! treev_HighlightNode(DirTreeView,tn); ! } ! else { ! sprintf(msg,"Couldn't locate directory node '%s'.",CurrEntry->name); ! bushv_Announce(self,msg); ! } ! bushv_RetractCursor(self,Cursor); ! } ! else PushToEntry(self); ! break; ! } ! if(name) free(name); ! PassivateControls(self); ! ClearFrameBuffer(self); ! OUT(Push); } static void Pop( self ) ! struct bushv *self; { ! IN(Pop); ! switch(Object) { ! case entries_object: ! PopToNodes(self); ! break; ! case entry_object: ! PopToEntries(self); ! break; ! } PassivateControls(self); ! ClearFrameBuffer(self); ! OUT(Pop); } static void PerformPop( self ) ! struct bushv *self; { ! IN(PerformPop); ! PostCursor(self,Cursor_Wait); ! Pop(self); ! bushv_RetractCursor(self,Cursor); ! OUT(PerformPop); } static long ToggleCaptionDetail( self, suite, item, datum ) ! struct bushv *self; ! struct suite *suite; ! struct suite_item *item; ! unsigned datum; { ! long int result = 0; ! IN(ToggleCaptionDetail); ! if(suite && item ) ! suite_SetItemAttribute(suite,item, ! suite_ItemCaption(FormatEntriesItem(self,NULL,0,(struct Dir_Entry*) suite_ItemAttribute(suite,item,suite_ItemDatum(0))))); ! OUT(ToggleCaptionDetail); ! return(result); } static void SortDir( self, tn ) ! struct bushv *self; ! tree_type_node tn; { ! register int (*sorter)(); ! IN(SortDir); ! sorter = DetermineSortHandler(self,tn); ! if(Object == entries_object) suite_Sort(EntriesView,0,sorter); ! suite_ChangeSuiteAttribute(EntriesView, suite_TitleCaption(FormatEntriesInfo(self,CurrNode))); ! OUT(SortDir); } static long ResetDirDetailModes( self, tree, tn, datum ) ! struct bushv *self; ! struct tree *tree; ! tree_type_node tn; ! long datum; { ! register long status = 0; ! IN(ResetDirDetailModes); ! if(tree && tn) DirDetail(tn) = -1; ! OUT(ResetDirDetailModes); ! return(status); } static void PerformDetail( self ) ! struct bushv *self; { ! int detail = 0; ! IN(PerformDetail); ! PostCursor(self,Cursor_Wait); ! sleep(1); ! if(Object == nodes_object) { ! Detail = !Detail; ! tree_Apply(Tree,NULL,ResetDirDetailModes,self,0); ! sprintf(msg,"Global detail '%s'", Detail ? "On" : "Off" ); ! bushv_Announce(self,msg); ! } ! else if(Object == entries_object) { ! if((detail = DirDetail(CurrNode)) == -1) ! DirDetail(CurrNode) = !Detail; ! else DirDetail(CurrNode) = !detail; ! suite_Apply(EntriesView,ToggleCaptionDetail,self,0); ! suite_WantUpdate(EntriesView,self); ! } ! bushv_RetractCursor(self,Cursor); ! OUT(PerformDetail); } void bushv__SetDataObject( self, bush ) ! struct bushv *self; ! struct bush *bush; { ! IN(bushv_SetDataObject); ! Bush = bush; ! treev_SetDataObject(DirTreeView,Tree); ! super_SetDataObject(self,bush); ! CurrNode = InitNode = TreeRoot; ! HandleChangeDir(self,RootPathName); ! OUT(bushv_SetDataObject); } static int SortRequested( self, tn ) ! struct bushv *self; ! tree_type_node tn; { ! int sort = -1, result = 0, current_mode = 0; ! IN(SortRequested); ! if( Object == entries_object ) { ! IgnoreFullUpdate = true; ! if(DirSortMode(CurrNode) != -1) ! current_mode = DirSortMode(CurrNode); ! else current_mode = SortMode; ! } else current_mode = SortMode; ! if(message_MultipleChoiceQuestion(self,100,"Sort By: ",current_mode, &result,sorts,NULL) != -1) ! switch(result) { ! case 0: sort = by_name; break; ! case 1: sort = by_size; break; ! case 2: sort = by_date; break; ! case 3: sort = by_suffix; break; ! case 4: sort = by_type; break; ! default: sort = -1; ! } ! OUT(SortRequested); ! return(sort); } static long ResetDirSortModes( self, tree, tn, datum ) /* ... to the globally-implied SortMode value. */ ! struct bushv *self; ! struct tree *tree; ! tree_type_node tn; ! long datum; { ! long int status = 0; ! IN(ResetDirSortModes); ! if(tree && tn) DirSortMode(tn) = -1; ! OUT(ResetDirSortModes); ! return(status); } static void PerformSort( self ) ! struct bushv *self; { ! int (*sorter)(), sMode = 0; ! IN(PerformSort); ! if(Object == entry_object) return; ! if((sMode = SortRequested(self,CurrNode)) != -1) { ! if(Object == nodes_object) { ! sprintf(msg,"Sorting by '%s' ...",sorts[SortMode = sMode]); ! bushv_Announce(self,msg); ! sorter = DetermineSortHandler(self,CurrNode); ! suite_SetSuiteAttribute(EntriesView,suite_SortHandler(sorter)); ! tree_Apply(Tree,NULL,ResetDirSortModes,self,0); ! bushv_Announce(self,""); ! return; ! } ! else if(Object == entries_object) { ! DirSortMode(CurrNode) = sMode; ! sprintf(msg,"Sorting by '%s' ...",sorts[sMode]); ! bushv_Announce(self,msg); ! im_ForceUpdate(); ! PostCursor(self,Cursor_Wait); ! SortDir(self,CurrNode); ! bushv_RetractCursor(self,Cursor); ! } ! ClearFrameBuffer(self); } ! bushv_Announce(self,""); ! OUT(PerformSort); } static void PerformRescan( self ) ! struct bushv *self; { ! struct stat stats; ! IN(PerformRescan); ! if(!CurrNode) return; ! PostCursor(self,Cursor_Wait); ! if(stat(DirPath(CurrNode),&stats)) { ! DirMode(CurrNode).stat_failed = TRUE; ! IssueError(self,"ReScanning",DirPath(CurrNode),TRUE); ! bushv_RetractCursor(self,Cursor); ! return; } ! if(Object == nodes_object || Object == entries_object) { ! sprintf(msg,"Scanning Directory '%s' ...",DirPath(CurrNode)); ! bushv_Announce(self,msg); ! if(Child(CurrNode)) { ! SetTreeNotificationData(self,CurrNode,tree_NodeChildrenDestroyed); ! NotifyTreeObservers(self); ! } ! bush_ScanDir(Bush,CurrNode); ! bush_BuildSubDirs(Bush,CurrNode); ! if(Child(CurrNode)) { ! SetTreeNotificationData(self,CurrNode,tree_NodeChildrenCreated); ! NotifyTreeObservers(self); ! } ! if(Object == entries_object) { ! ResetEntriesCaptions(self); ! SortDir(self,CurrNode); ! } ! sprintf(msg,"Finished scanning '%s'",DirPath(CurrNode)); ! bushv_Announce(self,msg); } ! else if(Object == entry_object) PushToEntry(self); ! bushv_RetractCursor(self,Cursor); ! OUT(PerformRescan); } static int ResetChildDirPaths( self, tree, tn, datum ) ! struct bushv *self; ! struct tree *tree; ! tree_type_node tn; ! long datum; { ! long int status = 0; ! char tmp_path[MAXPATHLEN]; ! IN(ResetChildDirPaths); ! if(tn && tree_NodeLevel(Tree,tn) > tree_NodeLevel(Tree,CurrNode)) { ! sprintf(tmp_path,"%s/%s",(char*)datum,DirName(tn)); ! AllocNameSpace(tmp_path,&DirPath(tn)); ! } ! else if(tn && (CurrNode == tn)) status = 0; ! else status = -1; ! OUT(ResetChildDirPaths); ! return(status); } static void PerformRename( self ) ! struct bushv *self; { ! int msg_status = 0, count = 0; ! char *response = NULL, tmp_path[MAXPATHLEN], ! *tmp = NULL; ! register struct suite_item **selected = NULL; ! struct Dir_Entry *dirEntry = NULL; ! register int i = 0; ! IN(PerformRename); ! if(!CurrNode) return; ! switch(Object) { ! case nodes_object: ! msg_status = bushv_Query(self,"New Name: ", ! DirName(CurrNode),&response); ! if(msg_status || !strcmp(response,DirName(CurrNode))) return; ! sprintf(msg,"Directory '%s' renamed to '",DirName(CurrNode)); ! strcpy(tmp_path,DirPath(CurrNode)); ! if(tmp = rindex(tmp_path,'/')) *tmp = '\0'; ! if(!bush_RenameDir(Bush,CurrNode,tmp_path,response)) { ! tree_SetNodeName(Tree,CurrNode,DirName(CurrNode)); ! SetTreeNotificationData(self,CurrNode,tree_NodeNameChanged); ! NotifyTreeObservers(self); ! strcat(msg,DirName(CurrNode)); ! strcat(msg,"'"); ! bushv_Announce(self,msg); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! tree_Apply(Tree,CurrNode,ResetChildDirPaths, ! self,strcpy(tmp_path,DirPath(CurrNode))); ! } ! else IssueError(self,"Renaming",DirName(CurrNode),TRUE); ! break; ! case entries_object: ! selected = suite_SelectedItems(EntriesView,&count); ! for( i = 0 ; (i < count) && selected[i] ; i++ ) { ! suite_PassivateItem(EntriesView,selected[i]); ! dirEntry = (struct Dir_Entry *) ! suite_ItemAttribute(EntriesView,selected[i],suite_ItemDatum(0)); ! sprintf(msg,"Renaming '%s' to '",dirEntry->name); ! msg_status = bushv_Query(self,"New Name: ", ! dirEntry->name,&response); ! if(msg_status || !strcmp(response,dirEntry->name)) { ! suite_ActivateItem(EntriesView,selected[i]); ! suite_HighlightItem(EntriesView,selected[i]); ! continue; ! } ! if(bush_MoveEntry(Bush,CurrNode,dirEntry,response) != -1) { ! strcat(msg,response); strcat(msg,"'"); ! bushv_Announce(self,msg); ! suite_ActivateItem(EntriesView,selected[i]); ! suite_HighlightItem(EntriesView,selected[i]); ! suite_ChangeItemAttribute(EntriesView,selected[i], ! suite_ItemCaption(FormatEntriesItem(self,NULL,0,dirEntry))); ! } ! else { ! IssueError(self,"Renaming",dirEntry->name,TRUE); ! suite_ActivateItem(EntriesView,selected[i]); ! suite_HighlightItem(EntriesView,selected[i]); ! } ! } ! break; ! case entry_object: ! msg_status = bushv_Query(self,"New Name: ",CurrEntry->name,&response); ! if(msg_status || !strcmp(response,CurrEntry->name)) return; ! sprintf(msg,"'%s' renamed to '",CurrEntry->name); ! if(bush_MoveEntry(Bush,CurrNode,CurrEntry,response) != -1) { ! strcat(msg,response); strcat(msg,"'"); ! bushv_Announce(self,msg); ! sprintf(msg,"%s/%s",DirPath(CurrNode),CurrEntry->name); ! suite_ChangeSuiteAttribute(ControlView,suite_TitleCaption(msg)); ! } ! else IssueError(self,"Renaming",CurrEntry->name,TRUE); ! break; ! } ! OUT(PerformRename); } static void ! ToggleDebug( self, rock ) ! struct bushv *self; ! long rock; { ! IN(ToggleDebug); ! Debug = !Debug; ! suite_SetDebug(EntriesView,TRUE); ! OUT(ToggleDebug); } struct view * bushv__GetApplicationLayer( self ) ! struct bushv *self; { ! IN(bushv_GetApplicationLayer); ! TopLevelInset = FALSE; ! OUT(bushv_GetApplicationLayer); ! return((struct view *)self); } void bushv__ReceiveInputFocus( self ) ! struct bushv *self; { ! IN(bushv_ReceiveInputFocus); ! bushv_PostMenus(self,NULL); ! OUT(bushv_ReceiveInputFocus); } static void HandleChangeDir( self, dirName ) ! register struct bushv *self; ! register char *dirName; { ! IN(HandleChangeDir); ! if(dirName && (*dirName != '\0')) ! im_ChangeDirectory(dirName); ! OUT(HandleChangeDir); } --- 1525,2656 ---- static void ResetEntriesCaptions( self ) ! struct bushv *self; { ! register int i = 0, count = 0; ! struct suite_item *item = NULL; ! IN(ResetEntriesCaptions); ! suite_Reset(EntriesView,suite_ClearItems); ! if(DirEntries(CurrNode) && ! (count = DirEntriesCount(CurrNode)) >= 0) ! for( i = 0 ; i < count ; i++ ) ! if(item = suite_CreateItem(EntriesView, ! DirEntryName(CurrNode,i),DirEntry(CurrNode,i))) ! suite_SetItemAttribute(EntriesView,item, ! suite_ItemCaption(FormatEntriesItem(self,CurrNode,i,NULL))); ! OUT(ResetEntriesCaptions); } + static int + HandleModifiedObject( self ) + register struct bushv *self; + { + int result = 0, return_value = 0; + static char *answers[] = { "Save to file.", + "Save As...", + "Don't save", + "Cancel", + NULL }; + + IN(HandleModifiedObject); + sprintf(msg,"File has been modified. Save?"); + if(message_MultipleChoiceQuestion(self,100,msg,0,&result,answers,NULL) == -1) + return_value = -1; + else + switch(result) { + case(0): + return_value = bushv_SaveFile(self); + break; + case(1): + return_value = bushv_WriteFile(self); + break; + case(2): + EntryObjectModified = EntryObjectLastCKP = 0; + break; + case(3): + default: + return_value = -1; + break; + } + OUT(HandleModifiedObject) + return(return_value); + } + static void PerformExit( self ) ! struct bushv *self; { ! IN(PerformExit); ! if(Object == entry_object) ! if(dataobject_GetModified(EntryObject) > EntryObjectModified) ! if(HandleModifiedObject(self) < 0) ! return; ! if(TopLevelInset) ! im_Destroy(bushv_GetIM(self)); ! bushv_Destroy(self); ! _exit(0); ! OUT(PerformExit); } static void SwitchDirectory( self ) ! struct bushv *self; { ! static char *question[] = {"Continue",NULL}; ! int msg_status = 0; ! long result = 0; ! char *response = NULL; ! struct stat stats; ! IN(SwitchDirectory); ! msg_status = bushv_QueryDirectoryName(self,"Switch To Directory: ",&response); ! if(msg_status) { ! return; ! } ! PostCursor(self,Cursor_Wait); ! if(stat(response,&stats)) { ! IssueError(self,"ReScanning",response,TRUE); ! bushv_RetractCursor(self,Cursor); ! return; ! } ! if((stats.st_mode & S_IFMT) != S_IFDIR) { ! sprintf(msg,"Must Change to a Directory"); ! message_MultipleChoiceQuestion(self,100,msg,0,&result,question,NULL); ! sprintf(msg,"Failed to change to '%s'",response); ! Announce(msg); ! bushv_RetractCursor(self,Cursor); ! return; ! } ! if(Object != nodes_object) { ! PopToNodes(self); PostCursor(self,Cursor_Wait); ! } ! SetTreeNotificationData(self,TreeRoot,tree_NodeDestroyed); ! NotifyTreeObservers(self); ! tree_DestroyNode(Tree,TreeRoot); ! bush_InitTree(Bush,response); ! CurrNode = InitNode = TreeRoot; ! bush_BuildSubDirs(Bush,CurrNode); ! SetTreeNotificationData(self,CurrNode,tree_NodeCreated); ! NotifyTreeObservers(self); ! suite_ChangeSuiteAttribute(ControlView, suite_TitleCaption(DirPath(CurrNode))); ! if(TopLevelInset) ! im_SetTitle(bushv_GetIM(self),DirName(CurrNode)); ! bushv_RetractCursor(self,Cursor); ! HandleChangeDir(self,RootPathName); ! OUT(SwitchDirectory); } static void SetEditor( self ) ! struct bushv *self; { ! long result = 0; ! char *response = NULL; ! IN(SetEditor); ! sprintf(msg,"Set editor to: "); ! if(message_MultipleChoiceQuestion(self,100,msg,EditorIndex, &result,EditorChoices,NULL) == -1) return; ! if(!strcmp(EditorChoices[result],"other")) { ! if(bushv_Query(self,"Set editor to: ","",&response)) return; ! AllocNameSpace(EditorChoices[NumEditorChoices-1], ! &EditorChoices[NumEditorChoices]); ! AllocNameSpace(response,&EditorChoices[NumEditorChoices-1]); ! EditorChoices[++NumEditorChoices] = NULL; ! } ! EditorIndex = result; ! strcpy(EditorProgram,EditorChoices[result]); ! if(EditorProgram && *EditorProgram != '\0') { ! struct suite_item *editorItem = NULL; ! char editorCaption[64]; ! ! if(editorItem = suite_ItemOfDatum(ControlView,&editor_data)) { ! sprintf(editorCaption,"Editor: %s",EditorProgram); ! suite_ChangeItemAttribute(ControlView, editorItem, suite_ItemCaption(editorCaption)); } ! } ! sprintf(msg,"Editor set to: '%s'",EditorProgram); ! Announce(msg); ! OUT(SetEditor); } void bushv__PostKeyState( self, kstate ) ! struct bushv *self; ! struct keystate *kstate; { ! IN(bushv_KeyState); ! keystate_AddBefore(Kstate,kstate); ! super_PostKeyState(self,Kstate); ! OUT(bushv_KeyState); } char * FormatEntriesInfo( self, tn ) ! struct bushv *self; ! tree_type_node tn; { ! static char entries_info[257]; ! register long i = 0, total_bytes = 0, count = 0; ! IN(FormatEntriesInfo); ! if(tn) { ! if(DirEntries(tn)) count = DirEntriesCount(tn); ! for( i = 0; i < count; i++ ) total_bytes += DirEntrySize(tn,i); ! sprintf(entries_info,"%d %s %d %s %s %s",count, ! "Entries",total_bytes,"Bytes","Sorted by", ! (DirSortMode(tn) != -1) ? sorts[DirSortMode(tn)] : ! sorts[SortMode]); ! } ! OUT(FormatEntriesInfo); ! return(entries_info); } static int (*DetermineSortHandler( self, tn ))() ! struct bushv *self; ! tree_type_node tn; { ! int (*sorter)(), sMode = 0; ! IN(DetermineSortHandler); ! if((sMode = DirSortMode(tn)) == -1) ! sMode = SortMode; ! switch(sMode) { ! case by_name: sorter = SortByName; break; ! case by_size: sorter = SortBySize; break; ! case by_date: sorter = SortByDate; break; ! case by_suffix: sorter = SortBySuffix; break; ! case by_type: sorter = SortByType; break; ! } ! OUT(DetermineSortHandler); ! return(sorter); ! } ! ! static void ! DoAutoRescan( self ) ! register struct bushv *self; ! { ! register struct suite_item **selected = NULL, *item = NULL; ! register char **names = NULL; ! int count = 0; ! register int i; ! ! IN(DoAutoRescan); ! if(ScanRequired(CurrNode)) { ! if(Object == entries_object) { ! selected = suite_SelectedItems(EntriesView,&count); ! names = (char**)calloc(count,sizeof(char*)); ! for(i = 0; i < count; i++) ! AllocNameSpace( suite_ItemAttribute(EntriesView, selected[i], suite_ItemCaption(0)), &names[i] ); } ! PerformRescan(self); ! if(Object == entries_object) ! for(i = 0; i < count; i++) { ! if(item = suite_ItemOfName(EntriesView,names[i])) ! suite_HighlightItem(EntriesView,item); ! free(names[i]); ! names[i] = NULL; ! } ! if(names) { ! free(names); ! names = NULL; ! } ! if(selected) { ! free(selected); ! selected = NULL; ! } ! } ! IN(DoAutoRescan); } static void PushToEntries( self ) ! struct bushv *self; { ! register int (*sorter)(); ! IN(PushToEntries); ! if(EntriesView) { ! sorter = DetermineSortHandler(self,CurrNode); ! suite_SetSuiteAttribute(EntriesView,suite_SortHandler(sorter)); ! if(DirDetail(CurrNode) >= 0 && Detail != DirDetail(CurrNode)) ! UpdateDetailCaption(self,DirDetail(CurrNode)); ! Object = entries_object; ! ResetEntriesCaptions(self); ! suite_SetSuiteAttribute(EntriesView, suite_TitleCaption(FormatEntriesInfo(self,CurrNode))); ! lpair_SetNth(LP,1,(struct view*)EntriesView); ! DoAutoRescan(self); ! bushv_WantInputFocus(self,EntriesView); ! } ! OUT(PushToEntries); } static void PushToEntry( self ) ! struct bushv *self; { ! char file_name[MAXPATHLEN]; ! char *objectName = NULL; ! long objectID = 0; ! IN(PushToEntry); ! PostCursor(self,Cursor_Wait); ! Object = entry_object; ! sprintf(file_name,"%s/%s",DirPath(CurrNode),CurrEntry->name); ! sprintf(msg,"reading '%s'",file_name); ! Announce(msg); ! if(EntryFilep = fopen(file_name,"r")) { ! if(!(objectName = filetype_Lookup( EntryFilep, file_name, ! &objectID, NULL))) ! objectName = "text"; ! if(EntryView) { ! if(view_IsAncestor(EntryViewAppLayer,self)) ! lpair_SetNth(LP,1,NULL); ! view_DeleteApplicationLayer(EntryView,EntryViewAppLayer); ! view_Destroy(EntryView); ! EntryView = EntryViewAppLayer = NULL; ! dataobject_Destroy(EntryObject); ! EntryObject = NULL; } ! if(!(EntryObject = (struct dataobject*)class_NewObject(objectName)) || ! !(EntryView = (struct view*) ! class_NewObject(dataobject_ViewName(EntryObject)))) { ! IssueError(self,"Allocating Object",objectName,TRUE); ! Object = entries_object; } ! else { /*success*/ ! struct attributes templateAttr, readWriteAttr; ! ! dataobject_Read(EntryObject,EntryFilep,objectID); ! view_SetDataObject(EntryView,EntryObject); ! readWriteAttr.next = NULL; ! readWriteAttr.key = "readonly"; ! if((access(file_name,W_OK) == -1) && (errno == EACCES)) { ! readWriteAttr.value.integer = 1; ! menulist_SetMask(Menulist,0); ! } ! else { ! if(!strcmp(objectName,"text") || !strcmp(objectName,"ctext")) { ! readWriteAttr.next = &templateAttr; ! templateAttr.next = NULL; ! templateAttr.key = "template"; ! templateAttr.value.string = "default"; ! } ! readWriteAttr.value.integer = 0; ! menulist_SetMask(Menulist,bushv_RWEntryMenus); ! if(CkpInterval != 0) ! im_EnqueueEvent(Checkpoint,(long)self,event_SECtoTU(CkpInterval)); ! } ! dataobject_SetAttributes(EntryObject,&readWriteAttr); ! lpair_SetNth(LP,1, ! EntryViewAppLayer = view_GetApplicationLayer(EntryView)); ! bushv_WantInputFocus(self,EntryView); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(file_name)); ! } ! EntryObjectModified = EntryObjectLastCKP = dataobject_GetModified(EntryObject); ! } ! else { ! IssueError(self,"Opening Entry",CurrEntry->name,TRUE); ! Object = entries_object; ! } ! ClearMessageLine(); ! bushv_RetractCursor(self,Cursor); ! OUT(PushToEntry); } ! static int PopToNodes( self ) ! struct bushv *self; { ! int status = 0; ! ! IN(PopToNodes); ! if(DirTreeView) { ! Object = nodes_object; ! CurrEntry = NULL; ! if(DirDetail(CurrNode) >= 0 && Detail != DirDetail(CurrNode)) ! UpdateDetailCaption(self,Detail); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! lpair_SetNth(LP,1,(struct view*)DirTreeView); ! DoAutoRescan(self); ! bushv_WantInputFocus(self,DirTreeView); ! } ! OUT(PopToNodes); ! return(status); } ! static int PopToEntries( self ) ! struct bushv *self; { ! int status = 0; ! ! IN(PopToEntries); ! if(Object == entry_object) ! if(dataobject_GetModified(EntryObject) > EntryObjectModified) ! if((status = HandleModifiedObject(self)) < 0) ! return(status); ! if(EntryFilep) { ! fclose(EntryFilep); ! EntryFilep = NULL; ! } ! if(EntriesView) { ! Object = entries_object; ! lpair_SetNth(LP,1,(struct view*)EntriesView); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! DoAutoRescan(self); ! bushv_WantInputFocus(self,EntriesView); ! } ! OUT(PopToEntries); ! return(status); } static long Passivator( self, suite, item, datum ) ! /*============================================================ ! I set the item_data attribute, active, of the ControlView items to be the OR'ed sum of the Object-codes for which the particular item is active. If a button is active during both the nodes_object(1) and entries_object(2) then it's data field is set to (nodes_object + entries_Object) = 1 + 2 = 3. This is how I implemented automatic button "Passivation" in bush. It has been proposed that this feature be incorporated into suite (3/29/89). ! =============================================================*/ ! struct bushv *self; ! struct suite *suite; ! struct suite_item *item; ! unsigned datum; { ! struct item_data *itemData = NULL; ! long int result = 0; ! if(suite && item) { ! itemData = (struct item_data*) suite_ItemAttribute(suite, item, suite_ItemData(0)); ! if(itemData && (itemData->activate & Object)) ! suite_ActivateItem(suite,item); ! else suite_PassivateItem(suite,item); ! } ! return(result); } static void PassivateControls( self ) ! struct bushv *self; { ! IN(PassivateControls); ! suite_Apply(ControlView,Passivator,self,NULL); ! suite_Reset(ControlView,suite_Normalize); ! OUT(PassivateControls); } static void Push( self ) ! register struct bushv *self; { ! register tree_type_node tn = NULL; ! char *name = NULL; ! IN(Push); ! switch(Object) { ! case nodes_object: ! PushToEntries(self); ! break; ! case entries_object: ! if(EntryDirType(CurrEntry)) { ! AllocNameSpace(CurrEntry->name,&name); ! PostCursor(self,Cursor_Wait); ! Pop(self); ! tn = Child(CurrNode); ! while(tn) ! if(!strcmp(DirName(tn),name)) break; ! else ! tn = Right(tn); ! if(tn) { ! TreeHitHandler(self,DirTreeView,tn, ! treev_NodeObject,view_LeftUp,0,0,0); ! treev_HighlightNode(DirTreeView,tn); ! } ! else { ! sprintf(msg,"Couldn't locate directory node '%s'.",CurrEntry->name); ! Announce(msg); ! } ! bushv_RetractCursor(self,Cursor); ! } ! else PushToEntry(self); ! break; ! } ! if(name) free(name); ! PassivateControls(self); ! ClearMessageLine(); ! OUT(Push); } static void Pop( self ) ! struct bushv *self; { ! int status = 0; ! ! IN(Pop); ! switch(Object) { ! case entries_object: ! status = PopToNodes(self); break; ! case entry_object: ! status = PopToEntries(self); break; ! } ! if(status == 0) { PassivateControls(self); ! ClearMessageLine(); ! } ! OUT(Pop); } static void PerformPop( self ) ! struct bushv *self; { ! IN(PerformPop); ! PostCursor(self,Cursor_Wait); ! Pop(self); ! bushv_RetractCursor(self,Cursor); ! OUT(PerformPop); } static long ToggleCaptionDetail( self, suite, item, datum ) ! struct bushv *self; ! struct suite *suite; ! struct suite_item *item; ! unsigned datum; { ! long int result = 0; ! IN(ToggleCaptionDetail); ! if(suite && item ) ! suite_SetItemAttribute(suite,item, ! suite_ItemCaption(FormatEntriesItem(self,NULL,0,(struct Dir_Entry*) suite_ItemAttribute(suite,item,suite_ItemDatum(0))))); ! OUT(ToggleCaptionDetail); ! return(result); } static void SortDir( self, tn ) ! struct bushv *self; ! tree_type_node tn; { ! register int (*sorter)(); ! IN(SortDir); ! sorter = DetermineSortHandler(self,tn); ! if(Object == entries_object) suite_Sort(EntriesView,0,sorter); ! suite_ChangeSuiteAttribute(EntriesView, suite_TitleCaption(FormatEntriesInfo(self,CurrNode))); ! OUT(SortDir); } static long ResetDirDetailModes( self, tree, tn, datum ) ! struct bushv *self; ! struct tree *tree; ! tree_type_node tn; ! long datum; { ! register long status = 0; ! IN(ResetDirDetailModes); ! if(tree && tn) DirDetail(tn) = -1; ! OUT(ResetDirDetailModes); ! return(status); } static void PerformDetail( self ) ! struct bushv *self; { ! int detail = 0; ! IN(PerformDetail); ! PostCursor(self,Cursor_Wait); ! if(Object == nodes_object) { ! detail = Detail = !Detail; ! tree_Apply(Tree,NULL,ResetDirDetailModes,self,0); ! sprintf(msg,"Global detail '%s'", Detail ? "On" : "Off" ); ! Announce(msg); ! } ! else if(Object == entries_object) { ! if((detail = DirDetail(CurrNode)) == -1) ! detail = DirDetail(CurrNode) = !Detail; ! else detail = DirDetail(CurrNode) = !detail; ! suite_Apply(EntriesView,ToggleCaptionDetail,self,0); ! bushv_WantUpdate(self,EntriesView); ! } ! UpdateDetailCaption(self,detail); ! bushv_RetractCursor(self,Cursor); ! OUT(PerformDetail); } void bushv__SetDataObject( self, bush ) ! struct bushv *self; ! struct bush *bush; { ! IN(bushv_SetDataObject); ! Bush = bush; ! treev_SetDataObject(DirTreeView,Tree); ! super_SetDataObject(self,bush); ! CurrNode = InitNode = TreeRoot; ! HandleChangeDir(self,RootPathName); ! OUT(bushv_SetDataObject); } static int SortRequested( self, tn ) ! struct bushv *self; ! tree_type_node tn; { ! int sort = -1, result = 0, current_mode = 0; ! IN(SortRequested); ! if( Object == entries_object ) { ! if(DirSortMode(CurrNode) != -1) ! current_mode = DirSortMode(CurrNode); else current_mode = SortMode; ! } ! else current_mode = SortMode; ! if(message_MultipleChoiceQuestion(self,100,"Sort By: ",current_mode, &result,sorts,NULL) != -1) ! switch(result) { ! case 0: sort = by_name; break; ! case 1: sort = by_size; break; ! case 2: sort = by_date; break; ! case 3: sort = by_suffix; break; ! case 4: sort = by_type; break; ! default: sort = -1; ! } ! OUT(SortRequested); ! return(sort); } static long ResetDirSortModes( self, tree, tn, datum ) /* ... to the globally-implied SortMode value. */ ! struct bushv *self; ! struct tree *tree; ! tree_type_node tn; ! long datum; { ! long int status = 0; ! IN(ResetDirSortModes); ! if(tree && tn) DirSortMode(tn) = -1; ! OUT(ResetDirSortModes); ! return(status); } static void PerformSort( self ) ! struct bushv *self; { ! int (*sorter)(), sMode = 0; ! struct suite_item *sortItem = NULL; ! char sortCaption[16]; ! IN(PerformSort); ! if((sMode = SortRequested(self,CurrNode)) != -1) { ! strcpy(sortCaption,"Sort: "); ! if(Object == nodes_object) { ! sprintf(msg,"Sorting by '%s' ...",sorts[SortMode = sMode]); ! Announce(msg); ! strcat(sortCaption,sorts[SortMode]); ! sorter = DetermineSortHandler(self,CurrNode); ! suite_SetSuiteAttribute(EntriesView,suite_SortHandler(sorter)); ! tree_Apply(Tree,NULL,ResetDirSortModes,self,0); ! ClearMessageLine(); } ! else if(Object == entries_object) { ! DirSortMode(CurrNode) = sMode; ! strcat(sortCaption,sorts[sMode]); ! sprintf(msg,"Sorting by '%s' ...",sorts[sMode]); ! Announce(msg); ! im_ForceUpdate(); ! PostCursor(self,Cursor_Wait); ! SortDir(self,CurrNode); ! bushv_RetractCursor(self,Cursor); ! } ! if(sortItem = suite_ItemOfDatum(ControlView,&sort_data)) ! suite_ChangeItemAttribute(ControlView, sortItem, suite_ItemCaption(sortCaption)); ! } ! ClearMessageLine(); ! OUT(PerformSort); } static void PerformRescan( self ) ! struct bushv *self; { ! struct stat stats; ! IN(PerformRescan); ! if(!CurrNode) return; ! PostCursor(self,Cursor_Wait); ! if(stat(DirPath(CurrNode),&stats)) { ! DirMode(CurrNode).stat_failed = TRUE; ! IssueError(self,"ReScanning",DirPath(CurrNode),TRUE); ! bushv_RetractCursor(self,Cursor); ! return; ! } ! if(Object == nodes_object || Object == entries_object) { ! sprintf(msg,"Scanning Directory '%s' ...",DirPath(CurrNode)); ! Announce(msg); ! if(Child(CurrNode)) { ! SetTreeNotificationData(self,CurrNode,tree_NodeChildrenDestroyed); ! NotifyTreeObservers(self); } ! bush_ScanDir(Bush,CurrNode); ! bush_BuildSubDirs(Bush,CurrNode); ! if(Child(CurrNode)) { ! SetTreeNotificationData(self,CurrNode,tree_NodeChildrenCreated); ! NotifyTreeObservers(self); } ! if(Object == entries_object) { ! ResetEntriesCaptions(self); ! SortDir(self,CurrNode); ! } ! sprintf(msg,"Finished scanning '%s'",DirPath(CurrNode)); ! Announce(msg); ! } ! else if(Object == entry_object) PushToEntry(self); ! bushv_RetractCursor(self,Cursor); ! OUT(PerformRescan); } static int ResetChildDirPaths( self, tree, tn, datum ) ! struct bushv *self; ! struct tree *tree; ! tree_type_node tn; ! long datum; { ! long int status = 0; ! char tmp_path[MAXPATHLEN]; ! IN(ResetChildDirPaths); ! if(tn && tree_NodeLevel(Tree,tn) > tree_NodeLevel(Tree,CurrNode)) { ! sprintf(tmp_path,"%s/%s",(char*)datum,DirName(tn)); ! AllocNameSpace(tmp_path,&DirPath(tn)); ! } ! else if(tn && (CurrNode == tn)) status = 0; ! else status = -1; ! OUT(ResetChildDirPaths); ! return(status); } static void PerformRename( self ) ! struct bushv *self; { ! int msg_status = 0, count = 0; ! char *response = NULL; ! char tmp_path[MAXPATHLEN],*tmp = NULL; ! register struct suite_item **selected = NULL; ! struct Dir_Entry *dirEntry = NULL; ! register int i = 0; ! IN(PerformRename); ! if(!CurrNode) return; ! switch(Object) { ! case nodes_object: ! msg_status = bushv_Query(self,"New Name: ", ! DirName(CurrNode),&response); ! if(msg_status || !strcmp(response,DirName(CurrNode))) return; ! sprintf(msg,"Directory '%s' renamed to '",DirName(CurrNode)); ! strcpy(tmp_path,DirPath(CurrNode)); ! if(tmp = rindex(tmp_path,'/')) *tmp = '\0'; ! if(!bush_RenameDir(Bush,CurrNode,tmp_path,response)) { ! tree_SetNodeName(Tree,CurrNode,DirName(CurrNode)); ! SetTreeNotificationData(self,CurrNode,tree_NodeNameChanged); ! NotifyTreeObservers(self); ! strcat(msg,DirName(CurrNode)); ! strcat(msg,"'"); ! Announce(msg); ! suite_ChangeSuiteAttribute(ControlView, ! suite_TitleCaption(DirPath(CurrNode))); ! tree_Apply(Tree,CurrNode,ResetChildDirPaths, ! self,strcpy(tmp_path,DirPath(CurrNode))); ! } ! else IssueError(self,"Renaming",DirName(CurrNode),TRUE); ! break; ! case entries_object: ! selected = suite_SelectedItems(EntriesView,&count); ! for( i = 0 ; (i < count) && selected[i] ; i++ ) { ! suite_PassivateItem(EntriesView,selected[i]); ! dirEntry = (struct Dir_Entry *) ! suite_ItemAttribute(EntriesView,selected[i],suite_ItemDatum(0)); ! sprintf(msg,"Renaming '%s' to '",dirEntry->name); ! msg_status = bushv_Query(self,"New Name: ", ! dirEntry->name,&response); ! if(msg_status || !strcmp(response,dirEntry->name)) { ! suite_ActivateItem(EntriesView,selected[i]); ! suite_HighlightItem(EntriesView,selected[i]); ! continue; ! } ! if(bush_MoveEntry(Bush,CurrNode,dirEntry,response) != -1) { ! strcat(msg,response); strcat(msg,"'"); ! Announce(msg); ! suite_ActivateItem(EntriesView,selected[i]); ! suite_HighlightItem(EntriesView,selected[i]); ! suite_ChangeItemAttribute(EntriesView,selected[i], ! suite_ItemCaption(FormatEntriesItem(self,NULL,0,dirEntry))); ! } ! else { ! IssueError(self,"Renaming",dirEntry->name,TRUE); ! suite_ActivateItem(EntriesView,selected[i]); ! suite_HighlightItem(EntriesView,selected[i]); ! } ! } ! break; ! case entry_object: ! msg_status = bushv_Query(self,"New Name: ",CurrEntry->name,&response); ! if(msg_status || !strcmp(response,CurrEntry->name)) return; ! sprintf(msg,"'%s' renamed to '",CurrEntry->name); ! if(bush_MoveEntry(Bush,CurrNode,CurrEntry,response) != -1) { ! strcat(msg,response); strcat(msg,"'"); ! Announce(msg); ! sprintf(msg,"%s/%s",DirPath(CurrNode),CurrEntry->name); ! suite_ChangeSuiteAttribute(ControlView,suite_TitleCaption(msg)); ! } ! else IssueError(self,"Renaming",CurrEntry->name,TRUE); ! break; ! } ! OUT(PerformRename); } static void ! ToggleDebug( self ) ! struct bushv *self; { ! IN(ToggleDebug); ! Debug = !Debug; ! suite_SetDebug(EntriesView,TRUE); ! OUT(ToggleDebug); } struct view * bushv__GetApplicationLayer( self ) ! struct bushv *self; { ! IN(bushv_GetApplicationLayer); ! TopLevelInset = FALSE; ! OUT(bushv_GetApplicationLayer); ! return((struct view *)self); } void bushv__ReceiveInputFocus( self ) ! struct bushv *self; { ! IN(bushv_ReceiveInputFocus); ! super_ReceiveInputFocus(self); ! OUT(bushv_ReceiveInputFocus); } static void HandleChangeDir( self, dirName ) ! register struct bushv *self; ! register char *dirName; { ! IN(HandleChangeDir); ! if(dirName && (*dirName != '\0')) ! im_ChangeDirectory(dirName); ! OUT(HandleChangeDir); ! } ! ! static int ! bushv_WriteToFile( self, filename ) ! struct bushv *self; ! char *filename; ! { ! char realName[MAXPATHLEN],tempFilename[MAXPATHLEN]; ! char *originalFilename = NULL, *endString, *basename; ! int closeCode, errorCode, originalMode, fd, counter = 1; ! FILE *outFile; ! struct stat statBuf; ! ! IN(bushv_WriteToFile); ! errorCode = 0; ! filetype_CanonicalizeFilename(realName,filename,sizeof(realName) - 1); ! filename = realName; ! if((access(filename,W_OK) < 0) && (errno == EACCES)) ! return(-1); ! if(stat(filename,&statBuf) >= 0) ! originalMode = statBuf.st_mode & (~S_IFMT); ! else originalMode = 0666; ! #ifndef USESHORTFILENAMES ! strcpy(tempFilename,filename); ! strcat(tempFilename,".NEW"); ! endString = tempFilename + strlen(tempFilename); ! while(access(tempFilename,F_OK) >= 0) /* While the file exists. */ ! sprintf(endString,".%d",counter++); ! #else /* USESHORTFILENAMES */ ! strcpy(tempFilename,filename); ! basename = rindex(tempFilename,'/'); ! if(!basename) basename = tempFilename; ! else basename++; ! if(strlen(basename) > 8) basename[8] = '\0'; ! strcat(tempFilename,".NEW"); ! endString = tempFilename + strlen(tempFilename); ! while(access(tempFilename,F_OK) >= 0 && counter < 10) ! sprintf(endString,".%d", counter++); ! if(counter == 10) return(-1); ! #endif /* USESHORTFILENAMES */ ! originalFilename = filename; ! filename = tempFilename; ! if((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT,originalMode)) < 0 ! || (outFile = fdopen(fd,"w")) == NULL) ! return(-1); ! dataobject_Write(EntryObject,outFile,im_GetWriteID(),0); ! fflush(outFile); ! if(ferror(outFile)) { ! fclose(outFile); ! errorCode = 0; ! closeCode = -1; ! } ! else { ! #ifdef AFS_ENV ! if((closeCode = vclose(fileno(outFile))) < 0) /* stdio can trash errno. */ ! errorCode = errno; /* Protect it from the fclose below. */ ! else if(originalFilename != NULL) ! if((closeCode = rename(filename, originalFilename)) < 0) ! errorCode = errno; ! #else /* AFS_ENV */ ! if((closeCode = close(fileno(outFile))) < 0) /* stdio can trash errno. */ ! errorCode = errno; /* Protect it from the fclose below. */ ! else if(originalFilename != NULL) ! if((closeCode = rename(filename, originalFilename)) < 0) ! errorCode = errno; ! #endif /* AFS_ENV */ ! fclose(outFile); /* Free stdio resources. */ ! if(closeCode >= 0) { /* Reset readonly mode. */ ! struct attributes attributes; ! ! attributes.next = NULL; ! attributes.key = "readonly"; ! if(access(filename,W_OK) == -1 && errno == EACCES) ! attributes.value.integer = TRUE; ! else attributes.value.integer = FALSE; ! dataobject_SetAttributes(EntryObject,&attributes); ! EntryObjectModified = dataobject_GetModified(EntryObject); ! } ! } ! sprintf(tempFilename,"%s.CKP",filename); ! if(access(tempFilename,F_OK) >= 0) ! unlink(tempFilename); ! errno = errorCode; ! OUT(bushv_WriteToFile); ! return(closeCode); ! } ! ! #define DIR_MSG \ ! "Write aborted: specified output file is a directory." ! ! static int ! bushv_SaveFile( self ) ! struct bushv *self; ! { ! int result = 0, return_value = 0; ! char message[sizeof("Wrote file ''.") + sizeof("Could not save file") + MAXPATHLEN]; ! char fName[MAXPATHLEN]; ! char *filename; ! struct stat statbuf; ! ! IN(bushv_SaveFile); ! sprintf(fName,"%s/%s",DirPath(CurrNode), CurrEntry->name); ! filename = fName; ! if(stat(filename, &statbuf) == 0 && (statbuf.st_mode & S_IFDIR)) { ! Announce(DIR_MSG); ! return(-1); ! } ! PostCursor(self,Cursor_Wait); ! result = bushv_WriteToFile(self,filename); ! if(result >= 0) { ! sprintf(message, "Wrote file '%.*s'", MAXPATHLEN, filename); ! Announce(message); ! } ! else { ! switch (errno) { ! case EACCES: ! Announce("Could not save file; permission denied."); ! break; ! #ifdef ETIMEDOUT ! case ETIMEDOUT: ! Announce("Could not save file; a server is down."); ! break; ! #endif /* ETIMEDOUT */ ! #ifdef EFAULT ! case EFAULT: ! Announce("Could not save file; a server is down."); ! break; ! #endif /* EFAULT */ ! #ifdef EDQUOT ! case EDQUOT: ! Announce("Could not save file; you are over your quota."); ! break; ! #endif /* EDQUOT */ ! case ENOSPC: ! Announce("Could not save file; no space left on partition."); ! break; ! #ifdef EIO ! case EIO: ! Announce("Could not save file; an I/O error occurred on the disk."); ! break; ! #endif /* EIO */ ! case EISDIR: ! Announce("File not found; could not create. Attempt to write to a directory."); ! break; ! default: ! sprintf(message, "Could not save file: %s.",sys_errlist[errno]); ! Announce(message); ! } ! return_value = -1; ! } ! bushv_RetractCursor(self,Cursor); ! OUT(bushv_SaveFile); ! return(return_value); ! } ! ! static int ! bushv_WriteFile( self ) ! struct bushv *self; ! { ! char filename[MAXPATHLEN]; ! char message[sizeof("Wrote file ''.") + sizeof("Could not save file") + MAXPATHLEN]; ! int result = 0, return_value = 0; ! ! IN(bushv_WriteFile); ! sprintf(filename,"%s/%s",DirPath(CurrNode),CurrEntry->name); ! if(completion_GetFilename(self, "Write to file: ", filename, filename, ! sizeof(filename), FALSE, FALSE) == -1) ! return(-1); ! PostCursor(self,Cursor_Wait); ! result = bushv_WriteToFile(self,filename); ! if(result >= 0) { ! sprintf(message, "Wrote file '%.*s'", MAXPATHLEN, filename); ! Announce(message); ! } ! else { ! switch (errno) { ! case EACCES: ! Announce("Could not save file; permission denied."); ! break; ! #ifdef ETIMEDOUT ! case ETIMEDOUT: ! Announce("Could not save file; a server is down."); ! break; ! #endif /* ETIMEDOUT */ ! #ifdef EFAULT ! case EFAULT: ! Announce("Could not save file; a server is down."); ! break; ! #endif /* EFAULT */ ! #ifdef EDQUOT ! case EDQUOT: ! Announce("Could not save file; you are over your quota."); ! break; ! #endif /* EDQUOT */ ! case ENOSPC: ! Announce("Could not save file; no space left on partition."); ! break; ! #ifdef EIO ! case EIO: ! Announce("Could not save file; an I/O error occurred on the disk."); ! break; ! #endif /* EIO */ ! case EISDIR: ! Announce("File not found; could not create. Attempt to write to a directory."); ! break; ! default: ! sprintf(message, "Could not save file: %s.",sys_errlist[errno]); ! Announce(message); ! } ! return_value = -1; ! } ! bushv_RetractCursor(self,Cursor); ! OUT(bushv_WriteFile); ! return(return_value); ! } ! ! static int ! bushv_SetPrinter(self) ! struct bushv *self; ! { ! char *currentPrinter, *defaultPrinter, answer[256]; ! char prompt[sizeof("Current printer is . Set printer to []: ") + 128]; ! int return_value = 0; ! ! currentPrinter = environ_Get("PRINTER"); ! defaultPrinter = environ_GetProfile("print.spooldir"); ! if((currentPrinter != NULL) && (defaultPrinter != NULL)) ! sprintf(prompt,"Current printer is %.64s. Set printer to [%.64s]: ", currentPrinter,defaultPrinter); ! else if(defaultPrinter != NULL) ! sprintf(prompt,"Set printer to [%.64s]: ",defaultPrinter); ! else strcpy(prompt,"Set printer to: "); ! if(message_AskForString(self,0,prompt,NULL,answer,sizeof(answer)) == -1) ! return; ! if(*answer != '\0') { ! environ_Put("PRINTER",answer); ! defaultPrinter = answer; ! } ! else environ_Delete("PRINTER"); ! if(defaultPrinter != NULL) { ! sprintf(prompt,"Printer set to %.64s.",defaultPrinter); ! Announce(prompt); ! } ! else { ! Announce("Printer not set."); ! return_value = -1; ! } ! return(return_value); ! } ! ! static void ! Checkpoint( dummyData ) ! long dummyData; ! { ! struct bushv *self = (struct bushv*)dummyData; ! char CkpFileName[MAXPATHLEN]; ! int closeCode; ! ! if(Object == entry_object) { ! if(dataobject_GetModified(EntryObject) > EntryObjectLastCKP) { ! PostCursor(self,Cursor_Wait); ! Announce("Checkpointing ..."); ! im_ForceUpdate(); ! sprintf(CkpFileName,"%s/%s.CKP",DirPath(CurrNode),CurrEntry->name); ! closeCode = bushv_WriteToFile(self,CkpFileName); ! Announce(closeCode ? "Checkpoint Failed." : "Checkpointed."); ! bushv_RetractCursor(self,Cursor); ! EntryObjectLastCKP = dataobject_GetModified(EntryObject); ! } ! im_EnqueueEvent(Checkpoint,(long)self,event_SECtoTU(CkpInterval)); ! } ! } ! ! static void ! UpdateDetailCaption( self, detail ) ! struct bushv *self; ! boolean detail; ! { ! struct suite_item *detailItem = NULL; ! char newCaption[16]; ! ! if(detailItem = suite_ItemOfDatum(ControlView,&detail_data)) { ! strcpy(newCaption,"Detail: "); ! if(detail) strcat(newCaption,"on"); ! else strcat(newCaption,"off"); ! suite_ChangeItemAttribute(ControlView, detailItem, suite_ItemCaption(newCaption)); ! } } *** atk/bush/bushv.ch Wed Apr 11 14:18:49 1990 --- atk/bush/bushv.ch.NEW Thu May 10 16:24:44 1990 *************** *** 7,37 **** /* $Source $ */ #ifndef lint ! static char *rcsidbushv_ch = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bushv.ch,v 1.5 90/03/05 11:18:34 gk5g Exp $"; #endif - /* - $Log: bushv.ch,v $ - Revision 1.5 90/03/05 11:18:34 gk5g - Follow soft links correctly now. - - Revision 1.4 89/09/08 13:38:01 gk5g - Added entry_filep to keep a handle of the currently visited file. - - Revision 1.3 89/07/28 15:45:54 gk5g - Added new instance variables to hold state regarding the new and improved way in which we handle viewing entries (files). Now we simply have a generic view and dataobject pair, as well as a ApplicationLayer view pointer. The added functionality allows the proper ApplicationLayer to be used when view a specific view-type. That is, now the rasterview is used instead of just relying on textview to do something like this for us. - - Revision 1.2 89/07/14 14:05:24 gk5g - Added new instance var, tree_type_node move_node, to support directory mv'ing from the nodes_level. - - Revision 1.1 89/04/28 21:24:09 tom - Initial revision - - Revision 1.1 89/04/28 21:20:44 tom - Initial revision - - */ - /** SPECIFICATION -- External Facility Suite ********************************* TITLE The Bush View-object --- 7,15 ---- /* $Source $ */ #ifndef lint ! static char *rcsidbushv_ch = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bushv.ch,v 1.7 90/05/08 12:19:54 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* TITLE The Bush View-object *************** *** 60,109 **** 01/15/89 Convert to ATK (GW Keim) END-SPECIFICATION ************************************************************/ - #define MAXEDITORS 25 ! class bushv: aptv{ ! classprocedures: ! InitializeClass() returns boolean; ! InitializeObject( struct bushv *self ) returns boolean; ! FinalizeObject( struct bushv *self ) returns void; ! Create( char object ) returns struct bushv *; ! overrides: ! FullUpdate( enum view_UpdateType Type, long left, long top, long width, long height ) returns void; ! Hit( enum view_MouseAction action, long x, long y, long numberOfClicks ) returns struct view *; ! PostMenus( struct menulist *menulist ) returns void; ! PostKeyState( struct keystate *kstate ) returns void; ! SetDataObject( struct bush *bush ) returns void; ! GetApplicationLayer() returns struct view *; ! ReceiveInputFocus() returns void; ! data: ! struct bush *bush; ! tree_type_node current_node, initial_node, move_node; ! struct Dir_Entry *current_entry; ! int editor_index; ! int num_editor_choices; ! char editor_program[1025]; ! char *editor_choices[MAXEDITORS]; ! struct suite *control_view; ! struct suite *entries_view; ! struct treev *dir_tree_view; ! struct view *entry_view, *entry_view_application_layer; ! struct dataobject *entry; ! FILE *entry_filep; ! int num_prev_selected; ! struct lpair *lp; ! int object; ! int sortmode; ! struct keystate *keyState; ! struct keymap *kmap; ! struct cursor *cursor; ! struct menulist *menulist; ! boolean detail; ! boolean top_level_inset, ignore_fullupdate; ! int debug; }; --- 38,88 ---- 01/15/89 Convert to ATK (GW Keim) END-SPECIFICATION ************************************************************/ #define MAXEDITORS 25 ! class bushv : aptv { ! classprocedures: ! InitializeClass() returns boolean; ! InitializeObject( struct bushv *self ) returns boolean; ! FinalizeObject( struct bushv *self ) returns void; ! Create( char object ) returns struct bushv *; ! overrides: ! FullUpdate( enum view_UpdateType Type, long left, long top, long width, long height ) returns void; ! Hit( enum view_MouseAction action, long x, long y, long numberOfClicks ) returns struct view *; ! PostMenus( struct menulist *menulist ) returns void; ! PostKeyState( struct keystate *kstate ) returns void; ! SetDataObject( struct bush *bush ) returns void; ! GetApplicationLayer() returns struct view *; ! ReceiveInputFocus() returns void; ! data: ! struct bush *bush; ! tree_type_node current_node, initial_node, move_node; ! struct Dir_Entry *current_entry; ! int editor_index; ! int num_editor_choices; ! char editor_program[1025]; ! char *editor_choices[MAXEDITORS]; ! struct suite *control_view; ! struct suite *entries_view; ! struct treev *dir_tree_view; ! struct view *entry_view, *entry_view_application_layer; ! struct dataobject *entry; ! long entry_object_modified; ! long entry_object_last_checkpoint; ! FILE *entry_filep; ! int num_prev_selected; ! struct lpair *lp; ! int object; ! int sortmode; ! struct keystate *keyState; ! struct keymap *kmap; ! struct cursor *cursor; ! struct menulist *menulist; ! boolean detail; ! boolean top_level_inset; ! int debug; }; *** atk/bush/bushapp.c Wed Apr 11 14:18:50 1990 --- atk/bush/bushapp.c.NEW Sat May 12 17:31:22 1990 *************** *** 4,10 **** \* ********************************************************************** */ #ifndef lint ! static char *rcsidbushapp_c = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bushapp.c,v 1.7 90/03/27 14:09:51 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* --- 4,10 ---- \* ********************************************************************** */ #ifndef lint ! static char *rcsidbushapp_c = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bushapp.c,v 1.9 90/05/12 17:30:06 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* *************** *** 13,25 **** MODULE bushapp.c ! VERSION 0.0 AUTHOR TC Peters & GW Keim Information Technology Center, Carnegie-Mellon University DESCRIPTION ! This is the Application layer for the Bush Inset.. NB: The comment-symbol "===" indicates areas which are: 1 - Questionable --- 13,25 ---- MODULE bushapp.c ! VERSION 1.0 AUTHOR TC Peters & GW Keim Information Technology Center, Carnegie-Mellon University DESCRIPTION ! This is the Application layer for the Bush Inset. NB: The comment-symbol "===" indicates areas which are: 1 - Questionable *************** *** 41,138 **** 09/07/89 Set V1.0 msg (TCP) END-SPECIFICATION ************************************************************/ - - #include #include ! #include "bush.h" ! #include "im.ih" ! #include "view.ih" ! #include "frame.ih" ! #include "tree.ih" ! #include "bush.ih" ! #include "bushv.ih" ! #include "bushapp.eh" #define Bush ((self)->bush) #define Debug ((self)->debug) - #define ProgramName ((self)->program_name) - #define CW ((self)->current_window) - #define NodesWindow ((self)->nodes_window) - #define EntriesWindow ((self)->entries_window) - #define EntryWindow ((self)->entry_window) #define imPtr ((self)->im) #define framePtr ((self)->frame) ! #define nodes_object 1 ! #define entries_object 2 ! #define entry_object 4 boolean bushapp__InitializeObject( ClassID, self ) ! struct classheader *ClassID; ! struct bushapp *self; { ! Bush = NULL; ! imPtr = NULL; ! framePtr = NULL; ! Debug = 0; ! *ProgramName = NULL; ! CW = NodesWindow = EntriesWindow = EntryWindow = NULL; ! bushapp_SetMajorVersion( self, 1 ); ! bushapp_SetMinorVersion( self, 0 ); ! return TRUE; } void bushapp__FinalizeObject( ClassID, self ) ! struct classheader *ClassID; ! struct bushapp *self; { ! if(imPtr) im_Destroy(imPtr); ! if(framePtr) frame_Destroy(framePtr); ! if(Bush) bush_Destroy(Bush); ! if(NodesWindow) bushv_Destroy(NodesWindow); ! if(EntriesWindow) bushv_Destroy(EntriesWindow); ! if(EntryWindow) bushv_Destroy(EntryWindow); } boolean bushapp__ParseArgs( self, argc, argv ) ! struct bushapp *self; ! int argc; ! char **argv; { ! if ( ! super_ParseArgs( self, argc, argv ) ) ! return FALSE; ! bushapp_SetFork(self,TRUE); ! self->argc = argc; ! self->argv = argv; ! return(TRUE); } boolean bushapp__Start( self ) ! struct bushapp *self; { ! register char *StartDir = NULL; ! if(self->argc > 1) StartDir = self->argv[1]; ! if(!(super_Start(self)) || ! !(imPtr = im_Create(NULL)) || ! !(framePtr = frame_New()) || ! !(Bush = bush_Create(StartDir)) || ! !(CW = NodesWindow = bushv_Create(nodes_object))) return(FALSE); ! bushv_SetDataObject(NodesWindow,Bush); ! frame_SetView(framePtr,NodesWindow); ! im_SetView(imPtr,framePtr); ! frame_PostDefaultHandler(framePtr,"message", ! frame_WantHandler(framePtr,"message")); ! if(bush_TreeRoot(Bush)) ! im_SetTitle(imPtr,bush_DirName(Bush,bush_TreeRoot(Bush))); ! chdir(bush_DirPath(Bush,bush_TreeRoot(Bush))); ! bushv_WantInputFocus(NodesWindow,NodesWindow); ! return(TRUE); } - - - --- 41,139 ---- 09/07/89 Set V1.0 msg (TCP) END-SPECIFICATION ************************************************************/ #include ! #include ! #include ! #include ! #include ! #include ! #include #define Bush ((self)->bush) + #define Bushv ((self)->bushview) #define Debug ((self)->debug) #define imPtr ((self)->im) #define framePtr ((self)->frame) + #define ArgC ((self)->argc) + #define ArgV ((self)->argv) ! /* The following defines are for when there are seperate windows for the tree-view, listing-view, and entry-view. */ ! #define nodes_object 1 ! #define entries_object 2 ! #define entry_object 4 boolean bushapp__InitializeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct bushapp *self; { ! Bush = NULL; ! Bushv = NULL; ! imPtr = NULL; ! framePtr = NULL; ! Debug = 0; ! bushapp_SetMajorVersion(self,1); ! bushapp_SetMinorVersion(self,0); ! return(TRUE); } void bushapp__FinalizeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct bushapp *self; { ! if(imPtr) { ! im_Destroy(imPtr); ! imPtr = NULL; ! } ! if(framePtr) { ! frame_Destroy(framePtr); ! framePtr = NULL; ! } ! if(Bush) { ! bush_Destroy(Bush); ! Bush = NULL; ! } ! if(Bushv) { ! bushv_Destroy(Bushv); ! Bushv = NULL; ! } } boolean bushapp__ParseArgs( self, argc, argv ) ! register struct bushapp *self; ! register int argc; ! register char **argv; { ! if(!super_ParseArgs(self,argc,argv)) ! return(FALSE); ! ArgC = argc; ! ArgV = argv; ! return(TRUE); } boolean bushapp__Start( self ) ! register struct bushapp *self; { ! register char *startDir = NULL; ! if(self->argc > 1) startDir = self->argv[1]; ! if(!(super_Start(self)) || ! !(imPtr = im_Create(NULL)) || ! !(framePtr = frame_New()) || ! !(Bush = bush_Create(startDir)) || ! !(Bushv = bushv_Create(nodes_object))) ! return(FALSE); ! bushv_SetDataObject(Bushv,Bush); ! frame_SetView(framePtr,Bushv); ! im_SetView(imPtr,framePtr); ! frame_PostDefaultHandler(framePtr,"message", ! frame_WantHandler(framePtr,"message")); ! if(bush_TreeRoot(Bush)) ! im_SetTitle(imPtr,bush_DirName(Bush,bush_TreeRoot(Bush))); ! chdir(bush_DirPath(Bush,bush_TreeRoot(Bush))); ! bushv_WantInputFocus(Bushv,Bushv); ! return(TRUE); } *** atk/bush/bushapp.ch Wed Nov 22 11:52:18 1989 --- atk/bush/bushapp.ch.NEW Fri Apr 27 12:13:13 1990 *************** *** 2,25 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ - - /* $Header $ */ - /* $Source $ */ - #ifndef lint ! static char *rcsidbushapp_ch = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/bush/RCS/bushapp.ch,v 1.1 89/04/28 21:24:06 tom Exp $"; #endif - - /* - $Log: bushapp.ch,v $ - Revision 1.1 89/04/28 21:24:06 tom - Initial revision - - Revision 1.1 89/04/28 21:20:42 tom - Initial revision - - */ - /** SPECIFICATION -- External Facility Suite ********************************* TITLE Bush Application --- 2,10 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ #ifndef lint ! static char *rcsidbushapp_ch = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bushapp.ch,v 1.2 90/04/27 12:11:18 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* TITLE Bush Application *************** *** 42,72 **** 3 - Temporary Hacks Such curiosities need be resolved prior to Project Completion... - HISTORY 08/21/85 Created (TCP) 01/15/89 Convert to ATK (GW Keim) ! END-SPECIFICATION ************************************************************/ ! ! class bushapp: application [app]{ ! classprocedures: ! InitializeObject( struct bushapp *self ) returns boolean; ! FinalizeObject( struct bushapp *self ) returns void; ! overrides: ! ParseArgs( int argc, char **argv ) returns boolean; ! Start() returns boolean; ! data: ! struct im *im; ! struct frame *frame; ! char program_name[40]; ! struct bush *bush; ! struct bushv *current_window; ! struct bushv *nodes_window; ! struct bushv *entries_window; ! struct bushv *entry_window; ! int argc; ! char **argv; ! int debug; ! }; --- 27,51 ---- 3 - Temporary Hacks Such curiosities need be resolved prior to Project Completion... HISTORY 08/21/85 Created (TCP) 01/15/89 Convert to ATK (GW Keim) ! END-SPECIFICATION ******************************************************/ + class bushapp : application [app] { + classprocedures: + InitializeObject( struct bushapp *self ) returns boolean; + FinalizeObject( struct bushapp *self ); + overrides: + ParseArgs( int argc, char **argv ) returns boolean; + Start() returns boolean; + data: + struct im *im; + struct frame *frame; + struct bush *bush; + struct bushv *bushview; + int argc; + char **argv; + int debug; + }; *** atk/bush/bush.c Wed Apr 11 14:18:54 1990 --- atk/bush/bush.c.NEW Wed Jun 13 16:53:38 1990 *************** *** 3,74 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ - /* $Header $ */ - /* $Source $ */ - #ifndef lint ! static char *rcsidbush_c = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bush.c,v 1.17 90/03/05 11:18:38 gk5g Exp $"; #endif - /* - $Log: bush.c,v $ - * Revision 1.17 90/03/05 11:18:38 gk5g - * Follow soft links correctly now. - * - * Revision 1.16 89/11/07 10:33:06 cfe - * Eliminate dependency on afs/param.h . - * - * Revision 1.15 89/10/23 16:16:30 cfe - * Typo in patch: use the result of the UidUnameMap cache if it's found, even in non-AFS circumstances. - * - * Revision 1.14 89/10/23 15:52:44 gk5g - * Added patch for bug 105 regarding incomplete handling of vanilla unix uid-lookups in getname(). - * Added bush_PerformSystemAction and call to it in bush_DestroyEntry(). - * - * Revision 1.13 89/10/16 11:03:12 cfe - * compiler warnings - * - * Revision 1.12 89/09/01 13:31:02 gk5g - * Made change from tree_NodeData to tree_NodeDatum. - * - * Revision 1.11 89/08/03 12:31:56 ghoti - * added include of andrewos.h (HPUX) - * - * Revision 1.10 89/08/02 12:14:32 gk5g - * Added code to do uid->uname mappings if not an AFS site. This code just does a normal getpwuid(). - * - * Revision 1.9 89/08/01 17:38:19 gk5g - * Added #include - * - * Revision 1.8 89/07/31 12:08:00 gk5g - * In the last entry log I entered a line that included a comment. This was stupid because it caused the $Log: to be prematurely truncated and all compiles will fail. I simply seperated the /-char and the *-char. - * - * Revision 1.7 89/07/31 11:06:17 gk5g - * Changed all #endif foo tp #endif /^*foo*^/. - * - * Revision 1.6 89/07/28 19:25:32 gk5g - * Added #ifdef WHITEPAGES_ENV around #include . - * - * Revision 1.5 89/07/28 15:43:16 gk5g - * Added AFS_ENV defines to exclude the AFS-specific uid->uname mapping code for those non-AFS sites. - * - * Revision 1.4 89/07/19 18:39:27 gk5g - * Added getcell() and gethomecell() to support white page uid lookups across cells. - * - * Revision 1.3 89/06/15 16:12:20 gk5g - * Added fix to bush_BuildSubDirs() to initialize DirPath(tn) correctly if the parent directory is /. - * - * Revision 1.2 89/06/06 17:29:28 gk5g - * Added initialization code to bush_Read() to support loading as an inset; Made a simple change to bush_ViewName(). - * - * Revision 1.1 89/04/28 21:24:10 tom - * Initial revision - * - * Revision 1.1 89/04/28 21:20:45 tom - * Initial revision - * - */ - /** SPECIFICATION -- External Facility Suite ********************************* TITLE The Bush Data-object --- 3,12 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ #ifndef lint ! static char *rcsidbush_c = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bush.c,v 1.20 90/06/06 17:05:35 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* TITLE The Bush Data-object *************** *** 95,159 **** HISTORY 08/21/85 Created (TCP) 01/15/89 Convert to ATK (GW Keim) - 06/06/89 Added initialization code to bush_Read() - to support loading as an inset; (GW Keim) - Made a simple change to bush_ViewName(); (GW Keim) - 06/15/89 Added fix to bush_BuildSubDirs() to initialize DirPath(tn) - correctly if the parent directory is /. - 07/16/89 Added getname() to determine the uid of the owner of a file. Will work - across cells if the proper args are provided to getname(self,uid,cell); (GW Keim) - 07/19/89 Added getcell() and gethomecell() to support white page uid lookups - across cells; (GW Keim) - 07/28/89 Added AFS_ENV defines to exclude the AFS-specific uid->uname mapping - code for those non-AFS sites; (GW Keim) - 07/28/89 Added #ifdef WHITEPAGES_ENV around #include ; (GW Keim) - 08/01/89 Added #include ; (GW Keim) - 08/02/89 Added code to do uid->uname mappings if not an AFS site. This code - just does a normal getpwuid(); (GW Keim) END-SPECIFICATION ************************************************************/ - struct map_item { ! int uid; ! char *uname; ! char *ucell; }; ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #ifdef AFS_ENV ! #include /*getv*(), getc*() routine family*/ ! #ifdef WHITEPAGES_ENV ! #include /*White Pages*/ ! #endif /* WHITEPAGES_ENV */ ! #include ! #include ! #endif /* AFS_ENV */ ! #include #include #include #include #include #include ! #include ! #include ! #include ! #define GivenDirName (self->given_dir_name) ! #define RootPath (self->root_pathname) ! #define UidUnameMap (self->uid_uname_map) ! #define MyCellName (self->mycellname) ! #define Debug (self->debug) #define AllocNameSpace(s,t) apts_CaptureString(s,t) tree_Specification DirTree[] = {tree_Order(tree_PreOrder),NULL}; --- 33,104 ---- HISTORY 08/21/85 Created (TCP) 01/15/89 Convert to ATK (GW Keim) END-SPECIFICATION ************************************************************/ struct map_item { ! int uid; ! char *uname; ! char *ucell; }; ! #include #include #include #include #include #include ! #include /* includes tree.ih */ ! #define GivenDirName (self->given_dir_name) ! #define RootPath (self->root_pathname) ! #define UidUnameMap (self->uid_uname_map) ! #define MyCellName (self->mycellname) ! #define Debug (self->debug) ! #define Tree ((self)->tree) ! #define Root (tree_RootNode(Tree)) ! #define RootPathName ((self)->root_pathname) ! #define Dir(tn) ((struct Dir_*)tree_NodeDatum(Tree,tn)) ! #define DirMode(tn) (Dir(tn)->mode) ! #define DirPath(tn) (Dir(tn)->path) ! #define DirName(tn) (Dir(tn)->name) ! #define DirTimeStamp(tn) (Dir(tn)->time_stamp) ! #define DirSortMode(tn) (Dir(tn)->sortmode) ! #define DirDetail(tn) (Dir(tn)->detail) ! #define RootDirPath (DirPath(Root)) ! #define DirEntries(tn) (Dir(tn)->Dir_Entries) ! #define DirEntriesCount(tn) (DirEntries(tn)->count) ! #define DirEntryPtr(tn) (DirEntries(tn)->Entry) ! #define DirEntry(tn,i) (DirEntries(tn)->Entry[i]) ! #define DirEntryMode(tn,i) (DirEntry(tn,i)->mode) ! #define DirEntryPos(tn,i) (DirEntry(tn,i)->position) ! #define DirEntryName(tn,i) (DirEntry(tn,i)->name) ! #define DirEntryLinkName(tn,i) (DirEntry(tn,i)->link_name) ! #define DirEntryType(tn,i) (DirEntry(tn,i)->type) ! #define DirEntryOwner(tn,i) (DirEntry(tn,i)->owner) ! #define DirEntryNLinks(tn,i) (DirEntry(tn,i)->nlinks) ! #define DirEntryTimeStamp(tn,i) (DirEntry(tn,i)->time_stamp) ! #define DirEntrySize(tn,i) (DirEntry(tn,i)->size) ! #define DirEntryPerms(tn,i) (DirEntry(tn,i)->permissions) ! #define DirEntryParent(tn,i) (DirEntry(tn,i)->parent) ! #define DirEntryInstance(tn,i) (DirEntry(tn,i)->instance) ! #define DirEntryParentDir(tn,i) (Dir(DirEntryParent(tn,i))) ! #define RootDir (Dir(Root)) ! #define Parent(tn) (tree_ParentNode(Tree,tn)) ! #define Child(tn) (tree_ChildNode(Tree,tn)) ! #define Left(tn) (tree_LeftNode(Tree,tn)) ! #define Right(tn) (tree_RightNode(Tree,tn)) ! #define ParentDir(tn) (Dir(Parent(tn))) ! #define ChildDir(tn) (Dir(Child(tn))) ! #define LeftDir(tn) (Dir(Left(tn))) ! #define RightDir(tn) (Dir(Right(tn))) + #define no_space 2 + #define no_superior 3 + #define no_inferior 4 + #define scan_failure 5 + #define read_failure 6 + #define AllocNameSpace(s,t) apts_CaptureString(s,t) tree_Specification DirTree[] = {tree_Order(tree_PreOrder),NULL}; *************** *** 164,795 **** static int NodeFilter( dir ) ! struct direct *dir; { ! return(!(*dir->d_name == '.' && (*(dir->d_name+1) == '.' || ! *(dir->d_name+1) == '\0'))); } struct bush * bush__Create( ClassID, init_dir ) ! struct classheader *ClassID; ! char *init_dir; { ! register struct bush *self = NULL; ! if(self = bush_New()) { ! if(init_dir && (init_dir[0] != '\0')) ! strcpy(GivenDirName,init_dir); ! else im_GetDirectory(GivenDirName); ! bush_InitTree(self,GivenDirName); ! bush_BuildSubDirs(self,bush_TreeRoot(self)); ! } ! OUT(bush_Create); ! return(self); } boolean bush__InitializeObject( ClassID, self ) ! struct classheader *ClassID; ! struct bush *self; { ! Tree = tree_Create(DirTree,self); ! RootPath = NULL; ! *GivenDirName = 0; ! Debug = 0; ! UidUnameMap = vector_Create(30,3); ! MyCellName[0] = '\0'; ! return(TRUE); } static int ExtractNodePath( self, source, path ) ! struct bush *self; ! char *source, **path; { ! register long status = 0, i = 0; ! char full_path[MAXPATHLEN + 1], ! workingPathName[MAXPATHLEN + 1]; ! register char *ptr; ! IN(ExtractNodePath); ! getwd(workingPathName); ! strcpy(full_path,workingPathName); ! switch(*source) { ! case '.': ! while(*(source + i) == '.' && *(source + i + 1) == '.' && ! (*(source + i + 2) == '\0' || *(source + i + 2) == '/')) { ! if(ptr = (char*)rindex(full_path,'/')) *ptr = '\0'; ! if(*(source + i + 2) == '\0') { ! i += 2; ! break; ! } ! else i += 3; ! } ! if(i && *(source + i) != '\0') { ! strcat(full_path,"/"); ! strcat(full_path,source + i); ! } ! source = full_path; ! break; ! default: ! if(*source != '/') { ! strcat(full_path,"/"); ! strcat(full_path,GivenDirName); ! source = full_path; ! } ! } ! if(!status && (*path = (char*)malloc(strlen(source)+1))) ! strcpy(*path,source); ! else status = -1; ! OUT(ExtractNodePath); ! return(status); } static int ExtractNodeName( source, name ) ! register char *source; ! register char **name; { ! register long status = 0; ! register char *ptr = NULL; ! if((ptr = (char*)rindex(source,'/')) && *(source+1) != '\0') ! source = ++ptr; ! if(*name = (char*)malloc(strlen(source)+1)) strcpy(*name,source); ! else status = -1; ! return(status); } void bush__InitTree( self, root_path ) ! struct bush *self; ! char *root_path; { ! tree_type_node root = NULL; ! struct Dir_ *rootDir = (struct Dir_ *)calloc(1,sizeof(struct Dir_)); ! char *nodeName = NULL, tmp[MAXPATHLEN]; ! struct stat stats; ! IN(bush_InitTree); ! if(RootPath) { ! free(RootPath); ! RootPath = NULL; ! } ! ExtractNodePath(self,root_path,&RootPath); ! strcpy(GivenDirName,root_path); ! strcpy(tmp,RootPath); ! ExtractNodeName(tmp,&nodeName); ! AllocNameSpace(nodeName,&rootDir->name); ! if(stat(RootPath,&stats)) return; ! else { ! gethomecell(self,baseName); ! root = tree_CreateRootNode(Tree,rootDir->name,(char*)rootDir); ! rootDir->tn = root; ! rootDir->detail = -1; ! rootDir->sortmode = -1; ! AllocNameSpace(RootPath,&rootDir->path); ! bush_ScanDir(self,root); ! DirMode(root).selected = TRUE; ! } ! OUT(bush_InitTree); } void bush__DestroySubDirs( self, tn ) ! struct bush *self; ! tree_type_node tn; { ! IN(bush_DestroySubDirs); ! bush_FreeSubDirs(self,tn); ! tree_DestroyNodeChildren(Tree,tn); ! IN(bush_DestroySubDirs); } static char * gethomecell( self, filename ) ! struct bush *self; ! char *filename; { #ifdef AFS_ENV ! struct ViceIoctl blob; ! int outcome; blob.in_size = sizeof(baseName); blob.in = baseName; blob.out_size = MAX_PIOCTL_BUFF_SIZE; blob.out = MyCellName; ! outcome = pioctl(baseName,VIOC_GET_PRIMARY_CELL,&blob,1); ! if(outcome) { ! blob.in_size = sizeof(baseName); ! blob.in = baseName; ! blob.out_size = MAX_PIOCTL_BUFF_SIZE; ! blob.out = MyCellName; ! ! outcome = pioctl(baseName,VIOC_GET_WS_CELL,&blob,1); ! if (outcome) sprintf(MyCellName,"%s","andrew.cmu.edu"); ! return(MyCellName); ! } #else ! return(""); #endif /* AFS_ENV */ } static char * getcell( self, filename ) ! struct bush *self; ! char *filename; { #ifdef AFS_ENV ! struct ViceIoctl blob; ! static char residence[MAX_PIOCTL_BUFF_SIZE]; ! blob.in_size = sizeof(filename); ! blob.in = filename; ! blob.out_size = MAX_PIOCTL_BUFF_SIZE; ! blob.out = residence; ! if(pioctl(filename,VIOC_FILE_CELL_NAME,&blob,1)) ! return(MyCellName); ! return(residence); #else ! return(""); #endif /* AFS_ENV */ } static char * getname( self, uid, cell ) ! struct bush *self; ! int uid; ! char *cell; { ! register int i = 0; ! register struct map_item *item = NULL; ! char *uname = NULL; ! register struct passwd *pw = NULL; #ifdef AFS_ENV ! for( i = 0 ; i < vector_Count(UidUnameMap) ; i++ ) { ! item = (struct map_item*)vector_Item(UidUnameMap,i); ! if((uid == item->uid) && !strcmp(cell,item->ucell)) { ! uname = item->uname; ! break; ! } } ! if(!uname) { ! if(pw = (struct passwd *) getcpwuid(uid,cell)) { ! item = (struct map_item*)calloc(1,sizeof(struct map_item)); ! item->uid = uid; ! AllocNameSpace(pw->pw_name,&item->uname); ! AllocNameSpace(cell,&item->ucell); ! vector_AddItem(UidUnameMap,(long)item); ! uname = item->uname; ! } ! else { ! char uid_str[200]; ! item = (struct map_item*)calloc(1,sizeof(struct map_item)); ! item->uid = uid; ! sprintf(uid_str,"%u@%s",uid,cell); ! AllocNameSpace(uid_str,&item->uname); ! AllocNameSpace(cell,&item->ucell); ! vector_AddItem(UidUnameMap,(long)item); ! uname = item->uname; ! } } #else /* AFS_ENV */ ! for( i = 0 ; i < vector_Count(UidUnameMap) ; i++ ) { ! item = (struct map_item*)vector_Item(UidUnameMap,i); ! if(uid == item->uid) { ! uname = item->uname; ! break; ! } } ! if (!uname) { ! if(pw = getpwuid(uid)) { ! item = (struct map_item*)calloc(1,sizeof(struct map_item)); ! item->uid = uid; ! AllocNameSpace(pw->pw_name,&item->uname); ! AllocNameSpace("",&item->ucell); ! vector_AddItem(UidUnameMap,(long)item); ! uname = item->uname; ! } ! else { ! char uid_str[200]; ! item = (struct map_item*)calloc(1,sizeof(struct map_item)); ! item->uid = uid; ! sprintf(uid_str,"%u",uid); ! AllocNameSpace(uid_str,&item->uname); ! AllocNameSpace("",&item->ucell); ! vector_AddItem(UidUnameMap,(long)item); ! uname = item->uname; ! } } #endif /* AFS_ENV */ ! return(uname); } int bush__ScanDir( self, tn ) ! struct bush *self; ! tree_type_node tn; { ! register long i = 0, status = ok, count = 0; ! register char *ptr = NULL; ! struct direct **anchor = NULL; ! struct stat stats, lstats; ! int alphasort(), cc = 0; ! char fullEntryName[MAXPATHLEN+25], buf[MAXPATHLEN]; ! char workingDir[MAXPATHLEN]; ! IN(bush_ScanDir); ! if(!tn) return (scan_failure); ! getwd(workingDir); ! chdir(DirPath(tn)); ! if(stat(DirPath(tn),&stats)) { ! status = scan_failure; ! DirMode(tn).stat_failed = TRUE; ! } ! else DirTimeStamp(tn) = stats.st_mtime; ! if(status == ok && ! (count = scandir(DirPath(tn),&anchor,NodeFilter,alphasort)) < 0) { ! status = read_failure; ! DirMode(tn).scan_failed = TRUE; ! } ! else if(status == ok) { ! if(Child(tn)) bush_DestroySubDirs(self,tn); ! else bush_DestroyDirEntries(self,tn); ! if(count) ! if(!(DirEntries(tn) = (struct Dir_Entries*) ! calloc(1,sizeof(struct Dir_Entries)))) status = no_space; ! else { ! DirEntryPtr(tn) = ! (struct Dir_Entry **) calloc(count,sizeof(struct Dir_Entry*)); ! DirEntriesCount(tn) = count; ! } ! for( i = 0; i < count && status == ok; i++ ) { ! DirEntry(tn,i) = (struct Dir_Entry*)calloc(1,sizeof(struct Dir_Entry)); ! DirEntryPos(tn,i) = i; ! AllocNameSpace(anchor[i]->d_name,&DirEntryName(tn,i)); ! ptr = DirEntryName(tn,i); ! while(*ptr != '\0') { ! if(!(isascii(*ptr) && isprint(*ptr))) *ptr = '.'; ! ptr++; ! } ! sprintf(fullEntryName,"%s/%s",DirPath(tn),anchor[i]->d_name); ! if(lstat(fullEntryName,&stats) < 0) ! DirEntryMode(tn,i).stat_failed = TRUE; ! else { ! if((stats.st_mode & S_IFMT) == S_IFDIR) ! DirEntryType(tn,i).dir = TRUE; ! else if((stats.st_mode & S_IFMT) == S_IFLNK) { ! DirEntryType(tn,i).soft_link = TRUE; ! if(cc = readlink(fullEntryName,buf,MAXPATHLEN)) { ! buf[cc] = '\0'; ! AllocNameSpace(buf,&DirEntryLinkName(tn,i)); ! } ! if(lstat(buf,&lstats) >= 0) { ! stats = lstats; ! if((stats.st_mode & S_IFMT) == S_IFDIR) ! DirEntryType(tn,i).dir = TRUE; ! else DirEntryType(tn,i).file = TRUE; ! } ! } ! else DirEntryType(tn,i).file = TRUE; ! AllocNameSpace(getname(self,stats.st_uid,getcell(self,fullEntryName)),&DirEntryOwner(tn,i)); ! DirEntryTimeStamp(tn,i) = stats.st_mtime; ! DirEntrySize(tn,i) = stats.st_size; ! DirEntryPerms(tn,i) = stats.st_mode; ! DirEntryNLinks(tn,i) = stats.st_nlink; ! } ! DirEntryParent(tn,i) = tn; } } ! if(anchor) free(anchor); ! DirMode(tn).do_rescan = FALSE; ! chdir(workingDir); ! OUT(bush_ScanDir); ! return(status); } void bush__BuildSubDirs( self, tn ) ! struct bush *self; ! tree_type_node tn; { ! register long i = 0, count = 0; ! tree_type_node newTreeNode = NULL; ! struct Dir_ *newDir = NULL; ! char newDirPath[MAXPATHLEN]; ! IN(bush_BuildSubDirs); ! if(tn && DirEntries(tn)) { ! count = DirEntriesCount(tn); ! while(i < count) { ! if(DirEntry(tn,i) && !(DirEntryMode(tn,i).destroyed) && ! DirEntryType(tn,i).dir) { ! newDir = (struct Dir_ *) calloc(1,sizeof(struct Dir_)); ! sprintf(newDirPath,"%s%s%s",DirPath(tn), ! !strcmp(DirPath(tn),"/") ? "": "/",DirEntryName(tn,i)); ! AllocNameSpace(newDirPath,&newDir->path); ! AllocNameSpace(DirEntryName(tn,i),&newDir->name); ! newTreeNode = tree_CreateChildNode(Tree,DirEntryName(tn,i), ! (char*)newDir,tn); ! DirSortMode(newTreeNode) = -1; ! DirDetail(newTreeNode) = -1; ! DirMode(newTreeNode).do_rescan = TRUE; ! DirEntryInstance(tn,i) = newTreeNode; ! newDir->tn = newTreeNode; ! } ! i++; ! } } ! OUT(bush_BuildSubDirs); } void bush__DestroyDirEntries( self, tn ) ! struct bush *self; ! tree_type_node tn; { ! register long i = 0, count = 0; ! IN(bush_DestroyDirEntries); ! if(tn && DirEntries(tn)) { ! count = DirEntriesCount(tn); ! while(i < count) { ! if(DirEntry(tn,i)) { ! if(DirEntryLinkName(tn,i)) { ! free(DirEntryLinkName(tn,i)); ! DirEntryLinkName(tn,i) = NULL; ! } ! if(DirEntryName(tn,i)) { ! free(DirEntryName(tn,i)); ! DirEntryName(tn,i) = NULL; ! } ! if(DirEntry(tn,i)) { ! free(DirEntry(tn,i)); ! DirEntry(tn,i) = NULL; ! } ! } ! i++; } ! if(DirEntryPtr(tn)) { ! free(DirEntryPtr(tn)); ! DirEntryPtr(tn) = NULL; } ! if(DirEntries(tn)) { ! free(DirEntries(tn)); ! DirEntries(tn) = NULL; } } ! OUT(bush_DestroyDirEntries); } void bush__DestroyDirEntry( self, tn ) ! struct bush *self; ! tree_type_node tn; { ! IN(bush_DestroyDirEntry); ! if(tn && bush_Dir(self,tn) && DirEntries(tn)) { ! bush_DestroyDirEntries(self,tn); ! if(DirPath(tn)) { ! free(DirPath(tn)); ! DirPath(tn) = NULL; ! } ! if(DirName(tn)) { ! free(DirName(tn)); ! DirName(tn) = NULL; ! } ! free(bush_Dir(self,tn)); ! tree_SetNodeDatum(Tree,tn,NULL); } ! OUT(bush_DestroyDirEntry); } void bush__FreeSubDirs( self, tn ) ! struct bush *self; ! tree_type_node tn; { ! register tree_type_node tmp = NULL; ! int level = 0; ! IN(bush_FreeSubDirs); ! if((tmp = tn) && ((level = tree_NodeLevel(Tree,tmp)) > 0)) ! while((tmp = tree_NextNode(Tree,tmp)) && (tree_NodeLevel(Tree,tmp) > level)) ! bush_DestroyDirEntry(self,tmp); } boolean bush__ScanRequired( self, tn ) ! struct bush *self; ! tree_type_node tn; { ! boolean status = FALSE; ! struct stat stats; ! IN(bush_ScanRequired); ! if(!DirMode(tn).destroyed && ! (stat(DirPath(tn),&stats) || ! DirTimeStamp(tn) != stats.st_mtime || ! DirMode(tn).do_rescan)) ! status = TRUE; ! OUT(bush_ScanRequired); ! ! return(status); } int bush__DestroyEntry( self, tn, Entry ) ! struct bush *self; ! tree_type_node tn; ! struct Dir_Entry *Entry; { ! char item[MAXPATHLEN*2]; ! register long status = 0; ! sprintf(item,"%s/%s",DirPath(tn),Entry->name); ! if(Entry->type.dir) { ! static char *argv[4] = {"rm","-rf",NULL,NULL}; ! ! argv[2] = item; ! status = bush_PerformSystemAction(self,"/bin/rm",argv); ! } ! else status = unlink(item); ! if(!status) { ! Entry->mode.destroyed = TRUE; ! DirMode(tn).do_rescan = TRUE; ! } ! return(status); } int bush__MoveEntry( self, tn, Entry, newName ) ! struct bush *self; ! tree_type_node tn; ! struct Dir_Entry *Entry; ! char *newName; { ! char oldPath[MAXPATHLEN*2], newPath[MAXPATHLEN]; ! register long status; ! sprintf(oldPath,"%s/%s",DirPath(tn),Entry->name); ! sprintf(newPath,"%s/%s",DirPath(tn),newName ); ! if((status = rename(oldPath,newPath)) != -1 ) ! AllocNameSpace(newName,&Entry->name); ! return(status); } int bush__RenameDir( self, tn, newPath, newName ) ! struct bush *self; ! tree_type_node tn; ! char *newPath, *newName; { ! register long status = ok, i = 0; ! register char *newFullName = NULL; ! IN(bush_RenameDir); ! newFullName = (char*)malloc(strlen(newPath)+strlen(newName)+2); ! sprintf(newFullName,"%s/%s",newPath,newName); ! if(status = rename(DirPath(tn),newFullName)) return(status); ! else { ! AllocNameSpace(newFullName,&DirPath(tn)); ! AllocNameSpace(newName,&DirName(tn)); ! for(i=0;iheader.dataobject.id = dataobject_UniqueID(self); ! fscanf(file,"%s",GivenDirName); ! im_GetDirectory(RootPathIfInset); ! bush_InitTree(self,RootPathIfInset); ! bush_BuildSubDirs(self,bush_TreeRoot(self)); ! chdir(bush_DirPath(self,bush_TreeRoot(self))); ! fscanf(file,"%s",RootPathIfInset); /* to get past enddata token */ ! OUT(bush_Read); ! return(status); } long bush__Write( self, file, id, level ) ! struct bush *self; ! FILE *file; ! long id; ! long level; { ! IN(bush_Write); ! if(self->header.dataobject.writeID != id) { ! self->header.dataobject.writeID = id; ! if(level) { ! fprintf(file,"\\begindata{%s,%d}\n", ! class_GetTypeName(self), ! dataobject_UniqueID(&self->header.dataobject)); ! fprintf(file,"%s",DirPath(bush_TreeRoot(self))); ! fprintf(file,"\n\\enddata{%s,%d}\n", ! class_GetTypeName(self), ! dataobject_UniqueID(&self->header.dataobject)); ! } ! else { ! fprintf(file,"\\begindata{%s,%d}\n", ! class_GetTypeName(self), ! dataobject_UniqueID(&self->header.dataobject)); ! fprintf(file,"\n%s\n",DirPath(bush_TreeRoot(self))); ! fprintf(file,"\n\\enddata{%s,%d}\n", ! class_GetTypeName(self), ! dataobject_UniqueID(&self->header.dataobject)); ! } } ! OUT(bush_Write); ! return((long)self); } char * bush__ViewName( self ) ! struct bush *self; { ! return("bushv"); } int bush__PerformSystemAction( self, name, argv ) ! struct bush *self; ! char *name; ! char *argv[]; { ! int pid = 0, status = 0; ! if((pid = osi_vfork()) == 0) { ! extern getpid(); ! register int fd; ! setpgrp(0,pid = getpid()); ! fd = open("/dev/null",O_WRONLY,0644); ! if(fd >= 0) dup2(fd,1); ! close(fd); ! execvp(name,argv); ! /* flow should never reach here, but just in case.... */ ! return(-1); ! } ! while(pid != wait(&status)); ! return(status); } --- 109,745 ---- static int NodeFilter( dir ) ! register struct direct *dir; { ! return(!(*dir->d_name == '.' && ! (*(dir->d_name+1) == '.' || ! *(dir->d_name+1) == '\0'))); } struct bush * bush__Create( ClassID, init_dir ) ! struct classheader *ClassID; ! char *init_dir; { ! register struct bush *self = NULL; ! if(self = bush_New()) { ! if(init_dir && (init_dir[0] != '\0')) ! strcpy(GivenDirName,init_dir); ! else im_GetDirectory(GivenDirName); ! bush_InitTree(self,GivenDirName); ! bush_BuildSubDirs(self,bush_TreeRoot(self)); ! } ! OUT(bush_Create); ! return(self); } boolean bush__InitializeObject( ClassID, self ) ! register struct classheader *ClassID; ! register struct bush *self; { ! Tree = tree_Create(DirTree,self); ! RootPath = NULL; ! *GivenDirName = 0; ! Debug = 0; ! UidUnameMap = vector_Create(30,3); ! MyCellName[0] = '\0'; ! return(TRUE); } static int ExtractNodePath( self, source, path ) ! register struct bush *self; ! register char *source, **path; { ! register long status = 0, i = 0; ! char full_path[MAXPATHLEN + 1], ! workingPathName[MAXPATHLEN + 1]; ! register char *ptr; ! IN(ExtractNodePath); ! getwd(workingPathName); ! strcpy(full_path,workingPathName); ! switch(*source) { ! case '.': ! while(*(source + i) == '.' && *(source + i + 1) == '.' && ! (*(source + i + 2) == '\0' || *(source + i + 2) == '/')) { ! if(ptr = (char*)rindex(full_path,'/')) ! *ptr = '\0'; ! if(*(source + i + 2) == '\0') { ! i += 2; ! break; ! } ! else i += 3; ! } ! if(i && *(source + i) != '\0') { ! strcat(full_path,"/"); ! strcat(full_path,source + i); ! } ! source = full_path; ! break; ! default: ! if(*source != '/') { ! strcat(full_path,"/"); ! strcat(full_path,GivenDirName); ! source = full_path; ! } ! } ! if(!status && (*path = (char*)malloc(strlen(source)+1))) ! strcpy(*path,source); ! else status = -1; ! OUT(ExtractNodePath); ! return(status); } static int ExtractNodeName( source, name ) ! register char *source; ! register char **name; { ! register long status = 0; ! register char *ptr = NULL; ! if((ptr = (char*)rindex(source,'/')) && *(source+1) != '\0') ! source = ++ptr; ! if(*name = (char*)malloc(strlen(source)+1)) strcpy(*name,source); ! else status = -1; ! return(status); } void bush__InitTree( self, root_path ) ! register struct bush *self; ! register char *root_path; { ! tree_type_node root = NULL; ! struct Dir_ *rootDir = (struct Dir_ *)calloc(1,sizeof(struct Dir_)); ! char *nodeName = NULL, tmp[MAXPATHLEN]; ! struct stat stats; ! IN(bush_InitTree); ! if(RootPath) { ! free(RootPath); ! RootPath = NULL; ! } ! ExtractNodePath(self,root_path,&RootPath); ! strcpy(GivenDirName,root_path); ! strcpy(tmp,RootPath); ! ExtractNodeName(tmp,&nodeName); ! AllocNameSpace(nodeName,&rootDir->name); ! if(stat(RootPath,&stats)) return; ! else { ! gethomecell(self,baseName); ! root = tree_CreateRootNode(Tree,rootDir->name,(char*)rootDir); ! rootDir->tn = root; ! rootDir->detail = -1; ! rootDir->sortmode = -1; ! AllocNameSpace(RootPath,&rootDir->path); ! bush_ScanDir(self,root); ! DirMode(root).selected = TRUE; ! } ! OUT(bush_InitTree); } void bush__DestroySubDirs( self, tn ) ! register struct bush *self; ! register tree_type_node tn; { ! IN(bush_DestroySubDirs); ! bush_FreeSubDirs(self,tn); ! tree_DestroyNodeChildren(Tree,tn); ! IN(bush_DestroySubDirs); } static char * gethomecell( self, filename ) ! register struct bush *self; ! register char *filename; { #ifdef AFS_ENV ! struct ViceIoctl blob; ! int outcome; + blob.in_size = sizeof(baseName); + blob.in = baseName; + blob.out_size = MAX_PIOCTL_BUFF_SIZE; + blob.out = MyCellName; + + outcome = pioctl(baseName,VIOC_GET_PRIMARY_CELL,&blob,1); + if(outcome) { blob.in_size = sizeof(baseName); blob.in = baseName; blob.out_size = MAX_PIOCTL_BUFF_SIZE; blob.out = MyCellName; ! outcome = pioctl(baseName,VIOC_GET_WS_CELL,&blob,1); ! if(outcome) ! sprintf(MyCellName,"%s","andrew.cmu.edu"); ! return(MyCellName); ! } #else ! return(""); #endif /* AFS_ENV */ } static char * getcell( self, filename ) ! register struct bush *self; ! register char *filename; { #ifdef AFS_ENV ! struct ViceIoctl blob; ! static char residence[MAX_PIOCTL_BUFF_SIZE]; ! blob.in_size = sizeof(filename); ! blob.in = filename; ! blob.out_size = MAX_PIOCTL_BUFF_SIZE; ! blob.out = residence; ! if(pioctl(filename,VIOC_FILE_CELL_NAME,&blob,1)) ! return(MyCellName); ! return(residence); #else ! return(""); #endif /* AFS_ENV */ } static char * getname( self, uid, cell ) ! register struct bush *self; ! register int uid; ! register char *cell; { ! register int i = 0; ! register struct map_item *item = NULL; ! char *uname = NULL; ! register struct passwd *pw = NULL; #ifdef AFS_ENV ! for( i = 0 ; i < vector_Count(UidUnameMap) ; i++ ) { ! item = (struct map_item*)vector_Item(UidUnameMap,i); ! if((uid == item->uid) && !strcmp(cell,item->ucell)) { ! uname = item->uname; ! break; } ! } ! if(!uname) { ! if(pw = (struct passwd *) getcpwuid(uid,cell)) { ! item = (struct map_item*)calloc(1,sizeof(struct map_item)); ! item->uid = uid; ! AllocNameSpace(pw->pw_name,&item->uname); ! AllocNameSpace(cell,&item->ucell); ! vector_AddItem(UidUnameMap,(long)item); ! uname = item->uname; ! } ! else { ! char uid_str[200]; ! item = (struct map_item*)calloc(1,sizeof(struct map_item)); ! item->uid = uid; ! sprintf(uid_str,"%u@%s",uid,cell); ! AllocNameSpace(uid_str,&item->uname); ! AllocNameSpace(cell,&item->ucell); ! vector_AddItem(UidUnameMap,(long)item); ! uname = item->uname; } + } #else /* AFS_ENV */ ! for( i = 0 ; i < vector_Count(UidUnameMap) ; i++ ) { ! item = (struct map_item*)vector_Item(UidUnameMap,i); ! if(uid == item->uid) { ! uname = item->uname; ! break; } ! } ! if(!uname) { ! if(pw = getpwuid(uid)) { ! item = (struct map_item*)calloc(1,sizeof(struct map_item)); ! item->uid = uid; ! AllocNameSpace(pw->pw_name,&item->uname); ! AllocNameSpace("",&item->ucell); ! vector_AddItem(UidUnameMap,(long)item); ! uname = item->uname; ! } ! else { ! char uid_str[200]; ! item = (struct map_item*)calloc(1,sizeof(struct map_item)); ! item->uid = uid; ! sprintf(uid_str,"%u",uid); ! AllocNameSpace(uid_str,&item->uname); ! AllocNameSpace("",&item->ucell); ! vector_AddItem(UidUnameMap,(long)item); ! uname = item->uname; } + } #endif /* AFS_ENV */ ! return(uname); } int bush__ScanDir( self, tn ) ! register struct bush *self; ! register tree_type_node tn; { ! register long i = 0, status = ok, count = 0; ! register char *ptr = NULL; ! struct direct **anchor = NULL; ! struct stat stats, lstats; ! int alphasort(), cc = 0; ! char fullEntryName[MAXPATHLEN+25], buf[MAXPATHLEN]; ! char workingDir[MAXPATHLEN]; ! IN(bush_ScanDir); ! if(!tn) return(scan_failure); ! getwd(workingDir); ! chdir(DirPath(tn)); ! if(stat(DirPath(tn),&stats)) { ! status = scan_failure; ! DirMode(tn).stat_failed = TRUE; ! } ! else DirTimeStamp(tn) = stats.st_mtime; ! if(status == ok && ! (count = scandir(DirPath(tn),&anchor,NodeFilter,alphasort)) < 0) { ! status = read_failure; ! DirMode(tn).scan_failed = TRUE; ! } ! else if(status == ok) { ! if(Child(tn)) bush_DestroySubDirs(self,tn); ! else bush_DestroyDirEntries(self,tn); ! if(count) ! if(!(DirEntries(tn) = (struct Dir_Entries*) ! calloc(1,sizeof(struct Dir_Entries)))) status = no_space; ! else { ! DirEntryPtr(tn) = ! (struct Dir_Entry **) calloc(count,sizeof(struct Dir_Entry*)); ! DirEntriesCount(tn) = count; ! } ! for( i = 0; i < count && status == ok; i++ ) { ! DirEntry(tn,i) = (struct Dir_Entry*)calloc(1,sizeof(struct Dir_Entry)); ! DirEntryPos(tn,i) = i; ! AllocNameSpace(anchor[i]->d_name,&DirEntryName(tn,i)); ! ptr = DirEntryName(tn,i); ! while(*ptr != '\0') { ! if(!(isascii(*ptr) && isprint(*ptr))) *ptr = '.'; ! ptr++; ! } ! sprintf(fullEntryName,"%s/%s",DirPath(tn),anchor[i]->d_name); ! if(lstat(fullEntryName,&stats) < 0) ! DirEntryMode(tn,i).stat_failed = TRUE; ! else { ! if((stats.st_mode & S_IFMT) == S_IFDIR) ! DirEntryType(tn,i).dir = TRUE; ! else if((stats.st_mode & S_IFMT) == S_IFLNK) { ! DirEntryType(tn,i).soft_link = TRUE; ! if(cc = readlink(fullEntryName,buf,MAXPATHLEN)) { ! buf[cc] = '\0'; ! AllocNameSpace(buf,&DirEntryLinkName(tn,i)); ! } ! if(lstat(buf,&lstats) >= 0) { ! stats = lstats; ! if((stats.st_mode & S_IFMT) == S_IFDIR) ! DirEntryType(tn,i).dir = TRUE; ! else DirEntryType(tn,i).file = TRUE; ! } } + else DirEntryType(tn,i).file = TRUE; + AllocNameSpace(getname(self,stats.st_uid,getcell(self,fullEntryName)), + &DirEntryOwner(tn,i)); + DirEntryTimeStamp(tn,i) = stats.st_mtime; + DirEntrySize(tn,i) = stats.st_size; + DirEntryPerms(tn,i) = stats.st_mode; + DirEntryNLinks(tn,i) = stats.st_nlink; + } + DirEntryParent(tn,i) = tn; + if(anchor[i]) free(anchor[i]); } ! } ! if(anchor) free(anchor); ! DirMode(tn).do_rescan = FALSE; ! chdir(workingDir); ! OUT(bush_ScanDir); ! return(status); } void bush__BuildSubDirs( self, tn ) ! register struct bush *self; ! register tree_type_node tn; { ! register long i = 0, count = 0; ! tree_type_node newTreeNode = NULL; ! struct Dir_ *newDir = NULL; ! char newDirPath[MAXPATHLEN]; ! IN(bush_BuildSubDirs); ! if(tn && DirEntries(tn)) { ! count = DirEntriesCount(tn); ! while(i < count) { ! if(DirEntry(tn,i) && !(DirEntryMode(tn,i).destroyed) && ! DirEntryType(tn,i).dir) { ! newDir = (struct Dir_ *) calloc(1,sizeof(struct Dir_)); ! sprintf(newDirPath,"%s%s%s",DirPath(tn), ! !strcmp(DirPath(tn),"/") ? "": "/",DirEntryName(tn,i)); ! AllocNameSpace(newDirPath,&newDir->path); ! AllocNameSpace(DirEntryName(tn,i),&newDir->name); ! newTreeNode = tree_CreateChildNode(Tree,DirEntryName(tn,i), ! (char*)newDir,tn); ! DirSortMode(newTreeNode) = -1; ! DirDetail(newTreeNode) = -1; ! DirMode(newTreeNode).do_rescan = TRUE; ! DirEntryInstance(tn,i) = newTreeNode; ! newDir->tn = newTreeNode; ! } ! i++; } ! } ! OUT(bush_BuildSubDirs); } void bush__DestroyDirEntries( self, tn ) ! register struct bush *self; ! register tree_type_node tn; { ! register long i = 0, count = 0; ! IN(bush_DestroyDirEntries); ! if(tn && DirEntries(tn)) { ! count = DirEntriesCount(tn); ! while(i < count) { ! if(DirEntry(tn,i)) { ! if(DirEntryLinkName(tn,i)) { ! free(DirEntryLinkName(tn,i)); ! DirEntryLinkName(tn,i) = NULL; } ! if(DirEntryName(tn,i)) { ! free(DirEntryName(tn,i)); ! DirEntryName(tn,i) = NULL; } ! if(DirEntry(tn,i)) { ! free(DirEntry(tn,i)); ! DirEntry(tn,i) = NULL; } + } + i++; } ! if(DirEntryPtr(tn)) { ! free(DirEntryPtr(tn)); ! DirEntryPtr(tn) = NULL; ! } ! if(DirEntries(tn)) { ! free(DirEntries(tn)); ! DirEntries(tn) = NULL; ! } ! } ! OUT(bush_DestroyDirEntries); } void bush__DestroyDirEntry( self, tn ) ! register struct bush *self; ! register tree_type_node tn; { ! IN(bush_DestroyDirEntry); ! if(tn && bush_Dir(self,tn) && DirEntries(tn)) { ! bush_DestroyDirEntries(self,tn); ! if(DirPath(tn)) { ! free(DirPath(tn)); ! DirPath(tn) = NULL; } ! if(DirName(tn)) { ! free(DirName(tn)); ! DirName(tn) = NULL; ! } ! free(bush_Dir(self,tn)); ! tree_SetNodeDatum(Tree,tn,NULL); ! } ! OUT(bush_DestroyDirEntry); } void bush__FreeSubDirs( self, tn ) ! register struct bush *self; ! register tree_type_node tn; { ! register tree_type_node tmp = NULL; ! register int level = 0; ! IN(bush_FreeSubDirs); ! if((tmp = tn) && ((level = tree_NodeLevel(Tree,tmp)) > 0)) ! while((tmp = tree_NextNode(Tree,tmp)) && (tree_NodeLevel(Tree,tmp) > level)) ! bush_DestroyDirEntry(self,tmp); } boolean bush__ScanRequired( self, tn ) ! register struct bush *self; ! register tree_type_node tn; { ! boolean status = FALSE; ! struct stat stats; ! IN(bush_ScanRequired); ! if(!DirMode(tn).destroyed && ! (stat(DirPath(tn),&stats) || ! DirTimeStamp(tn) != stats.st_mtime || ! DirMode(tn).do_rescan)) ! status = TRUE; ! OUT(bush_ScanRequired); ! return(status); } int bush__DestroyEntry( self, tn, Entry ) ! register struct bush *self; ! register tree_type_node tn; ! register struct Dir_Entry *Entry; { ! char item[MAXPATHLEN*2]; ! register long status = 0; ! sprintf(item,"%s/%s",DirPath(tn),Entry->name); ! if(Entry->type.dir) { ! static char *argv[4] = {"rm","-rf",NULL,NULL}; ! argv[2] = item; ! status = bush_PerformSystemAction(self,"/bin/rm",argv); ! } ! else status = unlink(item); ! if(!status) { ! Entry->mode.destroyed = TRUE; ! DirMode(tn).do_rescan = TRUE; ! } ! return(status); } int bush__MoveEntry( self, tn, Entry, newName ) ! register struct bush *self; ! register tree_type_node tn; ! register struct Dir_Entry *Entry; ! register char *newName; { ! char oldPath[MAXPATHLEN*2], newPath[MAXPATHLEN]; ! register long status; ! sprintf(oldPath,"%s/%s",DirPath(tn),Entry->name); ! sprintf(newPath,"%s/%s",DirPath(tn),newName ); ! if((status = rename(oldPath,newPath)) != -1 ) ! AllocNameSpace(newName,&Entry->name); ! return(status); } int bush__RenameDir( self, tn, newPath, newName ) ! register struct bush *self; ! register tree_type_node tn; ! register char *newPath, *newName; { ! register long status = ok, i = 0; ! register char *newFullName = NULL; ! IN(bush_RenameDir); ! newFullName = (char*)malloc(strlen(newPath)+strlen(newName)+2); ! sprintf(newFullName,"%s/%s",newPath,newName); ! if(status = rename(DirPath(tn),newFullName)) return(status); ! else { ! AllocNameSpace(newFullName,&DirPath(tn)); ! AllocNameSpace(newName,&DirName(tn)); ! for(i=0;iheader.dataobject.id = dataobject_UniqueID(self); ! fscanf(file,"%s",GivenDirName); ! im_GetDirectory(RootPathIfInset); ! bush_InitTree(self,RootPathIfInset); ! bush_BuildSubDirs(self,bush_TreeRoot(self)); ! chdir(bush_DirPath(self,bush_TreeRoot(self))); ! fscanf(file,"%s",RootPathIfInset); /* to get past enddata token */ ! OUT(bush_Read); ! return(status); } long bush__Write( self, file, id, level ) ! register struct bush *self; ! register FILE *file; ! register long id; ! register long level; { ! IN(bush_Write); ! if(self->header.dataobject.writeID != id) { ! self->header.dataobject.writeID = id; ! if(level) { ! fprintf(file,"\\begindata{%s,%d}\n", ! class_GetTypeName(self), ! dataobject_UniqueID(&self->header.dataobject)); ! fprintf(file,"%s",DirPath(bush_TreeRoot(self))); ! fprintf(file,"\n\\enddata{%s,%d}\n", ! class_GetTypeName(self), ! dataobject_UniqueID(&self->header.dataobject)); } ! else { ! fprintf(file,"\\begindata{%s,%d}\n", ! class_GetTypeName(self), ! dataobject_UniqueID(&self->header.dataobject)); ! fprintf(file,"\n%s\n",DirPath(bush_TreeRoot(self))); ! fprintf(file,"\n\\enddata{%s,%d}\n", ! class_GetTypeName(self), ! dataobject_UniqueID(&self->header.dataobject)); ! } ! } ! OUT(bush_Write); ! return((long)self); } char * bush__ViewName( self ) ! register struct bush *self; { ! return("bushv"); } int bush__PerformSystemAction( self, name, argv ) ! register struct bush *self; ! register char *name; ! register char *argv[]; { ! int pid = 0, status = 0; ! if((pid = osi_vfork()) == 0) { ! #if !SY_AIX12 ! extern getpid(); ! #endif /* SY_AIX12 */ ! register int fd; ! setpgrp(0,pid = getpid()); ! fd = open("/dev/null",O_WRONLY,0644); ! if(fd >= 0) dup2(fd,1); ! close(fd); ! execvp(name,argv); ! /* flow should never reach here, but just in case.... */ ! return(-1); ! } ! while(pid != wait(&status)); ! return(status); } *** atk/bush/bush.ch Wed Apr 11 14:18:56 1990 --- atk/bush/bush.ch.NEW Wed Jun 13 16:53:40 1990 *************** *** 7,40 **** /* $Source $ */ #ifndef lint ! static char *rcsidbush_ch = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bush.ch,v 1.6 90/03/05 11:18:11 gk5g Exp $"; #endif - /* - $Log: bush.ch,v $ - Revision 1.6 90/03/05 11:18:11 gk5g - Follow soft links correctly now. - - Revision 1.5 89/10/23 15:52:02 gk5g - Added method bush_PerformSystemAction. - - Revision 1.4 89/09/01 13:30:57 gk5g - Made change from tree_NodeData to tree_NodeDatum. - - Revision 1.3 89/07/28 15:43:54 gk5g - Change the token AptTree to just Tree. - - Revision 1.2 89/07/19 18:45:30 gk5g - Added new instance vars (struct vector *) uid_name_map and char mycellname[] to support cross-cellular uid lookups. - - Revision 1.1 89/04/28 21:24:03 tom - Initial revision - - Revision 1.1 89/04/28 21:20:41 tom - Initial revision - - */ - /** SPECIFICATION -- External Facility Suite ********************************* TITLE The Bush Data-object --- 7,15 ---- /* $Source $ */ #ifndef lint ! static char *rcsidbush_ch = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bush.ch,v 1.9 90/06/12 15:49:25 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* TITLE The Bush Data-object *************** *** 63,82 **** 01/15/89 Convert to ATK (GW Keim) END-SPECIFICATION ************************************************************/ ! struct entry_mode { ! unsigned do_rescan:1; ! unsigned destroyed:1; ! unsigned selected:1; ! unsigned detailed:1; ! unsigned stat_failed:1; ! unsigned scan_failed:1; }; struct entry_kind { ! short dir:1; ! short soft_link:1; ! short file:1; }; struct Dir_Entry { --- 38,58 ---- 01/15/89 Convert to ATK (GW Keim) END-SPECIFICATION ************************************************************/ ! #include ! struct entry_mode { ! unsigned int do_rescan:1; ! unsigned int destroyed:1; ! unsigned int selected:1; ! unsigned int detailed:1; ! unsigned int stat_failed:1; ! unsigned int scan_failed:1; }; struct entry_kind { ! unsigned int dir:1; ! unsigned int soft_link:1; ! unsigned int file:1; }; struct Dir_Entry { *************** *** 109,116 **** class bush : apt { classprocedures: ! Create(char *init_dir) returns struct bush*; methods: InitTree(char *root_path) returns void; ScanDir(tree_type_node tn) returns int; BuildSubDirs(tree_type_node tn) returns void; --- 85,95 ---- class bush : apt { classprocedures: ! ! Create(char *init_dir) returns struct bush *; ! methods: + InitTree(char *root_path) returns void; ScanDir(tree_type_node tn) returns int; BuildSubDirs(tree_type_node tn) returns void; *************** *** 123,133 **** --- 102,116 ---- RenameDir(tree_type_node tn,char *newPath, char *newName) returns int; MoveEntry(tree_type_node tn,struct Dir_Entry *Entry,char *newName) returns int; PerformSystemAction( char* name, char **argv ) returns int; + overrides: + Read(FILE *file,long id) returns long; Write(FILE *file,long id,long level) returns long; ViewName() returns char *; + macromethods: + Tree() (self->tree) TreeRoot() (tree_RootNode(bush_Tree(self))) RootPathName() (self->root_pathname) *************** *** 166,172 **** --- 149,157 ---- ChildDir(tn) (bush_Dir(self,bush_Child(self,tn))) LeftDir(tn) (bush_Dir(self,bush_Left(self,tn))) RightDir(tn) (bush_Dir(self,bush_Right(self,tn))) + data: + char given_dir_name[1025]; struct tree *tree; char *root_pathname; *************** *** 174,177 **** char mycellname[1000]; int debug; }; - --- 159,161 ---- *** atk/bush/bush.h Wed Apr 11 14:18:57 1990 --- atk/bush/bush.h.NEW Fri Apr 27 12:13:16 1990 *************** *** 7,17 **** /* $Source $ */ #ifndef lint ! static char *rcsidbush_h = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bush.h,v 1.3 90/03/14 15:29:29 gk5g Exp $"; #endif /* $Log: bush.h,v $ * Revision 1.3 90/03/14 15:29:29 gk5g * macros for improved readability. * --- 7,20 ---- /* $Source $ */ #ifndef lint ! static char *rcsidbush_h = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/bush/RCS/bush.h,v 1.4 90/04/27 12:11:34 gk5g Exp $"; #endif /* $Log: bush.h,v $ + * Revision 1.4 90/04/27 12:11:34 gk5g + * Sweeping revisions including: (1) reformated, (2) added editing capability while viewing a file, (3) cleaned up unused variables, (4) additional information added to the ControlPanel (sort, detail, editor). + * * Revision 1.3 90/03/14 15:29:29 gk5g * macros for improved readability. * *************** *** 57,107 **** 01/15/89 Convert to ATK (GW Keim) END-SPECIFICATION ************************************************************/ ! ! #define Tree ((self)->tree) ! #define Root (tree_RootNode(Tree)) ! #define RootPathName ((self)->root_pathname) ! #define Dir(tn) ((struct Dir_*)tree_NodeDatum(Tree,tn)) ! #define DirMode(tn) (Dir(tn)->mode) ! #define DirPath(tn) (Dir(tn)->path) ! #define DirName(tn) (Dir(tn)->name) ! #define DirTimeStamp(tn) (Dir(tn)->time_stamp) ! #define DirSortMode(tn) (Dir(tn)->sortmode) ! #define DirDetail(tn) (Dir(tn)->detail) ! #define RootDirPath (DirPath(Root)) ! #define DirEntries(tn) (Dir(tn)->Dir_Entries) ! #define DirEntriesCount(tn) (DirEntries(tn)->count) ! #define DirEntryPtr(tn) (DirEntries(tn)->Entry) ! #define DirEntry(tn,i) (DirEntries(tn)->Entry[i]) ! #define DirEntryMode(tn,i) (DirEntry(tn,i)->mode) ! #define DirEntryPos(tn,i) (DirEntry(tn,i)->position) ! #define DirEntryName(tn,i) (DirEntry(tn,i)->name) ! #define DirEntryLinkName(tn,i) (DirEntry(tn,i)->link_name) ! #define DirEntryType(tn,i) (DirEntry(tn,i)->type) ! #define DirEntryOwner(tn,i) (DirEntry(tn,i)->owner) ! #define DirEntryNLinks(tn,i) (DirEntry(tn,i)->nlinks) ! #define DirEntryTimeStamp(tn,i) (DirEntry(tn,i)->time_stamp) ! #define DirEntrySize(tn,i) (DirEntry(tn,i)->size) ! #define DirEntryPerms(tn,i) (DirEntry(tn,i)->permissions) ! #define DirEntryParent(tn,i) (DirEntry(tn,i)->parent) ! #define DirEntryInstance(tn,i) (DirEntry(tn,i)->instance) ! #define DirEntryParentDir(tn,i) (Dir(DirEntryParent(tn,i))) ! #define RootDir (Dir(Root)) ! #define Parent(tn) (tree_ParentNode(Tree,tn)) ! #define Child(tn) (tree_ChildNode(Tree,tn)) ! #define Left(tn) (tree_LeftNode(Tree,tn)) ! #define Right(tn) (tree_RightNode(Tree,tn)) ! #define ParentDir(tn) (Dir(Parent(tn))) ! #define ChildDir(tn) (Dir(Child(tn))) ! #define LeftDir(tn) (Dir(Left(tn))) ! #define RightDir(tn) (Dir(Right(tn))) ! ! #define no_space 2 ! #define no_superior 3 ! #define no_inferior 4 ! #define scan_failure 5 ! #define read_failure 6 ! --- 60,83 ---- 01/15/89 Convert to ATK (GW Keim) END-SPECIFICATION ************************************************************/ ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #ifdef AFS_ENV ! #include /*getv*(), getc*() routine family*/ ! #ifdef WHITEPAGES_ENV ! #include /*White Pages*/ ! #endif /* WHITEPAGES_ENV */ ! #include ! #include ! #endif /* AFS_ENV */ ! #include *** atk/bush/Imakefile Wed Nov 22 11:52:11 1989 --- atk/bush/Imakefile.NEW Fri Apr 27 12:13:17 1990 *************** *** 13,18 **** --- 13,19 ---- DependTarget() DynamicObject(bush,,$(UTILLIB)) + DynamicObject(bushv,,$(UTILLIB)) InstallClassFiles($(DOBJS),$(IHFILES)) InstallLink(runapp, ${DESTDIR}/bin/bush) *** atk/bush/bush.help Wed Nov 22 11:52:32 1989 --- atk/bush/bush.help.NEW Fri Apr 27 12:40:53 1990 *************** *** 1,4 **** ! \begindata{text,268886928} \textdsversion{12} \template{help} \chapter{\center{ --- 1,4 ---- ! \begindata{text,268980228} \textdsversion{12} \template{help} \chapter{\center{ *************** *** 10,16 **** \leftindent{Bush is a tool you can use to view and modify the structure of the ! Andrew file system. Bush presents file system information at three levels of detail: --- 10,16 ---- \leftindent{Bush is a tool you can use to view and modify the structure of the ! UNIX file system. Bush presents file system information at three levels of detail: *************** *** 33,49 **** \leftindent{You may access Bush by typing \bold{bush} and pressing at ! the \bold{Typescript} prompt. If you do not specify an initial directory ! name, bush will choose your \italic{current working directory} by default. If ! you specify a directory as the first argument, bush will begin by scanning and making visible the subdirectories of that directory. \bold{Level 1 -- A Graphic display of the directory hierarchy.} After you enter the bush command, bush displays the specified directory in a tree ! pattern, with the given directory name darkened at the top-most position of ! the tree, nearest to the root. Any child subdirectories are listed below the ! chosen parent directory, either as individual branches on the tree or as individual boxes within a larger containing box. The containing box appears whenever there is a large number of subdirectories for a given parent directory. --- 33,49 ---- \leftindent{You may access Bush by typing \bold{bush} and pressing at ! the \bold{typescript} prompt. If you do not specify an initial directory ! name, bush will choose your current working directory by default. If you ! specify a directory as the first argument, bush will begin by scanning and making visible the subdirectories of that directory. \bold{Level 1 -- A Graphic display of the directory hierarchy.} After you enter the bush command, bush displays the specified directory in a tree ! pattern graph, with the specified directory name darkened at the top-most ! position of the tree-- the root. Any child subdirectories are listed below ! the chosen parent directory, either as individual branches on the tree or as individual boxes within a larger containing box. The containing box appears whenever there is a large number of subdirectories for a given parent directory. *************** *** 55,61 **** \bold{its} child subdirectories, if any exist. As you move down through the directory branches, bush traces your path by shading the boxes you have chosen. The directory you have chosen most recently is always darkened, with ! its name shown in the directory bar at the top of the bush display. You can move a directory from under its current parent directory to some other --- 55,61 ---- \bold{its} child subdirectories, if any exist. As you move down through the directory branches, bush traces your path by shading the boxes you have chosen. The directory you have chosen most recently is always darkened, with ! its full path shown in the directory bar at the top of the bush display. You can move a directory from under its current parent directory to some other *************** *** 93,104 **** \bold{Using the Directory Bar.} The bar at the top of the bush window is the directory bar. It displays the pathname of the directory which you have most ! recently selected from the bush display [e.g. /usr/andrew/bin]. If you want ! to use programs which reference executable files, Bush allows you to change ! current directories by clicking on the directory bar. Changing current ! directories with the directory bar provides the ability to have the ATK ! dynamic loader "see" certain dynamic objects when 'Exec'ing a file that is a ! link to runapp (see runapp). To make the directory listed in the bar the current working directory, move --- 93,103 ---- \bold{Using the Directory Bar.} The bar at the top of the bush window is the directory bar. It displays the pathname of the directory which you have most ! recently selected from the bush display. If you want to use programs which ! reference executable files, Bush allows you to change the current directory by ! clicking on the directory bar. Changing the current directory with the ! directory bar provides the ability to have the ATK dynamic loader "see" ! certain dynamic objects when 'Exec'ing a file that is a link to runapp. To make the directory listed in the bar the current working directory, move *************** *** 224,248 **** \section{Recent changes to Bush } ! \leftindent{Recently augmented functionality with added features like ! 'Switch'. Now handles viewing of multi-media documents.} \section{Machine Types} ! \indent{Bush is available on the machine types rt_r3, sun3_35, and vax_30.} \section{Related Tools} ! Select (highlight) one of the italicized names and choose "Show Help on ! Selected Word" to see the help document for: \leftindent{\italic{Andrew} (the Tour) ! \italic{insets}} ! \enddata{text,268886928} --- 223,265 ---- \section{Recent changes to Bush } ! \indent{A set of proctable entries have been defined to allow users to bind ! keys to actions in the bush interface. Here is an example of how to bind the ! available functions to a set of keys in your $\{HOME\}/.atkinit file: + \indent{addkey bushv-pop ^X^P + + addkey bushv-destroy ^X^D + + addkey bushv-switch ^X^S + + addkey bushv-rescan ^X^R + + + }}\indent{Editing of files via bush is now supported. Modified files are + checkpointed every 2 minutes and that checkpoint interval can be set via your + $\{HOME\}/preferences file by specifying a value for + \bold{bush.CheckpointInterval} preference.} + + \section{Machine Types} ! \indent{Bush is available on the machine types rt_r3, sun3_35.} \section{Related Tools} ! Select one of the italicized names and choose "Show Help on Selected Word" to ! see the help document for: \leftindent{\italic{Andrew} (the Tour) ! \italic{insets ! preferences}} ! ! \enddata{text,268980228} *** atk/champ/butter.c Wed Nov 22 11:53:00 1989 --- atk/champ/butter.c.NEW Fri Jun 8 18:17:57 1990 *************** *** 8,14 **** --- 8,16 ---- #include "graphic.ih" #include "cursor.ih" + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ boolean butter__InitializeObject(c, self) *** atk/champ/butterv.c Mon Mar 12 13:15:48 1990 --- atk/champ/butterv.c.NEW Fri Jun 8 18:18:12 1990 *************** *** 9,15 **** --- 9,17 ---- #include "graphic.ih" #include "cursor.ih" + #ifndef _IBMR2 extern char *malloc(); + #endif /* _IBMR2 */ void butterview__FullUpdate(self, type, left, top, width, height) *** atk/champ/chlist.c Wed Nov 22 11:52:58 1989 --- atk/champ/chlist.c.NEW Fri Jul 27 12:47:25 1990 *************** *** 13,31 **** self->ItemList = NULL; self->numitems = 0; self->numitemsallocated = 0; chlist_SetReadOnly(self, TRUE); return(TRUE); } ! boolean chlist__AddItemToEnd(self, str, proc, data) struct chlist *self; char *str; int (*proc)(); long data; { char *mycopy; struct listitem *newbuf; ! int pos, len; if (self->numitems >= self->numitemsallocated) { self->numitemsallocated += 25; --- 13,234 ---- self->ItemList = NULL; self->numitems = 0; self->numitemsallocated = 0; + self->freeProc = NULL; + self->numRegions = 1; + self->numRegionsAllocated = 4; + self->strRegionNum = 0; chlist_SetReadOnly(self, TRUE); return(TRUE); } ! void Clear(self) struct chlist *self; + { + long i, j; + struct listitem *item; + + for (i = self->numitems - 1; i >= 0; i--) { + item = &self->ItemList[i]; + if (self->freeProc != NULL && item->rock != NULL) { + (*self->freeProc)(item->rock); + } + if (item->regionStrings != NULL) { + for (j = 0; j < self->numRegions; j++) { + if (item->regionStrings[j] != NULL) { + free(item->regionStrings[j]); + } + } + free(item->regionStrings); + } + else if (self->ItemList[i].str != NULL) { + free(self->ItemList[i].str); + } + } + if (self->ItemList != NULL) { + free(self->ItemList); + } + } + + void chlist__FinalizeObject(c, self) + struct classheader *c; + struct chlist *self; + { + Clear(self); + } + + void chlist__Clear(self) + struct chlist *self; + { + Clear(self); + super_Clear(self); + + self->ItemList = NULL; + self->numitems = 0; + self->numitemsallocated = 0; + self->freeProc = NULL; + self->numRegions = 1; + self->numRegionsAllocated = 4; + self->strRegionNum = 0; + chlist_SetReadOnly(self, TRUE); + } + + void chlist__SetRegionStringByIndex(self, index, regionNum, regionStr) + struct chlist *self; + long index; + long regionNum; + char *regionStr; + { + struct listitem *item; + long len, oldLen, changeLen = 0; + long startPos, i; + char *newstr; + + if (index < 0 || index >= self->numitems) { + return; + } + if (regionNum < 0 || regionNum >= self->numRegions) { + return; + } + + item = &self->ItemList[index]; + + len = 0; + newstr = NULL; + + if (regionStr != NULL) { + len = strlen(regionStr); + if (len != 0) { + newstr = (char *) malloc(len + 1); + strcpy(newstr, regionStr); + } + } + + startPos = item->loc; + if (item->regionStrings != NULL || regionNum != self->strRegionNum) { + if (item->regionStrings == NULL) { + item->regionStrings = (char **) calloc(self->numRegionsAllocated, sizeof(char *)); + item->regionStrings[self->strRegionNum] = item->str; + } + + for (i = 0; i < regionNum; i++) { + if (item->regionStrings[i] != NULL) { + startPos += strlen(item->regionStrings[i]); + } + } + + if (item->regionStrings[regionNum] == NULL) { + /* New string */ + if (len != 0) { + chlist_AlwaysInsertCharacters(self, startPos, newstr, len); + changeLen = len; + } + } + else { + oldLen = strlen(item->regionStrings[regionNum]); + if (len != 0) { + chlist_AlwaysReplaceCharacters(self, startPos, oldLen, newstr, len); + changeLen = len - oldLen; + } + else { + /* Need to check if enivironment goes away */ + chlist_AlwaysDeleteCharacters(self, startPos, oldLen); + changeLen = -oldLen; + } + free(item->regionStrings[regionNum]); + } + + item->regionStrings[regionNum] = newstr; + if (regionNum == self->strRegionNum) { + item->str = newstr; + } + } + else { + if (item->str != NULL) { + oldLen = strlen(item->str); + free(item->str); + } + else { + oldLen = 0; + } + + if (len != 0) { + chlist_AlwaysReplaceCharacters(self, startPos, oldLen, newstr, len); + changeLen = len - oldLen; + } + else { + chlist_AlwaysDeleteCharacters(self, startPos, oldLen); + changeLen = -oldLen; + } + item->str = newstr; + } + + if (changeLen != 0) { + for (i = index + 1; i < self->numitems; i++) { + self->ItemList[i].loc += changeLen; + } + } + chlist_NotifyObservers(self, 0); + } + + void chlist__SetRegionString(self, str, regionNum, regionStr) + struct chlist *self; char *str; + long regionNum; + char *regionStr; + { + chlist_SetRegionStringByIndex(self, chlist_GetIndexByString(self, str), regionNum, regionStr); + + } + + void chlist__DefineRegion(self, regionNum) + struct chlist *self; + long regionNum; + { + long i; + + if (regionNum >= self->numRegionsAllocated) { + /* Need to reallocate region strings */ + self->numRegionsAllocated += 4; + + for (i = 0; i < self->numitems; i++) { + if (self->ItemList[i].regionStrings != NULL) { + self->ItemList[i].regionStrings = (char **) realloc(self->ItemList[i].regionStrings, self->numRegionsAllocated * sizeof(char *)); + } + } + } + if (regionNum >= self->numRegions) { + self->numRegions = regionNum + 1; + } + } + + void chlist__DefineStringRegion(self, regionNum) + struct chlist *self; + long regionNum; + { + long i; + + if (self->strRegionNum != regionNum && regionNum < self->numRegions && regionNum >= 0) { + for (i = 0; i < self->numitems; i++) { + if (self->ItemList[i].regionStrings != NULL) { + chlist_SetRegionStringByIndex(self, i, regionNum, self->ItemList[i].str); + chlist_SetRegionStringByIndex(self, i, self->strRegionNum, NULL); + } + self->ItemList[i].str = self->ItemList[i].regionStrings[regionNum]; + } + self->strRegionNum = regionNum; + } + } + + boolean chlist__AddItemAtIndex(self, index, str, proc, data) + struct chlist *self; + long index; + char *str; int (*proc)(); long data; { char *mycopy; struct listitem *newbuf; ! int pos, len, i; if (self->numitems >= self->numitemsallocated) { self->numitemsallocated += 25; *************** *** 39,74 **** } self->ItemList = newbuf; } ! mycopy = malloc(1+strlen(str)); if (!mycopy) { --self->numitems; return(FALSE); } strcpy(mycopy, str); ! pos = chlist_GetLength(self); ! len = strlen(str); chlist_AlwaysInsertCharacters(self, pos, str, len); chlist_AlwaysInsertCharacters(self, pos+len, "\n", 1); ! self->ItemList[self->numitems].str = mycopy; ! self->ItemList[self->numitems].proc = proc; ! self->ItemList[self->numitems].rock = data; ! self->ItemList[self->numitems].loc = pos; ++self->numitems; return(TRUE); } struct listitem * chlist__FindItem(self, str) struct chlist *self; char *str; { int i; ! i = FindItemIndex(self,str); if (i>= 0) return(&self->ItemList[i]); return(NULL); } ! static int FindItemIndex(self, str) struct chlist *self; char *str; { int i; --- 242,324 ---- } self->ItemList = newbuf; } ! len = strlen(str); ! mycopy = malloc(1+len); if (!mycopy) { --self->numitems; return(FALSE); } strcpy(mycopy, str); ! ! if (index >= self->numitems) { ! index = self->numitems; ! pos = chlist_GetLength(self); ! } ! else { ! pos = self->ItemList[index].loc; ! for (i = self->numitems; i > index; i--) { ! self->ItemList[i] = self->ItemList[i-1]; ! self->ItemList[i].loc += len + 1; ! } ! } ! chlist_AlwaysInsertCharacters(self, pos, str, len); chlist_AlwaysInsertCharacters(self, pos+len, "\n", 1); ! self->ItemList[index].str = mycopy; ! self->ItemList[index].proc = proc; ! self->ItemList[index].rock = data; ! self->ItemList[index].loc = pos; ! self->ItemList[index].regionStrings = NULL; ++self->numitems; + + chlist_NotifyObservers(self, 0); + return(TRUE); } + + boolean chlist__AddItemToEnd(self, str, proc, data) + struct chlist *self; + char *str; + int (*proc)(); + long data; + { + return chlist_AddItemAtIndex(self, self->numitems, str, proc, data); + } + struct listitem * chlist__FindItem(self, str) struct chlist *self; char *str; { int i; ! i = chlist_GetIndexByString(self,str); if (i>= 0) return(&self->ItemList[i]); return(NULL); } ! struct listitem * chlist__FindItemByIndex(self, index) struct chlist *self; + unsigned long index; + { + if (index < self->numitems) { + return (&self->ItemList[index]); + } + return NULL; + } + + procedure chlist__SetFreeProcedure(self, proc) + struct chlist *self; + procedure proc; + { + procedure oldproc = self->freeProc; + + self->freeProc = proc; + + return(oldproc); + } + + long chlist__GetIndexByString(self, str) + struct chlist *self; char *str; { int i; *************** *** 80,93 **** return(-1); } ! boolean chlist__DeleteItem(self, str) struct chlist *self; ! char *str; { ! int i = FindItemIndex(self, str); ! int len; ! if (i<0) return(FALSE); if ((i+1) < self->numitems) { len = self->ItemList[i+1].loc - self->ItemList[i].loc; } else { --- 330,355 ---- return(-1); } ! long chlist__GetIndexByData(self, data) struct chlist *self; ! long data; { ! int i; ! for (i=0; inumitems; ++i) { ! if (data == self->ItemList[i].rock) { ! return(i); ! } ! } ! return(-1); ! } ! boolean chlist__DeleteItemByIndex(self, i) ! struct chlist *self; ! long i; ! { ! int len, j; ! ! if (i<0 || i >= self->numitems) return(FALSE); if ((i+1) < self->numitems) { len = self->ItemList[i+1].loc - self->ItemList[i].loc; } else { *************** *** 94,100 **** len = chlist_GetLength(self) - self->ItemList[i].loc; } chlist_AlwaysDeleteCharacters(self, self->ItemList[i].loc, len); ! free(self->ItemList[i].str); self->numitems --; while (inumitems) { self->ItemList[i].str = self->ItemList[i+1].str; --- 356,376 ---- len = chlist_GetLength(self) - self->ItemList[i].loc; } chlist_AlwaysDeleteCharacters(self, self->ItemList[i].loc, len); ! if (self->freeProc != NULL && self->ItemList[i].rock != NULL) { ! (*self->freeProc)(self->ItemList[i].rock); ! } ! if (self->ItemList[i].regionStrings != NULL) { ! for (j = 0; j < self->numRegions; j++) { ! if (self->ItemList[i].regionStrings[j] != NULL) { ! free(self->ItemList[i].regionStrings[j]); ! } ! } ! free(self->ItemList[i].regionStrings); ! } ! else if (self->ItemList[i].str != NULL) { ! free(self->ItemList[i].str); ! } ! self->numitems --; while (inumitems) { self->ItemList[i].str = self->ItemList[i+1].str; *************** *** 101,106 **** --- 377,383 ---- self->ItemList[i].loc = self->ItemList[i+1].loc - len; self->ItemList[i].proc = self->ItemList[i+1].proc; self->ItemList[i].rock = self->ItemList[i+1].rock; + self->ItemList[i].regionStrings = self->ItemList[i+1].regionStrings; ++i; } chlist_NotifyObservers(self, 0); *************** *** 107,136 **** return(TRUE); } boolean chlist__ChangeItem(self, oldstr, newstr) struct chlist *self; char *oldstr, *newstr; { ! int delta_len; ! int i = FindItemIndex(self, oldstr); ! int newlen, oldlen, pos; ! if (i<0) return(FALSE); ! newlen = strlen(newstr); ! oldlen = strlen(oldstr); ! pos = self->ItemList[i].loc; ! chlist_AlwaysReplaceCharacters(self, pos, oldlen, newstr, newlen); ! self->ItemList[i].str = realloc(self->ItemList[i].str, 1+strlen(newstr)); ! if (!self->ItemList[i].str) return(FALSE); ! strcpy(self->ItemList[i].str, newstr); - delta_len = newlen - oldlen; - while ((++i)numitems) { /* adjust other entries' position */ - self->ItemList[i].loc += delta_len; - } chlist_NotifyObservers(self, 0); return(TRUE); } --- 384,555 ---- return(TRUE); } + boolean chlist__DeleteItem(self, str) + struct chlist *self; + char *str; + { + int i = chlist_GetIndexByString(self, str); + + return chlist_DeleteItemByIndex(self, i); + } + + boolean chlist__ChangeItemByIndex(self, index, newstr) + struct chlist *self; + long index; + char *newstr; + { + chlist_SetRegionStringByIndex(self, index, self->strRegionNum, newstr); + + return(TRUE); + } + boolean chlist__ChangeItem(self, oldstr, newstr) struct chlist *self; char *oldstr, *newstr; { ! return chlist_ChangeItemByIndex(self, chlist_GetIndexByString(self, oldstr), newstr); ! } ! boolean chlist__ChangeDataByIndex(self, i, rock) ! struct chlist *self; ! long i; ! long rock; ! { ! if (i<0 || i >= self->numitems) return(FALSE); ! if (self->freeProc != NULL && self->ItemList[i].rock != NULL) { ! (*self->freeProc)(self->ItemList[i].rock); ! } ! self->ItemList[i].rock = rock; chlist_NotifyObservers(self, 0); return(TRUE); } + + boolean chlist__ChangeData(self, oldstr, rock) + struct chlist *self; + char *oldstr; + long rock; + { + return chlist_ChangeDataByIndex(self, chlist_GetIndexByString(self, oldstr), rock); + } + + long chlist__GetRegionInfoForPosition(self, index, position, size, offset) + struct chlist *self; + long index; + long position; + long *size; + long *offset; + { + struct listitem *item = &self->ItemList[index]; + long itemPosition = item->loc; + long len; + long itemLen, regionSize, regionOffset, regionID; + + if (index < self->numitems - 1) { + itemLen = self->ItemList[index + 1].loc - item->loc - 1; + } + else { + itemLen = chlist_GetLength(self) - item->loc - 1; + } + + if (position == item->loc + itemLen) { + regionSize = 1; + regionOffset = 0; + regionID = -1; + } + else if (item->regionStrings == NULL) { + regionID = self->strRegionNum; + regionSize = itemLen; + regionOffset = itemPosition - position; + } + else { + + long i; + + regionID = -1; + + for (i = 0; i < self->numRegions; i++) { + len = (item->regionStrings[i] != NULL) ? strlen(item->regionStrings[i]) : 0; + if (itemPosition + len > position) { + regionID = i; + regionSize = len; + regionOffset = position - itemPosition; + break; + } + else { + itemPosition += len; + } + } + } + if (size != NULL) { + *size = regionSize; + } + if (offset != NULL) { + *offset = regionOffset; + } + + return regionID; + } + + long chlist__GetIndexByPosition(self, position, regionID, size, offset) + struct chlist *self; + long position; + long *regionID; + long *size; + long *offset; + { + long min = 0; + long max = self->numitems - 1; + long split; + + while (max > min) { + split = min + (max-min)/2; + if (self->ItemList[split].loc > position) { + max = split - 1; + } else { + if (min == split) { + if (self->ItemList[max].loc <= position) { + min = max; + } + break; + } + min = split; + } + } + if (min < self->numitems) { + /* found an item */ + long region = chlist_GetRegionInfoForPosition(self, min, position, size, offset); + + if (regionID != NULL) { + *regionID = region; + } + + return min; + } + return -1; + } + + void chlist__EnumerateItems(self, index, length, proc, rock) + struct chlist *self; + long index; + long length; + procedure proc; + long rock; + { + long endIndex = index + length; + + if (endIndex > self->numitems) { + endIndex = self->numitems; + } + + while (index != endIndex) { + if (! (*proc)(self, &self->ItemList[index], index, rock)) { + return; + } + index++; + } + } + *** atk/champ/chlist.ch Wed Nov 22 11:53:12 1989 --- atk/champ/chlist.ch.NEW Sun Jun 10 18:38:06 1990 *************** *** 7,26 **** int loc; int (*proc)(); long rock; }; class chlist:text { classprocedures: InitializeObject(struct chlist *self) returns boolean; methods: ! AddItemToEnd(char *str, procedure proc, long data) returns boolean; DeleteItem(char *str) returns boolean; FindItem(char *str) returns struct listitem *; ChangeItem(char *oldstr, char *newstr) returns boolean; macromethods: GetItemList() (self->ItemList) GetNumItems() (self->numitems) data: struct listitem *ItemList; int numitems, numitemsallocated; }; --- 7,51 ---- int loc; int (*proc)(); long rock; + char **regionStrings; }; class chlist:text { classprocedures: InitializeObject(struct chlist *self) returns boolean; + FinalizeObject(struct chlist *self); + overrides: + Clear(); methods: ! AddItemAtIndex(char *str, long index, procedure proc, long rock) returns boolean; ! AddItemToEnd(char *str, procedure proc, long rock) returns boolean; DeleteItem(char *str) returns boolean; + DeleteItemByIndex(long index) returns boolean; + GetIndexByString(char *str) returns long; + GetIndexByData(long rock) returns long; FindItem(char *str) returns struct listitem *; + FindItemByIndex(unsigned long index) returns struct listitem *; + SetFreeProcedure(procedure freeProc) returns procedure; ChangeItem(char *oldstr, char *newstr) returns boolean; + ChangeItemByIndex(long index, char *newstr) returns boolean; + ChangeData(char *oldstr, long rock) returns boolean; + ChangeDataByIndex(long index, long rock) returns boolean; + DefineRegion(long regionNum); + DefineStringRegion(long regionNum); + SetRegionStringByIndex(long index, long regionNum, char *regionStr); + SetRegionString(char *str, long regionNum, char *regionStr); + GetRegionInfoForPosition(long index, long position, long *size, long *offset) returns long; + GetIndexByPosition(long position, long *regionID, long *size, long *offset) returns long; + EnumerateItems(long startIndex, long length, procedure proc, long rock); + macromethods: GetItemList() (self->ItemList) GetNumItems() (self->numitems) + GetNumRegions() (self->numRegions) data: struct listitem *ItemList; int numitems, numitemsallocated; + procedure freeProc; + int numRegions, numRegionsAllocated; + int strRegionNum; }; *** atk/champ/chlistv.c Wed Nov 22 11:53:30 1989 --- atk/champ/chlistv.c.NEW Sun Jun 10 18:38:08 1990 *************** *** 3,51 **** * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ #include "class.h" #include "view.ih" #include "chlist.ih" #include "chlistv.eh" boolean chlistview__InitializeObject(c, self) struct classheader *c; struct chlistview *self; { return(TRUE); } struct view *chlistview__Hit(self, action, x, y, nclicks) struct chlistview *self; enum view_MouseAction action; long x, y, nclicks; { ! int pos, min, max, split; struct chlist *l; ! super_Hit(self, action, x, y, 3); /* always select whole line */ l = (struct chlist *) chlistview_GetDataObject(self); pos = chlistview_GetDotPosition(self); ! min = 0; ! max = l->numitems - 1; ! while (max > min) { ! split = min + (max-min)/2; ! if (l->ItemList[split].loc > pos) { ! max = split - 1; ! } else { ! if (min == split) { ! if (l->ItemList[max].loc <= pos) { ! min = max; ! } ! break; ! } ! min = split; } } - if (min < l->numitems) { - if (l->ItemList[min].proc) { - (l->ItemList[min].proc)(l->ItemList[min].rock, l, action, nclicks); - } - } return((struct view *) self); } --- 3,82 ---- * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ #include "class.h" + #include "text.ih" #include "view.ih" #include "chlist.ih" + #include "style.ih" #include "chlistv.eh" + static boolean chlistview_Debug = FALSE; + + + void chlistview__SetUpdateRegion(self, pos, len) + struct chlistview *self; + long pos; + long len; + { + struct textview *tv = (struct textview *) self; + long i; + + for (i = 0; i < tv->nLines; i++) { + if (pos < mark_GetEndPos(tv->lines[i].data) && (pos + len) >= mark_GetPos(tv->lines[i].data)) { + mark_SetModified(tv->lines[i].data, TRUE); + } + } + if (pos < mark_GetEndPos(tv->predrawn) && (pos + len) >= mark_GetPos(tv->predrawn)) { + mark_SetModified(tv->predrawn, TRUE); + } + if (pos < mark_GetEndPos(tv->prepredrawn) && (pos + len) >= mark_GetPos(tv->prepredrawn)) { + mark_SetModified(tv->prepredrawn, TRUE); + } + + chlistview_WantUpdate(self, self); + } + + boolean chlistview__InitializeObject(c, self) struct classheader *c; struct chlistview *self; { + self->highlightedItem = -1; + self->numStylesAllocated = 0; + self->normalStyles = NULL; + self->highlightedStyles = NULL; return(TRUE); } + void chlistview__FinalizeObject(c, self) + struct classheader *c; + struct chlistview *self; + { + if (self->normalStyles != NULL) { + free(self->normalStyles); + } + if (self->highlightedStyles != NULL) { + free(self->highlightedStyles); + } + } + struct view *chlistview__Hit(self, action, x, y, nclicks) struct chlistview *self; enum view_MouseAction action; long x, y, nclicks; { ! int pos, index, region; struct chlist *l; ! super_Hit(self, action, x, y, nclicks); l = (struct chlist *) chlistview_GetDataObject(self); pos = chlistview_GetDotPosition(self); ! index = chlist_GetIndexByPosition(l, pos, ®ion, NULL, NULL); ! if (index >= 0) { ! chlistview_HighlightItem(self, index); ! if (l->ItemList[index].proc) { ! (l->ItemList[index].proc)(l->ItemList[index].rock, l, action, nclicks, index, region); } } return((struct view *) self); } *************** *** 53,75 **** struct chlistview *self; int pos; { ! int i, len; struct chlist *l; l = (struct chlist *) chlistview_GetDataObject(self); ! for (i=0; i < l->numitems && l->ItemList[i].loc < pos; ++i) { ! ; } ! if (inumitems) { ! len = l->ItemList[i].loc - l->ItemList[i-1].loc; ! } else { ! len = chlist_GetLength(l) - l->ItemList[i-1].loc; } ! --i; ! chlistview_SetDotPosition(self, l->ItemList[i].loc); ! chlistview_SetDotLength(self, len); ! if (l->ItemList[i].proc) { ! (l->ItemList[i].proc)(l->ItemList[i].rock, l, view_LeftDown, 3); } - chlistview_WantInputFocus(self, self); } --- 84,241 ---- struct chlistview *self; int pos; { ! int region, index; struct chlist *l; l = (struct chlist *) chlistview_GetDataObject(self); ! index = chlist_GetIndexByPosition(l, pos, ®ion, NULL, NULL); ! if (index >= 0) { ! chlistview_HighlightItem(self, index); ! if (l->ItemList[index].proc) { ! (l->ItemList[index].proc)(l->ItemList[index].rock, l, view_LeftDown, 1, index, region); ! } } ! chlistview_WantInputFocus(self, self); ! } ! ! void chlistview__HighlightItem(self, index) ! struct chlistview *self; ! long index; ! { ! if (self->highlightedItem != index) { ! struct chlist *l; ! long len; ! struct listitem *item, *nextItem; ! ! chlistview_UnhighlightItem(self, self->highlightedItem); ! ! if (index >= 0) { ! l = (struct chlist *) chlistview_GetDataObject(self); ! item = chlist_FindItemByIndex(l, index); ! if (index == (chlist_GetNumItems(l) - 1)) { ! len = chlist_GetLength(l); ! } ! else { ! nextItem = chlist_FindItemByIndex(l, index + 1); ! len = nextItem->loc; ! } ! len -= (item->loc + 1); ! ! chlistview_SetUpdateRegion(self, item->loc, len); ! chlistview_WantUpdate(self, self); ! } ! ! self->highlightedItem = index; } ! } ! ! void chlistview__UnhighlightItem(self, index) ! struct chlistview *self; ! long index; ! { ! if (self->highlightedItem >= 0) { ! struct chlist *l; ! long len; ! struct listitem *item, *nextItem; ! ! l = (struct chlist *) chlistview_GetDataObject(self); ! item = chlist_FindItemByIndex(l, self->highlightedItem); ! nextItem = chlist_FindItemByIndex(l, self->highlightedItem + 1); ! ! len = (self->highlightedItem == chlist_GetNumItems(l) - 1) ? chlist_GetLength(l) : nextItem->loc; ! len -= (item->loc + 1); ! ! chlistview_SetUpdateRegion(self, item->loc, len); ! ! self->highlightedItem = -1; ! chlistview_WantUpdate(self, self); } } + + struct environment *chlistview__GetStyleInformation(self, sv, pos, length) + struct chlistview *self; + struct text_statevector *sv; + long pos; + long *length; + { + struct environment *env; + long index, regionID, size, offset; + struct style *style; + struct chlist *l; + + l = (struct chlist *) chlistview_GetDataObject(self); + + env = super_GetStyleInformation(self, sv, pos, length); + index = chlist_GetIndexByPosition(l, pos, ®ionID, &size, &offset); + + if (chlistview_Debug) { + long len = (length == NULL) ? -1 : *length; + + printf("pos: %d length: %d index: %d regionID: %d size: %d offset: %d\n", pos, len, index, regionID, size, offset); + } + + if (index >= 0 && regionID >= 0) { + style = chlistview_GetRegionStyle(self, regionID, FALSE); + if (style != NULL) { + text_ApplyEnvironment(sv, style, NULL); + } + if (index == self->highlightedItem) { + style = chlistview_GetRegionStyle(self, regionID, TRUE); + if (style != NULL) { + text_ApplyEnvironment(sv, style, NULL); + } + } + if (length != NULL && (size - offset) < *length) { + *length = size - offset; + } + } + + return env; + } + + struct style *chlistview__GetRegionStyle(self, regionID, highlighted) + struct chlistview *self; + long regionID; + boolean highlighted; + { + if (self->normalStyles != NULL) { + if (highlighted) { + return self->highlightedStyles[regionID]; + } + else { + return self->normalStyles[regionID]; + } + } + return NULL; + } + + void chlistview__SetRegionStyles(self, regionID, normalStyle, highlightStyle) + struct chlistview *self; + long regionID; + struct style *normalStyle; + struct style *highlightStyle; + { + long oldSize; + + if (regionID >= (oldSize = self->numStylesAllocated)) { + self->numStylesAllocated = regionID + 4; + if (self->normalStyles == NULL) { + self->normalStyles = (struct style **) calloc(self->numStylesAllocated, sizeof(struct style *)); + self->highlightedStyles = (struct style **) calloc(self->numStylesAllocated, sizeof(struct style *)); + } + else { + self->normalStyles = (struct style **) realloc(self->normalStyles, self->numStylesAllocated * sizeof(struct style *)); + self->highlightedStyles = (struct style **) realloc(self->highlightedStyles, self->numStylesAllocated * sizeof(struct style *)); + while (oldSize < self->numStylesAllocated) { + self->normalStyles[oldSize] = NULL; + self->highlightedStyles[oldSize] = NULL; + oldSize++; + } + } + } + + self->normalStyles[regionID] = normalStyle; + self->highlightedStyles[regionID] = highlightStyle; + } + + *** atk/champ/chlistv.ch Wed Nov 22 11:52:56 1989 --- atk/champ/chlistv.ch.NEW Sun Jun 10 18:38:09 1990 *************** *** 5,12 **** --- 5,25 ---- class chlistview[chlistv]:textview[textv] { classprocedures: InitializeObject(struct chlistview *self) returns boolean; + FinalizeObject(struct chlistview *self); overrides: Hit (enum view_MouseAction action, long x, long y, long numberOfClicks) returns struct view *; + GetStyleInformation(struct text_statevector *sv, long pos, long *length) returns struct environment *; methods: ActivateItem(int pos); + HighlightItem(long index); + UnhighlightItem(long index); + GetRegionStyle(long regionID, boolean highlighted) returns struct style *; + SetRegionStyles(long regionID, struct style *normalStyle, struct style highlightStyle); + + SetUpdateRegion(long pos, long len); + data: + long highlightedItem; + long numStylesAllocated; + struct style **normalStyles; + struct style **highlightedStyles; }; *** atk/chart/chart.h Wed Nov 22 11:54:39 1989 --- atk/chart/chart.h.NEW Wed Jun 13 20:29:54 1990 *************** *** 41,47 **** { struct chart *data_object; struct chartobj *data_viewer; ! struct matrix /*===*/ *form_object, *sort_palette_object; struct suite *control_suite_object, *sort_position_suite_object, *sort_value_suite_object, *sort_label_suite_object, *type_suite_object, *title_suite_object; --- 41,47 ---- { struct chart *data_object; struct chartobj *data_viewer; ! struct suite /*===*/ *form_object, *sort_palette_object; struct suite *control_suite_object, *sort_position_suite_object, *sort_value_suite_object, *sort_label_suite_object, *type_suite_object, *title_suite_object; *** atk/chart/chartmap.c Wed Nov 22 11:54:27 1989 --- atk/chart/chartmap.c.NEW Wed Jun 13 20:29:57 1990 *************** *** 7,17 **** /* $Source $ */ #ifndef lint ! static char *rcsidchartmap = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/chart/RCS/chartmap.c,v 1.1 89/04/28 22:45:04 tom Exp $"; #endif /* $Log: chartmap.c,v $ * Revision 1.1 89/04/28 22:45:04 tom * Initial revision * --- 7,20 ---- /* $Source $ */ #ifndef lint ! static char *rcsidchartmap = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/chart/RCS/chartmap.c,v 1.2 90/06/13 18:54:40 gk5g Exp $"; #endif /* $Log: chartmap.c,v $ + * Revision 1.2 90/06/13 18:54:40 gk5g + * Fixed up the palette feature. The palette used to use a matix view but it now used a suite. + * * Revision 1.1 89/04/28 22:45:04 tom * Initial revision * *************** *** 46,66 **** END-SPECIFICATION ************************************************************/ #include #include ! #include "class.h" ! #include "graphic.ih" ! #include "observe.ih" ! #include "view.ih" ! #include "im.ih" ! #include "rect.h" ! #include "apt.h" ! #include "aptv.ih" ! #include "chartobj.ih" ! #include "chart.ih" ! #include "chartmap.eh" #include ! #include "zip.ih" ! #include "zipv.ih" #define Screen 1 #define Paper 2 --- 49,73 ---- END-SPECIFICATION ************************************************************/ #include + #include + #ifndef _IBMR2 #include ! #endif /* _IBMR2 */ ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include ! #include #include ! #include ! #include #define Screen 1 #define Paper 2 *************** *** 96,102 **** { register boolean status = TRUE; register FILE *file; ! /*===*/ register char *file_name = "usa.states.zip"; IN(chartmap_InitializeObject); chartmap_SetShrinkIcon( self, 'e', "icon12", "MapChart", "andysans10b" ); --- 103,109 ---- { register boolean status = TRUE; register FILE *file; ! char file_name[MAXPATHLEN]; IN(chartmap_InitializeObject); chartmap_SetShrinkIcon( self, 'e', "icon12", "MapChart", "andysans10b" ); *************** *** 107,112 **** --- 114,121 ---- if ( ZipView = zipview_New() ) { zipview_SetDataObject( ZipView, Zip ); + strcpy(file_name, environ_AndrewDir("/lib/zip/samples/states.zip")); + printf("file_name: '%s'\n", file_name); if ( file = fopen( file_name, "r" ) ) { if ( zip_Read( Zip, file, 1234 ) ) *** atk/chart/chartp.c Wed Nov 22 11:54:41 1989 --- atk/chart/chartp.c.NEW Wed Jun 13 20:29:59 1990 *************** *** 4,10 **** \* ********************************************************************** */ #ifndef lint ! static char *rcsidchartp = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/chart/RCS/chartp.c,v 1.6 89/09/14 14:16:56 tom Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* --- 4,10 ---- \* ********************************************************************** */ #ifndef lint ! static char *rcsidchartp = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/chart/RCS/chartp.c,v 1.7 90/06/13 18:54:49 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* *************** *** 52,58 **** #include #include #include - /*===#include ===*/ #include #define add_code 1 --- 52,57 ---- *************** *** 66,72 **** #define histogram_code 10 /*=== Must be dynamic===*/ #define dot_code 11 #define pie_code 12 ! #define map_code 13 #define stack_code 14 #define cartesian_code 15 #define line_code 16 --- 65,71 ---- #define histogram_code 10 /*=== Must be dynamic===*/ #define dot_code 11 #define pie_code 12 ! /*#define map_code 13*/ #define stack_code 14 #define cartesian_code 15 #define line_code 16 *************** *** 81,198 **** { suite_ItemCaptionFontName( ItemCaptionFontNamePhrase ), suite_ItemCaption("Add"), ! suite_ItemDatum(add_code), 0 }; suite_Specification delete_button[] = { suite_ItemCaption("Delete"), ! suite_ItemDatum(delete_code), 0 }; suite_Specification histogram_button[] = { suite_ItemCaption("Histogram"), /*===NAMES MUST BE DYNAMIC===*/ ! suite_ItemDatum(histogram_code), 0 }; suite_Specification line_button[] = { suite_ItemCaption("Line"), ! suite_ItemDatum(line_code), 0 }; suite_Specification dot_button[] = { suite_ItemCaption("Dot"), ! suite_ItemDatum(dot_code), 0 }; suite_Specification pie_button[] = { suite_ItemCaption("Pie"), ! suite_ItemDatum(pie_code), 0 }; ! suite_Specification map_button[] = { suite_ItemCaption("Map"), ! suite_ItemDatum(map_code), 0 }; suite_Specification stack_button[] = { suite_ItemCaption("Stack"), ! suite_ItemDatum(stack_code), 0 }; suite_Specification cartesian_button[] = { suite_ItemCaption("Cartesian"), ! suite_ItemDatum(cartesian_code), 0 }; suite_Specification sort_ascend_label_button[] = { suite_ItemCaption(AscendPhrase), ! suite_ItemDatum(sort_ascend_label_code), 0 }; suite_Specification sort_descend_label_button[] = { suite_ItemCaption(DescendPhrase), ! suite_ItemDatum(sort_descend_label_code), 0 }; suite_Specification sort_ascend_value_button[] = { suite_ItemCaption(AscendPhrase), ! suite_ItemDatum(sort_ascend_value_code), 0 }; suite_Specification sort_descend_value_button[] = { suite_ItemCaption(DescendPhrase), ! suite_ItemDatum(sort_descend_value_code), 0 }; suite_Specification sort_ascend_position_button[] = { suite_ItemCaption(AscendPhrase), ! suite_ItemDatum(sort_ascend_position_code), 0 }; suite_Specification sort_descend_position_button[] = { suite_ItemCaption(DescendPhrase), ! suite_ItemDatum(sort_descend_position_code), 0 }; suite_Specification print_button[] = { suite_ItemCaption(PrintPhrase), ! suite_ItemDatum(print_code), 0 }; suite_Specification save_button[] = { suite_ItemCaption(SavePhrase), ! suite_ItemDatum(save_code), 0 }; long Palette_Titles_Handler(); suite_Specification top_title_button[] = { suite_ItemTitleCaption( TopPhrase ), suite_ItemAccessMode( suite_ReadWrite ), suite_ItemHitHandler( Palette_Titles_Handler ), ! suite_ItemDatum(top_title_code), 0 }; suite_Specification bottom_title_button[] = { suite_ItemTitleCaption( BottomPhrase ), suite_ItemAccessMode( suite_ReadWrite ), suite_ItemHitHandler( Palette_Titles_Handler ), ! suite_ItemDatum(bottom_title_code), 0 }; suite_Specification left_title_button[] = { suite_ItemTitleCaption( LeftPhrase ), suite_ItemAccessMode( suite_ReadWrite ), suite_ItemHitHandler( Palette_Titles_Handler ), ! suite_ItemDatum(left_title_code), 0 }; suite_Specification right_title_button[] = { suite_ItemTitleCaption( RightPhrase ), suite_ItemAccessMode( suite_ReadWrite ), suite_ItemHitHandler( Palette_Titles_Handler ), ! suite_ItemDatum(right_title_code), 0 }; ! long Palette_Hit(); suite_Specification sort_label_buttons[] = { suite_TitleCaption( "By Label" ), --- 80,241 ---- { suite_ItemCaptionFontName( ItemCaptionFontNamePhrase ), suite_ItemCaption("Add"), ! suite_ItemDatum(add_code), ! NULL }; + suite_Specification delete_button[] = { suite_ItemCaption("Delete"), ! suite_ItemDatum(delete_code), ! NULL }; + suite_Specification histogram_button[] = { suite_ItemCaption("Histogram"), /*===NAMES MUST BE DYNAMIC===*/ ! suite_ItemDatum(histogram_code), ! NULL }; + suite_Specification line_button[] = { suite_ItemCaption("Line"), ! suite_ItemDatum(line_code), ! NULL }; + suite_Specification dot_button[] = { suite_ItemCaption("Dot"), ! suite_ItemDatum(dot_code), ! NULL }; + suite_Specification pie_button[] = { suite_ItemCaption("Pie"), ! suite_ItemDatum(pie_code), ! NULL }; ! ! /*suite_Specification map_button[] = { suite_ItemCaption("Map"), ! suite_ItemDatum(map_code), ! NULL }; + */ suite_Specification stack_button[] = { suite_ItemCaption("Stack"), ! suite_ItemDatum(stack_code), ! NULL }; + suite_Specification cartesian_button[] = { suite_ItemCaption("Cartesian"), ! suite_ItemDatum(cartesian_code), ! NULL }; + suite_Specification sort_ascend_label_button[] = { suite_ItemCaption(AscendPhrase), ! suite_ItemDatum(sort_ascend_label_code), ! NULL }; + suite_Specification sort_descend_label_button[] = { suite_ItemCaption(DescendPhrase), ! suite_ItemDatum(sort_descend_label_code), ! NULL }; + suite_Specification sort_ascend_value_button[] = { suite_ItemCaption(AscendPhrase), ! suite_ItemDatum(sort_ascend_value_code), ! NULL }; + suite_Specification sort_descend_value_button[] = { suite_ItemCaption(DescendPhrase), ! suite_ItemDatum(sort_descend_value_code), ! NULL }; + suite_Specification sort_ascend_position_button[] = { suite_ItemCaption(AscendPhrase), ! suite_ItemDatum(sort_ascend_position_code), ! NULL }; + suite_Specification sort_descend_position_button[] = { suite_ItemCaption(DescendPhrase), ! suite_ItemDatum(sort_descend_position_code), ! NULL }; + suite_Specification print_button[] = { suite_ItemCaption(PrintPhrase), ! suite_ItemDatum(print_code), ! NULL }; + suite_Specification save_button[] = { suite_ItemCaption(SavePhrase), ! suite_ItemDatum(save_code), ! NULL }; + long Palette_Titles_Handler(); + suite_Specification top_title_button[] = { suite_ItemTitleCaption( TopPhrase ), suite_ItemAccessMode( suite_ReadWrite ), suite_ItemHitHandler( Palette_Titles_Handler ), ! suite_ItemDatum(top_title_code), ! NULL }; + suite_Specification bottom_title_button[] = { suite_ItemTitleCaption( BottomPhrase ), suite_ItemAccessMode( suite_ReadWrite ), suite_ItemHitHandler( Palette_Titles_Handler ), ! suite_ItemDatum(bottom_title_code), ! NULL }; + suite_Specification left_title_button[] = { suite_ItemTitleCaption( LeftPhrase ), suite_ItemAccessMode( suite_ReadWrite ), suite_ItemHitHandler( Palette_Titles_Handler ), ! suite_ItemDatum(left_title_code), ! NULL }; + suite_Specification right_title_button[] = { suite_ItemTitleCaption( RightPhrase ), suite_ItemAccessMode( suite_ReadWrite ), suite_ItemHitHandler( Palette_Titles_Handler ), ! suite_ItemDatum(right_title_code), ! NULL }; ! ! struct view *Palette_Hit(); ! suite_Specification sort_label_buttons[] = { suite_TitleCaption( "By Label" ), *************** *** 204,211 **** suite_HitHandler( Palette_Hit ), suite_Item( sort_ascend_label_button ), suite_Item( sort_descend_label_button ), ! 0 }; suite_Specification sort_value_buttons[] = { suite_TitleCaption( "By Value" ), --- 247,255 ---- suite_HitHandler( Palette_Hit ), suite_Item( sort_ascend_label_button ), suite_Item( sort_descend_label_button ), ! NULL }; + suite_Specification sort_value_buttons[] = { suite_TitleCaption( "By Value" ), *************** *** 217,224 **** suite_HitHandler( Palette_Hit ), suite_Item( sort_ascend_value_button ), suite_Item( sort_descend_value_button ), ! 0 }; suite_Specification sort_position_buttons[] = { suite_TitleCaption( "By Position" ), --- 261,269 ---- suite_HitHandler( Palette_Hit ), suite_Item( sort_ascend_value_button ), suite_Item( sort_descend_value_button ), ! NULL }; + suite_Specification sort_position_buttons[] = { suite_TitleCaption( "By Position" ), *************** *** 230,237 **** suite_HitHandler( Palette_Hit ), suite_Item( sort_ascend_position_button ), suite_Item( sort_descend_position_button ), ! 0 }; suite_Specification type_buttons[] = { suite_TitleCaption( "Chart Types" ), --- 275,283 ---- suite_HitHandler( Palette_Hit ), suite_Item( sort_ascend_position_button ), suite_Item( sort_descend_position_button ), ! NULL }; + suite_Specification type_buttons[] = { suite_TitleCaption( "Chart Types" ), *************** *** 245,254 **** suite_Item( dot_button ), suite_Item( line_button ), suite_Item( pie_button ), ! suite_Item( map_button ), suite_Item( stack_button ), suite_Item( cartesian_button ), ! 0 }; suite_Specification title_buttons[] = --- 291,300 ---- suite_Item( dot_button ), suite_Item( line_button ), suite_Item( pie_button ), ! /* suite_Item( map_button ),*/ suite_Item( stack_button ), suite_Item( cartesian_button ), ! NULL }; suite_Specification title_buttons[] = *************** *** 258,270 **** suite_TitleCaptionFontHigh( 12 ), suite_ItemCaptionFontName( ItemCaptionFontNamePhrase ), suite_ItemCaptionFontHigh( 10 ), ! suite_Arrangement( suite_Matrix ), suite_Item( top_title_button ), suite_Item( bottom_title_button ), suite_Item( left_title_button ), suite_Item( right_title_button ), ! 0 }; suite_Specification control_buttons[] = { suite_TitleCaption( "Controls" ), --- 304,317 ---- suite_TitleCaptionFontHigh( 12 ), suite_ItemCaptionFontName( ItemCaptionFontNamePhrase ), suite_ItemCaptionFontHigh( 10 ), ! suite_Arrangement( suite_Column ), suite_Item( top_title_button ), suite_Item( bottom_title_button ), suite_Item( left_title_button ), suite_Item( right_title_button ), ! NULL }; + suite_Specification control_buttons[] = { suite_TitleCaption( "Controls" ), *************** *** 278,307 **** suite_Item( delete_button ), suite_Item( print_button ), suite_Item( save_button ), ! 0 }; ! /*=== ! matrix_Specification palette_matrix[] = { ! matrix_Rows( 2 ), ! matrix_Columns( 2 ), ! 0 }; ! matrix_Specification sort_matrix[] = { ! matrix_Rows( 1 ), ! matrix_Columns( 3 ), ! matrix_TitleCaption( "Sort" ), ! matrix_TitleCaptionFontName( "Andysans12b" ), ! 0 }; - ===*/ - ! #define SetCellView(m,r,c,v) \ ! matrix_SetCellAttribute(m,matrix_CellAtPosition(m,r,c),matrix_CellViewObject(v)) long Initialize_Palette( self ) /*=== CONVERT TO REAL FORM ===*/ register struct chartv *self; --- 325,410 ---- suite_Item( delete_button ), suite_Item( print_button ), suite_Item( save_button ), ! NULL }; ! ! #define palette_item1_code 1 ! #define palette_item2_code 2 ! #define palette_item3_code 3 ! #define palette_item4_code 4 ! ! #define sort_item1_code 1 ! #define sort_item2_code 2 ! #define sort_item3_code 3 ! ! suite_Specification palette_item1[] = { ! suite_ItemDatum( palette_item1_code ), ! NULL }; ! suite_Specification palette_item2[] = { ! suite_ItemDatum( palette_item2_code ), ! NULL }; ! suite_Specification palette_item3[] = ! { ! suite_ItemDatum( palette_item3_code ), ! NULL ! }; + suite_Specification palette_item4[] = + { + suite_ItemDatum( palette_item4_code ), + NULL + }; + + suite_Specification palette_suite[] = + { + suite_Arrangement( suite_Matrix ), + suite_ItemHighlightStyle( suite_None ), + suite_Item( palette_item1 ), + suite_Item( palette_item2 ), + suite_Item( palette_item3 ), + suite_Item( palette_item4 ), + NULL + }; + + suite_Specification sort_item1[] = + { + suite_ItemDatum( sort_item1_code ), + NULL + }; + + suite_Specification sort_item2[] = + { + suite_ItemDatum( sort_item2_code ), + NULL + }; + + suite_Specification sort_item3[] = + { + suite_ItemDatum( sort_item3_code ), + NULL + }; + + suite_Specification sort_suite[] = + { + suite_Arrangement( suite_Row ), + suite_ItemHighlightStyle( suite_None ), + suite_Item( sort_item1 ), + suite_Item( sort_item2 ), + suite_Item( sort_item3 ), + suite_TitleCaption( "Sort" ), + suite_TitleCaptionFontName( "Andysans12b" ), + NULL + }; + + #define SetItemView(suite,item,v) \ + suite_ItemViewObject(suite,item) = ((struct view*)v) + long Initialize_Palette( self ) /*=== CONVERT TO REAL FORM ===*/ register struct chartv *self; *************** *** 309,315 **** register long status = ok; IN(Initialize_Palette); - /*=== if ( ! PaletteInitialized ) { PaletteInitialized = true; --- 412,417 ---- *************** *** 319,326 **** ((SortPositionSuite = suite_Create( sort_position_buttons, self )) == NULL ) || ((TypeSuite = suite_Create( type_buttons, self )) == NULL ) || ((TitleSuite = suite_Create( title_buttons, self )) == NULL ) || ! ((Palette = matrix_Create( palette_matrix, self )) == NULL ) || ! ((SortForm = matrix_Create( sort_matrix, self )) == NULL ) ) { DEBUG(Object Creation Failed); status = failure; printf( "ChartV: Failed to Create Palette Object\n" ); --- 421,428 ---- ((SortPositionSuite = suite_Create( sort_position_buttons, self )) == NULL ) || ((TypeSuite = suite_Create( type_buttons, self )) == NULL ) || ((TitleSuite = suite_Create( title_buttons, self )) == NULL ) || ! ((Palette = suite_Create( palette_suite, self )) == NULL ) || ! ((SortForm = suite_Create( sort_suite, self )) == NULL ) ) { DEBUG(Object Creation Failed); status = failure; printf( "ChartV: Failed to Create Palette Object\n" ); *************** *** 339,359 **** suite_ItemCaption( chart_AreaTitle( Chart, apt_RightArea ) ) ); suite_SetItemAttribute( TitleSuite, suite_ItemOfDatum( TitleSuite, bottom_title_code ), suite_ItemCaption( chart_AreaTitle( Chart, apt_BottomArea ) ) ); ! SetCellView( Palette, 1, 1, ControlSuite ); ! SetCellView( Palette, 1, 2, TitleSuite ); ! SetCellView( Palette, 2, 1, SortForm ); ! SetCellView( Palette, 2, 2, TypeSuite ); ! SetCellView( SortForm, 1, 1, SortLabelSuite ); ! SetCellView( SortForm, 1, 2, SortValueSuite ); ! SetCellView( SortForm, 1, 3, SortPositionSuite ); PaletteFrame = frame_New(); frame_SetView( PaletteFrame, Palette ); - frame_SetCommandEnable( PaletteFrame, TRUE ); frame_PostDefaultHandler( PaletteFrame, "message", frame_WantHandler( PaletteFrame, "message" ) ); } } - ===*/ OUT(Initialize_Palette); return status; } --- 441,459 ---- suite_ItemCaption( chart_AreaTitle( Chart, apt_RightArea ) ) ); suite_SetItemAttribute( TitleSuite, suite_ItemOfDatum( TitleSuite, bottom_title_code ), suite_ItemCaption( chart_AreaTitle( Chart, apt_BottomArea ) ) ); ! SetItemView( Palette, suite_ItemOfDatum(Palette,palette_item1_code), ControlSuite ); ! SetItemView( Palette, suite_ItemOfDatum(Palette,palette_item2_code), TitleSuite ); ! SetItemView( Palette, suite_ItemOfDatum(Palette,palette_item3_code), SortForm ); ! SetItemView( Palette, suite_ItemOfDatum(Palette,palette_item4_code), TypeSuite ); ! SetItemView( SortForm, suite_ItemOfDatum(SortForm,sort_item1_code), SortLabelSuite ); ! SetItemView( SortForm, suite_ItemOfDatum(SortForm,sort_item2_code), SortValueSuite ); ! SetItemView( SortForm, suite_ItemOfDatum(SortForm,sort_item3_code), SortPositionSuite ); PaletteFrame = frame_New(); frame_SetView( PaletteFrame, Palette ); frame_PostDefaultHandler( PaletteFrame, "message", frame_WantHandler( PaletteFrame, "message" ) ); } } OUT(Initialize_Palette); return status; } *************** *** 361,367 **** Destroy_Palette( self ) register struct chartv *self; { - /*=== if ( ControlSuite ) suite_Destroy( ControlSuite ); if ( TitleSuite ) suite_Destroy( TitleSuite ); if ( TypeSuite ) suite_Destroy( TypeSuite ); --- 461,466 ---- *************** *** 368,376 **** if ( SortValueSuite ) suite_Destroy( SortValueSuite ); if ( SortLabelSuite ) suite_Destroy( SortLabelSuite ); if ( SortPositionSuite ) suite_Destroy( SortPositionSuite ); ! if ( Palette ) matrix_Destroy( Palette ); ! if ( SortForm ) matrix_Destroy( SortForm ); ! ===*/ } void --- 467,474 ---- if ( SortValueSuite ) suite_Destroy( SortValueSuite ); if ( SortLabelSuite ) suite_Destroy( SortLabelSuite ); if ( SortPositionSuite ) suite_Destroy( SortPositionSuite ); ! if ( Palette ) suite_Destroy( Palette ); ! if ( SortForm ) suite_Destroy( SortForm ); } void *************** *** 408,418 **** OUT(Hide_Palette); } ! long Palette_Hit( self, suite, item, type, action, x, y, clicks ) register struct chartv *self; register struct suite *suite; register struct suite_item *item; register enum view_MouseAction action; register long x, y, clicks; { --- 506,517 ---- OUT(Hide_Palette); } ! struct view * Palette_Hit( self, suite, item, type, action, x, y, clicks ) register struct chartv *self; register struct suite *suite; register struct suite_item *item; + register long type; register enum view_MouseAction action; register long x, y, clicks; { *************** *** 434,440 **** case dot_code: case line_code: case pie_code: ! case map_code: case stack_code: case cartesian_code: DEBUG(Types); ReChart( self, suite_ItemAttribute( suite, item, suite_ItemCaption(0) ) ); --- 533,539 ---- case dot_code: case line_code: case pie_code: ! /* case map_code:*/ case stack_code: case cartesian_code: DEBUG(Types); ReChart( self, suite_ItemAttribute( suite, item, suite_ItemCaption(0) ) ); *************** *** 445,470 **** --- 544,581 ---- case sort_ascend_value_code: DEBUG(SortAscendValue); chart_Sort( Chart, chart_ByValue | chart_Ascend, NULL ); chart_NotifyObservers( Chart, chart_ItemsSorted ); + suite_Reset(SortLabelSuite,suite_Normalize); + suite_Reset(SortPositionSuite,suite_Normalize); break; case sort_descend_value_code: DEBUG(SortDescendValue); chart_Sort( Chart, chart_ByValue | chart_Descend, NULL ); chart_NotifyObservers( Chart, chart_ItemsSorted ); + suite_Reset(SortLabelSuite,suite_Normalize); + suite_Reset(SortPositionSuite,suite_Normalize); break; case sort_ascend_label_code: DEBUG(SortAscendLabel); chart_Sort( Chart, chart_ByLabel | chart_Ascend, NULL ); chart_NotifyObservers( Chart, chart_ItemsSorted ); + suite_Reset(SortValueSuite,suite_Normalize); + suite_Reset(SortPositionSuite,suite_Normalize); break; case sort_descend_label_code: DEBUG(SortDescendLabel); chart_Sort( Chart, chart_ByLabel | chart_Descend, NULL ); chart_NotifyObservers( Chart, chart_ItemsSorted ); + suite_Reset(SortValueSuite,suite_Normalize); + suite_Reset(SortPositionSuite,suite_Normalize); break; case sort_ascend_position_code: DEBUG(SortAscendPosition); chart_Sort( Chart, chart_ByPosition | chart_Ascend, NULL ); chart_NotifyObservers( Chart, chart_ItemsSorted ); + suite_Reset(SortValueSuite,suite_Normalize); + suite_Reset(SortLabelSuite,suite_Normalize); break; case sort_descend_position_code: DEBUG(SortDescendPosition); chart_Sort( Chart, chart_ByPosition | chart_Descend, NULL ); chart_NotifyObservers( Chart, chart_ItemsSorted ); + suite_Reset(SortValueSuite,suite_Normalize); + suite_Reset(SortLabelSuite,suite_Normalize); break; case save_code: DEBUG(Save); Save_Command( self ); *************** *** 474,484 **** suite_ItemAttribute( suite, item, suite_ItemDatum(0) ) ); chartv_Announce( self, msg ); } - /*=== suite_NormalizeItem( suite, item );*/ if ( !InputFocus ) chartv_WantInputFocus( self, self ); } OUT(Palette_Hit); ! return 0; } long --- 585,594 ---- suite_ItemAttribute( suite, item, suite_ItemDatum(0) ) ); chartv_Announce( self, msg ); } if ( !InputFocus ) chartv_WantInputFocus( self, self ); } OUT(Palette_Hit); ! return ((struct view*)NULL); } long *** atk/chart/chartv.c Wed Nov 22 11:54:34 1989 --- atk/chart/chartv.c.NEW Wed Jun 13 20:30:09 1990 *************** *** 4,10 **** \* ********************************************************************** */ #ifndef lint ! static char *rcsidchartv = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/chart/RCS/chartv.c,v 1.18 89/09/07 18:30:38 tom Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* --- 4,10 ---- \* ********************************************************************** */ #ifndef lint ! static char *rcsidchartv = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/chart/RCS/chartv.c,v 1.19 90/06/13 18:54:59 gk5g Exp $"; #endif /** SPECIFICATION -- External Facility Suite ********************************* *************** *** 69,74 **** --- 69,75 ---- #include #include #include + #include #include #include #include *************** *** 124,135 **** Delete_Command, "Delete Item" }, { "chartv-Print", "", 0, "Print~63", 0, menu_default, Print_Command, "Print Database" }, - /*=== { "chartv-Palette", "", 0, "Expose Palette~70",0, menu_palette_hidden, Palette_Command, "Palette-toggle" }, { "chartv-Palette", "", 0, "Hide Palette~70", 0, menu_palette_exposed, Palette_Command, "Palette-toggle" }, - ===*/ { "chartv-DEBUG", "", 0, "DEBUG~80", 0, menu_default, DEBUG_Command, "Debug-toggle" }, { "chartv-Quit", "", 0, "Quit~99", 0, menu_default, --- 125,134 ---- *************** *** 291,298 **** } if ( Menu ) { ! menulist_SetMask( Menu, menu_default | menu_palette_hidden | ! ((Application) ? menu_application : 0) ); chartv_PostMenus( self, Menu ); } chartv_SetTransferMode( self, graphic_BLACK ); --- 290,300 ---- } if ( Menu ) { ! menulist_SetMask( Menu, menu_default | ! ((PaletteExposed) ? menu_palette_exposed : menu_palette_hidden) | ! ((Application) ? menu_application : 0) ); ! if(PaletteExposed) ! view_PostMenus( (struct view *)Palette, Menu ); chartv_PostMenus( self, Menu ); } chartv_SetTransferMode( self, graphic_BLACK ); *************** *** 310,317 **** { DEBUG(Do Not Ignore); chartv_SetTransferMode( self, graphic_WHITE ); chartv_DrawRectSize( self, Left, Top, Width-1, Height-1 ); - if ( PaletteExposed ) - Hide_Palette( self ); } OUT(chartv_LoseInputFocus); } --- 312,317 ---- *************** *** 565,570 **** --- 565,571 ---- } /*===*/ chart_SetModified( Chart ); + suite_Reset( ControlSuite, suite_Normalize ); OUT(Add_Command); } *************** *** 580,585 **** --- 581,587 ---- chart_NotifyObservers( Chart, chart_ItemDestroyed ); chart_SetModified( Chart ); } + suite_Reset( ControlSuite, suite_Normalize ); OUT(Delete_Command); } *************** *** 668,673 **** --- 670,676 ---- } else chartv_Announce( self, "Error Printing" ); chartv_UseNormalCursor( self ); + suite_Reset( ControlSuite, suite_Normalize ); OUT(Print_Command); } *************** *** 742,747 **** --- 745,751 ---- } chartv_UseNormalCursor( self ); } + suite_Reset( ControlSuite, suite_Normalize ); OUT(Save_Command); } *************** *** 762,769 **** IN(Palette_Command); if ( PaletteExposed ) Hide_Palette( self ); ! else ! Expose_Palette( self ); OUT(Palette_Command); } --- 766,775 ---- IN(Palette_Command); if ( PaletteExposed ) Hide_Palette( self ); ! else { ! Expose_Palette( self ); ! view_PostMenus((struct view *) Palette, Menu); ! } OUT(Palette_Command); } *** atk/controllers/calccon.c Wed Nov 22 11:55:13 1989 --- atk/controllers/calccon.c.NEW Wed Jun 13 16:54:22 1990 *************** *** 3,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/controllers/RCS/calccon.c,v 2.4 89/02/17 15:18:26 ghoti Exp Locker: tpn $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/controllers/RCS/calccon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/controllers/RCS/calccon.c,v 2.4 89/02/17 15:18:26 ghoti Exp Locker: tpn $ "; #endif /* lint */ /* user code ends here for HeaderInfo */ #include "class.h" --- 3,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/controllers/RCS/calccon.c,v 2.5 90/06/05 12:39:45 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/controllers/RCS/calccon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/controllers/RCS/calccon.c,v 2.5 90/06/05 12:39:45 gk5g Exp $ "; #endif /* lint */ /* user code ends here for HeaderInfo */ #include "class.h" *************** *** 25,31 **** --- 25,33 ---- #include "value.ih" #include "stringv.ih" /* user code begins here for includes */ + #ifndef _IBMR2 #include + #endif /* _IBMR2 */ #define ADD 1 #define SUB 2 #define MULT 3 *** atk/controllers/helpcon.c Wed Nov 22 11:55:04 1989 --- atk/controllers/helpcon.c.NEW Thu May 10 16:25:02 1990 *************** *** 3,13 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/controllers/RCS/helpcon.c,v 2.5 89/02/17 15:18:38 ghoti Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/controllers/RCS/helpcon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/controllers/RCS/helpcon.c,v 2.5 89/02/17 15:18:38 ghoti Exp $ "; #endif /* lint */ /* user code ends here for HeaderInfo */ #include --- 3,13 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/controllers/RCS/helpcon.c,v 2.6 90/04/24 17:06:39 gk5g Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/controllers/RCS/helpcon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/controllers/RCS/helpcon.c,v 2.6 90/04/24 17:06:39 gk5g Exp $ "; #endif /* lint */ /* user code ends here for HeaderInfo */ #include *************** *** 15,20 **** --- 15,21 ---- #include "proctbl.ih" #include "view.ih" #include "arbiterv.ih" + #include #include "helpcon.eh" #include "celv.ih" #include "cltextv.ih" *************** *** 30,36 **** #include "message.ih" #include "filetype.ih" #include "environ.ih" - #include #include /* #define HELPDIR "/usr/andy/help" */ #define HELPDIR environ_AndrewDir("/help") --- 31,36 ---- *** atk/controllers/pcontrol.c Wed Nov 22 11:55:08 1989 --- atk/controllers/pcontrol.c.NEW Mon May 14 16:32:39 1990 *************** *** 3,14 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/controllers/RCS/pcontrol.c,v 2.6 89/02/17 15:18:49 ghoti Exp Locker: tpn $ */ /* $ACIS: $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/controllers/RCS/pcontrol.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/controllers/RCS/pcontrol.c,v 2.6 89/02/17 15:18:49 ghoti Exp Locker: tpn $ "; #endif /* lint */ /* user code ends here for HeaderInfo */ #include --- 3,14 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/controllers/RCS/pcontrol.c,v 2.10 90/05/14 16:28:08 tpn Exp $ */ /* $ACIS: $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/controllers/RCS/pcontrol.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/controllers/RCS/pcontrol.c,v 2.10 90/05/14 16:28:08 tpn Exp $ "; #endif /* lint */ /* user code ends here for HeaderInfo */ #include *************** *** 19,46 **** #include #include #include - #include #include #include - #include - #include - #include - #include - #include #include #include #include - #include #include - #include /* user code begins here for includes */ #include - #include #include #include #define NUM 4 #define MAXNAMES 40 - static int wid = 12345; #define WHOLE 0 #define HALF 1 #define QUARTER 2 --- 19,38 ---- #include #include #include #include #include #include #include #include #include /* user code begins here for includes */ #include #include #include + #include + #include #define NUM 4 #define MAXNAMES 40 #define WHOLE 0 #define HALF 1 #define QUARTER 2 *************** *** 51,57 **** #include #endif /* sys_rt_r3 */ - #include struct nh { char *note; float freq; --- 43,48 ---- *************** *** 249,269 **** long r1,r2; { /* user code begins here for ReadCallBack */ ! char buf[512]; ! int foo[10],pf,i; ! FILE *ff,*fopen(); ! ff = NULL; ! for(i = 0 ; i < 10; i++) foo[i] = 1; ! do{ ! pf = message_AskForString(NULL, 0, "Discription file To read", 0, buf, sizeof(buf)); ! if (pf < 0 || (strlen(buf ) == 0 )) break; ! }while((ff = fopen(buf,"r") ) == NULL); ! if(ff != NULL){ text_Clear(self->score); ! text_Read(self->score,ff,0); text_NotifyObservers(self->score,0); ! fclose(ff); } /* user code ends here for ReadCallBack */ } static void noteoutCallBack(self,val,r1,r2) --- 240,262 ---- long r1,r2; { /* user code begins here for ReadCallBack */ ! ! char filename[1024]; ! FILE *file; ! ! if (im_GetDirectory(filename) != NULL) /* get the current directory */ ! strcat(filename, "/"); ! if (completion_GetFilename(self->v, "file to read: ", filename, filename, sizeof(filename), FALSE, TRUE) == -1 ) ! return; ! if((file = fopen(filename,"r")) != NULL){ text_Clear(self->score); ! text_Read(self->score,file,0); text_NotifyObservers(self->score,0); ! message_DisplayString(self->v,0,"Done"); } + else{ + message_DisplayString(self->v,0,"Can't write file"); + } /* user code ends here for ReadCallBack */ } static void noteoutCallBack(self,val,r1,r2) *************** *** 316,333 **** long r1,r2; { /* user code begins here for SaveCallBack */ ! char buf[512]; ! int pf; ! FILE *ff,*fopen(); ! ff = NULL; ! if(self->score == NULL) return; ! do{ ! pf = message_AskForString(NULL, 0, "Discription file To write", 0, buf, sizeof(buf)); ! if (pf < 0 || (strlen(buf ) == 0 )) break; ! }while((ff = fopen(buf,"w") ) == NULL); ! if(ff != NULL){ ! text_Write(self->score,ff,wid++,0); ! fclose(ff); } /* user code ends here for SaveCallBack */ } --- 309,329 ---- long r1,r2; { /* user code begins here for SaveCallBack */ ! ! char filename[1024]; ! FILE *file; ! ! if (im_GetDirectory(filename) != NULL) /* get the current directory */ ! strcat(filename, "/"); ! if (completion_GetFilename(self->v, "file to save: ", filename, filename, sizeof(filename), FALSE, FALSE) == -1 ) ! return; ! if((file = fopen(filename,"w")) != NULL){ ! text_Write(self->score,file,im_GetWriteID(),0); ! fclose(file); ! message_DisplayString(self->v,0,"Wrote song"); ! } ! else{ ! message_DisplayString(self->v,0,"Can't write file"); } /* user code ends here for SaveCallBack */ } *** atk/console/cmd/Imakefile Fri Feb 2 12:24:39 1990 --- atk/console/cmd/Imakefile.NEW Thu May 10 16:25:08 1990 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ - #ifdef AFS_ENV - VICEDOBJS = vopcona.do - VICEIHFILES = vopcona.ih - VICEOBJS = vopcona.o viceop.o - #endif /* AFS_ENV */ LOCALINCLUDES = -I../lib --- 2,7 ---- *************** *** 24,40 **** NormalATKRule() DynamicMultiObject(consolea.do, consolea.o mailmon.o notop.o frlibcmu.o,$(LIBS), -lm) - - #ifdef AFS_ENV - /* libcont.a is part of an old version of AFS not part of AFS3.0, but AFS-related anyway. */ - VLIBS = $(AFSBASEDIR)/lib/afs/libcont.a \ - $(AFSBASEDIR)/lib/afs/libafsint.a \ - $(AFSBASEDIR)/lib/libr.a \ - $(AFSBASEDIR)/lib/liblwp.a - - DynamicMultiObject(vopcona.do, vopcona.o viceop.o frlibcmu.o,$(LIBS) $(VLIBS), -lm) - InstallLink(runapp,${DESTDIR}/bin/vopcon) - #endif /* AFS_ENV */ InstallClassFiles($(DOBJS),$(IHFILES)) InstallLink(runapp,${DESTDIR}/bin/console) --- 19,24 ---- *** atk/console/cmd/mailmon.c Wed Nov 22 11:55:33 1989 --- atk/console/cmd/mailmon.c.NEW Thu Jul 12 12:58:06 1990 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/cmd/RCS/mailmon.c,v 2.17 89/10/18 13:34:00 cfe Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/cmd/RCS/mailmon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/cmd/RCS/mailmon.c,v 2.17 89/10/18 13:34:00 cfe Exp $"; #endif /* lint */ /* --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/cmd/RCS/mailmon.c,v 2.18 90/06/22 17:48:14 gk5g Exp $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/cmd/RCS/mailmon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/cmd/RCS/mailmon.c,v 2.18 90/06/22 17:48:14 gk5g Exp $"; #endif /* lint */ /* *************** *** 105,111 **** } SetMailEnv(); if (UseNonAndrewMail) { ! if (strlen(envmail) < (strlen(_SITE_NON_ANDREW_MAIL) + 1)) { envmail = NULL; ReportInternalError(self, "console: Can't check for Non-Andrew mail when USER is undefined"); } --- 105,111 ---- } SetMailEnv(); if (UseNonAndrewMail) { ! if (envmail[strlen(envmail) - 1] == '/') { envmail = NULL; ReportInternalError(self, "console: Can't check for Non-Andrew mail when USER is undefined"); } *** atk/console/lib/drawfreq.c Wed Nov 22 11:57:26 1989 --- atk/console/lib/drawfreq.c.NEW Thu May 10 16:25:23 1990 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/drawfreq.c,v 2.12 89/06/15 13:10:26 mmackay Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/drawfreq.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/drawfreq.c,v 2.12 89/06/15 13:10:26 mmackay Exp $"; #endif /* lint */ #include --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/drawfreq.c,v 2.13 90/04/24 17:02:59 gk5g Exp $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/drawfreq.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/drawfreq.c,v 2.13 90/04/24 17:02:59 gk5g Exp $"; #endif /* lint */ #include *************** *** 852,857 **** --- 852,858 ---- static char timestring[100]; static struct style *BoldStyle = NULL, *TimeStyle=NULL; struct environment *env = NULL; + char newstring[256]; mydbg(("entering: AddLineToLog\n")); if (LogErrorsExternally) { *************** *** 870,876 **** } if (! strncmp(string, "ERROR: ", 7)){ - char newstring[256]; string[strlen(string) - 1] = '\0'; /* get rid of \n */ sprintf(newstring, "|>> %s <<|\n", string + 7); string = newstring; --- 871,876 ---- *** atk/console/lib/errmonf.c Wed Nov 22 11:56:48 1989 --- atk/console/lib/errmonf.c.NEW Fri Jul 20 11:24:09 1990 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/errmonf.c,v 2.7 89/08/15 12:57:24 mmackay Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/errmonf.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/errmonf.c,v 2.7 89/08/15 12:57:24 mmackay Exp $"; #endif /* lint */ /* --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/errmonf.c,v 2.9 90/07/16 16:17:17 gk5g Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/errmonf.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/errmonf.c,v 2.9 90/07/16 16:17:17 gk5g Exp $"; #endif /* lint */ /* *************** *** 30,35 **** --- 30,36 ---- #include #include #include + #include #include /* #include */ #include *************** *** 94,102 **** --- 95,105 ---- if (errno != 0) { RestartErrorMonitoring(sys_errlist[errno]); } + #if !SY_AIX221 else { RestartErrorMonitoring("Odd EOF on error channel"); } + #endif } return; *** atk/console/lib/errormon.c Wed Nov 22 11:57:28 1989 --- atk/console/lib/errormon.c.NEW Fri Jul 20 11:24:12 1990 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/errormon.c,v 2.15 89/10/16 17:18:17 ajp Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/errormon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/errormon.c,v 2.15 89/10/16 17:18:17 ajp Exp $"; #endif /* lint */ /* --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/errormon.c,v 2.18 90/06/19 19:36:00 gk5g Exp Locker: gk5g $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/errormon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/errormon.c,v 2.18 90/06/19 19:36:00 gk5g Exp Locker: gk5g $"; #endif /* lint */ /* *************** *** 35,45 **** #include #include ! #ifdef AIX #include #include #include ! #endif /* #ifdef AIX */ #ifdef ibm032 /* --- 35,48 ---- #include #include ! #if SY_AIX221 #include #include #include ! #include ! #include ! #include ! #endif /* #if SY_AIX221 */ #ifdef ibm032 /* *************** *** 141,159 **** } #else /* vax || MIPSEL */ { ! #ifdef AIX int ON = REMOTE; if (ioctl (SubChannel, PTYSETM, &ON) < 0) { ReportInternalError(self, "console: Incomplete error monitoring: ioctl() failed on PTYSETM"); return(-1); } ! #else /* #ifdef AIX */ int ON = 1; if (ioctl (SubChannel, TIOCREMOTE, &ON) < 0) { ReportInternalError(self, "console: Incomplete error monitoring: ioctl (TIOCREMOTE) failed on TIOCREMOTE"); return(-1); } ! #endif /* #ifdef AIX */ } #endif /* vax */ #endif /* TIOCCONS */ --- 144,210 ---- } #else /* vax || MIPSEL */ { ! #if SY_AIX221 int ON = REMOTE; if (ioctl (SubChannel, PTYSETM, &ON) < 0) { ReportInternalError(self, "console: Incomplete error monitoring: ioctl() failed on PTYSETM"); return(-1); } ! switch (fork()) { ! case -1: ! ReportInternalError(self, "console: Incomplete error monitoring: fork of AIX console logger failed."); ! return(-1); ! case 0: ! /* child */ ! break; ! default: ! /* parent */ ! { ! int con; ! int msgqid, msgsize; ! char iobuf[100]; ! struct tlog tl; ! struct { ! mtyp_t mtype; /* message type */ ! char mtext[4096]; /* message text */ ! } msg; ! ! dup2(tempfd, 1); ! dup2(tempfd, 2); ! setvbuf(stdout, iobuf, _IOLBF, sizeof(iobuf)); ! setbuf(stderr, NULL); ! if ((con = open("/dev/console", O_RDWR)) < 0) { ! perror("console: Incomplete error monitoring: open /dev/console failed."); ! exit(1); ! } ! /* Set logging to our message queue. */ ! if ((msgqid = msgget(IPC_PRIVATE, IPC_CREAT|S_IRUSR|S_IWUSR)) < 0) { ! perror("console: Incomplete error monitoring: no msg queue."); ! exit(1); ! } ! tl.tl_flags = TLOG_ON|TLOG_QID; ! tl.tl_msgqid = msgqid; ! if (ioctl(con, TCLOG, &tl) < 0) { ! perror("console: Incomplete error monitoring: msg queueing failed."); ! exit(1); ! } ! while (1) { ! if ((msgsize = msgrcv(msgqid, &msg, sizeof(msg.mtext), 0, MSG_NOERROR)) < 0) { ! perror("console: Incomplete error monitoring: msg receive error."); ! exit(1); ! } ! msg.mtext[msgsize] = '\0'; ! printf("%s", msg.mtext); ! } ! } ! } ! #else /* #if SY_AIX221 */ int ON = 1; if (ioctl (SubChannel, TIOCREMOTE, &ON) < 0) { ReportInternalError(self, "console: Incomplete error monitoring: ioctl (TIOCREMOTE) failed on TIOCREMOTE"); return(-1); } ! #endif /* #if SY_AIX221 */ } #endif /* vax */ #endif /* TIOCCONS */ *** atk/console/lib/input.c Wed Nov 22 11:57:39 1989 --- atk/console/lib/input.c.NEW Thu May 10 16:25:33 1990 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see: andrew/config/ ******************************************************************* */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/input.c,v 2.32 89/10/21 16:22:06 bobg Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/input.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/input.c,v 2.32 89/10/21 16:22:06 bobg Exp $"; #endif /* lint */ /* --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see: andrew/config/ ******************************************************************* */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/input.c,v 2.33 90/04/24 17:03:44 gk5g Exp $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/input.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/input.c,v 2.33 90/04/24 17:03:44 gk5g Exp $"; #endif /* lint */ /* *************** *** 569,575 **** mydbg(("entering: TogVar\n")); if (whichvar < 0 || whichvar > NUMINTERNALVARIABLES) { ! ReportInternalError(self, sprintf(ErrTxt, "console: Variable %d does not exist", whichvar)); } else { if (IntrnlVars[whichvar].Value) { --- 569,576 ---- mydbg(("entering: TogVar\n")); if (whichvar < 0 || whichvar > NUMINTERNALVARIABLES) { ! sprintf(ErrTxt, "console: Variable %d does not exist", whichvar); ! ReportInternalError(self, ErrTxt); } else { if (IntrnlVars[whichvar].Value) { *** atk/console/lib/mailmonf.c Fri Feb 2 12:24:42 1990 --- atk/console/lib/mailmonf.c.NEW Thu May 10 16:25:35 1990 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/console/lib/RCS/mailmonf.c,v 2.17 90/01/22 12:16:28 ghoti Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/andrew/atk/console/lib/RCS/mailmonf.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/console/lib/RCS/mailmonf.c,v 2.17 90/01/22 12:16:28 ghoti Exp $"; #endif /* lint */ /* *************************************************************** --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/mailmonf.c,v 2.18 90/04/24 17:03:57 gk5g Exp $ */ ! /* $Source: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/mailmonf.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/.andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/mailmonf.c,v 2.18 90/04/24 17:03:57 gk5g Exp $"; #endif /* lint */ /* *************************************************************** *************** *** 82,88 **** } else{ *f = ' '; ! ReportInternalError(self, sprintf(ErrTxt, "console: '%s' is neither prefix nor suffix")); return(-1); } } --- 82,89 ---- } else{ *f = ' '; ! sprintf(ErrTxt, "console: '%s' is neither prefix nor suffix"); ! ReportInternalError(self, ErrTxt); return(-1); } } *************** *** 89,95 **** } else{ *f = ' '; ! ReportInternalError(self, sprintf(ErrTxt, "console: '%s' is invalid InitString specification")); return(-1); /* bogus string - contains either two * or the * is within the path */ } --- 90,97 ---- } else{ *f = ' '; ! sprintf(ErrTxt, "console: '%s' is invalid InitString specification"); ! ReportInternalError(self, ErrTxt); return(-1); /* bogus string - contains either two * or the * is within the path */ } *************** *** 102,113 **** } /* We now have a valid dirpath NewName, and possibly a wildcard f */ if (stat(NewName, &dirstatbuf) == -1) { ! ReportInternalError(self, sprintf(ErrTxt, "console: Cannot stat directory '%s': cannot check %s now.", NewName, LastModTime == &LastMailMod ? "your mail" : "its contents")); *LastModTime = 0; return(-1); } if ((dirstatbuf.st_mode & S_IFMT) != S_IFDIR) { ! ReportInternalError(self, sprintf(ErrTxt, "console: '%s' is not a directory! %s", NewName, LastModTime == &LastMailMod ? "You probably can't receive mail!" : "Can't count any files in it!")); *LastModTime = 0; return(-1); } --- 104,117 ---- } /* We now have a valid dirpath NewName, and possibly a wildcard f */ if (stat(NewName, &dirstatbuf) == -1) { ! sprintf(ErrTxt, "console: Cannot stat directory '%s': cannot check %s now.", NewName, LastModTime == &LastMailMod ? "your mail" : "its contents"); ! ReportInternalError(self, ErrTxt); *LastModTime = 0; return(-1); } if ((dirstatbuf.st_mode & S_IFMT) != S_IFDIR) { ! sprintf(ErrTxt, "console: '%s' is not a directory! %s", NewName, LastModTime == &LastMailMod ? "You probably can't receive mail!" : "Can't count any files in it!"); ! ReportInternalError(self, ErrTxt); *LastModTime = 0; return(-1); } *************** *** 115,121 **** return(LastValue); } if ((dp = opendir(NewName)) == NULL) { ! ReportInternalError(self, sprintf(ErrTxt, "console: Cannot open directory '%s'; problem with AFS?", NewName)); *LastModTime = 0; return(-1); } --- 119,126 ---- return(LastValue); } if ((dp = opendir(NewName)) == NULL) { ! sprintf(ErrTxt, "console: Cannot open directory '%s'; problem with AFS?", NewName); ! ReportInternalError(self, ErrTxt); *LastModTime = 0; return(-1); } *************** *** 179,185 **** } if (iserror) { value = -1; ! ReportInternalError(self, sprintf(ErrTxt, "console: Mail checking terminated (%s)", sys_errlist[errno])); DoMailChecking = FALSE; } #ifdef AFS_ENV --- 184,191 ---- } if (iserror) { value = -1; ! sprintf(ErrTxt, "console: Mail checking terminated (%s)", sys_errlist[errno]); ! ReportInternalError(self, ErrTxt); DoMailChecking = FALSE; } #ifdef AFS_ENV *************** *** 205,216 **** Numbers[i].Value); if (Numbers[i].Value < 0) { if (!IsViceError(errno)) { ! ReportInternalError(self, sprintf(ErrTxt, "console: Monitoring of %s terminated (%s)", Numbers[i].RawText, sys_errlist[errno])); free(Numbers[i].RawText); Numbers[i].RawText = Nullity; Numbers[i].IsDisplaying = FALSE; } else { ! ReportInternalError(self, sprintf(ErrTxt, "console: Temporary failure to check %s", Numbers[i].RawText)); } } NewValue(self, &Numbers[i], val, NULL, FALSE); --- 211,224 ---- Numbers[i].Value); if (Numbers[i].Value < 0) { if (!IsViceError(errno)) { ! sprintf(ErrTxt, "console: Monitoring of %s terminated (%s)", Numbers[i].RawText, sys_errlist[errno]); ! ReportInternalError(self, ErrTxt); free(Numbers[i].RawText); Numbers[i].RawText = Nullity; Numbers[i].IsDisplaying = FALSE; } else { ! sprintf(ErrTxt, "console: Temporary failure to check %s", Numbers[i].RawText); ! ReportInternalError(self, ErrTxt); } } NewValue(self, &Numbers[i], val, NULL, FALSE); *************** *** 234,244 **** } if (stat(PrintDirName, &dirstatbuf) == -1) { if (IsViceError(errno)) { ! ReportInternalError(self, sprintf(ErrTxt, "console: Cannot stat directory %s: cannot check print queue now.", PrintDirName)); PrintDirModTime = 0; return(-1); } ! return AbortPrintChecking(self, sprintf(ErrTxt, "console: Printing monitor terminated (%s)", sys_errlist[errno])); } if ((dirstatbuf.st_mode & S_IFMT) != S_IFDIR) { return AbortPrintChecking(self, "console: Printing monitor terminated -- PrintDir is not a directory"); --- 242,254 ---- } if (stat(PrintDirName, &dirstatbuf) == -1) { if (IsViceError(errno)) { ! sprintf(ErrTxt, "console: Cannot stat directory %s: cannot check print queue now.", PrintDirName); ! ReportInternalError(self, ErrTxt); PrintDirModTime = 0; return(-1); } ! sprintf(ErrTxt, "console: Printing monitor terminated (%s)", sys_errlist[errno]); ! return AbortPrintChecking(self, ErrTxt); } if ((dirstatbuf.st_mode & S_IFMT) != S_IFDIR) { return AbortPrintChecking(self, "console: Printing monitor terminated -- PrintDir is not a directory"); *************** *** 247,253 **** return; } if ((dp = opendir(PrintDirName)) == NULL) { ! return AbortPrintChecking(self, sprintf(ErrTxt, "console: Printing monitor terminated on opendir (%s)", sys_errlist[errno])); } PrintDirModTime = dirstatbuf.st_atime; while ((dirent = readdir(dp)) != NULL) { --- 257,264 ---- return; } if ((dp = opendir(PrintDirName)) == NULL) { ! sprintf(ErrTxt, "console: Printing monitor terminated on opendir (%s)", sys_errlist[errno]); ! return AbortPrintChecking(self, ErrTxt); } PrintDirModTime = dirstatbuf.st_atime; while ((dirent = readdir(dp)) != NULL) { *************** *** 298,304 **** mydbg(("entering: CheckOutgoingMail\n")); if (stat(OutgoingDir, &statbuf) == -1) { if (IsViceError(errno)) { ! ReportInternalError(self, sprintf(ErrTxt, "console: Cannot stat directory %s: cannot check outgoing mail now.", OutgoingDir)); OutgoingModTime = 0; return; } --- 309,316 ---- mydbg(("entering: CheckOutgoingMail\n")); if (stat(OutgoingDir, &statbuf) == -1) { if (IsViceError(errno)) { ! sprintf(ErrTxt, "console: Cannot stat directory %s: cannot check outgoing mail now.", OutgoingDir); ! ReportInternalError(self, ErrTxt); OutgoingModTime = 0; return; } *************** *** 314,320 **** return; } if ((dp = opendir(OutgoingDir)) == NULL) { ! ReportInternalError(self, sprintf(ErrTxt, "console: Printing monitor terminated on opendir (%s)", sys_errlist[errno])); return; } OutgoingModTime = statbuf.st_atime; --- 326,333 ---- return; } if ((dp = opendir(OutgoingDir)) == NULL) { ! sprintf(ErrTxt, "console: Printing monitor terminated on opendir (%s)", sys_errlist[errno]); ! ReportInternalError(self, ErrTxt); return; } OutgoingModTime = statbuf.st_atime; *************** *** 327,333 **** strcpy(NewPart, dirent->d_name); if (stat(FullName, &statbuf) == -1) { if (errno != ENOENT){ ! ReportInternalError(self, sprintf(ErrTxt, "console: Cannot stat outgoing mail file %s (%s)", dirent->d_name, sys_errlist[errno])); } continue; } --- 340,347 ---- strcpy(NewPart, dirent->d_name); if (stat(FullName, &statbuf) == -1) { if (errno != ENOENT){ ! sprintf(ErrTxt, "console: Cannot stat outgoing mail file %s (%s)", dirent->d_name, sys_errlist[errno]); ! ReportInternalError(self, ErrTxt); } continue; } *************** *** 449,455 **** header[c] = '\0'; if ((c > 14 && !strncmp(header, "ReSent-From:", 12)) || (c > 7 && !strncmp(header, "From:", 5))){ ! ReportInternalError(self, sprintf(buf, "mail>> %s", header)); fclose(fp); return; } --- 463,470 ---- header[c] = '\0'; if ((c > 14 && !strncmp(header, "ReSent-From:", 12)) || (c > 7 && !strncmp(header, "From:", 5))){ ! sprintf(buf, "mail>> %s", header); ! ReportInternalError(self, buf); fclose(fp); return; } *** atk/console/lib/setup.c Fri Feb 2 12:24:56 1990 --- atk/console/lib/setup.c.NEW Fri Jul 20 11:24:15 1990 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/console/lib/RCS/setup.c,v 2.46 90/01/29 10:38:01 ghoti Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/andrew/atk/console/lib/RCS/setup.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/andrew/atk/console/lib/RCS/setup.c,v 2.46 90/01/29 10:38:01 ghoti Exp $"; #endif /* lint */ /* --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/setup.c,v 2.50 90/07/16 16:26:14 gk5g Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/setup.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/setup.c,v 2.50 90/07/16 16:26:14 gk5g Exp $"; #endif /* lint */ /* *************** *** 837,843 **** * date: Thu May 25 14:10:03 EDT 1989 */ #define STDEXTLTH 8 ! #define MAXMATCHES 6 #define MODIFYTYPEIN 7 char *FindConsoleInPaths(theTypeInPtr) char *theTypeInPtr; --- 837,843 ---- * date: Thu May 25 14:10:03 EDT 1989 */ #define STDEXTLTH 8 ! #define MAXMATCHES 7 #define MODIFYTYPEIN 7 char *FindConsoleInPaths(theTypeInPtr) char *theTypeInPtr; *************** *** 947,953 **** sprintf(tmpbuf, "%s/%s", libpaths[i], theName); if ((pfd = fopen(tmpbuf, "r")) != NULL){ fclose(pfd); ! return(tmpbuf); } } } --- 947,964 ---- sprintf(tmpbuf, "%s/%s", libpaths[i], theName); if ((pfd = fopen(tmpbuf, "r")) != NULL){ fclose(pfd); ! if (theName !=NULL) { ! free(theName); ! theName = NULL; ! } ! theName = malloc(MAXPATHLEN * sizeof(char)); ! if (theName == NULL) { ! fprintf(stderr, "\nFATAL ERROR: in %s, couldn't allocate memory!\n", RealProgramName); ! fflush(stderr); ! return(NULL); ! } ! strcpy(theName, tmpbuf); ! return(theName); } } } *************** *** 1026,1032 **** bzero(theTypeInPtr, MAXPATHLEN); strcpy(theTypeInPtr, ConFile); } else { ! sprintf(stderr, "\nFATAL ERROR: couldn't allocate memory in %s!\n", RealProgramName); fflush(stderr); /* well, you COULD exit! */ return(FALSE); --- 1037,1043 ---- bzero(theTypeInPtr, MAXPATHLEN); strcpy(theTypeInPtr, ConFile); } else { ! fprintf(stderr, "\nFATAL ERROR: couldn't allocate memory in %s!\n", RealProgramName); fflush(stderr); /* well, you COULD exit! */ return(FALSE); *** atk/console/lib/venusmon.c Wed Nov 22 11:57:21 1989 --- atk/console/lib/venusmon.c.NEW Wed Jun 20 13:19:38 1990 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/venusmon.c,v 2.18 89/10/20 17:04:42 cfe Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/venusmon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/lib/RCS/venusmon.c,v 2.18 89/10/20 17:04:42 cfe Exp $"; #endif /* lint */ /* --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/venusmon.c,v 2.20 90/06/19 19:36:53 gk5g Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/venusmon.c,v $ */ #ifndef lint ! static char *rcsid = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/lib/RCS/venusmon.c,v 2.20 90/06/19 19:36:53 gk5g Exp $"; #endif /* lint */ /* *** atk/console/stats/Imakefile Wed Nov 22 11:58:16 1989 --- atk/console/stats/Imakefile.NEW Wed Jun 20 13:19:44 1990 *************** *** 1,6 **** #define IHaveSubdirs ! #if SY_AIX221 SUBDIRS = $(SYS_IDENT) #else SUBDIRS = $(SYS_IDENT) common --- 1,6 ---- #define IHaveSubdirs ! #if (SY_AIX221 || SY_AIX3 || SY_AIX31) SUBDIRS = $(SYS_IDENT) #else SUBDIRS = $(SYS_IDENT) common *** atk/console/stats/getstats.c Wed Nov 22 11:58:14 1989 --- atk/console/stats/getstats.c.NEW Mon May 14 11:42:22 1990 *************** *** 2,12 **** * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/stats/RCS/getstats.c,v 2.14 89/10/18 13:23:45 cfe Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/stats/RCS/getstats.c,v $ */ #ifndef lint ! static char *getstats_c_id = "$Header: /afs/andrew.cmu.edu/itc/sm/releases/X.V11R4/andrew/atk/console/stats/RCS/getstats.c,v 2.14 89/10/18 13:23:45 cfe Exp $"; #endif /* lint */ /* ********************************************************************** --- 2,12 ---- * Copyright IBM Corporation 1988,1989 - All Rights Reserved * * For full copyright information see:'andrew/config/COPYRITE' * \* ********************************************************************** */ ! /* $Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/RCS/getstats.c,v 2.15 90/05/14 11:41:42 gk5g Exp $ */ ! /* $Source: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/RCS/getstats.c,v $ */ #ifndef lint ! static char *getstats_c_id = "$Header: /afs/andrew.cmu.edu/itc/src/projects/andrew/atk/console/stats/RCS/getstats.c,v 2.15 90/05/14 11:41:42 gk5g Exp $"; #endif /* lint */ /* ********************************************************************** *************** *** 114,120 **** /* since that particular OS needs some special treatment. We would have */ /* used -Dsys_vax_20 except we want to use the same Makefile for each cpu... */ ! #include #include #include --- 114,124 ---- /* since that particular OS needs some special treatment. We would have */ /* used -Dsys_vax_20 except we want to use the same Makefile for each cpu... */ ! /* Wrap In_Imake around andrewos.h because we don't want any include files from this, only the op-sys info. This is a hack that gets around the fact that andrewos.h now includes and so does below... Gawd! */ ! ! #define In_Imake ! #include ! #undef In_Imake #include #include