From 9d902359e729980cc1844cce2b5b83d72a4367d3 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 23 Sep 2003 09:53:08 +0000 Subject: [PATCH] WS --- index/zebrash.c | 208 +++++++++++++++++++++++++++---------------------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/index/zebrash.c b/index/zebrash.c index efa8b2d..fceab10 100644 --- a/index/zebrash.c +++ b/index/zebrash.c @@ -1,4 +1,4 @@ -/* $Id: zebrash.c,v 1.20 2003-07-07 14:56:04 heikki Exp $ +/* $Id: zebrash.c,v 1.21 2003-09-23 09:53:08 adam Exp $ Copyright (C) 2002,2003 Index Data Aps @@ -76,28 +76,28 @@ static int split_args( char *line, char** args ) p++; while (*p) { - while (*p==' ' || *p=='\t' || *p=='\n') - p++; - if (*p=='#') /* skip comments */ - break; - args[i++]=p; - args[i]=0; - while (*p && *p!=' ' && *p!='\t' && *p!='\n' && *p!='#') - p++; - *p++='\0'; + while (*p==' ' || *p=='\t' || *p=='\n') + p++; + if (*p=='#') /* skip comments */ + break; + args[i++]=p; + args[i]=0; + while (*p && *p!=' ' && *p!='\t' && *p!='\n' && *p!='#') + p++; + *p++='\0'; } n=i; while (n1) /* args[0] is not yet set, can't use restargs */ rest= line + (args[1]-argbuf); /* rest of the line */ else return -1; /* need something to expect */ - if (0==strstr(prevout,rest)) - { - printf( "Failed expectation, '%s' not found\n", rest); + if (0==strstr(prevout,rest)) + { + printf( "Failed expectation, '%s' not found\n", rest); exit(9); - } - return 0; + } + return 0; } for (i=0;cmds[i].cmd;i++) - if (0==strcmp(cmds[i].cmd, args[0])) - { - if (nargs>1) - args[0]= line + (args[1]-argbuf); /* rest of the line */ - else - args[0]=""; - return ((cmds[i].testfunc)(args,outbuff)); - } + if (0==strcmp(cmds[i].cmd, args[0])) + { + if (nargs>1) + args[0]= line + (args[1]-argbuf); /* rest of the line */ + else + args[0]=""; + return ((cmds[i].testfunc)(args,outbuff)); + } wrbuf_printf(outbuff, "Unknown command '%s'. Try help\n",args[0]); logf(LOG_APP,"Unknown command"); return -90; @@ -641,20 +641,20 @@ static int cmd_help( char *args[], WRBUF outbuff) int linelen; if (args[1]) { /* help for a single command */ - for (i=0;cmds[i].cmd;i++) - if (0==strcmp(cmds[i].cmd, args[1])) - { + for (i=0;cmds[i].cmd;i++) + if (0==strcmp(cmds[i].cmd, args[1])) + { wrbuf_printf(outbuff,"%s %s\n%s\n", cmds[i].cmd, cmds[i].args, - cmds[i].explanation); - return 0; - } - wrbuf_printf(outbuff, "Unknown command '%s'", args[1]); - } + cmds[i].explanation); + return 0; + } + wrbuf_printf(outbuff, "Unknown command '%s'", args[1]); + } else { /* list all commands */ linelen=9999; - for (i=0;cmds[i].cmd;i++) + for (i=0;cmds[i].cmd;i++) { if (*cmds[i].cmd) { /* ordinary command */ @@ -682,20 +682,20 @@ static void Zerrors ( WRBUF outbuff) { int ec; if (!zh) - return ; + return ; ec=zebra_errCode (zh); if (ec) { - logf(LOG_APP, " Zebra error %d: %s, (%s)", - ec, zebra_errString (zh), - zebra_errAdd (zh) ); - wrbuf_printf(outbuff, " Zebra error %d: %s, (%s)\n", - ec, zebra_errString (zh), - zebra_errAdd (zh) ); - zebra_clearError(zh); + logf(LOG_APP, " Zebra error %d: %s, (%s)", + ec, zebra_errString (zh), + zebra_errAdd (zh) ); + wrbuf_printf(outbuff, " Zebra error %d: %s, (%s)\n", + ec, zebra_errString (zh), + zebra_errAdd (zh) ); + zebra_clearError(zh); } } - + /************************************** * The shell */ @@ -708,48 +708,48 @@ void shell() wrbuf_puts(outbuff,"Zebrash at your service"); while (rc!=-99) { - char buf[MAX_ARG_LEN]; + char buf[MAX_ARG_LEN]; #if HAVE_READLINE_READLINE_H - char* line_in; - line_in=readline(PROMPT); - if (!line_in) - break; + char* line_in; + line_in=readline(PROMPT); + if (!line_in) + break; #if HAVE_READLINE_HISTORY_H - if (*line_in) - add_history(line_in); + if (*line_in) + add_history(line_in); #endif - if(strlen(line_in) > MAX_ARG_LEN-1) { - fprintf(stderr,"Input line too long\n"); - break; - } - strcpy(buf,line_in); - free (line_in); + if(strlen(line_in) > MAX_ARG_LEN-1) { + fprintf(stderr,"Input line too long\n"); + break; + } + strcpy(buf,line_in); + free (line_in); #else - printf (PROMPT); - fflush (stdout); - if (!fgets (buf, MAX_ARG_LEN-1, stdin)) - break; + printf (PROMPT); + fflush (stdout); + if (!fgets (buf, MAX_ARG_LEN-1, stdin)) + break; #endif - strncpy(prevout, wrbuf_buf(outbuff), MAX_OUT_BUFF); + strncpy(prevout, wrbuf_buf(outbuff), MAX_OUT_BUFF); wrbuf_rewind(outbuff); - rc=onecommand(buf, outbuff, prevout); - if (rc==0) - { - wrbuf_puts(outbuff, " OK\n"); - logf(LOG_APP, "OK"); - } - else if (rc>-90) - { - wrbuf_printf(outbuff, " command returned %d\n",rc); - } - Zerrors(outbuff); - printf("%s\n", wrbuf_buf(outbuff)); + rc=onecommand(buf, outbuff, prevout); + if (rc==0) + { + wrbuf_puts(outbuff, " OK\n"); + logf(LOG_APP, "OK"); + } + else if (rc>-90) + { + wrbuf_printf(outbuff, " command returned %d\n",rc); + } + Zerrors(outbuff); + printf("%s\n", wrbuf_buf(outbuff)); } /* while */ wrbuf_free(outbuff,1); } /* shell() */ - - + + /************************************** * Main */ -- 1.7.10.4