Code Review
/
com
/
gs-lite.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Default to non-blocking ringbuffers
[com/gs-lite.git]
/
src
/
tools
/
gsprintconsole.c
diff --git
a/src/tools/gsprintconsole.c
b/src/tools/gsprintconsole.c
index
4b18ab5
..
7f3dae2
100644
(file)
--- a/
src/tools/gsprintconsole.c
+++ b/
src/tools/gsprintconsole.c
@@
-38,6
+38,7
@@
static char linebuf[MAXLINE];
int listensockfd=0;
int fd=0;
int listensockfd=0;
int fd=0;
+FILE* outf;
// Not all systems have timersub defined so make sure its ther
#ifndef timersub
// Not all systems have timersub defined so make sure its ther
#ifndef timersub
@@
-123,7
+124,7
@@
static void emit_socket() {
static void emit_line() {
if (tcpport==0) {
static void emit_line() {
if (tcpport==0) {
-
printf(
"%s",linebuf);
+
fprintf(outf,
"%s",linebuf);
} else {
emit_socket();
}
} else {
emit_socket();
}
@@
-157,14
+158,24
@@
int main(int argc, char* argv[]) {
gs_uint32_t tip1,tip2,tip3,tip4;
gs_sp_t instance_name;
gs_uint32_t tip1,tip2,tip3,tip4;
gs_sp_t instance_name;
+ char sep_str[2];
+
gs_uint32_t tlimit = 0; // time limit in seconds
time_t start_time, curr_time;
gs_uint32_t tlimit = 0; // time limit in seconds
time_t start_time, curr_time;
+
+ sep_str[0] = '|';
+ sep_str[1] = '\0';
gsopenlog(argv[0]);
gsopenlog(argv[0]);
+
+ // by default the output will go to stdout
+ outf = stdout;
-
- while ((ch = getopt(argc, argv, "l:p:r:vXD")) != -1) {
+ while ((ch = getopt(argc, argv, "l:p:r:sveXD")) != -1) {
switch (ch) {
switch (ch) {
+ case 's':
+ sep_str[0]=',';
+ break;
case 'r':
bufsz=atoi(optarg);
break;
case 'r':
bufsz=atoi(optarg);
break;
@@
-174,6
+185,9
@@
int main(int argc, char* argv[]) {
case 'v':
verbose++;
break;
case 'v':
verbose++;
break;
+ case 'e':
+ outf = stderr;
+ break;
case 'X':
xit++;
break;
case 'X':
xit++;
break;
@@
-185,7
+199,7
@@
int main(int argc, char* argv[]) {
break;
default:
usage:
break;
default:
usage:
- fprintf(stderr, "usage: %s [-r <bufsz>] [-p <port>] [-l <time_limit>] [-v] [-X] [-D] <gshub-hostname>:<gshub-port> <gsinstance_name> query param1 param2...\n",
+ fprintf(stderr, "usage: %s [-r <bufsz>] [-
e] [-
p <port>] [-l <time_limit>] [-v] [-X] [-D] <gshub-hostname>:<gshub-port> <gsinstance_name> query param1 param2...\n",
*argv);
exit(1);
}
*argv);
exit(1);
}
@@
-432,7
+446,8
@@
int main(int argc, char* argv[]) {
linebuf[0]=0;
break;
}
linebuf[0]=0;
break;
}
- if (y<numberoffields-1) snprintf(&linebuf[strlen(linebuf)],MAXLINE,"|");
+// if (y<numberoffields-1) snprintf(&linebuf[strlen(linebuf)],MAXLINE,"|");
+ if (y<numberoffields-1) snprintf(&linebuf[strlen(linebuf)],MAXLINE,sep_str);
emit_line();
}
snprintf(linebuf,MAXLINE,"\n");
emit_line();
}
snprintf(linebuf,MAXLINE,"\n");