xfaces-3.3/ 775 227 12 0 5540460237 11417 5ustar liebmanstaffxfaces-3.3/Makefile 664 227 12 40277 5540460211 13161 0ustar liebmanstaff# Makefile generated by imake - do not edit! # $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $ # # The cpp used on this machine replaces all newlines and multiple tabs and # spaces in a macro expansion with a single space. Imake tries to compensate # for this, but is not always successful. # # ------------------------------------------------------------------------- # Makefile generated from "Imake.tmpl" and # $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $ # # Platform-specific parameters may be set in the appropriate .cf # configuration files. Site-specific parameters should be set in the file # site.def. Full rebuilds are recommended if any parameters are changed. # # If your C preprocessor does not define any unique symbols, you will need # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing # "make World" the first time). # # ------------------------------------------------------------------------- # site-specific configuration parameters that need to come before # the platform-specific parameters - edit site.def to change # site: $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $ # ------------------------------------------------------------------------- # platform-specific configuration parameters - edit sun.cf to change # platform: $XConsortium: sun.cf,v 1.72.1.1 92/03/18 13:13:37 rws Exp $ # operating system: SunOS 4.1.1 # $XConsortium: sunLib.rules,v 1.7 91/12/20 11:19:47 rws Exp $ .c.o: $(CC) -c $(CFLAGS) $*.c # ------------------------------------------------------------------------- # site-specific configuration parameters that go after # the platform-specific parameters - edit site.def to change # site: $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $ SHELL = /bin/sh TOP = . CURRENT_DIR = . AR = ar clq BOOTSTRAPCFLAGS = CC = gcc -fstrength-reduce -fpcc-struct-return AS = as COMPRESS = compress CPP = /lib/cpp $(STD_CPP_DEFINES) PREPROCESSCMD = gcc -fstrength-reduce -fpcc-struct-return -E $(STD_CPP_DEFINES) INSTALL = install LD = ld LINT = lint LINTLIBFLAG = -C LINTOPTS = -axz LN = ln -s MAKE = make MV = mv CP = cp RANLIB = ranlib RANLIBINSTFLAGS = RM = rm -f TROFF = psroff MSMACROS = -ms TBL = tbl EQN = eqn STD_INCLUDES = STD_CPP_DEFINES = STD_DEFINES = EXTRA_LOAD_FLAGS = -B/usr/bin/ EXTRA_LIBRARIES = TAGS = ctags SHAREDCODEDEF = -DSHAREDCODE SHLIBDEF = -DSUNSHLIB PROTO_DEFINES = INSTPGMFLAGS = INSTBINFLAGS = -m 0755 INSTUIDFLAGS = -m 4755 INSTLIBFLAGS = -m 0644 INSTINCFLAGS = -m 0444 INSTMANFLAGS = -m 0444 INSTDATFLAGS = -m 0444 INSTKMEMFLAGS = -g kmem -m 2755 PROJECTROOT = /usr/X11R5 TOP_INCLUDES = -I$(INCROOT) CDEBUGFLAGS = -O CCOPTIONS = ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES) ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES) CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR) LDCOMBINEFLAGS = -X -r DEPENDFLAGS = MACROFILE = sun.cf RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut IMAKE_DEFINES = IRULESRC = $(CONFIGDIR) IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \ $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \ $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES) # ------------------------------------------------------------------------- # X Window System Build Parameters # $XConsortium: Project.tmpl,v 1.138.1.1 92/11/11 09:49:19 rws Exp $ # ------------------------------------------------------------------------- # X Window System make variables; this need to be coordinated with rules PATHSEP = / USRLIBDIR = /usr/X11R5/lib BINDIR = /usr/X11R5/bin INCROOT = /usr/X11R5/include BUILDINCROOT = $(TOP) BUILDINCDIR = $(BUILDINCROOT)/X11 BUILDINCTOP = .. INCDIR = $(INCROOT)/X11 ADMDIR = /usr/adm LIBDIR = $(USRLIBDIR)/X11 CONFIGDIR = $(LIBDIR)/config LINTLIBDIR = $(USRLIBDIR)/lint FONTDIR = $(LIBDIR)/fonts XINITDIR = $(LIBDIR)/xinit XDMDIR = $(LIBDIR)/xdm TWMDIR = $(LIBDIR)/twm MANPATH = /usr/X11R5/man MANSOURCEPATH = $(MANPATH)/man MANSUFFIX = n LIBMANSUFFIX = 3 MANDIR = $(MANSOURCEPATH)$(MANSUFFIX) LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX) NLSDIR = $(LIBDIR)/nls PEXAPIDIR = $(LIBDIR)/PEX XAPPLOADDIR = $(LIBDIR)/app-defaults FONTCFLAGS = -t INSTAPPFLAGS = $(INSTDATFLAGS) IMAKE = imake DEPEND = makedepend RGB = rgb FONTC = bdftopcf MKFONTDIR = mkfontdir MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier CONFIGSRC = $(TOP)/config DOCUTILSRC = $(TOP)/doc/util CLIENTSRC = $(TOP)/clients DEMOSRC = $(TOP)/demos LIBSRC = $(TOP)/lib FONTSRC = $(TOP)/fonts INCLUDESRC = $(TOP)/X11 SERVERSRC = $(TOP)/server UTILSRC = $(TOP)/util SCRIPTSRC = $(UTILSRC)/scripts EXAMPLESRC = $(TOP)/examples CONTRIBSRC = $(TOP)/../contrib DOCSRC = $(TOP)/doc RGBSRC = $(TOP)/rgb DEPENDSRC = $(UTILSRC)/makedepend IMAKESRC = $(CONFIGSRC) XAUTHSRC = $(LIBSRC)/Xau XLIBSRC = $(LIBSRC)/X XMUSRC = $(LIBSRC)/Xmu TOOLKITSRC = $(LIBSRC)/Xt AWIDGETSRC = $(LIBSRC)/Xaw OLDXLIBSRC = $(LIBSRC)/oldX XDMCPLIBSRC = $(LIBSRC)/Xdmcp BDFTOSNFSRC = $(FONTSRC)/bdftosnf BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir FSLIBSRC = $(FONTSRC)/lib/fs FONTSERVERSRC = $(FONTSRC)/server EXTENSIONSRC = $(TOP)/extensions XILIBSRC = $(EXTENSIONSRC)/lib/xinput PEXLIBSRC = $(EXTENSIONSRC)/lib/PEXlib PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX # $XConsortium: sunLib.tmpl,v 1.14.1.2 92/11/11 09:55:02 rws Exp $ SHLIBLDFLAGS = -assert pure-text PICFLAGS = -pic DEPEXTENSIONLIB = EXTENSIONLIB = -lXext DEPXLIB = $(DEPEXTENSIONLIB) XLIB = $(EXTENSIONLIB) -lX11 DEPXMULIB = $(USRLIBDIR)/libXmu.sa.$(SOXMUREV) XMULIBONLY = -lXmu XMULIB = -lXmu DEPOLDXLIB = OLDXLIB = -loldX DEPXTOOLLIB = $(USRLIBDIR)/libXt.sa.$(SOXTREV) XTOOLLIB = -lXt DEPXAWLIB = $(USRLIBDIR)/libXaw.sa.$(SOXAWREV) XAWLIB = -lXaw DEPXILIB = XILIB = -lXi DEPPEXLIB = PEXLIB = -lPEX5 SOXLIBREV = 4.10 SOXTREV = 4.10 SOXAWREV = 5.0 SOOLDXREV = 4.10 SOXMUREV = 4.10 SOXEXTREV = 4.10 SOXINPUTREV = 4.10 SOPEXREV = 1.0 DEPXAUTHLIB = $(USRLIBDIR)/libXau.a XAUTHLIB = -lXau DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a XDMCPLIB = -lXdmcp DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a PHIGSLIB = -lphigs DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a XBSDLIB = -lXbsd LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln LINTXI = $(LINTLIBDIR)/llib-lXi.ln LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) DEPLIBS1 = $(DEPLIBS) DEPLIBS2 = $(DEPLIBS) DEPLIBS3 = $(DEPLIBS) # ------------------------------------------------------------------------- # Imake rules for building libraries, programs, scripts, and data files # rules: $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $ # ------------------------------------------------------------------------- # start of Imakefile # # Copyright 1994 Christopher B. Liebman # # Permission to use, copy, modify, distribute, and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear in all copies and that # both that copyright notice and this permission notice appear in # supporting documentation, and that the name Christopher B. Liebman not # be used in advertising or publicity pertaining to distribution of this # software without specific, written prior permission. # # THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS # ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT # LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN 0 EVENT SHALL CHRISTOPHER # B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, # INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR # PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF # WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # # # $Id: Imakefile,v 1.41 1994/03/08 02:40:38 liebman Exp $ # # Makefile for XFaces. # # # For debugging. # # -DBINDING_DEBUG # -DFACEDB_DEBUG # -DPOP_DEBUG # -DRESOURCE_DEBUG # -DSEARCH_DEBUG # -DITEM_DEBUG # -DLOOKUP_DEBUG # #CDEBUGFLAGS= -Wall -g #CDEBUGFLAGS= -g XFACE_SRCS = face_search_xface.c face_image_xface.c XFACE_OBJS = face_search_xface.o face_image_xface.o XFACE_DEFS = -DXFACE #XFACE_LIBS = -L../compface -lcompface XFACE_LIBS = -L/usr/local/lib -lcompface XPM_SRCS = face_image_xpm.c XPM_OBJS = face_image_xpm.o XPM_INCL = #XPL_INCL = -I/usr/xpm/include XPM_LIBS = -lXpm #XPM_LIBS = -L/usr/xpm/lib -lXpm XPM_DEFS = -DXPM SOUND_SRCS = face_sound.c SOUND_OBJS = face_sound.o SOUND_INCL = #SOUND_INCL = -I/usr/audio/include SOUND_LIBS = -laudio #SOUND_LIBS = -L/usr/audio/lib -laudio SOUND_DEFS = -DSOUND -DUSE_BUCKETS SHAPE_SRCS = face_shape.c SHAPE_OBJS = face_shape.o SHAPE_INCL = SHAPE_LIBS = SHAPE_DEFS = -DSHAPE POP_SRCS = pop_check.c POP_OBJS = pop_check.o POP_INCL = POP_LIBS = POP_DEFS = -DPOP LHN_SRCS = LHN_OBJS = LHN_INCL = LHN_LIBS = LHN_DEFS = -DLOOKUP_HOSTNAME XFACES_VERSION_TAG= HDRS = Tiled.h \ TiledP.h \ faces.h \ face_command.h \ face_image.h \ face_search.h \ face_sound.h \ patchlevel.h \ regexp.h \ regmagic.h \ $(XFACE_HDRS) SRCS = Tiled.c \ cmd_check.c \ face_actions.c \ face_annotate.c \ face_binding.c \ face_command.c \ face_display.c \ face_image.c \ face_image_xbm.c \ face_search.c \ face_search_binding.c \ face_search_facedb.c \ face_search_resource.c \ face_search_uh.c \ mail_box.c \ mail_body.c \ mail_check.c \ mail_file.c \ mail_header.c \ mail_items.c \ mail_parse.c \ main.c \ path.c \ regexp.c \ regsub.c \ string.c \ $(SOUND_SRCS) $(XPM_SRCS) $(SHAPE_SRCS) $(XFACE_SRCS) $(POP_SRCS) \ $(LHN_OBJS) OBJS = Tiled.o \ cmd_check.o \ face_actions.o \ face_annotate.o \ face_binding.o \ face_command.o \ face_display.o \ face_image.o \ face_image_xbm.o \ face_search.o \ face_search_binding.o \ face_search_facedb.o \ face_search_resource.o \ face_search_uh.o \ mail_box.o \ mail_body.o \ mail_check.o \ mail_file.o \ mail_header.o \ mail_items.o \ mail_parse.o \ main.o \ path.o \ regexp.o \ regsub.o \ string.o \ $(SOUND_OBJS) $(XPM_OBJS) $(SHAPE_OBJS) $(XFACE_OBJS) $(POP_OBJS) \ $(LHN_OBJS) OTHER_FILES = BLURB README CHANGES CREDITS TODO COPYRIGHT ChangeLog \ Imakefile XFaces.ad xfaces.man ausun.patch \ Makefile.noimake IMAGEDIR = images INCLUDES = $(TOP_INCLUDES) $(SOUND_INCL) \ $(XPM_INCL) $(SHAPE_INCL) $(POP_INCL) $(LHN_INCL) SYS_LIBRARIES = $(SOUND_LIBS) -lm # # # You will need to add -lnsl and -lsocket on some Solaris2 systems using # openwindows. You may even need to add a -L/usr/openwin/lib before # the $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) also. # LOCAL_LIBRARIES = $(XPM_LIBS) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) $(XFACE_LIBS) $(POP_LIBS) \ $(LHN_LIBS) DEFINES = $(SOUND_DEFS) $(XPM_DEFS) $(SHAPE_DEFS) \ $(XFACE_DEFS) $(POP_DEFS) $(LHN_DEFS) PROGRAM = xfaces all:: xfaces xfaces: $(OBJS) $(DEPLIBS) $(RM) $@ $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) saber_xfaces:: $(SRCS) # load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) osaber_xfaces:: $(OBJS) # load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) install:: xfaces @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \ else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi $(INSTALL) -c $(INSTPGMFLAGS) xfaces $(DESTDIR)$(BINDIR) install.man:: xfaces.man @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \ else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi $(INSTALL) -c $(INSTMANFLAGS) xfaces.man $(DESTDIR)$(MANDIR)/xfaces.$(MANSUFFIX) depend:: $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS) lint: $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS) lint1: $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS) clean:: $(RM) $(PROGRAM) install:: XFaces.ad @if [ -d $(DESTDIR)$(XAPPLOADDIR) ]; then set +x; \ else (set -x; $(MKDIRHIER) $(DESTDIR)$(XAPPLOADDIR)); fi $(INSTALL) -c $(INSTAPPFLAGS) XFaces.ad $(DESTDIR)$(XAPPLOADDIR)/XFaces install.man:: xfaces.man @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \ else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi $(INSTALL) -c $(INSTMANFLAGS) xfaces.man $(DESTDIR)$(MANDIR)/xfaces.$(MANSUFFIX) # # A bit of a hack to make life easier. # distribution: (set -x;THIS_PLACE=`pwd`; \ export THIS_PLACE; \ if [ -z "$(XFACES_VERSION)" ]; then \ XFV=`grep XFACES_VERSION patchlevel.h|awk '{print $$3}'`; \ else \ XFV=$(XFACES_VERSION);\ fi; \ XFT=XFACES_`echo $$XFV | sed 's/\./_/'`; \ export XFT; \ mkdir -p Distribution/xfaces-$$XFV; \ cd Distribution/xfaces-$$XFV; \ ln -s $$THIS_PLACE/RCS; \ co -r$$XFT Imakefile; \ xmkmf; \ make XFACES_VERSION_TAG=$$XFT current; \ rm RCS; \ mkdir -p $(IMAGEDIR); \ (cd $(IMAGEDIR); \ ln -s $$THIS_PLACE/$(IMAGEDIR)/RCS; \ co -r$$XFT Imakefile; \ xmkmf; \ make XFACES_VERSION_TAG=$$XFT current; \ rm -f Makefile Makefile.bak Imakefile RCS); \ cd ..; \ tar cvf xfaces-$$XFV.tar xfaces-$$XFV; \ compress xfaces-$$XFV.tar) current: co -r$(XFACES_VERSION_TAG) $(HDRS) $(SRCS) $(OTHER_FILES) tag: if [ ! -z "$(XFACES_VERSION_TAG)" ]; then \ for i in $(HDRS) $(SRCS) $(OTHER_FILES);do \ head=`rlog -h $$i | grep '^head' | awk '{print $$2}'`; \ rcs -N$(XFACES_VERSION_TAG):$$head $$i; \ done; \ (cd $(IMAGEDIR); \ make XFACES_VERSION_TAG=$(XFACES_VERSION_TAG) tag); \ fi files: @echo $(HDRS) $(SRCS) $(OTHER_FILES) clean:: rm -rf Distribution # ------------------------------------------------------------------------- # common rules for all Makefiles - do not edit emptyrule:: clean:: $(RM_CMD) "#"* Makefile:: -@if [ -f Makefile ]; then set -x; \ $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ else exit 0; fi $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) tags:: $(TAGS) -w *.[ch] $(TAGS) -xw *.[ch] > TAGS saber: # load $(ALLDEFINES) $(SRCS) osaber: # load $(ALLDEFINES) $(OBJS) # ------------------------------------------------------------------------- # empty rules for directories that do not have SUBDIRS - do not edit install:: @echo "install in $(CURRENT_DIR) done" install.man:: @echo "install.man in $(CURRENT_DIR) done" Makefiles:: includes:: # ------------------------------------------------------------------------- # dependencies generated by makedepend xfaces-3.3/Imakefile 444 227 12 15333 5540460235 13327 0ustar liebmanstaff# # Copyright 1994 Christopher B. Liebman # # Permission to use, copy, modify, distribute, and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear in all copies and that # both that copyright notice and this permission notice appear in # supporting documentation, and that the name Christopher B. Liebman not # be used in advertising or publicity pertaining to distribution of this # software without specific, written prior permission. # # THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS # ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT # LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER # B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, # INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR # PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF # WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # # # $Id: Imakefile,v 1.41 1994/03/08 02:40:38 liebman Exp $ # # Makefile for XFaces. # /* * Undefine any of these to remove that feature. * * USE_XPM - Allows xpm format pixmaps to be used for face images. * USE_SHAPE - Allows the use of the shape extension for face * images. * USE_SOUND - Enables sound support using netaudio (tested with * version 1.1) * USE_BUCKETS - Store audio samples as buckets while they are active. * USE_XFACE - Add in support for X-Face compressed image headers. * USE_POP - Adds support for POP3 mailboxs. * LOOKUP_HOSTNAME - Lookup host using gethostbyname() to allow aliases. * * Note: netaudio-1.1 * USE_BUCKETS currently has a problem on both my Sparc10 SunOS 4.1.3 and * my SparcIPC SunOS 4.1.1. When the bucket is played if tends to have an * audible glitch after the first 1/4 to 1/2 second! The file ausun.patch * contains a fix for this. Either apply the patch or undefine USE_BUCKETS! */ #define USE_XPM #define USE_SHAPE #define USE_XFACE #define USE_SOUND #define USE_BUCKETS #define USE_POP #define LOOKUP_HOSTNAME # # For debugging. # # -DBINDING_DEBUG # -DFACEDB_DEBUG # -DPOP_DEBUG # -DRESOURCE_DEBUG # -DSEARCH_DEBUG # -DITEM_DEBUG # -DLOOKUP_DEBUG # #CDEBUGFLAGS= -Wall -g #CDEBUGFLAGS= -g #ifdef USE_XFACE XFACE_SRCS = face_search_xface.c face_image_xface.c XFACE_OBJS = face_search_xface.o face_image_xface.o XFACE_DEFS = -DXFACE #XFACE_LIBS = -L../compface -lcompface XFACE_LIBS = -L/usr/local/lib -lcompface #endif #ifdef USE_XPM XPM_SRCS = face_image_xpm.c XPM_OBJS = face_image_xpm.o XPM_INCL = #XPL_INCL = -I/usr/xpm/include XPM_LIBS = -lXpm #XPM_LIBS = -L/usr/xpm/lib -lXpm XPM_DEFS = -DXPM #endif #ifdef USE_SOUND SOUND_SRCS = face_sound.c SOUND_OBJS = face_sound.o SOUND_INCL = #SOUND_INCL = -I/usr/audio/include SOUND_LIBS = -laudio #SOUND_LIBS = -L/usr/audio/lib -laudio #ifdef USE_BUCKETS SOUND_DEFS = -DSOUND -DUSE_BUCKETS #else SOUND_DEFS = -DSOUND #endif #endif #ifdef USE_SHAPE SHAPE_SRCS = face_shape.c SHAPE_OBJS = face_shape.o SHAPE_INCL = SHAPE_LIBS = SHAPE_DEFS = -DSHAPE #endif #ifdef USE_POP POP_SRCS = pop_check.c POP_OBJS = pop_check.o POP_INCL = POP_LIBS = POP_DEFS = -DPOP #endif #ifdef LOOKUP_HOSTNAME LHN_SRCS = LHN_OBJS = LHN_INCL = LHN_LIBS = LHN_DEFS = -DLOOKUP_HOSTNAME #endif XFACES_VERSION_TAG= HDRS = Tiled.h \ TiledP.h \ faces.h \ face_command.h \ face_image.h \ face_search.h \ face_sound.h \ patchlevel.h \ regexp.h \ regmagic.h \ $(XFACE_HDRS) SRCS = Tiled.c \ cmd_check.c \ face_actions.c \ face_annotate.c \ face_binding.c \ face_command.c \ face_display.c \ face_image.c \ face_image_xbm.c \ face_search.c \ face_search_binding.c \ face_search_facedb.c \ face_search_resource.c \ face_search_uh.c \ mail_box.c \ mail_body.c \ mail_check.c \ mail_file.c \ mail_header.c \ mail_items.c \ mail_parse.c \ main.c \ path.c \ regexp.c \ regsub.c \ string.c \ $(SOUND_SRCS) $(XPM_SRCS) $(SHAPE_SRCS) $(XFACE_SRCS) $(POP_SRCS) \ $(LHN_OBJS) OBJS = Tiled.o \ cmd_check.o \ face_actions.o \ face_annotate.o \ face_binding.o \ face_command.o \ face_display.o \ face_image.o \ face_image_xbm.o \ face_search.o \ face_search_binding.o \ face_search_facedb.o \ face_search_resource.o \ face_search_uh.o \ mail_box.o \ mail_body.o \ mail_check.o \ mail_file.o \ mail_header.o \ mail_items.o \ mail_parse.o \ main.o \ path.o \ regexp.o \ regsub.o \ string.o \ $(SOUND_OBJS) $(XPM_OBJS) $(SHAPE_OBJS) $(XFACE_OBJS) $(POP_OBJS) \ $(LHN_OBJS) OTHER_FILES = BLURB README CHANGES CREDITS TODO COPYRIGHT ChangeLog \ Imakefile XFaces.ad xfaces.man ausun.patch \ Makefile.noimake IMAGEDIR = images INCLUDES = $(TOP_INCLUDES) $(SOUND_INCL) \ $(XPM_INCL) $(SHAPE_INCL) $(POP_INCL) $(LHN_INCL) SYS_LIBRARIES = $(SOUND_LIBS) -lm # # # You will need to add -lnsl and -lsocket on some Solaris2 systems using # openwindows. You may even need to add a -L/usr/openwin/lib before # the XawClientLibs also. # LOCAL_LIBRARIES = $(XPM_LIBS) XawClientLibs $(XFACE_LIBS) $(POP_LIBS) \ $(LHN_LIBS) DEFINES = $(SOUND_DEFS) $(XPM_DEFS) $(SHAPE_DEFS) \ $(XFACE_DEFS) $(POP_DEFS) $(LHN_DEFS) ComplexProgramTarget(xfaces) InstallAppDefaults(XFaces) InstallManPage(xfaces,$(MANDIR)) # # A bit of a hack to make life easier. # distribution: (set -x;THIS_PLACE=`pwd`; \ export THIS_PLACE; \ if [ -z "$(XFACES_VERSION)" ]; then \ XFV=`grep XFACES_VERSION patchlevel.h|awk '{print $$3}'`; \ else \ XFV=$(XFACES_VERSION);\ fi; \ XFT=XFACES_`echo $$XFV | sed 's/\./_/'`; \ export XFT; \ mkdir -p Distribution/xfaces-$$XFV; \ cd Distribution/xfaces-$$XFV; \ ln -s $$THIS_PLACE/RCS; \ co -r$$XFT Imakefile; \ xmkmf; \ make XFACES_VERSION_TAG=$$XFT current; \ rm RCS; \ mkdir -p $(IMAGEDIR); \ (cd $(IMAGEDIR); \ ln -s $$THIS_PLACE/$(IMAGEDIR)/RCS; \ co -r$$XFT Imakefile; \ xmkmf; \ make XFACES_VERSION_TAG=$$XFT current; \ rm -f Makefile Makefile.bak Imakefile RCS); \ cd ..; \ tar cvf xfaces-$$XFV.tar xfaces-$$XFV; \ compress xfaces-$$XFV.tar) current: co -r$(XFACES_VERSION_TAG) $(HDRS) $(SRCS) $(OTHER_FILES) tag: if [ ! -z "$(XFACES_VERSION_TAG)" ]; then \ for i in $(HDRS) $(SRCS) $(OTHER_FILES);do \ head=`rlog -h $$i | grep '^head' | awk '{print $$2}'`; \ rcs -N$(XFACES_VERSION_TAG):$$head $$i; \ done; \ (cd $(IMAGEDIR); \ make XFACES_VERSION_TAG=$(XFACES_VERSION_TAG) tag); \ fi files: @echo $(HDRS) $(SRCS) $(OTHER_FILES) clean:: rm -rf Distribution xfaces-3.3/regmagic.h 444 227 12 231 5540460215 13372 0ustar liebmanstaff/* * The first byte of the regexp internal "program" is actually this magic * number; the start node begins in the second byte. */ #define MAGIC 0234 xfaces-3.3/Tiled.h 444 227 12 4337 5540460213 12706 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : * Last Modified By: Chris Liebman * Last Modified On: * Update Count : 0 * Status : Released * * HISTORY * * PURPOSE * Simple tiled layout widget * * $Id: Tiled.h,v 1.2 1994/02/08 18:59:37 liebman Exp $ */ #ifndef Tiled_h_ #define Tiled_h_ /* * Tiled Widget */ #include #include #define XtNhorizSpacing "horizSpacing" #define XtNvertSpacing "vertSpacing" #define XtNtileWidth "tileWidth" #define XtNtileHeight "tileHeight" #define XtNsetWidth "setWidth" #define XtNsetHeight "setHeight" #define XtNminWidth "minWidth" #define XtNminHeight "minHeight" #define XtNmaxWidth "maxWidth" #define XtNmaxHeight "maxHeight" #define XtNlayout "layout" #define XtCLayout "Layout" /* Class record constants */ extern WidgetClass tiledWidgetClass; typedef struct _TiledClassRec *TiledWidgetClass; typedef struct _TiledRec *TiledWidget; #endif /* Tiled_h_ */ xfaces-3.3/TiledP.h 444 227 12 5646 5540460213 13032 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : * Last Modified By: Chris Liebman * Last Modified On: * Update Count : 0 * Status : Released * * HISTORY * * PURPOSE * Simple tiled layout widget * * $Id: TiledP.h,v 1.2 1994/02/08 18:59:47 liebman Exp $ */ #ifndef TiledP_h_ #define TiledP_h_ #include "Tiled.h" #include #include #include /* * New fields for the Tiled widget class record. */ typedef struct { int foo; } TiledClassPart; /* * Full class record declaration. */ typedef struct _TiledClassRec { CoreClassPart core_class; CompositeClassPart composite_class; TiledClassPart tiled_class; } TiledClassRec; extern TiledClassRec tiledClassRec; typedef struct { /* Resources. */ Dimension vert_spacing; Dimension horiz_spacing; Dimension internal_width; Dimension internal_height; Dimension tile_width; /* Width of tiles. */ Dimension tile_height; /* Height of tiles. */ Dimension set_width; /* Forced width in tiles. */ Dimension set_height; /* Forced height in tiles. */ Dimension min_width; /* In tiles. */ Dimension min_height; /* In tiles. */ Dimension max_width; /* In tiles. */ Dimension max_height; /* In tiles. */ Boolean layout; /* Private state. */ Dimension tile_count; /* Number of managed children. */ Dimension width_in_tiles; Dimension height_in_tiles; } TiledPart; /* Full instance record declaration. */ typedef struct _TiledRec { CorePart core; CompositePart composite; TiledPart tiled; } TiledRec; #endif /* TiledP_h_ */ xfaces-3.3/faces.h 444 227 12 40335 5540460213 12744 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Mar 7 16:55:46 1994 * Update Count : 164 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Sun Feb 13 00:38:34 1994 #150 (Chris Liebman) * Added mail annotations. Also added new command stuff. * * 2-Feb-1994 Chris Liebman * Last Modified: Tue Feb 1 14:38:13 1994 #120 (Chris Liebman) * Added annotation support. * * 31-Jan-1994 Chris Liebman * Last Modified: Mon Jan 31 22:35:28 1994 #116 (Chris Liebman) * New search support and resources. * * 24-Jan-1994 Chris Liebman * Last Modified: Sun Jan 23 18:54:23 1994 #47 (Chris Liebman) * Added lots of new resources! * * 18-Jan-1994 Chris Liebman * Last Modified: Tue Jan 18 16:57:29 1994 #31 (Chris Liebman) * Handle the cases where index, rindex, bcopy, bzero are * already defined as macros on SYSV. Added new resource: * closeness. Added new header structs. * * 14-Jan-1994 Chris Liebman * Last Modified: Fri Jan 14 10:22:29 1994 #5 (Chris Liebman) * Added defines for index(), rindex(), bcopy() and bzero() for SYSV. * Removed include of xpm.h, its now in face_image_xpm.c. * Added new ignore message binding resource element to TheXFacesResources. * Added the status header to the Face structure. * * PURPOSE * Definitions structures and extern declarations for xfaces. * * $Id: faces.h,v 1.29 1994/03/12 20:05:52 liebman Exp $ */ #ifndef FACES_H_ #define FACES_H_ #include #include #include #include #include #include #include "Tiled.h" #ifndef SYSV #include #else /* * Handle these functions if macros are not already defined. */ #ifndef index #define index(a, b) strchr(a, b) #endif #ifndef rindex #define rindex(a, b) strrchr(a, b) #endif #ifndef bcopy #define bcopy(a, b, c) memcpy(b, a, c) #endif #ifndef bzero #define bzero(a, b) memset(a, 0, b) #endif #endif /* SYSV */ #include "regexp.h" #include "patchlevel.h" /* * Compare a string. */ #define StringEqVal(s1, val) (strncmp((s1), (val), strlen(val)) == 0) /* * Application class. */ #ifndef XFACES_CLASS #define XFACES_CLASS "XFaces" #endif /* * Max size for mail seperator string. */ #define MAX_MAILSEP_SIZE 31 #define MAIL_SEP1 "From " #define MAIL_SEP1_SKIP False #define MAIL_SEP2 "\001\001\001\001\n" #define MAIL_SEP2_SKIP True /* * The face type. */ typedef struct face Face; typedef struct face_item FaceItem; /* *Image and sound types. */ typedef struct face_image FaceImage; typedef struct face_image_type FaceImageType; typedef struct face_sound FaceSound; typedef struct face_sound_type FaceSoundType; typedef struct face_command FaceCommand; typedef struct face_search_type FaceSearchType; typedef struct face_search_data FaceSearchData; /* * Here is a mail item structures. */ typedef struct mail_header MailHeader; typedef struct mail_item MailItem; /* * Here is the binding structure. */ typedef struct face_binding { String name; /* Field to search. */ String patsrc; regexp *pattern; /* Pattern to search for. */ String file; /* file for image/sound. */ String label; /* Label for face. */ int anno; /* Annotation number for label. */ int casesensitive; /* Zero means case insensitive. */ struct face_binding *next; } FaceBinding; /* * The resource structure. */ typedef struct _faces_resources { String spool_dir; /* The directory for default spool */ /* files. */ String spool_file; /* This is the file to monitor */ /* (full path!). */ String list_command; String pop_host; /* pop mailbox host. */ int pop_port; String pop_auth_file; /* login/passwd for pop server */ /* (full path!) */ String image_path; /* Where to find the images. */ char* image_path_str; char** image_paths; String sound_path; /* Where to find the sounds. */ char* sound_path_str; char** sound_paths; String facedb_path; /* Where to find the facedb's.*/ char* facedb_path_str; char** facedb_paths; char* machine; /* name for machine file. */ char* people; /* name for people file. */ int update; /* How often to check the mail. */ int volume; /* How loud to play sounds. */ String from_field; /* String to use as the field name * for getting the from name. */ String no_mail_image; /* No mail picture. */ String no_mail_sound; /* No mail sound. */ Boolean keep_order; Boolean compress_images; /* Show faces compressed. */ Boolean use_sound; /* Play sounds. */ Boolean use_shape; /* Shape windows. */ Boolean use_commands; /* Shape windows. */ Boolean use_content_length; /* Use Content-Length header (if * available) to skip mail body. */ Boolean shape_borders; Boolean shape_internal; int closeness; /* Allow similar colors. */ String image_types_str; FaceImageType** image_types; String image_search_str; FaceSearchData* image_search; String sound_search_str; FaceSearchData* sound_search; String command_search_str; FaceSearchData* command_search; String ignore_message_bindings_str; FaceBinding* ignore_message_bindings; String before_image_bindings_str; FaceBinding* before_image_bindings; String after_image_bindings_str; FaceBinding* after_image_bindings; String before_sound_bindings_str; FaceBinding* before_sound_bindings; String after_sound_bindings_str; FaceBinding* after_sound_bindings; String before_command_bindings_str; FaceBinding* before_command_bindings; String after_command_bindings_str; FaceBinding* after_command_bindings; int annotation_count; int unknown_annotation_count; Boolean annotation_above; Pixel background; Boolean shape_extra; Boolean path_by_chdir; Boolean lookup_hostname; } FacesResourcesRec, *FacesResources; /* * Headers are on a double linked list. */ struct mail_header { char* name; /* Header name. */ char* value; /* Header value. */ char* line; /* If we could not parse out name/value. */ MailHeader* next; /* Next header. */ MailHeader* prev; /* Previous header. */ }; struct mail_item { String user; /* User from From line. */ String host; /* Host from From line. */ String realhost; /* Unaliased hostname. */ String label; /* Item label. */ int use_label; /* Use label for annotation. */ int unknown; /* if non zero use unknown annos. */ int in_use; /* Message in use. */ MailHeader *headers; /* List of mail headers. */ char* body; /* Mail body. */ FaceImage* image; /* Image for user. */ FaceSound* sound; /* Sound to play. */ FaceCommand* command; /* Command to run. */ Face* face; char** annotations; /* Annotation data. */ MailItem* next; /* Pointer to next item. */ MailItem* prev; /* Pointer to prev item. */ }; struct face_item { MailItem* item; FaceItem* next; }; /* * Here is a face structure. */ struct face { FaceImage *image; /* Image */ char* label; /* Face label. */ int count; /* Count of items using this face. */ int last_count; /* Previous count. */ FaceItem* items; /* List of mail items using face. */ Widget widget; /* Widget used to display user. */ Pixmap pixmap; /* Annotated pixmap. */ Pixmap shape; /* Annotated shape pixmap. */ char** annotations; /* Annotation data. */ struct face *next; /* Pointer to next face. */ struct face *prev; /* Pointer to prev face. */ }; typedef enum face_format { FormatImage = 1, FormatAudio, FormatCommand } FaceFormat; #ifdef __STDC__ #define P_(xxx) xxx #else #define P_(xxx) () #endif /* * Global variable definitions. */ /* face_display.c */ extern Face *TheFaceList; extern Widget NoMailWidget; /* mail_box.c */ extern char* MailSeperator; extern int MailSeperatorLength; extern Boolean MailSeperatorSkip; /* mail_items.c */ extern MailItem* TheMailItems; /* main.c */ extern FacesResourcesRec TheFacesResources; extern Widget TheTopLevel; extern Widget TheFrame; extern FaceImage *NoMailImage; extern FaceSound *NoMailSound; extern char *getlogin(); /* * External functions. */ /* cmd_check.c */ extern void CmdCheck P_((void)); /* face_actions.c */ extern void FaceActionsInit P_((void)); /* face_annotate.c */ extern int FaceAnnotate P_((Face* face)); extern void FaceAnnotateFree P_((Face* face)); extern void FaceAnnotateInit P_((void)); /* face_binding.c */ extern FaceBinding* FaceBindingParse P_((String str, int has_value, int has_label)); extern FaceBinding* FaceBindingCheck P_((MailHeader* headers, FaceBinding*bindings)); /* face_command.c */ extern void FaceCommandFree P_((FaceCommand* fc)); extern int FaceCommandLoad P_((char* name, MailItem* item, FaceSearchData* data)); extern void FaceCommandRun P_((FaceCommand* fc)); extern void FaceCommandFind P_((MailItem* item)); /* face_display.c */ extern Face* FaceDisplay P_((MailItem* item)); extern void FaceClear P_((void)); extern void FaceClean P_((void)); extern int FaceCount P_((void)); extern void FaceDisplayInit P_((void)); /* face_image.c */ extern FaceImageType* FaceImageTypeByName P_((char* name)); extern void FaceImageTypeRegister P_((FaceImageType* type)); extern FaceImageType** FaceImageTypeListParse P_((char* str)); extern int FaceImageLoad P_((char* file, MailItem* item, FaceSearchData* data)); extern FaceImage* FaceImageCreate P_((char* file, FaceImageType* type, void* data)); extern void FaceImageLabelCreate P_((MailItem* item)); extern void FaceImageFree P_((FaceImage* fi)); extern Pixmap FaceImagePixmap P_((FaceImage* fi)); extern Pixmap FaceImageShape P_((FaceImage* fi)); extern String StringConcat P_((String s1, String s2)); extern void FaceImageRef P_((FaceImage* fi)); extern void FaceImageCount P_((FaceImage* fi)); extern void FaceImageDecount P_((FaceImage* fi)); extern String FaceImageLabelGet P_((FaceImage* fi)); extern void FaceImageFind P_((MailItem* item)); /* face_image_xbm.c */ extern void FaceImageColorize P_((Pixmap* pixmap, int width, int height)); extern void* FaceImageXbmRead P_((String file, void* type_data)); #ifdef SHAPE extern void* FaceImageShapedXbmRead P_((String file, void* type_data)); #endif extern void FaceImageXbmFree P_((void* data, void* type_data)); extern Pixmap FaceImageXbmPixmap P_((void *data, void* type_data)); extern Pixmap FaceImageXbmShape P_((void *data, void* type_data)); extern void FaceImageXbmInit P_((void)); /* face_image_xface.c */ #ifdef XFACE extern FaceImage* FaceImageXFaceCreate P_((String str)); extern void FaceImageXFaceFree P_((void* data, void* type_data)); extern Pixmap FaceImageXFacePixmap P_((void *data, void* type_data)); extern Pixmap FaceImageXFaceShape P_((void *data, void* type_data)); #endif /* face_image_xpm.c */ extern void* FaceImageXpmRead P_((String file, void* type_data)); #ifdef SHAPE extern void* FaceImageShapedXpmRead P_((String file, void* type_data)); #endif extern void FaceImageXpmFree P_((void* data, void* type_data)); extern Pixmap FaceImageXpmPixmap P_((void *data, void* type_data)); extern Pixmap FaceImageXpmShape P_((void *data, void* type_data)); extern void FaceImageXpmInit P_((void)); /* face_search.c */ extern FaceSearchType* FaceSearchTypeByName P_((char *name)); extern void FaceSearchTypeRegister P_((FaceSearchType* type)); extern int FaceSearch P_((MailItem* item, FaceSearchData* search_list)); extern int FaceSearchLoad P_((char *name, MailItem* item, FaceSearchData* data)); extern FaceSearchData* FaceSearchParse P_((char* str, FaceFormat format)); /* face_search_binding.c */ extern void FaceSearchBindingInit P_((void)); /* face_search_facedb.c */ extern void FaceSearchFacedbInit P_((void)); /* face_search_resource.c */ extern void FaceSearchResourceInit P_((void)); /* face_search_uh.c */ extern void FaceSearchUserHostInit P_((void)); /* face_search_xface.c */ #ifdef XFACE extern void FaceSearchXFaceInit P_((void)); #endif /* face_shape.c */ extern void FaceShapeCreate P_((void)); /* face_sound.c */ #ifdef SOUND extern FaceSound* FaceSoundCreate P_((char* file)); extern void FaceSoundFree P_((FaceSound* fs)); extern int FaceSoundLoad P_((char* name, MailItem* item, FaceSearchData* data)); extern void FaceSoundPlay P_((FaceSound* fs)); extern void FaceSoundInit P_((void)); extern void FaceSoundFind P_((MailItem* item)); #endif /* mail_body.c */ extern char* MailBodyRead P_((int content_length)); extern void MailBodySkip P_((int content_length)); /* mail_box.c */ extern void MailBoxParse P_((void)); /* mail_check.c */ extern void MailCheck P_((void)); /* mail_file.c */ extern int MailFileOpen P_((char* name)); extern void MailFileClose P_((void)); extern int MailFileReadChar P_((void)); extern void MailFileUnReadChar P_((int ch)); extern void MailFileUnReadString P_((char* str)); extern void MailFileClearUnRead P_((void)); extern void MailFilePeekString P_((char* buf, int len)); extern int MailFileReadString P_((char* buf, int len)); extern int MailFileSkipString P_((int len)); extern int MailFilePeekChar P_(()); /* mail_header.c */ extern char* MailHeaderLineRead P_((void)); extern MailHeader* MailHeaderRead P_((void)); extern MailHeader* MailHeaderListRead P_((void)); extern void MailHeaderFree P_((MailHeader* header)); extern void MailHeaderListFree P_((MailHeader* list)); extern MailHeader* MailHeaderFind P_((char* name, MailHeader* list)); extern int MailHeaderListCompare P_((MailHeader* list1, MailHeader* list2)); /* mail_items.c */ extern void MailBoxClear P_((void)); extern void MailBoxUnClear P_((void)); extern void MailBoxClean P_((void)); extern void MailItemCreate P_((MailHeader* headers)); extern void MailItemCreateNoHeaders P_((char* user, char* host, char** annotations)); extern void MailBoxEmpty P_((void)); extern void MailItemInit P_((void)); /* mail_parse.c */ extern void MailParseAddress P_((String from, String* user, String* host)); /* main.c */ extern void CheckMailNow P_((void)); extern int main P_((int argc, char** argv)); extern void regerror P_((String s)); /* path.c */ extern char** PathParse P_((char* path)); extern int PathEnumerate P_((char* file, char** paths, int (*func)(char* file, char* path, void* data), void* data)); /* pop_check.c */ extern void PopCheck P_((void)); /* regexp.c */ extern regexp* regcomp P_((char* exp)); extern int regexec P_((regexp *prog, char *string)); /* regsub.c */ extern void regsub P_((regexp *prog, char *source, char *dest)); /* string.c */ extern char* SkipChars P_((char* str, char* delim)); extern char* ParseToken P_((char** str, char* delim)); extern char** StringParse P_((char* str, char* delims)); #endif /* FACES_H_ */ xfaces-3.3/regexp.h 444 227 12 1076 5540460215 13136 0ustar liebmanstaff/* * Definitions etc. for regexp(3) routines. * * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], * not the System V one. */ #define NSUBEXP 10 typedef struct regexp { char *startp[NSUBEXP]; char *endp[NSUBEXP]; char regstart; /* Internal use only. */ char reganch; /* Internal use only. */ char *regmust; /* Internal use only. */ int regmlen; /* Internal use only. */ char program[1]; /* Unwarranted chumminess with compiler. */ } regexp; extern regexp *regcomp(); extern int regexec(); extern void regsub(); extern void regerror(); xfaces-3.3/face_command.h 444 227 12 3654 5540460214 14243 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * * * Author : Chris Liebman * Created On : Sat Feb 12 22:18:45 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 13 17:01:11 1994 * Update Count : 6 * Status : Released * * HISTORY * * PURPOSE * Definitions for commands. * * $Id: face_command.h,v 1.1 1994/02/13 22:01:14 liebman Exp $ */ #ifndef FACE_COMMAND_H_ #define FACE_COMMAND_H_ /* * Here is a face sound structure. */ struct face_command { String command; /* Shell command. */ int refs; /* Total refs on this face. */ struct face_command *next; /* Pointer to next face. */ struct face_command *prev; /* Pointer to prev face. */ }; #endif /* FACE_COMMAND_H_ */ xfaces-3.3/face_image.h 444 227 12 5514 5540460214 13704 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Jan 31 22:45:43 1994 * Update Count : 13 * Status : Released * * HISTORY * 31-Jan-1994 Chris Liebman * Last Modified: Sat Jan 29 20:36:37 1994 #11 (Chris Liebman) * Now use FaceImageType instead of FaceImageFuncs. * * 24-Jan-1994 Chris Liebman * Last Modified: Sun Jan 23 11:22:55 1994 #2 (Chris Liebman) * Minor rearangement. * * PURPOSE * Definitions for images. * * $Id: face_image.h,v 1.5 1994/02/23 13:17:02 liebman Exp $ */ #ifndef FACE_IMAGE_H_ #define FACE_IMAGE_H_ /* * Here is the function set for a face image. */ struct face_image_type { char* name; void* (*read) P_((char* file, void* type_data)); void (*free) P_((void* data, void* type_data)); Pixmap (*pixmap) P_((void *data, void* type_data)); Pixmap (*shape) P_((void *data, void* type_data)); char* extension; void* data; FaceImageType *next; }; /* * Here is a face image structure. */ struct face_image { String file; /* image file name */ String label; /* user@host label. */ int refs; /* Total refs on this face. */ int list_count; /* Count of times in display list. */ FaceImageType *type; /* image functions. */ void *data; /* image data */ struct face_image *next; /* Pointer to next face. */ struct face_image *prev; /* Pointer to prev face. */ }; #endif /* FACE_IMAGE_H_ */ xfaces-3.3/face_search.h 444 227 12 3727 5540460214 14073 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * * * Author : Chris Liebman * Created On : Sat Jan 29 15:03:34 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Jan 31 22:52:06 1994 * Update Count : 15 * Status : Released * * HISTORY * * PURPOSE * Search structs. * * $Id: face_search.h,v 1.1 1994/02/01 03:52:16 liebman Exp $ */ #ifndef FACE_SEARCH_H #define FACE_SEARCH_H struct face_search_type { char* name; int (*search) P_((MailItem* item, FaceSearchData* data)); void *data; FaceSearchType* next; }; struct face_search_data { FaceFormat format; FaceSearchType* search; FaceImageType** itypes; FaceSoundType** stypes; char** paths; FaceSearchData* next; }; #endif /* FACE_SEARCH_H */ xfaces-3.3/face_sound.h 444 227 12 4001 5540460214 13740 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sat Feb 12 22:22:41 1994 * Update Count : 2 * Status : Released * * HISTORY * * PURPOSE * Definitions for sounds. * * $Id: face_sound.h,v 1.3 1994/02/13 22:33:30 liebman Exp $ */ #ifndef FACE_SOUND_H_ #define FACE_SOUND_H_ /* * Here is a face sound structure. */ struct face_sound { String file; /* sound file name */ int refs; /* Total refs on this face. */ #ifdef USE_BUCKETS AuBucketID bucket; #else Sound sound; #endif struct face_sound *next; /* Pointer to next face. */ struct face_sound *prev; /* Pointer to prev face. */ }; #endif /* FACE_SOUND_H_ */ xfaces-3.3/patchlevel.h 444 227 12 3334 5540460215 13772 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Mar 7 21:20:18 1994 * Update Count : 7 * Status : Released * * HISTORY * * PURPOSE * Version and patch level. * * $Id: patchlevel.h,v 1.17 1994/03/12 21:25:34 liebman Exp $ */ #ifndef PATCHLEVEL_H_ #define PATCHLEVEL_H_ #define XFACES_VERSION 3.3 #define PATCH_LEVEL 0 #endif /* PATCHLEVEL_H_ */ xfaces-3.3/cmd_check.c 444 227 12 7400 5540460216 13535 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Fri Feb 4 08:20:34 1994 * Update Count : 3 * Status : Released * * HISTORY * 4-Feb-1994 Chris Liebman * Last Modified: Tue Jan 11 14:29:22 1994 #1 (Chris Liebman) * Added code to handle the Cols=nnn Rows=nnn line. * * PURPOSE * Use listCommand to get new list. */ #ifndef lint static char *RCSid = "$Id: cmd_check.c,v 1.3 1994/02/04 13:20:43 liebman Exp $"; #endif #include "faces.h" #include static char* buffer = NULL; static int buffer_size = 0; static int CmdReadLine(cmd) FILE* cmd; { int len; int c; if (buffer == NULL) { buffer_size = 1024; buffer = XtMalloc(buffer_size); } len = 0; buffer[len] = '\0'; while((c = fgetc(cmd)) != EOF && c != '\n') { if (len >= (buffer_size - 1)) { buffer_size += 1024; buffer = XtRealloc(buffer, buffer_size); } buffer[len++] = c; buffer[len] = '\0'; } /* * We only return 0 at eof. */ if (len == 0 && c != EOF) { buffer[len++] = '\n'; buffer[len] = '\0'; } return len; } void CmdCheck() { FILE* cmd; char** fields; int cols = 0; int rows = 0; cmd = popen(TheFacesResources.list_command, "r"); if (cmd == NULL) { return; } /* * read the first two lines. * (We currently ignore these lines, they * look like: "host\tuser" and "Cols=mm Rows=nn". */ CmdReadLine(cmd); /* * Read the number of rows and columns. */ if (CmdReadLine(cmd)) { fields = StringParse(buffer, "= \t\n"); /* * Expect four fields to of which should be fixed strings. */ if (fields[0] && fields[1] && fields[2] && fields[3] && !fields[4] && (strcmp(fields[0], "Cols") == 0) && (strcmp(fields[2], "Rows") == 0)) { cols = atoi(fields[1]); rows = atoi(fields[3]); XtVaSetValues(TheFrame, XtNsetWidth, cols, XtNsetHeight, rows, NULL); } else { fprintf(stderr, "malformed Cols=nnn Rows=nnn line.\n"); } XtFree((char*) fields); } while(CmdReadLine(cmd)) { fields = StringParse(buffer, "\t\n"); /* * The first two fields are required! */ if (!fields[0] || !fields[1]) { continue; } MailItemCreateNoHeaders(fields[0], fields[1], &fields[2]); XtFree((char*) fields); } pclose(cmd); return; } xfaces-3.3/Tiled.c 444 227 12 35616 5540460216 12730 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 13 16:58:19 1994 * Update Count : 8 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Sat Feb 5 20:43:46 1994 #6 (Chris Liebman) * Allow this file to compile with a non-ansi compiler. * * PURPOSE * Simple tiled layout widget */ #ifndef lint static char RCSid[] = "$Id: Tiled.c,v 1.5 1994/03/07 20:15:55 liebman Exp $"; #endif /* lint */ #include "TiledP.h" #include "X11/Composite.h" #include "X11/CompositeP.h" #include #define superclass ((CompositeWidgetClass)&compositeClassRec) #ifdef __STDC__ #define P_(x) x #else #define P_(x) (/* x */) #endif /*. *************************************************************************** Functional Prototypes. *************************************************************************** */ static Boolean SetValues P_((Widget gcurrent, Widget grequest, Widget gnew, ArgList args, Cardinal *num_args)); static Boolean AcceptFocus P_((Widget w, Time *time)); static void Layout P_((TiledWidget tw)); static XtGeometryResult GeometryHandler P_((Widget w, XtWidgetGeometry *request, XtWidgetGeometry *result)); static void ChangeManaged P_((Widget widget)); static void InsertChild P_((Widget new)); static void DeleteChild P_((Widget old)); static Boolean defTrue = True; #define offset(field) XtOffsetOf(TiledRec, field) static XtResource resources[] = { { XtNvertSpacing, XtCHeight, XtRDimension, sizeof(Dimension), offset(tiled.vert_spacing), XtRImmediate, (XtPointer) 0 }, { XtNhorizSpacing, XtCHeight, XtRDimension, sizeof(Dimension), offset(tiled.horiz_spacing), XtRImmediate, (XtPointer) 0 }, { XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension), offset(tiled.internal_width), XtRImmediate, (XtPointer) 0 }, { XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension), offset(tiled.internal_height), XtRImmediate, (XtPointer) 0 }, { XtNtileWidth, XtCWidth, XtRDimension, sizeof(Dimension), offset(tiled.tile_width), XtRImmediate, (XtPointer) 64 }, { XtNtileHeight, XtCHeight, XtRDimension, sizeof(Dimension), offset(tiled.tile_height), XtRImmediate, (XtPointer) 64 }, { XtNsetWidth, XtCWidth, XtRDimension, sizeof(Dimension), offset(tiled.set_width), XtRImmediate, (XtPointer) 0 }, { XtNsetHeight, XtCHeight, XtRDimension, sizeof(Dimension), offset(tiled.set_height), XtRImmediate, (XtPointer) 0 }, { XtNminWidth, XtCWidth, XtRDimension, sizeof(Dimension), offset(tiled.min_width), XtRImmediate, (XtPointer) 0 }, { XtNminHeight, XtCHeight, XtRDimension, sizeof(Dimension), offset(tiled.min_height), XtRImmediate, (XtPointer) 0 }, { XtNmaxWidth, XtCWidth, XtRDimension, sizeof(Dimension), offset(tiled.max_width), XtRImmediate, (XtPointer) 0 }, { XtNmaxHeight, XtCHeight, XtRDimension, sizeof(Dimension), offset(tiled.max_height), XtRImmediate, (XtPointer) 0 }, { XtNlayout, XtCLayout, XtRBoolean, sizeof(Boolean), offset(tiled.layout), XtRBoolean, (caddr_t) &defTrue } }; #undef offset static void NewSize(tw) TiledWidget tw; { int internal_width = tw->tiled.internal_width; int internal_height = tw->tiled.internal_height; int vert_spacing = tw->tiled.vert_spacing; int horiz_spacing = tw->tiled.horiz_spacing; int tile_width = tw->tiled.tile_width; int tile_height = tw->tiled.tile_height; int min_width = tw->tiled.min_width; int min_height = tw->tiled.min_height; int max_width = tw->tiled.max_width; int max_height = tw->tiled.max_height; int width_in_tiles = tw->tiled.set_width; int height_in_tiles = tw->tiled.set_height; int tile_count = tw->tiled.tile_count; Dimension width; Dimension height; /* * If there is no set width then calulate the preferred width in tiles; */ if (width_in_tiles == 0) { width_in_tiles = tile_count; if ((max_width > 0) && (width_in_tiles > max_width)) { width_in_tiles = max_width; } else if ((min_width > 0) && (width_in_tiles < min_width)) { width_in_tiles = min_width; } } /* * If there is no set height then calulate the preferred height in tiles; */ if (height_in_tiles == 0) { /* * Calculate what we want based upon the width in tiles and the * tile count. */ height_in_tiles = (tile_count / width_in_tiles); if ((height_in_tiles * width_in_tiles) < tile_count) { height_in_tiles += 1; } if ((max_height > 0) && (height_in_tiles > max_height)) { height_in_tiles = max_height; } else if ((min_height > 0) && (height_in_tiles < min_height)) { height_in_tiles = min_height; } } /* * Compute width and height in pixels. */ width = (2 * internal_width + width_in_tiles * tile_width + (width_in_tiles - 1) * horiz_spacing); height = (2 * internal_height + height_in_tiles * tile_height + (height_in_tiles - 1) * vert_spacing); /* * If this is already our size then we can stop now! */ if ((tw->core.width == width) && (tw->core.height == height)) { return; } /* * Now ask our parrent for this size. */ switch (XtMakeResizeRequest((Widget)tw, width, height, &width, &height)) { case XtGeometryYes: break; case XtGeometryNo: /* * Said no! Keep the current size! */ width = tw->core.width; height = tw->core.height; break; case XtGeometryAlmost: /* * We take whatever we can get! (parent must accept as was returned * "almost") */ (void)XtMakeResizeRequest((Widget)tw, width, height, &width, &height); break; default: /* * Don't understand result! */ width = tw->core.width; height = tw->core.height; break; } /* * recompute tile size based upon new width and height. * * First remove internal_width. */ width -= (2 * internal_width); /* * Stick in an extra horiz_spacing to compensate for the extra one in the * next calculation. */ width += horiz_spacing; /* * Compute the new width in tiles. */ width_in_tiles = width / (tile_width + horiz_spacing); if (width_in_tiles < 1) { width_in_tiles = 1; } tw->tiled.width_in_tiles = width_in_tiles; /* * Remove internal height. */ height -= (2 * internal_height); /* * Stick in an extra horiz_spacing to compensate for the extra one in the * next calculation. */ height += vert_spacing; /* * Compute the new height in tiles. */ height_in_tiles = height / (tile_height + vert_spacing); if (height_in_tiles < 1) { height_in_tiles = 1; } tw->tiled.height_in_tiles = height_in_tiles; } static void Layout(tw) TiledWidget tw; { int i, pos; Position x, y; Widget child; int internal_width = tw->tiled.internal_width; int internal_height = tw->tiled.internal_height; int vert_spacing = tw->tiled.vert_spacing; int horiz_spacing = tw->tiled.horiz_spacing; int tile_width = tw->tiled.tile_width; int tile_height = tw->tiled.tile_height; int width_in_tiles = tw->tiled.width_in_tiles; Dimension width, height; /* * Compute the new positions. */ for ( i = 0, pos = 0; i < tw->composite.num_children; i++ ) { child = tw->composite.children[i]; /* * Ignore unmanaged children! */ if (!XtIsManaged( child )) { continue; } /* * Compute the position for the child. */ x = (pos % width_in_tiles) * tile_width + (pos % width_in_tiles) * horiz_spacing + internal_width; y = (pos / width_in_tiles) * tile_height + (pos / width_in_tiles) * vert_spacing + internal_height; x -= child->core.border_width; y -= child->core.border_width; /* * We allow children to be smaller than the tile size but *not* * bigger. */ height = child->core.height; if (height > tile_height) { height = tile_height; } width = child->core.width; if (width > tile_width) { width = tile_width; } XtConfigureWidget(child, x, y, width, height, child->core.border_width); ++pos; } return; } static Boolean SetValues(gcurrent, grequest, gnew, args, num_args) Widget gcurrent; Widget grequest; Widget gnew; ArgList args; Cardinal *num_args; { TiledWidget current = (TiledWidget) gcurrent; TiledWidget new = (TiledWidget) gnew; /* * If the tile size or internal width/height or itemSpacing changes then * call Layout(). */ if ((current->tiled.vert_spacing != new->tiled.vert_spacing) || (current->tiled.horiz_spacing != new->tiled.horiz_spacing) || (current->tiled.internal_width != new->tiled.internal_width) || (current->tiled.internal_height != new->tiled.internal_height) || (current->tiled.tile_width != new->tiled.tile_width) || (current->tiled.tile_height != new->tiled.tile_height) || (current->tiled.set_width != new->tiled.set_width) || (current->tiled.set_height != new->tiled.set_height) || (current->tiled.min_width != new->tiled.min_width) || (current->tiled.min_height != new->tiled.min_height) || (current->tiled.max_width != new->tiled.max_width) || (current->tiled.max_height != new->tiled.max_height)) { if (new->tiled.layout) { NewSize(new); Layout(new); } } else if (!current->tiled.layout && new->tiled.layout) { NewSize(new); Layout(new); } return( FALSE ); } static Boolean AcceptFocus(w, time) Widget w; Time *time; { return( True ); } /* * The geometry handler. */ static XtGeometryResult GeometryHandler(w, request, result) Widget w; /* Child widget. */ XtWidgetGeometry *request; XtWidgetGeometry *result; { if (!(request->request_mode & XtCWQueryOnly)) { if (request->request_mode & CWX) { w->core.x = request->x; } if (request->request_mode & CWY) { w->core.y = request->y; } if (request->request_mode & CWWidth) { w->core.width = request->width; } if (request->request_mode & CWHeight) { w->core.height = request->height; } if (request->request_mode & CWBorderWidth) { w->core.border_width = request->border_width; } } return( XtGeometryYes ); } static void ChangeManaged(widget) Widget widget; { TiledWidget tw = (TiledWidget)widget; int count; int i; Widget child; for ( i = 0, count = 0; i < tw->composite.num_children; i++ ) { child = tw->composite.children[i]; if (XtIsManaged( child )) { ++count; } } tw->tiled.tile_count = count; if (tw->tiled.layout) { NewSize(tw); Layout(tw); } return; } static void InsertChild(new) Widget new; { /* * Insert the child widget in the composite children list with the * superclass insert_child routine. */ (*superclass->composite_class.insert_child)(new); return; } static void DeleteChild(old) Widget old; { TiledWidget tw; tw = (TiledWidget)XtParent( old ); if (tw->tiled.layout) { NewSize(tw); Layout(tw); } /* * Delete the child widget in the composite children list with the * superclass delete_child routine. */ (*superclass->composite_class.delete_child)(old); return; } /*. *************************************************************************** Full class record constant. *************************************************************************** */ TiledClassRec tiledClassRec = { { /* core_class fields */ (WidgetClass)superclass, /* superclass */ "Tiled", /* class_name */ sizeof(TiledRec), /* widget_size */ NULL, /* class_initialize */ NULL, /* class_part_initialize */ FALSE, /* class_inited */ NULL, /* initialize */ NULL, /* initialize_hook */ XtInheritRealize, /* realize */ NULL, /* actions */ 0, /* num_actions */ resources, /* resources */ XtNumber(resources), /* num_resources */ NULLQUARK, /* xrm_class */ TRUE, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave */ FALSE, /* visible_interest */ NULL, /* destroy */ XtInheritResize, /* resize */ NULL, /* expose */ SetValues, /* set_values */ NULL, /* set_values_hook */ XtInheritSetValuesAlmost, /* set_values_almost */ NULL, /* get_values_hook */ AcceptFocus, /* accept_focus */ XtVersion, /* version */ NULL, /* callback_private */ NULL, /* tm_table */ XtInheritQueryGeometry, /* query_geometry */ XtInheritDisplayAccelerator, /* display_accelerator */ NULL /* extension */ }, { /**** CompositePart *****/ GeometryHandler, /* geometry_handler */ ChangeManaged, /* change_managed */ InsertChild, /* insert_child */ DeleteChild, /* delete_child */ NULL /* extension */ }, { 0, /* unused. */ } }; WidgetClass tiledWidgetClass = (WidgetClass)&tiledClassRec; xfaces-3.3/README 444 227 12 17060 5540460231 12371 0ustar liebmanstaff -*- Mode: Indented-Text -*- XFaces 3.3 Christopher B. Liebman liebman@zod.clark.net March 12, 1994 What is XFaces? XFaces is a program that will display an image for each piece of mail in your mail box. This lets you know at a glance who you have mail from. XFaces starts out (when you have no mail) looking like a color xbiff. As you receive mail XFaces becomes a column of mail images. Some of XFaces features: - Both mono and color images. - Optional Shaped window support with both xpm and xbm. - Sound support using the NetAudio protocol. The NetAudio server currently supports Sun's SparcStation (SunOS 4.1.X and Solaris 2.2), SGI's Indigo and NCD MCX X terminals running NCDware 3.1 or later. - Face images can be "compressed" so that each image will only show up once on your display. This way, if you receive 30 messages from one user, list or whatever the image will only show up once. - You can use regular expressions to search any headers to choose images and sounds or ignore that mail message compleatly. This lets you specify an image/sound for mail that comes from a mailing list or ignore mail that you have already seen but left in your system mailbox. - Compatibility support for Rich Burridge's faces program. This includes the ability to run user command to generate the image list. - Support for POP mailboxes. - XFaces can kick off shell commands based upon mailbox contents. You could have yourself paged when a high priorty item needs your attention. - XFaces can run external filters to convert images into Xpm so that image formats that XFaces does not understand can be used. - The annotations for mail items include username, hostname, count, user@host, the contents of any header. XFaces is based on the Xt Intrinsics (-lXt) and the Athena Widget set (-lXaw). To build in Xpm support you need the xpm library (-lxpm) version 3.2 or later. To build in the sound support you will need NetAudio 1.1 or later. Both the xpm and the NetAudio distributions and publicly available with anon ftp from ftp.x.org in the contrib directory. If you want X-Face header support you will want James Ashton's compface library available from from ftp.clark.net in pub/liebman/compface.tar.Z. Whats new in this version? See the CHANGES file for a descriptions of what has changed since the previous version. What machines will XFaces run on? XFaces as been compiled and tested on the following machines/OS' (these are all that I have access to): Sun Sparc 10 SunOS 4.1.3 (MIT X11R5) Sun Sparc IPC SunOS 4.1.1 (MIT X11R5) It has also been reported to run on: DEC Alpha 3000 OSF 1.3 DEC 5000 Ultrix 4.2a (X11R5) IBM RS/6000 AIX 3.2.4 (X11R4) i486 System VR4 (X11R4) Macintosh IIci A/UX 3.0 (X11R5) SG Indigos IRIX 4.05H Bull DPX/2 68040 based, SV.3.1 POSIX/XPG3 80386 SCO UNIX 3.2.4 (ODT 2.0 with X11R4) hp700/800 ??? Please help me add to this list. I am really interested to find out how well this works on other machines (SGI?, HP?, DEC? IBM?, etc). Building and Installing XFaces If you do not have Imake I have supplied a Makefile.noimake that you can tailor to your site. The easiest method is to use Imake. You need to look at the Imakefile in this directory to see the definitions for USE_XPM, USE_SOUND, USE_BUCKETS , USE_XFACE, USE_SHAPE and USE_POP are what you want. By default All of these are compiled in. If you do not want one of them, just comment out or delete the #define. Sound support has another option USE_BUCKETS. If this is defined then XFaces will store the sounds for all active sounds in the audio server. If you are using NetAudio 1.1 on a sparc then you will either neet to disable the BUCKET support or apply the included patch to ausun (the patch is in ausun.patch). The bug in the sun NetAudio server causes a weird audio "glitch" that I noticed when playing from buckets. USE_XPM - Requires the xpm library. This is available from ftp.x.org in /contrib/xpm-3.3.tar.gz USE_SOUND - Requires the net audio client library and includes. NetAudio is available from ftp.x.org in /contrib/netaudio/netaudio-1.1.tar.Z USE_SHAPE - Requires the MIT SHAPE extension. USE_XFACE - Requires the compface library available from cs.indiana.edu in /pub/faces/xfaces/compface.tar.Z or ftp.clark.net in /pub/liebman/compface.tar.Z USE_POP - Requires BSD style sockets. Next to build the Makefile run: xmkmf Then to build XFaces run: make To install XFaces type: make install How to set up XFaces I recomend the use of the facedb search to find the majority of the images and sounds. A couple large databases of face images are available from cs.indiana.edu in the /pub/faces directory. Included in this release are a number of sample icons that I use. Also the sample XFaces app defaults file contains examples of using the before bindings to show a particular image/sound for items from a mailing list. I will be glad to help anyone who is having problems setting up XFaces or anyone who has any questions about XFaces. The man page provides more detailed information than any normal human being can stand! :^) Unfortunatly it is not very well written. :^( Does anyone care to take a stab at it? Sample face images I have placed a number if images that we use for XFaces in the images subdirectory. You will want to copy them to your images directory. Bugs (bugs? never! :^), Fixes and Enhancements If you find any bugs or have fixes for bugs or have suggestions for enhancements or have patches for enhancements please send them to me at: liebman@zod.clark.net I will welcome *any* improvements to the documentation! Disscussions of future enhancements are also welcome on the faces mailing list: faces@cs.indiana.edu To subscribe send your request (and all other adminstrative requests to: faces-request@cs.indiana.edu ------------------------------------------------------------------------------- Copyright 1994 Christopher B. Liebman Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name Christopher B. Liebman not be used in advertising or publicity pertaining to distribution of this software without specific, written prior permission. THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. xfaces-3.3/BLURB 444 227 12 13470 5540460231 12303 0ustar liebmanstaff XFaces 3.3 Christopher B. Liebman liebman@zod.clark.net March 12, 1994 What is XFaces? XFaces is a program that will display an image for each piece of mail in your mail box. This lets you know at a glance who you have mail from. XFaces starts out (when you have no mail) looking like a color xbiff. As you receive mail XFaces becomes a column of mail images. Some of XFaces features: - Both mono and color images. - Optional Shaped window support with both xpm and xbm. - Sound support using the NetAudio protocol. The NetAudio server currently supports Sun's SparcStation (SunOS 4.1.X and Solaris 2.2), SGI's Indigo and NCD MCX X terminals running NCDware 3.1 or later. - Face images can be "compressed" so that each image will only show up once on your display. This way, if you receive 30 messages from one user, list or whatever the image will only show up once. - You can use regular expressions to search any headers to choose images and sounds or ignore that mail message compleatly. This lets you specify an image/sound for mail that comes from a mailing list or ignore mail that you have already seen but left in your system mailbox. - Compatibility support for Rich Burridge's faces program. This includes the ability to run user command to generate the image list. - Support for POP mailboxes. - XFaces can kick off shell commands based upon mailbox contents. You could have yourself paged when a high priorty item needs your attention. - XFaces can run external filters to convert images into Xpm so that image formats that XFaces does not understand can be used. - The annotations for mail items include username, hostname, count, user@host, the contents of any header. XFaces is based on the Xt Intrinsics (-lXt) and the Athena Widget set (-lXaw). To build in Xpm support you need the xpm library (-lxpm) version 3.2 or later. To build in the sound support you will need NetAudio 1.1 or later. Both the xpm and the NetAudio distributions and publicly available with anon ftp from ftp.x.org in the contrib directory. If you want X-Face header support you will want James Ashton's compface library available from from ftp.clark.net in pub/liebman/compface.tar.Z. Changes in version 3.3: 3/12/1994 Fixed a large memory leak! Fixed a problem that was caused by elm setting the mod time of the mail spool file back. Fixed a problem with MMDF style mailboxes. Changes in version 3.2: 3/7/1994 A few bugs were fixed. Added a seperate set of annotation specifications for "unknown" faces. As the TODO file notes this feature could stand to be generalized a little. If the binding field name starts with a '|' then all binding checks are case insensitive. If the "lookupHostname" resource is True then the host name part of the from address will be looked up and translated to the real hostname. Handle rfc822 routing address in a semi-sane manor. Changes in version 3.1: 3/7/1994 A few bug fixes. (one had caused a SEG Fault on many machines) User control of the mail annotatons. The default values for the imageTypes and imageSearch resources should reflect the options that the user compiled in. Changes in version 3.0: 2/24/1994 The major changes were to add compatibility support for Rich Burridge's "faces" program: - Per-face shell commands. - X-Face: header support. - facedb image/sound search. (the way faces finds images) - User list commands. - Labling of images. The user name and the number of messages are displayed. - The following faces options are supported: -f -e -p -c <# of columns> -h -w -s - POP mailbox support. (still primitive with respect to user authentication but functional!) - A new Tiled widget so that the image list can be N columns and to allow for the "Rows=nnn Cols=nnn" line from a user command. - Full control of the order and imagetype/paths of searches. The search types are: - beforeImage, afterImage, beforeSound, afterSound, beforeCommand, afterCommand: These are regular expression searches on the mail headers. - resource: Lookup image/sound in X resources. - facedb: Lookup image/sound in "faces" style database. - x-face: X-Face: style header. - Searchs are done for images, sounds and shell commands. - Much improved shape support. Changes in version 2.3: 1/20/1994 Compleatly rewrote the mail header parsing. Now all headers are searched. Changed slightly the before/after image/sound bining format. Now you use three parts instead of to. The new format is:
<:> Fixed a bug in the image code where a pixmap value was uninitialized and caused X error on some machines (machines where the unitialized value happened to be "None" worked! others did not). Changes in version 2.2: 1/14/1994 Added new resource ignoreMessageBindings. This allows you to have some messages ignored. Made the "Status:" header one of the headers that is searched with the bindings resources. This allows people who like to keep 200 to 300 messages in their system mailbox to only see/hear from messages that they have not seen yet. Made a small change to faces.h to allow for SystemV machines. I added macros for bcopy, bzero, index and rindex. Improved mail parsing. Before if there was no subject header xfaces could be fooled by a line in the body starting with Subject:. xfaces-3.3/face_actions.c 444 227 12 10115 5540460216 14270 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 13 16:59:08 1994 * Update Count : 19 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Sat Feb 12 23:15:20 1994 #17 (Chris Liebman) * Added RunCommands action. * * 31-Jan-1994 Chris Liebman * Last Modified: Tue Jan 11 14:16:36 1994 #1 (Chris Liebman) * Now use CheckMailNow() to avoid duplicate code. * * PURPOSE * Global Xt Actions for xfaces. */ #ifndef lint static char *RCSid = "$Id: face_actions.c,v 1.8 1994/02/13 21:59:13 liebman Exp $"; #endif #include "faces.h" /* * Replay sound action. */ static void FacePlaySounds(w, event, params, num_params) Widget w; XEvent *event; String *params; int num_params; { #ifdef SOUND Face *face; FaceItem *item; /* * If we do not want sounds then don't play any! */ if (!TheFacesResources.use_sound) { return; } if (TheFaceList == NULL) { FaceSoundPlay(NoMailSound); return; } /* * Find the face associated with widget. */ for (face = TheFaceList; face != NULL; face = face->next) { if (face->widget == w) { break; } } if (face == NULL) { return; } /* * Play all attached sounds. */ for(item = face->items; item != NULL; item = item->next) { if (item->item->sound != NULL) { FaceSoundPlay(item->item->sound); } } #endif /* SOUND */ } /* * Run commands action. */ static void FaceRunCommands(w, event, params, num_params) Widget w; XEvent *event; String *params; int num_params; { Face *face; FaceItem *item; /* * If we do not want commands then don't run any. */ if (!TheFacesResources.use_commands) { return; } /* * Find the face associated with widget. */ for (face = TheFaceList; face != NULL; face = face->next) { if (face->widget == w) { break; } } if (face == NULL) { return; } /* * Run all attached commands. */ for(item = face->items; item != NULL; item = item->next) { if (item->item->command != NULL) { FaceCommandRun(item->item->command); } } } static void FaceCheckMail(w, event, params, num_params) Widget w; XEvent *event; String *params; int num_params; { CheckMailNow(); #ifdef SOUND if (TheFaceList == NULL && TheFacesResources.use_sound) { FaceSoundPlay(NoMailSound); return; } #endif /* SOUND */ } static XtActionsRec FaceActions[] = { {"PlaySounds", FacePlaySounds}, {"RunCommands", FaceRunCommands}, {"CheckMail", FaceCheckMail} }; void FaceActionsInit() { XtAddActions(FaceActions, XtNumber(FaceActions)); } xfaces-3.3/face_annotate.c 444 227 12 31410 5540460217 14443 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Mar 7 18:02:58 1994 * Update Count : 285 * Status : Released * * HISTORY * 6-Mar-1994 Chris Liebman * Last Modified: Sun Mar 6 12:28:00 1994 #274 (Chris Liebman) * Fixed a problem with FaceAnnotateWork being called with a struct * rather than a pointer to a struct! * * 13-Feb-1994 Chris Liebman * Last Modified: Sun Feb 13 00:38:41 1994 #271 (Chris Liebman) * Make images that are smaller than the tile size bigger and * Allow choice as to weather the extra height is on the top or the * bottom. The image is always centered left to right. * * PURPOSE * Handle image annotation. */ #ifndef lint static char *RCSid = "$Id: face_annotate.c,v 1.4 1994/03/08 02:16:44 liebman Exp $"; #endif #include "faces.h" #include "face_image.h" typedef struct annotation Annotation; struct annotation { Position x; Position y; Dimension max_width; Pixel fg; Pixel bg; XFontStruct* font; Boolean shape_text; Boolean opaque_text; }; #define offset(field) XtOffset(Annotation*, field) static XtResource AnnotationResourcesList[] = { { "x", "Position", XtRPosition, sizeof(Position), offset(x), XtRString, "0" }, { "y", "Position", XtRPosition, sizeof(Position), offset(y), XtRString, "0" }, { "maxWidth", "Dimension", XtRDimension, sizeof(Dimension), offset(max_width), XtRString, "48" }, { "foreground", "Foreground", XtRPixel, sizeof(Pixel), offset(fg), XtRString, XtDefaultForeground }, { "background", "Background", XtRPixel, sizeof(Pixel), offset(bg), XtRString, XtDefaultBackground }, { "font", "Font", XtRFontStruct, sizeof(XFontStruct *), offset(font), XtRString, XtDefaultFont }, { "shapeText", "ShapeText", XtRBoolean, sizeof(Boolean), offset(shape_text), XtRString, "False" }, { "opaqueText", "OpaqueText", XtRBoolean, sizeof(Boolean), offset(opaque_text), XtRString, "True" }, }; #undef offset static int annotationCount = 0; static Annotation* annotations = NULL; static int unknownAnnotationCount = 0; static Annotation* unknownAnnotations = NULL; static void FaceAnnotateWork(face, a, astr, imageWidth, imageHeight, imageGC, shapeGC) Face* face; Annotation* a; char* astr; unsigned int imageWidth; unsigned int imageHeight; GC imageGC; GC shapeGC; { int length; int dir, ascent, descent; int x, y; int width, height; int maxWidth; XCharStruct size; Display* display = XtDisplay(TheTopLevel); if (astr == NULL || *astr == '\0') { return; } /* * Compute max allowable width for text. */ x = a->x; y = a->y; if (x < 0) { maxWidth = imageWidth + x; } else { maxWidth = imageWidth - x; } if (maxWidth > a->max_width) { maxWidth = a->max_width; } /* * Compute the size of the string. */ size.width = imageWidth + 1; for(length = strlen(astr); length > 0; --length) { XTextExtents(a->font, astr, length, &dir, &ascent, &descent, &size); if (size.width <= maxWidth) { break; } } if (length == 0) { length = 1; } width = size.width; height = ascent + descent; /* * Upper left corner of text. */ if (x < 0) { x = imageWidth - width + x; } if (y < 0) { y = imageHeight - height + y; } /* * Set shape mask area for label if shaped. */ if (face->shape != None) { if (a->shape_text) { XDrawString(display, face->shape, shapeGC, x, y+ascent, astr, length); } else { XFillRectangle(display, face->shape, shapeGC, x, y, width, height); } } if (a->opaque_text) { XDrawImageString(display, face->pixmap, imageGC, x, y+ascent, astr, length); } else { XDrawString(display, face->pixmap, imageGC, x, y+ascent, astr, length); } } void FaceAnnotateFree(face) Face *face; { int i; if (face->annotations == NULL) { face->pixmap = None; face->shape = None; return; } for(i = 0; face->annotations[i]; ++i) { XtFree(face->annotations[i]); } XtFree((char*)face->annotations); if (face->pixmap != None) { XFreePixmap(XtDisplay(TheTopLevel), face->pixmap); } if (face->shape != None) { XFreePixmap(XtDisplay(TheTopLevel), face->shape); } face->annotations = NULL; face->pixmap = None; face->shape = None; } /* * Return 1 if image changed! */ int FaceAnnotate(face) Face* face; { Pixmap pixmap; Pixmap shape; unsigned int imageWidth; unsigned int imageHeight; int imageDepth; Window imageRoot; unsigned int shapeWidth; unsigned int shapeHeight; int shapeDepth; Window shapeRoot; int junkx, junky; unsigned int junkbw; unsigned int mask; XGCValues values; GC imageGC; GC shapeGC; Display* display = XtDisplay(TheTopLevel); int i; int x = 0; int y = 0; char** adata; Dimension tileHeight; Dimension tileWidth; int extraHeight = 0; int extraWidth = 0; int count; Annotation* annos; if (face->items->item->unknown) { count = unknownAnnotationCount; annos = unknownAnnotations; } else { count = annotationCount; annos = annotations; } /* * We use the newest mail item to do the annotations. */ adata = face->items->item->annotations; /* * If there is no "new" annotation data now then just clear it all off. */ if (adata == NULL) { pixmap = face->pixmap; FaceAnnotateFree(face); face->pixmap = FaceImagePixmap(face->image); face->shape = FaceImageShape(face->image); return (pixmap != face->pixmap); } /* * If there is old annotation data then see if it the same as the * new data. If it is then we need to do nothing! */ if (face->annotations != NULL) { for(i = 0; i < count; ++i) { if ((face->annotations[i] == NULL) || (adata[i] == NULL) || (strcmp(face->annotations[i], adata[i]) != 0)) { break; } } /* * Nothing changed! */ if ((i >= count) || ((face->annotations[i] == NULL) && (adata[i] == NULL))) { return 0; } } /* * Ok, things have changed, free the old annotations. */ FaceAnnotateFree(face); /* * Now make the annotations. */ if ((pixmap = FaceImagePixmap(face->image)) == None) { return 0; } shape = FaceImageShape(face->image); /* * We may need to make the pixmaps bigger to accomidate annotation * either above or below. Here we compute the position of the old * pixmap data and the extra height of the new. */ XtVaGetValues(TheFrame, XtNtileWidth, &tileWidth, XtNtileHeight, &tileHeight, NULL); /* * Copy the pixmap and any shape. */ XGetGeometry(display, pixmap, &imageRoot, &junkx, &junky, &imageWidth, &imageHeight, &junkbw, &imageDepth); /* * If the image is smaller than the frame need to enlarge it. */ if (tileHeight > imageHeight) { extraHeight = tileHeight - imageHeight; if (TheFacesResources.annotation_above) { y = extraHeight; } } if (tileWidth > imageWidth) { extraWidth = tileWidth - imageWidth; x = extraWidth / 2; } face->pixmap = XCreatePixmap(display, imageRoot, imageWidth + extraWidth, imageHeight + extraHeight, imageDepth); /* * Create a GC to use with the image. */ mask = GCForeground | GCFunction | GCGraphicsExposures | GCFillStyle; values.foreground = TheFacesResources.background; values.function = GXcopy; values.fill_style = FillSolid; values.graphics_exposures = False; imageGC = XCreateGC(display, face->pixmap, mask, &values); /* * Copy the image. */ XFillRectangle(display, face->pixmap, imageGC, 0, 0, imageWidth + extraWidth, imageHeight + extraHeight); XCopyArea(display, pixmap, face->pixmap, imageGC, 0, 0, imageWidth, imageHeight, x, y); if (shape == None) { shapeWidth = imageWidth; shapeHeight = imageHeight; shapeRoot = imageRoot; shapeDepth = 1; } else { XGetGeometry(display, shape, &shapeRoot, &junkx, &junky, &shapeWidth, &shapeHeight, &junkbw, &shapeDepth); } face->shape = XCreatePixmap(display, shapeRoot, shapeWidth + extraWidth, shapeHeight + extraHeight, shapeDepth); /* * Create a gc for use with the shape. */ mask = (GCForeground | GCBackground | GCFunction | GCFillStyle | GCGraphicsExposures); values.foreground = 0; values.background = 0; values.function = GXcopy; values.fill_style = FillSolid; values.graphics_exposures = False; shapeGC = XCreateGC(display, face->shape, mask, &values); /* * Copy shape data. */ XFillRectangle(display, face->shape, shapeGC, 0, 0, shapeWidth + extraWidth, shapeHeight + extraHeight); XSetForeground(display, shapeGC, 1); if (shape == None) { if (!TheFacesResources.shape_extra) { shapeWidth += extraWidth; shapeHeight += extraHeight; x = 0; y = 0; } XFillRectangle(display, face->shape, shapeGC, x, y, shapeWidth, shapeHeight); } else { XCopyArea(display, shape, face->shape, shapeGC, 0, 0, shapeWidth, shapeHeight, x, y); } /* * Now for each valid annotation. */ face->annotations = (char**)XtCalloc(count+1, sizeof(char*)); for(i = 0; i < count; ++i) { /* * Stop if we run out of data. */ if (adata[i] == NULL) { face->annotations[i] = NULL; break; } /* * Copy the string. */ face->annotations[i] = XtNewString(adata[i]); /* * Annotate image! */ XSetFont(display, imageGC, annos[i].font->fid); if (face->shape != None) { XSetFont(display, shapeGC, annos[i].font->fid); } XSetForeground(display, imageGC, annos[i].fg); XSetBackground(display, imageGC, annos[i].bg); FaceAnnotateWork(face, &annos[i], face->annotations[i], imageWidth + extraWidth, imageHeight + extraHeight, imageGC, shapeGC); } XFreeGC(display, imageGC); if (face->shape) { XFreeGC(display, shapeGC); } return 1; } void FaceAnnotateInit() { int i; char name[30]; annotationCount = TheFacesResources.annotation_count; annotations = (Annotation*) XtCalloc(annotationCount, sizeof(Annotation)); for(i = 0; i < annotationCount; ++i) { sprintf(name, "annotation%d", i+1); XtGetSubresources(TheTopLevel, &annotations[i], name, "Annotation", AnnotationResourcesList, XtNumber(AnnotationResourcesList), NULL, 0); }; unknownAnnotationCount = TheFacesResources.unknown_annotation_count; unknownAnnotations = (Annotation*) XtCalloc(unknownAnnotationCount, sizeof(Annotation)); for(i = 0; i < unknownAnnotationCount; ++i) { sprintf(name, "unknownAnnotation%d", i+1); XtGetSubresources(TheTopLevel, &unknownAnnotations[i], name, "Annotation", AnnotationResourcesList, XtNumber(AnnotationResourcesList), NULL, 0); }; } xfaces-3.3/face_binding.c 444 227 12 17101 5540460217 14245 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Mar 6 22:49:00 1994 * Update Count : 61 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Mon Jan 31 22:39:36 1994 #39 (Chris Liebman) * Added a label field to the bindings. * * 31-Jan-1994 Chris Liebman * Last Modified: Mon Jan 31 22:34:33 1994 #38 (Chris Liebman) * Moved SkipChars() and ParseToken() to string.c * * 18-Jan-1994 Chris Liebman * Last Modified: Tue Jan 18 15:18:09 1994 #9 (Chris Liebman) * Changed the binding parser to expect two and three tokens instead * of one and two. Now expects []. * * 14-Jan-1994 Chris Liebman * Last Modified: Tue Jan 11 14:16:14 1994 #1 (Chris Liebman) * added flag to FaceBindingParse to allow the ignoreMessages * bindings to be parsed also. * * PURPOSE * Parse the binding lines from the resource file. Bindings contain a * list of patterns then a file name for an image or sound if the pattern * is matched. */ #ifndef lint static char *RCSid = "$Id: face_binding.c,v 1.11 1994/03/07 20:24:10 liebman Exp $"; #endif #include "faces.h" /* * Parse the bindings. */ FaceBinding * FaceBindingParse(str, has_value, has_label) String str; int has_value; int has_label; { FaceBinding *fb; FaceBinding *list = NULL; String pair = NULL; String name = NULL; String pattern = NULL; String value = NULL; String label = NULL; String annop; int anno; char* p; if (str == NULL) { return(NULL); } while((pair = ParseToken(&str, "\n")) != NULL) { anno = 1; pair = SkipChars(pair, "\t \n"); /* * Field name to check. */ name = ParseToken(&pair, "\t \n"); /* * Parse out the expression. */ pair = SkipChars(pair, "\t \n"); if (!has_value) { if (strlen(pair) == 0) { continue; } pattern = pair; value = NULL; } else { if ((pattern = ParseToken(&pair, ":")) == NULL) { continue; } if (!has_label) { value = SkipChars(pair, "\t "); } else { value = ParseToken(&pair, "\t \n"); label = SkipChars(pair, "\t "); /* * If there is an annotation number then grab it, otherwise it * defaults to 1. */ annop = rindex(label, ':'); if (annop != NULL) { *annop++ = '\0'; anno = atoi(annop); } if (anno < 1 || anno > TheFacesResources.annotation_count) { anno = 1; } } } fb = XtNew(FaceBinding); /* * If the field name starts with a '|' then we should be case * insensitive. */ if (*name == '|') { ++name; fb->casesensitive = 0; for(p = pattern; *p != '\0'; ++p) { if (isupper(*p)) { *p = tolower(*p); } } } else { fb->casesensitive = 1; } /* * If the field name is "*" then all fields are searched. If the * field name has a leading */ if (strcmp(name, "*") == 0) { fb->name = NULL; } else { fb->name = XtNewString(name); } /* * Compile the regular expression. */ fb->patsrc = XtNewString(pattern); fb->pattern = regcomp(pattern); /* * If we don't need a value then net the file to NULL. */ if (!has_value) { fb->file = NULL; } else { fb->file = XtNewString(value); fb->label = XtNewString(label); fb->anno = anno; } /* * place binding on list. */ fb->next = list; list = fb; } return(list); } /* * Check a binding list agains a header list for a match. */ FaceBinding* FaceBindingCheck(headers, bindings) MailHeader* headers; FaceBinding* bindings; { MailHeader* header; FaceBinding* binding; char* value; char* p; int result; for (binding = bindings; binding != NULL; binding = binding->next) { #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: pattern: <%s>\n", binding->patsrc); #endif /* * See if we only need to check one header for this binding. */ if (binding->name != NULL) { #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: check <%s> header.\n", binding->name); #endif if ((header = MailHeaderFind(binding->name, headers)) != NULL) { #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: <%s> value: <%s>.\n", binding->name, header->value); #endif /* * if we are not case sensitive then copy the header value * and make it lower case. */ if (!binding->casesensitive) { value = XtNewString(header->value); for(p = value; *p != '\0'; ++p) { if (isupper(*p)) { *p = tolower(*p); } } #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: lowered value: <%s>\n", value); #endif } else { value = header->value; } result = regexec(binding->pattern, value); if (!binding->casesensitive) { XtFree(value); value = NULL; } if (result) { #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: matched!\n"); #endif return binding; } #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: no match.\n"); #endif } } else { #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: check all headers.\n"); #endif /* * Search all headers. */ for (header = headers; header != NULL; header = header->next) { #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: checking: <%s> value: <%s>.\n", header->name, header->value); #endif /* * if we are not case sensitive then copy the header value * and make it lower case. */ if (!binding->casesensitive) { value = XtNewString(header->value); for(p = value; *p != '\0'; ++p) { if (isupper(*p)) { *p = tolower(*p); } } #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: lowered value: <%s>\n", value); #endif } else { value = header->value; } result = regexec(binding->pattern, value); if (!binding->casesensitive) { XtFree(value); value = NULL; } if (result) { #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: matched!\n"); #endif return binding; } #ifdef BINDING_DEBUG fprintf(stderr, "FaceBindingCheck: no match.\n"); #endif } } } return NULL; } xfaces-3.3/face_command.c 444 227 12 7673 5540460217 14246 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * * * Author : Chris Liebman * Created On : Sat Feb 12 21:40:50 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 13 17:00:44 1994 * Update Count : 24 * Status : Released * * HISTORY * * PURPOSE * Handle commands. */ #ifndef lint static char *RCSid = "$Id: face_command.c,v 1.1 1994/02/13 22:00:52 liebman Exp $"; #endif #include "faces.h" #include "face_command.h" #include "face_search.h" static FaceCommand* TheCommands; /* * Create face command data for face. */ FaceCommand * FaceCommandCreate(file) char *file; { FaceCommand *fc; /* * First see if we already have this command. */ for (fc = TheCommands; fc != NULL; fc = fc->next) { if (strcmp(fc->command, file) == 0) { /* * Yep! */ fc->refs += 1; return(fc); } } /* * Ok, create a face command struct. */ fc = (FaceCommand *)XtCalloc(1, sizeof(FaceCommand)); fc->command = XtNewString(file); fc->refs = 1; /* * Put the new command on the list. */ fc->next = TheCommands; fc->prev = NULL; if (fc->next != NULL) { fc->next->prev = fc; } TheCommands = fc; /* * and return it. */ return(fc); } /* * Free a command. */ void FaceCommandFree(fc) FaceCommand *fc; { if (!fc) { return; } /* * First remove one reference. If there are still more refs just * return. */ fc->refs -= 1; if (fc->refs != 0) { return; } /* * The previous command is now previous to the next command. */ if (fc->next != NULL) { fc->next->prev = fc->prev; } /* * The next face is now next from the previous face. */ if (fc->prev != NULL) { fc->prev->next = fc->next; } /* * If this was the first command then the next command is * first. */ if (fc == TheCommands) { TheCommands = fc->next; } /* * Ok, free the name. */ XtFree(fc->command); /* * Free the struct. */ XtFree((void *)fc); } int FaceCommandLoad(file, item, data) char* file; MailItem* item; FaceSearchData* data; { /* * We always succeed! */ item->command = FaceCommandCreate(file); return 1; } /* * Execute a command. */ void FaceCommandRun(fc) FaceCommand *fc; { /* * No command! */ if (!fc) { return; } system(fc->command); } void FaceCommandFind(item) MailItem* item; { if (TheFacesResources.use_commands) { FaceSearch(item, TheFacesResources.command_search); } } xfaces-3.3/face_display.c 444 227 12 22461 5540460220 14277 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 13 17:02:35 1994 * Update Count : 51 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Sat Feb 12 22:31:05 1994 #48 (Chris Liebman) * Modified the way that annotations are handled. Removed sounds from * the face structure. Added a list of mail items using face to the * face struct. * * 2-Feb-1994 Chris Liebman * Last Modified: Tue Feb 1 14:03:54 1994 #27 (Chris Liebman) * Added Annotation support. * * 31-Jan-1994 Chris Liebman * Last Modified: Sat Jan 29 22:31:04 1994 #22 (Chris Liebman) * Added support to keep the face order by deleting and recreating * the widgets each check if the keepOrder resource is true. * Modified the initial nomail image and sound calls in * FaceDisplayInit(). * * 24-Jan-1994 Chris Liebman * Last Modified: Sun Jan 23 17:26:17 1994 #13 (Chris Liebman) * Changed the NoMail to NoMailWidget and exported. * * 20-Jan-1994 Chris Liebman * Last Modified: Tue Jan 18 20:48:03 1994 #5 (Chris Liebman) * Fixed a problem where the pixmap variable in two functions was * used before it was set and caused X error on some machines. * * PURPOSE * Manage the face list. */ #ifndef lint static char *RCSid = "$Id: face_display.c,v 1.15 1994/02/14 04:18:53 liebman Exp $"; #endif #include "faces.h" /* * The list of displayed faces. */ Face *TheFaceList; Face *TheFaceListTail; /* * Count of faces displayed. */ static int TheFaceCount; /* * This is the nomail widget. */ Widget NoMailWidget; static void FaceMakeWidget(face) Face* face; { if (face->pixmap != None) { face->widget = XtVaCreateWidget(face->label, labelWidgetClass, TheFrame, XtNbitmap, face->pixmap, NULL); } else { face->widget = XtVaCreateWidget(face->label, labelWidgetClass, TheFrame, NULL); } XtRealizeWidget(face->widget); XtManageChild(face->widget); } static void FaceDestroyWidget(face) Face* face; { /* * If there is a widget here then destroy it. */ if (face->widget != NULL) { XtUnmanageChild(face->widget); XtDestroyWidget(face->widget); face->widget = NULL; } } static void FaceItemClear(face) Face* face; { FaceItem* fi; FaceItem* next; for(fi = face->items; fi != NULL; fi = next) { next = fi->next; XtFree((char*)fi); } face->items = NULL; } static void FaceItemAdd(face, item) Face* face; MailItem* item; { FaceItem* fi = XtNew(FaceItem); fi->item = item; fi->next = face->items; face->items = fi; } /* * Allocate a face entry. */ static Face * FaceCreate(item) MailItem* item; { Face *face; face = (Face*) XtCalloc(1, sizeof(Face)); face->pixmap = None; face->shape = None; face->label = XtNewString(item->label); /* * Install and ref image. */ face->image = item->image; FaceImageRef(face->image); FaceItemAdd(face, item); /* * Put the new image on the list. */ if (TheFaceList == NULL) { TheFaceList = face; } else { face->next = NULL; face->prev = TheFaceListTail; face->prev->next = face; } TheFaceListTail = face; /* * Bump list count (count of times image is in list.) */ FaceImageCount(face->image); if (!TheFacesResources.keep_order) { /* * Construct the widget. */ FaceMakeWidget(face); if (TheFaceCount == 0) { XtUnmanageChild(NoMailWidget); } } /* * Bump the face count. */ TheFaceCount += 1; return (face); } /* * Free a face structure. */ static void FaceFree(face) Face *face; { /* * The previous face is now previous to the next face. */ if (face->next) { face->next->prev = face->prev; } /* * The next face is now next from the previous face. */ if (face->prev) { face->prev->next = face->next; } /* * If this was the first face then the next face is * first. */ if (face == TheFaceList) { TheFaceList = face->next; } /* * If this was the last face then the prev face is * last. */ if (face == TheFaceListTail) { TheFaceListTail = face->prev; } /* * Wipe out old links. */ face->next = NULL; face->prev = NULL; /* * Decrement the face count. */ --TheFaceCount; if (TheFaceCount == 0) { XtManageChild(NoMailWidget); } FaceItemClear(face); FaceDestroyWidget(face); /* * Free any image. Note that FaceImageFree() will decrement the * refs count. */ FaceImageDecount(face->image); FaceImageFree(face->image); /* * Free up any annotation. */ FaceAnnotateFree(face); XtFree(face->label); /* * Now free the face. */ XtFree((void *)face); } /* * Add a new face image to the display list. */ Face* FaceDisplay(item) MailItem* item; { Face *face; /* * Find face in list. */ for (face = TheFaceList; face != NULL; face = face->next) { /* * Does the labels match? */ if (strcmp(face->label, item->label) == 0) { /* * Yep, if we are not compressing faces and this one is * already used then keep looking! */ if (!TheFacesResources.compress_images && (face->count > 0)) { continue; } break; } } if (face == NULL) { face = FaceCreate(item); } else { FaceItemAdd(face, item); } face->count += 1; return face; } /* * Clear the count on all faces. */ void FaceClear() { Face *face; if (TheFacesResources.keep_order) { XtManageChild(NoMailWidget); } for (face = TheFaceList; face != NULL; face = face->next) { face->last_count = face->count; face->count = 0; FaceItemClear(face); if (TheFacesResources.keep_order) { FaceDestroyWidget(face); } } } /* * Weed out any faces with zero counts. This also re-annotates faces and * creates widgets if keep_order is set. */ void FaceClean() { Face *face; Face *next_face; for (face = TheFaceList; face != NULL; face = next_face) { next_face = face->next; /* * Get rid of any unused faces. */ if (face->count == 0) { FaceFree(face); continue; } /* * If we need to preserve the order then we must re-create the widget. */ if (TheFacesResources.keep_order) { FaceAnnotate(face); FaceMakeWidget(face); XtUnmanageChild(NoMailWidget); } /* * If the annotations were updated then change the image. */ if (FaceAnnotate(face)) { XtVaSetValues(face->widget, XtNbitmap, face->pixmap, NULL); } } } /* * Count active faces. */ int FaceCount() { Face *face; for (face = TheFaceList; face != NULL; face = face->next ) { if ( face->count != face->last_count && face->count ) { return( True ); } } return( False ); } /* * Initialize the faces display. */ void FaceDisplayInit() { Pixmap pixmap = None; MailItem item; if (FaceImageLoad(TheFacesResources.no_mail_image, &item, NULL)) { NoMailImage = item.image; pixmap = FaceImagePixmap(NoMailImage); } #ifdef SOUND if ((TheFacesResources.no_mail_sound != NULL) && FaceSoundLoad(TheFacesResources.no_mail_sound, &item, NULL)) { NoMailSound = item.sound; } else { NoMailSound = NULL; } #endif /* SOUND */ /* * Create the nomail widget. */ if (pixmap != None) { NoMailWidget = XtVaCreateManagedWidget("nomail", labelWidgetClass, TheFrame, XtNbitmap, pixmap, NULL); } else { NoMailWidget = XtVaCreateManagedWidget("nomail", labelWidgetClass, TheFrame, NULL); } } xfaces-3.3/face_image.c 444 227 12 24765 5540460220 13725 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 13 17:03:59 1994 * Update Count : 139 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Sat Feb 12 22:51:24 1994 #138 (Chris Liebman) * Removed the labelBindings. (the general bindings can now specify the * labels. * * 31-Jan-1994 Chris Liebman * Last Modified: Sat Jan 29 23:44:35 1994 #133 (Chris Liebman) * *Major* changes to support new searching configuration. * * 24-Jan-1994 Chris Liebman * Last Modified: Sun Jan 23 18:55:48 1994 #64 (Chris Liebman) * Added path support and added X-Face header support. * * 14-Jan-1994 Chris Liebman * Last Modified: Tue Jan 11 14:19:02 1994 #1 (Chris Liebman) * added #if to use XtDatabase() for versions of Xt less than 5 * * PURPOSE * Handle images in an image independent way. */ #ifndef lint static char *RCSid = "$Id: face_image.c,v 1.12 1994/02/23 13:17:02 liebman Exp $"; #endif #include "faces.h" #include "face_image.h" #include "face_search.h" #include /* * This is the master list of supported image types. */ static FaceImageType* AllImageTypes = NULL; /* * Look up an image type by name. */ FaceImageType* FaceImageTypeByName(name) char* name; { FaceImageType* type; for (type = AllImageTypes; type != NULL; type = type->next) { if (strcmp(name, type->name) == 0) { return type; } } return NULL; } /* * Register a new image type. */ void FaceImageTypeRegister(type) FaceImageType* type; { type->next = AllImageTypes; AllImageTypes = type; } /* * Parse a string of ':' seperated image type names into an array of * image type pointers. */ FaceImageType** FaceImageTypeListParse(str) char* str; { FaceImageType* type; char* name; int type_count = 0; int array_size = 0; FaceImageType** array = NULL; if (str == NULL) { return NULL; } array_size = 10; array = (FaceImageType**)XtMalloc(array_size * sizeof(FaceImageType*)); while((name = ParseToken(&str, ":")) != NULL) { type = FaceImageTypeByName(name); if (type == NULL) { fprintf(stderr, "FaceImageTypeListParse: bad type name: <%s>\n", name); continue; } if (type_count >= array_size) { array_size += 10; array = (FaceImageType**)XtRealloc((char*)array, array_size * sizeof(FaceImageType*)); } array[type_count++] = type; } array[type_count] = NULL; return array; } /* * Here we store a complete list of images. */ static FaceImage *TheImages = NULL; /* * Create face image data for face. */ FaceImage* FaceImageCreate(file, type, data) char* file; FaceImageType* type; void* data; { FaceImage* fi; fi = (FaceImage *)XtCalloc(1, sizeof(FaceImage)); fi->file = XtNewString(file); fi->refs = 1; fi->type = type; fi->data = data; /* * Put the new image on the list. */ fi->next = TheImages; fi->prev = NULL; if (fi->next != NULL) { fi->next->prev = fi; } TheImages = fi; return fi; } typedef struct face_image_load_info { MailItem *item; FaceImageType* type; } FaceImageLoadInfo; static int FaceImageLoadWork(file, path, info) char* file; char* path; FaceImageLoadInfo* info; { struct stat buf; void* image_data = NULL; FaceImage* fi; int length; static char* filename = NULL; static int filename_length = 0; /* * First see if we already have this image. */ for (fi = TheImages; fi != NULL; fi = fi->next) { if (strcmp(fi->file, file) == 0) { /* * Yep! */ fi->refs += 1; info->item->image = fi; return 1; } } /* * Only read if file exists and is not a directory. */ if ((stat(file, &buf) != -1) && !(buf.st_mode & S_IFDIR)) { /* * Attempt to read the file. */ image_data = info->type->read(file, info->type->data); } /* * Try the common extension if we failed. */ if (image_data == NULL) { /* * Now try common extension. */ length = strlen(file) + strlen(info->type->extension) + 1; if (filename_length < length) { filename_length = length; if (filename) { XtFree(filename); } filename = XtMalloc(filename_length); } sprintf(filename, "%s%s", file, info->type->extension); /* * Only read if file exists and is not a directory. */ if ((stat(filename, &buf) != -1) && !(buf.st_mode & S_IFDIR)) { /* * Attempt to read the file. */ image_data = info->type->read(filename, info->type->data); } } /* * If we still do not have it then fail. */ if (image_data == NULL) { return 0; } /* * Ok, create a face image struct. */ fi = FaceImageCreate(file, info->type, image_data); info->item->image = fi; return 1; } int FaceImageLoad(file, item, data) char* file; MailItem* item; FaceSearchData* data; { int type; FaceImageType** types = TheFacesResources.image_types; int found = 0; FaceImageLoadInfo info; char** paths = TheFacesResources.image_paths; if (data != NULL) { /* * Use the image types in teh search data. */ if (data->itypes != NULL) { types = data->itypes; } /* * Fixup paths. */ if (data->paths != NULL) { paths = data->paths; } } /* * No image types? */ if (types == NULL) { fprintf(stderr, "FaceImageLoad: no image types!\n"); return 0; } info.item = item; for(type = 0; types[type] != NULL; ++type) { info.type = types[type]; /* * enumerate thru paths if needed. */ if ((*file != '/') && strncmp(file, "./", 2) && strncmp(file, "../", 3)) { found = PathEnumerate(file, paths, FaceImageLoadWork, &info); } else { found = FaceImageLoadWork(file, ".", &info); } if (found) { break; } } return found; } /* * Free an image. */ void FaceImageFree(fi) FaceImage *fi; { if (!fi) { return; } /* * First remove one reference. If there are still more refs just * return. */ fi->refs -= 1; if (fi->refs != 0) { return; } /* * The previous image is now previous to the next image. */ if (fi->next != NULL) { fi->next->prev = fi->prev; } /* * The next face is now next from the previous face. */ if (fi->prev != NULL) { fi->prev->next = fi->next; } /* * If this was the first image then the next image is * first. */ if (fi == TheImages) { TheImages = fi->next; } /* * Ok, free the name. */ XtFree(fi->file); /* * Free any label. */ XtFree(fi->label); /* * Free the image data. */ if (fi->type != NULL && fi->type->free != NULL) { fi->type->free(fi->data, fi->type->data); } /* * Free the struct. */ XtFree((void *)fi); } /* * Retrieve the image pixmap. */ Pixmap FaceImagePixmap(fi) FaceImage *fi; { Pixmap pixmap = None; if (fi != NULL && fi->type != NULL && fi->type->pixmap != NULL) { pixmap = fi->type->pixmap(fi->data, fi->type->data); } return(pixmap); } /* * Retrieve the image shape mask. */ Pixmap FaceImageShape(fi) FaceImage *fi; { Pixmap shape = None; if (fi != NULL && fi->type != NULL && fi->type->shape != NULL) { shape = fi->type->shape(fi->data, fi->type->data); } return(shape); } /* * Add a label to an image, if there is no image then create one. */ void FaceImageLabelCreate(item) MailItem* item; { FaceImage* fi; char *label; label = XtMalloc(strlen(item->user) + strlen(item->host) + 2); sprintf(label, "%s@%s", item->user, item->host); /* * Ok, create a face image struct. */ if (item->image == NULL) { /* * First see if we already have this image/label. */ for (fi = TheImages; fi != NULL; fi = fi->next) { if (strcmp(fi->file, label) == 0) { /* * Yep! */ XtFree(label); fi->refs += 1; item->image = fi; return; } } item->image = FaceImageCreate(label, NULL, NULL); } /* * Add the label. */ item->image->label = label; } String StringConcat(s1, s2) String s1; String s2; { String s; s = XtMalloc(strlen(s1) + strlen(s2) + 1); sprintf(s, "%s%s", s1, s2); return(s); } void FaceImageRef(fi) FaceImage* fi; { if (fi) { fi->refs += 1; } } void FaceImageCount(fi) FaceImage* fi; { if (fi) { fi->list_count += 1; } } void FaceImageDecount(fi) FaceImage* fi; { if (fi) { fi->list_count -= 1; } } String FaceImageLabelGet(fi) FaceImage* fi; { if (!fi) { return "NoLabel"; } return fi->label; } /* * Find an image for the given mail item. */ void FaceImageFind(item) MailItem* item; { FaceSearch(item, TheFacesResources.image_search); FaceImageLabelCreate(item); } xfaces-3.3/face_image_xbm.c 444 227 12 15030 5540460221 14555 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 20 11:54:38 1994 * Update Count : 13 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Mon Jan 31 22:46:53 1994 #9 (Chris Liebman) * Automaticly make the bitmap deeper if possible. * * 31-Jan-1994 Chris Liebman * Last Modified: Thu Jan 27 14:35:24 1994 #8 (Chris Liebman) * Added new init function/sequence. * * PURPOSE * Handle xbm images. */ #ifndef lint static char *RCSid = "$Id: face_image_xbm.c,v 1.7 1994/02/23 13:17:02 liebman Exp $"; #endif #include "faces.h" #include "face_image.h" typedef struct face_image_xbm { Pixmap pixmap; Pixmap shape; } FaceImageXbm; typedef struct face_xbm_resources FaceXbmResources; struct face_xbm_resources { Pixel fg; Pixel bg; }; #define offset(field) XtOffset(FaceXbmResources*, field) static XtResource FaceXbmResourcesList[] = { { "foreground", "Foreground", XtRPixel, sizeof(Pixel), offset(fg), XtRString, XtDefaultForeground }, { "background", "Background", XtRPixel, sizeof(Pixel), offset(bg), XtRString, XtDefaultBackground } }; static Display *display; static Window root; static GC gc; static FaceXbmResources TheXbmResources; static int depth; #define XBM_EXT ".xbm" #define XBM_SHAPE_EXT ".xbm-shape" void FaceImageColorize(pixmap, width, height) Pixmap* pixmap; int width; int height; { /* * Make the image deeper than one if it looks possible. */ if (depth > 1) { Pixmap color; color = XCreatePixmap(display, root, width, height, depth); XCopyPlane(display, *pixmap, color, gc, 0, 0, width, height, 0, 0, 1); XFreePixmap(display, *pixmap); *pixmap = color; } } /* * Read an xbm file. */ void * FaceImageXbmRead(file, type_data) String file; void* type_data; { Pixmap pixmap; int width; int height; int depth; FaceImageXbm *fib; if (XReadBitmapFile(display, root, file, &width, &height, &pixmap, NULL, NULL) != BitmapSuccess) { return(NULL); } FaceImageColorize(&pixmap, width, height); fib = (FaceImageXbm *)XtCalloc(1, sizeof(FaceImageXbm)); fib->pixmap = pixmap; fib->shape = None; return((void *)fib); } #ifdef SHAPE /* * Read a shaped xbm file. */ void * FaceImageShapedXbmRead(file, type_data) String file; void* type_data; { Pixmap pixmap; Pixmap shape; int width; int height; String filename; FaceImageXbm *fib; if (TheFacesResources.use_shape != True) { return(NULL); } if (XReadBitmapFile(XtDisplay(TheFrame), DefaultRootWindow(XtDisplay(TheFrame)), file, &width, &height, &pixmap, NULL, NULL) != BitmapSuccess) { return(NULL); } filename = StringConcat(file, "-mask"); if (XReadBitmapFile(XtDisplay(TheFrame), DefaultRootWindow(XtDisplay(TheFrame)), filename, &width, &height, &shape, NULL, NULL) != BitmapSuccess) { XFreePixmap(XtDisplay(TheFrame), pixmap); XtFree(filename); return(NULL); } XtFree(filename); fib = (FaceImageXbm *)XtCalloc(1, sizeof(FaceImageXbm)); fib->pixmap = pixmap; fib->shape = shape; return((void *)fib); } #endif /* * Free an xbm file. */ void FaceImageXbmFree(data, type_data) void *data; void* type_data; { FaceImageXbm *fib = data; if (fib->pixmap != None) { XFreePixmap(XtDisplay(TheFrame), fib->pixmap); } if (fib->shape != None) { XFreePixmap(XtDisplay(TheFrame), fib->shape); } XtFree((void *)fib); } /* * Return pixmap for xbm file. */ Pixmap FaceImageXbmPixmap(data, type_data) void *data; void* type_data; { FaceImageXbm *fib = data; return(fib->pixmap); } /* * Return shape for xbm file. */ Pixmap FaceImageXbmShape(data, type_data) void *data; void* type_data; { FaceImageXbm *fib = data; return(fib->shape); } static FaceImageType FaceImageTypeXbm = { "xbm", FaceImageXbmRead, FaceImageXbmFree, FaceImageXbmPixmap, FaceImageXbmShape, ".xbm", NULL, NULL }; #ifdef SHAPE static FaceImageType FaceImageTypeShapedXbm = { "xbm-shape", FaceImageShapedXbmRead, FaceImageXbmFree, FaceImageXbmPixmap, FaceImageXbmShape, "-shape.xbm", NULL, NULL }; #endif void FaceImageXbmInit() { unsigned int mask; XGCValues values; FaceImageTypeRegister(&FaceImageTypeXbm); #ifdef SHAPE FaceImageTypeRegister(&FaceImageTypeShapedXbm); #endif display = XtDisplay(TheTopLevel); root = DefaultRootWindow(display); XtVaGetValues(TheTopLevel, XtNdepth, &depth, NULL); XtGetSubresources(TheTopLevel, &TheXbmResources, "xbm", "Xbm", FaceXbmResourcesList, XtNumber(FaceXbmResourcesList), NULL, 0); mask = (GCForeground | GCBackground | GCFunction | GCGraphicsExposures | GCFillStyle); values.foreground = TheXbmResources.fg; values.background = TheXbmResources.bg; values.function = GXcopy; values.fill_style = FillSolid; values.graphics_exposures = False; gc = XCreateGC(display, root, mask, &values); } xfaces-3.3/face_search.c 444 227 12 12623 5540460221 14077 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Thu Jan 27 09:53:07 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 13 17:07:36 1994 * Update Count : 65 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Sat Feb 12 22:04:13 1994 #64 (Chris Liebman) * Added FormatCommand support. * * PURPOSE * Handle searching for images/sounds. */ #ifndef lint static char *RCSid = "$Id: face_search.c,v 1.5 1994/02/13 22:33:30 liebman Exp $"; #endif #include "faces.h" #include "face_search.h" /* * This is the master list of supported search types. */ static FaceSearchType* AllSearchTypes = NULL; /* * Look up an search type by name. */ FaceSearchType* FaceSearchTypeByName(name) char* name; { FaceSearchType* type; for (type = AllSearchTypes; type != NULL; type = type->next) { if (strcmp(name, type->name) == 0) { return type; } } return NULL; } /* * Register a new search type. */ void FaceSearchTypeRegister(type) FaceSearchType* type; { type->next = AllSearchTypes; AllSearchTypes = type; } /* * Use the search data and search for something. */ int FaceSearch(item, search_list) MailItem* item; FaceSearchData* search_list; { FaceSearchData* data; #ifdef SEARCH_DEBUG fprintf(stderr, "FaceSearch failed.\n"); #endif /* * Foreach search specifier we look for each type with each path. */ for(data = search_list; data != NULL; data = data->next) { #ifdef SEARCH_DEBUG fprintf(stderr, "Attempting search type: <%s>\n", data->search->name); #endif if (data->search->search(item, data)) { #ifdef SEARCH_DEBUG fprintf(stderr, "Succeded with search type: <%s>\n", data->search->name); #endif return 1; } } #ifdef SEARCH_DEBUG fprintf(stderr, "FaceSearch failed.\n"); #endif return 0; } /* * Load a sound/image */ int FaceSearchLoad(name, item, data) char* name; MailItem* item; FaceSearchData* data; { int ret = 0; switch(data->format) { case FormatImage: ret = FaceImageLoad(name, item, data); break; #ifdef SOUND case FormatAudio: ret = FaceSoundLoad(name, item, data); break; #endif case FormatCommand: ret = FaceCommandLoad(name, item, data); break; default: fprintf(stderr, "FaceSearchLoad: unknown format flag!\n"); ret = 0; break; } return ret; } /* * Parse the search bindings. */ FaceSearchData* FaceSearchParse(str, format) char* str; FaceFormat format; { FaceSearchData* head = NULL; FaceSearchData* tail = NULL; FaceSearchData* data; FaceSearchType* search = NULL; FaceImageType** itypes = NULL; char** paths = NULL; char* line; char* value; if (str == NULL) { return(NULL); } while((line = ParseToken(&str, "\n")) != NULL) { /* * Skip past any leading whitespace. */ line = SkipChars(line, "\t \n"); /* * Get name of search type. */ value = ParseToken(&line, " \t\n"); /* * if there was no search name then skip this line. */ if ((value == NULL) || ((search = FaceSearchTypeByName(value)) == NULL)) { if (value != NULL) { fprintf(stderr, "FaceSearchParse: bad search type: <%s>\n", value); } continue; } /* * Get the list of types. */ value = ParseToken(&line, " \t\n"); if (value != NULL) { if (format == FormatImage) { itypes = FaceImageTypeListParse(value); } else { /* * We ignore the type list for sounds. */ } } /* * Get the path list. */ value = ParseToken(&line, " \t\n"); if (value != NULL) { paths = PathParse(value); } /* * Construct a new search data. */ data = XtNew(FaceSearchData); data->format = format; data->search = search; if (format == FormatImage) { data->stypes = NULL; data->itypes = itypes; } else { data->itypes = NULL; data->stypes = NULL; } data->paths = paths; data->next = NULL; /* * Construct list. */ if (!head) { head = data; tail = data; } else { tail->next = data; tail = data; } } return(head); } xfaces-3.3/face_search_resource.c 444 227 12 12620 5540460222 16004 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * * * Author : Chris Liebman * Created On : Sat Jan 29 15:17:46 1994 * Last Modified By: Chris Liebman * Last Modified On: Sat Feb 19 22:55:49 1994 * Update Count : 60 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Sat Feb 12 23:28:52 1994 #42 (Chris Liebman) * Added FormatCommand support. * * * PURPOSE * Resource search. */ #ifndef lint static char *RCSid = "$Id: face_search_resource.c,v 1.4 1994/03/07 20:26:32 liebman Exp $"; #endif #include "faces.h" #include "face_search.h" static int FaceSearchResourceWork(fullname, fullclass, item, data) char* fullname; char* fullclass; MailItem* item; FaceSearchData* data; { int ret = 0; XrmDatabase db; String type = NULL; XrmValue value; #ifdef RESOURCE_DEBUG fprintf(stderr, "FaceSearchResourceWork: looking for: <%s>/<%s>.\n", fullname, fullclass); #endif #if (XtSpecificationRelease > 4) db = XtScreenDatabase(XtScreen(TheTopLevel)); #else db = XtDatabase(XtDisplay(TheTopLevel)); #endif if (XrmGetResource(db, fullname, fullclass, &type, &value) && (strcmp(type, XtRString) == 0)) { ret = FaceSearchLoad(value.addr, item, data); } return ret; } static int FaceSearchResource(item, data) MailItem* item; FaceSearchData* data; { char* fullname; char* fullclass; char* appname = XtName(TheTopLevel); char* typename; char* typeclass; int reallen = 0; switch(data->format) { case FormatImage: typename = "image"; typeclass = "Image"; break; case FormatAudio: typename = "sound"; typeclass = "Sound"; break; case FormatCommand: typename = "command"; typeclass = "Command"; break; default: return 0; } /* * Make a buffer for resource name construction. */ if (item->realhost != NULL) { reallen = strlen(item->realhost); } fullname = XtMalloc(strlen(appname) + strlen(typename) + strlen(item->user) + strlen(item->host) + reallen + 9); fullclass = XtMalloc(strlen(XFACES_CLASS) + strlen(typeclass) + strlen("User@Host") + 9); /* * Build a resource name for this sucker. */ sprintf(fullname, "%s.%s.%s@%s", appname, typename, item->user, item->host); sprintf(fullclass, "%s.%s.User@Host", XFACES_CLASS, typeclass); /* * Try to load the thing in. */ if (FaceSearchResourceWork(fullname, fullclass, item, data)) { XtFree(fullname); XtFree(fullclass); return 1; } /* * try the real (looked up) hostname. */ if (item->realhost != NULL) { sprintf(fullname, "%s.%s.%s@%s", appname, typename, item->user, item->realhost); /* * Try to load the thing in. */ if (FaceSearchResourceWork(fullname, fullclass, item, data)) { XtFree(fullname); XtFree(fullclass); return 1; } } /* * Oh well. Lets try for just the user name. */ sprintf(fullname, "%s.%s.%s", appname, typename, item->user); sprintf(fullclass, "%s.%s.User", XFACES_CLASS, typeclass); if (FaceSearchResourceWork(fullname, fullclass, item, data)) { XtFree(fullname); XtFree(fullclass); return 1; } /* * Oh well. Lets try for just the host name. */ sprintf(fullname, "%s.%s.%s", appname, typename, item->host); sprintf(fullclass, "%s.%s.Host", XFACES_CLASS, typeclass); if (FaceSearchResourceWork(fullname, fullclass, item, data)) { XtFree(fullname); XtFree(fullclass); return 1; } /* * Oh well. Lets try for just the real (looked up) host name. */ if (item->realhost != NULL) { sprintf(fullname, "%s.%s.%s", appname, typename, item->realhost); if (FaceSearchResourceWork(fullname, fullclass, item, data)) { XtFree(fullname); XtFree(fullclass); return 1; } } XtFree(fullname); XtFree(fullclass); /* * Oh well... */ return(0); } static FaceSearchType resource = { "resource", FaceSearchResource, NULL, NULL, }; void FaceSearchResourceInit() { FaceSearchTypeRegister(&resource); } xfaces-3.3/face_search_binding.c 444 227 12 7666 5540460221 15564 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * * * Author : Chris Liebman * Created On : Sat Jan 29 15:17:46 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Mar 6 22:32:09 1994 * Update Count : 34 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Sat Feb 12 23:08:32 1994 #31 (Chris Liebman) * Use label from bindings it available. Also added command before and * after bindings. * * PURPOSE * Binding search. */ #ifndef lint static char *RCSid = "$Id: face_search_binding.c,v 1.3 1994/03/07 04:46:30 liebman Exp $"; #endif #include "faces.h" #include "face_search.h" typedef enum face_binding_type { BeforeBinding, AfterBinding } FaceBindingType; static int FaceSearchBinding(item, data) MailItem* item; FaceSearchData* data; { FaceBinding* binding; int ret = 0; binding = *(FaceBinding**)(data->search->data); /* * Check mail headers agains bindings. */ binding = FaceBindingCheck(item->headers, binding); /* * If no binding matched then fail. */ if (binding == NULL) { return 0; } /* * Now try to get an image/sound. */ ret = FaceSearchLoad(binding->file, item, data); /* * If we found something and it was an image and the binding specified * a label then set the item label. And force annotation to use the * label in the named position. */ if (ret && (data->format == FormatImage) && (binding->label != NULL)) { item->label = XtNewString(binding->label); item->use_label = binding->anno; } return ret; } static FaceSearchType beforeImage = { "beforeImage", FaceSearchBinding, &TheFacesResources.before_image_bindings, NULL, }; static FaceSearchType afterImage = { "afterImage", FaceSearchBinding, &TheFacesResources.after_image_bindings, NULL, }; static FaceSearchType beforeSound = { "beforeSound", FaceSearchBinding, &TheFacesResources.before_sound_bindings, NULL, }; static FaceSearchType afterSound = { "afterSound", FaceSearchBinding, &TheFacesResources.after_sound_bindings, NULL, }; static FaceSearchType beforeCommand = { "beforeCommand", FaceSearchBinding, &TheFacesResources.before_command_bindings, NULL, }; static FaceSearchType afterCommand = { "afterCommand", FaceSearchBinding, &TheFacesResources.after_command_bindings, NULL, }; void FaceSearchBindingInit() { FaceSearchTypeRegister(&beforeImage); FaceSearchTypeRegister(&afterImage); FaceSearchTypeRegister(&beforeSound); FaceSearchTypeRegister(&afterSound); FaceSearchTypeRegister(&beforeCommand); FaceSearchTypeRegister(&afterCommand); } xfaces-3.3/face_search_facedb.c 444 227 12 32721 5540460222 15365 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * * * Author : Chris Liebman * Created On : Sun Jan 30 00:08:36 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Mar 7 16:30:27 1994 * Update Count : 47 * Status : Released * * HISTORY * * PURPOSE * Disk based search for faces. */ #ifndef lint static char *RCSid = "$Id: face_search_facedb.c,v 1.5 1994/03/08 02:17:40 liebman Exp $"; #endif #include "faces.h" #include "face_search.h" typedef struct facedb_map FacedbMap; typedef struct host_entry HostEntry; typedef struct entry Entry; struct facedb_map { char* name; Entry* hosts; HostEntry* users; FacedbMap* next; }; /* * This is the top if the users list. Each host name has a list of * aliases. */ struct host_entry { char* name; Entry* users; HostEntry* next; }; struct entry { char* from; char* to; Entry* next; }; static FacedbMap* maps = NULL; static char* buffer = NULL; static int buffer_size = 0; static int FacedbReadLine(file) FILE* file; { int len; int c; if (buffer == NULL) { buffer_size = 1024; buffer = XtMalloc(buffer_size); } len = 0; buffer[len] = '\0'; while((c = fgetc(file)) != EOF && c != '\n') { if (len >= (buffer_size - 1)) { buffer_size += 1024; buffer = XtRealloc(buffer, buffer_size); } buffer[len++] = c; buffer[len] = '\0'; } /* * We only return 0 at eof. */ if (len == 0 && c != EOF) { buffer[len++] = '\n'; buffer[len] = '\0'; } return len; } static Entry* HostMapLoad(name) char* name; { char* filename; FILE* file; char** data; char* from; char* to; Entry* head = NULL; Entry* tail = NULL; Entry* e; filename = XtMalloc(strlen(name) + strlen(TheFacesResources.machine) + 2); sprintf(filename, "%s/%s", name, TheFacesResources.machine); file = fopen(filename, "r"); XtFree(filename); if (file == NULL) { return NULL; } while(FacedbReadLine(file)) { /* * Skip comment chars. */ if (*buffer == '#') { continue; } data = StringParse(buffer, "="); /* * Must have two parts and two parts only. */ if (data[0] == NULL || data[1] == NULL || data[2] != NULL) { continue; } /* * Strip any whitespace from both values as they are saved. */ from = ParseToken(&(data[0]), " \t\n"); to = ParseToken(&(data[1]), " \t\n"); XtFree((char *) data); if (from == NULL || *from == '\0' || to == NULL || *to == '\0') { continue; } e = (Entry*) XtMalloc(sizeof(Entry)); e->from = XtNewString(from); e->to = XtNewString(to); e->next = NULL; if (!head) { head = e; tail = e; } else { tail->next = e; tail = e; } } return head; } static HostEntry* UserMapLoad(name) char* name; { char* filename; FILE* file; char** data; char** data2; char* host; char* from; char* to; HostEntry* head = NULL; Entry* e; HostEntry* h; filename = XtMalloc(strlen(name) + strlen(TheFacesResources.people) + 2); sprintf(filename, "%s/%s", name, TheFacesResources.people); file = fopen(filename, "r"); XtFree(filename); if (file == NULL) { return NULL; } while(FacedbReadLine(file)) { /* * Skip comment chars. */ if (*buffer == '#') { continue; } data = StringParse(buffer, "="); /* * Must have two parts and two parts only. */ if (data[0] == NULL || data[1] == NULL || data[2] != NULL) { XtFree((char*)data); continue; } /* * Break up the first part into two parts. */ data2 = StringParse(data[0], "/"); /* * Must have two parts and two parts only. */ if (data2[0] == NULL || data2[1] == NULL || data2[2] != NULL) { XtFree((char*)data2); XtFree((char*)data); continue; } /* * Strip any whitespace from values as they are saved. */ host = ParseToken(&(data2[0]), " \t\n"); from = ParseToken(&(data2[1]), " \t\n"); to = ParseToken(&(data[1]), " \t\n"); XtFree((char*)data2); XtFree((char *) data); if (host == NULL || *host == '\0' || from == NULL || *from == '\0' || to == NULL || *to == '\0') { continue; } /* * Locate host entry in user list, create if needed. */ for(h = head; h; h = h->next) { if (strcmp(h->name, host) == 0) { break; } } if (h == NULL) { h = (HostEntry*) XtMalloc(sizeof(HostEntry)); h->name = XtNewString(host); h->users = NULL; h->next = head; head = h; } e = (Entry*) XtMalloc(sizeof(Entry)); e->from = XtNewString(from); e->to = XtNewString(to); e->next = h->users; h->users = e; } return head; } static FacedbMap* MapByName(name) char* name; { FacedbMap* map; for (map = maps; map != NULL; map = map->next) { if (strcmp(name, map->name) == 0) { return map; } } /* * No map yet. Create one. */ map = (FacedbMap*) XtMalloc(sizeof(FacedbMap)); map->name = XtNewString(name); map->hosts = HostMapLoad(name); map->users = UserMapLoad(name); map->next = maps; maps = map; return map; } static char * LookupHost(name, realname, map) char* name; char* realname; FacedbMap* map; { Entry* host; for(host = map->hosts; host; host = host->next) { if (strcmp(name, host->from) == 0) { return host->to; } } if (realname != NULL) { for(host = map->hosts; host; host = host->next) { if (strcmp(realname, host->from) == 0) { return host->to; } } return realname; } return name; } static char * LookupUser(username, hostname, map) char* username; char* hostname; FacedbMap* map; { Entry* user; HostEntry* host; for(host = map->users; host; host = host->next) { if (strcmp(hostname, host->name) == 0) { break; } } if (host != NULL) { for (user = host->users; user; user = user->next) { if (strcmp(username, user->from) == 0) { return user->to; } } } return username; } typedef struct facedb_info { MailItem* item; FaceSearchData* data; char* user; char** host; int parts; } FacedbInfo; static void FaceSearchFacedbMakeName(file, info, parts, try) char* file; FacedbInfo* info; int parts; char* try; { char* src; char* dst; int i; src = file; /* * Copy the path. */ dst = try; while(*src) { *dst++ = *src++; } /* * Now copy each host part. */ for(i = info->parts-1; i > (info->parts - 1) - parts; --i) { src = info->host[i]; while(*src) { *dst++ = *src++; } *dst++ = '/'; } src = info->user; while(*src) { *dst++ = *src++; } *dst = '\0'; } static int FaceSearchFacedbWork(file, path, info) char* file; char* path; FacedbInfo* info; { static char* buffer1 = NULL; static int buffer1_size = 0; int i; int len; char* tail; char* hostname; char* hostdata; char** host; int parts; char* username; FacedbMap* map; if (buffer1 == NULL) { buffer1_size = 1024; buffer1 = XtMalloc(buffer1_size); } if (*file == '\0') { file = "./"; } map = MapByName(path); hostname = LookupHost(info->item->host, info->item->realhost, map); username = LookupUser(info->item->user, hostname, map); /* * Break the host name up into parts. */ hostdata = XtNewString(hostname); host = StringParse(hostdata, "."); /* * Count the parts. */ for(parts = 0; host[parts] != NULL; ++parts); info->user = username; info->host = host; info->parts = parts; /* * Make sure that the buffer is big enough. */ len = strlen(file) + strlen(hostname) + strlen(username) + 50; if (len >= buffer1_size) { buffer1_size += len; buffer1 = XtRealloc(buffer1, buffer1_size); } for( i = parts; i > 0; --i) { /* * Compute the path. */ FaceSearchFacedbMakeName(file, info, i, buffer1); /* * Try to load this guy. */ #ifdef FACEDB_DEBUG fprintf(stderr, "facedb try: <%s>\n", buffer1); #endif if (FaceSearchLoad(buffer1, info->item, info->data)) { XtFree((char*) host); XtFree(hostdata); return 1; } /* * try adding "/face" and see what we find. */ for(tail = buffer1; *tail; ++tail); strcpy(tail, "/face"); #ifdef FACEDB_DEBUG fprintf(stderr, "facedb try: <%s>\n", buffer1); #endif if (FaceSearchLoad(buffer1, info->item, info->data)) { XtFree((char*) host); XtFree(hostdata); return 1; } #if 0 /* * Finally if we are looking for an image try "/48x48x1". */ if (info->data->format == FormatImage) { strcpy(tail, "/48x48x1"); if (FaceSearchLoad(buffer1, info->item, info->data)) { XtFree((char*) host); XtFree(hostdata); return 1; } } #endif } /* * try for user in the MISC directory. */ sprintf(buffer1, "%sMISC/%s", file, username); #ifdef FACEDB_DEBUG fprintf(stderr, "facedb try: <%s>\n", buffer1); #endif if (FaceSearchLoad(buffer1, info->item, info->data)) { XtFree((char*) host); XtFree(hostdata); return 1; } sprintf(buffer1, "%sMISC/%s/face", file, username); #ifdef FACEDB_DEBUG fprintf(stderr, "facedb try: <%s>\n", buffer1); #endif if (FaceSearchLoad(buffer1, info->item, info->data)) { XtFree((char*) host); XtFree(hostdata); return 1; } /* * Now attempt the same thing using unknown for the user. */ info->user = "unknown"; for( i = parts; i > 0; --i) { /* * Compute the path. */ FaceSearchFacedbMakeName(file, info, i, buffer1); /* * Try to load this guy. */ #ifdef FACEDB_DEBUG fprintf(stderr, "facedb try: <%s>\n", buffer1); #endif if (FaceSearchLoad(buffer1, info->item, info->data)) { XtFree((char*) host); XtFree(hostdata); if (info->data->format == FormatImage) { info->item->unknown = 1; } return 1; } /* * try adding "/face" and see what we find. */ for(tail = buffer1; *tail; ++tail); strcpy(tail, "/face"); #ifdef FACEDB_DEBUG fprintf(stderr, "facedb try: <%s>\n", buffer1); #endif if (FaceSearchLoad(buffer1, info->item, info->data)) { XtFree((char*) host); XtFree(hostdata); if (info->data->format == FormatImage) { info->item->unknown = 1; } return 1; } #if 0 /* * Finally if we are looking for an image try "/48x48x1". */ if (info->data->format == FormatImage) { strcpy(tail, "/48x48x1"); if (FaceSearchLoad(buffer1, info->item, info->data)) { XtFree((char*) host); XtFree(hostdata); return 1; } } #endif } XtFree((char*) host); XtFree(hostdata); /* * One last try. The MISC directory. Look for "unknown" */ sprintf(buffer1, "%sMISC/unknown", file); #ifdef FACEDB_DEBUG fprintf(stderr, "facedb try: <%s>\n", buffer1); #endif if (FaceSearchLoad(buffer1, info->item, info->data)) { if (info->data->format == FormatImage) { info->item->unknown = 1; } return 1; } sprintf(buffer1, "%sMISC/unknown/face", file); #ifdef FACEDB_DEBUG fprintf(stderr, "facedb try: <%s>\n", buffer1); #endif if (FaceSearchLoad(buffer1, info->item, info->data)) { if (info->data->format == FormatImage) { info->item->unknown = 1; } return 1; } return 0; } static int FaceSearchFacedb(item, data) MailItem* item; FaceSearchData* data; { char** paths = TheFacesResources.facedb_paths; int found = 0; FacedbInfo info; if ((data != NULL) && (data->paths != NULL)) { paths = data->paths; } /* * load the info struct. */ info.item = item; info.data = data; info.user = NULL; info.host = NULL; info.parts = 0; found = PathEnumerate("", paths, FaceSearchFacedbWork, &info); return found; } static FaceSearchType facedb = { "facedb", FaceSearchFacedb, NULL, NULL, }; void FaceSearchFacedbInit() { FaceSearchTypeRegister(&facedb); } xfaces-3.3/face_search_uh.c 444 227 12 6635 5540460222 14562 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * * * Author : Chris Liebman * Created On : Sat Jan 29 15:17:46 1994 * Last Modified By: Chris Liebman * Last Modified On: Sat Feb 19 21:56:14 1994 * Update Count : 49 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Sat Feb 12 23:28:52 1994 #42 (Chris Liebman) * Added FormatCommand support. * * * PURPOSE * Search path for files named user@host. */ #ifndef lint static char *RCSid = "$Id: face_search_uh.c,v 1.2 1994/03/07 20:26:45 liebman Exp $"; #endif #include "faces.h" #include "face_search.h" static int FaceSearchUserHost(item, data) MailItem* item; FaceSearchData* data; { char* name; int reallen = 0; if (item->realhost != NULL) { reallen = strlen(item->realhost); } /* * Make a buffer for UserHost name construction. */ name = XtMalloc(strlen(item->user) + strlen(item->host) + reallen + 9); /* * Build a User@Host name for this sucker. */ sprintf(name, "%s@%s", item->user, item->host); /* * Try to load the thing in. */ if (FaceSearchLoad(name, item, data)) { XtFree(name); return 1; } /* * Try the real (looked up) host if available. */ if (item->realhost != NULL) { sprintf(name, "%s@%s", item->user, item->realhost); /* * Try to load the thing in. */ if (FaceSearchLoad(name, item, data)) { XtFree(name); return 1; } } XtFree(name); /* * Oh well. Lets try for just the user name. */ if (FaceSearchLoad(item->user, item, data)) { return 1; } /* * Oh well. Lets try for just the host name. */ if (FaceSearchLoad(item->host, item, data)) { return 1; } /* * Try the real (looked up) hostname if available. */ if (item->realhost != NULL && FaceSearchLoad(item->realhost, item, data)) { return 1; } /* * Oh well... */ return(0); } static FaceSearchType UserHost = { "u@h", FaceSearchUserHost, NULL, NULL, }; void FaceSearchUserHostInit() { FaceSearchTypeRegister(&UserHost); } xfaces-3.3/mail_box.c 444 227 12 10370 5540460223 13445 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 20 14:13:33 1994 * Update Count : 21 * Status : Released * * HISTORY * * PURPOSE * Routines to parse the mail file. */ #ifndef lint static char *RCSid = "$Id: mail_box.c,v 1.2 1994/02/23 13:17:02 liebman Exp $"; #endif #include "faces.h" char* MailSeperator = NULL; int MailSeperatorLength = 0; Boolean MailSeperatorSkip = False; static Boolean MailSeperatorKnown = False; /* * There is mail and the mailbox has been changed. */ void MailBoxParse() { MailHeader* headers; MailHeader* header; int content_length; char sepbuf[MAX_MAILSEP_SIZE+1]; /* * Open the mail spool file. If we fail then we act as * though the mail box is empty. */ if (!MailFileOpen(TheFacesResources.spool_file)) { MailBoxEmpty(); return; } /* * If we do not know what the mail seperator is then try to guess. */ if (!MailSeperatorKnown) { /* * Peek at the first few chars and see what kind of mail seperator * is in use. */ MailFilePeekString(sepbuf, MAX_MAILSEP_SIZE); if (strncmp(sepbuf, MAIL_SEP1, strlen(MAIL_SEP1)) == 0) { MailSeperator = MAIL_SEP1; MailSeperatorLength = strlen(MAIL_SEP1); MailSeperatorSkip = MAIL_SEP1_SKIP; MailSeperatorKnown = True; } else if (strncmp(sepbuf, MAIL_SEP2, strlen(MAIL_SEP2)) == 0) { MailSeperator = MAIL_SEP2; MailSeperatorLength = strlen(MAIL_SEP2); MailSeperatorSkip = MAIL_SEP2_SKIP; MailSeperatorKnown = True; } else { /* * Just assume MAIL_SEP1 untill we know for sure. */ MailSeperator = MAIL_SEP1; MailSeperatorLength = strlen(MAIL_SEP1); MailSeperatorSkip = MAIL_SEP1_SKIP; } } /* * If we need to skip the seperator then skip it. */ if (MailSeperatorSkip) { MailFilePeekString(sepbuf, MailSeperatorLength); if (strcmp(sepbuf, MailSeperator) == 0) { MailFileSkipString(MailSeperatorLength); } } /* * Read each message from the mail file. */ while((headers = MailHeaderListRead()) != NULL) { content_length = -1; if (TheFacesResources.use_content_length && ((header = MailHeaderFind("Content-Length:", headers)) != NULL)) { content_length = atoi(header->value); } /* * We got a list of headers so skip the body. */ MailBodySkip(content_length); /* * If we used the content_length value then we should skip * at most one leftover blank line. (I am nor sure that this * is nessarry as my mailer users the From_ header and messages * with the content-length header had an extra blank line). */ if (TheFacesResources.use_content_length && MailFilePeekChar() == '\n') { (void) MailFileReadChar(); } /* * Create a mail item. */ MailItemCreate(headers); } MailFileClose(); return; } xfaces-3.3/mail_body.c 444 227 12 14723 5540460223 13620 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 20 14:09:37 1994 * Update Count : 53 * Status : Released * * HISTORY * * PURPOSE * Routines to handle mail message bodys. */ #ifndef lint static char *RCSid = "$Id: mail_body.c,v 1.2 1994/02/23 13:17:02 liebman Exp $"; #endif #include "faces.h" #define BUFFER_SIZE 4096 #define BUFFER_SIZE_INC 4096 static char* buffer = NULL; static int buffer_size = 0; /* * Read the mail body lines. The body ends with * a line starts with the MailSeperator. Note: This should be * configurable. */ char * MailBodyRead(content_length) int content_length; { int ch; int string_length = 0; int get_more; char* str; char sepbuf[MAX_MAILSEP_SIZE+1]; /* * If allowed, use the content length to skip the body. */ if (TheFacesResources.use_content_length && content_length >= 0) { if (content_length == 0) { return NULL; } /* * Make sure the buffer is big enough. */ if (buffer_size == 0) { buffer_size = content_length + 1; buffer = XtMalloc(buffer_size); } else if (buffer_size <= content_length) { buffer_size = content_length + 1; buffer = XtRealloc(buffer, buffer_size); } MailFileReadString(buffer, buffer_size); if (buffer[0] == '\0') { return NULL; } /* * Allocate a buffer that we can return. */ str = XtMalloc(string_length + 1); strcpy(str, buffer); return str; } /* * See if this is the start of a new message, */ MailFilePeekString(sepbuf, MailSeperatorLength); if (strcmp(sepbuf, MailSeperator) == 0) { /* * If we do not want the seperator then skip it. */ if (MailSeperatorSkip) { MailFileSkipString(MailSeperatorLength); } /* * Null message body. */ return NULL; } /* * Read the first char. Check for end of file. */ ch = MailFileReadChar(); if (ch == EOF) { return NULL; } /* * If the buffer has not beed created yet then create it. */ if (buffer_size == 0) { buffer = XtMalloc(BUFFER_SIZE); buffer_size = BUFFER_SIZE; } /* * Ok, start collecting characters. */ do { get_more = 1; /* * Collect the rest of this line. */ while((ch != '\n') && (ch != EOF)) { if (string_length >= buffer_size) { /* * Grow buffer. */ buffer = XtRealloc(buffer, buffer_size + BUFFER_SIZE_INC); buffer_size += BUFFER_SIZE_INC; } buffer[string_length++] = ch; ch = MailFileReadChar(); } if (ch == EOF) { get_more = 0; } else { /* * Ok, We have gotten to the end of a line. Peek at the start * of the next line to see if it is the seperator for the * next message. */ MailFilePeekString(sepbuf, MailSeperatorLength); if (strcmp(sepbuf, MailSeperator) == 0) { /* * If we do not want the seperator then skip it. */ if (MailSeperatorSkip) { MailFileSkipString(MailSeperatorLength); } get_more = 0; } } } while (get_more); /* * Terminate the string. */ buffer[string_length] = '\0'; /* * Allocate a buffer that we can return. */ str = XtMalloc(string_length + 1); strcpy(str, buffer); return (str); } /* * Skip the mail body lines. The body ends with * a line starts with the MailSeperator. Note: This should be * configurable. */ void MailBodySkip(content_length) int content_length; { int ch; int get_more; char sepbuf[MAX_MAILSEP_SIZE]; /* * If allowed, use the content length to skip the body. */ if (TheFacesResources.use_content_length && content_length >= 0) { if (content_length == 0) { return; } MailFileSkipString(content_length); return; } /* * See if this is the start of a new message, */ MailFilePeekString(sepbuf, MailSeperatorLength); if (strcmp(sepbuf, MailSeperator) == 0) { /* * If we do not want the seperator then skip it. */ if (MailSeperatorSkip) { MailFileSkipString(MailSeperatorLength); } /* * Null message body. */ return; } /* * Read the first char. Check for end of file. */ ch = MailFileReadChar(); if (ch == EOF) { return; } /* * Ok, start collecting characters. */ do { get_more = 1; /* * Collect the rest of this line. */ while((ch != '\n') && (ch != EOF)) { ch = MailFileReadChar(); } if (ch == EOF) { get_more = 0; } else { /* * Ok, We have gotten to the end of a line. Peek at the start * of the next line to see if it is the MailSeperator for the * next message. */ MailFilePeekString(sepbuf, MailSeperatorLength); if (strcmp(sepbuf, MailSeperator) == 0) { /* * If we do not want the seperator then skip it. */ if (MailSeperatorSkip) { MailFileSkipString(MailSeperatorLength); } get_more = 0; } } } while (get_more && (ch = MailFileReadChar()) != EOF); } xfaces-3.3/mail_check.c 444 227 12 7300 5540460223 13711 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Jan 31 23:10:42 1994 * Update Count : 3 * Status : Released * * HISTORY * 31-Jan-1994 Chris Liebman * Last Modified: Tue Jan 11 14:29:22 1994 #1 (Chris Liebman) * Modified MailCheck to remove code now in CheckMailNow(). * * PURPOSE * Check the users mailbox for new mail. */ #ifndef lint static char *RCSid = "$Id: mail_check.c,v 1.7 1994/03/12 21:18:56 liebman Exp $"; #endif #include "faces.h" #include /* * Status information about the mail file when we last * checked. */ static struct stat LastStat; /* * Check for any changes to the mail spool file. */ void MailCheck() { struct stat cur_stat; /* * First we stat the mail file to see if there is any * change. */ if (stat(TheFacesResources.spool_file, &cur_stat) == -1) { #ifdef MAILCHECK_DEBUG fprintf(stderr, "MailCheck: spoolfile non existant: %s\n", TheFacesResources.spool_file); #endif bzero((char *) &LastStat, sizeof(struct stat)); return; } #ifdef MAILCHECK_DEBUG fprintf(stderr, "MailCheck: last mtime: %d current: %d\n", LastStat.st_mtime, cur_stat.st_mtime); fprintf(stderr, "MailCheck: last ctime: %d current: %d\n", LastStat.st_ctime, cur_stat.st_ctime); fprintf(stderr, "MailCheck: last size: %d current: %d\n", LastStat.st_size, cur_stat.st_size); #endif /* * If there has been no change to the mail file then * just get out. Note that we check the ctime as well * cause the elm mailer uses utime() to set the mtime * field back to what it was when elm read it! We check the * size as an added precaution! */ #if defined(sun) && defined(SYSV) if (LastStat.st_mtim.tv_sec == cur_stat.st_mtim.tv_sec && LastStat.st_mtim.tv_nsec == cur_stat.st_mtim.tv_nsec) #else if ((LastStat.st_mtime == cur_stat.st_mtime) && (LastStat.st_ctime == cur_stat.st_ctime) && (LastStat.st_size == cur_stat.st_size)) #endif { /* * Mark all current mail items as in use! */ MailBoxUnClear(); return; } /* * Save the new stats. */ bcopy((char *) &cur_stat, (char *) &LastStat, sizeof(struct stat)); /* * Parse the mail spool file and build the mail item list and * display things. */ MailBoxParse(); return; } xfaces-3.3/mail_file.c 444 227 12 6760 5540460224 13565 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 20 13:54:23 1994 * Update Count : 48 * Status : Released * * HISTORY * * PURPOSE * Routines to handle reading of characters from the mail box file. * We need to be able to push back single chars and sometimes strings. */ #ifndef lint static char *RCSid = "$Id: mail_file.c,v 1.4 1994/02/23 13:17:02 liebman Exp $"; #endif #include "faces.h" #define BUFFER_SIZE 100 #define BUFFER_SIZE_INC 20 static char* buffer = NULL; static int buffer_size = 0; static int count; static FILE* file; int MailFileOpen(name) char *name; { file = fopen(name, "r"); if (file == NULL) { return 0; } return 1; } void MailFileClose() { (void) fclose(file); file = NULL; count = 0; } int MailFileReadChar() { int ch; if (count) { ch = buffer[--count]; ch &= 0xff; } else { ch = fgetc(file); } return ch; } int MailFileReadString(str, len) char* str; int len; { int got; int ch; for(got = 0; got < len; ++got) { ch = MailFileReadChar(); if (ch == EOF) { break; } str[got] = ch; } str[got] = '\0'; return got; } int MailFileSkipString(len) int len; { int skiped; int ch; for(skiped = 0; skiped < len; ++skiped) { ch = MailFileReadChar(); if (ch == EOF) { break; } } return skiped; } void MailFileUnReadChar(ch) int ch; { if (buffer == NULL) { buffer = XtMalloc(BUFFER_SIZE); buffer_size = BUFFER_SIZE; } if (count >= buffer_size) { buffer_size += BUFFER_SIZE_INC; buffer = XtRealloc(buffer, buffer_size); } buffer[count++] = ch; } void MailFileUnReadString(str) char* str; { int len; for (len = strlen(str); len > 0; --len) { MailFileUnReadChar(str[len - 1]); } } void MailFileClearUnRead() { count = 0; } int MailFilePeekChar() { int ch; ch = MailFileReadChar(); if (ch != EOF) { MailFileUnReadChar(ch); } return ch; } void MailFilePeekString(str, len) char* str; int len; { MailFileReadString(str, len); MailFileUnReadString(str); } xfaces-3.3/mail_header.c 444 227 12 20643 5540460224 14112 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sun Feb 20 13:01:44 1994 * Update Count : 38 * Status : Released * * HISTORY * * PURPOSE * Routines to handle mail headers. */ #ifndef lint static char *RCSid = "$Id: mail_header.c,v 1.2 1994/02/23 13:17:02 liebman Exp $"; #endif #include "faces.h" #define BUFFER_SIZE 80 #define BUFFER_SIZE_INC 80 static char* buffer = NULL; static int buffer_size = 0; /* * Read a mail header line from given file. Handle line continuations. * If the first char is a newln then there are no more headers. */ char* MailHeaderLineRead() { int ch; int string_length = 0; int get_more; char* str; /* * Look at the first char. If it is a newln then there are no more * headers and the newln is pushed back. Also return NULL if end of * file. */ ch = MailFileReadChar(); if (ch == EOF) { return NULL; } if (ch == '\n') { MailFileUnReadChar(ch); return NULL; } /* * If the buffer has not beed created yet then create it. */ if (buffer_size == 0) { buffer = XtMalloc(BUFFER_SIZE); buffer_size = BUFFER_SIZE; } /* * Ok, start collecting characters. */ do { get_more = 0; while((ch != '\n') && (ch != EOF)) { if (string_length >= buffer_size) { /* * Grow buffer. */ buffer = XtRealloc(buffer, buffer_size + BUFFER_SIZE_INC); buffer_size += BUFFER_SIZE_INC; } buffer[string_length++] = ch; ch = MailFileReadChar(); } /* * Ok, We have gotten to the end of a line. If the first character * on the next line is a tab then it is a continuation of this * line and we need to skip the tab and continue reading chars. */ if (ch != EOF) { /* * Get the next character, and if it is a TAB then we continue * the loop. */ ch = MailFileReadChar(); if ((ch == '\t') || (ch == ' ')) { get_more = 1; } else { /* * Not a line continuation, put back. */ MailFileUnReadChar(ch); } } } while (get_more); /* * Terminate the string. */ buffer[string_length] = '\0'; /* * Allocate a buffer that we can return. */ str = XtMalloc(string_length + 1); strcpy(str, buffer); return (str); } /* * Read a header line and create a header struct. */ MailHeader* MailHeaderRead() { MailHeader* header; char* line; char* p; int len; /* * First read a line. */ line = MailHeaderLineRead(); /* * No line means no more headers. */ if (!line) { return NULL; } #ifdef DEBUG fprintf(stderr, "read header: <%s>\n", line); #endif /* * Allocate the header. */ header = (MailHeader*) XtMalloc(sizeof(MailHeader)); header->name = NULL; header->value = NULL; header->line = NULL; header->next = NULL; header->prev = NULL; /* * Now locate the try to parse out the line. First skip to the: * at the end of this header name (note that we accept a ':' *or* * a ` ` as the terminator. */ for (p = line; *p && *p != ':' && *p != ' '; ++p); if (!*p) { /* * Bogus header! We failed to parse it. */ header->line = line; #ifdef DEBUG fprintf(stderr, "bogus header: <%s>\n", line); #endif return header; } ++p; /* * Allocate the name and value. */ len = p - line; header->name = XtMalloc(len + 1); strncpy(header->name, line, len); header->name[len] = '\0'; header->value = XtMalloc(strlen(p)+1); strcpy(header->value, p); XtFree(line); #ifdef DEBUG fprintf(stderr, "parsed header: <%s> <%s>\n", header->name, header->value); #endif return header; } /* * Read in all of the mail headers for a mail messages. */ MailHeader* MailHeaderListRead() { MailHeader *header_head = NULL; MailHeader *header_tail = NULL; MailHeader *header; #ifdef DEBUG fprintf(stderr, "reading mail headers...\n"); #endif while((header = MailHeaderRead()) != NULL) { /* * We go in the list at the end so there is no next guy. */ header->next = NULL; /* * The last guy on the list is our prev. */ header->prev = header_tail; /* * If there is a prev guy ne are its next. */ if (header->prev != NULL) { header->prev->next = header; } /* * If there is no head, we are it. This is the * first header. */ if (header_head == NULL) { header_head = header; } /* * We are the tail. */ header_tail = header; } return header_head; } void MailHeaderFree(header) MailHeader* header; { if (header->name != NULL) { XtFree(header->name); } if (header->value != NULL) { XtFree(header->value); } if (header->line) { XtFree(header->line); } XtFree((void *)header); } void MailHeaderListFree(list) MailHeader* list; { MailHeader* header; while(list != NULL) { header = list; list = list->next; MailHeaderFree(header); } } #define MKLOWER(c) isupper(c) ? tolower(c) : c static int HeaderNameCompare(s1, s2) char* s1; char* s2; { int c1, c2; while ((*s1 != '\0') && (*s2 != '\0')) { c1 = isupper(*s1) ? tolower(*s1) : *s1; c2 = isupper(*s2) ? tolower(*s2) : *s2; if (c1 != c2) { break; } ++s1; ++s2; } return *s1 - *s2; } /* * Locate the named header in the header list. */ MailHeader* MailHeaderFind(name, list) char* name; MailHeader* list; { MailHeader *header; for(header = list; header != NULL; header = header->next) { if (header->name != NULL && HeaderNameCompare(name, header->name) == 0) { return header; } } return NULL; } /* * Compare two mail header lists. */ int MailHeaderListCompare(list1, list2) MailHeader* list1; MailHeader* list2; { MailHeader* header1; MailHeader* header2; for(header1 = list1, header2 = list2; header1 != NULL && header2 != NULL; header1 = header1->next, header2 = header2->next) { int name1, name2; int value1, value2; int line1, line2; name1 = (header1->name != NULL); name2 = (header2->name != NULL); value1 = (header1->value != NULL); value2 = (header2->value != NULL); line1 = (header1->line != NULL); line2 = (header2->line != NULL); /* * Messages must both have or not have names/values/lines. */ if ((name1 != name2) || (value1 != value2) || (line1 != line2)) { break; } if (name1 && (strcmp(header1->name, header2->name) != 0)) { break; } if (value1 && (strcmp(header1->value, header2->value) != 0)) { break; } if (line1 && (strcmp(header1->line, header2->line) != 0)) { break; } } /* * If we got thru all of the headers and both lists are exausted then * the header lists are identicle. */ if (header1 == NULL && header2 == NULL) { return 1; } /* * Header lists are different. */ return 0; } xfaces-3.3/mail_items.c 444 227 12 44526 5540460224 14011 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Mar 7 17:49:59 1994 * Update Count : 142 * Status : Released * * HISTORY * 6-Mar-1994 Chris Liebman * Last Modified: Sun Mar 6 22:35:49 1994 #122 (Chris Liebman) * Added customization for mail annotations. * * 13-Feb-1994 Chris Liebman * Last Modified: Sat Feb 12 23:17:13 1994 #51 (Chris Liebman) * Added new mail annotation. * * 2-Feb-1994 Chris Liebman * Last Modified: Mon Jan 31 23:13:16 1994 #34 (Chris Liebman) * Added annotation support. This is only hooked up for scripts * currently. * * 31-Jan-1994 Chris Liebman * Last Modified: Sat Jan 29 20:40:41 1994 #33 (Chris Liebman) * Added new search support and a function to create an item that * has no headers. * * 24-Jan-1994 Chris Liebman * Last Modified: Sun Jan 23 14:04:47 1994 #28 (Chris Liebman) * Moved all of the sound / image searching to other files. * * 20-Jan-1994 Chris Liebman * Last Modified: Tue Jan 18 14:38:39 1994 #22 (Chris Liebman) * Added new header parsing and bindings. * * 14-Jan-1994 Chris Liebman * Last Modified: Fri Jan 14 10:42:41 1994 #7 (Chris Liebman) * Added new MailItemIgnore() function. * MailItemCreate() now ignores items for which MailItemIgnore() * returns true. * Search the status header with bindings. * * PURPOSE * Routines to manage the list of mail items. */ #ifndef lint static char *RCSid = "$Id: mail_items.c,v 1.20 1994/03/08 15:05:57 liebman Exp $"; #endif #include "faces.h" #ifdef LOOKUP_HOSTNAME #include #endif /* * The list of mail items from mail box. */ MailItem *TheMailItems; MailItem *TheMailItemsTail; /* * */ typedef enum mail_annotation_types { MailAnnotateNone, MailAnnotateCount, MailAnnotateUser, MailAnnotateHost, MailAnnotateUserHost, MailAnnotateHeader } MailAnnotationType; typedef struct mail_annotation { MailAnnotationType type; char* header; } MailAnnotation; static MailAnnotation* mailAnnotations; static int annotationCount; static MailAnnotation* unknownMailAnnotations; static int unknownAnnotationCount; static void MailItemAnnotate(item, annotations) MailItem* item; char** annotations; { int i; char buffer[30]; MailHeader* header; int count; MailAnnotation* annos; char* p; if (item->unknown) { count = unknownAnnotationCount; annos = unknownMailAnnotations; #ifdef ITEM_DEBUG fprintf(stderr, "MailItemAnnotate(): using unknown annotations.\n"); #endif } else { count = annotationCount; annos = mailAnnotations; #ifdef ITEM_DEBUG fprintf(stderr, "MailItemAnnotate(): using known annotations.\n"); #endif } if (item->annotations != NULL) { for (i = 0; item->annotations[i] != NULL; ++i) { XtFree(item->annotations[i]); } XtFree((char*)item->annotations); item->annotations = NULL; } if (item->face == NULL) { return; } if (annotations == NULL) { item->annotations = (char**)XtCalloc(count + 1, sizeof(char*)); for(i = 0; i < count; ++i) { if (item->use_label == (i+1)) { item->annotations[i] = XtNewString(item->label); } else { switch(annos[i].type) { case MailAnnotateNone: break; case MailAnnotateCount: sprintf(buffer, "%d", item->face->count); item->annotations[i] = XtNewString(buffer); break; case MailAnnotateUser: item->annotations[i] = XtNewString(item->user); break; case MailAnnotateHost: item->annotations[i] = XtNewString(item->host); break; case MailAnnotateUserHost: item->annotations[i] = XtMalloc(strlen(item->user) + strlen(item->host) + 2); sprintf(item->annotations[i], "%s@%s", item->user, item->host); break; case MailAnnotateHeader: header = MailHeaderFind(annos[i].header, item->headers); if ((header != NULL) && (header->value != NULL)) { p = SkipChars(header->value, " \t"); item->annotations[i] = XtNewString(p); } break; default: fprintf(stderr, "Bad MailAnnotationType: %d\n", annos[i].type); break; } } if (item->annotations[i] == NULL) { item->annotations[i] = XtMalloc(1); *(item->annotations[i]) = '\0'; } #ifdef ITEM_DEBUG fprintf(stderr, "item->annotation[%d]: <%s>\n", i, item->annotations[i]); #endif } } else { /* * Count annotations. */ for(i = 0; annotations[i] != NULL; ++i); /* * Copy annotations. */ item->annotations = (char**)XtCalloc(i+1, sizeof(char*)); for(i = 0; annotations[i] != NULL; ++i) { item->annotations[i] = XtNewString(annotations[i]); } item->annotations[i] = NULL; } } static void MailItemFree(item) MailItem *item; { if (item->next != NULL) { item->next->prev = item->prev; } if (item->prev != NULL) { item->prev->next = item->next; } if (TheMailItems == item) { TheMailItems = item->next; } if (TheMailItemsTail == item) { TheMailItemsTail = item->prev; } XtFree(item->user); XtFree(item->host); XtFree(item->realhost); XtFree(item->label); item->user = NULL; item->host = NULL; item->realhost = NULL; item->label = NULL; /* * Free mail headers. */ MailHeaderListFree(item->headers); item->headers = NULL; /* * Free annotations. */ item->face = NULL; MailItemAnnotate(item, NULL); FaceImageFree(item->image); item->image = NULL; #ifdef SOUND FaceSoundFree(item->sound); #endif /* SOUND */ item->sound = NULL; FaceCommandFree(item->command); item->command = NULL; XtFree((void *)item); } /* * Use the ignoreMessage expression to see if this message should be * ignored. */ static int MailItemIgnore(item) MailItem *item; { FaceBinding *binding; binding = FaceBindingCheck(item->headers, TheFacesResources.ignore_message_bindings); if (binding != NULL) { return 1; } return(0); } void MailBoxClear() { MailItem *item; for (item = TheMailItems; item != NULL; item = item->next) { item->in_use = 0; } FaceClear(); } void MailBoxUnClear() { MailItem *item; for (item = TheMailItems; item != NULL; item = item->next) { item->in_use = 1; item->face = FaceDisplay(item); } } void MailBoxClean() { MailItem *item; for (item = TheMailItems; item != NULL; item = item->next) { if (item->in_use == 0) { MailItemFree(item); } } FaceClean(); } static void MailItemLabel(item) MailItem* item; { if (item->label == NULL) { item->label = XtMalloc(strlen(item->user) + strlen(item->host) + 2); sprintf(item->label, "%s@%s", item->user, item->host); item->use_label = 0; } } /* * Create a new mail item */ void MailItemCreate(headers) MailHeader* headers; { MailItem *item; MailHeader *from; #ifdef LOOKUP_HOSTNAME struct hostent *host; #endif /* * Have we already seen this item? */ for (item = TheMailItems; item != NULL; item = item->next) { if (item->in_use) { continue; } if (MailHeaderListCompare(headers, item->headers)) { /* * Yep! */ item->face = FaceDisplay(item); item->in_use = 1; /* * Setup annotations. */ MailItemAnnotate(item, NULL); /* * Don't need these headers! */ MailHeaderListFree(headers); return; } } item = (MailItem *)XtCalloc(1, sizeof(MailItem)); item->headers = headers; item->in_use = 1; /* * Now parse the from line into the user and host parts. */ from = MailHeaderFind(TheFacesResources.from_field, headers); if (from == NULL) { from = MailHeaderFind("From:", headers); } if (from == NULL) { from = MailHeaderFind("From ", headers); } /* * If we found no from line then we ignore this message. */ if (from == NULL) { MailItemFree(item); return; } /* * Parse the from address. */ MailParseAddress(from->value, &(item->user), &(item->host)); #ifdef LOOKUP_HOSTNAME /* * Lookup the host via gethostbyname if asked. */ if (TheFacesResources.lookup_hostname) { host = gethostbyname(item->host); if (host != NULL) { if (strcmp(item->host, host->h_name) != 0) { item->realhost = XtNewString(host->h_name); } #ifdef LOOKUP_DEBUG fprintf(stderr, "lookup: <%s> -> <%s>\n", item->host, host->h_name); #endif } #ifdef LOOKUP_DEBUG else { fprintf(stderr, "lookup: <%s> -> <>\n", item->host); } #endif } #endif /* LOOKUP_HOSTNAME */ /* * Now see if we should ignore this message. */ if (MailItemIgnore(item)) { /* * Yup! Do not need this item. */ MailItemFree(item); return; } /* * Locate any image and sound. */ FaceImageFind(item); #ifdef SOUND FaceSoundFind(item); #endif FaceCommandFind(item); /* * Compute the label (this is what is used to compress images.) */ MailItemLabel(item); /* * Add this new item to the tail of the list. */ if (TheMailItems == NULL) { TheMailItems = TheMailItemsTail = item; } else { item->prev = TheMailItemsTail; item->prev->next = item; TheMailItemsTail = item; } item->face = FaceDisplay(item); /* * Setup annotations. */ MailItemAnnotate(item, NULL); #ifdef SOUND FaceSoundPlay(item->sound); #endif /* SOUND */ FaceCommandRun(item->command); } void MailItemCreateNoHeaders(user, host, annotations) char* user; char* host; char** annotations; { MailItem *item; if (annotations != NULL) { if (*annotations == NULL || **annotations == '\0') { annotations = NULL; } } if (user == NULL) { user = "unknown"; } if (host == NULL) { host = "LOCAL"; } /* * Have we already seen this item? */ for (item = TheMailItems; item != NULL; item = item->next) { if (item->in_use) { continue; } if (strcmp(user, item->user) == 0 && strcmp(host, item->host) == 0) { #ifdef ITEM_DEBUG fprintf(stderr,"MailItemCreateNoHeaders: reusing: <%s>:<%s>\n", user, host); #endif /* * Yep! */ item->face = FaceDisplay(item); /* * Annotations may have changed. */ MailItemAnnotate(item, annotations); item->in_use = 1; return; } } #ifdef ITEM_DEBUG fprintf(stderr,"MailItemCreateNoHeaders: creating: <%s>:<%s>\n", user, host); #endif item = (MailItem *)XtCalloc(1, sizeof(MailItem)); item->headers = NULL; item->user = XtNewString(user); item->host = XtNewString(host); item->in_use = 1; /* * Compute the label (this is what is used to compress images.) */ MailItemLabel(item); /* * Locate any image and sound. */ FaceImageFind(item); #ifdef SOUND FaceSoundFind(item); #endif FaceCommandFind(item); /* * Add this new item to the tail of the list. */ if (TheMailItems == NULL) { TheMailItems = TheMailItemsTail = item; } else { item->prev = TheMailItemsTail; item->prev->next = item; } item->face = FaceDisplay(item); MailItemAnnotate(item, annotations); #ifdef SOUND FaceSoundPlay(item->sound); #endif /* SOUND */ FaceCommandRun(item->command); } void MailBoxEmpty() { /* * There is no file, clear all counts and clean. This * will cause all faces to be removed. */ MailBoxClear(); MailBoxClean(); } void MailItemInit() { int i; XrmDatabase db; char* appname = XtName(TheTopLevel); char* fullname; char* fullclass; String type; XrmValue value; #if (XtSpecificationRelease > 4) db = XtScreenDatabase(XtScreen(TheTopLevel)); #else db = XtDatabase(XtDisplay(TheTopLevel)); #endif fullname = XtMalloc(strlen(appname) + 50); fullclass = XtMalloc(strlen(XFACES_CLASS) + 50); annotationCount = TheFacesResources.annotation_count; mailAnnotations = (MailAnnotation*) XtCalloc(annotationCount, sizeof(MailAnnotation)); for(i = 0; i < annotationCount; ++i) { type = NULL; mailAnnotations[i].type = MailAnnotateNone; mailAnnotations[i].header = NULL; sprintf(fullname, "%s.mail.annotation%d", appname, i+1); sprintf(fullclass, "%s.Mail.Annotation", XFACES_CLASS); #ifdef ITEM_DEBUG fprintf(stderr, "looking for: %s/%s\n", fullname, fullclass); #endif if (XrmGetResource(db, fullname, fullclass, &type, &value) && (strcmp(type, XtRString) == 0)) { #ifdef ITEM_DEBUG fprintf(stderr, "found: <%s>\n", (char*)(value.addr)); #endif if (strcmp(value.addr, "none") == 0) { mailAnnotations[i].type = MailAnnotateNone; } else if (strcmp(value.addr, "count") == 0) { mailAnnotations[i].type = MailAnnotateCount; } else if (strcmp(value.addr, "user") == 0) { mailAnnotations[i].type = MailAnnotateUser; } else if (strcmp(value.addr, "host") == 0) { mailAnnotations[i].type = MailAnnotateHost; } else if (strcmp(value.addr, "user@host") == 0) { mailAnnotations[i].type = MailAnnotateUserHost; } else if (strncmp(value.addr, "*", 1) == 0) { mailAnnotations[i].type = MailAnnotateHeader; mailAnnotations[i].header = (char*)(value.addr) + 1; } #ifdef ITEM_DEBUG switch (mailAnnotations[i].type) { case MailAnnotateNone: fprintf(stderr, "mailAnnotations[%d].type: MailAnnotateNone\n", i); break; case MailAnnotateCount: fprintf(stderr, "mailAnnotations[%d].type: MailAnnotateCount\n", i); break; case MailAnnotateUser: fprintf(stderr, "mailAnnotations[%d].type: MailAnnotateUser\n", i); break; case MailAnnotateHost: fprintf(stderr, "mailAnnotations[%d].type: MailAnnotateHost\n", i); break; case MailAnnotateUserHost: fprintf(stderr, "mailAnnotations[%d].type: MailAnnotateUserHost\n", i); break; case MailAnnotateHeader: fprintf(stderr, "mailAnnotations[%d].type: MailAnnotateHeader\n", i); fprintf(stderr, "mailAnnotations[%d].header: <%s>\n", i, mailAnnotations[i].header); break; } #endif } }; unknownAnnotationCount = TheFacesResources.unknown_annotation_count; unknownMailAnnotations = (MailAnnotation*)XtCalloc(unknownAnnotationCount, sizeof(MailAnnotation)); for(i = 0; i < unknownAnnotationCount; ++i) { type = NULL; unknownMailAnnotations[i].type = MailAnnotateNone; unknownMailAnnotations[i].header = NULL; sprintf(fullname, "%s.mail.unknownAnnotation%d", appname, i+1); sprintf(fullclass, "%s.Mail.Annotation", XFACES_CLASS); #ifdef ITEM_DEBUG fprintf(stderr, "looking for: %s/%s\n", fullname, fullclass); #endif if (XrmGetResource(db, fullname, fullclass, &type, &value) && (strcmp(type, XtRString) == 0)) { #ifdef ITEM_DEBUG fprintf(stderr, "found: <%s>\n", (char*)(value.addr)); #endif if (strcmp(value.addr, "none") == 0) { unknownMailAnnotations[i].type = MailAnnotateNone; } else if (strcmp(value.addr, "count") == 0) { unknownMailAnnotations[i].type = MailAnnotateCount; } else if (strcmp(value.addr, "user") == 0) { unknownMailAnnotations[i].type = MailAnnotateUser; } else if (strcmp(value.addr, "host") == 0) { unknownMailAnnotations[i].type = MailAnnotateHost; } else if (strcmp(value.addr, "user@host") == 0) { unknownMailAnnotations[i].type = MailAnnotateUserHost; } else if (strncmp(value.addr, "*", 1) == 0) { unknownMailAnnotations[i].type = MailAnnotateHeader; unknownMailAnnotations[i].header = (char*)(value.addr) + 1; } #ifdef ITEM_DEBUG switch (unknownMailAnnotations[i].type) { case MailAnnotateNone: fprintf(stderr, "unknownMailAnnotations[%d].type: MailAnnotateNone\n", i); break; case MailAnnotateCount: fprintf(stderr, "unknownMailAnnotations[%d].type: MailAnnotateCount\n", i); break; case MailAnnotateUser: fprintf(stderr, "unknownMailAnnotations[%d].type: MailAnnotateUser\n", i); break; case MailAnnotateHost: fprintf(stderr, "unknownMailAnnotations[%d].type: MailAnnotateHost\n", i); break; case MailAnnotateUserHost: fprintf(stderr, "unknownMailAnnotations[%d].type: MailAnnotateUserHost\n", i); break; case MailAnnotateHeader: fprintf(stderr, "unknownMailAnnotations[%d].type: MailAnnotateHeader\n", i); fprintf(stderr, "unknownMailAnnotations[%d].header: <%s>\n", i, unknownMailAnnotations[i].header); break; } #endif } }; XtFree(fullname); XtFree(fullclass); } xfaces-3.3/mail_parse.c 444 227 12 11433 5540460225 13772 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Thu Jan 20 11:11:36 1994 * Update Count : 8 * Status : Released * * HISTORY * 20-Jan-1994 Chris Liebman * Last Modified: Tue Jan 18 17:37:14 1994 #7 (Chris Liebman) * Now only parse addresses here. Header and mailbox parsing is now * done in other files. * * 14-Jan-1994 Chris Liebman * Last Modified: Fri Jan 14 10:09:52 1994 #3 (Chris Liebman) * Added support for teh status header. * Improved mail parsing, now detects when we are in the body and * will not match headers there! * * PURPOSE * Routines to parse the mail file and to parse a mail address. */ #ifndef lint static char *RCSid = "$Id: mail_parse.c,v 1.7 1994/03/07 20:30:49 liebman Exp $"; #endif #include "faces.h" void MailParseAddress(from, user, host) String from; String *user; String *host; { String phost; String puser; String data; String data1; data1 = data = XtNewString(from); /* * Make lower case. */ for(phost = data; *phost != '\0'; ++phost) { if (isupper(*phost)) { *phost = tolower(*phost); } } /* * space out any comment. */ while ((phost = index(data, '(')) != NULL) { while((*phost != ')') && (*phost != '\0')) { *phost++ = ' '; } if (*phost == ')') { *phost = ' '; } } /* * Skip any leading spaces. */ while(isspace(*data)) { ++data; } /* * See if there is an address in <>'s. */ if ((phost = index(data, '<')) != NULL) { data = phost+1; } /* * drop any junk off the end. */ for (phost = data; *phost != '\0'; ++phost) { if (isspace(*phost) || (*phost == ',') || (*phost == '>')) { *phost = '\0'; break; } } /* * Skip past any leading '@'. */ if (*data == '@') { ++data; } /* * Look for user@host first. */ if ((phost = index(data, '@')) != NULL) { *(phost++) = '\0'; /* * Look for host!user */ if ((puser = rindex(data, '!')) != NULL) { /* * Yep!, wipe the ! and point to the user name. */ *(puser++) = '\0'; /* * Now locate the host name. */ if ((phost = rindex(data, '!')) != NULL) { phost++; } else { phost = data; } /* * Return the user and host. */ *host = XtNewString(phost); *user = XtNewString(puser); XtFree(data1); return; } /* * Grab the user skipping past any RFC822 routing garbage. */ if ((puser = index(data, ':')) != NULL) { ++puser; } else { puser = data; } /* * Return the user and host. */ *host = XtNewString(phost); *user = XtNewString(puser); XtFree(data1); return; } /* * Ok, try uucp style: host!host!user */ if ((puser = rindex(data, '!')) != NULL) { /* * Wipe ! and move to user name. */ *(puser++) = '\0'; /* * Now locate the host name. */ if ((phost = rindex(data, '!')) != NULL) { phost++; } else { phost = data; } /* * Return the user and host. */ *host = XtNewString(phost); *user = XtNewString(puser); XtFree(data1); return; } /* * Must be local address! */ *user = XtNewString(data); *host = XtNewString("LOCAL"); XtFree(data1); return; } xfaces-3.3/main.c 444 227 12 40257 5540460225 12610 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Mar 7 16:56:37 1994 * Update Count : 130 * Status : Released * * HISTORY * 13-Feb-1994 Chris Liebman * Last Modified: Sun Feb 13 00:40:08 1994 #111 (Chris Liebman) * Added new command support and support to annotate mail items. * * 8-Feb-1994 Chris Liebman * Last Modified: Sat Feb 5 22:03:01 1994 #82 (Chris Liebman) * Added new command line options. Added new Tiled widget. * * 2-Feb-1994 Chris Liebman * Last Modified: Tue Feb 1 14:41:17 1994 #72 (Chris Liebman) * Added annotation support. * * 31-Jan-1994 Chris Liebman * Last Modified: Sun Jan 30 02:05:43 1994 #67 (Chris Liebman) * New search code. * Command line options. * New resources. * List Commad support. * * 24-Jan-1994 Chris Liebman * Last Modified: Sun Jan 23 18:46:43 1994 #18 (Chris Liebman) * Added new bindings. * * 20-Jan-1994 Chris Liebman * Last Modified: Tue Jan 18 17:14:31 1994 #9 (Chris Liebman) * Added new closeness resource and some cleanups. * * 14-Jan-1994 Chris Liebman * Last Modified: Fri Jan 14 09:59:56 1994 #4 (Chris Liebman) * Added ignoreMessageBindings resource. * * PURPOSE * This is xfaces initialization. */ #ifndef lint static char *RCSid = "$Id: main.c,v 1.29 1994/03/08 02:19:48 liebman Exp $"; #endif #include "faces.h" #include #ifdef __STDC__ #include #endif /* * The resources. */ FacesResourcesRec TheFacesResources; /* * This is ugly but it will remove some error messages when * some options are not compiled in. */ #ifdef SHAPE #ifdef XPM #define IMAGE_TYPES "xpm-shape:xpm:xbm-shape:xbm" #else /* XPM*/ #define IMAGE_TYPES "xbm-shape:xbm" #endif /* XPM */ #else /* SHAPE */ #ifdef XPM #define IMAGE_TYPES "xpm:xbm" #else /* XPM*/ #define IMAGE_TYPES "xbm" #endif /* XPM*/ #endif /* SHAPE */ #ifdef XFACE #define IMAGE_SEARCH "beforeImage\nresource\nfacedb\nx-face\nafterImage" #else /* XFACE */ #define IMAGE_SEARCH "beforeImage\nresource\nfacedb\nafterImage" #endif /* XFACE */ #define SOUND_SEARCH "beforeSound\nresource\nfacedb\nafterSound" #define COMMAND_SEARCH "beforeCommand\nresource\nafterCommand" /* * Here is a description of our resources for the toolkit. */ static Boolean defFalse = False; static Boolean defTrue = True; #define XtNvolume "volume" /* Int: volume for bell */ #define XtCVolume "Volume" #define offset(field) XtOffset(FacesResources, field) static XtResource FacesResourcesList[] = { { "spoolFile", "SpoolFile", XtRString, sizeof(String), offset(spool_file), XtRString, NULL }, { "spoolDir", "SpoolDir", XtRString, sizeof(String), offset(spool_dir), XtRString, "/usr/spool/mail" }, { "popHost", "PopHost", XtRString, sizeof(String), offset(pop_host), XtRString, NULL }, { "popAuthFile", "PopAuthFile", XtRString, sizeof(String), offset(pop_auth_file), XtRString, NULL }, { "popPort", "PopPort", XtRInt, sizeof(int), offset(pop_port), XtRString, "110" }, { "listCommand", "Command", XtRString, sizeof(String), offset(list_command), XtRString, NULL }, { "imagePath", "Path", XtRString, sizeof(String), offset(image_path), XtRString, "/usr/images" }, { "soundPath", "Path", XtRString, sizeof(String), offset(sound_path), XtRString, "/usr/sounds" }, { "facedbPath", "Path", XtRString, sizeof(String), offset(facedb_path), XtRString, "/usr/local/faces" }, { "machine", "Path", XtRString, sizeof(String), offset(machine), XtRString, "machine.tab" }, { "people", "Path", XtRString, sizeof(String), offset(people), XtRString, "people.tab" }, { "update", "Update", XtRInt, sizeof(int), offset(update), XtRString, "60" }, { XtNvolume, XtCVolume, XtRInt, sizeof(int), offset(volume), XtRString, "33" }, { "fromField", "FromField", XtRString, sizeof(String), offset(from_field), XtRString, "From " }, { "noMailImage", "Image", XtRString, sizeof(String), offset(no_mail_image), XtRString, "nomail" }, { "noMailSound", "Sound", XtRString, sizeof(String), offset(no_mail_sound), XtRString, NULL }, { "keepOrder", "KeepOrder", XtRBoolean, sizeof(Boolean), offset(keep_order), XtRBoolean, (caddr_t) &defFalse }, { "compressImages", "CompressImages", XtRBoolean, sizeof(Boolean), offset(compress_images), XtRBoolean, (caddr_t) &defTrue }, { "useSound", "UseSound", XtRBoolean, sizeof(Boolean), offset(use_sound), XtRBoolean, (caddr_t) &defTrue }, { "useShape", "UseShape", XtRBoolean, sizeof(Boolean), offset(use_shape), XtRBoolean, (caddr_t) &defTrue }, { "useCommands", "UseCommands", XtRBoolean, sizeof(Boolean), offset(use_commands), XtRBoolean, (caddr_t) &defFalse }, { "useContentLength", "UseContentLength", XtRBoolean, sizeof(Boolean), offset(use_content_length), XtRBoolean, (caddr_t) &defFalse }, { "shapeBorders", "ShapeBorders", XtRBoolean, sizeof(Boolean), offset(shape_borders), XtRBoolean, (caddr_t) &defTrue }, { "shapeInternal", "ShapeInternal", XtRBoolean, sizeof(Boolean), offset(shape_internal), XtRBoolean, (caddr_t) &defTrue }, { "closeness", "Closeness", XtRInt, sizeof(int), offset(closeness), XtRString, (caddr_t) "40000" }, { "imageTypes", "ImageTypes", XtRString, sizeof(String), offset(image_types_str), XtRString, IMAGE_TYPES }, { "imageSearch", "Search", XtRString, sizeof(String), offset(image_search_str), XtRString, IMAGE_SEARCH }, { "soundSearch", "Search", XtRString, sizeof(String), offset(sound_search_str), XtRString, SOUND_SEARCH }, { "commandSearch", "Search", XtRString, sizeof(String), offset(command_search_str), XtRString, COMMAND_SEARCH }, { "ignoreMessageBindings", "IgnoreBindings", XtRString, sizeof(String), offset(ignore_message_bindings_str), XtRString, NULL }, { "beforeImageBindings", "ImageBindings", XtRString, sizeof(String), offset(before_image_bindings_str), XtRString, NULL }, { "afterImageBindings", "ImageBindings", XtRString, sizeof(String), offset(after_image_bindings_str), XtRString, NULL }, { "beforeSoundBindings", "SoundBindings", XtRString, sizeof(String), offset(before_sound_bindings_str), XtRString, NULL }, { "afterSoundBindings", "SoundBindings", XtRString, sizeof(String), offset(after_sound_bindings_str), XtRString, NULL }, { "beforeCommandBindings", "CommandBindings", XtRString, sizeof(String), offset(before_command_bindings_str), XtRString, NULL }, { "afterCommandBindings", "CommandBindings", XtRString, sizeof(String), offset(after_command_bindings_str), XtRString, NULL }, { "annotationCount", "Count", XtRInt, sizeof(int), offset(annotation_count), XtRString, "1" }, { "unknownAnnotationCount", "Count", XtRInt, sizeof(int), offset(unknown_annotation_count), XtRString, "1" }, { "annotationAbove", "AnnotationAbove", XtRBoolean, sizeof(Boolean), offset(annotation_above), XtRString, "False" }, { "background", "Background", XtRPixel, sizeof(Pixel), offset(background), XtRString, XtDefaultBackground }, { "shapeExtra", "Shape", XtRBoolean, sizeof(Boolean), offset(shape_extra), XtRString, "True" }, { "pathByChdir", "PathByChdir", XtRBoolean, sizeof(Boolean), offset(path_by_chdir), XtRString, "True" }, { "lookupHostname", "LookupHostname", XtRBoolean, sizeof(Boolean), offset(lookup_hostname), XtRString, "False" }, }; #undef offset static XrmOptionDescRec options[] = { { "-c", "frame.setWidth", XrmoptionSepArg, NULL }, { "-e", "listCommand", XrmoptionSepArg, NULL }, { "-f", "facedbPath", XrmoptionSepArg, NULL }, { "-h", "frame.tileHeight", XrmoptionSepArg, NULL }, { "-p", "update", XrmoptionSepArg, NULL }, { "-s", "spoolFile", XrmoptionSepArg, NULL }, { "-w", "frame.tileWidth", XrmoptionSepArg, NULL }, { "-C", "compressImages", XrmoptionNoArg, "False" }, { "-K", "keepOrder", XrmoptionNoArg, "True" }, { "-S", "shapeExtra", XrmoptionNoArg, "False" }, { "-pop", "popHost", XrmoptionSepArg, NULL } }; static Atom wm_delete_window; static void quit (w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { if (event->type == ClientMessage && event->xclient.data.l[0] != wm_delete_window) { XBell (XtDisplay(w), 0); return; } /* * First suspend layout. Then cleanup. */ XtVaSetValues(TheFrame, XtNlayout, False, NULL); MailBoxClear(); MailBoxClean(); XCloseDisplay (XtDisplay(w)); exit (0); } static XtActionsRec xfaces_actions[] = { { "quit", quit }, }; /* * Here are the main widgets. */ Widget TheTopLevel; /* The top level shell widget. */ Widget TheFrame; /* A frame to hold the faces. */ FaceImage *NoMailImage = NULL; FaceSound *NoMailSound = NULL; void CheckMailNow() { /* * First suspend layout. */ XtVaSetValues(TheFrame, XtNlayout, False, NULL); /* * Wipe the current face display list. */ MailBoxClear(); /* * Process items. */ #ifdef POP if (TheFacesResources.pop_host) { PopCheck(); } else #endif if (TheFacesResources.list_command) { CmdCheck(); } else { MailCheck(); } /* * Build the FaceDisplay list from the item list. */ MailBoxClean(); /* * Now resume layout. */ XtVaSetValues(TheFrame, XtNlayout, True, NULL); /* * Shape the window. */ #ifdef SHAPE FaceShapeCreate(); #endif } static void StartTimer(); /* * Check for changes to the mail spool file and kick the * timer again. */ /* ARGSUSED */ static void CheckMail( data, id ) caddr_t data; XtIntervalId *id; { CheckMailNow(); /* * Restart the timer. */ StartTimer(TheFacesResources.update); return; } static void StartTimer(secs) int secs; { (void) XtAddTimeOut((unsigned long) secs * 1000, CheckMail, (caddr_t) NULL ); } /* * Here is the main routine. */ int main(argc, argv) int argc; char *argv[]; { char *name; char *home; struct passwd *pw; FacesResources fr = &TheFacesResources; /* * Create the top level widget. */ TheTopLevel = XtInitialize(NULL, XFACES_CLASS, options, XtNumber(options), &argc, argv); /* * Load any application resources. */ XtGetApplicationResources( TheTopLevel, fr, FacesResourcesList, XtNumber(FacesResourcesList), NULL, 0 ); /* * This is a hack so that f.delete will do something useful in this * single-window application. */ XtAppAddActions (XtWidgetToApplicationContext(TheTopLevel), xfaces_actions, XtNumber(xfaces_actions)); XtOverrideTranslations(TheTopLevel, XtParseTranslationTable ("WM_PROTOCOLS: quit()")); /* * If the spool file is null then create one from the * user name. */ if (fr->spool_file == NULL) { if ((name = getlogin()) == NULL) { pw = getpwuid(getuid()); if (pw != NULL || pw->pw_name != NULL) { name = pw->pw_name; } else { name = "nobody"; } endpwent(); } fr->spool_file = XtMalloc(strlen(fr->spool_dir)+ strlen(name) + 2); (void) sprintf(fr->spool_file, "%s/%s", fr->spool_dir, name); } if (fr->pop_auth_file == NULL) { home = getenv("HOME"); if (home == NULL) { home = "/tmp"; } fr->pop_auth_file = XtMalloc(strlen(home) + 30); sprintf(fr->pop_auth_file, "%s/.popauth", home); } /* * Initialize the image types. */ FaceImageXbmInit(); #ifdef XPM FaceImageXpmInit(); #endif #ifdef IKON FaceImageIkonInit(); #endif /* * Initialize the search types. */ FaceSearchBindingInit(); FaceSearchFacedbInit(); FaceSearchResourceInit(); FaceSearchUserHostInit(); #ifdef XFACE FaceSearchXFaceInit(); #endif /* * Parse up the image/sound paths. */ fr->image_path_str = XtNewString(fr->image_path); fr->sound_path_str = XtNewString(fr->sound_path); fr->facedb_path_str = XtNewString(fr->facedb_path); fr->image_paths = PathParse(fr->image_path_str); fr->sound_paths = PathParse(fr->sound_path_str); fr->facedb_paths = PathParse(fr->facedb_path_str); /* * Parse the image types. */ fr->image_types_str = XtNewString(fr->image_types_str); fr->image_types = FaceImageTypeListParse(fr->image_types_str); /* * Create binding lists. */ fr->ignore_message_bindings =FaceBindingParse(fr->ignore_message_bindings_str, 0, 0); fr->before_image_bindings = FaceBindingParse(fr->before_image_bindings_str, 1, 1); fr->after_image_bindings = FaceBindingParse(fr->after_image_bindings_str, 1, 1); fr->before_sound_bindings = FaceBindingParse(fr->before_sound_bindings_str, 1,1 ); fr->after_sound_bindings =FaceBindingParse(fr->after_sound_bindings_str, 1, 1); /* fr->command_bindings = FaceBindingParse(fr->command_bindings_str, 1, 0); */ /* * Parse the search instructions. */ fr->image_search_str = XtNewString(fr->image_search_str); fr->image_search = FaceSearchParse(fr->image_search_str, FormatImage); fr->sound_search_str = XtNewString(fr->sound_search_str); fr->sound_search = FaceSearchParse(fr->sound_search_str, FormatAudio); fr->command_search_str = XtNewString(fr->command_search_str); fr->command_search = FaceSearchParse(fr->command_search_str, FormatCommand); /* * Now we create a box to keep our faces in. */ TheFrame = XtVaCreateManagedWidget("frame", tiledWidgetClass, TheTopLevel, NULL); /* * Initialize the face list. */ #ifdef SOUND FaceSoundInit(); #endif /* SOUND */ FaceActionsInit(); FaceDisplayInit(); FaceAnnotateInit(); MailItemInit(); XtRealizeWidget(TheTopLevel); wm_delete_window = XInternAtom (XtDisplay(TheTopLevel), "WM_DELETE_WINDOW", False); (void) XSetWMProtocols (XtDisplay(TheTopLevel), XtWindow(TheTopLevel), &wm_delete_window, 1); /* * Set the initial shape. */ #ifdef SHAPE FaceShapeCreate(); #endif /* * Kick off the timer. (we start the timer with one second so that the * the shape stuff will get flushed first. */ StartTimer(1); /* * Ok, we are all set up! */ XtMainLoop(); return 0; } void regerror(s) String s; { fprintf(stderr, "regerror: %s\n", s); abort(); } xfaces-3.3/path.c 444 227 12 5617 5540460226 12602 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * * * Author : Chris Liebman * Created On : Sat Jan 29 16:45:48 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Jan 31 22:32:22 1994 * Update Count : 16 * Status : Unknown, Use with caution! * * HISTORY * * PURPOSE * Path functions. */ #ifndef lint static char *RCSid = "$Id: path.c,v 1.2 1994/02/23 13:17:02 liebman Exp $"; #endif #include "faces.h" #include char** PathParse(str) char* str; { char** path; path = StringParse(str, ":"); return path; } int PathEnumerate(file, paths, func, data) char* file; char** paths; int (*func) P_((char* file, char* path, void* data)); void* data; { static char* buffer = NULL; static int buffer_size = 0; struct stat buf; int ret = 0; int path_len; int file_len; int len; if (buffer == NULL) { buffer_size = 1024; buffer = XtMalloc(buffer_size); } if (paths == NULL) { fprintf(stderr, "PathEnumerate: NULL paths!\n"); return 0; } file_len = strlen(file); while(!ret && *paths != NULL) { if (TheFacesResources.path_by_chdir) { if (chdir(*paths) != -1) { ret = func(file, *paths, data); } } else { if (stat(*paths, &buf) != -1 && (buf.st_mode & S_IFDIR)) { path_len = strlen(*paths); /* * We need path+/+file+NUL */ len = path_len + file_len + 2; if (len > buffer_size) { buffer_size = len; buffer = XtRealloc(buffer, buffer_size); } sprintf(buffer, "%s/%s", *paths, file); ret = func(buffer, *paths, data); } } /* * Go to the next path. */ ++paths; } return ret; } xfaces-3.3/regexp.c 444 227 12 65740 5540460226 13163 0ustar liebmanstaff/* * regcomp and regexec -- regsub and regerror are elsewhere * * Copyright (c) 1986 by University of Toronto. * Written by Henry Spencer. Not derived from licensed software. * * Permission is granted to anyone to use this software for any * purpose on any computer system, and to redistribute it freely, * subject to the following restrictions: * * 1. The author is not responsible for the consequences of use of * this software, no matter how awful, even if they arise * from defects in it. * * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. * * Beware that some of this code is subtly aware of the way operator * precedence is structured in regular expressions. Serious changes in * regular-expression syntax might require a total rethink. */ #include #include "regexp.h" #include "regmagic.h" /* * The "internal use only" fields in regexp.h are present to pass info from * compile to execute that permits the execute phase to run lots faster on * simple cases. They are: * * regstart char that must begin a match; '\0' if none obvious * reganch is the match anchored (at beginning-of-line only)? * regmust string (pointer into program) that match must include, or NULL * regmlen length of regmust string * * Regstart and reganch permit very fast decisions on suitable starting points * for a match, cutting down the work a lot. Regmust permits fast rejection * of lines that cannot possibly match. The regmust tests are costly enough * that regcomp() supplies a regmust only if the r.e. contains something * potentially expensive (at present, the only such thing detected is * or + * at the start of the r.e., which can involve a lot of backup). Regmlen is * supplied because the test in regexec() needs it and regcomp() is computing * it anyway. */ /* * Structure for regexp "program". This is essentially a linear encoding * of a nondeterministic finite-state machine (aka syntax charts or * "railroad normal form" in parsing technology). Each node is an opcode * plus a "next" pointer, possibly plus an operand. "Next" pointers of * all nodes except BRANCH implement concatenation; a "next" pointer with * a BRANCH on both ends of it is connecting two alternatives. (Here we * have one of the subtle syntax dependencies: an individual BRANCH (as * opposed to a collection of them) is never concatenated with anything * because of operator precedence.) The operand of some types of node is * a literal string; for others, it is a node leading into a sub-FSM. In * particular, the operand of a BRANCH node is the first node of the branch. * (NB this is *not* a tree structure: the tail of the branch connects * to the thing following the set of BRANCHes.) The opcodes are: */ /* definition number opnd? meaning */ #define END 0 /* no End of program. */ #define BOL 1 /* no Match "" at beginning of line. */ #define EOL 2 /* no Match "" at end of line. */ #define ANY 3 /* no Match any one character. */ #define ANYOF 4 /* str Match any character in this string. */ #define ANYBUT 5 /* str Match any character not in this string. */ #define BRANCH 6 /* node Match this alternative, or the next... */ #define BACK 7 /* no Match "", "next" ptr points backward. */ #define EXACTLY 8 /* str Match this string. */ #define NOTHING 9 /* no Match empty string. */ #define STAR 10 /* node Match this (simple) thing 0 or more times. */ #define PLUS 11 /* node Match this (simple) thing 1 or more times. */ #define OPEN 20 /* no Mark this point in input as start of #n. */ /* OPEN+1 is number 1, etc. */ #define CLOSE 30 /* no Analogous to OPEN. */ /* * Opcode notes: * * BRANCH The set of branches constituting a single choice are hooked * together with their "next" pointers, since precedence prevents * anything being concatenated to any individual branch. The * "next" pointer of the last BRANCH in a choice points to the * thing following the whole choice. This is also where the * final "next" pointer of each individual branch points; each * branch starts with the operand node of a BRANCH node. * * BACK Normal "next" pointers all implicitly point forward; BACK * exists to make loop structures possible. * * STAR,PLUS '?', and complex '*' and '+', are implemented as circular * BRANCH structures using BACK. Simple cases (one character * per match) are implemented with STAR and PLUS for speed * and to minimize recursive plunges. * * OPEN,CLOSE ...are numbered at compile time. */ /* * A node is one char of opcode followed by two chars of "next" pointer. * "Next" pointers are stored as two 8-bit pieces, high order first. The * value is a positive offset from the opcode of the node containing it. * An operand, if any, simply follows the node. (Note that much of the * code generation knows about this implicit relationship.) * * Using two bytes for the "next" pointer is vast overkill for most things, * but allows patterns to get big without disasters. */ #define OP(p) (*(p)) #define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377)) #define OPERAND(p) ((p) + 3) /* * See regmagic.h for one further detail of program structure. */ /* * Utility definitions. */ #ifndef CHARBITS #define UCHARAT(p) ((int)*(unsigned char *)(p)) #else #define UCHARAT(p) ((int)*(p)&CHARBITS) #endif #define FAIL(m) { regerror(m); return(NULL); } #define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?') #define META "^$.[()|?+*\\" /* * Flags to be passed up and down. */ #define HASWIDTH 01 /* Known never to match null string. */ #define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */ #define SPSTART 04 /* Starts with * or +. */ #define WORST 0 /* Worst case. */ /* * Global work variables for regcomp(). */ static char *regparse; /* Input-scan pointer. */ static int regnpar; /* () count. */ static char regdummy; static char *regcode; /* Code-emit pointer; ®dummy = don't. */ static long regsize; /* Code size. */ /* * Forward declarations for regcomp()'s friends. */ #ifndef STATIC #define STATIC static #endif STATIC char *reg(); STATIC char *regbranch(); STATIC char *regpiece(); STATIC char *regatom(); STATIC char *regnode(); STATIC char *regnext(); STATIC void regc(); STATIC void reginsert(); STATIC void regtail(); STATIC void regoptail(); #ifdef STRCSPN STATIC int strcspn(); #endif /* - regcomp - compile a regular expression into internal code * * We can't allocate space until we know how big the compiled form will be, * but we can't compile it (and thus know how big it is) until we've got a * place to put the code. So we cheat: we compile it twice, once with code * generation turned off and size counting turned on, and once "for real". * This also means that we don't allocate space until we are sure that the * thing really will compile successfully, and we never have to move the * code and thus invalidate pointers into it. (Note that it has to be in * one piece because free() must be able to free it all.) * * Beware that the optimization-preparation code in here knows about some * of the structure of the compiled regexp. */ regexp * regcomp(exp) char *exp; { register regexp *r; register char *scan; register char *longest; register int len; int flags; extern char *malloc(); if (exp == NULL) FAIL("NULL argument"); /* First pass: determine size, legality. */ regparse = exp; regnpar = 1; regsize = 0L; regcode = ®dummy; regc(MAGIC); if (reg(0, &flags) == NULL) return(NULL); /* Small enough for pointer-storage convention? */ if (regsize >= 32767L) /* Probably could be 65535L. */ FAIL("regexp too big"); /* Allocate space. */ r = (regexp *)malloc(sizeof(regexp) + (unsigned)regsize); if (r == NULL) FAIL("out of space"); /* Second pass: emit code. */ regparse = exp; regnpar = 1; regcode = r->program; regc(MAGIC); if (reg(0, &flags) == NULL) return(NULL); /* Dig out information for optimizations. */ r->regstart = '\0'; /* Worst-case defaults. */ r->reganch = 0; r->regmust = NULL; r->regmlen = 0; scan = r->program+1; /* First BRANCH. */ if (OP(regnext(scan)) == END) { /* Only one top-level choice. */ scan = OPERAND(scan); /* Starting-point info. */ if (OP(scan) == EXACTLY) r->regstart = *OPERAND(scan); else if (OP(scan) == BOL) r->reganch++; /* * If there's something expensive in the r.e., find the * longest literal string that must appear and make it the * regmust. Resolve ties in favor of later strings, since * the regstart check works with the beginning of the r.e. * and avoiding duplication strengthens checking. Not a * strong reason, but sufficient in the absence of others. */ if (flags&SPSTART) { longest = NULL; len = 0; for (; scan != NULL; scan = regnext(scan)) if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) { longest = OPERAND(scan); len = strlen(OPERAND(scan)); } r->regmust = longest; r->regmlen = len; } } return(r); } /* - reg - regular expression, i.e. main body or parenthesized thing * * Caller must absorb opening parenthesis. * * Combining parenthesis handling with the base level of regular expression * is a trifle forced, but the need to tie the tails of the branches to what * follows makes it hard to avoid. */ static char * reg(paren, flagp) int paren; /* Parenthesized? */ int *flagp; { register char *ret; register char *br; register char *ender; register int parno; int flags; *flagp = HASWIDTH; /* Tentatively. */ /* Make an OPEN node, if parenthesized. */ if (paren) { if (regnpar >= NSUBEXP) FAIL("too many ()"); parno = regnpar; regnpar++; ret = regnode(OPEN+parno); } else ret = NULL; /* Pick up the branches, linking them together. */ br = regbranch(&flags); if (br == NULL) return(NULL); if (ret != NULL) regtail(ret, br); /* OPEN -> first. */ else ret = br; if (!(flags&HASWIDTH)) *flagp &= ~HASWIDTH; *flagp |= flags&SPSTART; while (*regparse == '|') { regparse++; br = regbranch(&flags); if (br == NULL) return(NULL); regtail(ret, br); /* BRANCH -> BRANCH. */ if (!(flags&HASWIDTH)) *flagp &= ~HASWIDTH; *flagp |= flags&SPSTART; } /* Make a closing node, and hook it on the end. */ ender = regnode((paren) ? CLOSE+parno : END); regtail(ret, ender); /* Hook the tails of the branches to the closing node. */ for (br = ret; br != NULL; br = regnext(br)) regoptail(br, ender); /* Check for proper termination. */ if (paren && *regparse++ != ')') { FAIL("unmatched ()"); } else if (!paren && *regparse != '\0') { if (*regparse == ')') { FAIL("unmatched ()"); } else FAIL("junk on end"); /* "Can't happen". */ /* NOTREACHED */ } return(ret); } /* - regbranch - one alternative of an | operator * * Implements the concatenation operator. */ static char * regbranch(flagp) int *flagp; { register char *ret; register char *chain; register char *latest; int flags; *flagp = WORST; /* Tentatively. */ ret = regnode(BRANCH); chain = NULL; while (*regparse != '\0' && *regparse != '|' && *regparse != ')') { latest = regpiece(&flags); if (latest == NULL) return(NULL); *flagp |= flags&HASWIDTH; if (chain == NULL) /* First piece. */ *flagp |= flags&SPSTART; else regtail(chain, latest); chain = latest; } if (chain == NULL) /* Loop ran zero times. */ (void) regnode(NOTHING); return(ret); } /* - regpiece - something followed by possible [*+?] * * Note that the branching code sequences used for ? and the general cases * of * and + are somewhat optimized: they use the same NOTHING node as * both the endmarker for their branch list and the body of the last branch. * It might seem that this node could be dispensed with entirely, but the * endmarker role is not redundant. */ static char * regpiece(flagp) int *flagp; { register char *ret; register char op; register char *next; int flags; ret = regatom(&flags); if (ret == NULL) return(NULL); op = *regparse; if (!ISMULT(op)) { *flagp = flags; return(ret); } if (!(flags&HASWIDTH) && op != '?') FAIL("*+ operand could be empty"); *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH); if (op == '*' && (flags&SIMPLE)) reginsert(STAR, ret); else if (op == '*') { /* Emit x* as (x&|), where & means "self". */ reginsert(BRANCH, ret); /* Either x */ regoptail(ret, regnode(BACK)); /* and loop */ regoptail(ret, ret); /* back */ regtail(ret, regnode(BRANCH)); /* or */ regtail(ret, regnode(NOTHING)); /* null. */ } else if (op == '+' && (flags&SIMPLE)) reginsert(PLUS, ret); else if (op == '+') { /* Emit x+ as x(&|), where & means "self". */ next = regnode(BRANCH); /* Either */ regtail(ret, next); regtail(regnode(BACK), ret); /* loop back */ regtail(next, regnode(BRANCH)); /* or */ regtail(ret, regnode(NOTHING)); /* null. */ } else if (op == '?') { /* Emit x? as (x|) */ reginsert(BRANCH, ret); /* Either x */ regtail(ret, regnode(BRANCH)); /* or */ next = regnode(NOTHING); /* null. */ regtail(ret, next); regoptail(ret, next); } regparse++; if (ISMULT(*regparse)) FAIL("nested *?+"); return(ret); } /* - regatom - the lowest level * * Optimization: gobbles an entire sequence of ordinary characters so that * it can turn them into a single node, which is smaller to store and * faster to run. Backslashed characters are exceptions, each becoming a * separate node; the code is simpler that way and it's not worth fixing. */ static char * regatom(flagp) int *flagp; { register char *ret; int flags; *flagp = WORST; /* Tentatively. */ switch (*regparse++) { case '^': ret = regnode(BOL); break; case '$': ret = regnode(EOL); break; case '.': ret = regnode(ANY); *flagp |= HASWIDTH|SIMPLE; break; case '[': { register int class; register int classend; if (*regparse == '^') { /* Complement of range. */ ret = regnode(ANYBUT); regparse++; } else ret = regnode(ANYOF); if (*regparse == ']' || *regparse == '-') regc(*regparse++); while (*regparse != '\0' && *regparse != ']') { if (*regparse == '-') { regparse++; if (*regparse == ']' || *regparse == '\0') regc('-'); else { class = UCHARAT(regparse-2)+1; classend = UCHARAT(regparse); if (class > classend+1) FAIL("invalid [] range"); for (; class <= classend; class++) regc(class); regparse++; } } else regc(*regparse++); } regc('\0'); if (*regparse != ']') FAIL("unmatched []"); regparse++; *flagp |= HASWIDTH|SIMPLE; } break; case '(': ret = reg(1, &flags); if (ret == NULL) return(NULL); *flagp |= flags&(HASWIDTH|SPSTART); break; case '\0': case '|': case ')': FAIL("internal urp"); /* Supposed to be caught earlier. */ break; case '?': case '+': case '*': FAIL("?+* follows nothing"); break; case '\\': if (*regparse == '\0') FAIL("trailing \\"); ret = regnode(EXACTLY); regc(*regparse++); regc('\0'); *flagp |= HASWIDTH|SIMPLE; break; default: { register int len; register char ender; regparse--; len = strcspn(regparse, META); if (len <= 0) FAIL("internal disaster"); ender = *(regparse+len); if (len > 1 && ISMULT(ender)) len--; /* Back off clear of ?+* operand. */ *flagp |= HASWIDTH; if (len == 1) *flagp |= SIMPLE; ret = regnode(EXACTLY); while (len > 0) { regc(*regparse++); len--; } regc('\0'); } break; } return(ret); } /* - regnode - emit a node */ static char * /* Location. */ regnode(op) char op; { register char *ret; register char *ptr; ret = regcode; if (ret == ®dummy) { regsize += 3; return(ret); } ptr = ret; *ptr++ = op; *ptr++ = '\0'; /* Null "next" pointer. */ *ptr++ = '\0'; regcode = ptr; return(ret); } /* - regc - emit (if appropriate) a byte of code */ static void regc(b) char b; { if (regcode != ®dummy) *regcode++ = b; else regsize++; } /* - reginsert - insert an operator in front of already-emitted operand * * Means relocating the operand. */ static void reginsert(op, opnd) char op; char *opnd; { register char *src; register char *dst; register char *place; if (regcode == ®dummy) { regsize += 3; return; } src = regcode; regcode += 3; dst = regcode; while (src > opnd) *--dst = *--src; place = opnd; /* Op node, where operand used to be. */ *place++ = op; *place++ = '\0'; *place++ = '\0'; } /* - regtail - set the next-pointer at the end of a node chain */ static void regtail(p, val) char *p; char *val; { register char *scan; register char *temp; register int offset; if (p == ®dummy) return; /* Find last node. */ scan = p; for (;;) { temp = regnext(scan); if (temp == NULL) break; scan = temp; } if (OP(scan) == BACK) offset = scan - val; else offset = val - scan; *(scan+1) = (offset>>8)&0377; *(scan+2) = offset&0377; } /* - regoptail - regtail on operand of first argument; nop if operandless */ static void regoptail(p, val) char *p; char *val; { /* "Operandless" and "op != BRANCH" are synonymous in practice. */ if (p == NULL || p == ®dummy || OP(p) != BRANCH) return; regtail(OPERAND(p), val); } /* * regexec and friends */ /* * Global work variables for regexec(). */ static char *reginput; /* String-input pointer. */ static char *regbol; /* Beginning of input, for ^ check. */ static char **regstartp; /* Pointer to startp array. */ static char **regendp; /* Ditto for endp. */ /* * Forwards. */ STATIC int regtry(); STATIC int regmatch(); STATIC int regrepeat(); #ifdef DEBUG int regnarrate = 0; void regdump(); STATIC char *regprop(); #endif /* - regexec - match a regexp against a string */ int regexec(prog, string) register regexp *prog; register char *string; { register char *s; extern char *strchr(); /* Be paranoid... */ if (prog == NULL || string == NULL) { regerror("NULL parameter"); return(0); } /* Check validity of program. */ if (UCHARAT(prog->program) != MAGIC) { regerror("corrupted program"); return(0); } /* If there is a "must appear" string, look for it. */ if (prog->regmust != NULL) { s = string; while ((s = strchr(s, prog->regmust[0])) != NULL) { if (strncmp(s, prog->regmust, prog->regmlen) == 0) break; /* Found it. */ s++; } if (s == NULL) /* Not present. */ return(0); } /* Mark beginning of line for ^ . */ regbol = string; /* Simplest case: anchored match need be tried only once. */ if (prog->reganch) return(regtry(prog, string)); /* Messy cases: unanchored match. */ s = string; if (prog->regstart != '\0') /* We know what char it must start with. */ while ((s = strchr(s, prog->regstart)) != NULL) { if (regtry(prog, s)) return(1); s++; } else /* We don't -- general case. */ do { if (regtry(prog, s)) return(1); } while (*s++ != '\0'); /* Failure. */ return(0); } /* - regtry - try match at specific point */ static int /* 0 failure, 1 success */ regtry(prog, string) regexp *prog; char *string; { register int i; register char **sp; register char **ep; reginput = string; regstartp = prog->startp; regendp = prog->endp; sp = prog->startp; ep = prog->endp; for (i = NSUBEXP; i > 0; i--) { *sp++ = NULL; *ep++ = NULL; } if (regmatch(prog->program + 1)) { prog->startp[0] = string; prog->endp[0] = reginput; return(1); } else return(0); } /* - regmatch - main matching routine * * Conceptually the strategy is simple: check to see whether the current * node matches, call self recursively to see whether the rest matches, * and then act accordingly. In practice we make some effort to avoid * recursion, in particular by going through "ordinary" nodes (that don't * need to know whether the rest of the match failed) by a loop instead of * by recursion. */ static int /* 0 failure, 1 success */ regmatch(prog) char *prog; { register char *scan; /* Current node. */ char *next; /* Next node. */ extern char *strchr(); scan = prog; #ifdef DEBUG if (scan != NULL && regnarrate) fprintf(stderr, "%s(\n", regprop(scan)); #endif while (scan != NULL) { #ifdef DEBUG if (regnarrate) fprintf(stderr, "%s...\n", regprop(scan)); #endif next = regnext(scan); switch (OP(scan)) { case BOL: if (reginput != regbol) return(0); break; case EOL: if (*reginput != '\0') return(0); break; case ANY: if (*reginput == '\0') return(0); reginput++; break; case EXACTLY: { register int len; register char *opnd; opnd = OPERAND(scan); /* Inline the first character, for speed. */ if (*opnd != *reginput) return(0); len = strlen(opnd); if (len > 1 && strncmp(opnd, reginput, len) != 0) return(0); reginput += len; } break; case ANYOF: if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL) return(0); reginput++; break; case ANYBUT: if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL) return(0); reginput++; break; case NOTHING: break; case BACK: break; case OPEN+1: case OPEN+2: case OPEN+3: case OPEN+4: case OPEN+5: case OPEN+6: case OPEN+7: case OPEN+8: case OPEN+9: { register int no; register char *save; no = OP(scan) - OPEN; save = reginput; if (regmatch(next)) { /* * Don't set startp if some later * invocation of the same parentheses * already has. */ if (regstartp[no] == NULL) regstartp[no] = save; return(1); } else return(0); } break; case CLOSE+1: case CLOSE+2: case CLOSE+3: case CLOSE+4: case CLOSE+5: case CLOSE+6: case CLOSE+7: case CLOSE+8: case CLOSE+9: { register int no; register char *save; no = OP(scan) - CLOSE; save = reginput; if (regmatch(next)) { /* * Don't set endp if some later * invocation of the same parentheses * already has. */ if (regendp[no] == NULL) regendp[no] = save; return(1); } else return(0); } break; case BRANCH: { register char *save; if (OP(next) != BRANCH) /* No choice. */ next = OPERAND(scan); /* Avoid recursion. */ else { do { save = reginput; if (regmatch(OPERAND(scan))) return(1); reginput = save; scan = regnext(scan); } while (scan != NULL && OP(scan) == BRANCH); return(0); /* NOTREACHED */ } } break; case STAR: case PLUS: { register char nextch; register int no; register char *save; register int min; /* * Lookahead to avoid useless match attempts * when we know what character comes next. */ nextch = '\0'; if (OP(next) == EXACTLY) nextch = *OPERAND(next); min = (OP(scan) == STAR) ? 0 : 1; save = reginput; no = regrepeat(OPERAND(scan)); while (no >= min) { /* If it could work, try it. */ if (nextch == '\0' || *reginput == nextch) if (regmatch(next)) return(1); /* Couldn't or didn't -- back up. */ no--; reginput = save + no; } return(0); } break; case END: return(1); /* Success! */ break; default: regerror("memory corruption"); return(0); break; } scan = next; } /* * We get here only if there's trouble -- normally "case END" is * the terminating point. */ regerror("corrupted pointers"); return(0); } /* - regrepeat - repeatedly match something simple, report how many */ static int regrepeat(p) char *p; { register int count = 0; register char *scan; register char *opnd; scan = reginput; opnd = OPERAND(p); switch (OP(p)) { case ANY: count = strlen(scan); scan += count; break; case EXACTLY: while (*opnd == *scan) { count++; scan++; } break; case ANYOF: while (*scan != '\0' && strchr(opnd, *scan) != NULL) { count++; scan++; } break; case ANYBUT: while (*scan != '\0' && strchr(opnd, *scan) == NULL) { count++; scan++; } break; default: /* Oh dear. Called inappropriately. */ regerror("internal foulup"); count = 0; /* Best compromise. */ break; } reginput = scan; return(count); } /* - regnext - dig the "next" pointer out of a node */ static char * regnext(p) register char *p; { register int offset; if (p == ®dummy) return(NULL); offset = NEXT(p); if (offset == 0) return(NULL); if (OP(p) == BACK) return(p-offset); else return(p+offset); } #ifdef DEBUG STATIC char *regprop(); /* - regdump - dump a regexp onto stdout in vaguely comprehensible form */ void regdump(r) regexp *r; { register char *s; register char op = EXACTLY; /* Arbitrary non-END op. */ register char *next; extern char *strchr(); s = r->program + 1; while (op != END) { /* While that wasn't END last time... */ op = OP(s); printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */ next = regnext(s); if (next == NULL) /* Next ptr. */ printf("(0)"); else printf("(%d)", (s-r->program)+(next-s)); s += 3; if (op == ANYOF || op == ANYBUT || op == EXACTLY) { /* Literal string, where present. */ while (*s != '\0') { putchar(*s); s++; } s++; } putchar('\n'); } /* Header fields of interest. */ if (r->regstart != '\0') printf("start `%c' ", r->regstart); if (r->reganch) printf("anchored "); if (r->regmust != NULL) printf("must have \"%s\"", r->regmust); printf("\n"); } /* - regprop - printable representation of opcode */ static char * regprop(op) char *op; { register char *p; static char buf[50]; (void) strcpy(buf, ":"); switch (OP(op)) { case BOL: p = "BOL"; break; case EOL: p = "EOL"; break; case ANY: p = "ANY"; break; case ANYOF: p = "ANYOF"; break; case ANYBUT: p = "ANYBUT"; break; case BRANCH: p = "BRANCH"; break; case EXACTLY: p = "EXACTLY"; break; case NOTHING: p = "NOTHING"; break; case BACK: p = "BACK"; break; case END: p = "END"; break; case OPEN+1: case OPEN+2: case OPEN+3: case OPEN+4: case OPEN+5: case OPEN+6: case OPEN+7: case OPEN+8: case OPEN+9: sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN); p = NULL; break; case CLOSE+1: case CLOSE+2: case CLOSE+3: case CLOSE+4: case CLOSE+5: case CLOSE+6: case CLOSE+7: case CLOSE+8: case CLOSE+9: sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE); p = NULL; break; case STAR: p = "STAR"; break; case PLUS: p = "PLUS"; break; default: regerror("corrupted opcode"); break; } if (p != NULL) (void) strcat(buf, p); return(buf); } #endif /* * The following is provided for those people who do not have strcspn() in * their C libraries. They should get off their butts and do something * about it; at least one public-domain implementation of those (highly * useful) string routines has been published on Usenet. */ #ifdef STRCSPN /* * strcspn - find length of initial segment of s1 consisting entirely * of characters not from s2 */ static int strcspn(s1, s2) char *s1; char *s2; { register char *scan1; register char *scan2; register int count; count = 0; for (scan1 = s1; *scan1 != '\0'; scan1++) { for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */ if (*scan1 == *scan2++) return(count); count++; } return(count); } #endif xfaces-3.3/regsub.c 444 227 12 3537 5540460226 13134 0ustar liebmanstaff/* * regsub * * Copyright (c) 1986 by University of Toronto. * Written by Henry Spencer. Not derived from licensed software. * * Permission is granted to anyone to use this software for any * purpose on any computer system, and to redistribute it freely, * subject to the following restrictions: * * 1. The author is not responsible for the consequences of use of * this software, no matter how awful, even if they arise * from defects in it. * * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. */ #include #include "regexp.h" #include "regmagic.h" #ifndef CHARBITS #define UCHARAT(p) ((int)*(unsigned char *)(p)) #else #define UCHARAT(p) ((int)*(p)&CHARBITS) #endif /* - regsub - perform substitutions after a regexp match */ void regsub(prog, source, dest) regexp *prog; char *source; char *dest; { register char *src; register char *dst; register char c; register int no; register int len; extern char *strncpy(); if (prog == NULL || source == NULL || dest == NULL) { regerror("NULL parm to regsub"); return; } if (UCHARAT(prog->program) != MAGIC) { regerror("damaged regexp fed to regsub"); return; } src = source; dst = dest; while ((c = *src++) != '\0') { if (c == '&') no = 0; else if (c == '\\' && '0' <= *src && *src <= '9') no = *src++ - '0'; else no = -1; if (no < 0) /* Ordinary character. */ *dst++ = c; else if (prog->startp[no] != NULL && prog->endp[no] != NULL) { len = prog->endp[no] - prog->startp[no]; (void) strncpy(dst, prog->startp[no], len); dst += len; if (len != 0 && *(dst-1) == '\0') { /* strncpy hit NUL. */ regerror("damaged match string"); return; } } } *dst++ = '\0'; } xfaces-3.3/string.c 444 227 12 5425 5540460227 13152 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * * * Author : Chris Liebman * Created On : Mon Jan 31 22:31:39 1994 * Last Modified By: Chris Liebman * Last Modified On: Mon Jan 31 23:22:48 1994 * Update Count : 5 * Status : Released * * HISTORY * * PURPOSE * Misc string functions. */ #ifndef lint static char *RCSid = "$Id: string.c,v 1.2 1994/02/01 04:25:32 liebman Exp $"; #endif #include "faces.h" char** StringParse(str, delims) char* str; char* delims; { char* name; int count = 0; int array_size = 0; char** array = NULL; if (str == NULL) { return NULL; } array_size = 10; array = (char**)XtMalloc(array_size * sizeof(char*)); while((name = ParseToken(&str, delims)) != NULL) { if (count >= array_size) { array_size += 10; array = (char**)XtRealloc((char*)array, array_size * sizeof(char*)); } array[count++] = name; } array[count] = NULL; return array; } String SkipChars(str, delim) String str; String delim; { while((*str != '\0') && (index(delim, *str) != NULL)) { ++str; } return(str); } String ParseToken(str, delim) String *str; String delim; { String token; *str = SkipChars(*str, delim); if (**str == '\0') { return(NULL); } token = *str; while(index(delim, **str) == NULL) { ++(*str); } /* * We are now pointing at the first delim, change it to a NULL. */ if (**str != '\0') { **str = '\0'; ++(*str); } return(token); } xfaces-3.3/face_sound.c 444 227 12 22162 5540460227 13767 0ustar liebmanstaff/* -*- Mode: C++-C -*- * * Copyright 1994 Christopher B. Liebman * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name Christopher B. Liebman not * be used in advertising or publicity pertaining to distribution of this * software without specific, written prior permission. * * THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER * B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL, * INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR * PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author : Chris Liebman * Created On : Tue Jan 11 14:11:30 1994 * Last Modified By: Chris Liebman * Last Modified On: Sat Feb 12 23:11:34 1994 * Update Count : 40 * Status : Released * * HISTORY * 31-Jan-1994 Chris Liebman * Last Modified: Sat Jan 29 23:56:11 1994 #35 (Chris Liebman) * Major changes for new search stuff. * * 24-Jan-1994 Chris Liebman * Last Modified: Sun Jan 23 16:03:49 1994 #19 (Chris Liebman) * Added path support and moved all sound checking here. * * 14-Jan-1994 Chris Liebman * Last Modified: Wed Jan 12 11:58:51 1994 #4 (Chris Liebman) * added #if to use XtDatabase() for versions of Xt less than 5 * * * PURPOSE * Sound support using NetAudio. */ #ifndef lint static char *RCSid = "$Id: face_sound.c,v 1.17 1994/03/07 20:27:46 liebman Exp $"; #endif #include "faces.h" #include