X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Ftools%2Fgsprintconsole.c;h=7f3dae2a1d79a509571fdcb39d69c4b1e06a6ab9;hb=refs%2Fchanges%2F78%2F4778%2F1;hp=4b18ab56862d2c441d6c68c59c656edc2c8b09d8;hpb=c9783d8ea8b85d810483559e50dbf2297109e349;p=com%2Fgs-lite.git diff --git a/src/tools/gsprintconsole.c b/src/tools/gsprintconsole.c index 4b18ab5..7f3dae2 100644 --- a/src/tools/gsprintconsole.c +++ b/src/tools/gsprintconsole.c @@ -38,6 +38,7 @@ static char linebuf[MAXLINE]; int listensockfd=0; int fd=0; +FILE* outf; // 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) { - printf("%s",linebuf); + fprintf(outf,"%s",linebuf); } 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; + char sep_str[2]; + 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]); + + // 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) { + case 's': + sep_str[0]=','; + break; case 'r': bufsz=atoi(optarg); break; @@ -174,6 +185,9 @@ int main(int argc, char* argv[]) { case 'v': verbose++; break; + case 'e': + outf = stderr; + break; case 'X': xit++; break; @@ -185,7 +199,7 @@ int main(int argc, char* argv[]) { break; default: usage: - fprintf(stderr, "usage: %s [-r ] [-p ] [-l ] [-v] [-X] [-D] : query param1 param2...\n", + fprintf(stderr, "usage: %s [-r ] [-e] [-p ] [-l ] [-v] [-X] [-D] : query param1 param2...\n", *argv); exit(1); } @@ -432,7 +446,8 @@ int main(int argc, char* argv[]) { linebuf[0]=0; break; } - if (y