Add data port
authorAlexey Chernobaev <achernobaev@dev.rtsoft.ru>
Tue, 28 Aug 2018 20:03:27 +0000 (23:03 +0300)
committerAleksei Vereshchagin <avereschagin@dev.rtsoft.ru>
Mon, 3 Sep 2018 15:21:42 +0000 (18:21 +0300)
README.md
profctl.c

index 1253f7f346c050619687666685e337b0bf4c519c..2a2fe73dab954161e60924520189955f7bf44d46 100644 (file)
--- a/README.md
+++ b/README.md
@@ -32,7 +32,9 @@ profctl [options...]
   waiting timeout in seconds
 * `-w, --pipe-owner`
   make profctl responsible on pipe management (create/unlink)
-* `-s, --server=port`
-  server port for control and data output
-* `-S, --stat=port`
+* `-c, --control=port`
+  server port for control
+* `-d, --data=port`
+  server port for data output
+* `-s, --stat=port`
   server port for statistic output
index 0df6dd310636403d2e39b3069469d4c45223240e..26f21736faf289b1768ee1cf5e17f5c6ca353250 100644 (file)
--- a/profctl.c
+++ b/profctl.c
@@ -49,8 +49,10 @@ static char *oname = NULL;
 static int isPipeOwner = 0;
 
 static int controlPort = -1;
+static int dataPort = -1;
 static int statPort = -1;
 static FILE *ctrl_file_in = NULL;
+static FILE *ctrl_file_out = NULL;
 static FILE *data_file_out = NULL;
 static FILE *stat_file_out = NULL;
 
@@ -64,9 +66,10 @@ static struct option long_options[] = {
        {"list",        no_argument,       0, 'l'},
        {"info",        no_argument,       0, 'i'},
        {"pipe-owner",  no_argument,       0, 'w'},
-       {"server",      required_argument, 0, 's'},
-       {"stat",        required_argument, 0, 'S'},
-       {0,         0,                 0,  0}
+       {"control",     required_argument, 0, 'c'},
+       {"data",        required_argument, 0, 'd'},
+       {"stat",        required_argument, 0, 's'},
+       {0, 0, 0, 0}
 };
 
 static void log_current_time()
@@ -399,7 +402,7 @@ static int process_option(int argc, char **argv)
 {
        int option_index;
 
-       switch(getopt_long(argc, argv, "-a:p:vle:o:it:ws:S:",
+       switch(getopt_long(argc, argv, "-a:p:vle:o:it:wc:d:s:",
                long_options, &option_index)) {
        case 1:
                if (appid == NULL) {
@@ -420,8 +423,9 @@ static int process_option(int argc, char **argv)
        case 'i': doinfo = 1; break;
        case 't': timeoutMicrosec = atoi(optarg) * 1000; break;
        case 'w': isPipeOwner = 1; break;
-       case 's': controlPort = atoi(optarg); break;
-       case 'S': statPort = atoi(optarg); break;
+       case 'c': controlPort = atoi(optarg); break;
+       case 'd': dataPort = atoi(optarg); break;
+       case 's': statPort = atoi(optarg); break;
        default:
                return -1;
        }
@@ -679,7 +683,7 @@ int main(int argc, char **argv)
        }
 
 #if TIZEN
-       if (controlPort < 0 && statPort < 0) {
+       if (controlPort < 0 && dataPort < 0 && statPort < 0) {
                /* stty */
                tcgetattr(0, &term);
                sterm = term;
@@ -699,6 +703,14 @@ int main(int argc, char **argv)
                }
        }
 
+       if (dataPort > 0) {
+               int s = openPort(dataPort);
+               data_file_out = fdopen(s, "w");
+               if (data_file_out == NULL) {
+                       log_system_error_and_exit("fdopen(data,w)");
+               }
+       }
+
        if (doinfo && (statPort > 0)) {
                int s = openPort(statPort);
                stat_file_out = fdopen(s, "w");