From 60cd1ff0635fdeda3c5a2cafee2d9a53f82cae0d Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Sun, 15 Mar 2009 22:13:16 +0000 Subject: cmu/zwgcplus changes --- acconfig.h | 12 +++ clients/zctl/zctl.c | 238 +++++++++++++++++++++++++++++++++++++++++++++- clients/zctl/zctl_cmds.ct | 10 ++ configure | 118 +++++++++++++++++------ configure.in | 28 ++++++ debian/rules | 6 +- h/config.h.in | 12 +++ h/zephyr/zephyr.h | 3 +- lib/Makefile.in | 2 +- lib/ZSubs.c | 10 ++ zwgc/Makefile.in | 2 +- zwgc/X_driver.c | 3 + zwgc/X_gram.c | 18 +++- zwgc/X_gram.h | 3 + zwgc/exec.c | 10 ++ zwgc/main.c | 184 +++++++++++++++++++++++++++++++---- zwgc/mux.c | 16 +++- zwgc/notice.c | 28 +++++- zwgc/subscriptions.c | 16 +++- zwgc/xcut.c | 51 +++++++++- zwgc/xshow.c | 199 ++++++++++++++++++++++++++++++++++++++ zwgc/zephyr.c | 10 ++ 22 files changed, 914 insertions(+), 65 deletions(-) diff --git a/acconfig.h b/acconfig.h index b4ec827..75d4b43 100644 --- a/acconfig.h +++ b/acconfig.h @@ -7,6 +7,18 @@ /* Define to compile with Kerberos v5 support. */ #undef HAVE_KRB5 +/* Define to allow users to locate themselves if they are opstaff */ +#undef OPSTAFF_LOCATE_SELF + +/* Define to get hm_flush restrictions in zctl */ +#undef HM_FLUSH_RESTRICT + +/* Define to pull in CMU zctl punt backward compat foo */ +#undef CMU_ZCTL_PUNT + +/* Define to enable zwgcplus support */ +#undef CMU_ZWGCPLUS + /* Define to 1 if `enc_part2' is member of `krb5_ticket'. */ #undef HAVE_KRB5_TICKET_ENC_PART2 diff --git a/clients/zctl/zctl.c b/clients/zctl/zctl.c index e48a651..9624550 100644 --- a/clients/zctl/zctl.c +++ b/clients/zctl/zctl.c @@ -660,6 +660,10 @@ load_subs(int argc, char *argv[]) { ZSubscription_t subs[SUBSATONCE],subs2[SUBSATONCE],unsubs[SUBSATONCE]; +#ifdef CMU_ZCTL_PUNT + ZSubscription_t punts[SUBSATONCE]; + int pind; +#endif FILE *fp; int ind,unind,lineno,i,retval,type; short wgport; @@ -695,7 +699,10 @@ load_subs(int argc, return; } - ind = unind = 0; +#ifdef CMU_ZCTL_PUNT + pind = +#endif + ind = unind = 0; lineno = 1; for (;;lineno++) { @@ -721,6 +728,11 @@ load_subs(int argc, if (*subline == '!') printf("(Un-subscription) Class %s instance %s recipient %s\n", subline+1, comma+1, comma2+1); +#ifdef CMU_ZCTL_PUNT + else if(*subline == '-') + printf("(Punted) Class %s instance %s recipient %s\n", + subline+1, comma+1, comma2+1); +#endif else printf("Class %s instance %s recipient %s\n", subline, comma+1, comma2+1); @@ -746,7 +758,27 @@ load_subs(int argc, /* XXX check malloc return */ (void) strcpy(unsubs[unind].zsub_recipient,comma2+1); unind++; - } else { + } else +#ifdef CMU_ZCTL_PUNT + if (*subline == '-') { /* a punt */ + if (type == UNSUB) + continue; + punts[pind].zsub_class = + (char *)malloc((unsigned)(strlen(subline)+1)); + /* XXX check malloc return */ + (void) strcpy(punts[pind].zsub_class,subline+1); + punts[pind].zsub_classinst = + (char *)malloc((unsigned)(strlen(comma+1)+1)); + /* XXX check malloc return */ + (void) strcpy(punts[pind].zsub_classinst,comma+1); + punts[pind].zsub_recipient = + (char *)malloc((unsigned)(strlen(comma2+1)+1)); + /* XXX check malloc return */ + (void) strcpy(punts[pind].zsub_recipient,comma2+1); + pind++; + } else +#endif + { subs[ind].zsub_class = (char *)malloc((unsigned)(strlen(subline)+1)); /* XXX check malloc return */ @@ -761,6 +793,24 @@ load_subs(int argc, (void) strcpy(subs[ind].zsub_recipient,comma2+1); ind++; } +#ifdef CMU_ZCTL_PUNT + if (pind == SUBSATONCE) { + fix_macros(punts,subs2,pind); + if (retval = ZPunt(subs2,pind,(u_short)wgport) != + ZERR_NONE) + { + ss_perror(sci_idx,retval, + "while punting"); + goto cleanup; + } + for (i=0;i\n", punt ? "Punting" : "Unpunting", + class, inst, *recip ? recip : "*"); + + memset((char *) ¬ice, 0, sizeof(ZNotice_t)); + notice.z_kind = UNSAFE; + notice.z_class = WG_CTL_CLASS; + notice.z_class_inst = WG_CTL_USER; + notice.z_recipient = ""; + notice.z_default_format = ""; + notice.z_opcode = (punt) ? "SUPPRESS" : "UNSUPPRESS"; + notice.z_port = 0; + notice.z_message = msg; + notice.z_message_len = strlen(class)+strlen(inst)+strlen(recip)+3; + + if ((retval = ZSendNotice(¬ice,ZNOAUTH)) != ZERR_NONE) + fprintf(stderr,"%s: while sending notice\n",whoami); + + free(msg); + + ZClosePort(); +#endif + return 0; +} + +list_punts(argc, argv) +int argc; +char **argv; +{ +#ifdef CMU_ZCTL_PUNT + ZNotice_t notice; + int retval, lensofar; + struct sockaddr_in old, to, from; + u_short ourport, zwgcport; + char *msg; + + ourport=0; + retval = ZOpenPort(&ourport); + if(retval != ZERR_NONE) { + com_err("zctl", retval, "while opening Zephyr port."); + return 1; + } + + old = ZGetDestAddr(); + to = old; + if ((zwgcport = ZGetWGPort()) == (u_short)-1) { + fprintf(stderr, "zctl: Can't find windowgram port\n"); + return 1; + } + + to.sin_port = (u_short) zwgcport; + if ((retval = ZSetDestAddr(&to)) != ZERR_NONE) { + com_err("zctl",retval,"while setting destination address"); + return 1; + } + + memset((char *) ¬ice, 0, sizeof(ZNotice_t)); + notice.z_kind = UNSAFE; + notice.z_class = WG_CTL_CLASS; + notice.z_class_inst = WG_CTL_USER; + notice.z_recipient = ""; + notice.z_default_format = ""; + notice.z_opcode = "LIST-SUPPRESSED" /*USER_LIST_SUPPRESSED*/; + notice.z_port = ourport; + notice.z_message = NULL; + notice.z_message_len = 0; + + if ((retval = ZSendNotice(¬ice,ZNOAUTH)) != ZERR_NONE) + com_err("zctl",retval,"while sending notice"); + + if ((retval = ZReceiveNotice(¬ice,&from)) != ZERR_NONE) + com_err("zctl",retval,"while receiving ack"); + + (void) ZFreeNotice(¬ice); + + if ((retval = ZReceiveNotice(¬ice,&from)) != ZERR_NONE) + com_err("zctl",retval,"while receiving notice"); + + notice.z_auth = ZCheckAuthentication(¬ice, &from); + + if ((retval = ZSetDestAddr(&old)) != ZERR_NONE) { + com_err("zctl",retval,"while resetting destination address"); + return 1; + } + + msg = (char *) malloc((notice.z_message_len+1) * sizeof(char)); + (void) strncpy(msg,notice.z_message, notice.z_message_len); + msg[notice.z_message_len]=(char)0; + printf("%s", msg); + (void) free(msg); + (void) ZFreeNotice(¬ice); + (void) ZClosePort(); + +#endif /* CMU_ZCTL_PUNT */ + return 0; +} diff --git a/clients/zctl/zctl_cmds.ct b/clients/zctl/zctl_cmds.ct index 374effc..2f7bbbb 100644 --- a/clients/zctl/zctl_cmds.ct +++ b/clients/zctl/zctl_cmds.ct @@ -84,5 +84,15 @@ request ss_quit, "Quit.", quit, exit, q; +#ifdef CMU_BACKWARD_COMPAT + request do_punt, "Ignore specified messages.", + punt; + request do_punt, "Stop ignoring specified messages.", + unpunt; + + request list_punts, "List current messages to ignore.", + list_punts, lp; + +#endif end; diff --git a/configure b/configure index fd0033e..233ecf1 100755 --- a/configure +++ b/configure @@ -1468,6 +1468,10 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) + --enable-cmu-zwgcplus enable CMU zwgcplus extensions + --enable-cmu-zctl-punt enable CMU zctl punt extensions + --enable-cmu-hm-flush-restrict enable CMU zctl hm flush restriction + --enable-cmu-opstaff-locate-self enable CMU opstaff locate-self ability Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -4142,7 +4146,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 4145 "configure"' > conftest.$ac_ext + echo '#line 4149 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6708,11 +6712,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6711: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6715: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6715: \$? = $ac_status" >&5 + echo "$as_me:6719: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -6941,11 +6945,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6944: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6948: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6948: \$? = $ac_status" >&5 + echo "$as_me:6952: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -7001,11 +7005,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7004: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7008: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7008: \$? = $ac_status" >&5 + echo "$as_me:7012: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8331,7 +8335,7 @@ linux*) libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) - echo '#line 8334 "configure"' > conftest.$ac_ext + echo '#line 8338 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -9169,7 +9173,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:11453: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:11453: \$? = $ac_status" >&5 + echo "$as_me:11457: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -11506,11 +11510,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11509: $lt_compile\"" >&5) + (eval echo "\"\$as_me:11513: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:11513: \$? = $ac_status" >&5 + echo "$as_me:11517: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12017,7 +12021,7 @@ linux*) libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) - echo '#line 12020 "configure"' > conftest.$ac_ext + echo '#line 12024 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -12855,7 +12859,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:13787: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13787: \$? = $ac_status" >&5 + echo "$as_me:13791: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -13840,11 +13844,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13843: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13847: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13847: \$? = $ac_status" >&5 + echo "$as_me:13851: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15150,7 +15154,7 @@ linux*) libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) - echo '#line 15153 "configure"' > conftest.$ac_ext + echo '#line 15157 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -15894,11 +15898,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15897: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15901: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15901: \$? = $ac_status" >&5 + echo "$as_me:15905: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -16127,11 +16131,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16130: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16134: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16134: \$? = $ac_status" >&5 + echo "$as_me:16138: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -16187,11 +16191,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16190: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16194: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16194: \$? = $ac_status" >&5 + echo "$as_me:16198: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17517,7 +17521,7 @@ linux*) libsuff= case "$host_cpu" in x86_64*|s390x*|powerpc64*) - echo '#line 17520 "configure"' > conftest.$ac_ext + echo '#line 17524 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -18355,7 +18359,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5 echo "${ECHO_T}$ac_cv_have_krb5_creds_keyblock_enctype" >&6; } +# Check whether --enable-cmu-zwgcplus was given. +if test "${enable_cmu_zwgcplus+set}" = set; then + enableval=$enable_cmu_zwgcplus; +if test "$enableval" = "yes"; then + cat >>confdefs.h <<\_ACEOF +#define CMU_ZWGCPLUS 1 +_ACEOF + +fi + +fi + + +# Check whether --enable-cmu-zctl-punt was given. +if test "${enable_cmu_zctl_punt+set}" = set; then + enableval=$enable_cmu_zctl_punt; +if test "$enableval" = "yes"; then + cat >>confdefs.h <<\_ACEOF +#define CMU_ZCTL_PUNT 1 +_ACEOF + +fi + +fi + + +# Check whether --enable-cmu-hm-flush-restrict was given. +if test "${enable_cmu_hm_flush_restrict+set}" = set; then + enableval=$enable_cmu_hm_flush_restrict; +if test "$enableval" = "yes"; then + cat >>confdefs.h <<\_ACEOF +#define HM_FLUSH_RESTRICT 1 +_ACEOF + +fi + +fi + + +# Check whether --enable-cmu-opstaff-locate-self was given. +if test "${enable_cmu_opstaff_locate_self+set}" = set; then + enableval=$enable_cmu_opstaff_locate_self; +if test "$enableval" = "yes"; then + cat >>confdefs.h <<\_ACEOF +#define OPSTAFF_LOCATE_SELF 1 +_ACEOF + +fi + +fi + + ac_config_headers="$ac_config_headers h/config.h" ac_config_files="$ac_config_files Makefile clients/Makefile clients/zaway/Makefile clients/zctl/Makefile clients/zleave/Makefile clients/zlocate/Makefile clients/znol/Makefile clients/zshutdown_notify/Makefile clients/zstat/Makefile clients/zwrite/Makefile lib/Makefile libdyn/Makefile server/Makefile zhm/Makefile zwgc/Makefile" diff --git a/configure.in b/configure.in index 72e9dd5..078aa09 100644 --- a/configure.in +++ b/configure.in @@ -184,6 +184,34 @@ if test "$ac_cv_have_krb5_creds_keyblock_enctype" = yes; then fi AC_MSG_RESULT($ac_cv_have_krb5_creds_keyblock_enctype) +AC_ARG_ENABLE(cmu-zwgcplus, +[ --enable-cmu-zwgcplus enable CMU zwgcplus extensions],[ +if test "$enableval" = "yes"; then + AC_DEFINE(CMU_ZWGCPLUS,1) +fi +]) + +AC_ARG_ENABLE(cmu-zctl-punt, +[ --enable-cmu-zctl-punt enable CMU zctl punt extensions],[ +if test "$enableval" = "yes"; then + AC_DEFINE(CMU_ZCTL_PUNT,1) +fi +]) + +AC_ARG_ENABLE(cmu-hm-flush-restrict, +[ --enable-cmu-hm-flush-restrict enable CMU zctl hm flush restriction],[ +if test "$enableval" = "yes"; then + AC_DEFINE(HM_FLUSH_RESTRICT,1) +fi +]) + +AC_ARG_ENABLE(cmu-opstaff-locate-self, +[ --enable-cmu-opstaff-locate-self enable CMU opstaff locate-self ability],[ +if test "$enableval" = "yes"; then + AC_DEFINE(OPSTAFF_LOCATE_SELF,1) +fi +]) + AC_CONFIG_HEADER(h/config.h) AC_OUTPUT(Makefile clients/Makefile clients/zaway/Makefile clients/zctl/Makefile clients/zleave/Makefile diff --git a/debian/rules b/debian/rules index d834423..bd64b82 100755 --- a/debian/rules +++ b/debian/rules @@ -11,7 +11,9 @@ # This has to be exported to make some magic below work. export DH_OPTIONS -CONFIGURE_ROOT=--prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --sysconfdir=/etc --datadir=/etc --with-ares=/usr --with-hesiod=/usr +CONFIGURE_ROOT=--prefix=/usr --mandir=\$${prefix}/share/man \ + --infodir=\$${prefix}/share/info --sysconfdir=/etc --datadir=/etc \ + --with-ares=/usr --with-hesiod=/usr --enable-cmu-zwgcplus # see /usr/share/doc/autotools-dev/README.Debian.gz export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) @@ -50,7 +52,7 @@ configure-stamp: dh_testdir # Add here commands to configure the package. -mkdir krb5 - cd krb5 && CFLAGS="-g -O" ../configure --with-krb5=/usr --with-openssl=/usr $(CONFIGURE_ROOT) + cd krb5 && CFLAGS="-g -O" ../configure --with-krb5=/usr $(CONFIGURE_ROOT) -mkdir krb45 cd krb45 && CFLAGS="-g -O" ../configure --with-krb4=/usr --with-krb5=/usr $(CONFIGURE_ROOT) -mkdir krb4 diff --git a/h/config.h.in b/h/config.h.in index bf03675..33657b5 100644 --- a/h/config.h.in +++ b/h/config.h.in @@ -8,6 +8,18 @@ /* Define to compile with Kerberos v5 support. */ #undef HAVE_KRB5 +/* Define to allow users to locate themselves if they are opstaff */ +#undef OPSTAFF_LOCATE_SELF + +/* Define to get hm_flush restrictions in zctl */ +#undef HM_FLUSH_RESTRICT + +/* Define to pull in CMU zctl punt backward compat foo */ +#undef CMU_ZCTL_PUNT + +/* Define to enable zwgcplus support */ +#undef CMU_ZWGCPLUS + /* Define to 1 if `enc_part2' is member of `krb5_ticket'. */ #undef HAVE_KRB5_TICKET_ENC_PART2 diff --git a/h/zephyr/zephyr.h b/h/zephyr/zephyr.h index a19f050..2c6a543 100644 --- a/h/zephyr/zephyr.h +++ b/h/zephyr/zephyr.h @@ -239,6 +239,7 @@ const char *ZCharsetToString(unsigned short charset); #ifdef Z_DEBUG void Z_debug(const char *, ...); #endif +char *ZExpandRealm(char *realm); /* Compatibility */ #define ZNewLocateUser ZLocateUser @@ -251,7 +252,7 @@ struct sockaddr_in ZGetDestAddr (void); #ifdef Z_DEBUG -void ZSetDebug ZP((void (*)(const char *, va_list, void *), void *)); +void ZSetDebug (void (*)(const char *, va_list, void *), void *); #define ZSetDebug(proc,closure) (__Z_debug_print=(proc), \ __Z_debug_print_closure=(closure), \ (void) 0) diff --git a/lib/Makefile.in b/lib/Makefile.in index 8a9cd2d..6823fc3 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -40,7 +40,7 @@ OBJS = zephyr_err.lo ZAsyncLocate.lo ZCkAuth.lo ZCkIfNot.lo ZClosePort.lo \ ZRecvNot.lo ZRecvPkt.lo ZRetSubs.lo ZSendList.lo ZSendNot.lo \ ZSendPkt.lo ZSendRaw.lo ZSendRLst.lo ZSetDest.lo ZSetFD.lo ZSetSrv.lo \ ZSubs.lo ZVariables.lo ZWait4Not.lo Zinternal.lo ZMakeZcode.lo \ - ZReadZcode.lo ZCkZAut.lo quad_cksum.lo charset.lo + ZReadZcode.lo ZCkZAut.lo quad_cksum.lo charset.lo ZExpnRlm.lo .SUFFIXES: .lo diff --git a/lib/ZSubs.c b/lib/ZSubs.c index e8519fe..3a241db 100644 --- a/lib/ZSubs.c +++ b/lib/ZSubs.c @@ -23,6 +23,16 @@ static Code_t Z_Subscriptions(register ZSubscription_t *sublist, static Code_t subscr_sendoff(ZNotice_t *notice, char **lyst, int num, int authit); +#ifdef CMU_ZCTL_PUNT +Code_t +ZPunt(ZSubscription_t *sublist, + int nitems, + unsigned int port) +{ + return (Z_Subscriptions(sublist, nitems, port, "SUPPRESS", 1)); +} +#endif + Code_t ZSubscribeTo(ZSubscription_t *sublist, int nitems, diff --git a/zwgc/Makefile.in b/zwgc/Makefile.in index b0f1476..f7b68a8 100644 --- a/zwgc/Makefile.in +++ b/zwgc/Makefile.in @@ -40,7 +40,7 @@ OBJS= port_dictionary.o pointer_dictionary.o unsigned_long_dictionary.o \ xcut.o regexp.o character_class.o text_operations.o file.o error.o \ variables.o formatter.o X_fonts.o X_gram.o tty_filter.o \ standard_ports.o xselect.o xmark.o xrevstack.o xerror.o \ - new_string.o new_memory.o + new_string.o new_memory.o plus.o all: zwgc diff --git a/zwgc/X_driver.c b/zwgc/X_driver.c index e969eb7..2a71cc2 100644 --- a/zwgc/X_driver.c +++ b/zwgc/X_driver.c @@ -224,6 +224,9 @@ static XrmOptionDescRec cmd_options[] = { {"-foreground", "*foreground", XrmoptionSepArg, (caddr_t) NULL}, {"-geometry", ".geometry", XrmoptionSepArg, (caddr_t) NULL}, {"-iconname", ".iconName", XrmoptionSepArg, (caddr_t) NULL}, +#ifdef CMU_ZWGCPLUS + {"-lifespan", "*lifespan", XrmoptionSepArg, (caddr_t) NULL}, +#endif {"-name", ".name", XrmoptionSepArg, (caddr_t) NULL}, {"-reverse", "*reverseVideo", XrmoptionNoArg, (caddr_t) "on"}, {"-rv", "*reverseVideo", XrmoptionNoArg, (caddr_t) "on"}, diff --git a/zwgc/X_gram.c b/zwgc/X_gram.c index 6ce4297..712d87a 100644 --- a/zwgc/X_gram.c +++ b/zwgc/X_gram.c @@ -34,6 +34,9 @@ static const char rcsid_X_gram_c[] = "$Id$"; #include "xrevstack.h" #include "xerror.h" #include "xselect.h" +#ifdef CMU_ZWGCPLUS +#include "plus.h" +#endif extern XContext desc_context; extern char *app_instance; @@ -47,7 +50,7 @@ int internal_border_width = 2; unsigned long default_fgcolor; unsigned long default_bgcolor; unsigned long default_bordercolor; -long ttl = 500; +long ttl = 0; static int reset_saver; static int border_width = 1; static int cursor_code = XC_sailboat; @@ -142,6 +145,16 @@ x_gram_init(Display *dpy) if (temp && atoi(temp)>=0) ttl = atoi(temp); +#ifdef CMU_ZWGCPLUS + if (ttl == 0) { + temp = get_string_resource("lifespan", "LifeSpan"); + if (temp && atoi(temp)>=0) + ttl = atoi(temp); + } + + get_full_names = get_bool_resource("getFullNames", "GetFullNames", 0); +#endif + reverse_stack = get_bool_resource("reverseStack", "ReverseStack", 0); reset_saver = get_bool_resource("resetSaver", "ResetSaver", 1); /* The default here should be 1, but mwm sucks */ @@ -222,6 +235,9 @@ x_gram_init(Display *dpy) xattributes.cursor = cursor; xattributes.event_mask = (ExposureMask|ButtonReleaseMask|ButtonPressMask |LeaveWindowMask|Button1MotionMask +#ifdef CMU_ZWGCPLUS + |KeyPressMask +#endif |Button3MotionMask|StructureNotifyMask); xattributes_mask = (CWBackPixel|CWBorderPixel|CWEventMask|CWCursor); diff --git a/zwgc/X_gram.h b/zwgc/X_gram.h index ed1adf7..d051f5e 100644 --- a/zwgc/X_gram.h +++ b/zwgc/X_gram.h @@ -39,6 +39,9 @@ typedef struct _x_gram { char *text; struct _x_gram *below,*above; Window w; +#ifdef CMU_ZWGCPLUS + char *notice; +#endif struct timeval can_die; } x_gram; diff --git a/zwgc/exec.c b/zwgc/exec.c index f24bcb8..9479ed5 100644 --- a/zwgc/exec.c +++ b/zwgc/exec.c @@ -453,6 +453,10 @@ void exec_process_packet(Node *program, ZNotice_t *notice) { +#ifdef CMU_ZWGCPLUS + set_stored_notice(notice); +#endif + notice_fields = notice->z_message; notice_fields_length = notice->z_message_len; @@ -466,4 +470,10 @@ exec_process_packet(Node *program, clear_buffer(); (void)exec_subtree(program); + +#ifdef CMU_ZWGCPLUS + plus_queue_notice(notice); + plus_window_deletions(notice); /* OOPS */ + set_stored_notice(NULL); +#endif } diff --git a/zwgc/main.c b/zwgc/main.c index 8584eca..3d0fda0 100644 --- a/zwgc/main.c +++ b/zwgc/main.c @@ -39,6 +39,13 @@ static const char rcsid_main_c[] = "$Id$"; #include "port.h" #include "variables.h" #include "main.h" +#ifdef CMU_ZCTL_PUNT +#include "int_dictionary.h" +#endif +#ifdef CMU_ZWGCPLUS +#include "plus.h" +int zwgcplus = 0; +#endif void notice_handler(ZNotice_t *); static void process_notice(ZNotice_t *, char *); @@ -48,6 +55,9 @@ static void signal_exit(int); #ifdef HAVE_ARES static void notice_callback(void *, int, struct hostent *); #endif +#ifdef CMU_ZWGCPLUS +void reprocess_notice(ZNotice_t *notice, char *hostname); +#endif /* * Global zwgc-wide variables: @@ -111,32 +121,42 @@ static struct _Node *program = NULL; static void fake_startup_packet(void) { - ZNotice_t notice; + ZNotice_t *notice = (ZNotice_t *)malloc(sizeof(ZNotice_t)); struct timezone tz; char msgbuf[BUFSIZ]; extern void Z_gettimeofday(struct _ZTimeval *, struct timezone *); var_set_variable("version", zwgc_version_string); - (void) memset(¬ice, 0, sizeof(notice)); - - notice.z_version = ""; - notice.z_class = "WG_CTL_CLASS"; - notice.z_class_inst = "WG_CTL_USER<<<>>>"; - notice.z_opcode = "WG_STARTUP"; - notice.z_default_format = "Zwgc mark II version $version now running...\n"; - notice.z_recipient = ""; - notice.z_sender = "ZWGC"; - Z_gettimeofday(¬ice.z_time, &tz); - notice.z_port = 0; - notice.z_kind = ACKED; - notice.z_auth = ZAUTH_YES; + (void) memset(notice, 0, sizeof(ZNotice_t)); + + notice->z_version = ""; + notice->z_class = "WG_CTL_CLASS"; + notice->z_class_inst = "WG_CTL_USER<<<>>>"; + notice->z_opcode = "WG_STARTUP"; + notice->z_default_format = "Zwgc mark II version $version now running...\n"; + notice->z_recipient = ""; + notice->z_sender = "ZWGC"; + Z_gettimeofday(¬ice->z_time, &tz); + notice->z_port = 0; + notice->z_kind = ACKED; + notice->z_auth = ZAUTH_YES; + notice->z_charset = ZCHARSET_UNKNOWN; sprintf(msgbuf,"Zwgc mark II version %s now running...", zwgc_version_string); - notice.z_message = msgbuf; - notice.z_message_len = strlen(notice.z_message)+1; + notice->z_message = msgbuf; + notice->z_message_len = strlen(notice->z_message)+1; - process_notice(¬ice, NULL); +#ifdef CMU_ZWGCPLUS + list_add_notice(notice); + set_notice_fake(notice, 1); +#endif + process_notice(notice, NULL); +#ifdef CMU_ZWGCPLUS + list_del_notice(notice); +#else + free(notice); +#endif } static void @@ -289,6 +309,9 @@ main(int argc, * Initialize various subsystems in proper order: */ dprintf("Initializing subsystems...\n"); /*<<<>>>*/ +#ifdef CMU_ZWGCPLUS + init_noticelist(); +#endif mux_init(); var_clear_all_variables(); /* <<<>>> */ init_ports(); /* <<<>>> */ @@ -311,6 +334,11 @@ main(int argc, dprintf("Test Zwgc parser.\n\n"); read_in_description_file(); +#ifdef CMU_ZWGCPLUS + if (strcmp(progname, "zwgcplus") == 0) + zwgcplus = 1; +#endif + dprintf("Entering main loop\n"); mux_loop(); @@ -329,11 +357,56 @@ main(int argc, #define USER_SUPPRESS "SUPPRESS" #define USER_UNSUPPRESS "UNSUPPRESS" +#ifdef CMU_ZCTL_PUNT +#define USER_LIST_SUPPRESSED "LIST-SUPPRESSED" + +#define PUNT_INC 1024 +extern int_dictionary puntable_addresses_dict; +ZNotice_t punt_reply; + +void +create_punt_reply(int_dictionary_binding *punt) +{ + string binding; + int key_len = strlen(punt->key); + char *tmp; + + if (!punt_reply.z_message) { + punt_reply.z_message = (char *)malloc(PUNT_INC); + punt_reply.z_message[0] = 0; + } + + if ((punt_reply.z_message_len + key_len + 1) / PUNT_INC > + (punt_reply.z_message_len + PUNT_INC - 1) / PUNT_INC) { + char *new_message = (char *)malloc((punt_reply.z_message_len + / PUNT_INC + 1) * PUNT_INC); + + strcpy(new_message, punt_reply.z_message); + + free(punt_reply.z_message); + punt_reply.z_message = new_message; + } + tmp = punt_reply.z_message + strlen(punt_reply.z_message); + strcat (punt_reply.z_message, punt->key); + strcat (punt_reply.z_message, "\n"); + punt_reply.z_message_len += key_len + 1; + + while (*tmp != '\001') tmp++; + *tmp = ','; + while (*tmp != '\001') tmp++; + *tmp = ','; +} +#endif /* CMU_ZCTL_PUNT */ + void notice_handler(ZNotice_t *notice) { struct hostent *fromhost = NULL; +#if defined(CMU_ZWGCPLUS) + list_add_notice(notice); +#endif + if (notice->z_sender_addr.s_addr) { #ifdef HAVE_ARES ares_gethostbyaddr(achannel, &(notice->z_sender_addr), @@ -346,8 +419,12 @@ notice_handler(ZNotice_t *notice) #endif } process_notice(notice, fromhost ? fromhost->h_name : NULL); +#ifdef CMU_ZWGCPLUS + /* Let list_del_notice clean up for us. */ +#else ZFreeNotice(notice); free(notice); +#endif } #ifdef HAVE_ARES @@ -358,9 +435,17 @@ notice_callback(void *arg, { ZNotice_t *notice = (ZNotice_t *) arg; +#ifdef CMU_ZWGCPLUS + plus_set_hname(notice, fromhost ? fromhost->h_name : NULL); +#endif + process_notice(notice, fromhost ? fromhost->h_name : NULL); +#ifdef CMU_ZWGCPLUS + list_del_notice(notice); +#else ZFreeNotice(notice); free(notice); +#endif } #endif @@ -408,12 +493,59 @@ process_notice(ZNotice_t *notice, free(class); free(instance); free(recipient); +#ifdef CMU_ZCTL_PUNT + } else if (!strcasecmp(control_opcode, USER_LIST_SUPPRESSED)) { + struct sockaddr_in old, to; + int retval; + + if (!notice->z_port) { + printf("zwgc: can't reply to LIST-SUPPRESSED request\n"); + return; + } + memset((char *) &punt_reply, 0, sizeof(ZNotice_t)); + punt_reply.z_kind = CLIENTACK; + punt_reply.z_class = WG_CTL_CLASS; + punt_reply.z_class_inst = "WG_REPLY"; + punt_reply.z_recipient = "zctl?"; + punt_reply.z_sender = "Zwgc"; + punt_reply.z_default_format = ""; + punt_reply.z_opcode = USER_LIST_SUPPRESSED; + punt_reply.z_port = notice->z_port; + punt_reply.z_message = NULL; + punt_reply.z_message_len = 0; + + if (puntable_addresses_dict) { + int_dictionary_Enumerate(puntable_addresses_dict, + create_punt_reply); + } + + old = ZGetDestAddr(); + to = old; + + to.sin_port = notice->z_port; + if ((retval = ZSetDestAddr(&to)) != ZERR_NONE) { + com_err("zwgc",retval,"while setting destination address"); + exit(1); + } + + ZSendNotice(&punt_reply, ZNOAUTH); + + if ((retval = ZSetDestAddr(&old)) != ZERR_NONE) { + com_err("zwgc",retval,"while resetting destination address"); + exit(1); + } + + if (punt_reply.z_message) { + free(punt_reply.z_message); + punt_reply.z_message = NULL; + } +#endif } else if (!strcasecmp(control_opcode, USER_EXIT)) { signal_exit(0); } else printf("zwgc: unknown control opcode %s.\n", control_opcode); - return; + goto cleanup; } if (!zwgc_active) { @@ -421,7 +553,7 @@ process_notice(ZNotice_t *notice, if (zwgc_debug) printf("NON-ACTIVE: PUNTED <%s>!!!!\n", notice->z_class_inst); #endif - return; + goto cleanup; } if (puntable_address_p(notice->z_class, @@ -431,12 +563,24 @@ process_notice(ZNotice_t *notice, if (zwgc_debug) printf("PUNTED <%s>!!!!\n", notice->z_class_inst); #endif - return; + goto cleanup; } exec_process_packet(program, notice); + cleanup: + return; } +#ifdef CMU_ZWGCPLUS +void reprocess_notice(ZNotice_t *notice, + char *hostname) +{ + list_add_notice(notice); + process_notice(notice, hostname); + list_del_notice(notice); +} +#endif + /***************************************************************************/ /* diff --git a/zwgc/mux.c b/zwgc/mux.c index 341e6e6..eb6232f 100644 --- a/zwgc/mux.c +++ b/zwgc/mux.c @@ -144,14 +144,24 @@ mux_loop(void) */ if (mux_end_loop_p) break; - + tvp = NULL; + tv.tv_sec = 0; if (have_tty) { +#ifdef CMU_ZWGCPLUS + tv.tv_sec = plus_timequeue_events(); + if (tv.tv_sec > 10) tv.tv_sec = 10; +#else tv.tv_sec = 10; +#endif tv.tv_usec = 0; - tvp = &tv; +#ifdef CMU_ZWGCPLUS } else { - tvp = NULL; + tv.tv_sec = plus_timequeue_events(); + tv.tv_usec = 0; +#endif } + if (tv.tv_sec) + tvp = &tv; /* * Do a select on all the file descriptors we care about to diff --git a/zwgc/notice.c b/zwgc/notice.c index ca257cd..3ca2dc7 100644 --- a/zwgc/notice.c +++ b/zwgc/notice.c @@ -31,6 +31,10 @@ static const char rcsid_notice_c[] = "$Id$"; #include "error.h" #include "variables.h" #include "notice.h" +#ifdef CMU_ZWGCPLUS +#include +#include "plus.h" +#endif /* * int count_nulls(char *data, int length) @@ -254,6 +258,9 @@ decode_notice(ZNotice_t *notice, { char *temp; string time, notyear, year, date_string, time_string; +#ifdef CMU_ZWGCPLUS + extern char *getSelectedText(); +#endif /* * Convert useful notice fields to ascii and store away in @@ -265,7 +272,7 @@ decode_notice(ZNotice_t *notice, var_set_variable("instance", notice->z_class_inst); var_set_variable("opcode", notice->z_opcode); var_set_variable("default", notice->z_default_format); - var_set_variable("charset", ZCharsetToString(notice->z_charset)); + var_set_variable("charset", (char *)ZCharsetToString(notice->z_charset)); /*XXX const*/ var_set_variable("recipient", (notice->z_recipient[0] ? notice->z_recipient : "*")); var_set_variable("fullsender", notice->z_sender); @@ -273,6 +280,14 @@ decode_notice(ZNotice_t *notice, var_set_variable_then_free_value("kind", z_kind_to_ascii(notice->z_kind)); var_set_variable_then_free_value("auth", z_auth_to_ascii(notice->z_auth)); +#ifdef CMU_ZWGCPLUS + if ((temp=getSelectedText()) != 0) + var_set_variable("selection", temp); + + var_set_variable("delete_window", "none"); + var_set_variable("event_time", "none"); + var_set_variable("event_name", "event"); +#endif /* * Set $sender to the name of the notice sender except first strip off the * realm name if it is the local realm: @@ -283,6 +298,17 @@ decode_notice(ZNotice_t *notice, temp-notice->z_sender)); else var_set_variable("sender", notice->z_sender); +#ifdef CMU_ZWGCPLUS + if (get_full_names) { + struct passwd *pwnam = getpwnam(var_get_variable("sender")); + if (pwnam) { + temp = string_Copy(pwnam->pw_gecos); + var_set_variable_then_free_value("sendername", temp); + } else { + var_set_variable("sendername", "unknown"); + } + } +#endif /* * Convert time & date notice was sent to ascii. The $time diff --git a/zwgc/subscriptions.c b/zwgc/subscriptions.c index 5123d5f..198fa7e 100644 --- a/zwgc/subscriptions.c +++ b/zwgc/subscriptions.c @@ -42,7 +42,10 @@ static const char rcsid_subscriptions_c[] = "$Id$"; /* * */ -static int_dictionary puntable_addresses_dict = 0; +#ifndef CMU_ZCTL_PUNT +static +#endif +int_dictionary puntable_addresses_dict = 0; static void init_puntable_dict(void) @@ -62,6 +65,9 @@ address_to_string(string class, */ if (string_Eq(recipient,"")) recipient = "*"; + else if (recipient[0] == '@') { + recipient = string_Concat("*", recipient); + } /* * The following is a hack for now only. It should be replaced with @@ -81,11 +87,19 @@ int puntable_address_p(string class, string recipient) { string temp; + int ret; if (!puntable_addresses_dict) init_puntable_dict(); temp = address_to_string(class, instance, recipient); + ret = int_dictionary_Lookup(puntable_addresses_dict, temp); + free(temp); + if (ret) + return 1;; + + /* This kludge is to allow punts of wildcard instance to work */ + temp = address_to_string(class, "*", recipient); if (int_dictionary_Lookup(puntable_addresses_dict, temp)) { free(temp); return(1); diff --git a/zwgc/xcut.c b/zwgc/xcut.c index 4fad2a7..22a94c9 100644 --- a/zwgc/xcut.c +++ b/zwgc/xcut.c @@ -38,6 +38,9 @@ static const char rcsid_xcut_c[] = "$Id$"; #include "error.h" #include "xrevstack.h" #include "X_driver.h" +#ifdef CMU_ZWGCPLUS +#include "plus.h" +#endif /* * @@ -139,7 +142,7 @@ xunmark(Display *dpy, #define PRESSOP_KILL 1 /* normal click */ #define PRESSOP_SEL 2 /* shift left */ #define PRESSOP_EXT 3 /* shift right */ -#define PRESSOP_NUKE 4 /* ctrl */ +#define PRESSOP_NUKE 4 /* ctrl */ #define PRESSOP_STOP 5 /* pressop cancelled by moving out of window */ static int current_pressop = PRESSOP_NONE; @@ -169,8 +172,16 @@ xdestroygram(Display *dpy, delete_gram(gram); free(gram->text); free(gram->blocks); +#ifdef CMU_ZWGCPLUS + if (gram->notice) + list_del_notice(gram->notice); +#endif free(gram); +#ifdef CMU_ZWGCPLUS + XFlush(dpy); +#endif + if (bottom_gram == NULL && unlinked == NULL) { /* flush colormap here */ } @@ -196,6 +207,36 @@ xcut(Display *dpy, * Dispatch on the event type: */ switch(event->type) { +#ifdef CMU_ZWGCPLUS + case KeyPress: + { + char c; + char *plusvar; + int res, metaflag; + res = XLookupString(event, &c, 1, NULL, NULL); + metaflag = event->xkey.state & Mod1Mask; + + /* Recheck if zwgcplus is turned on; + * Zephyr variables override zwgc variables + */ + + zwgcplus = 1; + plusvar = (char *)ZGetVariable("zwgcplus") ? (char *)ZGetVariable("zwgcplus") : (char *)var_get_variable("zwgcplus"); + + if ((plusvar[0]=='\0') || (strcmp(plusvar,"no") == 0)) + zwgcplus = 0; + else { + if (strcmp(plusvar,"no") == 0) + zwgcplus = 0; + if (strcmp(plusvar,"new") == 0) + zwgcplus = 2; + } + + if (res != 0 && zwgcplus != 0) + plus_retry_notice(gram->notice, c, metaflag); + } + break; +#endif case ClientMessage: if ((event->xclient.message_type == XA_WM_PROTOCOLS) && (event->xclient.format == 32) && @@ -273,6 +314,10 @@ xcut(Display *dpy, selected_text = xmarkGetText(); /* this is ok, since to get here, the selection must be owned */ current_pressop = PRESSOP_EXT; +#ifdef CMU_ZWGCPLUS + if (selected_text) + XStoreBytes(dpy, selected_text, strlen(selected_text)+1); +#endif } } else if ( (event->xbutton.state)&ControlMask ) { current_pressop = PRESSOP_NUKE; @@ -288,6 +333,10 @@ xcut(Display *dpy, current_pressop == PRESSOP_EXT) { if (selected_text) free(selected_text); selected_text = xmarkGetText(); +#ifdef CMU_ZWGCPLUS + if (selected_text) + XStoreBytes(dpy, selected_text, strlen(selected_text)+1); +#endif } else if (current_pressop == PRESSOP_NUKE) { XWindowAttributes wa; int gx,gy; diff --git a/zwgc/xshow.c b/zwgc/xshow.c index 6667013..98bab3a 100644 --- a/zwgc/xshow.c +++ b/zwgc/xshow.c @@ -34,6 +34,11 @@ static const char rcsid_xshow_c[] = "$Id$"; #include "X_fonts.h" #include "X_gram.h" #include "xmode_stack.h" +#ifdef CMU_ZWGCPLUS +#include +#include "xrevstack.h" +#include "plus.h" +#endif #define max(a,b) ((a)>(b)?(a):(b)) @@ -331,6 +336,9 @@ fixup_and_draw(Display *dpy, gram_ysize = yofs+internal_border_width; gram->numblocks = num; gram->blocks = blocks; +#ifdef CMU_ZWGCPLUS + gram->notice = get_stored_notice(); +#endif x_gram_create(dpy, gram, gram_xalign, gram_yalign, gram_xpos, gram_ypos, gram_xsize, gram_ysize, beepcount); @@ -575,5 +583,196 @@ x_get_input(Display *dpy) } } +#ifdef CMU_ZWGCPLUS +void +plus_window_deletions(ZNotice_t *notice) +{ + x_gram *tmp, *fry; + char *val; + int done; + static char class_nm[NAMESIZE], instance_nm[NAMESIZE], recip_nm[NAMESIZE]; + + if (!dpy) + return; + + val = var_get_variable("delete_window"); + +#ifdef DEBUG_DELETION + fprintf(stderr, "delete_window(%s)\n", val); +#endif + if (val) { + if (!strcmp(val, "this")) { + do { + done = 1; + tmp = bottom_gram; + while (tmp) { + if (tmp->notice == (char *)notice) { + fry = tmp; + tmp = tmp->above; + xdestroygram(dpy, fry->w, desc_context, fry, 1); + done = 0; + } else { + tmp = tmp->above; + } + } + } while (!done); + } + else if (!strcmp(val, "s")) { + /* I cheated. This is really sender, not class */ + strcpy(class_nm, notice->z_sender); + do { + done = 1; + tmp = bottom_gram; + while (tmp) { + if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_sender, class_nm)) { + fry = tmp; + tmp = tmp->above; + xdestroygram(dpy, fry->w, desc_context, fry, 1); + done = 0; + } else { + tmp = tmp->above; + } + } + } while (!done); + } + else if (!strcmp(val, "ns")) { + /* I cheated. This is really sender, not class */ + strcpy(class_nm, notice->z_sender); + do { + done = 1; + tmp = bottom_gram; + while (tmp) { + if (!!strcasecmp(((ZNotice_t *)(tmp->notice))->z_sender, class_nm)) { + fry = tmp; + tmp = tmp->above; + xdestroygram(dpy, fry->w, desc_context, fry, 1); + done = 0; + } else { + tmp = tmp->above; + } + } + } while (!done); + } + else if (!strcmp(val, "r")) { + strcpy(recip_nm, notice->z_recipient); + do { + done = 1; + tmp = bottom_gram; + while (tmp) { + if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_recipient, recip_nm)) { + fry = tmp; + tmp = tmp->above; + xdestroygram(dpy, fry->w, desc_context, fry, 1); + done = 0; + } else { + tmp = tmp->above; + } + } + } while (!done); + } + else if (!strcmp(val, "nr")) { + strcpy(recip_nm, notice->z_recipient); + do { + done = 1; + tmp = bottom_gram; + while (tmp) { + if (!!strcasecmp(((ZNotice_t *)(tmp->notice))->z_recipient, recip_nm)) { + fry = tmp; + tmp = tmp->above; + xdestroygram(dpy, fry->w, desc_context, fry, 1); + done = 0; + } else { + tmp = tmp->above; + } + } + } while (!done); + } + else if (!strcmp(val, "cir")) { + strcpy(class_nm, notice->z_class); + strcpy(instance_nm, notice->z_class_inst); + strcpy(recip_nm, notice->z_recipient); + do { + done = 1; + tmp = bottom_gram; + while (tmp) { + if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_class_inst, instance_nm) + && !strcasecmp(((ZNotice_t *)(tmp->notice))->z_class, class_nm) + && !strcasecmp(((ZNotice_t *)(tmp->notice))->z_recipient, recip_nm)) + { + fry = tmp; + tmp = tmp->above; + xdestroygram(dpy, fry->w, desc_context, fry, 1); + done = 0; + } else { + tmp = tmp->above; + } + } + } while (!done); + } + else if (!strcmp(val, "ci")) { + strcpy(class_nm, notice->z_class); + strcpy(instance_nm, notice->z_class_inst); + do { + done = 1; + tmp = bottom_gram; + while (tmp) { + if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_class_inst, instance_nm) + && !strcasecmp(((ZNotice_t *)(tmp->notice))->z_class, class_nm)) + { + fry = tmp; + tmp = tmp->above; + xdestroygram(dpy, fry->w, desc_context, fry, 1); + done = 0; + } else { + tmp = tmp->above; + } + } + } while (!done); + } + else if (!strcmp(val, "cr")) { + strcpy(class_nm, notice->z_class); + strcpy(recip_nm, notice->z_recipient); + do { + done = 1; + tmp = bottom_gram; + while (tmp) { + if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_class, class_nm) && + !strcasecmp(((ZNotice_t *)(tmp->notice))->z_recipient, recip_nm)) + { + fry = tmp; + tmp = tmp->above; + xdestroygram(dpy, fry->w, desc_context, fry, 1); + done = 0; + } else { + tmp = tmp->above; + } + } + } while (!done); + } + else if (!strcmp(val, "c")) { + strcpy(class_nm, notice->z_class); + do { + done = 1; + tmp = bottom_gram; + while (tmp) { + if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_class, class_nm)) { + fry = tmp; + tmp = tmp->above; + xdestroygram(dpy, fry->w, desc_context, fry, 1); + done = 0; + } else { + tmp = tmp->above; + } + } + } while (!done); + } + else if (!strcmp(val, "all")) { + while (bottom_gram) { + xdestroygram(dpy, bottom_gram->w, desc_context, bottom_gram, 1); + } + } + } +} +#endif #endif /* X_DISPLAY_MISSING */ diff --git a/zwgc/zephyr.c b/zwgc/zephyr.c index a2f9751..9c9fbd9 100644 --- a/zwgc/zephyr.c +++ b/zwgc/zephyr.c @@ -38,6 +38,9 @@ static const char rcsid_zephyr_c[] = "$Id$"; #ifndef X_DISPLAY_MISSING #include "X_driver.h" #endif +#ifdef CMU_ZWGCPLUS +#include "plus.h" +#endif #ifdef DEBUG extern int zwgc_debug; @@ -119,6 +122,13 @@ handle_zephyr_input(void (*notice_handler)(ZNotice_t *)) notice->z_auth = ZCheckAuthentication(notice, &from); notice_handler(notice); } +#ifdef CMU_ZWGCPLUS + if (get_list_refcount(notice) <= 0) { + /* no windows created */ + if (!get_notice_fake(notice)) + list_del_notice(notice); + } +#endif } } -- cgit v1.2.3