diff options
author | Karl Ramm <kcr@mit.edu> | 2007-07-20 04:26:48 +0000 |
---|---|---|
committer | Karl Ramm <kcr@mit.edu> | 2007-07-20 04:26:48 +0000 |
commit | 82ea504def6eb144c2b13b315890b297e29345c5 (patch) | |
tree | b4623148e6feddde431fcb3b564342c5b0d64523 /clients | |
parent | 0feeeb3f9ce439f7bca5b691c7c681319a107a8e (diff) | |
parent | e6df42eaf361b9878e79ab8964aa26e1ddb95cef (diff) |
unpack of new upstream
Diffstat (limited to 'clients')
28 files changed, 730 insertions, 1377 deletions
diff --git a/clients/xzwrite/Makefile.in b/clients/xzwrite/Makefile.in index f281368..6641df6 100644 --- a/clients/xzwrite/Makefile.in +++ b/clients/xzwrite/Makefile.in @@ -6,29 +6,31 @@ datadir=@datadir@ sysconfdir=@sysconfdir@ sbindir=@sbindir@ lsbindir=@lsbindir@ +top_builddir=../.. includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ at=@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la +LIBDYN=${BUILDTOP}/libdyn/libdyn.a CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -DDATADIR=\"${datadir}\" -I${top_srcdir}/h \ -I${BUILDTOP}/h @X_CFLAGS@ ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib -L${BUILDTOP}/libdyn @X_LIBS@ @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la ${BUILDTOP}/libdyn/libzdyn.la -lXaw -lXmu \ - -lXt @X_PRE_LIBS@ -lX11 -lXext @X_EXTRA_LIBS@ @LIBS@ -lcom_err +LDFLAGS=@X_LIBS@ @LDFLAGS@ +LIBS=${LIBZEPHYR} ${LIBDYN} -lXaw -lXmu -lXt @X_PRE_LIBS@ -lX11 -lXext \ + @X_EXTRA_LIBS@ @LIBS@ -lcom_err OBJS= interface.o resource.o destlist.o util.o bfgets.o gethomedir.o \ dest_window.o xzwrite.o edit_window.o zephyr.o GetString.o Popup.o \ @@ -36,8 +38,8 @@ OBJS= interface.o resource.o destlist.o util.o bfgets.o gethomedir.o \ all: xzwrite XZwrite -xzwrite: ${OBJS} ${BUILDTOP}/lib/libzephyr.la ${BUILDTOP}/libdyn/libzdyn.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +xzwrite: ${OBJS} ${LIBZEPHYR} ${LIBDYN} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} .c.o: ${CC} -c ${ALL_CFLAGS} $< @@ -50,13 +52,14 @@ XZwrite: XZwrite.in check: install: xzwrite XZwrite - ${LIBTOOL} ${INSTALL} -m 755 -s xzwrite ${DESTDIR}${bindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/xzwrite.1 ${DESTDIR}${mandir}/man1 - ${LIBTOOL} ${INSTALL} -m 644 XZwrite ${DESTDIR}${datadir}/zephyr - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/xzwrite.bitmap ${DESTDIR}${datadir}/zephyr + ${LIBTOOL} --mode=install ${INSTALL} -m 755 xzwrite ${DESTDIR}${bindir} + ${INSTALL} -m 644 ${srcdir}/xzwrite.1 ${DESTDIR}${mandir}/man1 + ${INSTALL} -m 644 XZwrite ${DESTDIR}${datadir}/zephyr + ${INSTALL} -m 644 ${srcdir}/xzwrite.bitmap ${DESTDIR}${datadir}/zephyr clean: - ${LIBTOOL} rm -f ${OBJS} xzwrite + ${LIBTOOL} --mode=clean rm -f xzwrite + rm -f ${OBJS} ${OBJS}: xzwrite.h xzwrite-proto.h ${top_srcdir}/h/sysdep.h ${OBJS}: ${BUILDTOP}/h/config.h ${BUILDTOP}/h/zephyr/zephyr.h diff --git a/clients/xzwrite/destlist.c b/clients/xzwrite/destlist.c index 1cc91e1..8621922 100644 --- a/clients/xzwrite/destlist.c +++ b/clients/xzwrite/destlist.c @@ -23,7 +23,7 @@ static DynObject dests; extern Defaults defs; static void get_dest_from_file(), _get_default_dest(); -static int sort_dest_func(); +static int sort_dest_func(const void *, const void *); /* A function for debugging */ void dest_print() @@ -366,12 +366,13 @@ void dest_add_reply(notice) list = dest_text(); num = dest_num(); - /* A hack so local-rhs is less annoying */ + + /* A hack so local-realm is less annoying */ { char *r; r = strchr(notice->z_sender, '@'); - if (r && ! strcmp(r+1, ZGetRhs(NULL))) + if (r && ! strcmp(r+1, ZGetRealm())) *r = '\0'; } diff --git a/clients/xzwrite/interface.c b/clients/xzwrite/interface.c index e218621..716e0e3 100644 --- a/clients/xzwrite/interface.c +++ b/clients/xzwrite/interface.c @@ -137,13 +137,14 @@ void build_interface(argc, argv) #ifdef HAVE_PUTENV strlen("XFILESEARCHPATH=") + #endif - strlen(DATADIR) + 5); + strlen(DATADIR) + 12); if (path2 != NULL) { #ifdef HAVE_PUTENV - sprintf(path2, "XFILESEARCHPATH=%s:%s/%%N", path1, DATADIR); + sprintf(path2, "XFILESEARCHPATH=%s:%s/zephyr/%%N", path1, + DATADIR); putenv(path2); #else - sprintf(path2, "%s:%s/%N", path1, DATADIR); + sprintf(path2, "%s:%s/zephyr/%%N", path1, DATADIR); setenv("XFILESEARCHPATH", path2, 1); free(path2); #endif @@ -225,7 +226,7 @@ static void Quit(w, e, p, n) Cardinal *n; { XtDestroyApplicationContext(app_con); - ZCancelSubscriptions(NULL, 0); + ZCancelSubscriptions(0); exit(0); } diff --git a/clients/xzwrite/zephyr.c b/clients/xzwrite/zephyr.c index 1354fd1..6e25dd5 100644 --- a/clients/xzwrite/zephyr.c +++ b/clients/xzwrite/zephyr.c @@ -74,23 +74,22 @@ int zeph_locateable(user) int n; if (strchr(user, '@') == NULL) - sprintf(buf, "%s@%s", user, ZGetRhs(NULL)); - ZLocateUser(NULL, buf, &n, ZAUTH); + sprintf(buf, "%s@%s", user, ZGetRealm()); + ZLocateUser(buf, &n, ZAUTH); return (!! n); } -/* XXX This will break on intergalactic zephyr, since all these subs - * are done in the default galaxy. */ +/* XXX This will break on interrealm zephyr */ void zeph_subto_logins(users, num) char **users; int num; { ZSubscription_t *sublist; - char *name, *rhs; + char *name, *realm; int rlen, c = 0; - rhs = ZGetRhs(NULL); - rlen = strlen(rhs); + realm = ZGetRealm(); + rlen = strlen(realm); sublist = (ZSubscription_t *) Malloc(num*sizeof(ZSubscription_t), "while subscribing to logins", NULL); @@ -103,12 +102,12 @@ void zeph_subto_logins(users, num) if (strchr(users[c], '@')) sprintf(name, "%s", users[c]); else - sprintf(name, "%s@%s", users[c], rhs); + sprintf(name, "%s@%s", users[c], realm); sublist[c].zsub_classinst = name; c += 1; } - ZSubscribeToSansDefaults(NULL, sublist, c, (unsigned short) 0); + ZSubscribeToSansDefaults(sublist, c, (unsigned short) 0); for(; c; --c) free(sublist[c-1].zsub_classinst); free(sublist); @@ -122,7 +121,7 @@ void zeph_subto_replies() sub.zsub_classinst = "*"; sub.zsub_recipient = ZGetSender(); - ZSubscribeToSansDefaults(NULL, &sub, 1, (unsigned short) 0); + ZSubscribeToSansDefaults(&sub, 1, (unsigned short) 0); } int zeph_send_message(dest, msg) diff --git a/clients/zaway/Makefile.in b/clients/zaway/Makefile.in index f29ad44..ebee5af 100644 --- a/clients/zaway/Makefile.in +++ b/clients/zaway/Makefile.in @@ -6,33 +6,34 @@ datadir=@datadir@ sysconfdir=@sysconfdir@ sbindir=@sbindir@ lsbindir=@lsbindir@ +top_builddir=../.. includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la @LIBS@ -lcom_err +LDFLAGS=@LDFLAGS@ +LIBS=${LIBZEPHYR} @LIBS@ -lcom_err OBJS= zaway.o all: zaway -zaway: ${OBJS} ${BUILDTOP}/lib/libzephyr.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +zaway: ${OBJS} ${LIBZEPHYR} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} .c.o: ${CC} -c ${ALL_CFLAGS} $< @@ -40,11 +41,12 @@ zaway: ${OBJS} ${BUILDTOP}/lib/libzephyr.la check: install: zaway - ${LIBTOOL} ${INSTALL} -m 755 -s zaway ${DESTDIR}${bindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zaway.1 ${DESTDIR}${mandir}/man1 + ${LIBTOOL} --mode=install ${INSTALL} -m 755 zaway ${DESTDIR}${bindir} + ${INSTALL} -m 644 ${srcdir}/zaway.1 ${DESTDIR}${mandir}/man1 clean: - ${LIBTOOL} rm -f ${OBJS} zaway + ${LIBTOOL} --mode=clean rm -f zaway + rm -f ${OBJS} ${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h ${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h diff --git a/clients/zaway/zaway.c b/clients/zaway/zaway.c index 7703092..c8a5f58 100644 --- a/clients/zaway/zaway.c +++ b/clients/zaway/zaway.c @@ -49,15 +49,13 @@ int main(argc,argv) struct passwd *pw; register char *ptr; char awayfile[BUFSIZ],*msg[2],*envptr; - int optchar, watch_location, cmdline_file = 0; + int optchar, watch_location; char *cmdline_msg; int nlocs; char *find_message(); #ifdef _POSIX_VERSION struct sigaction sa; #endif - int i, cnt; - char *galaxy; if ((retval = ZInitialize()) != ZERR_NONE) { com_err(argv[0],retval,"while initializing"); @@ -99,22 +97,9 @@ int main(argc,argv) } } - /* process or reject extra (filename) arguments */ - if (argc > optind) { - if (cmdline_msg) { - fprintf(stderr, "%s: Too many arguments - can't mix -m and filename\n", argv[0]); - return 1; - } else if (argc > optind + 1) { - fprintf(stderr, "%s: Too many arguments - only one filename\n", argv[0]); - return 1; - } else { - (void) strcpy(awayfile,argv[optind]); - cmdline_file = 1; - } - } - - /* after all that, construct the filename only if we'll need it */ - if (!cmdline_msg && !cmdline_file) { + if (argc > optind) + (void) strcpy(awayfile,argv[optind]); + else { envptr = getenv("HOME"); if (envptr) (void) sprintf(awayfile,"%s/.away",envptr); @@ -127,15 +112,11 @@ int main(argc,argv) } } - if (cmdline_msg) { - fp = NULL; - } else { - fp = fopen(awayfile,"r"); - if (!fp && argc > optind) { - fprintf(stderr,"File %s not found!\n",awayfile); - exit(1); - } - } + fp = fopen(awayfile,"r"); + if (!fp && argc > optind) { + fprintf(stderr,"File %s not found!\n",awayfile); + exit(1); + } #ifdef _POSIX_VERSION (void) sigemptyset(&sa.sa_mask); sa.sa_flags = 0; @@ -148,27 +129,9 @@ int main(argc,argv) (void) signal(SIGTERM, cleanup); (void) signal(SIGHUP, cleanup); #endif - - if (retval = ZGetGalaxyCount(&cnt)) { - com_err(argv[0], retval, "while getting galaxy count"); - return; - } - - for (i=0; i<cnt; i++) { - if (retval = ZGetGalaxyName(i, &galaxy)) { - com_err(argv[0], retval, "while getting galaxy name"); - return; - } - - if (((retval = ZSubscribeTo(galaxy, &sub,1,port)) - != ZERR_NONE) -#ifdef HAVE_KRB4 - && (retval != KRBET_AD_NOTGT) -#endif - ) { - com_err(argv[0],retval,"while subscribing"); - exit(1); - } + if ((retval = ZSubscribeToSansDefaults(&sub,1,port)) != ZERR_NONE) { + com_err(argv[0],retval,"while subscribing"); + exit(1); } for (;;) { @@ -180,23 +143,14 @@ int main(argc,argv) if (strcmp(notice.z_sender,ZGetSender()) == 0 || strcmp(notice.z_opcode,"PING") == 0 || + strcmp(notice.z_opcode,"AUTO") == 0 || strcmp(notice.z_message,"Automated reply:") == 0) { ZFreeNotice(¬ice); continue; } if (watch_location) { - char *defgalaxy; - - if ((retval = ZGetGalaxyName(0, &defgalaxy)) - != ZERR_NONE) { - com_err(argv[0],retval, - "while getting default galaxy"); - continue; - } - - if ((retval = ZLocateUser(defgalaxy, ZGetSender(), - &nlocs, ZNOAUTH)) + if ((retval = ZLocateUser(ZGetSender(), &nlocs, ZNOAUTH)) != ZERR_NONE) { com_err(argv[0],retval,"while locating self"); continue; @@ -211,7 +165,7 @@ int main(argc,argv) } if (cmdline_msg) { - ptr = malloc(strlen(cmdline_msg) + 1); + ptr = malloc(strlen(cmdline_msg)+1); if (!ptr) { com_err(argv[0],ENOMEM,"while getting cmdline message"); exit(1); @@ -225,7 +179,7 @@ int main(argc,argv) } } else { - ptr = malloc(sizeof(DEFAULT_MSG)); + ptr = malloc(sizeof(DEFAULT_MSG)+1); if (!ptr) { com_err(argv[0],ENOMEM,"while getting default message"); exit(1); @@ -301,19 +255,6 @@ char *find_message(notice,fp) RETSIGTYPE cleanup() { - int i, cnt; - char *galaxy; - - if (ZGetGalaxyCount(&cnt)) - exit(1); - - for (i=0; i<cnt; i++) { - if (ZGetGalaxyName(i, &galaxy)) - continue; - - if (ZCancelSubscriptions(galaxy, port)) - continue; - } - - exit(1); + ZCancelSubscriptions(port); + exit(1); } diff --git a/clients/zctl/ChangeLog b/clients/zctl/ChangeLog deleted file mode 100644 index fa7edcf..0000000 --- a/clients/zctl/ChangeLog +++ /dev/null @@ -1,5 +0,0 @@ -2002-03-10 Mark W. Eichin <eichin@thok.org> - - * zctl_cmds.ct: provide "help" as alias to list_requests. - * zctl.1: document it. - diff --git a/clients/zctl/Makefile.in b/clients/zctl/Makefile.in index 2c20987..0540927 100644 --- a/clients/zctl/Makefile.in +++ b/clients/zctl/Makefile.in @@ -8,32 +8,32 @@ sbindir=@sbindir@ lsbindir=@lsbindir@ includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin +top_builddir=../.. srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h @X_CFLAGS@ ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la @SS_LIBS@ -lcurses @LIBS@ \ - -lcom_err +LDFLAGS=@LDFLAGS@ +LIBS=${LIBZEPHYR} -lss -lreadline -lhistory -lcurses @LIBS@ -lcom_err -OBJS= zctl.o zutils.o zctl_cmds.o +OBJS= zctl.o zctl_cmds.o all: zctl -zctl: ${OBJS} ${BUILDTOP}/lib/libzephyr.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +zctl: ${OBJS} ${LIBZEPHYR} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} zctl_cmds.c: zctl_cmds.ct mk_cmds ${srcdir}/zctl_cmds.ct @@ -44,11 +44,12 @@ zctl_cmds.c: zctl_cmds.ct check: install: zctl - ${LIBTOOL} ${INSTALL} -m 755 -s zctl ${DESTDIR}${bindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zctl.1 ${DESTDIR}${mandir}/man1 + ${LIBTOOL} --mode=install ${INSTALL} -m 755 zctl ${DESTDIR}${bindir} + ${INSTALL} -m 644 ${srcdir}/zctl.1 ${DESTDIR}${mandir}/man1 clean: - ${LIBTOOL} rm -f ${OBJS} zctl_cmds.c zctl + ${LIBTOOL} --mode=clean rm -f zctl + rm -f ${OBJS} zctl_cmds.c ${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h ${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h diff --git a/clients/zctl/zctl.1 b/clients/zctl/zctl.1 index 614ca5a..c94bbf9 100644 --- a/clients/zctl/zctl.1 +++ b/clients/zctl/zctl.1 @@ -87,7 +87,7 @@ List contents of current subscriptions file or Any macros in the file (see below) are displayed verbatim and not expanded. .TP .B list_requests -List all available commands. May be abbreviated by '?' or 'help'. +List all available commands. May be abbreviated by '?'. .TP .B load \fR[ \fIfile\fR ] Subscribe to all subscription triplets and unsubscribe to all @@ -296,7 +296,7 @@ Service' .br $HOME/.zephyr.subs .br -$HOME/.zephyr.vars +$ZEPHYR_VARS or $HOME/.zephyr.vars .br /etc/athena/zephyr.vars .SH AUTHOR diff --git a/clients/zctl/zctl.c b/clients/zctl/zctl.c index 629f53c..e124b4a 100644 --- a/clients/zctl/zctl.c +++ b/clients/zctl/zctl.c @@ -3,8 +3,7 @@ * * Created by: Robert French * - * $Source$ - * $Author$ + * $Id$ * * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file @@ -13,46 +12,50 @@ #include <sysdep.h> #include <zephyr/zephyr.h> -#ifdef HAVE_SS_SS_H #include <ss/ss.h> -#else -# ifdef HAVE_KRB5_SS_H -# include <krb5/ss.h> -# endif -#endif #include <com_err.h> #include <pwd.h> #include <netdb.h> -#include <errno.h> #ifndef lint static const char *rcsid_zctl_c = "$Id$"; #endif -#include "zutils.h" +#define SUBSATONCE 7 +#define SUB 0 +#define UNSUB 1 +#define LIST 2 #define USERS_SUBS "/.zephyr.subs" #define OLD_SUBS "/.subscriptions" +#define TOKEN_HOSTNAME "%host%" +#define TOKEN_CANONNAME "%canon%" +#define TOKEN_ME "%me%" +#define TOKEN_WILD "*" + +#define ALL 0 +#define UNSUBONLY 1 +#define SUBONLY 2 + #define ERR (-1) #define NOT_REMOVED 0 #define REMOVED 1 int purge_subs(); -void add_file(char *fn, char *galaxy, short wgport, ZSubscription_t *subs, - int mode); -void del_file(char *fn, char *galaxy, short wgport, ZSubscription_t *subs, - int mode); - int sci_idx; char subsname[BUFSIZ]; +char ourhost[MAXHOSTNAMELEN],ourhostcanon[MAXHOSTNAMELEN]; extern ss_request_table zctl_cmds; +void add_file(), del_file(), fix_macros(), fix_macros2(); + main(argc,argv) int argc; char *argv[]; { struct passwd *pwd; + struct hostent *hent; char ssline[BUFSIZ],oldsubsname[BUFSIZ],*envptr,*tty = NULL; int retval,code,i; #ifdef HAVE_SYS_UTSNAME @@ -98,6 +101,24 @@ main(argc,argv) } } +#ifdef HAVE_SYS_UTSNAME + uname(&name); + strcpy(ourhost, name.nodename); +#else + if (gethostname(ourhost,MAXHOSTNAMELEN) == -1) { + com_err(argv[0],errno,"while getting host name"); + exit (1); + } +#endif + + if (!(hent = gethostbyname(ourhost))) { + fprintf(stderr,"%s: Can't resolve hostname %s; %s may be " + "wrong in subscriptions",argv[0],ourhost, + TOKEN_CANONNAME); + strncpy(ourhostcanon,ourhost,sizeof(ourhostcanon)-1); + } else + strncpy(ourhostcanon,hent->h_name,sizeof(ourhostcanon)-1); + sci_idx = ss_create_invocation("zctl","",0,&zctl_cmds,&code); if (code) { ss_perror(sci_idx,code,"while creating invocation"); @@ -118,9 +139,9 @@ main(argc,argv) printf("ZCTL $Revision$ (Protocol %s%d.%d) - Type '?' for a list of commands.\n\n", ZVERSIONHDR, - ZVERSIONMAJOR,ZVERSIONMINOR_GALAXY); + ZVERSIONMAJOR,ZVERSIONMINOR); - code = ss_listen(sci_idx); + ss_listen(sci_idx); exit(0); } @@ -145,136 +166,113 @@ flush_locations(argc,argv) int argc; char *argv[]; { - int retval; - char *galaxy; - int cnt, i; + int retval; - if (argc > 2) { - fprintf(stderr,"Usage: %s [galaxy]\n",argv[0]); - return; - } - - galaxy = (argc > 1)?argv[1]:NULL; - - if (galaxy && strcmp(galaxy, "*") == 0) { - if (retval = ZGetGalaxyCount(&cnt)) { - ss_perror(sci_idx, retval, "while getting galaxy count"); - return; - } - - for (i=0; i<cnt; i++) { - if (retval = ZGetGalaxyName(i, &galaxy)) { - ss_perror(sci_idx, retval, "while getting galaxy name"); - return; - } - - if ((retval = ZFlushMyLocations(galaxy)) != ZERR_NONE) { - ss_perror(sci_idx, retval, "while flushing locations"); + if (argc > 1) { + fprintf(stderr,"Usage: %s\n",argv[0]); return; - } - } - } else { - if ((retval = ZFlushMyLocations(galaxy)) != ZERR_NONE) { - ss_perror(sci_idx, retval, "while flushing locations"); - return; } - } + + if ((retval = ZFlushMyLocations()) != ZERR_NONE) + ss_perror(sci_idx,retval,"while flushing locations"); } void wgc_control(argc,argv) int argc; - char *argv[]; + register char **argv; { - Code_t retval; + int retval; + short newport; + struct sockaddr_in newsin; + ZNotice_t notice; + + newsin = ZGetDestAddr(); if (argc > 1) { fprintf(stderr,"Usage: %s\n",argv[0]); return; } + + if ((newport = ZGetWGPort()) == -1) { + ss_perror(sci_idx,errno,"while getting WindowGram port"); + return; + } + + newsin.sin_port = (u_short) newport; + if ((retval = ZSetDestAddr(&newsin)) != ZERR_NONE) { + ss_perror(sci_idx,retval,"while setting destination address"); + return; + } - if (!strcmp(argv[0],"wg_read")) { - retval = send_wgc_control(USER_REREAD, NULL, 0); - } else if (!strcmp(argv[0],"wg_shutdown")) { - retval = send_wgc_control(USER_SHUTDOWN, NULL, 0); - } else if (!strcmp(argv[0],"wg_startup")) { - retval = send_wgc_control(USER_STARTUP, NULL, 0); - } else if (!strcmp(argv[0],"wg_exit")) { - retval = send_wgc_control(USER_EXIT, NULL, 0); - } else { + (void) memset((char *)¬ice, 0, sizeof(notice)); + notice.z_kind = UNSAFE; + notice.z_port = 0; + notice.z_class = WG_CTL_CLASS; + notice.z_class_inst = WG_CTL_USER; + + if (!strcmp(argv[0],"wg_read")) + notice.z_opcode = USER_REREAD; + if (!strcmp(argv[0],"wg_shutdown")) + notice.z_opcode = USER_SHUTDOWN; + if (!strcmp(argv[0],"wg_startup")) + notice.z_opcode = USER_STARTUP; + if (!strcmp(argv[0],"wg_exit")) + notice.z_opcode = USER_EXIT; + if (!notice.z_opcode) { fprintf(stderr, "unknown WindowGram client control command %s\n", argv[0]); return; } + notice.z_sender = 0; + notice.z_recipient = ""; + notice.z_default_format = ""; + notice.z_message_len = 0; - if (retval) - ss_perror(sci_idx, retval, - "while sending WindowGram control message"); -} + if ((retval = ZSendNotice(¬ice,ZNOAUTH)) != ZERR_NONE) + ss_perror(sci_idx,retval,"while sending notice"); + + if ((retval = ZInitialize()) != ZERR_NONE) + ss_perror(sci_idx,retval, + "while reinitializing"); +} void hm_control(argc,argv) int argc; char *argv[]; { - int retval; - ZNotice_t notice; - char *galaxy; - int cnt, i; - - if (argc > 2) { - fprintf(stderr,"Usage: %s [galaxy]\n",argv[0]); - return; - } - - galaxy = (argc > 1)?argv[1]:NULL; - - (void) memset((char *)¬ice, 0, sizeof(notice)); - notice.z_kind = HMCTL; - notice.z_port = 0; - notice.z_class = HM_CTL_CLASS; - notice.z_class_inst = HM_CTL_CLIENT; - - if (!strcmp(argv[0],"hm_flush")) - notice.z_opcode = CLIENT_FLUSH; - if (!strcmp(argv[0],"new_server")) - notice.z_opcode = CLIENT_NEW_SERVER; - if (!notice.z_opcode) { - fprintf(stderr, "unknown HostManager control command %s\n", - argv[0]); - return; - } - notice.z_sender = 0; - notice.z_recipient = ""; - notice.z_default_format = ""; - notice.z_message_len = 0; + int retval; + ZNotice_t notice; - if (galaxy && strcmp(galaxy, "*") == 0) { - if (retval = ZGetGalaxyCount(&cnt)) { - ss_perror(sci_idx, retval, "while getting galaxy count"); - return; + if (argc > 1) { + fprintf(stderr,"Usage: %s\n",argv[0]); + return; } - - for (i=0; i<cnt; i++) { - if (retval = ZGetGalaxyName(i, &galaxy)) { - ss_perror(sci_idx, retval, "while getting galaxy name"); + + (void) memset((char *)¬ice, 0, sizeof(notice)); + notice.z_kind = HMCTL; + notice.z_port = 0; + notice.z_class = HM_CTL_CLASS; + notice.z_class_inst = HM_CTL_CLIENT; + + if (!strcmp(argv[0],"hm_flush")) + notice.z_opcode = CLIENT_FLUSH; + if (!strcmp(argv[0],"new_server")) + notice.z_opcode = CLIENT_NEW_SERVER; + if (!notice.z_opcode) { + fprintf(stderr, "unknown HostManager control command %s\n", + argv[0]); return; - } - - notice.z_dest_galaxy = galaxy; + } + notice.z_sender = 0; + notice.z_recipient = ""; + notice.z_default_format = ""; + notice.z_message_len = 0; - if ((retval = ZSendNotice(¬ice,ZNOAUTH)) != ZERR_NONE) { + if ((retval = ZSendNotice(¬ice,ZNOAUTH)) != ZERR_NONE) ss_perror(sci_idx,retval,"while sending notice"); - return; - } - } - } else { - if ((retval = ZSendNotice(¬ice,ZNOAUTH)) != ZERR_NONE) { - ss_perror(sci_idx,retval,"while sending notice"); - return; - } - } } void @@ -304,55 +302,79 @@ set_var(argc,argv) int argc; register char **argv; { - int retval,setting_exp,i; - char *galaxy; - char varcat[BUFSIZ]; + int retval,setting_exp,i; + char *exp_level,*newargv[1]; + char varcat[BUFSIZ]; - if (argc < 2) { - fprintf(stderr,"Usage: %s <varname> [value]\n", - argv[0]); - return; - } - - setting_exp = 0; - - if (strncasecmp(argv[1],"exposure",8) == 0) { - setting_exp = 1; - if (argc != 3) { - fprintf(stderr, "An exposure setting must be specified.\n"); - return; - } - if (strlen(argv[1]) == 8) { - galaxy = NULL; /* the default */ - } else if ((strlen(argv[1]) == 9) || - (ZGetRhs(argv[1]+9) == NULL)) { - fprintf(stderr, "The exposure variable's galaxy name was empty or invalid.\nUse a variable of the form exposure-GALAXYNAME.\n"); - return; - } else { - galaxy = argv[1]+9; - } - } - - if (argc == 2) - retval = ZSetVariable(argv[1],""); - else { - (void) strcpy(varcat,argv[2]); - for (i=3;i<argc;i++) { - (void) strcat(varcat," "); - (void) strcat(varcat,argv[i]); + if (argc < 2) { + fprintf(stderr,"Usage: %s <varname> [value]\n", + argv[0]); + return; + } + + setting_exp = 0; + + if (!strcasecmp(argv[1],"exposure")) { + setting_exp = 1; + if (argc != 3) { + fprintf(stderr,"An exposure setting must be specified.\n"); + return; + } + exp_level = (char *)0; + if (!strcasecmp(argv[2],EXPOSE_NONE)) + exp_level = EXPOSE_NONE; + if (!strcasecmp(argv[2],EXPOSE_OPSTAFF)) + exp_level = EXPOSE_OPSTAFF; + if (!strcasecmp(argv[2],EXPOSE_REALMVIS)) + exp_level = EXPOSE_REALMVIS; + if (!strcasecmp(argv[2],EXPOSE_REALMANN)) + exp_level = EXPOSE_REALMANN; + if (!strcasecmp(argv[2],EXPOSE_NETVIS)) + exp_level = EXPOSE_NETVIS; + if (!strcasecmp(argv[2],EXPOSE_NETANN)) + exp_level = EXPOSE_NETANN; + if (!exp_level) { + fprintf(stderr,"The exposure setting must be one of:\n"); + fprintf(stderr,"%s, %s, %s, %s, %s, %s.\n", + EXPOSE_NONE, + EXPOSE_OPSTAFF, + EXPOSE_REALMVIS, + EXPOSE_REALMANN, + EXPOSE_NETVIS, + EXPOSE_NETANN); + return; + } + } + if (argc == 2) + retval = ZSetVariable(argv[1],""); + else { + (void) strcpy(varcat,argv[2]); + for (i=3;i<argc;i++) { + (void) strcat(varcat," "); + (void) strcat(varcat,argv[i]); + } + retval = ZSetVariable(argv[1],varcat); } - retval = ZSetVariable(argv[1],varcat); - } - if (retval != ZERR_NONE) { - ss_perror(sci_idx,retval,"while setting variable value"); - return; - } + if (retval != ZERR_NONE) { + ss_perror(sci_idx,retval,"while setting variable value"); + return; + } - /* Side-effects? Naw, us? */ + /* Side-effects? Naw, us? */ - if (setting_exp) - set_exposure(galaxy?galaxy:"*", argv[2]); + if (setting_exp) { + if ((retval = ZSetLocation(exp_level)) != ZERR_NONE) + ss_perror(sci_idx,retval,"while changing exposure status"); + if (!strcmp(exp_level,EXPOSE_NONE)) { + newargv[0] = "wg_shutdown"; + wgc_control(1,newargv); + } else { + newargv[0] = "wg_startup"; + wgc_control(1,newargv); + } + return; + } } void @@ -360,32 +382,20 @@ do_hide(argc,argv) int argc; char *argv[]; { - char *exp_level; - char *galaxy; - int cnt, i; - Code_t code; + char *exp_level = NULL; + Code_t retval; - if (argc > 2) { - fprintf(stderr, "Usage: %s [galaxy]\n",argv[0]); - return; - } - - if (strcmp(argv[0], "unhide") == 0) { - exp_level = ZGetVariable("exposure"); - if (exp_level) - exp_level = ZParseExposureLevel(exp_level); - if (!exp_level) - exp_level = EXPOSE_REALMVIS; - } else { - exp_level = EXPOSE_OPSTAFF; - } - - galaxy = (argc > 1)?argv[1]:NULL; - - if (code = set_exposure(galaxy, exp_level)) { - ss_perror(sci_idx, code, "while setting exposures"); + if (argc != 1) { + fprintf(stderr, "Usage: %s\n",argv[0]); + return; + } + if (!strcmp(argv[0],"unhide")) + exp_level = EXPOSE_REALMVIS; + else + exp_level = EXPOSE_OPSTAFF; + if ((retval = ZSetLocation(exp_level)) != ZERR_NONE) + ss_perror(sci_idx,retval,"while changing exposure status"); return; - } } void @@ -406,54 +416,26 @@ unset_var(argc,argv) ss_perror(sci_idx,retval, "while unsetting variable value"); } - + void cancel_subs(argc,argv) int argc; char *argv[]; { - int retval; - short wgport; - int i, cnt; - char *galaxy; - - if (argc > 2) { - fprintf(stderr,"Usage: %s [galaxy]\n",argv[0]); - return; - } - - if ((wgport = ZGetWGPort()) == -1) { - ss_perror(sci_idx,errno,"while finding WindowGram port"); - return; - } - - galaxy = (argc > 1)?argv[1]:NULL; - - if (galaxy && strcmp(galaxy, "*") == 0) { - if (retval = ZGetGalaxyCount(&cnt)) { - ss_perror(sci_idx, retval, "while getting galaxy count"); - return; - } + int retval; + short wgport; - for (i=0; i<cnt; i++) { - if (retval = ZGetGalaxyName(i, &galaxy)) { - ss_perror(sci_idx, retval, "while getting galaxy name"); + if (argc != 1) { + fprintf(stderr,"Usage: %s\n",argv[0]); return; - } + } - if ((retval = ZCancelSubscriptions(galaxy, (u_short)wgport)) - != ZERR_NONE) { - ss_perror(sci_idx,retval,"while cancelling subscriptions"); + if ((wgport = ZGetWGPort()) == -1) { + ss_perror(sci_idx,errno,"while finding WindowGram port"); return; - } - } - } else { - if ((retval = ZCancelSubscriptions(galaxy, (u_short)wgport)) - != ZERR_NONE) { - ss_perror(sci_idx,retval,"while cancelling subscriptions"); - return; - } - } + } + if ((retval = ZCancelSubscriptions((u_short)wgport)) != ZERR_NONE) + ss_perror(sci_idx,retval,"while cancelling subscriptions"); } void @@ -464,35 +446,15 @@ subscribe(argc,argv) int retval; short wgport; ZSubscription_t sub,sub2; - char *galaxy; - int mode; - if (argc > 5 || argc < 3) { - fprintf(stderr,"Usage: %s class instance [* [galaxy]]\n", - argv[0]); + if (argc > 4 || argc < 3) { + fprintf(stderr,"Usage: %s class instance [*]\n",argv[0]); return; } - if (strncmp(argv[0], "sub", 3) == 0) { - mode = SUB; - } else if (strncmp(argv[0], "unsub", 5) == 0) { - mode = UNSUB; - } else if ((strncmp(argv[0], "punt", 4) == 0) || - (strncmp(argv[0], "sup", 3) == 0)) { - mode = PUNT; - } else if ((strncmp(argv[0], "unpunt", 6) == 0) || - (strncmp(argv[0], "unsup", 5) == 0)) { - mode = UNPUNT; - } else { - ss_perror(sci_idx, 0, "internal error in subscribe"); - exit(1); - } - sub.zsub_class = argv[1]; sub.zsub_classinst = argv[2]; - sub.zsub_recipient = (argc > 3)?argv[3]: - (((mode == PUNT) || (mode == UNPUNT))?"":ZGetSender()); - galaxy = (argc > 4)?argv[4]:NULL; + sub.zsub_recipient = (argc == 3)?ZGetSender():argv[3]; fix_macros(&sub,&sub2,1); @@ -501,26 +463,12 @@ subscribe(argc,argv) return; } - switch (mode) { - case SUB: - if (retval = ZSubscribeTo(galaxy, &sub2, 1, (u_short) wgport)) - ss_perror(sci_idx, retval, "while subscribing"); - break; - case UNSUB: - if (retval = ZUnsubscribeTo(galaxy, &sub2, 1, (u_short) wgport)) - ss_perror(sci_idx, retval, "while subscribing"); - break; - case PUNT: - if (retval = xpunt(sub2.zsub_class, sub2.zsub_classinst, - sub2.zsub_recipient, PUNT)) - ss_perror(sci_idx, retval, "while suppressing"); - break; - case UNPUNT: - if (retval = xpunt(sub2.zsub_class, sub2.zsub_classinst, - sub2.zsub_recipient, UNPUNT)) - ss_perror(sci_idx, retval, "while unsuppressing"); - break; - } + retval = (*argv[0] == 's') ? + ZSubscribeToSansDefaults(&sub2,1,(u_short)wgport) : + ZUnsubscribeTo(&sub2,1,(u_short)wgport); + + if (retval != ZERR_NONE) + ss_perror(sci_idx,retval,"while subscribing"); } void @@ -530,145 +478,69 @@ sub_file(argc,argv) { ZSubscription_t sub; short wgport; - char fn[MAXPATHLEN]; - char *arggalaxy, *galaxy; - int cnt, i; - Code_t retval; - int del, mode; - if (argc > 5 || argc < 3) { - fprintf(stderr,"Usage: %s class instance [* [galaxy]]\n", - argv[0]); + if (argc > 4 || argc < 3) { + fprintf(stderr,"Usage: %s class instance [*]\n",argv[0]); return; } - if (!strcmp(argv[0],"add")) { - del = 0; - mode = SUB; - } else if (!strcmp(argv[0],"add_unsubscription") || - !strcmp(argv[0],"add_un")) { - del = 0; - mode = UNSUB; - } else if (!strcmp(argv[0],"add_suppression") || - !strcmp(argv[0],"add_punt")) { - del = 0; - mode = PUNT; - } else if (!strcmp(argv[0],"delete") || - !strcmp(argv[0],"del") || - !strcmp(argv[0],"dl")) { - del = 1; - mode = SUB; - } else if (!strcmp(argv[0],"delete_unsubscription") || - !strcmp(argv[0],"del_un")) { - del = 1; - mode = UNSUB; - } else if (!strcmp(argv[0],"delete_suppression") || - !strcmp(argv[0],"del_punt")) { - del = 1; - mode = PUNT; - } else { - ss_perror(sci_idx,0,"unknown command name"); - } - if (argv[1][0] == '!') { - ss_perror(sci_idx,0, (mode == UNSUB)? + ss_perror(sci_idx,0, + (!strcmp(argv[0],"add_unsubscription") || + !strcmp(argv[0],"add_un") || + !strcmp(argv[0],"delete_unsubscription") || + !strcmp(argv[0],"del_un")) ? "Do not use `!' as the first character of a class.\n\tIt is automatically added before modifying the subscription file." : "Do not use `!' as the first character of a class.\n\tIt is reserved for internal use with un-subscriptions."); return; - } else if (argv[1][0] == '-') { - ss_perror(sci_idx,0, (mode == PUNT)? - "Do not use `-' as the first character of a class.\n\tIt is automatically added before modifying the subscription file." : - "Do not use `-' as the first character of a class.\n\tIt is reserved for internal use with suppressions."); - return; } - sub.zsub_class = argv[1]; sub.zsub_classinst = argv[2]; - sub.zsub_recipient = (argc > 3)?argv[3]: - (((mode == PUNT) || (mode == UNPUNT))?"":TOKEN_ME); - arggalaxy = (argc > 4)?argv[4]:NULL; + sub.zsub_recipient = (argc == 3)?TOKEN_ME:argv[3]; - if (arggalaxy) { - if (retval = ZGetGalaxyCount(&cnt)) { - ss_perror(sci_idx, retval, "while getting galaxy count"); + if (make_exist(subsname)) return; - } - - for (i=0; i<cnt; i++) { - if (retval = ZGetGalaxyName(i, &galaxy)) { - ss_perror(sci_idx, retval, "while getting galaxy name"); - return; - } - - if (strcasecmp(galaxy, arggalaxy) == 0) - break; - } - - if (i == cnt) { - ss_perror(sci_idx, 0, - "unknown galaxy specified while modifying subscripion file"); - return; - } - } else { - galaxy = ZGetDefaultGalaxy(); - } - if ((wgport = ZGetWGPort()) == -1) { ss_perror(sci_idx,errno,"while finding WindowGram port"); return; } - strcpy(fn, subsname); - strcat(fn, "-"); - strcat(fn, galaxy); - - if (!strcmp(argv[0],"add")) { - add_file(fn, galaxy, wgport, &sub, SUB); - } else if (!strcmp(argv[0],"add_unsubscription") || - !strcmp(argv[0],"add_un")) { - add_file(fn, galaxy, wgport, &sub, UNSUB); - } else if (!strcmp(argv[0],"add_suppression") || - !strcmp(argv[0],"add_punt")) { - add_file(fn, galaxy, wgport, &sub, PUNT); - } else if (!strcmp(argv[0],"delete") || - !strcmp(argv[0],"del") || - !strcmp(argv[0],"dl")) { - del_file(fn, galaxy, wgport, &sub, SUB); - } else if (!strcmp(argv[0],"delete_unsubscription") || - !strcmp(argv[0],"del_un")) { - del_file(fn, galaxy, wgport, &sub, UNSUB); - } else if (!strcmp(argv[0],"delete_suppression") || - !strcmp(argv[0],"del_punt")) { - del_file(fn, galaxy, wgport, &sub, PUNT); - } else { + if (!strcmp(argv[0],"add")) + add_file(wgport,&sub,0); + else if (!strcmp(argv[0],"add_unsubscription") || + !strcmp(argv[0],"add_un")) + add_file(wgport,&sub,1); + else if (!strcmp(argv[0],"delete") || + !strcmp(argv[0],"del") || + !strcmp(argv[0],"dl")) + del_file(wgport,&sub,0); + else if (!strcmp(argv[0],"delete_unsubscription") || + !strcmp(argv[0],"del_un")) { + del_file(wgport,&sub,1); + } else ss_perror(sci_idx,0,"unknown command name"); - } return; } void -add_file(fn,galaxy,wgport,subs,mode) - char *fn; - char *galaxy; - short wgport; - ZSubscription_t *subs; - int mode; +add_file(wgport,subs,unsub) +short wgport; +ZSubscription_t *subs; +int unsub; { FILE *fp; char errbuf[BUFSIZ]; ZSubscription_t sub2; Code_t retval; - (void) purge_subs(fn,subs,ALL); /* remove copies in the subs file */ - if (!(fp = fopen(fn,"a"))) { - (void) sprintf(errbuf,"while opening %s for append", fn); + (void) purge_subs(subs,ALL); /* remove copies in the subs file */ + if (!(fp = fopen(subsname,"a"))) { + (void) sprintf(errbuf,"while opening %s for append",subsname); ss_perror(sci_idx,errno,errbuf); return; } fprintf(fp,"%s%s,%s,%s\n", - ((mode == UNSUB) ? "!" : - ((mode == PUNT) ? "*" : - "")), + unsub ? "!" : "", subs->zsub_class, subs->zsub_classinst, subs->zsub_recipient); if (fclose(fp) == EOF) { (void) sprintf(errbuf, "while closing %s", subsname); @@ -676,70 +548,53 @@ add_file(fn,galaxy,wgport,subs,mode) return; } fix_macros(subs,&sub2,1); - if (mode == UNSUB) { - if (retval = ZUnsubscribeTo(galaxy, &sub2,1,(u_short)wgport)) - ss_perror(sci_idx, retval, "while subscribing"); - } else if (mode == PUNT) { - if (retval = xpunt(sub2.zsub_class, sub2.zsub_classinst, - sub2.zsub_recipient, PUNT)) - ss_perror(sci_idx, retval, "while unsubscribing"); - } else { - if (retval = ZSubscribeTo(galaxy, &sub2,1,(u_short)wgport)) - ss_perror(sci_idx, retval, "while suppressing"); - } - + if (retval = (unsub ? ZUnsubscribeTo(&sub2,1,(u_short)wgport) : + ZSubscribeToSansDefaults(&sub2,1,(u_short)wgport))) + ss_perror(sci_idx,retval, + unsub ? "while unsubscribing" : + "while subscribing"); return; } void -del_file(fn,galaxy,wgport,subs,mode) - char *fn; - char *galaxy; - short wgport; - ZSubscription_t *subs; - int mode; +del_file(wgport,subs,unsub) +short wgport; +register ZSubscription_t *subs; +int unsub; { ZSubscription_t sub2; int retval; - retval = purge_subs(fn, subs, mode); + retval = purge_subs(subs, unsub ? UNSUBONLY : SUBONLY); if (retval == ERR) return; if (retval == NOT_REMOVED) fprintf(stderr, "Couldn't find %sclass %s instance %s recipient %s in\n\tfile %s\n", - ((mode == UNSUB) ? "un-subscription " : - ((mode == PUNT) ? "suppression " : - "")), + unsub ? "un-subscription " : "", subs->zsub_class, subs->zsub_classinst, subs->zsub_recipient, subsname); fix_macros(subs,&sub2,1); - if (mode == PUNT) { - if (retval = xpunt(sub2.zsub_class, sub2.zsub_classinst, - sub2.zsub_recipient, UNPUNT)) - ss_perror(sci_idx,retval,"while unsuppressing"); - } else if ((retval = ZUnsubscribeTo(galaxy, &sub2,1,(u_short)wgport)) != - ZERR_NONE) { + if ((retval = ZUnsubscribeTo(&sub2,1,(u_short)wgport)) != + ZERR_NONE) ss_perror(sci_idx,retval,"while unsubscribing"); - } + return; } int -purge_subs(fn, subs, mode) - char *fn; - register ZSubscription_t *subs; - int mode; +purge_subs(subs,which) +register ZSubscription_t *subs; +int which; { FILE *fp,*fpout; char errbuf[BUFSIZ],subline[BUFSIZ]; char backup[BUFSIZ],ourline[BUFSIZ]; int delflag = NOT_REMOVED; - int purge; + int keep; - switch (mode) { - case SUB: - case UNSUB: - case PUNT: + switch (which) { + case SUBONLY: + case UNSUBONLY: case ALL: break; default: @@ -752,16 +607,12 @@ purge_subs(fn, subs, mode) subs->zsub_classinst, subs->zsub_recipient); - if (!(fp = fopen(fn,"r"))) { - if (errno == ENOENT) - /* if the filw doesn't exist, then the sub - is clearly purged */ - return(delflag); - (void) sprintf(errbuf,"while opening %s for read", fn); + if (!(fp = fopen(subsname,"r"))) { + (void) sprintf(errbuf,"while opening %s for read",subsname); ss_perror(sci_idx,errno,errbuf); return(ERR); } - (void) strcpy(backup, fn); + (void) strcpy(backup, subsname); (void) strcat(backup, ".temp"); (void) unlink(backup); if (!(fpout = fopen(backup,"w"))) { @@ -775,34 +626,28 @@ purge_subs(fn, subs, mode) break; if (*subline) subline[strlen(subline)-1] = '\0'; /* nuke newline */ - switch (mode) { - case SUB: - purge = (strcmp(subline,ourline) == 0); - break; - case UNSUB: - purge = (*subline == '!' && - (strcmp(subline+1,ourline) == 0)); + switch (which) { + case SUBONLY: + keep = strcmp(subline,ourline); break; - case PUNT: - purge = (*subline == '-' && - (strcmp(subline+1,ourline) == 0)); + case UNSUBONLY: + keep = (*subline != '!' || strcmp(subline+1,ourline)); break; case ALL: - purge = ((strcmp(subline,ourline) == 0) || - (((*subline == '!') || (*subline == '-')) && - (strcmp(subline+1, ourline) == 0))); + keep = (strcmp(subline,ourline) && + (*subline != '!' || strcmp(subline+1, + ourline))); break; } - if (purge) { - delflag = REMOVED; - } else { + if (keep) { fputs(subline, fpout); if (ferror(fpout) || (fputc('\n', fpout) == EOF)) { (void) sprintf(errbuf, "while writing to %s", backup); ss_perror(sci_idx, errno, errbuf); } - } + } else + delflag = REMOVED; } (void) fclose(fp); /* open read-only, ignore errs */ if (fclose(fpout) == EOF) { @@ -810,9 +655,9 @@ purge_subs(fn, subs, mode) ss_perror(sci_idx, errno, errbuf); return(ERR); } - if (rename(backup, fn) == -1) { + if (rename(backup,subsname) == -1) { (void) sprintf(errbuf,"while renaming %s to %s\n", - backup, fn); + backup,subsname); ss_perror(sci_idx,errno,errbuf); return(ERR); } @@ -824,78 +669,177 @@ load_subs(argc,argv) int argc; char *argv[]; { - int type, cnt, i; - char *file; - char *arggalaxy, *galaxy; - Code_t code; + ZSubscription_t subs[SUBSATONCE],subs2[SUBSATONCE],unsubs[SUBSATONCE]; + FILE *fp; + int ind,unind,lineno,i,retval,type; + short wgport; + char *comma,*comma2,*file,subline[BUFSIZ]; - if (argc > 3) { - fprintf(stderr,"Usage: %s [file [galaxy]]\n",argv[0]); + if (argc > 2) { + fprintf(stderr,"Usage: %s [file]\n",argv[0]); return; } if (*argv[0] == 'u') type = UNSUB; - else if (!strcmp(argv[0],"list") || !strcmp(argv[0],"ls")) - type = LIST; else - type = SUB; - - file = (argc > 1)?argv[1]:subsname; - arggalaxy = (argc > 2)?argv[2]:NULL; - - if (arggalaxy) { - if (code = ZGetGalaxyCount(&cnt)) { - ss_perror(sci_idx, code, "while getting galaxy count"); - return; - } + if (!strcmp(argv[0],"list") || !strcmp(argv[0],"ls")) + type = LIST; + else + type = SUB; - for (i=0; i<cnt; i++) { - if (code = ZGetGalaxyName(i, &galaxy)) { - ss_perror(sci_idx, code, "while getting galaxy name"); - return; - } + if (type != LIST) + if ((wgport = ZGetWGPort()) == -1) { + ss_perror(sci_idx,errno, + "while finding WindowGram port"); + return; + } - if (strcasecmp(galaxy, arggalaxy) == 0) - break; - } + file = (argc == 1) ? subsname : argv[1]; + + fp = fopen(file,"r"); - if (i == cnt) { - ss_perror(sci_idx, 0, - "unknown galaxy specified while loading subscription file"); + if (fp == NULL) { + ss_perror(sci_idx,errno, + "while loading subscription file"); return; - } - } else { - galaxy = NULL; } - - if (code = load_sub_file(type, file, galaxy)) - ss_perror(sci_idx, code, - "while loading subscription file"); - -} - -void -loadall(argc,argv) - int argc; - char *argv[]; -{ - int retval; - char *galaxy; - int type, cnt, i; - char fn[MAXPATHLEN]; - if (argc > 1) { - fprintf(stderr,"Usage: %s\n",argv[0]); - return; - } - - if (!strcmp(argv[0],"list") || !strcmp(argv[0],"ls")) - type = LIST; - else - type = SUB; + ind = unind = 0; + lineno = 1; + + for (;;lineno++) { + if (!fgets(subline,sizeof subline,fp)) + break; + if (*subline == '#' || !*subline) + continue; + subline[strlen(subline)-1] = '\0'; /* nuke newline */ + comma = strchr(subline,','); + if (comma) + comma2 = strchr(comma+1,','); + else + comma2 = 0; + if (!comma || !comma2) { + fprintf(stderr, + "Malformed subscription at line %d of %s:\n%s\n", + lineno,file,subline); + continue; + } + *comma = '\0'; + *comma2 = '\0'; + if (type == LIST) { + if (*subline == '!') + printf("(Un-subscription) Class %s instance %s recipient %s\n", + subline+1, comma+1, comma2+1); + else + printf("Class %s instance %s recipient %s\n", + subline, comma+1, comma2+1); + continue; + } + if (*subline == '!') { /* an un-subscription */ + /* if we are explicitly un-subscribing to + the contents of a subscription file, ignore + any un-subscriptions in that file */ + if (type == UNSUB) + continue; + unsubs[unind].zsub_class = + (char *)malloc((unsigned)(strlen(subline))); + /* XXX check malloc return */ + /* skip the leading '!' */ + (void) strcpy(unsubs[unind].zsub_class,subline+1); + unsubs[unind].zsub_classinst = + (char *)malloc((unsigned)(strlen(comma+1)+1)); + /* XXX check malloc return */ + (void) strcpy(unsubs[unind].zsub_classinst,comma+1); + unsubs[unind].zsub_recipient = + (char *)malloc((unsigned)(strlen(comma2+1)+1)); + /* XXX check malloc return */ + (void) strcpy(unsubs[unind].zsub_recipient,comma2+1); + unind++; + } else { + subs[ind].zsub_class = + (char *)malloc((unsigned)(strlen(subline)+1)); + /* XXX check malloc return */ + (void) strcpy(subs[ind].zsub_class,subline); + subs[ind].zsub_classinst = + (char *)malloc((unsigned)(strlen(comma+1)+1)); + /* XXX check malloc return */ + (void) strcpy(subs[ind].zsub_classinst,comma+1); + subs[ind].zsub_recipient = + (char *)malloc((unsigned)(strlen(comma2+1)+1)); + /* XXX check malloc return */ + (void) strcpy(subs[ind].zsub_recipient,comma2+1); + ind++; + } + if (ind == SUBSATONCE) { + fix_macros(subs,subs2,ind); + if ((retval = (type == SUB)? + ZSubscribeTo(subs2,ind,(u_short)wgport): + ZUnsubscribeTo(subs2,ind,(u_short)wgport)) != + ZERR_NONE) { + ss_perror(sci_idx,retval,(type == SUB)? + "while subscribing": + "while unsubscribing"); + goto cleanup; + } + for (i=0;i<ind;i++) { + free(subs[i].zsub_class); + free(subs[i].zsub_classinst); + free(subs[i].zsub_recipient); + } + ind = 0; + } + if (unind == SUBSATONCE) { + fix_macros(unsubs,subs2,unind); + if ((retval = ZUnsubscribeTo(subs2,unind,(u_short)wgport)) != ZERR_NONE) { + ss_perror(sci_idx,retval, + "while unsubscribing to un-subscriptions"); + goto cleanup; + } + for (i=0;i<unind;i++) { + free(unsubs[i].zsub_class); + free(unsubs[i].zsub_classinst); + free(unsubs[i].zsub_recipient); + } + unind = 0; + } + } + + if (type != LIST) { + /* even if we have no subscriptions, be sure to send + an empty packet to trigger the default subscriptions */ + fix_macros(subs,subs2,ind); + if ((retval = (type == SUB)?ZSubscribeTo(subs2,ind,(u_short)wgport): + ZUnsubscribeTo(subs2,ind,(u_short)wgport)) != ZERR_NONE) { + ss_perror(sci_idx,retval,(type == SUB)? + "while subscribing": + "while unsubscribing"); + goto cleanup; + } + if (unind) { + fix_macros(unsubs,subs2,unind); + if ((retval = + ZUnsubscribeTo(subs2,unind,(u_short)wgport)) != ZERR_NONE) { + ss_perror(sci_idx,retval, + "while unsubscribing to un-subscriptions"); + goto cleanup; + } + } + } +cleanup: + for (i=0;i<ind;i++) { + free(subs[i].zsub_class); + free(subs[i].zsub_classinst); + free(subs[i].zsub_recipient); + } + for (i=0;i<unind;i++) { + free(unsubs[i].zsub_class); + free(unsubs[i].zsub_classinst); + free(unsubs[i].zsub_recipient); + } - load_all_sub_files(type, subsname); + (void) fclose(fp); /* ignore errs--file is read-only */ + return; } void @@ -908,7 +852,7 @@ current(argc,argv) ZSubscription_t subs; int i,nsubs,retval,save,one,defs; short wgport; - char *galaxy, *file, backup[BUFSIZ]; + char *file,backup[BUFSIZ]; save = 0; defs = 0; @@ -918,22 +862,9 @@ current(argc,argv) else if (!strcmp(argv[0], "defaults") || !strcmp(argv[0], "defs")) defs = 1; - if (save) { - if (argc > 3) { - fprintf(stderr,"Usage: %s [filename [galaxy]]\n", - argv[0]); - return; - } else { - file = (argc > 1)?argv[1]:subsname; - galaxy = (argc > 2)?argv[2]:NULL; - } - } else { - if (argc > 2) { - fprintf(stderr,"Usage: %s [galaxy]\n",argv[0]); - return; - } else { - galaxy = (argc > 1)?argv[1]:NULL; - } + if (argc != 1 && !(save && argc == 2)) { + fprintf(stderr,"Usage: %s%s\n",argv[0],save?" [filename]":""); + return; } if (!defs) @@ -944,9 +875,9 @@ current(argc,argv) } if (defs) - retval = ZRetrieveDefaultSubscriptions(galaxy, &nsubs); + retval = ZRetrieveDefaultSubscriptions(&nsubs); else - retval = ZRetrieveSubscriptions(galaxy,(u_short)wgport,&nsubs); + retval = ZRetrieveSubscriptions((u_short)wgport,&nsubs); if (retval == ZERR_TOOMANYSUBS) { fprintf(stderr,"Too many subscriptions -- some have not been returned.\n"); @@ -962,6 +893,7 @@ current(argc,argv) } if (save) { + file = (argc == 1)?subsname:argv[1]; (void) strcpy(backup,file); (void) strcat(backup,".temp"); if (!(fp = fopen(backup,"w"))) { @@ -1006,3 +938,59 @@ current(argc,argv) } } } + +int +make_exist(filename) + char *filename; +{ + char errbuf[BUFSIZ]; + FILE *fpout; + + if (!access(filename,F_OK)) + return (0); + + if (!(fpout = fopen(filename,"w"))) { + (void) sprintf(errbuf,"while opening %s for write",filename); + ss_perror(sci_idx,errno,errbuf); + return (1); + } + + if (fclose(fpout) == EOF) { + (void) sprintf(errbuf, "while closing %s", filename); + ss_perror(sci_idx, errno, errbuf); + return(1); + } + return (0); +} + +void +fix_macros(subs,subs2,num) + ZSubscription_t *subs,*subs2; + int num; +{ + int i; + + for (i=0;i<num;i++) { + subs2[i] = subs[i]; + fix_macros2(subs[i].zsub_class,&subs2[i].zsub_class); + fix_macros2(subs[i].zsub_classinst,&subs2[i].zsub_classinst); + fix_macros2(subs[i].zsub_recipient,&subs2[i].zsub_recipient); + } +} + +void +fix_macros2(src,dest) + register char *src; + char **dest; +{ + if (!strcmp(src,TOKEN_HOSTNAME)) { + *dest = ourhost; + return; + } + if (!strcmp(src,TOKEN_CANONNAME)) { + *dest = ourhostcanon; + return; + } + if (!strcmp(src,TOKEN_ME)) + *dest = ZGetSender(); +} diff --git a/clients/zctl/zctl_cmds.ct b/clients/zctl/zctl_cmds.ct index aa9c5c4..374effc 100644 --- a/clients/zctl/zctl_cmds.ct +++ b/clients/zctl/zctl_cmds.ct @@ -1,6 +1,4 @@ -# $Source$ -# $Author$ -# $Header$ +# $Id$ # command_table zctl_cmds; @@ -10,12 +8,6 @@ request cancel_subs, "Cancel all subscriptions.", cancel; - request loadall, "Subscribe to all subscriptions files.", - loadall, ldall; - - request loadall, "List all subscriptions files.", - listall, lsall; - request load_subs, "Subscribe to a subscriptions file.", load, ld; @@ -31,29 +23,17 @@ request subscribe, "Unsubscribe to a class/class instance.", unsubscribe, unsub; - request subscribe, "Suppress a class/class instance.", - suppress, punt; - - request subscribe, "Unsuppress to a class/class instance.", - unsuppress, unpunt; - request sub_file, "Subscribe and add to subscriptions file.", add; request sub_file, "Unsubscribe and add to subscriptions file\n as un-subscription.", add_unsubscription, add_un; - request sub_file, "Suppress and add to subscriptions file\n\t\t\t as suppression.", - add_suppression, add_punt; - - request sub_file, "Unsubscribe and delete subscription from\n\t\t\t subscriptions file.", + request sub_file, "Unsubscribe and delete subscription from\n subscriptions file.", delete, del, dl; request sub_file, "Delete un-subscription from subscriptions file.", delete_unsubscription, del_un; - request sub_file, "Unsuppress and delete suppression from\n\t\t\t subscriptions file.", - delete_suppression, del_punt; - request current, "Retrieve current subscriptions.", retrieve, ret; @@ -100,7 +80,7 @@ unhide; request ss_list_requests, "List available commands.", - list_requests, help, lr, "?"; + list_requests, lr, "?"; request ss_quit, "Quit.", quit, exit, q; diff --git a/clients/zctl/zutils.c b/clients/zctl/zutils.c deleted file mode 100644 index 87d54b8..0000000 --- a/clients/zctl/zutils.c +++ /dev/null @@ -1,500 +0,0 @@ -/* XXX this file is duplicated in clients/zctl and clients/zwgc, until - zctl is changed to message zwgc to perform these tasks */ - -#include <stdio.h> -#include <string.h> -#include <netdb.h> -#include <errno.h> - -#include <sys/param.h> - -#include <zephyr/zephyr.h> -#ifdef HAVE_KRB4 -#include <krb_err.h> -#endif - -#include "zutils.h" - -#ifdef ZWGC -#include "subscriptions.h" -#define ZGetWGPort() (ZGetPort()) -#endif - -#ifdef ZCTL -Code_t send_wgc_control(opcode, msg, len) - char *opcode; - char *msg; - int len; -{ - int retval; - short newport; - struct sockaddr_in oldsin, newsin; - ZNotice_t notice; - - oldsin = ZGetDestAddr(); - - if ((newport = ZGetWGPort()) == -1) { - return(errno); - } - - newsin = oldsin; - newsin.sin_port = (u_short) newport; - if ((retval = ZSetDestAddr(&newsin)) != ZERR_NONE) { - return(retval); - } - - (void) memset((char *)¬ice, 0, sizeof(notice)); - notice.z_kind = UNSAFE; - notice.z_port = 0; - notice.z_class = WG_CTL_CLASS; - notice.z_class_inst = WG_CTL_USER; - notice.z_opcode = opcode; - notice.z_sender = 0; - notice.z_recipient = ""; - notice.z_default_format = ""; - notice.z_dest_galaxy = ""; - notice.z_message = msg; - notice.z_message_len = len; - - if ((retval = ZSendNotice(¬ice,ZNOAUTH)) != ZERR_NONE) - return(retval); - - if ((retval = ZSetDestAddr(&oldsin)) != ZERR_NONE) { - return(retval); - } - -#if 0 - /* XXX why was this here? */ - if ((retval = ZInitialize()) != ZERR_NONE) - return(retval); -#endif -} -#endif - -void fix_macros(subs,subs2,num) - ZSubscription_t *subs,*subs2; - int num; -{ - int i; - - for (i=0;i<num;i++) { - subs2[i] = subs[i]; - fix_macros2(subs[i].zsub_class,&subs2[i].zsub_class); - fix_macros2(subs[i].zsub_classinst,&subs2[i].zsub_classinst); - fix_macros2(subs[i].zsub_recipient,&subs2[i].zsub_recipient); - } -} - -void fix_macros2(src,dest) - char *src; - char **dest; -{ - static char ourhost[MAXHOSTNAMELEN],ourhostcanon[MAXHOSTNAMELEN]; - struct hostent *hent; - - if (!*ourhost) { -#ifdef HAVE_SYS_UTSNAME - uname(&name); - strcpy(ourhost, name.nodename); -#else - if (gethostname(ourhost,MAXHOSTNAMELEN) == -1) { - /* XXX */ - com_err("",errno,"while getting host name"); - return; - } -#endif - } - - if (!*ourhostcanon) { - if (!(hent = gethostbyname(ourhost))) { - fprintf(stderr,"Can't get canonical name for host %s", - ourhost); - return; - } - - (void) strcpy(ourhostcanon,hent->h_name); - } - - if (!strcmp(src,TOKEN_HOSTNAME)) { - *dest = ourhost; - } else if (!strcmp(src,TOKEN_CANONNAME)) { - *dest = ourhostcanon; - } else if (!strcmp(src,TOKEN_ME)) { - *dest = ZGetSender(); - } -} - -Code_t set_exposure(zgalaxy, exposure) - char *zgalaxy; - char *exposure; -{ - char *exp_level, *galaxy_exp_level, zvar[1024]; - Code_t code, retval; - int cnt, i; - - exp_level = ZParseExposureLevel(exposure); - - if (zgalaxy && strcmp(zgalaxy, "*") == 0) { - if (retval = ZGetGalaxyCount(&cnt)) - return(retval); - - for (i=0; i<cnt; i++) { - if (retval = ZGetGalaxyName(i, &zgalaxy)) - return(retval); - - sprintf(zvar, "exposure-%s", zgalaxy); - - if (galaxy_exp_level = ZGetVariable(zvar)) { - if (strcmp(galaxy_exp_level, EXPOSE_NETVIS) == 0) - galaxy_exp_level = EXPOSE_REALMVIS; - else - galaxy_exp_level = ZParseExposureLevel(galaxy_exp_level); - } else if (galaxy_exp_level = exp_level) { - if (strcmp(galaxy_exp_level, EXPOSE_NETVIS) == 0) - galaxy_exp_level = EXPOSE_REALMVIS; - - if (i > 0) { - if (strcmp(galaxy_exp_level, EXPOSE_REALMVIS) == 0) - galaxy_exp_level = EXPOSE_OPSTAFF; - else if (strcmp(galaxy_exp_level, EXPOSE_REALMANN) == 0) - galaxy_exp_level = EXPOSE_OPSTAFF; - } else { - galaxy_exp_level = ZParseExposureLevel(galaxy_exp_level); - } - } else { - galaxy_exp_level = EXPOSE_NONE; - } - - if (strcmp(galaxy_exp_level, EXPOSE_NONE) == 0) - continue; - - if ((code = ZSetLocation(zgalaxy, exp_level)) != ZERR_NONE) { - retval = code; - continue; - } -#ifdef ZCTL - if (strcmp(exp_level,EXPOSE_NONE) == 0) { - if (code = send_wgc_control(USER_SHUTDOWN, NULL, 0)) { - retval = code; - continue; - } - } else { - if (code = send_wgc_control(USER_STARTUP, NULL, 0)) { - retval = code; - continue; - } - } -#endif - } -#ifdef HAVE_KRB4 - if (retval == KRBET_AD_NOTGT) - retval = ZERR_NONE; -#endif - return(retval); - } else { - if ((retval = ZSetLocation(zgalaxy, exp_level)) != ZERR_NONE) - return(retval); -#ifdef ZCTL - if (strcmp(exp_level,EXPOSE_NONE) == 0) { - if (retval = send_wgc_control(USER_SHUTDOWN, NULL, 0)) - return(retval); - } else { - if (retval = send_wgc_control(USER_STARTUP, NULL, 0)) - return(retval); - } -#endif - } -} - -#ifdef ZCTL -Code_t xpunt(zclass, zinst, zrecip, type) - char *zclass; - char *zinst; - char *zrecip; - int type; -{ - char *msg; - - msg = (char *) malloc(strlen(zclass) + strlen(zinst) + strlen(zrecip) + 3); - - sprintf(msg, "%s%c%s%c%s", zclass, '\0', zinst, '\0', zrecip); - - return(send_wgc_control((type == PUNT)?"SUPPRESS":"UNSUPPRESS", - msg, - strlen(zclass) + strlen(zinst) + - strlen(zrecip) + 3)); -} - -#elif defined(ZWGC) - -Code_t xpunt(zclass, zinst, zrecip, type) - char *zclass; - char *zinst; - char *zrecip; - int type; -{ - if (type == PUNT) - punt(zclass, zinst, zrecip); - else - unpunt(zclass, zinst, zrecip); - - return(ZERR_NONE); -} - -#endif - -Code_t load_sub_file(type, file, galaxy) - int type; - char *file; - char *galaxy; -{ - ZSubscription_t subs[SUBSATONCE],subs2[SUBSATONCE],unsubs[SUBSATONCE], - punts[1]; - FILE *fp; - int ind,unind,puntind,lineno,i,retval; - short wgport; - char *comma,*comma2,subline[BUFSIZ]; - - if (type != LIST) - if ((wgport = ZGetWGPort()) == -1) { - return(errno); - } - - if (file) { - fp = fopen(file,"r"); - - if ((fp == NULL) && (errno != ENOENT)) - return(errno); - } else { - fp = NULL; - } - - ind = unind = puntind = 0; - lineno = 1; - - /* this will fall through to subbing an empty list, giving the default - subs only */ - - if (fp) { - for (;;lineno++) { - if (!fgets(subline,sizeof subline,fp)) - break; - if (*subline == '#' || !*subline) - continue; - subline[strlen(subline)-1] = '\0'; /* nuke newline */ - comma = strchr(subline,','); - if (comma) - comma2 = strchr(comma+1,','); - else - comma2 = 0; - if (!comma || !comma2) { - fprintf(stderr, - "Malformed subscription at line %d of %s:\n%s\n", - lineno,file,subline); - continue; - } - *comma = '\0'; - *comma2 = '\0'; - if (type == LIST) { - if (*subline == '!') - printf("(Un-subscription) Class %s instance %s recipient %s\n", - subline+1, comma+1, comma2+1); - else if (*subline = '-') - printf("(Suppression) Class %s instance %s recipient %s\n", - subline+1, comma+1, comma2+1); - else - printf("Class %s instance %s recipient %s\n", - subline, comma+1, comma2+1); - continue; - } - if (*subline == '!') { /* an un-subscription */ - /* if we are explicitly un-subscribing to - the contents of a subscription file, ignore - any un-subscriptions in that file */ - if (type == UNSUB) - continue; - unsubs[unind].zsub_class = - (char *)malloc((unsigned)(strlen(subline))); - /* XXX check malloc return */ - /* skip the leading '!' */ - (void) strcpy(unsubs[unind].zsub_class,subline+1); - unsubs[unind].zsub_classinst = - (char *)malloc((unsigned)(strlen(comma+1)+1)); - /* XXX check malloc return */ - (void) strcpy(unsubs[unind].zsub_classinst,comma+1); - unsubs[unind].zsub_recipient = - (char *)malloc((unsigned)(strlen(comma2+1)+1)); - /* XXX check malloc return */ - (void) strcpy(unsubs[unind].zsub_recipient,comma2+1); - unind++; - } else if (*subline == '-') { /* an suppression */ - punts[puntind].zsub_class = - (char *)malloc((unsigned)(strlen(subline))); - /* XXX check malloc return */ - /* skip the leading '-' */ - (void) strcpy(punts[puntind].zsub_class,subline+1); - punts[puntind].zsub_classinst = - (char *)malloc((unsigned)(strlen(comma+1)+1)); - /* XXX check malloc return */ - (void) strcpy(punts[puntind].zsub_classinst,comma+1); - punts[puntind].zsub_recipient = - (char *)malloc((unsigned)(strlen(comma2+1)+1)); - /* XXX check malloc return */ - (void) strcpy(punts[puntind].zsub_recipient,comma2+1); - puntind++; - } else { - subs[ind].zsub_class = - (char *)malloc((unsigned)(strlen(subline)+1)); - /* XXX check malloc return */ - (void) strcpy(subs[ind].zsub_class,subline); - subs[ind].zsub_classinst = - (char *)malloc((unsigned)(strlen(comma+1)+1)); - /* XXX check malloc return */ - (void) strcpy(subs[ind].zsub_classinst,comma+1); - subs[ind].zsub_recipient = - (char *)malloc((unsigned)(strlen(comma2+1)+1)); - /* XXX check malloc return */ - (void) strcpy(subs[ind].zsub_recipient,comma2+1); - ind++; - } - if (ind == SUBSATONCE) { - fix_macros(subs,subs2,ind); - if ((retval = (type == SUB)? - ZSubscribeTo(galaxy, subs2,ind,(u_short)wgport): - ZUnsubscribeTo(galaxy, subs2,ind,(u_short)wgport)) != - ZERR_NONE) { - goto cleanup; - } - for (i=0;i<ind;i++) { - free(subs[i].zsub_class); - free(subs[i].zsub_classinst); - free(subs[i].zsub_recipient); - } - ind = 0; - } - if (unind == SUBSATONCE) { - fix_macros(unsubs,subs2,unind); - if ((retval = ZUnsubscribeTo(galaxy, subs2,unind,(u_short)wgport)) != ZERR_NONE) { - goto cleanup; - } - for (i=0;i<unind;i++) { - free(unsubs[i].zsub_class); - free(unsubs[i].zsub_classinst); - free(unsubs[i].zsub_recipient); - } - unind = 0; - } - if (puntind) { - fix_macros(punts,subs2,puntind); - - if (retval = xpunt(punts[0].zsub_class, - punts[0].zsub_classinst, - punts[0].zsub_recipient, - (type == SUB)?PUNT:UNPUNT)) - goto cleanup; - - free(punts[0].zsub_class); - free(punts[0].zsub_classinst); - free(punts[0].zsub_recipient); - - puntind = 0; - } - } - } - - if (type != LIST) { - /* even if we have no subscriptions, be sure to send - an empty packet to trigger the default subscriptions */ - fix_macros(subs,subs2,ind); - if ((retval = (type == SUB)?ZSubscribeTo(galaxy, subs2,ind,(u_short)wgport): - ZUnsubscribeTo(galaxy, subs2,ind,(u_short)wgport)) != ZERR_NONE) { - goto cleanup; - } - if (unind) { - fix_macros(unsubs,subs2,unind); - if ((retval = - ZUnsubscribeTo(galaxy, subs2,unind,(u_short)wgport)) != ZERR_NONE) { - goto cleanup; - } - } - } - - retval = 0; - -cleanup: - for (i=0;i<ind;i++) { - free(subs[i].zsub_class); - free(subs[i].zsub_classinst); - free(subs[i].zsub_recipient); - } - for (i=0;i<unind;i++) { - free(unsubs[i].zsub_class); - free(unsubs[i].zsub_classinst); - free(unsubs[i].zsub_recipient); - } - for (i=0;i<puntind;i++) { - free(unsubs[i].zsub_class); - free(unsubs[i].zsub_classinst); - free(unsubs[i].zsub_recipient); - } - - if (fp) - (void) fclose(fp); /* ignore errs--file is read-only */ - return(retval); -} - -Code_t load_all_sub_files(type, basefile) - int type; - char *basefile; -{ - Code_t retval, code; - int i, cnt; - char *galaxy, *exp; - char fn[MAXPATHLEN]; - - if (retval = ZGetGalaxyCount(&cnt)) - return(retval); - - for (i=0; i<cnt; i++) { - if (retval = ZGetGalaxyName(i, &galaxy)) - return(retval); - - strcpy(fn, "exposure-"); - strcat(fn, galaxy); - - if ((((exp = ZGetVariable(fn)) == NULL) && - ((exp = ZGetVariable("exposure")) == NULL)) || - (strcasecmp(exp, EXPOSE_NONE) == 0)) - /* skip this galaxy */ - continue; - - if (basefile) { - strcpy(fn, basefile); - strcat(fn, "-"); - strcat(fn, galaxy); - } - - if (type == LIST) - printf("For galaxy %s:\n", galaxy); - - if ((i == 0) && basefile) { - code = load_sub_file(type, basefile, galaxy); - if ((code != ZERR_NONE) && - (code != ENOENT)) - retval = code; - } - - code = load_sub_file(type, basefile?fn:NULL, galaxy); - if ((code != ZERR_NONE) && - (code != ENOENT)) - retval = code; - - if (type == LIST) - printf("\n"); - } -#ifdef HAVE_KRB4 - if (retval == KRBET_AD_NOTGT) - retval = ZERR_NONE; -#endif - return(retval); -} diff --git a/clients/zctl/zutils.h b/clients/zctl/zutils.h deleted file mode 100644 index 8c0a25d..0000000 --- a/clients/zctl/zutils.h +++ /dev/null @@ -1,28 +0,0 @@ -/* XXX this file is duplicated in clients/zctl and clients/zwgc, until - zctl is changed to message zwgc to perform these tasks */ - -#define ZCTL - -#include <zephyr/zephyr.h> - -#define TOKEN_HOSTNAME "%host%" -#define TOKEN_CANONNAME "%canon%" -#define TOKEN_ME "%me%" -#define TOKEN_WILD "*" - -#define SUBSATONCE 7 - -#define SUB 0 -#define UNSUB 1 -#define PUNT 2 -#define UNPUNT 3 -#define LIST 4 -#define ALL 5 - -Code_t send_wgc_control (char *, char *, int); -void fix_macros (ZSubscription_t *, ZSubscription_t *, int); -void fix_macros2 (char *src, char **dest); -Code_t set_exposure (char *, char *); -Code_t load_sub_file (int, char *, char *); -Code_t load_all_sub_files (int, char *); -Code_t xpunt (char *, char *, char *, int); diff --git a/clients/zleave/Makefile.in b/clients/zleave/Makefile.in index dc0e34b..cff622f 100644 --- a/clients/zleave/Makefile.in +++ b/clients/zleave/Makefile.in @@ -8,31 +8,32 @@ sbindir=@sbindir@ lsbindir=@lsbindir@ includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin +top_builddir=../.. srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la @LIBS@ -lcom_err +LDFLAGS=@LDFLAGS@ +LIBS=${LIBZEPHYR} @LIBS@ -lcom_err OBJS= zleave.o all: zleave -zleave: ${OBJS} ${BUILDTOP}/lib/libzephyr.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +zleave: ${OBJS} ${LIBZEPHYR} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} .c.o: ${CC} -c ${ALL_CFLAGS} $< @@ -40,11 +41,12 @@ zleave: ${OBJS} ${BUILDTOP}/lib/libzephyr.la check: install: zleave - ${LIBTOOL} ${INSTALL} -m 755 -s zleave ${DESTDIR}${bindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zleave.1 ${DESTDIR}${mandir}/man1 + ${LIBTOOL} --mode=install ${INSTALL} -m 755 zleave ${DESTDIR}${bindir} + ${INSTALL} -m 644 ${srcdir}/zleave.1 ${DESTDIR}${mandir}/man1 clean: - ${LIBTOOL} rm -f ${OBJS} zleave + ${LIBTOOL} --mode=clean rm -f zleave + rm -f ${OBJS} ${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h ${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h diff --git a/clients/zleave/zleave.c b/clients/zleave/zleave.c index edea16a..91e8c14 100644 --- a/clients/zleave/zleave.c +++ b/clients/zleave/zleave.c @@ -88,7 +88,7 @@ char **argv; sub.zsub_class = MESSAGE_CLASS; sub.zsub_classinst = INSTANCE; sub.zsub_recipient = ZGetSender(); - if (ZSubscribeToSansDefaults(NULL, &sub,1,(u_short)port) + if (ZSubscribeToSansDefaults(&sub,1,(u_short)port) != ZERR_NONE) { fprintf(stderr, "Subscription error! Writing to your terminal...\n"); diff --git a/clients/zlocate/Makefile.in b/clients/zlocate/Makefile.in index 2a6dd06..fe88f0e 100644 --- a/clients/zlocate/Makefile.in +++ b/clients/zlocate/Makefile.in @@ -8,31 +8,32 @@ sbindir=@sbindir@ lsbindir=@lsbindir@ includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin +top_builddir=../.. srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la @LIBS@ -lcom_err +LDFLAGS=@LDFLAGS@ +LIBS=${LIBZEPHYR} @LIBS@ -lcom_err OBJS= zlocate.o all: zlocate -zlocate: ${OBJS} ${BUILDTOP}/lib/libzephyr.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +zlocate: ${OBJS} ${LIBZEPHYR} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} .c.o: ${CC} -c ${ALL_CFLAGS} $< @@ -40,11 +41,12 @@ zlocate: ${OBJS} ${BUILDTOP}/lib/libzephyr.la check: install: zlocate - ${LIBTOOL} ${INSTALL} -m 755 -s zlocate ${DESTDIR}${bindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zlocate.1 ${DESTDIR}${mandir}/man1 + ${LIBTOOL} --mode=install ${INSTALL} -m 755 zlocate ${DESTDIR}${bindir} + ${INSTALL} -m 644 ${srcdir}/zlocate.1 ${DESTDIR}${mandir}/man1 clean: - ${LIBTOOL} rm -f ${OBJS} zlocate + ${LIBTOOL} --mode=clean rm -f zlocate + rm -f ${OBJS} ${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h ${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h diff --git a/clients/zlocate/zlocate.c b/clients/zlocate/zlocate.c index 8428274..4469565 100644 --- a/clients/zlocate/zlocate.c +++ b/clients/zlocate/zlocate.c @@ -72,7 +72,6 @@ main(argc,argv) char user[BUFSIZ],*whichuser; ZAsyncLocateData_t ald; int retval,i,numlocs,numfound,loc,auth,rlen; - char *galaxy; ZNotice_t notice; #ifdef _POSIX_VERSION struct sigaction sa; @@ -101,12 +100,6 @@ main(argc,argv) case '1': oneline = 1; break; - case 'G': - if (i+1 == argc) - usage(); - galaxy = argv[i+1]; - i++; - break; default: usage(); break; @@ -126,37 +119,27 @@ main(argc,argv) numleft = numusers; numfound = 0; + rlen = strlen(ZGetRealm()); i = 0; for (loc = 0; loc < argc; loc++) { - char *rhs; - - if (argv[loc][0] == '-') { - if (argv[loc][1] == 'G') - loc++; - continue; - } - - rhs = ZGetRhs(galaxy); - rlen = strlen(rhs); + if (argv[loc][0] == '-') continue; (void) strncpy(user,argv[loc],sizeof(user) - rlen - 2); user[sizeof(user) - rlen - 2] = '\0'; if (!strchr(user,'@')) { (void) strcat(user,"@"); - (void) strcat(user,rhs); + (void) strcat(user,ZGetRealm()); } if (parallel) { - if ((retval = ZRequestLocations(galaxy, user, &ald, - i ? UNSAFE : UNACKED, + if ((retval = ZRequestLocations(user, &ald, i ? UNSAFE : UNACKED, auth?ZAUTH:ZNOAUTH)) != ZERR_NONE) { com_err(whoami,retval,"requesting location of %s",user); exit(1); } i = 1; } else { - if ((retval = ZLocateUser(galaxy, user,&numlocs, - auth?ZAUTH:ZNOAUTH)) != ZERR_NONE) { + if ((retval = ZLocateUser(user,&numlocs,auth?ZAUTH:ZNOAUTH)) != ZERR_NONE) { com_err(whoami,retval,"while locating user %s",user); exit(1); } diff --git a/clients/zmailnotify/Makefile.in b/clients/zmailnotify/Makefile.in index 436d165..0461a60 100644 --- a/clients/zmailnotify/Makefile.in +++ b/clients/zmailnotify/Makefile.in @@ -8,31 +8,32 @@ sbindir=@sbindir@ lsbindir=@lsbindir@ includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin +top_builddir=../.. srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h -DKPOP ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la @LIBS@ -lcom_err +LDFLAGS=@LDFLAGS@ +LIBS=${LIBZEPHYR} @LIBS@ -lcom_err OBJS= zmailnotify.o all: zmailnotify -zmailnotify: ${OBJS} ${BUILDTOP}/lib/libzephyr.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +zmailnotify: ${OBJS} ${LIBZEPHYR} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} .c.o: ${CC} -c ${ALL_CFLAGS} $< @@ -40,11 +41,13 @@ zmailnotify: ${OBJS} ${BUILDTOP}/lib/libzephyr.la check: install: zmailnotify - ${LIBTOOL} ${INSTALL} -m 755 -s zmailnotify ${DESTDIR}${bindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zmailnotify.1 ${DESTDIR}${mandir}/man1 + ${LIBTOOL} --mode=install ${INSTALL} -m 755 zmailnotify \ + ${DESTDIR}${bindir} + ${INSTALL} -m 644 ${srcdir}/zmailnotify.1 ${DESTDIR}${mandir}/man1 clean: - ${LIBTOOL} rm -f ${OBJS} zmailnotify + ${LIBTOOL} --mode=clean rm -f zmailnotify + rm -f ${OBJS} ${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h ${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h diff --git a/clients/znol/Makefile.in b/clients/znol/Makefile.in index 84a7977..969e44b 100644 --- a/clients/znol/Makefile.in +++ b/clients/znol/Makefile.in @@ -8,31 +8,32 @@ sbindir=@sbindir@ lsbindir=@lsbindir@ includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin +top_builddir=../.. srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la @LIBS@ -lcom_err +LDFLAGS=@LDFLAGS@ +LIBS=${LIBZEPHYR} @LIBS@ -lcom_err OBJS= znol.o all: znol -znol: ${OBJS} ${BUILDTOP}/lib/libzephyr.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +znol: ${OBJS} ${LIBZEPHYR} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} .c.o: ${CC} -c ${ALL_CFLAGS} $< @@ -40,11 +41,12 @@ znol: ${OBJS} ${BUILDTOP}/lib/libzephyr.la check: install: znol - ${LIBTOOL} ${INSTALL} -m 755 -s znol ${DESTDIR}${bindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/znol.1 ${DESTDIR}${mandir}/man1 + ${LIBTOOL} --mode=install ${INSTALL} -m 755 znol ${DESTDIR}${bindir} + ${INSTALL} -m 644 ${srcdir}/znol.1 ${DESTDIR}${mandir}/man1 clean: - ${LIBTOOL} rm -f ${OBJS} znol + ${LIBTOOL} --mode=clean rm -f znol + rm -f ${OBJS} ${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h ${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h diff --git a/clients/znol/znol.c b/clients/znol/znol.c index 2c843c0..53fd47c 100644 --- a/clients/znol/znol.c +++ b/clients/znol/znol.c @@ -32,7 +32,7 @@ main(argc,argv) ZLocations_t locations; FILE *fp; struct passwd *pwd; - char anyonename[BUFSIZ],name[BUFSIZ],cleanname[BUFSIZ],galaxyname[BUFSIZ],*envptr; + char anyonename[BUFSIZ],name[BUFSIZ],cleanname[BUFSIZ],*envptr; char *comment_ptr; int onoff = ON,quiet = 0,justlist = 0,useronly = 0, filenamed = 0; int retval,arg,ind,one,numlocs,i; @@ -79,14 +79,6 @@ main(argc,argv) (void) strcpy(cleanname,argv[++arg]); useronly = 1; break; - case 'G': - if (arg == argc-1) { - fprintf(stderr,"No galaxy name specified\n"); - goto usage; - } - (void) strcpy(galaxyname,argv[++arg]); - useronly = 1; - break; default: goto usage; } @@ -162,7 +154,7 @@ main(argc,argv) if (!strchr(name,'@')) { cp = name + strlen(name); *cp++ = '@'; - (void) strcpy(cp, ZGetRhs(galaxyname)); + (void) strcpy(cp,ZGetRealm()); } if ((subs[ind].zsub_classinst = malloc((unsigned)(strlen(name)+1))) == NULL) { fprintf (stderr, "znol: out of memory"); @@ -172,7 +164,7 @@ main(argc,argv) subs[ind++].zsub_recipient = ""; if (!quiet && onoff == ON) { - if ((retval = ZLocateUser(galaxyname,name,&numlocs,ZAUTH)) + if ((retval = ZLocateUser(name,&numlocs,ZAUTH)) != ZERR_NONE) { com_err(argv[0],retval,"locating user"); exit(1); @@ -202,9 +194,9 @@ main(argc,argv) if (ind == SUBSATONCE) { if (!justlist) if ((retval = (onoff==ON)? - ZSubscribeToSansDefaults(galaxyname,subs,ind, + ZSubscribeToSansDefaults(subs,ind, (u_short)wgport): - ZUnsubscribeTo(galaxyname,subs,ind,(u_short)wgport)) != + ZUnsubscribeTo(subs,ind,(u_short)wgport)) != ZERR_NONE) { com_err(argv[0],retval,(onoff==ON)? "subscribing": @@ -219,8 +211,8 @@ main(argc,argv) if (ind && !justlist) if ((retval = (onoff==ON)? - ZSubscribeToSansDefaults(galaxyname,subs,ind,(u_short)wgport): - ZUnsubscribeTo(galaxyname,subs,ind,(u_short)wgport)) != + ZSubscribeToSansDefaults(subs,ind,(u_short)wgport): + ZUnsubscribeTo(subs,ind,(u_short)wgport)) != ZERR_NONE) { com_err(argv[0],retval,(onoff==ON)? "subscribing": diff --git a/clients/zpopnotify/Makefile.in b/clients/zpopnotify/Makefile.in index 7a0f9ce..020a181 100644 --- a/clients/zpopnotify/Makefile.in +++ b/clients/zpopnotify/Makefile.in @@ -8,31 +8,32 @@ sbindir=@sbindir@ lsbindir=@lsbindir@ includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin +top_builddir=../.. srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la @LIBS@ -lcom_err +LDFLAGS=@LDFLAGS@ +LIBS=${LIBZEPHYR} @LIBS@ -lcom_err OBJS= zpopnotify.o all: zpopnotify -zpopnotify: ${OBJS} ${BUILDTOP}/lib/libzephyr.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +zpopnotify: ${OBJS} ${LIBZEPHYR} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} .c.o: ${CC} -c ${ALL_CFLAGS} $< @@ -40,11 +41,13 @@ zpopnotify: ${OBJS} ${BUILDTOP}/lib/libzephyr.la check: install: zpopnotify - ${LIBTOOL} ${INSTALL} -m 755 -s zpopnotify ${DESTDIR}${sbindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zpopnotify.8 ${DESTDIR}${mandir}/man8 + ${LIBTOOL} --mode=install ${INSTALL} -m 755 zpopnotify \ + ${DESTDIR}${sbindir} + ${INSTALL} -m 644 ${srcdir}/zpopnotify.8 ${DESTDIR}${mandir}/man8 clean: - ${LIBTOOL} rm -f ${OBJS} zpopnotify + ${LIBTOOL} --mode=clean rm -f zpopnotify + rm -f ${OBJS} ${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h ${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h diff --git a/clients/zpopnotify/zpopnotify.c b/clients/zpopnotify/zpopnotify.c index b6488c6..b2f79e3 100644 --- a/clients/zpopnotify/zpopnotify.c +++ b/clients/zpopnotify/zpopnotify.c @@ -71,7 +71,7 @@ main(argc,argv) lines[1] = "You have new mail."; (void) strcpy(mysender,"pop@"); - (void) strcat(mysender,ZGetRhs(NULL)); + (void) strcat(mysender,ZGetRealm()); for (i = 1; i < argc; i++) { (void) memset((char *)¬ice, 0, sizeof(notice)); diff --git a/clients/zshutdown_notify/Makefile.in b/clients/zshutdown_notify/Makefile.in index 31c8d4d..f619a09 100644 --- a/clients/zshutdown_notify/Makefile.in +++ b/clients/zshutdown_notify/Makefile.in @@ -8,31 +8,32 @@ sbindir=@sbindir@ lsbindir=@lsbindir@ includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin +top_builddir=../.. srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la @LIBS@ -lcom_err +LDFLAGS=@LDFLAGS@ +LIBS=${LIBZEPHYR} @LIBS@ -lcom_err OBJS= zshutdown_notify.o all: zshutdown_notify -zshutdown_notify: ${OBJS} ${BUILDTOP}/lib/libzephyr.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +zshutdown_notify: ${OBJS} ${LIBZEPHYR} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} .c.o: ${CC} -c ${ALL_CFLAGS} $< @@ -40,11 +41,13 @@ zshutdown_notify: ${OBJS} ${BUILDTOP}/lib/libzephyr.la check: install: zshutdown_notify - ${LIBTOOL} ${INSTALL} -m 755 -s zshutdown_notify ${DESTDIR}${lsbindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zshutdown_notify.8 ${DESTDIR}${mandir}/man8 + ${LIBTOOL} --mode=install ${INSTALL} -m 755 zshutdown_notify \ + ${DESTDIR}${lsbindir} + ${INSTALL} -m 644 ${srcdir}/zshutdown_notify.8 ${DESTDIR}${mandir}/man8 clean: - ${LIBTOOL} rm -f ${OBJS} zshutdown_notify + ${LIBTOOL} --mode=clean rm -f zshutdown_notify + rm -f ${OBJS} ${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h ${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h diff --git a/clients/zstat/Makefile.in b/clients/zstat/Makefile.in index aa6f92c..d5aae02 100644 --- a/clients/zstat/Makefile.in +++ b/clients/zstat/Makefile.in @@ -8,31 +8,32 @@ sbindir=@sbindir@ lsbindir=@lsbindir@ includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin +top_builddir=../.. srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la @LIBS@ -lcom_err +LDFLAGS=@LDFLAGS@ +LIBS=${LIBZEPHYR} @LIBS@ -lcom_err OBJS= zstat.o all: zstat -zstat: ${OBJS} ${BUILDTOP}/lib/libzephyr.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +zstat: ${OBJS} ${LIBZEPHYR} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} .c.o: ${CC} -c ${ALL_CFLAGS} $< @@ -40,11 +41,12 @@ zstat: ${OBJS} ${BUILDTOP}/lib/libzephyr.la check: install: zstat - ${LIBTOOL} ${INSTALL} -m 755 -s zstat ${DESTDIR}${bindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zstat.8 ${DESTDIR}${mandir}/man8 + ${LIBTOOL} --mode=install ${INSTALL} -m 755 zstat ${DESTDIR}${bindir} + ${INSTALL} -m 644 ${srcdir}/zstat.8 ${DESTDIR}${mandir}/man8 clean: - ${LIBTOOL} rm -f ${OBJS} zstat + ${LIBTOOL} --mode=clean rm -f zstat + rm -f ${OBJS} ${OBJS}: zserver.h ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h ${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h diff --git a/clients/zstat/zstat.c b/clients/zstat/zstat.c index 1ed7054..0c034f9 100644 --- a/clients/zstat/zstat.c +++ b/clients/zstat/zstat.c @@ -22,7 +22,7 @@ static const char rcsid_zstat_c[] = "$Id$"; #endif const char *hm_head[] = { - "Current server:", + "Current server =", "Items in queue:", "Client packets received:", "Server packets received:", @@ -124,18 +124,22 @@ do_stat(host) return; } - hm_stat(host, !hmonly); + if (hm_stat(host,srv_host)) + return; + + if (!hmonly) + (void) srv_stat(srv_host); } -hm_stat(host, do_server) - char *host; - int do_server; +int +hm_stat(host,server) + char *host,*server; { struct in_addr inaddr; Code_t code; - char **line,*mp; - int sock,i,nf,ret; + char *line[20],*mp; + int i,nf; struct hostent *hp; time_t runtime; struct tm *tim; @@ -157,55 +161,36 @@ hm_stat(host, do_server) } if ((code = ZhmStat(&inaddr, ¬ice)) != ZERR_NONE) { - com_err("zstat", ret, "getting hostmanager status"); + com_err("zstat", code, "getting hostmanager status"); exit(-1); } - for (nf=0, mp = notice.z_message; - mp<notice.z_message+notice.z_message_len; - nf++, mp += strlen(mp)+1) - ; - - line = (char **) malloc(sizeof(char *)*nf); - mp = notice.z_message; - for (nf=0, mp = notice.z_message; - mp<notice.z_message+notice.z_message_len; - nf++, mp += strlen(mp)+1) + for (nf=0;mp<notice.z_message+notice.z_message_len;nf++) { line[nf] = mp; + mp += strlen(mp)+1; + } + (void) strcpy(server,line[0]); - printf("HostManager protocol version = %s\n\n",notice.z_version); + printf("HostManager protocol version = %s\n",notice.z_version); - for (i=0; i<nf; i++) { - if (((i%(HM_SIZE+2)) == 0) && (i+HM_SIZE<nf)) { - printf("Zephyr galaxy = %s\n", line[i+HM_SIZE]); - printf("%s %s\n",hm_head[i%(HM_SIZE+2)],line[i]); - } else if ((i%(HM_SIZE+2)) == 7) { + for (i=0; (i < nf) && (i < HM_SIZE); i++) { + if (!strncmp("Time",hm_head[i],4)) { runtime = atol(line[i]); tim = gmtime(&runtime); - printf("%s %d days, %02d:%02d:%02d\n", hm_head[i%(HM_SIZE+1)], + printf("%s %d days, %02d:%02d:%02d\n", hm_head[i], tim->tm_yday, tim->tm_hour, tim->tm_min, tim->tm_sec); - } else if ((i%(HM_SIZE+2)) == HM_SIZE) { - /* do nothing */ - } else if (((i%(HM_SIZE+2)) == (HM_SIZE+1)) || - (i == nf-1)) { - printf("\n"); - if (do_server) { - srv_stat(line[i-(i%(HM_SIZE+2))]); - printf("\n"); - } - } else { - printf("%s %s\n",hm_head[i%(HM_SIZE+2)],line[i]); } + else + printf("%s %s\n",hm_head[i],line[i]); } - - free(line); - (void) close(sock); + printf("\n"); + ZFreeNotice(¬ice); return(0); } @@ -315,6 +300,7 @@ srv_stat(host) printf("%s\n",line[i]); } else printf("%s\n",line[i]); } + printf("\n"); (void) close(sock); ZFreeNotice(¬ice); diff --git a/clients/zwrite/Makefile.in b/clients/zwrite/Makefile.in index 6701250..304f268 100644 --- a/clients/zwrite/Makefile.in +++ b/clients/zwrite/Makefile.in @@ -8,31 +8,32 @@ sbindir=@sbindir@ lsbindir=@lsbindir@ includedir=${prefix}/include -mandir=@mandir@ +mandir=${prefix}/man libdir=${exec_prefix}/lib bindir=${exec_prefix}/bin +top_builddir=../.. srcdir=@srcdir@ top_srcdir=@top_srcdir@ -top_builddir=../.. BUILDTOP=../.. VPATH=@srcdir@ +LIBTOOL=@LIBTOOL@ CC=@CC@ INSTALL=@INSTALL@ -LIBTOOL=@LIBTOOL@ +LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS} -LDFLAGS=-L${BUILDTOP}/lib @LDFLAGS@ -LIBS=${BUILDTOP}/lib/libzephyr.la @LIBS@ -lcom_err +LDFLAGS=@LDFLAGS@ +LIBS=${LIBZEPHYR} @LIBS@ -lcom_err OBJS= zwrite.o all: zwrite -zwrite: ${OBJS} ${BUILDTOP}/lib/libzephyr.la - ${LIBTOOL} ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} +zwrite: ${OBJS} ${LIBZEPHYR} + ${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS} .c.o: ${CC} -c ${ALL_CFLAGS} $< @@ -40,11 +41,12 @@ zwrite: ${OBJS} ${BUILDTOP}/lib/libzephyr.la check: install: zwrite - ${LIBTOOL} ${INSTALL} -m 755 -s zwrite ${DESTDIR}${bindir} - ${LIBTOOL} ${INSTALL} -m 644 ${srcdir}/zwrite.1 ${DESTDIR}${mandir}/man1 + ${LIBTOOL} --mode=install ${INSTALL} -m 755 zwrite ${DESTDIR}${bindir} + ${INSTALL} -m 644 ${srcdir}/zwrite.1 ${DESTDIR}${mandir}/man1 clean: - ${LIBTOOL} rm -f ${OBJS} zwrite + ${LIBTOOL} --mode=clean rm -f zwrite + rm -f ${OBJS} ${OBJS}: ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h ${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h diff --git a/clients/zwrite/zwrite.1 b/clients/zwrite/zwrite.1 index 64453af..822177b 100644 --- a/clients/zwrite/zwrite.1 +++ b/clients/zwrite/zwrite.1 @@ -264,7 +264,7 @@ Service' .SH FILES /etc/passwd .br -$HOME/.zephyr.vars +$ZEPHYR_VARS or $HOME/.zephyr.vars .SH AUTHOR .PP .br diff --git a/clients/zwrite/zwrite.c b/clients/zwrite/zwrite.c index ebd4a41..f5dba36 100644 --- a/clients/zwrite/zwrite.c +++ b/clients/zwrite/zwrite.c @@ -29,7 +29,7 @@ static const char rcsid_zwrite_c[] = "$Id$"; #define MAXRECIPS 100 int nrecips, msgarg, verbose, quiet, nodot, cc; -char *whoami, *inst, *class, *opcode, *rhs, *galaxy, *recips[MAXRECIPS]; +char *whoami, *inst, *class, *opcode, *realm, *recips[MAXRECIPS]; Z_AuthProc auth; void un_tabify(); @@ -174,13 +174,7 @@ main(argc, argv) if (arg == argc-1) usage(whoami); arg++; - rhs = argv[arg]; - break; - case 'G': - if (arg == argc-1) - usage(whoami); - arg++; - galaxy = argv[arg]; + realm = argv[arg]; break; case 'C': cc = 1; @@ -230,7 +224,6 @@ main(argc, argv) notice.z_sender = 0; notice.z_message_len = 0; notice.z_recipient = ""; - notice.z_dest_galaxy = galaxy; if (format) notice.z_default_format = format; else if (filsys == 1) @@ -350,15 +343,15 @@ send_off(notice, real) int real; { int i, success, retval; - char bfr[BUFSIZ], rhs_recip[BUFSIZ], dest[3 * BUFSIZ], *cp; + char bfr[BUFSIZ], realm_recip[BUFSIZ], dest[3 * BUFSIZ], *cp; ZNotice_t retnotice; success = 0; - for (i=0;i<nrecips || !nrecips;i++) { - if (rhs) { - sprintf(rhs_recip, "%s@%s", (nrecips) ? recips[i] : "", rhs); - notice->z_recipient = rhs_recip; + for (i=0;i<nrecips || i==0;i++) { + if (realm) { + sprintf(realm_recip, "%s@%s", (nrecips) ? recips[i] : "", realm); + notice->z_recipient = realm_recip; } else { notice->z_recipient = (nrecips) ? recips[i] : ""; } @@ -446,8 +439,6 @@ send_off(notice, real) else printf("Internal failure - illegal message field in server response\n"); ZFreeNotice(&retnotice); - if (!nrecips) - break; } if (!success) exit(1); @@ -459,9 +450,8 @@ usage(s) { fprintf(stderr, "Usage: %s [-a] [-o] [-d] [-v] [-q] [-n] [-t] [-u] [-l]\n\ -\t[-c class] [-i inst] [-O opcode] [-f fsname] [-s signature] \n\ -\t[-G galaxy] [-C]\n\ -\t[user ...] [-F format] [-r rhs] [-m message]\n", s); +\t[-c class] [-i inst] [-O opcode] [-f fsname] [-s signature] [-C]\n\ +\t[user ...] [-F format] [-r realm] [-m message]\n", s); fprintf(stderr,"\t-f and -c are mutually exclusive\n\ \t-f and -i are mutually exclusive\n\ \trecipients must be specified unless -c or -f specifies a class\n\ |