From 5ed89738ffdb2065e7e0a2a002763eb9b1d5ea4e Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Sat, 17 Oct 2009 13:40:34 -0400 Subject: ifdef'd no-ss code (from Ken Raeburn) --- clients/zctl/zctl.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) (limited to 'clients') diff --git a/clients/zctl/zctl.c b/clients/zctl/zctl.c index 7f420c5..1607524 100644 --- a/clients/zctl/zctl.c +++ b/clients/zctl/zctl.c @@ -12,7 +12,9 @@ #include #include +#ifdef HAVE_SS #include +#endif #include #include #include @@ -41,11 +43,15 @@ static const char rcsid_zctl_c[] = "$Id$"; #define NOT_REMOVED 0 #define REMOVED 1 +#ifdef HAVE_SS int sci_idx; +#endif char subsname[BUFSIZ]; char ourhost[NS_MAXDNAME], ourhostcanon[NS_MAXDNAME]; +#ifdef HAVE_SS extern ss_request_table zctl_cmds; +#endif int purge_subs(register ZSubscription_t *, int); void add_file(short, ZSubscription_t *, int); @@ -55,6 +61,11 @@ void fix_macros2(char *, char **); int make_exist(char *); char *whoami; +#ifndef HAVE_SS +static void run_command(int, char *[]); +static void show_commands(int, char *[]); +#endif + int main(int argc, char *argv[]) @@ -125,12 +136,22 @@ main(int argc, } else strncpy(ourhostcanon,hent->h_name,sizeof(ourhostcanon)-1); +#ifdef HAVE_SS sci_idx = ss_create_invocation("zctl","",0,&zctl_cmds,&code); if (code) { ss_perror(sci_idx,code,"while creating invocation"); exit(1); +#else + if (argc <= 1) { + printf("ZCTL $Revision$ (Protocol %s%d.%d)\nType '%s help' for a list of subcommands.\n\n", + ZVERSIONHDR, + ZVERSIONMAJOR,ZVERSIONMINOR, + argv[0]); + exit(0); +#endif } +#ifdef HAVE_SS if (argc > 1) { *ssline = '\0'; for (i=1;i DOCCOL - 2) { + printf("\n"); + col = 0; + } + printf("%*s", DOCCOL - col, ""); + str = commands[i].doc; + while ((s = strchr(str, '\n')) != NULL) { + printf("%.*s\n%*s", (int)(s-str), str, DOCCOL, ""); + str = s+1; + } + printf("%s\n", str); + } +} + +static void +run_command(int argc, char *argv[]) +{ + int i, j; + for (i = 0; i < MAXCOMMAND; i++) + for (j = 0; j < MAXNAMES; j++) + if (commands[i].names[j] != NULL && + !strcmp(commands[i].names[j], argv[0])) { + commands[i].fptr(argc, argv); + return; + } + com_err(whoami, 0, + "Unknown command '%s'; use '%s help' for a list of commands.", + argv[0], whoami); + exit(1); +} +#endif -- cgit v1.2.3