From d2200fc25e3ae0c04e349a80b979476ee156d215 Mon Sep 17 00:00:00 2001 From: "Narasimhaiah Suprathik (RBEI/ECF3)" Date: Mon, 7 Dec 2020 16:27:57 +0530 Subject: lib: Add MaxFileSize handling Signed-Off By: Saya Sugiura --- src/examples/dlt-example-user.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/examples/dlt-example-user.c') diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c index 6ede605..8c79c42 100644 --- a/src/examples/dlt-example-user.c +++ b/src/examples/dlt-example-user.c @@ -98,6 +98,7 @@ void usage() printf("Options:\n"); printf(" -d delay Milliseconds to wait between sending messages (Default: 500)\n"); printf(" -f filename Use local log file instead of sending to daemon\n"); + printf(" -S filesize Set maximum size of local log file (Default: UINT_MAX)\n"); printf(" -n count Number of messages to be generated (Default: 10)\n"); printf(" -g Switch to non-verbose mode (Default: verbose mode)\n"); printf(" -a Enable local printing of DLT messages (Default: disabled)\n"); @@ -130,6 +131,7 @@ int main(int argc, char *argv[]) #endif /* DLT_TEST_ENABLE */ char *dvalue = 0; char *fvalue = 0; + unsigned int filesize = 0; char *nvalue = 0; char *mvalue = 0; char *message = 0; @@ -152,10 +154,10 @@ int main(int argc, char *argv[]) opterr = 0; #ifdef DLT_TEST_ENABLE - while ((c = getopt (argc, argv, "vgakcd:f:n:m:z:r:s:l:t:A:C:")) != -1) + while ((c = getopt (argc, argv, "vgakcd:f:S:n:m:z:r:s:l:t:A:C:")) != -1) #else - while ((c = getopt (argc, argv, "vgakd:f:n:m:l:r:t:A:C:")) != -1) + while ((c = getopt (argc, argv, "vgakd:f:S:n:m:l:r:t:A:C:")) != -1) #endif /* DLT_TEST_ENABLE */ { switch (c) { @@ -201,6 +203,11 @@ int main(int argc, char *argv[]) fvalue = optarg; break; } + case 'S': + { + filesize = atoi(optarg); + break; + } case 'n': { nvalue = optarg; @@ -238,7 +245,8 @@ int main(int argc, char *argv[]) } case '?': { - if ((optopt == 'd') || (optopt == 'f') || (optopt == 'n') || (optopt == 'l') || (optopt == 't')) + if ((optopt == 'd') || (optopt == 'f') || (optopt == 'n') || + (optopt == 'l') || (optopt == 't') || (optopt == 'S')) fprintf (stderr, "Option -%c requires an argument.\n", optopt); else if (isprint (optopt)) fprintf (stderr, "Unknown option `-%c'.\n", optopt); @@ -279,6 +287,11 @@ int main(int argc, char *argv[]) return -1; } + if (filesize != 0) { + if (dlt_set_filesize_max(filesize) < 0) + return -1; + } + dlt_with_session_id(1); dlt_with_timestamp(1); dlt_with_ecu_id(1); -- cgit v1.2.1