From 1e716038fe1265f207175ce6b3ac06893ed26122 Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Mon, 12 Oct 2009 17:51:50 +0000 Subject: ss_perror -> com_err As a precursor to loosening the dependency on ss. (Thanks to Ken Raeburn) --- clients/zctl/zctl.c | 88 +++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 43 deletions(-) (limited to 'clients') diff --git a/clients/zctl/zctl.c b/clients/zctl/zctl.c index 43ffbf5..47d7628 100644 --- a/clients/zctl/zctl.c +++ b/clients/zctl/zctl.c @@ -52,6 +52,7 @@ void del_file(short, ZSubscription_t *, int); void fix_macros(ZSubscription_t *, ZSubscription_t *, int); void fix_macros2(char *, char **); int make_exist(char *); +char *whoami; int main(int argc, @@ -65,6 +66,7 @@ main(int argc, struct utsname name; #endif + whoami = argv[0]; if ((retval = ZInitialize()) != ZERR_NONE) { com_err(argv[0],retval,"while initializing"); exit (1); @@ -175,7 +177,7 @@ flush_locations(int argc, } if ((retval = ZFlushMyLocations()) != ZERR_NONE) - ss_perror(sci_idx,retval,"while flushing locations"); + com_err(whoami, retval, "while flushing locations"); } void @@ -195,13 +197,13 @@ wgc_control(int argc, } if ((newport = ZGetWGPort()) == -1) { - ss_perror(sci_idx,errno,"while getting WindowGram port"); + com_err(whoami, 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"); + com_err(whoami, retval, "while setting destination address"); return; } @@ -231,10 +233,10 @@ wgc_control(int argc, notice.z_message_len = 0; if ((retval = ZSendNotice(¬ice,ZNOAUTH)) != ZERR_NONE) - ss_perror(sci_idx,retval,"while sending notice"); + com_err(whoami, retval, "while sending notice"); if ((retval = ZInitialize()) != ZERR_NONE) - ss_perror(sci_idx,retval, + com_err(whoami, retval, "while reinitializing"); } @@ -271,7 +273,7 @@ hm_control(int argc, notice.z_message_len = 0; if ((retval = ZSendNotice(¬ice,ZNOAUTH)) != ZERR_NONE) - ss_perror(sci_idx,retval,"while sending notice"); + com_err(whoami, retval, "while sending notice"); } void @@ -354,7 +356,7 @@ set_var(int argc, char *argv[]) } if (retval != ZERR_NONE) { - ss_perror(sci_idx,retval,"while setting variable value"); + com_err(whoami, retval, "while setting variable value"); return; } @@ -362,7 +364,7 @@ set_var(int argc, char *argv[]) if (setting_exp) { if ((retval = ZSetLocation(exp_level)) != ZERR_NONE) - ss_perror(sci_idx,retval,"while changing exposure status"); + com_err(whoami, retval, "while changing exposure status"); if (!strcmp(exp_level,EXPOSE_NONE)) { newargv[0] = "wg_shutdown"; wgc_control(1,newargv); @@ -390,7 +392,7 @@ do_hide(int argc, else exp_level = EXPOSE_OPSTAFF; if ((retval = ZSetLocation(exp_level)) != ZERR_NONE) - ss_perror(sci_idx,retval,"while changing exposure status"); + com_err(whoami,retval,"while changing exposure status"); return; } @@ -408,7 +410,7 @@ unset_var(int argc, for (i=1;izsub_class, subs->zsub_classinst, subs->zsub_recipient); if (fclose(fp) == EOF) { (void) sprintf(errbuf, "while closing %s", subsname); - ss_perror(sci_idx, errno, errbuf); + com_err(whoami, errno, errbuf); return; } fix_macros(subs,&sub2,1); @@ -543,7 +545,7 @@ add_file(short wgport, ? ZUnsubscribeTo(&sub2,1,(u_short)wgport) : ZSubscribeToSansDefaults(&sub2,1,(u_short)wgport)); if (retval) - ss_perror(sci_idx,retval, + com_err(whoami, retval, unsub ? "while unsubscribing" : "while subscribing"); return; @@ -569,7 +571,7 @@ del_file(short wgport, fix_macros(subs,&sub2,1); if ((retval = ZUnsubscribeTo(&sub2,1,(u_short)wgport)) != ZERR_NONE) - ss_perror(sci_idx,retval,"while unsubscribing"); + com_err(whoami, retval, "while unsubscribing"); return; } @@ -589,7 +591,7 @@ purge_subs(register ZSubscription_t *subs, case ALL: break; default: - ss_perror(sci_idx,0,"internal error in purge_subs"); + com_err(whoami, 0, "internal error in purge_subs"); return(ERR); } @@ -600,7 +602,7 @@ purge_subs(register ZSubscription_t *subs, if (!(fp = fopen(subsname,"r"))) { (void) sprintf(errbuf,"while opening %s for read",subsname); - ss_perror(sci_idx,errno,errbuf); + com_err(whoami, errno, errbuf); return(ERR); } (void) strcpy(backup, subsname); @@ -608,7 +610,7 @@ purge_subs(register ZSubscription_t *subs, (void) unlink(backup); if (!(fpout = fopen(backup,"w"))) { (void) sprintf(errbuf,"while opening %s for writing",backup); - ss_perror(sci_idx,errno,errbuf); + com_err(whoami, errno, errbuf); (void) fclose(fp); return(ERR); } @@ -635,7 +637,7 @@ purge_subs(register ZSubscription_t *subs, if (ferror(fpout) || (fputc('\n', fpout) == EOF)) { (void) sprintf(errbuf, "while writing to %s", backup); - ss_perror(sci_idx, errno, errbuf); + com_err(whoami, errno, errbuf); } } else delflag = REMOVED; @@ -643,13 +645,13 @@ purge_subs(register ZSubscription_t *subs, (void) fclose(fp); /* open read-only, ignore errs */ if (fclose(fpout) == EOF) { (void) sprintf(errbuf, "while closing %s",backup); - ss_perror(sci_idx, errno, errbuf); + com_err(whoami, errno, errbuf); return(ERR); } if (rename(backup,subsname) == -1) { (void) sprintf(errbuf,"while renaming %s to %s\n", backup,subsname); - ss_perror(sci_idx,errno,errbuf); + com_err(whoami, errno, errbuf); return(ERR); } return(delflag); @@ -684,7 +686,7 @@ load_subs(int argc, if (type != LIST) if ((wgport = ZGetWGPort()) == -1) { - ss_perror(sci_idx,errno, + com_err(whoami, errno, "while finding WindowGram port"); return; } @@ -694,7 +696,7 @@ load_subs(int argc, fp = fopen(file,"r"); if (fp == NULL) { - ss_perror(sci_idx,errno, + com_err(whoami, errno, "while loading subscription file"); return; } @@ -799,7 +801,7 @@ load_subs(int argc, if (retval = ZPunt(subs2,pind,(u_short)wgport) != ZERR_NONE) { - ss_perror(sci_idx,retval, + com_err(whoami, retval, "while punting"); goto cleanup; } @@ -817,7 +819,7 @@ load_subs(int argc, ZSubscribeTo(subs2,ind,(u_short)wgport): ZUnsubscribeTo(subs2,ind,(u_short)wgport)) != ZERR_NONE) { - ss_perror(sci_idx,retval,(type == SUB)? + com_err(whoami, retval, (type == SUB) ? "while subscribing": "while unsubscribing"); goto cleanup; @@ -832,7 +834,7 @@ load_subs(int argc, if (unind == SUBSATONCE) { fix_macros(unsubs,subs2,unind); if ((retval = ZUnsubscribeTo(subs2,unind,(u_short)wgport)) != ZERR_NONE) { - ss_perror(sci_idx,retval, + com_err(whoami, retval, "while unsubscribing to un-subscriptions"); goto cleanup; } @@ -851,7 +853,7 @@ load_subs(int argc, 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)? + com_err(whoami, retval, (type == SUB) ? "while subscribing": "while unsubscribing"); goto cleanup; @@ -860,7 +862,7 @@ load_subs(int argc, fix_macros(unsubs,subs2,unind); if ((retval = ZUnsubscribeTo(subs2,unind,(u_short)wgport)) != ZERR_NONE) { - ss_perror(sci_idx,retval, + com_err(whoami, retval, "while unsubscribing to un-subscriptions"); goto cleanup; } @@ -871,7 +873,7 @@ load_subs(int argc, if (retval = ZPunt(subs2,pind,(u_short)wgport) != ZERR_NONE) { - ss_perror(sci_idx,retval, + com_err(whoami,retval, "while punting"); goto cleanup; } @@ -928,7 +930,7 @@ current(int argc, if (!defs) if ((wgport = ZGetWGPort()) == -1) { - ss_perror(sci_idx,errno, + com_err(whoami, errno, "while finding WindowGram port"); return; } @@ -947,7 +949,7 @@ current(int argc, } else if (retval != ZERR_NONE) { - ss_perror(sci_idx,retval,"retrieving subscriptions"); + com_err(whoami, retval, "retrieving subscriptions"); return; } @@ -958,7 +960,7 @@ current(int argc, if (!(fp = fopen(backup,"w"))) { (void) sprintf(errbuf,"while opening %s for write", backup); - ss_perror(sci_idx,errno,errbuf); + com_err(whoami, errno, errbuf); return; } } @@ -966,7 +968,7 @@ current(int argc, for (i=0;i