- 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';
static int cmd_err ( char *args[], WRBUF outbuff)
{
wrbuf_printf(outbuff, "errCode: %d \nerrStr: %s\nerrAdd: %s \n",
static int cmd_err ( char *args[], WRBUF outbuff)
{
wrbuf_printf(outbuff, "errCode: %d \nerrStr: %s\nerrAdd: %s \n",
return 0; /* ok */
}
static int cmd_errcode ( char *args[], WRBUF outbuff)
{
wrbuf_printf(outbuff, "errCode: %d \n",
return 0; /* ok */
}
static int cmd_errcode ( char *args[], WRBUF outbuff)
{
wrbuf_printf(outbuff, "errCode: %d \n",
return 0; /* ok */
}
static int cmd_errstr ( char *args[], WRBUF outbuff)
{
wrbuf_printf(outbuff, "errStr: %s\n",
return 0; /* ok */
}
static int cmd_errstr ( char *args[], WRBUF outbuff)
{
wrbuf_printf(outbuff, "errStr: %s\n",
return 0; /* ok */
}
static int cmd_erradd ( char *args[], WRBUF outbuff)
{
wrbuf_printf(outbuff, "errAdd: %s \n",
return 0; /* ok */
}
static int cmd_erradd ( char *args[], WRBUF outbuff)
{
wrbuf_printf(outbuff, "errAdd: %s \n",
{
char *db=defarg(args[1],DEFAULTDATABASE);
wrbuf_printf(outbuff,"Creating database '%s'\n",db);
{
char *db=defarg(args[1],DEFAULTDATABASE);
wrbuf_printf(outbuff,"Creating database '%s'\n",db);
char *rec=restargs(args,4);
if (!(base && id && action && args[4] ))
{
char *rec=restargs(args,4);
if (!(base && id && action && args[4] ))
{
- wrbuf_puts(outbuff,"Missing arguments!\n");
- onecommand("help exchange_record", outbuff, "");
- return -90;
+ wrbuf_puts(outbuff,"Missing arguments!\n");
+ onecommand("help exchange_record", outbuff, "");
+ return -90;
}
rc=zebra_admin_exchange_record(zh, base, rec, strlen(rec),
id, strlen(id), atoi(action));
}
rc=zebra_admin_exchange_record(zh, base, rec, strlen(rec),
id, strlen(id), atoi(action));
wrbuf_puts(qry, "@attr 1=/ ");
wrbuf_puts(qry,restargs(args,1));
if (!zh)
wrbuf_puts(qry, "@attr 1=/ ");
wrbuf_puts(qry,restargs(args,1));
if (!zh)
wrbuf_printf(outbuff, "find %s\n",wrbuf_buf(qry));
rc=zebra_search_PQF(zh, wrbuf_buf(qry), setname, &hits);
if (0==rc)
wrbuf_printf(outbuff, "find %s\n",wrbuf_buf(qry));
rc=zebra_search_PQF(zh, wrbuf_buf(qry), setname, &hits);
if (0==rc)
recs[i].position=start+i;
rc = zebra_records_retrieve (zh, odr, setname,
recs[i].position=start+i;
rc = zebra_records_retrieve (zh, odr, setname,
- pcomp, format, nrecs,recs);
+ pcomp, format, nrecs,recs);
argbuf[MAX_ARG_LEN-1]='\0'; /* just to be sure */
/*memset(args,'\0',MAX_NO_ARGS*sizeof(char *));*/
nargs=split_args(argbuf, args);
argbuf[MAX_ARG_LEN-1]='\0'; /* just to be sure */
/*memset(args,'\0',MAX_NO_ARGS*sizeof(char *));*/
nargs=split_args(argbuf, args);
if (nargs>1) /* 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 (nargs>1) /* 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);
- 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;
wrbuf_printf(outbuff, "Unknown command '%s'. Try help\n",args[0]);
logf(LOG_APP,"Unknown command");
return -90;
- 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,
wrbuf_printf(outbuff,"%s %s\n%s\n",
cmds[i].cmd, cmds[i].args,
- 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);
- 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);
- 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));